@xyd-js/cli 0.1.0-xyd.4 → 0.1.0-xyd.6

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 (100) hide show
  1. package/.cli/bin.js +3 -0
  2. package/.cli/{host/node_modules/.vite/deps/gray-matter.js → index.js} +2714 -533
  3. package/.cli/package.json +37 -0
  4. package/package.json +11 -20
  5. package/.cli/dist/index.d.ts +0 -1
  6. package/.cli/dist/index.js +0 -12418
  7. package/.cli/host/.react-router/types/app/+types/root.ts +0 -40
  8. package/.cli/host/node_modules/.vite/deps/@mdx-js_mdx.js +0 -81
  9. package/.cli/host/node_modules/.vite/deps/@mdx-js_mdx.js.map +0 -7
  10. package/.cli/host/node_modules/.vite/deps/@mdx-js_rollup.js +0 -4003
  11. package/.cli/host/node_modules/.vite/deps/@mdx-js_rollup.js.map +0 -7
  12. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-icons.js +0 -7531
  13. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-icons.js.map +0 -7
  14. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-tabs.js +0 -917
  15. package/.cli/host/node_modules/.vite/deps/@radix-ui_react-tabs.js.map +0 -7
  16. package/.cli/host/node_modules/.vite/deps/_metadata.json +0 -157
  17. package/.cli/host/node_modules/.vite/deps/chunk-2TUXWMP5.js +0 -46
  18. package/.cli/host/node_modules/.vite/deps/chunk-2TUXWMP5.js.map +0 -7
  19. package/.cli/host/node_modules/.vite/deps/chunk-A76PLWFF.js +0 -23875
  20. package/.cli/host/node_modules/.vite/deps/chunk-A76PLWFF.js.map +0 -7
  21. package/.cli/host/node_modules/.vite/deps/chunk-B2TCFXA3.js +0 -27
  22. package/.cli/host/node_modules/.vite/deps/chunk-B2TCFXA3.js.map +0 -7
  23. package/.cli/host/node_modules/.vite/deps/chunk-CZACBYAQ.js +0 -3461
  24. package/.cli/host/node_modules/.vite/deps/chunk-CZACBYAQ.js.map +0 -7
  25. package/.cli/host/node_modules/.vite/deps/chunk-DNIFH2K7.js +0 -3461
  26. package/.cli/host/node_modules/.vite/deps/chunk-DNIFH2K7.js.map +0 -7
  27. package/.cli/host/node_modules/.vite/deps/chunk-ERHH4CDL.js +0 -23875
  28. package/.cli/host/node_modules/.vite/deps/chunk-ERHH4CDL.js.map +0 -7
  29. package/.cli/host/node_modules/.vite/deps/chunk-ETJV5QNK.js +0 -27
  30. package/.cli/host/node_modules/.vite/deps/chunk-ETJV5QNK.js.map +0 -7
  31. package/.cli/host/node_modules/.vite/deps/chunk-GPEJJ3KZ.js +0 -1906
  32. package/.cli/host/node_modules/.vite/deps/chunk-GPEJJ3KZ.js.map +0 -7
  33. package/.cli/host/node_modules/.vite/deps/chunk-IVP26VTC.js +0 -21
  34. package/.cli/host/node_modules/.vite/deps/chunk-IVP26VTC.js.map +0 -7
  35. package/.cli/host/node_modules/.vite/deps/chunk-MJUUSK53.js +0 -894
  36. package/.cli/host/node_modules/.vite/deps/chunk-MJUUSK53.js.map +0 -7
  37. package/.cli/host/node_modules/.vite/deps/chunk-NHN7DW4J.js +0 -928
  38. package/.cli/host/node_modules/.vite/deps/chunk-NHN7DW4J.js.map +0 -7
  39. package/.cli/host/node_modules/.vite/deps/chunk-NSHFRFAV.js +0 -894
  40. package/.cli/host/node_modules/.vite/deps/chunk-NSHFRFAV.js.map +0 -7
  41. package/.cli/host/node_modules/.vite/deps/chunk-O6QCC74R.js +0 -205
  42. package/.cli/host/node_modules/.vite/deps/chunk-O6QCC74R.js.map +0 -7
  43. package/.cli/host/node_modules/.vite/deps/chunk-OO6QDGMA.js +0 -10609
  44. package/.cli/host/node_modules/.vite/deps/chunk-OO6QDGMA.js.map +0 -7
  45. package/.cli/host/node_modules/.vite/deps/chunk-OUN4SSIE.js +0 -205
  46. package/.cli/host/node_modules/.vite/deps/chunk-OUN4SSIE.js.map +0 -7
  47. package/.cli/host/node_modules/.vite/deps/chunk-SBIFJFEH.js +0 -894
  48. package/.cli/host/node_modules/.vite/deps/chunk-SBIFJFEH.js.map +0 -7
  49. package/.cli/host/node_modules/.vite/deps/chunk-SURLKOJ2.js +0 -12
  50. package/.cli/host/node_modules/.vite/deps/chunk-SURLKOJ2.js.map +0 -7
  51. package/.cli/host/node_modules/.vite/deps/chunk-TKNG6GUJ.js +0 -894
  52. package/.cli/host/node_modules/.vite/deps/chunk-TKNG6GUJ.js.map +0 -7
  53. package/.cli/host/node_modules/.vite/deps/chunk-TM4FKLNO.js +0 -21628
  54. package/.cli/host/node_modules/.vite/deps/chunk-TM4FKLNO.js.map +0 -7
  55. package/.cli/host/node_modules/.vite/deps/chunk-V2IF7L2E.js +0 -12
  56. package/.cli/host/node_modules/.vite/deps/chunk-V2IF7L2E.js.map +0 -7
  57. package/.cli/host/node_modules/.vite/deps/chunk-VENRSTQF.js +0 -21628
  58. package/.cli/host/node_modules/.vite/deps/chunk-VENRSTQF.js.map +0 -7
  59. package/.cli/host/node_modules/.vite/deps/chunk-XCGROZNW.js +0 -10609
  60. package/.cli/host/node_modules/.vite/deps/chunk-XCGROZNW.js.map +0 -7
  61. package/.cli/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js +0 -928
  62. package/.cli/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js.map +0 -7
  63. package/.cli/host/node_modules/.vite/deps/chunk-ZFOARUJI.js +0 -1906
  64. package/.cli/host/node_modules/.vite/deps/chunk-ZFOARUJI.js.map +0 -7
  65. package/.cli/host/node_modules/.vite/deps/gray-matter.js.map +0 -7
  66. package/.cli/host/node_modules/.vite/deps/lucide-react.js +0 -34742
  67. package/.cli/host/node_modules/.vite/deps/lucide-react.js.map +0 -7
  68. package/.cli/host/node_modules/.vite/deps/package.json +0 -3
  69. package/.cli/host/node_modules/.vite/deps/react-dom.js +0 -7
  70. package/.cli/host/node_modules/.vite/deps/react-dom.js.map +0 -7
  71. package/.cli/host/node_modules/.vite/deps/react-dom_client.js +0 -39
  72. package/.cli/host/node_modules/.vite/deps/react-dom_client.js.map +0 -7
  73. package/.cli/host/node_modules/.vite/deps/react-router.js +0 -243
  74. package/.cli/host/node_modules/.vite/deps/react-router.js.map +0 -7
  75. package/.cli/host/node_modules/.vite/deps/react-router_dom.js +0 -212
  76. package/.cli/host/node_modules/.vite/deps/react-router_dom.js.map +0 -7
  77. package/.cli/host/node_modules/.vite/deps/react.js +0 -6
  78. package/.cli/host/node_modules/.vite/deps/react.js.map +0 -7
  79. package/.cli/host/node_modules/.vite/deps/react_jsx-dev-runtime.js +0 -913
  80. package/.cli/host/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +0 -7
  81. package/.cli/host/node_modules/.vite/deps/react_jsx-runtime.js +0 -7
  82. package/.cli/host/node_modules/.vite/deps/react_jsx-runtime.js.map +0 -7
  83. package/.cli/host/node_modules/.vite/deps/remark-frontmatter.js +0 -428
  84. package/.cli/host/node_modules/.vite/deps/remark-frontmatter.js.map +0 -7
  85. package/.cli/host/node_modules/.vite/deps/remark-gfm.js +0 -3122
  86. package/.cli/host/node_modules/.vite/deps/remark-gfm.js.map +0 -7
  87. package/.cli/host/node_modules/.vite/deps/remark-mdx-frontmatter.js +0 -10482
  88. package/.cli/host/node_modules/.vite/deps/remark-mdx-frontmatter.js.map +0 -7
  89. package/.cli/host/node_modules/.vite/deps/unist-util-visit.js +0 -14
  90. package/.cli/host/node_modules/.vite/deps/unist-util-visit.js.map +0 -7
  91. package/.cli/host/node_modules/.vite/deps/vfile.js +0 -8
  92. package/.cli/host/node_modules/.vite/deps/vfile.js.map +0 -7
  93. package/.cli/host/package.json +0 -43
  94. package/bin.js +0 -3
  95. /package/.cli/{host/app → app}/root.tsx +0 -0
  96. /package/.cli/{host/app → app}/routes.ts +0 -0
  97. /package/.cli/{host/postcss.config.cjs → postcss.config.cjs} +0 -0
  98. /package/.cli/{host/react-router.config.ts → react-router.config.ts} +0 -0
  99. /package/.cli/{host/tsconfig.json → tsconfig.json} +0 -0
  100. /package/.cli/{host/vite.config.ts → vite.config.ts} +0 -0
@@ -1,14 +1,1599 @@
1
- import {
2
- require_fs
3
- } from "./chunk-IVP26VTC.js";
4
- import {
5
- __commonJS,
6
- __require
7
- } from "./chunk-2TUXWMP5.js";
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require3() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+
34
+ // node_modules/picocolors/picocolors.js
35
+ var require_picocolors = __commonJS({
36
+ "node_modules/picocolors/picocolors.js"(exports2, module2) {
37
+ "use strict";
38
+ var p = process || {};
39
+ var argv = p.argv || [];
40
+ var env = p.env || {};
41
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
42
+ var formatter = (open, close, replace = open) => (input) => {
43
+ let string = "" + input, index = string.indexOf(close, open.length);
44
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
45
+ };
46
+ var replaceClose = (string, close, replace, index) => {
47
+ let result = "", cursor = 0;
48
+ do {
49
+ result += string.substring(cursor, index) + replace;
50
+ cursor = index + close.length;
51
+ index = string.indexOf(close, cursor);
52
+ } while (~index);
53
+ return result + string.substring(cursor);
54
+ };
55
+ var createColors = (enabled = isColorSupported) => {
56
+ let f = enabled ? formatter : () => String;
57
+ return {
58
+ isColorSupported: enabled,
59
+ reset: f("\x1B[0m", "\x1B[0m"),
60
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
61
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
62
+ italic: f("\x1B[3m", "\x1B[23m"),
63
+ underline: f("\x1B[4m", "\x1B[24m"),
64
+ inverse: f("\x1B[7m", "\x1B[27m"),
65
+ hidden: f("\x1B[8m", "\x1B[28m"),
66
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
67
+ black: f("\x1B[30m", "\x1B[39m"),
68
+ red: f("\x1B[31m", "\x1B[39m"),
69
+ green: f("\x1B[32m", "\x1B[39m"),
70
+ yellow: f("\x1B[33m", "\x1B[39m"),
71
+ blue: f("\x1B[34m", "\x1B[39m"),
72
+ magenta: f("\x1B[35m", "\x1B[39m"),
73
+ cyan: f("\x1B[36m", "\x1B[39m"),
74
+ white: f("\x1B[37m", "\x1B[39m"),
75
+ gray: f("\x1B[90m", "\x1B[39m"),
76
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
77
+ bgRed: f("\x1B[41m", "\x1B[49m"),
78
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
79
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
80
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
81
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
82
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
83
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
84
+ blackBright: f("\x1B[90m", "\x1B[39m"),
85
+ redBright: f("\x1B[91m", "\x1B[39m"),
86
+ greenBright: f("\x1B[92m", "\x1B[39m"),
87
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
88
+ blueBright: f("\x1B[94m", "\x1B[39m"),
89
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
90
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
91
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
92
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
93
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
94
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
95
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
96
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
97
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
98
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
99
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
100
+ };
101
+ };
102
+ module2.exports = createColors();
103
+ module2.exports.createColors = createColors;
104
+ }
105
+ });
8
106
 
9
- // ../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js
10
- var require_kind_of = __commonJS({
11
- "../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"(exports2, module2) {
107
+ // package.json
108
+ var require_package = __commonJS({
109
+ "package.json"(exports2, module2) {
110
+ module2.exports = {
111
+ name: "@xyd-js/cli",
112
+ version: "0.1.0-xyd.5",
113
+ keywords: [],
114
+ author: "",
115
+ description: "",
116
+ type: "module",
117
+ main: ".cli/index.js",
118
+ files: [
119
+ ".cli",
120
+ ".cli/package.json"
121
+ ],
122
+ scripts: {
123
+ build: "tsup"
124
+ },
125
+ dependencies: {
126
+ "@xyd-js/react-router-dev": "7.1.1-xyd.3",
127
+ arg: "^5.0.2",
128
+ colors: "^1.4.0",
129
+ semver: "^7.6.3",
130
+ codehike: "^1.0.3",
131
+ express: "^4.21.1",
132
+ isbot: "^5.1.17",
133
+ react: "^18.3.1",
134
+ "react-dom": "^18.3.1",
135
+ "react-router": "^7.1.1",
136
+ "remark-frontmatter": "^5.0.0",
137
+ "remark-gfm": "^4.0.0",
138
+ "remark-mdx-frontmatter": "^5.0.0",
139
+ typescript: "^5.6.3",
140
+ vfile: "^6.0.3",
141
+ yaml: "^2.6.0",
142
+ "@graphql-markdown/core": "^1.12.0",
143
+ "@graphql-markdown/graphql": "^1.1.4",
144
+ "@graphql-markdown/types": "^1.4.0",
145
+ "graphql-config": "^5.1.2",
146
+ "gray-matter": "^4.0.3",
147
+ "json-to-graphql-query": "^2.3.0",
148
+ remark: "^15.0.1",
149
+ "remark-stringify": "^11.0.0",
150
+ "unist-builder": "^4.0.0",
151
+ "unist-util-visit": "^5.0.0",
152
+ "@readme/oas-to-snippet": "^26.0.1",
153
+ "js-yaml": "^4.1.0",
154
+ "json-schema-ref-parser": "^9.0.9",
155
+ oas: "^25.0.3",
156
+ "openapi-sampler": "^1.5.1",
157
+ "openapi-types": "^12.1.3",
158
+ "@react-router/node": "^7.1.1",
159
+ "@react-router/serve": "^7.1.1",
160
+ "@react-router/dev": "^7.1.1",
161
+ compression: "^1.7.5",
162
+ "get-port": "^7.1.0",
163
+ lightningcss: "^1.27.0",
164
+ morgan: "^1.10.0",
165
+ "source-map-support": "^0.5.21",
166
+ "vite-tsconfig-paths": "^5.1.4"
167
+ },
168
+ devDependencies: {
169
+ "@xyd-js/documan": "0.1.0-xyd.15",
170
+ tsup: "^8.3.0",
171
+ arg: "^5.0.2",
172
+ colors: "^1.4.0",
173
+ semver: "^7.6.3",
174
+ "vite-tsconfig-paths": "^5.1.4"
175
+ }
176
+ };
177
+ }
178
+ });
179
+
180
+ // src/run.ts
181
+ var import_picocolors = __toESM(require_picocolors(), 1);
182
+ import arg from "arg";
183
+ import semver from "semver";
184
+
185
+ // node_modules/@xyd-js/documan/dist/index.js
186
+ import path4 from "node:path";
187
+ import fs4 from "node:fs";
188
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
189
+ import { execSync } from "child_process";
190
+ import { build as viteBuild } from "vite";
191
+ import tsconfigPaths from "vite-tsconfig-paths";
192
+ import { reactRouter } from "@xyd-js/react-router-dev/vite";
193
+
194
+ // node_modules/@xyd-js/content/dist/index.js
195
+ import { VFile } from "vfile";
196
+ import { compile as mdxCompile } from "@mdx-js/mdx";
197
+ import remarkFrontmatter from "remark-frontmatter";
198
+ import remarkMdxFrontmatter from "remark-mdx-frontmatter";
199
+ import remarkGfm from "remark-gfm";
200
+ import { visit } from "unist-util-visit";
201
+ import { visit as visit2 } from "unist-util-visit";
202
+ import { visit as visit3 } from "unist-util-visit";
203
+ import mdx from "@mdx-js/rollup";
204
+ var remarkMdxToc = (options2) => () => async (ast) => {
205
+ const { visit: visit4 } = await import("unist-util-visit");
206
+ const { toString } = await import("mdast-util-to-string");
207
+ const { valueToEstree } = await import("estree-util-value-to-estree");
208
+ const { name: isIdentifierName } = await import("estree-util-is-identifier-name");
209
+ const mdast = ast;
210
+ const name = options2.name ?? "toc";
211
+ if (!isIdentifierName(name)) {
212
+ throw new Error(`Invalid name for an identifier: ${name}`);
213
+ }
214
+ const toc = [];
215
+ const flatToc = [];
216
+ const createEntry = (node, depth) => {
217
+ let attributes = node.data || {};
218
+ if (node.type === "mdxJsxFlowElement") {
219
+ attributes = Object.fromEntries(
220
+ node.attributes.filter((attribute) => attribute.type === "mdxJsxAttribute" && typeof attribute.value === "string").map((attribute) => [attribute.name, attribute.value])
221
+ );
222
+ }
223
+ return {
224
+ depth,
225
+ value: toString(node, { includeImageAlt: false }),
226
+ attributes,
227
+ children: []
228
+ };
229
+ };
230
+ visit4(mdast, ["heading", "mdxJsxFlowElement"], (node) => {
231
+ let depth = 0;
232
+ if (node.type === "mdxJsxFlowElement") {
233
+ let valid = false;
234
+ if (/^h[1-6]$/.test(node.name || "")) {
235
+ valid = true;
236
+ depth = parseInt(node.name.substring(1));
237
+ } else if (options2.customTags) {
238
+ for (const tag of options2.customTags) {
239
+ if (tag.name.test(node.name || "")) {
240
+ valid = true;
241
+ depth = tag.depth(node.name || "");
242
+ break;
243
+ }
244
+ }
245
+ }
246
+ if (!valid) {
247
+ return;
248
+ }
249
+ } else if (node.type === "heading") {
250
+ depth = node.depth;
251
+ } else {
252
+ return;
253
+ }
254
+ if (depth && ((options2 == null ? void 0 : options2.minDepth) && options2.minDepth > depth)) {
255
+ return;
256
+ }
257
+ const entry = createEntry(node, depth);
258
+ flatToc.push(entry);
259
+ let parent = toc;
260
+ for (let i = flatToc.length - 1; i >= 0; --i) {
261
+ const current = flatToc[i];
262
+ if (current.depth < entry.depth) {
263
+ parent = current.children;
264
+ break;
265
+ }
266
+ }
267
+ parent.push(entry);
268
+ });
269
+ const tocExport = {
270
+ type: "mdxjsEsm",
271
+ value: "",
272
+ data: {
273
+ estree: {
274
+ type: "Program",
275
+ sourceType: "module",
276
+ body: [
277
+ {
278
+ type: "ExportNamedDeclaration",
279
+ specifiers: [],
280
+ source: null,
281
+ declaration: {
282
+ type: "VariableDeclaration",
283
+ kind: "const",
284
+ declarations: [
285
+ {
286
+ type: "VariableDeclarator",
287
+ id: {
288
+ type: "Identifier",
289
+ name
290
+ },
291
+ init: valueToEstree(toc)
292
+ }
293
+ ]
294
+ }
295
+ }
296
+ ]
297
+ }
298
+ }
299
+ };
300
+ mdast.children.unshift(tocExport);
301
+ };
302
+ function remarkInjectCodeMeta() {
303
+ return (tree) => {
304
+ visit(tree, "code", (node) => {
305
+ if (node.meta) {
306
+ node.data = node.data || {};
307
+ node.data.hProperties = {
308
+ ...node.data.hProperties || {},
309
+ meta: node.meta
310
+ };
311
+ }
312
+ });
313
+ };
314
+ }
315
+ var extractThemeSettings = () => {
316
+ return (tree) => {
317
+ visit2(tree, "exportNamedDeclaration", (node) => {
318
+ const declaration = node.declaration;
319
+ if (declaration && declaration.declarations) {
320
+ declaration.declarations.forEach((decl) => {
321
+ if (decl.id.name === "themeSettings") {
322
+ global.themeSettings = decl.init;
323
+ }
324
+ });
325
+ }
326
+ });
327
+ };
328
+ };
329
+ var extractPage = () => {
330
+ return (tree) => {
331
+ visit3(tree, "exportNamedDeclaration", (node) => {
332
+ const declaration = node.declaration;
333
+ if (declaration && declaration.declarations) {
334
+ declaration.declarations.forEach((decl) => {
335
+ if (decl.id.name === "page") {
336
+ global.page = decl.init;
337
+ }
338
+ });
339
+ }
340
+ });
341
+ };
342
+ };
343
+ function mdxOptions(toc) {
344
+ return {
345
+ remarkPlugins: [
346
+ remarkFrontmatter,
347
+ remarkMdxFrontmatter,
348
+ remarkGfm,
349
+ remarkInjectCodeMeta,
350
+ remarkMdxToc(toc),
351
+ extractThemeSettings,
352
+ extractPage
353
+ ],
354
+ rehypePlugins: []
355
+ };
356
+ }
357
+ function vitePlugins(options2) {
358
+ return [
359
+ mdx(mdxOptions(options2.toc))
360
+ ];
361
+ }
362
+
363
+ // node_modules/@xyd-js/plugin-zero/dist/index.js
364
+ import { promises as fs2 } from "fs";
365
+ import path22 from "node:path";
366
+ import { createServer as createServer2 } from "vite";
367
+ import { route } from "@react-router/dev/routes";
368
+ import fs3 from "fs/promises";
369
+ import path3 from "node:path";
370
+ import { createServer } from "vite";
371
+ import { fileURLToPath } from "node:url";
372
+
373
+ // node_modules/@xyd-js/gql/dist/index.js
374
+ import { getDocumentLoaders, loadSchema } from "@graphql-markdown/graphql";
375
+
376
+ // node_modules/@xyd-js/uniform/dist/index.js
377
+ import path from "path";
378
+ import matter from "gray-matter";
379
+ function uniform(references, config) {
380
+ const response = {
381
+ references,
382
+ out: {}
383
+ };
384
+ const finishCallbacks = /* @__PURE__ */ new Set();
385
+ config.plugins.forEach((plugin) => {
386
+ const call = plugin((cb) => {
387
+ finishCallbacks.add(cb);
388
+ });
389
+ references.forEach((ref) => {
390
+ call(ref);
391
+ });
392
+ });
393
+ finishCallbacks.forEach((cb) => {
394
+ if (typeof cb === "function") {
395
+ const resp = cb();
396
+ if (typeof resp !== "object") {
397
+ throw new Error(`Invalid callback return type: ${typeof resp}`);
398
+ }
399
+ response.out = {
400
+ ...response.out,
401
+ ...resp
402
+ };
403
+ } else {
404
+ throw new Error(`Invalid callback type: ${typeof cb}`);
405
+ }
406
+ });
407
+ return response;
408
+ }
409
+ function pluginNavigation(options2) {
410
+ if (!options2.urlPrefix) {
411
+ throw new Error("urlPrefix is required");
412
+ }
413
+ return function pluginNavigationInner(cb) {
414
+ const pageFrontMatter = {};
415
+ const groupMaps = {};
416
+ cb(() => {
417
+ return {
418
+ pageFrontMatter,
419
+ sidebar: convertGroupMapsToNavigations(groupMaps)
420
+ };
421
+ });
422
+ return (ref) => {
423
+ var _a;
424
+ const content = matter(ref.description || "");
425
+ if (content.data) {
426
+ const data = content.data;
427
+ const pagePath = path.join(options2.urlPrefix, ref.canonical);
428
+ if (data.title) {
429
+ pageFrontMatter[pagePath] = {
430
+ title: data.title
431
+ };
432
+ }
433
+ if (data.group) {
434
+ if (typeof ((_a = content == null ? void 0 : content.data) == null ? void 0 : _a.group) === "string") {
435
+ throw new Error("group as string is not supported yet");
436
+ }
437
+ content.data.group.reduce((groups, group, i) => {
438
+ if (!groups[group]) {
439
+ groups[group] = {
440
+ __groups: {},
441
+ pages: /* @__PURE__ */ new Set()
442
+ };
443
+ }
444
+ if (i === content.data.group.length - 1) {
445
+ groups[group].pages.add(pagePath);
446
+ }
447
+ return groups[group].__groups;
448
+ }, groupMaps);
449
+ }
450
+ ref.description = content.content;
451
+ }
452
+ };
453
+ };
454
+ }
455
+ function convertGroupMapsToNavigations(groupMaps) {
456
+ const nav = [];
457
+ Object.keys(groupMaps).map((groupName) => {
458
+ const current = groupMaps[groupName];
459
+ const pages = [];
460
+ current.pages.forEach((page) => {
461
+ pages.push(page);
462
+ });
463
+ if (Object.keys(current.__groups).length) {
464
+ const subNav = {
465
+ group: groupName,
466
+ pages: convertGroupMapsToNavigations(current.__groups)
467
+ };
468
+ nav.push(subNav);
469
+ } else {
470
+ nav.push({
471
+ group: groupName,
472
+ pages
473
+ });
474
+ }
475
+ });
476
+ return nav;
477
+ }
478
+ var ReferenceCategory = /* @__PURE__ */ ((ReferenceCategory22) => {
479
+ ReferenceCategory22["COMPONENTS"] = "components";
480
+ ReferenceCategory22["HOOKS"] = "hooks";
481
+ ReferenceCategory22["REST"] = "rest";
482
+ ReferenceCategory22["GRAPHQL"] = "graphql";
483
+ ReferenceCategory22["FUNCTIONS"] = "functions";
484
+ return ReferenceCategory22;
485
+ })(ReferenceCategory || {});
486
+ var ReferenceType = /* @__PURE__ */ ((ReferenceType22) => {
487
+ ReferenceType22["COMPONENT"] = "component";
488
+ ReferenceType22["HOOK"] = "hook";
489
+ ReferenceType22["REST_HTTP_GET"] = "rest_get";
490
+ ReferenceType22["REST_HTTP_POST"] = "rest_post";
491
+ ReferenceType22["REST_HTTP_PUT"] = "rest_put";
492
+ ReferenceType22["REST_HTTP_PATCH"] = "rest_patch";
493
+ ReferenceType22["REST_HTTP_DELETE"] = "rest_delete";
494
+ ReferenceType22["GRAPHQL_QUERY"] = "graphql_query";
495
+ ReferenceType22["GRAPHQL_MUTATION"] = "graphql_mutation";
496
+ ReferenceType22["FUNCTION_JS"] = "function_js";
497
+ return ReferenceType22;
498
+ })(ReferenceType || {});
499
+
500
+ // node_modules/@xyd-js/gql/dist/index.js
501
+ import { jsonToGraphQLQuery, VariableType } from "json-to-graphql-query";
502
+ var __create2 = Object.create;
503
+ var __defProp2 = Object.defineProperty;
504
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
505
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
506
+ var __getProtoOf2 = Object.getPrototypeOf;
507
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
508
+ var __commonJS2 = (cb, mod) => function __require3() {
509
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
510
+ };
511
+ var __copyProps2 = (to, from, except, desc) => {
512
+ if (from && typeof from === "object" || typeof from === "function") {
513
+ for (let key of __getOwnPropNames2(from))
514
+ if (!__hasOwnProp2.call(to, key) && key !== except)
515
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
516
+ }
517
+ return to;
518
+ };
519
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
520
+ // If the importer is in node compatibility mode or this is not an ESM
521
+ // file that has been converted to a CommonJS file using a Babel-
522
+ // compatible transform (i.e. "__esModule" has not been set), then set
523
+ // "default" to the CommonJS "module.exports" for node compatibility.
524
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
525
+ mod
526
+ ));
527
+ var require_ast = __commonJS2({
528
+ "node_modules/graphql/language/ast.js"(exports2) {
529
+ "use strict";
530
+ Object.defineProperty(exports2, "__esModule", {
531
+ value: true
532
+ });
533
+ exports2.Token = exports2.QueryDocumentKeys = exports2.OperationTypeNode = exports2.Location = void 0;
534
+ exports2.isNode = isNode;
535
+ var Location = class {
536
+ /**
537
+ * The character offset at which this Node begins.
538
+ */
539
+ /**
540
+ * The character offset at which this Node ends.
541
+ */
542
+ /**
543
+ * The Token at which this Node begins.
544
+ */
545
+ /**
546
+ * The Token at which this Node ends.
547
+ */
548
+ /**
549
+ * The Source document the AST represents.
550
+ */
551
+ constructor(startToken, endToken, source) {
552
+ this.start = startToken.start;
553
+ this.end = endToken.end;
554
+ this.startToken = startToken;
555
+ this.endToken = endToken;
556
+ this.source = source;
557
+ }
558
+ get [Symbol.toStringTag]() {
559
+ return "Location";
560
+ }
561
+ toJSON() {
562
+ return {
563
+ start: this.start,
564
+ end: this.end
565
+ };
566
+ }
567
+ };
568
+ exports2.Location = Location;
569
+ var Token = class {
570
+ /**
571
+ * The kind of Token.
572
+ */
573
+ /**
574
+ * The character offset at which this Node begins.
575
+ */
576
+ /**
577
+ * The character offset at which this Node ends.
578
+ */
579
+ /**
580
+ * The 1-indexed line number on which this Token appears.
581
+ */
582
+ /**
583
+ * The 1-indexed column number at which this Token begins.
584
+ */
585
+ /**
586
+ * For non-punctuation tokens, represents the interpreted value of the token.
587
+ *
588
+ * Note: is undefined for punctuation tokens, but typed as string for
589
+ * convenience in the parser.
590
+ */
591
+ /**
592
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
593
+ * including ignored tokens. <SOF> is always the first node and <EOF>
594
+ * the last.
595
+ */
596
+ constructor(kind, start2, end, line, column, value) {
597
+ this.kind = kind;
598
+ this.start = start2;
599
+ this.end = end;
600
+ this.line = line;
601
+ this.column = column;
602
+ this.value = value;
603
+ this.prev = null;
604
+ this.next = null;
605
+ }
606
+ get [Symbol.toStringTag]() {
607
+ return "Token";
608
+ }
609
+ toJSON() {
610
+ return {
611
+ kind: this.kind,
612
+ value: this.value,
613
+ line: this.line,
614
+ column: this.column
615
+ };
616
+ }
617
+ };
618
+ exports2.Token = Token;
619
+ var QueryDocumentKeys = {
620
+ Name: [],
621
+ Document: ["definitions"],
622
+ OperationDefinition: [
623
+ "name",
624
+ "variableDefinitions",
625
+ "directives",
626
+ "selectionSet"
627
+ ],
628
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
629
+ Variable: ["name"],
630
+ SelectionSet: ["selections"],
631
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
632
+ Argument: ["name", "value"],
633
+ FragmentSpread: ["name", "directives"],
634
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
635
+ FragmentDefinition: [
636
+ "name",
637
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
638
+ "variableDefinitions",
639
+ "typeCondition",
640
+ "directives",
641
+ "selectionSet"
642
+ ],
643
+ IntValue: [],
644
+ FloatValue: [],
645
+ StringValue: [],
646
+ BooleanValue: [],
647
+ NullValue: [],
648
+ EnumValue: [],
649
+ ListValue: ["values"],
650
+ ObjectValue: ["fields"],
651
+ ObjectField: ["name", "value"],
652
+ Directive: ["name", "arguments"],
653
+ NamedType: ["name"],
654
+ ListType: ["type"],
655
+ NonNullType: ["type"],
656
+ SchemaDefinition: ["description", "directives", "operationTypes"],
657
+ OperationTypeDefinition: ["type"],
658
+ ScalarTypeDefinition: ["description", "name", "directives"],
659
+ ObjectTypeDefinition: [
660
+ "description",
661
+ "name",
662
+ "interfaces",
663
+ "directives",
664
+ "fields"
665
+ ],
666
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
667
+ InputValueDefinition: [
668
+ "description",
669
+ "name",
670
+ "type",
671
+ "defaultValue",
672
+ "directives"
673
+ ],
674
+ InterfaceTypeDefinition: [
675
+ "description",
676
+ "name",
677
+ "interfaces",
678
+ "directives",
679
+ "fields"
680
+ ],
681
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
682
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
683
+ EnumValueDefinition: ["description", "name", "directives"],
684
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
685
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
686
+ SchemaExtension: ["directives", "operationTypes"],
687
+ ScalarTypeExtension: ["name", "directives"],
688
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
689
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
690
+ UnionTypeExtension: ["name", "directives", "types"],
691
+ EnumTypeExtension: ["name", "directives", "values"],
692
+ InputObjectTypeExtension: ["name", "directives", "fields"]
693
+ };
694
+ exports2.QueryDocumentKeys = QueryDocumentKeys;
695
+ var kindValues = new Set(Object.keys(QueryDocumentKeys));
696
+ function isNode(maybeNode) {
697
+ const maybeKind = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind;
698
+ return typeof maybeKind === "string" && kindValues.has(maybeKind);
699
+ }
700
+ var OperationTypeNode2;
701
+ exports2.OperationTypeNode = OperationTypeNode2;
702
+ (function(OperationTypeNode3) {
703
+ OperationTypeNode3["QUERY"] = "query";
704
+ OperationTypeNode3["MUTATION"] = "mutation";
705
+ OperationTypeNode3["SUBSCRIPTION"] = "subscription";
706
+ })(OperationTypeNode2 || (exports2.OperationTypeNode = OperationTypeNode2 = {}));
707
+ }
708
+ });
709
+ var import_ast = __toESM2(require_ast(), 1);
710
+ function fieldIntoDefinitionProperty(fieldName, field) {
711
+ let properties2;
712
+ if ("ofType" in field.type) {
713
+ switch (field.type.constructor.name) {
714
+ case "GraphQLList": {
715
+ switch (field.type.ofType.constructor.name) {
716
+ case "GraphQLObjectType": {
717
+ const objectType = field.type.ofType;
718
+ properties2 = nestedProperties(objectType);
719
+ break;
720
+ }
721
+ case "GraphQLInputObjectType": {
722
+ const inputObjectType = field.type.ofType;
723
+ properties2 = nestedProperties(inputObjectType);
724
+ break;
725
+ }
726
+ case "GraphQLScalarType": {
727
+ properties2 = definitionPropsFromNestedObj(field) || [];
728
+ break;
729
+ }
730
+ case "GraphQLNonNull": {
731
+ properties2 = definitionPropsFromNestedObj(field) || [];
732
+ break;
733
+ }
734
+ default: {
735
+ console.error("unsupported ofType list", field.type.ofType.constructor.name);
736
+ break;
737
+ }
738
+ }
739
+ break;
740
+ }
741
+ case "GraphQLNonNull": {
742
+ properties2 = definitionPropsFromNestedObj(field) || [];
743
+ break;
744
+ }
745
+ default: {
746
+ console.error("unsupported ofType", field.type.constructor.name);
747
+ break;
748
+ }
749
+ }
750
+ } else if (field.type.constructor.name === "GraphQLObjectType") {
751
+ const objectType = field.type;
752
+ properties2 = nestedProperties(objectType);
753
+ } else if (field.type.constructor.name === "GraphQLInputObjectType") {
754
+ const objectType = field.type;
755
+ properties2 = nestedProperties(objectType);
756
+ }
757
+ return {
758
+ name: fieldName,
759
+ type: field.type.toJSON(),
760
+ description: field.description || "",
761
+ properties: properties2
762
+ };
763
+ }
764
+ function definitionPropsFromNestedObj(obj) {
765
+ if (!obj) {
766
+ return null;
767
+ }
768
+ if (obj.getFields) {
769
+ return nestedProperties(obj);
770
+ }
771
+ if (obj.ofType) {
772
+ return definitionPropsFromNestedObj(obj.ofType);
773
+ }
774
+ if (obj.type) {
775
+ return definitionPropsFromNestedObj(obj.type);
776
+ }
777
+ return null;
778
+ }
779
+ function deepFieldMap(fieldsMap) {
780
+ const properties2 = [];
781
+ for (const [name, field] of Object.entries(fieldsMap)) {
782
+ const prop = fieldIntoDefinitionProperty(
783
+ name,
784
+ field
785
+ );
786
+ if (prop) {
787
+ properties2.push(prop);
788
+ }
789
+ }
790
+ return properties2;
791
+ }
792
+ function nestedProperties(objectType) {
793
+ var _a;
794
+ const nestedFields = (_a = objectType == null ? void 0 : objectType.getFields) == null ? void 0 : _a.call(objectType);
795
+ return deepFieldMap(nestedFields);
796
+ }
797
+ function argumentsIntoDefinitionProperty(args) {
798
+ const resp = [];
799
+ args.forEach((arg2) => {
800
+ var _a;
801
+ if (arg2.type.constructor.name === "GraphQLInputObjectType") {
802
+ const inputObjectType = arg2.type;
803
+ const inputFields = (_a = inputObjectType.getFields) == null ? void 0 : _a.call(inputObjectType);
804
+ const nestedProps = [];
805
+ const nestedDefinitionProperty = {
806
+ name: arg2.name,
807
+ type: arg2.type.toJSON(),
808
+ description: arg2.description || "",
809
+ properties: nestedProps
810
+ };
811
+ for (const [name, inputField] of Object.entries(inputFields)) {
812
+ const prop = fieldIntoDefinitionProperty(
813
+ name,
814
+ inputField
815
+ );
816
+ if (prop) {
817
+ nestedProps.push(prop);
818
+ }
819
+ }
820
+ resp.push(nestedDefinitionProperty);
821
+ } else {
822
+ const prop = {
823
+ name: arg2.name,
824
+ type: arg2.type.toJSON(),
825
+ description: arg2.description || "",
826
+ properties: []
827
+ };
828
+ resp.push(prop);
829
+ }
830
+ });
831
+ return resp;
832
+ }
833
+ function simpleGraphqlExample(operationType, operationName, args, returns) {
834
+ let obj = {};
835
+ switch (operationType) {
836
+ case ReferenceType.GRAPHQL_QUERY: {
837
+ const exampleReturnProps = exampleReturns(returns);
838
+ obj = {
839
+ query: {
840
+ __name: operationName,
841
+ [operationName]: exampleReturnProps
842
+ }
843
+ };
844
+ break;
845
+ }
846
+ case ReferenceType.GRAPHQL_MUTATION: {
847
+ const exampleReturnProps = exampleReturns(returns);
848
+ const vars = exampleVariables(args);
849
+ const argumen = exampleArguments(args);
850
+ obj = {
851
+ mutation: {
852
+ __name: operationName,
853
+ __variables: vars,
854
+ [operationName]: {
855
+ ...exampleReturnProps,
856
+ __args: argumen
857
+ }
858
+ }
859
+ };
860
+ break;
861
+ }
862
+ }
863
+ return jsonToGraphQLQuery(obj, { pretty: true });
864
+ }
865
+ function exampleReturns(properties2, obj = {}) {
866
+ properties2.forEach((property) => {
867
+ var _a;
868
+ obj[property.name] = true;
869
+ if ((_a = property == null ? void 0 : property.properties) == null ? void 0 : _a.length) {
870
+ obj[property.name] = {};
871
+ exampleReturns(property.properties, obj[property.name]);
872
+ }
873
+ });
874
+ return obj;
875
+ }
876
+ function exampleArguments(properties2, obj = {}) {
877
+ properties2.forEach((property) => {
878
+ obj[property.name] = new VariableType(property.name);
879
+ });
880
+ return obj;
881
+ }
882
+ function exampleVariables(properties2, obj = {}) {
883
+ properties2.forEach((property) => {
884
+ obj[property.name] = property.type;
885
+ });
886
+ return obj;
887
+ }
888
+ function graphqlOperationReferences(operationType, fieldsMap) {
889
+ const references = [];
890
+ for (const [operationName, operationField] of Object.entries(fieldsMap)) {
891
+ const definitions2 = [];
892
+ const args = argumentsIntoDefinitionProperty(operationField.args);
893
+ const returns = fieldIntoDefinitionProperty(operationName, operationField);
894
+ const returnProperties = returns.properties || [];
895
+ definitions2.push({
896
+ title: "Arguments",
897
+ properties: args
898
+ });
899
+ definitions2.push({
900
+ title: "Returns",
901
+ properties: returnProperties
902
+ });
903
+ const exampleQuery = simpleGraphqlExample(
904
+ operationType,
905
+ operationName,
906
+ args,
907
+ returnProperties
908
+ );
909
+ const examples2 = [
910
+ {
911
+ codeblock: {
912
+ tabs: [
913
+ {
914
+ title: "graphql",
915
+ language: "graphql",
916
+ code: exampleQuery
917
+ }
918
+ ]
919
+ }
920
+ }
921
+ ];
922
+ const exampleGroup = {
923
+ description: "Example request",
924
+ examples: examples2
925
+ };
926
+ let description = operationField.description || "";
927
+ references.push(graphqlReference(
928
+ operationType,
929
+ operationName,
930
+ operationName,
931
+ description,
932
+ [exampleGroup],
933
+ definitions2
934
+ ));
935
+ }
936
+ return references;
937
+ }
938
+ function graphqlReference(operationType, title, canonical, description, examples2, definitions2) {
939
+ return {
940
+ title,
941
+ canonical,
942
+ description,
943
+ category: ReferenceCategory.GRAPHQL,
944
+ type: operationType,
945
+ examples: {
946
+ groups: examples2
947
+ },
948
+ definitions: definitions2
949
+ };
950
+ }
951
+ async function gqlSchemaToReferences(schemaLocation) {
952
+ var _a, _b;
953
+ const loadersList = {
954
+ ["GraphQLFileLoader"]: "@graphql-tools/graphql-file-loader"
955
+ };
956
+ const loaders = await getDocumentLoaders(loadersList);
957
+ const schema = await loadSchema(schemaLocation, loaders);
958
+ const references = [];
959
+ const queries = schema.getRootType(import_ast.OperationTypeNode.QUERY);
960
+ const queryFields = (_a = queries == null ? void 0 : queries.getFields) == null ? void 0 : _a.call(queries);
961
+ if (queryFields) {
962
+ references.push(...graphqlOperationReferences(
963
+ ReferenceType.GRAPHQL_QUERY,
964
+ queryFields
965
+ ));
966
+ }
967
+ const mutations = schema.getRootType(import_ast.OperationTypeNode.MUTATION);
968
+ const mutationFields = (_b = mutations == null ? void 0 : mutations.getFields) == null ? void 0 : _b.call(mutations);
969
+ if (mutationFields) {
970
+ references.push(...graphqlOperationReferences(
971
+ ReferenceType.GRAPHQL_MUTATION,
972
+ mutationFields
973
+ ));
974
+ }
975
+ return references;
976
+ }
977
+
978
+ // node_modules/@xyd-js/plugin-zero/dist/index.js
979
+ import path32 from "path";
980
+ import { promises as fs32 } from "fs";
981
+ import { route as route2 } from "@react-router/dev/routes";
982
+
983
+ // node_modules/@xyd-js/uniform/dist/markdown.js
984
+ import { remark } from "remark";
985
+ import remarkStringify from "remark-stringify";
986
+ import { u } from "unist-builder";
987
+ var START_DEPTH_LEVEL = 2;
988
+ function root(ast) {
989
+ return u("root", ast);
990
+ }
991
+ function heading(title, canonical, description, refCategory, refType, refContext) {
992
+ const uTitle = u(
993
+ "heading",
994
+ { depth: START_DEPTH_LEVEL },
995
+ [u("text", `!!references ${title}`)]
996
+ );
997
+ const uCanonical = u(
998
+ "heading",
999
+ { depth: uTitle.depth + 1 },
1000
+ [u("text", `!canonical ${canonical}`)]
1001
+ );
1002
+ let uDesc = [
1003
+ u(
1004
+ "heading",
1005
+ { depth: START_DEPTH_LEVEL },
1006
+ [u("text", `!description`)]
1007
+ ),
1008
+ u("paragraph", [u("text", description)])
1009
+ ];
1010
+ let uRefCategory;
1011
+ if (refCategory) {
1012
+ uRefCategory = u(
1013
+ "heading",
1014
+ { depth: uTitle.depth + 1 },
1015
+ [u("text", `!category ${refCategory}`)]
1016
+ );
1017
+ }
1018
+ let uRefType;
1019
+ if (refType) {
1020
+ uRefType = u(
1021
+ "heading",
1022
+ { depth: uTitle.depth + 1 },
1023
+ [u("text", `!type ${refType}`)]
1024
+ );
1025
+ }
1026
+ let uContext = [];
1027
+ if (refContext && Object.keys(refContext)) {
1028
+ uContext.push(u(
1029
+ "heading",
1030
+ { depth: uTitle.depth + 1 },
1031
+ [
1032
+ u("text", `!context`)
1033
+ ]
1034
+ ));
1035
+ for (const [key, value] of Object.entries(refContext)) {
1036
+ uContext.push(
1037
+ u(
1038
+ "heading",
1039
+ { depth: uContext[0].depth + 1 },
1040
+ [u("text", `!${key} ${value}`)]
1041
+ )
1042
+ );
1043
+ }
1044
+ }
1045
+ return {
1046
+ title: uTitle,
1047
+ canonical: uCanonical,
1048
+ description: uDesc,
1049
+ category: uRefCategory || null,
1050
+ type: uRefType || null,
1051
+ context: uContext || null
1052
+ };
1053
+ }
1054
+ function examples(examples2) {
1055
+ const md = [];
1056
+ const uExampleRoot = u(
1057
+ "heading",
1058
+ { depth: START_DEPTH_LEVEL + 1 },
1059
+ [u("text", `!examples`)]
1060
+ );
1061
+ md.push(uExampleRoot);
1062
+ examples2.groups.forEach((group) => {
1063
+ const uExampleGroups = u(
1064
+ "heading",
1065
+ { depth: uExampleRoot.depth + 1 },
1066
+ [u("text", `!!groups`)]
1067
+ );
1068
+ md.push(uExampleGroups);
1069
+ const uGroupDescription = u(
1070
+ "heading",
1071
+ { depth: uExampleGroups.depth + 1 },
1072
+ [u("text", `!description ${group.description}`)]
1073
+ );
1074
+ md.push(uGroupDescription);
1075
+ group.examples.forEach((example) => {
1076
+ const uExamples = u(
1077
+ "heading",
1078
+ { depth: uExampleGroups.depth + 1 },
1079
+ [u("text", `!!examples`)]
1080
+ );
1081
+ md.push(uExamples);
1082
+ const codeBlock = u(
1083
+ "heading",
1084
+ { depth: uExamples.depth + 1 },
1085
+ [u("text", `!codeblock`)]
1086
+ );
1087
+ md.push(codeBlock);
1088
+ const codeBlockTitle = u(
1089
+ "heading",
1090
+ { depth: codeBlock.depth + 1 },
1091
+ [u("text", `!title ${example.codeblock.title}`)]
1092
+ );
1093
+ md.push(codeBlockTitle);
1094
+ const tabs = u(
1095
+ "heading",
1096
+ { depth: codeBlock.depth + 1 },
1097
+ [u("text", `!!tabs`)]
1098
+ );
1099
+ md.push(tabs);
1100
+ example.codeblock.tabs.forEach((tab) => {
1101
+ const code = u("code", {
1102
+ lang: tab.language,
1103
+ meta: `!code ${tab.title}`
1104
+ }, tab.code);
1105
+ md.push(code);
1106
+ });
1107
+ });
1108
+ });
1109
+ return md;
1110
+ }
1111
+ function definitions(definitions2) {
1112
+ const md = [];
1113
+ definitions2.forEach((definition) => {
1114
+ const uDefinition = u(
1115
+ "heading",
1116
+ { depth: START_DEPTH_LEVEL + 1 },
1117
+ [u("text", `!!definitions`)]
1118
+ );
1119
+ md.push(uDefinition);
1120
+ md.push(u(
1121
+ "heading",
1122
+ { depth: uDefinition.depth + 1 },
1123
+ [u("text", `!title ${definition.title}`)]
1124
+ ));
1125
+ definition.properties.forEach((prop) => {
1126
+ properties(
1127
+ uDefinition.depth + 1,
1128
+ {
1129
+ name: prop.name,
1130
+ type: prop.type,
1131
+ description: prop.description,
1132
+ properties: prop.properties
1133
+ // TODO: fix ts
1134
+ },
1135
+ md
1136
+ );
1137
+ });
1138
+ });
1139
+ return md;
1140
+ }
1141
+ function properties(depth, props, output = []) {
1142
+ const paramName = props.name;
1143
+ const propTitle = `!!properties ${paramName}`;
1144
+ const uPropTitle = u("heading", { depth }, [u("text", propTitle)]);
1145
+ const uPropName = u("paragraph", { depth }, [u("text", `!name ${paramName}`)]);
1146
+ const uPropType = u("paragraph", { depth }, [u("text", `!type ${props.type}`)]);
1147
+ const uPropDesc = u("paragraph", { depth }, [u("text", props.description || "")]);
1148
+ output.push(
1149
+ uPropTitle,
1150
+ uPropName,
1151
+ uPropType,
1152
+ uPropDesc
1153
+ );
1154
+ if (props.properties) {
1155
+ const deepDepth = depth + 1;
1156
+ for (const prop of props.properties) {
1157
+ properties(deepDepth, prop, output);
1158
+ }
1159
+ }
1160
+ }
1161
+ function compile(ast) {
1162
+ return remark().use(remarkStringify, {
1163
+ bullet: "-",
1164
+ fences: true,
1165
+ listItemIndent: "one",
1166
+ incrementListMarker: false,
1167
+ handlers: {
1168
+ heading(node) {
1169
+ return `${"#".repeat(node.depth)} ${node.children[0].value}`;
1170
+ }
1171
+ }
1172
+ }).stringify(root(ast));
1173
+ }
1174
+ function referenceAST(ref) {
1175
+ var _a, _b;
1176
+ const md = [];
1177
+ const mdHeading = heading(
1178
+ ref.title,
1179
+ ref.canonical,
1180
+ ref.description,
1181
+ ref.category,
1182
+ ref.type,
1183
+ ref.context
1184
+ );
1185
+ if ((_a = mdHeading == null ? void 0 : mdHeading.description) == null ? void 0 : _a.length) {
1186
+ md.push(...mdHeading.description);
1187
+ }
1188
+ md.push(
1189
+ mdHeading.title,
1190
+ mdHeading.canonical
1191
+ );
1192
+ if (mdHeading.category) {
1193
+ md.push(mdHeading.category);
1194
+ }
1195
+ if (mdHeading.type) {
1196
+ md.push(mdHeading.type);
1197
+ }
1198
+ if ((_b = mdHeading == null ? void 0 : mdHeading.context) == null ? void 0 : _b.length) {
1199
+ md.push(...mdHeading.context);
1200
+ }
1201
+ const mdExamples = examples(ref.examples);
1202
+ const mdDefinitions = definitions(ref.definitions);
1203
+ md.push(...mdExamples, ...mdDefinitions);
1204
+ return md;
1205
+ }
1206
+
1207
+ // node_modules/@xyd-js/openapi/dist/index.js
1208
+ import Oas from "oas";
1209
+
1210
+ // node_modules/@xyd-js/openapi/node_modules/@xyd-js/uniform/dist/index.js
1211
+ import matter2 from "gray-matter";
1212
+ var ReferenceCategory2 = /* @__PURE__ */ ((ReferenceCategory22) => {
1213
+ ReferenceCategory22["COMPONENTS"] = "components";
1214
+ ReferenceCategory22["HOOKS"] = "hooks";
1215
+ ReferenceCategory22["REST"] = "rest";
1216
+ ReferenceCategory22["GRAPHQL"] = "graphql";
1217
+ ReferenceCategory22["FUNCTIONS"] = "functions";
1218
+ return ReferenceCategory22;
1219
+ })(ReferenceCategory2 || {});
1220
+ var ReferenceType2 = /* @__PURE__ */ ((ReferenceType22) => {
1221
+ ReferenceType22["COMPONENT"] = "component";
1222
+ ReferenceType22["HOOK"] = "hook";
1223
+ ReferenceType22["REST_HTTP_GET"] = "rest_get";
1224
+ ReferenceType22["REST_HTTP_POST"] = "rest_post";
1225
+ ReferenceType22["REST_HTTP_PUT"] = "rest_put";
1226
+ ReferenceType22["REST_HTTP_PATCH"] = "rest_patch";
1227
+ ReferenceType22["REST_HTTP_DELETE"] = "rest_delete";
1228
+ ReferenceType22["GRAPHQL_QUERY"] = "graphql_query";
1229
+ ReferenceType22["GRAPHQL_MUTATION"] = "graphql_mutation";
1230
+ ReferenceType22["FUNCTION_JS"] = "function_js";
1231
+ return ReferenceType22;
1232
+ })(ReferenceType2 || {});
1233
+
1234
+ // node_modules/@xyd-js/openapi/dist/index.js
1235
+ import path2 from "path";
1236
+ import fs from "fs";
1237
+ import yaml2 from "js-yaml";
1238
+ import $refParser from "json-schema-ref-parser";
1239
+ import oasToSnippet from "@readme/oas-to-snippet";
1240
+ import OpenAPISampler from "openapi-sampler";
1241
+ var SUPPORTED_HTTP_METHODS = [
1242
+ "get",
1243
+ "put",
1244
+ "patch",
1245
+ "post",
1246
+ "delete"
1247
+ // 'options',
1248
+ // 'head',
1249
+ // 'trace'
1250
+ ];
1251
+ function oapParametersToDefinitionProperties(parameters) {
1252
+ const parameterIn = {};
1253
+ parameters.forEach((param) => {
1254
+ if (!parameterIn[param.in]) {
1255
+ parameterIn[param.in] = [];
1256
+ }
1257
+ const schema = param.schema;
1258
+ const property = {
1259
+ name: param.name,
1260
+ type: schema.type || "",
1261
+ description: param.description || ""
1262
+ };
1263
+ parameterIn[param.in].push(property);
1264
+ });
1265
+ return parameterIn;
1266
+ }
1267
+ function schemaObjectToDefinitionProperties(v) {
1268
+ return Object.entries(v.properties || {}).map(([name, prop]) => {
1269
+ let objProp = prop;
1270
+ let merged = [];
1271
+ if (objProp.allOf) {
1272
+ merged = objProp.allOf.reduce((acc, of) => {
1273
+ return [
1274
+ ...acc,
1275
+ ...schemaObjectToDefinitionProperties(of)
1276
+ ];
1277
+ }, []);
1278
+ }
1279
+ return {
1280
+ name,
1281
+ type: objProp.type || "",
1282
+ description: objProp.description || "",
1283
+ properties: (merged == null ? void 0 : merged.length) ? merged : objProp.properties ? schemaObjectToDefinitionProperties(objProp) : []
1284
+ };
1285
+ });
1286
+ }
1287
+ function oapRequestBodyToDefinitionProperties(reqBody) {
1288
+ const schema = reqBody.content["application/json"].schema;
1289
+ let schemaObject;
1290
+ if (schema.allOf) {
1291
+ return schema.allOf.reduce((acc, of) => {
1292
+ const fakeBody = {
1293
+ content: {
1294
+ "application/json": {
1295
+ schema: of
1296
+ }
1297
+ }
1298
+ };
1299
+ return [
1300
+ ...acc,
1301
+ ...oapRequestBodyToDefinitionProperties(fakeBody) || []
1302
+ ];
1303
+ }, []);
1304
+ }
1305
+ switch (schema.type) {
1306
+ case "object": {
1307
+ schemaObject = schema;
1308
+ break;
1309
+ }
1310
+ case "array": {
1311
+ const arrSchema = schema;
1312
+ const items = arrSchema.items;
1313
+ schemaObject = items;
1314
+ break;
1315
+ }
1316
+ default:
1317
+ break;
1318
+ }
1319
+ if (!schemaObject) {
1320
+ return null;
1321
+ }
1322
+ return schemaObjectToDefinitionProperties(schemaObject);
1323
+ }
1324
+ function oapResponseToDefinitionProperties(responses) {
1325
+ var _a, _b, _c, _d;
1326
+ let schemaObject;
1327
+ if (responses["default"]) {
1328
+ const w = responses["default"];
1329
+ schemaObject = (_b = (_a = w == null ? void 0 : w.content) == null ? void 0 : _a["application/json"]) == null ? void 0 : _b.schema;
1330
+ } else if (responses["200"]) {
1331
+ const w = responses["200"];
1332
+ schemaObject = (_d = (_c = w == null ? void 0 : w.content) == null ? void 0 : _c["application/json"]) == null ? void 0 : _d.schema;
1333
+ }
1334
+ if (!schemaObject) {
1335
+ return null;
1336
+ }
1337
+ switch (schemaObject.type) {
1338
+ case "array":
1339
+ const arrSchema = schemaObject;
1340
+ const items = arrSchema.items;
1341
+ schemaObject = items;
1342
+ break;
1343
+ default:
1344
+ break;
1345
+ }
1346
+ return schemaObjectToDefinitionProperties(schemaObject);
1347
+ }
1348
+ function toPascalCase(str2) {
1349
+ return str2.split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
1350
+ }
1351
+ function readOpenApiSpec(filePath) {
1352
+ const ext = path2.extname(filePath).toLowerCase();
1353
+ const content = fs.readFileSync(filePath, "utf-8");
1354
+ if (ext === ".yaml" || ext === ".yml") {
1355
+ return yaml2.load(content);
1356
+ } else if (ext === ".json") {
1357
+ return JSON.parse(content);
1358
+ } else {
1359
+ throw new Error("Unsupported file format. Use JSON or YAML.");
1360
+ }
1361
+ }
1362
+ async function deferencedOpenAPI(openApiPath) {
1363
+ const openApiSpec = readOpenApiSpec(openApiPath);
1364
+ await $refParser.dereference(openApiSpec);
1365
+ return openApiSpec;
1366
+ }
1367
+ function httpMethodToUniformMethod(method) {
1368
+ switch (method) {
1369
+ case "get":
1370
+ return ReferenceType2.REST_HTTP_GET;
1371
+ case "put":
1372
+ return ReferenceType2.REST_HTTP_PUT;
1373
+ case "patch":
1374
+ return ReferenceType2.REST_HTTP_PATCH;
1375
+ case "post":
1376
+ return ReferenceType2.REST_HTTP_POST;
1377
+ case "delete":
1378
+ return ReferenceType2.REST_HTTP_DELETE;
1379
+ // case 'options':
1380
+ // return ReferenceType.REST_HTTP_OPTIONS
1381
+ // case 'head':
1382
+ // return ReferenceType.REST_HTTP_HEAD
1383
+ // case 'trace':
1384
+ // return ReferenceType.REST_HTTP_TRACE
1385
+ default:
1386
+ return null;
1387
+ }
1388
+ }
1389
+ function oapPathToReference(httpMethod, path24, oapPath) {
1390
+ const mType = httpMethodToUniformMethod(httpMethod);
1391
+ if (!mType) {
1392
+ console.error(`Unsupported method: ${httpMethod}`);
1393
+ return null;
1394
+ }
1395
+ const definitions2 = [];
1396
+ const exampleGroups = [];
1397
+ const oapMethod = oapPath == null ? void 0 : oapPath[httpMethod];
1398
+ if (!oapMethod) {
1399
+ return null;
1400
+ }
1401
+ const endpointRef = {
1402
+ title: (oapMethod == null ? void 0 : oapMethod.summary) || "",
1403
+ canonical: toPascalCase((oapMethod == null ? void 0 : oapMethod.summary) || ""),
1404
+ description: (oapMethod == null ? void 0 : oapMethod.description) || "",
1405
+ category: ReferenceCategory2.REST,
1406
+ type: mType,
1407
+ context: {
1408
+ method: httpMethod,
1409
+ path: path24
1410
+ },
1411
+ examples: {
1412
+ groups: exampleGroups
1413
+ },
1414
+ definitions: definitions2
1415
+ };
1416
+ if (oapMethod.parameters) {
1417
+ const parameters = oapMethod.parameters;
1418
+ const paramtersMap = oapParametersToDefinitionProperties(parameters);
1419
+ Object.entries(paramtersMap).forEach(([key, definitionProperties]) => {
1420
+ let title;
1421
+ switch (key) {
1422
+ case "path":
1423
+ title = "Paths";
1424
+ break;
1425
+ case "query":
1426
+ title = "Query";
1427
+ break;
1428
+ case "header":
1429
+ title = "Header";
1430
+ break;
1431
+ default:
1432
+ console.error(`Unsupported parameter type: ${key} for ${httpMethod} ${path24}`);
1433
+ return;
1434
+ }
1435
+ definitions2.push({
1436
+ title,
1437
+ properties: definitionProperties
1438
+ });
1439
+ });
1440
+ }
1441
+ if (oapMethod.requestBody) {
1442
+ const reqBody = oapMethod.requestBody;
1443
+ definitions2.push({
1444
+ title: "Request body",
1445
+ properties: oapRequestBodyToDefinitionProperties(reqBody) || []
1446
+ });
1447
+ }
1448
+ if (oapMethod.responses) {
1449
+ const responses = oapMethod.responses;
1450
+ definitions2.push({
1451
+ title: "Response",
1452
+ properties: oapResponseToDefinitionProperties(responses) || []
1453
+ });
1454
+ }
1455
+ return endpointRef;
1456
+ }
1457
+ function oapExamples(oas, operation) {
1458
+ const exampleGroups = [];
1459
+ if (operation.schema.requestBody) {
1460
+ const body = operation.schema.requestBody;
1461
+ const schema = fixAllOfBug(
1462
+ body.content["application/json"].schema
1463
+ );
1464
+ if (!schema) {
1465
+ return exampleGroups;
1466
+ }
1467
+ const fakeData = OpenAPISampler.sample(schema);
1468
+ const { code } = oasToSnippet(oas, operation, {
1469
+ body: fakeData
1470
+ }, null, "shell");
1471
+ const examples2 = [];
1472
+ examples2.push({
1473
+ codeblock: {
1474
+ tabs: [{
1475
+ title: "curl",
1476
+ language: "curl",
1477
+ code: code || ""
1478
+ }]
1479
+ }
1480
+ });
1481
+ exampleGroups.push({
1482
+ description: "Example request",
1483
+ examples: examples2
1484
+ });
1485
+ }
1486
+ if (operation.schema.responses) {
1487
+ const responses = operation.schema.responses;
1488
+ const examples2 = [];
1489
+ Object.entries(responses).forEach(([status, r]) => {
1490
+ var _a;
1491
+ const response = r;
1492
+ const schema = (_a = response == null ? void 0 : response.content) == null ? void 0 : _a["application/json"].schema;
1493
+ if (!schema) {
1494
+ return;
1495
+ }
1496
+ const fakeData = OpenAPISampler.sample(schema);
1497
+ examples2.push({
1498
+ codeblock: {
1499
+ title: status,
1500
+ tabs: [{
1501
+ title: "json",
1502
+ language: "json",
1503
+ code: JSON.stringify(fakeData, null, 2) || ""
1504
+ }]
1505
+ }
1506
+ });
1507
+ });
1508
+ exampleGroups.push({
1509
+ description: "Response",
1510
+ examples: examples2
1511
+ });
1512
+ }
1513
+ return exampleGroups;
1514
+ }
1515
+ function fixAllOfBug(schema) {
1516
+ const modifiedSchema = { ...schema };
1517
+ if (schema.allOf) {
1518
+ schema.allOf.forEach((prop, i) => {
1519
+ var _a;
1520
+ const propObj = prop;
1521
+ if ("properties" in propObj && !propObj["properties"]) {
1522
+ (_a = modifiedSchema.allOf) == null ? true : delete _a[i];
1523
+ }
1524
+ });
1525
+ }
1526
+ return modifiedSchema;
1527
+ }
1528
+ function oapSchemaToReferences(schema) {
1529
+ const references = [];
1530
+ const oas = new Oas(schema);
1531
+ Object.entries(schema.paths).forEach(([path24, oapPath]) => {
1532
+ let type;
1533
+ SUPPORTED_HTTP_METHODS.forEach((eachMethod) => {
1534
+ const httpMethod = eachMethod.toLowerCase();
1535
+ switch (httpMethod) {
1536
+ case "get":
1537
+ break;
1538
+ case "put":
1539
+ break;
1540
+ case "post":
1541
+ break;
1542
+ case "delete":
1543
+ break;
1544
+ default:
1545
+ console.error(`Unsupported method: ${httpMethod}`);
1546
+ return;
1547
+ }
1548
+ const reference = oapPathToReference(
1549
+ httpMethod,
1550
+ path24,
1551
+ oapPath
1552
+ );
1553
+ if (reference) {
1554
+ const operation = oas.operation(path24, httpMethod);
1555
+ reference.examples.groups = oapExamples(oas, operation);
1556
+ references.push(reference);
1557
+ }
1558
+ });
1559
+ });
1560
+ return references;
1561
+ }
1562
+
1563
+ // node_modules/@xyd-js/plugin-zero/dist/index.js
1564
+ var __create3 = Object.create;
1565
+ var __defProp3 = Object.defineProperty;
1566
+ var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
1567
+ var __getOwnPropNames3 = Object.getOwnPropertyNames;
1568
+ var __getProtoOf3 = Object.getPrototypeOf;
1569
+ var __hasOwnProp3 = Object.prototype.hasOwnProperty;
1570
+ var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
1571
+ get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
1572
+ }) : x)(function(x) {
1573
+ if (typeof __require !== "undefined") return __require.apply(this, arguments);
1574
+ throw Error('Dynamic require of "' + x + '" is not supported');
1575
+ });
1576
+ var __commonJS3 = (cb, mod) => function __require22() {
1577
+ return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1578
+ };
1579
+ var __copyProps3 = (to, from, except, desc) => {
1580
+ if (from && typeof from === "object" || typeof from === "function") {
1581
+ for (let key of __getOwnPropNames3(from))
1582
+ if (!__hasOwnProp3.call(to, key) && key !== except)
1583
+ __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
1584
+ }
1585
+ return to;
1586
+ };
1587
+ var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create3(__getProtoOf3(mod)) : {}, __copyProps3(
1588
+ // If the importer is in node compatibility mode or this is not an ESM
1589
+ // file that has been converted to a CommonJS file using a Babel-
1590
+ // compatible transform (i.e. "__esModule" has not been set), then set
1591
+ // "default" to the CommonJS "module.exports" for node compatibility.
1592
+ isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
1593
+ mod
1594
+ ));
1595
+ var require_kind_of = __commonJS3({
1596
+ "../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"(exports2, module2) {
12
1597
  var toString = Object.prototype.toString;
13
1598
  module2.exports = function kindOf(val) {
14
1599
  if (val === void 0) return "undefined";
@@ -32,6 +1617,7 @@ var require_kind_of = __commonJS({
32
1617
  return "symbol";
33
1618
  case "Promise":
34
1619
  return "promise";
1620
+ // Set, Map, WeakSet, WeakMap
35
1621
  case "WeakMap":
36
1622
  return "weakmap";
37
1623
  case "WeakSet":
@@ -40,16 +1626,19 @@ var require_kind_of = __commonJS({
40
1626
  return "map";
41
1627
  case "Set":
42
1628
  return "set";
1629
+ // 8-bit typed arrays
43
1630
  case "Int8Array":
44
1631
  return "int8array";
45
1632
  case "Uint8Array":
46
1633
  return "uint8array";
47
1634
  case "Uint8ClampedArray":
48
1635
  return "uint8clampedarray";
1636
+ // 16-bit typed arrays
49
1637
  case "Int16Array":
50
1638
  return "int16array";
51
1639
  case "Uint16Array":
52
1640
  return "uint16array";
1641
+ // 32-bit typed arrays
53
1642
  case "Int32Array":
54
1643
  return "int32array";
55
1644
  case "Uint32Array":
@@ -66,6 +1655,7 @@ var require_kind_of = __commonJS({
66
1655
  switch (type) {
67
1656
  case "[object Object]":
68
1657
  return "object";
1658
+ // iterators
69
1659
  case "[object Map Iterator]":
70
1660
  return "mapiterator";
71
1661
  case "[object Set Iterator]":
@@ -121,158 +1711,40 @@ var require_kind_of = __commonJS({
121
1711
  }
122
1712
  }
123
1713
  });
124
-
125
- // ../node_modules/.pnpm/is-extendable@0.1.1/node_modules/is-extendable/index.js
126
- var require_is_extendable = __commonJS({
127
- "../node_modules/.pnpm/is-extendable@0.1.1/node_modules/is-extendable/index.js"(exports2, module2) {
1714
+ var require_engine = __commonJS3({
1715
+ "../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engine.js"(exports2, module2) {
128
1716
  "use strict";
129
- module2.exports = function isExtendable(val) {
130
- return typeof val !== "undefined" && val !== null && (typeof val === "object" || typeof val === "function");
131
- };
132
- }
133
- });
134
-
135
- // ../node_modules/.pnpm/extend-shallow@2.0.1/node_modules/extend-shallow/index.js
136
- var require_extend_shallow = __commonJS({
137
- "../node_modules/.pnpm/extend-shallow@2.0.1/node_modules/extend-shallow/index.js"(exports2, module2) {
138
- "use strict";
139
- var isObject = require_is_extendable();
140
- module2.exports = function extend(o) {
141
- if (!isObject(o)) {
142
- o = {};
1717
+ module2.exports = function(name, options2) {
1718
+ let engine = options2.engines[name] || options2.engines[aliase(name)];
1719
+ if (typeof engine === "undefined") {
1720
+ throw new Error('gray-matter engine "' + name + '" is not registered');
143
1721
  }
144
- var len = arguments.length;
145
- for (var i = 1; i < len; i++) {
146
- var obj = arguments[i];
147
- if (isObject(obj)) {
148
- assign(o, obj);
149
- }
1722
+ if (typeof engine === "function") {
1723
+ engine = { parse: engine };
150
1724
  }
151
- return o;
1725
+ return engine;
152
1726
  };
153
- function assign(a, b) {
154
- for (var key in b) {
155
- if (hasOwn(b, key)) {
156
- a[key] = b[key];
157
- }
158
- }
159
- }
160
- function hasOwn(obj, key) {
161
- return Object.prototype.hasOwnProperty.call(obj, key);
162
- }
163
- }
164
- });
165
-
166
- // ../node_modules/.pnpm/section-matter@1.0.0/node_modules/section-matter/index.js
167
- var require_section_matter = __commonJS({
168
- "../node_modules/.pnpm/section-matter@1.0.0/node_modules/section-matter/index.js"(exports2, module2) {
169
- "use strict";
170
- var typeOf = require_kind_of();
171
- var extend = require_extend_shallow();
172
- module2.exports = function(input, options2) {
173
- if (typeof options2 === "function") {
174
- options2 = { parse: options2 };
175
- }
176
- var file = toObject(input);
177
- var defaults = { section_delimiter: "---", parse: identity };
178
- var opts = extend({}, defaults, options2);
179
- var delim = opts.section_delimiter;
180
- var lines = file.content.split(/\r?\n/);
181
- var sections = null;
182
- var section = createSection();
183
- var content = [];
184
- var stack = [];
185
- function initSections(val) {
186
- file.content = val;
187
- sections = [];
188
- content = [];
189
- }
190
- function closeSection(val) {
191
- if (stack.length) {
192
- section.key = getKey(stack[0], delim);
193
- section.content = val;
194
- opts.parse(section, sections);
195
- sections.push(section);
196
- section = createSection();
197
- content = [];
198
- stack = [];
199
- }
200
- }
201
- for (var i = 0; i < lines.length; i++) {
202
- var line = lines[i];
203
- var len = stack.length;
204
- var ln = line.trim();
205
- if (isDelimiter(ln, delim)) {
206
- if (ln.length === 3 && i !== 0) {
207
- if (len === 0 || len === 2) {
208
- content.push(line);
209
- continue;
210
- }
211
- stack.push(ln);
212
- section.data = content.join("\n");
213
- content = [];
214
- continue;
215
- }
216
- if (sections === null) {
217
- initSections(content.join("\n"));
218
- }
219
- if (len === 2) {
220
- closeSection(content.join("\n"));
221
- }
222
- stack.push(ln);
223
- continue;
1727
+ function aliase(name) {
1728
+ switch (name.toLowerCase()) {
1729
+ case "js":
1730
+ case "javascript":
1731
+ return "javascript";
1732
+ case "coffee":
1733
+ case "coffeescript":
1734
+ case "cson":
1735
+ return "coffee";
1736
+ case "yaml":
1737
+ case "yml":
1738
+ return "yaml";
1739
+ default: {
1740
+ return name;
224
1741
  }
225
- content.push(line);
226
- }
227
- if (sections === null) {
228
- initSections(content.join("\n"));
229
- } else {
230
- closeSection(content.join("\n"));
231
- }
232
- file.sections = sections;
233
- return file;
234
- };
235
- function isDelimiter(line, delim) {
236
- if (line.slice(0, delim.length) !== delim) {
237
- return false;
238
- }
239
- if (line.charAt(delim.length + 1) === delim.slice(-1)) {
240
- return false;
241
- }
242
- return true;
243
- }
244
- function toObject(input) {
245
- if (typeOf(input) !== "object") {
246
- input = { content: input };
247
- }
248
- if (typeof input.content !== "string" && !isBuffer(input.content)) {
249
- throw new TypeError("expected a buffer or string");
250
- }
251
- input.content = input.content.toString();
252
- input.sections = [];
253
- return input;
254
- }
255
- function getKey(val, delim) {
256
- return val ? val.slice(delim.length).trim() : "";
257
- }
258
- function createSection() {
259
- return { key: "", data: "", content: "" };
260
- }
261
- function identity(val) {
262
- return val;
263
- }
264
- function isBuffer(val) {
265
- if (val && val.constructor && typeof val.constructor.isBuffer === "function") {
266
- return val.constructor.isBuffer(val);
267
1742
  }
268
- return false;
269
1743
  }
270
1744
  }
271
1745
  });
272
-
273
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/common.js
274
- var require_common = __commonJS({
275
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/common.js"(exports2, module2) {
1746
+ var require_common = __commonJS3({
1747
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/common.js"(exports2, module2) {
276
1748
  "use strict";
277
1749
  function isNothing(subject) {
278
1750
  return typeof subject === "undefined" || subject === null;
@@ -314,10 +1786,8 @@ var require_common = __commonJS({
314
1786
  module2.exports.extend = extend;
315
1787
  }
316
1788
  });
317
-
318
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/exception.js
319
- var require_exception = __commonJS({
320
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/exception.js"(exports2, module2) {
1789
+ var require_exception = __commonJS3({
1790
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/exception.js"(exports2, module2) {
321
1791
  "use strict";
322
1792
  function YAMLException(reason, mark) {
323
1793
  Error.call(this);
@@ -344,10 +1814,8 @@ var require_exception = __commonJS({
344
1814
  module2.exports = YAMLException;
345
1815
  }
346
1816
  });
347
-
348
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/mark.js
349
- var require_mark = __commonJS({
350
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/mark.js"(exports2, module2) {
1817
+ var require_mark = __commonJS3({
1818
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/mark.js"(exports2, module2) {
351
1819
  "use strict";
352
1820
  var common = require_common();
353
1821
  function Mark(name, buffer, position, line, column) {
@@ -358,23 +1826,23 @@ var require_mark = __commonJS({
358
1826
  this.column = column;
359
1827
  }
360
1828
  Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
361
- var head, start, tail, end, snippet;
1829
+ var head, start2, tail, end, snippet;
362
1830
  if (!this.buffer) return null;
363
1831
  indent = indent || 4;
364
1832
  maxLength = maxLength || 75;
365
1833
  head = "";
366
- start = this.position;
367
- while (start > 0 && "\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(start - 1)) === -1) {
368
- start -= 1;
369
- if (this.position - start > maxLength / 2 - 1) {
1834
+ start2 = this.position;
1835
+ while (start2 > 0 && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(start2 - 1)) === -1) {
1836
+ start2 -= 1;
1837
+ if (this.position - start2 > maxLength / 2 - 1) {
370
1838
  head = " ... ";
371
- start += 5;
1839
+ start2 += 5;
372
1840
  break;
373
1841
  }
374
1842
  }
375
1843
  tail = "";
376
1844
  end = this.position;
377
- while (end < this.buffer.length && "\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(end)) === -1) {
1845
+ while (end < this.buffer.length && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(end)) === -1) {
378
1846
  end += 1;
379
1847
  if (end - this.position > maxLength / 2 - 1) {
380
1848
  tail = " ... ";
@@ -382,8 +1850,8 @@ var require_mark = __commonJS({
382
1850
  break;
383
1851
  }
384
1852
  }
385
- snippet = this.buffer.slice(start, end);
386
- return common.repeat(" ", indent) + head + snippet + tail + "\n" + common.repeat(" ", indent + this.position - start + head.length) + "^";
1853
+ snippet = this.buffer.slice(start2, end);
1854
+ return common.repeat(" ", indent) + head + snippet + tail + "\n" + common.repeat(" ", indent + this.position - start2 + head.length) + "^";
387
1855
  };
388
1856
  Mark.prototype.toString = function toString(compact) {
389
1857
  var snippet, where = "";
@@ -402,10 +1870,8 @@ var require_mark = __commonJS({
402
1870
  module2.exports = Mark;
403
1871
  }
404
1872
  });
405
-
406
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type.js
407
- var require_type = __commonJS({
408
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type.js"(exports2, module2) {
1873
+ var require_type = __commonJS3({
1874
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type.js"(exports2, module2) {
409
1875
  "use strict";
410
1876
  var YAMLException = require_exception();
411
1877
  var TYPE_CONSTRUCTOR_OPTIONS = [
@@ -461,10 +1927,8 @@ var require_type = __commonJS({
461
1927
  module2.exports = Type;
462
1928
  }
463
1929
  });
464
-
465
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema.js
466
- var require_schema = __commonJS({
467
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema.js"(exports2, module2) {
1930
+ var require_schema = __commonJS3({
1931
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema.js"(exports2, module2) {
468
1932
  "use strict";
469
1933
  var common = require_common();
470
1934
  var YAMLException = require_exception();
@@ -549,10 +2013,8 @@ var require_schema = __commonJS({
549
2013
  module2.exports = Schema;
550
2014
  }
551
2015
  });
552
-
553
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/str.js
554
- var require_str = __commonJS({
555
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/str.js"(exports2, module2) {
2016
+ var require_str = __commonJS3({
2017
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/str.js"(exports2, module2) {
556
2018
  "use strict";
557
2019
  var Type = require_type();
558
2020
  module2.exports = new Type("tag:yaml.org,2002:str", {
@@ -563,10 +2025,8 @@ var require_str = __commonJS({
563
2025
  });
564
2026
  }
565
2027
  });
566
-
567
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/seq.js
568
- var require_seq = __commonJS({
569
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/seq.js"(exports2, module2) {
2028
+ var require_seq = __commonJS3({
2029
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/seq.js"(exports2, module2) {
570
2030
  "use strict";
571
2031
  var Type = require_type();
572
2032
  module2.exports = new Type("tag:yaml.org,2002:seq", {
@@ -577,10 +2037,8 @@ var require_seq = __commonJS({
577
2037
  });
578
2038
  }
579
2039
  });
580
-
581
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/map.js
582
- var require_map = __commonJS({
583
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/map.js"(exports2, module2) {
2040
+ var require_map = __commonJS3({
2041
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/map.js"(exports2, module2) {
584
2042
  "use strict";
585
2043
  var Type = require_type();
586
2044
  module2.exports = new Type("tag:yaml.org,2002:map", {
@@ -591,10 +2049,8 @@ var require_map = __commonJS({
591
2049
  });
592
2050
  }
593
2051
  });
594
-
595
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
596
- var require_failsafe = __commonJS({
597
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js"(exports2, module2) {
2052
+ var require_failsafe = __commonJS3({
2053
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js"(exports2, module2) {
598
2054
  "use strict";
599
2055
  var Schema = require_schema();
600
2056
  module2.exports = new Schema({
@@ -606,10 +2062,8 @@ var require_failsafe = __commonJS({
606
2062
  });
607
2063
  }
608
2064
  });
609
-
610
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/null.js
611
- var require_null = __commonJS({
612
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/null.js"(exports2, module2) {
2065
+ var require_null = __commonJS3({
2066
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/null.js"(exports2, module2) {
613
2067
  "use strict";
614
2068
  var Type = require_type();
615
2069
  function resolveYamlNull(data) {
@@ -646,10 +2100,8 @@ var require_null = __commonJS({
646
2100
  });
647
2101
  }
648
2102
  });
649
-
650
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/bool.js
651
- var require_bool = __commonJS({
652
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/bool.js"(exports2, module2) {
2103
+ var require_bool = __commonJS3({
2104
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/bool.js"(exports2, module2) {
653
2105
  "use strict";
654
2106
  var Type = require_type();
655
2107
  function resolveYamlBoolean(data) {
@@ -683,10 +2135,8 @@ var require_bool = __commonJS({
683
2135
  });
684
2136
  }
685
2137
  });
686
-
687
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/int.js
688
- var require_int = __commonJS({
689
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/int.js"(exports2, module2) {
2138
+ var require_int = __commonJS3({
2139
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/int.js"(exports2, module2) {
690
2140
  "use strict";
691
2141
  var common = require_common();
692
2142
  var Type = require_type();
@@ -816,10 +2266,8 @@ var require_int = __commonJS({
816
2266
  });
817
2267
  }
818
2268
  });
819
-
820
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/float.js
821
- var require_float = __commonJS({
822
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/float.js"(exports2, module2) {
2269
+ var require_float = __commonJS3({
2270
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/float.js"(exports2, module2) {
823
2271
  "use strict";
824
2272
  var common = require_common();
825
2273
  var Type = require_type();
@@ -911,10 +2359,8 @@ var require_float = __commonJS({
911
2359
  });
912
2360
  }
913
2361
  });
914
-
915
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/json.js
916
- var require_json = __commonJS({
917
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/json.js"(exports2, module2) {
2362
+ var require_json = __commonJS3({
2363
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/json.js"(exports2, module2) {
918
2364
  "use strict";
919
2365
  var Schema = require_schema();
920
2366
  module2.exports = new Schema({
@@ -930,10 +2376,8 @@ var require_json = __commonJS({
930
2376
  });
931
2377
  }
932
2378
  });
933
-
934
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/core.js
935
- var require_core = __commonJS({
936
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/core.js"(exports2, module2) {
2379
+ var require_core = __commonJS3({
2380
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/core.js"(exports2, module2) {
937
2381
  "use strict";
938
2382
  var Schema = require_schema();
939
2383
  module2.exports = new Schema({
@@ -943,10 +2387,8 @@ var require_core = __commonJS({
943
2387
  });
944
2388
  }
945
2389
  });
946
-
947
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
948
- var require_timestamp = __commonJS({
949
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/timestamp.js"(exports2, module2) {
2390
+ var require_timestamp = __commonJS3({
2391
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/timestamp.js"(exports2, module2) {
950
2392
  "use strict";
951
2393
  var Type = require_type();
952
2394
  var YAML_DATE_REGEXP = new RegExp(
@@ -1004,10 +2446,8 @@ var require_timestamp = __commonJS({
1004
2446
  });
1005
2447
  }
1006
2448
  });
1007
-
1008
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/merge.js
1009
- var require_merge = __commonJS({
1010
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/merge.js"(exports2, module2) {
2449
+ var require_merge = __commonJS3({
2450
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/merge.js"(exports2, module2) {
1011
2451
  "use strict";
1012
2452
  var Type = require_type();
1013
2453
  function resolveYamlMerge(data) {
@@ -1019,14 +2459,12 @@ var require_merge = __commonJS({
1019
2459
  });
1020
2460
  }
1021
2461
  });
1022
-
1023
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/binary.js
1024
- var require_binary = __commonJS({
1025
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/binary.js"(exports2, module2) {
2462
+ var require_binary = __commonJS3({
2463
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/binary.js"(exports2, module2) {
1026
2464
  "use strict";
1027
2465
  var NodeBuffer;
1028
2466
  try {
1029
- _require = __require;
2467
+ _require = __require2;
1030
2468
  NodeBuffer = _require("buffer").Buffer;
1031
2469
  } catch (__) {
1032
2470
  }
@@ -1112,10 +2550,8 @@ var require_binary = __commonJS({
1112
2550
  });
1113
2551
  }
1114
2552
  });
1115
-
1116
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/omap.js
1117
- var require_omap = __commonJS({
1118
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/omap.js"(exports2, module2) {
2553
+ var require_omap = __commonJS3({
2554
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/omap.js"(exports2, module2) {
1119
2555
  "use strict";
1120
2556
  var Type = require_type();
1121
2557
  var _hasOwnProperty = Object.prototype.hasOwnProperty;
@@ -1149,10 +2585,8 @@ var require_omap = __commonJS({
1149
2585
  });
1150
2586
  }
1151
2587
  });
1152
-
1153
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/pairs.js
1154
- var require_pairs = __commonJS({
1155
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/pairs.js"(exports2, module2) {
2588
+ var require_pairs = __commonJS3({
2589
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/pairs.js"(exports2, module2) {
1156
2590
  "use strict";
1157
2591
  var Type = require_type();
1158
2592
  var _toString = Object.prototype.toString;
@@ -1187,10 +2621,8 @@ var require_pairs = __commonJS({
1187
2621
  });
1188
2622
  }
1189
2623
  });
1190
-
1191
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/set.js
1192
- var require_set = __commonJS({
1193
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/set.js"(exports2, module2) {
2624
+ var require_set = __commonJS3({
2625
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/set.js"(exports2, module2) {
1194
2626
  "use strict";
1195
2627
  var Type = require_type();
1196
2628
  var _hasOwnProperty = Object.prototype.hasOwnProperty;
@@ -1214,10 +2646,8 @@ var require_set = __commonJS({
1214
2646
  });
1215
2647
  }
1216
2648
  });
1217
-
1218
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
1219
- var require_default_safe = __commonJS({
1220
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js"(exports2, module2) {
2649
+ var require_default_safe = __commonJS3({
2650
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js"(exports2, module2) {
1221
2651
  "use strict";
1222
2652
  var Schema = require_schema();
1223
2653
  module2.exports = new Schema({
@@ -1237,10 +2667,8 @@ var require_default_safe = __commonJS({
1237
2667
  });
1238
2668
  }
1239
2669
  });
1240
-
1241
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
1242
- var require_undefined = __commonJS({
1243
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js"(exports2, module2) {
2670
+ var require_undefined = __commonJS3({
2671
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js"(exports2, module2) {
1244
2672
  "use strict";
1245
2673
  var Type = require_type();
1246
2674
  function resolveJavascriptUndefined() {
@@ -1264,10 +2692,8 @@ var require_undefined = __commonJS({
1264
2692
  });
1265
2693
  }
1266
2694
  });
1267
-
1268
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
1269
- var require_regexp = __commonJS({
1270
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js"(exports2, module2) {
2695
+ var require_regexp = __commonJS3({
2696
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js"(exports2, module2) {
1271
2697
  "use strict";
1272
2698
  var Type = require_type();
1273
2699
  function resolveJavascriptRegExp(data) {
@@ -1308,14 +2734,12 @@ var require_regexp = __commonJS({
1308
2734
  });
1309
2735
  }
1310
2736
  });
1311
-
1312
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/function.js
1313
- var require_function = __commonJS({
1314
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/function.js"(exports2, module2) {
2737
+ var require_function = __commonJS3({
2738
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/function.js"(exports2, module2) {
1315
2739
  "use strict";
1316
2740
  var esprima;
1317
2741
  try {
1318
- _require = __require;
2742
+ _require = __require2;
1319
2743
  esprima = _require("esprima");
1320
2744
  } catch (_) {
1321
2745
  if (typeof window !== "undefined") esprima = window.esprima;
@@ -1363,10 +2787,8 @@ var require_function = __commonJS({
1363
2787
  });
1364
2788
  }
1365
2789
  });
1366
-
1367
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
1368
- var require_default_full = __commonJS({
1369
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_full.js"(exports2, module2) {
2790
+ var require_default_full = __commonJS3({
2791
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_full.js"(exports2, module2) {
1370
2792
  "use strict";
1371
2793
  var Schema = require_schema();
1372
2794
  module2.exports = Schema.DEFAULT = new Schema({
@@ -1381,10 +2803,8 @@ var require_default_full = __commonJS({
1381
2803
  });
1382
2804
  }
1383
2805
  });
1384
-
1385
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/loader.js
1386
- var require_loader = __commonJS({
1387
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/loader.js"(exports2, module2) {
2806
+ var require_loader = __commonJS3({
2807
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/loader.js"(exports2, module2) {
1388
2808
  "use strict";
1389
2809
  var common = require_common();
1390
2810
  var YAMLException = require_exception();
@@ -1449,7 +2869,7 @@ var require_loader = __commonJS({
1449
2869
  return -1;
1450
2870
  }
1451
2871
  function simpleEscapeSequence(c) {
1452
- return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "…" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
2872
+ return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
1453
2873
  }
1454
2874
  function charFromCodepoint(c) {
1455
2875
  if (c <= 65535) {
@@ -1541,10 +2961,10 @@ var require_loader = __commonJS({
1541
2961
  state.tagMap[handle] = prefix;
1542
2962
  }
1543
2963
  };
1544
- function captureSegment(state, start, end, checkJson) {
2964
+ function captureSegment(state, start2, end, checkJson) {
1545
2965
  var _position, _length, _character, _result;
1546
- if (start < end) {
1547
- _result = state.input.slice(start, end);
2966
+ if (start2 < end) {
2967
+ _result = state.input.slice(start2, end);
1548
2968
  if (checkJson) {
1549
2969
  for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1550
2970
  _character = _result.charCodeAt(_position);
@@ -2488,10 +3908,8 @@ var require_loader = __commonJS({
2488
3908
  module2.exports.safeLoad = safeLoad;
2489
3909
  }
2490
3910
  });
2491
-
2492
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/dumper.js
2493
- var require_dumper = __commonJS({
2494
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/dumper.js"(exports2, module2) {
3911
+ var require_dumper = __commonJS3({
3912
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/dumper.js"(exports2, module2) {
2495
3913
  "use strict";
2496
3914
  var common = require_common();
2497
3915
  var YAMLException = require_exception();
@@ -2771,22 +4189,22 @@ var require_dumper = __commonJS({
2771
4189
  if (line === "" || line[0] === " ") return line;
2772
4190
  var breakRe = / [^ ]/g;
2773
4191
  var match;
2774
- var start = 0, end, curr = 0, next = 0;
4192
+ var start2 = 0, end, curr = 0, next = 0;
2775
4193
  var result = "";
2776
4194
  while (match = breakRe.exec(line)) {
2777
4195
  next = match.index;
2778
- if (next - start > width) {
2779
- end = curr > start ? curr : next;
2780
- result += "\n" + line.slice(start, end);
2781
- start = end + 1;
4196
+ if (next - start2 > width) {
4197
+ end = curr > start2 ? curr : next;
4198
+ result += "\n" + line.slice(start2, end);
4199
+ start2 = end + 1;
2782
4200
  }
2783
4201
  curr = next;
2784
4202
  }
2785
4203
  result += "\n";
2786
- if (line.length - start > width && curr > start) {
2787
- result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
4204
+ if (line.length - start2 > width && curr > start2) {
4205
+ result += line.slice(start2, curr) + "\n" + line.slice(curr + 1);
2788
4206
  } else {
2789
- result += line.slice(start);
4207
+ result += line.slice(start2);
2790
4208
  }
2791
4209
  return result.slice(1);
2792
4210
  }
@@ -3036,10 +4454,8 @@ var require_dumper = __commonJS({
3036
4454
  module2.exports.safeDump = safeDump;
3037
4455
  }
3038
4456
  });
3039
-
3040
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml.js
3041
- var require_js_yaml = __commonJS({
3042
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml.js"(exports2, module2) {
4457
+ var require_js_yaml = __commonJS3({
4458
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml.js"(exports2, module2) {
3043
4459
  "use strict";
3044
4460
  var loader = require_loader();
3045
4461
  var dumper = require_dumper();
@@ -3071,19 +4487,15 @@ var require_js_yaml = __commonJS({
3071
4487
  module2.exports.addConstructor = deprecated("addConstructor");
3072
4488
  }
3073
4489
  });
3074
-
3075
- // ../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/index.js
3076
- var require_js_yaml2 = __commonJS({
3077
- "../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/index.js"(exports2, module2) {
4490
+ var require_js_yaml2 = __commonJS3({
4491
+ "../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/index.js"(exports2, module2) {
3078
4492
  "use strict";
3079
- var yaml2 = require_js_yaml();
3080
- module2.exports = yaml2;
4493
+ var yaml22 = require_js_yaml();
4494
+ module2.exports = yaml22;
3081
4495
  }
3082
4496
  });
3083
-
3084
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engines.js
3085
- var require_engines = __commonJS({
3086
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engines.js"(exports, module) {
4497
+ var require_engines = __commonJS3({
4498
+ "../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engines.js"(exports, module) {
3087
4499
  "use strict";
3088
4500
  var yaml = require_js_yaml2();
3089
4501
  var engines = exports = module.exports;
@@ -3118,10 +4530,8 @@ var require_engines = __commonJS({
3118
4530
  };
3119
4531
  }
3120
4532
  });
3121
-
3122
- // ../node_modules/.pnpm/strip-bom-string@1.0.0/node_modules/strip-bom-string/index.js
3123
- var require_strip_bom_string = __commonJS({
3124
- "../node_modules/.pnpm/strip-bom-string@1.0.0/node_modules/strip-bom-string/index.js"(exports2, module2) {
4533
+ var require_strip_bom_string = __commonJS3({
4534
+ "../../node_modules/.pnpm/strip-bom-string@1.0.0/node_modules/strip-bom-string/index.js"(exports2, module2) {
3125
4535
  "use strict";
3126
4536
  module2.exports = function(str2) {
3127
4537
  if (typeof str2 === "string" && str2.charAt(0) === "\uFEFF") {
@@ -3131,10 +4541,8 @@ var require_strip_bom_string = __commonJS({
3131
4541
  };
3132
4542
  }
3133
4543
  });
3134
-
3135
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/utils.js
3136
- var require_utils = __commonJS({
3137
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/utils.js"(exports2) {
4544
+ var require_utils = __commonJS3({
4545
+ "../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/utils.js"(exports2) {
3138
4546
  "use strict";
3139
4547
  var stripBom = require_strip_bom_string();
3140
4548
  var typeOf = require_kind_of();
@@ -3171,10 +4579,8 @@ var require_utils = __commonJS({
3171
4579
  };
3172
4580
  }
3173
4581
  });
3174
-
3175
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/defaults.js
3176
- var require_defaults = __commonJS({
3177
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/defaults.js"(exports2, module2) {
4582
+ var require_defaults = __commonJS3({
4583
+ "../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/defaults.js"(exports2, module2) {
3178
4584
  "use strict";
3179
4585
  var engines2 = require_engines();
3180
4586
  var utils = require_utils();
@@ -3190,44 +4596,8 @@ var require_defaults = __commonJS({
3190
4596
  };
3191
4597
  }
3192
4598
  });
3193
-
3194
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engine.js
3195
- var require_engine = __commonJS({
3196
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engine.js"(exports2, module2) {
3197
- "use strict";
3198
- module2.exports = function(name, options2) {
3199
- let engine = options2.engines[name] || options2.engines[aliase(name)];
3200
- if (typeof engine === "undefined") {
3201
- throw new Error('gray-matter engine "' + name + '" is not registered');
3202
- }
3203
- if (typeof engine === "function") {
3204
- engine = { parse: engine };
3205
- }
3206
- return engine;
3207
- };
3208
- function aliase(name) {
3209
- switch (name.toLowerCase()) {
3210
- case "js":
3211
- case "javascript":
3212
- return "javascript";
3213
- case "coffee":
3214
- case "coffeescript":
3215
- case "cson":
3216
- return "coffee";
3217
- case "yaml":
3218
- case "yml":
3219
- return "yaml";
3220
- default: {
3221
- return name;
3222
- }
3223
- }
3224
- }
3225
- }
3226
- });
3227
-
3228
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/stringify.js
3229
- var require_stringify = __commonJS({
3230
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/stringify.js"(exports2, module2) {
4599
+ var require_stringify = __commonJS3({
4600
+ "../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/stringify.js"(exports2, module2) {
3231
4601
  "use strict";
3232
4602
  var typeOf = require_kind_of();
3233
4603
  var getEngine = require_engine();
@@ -3260,10 +4630,10 @@ var require_stringify = __commonJS({
3260
4630
  data = Object.assign({}, file.data, data);
3261
4631
  const open = opts.delimiters[0];
3262
4632
  const close = opts.delimiters[1];
3263
- const matter = engine.stringify(data, options2).trim();
4633
+ const matter3 = engine.stringify(data, options2).trim();
3264
4634
  let buf = "";
3265
- if (matter !== "{}") {
3266
- buf = newline(open) + newline(matter) + newline(close);
4635
+ if (matter3 !== "{}") {
4636
+ buf = newline(open) + newline(matter3) + newline(close);
3267
4637
  }
3268
4638
  if (typeof file.excerpt === "string" && file.excerpt !== "") {
3269
4639
  if (str2.indexOf(file.excerpt.trim()) === -1) {
@@ -3277,216 +4647,1027 @@ var require_stringify = __commonJS({
3277
4647
  }
3278
4648
  }
3279
4649
  });
3280
-
3281
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/excerpt.js
3282
- var require_excerpt = __commonJS({
3283
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/excerpt.js"(exports2, module2) {
3284
- "use strict";
3285
- var defaults = require_defaults();
3286
- module2.exports = function(file, options2) {
3287
- const opts = defaults(options2);
3288
- if (file.data == null) {
3289
- file.data = {};
4650
+ var extensions = ["tsx", "jsx", "js", "ts", "json"];
4651
+ async function readSettings() {
4652
+ const dirPath = process.cwd();
4653
+ const baseFileName = "settings";
4654
+ let settingsFilePath = "";
4655
+ let reactSettings = false;
4656
+ try {
4657
+ const files = await fs3.readdir(dirPath);
4658
+ const settingsFile = files.find((file) => {
4659
+ const ext = path3.extname(file).slice(1);
4660
+ return file.startsWith(baseFileName) && extensions.includes(ext);
4661
+ });
4662
+ if (settingsFile) {
4663
+ settingsFilePath = path3.join(dirPath, settingsFile);
4664
+ reactSettings = path3.extname(settingsFile) !== ".json";
4665
+ } else {
4666
+ console.error("No settings file found");
4667
+ return null;
4668
+ }
4669
+ } catch (error) {
4670
+ console.error(error);
4671
+ return null;
4672
+ }
4673
+ if (reactSettings) {
4674
+ const settingsPreview = await createServer({
4675
+ optimizeDeps: {
4676
+ include: ["react/jsx-runtime"]
4677
+ }
4678
+ });
4679
+ const config = await settingsPreview.ssrLoadModule(settingsFilePath);
4680
+ return config.default;
4681
+ } else {
4682
+ const rawJsonSettings = await fs3.readFile(settingsFilePath, "utf-8");
4683
+ return JSON.parse(rawJsonSettings);
4684
+ }
4685
+ }
4686
+ async function loadModule(filePath) {
4687
+ const server = await createServer2({
4688
+ optimizeDeps: {
4689
+ include: ["react/jsx-runtime"]
4690
+ }
4691
+ });
4692
+ try {
4693
+ const module2 = await server.ssrLoadModule(filePath);
4694
+ return module2.default;
4695
+ } finally {
4696
+ await server.close();
4697
+ }
4698
+ }
4699
+ function preinstall() {
4700
+ return async function docsPluginInner(_, data) {
4701
+ const root2 = process.cwd();
4702
+ const settings = await readSettings();
4703
+ let themeRoutesExists = false;
4704
+ try {
4705
+ await fs2.access(path22.join(root2, ".xyd/theme/routes.ts"));
4706
+ themeRoutesExists = true;
4707
+ } catch (_2) {
4708
+ }
4709
+ if (themeRoutesExists) {
4710
+ const routeMod = await loadModule(path22.join(root2, ".xyd/theme/routes.ts"));
4711
+ const routes = routeMod((routePath, routeFile, routeOptions) => {
4712
+ return route(routePath, path22.join(root2, ".xyd/theme", routeFile), routeOptions);
4713
+ });
4714
+ data.routes.push(...routes);
4715
+ }
4716
+ return {
4717
+ settings
4718
+ };
4719
+ };
4720
+ }
4721
+ function vitePluginSettings() {
4722
+ return async function({ preinstall: preinstall3 }) {
4723
+ return {
4724
+ name: "virtual:xyd-settings",
4725
+ resolveId(id) {
4726
+ if (id === "virtual:xyd-settings") {
4727
+ return id + ".jsx";
4728
+ }
4729
+ return null;
4730
+ },
4731
+ async load(id) {
4732
+ if (id === "virtual:xyd-settings.jsx") {
4733
+ if (typeof preinstall3.settings === "string") {
4734
+ return preinstall3.settings;
4735
+ }
4736
+ return `export default ${JSON.stringify(preinstall3.settings)};`;
4737
+ }
4738
+ return null;
3290
4739
  }
3291
- if (typeof opts.excerpt === "function") {
3292
- return opts.excerpt(file, opts);
4740
+ };
4741
+ };
4742
+ }
4743
+ function vitePluginThemeCSS() {
4744
+ return async function({ preinstall: preinstall3 }) {
4745
+ return {
4746
+ name: "virtual:xyd-theme-css",
4747
+ resolveId(source) {
4748
+ if (source === "virtual:xyd-theme/index.css") {
4749
+ let basePath = "";
4750
+ if (process.env.XYD_CLI) {
4751
+ const __filename3 = fileURLToPath(import.meta.url);
4752
+ const __dirname23 = path22.dirname(__filename3);
4753
+ basePath = __dirname23 + "/";
4754
+ } else {
4755
+ basePath = import.meta.url.split("xyd/packages")[0] += "xyd/";
4756
+ }
4757
+ switch (preinstall3.settings.styling?.theme) {
4758
+ // TODO: support another themes + custom themes
4759
+ case "gusto": {
4760
+ const gustoCss = basePath += "node_modules/@xyd-js/theme-gusto/dist/index.css";
4761
+ return gustoCss.replace("file://", "");
4762
+ }
4763
+ case "poetry": {
4764
+ const poetryCss = basePath += "node_modules/@xyd-js/theme-poetry/dist/index.css";
4765
+ return poetryCss.replace("file://", "");
4766
+ }
4767
+ default: {
4768
+ const fableCss = basePath += "node_modules/@xyd-js/fable-wiki/dist/theme.css";
4769
+ return fableCss.replace("file://", "");
4770
+ }
4771
+ }
4772
+ }
4773
+ return null;
3293
4774
  }
3294
- const sep = file.data.excerpt_separator || opts.excerpt_separator;
3295
- if (sep == null && (opts.excerpt === false || opts.excerpt == null)) {
3296
- return file;
4775
+ };
4776
+ };
4777
+ }
4778
+ function vitePluginThemeOverrideCSS() {
4779
+ return async function({ preinstall: preinstall3 }) {
4780
+ return {
4781
+ name: "virtual:xyd-theme-override-css",
4782
+ async resolveId(id) {
4783
+ if (id === "virtual:xyd-theme-override/index.css") {
4784
+ const root2 = process.cwd();
4785
+ const filePath = path22.join(root2, ".xyd/theme/index.css");
4786
+ try {
4787
+ await fs2.access(filePath);
4788
+ return filePath;
4789
+ } catch {
4790
+ return "virtual:xyd-theme-override/empty.css";
4791
+ }
4792
+ }
4793
+ return null;
4794
+ },
4795
+ async load(id) {
4796
+ if (id === "virtual:xyd-theme-override/empty.css") {
4797
+ return "";
4798
+ }
4799
+ return null;
3297
4800
  }
3298
- const delimiter = typeof opts.excerpt === "string" ? opts.excerpt : sep || opts.delimiters[0];
3299
- const idx = file.content.indexOf(delimiter);
3300
- if (idx !== -1) {
3301
- file.excerpt = file.content.slice(0, idx);
4801
+ };
4802
+ };
4803
+ }
4804
+ function vitePluginTheme() {
4805
+ return async function({
4806
+ preinstall: preinstall3
4807
+ }) {
4808
+ return {
4809
+ name: "virtual:xyd-theme",
4810
+ resolveId(id) {
4811
+ if (id === "virtual:xyd-theme") {
4812
+ return id;
4813
+ }
4814
+ return null;
4815
+ },
4816
+ async load(id) {
4817
+ if (id === "virtual:xyd-theme") {
4818
+ switch (preinstall3.settings.styling?.theme) {
4819
+ // TODO: support another themes + custom themes
4820
+ case "gusto": {
4821
+ return `import Theme from '@xyd-js/theme-gusto'; export default Theme;`;
4822
+ }
4823
+ case "poetry": {
4824
+ return `import Theme from '@xyd-js/theme-poetry'; export default Theme;`;
4825
+ }
4826
+ default: {
4827
+ return `import Theme from '@xyd-js/fable-wiki/theme'; export default Theme;`;
4828
+ }
4829
+ }
4830
+ }
4831
+ return null;
3302
4832
  }
3303
- return file;
3304
4833
  };
4834
+ };
4835
+ }
4836
+ function preset(settings, options2) {
4837
+ const __filename3 = fileURLToPath(import.meta.url);
4838
+ const __dirname23 = path22.dirname(__filename3);
4839
+ let basePath = "";
4840
+ if (process.env.XYD_CLI) {
4841
+ basePath = path22.join(__dirname23, "./plugins/xyd-plugin-zero");
4842
+ } else {
4843
+ basePath = "../../../xyd-plugin-zero";
3305
4844
  }
3306
- });
3307
-
3308
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/to-file.js
3309
- var require_to_file = __commonJS({
3310
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/to-file.js"(exports2, module2) {
3311
- "use strict";
3312
- var typeOf = require_kind_of();
3313
- var stringify = require_stringify();
3314
- var utils = require_utils();
3315
- module2.exports = function(file) {
3316
- if (typeOf(file) !== "object") {
3317
- file = { content: file };
4845
+ return {
4846
+ preinstall: [
4847
+ preinstall
4848
+ ],
4849
+ routes: [
4850
+ route("", path22.join(basePath, "src/pages/docs.tsx")),
4851
+ // TODO: custom routes
4852
+ route(options2.urlPrefix ? `${options2.urlPrefix}/*` : "*", path22.join(basePath, "src/pages/docs.tsx"), {
4853
+ // TODO: absolute paths does not works
4854
+ id: "xyd-plugin-zero/docs"
4855
+ })
4856
+ ],
4857
+ vitePlugins: [
4858
+ vitePluginSettings,
4859
+ vitePluginTheme,
4860
+ vitePluginThemeCSS,
4861
+ vitePluginThemeOverrideCSS
4862
+ ]
4863
+ };
4864
+ }
4865
+ var docsPreset = preset;
4866
+ var import_stringify = __toESM3(require_stringify(), 1);
4867
+ function flatPages(sidebar, groups, resp = []) {
4868
+ sidebar.map(async (side) => {
4869
+ if ("match" in side) {
4870
+ side.items.map((item) => {
4871
+ return flatPages([item], groups, resp);
4872
+ });
4873
+ return;
4874
+ }
4875
+ if (groups[side.group || ""]) {
4876
+ const link = groups[side.group || ""];
4877
+ resp.push(link);
4878
+ }
4879
+ side?.pages?.map(async (page) => {
4880
+ if (typeof page === "string") {
4881
+ resp.push(page);
4882
+ return;
4883
+ }
4884
+ return flatPages([page], groups, resp);
4885
+ });
4886
+ });
4887
+ return resp;
4888
+ }
4889
+ function flatGroups(sidebar, resp = {}) {
4890
+ sidebar.map(async (side) => {
4891
+ if ("match" in side) {
4892
+ side.items.map((item) => {
4893
+ return flatGroups([item], resp);
4894
+ });
4895
+ return;
4896
+ }
4897
+ if (side.group) {
4898
+ if (resp[side.group]) {
4899
+ console.error("group already exists", side.group);
4900
+ }
4901
+ const first = side?.pages?.[0];
4902
+ if (first && typeof first === "string") {
4903
+ const chunks = first.split("/");
4904
+ chunks[chunks.length - 1] = side.group || "";
4905
+ const groupLink = chunks.join("/");
4906
+ resp[side.group] = groupLink;
4907
+ }
4908
+ }
4909
+ side?.pages?.map(async (page) => {
4910
+ if (typeof page === "string") {
4911
+ return;
3318
4912
  }
3319
- if (typeOf(file.data) !== "object") {
3320
- file.data = {};
4913
+ return flatGroups([page], resp);
4914
+ });
4915
+ });
4916
+ return resp;
4917
+ }
4918
+ function uniformSidebarLevelMap(pages) {
4919
+ const out = {};
4920
+ let level = 0;
4921
+ function recursive(items) {
4922
+ for (const item of items) {
4923
+ out[item] = level++;
4924
+ }
4925
+ }
4926
+ recursive(pages);
4927
+ return out;
4928
+ }
4929
+ async function uniformResolver(root2, matchRoute, apiFile, uniformApiResolver, sidebar, options2) {
4930
+ let urlPrefix = "";
4931
+ if (matchRoute && sidebar) {
4932
+ sidebar.forEach((sidebar2) => {
4933
+ if ("match" in sidebar2) {
4934
+ if (sidebar2.match === matchRoute) {
4935
+ if (urlPrefix) {
4936
+ throw new Error("multiple sidebars found for apiFile match");
4937
+ }
4938
+ urlPrefix = sidebar2.match;
4939
+ }
3321
4940
  }
3322
- if (file.contents && file.content == null) {
3323
- file.content = file.contents;
4941
+ });
4942
+ }
4943
+ if (!urlPrefix && options2?.urlPrefix) {
4944
+ urlPrefix = options2.urlPrefix;
4945
+ }
4946
+ if (!urlPrefix) {
4947
+ throw new Error("urlPrefix not found");
4948
+ }
4949
+ const apiFilePath = path32.join(root2, apiFile);
4950
+ const uniformRefs = await uniformApiResolver(apiFilePath);
4951
+ const uniformWithNavigation = uniform(uniformRefs, {
4952
+ plugins: [pluginNavigation({
4953
+ urlPrefix
4954
+ })]
4955
+ });
4956
+ let pageLevels = {};
4957
+ const uniformData = {
4958
+ slugs: {},
4959
+ data: [],
4960
+ // TODO: fix any
4961
+ i: 0,
4962
+ set: (slug, content, options3 = {}) => {
4963
+ if (uniformData.slugs[slug]) {
4964
+ console.error("slug already exists", slug);
4965
+ }
4966
+ const level = pageLevels[slug];
4967
+ uniformData.data[level] = {
4968
+ slug,
4969
+ content,
4970
+ options: options3
4971
+ };
4972
+ }
4973
+ };
4974
+ const uniformSidebars = [];
4975
+ if (sidebar && matchRoute) {
4976
+ sidebar.forEach((sidebar2) => {
4977
+ if ("match" in sidebar2) {
4978
+ if (sidebar2.match === matchRoute) {
4979
+ uniformSidebars.push(sidebar2);
4980
+ }
3324
4981
  }
3325
- utils.define(file, "orig", utils.toBuffer(file.content));
3326
- utils.define(file, "language", file.language || "");
3327
- utils.define(file, "matter", file.matter || "");
3328
- utils.define(file, "stringify", function(data, options2) {
3329
- if (options2 && options2.language) {
3330
- file.language = options2.language;
4982
+ });
4983
+ if (uniformSidebars.length > 1) {
4984
+ throw new Error("multiple sidebars found for uniform match");
4985
+ }
4986
+ }
4987
+ {
4988
+ const otherUniformPages = flatPages(uniformSidebars, {});
4989
+ const groups = flatGroups(uniformWithNavigation.out.sidebar);
4990
+ const flatUniformPages = [
4991
+ ...otherUniformPages,
4992
+ ...flatPages(
4993
+ uniformWithNavigation.out.sidebar,
4994
+ groups
4995
+ // TODO: we dont need groups - because it comes to structured page levels
4996
+ )
4997
+ ];
4998
+ pageLevels = uniformSidebarLevelMap(flatUniformPages);
4999
+ {
5000
+ await Promise.all(otherUniformPages.map(async (page) => {
5001
+ const content = await fs32.readFile(path32.join(root2, page + ".mdx"), "utf-8");
5002
+ uniformData.set(page, content + "\n");
5003
+ }));
5004
+ await Promise.all(Object.keys(groups).map(async (group) => {
5005
+ try {
5006
+ const page = groups[group];
5007
+ const content = await fs32.readFile(path32.join(root2, page + ".mdx"), "utf-8");
5008
+ uniformData.set(page, content + "\n");
5009
+ } catch (e) {
3331
5010
  }
3332
- return stringify(file, data, options2);
5011
+ }));
5012
+ }
5013
+ }
5014
+ await Promise.all(
5015
+ uniformWithNavigation.references.map(async (ref) => {
5016
+ const ast = referenceAST(ref);
5017
+ const md = compile(ast);
5018
+ const byCanonical = path32.join(urlPrefix, ref.canonical);
5019
+ const mdPath = path32.join(root2, byCanonical + ".md");
5020
+ const frontmatter = uniformWithNavigation.out.pageFrontMatter[byCanonical];
5021
+ if (!frontmatter) {
5022
+ console.error("frontmatter not found", byCanonical);
5023
+ return;
5024
+ }
5025
+ const content = (0, import_stringify.default)({ content: md }, {
5026
+ title: frontmatter.title
3333
5027
  });
3334
- file.content = utils.toString(file.content);
3335
- file.isEmpty = false;
3336
- file.excerpt = "";
3337
- return file;
5028
+ await fs32.writeFile(mdPath, content);
5029
+ uniformData.set(byCanonical, md + "\n");
5030
+ })
5031
+ );
5032
+ if (!sidebar) {
5033
+ return {
5034
+ sidebar: uniformWithNavigation.out.sidebar,
5035
+ data: uniformData.data
3338
5036
  };
3339
5037
  }
3340
- });
3341
-
3342
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/parse.js
3343
- var require_parse = __commonJS({
3344
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/parse.js"(exports2, module2) {
3345
- "use strict";
3346
- var getEngine = require_engine();
3347
- var defaults = require_defaults();
3348
- module2.exports = function(language, str2, options2) {
3349
- const opts = defaults(options2);
3350
- const engine = getEngine(language, opts);
3351
- if (typeof engine.parse !== "function") {
3352
- throw new TypeError('expected "' + language + '.parse" to be a function');
3353
- }
3354
- return engine.parse(str2, opts);
5038
+ if (matchRoute) {
5039
+ uniformSidebars[0].items.push(...uniformWithNavigation.out.sidebar);
5040
+ return {
5041
+ data: uniformData.data
3355
5042
  };
3356
5043
  }
3357
- });
3358
-
3359
- // ../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/index.js
3360
- var require_gray_matter = __commonJS({
3361
- "../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/index.js"(exports2, module2) {
3362
- var fs = require_fs();
3363
- var sections = require_section_matter();
3364
- var defaults = require_defaults();
3365
- var stringify = require_stringify();
3366
- var excerpt = require_excerpt();
3367
- var engines2 = require_engines();
3368
- var toFile = require_to_file();
3369
- var parse2 = require_parse();
3370
- var utils = require_utils();
3371
- function matter(input, options2) {
3372
- if (input === "") {
3373
- return { data: {}, content: input, excerpt: "", orig: input };
5044
+ sidebar.push(...uniformWithNavigation.out.sidebar);
5045
+ return {
5046
+ data: uniformData.data
5047
+ };
5048
+ }
5049
+ function preinstall2(id, uniformApiResolver, apiFile) {
5050
+ return function preinstallInner(options2) {
5051
+ return async function uniformPluginInner(settings, data) {
5052
+ const root2 = options2.root ?? process.cwd();
5053
+ if (!apiFile) {
5054
+ return;
3374
5055
  }
3375
- let file = toFile(input);
3376
- const cached = matter.cache[file.content];
3377
- if (!options2) {
3378
- if (cached) {
3379
- file = Object.assign({}, cached);
3380
- file.orig = cached.orig;
3381
- return file;
5056
+ const resp = [];
5057
+ if (typeof apiFile === "string") {
5058
+ const routeMatch = settings.api?.match?.[id] || "";
5059
+ const resolved = await uniformResolver(
5060
+ root2,
5061
+ routeMatch,
5062
+ apiFile,
5063
+ uniformApiResolver,
5064
+ settings?.structure?.sidebar,
5065
+ options2
5066
+ );
5067
+ if (resolved.sidebar) {
5068
+ settings.structure = {
5069
+ ...settings?.structure,
5070
+ sidebar: !settings.structure?.sidebar ? resolved.sidebar : [
5071
+ ...!settings.structure?.sidebar || [],
5072
+ ...resolved.sidebar
5073
+ ]
5074
+ };
3382
5075
  }
3383
- matter.cache[file.content] = file;
3384
- }
3385
- return parseMatter(file, options2);
3386
- }
3387
- function parseMatter(file, options2) {
3388
- const opts = defaults(options2);
3389
- const open = opts.delimiters[0];
3390
- const close = "\n" + opts.delimiters[1];
3391
- let str2 = file.content;
3392
- if (opts.language) {
3393
- file.language = opts.language;
3394
- }
3395
- const openLen = open.length;
3396
- if (!utils.startsWith(str2, open, openLen)) {
3397
- excerpt(file, opts);
3398
- return file;
3399
- }
3400
- if (str2.charAt(openLen) === open.slice(-1)) {
3401
- return file;
3402
- }
3403
- str2 = str2.slice(openLen);
3404
- const len = str2.length;
3405
- const language = matter.language(str2, opts);
3406
- if (language.name) {
3407
- file.language = language.name;
3408
- str2 = str2.slice(language.raw.length);
3409
- }
3410
- let closeIndex = str2.indexOf(close);
3411
- if (closeIndex === -1) {
3412
- closeIndex = len;
3413
- }
3414
- file.matter = str2.slice(0, closeIndex);
3415
- const block = file.matter.replace(/^\s*#[^\n]+/gm, "").trim();
3416
- if (block === "") {
3417
- file.isEmpty = true;
3418
- file.empty = file.content;
3419
- file.data = {};
5076
+ resp.push({
5077
+ urlPrefix: routeMatch.startsWith("/") ? routeMatch : `/${routeMatch}`,
5078
+ data: resolved.data
5079
+ });
3420
5080
  } else {
3421
- file.data = parse2(file.language, file.matter, opts);
5081
+ for (const openapiKey in apiFile) {
5082
+ const uniform2 = apiFile?.[openapiKey];
5083
+ const routeMatch = settings.api?.match?.[id]?.[openapiKey] || "";
5084
+ if (!routeMatch) {
5085
+ throw new Error(`route match not found for ${openapiKey}`);
5086
+ }
5087
+ if (!uniform2) {
5088
+ throw new Error(`uniform not found for ${openapiKey}`);
5089
+ }
5090
+ const resolved = await uniformResolver(
5091
+ root2,
5092
+ routeMatch,
5093
+ uniform2,
5094
+ uniformApiResolver,
5095
+ settings?.structure?.sidebar
5096
+ );
5097
+ if (resolved.sidebar) {
5098
+ settings.structure = {
5099
+ ...settings?.structure,
5100
+ sidebar: !settings.structure?.sidebar ? resolved.sidebar : [
5101
+ ...!settings.structure?.sidebar || [],
5102
+ ...resolved.sidebar
5103
+ ]
5104
+ };
5105
+ }
5106
+ resp.push({
5107
+ urlPrefix: routeMatch.startsWith("/") ? routeMatch : `/${routeMatch}`,
5108
+ data: resolved.data
5109
+ });
5110
+ }
3422
5111
  }
3423
- if (closeIndex === len) {
3424
- file.content = "";
3425
- } else {
3426
- file.content = str2.slice(closeIndex + close.length);
3427
- if (file.content[0] === "\r") {
3428
- file.content = file.content.slice(1);
5112
+ return resp;
5113
+ };
5114
+ };
5115
+ }
5116
+ function vitePluginUniformContent(pluginId) {
5117
+ return function vitePluginUniformContentInner() {
5118
+ return async function({
5119
+ preinstall: preinstall3
5120
+ }) {
5121
+ return {
5122
+ name: `virtual:xyd-plugin-zero/${pluginId}`,
5123
+ // TODO: unique name per plugin ?
5124
+ resolveId(id) {
5125
+ if (id == `virtual:xyd-plugin-zero/${pluginId}`) {
5126
+ return id;
5127
+ }
5128
+ },
5129
+ async load(id) {
5130
+ if (id === `virtual:xyd-plugin-zero/${pluginId}`) {
5131
+ if (!preinstall3.data) {
5132
+ return `export default ${JSON.stringify(preinstall3)}`;
5133
+ }
5134
+ return `export default ${JSON.stringify(preinstall3.data)}`;
5135
+ }
3429
5136
  }
3430
- if (file.content[0] === "\n") {
3431
- file.content = file.content.slice(1);
5137
+ };
5138
+ };
5139
+ };
5140
+ }
5141
+ function uniformPreset(id, apiFile, sidebar, options2, uniformApiResolver) {
5142
+ return function(settings) {
5143
+ const routeMatches = [];
5144
+ if (apiFile) {
5145
+ sidebar.forEach((sidebar2) => {
5146
+ if ("match" in sidebar2) {
5147
+ if (typeof apiFile === "string") {
5148
+ const routeMatch = settings?.api?.match?.[id];
5149
+ if (sidebar2.match === routeMatch) {
5150
+ routeMatches.push(routeMatch);
5151
+ }
5152
+ return;
5153
+ }
5154
+ if (typeof apiFile === "object" && !Array.isArray(apiFile)) {
5155
+ for (const routeMatchKey in apiFile) {
5156
+ const routeMatch = settings?.api?.match?.[id]?.[routeMatchKey];
5157
+ if (sidebar2.match === routeMatch) {
5158
+ routeMatches.push(routeMatch);
5159
+ }
5160
+ }
5161
+ }
5162
+ return;
3432
5163
  }
5164
+ });
5165
+ } else {
5166
+ if (!options2.urlPrefix) {
5167
+ throw new Error("urlPrefix not found");
3433
5168
  }
3434
- excerpt(file, opts);
3435
- if (opts.sections === true || typeof opts.section === "function") {
3436
- sections(file, opts.section);
3437
- }
3438
- return file;
5169
+ routeMatches.push(`${options2.urlPrefix}/*`);
3439
5170
  }
3440
- matter.engines = engines2;
3441
- matter.stringify = function(file, data, options2) {
3442
- if (typeof file === "string") file = matter(file, options2);
3443
- return stringify(file, data, options2);
3444
- };
3445
- matter.read = function(filepath, options2) {
3446
- const str2 = fs.readFileSync(filepath, "utf8");
3447
- const file = matter(str2, options2);
3448
- file.path = filepath;
3449
- return file;
5171
+ let basePath = "";
5172
+ if (process.env.XYD_CLI) {
5173
+ basePath = path32.join(__dirname, "./plugins/xyd-plugin-zero");
5174
+ } else {
5175
+ basePath = "../../../xyd-plugin-zero";
5176
+ }
5177
+ return {
5178
+ preinstall: [
5179
+ preinstall2(id, uniformApiResolver, apiFile)
5180
+ ],
5181
+ routes: routeMatches.map(
5182
+ (routeMatch, i) => route2(
5183
+ `${routeMatch}/*`,
5184
+ path32.join(basePath, "src/pages/api-reference.tsx"),
5185
+ {
5186
+ id: `xyd-plugin-zero/${id}-${i}`
5187
+ }
5188
+ )
5189
+ ),
5190
+ vitePlugins: [
5191
+ vitePluginUniformContent(id)
5192
+ ]
3450
5193
  };
3451
- matter.test = function(str2, options2) {
3452
- return utils.startsWith(str2, defaults(options2).delimiters[0]);
5194
+ };
5195
+ }
5196
+ function preset2(settings, options2) {
5197
+ return uniformPreset(
5198
+ "graphql",
5199
+ settings?.api?.graphql || "",
5200
+ settings?.structure?.sidebar || [],
5201
+ {
5202
+ root: options2.root,
5203
+ urlPrefix: options2.urlPrefix
5204
+ },
5205
+ async (gqlPath) => {
5206
+ return await gqlSchemaToReferences(gqlPath);
5207
+ }
5208
+ )(settings);
5209
+ }
5210
+ var graphqlPreset = preset2;
5211
+ function preset3(settings, options2) {
5212
+ return uniformPreset(
5213
+ "openapi",
5214
+ settings?.api?.openapi || "",
5215
+ settings?.structure?.sidebar || [],
5216
+ {
5217
+ root: options2.root,
5218
+ urlPrefix: options2.urlPrefix
5219
+ },
5220
+ async (openApiPath) => {
5221
+ const schema = await deferencedOpenAPI(openApiPath);
5222
+ return oapSchemaToReferences(schema);
5223
+ }
5224
+ )(settings);
5225
+ }
5226
+ var openapiPreset = preset3;
5227
+ async function pluginZero() {
5228
+ let settings = null;
5229
+ const vitePlugins2 = [];
5230
+ const routes = [];
5231
+ {
5232
+ const options2 = {
5233
+ urlPrefix: ""
5234
+ // TODO: configurable
3453
5235
  };
3454
- matter.language = function(str2, options2) {
3455
- const opts = defaults(options2);
3456
- const open = opts.delimiters[0];
3457
- if (matter.test(str2)) {
3458
- str2 = str2.slice(open.length);
5236
+ const docs = docsPreset(void 0, options2);
5237
+ docs.preinstall = docs.preinstall || [];
5238
+ let preinstallMerge = {};
5239
+ for (const preinstall3 of docs.preinstall) {
5240
+ const resp = await preinstall3()({}, {
5241
+ routes: docs.routes
5242
+ });
5243
+ if (resp && typeof resp === "object") {
5244
+ preinstallMerge = {
5245
+ ...preinstallMerge,
5246
+ ...resp
5247
+ };
3459
5248
  }
3460
- const language = str2.slice(0, str2.search(/\r?\n/));
3461
- return {
3462
- raw: language,
3463
- name: language ? language.trim() : ""
3464
- };
3465
- };
3466
- matter.cache = {};
3467
- matter.clearCache = function() {
3468
- matter.cache = {};
5249
+ }
5250
+ docs.vitePlugins = docs.vitePlugins || [];
5251
+ for (const vitePlugin of docs.vitePlugins) {
5252
+ const vitePlug = await vitePlugin()({
5253
+ preinstall: preinstallMerge
5254
+ });
5255
+ vitePlugins2.push(vitePlug);
5256
+ }
5257
+ if ("settings" in preinstallMerge) {
5258
+ settings = preinstallMerge.settings;
5259
+ }
5260
+ docs.routes = docs.routes || [];
5261
+ routes.push(...docs.routes);
5262
+ }
5263
+ if (!settings) {
5264
+ throw new Error("settings not found");
5265
+ }
5266
+ if (settings?.api?.graphql) {
5267
+ const options2 = {};
5268
+ const gql = graphqlPreset(settings, options2);
5269
+ gql.preinstall = gql.preinstall || [];
5270
+ let preinstallMerge = {};
5271
+ for (const preinstall3 of gql.preinstall) {
5272
+ const resp = await preinstall3(options2)(settings, {
5273
+ routes: gql.routes
5274
+ });
5275
+ if (resp && typeof resp === "object") {
5276
+ preinstallMerge = {
5277
+ ...preinstallMerge,
5278
+ ...resp
5279
+ };
5280
+ }
5281
+ }
5282
+ gql.vitePlugins = gql.vitePlugins || [];
5283
+ for (const vitePlugin of gql.vitePlugins) {
5284
+ const vitePlug = await vitePlugin()({
5285
+ preinstall: preinstallMerge
5286
+ });
5287
+ vitePlugins2.push(vitePlug);
5288
+ }
5289
+ gql.routes = gql.routes || [];
5290
+ routes.push(...gql.routes);
5291
+ }
5292
+ if (settings?.api?.openapi) {
5293
+ const options2 = {};
5294
+ const oap = openapiPreset(settings, options2);
5295
+ oap.preinstall = oap.preinstall || [];
5296
+ let preinstallMerge = {};
5297
+ for (const preinstall3 of oap.preinstall) {
5298
+ const resp = await preinstall3(options2)(settings, {
5299
+ routes: oap.routes
5300
+ });
5301
+ if (resp && typeof resp === "object") {
5302
+ preinstallMerge = {
5303
+ ...preinstallMerge,
5304
+ ...resp
5305
+ };
5306
+ }
5307
+ }
5308
+ oap.vitePlugins = oap.vitePlugins || [];
5309
+ for (const vitePlugin of oap.vitePlugins) {
5310
+ const vitePlug = await vitePlugin()({
5311
+ preinstall: preinstallMerge
5312
+ });
5313
+ vitePlugins2.push(vitePlug);
5314
+ }
5315
+ oap.routes = oap.routes || [];
5316
+ routes.push(...oap.routes);
5317
+ }
5318
+ return {
5319
+ vitePlugins: vitePlugins2,
5320
+ settings,
5321
+ routes
5322
+ };
5323
+ }
5324
+
5325
+ // node_modules/@xyd-js/documan/dist/index.js
5326
+ import path23 from "node:path";
5327
+ import { fileURLToPath as fileURLToPath22 } from "node:url";
5328
+ import { createServer as createServer3, searchForWorkspaceRoot } from "vite";
5329
+ import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
5330
+ import fs22 from "node:fs";
5331
+ import os from "node:os";
5332
+ import path33 from "node:path";
5333
+ import url from "node:url";
5334
+ import { createRequestHandler } from "@react-router/express";
5335
+ import compression from "compression";
5336
+ import express from "express";
5337
+ import morgan from "morgan";
5338
+ import sourceMapSupport from "source-map-support";
5339
+ import getPort from "get-port";
5340
+ var __filename = fileURLToPath2(import.meta.url);
5341
+ var __dirname2 = path4.dirname(__filename);
5342
+ async function build() {
5343
+ const resp = await pluginZero();
5344
+ if (!resp) {
5345
+ throw new Error("PluginZero not found");
5346
+ }
5347
+ const buildDir = path4.join(process.cwd(), ".xyd/build");
5348
+ {
5349
+ const packageJsonPath = path4.join(buildDir, "package.json");
5350
+ const packageJsonContent = {
5351
+ type: "module",
5352
+ scripts: {},
5353
+ dependencies: {
5354
+ // TODO: better
5355
+ "@xyd-js/content": "latest",
5356
+ "@xyd-js/components": "latest",
5357
+ "@xyd-js/framework": "latest",
5358
+ "@xyd-js/theme-poetry": "latest",
5359
+ "@react-router/node": "^7.1.1",
5360
+ "isbot": "^5"
5361
+ },
5362
+ devDependencies: {}
3469
5363
  };
3470
- module2.exports = matter;
5364
+ if (!fs4.existsSync(buildDir)) {
5365
+ fs4.mkdirSync(buildDir, { recursive: true });
5366
+ }
5367
+ fs4.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), "utf8");
5368
+ console.log("Installing dependencies...");
5369
+ execSync("npm install", { cwd: buildDir, stdio: "inherit" });
3471
5370
  }
3472
- });
3473
- export default require_gray_matter();
3474
- /*! Bundled license information:
5371
+ try {
5372
+ await viteBuild({
5373
+ root: process.env.XYD_CLI ? __dirname2 : process.env.XYD_DOCUMAN_HOST || path4.join(__dirname2, "../host"),
5374
+ // @ts-ignore
5375
+ plugins: [
5376
+ ...vitePlugins({
5377
+ toc: {
5378
+ minDepth: 2
5379
+ }
5380
+ }),
5381
+ reactRouter({
5382
+ outDir: buildDir,
5383
+ routes: resp.routes
5384
+ }),
5385
+ tsconfigPaths(),
5386
+ ...resp.vitePlugins
5387
+ ],
5388
+ optimizeDeps: {
5389
+ include: ["react/jsx-runtime"]
5390
+ }
5391
+ });
5392
+ await viteBuild({
5393
+ root: process.env.XYD_CLI ? __dirname2 : process.env.XYD_DOCUMAN_HOST || path4.join(__dirname2, "../host"),
5394
+ build: {
5395
+ ssr: true
5396
+ },
5397
+ // @ts-ignore
5398
+ plugins: [
5399
+ ...vitePlugins({
5400
+ toc: {
5401
+ minDepth: 2
5402
+ }
5403
+ }),
5404
+ reactRouter({
5405
+ outDir: buildDir,
5406
+ routes: resp.routes
5407
+ }),
5408
+ tsconfigPaths(),
5409
+ ...resp.vitePlugins
5410
+ ],
5411
+ optimizeDeps: {
5412
+ include: ["react/jsx-runtime"]
5413
+ }
5414
+ });
5415
+ console.log("Build completed successfully.");
5416
+ } catch (error) {
5417
+ console.error("Build failed:", error);
5418
+ }
5419
+ }
5420
+ var __filename2 = fileURLToPath22(import.meta.url);
5421
+ var __dirname22 = path23.dirname(__filename2);
5422
+ var port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;
5423
+ async function dev() {
5424
+ const resp = await pluginZero();
5425
+ if (!resp) {
5426
+ throw new Error("PluginZero not found");
5427
+ }
5428
+ const allowCwd = searchForWorkspaceRoot(process.cwd());
5429
+ const preview = await createServer3({
5430
+ // any valid user config options, plus `mode` and `configFile`
5431
+ // configFile: path.join(__dirname, "../src/vite/empty-config.ts"), // TODO: bundler??
5432
+ // configFile: path.join(__dirname, "../"), // TODO: bundler??
5433
+ // root: path.join(__dirname, "../"), // TODO: bundler?
5434
+ root: process.env.XYD_CLI ? __dirname22 : process.env.XYD_DOCUMAN_HOST || path23.join(__dirname22, "../host"),
5435
+ // TODO: bundler?
5436
+ server: {
5437
+ port,
5438
+ fs: {
5439
+ allow: [
5440
+ allowCwd,
5441
+ process.env.XYD_CLI ? path23.join(__dirname22, "../../") : ""
5442
+ // path.join(__dirname, "../node_modules") // Ensure node_modules from xyd-documan is included
5443
+ ]
5444
+ }
5445
+ },
5446
+ build: {
5447
+ rollupOptions: {
5448
+ // Exclude package `B` from the client-side bundle
5449
+ external: ["@xyd-js/uniform", "@xyd-js/uniform/content", "@xyd-js/plugin-zero"]
5450
+ }
5451
+ },
5452
+ ssr: {
5453
+ external: ["@xyd-js/uniform", "@xyd-js/uniform/content", "@xyd-js/plugin-zero"]
5454
+ // noExternal: [
5455
+ // "@xyd-js/uniform",
5456
+ // "@xyd-js/uniform/content",
5457
+ // "@xyd-js/plugin-zero"
5458
+ // ],
5459
+ },
5460
+ optimizeDeps: {
5461
+ include: ["react/jsx-runtime"]
5462
+ },
5463
+ // @ts-ignore
5464
+ plugins: [
5465
+ // TODO: fix plugin ts
5466
+ ...vitePlugins({
5467
+ toc: {
5468
+ minDepth: 2
5469
+ }
5470
+ }),
5471
+ reactRouter2({
5472
+ routes: resp.routes
5473
+ }),
5474
+ ...resp.vitePlugins
5475
+ ]
5476
+ });
5477
+ await preview.listen(port);
5478
+ preview.printUrls();
5479
+ preview.bindCLIShortcuts({ print: true });
5480
+ }
5481
+ function parseNumber(raw) {
5482
+ if (raw === void 0) return void 0;
5483
+ let maybe = Number(raw);
5484
+ if (Number.isNaN(maybe)) return void 0;
5485
+ return maybe;
5486
+ }
5487
+ async function serve() {
5488
+ process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
5489
+ sourceMapSupport.install({
5490
+ retrieveSourceMap: function(source) {
5491
+ let match = source.startsWith("file://");
5492
+ if (match) {
5493
+ let filePath = url.fileURLToPath(source);
5494
+ let sourceMapPath = `${filePath}.map`;
5495
+ if (fs22.existsSync(sourceMapPath)) {
5496
+ return {
5497
+ url: source,
5498
+ map: fs22.readFileSync(sourceMapPath, "utf8")
5499
+ };
5500
+ }
5501
+ }
5502
+ return null;
5503
+ }
5504
+ });
5505
+ let port2 = parseNumber(process.env.PORT) ?? await getPort({ port: 3e3 });
5506
+ let buildPathArg = path33.join(process.cwd(), ".xyd/build/server/index.js");
5507
+ if (!buildPathArg) {
5508
+ console.error(`
5509
+ Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);
5510
+ process.exit(1);
5511
+ }
5512
+ let buildPath = path33.resolve(buildPathArg);
5513
+ let build22 = await import(url.pathToFileURL(buildPath).href);
5514
+ let onListen = () => {
5515
+ let address = process.env.HOST || Object.values(os.networkInterfaces()).flat().find((ip) => String(ip?.family).includes("4") && !ip?.internal)?.address;
5516
+ if (!address) {
5517
+ console.log(`[xyd-serve] http://localhost:${port2}`);
5518
+ } else {
5519
+ console.log(
5520
+ `[xyd-serve] http://localhost:${port2} (http://${address}:${port2})`
5521
+ );
5522
+ }
5523
+ };
5524
+ build22 = {
5525
+ ...build22,
5526
+ assetsBuildDirectory: path33.join(process.cwd(), ".xyd/build/client")
5527
+ };
5528
+ let app = express();
5529
+ app.disable("x-powered-by");
5530
+ app.use(compression());
5531
+ app.use(
5532
+ path33.posix.join(build22.publicPath, "assets"),
5533
+ express.static(path33.join(build22.assetsBuildDirectory, "assets"), {
5534
+ immutable: true,
5535
+ maxAge: "1y"
5536
+ })
5537
+ );
5538
+ app.use(build22.publicPath, express.static(build22.assetsBuildDirectory));
5539
+ app.use(express.static("public", { maxAge: "1h" }));
5540
+ app.use(morgan("tiny"));
5541
+ app.all(
5542
+ "*",
5543
+ createRequestHandler({
5544
+ build: build22,
5545
+ mode: process.env.NODE_ENV
5546
+ })
5547
+ );
5548
+ let server = process.env.HOST ? app.listen(port2, process.env.HOST, onListen) : app.listen(port2, onListen);
5549
+ ["SIGTERM", "SIGINT"].forEach((signal) => {
5550
+ process.once(signal, () => server?.close(console.error));
5551
+ });
5552
+ }
3475
5553
 
3476
- is-extendable/index.js:
3477
- (*!
3478
- * is-extendable <https://github.com/jonschlinkert/is-extendable>
3479
- *
3480
- * Copyright (c) 2015, Jon Schlinkert.
3481
- * Licensed under the MIT License.
3482
- *)
5554
+ // src/commands.ts
5555
+ async function build2(root2, options2 = {}) {
5556
+ await build();
5557
+ }
5558
+ async function start(root2, options2 = {}) {
5559
+ await serve();
5560
+ await new Promise(() => {
5561
+ });
5562
+ }
5563
+ async function dev2(root2, options2 = {}) {
5564
+ await dev();
5565
+ await new Promise(() => {
5566
+ });
5567
+ }
5568
+
5569
+ // src/run.ts
5570
+ var helpText = `
5571
+ ${import_picocolors.default.blueBright("xyd")}
5572
+
5573
+ ${import_picocolors.default.underline("Usage")}:
5574
+ $ xyd build [${import_picocolors.default.yellowBright("projectDir")}]
5575
+ $ xyd start [${import_picocolors.default.yellowBright("projectDir")}]
5576
+ $ xyd dev [${import_picocolors.default.yellowBright("projectDir")}]
5577
+
5578
+ ${import_picocolors.default.underline("Options")}:
5579
+ --help, -h Print this help message and exit
5580
+ --version, -v Print the CLI version and exit
5581
+
5582
+ ${import_picocolors.default.underline("Build your project")}:
5583
+
5584
+ $ xyd build
5585
+
5586
+
5587
+ ${import_picocolors.default.underline("Start your production server")}:
5588
+
5589
+ $ xyd start
5590
+
5591
+ ${import_picocolors.default.underline("Run your project locally in development")}:
5592
+
5593
+ $ xyd dev
5594
+ `;
5595
+ async function run(argv = process.argv.slice(2)) {
5596
+ process.env.XYD_CLI = "true";
5597
+ let versions = process.versions;
5598
+ let MINIMUM_NODE_VERSION = 20;
5599
+ if (versions && versions.node && semver.major(versions.node) < MINIMUM_NODE_VERSION) {
5600
+ console.warn(
5601
+ `\uFE0F\u26A0\uFE0F Oops, Node v${versions.node} detected. xyd requires a Node version greater than ${MINIMUM_NODE_VERSION}.`
5602
+ );
5603
+ }
5604
+ let args = arg(
5605
+ {
5606
+ "--help": Boolean,
5607
+ "-h": "--help",
5608
+ "--version": Boolean,
5609
+ "-v": "--version",
5610
+ "--port": Number,
5611
+ "-p": "--port",
5612
+ "--logLevel": String,
5613
+ "-l": "--logLevel"
5614
+ },
5615
+ {
5616
+ argv
5617
+ }
5618
+ );
5619
+ let input = args._;
5620
+ let flags = Object.entries(args).reduce((acc, [key, value]) => {
5621
+ key = key.replace(/^--/, "");
5622
+ acc[key] = value;
5623
+ return acc;
5624
+ }, {});
5625
+ if (flags.help) {
5626
+ console.log(helpText);
5627
+ return;
5628
+ }
5629
+ if (flags.version) {
5630
+ let version = require_package().version;
5631
+ console.log(version);
5632
+ return;
5633
+ }
5634
+ let command = input[0];
5635
+ switch (command) {
5636
+ case "build":
5637
+ await build2(input[1], flags);
5638
+ break;
5639
+ case "start":
5640
+ await start(input[1], flags);
5641
+ break;
5642
+ case "dev":
5643
+ await dev2(input[1], flags);
5644
+ break;
5645
+ default:
5646
+ await dev2(input[0], flags);
5647
+ }
5648
+ }
5649
+
5650
+ // index.ts
5651
+ run().then(
5652
+ () => {
5653
+ process.exit(0);
5654
+ },
5655
+ (error) => {
5656
+ if (error) console.error(error);
5657
+ process.exit(1);
5658
+ }
5659
+ );
5660
+ /*! Bundled license information:
3483
5661
 
3484
- strip-bom-string/index.js:
3485
- (*!
3486
- * strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
3487
- *
3488
- * Copyright (c) 2015, 2017, Jon Schlinkert.
3489
- * Released under the MIT License.
3490
- *)
5662
+ @xyd-js/plugin-zero/dist/index.js:
5663
+ (*! Bundled license information:
5664
+
5665
+ strip-bom-string/index.js:
5666
+ (*!
5667
+ * strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
5668
+ *
5669
+ * Copyright (c) 2015, 2017, Jon Schlinkert.
5670
+ * Released under the MIT License.
5671
+ *)
5672
+ *)
3491
5673
  */
3492
- //# sourceMappingURL=gray-matter.js.map