veslx 0.0.28 → 0.1.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 (85) hide show
  1. package/bin/lib/build.ts +3 -0
  2. package/bin/lib/serve.ts +4 -4
  3. package/bin/veslx.ts +1 -1
  4. package/dist/assets/README-DVMP1xaW.js +7 -0
  5. package/dist/assets/SLIDES-DjNLQtEU.js +10 -0
  6. package/dist/assets/index-CBkKcH4y.js +469 -0
  7. package/dist/assets/index-PspMxLnH.css +1 -0
  8. package/dist/assets/index-UZKwazVi.js +1 -0
  9. package/dist/index.html +2 -2
  10. package/dist/raw/.veslx.json +61 -0
  11. package/dist/raw/README.md +33 -0
  12. package/dist/raw/test-post/Chart.tsx +16 -0
  13. package/dist/raw/test-post/README.mdx +21 -0
  14. package/dist/raw/test-slides/Counter.tsx +25 -0
  15. package/dist/raw/test-slides/SLIDES.mdx +27 -0
  16. package/package.json +3 -7
  17. package/plugin/src/plugin.ts +41 -0
  18. package/src/components/slides-renderer.tsx +130 -0
  19. package/src/hooks/use-mdx-content.ts +108 -0
  20. package/src/pages/post.tsx +15 -13
  21. package/src/pages/slides.tsx +21 -34
  22. package/src/vite-env.d.ts +21 -0
  23. package/vite.config.ts +1 -19
  24. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  25. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  26. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  27. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  28. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  29. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  30. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  31. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  32. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  33. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  34. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  35. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  36. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  37. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  38. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  39. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  40. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  41. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  42. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  43. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  44. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  45. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  46. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  47. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  48. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  49. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  50. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  51. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  52. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  53. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  54. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  55. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  56. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  57. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  58. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  59. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  60. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  61. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  62. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  63. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  64. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  65. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  66. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  67. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  68. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  69. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  70. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  71. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  72. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  73. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  74. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  75. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  76. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  77. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  78. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  79. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  80. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  81. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  82. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  83. package/dist/assets/index-C75KddSa.css +0 -1
  84. package/dist/assets/index-DsHb4M_F.js +0 -542
  85. package/src/components/runtime-mdx.tsx +0 -82
@@ -0,0 +1,108 @@
1
+ import { useState, useEffect } from 'react'
2
+ import { modules, slides } from 'virtual:content-modules'
3
+ import type { ComponentType } from 'react'
4
+
5
+ interface MDXModule {
6
+ default: ComponentType<{ components?: Record<string, ComponentType> }>
7
+ frontmatter?: {
8
+ title?: string
9
+ description?: string
10
+ date?: string
11
+ visibility?: string
12
+ }
13
+ }
14
+
15
+ type ModuleLoader = () => Promise<MDXModule>
16
+
17
+ export function useMDXContent(path: string) {
18
+ const [Content, setContent] = useState<MDXModule['default'] | null>(null)
19
+ const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)
20
+ const [loading, setLoading] = useState(true)
21
+ const [error, setError] = useState<Error | null>(null)
22
+
23
+ useEffect(() => {
24
+ let cancelled = false
25
+ setLoading(true)
26
+ setError(null)
27
+
28
+ // Find the matching module - keys are like "/content-dir/path/README.mdx"
29
+ // We need to match against the path segment
30
+ const matchingKey = Object.keys(modules).find(key =>
31
+ key.endsWith(`/${path}/README.mdx`)
32
+ )
33
+ const loader = matchingKey ? (modules as Record<string, ModuleLoader>)[matchingKey] : null
34
+
35
+ if (!loader) {
36
+ setError(new Error(`MDX module not found for path: ${path}`))
37
+ setLoading(false)
38
+ return
39
+ }
40
+
41
+ loader()
42
+ .then((mod) => {
43
+ if (!cancelled) {
44
+ setContent(() => mod.default)
45
+ setFrontmatter(mod.frontmatter)
46
+ setLoading(false)
47
+ }
48
+ })
49
+ .catch((err) => {
50
+ if (!cancelled) {
51
+ setError(err)
52
+ setLoading(false)
53
+ }
54
+ })
55
+
56
+ return () => {
57
+ cancelled = true
58
+ }
59
+ }, [path])
60
+
61
+ return { Content, frontmatter, loading, error }
62
+ }
63
+
64
+ export function useMDXSlides(path: string) {
65
+ const [Content, setContent] = useState<MDXModule['default'] | null>(null)
66
+ const [frontmatter, setFrontmatter] = useState<MDXModule['frontmatter']>(undefined)
67
+ const [loading, setLoading] = useState(true)
68
+ const [error, setError] = useState<Error | null>(null)
69
+
70
+ useEffect(() => {
71
+ let cancelled = false
72
+ setLoading(true)
73
+ setError(null)
74
+
75
+ // Find the matching module - keys are like "/content-dir/path/SLIDES.mdx"
76
+ const matchingKey = Object.keys(slides).find(key =>
77
+ key.endsWith(`/${path}/SLIDES.mdx`)
78
+ )
79
+ const loader = matchingKey ? (slides as Record<string, ModuleLoader>)[matchingKey] : null
80
+
81
+ if (!loader) {
82
+ setError(new Error(`Slides module not found for path: ${path}`))
83
+ setLoading(false)
84
+ return
85
+ }
86
+
87
+ loader()
88
+ .then((mod) => {
89
+ if (!cancelled) {
90
+ setContent(() => mod.default)
91
+ setFrontmatter(mod.frontmatter)
92
+ setLoading(false)
93
+ }
94
+ })
95
+ .catch((err) => {
96
+ if (!cancelled) {
97
+ setError(err)
98
+ setLoading(false)
99
+ }
100
+ })
101
+
102
+ return () => {
103
+ cancelled = true
104
+ }
105
+ }, [path])
106
+
107
+ return { Content, frontmatter, loading, error }
108
+ }
@@ -1,19 +1,19 @@
1
-
2
1
  import { useParams } from "react-router-dom";
3
- import { findSlides, isSimulationRunning, useDirectory, useFileContent } from "../../plugin/src/client";
2
+ import { findSlides, isSimulationRunning, useDirectory } from "../../plugin/src/client";
4
3
  import Loading from "@/components/loading";
5
4
  import { FileEntry } from "plugin/src/lib";
6
5
  import { FrontMatter } from "@/components/front-matter";
7
6
  import { RunningBar } from "@/components/running-bar";
8
7
  import { Header } from "@/components/header";
9
- import { RuntimeMDX } from "@/components/runtime-mdx";
8
+ import { useMDXContent } from "@/hooks/use-mdx-content";
9
+ import { mdxComponents } from "@/components/mdx-components";
10
10
 
11
11
 
12
12
  export function Post() {
13
13
  const { "path": path = "." } = useParams();
14
14
  const filePath = `${path}/README.mdx`
15
- const { directory, file, loading, error } = useDirectory(filePath)
16
- const { content } = useFileContent(filePath);
15
+ const { directory, loading: dirLoading } = useDirectory(filePath)
16
+ const { Content, frontmatter, loading: mdxLoading, error } = useMDXContent(path);
17
17
  const isRunning = isSimulationRunning();
18
18
 
19
19
  let slides: FileEntry | null = null;
@@ -21,6 +21,8 @@ export function Post() {
21
21
  slides = findSlides(directory);
22
22
  }
23
23
 
24
+ const loading = dirLoading || mdxLoading;
25
+
24
26
  if (loading) return <Loading />
25
27
 
26
28
  if (error) {
@@ -33,11 +35,11 @@ export function Post() {
33
35
 
34
36
  return (
35
37
  <div className="flex min-h-screen flex-col bg-background noise-overlay">
36
- <title>{file?.frontmatter?.title}</title>
38
+ <title>{frontmatter?.title}</title>
37
39
  <RunningBar />
38
40
  <Header />
39
41
  <main className="flex-1 mx-auto w-full max-w-[var(--content-width)] px-[var(--page-padding)]">
40
-
42
+
41
43
  {isRunning && (
42
44
  <div className="sticky top-0 z-50 px-[var(--page-padding)] py-2 bg-red-500 text-primary-foreground font-mono text-xs text-center tracking-wide">
43
45
  <span className="inline-flex items-center gap-3">
@@ -48,18 +50,18 @@ export function Post() {
48
50
  </div>
49
51
  )}
50
52
 
51
- {file && (
53
+ {Content && (
52
54
  <article className="my-24 prose dark:prose-invert prose-headings:tracking-tight prose-p:leading-relaxed prose-a:text-primary prose-a:no-underline hover:prose-a:underline max-w-[var(--prose-width)] animate-fade-in">
53
55
  <FrontMatter
54
- title={file.frontmatter?.title}
55
- date={file.frontmatter?.date}
56
- description={file.frontmatter?.description}
56
+ title={frontmatter?.title}
57
+ date={frontmatter?.date}
58
+ description={frontmatter?.description}
57
59
  slides={slides}
58
60
  />
59
- {content && <RuntimeMDX content={content} />}
61
+ <Content components={mdxComponents} />
60
62
  </article>
61
63
  )}
62
64
  </main>
63
- </div>
65
+ </div>
64
66
  )
65
67
  }
@@ -1,35 +1,23 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
2
  import { FULLSCREEN_DATA_ATTR } from "@/lib/constants";
3
- import { useDirectory, useFileContent } from "../../plugin/src/client";
4
3
  import { useParams, useSearchParams } from "react-router-dom"
5
4
  import Loading from "@/components/loading";
6
5
  import { FrontMatter } from "@/components/front-matter";
7
- import { RuntimeMDX } from "@/components/runtime-mdx";
8
6
  import { RunningBar } from "@/components/running-bar";
9
7
  import { Header } from "@/components/header";
10
-
11
- export function parseSlideContent(content: string): string[] {
12
- // Strip frontmatter if present (starts with --- and ends with ---)
13
- let processedContent = content;
14
- const frontmatterMatch = content.match(/^---\n[\s\S]*?\n---\n/);
15
- if (frontmatterMatch) {
16
- processedContent = content.slice(frontmatterMatch[0].length);
17
- }
18
-
19
- return processedContent
20
- .split(/^---$/m)
21
- .map((slide) => slide.trim())
22
- .filter((slide) => slide.length > 0);
23
- }
8
+ import { useMDXSlides } from "@/hooks/use-mdx-content";
9
+ import { useSlidesFromMDX, SlideContent } from "@/components/slides-renderer";
24
10
 
25
11
 
26
12
  export function SlidesPage() {
27
13
  const { "path": path = "." } = useParams();
28
14
  const [searchParams, setSearchParams] = useSearchParams();
29
- const filePath = `${path}/SLIDES.mdx`
30
- const { file } = useDirectory(filePath)
31
- const { content, loading, error } = useFileContent(filePath);
32
- const slides = content ? parseSlideContent(content) : [];
15
+
16
+ // Load the compiled MDX module
17
+ const { Content, frontmatter, loading, error } = useMDXSlides(path);
18
+
19
+ // Split the MDX content into slides by <hr> elements
20
+ const { slides } = useSlidesFromMDX({ Content, frontmatter });
33
21
 
34
22
  // Total slides = 1 (title) + content slides
35
23
  const totalSlides = slides.length + 1;
@@ -109,15 +97,13 @@ export function SlidesPage() {
109
97
  }, [slides.length, setSearchParams]);
110
98
 
111
99
  if (loading) {
112
- return (
113
- <Loading />
114
- )
100
+ return <Loading />
115
101
  }
116
102
 
117
103
  if (error) {
118
104
  return (
119
105
  <main className="min-h-screen bg-background container mx-auto max-w-4xl py-12">
120
- <p className="text-center text-red-600">{error}</p>
106
+ <p className="text-center text-red-600">{error.message}</p>
121
107
  </main>
122
108
  )
123
109
  }
@@ -132,7 +118,7 @@ export function SlidesPage() {
132
118
 
133
119
  return (
134
120
  <main className="slides-container">
135
- <title>{file?.frontmatter?.title}</title>
121
+ <title>{frontmatter?.title}</title>
136
122
  <RunningBar />
137
123
  <Header
138
124
  slideControls={{
@@ -143,26 +129,27 @@ export function SlidesPage() {
143
129
  }}
144
130
  />
145
131
  <div {...{[FULLSCREEN_DATA_ATTR]: "true"}}>
132
+ {/* Title slide */}
146
133
  <div
147
134
  ref={(el) => { slideRefs.current[0] = el; }}
148
135
  className="slide-page max-w-xl min-h-[50vh] sm:min-h-[70vh] md:min-h-screen flex items-center justify-center py-8 sm:py-12 md:py-16 px-4 mx-auto"
149
136
  >
150
- {file && (
151
- <FrontMatter
152
- title={file.frontmatter?.title}
153
- date={file.frontmatter?.date}
154
- description={file.frontmatter?.description}
155
- />
156
- )}
137
+ <FrontMatter
138
+ title={frontmatter?.title}
139
+ date={frontmatter?.date}
140
+ description={frontmatter?.description}
141
+ />
157
142
  </div>
158
143
  <hr className="print:hidden" />
159
- {slides.map((content, index) => (
144
+
145
+ {/* Content slides */}
146
+ {slides.map((slideContent, index) => (
160
147
  <div key={index}>
161
148
  <div
162
149
  ref={(el) => { slideRefs.current[index + 1] = el; }}
163
150
  className="slide-page min-h-[50vh] sm:min-h-[70vh] md:min-h-screen flex items-center justify-center py-8 sm:py-12 md:py-16 px-4 mx-auto"
164
151
  >
165
- {content && <RuntimeMDX content={content} size="md" />}
152
+ <SlideContent>{slideContent}</SlideContent>
166
153
  </div>
167
154
  {index < slides.length - 1 && <hr className="print:hidden" />}
168
155
  </div>
@@ -0,0 +1,21 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module 'virtual:content-modules' {
4
+ import type { ComponentType } from 'react'
5
+
6
+ interface MDXModule {
7
+ default: ComponentType<{ components?: Record<string, ComponentType> }>
8
+ frontmatter?: {
9
+ title?: string
10
+ description?: string
11
+ date?: string
12
+ visibility?: string
13
+ }
14
+ }
15
+
16
+ type ModuleLoader = () => Promise<MDXModule>
17
+
18
+ export const modules: Record<string, ModuleLoader>
19
+ export const slides: Record<string, ModuleLoader>
20
+ export const index: Record<string, { default: unknown }>
21
+ }
package/vite.config.ts CHANGED
@@ -57,10 +57,10 @@ export default defineConfig({
57
57
  },
58
58
  build: {
59
59
  chunkSizeWarningLimit: 1500,
60
+ reportCompressedSize: false,
60
61
  },
61
62
  optimizeDeps: {
62
63
  entries: [path.join(__dirname, 'src/main.tsx')],
63
- // Include all CommonJS dependencies that need ESM conversion
64
64
  include: [
65
65
  'react',
66
66
  'react-dom',
@@ -68,25 +68,7 @@ export default defineConfig({
68
68
  'react/jsx-runtime',
69
69
  'react/jsx-dev-runtime',
70
70
  '@mdx-js/react',
71
- '@mdx-js/mdx',
72
71
  'react-router-dom',
73
- 'acorn-jsx',
74
- 'acorn',
75
- 'estree-util-to-js',
76
- 'recma-jsx',
77
- 'recma-parse',
78
- 'recma-stringify',
79
- 'micromark-extension-mdxjs',
80
- 'style-to-js',
81
- 'style-to-object',
82
- 'debug',
83
- 'unified',
84
- 'extend',
85
- 'bail',
86
- 'trough',
87
- 'vfile',
88
- 'format',
89
- 'fault',
90
72
  ],
91
73
  },
92
74
  })