zudoku 0.29.1 → 0.30.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.
- package/dist/lib/plugins/markdown/resolver.d.ts +0 -6
- package/dist/lib/plugins/markdown/resolver.js +0 -29
- package/dist/lib/plugins/markdown/resolver.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +2 -2
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/vite/build.js +4 -1
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/prerender/prerender.d.ts +1 -1
- package/dist/vite/prerender/prerender.js +53 -20
- package/dist/vite/prerender/prerender.js.map +1 -1
- package/dist/vite/prerender/worker.d.ts +6 -4
- package/dist/vite/prerender/worker.js +13 -19
- package/dist/vite/prerender/worker.js.map +1 -1
- package/dist/vite/reporter.d.ts +3 -0
- package/dist/vite/reporter.js +33 -0
- package/dist/vite/reporter.js.map +1 -0
- package/lib/{OperationList-B3VX94x4.js → OperationList-CnYOgwBj.js} +259 -257
- package/lib/OperationList-CnYOgwBj.js.map +1 -0
- package/lib/{index-P0YUtHIb.js → index-CnKeVT2S.js} +5 -5
- package/lib/{index-P0YUtHIb.js.map → index-CnKeVT2S.js.map} +1 -1
- package/lib/zudoku.plugin-markdown.js +23 -44
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +2 -2
- package/src/lib/plugins/markdown/resolver.ts +0 -33
- package/src/lib/plugins/openapi/index.tsx +2 -2
- package/lib/OperationList-B3VX94x4.js.map +0 -1
- package/lib/__vite-browser-external-BYRIRx8p.js +0 -9
- package/lib/__vite-browser-external-BYRIRx8p.js.map +0 -1
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { j as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class c {
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var g = (e, t, o) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var c = (e, t, o) => g(e, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { j as d } from "./jsx-runtime-Bdg6XQ1m.js";
|
|
5
|
+
const m = "/pages/**/*.{md,mdx}";
|
|
6
|
+
class w {
|
|
8
7
|
constructor(t) {
|
|
9
|
-
|
|
8
|
+
c(this, "fileMap", /* @__PURE__ */ new Map());
|
|
10
9
|
this.config = t;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
12
|
* Gets the default docs config from the zudoku config
|
|
14
13
|
*/
|
|
15
14
|
getDocsConfigs() {
|
|
16
|
-
return this.config.docs ? Array.isArray(this.config.docs) ? this.config.docs : [this.config.docs] : [{ files:
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Resolves the first matching file system path for a given docId
|
|
20
|
-
* @param docId - The docId to resolve
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
resolveFilePath(t) {
|
|
24
|
-
const o = this.getDocsConfigs();
|
|
25
|
-
let e;
|
|
26
|
-
return o.forEach(({ files: i }) => {
|
|
27
|
-
if (e)
|
|
28
|
-
return;
|
|
29
|
-
const s = c.getRootDir(i);
|
|
30
|
-
for (const a of D) {
|
|
31
|
-
if (e)
|
|
32
|
-
return;
|
|
33
|
-
const r = u.join(s, `${t}${a}`);
|
|
34
|
-
u.existsSync(r) && (e = r);
|
|
35
|
-
}
|
|
36
|
-
}), e;
|
|
15
|
+
return this.config.docs ? Array.isArray(this.config.docs) ? this.config.docs : [this.config.docs] : [{ files: m }];
|
|
37
16
|
}
|
|
38
17
|
/**
|
|
39
18
|
* Gets the root directory from a files glob
|
|
@@ -53,17 +32,17 @@ class c {
|
|
|
53
32
|
filesGlob: t,
|
|
54
33
|
fsPath: o
|
|
55
34
|
}) {
|
|
56
|
-
const
|
|
35
|
+
const n = this.getRootDir(t), a = new RegExp(`^${n}(.*).mdx?`), s = o.match(a);
|
|
57
36
|
return s == null ? void 0 : s.at(1);
|
|
58
37
|
}
|
|
59
38
|
}
|
|
60
|
-
const
|
|
39
|
+
const P = (e) => ({
|
|
61
40
|
getRoutes: () => {
|
|
62
41
|
const t = /* @__PURE__ */ new Map();
|
|
63
|
-
return
|
|
64
|
-
({ fileImports: o, files:
|
|
65
|
-
const r =
|
|
66
|
-
filesGlob:
|
|
42
|
+
return e.forEach(
|
|
43
|
+
({ fileImports: o, files: n, defaultOptions: a }) => Object.entries(o).flatMap(([s, i]) => {
|
|
44
|
+
const r = w.resolveRoutePath({
|
|
45
|
+
filesGlob: n,
|
|
67
46
|
fsPath: s
|
|
68
47
|
});
|
|
69
48
|
if (!r) return [];
|
|
@@ -71,29 +50,29 @@ const C = (n) => ({
|
|
|
71
50
|
return console.warn(
|
|
72
51
|
`Duplicate route path found for ${r}. Skipping file at '${s}'.`
|
|
73
52
|
), [];
|
|
74
|
-
const
|
|
53
|
+
const u = {
|
|
75
54
|
path: r,
|
|
76
55
|
lazy: async () => {
|
|
77
|
-
const { MdxPage:
|
|
56
|
+
const { MdxPage: p } = await import("./MdxPage-BalfwlsD.js"), { default: f, ...l } = await i();
|
|
78
57
|
return {
|
|
79
|
-
element: /* @__PURE__ */
|
|
80
|
-
|
|
58
|
+
element: /* @__PURE__ */ d.jsx(
|
|
59
|
+
p,
|
|
81
60
|
{
|
|
82
61
|
file: s,
|
|
83
|
-
mdxComponent:
|
|
84
|
-
...
|
|
85
|
-
defaultOptions:
|
|
62
|
+
mdxComponent: f,
|
|
63
|
+
...l,
|
|
64
|
+
defaultOptions: a
|
|
86
65
|
}
|
|
87
66
|
)
|
|
88
67
|
};
|
|
89
68
|
}
|
|
90
69
|
};
|
|
91
|
-
t.set(r,
|
|
70
|
+
t.set(r, u);
|
|
92
71
|
})
|
|
93
72
|
), [...t.values()];
|
|
94
73
|
}
|
|
95
74
|
});
|
|
96
75
|
export {
|
|
97
|
-
|
|
76
|
+
P as markdownPlugin
|
|
98
77
|
};
|
|
99
78
|
//# sourceMappingURL=zudoku.plugin-markdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zudoku.plugin-markdown.js","sources":["../src/lib/plugins/markdown/resolver.ts","../src/lib/plugins/markdown/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"zudoku.plugin-markdown.js","sources":["../src/lib/plugins/markdown/resolver.ts","../src/lib/plugins/markdown/index.tsx"],"sourcesContent":["import { ZudokuDocsConfig } from \"../../../config/validators/common.js\";\nimport { ZudokuConfig } from \"../../../config/validators/validate.js\";\n\nconst DEFAULT_DOCS_FILES = \"/pages/**/*.{md,mdx}\";\n\n/**\n * Utilities for resolving markdown file paths and routes\n */\nexport class DocResolver {\n constructor(private config: ZudokuConfig) {}\n\n fileMap = new Map<string, string>();\n\n /**\n * Gets the default docs config from the zudoku config\n */\n getDocsConfigs() {\n const docsConfigs: ZudokuDocsConfig[] = this.config.docs\n ? Array.isArray(this.config.docs)\n ? this.config.docs\n : [this.config.docs]\n : [{ files: DEFAULT_DOCS_FILES }];\n\n return docsConfigs;\n }\n\n /**\n * Gets the root directory from a files glob\n */\n private static getRootDir(filesGlob: string) {\n let rootDir = filesGlob.split(\"**\")[0];\n if (!rootDir) {\n throw new Error(\"Invalid files glob. Must have '**' in the path.\");\n }\n rootDir = rootDir.replace(\"/**\", \"/\");\n return rootDir;\n }\n\n /**\n * Resolves the route path for a given file system path\n * @param options - The options to resolve the route path\n * @returns The string route path\n */\n static resolveRoutePath({\n filesGlob,\n fsPath,\n }: {\n filesGlob: string;\n fsPath: string;\n }) {\n const rootDir = this.getRootDir(filesGlob);\n const re = new RegExp(`^${rootDir}(.*).mdx?`);\n const match = fsPath.match(re);\n const routePath = match?.at(1);\n return routePath;\n }\n}\n","import type { Toc } from \"@stefanprobst/rehype-extract-toc\";\nimport type { MDXProps } from \"mdx/types.js\";\nimport { type JSX } from \"react\";\nimport { RouteObject } from \"react-router\";\nimport { ZudokuDocsConfig } from \"../../../config/validators/common.js\";\nimport type { ZudokuPlugin } from \"../../core/plugins.js\";\nimport { DocResolver } from \"./resolver.js\";\n\nexport interface MarkdownPluginOptions extends ZudokuDocsConfig {\n fileImports: Record<string, () => Promise<MDXImport>>;\n}\nexport type MarkdownPluginDefaultOptions = Pick<\n Frontmatter,\n \"toc\" | \"disablePager\"\n>;\n\nexport type Frontmatter = {\n title?: string;\n description?: string;\n category?: string;\n toc?: boolean;\n disablePager?: boolean;\n};\n\nexport type MDXImport = {\n tableOfContents: Toc;\n frontmatter: Frontmatter;\n excerpt?: string;\n default: (props: MDXProps) => JSX.Element;\n};\n\nexport const markdownPlugin = (\n options: MarkdownPluginOptions[],\n): ZudokuPlugin => ({\n getRoutes: () => {\n const routeMap = new Map<string, RouteObject>();\n options.forEach(({ fileImports, files, defaultOptions }) =>\n Object.entries(fileImports).flatMap(([file, importPromise]) => {\n const routePath = DocResolver.resolveRoutePath({\n filesGlob: files,\n fsPath: file,\n });\n\n if (!routePath) return [];\n\n if (routeMap.has(routePath)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Duplicate route path found for ${routePath}. Skipping file at '${file}'.`,\n );\n return [];\n }\n\n const route: RouteObject = {\n path: routePath,\n lazy: async () => {\n const { MdxPage } = await import(\"./MdxPage.js\");\n const { default: Component, ...props } = await importPromise();\n return {\n element: (\n <MdxPage\n file={file}\n mdxComponent={Component}\n {...props}\n defaultOptions={defaultOptions}\n />\n ),\n };\n },\n };\n routeMap.set(routePath, route);\n }),\n );\n return [...routeMap.values()];\n },\n});\n"],"names":["DEFAULT_DOCS_FILES","DocResolver","config","__publicField","filesGlob","rootDir","fsPath","re","match","markdownPlugin","options","routeMap","fileImports","files","defaultOptions","file","importPromise","routePath","route","MdxPage","Component","props","jsx"],"mappings":";;;;AAGA,MAAMA,IAAqB;AAKpB,MAAMC,EAAY;AAAA,EACvB,YAAoBC,GAAsB;AAE1C,IAAAC,EAAA,qCAAc,IAAoB;AAFd,SAAA,SA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D;AAAA,UACN,MAAM,YAAY;AAChB,kBAAM,EAAE,SAAAE,EAAA,IAAY,MAAM,OAAO,uBAAc,GACzC,EAAE,SAASC,GAAW,GAAGC,EAAM,IAAI,MAAML,EAAc;AACtD,mBAAA;AAAA,cACL,SACEM,gBAAAA,EAAA;AAAA,gBAACH;AAAA,gBAAA;AAAA,kBACC,MAAAJ;AAAA,kBACA,cAAcK;AAAA,kBACb,GAAGC;AAAA,kBACJ,gBAAAP;AAAA,gBAAA;AAAA,cAAA;AAAA,YAGN;AAAA,UAAA;AAAA,QAEJ;AACS,QAAAH,EAAA,IAAIM,GAAWC,CAAK;AAAA,MAC9B,CAAA;AAAA,IACH,GACO,CAAC,GAAGP,EAAS,QAAQ;AAAA,EAAA;AAEhC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zudoku",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://zudoku.dev",
|
|
6
6
|
"repository": {
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
"react-dom": "19.0.0",
|
|
241
241
|
"rollup-plugin-visualizer": "5.14.0",
|
|
242
242
|
"typescript": "5.7.3",
|
|
243
|
-
"vitest": "3.0.
|
|
243
|
+
"vitest": "3.0.5"
|
|
244
244
|
},
|
|
245
245
|
"peerDependencies": {
|
|
246
246
|
"react": ">=19",
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
1
|
import { ZudokuDocsConfig } from "../../../config/validators/common.js";
|
|
4
2
|
import { ZudokuConfig } from "../../../config/validators/validate.js";
|
|
5
3
|
|
|
6
4
|
const DEFAULT_DOCS_FILES = "/pages/**/*.{md,mdx}";
|
|
7
5
|
|
|
8
|
-
// TODO: This should be dynamic based on the glob selector
|
|
9
|
-
const SUPPORTED_EXTENSIONS = [".md", ".mdx"];
|
|
10
|
-
|
|
11
6
|
/**
|
|
12
7
|
* Utilities for resolving markdown file paths and routes
|
|
13
8
|
*/
|
|
@@ -29,34 +24,6 @@ export class DocResolver {
|
|
|
29
24
|
return docsConfigs;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
/**
|
|
33
|
-
* Resolves the first matching file system path for a given docId
|
|
34
|
-
* @param docId - The docId to resolve
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
resolveFilePath(docId: string) {
|
|
38
|
-
const docsConfigs = this.getDocsConfigs();
|
|
39
|
-
let fsPath: string | undefined;
|
|
40
|
-
|
|
41
|
-
docsConfigs.forEach(({ files: fileGlob }) => {
|
|
42
|
-
if (fsPath) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const rootDir = DocResolver.getRootDir(fileGlob);
|
|
46
|
-
for (const ext of SUPPORTED_EXTENSIONS) {
|
|
47
|
-
if (fsPath) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const checkPath = path.join(rootDir, `${docId}${ext}`);
|
|
51
|
-
if (fs.existsSync(checkPath)) {
|
|
52
|
-
fsPath = checkPath;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return fsPath;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
27
|
/**
|
|
61
28
|
* Gets the root directory from a files glob
|
|
62
29
|
*/
|
|
@@ -226,7 +226,7 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
228
|
getRoutes: () => {
|
|
229
|
-
const versionsInPath = [null, ...versions];
|
|
229
|
+
const versionsInPath = versions.length > 1 ? [null, ...versions] : [null];
|
|
230
230
|
|
|
231
231
|
const tagPages = (config.tagPages ?? []).map((tag) => ({
|
|
232
232
|
tag,
|
|
@@ -234,7 +234,7 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
|
234
234
|
}));
|
|
235
235
|
|
|
236
236
|
return versionsInPath.map((version) => {
|
|
237
|
-
const versionPath = joinUrl(basePath, version
|
|
237
|
+
const versionPath = joinUrl(basePath, version);
|
|
238
238
|
|
|
239
239
|
return {
|
|
240
240
|
path: versionPath,
|