mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
chore: adjust prettier config, .gitignore and use taplo to format toml files (#1728)
* chore: adjust prettier config, .gitignore and use taplo to format toml files This brings the plugins-workspace repository to the same code style of the main tauri repo * format toml * ignore examples gen dir * add .vscode/extensions.json * remove packageManager field * fmt * fix audit * taplo ignore permissions autogenerated files * remove create dummy dist * fix prettier workflow * install fmt in prettier workflow --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
/**
|
||||
* Extension filters for the file dialog.
|
||||
@@ -11,7 +11,7 @@ import { invoke } from "@tauri-apps/api/core";
|
||||
*/
|
||||
interface DialogFilter {
|
||||
/** Filter name. */
|
||||
name: string;
|
||||
name: string
|
||||
/**
|
||||
* Extensions to filter, without a `.` prefix.
|
||||
* @example
|
||||
@@ -19,7 +19,7 @@ interface DialogFilter {
|
||||
* extensions: ['svg', 'png']
|
||||
* ```
|
||||
*/
|
||||
extensions: string[];
|
||||
extensions: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,9 +29,9 @@ interface DialogFilter {
|
||||
*/
|
||||
interface OpenDialogOptions {
|
||||
/** The title of the dialog window (desktop only). */
|
||||
title?: string;
|
||||
title?: string
|
||||
/** The filters of the dialog. */
|
||||
filters?: DialogFilter[];
|
||||
filters?: DialogFilter[]
|
||||
/**
|
||||
* Initial directory or file path.
|
||||
* If it's a directory path, the dialog interface will change to that folder.
|
||||
@@ -40,18 +40,18 @@ interface OpenDialogOptions {
|
||||
* On mobile the file name is always used on the dialog's file name input.
|
||||
* If not provided, Android uses `(invalid).txt` as default file name.
|
||||
*/
|
||||
defaultPath?: string;
|
||||
defaultPath?: string
|
||||
/** Whether the dialog allows multiple selection or not. */
|
||||
multiple?: boolean;
|
||||
multiple?: boolean
|
||||
/** Whether the dialog is a directory selection or not. */
|
||||
directory?: boolean;
|
||||
directory?: boolean
|
||||
/**
|
||||
* If `directory` is true, indicates that it will be read recursively later.
|
||||
* Defines whether subdirectories will be allowed on the scope or not.
|
||||
*/
|
||||
recursive?: boolean;
|
||||
recursive?: boolean
|
||||
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
|
||||
canCreateDirectories?: boolean;
|
||||
canCreateDirectories?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,9 +61,9 @@ interface OpenDialogOptions {
|
||||
*/
|
||||
interface SaveDialogOptions {
|
||||
/** The title of the dialog window (desktop only). */
|
||||
title?: string;
|
||||
title?: string
|
||||
/** The filters of the dialog. */
|
||||
filters?: DialogFilter[];
|
||||
filters?: DialogFilter[]
|
||||
/**
|
||||
* Initial directory or file path.
|
||||
* If it's a directory path, the dialog interface will change to that folder.
|
||||
@@ -72,9 +72,9 @@ interface SaveDialogOptions {
|
||||
* On mobile the file name is always used on the dialog's file name input.
|
||||
* If not provided, Android uses `(invalid).txt` as default file name.
|
||||
*/
|
||||
defaultPath?: string;
|
||||
defaultPath?: string
|
||||
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
|
||||
canCreateDirectories?: boolean;
|
||||
canCreateDirectories?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,31 +82,31 @@ interface SaveDialogOptions {
|
||||
*/
|
||||
interface MessageDialogOptions {
|
||||
/** The title of the dialog. Defaults to the app name. */
|
||||
title?: string;
|
||||
title?: string
|
||||
/** The kind of the dialog. Defaults to `info`. */
|
||||
kind?: "info" | "warning" | "error";
|
||||
kind?: 'info' | 'warning' | 'error'
|
||||
/** The label of the confirm button. */
|
||||
okLabel?: string;
|
||||
okLabel?: string
|
||||
}
|
||||
|
||||
interface ConfirmDialogOptions {
|
||||
/** The title of the dialog. Defaults to the app name. */
|
||||
title?: string;
|
||||
title?: string
|
||||
/** The kind of the dialog. Defaults to `info`. */
|
||||
kind?: "info" | "warning" | "error";
|
||||
kind?: 'info' | 'warning' | 'error'
|
||||
/** The label of the confirm button. */
|
||||
okLabel?: string;
|
||||
okLabel?: string
|
||||
/** The label of the cancel button. */
|
||||
cancelLabel?: string;
|
||||
cancelLabel?: string
|
||||
}
|
||||
|
||||
type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true
|
||||
? T["multiple"] extends true
|
||||
type OpenDialogReturn<T extends OpenDialogOptions> = T['directory'] extends true
|
||||
? T['multiple'] extends true
|
||||
? string[] | null
|
||||
: string | null
|
||||
: T["multiple"] extends true
|
||||
: T['multiple'] extends true
|
||||
? string[] | null
|
||||
: string | null;
|
||||
: string | null
|
||||
|
||||
/**
|
||||
* Open a file/directory selection dialog.
|
||||
@@ -161,13 +161,13 @@ type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function open<T extends OpenDialogOptions>(
|
||||
options: T = {} as T,
|
||||
options: T = {} as T
|
||||
): Promise<OpenDialogReturn<T>> {
|
||||
if (typeof options === "object") {
|
||||
Object.freeze(options);
|
||||
if (typeof options === 'object') {
|
||||
Object.freeze(options)
|
||||
}
|
||||
|
||||
return await invoke("plugin:dialog|open", { options });
|
||||
return await invoke('plugin:dialog|open', { options })
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,11 +195,11 @@ async function open<T extends OpenDialogOptions>(
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function save(options: SaveDialogOptions = {}): Promise<string | null> {
|
||||
if (typeof options === "object") {
|
||||
Object.freeze(options);
|
||||
if (typeof options === 'object') {
|
||||
Object.freeze(options)
|
||||
}
|
||||
|
||||
return await invoke("plugin:dialog|save", { options });
|
||||
return await invoke('plugin:dialog|save', { options })
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,15 +221,15 @@ async function save(options: SaveDialogOptions = {}): Promise<string | null> {
|
||||
*/
|
||||
async function message(
|
||||
message: string,
|
||||
options?: string | MessageDialogOptions,
|
||||
options?: string | MessageDialogOptions
|
||||
): Promise<void> {
|
||||
const opts = typeof options === "string" ? { title: options } : options;
|
||||
await invoke("plugin:dialog|message", {
|
||||
const opts = typeof options === 'string' ? { title: options } : options
|
||||
await invoke('plugin:dialog|message', {
|
||||
message: message.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
kind: opts?.kind,
|
||||
okButtonLabel: opts?.okLabel?.toString(),
|
||||
});
|
||||
okButtonLabel: opts?.okLabel?.toString()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,16 +250,16 @@ async function message(
|
||||
*/
|
||||
async function ask(
|
||||
message: string,
|
||||
options?: string | ConfirmDialogOptions,
|
||||
options?: string | ConfirmDialogOptions
|
||||
): Promise<boolean> {
|
||||
const opts = typeof options === "string" ? { title: options } : options;
|
||||
return await invoke("plugin:dialog|ask", {
|
||||
const opts = typeof options === 'string' ? { title: options } : options
|
||||
return await invoke('plugin:dialog|ask', {
|
||||
message: message.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
kind: opts?.kind,
|
||||
okButtonLabel: opts?.okLabel?.toString() ?? "Yes",
|
||||
cancelButtonLabel: opts?.cancelLabel?.toString() ?? "No",
|
||||
});
|
||||
okButtonLabel: opts?.okLabel?.toString() ?? 'Yes',
|
||||
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'No'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,16 +280,16 @@ async function ask(
|
||||
*/
|
||||
async function confirm(
|
||||
message: string,
|
||||
options?: string | ConfirmDialogOptions,
|
||||
options?: string | ConfirmDialogOptions
|
||||
): Promise<boolean> {
|
||||
const opts = typeof options === "string" ? { title: options } : options;
|
||||
return await invoke("plugin:dialog|confirm", {
|
||||
const opts = typeof options === 'string' ? { title: options } : options
|
||||
return await invoke('plugin:dialog|confirm', {
|
||||
message: message.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
kind: opts?.kind,
|
||||
okButtonLabel: opts?.okLabel?.toString() ?? "Ok",
|
||||
cancelButtonLabel: opts?.cancelLabel?.toString() ?? "Cancel",
|
||||
});
|
||||
okButtonLabel: opts?.okLabel?.toString() ?? 'Ok',
|
||||
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'Cancel'
|
||||
})
|
||||
}
|
||||
|
||||
export type {
|
||||
@@ -298,7 +298,7 @@ export type {
|
||||
OpenDialogReturn,
|
||||
SaveDialogOptions,
|
||||
MessageDialogOptions,
|
||||
ConfirmDialogOptions,
|
||||
};
|
||||
ConfirmDialogOptions
|
||||
}
|
||||
|
||||
export { open, save, message, ask, confirm };
|
||||
export { open, save, message, ask, confirm }
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
window.alert = function (message: string) {
|
||||
void invoke("plugin:dialog|message", {
|
||||
message: message.toString(),
|
||||
});
|
||||
};
|
||||
void invoke('plugin:dialog|message', {
|
||||
message: message.toString()
|
||||
})
|
||||
}
|
||||
|
||||
// @ts-expect-error tauri does not have sync IPC :(
|
||||
window.confirm = async function (message: string) {
|
||||
return await invoke("plugin:dialog|confirm", {
|
||||
message: message.toString(),
|
||||
});
|
||||
};
|
||||
return await invoke('plugin:dialog|confirm', {
|
||||
message: message.toString()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user