@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,10 @@
|
|
|
1
|
+
//! Root module of the default embeddable static library (`zig build lib`):
|
|
2
|
+
//! exports the `native_sdk_app_*` C ABI answered by the fixed WebView
|
|
3
|
+
//! shell host. Libraries compiled with a user app use
|
|
4
|
+
//! `app_exports.zig` (via `native_sdk.addMobileLib`) instead.
|
|
5
|
+
|
|
6
|
+
const native_sdk = @import("native_sdk");
|
|
7
|
+
|
|
8
|
+
comptime {
|
|
9
|
+
native_sdk.embed.exportMobileCApi(native_sdk.embed.MobileHostApp);
|
|
10
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
//! Declared platform chrome over the embed C ABI.
|
|
2
|
+
//!
|
|
3
|
+
//! Apps declare a tab set (and optionally one primary floating action)
|
|
4
|
+
//! in shell metadata (`ShellConfig.chrome`); a projecting host reads the
|
|
5
|
+
//! declaration through the `native_sdk_app_chrome_*` exports and builds
|
|
6
|
+
//! REAL native controls from it — on iOS an actual system tab bar and a
|
|
7
|
+
//! real button, styled by the OS, never imitated in canvas. Everything
|
|
8
|
+
//! here is read-only projection plumbing:
|
|
9
|
+
//!
|
|
10
|
+
//! - `MobileChromeItem` carries one declared tab or the primary action
|
|
11
|
+
//! across the ABI (static manifest strings, valid for the app's
|
|
12
|
+
//! lifetime).
|
|
13
|
+
//! - `selectedTabIndex` maps the model's selected tab id (the UiApp's
|
|
14
|
+
//! `selected_tab_fn` derivation) onto the declared set, so the host's
|
|
15
|
+
//! projection poll is one integer compare per frame.
|
|
16
|
+
//! - `renderIconPixels` rasterizes a declared icon-vocabulary glyph
|
|
17
|
+
//! through the same vector core the canvas draws with, into a
|
|
18
|
+
//! white-on-transparent RGBA8 template the system control tints —
|
|
19
|
+
//! the artwork stays the app's, the styling stays the platform's. An
|
|
20
|
+
//! unresolvable name renders the honest missing glyph, exactly like a
|
|
21
|
+
//! broken icon reference in canvas.
|
|
22
|
+
//!
|
|
23
|
+
//! Taps travel the OTHER direction over the existing command path
|
|
24
|
+
//! (`native_sdk_app_command` with the tab or action id), so selection
|
|
25
|
+
//! state lives in the model and the whole loop replays deterministically
|
|
26
|
+
//! from the Msg journal — the native bar is never the source of truth.
|
|
27
|
+
|
|
28
|
+
const std = @import("std");
|
|
29
|
+
const canvas = @import("canvas");
|
|
30
|
+
const app_manifest = @import("app_manifest");
|
|
31
|
+
const platform = @import("../platform/root.zig");
|
|
32
|
+
|
|
33
|
+
/// One declared chrome tab (or the primary action) over the C ABI. The
|
|
34
|
+
/// string pointers reference the app's static shell metadata and stay
|
|
35
|
+
/// valid for the app's lifetime.
|
|
36
|
+
pub const MobileChromeItem = extern struct {
|
|
37
|
+
id: ?[*]const u8 = null,
|
|
38
|
+
id_len: usize = 0,
|
|
39
|
+
label: ?[*]const u8 = null,
|
|
40
|
+
label_len: usize = 0,
|
|
41
|
+
icon: ?[*]const u8 = null,
|
|
42
|
+
icon_len: usize = 0,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
pub fn chromeItemFromTab(tab: app_manifest.ShellTab) MobileChromeItem {
|
|
46
|
+
return .{
|
|
47
|
+
.id = tab.id.ptr,
|
|
48
|
+
.id_len = tab.id.len,
|
|
49
|
+
.label = tab.label.ptr,
|
|
50
|
+
.label_len = tab.label.len,
|
|
51
|
+
.icon = if (tab.icon.len > 0) tab.icon.ptr else null,
|
|
52
|
+
.icon_len = tab.icon.len,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
pub fn chromeItemFromAction(action: app_manifest.ShellPrimaryAction) MobileChromeItem {
|
|
57
|
+
return .{
|
|
58
|
+
.id = action.id.ptr,
|
|
59
|
+
.id_len = action.id.len,
|
|
60
|
+
.label = action.label.ptr,
|
|
61
|
+
.label_len = action.label.len,
|
|
62
|
+
.icon = if (action.icon.len > 0) action.icon.ptr else null,
|
|
63
|
+
.icon_len = action.icon.len,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// The declared tab whose id equals the model's selected id, or -1 when
|
|
68
|
+
/// the selection names no declared tab (including the empty pre-install
|
|
69
|
+
/// selection) — the host projects "no selected item" honestly instead of
|
|
70
|
+
/// defaulting to the first tab.
|
|
71
|
+
pub fn selectedTabIndex(tabs: []const app_manifest.ShellTab, selected_id: []const u8) isize {
|
|
72
|
+
if (selected_id.len == 0) return -1;
|
|
73
|
+
for (tabs, 0..) |tab, index| {
|
|
74
|
+
if (std.mem.eql(u8, tab.id, selected_id)) return @intCast(index);
|
|
75
|
+
}
|
|
76
|
+
return -1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// Form-factor ordinals over the C ABI, matching `platform.FormFactor`
|
|
80
|
+
/// (0 unknown, 1 compact, 2 regular). Out-of-range reports clamp to
|
|
81
|
+
/// unknown so a newer host never poisons an older library.
|
|
82
|
+
pub fn formFactorFromInt(value: c_int) platform.FormFactor {
|
|
83
|
+
return switch (value) {
|
|
84
|
+
1 => .compact,
|
|
85
|
+
2 => .regular,
|
|
86
|
+
else => .unknown,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// Coverage sink accumulating anti-aliased alpha into a square
|
|
91
|
+
/// tightly-packed RGBA8 buffer as premultiplied white — the template
|
|
92
|
+
/// image shape native controls tint (UIKit reads the alpha channel;
|
|
93
|
+
/// white keeps non-template consumers visible too). Overlapping shapes
|
|
94
|
+
/// keep the maximum coverage per pixel, matching how the reference
|
|
95
|
+
/// renderer composites an icon's fill and stroke of one color.
|
|
96
|
+
const TemplateSink = struct {
|
|
97
|
+
pixels: []u8,
|
|
98
|
+
size: usize,
|
|
99
|
+
|
|
100
|
+
pub fn pixel(self: *TemplateSink, x: i32, y: i32, coverage: f32) void {
|
|
101
|
+
if (x < 0 or y < 0) return;
|
|
102
|
+
const px: usize = @intCast(x);
|
|
103
|
+
const py: usize = @intCast(y);
|
|
104
|
+
if (px >= self.size or py >= self.size) return;
|
|
105
|
+
const alpha: u8 = @intFromFloat(@round(std.math.clamp(coverage, 0, 1) * 255));
|
|
106
|
+
const base = (py * self.size + px) * 4;
|
|
107
|
+
if (alpha <= self.pixels[base + 3]) return;
|
|
108
|
+
self.pixels[base + 0] = alpha;
|
|
109
|
+
self.pixels[base + 1] = alpha;
|
|
110
|
+
self.pixels[base + 2] = alpha;
|
|
111
|
+
self.pixels[base + 3] = alpha;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
pub const IconRenderError = error{
|
|
116
|
+
InvalidIconRequest,
|
|
117
|
+
} || canvas.vector.Error;
|
|
118
|
+
|
|
119
|
+
/// Rasterize the icon-vocabulary glyph named `name` into `pixels` — a
|
|
120
|
+
/// tightly packed `size_px` x `size_px` RGBA8 buffer, premultiplied
|
|
121
|
+
/// white on transparent (a template image). Resolution follows the
|
|
122
|
+
/// canvas draw seam exactly (`icons.resolveOrMissing`): built-ins by
|
|
123
|
+
/// bare name, app-registered icons under `app:`, and any non-empty name
|
|
124
|
+
/// that resolves nowhere renders the visible missing glyph rather than
|
|
125
|
+
/// nothing. The icon is fitted contain-centered into the square with
|
|
126
|
+
/// stroke widths scaled, the same transform the widget draw paths use.
|
|
127
|
+
pub fn renderIconPixels(name: []const u8, size_px: usize, pixels: []u8) IconRenderError!void {
|
|
128
|
+
if (name.len == 0 or size_px == 0 or size_px > canvas.vector.max_raster_width) return error.InvalidIconRequest;
|
|
129
|
+
if (pixels.len != size_px * size_px * 4) return error.InvalidIconRequest;
|
|
130
|
+
const icon = canvas.icons.resolveOrMissing(name) orelse return error.InvalidIconRequest;
|
|
131
|
+
@memset(pixels, 0);
|
|
132
|
+
|
|
133
|
+
const box = icon.view_box;
|
|
134
|
+
const extent: f32 = @floatFromInt(size_px);
|
|
135
|
+
const scale = @min(extent / box.width, extent / box.height);
|
|
136
|
+
if (!(scale > 0)) return error.InvalidIconRequest;
|
|
137
|
+
const transform = canvas.Affine{
|
|
138
|
+
.a = scale,
|
|
139
|
+
.b = 0,
|
|
140
|
+
.c = 0,
|
|
141
|
+
.d = scale,
|
|
142
|
+
.tx = (extent - box.width * scale) * 0.5 - box.x * scale,
|
|
143
|
+
.ty = (extent - box.height * scale) * 0.5 - box.y * scale,
|
|
144
|
+
};
|
|
145
|
+
const clip = canvas.vector.ClipRect{
|
|
146
|
+
.x0 = 0,
|
|
147
|
+
.y0 = 0,
|
|
148
|
+
.x1 = @intCast(size_px),
|
|
149
|
+
.y1 = @intCast(size_px),
|
|
150
|
+
};
|
|
151
|
+
var sink = TemplateSink{ .pixels = pixels, .size = size_px };
|
|
152
|
+
for (icon.shapes) |shape| {
|
|
153
|
+
const elements = icon.elements[shape.start .. shape.start + shape.len];
|
|
154
|
+
if (shape.style.fill != .none) {
|
|
155
|
+
try canvas.vector.fillPath(elements, transform, .nonzero, canvas.vector.default_tolerance, clip, &sink);
|
|
156
|
+
}
|
|
157
|
+
if (shape.style.stroke != .none and shape.style.stroke_width > 0) {
|
|
158
|
+
try canvas.vector.strokePath(elements, transform, .{
|
|
159
|
+
// Stroke geometry is generated in DEVICE space (the
|
|
160
|
+
// transform has already run), so the authored viewBox
|
|
161
|
+
// width scales with the icon.
|
|
162
|
+
.width = shape.style.stroke_width * scale,
|
|
163
|
+
.cap = shape.style.linecap,
|
|
164
|
+
.join = shape.style.linejoin,
|
|
165
|
+
}, canvas.vector.default_tolerance, clip, &sink);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const geometry = @import("geometry");
|
|
3
|
+
const canvas = @import("canvas");
|
|
4
|
+
const runtime = @import("../runtime/root.zig");
|
|
5
|
+
const platform = @import("../platform/root.zig");
|
|
6
|
+
const types = @import("types.zig");
|
|
7
|
+
|
|
8
|
+
const MobileWidgetRole = types.MobileWidgetRole;
|
|
9
|
+
const MobileWidgetFlag = types.MobileWidgetFlag;
|
|
10
|
+
const MobileWidgetAction = types.MobileWidgetAction;
|
|
11
|
+
const MobileWidgetActionKind = types.MobileWidgetActionKind;
|
|
12
|
+
const MobileWidgetSemantics = types.MobileWidgetSemantics;
|
|
13
|
+
const MobileWidgetTextGeometry = types.MobileWidgetTextGeometry;
|
|
14
|
+
const MobileViewportState = types.MobileViewportState;
|
|
15
|
+
const MobileGpuFrameState = types.MobileGpuFrameState;
|
|
16
|
+
|
|
17
|
+
pub fn mobileViewportStateFromSurface(surface: platform.Surface) MobileViewportState {
|
|
18
|
+
const content = geometry.RectF.fromSize(surface.size).deflate(combinedMobileViewportInsets(surface));
|
|
19
|
+
return .{
|
|
20
|
+
.width = surface.size.width,
|
|
21
|
+
.height = surface.size.height,
|
|
22
|
+
.scale = surface.scale_factor,
|
|
23
|
+
.has_surface = if (surface.native_handle != null) 1 else 0,
|
|
24
|
+
.safe_top = surface.safe_area_insets.top,
|
|
25
|
+
.safe_right = surface.safe_area_insets.right,
|
|
26
|
+
.safe_bottom = surface.safe_area_insets.bottom,
|
|
27
|
+
.safe_left = surface.safe_area_insets.left,
|
|
28
|
+
.keyboard_top = surface.keyboard_insets.top,
|
|
29
|
+
.keyboard_right = surface.keyboard_insets.right,
|
|
30
|
+
.keyboard_bottom = surface.keyboard_insets.bottom,
|
|
31
|
+
.keyboard_left = surface.keyboard_insets.left,
|
|
32
|
+
.content_x = content.x,
|
|
33
|
+
.content_y = content.y,
|
|
34
|
+
.content_width = content.width,
|
|
35
|
+
.content_height = content.height,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub fn mobileGpuFrameStateFromFrame(frame: platform.GpuFrame) MobileGpuFrameState {
|
|
40
|
+
return .{
|
|
41
|
+
.surface_id = frame.surface_id,
|
|
42
|
+
.window_id = frame.window_id,
|
|
43
|
+
.width = frame.size.width,
|
|
44
|
+
.height = frame.size.height,
|
|
45
|
+
.scale = frame.scale_factor,
|
|
46
|
+
.frame_index = frame.frame_index,
|
|
47
|
+
.timestamp_ns = frame.timestamp_ns,
|
|
48
|
+
.frame_interval_ns = frame.frame_interval_ns,
|
|
49
|
+
.input_timestamp_ns = frame.input_timestamp_ns,
|
|
50
|
+
.input_latency_ns = frame.input_latency_ns,
|
|
51
|
+
.input_latency_budget_ns = frame.input_latency_budget_ns,
|
|
52
|
+
.input_latency_budget_exceeded_count = frame.input_latency_budget_exceeded_count,
|
|
53
|
+
.input_latency_budget_ok = if (frame.input_latency_budget_ok) 1 else 0,
|
|
54
|
+
.first_frame_latency_ns = frame.first_frame_latency_ns,
|
|
55
|
+
.first_frame_latency_budget_ns = frame.first_frame_latency_budget_ns,
|
|
56
|
+
.first_frame_latency_budget_exceeded_count = frame.first_frame_latency_budget_exceeded_count,
|
|
57
|
+
.first_frame_latency_budget_ok = if (frame.first_frame_latency_budget_ok) 1 else 0,
|
|
58
|
+
.nonblank = if (frame.nonblank) 1 else 0,
|
|
59
|
+
.sample_color = frame.sample_color,
|
|
60
|
+
.status = @intFromEnum(frame.status),
|
|
61
|
+
.vsync = if (frame.vsync) 1 else 0,
|
|
62
|
+
.canvas_revision = frame.canvas_revision,
|
|
63
|
+
.canvas_command_count = frame.canvas_command_count,
|
|
64
|
+
.canvas_frame_requires_render = if (frame.canvas_frame_requires_render) 1 else 0,
|
|
65
|
+
.canvas_frame_full_repaint = if (frame.canvas_frame_full_repaint) 1 else 0,
|
|
66
|
+
.canvas_frame_batch_count = frame.canvas_frame_batch_count,
|
|
67
|
+
.canvas_frame_budget_exceeded_count = frame.canvas_frame_budget_exceeded_count,
|
|
68
|
+
.canvas_frame_budget_ok = if (frame.canvas_frame_budget_ok) 1 else 0,
|
|
69
|
+
.widget_revision = frame.widget_revision,
|
|
70
|
+
.widget_node_count = frame.widget_node_count,
|
|
71
|
+
.widget_semantics_count = frame.widget_semantics_count,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
pub fn combinedMobileViewportInsets(surface: platform.Surface) geometry.InsetsF {
|
|
76
|
+
return .{
|
|
77
|
+
.top = @max(surface.safe_area_insets.top, surface.keyboard_insets.top),
|
|
78
|
+
.right = @max(surface.safe_area_insets.right, surface.keyboard_insets.right),
|
|
79
|
+
.bottom = @max(surface.safe_area_insets.bottom, surface.keyboard_insets.bottom),
|
|
80
|
+
.left = @max(surface.safe_area_insets.left, surface.keyboard_insets.left),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
pub fn mobileSurface(width: f32, height: f32, scale: f32, surface: ?*anyopaque, safe_area_insets: geometry.InsetsF, keyboard_insets: geometry.InsetsF) platform.Surface {
|
|
85
|
+
return .{
|
|
86
|
+
.size = .{ .width = width, .height = height },
|
|
87
|
+
.scale_factor = scale,
|
|
88
|
+
.safe_area_insets = safe_area_insets,
|
|
89
|
+
.keyboard_insets = keyboard_insets,
|
|
90
|
+
.native_handle = surface,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
pub fn mobileTouchKindFromPhase(phase: c_int) anyerror!platform.GpuSurfaceInputKind {
|
|
94
|
+
return switch (phase) {
|
|
95
|
+
0, 5 => .pointer_down,
|
|
96
|
+
1, 6 => .pointer_up,
|
|
97
|
+
2 => .pointer_drag,
|
|
98
|
+
3 => .pointer_cancel,
|
|
99
|
+
else => error.InvalidTouchPhase,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
pub fn mobileKeyKindFromPhase(phase: c_int) anyerror!platform.GpuSurfaceInputKind {
|
|
104
|
+
return switch (phase) {
|
|
105
|
+
0 => .key_down,
|
|
106
|
+
1 => .key_up,
|
|
107
|
+
else => error.InvalidKeyPhase,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
pub fn mobileImeKindFromInt(kind: c_int) anyerror!platform.GpuSurfaceInputKind {
|
|
112
|
+
return switch (kind) {
|
|
113
|
+
0 => .ime_set_composition,
|
|
114
|
+
1 => .ime_commit_composition,
|
|
115
|
+
2 => .ime_cancel_composition,
|
|
116
|
+
else => error.InvalidImeKind,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
pub fn mobileModifiersFromMask(mask: u32) platform.ShortcutModifiers {
|
|
121
|
+
return .{
|
|
122
|
+
.primary = (mask & 1) != 0,
|
|
123
|
+
.command = (mask & 2) != 0,
|
|
124
|
+
.control = (mask & 4) != 0,
|
|
125
|
+
.option = (mask & 8) != 0,
|
|
126
|
+
.shift = (mask & 16) != 0,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
pub fn mobileWidgetActionKindFromInt(value: c_int) anyerror!runtime.CanvasWidgetAccessibilityActionKind {
|
|
131
|
+
return switch (value) {
|
|
132
|
+
@intFromEnum(MobileWidgetActionKind.focus) => .focus,
|
|
133
|
+
@intFromEnum(MobileWidgetActionKind.press) => .press,
|
|
134
|
+
@intFromEnum(MobileWidgetActionKind.toggle) => .toggle,
|
|
135
|
+
@intFromEnum(MobileWidgetActionKind.increment) => .increment,
|
|
136
|
+
@intFromEnum(MobileWidgetActionKind.decrement) => .decrement,
|
|
137
|
+
@intFromEnum(MobileWidgetActionKind.set_text) => .set_text,
|
|
138
|
+
@intFromEnum(MobileWidgetActionKind.set_selection) => .set_selection,
|
|
139
|
+
@intFromEnum(MobileWidgetActionKind.set_composition) => .set_composition,
|
|
140
|
+
@intFromEnum(MobileWidgetActionKind.commit_composition) => .commit_composition,
|
|
141
|
+
@intFromEnum(MobileWidgetActionKind.cancel_composition) => .cancel_composition,
|
|
142
|
+
@intFromEnum(MobileWidgetActionKind.select) => .select,
|
|
143
|
+
@intFromEnum(MobileWidgetActionKind.drag) => .drag,
|
|
144
|
+
@intFromEnum(MobileWidgetActionKind.drop_files) => .drop_files,
|
|
145
|
+
@intFromEnum(MobileWidgetActionKind.dismiss) => .dismiss,
|
|
146
|
+
else => error.InvalidCommand,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// Audio event kind ordinals over the C ABI (`native_sdk_app_audio_event`),
|
|
151
|
+
/// matching `platform.AudioEventKind` and the macOS host's constants:
|
|
152
|
+
/// 0 loaded, 1 position, 2 completed, 3 failed.
|
|
153
|
+
pub fn mobileAudioEventKindFromInt(kind: c_int) anyerror!platform.AudioEventKind {
|
|
154
|
+
return switch (kind) {
|
|
155
|
+
0 => .loaded,
|
|
156
|
+
1 => .position,
|
|
157
|
+
2 => .completed,
|
|
158
|
+
3 => .failed,
|
|
159
|
+
else => error.InvalidAudioOptions,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
pub fn inputSlice(pointer: ?[*]const u8, len: usize) anyerror![]const u8 {
|
|
164
|
+
if (len == 0) return "";
|
|
165
|
+
const value = pointer orelse return error.InvalidCommand;
|
|
166
|
+
return value[0..len];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
pub fn copyInputText(buffer: []u8, value: []const u8) usize {
|
|
170
|
+
const count = @min(buffer.len, value.len);
|
|
171
|
+
@memcpy(buffer[0..count], value[0..count]);
|
|
172
|
+
return count;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
pub fn mobileWidgetSemanticsFromNode(nodes: []const canvas.WidgetSemanticsNode, index: usize) MobileWidgetSemantics {
|
|
176
|
+
const node = nodes[index];
|
|
177
|
+
const label = mobileOptionalString(node.label);
|
|
178
|
+
const text = mobileOptionalString(node.text_value);
|
|
179
|
+
const placeholder = mobileOptionalString(node.placeholder);
|
|
180
|
+
return .{
|
|
181
|
+
.id = node.id,
|
|
182
|
+
.parent_id = mobileWidgetSemanticParentId(nodes, node.parent_index),
|
|
183
|
+
.role = @intFromEnum(mobileWidgetRole(node.role)),
|
|
184
|
+
.flags = mobileWidgetFlags(node),
|
|
185
|
+
.actions = mobileWidgetActions(node.actions),
|
|
186
|
+
.x = node.bounds.x,
|
|
187
|
+
.y = node.bounds.y,
|
|
188
|
+
.width = node.bounds.width,
|
|
189
|
+
.height = node.bounds.height,
|
|
190
|
+
.value = node.value orelse 0,
|
|
191
|
+
.has_value = if (node.value != null) 1 else 0,
|
|
192
|
+
.label = label.ptr,
|
|
193
|
+
.label_len = label.len,
|
|
194
|
+
.text = text.ptr,
|
|
195
|
+
.text_len = text.len,
|
|
196
|
+
.placeholder = placeholder.ptr,
|
|
197
|
+
.placeholder_len = placeholder.len,
|
|
198
|
+
.text_selection_start = mobileTextRangeStart(node.text_selection),
|
|
199
|
+
.text_selection_end = mobileTextRangeEnd(node.text_selection),
|
|
200
|
+
.text_composition_start = mobileTextRangeStart(node.text_composition),
|
|
201
|
+
.text_composition_end = mobileTextRangeEnd(node.text_composition),
|
|
202
|
+
.grid_row_index = mobileOptionalIndex(node.grid_row_index),
|
|
203
|
+
.grid_column_index = mobileOptionalIndex(node.grid_column_index),
|
|
204
|
+
.grid_row_count = mobileOptionalIndex(node.grid_row_count),
|
|
205
|
+
.grid_column_count = mobileOptionalIndex(node.grid_column_count),
|
|
206
|
+
.list_item_index = if (node.list.present) mobileU32Index(node.list.item_index) else -1,
|
|
207
|
+
.list_item_count = if (node.list.present) mobileU32Index(node.list.item_count) else -1,
|
|
208
|
+
.scroll_offset = node.scroll.offset,
|
|
209
|
+
.scroll_viewport_extent = node.scroll.viewport_extent,
|
|
210
|
+
.scroll_content_extent = node.scroll.content_extent,
|
|
211
|
+
.has_scroll = if (node.scroll.present) 1 else 0,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
pub fn mobileWidgetTextGeometryFromCanvas(id: canvas.ObjectId, geometry_value: canvas.WidgetTextGeometry) MobileWidgetTextGeometry {
|
|
216
|
+
var value = MobileWidgetTextGeometry{
|
|
217
|
+
.id = id,
|
|
218
|
+
.selection_rect_count = geometry_value.selection_rect_count,
|
|
219
|
+
.composition_rect_count = geometry_value.composition_rect_count,
|
|
220
|
+
};
|
|
221
|
+
if (geometry_value.caret_bounds) |bounds| {
|
|
222
|
+
value.has_caret_bounds = 1;
|
|
223
|
+
value.caret_x = bounds.x;
|
|
224
|
+
value.caret_y = bounds.y;
|
|
225
|
+
value.caret_width = bounds.width;
|
|
226
|
+
value.caret_height = bounds.height;
|
|
227
|
+
}
|
|
228
|
+
if (geometry_value.selection_bounds) |bounds| {
|
|
229
|
+
value.has_selection_bounds = 1;
|
|
230
|
+
value.selection_x = bounds.x;
|
|
231
|
+
value.selection_y = bounds.y;
|
|
232
|
+
value.selection_width = bounds.width;
|
|
233
|
+
value.selection_height = bounds.height;
|
|
234
|
+
}
|
|
235
|
+
if (geometry_value.composition_bounds) |bounds| {
|
|
236
|
+
value.has_composition_bounds = 1;
|
|
237
|
+
value.composition_x = bounds.x;
|
|
238
|
+
value.composition_y = bounds.y;
|
|
239
|
+
value.composition_width = bounds.width;
|
|
240
|
+
value.composition_height = bounds.height;
|
|
241
|
+
}
|
|
242
|
+
return value;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
pub fn mobileWidgetSemanticParentId(nodes: []const canvas.WidgetSemanticsNode, parent_index: ?usize) u64 {
|
|
246
|
+
const index = parent_index orelse return 0;
|
|
247
|
+
if (index >= nodes.len) return 0;
|
|
248
|
+
return nodes[index].id;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const MobileStringView = struct {
|
|
252
|
+
ptr: ?[*]const u8,
|
|
253
|
+
len: usize,
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
pub fn mobileOptionalString(value: []const u8) MobileStringView {
|
|
257
|
+
return .{
|
|
258
|
+
.ptr = if (value.len > 0) value.ptr else null,
|
|
259
|
+
.len = value.len,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
pub fn mobileWidgetRole(role: canvas.WidgetRole) MobileWidgetRole {
|
|
264
|
+
return switch (role) {
|
|
265
|
+
.none => .none,
|
|
266
|
+
.group => .group,
|
|
267
|
+
.text => .text,
|
|
268
|
+
// The mobile ABI predates the link role; expose links as pressable
|
|
269
|
+
// text until the ABI grows a dedicated value.
|
|
270
|
+
.link => .text,
|
|
271
|
+
.image => .image,
|
|
272
|
+
.button => .button,
|
|
273
|
+
.textbox => .textbox,
|
|
274
|
+
.tooltip => .tooltip,
|
|
275
|
+
.dialog => .dialog,
|
|
276
|
+
.menu => .menu,
|
|
277
|
+
.menuitem => .menuitem,
|
|
278
|
+
.list => .list,
|
|
279
|
+
.listitem => .listitem,
|
|
280
|
+
.row => .row,
|
|
281
|
+
.grid => .grid,
|
|
282
|
+
.gridcell => .gridcell,
|
|
283
|
+
.tab => .tab,
|
|
284
|
+
.checkbox => .checkbox,
|
|
285
|
+
.radio => .radio,
|
|
286
|
+
.switch_control => .switch_control,
|
|
287
|
+
.slider => .slider,
|
|
288
|
+
.progressbar => .progressbar,
|
|
289
|
+
// The mobile ABI predates the chart role; expose charts as images
|
|
290
|
+
// carrying the series-summary label.
|
|
291
|
+
.chart => .image,
|
|
292
|
+
// The mobile ABI predates the tree/treeitem/separator roles;
|
|
293
|
+
// trees expose as lists (rows as list items) and the split
|
|
294
|
+
// divider as a group whose value carries the fraction.
|
|
295
|
+
.tree => .list,
|
|
296
|
+
.treeitem => .listitem,
|
|
297
|
+
.separator => .group,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
pub fn mobileWidgetFlags(node: canvas.WidgetSemanticsNode) u32 {
|
|
302
|
+
var flags: u32 = 0;
|
|
303
|
+
if (node.state.focused) flags |= @intFromEnum(MobileWidgetFlag.focused);
|
|
304
|
+
if (node.state.hovered) flags |= @intFromEnum(MobileWidgetFlag.hovered);
|
|
305
|
+
if (node.state.pressed) flags |= @intFromEnum(MobileWidgetFlag.pressed);
|
|
306
|
+
if (node.state.selected) flags |= @intFromEnum(MobileWidgetFlag.selected);
|
|
307
|
+
if (node.state.disabled) flags |= @intFromEnum(MobileWidgetFlag.disabled);
|
|
308
|
+
if (node.focusable) flags |= @intFromEnum(MobileWidgetFlag.focusable);
|
|
309
|
+
if (node.state.expanded) |expanded| {
|
|
310
|
+
flags |= @intFromEnum(if (expanded) MobileWidgetFlag.expanded else MobileWidgetFlag.collapsed);
|
|
311
|
+
}
|
|
312
|
+
if (node.state.required) flags |= @intFromEnum(MobileWidgetFlag.required);
|
|
313
|
+
if (node.state.read_only) flags |= @intFromEnum(MobileWidgetFlag.read_only);
|
|
314
|
+
if (node.state.invalid) flags |= @intFromEnum(MobileWidgetFlag.invalid);
|
|
315
|
+
return flags;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
pub fn mobileWidgetActions(actions: canvas.WidgetActions) u32 {
|
|
319
|
+
var flags: u32 = 0;
|
|
320
|
+
if (actions.focus) flags |= @intFromEnum(MobileWidgetAction.focus);
|
|
321
|
+
if (actions.press) flags |= @intFromEnum(MobileWidgetAction.press);
|
|
322
|
+
if (actions.toggle) flags |= @intFromEnum(MobileWidgetAction.toggle);
|
|
323
|
+
if (actions.increment) flags |= @intFromEnum(MobileWidgetAction.increment);
|
|
324
|
+
if (actions.decrement) flags |= @intFromEnum(MobileWidgetAction.decrement);
|
|
325
|
+
if (actions.set_text) flags |= @intFromEnum(MobileWidgetAction.set_text);
|
|
326
|
+
if (actions.set_selection) flags |= @intFromEnum(MobileWidgetAction.set_selection);
|
|
327
|
+
if (actions.select) flags |= @intFromEnum(MobileWidgetAction.select);
|
|
328
|
+
if (actions.drag) flags |= @intFromEnum(MobileWidgetAction.drag);
|
|
329
|
+
if (actions.drop_files) flags |= @intFromEnum(MobileWidgetAction.drop_files);
|
|
330
|
+
if (actions.dismiss) flags |= @intFromEnum(MobileWidgetAction.dismiss);
|
|
331
|
+
return flags;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
pub fn mobileOptionalIndex(value: ?usize) isize {
|
|
335
|
+
const index = value orelse return -1;
|
|
336
|
+
if (index > @as(usize, @intCast(std.math.maxInt(isize)))) return std.math.maxInt(isize);
|
|
337
|
+
return @intCast(index);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
pub fn mobileU32Index(value: u32) isize {
|
|
341
|
+
return @intCast(value);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
pub fn mobileTextRangeStart(range: ?canvas.TextRange) isize {
|
|
345
|
+
const value = range orelse return -1;
|
|
346
|
+
return mobileOptionalIndex(value.start);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
pub fn mobileTextRangeEnd(range: ?canvas.TextRange) isize {
|
|
350
|
+
const value = range orelse return -1;
|
|
351
|
+
return mobileOptionalIndex(value.end);
|
|
352
|
+
}
|
|
353
|
+
/// Wall-clock nanoseconds for embed input timestamps, through the
|
|
354
|
+
/// runtime clock seam (which covers Windows via the NT precise system
|
|
355
|
+
/// time and degrades to 0 only on targets without a readable clock).
|
|
356
|
+
pub fn nowNanoseconds() u64 {
|
|
357
|
+
const ns = runtime.nowNanoseconds();
|
|
358
|
+
return if (ns > 0) @intCast(ns) else 0;
|
|
359
|
+
}
|