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:
Amr Bashir
2024-09-04 14:54:23 +03:00
committed by GitHub
parent 72c2ce82c1
commit cf4d7d4e6c
227 changed files with 2534 additions and 2505 deletions
-1
View File
@@ -1 +0,0 @@
/.tauri
+4 -4
View File
@@ -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 }
+6 -6
View File
@@ -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
+1 -1
View File
@@ -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).
+60 -60
View File
@@ -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 -4
View File
@@ -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 -2
View File
@@ -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()