Merge branch 'dev' into next

pull/340/head^2
Lucas Nogueira 2 years ago
commit 4470468d7b
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

@ -3,12 +3,12 @@
"pkgManagers": { "pkgManagers": {
"javascript": { "javascript": {
"version": true, "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"] "publish": ["pnpm build", "pnpm publish --access public --no-git-checks"]
}, },
"rust": { "rust": {
"version": true, "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": [ "publish": [
{ {
"command": "cargo package --no-verify", "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'; import { watch, watchImmediate } from 'tauri-plugin-fs-watch-api';
// can also watch an array of paths // 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; 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; const { path, operation, cookie } = event;
}); },
{}
);
``` ```
## Contributing ## Contributing

@ -44,8 +44,8 @@ async function unwatch(id: number): Promise<void> {
export async function watch( export async function watch(
paths: string | string[], paths: string | string[],
options: DebouncedWatchOptions, cb: (event: DebouncedEvent) => void,
cb: (event: DebouncedEvent) => void options: DebouncedWatchOptions = {}
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
const opts = { const opts = {
recursive: false, recursive: false,
@ -82,8 +82,8 @@ export async function watch(
export async function watchImmediate( export async function watchImmediate(
paths: string | string[], paths: string | string[],
options: WatchOptions, cb: (event: RawEvent) => void,
cb: (event: RawEvent) => void options: WatchOptions = {}
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
const opts = { const opts = {
recursive: false, recursive: false,

@ -52,10 +52,15 @@ async function log(
const { file, line, ...keyValues } = options ?? {}; 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", { await invoke("plugin:log|log", {
level, level,
message, message,
location: filtered?.[0]?.filter((v) => v.length > 0).join("@"), location,
file, file,
line, line,
keyValues, keyValues,

@ -178,8 +178,8 @@ fn log(
let location = location.unwrap_or("webview"); let location = location.unwrap_or("webview");
let mut builder = RecordBuilder::new(); let mut builder = RecordBuilder::new();
builder builder
.target(location)
.level(level.into()) .level(level.into())
.target(location)
.file(file) .file(file)
.line(line); .line(line);
@ -251,8 +251,8 @@ impl Builder {
out.finish(format_args!( out.finish(format_args!(
"{}[{}][{}] {}", "{}[{}][{}] {}",
timezone_strategy.get_now().format(&format).unwrap(), timezone_strategy.get_now().format(&format).unwrap(),
record.target(),
record.level(), record.level(),
record.target(),
message message
)) ))
}); });
@ -311,8 +311,8 @@ impl Builder {
out.finish(format_args!( out.finish(format_args!(
"{}[{}][{}] {}", "{}[{}][{}] {}",
timezone_strategy.get_now().format(&format).unwrap(), timezone_strategy.get_now().format(&format).unwrap(),
record.target(),
colors.color(record.level()), colors.color(record.level()),
record.target(),
message 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. > 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 ```sh
pnpm add tauri-plugin-positioner pnpm add tauri-plugin-positioner-api
# or # or
npm add tauri-plugin-positioner npm add tauri-plugin-positioner-api
# or # or
yarn add tauri-plugin-positioner yarn add tauri-plugin-positioner-api
``` ```
Or through git: Or through git:

@ -79,15 +79,14 @@ enum WebSocketMessage {
} }
#[tauri::command] #[tauri::command]
fn connect<R: Runtime>( async fn connect<R: Runtime>(
window: Window<R>, window: Window<R>,
url: String, url: String,
callback_function: CallbackFn, callback_function: CallbackFn,
config: Option<ConnectionConfig>, config: Option<ConnectionConfig>,
) -> Result<Id> { ) -> Result<Id> {
let id = rand::random(); let id = rand::random();
let (ws_stream, _) = let (ws_stream, _) = connect_async_with_config(url, config.map(Into::into)).await?;
tauri::async_runtime::block_on(connect_async_with_config(url, config.map(Into::into)))?;
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
let (write, read) = ws_stream.split(); let (write, read) = ws_stream.split();

Loading…
Cancel
Save