refactor: remove tauri module/integration (#3377)
This commit is contained in:
parent
6f7806fa95
commit
4e96759f8c
13 changed files with 16 additions and 262 deletions
|
@ -30,12 +30,11 @@ const containerClass = computed(() => {
|
|||
sticky top-0 z-20
|
||||
pt="[env(safe-area-inset-top,0)]"
|
||||
bg="[rgba(var(--rgb-bg-base),0.7)]"
|
||||
class="native:lg:w-[calc(100vw-5rem)] native:xl:w-[calc(135%+(100vw-1200px)/2)]"
|
||||
:class="{
|
||||
'backdrop-blur': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
|
||||
}"
|
||||
>
|
||||
<div flex justify-between gap-2 min-h-53px px5 py1 :class="{ 'xl:hidden': $route.name !== 'tag' }" class="native:xl:flex" border="b base">
|
||||
<div flex justify-between gap-2 min-h-53px px5 py1 :class="{ 'xl:hidden': $route.name !== 'tag' }" border="b base">
|
||||
<div flex gap-2 items-center :overflow-hidden="!noOverflowHidden ? '' : false" w-full>
|
||||
<button
|
||||
v-if="backOnSmallScreen || back"
|
||||
|
@ -45,7 +44,7 @@ const containerClass = computed(() => {
|
|||
>
|
||||
<div text-lg i-ri:arrow-left-line class="rtl-flip" />
|
||||
</button>
|
||||
<div :truncate="!noOverflowHidden ? '' : false" flex w-full data-tauri-drag-region class="native-mac:justify-start native-mac:text-center">
|
||||
<div :truncate="!noOverflowHidden ? '' : false" flex w-full class="native-mac:justify-start native-mac:text-center">
|
||||
<slot name="title" />
|
||||
</div>
|
||||
<div sm:hidden h-7 w-1px />
|
||||
|
|
|
@ -18,7 +18,7 @@ router.afterEach(() => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div flex justify-between sticky top-0 bg-base z-1 py-4 native:py-7 data-tauri-drag-region>
|
||||
<div flex justify-between sticky top-0 bg-base z-1 py-4>
|
||||
<NuxtLink
|
||||
flex items-end gap-3
|
||||
py2 px-5
|
||||
|
|
|
@ -16,9 +16,9 @@ const instance = instanceStorage.value[currentServer.value]
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div h-full :data-mode="isHydrated && isGrayscale ? 'grayscale' : ''" data-tauri-drag-region>
|
||||
<main flex w-full mxa lg:max-w-80rem class="native:grid native:sm:grid-cols-[auto_1fr] native:lg:grid-cols-[auto_minmax(600px,2fr)_1fr]">
|
||||
<aside class="native:w-auto w-1/8 md:w-1/6 lg:w-1/5 xl:w-1/4 zen-hide" hidden sm:flex justify-end xl:me-4 native:me-0 relative>
|
||||
<div h-full :data-mode="isHydrated && isGrayscale ? 'grayscale' : ''">
|
||||
<main flex w-full mxa lg:max-w-80rem>
|
||||
<aside class="w-1/8 md:w-1/6 lg:w-1/5 xl:w-1/4 zen-hide" hidden sm:flex justify-end xl:me-4 relative>
|
||||
<div sticky top-0 w-20 xl:w-100 h-100dvh flex="~ col" lt-xl-items-center>
|
||||
<slot name="left">
|
||||
<div flex="~ col" overflow-y-auto justify-between h-full max-w-full overflow-x-hidden>
|
||||
|
@ -60,7 +60,7 @@ const instance = instanceStorage.value[currentServer.value]
|
|||
<NavBottom v-if="isHydrated" sm:hidden />
|
||||
</div>
|
||||
</div>
|
||||
<aside v-if="isHydrated && !wideLayout" class="hidden lg:w-1/5 xl:w-1/4 sm:none xl:block native:w-full zen-hide">
|
||||
<aside v-if="isHydrated && !wideLayout" class="hidden lg:w-1/5 xl:w-1/4 sm:none xl:block zen-hide">
|
||||
<div sticky top-0 h-100dvh flex="~ col" gap-2 py3 ms-2>
|
||||
<slot name="right">
|
||||
<SearchWidget mt-4 mx-1 hidden xl:block />
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
import { rm } from 'node:fs/promises'
|
||||
import { addImports, addImportsSources, addPlugin, createResolver, defineNuxtModule, useNuxt } from '@nuxt/kit'
|
||||
import { resolveModulePath } from 'exsolve'
|
||||
|
||||
const mockProxy = resolveModulePath('mocked-exports/proxy', { from: import.meta.url })
|
||||
|
||||
export default defineNuxtModule({
|
||||
meta: {
|
||||
name: 'tauri',
|
||||
},
|
||||
setup() {
|
||||
const nuxt = useNuxt()
|
||||
const { resolve } = createResolver(import.meta.url)
|
||||
|
||||
if (!process.env.TAURI_PLATFORM)
|
||||
return
|
||||
|
||||
if (nuxt.options.dev)
|
||||
nuxt.options.ssr = false
|
||||
|
||||
nuxt.options.pwa.disable = true
|
||||
nuxt.options.sourcemap.client = false
|
||||
|
||||
nuxt.options.alias = {
|
||||
...nuxt.options.alias,
|
||||
'unstorage/drivers/fs': mockProxy,
|
||||
'unstorage/drivers/cloudflare-kv-http': mockProxy,
|
||||
'#storage-config': resolve('./runtime/storage-config'),
|
||||
'node:events': 'unenv/runtime/node/events/index',
|
||||
'#build-info': resolve('./runtime/build-info'),
|
||||
}
|
||||
|
||||
nuxt.hook('vite:extend', ({ config }) => {
|
||||
config.build!.target = ['chrome100', 'safari15']
|
||||
config.envPrefix = [...config.envPrefix || [], 'VITE_', 'TAURI_']
|
||||
})
|
||||
|
||||
// prevent creation of server routes
|
||||
nuxt.hook('nitro:config', (config) => {
|
||||
config.srcDir = './_nonexistent'
|
||||
config.scanDirs = []
|
||||
})
|
||||
|
||||
addImportsSources({
|
||||
from: 'h3',
|
||||
imports: ['defineEventHandler', 'getQuery', 'getRouterParams', 'readBody', 'sendRedirect'] as Array<keyof typeof import('h3')>,
|
||||
})
|
||||
|
||||
nuxt.options.imports.dirs = nuxt.options.imports.dirs || []
|
||||
nuxt.options.imports.dirs.push(resolve('../../server/utils'))
|
||||
|
||||
addImports({ name: 'useStorage', from: resolve('./runtime/storage') })
|
||||
|
||||
addPlugin(resolve('./runtime/logging.client'))
|
||||
addPlugin(resolve('./runtime/nitro.client'))
|
||||
|
||||
// cleanup files copied from the public folder that we don't need
|
||||
nuxt.hook('close', async () => {
|
||||
await rm('.output/public/_redirects')
|
||||
await rm('.output/public/apple-touch-icon.png')
|
||||
await rm('.output/public/elk-og.png')
|
||||
await rm('.output/public/favicon.ico')
|
||||
await rm('.output/public/pwa-192x192.png')
|
||||
await rm('.output/public/pwa-512x512.png')
|
||||
await rm('.output/public/robots.txt')
|
||||
})
|
||||
},
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
export const env = useAppConfig().env
|
|
@ -1,18 +0,0 @@
|
|||
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 default defineNuxtPlugin(() => {
|
||||
// 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)
|
||||
})
|
|
@ -1,73 +0,0 @@
|
|||
import type { FetchResponse } from 'ofetch'
|
||||
import {
|
||||
createApp,
|
||||
createRouter,
|
||||
defineLazyEventHandler,
|
||||
toNodeListener,
|
||||
} from 'h3'
|
||||
import { fetchNodeRequestHandler } from 'node-mock-http'
|
||||
import { createFetch } from 'ofetch'
|
||||
|
||||
const handlers = [
|
||||
{
|
||||
route: '/api/:server/oauth',
|
||||
handler: defineLazyEventHandler(() => import('~~/server/api/[server]/oauth/[origin]').then(r => r.default || r)),
|
||||
},
|
||||
{
|
||||
route: '/api/:server/login',
|
||||
handler: defineLazyEventHandler(() => import('~~/server/api/[server]/login').then(r => r.default || r)),
|
||||
},
|
||||
{
|
||||
route: '/api/list-servers',
|
||||
handler: defineLazyEventHandler(() => import('~~/server/api/list-servers').then(r => r.default || r)),
|
||||
},
|
||||
]
|
||||
|
||||
// @ts-expect-error undeclared global window property
|
||||
window.__NUXT__.config = {
|
||||
// @ts-expect-error undeclared global window property
|
||||
...window.__NUXT__.config,
|
||||
storage: {},
|
||||
}
|
||||
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
const h3App = createApp({
|
||||
debug: import.meta.dev,
|
||||
// TODO: add global error handler
|
||||
// onError: (err, event) => {
|
||||
// console.log({ err, event })
|
||||
// },
|
||||
})
|
||||
|
||||
const router = createRouter()
|
||||
|
||||
for (const h of handlers)
|
||||
router.use(h.route, h.handler)
|
||||
|
||||
// @ts-expect-error TODO: fix
|
||||
h3App.use(config.app.baseURL, router)
|
||||
|
||||
const nodeHandler = toNodeListener(h3App)
|
||||
const localFetch: typeof fetch = async (input, init) => {
|
||||
if (!input.toString().startsWith('/')) {
|
||||
return globalThis.fetch(input.toString(), init)
|
||||
}
|
||||
return await fetchNodeRequestHandler(nodeHandler, input.toString(), init)
|
||||
}
|
||||
|
||||
// @ts-expect-error error types are subtly different here in a future nitro version
|
||||
globalThis.$fetch = createFetch({
|
||||
fetch: localFetch,
|
||||
Headers,
|
||||
defaults: { baseURL: config.app.baseURL },
|
||||
})
|
||||
|
||||
const route = useRoute()
|
||||
if (route.path.startsWith('/api')) {
|
||||
const result = (await ($fetch.raw as any)(route.fullPath)) as FetchResponse<unknown>
|
||||
if (result.headers.get('location'))
|
||||
location.href = result.headers.get('location')!
|
||||
}
|
||||
})
|
|
@ -1,2 +0,0 @@
|
|||
export const driver = undefined
|
||||
export const fsBase = ''
|
|
@ -1,29 +0,0 @@
|
|||
import { Store } from 'tauri-plugin-store-api'
|
||||
import { createStorage } from 'unstorage'
|
||||
|
||||
const store = new Store('.servers.dat')
|
||||
const storage = createStorage()
|
||||
storage.mount('servers', {
|
||||
getKeys() {
|
||||
return store.keys()
|
||||
},
|
||||
async removeItem(key: string) {
|
||||
await store.delete(key)
|
||||
},
|
||||
clear() {
|
||||
return store.clear()
|
||||
},
|
||||
hasItem(key: string) {
|
||||
return store.has(key)
|
||||
},
|
||||
setItem(key: string, value: any) {
|
||||
return store.set(key, value)
|
||||
},
|
||||
getItem(key: string) {
|
||||
return store.get(key)
|
||||
},
|
||||
})
|
||||
|
||||
export function useStorage() {
|
||||
return storage
|
||||
}
|
|
@ -40,7 +40,6 @@ export default defineNuxtConfig({
|
|||
'~~/modules/emoji-mart-translation',
|
||||
'~~/modules/purge-comments',
|
||||
'~~/modules/build-env',
|
||||
'~~/modules/tauri/index',
|
||||
'~~/modules/pwa/index', // change to '@vite-pwa/nuxt' once released and remove pwa module
|
||||
'stale-dep/nuxt',
|
||||
],
|
||||
|
@ -69,9 +68,7 @@ export default defineNuxtConfig({
|
|||
'~/styles/default-theme.css',
|
||||
'~/styles/vars.css',
|
||||
'~/styles/global.css',
|
||||
...process.env.TAURI_PLATFORM === 'macos'
|
||||
? []
|
||||
: ['~/styles/scrollbars.css'],
|
||||
'~/styles/scrollbars.css',
|
||||
'~/styles/tiptap.css',
|
||||
'~/styles/dropdown.css',
|
||||
],
|
||||
|
|
|
@ -88,7 +88,6 @@
|
|||
"masto": "^6.10.4",
|
||||
"mocked-exports": "^0.1.1",
|
||||
"node-emoji": "^2.1.3",
|
||||
"node-mock-http": "^1.0.0",
|
||||
"nuxt-security": "^2.2.0",
|
||||
"page-lifecycle": "^0.1.2",
|
||||
"pinia": "^3.0.2",
|
||||
|
@ -101,8 +100,6 @@
|
|||
"stale-dep": "^0.8.0",
|
||||
"std-env": "^3.7.0",
|
||||
"string-length": "^5.0.1",
|
||||
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log",
|
||||
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
|
||||
"theme-vitesse": "^0.8.0",
|
||||
"tiny-decode": "^0.1.3",
|
||||
"tippy.js": "^6.3.7",
|
||||
|
|
31
pnpm-lock.yaml
generated
31
pnpm-lock.yaml
generated
|
@ -184,9 +184,6 @@ importers:
|
|||
node-emoji:
|
||||
specifier: ^2.1.3
|
||||
version: 2.1.3
|
||||
node-mock-http:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
nuxt-security:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0(magicast@0.3.5)(rollup@4.46.2)
|
||||
|
@ -223,12 +220,6 @@ importers:
|
|||
string-length:
|
||||
specifier: ^5.0.1
|
||||
version: 5.0.1
|
||||
tauri-plugin-log-api:
|
||||
specifier: github:tauri-apps/tauri-plugin-log
|
||||
version: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/f76f6c56a5f63e9192c5e05fafbd114b9c455ee6
|
||||
tauri-plugin-store-api:
|
||||
specifier: github:tauri-apps/tauri-plugin-store
|
||||
version: https://codeload.github.com/tauri-apps/tauri-plugin-store/tar.gz/56f690f2432e4fd85f53ec32e22de8c2d7a11651
|
||||
theme-vitesse:
|
||||
specifier: ^0.8.0
|
||||
version: 0.8.3
|
||||
|
@ -3506,10 +3497,6 @@ packages:
|
|||
'@surma/rollup-plugin-off-main-thread@2.2.3':
|
||||
resolution: {integrity: sha512-lR8q/9W7hZpMWweNiAKU7NQerBnzQQLvi8qnTDU/fxItPhtZVMbPV3lbCwjhIlNBe9Bbr5V+KHshvWmVSG9cxQ==}
|
||||
|
||||
'@tauri-apps/api@1.6.0':
|
||||
resolution: {integrity: sha512-rqI++FWClU5I2UBp4HXFvl+sBWkdigBkxnpJDQUWttNyG7IZP4FwQGhTNL5EOw0vI8i6eSAJ5frLqO7n7jbJdg==}
|
||||
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
|
||||
|
||||
'@tiptap/core@2.2.4':
|
||||
resolution: {integrity: sha512-cRrI8IlLIhCE1hacBQzXIC8dsRvGq6a4lYWQK/BaHuZg21CG7szp3Vd8Ix+ra1f5v0xPOT+Hy+QFNQooRMKMCw==}
|
||||
peerDependencies:
|
||||
|
@ -9019,14 +9006,6 @@ packages:
|
|||
resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
tauri-plugin-log-api@https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/f76f6c56a5f63e9192c5e05fafbd114b9c455ee6:
|
||||
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/f76f6c56a5f63e9192c5e05fafbd114b9c455ee6}
|
||||
version: 0.0.0
|
||||
|
||||
tauri-plugin-store-api@https://codeload.github.com/tauri-apps/tauri-plugin-store/tar.gz/56f690f2432e4fd85f53ec32e22de8c2d7a11651:
|
||||
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-store/tar.gz/56f690f2432e4fd85f53ec32e22de8c2d7a11651}
|
||||
version: 0.0.0
|
||||
|
||||
temp-dir@2.0.0:
|
||||
resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -13573,8 +13552,6 @@ snapshots:
|
|||
magic-string: 0.25.9
|
||||
string.prototype.matchall: 4.0.8
|
||||
|
||||
'@tauri-apps/api@1.6.0': {}
|
||||
|
||||
'@tiptap/core@2.2.4(@tiptap/pm@2.2.4)':
|
||||
dependencies:
|
||||
'@tiptap/pm': 2.2.4
|
||||
|
@ -20917,14 +20894,6 @@ snapshots:
|
|||
mkdirp: 3.0.1
|
||||
yallist: 5.0.0
|
||||
|
||||
tauri-plugin-log-api@https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/f76f6c56a5f63e9192c5e05fafbd114b9c455ee6:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 1.6.0
|
||||
|
||||
tauri-plugin-store-api@https://codeload.github.com/tauri-apps/tauri-plugin-store/tar.gz/56f690f2432e4fd85f53ec32e22de8c2d7a11651:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 1.6.0
|
||||
|
||||
temp-dir@2.0.0: {}
|
||||
|
||||
tempy@0.6.0:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import type { Variant } from 'unocss'
|
||||
import process from 'node:process'
|
||||
import { variantParentMatcher } from '@unocss/preset-mini/utils'
|
||||
|
||||
import {
|
||||
|
@ -108,18 +106,6 @@ export default defineConfig({
|
|||
},
|
||||
},
|
||||
variants: [
|
||||
...(process.env.TAURI_PLATFORM
|
||||
? <Variant<any>[]>[(matcher) => {
|
||||
if (!matcher.startsWith('native:'))
|
||||
return
|
||||
return {
|
||||
matcher: matcher.slice(7),
|
||||
layer: 'native',
|
||||
}
|
||||
}]
|
||||
: []),
|
||||
...(process.env.TAURI_PLATFORM !== 'macos'
|
||||
? <Variant<any>[]>[
|
||||
(matcher) => {
|
||||
if (!matcher.startsWith('native-mac:'))
|
||||
return
|
||||
|
@ -128,9 +114,6 @@ export default defineConfig({
|
|||
layer: 'native-mac',
|
||||
}
|
||||
},
|
||||
]
|
||||
: []
|
||||
),
|
||||
variantParentMatcher('fullscreen', '@media (display-mode: fullscreen)'),
|
||||
variantParentMatcher('coarse-pointer', '@media (pointer: coarse)'),
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue