@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 CHANGED
@@ -1,62 +1,78 @@
1
- 'use strict';
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
- var path2 = require('path');
4
- var core = require('@kubb/core');
5
- var pluginOas = require('@kubb/plugin-oas');
6
- var fs = require('@kubb/core/fs');
7
- var fs$1 = require('fs');
8
- var pkg = require('handlebars');
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
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
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
- const templateFileName = path2__default.default.join(__dirname, "../static/redoc.hbs");
19
- const template = pkg__default.default.compile(fs__default.default.readFileSync(templateFileName).toString());
20
- return template({
21
- title: title || api.info.title || "ReDoc documentation",
22
- redocHTML: `
23
- <script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
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
- </script>
45
+ <\/script>
31
46
  `,
32
- disableGoogleFont,
33
- templateOptions
34
- });
47
+ disableGoogleFont,
48
+ templateOptions
49
+ });
35
50
  }
36
51
 
37
- // src/plugin.ts
38
- var pluginRedocName = "plugin-redoc";
39
- var pluginRedoc = core.createPlugin((options) => {
40
- const { output = { path: "docs.html" } } = options;
41
- return {
42
- name: pluginRedocName,
43
- options: {
44
- output,
45
- name: fs.trimExtName(output.path)
46
- },
47
- pre: [pluginOas.pluginOasName],
48
- async buildStart() {
49
- const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
50
- const oas = await swaggerPlugin.context.getOas();
51
- await oas.dereference();
52
- const root = path2__default.default.resolve(this.config.root, this.config.output.path);
53
- const pageHTML = await getPageHTML(oas.api);
54
- await fs.write(path2__default.default.resolve(root, output.path || "./docs.html"), pageHTML);
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
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/redoc.tsx","../src/plugin.ts"],"names":["path","pkg","fs","createPlugin","trimExtName","pluginOasName","PluginManager","write"],"mappings":";;;;;;;;;;;;;;;;AAWA,eAAsB,WAAA,CAAY,KAA2B,EAAE,KAAA,EAAO,mBAAmB,eAAgB,EAAA,GAAsB,EAAI,EAAA;AACjI,EAAA,MAAM,gBAAmB,GAAAA,sBAAA,CAAK,IAAK,CAAA,SAAA,EAAW,qBAAqB,CAAA;AACnE,EAAM,MAAA,QAAA,GAAWC,qBAAI,OAAQ,CAAAC,mBAAA,CAAG,aAAa,gBAAgB,CAAA,CAAE,UAAU,CAAA;AACzE,EAAA,OAAO,QAAS,CAAA;AAAA,IACd,KAAO,EAAA,KAAA,IAAS,GAAI,CAAA,IAAA,CAAK,KAAS,IAAA,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'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"]}
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"}