@slidev/client 0.48.0-beta.16 → 0.48.0-beta.17

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.
@@ -56,8 +56,12 @@ onUnmounted(() => {
56
56
  clicks!.unregister(id)
57
57
  })
58
58
 
59
+ watchEffect(() => {
60
+ el.value?.classList.toggle('slidev-code-line-numbers', props.lines)
61
+ })
62
+
59
63
  onMounted(() => {
60
- if (!clicks || clicks.disabled)
64
+ if (!clicks || clicks.disabled || !props.ranges?.length)
61
65
  return
62
66
 
63
67
  const { start, end, delta } = clicks.resolve(props.at, props.ranges.length - 1)
@@ -121,9 +125,12 @@ function copyCode() {
121
125
 
122
126
  <template>
123
127
  <div
124
- ref="el" class="slidev-code-wrapper relative group" :class="{
128
+ ref="el"
129
+ class="slidev-code-wrapper relative group"
130
+ :class="{
125
131
  'slidev-code-line-numbers': props.lines,
126
- }" :style="{
132
+ }"
133
+ :style="{
127
134
  'max-height': props.maxHeight,
128
135
  'overflow-y': props.maxHeight ? 'scroll' : undefined,
129
136
  '--start': props.startLine,
@@ -12,11 +12,10 @@ Learn more: https://sli.dev/guide/syntax.html#monaco-editor
12
12
  -->
13
13
 
14
14
  <script setup lang="ts">
15
- import * as monaco from 'monaco-editor'
15
+ import type * as monaco from 'monaco-editor'
16
16
  import { computed, nextTick, onMounted, ref } from 'vue'
17
17
  import { debounce } from '@antfu/utils'
18
- import { decompressFromBase64 } from 'lz-string'
19
- import setup from '../setup/monaco'
18
+ import lz from 'lz-string'
20
19
  import { makeId } from '../logic/utils'
21
20
 
22
21
  const props = withDefaults(defineProps<{
@@ -37,8 +36,8 @@ const props = withDefaults(defineProps<{
37
36
  ata: true,
38
37
  })
39
38
 
40
- const code = decompressFromBase64(props.codeLz).trimEnd()
41
- const diff = props.diffLz && decompressFromBase64(props.diffLz).trimEnd()
39
+ const code = lz.decompressFromBase64(props.codeLz).trimEnd()
40
+ const diff = props.diffLz && lz.decompressFromBase64(props.diffLz).trimEnd()
42
41
 
43
42
  const langMap: Record<string, string> = {
44
43
  ts: 'typescript',
@@ -67,7 +66,9 @@ const height = computed(() => {
67
66
  })
68
67
 
69
68
  onMounted(async () => {
70
- const { ata } = await setup()
69
+ // Lazy load monaco, so it will be bundled in async chunk
70
+ const { default: setup } = await import('../setup/monaco')
71
+ const { ata, monaco } = await setup()
71
72
  const model = monaco.editor.createModel(code, lang, monaco.Uri.parse(`file:///${makeId()}.${ext}`))
72
73
  const commonOptions = {
73
74
  automaticLayout: true,
@@ -88,7 +89,7 @@ onMounted(async () => {
88
89
 
89
90
  let editableEditor: monaco.editor.IStandaloneCodeEditor
90
91
  if (diff) {
91
- const diffModel = monaco.editor.createModel(diff, lang, monaco.Uri.parse(`file:///${nanoid()}.${ext}`))
92
+ const diffModel = monaco.editor.createModel(diff, lang, monaco.Uri.parse(`file:///${makeId()}.${ext}`))
92
93
  const editor = monaco.editor.createDiffEditor(container.value!, {
93
94
  renderOverviewRuler: false,
94
95
  ...commonOptions,
@@ -2,7 +2,7 @@
2
2
  import { ShikiMagicMovePrecompiled } from 'shiki-magic-move/vue'
3
3
  import type { KeyedTokensInfo } from 'shiki-magic-move/types'
4
4
  import { onMounted, onUnmounted, ref, watchEffect } from 'vue'
5
- import { decompressFromBase64 } from 'lz-string'
5
+ import lz from 'lz-string'
6
6
  import { useSlideContext } from '../context'
7
7
  import { makeId } from '../logic/utils'
8
8
 
@@ -13,7 +13,7 @@ const props = defineProps<{
13
13
  at?: string | number
14
14
  }>()
15
15
 
16
- const steps = JSON.parse(decompressFromBase64(props.stepsLz)) as KeyedTokensInfo[]
16
+ const steps = JSON.parse(lz.decompressFromBase64(props.stepsLz)) as KeyedTokensInfo[]
17
17
  const { $clicksContext: clicks, $scale: scale } = useSlideContext()
18
18
  const id = makeId()
19
19
  const index = ref(0)
package/builtin/Tweet.vue CHANGED
@@ -7,9 +7,8 @@ Usage:
7
7
  -->
8
8
 
9
9
  <script setup lang="ts">
10
- import { getCurrentInstance, onMounted, ref } from 'vue'
10
+ import { onMounted, ref } from 'vue'
11
11
  import { isDark } from '../logic/dark'
12
- import { useTweetScript } from '../composables/useTweetScript'
13
12
 
14
13
  const props = defineProps<{
15
14
  id: string | number
@@ -20,11 +19,10 @@ const props = defineProps<{
20
19
 
21
20
  const tweet = ref<HTMLElement | null>()
22
21
 
23
- const vm = getCurrentInstance()!
24
22
  const loaded = ref(false)
25
23
  const tweetNotFound = ref(false)
26
24
 
27
- async function create() {
25
+ onMounted(async () => {
28
26
  // @ts-expect-error global
29
27
  const element = await window.twttr.widgets.createTweet(
30
28
  props.id.toString(),
@@ -38,13 +36,7 @@ async function create() {
38
36
  loaded.value = true
39
37
  if (element === undefined)
40
38
  tweetNotFound.value = true
41
- }
42
-
43
- // @ts-expect-error global
44
- if (window?.twttr?.widgets)
45
- onMounted(create)
46
- else
47
- useTweetScript(vm, create)
39
+ })
48
40
  </script>
49
41
 
50
42
  <template>
@@ -50,6 +50,6 @@ provideLocal(injectionSlideScale, scale)
50
50
  }
51
51
 
52
52
  .print-slide-container {
53
- @apply relative overflow-hidden break-after-page;
53
+ @apply relative overflow-hidden break-after-page translate-0;
54
54
  }
55
55
  </style>
@@ -1,5 +1,5 @@
1
1
  import mermaid from 'mermaid/dist/mermaid.esm.mjs'
2
- import { decompressFromBase64 } from 'lz-string'
2
+ import lz from 'lz-string'
3
3
  import { clearUndefined } from '@antfu/utils'
4
4
  import setupMermaid from '../setup/mermaid'
5
5
  import { makeId } from '../logic/utils'
@@ -20,7 +20,7 @@ export async function renderMermaid(lzEncoded: string, options: any) {
20
20
  ...clearUndefined(setupMermaid() || {}),
21
21
  ...clearUndefined(options),
22
22
  })
23
- const code = decompressFromBase64(lzEncoded)
23
+ const code = lz.decompressFromBase64(lzEncoded)
24
24
  const id = makeId()
25
25
  const { svg } = await mermaid.render(id, code)
26
26
  cache.set(key, svg)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "0.48.0-beta.16",
4
+ "version": "0.48.0-beta.17",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -58,8 +58,8 @@
58
58
  "unocss": "^0.58.5",
59
59
  "vue": "^3.4.20",
60
60
  "vue-router": "^4.3.0",
61
- "@slidev/parser": "0.48.0-beta.16",
62
- "@slidev/types": "0.48.0-beta.16"
61
+ "@slidev/parser": "0.48.0-beta.17",
62
+ "@slidev/types": "0.48.0-beta.17"
63
63
  },
64
64
  "devDependencies": {
65
65
  "vite": "^5.1.4"
package/setup/monaco.ts CHANGED
@@ -24,7 +24,6 @@ import { isDark } from '../logic/dark'
24
24
  import configs from '#slidev/configs'
25
25
 
26
26
  /* __imports__ */
27
-
28
27
  window.MonacoEnvironment = {
29
28
  getWorker(_, label) {
30
29
  if (label === 'json')
@@ -1,17 +0,0 @@
1
- import { createSharedComposable, useScriptTag } from '@vueuse/core'
2
- import type { ComponentInternalInstance } from 'vue'
3
- import { onMounted } from 'vue'
4
-
5
- export const useTweetScript = createSharedComposable(
6
- (vm: ComponentInternalInstance, create: () => void) =>
7
- useScriptTag(
8
- 'https://platform.twitter.com/widgets.js',
9
- () => {
10
- if (vm.isMounted)
11
- create()
12
- else
13
- onMounted(create, vm)
14
- },
15
- { async: true },
16
- ),
17
- )