jamdesk 1.1.92 → 1.1.93
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.
package/dist/lib/deps.js
CHANGED
|
@@ -58,7 +58,7 @@ export const REQUIRED_DEPS = {
|
|
|
58
58
|
'remark-math': '^6.0.0',
|
|
59
59
|
'remark-smartypants': '^3.0.2',
|
|
60
60
|
// Math/LaTeX rendering
|
|
61
|
-
'katex': '^0.16.
|
|
61
|
+
'katex': '^0.16.46',
|
|
62
62
|
// Diagrams
|
|
63
63
|
'mermaid': '^11.14.0',
|
|
64
64
|
// YAML parsing (for OpenAPI specs)
|
|
@@ -88,7 +88,7 @@ export const REQUIRED_DEPS = {
|
|
|
88
88
|
'@upstash/redis': '^1.37.0',
|
|
89
89
|
// TypeScript (needed for Next.js to avoid auto-install breaking symlink)
|
|
90
90
|
'typescript': '^6.0.3',
|
|
91
|
-
'@types/node': '^25.
|
|
91
|
+
'@types/node': '^25.8.0',
|
|
92
92
|
'@types/react': '^19.2.14',
|
|
93
93
|
'@types/react-dom': '^19.0.0',
|
|
94
94
|
'@next/third-parties': '^16.2.6',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jamdesk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.93",
|
|
4
4
|
"description": "CLI for Jamdesk — build, preview, and deploy documentation sites from MDX. Dev server with hot reload, 50+ components, OpenAPI support, AI search, and Mintlify migration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jamdesk",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@mdx-js/mdx": "^3.1.1",
|
|
122
122
|
"@types/fs-extra": "^11.0.0",
|
|
123
|
-
"@types/node": "^25.
|
|
123
|
+
"@types/node": "^25.8.0",
|
|
124
124
|
"typescript": "^6.0.2",
|
|
125
125
|
"vitest": "^4.1.5"
|
|
126
126
|
},
|
|
@@ -1,8 +1,65 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import mermaid from 'mermaid';
|
|
5
5
|
|
|
6
|
+
mermaid.initialize({
|
|
7
|
+
startOnLoad: false,
|
|
8
|
+
theme: 'neutral', // Works well with both light and dark modes
|
|
9
|
+
securityLevel: 'strict', // Sanitizes SVG output to prevent XSS
|
|
10
|
+
gitGraph: {
|
|
11
|
+
mainBranchName: 'main',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const CACHE_KEY_PREFIX = 'mermaid:v1:';
|
|
16
|
+
|
|
17
|
+
// djb2; collisions are theoretically possible but the input space is tiny for a docs site.
|
|
18
|
+
export function hashDiagram(source: string): string {
|
|
19
|
+
let h = 5381;
|
|
20
|
+
for (let i = 0; i < source.length; i++) {
|
|
21
|
+
h = ((h << 5) + h) ^ source.charCodeAt(i);
|
|
22
|
+
}
|
|
23
|
+
return (h >>> 0).toString(36);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CachedDiagram {
|
|
27
|
+
svg: string;
|
|
28
|
+
height: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function readCache(source: string): CachedDiagram | null {
|
|
32
|
+
try {
|
|
33
|
+
const raw = sessionStorage.getItem(CACHE_KEY_PREFIX + hashDiagram(source));
|
|
34
|
+
if (!raw) return null;
|
|
35
|
+
const parsed = JSON.parse(raw) as Partial<CachedDiagram>;
|
|
36
|
+
if (typeof parsed?.svg !== 'string') return null;
|
|
37
|
+
// Normalize the shape so the return honestly matches CachedDiagram:
|
|
38
|
+
// legacy v1 entries predate height tracking, and a tampered/foreign
|
|
39
|
+
// entry could carry a non-numeric height. Coerce both to a number.
|
|
40
|
+
return {
|
|
41
|
+
svg: parsed.svg,
|
|
42
|
+
height: typeof parsed.height === 'number' ? parsed.height : 0,
|
|
43
|
+
};
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function writeCache(source: string, entry: CachedDiagram): void {
|
|
50
|
+
try {
|
|
51
|
+
sessionStorage.setItem(CACHE_KEY_PREFIX + hashDiagram(source), JSON.stringify(entry));
|
|
52
|
+
} catch {}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Mermaid always emits a `height` attribute on the root <svg>. Reading it
|
|
56
|
+
// from the markup (rather than getBoundingClientRect) works in jsdom and
|
|
57
|
+
// avoids a forced reflow on the production hot path.
|
|
58
|
+
export function readSvgHeight(svgMarkup: string): number {
|
|
59
|
+
const match = svgMarkup.match(/<svg\b[^>]*\bheight=["']([\d.]+)(?:px)?["']/i);
|
|
60
|
+
return match ? parseFloat(match[1]) : 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
6
63
|
interface MermaidInnerProps {
|
|
7
64
|
children: string;
|
|
8
65
|
className?: string;
|
|
@@ -10,7 +67,6 @@ interface MermaidInnerProps {
|
|
|
10
67
|
minWidth?: string;
|
|
11
68
|
}
|
|
12
69
|
|
|
13
|
-
// Color palette for theming diagram elements
|
|
14
70
|
interface ColorPalette {
|
|
15
71
|
text: string;
|
|
16
72
|
line: string;
|
|
@@ -232,40 +288,70 @@ function applyLightModeCleanup(svgEl: SVGElement): void {
|
|
|
232
288
|
*/
|
|
233
289
|
export function MermaidInner({ children, className, minWidth }: MermaidInnerProps) {
|
|
234
290
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
235
|
-
const [svg, setSvg] = useState<string>(
|
|
291
|
+
const [svg, setSvg] = useState<string>(() => {
|
|
292
|
+
if (typeof window === 'undefined') return '';
|
|
293
|
+
return readCache(children)?.svg ?? '';
|
|
294
|
+
});
|
|
236
295
|
const [error, setError] = useState<string | null>(null);
|
|
237
296
|
|
|
297
|
+
// Reserves space so the skeleton → SVG swap doesn't shift layout below it.
|
|
298
|
+
// Derived from svg (not separate state) so it can't desync. The regex is
|
|
299
|
+
// cheap (small string, no backtracking).
|
|
300
|
+
const minHeightPx = useMemo(() => (svg ? readSvgHeight(svg) : 0), [svg]);
|
|
301
|
+
|
|
238
302
|
useEffect(() => {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
303
|
+
let cancelled = false;
|
|
304
|
+
|
|
305
|
+
const cached = readCache(children);
|
|
306
|
+
if (cached) {
|
|
307
|
+
// Already hydrated from cache via useState initializer on first mount;
|
|
308
|
+
// on subsequent `children` changes, sync state to the cached value.
|
|
309
|
+
setSvg(cached.svg);
|
|
310
|
+
setError(null);
|
|
311
|
+
// Synchronous path: no async work to cancel, so no cleanup needed.
|
|
312
|
+
// StrictMode re-invokes this effect, but both setters are idempotent
|
|
313
|
+
// (state already equals these values), so the repeat is a no-op.
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Cache miss — clear previous diagram so user sees skeleton/empty
|
|
318
|
+
// while the new render is in flight, not stale styled markup.
|
|
319
|
+
setSvg('');
|
|
320
|
+
setError(null);
|
|
247
321
|
|
|
248
322
|
const renderDiagram = async () => {
|
|
249
323
|
try {
|
|
250
324
|
if (!children || typeof children !== 'string') {
|
|
251
|
-
setError('Invalid diagram content');
|
|
325
|
+
if (!cancelled) setError('Invalid diagram content');
|
|
252
326
|
return;
|
|
253
327
|
}
|
|
254
328
|
// Generate unique ID for each render to avoid conflicts with React StrictMode
|
|
255
329
|
const uniqueId = `mermaid-${Math.random().toString(36).substring(2, 11)}`;
|
|
256
330
|
const { svg: renderedSvg } = await mermaid.render(uniqueId, children.trim());
|
|
331
|
+
// writeCache runs UNGATED — the entry is keyed by source string and is
|
|
332
|
+
// correct regardless of which `children` the component currently displays.
|
|
333
|
+
writeCache(children, { svg: renderedSvg, height: readSvgHeight(renderedSvg) });
|
|
334
|
+
if (cancelled) return;
|
|
257
335
|
setSvg(renderedSvg);
|
|
258
336
|
setError(null);
|
|
259
337
|
} catch (err) {
|
|
260
|
-
|
|
338
|
+
if (!cancelled) {
|
|
339
|
+
setError(err instanceof Error ? err.message : 'Failed to render diagram');
|
|
340
|
+
}
|
|
261
341
|
}
|
|
262
342
|
};
|
|
263
343
|
|
|
264
344
|
renderDiagram();
|
|
345
|
+
|
|
346
|
+
return () => {
|
|
347
|
+
cancelled = true;
|
|
348
|
+
};
|
|
265
349
|
}, [children]);
|
|
266
350
|
|
|
267
|
-
// Apply styles to SVG after
|
|
268
|
-
useEffect
|
|
351
|
+
// Apply styles to SVG after commit, before paint, for dark mode compatibility.
|
|
352
|
+
// useLayoutEffect — not useEffect — so the theme palette is applied in the same
|
|
353
|
+
// visual frame as the SVG markup, eliminating an unstyled-SVG flash.
|
|
354
|
+
useLayoutEffect(() => {
|
|
269
355
|
if (!containerRef.current) return;
|
|
270
356
|
|
|
271
357
|
const svgEl = containerRef.current.querySelector('svg');
|
|
@@ -298,7 +384,7 @@ export function MermaidInner({ children, className, minWidth }: MermaidInnerProp
|
|
|
298
384
|
applyLightModeStyles();
|
|
299
385
|
}
|
|
300
386
|
|
|
301
|
-
//
|
|
387
|
+
// CSS hook for global mermaid styling.
|
|
302
388
|
svgEl.classList.add('mermaid-svg');
|
|
303
389
|
|
|
304
390
|
// Watch for dark mode changes
|
|
@@ -336,6 +422,7 @@ export function MermaidInner({ children, className, minWidth }: MermaidInnerProp
|
|
|
336
422
|
<div
|
|
337
423
|
ref={containerRef}
|
|
338
424
|
className={`mermaid-container my-6 flex justify-center overflow-x-auto ${className || ''}`}
|
|
425
|
+
style={minHeightPx ? { minHeight: `${minHeightPx}px` } : undefined}
|
|
339
426
|
dangerouslySetInnerHTML={{ __html: svg }}
|
|
340
427
|
/>
|
|
341
428
|
);
|
|
@@ -93,14 +93,14 @@ export function generateSitemap(options: SitemapOptions): string {
|
|
|
93
93
|
hreflangLinks = Object.entries(alternates)
|
|
94
94
|
.map(
|
|
95
95
|
([tag, href]) =>
|
|
96
|
-
`\n <xhtml:link rel="alternate" hreflang="${tag}" href="${href}"/>`,
|
|
96
|
+
`\n <xhtml:link rel="alternate" hreflang="${escapeXml(tag)}" href="${escapeXml(href)}"/>`,
|
|
97
97
|
)
|
|
98
98
|
.join('');
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
return ` <url>
|
|
103
|
-
<loc>${url}</loc>
|
|
103
|
+
<loc>${escapeXml(url)}</loc>
|
|
104
104
|
<lastmod>${lastmod}</lastmod>
|
|
105
105
|
<changefreq>weekly</changefreq>
|
|
106
106
|
<priority>${priority}</priority>${hreflangLinks}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@shikijs/transformers": "^4.0.1",
|
|
23
23
|
"@tailwindcss/postcss": "^4.2.4",
|
|
24
24
|
"@tailwindcss/typography": "^0.5.10",
|
|
25
|
-
"@types/node": "^25.
|
|
25
|
+
"@types/node": "^25.8.0",
|
|
26
26
|
"@types/react": "^19.2.14",
|
|
27
27
|
"@types/react-dom": "^19.0.0",
|
|
28
28
|
"@upstash/redis": "^1.37.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"gray-matter": "^4.0.3",
|
|
38
38
|
"js-yaml": "^4.1.1",
|
|
39
39
|
"json5": "^2.2.3",
|
|
40
|
-
"katex": "^0.16.
|
|
40
|
+
"katex": "^0.16.46",
|
|
41
41
|
"lucide-react": "^0.562.0",
|
|
42
42
|
"mermaid": "^11.14.0",
|
|
43
43
|
"next": "^16.2.6",
|
|
@@ -2134,9 +2134,9 @@
|
|
|
2134
2134
|
}
|
|
2135
2135
|
},
|
|
2136
2136
|
"node_modules/baseline-browser-mapping": {
|
|
2137
|
-
"version": "2.10.
|
|
2138
|
-
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.
|
|
2139
|
-
"integrity": "sha512-
|
|
2137
|
+
"version": "2.10.30",
|
|
2138
|
+
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.30.tgz",
|
|
2139
|
+
"integrity": "sha512-xjOFN16Ha1+Rz4nFYKqHU/LSB+gx/Vi3yQLX7r7sAW+Wa+8hhF2h4pvqTrTMc8+WcDBEunnUurr46Jvv0jk3Vg==",
|
|
2140
2140
|
"license": "Apache-2.0",
|
|
2141
2141
|
"bin": {
|
|
2142
2142
|
"baseline-browser-mapping": "dist/cli.cjs"
|
|
@@ -2197,9 +2197,9 @@
|
|
|
2197
2197
|
"license": "MIT"
|
|
2198
2198
|
},
|
|
2199
2199
|
"node_modules/caniuse-lite": {
|
|
2200
|
-
"version": "1.0.
|
|
2201
|
-
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.
|
|
2202
|
-
"integrity": "sha512-
|
|
2200
|
+
"version": "1.0.30001793",
|
|
2201
|
+
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001793.tgz",
|
|
2202
|
+
"integrity": "sha512-iwSsYWaCOoh26cV8NwNRViHlrfUvYsHDfRVcbtmw0Kg6PJIZZXwMkj1442FYLBGkeUf1juAsU3DTfxW579mrPA==",
|
|
2203
2203
|
"funding": [
|
|
2204
2204
|
{
|
|
2205
2205
|
"type": "opencollective",
|
|
@@ -2913,9 +2913,9 @@
|
|
|
2913
2913
|
}
|
|
2914
2914
|
},
|
|
2915
2915
|
"node_modules/dompurify": {
|
|
2916
|
-
"version": "3.4.
|
|
2917
|
-
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.
|
|
2918
|
-
"integrity": "sha512-
|
|
2916
|
+
"version": "3.4.4",
|
|
2917
|
+
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.4.tgz",
|
|
2918
|
+
"integrity": "sha512-r8K7KGKEcztXfA/nfabSYB2hg9tDphORJTdf8xprN/luSLGmNhOBN8dm1/SYjqLLet6YUFEXOcrdTuwryp/Bew==",
|
|
2919
2919
|
"license": "(MPL-2.0 OR Apache-2.0)",
|
|
2920
2920
|
"optionalDependencies": {
|
|
2921
2921
|
"@types/trusted-types": "^2.0.7"
|
|
@@ -2928,9 +2928,9 @@
|
|
|
2928
2928
|
"license": "MIT"
|
|
2929
2929
|
},
|
|
2930
2930
|
"node_modules/electron-to-chromium": {
|
|
2931
|
-
"version": "1.5.
|
|
2932
|
-
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.
|
|
2933
|
-
"integrity": "sha512-
|
|
2931
|
+
"version": "1.5.357",
|
|
2932
|
+
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.357.tgz",
|
|
2933
|
+
"integrity": "sha512-NHlTIQDK8fmVwHwuIzmXYEJ1Ewq3D9wDNc0cWXxDGysP6Pb21giwGNkxiTifyKy/4SoPuN5l6GLP1W9Sv7zB2g==",
|
|
2934
2934
|
"license": "ISC"
|
|
2935
2935
|
},
|
|
2936
2936
|
"node_modules/enhanced-resolve": {
|
|
@@ -3739,9 +3739,9 @@
|
|
|
3739
3739
|
}
|
|
3740
3740
|
},
|
|
3741
3741
|
"node_modules/katex": {
|
|
3742
|
-
"version": "0.16.
|
|
3743
|
-
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.
|
|
3744
|
-
"integrity": "sha512-
|
|
3742
|
+
"version": "0.16.47",
|
|
3743
|
+
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.47.tgz",
|
|
3744
|
+
"integrity": "sha512-Eeo8Ys1doU1z+x8AZsPpQu+p/QcZBI5PeOo7QGQdy2x2m0MU/hYagBbGOmXwr5KVbEfVuWv9LpnQWeehogurjg==",
|
|
3745
3745
|
"funding": [
|
|
3746
3746
|
"https://opencollective.com/katex",
|
|
3747
3747
|
"https://github.com/sponsors/katex"
|