@kubb/plugin-redoc 3.16.2 → 3.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +61 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +678 -14
- package/dist/index.d.ts +678 -14
- package/dist/index.js +57 -42
- package/dist/index.js.map +1 -1
- package/package.json +14 -17
package/dist/index.cjs
CHANGED
|
@@ -1,62 +1,78 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
2
22
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
const node_path = __toESM(require("node:path"));
|
|
25
|
+
const __kubb_core = __toESM(require("@kubb/core"));
|
|
26
|
+
const __kubb_plugin_oas = __toESM(require("@kubb/plugin-oas"));
|
|
27
|
+
const __kubb_core_fs = __toESM(require("@kubb/core/fs"));
|
|
28
|
+
const node_fs = __toESM(require("node:fs"));
|
|
29
|
+
const handlebars = __toESM(require("handlebars"));
|
|
9
30
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
13
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs$1);
|
|
14
|
-
var pkg__default = /*#__PURE__*/_interopDefault(pkg);
|
|
15
|
-
|
|
16
|
-
// src/plugin.ts
|
|
31
|
+
//#region src/redoc.tsx
|
|
17
32
|
async function getPageHTML(api, { title, disableGoogleFont, templateOptions } = {}) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js">
|
|
33
|
+
const templateFileName = node_path.default.join(__dirname, "../static/redoc.hbs");
|
|
34
|
+
const template = handlebars.default.compile(node_fs.default.readFileSync(templateFileName).toString());
|
|
35
|
+
return template({
|
|
36
|
+
title: title || api.info.title || "ReDoc documentation",
|
|
37
|
+
redocHTML: `
|
|
38
|
+
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> <\/script>
|
|
24
39
|
<div id="redoc-container"></div>
|
|
25
40
|
<script>
|
|
26
41
|
const data = ${JSON.stringify(api, null, 2)};
|
|
27
42
|
Redoc.init(data, {
|
|
28
43
|
"expandResponses": "200,400"
|
|
29
44
|
}, document.getElementById('redoc-container'))
|
|
30
|
-
|
|
45
|
+
<\/script>
|
|
31
46
|
`,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
disableGoogleFont,
|
|
48
|
+
templateOptions
|
|
49
|
+
});
|
|
35
50
|
}
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/plugin.ts
|
|
54
|
+
const pluginRedocName = "plugin-redoc";
|
|
55
|
+
const pluginRedoc = (0, __kubb_core.createPlugin)((options) => {
|
|
56
|
+
const { output = { path: "docs.html" } } = options;
|
|
57
|
+
return {
|
|
58
|
+
name: pluginRedocName,
|
|
59
|
+
options: {
|
|
60
|
+
output,
|
|
61
|
+
name: (0, __kubb_core_fs.trimExtName)(output.path)
|
|
62
|
+
},
|
|
63
|
+
pre: [__kubb_plugin_oas.pluginOasName],
|
|
64
|
+
async buildStart() {
|
|
65
|
+
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
66
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
67
|
+
await oas.dereference();
|
|
68
|
+
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
69
|
+
const pageHTML = await getPageHTML(oas.api);
|
|
70
|
+
await (0, __kubb_core_fs.write)(node_path.default.resolve(root, output.path || "./docs.html"), pageHTML);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
57
73
|
});
|
|
58
74
|
|
|
75
|
+
//#endregion
|
|
59
76
|
exports.pluginRedoc = pluginRedoc;
|
|
60
77
|
exports.pluginRedocName = pluginRedocName;
|
|
61
|
-
//# sourceMappingURL=index.cjs.map
|
|
62
78
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["api: OasTypes.OASDocument","path","pkg","fs","pluginOasName","PluginManager","path"],"sources":["../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions }: BuildDocsOptions = {}) {\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n title: title || api.info.title || 'ReDoc documentation',\n redocHTML: `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `,\n disableGoogleFont,\n templateOptions,\n })\n}\n","import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport { trimExtName, write } from '@kubb/core/fs'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\nexport const pluginRedoc = createPlugin<PluginRedoc>((options) => {\n const { output = { path: 'docs.html' } } = options\n\n return {\n name: pluginRedocName,\n options: {\n output,\n name: trimExtName(output.path),\n },\n pre: [pluginOasName],\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n const oas = await swaggerPlugin.context.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await write(path.resolve(root, output.path || './docs.html'), pageHTML)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,eAAsB,YAAYA,KAA2B,EAAE,OAAO,mBAAmB,iBAAmC,GAAG,CAAE,GAAE;CACjI,MAAM,mBAAmBC,kBAAK,KAAK,WAAW,sBAAsB;CACpE,MAAM,WAAWC,mBAAI,QAAQC,gBAAG,aAAa,iBAAiB,CAAC,UAAU,CAAC;AAC1E,QAAO,SAAS;EACd,OAAO,SAAS,IAAI,KAAK,SAAS;EAClC,WAAW,CAAC;;;;gBAIA,EAAE,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;;;;;IAK3C,CAAC;EACD;EACA;CACD,EAAC;AACH;;;;AClBD,MAAa,kBAAkB;AAE/B,MAAa,4CAAwC,CAAC,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAa,GAAE,GAAG;AAE3C,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,sCAAkB,OAAO,KAAK;EAC/B;EACD,KAAK,CAACC,+BAAc;EACpB,MAAM,aAAa;GACjB,MAAM,CAAC,cAAmC,GAAGC,0BAAc,mBAA8B,KAAK,SAAS,CAACD,+BAAc,EAAC;GACvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAEhD,MAAM,IAAI,aAAa;GAEvB,MAAM,OAAOE,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,WAAW,MAAM,YAAY,IAAI,IAAI;GAE3C,gCAAYA,kBAAK,QAAQ,MAAM,OAAO,QAAQ,cAAc,EAAE,SAAS;EACxE;CACF;AACF,EAAC"}
|