chore: update nuxt to 3.10.3 (#2610)

This commit is contained in:
Joaquín Sánchez 2024-02-24 17:46:14 +01:00 committed by GitHub
parent 1fefb6e5b6
commit 55037f04cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 3584 additions and 3766 deletions

View file

@ -5,7 +5,7 @@ const cache = new LRUCache<string, any>({
max: 1000,
})
if (process.dev && process.client)
if (import.meta.dev && import.meta.client)
// eslint-disable-next-line no-console
console.log({ cache })

View file

@ -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

View file

@ -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()

View file

@ -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)

View file

@ -21,7 +21,7 @@ export async function useAsyncIDBKeyval<T>(
const data = (shallow ? shallowRef : ref)(initialValue) as Ref<T>
const rawInit: T = resolveUnref(initialValue)
const rawInit: T = toValue(initialValue)
async function read() {
if (!isIDBSupported)

View file

@ -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()

View file

@ -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)

View file

@ -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<Draft>) {
}
async function pickAttachments() {
if (process.server)
if (import.meta.server)
return
const mimeTypes = currentInstance.value!.configuration?.mediaAttachments.supportedMimeTypes
const files = await fileOpen({

View file

@ -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<DraftMap>(() => ({}))
: useUserLocalStorage<DraftMap>(STORAGE_KEY_DRAFTS, () => ({}))

View file

@ -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)
}

View file

@ -103,7 +103,7 @@ export function usePaginator<T, P, U = T>(
bound.update()
}
if (process.client) {
if (import.meta.client) {
useIntervalFn(() => {
bound.update()
}, 1000)

View file

@ -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'
}

View file

@ -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<UserSettings>(STORAGE_KEY_SETTINGS, () => getDefaultUserSettings(supportLanguages))
// Backward compatibility, font size was xs, sm, md, lg, xl before

View file

@ -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',

View file

@ -28,7 +28,7 @@ export interface UseTiptapOptions {
}
export function useTiptap(options: UseTiptapOptions) {
if (process.server)
if (import.meta.server)
return { editor: ref<Editor | undefined>() }
const {

View file

@ -18,7 +18,7 @@ export function isCustomEmoji(emoji: CustomEmoji | Emoji): emoji is CustomEmoji
return !!(emoji as CustomEmoji).custom
}
export const TiptapMentionSuggestion: Partial<SuggestionOptions> = process.server
export const TiptapMentionSuggestion: Partial<SuggestionOptions> = import.meta.server
? {}
: {
pluginKey: new PluginKey('mention'),
@ -56,7 +56,7 @@ export const TiptapEmojiSuggestion: Partial<SuggestionOptions> = {
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)

View file

@ -32,7 +32,7 @@ function initializeUsers(): Promise<Ref<UserLogin[]> | RemovableRef<UserLogin[]>
}
}
const users = process.server
const users = import.meta.server
? ref<UserLogin[]>(defaultUsers)
: useAsyncIDBKeyval<UserLogin[]>(STORAGE_KEY_USERS, defaultUsers, { deep: true })
@ -42,7 +42,7 @@ function initializeUsers(): Promise<Ref<UserLogin[]> | RemovableRef<UserLogin[]>
return users
}
const users = process.server ? initializeUsers() as Ref<UserLogin[]> | RemovableRef<UserLogin[]> : await initializeUsers()
const users = import.meta.server ? initializeUsers() as Ref<UserLogin[]> | RemovableRef<UserLogin[]> : await initializeUsers()
const nodes = useLocalStorage<Record<string, any>>(STORAGE_KEY_NODES, {}, { deep: true })
const currentUserHandle = useLocalStorage<string>(STORAGE_KEY_CURRENT_USER_HANDLE, mock ? mock.user.account.id : '')
export const instanceStorage = useLocalStorage<Record<string, mastodon.v1.Instance>>(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<T extends object>(key: string, initial: () => T): Ref<T> {
if (process.server || process.test)
if (import.meta.server || process.test)
return shallowRef(initial())
// @ts-expect-error bind value to the function

View file

@ -43,7 +43,7 @@ export function onReactivated(hook: () => void, target?: ComponentInternalInstan
export function useHydratedHead<T extends SchemaAugmentations>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | 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(

View file

@ -1,5 +1,5 @@
export function useWebShareTarget(listener?: (message: MessageEvent) => void) {
if (process.server)
if (import.meta.server)
return
onBeforeMount(() => {