miqro 6.2.11 → 6.2.13
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/build/editor.bundle.js +4 -5
- package/build/esm/src/common/arguments.d.ts +2 -0
- package/build/esm/src/common/arguments.js +31 -1
- package/build/esm/src/common/fs.d.ts +6 -0
- package/build/esm/src/common/fs.js +69 -0
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +1 -0
- package/build/esm/src/common/jsx.js +22 -22
- package/build/esm/src/inflate/inflate-sea.js +17 -2
- package/build/esm/src/inflate/inflate.d.ts +2 -1
- package/build/esm/src/inflate/inflate.js +2 -2
- package/build/esm/src/inflate/setup-http.d.ts +1 -1
- package/build/esm/src/inflate/setup-http.js +125 -89
- package/build/esm/src/main.js +13 -5
- package/build/esm/src/services/app.d.ts +1 -0
- package/build/esm/src/services/app.js +3 -1
- package/build/jsx.dom.js +34 -36
- package/build/lib.cjs +343 -225
- package/package.json +1 -1
- package/sea/basic-compile.base64.sh +1 -1
- package/sea/basic-compile.sh +1 -1
- package/src/common/arguments.ts +34 -1
- package/src/common/fs.ts +65 -0
- package/src/common/help.ts +1 -0
- package/src/common/jsx.ts +22 -22
- package/src/inflate/inflate-sea.ts +18 -2
- package/src/inflate/inflate.ts +3 -2
- package/src/inflate/setup-http.ts +127 -91
- package/src/main.ts +13 -5
- package/src/services/app.ts +4 -1
package/build/lib.cjs
CHANGED
|
@@ -4093,7 +4093,7 @@ var write_api_exports = {};
|
|
|
4093
4093
|
__export(write_api_exports, {
|
|
4094
4094
|
default: () => write_api_default
|
|
4095
4095
|
});
|
|
4096
|
-
async function
|
|
4096
|
+
async function writeFile3(path, contents, override) {
|
|
4097
4097
|
if ((0, import_node_fs20.existsSync)(getPath(path)) && !override) {
|
|
4098
4098
|
throw new Error("file already exists!");
|
|
4099
4099
|
}
|
|
@@ -4128,7 +4128,7 @@ var init_write_api = __esm({
|
|
|
4128
4128
|
},
|
|
4129
4129
|
handler: async (req, res) => {
|
|
4130
4130
|
const { path, contents, override } = req.body;
|
|
4131
|
-
await
|
|
4131
|
+
await writeFile3(path, contents, override);
|
|
4132
4132
|
return res.json({
|
|
4133
4133
|
message: "OK"
|
|
4134
4134
|
});
|
|
@@ -9405,7 +9405,7 @@ var CONTENT_TYPE_MAP = {
|
|
|
9405
9405
|
".7z": "application/x-7z-compressed"
|
|
9406
9406
|
};
|
|
9407
9407
|
|
|
9408
|
-
//
|
|
9408
|
+
// node_modules/@miqro/jsx/build/esm/vdom/log.js
|
|
9409
9409
|
var debugLogEnabled = false;
|
|
9410
9410
|
function debug(runtime, message2, ...args) {
|
|
9411
9411
|
if (debugLogEnabled) {
|
|
@@ -9419,7 +9419,7 @@ function enableDebugLog() {
|
|
|
9419
9419
|
debugLogEnabled = true;
|
|
9420
9420
|
}
|
|
9421
9421
|
|
|
9422
|
-
//
|
|
9422
|
+
// node_modules/@miqro/jsx/build/esm/vdom/actions.js
|
|
9423
9423
|
function createAppendAction(node, runtime) {
|
|
9424
9424
|
return {
|
|
9425
9425
|
isDestructive: true,
|
|
@@ -9702,7 +9702,7 @@ function createSetInnerHTMLAction(node, innerHTML, runtime) {
|
|
|
9702
9702
|
};
|
|
9703
9703
|
}
|
|
9704
9704
|
|
|
9705
|
-
//
|
|
9705
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/base-node.js
|
|
9706
9706
|
var BaseNode = class {
|
|
9707
9707
|
type;
|
|
9708
9708
|
parent;
|
|
@@ -9810,7 +9810,7 @@ function getDefaultOptions() {
|
|
|
9810
9810
|
return DEFAULT_OPTIONS;
|
|
9811
9811
|
}
|
|
9812
9812
|
|
|
9813
|
-
//
|
|
9813
|
+
// node_modules/@miqro/jsx/build/esm/jsx.js
|
|
9814
9814
|
var Fragment = Symbol("Fragment");
|
|
9815
9815
|
function createElement(tag2, attributes, ...children) {
|
|
9816
9816
|
if (!tag2) {
|
|
@@ -9863,10 +9863,10 @@ objectDefineProperty(JSX, "jsxFragmentFactory", {
|
|
|
9863
9863
|
});
|
|
9864
9864
|
Object.freeze(JSX);
|
|
9865
9865
|
|
|
9866
|
-
//
|
|
9866
|
+
// node_modules/@miqro/jsx/build/esm/vdom/types.js
|
|
9867
9867
|
var CHANGE_TYPES_SET = /* @__PURE__ */ new Set(["FragmentComponent", "Component", "Element", "Ref", "Fragment", "ContextProvider"]);
|
|
9868
9868
|
|
|
9869
|
-
//
|
|
9869
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/context-provider.js
|
|
9870
9870
|
var ContextProvider = class extends BaseNode {
|
|
9871
9871
|
constructor(parent) {
|
|
9872
9872
|
super("ContextProvider", parent);
|
|
@@ -9890,7 +9890,7 @@ var ContextProvider = class extends BaseNode {
|
|
|
9890
9890
|
}
|
|
9891
9891
|
};
|
|
9892
9892
|
|
|
9893
|
-
//
|
|
9893
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/fragment.js
|
|
9894
9894
|
var Fragment2 = class extends BaseNode {
|
|
9895
9895
|
constructor(parent) {
|
|
9896
9896
|
super("Fragment", parent);
|
|
@@ -9906,7 +9906,7 @@ var Fragment2 = class extends BaseNode {
|
|
|
9906
9906
|
}
|
|
9907
9907
|
};
|
|
9908
9908
|
|
|
9909
|
-
//
|
|
9909
|
+
// node_modules/@miqro/jsx/build/esm/component/render.js
|
|
9910
9910
|
var currentContext = null;
|
|
9911
9911
|
function useConditional(name) {
|
|
9912
9912
|
return pushContextCall(currentContext, name);
|
|
@@ -9977,7 +9977,7 @@ function pushContextCall(context, name) {
|
|
|
9977
9977
|
return key;
|
|
9978
9978
|
}
|
|
9979
9979
|
|
|
9980
|
-
//
|
|
9980
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/component-fragment.js
|
|
9981
9981
|
var FragmentComponent = class extends Fragment2 {
|
|
9982
9982
|
constructor(parent) {
|
|
9983
9983
|
super(parent);
|
|
@@ -10013,7 +10013,7 @@ var FragmentComponent = class extends Fragment2 {
|
|
|
10013
10013
|
}
|
|
10014
10014
|
};
|
|
10015
10015
|
|
|
10016
|
-
//
|
|
10016
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/element.js
|
|
10017
10017
|
var ATTRIBUTES_WITHOUT_VALUE = /* @__PURE__ */ new Set([
|
|
10018
10018
|
"disabled",
|
|
10019
10019
|
"checked",
|
|
@@ -10144,7 +10144,7 @@ var Element = class extends BaseNode {
|
|
|
10144
10144
|
}
|
|
10145
10145
|
};
|
|
10146
10146
|
|
|
10147
|
-
//
|
|
10147
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/component.js
|
|
10148
10148
|
var Component = class extends Element {
|
|
10149
10149
|
constructor(parent) {
|
|
10150
10150
|
super(parent);
|
|
@@ -10195,7 +10195,7 @@ var Component = class extends Element {
|
|
|
10195
10195
|
}
|
|
10196
10196
|
};
|
|
10197
10197
|
|
|
10198
|
-
//
|
|
10198
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/ref.js
|
|
10199
10199
|
var Ref = class extends BaseNode {
|
|
10200
10200
|
constructor(parent) {
|
|
10201
10201
|
super("Ref", parent);
|
|
@@ -10214,7 +10214,7 @@ var Ref = class extends BaseNode {
|
|
|
10214
10214
|
}
|
|
10215
10215
|
};
|
|
10216
10216
|
|
|
10217
|
-
//
|
|
10217
|
+
// node_modules/@miqro/jsx/build/esm/vdom/nodes/text.js
|
|
10218
10218
|
var Text = class extends BaseNode {
|
|
10219
10219
|
constructor(parent) {
|
|
10220
10220
|
super("Text", parent);
|
|
@@ -10237,7 +10237,7 @@ var Text = class extends BaseNode {
|
|
|
10237
10237
|
}
|
|
10238
10238
|
};
|
|
10239
10239
|
|
|
10240
|
-
//
|
|
10240
|
+
// node_modules/@miqro/jsx/build/esm/vdom/tree.js
|
|
10241
10241
|
var Tree = class extends BaseNode {
|
|
10242
10242
|
name;
|
|
10243
10243
|
constructor(name, ref, runtime, shadowInit) {
|
|
@@ -10297,7 +10297,7 @@ function normalizeChild(runtime, c) {
|
|
|
10297
10297
|
};
|
|
10298
10298
|
}
|
|
10299
10299
|
|
|
10300
|
-
//
|
|
10300
|
+
// node_modules/@miqro/jsx/build/esm/vdom/diff.js
|
|
10301
10301
|
function diff(abortSignal, tree, changes, actions, options, runtime, lo = false) {
|
|
10302
10302
|
if (changes === void 0 || changes === null || abortSignal.aborted) {
|
|
10303
10303
|
return actions;
|
|
@@ -10347,7 +10347,7 @@ function areActionDestructive(actions) {
|
|
|
10347
10347
|
return false;
|
|
10348
10348
|
}
|
|
10349
10349
|
|
|
10350
|
-
//
|
|
10350
|
+
// node_modules/@miqro/jsx/build/esm/vdom/execute.js
|
|
10351
10351
|
function execute(abortSignal, runtime, actions) {
|
|
10352
10352
|
if (abortSignal.aborted) {
|
|
10353
10353
|
return 0;
|
|
@@ -10380,7 +10380,7 @@ function execute(abortSignal, runtime, actions) {
|
|
|
10380
10380
|
return changes;
|
|
10381
10381
|
}
|
|
10382
10382
|
|
|
10383
|
-
//
|
|
10383
|
+
// node_modules/@miqro/jsx/build/esm/vdom/render.js
|
|
10384
10384
|
function render(runtime, tree, treeOptions, change, preActions = [], props, children) {
|
|
10385
10385
|
const meta = tree.state;
|
|
10386
10386
|
if (!meta) {
|
|
@@ -10405,7 +10405,7 @@ function render(runtime, tree, treeOptions, change, preActions = [], props, chil
|
|
|
10405
10405
|
}
|
|
10406
10406
|
}
|
|
10407
10407
|
|
|
10408
|
-
//
|
|
10408
|
+
// node_modules/@miqro/jsx/build/esm/component/container.js
|
|
10409
10409
|
var objectDefineProperty2 = Object.defineProperty;
|
|
10410
10410
|
function createContainer(element, runtime, args) {
|
|
10411
10411
|
const name = `DOMContainer [${String(element)}]`;
|
|
@@ -10449,7 +10449,7 @@ function createContainer(element, runtime, args) {
|
|
|
10449
10449
|
return container;
|
|
10450
10450
|
}
|
|
10451
10451
|
|
|
10452
|
-
//
|
|
10452
|
+
// node_modules/@miqro/jsx/build/esm/hooks/runtime.js
|
|
10453
10453
|
function useRuntime() {
|
|
10454
10454
|
useConditional("useRuntime");
|
|
10455
10455
|
const currentContext2 = useRenderContext();
|
|
@@ -10459,7 +10459,7 @@ function useRuntime() {
|
|
|
10459
10459
|
return currentContext2.runtime;
|
|
10460
10460
|
}
|
|
10461
10461
|
|
|
10462
|
-
//
|
|
10462
|
+
// node_modules/@miqro/jsx/build/esm/hooks/refresh.js
|
|
10463
10463
|
var REFRESH_TIMEOUT_MS = 0;
|
|
10464
10464
|
function useRefresh() {
|
|
10465
10465
|
useConditional("useRefresh");
|
|
@@ -10496,7 +10496,7 @@ function useRefresh() {
|
|
|
10496
10496
|
};
|
|
10497
10497
|
}
|
|
10498
10498
|
|
|
10499
|
-
//
|
|
10499
|
+
// node_modules/@miqro/jsx/build/esm/hooks/state.js
|
|
10500
10500
|
function useState(defaultValue) {
|
|
10501
10501
|
const key = useConditional("useState");
|
|
10502
10502
|
const currentContext2 = useRenderContext();
|
|
@@ -10548,7 +10548,7 @@ function useState(defaultValue) {
|
|
|
10548
10548
|
}
|
|
10549
10549
|
}
|
|
10550
10550
|
|
|
10551
|
-
//
|
|
10551
|
+
// node_modules/@miqro/jsx/build/esm/hooks/effect.js
|
|
10552
10552
|
function useEffect(effect, condition) {
|
|
10553
10553
|
const currentContext2 = useRenderContext();
|
|
10554
10554
|
if (!currentContext2) {
|
|
@@ -10594,7 +10594,7 @@ function equalArray(a, c) {
|
|
|
10594
10594
|
return true;
|
|
10595
10595
|
}
|
|
10596
10596
|
|
|
10597
|
-
//
|
|
10597
|
+
// node_modules/@miqro/jsx/build/esm/hooks/pathname.js
|
|
10598
10598
|
function usePathname() {
|
|
10599
10599
|
const runtime = useRuntime();
|
|
10600
10600
|
const pathname = runtime.getLocation().pathname;
|
|
@@ -10613,7 +10613,7 @@ function usePathname() {
|
|
|
10613
10613
|
return String(currentLocation);
|
|
10614
10614
|
}
|
|
10615
10615
|
|
|
10616
|
-
//
|
|
10616
|
+
// node_modules/@miqro/jsx/build/esm/component/router.js
|
|
10617
10617
|
function useIsLocationPathNameActive(path) {
|
|
10618
10618
|
useConditional("useIsLocationPathNameMatch");
|
|
10619
10619
|
const runtime = useRuntime();
|
|
@@ -10687,7 +10687,7 @@ function normalizePath2(path) {
|
|
|
10687
10687
|
return path;
|
|
10688
10688
|
}
|
|
10689
10689
|
|
|
10690
|
-
//
|
|
10690
|
+
// node_modules/@miqro/jsx/build/esm/hooks/ref.js
|
|
10691
10691
|
function useRef() {
|
|
10692
10692
|
const [ref, setRef] = useState(null);
|
|
10693
10693
|
function useRefFunction(newRef) {
|
|
@@ -10698,24 +10698,23 @@ function useRef() {
|
|
|
10698
10698
|
return useRefFunction;
|
|
10699
10699
|
}
|
|
10700
10700
|
|
|
10701
|
-
//
|
|
10701
|
+
// node_modules/@miqro/jsx/build/esm/hooks/query.js
|
|
10702
10702
|
function useQuery(name, defaultValue, watch2 = true) {
|
|
10703
10703
|
const key = useConditional(`useQuery-${name}-${defaultValue}`);
|
|
10704
10704
|
const runtime = useRuntime();
|
|
10705
10705
|
const [last, setLast, getLast] = useState(getQueryValue(runtime, name, defaultValue));
|
|
10706
10706
|
useEffect(function useQueryEffect() {
|
|
10707
10707
|
if (watch2) {
|
|
10708
|
-
let
|
|
10708
|
+
let useQueryEffectPathListener = function() {
|
|
10709
10709
|
const current = getQueryValue(runtime, name, defaultValue);
|
|
10710
10710
|
if (getLast() !== current) {
|
|
10711
10711
|
debug(runtime, "useQuery listener for %s", key);
|
|
10712
10712
|
setLast(current);
|
|
10713
10713
|
}
|
|
10714
10714
|
};
|
|
10715
|
-
|
|
10716
|
-
runtime.addPathListener(useQueryEffectPathListener2);
|
|
10715
|
+
runtime.addPathListener(useQueryEffectPathListener);
|
|
10717
10716
|
return function useQueryEffectUnLoad() {
|
|
10718
|
-
runtime.removePathListener(
|
|
10717
|
+
runtime.removePathListener(useQueryEffectPathListener);
|
|
10719
10718
|
};
|
|
10720
10719
|
}
|
|
10721
10720
|
}, []);
|
|
@@ -10758,7 +10757,7 @@ function setQueryValue(runtime, name, value, watch2 = true) {
|
|
|
10758
10757
|
}
|
|
10759
10758
|
}
|
|
10760
10759
|
|
|
10761
|
-
//
|
|
10760
|
+
// node_modules/@miqro/jsx/build/esm/hooks/useelement.js
|
|
10762
10761
|
function useElement() {
|
|
10763
10762
|
useConditional("useElement");
|
|
10764
10763
|
const currentContext2 = useRenderContext();
|
|
@@ -10768,7 +10767,7 @@ function useElement() {
|
|
|
10768
10767
|
return currentContext2.node.ref ? currentContext2.node.ref : null;
|
|
10769
10768
|
}
|
|
10770
10769
|
|
|
10771
|
-
//
|
|
10770
|
+
// node_modules/@miqro/jsx/build/esm/hooks/context.js
|
|
10772
10771
|
function createContext(defaultValue) {
|
|
10773
10772
|
const symbol = Symbol();
|
|
10774
10773
|
return {
|
|
@@ -11211,9 +11210,8 @@ var import_os = require("os");
|
|
|
11211
11210
|
var DEFAULT_BUILD_DIR = (0, import_os.tmpdir)();
|
|
11212
11211
|
|
|
11213
11212
|
// src/common/jsx.ts
|
|
11214
|
-
var
|
|
11213
|
+
var import_node_path6 = require("node:path");
|
|
11215
11214
|
var import_node_crypto4 = require("node:crypto");
|
|
11216
|
-
var import_node_fs6 = require("node:fs");
|
|
11217
11215
|
var import_node_process3 = require("node:process");
|
|
11218
11216
|
|
|
11219
11217
|
// src/common/esbuild.ts
|
|
@@ -11420,6 +11418,13 @@ function getErrorConfigPath(servicePath) {
|
|
|
11420
11418
|
function getDocConfigPath(servicePath) {
|
|
11421
11419
|
return getFilePath(servicePath, "doc", EXTENSIONS);
|
|
11422
11420
|
}
|
|
11421
|
+
function getMiqroJSONPath() {
|
|
11422
|
+
const miqroRCPath = (0, import_node_path3.resolve)((0, import_node_process2.cwd)(), "miqro.json");
|
|
11423
|
+
if ((0, import_node_fs4.existsSync)(miqroRCPath) && !(0, import_node_fs4.statSync)(miqroRCPath).isDirectory()) {
|
|
11424
|
+
return miqroRCPath;
|
|
11425
|
+
}
|
|
11426
|
+
return false;
|
|
11427
|
+
}
|
|
11423
11428
|
function getAuthConfigPath(servicePath) {
|
|
11424
11429
|
return getFilePath(servicePath, "auth", EXTENSIONS);
|
|
11425
11430
|
}
|
|
@@ -14263,6 +14268,85 @@ function assertGlobalTampered() {
|
|
|
14263
14268
|
}
|
|
14264
14269
|
}
|
|
14265
14270
|
|
|
14271
|
+
// src/common/fs.ts
|
|
14272
|
+
var import_node_fs6 = require("node:fs");
|
|
14273
|
+
var import_node_path5 = require("node:path");
|
|
14274
|
+
function describeFilePath(filePath) {
|
|
14275
|
+
const ext = (0, import_node_path5.extname)(filePath);
|
|
14276
|
+
const fileName = (0, import_node_path5.basename)(filePath);
|
|
14277
|
+
const name = fileName.substring(0, fileName.length - ext.length);
|
|
14278
|
+
const subExt = (0, import_node_path5.extname)(name);
|
|
14279
|
+
const subName = name.substring(0, name.length - subExt.length);
|
|
14280
|
+
return {
|
|
14281
|
+
ext,
|
|
14282
|
+
fileName,
|
|
14283
|
+
name,
|
|
14284
|
+
subExt,
|
|
14285
|
+
subName,
|
|
14286
|
+
filePath
|
|
14287
|
+
};
|
|
14288
|
+
}
|
|
14289
|
+
async function mkdirASync(path, options) {
|
|
14290
|
+
return new Promise((resolve24, reject) => {
|
|
14291
|
+
try {
|
|
14292
|
+
(0, import_node_fs6.mkdir)(path, options, (err) => {
|
|
14293
|
+
if (err) {
|
|
14294
|
+
reject(err);
|
|
14295
|
+
} else {
|
|
14296
|
+
resolve24();
|
|
14297
|
+
}
|
|
14298
|
+
});
|
|
14299
|
+
} catch (e) {
|
|
14300
|
+
reject(e);
|
|
14301
|
+
}
|
|
14302
|
+
});
|
|
14303
|
+
}
|
|
14304
|
+
async function writeFileASync(path, body) {
|
|
14305
|
+
return new Promise((resolve24, reject) => {
|
|
14306
|
+
try {
|
|
14307
|
+
(0, import_node_fs6.writeFile)(path, body, (err) => {
|
|
14308
|
+
if (err) {
|
|
14309
|
+
reject(err);
|
|
14310
|
+
} else {
|
|
14311
|
+
resolve24();
|
|
14312
|
+
}
|
|
14313
|
+
});
|
|
14314
|
+
} catch (e) {
|
|
14315
|
+
reject(e);
|
|
14316
|
+
}
|
|
14317
|
+
});
|
|
14318
|
+
}
|
|
14319
|
+
async function rmdirASync(path) {
|
|
14320
|
+
return new Promise((resolve24, reject) => {
|
|
14321
|
+
try {
|
|
14322
|
+
(0, import_node_fs6.rmdir)(path, (err) => {
|
|
14323
|
+
if (err) {
|
|
14324
|
+
reject(err);
|
|
14325
|
+
} else {
|
|
14326
|
+
resolve24();
|
|
14327
|
+
}
|
|
14328
|
+
});
|
|
14329
|
+
} catch (e) {
|
|
14330
|
+
reject(e);
|
|
14331
|
+
}
|
|
14332
|
+
});
|
|
14333
|
+
}
|
|
14334
|
+
async function unlinkASync(path) {
|
|
14335
|
+
return new Promise((resolve24, reject) => {
|
|
14336
|
+
try {
|
|
14337
|
+
(0, import_node_fs6.unlink)(path, (err) => {
|
|
14338
|
+
if (err) {
|
|
14339
|
+
reject(err);
|
|
14340
|
+
} else {
|
|
14341
|
+
resolve24();
|
|
14342
|
+
}
|
|
14343
|
+
});
|
|
14344
|
+
} catch (e) {
|
|
14345
|
+
reject(e);
|
|
14346
|
+
}
|
|
14347
|
+
});
|
|
14348
|
+
}
|
|
14349
|
+
|
|
14266
14350
|
// src/common/jsx.ts
|
|
14267
14351
|
var jsxJSBuffer = null;
|
|
14268
14352
|
var jsxJSBufferChecksumPromise = null;
|
|
@@ -14279,17 +14363,17 @@ var DEFAULT_ESOPTION = {
|
|
|
14279
14363
|
jsxFragment: "JSX.Fragment"
|
|
14280
14364
|
};
|
|
14281
14365
|
async function inflateJSX(inFile, options) {
|
|
14282
|
-
const tmpBuildDir = (0,
|
|
14283
|
-
const inFileTmp = (0,
|
|
14366
|
+
const tmpBuildDir = (0, import_node_path6.resolve)(JSX_TMP_DIR, String(process.pid), "build", Date.now() + "-" + (0, import_node_crypto4.randomUUID)());
|
|
14367
|
+
const inFileTmp = (0, import_node_path6.resolve)(tmpBuildDir, (0, import_node_path6.basename)(inFile) + ".mjs");
|
|
14284
14368
|
const jsxJSPath = getJSXJSPath();
|
|
14285
14369
|
const logger = options.logger;
|
|
14286
14370
|
try {
|
|
14287
14371
|
if (!options.embemedJSX) {
|
|
14288
|
-
|
|
14372
|
+
await mkdirASync(tmpBuildDir, {
|
|
14289
14373
|
recursive: true
|
|
14290
14374
|
});
|
|
14291
|
-
|
|
14292
|
-
logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", (0,
|
|
14375
|
+
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, false, options.useExport));
|
|
14376
|
+
logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", (0, import_node_path6.relative)((0, import_node_process3.cwd)(), inFile), (0, import_node_path6.dirname)((0, import_node_path6.relative)(JSX_TMP_DIR, inFileTmp)));
|
|
14293
14377
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
14294
14378
|
...DEFAULT_ESOPTION,
|
|
14295
14379
|
entryPoints: [inFileTmp],
|
|
@@ -14298,16 +14382,16 @@ async function inflateJSX(inFile, options) {
|
|
|
14298
14382
|
});
|
|
14299
14383
|
if (CLEAR_JSX_CACHE) {
|
|
14300
14384
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14301
|
-
|
|
14302
|
-
|
|
14385
|
+
await unlinkASync(inFileTmp);
|
|
14386
|
+
await rmdirASync(tmpBuildDir);
|
|
14303
14387
|
}
|
|
14304
14388
|
return contents;
|
|
14305
14389
|
} else {
|
|
14306
|
-
|
|
14390
|
+
await mkdirASync(tmpBuildDir, {
|
|
14307
14391
|
recursive: true
|
|
14308
14392
|
});
|
|
14309
|
-
|
|
14310
|
-
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", (0,
|
|
14393
|
+
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
|
|
14394
|
+
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", (0, import_node_path6.relative)((0, import_node_process3.cwd)(), inFile), (0, import_node_path6.dirname)((0, import_node_path6.relative)(JSX_TMP_DIR, inFileTmp)));
|
|
14311
14395
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
14312
14396
|
...DEFAULT_ESOPTION,
|
|
14313
14397
|
entryPoints: [inFileTmp],
|
|
@@ -14316,8 +14400,8 @@ async function inflateJSX(inFile, options) {
|
|
|
14316
14400
|
});
|
|
14317
14401
|
if (CLEAR_JSX_CACHE) {
|
|
14318
14402
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14319
|
-
|
|
14320
|
-
|
|
14403
|
+
await unlinkASync(inFileTmp);
|
|
14404
|
+
await rmdirASync(tmpBuildDir);
|
|
14321
14405
|
}
|
|
14322
14406
|
return contents;
|
|
14323
14407
|
}
|
|
@@ -14327,8 +14411,8 @@ async function inflateJSX(inFile, options) {
|
|
|
14327
14411
|
if (options.embemedJSX) {
|
|
14328
14412
|
if (CLEAR_JSX_CACHE) {
|
|
14329
14413
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14330
|
-
|
|
14331
|
-
|
|
14414
|
+
await unlinkASync(inFileTmp);
|
|
14415
|
+
await rmdirASync(tmpBuildDir);
|
|
14332
14416
|
} else {
|
|
14333
14417
|
logger?.error("error with: %s", inFileTmp);
|
|
14334
14418
|
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
@@ -14500,9 +14584,9 @@ var DocConfigSchema = {
|
|
|
14500
14584
|
}
|
|
14501
14585
|
};
|
|
14502
14586
|
async function importAPIRoute(inFile, logger) {
|
|
14503
|
-
const isCJS = (0,
|
|
14587
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14504
14588
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14505
|
-
const module2 = typeof mod === "function" ? { handler: mod } : parser2.parse(mod, APIRouteSchema, (0,
|
|
14589
|
+
const module2 = typeof mod === "function" ? { handler: mod } : parser2.parse(mod, APIRouteSchema, (0, import_node_path6.basename)(inFile));
|
|
14506
14590
|
if (module2 !== void 0) {
|
|
14507
14591
|
return module2;
|
|
14508
14592
|
} else {
|
|
@@ -14510,9 +14594,9 @@ async function importAPIRoute(inFile, logger) {
|
|
|
14510
14594
|
}
|
|
14511
14595
|
}
|
|
14512
14596
|
async function importMigrationModule(inFile, logger) {
|
|
14513
|
-
const isCJS = (0,
|
|
14597
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14514
14598
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14515
|
-
const module2 = parser2.parse(mod, MigrationSchema, (0,
|
|
14599
|
+
const module2 = parser2.parse(mod, MigrationSchema, (0, import_node_path6.basename)(inFile));
|
|
14516
14600
|
if (module2 !== void 0) {
|
|
14517
14601
|
return module2;
|
|
14518
14602
|
} else {
|
|
@@ -14521,8 +14605,8 @@ async function importMigrationModule(inFile, logger) {
|
|
|
14521
14605
|
}
|
|
14522
14606
|
async function importHTMLModule(inFile, logger) {
|
|
14523
14607
|
const module2 = await importJSXFile(inFile, logger);
|
|
14524
|
-
parser2.parse(module2.default, HTMLModuleSchema.properties.default, `${(0,
|
|
14525
|
-
parser2.parse(module2.apiOptions, APIOptionsSchema, `${(0,
|
|
14608
|
+
parser2.parse(module2.default, HTMLModuleSchema.properties.default, `${(0, import_node_path6.basename)(inFile)}.default`);
|
|
14609
|
+
parser2.parse(module2.apiOptions, APIOptionsSchema, `${(0, import_node_path6.basename)(inFile)}.apiOptions`);
|
|
14526
14610
|
if (module2 !== void 0) {
|
|
14527
14611
|
return module2;
|
|
14528
14612
|
} else {
|
|
@@ -14531,8 +14615,8 @@ async function importHTMLModule(inFile, logger) {
|
|
|
14531
14615
|
}
|
|
14532
14616
|
async function importJSONModule(inFile, logger) {
|
|
14533
14617
|
const module2 = await importJSXFile(inFile, logger);
|
|
14534
|
-
parser2.parse(module2.default, JSONModuleSchema.properties.default, `${(0,
|
|
14535
|
-
parser2.parse(module2.apiOptions, APIOptionsSchema, `${(0,
|
|
14618
|
+
parser2.parse(module2.default, JSONModuleSchema.properties.default, `${(0, import_node_path6.basename)(inFile)}.default`);
|
|
14619
|
+
parser2.parse(module2.apiOptions, APIOptionsSchema, `${(0, import_node_path6.basename)(inFile)}.apiOptions`);
|
|
14536
14620
|
if (module2 !== void 0) {
|
|
14537
14621
|
return module2;
|
|
14538
14622
|
} else {
|
|
@@ -14540,9 +14624,9 @@ async function importJSONModule(inFile, logger) {
|
|
|
14540
14624
|
}
|
|
14541
14625
|
}
|
|
14542
14626
|
async function importAuthModule(inFile, logger) {
|
|
14543
|
-
const isCJS = (0,
|
|
14627
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14544
14628
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14545
|
-
const module2 = parser2.parse(mod, AuthConfigSchema, (0,
|
|
14629
|
+
const module2 = parser2.parse(mod, AuthConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14546
14630
|
if (module2 !== void 0) {
|
|
14547
14631
|
return module2;
|
|
14548
14632
|
} else {
|
|
@@ -14550,9 +14634,9 @@ async function importAuthModule(inFile, logger) {
|
|
|
14550
14634
|
}
|
|
14551
14635
|
}
|
|
14552
14636
|
async function importMiddlewareConfigModule(inFile, logger) {
|
|
14553
|
-
const isCJS = (0,
|
|
14637
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14554
14638
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14555
|
-
const module2 = parser2.parse(mod, MiddlewareConfigSchema, (0,
|
|
14639
|
+
const module2 = parser2.parse(mod, MiddlewareConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14556
14640
|
if (module2 !== void 0) {
|
|
14557
14641
|
return module2;
|
|
14558
14642
|
} else {
|
|
@@ -14560,9 +14644,9 @@ async function importMiddlewareConfigModule(inFile, logger) {
|
|
|
14560
14644
|
}
|
|
14561
14645
|
}
|
|
14562
14646
|
async function importErrorConfigModule(inFile, logger) {
|
|
14563
|
-
const isCJS = (0,
|
|
14647
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14564
14648
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14565
|
-
const module2 = parser2.parse(mod, ErrorConfigSchema, (0,
|
|
14649
|
+
const module2 = parser2.parse(mod, ErrorConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14566
14650
|
if (module2 !== void 0) {
|
|
14567
14651
|
return module2;
|
|
14568
14652
|
} else {
|
|
@@ -14570,9 +14654,9 @@ async function importErrorConfigModule(inFile, logger) {
|
|
|
14570
14654
|
}
|
|
14571
14655
|
}
|
|
14572
14656
|
async function importDocConfigModule(inFile, logger) {
|
|
14573
|
-
const isCJS = (0,
|
|
14657
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14574
14658
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14575
|
-
const module2 = parser2.parse(mod, DocConfigSchema, (0,
|
|
14659
|
+
const module2 = parser2.parse(mod, DocConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14576
14660
|
if (module2 !== void 0) {
|
|
14577
14661
|
return module2;
|
|
14578
14662
|
} else {
|
|
@@ -14580,9 +14664,9 @@ async function importDocConfigModule(inFile, logger) {
|
|
|
14580
14664
|
}
|
|
14581
14665
|
}
|
|
14582
14666
|
async function importCORSModule(inFile, logger) {
|
|
14583
|
-
const isCJS = (0,
|
|
14667
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14584
14668
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14585
|
-
const module2 = parser2.parse(mod, CORSOptionsSchema, (0,
|
|
14669
|
+
const module2 = parser2.parse(mod, CORSOptionsSchema, (0, import_node_path6.basename)(inFile));
|
|
14586
14670
|
if (module2 !== void 0) {
|
|
14587
14671
|
return module2;
|
|
14588
14672
|
} else {
|
|
@@ -14590,9 +14674,9 @@ async function importCORSModule(inFile, logger) {
|
|
|
14590
14674
|
}
|
|
14591
14675
|
}
|
|
14592
14676
|
async function importWSConfigModule(inFile, logger) {
|
|
14593
|
-
const isCJS = (0,
|
|
14677
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14594
14678
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14595
|
-
const module2 = parser2.parse(mod, WSConfigSchema, (0,
|
|
14679
|
+
const module2 = parser2.parse(mod, WSConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14596
14680
|
if (module2 !== void 0) {
|
|
14597
14681
|
return module2;
|
|
14598
14682
|
} else {
|
|
@@ -14600,9 +14684,9 @@ async function importWSConfigModule(inFile, logger) {
|
|
|
14600
14684
|
}
|
|
14601
14685
|
}
|
|
14602
14686
|
async function importDBConfigModule(inFile, logger) {
|
|
14603
|
-
const isCJS = (0,
|
|
14687
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14604
14688
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14605
|
-
const module2 = parser2.parse(mod, DBConfigSchema, (0,
|
|
14689
|
+
const module2 = parser2.parse(mod, DBConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14606
14690
|
if (module2 !== void 0) {
|
|
14607
14691
|
return module2;
|
|
14608
14692
|
} else {
|
|
@@ -14610,7 +14694,7 @@ async function importDBConfigModule(inFile, logger) {
|
|
|
14610
14694
|
}
|
|
14611
14695
|
}
|
|
14612
14696
|
async function importLogConfigModule(inFile, logger) {
|
|
14613
|
-
const module2 = parser2.parse((await importJSXFile(inFile, logger)).default, LogConfigSchema, (0,
|
|
14697
|
+
const module2 = parser2.parse((await importJSXFile(inFile, logger)).default, LogConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14614
14698
|
if (module2 !== void 0) {
|
|
14615
14699
|
return module2;
|
|
14616
14700
|
} else {
|
|
@@ -14618,9 +14702,9 @@ async function importLogConfigModule(inFile, logger) {
|
|
|
14618
14702
|
}
|
|
14619
14703
|
}
|
|
14620
14704
|
async function importServerConfigModule(inFile, logger) {
|
|
14621
|
-
const isCJS = (0,
|
|
14705
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14622
14706
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14623
|
-
const module2 = parser2.parse(mod, ServerConfigSchema, (0,
|
|
14707
|
+
const module2 = parser2.parse(mod, ServerConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14624
14708
|
if (module2 !== void 0) {
|
|
14625
14709
|
return module2;
|
|
14626
14710
|
} else {
|
|
@@ -14635,22 +14719,22 @@ async function importJSXFile(inFile, logger) {
|
|
|
14635
14719
|
platform: "node",
|
|
14636
14720
|
logger
|
|
14637
14721
|
});
|
|
14638
|
-
const tmpBuildDir = (0,
|
|
14639
|
-
const inFileTmp = (0,
|
|
14640
|
-
|
|
14722
|
+
const tmpBuildDir = (0, import_node_path6.resolve)(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + (0, import_node_crypto4.randomUUID)());
|
|
14723
|
+
const inFileTmp = (0, import_node_path6.resolve)(tmpBuildDir, (0, import_node_path6.basename)(inFile) + ".cjs");
|
|
14724
|
+
await mkdirASync(tmpBuildDir, {
|
|
14641
14725
|
recursive: true
|
|
14642
14726
|
});
|
|
14643
14727
|
try {
|
|
14644
|
-
|
|
14728
|
+
await writeFileASync(inFileTmp, inflatedCode);
|
|
14645
14729
|
assertGlobalTampered();
|
|
14646
|
-
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", (0,
|
|
14647
|
-
logger?.debug("importing [%s]", (0,
|
|
14648
|
-
const module2 = await import((0,
|
|
14730
|
+
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", (0, import_node_path6.relative)((0, import_node_process3.cwd)(), inFile), (0, import_node_path6.dirname)((0, import_node_path6.relative)(JSX_TMP_DIR, inFileTmp)));
|
|
14731
|
+
logger?.debug("importing [%s]", (0, import_node_path6.relative)((0, import_node_process3.cwd)(), inFile));
|
|
14732
|
+
const module2 = await import((0, import_node_path6.resolve)(inFileTmp));
|
|
14649
14733
|
assertGlobalTampered();
|
|
14650
14734
|
if (CLEAR_JSX_CACHE) {
|
|
14651
14735
|
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14652
|
-
|
|
14653
|
-
|
|
14736
|
+
await unlinkASync(inFileTmp);
|
|
14737
|
+
await rmdirASync(tmpBuildDir);
|
|
14654
14738
|
}
|
|
14655
14739
|
return module2.default;
|
|
14656
14740
|
} catch (e) {
|
|
@@ -14658,8 +14742,8 @@ async function importJSXFile(inFile, logger) {
|
|
|
14658
14742
|
logger?.error("error with2: " + inFile);
|
|
14659
14743
|
if (CLEAR_JSX_CACHE) {
|
|
14660
14744
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14661
|
-
|
|
14662
|
-
|
|
14745
|
+
await unlinkASync(inFileTmp);
|
|
14746
|
+
await rmdirASync(tmpBuildDir);
|
|
14663
14747
|
} else {
|
|
14664
14748
|
logger?.error("error with: %s", inFileTmp);
|
|
14665
14749
|
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
@@ -14739,21 +14823,21 @@ var import_node_process8 = require("node:process");
|
|
|
14739
14823
|
|
|
14740
14824
|
// src/inflate/setup-cors.ts
|
|
14741
14825
|
var import_node_fs7 = require("node:fs");
|
|
14742
|
-
var
|
|
14826
|
+
var import_node_path7 = require("node:path");
|
|
14743
14827
|
var import_node_process4 = require("node:process");
|
|
14744
14828
|
async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
|
|
14745
14829
|
const corsPath = getCORSConfigPath(servicePath);
|
|
14746
14830
|
if (corsPath) {
|
|
14747
14831
|
try {
|
|
14748
14832
|
const corsOptions = await importCORSModule(corsPath, logger);
|
|
14749
|
-
logger.debug("setting up cors from [%s]", (0,
|
|
14833
|
+
logger.debug("setting up cors from [%s]", (0, import_node_path7.join)(service, (0, import_node_path7.basename)(corsPath)));
|
|
14750
14834
|
mainRouter.use(CORS(corsOptions));
|
|
14751
14835
|
if (inflateDir && inflateSea) {
|
|
14752
|
-
const inflatePath = (0,
|
|
14753
|
-
(0, import_node_fs7.mkdirSync)((0,
|
|
14836
|
+
const inflatePath = (0, import_node_path7.resolve)(inflateDir, service, "cors.cjs");
|
|
14837
|
+
(0, import_node_fs7.mkdirSync)((0, import_node_path7.dirname)(inflatePath), {
|
|
14754
14838
|
recursive: true
|
|
14755
14839
|
});
|
|
14756
|
-
logger.log("writing [%s]", (0,
|
|
14840
|
+
logger.log("writing [%s]", (0, import_node_path7.relative)((0, import_node_process4.cwd)(), inflatePath));
|
|
14757
14841
|
(0, import_node_fs7.writeFileSync)(inflatePath, await inflateJSX(corsPath, {
|
|
14758
14842
|
embemedJSX: false,
|
|
14759
14843
|
minify: false,
|
|
@@ -14774,7 +14858,7 @@ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14774
14858
|
}
|
|
14775
14859
|
|
|
14776
14860
|
// src/inflate/setup-auth.ts
|
|
14777
|
-
var
|
|
14861
|
+
var import_node_path8 = require("node:path");
|
|
14778
14862
|
var import_node_fs8 = require("node:fs");
|
|
14779
14863
|
var import_node_process5 = require("node:process");
|
|
14780
14864
|
async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
|
|
@@ -14782,14 +14866,14 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14782
14866
|
if (authPath) {
|
|
14783
14867
|
try {
|
|
14784
14868
|
const authModule = await importAuthModule(authPath, logger);
|
|
14785
|
-
logger.debug("setting up authentication from [%s]", (0,
|
|
14869
|
+
logger.debug("setting up authentication from [%s]", (0, import_node_path8.join)(service, (0, import_node_path8.basename)(authPath)));
|
|
14786
14870
|
mainRouter.use(SessionHandler(authModule));
|
|
14787
14871
|
if (inflateDir && inflateSea) {
|
|
14788
|
-
const inflatePath = (0,
|
|
14789
|
-
(0, import_node_fs8.mkdirSync)((0,
|
|
14872
|
+
const inflatePath = (0, import_node_path8.resolve)(inflateDir, service, "auth.cjs");
|
|
14873
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path8.dirname)(inflatePath), {
|
|
14790
14874
|
recursive: true
|
|
14791
14875
|
});
|
|
14792
|
-
logger.log("writing [%s]", (0,
|
|
14876
|
+
logger.log("writing [%s]", (0, import_node_path8.relative)((0, import_node_process5.cwd)(), inflatePath));
|
|
14793
14877
|
(0, import_node_fs8.writeFileSync)(inflatePath, await inflateJSX(authPath, {
|
|
14794
14878
|
embemedJSX: false,
|
|
14795
14879
|
minify: false,
|
|
@@ -14810,11 +14894,11 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14810
14894
|
}
|
|
14811
14895
|
|
|
14812
14896
|
// src/services/utils/get-route.ts
|
|
14813
|
-
var
|
|
14897
|
+
var import_node_path9 = require("node:path");
|
|
14814
14898
|
function getRoutes(prePath, defaultPath, apiOptions) {
|
|
14815
14899
|
const ret = [];
|
|
14816
14900
|
const path = apiOptions && apiOptions.path ? apiOptions.path : defaultPath;
|
|
14817
|
-
const defaultInflatePath = (0,
|
|
14901
|
+
const defaultInflatePath = (0, import_node_path9.join)(prePath, defaultPath);
|
|
14818
14902
|
const method = apiOptions && apiOptions.method ? apiOptions.method : "GET";
|
|
14819
14903
|
const methods = method instanceof Array ? method : [method];
|
|
14820
14904
|
const paths = path instanceof Array ? path : [path];
|
|
@@ -14855,10 +14939,10 @@ function getRoutes(prePath, defaultPath, apiOptions) {
|
|
|
14855
14939
|
response: apiOptions?.response,
|
|
14856
14940
|
session: apiOptions?.session
|
|
14857
14941
|
},
|
|
14858
|
-
inflatePath: p !== "/" ? (0,
|
|
14942
|
+
inflatePath: p !== "/" ? (0, import_node_path9.join)(prePath, p) : defaultInflatePath,
|
|
14859
14943
|
defaultInflatePath,
|
|
14860
14944
|
method: m.toLocaleLowerCase() !== "use" ? m.toUpperCase() : void 0,
|
|
14861
|
-
path: normalizePath((0,
|
|
14945
|
+
path: normalizePath((0, import_node_path9.join)(prePath, p))
|
|
14862
14946
|
});
|
|
14863
14947
|
}
|
|
14864
14948
|
}
|
|
@@ -14866,24 +14950,6 @@ function getRoutes(prePath, defaultPath, apiOptions) {
|
|
|
14866
14950
|
return ret;
|
|
14867
14951
|
}
|
|
14868
14952
|
|
|
14869
|
-
// src/common/fs.ts
|
|
14870
|
-
var import_node_path9 = require("node:path");
|
|
14871
|
-
function describeFilePath(filePath) {
|
|
14872
|
-
const ext = (0, import_node_path9.extname)(filePath);
|
|
14873
|
-
const fileName = (0, import_node_path9.basename)(filePath);
|
|
14874
|
-
const name = fileName.substring(0, fileName.length - ext.length);
|
|
14875
|
-
const subExt = (0, import_node_path9.extname)(name);
|
|
14876
|
-
const subName = name.substring(0, name.length - subExt.length);
|
|
14877
|
-
return {
|
|
14878
|
-
ext,
|
|
14879
|
-
fileName,
|
|
14880
|
-
name,
|
|
14881
|
-
subExt,
|
|
14882
|
-
subName,
|
|
14883
|
-
filePath
|
|
14884
|
-
};
|
|
14885
|
-
}
|
|
14886
|
-
|
|
14887
14953
|
// src/inflate/setup-middleware.ts
|
|
14888
14954
|
var import_node_path10 = require("node:path");
|
|
14889
14955
|
var import_node_fs9 = require("node:fs");
|
|
@@ -14967,7 +15033,7 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
|
|
|
14967
15033
|
}
|
|
14968
15034
|
|
|
14969
15035
|
// src/inflate/setup-http.ts
|
|
14970
|
-
async function setupHTTPRouter(server2, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors) {
|
|
15036
|
+
async function setupHTTPRouter(server2, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors, inflateParallel) {
|
|
14971
15037
|
const mainRouter = new Router();
|
|
14972
15038
|
const apiRouterPath = getHTTPRouterPath(servicePath);
|
|
14973
15039
|
let middlewareConfig = null;
|
|
@@ -14977,13 +15043,13 @@ async function setupHTTPRouter(server2, logger, hotreload, servicePath, service,
|
|
|
14977
15043
|
middlewareConfig = await setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
14978
15044
|
if (apiRouterPath) {
|
|
14979
15045
|
logger.trace("setting up http routes from [%s]", service);
|
|
14980
|
-
const { router: httpRouter } = await createRouterFromDirectory(server2, hotreload, service, logger, apiRouterPath, errors, routeFileMap, staticFileMap, inflateDir, inflateSea);
|
|
15046
|
+
const { router: httpRouter } = await createRouterFromDirectory(server2, hotreload, service, logger, apiRouterPath, errors, routeFileMap, staticFileMap, inflateDir, inflateSea, inflateParallel);
|
|
14981
15047
|
mainRouter.use(httpRouter);
|
|
14982
15048
|
}
|
|
14983
15049
|
const staticFilesPath = getStaticFilesPath(servicePath);
|
|
14984
15050
|
if (staticFilesPath) {
|
|
14985
15051
|
logger.trace("setting up static file routes from [%s]", service);
|
|
14986
|
-
const staticRouter = createStaticRouterFromDirectory(service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap);
|
|
15052
|
+
const staticRouter = await createStaticRouterFromDirectory(service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap, inflateParallel);
|
|
14987
15053
|
mainRouter.use(staticRouter);
|
|
14988
15054
|
}
|
|
14989
15055
|
if (middlewareConfig && middlewareConfig.post) {
|
|
@@ -14993,83 +15059,110 @@ async function setupHTTPRouter(server2, logger, hotreload, servicePath, service,
|
|
|
14993
15059
|
}
|
|
14994
15060
|
return mainRouter;
|
|
14995
15061
|
}
|
|
14996
|
-
function createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap) {
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
|
|
15009
|
-
|
|
15010
|
-
|
|
15011
|
-
|
|
15012
|
-
};
|
|
15013
|
-
if (inflateDir) {
|
|
15014
|
-
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15015
|
-
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15016
|
-
recursive: true
|
|
15017
|
-
});
|
|
15018
|
-
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15019
|
-
const body = (0, import_node_fs11.readFileSync)(file.filePath);
|
|
15020
|
-
(0, import_node_fs11.writeFileSync)(inflatePath, body);
|
|
15021
|
-
if (staticFileMap) {
|
|
15022
|
-
staticFileMap[file.filePath] = {
|
|
15023
|
-
contentType,
|
|
15062
|
+
async function createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap) {
|
|
15063
|
+
return new Promise(async (resolve24, reject) => {
|
|
15064
|
+
try {
|
|
15065
|
+
logger.trace("creating static route for [%s]", file.filePath);
|
|
15066
|
+
logger.trace("[%o]", {
|
|
15067
|
+
file,
|
|
15068
|
+
dir
|
|
15069
|
+
});
|
|
15070
|
+
const contentType = CONTENT_TYPE_MAP[String(file.ext).toLocaleLowerCase()];
|
|
15071
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.relative)(dir, file.filePath));
|
|
15072
|
+
routeFileMap[file.filePath] = {
|
|
15073
|
+
routes: [{
|
|
15074
|
+
method: "GET",
|
|
15075
|
+
path: normalizePath(path)
|
|
15076
|
+
}],
|
|
15077
|
+
service,
|
|
15024
15078
|
filePath: file.filePath,
|
|
15025
|
-
previewMethod: "html"
|
|
15026
|
-
method: "GET",
|
|
15027
|
-
path: normalizePath(path),
|
|
15028
|
-
body: Buffer.from(body),
|
|
15029
|
-
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15079
|
+
previewMethod: "html"
|
|
15030
15080
|
};
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
try {
|
|
15037
|
-
(0, import_node_fs11.readFile)(file.filePath, async (err, body) => {
|
|
15038
|
-
if (err) {
|
|
15039
|
-
reject(err);
|
|
15040
|
-
} else {
|
|
15041
|
-
try {
|
|
15042
|
-
await res.asyncEnd({
|
|
15043
|
-
status: 200,
|
|
15044
|
-
headers: {
|
|
15045
|
-
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15046
|
-
},
|
|
15047
|
-
body
|
|
15048
|
-
});
|
|
15049
|
-
resolve24();
|
|
15050
|
-
} catch (e) {
|
|
15051
|
-
reject(e);
|
|
15052
|
-
}
|
|
15053
|
-
}
|
|
15081
|
+
if (inflateDir) {
|
|
15082
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15083
|
+
(0, import_node_fs11.mkdir)((0, import_node_path12.dirname)(inflatePath), {
|
|
15084
|
+
recursive: true
|
|
15085
|
+
}, (err) => {
|
|
15054
15086
|
});
|
|
15055
|
-
|
|
15056
|
-
|
|
15087
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15088
|
+
recursive: true
|
|
15089
|
+
});
|
|
15090
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15091
|
+
const body = (0, import_node_fs11.readFileSync)(file.filePath);
|
|
15092
|
+
await writeFileASync(inflatePath, body);
|
|
15093
|
+
if (staticFileMap) {
|
|
15094
|
+
staticFileMap[file.filePath] = {
|
|
15095
|
+
contentType,
|
|
15096
|
+
filePath: file.filePath,
|
|
15097
|
+
previewMethod: "html",
|
|
15098
|
+
method: "GET",
|
|
15099
|
+
path: normalizePath(path),
|
|
15100
|
+
body: Buffer.from(body),
|
|
15101
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15102
|
+
};
|
|
15103
|
+
}
|
|
15057
15104
|
}
|
|
15058
|
-
|
|
15105
|
+
router.use(assertGlobalTampered);
|
|
15106
|
+
router.get(path, async function(_req, res) {
|
|
15107
|
+
await new Promise((resolve25, reject2) => {
|
|
15108
|
+
try {
|
|
15109
|
+
(0, import_node_fs11.readFile)(file.filePath, async (err, body) => {
|
|
15110
|
+
if (err) {
|
|
15111
|
+
reject2(err);
|
|
15112
|
+
} else {
|
|
15113
|
+
try {
|
|
15114
|
+
await res.asyncEnd({
|
|
15115
|
+
status: 200,
|
|
15116
|
+
headers: {
|
|
15117
|
+
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15118
|
+
},
|
|
15119
|
+
body
|
|
15120
|
+
});
|
|
15121
|
+
resolve25();
|
|
15122
|
+
} catch (e) {
|
|
15123
|
+
reject2(e);
|
|
15124
|
+
}
|
|
15125
|
+
}
|
|
15126
|
+
});
|
|
15127
|
+
} catch (e) {
|
|
15128
|
+
reject2(e);
|
|
15129
|
+
}
|
|
15130
|
+
});
|
|
15131
|
+
});
|
|
15132
|
+
resolve24();
|
|
15133
|
+
} catch (e) {
|
|
15134
|
+
reject(e);
|
|
15135
|
+
}
|
|
15059
15136
|
});
|
|
15060
15137
|
}
|
|
15061
|
-
function createStaticRouterFromDirectory(service, logger, dir, inflateDir, routeFileMap, staticFileMap) {
|
|
15138
|
+
async function createStaticRouterFromDirectory(service, logger, dir, inflateDir, routeFileMap, staticFileMap, inflateParallel) {
|
|
15062
15139
|
const router = new Router();
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15140
|
+
const maxParallel = inflateParallel ? inflateParallel : 1;
|
|
15141
|
+
logger.debug("loading static directory with parallel [%s]", maxParallel);
|
|
15142
|
+
let tR = [];
|
|
15143
|
+
const files = scanFiles(dir);
|
|
15144
|
+
for (const file of files) {
|
|
15145
|
+
tR.push(await createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap));
|
|
15146
|
+
if (tR.length >= maxParallel) {
|
|
15147
|
+
await Promise.all(tR);
|
|
15148
|
+
tR = [];
|
|
15149
|
+
}
|
|
15150
|
+
}
|
|
15151
|
+
if (tR.length > 0) {
|
|
15152
|
+
await Promise.all(tR);
|
|
15153
|
+
tR = [];
|
|
15154
|
+
}
|
|
15066
15155
|
return router;
|
|
15067
15156
|
}
|
|
15068
|
-
async function createRouterFromDirectory(server2, hotreload, service, logger, dir, errors = [], routeFileMap = {}, staticFileMap = null, inflateDir, inflateSea) {
|
|
15157
|
+
async function createRouterFromDirectory(server2, hotreload, service, logger, dir, errors = [], routeFileMap = {}, staticFileMap = null, inflateDir, inflateSea, inflateParallel) {
|
|
15069
15158
|
const router = new Router();
|
|
15159
|
+
const maxParallel = inflateParallel ? inflateParallel : 1;
|
|
15160
|
+
server2.logger.debug("loading http directory with parallel [%s]", maxParallel);
|
|
15161
|
+
let tR = [];
|
|
15070
15162
|
router.use(assertGlobalTampered);
|
|
15071
|
-
|
|
15072
|
-
|
|
15163
|
+
const files = scanFiles(dir);
|
|
15164
|
+
for (const file of files) {
|
|
15165
|
+
tR.push(new Promise(async (resolve24) => {
|
|
15073
15166
|
try {
|
|
15074
15167
|
switch (file.ext) {
|
|
15075
15168
|
case ".jsx":
|
|
@@ -15103,11 +15196,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15103
15196
|
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
15104
15197
|
const rPath = r.defaultInflatePath;
|
|
15105
15198
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.cjs");
|
|
15106
|
-
|
|
15199
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15107
15200
|
recursive: true
|
|
15108
15201
|
});
|
|
15109
15202
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15110
|
-
|
|
15203
|
+
await writeFileASync(inflatePath, inflatedCode);
|
|
15111
15204
|
}
|
|
15112
15205
|
router.use(assertGlobalTampered);
|
|
15113
15206
|
router.use(module2.handler, r.path, r.method, r.options);
|
|
@@ -15129,7 +15222,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15129
15222
|
if (r.inflatePath) {
|
|
15130
15223
|
const rPath = r.inflatePath;
|
|
15131
15224
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15132
|
-
|
|
15225
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15133
15226
|
recursive: true
|
|
15134
15227
|
});
|
|
15135
15228
|
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
@@ -15138,7 +15231,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15138
15231
|
}
|
|
15139
15232
|
const JSON_STATIC = await getJSON({ server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, module2.default);
|
|
15140
15233
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15141
|
-
|
|
15234
|
+
await writeFileASync(inflatePath, JSON_STATIC);
|
|
15142
15235
|
if (staticFileMap && inflateSea) {
|
|
15143
15236
|
staticFileMap[file.filePath] = {
|
|
15144
15237
|
contentType,
|
|
@@ -15181,7 +15274,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15181
15274
|
if (r.inflatePath) {
|
|
15182
15275
|
const rPath = r.inflatePath;
|
|
15183
15276
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15184
|
-
|
|
15277
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15185
15278
|
recursive: true
|
|
15186
15279
|
});
|
|
15187
15280
|
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
@@ -15191,7 +15284,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15191
15284
|
const toRender = typeof module2.default === "function" ? module2.default({ server: server2 }, null) : module2.default;
|
|
15192
15285
|
const HTML_STATIC = await getHTML(hotreload, { server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, await toRender);
|
|
15193
15286
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15194
|
-
|
|
15287
|
+
await writeFileASync(inflatePath, HTML_STATIC);
|
|
15195
15288
|
if (staticFileMap && inflateSea) {
|
|
15196
15289
|
staticFileMap[file.filePath + r.method + r.path] = {
|
|
15197
15290
|
filePath: file.filePath,
|
|
@@ -15243,11 +15336,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15243
15336
|
};
|
|
15244
15337
|
if (inflateDir) {
|
|
15245
15338
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15246
|
-
|
|
15339
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15247
15340
|
recursive: true
|
|
15248
15341
|
});
|
|
15249
15342
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15250
|
-
|
|
15343
|
+
await writeFileASync(inflatePath, code);
|
|
15251
15344
|
if (staticFileMap && inflateSea) {
|
|
15252
15345
|
staticFileMap[file.filePath] = {
|
|
15253
15346
|
contentType,
|
|
@@ -15292,11 +15385,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15292
15385
|
};
|
|
15293
15386
|
if (inflateDir) {
|
|
15294
15387
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15295
|
-
|
|
15388
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15296
15389
|
recursive: true
|
|
15297
15390
|
});
|
|
15298
15391
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15299
|
-
|
|
15392
|
+
await writeFileASync(inflatePath, code);
|
|
15300
15393
|
if (staticFileMap && inflateSea) {
|
|
15301
15394
|
staticFileMap[file.filePath] = {
|
|
15302
15395
|
contentType,
|
|
@@ -15351,11 +15444,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15351
15444
|
};
|
|
15352
15445
|
if (inflateDir) {
|
|
15353
15446
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15354
|
-
|
|
15447
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15355
15448
|
recursive: true
|
|
15356
15449
|
});
|
|
15357
15450
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15358
|
-
|
|
15451
|
+
await writeFileASync(inflatePath, code);
|
|
15359
15452
|
if (staticFileMap && inflateSea) {
|
|
15360
15453
|
staticFileMap[file.filePath] = {
|
|
15361
15454
|
contentType,
|
|
@@ -15402,11 +15495,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15402
15495
|
};
|
|
15403
15496
|
if (inflateDir) {
|
|
15404
15497
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15405
|
-
|
|
15498
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15406
15499
|
recursive: true
|
|
15407
15500
|
});
|
|
15408
15501
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15409
|
-
|
|
15502
|
+
await writeFileASync(inflatePath, code);
|
|
15410
15503
|
if (staticFileMap && inflateSea) {
|
|
15411
15504
|
staticFileMap[file.filePath] = {
|
|
15412
15505
|
contentType,
|
|
@@ -15433,7 +15526,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15433
15526
|
}
|
|
15434
15527
|
}
|
|
15435
15528
|
}
|
|
15436
|
-
createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
|
|
15529
|
+
await createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
|
|
15437
15530
|
return resolve24();
|
|
15438
15531
|
}
|
|
15439
15532
|
} catch (e) {
|
|
@@ -15446,7 +15539,15 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15446
15539
|
} finally {
|
|
15447
15540
|
return resolve24();
|
|
15448
15541
|
}
|
|
15449
|
-
});
|
|
15542
|
+
}));
|
|
15543
|
+
if (tR.length >= maxParallel) {
|
|
15544
|
+
await Promise.all(tR);
|
|
15545
|
+
tR = [];
|
|
15546
|
+
}
|
|
15547
|
+
}
|
|
15548
|
+
if (tR.length > 0) {
|
|
15549
|
+
await Promise.all(tR);
|
|
15550
|
+
tR = [];
|
|
15450
15551
|
}
|
|
15451
15552
|
router.use(assertGlobalTampered);
|
|
15452
15553
|
return {
|
|
@@ -15536,25 +15637,25 @@ var import_node_process10 = require("node:process");
|
|
|
15536
15637
|
async function inflateSeaAssets(logger, inflateDir) {
|
|
15537
15638
|
const esbuildBinaryBuffer2 = Buffer.from(getAsset("esbuild-binary"));
|
|
15538
15639
|
if (import_node_process10.platform === "win32") {
|
|
15539
|
-
|
|
15640
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "esbuild.exe"), esbuildBinaryBuffer2);
|
|
15540
15641
|
(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);
|
|
15541
15642
|
} else {
|
|
15542
|
-
|
|
15643
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "esbuild"), esbuildBinaryBuffer2);
|
|
15543
15644
|
(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);
|
|
15544
15645
|
}
|
|
15545
|
-
|
|
15546
|
-
|
|
15547
|
-
|
|
15548
|
-
|
|
15549
|
-
|
|
15550
|
-
|
|
15551
|
-
|
|
15552
|
-
|
|
15646
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
15647
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "config.json"), Buffer.from(getAsset("sea.basic.config.json")));
|
|
15648
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "run.sh"), Buffer.from(getAsset("app.sh")));
|
|
15649
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "node.sh"), Buffer.from(getAsset("node.sh")));
|
|
15650
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "compile.sh"), Buffer.from(Buffer.from(getAsset("compile.base64.sh")).toString(), "base64"));
|
|
15651
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "sign-add.sh"), Buffer.from(getAsset("sign-add.sh")));
|
|
15652
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "sign-remove.sh"), Buffer.from(getAsset("sign-remove.sh")));
|
|
15653
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
|
|
15553
15654
|
}
|
|
15554
15655
|
async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
15555
15656
|
const PORT2 = port;
|
|
15556
15657
|
inflateSeaAssets(logger, inflateDir);
|
|
15557
|
-
|
|
15658
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
15558
15659
|
const WSLIST = services.filter((service) => getWSConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
15559
15660
|
return `(await import("../${service}/ws.cjs")).default`;
|
|
15560
15661
|
}).join(",");
|
|
@@ -15573,8 +15674,8 @@ async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
15573
15674
|
|
|
15574
15675
|
})`;
|
|
15575
15676
|
}).join(",");
|
|
15576
|
-
|
|
15577
|
-
|
|
15677
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
15678
|
+
writeFile2(
|
|
15578
15679
|
logger,
|
|
15579
15680
|
(0, import_node_path14.join)(inflateDir, "sea", "app.cjs"),
|
|
15580
15681
|
`const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
@@ -15622,11 +15723,25 @@ async function main() {
|
|
|
15622
15723
|
main().catch(e=>console.error(e));
|
|
15623
15724
|
`
|
|
15624
15725
|
);
|
|
15726
|
+
logger.log("writing [%s]", (0, import_node_path14.relative)((0, import_node_process10.cwd)(), (0, import_node_path14.join)(inflateDir, "sea", "app.bundle.cjs")));
|
|
15727
|
+
await esBuild({
|
|
15728
|
+
entryPoints: [(0, import_node_path14.join)(inflateDir, "sea", "app.cjs")],
|
|
15729
|
+
bundle: true,
|
|
15730
|
+
minify: true,
|
|
15731
|
+
jsxFactory: "JSX.createElement",
|
|
15732
|
+
jsxFragment: "JSX.Fragment",
|
|
15733
|
+
platform: "node",
|
|
15734
|
+
outfile: (0, import_node_path14.join)(inflateDir, "sea", "app.bundle.cjs")
|
|
15735
|
+
});
|
|
15736
|
+
const miqroRCPath = getMiqroJSONPath();
|
|
15737
|
+
if (miqroRCPath) {
|
|
15738
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "miqro.json"), (0, import_node_fs13.readFileSync)(miqroRCPath));
|
|
15739
|
+
}
|
|
15625
15740
|
}
|
|
15626
15741
|
async function inflateServiceForSea(logger, inflateDir, service, servicePath, serviceRouteFileMap, serviceStaticFileMap) {
|
|
15627
15742
|
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
15628
15743
|
const serviceMigrations = migrationsFolderPath ? lib_exports.getSortedMigrations(migrationsFolderPath) : [];
|
|
15629
|
-
|
|
15744
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";
|
|
15630
15745
|
|
|
15631
15746
|
export async function setupRouter() {
|
|
15632
15747
|
const router = new Router();
|
|
@@ -15667,7 +15782,7 @@ ${getMiddlewareConfigPath(servicePath) ? `
|
|
|
15667
15782
|
|
|
15668
15783
|
return router;
|
|
15669
15784
|
}`);
|
|
15670
|
-
|
|
15785
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-up.js"), `import { migration } from "./../lib.cjs";
|
|
15671
15786
|
|
|
15672
15787
|
export async function runMigrations(db) {
|
|
15673
15788
|
await migration.init(db);
|
|
@@ -15676,7 +15791,7 @@ ${serviceMigrations.map((file) => {
|
|
|
15676
15791
|
return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
15677
15792
|
}).join("\n")}
|
|
15678
15793
|
}`);
|
|
15679
|
-
|
|
15794
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.js"), `import { migration } from "./../lib.cjs";
|
|
15680
15795
|
|
|
15681
15796
|
export async function runMigrations(db) {
|
|
15682
15797
|
await migration.init(db);
|
|
@@ -15686,7 +15801,7 @@ ${serviceMigrations.reverse().map((file) => {
|
|
|
15686
15801
|
}).join("\n")}
|
|
15687
15802
|
}`);
|
|
15688
15803
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
15689
|
-
|
|
15804
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "static-router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";
|
|
15690
15805
|
|
|
15691
15806
|
export async function setupRouter() {
|
|
15692
15807
|
const router = new Router();
|
|
@@ -15706,7 +15821,7 @@ ${staticFiles.map((filePath) => {
|
|
|
15706
15821
|
return router;
|
|
15707
15822
|
}`);
|
|
15708
15823
|
}
|
|
15709
|
-
function
|
|
15824
|
+
function writeFile2(logger, path, buffer) {
|
|
15710
15825
|
logger.log("writing [%s]", (0, import_node_path14.relative)((0, import_node_process10.cwd)(), path));
|
|
15711
15826
|
(0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(path), {
|
|
15712
15827
|
recursive: true
|
|
@@ -16074,7 +16189,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, infla
|
|
|
16074
16189
|
}
|
|
16075
16190
|
|
|
16076
16191
|
// src/inflate/inflate.ts
|
|
16077
|
-
async function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
|
|
16192
|
+
async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
|
|
16078
16193
|
logger.trace("inflateApp");
|
|
16079
16194
|
const errors = [];
|
|
16080
16195
|
let routeFileMap = {};
|
|
@@ -16087,7 +16202,7 @@ async function inflateApp({ serverInterface, logger, hotreload, services, inflat
|
|
|
16087
16202
|
const serviceStaticFileMap = inflateSea ? {} : null;
|
|
16088
16203
|
const servicePath = getServicePath(service);
|
|
16089
16204
|
await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, errors);
|
|
16090
|
-
router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors));
|
|
16205
|
+
router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
|
|
16091
16206
|
routeFileMap = {
|
|
16092
16207
|
...routeFileMap,
|
|
16093
16208
|
...serviceRouteFileMap
|
|
@@ -16642,7 +16757,8 @@ var MiqroJSONSchema = {
|
|
|
16642
16757
|
editor: "boolean?",
|
|
16643
16758
|
https: "boolean?",
|
|
16644
16759
|
serverOptions: "any?",
|
|
16645
|
-
httpsRedirect: "number?"
|
|
16760
|
+
httpsRedirect: "number?",
|
|
16761
|
+
inflateParallel: "number?"
|
|
16646
16762
|
}
|
|
16647
16763
|
};
|
|
16648
16764
|
function importMiqroJSON(inFile) {
|
|
@@ -16853,6 +16969,7 @@ var Miqro = class _Miqro {
|
|
|
16853
16969
|
});
|
|
16854
16970
|
await app.inflate({
|
|
16855
16971
|
inflateDir: miqroJSON.inflateDir ? String(miqroJSON.inflateDir) : void 0,
|
|
16972
|
+
inflateParallel: miqroJSON.inflateParallel ? miqroJSON.inflateParallel : void 0,
|
|
16856
16973
|
...inflate ? inflate : {}
|
|
16857
16974
|
});
|
|
16858
16975
|
return app;
|
|
@@ -17002,7 +17119,8 @@ var Miqro = class _Miqro {
|
|
|
17002
17119
|
inflateDir: options?.inflateDir,
|
|
17003
17120
|
inflateSea: options?.inflateSea ? true : false,
|
|
17004
17121
|
//inflateTests: options?.inflateTests ? true : false,
|
|
17005
|
-
hotreload: this.options?.hotreload ? true : false
|
|
17122
|
+
hotreload: this.options?.hotreload ? true : false,
|
|
17123
|
+
inflateParallel: options?.inflateParallel
|
|
17006
17124
|
});
|
|
17007
17125
|
wsConfigList.push(...serviceWSConfigList);
|
|
17008
17126
|
router.use(serviceRouter);
|