From 55037f04cda5c9b5fbbc491464dedece73d65386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Sat, 24 Feb 2024 17:46:14 +0100 Subject: [PATCH] chore: update nuxt to 3.10.3 (#2610) --- app.vue | 2 +- components/aria/AriaAnnouncer.vue | 2 +- components/common/CommonInputImage.vue | 2 +- .../modal/ModalMediaPreviewCarousel.vue | 2 +- components/settings/SettingsItem.vue | 2 +- components/settings/SettingsLanguage.vue | 2 +- components/status/StatusActionsMore.vue | 2 +- components/status/StatusPreviewGitHub.vue | 5 +- components/status/StatusPreviewStackBlitz.vue | 5 +- components/tiptap/TiptapEmojiList.vue | 2 +- composables/cache.ts | 2 +- composables/command.ts | 2 +- composables/dialog.ts | 4 +- composables/emojis.ts | 2 +- composables/idb/index.ts | 2 +- composables/mask.ts | 2 +- composables/masto/masto.ts | 2 +- composables/masto/publish.ts | 4 +- composables/masto/statusDrafts.ts | 2 +- composables/masto/translate.ts | 2 +- composables/paginator.ts | 2 +- composables/settings/definition.ts | 2 +- composables/settings/storage.ts | 8 +- composables/setups.ts | 5 +- composables/tiptap.ts | 2 +- composables/tiptap/suggestion.ts | 4 +- composables/users.ts | 12 +- composables/vue.ts | 2 +- composables/web-share-target.ts | 2 +- config/i18n.config.ts | 20 + config/i18n.ts | 30 +- docs/package.json | 6 +- emoji-mart-traslation.d.ts | 2 +- error.vue | 2 +- middleware/1.permalink.global.ts | 2 +- middleware/2.single-instance.global.ts | 2 +- middleware/auth.ts | 2 +- modules/emoji-mart-translation.ts | 5 +- modules/pwa/i18n.ts | 9 +- modules/tauri/runtime/nitro.client.ts | 2 +- nuxt.config.ts | 17 +- package.json | 60 +- page-lifecycle.d.ts | 28 +- pages/[[server]]/@[account]/index.vue | 2 +- pages/home.vue | 2 +- pages/settings/users/index.vue | 4 +- pages/share-target.vue | 2 +- plugins/setup-head-script.server.ts | 2 +- plugins/setup-i18n.ts | 6 +- pnpm-lock.yaml | 7039 ++++++++--------- scripts/cleanup-translations.ts | 7 +- service-worker/tsconfig.json | 4 +- tests/nuxt/content-rich.test.ts | 6 +- 53 files changed, 3584 insertions(+), 3766 deletions(-) create mode 100644 config/i18n.config.ts diff --git a/app.vue b/app.vue index 89c1fa0e..4498af06 100644 --- a/app.vue +++ b/app.vue @@ -4,7 +4,7 @@ provideGlobalCommands() const route = useRoute() -if (process.server && !route.path.startsWith('/settings')) { +if (import.meta.server && !route.path.startsWith('/settings')) { const url = useRequestURL() useHead({ diff --git a/components/aria/AriaAnnouncer.vue b/components/aria/AriaAnnouncer.vue index fe46114e..ed6a8e3d 100644 --- a/components/aria/AriaAnnouncer.vue +++ b/components/aria/AriaAnnouncer.vue @@ -1,6 +1,6 @@ diff --git a/components/status/StatusPreviewStackBlitz.vue b/components/status/StatusPreviewStackBlitz.vue index 6f553798..7110edf1 100644 --- a/components/status/StatusPreviewStackBlitz.vue +++ b/components/status/StatusPreviewStackBlitz.vue @@ -26,13 +26,12 @@ const meta = computed(() => { const lines = meta?.[2] const code = meta?.[3].split('\n').slice(0, maxLines).join('\n') const project = props.card.title?.replace(' - StackBlitz', '') - const info = { + return { file, lines, code, project, - } - return info + } satisfies Meta }) const vnodeCode = computed(() => { diff --git a/components/tiptap/TiptapEmojiList.vue b/components/tiptap/TiptapEmojiList.vue index 3268fbfe..47d810a6 100644 --- a/components/tiptap/TiptapEmojiList.vue +++ b/components/tiptap/TiptapEmojiList.vue @@ -13,7 +13,7 @@ const { items, command } = defineProps<{ }>() const emojis = computed(() => { - if (process.server) + if (import.meta.server) return [] return items.map((item: CustomEmoji | Emoji) => { diff --git a/composables/cache.ts b/composables/cache.ts index d9503638..6ea52f6b 100644 --- a/composables/cache.ts +++ b/composables/cache.ts @@ -5,7 +5,7 @@ const cache = new LRUCache({ max: 1000, }) -if (process.dev && process.client) +if (import.meta.dev && import.meta.client) // eslint-disable-next-line no-console console.log({ cache }) diff --git a/composables/command.ts b/composables/command.ts index 6f40de3e..9d18d851 100644 --- a/composables/command.ts +++ b/composables/command.ts @@ -1,7 +1,7 @@ import type { ComputedRef } from 'vue' import { defineStore } from 'pinia' import Fuse from 'fuse.js' -import type { LocaleObject } from '#i18n' +import type { LocaleObject } from '@nuxtjs/i18n' import type { SearchResult } from '~/composables/masto/search' // @unocss-include diff --git a/composables/dialog.ts b/composables/dialog.ts index 07cee25d..b35af76b 100644 --- a/composables/dialog.ts +++ b/composables/dialog.ts @@ -56,7 +56,7 @@ export async function openPublishDialog(draftKey = 'dialog', draft?: Draft, over if (overwrite && !isEmptyDraft(currentUserDrafts.value[draftKey])) { // TODO overwrite warning // TODO don't overwrite, have a draft list - if (process.dev) { + if (import.meta.dev) { // eslint-disable-next-line no-alert const result = confirm('[DEV] Are you sure you overwrite draft content?') if (!result) @@ -89,7 +89,7 @@ function restoreMediaPreviewFromState() { isMediaPreviewOpen.value = history.state?.mediaPreview ?? false } -if (process.client) { +if (import.meta.client) { window.addEventListener('popstate', restoreMediaPreviewFromState) restoreMediaPreviewFromState() diff --git a/composables/emojis.ts b/composables/emojis.ts index ce39c051..d16e13fb 100644 --- a/composables/emojis.ts +++ b/composables/emojis.ts @@ -11,7 +11,7 @@ function getDefault(): CustomEmojisInfo { } } -export const currentCustomEmojis = process.server +export const currentCustomEmojis = import.meta.server ? computed(getDefault) : useUserLocalStorage(STORAGE_KEY_CUSTOM_EMOJIS, getDefault) diff --git a/composables/idb/index.ts b/composables/idb/index.ts index 9ce1e794..d671eead 100644 --- a/composables/idb/index.ts +++ b/composables/idb/index.ts @@ -21,7 +21,7 @@ export async function useAsyncIDBKeyval( const data = (shallow ? shallowRef : ref)(initialValue) as Ref - const rawInit: T = resolveUnref(initialValue) + const rawInit: T = toValue(initialValue) async function read() { if (!isIDBSupported) diff --git a/composables/mask.ts b/composables/mask.ts index 9534abc0..ee02252c 100644 --- a/composables/mask.ts +++ b/composables/mask.ts @@ -13,7 +13,7 @@ export function useMask(options: UseMaskOptions = {}) { getContainer = () => document.body, zIndex = 100, } = options - const wrapperEl = (process.server ? null : document.createElement('div')) as HTMLDivElement + const wrapperEl = (import.meta.server ? null : document.createElement('div')) as HTMLDivElement function show() { const container = getContainer() diff --git a/composables/masto/masto.ts b/composables/masto/masto.ts index 2aa11fa8..56f0918c 100644 --- a/composables/masto/masto.ts +++ b/composables/masto/masto.ts @@ -99,7 +99,7 @@ export function useStreaming( stream.value = cb(streamingClient.value) }) - if (process.client && !process.test) + if (import.meta.client && !process.test) useNuxtApp().$pageLifecycle.addFrozenListener(cleanup) tryOnBeforeUnmount(() => isActive.value = false) diff --git a/composables/masto/publish.ts b/composables/masto/publish.ts index 85f53c90..10dd28b8 100644 --- a/composables/masto/publish.ts +++ b/composables/masto/publish.ts @@ -94,7 +94,7 @@ export function usePublish(options: { ...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}), } as mastodon.rest.v1.CreateStatusParams - if (process.dev) { + if (import.meta.dev) { // eslint-disable-next-line no-console console.info({ raw: draft.value.params.status, @@ -249,7 +249,7 @@ export function useUploadMediaAttachment(draft: Ref) { } async function pickAttachments() { - if (process.server) + if (import.meta.server) return const mimeTypes = currentInstance.value!.configuration?.mediaAttachments.supportedMimeTypes const files = await fileOpen({ diff --git a/composables/masto/statusDrafts.ts b/composables/masto/statusDrafts.ts index 34b429bb..4dddee8c 100644 --- a/composables/masto/statusDrafts.ts +++ b/composables/masto/statusDrafts.ts @@ -4,7 +4,7 @@ import { STORAGE_KEY_DRAFTS } from '~/constants' import type { Draft, DraftMap } from '~/types' import type { Mutable } from '~/types/utils' -export const currentUserDrafts = (process.server || process.test) +export const currentUserDrafts = (import.meta.server || process.test) ? computed(() => ({})) : useUserLocalStorage(STORAGE_KEY_DRAFTS, () => ({})) diff --git a/composables/masto/translate.ts b/composables/masto/translate.ts index 06a81520..8cddbbd5 100644 --- a/composables/masto/translate.ts +++ b/composables/masto/translate.ts @@ -45,7 +45,7 @@ export const supportedTranslationCodes = [ export function getLanguageCode() { let code = 'en' const getCode = (code: string) => code.replace(/-.*$/, '') - if (!process.server) { + if (import.meta.client) { const { locale } = useI18n() code = getCode(locale.value ? locale.value : navigator.language) } diff --git a/composables/paginator.ts b/composables/paginator.ts index 02c96945..49884f23 100644 --- a/composables/paginator.ts +++ b/composables/paginator.ts @@ -103,7 +103,7 @@ export function usePaginator( bound.update() } - if (process.client) { + if (import.meta.client) { useIntervalFn(() => { bound.update() }, 1000) diff --git a/composables/settings/definition.ts b/composables/settings/definition.ts index 5c9ca284..566ac0f5 100644 --- a/composables/settings/definition.ts +++ b/composables/settings/definition.ts @@ -56,7 +56,7 @@ export interface ThemeColors { } export function getDefaultLanguage(languages: string[]) { - if (process.server) + if (import.meta.server) return 'en-US' return matchLanguages(languages, navigator.languages) || 'en-US' } diff --git a/composables/settings/storage.ts b/composables/settings/storage.ts index a1a543d7..329f56b2 100644 --- a/composables/settings/storage.ts +++ b/composables/settings/storage.ts @@ -1,14 +1,12 @@ import type { Ref } from 'vue' -import type { VueI18n } from 'vue-i18n' -import type { LocaleObject } from 'vue-i18n-routing' +import type { LocaleObject } from '@nuxtjs/i18n' import type { FontSize, OldFontSize, PreferencesSettings, UserSettings } from './definition' import { STORAGE_KEY_SETTINGS } from '~/constants' import { oldFontSizeMap } from '~~/constants/options' export function useUserSettings() { - const i18n = useNuxtApp().vueApp.config.globalProperties.$i18n as VueI18n - const { locales } = i18n - const supportLanguages = (locales as LocaleObject[]).map(locale => locale.code) + const { locales } = useNuxtApp().$i18n + const supportLanguages = (unref(locales) as LocaleObject[]).map(locale => locale.code) const settingsStorage = useUserLocalStorage(STORAGE_KEY_SETTINGS, () => getDefaultUserSettings(supportLanguages)) // Backward compatibility, font size was xs, sm, md, lg, xl before diff --git a/composables/setups.ts b/composables/setups.ts index f5a7a312..ec93ecd6 100644 --- a/composables/setups.ts +++ b/composables/setups.ts @@ -1,5 +1,4 @@ -import type { Directions } from 'vue-i18n-routing' -import type { LocaleObject } from '#i18n' +import type { Directions, LocaleObject } from '@nuxtjs/i18n' export function setupPageHeader() { const { locale, locales, t } = useI18n() @@ -52,7 +51,7 @@ export function setupPageHeader() { return titleTemplate }, - link: (process.client && useAppConfig().pwaEnabled) + link: (import.meta.client && useAppConfig().pwaEnabled) ? () => [{ key: 'webmanifest', rel: 'manifest', diff --git a/composables/tiptap.ts b/composables/tiptap.ts index da7c42bb..598dff5f 100644 --- a/composables/tiptap.ts +++ b/composables/tiptap.ts @@ -28,7 +28,7 @@ export interface UseTiptapOptions { } export function useTiptap(options: UseTiptapOptions) { - if (process.server) + if (import.meta.server) return { editor: ref() } const { diff --git a/composables/tiptap/suggestion.ts b/composables/tiptap/suggestion.ts index e9c6b035..ce666bab 100644 --- a/composables/tiptap/suggestion.ts +++ b/composables/tiptap/suggestion.ts @@ -18,7 +18,7 @@ export function isCustomEmoji(emoji: CustomEmoji | Emoji): emoji is CustomEmoji return !!(emoji as CustomEmoji).custom } -export const TiptapMentionSuggestion: Partial = process.server +export const TiptapMentionSuggestion: Partial = import.meta.server ? {} : { pluginKey: new PluginKey('mention'), @@ -56,7 +56,7 @@ export const TiptapEmojiSuggestion: Partial = { pluginKey: new PluginKey('emoji'), char: ':', async items({ query }): Promise<(CustomEmoji | Emoji)[]> { - if (process.server || query.length === 0) + if (import.meta.server || query.length === 0) return [] if (currentCustomEmojis.value.emojis.length === 0) diff --git a/composables/users.ts b/composables/users.ts index 75460b07..8c0b21bd 100644 --- a/composables/users.ts +++ b/composables/users.ts @@ -32,7 +32,7 @@ function initializeUsers(): Promise | RemovableRef } } - const users = process.server + const users = import.meta.server ? ref(defaultUsers) : useAsyncIDBKeyval(STORAGE_KEY_USERS, defaultUsers, { deep: true }) @@ -42,7 +42,7 @@ function initializeUsers(): Promise | RemovableRef return users } -const users = process.server ? initializeUsers() as Ref | RemovableRef : await initializeUsers() +const users = import.meta.server ? initializeUsers() as Ref | RemovableRef : await initializeUsers() const nodes = useLocalStorage>(STORAGE_KEY_NODES, {}, { deep: true }) const currentUserHandle = useLocalStorage(STORAGE_KEY_CURRENT_USER_HANDLE, mock ? mock.user.account.id : '') export const instanceStorage = useLocalStorage>(STORAGE_KEY_SERVERS, mock ? mock.server : {}, { deep: true }) @@ -81,7 +81,7 @@ export const isGotoSocial = computed(() => currentNodeInfo.value?.software?.name export const isGlitchEdition = computed(() => currentInstance.value?.version?.includes('+glitch')) // when multiple tabs: we need to reload window when sign in, switch account or sign out -if (process.client) { +if (import.meta.client) { const windowReload = () => { document.visibilityState === 'visible' && window.location.reload() } @@ -184,7 +184,7 @@ export function getExpandSpoilersByDefault(account: mastodon.v1.AccountCredentia * @returns `true` when user selected "Always show media" as Media Display preference */ export function getExpandMediaByDefault(account: mastodon.v1.AccountCredentials) { - return accountPreferencesMap.get(account.acct)?.['reading:expand:media'] === 'show_all' ?? false + return accountPreferencesMap.get(account.acct)?.['reading:expand:media'] === 'show_all' } /** @@ -192,7 +192,7 @@ export function getExpandMediaByDefault(account: mastodon.v1.AccountCredentials) * @returns `true` when user selected "Always hide media" as Media Display preference */ export function getHideMediaByDefault(account: mastodon.v1.AccountCredentials) { - return accountPreferencesMap.get(account.acct)?.['reading:expand:media'] === 'hide_all' ?? false + return accountPreferencesMap.get(account.acct)?.['reading:expand:media'] === 'hide_all' } export async function fetchAccountInfo(client: mastodon.rest.Client, server: string) { @@ -343,7 +343,7 @@ interface UseUserLocalStorageCache { * @param initial */ export function useUserLocalStorage(key: string, initial: () => T): Ref { - if (process.server || process.test) + if (import.meta.server || process.test) return shallowRef(initial()) // @ts-expect-error bind value to the function diff --git a/composables/vue.ts b/composables/vue.ts index 10b7e212..5b50549d 100644 --- a/composables/vue.ts +++ b/composables/vue.ts @@ -43,7 +43,7 @@ export function onReactivated(hook: () => void, target?: ComponentInternalInstan export function useHydratedHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry> | void { if (input && typeof input === 'object' && !('value' in input)) { const title = 'title' in input ? input.title : undefined - if (process.server && title) { + if (import.meta.server && title) { input.meta = input.meta || [] if (Array.isArray(input.meta)) { input.meta.push( diff --git a/composables/web-share-target.ts b/composables/web-share-target.ts index 70772fc5..c68d59a8 100644 --- a/composables/web-share-target.ts +++ b/composables/web-share-target.ts @@ -1,5 +1,5 @@ export function useWebShareTarget(listener?: (message: MessageEvent) => void) { - if (process.server) + if (import.meta.server) return onBeforeMount(() => { diff --git a/config/i18n.config.ts b/config/i18n.config.ts new file mode 100644 index 00000000..fcef6fb8 --- /dev/null +++ b/config/i18n.config.ts @@ -0,0 +1,20 @@ +import { + currentLocales, + datetimeFormats, + numberFormats, + pluralRules, +} from './i18n' + +export default defineI18nConfig(() => { + return { + legacy: false, + availableLocales: currentLocales.map(l => l.code), + fallbackLocale: 'en-US', + fallbackWarn: true, + missingWarn: true, + datetimeFormats, + numberFormats, + // eslint-disable-next-line @typescript-eslint/comma-dangle + pluralRules + } +}) diff --git a/config/i18n.ts b/config/i18n.ts index 1230d5db..9975780c 100644 --- a/config/i18n.ts +++ b/config/i18n.ts @@ -1,7 +1,5 @@ -import type { NuxtI18nOptions } from '@nuxtjs/i18n' import type { DateTimeFormats, NumberFormats, PluralizationRule, PluralizationRules } from '@intlify/core-base' - -import type { LocaleObject } from '#i18n' +import type { LocaleObject } from '@nuxtjs/i18n' interface LocaleObjectData extends LocaleObject { numberFormats?: NumberFormats @@ -239,7 +237,7 @@ function buildLocales() { ...data, code: l.code, name: l.name, - files: [data.file!, `${l.code}.json`], + files: [data.file as string, `${l.code}.json`], } delete entry.file acc.push(entry) @@ -256,7 +254,7 @@ function buildLocales() { export const currentLocales = buildLocales() -const datetimeFormats = Object.values(currentLocales).reduce((acc, data) => { +export const datetimeFormats = Object.values(currentLocales).reduce((acc, data) => { const dateTimeFormats = data.dateTimeFormats if (dateTimeFormats) { acc[data.code] = { ...dateTimeFormats } @@ -281,7 +279,7 @@ const datetimeFormats = Object.values(currentLocales).reduce((acc, data) => { return acc }, {}) -const numberFormats = Object.values(currentLocales).reduce((acc, data) => { +export const numberFormats = Object.values(currentLocales).reduce((acc, data) => { const numberFormats = data.numberFormats if (numberFormats) { acc[data.code] = { ...numberFormats } @@ -313,7 +311,7 @@ const numberFormats = Object.values(currentLocales).reduce((acc, data) => { return acc }, {}) -const pluralRules = Object.values(currentLocales).reduce((acc, data) => { +export const pluralRules = Object.values(currentLocales).reduce((acc, data) => { const pluralRule = data.pluralRule if (pluralRule) { acc[data.code] = pluralRule @@ -322,21 +320,3 @@ const pluralRules = Object.values(currentLocales).reduce((acc, data) => { return acc }, {}) - -export const i18n: NuxtI18nOptions = { - locales: currentLocales, - lazy: true, - strategy: 'no_prefix', - detectBrowserLanguage: false, - langDir: 'locales', - defaultLocale: 'en-US', - vueI18n: { - availableLocales: currentLocales.map(l => l.code), - fallbackLocale: 'en-US', - fallbackWarn: false, - missingWarn: false, - datetimeFormats, - numberFormats, - pluralRules, - }, -} diff --git a/docs/package.json b/docs/package.json index 9ba583dc..b07df8cc 100755 --- a/docs/package.json +++ b/docs/package.json @@ -9,10 +9,10 @@ "preview": "nuxi preview" }, "dependencies": { - "theme-colors": "^0.0.5" + "theme-colors": "^0.1.0" }, "devDependencies": { - "@nuxt-themes/docus": "^1.14.6", - "nuxt": "^3.7.0" + "@nuxt-themes/docus": "^1.15.0", + "nuxt": "^3.10.3" } } diff --git a/emoji-mart-traslation.d.ts b/emoji-mart-traslation.d.ts index d99e6cd2..32fca08c 100644 --- a/emoji-mart-traslation.d.ts +++ b/emoji-mart-traslation.d.ts @@ -1,3 +1,3 @@ declare module 'virtual:emoji-mart-lang-importer' { - export default function(lang: string): Promise + export default function (lang: string): Promise } diff --git a/error.vue b/error.vue index ea822dfb..f4c4b575 100644 --- a/error.vue +++ b/error.vue @@ -11,7 +11,7 @@ const errorCodes: Record = { 404: 'Page not found', } -if (process.dev) +if (import.meta.dev) console.error(error) const defaultMessage = 'Something went wrong' diff --git a/middleware/1.permalink.global.ts b/middleware/1.permalink.global.ts index e27f5fdc..754d0815 100644 --- a/middleware/1.permalink.global.ts +++ b/middleware/1.permalink.global.ts @@ -1,5 +1,5 @@ export default defineNuxtRouteMiddleware(async (to, from) => { - if (process.server) + if (import.meta.server) return if (!('server' in to.params)) diff --git a/middleware/2.single-instance.global.ts b/middleware/2.single-instance.global.ts index 83bb9a2c..527d8358 100644 --- a/middleware/2.single-instance.global.ts +++ b/middleware/2.single-instance.global.ts @@ -1,5 +1,5 @@ export default defineNuxtRouteMiddleware(async (to) => { - if (process.server || !useRuntimeConfig().public.singleInstance) + if (import.meta.server || !useRuntimeConfig().public.singleInstance) return if (to.params.server) { diff --git a/middleware/auth.ts b/middleware/auth.ts index 7d5c36c4..0210fedc 100644 --- a/middleware/auth.ts +++ b/middleware/auth.ts @@ -1,7 +1,7 @@ import type { RouteLocationNormalized } from 'vue-router' export default defineNuxtRouteMiddleware((to) => { - if (process.server) + if (import.meta.server) return if (to.path === '/signin/callback') diff --git a/modules/emoji-mart-translation.ts b/modules/emoji-mart-translation.ts index fbc62858..8118c4dd 100644 --- a/modules/emoji-mart-translation.ts +++ b/modules/emoji-mart-translation.ts @@ -1,7 +1,6 @@ import fs from 'fs-extra' import { createResolver, defineNuxtModule } from '@nuxt/kit' -import { i18n } from '../config/i18n' -import type { LocaleObject } from '#i18n' +import { currentLocales } from '../config/i18n' const virtual = 'virtual:emoji-mart-lang-importer' const resolvedVirtual = `\0${virtual}.mjs` @@ -25,7 +24,7 @@ export default defineNuxtModule({ if (id === resolvedVirtual) { const locales = await Promise.all( Array - .from(new Set((i18n.locales as LocaleObject[]).map(l => l.code.split('-')[0]))) + .from(new Set((currentLocales).map(l => l.code.split('-')[0]))) .map(async (l) => { const exists = await isFile(resolver.resolve(`../node_modules/@emoji-mart/data/i18n/${l}.json`)) return [l, exists] as [code: string, exists: boolean] diff --git a/modules/pwa/i18n.ts b/modules/pwa/i18n.ts index e1cfe25b..f8e2b1e6 100644 --- a/modules/pwa/i18n.ts +++ b/modules/pwa/i18n.ts @@ -3,12 +3,11 @@ import { readFile } from 'fs-extra' import { createResolver } from '@nuxt/kit' import type { ManifestOptions } from 'vite-plugin-pwa' import { getEnv } from '../../config/env' -import { i18n } from '../../config/i18n' -import type { LocaleObject } from '#i18n' +import { currentLocales } from '../../config/i18n' export type LocalizedWebManifest = Record> -export const pwaLocales = i18n.locales as LocaleObject[] +export const pwaLocales = currentLocales type WebManifestEntry = Pick type RequiredWebManifestEntry = Required> @@ -141,8 +140,8 @@ export async function createI18n(): Promise { .map(async ({ code, dir = 'ltr', file, files }) => { // read locale file or files const { action, app_desc_short, app_name, nav, pwa } = file - ? await readI18nFile(file) - : await findBestWebManifestData(files, env) + ? await readI18nFile(file as string) + : await findBestWebManifestData(files as string[], env) const entry = pwa?.webmanifest?.[env] ?? {} if (!entry.name && app_name) diff --git a/modules/tauri/runtime/nitro.client.ts b/modules/tauri/runtime/nitro.client.ts index 5f16feba..affedc06 100644 --- a/modules/tauri/runtime/nitro.client.ts +++ b/modules/tauri/runtime/nitro.client.ts @@ -37,7 +37,7 @@ export default defineNuxtPlugin(async () => { const config = useRuntimeConfig() const h3App = createApp({ - debug: process.dev, + debug: import.meta.dev, // TODO: add global error handler // onError: (err, event) => { // console.log({ err, event }) diff --git a/nuxt.config.ts b/nuxt.config.ts index 911e9b56..034eaded 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,9 +1,9 @@ import { createResolver, useNuxt } from '@nuxt/kit' import { isCI, isDevelopment, isWindows } from 'std-env' import { isPreview } from './config/env' -import { i18n } from './config/i18n' import { pwa } from './config/pwa' import type { BuildInfo } from './types' +import { currentLocales } from './config/i18n' const { resolve } = createResolver(import.meta.url) @@ -34,7 +34,6 @@ export default defineNuxtConfig({ 'stale-dep/nuxt', ], vue: { - defineModel: true, propsDestructure: true, }, macros: { @@ -46,9 +45,11 @@ export default defineNuxtConfig({ devtools: { enabled: true, }, + features: { + inlineStyles: false, + }, experimental: { payloadExtraction: false, - inlineSSRStyles: false, renderJsonPayloads: true, }, css: [ @@ -277,7 +278,15 @@ export default defineNuxtConfig({ rateLimiter: false, }, colorMode: { classSuffix: '' }, - i18n, + i18n: { + locales: currentLocales, + lazy: true, + strategy: 'no_prefix', + detectBrowserLanguage: false, + langDir: 'locales', + defaultLocale: 'en-US', + vueI18n: './config/i18n.config.ts', + }, pwa, staleDep: { packageManager: 'pnpm', diff --git a/package.json b/package.json index b94829ff..0a5cf720 100644 --- a/package.json +++ b/package.json @@ -36,12 +36,12 @@ "@fnando/sparkline": "^0.3.10", "@iconify-emoji/twemoji": "^1.0.2", "@iconify/json": "^2.2.170", - "@iconify/utils": "^2.1.7", - "@nuxt/devtools": "^1.0.0-beta.1", - "@nuxt/test-utils": "^3.9.0-alpha.1", + "@iconify/utils": "^2.1.22", + "@nuxt/devtools": "^1.0.8", + "@nuxt/test-utils": "^3.11.0", "@nuxtjs/color-mode": "^3.3.2", - "@nuxtjs/i18n": "8.0.0-beta.10", - "@pinia/nuxt": "^0.4.11", + "@nuxtjs/i18n": "^8.1.1", + "@pinia/nuxt": "^0.5.1", "@tiptap/core": "2.1.8", "@tiptap/extension-bold": "2.1.8", "@tiptap/extension-character-count": "2.1.8", @@ -56,22 +56,22 @@ "@tiptap/starter-kit": "2.1.8", "@tiptap/suggestion": "2.1.8", "@tiptap/vue-3": "2.1.8", - "@unocss/nuxt": "^0.53.4", + "@unocss/nuxt": "^0.58.5", "@upstash/redis": "^1.27.1", "@vercel/kv": "^1.0.1", "@vue-macros/nuxt": "^1.6.0", - "@vueuse/core": "^10.2.1", + "@vueuse/core": "^10.8.0", "@vueuse/gesture": "^2.0.0", - "@vueuse/integrations": "^10.2.1", - "@vueuse/math": "^10.2.1", - "@vueuse/motion": "2.0.0", - "@vueuse/nuxt": "^10.2.1", + "@vueuse/integrations": "^10.8.0", + "@vueuse/math": "^10.8.0", + "@vueuse/motion": "2.1.0", + "@vueuse/nuxt": "^10.8.0", "blurhash": "^2.0.5", - "browser-fs-access": "^0.34.1", + "browser-fs-access": "^0.35.0", "chroma-js": "^2.4.2", "emoji-mart": "^5.5.2", "file-saver": "^2.0.5", - "floating-vue": "2.0.0-beta.24", + "floating-vue": "^5.2.2", "focus-trap": "^7.5.1", "form-data": "^4.0.0", "fuse.js": "^6.6.2", @@ -86,7 +86,7 @@ "node-emoji": "^2.1.3", "nuxt-security": "^0.13.1", "page-lifecycle": "^0.1.2", - "pinia": "^2.1.4", + "pinia": "^2.1.7", "postcss-nested": "^6.0.1", "prosemirror-highlight": "^0.5.0", "rollup-plugin-node-polyfills": "^0.2.1", @@ -101,10 +101,10 @@ "theme-vitesse": "^0.7.2", "tiny-decode": "^0.1.3", "tippy.js": "^6.3.7", - "ufo": "^1.3.0", - "ultrahtml": "^1.2.0", - "unimport": "^3.0.12", - "vite-plugin-pwa": "^0.16.4", + "ufo": "^1.4.0", + "ultrahtml": "^1.5.3", + "unimport": "^3.7.1", + "vite-plugin-pwa": "^0.19.0", "vue-advanced-cropper": "^2.8.8", "vue-virtual-scroller": "2.0.0-beta.8", "workbox-build": "^7.0.0", @@ -112,8 +112,8 @@ "ws": "^8.15.1" }, "devDependencies": { - "@antfu/eslint-config": "^0.41.3", - "@antfu/ni": "^0.21.8", + "@antfu/eslint-config": "^0.43.1", + "@antfu/ni": "^0.21.12", "@types/chroma-js": "^2.4.1", "@types/file-saver": "^2.0.5", "@types/flat": "^5.0.2", @@ -123,34 +123,34 @@ "@types/prettier": "^2.7.3", "@types/wicg-file-system-access": "^2020.9.6", "@types/ws": "^8.5.10", - "@unlazy/nuxt": "^0.9.3", - "@vue/test-utils": "^2.4.3", + "@unlazy/nuxt": "^0.11.1", + "@vue/test-utils": "^2.4.4", "bumpp": "^9.2.0", "consola": "^3.2.3", "eslint": "^8.49.0", "flat": "^5.0.2", "fs-extra": "^11.1.1", "lint-staged": "^14.0.1", - "nuxt": "3.8.2", + "nuxt": "^3.10.3", "prettier": "^3.0.3", - "sharp": "^0.32.5", + "sharp": "^0.32.6", "sharp-ico": "^0.1.5", "simple-git-hooks": "^2.9.0", - "tsx": "^3.12.8", - "typescript": "^5.1.6", - "vitest": "^1.3.0", - "vue-tsc": "^1.8.8" + "tsx": "^4.7.1", + "typescript": "^5.3.3", + "vitest": "1.3.1", + "vue-tsc": "^1.8.27" }, "pnpm": { "overrides": { - "@nuxt/schema": "3.8.2", - "unstorage": "^1.9.0" + "unstorage": "^1.10.1" }, "patchedDependencies": { "nuxt-security@0.13.1": "patches/nuxt-security@0.13.1.patch" } }, "resolutions": { + "vitest": "1.3.1", "vue": "^3.4.19" }, "simple-git-hooks": { diff --git a/page-lifecycle.d.ts b/page-lifecycle.d.ts index 16fe86dd..415f1d94 100644 --- a/page-lifecycle.d.ts +++ b/page-lifecycle.d.ts @@ -1,17 +1,17 @@ declare module 'page-lifecycle/dist/lifecycle.mjs' { - type PageLifecycleState = 'active' | 'passive' | 'hidden' | 'frozen' | 'terminated' + type PageLifecycleState = 'active' | 'passive' | 'hidden' | 'frozen' | 'terminated' - interface PageLifecycleEvent extends Event { - newState: PageLifecycleState - oldState: PageLifecycleState - } - interface PageLifecycle extends EventTarget { - get state(): PageLifecycleState - get pageWasDiscarded(): boolean - addUnsavedChanges: (id: Symbol | any) => void - removeUnsavedChanges: (id: Symbol | any) => void - addEventListener: (type: string, listener: (evt: PageLifecycleEvent) => void) => void - } - const lifecycle: PageLifecycle - export default lifecycle + interface PageLifecycleEvent extends Event { + newState: PageLifecycleState + oldState: PageLifecycleState + } + interface PageLifecycle extends EventTarget { + get state(): PageLifecycleState + get pageWasDiscarded(): boolean + addUnsavedChanges: (id: symbol | any) => void + removeUnsavedChanges: (id: symbol | any) => void + addEventListener: (type: string, listener: (evt: PageLifecycleEvent) => void) => void + } + const lifecycle: PageLifecycle + export default lifecycle } diff --git a/pages/[[server]]/@[account]/index.vue b/pages/[[server]]/@[account]/index.vue index 36eb9298..46e9211a 100644 --- a/pages/[[server]]/@[account]/index.vue +++ b/pages/[[server]]/@[account]/index.vue @@ -8,7 +8,7 @@ const accountName = computed(() => toShortHandle(params.account as string)) const { t } = useI18n() -const { data: account, pending, refresh } = await useAsyncData(() => fetchAccountByHandle(accountName.value).catch(() => null), { immediate: process.client, default: () => shallowRef() }) +const { data: account, pending, refresh } = await useAsyncData(() => fetchAccountByHandle(accountName.value).catch(() => null), { immediate: import.meta.client, default: () => shallowRef() }) const relationship = computed(() => account ? useRelationship(account.value).value : undefined) const userSettings = useUserSettings() diff --git a/pages/home.vue b/pages/home.vue index b25c85bf..27383c2d 100644 --- a/pages/home.vue +++ b/pages/home.vue @@ -6,7 +6,7 @@ definePageMeta({ const route = useRoute() const router = useRouter() -if (process.client && route.path === '/signin/callback') +if (import.meta.client && route.path === '/signin/callback') router.push('/home') const { t } = useI18n() diff --git a/pages/settings/users/index.vue b/pages/settings/users/index.vue index 6daa02ee..b44e9781 100644 --- a/pages/settings/users/index.vue +++ b/pages/settings/users/index.vue @@ -12,7 +12,7 @@ useHydratedHead({ const loggedInUsers = useUsers() async function exportTokens() { - if (process.server) + if (import.meta.server) return if (!confirm('Please aware that the tokens represent the **full access** to your accounts, and should be treated as sensitive information. Are you sure you want to export the tokens?')) @@ -31,7 +31,7 @@ async function exportTokens() { } async function importTokens() { - if (process.server) + if (import.meta.server) return const file = await fileOpen({ description: 'Token File', diff --git a/pages/share-target.vue b/pages/share-target.vue index 5e565218..1e41717d 100644 --- a/pages/share-target.vue +++ b/pages/share-target.vue @@ -8,7 +8,7 @@ definePageMeta({ useWebShareTarget() -const pwaIsInstalled = process.client && !!useNuxtApp().$pwa?.isInstalled +const pwaIsInstalled = import.meta.client && !!useNuxtApp().$pwa?.isInstalled