mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
Merge branch 'dev' into next
This commit is contained in:
@@ -54,13 +54,21 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind
|
||||
import { watch, watchImmediate } from 'tauri-plugin-fs-watch-api';
|
||||
|
||||
// can also watch an array of paths
|
||||
const stopWatching = await watch('/path/to/something', { recursive: true }, (event) => {
|
||||
const stopWatching = await watch(
|
||||
"/path/to/something",
|
||||
(event) => {
|
||||
const { type, payload } = event;
|
||||
});
|
||||
},
|
||||
{ recursive: true }
|
||||
);
|
||||
|
||||
const stopRawWatcher = await watchImmediate(['/path/a', '/path/b'], {}, (event) => {
|
||||
const stopRawWatcher = await watchImmediate(
|
||||
["/path/a", "/path/b"],
|
||||
(event) => {
|
||||
const { path, operation, cookie } = event;
|
||||
});
|
||||
},
|
||||
{}
|
||||
);
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -44,8 +44,8 @@ async function unwatch(id: number): Promise<void> {
|
||||
|
||||
export async function watch(
|
||||
paths: string | string[],
|
||||
options: DebouncedWatchOptions,
|
||||
cb: (event: DebouncedEvent) => void
|
||||
cb: (event: DebouncedEvent) => void,
|
||||
options: DebouncedWatchOptions = {}
|
||||
): Promise<UnlistenFn> {
|
||||
const opts = {
|
||||
recursive: false,
|
||||
@@ -82,8 +82,8 @@ export async function watch(
|
||||
|
||||
export async function watchImmediate(
|
||||
paths: string | string[],
|
||||
options: WatchOptions,
|
||||
cb: (event: RawEvent) => void
|
||||
cb: (event: RawEvent) => void,
|
||||
options: WatchOptions = {}
|
||||
): Promise<UnlistenFn> {
|
||||
const opts = {
|
||||
recursive: false,
|
||||
|
||||
@@ -52,10 +52,15 @@ async function log(
|
||||
|
||||
const { file, line, ...keyValues } = options ?? {};
|
||||
|
||||
let location = filtered?.[0]?.filter((v) => v.length > 0).join("@");
|
||||
if (location === "Error") {
|
||||
location = "webview::unknown";
|
||||
}
|
||||
|
||||
await invoke("plugin:log|log", {
|
||||
level,
|
||||
message,
|
||||
location: filtered?.[0]?.filter((v) => v.length > 0).join("@"),
|
||||
location,
|
||||
file,
|
||||
line,
|
||||
keyValues,
|
||||
|
||||
@@ -178,8 +178,8 @@ fn log(
|
||||
let location = location.unwrap_or("webview");
|
||||
let mut builder = RecordBuilder::new();
|
||||
builder
|
||||
.target(location)
|
||||
.level(level.into())
|
||||
.target(location)
|
||||
.file(file)
|
||||
.line(line);
|
||||
|
||||
@@ -251,8 +251,8 @@ impl Builder {
|
||||
out.finish(format_args!(
|
||||
"{}[{}][{}] {}",
|
||||
timezone_strategy.get_now().format(&format).unwrap(),
|
||||
record.target(),
|
||||
record.level(),
|
||||
record.target(),
|
||||
message
|
||||
))
|
||||
});
|
||||
@@ -311,8 +311,8 @@ impl Builder {
|
||||
out.finish(format_args!(
|
||||
"{}[{}][{}] {}",
|
||||
timezone_strategy.get_now().format(&format).unwrap(),
|
||||
record.target(),
|
||||
colors.color(record.level()),
|
||||
record.target(),
|
||||
message
|
||||
))
|
||||
})
|
||||
|
||||
@@ -30,11 +30,11 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa
|
||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||
|
||||
```sh
|
||||
pnpm add tauri-plugin-positioner
|
||||
pnpm add tauri-plugin-positioner-api
|
||||
# or
|
||||
npm add tauri-plugin-positioner
|
||||
npm add tauri-plugin-positioner-api
|
||||
# or
|
||||
yarn add tauri-plugin-positioner
|
||||
yarn add tauri-plugin-positioner-api
|
||||
```
|
||||
|
||||
Or through git:
|
||||
|
||||
@@ -79,15 +79,14 @@ enum WebSocketMessage {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn connect<R: Runtime>(
|
||||
async fn connect<R: Runtime>(
|
||||
window: Window<R>,
|
||||
url: String,
|
||||
callback_function: CallbackFn,
|
||||
config: Option<ConnectionConfig>,
|
||||
) -> Result<Id> {
|
||||
let id = rand::random();
|
||||
let (ws_stream, _) =
|
||||
tauri::async_runtime::block_on(connect_async_with_config(url, config.map(Into::into)))?;
|
||||
let (ws_stream, _) = connect_async_with_config(url, config.map(Into::into)).await?;
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let (write, read) = ws_stream.split();
|
||||
|
||||
Reference in New Issue
Block a user