@writedocs/generator 0.10.12 → 0.10.14

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/astro.config.mjs CHANGED
@@ -508,6 +508,16 @@ export default defineConfig({
508
508
  // mintlifyReactHooksPlugin() does for a site's .jsx/.tsx snippets what
509
509
  // remarkMintlifyReactHooks does for its MDX pages.
510
510
  plugins: [contentTailwindSource(), tailwindcss(), mintlifyReactHooksPlugin(contentDir)],
511
+ // `writedocs dev`: Vite only prepares for the browser the dependencies
512
+ // it finds by scanning the project's own source - and when writedocs is
513
+ // installed, its source sits in node_modules, which the scan skips. The
514
+ // page script's `import("mermaid")` ([...slug].astro) was then served
515
+ // as it is, and its CommonJS dependencies failed in the browser ("dayjs
516
+ // ... does not provide an export named 'default'"): diagrams stayed as
517
+ // text in dev, while builds were fine. Naming it here prepares it always.
518
+ optimizeDeps: {
519
+ include: ['mermaid'],
520
+ },
511
521
  resolve: {
512
522
  alias: [
513
523
  // Lets a page's MDX write `import Foo from '/snippets/foo.mdx'`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@writedocs/generator",
3
- "version": "0.10.12",
3
+ "version": "0.10.14",
4
4
  "description": "Static site generator for docs — a writedocs.json + MDX folder in, a static site out.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,40 +48,40 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@apidevtools/swagger-parser": "^12.1.0",
51
+ "@apidevtools/swagger-parser": "12.1.0",
52
52
  "@astrojs/markdown-remark": "7.2.4",
53
- "@astrojs/mdx": "^7.0.5",
54
- "@astrojs/react": "^6.0.2",
55
- "@astrojs/sitemap": "^3.7.3",
56
- "@iconify-json/bi": "^1.2.7",
57
- "@iconify-json/fa6-brands": "^1.2.6",
58
- "@iconify-json/fa6-solid": "^1.2.4",
59
- "@iconify-json/heroicons": "^1.2.3",
60
- "@iconify-json/ion": "^1.2.7",
61
- "@iconify-json/lucide": "^1.2.116",
62
- "@iconify-json/mdi": "^1.2.3",
63
- "@iconify-json/ri": "^1.2.10",
64
- "@iconify-json/simple-icons": "^1.2.89",
65
- "@iconify-json/tabler": "^1.2.35",
66
- "@mdx-js/mdx": "^3.1.1",
67
- "@shikijs/transformers": "^4.3.1",
68
- "@tailwindcss/vite": "^4.3.2",
53
+ "@astrojs/mdx": "7.0.8",
54
+ "@astrojs/react": "6.0.2",
55
+ "@astrojs/sitemap": "3.7.3",
56
+ "@iconify-json/bi": "1.2.7",
57
+ "@iconify-json/fa6-brands": "1.2.6",
58
+ "@iconify-json/fa6-solid": "1.2.4",
59
+ "@iconify-json/heroicons": "1.2.3",
60
+ "@iconify-json/ion": "1.2.7",
61
+ "@iconify-json/lucide": "1.2.123",
62
+ "@iconify-json/mdi": "1.2.3",
63
+ "@iconify-json/ri": "1.2.10",
64
+ "@iconify-json/simple-icons": "1.2.93",
65
+ "@iconify-json/tabler": "1.2.38",
66
+ "@mdx-js/mdx": "3.1.1",
67
+ "@shikijs/transformers": "4.4.3",
68
+ "@tailwindcss/vite": "4.3.3",
69
69
  "astro": "7.2.9",
70
- "astro-icon": "^1.1.5",
71
- "commander": "^15.0.0",
72
- "dotenv": "^17.4.2",
73
- "gray-matter": "^4.0.3",
70
+ "astro-icon": "1.1.5",
71
+ "commander": "15.0.0",
72
+ "dotenv": "17.4.2",
73
+ "gray-matter": "4.0.3",
74
74
  "jsonc-parser": "3.3.1",
75
- "katex": "^0.16.47",
76
- "mermaid": "^11.16.0",
77
- "pagefind": "^1.5.2",
78
- "react": "^19.2.8",
79
- "react-dom": "^19.2.8",
80
- "rehype-katex": "^7.0.1",
81
- "remark-math": "^6.0.0",
82
- "shiki": "^4.3.1",
83
- "tailwindcss": "^4.3.2",
84
- "zod": "^4.4.3"
75
+ "katex": "0.16.47",
76
+ "mermaid": "11.16.1",
77
+ "pagefind": "1.5.2",
78
+ "react": "19.2.8",
79
+ "react-dom": "19.2.8",
80
+ "rehype-katex": "7.0.1",
81
+ "remark-math": "6.0.0",
82
+ "shiki": "4.4.3",
83
+ "tailwindcss": "4.3.3",
84
+ "zod": "4.4.3"
85
85
  },
86
86
  "engines": {
87
87
  "node": ">=22.12.0"
@@ -17,6 +17,7 @@
17
17
  // { type: 'fatal', error } - see serializeError()
18
18
  import path from 'node:path';
19
19
  import { build, dev } from 'astro';
20
+ import { exitWhenFlushed } from './exit-when-flushed.js';
20
21
 
21
22
  const command = process.argv[2];
22
23
  const packageRoot = process.env.WRITEDOCS_PACKAGE_ROOT;
@@ -40,11 +41,11 @@ function serializeError(err) {
40
41
  };
41
42
  }
42
43
 
44
+ // Both ways out go through exitWhenFlushed(): the last message and whatever
45
+ // was printed (a page's console.log goes straight to stdout) have left this
46
+ // process before it exits - see exit-when-flushed.js.
43
47
  async function fail(err) {
44
- send({ type: 'fatal', error: serializeError(err) });
45
- // Let the IPC message leave before exiting.
46
- await new Promise((resolve) => setTimeout(resolve, 50));
47
- process.exit(1);
48
+ await exitWhenFlushed(1, { type: 'fatal', error: serializeError(err) });
48
49
  }
49
50
 
50
51
  process.on('uncaughtException', fail);
@@ -67,9 +68,7 @@ try {
67
68
  send({ type: 'ready', urls: server.resolvedUrls ?? { local: [], network: [] } });
68
69
  } else if (command === 'build') {
69
70
  await build(inlineConfig);
70
- send({ type: 'done' });
71
- await new Promise((resolve) => setTimeout(resolve, 50));
72
- process.exit(0);
71
+ await exitWhenFlushed(0, { type: 'done' });
73
72
  } else {
74
73
  throw new Error(`astro-worker: unknown command "${command}"`);
75
74
  }
@@ -0,0 +1,38 @@
1
+ // Leaving a process without losing what it printed. astro-worker.js ends with
2
+ // process.exit() - Astro leaves handles open, so the process wouldn't end by
3
+ // itself - and on a pipe both stdout/stderr and the IPC channel are
4
+ // asynchronous (on Linux): exit() drops whatever is still queued in the
5
+ // process. A fixed wait isn't enough: a page that prints 1 MiB on a busy
6
+ // machine still had most of it queued after 50 ms, and the CLI got the output
7
+ // cut short with the build exiting 0.
8
+ //
9
+ // Plain JavaScript with no Astro import, so scripts/exit-when-flushed.test.js
10
+ // can run it in a child process of its own.
11
+
12
+ /** How long the wait may take. If the CLI stops reading (alive, but stuck),
13
+ * the worker exits anyway instead of hanging. */
14
+ export const MAX_FLUSH_WAIT_MS = 10_000;
15
+
16
+ /** Resolves once everything written to `stream` so far has left the process. */
17
+ function flushed(stream) {
18
+ return new Promise((resolve) => {
19
+ if (!stream.writable || stream.destroyed) return resolve();
20
+ stream.write('', () => resolve());
21
+ });
22
+ }
23
+
24
+ /** Sends `lastMessage` to the parent (when there is one), waits for it and
25
+ * for stdout and stderr to leave the process, then exits with `code` - or
26
+ * after `maxWaitMs`, whichever comes first. */
27
+ export async function exitWhenFlushed(code, lastMessage, { maxWaitMs = MAX_FLUSH_WAIT_MS } = {}) {
28
+ // unref: the timer alone never keeps the process alive.
29
+ const deadline = setTimeout(() => process.exit(code), maxWaitMs);
30
+ deadline.unref();
31
+ await new Promise((resolve) => {
32
+ if (lastMessage !== undefined && typeof process.send === 'function' && process.connected) {
33
+ process.send(lastMessage, () => resolve());
34
+ } else resolve();
35
+ });
36
+ await Promise.all([flushed(process.stdout), flushed(process.stderr)]);
37
+ process.exit(code);
38
+ }
@@ -0,0 +1,12 @@
1
+ This folder is here on purpose, and stays empty of icons.
2
+
3
+ The icon integration (astro-icon) looks for local SVG icons in `src/icons`
4
+ under the project root - which, for writedocs, is this package. Since
5
+ astro-icon 1.2.0, a missing folder prints a warning on every `writedocs dev`
6
+ and `writedocs build`:
7
+
8
+ Failed to load icons from "src/icons": ENOENT: no such file or directory
9
+
10
+ writedocs has no local icons: every icon comes from the installed icon sets
11
+ (see src/lib/icons.js). Don't delete the folder; `scripts/package-files.test.js`
12
+ checks it ships in the npm package.