@unterberg/nivel 0.1.14 → 0.2.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 (51) hide show
  1. package/README.md +8 -9
  2. package/dist/{SearchModal-YJZFUB53.js → SearchModal-Q2MTOIZU.js} +4 -4
  3. package/dist/SearchModal-Q2MTOIZU.js.map +1 -0
  4. package/dist/{chunk-SH5XWPXW.js → chunk-AQJQDMKW.js} +181 -106
  5. package/dist/chunk-AQJQDMKW.js.map +1 -0
  6. package/dist/{chunk-SOVTSE5J.js → chunk-AT4O3RRN.js} +8 -2
  7. package/dist/chunk-AT4O3RRN.js.map +1 -0
  8. package/dist/{chunk-PKXDOKJY.js → chunk-C724XH47.js} +23 -18
  9. package/dist/chunk-C724XH47.js.map +1 -0
  10. package/dist/{chunk-NGX2C26M.js → chunk-GFZ3P4F4.js} +556 -15
  11. package/dist/chunk-GFZ3P4F4.js.map +1 -0
  12. package/dist/{chunk-R6O4NLHC.js → chunk-I75ALNG2.js} +6 -2
  13. package/dist/chunk-I75ALNG2.js.map +1 -0
  14. package/dist/chunk-WMHFKLPG.js +124 -0
  15. package/dist/chunk-WMHFKLPG.js.map +1 -0
  16. package/dist/cli.js +2 -3
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.d.ts +2 -1
  19. package/dist/client.js +3 -4
  20. package/dist/icons.d.ts +1 -0
  21. package/dist/icons.js +11638 -0
  22. package/dist/icons.js.map +1 -0
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +2 -9
  25. package/dist/mdx/code-blocks.d.ts +1 -1
  26. package/dist/mdx.js +2 -4
  27. package/dist/mdx.js.map +1 -1
  28. package/dist/runtime/client.d.ts +2 -1
  29. package/dist/runtime/client.js +3 -4
  30. package/dist/runtime/node.d.ts +2 -1
  31. package/dist/runtime/node.js +6 -8
  32. package/dist/{types-IiJ1jLWc.d.ts → types-Duk127zu.d.ts} +20 -2
  33. package/dist/vike.d.ts +2 -1
  34. package/dist/vike.js +7 -9
  35. package/dist/vike.js.map +1 -1
  36. package/package.json +10 -9
  37. package/dist/SearchModal-YJZFUB53.js.map +0 -1
  38. package/dist/chunk-JSZZPQEP.js +0 -9
  39. package/dist/chunk-JSZZPQEP.js.map +0 -1
  40. package/dist/chunk-L6ZVB6XH.js +0 -36
  41. package/dist/chunk-L6ZVB6XH.js.map +0 -1
  42. package/dist/chunk-NGX2C26M.js.map +0 -1
  43. package/dist/chunk-PKXDOKJY.js.map +0 -1
  44. package/dist/chunk-QWIYQPCW.js +0 -404
  45. package/dist/chunk-QWIYQPCW.js.map +0 -1
  46. package/dist/chunk-R6O4NLHC.js.map +0 -1
  47. package/dist/chunk-SH5XWPXW.js.map +0 -1
  48. package/dist/chunk-SOVTSE5J.js.map +0 -1
  49. package/dist/config.d.ts +0 -6
  50. package/dist/config.js +0 -9
  51. package/dist/config.js.map +0 -1
@@ -1,15 +1,421 @@
1
1
  import {
2
- extractDocHeadings
3
- } from "./chunk-SOVTSE5J.js";
2
+ extractDocHeadings,
3
+ getDocsIconMapKey
4
+ } from "./chunk-AT4O3RRN.js";
4
5
  import {
5
- getResolvedPageById,
6
- resolveDocsConfig
7
- } from "./chunk-QWIYQPCW.js";
6
+ nivelAssetUrl,
7
+ resolvePublicAssetUrl,
8
+ withSiteBaseUrl
9
+ } from "./chunk-PYYPYIBD.js";
10
+
11
+ // src/docs/icons.ts
12
+ import * as lucideIcons from "lucide-react";
13
+ var excludedLucideExports = /* @__PURE__ */ new Set(["createLucideIcon", "Icon", "icons", "LucideProvider", "useLucideContext"]);
14
+ var isLucideIconExport = (value) => {
15
+ if (typeof value !== "object" || value === null) {
16
+ return false;
17
+ }
18
+ return "$$typeof" in value && "render" in value;
19
+ };
20
+ var docsIconNames = Object.freeze(
21
+ Object.entries(lucideIcons).filter(([name, value]) => !excludedLucideExports.has(name) && isLucideIconExport(value)).map(([name]) => name).sort()
22
+ );
23
+ var docsIconNameSet = new Set(docsIconNames);
24
+ var isDocsIconName = (value) => {
25
+ return docsIconNameSet.has(value);
26
+ };
27
+ var assertDocsIconName = (value, context) => {
28
+ if (isDocsIconName(value)) {
29
+ return;
30
+ }
31
+ throw new Error(
32
+ `${context} must be a valid lucide-react icon export. Received "${value}". See https://lucide.dev/icons/`
33
+ );
34
+ };
35
+
36
+ // src/docs/resolveDocsConfig.ts
37
+ var isExternalHref = (value) => {
38
+ return /^(?:[a-z]+:)?\/\//i.test(value) || value.startsWith("mailto:") || value.startsWith("tel:");
39
+ };
40
+ var normalizeBasePath = (value) => {
41
+ const normalized = value.trim();
42
+ if (!normalized) {
43
+ throw new Error("Docs basePath must be a non-empty absolute path.");
44
+ }
45
+ if (!normalized.startsWith("/") || normalized.startsWith("//")) {
46
+ throw new Error(`Docs basePath must start with "/". Received ${JSON.stringify(value)}.`);
47
+ }
48
+ if (normalized.includes("?") || normalized.includes("#")) {
49
+ throw new Error(`Docs basePath cannot include query strings or hashes. Received ${JSON.stringify(value)}.`);
50
+ }
51
+ const collapsed = normalized.replace(/\/+/g, "/").replace(/\/+$/g, "");
52
+ return collapsed === "" ? "/" : collapsed;
53
+ };
54
+ var normalizeContentDir = (value) => {
55
+ const normalized = (value ?? "docs").trim();
56
+ if (!normalized) {
57
+ throw new Error("Docs contentDir must be a non-empty project-relative path.");
58
+ }
59
+ if (normalized.startsWith("/") || normalized.startsWith("\\")) {
60
+ throw new Error(`Docs contentDir must be project-relative. Received ${JSON.stringify(value)}.`);
61
+ }
62
+ if (/^[a-zA-Z]:[\\/]/.test(normalized)) {
63
+ throw new Error(`Docs contentDir must be project-relative. Received ${JSON.stringify(value)}.`);
64
+ }
65
+ const segments = normalized.replaceAll("\\", "/").split("/");
66
+ const resolvedSegments = [];
67
+ for (const segment of segments) {
68
+ if (segment === "" || segment === ".") {
69
+ continue;
70
+ }
71
+ if (segment === "..") {
72
+ throw new Error(`Docs contentDir cannot escape the project root. Received ${JSON.stringify(value)}.`);
73
+ }
74
+ resolvedSegments.push(segment);
75
+ }
76
+ if (resolvedSegments.length === 0) {
77
+ throw new Error(`Docs contentDir must contain at least one path segment. Received ${JSON.stringify(value)}.`);
78
+ }
79
+ return resolvedSegments.join("/");
80
+ };
81
+ var normalizeSlug = (value) => value.replace(/^\/+|\/+$/g, "");
82
+ var joinDocsHref = (basePath, slug) => {
83
+ const normalizedBasePath = normalizeBasePath(basePath);
84
+ const normalizedSlug = normalizeSlug(slug);
85
+ if (!normalizedSlug) {
86
+ return normalizedBasePath === "/" ? "/" : `${normalizedBasePath}/`;
87
+ }
88
+ return normalizedBasePath === "/" ? `/${normalizedSlug}/` : `${normalizedBasePath}/${normalizedSlug}/`;
89
+ };
90
+ var normalizePathname = (value) => {
91
+ const pathname = value.split("?")[0]?.split("#")[0] ?? value;
92
+ const normalized = pathname.trim().replace(/\/+$/g, "");
93
+ return normalized === "" ? "/" : `${normalized}/`.replace(/\/+/g, "/");
94
+ };
95
+ var resolveDocsHref = (basePath, href) => {
96
+ const normalized = href.trim();
97
+ if (!normalized || normalized.startsWith("#") || isExternalHref(normalized)) {
98
+ return null;
99
+ }
100
+ const pathname = normalized.split("?")[0]?.split("#")[0] ?? normalized;
101
+ if (!pathname) {
102
+ return null;
103
+ }
104
+ if (pathname.startsWith("/")) {
105
+ const normalizedPathname = normalizePathname(pathname);
106
+ const normalizedBasePath = normalizeBasePath(basePath);
107
+ if (normalizedBasePath === "/") {
108
+ return normalizedPathname;
109
+ }
110
+ return normalizedPathname === `${normalizedBasePath}/` || normalizedPathname.startsWith(`${normalizedBasePath}/`) ? normalizedPathname : null;
111
+ }
112
+ if (pathname.startsWith("./") || pathname.startsWith("../")) {
113
+ return null;
114
+ }
115
+ return joinDocsHref(basePath, pathname);
116
+ };
117
+ var normalizeSourcePath = (value) => {
118
+ const segments = value.replaceAll("\\", "/").split("/");
119
+ const normalizedSegments = [];
120
+ for (const segment of segments) {
121
+ if (segment === "" || segment === ".") {
122
+ continue;
123
+ }
124
+ if (segment === "..") {
125
+ normalizedSegments.pop();
126
+ continue;
127
+ }
128
+ normalizedSegments.push(segment);
129
+ }
130
+ return normalizedSegments.join("/");
131
+ };
132
+ var getSectionHref = (items, visibleOnly = false) => {
133
+ for (const item of items) {
134
+ if (item.kind === "page") {
135
+ if (visibleOnly && !item.showInNav) {
136
+ continue;
137
+ }
138
+ return item.href;
139
+ }
140
+ if (item.kind === "group") {
141
+ if (visibleOnly && !item.showInNav) {
142
+ continue;
143
+ }
144
+ const href = getSectionHref(item.items, visibleOnly);
145
+ if (href) {
146
+ return href;
147
+ }
148
+ }
149
+ }
150
+ return null;
151
+ };
152
+ var resolveNavigationHref = (value, fieldName, basePath) => {
153
+ const normalized = value.trim();
154
+ if (!normalized) {
155
+ throw new Error(`Docs ${fieldName} must be a non-empty string.`);
156
+ }
157
+ if (normalized.startsWith("#") || isExternalHref(normalized)) {
158
+ return normalized;
159
+ }
160
+ if (!normalized.startsWith("/")) {
161
+ return joinDocsHref(basePath, normalized);
162
+ }
163
+ return normalizePathname(normalized);
164
+ };
165
+ var resolveThemeConfig = (theme) => {
166
+ return {
167
+ light: theme?.light ?? "consumer-light",
168
+ dark: theme?.dark ?? "consumer-dark",
169
+ defaultPreference: theme?.defaultPreference ?? "light"
170
+ };
171
+ };
172
+ var resolveFooterConfig = (footer) => {
173
+ return {
174
+ pagination: footer?.pagination ?? false
175
+ };
176
+ };
177
+ var resolveBrandConfig = (brand, siteTitle) => {
178
+ const text = brand?.text ?? siteTitle;
179
+ return {
180
+ text,
181
+ href: withSiteBaseUrl(brand?.href ?? "/"),
182
+ logoLight: resolvePublicAssetUrl(brand?.logoLight),
183
+ logoDark: resolvePublicAssetUrl(brand?.logoDark),
184
+ logoAlt: brand?.logoAlt ?? `${text} logo`
185
+ };
186
+ };
187
+ var resolveHeadConfig = (head) => {
188
+ const fontPreset = head?.fontPreset ?? "inter";
189
+ const defaultFontStylesheetHref = fontPreset === "inter" ? nivelAssetUrl("fonts/fonts-inter.css") : void 0;
190
+ const defaultFontPreloadHrefs = fontPreset === "inter" ? [
191
+ nivelAssetUrl("fonts/inter-v20-latin-regular.woff2"),
192
+ nivelAssetUrl("fonts/inter-v20-latin-600.woff2"),
193
+ nivelAssetUrl("fonts/inter-v20-latin-800.woff2")
194
+ ] : [];
195
+ return {
196
+ faviconSvg: resolvePublicAssetUrl(head?.faviconSvg),
197
+ faviconIco: resolvePublicAssetUrl(head?.faviconIco),
198
+ appleTouchIcon: resolvePublicAssetUrl(head?.appleTouchIcon),
199
+ fontPreset,
200
+ fontStylesheetHref: head?.fontStylesheetHref ?? defaultFontStylesheetHref,
201
+ fontPreloadHrefs: head?.fontPreloadHrefs ?? defaultFontPreloadHrefs
202
+ };
203
+ };
204
+ var resolvePartnerAssetUrl = (value) => {
205
+ if (!value) {
206
+ return void 0;
207
+ }
208
+ return resolvePublicAssetUrl(value);
209
+ };
210
+ var resolvePartner = (partner) => {
211
+ return {
212
+ name: partner.name,
213
+ href: withSiteBaseUrl(partner.href),
214
+ logoLight: resolvePartnerAssetUrl(partner.logoLight) ?? partner.logoLight,
215
+ logoDark: resolvePartnerAssetUrl(partner.logoDark),
216
+ logoAlt: partner.logoAlt ?? `${partner.name} logo`
217
+ };
218
+ };
219
+ var resolveSocialConfig = (social) => {
220
+ return {
221
+ ...social
222
+ };
223
+ };
224
+ var resolvePartnersConfig = (partners) => {
225
+ return {
226
+ primary: (partners?.primary ?? []).map(resolvePartner),
227
+ gold: (partners?.gold ?? []).map(resolvePartner)
228
+ };
229
+ };
230
+ var requireTrimmedString = (value, fieldName) => {
231
+ const normalized = value.trim();
232
+ if (!normalized) {
233
+ throw new Error(`Docs algolia config "${fieldName}" must be a non-empty string.`);
234
+ }
235
+ return normalized;
236
+ };
237
+ var resolveAlgoliaConfig = (algolia) => {
238
+ if (!algolia) {
239
+ return null;
240
+ }
241
+ return {
242
+ appId: requireTrimmedString(algolia.appId, "appId"),
243
+ apiKey: requireTrimmedString(algolia.apiKey, "apiKey"),
244
+ indexName: requireTrimmedString(algolia.indexName, "indexName"),
245
+ fields: {
246
+ href: algolia.fields?.href?.trim() || "href",
247
+ title: algolia.fields?.title?.trim() || "title",
248
+ excerpt: algolia.fields?.excerpt?.trim() || "excerpt",
249
+ sectionTitle: algolia.fields?.sectionTitle?.trim() || "sectionTitle"
250
+ },
251
+ searchParams: algolia.searchParams ?? {}
252
+ };
253
+ };
254
+ var normalizeAliases = (aliases, slug) => {
255
+ const normalizedAliases = /* @__PURE__ */ new Set();
256
+ for (const alias of aliases ?? []) {
257
+ const normalizedAlias = normalizeSlug(alias);
258
+ if (!normalizedAlias || normalizedAlias === slug) {
259
+ continue;
260
+ }
261
+ normalizedAliases.add(normalizedAlias);
262
+ }
263
+ return [...normalizedAliases];
264
+ };
265
+ var resolveDocsConfig = (config) => {
266
+ const normalizedBasePath = normalizeBasePath(config.basePath);
267
+ const normalizedContentDir = normalizeContentDir(config.contentDir);
268
+ const pageIds = /* @__PURE__ */ new Set();
269
+ const pageSlugs = /* @__PURE__ */ new Set();
270
+ const pageAliases = /* @__PURE__ */ new Set();
271
+ const groupIds = /* @__PURE__ */ new Set();
272
+ const sectionIds = /* @__PURE__ */ new Set();
273
+ const pages = [];
274
+ const navbarItems = [];
275
+ const resolveSidebarNodes = (nodes, sectionId) => {
276
+ return nodes.map((node) => {
277
+ if (node.kind === "group") {
278
+ if (groupIds.has(node.id)) {
279
+ throw new Error(`Duplicate docs group id "${node.id}".`);
280
+ }
281
+ if (node.icon) {
282
+ assertDocsIconName(node.icon, `Docs group "${node.id}" icon`);
283
+ }
284
+ groupIds.add(node.id);
285
+ return {
286
+ kind: "group",
287
+ id: node.id,
288
+ title: node.title,
289
+ href: node.href ? resolveNavigationHref(node.href, `group "${node.id}" href`, normalizedBasePath) : void 0,
290
+ showInNav: node.showInNav ?? true,
291
+ collapsible: node.collapsible,
292
+ items: resolveSidebarNodes(node.items, sectionId),
293
+ icon: node.icon
294
+ };
295
+ }
296
+ if (node.kind !== "page") {
297
+ throw new Error(`Invalid docs sidebar node: ${JSON.stringify(node)}`);
298
+ }
299
+ const pageNode = node;
300
+ const slug = normalizeSlug(pageNode.slug);
301
+ const aliases = normalizeAliases(pageNode.aliases, slug);
302
+ if (pageNode.icon) {
303
+ assertDocsIconName(pageNode.icon, `Docs page "${pageNode.id}" icon`);
304
+ }
305
+ if (!slug) {
306
+ throw new Error(`Docs page "${pageNode.id}" must define a non-empty slug.`);
307
+ }
308
+ if (pageIds.has(pageNode.id)) {
309
+ throw new Error(`Duplicate docs page id "${pageNode.id}".`);
310
+ }
311
+ if (pageSlugs.has(slug)) {
312
+ throw new Error(`Duplicate docs page slug "${slug}".`);
313
+ }
314
+ for (const alias of aliases) {
315
+ if (pageSlugs.has(alias) || pageAliases.has(alias)) {
316
+ throw new Error(`Duplicate docs page alias "${alias}".`);
317
+ }
318
+ }
319
+ pageIds.add(pageNode.id);
320
+ pageSlugs.add(slug);
321
+ for (const alias of aliases) {
322
+ pageAliases.add(alias);
323
+ }
324
+ const href = joinDocsHref(normalizedBasePath, slug);
325
+ const page = {
326
+ ...pageNode,
327
+ slug,
328
+ aliases,
329
+ href,
330
+ aliasHrefs: aliases.map((alias) => joinDocsHref(normalizedBasePath, alias)),
331
+ tableOfContents: pageNode.tableOfContents ?? true,
332
+ sectionId,
333
+ documentTitle: `${pageNode.title} | ${config.siteTitle}`,
334
+ source: normalizeSourcePath(pageNode.source)
335
+ };
336
+ pages.push(page);
337
+ return {
338
+ kind: "page",
339
+ id: pageNode.id,
340
+ title: pageNode.title,
341
+ navTitle: pageNode.navTitle ?? pageNode.title,
342
+ href,
343
+ showInNav: pageNode.showInNav ?? true,
344
+ icon: pageNode.icon
345
+ };
346
+ });
347
+ };
348
+ const sections = config.graph.items.map((section) => {
349
+ if (section.kind !== "section") {
350
+ throw new Error(`Top-level docs graph items must be sections. Received ${JSON.stringify(section)}`);
351
+ }
352
+ if (sectionIds.has(section.id)) {
353
+ throw new Error(`Duplicate docs section id "${section.id}".`);
354
+ }
355
+ if (section.icon) {
356
+ assertDocsIconName(section.icon, `Docs section "${section.id}" icon`);
357
+ }
358
+ sectionIds.add(section.id);
359
+ const items = resolveSidebarNodes(section.items, section.id);
360
+ const firstVisibleHref = getSectionHref(items, true);
361
+ const href = section.href ? resolveNavigationHref(section.href, `section "${section.id}" href`, normalizedBasePath) : firstVisibleHref ?? getSectionHref(items);
362
+ if (!href) {
363
+ throw new Error(`Docs section "${section.id}" must contain at least one page.`);
364
+ }
365
+ const resolvedSection = {
366
+ id: section.id,
367
+ title: section.title,
368
+ navTitle: section.navTitle ?? section.title,
369
+ href,
370
+ items,
371
+ icon: section.icon
372
+ };
373
+ navbarItems.push({
374
+ id: section.id,
375
+ title: resolvedSection.navTitle,
376
+ href: resolvedSection.href
377
+ });
378
+ return resolvedSection;
379
+ });
380
+ if (pages.length === 0) {
381
+ throw new Error("Docs graph must contain at least one page.");
382
+ }
383
+ return {
384
+ siteTitle: config.siteTitle,
385
+ siteDescription: config.siteDescription ?? null,
386
+ basePath: normalizedBasePath,
387
+ contentDir: normalizedContentDir,
388
+ theme: resolveThemeConfig(config.theme),
389
+ footer: resolveFooterConfig(config.footer),
390
+ brand: resolveBrandConfig(config.brand, config.siteTitle),
391
+ head: resolveHeadConfig(config.head),
392
+ partners: resolvePartnersConfig(config.partners),
393
+ social: resolveSocialConfig(config.social),
394
+ algolia: resolveAlgoliaConfig(config.algolia),
395
+ pages,
396
+ sections,
397
+ navbarItems
398
+ };
399
+ };
400
+ var getResolvedPageById = (config, pageId) => {
401
+ const page = config.pages.find((candidate) => candidate.id === pageId);
402
+ if (!page) {
403
+ throw new Error(`Unknown docs page id "${pageId}".`);
404
+ }
405
+ return page;
406
+ };
8
407
 
9
408
  // src/runtime/node/codegen.ts
10
409
  import fs from "fs";
410
+ import { createRequire } from "module";
11
411
  import path from "path";
12
412
  var GENERATED_DIRNAME = "(nivel-generated)";
413
+ var require2 = createRequire(import.meta.url);
414
+ var lucidePackageRoot = path.dirname(require2.resolve("lucide-react/package.json"));
415
+ var lucideEsmEntryPath = path.join(lucidePackageRoot, "dist", "esm", "lucide-react.js");
416
+ var lucideEsmIconsDirectoryPath = path.join(lucidePackageRoot, "dist", "esm", "icons");
417
+ var lucideIconModuleNameByExportName = null;
418
+ var lucideIconNodeByName = /* @__PURE__ */ new Map();
13
419
  var writeFileIfChanged = (filePath, source) => {
14
420
  const current = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : null;
15
421
  if (current === source) {
@@ -94,11 +500,138 @@ var getGeneratedDataSource = (data) => {
94
500
  ""
95
501
  ].join("\n");
96
502
  };
503
+ var getSidebarIconEntries = (nodes) => {
504
+ return nodes.flatMap((node) => {
505
+ const iconEntries = node.icon ? [{ iconKey: getDocsIconMapKey(node.kind, node.id), iconName: node.icon }] : [];
506
+ if (node.kind === "group") {
507
+ return [...iconEntries, ...getSidebarIconEntries(node.items)];
508
+ }
509
+ return iconEntries;
510
+ });
511
+ };
512
+ var getGeneratedIconMapSource = (entries) => {
513
+ if (entries.length === 0) {
514
+ return "{}";
515
+ }
516
+ return ["{", ...entries.map(({ iconKey, iconName }) => ` ${JSON.stringify(iconKey)}: ${iconName},`), "}"].join("\n");
517
+ };
518
+ var getLucideIconModuleNameByExportName = () => {
519
+ if (lucideIconModuleNameByExportName) {
520
+ return lucideIconModuleNameByExportName;
521
+ }
522
+ const lucideEntrySource = fs.readFileSync(lucideEsmEntryPath, "utf8");
523
+ const exportMap = /* @__PURE__ */ new Map();
524
+ const exportPattern = /export\s+\{\s*([\s\S]*?)\s*\}\s+from\s+'\.\/icons\/([^']+)\.js';/g;
525
+ for (const match of lucideEntrySource.matchAll(exportPattern)) {
526
+ const exportsSource = match[1];
527
+ const moduleName = match[2];
528
+ if (!exportsSource || !moduleName) {
529
+ continue;
530
+ }
531
+ for (const exportPart of exportsSource.split(",").map((value) => value.trim())) {
532
+ const exportMatch = /^default as (\w+)$/.exec(exportPart);
533
+ if (!exportMatch?.[1]) {
534
+ continue;
535
+ }
536
+ exportMap.set(exportMatch[1], moduleName);
537
+ }
538
+ }
539
+ lucideIconModuleNameByExportName = exportMap;
540
+ return exportMap;
541
+ };
542
+ var getDocsIconNode = (iconName) => {
543
+ const cachedIconNode = lucideIconNodeByName.get(iconName);
544
+ if (cachedIconNode) {
545
+ return cachedIconNode;
546
+ }
547
+ const moduleName = getLucideIconModuleNameByExportName().get(iconName);
548
+ if (!moduleName) {
549
+ throw new Error(`Unable to resolve lucide-react module for docs icon "${iconName}".`);
550
+ }
551
+ const iconModuleSource = fs.readFileSync(path.join(lucideEsmIconsDirectoryPath, `${moduleName}.js`), "utf8");
552
+ const iconNodeMatch = /const __iconNode = (\[[\s\S]*?\]);\s*const /.exec(iconModuleSource);
553
+ if (!iconNodeMatch?.[1]) {
554
+ throw new Error(`Unable to read lucide-react icon node for docs icon "${iconName}".`);
555
+ }
556
+ const iconNode = Function(`"use strict"; return (${iconNodeMatch[1]})`)();
557
+ lucideIconNodeByName.set(iconName, iconNode);
558
+ return iconNode;
559
+ };
560
+ var getGeneratedIconDefinitionsSource = (iconNames) => {
561
+ if (iconNames.length === 0) {
562
+ return [];
563
+ }
564
+ const definitions = iconNames.flatMap((iconName) => {
565
+ return [`const ${iconName} = createDocsIcon(${JSON.stringify(getDocsIconNode(iconName))})`, ""];
566
+ });
567
+ return [
568
+ "import { createElement, forwardRef, type SVGProps } from 'react'",
569
+ "",
570
+ "type DocsGeneratedIconProps = SVGProps<SVGSVGElement> & {",
571
+ " size?: string | number",
572
+ " absoluteStrokeWidth?: boolean",
573
+ "}",
574
+ "",
575
+ "type DocsGeneratedIconNode = [tagName: string, attrs: Record<string, string>][]",
576
+ "",
577
+ "const docsGeneratedIconSvgAttrs = {",
578
+ " xmlns: 'http://www.w3.org/2000/svg',",
579
+ " fill: 'none',",
580
+ " viewBox: '0 0 24 24',",
581
+ " stroke: 'currentColor',",
582
+ " strokeWidth: 2,",
583
+ " strokeLinecap: 'round',",
584
+ " strokeLinejoin: 'round',",
585
+ "} as const",
586
+ "",
587
+ "const createDocsIcon = (iconNode: DocsGeneratedIconNode) => {",
588
+ " return forwardRef<SVGSVGElement, DocsGeneratedIconProps>(",
589
+ ' ({ color = "currentColor", size = 24, strokeWidth = 2, absoluteStrokeWidth, children, ...props }, ref) => {',
590
+ " const resolvedSize = typeof size === 'number' ? size : Number(size)",
591
+ " const resolvedStrokeWidth =",
592
+ " absoluteStrokeWidth && Number.isFinite(resolvedSize) && resolvedSize > 0",
593
+ " ? (Number(strokeWidth) * 24) / resolvedSize",
594
+ " : strokeWidth",
595
+ "",
596
+ " return createElement(",
597
+ " 'svg',",
598
+ " {",
599
+ " ...docsGeneratedIconSvgAttrs,",
600
+ " ...props,",
601
+ " ref,",
602
+ " width: size,",
603
+ " height: size,",
604
+ " stroke: color,",
605
+ " strokeWidth: resolvedStrokeWidth,",
606
+ " },",
607
+ " ...iconNode.map(([tagName, attrs]) => createElement(tagName, attrs)),",
608
+ " children,",
609
+ " )",
610
+ " },",
611
+ " )",
612
+ "}",
613
+ "",
614
+ ...definitions
615
+ ];
616
+ };
97
617
  var getGeneratedGlobalContextSource = (data) => {
618
+ const iconEntries = data.sidebarSections.flatMap((section) => {
619
+ const sectionIconEntries = section.icon ? [{ iconKey: getDocsIconMapKey("section", section.id), iconName: section.icon }] : [];
620
+ return [...sectionIconEntries, ...getSidebarIconEntries(section.items)];
621
+ });
622
+ const iconImports = [...new Set(iconEntries.map(({ iconName }) => iconName))].sort();
98
623
  return [
99
- "import type { DocsGlobalContextData } from '@unterberg/nivel'",
624
+ "import type { DocsGlobalContextData, DocsGlobalContextSerializableData, DocsIconMap } from '@unterberg/nivel'",
625
+ ...getGeneratedIconDefinitionsSource(iconImports),
626
+ "",
627
+ `const docsGlobalContextSerializableData: DocsGlobalContextSerializableData = ${serializeData(data)}`,
100
628
  "",
101
- `const docsGlobalContextData: DocsGlobalContextData = ${serializeData(data)}`,
629
+ `const docsIconMap: DocsIconMap = ${getGeneratedIconMapSource(iconEntries)}`,
630
+ "",
631
+ "const docsGlobalContextData: DocsGlobalContextData = {",
632
+ " ...docsGlobalContextSerializableData,",
633
+ " docsIconMap,",
634
+ "}",
102
635
  "",
103
636
  "export { docsGlobalContextData }",
104
637
  ""
@@ -141,15 +674,19 @@ var getDocsSourcePaths = (options) => {
141
674
  };
142
675
  var isDocsSourcePath = (filePath, docsSourcePaths) => {
143
676
  const normalized = toPosix(filePath);
144
- const generatedRootPath = toPosix(docsSourcePaths.generatedRootPath);
677
+ if (isGeneratedDocsPath(filePath, docsSourcePaths)) {
678
+ return false;
679
+ }
145
680
  const docsConfigPath = toPosix(docsSourcePaths.docsConfigPath);
146
681
  const docsGraphPath = toPosix(docsSourcePaths.docsGraphPath);
147
682
  const contentRootPath = toPosix(docsSourcePaths.contentRootPath);
148
- if (normalized.startsWith(generatedRootPath)) {
149
- return false;
150
- }
151
683
  return normalized === docsConfigPath || normalized === docsGraphPath || normalized === contentRootPath || normalized.startsWith(`${contentRootPath}/`);
152
684
  };
685
+ var isGeneratedDocsPath = (filePath, docsSourcePaths) => {
686
+ const normalized = toPosix(filePath);
687
+ const generatedRootPath = toPosix(docsSourcePaths.generatedRootPath);
688
+ return normalized.startsWith(generatedRootPath);
689
+ };
153
690
  var syncGeneratedDocsPages = (options) => {
154
691
  const { rootDir, docsConfig } = options;
155
692
  const resolved = resolveDocsConfig(docsConfig);
@@ -290,9 +827,9 @@ var getDocsConfigTemplate = () => {
290
827
  };
291
828
  var getDocsGraphTemplate = () => {
292
829
  return [
293
- "import { defineDocsGraph } from '@unterberg/nivel/config'",
830
+ "import type { DocsGraph } from '@unterberg/nivel'",
294
831
  "",
295
- "export const docsGraph = defineDocsGraph({",
832
+ "export const docsGraph = {",
296
833
  " items: [",
297
834
  " {",
298
835
  " kind: 'section',",
@@ -310,7 +847,7 @@ var getDocsGraphTemplate = () => {
310
847
  " ],",
311
848
  " },",
312
849
  " ],",
313
- "})",
850
+ "} satisfies DocsGraph",
314
851
  ""
315
852
  ].join("\n");
316
853
  };
@@ -729,13 +1266,17 @@ var initConsumer = (options) => {
729
1266
  };
730
1267
 
731
1268
  export {
1269
+ resolveDocsHref,
1270
+ resolveDocsConfig,
1271
+ getResolvedPageById,
732
1272
  getGeneratedPagesRoot,
733
1273
  getDocsSourcePaths,
734
1274
  isDocsSourcePath,
1275
+ isGeneratedDocsPath,
735
1276
  syncGeneratedDocsPages,
736
1277
  loadDocsConfig,
737
1278
  getTailwindBootstrapWarnings,
738
1279
  getInitSummary,
739
1280
  initConsumer
740
1281
  };
741
- //# sourceMappingURL=chunk-NGX2C26M.js.map
1282
+ //# sourceMappingURL=chunk-GFZ3P4F4.js.map