shokupan 0.10.2 → 0.10.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 +21 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/plugins/application/api-explorer/plugin.d.ts +7 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,10 +33,10 @@ const api = require("@opentelemetry/api");
|
|
|
33
33
|
const jsYaml = require("js-yaml");
|
|
34
34
|
const node_async_hooks = require("node:async_hooks");
|
|
35
35
|
const os = require("node:os");
|
|
36
|
-
const renderToString = require("preact-render-to-string");
|
|
37
|
-
const jsxRuntime = require("preact/jsx-runtime");
|
|
38
36
|
const path$1 = require("node:path");
|
|
39
37
|
const node_url = require("node:url");
|
|
38
|
+
const renderToString = require("preact-render-to-string");
|
|
39
|
+
const jsxRuntime = require("preact/jsx-runtime");
|
|
40
40
|
const cluster = require("node:cluster");
|
|
41
41
|
const net = require("node:net");
|
|
42
42
|
const node_perf_hooks = require("node:perf_hooks");
|
|
@@ -3795,12 +3795,29 @@ function MainContent$1({ allRoutes, config, spec }) {
|
|
|
3795
3795
|
] });
|
|
3796
3796
|
}
|
|
3797
3797
|
class ApiExplorerPlugin extends ShokupanRouter {
|
|
3798
|
-
constructor(pluginOptions) {
|
|
3798
|
+
constructor(pluginOptions = {}) {
|
|
3799
3799
|
super({ renderer: renderToString });
|
|
3800
3800
|
this.pluginOptions = pluginOptions;
|
|
3801
3801
|
pluginOptions.path ??= "/explorer";
|
|
3802
|
+
this.init();
|
|
3803
|
+
}
|
|
3804
|
+
onInit(app, options) {
|
|
3805
|
+
const path2 = this.pluginOptions.path || options?.path || "/apiexplorer";
|
|
3806
|
+
app.mount(path2, this);
|
|
3807
|
+
if (app.applicationConfig.enableOpenApiGen !== true) {
|
|
3808
|
+
console.warn("ApiExplorerPlugin: enableOpenApiGen is disabled. ApiExplorerPlugin will not generate spec.");
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
static getBasePath() {
|
|
3812
|
+
const dir = path$1.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href));
|
|
3813
|
+
if (dir.endsWith("dist")) {
|
|
3814
|
+
return dir + "/plugins/application/api-explorer";
|
|
3815
|
+
}
|
|
3816
|
+
return dir;
|
|
3817
|
+
}
|
|
3818
|
+
init() {
|
|
3802
3819
|
const serveFile = async (ctx, file, type) => {
|
|
3803
|
-
const content = await promises$1.readFile(path.join(
|
|
3820
|
+
const content = await promises$1.readFile(path$1.join(ApiExplorerPlugin.getBasePath(), "static", file), "utf-8");
|
|
3804
3821
|
ctx.set("Content-Type", type);
|
|
3805
3822
|
return ctx.send(content);
|
|
3806
3823
|
};
|