From adf4d52445a63e59c636cfc1de3e7bc4ec32c4a3 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Tue, 12 Nov 2024 16:01:26 +0200 Subject: [PATCH] strong type openWith paramter --- plugins/opener/guest-js/index.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/opener/guest-js/index.ts b/plugins/opener/guest-js/index.ts index d586572f..9484f5bd 100644 --- a/plugins/opener/guest-js/index.ts +++ b/plugins/opener/guest-js/index.ts @@ -20,6 +20,19 @@ import { invoke } from '@tauri-apps/api/core' +export type Program = + | 'firefox' + | 'google chrome' + | 'chromium' + | 'safari' + | 'open' + | 'start' + | 'xdg-open' + | 'gio' + | 'gnome-open' + | 'kde-open' + | 'wslview' + /** * Opens a path or URL with the system's default app, * or the one specified with `openWith`. @@ -44,7 +57,7 @@ import { invoke } from '@tauri-apps/api/core' * * @since 2.0.0 */ -export async function open(path: string, openWith?: string): Promise { +export async function open(path: string, openWith?: Program): Promise { await invoke('plugin:opener|open', { path, with: openWith