miqro 6.2.12 → 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/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 +6 -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/lib.cjs +302 -193
- package/package.json +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 +6 -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
|
});
|
|
@@ -11210,9 +11210,8 @@ var import_os = require("os");
|
|
|
11210
11210
|
var DEFAULT_BUILD_DIR = (0, import_os.tmpdir)();
|
|
11211
11211
|
|
|
11212
11212
|
// src/common/jsx.ts
|
|
11213
|
-
var
|
|
11213
|
+
var import_node_path6 = require("node:path");
|
|
11214
11214
|
var import_node_crypto4 = require("node:crypto");
|
|
11215
|
-
var import_node_fs6 = require("node:fs");
|
|
11216
11215
|
var import_node_process3 = require("node:process");
|
|
11217
11216
|
|
|
11218
11217
|
// src/common/esbuild.ts
|
|
@@ -11419,6 +11418,13 @@ function getErrorConfigPath(servicePath) {
|
|
|
11419
11418
|
function getDocConfigPath(servicePath) {
|
|
11420
11419
|
return getFilePath(servicePath, "doc", EXTENSIONS);
|
|
11421
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
|
+
}
|
|
11422
11428
|
function getAuthConfigPath(servicePath) {
|
|
11423
11429
|
return getFilePath(servicePath, "auth", EXTENSIONS);
|
|
11424
11430
|
}
|
|
@@ -14262,6 +14268,85 @@ function assertGlobalTampered() {
|
|
|
14262
14268
|
}
|
|
14263
14269
|
}
|
|
14264
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
|
+
|
|
14265
14350
|
// src/common/jsx.ts
|
|
14266
14351
|
var jsxJSBuffer = null;
|
|
14267
14352
|
var jsxJSBufferChecksumPromise = null;
|
|
@@ -14278,17 +14363,17 @@ var DEFAULT_ESOPTION = {
|
|
|
14278
14363
|
jsxFragment: "JSX.Fragment"
|
|
14279
14364
|
};
|
|
14280
14365
|
async function inflateJSX(inFile, options) {
|
|
14281
|
-
const tmpBuildDir = (0,
|
|
14282
|
-
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");
|
|
14283
14368
|
const jsxJSPath = getJSXJSPath();
|
|
14284
14369
|
const logger = options.logger;
|
|
14285
14370
|
try {
|
|
14286
14371
|
if (!options.embemedJSX) {
|
|
14287
|
-
|
|
14372
|
+
await mkdirASync(tmpBuildDir, {
|
|
14288
14373
|
recursive: true
|
|
14289
14374
|
});
|
|
14290
|
-
|
|
14291
|
-
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)));
|
|
14292
14377
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
14293
14378
|
...DEFAULT_ESOPTION,
|
|
14294
14379
|
entryPoints: [inFileTmp],
|
|
@@ -14297,16 +14382,16 @@ async function inflateJSX(inFile, options) {
|
|
|
14297
14382
|
});
|
|
14298
14383
|
if (CLEAR_JSX_CACHE) {
|
|
14299
14384
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14300
|
-
|
|
14301
|
-
|
|
14385
|
+
await unlinkASync(inFileTmp);
|
|
14386
|
+
await rmdirASync(tmpBuildDir);
|
|
14302
14387
|
}
|
|
14303
14388
|
return contents;
|
|
14304
14389
|
} else {
|
|
14305
|
-
|
|
14390
|
+
await mkdirASync(tmpBuildDir, {
|
|
14306
14391
|
recursive: true
|
|
14307
14392
|
});
|
|
14308
|
-
|
|
14309
|
-
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)));
|
|
14310
14395
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
14311
14396
|
...DEFAULT_ESOPTION,
|
|
14312
14397
|
entryPoints: [inFileTmp],
|
|
@@ -14315,8 +14400,8 @@ async function inflateJSX(inFile, options) {
|
|
|
14315
14400
|
});
|
|
14316
14401
|
if (CLEAR_JSX_CACHE) {
|
|
14317
14402
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14318
|
-
|
|
14319
|
-
|
|
14403
|
+
await unlinkASync(inFileTmp);
|
|
14404
|
+
await rmdirASync(tmpBuildDir);
|
|
14320
14405
|
}
|
|
14321
14406
|
return contents;
|
|
14322
14407
|
}
|
|
@@ -14326,8 +14411,8 @@ async function inflateJSX(inFile, options) {
|
|
|
14326
14411
|
if (options.embemedJSX) {
|
|
14327
14412
|
if (CLEAR_JSX_CACHE) {
|
|
14328
14413
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14329
|
-
|
|
14330
|
-
|
|
14414
|
+
await unlinkASync(inFileTmp);
|
|
14415
|
+
await rmdirASync(tmpBuildDir);
|
|
14331
14416
|
} else {
|
|
14332
14417
|
logger?.error("error with: %s", inFileTmp);
|
|
14333
14418
|
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
@@ -14499,9 +14584,9 @@ var DocConfigSchema = {
|
|
|
14499
14584
|
}
|
|
14500
14585
|
};
|
|
14501
14586
|
async function importAPIRoute(inFile, logger) {
|
|
14502
|
-
const isCJS = (0,
|
|
14587
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14503
14588
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14504
|
-
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));
|
|
14505
14590
|
if (module2 !== void 0) {
|
|
14506
14591
|
return module2;
|
|
14507
14592
|
} else {
|
|
@@ -14509,9 +14594,9 @@ async function importAPIRoute(inFile, logger) {
|
|
|
14509
14594
|
}
|
|
14510
14595
|
}
|
|
14511
14596
|
async function importMigrationModule(inFile, logger) {
|
|
14512
|
-
const isCJS = (0,
|
|
14597
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14513
14598
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14514
|
-
const module2 = parser2.parse(mod, MigrationSchema, (0,
|
|
14599
|
+
const module2 = parser2.parse(mod, MigrationSchema, (0, import_node_path6.basename)(inFile));
|
|
14515
14600
|
if (module2 !== void 0) {
|
|
14516
14601
|
return module2;
|
|
14517
14602
|
} else {
|
|
@@ -14520,8 +14605,8 @@ async function importMigrationModule(inFile, logger) {
|
|
|
14520
14605
|
}
|
|
14521
14606
|
async function importHTMLModule(inFile, logger) {
|
|
14522
14607
|
const module2 = await importJSXFile(inFile, logger);
|
|
14523
|
-
parser2.parse(module2.default, HTMLModuleSchema.properties.default, `${(0,
|
|
14524
|
-
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`);
|
|
14525
14610
|
if (module2 !== void 0) {
|
|
14526
14611
|
return module2;
|
|
14527
14612
|
} else {
|
|
@@ -14530,8 +14615,8 @@ async function importHTMLModule(inFile, logger) {
|
|
|
14530
14615
|
}
|
|
14531
14616
|
async function importJSONModule(inFile, logger) {
|
|
14532
14617
|
const module2 = await importJSXFile(inFile, logger);
|
|
14533
|
-
parser2.parse(module2.default, JSONModuleSchema.properties.default, `${(0,
|
|
14534
|
-
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`);
|
|
14535
14620
|
if (module2 !== void 0) {
|
|
14536
14621
|
return module2;
|
|
14537
14622
|
} else {
|
|
@@ -14539,9 +14624,9 @@ async function importJSONModule(inFile, logger) {
|
|
|
14539
14624
|
}
|
|
14540
14625
|
}
|
|
14541
14626
|
async function importAuthModule(inFile, logger) {
|
|
14542
|
-
const isCJS = (0,
|
|
14627
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14543
14628
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14544
|
-
const module2 = parser2.parse(mod, AuthConfigSchema, (0,
|
|
14629
|
+
const module2 = parser2.parse(mod, AuthConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14545
14630
|
if (module2 !== void 0) {
|
|
14546
14631
|
return module2;
|
|
14547
14632
|
} else {
|
|
@@ -14549,9 +14634,9 @@ async function importAuthModule(inFile, logger) {
|
|
|
14549
14634
|
}
|
|
14550
14635
|
}
|
|
14551
14636
|
async function importMiddlewareConfigModule(inFile, logger) {
|
|
14552
|
-
const isCJS = (0,
|
|
14637
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14553
14638
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14554
|
-
const module2 = parser2.parse(mod, MiddlewareConfigSchema, (0,
|
|
14639
|
+
const module2 = parser2.parse(mod, MiddlewareConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14555
14640
|
if (module2 !== void 0) {
|
|
14556
14641
|
return module2;
|
|
14557
14642
|
} else {
|
|
@@ -14559,9 +14644,9 @@ async function importMiddlewareConfigModule(inFile, logger) {
|
|
|
14559
14644
|
}
|
|
14560
14645
|
}
|
|
14561
14646
|
async function importErrorConfigModule(inFile, logger) {
|
|
14562
|
-
const isCJS = (0,
|
|
14647
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14563
14648
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14564
|
-
const module2 = parser2.parse(mod, ErrorConfigSchema, (0,
|
|
14649
|
+
const module2 = parser2.parse(mod, ErrorConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14565
14650
|
if (module2 !== void 0) {
|
|
14566
14651
|
return module2;
|
|
14567
14652
|
} else {
|
|
@@ -14569,9 +14654,9 @@ async function importErrorConfigModule(inFile, logger) {
|
|
|
14569
14654
|
}
|
|
14570
14655
|
}
|
|
14571
14656
|
async function importDocConfigModule(inFile, logger) {
|
|
14572
|
-
const isCJS = (0,
|
|
14657
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14573
14658
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14574
|
-
const module2 = parser2.parse(mod, DocConfigSchema, (0,
|
|
14659
|
+
const module2 = parser2.parse(mod, DocConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14575
14660
|
if (module2 !== void 0) {
|
|
14576
14661
|
return module2;
|
|
14577
14662
|
} else {
|
|
@@ -14579,9 +14664,9 @@ async function importDocConfigModule(inFile, logger) {
|
|
|
14579
14664
|
}
|
|
14580
14665
|
}
|
|
14581
14666
|
async function importCORSModule(inFile, logger) {
|
|
14582
|
-
const isCJS = (0,
|
|
14667
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14583
14668
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14584
|
-
const module2 = parser2.parse(mod, CORSOptionsSchema, (0,
|
|
14669
|
+
const module2 = parser2.parse(mod, CORSOptionsSchema, (0, import_node_path6.basename)(inFile));
|
|
14585
14670
|
if (module2 !== void 0) {
|
|
14586
14671
|
return module2;
|
|
14587
14672
|
} else {
|
|
@@ -14589,9 +14674,9 @@ async function importCORSModule(inFile, logger) {
|
|
|
14589
14674
|
}
|
|
14590
14675
|
}
|
|
14591
14676
|
async function importWSConfigModule(inFile, logger) {
|
|
14592
|
-
const isCJS = (0,
|
|
14677
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14593
14678
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14594
|
-
const module2 = parser2.parse(mod, WSConfigSchema, (0,
|
|
14679
|
+
const module2 = parser2.parse(mod, WSConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14595
14680
|
if (module2 !== void 0) {
|
|
14596
14681
|
return module2;
|
|
14597
14682
|
} else {
|
|
@@ -14599,9 +14684,9 @@ async function importWSConfigModule(inFile, logger) {
|
|
|
14599
14684
|
}
|
|
14600
14685
|
}
|
|
14601
14686
|
async function importDBConfigModule(inFile, logger) {
|
|
14602
|
-
const isCJS = (0,
|
|
14687
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14603
14688
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14604
|
-
const module2 = parser2.parse(mod, DBConfigSchema, (0,
|
|
14689
|
+
const module2 = parser2.parse(mod, DBConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14605
14690
|
if (module2 !== void 0) {
|
|
14606
14691
|
return module2;
|
|
14607
14692
|
} else {
|
|
@@ -14609,7 +14694,7 @@ async function importDBConfigModule(inFile, logger) {
|
|
|
14609
14694
|
}
|
|
14610
14695
|
}
|
|
14611
14696
|
async function importLogConfigModule(inFile, logger) {
|
|
14612
|
-
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));
|
|
14613
14698
|
if (module2 !== void 0) {
|
|
14614
14699
|
return module2;
|
|
14615
14700
|
} else {
|
|
@@ -14617,9 +14702,9 @@ async function importLogConfigModule(inFile, logger) {
|
|
|
14617
14702
|
}
|
|
14618
14703
|
}
|
|
14619
14704
|
async function importServerConfigModule(inFile, logger) {
|
|
14620
|
-
const isCJS = (0,
|
|
14705
|
+
const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
|
|
14621
14706
|
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
14622
|
-
const module2 = parser2.parse(mod, ServerConfigSchema, (0,
|
|
14707
|
+
const module2 = parser2.parse(mod, ServerConfigSchema, (0, import_node_path6.basename)(inFile));
|
|
14623
14708
|
if (module2 !== void 0) {
|
|
14624
14709
|
return module2;
|
|
14625
14710
|
} else {
|
|
@@ -14634,22 +14719,22 @@ async function importJSXFile(inFile, logger) {
|
|
|
14634
14719
|
platform: "node",
|
|
14635
14720
|
logger
|
|
14636
14721
|
});
|
|
14637
|
-
const tmpBuildDir = (0,
|
|
14638
|
-
const inFileTmp = (0,
|
|
14639
|
-
|
|
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, {
|
|
14640
14725
|
recursive: true
|
|
14641
14726
|
});
|
|
14642
14727
|
try {
|
|
14643
|
-
|
|
14728
|
+
await writeFileASync(inFileTmp, inflatedCode);
|
|
14644
14729
|
assertGlobalTampered();
|
|
14645
|
-
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", (0,
|
|
14646
|
-
logger?.debug("importing [%s]", (0,
|
|
14647
|
-
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));
|
|
14648
14733
|
assertGlobalTampered();
|
|
14649
14734
|
if (CLEAR_JSX_CACHE) {
|
|
14650
14735
|
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14651
|
-
|
|
14652
|
-
|
|
14736
|
+
await unlinkASync(inFileTmp);
|
|
14737
|
+
await rmdirASync(tmpBuildDir);
|
|
14653
14738
|
}
|
|
14654
14739
|
return module2.default;
|
|
14655
14740
|
} catch (e) {
|
|
@@ -14657,8 +14742,8 @@ async function importJSXFile(inFile, logger) {
|
|
|
14657
14742
|
logger?.error("error with2: " + inFile);
|
|
14658
14743
|
if (CLEAR_JSX_CACHE) {
|
|
14659
14744
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
14660
|
-
|
|
14661
|
-
|
|
14745
|
+
await unlinkASync(inFileTmp);
|
|
14746
|
+
await rmdirASync(tmpBuildDir);
|
|
14662
14747
|
} else {
|
|
14663
14748
|
logger?.error("error with: %s", inFileTmp);
|
|
14664
14749
|
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
@@ -14738,21 +14823,21 @@ var import_node_process8 = require("node:process");
|
|
|
14738
14823
|
|
|
14739
14824
|
// src/inflate/setup-cors.ts
|
|
14740
14825
|
var import_node_fs7 = require("node:fs");
|
|
14741
|
-
var
|
|
14826
|
+
var import_node_path7 = require("node:path");
|
|
14742
14827
|
var import_node_process4 = require("node:process");
|
|
14743
14828
|
async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
|
|
14744
14829
|
const corsPath = getCORSConfigPath(servicePath);
|
|
14745
14830
|
if (corsPath) {
|
|
14746
14831
|
try {
|
|
14747
14832
|
const corsOptions = await importCORSModule(corsPath, logger);
|
|
14748
|
-
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)));
|
|
14749
14834
|
mainRouter.use(CORS(corsOptions));
|
|
14750
14835
|
if (inflateDir && inflateSea) {
|
|
14751
|
-
const inflatePath = (0,
|
|
14752
|
-
(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), {
|
|
14753
14838
|
recursive: true
|
|
14754
14839
|
});
|
|
14755
|
-
logger.log("writing [%s]", (0,
|
|
14840
|
+
logger.log("writing [%s]", (0, import_node_path7.relative)((0, import_node_process4.cwd)(), inflatePath));
|
|
14756
14841
|
(0, import_node_fs7.writeFileSync)(inflatePath, await inflateJSX(corsPath, {
|
|
14757
14842
|
embemedJSX: false,
|
|
14758
14843
|
minify: false,
|
|
@@ -14773,7 +14858,7 @@ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14773
14858
|
}
|
|
14774
14859
|
|
|
14775
14860
|
// src/inflate/setup-auth.ts
|
|
14776
|
-
var
|
|
14861
|
+
var import_node_path8 = require("node:path");
|
|
14777
14862
|
var import_node_fs8 = require("node:fs");
|
|
14778
14863
|
var import_node_process5 = require("node:process");
|
|
14779
14864
|
async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
|
|
@@ -14781,14 +14866,14 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14781
14866
|
if (authPath) {
|
|
14782
14867
|
try {
|
|
14783
14868
|
const authModule = await importAuthModule(authPath, logger);
|
|
14784
|
-
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)));
|
|
14785
14870
|
mainRouter.use(SessionHandler(authModule));
|
|
14786
14871
|
if (inflateDir && inflateSea) {
|
|
14787
|
-
const inflatePath = (0,
|
|
14788
|
-
(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), {
|
|
14789
14874
|
recursive: true
|
|
14790
14875
|
});
|
|
14791
|
-
logger.log("writing [%s]", (0,
|
|
14876
|
+
logger.log("writing [%s]", (0, import_node_path8.relative)((0, import_node_process5.cwd)(), inflatePath));
|
|
14792
14877
|
(0, import_node_fs8.writeFileSync)(inflatePath, await inflateJSX(authPath, {
|
|
14793
14878
|
embemedJSX: false,
|
|
14794
14879
|
minify: false,
|
|
@@ -14809,11 +14894,11 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14809
14894
|
}
|
|
14810
14895
|
|
|
14811
14896
|
// src/services/utils/get-route.ts
|
|
14812
|
-
var
|
|
14897
|
+
var import_node_path9 = require("node:path");
|
|
14813
14898
|
function getRoutes(prePath, defaultPath, apiOptions) {
|
|
14814
14899
|
const ret = [];
|
|
14815
14900
|
const path = apiOptions && apiOptions.path ? apiOptions.path : defaultPath;
|
|
14816
|
-
const defaultInflatePath = (0,
|
|
14901
|
+
const defaultInflatePath = (0, import_node_path9.join)(prePath, defaultPath);
|
|
14817
14902
|
const method = apiOptions && apiOptions.method ? apiOptions.method : "GET";
|
|
14818
14903
|
const methods = method instanceof Array ? method : [method];
|
|
14819
14904
|
const paths = path instanceof Array ? path : [path];
|
|
@@ -14854,10 +14939,10 @@ function getRoutes(prePath, defaultPath, apiOptions) {
|
|
|
14854
14939
|
response: apiOptions?.response,
|
|
14855
14940
|
session: apiOptions?.session
|
|
14856
14941
|
},
|
|
14857
|
-
inflatePath: p !== "/" ? (0,
|
|
14942
|
+
inflatePath: p !== "/" ? (0, import_node_path9.join)(prePath, p) : defaultInflatePath,
|
|
14858
14943
|
defaultInflatePath,
|
|
14859
14944
|
method: m.toLocaleLowerCase() !== "use" ? m.toUpperCase() : void 0,
|
|
14860
|
-
path: normalizePath((0,
|
|
14945
|
+
path: normalizePath((0, import_node_path9.join)(prePath, p))
|
|
14861
14946
|
});
|
|
14862
14947
|
}
|
|
14863
14948
|
}
|
|
@@ -14865,24 +14950,6 @@ function getRoutes(prePath, defaultPath, apiOptions) {
|
|
|
14865
14950
|
return ret;
|
|
14866
14951
|
}
|
|
14867
14952
|
|
|
14868
|
-
// src/common/fs.ts
|
|
14869
|
-
var import_node_path9 = require("node:path");
|
|
14870
|
-
function describeFilePath(filePath) {
|
|
14871
|
-
const ext = (0, import_node_path9.extname)(filePath);
|
|
14872
|
-
const fileName = (0, import_node_path9.basename)(filePath);
|
|
14873
|
-
const name = fileName.substring(0, fileName.length - ext.length);
|
|
14874
|
-
const subExt = (0, import_node_path9.extname)(name);
|
|
14875
|
-
const subName = name.substring(0, name.length - subExt.length);
|
|
14876
|
-
return {
|
|
14877
|
-
ext,
|
|
14878
|
-
fileName,
|
|
14879
|
-
name,
|
|
14880
|
-
subExt,
|
|
14881
|
-
subName,
|
|
14882
|
-
filePath
|
|
14883
|
-
};
|
|
14884
|
-
}
|
|
14885
|
-
|
|
14886
14953
|
// src/inflate/setup-middleware.ts
|
|
14887
14954
|
var import_node_path10 = require("node:path");
|
|
14888
14955
|
var import_node_fs9 = require("node:fs");
|
|
@@ -14966,7 +15033,7 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
|
|
|
14966
15033
|
}
|
|
14967
15034
|
|
|
14968
15035
|
// src/inflate/setup-http.ts
|
|
14969
|
-
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) {
|
|
14970
15037
|
const mainRouter = new Router();
|
|
14971
15038
|
const apiRouterPath = getHTTPRouterPath(servicePath);
|
|
14972
15039
|
let middlewareConfig = null;
|
|
@@ -14976,13 +15043,13 @@ async function setupHTTPRouter(server2, logger, hotreload, servicePath, service,
|
|
|
14976
15043
|
middlewareConfig = await setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
|
|
14977
15044
|
if (apiRouterPath) {
|
|
14978
15045
|
logger.trace("setting up http routes from [%s]", service);
|
|
14979
|
-
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);
|
|
14980
15047
|
mainRouter.use(httpRouter);
|
|
14981
15048
|
}
|
|
14982
15049
|
const staticFilesPath = getStaticFilesPath(servicePath);
|
|
14983
15050
|
if (staticFilesPath) {
|
|
14984
15051
|
logger.trace("setting up static file routes from [%s]", service);
|
|
14985
|
-
const staticRouter = createStaticRouterFromDirectory(service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap);
|
|
15052
|
+
const staticRouter = await createStaticRouterFromDirectory(service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap, inflateParallel);
|
|
14986
15053
|
mainRouter.use(staticRouter);
|
|
14987
15054
|
}
|
|
14988
15055
|
if (middlewareConfig && middlewareConfig.post) {
|
|
@@ -14992,83 +15059,110 @@ async function setupHTTPRouter(server2, logger, hotreload, servicePath, service,
|
|
|
14992
15059
|
}
|
|
14993
15060
|
return mainRouter;
|
|
14994
15061
|
}
|
|
14995
|
-
function createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap) {
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
|
|
15009
|
-
|
|
15010
|
-
|
|
15011
|
-
};
|
|
15012
|
-
if (inflateDir) {
|
|
15013
|
-
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15014
|
-
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15015
|
-
recursive: true
|
|
15016
|
-
});
|
|
15017
|
-
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15018
|
-
const body = (0, import_node_fs11.readFileSync)(file.filePath);
|
|
15019
|
-
(0, import_node_fs11.writeFileSync)(inflatePath, body);
|
|
15020
|
-
if (staticFileMap) {
|
|
15021
|
-
staticFileMap[file.filePath] = {
|
|
15022
|
-
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,
|
|
15023
15078
|
filePath: file.filePath,
|
|
15024
|
-
previewMethod: "html"
|
|
15025
|
-
method: "GET",
|
|
15026
|
-
path: normalizePath(path),
|
|
15027
|
-
body: Buffer.from(body),
|
|
15028
|
-
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15079
|
+
previewMethod: "html"
|
|
15029
15080
|
};
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
try {
|
|
15036
|
-
(0, import_node_fs11.readFile)(file.filePath, async (err, body) => {
|
|
15037
|
-
if (err) {
|
|
15038
|
-
reject(err);
|
|
15039
|
-
} else {
|
|
15040
|
-
try {
|
|
15041
|
-
await res.asyncEnd({
|
|
15042
|
-
status: 200,
|
|
15043
|
-
headers: {
|
|
15044
|
-
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15045
|
-
},
|
|
15046
|
-
body
|
|
15047
|
-
});
|
|
15048
|
-
resolve24();
|
|
15049
|
-
} catch (e) {
|
|
15050
|
-
reject(e);
|
|
15051
|
-
}
|
|
15052
|
-
}
|
|
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) => {
|
|
15053
15086
|
});
|
|
15054
|
-
|
|
15055
|
-
|
|
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
|
+
}
|
|
15056
15104
|
}
|
|
15057
|
-
|
|
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
|
+
}
|
|
15058
15136
|
});
|
|
15059
15137
|
}
|
|
15060
|
-
function createStaticRouterFromDirectory(service, logger, dir, inflateDir, routeFileMap, staticFileMap) {
|
|
15138
|
+
async function createStaticRouterFromDirectory(service, logger, dir, inflateDir, routeFileMap, staticFileMap, inflateParallel) {
|
|
15061
15139
|
const router = new Router();
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
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
|
+
}
|
|
15065
15155
|
return router;
|
|
15066
15156
|
}
|
|
15067
|
-
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) {
|
|
15068
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 = [];
|
|
15069
15162
|
router.use(assertGlobalTampered);
|
|
15070
|
-
|
|
15071
|
-
|
|
15163
|
+
const files = scanFiles(dir);
|
|
15164
|
+
for (const file of files) {
|
|
15165
|
+
tR.push(new Promise(async (resolve24) => {
|
|
15072
15166
|
try {
|
|
15073
15167
|
switch (file.ext) {
|
|
15074
15168
|
case ".jsx":
|
|
@@ -15102,11 +15196,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15102
15196
|
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
15103
15197
|
const rPath = r.defaultInflatePath;
|
|
15104
15198
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.cjs");
|
|
15105
|
-
|
|
15199
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15106
15200
|
recursive: true
|
|
15107
15201
|
});
|
|
15108
15202
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15109
|
-
|
|
15203
|
+
await writeFileASync(inflatePath, inflatedCode);
|
|
15110
15204
|
}
|
|
15111
15205
|
router.use(assertGlobalTampered);
|
|
15112
15206
|
router.use(module2.handler, r.path, r.method, r.options);
|
|
@@ -15128,7 +15222,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15128
15222
|
if (r.inflatePath) {
|
|
15129
15223
|
const rPath = r.inflatePath;
|
|
15130
15224
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15131
|
-
|
|
15225
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15132
15226
|
recursive: true
|
|
15133
15227
|
});
|
|
15134
15228
|
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
@@ -15137,7 +15231,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15137
15231
|
}
|
|
15138
15232
|
const JSON_STATIC = await getJSON({ server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, module2.default);
|
|
15139
15233
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15140
|
-
|
|
15234
|
+
await writeFileASync(inflatePath, JSON_STATIC);
|
|
15141
15235
|
if (staticFileMap && inflateSea) {
|
|
15142
15236
|
staticFileMap[file.filePath] = {
|
|
15143
15237
|
contentType,
|
|
@@ -15180,7 +15274,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15180
15274
|
if (r.inflatePath) {
|
|
15181
15275
|
const rPath = r.inflatePath;
|
|
15182
15276
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15183
|
-
|
|
15277
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15184
15278
|
recursive: true
|
|
15185
15279
|
});
|
|
15186
15280
|
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
@@ -15190,7 +15284,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15190
15284
|
const toRender = typeof module2.default === "function" ? module2.default({ server: server2 }, null) : module2.default;
|
|
15191
15285
|
const HTML_STATIC = await getHTML(hotreload, { server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, await toRender);
|
|
15192
15286
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15193
|
-
|
|
15287
|
+
await writeFileASync(inflatePath, HTML_STATIC);
|
|
15194
15288
|
if (staticFileMap && inflateSea) {
|
|
15195
15289
|
staticFileMap[file.filePath + r.method + r.path] = {
|
|
15196
15290
|
filePath: file.filePath,
|
|
@@ -15242,11 +15336,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15242
15336
|
};
|
|
15243
15337
|
if (inflateDir) {
|
|
15244
15338
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15245
|
-
|
|
15339
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15246
15340
|
recursive: true
|
|
15247
15341
|
});
|
|
15248
15342
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15249
|
-
|
|
15343
|
+
await writeFileASync(inflatePath, code);
|
|
15250
15344
|
if (staticFileMap && inflateSea) {
|
|
15251
15345
|
staticFileMap[file.filePath] = {
|
|
15252
15346
|
contentType,
|
|
@@ -15291,11 +15385,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15291
15385
|
};
|
|
15292
15386
|
if (inflateDir) {
|
|
15293
15387
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15294
|
-
|
|
15388
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15295
15389
|
recursive: true
|
|
15296
15390
|
});
|
|
15297
15391
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15298
|
-
|
|
15392
|
+
await writeFileASync(inflatePath, code);
|
|
15299
15393
|
if (staticFileMap && inflateSea) {
|
|
15300
15394
|
staticFileMap[file.filePath] = {
|
|
15301
15395
|
contentType,
|
|
@@ -15350,11 +15444,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15350
15444
|
};
|
|
15351
15445
|
if (inflateDir) {
|
|
15352
15446
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15353
|
-
|
|
15447
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15354
15448
|
recursive: true
|
|
15355
15449
|
});
|
|
15356
15450
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15357
|
-
|
|
15451
|
+
await writeFileASync(inflatePath, code);
|
|
15358
15452
|
if (staticFileMap && inflateSea) {
|
|
15359
15453
|
staticFileMap[file.filePath] = {
|
|
15360
15454
|
contentType,
|
|
@@ -15401,11 +15495,11 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15401
15495
|
};
|
|
15402
15496
|
if (inflateDir) {
|
|
15403
15497
|
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15404
|
-
|
|
15498
|
+
await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
|
|
15405
15499
|
recursive: true
|
|
15406
15500
|
});
|
|
15407
15501
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15408
|
-
|
|
15502
|
+
await writeFileASync(inflatePath, code);
|
|
15409
15503
|
if (staticFileMap && inflateSea) {
|
|
15410
15504
|
staticFileMap[file.filePath] = {
|
|
15411
15505
|
contentType,
|
|
@@ -15432,7 +15526,7 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15432
15526
|
}
|
|
15433
15527
|
}
|
|
15434
15528
|
}
|
|
15435
|
-
createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
|
|
15529
|
+
await createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
|
|
15436
15530
|
return resolve24();
|
|
15437
15531
|
}
|
|
15438
15532
|
} catch (e) {
|
|
@@ -15445,7 +15539,15 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15445
15539
|
} finally {
|
|
15446
15540
|
return resolve24();
|
|
15447
15541
|
}
|
|
15448
|
-
});
|
|
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 = [];
|
|
15449
15551
|
}
|
|
15450
15552
|
router.use(assertGlobalTampered);
|
|
15451
15553
|
return {
|
|
@@ -15535,25 +15637,25 @@ var import_node_process10 = require("node:process");
|
|
|
15535
15637
|
async function inflateSeaAssets(logger, inflateDir) {
|
|
15536
15638
|
const esbuildBinaryBuffer2 = Buffer.from(getAsset("esbuild-binary"));
|
|
15537
15639
|
if (import_node_process10.platform === "win32") {
|
|
15538
|
-
|
|
15640
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "esbuild.exe"), esbuildBinaryBuffer2);
|
|
15539
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);
|
|
15540
15642
|
} else {
|
|
15541
|
-
|
|
15643
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "esbuild"), esbuildBinaryBuffer2);
|
|
15542
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);
|
|
15543
15645
|
}
|
|
15544
|
-
|
|
15545
|
-
|
|
15546
|
-
|
|
15547
|
-
|
|
15548
|
-
|
|
15549
|
-
|
|
15550
|
-
|
|
15551
|
-
|
|
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")));
|
|
15552
15654
|
}
|
|
15553
15655
|
async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
15554
15656
|
const PORT2 = port;
|
|
15555
15657
|
inflateSeaAssets(logger, inflateDir);
|
|
15556
|
-
|
|
15658
|
+
writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
15557
15659
|
const WSLIST = services.filter((service) => getWSConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
15558
15660
|
return `(await import("../${service}/ws.cjs")).default`;
|
|
15559
15661
|
}).join(",");
|
|
@@ -15572,8 +15674,8 @@ async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
15572
15674
|
|
|
15573
15675
|
})`;
|
|
15574
15676
|
}).join(",");
|
|
15575
|
-
|
|
15576
|
-
|
|
15677
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
15678
|
+
writeFile2(
|
|
15577
15679
|
logger,
|
|
15578
15680
|
(0, import_node_path14.join)(inflateDir, "sea", "app.cjs"),
|
|
15579
15681
|
`const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
@@ -15631,11 +15733,15 @@ main().catch(e=>console.error(e));
|
|
|
15631
15733
|
platform: "node",
|
|
15632
15734
|
outfile: (0, import_node_path14.join)(inflateDir, "sea", "app.bundle.cjs")
|
|
15633
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
|
+
}
|
|
15634
15740
|
}
|
|
15635
15741
|
async function inflateServiceForSea(logger, inflateDir, service, servicePath, serviceRouteFileMap, serviceStaticFileMap) {
|
|
15636
15742
|
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
15637
15743
|
const serviceMigrations = migrationsFolderPath ? lib_exports.getSortedMigrations(migrationsFolderPath) : [];
|
|
15638
|
-
|
|
15744
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";
|
|
15639
15745
|
|
|
15640
15746
|
export async function setupRouter() {
|
|
15641
15747
|
const router = new Router();
|
|
@@ -15676,7 +15782,7 @@ ${getMiddlewareConfigPath(servicePath) ? `
|
|
|
15676
15782
|
|
|
15677
15783
|
return router;
|
|
15678
15784
|
}`);
|
|
15679
|
-
|
|
15785
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-up.js"), `import { migration } from "./../lib.cjs";
|
|
15680
15786
|
|
|
15681
15787
|
export async function runMigrations(db) {
|
|
15682
15788
|
await migration.init(db);
|
|
@@ -15685,7 +15791,7 @@ ${serviceMigrations.map((file) => {
|
|
|
15685
15791
|
return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
15686
15792
|
}).join("\n")}
|
|
15687
15793
|
}`);
|
|
15688
|
-
|
|
15794
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.js"), `import { migration } from "./../lib.cjs";
|
|
15689
15795
|
|
|
15690
15796
|
export async function runMigrations(db) {
|
|
15691
15797
|
await migration.init(db);
|
|
@@ -15695,7 +15801,7 @@ ${serviceMigrations.reverse().map((file) => {
|
|
|
15695
15801
|
}).join("\n")}
|
|
15696
15802
|
}`);
|
|
15697
15803
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
15698
|
-
|
|
15804
|
+
writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "static-router.js"), `import { appendAPIModule, Router } from "./../lib.cjs";
|
|
15699
15805
|
|
|
15700
15806
|
export async function setupRouter() {
|
|
15701
15807
|
const router = new Router();
|
|
@@ -15715,7 +15821,7 @@ ${staticFiles.map((filePath) => {
|
|
|
15715
15821
|
return router;
|
|
15716
15822
|
}`);
|
|
15717
15823
|
}
|
|
15718
|
-
function
|
|
15824
|
+
function writeFile2(logger, path, buffer) {
|
|
15719
15825
|
logger.log("writing [%s]", (0, import_node_path14.relative)((0, import_node_process10.cwd)(), path));
|
|
15720
15826
|
(0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(path), {
|
|
15721
15827
|
recursive: true
|
|
@@ -16083,7 +16189,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, infla
|
|
|
16083
16189
|
}
|
|
16084
16190
|
|
|
16085
16191
|
// src/inflate/inflate.ts
|
|
16086
|
-
async function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
|
|
16192
|
+
async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
|
|
16087
16193
|
logger.trace("inflateApp");
|
|
16088
16194
|
const errors = [];
|
|
16089
16195
|
let routeFileMap = {};
|
|
@@ -16096,7 +16202,7 @@ async function inflateApp({ serverInterface, logger, hotreload, services, inflat
|
|
|
16096
16202
|
const serviceStaticFileMap = inflateSea ? {} : null;
|
|
16097
16203
|
const servicePath = getServicePath(service);
|
|
16098
16204
|
await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, errors);
|
|
16099
|
-
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));
|
|
16100
16206
|
routeFileMap = {
|
|
16101
16207
|
...routeFileMap,
|
|
16102
16208
|
...serviceRouteFileMap
|
|
@@ -16651,7 +16757,8 @@ var MiqroJSONSchema = {
|
|
|
16651
16757
|
editor: "boolean?",
|
|
16652
16758
|
https: "boolean?",
|
|
16653
16759
|
serverOptions: "any?",
|
|
16654
|
-
httpsRedirect: "number?"
|
|
16760
|
+
httpsRedirect: "number?",
|
|
16761
|
+
inflateParallel: "number?"
|
|
16655
16762
|
}
|
|
16656
16763
|
};
|
|
16657
16764
|
function importMiqroJSON(inFile) {
|
|
@@ -16862,6 +16969,7 @@ var Miqro = class _Miqro {
|
|
|
16862
16969
|
});
|
|
16863
16970
|
await app.inflate({
|
|
16864
16971
|
inflateDir: miqroJSON.inflateDir ? String(miqroJSON.inflateDir) : void 0,
|
|
16972
|
+
inflateParallel: miqroJSON.inflateParallel ? miqroJSON.inflateParallel : void 0,
|
|
16865
16973
|
...inflate ? inflate : {}
|
|
16866
16974
|
});
|
|
16867
16975
|
return app;
|
|
@@ -17011,7 +17119,8 @@ var Miqro = class _Miqro {
|
|
|
17011
17119
|
inflateDir: options?.inflateDir,
|
|
17012
17120
|
inflateSea: options?.inflateSea ? true : false,
|
|
17013
17121
|
//inflateTests: options?.inflateTests ? true : false,
|
|
17014
|
-
hotreload: this.options?.hotreload ? true : false
|
|
17122
|
+
hotreload: this.options?.hotreload ? true : false,
|
|
17123
|
+
inflateParallel: options?.inflateParallel
|
|
17015
17124
|
});
|
|
17016
17125
|
wsConfigList.push(...serviceWSConfigList);
|
|
17017
17126
|
router.use(serviceRouter);
|