@kubb/plugin-redoc 3.16.2 → 3.16.4
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.js
CHANGED
|
@@ -1,57 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import fs from
|
|
7
|
-
import pkg from
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { PluginManager, createPlugin } from "@kubb/core";
|
|
3
|
+
import { pluginOasName } from "@kubb/plugin-oas";
|
|
4
|
+
import { trimExtName, write } from "@kubb/core/fs";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import pkg from "handlebars";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
9
|
+
//#region rolldown:runtime
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __esm = (fn, res) => function() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../node_modules/.pnpm/tsdown@0.14.1_typescript@5.9.2/node_modules/tsdown/esm-shims.js
|
|
17
|
+
var getFilename, getDirname, __dirname;
|
|
18
|
+
var init_esm_shims = __esm({ "../../node_modules/.pnpm/tsdown@0.14.1_typescript@5.9.2/node_modules/tsdown/esm-shims.js": (() => {
|
|
19
|
+
getFilename = () => fileURLToPath(import.meta.url);
|
|
20
|
+
getDirname = () => path.dirname(getFilename());
|
|
21
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
22
|
+
}) });
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/redoc.tsx
|
|
26
|
+
init_esm_shims();
|
|
13
27
|
async function getPageHTML(api, { title, disableGoogleFont, templateOptions } = {}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js">
|
|
28
|
+
const templateFileName = path.join(__dirname, "../static/redoc.hbs");
|
|
29
|
+
const template = pkg.compile(fs.readFileSync(templateFileName).toString());
|
|
30
|
+
return template({
|
|
31
|
+
title: title || api.info.title || "ReDoc documentation",
|
|
32
|
+
redocHTML: `
|
|
33
|
+
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> <\/script>
|
|
20
34
|
<div id="redoc-container"></div>
|
|
21
35
|
<script>
|
|
22
36
|
const data = ${JSON.stringify(api, null, 2)};
|
|
23
37
|
Redoc.init(data, {
|
|
24
38
|
"expandResponses": "200,400"
|
|
25
39
|
}, document.getElementById('redoc-container'))
|
|
26
|
-
|
|
40
|
+
<\/script>
|
|
27
41
|
`,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
disableGoogleFont,
|
|
43
|
+
templateOptions
|
|
44
|
+
});
|
|
31
45
|
}
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/plugin.ts
|
|
49
|
+
const pluginRedocName = "plugin-redoc";
|
|
50
|
+
const pluginRedoc = createPlugin((options) => {
|
|
51
|
+
const { output = { path: "docs.html" } } = options;
|
|
52
|
+
return {
|
|
53
|
+
name: pluginRedocName,
|
|
54
|
+
options: {
|
|
55
|
+
output,
|
|
56
|
+
name: trimExtName(output.path)
|
|
57
|
+
},
|
|
58
|
+
pre: [pluginOasName],
|
|
59
|
+
async buildStart() {
|
|
60
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
61
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
62
|
+
await oas.dereference();
|
|
63
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
64
|
+
const pageHTML = await getPageHTML(oas.api);
|
|
65
|
+
await write(path.resolve(root, output.path || "./docs.html"), pageHTML);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
53
68
|
});
|
|
54
69
|
|
|
70
|
+
//#endregion
|
|
55
71
|
export { pluginRedoc, pluginRedocName };
|
|
56
|
-
//# sourceMappingURL=index.js.map
|
|
57
72
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/
|
|
1
|
+
{"version":3,"file":"index.js","names":["api: OasTypes.OASDocument"],"sources":["../../../node_modules/.pnpm/tsdown@0.14.1_typescript@5.9.2/node_modules/tsdown/esm-shims.js","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","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"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;CAIM,cAAc,MAAM,cAAc,OAAO,KAAK,IAAI;CAClD,aAAa,MAAM,KAAK,QAAQ,aAAa,CAAC;CAEvC,4BAA4B,YAAY;;;;;;ACIrD,eAAsB,YAAYA,KAA2B,EAAE,OAAO,mBAAmB,iBAAmC,GAAG,CAAE,GAAE;CACjI,MAAM,mBAAmB,KAAK,KAAK,WAAW,sBAAsB;CACpE,MAAM,WAAW,IAAI,QAAQ,GAAG,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,cAAc,aAA0B,CAAC,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAa,GAAE,GAAG;AAE3C,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,MAAM,YAAY,OAAO,KAAK;EAC/B;EACD,KAAK,CAAC,aAAc;EACpB,MAAM,aAAa;GACjB,MAAM,CAAC,cAAmC,GAAG,cAAc,mBAA8B,KAAK,SAAS,CAAC,aAAc,EAAC;GACvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAEhD,MAAM,IAAI,aAAa;GAEvB,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,WAAW,MAAM,YAAY,IAAI,IAAI;GAE3C,MAAM,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,cAAc,EAAE,SAAS;EACxE;CACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-redoc",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.4",
|
|
4
4
|
"description": "Beautiful docs with Redoc",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -21,15 +21,13 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"import": "./dist/index.js",
|
|
24
|
-
"require": "./dist/index.cjs"
|
|
25
|
-
"default": "./dist/index.cjs"
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
26
25
|
},
|
|
27
|
-
"./package.json": "./package.json"
|
|
28
|
-
"./*": "./*"
|
|
26
|
+
"./package.json": "./package.json"
|
|
29
27
|
},
|
|
30
|
-
"main": "dist/index.cjs",
|
|
31
|
-
"module": "dist/index.js",
|
|
32
|
-
"types": "./dist/index.d.
|
|
28
|
+
"main": "./dist/index.cjs",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
33
31
|
"typesVersions": {
|
|
34
32
|
"*": {}
|
|
35
33
|
},
|
|
@@ -42,15 +40,14 @@
|
|
|
42
40
|
],
|
|
43
41
|
"dependencies": {
|
|
44
42
|
"handlebars": "^4.7.8",
|
|
45
|
-
"@kubb/core": "3.16.
|
|
46
|
-
"@kubb/oas": "3.16.
|
|
47
|
-
"@kubb/plugin-oas": "3.16.
|
|
43
|
+
"@kubb/core": "3.16.4",
|
|
44
|
+
"@kubb/oas": "3.16.4",
|
|
45
|
+
"@kubb/plugin-oas": "3.16.4"
|
|
48
46
|
},
|
|
49
47
|
"devDependencies": {
|
|
50
|
-
"
|
|
48
|
+
"tsdown": "^0.14.1",
|
|
51
49
|
"typescript": "^5.9.2",
|
|
52
|
-
"@kubb/config-ts": "3.16.
|
|
53
|
-
"@kubb/config-tsup": "3.16.2"
|
|
50
|
+
"@kubb/config-ts": "3.16.4"
|
|
54
51
|
},
|
|
55
52
|
"peerDependencies": {
|
|
56
53
|
"@kubb/react": "^3.0.0"
|
|
@@ -63,13 +60,13 @@
|
|
|
63
60
|
"registry": "https://registry.npmjs.org/"
|
|
64
61
|
},
|
|
65
62
|
"scripts": {
|
|
66
|
-
"build": "
|
|
63
|
+
"build": "tsdown",
|
|
67
64
|
"clean": "npx rimraf ./dist",
|
|
68
65
|
"lint": "bun biome lint .",
|
|
69
|
-
"lint:fix": "bun biome lint--fix --unsafe .",
|
|
66
|
+
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
70
67
|
"release": "pnpm publish --no-git-check",
|
|
71
68
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
72
|
-
"start": "
|
|
69
|
+
"start": "tsdown --watch",
|
|
73
70
|
"test": "vitest --passWithNoTests",
|
|
74
71
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
75
72
|
}
|