@slidev/client 51.2.2 → 51.4.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.
@@ -22,33 +22,36 @@ import { useNav } from '../composables/useNav'
22
22
  import { useSlideContext } from '../context'
23
23
  import { makeId } from '../logic/utils'
24
24
 
25
- const props = withDefaults(defineProps<{
26
- codeLz: string
27
- diffLz?: string
28
- lang?: string
29
- readonly?: boolean
30
- lineNumbers?: 'on' | 'off' | 'relative' | 'interval'
31
- height?: number | string // Posible values: 'initial', 'auto', '100%', '200px', etc.
32
- editorOptions?: monaco.editor.IEditorOptions
33
- ata?: boolean
34
- runnable?: boolean
35
- writable?: string
36
- autorun?: boolean | 'once'
37
- showOutputAt?: RawAtValue
38
- outputHeight?: string
39
- highlightOutput?: boolean
40
- runnerOptions?: Record<string, unknown>
41
- }>(), {
42
- codeLz: '',
43
- lang: 'typescript',
44
- readonly: false,
45
- lineNumbers: 'off',
46
- height: 'initial',
47
- ata: true,
48
- runnable: false,
49
- autorun: true,
50
- highlightOutput: true,
51
- })
25
+ const props = withDefaults(
26
+ defineProps<{
27
+ codeLz?: string
28
+ diffLz?: string
29
+ lang?: string
30
+ readonly?: boolean
31
+ lineNumbers?: 'on' | 'off' | 'relative' | 'interval'
32
+ height?: number | string // Posible values: 'initial', 'auto', '100%', '200px', etc.
33
+ editorOptions?: monaco.editor.IEditorOptions
34
+ ata?: boolean
35
+ runnable?: boolean
36
+ writable?: string
37
+ autorun?: boolean | 'once'
38
+ showOutputAt?: RawAtValue
39
+ outputHeight?: string
40
+ highlightOutput?: boolean
41
+ runnerOptions?: Record<string, unknown>
42
+ }>(),
43
+ {
44
+ codeLz: '',
45
+ lang: 'typescript',
46
+ readonly: false,
47
+ lineNumbers: 'off',
48
+ height: 'initial',
49
+ ata: true,
50
+ runnable: false,
51
+ autorun: true,
52
+ highlightOutput: true,
53
+ },
54
+ )
52
55
 
53
56
  const CodeRunner = defineAsyncComponent(() => import('../internals/CodeRunner.vue').then(r => r.default))
54
57
 
@@ -13,13 +13,16 @@ import { toArray } from '@antfu/utils'
13
13
  import { computed } from 'vue'
14
14
  import { useNav } from '../composables/useNav'
15
15
 
16
- const props = withDefaults(defineProps<{
17
- level: number
18
- start?: string | number
19
- listStyle?: string | string[]
20
- list: TocItem[]
21
- listClass?: string | string[]
22
- }>(), { level: 1 })
16
+ const props = withDefaults(
17
+ defineProps<{
18
+ level?: number
19
+ start?: string | number
20
+ listStyle?: string | string[]
21
+ list: TocItem[]
22
+ listClass?: string | string[]
23
+ }>(),
24
+ { level: 1 },
25
+ )
23
26
 
24
27
  const { isPresenter } = useNav()
25
28
 
@@ -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.2",
4
+ "version": "51.4.0",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -29,20 +29,20 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@antfu/utils": "^9.1.0",
32
- "@iconify-json/carbon": "^1.2.7",
32
+ "@iconify-json/carbon": "^1.2.8",
33
33
  "@iconify-json/ph": "^1.2.2",
34
34
  "@iconify-json/svg-spinners": "^1.2.2",
35
- "@shikijs/engine-javascript": "^3.0.0",
36
- "@shikijs/monaco": "^3.0.0",
37
- "@shikijs/vitepress-twoslash": "^3.0.0",
35
+ "@shikijs/engine-javascript": "^3.1.0",
36
+ "@shikijs/monaco": "^3.1.0",
37
+ "@shikijs/vitepress-twoslash": "^3.1.0",
38
38
  "@slidev/rough-notation": "^0.1.0",
39
39
  "@typescript/ata": "^0.9.7",
40
- "@unhead/vue": "^1.11.19",
40
+ "@unhead/vue": "^1.11.20",
41
41
  "@unocss/reset": "^66.0.0",
42
- "@vueuse/core": "^12.7.0",
43
- "@vueuse/math": "^12.7.0",
44
- "@vueuse/motion": "^2.2.6",
45
- "drauu": "^0.4.2",
42
+ "@vueuse/core": "^13.0.0",
43
+ "@vueuse/math": "^13.0.0",
44
+ "@vueuse/motion": "^3.0.1",
45
+ "drauu": "^0.4.3",
46
46
  "file-saver": "^2.0.5",
47
47
  "floating-vue": "^5.2.2",
48
48
  "fuse.js": "^7.1.0",
@@ -52,19 +52,19 @@
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.3",
56
56
  "recordrtc": "^5.6.2",
57
- "shiki": "^3.0.0",
57
+ "shiki": "^3.1.0",
58
58
  "shiki-magic-move": "^1.0.1",
59
- "typescript": "^5.7.3",
59
+ "typescript": "^5.8.2",
60
60
  "unocss": "^66.0.0",
61
61
  "vue": "^3.5.13",
62
62
  "vue-router": "^4.5.0",
63
63
  "yaml": "^2.7.0",
64
- "@slidev/types": "51.2.2",
65
- "@slidev/parser": "51.2.2"
64
+ "@slidev/parser": "51.4.0",
65
+ "@slidev/types": "51.4.0"
66
66
  },
67
67
  "devDependencies": {
68
- "vite": "^6.1.1"
68
+ "vite": "^6.2.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
@@ -54,7 +54,13 @@ const notesEditing = ref(false)
54
54
 
55
55
  const { timer, isTimerActive, resetTimer, toggleTimer } = useTimer()
56
56
 
57
- const clicksCtxMap = computed(() => slides.value.map(route => createFixedClicks(route)))
57
+ const clicksCtxMap = computed(() => slides.value.map((route) => {
58
+ const clicks = ref(0)
59
+ return {
60
+ context: createFixedClicks(route, clicks),
61
+ clicks,
62
+ }
63
+ }))
58
64
  const nextFrame = computed(() => {
59
65
  if (clicksContext.value.current < clicksContext.value.total)
60
66
  return [currentSlideRoute.value!, clicksContext.value.current + 1] as const
@@ -72,7 +78,7 @@ watch(
72
78
  nextFrame,
73
79
  () => {
74
80
  if (nextFrameClicksCtx.value && nextFrame.value)
75
- nextFrameClicksCtx.value.current = nextFrame.value[1]
81
+ nextFrameClicksCtx.value.clicks.value = nextFrame.value[1]
76
82
  },
77
83
  { immediate: true },
78
84
  )
@@ -149,7 +155,7 @@ onMounted(() => {
149
155
  <SlideContainer v-if="nextFrame && nextFrameClicksCtx" key="next">
150
156
  <SlideWrapper
151
157
  :key="nextFrame[0].no"
152
- :clicks-context="nextFrameClicksCtx"
158
+ :clicks-context="nextFrameClicksCtx.context"
153
159
  :route="nextFrame[0]"
154
160
  render-context="previewNext"
155
161
  />
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
  }