@slidev/client 0.48.3 → 0.48.5

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.
@@ -14,7 +14,7 @@ const props = defineProps<{
14
14
  }>()
15
15
 
16
16
  const steps = JSON.parse(lz.decompressFromBase64(props.stepsLz)) as KeyedTokensInfo[]
17
- const { $clicksContext: clicks, $scale: scale } = useSlideContext()
17
+ const { $clicksContext: clicks, $scale: scale, $zoom: zoom } = useSlideContext()
18
18
  const { isPrintMode } = useNav()
19
19
  const id = makeId()
20
20
 
@@ -96,7 +96,7 @@ onMounted(() => {
96
96
  :step="stepIndex"
97
97
  :animate="!isPrintMode"
98
98
  :options="{
99
- globalScale: scale,
99
+ globalScale: scale * zoom,
100
100
  // TODO: make this configurable later
101
101
  duration: 800,
102
102
  stagger: 1,
@@ -3,6 +3,7 @@ import { useFetch } from '@vueuse/core'
3
3
  import type { Ref } from 'vue'
4
4
  import { computed, ref, unref } from 'vue'
5
5
  import type { SlideInfo, SlidePatch } from '@slidev/types'
6
+ import { getSlide } from '../logic/slides'
6
7
 
7
8
  export interface UseSlideInfo {
8
9
  info: Ref<SlideInfo | undefined>
@@ -10,9 +11,9 @@ export interface UseSlideInfo {
10
11
  }
11
12
 
12
13
  export function useSlideInfo(no: number): UseSlideInfo {
13
- if (no == null) {
14
+ if (!__SLIDEV_HAS_SERVER__) {
14
15
  return {
15
- info: ref() as Ref<SlideInfo | undefined>,
16
+ info: ref(getSlide(no)?.meta.slide) as Ref<SlideInfo | undefined>,
16
17
  update: async () => {},
17
18
  }
18
19
  }
package/constants.ts CHANGED
@@ -12,6 +12,7 @@ export const injectionRoute = '$$slidev-route' as unknown as InjectionKey<SlideR
12
12
  export const injectionRenderContext = '$$slidev-render-context' as unknown as InjectionKey<Ref<RenderContext>>
13
13
  export const injectionActive = '$$slidev-active' as unknown as InjectionKey<Ref<boolean>>
14
14
  export const injectionFrontmatter = '$$slidev-fontmatter' as unknown as InjectionKey<Record<string, any>>
15
+ export const injectionSlideZoom = '$$slidev-slide-zoom' as unknown as InjectionKey<ComputedRef<number>>
15
16
 
16
17
  export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
17
18
  export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
package/context.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ref, toRef } from 'vue'
1
+ import { computed, ref, toRef } from 'vue'
2
2
  import { injectLocal, objectOmit, provideLocal } from '@vueuse/core'
3
3
  import {
4
4
  FRONTMATTER_FIELDS,
@@ -9,6 +9,7 @@ import {
9
9
  injectionRenderContext,
10
10
  injectionRoute,
11
11
  injectionSlideScale,
12
+ injectionSlideZoom,
12
13
  injectionSlidevContext,
13
14
  } from './constants'
14
15
 
@@ -24,7 +25,8 @@ export function useSlideContext() {
24
25
  const $renderContext = injectLocal(injectionRenderContext)!
25
26
  const $frontmatter = injectLocal(injectionFrontmatter, {})
26
27
  const $route = injectLocal(injectionRoute, undefined)
27
- const $scale = injectLocal(injectionSlideScale, ref(1))!
28
+ const $scale = injectLocal(injectionSlideScale, ref(1))
29
+ const $zoom = injectLocal(injectionSlideZoom, computed(() => 1))
28
30
 
29
31
  return {
30
32
  $slidev,
@@ -36,6 +38,7 @@ export function useSlideContext() {
36
38
  $renderContext,
37
39
  $frontmatter,
38
40
  $scale,
41
+ $zoom,
39
42
  }
40
43
  }
41
44
 
@@ -3,7 +3,7 @@ import { computed, defineAsyncComponent, defineComponent, h, onMounted, ref, toR
3
3
  import type { PropType } from 'vue'
4
4
  import { provideLocal } from '@vueuse/core'
5
5
  import type { ClicksContext, RenderContext, SlideRoute } from '@slidev/types'
6
- import { injectionActive, injectionClicksContext, injectionCurrentPage, injectionRenderContext, injectionRoute } from '../constants'
6
+ import { injectionActive, injectionClicksContext, injectionCurrentPage, injectionRenderContext, injectionRoute, injectionSlideZoom } from '../constants'
7
7
  import SlideLoading from './SlideLoading.vue'
8
8
 
9
9
  const props = defineProps({
@@ -29,21 +29,23 @@ const props = defineProps({
29
29
  },
30
30
  })
31
31
 
32
+ const zoom = computed(() => props.route.meta?.slide?.frontmatter.zoom ?? 1)
33
+
32
34
  provideLocal(injectionRoute, props.route)
33
35
  provideLocal(injectionCurrentPage, ref(props.route.no))
34
36
  provideLocal(injectionRenderContext, ref(props.renderContext as RenderContext))
35
37
  provideLocal(injectionActive, toRef(props, 'active'))
36
38
  provideLocal(injectionClicksContext, toRef(props, 'clicksContext'))
39
+ provideLocal(injectionSlideZoom, zoom)
37
40
 
38
41
  const style = computed(() => {
39
- const zoom = props.route.meta?.slide?.frontmatter.zoom ?? 1
40
- return zoom === 1
42
+ return zoom.value === 1
41
43
  ? undefined
42
44
  : {
43
- width: `${100 / zoom}%`,
44
- height: `${100 / zoom}%`,
45
+ width: `${100 / zoom.value}%`,
46
+ height: `${100 / zoom.value}%`,
45
47
  transformOrigin: 'top left',
46
- transform: `scale(${zoom})`,
48
+ transform: `scale(${zoom.value})`,
47
49
  }
48
50
  })
49
51
 
@@ -75,6 +75,7 @@ function onAfterLeave() {
75
75
  class="overflow-hidden"
76
76
  />
77
77
  </div>
78
+ <div id="twoslash-container" />
78
79
  </component>
79
80
 
80
81
  <!-- Global Top -->
@@ -91,10 +92,9 @@ function onAfterLeave() {
91
92
  height: 100%;
92
93
  }
93
94
 
94
- #slideshow > div {
95
+ #slideshow > div:not(#twoslash-container) {
95
96
  position: absolute;
96
97
  height: 100%;
97
98
  width: 100%;
98
99
  }
99
100
  </style>
100
- ../logic/hmr
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "0.48.3",
4
+ "version": "0.48.5",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -60,8 +60,8 @@
60
60
  "vue": "^3.4.21",
61
61
  "vue-demi": "^0.14.7",
62
62
  "vue-router": "^4.3.0",
63
- "@slidev/types": "0.48.3",
64
- "@slidev/parser": "0.48.3"
63
+ "@slidev/parser": "0.48.5",
64
+ "@slidev/types": "0.48.5"
65
65
  },
66
66
  "devDependencies": {
67
67
  "vite": "^5.1.6"
package/pages/print.vue CHANGED
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { watchEffect } from 'vue'
2
+ import { onMounted, watchEffect } from 'vue'
3
+ import { recomputeAllPoppers } from 'floating-vue'
3
4
  import { windowSize } from '../state'
4
5
  import PrintContainer from '../internals/PrintContainer.vue'
5
6
  import PrintStyle from '../internals/PrintStyle.vue'
@@ -13,6 +14,10 @@ watchEffect(() => {
13
14
  else
14
15
  (document.body.parentNode as HTMLElement).classList.remove('print')
15
16
  })
17
+
18
+ onMounted(() => {
19
+ recomputeAllPoppers()
20
+ })
16
21
  </script>
17
22
 
18
23
  <template>
@@ -24,6 +29,7 @@ watchEffect(() => {
24
29
  :width="windowSize.width.value"
25
30
  />
26
31
  </div>
32
+ <div id="twoslash-container" />
27
33
  </template>
28
34
 
29
35
  <style lang="postcss">
package/setup/main.ts CHANGED
@@ -35,7 +35,7 @@ export default async function setupMain(app: App) {
35
35
  app.use(createVClickDirectives())
36
36
  app.use(createVMarkDirective())
37
37
  app.use(MotionPlugin)
38
- app.use(TwoSlashFloatingVue as any, { container: '#slideshow' })
38
+ app.use(TwoSlashFloatingVue as any, { container: '#twoslash-container' })
39
39
 
40
40
  const context: AppContext = {
41
41
  app,