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 4 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
4 changes: 2 additions & 2 deletions components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,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
4 changes: 4 additions & 0 deletions composables/content-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const sanitizer = sanitize({
/**
* Parse raw HTML form Mastodon server to AST,
* with interop of custom emojis and inline Markdown syntax
* @param html
* @param options
*/
export function parseMastodonHTML(
html: string,
Expand Down Expand Up @@ -140,6 +142,8 @@ export function parseMastodonHTML(

/**
* Converts raw HTML form Mastodon server to HTML for Tiptap editor
* @param html
* @param customEmojis
*/
export function convertMastodonHTML(html: string, customEmojis: Record<string, mastodon.v1.CustomEmoji> = {}) {
const tree = parseMastodonHTML(html, {
Expand Down
1 change: 1 addition & 0 deletions composables/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,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
8 changes: 7 additions & 1 deletion composables/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,27 @@ export async function loginTo(masto: ElkMasto, user: Overwrite<UserLogin, { acco
const accountPreferencesMap = new Map<string, Partial<mastodon.v1.Preference>>()

/**
* @param account
* @returns `true` when user ticked the preference to always expand posts with content warnings
*/
export function getExpandSpoilersByDefault(account: mastodon.v1.AccountCredentials) {
return accountPreferencesMap.get(account.acct)?.['reading:expand:spoilers'] ?? false
}

/**
* @param account
* @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
}

/**
* @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') ?? false
}

export async function fetchAccountInfo(client: mastodon.Client, server: string) {
Expand Down Expand Up @@ -336,6 +339,8 @@ interface UseUserLocalStorageCache {

/**
* Create reactive storage for the current user
* @param key
* @param initial
*/
export function useUserLocalStorage<T extends object>(key: string, initial: () => T): Ref<T> {
if (process.server || process.test)
Expand Down Expand Up @@ -382,6 +387,7 @@ export function useUserLocalStorage<T extends object>(key: string, initial: () =

/**
* Clear all storages for the given account
* @param account
*/
export function clearUserLocalStorage(account?: mastodon.v1.Account) {
if (!account)
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.0"
}
}
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
30 changes: 27 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -44,9 +44,14 @@ export default defineNuxtConfig({
devtools: {
enabled: true,
},
features: {
inlineStyles: false,
},
/* future: {
typescriptBundlerResolution: true,
}, */
experimental: {
payloadExtraction: false,
inlineSSRStyles: false,
renderJsonPayloads: true,
},
css: [
Expand Down Expand Up @@ -84,6 +89,17 @@ export default defineNuxtConfig({
build: {
target: 'esnext',
},
optimizeDeps: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks like a problem on the compile-time schedule, and probably a regression from Nuxt with the ability to create dependency between modules..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any change here is more likely a change in Vite (as we upgraded from Vite 4 -> Vite 5 in v3.9).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the list for testing (testing with current main and this PR on my local), I need to remove all entries, we only need focus trap for client

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a good idea to include most of these in the config. We're lazy loading a lot of dependencies and they aren't discovered by the scanner. Some will end up triggering a full-reload on cold start. We may merge a new strategy in Vite 5.1 that we can adopt and this will be even more important then (we will start getting warnings to add the deps to the config). See:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has anyone in the team tried running dev in a clean clone (main branch with Nuxt 3.8)? there are almost 10 page refresh even when scrolling on timeline

@patak-dev I'm going to activate Vite 5 { server: { fs: cachedChecks: true } } ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@userquin see nuxt/nuxt#24196 (comment), there were issues in Nuxt 3.8 preventing the optimized deps cache to be used (so every startup was a cold start). This should be fixed in 3.9 (I imagine also in newer patches for 3.8?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to include also the new floating-vue v5.0.0 :fingers_crossed:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patak-dev I don't see any improvement activating cachedChecks: true on my laptop (with or without optimized deps, just a few ms, in both cases removing the .cache folder):

# without cachedChecks: true
ℹ Vite server warmed up in 8133ms                                                                                                                     15:02:18
ℹ Vite client warmed up in 12612ms                                                                                                                    15:02:19
✔ Nitro built in 5417 ms

# with cachedChecks: true
ℹ Vite server warmed up in 8190ms                                                                                                                     15:03:23
ℹ Vite client warmed up in 12484ms                                                                                                                    15:03:24
✔ Nitro built in 5196 ms

include: [
'@vueuse/integrations/useFocusTrap', 'browser-fs-access', 'file-saver', 'slimeform', 'iso-639-1', '@tiptap/vue-3', 'string-length',
'vue-advanced-cropper', 'github-reserved-names', 'emoji-mart', '@tiptap/extension-placeholder',
'@tiptap/extension-document', '@tiptap/extension-paragraph', '@tiptap/extension-text',
'@tiptap/extension-mention', '@tiptap/extension-hard-break', '@tiptap/extension-bold',
'@tiptap/extension-italic', '@tiptap/extension-code', '@tiptap/extension-history',
'prosemirror-state', '@tiptap/core', '@tiptap/extension-code-block', 'prosemirror-highlight',
'tippy.js', 'prosemirror-highlight/shikiji',
],
},
},
postcss: {
plugins: {
Expand Down Expand Up @@ -256,7 +272,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',
Expand Down