@xyd-js/uniform 0.0.0-build
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/content.ts +1 -0
- package/dist/content.cjs +133 -0
- package/dist/content.cjs.map +1 -0
- package/dist/content.d.cts +4 -0
- package/dist/content.d.ts +4 -0
- package/dist/content.js +95 -0
- package/dist/content.js.map +1 -0
- package/dist/index.cjs +235 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +194 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.cjs +302 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +8 -0
- package/dist/markdown.d.ts +8 -0
- package/dist/markdown.js +264 -0
- package/dist/markdown.js.map +1 -0
- package/dist/types-BiglsETJ.d.cts +180 -0
- package/dist/types-BiglsETJ.d.ts +180 -0
- package/index.ts +14 -0
- package/markdown.ts +1 -0
- package/package.json +40 -0
- package/src/content/index.ts +124 -0
- package/src/index.ts +105 -0
- package/src/markdown/index.ts +67 -0
- package/src/markdown/utils.ts +270 -0
- package/src/plugins/__tests__/pluginJsonView.test.ts +132 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/pluginJsonView.ts +54 -0
- package/src/plugins/pluginNavigation.ts +135 -0
- package/src/types.ts +294 -0
- package/tsconfig.json +21 -0
- package/tsup.config.ts +39 -0
- package/vitest.config.ts +15 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 xyd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/content.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/content/index"
|
package/dist/content.cjs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// content.ts
|
|
31
|
+
var content_exports = {};
|
|
32
|
+
__export(content_exports, {
|
|
33
|
+
compileBySlug: () => compileBySlug,
|
|
34
|
+
lazyReferences: () => lazyReferences
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(content_exports);
|
|
37
|
+
|
|
38
|
+
// src/content/index.ts
|
|
39
|
+
var import_path = __toESM(require("path"), 1);
|
|
40
|
+
var import_fs = require("fs");
|
|
41
|
+
var import_react = __toESM(require("react"), 1);
|
|
42
|
+
var import_codehike = require("codehike");
|
|
43
|
+
var import_unist_util_visit = require("unist-util-visit");
|
|
44
|
+
var import_mdx = require("codehike/mdx");
|
|
45
|
+
var import_mdx2 = require("@mdx-js/mdx");
|
|
46
|
+
var codeHikeOptions = {
|
|
47
|
+
lineNumbers: true,
|
|
48
|
+
showCopyButton: true,
|
|
49
|
+
autoImport: true,
|
|
50
|
+
components: { code: "Code" }
|
|
51
|
+
// syntaxHighlighting: { // TODO: !!! FROM SETTINGS !!! wait for rr7 rsc ??
|
|
52
|
+
// theme: "github-dark",
|
|
53
|
+
// },
|
|
54
|
+
};
|
|
55
|
+
function normalizeCustomHeadings() {
|
|
56
|
+
return (tree) => {
|
|
57
|
+
(0, import_unist_util_visit.visit)(tree, "paragraph", (node, index, parent) => {
|
|
58
|
+
const match = node.children[0] && node.children[0].value.match(/^(#+)\s+(.*)/);
|
|
59
|
+
if (match) {
|
|
60
|
+
const level = match[1].length;
|
|
61
|
+
const text = match[2];
|
|
62
|
+
if (level > 6) {
|
|
63
|
+
const headingNode = {
|
|
64
|
+
type: "heading",
|
|
65
|
+
depth: level,
|
|
66
|
+
children: [{ type: "text", value: text }]
|
|
67
|
+
};
|
|
68
|
+
parent.children[index] = headingNode;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function compile(content) {
|
|
75
|
+
const compiled = await (0, import_mdx2.compile)(content, {
|
|
76
|
+
remarkPlugins: [normalizeCustomHeadings, [import_mdx.remarkCodeHike, codeHikeOptions]],
|
|
77
|
+
recmaPlugins: [
|
|
78
|
+
[import_mdx.recmaCodeHike, codeHikeOptions]
|
|
79
|
+
],
|
|
80
|
+
outputFormat: "function-body",
|
|
81
|
+
development: false
|
|
82
|
+
});
|
|
83
|
+
return String(compiled);
|
|
84
|
+
}
|
|
85
|
+
async function compileBySlug(slug) {
|
|
86
|
+
const filePath = import_path.default.join(process.cwd(), `${slug}.md`);
|
|
87
|
+
try {
|
|
88
|
+
await import_fs.promises.access(filePath);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error(e);
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
93
|
+
const content = await import_fs.promises.readFile(filePath, "utf-8");
|
|
94
|
+
return await compile(content);
|
|
95
|
+
}
|
|
96
|
+
function getMDXComponent(code) {
|
|
97
|
+
const mdxExport = getMDXExport(code);
|
|
98
|
+
return mdxExport.default;
|
|
99
|
+
}
|
|
100
|
+
function getMDXExport(code) {
|
|
101
|
+
const scope = {
|
|
102
|
+
Fragment: import_react.default.Fragment,
|
|
103
|
+
jsxs: import_react.default.createElement,
|
|
104
|
+
jsx: import_react.default.createElement,
|
|
105
|
+
jsxDEV: import_react.default.createElement
|
|
106
|
+
};
|
|
107
|
+
const fn = new Function(...Object.keys(scope), code);
|
|
108
|
+
return fn(scope);
|
|
109
|
+
}
|
|
110
|
+
async function lazyReferences(mod) {
|
|
111
|
+
const references = [];
|
|
112
|
+
if (Array.isArray(mod.default)) {
|
|
113
|
+
for (const chunk of mod.default) {
|
|
114
|
+
try {
|
|
115
|
+
const code = await compile(chunk);
|
|
116
|
+
const Content = getMDXComponent(code);
|
|
117
|
+
const content = Content ? (0, import_codehike.parse)(Content) : null;
|
|
118
|
+
references.push(...content.references);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error(e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
console.warn(`mod.default is not an array, current type is: ${typeof mod.default}`);
|
|
125
|
+
}
|
|
126
|
+
return references;
|
|
127
|
+
}
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
compileBySlug,
|
|
131
|
+
lazyReferences
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=content.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../content.ts","../src/content/index.ts"],"sourcesContent":["export * from \"./src/content/index\"","import path from \"path\";\nimport {promises as fs} from \"fs\";\n\nimport React from \"react\";\nimport {parse} from \"codehike\";\nimport {visit} from \"unist-util-visit\";\nimport {recmaCodeHike, remarkCodeHike} from \"codehike/mdx\";\nimport {compile as mdxCompile} from \"@mdx-js/mdx\";\n\nconst codeHikeOptions = {\n lineNumbers: true,\n showCopyButton: true,\n autoImport: true,\n components: {code: \"Code\"},\n // syntaxHighlighting: { // TODO: !!! FROM SETTINGS !!! wait for rr7 rsc ??\n // theme: \"github-dark\",\n // },\n};\n//\n// // since unist does not support heading level > 6, we need to normalize them\nfunction normalizeCustomHeadings() {\n return (tree: any) => {\n visit(tree, 'paragraph', (node, index, parent) => {\n const match = node.children[0] && node.children[0].value.match(/^(#+)\\s+(.*)/);\n if (match) {\n const level = match[1].length;\n const text = match[2];\n if (level > 6) {\n // Create a new heading node with depth 6\n const headingNode = {\n type: 'heading',\n depth: level,\n children: [{type: 'text', value: text}]\n };\n // Replace the paragraph node with the new heading node\n //@ts-ignore\n parent.children[index] = headingNode;\n }\n }\n });\n };\n}\n\n//\nasync function compile(content: string): Promise<string> {\n const compiled = await mdxCompile(content, {\n remarkPlugins: [normalizeCustomHeadings, [remarkCodeHike, codeHikeOptions]],\n recmaPlugins: [\n [recmaCodeHike, codeHikeOptions]\n ],\n outputFormat: 'function-body',\n development: false,\n });\n\n return String(compiled)\n}\n\nasync function compileBySlug(slug: string) {\n // TODO: cwd ?\n const filePath = path.join(process.cwd(), `${slug}.md`)\n\n try {\n await fs.access(filePath)\n } catch (e) {\n console.error(e)\n return \"\"\n }\n\n const content = await fs.readFile(filePath, \"utf-8\");\n\n return await compile(content)\n}\n\nfunction getMDXComponent(code: string) {\n const mdxExport = getMDXExport(code)\n return mdxExport.default\n}\n\nfunction getMDXExport(code: string) {\n const scope = {\n Fragment: React.Fragment,\n jsxs: React.createElement,\n jsx: React.createElement,\n jsxDEV: React.createElement,\n }\n const fn = new Function(...Object.keys(scope), code)\n return fn(scope)\n}\n\n//\n// function MDXContent(code: string) {\n// return React.useMemo(\n// () => code ? getMDXComponent(code) : null,\n// [code]\n// )\n// }\n\n// TODO: mod ts\nasync function lazyReferences(mod: any) {\n const references: any[] = []\n\n if (Array.isArray(mod.default)) {\n for (const chunk of mod.default) {\n try {\n const code = await compile(chunk) // TODO: do we need real path?\n const Content = getMDXComponent(code)\n const content = Content ? parse(Content) : null\n\n references.push(...content.references as [])\n } catch (e) {\n console.error(e)\n }\n }\n } else {\n console.warn(`mod.default is not an array, current type is: ${typeof mod.default}`)\n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IAAI,GAAG,GAAG,IAAI,KAAK;AAEtD,MAAI;AACA,UAAM,UAAAC,SAAG,OAAO,QAAQ;AAAA,EAC5B,SAAS,GAAG;AACR,YAAQ,MAAM,CAAC;AACf,WAAO;AAAA,EACX;AAEA,QAAM,UAAU,MAAM,UAAAA,SAAG,SAAS,UAAU,OAAO;AAEnD,SAAO,MAAM,QAAQ,OAAO;AAChC;AAEA,SAAS,gBAAgB,MAAc;AACnC,QAAM,YAAY,aAAa,IAAI;AACnC,SAAO,UAAU;AACrB;AAEA,SAAS,aAAa,MAAc;AAChC,QAAM,QAAQ;AAAA,IACV,UAAU,aAAAC,QAAM;AAAA,IAChB,MAAM,aAAAA,QAAM;AAAA,IACZ,KAAK,aAAAA,QAAM;AAAA,IACX,QAAQ,aAAAA,QAAM;AAAA,EAClB;AACA,QAAM,KAAK,IAAI,SAAS,GAAG,OAAO,KAAK,KAAK,GAAG,IAAI;AACnD,SAAO,GAAG,KAAK;AACnB;AAWA,eAAe,eAAe,KAAU;AACpC,QAAM,aAAoB,CAAC;AAE3B,MAAI,MAAM,QAAQ,IAAI,OAAO,GAAG;AAC5B,eAAW,SAAS,IAAI,SAAS;AAC7B,UAAI;AACA,cAAM,OAAO,MAAM,QAAQ,KAAK;AAChC,cAAM,UAAU,gBAAgB,IAAI;AACpC,cAAM,UAAU,cAAU,uBAAM,OAAO,IAAI;AAE3C,mBAAW,KAAK,GAAG,QAAQ,UAAgB;AAAA,MAC/C,SAAS,GAAG;AACR,gBAAQ,MAAM,CAAC;AAAA,MACnB;AAAA,IACJ;AAAA,EACJ,OAAO;AACH,YAAQ,KAAK,iDAAiD,OAAO,IAAI,OAAO,EAAE;AAAA,EACtF;AAEA,SAAO;AACX;","names":["import_mdx","mdxCompile","path","fs","React"]}
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// src/content/index.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { promises as fs } from "fs";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { parse } from "codehike";
|
|
6
|
+
import { visit } from "unist-util-visit";
|
|
7
|
+
import { recmaCodeHike, remarkCodeHike } from "codehike/mdx";
|
|
8
|
+
import { compile as mdxCompile } from "@mdx-js/mdx";
|
|
9
|
+
var codeHikeOptions = {
|
|
10
|
+
lineNumbers: true,
|
|
11
|
+
showCopyButton: true,
|
|
12
|
+
autoImport: true,
|
|
13
|
+
components: { code: "Code" }
|
|
14
|
+
// syntaxHighlighting: { // TODO: !!! FROM SETTINGS !!! wait for rr7 rsc ??
|
|
15
|
+
// theme: "github-dark",
|
|
16
|
+
// },
|
|
17
|
+
};
|
|
18
|
+
function normalizeCustomHeadings() {
|
|
19
|
+
return (tree) => {
|
|
20
|
+
visit(tree, "paragraph", (node, index, parent) => {
|
|
21
|
+
const match = node.children[0] && node.children[0].value.match(/^(#+)\s+(.*)/);
|
|
22
|
+
if (match) {
|
|
23
|
+
const level = match[1].length;
|
|
24
|
+
const text = match[2];
|
|
25
|
+
if (level > 6) {
|
|
26
|
+
const headingNode = {
|
|
27
|
+
type: "heading",
|
|
28
|
+
depth: level,
|
|
29
|
+
children: [{ type: "text", value: text }]
|
|
30
|
+
};
|
|
31
|
+
parent.children[index] = headingNode;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function compile(content) {
|
|
38
|
+
const compiled = await mdxCompile(content, {
|
|
39
|
+
remarkPlugins: [normalizeCustomHeadings, [remarkCodeHike, codeHikeOptions]],
|
|
40
|
+
recmaPlugins: [
|
|
41
|
+
[recmaCodeHike, codeHikeOptions]
|
|
42
|
+
],
|
|
43
|
+
outputFormat: "function-body",
|
|
44
|
+
development: false
|
|
45
|
+
});
|
|
46
|
+
return String(compiled);
|
|
47
|
+
}
|
|
48
|
+
async function compileBySlug(slug) {
|
|
49
|
+
const filePath = path.join(process.cwd(), `${slug}.md`);
|
|
50
|
+
try {
|
|
51
|
+
await fs.access(filePath);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error(e);
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
57
|
+
return await compile(content);
|
|
58
|
+
}
|
|
59
|
+
function getMDXComponent(code) {
|
|
60
|
+
const mdxExport = getMDXExport(code);
|
|
61
|
+
return mdxExport.default;
|
|
62
|
+
}
|
|
63
|
+
function getMDXExport(code) {
|
|
64
|
+
const scope = {
|
|
65
|
+
Fragment: React.Fragment,
|
|
66
|
+
jsxs: React.createElement,
|
|
67
|
+
jsx: React.createElement,
|
|
68
|
+
jsxDEV: React.createElement
|
|
69
|
+
};
|
|
70
|
+
const fn = new Function(...Object.keys(scope), code);
|
|
71
|
+
return fn(scope);
|
|
72
|
+
}
|
|
73
|
+
async function lazyReferences(mod) {
|
|
74
|
+
const references = [];
|
|
75
|
+
if (Array.isArray(mod.default)) {
|
|
76
|
+
for (const chunk of mod.default) {
|
|
77
|
+
try {
|
|
78
|
+
const code = await compile(chunk);
|
|
79
|
+
const Content = getMDXComponent(code);
|
|
80
|
+
const content = Content ? parse(Content) : null;
|
|
81
|
+
references.push(...content.references);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
console.warn(`mod.default is not an array, current type is: ${typeof mod.default}`);
|
|
88
|
+
}
|
|
89
|
+
return references;
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
compileBySlug,
|
|
93
|
+
lazyReferences
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/content/index.ts"],"sourcesContent":["import path from \"path\";\nimport {promises as fs} from \"fs\";\n\nimport React from \"react\";\nimport {parse} from \"codehike\";\nimport {visit} from \"unist-util-visit\";\nimport {recmaCodeHike, remarkCodeHike} from \"codehike/mdx\";\nimport {compile as mdxCompile} from \"@mdx-js/mdx\";\n\nconst codeHikeOptions = {\n lineNumbers: true,\n showCopyButton: true,\n autoImport: true,\n components: {code: \"Code\"},\n // syntaxHighlighting: { // TODO: !!! FROM SETTINGS !!! wait for rr7 rsc ??\n // theme: \"github-dark\",\n // },\n};\n//\n// // since unist does not support heading level > 6, we need to normalize them\nfunction normalizeCustomHeadings() {\n return (tree: any) => {\n visit(tree, 'paragraph', (node, index, parent) => {\n const match = node.children[0] && node.children[0].value.match(/^(#+)\\s+(.*)/);\n if (match) {\n const level = match[1].length;\n const text = match[2];\n if (level > 6) {\n // Create a new heading node with depth 6\n const headingNode = {\n type: 'heading',\n depth: level,\n children: [{type: 'text', value: text}]\n };\n // Replace the paragraph node with the new heading node\n //@ts-ignore\n parent.children[index] = headingNode;\n }\n }\n });\n };\n}\n\n//\nasync function compile(content: string): Promise<string> {\n const compiled = await mdxCompile(content, {\n remarkPlugins: [normalizeCustomHeadings, [remarkCodeHike, codeHikeOptions]],\n recmaPlugins: [\n [recmaCodeHike, codeHikeOptions]\n ],\n outputFormat: 'function-body',\n development: false,\n });\n\n return String(compiled)\n}\n\nasync function compileBySlug(slug: string) {\n // TODO: cwd ?\n const filePath = path.join(process.cwd(), `${slug}.md`)\n\n try {\n await fs.access(filePath)\n } catch (e) {\n console.error(e)\n return \"\"\n }\n\n const content = await fs.readFile(filePath, \"utf-8\");\n\n return await compile(content)\n}\n\nfunction getMDXComponent(code: string) {\n const mdxExport = getMDXExport(code)\n return mdxExport.default\n}\n\nfunction getMDXExport(code: string) {\n const scope = {\n Fragment: React.Fragment,\n jsxs: React.createElement,\n jsx: React.createElement,\n jsxDEV: React.createElement,\n }\n const fn = new Function(...Object.keys(scope), code)\n return fn(scope)\n}\n\n//\n// function MDXContent(code: string) {\n// return React.useMemo(\n// () => code ? getMDXComponent(code) : null,\n// [code]\n// )\n// }\n\n// TODO: mod ts\nasync function lazyReferences(mod: any) {\n const references: any[] = []\n\n if (Array.isArray(mod.default)) {\n for (const chunk of mod.default) {\n try {\n const code = await compile(chunk) // TODO: do we need real path?\n const Content = getMDXComponent(code)\n const content = Content ? parse(Content) : null\n\n references.push(...content.references as [])\n } catch (e) {\n console.error(e)\n }\n }\n } else {\n console.warn(`mod.default is not an array, current type is: ${typeof mod.default}`)\n }\n\n return references\n}\n\nexport {\n compileBySlug,\n lazyReferences\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAQ,YAAY,UAAS;AAE7B,OAAO,WAAW;AAClB,SAAQ,aAAY;AACpB,SAAQ,aAAY;AACpB,SAAQ,eAAe,sBAAqB;AAC5C,SAAQ,WAAW,kBAAiB;AAEpC,IAAM,kBAAkB;AAAA,EACpB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,YAAY,EAAC,MAAM,OAAM;AAAA;AAAA;AAAA;AAI7B;AAGA,SAAS,0BAA0B;AAC/B,SAAO,CAAC,SAAc;AAClB,UAAM,MAAM,aAAa,CAAC,MAAM,OAAO,WAAW;AAC9C,YAAM,QAAQ,KAAK,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,EAAE,MAAM,MAAM,cAAc;AAC7E,UAAI,OAAO;AACP,cAAM,QAAQ,MAAM,CAAC,EAAE;AACvB,cAAM,OAAO,MAAM,CAAC;AACpB,YAAI,QAAQ,GAAG;AAEX,gBAAM,cAAc;AAAA,YAChB,MAAM;AAAA,YACN,OAAO;AAAA,YACP,UAAU,CAAC,EAAC,MAAM,QAAQ,OAAO,KAAI,CAAC;AAAA,UAC1C;AAGA,iBAAO,SAAS,KAAK,IAAI;AAAA,QAC7B;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAGA,eAAe,QAAQ,SAAkC;AACrD,QAAM,WAAW,MAAM,WAAW,SAAS;AAAA,IACvC,eAAe,CAAC,yBAAyB,CAAC,gBAAgB,eAAe,CAAC;AAAA,IAC1E,cAAc;AAAA,MACV,CAAC,eAAe,eAAe;AAAA,IACnC;AA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ict";
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
DEFINED_DEFINITION_PROPERTY_TYPE: () => DEFINED_DEFINITION_PROPERTY_TYPE,
|
|
34
|
+
ReferenceCategory: () => ReferenceCategory,
|
|
35
|
+
ReferenceType: () => ReferenceType,
|
|
36
|
+
default: () => uniform,
|
|
37
|
+
pluginJsonView: () => pluginJsonView,
|
|
38
|
+
pluginNavigation: () => pluginNavigation
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(index_exports);
|
|
41
|
+
|
|
42
|
+
// src/types.ts
|
|
43
|
+
var DEFINED_DEFINITION_PROPERTY_TYPE = /* @__PURE__ */ ((DEFINED_DEFINITION_PROPERTY_TYPE2) => {
|
|
44
|
+
DEFINED_DEFINITION_PROPERTY_TYPE2["UNION"] = "$$union";
|
|
45
|
+
DEFINED_DEFINITION_PROPERTY_TYPE2["XOR"] = "$$xor";
|
|
46
|
+
DEFINED_DEFINITION_PROPERTY_TYPE2["ARRAY"] = "$$array";
|
|
47
|
+
DEFINED_DEFINITION_PROPERTY_TYPE2["ENUM"] = "$$enum";
|
|
48
|
+
return DEFINED_DEFINITION_PROPERTY_TYPE2;
|
|
49
|
+
})(DEFINED_DEFINITION_PROPERTY_TYPE || {});
|
|
50
|
+
var ReferenceCategory = /* @__PURE__ */ ((ReferenceCategory2) => {
|
|
51
|
+
ReferenceCategory2["COMPONENTS"] = "components";
|
|
52
|
+
ReferenceCategory2["HOOKS"] = "hooks";
|
|
53
|
+
ReferenceCategory2["REST"] = "rest";
|
|
54
|
+
ReferenceCategory2["GRAPHQL"] = "graphql";
|
|
55
|
+
ReferenceCategory2["FUNCTIONS"] = "functions";
|
|
56
|
+
return ReferenceCategory2;
|
|
57
|
+
})(ReferenceCategory || {});
|
|
58
|
+
var ReferenceType = /* @__PURE__ */ ((ReferenceType2) => {
|
|
59
|
+
ReferenceType2["COMPONENT"] = "component";
|
|
60
|
+
ReferenceType2["HOOK"] = "hook";
|
|
61
|
+
ReferenceType2["REST_HTTP_GET"] = "rest_get";
|
|
62
|
+
ReferenceType2["REST_HTTP_POST"] = "rest_post";
|
|
63
|
+
ReferenceType2["REST_HTTP_PUT"] = "rest_put";
|
|
64
|
+
ReferenceType2["REST_HTTP_PATCH"] = "rest_patch";
|
|
65
|
+
ReferenceType2["REST_HTTP_DELETE"] = "rest_delete";
|
|
66
|
+
ReferenceType2["REST_HTTP_OPTIONS"] = "rest_options";
|
|
67
|
+
ReferenceType2["REST_HTTP_HEAD"] = "rest_head";
|
|
68
|
+
ReferenceType2["REST_HTTP_TRACE"] = "rest_trace";
|
|
69
|
+
ReferenceType2["REST_COMPONENT_SCHEMA"] = "rest_component_schema";
|
|
70
|
+
ReferenceType2["GRAPHQL_QUERY"] = "graphql_query";
|
|
71
|
+
ReferenceType2["GRAPHQL_MUTATION"] = "graphql_mutation";
|
|
72
|
+
ReferenceType2["GRAPHQL_SUBSCRIPTION"] = "graphql_subscription";
|
|
73
|
+
ReferenceType2["GRAPHQL_SCALAR"] = "graphql_scalar";
|
|
74
|
+
ReferenceType2["GRAPHQL_OBJECT"] = "graphql_object";
|
|
75
|
+
ReferenceType2["GRAPHQL_INTERFACE"] = "graphql_interface";
|
|
76
|
+
ReferenceType2["GRAPHQL_UNION"] = "graphql_union";
|
|
77
|
+
ReferenceType2["GRAPHQL_ENUM"] = "graphql_enum";
|
|
78
|
+
ReferenceType2["GRAPHQL_INPUT"] = "graphql_input";
|
|
79
|
+
ReferenceType2["FUNCTION_JS"] = "function_js";
|
|
80
|
+
return ReferenceType2;
|
|
81
|
+
})(ReferenceType || {});
|
|
82
|
+
|
|
83
|
+
// src/index.ts
|
|
84
|
+
function uniform(references, config) {
|
|
85
|
+
const response = {
|
|
86
|
+
references,
|
|
87
|
+
out: {}
|
|
88
|
+
};
|
|
89
|
+
config.plugins.forEach((plugin) => {
|
|
90
|
+
let defer = void 0;
|
|
91
|
+
const call = plugin({
|
|
92
|
+
references,
|
|
93
|
+
defer: (cb) => {
|
|
94
|
+
if (typeof cb === "function") {
|
|
95
|
+
defer = cb;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// visit: (pattern, callback) => {
|
|
99
|
+
// }
|
|
100
|
+
});
|
|
101
|
+
references.map((ref, i) => {
|
|
102
|
+
call(ref, {
|
|
103
|
+
index: i
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
if (typeof defer === "function") {
|
|
107
|
+
const resp = defer();
|
|
108
|
+
if (typeof resp !== "object") {
|
|
109
|
+
throw new Error(`Invalid callback return type: ${typeof resp}`);
|
|
110
|
+
}
|
|
111
|
+
response.out = {
|
|
112
|
+
...response.out,
|
|
113
|
+
...resp
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return response;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/plugins/pluginJsonView.ts
|
|
121
|
+
function pluginJsonView(options) {
|
|
122
|
+
return function pluginJsonViewInner({
|
|
123
|
+
defer
|
|
124
|
+
}) {
|
|
125
|
+
const jsonViews = [];
|
|
126
|
+
defer(() => ({
|
|
127
|
+
jsonViews
|
|
128
|
+
}));
|
|
129
|
+
return (ref) => {
|
|
130
|
+
const lines = [];
|
|
131
|
+
lines.push("{");
|
|
132
|
+
ref.definitions.forEach((def) => {
|
|
133
|
+
def.properties.forEach((prop, index) => {
|
|
134
|
+
var _a;
|
|
135
|
+
const value = (((_a = prop.examples) == null ? void 0 : _a[0]) || "").replace(/^"|"$|[^a-zA-Z0-9\s\-_.,:/@#=;+()]/g, "");
|
|
136
|
+
const comment = prop.examples && prop.examples.length > 1 ? ` // or "${prop.examples[1].replace(/^"|"$|[^a-zA-Z0-9\s\-_.,:/@#=;+()]/g, "")}"` : "";
|
|
137
|
+
const isLast = index === def.properties.length - 1;
|
|
138
|
+
lines.push(` "${prop.name}": "${value}"${isLast ? "" : ","}${comment}`);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
lines.push("}");
|
|
142
|
+
jsonViews.push(lines.join("\n"));
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/plugins/pluginNavigation.ts
|
|
148
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
149
|
+
var DEFAULT_VIRTUAL_FOLDER = ".xyd/.cache/.content";
|
|
150
|
+
var DEFAULT_GROUP_NAME = "API Reference";
|
|
151
|
+
function pluginNavigation(settings, options) {
|
|
152
|
+
if (!options.urlPrefix) {
|
|
153
|
+
throw new Error("urlPrefix is required");
|
|
154
|
+
}
|
|
155
|
+
return function pluginNavigationInner({
|
|
156
|
+
defer
|
|
157
|
+
}) {
|
|
158
|
+
const pageFrontMatter = {};
|
|
159
|
+
const groupMaps = {};
|
|
160
|
+
defer(() => ({
|
|
161
|
+
pageFrontMatter,
|
|
162
|
+
sidebar: convertGroupMapsToSidebar(settings, groupMaps)
|
|
163
|
+
}));
|
|
164
|
+
return (ref) => {
|
|
165
|
+
const dataCtx = ref.context;
|
|
166
|
+
const pagePath = import_node_path.default.join(options.urlPrefix, ref.canonical);
|
|
167
|
+
let group = (dataCtx == null ? void 0 : dataCtx.group) || [];
|
|
168
|
+
let title = ref.title;
|
|
169
|
+
if (pageFrontMatter[pagePath]) {
|
|
170
|
+
console.error("(pluginNavigation): pageFrontMatter[pagePath] already exists", pagePath);
|
|
171
|
+
}
|
|
172
|
+
if (!group) {
|
|
173
|
+
group = [options.defaultGroup || DEFAULT_GROUP_NAME];
|
|
174
|
+
}
|
|
175
|
+
pageFrontMatter[pagePath] = {
|
|
176
|
+
title
|
|
177
|
+
};
|
|
178
|
+
if (typeof group === "string") {
|
|
179
|
+
throw new Error("group as string is not supported yet");
|
|
180
|
+
}
|
|
181
|
+
group.reduce((groups, groupName, i) => {
|
|
182
|
+
if (!groups[groupName]) {
|
|
183
|
+
groups[groupName] = {
|
|
184
|
+
__groups: {},
|
|
185
|
+
pages: /* @__PURE__ */ new Set()
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (i === group.length - 1) {
|
|
189
|
+
groups[groupName].pages.add(pagePath);
|
|
190
|
+
}
|
|
191
|
+
return groups[groupName].__groups;
|
|
192
|
+
}, groupMaps);
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function convertGroupMapsToSidebar(settings, groupMaps) {
|
|
197
|
+
const nav = [];
|
|
198
|
+
Object.keys(groupMaps).map((groupName) => {
|
|
199
|
+
const current = groupMaps[groupName];
|
|
200
|
+
const pages = [];
|
|
201
|
+
current.pages.forEach((page) => {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
if ((_b = (_a = settings == null ? void 0 : settings.engine) == null ? void 0 : _a.uniform) == null ? void 0 : _b.store) {
|
|
204
|
+
pages.push(page);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
pages.push({
|
|
208
|
+
virtual: import_node_path.default.join(DEFAULT_VIRTUAL_FOLDER, page),
|
|
209
|
+
page
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
if (Object.keys(current.__groups).length) {
|
|
213
|
+
const subNav = {
|
|
214
|
+
group: groupName,
|
|
215
|
+
pages: convertGroupMapsToSidebar(settings, current.__groups)
|
|
216
|
+
};
|
|
217
|
+
nav.push(subNav);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
nav.push({
|
|
221
|
+
group: groupName,
|
|
222
|
+
pages
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
return nav;
|
|
226
|
+
}
|
|
227
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
228
|
+
0 && (module.exports = {
|
|
229
|
+
DEFINED_DEFINITION_PROPERTY_TYPE,
|
|
230
|
+
ReferenceCategory,
|
|
231
|
+
ReferenceType,
|
|
232
|
+
pluginJsonView,
|
|
233
|
+
pluginNavigation
|
|
234
|
+
});
|
|
235
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts","../src/types.ts","../src/index.ts","../src/plugins/pluginJsonView.ts","../src/plugins/pluginNavigation.ts"],"sourcesContent":["export * from \"./src/types\"\nexport type {\n UniformPlugin,\n UniformPluginArgs\n} from \"./src/index\"\n\nexport { default } from \"./src/index\"\n\nexport {\n pluginJsonView,\n pluginNavigation,\n} from \"./src/plugins\"\n\n\n","import React from \"react\";\nimport {HighlightedCode} from \"codehike/code\";\n\n// TODO: type, and category also as generic?\nexport interface Reference<\n C = ReferenceContext,\n M extends DefinitionMeta = DefinitionMeta,\n VM extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n description: string | React.ReactNode;\n canonical: string;\n\n definitions: Definition<M, VM>[] // TODO: in the future from generic?\n examples: ExampleRoot\n\n\n category?: ReferenceCategory; // TODO: do we need that?\n\n type?: ReferenceType; // TODO: do we need that?\n\n context?: C;\n\n /**\n * TODO: !!!! BETTER !!!!\n * @internal\n */\n __UNSAFE_selector?: (selector: string) => any;\n}\n\nexport type DefinitionOpenAPIMeta = Meta<\"contentType\" | \"required\" | \"definitionDescription\">;\nexport type DefinitionTypeDocMeta = Meta<\"type\">;\nexport type DefinitionGraphqlMeta = Meta<\"type\" | \"graphqlName\">;\n\nexport type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta\n\nexport type SymbolDef = {\n id?: string | string[];\n\n canonical?: string | string[];\n}\n\nexport interface Definition<\n M extends DefinitionMeta = DefinitionMeta,\n VM extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n\n properties: DefinitionProperty[];\n\n rootProperty?: DefinitionProperty\n\n variants?: DefinitionVariant<VM>[];\n\n description?: string | React.ReactNode;\n\n meta?: M[];\n\n /**\n * @internal\n */\n symbolDef?: SymbolDef;\n\n /**\n * @internal\n */\n id?: string;\n\n /**\n * @internal\n */\n type?: string;\n}\n\nexport type DefinitionVariantOpenAPIMeta = Meta<\"status\" | \"contentType\" | \"definitionDescription\" | \"required\">;\nexport type CommonDefinitionVariantMeta = Meta<\"symbolName\">;\n\nexport type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta\n\nexport interface DefinitionVariant<\n M extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n\n properties: DefinitionProperty[];\n\n rootProperty?: DefinitionProperty\n\n description?: string | React.ReactNode;\n\n symbolDef?: SymbolDef;\n\n meta?: M[];\n}\n\nexport interface Meta<T = string> {\n name: T;\n\n value?: unknown; // TODO: better type?\n}\n\nexport type DefinitionPropertyMeta = Meta<\"required\" | \"deprecated\" | \"internal\" | \"defaults\" | \"nullable\" | \"example\" | \"examples\" | \"minimum\" | \"maximum\" | \"enum-type\"> // TODO: better solution than enum-type?\n\nexport enum DEFINED_DEFINITION_PROPERTY_TYPE {\n UNION = \"$$union\",\n\n XOR = \"$$xor\",\n\n ARRAY = \"$$array\",\n\n ENUM = \"$$enum\",\n\n // TYPE = \"$$type\", TODO: good idea?\n}\n\nexport interface DefinitionProperty {\n name: string;\n\n type: string | DEFINED_DEFINITION_PROPERTY_TYPE\n\n description: string | React.ReactNode;\n\n // TODO: in the future more advanced examples?\n examples?: string | string[];\n\n symbolDef?: SymbolDef;\n\n meta?: DefinitionPropertyMeta[];\n\n context?: any // TODO: better type\n\n properties?: DefinitionProperty[];\n\n ofProperty?: DefinitionProperty;\n}\n\nexport interface ExampleRoot {\n groups: ExampleGroup[];\n}\n\nexport interface ExampleGroup {\n description?: string;\n\n examples: Example[];\n}\n\nexport interface Example {\n description?: string; // TODO: replace with title ?\n\n codeblock: CodeBlock;\n}\n\nexport interface CodeBlock {\n title?: string;\n\n tabs: CodeBlockTab[];\n}\n\nexport interface CodeBlockTab {\n // title of the tab e.g \"JavaScript\"\n title: string;\n\n // code in the tab e.g \"console.log('Hello World')\"\n code: string\n\n // language of the code e.g \"js\"\n language: string;\n\n // context of the generation method e.g openapi or graphql\n context?: ExampleContext;\n\n // TODO: highlighted code\n highlighted?: HighlightedCode;\n}\n\nexport type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;\n\n// TODO: concept only\nexport enum ReferenceCategory {\n // for React\n COMPONENTS = \"components\",\n HOOKS = \"hooks\",\n // end for React\n\n // for API\n REST = \"rest\",\n GRAPHQL = \"graphql\",\n // end for API\n\n // for code\n FUNCTIONS = \"functions\",\n //\n}\n\n// TODO: concept only\nexport enum ReferenceType {\n // for React\n COMPONENT = \"component\",\n HOOK = \"hook\",\n // end for React\n\n // for API\n // TODO: better type system for specific api typesl like gql or rest\n REST_HTTP_GET = \"rest_get\",\n REST_HTTP_POST = \"rest_post\",\n REST_HTTP_PUT = \"rest_put\",\n REST_HTTP_PATCH = \"rest_patch\",\n REST_HTTP_DELETE = \"rest_delete\",\n REST_HTTP_OPTIONS = \"rest_options\",\n REST_HTTP_HEAD = \"rest_head\",\n REST_HTTP_TRACE = \"rest_trace\",\n\n REST_COMPONENT_SCHEMA = \"rest_component_schema\",\n // ---\n GRAPHQL_QUERY = \"graphql_query\",\n GRAPHQL_MUTATION = \"graphql_mutation\",\n GRAPHQL_SUBSCRIPTION = \"graphql_subscription\",\n\n GRAPHQL_SCALAR = \"graphql_scalar\",\n GRAPHQL_OBJECT = \"graphql_object\",\n GRAPHQL_INTERFACE = \"graphql_interface\",\n GRAPHQL_UNION = \"graphql_union\",\n GRAPHQL_ENUM = \"graphql_enum\",\n GRAPHQL_INPUT = \"graphql_input\",\n // end for API\n\n // for code\n FUNCTION_JS = \"function_js\",\n // end for code\n}\n\nexport interface BaseReferenceContext {\n group?: string[];\n\n scopes?: string[];\n}\n\nexport interface GraphQLReferenceContext extends BaseReferenceContext {\n /**\n * @internal\n */\n graphqlTypeShort: string;\n\n graphqlName: string;\n}\n\n// TODO: custom value?\nexport interface OpenAPIReferenceContext extends BaseReferenceContext {\n method?: string;\n\n path?: string;\n\n fullPath?: string;\n\n componentSchema?: string\n}\n\nexport type TypeDocReferenceContextMeta = Meta<\"internal\">\n\n// Add TypeDocReferenceContext to the union type\nexport interface TypeDocReferenceContext extends BaseReferenceContext {\n symbolId: string;\n symbolName: string;\n symbolKind: number;\n packageName: string;\n fileName: string;\n fileFullPath: string;\n line: number;\n col: number;\n signatureText: {\n code: string;\n lang: string;\n };\n sourcecode: {\n code: string;\n lang: string;\n };\n category?: string;\n meta?: TypeDocReferenceContextMeta[]\n}\n\nexport type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext\n\nexport interface GraphQLExampleContext {\n schema?: any; // TODO:\n}\n\nexport interface OpenAPIExampleContext {\n status?: number;\n\n content?: string;\n}\n\n\n","// Define the new PluginV type with a callback function that returns another function\nimport {Reference} from \"./types\";\n\nexport * from \"./types\";\n\n// Define the new PluginV type with a callback function that returns another function\nexport type UniformPluginArgs = {\n references: Reference[] | Reference,\n defer: (defer: () => any) => void;\n\n // TODO: maybe in the future\n // visit: (selector: string | \"[method] [path]\", callback: (...args: any[]) => void) => void;\n}\n\n\nexport type UniformPluginRestArgs = {\n index: number;\n}\nexport type UniformPlugin<T> = (args: UniformPluginArgs) => (ref: Reference, restArgs: UniformPluginRestArgs) => void;\n\n// Utility type to infer if a type is an array and avoid wrapping it into an array twice\ntype NormalizeArray<T> = T extends Array<infer U> ? U[] : T;\n\n// Infer the return type of the plugin callback properly and normalize array types\ntype PluginResult<T extends UniformPlugin<any>> = T extends UniformPlugin<infer R> ? R : never;\n\n// Merge all plugin return types into a single object and normalize arrays\ntype MergePluginResults<T extends UniformPlugin<any>[]> = {\n [K in keyof UnionToIntersection<PluginResult<T[number]>>]: NormalizeArray<UnionToIntersection<PluginResult<T[number]>>[K]>\n};\n\n// Utility type to handle intersection to an object type\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\n// Implement the uniform function\nexport default function uniform<T extends UniformPlugin<any>[]>(\n references: Reference[],\n config: { plugins: T }\n) {\n // Infer the merged result type from all plugins\n type ResultType = MergePluginResults<T>;\n\n // Initialize the response with a type-safe out object\n const response: {\n references: Reference[]\n out: { [K in keyof ResultType]: ResultType[K] }\n } = {\n references,\n out: {} as { [K in keyof ResultType]: ResultType[K] }\n };\n\n config.plugins.forEach((plugin) => {\n let defer: any = undefined; // fix any\n\n const call = plugin({\n references: references,\n defer: (cb) => {\n if (typeof cb === \"function\") {\n defer = cb\n }\n },\n // visit: (pattern, callback) => {\n // }\n })\n\n references.map((ref, i) => {\n call(ref, {\n index: i,\n })\n });\n\n if (typeof defer === \"function\") {\n const resp = defer()\n if (typeof resp !== \"object\") {\n throw new Error(`Invalid callback return type: ${typeof resp}`)\n }\n\n response.out = {\n ...response.out,\n ...resp\n }\n }\n })\n\n return response;\n}\n\n// Example usage\n// const examplePlugin: UniformPlugin<{ value: boolean }> = (cb) => {\n// return (ref: Reference) => {\n// };\n// };\n// function examplePlugin(defer: (defer: () => { value: boolean }) => void) {\n// defer(() => ({\n// value: true,\n// }));\n//\n// return (ref: Reference) => {\n//\n// };\n// }\n// const response = uniform([/* references */], {\n// plugins: [examplePlugin],\n// });\n// response.out\n","import type { UniformPluginArgs, UniformPlugin } from \"../index\";\nimport { Reference } from \"../types\";\n\nexport interface pluginJsonViewOptions {\n}\n\ntype pluginJsonViewOutput = {\n jsonViews: string;\n}\n\nexport function pluginJsonView(\n options?: pluginJsonViewOptions\n): UniformPlugin<pluginJsonViewOutput> {\n\n return function pluginJsonViewInner({\n defer,\n }: UniformPluginArgs) {\n const jsonViews: string[] = [];\n\n defer(() => ({\n jsonViews\n }))\n\n return (ref: Reference) => {\n // Build the output string manually to ensure exact format\n const lines: string[] = [];\n lines.push('{');\n \n ref.definitions.forEach(def => {\n def.properties.forEach((prop, index) => {\n // Remove any quotes and trailing characters from the value\n const value = (prop.examples?.[0] || '').replace(/^\"|\"$|[^a-zA-Z0-9\\s\\-_.,:/@#=;+()]/g, '');\n const comment = prop.examples && prop.examples.length > 1 \n ? ` // or \"${(prop.examples as string[])[1].replace(/^\"|\"$|[^a-zA-Z0-9\\s\\-_.,:/@#=;+()]/g, '')}\"`\n : '';\n const isLast = index === def.properties.length - 1;\n // Add comma after the value but before the comment\n lines.push(` \"${prop.name}\": \"${value}\"${isLast ? '' : ','}${comment}`);\n });\n });\n \n lines.push('}');\n \n jsonViews.push(lines.join('\\n'));\n }\n }\n}\n\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginJsonView({\n// \n// })],\n// });\n","import path from 'node:path';\n\nimport type { Sidebar, Metadata, MetadataMap, Settings, PageURL } from \"@xyd-js/core\";\n\nimport type { UniformPluginArgs, UniformPlugin } from \"../index\";\nimport { CodeBlockTab, Example, ExampleGroup, Reference } from \"../types\";\n\nconst DEFAULT_VIRTUAL_FOLDER = \".xyd/.cache/.content\" // TODO: share this + .xyd/.build/.content for build\n\nconst DEFAULT_GROUP_NAME = \"API Reference\" // TODO: configurable\n\ntype GroupMap = {\n [key: string]: {\n __groups: GroupMap\n pages: Set<string>\n }\n}\n\nexport interface pluginNavigationOptions {\n urlPrefix: string\n defaultGroup?: string\n}\n\ntype pluginNavigationOutput = {\n pageFrontMatter: MetadataMap;\n sidebar: Sidebar[];\n}\n\nexport function pluginNavigation(\n settings: Settings,\n options: pluginNavigationOptions\n): UniformPlugin<pluginNavigationOutput> {\n if (!options.urlPrefix) {\n throw new Error(\"urlPrefix is required\")\n }\n\n return function pluginNavigationInner({\n defer,\n }: UniformPluginArgs) {\n const pageFrontMatter: MetadataMap = {}\n const groupMaps: GroupMap = {}\n\n defer(() => ({\n pageFrontMatter,\n sidebar: convertGroupMapsToSidebar(settings, groupMaps) as Sidebar[]\n }))\n\n return (ref: Reference) => {\n const dataCtx = ref.context\n const pagePath = path.join(options.urlPrefix, ref.canonical)\n\n let group = dataCtx?.group || []\n let title = ref.title\n\n if (pageFrontMatter[pagePath]) {\n console.error(\"(pluginNavigation): pageFrontMatter[pagePath] already exists\", pagePath)\n }\n\n if (!group) {\n group = [options.defaultGroup || DEFAULT_GROUP_NAME]\n }\n\n pageFrontMatter[pagePath] = {\n title,\n }\n\n if (typeof group === \"string\") {\n // TODO: seek nested group (it's not always from 0)\n throw new Error(\"group as string is not supported yet\")\n }\n\n group.reduce((groups: GroupMap, groupName: string, i: number) => {\n if (!groups[groupName]) {\n groups[groupName] = {\n __groups: {},\n pages: new Set()\n }\n }\n\n if (i === group.length - 1) {\n groups[groupName].pages.add(pagePath)\n }\n\n return groups[groupName].__groups\n }, groupMaps)\n }\n }\n}\n\nfunction convertGroupMapsToSidebar(settings: Settings, groupMaps: GroupMap): Sidebar[] {\n const nav: Sidebar[] = []\n\n Object.keys(groupMaps).map((groupName) => {\n const current = groupMaps[groupName]\n\n const pages: PageURL[] = []\n\n current.pages.forEach((page: string) => {\n if (settings?.engine?.uniform?.store) {\n pages.push(page)\n return\n }\n pages.push({\n virtual: path.join(DEFAULT_VIRTUAL_FOLDER, page),\n page: page,\n })\n })\n\n if (Object.keys(current.__groups).length) {\n const subNav: Sidebar = {\n group: groupName,\n pages: convertGroupMapsToSidebar(settings, current.__groups)\n }\n\n nav.push(subNav)\n\n return\n }\n\n nav.push({\n group: groupName,\n pages,\n })\n })\n\n return nav\n}\n\n// TODO: in the future xyd settings must be removed cuz uniform will be part of opendocs\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginNavigation({}, {\n// urlPrefix: \"/docs\"\n// })],\n// });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuGO,IAAK,mCAAL,kBAAKA,sCAAL;AACH,EAAAA,kCAAA,WAAQ;AAER,EAAAA,kCAAA,SAAM;AAEN,EAAAA,kCAAA,WAAQ;AAER,EAAAA,kCAAA,UAAO;AAPC,SAAAA;AAAA,GAAA;AA2EL,IAAK,oBAAL,kBAAKC,uBAAL;AAEH,EAAAA,mBAAA,gBAAa;AACb,EAAAA,mBAAA,WAAQ;AAIR,EAAAA,mBAAA,UAAO;AACP,EAAAA,mBAAA,aAAU;AAIV,EAAAA,mBAAA,eAAY;AAZJ,SAAAA;AAAA,GAAA;AAiBL,IAAK,gBAAL,kBAAKC,mBAAL;AAEH,EAAAA,eAAA,eAAY;AACZ,EAAAA,eAAA,UAAO;AAKP,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,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A,QACP,OAAO,0BAA0B,UAAU,QAAQ,QAAQ;AAAA,MAC/D;AAEA,UAAI,KAAK,MAAM;AAEf;AAAA,IACJ;AAEA,QAAI,KAAK;AAAA,MACL,OAAO;AAAA,MACP;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,SAAO;AACX;","names":["DEFINED_DEFINITION_PROPERTY_TYPE","ReferenceCategory","ReferenceType","path"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { R as Reference } from './types-BiglsETJ.cjs';
|
|
2
|
+
export { B as BaseReferenceContext, m as CodeBlock, n as CodeBlockTab, C as CommonDefinitionVariantMeta, i as DEFINED_DEFINITION_PROPERTY_TYPE, d as Definition, b as DefinitionGraphqlMeta, c as DefinitionMeta, D as DefinitionOpenAPIMeta, j as DefinitionProperty, h as DefinitionPropertyMeta, a as DefinitionTypeDocMeta, g as DefinitionVariant, f as DefinitionVariantMeta, e as DefinitionVariantOpenAPIMeta, l as Example, o as ExampleContext, k as ExampleGroup, E as ExampleRoot, t as GraphQLExampleContext, G as GraphQLReferenceContext, M as Meta, u as OpenAPIExampleContext, O as OpenAPIReferenceContext, p as ReferenceCategory, s as ReferenceContext, q as ReferenceType, S as SymbolDef, r as TypeDocReferenceContext, T as TypeDocReferenceContextMeta } from './types-BiglsETJ.cjs';
|
|
3
|
+
import { Settings, MetadataMap, Sidebar } from '@xyd-js/core';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'codehike/code';
|
|
6
|
+
|
|
7
|
+
type UniformPluginArgs = {
|
|
8
|
+
references: Reference[] | Reference;
|
|
9
|
+
defer: (defer: () => any) => void;
|
|
10
|
+
};
|
|
11
|
+
type UniformPluginRestArgs = {
|
|
12
|
+
index: number;
|
|
13
|
+
};
|
|
14
|
+
type UniformPlugin<T> = (args: UniformPluginArgs) => (ref: Reference, restArgs: UniformPluginRestArgs) => void;
|
|
15
|
+
type NormalizeArray<T> = T extends Array<infer U> ? U[] : T;
|
|
16
|
+
type PluginResult<T extends UniformPlugin<any>> = T extends UniformPlugin<infer R> ? R : never;
|
|
17
|
+
type MergePluginResults<T extends UniformPlugin<any>[]> = {
|
|
18
|
+
[K in keyof UnionToIntersection<PluginResult<T[number]>>]: NormalizeArray<UnionToIntersection<PluginResult<T[number]>>[K]>;
|
|
19
|
+
};
|
|
20
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
21
|
+
declare function uniform<T extends UniformPlugin<any>[]>(references: Reference[], config: {
|
|
22
|
+
plugins: T;
|
|
23
|
+
}): {
|
|
24
|
+
references: Reference[];
|
|
25
|
+
out: MergePluginResults<T> extends infer T_1 ? { [K in keyof T_1]: MergePluginResults<T>[K]; } : never;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
interface pluginJsonViewOptions {
|
|
29
|
+
}
|
|
30
|
+
type pluginJsonViewOutput = {
|
|
31
|
+
jsonViews: string;
|
|
32
|
+
};
|
|
33
|
+
declare function pluginJsonView(options?: pluginJsonViewOptions): UniformPlugin<pluginJsonViewOutput>;
|
|
34
|
+
|
|
35
|
+
interface pluginNavigationOptions {
|
|
36
|
+
urlPrefix: string;
|
|
37
|
+
defaultGroup?: string;
|
|
38
|
+
}
|
|
39
|
+
type pluginNavigationOutput = {
|
|
40
|
+
pageFrontMatter: MetadataMap;
|
|
41
|
+
sidebar: Sidebar[];
|
|
42
|
+
};
|
|
43
|
+
declare function pluginNavigation(settings: Settings, options: pluginNavigationOptions): UniformPlugin<pluginNavigationOutput>;
|
|
44
|
+
|
|
45
|
+
export { Reference, type UniformPlugin, type UniformPluginArgs, uniform as default, pluginJsonView, pluginNavigation };
|