miqro 6.2.1 → 6.2.3

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.
Files changed (37) hide show
  1. package/build/esm/src/common/jsx.d.ts +1 -0
  2. package/build/esm/src/common/jsx.js +10 -6
  3. package/build/esm/src/inflate/inflate-sea.d.ts +1 -1
  4. package/build/esm/src/inflate/inflate-sea.js +15 -13
  5. package/build/esm/src/inflate/inflate.d.ts +2 -1
  6. package/build/esm/src/inflate/inflate.js +2 -2
  7. package/build/esm/src/inflate/setup-auth.js +2 -1
  8. package/build/esm/src/inflate/setup-cors.js +2 -1
  9. package/build/esm/src/inflate/setup-db.js +4 -2
  10. package/build/esm/src/inflate/setup-error.js +2 -1
  11. package/build/esm/src/inflate/setup-http.js +2 -1
  12. package/build/esm/src/inflate/setup-log.js +2 -1
  13. package/build/esm/src/inflate/setup-middleware.js +2 -1
  14. package/build/esm/src/inflate/setup-server-config.js +2 -1
  15. package/build/esm/src/inflate/setup-ws.js +2 -1
  16. package/build/esm/src/services/app.js +21 -17
  17. package/build/esm/src/services/hot-reload.js +4 -1
  18. package/build/esm/src/services/migrations.js +4 -2
  19. package/build/esm/src/services/utils/websocketmanager.js +1 -1
  20. package/build/lib.cjs +56 -59
  21. package/package.json +1 -1
  22. package/src/common/jsx.ts +11 -6
  23. package/src/inflate/inflate-sea.ts +16 -13
  24. package/src/inflate/inflate.ts +3 -2
  25. package/src/inflate/setup-auth.ts +2 -1
  26. package/src/inflate/setup-cors.ts +2 -1
  27. package/src/inflate/setup-db.ts +4 -2
  28. package/src/inflate/setup-error.ts +2 -1
  29. package/src/inflate/setup-http.ts +2 -1
  30. package/src/inflate/setup-log.ts +2 -1
  31. package/src/inflate/setup-middleware.ts +2 -1
  32. package/src/inflate/setup-server-config.ts +2 -1
  33. package/src/inflate/setup-ws.ts +2 -1
  34. package/src/services/app.ts +9 -5
  35. package/src/services/hot-reload.ts +4 -1
  36. package/src/services/migrations.ts +4 -2
  37. package/src/services/utils/websocketmanager.ts +1 -1
package/build/lib.cjs CHANGED
@@ -9060,7 +9060,7 @@ var WebSocketManager = class {
9060
9060
  this.onUpgrade = this.onUpgrade.bind(this);
9061
9061
  this.logger = options && options.logger ? options.logger : null;
9062
9062
  this.name = options && options.name ? options.name : "WebSocketManager";
9063
- this.loggerProvider = options.loggerProvider;
9063
+ this.loggerProvider = options && options.loggerProvider;
9064
9064
  this.avoidLogSocket = options && options.avoidLogSocket ? options.avoidLogSocket : false;
9065
9065
  }
9066
9066
  deleteWS(path) {
@@ -14343,7 +14343,8 @@ async function inflateJSX(inFile, options) {
14343
14343
  const { outputFiles: [{ contents }] } = await esBuild({
14344
14344
  ...DEFAULT_ESOPTION,
14345
14345
  entryPoints: [inFileTmp],
14346
- minify: options.minify
14346
+ minify: options.minify,
14347
+ platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
14347
14348
  });
14348
14349
  if (CLEAR_JSX_CACHE) {
14349
14350
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
@@ -14360,7 +14361,8 @@ async function inflateJSX(inFile, options) {
14360
14361
  const { outputFiles: [{ contents }] } = await esBuild({
14361
14362
  ...DEFAULT_ESOPTION,
14362
14363
  entryPoints: [inFileTmp],
14363
- minify: options.minify
14364
+ minify: options.minify,
14365
+ platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
14364
14366
  });
14365
14367
  if (CLEAR_JSX_CACHE) {
14366
14368
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
@@ -14661,10 +14663,11 @@ async function importJSXFile(inFile, logger) {
14661
14663
  embemedJSX: false,
14662
14664
  minify: false,
14663
14665
  useExport: true,
14666
+ platform: "node",
14664
14667
  logger
14665
14668
  });
14666
14669
  const tmpBuildDir = (0, import_node_path5.resolve)(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + (0, import_node_crypto4.randomUUID)());
14667
- const inFileTmp = (0, import_node_path5.resolve)(tmpBuildDir, (0, import_node_path5.basename)(inFile) + ".mjs");
14670
+ const inFileTmp = (0, import_node_path5.resolve)(tmpBuildDir, (0, import_node_path5.basename)(inFile) + ".cjs");
14668
14671
  (0, import_node_fs6.mkdirSync)(tmpBuildDir, {
14669
14672
  recursive: true
14670
14673
  });
@@ -14673,17 +14676,17 @@ async function importJSXFile(inFile, logger) {
14673
14676
  assertGlobalTampered();
14674
14677
  logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", (0, import_node_path5.relative)((0, import_node_process3.cwd)(), inFile), (0, import_node_path5.dirname)((0, import_node_path5.relative)(JSX_TMP_DIR, inFileTmp)));
14675
14678
  logger?.debug("importing [%s]", (0, import_node_path5.relative)((0, import_node_process3.cwd)(), inFile));
14676
- const module2 = await import(inFileTmp);
14679
+ const module2 = await import((0, import_node_path5.resolve)(inFileTmp));
14677
14680
  assertGlobalTampered();
14678
14681
  if (CLEAR_JSX_CACHE) {
14679
14682
  logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
14680
14683
  (0, import_node_fs6.unlinkSync)(inFileTmp);
14681
14684
  (0, import_node_fs6.rmdirSync)(tmpBuildDir);
14682
14685
  }
14683
- return module2;
14686
+ return module2.default;
14684
14687
  } catch (e) {
14685
14688
  logger?.error(e);
14686
- logger?.error("error with: " + inFile);
14689
+ logger?.error("error with2: " + inFile);
14687
14690
  if (CLEAR_JSX_CACHE) {
14688
14691
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
14689
14692
  (0, import_node_fs6.unlinkSync)(inFileTmp);
@@ -14735,7 +14738,10 @@ function tryConnection() {
14735
14738
  const newSocket = getSocket();
14736
14739
  newSocket.addEventListener("open", (event) => {
14737
14740
  console.log("reloading");
14738
- window.location.reload();
14741
+ setTimeout(()=>{
14742
+ window.location.reload();
14743
+ }, 500);
14744
+
14739
14745
  });
14740
14746
  newSocket.addEventListener("error", (err) => {
14741
14747
  console.error(err);
@@ -14774,7 +14780,7 @@ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, i
14774
14780
  logger.debug("setting up cors from [%s]", (0, import_node_path6.join)(service, (0, import_node_path6.basename)(corsPath)));
14775
14781
  mainRouter.use(CORS(corsOptions));
14776
14782
  if (inflateDir && inflateSea) {
14777
- const inflatePath = (0, import_node_path6.resolve)(inflateDir, service, "cors.js");
14783
+ const inflatePath = (0, import_node_path6.resolve)(inflateDir, service, "cors.cjs");
14778
14784
  (0, import_node_fs7.mkdirSync)((0, import_node_path6.dirname)(inflatePath), {
14779
14785
  recursive: true
14780
14786
  });
@@ -14783,6 +14789,7 @@ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, i
14783
14789
  embemedJSX: false,
14784
14790
  minify: false,
14785
14791
  useExport: true,
14792
+ platform: "node",
14786
14793
  logger
14787
14794
  }));
14788
14795
  }
@@ -14809,7 +14816,7 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
14809
14816
  logger.debug("setting up authentication from [%s]", (0, import_node_path7.join)(service, (0, import_node_path7.basename)(authPath)));
14810
14817
  mainRouter.use(SessionHandler(authModule));
14811
14818
  if (inflateDir && inflateSea) {
14812
- const inflatePath = (0, import_node_path7.resolve)(inflateDir, service, "auth.js");
14819
+ const inflatePath = (0, import_node_path7.resolve)(inflateDir, service, "auth.cjs");
14813
14820
  (0, import_node_fs8.mkdirSync)((0, import_node_path7.dirname)(inflatePath), {
14814
14821
  recursive: true
14815
14822
  });
@@ -14818,6 +14825,7 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
14818
14825
  embemedJSX: false,
14819
14826
  minify: false,
14820
14827
  useExport: true,
14828
+ platform: "node",
14821
14829
  logger
14822
14830
  }));
14823
14831
  }
@@ -14923,7 +14931,7 @@ async function setupMiddleware(logger, servicePath, service, mainRouter, inflate
14923
14931
  }
14924
14932
  }
14925
14933
  if (inflateDir && inflateSea) {
14926
- const inflatePath = (0, import_node_path10.resolve)(inflateDir, service, "middleware.js");
14934
+ const inflatePath = (0, import_node_path10.resolve)(inflateDir, service, "middleware.cjs");
14927
14935
  (0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(inflatePath), {
14928
14936
  recursive: true
14929
14937
  });
@@ -14931,6 +14939,7 @@ async function setupMiddleware(logger, servicePath, service, mainRouter, inflate
14931
14939
  (0, import_node_fs9.writeFileSync)(inflatePath, await inflateJSX(middlewarePath, {
14932
14940
  embemedJSX: false,
14933
14941
  minify: false,
14942
+ platform: "node",
14934
14943
  useExport: true,
14935
14944
  logger
14936
14945
  }));
@@ -14964,7 +14973,7 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
14964
14973
  }
14965
14974
  }
14966
14975
  if (inflateDir && inflateSea) {
14967
- const inflatePath = (0, import_node_path11.resolve)(inflateDir, service, "catch.js");
14976
+ const inflatePath = (0, import_node_path11.resolve)(inflateDir, service, "catch.cjs");
14968
14977
  (0, import_node_fs10.mkdirSync)((0, import_node_path11.dirname)(inflatePath), {
14969
14978
  recursive: true
14970
14979
  });
@@ -14973,6 +14982,7 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
14973
14982
  embemedJSX: false,
14974
14983
  minify: false,
14975
14984
  useExport: true,
14985
+ platform: "node",
14976
14986
  logger
14977
14987
  }));
14978
14988
  }
@@ -15115,12 +15125,13 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
15115
15125
  embemedJSX: false,
15116
15126
  minify: false,
15117
15127
  useExport: true,
15128
+ platform: "node",
15118
15129
  logger
15119
15130
  }) : "";
15120
15131
  for (const r of routes) {
15121
15132
  if (inflateDir && r.defaultInflatePath && inflateSea) {
15122
15133
  const rPath = r.defaultInflatePath;
15123
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.js");
15134
+ const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.cjs");
15124
15135
  (0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
15125
15136
  recursive: true
15126
15137
  });
@@ -15522,7 +15533,7 @@ async function inflateWSConfig(logger, servicePath, service, wsConfigList, infla
15522
15533
  wsConfigList.push(wsConfig);
15523
15534
  }
15524
15535
  if (inflateDir) {
15525
- const inflatePath = (0, import_node_path13.resolve)(inflateDir, service, "ws.js");
15536
+ const inflatePath = (0, import_node_path13.resolve)(inflateDir, service, "ws.cjs");
15526
15537
  (0, import_node_fs12.mkdirSync)((0, import_node_path13.dirname)(inflatePath), {
15527
15538
  recursive: true
15528
15539
  });
@@ -15530,6 +15541,7 @@ async function inflateWSConfig(logger, servicePath, service, wsConfigList, infla
15530
15541
  (0, import_node_fs12.writeFileSync)(inflatePath, await inflateJSX(wsPath, {
15531
15542
  embemedJSX: false,
15532
15543
  minify: false,
15544
+ platform: "node",
15533
15545
  useExport: true,
15534
15546
  logger
15535
15547
  }));
@@ -15567,19 +15579,20 @@ async function inflateSeaAssets(logger, inflateDir) {
15567
15579
  writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "sign-remove.sh"), Buffer.from(getAsset("sign-remove.sh")));
15568
15580
  writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
15569
15581
  }
15570
- async function inflateAppForSea(logger, inflateDir, services) {
15582
+ async function inflateAppForSea(logger, inflateDir, services, port) {
15583
+ const PORT2 = port;
15571
15584
  inflateSeaAssets(logger, inflateDir);
15572
15585
  writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
15573
15586
  const WSLIST = services.filter((service) => getWSConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
15574
- return `(await import("../${service}/ws.js")).default`;
15587
+ return `(await import("../${service}/ws.cjs")).default`;
15575
15588
  }).join(",");
15576
15589
  const SERVERCONFIGLIST = services.filter((service) => getServerConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
15577
- return `(await import("../${service}/server.js")).default`;
15590
+ return `(await import("../${service}/server.cjs")).default`;
15578
15591
  }).join(",\n");
15579
15592
  const DBCONFIGLIST = services.filter((service) => getDBConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
15580
15593
  return `new Promise(async (resolve, reject) => {
15581
15594
  try {
15582
- const db = await dbManager.setupDB((await import("../${service}/db.js")).default);
15595
+ const db = await dbManager.setupDB((await import("../${service}/db.cjs")).default);
15583
15596
  await (await import("./${service}/migration-up.js")).runMigrations(db);
15584
15597
  resolve();
15585
15598
  } catch(e) {
@@ -15595,7 +15608,7 @@ async function inflateAppForSea(logger, inflateDir, services) {
15595
15608
  `const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
15596
15609
 
15597
15610
  async function main() {
15598
- const PORT = process.env["PORT"] ? process.env["PORT"] : 8080;
15611
+ const PORT = "${PORT2}";
15599
15612
  const loggerProvider = new LogProvider();
15600
15613
  const localCache = new LocalCache();
15601
15614
  const cache = new ClusterCache();
@@ -15632,6 +15645,7 @@ async function main() {
15632
15645
  await app.listen(PORT);
15633
15646
  ${SERVERCONFIGLIST ? `
15634
15647
  await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
15648
+ loggerProvider.getLogger("server").info("listening on [%s]", PORT);
15635
15649
  }
15636
15650
  main().catch(e=>console.error(e));
15637
15651
  `
@@ -15645,16 +15659,16 @@ async function inflateServiceForSea(logger, inflateDir, service, servicePath, se
15645
15659
  export async function setupRouter() {
15646
15660
  const router = new Router();
15647
15661
  ${getErrorConfigPath(servicePath) ? `
15648
- const errorConfig = (await import("../../${service}/catch.js")).default;
15662
+ const errorConfig = (await import("../../${service}/catch.cjs")).default.default;
15649
15663
  if(errorConfig && errorConfig.catch) {
15650
15664
  for(const m of errorConfig.catch) {
15651
15665
  router.catch(m);
15652
15666
  }
15653
15667
  }` : ""}
15654
- ${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.js")).default));` : ""}
15655
- ${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.js")).default));` : ""}
15668
+ ${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.cjs")).default.default));` : ""}
15669
+ ${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.cjs")).default.default));` : ""}
15656
15670
  ${getMiddlewareConfigPath(servicePath) ? `
15657
- const middlewareConfig = (await import("../../${service}/middleware.js")).default;
15671
+ const middlewareConfig = (await import("../../${service}/middleware.cjs")).default.default;
15658
15672
  if(middlewareConfig && middlewareConfig.middleware) {
15659
15673
  for(const m of middlewareConfig.middleware) {
15660
15674
  router.use(m);
@@ -15664,8 +15678,8 @@ ${Object.keys(serviceRouteFileMap).map((filePath) => serviceRouteFileMap[filePat
15664
15678
  const rPath = (0, import_node_path14.join)((0, import_node_path14.relative)((0, import_node_process10.cwd)(), (0, import_node_path14.dirname)(data.filePath)), (0, import_node_path14.basename)(data.filePath));
15665
15679
  if (rPath) {
15666
15680
  const rPathExt = (0, import_node_path14.extname)(rPath);
15667
- const apiInflatedPath = (0, import_node_path14.join)("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".js");
15668
- return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default);`;
15681
+ const apiInflatedPath = (0, import_node_path14.join)("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
15682
+ return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default.default);`;
15669
15683
  } else {
15670
15684
  return "";
15671
15685
  }
@@ -15687,7 +15701,7 @@ export async function runMigrations(db) {
15687
15701
  await migration.init(db);
15688
15702
  ${serviceMigrations.map((file) => {
15689
15703
  const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
15690
- return ` await migration.up.module(db, "${name}", (await import("../../${service}/migration/${name}.js")).default)`;
15704
+ return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
15691
15705
  }).join("\n")}
15692
15706
  }`);
15693
15707
  writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.js"), `import { migration } from "./../lib.cjs";
@@ -15696,7 +15710,7 @@ export async function runMigrations(db) {
15696
15710
  await migration.init(db);
15697
15711
  ${serviceMigrations.reverse().map((file) => {
15698
15712
  const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
15699
- return ` await migration.down.module(db, "${name}", (await import("../../${service}/migration/${name}.js")).default)`;
15713
+ return ` await migration.down.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
15700
15714
  }).join("\n")}
15701
15715
  }`);
15702
15716
  const staticFiles = Object.keys(serviceStaticFileMap);
@@ -15739,7 +15753,7 @@ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflat
15739
15753
  const logConfig = await importLogConfigModule(logPath, logger);
15740
15754
  logConfigMap[service] = logConfig;
15741
15755
  if (inflateDir) {
15742
- const inflatePath = (0, import_node_path15.resolve)(inflateDir, service, "log.js");
15756
+ const inflatePath = (0, import_node_path15.resolve)(inflateDir, service, "log.cjs");
15743
15757
  (0, import_node_fs14.mkdirSync)((0, import_node_path15.dirname)(inflatePath), {
15744
15758
  recursive: true
15745
15759
  });
@@ -15748,6 +15762,7 @@ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflat
15748
15762
  embemedJSX: false,
15749
15763
  minify: false,
15750
15764
  useExport: true,
15765
+ platform: "node",
15751
15766
  logger
15752
15767
  }));
15753
15768
  }
@@ -16087,15 +16102,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, infla
16087
16102
  }
16088
16103
 
16089
16104
  // src/inflate/inflate.ts
16090
- async function inflateApp({
16091
- serverInterface,
16092
- logger,
16093
- hotreload,
16094
- services,
16095
- inflateDir,
16096
- inflateSea
16097
- /*, editor, inflateTests*/
16098
- }) {
16105
+ async function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
16099
16106
  logger.trace("inflateApp");
16100
16107
  const errors = [];
16101
16108
  let routeFileMap = {};
@@ -16120,7 +16127,7 @@ async function inflateApp({
16120
16127
  }
16121
16128
  }
16122
16129
  if (inflateDir && inflateSea) {
16123
- await inflateAppForSea(logger, inflateDir, services);
16130
+ await inflateAppForSea(logger, inflateDir, services, port);
16124
16131
  }
16125
16132
  router.use(assertGlobalTampered);
16126
16133
  return errors.length === 0 ? [router, null, routeFileMap, wsConfigList, logConfigMap] : [router, errors, routeFileMap, wsConfigList, logConfigMap];
@@ -16137,7 +16144,7 @@ async function setupServerConfig(logger, servicePath, service, serverConfigMap,
16137
16144
  const serverConfig = await importServerConfigModule(serverPath, logger);
16138
16145
  serverConfigMap[service] = serverConfig;
16139
16146
  if (inflateDir) {
16140
- const inflatePath = (0, import_node_path17.resolve)(inflateDir, service, "server.js");
16147
+ const inflatePath = (0, import_node_path17.resolve)(inflateDir, service, "server.cjs");
16141
16148
  (0, import_node_fs16.mkdirSync)((0, import_node_path17.dirname)(inflatePath), {
16142
16149
  recursive: true
16143
16150
  });
@@ -16145,6 +16152,7 @@ async function setupServerConfig(logger, servicePath, service, serverConfigMap,
16145
16152
  (0, import_node_fs16.writeFileSync)(inflatePath, await inflateJSX(serverPath, {
16146
16153
  embemedJSX: false,
16147
16154
  minify: false,
16155
+ platform: "node",
16148
16156
  useExport: true,
16149
16157
  logger
16150
16158
  }));
@@ -16488,7 +16496,7 @@ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors
16488
16496
  }
16489
16497
  if (config) {
16490
16498
  if (inflateDir) {
16491
- const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "db.js");
16499
+ const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "db.cjs");
16492
16500
  (0, import_node_fs25.mkdirSync)((0, import_node_path28.dirname)(inflatePath), {
16493
16501
  recursive: true
16494
16502
  });
@@ -16497,6 +16505,7 @@ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors
16497
16505
  embemedJSX: false,
16498
16506
  minify: false,
16499
16507
  useExport: true,
16508
+ platform: "node",
16500
16509
  logger
16501
16510
  }));
16502
16511
  }
@@ -16532,7 +16541,7 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
16532
16541
  ...migrationModule
16533
16542
  });
16534
16543
  if (inflateDir) {
16535
- const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - (0, import_node_path28.extname)(migrationName).length) + ".js");
16544
+ const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - (0, import_node_path28.extname)(migrationName).length) + ".cjs");
16536
16545
  (0, import_node_fs25.mkdirSync)((0, import_node_path28.dirname)(inflatePath), {
16537
16546
  recursive: true
16538
16547
  });
@@ -16541,6 +16550,7 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
16541
16550
  embemedJSX: false,
16542
16551
  minify: false,
16543
16552
  useExport: true,
16553
+ platform: "node",
16544
16554
  logger
16545
16555
  }));
16546
16556
  }
@@ -17016,6 +17026,7 @@ var Miqro = class _Miqro {
17016
17026
  services: this.options.services,
17017
17027
  serverInterface: this.serverInterface,
17018
17028
  //dbManager: this.dbManager,
17029
+ port: this.options.port,
17019
17030
  inflateDir: options?.inflateDir,
17020
17031
  inflateSea: options?.inflateSea ? true : false,
17021
17032
  //inflateTests: options?.inflateTests ? true : false,
@@ -17093,15 +17104,8 @@ var Miqro = class _Miqro {
17093
17104
  reloadInflatedRouter(this);
17094
17105
  await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "load");
17095
17106
  if (this.logger && (import_node_cluster3.default.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
17096
- this.logger?.debug(" ==http routes==");
17097
- this.server.logPaths({
17098
- debug: this.logger.debug.bind(this.logger),
17099
- error: this.logger.error.bind(this.logger),
17100
- info: this.logger.debug.bind(this.logger),
17101
- log: this.logger.debug.bind(this.logger),
17102
- trace: this.logger.trace.bind(this.logger),
17103
- warn: this.logger.warn.bind(this.logger)
17104
- });
17107
+ this.logger?.info(" ==http routes==");
17108
+ this.server.logPaths(this.logger);
17105
17109
  }
17106
17110
  this.logger?.trace("calling listen on [%s]", this.options.port);
17107
17111
  await this.server.listen(this.options.port);
@@ -17212,15 +17216,8 @@ var Miqro = class _Miqro {
17212
17216
  this.webSocketManager.replaceALLWSBuLOGSocket(this.inflated.wsConfigList);
17213
17217
  await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "load");
17214
17218
  if (this.logger && (import_node_cluster3.default.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
17215
- this.logger?.debug(" ==http routes==");
17216
- this.server.logPaths({
17217
- debug: this.logger.debug.bind(this.logger),
17218
- error: this.logger.error.bind(this.logger),
17219
- info: this.logger.debug.bind(this.logger),
17220
- log: this.logger.debug.bind(this.logger),
17221
- trace: this.logger.trace.bind(this.logger),
17222
- warn: this.logger.warn.bind(this.logger)
17223
- });
17219
+ this.logger?.info(" ==http routes==");
17220
+ this.server.logPaths(this.logger);
17224
17221
  }
17225
17222
  this.logger?.debug(" ==reload done==");
17226
17223
  this.status = "started";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miqro",
3
- "version": "6.2.1",
3
+ "version": "6.2.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "build/esm/src/lib.js",
package/src/common/jsx.ts CHANGED
@@ -50,6 +50,7 @@ export interface InflateOptions {
50
50
  embemedJSX: boolean;
51
51
  minify: boolean;
52
52
  useExport: boolean;
53
+ platform?: string;
53
54
  logger?: Logger | Console;
54
55
  }
55
56
 
@@ -78,7 +79,8 @@ export async function inflateJSX(inFile: string, options: InflateOptions): Promi
78
79
  const { outputFiles: [{ contents }] } = await esBuild({
79
80
  ...DEFAULT_ESOPTION,
80
81
  entryPoints: [inFileTmp],
81
- minify: options.minify
82
+ minify: options.minify,
83
+ platform: options.platform ? options.platform: DEFAULT_ESOPTION.platform
82
84
  });
83
85
  if (CLEAR_JSX_CACHE) {
84
86
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
@@ -97,7 +99,8 @@ export async function inflateJSX(inFile: string, options: InflateOptions): Promi
97
99
  const { outputFiles: [{ contents }] } = await esBuild({
98
100
  ...DEFAULT_ESOPTION,
99
101
  entryPoints: [inFileTmp],
100
- minify: options.minify
102
+ minify: options.minify,
103
+ platform: options.platform ? options.platform: DEFAULT_ESOPTION.platform
101
104
  });
102
105
  if (CLEAR_JSX_CACHE) {
103
106
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
@@ -449,10 +452,12 @@ export async function importJSXFile(inFile: string, logger?: Logger | Console):
449
452
  embemedJSX: false,
450
453
  minify: false,
451
454
  useExport: true,
455
+ platform: "node",
452
456
  logger
453
457
  });
454
458
  const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + randomUUID());
455
- const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
459
+ //const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
460
+ const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
456
461
  //const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
457
462
  mkdirSync(tmpBuildDir, {
458
463
  recursive: true
@@ -462,17 +467,17 @@ export async function importJSXFile(inFile: string, logger?: Logger | Console):
462
467
  assertGlobalTampered();
463
468
  logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
464
469
  logger?.debug("importing [%s]", relative(cwd(), inFile));
465
- const module = await import(inFileTmp);
470
+ const module = await import(resolve(inFileTmp));
466
471
  assertGlobalTampered();
467
472
  if (CLEAR_JSX_CACHE) {
468
473
  logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
469
474
  unlinkSync(inFileTmp);
470
475
  rmdirSync(tmpBuildDir);
471
476
  }
472
- return module;
477
+ return module.default;
473
478
  } catch (e) {
474
479
  logger?.error(e);
475
- logger?.error("error with: " + inFile);
480
+ logger?.error("error with2: " + inFile);
476
481
  if (CLEAR_JSX_CACHE) {
477
482
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
478
483
  unlinkSync(inFileTmp);
@@ -37,24 +37,26 @@ export async function inflateSeaAssets(logger: Logger, inflateDir: string) {
37
37
  writeFile(logger, resolve(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
38
38
  }
39
39
 
40
- export async function inflateAppForSea(logger: Logger, inflateDir: string, services: string[]) {
40
+ export async function inflateAppForSea(logger: Logger, inflateDir: string, services: string[], port: string) {
41
+
42
+ const PORT = port;
41
43
 
42
44
  inflateSeaAssets(logger, inflateDir);
43
45
 
44
46
  writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
45
47
 
46
48
  const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
47
- return `(await import("../${service}/ws.js")).default`;
49
+ return `(await import("../${service}/ws.cjs")).default`;
48
50
  }).join(",")
49
51
 
50
52
  const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
51
- return `(await import("../${service}/server.js")).default`;
53
+ return `(await import("../${service}/server.cjs")).default`;
52
54
  }).join(",\n");
53
55
 
54
56
  const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
55
57
  return `new Promise(async (resolve, reject) => {
56
58
  try {
57
- const db = await dbManager.setupDB((await import("../${service}/db.js")).default);
59
+ const db = await dbManager.setupDB((await import("../${service}/db.cjs")).default);
58
60
  await (await import("./${service}/migration-up.js")).runMigrations(db);
59
61
  resolve();
60
62
  } catch(e) {
@@ -69,7 +71,7 @@ export async function inflateAppForSea(logger: Logger, inflateDir: string, servi
69
71
  writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
70
72
 
71
73
  async function main() {
72
- const PORT = process.env["PORT"] ? process.env["PORT"] : 8080;
74
+ const PORT = "${PORT}";
73
75
  const loggerProvider = new LogProvider();
74
76
  const localCache = new LocalCache();
75
77
  const cache = new ClusterCache();
@@ -100,6 +102,7 @@ async function main() {
100
102
 
101
103
  await app.listen(PORT);
102
104
  ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
105
+ loggerProvider.getLogger("server").info("listening on [%s]", PORT);
103
106
  }
104
107
  main().catch(e=>console.error(e));
105
108
  `
@@ -114,16 +117,16 @@ export async function inflateServiceForSea(logger: Logger, inflateDir: string, s
114
117
  export async function setupRouter() {
115
118
  const router = new Router();
116
119
  ${getErrorConfigPath(servicePath) ? `
117
- const errorConfig = (await import("../../${service}/catch.js")).default;
120
+ const errorConfig = (await import("../../${service}/catch.cjs")).default.default;
118
121
  if(errorConfig && errorConfig.catch) {
119
122
  for(const m of errorConfig.catch) {
120
123
  router.catch(m);
121
124
  }
122
125
  }` : ""}
123
- ${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.js")).default));` : ""}
124
- ${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.js")).default));` : ""}
126
+ ${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.cjs")).default.default));` : ""}
127
+ ${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.cjs")).default.default));` : ""}
125
128
  ${getMiddlewareConfigPath(servicePath) ? `
126
- const middlewareConfig = (await import("../../${service}/middleware.js")).default;
129
+ const middlewareConfig = (await import("../../${service}/middleware.cjs")).default.default;
127
130
  if(middlewareConfig && middlewareConfig.middleware) {
128
131
  for(const m of middlewareConfig.middleware) {
129
132
  router.use(m);
@@ -136,8 +139,8 @@ ${Object.keys(serviceRouteFileMap)
136
139
  const rPath = join(relative(cwd(), dirname(data.filePath)), basename(data.filePath));
137
140
  if (rPath) {
138
141
  const rPathExt = extname(rPath);
139
- const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".js");
140
- return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default);`;
142
+ const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
143
+ return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default.default);`;
141
144
  } else {
142
145
  return "";
143
146
  }
@@ -160,7 +163,7 @@ export async function runMigrations(db) {
160
163
  await migration.init(db);
161
164
  ${serviceMigrations.map(file => {
162
165
  const name = `${file.substring(0, file.length - extname(file).length)}`;
163
- return ` await migration.up.module(db, "${name}", (await import("../../${service}/migration/${name}.js")).default)`;
166
+ return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
164
167
  }).join("\n")}
165
168
  }`);
166
169
 
@@ -169,7 +172,7 @@ export async function runMigrations(db) {
169
172
  await migration.init(db);
170
173
  ${serviceMigrations.reverse().map(file => {
171
174
  const name = `${file.substring(0, file.length - extname(file).length)}`;
172
- return ` await migration.down.module(db, "${name}", (await import("../../${service}/migration/${name}.js")).default)`;
175
+ return ` await migration.down.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
173
176
  }).join("\n")}
174
177
  }`);
175
178
 
@@ -20,10 +20,11 @@ export interface InflateAppOptions {
20
20
  //editor: boolean;
21
21
  //inflateTests: boolean;
22
22
  hotreload?: boolean;
23
+ port: string;
23
24
  serverInterface: ServerInterface;
24
25
  }
25
26
 
26
- export async function inflateApp({ serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/ }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
27
+ export async function inflateApp({ serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/, port }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
27
28
  logger.trace("inflateApp");
28
29
  const errors: InflateError[] = [];
29
30
  //const migrations: string[] = [];
@@ -90,7 +91,7 @@ export async function inflateApp({ serverInterface, logger, hotreload, services/
90
91
  }
91
92
 
92
93
  if (inflateDir && inflateSea) {
93
- await inflateAppForSea(logger, inflateDir, services);
94
+ await inflateAppForSea(logger, inflateDir, services, port);
94
95
  }
95
96
 
96
97
  router.use(assertGlobalTampered);
@@ -15,7 +15,7 @@ export async function setupAUTH(logger: Logger, servicePath: string, service: st
15
15
  mainRouter.use(SessionHandler(authModule));
16
16
 
17
17
  if (inflateDir && inflateSea) {
18
- const inflatePath = resolve(inflateDir, service, "auth.js");
18
+ const inflatePath = resolve(inflateDir, service, "auth.cjs");
19
19
  mkdirSync(dirname(inflatePath), {
20
20
  recursive: true
21
21
  });
@@ -24,6 +24,7 @@ export async function setupAUTH(logger: Logger, servicePath: string, service: st
24
24
  embemedJSX: false,
25
25
  minify: false,
26
26
  useExport: true,
27
+ platform: "node",
27
28
  logger
28
29
  }));
29
30
  }
@@ -15,7 +15,7 @@ export async function setupCORS(logger: Logger, servicePath: string, service: st
15
15
  mainRouter.use(CORS(corsOptions));
16
16
 
17
17
  if (inflateDir && inflateSea) {
18
- const inflatePath = resolve(inflateDir, service, "cors.js");
18
+ const inflatePath = resolve(inflateDir, service, "cors.cjs");
19
19
  mkdirSync(dirname(inflatePath), {
20
20
  recursive: true
21
21
  });
@@ -24,6 +24,7 @@ export async function setupCORS(logger: Logger, servicePath: string, service: st
24
24
  embemedJSX: false,
25
25
  minify: false,
26
26
  useExport: true,
27
+ platform: "node",
27
28
  logger
28
29
  }));
29
30
  }
@@ -30,7 +30,7 @@ export async function inflateDBConfig(logger: Logger, service: string, dbConfigL
30
30
 
31
31
  if (config) {
32
32
  if (inflateDir) {
33
- const inflatePath = resolve(inflateDir, service, "db.js");
33
+ const inflatePath = resolve(inflateDir, service, "db.cjs");
34
34
  mkdirSync(dirname(inflatePath), {
35
35
  recursive: true
36
36
  });
@@ -39,6 +39,7 @@ export async function inflateDBConfig(logger: Logger, service: string, dbConfigL
39
39
  embemedJSX: false,
40
40
  minify: false,
41
41
  useExport: true,
42
+ platform: "node",
42
43
  logger
43
44
  }));
44
45
  }
@@ -84,7 +85,7 @@ export async function inflateDBMigrations(logger: Logger, service: string, dbNam
84
85
  });
85
86
 
86
87
  if (inflateDir) {
87
- const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".js");
88
+ const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".cjs");
88
89
  mkdirSync(dirname(inflatePath), {
89
90
  recursive: true
90
91
  });
@@ -93,6 +94,7 @@ export async function inflateDBMigrations(logger: Logger, service: string, dbNam
93
94
  embemedJSX: false,
94
95
  minify: false,
95
96
  useExport: true,
97
+ platform: "node",
96
98
  logger
97
99
  }));
98
100
  }