mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
Merge branch 'dev' into next
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
"pkgManagers": {
|
||||
"javascript": {
|
||||
"version": true,
|
||||
"getPublishedVersion": "pnpm view ${ pkgFile.pkg.name } version",
|
||||
"getPublishedVersion": "node ../../.scripts/covector/package-latest-version.js npm ${ pkgFile.pkg.name } ${ pkgFile.pkg.version }",
|
||||
"publish": ["pnpm build", "pnpm publish --access public --no-git-checks"]
|
||||
},
|
||||
"rust": {
|
||||
"version": true,
|
||||
"getPublishedVersion": "cargo search ${ pkgFile.pkg.package.name } --limit 1 | sed -nE 's/^[^\"]*\"//; s/\".*//1p' -",
|
||||
"getPublishedVersion": "node ../../.scripts/covector/package-latest-version.js cargo ${ pkgFile.pkg.package.name } ${ pkgFile.pkg.package.version }",
|
||||
"publish": [
|
||||
{
|
||||
"command": "cargo package --no-verify",
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/*
|
||||
This script is solely intended to be run as part of the `covector publish` step to
|
||||
check the latest version of a crate, considering the current minor version.
|
||||
*/
|
||||
|
||||
const https = require('https')
|
||||
|
||||
const kind = process.argv[2]
|
||||
const packageName = process.argv[3]
|
||||
const packageVersion = process.argv[4]
|
||||
const target = packageVersion.substring(0, packageVersion.lastIndexOf('.'))
|
||||
|
||||
let url = null
|
||||
switch (kind) {
|
||||
case 'cargo':
|
||||
url = `https://crates.io/api/v1/crates/${packageName}`
|
||||
break;
|
||||
case 'npm':
|
||||
url = `https://registry.npmjs.org/${packageName}`
|
||||
break;
|
||||
default:
|
||||
throw new Error('unexpected kind ' + kind)
|
||||
}
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': 'tauri (https://github.com/tauri-apps/tauri)'
|
||||
}
|
||||
}
|
||||
|
||||
https.get(url, options, (response) => {
|
||||
let chunks = []
|
||||
response.on('data', function (chunk) {
|
||||
chunks.push(chunk)
|
||||
})
|
||||
|
||||
response.on('end', function () {
|
||||
const data = JSON.parse(chunks.join(''))
|
||||
if (kind === 'cargo') {
|
||||
const versions = data.versions.filter(v => v.num.startsWith(target))
|
||||
console.log(versions.length ? versions[0].num : '0.0.0')
|
||||
} else if (kind === 'npm') {
|
||||
const versions = Object.keys(data.versions).filter(v => v.startsWith(target))
|
||||
console.log(versions[versions.length - 1] || '0.0.0')
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -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