@slidev/client 51.2.1 → 51.3.0

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.
@@ -43,9 +43,11 @@ export default defineComponent({
43
43
  const every = +this.every
44
44
  const at = normalizeSingleAtValue(this.at)
45
45
  const isRelative = typeof at === 'string'
46
- if (!at) {
47
- console.warn('[slidev] Invalid at prop for v-clicks component:', at)
48
- return
46
+
47
+ let elements = this.$slots.default?.()
48
+
49
+ if (at == null || !elements) {
50
+ return elements
49
51
  }
50
52
 
51
53
  const click = resolveDirective('click')!
@@ -71,11 +73,6 @@ export default defineComponent({
71
73
  }) as T
72
74
  }
73
75
 
74
- let elements = this.$slots.default?.()
75
-
76
- if (!elements)
77
- return
78
-
79
76
  elements = openAllTopLevelSlots(toArray(elements))
80
77
 
81
78
  const mapSubList = (children: VNodeArrayChildren, depth = 1): VNodeArrayChildren => {
@@ -165,7 +165,7 @@ export function createFixedClicks(
165
165
  ): ClicksContext {
166
166
  const clicksStart = route?.meta.slide?.frontmatter.clicksStart ?? 0
167
167
  return createClicksContextBase(
168
- ref(Math.max(toValue(currentInit), clicksStart)),
168
+ computed(() => Math.max(toValue(currentInit), clicksStart)),
169
169
  clicksStart,
170
170
  route?.meta?.clicks,
171
171
  )
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'vue'
2
2
  import { useEventListener } from '@vueuse/core'
3
- import { computed, watch } from 'vue'
3
+ import { computed, onScopeDispose, watch } from 'vue'
4
4
  import { hideCursorIdle } from '../state'
5
5
 
6
6
  const TIMEOUT = 2000
@@ -17,8 +17,6 @@ export function useHideCursorIdle(
17
17
  document.body.style.cursor = ''
18
18
  }
19
19
 
20
- let timer: ReturnType<typeof setTimeout> | null = null
21
-
22
20
  // If disabled, immediately show the cursor
23
21
  watch(
24
22
  shouldHide,
@@ -27,7 +25,9 @@ export function useHideCursorIdle(
27
25
  show()
28
26
  },
29
27
  )
28
+ onScopeDispose(show)
30
29
 
30
+ let timer: ReturnType<typeof setTimeout> | null = null
31
31
  useEventListener(
32
32
  document.body,
33
33
  ['pointermove', 'pointerdown'],
@@ -35,9 +35,12 @@ export function useHideCursorIdle(
35
35
  show()
36
36
  if (timer)
37
37
  clearTimeout(timer)
38
- if (!shouldHide.value)
39
- return
40
- timer = setTimeout(hide, TIMEOUT)
38
+ if (shouldHide.value) {
39
+ timer = setTimeout(hide, TIMEOUT)
40
+ }
41
+ else {
42
+ timer = null
43
+ }
41
44
  },
42
45
  { passive: true },
43
46
  )
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { provideLocal, useElementSize, useStyleTag } from '@vueuse/core'
3
- import { computed, ref } from 'vue'
2
+ import { provideLocal, useElementSize } from '@vueuse/core'
3
+ import { computed, onUnmounted, ref, watchEffect } from 'vue'
4
4
  import { useNav } from '../composables/useNav'
5
5
  import { injectionSlideElement, injectionSlideScale } from '../constants'
6
6
  import { slideAspect, slideHeight, slideWidth } from '../env'
@@ -64,8 +64,11 @@ const containerStyle = computed(() => props.width
64
64
  : {},
65
65
  )
66
66
 
67
- if (props.isMain)
68
- useStyleTag(computed(() => `:root { --slidev-slide-scale: ${scale.value}; }`))
67
+ if (props.isMain) {
68
+ const rootStyle = document.documentElement.style
69
+ watchEffect(() => rootStyle.setProperty('--slidev-slide-scale', scale.value.toString()))
70
+ onUnmounted(() => rootStyle.removeProperty('--slidev-slide-scale'))
71
+ }
69
72
 
70
73
  provideLocal(injectionSlideScale, scale)
71
74
  provideLocal(injectionSlideElement, slideElement)
@@ -87,7 +87,6 @@ function onAfterLeave() {
87
87
  >
88
88
  <template v-for="route of loadedRoutes" :key="route.no">
89
89
  <SlideWrapper
90
- v-if="Math.abs(route.no - currentSlideRoute.no) <= 20"
91
90
  v-show="route === currentSlideRoute"
92
91
  :clicks-context="isPrintMode && !isPrintWithClicks ? createFixedClicks(route, CLICKS_MAX) : getPrimaryClicks(route)"
93
92
  :route="route"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "51.2.1",
4
+ "version": "51.3.0",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "monaco-editor": "0.51.0",
53
53
  "nanotar": "^0.2.0",
54
54
  "pptxgenjs": "^3.12.0",
55
- "prettier": "^3.5.1",
55
+ "prettier": "^3.5.2",
56
56
  "recordrtc": "^5.6.2",
57
57
  "shiki": "^3.0.0",
58
58
  "shiki-magic-move": "^1.0.1",
@@ -61,10 +61,10 @@
61
61
  "vue": "^3.5.13",
62
62
  "vue-router": "^4.5.0",
63
63
  "yaml": "^2.7.0",
64
- "@slidev/parser": "51.2.1",
65
- "@slidev/types": "51.2.1"
64
+ "@slidev/parser": "51.3.0",
65
+ "@slidev/types": "51.3.0"
66
66
  },
67
67
  "devDependencies": {
68
- "vite": "^6.1.0"
68
+ "vite": "^6.1.1"
69
69
  }
70
70
  }
package/pages/play.vue CHANGED
@@ -15,7 +15,7 @@ import { onContextMenu } from '../logic/contextMenu'
15
15
  import { registerShortcuts } from '../logic/shortcuts'
16
16
  import { editorHeight, editorWidth, isEditorVertical, isScreenVertical, showEditor, viewerCssFilter, viewerCssFilterDefaults } from '../state'
17
17
 
18
- const { next, prev, isPrintMode, isPresenter } = useNav()
18
+ const { next, prev, isPrintMode, isPlaying, isEmbedded } = useNav()
19
19
  const { isDrawing } = useDrawings()
20
20
 
21
21
  const root = ref<HTMLDivElement>()
@@ -36,7 +36,7 @@ useSwipeControls(root)
36
36
  registerShortcuts()
37
37
  if (__SLIDEV_FEATURE_WAKE_LOCK__)
38
38
  useWakeLock()
39
- useHideCursorIdle(computed(() => !isPresenter.value && !isPrintMode.value))
39
+ useHideCursorIdle(computed(() => isPlaying.value && !isEmbedded.value && !showEditor.value))
40
40
 
41
41
  if (import.meta.hot) {
42
42
  useStyleTag(computed(() => showEditor.value
package/setup/routes.ts CHANGED
@@ -25,11 +25,13 @@ export default function setupRoutes() {
25
25
  name: 'entry',
26
26
  path: '/entry',
27
27
  component: () => import('../pages/entry.vue'),
28
+ beforeEnter: passwordGuard,
28
29
  },
29
30
  {
30
31
  name: 'overview',
31
32
  path: '/overview',
32
33
  component: () => import('../pages/overview.vue'),
34
+ beforeEnter: passwordGuard,
33
35
  },
34
36
  {
35
37
  name: 'notes',
@@ -56,10 +58,12 @@ export default function setupRoutes() {
56
58
  name: 'print',
57
59
  path: '/print',
58
60
  component: () => import('../pages/print.vue'),
61
+ beforeEnter: passwordGuard,
59
62
  },
60
63
  {
61
64
  path: '/presenter/print',
62
65
  component: () => import('../pages/presenter/print.vue'),
66
+ beforeEnter: passwordGuard,
63
67
  },
64
68
  )
65
69
  }