Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update nuxt to v3.9.3 and vue 3.4.15 #2543

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
185a255
chore: update nuxt to v3.9.0
userquin Jan 3, 2024
8770688
Merge branch 'main' into userquin/chore-nuxt-3.9.0
userquin Jan 3, 2024
36c79b5
chore: update lock file
userquin Jan 3, 2024
2edbf58
chore: fix lint
userquin Jan 3, 2024
9f3d168
Merge branch 'main' into userquin/chore-nuxt-3.9.0
userquin Jan 8, 2024
24f8823
chore: remove optimized deps + add some plugin log
userquin Jan 8, 2024
a52546b
Merge branch 'main' into userquin/chore-nuxt-3.9.0
userquin Jan 9, 2024
b45b550
Merge branch 'main' into userquin/chore-nuxt-3.9.0
userquin Jan 21, 2024
e5804b9
chore: nuxt 3.9.3 and vue 3.4.15
userquin Jan 22, 2024
7e48b07
chore: add $pwa stub, vue sfc complaining
userquin Jan 22, 2024
e560c10
chore: fix hydration miss match warnings
userquin Jan 22, 2024
0481f54
chore: register $pwa stub, vue sfc complaining
userquin Jan 22, 2024
0f01f7e
chore: fix error mutating data inside scope
userquin Jan 22, 2024
5abad7a
chore: fix warning about deps
userquin Jan 22, 2024
262ef35
chore: w-fit breaking item layout
userquin Jan 22, 2024
6d6313e
chore: fix typecheck
userquin Jan 22, 2024
bf3bb5a
chore: fix hydration miss match, tool tip with ids
userquin Jan 22, 2024
aa5a9e0
chore: cleanup
userquin Jan 22, 2024
19a1d05
chore: fix user effect scope error
userquin Jan 22, 2024
a6c6175
chore: replace computedEager with computed
userquin Jan 22, 2024
d16d874
chore: pin vitest for now
danielroe Jan 22, 2024
5d0c4b0
chore: remove expect error
danielroe Jan 22, 2024
84249b4
chore: remove warnings about ?? and left operand
userquin Jan 22, 2024
3d5f10e
chore: cleanup
userquin Jan 22, 2024
f2722e1
Merge remote-tracking branch 'origin/userquin/chore-nuxt-3.9.0' into …
userquin Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/account/AccountHoverWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const props = defineProps<{
disabled?: boolean
}>()

const account = computed(() => props.account || (props.handle ? useAccountByHandle(props.handle!) : undefined))
const account = computed(() => props.account || (props.handle ? useAccountByHandle(props.handle!)?.value : undefined))
const userSettings = useUserSettings()
</script>

Expand Down
12 changes: 6 additions & 6 deletions components/account/AccountTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type { CommonRouteTabOption } from '../common/CommonRouteTabs.vue'
const { t } = useI18n()
const route = useRoute()

const server = $(computedEager(() => route.params.server as string))
const account = $(computedEager(() => route.params.account as string))
const server = computed(() => route.params.server as string)
const account = computed(() => route.params.account as string)

const tabs = $computed<CommonRouteTabOption[]>(() => [
const tabs = computed<CommonRouteTabOption[]>(() => [
{
name: 'account-index',
to: {
name: 'account-index',
params: { server, account },
params: { server: server.value, account: account.value },
},
display: t('tab.posts'),
icon: 'i-ri:file-list-2-line',
Expand All @@ -21,7 +21,7 @@ const tabs = $computed<CommonRouteTabOption[]>(() => [
name: 'account-replies',
to: {
name: 'account-replies',
params: { server, account },
params: { server: server.value, account: account.value },
},
display: t('tab.posts_with_replies'),
icon: 'i-ri:chat-1-line',
Expand All @@ -30,7 +30,7 @@ const tabs = $computed<CommonRouteTabOption[]>(() => [
name: 'account-media',
to: {
name: 'account-media',
params: { server, account },
params: { server: server.value, account: account.value },
},
display: t('tab.media'),
icon: 'i-ri:camera-2-line',
Expand Down
4 changes: 2 additions & 2 deletions components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ defineExpose({ createEntry, removeEntry, updateEntry })
</template>
<template v-else>
<slot
v-for="item, index of items"
v-bind="{ key: item[keyProp as keyof U] }"
v-for="(item, index) of items"
v-bind="{ key: (item as U)[keyProp as keyof U] }"
:item="item as U"
:older="items[index + 1] as U"
:newer="items[index - 1] as U"
Expand Down
8 changes: 4 additions & 4 deletions components/common/CommonRouteTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ useCommands(() => command
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center text-secondary-light op50>{{ option.display }}</span>
</div>
</template>
<template v-if="moreOptions?.options?.length">
<template v-if="isHydrated && moreOptions?.options?.length">
<CommonDropdown placement="bottom" flex cursor-pointer mx-1.25rem>
<CommonTooltip placement="top" :content="moreOptions.tooltip || t('action.more')">
<CommonTooltip placement="top" :content="isHydrated ? (moreOptions.tooltip || t('action.more')) : ''">
<button
cursor-pointer
flex
Expand All @@ -74,7 +74,7 @@ useCommands(() => command
op75
px4
group
:aria-label="t('action.more')"
:aria-label="isHydrated ? t('action.more') : ''"
:class="moreOptions.match ? 'text-primary' : 'text-secondary'"
>
<span v-if="moreOptions.icon" :class="moreOptions.icon" text-sm me--1 block />
Expand All @@ -91,7 +91,7 @@ useCommands(() => command
<span flex="~ row" gap-x-4 items-center :class="option.match ? 'text-primary' : ''">
<span v-if="option.icon" :class="[option.icon, option.match ? 'text-primary' : 'text.secondary']" text-md me--1 block />
<span v-else block>&#160;</span>
<span>{{ option.display }}</span>
<span>{{ isHydrated ? option.display : '' }}</span>
</span>
</CommonDropdownItem>
</NuxtLink>
Expand Down
1 change: 1 addition & 0 deletions components/common/CommonTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defineProps<Props>()

<template>
<VTooltip
v-if="isHydrated"
v-bind="$attrs"
auto-hide
>
Expand Down
6 changes: 3 additions & 3 deletions components/common/dropdown/DropdownItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ useCommand({
flex gap-3 items-center cursor-pointer px4 py3
select-none
hover-bg-active
:aria-label="text"
:aria-label="isHydrated ? text : ''"
@click="handleClick"
>
<div v-if="icon" :class="icon" />
<div flex="~ col">
<div text-15px>
<slot>
{{ text }}
{{ isHydrated ? text : '' }}
</slot>
</div>
<div text-3 text-secondary>
<slot name="description">
<p v-if="description">
{{ description }}
{{ isHydrated ? description : '' }}
</p>
</slot>
</div>
Expand Down
1 change: 1 addition & 0 deletions components/search/SearchWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { accounts, hashtags, loading, statuses } = useSearch(query)
const index = ref(0)

const { t } = useI18n()

const el = ref<HTMLElement>()
const input = ref<HTMLInputElement>()
const router = useRouter()
Expand Down
2 changes: 1 addition & 1 deletion components/settings/SettingsItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ useCommand({
@click="to ? $scrollToTop() : undefined"
>
<div
w-full flex w-fit px5 py3 md:gap2 gap4 items-center
w-full flex px5 py3 md:gap2 gap4 items-center
transition-250 group-hover:bg-active
group-focus-visible:ring="2 current"
>
Expand Down
2 changes: 1 addition & 1 deletion composables/idb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions composables/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function usePaginator<T, P, U = T>(
)
loadNext()
},
// { immediate: true, flush: 'post' },
)
}

Expand Down
6 changes: 2 additions & 4 deletions composables/settings/storage.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import type { Ref } from 'vue'
import type { VueI18n } from 'vue-i18n'
import type { LocaleObject } from 'vue-i18n-routing'
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
Expand Down
4 changes: 2 additions & 2 deletions composables/tiptap/shikiji-parser.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type Parser, createParser } from 'prosemirror-highlight/shikiji'
import type { BuiltinLanguage } from 'shikiji/langs'
import type { BundledLanguage } from 'shikiji/langs'

let parser: Parser | undefined

export const shikijiParser: Parser = (options) => {
const lang = options.language ?? 'text'

// Register the language if it's not yet registered
const { highlighter, promise } = useHighlighter(lang as BuiltinLanguage)
const { highlighter, promise } = useHighlighter(lang as BundledLanguage)

// If the highlighter or the language is not available, return a promise that
// will resolve when it's ready. When the promise resolves, the editor will
Expand Down
28 changes: 14 additions & 14 deletions composables/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ 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'
}

/**
* @param account
* @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) {
Expand Down Expand Up @@ -362,20 +362,20 @@ export function useUserLocalStorage<T extends object>(key: string, initial: () =
// Backward compatibility, respect webDomain in acct
// In previous versions, acct was username@server instead of username@webDomain
// for example: elk@m.webtoo.ls instead of elk@webtoo.ls
// if (!all.value[id]) { // TODO: add back this condition in the future
const [username, webDomain] = id.split('@')
const server = currentServer.value
if (webDomain && server && server !== webDomain) {
const oldId = `${username}@${server}`
const outdatedSettings = all.value[oldId]
if (outdatedSettings) {
const newAllValue = { ...all.value, [id]: outdatedSettings }
delete newAllValue[oldId]
all.value = newAllValue
if (!all.value[id]) {
const [username, webDomain] = id.split('@')
const server = currentServer.value
if (webDomain && server && server !== webDomain) {
const oldId = `${username}@${server}`
const outdatedSettings = all.value[oldId]
if (outdatedSettings) {
const newAllValue = { ...all.value, [id]: outdatedSettings }
delete newAllValue[oldId]
all.value = newAllValue
}
}
all.value[id] = Object.assign(initial(), all.value[id] || {})
}
// }
all.value[id] = Object.assign(initial(), all.value[id] || {})
return all.value[id]
})
})
Expand Down
5 changes: 4 additions & 1 deletion composables/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import type { SchemaAugmentations } from '@unhead/schema'
export const isHydrated = ref(false)

export function onHydrated(cb: () => unknown) {
watchOnce(isHydrated, () => cb(), { immediate: isHydrated.value })
if (isHydrated.value)
watchOnce(isHydrated, () => cb(), { immediate: true })
else
watchOnce(isHydrated, () => cb())
}

/**
Expand Down
20 changes: 20 additions & 0 deletions config/i18n.config.ts
Original file line number Diff line number Diff line change
@@ -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
}
})
25 changes: 3 additions & 22 deletions config/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { NuxtI18nOptions } from '@nuxtjs/i18n'
import type { DateTimeFormats, NumberFormats, PluralizationRule, PluralizationRules } from '@intlify/core-base'

import type { LocaleObject } from '#i18n'
Expand Down Expand Up @@ -256,7 +255,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 }
Expand All @@ -281,7 +280,7 @@ const datetimeFormats = Object.values(currentLocales).reduce((acc, data) => {
return acc
}, <DateTimeFormats>{})

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 }
Expand Down Expand Up @@ -313,7 +312,7 @@ const numberFormats = Object.values(currentLocales).reduce((acc, data) => {
return acc
}, <NumberFormats>{})

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
Expand All @@ -322,21 +321,3 @@ const pluralRules = Object.values(currentLocales).reduce((acc, data) => {

return acc
}, <PluralizationRules>{})

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,
},
}
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.3"
}
}
2 changes: 1 addition & 1 deletion emoji-mart-traslation.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module 'virtual:emoji-mart-lang-importer' {
export default function(lang: string): Promise<any>
export default function (lang: string): Promise<any>
}
5 changes: 2 additions & 3 deletions modules/emoji-mart-translation.ts
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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]
Expand Down
5 changes: 2 additions & 3 deletions modules/pwa/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Partial<ManifestOptions>>

export const pwaLocales = i18n.locales as LocaleObject[]
export const pwaLocales = currentLocales

type WebManifestEntry = Pick<ManifestOptions, 'name' | 'short_name' | 'description' | 'screenshots' | 'shortcuts'>
type RequiredWebManifestEntry = Required<WebManifestEntry & Pick<ManifestOptions, 'dir' | 'lang' | 'screenshots' | 'shortcuts'>>
Expand Down
6 changes: 2 additions & 4 deletions modules/pwa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ export default defineNuxtModule<VitePWANuxtOptions>({
references.push({ types: 'vite-plugin-pwa/info' })
references.push({ types: 'vite-plugin-pwa/vue' })
})
if (!options.disable) {
// Inject $pwa helper throughout app
addPlugin({ src: resolver.resolve('./runtime/pwa-plugin.client') })
}
// Inject $pwa helper throughout app: vue complaining about missing $pwa in pwa badges
addPlugin({ src: resolver.resolve(options.disable ? './runtime/pwa-plugin-stub.client' : './runtime/pwa-plugin.client') })

// TODO: combine with configurePWAOptions?
nuxt.hook('nitro:init', (nitro) => {
Expand Down
7 changes: 7 additions & 0 deletions modules/pwa/runtime/pwa-plugin-stub.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default defineNuxtPlugin(() => {
return {
provide: {
pwa: {},
},
}
})