prev-cli 0.1.6 → 0.1.7

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/cli.js CHANGED
@@ -387,7 +387,10 @@ async function createViteConfig(options) {
387
387
  "@prev/theme": path4.join(srcRoot2, "theme"),
388
388
  react: path4.join(cliNodeModules, "react"),
389
389
  "react-dom": path4.join(cliNodeModules, "react-dom"),
390
- "react-router-dom": path4.join(cliNodeModules, "react-router-dom")
390
+ "react-router-dom": path4.join(cliNodeModules, "react-router-dom"),
391
+ mermaid: path4.join(cliNodeModules, "mermaid"),
392
+ dayjs: path4.join(cliNodeModules, "dayjs"),
393
+ "@terrastruct/d2": path4.join(cliNodeModules, "@terrastruct/d2")
391
394
  }
392
395
  },
393
396
  optimizeDeps: {
@@ -398,7 +401,10 @@ async function createViteConfig(options) {
398
401
  "react-dom/client",
399
402
  "react-router-dom",
400
403
  "react/jsx-runtime",
401
- "react/jsx-dev-runtime"
404
+ "react/jsx-dev-runtime",
405
+ "mermaid",
406
+ "dayjs",
407
+ "@terrastruct/d2"
402
408
  ],
403
409
  exclude: [
404
410
  "clsx",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prev-cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Transform MDX directories into beautiful documentation websites",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,28 +37,33 @@ async function renderD2Diagrams() {
37
37
  const codeBlocks = document.querySelectorAll('code.language-d2, code.hljs.language-d2')
38
38
  if (codeBlocks.length === 0) return
39
39
 
40
- const { D2 } = await import('@terrastruct/d2')
41
- const d2 = new D2()
40
+ try {
41
+ const d2Module = await import('@terrastruct/d2')
42
+ const { D2 } = d2Module
43
+ const d2 = new D2()
42
44
 
43
- for (const block of codeBlocks) {
44
- const pre = block.parentElement as HTMLElement
45
- if (!pre || pre.dataset.rendered) continue
46
- pre.dataset.rendered = 'true'
45
+ for (const block of codeBlocks) {
46
+ const pre = block.parentElement as HTMLElement
47
+ if (!pre || pre.dataset.rendered) continue
48
+ pre.dataset.rendered = 'true'
47
49
 
48
- const code = block.textContent || ''
49
- const container = document.createElement('div')
50
- container.className = 'd2-diagram'
50
+ const code = block.textContent || ''
51
+ const container = document.createElement('div')
52
+ container.className = 'd2-diagram'
51
53
 
52
- try {
53
- const result = await d2.compile(code)
54
- const svg = await d2.render(result.diagram)
55
- container.innerHTML = svg
56
- // Hide original instead of replacing (avoids React DOM conflicts)
57
- pre.style.display = 'none'
58
- pre.insertAdjacentElement('afterend', container)
59
- } catch (e) {
60
- console.error('D2 render error:', e)
54
+ try {
55
+ const result = await d2.compile(code)
56
+ const svg = await d2.render(result.diagram, result.renderOptions)
57
+ container.innerHTML = svg
58
+ // Hide original instead of replacing (avoids React DOM conflicts)
59
+ pre.style.display = 'none'
60
+ pre.insertAdjacentElement('afterend', container)
61
+ } catch (e) {
62
+ console.error('D2 render error:', e)
63
+ }
61
64
  }
65
+ } catch (e) {
66
+ console.error('D2 library load error:', e)
62
67
  }
63
68
  }
64
69