@unterberg/nivel 0.0.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 (49) hide show
  1. package/assets/nivel/brands/bluesky.svg +4 -0
  2. package/assets/nivel/brands/discord.svg +3 -0
  3. package/assets/nivel/brands/github.svg +2 -0
  4. package/assets/nivel/brands/linkedin.svg +3 -0
  5. package/assets/nivel/brands/typescript.svg +26 -0
  6. package/assets/nivel/brands/x.svg +4 -0
  7. package/assets/nivel/decorators/pattern-light.png +0 -0
  8. package/assets/nivel/decorators/pattern.png +0 -0
  9. package/assets/nivel/fonts/fonts-inter.css +26 -0
  10. package/assets/nivel/fonts/inter-v20-latin-600.woff2 +0 -0
  11. package/assets/nivel/fonts/inter-v20-latin-800.woff2 +0 -0
  12. package/assets/nivel/fonts/inter-v20-latin-regular.woff2 +0 -0
  13. package/dist/chunk-3JJ6TYWL.js +614 -0
  14. package/dist/chunk-3JJ6TYWL.js.map +1 -0
  15. package/dist/chunk-45CLUNJW.js +657 -0
  16. package/dist/chunk-45CLUNJW.js.map +1 -0
  17. package/dist/chunk-4WTEOEV2.js +36 -0
  18. package/dist/chunk-4WTEOEV2.js.map +1 -0
  19. package/dist/chunk-62MBEYU7.js +1091 -0
  20. package/dist/chunk-62MBEYU7.js.map +1 -0
  21. package/dist/chunk-73NPVCDQ.js +353 -0
  22. package/dist/chunk-73NPVCDQ.js.map +1 -0
  23. package/dist/chunk-FLO5CJZH.js +42 -0
  24. package/dist/chunk-FLO5CJZH.js.map +1 -0
  25. package/dist/chunk-PHHK2BAF.js +350 -0
  26. package/dist/chunk-PHHK2BAF.js.map +1 -0
  27. package/dist/client.d.ts +70 -0
  28. package/dist/client.js +26 -0
  29. package/dist/client.js.map +1 -0
  30. package/dist/code-blocks.d.ts +35 -0
  31. package/dist/code-blocks.js +21 -0
  32. package/dist/code-blocks.js.map +1 -0
  33. package/dist/config.d.ts +16 -0
  34. package/dist/config.js +101 -0
  35. package/dist/config.js.map +1 -0
  36. package/dist/index.d.ts +143 -0
  37. package/dist/index.js +45 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/mdx.d.ts +6 -0
  40. package/dist/mdx.js +35 -0
  41. package/dist/mdx.js.map +1 -0
  42. package/dist/runtime/client.d.ts +7 -0
  43. package/dist/runtime/client.js +26 -0
  44. package/dist/runtime/client.js.map +1 -0
  45. package/dist/runtime/index.d.ts +15 -0
  46. package/dist/runtime/index.js +18 -0
  47. package/dist/runtime/index.js.map +1 -0
  48. package/dist/types-mvLNHHrf.d.ts +177 -0
  49. package/package.json +90 -0
@@ -0,0 +1,350 @@
1
+ import {
2
+ extractDocHeadings,
3
+ getResolvedPageById,
4
+ getResolvedSectionById,
5
+ resolveDocsConfig
6
+ } from "./chunk-73NPVCDQ.js";
7
+ import {
8
+ nivelPublicRoute
9
+ } from "./chunk-FLO5CJZH.js";
10
+
11
+ // src/runtime/codegen.ts
12
+ import fs from "fs";
13
+ import path from "path";
14
+ var GENERATED_DIRNAME = "(nivel-generated)";
15
+ var writeFileIfChanged = (filePath, source) => {
16
+ const current = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : null;
17
+ if (current === source) {
18
+ return;
19
+ }
20
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
21
+ fs.writeFileSync(filePath, source);
22
+ };
23
+ var toPosix = (value) => value.split(path.sep).join(path.posix.sep);
24
+ var getRelativeImportPath = (fromDirectory, toFile) => {
25
+ const relativePath = toPosix(path.relative(fromDirectory, toFile));
26
+ if (relativePath.startsWith(".")) {
27
+ return relativePath;
28
+ }
29
+ return `./${relativePath}`;
30
+ };
31
+ var getRelativeScriptImportPath = (fromDirectory, toFile) => {
32
+ return getRelativeImportPath(fromDirectory, toFile).replace(/\.(cts|mts|ts|tsx)$/, "");
33
+ };
34
+ var serializeData = (data) => JSON.stringify(data, null, 2);
35
+ var collectFiles = (directoryPath) => {
36
+ if (!fs.existsSync(directoryPath)) {
37
+ return [];
38
+ }
39
+ const entries = fs.readdirSync(directoryPath, { withFileTypes: true });
40
+ return entries.flatMap((entry) => {
41
+ const entryPath = path.join(directoryPath, entry.name);
42
+ return entry.isDirectory() ? collectFiles(entryPath) : [entryPath];
43
+ });
44
+ };
45
+ var removeEmptyDirectories = (directoryPath, rootPath) => {
46
+ if (!fs.existsSync(directoryPath)) {
47
+ return;
48
+ }
49
+ for (const entry of fs.readdirSync(directoryPath, { withFileTypes: true })) {
50
+ if (!entry.isDirectory()) {
51
+ continue;
52
+ }
53
+ removeEmptyDirectories(path.join(directoryPath, entry.name), rootPath);
54
+ }
55
+ if (directoryPath === rootPath) {
56
+ return;
57
+ }
58
+ if (fs.readdirSync(directoryPath).length === 0) {
59
+ fs.rmdirSync(directoryPath);
60
+ }
61
+ };
62
+ var getGeneratedPageSource = (contentImportPath, docsConfigImportPath) => {
63
+ return [
64
+ "import { DocsPage } from '@unterberg/nivel/client'",
65
+ `import docsConfig from ${JSON.stringify(docsConfigImportPath)}`,
66
+ `import Content from ${JSON.stringify(contentImportPath)}`,
67
+ "",
68
+ "const Page = () => {",
69
+ " return <DocsPage Content={Content} docsConfig={docsConfig} />",
70
+ "}",
71
+ "",
72
+ "export default Page",
73
+ ""
74
+ ].join("\n");
75
+ };
76
+ var getGeneratedDataSource = (data) => {
77
+ return [
78
+ "import type { DocPageData } from '@unterberg/nivel'",
79
+ "",
80
+ `const data: DocPageData = ${serializeData(data)}`,
81
+ "",
82
+ "const pageData = () => {",
83
+ " return data",
84
+ "}",
85
+ "",
86
+ "export default pageData",
87
+ ""
88
+ ].join("\n");
89
+ };
90
+ var getRouteString = (href) => {
91
+ if (href === "/") {
92
+ return href;
93
+ }
94
+ return href.replace(/\/+$/g, "");
95
+ };
96
+ var getGeneratedRouteSource = (href) => {
97
+ return [`export default ${JSON.stringify(getRouteString(href))}`, ""].join("\n");
98
+ };
99
+ var getGeneratedTextExport = (value) => {
100
+ return [`export default ${JSON.stringify(value)}`, ""].join("\n");
101
+ };
102
+ var toDocPageLinkData = (page) => {
103
+ if (!page) {
104
+ return null;
105
+ }
106
+ return {
107
+ id: page.id,
108
+ title: page.title,
109
+ href: page.href,
110
+ documentTitle: page.documentTitle
111
+ };
112
+ };
113
+ var getGeneratedPagesRoot = (rootDir) => path.join(rootDir, "pages", GENERATED_DIRNAME);
114
+ var syncGeneratedDocsPages = (options) => {
115
+ const { rootDir, docsConfig } = options;
116
+ const resolved = resolveDocsConfig(docsConfig);
117
+ const generatedPagesRoot = getGeneratedPagesRoot(rootDir);
118
+ const docsRoot = path.join(rootDir, "docs");
119
+ const docsConfigPath = path.join(rootDir, "pages", "+docs.ts");
120
+ const expectedFiles = /* @__PURE__ */ new Set();
121
+ fs.mkdirSync(generatedPagesRoot, { recursive: true });
122
+ for (const [pageIndex, page] of resolved.pages.entries()) {
123
+ const contentFilePath = path.join(docsRoot, page.source);
124
+ if (!fs.existsSync(contentFilePath)) {
125
+ throw new Error(`Docs page "${page.id}" points to missing source file: ${contentFilePath}`);
126
+ }
127
+ const section = getResolvedSectionById(resolved, page.sectionId);
128
+ const pageSource = fs.readFileSync(contentFilePath, "utf8");
129
+ const data = {
130
+ siteTitle: resolved.siteTitle,
131
+ basePath: resolved.basePath,
132
+ theme: resolved.theme,
133
+ footer: resolved.footer,
134
+ page: getResolvedPageById(resolved, page.id),
135
+ activeSectionId: page.sectionId,
136
+ activeSectionTitle: section?.title ?? page.sectionId,
137
+ headings: extractDocHeadings(pageSource),
138
+ previousPage: toDocPageLinkData(resolved.pages[pageIndex - 1]),
139
+ nextPage: toDocPageLinkData(resolved.pages[pageIndex + 1]),
140
+ navbarItems: resolved.navbarItems,
141
+ sidebarItems: section?.items ?? [],
142
+ sidebarSections: resolved.sections
143
+ };
144
+ for (const routeHref of [page.href, ...page.aliasHrefs]) {
145
+ const routeSlug = routeHref.replace(/^\/docs\//, "").replace(/\/+$/g, "");
146
+ const pageDir = path.join(generatedPagesRoot, ...routeSlug.split("/"));
147
+ const contentImportPath = getRelativeImportPath(pageDir, contentFilePath);
148
+ const docsConfigImportPath = getRelativeScriptImportPath(pageDir, docsConfigPath);
149
+ const pageFilePath = path.join(pageDir, "+Page.tsx");
150
+ const dataFilePath = path.join(pageDir, "+data.ts");
151
+ const routeFilePath = path.join(pageDir, "+route.ts");
152
+ const titleFilePath = path.join(pageDir, "+title.ts");
153
+ writeFileIfChanged(pageFilePath, getGeneratedPageSource(contentImportPath, docsConfigImportPath));
154
+ writeFileIfChanged(dataFilePath, getGeneratedDataSource(data));
155
+ writeFileIfChanged(routeFilePath, getGeneratedRouteSource(routeHref));
156
+ writeFileIfChanged(titleFilePath, getGeneratedTextExport(page.documentTitle));
157
+ expectedFiles.add(pageFilePath);
158
+ expectedFiles.add(dataFilePath);
159
+ expectedFiles.add(routeFilePath);
160
+ expectedFiles.add(titleFilePath);
161
+ if (page.description) {
162
+ const descriptionFilePath = path.join(pageDir, "+description.ts");
163
+ writeFileIfChanged(descriptionFilePath, getGeneratedTextExport(page.description));
164
+ expectedFiles.add(descriptionFilePath);
165
+ }
166
+ }
167
+ }
168
+ for (const filePath of collectFiles(generatedPagesRoot)) {
169
+ if (expectedFiles.has(filePath)) {
170
+ continue;
171
+ }
172
+ fs.rmSync(filePath, { force: true });
173
+ }
174
+ removeEmptyDirectories(generatedPagesRoot, generatedPagesRoot);
175
+ };
176
+ var isDocsSourcePath = (filePath, rootDir) => {
177
+ const normalized = toPosix(filePath);
178
+ const docsRoot = toPosix(path.join(rootDir, "docs"));
179
+ const docsConfigPath = toPosix(path.join(rootDir, "pages", "+docs.ts"));
180
+ const generatedRoot = toPosix(getGeneratedPagesRoot(rootDir));
181
+ if (normalized.startsWith(generatedRoot)) {
182
+ return false;
183
+ }
184
+ return normalized === docsConfigPath || normalized.startsWith(`${docsRoot}/`);
185
+ };
186
+
187
+ // src/runtime/plugin.ts
188
+ import fs3 from "fs";
189
+ import path3 from "path";
190
+
191
+ // src/runtime/publicAssets.ts
192
+ import fs2 from "fs";
193
+ import path2 from "path";
194
+ import { fileURLToPath, pathToFileURL } from "url";
195
+ var toPosix2 = (value) => value.split(path2.sep).join(path2.posix.sep);
196
+ var getRequestPathname = (requestUrl) => {
197
+ return requestUrl?.split("?")[0]?.split("#")[0] ?? "";
198
+ };
199
+ var normalizeNivelAssetPathname = (pathname) => {
200
+ if (pathname === nivelPublicRoute) {
201
+ return pathname;
202
+ }
203
+ if (!pathname.startsWith(`${nivelPublicRoute}/`)) {
204
+ return null;
205
+ }
206
+ const trimmedPathname = pathname.replace(/\/+$/g, "");
207
+ if (trimmedPathname !== pathname && path2.extname(trimmedPathname)) {
208
+ return trimmedPathname;
209
+ }
210
+ return pathname;
211
+ };
212
+ var getPublicAssetsRootCandidates = (runtimeDir) => {
213
+ let packageRoot = null;
214
+ try {
215
+ const nivelConfigUrl = import.meta.resolve("@unterberg/nivel/config");
216
+ const nivelConfigPath = fileURLToPath(nivelConfigUrl);
217
+ packageRoot = path2.resolve(path2.dirname(nivelConfigPath), "..");
218
+ } catch {
219
+ packageRoot = null;
220
+ }
221
+ return [
222
+ ...packageRoot ? [path2.join(packageRoot, "assets")] : [],
223
+ path2.resolve(runtimeDir, "../assets"),
224
+ path2.resolve(runtimeDir, "../../assets")
225
+ ];
226
+ };
227
+ var getNivelPublicAssetsRoot = () => {
228
+ const runtimeUrl = import.meta.url.startsWith("/") ? pathToFileURL(import.meta.url).href : import.meta.url;
229
+ const runtimeDir = path2.dirname(fileURLToPath(runtimeUrl));
230
+ for (const candidate of getPublicAssetsRootCandidates(runtimeDir)) {
231
+ if (fs2.existsSync(candidate) && fs2.statSync(candidate).isDirectory()) {
232
+ return candidate;
233
+ }
234
+ }
235
+ throw new Error(`Unable to locate nivel public assets from ${runtimeDir}.`);
236
+ };
237
+ var getNivelPublicAssetFilePath = (requestUrl) => {
238
+ const pathname = normalizeNivelAssetPathname(getRequestPathname(requestUrl));
239
+ if (!pathname) {
240
+ return null;
241
+ }
242
+ const assetsRoot = getNivelPublicAssetsRoot();
243
+ const relativePath = pathname.replace(/^\/+/, "");
244
+ const filePath = path2.resolve(assetsRoot, relativePath);
245
+ const relativeToRoot = path2.relative(assetsRoot, filePath);
246
+ if (relativeToRoot.startsWith("..") || path2.isAbsolute(relativeToRoot) || !fs2.existsSync(filePath) || !fs2.statSync(filePath).isFile()) {
247
+ return null;
248
+ }
249
+ return filePath;
250
+ };
251
+ var getNivelPublicAssetContentType = (filePath) => {
252
+ switch (path2.extname(filePath)) {
253
+ case ".css":
254
+ return "text/css; charset=utf-8";
255
+ case ".svg":
256
+ return "image/svg+xml";
257
+ case ".png":
258
+ return "image/png";
259
+ case ".ico":
260
+ return "image/x-icon";
261
+ case ".woff2":
262
+ return "font/woff2";
263
+ default:
264
+ return "application/octet-stream";
265
+ }
266
+ };
267
+ var isNivelAssetRequestUrl = (requestUrl) => {
268
+ return normalizeNivelAssetPathname(getRequestPathname(requestUrl)) !== null;
269
+ };
270
+ var isNivelAssetPath = (filePath) => {
271
+ const normalizedFilePath = toPosix2(path2.resolve(filePath));
272
+ const assetsRoot = toPosix2(getNivelPublicAssetsRoot());
273
+ return normalizedFilePath.startsWith(`${assetsRoot}/`);
274
+ };
275
+
276
+ // src/runtime/plugin.ts
277
+ var loadDocsConfig = async (server, rootDir) => {
278
+ const modulePath = path3.join(rootDir, "pages", "+docs.ts");
279
+ const loaded = await server.ssrLoadModule(modulePath);
280
+ const docsConfig = loaded.default;
281
+ if (!docsConfig) {
282
+ throw new Error(`Expected default export from ${modulePath}`);
283
+ }
284
+ return docsConfig;
285
+ };
286
+ var syncAndRestart = async (server, rootDir) => {
287
+ const docsConfig = await loadDocsConfig(server, rootDir);
288
+ syncGeneratedDocsPages({ rootDir, docsConfig });
289
+ await server.restart();
290
+ };
291
+ var nivelPagesPlugin = () => {
292
+ return {
293
+ name: "nivel-pages-plugin",
294
+ enforce: "pre",
295
+ configureServer(server) {
296
+ const rootDir = server.config.root;
297
+ const assetsRoot = getNivelPublicAssetsRoot();
298
+ server.watcher.add(assetsRoot);
299
+ const onChange = async (filePath) => {
300
+ if (!isDocsSourcePath(filePath, rootDir)) {
301
+ return;
302
+ }
303
+ await syncAndRestart(server, rootDir);
304
+ };
305
+ server.watcher.on("add", onChange);
306
+ server.watcher.on("change", onChange);
307
+ server.watcher.on("unlink", onChange);
308
+ server.watcher.on("change", (filePath) => {
309
+ if (!isNivelAssetPath(filePath)) {
310
+ return;
311
+ }
312
+ server.ws.send({ type: "full-reload" });
313
+ });
314
+ server.middlewares.use((req, res, next) => {
315
+ const filePath = getNivelPublicAssetFilePath(req.url);
316
+ if (filePath) {
317
+ res.setHeader("Content-Type", getNivelPublicAssetContentType(filePath));
318
+ res.setHeader("Cache-Control", "no-store");
319
+ res.end(fs3.readFileSync(filePath));
320
+ return;
321
+ }
322
+ if (isNivelAssetRequestUrl(req.url)) {
323
+ res.statusCode = 404;
324
+ res.setHeader("Cache-Control", "no-store");
325
+ res.end();
326
+ return;
327
+ }
328
+ next();
329
+ });
330
+ },
331
+ handleHotUpdate(ctx) {
332
+ if (isNivelAssetPath(ctx.file)) {
333
+ ctx.server.ws.send({ type: "full-reload" });
334
+ return [];
335
+ }
336
+ if (!isDocsSourcePath(ctx.file, ctx.server.config.root)) {
337
+ return;
338
+ }
339
+ ctx.server.ws.send({ type: "full-reload" });
340
+ return [];
341
+ }
342
+ };
343
+ };
344
+
345
+ export {
346
+ getGeneratedPagesRoot,
347
+ syncGeneratedDocsPages,
348
+ nivelPagesPlugin
349
+ };
350
+ //# sourceMappingURL=chunk-PHHK2BAF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/codegen.ts","../src/runtime/plugin.ts","../src/runtime/publicAssets.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { DocPageData, DocPageLinkData, DocsConfig } from '../types.js'\nimport { extractDocHeadings } from './docHeadings.js'\nimport { getResolvedPageById, getResolvedSectionById, resolveDocsConfig } from './resolveDocsConfig.js'\n\nconst GENERATED_DIRNAME = '(nivel-generated)'\n\nconst writeFileIfChanged = (filePath: string, source: string) => {\n const current = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : null\n if (current === source) {\n return\n }\n\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, source)\n}\n\nconst toPosix = (value: string) => value.split(path.sep).join(path.posix.sep)\n\nconst getRelativeImportPath = (fromDirectory: string, toFile: string) => {\n const relativePath = toPosix(path.relative(fromDirectory, toFile))\n if (relativePath.startsWith('.')) {\n return relativePath\n }\n return `./${relativePath}`\n}\n\nconst getRelativeScriptImportPath = (fromDirectory: string, toFile: string) => {\n return getRelativeImportPath(fromDirectory, toFile).replace(/\\.(cts|mts|ts|tsx)$/, '')\n}\n\nconst serializeData = (data: DocPageData) => JSON.stringify(data, null, 2)\n\nconst collectFiles = (directoryPath: string): string[] => {\n if (!fs.existsSync(directoryPath)) {\n return []\n }\n\n const entries = fs.readdirSync(directoryPath, { withFileTypes: true })\n\n return entries.flatMap((entry) => {\n const entryPath = path.join(directoryPath, entry.name)\n return entry.isDirectory() ? collectFiles(entryPath) : [entryPath]\n })\n}\n\nconst removeEmptyDirectories = (directoryPath: string, rootPath: string) => {\n if (!fs.existsSync(directoryPath)) {\n return\n }\n\n for (const entry of fs.readdirSync(directoryPath, { withFileTypes: true })) {\n if (!entry.isDirectory()) {\n continue\n }\n\n removeEmptyDirectories(path.join(directoryPath, entry.name), rootPath)\n }\n\n if (directoryPath === rootPath) {\n return\n }\n\n if (fs.readdirSync(directoryPath).length === 0) {\n fs.rmdirSync(directoryPath)\n }\n}\n\nconst getGeneratedPageSource = (contentImportPath: string, docsConfigImportPath: string) => {\n return [\n \"import { DocsPage } from '@unterberg/nivel/client'\",\n `import docsConfig from ${JSON.stringify(docsConfigImportPath)}`,\n `import Content from ${JSON.stringify(contentImportPath)}`,\n '',\n 'const Page = () => {',\n ' return <DocsPage Content={Content} docsConfig={docsConfig} />',\n '}',\n '',\n 'export default Page',\n '',\n ].join('\\n')\n}\n\nconst getGeneratedDataSource = (data: DocPageData) => {\n return [\n \"import type { DocPageData } from '@unterberg/nivel'\",\n '',\n `const data: DocPageData = ${serializeData(data)}`,\n '',\n 'const pageData = () => {',\n ' return data',\n '}',\n '',\n 'export default pageData',\n '',\n ].join('\\n')\n}\n\nconst getRouteString = (href: string) => {\n if (href === '/') {\n return href\n }\n\n return href.replace(/\\/+$/g, '')\n}\n\nconst getGeneratedRouteSource = (href: string) => {\n return [`export default ${JSON.stringify(getRouteString(href))}`, ''].join('\\n')\n}\n\nconst getGeneratedTextExport = (value: string) => {\n return [`export default ${JSON.stringify(value)}`, ''].join('\\n')\n}\n\nconst toDocPageLinkData = (\n page:\n | {\n id: string\n title: string\n href: string\n documentTitle: string\n }\n | undefined,\n): DocPageLinkData | null => {\n if (!page) {\n return null\n }\n\n return {\n id: page.id,\n title: page.title,\n href: page.href,\n documentTitle: page.documentTitle,\n }\n}\n\nexport const getGeneratedPagesRoot = (rootDir: string) => path.join(rootDir, 'pages', GENERATED_DIRNAME)\n\nexport const syncGeneratedDocsPages = (options: { rootDir: string; docsConfig: DocsConfig }) => {\n const { rootDir, docsConfig } = options\n const resolved = resolveDocsConfig(docsConfig)\n const generatedPagesRoot = getGeneratedPagesRoot(rootDir)\n const docsRoot = path.join(rootDir, 'docs')\n const docsConfigPath = path.join(rootDir, 'pages', '+docs.ts')\n const expectedFiles = new Set<string>()\n\n fs.mkdirSync(generatedPagesRoot, { recursive: true })\n\n for (const [pageIndex, page] of resolved.pages.entries()) {\n const contentFilePath = path.join(docsRoot, page.source)\n\n if (!fs.existsSync(contentFilePath)) {\n throw new Error(`Docs page \"${page.id}\" points to missing source file: ${contentFilePath}`)\n }\n\n const section = getResolvedSectionById(resolved, page.sectionId)\n const pageSource = fs.readFileSync(contentFilePath, 'utf8')\n const data: DocPageData = {\n siteTitle: resolved.siteTitle,\n basePath: resolved.basePath,\n theme: resolved.theme,\n footer: resolved.footer,\n page: getResolvedPageById(resolved, page.id),\n activeSectionId: page.sectionId,\n activeSectionTitle: section?.title ?? page.sectionId,\n headings: extractDocHeadings(pageSource),\n previousPage: toDocPageLinkData(resolved.pages[pageIndex - 1]),\n nextPage: toDocPageLinkData(resolved.pages[pageIndex + 1]),\n navbarItems: resolved.navbarItems,\n sidebarItems: section?.items ?? [],\n sidebarSections: resolved.sections,\n }\n\n for (const routeHref of [page.href, ...page.aliasHrefs]) {\n const routeSlug = routeHref.replace(/^\\/docs\\//, '').replace(/\\/+$/g, '')\n const pageDir = path.join(generatedPagesRoot, ...routeSlug.split('/'))\n const contentImportPath = getRelativeImportPath(pageDir, contentFilePath)\n const docsConfigImportPath = getRelativeScriptImportPath(pageDir, docsConfigPath)\n\n const pageFilePath = path.join(pageDir, '+Page.tsx')\n const dataFilePath = path.join(pageDir, '+data.ts')\n const routeFilePath = path.join(pageDir, '+route.ts')\n const titleFilePath = path.join(pageDir, '+title.ts')\n\n writeFileIfChanged(pageFilePath, getGeneratedPageSource(contentImportPath, docsConfigImportPath))\n writeFileIfChanged(dataFilePath, getGeneratedDataSource(data))\n writeFileIfChanged(routeFilePath, getGeneratedRouteSource(routeHref))\n writeFileIfChanged(titleFilePath, getGeneratedTextExport(page.documentTitle))\n\n expectedFiles.add(pageFilePath)\n expectedFiles.add(dataFilePath)\n expectedFiles.add(routeFilePath)\n expectedFiles.add(titleFilePath)\n\n if (page.description) {\n const descriptionFilePath = path.join(pageDir, '+description.ts')\n writeFileIfChanged(descriptionFilePath, getGeneratedTextExport(page.description))\n expectedFiles.add(descriptionFilePath)\n }\n }\n }\n\n for (const filePath of collectFiles(generatedPagesRoot)) {\n if (expectedFiles.has(filePath)) {\n continue\n }\n\n fs.rmSync(filePath, { force: true })\n }\n\n removeEmptyDirectories(generatedPagesRoot, generatedPagesRoot)\n}\n\nexport const isDocsSourcePath = (filePath: string, rootDir: string) => {\n const normalized = toPosix(filePath)\n const docsRoot = toPosix(path.join(rootDir, 'docs'))\n const docsConfigPath = toPosix(path.join(rootDir, 'pages', '+docs.ts'))\n const generatedRoot = toPosix(getGeneratedPagesRoot(rootDir))\n\n if (normalized.startsWith(generatedRoot)) {\n return false\n }\n\n return normalized === docsConfigPath || normalized.startsWith(`${docsRoot}/`)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { Plugin, ViteDevServer } from 'vite'\nimport type { DocsConfig } from '../types.js'\nimport { isDocsSourcePath, syncGeneratedDocsPages } from './codegen.js'\nimport {\n getNivelPublicAssetContentType,\n getNivelPublicAssetFilePath,\n getNivelPublicAssetsRoot,\n isNivelAssetPath,\n isNivelAssetRequestUrl,\n} from './publicAssets.js'\n\nconst loadDocsConfig = async (server: ViteDevServer, rootDir: string): Promise<DocsConfig> => {\n const modulePath = path.join(rootDir, 'pages', '+docs.ts')\n const loaded = await server.ssrLoadModule(modulePath)\n const docsConfig = loaded.default as DocsConfig | undefined\n\n if (!docsConfig) {\n throw new Error(`Expected default export from ${modulePath}`)\n }\n\n return docsConfig\n}\n\nconst syncAndRestart = async (server: ViteDevServer, rootDir: string) => {\n const docsConfig = await loadDocsConfig(server, rootDir)\n syncGeneratedDocsPages({ rootDir, docsConfig })\n await server.restart()\n}\n\nexport const nivelPagesPlugin = (): Plugin => {\n return {\n name: 'nivel-pages-plugin',\n enforce: 'pre',\n configureServer(server) {\n const rootDir = server.config.root\n const assetsRoot = getNivelPublicAssetsRoot()\n\n server.watcher.add(assetsRoot)\n\n const onChange = async (filePath: string) => {\n if (!isDocsSourcePath(filePath, rootDir)) {\n return\n }\n\n await syncAndRestart(server, rootDir)\n }\n\n server.watcher.on('add', onChange)\n server.watcher.on('change', onChange)\n server.watcher.on('unlink', onChange)\n\n server.watcher.on('change', (filePath) => {\n if (!isNivelAssetPath(filePath)) {\n return\n }\n\n server.ws.send({ type: 'full-reload' })\n })\n\n server.middlewares.use((req, res, next) => {\n const filePath = getNivelPublicAssetFilePath(req.url)\n\n if (filePath) {\n res.setHeader('Content-Type', getNivelPublicAssetContentType(filePath))\n res.setHeader('Cache-Control', 'no-store')\n res.end(fs.readFileSync(filePath))\n return\n }\n\n if (isNivelAssetRequestUrl(req.url)) {\n res.statusCode = 404\n res.setHeader('Cache-Control', 'no-store')\n res.end()\n return\n }\n\n next()\n })\n },\n handleHotUpdate(ctx) {\n if (isNivelAssetPath(ctx.file)) {\n ctx.server.ws.send({ type: 'full-reload' })\n return []\n }\n\n if (!isDocsSourcePath(ctx.file, ctx.server.config.root)) {\n return\n }\n\n ctx.server.ws.send({ type: 'full-reload' })\n return []\n },\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { nivelPublicRoute } from '../nivelAssets.js'\n\nconst toPosix = (value: string) => value.split(path.sep).join(path.posix.sep)\n\nconst getRequestPathname = (requestUrl: string | undefined) => {\n return requestUrl?.split('?')[0]?.split('#')[0] ?? ''\n}\n\nconst normalizeNivelAssetPathname = (pathname: string) => {\n if (pathname === nivelPublicRoute) {\n return pathname\n }\n\n if (!pathname.startsWith(`${nivelPublicRoute}/`)) {\n return null\n }\n\n const trimmedPathname = pathname.replace(/\\/+$/g, '')\n if (trimmedPathname !== pathname && path.extname(trimmedPathname)) {\n return trimmedPathname\n }\n\n return pathname\n}\n\nconst getPublicAssetsRootCandidates = (runtimeDir: string) => {\n let packageRoot: string | null = null\n\n try {\n const nivelConfigUrl = import.meta.resolve('@unterberg/nivel/config')\n const nivelConfigPath = fileURLToPath(nivelConfigUrl)\n packageRoot = path.resolve(path.dirname(nivelConfigPath), '..')\n } catch {\n packageRoot = null\n }\n\n return [\n ...(packageRoot ? [path.join(packageRoot, 'assets')] : []),\n path.resolve(runtimeDir, '../assets'),\n path.resolve(runtimeDir, '../../assets'),\n ]\n}\n\nexport const getNivelPublicAssetsRoot = () => {\n const runtimeUrl = import.meta.url.startsWith('/') ? pathToFileURL(import.meta.url).href : import.meta.url\n const runtimeDir = path.dirname(fileURLToPath(runtimeUrl))\n\n for (const candidate of getPublicAssetsRootCandidates(runtimeDir)) {\n if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {\n return candidate\n }\n }\n\n throw new Error(`Unable to locate nivel public assets from ${runtimeDir}.`)\n}\n\nexport const getNivelPublicAssetFilePath = (requestUrl: string | undefined) => {\n const pathname = normalizeNivelAssetPathname(getRequestPathname(requestUrl))\n\n if (!pathname) {\n return null\n }\n\n const assetsRoot = getNivelPublicAssetsRoot()\n const relativePath = pathname.replace(/^\\/+/, '')\n const filePath = path.resolve(assetsRoot, relativePath)\n const relativeToRoot = path.relative(assetsRoot, filePath)\n\n if (\n relativeToRoot.startsWith('..') ||\n path.isAbsolute(relativeToRoot) ||\n !fs.existsSync(filePath) ||\n !fs.statSync(filePath).isFile()\n ) {\n return null\n }\n\n return filePath\n}\n\nexport const getNivelPublicAssetContentType = (filePath: string) => {\n switch (path.extname(filePath)) {\n case '.css':\n return 'text/css; charset=utf-8'\n case '.svg':\n return 'image/svg+xml'\n case '.png':\n return 'image/png'\n case '.ico':\n return 'image/x-icon'\n case '.woff2':\n return 'font/woff2'\n default:\n return 'application/octet-stream'\n }\n}\n\nexport const isNivelAssetRequestUrl = (requestUrl: string | undefined) => {\n return normalizeNivelAssetPathname(getRequestPathname(requestUrl)) !== null\n}\n\nexport const isNivelAssetPath = (filePath: string) => {\n const normalizedFilePath = toPosix(path.resolve(filePath))\n const assetsRoot = toPosix(getNivelPublicAssetsRoot())\n return normalizedFilePath.startsWith(`${assetsRoot}/`)\n}\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAKjB,IAAM,oBAAoB;AAE1B,IAAM,qBAAqB,CAAC,UAAkB,WAAmB;AAC/D,QAAM,UAAU,GAAG,WAAW,QAAQ,IAAI,GAAG,aAAa,UAAU,MAAM,IAAI;AAC9E,MAAI,YAAY,QAAQ;AACtB;AAAA,EACF;AAEA,KAAG,UAAU,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AACxD,KAAG,cAAc,UAAU,MAAM;AACnC;A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AAuB,IAAI,GAAG,GAAG;AACnC,cAAI,aAAa;AACjB,cAAI,UAAU,iBAAiB,UAAU;AACzC,cAAI,IAAI;AACR;AAAA,QACF;AAEA,aAAK;AAAA,MACP,CAAC;AAAA,IACH;AAAA,IACA,gBAAgB,KAAK;AACnB,UAAI,iBAAiB,IAAI,IAAI,GAAG;AAC9B,YAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,eAAO,CAAC;AAAA,MACV;AAEA,UAAI,CAAC,iBAAiB,IAAI,MAAM,IAAI,OAAO,OAAO,IAAI,GAAG;AACvD;AAAA,MACF;AAEA,UAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AACF;","names":["fs","path","fs","path","toPosix","path","fs","path","fs"]}
@@ -0,0 +1,70 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, ComponentType } from 'react';
4
+ import { D as DocsConfig, T as ThemePreference, p as DocsThemeConfig } from './types-mvLNHHrf.js';
5
+ import * as _classmatejs_react from '@classmatejs/react';
6
+ import * as zustand_middleware from 'zustand/middleware';
7
+ import * as zustand from 'zustand';
8
+
9
+ interface AppLayoutProps {
10
+ children: ReactNode;
11
+ docsConfig: DocsConfig;
12
+ }
13
+ declare const AppLayout: ({ children, docsConfig }: AppLayoutProps) => react_jsx_runtime.JSX.Element;
14
+
15
+ declare const LayoutSize: {
16
+ readonly xxs: "xxs";
17
+ readonly xs: "xs";
18
+ readonly sm: "sm";
19
+ readonly md: "md";
20
+ readonly lg: "lg";
21
+ readonly xl: "xl";
22
+ readonly full: "full";
23
+ };
24
+ type LayoutSize = (typeof LayoutSize)[keyof typeof LayoutSize];
25
+ interface LayoutComponentProps {
26
+ $size?: LayoutSize;
27
+ $noGrow?: boolean;
28
+ }
29
+ declare const LayoutComponent: _classmatejs_react.CmBaseComponent<react.ClassAttributes<HTMLDivElement> & react.HTMLAttributes<HTMLDivElement> & LayoutComponentProps & Partial<LayoutComponentProps>>;
30
+
31
+ declare const MetaHead: ({ docsConfig }: {
32
+ docsConfig: DocsConfig;
33
+ }) => react_jsx_runtime.JSX.Element;
34
+
35
+ declare const ProseContainer: _classmatejs_react.CmBaseComponent<react.ClassAttributes<HTMLElement> & react.HTMLAttributes<HTMLElement> & object>;
36
+
37
+ declare const UserSettingsSync: ({ theme }: {
38
+ theme?: DocsConfig["theme"];
39
+ }) => null;
40
+
41
+ interface DocsPageProps {
42
+ Content: ComponentType;
43
+ docsConfig: DocsConfig;
44
+ }
45
+ declare const DocsPage: ({ Content, docsConfig }: DocsPageProps) => react_jsx_runtime.JSX.Element;
46
+
47
+ type DocsUserSettingsState = {
48
+ codeBlockChoices: Record<string, string>;
49
+ themePreference: ThemePreference | null;
50
+ setCodeBlockChoice: (choiceGroupName: string, choice: string) => void;
51
+ setThemePreference: (themePreference: ThemePreference) => void;
52
+ };
53
+ declare const useDocsUserSettingsStore: zustand.UseBoundStore<Omit<zustand.StoreApi<DocsUserSettingsState>, "setState" | "persist"> & {
54
+ setState(partial: DocsUserSettingsState | Partial<DocsUserSettingsState> | ((state: DocsUserSettingsState) => DocsUserSettingsState | Partial<DocsUserSettingsState>), replace?: false | undefined): unknown;
55
+ setState(state: DocsUserSettingsState | ((state: DocsUserSettingsState) => DocsUserSettingsState), replace: true): unknown;
56
+ persist: {
57
+ setOptions: (options: Partial<zustand_middleware.PersistOptions<DocsUserSettingsState, unknown, unknown>>) => void;
58
+ clearStorage: () => void;
59
+ rehydrate: () => Promise<void> | void;
60
+ hasHydrated: () => boolean;
61
+ onHydrate: (fn: (state: DocsUserSettingsState) => void) => () => void;
62
+ onFinishHydration: (fn: (state: DocsUserSettingsState) => void) => () => void;
63
+ getOptions: () => Partial<zustand_middleware.PersistOptions<DocsUserSettingsState, unknown, unknown>>;
64
+ };
65
+ }>;
66
+
67
+ declare const DEFAULT_THEME_PREFERENCE: ThemePreference;
68
+ declare const applyThemePreference: (themePreference: ThemePreference | null | undefined, themeConfig: Required<DocsThemeConfig>) => void;
69
+
70
+ export { AppLayout, DEFAULT_THEME_PREFERENCE, DocsPage, LayoutComponent, MetaHead, ProseContainer, UserSettingsSync, applyThemePreference, useDocsUserSettingsStore };
package/dist/client.js ADDED
@@ -0,0 +1,26 @@
1
+ import {
2
+ AppLayout,
3
+ DEFAULT_THEME_PREFERENCE,
4
+ DocsPage,
5
+ LayoutComponent,
6
+ MetaHead,
7
+ ProseContainer,
8
+ UserSettingsSync,
9
+ applyThemePreference,
10
+ useDocsUserSettingsStore
11
+ } from "./chunk-62MBEYU7.js";
12
+ import "./chunk-4WTEOEV2.js";
13
+ import "./chunk-73NPVCDQ.js";
14
+ import "./chunk-FLO5CJZH.js";
15
+ export {
16
+ AppLayout,
17
+ DEFAULT_THEME_PREFERENCE,
18
+ DocsPage,
19
+ LayoutComponent,
20
+ MetaHead,
21
+ ProseContainer,
22
+ UserSettingsSync,
23
+ applyThemePreference,
24
+ useDocsUserSettingsStore
25
+ };
26
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,35 @@
1
+ import { ShikiTransformer } from 'shiki';
2
+
3
+ type ParsedMeta<Name extends string = string> = {
4
+ props: Partial<Record<Name, string>>;
5
+ rest: string;
6
+ tokens: ParsedMetaToken[];
7
+ };
8
+ type ParsedMetaToken = {
9
+ hasExplicitValue: boolean;
10
+ name: string;
11
+ raw: string;
12
+ value?: string;
13
+ };
14
+ declare const parseMetaString: <Name extends string = string>(meta: unknown, propNames?: Name[]) => ParsedMeta<Name>;
15
+ declare const getCodeBlockPropsFromMeta: (meta: unknown) => {
16
+ props: Record<string, string>;
17
+ title: string | null;
18
+ };
19
+
20
+ declare const rehypeMetaToProps: () => (tree: unknown) => void;
21
+
22
+ declare const remarkChoiceGroup: () => (tree: unknown) => void;
23
+
24
+ declare const remarkDetype: () => (tree: unknown, file: any) => Promise<void>;
25
+
26
+ declare const remarkPkgManager: () => (tree: unknown) => void;
27
+
28
+ declare const shikiTransformerAutoLinks: () => ShikiTransformer;
29
+
30
+ declare const getCodeBlockMdxPlugins: () => {
31
+ remarkPlugins: any[];
32
+ rehypePlugins: any[];
33
+ };
34
+
35
+ export { getCodeBlockMdxPlugins, getCodeBlockPropsFromMeta, parseMetaString, rehypeMetaToProps, remarkChoiceGroup, remarkDetype, remarkPkgManager, shikiTransformerAutoLinks };
@@ -0,0 +1,21 @@
1
+ import {
2
+ getCodeBlockMdxPlugins,
3
+ getCodeBlockPropsFromMeta,
4
+ parseMetaString,
5
+ rehypeMetaToProps,
6
+ remarkChoiceGroup,
7
+ remarkDetype,
8
+ remarkPkgManager,
9
+ shikiTransformerAutoLinks
10
+ } from "./chunk-45CLUNJW.js";
11
+ export {
12
+ getCodeBlockMdxPlugins,
13
+ getCodeBlockPropsFromMeta,
14
+ parseMetaString,
15
+ rehypeMetaToProps,
16
+ remarkChoiceGroup,
17
+ remarkDetype,
18
+ remarkPkgManager,
19
+ shikiTransformerAutoLinks
20
+ };
21
+ //# sourceMappingURL=code-blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,16 @@
1
+ declare const nivelConfig: {
2
+ meta: {
3
+ docs: {
4
+ env: {
5
+ server: true;
6
+ client: true;
7
+ };
8
+ global: true;
9
+ };
10
+ };
11
+ prerender: true;
12
+ trailingSlash: true;
13
+ vite: Record<string, unknown>;
14
+ };
15
+
16
+ export { nivelConfig as default };
package/dist/config.js ADDED
@@ -0,0 +1,101 @@
1
+ import {
2
+ getCodeBlockMdxPlugins
3
+ } from "./chunk-45CLUNJW.js";
4
+ import {
5
+ nivelPagesPlugin
6
+ } from "./chunk-PHHK2BAF.js";
7
+ import {
8
+ createHeadingSlugger,
9
+ normalizeHeadingTitle
10
+ } from "./chunk-73NPVCDQ.js";
11
+ import "./chunk-FLO5CJZH.js";
12
+
13
+ // src/config.ts
14
+ import mdx from "@mdx-js/rollup";
15
+ import remarkGfm from "remark-gfm";
16
+
17
+ // src/runtime/rehypeDocsHeadings.ts
18
+ import { visit } from "unist-util-visit";
19
+ var headingTags = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
20
+ var getNodeText = (node) => {
21
+ if (!node || typeof node !== "object") {
22
+ return "";
23
+ }
24
+ if (node.type === "text") {
25
+ return typeof node.value === "string" ? node.value : "";
26
+ }
27
+ if (Array.isArray(node.children)) {
28
+ return node.children.map((child) => getNodeText(child)).join("");
29
+ }
30
+ return "";
31
+ };
32
+ var getClassNames = (value) => {
33
+ if (Array.isArray(value)) {
34
+ return value.flatMap((entry) => getClassNames(entry));
35
+ }
36
+ if (typeof value === "string") {
37
+ return value.split(/\s+/).filter(Boolean);
38
+ }
39
+ return [];
40
+ };
41
+ var rehypeDocsHeadings = () => {
42
+ return (tree) => {
43
+ const slugify = createHeadingSlugger();
44
+ visit(tree, "element", (node) => {
45
+ if (!headingTags.has(node?.tagName)) {
46
+ return;
47
+ }
48
+ const title = normalizeHeadingTitle(getNodeText(node));
49
+ if (!title) {
50
+ return;
51
+ }
52
+ node.properties ??= {};
53
+ if (typeof node.properties.id !== "string" || node.properties.id === "") {
54
+ node.properties.id = slugify(title);
55
+ }
56
+ const classNames = getClassNames(node.properties.className);
57
+ if (!classNames.includes("scroll-mt-24")) {
58
+ node.properties.className = [...classNames, "scroll-mt-24"];
59
+ }
60
+ });
61
+ };
62
+ };
63
+
64
+ // src/config.ts
65
+ process.env.VIKE_CRAWL ??= JSON.stringify({ git: false });
66
+ var codeBlockMdxPlugins = getCodeBlockMdxPlugins();
67
+ var viteConfig = {
68
+ plugins: [
69
+ {
70
+ ...mdx({
71
+ providerImportSource: "@unterberg/nivel/mdx",
72
+ ...codeBlockMdxPlugins,
73
+ rehypePlugins: [...codeBlockMdxPlugins.rehypePlugins, rehypeDocsHeadings],
74
+ remarkPlugins: [remarkGfm, ...codeBlockMdxPlugins.remarkPlugins]
75
+ }),
76
+ enforce: "pre"
77
+ },
78
+ nivelPagesPlugin()
79
+ ],
80
+ ssr: {
81
+ noExternal: ["@unterberg/nivel"]
82
+ }
83
+ };
84
+ var nivelConfig = {
85
+ meta: {
86
+ docs: {
87
+ env: {
88
+ server: true,
89
+ client: true
90
+ },
91
+ global: true
92
+ }
93
+ },
94
+ prerender: true,
95
+ trailingSlash: true,
96
+ vite: viteConfig
97
+ };
98
+ export {
99
+ nivelConfig as default
100
+ };
101
+ //# sourceMappingURL=config.js.map