@docubook/flame 2.0.0-beta.0 → 2.0.0-beta.2

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 (54) hide show
  1. package/.docu/components/ScrollTo.tsx +17 -11
  2. package/.docu/components/Toc.tsx +32 -7
  3. package/.docu/lib/build.deno.js +6 -9
  4. package/.docu/lib/build.deno.js.map +1 -0
  5. package/.docu/lib/build.impl-BJsi28mD.js +377 -0
  6. package/.docu/lib/build.impl-BJsi28mD.js.map +1 -0
  7. package/.docu/lib/build.impl-yVLaa1eQ.js +2 -0
  8. package/.docu/lib/build.node.js +6 -9
  9. package/.docu/lib/build.node.js.map +1 -0
  10. package/.docu/lib/clean.js +25 -25
  11. package/.docu/lib/clean.js.map +1 -0
  12. package/.docu/lib/deno-DmEaKggj.js +20 -0
  13. package/.docu/lib/deno-DmEaKggj.js.map +1 -0
  14. package/.docu/lib/deploy.deno.js +9 -9
  15. package/.docu/lib/deploy.deno.js.map +1 -0
  16. package/.docu/lib/deploy.node.js +8 -8
  17. package/.docu/lib/deploy.node.js.map +1 -0
  18. package/.docu/lib/deploy.shared-D3UWafa6.js +295 -0
  19. package/.docu/lib/deploy.shared-D3UWafa6.js.map +1 -0
  20. package/.docu/lib/html.shared-DSn-7_6t.js +2467 -0
  21. package/.docu/lib/html.shared-DSn-7_6t.js.map +1 -0
  22. package/.docu/lib/logger-CycvLCrQ.js +312 -0
  23. package/.docu/lib/logger-CycvLCrQ.js.map +1 -0
  24. package/.docu/lib/node-DPTySdwG.js +80 -0
  25. package/.docu/lib/node-DPTySdwG.js.map +1 -0
  26. package/.docu/lib/paths-BtOIPBQ9.js +52 -0
  27. package/.docu/lib/paths-BtOIPBQ9.js.map +1 -0
  28. package/.docu/lib/preview.deno.js +7 -11
  29. package/.docu/lib/preview.deno.js.map +1 -0
  30. package/.docu/lib/preview.impl-CXJS2tQS.js +77 -0
  31. package/.docu/lib/preview.impl-CXJS2tQS.js.map +1 -0
  32. package/.docu/lib/preview.node.js +7 -11
  33. package/.docu/lib/preview.node.js.map +1 -0
  34. package/.docu/lib/server.deno.js +7 -12
  35. package/.docu/lib/server.deno.js.map +1 -0
  36. package/.docu/lib/server.impl-CJuWimfN.js +358 -0
  37. package/.docu/lib/server.impl-CJuWimfN.js.map +1 -0
  38. package/.docu/lib/server.node.js +7 -12
  39. package/.docu/lib/server.node.js.map +1 -0
  40. package/.docu/lib/utils-DA17MyQG.js +167 -0
  41. package/.docu/lib/utils-DA17MyQG.js.map +1 -0
  42. package/.docu/node/hydrate.node.ts +116 -166
  43. package/bin/compile-lib.mjs +30 -28
  44. package/package.json +6 -6
  45. package/.docu/lib/build.impl-S4DS5XPH.js +0 -12
  46. package/.docu/lib/chunk-4IQXHHPF.js +0 -62
  47. package/.docu/lib/chunk-C3RCUTUE.js +0 -470
  48. package/.docu/lib/chunk-D3QTSBR4.js +0 -434
  49. package/.docu/lib/chunk-EOK6KATZ.js +0 -191
  50. package/.docu/lib/chunk-IVM5UM44.js +0 -301
  51. package/.docu/lib/chunk-JMQI3FKV.js +0 -92
  52. package/.docu/lib/chunk-LXJLSXQI.js +0 -2691
  53. package/.docu/lib/chunk-O326MYJE.js +0 -330
  54. package/.docu/lib/chunk-UISOJ4RW.js +0 -114
@@ -1,301 +0,0 @@
1
- import {
2
- loadDocuConfig
3
- } from "./chunk-4IQXHHPF.js";
4
-
5
- // package.json
6
- var package_default = {
7
- name: "@docubook/flame",
8
- version: "2.0.0-beta.0",
9
- description: "A blazing-fast React + MDX framework powered by Bun, built for modern documentation experiences.",
10
- type: "module",
11
- bin: {
12
- flame: "./bin/cli.js"
13
- },
14
- files: [
15
- "bin",
16
- "template",
17
- "docu.schema.json",
18
- ".docu",
19
- "!.docu/__tests__",
20
- "!.docu/dist",
21
- "!.docu/build-cache.json",
22
- "README.md",
23
- "LICENSE"
24
- ],
25
- publishConfig: {
26
- registry: "https://registry.npmjs.org/",
27
- access: "public"
28
- },
29
- engines: {
30
- node: ">=20.11",
31
- bun: ">=1.1.0"
32
- },
33
- scripts: {
34
- dev: "bun .docu/node/server.ts",
35
- build: "NODE_ENV=production bun .docu/node/build.ts",
36
- clean: "bun .docu/node/clean.ts",
37
- preview: "bun .docu/node/preview.ts",
38
- deploy: "bun .docu/node/deploy.ts",
39
- "compile:lib": "node bin/compile-lib.mjs",
40
- test: "vitest run",
41
- lint: "eslint .",
42
- prepublishOnly: "bun .docu/node/clean.ts && eslint . && vitest run && node bin/compile-lib.mjs"
43
- },
44
- keywords: [
45
- "docubook",
46
- "documentation",
47
- "static-site",
48
- "daisyui",
49
- "bun",
50
- "docs framework",
51
- "react",
52
- "react-dom"
53
- ],
54
- homepage: "https://github.com/DocuBook/docubook/tree/main/packages/flame",
55
- repository: {
56
- type: "git",
57
- url: "git+https://github.com/DocuBook/docubook.git",
58
- directory: "packages/flame"
59
- },
60
- author: "wildan.nrs",
61
- "author-url": "https://wildan.dev",
62
- license: "MIT",
63
- dependencies: {
64
- "@docubook/core": "workspace:^",
65
- "@docubook/markdown": "workspace:^",
66
- "@docubook/themes-colors": "workspace:^",
67
- "@docubook/ui-react": "workspace:^",
68
- "@mdx-js/react": "^3.0.1",
69
- "@tailwindcss/cli": "4.3.0",
70
- "@tailwindcss/typography": "0.5.16",
71
- "bun-plugin-tailwind": "^0.1.2",
72
- daisyui: "^5.5.19",
73
- esbuild: "^0.28.1",
74
- "lucide-react": "^1.14.0",
75
- react: "^19.2.7",
76
- "react-dom": "^19.2.7",
77
- unified: "^11.0.0",
78
- zod: "^4.4.3"
79
- },
80
- peerDependencies: {
81
- "@sentry/bun": "^10.0.0"
82
- },
83
- peerDependenciesMeta: {
84
- "@sentry/bun": {
85
- optional: true
86
- }
87
- },
88
- devDependencies: {
89
- "@eslint/js": "^10.0.1",
90
- "@types/node": "^22.0.0",
91
- "@types/react": "^19.0.0",
92
- "@types/react-dom": "^19.0.0",
93
- "bun-types": "^1.3.0",
94
- eslint: "^10.3.0",
95
- "eslint-plugin-perfectionist": "^5.9.0",
96
- "eslint-plugin-react": "^7.37.5",
97
- "eslint-plugin-react-hooks": "^7.1.1",
98
- tailwindcss: "^4.3.0",
99
- typescript: "^5.9.3",
100
- "typescript-eslint": "^8.59.2"
101
- }
102
- };
103
-
104
- // .docu/node/logger.ts
105
- var docuConfig = loadDocuConfig();
106
- var isCI = !!(process.env.CI || process.env.NO_COLOR || !process.stdout.isTTY);
107
- var LOG_FORMAT = process.env.LOG_FORMAT || "pretty";
108
- var isJSON = LOG_FORMAT === "json";
109
- var LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
110
- var currentLevel = LEVELS[process.env.LOG_LEVEL || "info"] ?? LEVELS.info;
111
- function shouldLog(level) {
112
- return LEVELS[level] >= currentLevel;
113
- }
114
- function jsonLog(level, msg, meta) {
115
- if (!shouldLog(level)) return;
116
- const entry = { ts: (/* @__PURE__ */ new Date()).toISOString(), ...meta, level, msg };
117
- const out = level === "error" ? console.error : level === "warn" ? console.warn : console.log;
118
- out(JSON.stringify(entry));
119
- }
120
- function guard(level, msg, meta) {
121
- if (isJSON) {
122
- jsonLog(level, msg, meta);
123
- return true;
124
- }
125
- return !shouldLog(level);
126
- }
127
- var c = isCI || isJSON ? {
128
- reset: "",
129
- bold: "",
130
- dim: "",
131
- green: "",
132
- cyan: "",
133
- magenta: "",
134
- yellow: "",
135
- red: "",
136
- white: "",
137
- gray: ""
138
- } : {
139
- reset: "\x1B[0m",
140
- bold: "\x1B[1m",
141
- dim: "\x1B[2m",
142
- green: "\x1B[32m",
143
- cyan: "\x1B[36m",
144
- magenta: "\x1B[35m",
145
- yellow: "\x1B[33m",
146
- red: "\x1B[31m",
147
- white: "\x1B[37m",
148
- gray: "\x1B[90m"
149
- };
150
- var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
151
- var Spinner = class {
152
- frame = 0;
153
- message = "";
154
- timer = null;
155
- info(finalMsg) {
156
- if (this.timer) clearInterval(this.timer);
157
- this.timer = null;
158
- if (isCI) {
159
- console.log(`\u2139 ${finalMsg}`);
160
- } else {
161
- process.stdout.write(`\r\x1B[K${c.cyan}\u2139${c.reset} ${finalMsg}
162
- `);
163
- process.stdout.write("\x1B[?25h");
164
- }
165
- }
166
- start(msg) {
167
- this.message = msg;
168
- if (isCI) {
169
- console.log(`\u2026 ${msg}`);
170
- return;
171
- }
172
- this.frame = 0;
173
- process.stdout.write("\x1B[?25l");
174
- this.render();
175
- this.timer = setInterval(() => this.render(), 80);
176
- }
177
- stop(finalMsg) {
178
- if (this.timer) clearInterval(this.timer);
179
- this.timer = null;
180
- if (isCI) {
181
- console.log(`\u2713 ${finalMsg}`);
182
- return;
183
- }
184
- process.stdout.write(`\r\x1B[K${c.green}\u2713${c.reset} ${finalMsg}
185
- `);
186
- process.stdout.write("\x1B[?25h");
187
- }
188
- render() {
189
- const f = SPINNER_FRAMES[this.frame % SPINNER_FRAMES.length];
190
- process.stdout.write(`\r${c.cyan}${f}${c.reset} ${this.message}`);
191
- this.frame++;
192
- }
193
- };
194
- var MAX_ROUTE_LINES = 5;
195
- var routeLineCount = 0;
196
- var routeTruncated = false;
197
- function printRouteTree(routes, prefix = "", isRoot = true) {
198
- for (let i = 0; i < routes.length; i++) {
199
- if (routeTruncated) return;
200
- if (routeLineCount >= MAX_ROUTE_LINES) {
201
- routeTruncated = true;
202
- process.stdout.write(`${prefix}${c.dim}...${c.reset}
203
- `);
204
- return;
205
- }
206
- const route = routes[i];
207
- const last = i === routes.length - 1;
208
- const connector = isRoot ? "" : last ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
209
- const childPrefix = isRoot ? "" : last ? " " : "\u2502 ";
210
- const path = route.noLink ? `${c.dim}${route.href}${c.reset}` : `${c.white}${route.href}${c.reset}`;
211
- const label = route.noLink ? `${c.gray}(group)${c.reset}` : "";
212
- process.stdout.write(`${prefix}${connector}${path} ${label}
213
- `);
214
- routeLineCount++;
215
- if (route.items?.length) {
216
- printRouteTree(route.items, prefix + childPrefix, false);
217
- }
218
- }
219
- }
220
- var logger = {
221
- spinner: new Spinner(),
222
- buildStart() {
223
- if (guard("info", "build_start", { package: "@docubook/flame", version: package_default.version })) return;
224
- console.log(
225
- `
226
- ${c.bold}${c.cyan} \u{1F525} DocuBook Flame${c.reset} ${c.dim}v${package_default.version}${c.reset}
227
- `
228
- );
229
- },
230
- bundleStart() {
231
- if (guard("info", "bundle_start")) return;
232
- this.spinner.start("Building client bundle...");
233
- },
234
- bundleDone(ms) {
235
- if (guard("info", "bundle_done", { duration_ms: ms })) return;
236
- this.spinner.stop(`Client bundle compiled ${c.dim}(${ms}ms)${c.reset}`);
237
- },
238
- indexStart() {
239
- if (guard("info", "index_start")) return;
240
- this.spinner.start("Generating search index...");
241
- },
242
- indexDone(records, ms, skipped = false) {
243
- if (guard("info", "index_done", { records, duration_ms: ms, skipped })) return;
244
- this.spinner.stop(
245
- skipped ? `Search index cached ${c.dim}(${ms}ms)${c.reset}` : `Search index generated ${c.dim}(${records} records, ${ms}ms)${c.reset}`
246
- );
247
- },
248
- routes() {
249
- if (guard("debug", "routes")) return;
250
- const routes = docuConfig.routes;
251
- if (!routes?.length) return;
252
- console.log(`
253
- ${c.bold} Routes${c.reset} ${c.dim}(${countRoutes(routes)} pages)${c.reset}
254
- `);
255
- routeLineCount = 0;
256
- routeTruncated = false;
257
- printRouteTree(routes, " ");
258
- },
259
- ready(port, hmr = false) {
260
- if (guard("info", "server_ready", { port, hmr })) return;
261
- console.log(
262
- `
263
- ${c.green}${c.bold} \u2713 Ready${c.reset} in ${c.bold}http://localhost:${port}/docs/${c.reset}`
264
- );
265
- if (hmr) console.log(`${c.dim} HMR enabled \u2014 watching docs/ for changes${c.reset}`);
266
- console.log("");
267
- },
268
- request(method, pathname, status, duration_ms) {
269
- if (guard("info", "http_request", { method, path: pathname, status, duration_ms })) return;
270
- const color = status >= 500 ? c.red : status >= 400 ? c.gray : c.green;
271
- const ts = (/* @__PURE__ */ new Date()).toLocaleTimeString();
272
- const dur = duration_ms != null ? ` ${c.dim}${duration_ms}ms${c.reset}` : "";
273
- console.log(
274
- `${c.dim} ${ts}${c.reset} ${method} ${pathname} ${color}${status}${c.reset}${dur}`
275
- );
276
- },
277
- debug(msg, meta) {
278
- if (guard("debug", msg, meta)) return;
279
- console.log(`${c.gray} [debug] ${msg}${c.reset}`);
280
- },
281
- warn(msg, meta) {
282
- if (guard("warn", msg, meta)) return;
283
- console.warn(`${c.yellow} \u26A0 ${msg}${c.reset}`);
284
- },
285
- error(msg, meta) {
286
- if (guard("error", msg, meta)) return;
287
- console.error(`${c.red} \u2716 ${msg}${c.reset}`);
288
- }
289
- };
290
- function countRoutes(routes) {
291
- let count = 0;
292
- for (const r of routes) {
293
- if (!r.noLink) count++;
294
- if (r.items) count += countRoutes(r.items);
295
- }
296
- return count;
297
- }
298
-
299
- export {
300
- logger
301
- };
@@ -1,92 +0,0 @@
1
- import {
2
- SECURITY_HEADERS,
3
- cspHeader,
4
- generateNonce,
5
- getContentType,
6
- injectNonce
7
- } from "./chunk-EOK6KATZ.js";
8
- import {
9
- logger
10
- } from "./chunk-IVM5UM44.js";
11
- import {
12
- DIST_DIR
13
- } from "./chunk-4IQXHHPF.js";
14
-
15
- // .docu/node/preview.impl.ts
16
- import { existsSync, statSync, readFileSync } from "node:fs";
17
- import { readFile } from "node:fs/promises";
18
- import { resolve } from "node:path";
19
- function resolveFile(pathname) {
20
- const path = pathname.slice(1);
21
- const isWithinDist = (p) => p === DIST_DIR || p.startsWith(DIST_DIR + "/");
22
- if (!path.includes(".")) {
23
- const withIndex = resolve(DIST_DIR, path, "index.html");
24
- if (isWithinDist(withIndex) && existsSync(withIndex)) return withIndex;
25
- const withHtml = resolve(DIST_DIR, path + ".html");
26
- if (isWithinDist(withHtml) && existsSync(withHtml)) return withHtml;
27
- }
28
- const exact = resolve(DIST_DIR, path);
29
- if (!isWithinDist(exact)) return null;
30
- try {
31
- if (statSync(exact).isFile()) return exact;
32
- } catch (err) {
33
- if (err.code !== "ENOENT") throw err;
34
- }
35
- return null;
36
- }
37
- async function runPreview(adapter) {
38
- const PORT = parseInt(process.env.PORT || "4173", 10);
39
- logger.buildStart();
40
- if (!existsSync(DIST_DIR)) {
41
- logger.spinner.start("Checking build output...");
42
- logger.spinner.info("dist not found. Run \x1B[1mflame build\x1B[0m first.");
43
- process.exit(0);
44
- }
45
- const notFoundPath = resolve(DIST_DIR, "404.html");
46
- const handle = await adapter.serve(
47
- async (req) => {
48
- const url = new URL(req.url);
49
- const pathname = decodeURIComponent(url.pathname);
50
- const filePath = resolveFile(pathname);
51
- if (filePath) {
52
- const contentType = getContentType(filePath);
53
- if (contentType === "text/html") {
54
- const nonce = generateNonce();
55
- const html = await readFile(filePath, "utf-8");
56
- const modified = injectNonce(html, nonce);
57
- return new Response(modified, {
58
- headers: {
59
- "Content-Type": "text/html",
60
- ...SECURITY_HEADERS,
61
- "Content-Security-Policy": cspHeader(nonce)
62
- }
63
- });
64
- }
65
- return new Response(readFileSync(filePath), {
66
- headers: { "Content-Type": contentType }
67
- });
68
- }
69
- if (existsSync(notFoundPath)) {
70
- const nonce = generateNonce();
71
- const html = await readFile(notFoundPath, "utf-8");
72
- const modified = injectNonce(html, nonce);
73
- return new Response(modified, {
74
- status: 404,
75
- headers: {
76
- "Content-Type": "text/html",
77
- ...SECURITY_HEADERS,
78
- "Content-Security-Policy": cspHeader(nonce)
79
- }
80
- });
81
- }
82
- return new Response("404 - Not Found", { status: 404 });
83
- },
84
- { port: PORT }
85
- );
86
- logger.ready(handle.port);
87
- return handle;
88
- }
89
-
90
- export {
91
- runPreview
92
- };