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

refactor: Enable auto-import for composables #2929

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components/account/AccountFollowButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleFollowAccount, useRelationship } from '~~/composables/masto/relationship'

const { account, command, context, ...props } = defineProps<{
account: mastodon.v1.Account
Expand Down
1 change: 0 additions & 1 deletion components/account/AccountHoverWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { fetchAccountByHandle } from '~/composables/cache'

type WatcherType = [acc?: mastodon.v1.Account | null, h?: string, v?: boolean]

Expand Down
1 change: 0 additions & 1 deletion components/account/AccountMoreButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleBlockAccount, toggleBlockDomain, toggleMuteAccount } from '~~/composables/masto/relationship'

const { account } = defineProps<{
account: mastodon.v1.Account
Expand Down
1 change: 0 additions & 1 deletion components/aria/AriaAnnouncer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { LocaleObject } from '@nuxtjs/i18n'
import type { AriaAnnounceType, AriaLive } from '~/composables/aria'

const router = useRouter()
const { t, locale, locales } = useI18n()
Expand Down
2 changes: 0 additions & 2 deletions components/aria/AriaLog.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { AriaLive } from '~/composables/aria'

// tsc complaining when using $defineProps
withDefaults(defineProps<{
title: string
Expand Down
2 changes: 0 additions & 2 deletions components/aria/AriaStatus.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { AriaLive } from '~/composables/aria'

// tsc complaining when using $defineProps
withDefaults(defineProps<{
ariaLive?: AriaLive
Expand Down
2 changes: 0 additions & 2 deletions components/command/CommandItem.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script lang="ts" setup>
import type { ResolvedCommand } from '~/composables/command'

const {
cmd,
index,
Expand Down
3 changes: 1 addition & 2 deletions components/command/CommandPanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { SearchResult as SearchResultType } from '~/composables/masto/search'
import type { CommandScope, QueryResult, QueryResultItem } from '~/composables/command'
type SearchResultType = SearchResult

const emit = defineEmits<{
(event: 'close'): void
Expand Down
13 changes: 0 additions & 13 deletions components/modal/ModalContainer.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { ConfirmDialogChoice } from '~/types'
import {
isCommandPanelOpen,
isConfirmDialogOpen,
isEditHistoryDialogOpen,
isErrorDialogOpen,
isFavouritedBoostedByDialogOpen,
isKeyboardShortcutsDialogOpen,
isMediaPreviewOpen,
isPreviewHelpOpen,
isPublishDialogOpen,
isReportDialogOpen,
isSigninDialogOpen,
} from '~/composables/dialog'

const isMac = useIsMac()

Expand Down
1 change: 0 additions & 1 deletion components/nav/NavBottom.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { Component } from 'vue'
import type { NavButtonName } from '../../composables/settings'

import { STORAGE_KEY_BOTTOM_NAV_BUTTONS } from '~/constants'

Expand Down
1 change: 0 additions & 1 deletion components/report/ReportModal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleBlockAccount, toggleFollowAccount, toggleMuteAccount, useRelationship } from '~~/composables/masto/relationship'

const { account, status } = defineProps<{
account: mastodon.v1.Account
Expand Down
2 changes: 0 additions & 2 deletions components/search/SearchResult.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { SearchResult } from '~/composables/masto/search'

defineProps<{
result: SearchResult
active: boolean
Expand Down
1 change: 0 additions & 1 deletion components/settings/SettingsBottomNav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import type { NavButtonName } from '~/composables/settings'
import { STORAGE_KEY_BOTTOM_NAV_BUTTONS } from '~/constants'

interface NavButton {
Expand Down
2 changes: 0 additions & 2 deletions components/settings/SettingsColorMode.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { ColorMode } from '~/composables/settings'

const colorMode = useColorMode()

function setColorMode(mode: ColorMode) {
Expand Down
1 change: 0 additions & 1 deletion components/settings/SettingsFontSize.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" setup>
import { DEFAULT_FONT_SIZE } from '~/constants'
import type { FontSize } from '~/composables/settings'

const userSettings = useUserSettings()

Expand Down
2 changes: 0 additions & 2 deletions components/settings/SettingsThemeColors.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { ThemeColors } from '~/composables/settings'

const themes = await import('~/constants/themes.json').then(r => r.default) as [string, ThemeColors][]
const settings = useUserSettings()

Expand Down
1 change: 0 additions & 1 deletion components/status/StatusActionsMore.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleBlockAccount, toggleMuteAccount, useRelationship } from '~~/composables/masto/relationship'

const props = defineProps<{
status: mastodon.v1.Status
Expand Down
2 changes: 0 additions & 2 deletions components/status/StatusFavouritedBoostedBy.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { favouritedBoostedByStatusId } from '~/composables/dialog'

const type = ref<'favourited-by' | 'boosted-by'>('favourited-by')

const { client } = useMasto()
Expand Down
1 change: 0 additions & 1 deletion components/status/StatusReplyingTo.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { fetchAccountById } from '~/composables/cache'

type WatcherType = [status?: mastodon.v1.Status, v?: boolean]

Expand Down
3 changes: 0 additions & 3 deletions components/tiptap/TiptapEmojiList.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script setup lang="ts">
import { getEmojiMatchesInText } from '@iconify/utils/lib/emoji/replace/find'
import type { CustomEmoji, Emoji } from '~/composables/tiptap/suggestion'
import { isCustomEmoji } from '~/composables/tiptap/suggestion'
import { emojiFilename, emojiPrefix, emojiRegEx } from '~~/config/emojis'
import type { CommandHandler } from '~/composables/command'

const { items, command } = defineProps<{
items: (CustomEmoji | Emoji)[]
Expand Down
1 change: 0 additions & 1 deletion components/tiptap/TiptapHashtagList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { CommandHandler } from '~/composables/command'

const { items, command } = defineProps<{
items: mastodon.v1.Tag[]
Expand Down
1 change: 0 additions & 1 deletion components/tiptap/TiptapMentionList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { CommandHandler } from '~/composables/command'

const { items, command } = defineProps<{
items: mastodon.v1.Account[]
Expand Down
1 change: 0 additions & 1 deletion composables/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ComputedRef } from 'vue'
import { defineStore } from 'pinia'
import Fuse from 'fuse.js'
import type { LocaleObject } from '@nuxtjs/i18n'
import type { SearchResult } from '~/composables/masto/search'

// @unocss-include

Expand Down
8 changes: 1 addition & 7 deletions composables/push-notifications/createPushSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import type { mastodon } from 'masto'
import type {
CreatePushNotification,
PushManagerSubscriptionInfo,
RequiredUserLogin,
} from '~/composables/push-notifications/types'
import { PushSubscriptionError } from '~/composables/push-notifications/types'

export async function createPushSubscription(
user: RequiredUserLogin,
Expand Down Expand Up @@ -42,7 +36,7 @@ export async function createPushSubscription(
)
})
.catch((error) => {
let useError: PushSubscriptionError | Error = error
let useError: typeof PushSubscriptionError | Error = error
if (error.code === 11 && error.name === 'InvalidStateError')
useError = new PushSubscriptionError('too_many_registrations', 'Too many registrations')
else if (error.code === 20 && error.name === 'AbortError')
Expand Down
6 changes: 0 additions & 6 deletions composables/push-notifications/usePushManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import type { mastodon } from 'masto'

import type {
CreatePushNotification,
PushNotificationPolicy,
PushNotificationRequest,
SubscriptionResult,
} from '~/composables/push-notifications/types'
import { STORAGE_KEY_NOTIFICATION, STORAGE_KEY_NOTIFICATION_POLICY } from '~/constants'

const supportsPushNotifications = typeof window !== 'undefined'
Expand Down
1 change: 0 additions & 1 deletion composables/tiptap/suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PluginKey } from 'prosemirror-state'
import type { Component } from 'vue'
import type { Emoji, EmojiMartData } from '@emoji-mart/data'
import type { mastodon } from 'masto'
import { currentCustomEmojis, updateCustomEmojis } from '~/composables/emojis'
import TiptapMentionList from '~/components/tiptap/TiptapMentionList.vue'
import TiptapHashtagList from '~/components/tiptap/TiptapHashtagList.vue'
import TiptapEmojiList from '~/components/tiptap/TiptapEmojiList.vue'
Expand Down
2 changes: 0 additions & 2 deletions composables/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
STORAGE_KEY_SERVERS,
STORAGE_KEY_USERS,
} from '~/constants'
import type { PushNotificationPolicy, PushNotificationRequest } from '~/composables/push-notifications/types'
import { useAsyncIDBKeyval } from '~/composables/idb'

const mock = process.mock

Expand Down
2 changes: 0 additions & 2 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script lang="ts" setup>
import { usePreferences } from '~/composables/settings'

const route = useRoute()
const info = useBuildInfo()

Expand Down
7 changes: 4 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ export default defineNuxtConfig({
},
imports: {
dirs: [
'./composables/masto',
'./composables/push-notifications',
'./composables/masto/*',
'./composables/push-notifications/*',
'./composables/settings',
'./composables/tiptap/index.ts',
'./composables/tiptap/*',
'./composables/idb',
],
imports: [{
name: 'useI18n',
Expand Down
2 changes: 0 additions & 2 deletions plugins/magic-keys.client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { RouteLocationRaw } from 'vue-router'
import { useMagicSequence } from '~/composables/magickeys'
import { currentUser, getInstanceDomain } from '~/composables/users'

export default defineNuxtPlugin(({ $scrollToTop }) => {
const keys = useMagicKeys()
Expand Down
1 change: 0 additions & 1 deletion plugins/setup-global-effects.client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { OldFontSize } from '~/composables/settings'
import { oldFontSizeMap } from '~/constants/options'
import { DEFAULT_FONT_SIZE } from '~/constants'

Expand Down
1 change: 0 additions & 1 deletion scripts/avatars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Buffer } from 'node:buffer'
import { join, resolve } from 'pathe'
import fs from 'fs-extra'
import { ofetch } from 'ofetch'
import { elkTeamMembers } from '../composables/about'

const avatarsDir = resolve('./public/avatars/')

Expand Down
1 change: 0 additions & 1 deletion scripts/generate-themes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chroma from 'chroma-js'
import type { ThemeColors } from '~/composables/settings'

// #cc7d24 -> hcl(67.14,62.19,59.56)
export const themesColor = Array.from(
Expand Down
2 changes: 0 additions & 2 deletions tests/nuxt/content-rich.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { renderToString } from 'vue/server-renderer'
import { format } from 'prettier'
import type { mastodon } from 'masto'
import { mockComponent } from '@nuxt/test-utils/runtime'
import { contentToVNode } from '~/composables/content-render'
import type { ContentParseOptions } from '~/composables/content-parse'

beforeEach(() => {
publicServer.value = useRuntimeConfig().public.defaultServer
Expand Down
1 change: 0 additions & 1 deletion tests/nuxt/html-parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, expect, it } from 'vitest'
import { format } from 'prettier'
import { render as renderTree } from 'ultrahtml'
import type { ContentParseOptions } from '~/composables/content-parse'

describe('html-parse', () => {
it('empty', async () => {
Expand Down
Loading