@vendure-io/docs-provider 0.7.0 → 0.8.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.
package/dist/index.js CHANGED
@@ -1,233 +1,362 @@
1
1
  var A = Object.defineProperty;
2
- var B = (e, t, i) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
- var m = (e, t, i) => B(e, typeof t != "symbol" ? t + "" : t, i);
4
- import { B as _, D as ee, a as te, b as re, c as ie, F as oe, G as ne, L as se, M as ae, N as le, d as ce, S as fe, V as de, e as he, f as ue, g as ge, h as me, i as ve, j as Fe, k as Ne, v as Se } from "./manifest-ZCrzbFSf.js";
5
- import { e as M } from "./frontmatter-C0Wmtdep.js";
6
- import { F as xe, h as be, p as $e, v as we } from "./frontmatter-C0Wmtdep.js";
7
- import { s as v, t as F } from "./slug-utils-DVKYe9h8.js";
8
- import { f as Ee, g as Me, a as Ie } from "./slug-utils-DVKYe9h8.js";
9
- import { readdirSync as I, readFileSync as P, statSync as T } from "fs";
10
- import { join as N } from "path";
11
- const V = (e, t) => e.order !== t.order ? e.order - t.order : e.title.localeCompare(t.title);
12
- function K(e, t = {}) {
13
- const { extensions: i = [".mdx", ".md"], filter: r, sort: o = V } = t, n = k(e, i);
14
- return (r ? n.filter(r) : n).sort(o).map((f) => ({
15
- title: f.title,
16
- slug: f.slug,
17
- file: f.path
2
+ var U = (e, t, r) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var v = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as ye, D as Ne, a as Se, b as $e, c as xe, F as be, G as De, L as Pe, M as Me, N as ke, d as Ee, S as Ie, V as We, e as je, f as Ce, g as Ge, h as Le, i as Ve, j as Re, k as Te, v as Be } from "./manifest-DlSWyjsA.js";
5
+ import { e as I } from "./frontmatter-B5d9WZzh.js";
6
+ import { F as ze, h as Ae, p as Ue, v as He } from "./frontmatter-B5d9WZzh.js";
7
+ import { s as F, t as w } from "./slug-utils-DVKYe9h8.js";
8
+ import { f as qe, g as Je, a as Ke } from "./slug-utils-DVKYe9h8.js";
9
+ import { readdirSync as W, readFileSync as j, statSync as H } from "fs";
10
+ import { join as y } from "path";
11
+ import { exec as _ } from "node:child_process";
12
+ import { promisify as q } from "node:util";
13
+ import { writeFile as C, readdir as J } from "node:fs/promises";
14
+ import { join as G, relative as K } from "node:path";
15
+ const L = (e, t) => e.order !== t.order ? e.order - t.order : e.title.localeCompare(t.title);
16
+ function ue(e, t = {}) {
17
+ const { extensions: r = [".mdx", ".md"], filter: i, sort: n = L } = t, s = R(e, r);
18
+ return (i ? s.filter(i) : s).sort(n).map((l) => ({
19
+ title: l.title,
20
+ slug: l.slug,
21
+ file: l.path
18
22
  }));
19
23
  }
20
- function O(e, t = {}) {
21
- return C(e, t, 0);
24
+ function he(e, t = {}) {
25
+ return V(e, t, 0);
22
26
  }
23
- function C(e, t, i) {
27
+ function V(e, t, r) {
24
28
  const {
25
- extensions: r = [".mdx", ".md"],
26
- filter: o,
27
- sort: n = V,
28
- maxDepth: a = 1 / 0,
29
- folderFilter: d
30
- } = t, f = I(e, { withFileTypes: !0 }), h = [], w = k(e, r), S = (o ? w.filter(o) : w).sort(n);
31
- for (const c of S)
32
- h.push({
33
- title: c.title,
34
- slug: c.slug,
35
- file: c.path
29
+ extensions: i = [".mdx", ".md"],
30
+ filter: n,
31
+ sort: s = L,
32
+ maxDepth: o = 1 / 0,
33
+ folderFilter: a
34
+ } = t, l = W(e, { withFileTypes: !0 }), c = [], h = R(e, i), g = (n ? h.filter(n) : h).sort(s);
35
+ for (const u of g)
36
+ c.push({
37
+ title: u.title,
38
+ slug: u.slug,
39
+ file: u.path
36
40
  });
37
- if (i < a) {
38
- const c = f.filter((l) => l.isDirectory());
39
- for (const l of c) {
40
- if (d) {
41
- const s = N(e, l.name);
42
- if (!d(l.name, s))
41
+ if (r < o) {
42
+ const u = l.filter((d) => d.isDirectory());
43
+ for (const d of u) {
44
+ if (a) {
45
+ const f = y(e, d.name);
46
+ if (!a(d.name, f))
43
47
  continue;
44
48
  }
45
- const u = N(e, l.name), g = C(u, t, i + 1);
46
- if (g.length > 0) {
47
- const s = W(u, r);
48
- h.push({
49
- title: (s == null ? void 0 : s.title) || F(l.name),
50
- slug: v(l.name),
51
- file: s == null ? void 0 : s.path,
52
- children: g.filter((y) => !(s && y.file === s.path))
49
+ const m = y(e, d.name), p = V(m, t, r + 1);
50
+ if (p.length > 0) {
51
+ const f = Q(m, i);
52
+ c.push({
53
+ title: (f == null ? void 0 : f.title) || w(d.name),
54
+ slug: F(d.name),
55
+ file: f == null ? void 0 : f.path,
56
+ children: p.filter((S) => !(f && S.file === f.path))
53
57
  });
54
58
  }
55
59
  }
56
60
  }
57
- return h.sort((c, l) => {
58
- var D, E;
59
- const u = S.find((x) => x.slug === c.slug), g = S.find((x) => x.slug === l.slug);
60
- if (u && g)
61
- return n(u, g);
62
- const s = !!c.file && !((D = c.children) != null && D.length), y = !!l.file && !((E = l.children) != null && E.length);
63
- return s !== y ? s ? -1 : 1 : (c.title || "").localeCompare(l.title || "");
61
+ return c.sort((u, d) => {
62
+ var P, M;
63
+ const m = g.find(($) => $.slug === u.slug), p = g.find(($) => $.slug === d.slug);
64
+ if (m && p)
65
+ return s(m, p);
66
+ const f = !!u.file && !((P = u.children) != null && P.length), S = !!d.file && !((M = d.children) != null && M.length);
67
+ return f !== S ? f ? -1 : 1 : (u.title || "").localeCompare(d.title || "");
64
68
  });
65
69
  }
66
- function k(e, t) {
70
+ function R(e, t) {
67
71
  try {
68
- const i = I(e, { withFileTypes: !0 }), r = [];
69
- for (const o of i) {
70
- if (!o.isFile()) continue;
71
- const n = t.find((h) => o.name.toLowerCase().endsWith(h));
72
- if (!n || o.name.slice(0, -n.length).toLowerCase() === "index") continue;
73
- const d = N(e, o.name), f = L(d, o.name, n);
74
- r.push(f);
72
+ const r = W(e, { withFileTypes: !0 }), i = [];
73
+ for (const n of r) {
74
+ if (!n.isFile()) continue;
75
+ const s = t.find((c) => n.name.toLowerCase().endsWith(c));
76
+ if (!s || n.name.slice(0, -s.length).toLowerCase() === "index") continue;
77
+ const a = y(e, n.name), l = T(a, n.name, s);
78
+ i.push(l);
75
79
  }
76
- return r;
80
+ return i;
77
81
  } catch {
78
82
  return [];
79
83
  }
80
84
  }
81
- function L(e, t, i) {
82
- let r = {}, o = F(t), n = 1 / 0;
85
+ function T(e, t, r) {
86
+ let i = {}, n = w(t), s = 1 / 0;
83
87
  try {
84
- const a = P(e, "utf-8");
85
- r = M(a), r.title && typeof r.title == "string" && (o = r.title), typeof r.order == "number" && (n = r.order);
88
+ const o = j(e, "utf-8");
89
+ i = I(o), i.title && typeof i.title == "string" && (n = i.title), typeof i.order == "number" && (s = i.order);
86
90
  } catch {
87
91
  }
88
92
  return {
89
93
  path: e,
90
94
  filename: t,
91
- extension: i,
92
- frontmatter: r,
93
- order: n,
94
- title: o,
95
- slug: v(t)
95
+ extension: r,
96
+ frontmatter: i,
97
+ order: s,
98
+ title: n,
99
+ slug: F(t)
96
100
  };
97
101
  }
98
- function W(e, t) {
99
- for (const i of t) {
100
- const r = N(e, `index${i}`);
102
+ function Q(e, t) {
103
+ for (const r of t) {
104
+ const i = y(e, `index${r}`);
101
105
  try {
102
- if (T(r).isFile())
103
- return L(r, `index${i}`, i);
106
+ if (H(i).isFile())
107
+ return T(i, `index${r}`, r);
104
108
  } catch {
105
109
  }
106
110
  }
107
111
  }
108
- class b extends Error {
109
- constructor(i, r, o, n) {
110
- super(i);
111
- m(this, "nodePath");
112
- m(this, "filePath");
113
- m(this, "originalError");
114
- this.name = "ManifestResolutionError", this.nodePath = r, this.filePath = o, this.originalError = n;
112
+ class x extends Error {
113
+ constructor(r, i, n, s) {
114
+ super(r);
115
+ v(this, "nodePath");
116
+ v(this, "filePath");
117
+ v(this, "originalError");
118
+ this.name = "ManifestResolutionError", this.nodePath = i, this.filePath = n, this.originalError = s;
115
119
  }
116
120
  }
117
- function Q(e, t = {}) {
118
- const { strict: i = !0 } = t, r = $(e.navigation, "", i);
121
+ function ge(e, t = {}) {
122
+ const { strict: r = !0 } = t, i = b(e.navigation, "", r);
119
123
  return {
120
124
  id: e.id,
121
125
  name: e.name,
122
126
  version: e.version,
123
127
  vendureVersion: e.vendureVersion,
124
- navigation: r,
128
+ navigation: i,
125
129
  search: e.search,
126
130
  github: e.github,
127
131
  basePath: e.basePath
128
132
  };
129
133
  }
130
- function $(e, t, i) {
131
- return e.map((r, o) => j(r, t, o, i));
134
+ function b(e, t, r) {
135
+ return e.map((i, n) => X(i, t, n, r));
132
136
  }
133
- function j(e, t, i, r) {
134
- const o = t ? `${t}[${i}]` : `navigation[${i}]`;
137
+ function X(e, t, r, i) {
138
+ const n = t ? `${t}[${r}]` : `navigation[${r}]`;
135
139
  if (e.title && e.slug)
136
140
  return {
137
141
  title: e.title,
138
142
  slug: e.slug,
139
143
  file: e.file,
140
- children: e.children ? $(e.children, `${o}.children`, r) : void 0,
144
+ children: e.children ? b(e.children, `${n}.children`, i) : void 0,
141
145
  badge: e.badge,
142
146
  hidden: e.hidden
143
147
  };
144
- let n = e.title, a = e.slug;
145
- if (e.file && (a || (a = v(e.file)), n || (n = p(e.file, o, r))), !n) {
146
- if (r)
147
- throw new b(
148
- `Navigation node at ${o} is missing title and has no file to derive it from`,
149
- o,
148
+ let s = e.title, o = e.slug;
149
+ if (e.file && (o || (o = F(e.file)), s || (s = Y(e.file, n, i))), !s) {
150
+ if (i)
151
+ throw new x(
152
+ `Navigation node at ${n} is missing title and has no file to derive it from`,
153
+ n,
150
154
  e.file
151
155
  );
152
- n = a || `Unknown (${i})`;
156
+ s = o || `Unknown (${r})`;
153
157
  }
154
- if (!a) {
155
- if (r)
156
- throw new b(
157
- `Navigation node at ${o} is missing slug and has no file to derive it from`,
158
- o,
158
+ if (!o) {
159
+ if (i)
160
+ throw new x(
161
+ `Navigation node at ${n} is missing slug and has no file to derive it from`,
162
+ n,
159
163
  e.file
160
164
  );
161
- a = n ? v(n) : `node-${i}`;
165
+ o = s ? F(s) : `node-${r}`;
162
166
  }
163
167
  return {
164
- title: n,
165
- slug: a,
168
+ title: s,
169
+ slug: o,
166
170
  file: e.file,
167
- children: e.children ? $(e.children, `${o}.children`, r) : void 0,
171
+ children: e.children ? b(e.children, `${n}.children`, i) : void 0,
168
172
  badge: e.badge,
169
173
  hidden: e.hidden
170
174
  };
171
175
  }
172
- function p(e, t, i) {
176
+ function Y(e, t, r) {
173
177
  try {
174
- const r = P(e, "utf-8"), o = M(r);
175
- return o.title && typeof o.title == "string" ? o.title : F(e);
176
- } catch (r) {
177
- if (i)
178
- throw new b(
178
+ const i = j(e, "utf-8"), n = I(i);
179
+ return n.title && typeof n.title == "string" ? n.title : w(e);
180
+ } catch (i) {
181
+ if (r)
182
+ throw new x(
179
183
  `Failed to read file for title derivation at ${t}: ${e}`,
180
184
  t,
181
185
  e,
182
- r
186
+ i
183
187
  );
184
- return F(e);
188
+ return w(e);
185
189
  }
186
190
  }
187
- function X(e) {
188
- return R(e.navigation);
191
+ function me(e) {
192
+ return B(e.navigation);
189
193
  }
190
- function R(e) {
194
+ function B(e) {
191
195
  for (const t of e)
192
- if (!t.title || !t.slug || t.children && R(t.children))
196
+ if (!t.title || !t.slug || t.children && B(t.children))
193
197
  return !0;
194
198
  return !1;
195
199
  }
200
+ const O = q(_);
201
+ async function z(e = process.cwd()) {
202
+ try {
203
+ return await O("git rev-parse --git-dir", { cwd: e }), !0;
204
+ } catch {
205
+ return !1;
206
+ }
207
+ }
208
+ async function Z(e, t = {}) {
209
+ const r = t.cwd ?? process.cwd();
210
+ try {
211
+ const { stdout: i } = await O(`git log -1 --format=%cI -- "${e}"`, { cwd: r }), n = i.trim();
212
+ return n || null;
213
+ } catch {
214
+ return null;
215
+ }
216
+ }
217
+ async function ee(e, t = {}) {
218
+ const r = t.cwd ?? process.cwd(), i = {}, n = [];
219
+ return await z(r) ? (await Promise.all(
220
+ e.map(async (s) => {
221
+ const o = await Z(s, t);
222
+ o ? i[s] = o : n.push(s);
223
+ })
224
+ ), { dates: i, skipped: n }) : {
225
+ dates: {},
226
+ skipped: e
227
+ };
228
+ }
229
+ async function te(e, t) {
230
+ const r = [];
231
+ async function i(n) {
232
+ const s = await J(n, { withFileTypes: !0 });
233
+ for (const o of s) {
234
+ const a = G(n, o.name);
235
+ o.isDirectory() ? !o.name.startsWith(".") && o.name !== "node_modules" && await i(a) : o.isFile() && t.some((c) => o.name.endsWith(c)) && r.push(a);
236
+ }
237
+ }
238
+ return await i(e), r;
239
+ }
240
+ async function pe(e) {
241
+ const { docsDir: t, outputPath: r, extensions: i = [".mdx", ".md"] } = e, n = e.gitCwd ?? G(t, "..");
242
+ if (!await z(n))
243
+ return console.warn("Warning: Not a git repository. Generating empty dates file."), await k(r), {
244
+ filesWithDates: 0,
245
+ filesSkipped: 0,
246
+ outputPath: r
247
+ };
248
+ const s = await te(t, i);
249
+ if (s.length === 0)
250
+ return console.warn(`Warning: No files found in ${t} with extensions ${i.join(", ")}`), await k(r), {
251
+ filesWithDates: 0,
252
+ filesSkipped: 0,
253
+ outputPath: r
254
+ };
255
+ const o = s.map((h) => K(n, h)), { dates: a, skipped: l } = await ee(o, { cwd: n }), c = ie(a);
256
+ return await C(r, c, "utf-8"), {
257
+ filesWithDates: Object.keys(a).length,
258
+ filesSkipped: l.length,
259
+ outputPath: r
260
+ };
261
+ }
262
+ async function k(e) {
263
+ const t = `// dates.generated.ts (auto-generated, do not edit)
264
+ // Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}
265
+ // Warning: Git repository not available, no dates extracted
266
+
267
+ export const lastModifiedDates: Record<string, string> = {}
268
+ `;
269
+ await C(e, t, "utf-8");
270
+ }
271
+ function ie(e) {
272
+ const t = Object.entries(e).sort(([i], [n]) => i.localeCompare(n)), r = t.map(([i, n]) => ` '${i}': '${n}',`).join(`
273
+ `);
274
+ return `// dates.generated.ts (auto-generated, do not edit)
275
+ // Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}
276
+ // Total files: ${t.length}
277
+
278
+ export const lastModifiedDates: Record<string, string> = {
279
+ ${r}
280
+ }
281
+ `;
282
+ }
283
+ function D(e) {
284
+ return e.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/\/$/, "");
285
+ }
286
+ function E(...e) {
287
+ return D(e.filter(Boolean).join("/"));
288
+ }
289
+ function ve(e, t, r = {}) {
290
+ const { basePath: i } = r;
291
+ function n(s) {
292
+ const o = { ...s };
293
+ if (s.file) {
294
+ const a = D(s.file), l = [];
295
+ if (i) {
296
+ const h = `/${D(i)}/`, N = a.indexOf(h);
297
+ if (N !== -1) {
298
+ const g = a.slice(N + 1);
299
+ l.push(g);
300
+ }
301
+ l.push(E(i, a)), l.push(E(i, a).replace(/^\//, ""));
302
+ }
303
+ if (l.push(a), l.push(a.replace(/^\//, "")), i) {
304
+ const c = a.split(`/${i}/`);
305
+ if (c.length > 1) {
306
+ const h = c[c.length - 1];
307
+ l.push(`${i}/${h}`), l.push(h);
308
+ }
309
+ }
310
+ for (const c of l)
311
+ if (t[c]) {
312
+ o.lastModified = t[c];
313
+ break;
314
+ }
315
+ }
316
+ return s.children && s.children.length > 0 && (o.children = s.children.map(n)), o;
317
+ }
318
+ return e.map(n);
319
+ }
196
320
  export {
197
- _ as BreadcrumbItemSchema,
198
- ee as DocPageMetaSchema,
199
- te as DocPageSchema,
200
- re as DocsPackageManifestInputSchema,
201
- ie as DocsPackageManifestSchema,
202
- oe as FlatNavigationNodeSchema,
203
- xe as FrontmatterParseError,
204
- ne as GitHubConfigSchema,
205
- se as LoadedDocsPackageSchema,
206
- b as ManifestResolutionError,
207
- ae as ManifestValidationError,
208
- le as NavigationNodeInputSchema,
209
- ce as NavigationNodeSchema,
210
- fe as SearchConfigSchema,
211
- de as VendureVersionSchema,
212
- he as buildBreadcrumbs,
213
- K as createNavigationFromFolder,
214
- O as createNestedNavigationFromFolder,
215
- M as extractFrontmatterData,
216
- Ee as filterVisibleNavigation,
217
- ue as findNavigationNode,
218
- ge as flattenNavigation,
219
- Me as getAllFilePaths,
220
- me as getLeafNodes,
221
- ve as getNodesAtDepth,
222
- Fe as getPrevNextNodes,
223
- be as hasFrontmatter,
224
- Ne as isNodeActive,
225
- X as manifestNeedsResolution,
226
- $e as parseFrontmatter,
227
- Q as resolveManifest,
228
- v as slugFromFilename,
229
- F as titleFromFilename,
230
- Ie as toSlug,
231
- we as validateFrontmatter,
232
- Se as validateManifest
321
+ ye as BreadcrumbItemSchema,
322
+ Ne as DocPageMetaSchema,
323
+ Se as DocPageSchema,
324
+ $e as DocsPackageManifestInputSchema,
325
+ xe as DocsPackageManifestSchema,
326
+ be as FlatNavigationNodeSchema,
327
+ ze as FrontmatterParseError,
328
+ De as GitHubConfigSchema,
329
+ Pe as LoadedDocsPackageSchema,
330
+ x as ManifestResolutionError,
331
+ Me as ManifestValidationError,
332
+ ke as NavigationNodeInputSchema,
333
+ Ee as NavigationNodeSchema,
334
+ Ie as SearchConfigSchema,
335
+ We as VendureVersionSchema,
336
+ ve as applyLastModifiedDates,
337
+ je as buildBreadcrumbs,
338
+ ue as createNavigationFromFolder,
339
+ he as createNestedNavigationFromFolder,
340
+ I as extractFrontmatterData,
341
+ qe as filterVisibleNavigation,
342
+ Ce as findNavigationNode,
343
+ Ge as flattenNavigation,
344
+ pe as generateDatesFile,
345
+ Je as getAllFilePaths,
346
+ Z as getGitLastModified,
347
+ ee as getGitLastModifiedBatch,
348
+ Le as getLeafNodes,
349
+ Ve as getNodesAtDepth,
350
+ Re as getPrevNextNodes,
351
+ Ae as hasFrontmatter,
352
+ z as isGitRepository,
353
+ Te as isNodeActive,
354
+ me as manifestNeedsResolution,
355
+ Ue as parseFrontmatter,
356
+ ge as resolveManifest,
357
+ F as slugFromFilename,
358
+ w as titleFromFilename,
359
+ Ke as toSlug,
360
+ He as validateFrontmatter,
361
+ Be as validateManifest
233
362
  };
package/dist/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var g=(e,r,t)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>g(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("fs/promises"),P=require("module"),m=require("./frontmatter-CJYZSUYM.cjs"),p=require("./manifest-D-EWZlSh.cjs");var c=typeof document<"u"?document.currentScript:null;class a extends Error{constructor(t,n){super(t);i(this,"packageName");this.name="DocsPackageLoadError",this.packageName=n}}async function $(e,r={}){try{const t=r.resolver?await r.resolver(e):u(e),n=await import(e);if(!n.manifest)throw new a(`Package "${e}" does not export a manifest`,e);return{manifest:p.validateManifest(n.manifest),basePath:t}}catch(t){throw t instanceof a?t:new a(`Failed to load docs package "${e}": ${t instanceof Error?t.message:String(t)}`,e)}}function u(e){try{return P.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("loader.cjs",document.baseURI).href).resolve(`${e}/package.json`).replace(/\/package\.json$/,"")}catch{throw new a(`Cannot resolve package "${e}". Make sure it is installed.`,e)}}async function l(e,r){try{const t=`${e.basePath}/${r}`,n=await h.readFile(t,"utf-8"),{meta:o,content:s}=m.parseFrontmatter(n,r);return{meta:o,content:s,filePath:r}}catch(t){throw new a(`Failed to load doc page "${r}": ${t instanceof Error?t.message:String(t)}`,e.manifest.id)}}async function v(e,r){const t=d(e.manifest.navigation,r.split("/"));if(t!=null&&t.file)return l(e,t.file)}function d(e,r){if(r.length===0)return;const[t,...n]=r,o=e.find(s=>s.slug===t);if(o){if(n.length===0)return o;if(o.children)return d(o.children,n)}}function y(e,r){if(r.file)return`${e.basePath}/${r.file}`}function w(e){try{return u(e),!0}catch{return!1}}exports.DocsPackageLoadError=a;exports.isDocsPackageInstalled=w;exports.loadDocPage=l;exports.loadDocPageBySlug=v;exports.loadDocsPackage=$;exports.resolveFilePath=y;
1
+ "use strict";var f=Object.defineProperty;var g=(e,r,t)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>g(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("fs/promises"),P=require("module"),m=require("./frontmatter-QFErVd9b.cjs"),p=require("./manifest-BkO3d77g.cjs");var c=typeof document<"u"?document.currentScript:null;class a extends Error{constructor(t,n){super(t);i(this,"packageName");this.name="DocsPackageLoadError",this.packageName=n}}async function $(e,r={}){try{const t=r.resolver?await r.resolver(e):u(e),n=await import(e);if(!n.manifest)throw new a(`Package "${e}" does not export a manifest`,e);return{manifest:p.validateManifest(n.manifest),basePath:t}}catch(t){throw t instanceof a?t:new a(`Failed to load docs package "${e}": ${t instanceof Error?t.message:String(t)}`,e)}}function u(e){try{return P.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("loader.cjs",document.baseURI).href).resolve(`${e}/package.json`).replace(/\/package\.json$/,"")}catch{throw new a(`Cannot resolve package "${e}". Make sure it is installed.`,e)}}async function l(e,r){try{const t=`${e.basePath}/${r}`,n=await h.readFile(t,"utf-8"),{meta:o,content:s}=m.parseFrontmatter(n,r);return{meta:o,content:s,filePath:r}}catch(t){throw new a(`Failed to load doc page "${r}": ${t instanceof Error?t.message:String(t)}`,e.manifest.id)}}async function v(e,r){const t=d(e.manifest.navigation,r.split("/"));if(t!=null&&t.file)return l(e,t.file)}function d(e,r){if(r.length===0)return;const[t,...n]=r,o=e.find(s=>s.slug===t);if(o){if(n.length===0)return o;if(o.children)return d(o.children,n)}}function y(e,r){if(r.file)return`${e.basePath}/${r.file}`}function w(e){try{return u(e),!0}catch{return!1}}exports.DocsPackageLoadError=a;exports.isDocsPackageInstalled=w;exports.loadDocPage=l;exports.loadDocPageBySlug=v;exports.loadDocsPackage=$;exports.resolveFilePath=y;
package/dist/loader.js CHANGED
@@ -3,8 +3,8 @@ var l = (t, e, r) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writab
3
3
  var i = (t, e, r) => l(t, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { readFile as d } from "fs/promises";
5
5
  import { createRequire as h } from "module";
6
- import { p as g } from "./frontmatter-C0Wmtdep.js";
7
- import { v as m } from "./manifest-ZCrzbFSf.js";
6
+ import { p as g } from "./frontmatter-B5d9WZzh.js";
7
+ import { v as m } from "./manifest-DlSWyjsA.js";
8
8
  class a extends Error {
9
9
  constructor(r, n) {
10
10
  super(r);
@@ -0,0 +1 @@
1
+ "use strict";var M=Object.defineProperty;var D=(n,t,i)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i;var m=(n,t,i)=>D(n,typeof t!="symbol"?t+"":t,i);const e=require("zod"),d=e.z.enum(["v1","v2","v3"]),g=e.z.object({indexFields:e.z.array(e.z.enum(["title","description","content","keywords"])),boosts:e.z.record(e.z.string(),e.z.number()).optional()}),u=e.z.object({repository:e.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:e.z.string().optional(),docsPath:e.z.string().optional()}),l=e.z.lazy(()=>e.z.object({title:e.z.string().min(1,"Navigation title is required"),slug:e.z.string().min(1,"Navigation slug is required"),file:e.z.string().optional(),children:e.z.array(l).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional(),lastModified:e.z.string().datetime({offset:!0}).optional()})),f=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:d,navigation:e.z.array(l),search:g.optional(),github:u.optional(),basePath:e.z.string().optional()}),p=e.z.object({title:e.z.string().min(1,"Page title is required"),description:e.z.string().optional(),keywords:e.z.array(e.z.string()).optional(),sidebarLabel:e.z.string().optional(),hidden:e.z.boolean().optional(),order:e.z.number().int().optional(),lastModified:e.z.string().datetime({offset:!0}).optional()}),j=e.z.object({meta:p,content:e.z.string(),filePath:e.z.string()}),k=e.z.object({manifest:f,basePath:e.z.string()}),I=e.z.object({title:e.z.string(),slug:e.z.string(),path:e.z.string()}),V=e.z.object({title:e.z.string(),slug:e.z.string(),file:e.z.string().optional(),children:e.z.array(e.z.lazy(()=>l)).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional(),lastModified:e.z.string().datetime({offset:!0}).optional(),path:e.z.string(),depth:e.z.number().int().min(0),parentPath:e.z.string().optional()}),z=e.z.lazy(()=>e.z.object({title:e.z.string().min(1).optional(),slug:e.z.string().min(1).optional(),file:e.z.string().optional(),children:e.z.array(z).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional(),lastModified:e.z.string().datetime({offset:!0}).optional()})),x=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:d,navigation:e.z.array(z),search:g.optional(),github:u.optional(),basePath:e.z.string().optional()});class b extends Error{constructor(i,o){super(i);m(this,"issues");this.name="ManifestValidationError",this.issues=o}}function q(n){const t=f.safeParse(n);if(!t.success){const i=t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`);throw new b("Invalid manifest",i)}return t.data}function B(n,t){const i=t.split("/").filter(Boolean);return v(n.navigation,i)}function v(n,t){if(t.length===0)return;const[i,...o]=t,a=n.find(r=>r.slug===i);if(a){if(o.length===0)return a;if(a.children)return v(a.children,o)}}function h(n){const t=[];return N(n.navigation,"",0,void 0,t),t}function N(n,t,i,o,a){for(const r of n){const s=t?`${t}/${r.slug}`:r.slug;a.push({...r,path:s,depth:i,parentPath:o}),r.children&&r.children.length>0&&N(r.children,s,i+1,s,a)}}function $(n,t){const i=t.split("/").filter(Boolean),o=[];let a=n.navigation,r="";for(const s of i){const c=a.find(y=>y.slug===s);if(!c)break;r=r?`${r}/${s}`:s,o.push({title:c.title,slug:c.slug,path:r,file:c.file}),a=c.children??[]}return o}function S(n){return h(n).filter(t=>t.file!==void 0)}function w(n,t){const i=S(n),o=i.findIndex(a=>a.path===t);return o===-1?{}:{prev:o>0?i[o-1]:void 0,next:o<i.length-1?i[o+1]:void 0}}function P(n,t){const i=t.split("/").filter(Boolean);if(i.length===0)return!1;if(n.slug===i[0]){if(i.length===1)return!0;if(n.children){const o=i.slice(1).join("/");return n.children.some(a=>P(a,o))}}return!1}function L(n,t){return h(n).filter(i=>i.depth===t)}exports.BreadcrumbItemSchema=I;exports.DocPageMetaSchema=p;exports.DocPageSchema=j;exports.DocsPackageManifestInputSchema=x;exports.DocsPackageManifestSchema=f;exports.FlatNavigationNodeSchema=V;exports.GitHubConfigSchema=u;exports.LoadedDocsPackageSchema=k;exports.ManifestValidationError=b;exports.NavigationNodeInputSchema=z;exports.NavigationNodeSchema=l;exports.SearchConfigSchema=g;exports.VendureVersionSchema=d;exports.buildBreadcrumbs=$;exports.findNavigationNode=B;exports.flattenNavigation=h;exports.getLeafNodes=S;exports.getNodesAtDepth=L;exports.getPrevNextNodes=w;exports.isNodeActive=P;exports.validateManifest=q;