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.js
CHANGED
|
@@ -10,10 +10,10 @@ import { dump } from "js-yaml";
|
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
11
|
import * as os from "node:os";
|
|
12
12
|
import os__default from "node:os";
|
|
13
|
-
import renderToString from "preact-render-to-string";
|
|
14
|
-
import { jsxs, jsx, Fragment } from "preact/jsx-runtime";
|
|
15
13
|
import { dirname, join as join$1 } from "node:path";
|
|
16
14
|
import { fileURLToPath } from "node:url";
|
|
15
|
+
import renderToString from "preact-render-to-string";
|
|
16
|
+
import { jsxs, jsx, Fragment } from "preact/jsx-runtime";
|
|
17
17
|
import cluster from "node:cluster";
|
|
18
18
|
import net from "node:net";
|
|
19
19
|
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
@@ -3753,12 +3753,29 @@ function MainContent$1({ allRoutes, config, spec }) {
|
|
|
3753
3753
|
] });
|
|
3754
3754
|
}
|
|
3755
3755
|
class ApiExplorerPlugin extends ShokupanRouter {
|
|
3756
|
-
constructor(pluginOptions) {
|
|
3756
|
+
constructor(pluginOptions = {}) {
|
|
3757
3757
|
super({ renderer: renderToString });
|
|
3758
3758
|
this.pluginOptions = pluginOptions;
|
|
3759
3759
|
pluginOptions.path ??= "/explorer";
|
|
3760
|
+
this.init();
|
|
3761
|
+
}
|
|
3762
|
+
onInit(app, options) {
|
|
3763
|
+
const path = this.pluginOptions.path || options?.path || "/apiexplorer";
|
|
3764
|
+
app.mount(path, this);
|
|
3765
|
+
if (app.applicationConfig.enableOpenApiGen !== true) {
|
|
3766
|
+
console.warn("ApiExplorerPlugin: enableOpenApiGen is disabled. ApiExplorerPlugin will not generate spec.");
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
static getBasePath() {
|
|
3770
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
3771
|
+
if (dir.endsWith("dist")) {
|
|
3772
|
+
return dir + "/plugins/application/api-explorer";
|
|
3773
|
+
}
|
|
3774
|
+
return dir;
|
|
3775
|
+
}
|
|
3776
|
+
init() {
|
|
3760
3777
|
const serveFile = async (ctx, file, type) => {
|
|
3761
|
-
const content = await readFile$1(join(
|
|
3778
|
+
const content = await readFile$1(join$1(ApiExplorerPlugin.getBasePath(), "static", file), "utf-8");
|
|
3762
3779
|
ctx.set("Content-Type", type);
|
|
3763
3780
|
return ctx.send(content);
|
|
3764
3781
|
};
|