@docubook/flame 1.7.2 → 2.0.0-alpha.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 (67) hide show
  1. package/.docu/components/Context.tsx +1 -1
  2. package/.docu/components/Pagination.tsx +9 -1
  3. package/.docu/components/Search.tsx +6 -6
  4. package/.docu/components/Sidebar.tsx +37 -8
  5. package/.docu/components/Theme.tsx +2 -2
  6. package/.docu/components/Toc.tsx +52 -6
  7. package/.docu/components/Typography.tsx +1 -1
  8. package/.docu/components/home/Hero.tsx +4 -4
  9. package/.docu/components/registry.ts +1 -1
  10. package/.docu/lib/build.deno.js +3 -3
  11. package/.docu/lib/{build.impl-TSIF3F7O.js → build.impl-VXB4KL4D.js} +3 -3
  12. package/.docu/lib/build.node.js +3 -3
  13. package/.docu/lib/{chunk-SPHVBXRR.js → chunk-7PRQ3RQB.js} +6 -6
  14. package/.docu/lib/{chunk-DITXUPUV.js → chunk-A6FIEG3H.js} +61 -10
  15. package/.docu/lib/{chunk-PJIJEPNR.js → chunk-JRERMREW.js} +5 -4
  16. package/.docu/lib/{chunk-KMDGSD57.js → chunk-LZDEWK25.js} +3 -3
  17. package/.docu/lib/{chunk-HRO7ONJQ.js → chunk-MQWWCO6O.js} +70 -27
  18. package/.docu/lib/{chunk-B6LGUADD.js → chunk-TRT6WQZG.js} +346 -183
  19. package/.docu/lib/chunk-UISOJ4RW.js +114 -0
  20. package/.docu/lib/clean.js +1 -1
  21. package/.docu/lib/deploy.deno.js +1 -1
  22. package/.docu/lib/deploy.node.js +1 -1
  23. package/.docu/lib/preview.deno.js +5 -3
  24. package/.docu/lib/preview.node.js +5 -3
  25. package/.docu/lib/server.deno.js +6 -4
  26. package/.docu/lib/server.node.js +6 -4
  27. package/.docu/node/build.impl.ts +75 -26
  28. package/.docu/node/build.ts +70 -17
  29. package/.docu/node/client.ts +64 -27
  30. package/.docu/node/deploy.shared.ts +5 -5
  31. package/.docu/node/deploy.ts +1 -1
  32. package/.docu/node/html.shared.ts +7 -2
  33. package/.docu/node/html.ts +4 -2
  34. package/.docu/node/hydrate.node.ts +69 -4
  35. package/.docu/node/hydrate.ts +50 -1
  36. package/.docu/node/mdx-manifest.d.ts +5 -0
  37. package/.docu/node/mdx.ts +103 -17
  38. package/.docu/node/preview.deno.ts +1 -1
  39. package/.docu/node/preview.impl.ts +3 -3
  40. package/.docu/node/preview.node.ts +1 -1
  41. package/.docu/node/preview.ts +2 -2
  42. package/.docu/node/route.ts +57 -1
  43. package/.docu/node/runtime/bun.ts +28 -0
  44. package/.docu/node/runtime/deno.ts +34 -0
  45. package/.docu/node/runtime/index.ts +4 -0
  46. package/.docu/node/runtime/node.ts +107 -0
  47. package/.docu/node/runtime/types.ts +19 -0
  48. package/.docu/node/search-indexer.ts +3 -2
  49. package/.docu/node/seo.ts +2 -2
  50. package/.docu/node/server-routes.ts +32 -13
  51. package/.docu/node/server.deno.ts +1 -1
  52. package/.docu/node/server.impl.ts +49 -3
  53. package/.docu/node/server.node.ts +1 -1
  54. package/.docu/node/server.ts +45 -1
  55. package/.docu/pages/docs/[[...slug]].tsx +13 -4
  56. package/.docu/pages/index.tsx +1 -1
  57. package/.docu/styles/globals.css +38 -20
  58. package/README.md +7 -48
  59. package/bin/cli.js +25 -7
  60. package/package.json +7 -6
  61. package/template/README.md +7 -48
  62. package/template/docs/getting-started/configuration.mdx +16 -4
  63. package/template/docs/getting-started/overview.mdx +34 -42
  64. package/template/docs/guide/components.mdx +46 -228
  65. package/template/docs/guide/routing.mdx +8 -6
  66. package/template/docs/index.mdx +9 -8
  67. package/template/docu.json +4 -4
@@ -7,13 +7,15 @@ import {
7
7
  buildClientBundle,
8
8
  captureException,
9
9
  compileMdx,
10
+ compileMdxModule,
10
11
  computeInlineThemeCss,
12
+ frontmatterField,
11
13
  generateSearchIndex,
12
14
  getGitLastModifiedBatch,
13
15
  htmlShell,
14
16
  initSentry,
15
17
  loadPlugins
16
- } from "./chunk-B6LGUADD.js";
18
+ } from "./chunk-TRT6WQZG.js";
17
19
  import {
18
20
  cspHeader,
19
21
  generateNonce,
@@ -21,7 +23,7 @@ import {
21
23
  } from "./chunk-EOK6KATZ.js";
22
24
  import {
23
25
  logger
24
- } from "./chunk-PJIJEPNR.js";
26
+ } from "./chunk-JRERMREW.js";
25
27
  import {
26
28
  ASSETS_DIR,
27
29
  CACHE_FILE,
@@ -48,7 +50,7 @@ function buildSeoMeta(config, frontmatter, slug) {
48
50
  url,
49
51
  siteName: config.meta?.title || ""
50
52
  };
51
- const image = typeof frontmatter.image === "string" && frontmatter.image || config.meta?.ogImage;
53
+ const image = frontmatterField(frontmatter, "image") || config.meta?.ogImage;
52
54
  if (image) {
53
55
  try {
54
56
  result.image = new URL(image, image.startsWith("/") ? baseURL : `${baseURL}/docs/`).href;
@@ -121,8 +123,8 @@ ${msg}`, { cause: err });
121
123
  content
122
124
  });
123
125
  }
124
- const title = (typeof frontmatter.title === "string" ? frontmatter.title : "") || slug || "Docs";
125
- const description = typeof frontmatter.description === "string" ? frontmatter.description : "";
126
+ const title = frontmatterField(frontmatter, "title") || slug || "Docs";
127
+ const description = frontmatterField(frontmatter, "description");
126
128
  const slugParts = slug ? slug.split("/") : [];
127
129
  const page = React.createElement(
128
130
  DocsLayout,
@@ -131,12 +133,15 @@ ${msg}`, { cause: err });
131
133
  slug: slugParts,
132
134
  title,
133
135
  description,
134
- date: frontmatter.date || void 0,
135
- content: result.content,
136
+ date: frontmatterField(frontmatter, "date") || void 0,
137
+ // Render MDX content as its own root: client hydrates the island as a
138
+ // separate root, so SSR must be root-relative too or useId-based ids
139
+ // (mdx-compiler components) mismatch during hydration.
140
+ content: renderToString(result.content),
136
141
  tocs: result.tocs,
137
142
  filePath,
138
143
  repoUrl: docuConfig.repo?.url,
139
- compiledSource: result.compiledSource
144
+ mdxSlug: slug
140
145
  })
141
146
  );
142
147
  const body = renderToString(page);
@@ -146,7 +151,7 @@ ${msg}`, { cause: err });
146
151
  const depth = slug ? slug.split("/").length : 1;
147
152
  const favicon = docuConfig.meta?.favicon || "/docs/assets/images/favicon.ico";
148
153
  const seo = buildSeoMeta(docuConfig, frontmatter, slug || "");
149
- const csp = cspHeader(nonce, true);
154
+ const csp = cspHeader(nonce);
150
155
  let html = htmlShell({
151
156
  title,
152
157
  description,
@@ -200,9 +205,55 @@ async function runBuild() {
200
205
  const cache = args.force ? {} : await readCache();
201
206
  let built = 0;
202
207
  let skipped = 0;
208
+ const pluginsConfig = docuConfig.plugins ?? [];
209
+ const builder = pluginsConfig.length > 0 ? new BuildPluginBuilder(docuConfig) : null;
210
+ if (builder) {
211
+ const plugins = await loadPlugins(pluginsConfig);
212
+ for (const plugin of plugins) {
213
+ await plugin.setup(builder);
214
+ }
215
+ await builder.runOnStart();
216
+ }
217
+ const mdxSources = {};
218
+ const prePassTasks = mdxFiles.map(async (file) => {
219
+ let raw;
220
+ try {
221
+ raw = await readFile(file.absPath, "utf-8");
222
+ } catch {
223
+ return;
224
+ }
225
+ let content = raw;
226
+ if (builder) {
227
+ const relPath = file.absPath.replace(PROJECT_ROOT + "/", "");
228
+ const transformed = await builder.runOnLoad(relPath, content);
229
+ if (transformed?.contents) content = transformed.contents;
230
+ }
231
+ const remarkPlugins = builder?.collectRemarkPlugins();
232
+ const rehypePlugins = builder?.collectRehypePlugins();
233
+ mdxSources[file.path] = await compileMdxModule(content, remarkPlugins, rehypePlugins);
234
+ });
235
+ await Promise.all(prePassTasks);
236
+ const indexMdxPath = join(DOCS_DIR, "index.mdx");
237
+ if (existsSync(indexMdxPath)) {
238
+ try {
239
+ const indexRaw = await readFile(indexMdxPath, "utf-8");
240
+ let indexContent = indexRaw;
241
+ if (builder) {
242
+ const relPath = indexMdxPath.replace(PROJECT_ROOT + "/", "");
243
+ const transformed = await builder.runOnLoad(relPath, indexContent);
244
+ if (transformed?.contents) indexContent = transformed.contents;
245
+ }
246
+ mdxSources[""] = await compileMdxModule(
247
+ indexContent,
248
+ builder?.collectRemarkPlugins(),
249
+ builder?.collectRehypePlugins()
250
+ );
251
+ } catch {
252
+ }
253
+ }
203
254
  logger.bundleStart();
204
255
  let t = performance.now();
205
- assetManifest = await buildClientBundle();
256
+ assetManifest = await buildClientBundle(mdxSources);
206
257
  logger.bundleDone(Math.round(performance.now() - t));
207
258
  inlineThemeCss = computeInlineThemeCss();
208
259
  const lastManifest = cache["__assets__"];
@@ -214,15 +265,6 @@ async function runBuild() {
214
265
  builtAt: Date.now()
215
266
  };
216
267
  }
217
- const pluginsConfig = docuConfig.plugins ?? [];
218
- const builder = pluginsConfig.length > 0 ? new BuildPluginBuilder(docuConfig) : null;
219
- if (builder) {
220
- const plugins = await loadPlugins(pluginsConfig);
221
- for (const plugin of plugins) {
222
- await plugin.setup(builder);
223
- }
224
- await builder.runOnStart();
225
- }
226
268
  logger.spinner.start("Building pages...");
227
269
  t = performance.now();
228
270
  const allRelPaths = mdxFiles.map((f) => f.absPath.replace(PROJECT_ROOT + "/", ""));
@@ -301,9 +343,9 @@ async function runBuild() {
301
343
  await Promise.all(buildTasks.slice(i, i + CONCURRENCY).map((fn) => fn()));
302
344
  }
303
345
  try {
304
- const indexMdxPath = join(DOCS_DIR, "index.mdx");
305
- const indexRaw = await readFile(indexMdxPath, "utf-8");
306
- const indexRelPath = indexMdxPath.replace(PROJECT_ROOT + "/", "");
346
+ const indexMdxPath2 = join(DOCS_DIR, "index.mdx");
347
+ const indexRaw = await readFile(indexMdxPath2, "utf-8");
348
+ const indexRelPath = indexMdxPath2.replace(PROJECT_ROOT + "/", "");
307
349
  const indexHtml = await renderDocsPage(
308
350
  docuConfig,
309
351
  "",
@@ -332,8 +374,7 @@ async function runBuild() {
332
374
  body: renderToString(landingPage),
333
375
  favicon: landingFavicon,
334
376
  seo: landingSeo,
335
- /** unsafe-eval required by mdx-remote hydration — see above. */
336
- csp: cspHeader(landingNonce, true),
377
+ csp: cspHeader(landingNonce),
337
378
  css: assetManifest.css,
338
379
  js: assetManifest.js,
339
380
  nonce: landingNonce,
@@ -353,12 +394,14 @@ async function runBuild() {
353
394
  body: renderToString(notFoundPage),
354
395
  favicon: notFoundFavicon,
355
396
  headExtra: ['<meta name="robots" content="noindex,follow">'],
356
- /** unsafe-eval required by mdx-remote hydration — see above. */
357
- csp: cspHeader(notFoundNonce, true),
397
+ csp: cspHeader(notFoundNonce),
358
398
  css: assetManifest.css,
359
399
  js: assetManifest.js,
360
400
  nonce: notFoundNonce,
361
- themeCss: inlineThemeCss
401
+ themeCss: inlineThemeCss,
402
+ // Served as the static-host fallback at ANY requested path — relative
403
+ // depth can never be right there, so use root-absolute asset URLs.
404
+ absoluteAssets: true
362
405
  });
363
406
  await writeFile(join(DIST_DIR, "404.html"), notFoundHtml);
364
407
  logger.spinner.stop(