Skip to content

Commit ed46dca

Browse files
committed
Merge remote-tracking branch 'origin/v1' into chore/merge-v1-into-v2
2 parents 1f9e7ab + 5c97db9 commit ed46dca

65 files changed

Lines changed: 1075 additions & 371 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changes/feat-log-attachlogger.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"log-js": patch
3+
---
4+
5+
Added `attachLogger` helper function to register a function that should be called for each log entry.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"single-instance": patch
3+
---
4+
5+
Added the `semver` feature flag to make the single instance mechanism only trigger for semver compatible versions.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"websocket": patch
3+
---
4+
5+
**Breaking change:** Enable rustls by default and added a method to configure the TLS Connector for tungstenite.

.changes/upload-returnval.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"upload": patch
3+
"upload-js": patch
4+
---
5+
6+
Return the upload response as a string and error out if the status code is not within 200-299.

.github/workflows/covector-version-or-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ jobs:
6464
title: "Publish New Versions"
6565
commit-message: "publish new versions"
6666
labels: "version updates"
67-
branch: "release"
67+
branch: "ci/release-v1"
6868
body: ${{ steps.covector.outputs.change }}

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
"@rollup/plugin-node-resolve": "15.2.3",
1414
"@rollup/plugin-terser": "0.4.4",
1515
"@rollup/plugin-typescript": "11.1.6",
16-
"@typescript-eslint/eslint-plugin": "6.20.0",
17-
"@typescript-eslint/parser": "6.20.0",
16+
"@typescript-eslint/eslint-plugin": "7.6.0",
17+
"@typescript-eslint/parser": "7.6.0",
1818
"covector": "^0.10.2",
19-
"eslint": "8.56.0",
19+
"eslint": "8.57.0",
2020
"eslint-config-prettier": "9.1.0",
2121
"eslint-config-standard-with-typescript": "43.0.1",
2222
"eslint-plugin-import": "2.29.1",
23-
"eslint-plugin-n": "16.6.2",
23+
"eslint-plugin-n": "17.2.1",
2424
"eslint-plugin-promise": "6.1.1",
25-
"eslint-plugin-security": "2.1.0",
26-
"prettier": "3.2.2",
27-
"rollup": "4.9.6",
25+
"eslint-plugin-security": "3.0.0",
26+
"prettier": "3.2.5",
27+
"rollup": "4.14.3",
2828
"tslib": "2.6.2",
29-
"typescript": "5.3.3"
29+
"typescript": "5.4.5"
3030
},
3131
"resolutions": {
3232
"semver": ">=7.5.2",

plugins/log/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ tauri-plugin-log = "2.0.0-beta"
2323
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
2424
```
2525

26-
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
26+
If you want the single instance mechanism to only trigger for semver compatible instances of your apps, for example if you expect users to have multiple installations of your app installed, you can add `features = ["semver"]` to the dependency declaration in `Cargo.toml`.
27+
28+
Then you can install the JavaScript Guest bindings using your preferred JavaScript package manager:
2729

2830
> 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.
2931

plugins/log/api-iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/log/guest-js/index.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
import { listen, UnlistenFn } from "@tauri-apps/api/event";
6-
75
import { invoke } from "@tauri-apps/api/core";
6+
import { listen, type UnlistenFn, type Event } from "@tauri-apps/api/event";
87

98
export type LogOptions = {
109
file?: string;
@@ -189,19 +188,38 @@ interface RecordPayload {
189188
message: string;
190189
}
191190

192-
export async function attachConsole(): Promise<UnlistenFn> {
193-
return await listen("log://log", (event) => {
194-
const payload = event.payload as RecordPayload;
191+
type LoggerFn = (fn: RecordPayload) => void;
192+
193+
/**
194+
* Attaches a listener for the log, and calls the passed function for each log entry.
195+
* @param fn
196+
*
197+
* @returns a function to cancel the listener.
198+
*/
199+
export async function attachLogger(fn: LoggerFn): Promise<UnlistenFn> {
200+
return await listen("log://log", (event: Event<RecordPayload>) => {
201+
const { level } = event.payload;
202+
let { message } = event.payload;
195203

196204
// Strip ANSI escape codes
197-
const message = payload.message.replace(
205+
message = message.replace(
198206
// TODO: Investigate security/detect-unsafe-regex
199207
// eslint-disable-next-line no-control-regex, security/detect-unsafe-regex
200208
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
201209
"",
202210
);
211+
fn({ message, level });
212+
});
213+
}
203214

204-
switch (payload.level) {
215+
/**
216+
* Attaches a listener that writes log entries to the console as they come in.
217+
*
218+
* @returns a function to cancel the listener.
219+
*/
220+
export async function attachConsole(): Promise<UnlistenFn> {
221+
return attachLogger(({ level, message }: RecordPayload) => {
222+
switch (level) {
205223
case LogLevel.Trace:
206224
console.log(message);
207225
break;
@@ -219,7 +237,7 @@ export async function attachConsole(): Promise<UnlistenFn> {
219237
break;
220238
default:
221239
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
222-
throw new Error(`unknown log level ${payload.level}`);
240+
throw new Error(`unknown log level ${level}`);
223241
}
224242
});
225243
}

0 commit comments

Comments
 (0)