@slidev/client 0.42.4 → 0.42.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,7 @@ watch([container, value, containerSize.width, innerSize.width], async () => {
49
49
  if (!container.value || innerSize.width.value <= 0)
50
50
  return
51
51
  const ratio = containerSize.width.value / innerSize.width.value
52
- if (isNaN(ratio) || ratio <= 0)
52
+ if (Number.isNaN(ratio) || ratio <= 0)
53
53
  return
54
54
  let newSize = size.value * (containerSize.width.value / innerSize.width.value)
55
55
  if (newSize < props.min) {
@@ -53,8 +53,8 @@ watch(html, () => {
53
53
  watchEffect(() => {
54
54
  const svgEl = el.value?.children?.[0] as SVGElement | undefined
55
55
  if (svgEl && svgEl.hasAttribute('viewBox') && actualHeight.value == null) {
56
- const v = parseFloat(svgEl.getAttribute('viewBox')?.split(' ')[3] || '')
57
- actualHeight.value = isNaN(v) ? undefined : v
56
+ const v = Number.parseFloat(svgEl.getAttribute('viewBox')?.split(' ')[3] || '')
57
+ actualHeight.value = Number.isNaN(v) ? undefined : v
58
58
  }
59
59
  }, { flush: 'post' })
60
60
 
package/builtin/Toc.vue CHANGED
@@ -23,7 +23,7 @@ const props = withDefaults(
23
23
  {
24
24
  columns: 1,
25
25
  listClass: '',
26
- maxDepth: Infinity,
26
+ maxDepth: Number.POSITIVE_INFINITY,
27
27
  minDepth: 1,
28
28
  mode: 'all',
29
29
  },
@@ -7,7 +7,7 @@
7
7
  import { toArray } from '@antfu/utils'
8
8
  import type { Directive, VNode, VNodeArrayChildren } from 'vue'
9
9
 
10
- import { defineComponent, h, isVNode, resolveDirective, withDirectives } from 'vue'
10
+ import { Comment, defineComponent, h, isVNode, resolveDirective, withDirectives } from 'vue'
11
11
 
12
12
  const listTags = ['ul', 'ol']
13
13
 
@@ -77,7 +77,7 @@ export default defineComponent({
77
77
  const mapChildren = (children: VNodeArrayChildren, depth = 1): [VNodeArrayChildren, number] => {
78
78
  let idx = 0
79
79
  const vNodes = children.map((i) => {
80
- if (!isVNode(i))
80
+ if (!isVNode(i) || i.type === Comment)
81
81
  return i
82
82
  const directive = idx % this.every === 0 ? click : after
83
83
  let vNode
@@ -10,7 +10,7 @@ export function useNav(route: ComputedRef<RouteRecordRaw | RouteLocationNormaliz
10
10
  const path = computed(() => route.value.path)
11
11
  const total = computed(() => rawRoutes.length)
12
12
 
13
- const currentPage = computed(() => parseInt(path.value.split(/\//g).slice(-1)[0]) || 1)
13
+ const currentPage = computed(() => Number.parseInt(path.value.split(/\//g).slice(-1)[0]) || 1)
14
14
  const currentPath = computed(() => getPath(currentPage.value))
15
15
  const currentRoute = computed(() => rawRoutes.find(i => i.path === `${currentPage.value}`))
16
16
  const currentSlideId = computed(() => currentRoute.value?.meta?.slide?.id)
package/env.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { SlidevConfig } from '@slidev/types'
2
+ import type { UnwrapNestedRefs } from 'vue'
2
3
  import { computed } from 'vue'
3
4
  import { objectMap } from '@antfu/utils'
4
5
 
5
6
  // @ts-expect-error missing types
6
7
  import _configs from '/@slidev/configs'
8
+ import type { SlidevContext } from './modules/context'
7
9
 
8
10
  export const configs = _configs as SlidevConfig
9
11
  export const slideAspect = configs.aspectRatio ?? (16 / 9)
@@ -15,3 +17,9 @@ export const slideHeight = Math.ceil(slideWidth / slideAspect)
15
17
  export const themeVars = computed(() => {
16
18
  return objectMap(configs.themeConfig || {}, (k, v) => [`--slidev-theme-${k}`, v])
17
19
  })
20
+
21
+ declare module 'vue' {
22
+ interface ComponentCustomProperties {
23
+ $slidev: UnwrapNestedRefs<SlidevContext>
24
+ }
25
+ }
@@ -3,6 +3,7 @@ import { computed, ref, watch } from 'vue'
3
3
  import Fuse from 'fuse.js'
4
4
  import { go, rawRoutes } from '../logic/nav'
5
5
  import { activeElement, showGotoDialog } from '../state'
6
+ import Titles from '/@slidev/titles.md'
6
7
 
7
8
  const container = ref<HTMLDivElement>()
8
9
  const input = ref<HTMLInputElement>()
@@ -153,12 +154,12 @@ watch(activeElement, () => {
153
154
  items-center
154
155
  :border="index === 0 ? '' : 't main'"
155
156
  :class="selectedIndex === index ? 'bg-active op100' : 'op80'"
156
- @click.stop="select(item.no)"
157
+ @click.stop.prevent="select(item.no)"
157
158
  >
158
159
  <div w-4 text-right op50 text-sm>
159
160
  {{ item.no }}
160
161
  </div>
161
- {{ item.title }}
162
+ <Titles :no="item.no" />
162
163
  </li>
163
164
  </ul>
164
165
  </div>
@@ -52,7 +52,7 @@ const className = computed(() => ({
52
52
  'select-none': !configs.selectable,
53
53
  }))
54
54
 
55
- provide(injectionSlideScale, scale)
55
+ provide(injectionSlideScale, scale as any)
56
56
  </script>
57
57
 
58
58
  <template>
@@ -1,5 +1,7 @@
1
1
  import { useVModel } from '@vueuse/core'
2
+ import type { Ref } from 'vue'
2
3
  import { defineComponent, h, provide } from 'vue'
4
+ import type { RenderContext } from '@slidev/types'
3
5
  import { injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionOrderMap, injectionRoute, injectionSlideContext } from '../constants'
4
6
 
5
7
  export default defineComponent({
@@ -42,12 +44,12 @@ export default defineComponent({
42
44
 
43
45
  clicksElements.value.length = 0
44
46
 
45
- provide(injectionRoute, props.route)
46
- provide(injectionSlideContext, props.context)
47
- provide(injectionClicks, clicks)
47
+ provide(injectionRoute, props.route as any)
48
+ provide(injectionSlideContext, props.context as RenderContext)
49
+ provide(injectionClicks, clicks as Ref<number>)
48
50
  provide(injectionClicksDisabled, clicksDisabled)
49
- provide(injectionClicksElements, clicksElements)
50
- provide(injectionOrderMap, clicksOrderMap)
51
+ provide(injectionClicksElements, clicksElements as any)
52
+ provide(injectionOrderMap, clicksOrderMap as any)
51
53
  },
52
54
  render() {
53
55
  if (this.$props.is)
package/layoutHelper.ts CHANGED
@@ -9,7 +9,7 @@ export function resolveAssetUrl(url: string) {
9
9
  return url
10
10
  }
11
11
 
12
- export function handleBackground(background?: string, dim = false): CSSProperties {
12
+ export function handleBackground(background?: string, dim = false, backgroundSize = 'cover'): CSSProperties {
13
13
  const isColor = background && (background[0] === '#' || background.startsWith('rgb'))
14
14
 
15
15
  const style = {
@@ -28,7 +28,7 @@ export function handleBackground(background?: string, dim = false): CSSPropertie
28
28
  : undefined,
29
29
  backgroundRepeat: 'no-repeat',
30
30
  backgroundPosition: 'center',
31
- backgroundSize: 'cover',
31
+ backgroundSize,
32
32
  }
33
33
 
34
34
  if (!style.background)
@@ -9,9 +9,13 @@ const props = defineProps({
9
9
  class: {
10
10
  type: String,
11
11
  },
12
+ backgroundSize: {
13
+ type: String,
14
+ default: 'cover',
15
+ },
12
16
  })
13
17
 
14
- const style = computed(() => handleBackground(props.image))
18
+ const style = computed(() => handleBackground(props.image, false, props.backgroundSize))
15
19
  </script>
16
20
 
17
21
  <template>
@@ -9,9 +9,13 @@ const props = defineProps({
9
9
  class: {
10
10
  type: String,
11
11
  },
12
+ backgroundSize: {
13
+ type: String,
14
+ default: 'cover',
15
+ },
12
16
  })
13
17
 
14
- const style = computed(() => handleBackground(props.image))
18
+ const style = computed(() => handleBackground(props.image, false, props.backgroundSize))
15
19
  </script>
16
20
 
17
21
  <template>
package/layouts/image.vue CHANGED
@@ -6,9 +6,13 @@ const props = defineProps({
6
6
  image: {
7
7
  type: String,
8
8
  },
9
+ backgroundSize: {
10
+ type: String,
11
+ default: 'cover',
12
+ },
9
13
  })
10
14
 
11
- const style = computed(() => handleBackground(props.image))
15
+ const style = computed(() => handleBackground(props.image, false, props.backgroundSize))
12
16
  </script>
13
17
 
14
18
  <template>
package/logic/nav.ts CHANGED
@@ -35,7 +35,7 @@ export const queryClicks = useRouteQuery('clicks', '0')
35
35
  export const total = computed(() => rawRoutes.length)
36
36
  export const path = computed(() => route.value.path)
37
37
 
38
- export const currentPage = computed(() => parseInt(path.value.split(/\//g).slice(-1)[0]) || 1)
38
+ export const currentPage = computed(() => Number.parseInt(path.value.split(/\//g).slice(-1)[0]) || 1)
39
39
  export const currentPath = computed(() => getPath(currentPage.value))
40
40
  export const currentRoute = computed(() => rawRoutes.find(i => i.path === `${currentPage.value}`))
41
41
  export const currentSlideId = computed(() => currentRoute.value?.meta?.slide?.id)
@@ -55,7 +55,7 @@ export const clicks = computed<number>({
55
55
  if (isClicksDisabled.value)
56
56
  return 99999
57
57
  let clicks = +(queryClicks.value || 0)
58
- if (isNaN(clicks))
58
+ if (Number.isNaN(clicks))
59
59
  clicks = 0
60
60
  return clicks
61
61
  },
@@ -66,7 +66,7 @@ export const clicks = computed<number>({
66
66
 
67
67
  export const clicksTotal = computed(() => +(currentRoute.value?.meta?.clicks ?? clicksElements.value.length))
68
68
 
69
- export const hasNext = computed(() => currentPage.value < rawRoutes.length - 1 || clicks.value < clicksTotal.value)
69
+ export const hasNext = computed(() => currentPage.value < rawRoutes.length || clicks.value < clicksTotal.value)
70
70
  export const hasPrev = computed(() => currentPage.value > 1 || clicks.value > 0)
71
71
 
72
72
  export const rawTree = computed(() => rawRoutes
@@ -44,7 +44,7 @@ export function strokeShortcut(key: KeyFilter, fn: Fn) {
44
44
  export function registerShortcuts() {
45
45
  const allShortcuts = setupShortcuts()
46
46
 
47
- const shortcuts = new Map<string | Ref<Boolean>, ShortcutOptions>(
47
+ const shortcuts = new Map<string | Ref<boolean>, ShortcutOptions>(
48
48
  allShortcuts.map((options: ShortcutOptions) => [options.key, options]),
49
49
  )
50
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.42.4",
3
+ "version": "0.42.6",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -15,36 +15,36 @@
15
15
  "node": ">=14.0.0"
16
16
  },
17
17
  "dependencies": {
18
- "@antfu/utils": "^0.7.4",
19
- "@unocss/reset": "^0.53.0",
20
- "@vueuse/core": "^10.1.2",
18
+ "@antfu/utils": "^0.7.5",
19
+ "@unocss/reset": "^0.54.1",
20
+ "@vueuse/core": "^10.3.0",
21
21
  "@vueuse/head": "^1.1.26",
22
- "@vueuse/math": "^10.1.2",
22
+ "@vueuse/math": "^10.3.0",
23
23
  "@vueuse/motion": "^2.0.0",
24
24
  "codemirror": "^5.65.5",
25
25
  "defu": "^6.1.2",
26
- "drauu": "^0.3.2",
26
+ "drauu": "^0.3.3",
27
27
  "file-saver": "^2.0.5",
28
28
  "fuse.js": "^6.6.2",
29
29
  "js-base64": "^3.7.5",
30
30
  "js-yaml": "^4.1.0",
31
- "katex": "^0.16.7",
32
- "mermaid": "^10.2.2",
31
+ "katex": "^0.16.8",
32
+ "mermaid": "^10.3.0",
33
33
  "monaco-editor": "^0.37.1",
34
34
  "nanoid": "^4.0.2",
35
- "prettier": "^2.8.8",
35
+ "prettier": "^3.0.0",
36
36
  "recordrtc": "^5.6.2",
37
37
  "resolve": "^1.22.2",
38
- "unocss": "^0.53.0",
38
+ "unocss": "^0.54.1",
39
39
  "vite-plugin-windicss": "^1.9.0",
40
40
  "vue": "^3.3.4",
41
- "vue-router": "^4.2.2",
41
+ "vue-router": "^4.2.4",
42
42
  "vue-starport": "^0.3.0",
43
43
  "windicss": "^3.5.6",
44
- "@slidev/parser": "0.42.4",
45
- "@slidev/types": "0.42.4"
44
+ "@slidev/parser": "0.42.6",
45
+ "@slidev/types": "0.42.6"
46
46
  },
47
47
  "devDependencies": {
48
- "vite": "^4.3.9"
48
+ "vite": "^4.4.8"
49
49
  }
50
50
  }
package/routes.ts CHANGED
@@ -5,7 +5,7 @@ import Play from './internals/Play.vue'
5
5
  import Print from './internals/Print.vue'
6
6
 
7
7
  // @ts-expect-error missing types
8
- import _rawRoutes from '/@slidev/routes'
8
+ import _rawRoutes, { redirects } from '/@slidev/routes'
9
9
 
10
10
  // @ts-expect-error missing types
11
11
  import _configs from '/@slidev/configs'
@@ -19,6 +19,7 @@ export const routes: RouteRecordRaw[] = [
19
19
  component: Play,
20
20
  children: [
21
21
  ...rawRoutes,
22
+ ...redirects,
22
23
  ],
23
24
  },
24
25
  { name: 'print', path: '/print', component: Print },
@@ -38,7 +38,7 @@ export async function useCodeMirror(
38
38
  if (v !== cm.getValue()) {
39
39
  skip = true
40
40
  const selections = cm.listSelections()
41
- cm.replaceRange(v, cm.posFromIndex(0), cm.posFromIndex(Infinity))
41
+ cm.replaceRange(v, cm.posFromIndex(0), cm.posFromIndex(Number.POSITIVE_INFINITY))
42
42
  cm.setSelections(selections)
43
43
  }
44
44
  },
package/setup/prettier.ts CHANGED
@@ -10,24 +10,20 @@ export async function formatCode(code: string, lang: string) {
10
10
  case 'typescript':
11
11
  parser = 'typescript'
12
12
  plugins = [
13
- // @ts-expect-error missing types
14
- (await import('prettier/esm/parser-babel')).default,
15
- // @ts-expect-error missing types
16
- (await import('prettier/esm/parser-typescript')).default,
13
+ (await import('prettier/plugins/babel')).default,
14
+ (await import('prettier/plugins/typescript')).default,
17
15
  ]
18
16
  break
19
17
  case 'html':
20
18
  parser = 'html'
21
19
  plugins = [
22
- // @ts-expect-error missing types
23
- (await import('prettier/esm/parser-html')).default,
20
+ (await import('prettier/plugins/html')).default,
24
21
  ]
25
22
  break
26
23
  default:
27
24
  parser = 'babel'
28
25
  plugins = [
29
- // @ts-expect-error missing types
30
- (await import('prettier/esm/parser-babel')).default,
26
+ (await import('prettier/plugins/babel')).default,
31
27
  ]
32
28
  }
33
29
 
package/shim.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  declare interface Window {
2
4
  // extend the window
3
5
  }
package/windi.config.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { resolve } from 'node:path'
2
+ import process from 'node:process'
2
3
  import { isTruthy } from '@antfu/utils'
3
4
  import { DefaultExtractor, defineConfig } from 'vite-plugin-windicss'
4
5
  import typography from 'windicss/plugin/typography'