Skip to content

Commit

Permalink
fix: type error with users' vue-tsc (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound authored Jun 3, 2024
1 parent a0e9a42 commit 3fa55fe
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/NuAsciinemaPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ onMounted(async () => {
if (!playerRef.value)
return
const AsciinemaPlayer = await import('asciinema-player')
const { AsciinemaPlayer } = await import('./deps')
asciinemaPlayer.value = AsciinemaPlayer.create(props.src, playerRef.value, {
...props,
fit: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/NuLazyTeleportRiveCanvas.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRoute } from 'vitepress'
import type { Rive } from '@rive-app/canvas'
import type { Rive } from './deps'
const route = useRoute()
const riveInstances = ref<Rive[]>([])
Expand Down Expand Up @@ -128,7 +128,7 @@ async function renderRiveAsset() {
el.appendChild(canvas)
const rive = await import('@rive-app/canvas')
const { rive } = await import('./deps')
const r = new rive.Rive({
canvas,
src: src.value,
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/components/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Collect optional external dependencies required by the components to avoid accessing them directly in `.vue` files.
// Because users' vue-tsc may report errors due to missing optional dependencies when processing these `.vue` files in our repository.

// asciinema-player
export * as AsciinemaPlayer from 'asciinema-player'

// @rive-app/canvas
export * as rive from '@rive-app/canvas'
export type { Rive } from '@rive-app/canvas'
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script setup lang="ts">
import { useMounted } from '@vueuse/core'
import VPFlyout from 'vitepress/dist/client/theme-default/components/VPFlyout.vue'
import { useI18n } from '../composables/i18n'
import { VPFlyout } from './deps'
import LayoutSwitch from './LayoutSwitch.vue'
import LayoutSwitchPageLayoutWidthInput from './LayoutSwitchPageLayoutMaxWidthSlider.vue'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import _VPFlyout from 'vitepress/dist/client/theme-default/components/VPFlyout.vue'
// Isolate the types of Vitepress internal components to avoid typecheck errors
export const VPFlyout: any = _VPFlyout
1 change: 1 addition & 0 deletions packages/vitepress-plugin-git-changelog/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default defineBuildConfig({
{ builder: 'mkdist', input: './src/client', outDir: './dist/client', pattern: ['**/*.ts'], format: 'cjs', loaders: ['js'] },
{ builder: 'mkdist', input: './src/client', outDir: './dist/client', pattern: ['**/*.ts'], format: 'esm', loaders: ['js'] },
{ builder: 'mkdist', input: './src/client', outDir: './dist/client', pattern: ['**/*.css'], loaders: ['postcss'] },
{ builder: 'mkdist', input: './src/types', outDir: './dist/types', loaders: ['js'] },
{ builder: 'rollup', input: './src/locales/index', outDir: './dist/locales' },
{ builder: 'rollup', input: './src/vite/index', outDir: './dist/vite' },
{ builder: 'rollup', input: './src/vite/index', outDir: './dist/vite' },
Expand Down
3 changes: 3 additions & 0 deletions packages/vitepress-plugin-git-changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"import": "./dist/locales/index.mjs",
"require": "./dist/locales/index.cjs"
},
"./types": {
"types": "./dist/client/index.d.ts"
},
"./vite": {
"types": "./dist/vite/index.d.ts",
"import": "./dist/vite/index.mjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defu } from 'defu'
import { inject } from 'vue'
import { useI18n } from '../composables/i18n'
import type { Commit } from '../../types'
import type { Commit } from '../types'
import { renderCommitMessage } from '../utils'
import { InjectionKey, defaultNumCommitHashLetters, defaultOptions } from '../constants'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { toDate } from 'date-fns'
import type { Commit } from '../../types'
import type { Commit } from '../types'
import { useI18n } from '../composables/i18n'
const props = defineProps<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { defu } from 'defu'
import { useCommits } from '../composables/commits'
import { useI18n } from '../composables/i18n'
import { InjectionKey, defaultOptions } from '../constants'
import type { Commit } from '../../types'
import type { Commit } from '../types'
import type { AuthorInfo } from '../composables/author'
import { extractAuthorsWithMultiple, mapCommitAuthors } from '../composables/author'
Expand Down
70 changes: 70 additions & 0 deletions packages/vitepress-plugin-git-changelog/src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,73 @@ export interface Options {
*/
numCommitHashLetters?: number
}

export interface Commit {
/**
* The file path for this commit.
*
* When the file is located in `srcDir`, the path is relative to `srcDir`.
* Otherwise, the path is relative to cwd. Paths without `. /`.
*/
path: string
/**
* The matched first tag of the commit.
*/
tag?: string
/**
* The matched tags of the commit.
*/
tags?: string[]
/**
* The URL of the release tag.
*/
release_tag_url?: string
/**
* The URLs of the release tags.
*/
release_tags_url?: string[]
/**
* The hash of the commit.
*/
hash: string
/**
* The URL of the commit.
*/
hash_url?: string
/**
* The date of the commit.
*/
date: string
/**
* The UNIX timestamp of the commit.
*/
date_timestamp: number
/**
* The message of the commit.
*/
message: string
/**
* The refs of the commit.
*/
refs?: string
/**
* The body of the commit.
*/
body?: string
/**
* The author name of the commit.
*/
author_name: string
/**
* The author email of the commit.
*/
author_email: string
/**
* The author avatar of the commit.
*/
author_avatar: string
/**
* The repository URL.
*/
repo_url?: string
}

0 comments on commit 3fa55fe

Please sign in to comment.