@slidev/client 52.14.2 → 52.15.1

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.
Files changed (43) hide show
  1. package/builtin/BlueSky.vue +167 -0
  2. package/builtin/CodeBlockWrapper.vue +1 -1
  3. package/builtin/Link.vue +2 -2
  4. package/builtin/Monaco.vue +1 -2
  5. package/builtin/Tweet.vue +1 -1
  6. package/builtin/VClick.ts +8 -0
  7. package/builtin/VClicks.ts +24 -4
  8. package/builtin/VDrag.vue +1 -0
  9. package/composables/useDragElements.ts +5 -2
  10. package/composables/useDrawings.ts +6 -6
  11. package/composables/useMousePosInSlide.ts +21 -0
  12. package/composables/usePreloadImages.ts +2 -1
  13. package/composables/useSlideInfo.ts +1 -2
  14. package/constants.ts +2 -1
  15. package/internals/DrawingControls.vue +25 -7
  16. package/internals/IconButton.vue +3 -1
  17. package/internals/LaserPointer.vue +66 -0
  18. package/internals/MenuButton.vue +1 -1
  19. package/internals/NavControls.vue +28 -18
  20. package/internals/PresenterMouse.vue +1 -1
  21. package/internals/Settings.vue +10 -1
  22. package/internals/ShikiEditor.vue +2 -4
  23. package/internals/SideEditor.vue +3 -1
  24. package/internals/SlideContainer.vue +18 -1
  25. package/logic/recording.ts +16 -8
  26. package/logic/slides.ts +20 -7
  27. package/modules/v-click.ts +42 -8
  28. package/package.json +22 -21
  29. package/pages/404.vue +3 -1
  30. package/pages/export.vue +5 -1
  31. package/pages/notes-edit.vue +3 -1
  32. package/pages/play.vue +2 -0
  33. package/pages/presenter.vue +18 -23
  34. package/setup/main.ts +1 -2
  35. package/setup/monaco.ts +4 -4
  36. package/setup/root.ts +1 -1
  37. package/shim-vue.d.ts +3 -1
  38. package/state/shared.ts +1 -0
  39. package/state/storage.ts +7 -0
  40. package/styles/index.css +8 -22
  41. package/styles/index.ts +23 -0
  42. package/styles/layouts-base.css +1 -1
  43. package/styles/vclick.css +54 -0
@@ -1,9 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import { useHead } from '@unhead/vue'
3
- import { useEventListener, useLocalStorage, useMediaQuery, useMouse, useWindowFocus } from '@vueuse/core'
4
- import { computed, onMounted, reactive, ref, shallowRef, watch } from 'vue'
3
+ import { useEventListener, useLocalStorage, useMediaQuery, useWindowFocus } from '@vueuse/core'
4
+ import { computed, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
5
5
  import { createClicksContextBase } from '../composables/useClicks'
6
6
  import { useDrawings } from '../composables/useDrawings'
7
+ import { useMousePosInSlide } from '../composables/useMousePosInSlide'
7
8
  import { useNav } from '../composables/useNav'
8
9
  import { useSwipeControls } from '../composables/useSwipeControls'
9
10
  import { useWakeLock } from '../composables/useWakeLock'
@@ -14,6 +15,7 @@ import CurrentProgressBar from '../internals/CurrentProgressBar.vue'
14
15
  import DrawingControls from '../internals/DrawingControls.vue'
15
16
  import Goto from '../internals/Goto.vue'
16
17
  import IconButton from '../internals/IconButton.vue'
18
+ import LaserPointer from '../internals/LaserPointer.vue'
17
19
  import NavControls from '../internals/NavControls.vue'
18
20
  import NoteEditable from '../internals/NoteEditable.vue'
19
21
  import NoteStatic from '../internals/NoteStatic.vue'
@@ -27,7 +29,7 @@ import TimerBar from '../internals/TimerBar.vue'
27
29
  import TimerInlined from '../internals/TimerInlined.vue'
28
30
  import { onContextMenu } from '../logic/contextMenu'
29
31
  import { registerShortcuts } from '../logic/shortcuts'
30
- import { decreasePresenterFontSize, increasePresenterFontSize, presenterLayout, presenterNotesFontSize, showEditor, showPresenterCursor } from '../state'
32
+ import { cursorStyle, decreasePresenterFontSize, increasePresenterFontSize, presenterLayout, presenterNotesFontSize, showEditor, showPresenterCursor } from '../state'
31
33
  import { sharedState } from '../state/shared'
32
34
 
33
35
  const inFocus = useWindowFocus()
@@ -244,28 +246,20 @@ if (__DEV__ && __SLIDEV_FEATURE_EDITOR__)
244
246
 
245
247
  // sync presenter cursor
246
248
  onMounted(() => {
247
- const slidesContainer = main.value!.querySelector('#slide-content')!
248
- const mouse = reactive(useMouse())
249
+ const mouse = useMousePosInSlide()
249
250
  const focus = useWindowFocus()
250
251
 
251
- watch(
252
- () => {
253
- if (!focus.value || isDrawing.value || !showPresenterCursor.value || !slidesContainer)
254
- return undefined
255
-
256
- const rect = slidesContainer.getBoundingClientRect()
257
- const x = (mouse.x - rect.left) / rect.width * 100
258
- const y = (mouse.y - rect.top) / rect.height * 100
259
-
260
- if (x < 0 || x > 100 || y < 0 || y > 100)
261
- return undefined
262
-
263
- return { x, y }
264
- },
265
- (pos) => {
266
- sharedState.cursor = pos
267
- },
268
- )
252
+ watchEffect(() => {
253
+ if (!mouse.value || !focus.value || isDrawing.value || !showPresenterCursor.value) {
254
+ sharedState.cursor = undefined
255
+ }
256
+ else {
257
+ sharedState.cursor = {
258
+ ...mouse.value,
259
+ style: cursorStyle.value,
260
+ }
261
+ }
262
+ })
269
263
  })
270
264
  </script>
271
265
 
@@ -328,6 +322,7 @@ onMounted(() => {
328
322
  @contextmenu="onContextMenu"
329
323
  >
330
324
  <SlidesShow render-context="presenter" />
325
+ <LaserPointer />
331
326
  </SlideContainer>
332
327
 
333
328
  <ClicksSlider
package/setup/main.ts CHANGED
@@ -9,8 +9,7 @@ import { createVDragDirective } from '../modules/v-drag'
9
9
  import { createVMarkDirective } from '../modules/v-mark'
10
10
  import { createVMotionDirectives } from '../modules/v-motion'
11
11
  import setupRoutes from '../setup/routes'
12
-
13
- import '#slidev/styles'
12
+ import '../styles'
14
13
 
15
14
  export default async function setupMain(app: App) {
16
15
  function setMaxHeight() {
package/setup/monaco.ts CHANGED
@@ -56,12 +56,12 @@ StandaloneServices.initialize({
56
56
  })
57
57
 
58
58
  const setup = createSingletonPromise(async () => {
59
- const defaults = monaco.languages.typescript.typescriptDefaults
59
+ const defaults = monaco.typescript.typescriptDefaults
60
60
  defaults.setCompilerOptions({
61
61
  ...defaults.getCompilerOptions(),
62
62
  strict: true,
63
- moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
64
- module: monaco.languages.typescript.ModuleKind.ESNext,
63
+ moduleResolution: monaco.typescript.ModuleResolutionKind.NodeJs,
64
+ module: monaco.typescript.ModuleKind.ESNext,
65
65
  })
66
66
 
67
67
  const ata = configs.monacoTypesSource === 'cdn'
@@ -137,7 +137,7 @@ const setup = createSingletonPromise(async () => {
137
137
  async function _addFile(raw: () => Promise<{ default: string }>, path: string) {
138
138
  const uri = monaco.Uri.file(path)
139
139
  const code = (await raw()).default
140
- monaco.languages.typescript.typescriptDefaults.addExtraLib(code, `file:///${path}`)
140
+ monaco.typescript.typescriptDefaults.addExtraLib(code, `file:///${path}`)
141
141
  monaco.editor.createModel(code, 'javascript', uri)
142
142
  }
143
143
 
package/setup/root.ts CHANGED
@@ -80,7 +80,7 @@ export default function setupRoot() {
80
80
  patch('lastUpdate', {
81
81
  id,
82
82
  type: syncType.value,
83
- time: new Date().getTime(),
83
+ time: Date.now(),
84
84
  })
85
85
  }
86
86
  const router = useRouter()
package/shim-vue.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  declare module 'vue' {
2
- type SlideContext = import('./context').SlideContext
2
+ import type { ShallowUnwrapRef } from 'vue'
3
+
4
+ type SlideContext = ShallowUnwrapRef<import('./context').SlideContext>
3
5
  interface ComponentCustomProperties extends SlideContext {
4
6
  }
5
7
  }
package/state/shared.ts CHANGED
@@ -20,6 +20,7 @@ export interface SharedState {
20
20
  cursor?: {
21
21
  x: number
22
22
  y: number
23
+ style?: 'cursor' | 'laser'
23
24
  }
24
25
 
25
26
  lastUpdate?: {
package/state/storage.ts CHANGED
@@ -55,6 +55,13 @@ export const skipExportPdfTip = useLocalStorage('slidev-skip-export-pdf-tip', fa
55
55
  export const captureDelay = useLocalStorage('slidev-export-capture-delay', 400, { listenToStorageChanges: false })
56
56
 
57
57
  export const showPresenterCursor = useLocalStorage('slidev-presenter-cursor', true, { listenToStorageChanges: false })
58
+
59
+ export const cursorStyle = useLocalStorage<'cursor' | 'laser'>('slidev-cursor-style', 'cursor', { listenToStorageChanges: false })
60
+
61
+ export function togglePresenterCursor() {
62
+ showPresenterCursor.value = !showPresenterCursor.value
63
+ }
64
+
58
65
  export const showEditor = useLocalStorage('slidev-show-editor', false, { listenToStorageChanges: false })
59
66
  export const isEditorVertical = useLocalStorage('slidev-editor-vertical', false, { listenToStorageChanges: false })
60
67
  export const editorWidth = useLocalStorage('slidev-editor-width', isClient ? window.innerWidth * 0.4 : 318, { listenToStorageChanges: false })
package/styles/index.css CHANGED
@@ -45,24 +45,6 @@ html {
45
45
  @apply border-none hover:border-none hover:text-white;
46
46
  }
47
47
 
48
- .slidev-vclick-target {
49
- @apply transition-opacity duration-100;
50
- }
51
-
52
- .slidev-vclick-hidden {
53
- opacity: 0 !important;
54
- pointer-events: none !important;
55
- user-select: none !important;
56
- }
57
-
58
- .slidev-vclick-display-none {
59
- display: none !important;
60
- }
61
-
62
- .slidev-vclick-fade {
63
- opacity: 0.5;
64
- }
65
-
66
48
  .slidev-icon {
67
49
  display: inline-block;
68
50
  vertical-align: sub;
@@ -142,11 +124,15 @@ html {
142
124
 
143
125
  #twoslash-container {
144
126
  position: fixed;
145
- }
146
127
 
147
- #twoslash-container .v-popper__wrapper:not(.no-slide-scale > *) {
148
- transform: scale(calc(1 * var(--slidev-slide-scale)));
149
- transform-origin: 30px top;
128
+ .v-popper__wrapper:not(.no-slide-scale > *) {
129
+ zoom: var(--slidev-slide-scale);
130
+ }
131
+
132
+ .v-popper__popper:not(.no-slide-scale > *) {
133
+ translate: calc(10px * (1 - var(--slidev-slide-scale))) 0;
134
+ width: max-content;
135
+ }
150
136
  }
151
137
 
152
138
  .slidev-note ul {
@@ -0,0 +1,23 @@
1
+ import '@unocss/reset/tailwind.css'
2
+
3
+ import 'uno:preflights.css'
4
+ import 'uno:typography.css'
5
+ import 'uno:shortcuts.css'
6
+
7
+ import '@shikijs/vitepress-twoslash/style.css'
8
+ import 'shiki-magic-move/style.css'
9
+ import 'markdown-it-github-alerts/styles/github-colors-light.css'
10
+ import 'markdown-it-github-alerts/styles/github-colors-dark-media.css'
11
+ import 'markdown-it-github-alerts/styles/github-base.css'
12
+
13
+ import './vars.css'
14
+ import './index.css'
15
+ import './code.css'
16
+ import './katex.css'
17
+ import './transitions.css'
18
+ import './shiki-twoslash.css'
19
+ import './vclick.css'
20
+
21
+ import '#slidev/conditional-styles'
22
+
23
+ import 'uno.css'
@@ -34,7 +34,7 @@
34
34
  @apply text-sm pt-1 uppercase tracking-widest font-500;
35
35
  }
36
36
 
37
- h6:not(.opacity-100) {
37
+ :where(&) h6 {
38
38
  @apply opacity-40;
39
39
  }
40
40
 
@@ -0,0 +1,54 @@
1
+ .slidev-vclick-target {
2
+ transition: all 0.1s ease;
3
+
4
+ &.slidev-vclick-anim-none {
5
+ transition: none;
6
+ }
7
+
8
+ &.slidev-vclick-anim-fade-in {
9
+ transition: all 0.3s ease;
10
+ }
11
+ }
12
+
13
+ .slidev-vclick-hidden {
14
+ opacity: 0 !important;
15
+ pointer-events: none !important;
16
+ user-select: none !important;
17
+
18
+ &.slidev-vclick-anim-fade {
19
+ opacity: 0.5 !important;
20
+ }
21
+
22
+ &.slidev-vclick-anim-fade-in {
23
+ opacity: 0 !important;
24
+ }
25
+
26
+ &.slidev-vclick-anim-up {
27
+ translate: 0 20px;
28
+ }
29
+
30
+ &.slidev-vclick-anim-down {
31
+ translate: 0 -20px;
32
+ }
33
+
34
+ &.slidev-vclick-anim-left {
35
+ translate: 20px 0;
36
+ }
37
+
38
+ &.slidev-vclick-anim-right {
39
+ translate: -20px 0;
40
+ }
41
+
42
+ &.slidev-vclick-anim-scale {
43
+ scale: 0.9;
44
+ }
45
+ }
46
+
47
+ .slidev-vclick-display-none {
48
+ display: none !important;
49
+ }
50
+
51
+ /* No longer used, but kept for backward compatibility */
52
+ .slidev-vclick-fade {
53
+ opacity: 0.5;
54
+ }