miqro 6.0.13 → 6.1.1
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/README.md +12 -0
- package/build/editor.bundle.js +41 -50413
- package/build/esm/src/cluster.js +0 -1
- package/build/esm/src/common/arguments.d.ts +12 -0
- package/build/esm/src/common/arguments.js +111 -10
- package/build/esm/src/common/assets.js +2 -3
- package/build/esm/src/common/checksum.js +0 -1
- package/build/esm/src/common/constants.d.ts +1 -0
- package/build/esm/src/common/constants.js +2 -3
- package/build/esm/src/common/content-type.js +0 -1
- package/build/esm/src/common/esbuild.js +0 -1
- package/build/esm/src/common/exit.js +0 -1
- package/build/esm/src/common/fs.js +0 -1
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +4 -1
- package/build/esm/src/common/jsx.d.ts +8 -1
- package/build/esm/src/common/jsx.js +84 -2
- package/build/esm/src/common/paths.d.ts +4 -0
- package/build/esm/src/common/paths.js +41 -2
- package/build/esm/src/common/watch.js +0 -1
- package/build/esm/src/inflate/inflate-sea.js +27 -16
- package/build/esm/src/inflate/inflate.js +2 -1
- package/build/esm/src/inflate/md.d.ts +1 -0
- package/build/esm/src/inflate/md.js +9 -6
- package/build/esm/src/inflate/setup-auth.js +0 -1
- package/build/esm/src/inflate/setup-cors.js +0 -1
- package/build/esm/src/inflate/setup-db.js +0 -1
- package/build/esm/src/inflate/setup-error.d.ts +3 -0
- package/build/esm/src/inflate/setup-error.js +40 -0
- package/build/esm/src/inflate/setup-http.js +13 -4
- package/build/esm/src/inflate/setup-log.js +0 -1
- package/build/esm/src/inflate/setup-middleware.d.ts +4 -0
- package/build/esm/src/inflate/setup-middleware.js +42 -0
- package/build/esm/src/inflate/setup-server-config.js +0 -1
- package/build/esm/src/inflate/setup-test.js +0 -1
- package/build/esm/src/inflate/setup-ws.js +0 -1
- package/build/esm/src/inflate/setup.doc.d.ts +4 -0
- package/build/esm/src/inflate/setup.doc.js +62 -0
- package/build/esm/src/inflate/utils/sea-utils.js +0 -1
- package/build/esm/src/lib.js +0 -1
- package/build/esm/src/main.js +3 -4
- package/build/esm/src/services/app.d.ts +1 -0
- package/build/esm/src/services/app.js +21 -5
- package/build/esm/src/services/editor.js +0 -1
- package/build/esm/src/services/globals.js +0 -1
- package/build/esm/src/services/hot-reload.js +2 -2
- package/build/esm/src/services/migrations.js +0 -1
- package/build/esm/src/services/utils/admin-interface.js +0 -1
- package/build/esm/src/services/utils/cache.js +0 -1
- package/build/esm/src/services/utils/cluster-cache.js +0 -1
- package/build/esm/src/services/utils/cluster-ws.js +0 -1
- package/build/esm/src/services/utils/db-manager.js +0 -1
- package/build/esm/src/services/utils/get-route.js +0 -1
- package/build/esm/src/services/utils/log-transport.js +0 -1
- package/build/esm/src/services/utils/log.js +2 -2
- package/build/esm/src/services/utils/server-interface.js +0 -1
- package/build/esm/src/services/utils/websocketmanager.js +0 -1
- package/build/esm/src/types.d.ts +16 -1
- package/build/esm/src/types.js +0 -1
- package/build/lib.cjs +895 -326
- package/package.json +4 -2
- package/sea/types.json +1 -1
- package/tsconfig.json +1 -1
- package/bin/miqro +0 -34
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -42
- package/build/esm/editor/auth.js.map +0 -1
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -45
- package/build/esm/editor/common/admin-interface.js.map +0 -1
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -21
- package/build/esm/editor/common/constants.js.map +0 -1
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -5
- package/build/esm/editor/common/constants.server.js.map +0 -1
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -15
- package/build/esm/editor/common/editor-index.js.map +0 -1
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -15
- package/build/esm/editor/common/html-encode.js.map +0 -1
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -71
- package/build/esm/editor/common/log-socket.js.map +0 -1
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -444
- package/build/esm/editor/common/templates.js.map +0 -1
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -91
- package/build/esm/editor/components/api-preview.js.map +0 -1
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -358
- package/build/esm/editor/components/editor.js.map +0 -1
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -127
- package/build/esm/editor/components/file-browser.js.map +0 -1
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -94
- package/build/esm/editor/components/file-editor-toolbar.js.map +0 -1
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -60
- package/build/esm/editor/components/file-editor.js.map +0 -1
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -23
- package/build/esm/editor/components/filter-query.js.map +0 -1
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -139
- package/build/esm/editor/components/highlight-text-area.js.map +0 -1
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -70
- package/build/esm/editor/components/log-viewer.js.map +0 -1
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -118
- package/build/esm/editor/components/new-file.js.map +0 -1
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -22
- package/build/esm/editor/components/scroll-query.js.map +0 -1
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -31
- package/build/esm/editor/components/start-page.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -30
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -50
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -40
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -150
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -39
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -47
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -46
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -8
- package/build/esm/editor/http/admin/editor/editor.js.map +0 -1
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -22
- package/build/esm/editor/http/admin/editor/index.api.js.map +0 -1
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -50
- package/build/esm/editor/server.js.map +0 -1
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -12
- package/build/esm/editor/ws.js.map +0 -1
- package/build/esm/src/bin/compile.d.ts +0 -3
- package/build/esm/src/bin/compile.js +0 -31
- package/build/esm/src/bin/compile.js.map +0 -1
- package/build/esm/src/bin/doc-md.d.ts +0 -17
- package/build/esm/src/bin/doc-md.js +0 -187
- package/build/esm/src/bin/doc-md.js.map +0 -1
- package/build/esm/src/bin/generate-doc.d.ts +0 -4
- package/build/esm/src/bin/generate-doc.js +0 -49
- package/build/esm/src/bin/generate-doc.js.map +0 -1
- package/build/esm/src/bin/test.d.ts +0 -3
- package/build/esm/src/bin/test.js +0 -68
- package/build/esm/src/bin/test.js.map +0 -1
- package/build/esm/src/bin/types.d.ts +0 -3
- package/build/esm/src/bin/types.js +0 -21
- package/build/esm/src/bin/types.js.map +0 -1
- package/build/esm/src/cluster.js.map +0 -1
- package/build/esm/src/common/arguments.js.map +0 -1
- package/build/esm/src/common/assets.js.map +0 -1
- package/build/esm/src/common/checksum.js.map +0 -1
- package/build/esm/src/common/constants.js.map +0 -1
- package/build/esm/src/common/content-type.js.map +0 -1
- package/build/esm/src/common/esbuild.js.map +0 -1
- package/build/esm/src/common/exit.js.map +0 -1
- package/build/esm/src/common/fs.js.map +0 -1
- package/build/esm/src/common/help.js.map +0 -1
- package/build/esm/src/common/jsx.js.map +0 -1
- package/build/esm/src/common/paths.js.map +0 -1
- package/build/esm/src/common/watch.js.map +0 -1
- package/build/esm/src/inflate/inflate-sea.js.map +0 -1
- package/build/esm/src/inflate/inflate.js.map +0 -1
- package/build/esm/src/inflate/md.js.map +0 -1
- package/build/esm/src/inflate/setup-auth.js.map +0 -1
- package/build/esm/src/inflate/setup-cors.js.map +0 -1
- package/build/esm/src/inflate/setup-db.js.map +0 -1
- package/build/esm/src/inflate/setup-http.js.map +0 -1
- package/build/esm/src/inflate/setup-log.js.map +0 -1
- package/build/esm/src/inflate/setup-server-config.js.map +0 -1
- package/build/esm/src/inflate/setup-test.js.map +0 -1
- package/build/esm/src/inflate/setup-ws.js.map +0 -1
- package/build/esm/src/inflate/utils/sea-utils.js.map +0 -1
- package/build/esm/src/lib.js.map +0 -1
- package/build/esm/src/main.js.map +0 -1
- package/build/esm/src/services/app.js.map +0 -1
- package/build/esm/src/services/editor.js.map +0 -1
- package/build/esm/src/services/globals.js.map +0 -1
- package/build/esm/src/services/hot-reload.js.map +0 -1
- package/build/esm/src/services/migrations.js.map +0 -1
- package/build/esm/src/services/utils/admin-interface.js.map +0 -1
- package/build/esm/src/services/utils/cache.js.map +0 -1
- package/build/esm/src/services/utils/cluster-cache.js.map +0 -1
- package/build/esm/src/services/utils/cluster-ws.js.map +0 -1
- package/build/esm/src/services/utils/db-manager.js.map +0 -1
- package/build/esm/src/services/utils/get-route.js.map +0 -1
- package/build/esm/src/services/utils/log-transport.js.map +0 -1
- package/build/esm/src/services/utils/log.js.map +0 -1
- package/build/esm/src/services/utils/server-interface.js.map +0 -1
- package/build/esm/src/services/utils/websocketmanager.js.map +0 -1
- package/build/esm/src/types.js.map +0 -1
- package/editor/auth.ts +0 -51
- package/editor/common/admin-interface.ts +0 -84
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -85
- package/editor/common/templates.ts +0 -448
- package/editor/components/api-preview.tsx +0 -116
- package/editor/components/editor.tsx +0 -486
- package/editor/components/file-browser.tsx +0 -308
- package/editor/components/file-editor-toolbar.tsx +0 -191
- package/editor/components/file-editor.tsx +0 -122
- package/editor/components/filter-query.tsx +0 -22
- package/editor/components/highlight-text-area.tsx +0 -159
- package/editor/components/log-viewer.tsx +0 -110
- package/editor/components/new-file.tsx +0 -169
- package/editor/components/scroll-query.tsx +0 -22
- package/editor/components/start-page.tsx +0 -49
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -8
- package/editor/http/admin/editor/index.api.tsx +0 -39
- package/editor/server.ts +0 -57
- package/editor/static/android-chrome-192x192.png +0 -0
- package/editor/static/android-chrome-512x512.png +0 -0
- package/editor/static/apple-touch-icon.png +0 -0
- package/editor/static/editor.bundle.in.mjs +0 -20
- package/editor/static/favicon-16x16.png +0 -0
- package/editor/static/favicon-32x32.png +0 -0
- package/editor/static/favicon.ico +0 -0
- package/editor/static/site.webmanifest +0 -19
- package/editor/ws.ts +0 -15
- package/sea/base64.js +0 -3
- package/sea/compile.sh +0 -127
- package/sea/copy-types.sh +0 -46
- package/sea/editor-assets/editor.bundle.in.mjs +0 -19
- package/sea/generate-global-types-asset-json.js +0 -34
- package/sea/release-tar.sh +0 -5
- package/sea/tsc.sh +0 -1
- package/sea/version.tag.js +0 -11
- package/src/bin/compile.ts +0 -35
- package/src/bin/doc-md.ts +0 -210
- package/src/bin/generate-doc.ts +0 -58
- package/src/bin/test.ts +0 -92
- package/src/bin/types.ts +0 -22
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -382
- package/src/common/assets.ts +0 -128
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -18
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -94
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -17
- package/src/common/help.ts +0 -47
- package/src/common/jsx.ts +0 -426
- package/src/common/paths.ts +0 -117
- package/src/common/watch.ts +0 -85
- package/src/inflate/inflate-sea.ts +0 -194
- package/src/inflate/inflate.ts +0 -96
- package/src/inflate/md.ts +0 -20
- package/src/inflate/setup-auth.ts +0 -40
- package/src/inflate/setup-cors.ts +0 -40
- package/src/inflate/setup-db.ts +0 -113
- package/src/inflate/setup-http.ts +0 -643
- package/src/inflate/setup-log.ts +0 -44
- package/src/inflate/setup-server-config.ts +0 -47
- package/src/inflate/setup-test.ts +0 -23
- package/src/inflate/setup-ws.ts +0 -48
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -19
- package/src/main.ts +0 -87
- package/src/services/app.ts +0 -640
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts +0 -143
- package/src/services/hot-reload.ts +0 -46
- package/src/services/migrations.ts +0 -66
- package/src/services/utils/admin-interface.ts +0 -37
- package/src/services/utils/cache.ts +0 -88
- package/src/services/utils/cluster-cache.ts +0 -230
- package/src/services/utils/cluster-ws.ts +0 -197
- package/src/services/utils/db-manager.ts +0 -92
- package/src/services/utils/get-route.ts +0 -70
- package/src/services/utils/log-transport.ts +0 -75
- package/src/services/utils/log.ts +0 -91
- package/src/services/utils/server-interface.ts +0 -172
- package/src/services/utils/websocketmanager.ts +0 -149
- package/src/types/@esbuild.d.ts +0 -1
- package/src/types/@miqro/core.d.ts +0 -2
- package/src/types/@miqro/jsx.d.ts +0 -2
- package/src/types/@miqro/parser.d.ts +0 -2
- package/src/types/@miqro/query.d.ts +0 -2
- package/src/types/@miqro/request.d.ts +0 -2
- package/src/types/@miqro/test.d.ts +0 -2
- package/src/types/@miqro.d.ts +0 -1
- package/src/types/@types.d.ts +0 -1
- package/src/types/browser.globals.d.ts +0 -9
- package/src/types/globals.d.ts +0 -2
- package/src/types/jsx.globals.d.ts +0 -37
- package/src/types/miqro.d.ts +0 -111
- package/src/types/postject.d.ts +0 -1
- package/src/types/server.globals.d.ts +0 -72
- package/src/types.ts +0 -204
- /package/{editor/http/admin/editor → build}/font.ttf +0 -0
- /package/{editor/http/admin/editor → build}/style.css +0 -0
package/build/lib.cjs
CHANGED
|
@@ -3854,13 +3854,13 @@ var require_showdown = __commonJS({
|
|
|
3854
3854
|
});
|
|
3855
3855
|
|
|
3856
3856
|
// editor/common/constants.server.ts
|
|
3857
|
-
var
|
|
3857
|
+
var import_node_path19, import_node_process14, PORT, BASE_PATH;
|
|
3858
3858
|
var init_constants_server = __esm({
|
|
3859
3859
|
"editor/common/constants.server.ts"() {
|
|
3860
|
-
|
|
3861
|
-
|
|
3860
|
+
import_node_path19 = require("node:path");
|
|
3861
|
+
import_node_process14 = require("node:process");
|
|
3862
3862
|
PORT = process.env["PORT"] ? process.env["PORT"] : "8080";
|
|
3863
|
-
BASE_PATH = (0,
|
|
3863
|
+
BASE_PATH = (0, import_node_path19.resolve)((0, import_node_process14.cwd)());
|
|
3864
3864
|
}
|
|
3865
3865
|
});
|
|
3866
3866
|
|
|
@@ -3877,33 +3877,33 @@ function scanDir(req, basePath = BASE_PATH, ret = []) {
|
|
|
3877
3877
|
const admin = req.editor;
|
|
3878
3878
|
const services = admin ? admin.getServices() : ["."];
|
|
3879
3879
|
services.forEach((service) => {
|
|
3880
|
-
scanDirInternal(req, (0,
|
|
3880
|
+
scanDirInternal(req, (0, import_node_path20.resolve)(basePath, service), ret);
|
|
3881
3881
|
});
|
|
3882
3882
|
return ret;
|
|
3883
3883
|
}
|
|
3884
3884
|
function scanDirInternal(req, path = BASE_PATH, ret = []) {
|
|
3885
|
-
if (!(0,
|
|
3885
|
+
if (!(0, import_node_fs18.existsSync)(path)) {
|
|
3886
3886
|
return ret;
|
|
3887
3887
|
}
|
|
3888
|
-
const files = (0,
|
|
3888
|
+
const files = (0, import_node_fs18.readdirSync)(path);
|
|
3889
3889
|
for (const file of files) {
|
|
3890
3890
|
if (shouldIgnoreFile(file)) {
|
|
3891
3891
|
continue;
|
|
3892
3892
|
}
|
|
3893
|
-
const filePath = (0,
|
|
3894
|
-
if ((0,
|
|
3893
|
+
const filePath = (0, import_node_path20.resolve)(path, file);
|
|
3894
|
+
if ((0, import_node_fs18.statSync)(filePath).isDirectory()) {
|
|
3895
3895
|
scanDirInternal(req, filePath, ret);
|
|
3896
3896
|
continue;
|
|
3897
3897
|
} else {
|
|
3898
|
-
const ext = (0,
|
|
3899
|
-
const fileName = (0,
|
|
3898
|
+
const ext = (0, import_node_path20.extname)(filePath);
|
|
3899
|
+
const fileName = (0, import_node_path20.basename)(filePath);
|
|
3900
3900
|
const name = fileName.substring(0, fileName.length - ext.length);
|
|
3901
|
-
const subExt = (0,
|
|
3901
|
+
const subExt = (0, import_node_path20.extname)(name);
|
|
3902
3902
|
const subName = name.substring(0, name.length - subExt.length);
|
|
3903
3903
|
ret.push({
|
|
3904
|
-
dirs: getFileDirs((0,
|
|
3904
|
+
dirs: getFileDirs((0, import_node_path20.relative)(BASE_PATH, filePath)),
|
|
3905
3905
|
language: getLanguage(filePath),
|
|
3906
|
-
filePath: (0,
|
|
3906
|
+
filePath: (0, import_node_path20.relative)(BASE_PATH, filePath),
|
|
3907
3907
|
ext,
|
|
3908
3908
|
fileName,
|
|
3909
3909
|
name,
|
|
@@ -3921,16 +3921,16 @@ function shouldIgnoreFile(file) {
|
|
|
3921
3921
|
}
|
|
3922
3922
|
function getFileDirs(filePath) {
|
|
3923
3923
|
const dirs = [];
|
|
3924
|
-
let dir = (0,
|
|
3925
|
-
while (dir !==
|
|
3924
|
+
let dir = (0, import_node_path20.dirname)(filePath);
|
|
3925
|
+
while (dir !== import_node_path20.sep && dir !== "" && dir !== "." && dir !== BASE_PATH) {
|
|
3926
3926
|
dirs.push(dir);
|
|
3927
|
-
dir = (0,
|
|
3927
|
+
dir = (0, import_node_path20.dirname)(dir);
|
|
3928
3928
|
}
|
|
3929
|
-
return dirs.reverse().map((d) => (0,
|
|
3929
|
+
return dirs.reverse().map((d) => (0, import_node_path20.basename)(d));
|
|
3930
3930
|
}
|
|
3931
3931
|
function getLanguage(filePath) {
|
|
3932
|
-
const ext = (0,
|
|
3933
|
-
const fileName = (0,
|
|
3932
|
+
const ext = (0, import_node_path20.extname)(filePath);
|
|
3933
|
+
const fileName = (0, import_node_path20.basename)(filePath);
|
|
3934
3934
|
switch (ext.toLocaleLowerCase()) {
|
|
3935
3935
|
case ".py":
|
|
3936
3936
|
return "python";
|
|
@@ -3998,11 +3998,11 @@ function getAPIPreview(req, filePath) {
|
|
|
3998
3998
|
}
|
|
3999
3999
|
return void 0;
|
|
4000
4000
|
}
|
|
4001
|
-
var
|
|
4001
|
+
var import_node_fs18, import_node_path20, scan_api_default;
|
|
4002
4002
|
var init_scan_api = __esm({
|
|
4003
4003
|
"editor/http/admin/editor/api/fs/scan.api.tsx"() {
|
|
4004
|
-
|
|
4005
|
-
|
|
4004
|
+
import_node_fs18 = require("node:fs");
|
|
4005
|
+
import_node_path20 = require("node:path");
|
|
4006
4006
|
init_constants_server();
|
|
4007
4007
|
scan_api_default = {
|
|
4008
4008
|
method: "GET",
|
|
@@ -4038,25 +4038,25 @@ function readFile2(path) {
|
|
|
4038
4038
|
const filePath = getPath(path);
|
|
4039
4039
|
const language = getLanguage(filePath);
|
|
4040
4040
|
if (SUPPORTED_LANGUAGES.includes(language)) {
|
|
4041
|
-
const contents = (0,
|
|
4041
|
+
const contents = (0, import_node_fs19.readFileSync)(filePath).toString();
|
|
4042
4042
|
return contents;
|
|
4043
4043
|
} else {
|
|
4044
4044
|
throw new Error("unsupported file format");
|
|
4045
4045
|
}
|
|
4046
4046
|
}
|
|
4047
4047
|
function getPath(path) {
|
|
4048
|
-
const realPath = (0,
|
|
4049
|
-
if ((0,
|
|
4048
|
+
const realPath = (0, import_node_path21.resolve)(BASE_PATH, path);
|
|
4049
|
+
if ((0, import_node_path21.relative)(BASE_PATH, realPath).startsWith("..")) {
|
|
4050
4050
|
throw new Error("invalid path! [" + path + "]");
|
|
4051
4051
|
}
|
|
4052
4052
|
return realPath;
|
|
4053
4053
|
}
|
|
4054
|
-
var
|
|
4054
|
+
var import_node_fs19, import_node_path21, read_api_default;
|
|
4055
4055
|
var init_read_api = __esm({
|
|
4056
4056
|
"editor/http/admin/editor/api/fs/read.api.tsx"() {
|
|
4057
|
-
|
|
4057
|
+
import_node_fs19 = require("node:fs");
|
|
4058
4058
|
init_constants();
|
|
4059
|
-
|
|
4059
|
+
import_node_path21 = require("node:path");
|
|
4060
4060
|
init_scan_api();
|
|
4061
4061
|
init_constants_server();
|
|
4062
4062
|
read_api_default = {
|
|
@@ -4094,20 +4094,20 @@ __export(write_api_exports, {
|
|
|
4094
4094
|
default: () => write_api_default
|
|
4095
4095
|
});
|
|
4096
4096
|
async function writeFile2(path, contents, override) {
|
|
4097
|
-
if ((0,
|
|
4097
|
+
if ((0, import_node_fs20.existsSync)(getPath(path)) && !override) {
|
|
4098
4098
|
throw new Error("file already exists!");
|
|
4099
4099
|
}
|
|
4100
|
-
(0,
|
|
4100
|
+
(0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(getPath(path)), {
|
|
4101
4101
|
recursive: true
|
|
4102
4102
|
});
|
|
4103
|
-
(0,
|
|
4103
|
+
(0, import_node_fs20.writeFileSync)(getPath(path), contents);
|
|
4104
4104
|
}
|
|
4105
|
-
var
|
|
4105
|
+
var import_node_fs20, import_node_path22, write_api_default;
|
|
4106
4106
|
var init_write_api = __esm({
|
|
4107
4107
|
"editor/http/admin/editor/api/fs/write.api.tsx"() {
|
|
4108
|
-
|
|
4108
|
+
import_node_fs20 = require("node:fs");
|
|
4109
4109
|
init_read_api();
|
|
4110
|
-
|
|
4110
|
+
import_node_path22 = require("node:path");
|
|
4111
4111
|
write_api_default = {
|
|
4112
4112
|
middleware: [server.middleware.json()],
|
|
4113
4113
|
method: "POST",
|
|
@@ -4144,21 +4144,21 @@ __export(rename_api_exports, {
|
|
|
4144
4144
|
rename: () => rename
|
|
4145
4145
|
});
|
|
4146
4146
|
async function rename(path, newName) {
|
|
4147
|
-
if ((0,
|
|
4148
|
-
(0,
|
|
4147
|
+
if ((0, import_node_fs21.existsSync)(path) && !(0, import_node_fs21.existsSync)(newName)) {
|
|
4148
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path23.dirname)(getPath(newName)), {
|
|
4149
4149
|
recursive: true
|
|
4150
4150
|
});
|
|
4151
|
-
(0,
|
|
4151
|
+
(0, import_node_fs21.renameSync)(getPath(path), getPath(newName));
|
|
4152
4152
|
} else {
|
|
4153
4153
|
throw new Error("invalid paths");
|
|
4154
4154
|
}
|
|
4155
4155
|
}
|
|
4156
|
-
var
|
|
4156
|
+
var import_node_fs21, import_node_path23, rename_api_default;
|
|
4157
4157
|
var init_rename_api = __esm({
|
|
4158
4158
|
"editor/http/admin/editor/api/fs/rename.api.tsx"() {
|
|
4159
|
-
|
|
4159
|
+
import_node_fs21 = require("node:fs");
|
|
4160
4160
|
init_read_api();
|
|
4161
|
-
|
|
4161
|
+
import_node_path23 = require("node:path");
|
|
4162
4162
|
rename_api_default = {
|
|
4163
4163
|
middleware: [server.middleware.json()],
|
|
4164
4164
|
method: "POST",
|
|
@@ -4193,12 +4193,12 @@ __export(delete_api_exports, {
|
|
|
4193
4193
|
default: () => delete_api_default
|
|
4194
4194
|
});
|
|
4195
4195
|
function deleteFile(path) {
|
|
4196
|
-
(0,
|
|
4196
|
+
(0, import_node_fs22.unlinkSync)(getPath(path));
|
|
4197
4197
|
}
|
|
4198
|
-
var
|
|
4198
|
+
var import_node_fs22, delete_api_default;
|
|
4199
4199
|
var init_delete_api = __esm({
|
|
4200
4200
|
"editor/http/admin/editor/api/fs/delete.api.tsx"() {
|
|
4201
|
-
|
|
4201
|
+
import_node_fs22 = require("node:fs");
|
|
4202
4202
|
init_read_api();
|
|
4203
4203
|
delete_api_default = {
|
|
4204
4204
|
description: "admin editor file deletion endpoint",
|
|
@@ -4236,15 +4236,15 @@ __export(restart_api_exports, {
|
|
|
4236
4236
|
function parseInflateErrors(errors) {
|
|
4237
4237
|
return errors?.map((error2) => {
|
|
4238
4238
|
return {
|
|
4239
|
-
filePath: (0,
|
|
4239
|
+
filePath: (0, import_node_path24.relative)(BASE_PATH, error2.filePath),
|
|
4240
4240
|
error: error2.error.message
|
|
4241
4241
|
};
|
|
4242
4242
|
});
|
|
4243
4243
|
}
|
|
4244
|
-
var
|
|
4244
|
+
var import_node_path24, restart_api_default;
|
|
4245
4245
|
var init_restart_api = __esm({
|
|
4246
4246
|
"editor/http/admin/editor/api/server/restart.api.tsx"() {
|
|
4247
|
-
|
|
4247
|
+
import_node_path24 = require("node:path");
|
|
4248
4248
|
init_constants_server();
|
|
4249
4249
|
restart_api_default = {
|
|
4250
4250
|
method: "POST",
|
|
@@ -4293,15 +4293,15 @@ __export(reload_api_exports, {
|
|
|
4293
4293
|
function parseInflateErrors2(errors) {
|
|
4294
4294
|
return errors?.map((error2) => {
|
|
4295
4295
|
return {
|
|
4296
|
-
filePath: (0,
|
|
4296
|
+
filePath: (0, import_node_path25.relative)(BASE_PATH, error2.filePath),
|
|
4297
4297
|
error: error2.error.message
|
|
4298
4298
|
};
|
|
4299
4299
|
});
|
|
4300
4300
|
}
|
|
4301
|
-
var
|
|
4301
|
+
var import_node_path25, reload_api_default;
|
|
4302
4302
|
var init_reload_api = __esm({
|
|
4303
4303
|
"editor/http/admin/editor/api/server/reload.api.ts"() {
|
|
4304
|
-
|
|
4304
|
+
import_node_path25 = require("node:path");
|
|
4305
4305
|
init_constants_server();
|
|
4306
4306
|
reload_api_default = {
|
|
4307
4307
|
method: "POST",
|
|
@@ -4433,7 +4433,7 @@ function newParseOptionsError(baseOption, option, name) {
|
|
|
4433
4433
|
return new ParseOptionsError(option.usage ? String(option.usage) : `${name ? `${name} ` : ""}not ${baseOption.type}${option.type === "number" && option.numberMin !== void 0 ? `${option.numberMin}:` : ""}${option.type === "number" && option.numberMax !== void 0 ? `:${option.numberMax}` : ""}${option.numberMinDecimals !== void 0 ? ` min decimals[${option.numberMinDecimals}]` : ""}${option.numberMaxDecimals !== void 0 ? ` max decimals[${option.numberMaxDecimals}]` : ""}${option.type === "string" && option.stringMinLength !== void 0 ? `${option.stringMinLength}:` : ""}${option.type === "string" && option.stringMaxLength !== void 0 ? `:${option.stringMaxLength}` : ""}${option.type === "array" && option.arrayMinLength !== void 0 ? `${option.arrayMinLength}:` : ""}${option.type === "array" && option.arrayMaxLength !== void 0 ? `:${option.arrayMaxLength}` : ""}${option.type === "array" && option.arrayType ? option.arrayType !== "enum" ? ` of ${option.arrayType}` : ` of ${option.arrayType} as defined. valid values [${option.enumValues}]` : ""}${option.type === "enum" ? ` as defined. valid values [${option.enumValues}]` : ""}`, name);
|
|
4434
4434
|
}
|
|
4435
4435
|
var parseAny = (value) => value;
|
|
4436
|
-
function parseArray(value, args,
|
|
4436
|
+
function parseArray(value, args, parser4) {
|
|
4437
4437
|
let parsedList = [];
|
|
4438
4438
|
if (!(value instanceof Array)) {
|
|
4439
4439
|
return;
|
|
@@ -4449,7 +4449,7 @@ function parseArray(value, args, parser3) {
|
|
|
4449
4449
|
} else {
|
|
4450
4450
|
for (let i = 0; i < value.length; i++) {
|
|
4451
4451
|
const v = value[i];
|
|
4452
|
-
const parsed =
|
|
4452
|
+
const parsed = parser4.parse(v, {
|
|
4453
4453
|
...args,
|
|
4454
4454
|
parseJSON: false,
|
|
4455
4455
|
forceArray: false,
|
|
@@ -4467,7 +4467,7 @@ function parseArray(value, args, parser3) {
|
|
|
4467
4467
|
function parseBoolean(value) {
|
|
4468
4468
|
return value === "true" || value === true ? true : value === "false" || value === false ? false : void 0;
|
|
4469
4469
|
}
|
|
4470
|
-
function parseDict(value, args,
|
|
4470
|
+
function parseDict(value, args, parser4) {
|
|
4471
4471
|
const isObject = typeof value === "object";
|
|
4472
4472
|
if (!isObject || !value) {
|
|
4473
4473
|
return;
|
|
@@ -4476,7 +4476,7 @@ function parseDict(value, args, parser3) {
|
|
|
4476
4476
|
const keys = Object.keys(value);
|
|
4477
4477
|
const parsed = {};
|
|
4478
4478
|
for (const key of keys) {
|
|
4479
|
-
parsed[key] =
|
|
4479
|
+
parsed[key] = parser4.parse(value[key], {
|
|
4480
4480
|
...args,
|
|
4481
4481
|
type: args.dictType
|
|
4482
4482
|
}, `${args.name ? `${args.name}.` : ""}${key}`);
|
|
@@ -4494,14 +4494,14 @@ function parseEmail(value, args) {
|
|
|
4494
4494
|
}
|
|
4495
4495
|
return value;
|
|
4496
4496
|
}
|
|
4497
|
-
function parseEnum(value, args,
|
|
4497
|
+
function parseEnum(value, args, parser4) {
|
|
4498
4498
|
const enumValues = parseArray(args.enumValues, {
|
|
4499
4499
|
name: args.name,
|
|
4500
4500
|
mode: args.mode,
|
|
4501
4501
|
forceArray: false,
|
|
4502
4502
|
type: "array",
|
|
4503
4503
|
arrayType: "string"
|
|
4504
|
-
},
|
|
4504
|
+
}, parser4);
|
|
4505
4505
|
if (enumValues === void 0) {
|
|
4506
4506
|
throw new ParseOptionsError(`options.enumValues not a string array`);
|
|
4507
4507
|
}
|
|
@@ -4541,8 +4541,8 @@ function parseDecodeHTML(value, args) {
|
|
|
4541
4541
|
return decodeHTML(str);
|
|
4542
4542
|
}
|
|
4543
4543
|
}
|
|
4544
|
-
function parseInteger(value, args,
|
|
4545
|
-
return
|
|
4544
|
+
function parseInteger(value, args, parser4) {
|
|
4545
|
+
return parser4.parse(value, {
|
|
4546
4546
|
...args,
|
|
4547
4547
|
type: "number",
|
|
4548
4548
|
numberMinDecimals: 0,
|
|
@@ -4573,7 +4573,7 @@ function parseNumber(value, args) {
|
|
|
4573
4573
|
}
|
|
4574
4574
|
return parsedValue;
|
|
4575
4575
|
}
|
|
4576
|
-
function parseObject(value, args,
|
|
4576
|
+
function parseObject(value, args, parser4) {
|
|
4577
4577
|
const isObject = typeof value === "object" ? value : void 0;
|
|
4578
4578
|
if (!isObject || !value) {
|
|
4579
4579
|
return;
|
|
@@ -4585,7 +4585,7 @@ function parseObject(value, args, parser3) {
|
|
|
4585
4585
|
const valueLeftOverProperties = new Set(Object.keys(value));
|
|
4586
4586
|
for (const property of propertyNames) {
|
|
4587
4587
|
const p = args.properties[property];
|
|
4588
|
-
const v =
|
|
4588
|
+
const v = parser4.parse(value[property], p, `${args.name ? `${args.name}.` : ""}${property}`);
|
|
4589
4589
|
if (v !== void 0) {
|
|
4590
4590
|
parsed[property] = v;
|
|
4591
4591
|
}
|
|
@@ -4677,8 +4677,8 @@ var SchemaSchema = {
|
|
|
4677
4677
|
enumValues: "string[]?"
|
|
4678
4678
|
}
|
|
4679
4679
|
};
|
|
4680
|
-
function SchemaParser(value, args,
|
|
4681
|
-
return
|
|
4680
|
+
function SchemaParser(value, args, parser4) {
|
|
4681
|
+
return parser4.parse(value, {
|
|
4682
4682
|
...args,
|
|
4683
4683
|
...SchemaSchema
|
|
4684
4684
|
}, args.name);
|
|
@@ -4699,8 +4699,8 @@ function parseString(value, args) {
|
|
|
4699
4699
|
return value;
|
|
4700
4700
|
}
|
|
4701
4701
|
}
|
|
4702
|
-
function parseString1(value, args,
|
|
4703
|
-
return
|
|
4702
|
+
function parseString1(value, args, parser4) {
|
|
4703
|
+
return parser4.parse(value, {
|
|
4704
4704
|
...args,
|
|
4705
4705
|
type: "string",
|
|
4706
4706
|
stringMinLength: 1
|
|
@@ -4733,8 +4733,8 @@ function parseURL(value, args) {
|
|
|
4733
4733
|
}
|
|
4734
4734
|
}
|
|
4735
4735
|
}
|
|
4736
|
-
function runParser(p,
|
|
4737
|
-
if (
|
|
4736
|
+
function runParser(p, parser4, value, args) {
|
|
4737
|
+
if (parser4 === void 0) {
|
|
4738
4738
|
throw new ParseOptionsError(`unsupported type ${args.type}`);
|
|
4739
4739
|
}
|
|
4740
4740
|
if (value === void 0 && (args.required === true || args.required === void 0)) {
|
|
@@ -4762,17 +4762,17 @@ function runParser(p, parser3, value, args) {
|
|
|
4762
4762
|
value = [value];
|
|
4763
4763
|
}
|
|
4764
4764
|
}
|
|
4765
|
-
if (typeof
|
|
4766
|
-
return
|
|
4767
|
-
} else if (typeof
|
|
4765
|
+
if (typeof parser4 === "function") {
|
|
4766
|
+
return parser4(value, args, p);
|
|
4767
|
+
} else if (typeof parser4 === "object") {
|
|
4768
4768
|
return p.parse(value, {
|
|
4769
4769
|
...args,
|
|
4770
|
-
...
|
|
4770
|
+
...parser4
|
|
4771
4771
|
}, args.name);
|
|
4772
4772
|
} else {
|
|
4773
4773
|
return p.parse(value, {
|
|
4774
4774
|
...args,
|
|
4775
|
-
type:
|
|
4775
|
+
type: parser4
|
|
4776
4776
|
}, args.name);
|
|
4777
4777
|
}
|
|
4778
4778
|
}
|
|
@@ -4817,11 +4817,11 @@ var Parser = class {
|
|
|
4817
4817
|
this.register("decodeHTML", parseDecodeHTML, void 0, true, true);
|
|
4818
4818
|
this.register("schema", SchemaParser, ["Schema"]);
|
|
4819
4819
|
}
|
|
4820
|
-
register(type,
|
|
4820
|
+
register(type, parser4, aliases, noList = false, noDict = false) {
|
|
4821
4821
|
if (typeof type !== "string") {
|
|
4822
4822
|
throw new Error("type must be a string");
|
|
4823
4823
|
}
|
|
4824
|
-
if (typeof
|
|
4824
|
+
if (typeof parser4 !== "function" && typeof parser4 !== "object" && typeof parser4 !== "string") {
|
|
4825
4825
|
throw new Error("parser must be a function or Schema or a string");
|
|
4826
4826
|
}
|
|
4827
4827
|
if (typeof noList !== "boolean") {
|
|
@@ -4835,7 +4835,7 @@ var Parser = class {
|
|
|
4835
4835
|
if (this.parsers.has(type)) {
|
|
4836
4836
|
throw new Error(`already registered type [${type}]!`);
|
|
4837
4837
|
}
|
|
4838
|
-
this.parsers.set(type,
|
|
4838
|
+
this.parsers.set(type, parser4);
|
|
4839
4839
|
if (!noList) {
|
|
4840
4840
|
this.register(`${type}[]`, {
|
|
4841
4841
|
type: "array",
|
|
@@ -5000,7 +5000,7 @@ function ReadBuffer(options) {
|
|
|
5000
5000
|
timeout = parseInt(timeoutS, 10);
|
|
5001
5001
|
}
|
|
5002
5002
|
return async function ReadBuffer2(req, res) {
|
|
5003
|
-
return new Promise((
|
|
5003
|
+
return new Promise((resolve24, reject) => {
|
|
5004
5004
|
try {
|
|
5005
5005
|
const readTimeout = setTimeout(() => {
|
|
5006
5006
|
clearTimeout(readTimeout);
|
|
@@ -5022,7 +5022,7 @@ function ReadBuffer(options) {
|
|
|
5022
5022
|
const responseBuffer = req.headers["content-encoding"] === "gzip" ? (0, import_zlib.gunzipSync)(concatBuffers) : concatBuffers;
|
|
5023
5023
|
req.logger.trace("ctx.buffer %o", responseBuffer);
|
|
5024
5024
|
req.buffer = responseBuffer;
|
|
5025
|
-
|
|
5025
|
+
resolve24();
|
|
5026
5026
|
} catch (e) {
|
|
5027
5027
|
reject(e);
|
|
5028
5028
|
}
|
|
@@ -5206,7 +5206,7 @@ function normalizeParseOptions(option) {
|
|
|
5206
5206
|
properties: option !== void 0 && typeof option !== "string" && typeof option !== "boolean" ? option instanceof Array ? option : [option] : typeof option === "boolean" ? option ? ADD_EXTRA : NO_OPTIONS : typeof option === "string" ? [option] : ADD_EXTRA
|
|
5207
5207
|
};
|
|
5208
5208
|
}
|
|
5209
|
-
function parseRequestPart(part, req, option, mode,
|
|
5209
|
+
function parseRequestPart(part, req, option, mode, parser4) {
|
|
5210
5210
|
if (part === "headers" && mode === void 0) {
|
|
5211
5211
|
mode = "add_extra";
|
|
5212
5212
|
}
|
|
@@ -5214,7 +5214,7 @@ function parseRequestPart(part, req, option, mode, parser3) {
|
|
|
5214
5214
|
for (let i = 0; i < option.length; i++) {
|
|
5215
5215
|
const o = option[i];
|
|
5216
5216
|
try {
|
|
5217
|
-
req[part] = (
|
|
5217
|
+
req[part] = (parser4 ? parser4 : DEFAULT_PARSER).parse(value, typeof o === "string" ? o : {
|
|
5218
5218
|
type: "object",
|
|
5219
5219
|
properties: o,
|
|
5220
5220
|
mode
|
|
@@ -5228,7 +5228,7 @@ function parseRequestPart(part, req, option, mode, parser3) {
|
|
|
5228
5228
|
}
|
|
5229
5229
|
}
|
|
5230
5230
|
}
|
|
5231
|
-
function ParseRequest(options,
|
|
5231
|
+
function ParseRequest(options, parser4) {
|
|
5232
5232
|
const query = normalizeParseOptions(options.query);
|
|
5233
5233
|
const params = normalizeParseOptions(options.params);
|
|
5234
5234
|
const body = normalizeParseOptions(options.body);
|
|
@@ -5237,7 +5237,7 @@ function ParseRequest(options, parser3) {
|
|
|
5237
5237
|
try {
|
|
5238
5238
|
try {
|
|
5239
5239
|
if (options.headers !== void 0) {
|
|
5240
|
-
parseRequestPart("headers", req, headers.properties, options.headersMode ? options.headersMode : headers.mode,
|
|
5240
|
+
parseRequestPart("headers", req, headers.properties, options.headersMode ? options.headersMode : headers.mode, parser4);
|
|
5241
5241
|
}
|
|
5242
5242
|
} catch (e) {
|
|
5243
5243
|
req.logger.error("error parsing headers %o", req.headers);
|
|
@@ -5245,7 +5245,7 @@ function ParseRequest(options, parser3) {
|
|
|
5245
5245
|
}
|
|
5246
5246
|
try {
|
|
5247
5247
|
if (options.query !== void 0) {
|
|
5248
|
-
parseRequestPart("query", req, query.properties, options.queryMode ? options.queryMode : query.mode,
|
|
5248
|
+
parseRequestPart("query", req, query.properties, options.queryMode ? options.queryMode : query.mode, parser4);
|
|
5249
5249
|
}
|
|
5250
5250
|
} catch (e) {
|
|
5251
5251
|
req.logger.error("error parsing query %o", req.query);
|
|
@@ -5253,7 +5253,7 @@ function ParseRequest(options, parser3) {
|
|
|
5253
5253
|
}
|
|
5254
5254
|
try {
|
|
5255
5255
|
if (options.params !== void 0) {
|
|
5256
|
-
parseRequestPart("params", req, params.properties, options.paramsMode ? options.paramsMode : params.mode,
|
|
5256
|
+
parseRequestPart("params", req, params.properties, options.paramsMode ? options.paramsMode : params.mode, parser4);
|
|
5257
5257
|
}
|
|
5258
5258
|
} catch (e) {
|
|
5259
5259
|
req.logger.error("error parsing params %o", req.params);
|
|
@@ -5261,7 +5261,7 @@ function ParseRequest(options, parser3) {
|
|
|
5261
5261
|
}
|
|
5262
5262
|
try {
|
|
5263
5263
|
if (options.body !== void 0) {
|
|
5264
|
-
parseRequestPart("body", req, body.properties, options.bodyMode ? options.bodyMode : body.mode,
|
|
5264
|
+
parseRequestPart("body", req, body.properties, options.bodyMode ? options.bodyMode : body.mode, parser4);
|
|
5265
5265
|
}
|
|
5266
5266
|
} catch (e) {
|
|
5267
5267
|
req.logger.error("error parsing body %o", req.body);
|
|
@@ -5273,7 +5273,7 @@ function ParseRequest(options, parser3) {
|
|
|
5273
5273
|
}
|
|
5274
5274
|
};
|
|
5275
5275
|
}
|
|
5276
|
-
function ResultParser(options,
|
|
5276
|
+
function ResultParser(options, parser4) {
|
|
5277
5277
|
const bodyParser = options.body instanceof Array ? options.body : typeof options.body === "boolean" ? options.body === true ? ["any?"] : [] : typeof options.body === "string" ? [options.body] : options.body ? [options.body] : ["any?"];
|
|
5278
5278
|
const statusParserSet = options.status instanceof Array ? new Set(options.status) : options.status !== void 0 ? /* @__PURE__ */ new Set([options.status]) : null;
|
|
5279
5279
|
const headersParser = options.headers instanceof Array ? options.headers : typeof options.headers === "boolean" ? options.headers === true ? ["any?"] : [] : typeof options.headers === "string" ? [options.headers] : options.headers ? [options.headers] : ["any?"];
|
|
@@ -5289,7 +5289,7 @@ function ResultParser(options, parser3) {
|
|
|
5289
5289
|
const mappedLastResult = {
|
|
5290
5290
|
...lastResult
|
|
5291
5291
|
};
|
|
5292
|
-
const parsedStatus = (
|
|
5292
|
+
const parsedStatus = (parser4 ? parser4 : DEFAULT_PARSER).parse(lastResult.status, "number?", `ctx.results.status}`);
|
|
5293
5293
|
if (statusParserSet) {
|
|
5294
5294
|
if (parsedStatus === void 0) {
|
|
5295
5295
|
throw new Error(`error parsing lastResult.status[${lastResult.status}] not defined as [${statusParserSet}]`);
|
|
@@ -5305,8 +5305,8 @@ function ResultParser(options, parser3) {
|
|
|
5305
5305
|
mappedLastResult.status = parsedStatus;
|
|
5306
5306
|
req.logger.debug(`ctx.results.status mapped to %o`, mappedLastResult.status);
|
|
5307
5307
|
}
|
|
5308
|
-
mappedLastResult.body = parsePart(req, "body", lastResult.body, bodyParser, options.bodyMode,
|
|
5309
|
-
mappedLastResult.headers = parsePart(req, "headers", lastResult.headers, headersParser, options.headersMode,
|
|
5308
|
+
mappedLastResult.body = parsePart(req, "body", lastResult.body, bodyParser, options.bodyMode, parser4);
|
|
5309
|
+
mappedLastResult.headers = parsePart(req, "headers", lastResult.headers, headersParser, options.headersMode, parser4);
|
|
5310
5310
|
return mappedLastResult;
|
|
5311
5311
|
} catch (e) {
|
|
5312
5312
|
req.logger.error(`error parsing lastResult[%o]`, lastResult);
|
|
@@ -5342,11 +5342,11 @@ async function ResponseHandler(req, res) {
|
|
|
5342
5342
|
}
|
|
5343
5343
|
}
|
|
5344
5344
|
}
|
|
5345
|
-
function parsePart(req, part, value, args, mode,
|
|
5345
|
+
function parsePart(req, part, value, args, mode, parser4) {
|
|
5346
5346
|
for (let i = 0; i < args.length; i++) {
|
|
5347
5347
|
const o = args[i];
|
|
5348
5348
|
try {
|
|
5349
|
-
const mappedResultBody = (
|
|
5349
|
+
const mappedResultBody = (parser4 ? parser4 : DEFAULT_PARSER).parse(value, typeof o === "string" ? o : {
|
|
5350
5350
|
type: "object",
|
|
5351
5351
|
properties: o,
|
|
5352
5352
|
mode
|
|
@@ -5853,12 +5853,12 @@ var Response = class _Response extends import_http.ServerResponse {
|
|
|
5853
5853
|
});
|
|
5854
5854
|
}
|
|
5855
5855
|
async asyncWrite(chunk) {
|
|
5856
|
-
return new Promise((
|
|
5856
|
+
return new Promise((resolve24, reject) => {
|
|
5857
5857
|
this.write(chunk, function(error2) {
|
|
5858
5858
|
if (error2) {
|
|
5859
5859
|
reject(error2);
|
|
5860
5860
|
} else {
|
|
5861
|
-
|
|
5861
|
+
resolve24();
|
|
5862
5862
|
}
|
|
5863
5863
|
});
|
|
5864
5864
|
});
|
|
@@ -5867,7 +5867,7 @@ var Response = class _Response extends import_http.ServerResponse {
|
|
|
5867
5867
|
if (this.headersSent) {
|
|
5868
5868
|
return Promise.reject(new Error("already ended"));
|
|
5869
5869
|
}
|
|
5870
|
-
return new Promise((
|
|
5870
|
+
return new Promise((resolve24, reject) => {
|
|
5871
5871
|
try {
|
|
5872
5872
|
if (this.headersSent) {
|
|
5873
5873
|
reject(new Error("already ended"));
|
|
@@ -5896,7 +5896,7 @@ var Response = class _Response extends import_http.ServerResponse {
|
|
|
5896
5896
|
this.setHeader("connection", "close");
|
|
5897
5897
|
const nBody = body !== void 0 ? body instanceof Buffer ? body : String(body) : null;
|
|
5898
5898
|
this.end(nBody, () => {
|
|
5899
|
-
|
|
5899
|
+
resolve24();
|
|
5900
5900
|
});
|
|
5901
5901
|
}
|
|
5902
5902
|
} catch (e) {
|
|
@@ -6790,11 +6790,11 @@ var App = class extends Router {
|
|
|
6790
6790
|
return this.httpServer.listen(...args);
|
|
6791
6791
|
}
|
|
6792
6792
|
async listen(...args) {
|
|
6793
|
-
return new Promise((
|
|
6793
|
+
return new Promise((resolve24, reject) => {
|
|
6794
6794
|
try {
|
|
6795
6795
|
this.shouldCloseConnection = false;
|
|
6796
6796
|
this.httpServer.listen(...args, () => {
|
|
6797
|
-
|
|
6797
|
+
resolve24(this.httpServer);
|
|
6798
6798
|
});
|
|
6799
6799
|
} catch (e) {
|
|
6800
6800
|
reject(e);
|
|
@@ -6802,14 +6802,14 @@ var App = class extends Router {
|
|
|
6802
6802
|
});
|
|
6803
6803
|
}
|
|
6804
6804
|
async close() {
|
|
6805
|
-
return new Promise((
|
|
6805
|
+
return new Promise((resolve24, reject) => {
|
|
6806
6806
|
try {
|
|
6807
6807
|
this.shouldCloseConnection = true;
|
|
6808
6808
|
this.httpServer.close((err) => {
|
|
6809
6809
|
if (err) {
|
|
6810
6810
|
reject(err);
|
|
6811
6811
|
} else {
|
|
6812
|
-
|
|
6812
|
+
resolve24(this.httpServer);
|
|
6813
6813
|
}
|
|
6814
6814
|
});
|
|
6815
6815
|
const keys = Object.keys(this.connections);
|
|
@@ -6853,10 +6853,10 @@ var WebSocketServer = class {
|
|
|
6853
6853
|
const clients = this.clients.values();
|
|
6854
6854
|
for (const client of clients) {
|
|
6855
6855
|
if (fromUUID === void 0 || client.uuid !== fromUUID) {
|
|
6856
|
-
tR.push(new Promise(async (
|
|
6856
|
+
tR.push(new Promise(async (resolve24, reject) => {
|
|
6857
6857
|
try {
|
|
6858
6858
|
await this.writeTo(client.uuid, data);
|
|
6859
|
-
|
|
6859
|
+
resolve24();
|
|
6860
6860
|
} catch (e) {
|
|
6861
6861
|
reject(e);
|
|
6862
6862
|
}
|
|
@@ -6870,7 +6870,7 @@ var WebSocketServer = class {
|
|
|
6870
6870
|
if (!client) {
|
|
6871
6871
|
throw new Error("client not found");
|
|
6872
6872
|
}
|
|
6873
|
-
return new Promise((
|
|
6873
|
+
return new Promise((resolve24, reject) => {
|
|
6874
6874
|
try {
|
|
6875
6875
|
client.req.socket.write(createFrame(data), (err) => {
|
|
6876
6876
|
if (err) {
|
|
@@ -6882,7 +6882,7 @@ var WebSocketServer = class {
|
|
|
6882
6882
|
this.clients.delete(clientUUID);
|
|
6883
6883
|
reject(err);
|
|
6884
6884
|
} else {
|
|
6885
|
-
|
|
6885
|
+
resolve24();
|
|
6886
6886
|
}
|
|
6887
6887
|
});
|
|
6888
6888
|
} catch (e) {
|
|
@@ -7145,12 +7145,12 @@ function sqlite3ExecutorPrepare(args) {
|
|
|
7145
7145
|
const columnsSQL = isSelect ? `SELECT ${renderNameAS(q._columns)}` : "SELECT count(*) as count";
|
|
7146
7146
|
const whereSQL = where.sql !== "" ? ` WHERE ${where.sql}` : "";
|
|
7147
7147
|
const fromSQL = ` FROM ${renderNameAS(q._selectFrom)}`;
|
|
7148
|
-
const
|
|
7149
|
-
const joinValues =
|
|
7148
|
+
const join14 = q._joins.map((j) => getJoin(j));
|
|
7149
|
+
const joinValues = join14.reduce(function(ret, current) {
|
|
7150
7150
|
ret = ret.concat(current.values);
|
|
7151
7151
|
return ret;
|
|
7152
7152
|
}, []);
|
|
7153
|
-
const joinSQL =
|
|
7153
|
+
const joinSQL = join14.map((j) => j.sql).join(" ");
|
|
7154
7154
|
const sql = `${columnsSQL}${fromSQL}${joinSQL}${whereSQL}${getGroupBy(q._groupBy)}${getOrderBy(q._orderBy)}${getLimit(q._limitBy, q._offsetBy)}`;
|
|
7155
7155
|
return [{
|
|
7156
7156
|
sql,
|
|
@@ -7179,10 +7179,10 @@ function sqlite3ExecutorPrepare(args) {
|
|
|
7179
7179
|
throw new Error(`unsupported ${args}`);
|
|
7180
7180
|
}
|
|
7181
7181
|
}
|
|
7182
|
-
function getJoin(
|
|
7183
|
-
const wherePrepare = getWhereStatement(
|
|
7182
|
+
function getJoin(join14) {
|
|
7183
|
+
const wherePrepare = getWhereStatement(join14._on);
|
|
7184
7184
|
return {
|
|
7185
|
-
sql: ` ${
|
|
7185
|
+
sql: ` ${join14._verb ? `${join14._verb} ` : ""}JOIN ${renderNameAS(join14._table)} ON ${wherePrepare.sql}`,
|
|
7186
7186
|
values: wherePrepare.values
|
|
7187
7187
|
};
|
|
7188
7188
|
}
|
|
@@ -7366,9 +7366,9 @@ function getInsertValues(columns, values) {
|
|
|
7366
7366
|
values: args
|
|
7367
7367
|
};
|
|
7368
7368
|
}
|
|
7369
|
-
function renderNameAS(input,
|
|
7369
|
+
function renderNameAS(input, join14 = ", ") {
|
|
7370
7370
|
const list = input instanceof Array ? input : [input];
|
|
7371
|
-
return list.map((i) => typeof i === "string" ? i : `${i.name} AS ${i.as}`).join(
|
|
7371
|
+
return list.map((i) => typeof i === "string" ? i : `${i.name} AS ${i.as}`).join(join14);
|
|
7372
7372
|
}
|
|
7373
7373
|
function getGroupBy(groupBy) {
|
|
7374
7374
|
return groupBy.length > 0 ? ` GROUP BY ${groupBy.join(",")}` : "";
|
|
@@ -7470,7 +7470,7 @@ async function sqlite3Executor(config) {
|
|
|
7470
7470
|
},
|
|
7471
7471
|
prepare: sqlite3ExecutorPrepare,
|
|
7472
7472
|
query: async function sqlite3Executor2(sql, values) {
|
|
7473
|
-
return new Promise((
|
|
7473
|
+
return new Promise((resolve24, reject) => {
|
|
7474
7474
|
const st = driver.prepare(sql, values, function(error2) {
|
|
7475
7475
|
if (error2) {
|
|
7476
7476
|
reject(error2);
|
|
@@ -7483,7 +7483,7 @@ async function sqlite3Executor(config) {
|
|
|
7483
7483
|
if (error4) {
|
|
7484
7484
|
reject(error4);
|
|
7485
7485
|
} else {
|
|
7486
|
-
|
|
7486
|
+
resolve24(rows);
|
|
7487
7487
|
}
|
|
7488
7488
|
});
|
|
7489
7489
|
}
|
|
@@ -8227,7 +8227,7 @@ async function sqlite3CLIExecutor(config) {
|
|
|
8227
8227
|
disconnect: async function sqlite3ExecutorDisconnect() {
|
|
8228
8228
|
},
|
|
8229
8229
|
query: async function sqlite3Executor2(sql, values) {
|
|
8230
|
-
return new Promise((
|
|
8230
|
+
return new Promise((resolve24, reject) => {
|
|
8231
8231
|
try {
|
|
8232
8232
|
let i = 0;
|
|
8233
8233
|
const raw = sql.replaceAll("?", (sub) => {
|
|
@@ -8254,9 +8254,9 @@ async function sqlite3CLIExecutor(config) {
|
|
|
8254
8254
|
reject(new Error(stderr));
|
|
8255
8255
|
} else {
|
|
8256
8256
|
if (stdout) {
|
|
8257
|
-
|
|
8257
|
+
resolve24(JSON.parse(stdout));
|
|
8258
8258
|
} else {
|
|
8259
|
-
|
|
8259
|
+
resolve24([]);
|
|
8260
8260
|
}
|
|
8261
8261
|
}
|
|
8262
8262
|
}
|
|
@@ -8294,7 +8294,7 @@ async function nativeSqlite(config) {
|
|
|
8294
8294
|
return driver.close();
|
|
8295
8295
|
},
|
|
8296
8296
|
query: async function sqlite3Executor2(sql, values) {
|
|
8297
|
-
return new Promise((
|
|
8297
|
+
return new Promise((resolve24, reject) => {
|
|
8298
8298
|
try {
|
|
8299
8299
|
if (values) {
|
|
8300
8300
|
for (let i = 0; i < values.length; i++) {
|
|
@@ -8314,10 +8314,10 @@ async function nativeSqlite(config) {
|
|
|
8314
8314
|
stmt.setReadBigInts(true);
|
|
8315
8315
|
if (values && values.length > 0) {
|
|
8316
8316
|
const ret = stmt.all(...values);
|
|
8317
|
-
|
|
8317
|
+
resolve24(ret);
|
|
8318
8318
|
} else {
|
|
8319
8319
|
const ret = stmt.all();
|
|
8320
|
-
|
|
8320
|
+
resolve24(ret);
|
|
8321
8321
|
}
|
|
8322
8322
|
} catch (e) {
|
|
8323
8323
|
reject(e);
|
|
@@ -9239,7 +9239,8 @@ var LogProvider = class {
|
|
|
9239
9239
|
constructor(options) {
|
|
9240
9240
|
this.options = {
|
|
9241
9241
|
formatter: options && options.formatter ? options.formatter : DEFAULT_FORMATTER,
|
|
9242
|
-
transports: options && options.transports ? options.transports : [ConsoleTransport()]
|
|
9242
|
+
transports: options && options.transports ? options.transports : [ConsoleTransport()],
|
|
9243
|
+
name: options?.name
|
|
9243
9244
|
};
|
|
9244
9245
|
this.requestLoggerFactory = this.requestLoggerFactory.bind(this);
|
|
9245
9246
|
}
|
|
@@ -9303,8 +9304,8 @@ var LogProvider = class {
|
|
|
9303
9304
|
var import_node_cluster3 = __toESM(require("node:cluster"), 1);
|
|
9304
9305
|
|
|
9305
9306
|
// src/inflate/setup-http.ts
|
|
9306
|
-
var
|
|
9307
|
-
var
|
|
9307
|
+
var import_node_fs11 = require("node:fs");
|
|
9308
|
+
var import_node_path12 = require("node:path");
|
|
9308
9309
|
|
|
9309
9310
|
// src/common/content-type.ts
|
|
9310
9311
|
var DEFAULT_CONTENT_TYPE = "application/octet-stream";
|
|
@@ -11212,7 +11213,7 @@ async function calculateChecksum(filePath) {
|
|
|
11212
11213
|
return calculateChecksumFromStream((0, import_node_fs2.createReadStream)(filePath));
|
|
11213
11214
|
}
|
|
11214
11215
|
async function calculateChecksumFromStream(input) {
|
|
11215
|
-
return new Promise((
|
|
11216
|
+
return new Promise((resolve24, reject) => {
|
|
11216
11217
|
try {
|
|
11217
11218
|
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
11218
11219
|
input.on("readable", () => {
|
|
@@ -11220,7 +11221,7 @@ async function calculateChecksumFromStream(input) {
|
|
|
11220
11221
|
if (data)
|
|
11221
11222
|
hash.update(data);
|
|
11222
11223
|
else {
|
|
11223
|
-
|
|
11224
|
+
resolve24(hash.digest("hex").toString());
|
|
11224
11225
|
}
|
|
11225
11226
|
});
|
|
11226
11227
|
input.on("error", (e) => {
|
|
@@ -11232,11 +11233,11 @@ async function calculateChecksumFromStream(input) {
|
|
|
11232
11233
|
});
|
|
11233
11234
|
}
|
|
11234
11235
|
async function calculateChecksumFromBuffer(buffer) {
|
|
11235
|
-
return new Promise((
|
|
11236
|
+
return new Promise((resolve24, reject) => {
|
|
11236
11237
|
try {
|
|
11237
11238
|
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
11238
11239
|
hash.update(buffer);
|
|
11239
|
-
|
|
11240
|
+
resolve24(hash.digest("hex").toString());
|
|
11240
11241
|
} catch (e) {
|
|
11241
11242
|
reject(e);
|
|
11242
11243
|
}
|
|
@@ -11264,8 +11265,8 @@ var ASSETS_ROUTER = {
|
|
|
11264
11265
|
"jsx.dom.js": "build/jsx.dom.js",
|
|
11265
11266
|
"types.json": "sea/types.json",
|
|
11266
11267
|
"editor-assets/editor.bundle.js": "build/editor.bundle.js",
|
|
11267
|
-
"editor-assets/style.css": "
|
|
11268
|
-
"editor-assets/font.ttf": "
|
|
11268
|
+
"editor-assets/style.css": "build/style.css",
|
|
11269
|
+
"editor-assets/font.ttf": "build/font.ttf"
|
|
11269
11270
|
};
|
|
11270
11271
|
function getAsset(key) {
|
|
11271
11272
|
if ((0, import_node_sea.isSea)()) {
|
|
@@ -11417,12 +11418,42 @@ function getStaticFilesPath(servicePath) {
|
|
|
11417
11418
|
}
|
|
11418
11419
|
return false;
|
|
11419
11420
|
}
|
|
11421
|
+
function getMiddlewareConfigPath(servicePath) {
|
|
11422
|
+
const middlewarePath = (0, import_node_path3.resolve)(servicePath, "middleware.ts");
|
|
11423
|
+
const middlewarePathJS = (0, import_node_path3.resolve)(servicePath, "middleware.js");
|
|
11424
|
+
if ((0, import_node_fs4.existsSync)(middlewarePath) && !(0, import_node_fs4.statSync)(middlewarePath).isDirectory()) {
|
|
11425
|
+
return middlewarePath;
|
|
11426
|
+
} else if ((0, import_node_fs4.existsSync)(middlewarePathJS) && !(0, import_node_fs4.statSync)(middlewarePathJS).isDirectory()) {
|
|
11427
|
+
return middlewarePathJS;
|
|
11428
|
+
}
|
|
11429
|
+
return false;
|
|
11430
|
+
}
|
|
11431
|
+
function getErrorConfigPath(servicePath) {
|
|
11432
|
+
const errorPath = (0, import_node_path3.resolve)(servicePath, "catch.ts");
|
|
11433
|
+
const errorPathJS = (0, import_node_path3.resolve)(servicePath, "catch.js");
|
|
11434
|
+
if ((0, import_node_fs4.existsSync)(errorPath) && !(0, import_node_fs4.statSync)(errorPath).isDirectory()) {
|
|
11435
|
+
return errorPath;
|
|
11436
|
+
} else if ((0, import_node_fs4.existsSync)(errorPathJS) && !(0, import_node_fs4.statSync)(errorPathJS).isDirectory()) {
|
|
11437
|
+
return errorPathJS;
|
|
11438
|
+
}
|
|
11439
|
+
return false;
|
|
11440
|
+
}
|
|
11441
|
+
function getDocConfigPath(servicePath) {
|
|
11442
|
+
const docPath = (0, import_node_path3.resolve)(servicePath, "doc.ts");
|
|
11443
|
+
const docPathJS = (0, import_node_path3.resolve)(servicePath, "doc.js");
|
|
11444
|
+
if ((0, import_node_fs4.existsSync)(docPath) && !(0, import_node_fs4.statSync)(docPath).isDirectory()) {
|
|
11445
|
+
return docPath;
|
|
11446
|
+
} else if ((0, import_node_fs4.existsSync)(docPathJS) && !(0, import_node_fs4.statSync)(docPathJS).isDirectory()) {
|
|
11447
|
+
return docPathJS;
|
|
11448
|
+
}
|
|
11449
|
+
return false;
|
|
11450
|
+
}
|
|
11420
11451
|
function getAuthConfigPath(servicePath) {
|
|
11421
11452
|
const authPath = (0, import_node_path3.resolve)(servicePath, "auth.ts");
|
|
11422
11453
|
const authPathJS = (0, import_node_path3.resolve)(servicePath, "auth.js");
|
|
11423
11454
|
if ((0, import_node_fs4.existsSync)(authPath) && !(0, import_node_fs4.statSync)(authPath).isDirectory()) {
|
|
11424
11455
|
return authPath;
|
|
11425
|
-
} else if ((0, import_node_fs4.existsSync)(
|
|
11456
|
+
} else if ((0, import_node_fs4.existsSync)(authPathJS) && !(0, import_node_fs4.statSync)(authPathJS).isDirectory()) {
|
|
11426
11457
|
return authPathJS;
|
|
11427
11458
|
}
|
|
11428
11459
|
return false;
|
|
@@ -11492,7 +11523,7 @@ var NODEJS_EXTERNAL = [
|
|
|
11492
11523
|
"pg"
|
|
11493
11524
|
];
|
|
11494
11525
|
async function esBuild(options, logger) {
|
|
11495
|
-
return new Promise(async (
|
|
11526
|
+
return new Promise(async (resolve24, reject) => {
|
|
11496
11527
|
try {
|
|
11497
11528
|
const valid = await validateESBuild(logger);
|
|
11498
11529
|
const esBuildCMD = `${getESBuildBinaryPath()} "${options.entryPoints[0]}" ${NODEJS_EXTERNAL.map((e) => `--external:${e}`).join(" ")} --loader:.js=jsx --jsx-factory=${options.jsxFactory} --jsx-fragment=${options.jsxFragment} ${options.bundle ? " --bundle" : ""}${options.minify ? " --minify" : ""}${options.outfile ? ` --outfile="${options.outfile}"` : ""}${options.platform ? ` --platform=${options.platform}` : ""}`;
|
|
@@ -11508,7 +11539,7 @@ async function esBuild(options, logger) {
|
|
|
11508
11539
|
if (err) {
|
|
11509
11540
|
reject(err);
|
|
11510
11541
|
} else {
|
|
11511
|
-
|
|
11542
|
+
resolve24({
|
|
11512
11543
|
outputFiles: [{
|
|
11513
11544
|
path: "",
|
|
11514
11545
|
contents: stdout
|
|
@@ -11532,10 +11563,8 @@ var showdown = __toESM(require_showdown(), 1);
|
|
|
11532
11563
|
var import_node_fs5 = require("node:fs");
|
|
11533
11564
|
function inflateMD2HTML(inFile, logger) {
|
|
11534
11565
|
try {
|
|
11535
|
-
const converter = new showdown.default.Converter();
|
|
11536
|
-
converter.setFlavor("github");
|
|
11537
11566
|
const text = (0, import_node_fs5.readFileSync)(inFile).toString();
|
|
11538
|
-
const html =
|
|
11567
|
+
const html = inflateMDString2HTML(text);
|
|
11539
11568
|
return html;
|
|
11540
11569
|
} catch (e) {
|
|
11541
11570
|
logger?.error("error with: " + inFile);
|
|
@@ -11543,6 +11572,12 @@ function inflateMD2HTML(inFile, logger) {
|
|
|
11543
11572
|
throw e;
|
|
11544
11573
|
}
|
|
11545
11574
|
}
|
|
11575
|
+
function inflateMDString2HTML(text, logger) {
|
|
11576
|
+
const converter = new showdown.default.Converter();
|
|
11577
|
+
converter.setFlavor("github");
|
|
11578
|
+
const html = converter.makeHtml(text);
|
|
11579
|
+
return html;
|
|
11580
|
+
}
|
|
11546
11581
|
|
|
11547
11582
|
// src/common/constants.ts
|
|
11548
11583
|
var EXIT_CODES = {
|
|
@@ -11553,8 +11588,9 @@ var EXIT_CODES = {
|
|
|
11553
11588
|
ABNORMAL_UNCONTROLLED: 99,
|
|
11554
11589
|
TEST_FAILED: 30
|
|
11555
11590
|
};
|
|
11556
|
-
var CLEAR_JSX_CACHE =
|
|
11591
|
+
var CLEAR_JSX_CACHE = (process.env["CLEAR_JSX_CACHE"] !== void 0 ? process.env["CLEAR_JSX_CACHE"] : "1") === "1";
|
|
11557
11592
|
var EDITOR_CONFIG_KEY = "$$editor$$";
|
|
11593
|
+
var HOT_RELOAD_PATH = "/hot-reload";
|
|
11558
11594
|
|
|
11559
11595
|
// src/services/globals.ts
|
|
11560
11596
|
var globalJSX = Object.freeze({
|
|
@@ -11830,6 +11866,53 @@ var AuthConfigSchema = {
|
|
|
11830
11866
|
}
|
|
11831
11867
|
//mode:"add_extra"
|
|
11832
11868
|
};
|
|
11869
|
+
var MiddlewareConfigSchema = {
|
|
11870
|
+
type: "object",
|
|
11871
|
+
properties: {
|
|
11872
|
+
middleware: {
|
|
11873
|
+
type: "Array",
|
|
11874
|
+
arrayType: "function|object",
|
|
11875
|
+
required: false,
|
|
11876
|
+
properties: {
|
|
11877
|
+
...HandlerWithOptionsSchema.properties
|
|
11878
|
+
}
|
|
11879
|
+
},
|
|
11880
|
+
post: {
|
|
11881
|
+
type: "Array",
|
|
11882
|
+
arrayType: "function|object",
|
|
11883
|
+
required: false,
|
|
11884
|
+
properties: {
|
|
11885
|
+
...HandlerWithOptionsSchema.properties
|
|
11886
|
+
}
|
|
11887
|
+
}
|
|
11888
|
+
}
|
|
11889
|
+
};
|
|
11890
|
+
var ErrorConfigSchema = {
|
|
11891
|
+
type: "object",
|
|
11892
|
+
properties: {
|
|
11893
|
+
catch: {
|
|
11894
|
+
type: "Array",
|
|
11895
|
+
required: false,
|
|
11896
|
+
arrayType: "function"
|
|
11897
|
+
}
|
|
11898
|
+
}
|
|
11899
|
+
};
|
|
11900
|
+
var DocConfigSchema = {
|
|
11901
|
+
type: "object",
|
|
11902
|
+
properties: {
|
|
11903
|
+
publish: {
|
|
11904
|
+
type: "dict?",
|
|
11905
|
+
dictType: "object",
|
|
11906
|
+
properties: {
|
|
11907
|
+
type: {
|
|
11908
|
+
type: "enum?",
|
|
11909
|
+
enumValues: ["HTML", "MD", "JSON"]
|
|
11910
|
+
},
|
|
11911
|
+
all: "boolean?"
|
|
11912
|
+
}
|
|
11913
|
+
}
|
|
11914
|
+
}
|
|
11915
|
+
};
|
|
11833
11916
|
async function importAPIRoute(inFile, logger) {
|
|
11834
11917
|
const mod = (await importJSXFile(inFile, logger)).default;
|
|
11835
11918
|
const module2 = typeof mod === "function" ? { handler: mod } : parser2.parse(mod, APIRouteSchema, (0, import_node_path5.basename)(inFile));
|
|
@@ -11875,6 +11958,30 @@ async function importAuthModule(inFile, logger) {
|
|
|
11875
11958
|
throw new Error(`error with module [${inFile}] undefined`);
|
|
11876
11959
|
}
|
|
11877
11960
|
}
|
|
11961
|
+
async function importMiddlewareConfigModule(inFile, logger) {
|
|
11962
|
+
const module2 = parser2.parse((await importJSXFile(inFile, logger)).default, MiddlewareConfigSchema, (0, import_node_path5.basename)(inFile));
|
|
11963
|
+
if (module2 !== void 0) {
|
|
11964
|
+
return module2;
|
|
11965
|
+
} else {
|
|
11966
|
+
throw new Error(`error with module [${inFile}] undefined`);
|
|
11967
|
+
}
|
|
11968
|
+
}
|
|
11969
|
+
async function importErrorConfigModule(inFile, logger) {
|
|
11970
|
+
const module2 = parser2.parse((await importJSXFile(inFile, logger)).default, ErrorConfigSchema, (0, import_node_path5.basename)(inFile));
|
|
11971
|
+
if (module2 !== void 0) {
|
|
11972
|
+
return module2;
|
|
11973
|
+
} else {
|
|
11974
|
+
throw new Error(`error with module [${inFile}] undefined`);
|
|
11975
|
+
}
|
|
11976
|
+
}
|
|
11977
|
+
async function importDocConfigModule(inFile, logger) {
|
|
11978
|
+
const module2 = parser2.parse((await importJSXFile(inFile, logger)).default, DocConfigSchema, (0, import_node_path5.basename)(inFile));
|
|
11979
|
+
if (module2 !== void 0) {
|
|
11980
|
+
return module2;
|
|
11981
|
+
} else {
|
|
11982
|
+
throw new Error(`error with module [${inFile}] undefined`);
|
|
11983
|
+
}
|
|
11984
|
+
}
|
|
11878
11985
|
async function importCORSModule(inFile, logger) {
|
|
11879
11986
|
const module2 = parser2.parse((await importJSXFile(inFile, logger)).default, CORSOptionsSchema, (0, import_node_path5.basename)(inFile));
|
|
11880
11987
|
if (module2 !== void 0) {
|
|
@@ -11982,7 +12089,7 @@ function getHotReloadScript() {
|
|
|
11982
12089
|
// Create WebSocket connection.
|
|
11983
12090
|
|
|
11984
12091
|
function getSocket() {
|
|
11985
|
-
return new WebSocket("
|
|
12092
|
+
return new WebSocket("${HOT_RELOAD_PATH}");
|
|
11986
12093
|
}
|
|
11987
12094
|
|
|
11988
12095
|
const socket = getSocket();
|
|
@@ -12019,7 +12126,7 @@ socket.addEventListener("error", (err) => {
|
|
|
12019
12126
|
}
|
|
12020
12127
|
|
|
12021
12128
|
// src/inflate/setup-http.ts
|
|
12022
|
-
var
|
|
12129
|
+
var import_node_process8 = require("node:process");
|
|
12023
12130
|
|
|
12024
12131
|
// src/inflate/setup-cors.ts
|
|
12025
12132
|
var import_node_fs7 = require("node:fs");
|
|
@@ -12166,13 +12273,96 @@ function describeFilePath(filePath) {
|
|
|
12166
12273
|
};
|
|
12167
12274
|
}
|
|
12168
12275
|
|
|
12276
|
+
// src/inflate/setup-middleware.ts
|
|
12277
|
+
var import_node_path10 = require("node:path");
|
|
12278
|
+
var import_node_fs9 = require("node:fs");
|
|
12279
|
+
var import_node_process6 = require("node:process");
|
|
12280
|
+
async function setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
|
|
12281
|
+
const middlewarePath = getMiddlewareConfigPath(servicePath);
|
|
12282
|
+
if (middlewarePath) {
|
|
12283
|
+
try {
|
|
12284
|
+
const middewareModule = await importMiddlewareConfigModule(middlewarePath, logger);
|
|
12285
|
+
logger.debug("setting up middleware from [%s]", (0, import_node_path10.join)(service, (0, import_node_path10.basename)(middlewarePath)));
|
|
12286
|
+
if (middewareModule && middewareModule.middleware) {
|
|
12287
|
+
for (const m of middewareModule.middleware) {
|
|
12288
|
+
mainRouter.use(m);
|
|
12289
|
+
}
|
|
12290
|
+
}
|
|
12291
|
+
if (inflateDir && inflateSea) {
|
|
12292
|
+
const inflatePath = (0, import_node_path10.resolve)(inflateDir, service, "middleware.js");
|
|
12293
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(inflatePath), {
|
|
12294
|
+
recursive: true
|
|
12295
|
+
});
|
|
12296
|
+
logger.log("writing [%s]", (0, import_node_path10.relative)((0, import_node_process6.cwd)(), inflatePath));
|
|
12297
|
+
(0, import_node_fs9.writeFileSync)(inflatePath, await inflateJSX(middlewarePath, {
|
|
12298
|
+
embemedJSX: false,
|
|
12299
|
+
minify: false,
|
|
12300
|
+
useExport: true,
|
|
12301
|
+
logger
|
|
12302
|
+
}));
|
|
12303
|
+
}
|
|
12304
|
+
return middewareModule;
|
|
12305
|
+
} catch (e) {
|
|
12306
|
+
errors.push({
|
|
12307
|
+
filePath: middlewarePath,
|
|
12308
|
+
error: e
|
|
12309
|
+
});
|
|
12310
|
+
logger.error("error with " + middlewarePath);
|
|
12311
|
+
logger.error(e);
|
|
12312
|
+
}
|
|
12313
|
+
}
|
|
12314
|
+
return null;
|
|
12315
|
+
}
|
|
12316
|
+
|
|
12317
|
+
// src/inflate/setup-error.ts
|
|
12318
|
+
var import_node_path11 = require("node:path");
|
|
12319
|
+
var import_node_fs10 = require("node:fs");
|
|
12320
|
+
var import_node_process7 = require("node:process");
|
|
12321
|
+
async function setupError(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
|
|
12322
|
+
const errorPath = getErrorConfigPath(servicePath);
|
|
12323
|
+
if (errorPath) {
|
|
12324
|
+
try {
|
|
12325
|
+
const errorModule = await importErrorConfigModule(errorPath, logger);
|
|
12326
|
+
logger.debug("setting up error handling from [%s]", (0, import_node_path11.join)(service, (0, import_node_path11.basename)(errorPath)));
|
|
12327
|
+
if (errorModule && errorModule.catch) {
|
|
12328
|
+
for (const m of errorModule.catch) {
|
|
12329
|
+
mainRouter.catch(m);
|
|
12330
|
+
}
|
|
12331
|
+
}
|
|
12332
|
+
if (inflateDir && inflateSea) {
|
|
12333
|
+
const inflatePath = (0, import_node_path11.resolve)(inflateDir, service, "catch.js");
|
|
12334
|
+
(0, import_node_fs10.mkdirSync)((0, import_node_path11.dirname)(inflatePath), {
|
|
12335
|
+
recursive: true
|
|
12336
|
+
});
|
|
12337
|
+
logger.log("writing [%s]", (0, import_node_path11.relative)((0, import_node_process7.cwd)(), inflatePath));
|
|
12338
|
+
(0, import_node_fs10.writeFileSync)(inflatePath, await inflateJSX(errorPath, {
|
|
12339
|
+
embemedJSX: false,
|
|
12340
|
+
minify: false,
|
|
12341
|
+
useExport: true,
|
|
12342
|
+
logger
|
|
12343
|
+
}));
|
|
12344
|
+
}
|
|
12345
|
+
} catch (e) {
|
|
12346
|
+
errors.push({
|
|
12347
|
+
filePath: errorPath,
|
|
12348
|
+
error: e
|
|
12349
|
+
});
|
|
12350
|
+
logger.error("error with " + errorPath);
|
|
12351
|
+
logger.error(e);
|
|
12352
|
+
}
|
|
12353
|
+
}
|
|
12354
|
+
}
|
|
12355
|
+
|
|
12169
12356
|
// src/inflate/setup-http.ts
|
|
12170
12357
|
async function setupHTTPRouter(server2, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors) {
|
|
12171
12358
|
const mainRouter = new Router();
|
|
12172
12359
|
const apiRouterPath = getHTTPRouterPath(servicePath);
|
|
12360
|
+
let middlewareConfig = null;
|
|
12361
|
+
await setupError(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
12362
|
+
await setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
12363
|
+
await setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
12364
|
+
middlewareConfig = await setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
12173
12365
|
if (apiRouterPath) {
|
|
12174
|
-
await setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
12175
|
-
await setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
12176
12366
|
logger.trace("setting up http routes from [%s]", service);
|
|
12177
12367
|
const { router: httpRouter } = await createRouterFromDirectory(server2, hotreload, service, logger, apiRouterPath, errors, routeFileMap, staticFileMap, inflateDir, inflateSea);
|
|
12178
12368
|
mainRouter.use(httpRouter);
|
|
@@ -12183,6 +12373,11 @@ async function setupHTTPRouter(server2, logger, hotreload, servicePath, service,
|
|
|
12183
12373
|
const staticRouter = createStaticRouterFromDirectory(service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap);
|
|
12184
12374
|
mainRouter.use(staticRouter);
|
|
12185
12375
|
}
|
|
12376
|
+
if (middlewareConfig && middlewareConfig.post) {
|
|
12377
|
+
for (const m of middlewareConfig.post) {
|
|
12378
|
+
mainRouter.use(m);
|
|
12379
|
+
}
|
|
12380
|
+
}
|
|
12186
12381
|
return mainRouter;
|
|
12187
12382
|
}
|
|
12188
12383
|
function createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap) {
|
|
@@ -12192,7 +12387,7 @@ function createStaticRoute(service, logger, router, dir, file, inflateDir, route
|
|
|
12192
12387
|
dir
|
|
12193
12388
|
});
|
|
12194
12389
|
const contentType = CONTENT_TYPE_MAP[String(file.ext).toLocaleLowerCase()];
|
|
12195
|
-
const path = (0,
|
|
12390
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.relative)(dir, file.filePath));
|
|
12196
12391
|
routeFileMap[file.filePath] = {
|
|
12197
12392
|
routes: [{
|
|
12198
12393
|
method: "GET",
|
|
@@ -12202,13 +12397,13 @@ function createStaticRoute(service, logger, router, dir, file, inflateDir, route
|
|
|
12202
12397
|
previewMethod: "html"
|
|
12203
12398
|
};
|
|
12204
12399
|
if (inflateDir) {
|
|
12205
|
-
const inflatePath = (0,
|
|
12206
|
-
(0,
|
|
12400
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
12401
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12207
12402
|
recursive: true
|
|
12208
12403
|
});
|
|
12209
|
-
logger.log("writing [%s]", (0,
|
|
12210
|
-
const body = (0,
|
|
12211
|
-
(0,
|
|
12404
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12405
|
+
const body = (0, import_node_fs11.readFileSync)(file.filePath);
|
|
12406
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, body);
|
|
12212
12407
|
if (staticFileMap) {
|
|
12213
12408
|
staticFileMap[file.filePath] = {
|
|
12214
12409
|
contentType,
|
|
@@ -12217,15 +12412,15 @@ function createStaticRoute(service, logger, router, dir, file, inflateDir, route
|
|
|
12217
12412
|
method: "GET",
|
|
12218
12413
|
path: normalizePath(path),
|
|
12219
12414
|
body: Buffer.from(body),
|
|
12220
|
-
inflatePath: inflateDir ? (0,
|
|
12415
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
12221
12416
|
};
|
|
12222
12417
|
}
|
|
12223
12418
|
}
|
|
12224
12419
|
router.use(assertGlobalTampered);
|
|
12225
12420
|
router.get(path, async function(_req, res) {
|
|
12226
|
-
await new Promise((
|
|
12421
|
+
await new Promise((resolve24, reject) => {
|
|
12227
12422
|
try {
|
|
12228
|
-
(0,
|
|
12423
|
+
(0, import_node_fs11.readFile)(file.filePath, async (err, body) => {
|
|
12229
12424
|
if (err) {
|
|
12230
12425
|
reject(err);
|
|
12231
12426
|
} else {
|
|
@@ -12237,7 +12432,7 @@ function createStaticRoute(service, logger, router, dir, file, inflateDir, route
|
|
|
12237
12432
|
},
|
|
12238
12433
|
body
|
|
12239
12434
|
});
|
|
12240
|
-
|
|
12435
|
+
resolve24();
|
|
12241
12436
|
} catch (e) {
|
|
12242
12437
|
reject(e);
|
|
12243
12438
|
}
|
|
@@ -12259,7 +12454,7 @@ function createStaticRouterFromDirectory(service, logger, dir, inflateDir, route
|
|
|
12259
12454
|
async function createRouterFromDirectory(server2, hotreload, service, logger, dir, errors = [], routeFileMap = {}, staticFileMap = null, inflateDir, inflateSea) {
|
|
12260
12455
|
const router = new Router();
|
|
12261
12456
|
router.use(assertGlobalTampered);
|
|
12262
|
-
await Promise.all(scanFiles(dir).map((file) => new Promise(async (
|
|
12457
|
+
await Promise.all(scanFiles(dir).map((file) => new Promise(async (resolve24) => {
|
|
12263
12458
|
try {
|
|
12264
12459
|
switch (file.ext) {
|
|
12265
12460
|
case ".jsx":
|
|
@@ -12268,13 +12463,13 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12268
12463
|
case ".tsx": {
|
|
12269
12464
|
switch (file.subExt) {
|
|
12270
12465
|
case ".test":
|
|
12271
|
-
return
|
|
12466
|
+
return resolve24();
|
|
12272
12467
|
case ".ignore":
|
|
12273
12468
|
logger.warn("ignoring [%s]", file.filePath);
|
|
12274
|
-
return
|
|
12469
|
+
return resolve24();
|
|
12275
12470
|
case ".api": {
|
|
12276
12471
|
const module2 = await importAPIRoute(file.filePath, logger);
|
|
12277
|
-
const routes = getRoutes((0,
|
|
12472
|
+
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName, module2);
|
|
12278
12473
|
routeFileMap[file.filePath] = {
|
|
12279
12474
|
routes,
|
|
12280
12475
|
service,
|
|
@@ -12289,21 +12484,21 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12289
12484
|
for (const r of routes) {
|
|
12290
12485
|
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
12291
12486
|
const rPath = r.defaultInflatePath;
|
|
12292
|
-
const inflatePath = (0,
|
|
12293
|
-
(0,
|
|
12487
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.js");
|
|
12488
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12294
12489
|
recursive: true
|
|
12295
12490
|
});
|
|
12296
|
-
logger.log("writing [%s]", (0,
|
|
12297
|
-
(0,
|
|
12491
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12492
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, inflatedCode);
|
|
12298
12493
|
}
|
|
12299
12494
|
router.use(assertGlobalTampered);
|
|
12300
12495
|
router.use(module2.handler, r.path, r.method, r.options);
|
|
12301
12496
|
}
|
|
12302
|
-
return
|
|
12497
|
+
return resolve24();
|
|
12303
12498
|
}
|
|
12304
12499
|
case ".json": {
|
|
12305
12500
|
const module2 = await importJSONModule(file.filePath, logger);
|
|
12306
|
-
const routes = getRoutes((0,
|
|
12501
|
+
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".json", module2.apiOptions);
|
|
12307
12502
|
routeFileMap[file.filePath] = {
|
|
12308
12503
|
routes,
|
|
12309
12504
|
service,
|
|
@@ -12314,17 +12509,17 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12314
12509
|
if (inflateDir) {
|
|
12315
12510
|
if (r.inflatePath) {
|
|
12316
12511
|
const rPath = r.inflatePath;
|
|
12317
|
-
const inflatePath = (0,
|
|
12318
|
-
(0,
|
|
12512
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
12513
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12319
12514
|
recursive: true
|
|
12320
12515
|
});
|
|
12321
|
-
if ((0,
|
|
12322
|
-
logger.trace("ignoring writing over directory [%s] for file [%s]", (0,
|
|
12516
|
+
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
12517
|
+
logger.trace("ignoring writing over directory [%s] for file [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath), file.filePath);
|
|
12323
12518
|
continue;
|
|
12324
12519
|
}
|
|
12325
12520
|
const JSON_STATIC = await getJSON({ server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, module2.default);
|
|
12326
|
-
logger.log("writing [%s]", (0,
|
|
12327
|
-
(0,
|
|
12521
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12522
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, JSON_STATIC);
|
|
12328
12523
|
if (staticFileMap && inflateSea) {
|
|
12329
12524
|
staticFileMap[file.filePath] = {
|
|
12330
12525
|
contentType,
|
|
@@ -12333,7 +12528,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12333
12528
|
previewMethod: "html",
|
|
12334
12529
|
path: r.path,
|
|
12335
12530
|
body: Buffer.from(JSON_STATIC),
|
|
12336
|
-
inflatePath: inflateDir ? (0,
|
|
12531
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
|
|
12337
12532
|
};
|
|
12338
12533
|
}
|
|
12339
12534
|
}
|
|
@@ -12350,11 +12545,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12350
12545
|
});
|
|
12351
12546
|
}, r.path, r.method, r.options);
|
|
12352
12547
|
}
|
|
12353
|
-
return
|
|
12548
|
+
return resolve24();
|
|
12354
12549
|
}
|
|
12355
12550
|
case ".html": {
|
|
12356
12551
|
const module2 = await importHTMLModule(file.filePath, logger);
|
|
12357
|
-
const routes = getRoutes((0,
|
|
12552
|
+
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".html", module2.apiOptions);
|
|
12358
12553
|
routeFileMap[file.filePath] = {
|
|
12359
12554
|
routes,
|
|
12360
12555
|
service,
|
|
@@ -12365,18 +12560,18 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12365
12560
|
if (inflateDir) {
|
|
12366
12561
|
if (r.inflatePath) {
|
|
12367
12562
|
const rPath = r.inflatePath;
|
|
12368
|
-
const inflatePath = (0,
|
|
12369
|
-
(0,
|
|
12563
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
12564
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12370
12565
|
recursive: true
|
|
12371
12566
|
});
|
|
12372
|
-
if ((0,
|
|
12373
|
-
logger.trace("ignoring writing over directory [%s] for file [%s]", (0,
|
|
12567
|
+
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
12568
|
+
logger.trace("ignoring writing over directory [%s] for file [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath), file.filePath);
|
|
12374
12569
|
continue;
|
|
12375
12570
|
}
|
|
12376
12571
|
const toRender = typeof module2.default === "function" ? module2.default({ server: server2 }, null) : module2.default;
|
|
12377
12572
|
const HTML_STATIC = await getHTML(hotreload, { server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, await toRender);
|
|
12378
|
-
logger.log("writing [%s]", (0,
|
|
12379
|
-
(0,
|
|
12573
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12574
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, HTML_STATIC);
|
|
12380
12575
|
if (staticFileMap && inflateSea) {
|
|
12381
12576
|
staticFileMap[file.filePath + r.method + r.path] = {
|
|
12382
12577
|
filePath: file.filePath,
|
|
@@ -12385,7 +12580,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12385
12580
|
previewMethod: "html",
|
|
12386
12581
|
path: r.path,
|
|
12387
12582
|
body: Buffer.from(HTML_STATIC),
|
|
12388
|
-
inflatePath: inflateDir ? (0,
|
|
12583
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
|
|
12389
12584
|
};
|
|
12390
12585
|
}
|
|
12391
12586
|
}
|
|
@@ -12403,7 +12598,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12403
12598
|
});
|
|
12404
12599
|
}, r.path, r.method, r.options);
|
|
12405
12600
|
}
|
|
12406
|
-
return
|
|
12601
|
+
return resolve24();
|
|
12407
12602
|
}
|
|
12408
12603
|
case ".min":
|
|
12409
12604
|
case ".js":
|
|
@@ -12416,7 +12611,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12416
12611
|
logger
|
|
12417
12612
|
});
|
|
12418
12613
|
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
12419
|
-
const path = (0,
|
|
12614
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name + ".js");
|
|
12420
12615
|
routeFileMap[file.filePath] = {
|
|
12421
12616
|
routes: [{
|
|
12422
12617
|
method: "GET",
|
|
@@ -12426,12 +12621,12 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12426
12621
|
previewMethod: "html"
|
|
12427
12622
|
};
|
|
12428
12623
|
if (inflateDir) {
|
|
12429
|
-
const inflatePath = (0,
|
|
12430
|
-
(0,
|
|
12624
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
12625
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12431
12626
|
recursive: true
|
|
12432
12627
|
});
|
|
12433
|
-
logger.log("writing [%s]", (0,
|
|
12434
|
-
(0,
|
|
12628
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12629
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
12435
12630
|
if (staticFileMap && inflateSea) {
|
|
12436
12631
|
staticFileMap[file.filePath] = {
|
|
12437
12632
|
contentType,
|
|
@@ -12440,7 +12635,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12440
12635
|
previewMethod: "html",
|
|
12441
12636
|
path,
|
|
12442
12637
|
body: Buffer.from(code),
|
|
12443
|
-
inflatePath: inflateDir ? (0,
|
|
12638
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
12444
12639
|
};
|
|
12445
12640
|
}
|
|
12446
12641
|
}
|
|
@@ -12454,7 +12649,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12454
12649
|
body: code
|
|
12455
12650
|
});
|
|
12456
12651
|
});
|
|
12457
|
-
return
|
|
12652
|
+
return resolve24();
|
|
12458
12653
|
}
|
|
12459
12654
|
}
|
|
12460
12655
|
}
|
|
@@ -12464,7 +12659,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12464
12659
|
case ".html": {
|
|
12465
12660
|
const code = await inflateMD2HTML(file.filePath, logger);
|
|
12466
12661
|
const contentType = CONTENT_TYPE_MAP[".html"];
|
|
12467
|
-
const path = (0,
|
|
12662
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name);
|
|
12468
12663
|
routeFileMap[file.filePath] = {
|
|
12469
12664
|
routes: [{
|
|
12470
12665
|
method: "GET",
|
|
@@ -12474,12 +12669,12 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12474
12669
|
previewMethod: "html"
|
|
12475
12670
|
};
|
|
12476
12671
|
if (inflateDir) {
|
|
12477
|
-
const inflatePath = (0,
|
|
12478
|
-
(0,
|
|
12672
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
12673
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12479
12674
|
recursive: true
|
|
12480
12675
|
});
|
|
12481
|
-
logger.log("writing [%s]", (0,
|
|
12482
|
-
(0,
|
|
12676
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12677
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
12483
12678
|
if (staticFileMap && inflateSea) {
|
|
12484
12679
|
staticFileMap[file.filePath] = {
|
|
12485
12680
|
contentType,
|
|
@@ -12488,7 +12683,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12488
12683
|
previewMethod: "html",
|
|
12489
12684
|
path,
|
|
12490
12685
|
body: Buffer.from(code),
|
|
12491
|
-
inflatePath: inflateDir ? (0,
|
|
12686
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
12492
12687
|
};
|
|
12493
12688
|
}
|
|
12494
12689
|
}
|
|
@@ -12502,7 +12697,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12502
12697
|
body: code
|
|
12503
12698
|
});
|
|
12504
12699
|
});
|
|
12505
|
-
return
|
|
12700
|
+
return resolve24();
|
|
12506
12701
|
}
|
|
12507
12702
|
}
|
|
12508
12703
|
}
|
|
@@ -12511,7 +12706,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12511
12706
|
switch (file.subExt) {
|
|
12512
12707
|
case ".ignore": {
|
|
12513
12708
|
logger.warn("ignoring [%s]", file.filePath);
|
|
12514
|
-
return
|
|
12709
|
+
return resolve24();
|
|
12515
12710
|
}
|
|
12516
12711
|
case ".bundle":
|
|
12517
12712
|
case ".min": {
|
|
@@ -12522,7 +12717,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12522
12717
|
logger
|
|
12523
12718
|
});
|
|
12524
12719
|
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
12525
|
-
const path = (0,
|
|
12720
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name + ".js");
|
|
12526
12721
|
routeFileMap[file.filePath] = {
|
|
12527
12722
|
routes: [{
|
|
12528
12723
|
method: "GET",
|
|
@@ -12532,12 +12727,12 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12532
12727
|
previewMethod: "html"
|
|
12533
12728
|
};
|
|
12534
12729
|
if (inflateDir) {
|
|
12535
|
-
const inflatePath = (0,
|
|
12536
|
-
(0,
|
|
12730
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
12731
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12537
12732
|
recursive: true
|
|
12538
12733
|
});
|
|
12539
|
-
logger.log("writing [%s]", (0,
|
|
12540
|
-
(0,
|
|
12734
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12735
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
12541
12736
|
if (staticFileMap && inflateSea) {
|
|
12542
12737
|
staticFileMap[file.filePath] = {
|
|
12543
12738
|
contentType,
|
|
@@ -12546,7 +12741,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12546
12741
|
previewMethod: "html",
|
|
12547
12742
|
path,
|
|
12548
12743
|
body: Buffer.from(code),
|
|
12549
|
-
inflatePath: inflateDir ? (0,
|
|
12744
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
12550
12745
|
};
|
|
12551
12746
|
}
|
|
12552
12747
|
}
|
|
@@ -12560,19 +12755,19 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12560
12755
|
body: code
|
|
12561
12756
|
});
|
|
12562
12757
|
});
|
|
12563
|
-
return
|
|
12758
|
+
return resolve24();
|
|
12564
12759
|
}
|
|
12565
12760
|
}
|
|
12566
12761
|
} else if (file.ext === ".bundle") {
|
|
12567
12762
|
switch (file.subExt) {
|
|
12568
12763
|
case ".ignore": {
|
|
12569
12764
|
logger.warn("ignoring [%s]", file.filePath);
|
|
12570
|
-
return
|
|
12765
|
+
return resolve24();
|
|
12571
12766
|
}
|
|
12572
12767
|
case ".css": {
|
|
12573
|
-
const code = (0,
|
|
12768
|
+
const code = (0, import_node_fs11.readFileSync)(file.filePath).toString().split("\n").filter((c) => c).filter((c) => c.charAt(0) !== "#").map((cssPath) => (0, import_node_fs11.readFileSync)((0, import_node_path12.resolve)((0, import_node_path12.dirname)(file.filePath), cssPath)).toString()).join("\n");
|
|
12574
12769
|
const contentType = CONTENT_TYPE_MAP[".css"];
|
|
12575
|
-
const path = (0,
|
|
12770
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name);
|
|
12576
12771
|
routeFileMap[file.filePath] = {
|
|
12577
12772
|
routes: [{
|
|
12578
12773
|
method: "GET",
|
|
@@ -12582,12 +12777,12 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12582
12777
|
previewMethod: "html"
|
|
12583
12778
|
};
|
|
12584
12779
|
if (inflateDir) {
|
|
12585
|
-
const inflatePath = (0,
|
|
12586
|
-
(0,
|
|
12780
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
12781
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
12587
12782
|
recursive: true
|
|
12588
12783
|
});
|
|
12589
|
-
logger.log("writing [%s]", (0,
|
|
12590
|
-
(0,
|
|
12784
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
12785
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
12591
12786
|
if (staticFileMap && inflateSea) {
|
|
12592
12787
|
staticFileMap[file.filePath] = {
|
|
12593
12788
|
contentType,
|
|
@@ -12596,7 +12791,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12596
12791
|
previewMethod: "html",
|
|
12597
12792
|
path,
|
|
12598
12793
|
body: Buffer.from(code),
|
|
12599
|
-
inflatePath: inflateDir ? (0,
|
|
12794
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
12600
12795
|
};
|
|
12601
12796
|
}
|
|
12602
12797
|
}
|
|
@@ -12610,12 +12805,12 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12610
12805
|
body: code
|
|
12611
12806
|
});
|
|
12612
12807
|
});
|
|
12613
|
-
return
|
|
12808
|
+
return resolve24();
|
|
12614
12809
|
}
|
|
12615
12810
|
}
|
|
12616
12811
|
}
|
|
12617
12812
|
createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
|
|
12618
|
-
return
|
|
12813
|
+
return resolve24();
|
|
12619
12814
|
}
|
|
12620
12815
|
} catch (e) {
|
|
12621
12816
|
logger.error("error with " + file.filePath);
|
|
@@ -12625,7 +12820,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12625
12820
|
error: e
|
|
12626
12821
|
});
|
|
12627
12822
|
} finally {
|
|
12628
|
-
return
|
|
12823
|
+
return resolve24();
|
|
12629
12824
|
}
|
|
12630
12825
|
})));
|
|
12631
12826
|
router.use(assertGlobalTampered);
|
|
@@ -12636,10 +12831,10 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
12636
12831
|
};
|
|
12637
12832
|
}
|
|
12638
12833
|
function scanFiles(path, ret = []) {
|
|
12639
|
-
const files = (0,
|
|
12834
|
+
const files = (0, import_node_fs11.readdirSync)(path).sort();
|
|
12640
12835
|
for (const file of files) {
|
|
12641
|
-
const filePath = (0,
|
|
12642
|
-
if ((0,
|
|
12836
|
+
const filePath = (0, import_node_path12.resolve)(path, file);
|
|
12837
|
+
if ((0, import_node_fs11.statSync)(filePath).isDirectory()) {
|
|
12643
12838
|
scanFiles(filePath, ret);
|
|
12644
12839
|
continue;
|
|
12645
12840
|
} else {
|
|
@@ -12669,9 +12864,9 @@ async function getJSON(req, res, url, basePath, out) {
|
|
|
12669
12864
|
}
|
|
12670
12865
|
|
|
12671
12866
|
// src/inflate/setup-ws.ts
|
|
12672
|
-
var
|
|
12673
|
-
var
|
|
12674
|
-
var
|
|
12867
|
+
var import_node_path13 = require("node:path");
|
|
12868
|
+
var import_node_process9 = require("node:process");
|
|
12869
|
+
var import_node_fs12 = require("node:fs");
|
|
12675
12870
|
async function inflateWSConfig(logger, servicePath, service, wsConfigList, inflateDir, errors) {
|
|
12676
12871
|
const wsPath = getWSConfigPath(servicePath);
|
|
12677
12872
|
if (wsPath) {
|
|
@@ -12681,16 +12876,16 @@ async function inflateWSConfig(logger, servicePath, service, wsConfigList, infla
|
|
|
12681
12876
|
if (wsConfig && wsConfigList.filter((c) => c.path === wsConfig.path).length > 0) {
|
|
12682
12877
|
throw new Error(`ws path [${wsConfig.path}] already defined! from [${wsPath}]`);
|
|
12683
12878
|
} else if (wsConfigList) {
|
|
12684
|
-
logger.debug("importing websocket on path [%s] from [%s]", wsConfig.path, (0,
|
|
12879
|
+
logger.debug("importing websocket on path [%s] from [%s]", wsConfig.path, (0, import_node_path13.join)(service, "ws.ts"));
|
|
12685
12880
|
wsConfigList.push(wsConfig);
|
|
12686
12881
|
}
|
|
12687
12882
|
if (inflateDir) {
|
|
12688
|
-
const inflatePath = (0,
|
|
12689
|
-
(0,
|
|
12883
|
+
const inflatePath = (0, import_node_path13.resolve)(inflateDir, service, "ws.js");
|
|
12884
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path13.dirname)(inflatePath), {
|
|
12690
12885
|
recursive: true
|
|
12691
12886
|
});
|
|
12692
|
-
logger.log("writing [%s]", (0,
|
|
12693
|
-
(0,
|
|
12887
|
+
logger.log("writing [%s]", (0, import_node_path13.relative)((0, import_node_process9.cwd)(), inflatePath));
|
|
12888
|
+
(0, import_node_fs12.writeFileSync)(inflatePath, await inflateJSX(wsPath, {
|
|
12694
12889
|
embemedJSX: false,
|
|
12695
12890
|
minify: false,
|
|
12696
12891
|
useExport: true,
|
|
@@ -12711,37 +12906,37 @@ async function inflateWSConfig(logger, servicePath, service, wsConfigList, infla
|
|
|
12711
12906
|
}
|
|
12712
12907
|
|
|
12713
12908
|
// src/inflate/inflate-sea.ts
|
|
12714
|
-
var
|
|
12715
|
-
var
|
|
12716
|
-
var
|
|
12909
|
+
var import_node_fs13 = require("node:fs");
|
|
12910
|
+
var import_node_path14 = require("node:path");
|
|
12911
|
+
var import_node_process10 = require("node:process");
|
|
12717
12912
|
async function inflateSeaAssets(logger, inflateDir) {
|
|
12718
12913
|
const esbuildBinaryBuffer2 = Buffer.from(getAsset("esbuild-binary"));
|
|
12719
|
-
if (
|
|
12720
|
-
writeFile(logger, (0,
|
|
12721
|
-
(0,
|
|
12914
|
+
if (import_node_process10.platform === "win32") {
|
|
12915
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "esbuild.exe"), esbuildBinaryBuffer2);
|
|
12916
|
+
(0, import_node_fs13.chmodSync)((0, import_node_path14.resolve)(inflateDir, "sea", "esbuild.exe"), import_node_fs13.constants.S_IXUSR | import_node_fs13.constants.S_IRUSR | import_node_fs13.constants.S_IWUSR);
|
|
12722
12917
|
} else {
|
|
12723
|
-
writeFile(logger, (0,
|
|
12724
|
-
(0,
|
|
12725
|
-
}
|
|
12726
|
-
writeFile(logger, (0,
|
|
12727
|
-
writeFile(logger, (0,
|
|
12728
|
-
writeFile(logger, (0,
|
|
12729
|
-
writeFile(logger, (0,
|
|
12730
|
-
writeFile(logger, (0,
|
|
12731
|
-
writeFile(logger, (0,
|
|
12732
|
-
writeFile(logger, (0,
|
|
12733
|
-
writeFile(logger, (0,
|
|
12918
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "esbuild"), esbuildBinaryBuffer2);
|
|
12919
|
+
(0, import_node_fs13.chmodSync)((0, import_node_path14.resolve)(inflateDir, "sea", "esbuild"), import_node_fs13.constants.S_IXUSR | import_node_fs13.constants.S_IRUSR | import_node_fs13.constants.S_IWUSR);
|
|
12920
|
+
}
|
|
12921
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
12922
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "config.json"), Buffer.from(getAsset("sea.basic.config.json")));
|
|
12923
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "run.sh"), Buffer.from(getAsset("app.sh")));
|
|
12924
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "node.sh"), Buffer.from(getAsset("node.sh")));
|
|
12925
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "compile.sh"), Buffer.from(Buffer.from(getAsset("compile.base64.sh")).toString(), "base64"));
|
|
12926
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "sign-add.sh"), Buffer.from(getAsset("sign-add.sh")));
|
|
12927
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "sign-remove.sh"), Buffer.from(getAsset("sign-remove.sh")));
|
|
12928
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
|
|
12734
12929
|
}
|
|
12735
12930
|
async function inflateAppForSea(logger, inflateDir, services) {
|
|
12736
12931
|
inflateSeaAssets(logger, inflateDir);
|
|
12737
|
-
writeFile(logger, (0,
|
|
12738
|
-
const WSLIST = services.filter((service) => getWSConfigPath((0,
|
|
12932
|
+
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
12933
|
+
const WSLIST = services.filter((service) => getWSConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
12739
12934
|
return `(await import("../${service}/ws.js")).default`;
|
|
12740
12935
|
}).join(",");
|
|
12741
|
-
const SERVERCONFIGLIST = services.filter((service) => getServerConfigPath((0,
|
|
12936
|
+
const SERVERCONFIGLIST = services.filter((service) => getServerConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
12742
12937
|
return `(await import("../${service}/server.js")).default`;
|
|
12743
12938
|
}).join(",\n");
|
|
12744
|
-
const DBCONFIGLIST = services.filter((service) => getDBConfigPath((0,
|
|
12939
|
+
const DBCONFIGLIST = services.filter((service) => getDBConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
12745
12940
|
return `new Promise(async (resolve, reject) => {
|
|
12746
12941
|
try {
|
|
12747
12942
|
const db = await dbManager.setupDB((await import("../${service}/db.js")).default);
|
|
@@ -12753,10 +12948,10 @@ async function inflateAppForSea(logger, inflateDir, services) {
|
|
|
12753
12948
|
|
|
12754
12949
|
})`;
|
|
12755
12950
|
}).join(",");
|
|
12756
|
-
writeFile(logger, (0,
|
|
12951
|
+
writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
12757
12952
|
writeFile(
|
|
12758
12953
|
logger,
|
|
12759
|
-
(0,
|
|
12954
|
+
(0, import_node_path14.join)(inflateDir, "sea", "app.cjs"),
|
|
12760
12955
|
`const { ServerInterfaceImpl, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
12761
12956
|
|
|
12762
12957
|
async function main() {
|
|
@@ -12789,22 +12984,11 @@ async function main() {
|
|
|
12789
12984
|
` : ""}
|
|
12790
12985
|
app.use(ServerRequestHandler(serverInterface));
|
|
12791
12986
|
app.use(LoggerHandler());
|
|
12792
|
-
${services.map((service) => {
|
|
12793
|
-
const servicePath = getServicePath(service);
|
|
12794
|
-
return `${getCORSConfigPath(servicePath) ? `app.use(server.middleware.cors((await import("../${service}/cors.js")).default));` : ""}`;
|
|
12795
|
-
})}
|
|
12796
|
-
${services.map((service) => {
|
|
12797
|
-
const servicePath = getServicePath(service);
|
|
12798
|
-
return `${getAuthConfigPath(servicePath) ? `app.use(server.middleware.session((await import("../${service}/auth.js")).default));` : ""}`;
|
|
12799
|
-
})}
|
|
12800
|
-
${services.map((service) => `
|
|
12801
|
-
app.use(await (await import("./${(0, import_node_path12.join)(service, "api-router.js")}")).setupRouter());
|
|
12802
|
-
app.use(await (await import("./${(0, import_node_path12.join)(service, "static-router.js")}")).setupRouter())`).join("\n")}
|
|
12987
|
+
${services.map((service) => `app.use(await (await import("./${(0, import_node_path14.join)(service, "router.js")}")).setupRouter());`).join("\n")}
|
|
12803
12988
|
${SERVERCONFIGLIST ? `
|
|
12804
12989
|
await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.load).map(config=>config.load(serverInterface)));
|
|
12805
12990
|
` : ""}
|
|
12806
12991
|
|
|
12807
|
-
|
|
12808
12992
|
await app.listen(PORT);
|
|
12809
12993
|
${SERVERCONFIGLIST ? `
|
|
12810
12994
|
await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
|
|
@@ -12816,43 +13000,66 @@ main().catch(e=>console.error(e));
|
|
|
12816
13000
|
async function inflateServiceForSea(logger, inflateDir, service, servicePath, serviceRouteFileMap, serviceStaticFileMap) {
|
|
12817
13001
|
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
12818
13002
|
const serviceMigrations = migrationsFolderPath ? lib_exports.getSortedMigrations(migrationsFolderPath) : [];
|
|
12819
|
-
writeFile(logger, (0,
|
|
13003
|
+
writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";
|
|
12820
13004
|
|
|
12821
13005
|
export async function setupRouter() {
|
|
12822
13006
|
const router = new Router();
|
|
12823
|
-
|
|
13007
|
+
${getErrorConfigPath(servicePath) ? `
|
|
13008
|
+
const errorConfig = (await import("../../${service}/catch.js")).default;
|
|
13009
|
+
if(errorConfig && errorConfig.catch) {
|
|
13010
|
+
for(const m of errorConfig.catch) {
|
|
13011
|
+
router.catch(m);
|
|
13012
|
+
}
|
|
13013
|
+
}` : ""}
|
|
13014
|
+
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.js")).default));` : ""}
|
|
13015
|
+
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.js")).default));` : ""}
|
|
13016
|
+
${getMiddlewareConfigPath(servicePath) ? `
|
|
13017
|
+
const middlewareConfig = (await import("../../${service}/middleware.js")).default;
|
|
13018
|
+
if(middlewareConfig && middlewareConfig.middleware) {
|
|
13019
|
+
for(const m of middlewareConfig.middleware) {
|
|
13020
|
+
router.use(m);
|
|
13021
|
+
}
|
|
13022
|
+
}` : ""}
|
|
12824
13023
|
${Object.keys(serviceRouteFileMap).map((filePath) => serviceRouteFileMap[filePath]).filter((data) => data.previewMethod === "api").map((data) => data.routes.map((r) => {
|
|
12825
13024
|
const rPath = r.inflatePath;
|
|
12826
13025
|
if (rPath) {
|
|
12827
|
-
const apiInflatedPath = (0,
|
|
13026
|
+
const apiInflatedPath = (0, import_node_path14.join)("..", "..", service, "http", rPath + ".api.js");
|
|
12828
13027
|
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default);`;
|
|
12829
13028
|
} else {
|
|
12830
13029
|
return "";
|
|
12831
13030
|
}
|
|
12832
13031
|
}).filter((l) => l)[0]).join("\n")}
|
|
13032
|
+
router.use(await (await import("./static-router.js")).setupRouter())
|
|
12833
13033
|
|
|
13034
|
+
${getMiddlewareConfigPath(servicePath) ? `
|
|
13035
|
+
if(middlewareConfig && middlewareConfig.post) {
|
|
13036
|
+
for(const m of middlewareConfig.post) {
|
|
13037
|
+
router.use(m);
|
|
13038
|
+
}
|
|
13039
|
+
}` : ""}
|
|
13040
|
+
|
|
12834
13041
|
return router;
|
|
12835
13042
|
}`);
|
|
12836
|
-
writeFile(logger, (0,
|
|
13043
|
+
writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-up.js"), `import { migration } from "./../lib.cjs";
|
|
12837
13044
|
|
|
12838
13045
|
export async function runMigrations(db) {
|
|
12839
13046
|
await migration.init(db);
|
|
12840
13047
|
${serviceMigrations.map((file) => {
|
|
12841
|
-
const name = `${file.substring(0, file.length - (0,
|
|
13048
|
+
const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
|
|
12842
13049
|
return ` await migration.up.module(db, "${name}", (await import("../../${service}/migration/${name}.js")).default)`;
|
|
12843
13050
|
}).join("\n")}
|
|
12844
13051
|
}`);
|
|
12845
|
-
writeFile(logger, (0,
|
|
13052
|
+
writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.js"), `import { migration } from "./../lib.cjs";
|
|
12846
13053
|
|
|
12847
13054
|
export async function runMigrations(db) {
|
|
12848
13055
|
await migration.init(db);
|
|
12849
13056
|
${serviceMigrations.reverse().map((file) => {
|
|
12850
|
-
const name = `${file.substring(0, file.length - (0,
|
|
13057
|
+
const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
|
|
12851
13058
|
return ` await migration.down.module(db, "${name}", (await import("../../${service}/migration/${name}.js")).default)`;
|
|
12852
13059
|
}).join("\n")}
|
|
12853
13060
|
}`);
|
|
12854
13061
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
12855
|
-
writeFile(logger, (0,
|
|
13062
|
+
writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "static-router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";
|
|
12856
13063
|
|
|
12857
13064
|
export async function setupRouter() {
|
|
12858
13065
|
const router = new Router();
|
|
@@ -12873,17 +13080,17 @@ ${staticFiles.map((filePath) => {
|
|
|
12873
13080
|
}`);
|
|
12874
13081
|
}
|
|
12875
13082
|
function writeFile(logger, path, buffer) {
|
|
12876
|
-
logger.log("writing [%s]", (0,
|
|
12877
|
-
(0,
|
|
13083
|
+
logger.log("writing [%s]", (0, import_node_path14.relative)((0, import_node_process10.cwd)(), path));
|
|
13084
|
+
(0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(path), {
|
|
12878
13085
|
recursive: true
|
|
12879
13086
|
});
|
|
12880
|
-
(0,
|
|
13087
|
+
(0, import_node_fs13.writeFileSync)(path, buffer);
|
|
12881
13088
|
}
|
|
12882
13089
|
|
|
12883
13090
|
// src/inflate/setup-log.ts
|
|
12884
|
-
var
|
|
12885
|
-
var
|
|
12886
|
-
var
|
|
13091
|
+
var import_node_path15 = require("node:path");
|
|
13092
|
+
var import_node_fs14 = require("node:fs");
|
|
13093
|
+
var import_node_process11 = require("node:process");
|
|
12887
13094
|
async function setupLogConfig(logger, servicePath, service, logConfigMap, inflateDir, errors) {
|
|
12888
13095
|
const logPath = getLogConfigPath(servicePath);
|
|
12889
13096
|
if (logPath) {
|
|
@@ -12891,12 +13098,12 @@ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflat
|
|
|
12891
13098
|
const logConfig = await importLogConfigModule(logPath, logger);
|
|
12892
13099
|
logConfigMap[service] = logConfig;
|
|
12893
13100
|
if (inflateDir) {
|
|
12894
|
-
const inflatePath = (0,
|
|
12895
|
-
(0,
|
|
13101
|
+
const inflatePath = (0, import_node_path15.resolve)(inflateDir, service, "log.js");
|
|
13102
|
+
(0, import_node_fs14.mkdirSync)((0, import_node_path15.dirname)(inflatePath), {
|
|
12896
13103
|
recursive: true
|
|
12897
13104
|
});
|
|
12898
|
-
logger.log("writing [%s]", (0,
|
|
12899
|
-
(0,
|
|
13105
|
+
logger.log("writing [%s]", (0, import_node_path15.relative)((0, import_node_process11.cwd)(), inflatePath));
|
|
13106
|
+
(0, import_node_fs14.writeFileSync)(inflatePath, await inflateJSX(logPath, {
|
|
12900
13107
|
embemedJSX: false,
|
|
12901
13108
|
minify: false,
|
|
12902
13109
|
useExport: true,
|
|
@@ -12914,6 +13121,330 @@ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflat
|
|
|
12914
13121
|
}
|
|
12915
13122
|
}
|
|
12916
13123
|
|
|
13124
|
+
// src/inflate/setup.doc.ts
|
|
13125
|
+
var import_node_path16 = require("node:path");
|
|
13126
|
+
var import_node_fs15 = require("node:fs");
|
|
13127
|
+
var import_node_process12 = require("node:process");
|
|
13128
|
+
|
|
13129
|
+
// src/bin/doc-md.ts
|
|
13130
|
+
async function getMDDoc(args, logger) {
|
|
13131
|
+
const pathList = Object.keys(args.jsonDoc).sort();
|
|
13132
|
+
let outMD = "";
|
|
13133
|
+
const tableIndexItems = [];
|
|
13134
|
+
for (const path of pathList) {
|
|
13135
|
+
const pathData = args.jsonDoc[path];
|
|
13136
|
+
const methods = Object.keys(pathData);
|
|
13137
|
+
for (const method of methods) {
|
|
13138
|
+
if (method) {
|
|
13139
|
+
const apiDataList = pathData[method];
|
|
13140
|
+
for (const apiData of apiDataList) {
|
|
13141
|
+
tableIndexItems.push({
|
|
13142
|
+
apiData
|
|
13143
|
+
});
|
|
13144
|
+
outMD += `## ${apiData.identifier}
|
|
13145
|
+
|
|
13146
|
+
`;
|
|
13147
|
+
outMD += `${args.showFilePath && apiData.___filePath ? apiData.___filePath + "\n\n" : ""}`;
|
|
13148
|
+
if (apiData.name) {
|
|
13149
|
+
outMD += `${apiData.name}
|
|
13150
|
+
|
|
13151
|
+
`;
|
|
13152
|
+
}
|
|
13153
|
+
if (apiData.description) {
|
|
13154
|
+
outMD += `${apiData.description}
|
|
13155
|
+
|
|
13156
|
+
`;
|
|
13157
|
+
}
|
|
13158
|
+
outMD += `[${method}] ${path}
|
|
13159
|
+
|
|
13160
|
+
`;
|
|
13161
|
+
outMD += `[${path}](${path})
|
|
13162
|
+
|
|
13163
|
+
`;
|
|
13164
|
+
if (apiData.policy) {
|
|
13165
|
+
outMD += `### policy
|
|
13166
|
+
|
|
13167
|
+
`;
|
|
13168
|
+
outMD += policyToString(apiData.policy);
|
|
13169
|
+
}
|
|
13170
|
+
if (apiData.request) {
|
|
13171
|
+
const requestOutMD = parserToString(apiData.request);
|
|
13172
|
+
outMD += requestOutMD !== "" ? `### request
|
|
13173
|
+
|
|
13174
|
+
${requestOutMD}` : "";
|
|
13175
|
+
}
|
|
13176
|
+
if (apiData.response && typeof apiData.response !== "boolean") {
|
|
13177
|
+
const responseOutMD = parserToString(apiData.response);
|
|
13178
|
+
outMD += responseOutMD !== "" ? `### response
|
|
13179
|
+
|
|
13180
|
+
${responseOutMD}` : "";
|
|
13181
|
+
}
|
|
13182
|
+
}
|
|
13183
|
+
}
|
|
13184
|
+
}
|
|
13185
|
+
}
|
|
13186
|
+
const indexTable = getIndexTable(tableIndexItems);
|
|
13187
|
+
return `${indexTable}
|
|
13188
|
+
|
|
13189
|
+
${outMD}`;
|
|
13190
|
+
}
|
|
13191
|
+
function getIndexTable(data) {
|
|
13192
|
+
return `${data.map((api) => `[${api.apiData.identifier}](#${api.apiData.identifier.toLocaleLowerCase()})${api.apiData.name || api.apiData.description ? `
|
|
13193
|
+
|
|
13194
|
+
${api.apiData.name ? api.apiData.name + " " : ""}${api.apiData.description ? api.apiData.description : ""}` : ""}`).join("\n\n")}`;
|
|
13195
|
+
}
|
|
13196
|
+
function policyToString(policy) {
|
|
13197
|
+
let outMD = "| groups | policy |\n";
|
|
13198
|
+
outMD += "|--------|--------|\n";
|
|
13199
|
+
outMD += `| ${(policy.groups instanceof Array ? policy.groups : [policy.groups]).join(",")} | ${policy.groupPolicy} |
|
|
13200
|
+
|
|
13201
|
+
`;
|
|
13202
|
+
return outMD;
|
|
13203
|
+
}
|
|
13204
|
+
function parserToString(parser4) {
|
|
13205
|
+
let outMD = "";
|
|
13206
|
+
if (parser4.status) {
|
|
13207
|
+
outMD += `#### status
|
|
13208
|
+
|
|
13209
|
+
${parser4.status instanceof Array ? parser4.status.join(",") : parser4.status}
|
|
13210
|
+
|
|
13211
|
+
`;
|
|
13212
|
+
}
|
|
13213
|
+
if (parser4.params && typeof parser4.params !== "boolean") {
|
|
13214
|
+
outMD += `#### path params
|
|
13215
|
+
|
|
13216
|
+
`;
|
|
13217
|
+
outMD += parserPartToString(parser4.params, parser4.paramsMode);
|
|
13218
|
+
}
|
|
13219
|
+
if (parser4.headers) {
|
|
13220
|
+
outMD += `#### headers
|
|
13221
|
+
|
|
13222
|
+
`;
|
|
13223
|
+
outMD += parserPartToString(parser4.headers, parser4.headersMode);
|
|
13224
|
+
}
|
|
13225
|
+
if (parser4.query && parser4.query !== true) {
|
|
13226
|
+
outMD += `#### query
|
|
13227
|
+
|
|
13228
|
+
`;
|
|
13229
|
+
outMD += parserPartToString(parser4.query, parser4.queryMode);
|
|
13230
|
+
}
|
|
13231
|
+
if (parser4.body && parser4.body !== true) {
|
|
13232
|
+
outMD += `#### body
|
|
13233
|
+
|
|
13234
|
+
`;
|
|
13235
|
+
outMD += parserPartToString(parser4.body, parser4.bodyMode);
|
|
13236
|
+
}
|
|
13237
|
+
return outMD;
|
|
13238
|
+
}
|
|
13239
|
+
function parserPartToString(arg, mode) {
|
|
13240
|
+
if (arg === false) {
|
|
13241
|
+
return "not allowed";
|
|
13242
|
+
}
|
|
13243
|
+
let outMD = "";
|
|
13244
|
+
let maxTabulation = 1;
|
|
13245
|
+
const parsers = arg instanceof Array ? arg : typeof arg === "string" ? [arg] : [arg];
|
|
13246
|
+
for (const parser4 of parsers) {
|
|
13247
|
+
const ret = internalParserToString(parser4);
|
|
13248
|
+
if (ret.maxTabulation > maxTabulation) {
|
|
13249
|
+
maxTabulation = ret.maxTabulation;
|
|
13250
|
+
}
|
|
13251
|
+
outMD += `| | | | ${getTabulation(ret.maxTabulation * 2)}
|
|
13252
|
+
`;
|
|
13253
|
+
outMD += `|--------|-------|-------|${getTabulation(ret.maxTabulation * 2, true)}
|
|
13254
|
+
`;
|
|
13255
|
+
outMD += `${ret.out}
|
|
13256
|
+
|
|
13257
|
+
`;
|
|
13258
|
+
}
|
|
13259
|
+
return outMD;
|
|
13260
|
+
}
|
|
13261
|
+
function internalParserToString(parser4, tabulation = 1) {
|
|
13262
|
+
let outMD = "";
|
|
13263
|
+
let maxTabulation = tabulation;
|
|
13264
|
+
if (typeof parser4 === "string") {
|
|
13265
|
+
outMD += `${getTabulation(tabulation)}${parser4}|
|
|
13266
|
+
`;
|
|
13267
|
+
} else {
|
|
13268
|
+
const attrNames = Object.keys(parser4);
|
|
13269
|
+
for (const name of attrNames) {
|
|
13270
|
+
const p = parser4[name];
|
|
13271
|
+
const description = typeof p === "string" ? "" : p.description ? p.description : "";
|
|
13272
|
+
if (typeof p === "string") {
|
|
13273
|
+
outMD += `${getTabulation(tabulation)}${name} | ${p}|
|
|
13274
|
+
`;
|
|
13275
|
+
} else if (p.type.toLocaleLowerCase() === "object" || p.type.toLocaleLowerCase() === "object?") {
|
|
13276
|
+
const rString = p.required === false || p.type.toLocaleLowerCase() === "object?" ? "?" : "";
|
|
13277
|
+
outMD += `${getTabulation(tabulation)}${name} | object${rString}| ${description}|
|
|
13278
|
+
`;
|
|
13279
|
+
const ret = parserBaseObjectTypeToString(p, tabulation + 1);
|
|
13280
|
+
if (maxTabulation < ret.maxTabulation) {
|
|
13281
|
+
maxTabulation = ret.maxTabulation;
|
|
13282
|
+
}
|
|
13283
|
+
outMD += `${ret.out}`;
|
|
13284
|
+
} else if (p.type.toLocaleLowerCase() === "dict" || p.type.toLocaleLowerCase() === "dict?") {
|
|
13285
|
+
const rString = p.required === false || p.type.toLocaleLowerCase() === "dict?" ? "?" : "";
|
|
13286
|
+
outMD += `${getTabulation(tabulation)}${name} | Dict\\<${p.dictType}>${rString}| ${description}|
|
|
13287
|
+
`;
|
|
13288
|
+
if (p.dictType === "object") {
|
|
13289
|
+
const ret = parserBaseObjectTypeToString(p, tabulation + 1);
|
|
13290
|
+
if (maxTabulation < ret.maxTabulation) {
|
|
13291
|
+
maxTabulation = ret.maxTabulation;
|
|
13292
|
+
}
|
|
13293
|
+
outMD += `${ret.out}`;
|
|
13294
|
+
}
|
|
13295
|
+
} else if (p.type.toLocaleLowerCase() === "array" || p.type.toLocaleLowerCase() === "array?") {
|
|
13296
|
+
const rString = p.required === false || p.type.toLocaleLowerCase() === "array?" ? "?" : "";
|
|
13297
|
+
outMD += `${getTabulation(tabulation)}${name} | Array\\<${p.arrayType}>${rString}| ${description}|
|
|
13298
|
+
`;
|
|
13299
|
+
if (p.arrayType.toLocaleLowerCase() === "object") {
|
|
13300
|
+
const ret = parserBaseObjectTypeToString(p, tabulation + 1);
|
|
13301
|
+
if (maxTabulation < ret.maxTabulation) {
|
|
13302
|
+
maxTabulation = ret.maxTabulation;
|
|
13303
|
+
}
|
|
13304
|
+
outMD += `${ret.out}`;
|
|
13305
|
+
}
|
|
13306
|
+
} else if (p.type.toLocaleLowerCase() === "regex") {
|
|
13307
|
+
outMD += `${getTabulation(tabulation)}${name} | ${p.regex}| ${description}|
|
|
13308
|
+
`;
|
|
13309
|
+
} else if (p.type.toLocaleLowerCase() === "regex?") {
|
|
13310
|
+
outMD += `${getTabulation(tabulation)}${name} | ${p.regex}?| ${description}|
|
|
13311
|
+
`;
|
|
13312
|
+
} else if (p.type.toLocaleLowerCase() === "enum") {
|
|
13313
|
+
outMD += `${getTabulation(tabulation)}${name} | ${p.type}| ${description}|
|
|
13314
|
+
`;
|
|
13315
|
+
outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|
|
|
13316
|
+
`;
|
|
13317
|
+
if (maxTabulation < tabulation + 1) {
|
|
13318
|
+
maxTabulation = tabulation + 1;
|
|
13319
|
+
}
|
|
13320
|
+
} else if (p.type.toLocaleLowerCase() === "enum?") {
|
|
13321
|
+
outMD += `${getTabulation(tabulation)}${name} | ${p.type}?| ${description}|
|
|
13322
|
+
`;
|
|
13323
|
+
outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|
|
|
13324
|
+
`;
|
|
13325
|
+
if (maxTabulation < tabulation + 1) {
|
|
13326
|
+
maxTabulation = tabulation + 1;
|
|
13327
|
+
}
|
|
13328
|
+
} else {
|
|
13329
|
+
const rString = p.required === false ? "?" : "";
|
|
13330
|
+
outMD += `${getTabulation(tabulation)}${name} | ${p.type}${rString}| ${description}|
|
|
13331
|
+
`;
|
|
13332
|
+
}
|
|
13333
|
+
}
|
|
13334
|
+
}
|
|
13335
|
+
return {
|
|
13336
|
+
out: outMD,
|
|
13337
|
+
maxTabulation
|
|
13338
|
+
};
|
|
13339
|
+
}
|
|
13340
|
+
function parserBaseObjectTypeToString(arg, tabulation) {
|
|
13341
|
+
const options = arg.properties ? arg.properties : {};
|
|
13342
|
+
return internalParserToString(options, tabulation + 1);
|
|
13343
|
+
}
|
|
13344
|
+
function getTabulation(n, header = false) {
|
|
13345
|
+
let out = "";
|
|
13346
|
+
for (let i = 0; i < n; i++) {
|
|
13347
|
+
out += header ? "-|" : "| ";
|
|
13348
|
+
}
|
|
13349
|
+
return out;
|
|
13350
|
+
}
|
|
13351
|
+
|
|
13352
|
+
// src/bin/generate-doc.ts
|
|
13353
|
+
async function getDocOutput(router, fileMap, generateDocAll, generateDocType) {
|
|
13354
|
+
const fileMapAPIRouteList = Object.keys(fileMap).map((f) => fileMap[f]).filter((fMap) => fMap.previewMethod === "api").map((fMap) => fMap.routes);
|
|
13355
|
+
const jsonDoc = router.getJSONDoc();
|
|
13356
|
+
if (!generateDocAll) {
|
|
13357
|
+
Object.keys(jsonDoc).forEach((path) => {
|
|
13358
|
+
const methods = Object.keys(jsonDoc[path]);
|
|
13359
|
+
methods.forEach((method) => {
|
|
13360
|
+
const data = jsonDoc[path][method];
|
|
13361
|
+
if (fileMapAPIRouteList.filter((f) => {
|
|
13362
|
+
for (const r of f) {
|
|
13363
|
+
if (r.method === String(method).toUpperCase() && r.path === path) {
|
|
13364
|
+
return true;
|
|
13365
|
+
}
|
|
13366
|
+
}
|
|
13367
|
+
return false;
|
|
13368
|
+
}).length === 0) {
|
|
13369
|
+
delete jsonDoc[path][method];
|
|
13370
|
+
} else {
|
|
13371
|
+
}
|
|
13372
|
+
});
|
|
13373
|
+
});
|
|
13374
|
+
}
|
|
13375
|
+
switch (generateDocType) {
|
|
13376
|
+
case "JSON":
|
|
13377
|
+
return JSON.stringify(jsonDoc, void 0, 2);
|
|
13378
|
+
break;
|
|
13379
|
+
case "MD":
|
|
13380
|
+
return await getMDDoc({ showFilePath: true, jsonDoc });
|
|
13381
|
+
break;
|
|
13382
|
+
case "HTML":
|
|
13383
|
+
const md = await getMDDoc({ showFilePath: true, jsonDoc });
|
|
13384
|
+
const html = inflateMDString2HTML(md);
|
|
13385
|
+
return html;
|
|
13386
|
+
break;
|
|
13387
|
+
default:
|
|
13388
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
13389
|
+
}
|
|
13390
|
+
}
|
|
13391
|
+
|
|
13392
|
+
// src/inflate/setup.doc.ts
|
|
13393
|
+
async function setupDoc(logger, servicePath, service, mainRouter, fileMap, inflateDir, errors) {
|
|
13394
|
+
const docPath = getDocConfigPath(servicePath);
|
|
13395
|
+
if (docPath) {
|
|
13396
|
+
try {
|
|
13397
|
+
const docModule = await importDocConfigModule(docPath, logger);
|
|
13398
|
+
logger.debug("setting up error handling from [%s]", (0, import_node_path16.join)(service, (0, import_node_path16.basename)(docPath)));
|
|
13399
|
+
if (docModule && docModule.publish) {
|
|
13400
|
+
const paths = Object.keys(docModule.publish);
|
|
13401
|
+
for (const path of paths) {
|
|
13402
|
+
const config = docModule.publish[path];
|
|
13403
|
+
const body = await getDocOutput(mainRouter, fileMap, config.all, config.type);
|
|
13404
|
+
mainRouter.get(path, async (_, res) => {
|
|
13405
|
+
switch (config.type) {
|
|
13406
|
+
case "MD": {
|
|
13407
|
+
const contentType = CONTENT_TYPE_MAP[".md"];
|
|
13408
|
+
return await res.asyncEnd({
|
|
13409
|
+
headers: {
|
|
13410
|
+
"content-type": contentType
|
|
13411
|
+
},
|
|
13412
|
+
status: 200,
|
|
13413
|
+
body
|
|
13414
|
+
});
|
|
13415
|
+
}
|
|
13416
|
+
case "JSON": {
|
|
13417
|
+
return await res.json(body);
|
|
13418
|
+
}
|
|
13419
|
+
case "HTML": {
|
|
13420
|
+
return await res.html(body);
|
|
13421
|
+
}
|
|
13422
|
+
default:
|
|
13423
|
+
return true;
|
|
13424
|
+
}
|
|
13425
|
+
});
|
|
13426
|
+
if (inflateDir) {
|
|
13427
|
+
const inflatePath = (0, import_node_path16.join)(inflateDir, service, "static", path);
|
|
13428
|
+
(0, import_node_fs15.mkdirSync)((0, import_node_path16.dirname)(inflatePath), {
|
|
13429
|
+
recursive: true
|
|
13430
|
+
});
|
|
13431
|
+
logger.log("writing [%s]", (0, import_node_path16.relative)((0, import_node_process12.cwd)(), inflatePath));
|
|
13432
|
+
(0, import_node_fs15.writeFileSync)(inflatePath, body);
|
|
13433
|
+
}
|
|
13434
|
+
}
|
|
13435
|
+
}
|
|
13436
|
+
} catch (e) {
|
|
13437
|
+
errors.push({
|
|
13438
|
+
filePath: docPath,
|
|
13439
|
+
error: e
|
|
13440
|
+
});
|
|
13441
|
+
logger.error("error with " + docPath);
|
|
13442
|
+
logger.error(e);
|
|
13443
|
+
}
|
|
13444
|
+
}
|
|
13445
|
+
return null;
|
|
13446
|
+
}
|
|
13447
|
+
|
|
12917
13448
|
// src/inflate/inflate.ts
|
|
12918
13449
|
async function inflateApp({
|
|
12919
13450
|
serverInterface,
|
|
@@ -12941,6 +13472,7 @@ async function inflateApp({
|
|
|
12941
13472
|
...routeFileMap,
|
|
12942
13473
|
...serviceRouteFileMap
|
|
12943
13474
|
};
|
|
13475
|
+
await setupDoc(logger, servicePath, service, router, routeFileMap, inflateDir, errors);
|
|
12944
13476
|
await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : void 0, errors);
|
|
12945
13477
|
if (inflateDir && inflateSea) {
|
|
12946
13478
|
await inflateServiceForSea(logger, inflateDir, service, servicePath, serviceRouteFileMap, serviceStaticFileMap);
|
|
@@ -12954,9 +13486,9 @@ async function inflateApp({
|
|
|
12954
13486
|
}
|
|
12955
13487
|
|
|
12956
13488
|
// src/inflate/setup-server-config.ts
|
|
12957
|
-
var
|
|
12958
|
-
var
|
|
12959
|
-
var
|
|
13489
|
+
var import_node_fs16 = require("node:fs");
|
|
13490
|
+
var import_node_path17 = require("node:path");
|
|
13491
|
+
var import_node_process13 = require("node:process");
|
|
12960
13492
|
async function setupServerConfig(logger, servicePath, service, serverConfigMap, inflateDir, errors) {
|
|
12961
13493
|
const serverPath = getServerConfigPath(servicePath);
|
|
12962
13494
|
if (serverPath) {
|
|
@@ -12964,12 +13496,12 @@ async function setupServerConfig(logger, servicePath, service, serverConfigMap,
|
|
|
12964
13496
|
const serverConfig = await importServerConfigModule(serverPath, logger);
|
|
12965
13497
|
serverConfigMap[service] = serverConfig;
|
|
12966
13498
|
if (inflateDir) {
|
|
12967
|
-
const inflatePath = (0,
|
|
12968
|
-
(0,
|
|
13499
|
+
const inflatePath = (0, import_node_path17.resolve)(inflateDir, service, "server.js");
|
|
13500
|
+
(0, import_node_fs16.mkdirSync)((0, import_node_path17.dirname)(inflatePath), {
|
|
12969
13501
|
recursive: true
|
|
12970
13502
|
});
|
|
12971
|
-
logger.log("writing [%s]", (0,
|
|
12972
|
-
(0,
|
|
13503
|
+
logger.log("writing [%s]", (0, import_node_path17.relative)((0, import_node_process13.cwd)(), inflatePath));
|
|
13504
|
+
(0, import_node_fs16.writeFileSync)(inflatePath, await inflateJSX(serverPath, {
|
|
12973
13505
|
embemedJSX: false,
|
|
12974
13506
|
minify: false,
|
|
12975
13507
|
useExport: true,
|
|
@@ -13006,8 +13538,8 @@ var ws_default = {
|
|
|
13006
13538
|
// editor/server.ts
|
|
13007
13539
|
var import_node_crypto4 = require("node:crypto");
|
|
13008
13540
|
init_constants();
|
|
13009
|
-
var
|
|
13010
|
-
var
|
|
13541
|
+
var import_node_fs17 = require("node:fs");
|
|
13542
|
+
var import_node_path18 = require("node:path");
|
|
13011
13543
|
|
|
13012
13544
|
// editor/auth.ts
|
|
13013
13545
|
var ADMIN_EDITOR_AUTH_KEY = "$$ADMIN_EDITOR_AUTH_KEY$$";
|
|
@@ -13057,10 +13589,10 @@ var server_default = {
|
|
|
13057
13589
|
if (serverInterface?.isPrimaryWorker()) {
|
|
13058
13590
|
const cache = adminInterface ? adminInterface.getCache() : serverInterface.cache;
|
|
13059
13591
|
if (!cache.has(ADMIN_EDITOR_AUTH_KEY)) {
|
|
13060
|
-
const adminKEYPath = (0,
|
|
13061
|
-
if ((0,
|
|
13062
|
-
serverInterface.logger.warn("loading static ADMIN_KEY from [%s]", (0,
|
|
13063
|
-
cache.set(ADMIN_EDITOR_AUTH_KEY, (0,
|
|
13592
|
+
const adminKEYPath = (0, import_node_path18.resolve)(".admin_key");
|
|
13593
|
+
if ((0, import_node_fs17.existsSync)(adminKEYPath)) {
|
|
13594
|
+
serverInterface.logger.warn("loading static ADMIN_KEY from [%s]", (0, import_node_path18.relative)(process.cwd(), adminKEYPath));
|
|
13595
|
+
cache.set(ADMIN_EDITOR_AUTH_KEY, (0, import_node_fs17.readFileSync)(adminKEYPath).toString().trim());
|
|
13064
13596
|
} else {
|
|
13065
13597
|
cache.set(ADMIN_EDITOR_AUTH_KEY, (0, import_node_crypto4.randomUUID)());
|
|
13066
13598
|
}
|
|
@@ -13170,8 +13702,8 @@ function getHandler(router) {
|
|
|
13170
13702
|
}
|
|
13171
13703
|
|
|
13172
13704
|
// src/common/watch.ts
|
|
13173
|
-
var
|
|
13174
|
-
var
|
|
13705
|
+
var import_node_fs23 = require("node:fs");
|
|
13706
|
+
var import_node_path26 = require("node:path");
|
|
13175
13707
|
async function watchAndServer(app) {
|
|
13176
13708
|
let timeout;
|
|
13177
13709
|
const watchLogger = app.logger;
|
|
@@ -13200,13 +13732,13 @@ async function watchAndServer(app) {
|
|
|
13200
13732
|
}, 2e3);
|
|
13201
13733
|
}
|
|
13202
13734
|
function watchDir(toWatch) {
|
|
13203
|
-
const files = (0,
|
|
13735
|
+
const files = (0, import_node_fs23.existsSync)(toWatch) ? (0, import_node_fs23.readdirSync)(toWatch) : [];
|
|
13204
13736
|
for (const file of files) {
|
|
13205
|
-
const filePath = (0,
|
|
13206
|
-
if ((0,
|
|
13737
|
+
const filePath = (0, import_node_path26.resolve)(toWatch, file);
|
|
13738
|
+
if ((0, import_node_fs23.statSync)(filePath).isDirectory()) {
|
|
13207
13739
|
watchDir(filePath);
|
|
13208
13740
|
} else {
|
|
13209
|
-
watchers.push((0,
|
|
13741
|
+
watchers.push((0, import_node_fs23.watch)(filePath, watchHandler));
|
|
13210
13742
|
}
|
|
13211
13743
|
}
|
|
13212
13744
|
}
|
|
@@ -13219,7 +13751,7 @@ async function watchAndServer(app) {
|
|
|
13219
13751
|
function reWatch() {
|
|
13220
13752
|
stopWatch();
|
|
13221
13753
|
for (const service of app.options.services) {
|
|
13222
|
-
const toWatch = (0,
|
|
13754
|
+
const toWatch = (0, import_node_path26.resolve)(process.cwd(), service);
|
|
13223
13755
|
watchDir(toWatch);
|
|
13224
13756
|
}
|
|
13225
13757
|
}
|
|
@@ -13233,30 +13765,30 @@ async function watchAndServer(app) {
|
|
|
13233
13765
|
}
|
|
13234
13766
|
|
|
13235
13767
|
// src/common/exit.ts
|
|
13236
|
-
var
|
|
13237
|
-
var
|
|
13768
|
+
var import_node_fs24 = require("node:fs");
|
|
13769
|
+
var import_node_path27 = require("node:path");
|
|
13238
13770
|
function cleanJSX(app) {
|
|
13239
13771
|
app.logger?.trace("trying to clean up esbuild installation at [%s]", getESBuildBinaryPath());
|
|
13240
|
-
if ((0,
|
|
13241
|
-
(0,
|
|
13772
|
+
if ((0, import_node_fs24.existsSync)(getESBuildBinaryPath())) {
|
|
13773
|
+
(0, import_node_fs24.unlinkSync)(getESBuildBinaryPath());
|
|
13242
13774
|
}
|
|
13243
13775
|
if (CLEAR_JSX_CACHE) {
|
|
13244
13776
|
app.logger?.trace("trying to clean up jsx.js installation at [%s]", getJSXJSPath());
|
|
13245
|
-
if ((0,
|
|
13246
|
-
(0,
|
|
13777
|
+
if ((0, import_node_fs24.existsSync)(getJSXJSPath())) {
|
|
13778
|
+
(0, import_node_fs24.unlinkSync)(getJSXJSPath());
|
|
13247
13779
|
}
|
|
13248
|
-
const buildParendDir = (0,
|
|
13780
|
+
const buildParendDir = (0, import_node_path27.resolve)(JSX_TMP_DIR, String(process.pid));
|
|
13249
13781
|
app.logger?.trace("trying to clean up jsx build/import folders at [%s]", buildParendDir);
|
|
13250
|
-
const buildDir = (0,
|
|
13251
|
-
const importDir = (0,
|
|
13252
|
-
if ((0,
|
|
13253
|
-
(0,
|
|
13782
|
+
const buildDir = (0, import_node_path27.resolve)(buildParendDir, "build");
|
|
13783
|
+
const importDir = (0, import_node_path27.resolve)(buildParendDir, "import");
|
|
13784
|
+
if ((0, import_node_fs24.existsSync)(buildDir)) {
|
|
13785
|
+
(0, import_node_fs24.rmdirSync)(buildDir);
|
|
13254
13786
|
}
|
|
13255
|
-
if ((0,
|
|
13256
|
-
(0,
|
|
13787
|
+
if ((0, import_node_fs24.existsSync)(importDir)) {
|
|
13788
|
+
(0, import_node_fs24.rmdirSync)(importDir);
|
|
13257
13789
|
}
|
|
13258
|
-
if ((0,
|
|
13259
|
-
(0,
|
|
13790
|
+
if ((0, import_node_fs24.existsSync)(buildParendDir)) {
|
|
13791
|
+
(0, import_node_fs24.rmdirSync)(buildParendDir);
|
|
13260
13792
|
}
|
|
13261
13793
|
}
|
|
13262
13794
|
}
|
|
@@ -13297,9 +13829,9 @@ function setupExitHandlers(app) {
|
|
|
13297
13829
|
}
|
|
13298
13830
|
|
|
13299
13831
|
// src/inflate/setup-db.ts
|
|
13300
|
-
var
|
|
13301
|
-
var
|
|
13302
|
-
var
|
|
13832
|
+
var import_node_path28 = require("node:path");
|
|
13833
|
+
var import_node_fs25 = require("node:fs");
|
|
13834
|
+
var import_node_process15 = require("node:process");
|
|
13303
13835
|
async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors) {
|
|
13304
13836
|
const servicePath = getServicePath(service);
|
|
13305
13837
|
const dbConfigPath = getDBConfigPath(servicePath);
|
|
@@ -13315,12 +13847,12 @@ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors
|
|
|
13315
13847
|
}
|
|
13316
13848
|
if (config) {
|
|
13317
13849
|
if (inflateDir) {
|
|
13318
|
-
const inflatePath = (0,
|
|
13319
|
-
(0,
|
|
13850
|
+
const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "db.js");
|
|
13851
|
+
(0, import_node_fs25.mkdirSync)((0, import_node_path28.dirname)(inflatePath), {
|
|
13320
13852
|
recursive: true
|
|
13321
13853
|
});
|
|
13322
|
-
logger.log("writing [%s]", (0,
|
|
13323
|
-
(0,
|
|
13854
|
+
logger.log("writing [%s]", (0, import_node_path28.relative)((0, import_node_process15.cwd)(), inflatePath));
|
|
13855
|
+
(0, import_node_fs25.writeFileSync)(inflatePath, await inflateJSX(dbConfigPath, {
|
|
13324
13856
|
embemedJSX: false,
|
|
13325
13857
|
minify: false,
|
|
13326
13858
|
useExport: true,
|
|
@@ -13349,7 +13881,7 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
|
|
|
13349
13881
|
const serviceMigrations = lib_exports.getSortedMigrations(migrationsFolderPath);
|
|
13350
13882
|
const migrationModules = [];
|
|
13351
13883
|
for (const migrationName of serviceMigrations) {
|
|
13352
|
-
const migrationPath = (0,
|
|
13884
|
+
const migrationPath = (0, import_node_path28.resolve)(migrationsFolderPath, migrationName);
|
|
13353
13885
|
try {
|
|
13354
13886
|
const migrationModule = await importMigrationModule(migrationPath);
|
|
13355
13887
|
migrationModules.push({
|
|
@@ -13359,12 +13891,12 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
|
|
|
13359
13891
|
...migrationModule
|
|
13360
13892
|
});
|
|
13361
13893
|
if (inflateDir) {
|
|
13362
|
-
const inflatePath = (0,
|
|
13363
|
-
(0,
|
|
13894
|
+
const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - (0, import_node_path28.extname)(migrationName).length) + ".js");
|
|
13895
|
+
(0, import_node_fs25.mkdirSync)((0, import_node_path28.dirname)(inflatePath), {
|
|
13364
13896
|
recursive: true
|
|
13365
13897
|
});
|
|
13366
|
-
logger?.log("writing [%s]", (0,
|
|
13367
|
-
(0,
|
|
13898
|
+
logger?.log("writing [%s]", (0, import_node_path28.relative)((0, import_node_process15.cwd)(), inflatePath));
|
|
13899
|
+
(0, import_node_fs25.writeFileSync)(inflatePath, await inflateJSX((0, import_node_path28.resolve)(migrationsFolderPath, migrationName), {
|
|
13368
13900
|
embemedJSX: false,
|
|
13369
13901
|
minify: false,
|
|
13370
13902
|
useExport: true,
|
|
@@ -13467,7 +13999,8 @@ var ServerInterfaceImpl = class {
|
|
|
13467
13999
|
};
|
|
13468
14000
|
|
|
13469
14001
|
// src/common/arguments.ts
|
|
13470
|
-
var
|
|
14002
|
+
var import_node_fs26 = require("node:fs");
|
|
14003
|
+
var import_node_path29 = require("node:path");
|
|
13471
14004
|
|
|
13472
14005
|
// src/common/help.ts
|
|
13473
14006
|
var BIN_NAME = "miqro";
|
|
@@ -13484,6 +14017,25 @@ CLUSTER_COUNT=10 ${BIN_NAME}-cluster --service api/`;
|
|
|
13484
14017
|
|
|
13485
14018
|
// src/common/arguments.ts
|
|
13486
14019
|
var import_node_sea2 = require("node:sea");
|
|
14020
|
+
var parser3 = new Parser();
|
|
14021
|
+
var MiqroJSONSchema = {
|
|
14022
|
+
type: "object",
|
|
14023
|
+
properties: {
|
|
14024
|
+
name: "string?",
|
|
14025
|
+
services: "string[]?",
|
|
14026
|
+
port: "number?|string?",
|
|
14027
|
+
inflateDir: "string?"
|
|
14028
|
+
}
|
|
14029
|
+
};
|
|
14030
|
+
function importMiqroJSON(inFile) {
|
|
14031
|
+
const mod = JSON.parse((0, import_node_fs26.readFileSync)(inFile).toString());
|
|
14032
|
+
const module2 = parser3.parse(mod, MiqroJSONSchema, (0, import_node_path29.basename)(inFile));
|
|
14033
|
+
if (module2 !== void 0) {
|
|
14034
|
+
return module2;
|
|
14035
|
+
} else {
|
|
14036
|
+
throw new Error(`error loading [${inFile}] undefined`);
|
|
14037
|
+
}
|
|
14038
|
+
}
|
|
13487
14039
|
function getPORT() {
|
|
13488
14040
|
return checkEnvVariable("PORT", "8080");
|
|
13489
14041
|
}
|
|
@@ -13593,6 +14145,8 @@ function createAdminInterface(app) {
|
|
|
13593
14145
|
}
|
|
13594
14146
|
|
|
13595
14147
|
// src/services/app.ts
|
|
14148
|
+
var import_node_path30 = require("node:path");
|
|
14149
|
+
var import_node_process16 = require("node:process");
|
|
13596
14150
|
var MiqroApplicationMessageType = "$$$MiqroApplicationMessageType$$$";
|
|
13597
14151
|
var Miqro = class _Miqro {
|
|
13598
14152
|
status = "stopped";
|
|
@@ -13668,6 +14222,21 @@ var Miqro = class _Miqro {
|
|
|
13668
14222
|
this.adminInterface = createAdminInterface(this);
|
|
13669
14223
|
setupExitHandlers(this);
|
|
13670
14224
|
}
|
|
14225
|
+
static async import(inFile, options, inflate) {
|
|
14226
|
+
const miqroJSON = importMiqroJSON((0, import_node_path30.resolve)(inFile));
|
|
14227
|
+
const miqroJSONDir = (0, import_node_path30.dirname)((0, import_node_path30.resolve)(inFile));
|
|
14228
|
+
const app = new _Miqro({
|
|
14229
|
+
name: miqroJSON.name ? miqroJSON.name : void 0,
|
|
14230
|
+
port: miqroJSON.port ? String(miqroJSON.port) : void 0,
|
|
14231
|
+
services: miqroJSON.services ? miqroJSON.services.map((s) => (0, import_node_path30.join)((0, import_node_path30.relative)((0, import_node_process16.cwd)(), miqroJSONDir), s)) : void 0,
|
|
14232
|
+
...options ? options : {}
|
|
14233
|
+
});
|
|
14234
|
+
await app.inflate({
|
|
14235
|
+
inflateDir: miqroJSON.inflateDir ? String(miqroJSON.inflateDir) : void 0,
|
|
14236
|
+
...inflate ? inflate : {}
|
|
14237
|
+
});
|
|
14238
|
+
return app;
|
|
14239
|
+
}
|
|
13671
14240
|
connect() {
|
|
13672
14241
|
if (process.send) {
|
|
13673
14242
|
process.removeListener("message", this.listener);
|
|
@@ -13798,9 +14367,9 @@ var Miqro = class _Miqro {
|
|
|
13798
14367
|
serverConfigMap[EDITOR_CONFIG_KEY] = server_default;
|
|
13799
14368
|
}
|
|
13800
14369
|
if (this.options?.hotreload) {
|
|
13801
|
-
this.logger?.debug("setting up websocket on [
|
|
14370
|
+
this.logger?.debug("setting up websocket on [%s]", HOT_RELOAD_PATH);
|
|
13802
14371
|
wsConfigList.push({
|
|
13803
|
-
path:
|
|
14372
|
+
path: HOT_RELOAD_PATH
|
|
13804
14373
|
});
|
|
13805
14374
|
}
|
|
13806
14375
|
await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, serverConfigMap, "preload");
|
|
@@ -14024,7 +14593,7 @@ function reloadInflatedRouter(app) {
|
|
|
14024
14593
|
async function notifiyServerConfig(logger, serverInterface, adminInterface, serverConfigMap, method) {
|
|
14025
14594
|
if (serverConfigMap) {
|
|
14026
14595
|
await Promise.allSettled(Object.keys(serverConfigMap).map((name) => {
|
|
14027
|
-
return new Promise(async (
|
|
14596
|
+
return new Promise(async (resolve24) => {
|
|
14028
14597
|
try {
|
|
14029
14598
|
const serverConfig = serverConfigMap[name];
|
|
14030
14599
|
if (serverConfig && serverConfig[method]) {
|
|
@@ -14034,10 +14603,10 @@ async function notifiyServerConfig(logger, serverInterface, adminInterface, serv
|
|
|
14034
14603
|
await serverConfig[method](serverInterface);
|
|
14035
14604
|
}
|
|
14036
14605
|
}
|
|
14037
|
-
|
|
14606
|
+
resolve24();
|
|
14038
14607
|
} catch (e) {
|
|
14039
14608
|
logger?.error(e);
|
|
14040
|
-
|
|
14609
|
+
resolve24();
|
|
14041
14610
|
}
|
|
14042
14611
|
});
|
|
14043
14612
|
}));
|
|
@@ -14061,10 +14630,10 @@ function notifiyServerConfigSync(app, method) {
|
|
|
14061
14630
|
}
|
|
14062
14631
|
|
|
14063
14632
|
// src/inflate/utils/sea-utils.ts
|
|
14064
|
-
var
|
|
14633
|
+
var import_node_path31 = require("node:path");
|
|
14065
14634
|
async function appendAPIModule(router, dir, filePath, module2) {
|
|
14066
14635
|
const file = describeFilePath(filePath);
|
|
14067
|
-
const routes = getRoutes((0,
|
|
14636
|
+
const routes = getRoutes((0, import_node_path31.join)("/", (0, import_node_path31.dirname)((0, import_node_path31.relative)(dir, file.filePath))), file.subName, module2);
|
|
14068
14637
|
for (const r of routes) {
|
|
14069
14638
|
router.use(assertGlobalTampered);
|
|
14070
14639
|
router.use(module2.handler, r.path, r.method, r.options);
|