diff --git a/app.vue b/app.vue
index d2ba216a..6a73749a 100644
--- a/app.vue
+++ b/app.vue
@@ -1,4 +1,5 @@
@@ -69,12 +70,12 @@ const avatarOnAvatar = $(computedEager(() => useFeatureFlags().experimentalAvata
-
+
-
diff --git a/composables/log.ts b/composables/log.ts
new file mode 100644
index 00000000..b3db4ef5
--- /dev/null
+++ b/composables/log.ts
@@ -0,0 +1,21 @@
+import * as log from 'tauri-plugin-log-api'
+
+// When running inside Tauri, catch all logs from 3rd party packages and direct them to the unified logging stream
+export function setupLogging() {
+ if (import.meta.env.TAURI_PLATFORM) {
+ // eslint-disable-next-line no-global-assign
+ console = {
+ ...console,
+ trace: log.trace,
+ debug: log.debug,
+ log: log.info,
+ warn: log.warn,
+ error: log.error,
+ }
+
+ window.addEventListener('unhandledrejection', err =>
+ log.error(err.reason),
+ )
+ window.addEventListener('error', err => log.error(err.error), true)
+ }
+}
diff --git a/nuxt.config.ts b/nuxt.config.ts
index b068c41c..86c61a82 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -32,6 +32,10 @@ export default defineNuxtConfig({
querystring: 'rollup-plugin-node-polyfills/polyfills/qs',
},
vite: {
+ // to make use of `TAURI_PLATFORM`, `TAURI_ARCH`, `TAURI_FAMILY`,
+ // `TAURI_PLATFORM_VERSION`, `TAURI_PLATFORM_TYPE` and `TAURI_DEBUG`
+ // env variables
+ envPrefix: ['VITE_', 'TAURI_'],
define: {
'import.meta.env.__BUILD_TIME__': JSON.stringify(new Date().toISOString()),
'import.meta.env.__BUILD_COMMIT__': JSON.stringify(process.env.COMMIT_REF || ''),
@@ -39,7 +43,7 @@ export default defineNuxtConfig({
'process.mock': ((!isCI || isPreview) && process.env.MOCK_USER) || 'false',
},
build: {
- target: 'esnext',
+ target: process.env.TAURI_PLATFORM ? ['es2021', 'chrome100', 'safari13'] : 'esnext',
},
plugins: [
Inspect(),
diff --git a/package.json b/package.json
index 13f22078..94ef7c39 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,8 @@
"postinstall": "nuxi prepare && simple-git-hooks"
},
"dependencies": {
- "@fnando/sparkline": "^0.3.10"
+ "@fnando/sparkline": "^0.3.10",
+ "tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log"
},
"devDependencies": {
"@antfu/eslint-config": "^0.33.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5bf9a4ac..a0e1a0ca 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -57,6 +57,7 @@ specifiers:
shiki-es: ^0.1.2
simple-git-hooks: ^2.8.1
std-env: ^3.3.1
+ tauri-plugin-log-api: github:tauri-apps/tauri-plugin-log
theme-vitesse: ^0.6.0
tippy.js: ^6.3.7
typescript: ^4.9.3
@@ -71,6 +72,7 @@ specifiers:
dependencies:
'@fnando/sparkline': 0.3.10
+ tauri-plugin-log-api: github.com/tauri-apps/tauri-plugin-log/b58475bbc410fa78eb69276c62d0b64c91c07914
devDependencies:
'@antfu/eslint-config': 0.33.1_s5ps7njkmjlaqajutnox5ntcla
@@ -1316,6 +1318,11 @@ packages:
rollup: 2.79.1
dev: true
+ /@tauri-apps/api/1.2.0:
+ resolution: {integrity: sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==}
+ engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
+ dev: false
+
/@tiptap/core/2.0.0-beta.204:
resolution: {integrity: sha512-MH4LQE6rvX+DAy83tZH5E6gaA/hO5A6F/w5ZM6En5PcRhNsgpfQl+kjRfeVQYahxouc1mzetayhRe4XQ8PAwng==}
dependencies:
@@ -8243,7 +8250,6 @@ packages:
/tslib/2.4.1:
resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==}
- dev: true
/tsutils/3.21.0_typescript@4.9.3:
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
@@ -9280,3 +9286,12 @@ packages:
compress-commons: 4.1.1
readable-stream: 3.6.0
dev: true
+
+ github.com/tauri-apps/tauri-plugin-log/b58475bbc410fa78eb69276c62d0b64c91c07914:
+ resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/b58475bbc410fa78eb69276c62d0b64c91c07914}
+ name: tauri-plugin-log-api
+ version: 0.1.0
+ dependencies:
+ '@tauri-apps/api': 1.2.0
+ tslib: 2.4.1
+ dev: false