@slidev/client 0.49.7 → 0.49.9

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.
@@ -15,13 +15,12 @@ Learn more: https://sli.dev/guide/syntax.html#monaco-editor
15
15
  import { debounce } from '@antfu/utils'
16
16
  import lz from 'lz-string'
17
17
  import type * as monaco from 'monaco-editor'
18
- import { computed, nextTick, onMounted, ref } from 'vue'
18
+ import { computed, defineAsyncComponent, nextTick, onMounted, ref } from 'vue'
19
19
  import type { RawAtValue } from '@slidev/types'
20
20
  import { whenever } from '@vueuse/core'
21
21
  import { makeId } from '../logic/utils'
22
22
  import { useSlideContext } from '../context'
23
23
  import { useNav } from '../composables/useNav'
24
- import CodeRunner from '../internals/CodeRunner.vue'
25
24
 
26
25
  const props = withDefaults(defineProps<{
27
26
  codeLz: string
@@ -51,6 +50,8 @@ const props = withDefaults(defineProps<{
51
50
  highlightOutput: true,
52
51
  })
53
52
 
53
+ const CodeRunner = defineAsyncComponent(() => import('../internals/CodeRunner.vue').then(r => r.default))
54
+
54
55
  const code = ref(lz.decompressFromBase64(props.codeLz).trimEnd())
55
56
  const diff = props.diffLz && ref(lz.decompressFromBase64(props.diffLz).trimEnd())
56
57
  const isWritable = computed(() => props.writable && !props.readonly && __DEV__)
package/logic/slides.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { SlideRoute } from '@slidev/types'
2
- import { pathPrefix } from '../env'
3
2
  import { slides } from '#slidev/slides'
4
3
 
5
4
  export { slides }
@@ -17,5 +16,5 @@ export function getSlidePath(
17
16
  if (typeof route === 'number' || typeof route === 'string')
18
17
  route = getSlide(route)!
19
18
  const no = route.meta.slide?.frontmatter.routeAlias ?? route.no
20
- return presenter ? `${pathPrefix}presenter/${no}` : `${pathPrefix}${no}`
19
+ return presenter ? `/presenter/${no}` : `/${no}`
21
20
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "0.49.7",
4
+ "version": "0.49.9",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -35,12 +35,12 @@
35
35
  "@shikijs/monaco": "^1.6.1",
36
36
  "@shikijs/vitepress-twoslash": "^1.6.1",
37
37
  "@slidev/rough-notation": "^0.1.0",
38
- "@typescript/ata": "^0.9.4",
38
+ "@typescript/ata": "^0.9.5",
39
39
  "@unhead/vue": "^1.9.11",
40
- "@unocss/reset": "^0.60.3",
40
+ "@unocss/reset": "^0.60.4",
41
41
  "@vueuse/core": "^10.10.0",
42
42
  "@vueuse/math": "^10.10.0",
43
- "@vueuse/motion": "^2.1.0",
43
+ "@vueuse/motion": "^2.2.3",
44
44
  "codemirror": "^5.65.16",
45
45
  "drauu": "^0.4.0",
46
46
  "file-saver": "^2.0.5",
@@ -50,17 +50,17 @@
50
50
  "lz-string": "^1.5.0",
51
51
  "mermaid": "^10.9.1",
52
52
  "monaco-editor": "^0.49.0",
53
- "prettier": "^3.2.5",
53
+ "prettier": "^3.3.0",
54
54
  "recordrtc": "^5.6.2",
55
55
  "shiki": "^1.6.1",
56
56
  "shiki-magic-move": "^0.4.2",
57
57
  "typescript": "^5.4.5",
58
- "unocss": "^0.60.3",
58
+ "unocss": "^0.60.4",
59
59
  "vue": "^3.4.27",
60
60
  "vue-router": "^4.3.2",
61
61
  "yaml": "^2.4.2",
62
- "@slidev/parser": "0.49.7",
63
- "@slidev/types": "0.49.7"
62
+ "@slidev/parser": "0.49.9",
63
+ "@slidev/types": "0.49.9"
64
64
  },
65
65
  "devDependencies": {
66
66
  "vite": "^5.2.12"
package/pages/404.vue ADDED
@@ -0,0 +1,46 @@
1
+ <script setup>
2
+ import { computed } from 'vue'
3
+ import { useRouter } from 'vue-router'
4
+ import { useNav } from '../composables/useNav'
5
+
6
+ const { currentRoute } = useRouter()
7
+ const { total } = useNav()
8
+
9
+ const guessedSlide = computed(() => {
10
+ const path = currentRoute.value.path
11
+ const match = path.match(/\d+/)
12
+ if (match) {
13
+ const slideNo = +match[0]
14
+ if (slideNo > 0 && slideNo <= total.value)
15
+ return slideNo
16
+ }
17
+ return null
18
+ })
19
+ </script>
20
+
21
+ <template>
22
+ <div class="grid justify-center pt-15%">
23
+ <div>
24
+ <h1 class="text-9xl font-bold">
25
+ 404
26
+ </h1>
27
+ <p class="text-2xl">
28
+ Page not found<code class="op-70">:{{ currentRoute.path }}</code>
29
+ </p>
30
+ <div class="mt-3 flex flex-col gap-2">
31
+ <RouterLink v-if="guessedSlide !== 1" to="/" class="page-link">
32
+ Go Home
33
+ </RouterLink>
34
+ <RouterLink v-if="guessedSlide" :to="`/${guessedSlide}`" class="page-link">
35
+ Go to Slide {{ guessedSlide }}
36
+ </RouterLink>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </template>
41
+
42
+ <style scoped lang="postcss">
43
+ .page-link {
44
+ @apply py-2 px-4 bg-gray/10 hover:bg-gray/20 rounded;
45
+ }
46
+ </style>
@@ -2,7 +2,7 @@
2
2
  import { computed, nextTick, onMounted, reactive, ref } from 'vue'
3
3
  import { useHead } from '@unhead/vue'
4
4
  import type { ClicksContext, SlideRoute } from '@slidev/types'
5
- import { slidesTitle } from '../env'
5
+ import { pathPrefix, slidesTitle } from '../env'
6
6
  import { getSlidePath } from '../logic/slides'
7
7
  import { createFixedClicks } from '../composables/useClicks'
8
8
  import { isColorSchemaConfigured, isDark, toggleDark } from '../logic/dark'
@@ -68,7 +68,7 @@ function checkActiveBlocks() {
68
68
  function openSlideInNewTab(path: string) {
69
69
  const a = document.createElement('a')
70
70
  a.target = '_blank'
71
- a.href = path
71
+ a.href = pathPrefix + path.slice(1)
72
72
  a.click()
73
73
  }
74
74
 
package/setup/monaco.ts CHANGED
@@ -121,16 +121,16 @@ const setup = createSingletonPromise(async () => {
121
121
  }
122
122
  })
123
123
 
124
- async function _addFile(raw: Promise<{ default: string }>, path: string) {
124
+ async function _addFile(raw: () => Promise<{ default: string }>, path: string) {
125
125
  const uri = monaco.Uri.file(path)
126
- const code = (await raw).default
126
+ const code = (await raw()).default
127
127
  monaco.languages.typescript.typescriptDefaults.addExtraLib(code, `file:///${path}`)
128
128
  monaco.editor.createModel(code, 'javascript', uri)
129
129
  }
130
130
 
131
131
  const addFileCache = new Map<string, Promise<void>>()
132
132
 
133
- export async function addFile(raw: Promise<{ default: string }>, path: string) {
133
+ export async function addFile(raw: () => Promise<{ default: string }>, path: string) {
134
134
  if (addFileCache.has(path))
135
135
  return addFileCache.get(path)
136
136
  const promise = _addFile(raw, path)
package/setup/routes.ts CHANGED
@@ -74,6 +74,11 @@ export default function setupRoutes() {
74
74
  path: '',
75
75
  redirect: { path: '/1' },
76
76
  },
77
+ {
78
+ path: '/:pathMatch(.*)*',
79
+ name: 'NotFound',
80
+ component: () => import('../pages/404.vue'),
81
+ },
77
82
  )
78
83
 
79
84
  return setups.reduce((routes, setup) => setup(routes), routes)