From e9f0988b4da7ea13a86def1f6245d5e96a04f7a9 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 6 Sep 2022 10:04:27 +0800 Subject: [PATCH] chore: update fixture --- fixture/a.ts | 6 - fixtures/vitesse/.editorconfig | 9 + fixtures/vitesse/.gitignore | 9 + fixtures/vitesse/LICENSE | 21 + fixtures/vitesse/README.md | 1 + fixtures/vitesse/cypress.config.ts | 10 + fixtures/vitesse/cypress/e2e/basic.spec.ts | 36 ++ fixtures/vitesse/index.html | 22 + fixtures/vitesse/package.json | 62 ++ fixtures/vitesse/src/App.vue | 26 + fixtures/vitesse/src/auto-imports.d.ts | 546 ++++++++++++++++++ fixtures/vitesse/src/components.d.ts | 16 + fixtures/vitesse/src/components/Counter.vue | 19 + fixtures/vitesse/src/components/Footer.vue | 33 ++ fixtures/vitesse/src/components/README.md | 10 + fixtures/vitesse/src/composables/dark.ts | 4 + fixtures/vitesse/src/layouts/404.vue | 18 + fixtures/vitesse/src/layouts/README.md | 14 + fixtures/vitesse/src/layouts/default.vue | 9 + fixtures/vitesse/src/layouts/home.vue | 9 + fixtures/vitesse/src/main.ts | 22 + fixtures/vitesse/src/modules/README.md | 11 + fixtures/vitesse/src/modules/i18n.ts | 25 + fixtures/vitesse/src/modules/nprogress.ts | 12 + fixtures/vitesse/src/modules/pinia.ts | 17 + fixtures/vitesse/src/modules/pwa.ts | 12 + fixtures/vitesse/src/pages/README.md | 20 + fixtures/vitesse/src/pages/[...all].vue | 14 + fixtures/vitesse/src/pages/about.md | 21 + fixtures/vitesse/src/pages/hi/[name].vue | 47 ++ fixtures/vitesse/src/pages/index.vue | 62 ++ fixtures/vitesse/src/shims.d.ts | 16 + fixtures/vitesse/src/store/user.ts | 34 ++ fixtures/vitesse/src/styles/main.css | 29 + fixtures/vitesse/src/styles/markdown.css | 28 + fixtures/vitesse/src/types.ts | 3 + .../test/__snapshots__/component.test.ts.snap | 3 + fixtures/vitesse/test/basic.test.ts | 7 + fixtures/vitesse/test/component.test.ts | 28 + fixtures/vitesse/unocss.config.ts | 38 ++ fixtures/vitesse/vite.config.ts | 153 +++++ tsconfig.json | 11 + 42 files changed, 1487 insertions(+), 6 deletions(-) delete mode 100644 fixture/a.ts create mode 100644 fixtures/vitesse/.editorconfig create mode 100644 fixtures/vitesse/.gitignore create mode 100644 fixtures/vitesse/LICENSE create mode 100644 fixtures/vitesse/README.md create mode 100644 fixtures/vitesse/cypress.config.ts create mode 100644 fixtures/vitesse/cypress/e2e/basic.spec.ts create mode 100644 fixtures/vitesse/index.html create mode 100644 fixtures/vitesse/package.json create mode 100644 fixtures/vitesse/src/App.vue create mode 100644 fixtures/vitesse/src/auto-imports.d.ts create mode 100644 fixtures/vitesse/src/components.d.ts create mode 100644 fixtures/vitesse/src/components/Counter.vue create mode 100644 fixtures/vitesse/src/components/Footer.vue create mode 100644 fixtures/vitesse/src/components/README.md create mode 100644 fixtures/vitesse/src/composables/dark.ts create mode 100644 fixtures/vitesse/src/layouts/404.vue create mode 100644 fixtures/vitesse/src/layouts/README.md create mode 100644 fixtures/vitesse/src/layouts/default.vue create mode 100644 fixtures/vitesse/src/layouts/home.vue create mode 100644 fixtures/vitesse/src/main.ts create mode 100644 fixtures/vitesse/src/modules/README.md create mode 100644 fixtures/vitesse/src/modules/i18n.ts create mode 100644 fixtures/vitesse/src/modules/nprogress.ts create mode 100644 fixtures/vitesse/src/modules/pinia.ts create mode 100644 fixtures/vitesse/src/modules/pwa.ts create mode 100644 fixtures/vitesse/src/pages/README.md create mode 100755 fixtures/vitesse/src/pages/[...all].vue create mode 100644 fixtures/vitesse/src/pages/about.md create mode 100644 fixtures/vitesse/src/pages/hi/[name].vue create mode 100644 fixtures/vitesse/src/pages/index.vue create mode 100644 fixtures/vitesse/src/shims.d.ts create mode 100644 fixtures/vitesse/src/store/user.ts create mode 100755 fixtures/vitesse/src/styles/main.css create mode 100644 fixtures/vitesse/src/styles/markdown.css create mode 100644 fixtures/vitesse/src/types.ts create mode 100644 fixtures/vitesse/test/__snapshots__/component.test.ts.snap create mode 100644 fixtures/vitesse/test/basic.test.ts create mode 100644 fixtures/vitesse/test/component.test.ts create mode 100644 fixtures/vitesse/unocss.config.ts create mode 100644 fixtures/vitesse/vite.config.ts create mode 100644 tsconfig.json diff --git a/fixture/a.ts b/fixture/a.ts deleted file mode 100644 index 6905d6e..0000000 --- a/fixture/a.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @ts-expect-error requires a comment -export const a: string = 1 - -export interface Foo { - a: string -} diff --git a/fixtures/vitesse/.editorconfig b/fixtures/vitesse/.editorconfig new file mode 100644 index 0000000..9d08a1a --- /dev/null +++ b/fixtures/vitesse/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/fixtures/vitesse/.gitignore b/fixtures/vitesse/.gitignore new file mode 100644 index 0000000..912c396 --- /dev/null +++ b/fixtures/vitesse/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +.vite-ssg-dist +.vite-ssg-temp +*.local +dist +dist-ssr +node_modules +.idea/ +*.log diff --git a/fixtures/vitesse/LICENSE b/fixtures/vitesse/LICENSE new file mode 100644 index 0000000..da26da3 --- /dev/null +++ b/fixtures/vitesse/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020-2021 Anthony Fu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/fixtures/vitesse/README.md b/fixtures/vitesse/README.md new file mode 100644 index 0000000..8f39e4f --- /dev/null +++ b/fixtures/vitesse/README.md @@ -0,0 +1 @@ +This is a fixture cloned from https://github.com/antfu/vitesse. It's only for lint checking and does not run. diff --git a/fixtures/vitesse/cypress.config.ts b/fixtures/vitesse/cypress.config.ts new file mode 100644 index 0000000..de709e5 --- /dev/null +++ b/fixtures/vitesse/cypress.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'cypress' + +export default defineConfig({ + e2e: { + baseUrl: 'http://localhost:3333', + chromeWebSecurity: false, + specPattern: 'cypress/e2e/**/*.spec.*', + supportFile: false, + }, +}) diff --git a/fixtures/vitesse/cypress/e2e/basic.spec.ts b/fixtures/vitesse/cypress/e2e/basic.spec.ts new file mode 100644 index 0000000..55a838f --- /dev/null +++ b/fixtures/vitesse/cypress/e2e/basic.spec.ts @@ -0,0 +1,36 @@ +context('Basic', () => { + beforeEach(() => { + cy.visit('/') + }) + + it('basic nav', () => { + cy.url() + .should('eq', 'http://localhost:3333/') + + cy.contains('[Home Layout]') + .should('exist') + + cy.get('#input') + .type('Vitesse{Enter}') + .url() + .should('eq', 'http://localhost:3333/hi/Vitesse') + + cy.contains('[Default Layout]') + .should('exist') + + cy.get('[btn]') + .click() + .url() + .should('eq', 'http://localhost:3333/') + }) + + it('markdown', () => { + cy.get('[title="About"]') + .click() + .url() + .should('eq', 'http://localhost:3333/about') + + cy.get('.shiki') + .should('exist') + }) +}) diff --git a/fixtures/vitesse/index.html b/fixtures/vitesse/index.html new file mode 100644 index 0000000..68cef02 --- /dev/null +++ b/fixtures/vitesse/index.html @@ -0,0 +1,22 @@ + + + + + + + + + + + +
+ + + diff --git a/fixtures/vitesse/package.json b/fixtures/vitesse/package.json new file mode 100644 index 0000000..060428c --- /dev/null +++ b/fixtures/vitesse/package.json @@ -0,0 +1,62 @@ +{ + "type": "module", + "private": true, + "packageManager": "pnpm@7.8.0", + "scripts": { + "build": "vite-ssg build", + "dev": "vite --port 3333 --open", + "lint": "eslint .", + "preview": "vite preview", + "preview-https": "serve dist", + "test": "vitest", + "test:e2e": "cypress open", + "test:unit": "vitest", + "typecheck": "vue-tsc --noEmit", + "up": "taze major -I" + }, + "dependencies": { + "@unocss/reset": "^0.45.8", + "@vueuse/core": "^9.1.0", + "@vueuse/head": "^0.7.9", + "nprogress": "^0.2.0", + "pinia": "^2.0.17", + "vue": "^3.2.37", + "vue-demi": "^0.13.6", + "vue-i18n": "^9.2.2", + "vue-router": "^4.1.3" + }, + "devDependencies": { + "@antfu/eslint-config": "^0.25.2", + "@iconify-json/carbon": "^1.1.7", + "@intlify/vite-plugin-vue-i18n": "^6.0.0", + "@types/markdown-it-link-attributes": "^3.0.1", + "@types/nprogress": "^0.2.0", + "@vitejs/plugin-vue": "^3.0.1", + "@vue/test-utils": "^2.0.2", + "critters": "^0.0.16", + "cross-env": "^7.0.3", + "cypress": "^10.4.0", + "eslint": "^8.21.0", + "eslint-plugin-cypress": "^2.12.1", + "https-localhost": "^4.7.1", + "markdown-it-link-attributes": "^4.0.0", + "markdown-it-shiki": "^0.5.1", + "pnpm": "^7.8.0", + "shiki": "^0.10.1", + "taze": "^0.7.6", + "typescript": "^4.7.4", + "unocss": "^0.45.5", + "unplugin-auto-import": "^0.11.0", + "unplugin-vue-components": "^0.22.0", + "vite": "^3.0.4", + "vite-plugin-inspect": "^0.6.0", + "vite-plugin-pages": "^0.25.0", + "vite-plugin-pwa": "^0.12.3", + "vite-plugin-vue-layouts": "^0.7.0", + "vite-plugin-vue-markdown": "^0.21.1", + "vite-ssg": "^0.20.2", + "vite-ssg-sitemap": "^0.3.1", + "vitest": "^0.21.0", + "vue-tsc": "^0.39.5" + } +} diff --git a/fixtures/vitesse/src/App.vue b/fixtures/vitesse/src/App.vue new file mode 100644 index 0000000..7b36d82 --- /dev/null +++ b/fixtures/vitesse/src/App.vue @@ -0,0 +1,26 @@ + + + diff --git a/fixtures/vitesse/src/auto-imports.d.ts b/fixtures/vitesse/src/auto-imports.d.ts new file mode 100644 index 0000000..288f2a1 --- /dev/null +++ b/fixtures/vitesse/src/auto-imports.d.ts @@ -0,0 +1,546 @@ +// Generated by 'unplugin-auto-import' +export {} +declare global { + const $$: typeof import('vue/macros')['$$'] + const $: typeof import('vue/macros')['$'] + const $computed: typeof import('vue/macros')['$computed'] + const $customRef: typeof import('vue/macros')['$customRef'] + const $ref: typeof import('vue/macros')['$ref'] + const $shallowRef: typeof import('vue/macros')['$shallowRef'] + const $toRef: typeof import('vue/macros')['$toRef'] + const EffectScope: typeof import('vue')['EffectScope'] + const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] + const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] + const computed: typeof import('vue')['computed'] + const computedAsync: typeof import('@vueuse/core')['computedAsync'] + const computedEager: typeof import('@vueuse/core')['computedEager'] + const computedInject: typeof import('@vueuse/core')['computedInject'] + const computedWithControl: typeof import('@vueuse/core')['computedWithControl'] + const controlledComputed: typeof import('@vueuse/core')['controlledComputed'] + const controlledRef: typeof import('@vueuse/core')['controlledRef'] + const createApp: typeof import('vue')['createApp'] + const createEventHook: typeof import('@vueuse/core')['createEventHook'] + const createGlobalState: typeof import('@vueuse/core')['createGlobalState'] + const createInjectionState: typeof import('@vueuse/core')['createInjectionState'] + const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn'] + const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable'] + const createUnrefFn: typeof import('@vueuse/core')['createUnrefFn'] + const customRef: typeof import('vue')['customRef'] + const debouncedRef: typeof import('@vueuse/core')['debouncedRef'] + const debouncedWatch: typeof import('@vueuse/core')['debouncedWatch'] + const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] + const defineComponent: typeof import('vue')['defineComponent'] + const eagerComputed: typeof import('@vueuse/core')['eagerComputed'] + const effectScope: typeof import('vue')['effectScope'] + const extendRef: typeof import('@vueuse/core')['extendRef'] + const getCurrentInstance: typeof import('vue')['getCurrentInstance'] + const getCurrentScope: typeof import('vue')['getCurrentScope'] + const h: typeof import('vue')['h'] + const ignorableWatch: typeof import('@vueuse/core')['ignorableWatch'] + const inject: typeof import('vue')['inject'] + const isDark: typeof import('./composables/dark')['isDark'] + const isDefined: typeof import('@vueuse/core')['isDefined'] + const isProxy: typeof import('vue')['isProxy'] + const isReactive: typeof import('vue')['isReactive'] + const isReadonly: typeof import('vue')['isReadonly'] + const isRef: typeof import('vue')['isRef'] + const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable'] + const markRaw: typeof import('vue')['markRaw'] + const nextTick: typeof import('vue')['nextTick'] + const onActivated: typeof import('vue')['onActivated'] + const onBeforeMount: typeof import('vue')['onBeforeMount'] + const onBeforeUnmount: typeof import('vue')['onBeforeUnmount'] + const onBeforeUpdate: typeof import('vue')['onBeforeUpdate'] + const onClickOutside: typeof import('@vueuse/core')['onClickOutside'] + const onDeactivated: typeof import('vue')['onDeactivated'] + const onErrorCaptured: typeof import('vue')['onErrorCaptured'] + const onKeyStroke: typeof import('@vueuse/core')['onKeyStroke'] + const onLongPress: typeof import('@vueuse/core')['onLongPress'] + const onMounted: typeof import('vue')['onMounted'] + const onRenderTracked: typeof import('vue')['onRenderTracked'] + const onRenderTriggered: typeof import('vue')['onRenderTriggered'] + const onScopeDispose: typeof import('vue')['onScopeDispose'] + const onServerPrefetch: typeof import('vue')['onServerPrefetch'] + const onStartTyping: typeof import('@vueuse/core')['onStartTyping'] + const onUnmounted: typeof import('vue')['onUnmounted'] + const onUpdated: typeof import('vue')['onUpdated'] + const pausableWatch: typeof import('@vueuse/core')['pausableWatch'] + const preferredDark: typeof import('./composables/dark')['preferredDark'] + const provide: typeof import('vue')['provide'] + const reactify: typeof import('@vueuse/core')['reactify'] + const reactifyObject: typeof import('@vueuse/core')['reactifyObject'] + const reactive: typeof import('vue')['reactive'] + const reactiveComputed: typeof import('@vueuse/core')['reactiveComputed'] + const reactiveOmit: typeof import('@vueuse/core')['reactiveOmit'] + const reactivePick: typeof import('@vueuse/core')['reactivePick'] + const readonly: typeof import('vue')['readonly'] + const ref: typeof import('vue')['ref'] + const refAutoReset: typeof import('@vueuse/core')['refAutoReset'] + const refDebounced: typeof import('@vueuse/core')['refDebounced'] + const refDefault: typeof import('@vueuse/core')['refDefault'] + const refThrottled: typeof import('@vueuse/core')['refThrottled'] + const refWithControl: typeof import('@vueuse/core')['refWithControl'] + const resolveComponent: typeof import('vue')['resolveComponent'] + const resolveRef: typeof import('@vueuse/core')['resolveRef'] + const resolveUnref: typeof import('@vueuse/core')['resolveUnref'] + const shallowReactive: typeof import('vue')['shallowReactive'] + const shallowReadonly: typeof import('vue')['shallowReadonly'] + const shallowRef: typeof import('vue')['shallowRef'] + const syncRef: typeof import('@vueuse/core')['syncRef'] + const syncRefs: typeof import('@vueuse/core')['syncRefs'] + const templateRef: typeof import('@vueuse/core')['templateRef'] + const throttledRef: typeof import('@vueuse/core')['throttledRef'] + const throttledWatch: typeof import('@vueuse/core')['throttledWatch'] + const toRaw: typeof import('vue')['toRaw'] + const toReactive: typeof import('@vueuse/core')['toReactive'] + const toRef: typeof import('vue')['toRef'] + const toRefs: typeof import('vue')['toRefs'] + const toggleDark: typeof import('./composables/dark')['toggleDark'] + const triggerRef: typeof import('vue')['triggerRef'] + const tryOnBeforeMount: typeof import('@vueuse/core')['tryOnBeforeMount'] + const tryOnBeforeUnmount: typeof import('@vueuse/core')['tryOnBeforeUnmount'] + const tryOnMounted: typeof import('@vueuse/core')['tryOnMounted'] + const tryOnScopeDispose: typeof import('@vueuse/core')['tryOnScopeDispose'] + const tryOnUnmounted: typeof import('@vueuse/core')['tryOnUnmounted'] + const unref: typeof import('vue')['unref'] + const unrefElement: typeof import('@vueuse/core')['unrefElement'] + const until: typeof import('@vueuse/core')['until'] + const useActiveElement: typeof import('@vueuse/core')['useActiveElement'] + const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery'] + const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter'] + const useArrayFind: typeof import('@vueuse/core')['useArrayFind'] + const useArrayFindIndex: typeof import('@vueuse/core')['useArrayFindIndex'] + const useArrayJoin: typeof import('@vueuse/core')['useArrayJoin'] + const useArrayMap: typeof import('@vueuse/core')['useArrayMap'] + const useArrayReduce: typeof import('@vueuse/core')['useArrayReduce'] + const useArraySome: typeof import('@vueuse/core')['useArraySome'] + const useAsyncQueue: typeof import('@vueuse/core')['useAsyncQueue'] + const useAsyncState: typeof import('@vueuse/core')['useAsyncState'] + const useAttrs: typeof import('vue')['useAttrs'] + const useBase64: typeof import('@vueuse/core')['useBase64'] + const useBattery: typeof import('@vueuse/core')['useBattery'] + const useBluetooth: typeof import('@vueuse/core')['useBluetooth'] + const useBreakpoints: typeof import('@vueuse/core')['useBreakpoints'] + const useBroadcastChannel: typeof import('@vueuse/core')['useBroadcastChannel'] + const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation'] + const useCached: typeof import('@vueuse/core')['useCached'] + const useClipboard: typeof import('@vueuse/core')['useClipboard'] + const useColorMode: typeof import('@vueuse/core')['useColorMode'] + const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog'] + const useCounter: typeof import('@vueuse/core')['useCounter'] + const useCssModule: typeof import('vue')['useCssModule'] + const useCssVar: typeof import('@vueuse/core')['useCssVar'] + const useCssVars: typeof import('vue')['useCssVars'] + const useCurrentElement: typeof import('@vueuse/core')['useCurrentElement'] + const useCycleList: typeof import('@vueuse/core')['useCycleList'] + const useDark: typeof import('@vueuse/core')['useDark'] + const useDateFormat: typeof import('@vueuse/core')['useDateFormat'] + const useDebounce: typeof import('@vueuse/core')['useDebounce'] + const useDebounceFn: typeof import('@vueuse/core')['useDebounceFn'] + const useDebouncedRefHistory: typeof import('@vueuse/core')['useDebouncedRefHistory'] + const useDeviceMotion: typeof import('@vueuse/core')['useDeviceMotion'] + const useDeviceOrientation: typeof import('@vueuse/core')['useDeviceOrientation'] + const useDevicePixelRatio: typeof import('@vueuse/core')['useDevicePixelRatio'] + const useDevicesList: typeof import('@vueuse/core')['useDevicesList'] + const useDisplayMedia: typeof import('@vueuse/core')['useDisplayMedia'] + const useDocumentVisibility: typeof import('@vueuse/core')['useDocumentVisibility'] + const useDraggable: typeof import('@vueuse/core')['useDraggable'] + const useDropZone: typeof import('@vueuse/core')['useDropZone'] + const useElementBounding: typeof import('@vueuse/core')['useElementBounding'] + const useElementByPoint: typeof import('@vueuse/core')['useElementByPoint'] + const useElementHover: typeof import('@vueuse/core')['useElementHover'] + const useElementSize: typeof import('@vueuse/core')['useElementSize'] + const useElementVisibility: typeof import('@vueuse/core')['useElementVisibility'] + const useEventBus: typeof import('@vueuse/core')['useEventBus'] + const useEventListener: typeof import('@vueuse/core')['useEventListener'] + const useEventSource: typeof import('@vueuse/core')['useEventSource'] + const useEyeDropper: typeof import('@vueuse/core')['useEyeDropper'] + const useFavicon: typeof import('@vueuse/core')['useFavicon'] + const useFetch: typeof import('@vueuse/core')['useFetch'] + const useFileDialog: typeof import('@vueuse/core')['useFileDialog'] + const useFileSystemAccess: typeof import('@vueuse/core')['useFileSystemAccess'] + const useFocus: typeof import('@vueuse/core')['useFocus'] + const useFocusWithin: typeof import('@vueuse/core')['useFocusWithin'] + const useFps: typeof import('@vueuse/core')['useFps'] + const useFullscreen: typeof import('@vueuse/core')['useFullscreen'] + const useGamepad: typeof import('@vueuse/core')['useGamepad'] + const useGeolocation: typeof import('@vueuse/core')['useGeolocation'] + const useHead: typeof import('@vueuse/head')['useHead'] + const useI18n: typeof import('vue-i18n')['useI18n'] + const useIdle: typeof import('@vueuse/core')['useIdle'] + const useImage: typeof import('@vueuse/core')['useImage'] + const useInfiniteScroll: typeof import('@vueuse/core')['useInfiniteScroll'] + const useIntersectionObserver: typeof import('@vueuse/core')['useIntersectionObserver'] + const useInterval: typeof import('@vueuse/core')['useInterval'] + const useIntervalFn: typeof import('@vueuse/core')['useIntervalFn'] + const useKeyModifier: typeof import('@vueuse/core')['useKeyModifier'] + const useLastChanged: typeof import('@vueuse/core')['useLastChanged'] + const useLocalStorage: typeof import('@vueuse/core')['useLocalStorage'] + const useMagicKeys: typeof import('@vueuse/core')['useMagicKeys'] + const useManualRefHistory: typeof import('@vueuse/core')['useManualRefHistory'] + const useMediaControls: typeof import('@vueuse/core')['useMediaControls'] + const useMediaQuery: typeof import('@vueuse/core')['useMediaQuery'] + const useMemoize: typeof import('@vueuse/core')['useMemoize'] + const useMemory: typeof import('@vueuse/core')['useMemory'] + const useMounted: typeof import('@vueuse/core')['useMounted'] + const useMouse: typeof import('@vueuse/core')['useMouse'] + const useMouseInElement: typeof import('@vueuse/core')['useMouseInElement'] + const useMousePressed: typeof import('@vueuse/core')['useMousePressed'] + const useMutationObserver: typeof import('@vueuse/core')['useMutationObserver'] + const useNavigatorLanguage: typeof import('@vueuse/core')['useNavigatorLanguage'] + const useNetwork: typeof import('@vueuse/core')['useNetwork'] + const useNow: typeof import('@vueuse/core')['useNow'] + const useObjectUrl: typeof import('@vueuse/core')['useObjectUrl'] + const useOffsetPagination: typeof import('@vueuse/core')['useOffsetPagination'] + const useOnline: typeof import('@vueuse/core')['useOnline'] + const usePageLeave: typeof import('@vueuse/core')['usePageLeave'] + const useParallax: typeof import('@vueuse/core')['useParallax'] + const usePermission: typeof import('@vueuse/core')['usePermission'] + const usePointer: typeof import('@vueuse/core')['usePointer'] + const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe'] + const usePreferredColorScheme: typeof import('@vueuse/core')['usePreferredColorScheme'] + const usePreferredDark: typeof import('@vueuse/core')['usePreferredDark'] + const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages'] + const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion'] + const useRafFn: typeof import('@vueuse/core')['useRafFn'] + const useRefHistory: typeof import('@vueuse/core')['useRefHistory'] + const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver'] + const useRoute: typeof import('vue-router')['useRoute'] + const useRouter: typeof import('vue-router')['useRouter'] + const useScreenOrientation: typeof import('@vueuse/core')['useScreenOrientation'] + const useScreenSafeArea: typeof import('@vueuse/core')['useScreenSafeArea'] + const useScriptTag: typeof import('@vueuse/core')['useScriptTag'] + const useScroll: typeof import('@vueuse/core')['useScroll'] + const useScrollLock: typeof import('@vueuse/core')['useScrollLock'] + const useSessionStorage: typeof import('@vueuse/core')['useSessionStorage'] + const useShare: typeof import('@vueuse/core')['useShare'] + const useSlots: typeof import('vue')['useSlots'] + const useSpeechRecognition: typeof import('@vueuse/core')['useSpeechRecognition'] + const useSpeechSynthesis: typeof import('@vueuse/core')['useSpeechSynthesis'] + const useStepper: typeof import('@vueuse/core')['useStepper'] + const useStorage: typeof import('@vueuse/core')['useStorage'] + const useStorageAsync: typeof import('@vueuse/core')['useStorageAsync'] + const useStyleTag: typeof import('@vueuse/core')['useStyleTag'] + const useSupported: typeof import('@vueuse/core')['useSupported'] + const useSwipe: typeof import('@vueuse/core')['useSwipe'] + const useTemplateRefsList: typeof import('@vueuse/core')['useTemplateRefsList'] + const useTextDirection: typeof import('@vueuse/core')['useTextDirection'] + const useTextSelection: typeof import('@vueuse/core')['useTextSelection'] + const useTextareaAutosize: typeof import('@vueuse/core')['useTextareaAutosize'] + const useThrottle: typeof import('@vueuse/core')['useThrottle'] + const useThrottleFn: typeof import('@vueuse/core')['useThrottleFn'] + const useThrottledRefHistory: typeof import('@vueuse/core')['useThrottledRefHistory'] + const useTimeAgo: typeof import('@vueuse/core')['useTimeAgo'] + const useTimeout: typeof import('@vueuse/core')['useTimeout'] + const useTimeoutFn: typeof import('@vueuse/core')['useTimeoutFn'] + const useTimeoutPoll: typeof import('@vueuse/core')['useTimeoutPoll'] + const useTimestamp: typeof import('@vueuse/core')['useTimestamp'] + const useTitle: typeof import('@vueuse/core')['useTitle'] + const useToNumber: typeof import('@vueuse/core')['useToNumber'] + const useToString: typeof import('@vueuse/core')['useToString'] + const useToggle: typeof import('@vueuse/core')['useToggle'] + const useTransition: typeof import('@vueuse/core')['useTransition'] + const useUrlSearchParams: typeof import('@vueuse/core')['useUrlSearchParams'] + const useUserMedia: typeof import('@vueuse/core')['useUserMedia'] + const useUserStore: typeof import('./store/user')['useUserStore'] + const useVModel: typeof import('@vueuse/core')['useVModel'] + const useVModels: typeof import('@vueuse/core')['useVModels'] + const useVibrate: typeof import('@vueuse/core')['useVibrate'] + const useVirtualList: typeof import('@vueuse/core')['useVirtualList'] + const useWakeLock: typeof import('@vueuse/core')['useWakeLock'] + const useWebNotification: typeof import('@vueuse/core')['useWebNotification'] + const useWebSocket: typeof import('@vueuse/core')['useWebSocket'] + const useWebWorker: typeof import('@vueuse/core')['useWebWorker'] + const useWebWorkerFn: typeof import('@vueuse/core')['useWebWorkerFn'] + const useWindowFocus: typeof import('@vueuse/core')['useWindowFocus'] + const useWindowScroll: typeof import('@vueuse/core')['useWindowScroll'] + const useWindowSize: typeof import('@vueuse/core')['useWindowSize'] + const watch: typeof import('vue')['watch'] + const watchArray: typeof import('@vueuse/core')['watchArray'] + const watchAtMost: typeof import('@vueuse/core')['watchAtMost'] + const watchDebounced: typeof import('@vueuse/core')['watchDebounced'] + const watchEffect: typeof import('vue')['watchEffect'] + const watchIgnorable: typeof import('@vueuse/core')['watchIgnorable'] + const watchOnce: typeof import('@vueuse/core')['watchOnce'] + const watchPausable: typeof import('@vueuse/core')['watchPausable'] + const watchPostEffect: typeof import('vue')['watchPostEffect'] + const watchSyncEffect: typeof import('vue')['watchSyncEffect'] + const watchThrottled: typeof import('@vueuse/core')['watchThrottled'] + const watchTriggerable: typeof import('@vueuse/core')['watchTriggerable'] + const watchWithFilter: typeof import('@vueuse/core')['watchWithFilter'] + const whenever: typeof import('@vueuse/core')['whenever'] +} +// for vue template auto import +import { UnwrapRef } from 'vue' +declare module '@vue/runtime-core' { + interface ComponentCustomProperties { + readonly $$: UnwrapRef + readonly $: UnwrapRef + readonly $computed: UnwrapRef + readonly $customRef: UnwrapRef + readonly $ref: UnwrapRef + readonly $shallowRef: UnwrapRef + readonly $toRef: UnwrapRef + readonly EffectScope: UnwrapRef + readonly asyncComputed: UnwrapRef + readonly autoResetRef: UnwrapRef + readonly computed: UnwrapRef + readonly computedAsync: UnwrapRef + readonly computedEager: UnwrapRef + readonly computedInject: UnwrapRef + readonly computedWithControl: UnwrapRef + readonly controlledComputed: UnwrapRef + readonly controlledRef: UnwrapRef + readonly createApp: UnwrapRef + readonly createEventHook: UnwrapRef + readonly createGlobalState: UnwrapRef + readonly createInjectionState: UnwrapRef + readonly createReactiveFn: UnwrapRef + readonly createSharedComposable: UnwrapRef + readonly createUnrefFn: UnwrapRef + readonly customRef: UnwrapRef + readonly debouncedRef: UnwrapRef + readonly debouncedWatch: UnwrapRef + readonly defineAsyncComponent: UnwrapRef + readonly defineComponent: UnwrapRef + readonly eagerComputed: UnwrapRef + readonly effectScope: UnwrapRef + readonly extendRef: UnwrapRef + readonly getCurrentInstance: UnwrapRef + readonly getCurrentScope: UnwrapRef + readonly h: UnwrapRef + readonly ignorableWatch: UnwrapRef + readonly inject: UnwrapRef + readonly isDark: UnwrapRef + readonly isDefined: UnwrapRef + readonly isProxy: UnwrapRef + readonly isReactive: UnwrapRef + readonly isReadonly: UnwrapRef + readonly isRef: UnwrapRef + readonly makeDestructurable: UnwrapRef + readonly markRaw: UnwrapRef + readonly nextTick: UnwrapRef + readonly onActivated: UnwrapRef + readonly onBeforeMount: UnwrapRef + readonly onBeforeUnmount: UnwrapRef + readonly onBeforeUpdate: UnwrapRef + readonly onClickOutside: UnwrapRef + readonly onDeactivated: UnwrapRef + readonly onErrorCaptured: UnwrapRef + readonly onKeyStroke: UnwrapRef + readonly onLongPress: UnwrapRef + readonly onMounted: UnwrapRef + readonly onRenderTracked: UnwrapRef + readonly onRenderTriggered: UnwrapRef + readonly onScopeDispose: UnwrapRef + readonly onServerPrefetch: UnwrapRef + readonly onStartTyping: UnwrapRef + readonly onUnmounted: UnwrapRef + readonly onUpdated: UnwrapRef + readonly pausableWatch: UnwrapRef + readonly preferredDark: UnwrapRef + readonly provide: UnwrapRef + readonly reactify: UnwrapRef + readonly reactifyObject: UnwrapRef + readonly reactive: UnwrapRef + readonly reactiveComputed: UnwrapRef + readonly reactiveOmit: UnwrapRef + readonly reactivePick: UnwrapRef + readonly readonly: UnwrapRef + readonly ref: UnwrapRef + readonly refAutoReset: UnwrapRef + readonly refDebounced: UnwrapRef + readonly refDefault: UnwrapRef + readonly refThrottled: UnwrapRef + readonly refWithControl: UnwrapRef + readonly resolveComponent: UnwrapRef + readonly resolveRef: UnwrapRef + readonly resolveUnref: UnwrapRef + readonly shallowReactive: UnwrapRef + readonly shallowReadonly: UnwrapRef + readonly shallowRef: UnwrapRef + readonly syncRef: UnwrapRef + readonly syncRefs: UnwrapRef + readonly templateRef: UnwrapRef + readonly throttledRef: UnwrapRef + readonly throttledWatch: UnwrapRef + readonly toRaw: UnwrapRef + readonly toReactive: UnwrapRef + readonly toRef: UnwrapRef + readonly toRefs: UnwrapRef + readonly toggleDark: UnwrapRef + readonly triggerRef: UnwrapRef + readonly tryOnBeforeMount: UnwrapRef + readonly tryOnBeforeUnmount: UnwrapRef + readonly tryOnMounted: UnwrapRef + readonly tryOnScopeDispose: UnwrapRef + readonly tryOnUnmounted: UnwrapRef + readonly unref: UnwrapRef + readonly unrefElement: UnwrapRef + readonly until: UnwrapRef + readonly useActiveElement: UnwrapRef + readonly useArrayEvery: UnwrapRef + readonly useArrayFilter: UnwrapRef + readonly useArrayFind: UnwrapRef + readonly useArrayFindIndex: UnwrapRef + readonly useArrayJoin: UnwrapRef + readonly useArrayMap: UnwrapRef + readonly useArrayReduce: UnwrapRef + readonly useArraySome: UnwrapRef + readonly useAsyncQueue: UnwrapRef + readonly useAsyncState: UnwrapRef + readonly useAttrs: UnwrapRef + readonly useBase64: UnwrapRef + readonly useBattery: UnwrapRef + readonly useBluetooth: UnwrapRef + readonly useBreakpoints: UnwrapRef + readonly useBroadcastChannel: UnwrapRef + readonly useBrowserLocation: UnwrapRef + readonly useCached: UnwrapRef + readonly useClipboard: UnwrapRef + readonly useColorMode: UnwrapRef + readonly useConfirmDialog: UnwrapRef + readonly useCounter: UnwrapRef + readonly useCssModule: UnwrapRef + readonly useCssVar: UnwrapRef + readonly useCssVars: UnwrapRef + readonly useCurrentElement: UnwrapRef + readonly useCycleList: UnwrapRef + readonly useDark: UnwrapRef + readonly useDateFormat: UnwrapRef + readonly useDebounce: UnwrapRef + readonly useDebounceFn: UnwrapRef + readonly useDebouncedRefHistory: UnwrapRef + readonly useDeviceMotion: UnwrapRef + readonly useDeviceOrientation: UnwrapRef + readonly useDevicePixelRatio: UnwrapRef + readonly useDevicesList: UnwrapRef + readonly useDisplayMedia: UnwrapRef + readonly useDocumentVisibility: UnwrapRef + readonly useDraggable: UnwrapRef + readonly useDropZone: UnwrapRef + readonly useElementBounding: UnwrapRef + readonly useElementByPoint: UnwrapRef + readonly useElementHover: UnwrapRef + readonly useElementSize: UnwrapRef + readonly useElementVisibility: UnwrapRef + readonly useEventBus: UnwrapRef + readonly useEventListener: UnwrapRef + readonly useEventSource: UnwrapRef + readonly useEyeDropper: UnwrapRef + readonly useFavicon: UnwrapRef + readonly useFetch: UnwrapRef + readonly useFileDialog: UnwrapRef + readonly useFileSystemAccess: UnwrapRef + readonly useFocus: UnwrapRef + readonly useFocusWithin: UnwrapRef + readonly useFps: UnwrapRef + readonly useFullscreen: UnwrapRef + readonly useGamepad: UnwrapRef + readonly useGeolocation: UnwrapRef + readonly useHead: UnwrapRef + readonly useI18n: UnwrapRef + readonly useIdle: UnwrapRef + readonly useImage: UnwrapRef + readonly useInfiniteScroll: UnwrapRef + readonly useIntersectionObserver: UnwrapRef + readonly useInterval: UnwrapRef + readonly useIntervalFn: UnwrapRef + readonly useKeyModifier: UnwrapRef + readonly useLastChanged: UnwrapRef + readonly useLocalStorage: UnwrapRef + readonly useMagicKeys: UnwrapRef + readonly useManualRefHistory: UnwrapRef + readonly useMediaControls: UnwrapRef + readonly useMediaQuery: UnwrapRef + readonly useMemoize: UnwrapRef + readonly useMemory: UnwrapRef + readonly useMounted: UnwrapRef + readonly useMouse: UnwrapRef + readonly useMouseInElement: UnwrapRef + readonly useMousePressed: UnwrapRef + readonly useMutationObserver: UnwrapRef + readonly useNavigatorLanguage: UnwrapRef + readonly useNetwork: UnwrapRef + readonly useNow: UnwrapRef + readonly useObjectUrl: UnwrapRef + readonly useOffsetPagination: UnwrapRef + readonly useOnline: UnwrapRef + readonly usePageLeave: UnwrapRef + readonly useParallax: UnwrapRef + readonly usePermission: UnwrapRef + readonly usePointer: UnwrapRef + readonly usePointerSwipe: UnwrapRef + readonly usePreferredColorScheme: UnwrapRef + readonly usePreferredDark: UnwrapRef + readonly usePreferredLanguages: UnwrapRef + readonly usePreferredReducedMotion: UnwrapRef + readonly useRafFn: UnwrapRef + readonly useRefHistory: UnwrapRef + readonly useResizeObserver: UnwrapRef + readonly useRoute: UnwrapRef + readonly useRouter: UnwrapRef + readonly useScreenOrientation: UnwrapRef + readonly useScreenSafeArea: UnwrapRef + readonly useScriptTag: UnwrapRef + readonly useScroll: UnwrapRef + readonly useScrollLock: UnwrapRef + readonly useSessionStorage: UnwrapRef + readonly useShare: UnwrapRef + readonly useSlots: UnwrapRef + readonly useSpeechRecognition: UnwrapRef + readonly useSpeechSynthesis: UnwrapRef + readonly useStepper: UnwrapRef + readonly useStorage: UnwrapRef + readonly useStorageAsync: UnwrapRef + readonly useStyleTag: UnwrapRef + readonly useSupported: UnwrapRef + readonly useSwipe: UnwrapRef + readonly useTemplateRefsList: UnwrapRef + readonly useTextDirection: UnwrapRef + readonly useTextSelection: UnwrapRef + readonly useTextareaAutosize: UnwrapRef + readonly useThrottle: UnwrapRef + readonly useThrottleFn: UnwrapRef + readonly useThrottledRefHistory: UnwrapRef + readonly useTimeAgo: UnwrapRef + readonly useTimeout: UnwrapRef + readonly useTimeoutFn: UnwrapRef + readonly useTimeoutPoll: UnwrapRef + readonly useTimestamp: UnwrapRef + readonly useTitle: UnwrapRef + readonly useToNumber: UnwrapRef + readonly useToString: UnwrapRef + readonly useToggle: UnwrapRef + readonly useTransition: UnwrapRef + readonly useUrlSearchParams: UnwrapRef + readonly useUserMedia: UnwrapRef + readonly useUserStore: UnwrapRef + readonly useVModel: UnwrapRef + readonly useVModels: UnwrapRef + readonly useVibrate: UnwrapRef + readonly useVirtualList: UnwrapRef + readonly useWakeLock: UnwrapRef + readonly useWebNotification: UnwrapRef + readonly useWebSocket: UnwrapRef + readonly useWebWorker: UnwrapRef + readonly useWebWorkerFn: UnwrapRef + readonly useWindowFocus: UnwrapRef + readonly useWindowScroll: UnwrapRef + readonly useWindowSize: UnwrapRef + readonly watch: UnwrapRef + readonly watchArray: UnwrapRef + readonly watchAtMost: UnwrapRef + readonly watchDebounced: UnwrapRef + readonly watchEffect: UnwrapRef + readonly watchIgnorable: UnwrapRef + readonly watchOnce: UnwrapRef + readonly watchPausable: UnwrapRef + readonly watchPostEffect: UnwrapRef + readonly watchSyncEffect: UnwrapRef + readonly watchThrottled: UnwrapRef + readonly watchTriggerable: UnwrapRef + readonly watchWithFilter: UnwrapRef + readonly whenever: UnwrapRef + } +} diff --git a/fixtures/vitesse/src/components.d.ts b/fixtures/vitesse/src/components.d.ts new file mode 100644 index 0000000..20ec2b8 --- /dev/null +++ b/fixtures/vitesse/src/components.d.ts @@ -0,0 +1,16 @@ +// generated by unplugin-vue-components +// We suggest you to commit this file into source control +// Read more: https://github.com/vuejs/core/pull/3399 +import '@vue/runtime-core' + +export {} + +declare module '@vue/runtime-core' { + export interface GlobalComponents { + Counter: typeof import('./components/Counter.vue')['default'] + Footer: typeof import('./components/Footer.vue')['default'] + README: typeof import('./components/README.md')['default'] + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] + } +} diff --git a/fixtures/vitesse/src/components/Counter.vue b/fixtures/vitesse/src/components/Counter.vue new file mode 100644 index 0000000..6086a45 --- /dev/null +++ b/fixtures/vitesse/src/components/Counter.vue @@ -0,0 +1,19 @@ + + + diff --git a/fixtures/vitesse/src/components/Footer.vue b/fixtures/vitesse/src/components/Footer.vue new file mode 100644 index 0000000..d1c827c --- /dev/null +++ b/fixtures/vitesse/src/components/Footer.vue @@ -0,0 +1,33 @@ + + + diff --git a/fixtures/vitesse/src/components/README.md b/fixtures/vitesse/src/components/README.md new file mode 100644 index 0000000..ee44679 --- /dev/null +++ b/fixtures/vitesse/src/components/README.md @@ -0,0 +1,10 @@ +## Components + +Components in this dir will be auto-registered and on-demand, powered by [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components). + + +### Icons + +You can use icons from almost any icon sets by the power of [Iconify](https://iconify.design/). + +It will only bundle the icons you use. Check out [`unplugin-icons`](https://github.com/antfu/unplugin-icons) for more details. diff --git a/fixtures/vitesse/src/composables/dark.ts b/fixtures/vitesse/src/composables/dark.ts new file mode 100644 index 0000000..5ad5936 --- /dev/null +++ b/fixtures/vitesse/src/composables/dark.ts @@ -0,0 +1,4 @@ +// these APIs are auto-imported from @vueuse/core +export const isDark = useDark() +export const toggleDark = useToggle(isDark) +export const preferredDark = usePreferredDark() diff --git a/fixtures/vitesse/src/layouts/404.vue b/fixtures/vitesse/src/layouts/404.vue new file mode 100644 index 0000000..ca5ada7 --- /dev/null +++ b/fixtures/vitesse/src/layouts/404.vue @@ -0,0 +1,18 @@ + + + diff --git a/fixtures/vitesse/src/layouts/README.md b/fixtures/vitesse/src/layouts/README.md new file mode 100644 index 0000000..6ca905c --- /dev/null +++ b/fixtures/vitesse/src/layouts/README.md @@ -0,0 +1,14 @@ +## Layouts + +Vue components in this dir are used as layouts. + +By default, `default.vue` will be used unless an alternative is specified in the route meta. + +With [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this: + +```html + +meta: + layout: home + +``` diff --git a/fixtures/vitesse/src/layouts/default.vue b/fixtures/vitesse/src/layouts/default.vue new file mode 100644 index 0000000..8ad6202 --- /dev/null +++ b/fixtures/vitesse/src/layouts/default.vue @@ -0,0 +1,9 @@ + diff --git a/fixtures/vitesse/src/layouts/home.vue b/fixtures/vitesse/src/layouts/home.vue new file mode 100644 index 0000000..7ff5a06 --- /dev/null +++ b/fixtures/vitesse/src/layouts/home.vue @@ -0,0 +1,9 @@ + diff --git a/fixtures/vitesse/src/main.ts b/fixtures/vitesse/src/main.ts new file mode 100644 index 0000000..7084cde --- /dev/null +++ b/fixtures/vitesse/src/main.ts @@ -0,0 +1,22 @@ +import { ViteSSG } from 'vite-ssg' +import { setupLayouts } from 'virtual:generated-layouts' +import App from './App.vue' +import type { UserModule } from './types' +import generatedRoutes from '~pages' + +import '@unocss/reset/tailwind.css' +import './styles/main.css' +import 'uno.css' + +const routes = setupLayouts(generatedRoutes) + +// https://github.com/antfu/vite-ssg +export const createApp = ViteSSG( + App, + { routes, base: import.meta.env.BASE_URL }, + (ctx) => { + // install all modules under `modules/` + Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true })) + .forEach(i => i.install?.(ctx)) + }, +) diff --git a/fixtures/vitesse/src/modules/README.md b/fixtures/vitesse/src/modules/README.md new file mode 100644 index 0000000..4504250 --- /dev/null +++ b/fixtures/vitesse/src/modules/README.md @@ -0,0 +1,11 @@ +## Modules + +A custom user module system. Place a `.ts` file with the following template, it will be installed automatically. + +```ts +import { type UserModule } from '~/types' + +export const install: UserModule = ({ app, router, isClient }) => { + // do something +} +``` diff --git a/fixtures/vitesse/src/modules/i18n.ts b/fixtures/vitesse/src/modules/i18n.ts new file mode 100644 index 0000000..5d34801 --- /dev/null +++ b/fixtures/vitesse/src/modules/i18n.ts @@ -0,0 +1,25 @@ +import { createI18n } from 'vue-i18n' +import { type UserModule } from '~/types' + +// Import i18n resources +// https://vitejs.dev/guide/features.html#glob-import +// +// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite +const messages = Object.fromEntries( + Object.entries( + import.meta.glob<{ default: any }>('../../locales/*.y(a)?ml', { eager: true })) + .map(([key, value]) => { + const yaml = key.endsWith('.yaml') + return [key.slice(14, yaml ? -5 : -4), value.default] + }), +) + +export const install: UserModule = ({ app }) => { + const i18n = createI18n({ + legacy: false, + locale: 'en', + messages, + }) + + app.use(i18n) +} diff --git a/fixtures/vitesse/src/modules/nprogress.ts b/fixtures/vitesse/src/modules/nprogress.ts new file mode 100644 index 0000000..0c65954 --- /dev/null +++ b/fixtures/vitesse/src/modules/nprogress.ts @@ -0,0 +1,12 @@ +import NProgress from 'nprogress' +import { type UserModule } from '~/types' + +export const install: UserModule = ({ isClient, router }) => { + if (isClient) { + router.beforeEach((to, from) => { + if (to.path !== from.path) + NProgress.start() + }) + router.afterEach(() => { NProgress.done() }) + } +} diff --git a/fixtures/vitesse/src/modules/pinia.ts b/fixtures/vitesse/src/modules/pinia.ts new file mode 100644 index 0000000..b27907a --- /dev/null +++ b/fixtures/vitesse/src/modules/pinia.ts @@ -0,0 +1,17 @@ +import { createPinia } from 'pinia' +import { type UserModule } from '~/types' + +// Setup Pinia +// https://pinia.vuejs.org/ +export const install: UserModule = ({ isClient, initialState, app }) => { + const pinia = createPinia() + app.use(pinia) + // Refer to + // https://github.com/antfu/vite-ssg/blob/main/README.md#state-serialization + // for other serialization strategies. + if (isClient) + pinia.state.value = (initialState.pinia) || {} + + else + initialState.pinia = pinia.state.value +} diff --git a/fixtures/vitesse/src/modules/pwa.ts b/fixtures/vitesse/src/modules/pwa.ts new file mode 100644 index 0000000..c0c9f82 --- /dev/null +++ b/fixtures/vitesse/src/modules/pwa.ts @@ -0,0 +1,12 @@ +import { type UserModule } from '~/types' + +// https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available +export const install: UserModule = ({ isClient, router }) => { + if (!isClient) + return + + router.isReady().then(async () => { + const { registerSW } = await import('virtual:pwa-register') + registerSW({ immediate: true }) + }) +} diff --git a/fixtures/vitesse/src/pages/README.md b/fixtures/vitesse/src/pages/README.md new file mode 100644 index 0000000..929b7c9 --- /dev/null +++ b/fixtures/vitesse/src/pages/README.md @@ -0,0 +1,20 @@ +## File-based Routing + +Routes will be auto-generated for Vue files in this dir with the same file structure. +Check out [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) for more details. + +### Path Aliasing + +`~/` is aliased to `./src/` folder. + +For example, instead of having + +```ts +import { isDark } from '../../../../composables' +``` + +now, you can use + +```ts +import { isDark } from '~/composables' +``` diff --git a/fixtures/vitesse/src/pages/[...all].vue b/fixtures/vitesse/src/pages/[...all].vue new file mode 100755 index 0000000..673f718 --- /dev/null +++ b/fixtures/vitesse/src/pages/[...all].vue @@ -0,0 +1,14 @@ + + + + + +meta: + layout: 404 + diff --git a/fixtures/vitesse/src/pages/about.md b/fixtures/vitesse/src/pages/about.md new file mode 100644 index 0000000..907d03d --- /dev/null +++ b/fixtures/vitesse/src/pages/about.md @@ -0,0 +1,21 @@ +--- +title: About +--- + +
+ +
+

About

+
+ +[Vitesse](https://github.com/antfu/vitesse) is an opinionated [Vite](https://github.com/vitejs/vite) starter template made by [@antfu](https://github.com/antfu) for mocking apps swiftly. With **file-based routing**, **components auto importing**, **markdown support**, I18n, PWA and uses **UnoCSS** for styling and icons. + +```js +// syntax highlighting example +function vitesse() { + const foo = 'bar' + console.log(foo) +} +``` + +Check out the [GitHub repo](https://github.com/antfu/vitesse) for more details. diff --git a/fixtures/vitesse/src/pages/hi/[name].vue b/fixtures/vitesse/src/pages/hi/[name].vue new file mode 100644 index 0000000..d741d69 --- /dev/null +++ b/fixtures/vitesse/src/pages/hi/[name].vue @@ -0,0 +1,47 @@ + + + diff --git a/fixtures/vitesse/src/pages/index.vue b/fixtures/vitesse/src/pages/index.vue new file mode 100644 index 0000000..f39fcae --- /dev/null +++ b/fixtures/vitesse/src/pages/index.vue @@ -0,0 +1,62 @@ + + + + + +meta: + layout: home + diff --git a/fixtures/vitesse/src/shims.d.ts b/fixtures/vitesse/src/shims.d.ts new file mode 100644 index 0000000..fd84e1e --- /dev/null +++ b/fixtures/vitesse/src/shims.d.ts @@ -0,0 +1,16 @@ +declare interface Window { + // extend the window +} + +// with vite-plugin-vue-markdown, markdown files can be treated as Vue components +declare module '*.md' { + import { type DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} + +declare module '*.vue' { + import { type DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/fixtures/vitesse/src/store/user.ts b/fixtures/vitesse/src/store/user.ts new file mode 100644 index 0000000..b83f5b6 --- /dev/null +++ b/fixtures/vitesse/src/store/user.ts @@ -0,0 +1,34 @@ +import { acceptHMRUpdate, defineStore } from 'pinia' + +export const useUserStore = defineStore('user', () => { + /** + * Current name of the user. + */ + const savedName = ref('') + const previousNames = ref(new Set()) + + const usedNames = computed(() => Array.from(previousNames.value)) + const otherNames = computed(() => usedNames.value.filter(name => name !== savedName.value)) + + /** + * Changes the current name of the user and saves the one that was used + * before. + * + * @param name - new name to set + */ + function setNewName(name: string) { + if (savedName.value) + previousNames.value.add(savedName.value) + + savedName.value = name + } + + return { + setNewName, + otherNames, + savedName, + } +}) + +if (import.meta.hot) + import.meta.hot.accept(acceptHMRUpdate(useUserStore, import.meta.hot)) diff --git a/fixtures/vitesse/src/styles/main.css b/fixtures/vitesse/src/styles/main.css new file mode 100755 index 0000000..a9b54e6 --- /dev/null +++ b/fixtures/vitesse/src/styles/main.css @@ -0,0 +1,29 @@ +@import './markdown.css'; + +html, +body, +#app { + height: 100%; + margin: 0; + padding: 0; +} + +html.dark { + background: #121212; + color-scheme: dark; +} + +#nprogress { + pointer-events: none; +} + +#nprogress .bar { + background: rgb(13,148,136); + opacity: 0.75; + position: fixed; + z-index: 1031; + top: 0; + left: 0; + width: 100%; + height: 2px; +} diff --git a/fixtures/vitesse/src/styles/markdown.css b/fixtures/vitesse/src/styles/markdown.css new file mode 100644 index 0000000..df79499 --- /dev/null +++ b/fixtures/vitesse/src/styles/markdown.css @@ -0,0 +1,28 @@ +.prose pre:not(.shiki) { + padding: 0; +} + +.prose .shiki { + font-family: 'DM Mono', monospace; + font-size: 1.2em; + line-height: 1.4; +} + +.prose img { + width: 100%; +} + +.shiki-light { + background: #f8f8f8 !important; +} +.shiki-dark { + background: #0e0e0e !important; +} + +html.dark .shiki-light { + display: none; +} + +html:not(.dark) .shiki-dark { + display: none; +} diff --git a/fixtures/vitesse/src/types.ts b/fixtures/vitesse/src/types.ts new file mode 100644 index 0000000..8fa90dc --- /dev/null +++ b/fixtures/vitesse/src/types.ts @@ -0,0 +1,3 @@ +import { type ViteSSGContext } from 'vite-ssg' + +export type UserModule = (ctx: ViteSSGContext) => void diff --git a/fixtures/vitesse/test/__snapshots__/component.test.ts.snap b/fixtures/vitesse/test/__snapshots__/component.test.ts.snap new file mode 100644 index 0000000..f5a07c8 --- /dev/null +++ b/fixtures/vitesse/test/__snapshots__/component.test.ts.snap @@ -0,0 +1,3 @@ +// Vitest Snapshot v1 + +exports[`Counter.vue > should render 1`] = `"
10
"`; diff --git a/fixtures/vitesse/test/basic.test.ts b/fixtures/vitesse/test/basic.test.ts new file mode 100644 index 0000000..2abc95f --- /dev/null +++ b/fixtures/vitesse/test/basic.test.ts @@ -0,0 +1,7 @@ +import { describe, expect, it } from 'vitest' + +describe('tests', () => { + it('should works', () => { + expect(1 + 1).toEqual(2) + }) +}) diff --git a/fixtures/vitesse/test/component.test.ts b/fixtures/vitesse/test/component.test.ts new file mode 100644 index 0000000..6ac9b41 --- /dev/null +++ b/fixtures/vitesse/test/component.test.ts @@ -0,0 +1,28 @@ +import { mount } from '@vue/test-utils' +import { describe, expect, it } from 'vitest' +import Counter from '../src/components/Counter.vue' + +describe('Counter.vue', () => { + it('should render', () => { + const wrapper = mount(Counter, { props: { initial: 10 } }) + expect(wrapper.text()).toContain('10') + expect(wrapper.html()).toMatchSnapshot() + }) + + it('should be interactive', async () => { + const wrapper = mount(Counter, { props: { initial: 0 } }) + expect(wrapper.text()).toContain('0') + + expect(wrapper.find('.inc').exists()).toBe(true) + + expect(wrapper.find('.dec').exists()).toBe(true) + + await wrapper.get('.inc').trigger('click') + + expect(wrapper.text()).toContain('1') + + await wrapper.get('.dec').trigger('click') + + expect(wrapper.text()).toContain('0') + }) +}) diff --git a/fixtures/vitesse/unocss.config.ts b/fixtures/vitesse/unocss.config.ts new file mode 100644 index 0000000..7d409e8 --- /dev/null +++ b/fixtures/vitesse/unocss.config.ts @@ -0,0 +1,38 @@ +import { + defineConfig, + presetAttributify, + presetIcons, + presetTypography, + presetUno, + presetWebFonts, + transformerDirectives, + transformerVariantGroup, +} from 'unocss' + +export default defineConfig({ + shortcuts: [ + ['btn', 'px-4 py-1 rounded inline-block bg-teal-700 text-white cursor-pointer hover:bg-teal-800 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'], + ['icon-btn', 'inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-teal-600'], + ], + presets: [ + presetUno(), + presetAttributify(), + presetIcons({ + scale: 1.2, + warn: true, + }), + presetTypography(), + presetWebFonts({ + fonts: { + sans: 'DM Sans', + serif: 'DM Serif Display', + mono: 'DM Mono', + }, + }), + ], + transformers: [ + transformerDirectives(), + transformerVariantGroup(), + ], + safelist: 'prose prose-sm m-auto text-left'.split(' '), +}) diff --git a/fixtures/vitesse/vite.config.ts b/fixtures/vitesse/vite.config.ts new file mode 100644 index 0000000..1097f32 --- /dev/null +++ b/fixtures/vitesse/vite.config.ts @@ -0,0 +1,153 @@ +import path from 'path' +import { defineConfig } from 'vite' +import Vue from '@vitejs/plugin-vue' +import Pages from 'vite-plugin-pages' +import generateSitemap from 'vite-ssg-sitemap' +import Layouts from 'vite-plugin-vue-layouts' +import Components from 'unplugin-vue-components/vite' +import AutoImport from 'unplugin-auto-import/vite' +import Markdown from 'vite-plugin-vue-markdown' +import { VitePWA } from 'vite-plugin-pwa' +import VueI18n from '@intlify/vite-plugin-vue-i18n' +import Inspect from 'vite-plugin-inspect' +import LinkAttributes from 'markdown-it-link-attributes' +import Unocss from 'unocss/vite' +import Shiki from 'markdown-it-shiki' + +export default defineConfig({ + resolve: { + alias: { + '~/': `${path.resolve(__dirname, 'src')}/`, + }, + }, + + plugins: [ + Vue({ + include: [/\.vue$/, /\.md$/], + reactivityTransform: true, + }), + + // https://github.com/hannoeru/vite-plugin-pages + Pages({ + extensions: ['vue', 'md'], + }), + + // https://github.com/JohnCampionJr/vite-plugin-vue-layouts + Layouts(), + + // https://github.com/antfu/unplugin-auto-import + AutoImport({ + imports: [ + 'vue', + 'vue-router', + 'vue-i18n', + 'vue/macros', + '@vueuse/head', + '@vueuse/core', + ], + dts: 'src/auto-imports.d.ts', + dirs: [ + 'src/composables', + 'src/store', + ], + vueTemplate: true, + }), + + // https://github.com/antfu/unplugin-vue-components + Components({ + // allow auto load markdown components under `./src/components/` + extensions: ['vue', 'md'], + // allow auto import and register components used in markdown + include: [/\.vue$/, /\.vue\?vue/, /\.md$/], + dts: 'src/components.d.ts', + }), + + // https://github.com/antfu/unocss + // see unocss.config.ts for config + Unocss(), + + // https://github.com/antfu/vite-plugin-vue-markdown + // Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite + Markdown({ + wrapperClasses: 'prose prose-sm m-auto text-left', + headEnabled: true, + markdownItSetup(md) { + // https://prismjs.com/ + md.use(Shiki, { + theme: { + light: 'vitesse-light', + dark: 'vitesse-dark', + }, + }) + md.use(LinkAttributes, { + matcher: (link: string) => /^https?:\/\//.test(link), + attrs: { + target: '_blank', + rel: 'noopener', + }, + }) + }, + }), + + // https://github.com/antfu/vite-plugin-pwa + VitePWA({ + registerType: 'autoUpdate', + includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'], + manifest: { + name: 'Vitesse', + short_name: 'Vitesse', + theme_color: '#ffffff', + icons: [ + { + src: '/pwa-192x192.png', + sizes: '192x192', + type: 'image/png', + }, + { + src: '/pwa-512x512.png', + sizes: '512x512', + type: 'image/png', + }, + { + src: '/pwa-512x512.png', + sizes: '512x512', + type: 'image/png', + purpose: 'any maskable', + }, + ], + }, + }), + + // https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n + VueI18n({ + runtimeOnly: true, + compositionOnly: true, + include: [path.resolve(__dirname, 'locales/**')], + }), + + // https://github.com/antfu/vite-plugin-inspect + // Visit http://localhost:3333/__inspect/ to see the inspector + Inspect(), + ], + + // https://github.com/vitest-dev/vitest + test: { + include: ['test/**/*.test.ts'], + environment: 'jsdom', + deps: { + inline: ['@vue', '@vueuse', 'vue-demi'], + }, + }, + + // https://github.com/antfu/vite-ssg + ssgOptions: { + script: 'async', + formatting: 'minify', + onFinished() { generateSitemap() }, + }, + + ssr: { + // TODO: workaround until they support native ESM + noExternal: ['workbox-window', /vue-i18n/], + }, +}) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..11c8abe --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "baseUrl": "." + }, + "include": [ + "./packages/**/*.ts" + ], + "exclude": [ + "./fixtures/**/*.*" + ] +}