Skip to content

Commit

Permalink
chore: fix type errors (#1825)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX authored Aug 19, 2024
1 parent 58391dd commit 7c2c9e7
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 688 deletions.
8 changes: 0 additions & 8 deletions docs/.vitepress/scripts/prepare.js

This file was deleted.

8 changes: 3 additions & 5 deletions docs/.vitepress/theme/components/Demo.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import TypeIt from 'typeit'
import Markdown from 'markdown-it'
import type { SlidevMarkdown } from '@slidev/types'
import { parse } from '@slidev/parser'
import { parseSync } from '@slidev/parser'
import Cover from '@slidev/theme-default/layouts/cover.vue'
import Default from '@slidev/client/layouts/default.vue'
import Center from '@slidev/client/layouts/center.vue'
import SlideContainer from '@slidev/client/internals/SlideContainer.vue'
import SlideContainer from './SlideContainer.vue'
import '@slidev/client/styles/layouts-base.css'
import '@slidev/theme-default/styles/layouts.css'
Expand Down Expand Up @@ -38,7 +36,7 @@ watch([code, paused], () => {
if (paused.value)
return
try {
info.value = parse(code.value)
info.value = parseSync(code.value, '')
}
catch {
}
Expand Down
47 changes: 47 additions & 0 deletions docs/.vitepress/theme/components/SlideContainer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { useElementSize } from '@vueuse/core'
import { computed, ref } from 'vue'
const slideAspect = 16 / 9
const slideWidth = 980
const slideHeight = 980 * 9 / 16
const root = ref<HTMLDivElement>()
const element = useElementSize(root)
const width = computed(() => element.width.value)
const height = computed(() => element.height.value)
const screenAspect = computed(() => width.value / height.value)
const scale = computed(() => {
if (screenAspect.value < slideAspect)
return width.value / slideWidth
return height.value * slideAspect / slideWidth
})
const style = computed(() => ({
height: `${slideHeight}px`,
width: `${slideWidth}px`,
transform: `translate(-50%, -50%) scale(${scale.value})`,
}))
</script>

<template>
<div ref="root" class="slide-container">
<div class="slide-content" :style="style">
<slot />
</div>
<slot name="controls" />
</div>
</template>

<style lang="postcss">
.slide-container {
@apply relative overflow-hidden;
}
.slide-content {
@apply relative overflow-hidden bg-main absolute left-1/2 top-1/2;
}
</style>
41 changes: 24 additions & 17 deletions docs/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ declare module 'vue' {
export interface GlobalComponents {
AddonGallery: typeof import('./.vitepress/theme/components/AddonGallery.vue')['default']
AddonInfo: typeof import('./.vitepress/theme/components/AddonInfo.vue')['default']
Arrow: typeof import('./.vitepress/@slidev/client/builtin/Arrow.vue')['default']
AutoFitText: typeof import('./.vitepress/@slidev/client/builtin/AutoFitText.vue')['default']
Arrow: typeof import('./node_modules/@slidev/client/builtin/Arrow.vue')['default']
AutoFitText: typeof import('./node_modules/@slidev/client/builtin/AutoFitText.vue')['default']
'Carbon:chevronLeft': typeof import('~icons/carbon/chevron-left')['default']
'Carbon:chevronRight': typeof import('~icons/carbon/chevron-right')['default']
'Carbon:close': typeof import('~icons/carbon/close')['default']
Expand Down Expand Up @@ -39,7 +39,7 @@ declare module 'vue' {
CarbonUserAvatar: typeof import('~icons/carbon/user-avatar')['default']
CarbonUserSpeaker: typeof import('~icons/carbon/user-speaker')['default']
CarbonVideo: typeof import('~icons/carbon/video')['default']
CodeBlockWrapper: typeof import('./.vitepress/@slidev/client/builtin/CodeBlockWrapper.vue')['default']
CodeBlockWrapper: typeof import('./node_modules/@slidev/client/builtin/CodeBlockWrapper.vue')['default']
CodiconAdd: typeof import('~icons/codicon/add')['default']
CodiconEye: typeof import('~icons/codicon/eye')['default']
CodiconGlobe: typeof import('~icons/codicon/globe')['default']
Expand All @@ -53,37 +53,44 @@ declare module 'vue' {
FeaturesAnimationInner: typeof import('./.vitepress/theme/components/FeaturesAnimationInner.vue')['default']
FeaturesOverview: typeof import('./.vitepress/theme/components/FeaturesOverview.vue')['default']
FeatureTag: typeof import('./.vitepress/theme/components/FeatureTag.vue')['default']
KaTexBlockWrapper: typeof import('./node_modules/@slidev/client/builtin/KaTexBlockWrapper.vue')['default']
LandingPage: typeof import('./.vitepress/theme/components/LandingPage.vue')['default']
Layout: typeof import('./.vitepress/theme/components/Layout.vue')['default']
Link: typeof import('./.vitepress/@slidev/client/builtin/Link.vue')['default']
LightOrDark: typeof import('./node_modules/@slidev/client/builtin/LightOrDark.vue')['default']
Link: typeof import('./node_modules/@slidev/client/builtin/Link.vue')['default']
LinkCard: typeof import('./.vitepress/theme/components/LinkCard.vue')['default']
LinkInline: typeof import('./.vitepress/theme/components/LinkInline.vue')['default']
LogosVue: typeof import('~icons/logos/vue')['default']
MdiAccountCircle: typeof import('~icons/mdi/account-circle')['default']
Mermaid: typeof import('./.vitepress/@slidev/client/builtin/Mermaid.vue')['default']
Monaco: typeof import('./.vitepress/@slidev/client/builtin/Monaco.vue')['default']
PlantUml: typeof import('./.vitepress/@slidev/client/builtin/PlantUml.vue')['default']
RenderWhen: typeof import('./.vitepress/@slidev/client/builtin/RenderWhen.vue')['default']
Mermaid: typeof import('./node_modules/@slidev/client/builtin/Mermaid.vue')['default']
Monaco: typeof import('./node_modules/@slidev/client/builtin/Monaco.vue')['default']
PlantUml: typeof import('./node_modules/@slidev/client/builtin/PlantUml.vue')['default']
PoweredBySlidev: typeof import('./node_modules/@slidev/client/builtin/PoweredBySlidev.vue')['default']
RenderWhen: typeof import('./node_modules/@slidev/client/builtin/RenderWhen.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SeeAlso: typeof import('./.vitepress/theme/components/SeeAlso.vue')['default']
ShikiMagicMove: typeof import('./node_modules/@slidev/client/builtin/ShikiMagicMove.vue')['default']
ShowCaseInfo: typeof import('./.vitepress/theme/components/ShowCaseInfo.vue')['default']
ShowCases: typeof import('./.vitepress/theme/components/ShowCases.vue')['default']
SimpleIconsGithub: typeof import('~icons/simple-icons/github')['default']
SimpleIconsNpm: typeof import('~icons/simple-icons/npm')['default']
SlideCurrentNo: typeof import('./.vitepress/@slidev/client/builtin/SlideCurrentNo.vue')['default']
SlidesTotal: typeof import('./.vitepress/@slidev/client/builtin/SlidesTotal.vue')['default']
Starport: typeof import('vue-starport')['Starport']
StarportCarrier: typeof import('vue-starport')['StarportCarrier']
SlideContainer: typeof import('./.vitepress/theme/components/SlideContainer.vue')['default']
SlideCurrentNo: typeof import('./node_modules/@slidev/client/builtin/SlideCurrentNo.vue')['default']
SlidesTotal: typeof import('./node_modules/@slidev/client/builtin/SlidesTotal.vue')['default']
SlidevVideo: typeof import('./node_modules/@slidev/client/builtin/SlidevVideo.vue')['default']
ThemeGallery: typeof import('./.vitepress/theme/components/ThemeGallery.vue')['default']
ThemeInfo: typeof import('./.vitepress/theme/components/ThemeInfo.vue')['default']
TheTweet: typeof import('./.vitepress/theme/components/TheTweet.vue')['default']
Toc: typeof import('./.vitepress/@slidev/client/builtin/Toc.vue')['default']
TocList: typeof import('./.vitepress/@slidev/client/builtin/TocList.vue')['default']
Transform: typeof import('./.vitepress/@slidev/client/builtin/Transform.vue')['default']
Tweet: typeof import('./.vitepress/@slidev/client/builtin/Tweet.vue')['default']
Toc: typeof import('./node_modules/@slidev/client/builtin/Toc.vue')['default']
TocList: typeof import('./node_modules/@slidev/client/builtin/TocList.vue')['default']
Transform: typeof import('./node_modules/@slidev/client/builtin/Transform.vue')['default']
Tweet: typeof import('./node_modules/@slidev/client/builtin/Tweet.vue')['default']
TwemojiCatWithTearsOfJoy: typeof import('~icons/twemoji/cat-with-tears-of-joy')['default']
UimRocket: typeof import('~icons/uim/rocket')['default']
Youtube: typeof import('./.vitepress/@slidev/client/builtin/Youtube.vue')['default']
VClickGap: typeof import('./node_modules/@slidev/client/builtin/VClickGap.vue')['default']
VDrag: typeof import('./node_modules/@slidev/client/builtin/VDrag.vue')['default']
VDragArrow: typeof import('./node_modules/@slidev/client/builtin/VDragArrow.vue')['default']
Youtube: typeof import('./node_modules/@slidev/client/builtin/Youtube.vue')['default']
}
}
4 changes: 2 additions & 2 deletions docs/custom/config-vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To configure the built-in plugins listed above, create a `vite.config.ts` with t
```ts twoslash
/// <reference types="@slidev/types" />
import type MarkdownIt from 'markdown-it'
declare const MyPlugin: (md: MarkdownIt) => void
declare const MyPlugin: (md: any) => void
// ---cut---
import { defineConfig } from 'vite'

Expand All @@ -37,7 +37,7 @@ export default defineConfig({
/* markdown-it options */
markdownItSetup(md) {
/* custom markdown-it plugins */
md.use(MyPlugin/* ... */)
md.use(MyPlugin)
},
},
/* options for other plugins */
Expand Down
7 changes: 1 addition & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"packageManager": "[email protected]",
"scripts": {
"dev": "vitepress",
"build": "vitepress build",
"postinstall": "node .vitepress/scripts/prepare.js"
"build": "vitepress build"
},
"dependencies": {
"@antfu/utils": "^0.7.10",
Expand All @@ -17,10 +16,6 @@
"devDependencies": {
"@iconify/json": "^2.2.237",
"@shikijs/vitepress-twoslash": "^1.13.0",
"@slidev-old/client": "npm:@slidev/[email protected]",
"@slidev-old/parser": "npm:@slidev/[email protected]",
"@slidev-old/theme-default": "npm:@slidev/[email protected]",
"@slidev-old/types": "npm:@slidev/[email protected]",
"@slidev/client": "workspace:*",
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
Expand Down
10 changes: 1 addition & 9 deletions docs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
Expand All @@ -7,13 +6,6 @@ import Inspect from 'vite-plugin-inspect'
import UnoCSS from 'unocss/vite'

export default defineConfig({
resolve: {
alias: {
'@slidev/client/': `${resolve(__dirname, '.vitepress/@slidev/client')}/`,
'@slidev/parser': resolve(__dirname, '.vitepress/@slidev/parser'),
'@slidev/theme-default': resolve(__dirname, '.vitepress/@slidev/theme-default'),
},
},
optimizeDeps: {
exclude: [
'vue-demi',
Expand All @@ -30,7 +22,7 @@ export default defineConfig({
Components({
dirs: [
'./.vitepress/theme/components',
'./.vitepress/@slidev/client/builtin',
'./node_modules/@slidev/client/builtin',
],
extensions: ['vue', 'md'],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/, /\.md\?vue/],
Expand Down
1 change: 1 addition & 0 deletions packages/client/builtin/Toc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Usage:
import { computed } from 'vue'
import type { TocItem } from '@slidev/types'
import { useSlideContext } from '../context'
import TocList from './TocList.vue'
const props = withDefaults(
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion packages/client/builtin/TocList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TitleRenderer from '#slidev/title-renderer'
const props = withDefaults(defineProps<{
level: number
start?: number
start?: string | number
listStyle?: string | string[]
list: TocItem[]
listClass?: string | string[]
Expand Down
2 changes: 1 addition & 1 deletion packages/client/logic/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getCurrentTransition(direction: number, currentRoute?: SlideRout
? prevRoute?.meta?.transition
: currentRoute?.meta?.transition
if (!transition)
transition = configs.transition
transition = configs.transition || undefined

return resolveTransition(transition, direction < 0)
}
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@
"mlly": "^1.7.1",
"ovsx": "^0.9.2",
"prettier": "^3.3.3",
"reactive-vscode": "0.2.0-beta.5",
"reactive-vscode": "0.2.0",
"tm-grammars": "^1.17.1",
"volar-service-prettier": "^0.0.54",
"volar-service-yaml": "^0.0.59"
Expand Down
5 changes: 3 additions & 2 deletions packages/vscode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { useSlidesTree } from './views/slidesTree'
import { useProjectsTree } from './views/projectsTree'
import { useLanguageClient } from './languageClient'

// eslint-disable-next-line no-restricted-syntax
export = defineExtension(() => {
const { activate, deactivate } = defineExtension(() => {
// states
useProjects()

Expand All @@ -32,3 +31,5 @@ export = defineExtension(() => {

return labsInfo
})

export { activate, deactivate }
Loading

0 comments on commit 7c2c9e7

Please sign in to comment.