@native-sdk/cli 0.0.0 → 0.4.0
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/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 +44 -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,440 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const builtin = @import("builtin");
|
|
3
|
+
|
|
4
|
+
pub const Error = error{
|
|
5
|
+
MissingHome,
|
|
6
|
+
MissingRequiredEnv,
|
|
7
|
+
InvalidAppName,
|
|
8
|
+
UnsupportedPlatform,
|
|
9
|
+
NoSpaceLeft,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
pub const Platform = enum {
|
|
13
|
+
macos,
|
|
14
|
+
windows,
|
|
15
|
+
linux,
|
|
16
|
+
ios,
|
|
17
|
+
android,
|
|
18
|
+
unknown,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
pub const DirKind = enum {
|
|
22
|
+
config,
|
|
23
|
+
cache,
|
|
24
|
+
data,
|
|
25
|
+
state,
|
|
26
|
+
logs,
|
|
27
|
+
temp,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
pub const AppInfo = struct {
|
|
31
|
+
name: []const u8,
|
|
32
|
+
organization: ?[]const u8 = null,
|
|
33
|
+
qualifier: ?[]const u8 = null,
|
|
34
|
+
|
|
35
|
+
pub fn validate(self: AppInfo) Error!void {
|
|
36
|
+
try validateAppName(self.name);
|
|
37
|
+
if (self.organization) |organization| try validateAppName(organization);
|
|
38
|
+
if (self.qualifier) |qualifier| try validateAppName(qualifier);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pub fn pathName(self: AppInfo) []const u8 {
|
|
42
|
+
return self.name;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
pub const Env = struct {
|
|
47
|
+
home: ?[]const u8 = null,
|
|
48
|
+
xdg_config_home: ?[]const u8 = null,
|
|
49
|
+
xdg_cache_home: ?[]const u8 = null,
|
|
50
|
+
xdg_data_home: ?[]const u8 = null,
|
|
51
|
+
xdg_state_home: ?[]const u8 = null,
|
|
52
|
+
local_app_data: ?[]const u8 = null,
|
|
53
|
+
app_data: ?[]const u8 = null,
|
|
54
|
+
temp: ?[]const u8 = null,
|
|
55
|
+
tmp: ?[]const u8 = null,
|
|
56
|
+
tmpdir: ?[]const u8 = null,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
pub const ResolvedDirs = struct {
|
|
60
|
+
config: []const u8,
|
|
61
|
+
cache: []const u8,
|
|
62
|
+
data: []const u8,
|
|
63
|
+
state: []const u8,
|
|
64
|
+
logs: []const u8,
|
|
65
|
+
temp: []const u8,
|
|
66
|
+
|
|
67
|
+
pub fn get(self: ResolvedDirs, kind: DirKind) []const u8 {
|
|
68
|
+
return switch (kind) {
|
|
69
|
+
.config => self.config,
|
|
70
|
+
.cache => self.cache,
|
|
71
|
+
.data => self.data,
|
|
72
|
+
.state => self.state,
|
|
73
|
+
.logs => self.logs,
|
|
74
|
+
.temp => self.temp,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
pub const Buffers = struct {
|
|
80
|
+
config: []u8,
|
|
81
|
+
cache: []u8,
|
|
82
|
+
data: []u8,
|
|
83
|
+
state: []u8,
|
|
84
|
+
logs: []u8,
|
|
85
|
+
temp: []u8,
|
|
86
|
+
|
|
87
|
+
pub fn fromArray(comptime len: usize, buffers: *[6][len]u8) Buffers {
|
|
88
|
+
return .{
|
|
89
|
+
.config = buffers[0][0..],
|
|
90
|
+
.cache = buffers[1][0..],
|
|
91
|
+
.data = buffers[2][0..],
|
|
92
|
+
.state = buffers[3][0..],
|
|
93
|
+
.logs = buffers[4][0..],
|
|
94
|
+
.temp = buffers[5][0..],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fn forKind(self: Buffers, kind: DirKind) []u8 {
|
|
99
|
+
return switch (kind) {
|
|
100
|
+
.config => self.config,
|
|
101
|
+
.cache => self.cache,
|
|
102
|
+
.data => self.data,
|
|
103
|
+
.state => self.state,
|
|
104
|
+
.logs => self.logs,
|
|
105
|
+
.temp => self.temp,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
pub fn currentPlatform() Platform {
|
|
111
|
+
if (comptime @hasField(@TypeOf(builtin.abi), "android")) {
|
|
112
|
+
if (builtin.abi == .android) return .android;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return switch (builtin.os.tag) {
|
|
116
|
+
.macos => .macos,
|
|
117
|
+
.windows => .windows,
|
|
118
|
+
.linux => .linux,
|
|
119
|
+
.ios => .ios,
|
|
120
|
+
else => .unknown,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
pub fn platformSeparator(platform: Platform) u8 {
|
|
125
|
+
return switch (platform) {
|
|
126
|
+
.windows => '\\',
|
|
127
|
+
else => '/',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
pub fn validateAppName(name: []const u8) Error!void {
|
|
132
|
+
if (name.len == 0) return error.InvalidAppName;
|
|
133
|
+
if (std.mem.eql(u8, name, ".") or std.mem.eql(u8, name, "..")) return error.InvalidAppName;
|
|
134
|
+
|
|
135
|
+
for (name) |ch| {
|
|
136
|
+
if (ch == 0 or ch == '/' or ch == '\\') return error.InvalidAppName;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
pub fn resolve(app: AppInfo, platform: Platform, env: Env, buffers: Buffers) Error!ResolvedDirs {
|
|
141
|
+
return .{
|
|
142
|
+
.config = try resolveOne(app, platform, env, .config, buffers.config),
|
|
143
|
+
.cache = try resolveOne(app, platform, env, .cache, buffers.cache),
|
|
144
|
+
.data = try resolveOne(app, platform, env, .data, buffers.data),
|
|
145
|
+
.state = try resolveOne(app, platform, env, .state, buffers.state),
|
|
146
|
+
.logs = try resolveOne(app, platform, env, .logs, buffers.logs),
|
|
147
|
+
.temp = try resolveOne(app, platform, env, .temp, buffers.temp),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
pub fn resolveOne(app: AppInfo, platform: Platform, env: Env, kind: DirKind, output: []u8) Error![]const u8 {
|
|
152
|
+
try app.validate();
|
|
153
|
+
|
|
154
|
+
return switch (platform) {
|
|
155
|
+
.linux => resolveLinux(app.pathName(), env, kind, output),
|
|
156
|
+
.macos => resolveMacos(app.pathName(), env, kind, output),
|
|
157
|
+
.windows => resolveWindows(app.pathName(), env, kind, output),
|
|
158
|
+
.ios => resolveIos(env, kind, output),
|
|
159
|
+
.android => resolveAndroid(env, kind, output),
|
|
160
|
+
.unknown => error.UnsupportedPlatform,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
pub fn join(platform: Platform, output: []u8, parts: []const []const u8) Error![]const u8 {
|
|
165
|
+
if (parts.len == 0) return output[0..0];
|
|
166
|
+
|
|
167
|
+
const sep = platformSeparator(platform);
|
|
168
|
+
var len: usize = 0;
|
|
169
|
+
|
|
170
|
+
for (parts, 0..) |part, i| {
|
|
171
|
+
if (part.len == 0) continue;
|
|
172
|
+
if (i != 0 and len > 0 and output[len - 1] != sep) {
|
|
173
|
+
if (len >= output.len) return error.NoSpaceLeft;
|
|
174
|
+
output[len] = sep;
|
|
175
|
+
len += 1;
|
|
176
|
+
}
|
|
177
|
+
if (len + part.len > output.len) return error.NoSpaceLeft;
|
|
178
|
+
@memcpy(output[len..][0..part.len], part);
|
|
179
|
+
len += part.len;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return output[0..len];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fn resolveLinux(app_name: []const u8, env: Env, kind: DirKind, output: []u8) Error![]const u8 {
|
|
186
|
+
const home = env.home;
|
|
187
|
+
|
|
188
|
+
return switch (kind) {
|
|
189
|
+
.config => join(.linux, output, if (env.xdg_config_home) |root| &.{ root, app_name } else &.{ home orelse return error.MissingHome, ".config", app_name }),
|
|
190
|
+
.cache => join(.linux, output, if (env.xdg_cache_home) |root| &.{ root, app_name } else &.{ home orelse return error.MissingHome, ".cache", app_name }),
|
|
191
|
+
.data => join(.linux, output, if (env.xdg_data_home) |root| &.{ root, app_name } else &.{ home orelse return error.MissingHome, ".local", "share", app_name }),
|
|
192
|
+
.state => join(.linux, output, if (env.xdg_state_home) |root| &.{ root, app_name } else &.{ home orelse return error.MissingHome, ".local", "state", app_name }),
|
|
193
|
+
.logs => join(.linux, output, if (env.xdg_state_home) |root| &.{ root, app_name, "logs" } else &.{ home orelse return error.MissingHome, ".local", "state", app_name, "logs" }),
|
|
194
|
+
.temp => join(.linux, output, &.{ env.tmpdir orelse "/tmp", app_name }),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fn resolveMacos(app_name: []const u8, env: Env, kind: DirKind, output: []u8) Error![]const u8 {
|
|
199
|
+
const home = env.home orelse return error.MissingHome;
|
|
200
|
+
|
|
201
|
+
return switch (kind) {
|
|
202
|
+
.config => join(.macos, output, &.{ home, "Library", "Preferences", app_name }),
|
|
203
|
+
.cache => join(.macos, output, &.{ home, "Library", "Caches", app_name }),
|
|
204
|
+
.data => join(.macos, output, &.{ home, "Library", "Application Support", app_name }),
|
|
205
|
+
.state => join(.macos, output, &.{ home, "Library", "Application Support", app_name, "State" }),
|
|
206
|
+
.logs => join(.macos, output, &.{ home, "Library", "Logs", app_name }),
|
|
207
|
+
.temp => join(.macos, output, &.{ env.tmpdir orelse "/tmp", app_name }),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// iOS: every process runs inside its app's sandbox container and `HOME`
|
|
212
|
+
/// is the container root, so the container itself is the per-app
|
|
213
|
+
/// namespace — no `<app>` child directory (the macOS shape would just
|
|
214
|
+
/// nest a redundant level the OS tooling never looks in). `.cache`
|
|
215
|
+
/// resolves to the container's `Library/Caches`, which the system
|
|
216
|
+
/// already treats as purgeable — exactly where the audio track cache
|
|
217
|
+
/// belongs. `.temp` prefers `TMPDIR` (set to the container's `tmp/` in
|
|
218
|
+
/// every iOS process) and falls back to that directory by convention.
|
|
219
|
+
fn resolveIos(env: Env, kind: DirKind, output: []u8) Error![]const u8 {
|
|
220
|
+
const home = env.home orelse return error.MissingHome;
|
|
221
|
+
|
|
222
|
+
return switch (kind) {
|
|
223
|
+
.config => join(.ios, output, &.{ home, "Library", "Preferences" }),
|
|
224
|
+
.cache => join(.ios, output, &.{ home, "Library", "Caches" }),
|
|
225
|
+
.data => join(.ios, output, &.{ home, "Library", "Application Support" }),
|
|
226
|
+
.state => join(.ios, output, &.{ home, "Library", "Application Support", "State" }),
|
|
227
|
+
.logs => join(.ios, output, &.{ home, "Library", "Caches", "Logs" }),
|
|
228
|
+
.temp => if (env.tmpdir) |tmpdir| join(.ios, output, &.{tmpdir}) else join(.ios, output, &.{ home, "tmp" }),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// Android: like iOS, every process runs inside its app's private data
|
|
233
|
+
/// directory, so that directory is the per-app namespace — no `<app>`
|
|
234
|
+
/// child. The toolkit's Android host exports `HOME` as the app data
|
|
235
|
+
/// directory and `TMPDIR` as its `cache/` child before the app starts
|
|
236
|
+
/// (the OS gives app processes no per-app environment of its own), so
|
|
237
|
+
/// env-based resolution stays honest. The mapping follows the two
|
|
238
|
+
/// directories the OS itself manages inside the data dir: `files/` for
|
|
239
|
+
/// durable bytes and `cache/` for reclaimable ones (`.cache` is exactly
|
|
240
|
+
/// the platform cache directory the system may clear under pressure —
|
|
241
|
+
/// where the audio track cache belongs). Android has no per-app tmp
|
|
242
|
+
/// directory; the cache directory is the platform's documented home for
|
|
243
|
+
/// temporary files, so `.temp` prefers `TMPDIR` and falls back to it.
|
|
244
|
+
fn resolveAndroid(env: Env, kind: DirKind, output: []u8) Error![]const u8 {
|
|
245
|
+
const home = env.home orelse return error.MissingHome;
|
|
246
|
+
|
|
247
|
+
return switch (kind) {
|
|
248
|
+
.config => join(.android, output, &.{ home, "files", "config" }),
|
|
249
|
+
.cache => join(.android, output, &.{ home, "cache" }),
|
|
250
|
+
.data => join(.android, output, &.{ home, "files" }),
|
|
251
|
+
.state => join(.android, output, &.{ home, "files", "state" }),
|
|
252
|
+
.logs => join(.android, output, &.{ home, "cache", "logs" }),
|
|
253
|
+
.temp => if (env.tmpdir) |tmpdir| join(.android, output, &.{tmpdir}) else join(.android, output, &.{ home, "cache" }),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fn resolveWindows(app_name: []const u8, env: Env, kind: DirKind, output: []u8) Error![]const u8 {
|
|
258
|
+
return switch (kind) {
|
|
259
|
+
.config => join(.windows, output, &.{ env.app_data orelse return error.MissingRequiredEnv, app_name }),
|
|
260
|
+
.cache => join(.windows, output, &.{ env.local_app_data orelse return error.MissingRequiredEnv, app_name, "Cache" }),
|
|
261
|
+
.data => join(.windows, output, &.{ env.local_app_data orelse return error.MissingRequiredEnv, app_name, "Data" }),
|
|
262
|
+
.state => join(.windows, output, &.{ env.local_app_data orelse return error.MissingRequiredEnv, app_name, "State" }),
|
|
263
|
+
.logs => join(.windows, output, &.{ env.local_app_data orelse return error.MissingRequiredEnv, app_name, "Logs" }),
|
|
264
|
+
.temp => join(.windows, output, &.{ env.temp orelse env.tmp orelse return error.MissingRequiredEnv, app_name }),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
fn expectEqualString(expected: []const u8, actual: []const u8) !void {
|
|
269
|
+
try std.testing.expectEqualStrings(expected, actual);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
fn testBuffers() Buffers {
|
|
273
|
+
const State = struct {
|
|
274
|
+
threadlocal var buffers: [6][256]u8 = undefined;
|
|
275
|
+
};
|
|
276
|
+
return Buffers.fromArray(256, &State.buffers);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
test "app name validation accepts ordinary names and rejects path-like names" {
|
|
280
|
+
try validateAppName("my-app");
|
|
281
|
+
try validateAppName("My App");
|
|
282
|
+
try validateAppName("com.example.tool");
|
|
283
|
+
|
|
284
|
+
try std.testing.expectError(error.InvalidAppName, validateAppName(""));
|
|
285
|
+
try std.testing.expectError(error.InvalidAppName, validateAppName("."));
|
|
286
|
+
try std.testing.expectError(error.InvalidAppName, validateAppName(".."));
|
|
287
|
+
try std.testing.expectError(error.InvalidAppName, validateAppName("my/app"));
|
|
288
|
+
try std.testing.expectError(error.InvalidAppName, validateAppName("my\\app"));
|
|
289
|
+
try std.testing.expectError(error.InvalidAppName, validateAppName("my\x00app"));
|
|
290
|
+
try std.testing.expectError(error.InvalidAppName, (AppInfo{ .name = "app", .organization = "bad/org" }).validate());
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
test "linux xdg paths use explicit environment values" {
|
|
294
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
295
|
+
const env: Env = .{
|
|
296
|
+
.home = "/home/alice",
|
|
297
|
+
.xdg_config_home = "/xdg/config",
|
|
298
|
+
.xdg_cache_home = "/xdg/cache",
|
|
299
|
+
.xdg_data_home = "/xdg/data",
|
|
300
|
+
.xdg_state_home = "/xdg/state",
|
|
301
|
+
.tmpdir = "/run/tmp",
|
|
302
|
+
};
|
|
303
|
+
const dirs = try resolve(app, .linux, env, testBuffers());
|
|
304
|
+
|
|
305
|
+
try expectEqualString("/xdg/config/demo", dirs.config);
|
|
306
|
+
try expectEqualString("/xdg/cache/demo", dirs.cache);
|
|
307
|
+
try expectEqualString("/xdg/data/demo", dirs.data);
|
|
308
|
+
try expectEqualString("/xdg/state/demo", dirs.state);
|
|
309
|
+
try expectEqualString("/xdg/state/demo/logs", dirs.logs);
|
|
310
|
+
try expectEqualString("/run/tmp/demo", dirs.temp);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
test "linux falls back to home defaults" {
|
|
314
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
315
|
+
const env: Env = .{ .home = "/home/alice" };
|
|
316
|
+
const dirs = try resolve(app, .linux, env, testBuffers());
|
|
317
|
+
|
|
318
|
+
try expectEqualString("/home/alice/.config/demo", dirs.config);
|
|
319
|
+
try expectEqualString("/home/alice/.cache/demo", dirs.cache);
|
|
320
|
+
try expectEqualString("/home/alice/.local/share/demo", dirs.data);
|
|
321
|
+
try expectEqualString("/home/alice/.local/state/demo", dirs.state);
|
|
322
|
+
try expectEqualString("/home/alice/.local/state/demo/logs", dirs.logs);
|
|
323
|
+
try expectEqualString("/tmp/demo", dirs.temp);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
test "macos library paths resolve from home" {
|
|
327
|
+
const app: AppInfo = .{ .name = "Demo" };
|
|
328
|
+
const env: Env = .{ .home = "/Users/alice", .tmpdir = "/var/folders/tmp" };
|
|
329
|
+
const dirs = try resolve(app, .macos, env, testBuffers());
|
|
330
|
+
|
|
331
|
+
try expectEqualString("/Users/alice/Library/Preferences/Demo", dirs.config);
|
|
332
|
+
try expectEqualString("/Users/alice/Library/Caches/Demo", dirs.cache);
|
|
333
|
+
try expectEqualString("/Users/alice/Library/Application Support/Demo", dirs.data);
|
|
334
|
+
try expectEqualString("/Users/alice/Library/Application Support/Demo/State", dirs.state);
|
|
335
|
+
try expectEqualString("/Users/alice/Library/Logs/Demo", dirs.logs);
|
|
336
|
+
try expectEqualString("/var/folders/tmp/Demo", dirs.temp);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
test "windows paths resolve from appdata environment" {
|
|
340
|
+
const app: AppInfo = .{ .name = "Demo" };
|
|
341
|
+
const env: Env = .{
|
|
342
|
+
.app_data = "C:\\Users\\alice\\AppData\\Roaming",
|
|
343
|
+
.local_app_data = "C:\\Users\\alice\\AppData\\Local",
|
|
344
|
+
.temp = "C:\\Users\\alice\\AppData\\Local\\Temp",
|
|
345
|
+
};
|
|
346
|
+
const dirs = try resolve(app, .windows, env, testBuffers());
|
|
347
|
+
|
|
348
|
+
try expectEqualString("C:\\Users\\alice\\AppData\\Roaming\\Demo", dirs.config);
|
|
349
|
+
try expectEqualString("C:\\Users\\alice\\AppData\\Local\\Demo\\Cache", dirs.cache);
|
|
350
|
+
try expectEqualString("C:\\Users\\alice\\AppData\\Local\\Demo\\Data", dirs.data);
|
|
351
|
+
try expectEqualString("C:\\Users\\alice\\AppData\\Local\\Demo\\State", dirs.state);
|
|
352
|
+
try expectEqualString("C:\\Users\\alice\\AppData\\Local\\Demo\\Logs", dirs.logs);
|
|
353
|
+
try expectEqualString("C:\\Users\\alice\\AppData\\Local\\Temp\\Demo", dirs.temp);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
test "temp fallback behavior is platform specific" {
|
|
357
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
358
|
+
|
|
359
|
+
try expectEqualString("/tmp/demo", try resolveOne(app, .linux, .{ .home = "/home/a" }, .temp, testBuffers().temp));
|
|
360
|
+
try expectEqualString("/custom/demo", try resolveOne(app, .linux, .{ .home = "/home/a", .tmpdir = "/custom" }, .temp, testBuffers().temp));
|
|
361
|
+
try expectEqualString("/tmp/demo", try resolveOne(app, .macos, .{ .home = "/Users/a" }, .temp, testBuffers().temp));
|
|
362
|
+
try expectEqualString("C:\\Tmp\\demo", try resolveOne(app, .windows, .{ .app_data = "C:\\Roaming", .local_app_data = "C:\\Local", .tmp = "C:\\Tmp" }, .temp, testBuffers().temp));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
test "missing required env produces explicit errors" {
|
|
366
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
367
|
+
|
|
368
|
+
try std.testing.expectError(error.MissingHome, resolveOne(app, .linux, .{}, .config, testBuffers().config));
|
|
369
|
+
try std.testing.expectError(error.MissingHome, resolveOne(app, .macos, .{}, .data, testBuffers().data));
|
|
370
|
+
try std.testing.expectError(error.MissingRequiredEnv, resolveOne(app, .windows, .{ .local_app_data = "C:\\Local" }, .config, testBuffers().config));
|
|
371
|
+
try std.testing.expectError(error.MissingRequiredEnv, resolveOne(app, .windows, .{ .app_data = "C:\\Roaming" }, .cache, testBuffers().cache));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
test "ios resolves inside the app sandbox container" {
|
|
375
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
376
|
+
const home = "/var/mobile/Containers/Data/Application/ABC";
|
|
377
|
+
const env: Env = .{ .home = home, .tmpdir = home ++ "/tmp" };
|
|
378
|
+
const dirs = try resolve(app, .ios, env, testBuffers());
|
|
379
|
+
|
|
380
|
+
try expectEqualString(home ++ "/Library/Preferences", dirs.config);
|
|
381
|
+
try expectEqualString(home ++ "/Library/Caches", dirs.cache);
|
|
382
|
+
try expectEqualString(home ++ "/Library/Application Support", dirs.data);
|
|
383
|
+
try expectEqualString(home ++ "/Library/Application Support/State", dirs.state);
|
|
384
|
+
try expectEqualString(home ++ "/Library/Caches/Logs", dirs.logs);
|
|
385
|
+
try expectEqualString(home ++ "/tmp", dirs.temp);
|
|
386
|
+
try expectEqualString(home ++ "/tmp", try resolveOne(app, .ios, .{ .home = home }, .temp, testBuffers().temp));
|
|
387
|
+
try std.testing.expectError(error.MissingHome, resolveOne(app, .ios, .{}, .cache, testBuffers().cache));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
test "android resolves inside the app data directory" {
|
|
391
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
392
|
+
const home = "/data/user/0/dev.native_sdk.demo";
|
|
393
|
+
const env: Env = .{ .home = home, .tmpdir = home ++ "/cache" };
|
|
394
|
+
const dirs = try resolve(app, .android, env, testBuffers());
|
|
395
|
+
|
|
396
|
+
try expectEqualString(home ++ "/files/config", dirs.config);
|
|
397
|
+
try expectEqualString(home ++ "/cache", dirs.cache);
|
|
398
|
+
try expectEqualString(home ++ "/files", dirs.data);
|
|
399
|
+
try expectEqualString(home ++ "/files/state", dirs.state);
|
|
400
|
+
try expectEqualString(home ++ "/cache/logs", dirs.logs);
|
|
401
|
+
try expectEqualString(home ++ "/cache", dirs.temp);
|
|
402
|
+
try expectEqualString(home ++ "/cache", try resolveOne(app, .android, .{ .home = home }, .temp, testBuffers().temp));
|
|
403
|
+
try std.testing.expectError(error.MissingHome, resolveOne(app, .android, .{}, .cache, testBuffers().cache));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
test "unknown is unsupported in v1" {
|
|
407
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
408
|
+
|
|
409
|
+
try std.testing.expectError(error.UnsupportedPlatform, resolveOne(app, .unknown, .{}, .config, testBuffers().config));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
test "buffer exhaustion returns no space left" {
|
|
413
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
414
|
+
var small: [4]u8 = undefined;
|
|
415
|
+
|
|
416
|
+
try std.testing.expectError(error.NoSpaceLeft, resolveOne(app, .linux, .{ .home = "/home/alice" }, .config, &small));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
test "resolve one matches corresponding resolved field" {
|
|
420
|
+
const app: AppInfo = .{ .name = "demo" };
|
|
421
|
+
const env: Env = .{ .home = "/home/alice" };
|
|
422
|
+
const dirs = try resolve(app, .linux, env, testBuffers());
|
|
423
|
+
var buffer: [256]u8 = undefined;
|
|
424
|
+
|
|
425
|
+
try expectEqualString(dirs.cache, try resolveOne(app, .linux, env, .cache, &buffer));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
test "join and platform helpers" {
|
|
429
|
+
var buffer: [64]u8 = undefined;
|
|
430
|
+
|
|
431
|
+
try expectEqualString("a/b/c", try join(.linux, &buffer, &.{ "a", "b", "c" }));
|
|
432
|
+
try expectEqualString("a\\b\\c", try join(.windows, &buffer, &.{ "a", "b", "c" }));
|
|
433
|
+
try std.testing.expectEqual(@as(u8, '\\'), platformSeparator(.windows));
|
|
434
|
+
try std.testing.expectEqual(@as(u8, '/'), platformSeparator(.macos));
|
|
435
|
+
_ = currentPlatform();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
test {
|
|
439
|
+
std.testing.refAllDecls(@This());
|
|
440
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const types = @import("types.zig");
|
|
3
|
+
const validation = @import("validation.zig");
|
|
4
|
+
|
|
5
|
+
pub const ValidationError = types.ValidationError;
|
|
6
|
+
pub const max_shortcuts = types.max_shortcuts;
|
|
7
|
+
pub const max_shortcut_id_bytes = types.max_shortcut_id_bytes;
|
|
8
|
+
pub const max_shortcut_key_bytes = types.max_shortcut_key_bytes;
|
|
9
|
+
pub const max_shell_windows = types.max_shell_windows;
|
|
10
|
+
pub const max_shell_views_per_window = types.max_shell_views_per_window;
|
|
11
|
+
pub const max_shell_tabs = types.max_shell_tabs;
|
|
12
|
+
pub const max_view_label_bytes = types.max_view_label_bytes;
|
|
13
|
+
pub const max_view_role_bytes = types.max_view_role_bytes;
|
|
14
|
+
pub const max_view_accessibility_label_bytes = types.max_view_accessibility_label_bytes;
|
|
15
|
+
pub const max_command_id_bytes = types.max_command_id_bytes;
|
|
16
|
+
pub const max_commands = types.max_commands;
|
|
17
|
+
pub const max_command_title_bytes = types.max_command_title_bytes;
|
|
18
|
+
pub const max_menus = types.max_menus;
|
|
19
|
+
pub const max_menu_items = types.max_menu_items;
|
|
20
|
+
pub const max_menu_title_bytes = types.max_menu_title_bytes;
|
|
21
|
+
pub const max_menu_item_label_bytes = types.max_menu_item_label_bytes;
|
|
22
|
+
pub const max_menu_key_bytes = types.max_menu_key_bytes;
|
|
23
|
+
pub const max_file_associations = types.max_file_associations;
|
|
24
|
+
pub const max_file_association_extensions = types.max_file_association_extensions;
|
|
25
|
+
pub const max_file_association_mime_types = types.max_file_association_mime_types;
|
|
26
|
+
pub const max_url_schemes = types.max_url_schemes;
|
|
27
|
+
pub const Platform = types.Platform;
|
|
28
|
+
pub const PackageKind = types.PackageKind;
|
|
29
|
+
pub const WebEngine = types.WebEngine;
|
|
30
|
+
pub const CefConfig = types.CefConfig;
|
|
31
|
+
pub const IconPurpose = types.IconPurpose;
|
|
32
|
+
pub const PermissionKind = types.PermissionKind;
|
|
33
|
+
pub const Permission = types.Permission;
|
|
34
|
+
pub const CapabilityKind = types.CapabilityKind;
|
|
35
|
+
pub const Capability = types.Capability;
|
|
36
|
+
pub const AppIdentity = types.AppIdentity;
|
|
37
|
+
pub const Version = types.Version;
|
|
38
|
+
pub const Icon = types.Icon;
|
|
39
|
+
pub const PlatformSettings = types.PlatformSettings;
|
|
40
|
+
pub const BridgeCommand = types.BridgeCommand;
|
|
41
|
+
pub const BridgeConfig = types.BridgeConfig;
|
|
42
|
+
pub const ExternalLinkAction = types.ExternalLinkAction;
|
|
43
|
+
pub const ExternalLinkPolicy = types.ExternalLinkPolicy;
|
|
44
|
+
pub const NavigationPolicy = types.NavigationPolicy;
|
|
45
|
+
pub const SecurityConfig = types.SecurityConfig;
|
|
46
|
+
pub const FrontendDevConfig = types.FrontendDevConfig;
|
|
47
|
+
pub const FrontendConfig = types.FrontendConfig;
|
|
48
|
+
pub const WindowRestorePolicy = types.WindowRestorePolicy;
|
|
49
|
+
pub const WindowTitlebarStyle = types.WindowTitlebarStyle;
|
|
50
|
+
pub const Window = types.Window;
|
|
51
|
+
pub const ViewKind = types.ViewKind;
|
|
52
|
+
pub const GpuSurfaceBackend = types.GpuSurfaceBackend;
|
|
53
|
+
pub const GpuSurfacePixelFormat = types.GpuSurfacePixelFormat;
|
|
54
|
+
pub const GpuSurfacePresentMode = types.GpuSurfacePresentMode;
|
|
55
|
+
pub const GpuSurfaceAlphaMode = types.GpuSurfaceAlphaMode;
|
|
56
|
+
pub const GpuSurfaceColorSpace = types.GpuSurfaceColorSpace;
|
|
57
|
+
pub const ShellEdge = types.ShellEdge;
|
|
58
|
+
pub const ShellAxis = types.ShellAxis;
|
|
59
|
+
pub const ShellView = types.ShellView;
|
|
60
|
+
pub const ShellWindow = types.ShellWindow;
|
|
61
|
+
pub const ShellConfig = types.ShellConfig;
|
|
62
|
+
pub const ShellTab = types.ShellTab;
|
|
63
|
+
pub const ShellPrimaryAction = types.ShellPrimaryAction;
|
|
64
|
+
pub const ShellChrome = types.ShellChrome;
|
|
65
|
+
pub const ShortcutModifiers = types.ShortcutModifiers;
|
|
66
|
+
pub const Shortcut = types.Shortcut;
|
|
67
|
+
pub const Command = types.Command;
|
|
68
|
+
pub const Menu = types.Menu;
|
|
69
|
+
pub const MenuItem = types.MenuItem;
|
|
70
|
+
pub const AssociationRole = types.AssociationRole;
|
|
71
|
+
pub const FileAssociation = types.FileAssociation;
|
|
72
|
+
pub const UrlScheme = types.UrlScheme;
|
|
73
|
+
pub const PackageMetadata = types.PackageMetadata;
|
|
74
|
+
pub const UpdateConfig = types.UpdateConfig;
|
|
75
|
+
pub const Manifest = types.Manifest;
|
|
76
|
+
pub const validateManifest = validation.validateManifest;
|
|
77
|
+
pub const validateIdentity = validation.validateIdentity;
|
|
78
|
+
pub const validateDescription = validation.validateDescription;
|
|
79
|
+
pub const validateVersion = validation.validateVersion;
|
|
80
|
+
pub const validateWindows = validation.validateWindows;
|
|
81
|
+
pub const validateShell = validation.validateShell;
|
|
82
|
+
pub const validateShellChrome = validation.validateShellChrome;
|
|
83
|
+
pub const validateShortcuts = validation.validateShortcuts;
|
|
84
|
+
pub const validateCommands = validation.validateCommands;
|
|
85
|
+
pub const validateMenus = validation.validateMenus;
|
|
86
|
+
pub const validateFileAssociations = validation.validateFileAssociations;
|
|
87
|
+
pub const validateUrlSchemes = validation.validateUrlSchemes;
|
|
88
|
+
pub const validateShortcutsForPlatforms = validation.validateShortcutsForPlatforms;
|
|
89
|
+
pub const validateCefConfig = validation.validateCefConfig;
|
|
90
|
+
pub const AppIdMode = validation.AppIdMode;
|
|
91
|
+
pub const validateAppId = validation.validateAppId;
|
|
92
|
+
pub const validateName = validation.validateName;
|
|
93
|
+
pub const validateUrl = validation.validateUrl;
|
|
94
|
+
pub const validateIcons = validation.validateIcons;
|
|
95
|
+
pub const validatePermissions = validation.validatePermissions;
|
|
96
|
+
pub const validateCapabilities = validation.validateCapabilities;
|
|
97
|
+
pub const validateBridge = validation.validateBridge;
|
|
98
|
+
pub const validateFrontend = validation.validateFrontend;
|
|
99
|
+
pub const validateBridgeOrigin = validation.validateBridgeOrigin;
|
|
100
|
+
pub const validateSecurity = validation.validateSecurity;
|
|
101
|
+
pub const validateUpdates = validation.validateUpdates;
|
|
102
|
+
pub const validatePlatforms = validation.validatePlatforms;
|
|
103
|
+
pub const validatePackageMetadata = validation.validatePackageMetadata;
|
|
104
|
+
pub const versionString = validation.versionString;
|
|
105
|
+
|
|
106
|
+
test {
|
|
107
|
+
std.testing.refAllDecls(@This());
|
|
108
|
+
_ = @import("tests.zig");
|
|
109
|
+
}
|