mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +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:
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -9,12 +9,12 @@ repository = { workspace = true }
|
||||
links = "tauri-plugin-haptics"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustc-args = [ "--cfg", "docsrs" ]
|
||||
rustdoc-args = [ "--cfg", "docsrs" ]
|
||||
targets = [ "x86_64-linux-android" ]
|
||||
rustc-args = ["--cfg", "docsrs"]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
targets = ["x86_64-linux-android"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-plugin = { workspace = true, features = [ "build" ] }
|
||||
tauri-plugin = { workspace = true, features = ["build"] }
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -68,13 +68,13 @@ import {
|
||||
vibrate,
|
||||
impactFeedback,
|
||||
notificationFeedback,
|
||||
selectionFeedback,
|
||||
} from "@tauri-apps/plugin-haptics";
|
||||
selectionFeedback
|
||||
} from '@tauri-apps/plugin-haptics'
|
||||
|
||||
await vibrate(1);
|
||||
await impactFeedback("medium");
|
||||
await notificationFeedback("warning");
|
||||
await selectionFeedback();
|
||||
await vibrate(1)
|
||||
await impactFeedback('medium')
|
||||
await notificationFeedback('warning')
|
||||
await selectionFeedback()
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -20,4 +20,4 @@ We prefer to receive reports in English.
|
||||
|
||||
Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new).
|
||||
|
||||
Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app).
|
||||
Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app).
|
||||
|
||||
@@ -11,54 +11,54 @@ export const commands = {
|
||||
async vibrate(duration: number): Promise<Result<null, Error>> {
|
||||
try {
|
||||
return {
|
||||
status: "ok",
|
||||
data: await TAURI_INVOKE("plugin:haptics|vibrate", { duration }),
|
||||
};
|
||||
status: 'ok',
|
||||
data: await TAURI_INVOKE('plugin:haptics|vibrate', { duration })
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) throw e;
|
||||
else return { status: "error", error: e as any };
|
||||
if (e instanceof Error) throw e
|
||||
else return { status: 'error', error: e as any }
|
||||
}
|
||||
},
|
||||
async impactFeedback(
|
||||
style: ImpactFeedbackStyle,
|
||||
style: ImpactFeedbackStyle
|
||||
): Promise<Result<null, Error>> {
|
||||
try {
|
||||
return {
|
||||
status: "ok",
|
||||
data: await TAURI_INVOKE("plugin:haptics|impact_feedback", { style }),
|
||||
};
|
||||
status: 'ok',
|
||||
data: await TAURI_INVOKE('plugin:haptics|impact_feedback', { style })
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) throw e;
|
||||
else return { status: "error", error: e as any };
|
||||
if (e instanceof Error) throw e
|
||||
else return { status: 'error', error: e as any }
|
||||
}
|
||||
},
|
||||
async notificationFeedback(
|
||||
type: NotificationFeedbackType,
|
||||
type: NotificationFeedbackType
|
||||
): Promise<Result<null, Error>> {
|
||||
try {
|
||||
return {
|
||||
status: "ok",
|
||||
data: await TAURI_INVOKE("plugin:haptics|notification_feedback", {
|
||||
type,
|
||||
}),
|
||||
};
|
||||
status: 'ok',
|
||||
data: await TAURI_INVOKE('plugin:haptics|notification_feedback', {
|
||||
type
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) throw e;
|
||||
else return { status: "error", error: e as any };
|
||||
if (e instanceof Error) throw e
|
||||
else return { status: 'error', error: e as any }
|
||||
}
|
||||
},
|
||||
async selectionFeedback(): Promise<Result<null, Error>> {
|
||||
try {
|
||||
return {
|
||||
status: "ok",
|
||||
data: await TAURI_INVOKE("plugin:haptics|selection_feedback"),
|
||||
};
|
||||
status: 'ok',
|
||||
data: await TAURI_INVOKE('plugin:haptics|selection_feedback')
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) throw e;
|
||||
else return { status: "error", error: e as any };
|
||||
if (e instanceof Error) throw e
|
||||
else return { status: 'error', error: e as any }
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** user-defined events **/
|
||||
|
||||
@@ -72,69 +72,69 @@ export const commands = {
|
||||
|
||||
/** user-defined types **/
|
||||
|
||||
export type Error = never;
|
||||
export type Error = never
|
||||
export type ImpactFeedbackStyle =
|
||||
| "light"
|
||||
| "medium"
|
||||
| "heavy"
|
||||
| "soft"
|
||||
| "rigid";
|
||||
export type NotificationFeedbackType = "success" | "warning" | "error";
|
||||
| 'light'
|
||||
| 'medium'
|
||||
| 'heavy'
|
||||
| 'soft'
|
||||
| 'rigid'
|
||||
export type NotificationFeedbackType = 'success' | 'warning' | 'error'
|
||||
//export type RandomNumber = number;
|
||||
|
||||
/** tauri-specta globals **/
|
||||
|
||||
import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
|
||||
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
|
||||
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
|
||||
import { invoke as TAURI_INVOKE } from '@tauri-apps/api/core'
|
||||
import * as TAURI_API_EVENT from '@tauri-apps/api/event'
|
||||
import { type WebviewWindow as __WebviewWindow__ } from '@tauri-apps/api/webviewWindow'
|
||||
|
||||
type __EventObj__<T> = {
|
||||
listen: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
|
||||
cb: TAURI_API_EVENT.EventCallback<T>
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>
|
||||
once: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
|
||||
cb: TAURI_API_EVENT.EventCallback<T>
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>
|
||||
emit: T extends null
|
||||
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
|
||||
};
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
}
|
||||
|
||||
export type Result<T, E> =
|
||||
| { status: "ok"; data: T }
|
||||
| { status: "error"; error: E };
|
||||
| { status: 'ok'; data: T }
|
||||
| { status: 'error'; error: E }
|
||||
|
||||
function __makeEvents__<T extends Record<string, any>>(
|
||||
mappings: Record<keyof T, string>,
|
||||
mappings: Record<keyof T, string>
|
||||
) {
|
||||
return new Proxy(
|
||||
{} as unknown as {
|
||||
[K in keyof T]: __EventObj__<T[K]> & {
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>;
|
||||
};
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>
|
||||
}
|
||||
},
|
||||
{
|
||||
get: (_, event) => {
|
||||
const name = mappings[event as keyof T];
|
||||
const name = mappings[event as keyof T]
|
||||
|
||||
return new Proxy((() => {}) as any, {
|
||||
apply: (_, __, [window]: [__WebviewWindow__]) => ({
|
||||
listen: (arg: any) => window.listen(name, arg),
|
||||
once: (arg: any) => window.once(name, arg),
|
||||
emit: (arg: any) => window.emit(name, arg),
|
||||
emit: (arg: any) => window.emit(name, arg)
|
||||
}),
|
||||
get: (_, command: keyof __EventObj__<any>) => {
|
||||
switch (command) {
|
||||
case "listen":
|
||||
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
|
||||
case "once":
|
||||
return (arg: any) => TAURI_API_EVENT.once(name, arg);
|
||||
case "emit":
|
||||
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
|
||||
case 'listen':
|
||||
return (arg: any) => TAURI_API_EVENT.listen(name, arg)
|
||||
case 'once':
|
||||
return (arg: any) => TAURI_API_EVENT.once(name, arg)
|
||||
case 'emit':
|
||||
return (arg: any) => TAURI_API_EVENT.emit(name, arg)
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
|
||||
import { commands } from "./bindings";
|
||||
import { commands } from './bindings'
|
||||
|
||||
export const {
|
||||
vibrate,
|
||||
impactFeedback,
|
||||
notificationFeedback,
|
||||
selectionFeedback,
|
||||
} = commands;
|
||||
selectionFeedback
|
||||
} = commands
|
||||
|
||||
export { ImpactFeedbackStyle, NotificationFeedbackType } from "./bindings";
|
||||
export { ImpactFeedbackStyle, NotificationFeedbackType } from './bindings'
|
||||
|
||||
// export { events };
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { createConfig } from "../../shared/rollup.config.js";
|
||||
import { createConfig } from '../../shared/rollup.config.js'
|
||||
|
||||
export default createConfig();
|
||||
export default createConfig()
|
||||
|
||||
Reference in New Issue
Block a user