miqro 7.0.10 → 7.2.0

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 (216) hide show
  1. package/README.md +92 -24
  2. package/build/esm/editor/auth.js +1 -0
  3. package/build/esm/editor/auth.js.map +1 -0
  4. package/build/esm/editor/common/admin-interface.js +1 -0
  5. package/build/esm/editor/common/admin-interface.js.map +1 -0
  6. package/build/esm/editor/common/constants.js +1 -0
  7. package/build/esm/editor/common/constants.js.map +1 -0
  8. package/build/esm/editor/common/constants.server.js +1 -0
  9. package/build/esm/editor/common/constants.server.js.map +1 -0
  10. package/build/esm/editor/common/editor-index.js +1 -0
  11. package/build/esm/editor/common/editor-index.js.map +1 -0
  12. package/build/esm/editor/common/html-encode.js +1 -0
  13. package/build/esm/editor/common/html-encode.js.map +1 -0
  14. package/build/esm/editor/common/log-socket.js +1 -0
  15. package/build/esm/editor/common/log-socket.js.map +1 -0
  16. package/build/esm/editor/common/templates.js +1 -0
  17. package/build/esm/editor/common/templates.js.map +1 -0
  18. package/build/esm/editor/components/api-preview.js +1 -0
  19. package/build/esm/editor/components/api-preview.js.map +1 -0
  20. package/build/esm/editor/components/editor.js +1 -0
  21. package/build/esm/editor/components/editor.js.map +1 -0
  22. package/build/esm/editor/components/file-browser.js +1 -0
  23. package/build/esm/editor/components/file-browser.js.map +1 -0
  24. package/build/esm/editor/components/file-editor-toolbar.js +1 -0
  25. package/build/esm/editor/components/file-editor-toolbar.js.map +1 -0
  26. package/build/esm/editor/components/file-editor.js +1 -0
  27. package/build/esm/editor/components/file-editor.js.map +1 -0
  28. package/build/esm/editor/components/filter-query.js +1 -0
  29. package/build/esm/editor/components/filter-query.js.map +1 -0
  30. package/build/esm/editor/components/highlight-text-area.js +1 -0
  31. package/build/esm/editor/components/highlight-text-area.js.map +1 -0
  32. package/build/esm/editor/components/log-viewer.js +1 -0
  33. package/build/esm/editor/components/log-viewer.js.map +1 -0
  34. package/build/esm/editor/components/new-file.js +1 -0
  35. package/build/esm/editor/components/new-file.js.map +1 -0
  36. package/build/esm/editor/components/scroll-query.js +1 -0
  37. package/build/esm/editor/components/scroll-query.js.map +1 -0
  38. package/build/esm/editor/components/start-page.js +1 -0
  39. package/build/esm/editor/components/start-page.js.map +1 -0
  40. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +1 -0
  41. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +1 -0
  42. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +1 -0
  43. package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +1 -0
  44. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +1 -0
  45. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +1 -0
  46. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +1 -0
  47. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js.map +1 -0
  48. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +1 -0
  49. package/build/esm/editor/http/admin/editor/api/fs/write.api.js.map +1 -0
  50. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +1 -0
  51. package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +1 -0
  52. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +1 -0
  53. package/build/esm/editor/http/admin/editor/api/server/restart.api.js.map +1 -0
  54. package/build/esm/editor/http/admin/editor/editor.js +1 -0
  55. package/build/esm/editor/http/admin/editor/editor.js.map +1 -0
  56. package/build/esm/editor/http/admin/editor/index.api.js +1 -0
  57. package/build/esm/editor/http/admin/editor/index.api.js.map +1 -0
  58. package/build/esm/editor/server.js +1 -0
  59. package/build/esm/editor/server.js.map +1 -0
  60. package/build/esm/editor/ws.js +1 -0
  61. package/build/esm/editor/ws.js.map +1 -0
  62. package/build/esm/src/bin/compile.js +1 -0
  63. package/build/esm/src/bin/compile.js.map +1 -0
  64. package/build/esm/src/bin/doc-md.js +1 -0
  65. package/build/esm/src/bin/doc-md.js.map +1 -0
  66. package/build/esm/src/bin/generate-doc.js +1 -0
  67. package/build/esm/src/bin/generate-doc.js.map +1 -0
  68. package/build/esm/src/bin/test.d.ts +2 -1
  69. package/build/esm/src/bin/test.js +3 -2
  70. package/build/esm/src/bin/test.js.map +1 -0
  71. package/build/esm/src/bin/types.js +1 -0
  72. package/build/esm/src/bin/types.js.map +1 -0
  73. package/build/esm/src/cluster.js +1 -0
  74. package/build/esm/src/cluster.js.map +1 -0
  75. package/build/esm/src/common/arguments.d.ts +8 -0
  76. package/build/esm/src/common/arguments.js +78 -1
  77. package/build/esm/src/common/arguments.js.map +1 -0
  78. package/build/esm/src/common/assets.d.ts +1 -1
  79. package/build/esm/src/common/assets.js +2 -1
  80. package/build/esm/src/common/assets.js.map +1 -0
  81. package/build/esm/src/common/checksum.js +1 -0
  82. package/build/esm/src/common/checksum.js.map +1 -0
  83. package/build/esm/src/common/constants.d.ts +1 -0
  84. package/build/esm/src/common/constants.js +2 -0
  85. package/build/esm/src/common/constants.js.map +1 -0
  86. package/build/esm/src/common/content-type.js +1 -0
  87. package/build/esm/src/common/content-type.js.map +1 -0
  88. package/build/esm/src/common/esbuild.js +1 -0
  89. package/build/esm/src/common/esbuild.js.map +1 -0
  90. package/build/esm/src/common/exit.js +1 -0
  91. package/build/esm/src/common/exit.js.map +1 -0
  92. package/build/esm/src/common/fs.js +1 -0
  93. package/build/esm/src/common/fs.js.map +1 -0
  94. package/build/esm/src/common/help.d.ts +1 -1
  95. package/build/esm/src/common/help.js +7 -1
  96. package/build/esm/src/common/help.js.map +1 -0
  97. package/build/esm/src/common/jsx.d.ts +20 -16
  98. package/build/esm/src/common/jsx.js +34 -29
  99. package/build/esm/src/common/jsx.js.map +1 -0
  100. package/build/esm/src/common/jwt.js +1 -0
  101. package/build/esm/src/common/jwt.js.map +1 -0
  102. package/build/esm/src/common/paths.js +1 -0
  103. package/build/esm/src/common/paths.js.map +1 -0
  104. package/build/esm/src/common/watch.js +1 -0
  105. package/build/esm/src/common/watch.js.map +1 -0
  106. package/build/esm/src/inflate/inflate-sea.js +16 -15
  107. package/build/esm/src/inflate/inflate-sea.js.map +1 -0
  108. package/build/esm/src/inflate/inflate.d.ts +5 -1
  109. package/build/esm/src/inflate/inflate.js +6 -5
  110. package/build/esm/src/inflate/inflate.js.map +1 -0
  111. package/build/esm/src/inflate/md.js +1 -0
  112. package/build/esm/src/inflate/md.js.map +1 -0
  113. package/build/esm/src/inflate/setup-auth.d.ts +2 -2
  114. package/build/esm/src/inflate/setup-auth.js +3 -2
  115. package/build/esm/src/inflate/setup-auth.js.map +1 -0
  116. package/build/esm/src/inflate/setup-cors.d.ts +2 -2
  117. package/build/esm/src/inflate/setup-cors.js +3 -2
  118. package/build/esm/src/inflate/setup-cors.js.map +1 -0
  119. package/build/esm/src/inflate/setup-db.d.ts +3 -3
  120. package/build/esm/src/inflate/setup-db.js +6 -5
  121. package/build/esm/src/inflate/setup-db.js.map +1 -0
  122. package/build/esm/src/inflate/setup-error.d.ts +2 -2
  123. package/build/esm/src/inflate/setup-error.js +3 -2
  124. package/build/esm/src/inflate/setup-error.js.map +1 -0
  125. package/build/esm/src/inflate/setup-http.d.ts +7 -2
  126. package/build/esm/src/inflate/setup-http.js +54 -45
  127. package/build/esm/src/inflate/setup-http.js.map +1 -0
  128. package/build/esm/src/inflate/setup-log.d.ts +2 -2
  129. package/build/esm/src/inflate/setup-log.js +3 -2
  130. package/build/esm/src/inflate/setup-log.js.map +1 -0
  131. package/build/esm/src/inflate/setup-middleware.d.ts +2 -2
  132. package/build/esm/src/inflate/setup-middleware.js +3 -2
  133. package/build/esm/src/inflate/setup-middleware.js.map +1 -0
  134. package/build/esm/src/inflate/setup-server-config.d.ts +2 -2
  135. package/build/esm/src/inflate/setup-server-config.js +3 -2
  136. package/build/esm/src/inflate/setup-server-config.js.map +1 -0
  137. package/build/esm/src/inflate/setup-test.d.ts +2 -1
  138. package/build/esm/src/inflate/setup-test.js +3 -2
  139. package/build/esm/src/inflate/setup-test.js.map +1 -0
  140. package/build/esm/src/inflate/setup-ws.d.ts +2 -2
  141. package/build/esm/src/inflate/setup-ws.js +3 -2
  142. package/build/esm/src/inflate/setup-ws.js.map +1 -0
  143. package/build/esm/src/inflate/setup.doc.d.ts +2 -2
  144. package/build/esm/src/inflate/setup.doc.js +5 -4
  145. package/build/esm/src/inflate/setup.doc.js.map +1 -0
  146. package/build/esm/src/inflate/utils/sea-utils.js +1 -0
  147. package/build/esm/src/inflate/utils/sea-utils.js.map +1 -0
  148. package/build/esm/src/lib.js +1 -0
  149. package/build/esm/src/lib.js.map +1 -0
  150. package/build/esm/src/main.js +9 -2
  151. package/build/esm/src/main.js.map +1 -0
  152. package/build/esm/src/services/app.d.ts +5 -2
  153. package/build/esm/src/services/app.js +19 -6
  154. package/build/esm/src/services/app.js.map +1 -0
  155. package/build/esm/src/services/editor.js +1 -0
  156. package/build/esm/src/services/editor.js.map +1 -0
  157. package/build/esm/src/services/hot-reload.d.ts +1 -0
  158. package/build/esm/src/services/hot-reload.js +9 -5
  159. package/build/esm/src/services/hot-reload.js.map +1 -0
  160. package/build/esm/src/services/migrations.d.ts +3 -2
  161. package/build/esm/src/services/migrations.js +5 -4
  162. package/build/esm/src/services/migrations.js.map +1 -0
  163. package/build/esm/src/services/utils/admin-interface.js +1 -0
  164. package/build/esm/src/services/utils/admin-interface.js.map +1 -0
  165. package/build/esm/src/services/utils/cache.js +1 -0
  166. package/build/esm/src/services/utils/cache.js.map +1 -0
  167. package/build/esm/src/services/utils/cluster-cache.js +1 -0
  168. package/build/esm/src/services/utils/cluster-cache.js.map +1 -0
  169. package/build/esm/src/services/utils/cluster-ws.js +1 -0
  170. package/build/esm/src/services/utils/cluster-ws.js.map +1 -0
  171. package/build/esm/src/services/utils/db-manager.js +1 -0
  172. package/build/esm/src/services/utils/db-manager.js.map +1 -0
  173. package/build/esm/src/services/utils/get-route.js +1 -0
  174. package/build/esm/src/services/utils/get-route.js.map +1 -0
  175. package/build/esm/src/services/utils/jwt.js +1 -0
  176. package/build/esm/src/services/utils/jwt.js.map +1 -0
  177. package/build/esm/src/services/utils/log-transport.js +1 -0
  178. package/build/esm/src/services/utils/log-transport.js.map +1 -0
  179. package/build/esm/src/services/utils/log.js +1 -0
  180. package/build/esm/src/services/utils/log.js.map +1 -0
  181. package/build/esm/src/services/utils/middleware.js +1 -0
  182. package/build/esm/src/services/utils/middleware.js.map +1 -0
  183. package/build/esm/src/services/utils/server-interface.js +1 -0
  184. package/build/esm/src/services/utils/server-interface.js.map +1 -0
  185. package/build/esm/src/services/utils/websocketmanager.js +1 -0
  186. package/build/esm/src/services/utils/websocketmanager.js.map +1 -0
  187. package/build/esm/src/types.js +1 -0
  188. package/build/esm/src/types.js.map +1 -0
  189. package/build/lib.cjs +239 -150
  190. package/package.json +5 -5
  191. package/sea/install-esbuild.sh +1 -1
  192. package/sea/install-nodejs.sh +1 -1
  193. package/sea/node.version.tag +1 -1
  194. package/src/bin/test.ts +3 -2
  195. package/src/common/arguments.ts +92 -1
  196. package/src/common/assets.ts +2 -2
  197. package/src/common/constants.ts +1 -0
  198. package/src/common/help.ts +6 -1
  199. package/src/common/jsx.ts +41 -30
  200. package/src/inflate/inflate-sea.ts +15 -15
  201. package/src/inflate/inflate.ts +9 -5
  202. package/src/inflate/setup-auth.ts +3 -3
  203. package/src/inflate/setup-cors.ts +4 -3
  204. package/src/inflate/setup-db.ts +6 -6
  205. package/src/inflate/setup-error.ts +3 -3
  206. package/src/inflate/setup-http.ts +61 -45
  207. package/src/inflate/setup-log.ts +3 -3
  208. package/src/inflate/setup-middleware.ts +3 -3
  209. package/src/inflate/setup-server-config.ts +3 -3
  210. package/src/inflate/setup-test.ts +3 -3
  211. package/src/inflate/setup-ws.ts +3 -3
  212. package/src/inflate/setup.doc.ts +5 -5
  213. package/src/main.ts +8 -2
  214. package/src/services/app.ts +24 -9
  215. package/src/services/hot-reload.ts +9 -5
  216. package/src/services/migrations.ts +5 -5
package/build/lib.cjs CHANGED
@@ -9171,7 +9171,7 @@ var ASSETS_ROUTER = {
9171
9171
  };
9172
9172
  function getAsset(key) {
9173
9173
  if ((0, import_node_sea.isSea)()) {
9174
- return (0, import_node_sea.getAsset)(key);
9174
+ return Buffer.from((0, import_node_sea.getAsset)(key));
9175
9175
  } else {
9176
9176
  if (!ASSETS_ROUTER[key]) {
9177
9177
  if (key === "esbuild-binary") {
@@ -9403,6 +9403,7 @@ var EXIT_CODES = {
9403
9403
  var CLEAR_JSX_CACHE = (process.env["CLEAR_JSX_CACHE"] !== void 0 ? process.env["CLEAR_JSX_CACHE"] : "1") === "1";
9404
9404
  var EDITOR_CONFIG_KEY = "$$editor$$";
9405
9405
  var HOT_RELOAD_PATH = "/hot-reload";
9406
+ var HOT_RELOAD_SCRIPT_PATH = "/hot-reload.js";
9406
9407
 
9407
9408
  // src/common/jsx.ts
9408
9409
  init_types();
@@ -9611,9 +9612,9 @@ var DocConfigSchema = {
9611
9612
  }
9612
9613
  }
9613
9614
  };
9614
- async function importAPIRoute(inFile, logger) {
9615
+ async function importAPIRoute(inFile, options, logger) {
9615
9616
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9616
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9617
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9617
9618
  const module2 = typeof mod === "function" ? { handler: mod } : parser.parse(mod, APIRouteSchema, (0, import_node_path6.basename)(inFile));
9618
9619
  if (module2 !== void 0) {
9619
9620
  return module2;
@@ -9621,9 +9622,9 @@ async function importAPIRoute(inFile, logger) {
9621
9622
  throw new Error(`error with module [${inFile}] undefined`);
9622
9623
  }
9623
9624
  }
9624
- async function importMigrationModule(inFile, logger) {
9625
+ async function importMigrationModule(inFile, options, logger) {
9625
9626
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9626
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9627
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9627
9628
  const module2 = parser.parse(mod, MigrationSchema, (0, import_node_path6.basename)(inFile));
9628
9629
  if (module2 !== void 0) {
9629
9630
  return module2;
@@ -9631,8 +9632,8 @@ async function importMigrationModule(inFile, logger) {
9631
9632
  throw new Error(`error with module [${inFile}] undefined`);
9632
9633
  }
9633
9634
  }
9634
- async function importHTMLModule(inFile, logger) {
9635
- const module2 = await importJSXFile(inFile, logger);
9635
+ async function importHTMLModule(inFile, options, logger) {
9636
+ const module2 = await importJSXFile(inFile, options, logger);
9636
9637
  parser.parse(module2.default, HTMLModuleSchema.properties.default, `${(0, import_node_path6.basename)(inFile)}.default`);
9637
9638
  parser.parse(module2.apiOptions, APIOptionsSchema, `${(0, import_node_path6.basename)(inFile)}.apiOptions`);
9638
9639
  if (module2 !== void 0) {
@@ -9641,8 +9642,8 @@ async function importHTMLModule(inFile, logger) {
9641
9642
  throw new Error(`error with module [${inFile}] undefined`);
9642
9643
  }
9643
9644
  }
9644
- async function importJSONModule(inFile, logger) {
9645
- const module2 = await importJSXFile(inFile, logger);
9645
+ async function importJSONModule(inFile, options, logger) {
9646
+ const module2 = await importJSXFile(inFile, options, logger);
9646
9647
  parser.parse(module2.default, JSONModuleSchema.properties.default, `${(0, import_node_path6.basename)(inFile)}.default`);
9647
9648
  parser.parse(module2.apiOptions, APIOptionsSchema, `${(0, import_node_path6.basename)(inFile)}.apiOptions`);
9648
9649
  if (module2 !== void 0) {
@@ -9651,9 +9652,9 @@ async function importJSONModule(inFile, logger) {
9651
9652
  throw new Error(`error with module [${inFile}] undefined`);
9652
9653
  }
9653
9654
  }
9654
- async function importAuthModule(inFile, logger) {
9655
+ async function importAuthModule(inFile, options, logger) {
9655
9656
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9656
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9657
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9657
9658
  const module2 = parser.parse(mod, AuthConfigSchema, (0, import_node_path6.basename)(inFile));
9658
9659
  if (module2 !== void 0) {
9659
9660
  return module2;
@@ -9661,9 +9662,9 @@ async function importAuthModule(inFile, logger) {
9661
9662
  throw new Error(`error with module [${inFile}] undefined`);
9662
9663
  }
9663
9664
  }
9664
- async function importMiddlewareConfigModule(inFile, logger) {
9665
+ async function importMiddlewareConfigModule(inFile, options, logger) {
9665
9666
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9666
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9667
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9667
9668
  const module2 = parser.parse(mod, MiddlewareConfigSchema, (0, import_node_path6.basename)(inFile));
9668
9669
  if (module2 !== void 0) {
9669
9670
  return module2;
@@ -9671,9 +9672,9 @@ async function importMiddlewareConfigModule(inFile, logger) {
9671
9672
  throw new Error(`error with module [${inFile}] undefined`);
9672
9673
  }
9673
9674
  }
9674
- async function importErrorConfigModule(inFile, logger) {
9675
+ async function importErrorConfigModule(inFile, options, logger) {
9675
9676
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9676
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9677
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9677
9678
  const module2 = parser.parse(mod, ErrorConfigSchema, (0, import_node_path6.basename)(inFile));
9678
9679
  if (module2 !== void 0) {
9679
9680
  return module2;
@@ -9681,9 +9682,9 @@ async function importErrorConfigModule(inFile, logger) {
9681
9682
  throw new Error(`error with module [${inFile}] undefined`);
9682
9683
  }
9683
9684
  }
9684
- async function importDocConfigModule(inFile, logger) {
9685
+ async function importDocConfigModule(inFile, options, logger) {
9685
9686
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9686
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9687
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9687
9688
  const module2 = parser.parse(mod, DocConfigSchema, (0, import_node_path6.basename)(inFile));
9688
9689
  if (module2 !== void 0) {
9689
9690
  return module2;
@@ -9691,9 +9692,9 @@ async function importDocConfigModule(inFile, logger) {
9691
9692
  throw new Error(`error with module [${inFile}] undefined`);
9692
9693
  }
9693
9694
  }
9694
- async function importCORSModule(inFile, logger) {
9695
+ async function importCORSModule(inFile, options, logger) {
9695
9696
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9696
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9697
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9697
9698
  const module2 = parser.parse(mod, CORSOptionsSchema, (0, import_node_path6.basename)(inFile));
9698
9699
  if (module2 !== void 0) {
9699
9700
  return module2;
@@ -9701,9 +9702,9 @@ async function importCORSModule(inFile, logger) {
9701
9702
  throw new Error(`error with module [${inFile}] undefined`);
9702
9703
  }
9703
9704
  }
9704
- async function importWSConfigModule(inFile, logger) {
9705
+ async function importWSConfigModule(inFile, options, logger) {
9705
9706
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9706
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9707
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9707
9708
  const module2 = parser.parse(mod, WSConfigSchema, (0, import_node_path6.basename)(inFile));
9708
9709
  if (module2 !== void 0) {
9709
9710
  return module2;
@@ -9711,9 +9712,9 @@ async function importWSConfigModule(inFile, logger) {
9711
9712
  throw new Error(`error with module [${inFile}] undefined`);
9712
9713
  }
9713
9714
  }
9714
- async function importDBConfigModule(inFile, logger) {
9715
+ async function importDBConfigModule(inFile, options, logger) {
9715
9716
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9716
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9717
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9717
9718
  const module2 = parser.parse(mod, DBConfigSchema, (0, import_node_path6.basename)(inFile));
9718
9719
  if (module2 !== void 0) {
9719
9720
  return module2;
@@ -9721,17 +9722,17 @@ async function importDBConfigModule(inFile, logger) {
9721
9722
  throw new Error(`error with module [${inFile}] undefined`);
9722
9723
  }
9723
9724
  }
9724
- async function importLogConfigModule(inFile, logger) {
9725
- const module2 = parser.parse((await importJSXFile(inFile, logger)).default, LogConfigSchema, (0, import_node_path6.basename)(inFile));
9725
+ async function importLogConfigModule(inFile, options, logger) {
9726
+ const module2 = parser.parse((await importJSXFile(inFile, options, logger)).default, LogConfigSchema, (0, import_node_path6.basename)(inFile));
9726
9727
  if (module2 !== void 0) {
9727
9728
  return module2;
9728
9729
  } else {
9729
9730
  throw new Error(`error with module [${inFile}] undefined`);
9730
9731
  }
9731
9732
  }
9732
- async function importServerConfigModule(inFile, logger) {
9733
+ async function importServerConfigModule(inFile, options, logger) {
9733
9734
  const isCJS = (0, import_node_path6.extname)(inFile) === ".cjs";
9734
- const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
9735
+ const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
9735
9736
  const module2 = parser.parse(mod, ServerConfigSchema, (0, import_node_path6.basename)(inFile));
9736
9737
  if (module2 !== void 0) {
9737
9738
  return module2;
@@ -9739,7 +9740,11 @@ async function importServerConfigModule(inFile, logger) {
9739
9740
  throw new Error(`error with module [${inFile}] undefined`);
9740
9741
  }
9741
9742
  }
9742
- async function importJSXFile(inFile, logger) {
9743
+ async function importJSXFile(inFile, options, logger) {
9744
+ if (options.noBuild) {
9745
+ const module2 = await import((0, import_node_path6.resolve)(inFile));
9746
+ return module2;
9747
+ }
9743
9748
  const inflatedCode = await inflateJSX(inFile, {
9744
9749
  // embemedJSX: false,
9745
9750
  minify: false,
@@ -12156,8 +12161,7 @@ var CONTENT_TYPE_MAP = {
12156
12161
  };
12157
12162
 
12158
12163
  // src/services/hot-reload.ts
12159
- function getHotReloadScript() {
12160
- const HOT_RELOAD_JS_SCRIPT = `
12164
+ var HOT_RELOAD_JS_SCRIPT = `
12161
12165
  // Create WebSocket connection.
12162
12166
 
12163
12167
  function getSocket() {
@@ -12167,13 +12171,14 @@ function getSocket() {
12167
12171
  const socket = getSocket();
12168
12172
 
12169
12173
  let timeout;
12174
+ let reloadtimeout;
12170
12175
 
12171
12176
  function tryConnection() {
12172
12177
  try {
12173
12178
  const newSocket = getSocket();
12174
12179
  newSocket.addEventListener("open", (event) => {
12175
12180
  console.log("reloading");
12176
- setTimeout(()=>{
12181
+ reloadtimeout = setTimeout(()=>{
12177
12182
  window.location.reload();
12178
12183
  }, 500);
12179
12184
 
@@ -12191,13 +12196,16 @@ function tryConnection() {
12191
12196
  // Connection closed
12192
12197
  socket.addEventListener("close", (event) => {
12193
12198
  clearTimeout(timeout);
12199
+ clearTimeout(reloadtimeout);
12194
12200
  timeout = setTimeout(tryConnection, 500);
12195
12201
  });
12196
12202
 
12197
12203
  socket.addEventListener("error", (err) => {
12204
+ clearTimeout(reloadtimeout);
12198
12205
  console.error(err);
12199
12206
  });`;
12200
- return `<script>${HOT_RELOAD_JS_SCRIPT}</script>`;
12207
+ function getHotReloadScript() {
12208
+ return `<script src="${HOT_RELOAD_SCRIPT_PATH}"></script>`;
12201
12209
  }
12202
12210
 
12203
12211
  // src/inflate/setup-http.ts
@@ -12208,12 +12216,12 @@ var import_node_fs6 = require("node:fs");
12208
12216
  init_lib3();
12209
12217
  var import_node_path7 = require("node:path");
12210
12218
  var import_node_process4 = require("node:process");
12211
- async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
12219
+ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, options, errors) {
12212
12220
  const corsPath = getCORSConfigPath(servicePath);
12213
12221
  if (corsPath) {
12214
12222
  try {
12215
- const corsOptions = await importCORSModule(corsPath, logger);
12216
12223
  logger.debug("setting up cors from [%s]", (0, import_node_path7.join)(service, (0, import_node_path7.basename)(corsPath)));
12224
+ const corsOptions = await importCORSModule(corsPath, options, logger);
12217
12225
  mainRouter.use(CORS(corsOptions));
12218
12226
  if (inflateDir && inflateSea) {
12219
12227
  const inflatePath = (0, import_node_path7.resolve)(inflateDir, service, "cors.cjs");
@@ -12245,11 +12253,11 @@ init_lib3();
12245
12253
  var import_node_path8 = require("node:path");
12246
12254
  var import_node_fs7 = require("node:fs");
12247
12255
  var import_node_process5 = require("node:process");
12248
- async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
12256
+ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, options, errors) {
12249
12257
  const authPath = getAuthConfigPath(servicePath);
12250
12258
  if (authPath) {
12251
12259
  try {
12252
- const authModule = await importAuthModule(authPath, logger);
12260
+ const authModule = await importAuthModule(authPath, options, logger);
12253
12261
  logger.debug("setting up authentication from [%s]", (0, import_node_path8.join)(service, (0, import_node_path8.basename)(authPath)));
12254
12262
  mainRouter.use(SessionHandler(authModule));
12255
12263
  if (inflateDir && inflateSea) {
@@ -12360,11 +12368,11 @@ function inflateMDString2HTML(text, logger) {
12360
12368
  var import_node_path10 = require("node:path");
12361
12369
  var import_node_fs9 = require("node:fs");
12362
12370
  var import_node_process6 = require("node:process");
12363
- async function setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
12371
+ async function setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, options, errors) {
12364
12372
  const middlewarePath = getMiddlewareConfigPath(servicePath);
12365
12373
  if (middlewarePath) {
12366
12374
  try {
12367
- const middewareModule = await importMiddlewareConfigModule(middlewarePath, logger);
12375
+ const middewareModule = await importMiddlewareConfigModule(middlewarePath, options, logger);
12368
12376
  logger.debug("setting up middleware from [%s]", (0, import_node_path10.join)(service, (0, import_node_path10.basename)(middlewarePath)));
12369
12377
  if (middewareModule && middewareModule.middleware) {
12370
12378
  for (const m of middewareModule.middleware) {
@@ -12402,11 +12410,11 @@ async function setupMiddleware(logger, servicePath, service, mainRouter, inflate
12402
12410
  var import_node_path11 = require("node:path");
12403
12411
  var import_node_fs10 = require("node:fs");
12404
12412
  var import_node_process7 = require("node:process");
12405
- async function setupError(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors) {
12413
+ async function setupError(logger, servicePath, service, mainRouter, inflateDir, inflateSea, options, errors) {
12406
12414
  const errorPath = getErrorConfigPath(servicePath);
12407
12415
  if (errorPath) {
12408
12416
  try {
12409
- const errorModule = await importErrorConfigModule(errorPath, logger);
12417
+ const errorModule = await importErrorConfigModule(errorPath, options, logger);
12410
12418
  logger.debug("setting up error handling from [%s]", (0, import_node_path11.join)(service, (0, import_node_path11.basename)(errorPath)));
12411
12419
  if (errorModule && errorModule.catch) {
12412
12420
  for (const m of errorModule.catch) {
@@ -12439,23 +12447,23 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
12439
12447
  }
12440
12448
 
12441
12449
  // src/inflate/setup-http.ts
12442
- async function setupHTTPRouter(server, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors, inflateParallel) {
12450
+ async function setupHTTPRouter(importOptions, inflateOptions, server, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors, inflateParallel) {
12443
12451
  const mainRouter = new Router2();
12444
12452
  const apiRouterPath = getHTTPRouterPath(servicePath);
12445
12453
  let middlewareConfig = null;
12446
- await setupError(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
12447
- await setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
12448
- await setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
12449
- middlewareConfig = await setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, errors);
12454
+ await setupError(logger, servicePath, service, mainRouter, inflateDir, inflateSea, importOptions, errors);
12455
+ await setupCORS(logger, servicePath, service, mainRouter, inflateDir, inflateSea, importOptions, errors);
12456
+ await setupAUTH(logger, servicePath, service, mainRouter, inflateDir, inflateSea, importOptions, errors);
12457
+ middlewareConfig = await setupMiddleware(logger, servicePath, service, mainRouter, inflateDir, inflateSea, importOptions, errors);
12450
12458
  if (apiRouterPath) {
12451
12459
  logger.trace("setting up http routes from [%s]", service);
12452
- const { router: httpRouter } = await createRouterFromDirectory(server, hotreload, service, logger, apiRouterPath, errors, routeFileMap, staticFileMap, inflateDir, inflateSea, inflateParallel);
12460
+ const { router: httpRouter } = await createRouterFromDirectory(importOptions, inflateOptions, server, hotreload, service, logger, apiRouterPath, errors, routeFileMap, staticFileMap, inflateDir, inflateSea, inflateParallel);
12453
12461
  mainRouter.use(httpRouter);
12454
12462
  }
12455
12463
  const staticFilesPath = getStaticFilesPath(servicePath);
12456
12464
  if (staticFilesPath) {
12457
12465
  logger.trace("setting up static file routes from [%s]", service);
12458
- const staticRouter = await createStaticRouterFromDirectory(service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap, inflateParallel);
12466
+ const staticRouter = await createStaticRouterFromDirectory(inflateOptions, service, logger, staticFilesPath, inflateDir, routeFileMap, staticFileMap, inflateParallel);
12459
12467
  mainRouter.use(staticRouter);
12460
12468
  }
12461
12469
  if (middlewareConfig && middlewareConfig.post) {
@@ -12465,7 +12473,7 @@ async function setupHTTPRouter(server, logger, hotreload, servicePath, service,
12465
12473
  }
12466
12474
  return mainRouter;
12467
12475
  }
12468
- async function createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap) {
12476
+ async function createStaticRoute(inflateJSXOptions, service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap) {
12469
12477
  return new Promise(async (resolve24, reject) => {
12470
12478
  try {
12471
12479
  logger.trace("creating static route for [%s]", file.filePath);
@@ -12484,8 +12492,8 @@ async function createStaticRoute(service, logger, router, dir, file, inflateDir,
12484
12492
  filePath: file.filePath,
12485
12493
  previewMethod: "html"
12486
12494
  };
12487
- if (inflateDir) {
12488
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
12495
+ if (inflateDir && (inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12496
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path);
12489
12497
  (0, import_node_fs11.mkdir)((0, import_node_path12.dirname)(inflatePath), {
12490
12498
  recursive: true
12491
12499
  }, (err) => {
@@ -12504,7 +12512,7 @@ async function createStaticRoute(service, logger, router, dir, file, inflateDir,
12504
12512
  method: "GET",
12505
12513
  path: normalizePath2(path),
12506
12514
  body: Buffer.from(body),
12507
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
12515
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path) : void 0
12508
12516
  };
12509
12517
  }
12510
12518
  }
@@ -12540,14 +12548,14 @@ async function createStaticRoute(service, logger, router, dir, file, inflateDir,
12540
12548
  }
12541
12549
  });
12542
12550
  }
12543
- async function createStaticRouterFromDirectory(service, logger, dir, inflateDir, routeFileMap, staticFileMap, inflateParallel) {
12551
+ async function createStaticRouterFromDirectory(inflateOptions, service, logger, dir, inflateDir, routeFileMap, staticFileMap, inflateParallel) {
12544
12552
  const router = new Router2();
12545
12553
  const maxParallel = inflateParallel ? inflateParallel : 1;
12546
12554
  logger.debug("loading static directory with parallel [%s]", maxParallel);
12547
12555
  let tR = [];
12548
12556
  const files = scanFiles(dir);
12549
12557
  for (const file of files) {
12550
- tR.push(await createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap));
12558
+ tR.push(await createStaticRoute(inflateOptions, service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap));
12551
12559
  if (tR.length >= maxParallel) {
12552
12560
  await Promise.all(tR);
12553
12561
  tR = [];
@@ -12559,7 +12567,7 @@ async function createStaticRouterFromDirectory(service, logger, dir, inflateDir,
12559
12567
  }
12560
12568
  return router;
12561
12569
  }
12562
- async function createRouterFromDirectory(server, hotreload, service, logger, dir, errors = [], routeFileMap = {}, staticFileMap = null, inflateDir, inflateSea, inflateParallel) {
12570
+ async function createRouterFromDirectory(importOptions, inflateJSXOptions, server, hotreload, service, logger, dir, errors = [], routeFileMap = {}, staticFileMap = null, inflateDir, inflateSea, inflateParallel) {
12563
12571
  const router = new Router2();
12564
12572
  const maxParallel = inflateParallel ? inflateParallel : 1;
12565
12573
  server.logger.debug("loading http directory with parallel [%s]", maxParallel);
@@ -12581,7 +12589,11 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12581
12589
  logger.warn("ignoring [%s]", file.filePath);
12582
12590
  return resolve24();
12583
12591
  case ".api": {
12584
- const module2 = await importAPIRoute(file.filePath, logger);
12592
+ if (inflateJSXOptions.inflateOnlyAssets) {
12593
+ logger.warn("ignoring [%s]", file.filePath);
12594
+ return resolve24();
12595
+ }
12596
+ const module2 = await importAPIRoute(file.filePath, importOptions, logger);
12585
12597
  const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName, module2);
12586
12598
  routeFileMap[file.filePath] = {
12587
12599
  routes,
@@ -12589,7 +12601,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12589
12601
  filePath: file.filePath,
12590
12602
  previewMethod: "api"
12591
12603
  };
12592
- const inflatedCode = inflateDir ? await inflateJSX(file.filePath, {
12604
+ const inflatedCode = inflateDir && inflateSea && (!inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0) ? await inflateJSX(file.filePath, {
12593
12605
  // embemedJSX: false,
12594
12606
  minify: false,
12595
12607
  useExport: true,
@@ -12599,7 +12611,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12599
12611
  for (const r of routes) {
12600
12612
  if (inflateDir && r.defaultInflatePath && inflateSea) {
12601
12613
  const rPath = r.defaultInflatePath;
12602
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.cjs");
12614
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "http", rPath + ".api.cjs");
12603
12615
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12604
12616
  recursive: true
12605
12617
  });
@@ -12611,7 +12623,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12611
12623
  return resolve24();
12612
12624
  }
12613
12625
  case ".json": {
12614
- const module2 = await importJSONModule(file.filePath, logger);
12626
+ const module2 = await importJSONModule(file.filePath, importOptions, logger);
12615
12627
  const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".json", module2.apiOptions);
12616
12628
  routeFileMap[file.filePath] = {
12617
12629
  routes,
@@ -12621,10 +12633,10 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12621
12633
  };
12622
12634
  for (const r of routes) {
12623
12635
  const contentType = CONTENT_TYPE_MAP[".json"] ? CONTENT_TYPE_MAP[".json"] : DEFAULT_CONTENT_TYPE;
12624
- if (inflateDir) {
12636
+ if (inflateDir && (inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12625
12637
  if (r.inflatePath) {
12626
12638
  const rPath = r.inflatePath;
12627
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
12639
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", rPath);
12628
12640
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12629
12641
  recursive: true
12630
12642
  });
@@ -12643,7 +12655,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12643
12655
  previewMethod: "html",
12644
12656
  path: r.path,
12645
12657
  body: Buffer.from(JSON_STATIC),
12646
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
12658
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", r.inflatePath) : void 0
12647
12659
  };
12648
12660
  }
12649
12661
  }
@@ -12662,7 +12674,11 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12662
12674
  return resolve24();
12663
12675
  }
12664
12676
  case ".html": {
12665
- const module2 = await importHTMLModule(file.filePath, logger);
12677
+ if (inflateJSXOptions.inflateOnlyAssets) {
12678
+ logger.warn("ignoring [%s]", file.filePath);
12679
+ return resolve24();
12680
+ }
12681
+ const module2 = await importHTMLModule(file.filePath, importOptions, logger);
12666
12682
  const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".html", module2.apiOptions);
12667
12683
  routeFileMap[file.filePath] = {
12668
12684
  routes,
@@ -12672,10 +12688,10 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12672
12688
  };
12673
12689
  for (const r of routes) {
12674
12690
  const contentType = CONTENT_TYPE_MAP[".html"] ? CONTENT_TYPE_MAP[".html"] : DEFAULT_CONTENT_TYPE;
12675
- if (inflateDir) {
12691
+ if (inflateDir && (!inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12676
12692
  if (r.inflatePath) {
12677
12693
  const rPath = r.inflatePath;
12678
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
12694
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", rPath);
12679
12695
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12680
12696
  recursive: true
12681
12697
  });
@@ -12687,7 +12703,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12687
12703
  const HTML_STATIC = await getHTML(hotreload, { server }, null, newURL2(r.path), module2.apiOptions?.basePath, await toRender);
12688
12704
  logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
12689
12705
  await writeFileASync(inflatePath, HTML_STATIC);
12690
- if (staticFileMap && inflateSea) {
12706
+ if (staticFileMap && inflateSea && (!inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12691
12707
  staticFileMap[file.filePath + r.method + r.path] = {
12692
12708
  filePath: file.filePath,
12693
12709
  contentType,
@@ -12695,7 +12711,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12695
12711
  previewMethod: "html",
12696
12712
  path: r.path,
12697
12713
  body: Buffer.from(HTML_STATIC),
12698
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
12714
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", r.inflatePath) : void 0
12699
12715
  };
12700
12716
  }
12701
12717
  }
@@ -12718,7 +12734,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12718
12734
  case ".js":
12719
12735
  default: {
12720
12736
  if (file.ext !== ".js" && file.ext !== ".ts") {
12721
- const code = await inflateJSX(file.filePath, {
12737
+ const code = inflateJSXOptions.noMinify ? (0, import_node_fs11.readFileSync)(file.filePath).toString() : await inflateJSX(file.filePath, {
12722
12738
  // embemedJSX: true,
12723
12739
  minify: file.subExt === ".min" ? true : false,
12724
12740
  useExport: true,
@@ -12735,8 +12751,8 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12735
12751
  service,
12736
12752
  previewMethod: "html"
12737
12753
  };
12738
- if (inflateDir) {
12739
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
12754
+ if (inflateDir && (inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12755
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path);
12740
12756
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12741
12757
  recursive: true
12742
12758
  });
@@ -12750,7 +12766,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12750
12766
  previewMethod: "html",
12751
12767
  path,
12752
12768
  body: Buffer.from(code),
12753
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
12769
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path) : void 0
12754
12770
  };
12755
12771
  }
12756
12772
  }
@@ -12783,8 +12799,8 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12783
12799
  filePath: file.filePath,
12784
12800
  previewMethod: "html"
12785
12801
  };
12786
- if (inflateDir) {
12787
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
12802
+ if (inflateDir && (inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12803
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path);
12788
12804
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12789
12805
  recursive: true
12790
12806
  });
@@ -12798,7 +12814,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12798
12814
  previewMethod: "html",
12799
12815
  path,
12800
12816
  body: Buffer.from(code),
12801
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
12817
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path) : void 0
12802
12818
  };
12803
12819
  }
12804
12820
  }
@@ -12824,7 +12840,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12824
12840
  }
12825
12841
  case ".bundle":
12826
12842
  case ".min": {
12827
- const code = await inflateJSX(file.filePath, {
12843
+ const code = inflateJSXOptions.noMinify ? (0, import_node_fs11.readFileSync)(file.filePath).toString() : await inflateJSX(file.filePath, {
12828
12844
  // embemedJSX: false,
12829
12845
  minify: file.subExt === ".min" ? true : false,
12830
12846
  useExport: true,
@@ -12841,8 +12857,8 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12841
12857
  service,
12842
12858
  previewMethod: "html"
12843
12859
  };
12844
- if (inflateDir) {
12845
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
12860
+ if (inflateDir && (inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12861
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path);
12846
12862
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12847
12863
  recursive: true
12848
12864
  });
@@ -12856,7 +12872,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12856
12872
  previewMethod: "html",
12857
12873
  path,
12858
12874
  body: Buffer.from(code),
12859
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
12875
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path) : void 0
12860
12876
  };
12861
12877
  }
12862
12878
  }
@@ -12891,8 +12907,8 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12891
12907
  filePath: file.filePath,
12892
12908
  previewMethod: "html"
12893
12909
  };
12894
- if (inflateDir) {
12895
- const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
12910
+ if (inflateDir && (inflateJSXOptions.inflateOnlyAssets || inflateJSXOptions.inflateOnlyAssets === void 0)) {
12911
+ const inflatePath = (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path);
12896
12912
  await mkdirASync((0, import_node_path12.dirname)(inflatePath), {
12897
12913
  recursive: true
12898
12914
  });
@@ -12906,7 +12922,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12906
12922
  previewMethod: "html",
12907
12923
  path,
12908
12924
  body: Buffer.from(code),
12909
- inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
12925
+ inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, !inflateJSXOptions.inflateFlat ? service : "", "static", path) : void 0
12910
12926
  };
12911
12927
  }
12912
12928
  }
@@ -12923,7 +12939,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
12923
12939
  }
12924
12940
  }
12925
12941
  }
12926
- await createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
12942
+ await createStaticRoute(inflateJSXOptions, service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
12927
12943
  return resolve24();
12928
12944
  }
12929
12945
  } catch (e) {
@@ -12971,13 +12987,11 @@ function scanFiles(path, ret = []) {
12971
12987
  }
12972
12988
  function getHTML(hotreload, req, res, url, basePath, out) {
12973
12989
  let HTML = `<!DOCTYPE html>
12974
- ${jsx2HTML(out, createNodeRuntime({
12990
+ ${hotreload ? `${getHotReloadScript()}
12991
+ ` : ""}${jsx2HTML(out, createNodeRuntime({
12975
12992
  url,
12976
12993
  basePath
12977
12994
  }))}`;
12978
- if (hotreload) {
12979
- HTML += getHotReloadScript();
12980
- }
12981
12995
  return HTML;
12982
12996
  }
12983
12997
  async function getJSON(req, res, url, basePath, out) {
@@ -12989,12 +13003,12 @@ async function getJSON(req, res, url, basePath, out) {
12989
13003
  var import_node_path13 = require("node:path");
12990
13004
  var import_node_process9 = require("node:process");
12991
13005
  var import_node_fs12 = require("node:fs");
12992
- async function inflateWSConfig(logger, servicePath, service, wsConfigList, inflateDir, errors) {
13006
+ async function inflateWSConfig(logger, servicePath, service, wsConfigList, inflateDir, errors, options) {
12993
13007
  const wsPath = getWSConfigPath(servicePath);
12994
13008
  if (wsPath) {
12995
13009
  try {
12996
13010
  logger.debug("importing websocket socket for service [%s]", service);
12997
- const wsConfig = await importWSConfigModule(wsPath, logger);
13011
+ const wsConfig = await importWSConfigModule(wsPath, options, logger);
12998
13012
  if (wsConfig && wsConfigList.filter((c) => c.path === wsConfig.path).length > 0) {
12999
13013
  throw new Error(`ws path [${wsConfig.path}] already defined! from [${wsPath}]`);
13000
13014
  } else if (wsConfigList) {
@@ -13052,13 +13066,13 @@ async function inflateAppForSea(logger, inflateDir, services, port) {
13052
13066
  inflateSeaAssets(logger, inflateDir);
13053
13067
  writeFile2(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
13054
13068
  const WSLIST = services.filter((service) => getWSConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
13055
- return `(await require("../${service}/ws.cjs")).default`;
13069
+ return `(await require("./../${service}/ws.cjs")).default`;
13056
13070
  }).join(",");
13057
13071
  const LOGCONFIGLIST = services.filter((service) => getLogConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
13058
- return `{config: (await require("../${service}/log.cjs")).default, service: "${service}" }`;
13072
+ return `{config: (await require("./../${service}/log.cjs")).default, service: "${service}" }`;
13059
13073
  }).join(",");
13060
13074
  const SERVERCONFIGLIST = services.filter((service) => getServerConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
13061
- return `(await require("../${service}/server.cjs")).default`;
13075
+ return `(await require("./../${service}/server.cjs")).default`;
13062
13076
  }).join(",\n");
13063
13077
  const DBCONFIGLIST = services.filter((service) => getDBConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
13064
13078
  return `new Promise(async (resolve, reject) => {
@@ -13165,21 +13179,21 @@ main().catch(e=>console.error(e));
13165
13179
  async function inflateServiceForSea(logger, inflateDir, service, servicePath, serviceRouteFileMap, serviceStaticFileMap) {
13166
13180
  const migrationsFolderPath = getMigrationsPath(servicePath);
13167
13181
  const serviceMigrations = migrationsFolderPath ? lib_exports2.getSortedMigrations(migrationsFolderPath) : [];
13168
- writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("./../lib.cjs");
13182
+ writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("./${(0, import_node_path14.relative)(service, "")}/lib.cjs");
13169
13183
 
13170
13184
  async function setupRouter() {
13171
13185
  const router = new Router();
13172
13186
  ${getErrorConfigPath(servicePath) ? `
13173
- const errorConfig = (await require("../../${service}/catch.cjs")).default;
13187
+ const errorConfig = (await require("../${(0, import_node_path14.relative)(service, "")}/${service}/catch.cjs")).default;
13174
13188
  if(errorConfig && errorConfig.catch) {
13175
13189
  for(const m of errorConfig.catch) {
13176
13190
  router.catch(m);
13177
13191
  }
13178
13192
  }` : ""}
13179
- ${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("../../${service}/cors.cjs")).default));` : ""}
13180
- ${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("../../${service}/auth.cjs")).default));` : ""}
13193
+ ${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("../${(0, import_node_path14.relative)(service, "")}/${service}/cors.cjs")).default));` : ""}
13194
+ ${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("../${(0, import_node_path14.relative)(service, "")}/${service}/auth.cjs")).default));` : ""}
13181
13195
  ${getMiddlewareConfigPath(servicePath) ? `
13182
- const middlewareConfig = (await require("../../${service}/middleware.cjs")).default;
13196
+ const middlewareConfig = (await require("../${(0, import_node_path14.relative)(service, "")}/${service}/middleware.cjs")).default;
13183
13197
  if(middlewareConfig && middlewareConfig.middleware) {
13184
13198
  for(const m of middlewareConfig.middleware) {
13185
13199
  router.use(m);
@@ -13189,8 +13203,8 @@ ${Object.keys(serviceRouteFileMap).map((filePath) => serviceRouteFileMap[filePat
13189
13203
  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));
13190
13204
  if (rPath) {
13191
13205
  const rPathExt = (0, import_node_path14.extname)(rPath);
13192
- const apiInflatedPath = (0, import_node_path14.join)("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
13193
- return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await require("./${apiInflatedPath}")).default);`;
13206
+ const apiInflatedPath = (0, import_node_path14.join)("..", (0, import_node_path14.relative)(service, ""), rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
13207
+ return ` await appendAPIModule(router, "../${(0, import_node_path14.relative)(service, "")}/${service}/http", "./${apiInflatedPath}", (await require("./${apiInflatedPath}")).default);`;
13194
13208
  } else {
13195
13209
  return "";
13196
13210
  }
@@ -13209,32 +13223,32 @@ ${getMiddlewareConfigPath(servicePath) ? `
13209
13223
  module.exports = {
13210
13224
  setupRouter
13211
13225
  }`);
13212
- writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("./../lib.cjs");
13226
+ writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("./${(0, import_node_path14.relative)(service, "")}/lib.cjs");
13213
13227
 
13214
13228
  async function runMigrations(db) {
13215
13229
  await migration.init(db);
13216
13230
  ${serviceMigrations.map((file) => {
13217
13231
  const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
13218
- return ` await migration.up.module(db, "${file}", (await require("../../${service}/migration/${name}.cjs")).default)`;
13232
+ return ` await migration.up.module(db, "${file}", (await require("../${(0, import_node_path14.relative)(service, "")}/${service}/migration/${name}.cjs")).default)`;
13219
13233
  }).join("\n")}
13220
13234
  }
13221
13235
  module.exports = {
13222
13236
  runMigrations
13223
13237
  }`);
13224
- writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("./../lib.cjs");
13238
+ writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("./${(0, import_node_path14.relative)(service, "")}/lib.cjs");
13225
13239
 
13226
13240
  async function runMigrations(db) {
13227
13241
  await migration.init(db);
13228
13242
  ${serviceMigrations.reverse().map((file) => {
13229
13243
  const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
13230
- return ` await migration.down.module(db, "${file}", (await require("../../${service}/migration/${name}.cjs")).default)`;
13244
+ return ` await migration.down.module(db, "${file}", (await require("../${(0, import_node_path14.relative)(service, "")}/${service}/migration/${name}.cjs")).default)`;
13231
13245
  }).join("\n")}
13232
13246
  }
13233
13247
  module.exports = {
13234
13248
  runMigrations
13235
13249
  }`);
13236
13250
  const staticFiles = Object.keys(serviceStaticFileMap);
13237
- writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("./../lib.cjs");
13251
+ writeFile2(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("./${(0, import_node_path14.relative)(service, "")}/lib.cjs");
13238
13252
 
13239
13253
  async function setupRouter() {
13240
13254
  const router = new Router();
@@ -13269,11 +13283,11 @@ function writeFile2(logger, path, buffer) {
13269
13283
  var import_node_path15 = require("node:path");
13270
13284
  var import_node_fs14 = require("node:fs");
13271
13285
  var import_node_process11 = require("node:process");
13272
- async function setupLogConfig(logger, servicePath, service, logConfigMap, inflateDir, errors) {
13286
+ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflateDir, options, errors) {
13273
13287
  const logPath = getLogConfigPath(servicePath);
13274
13288
  if (logPath) {
13275
13289
  try {
13276
- const logConfig = await importLogConfigModule(logPath, logger);
13290
+ const logConfig = await importLogConfigModule(logPath, options, logger);
13277
13291
  logConfigMap[service] = logConfig;
13278
13292
  if (inflateDir) {
13279
13293
  const inflatePath = (0, import_node_path15.resolve)(inflateDir, service, "log.cjs");
@@ -13569,11 +13583,11 @@ async function getDocOutput(router, fileMap, generateDocAll, generateDocType) {
13569
13583
  }
13570
13584
 
13571
13585
  // src/inflate/setup.doc.ts
13572
- async function setupDoc(logger, servicePath, service, mainRouter, fileMap, staticFileMap, inflateDir, errors) {
13586
+ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, staticFileMap, inflateDir, errors, options, inflateFlat) {
13573
13587
  const docPath = getDocConfigPath(servicePath);
13574
13588
  if (docPath) {
13575
13589
  try {
13576
- const docModule = await importDocConfigModule(docPath, logger);
13590
+ const docModule = await importDocConfigModule(docPath, options, logger);
13577
13591
  logger.debug("setting up error handling from [%s]", (0, import_node_path16.join)(service, (0, import_node_path16.basename)(docPath)));
13578
13592
  if (docModule && docModule.publish) {
13579
13593
  const paths = Object.keys(docModule.publish);
@@ -13603,7 +13617,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, stati
13603
13617
  }
13604
13618
  });
13605
13619
  if (inflateDir) {
13606
- const inflatePath = (0, import_node_path16.join)(inflateDir, service, "static", path);
13620
+ const inflatePath = (0, import_node_path16.join)(inflateDir, !inflateFlat ? service : "", "static", path);
13607
13621
  (0, import_node_fs15.mkdirSync)((0, import_node_path16.dirname)(inflatePath), {
13608
13622
  recursive: true
13609
13623
  });
@@ -13626,7 +13640,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, stati
13626
13640
  method: "GET",
13627
13641
  path,
13628
13642
  body: Buffer.from(body),
13629
- inflatePath: inflateDir ? (0, import_node_path16.join)(inflateDir, service, "static", path) : void 0
13643
+ inflatePath: inflateDir ? (0, import_node_path16.join)(inflateDir, !inflateFlat ? service : "", "static", path) : void 0
13630
13644
  };
13631
13645
  }
13632
13646
  }
@@ -13645,7 +13659,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, stati
13645
13659
  }
13646
13660
 
13647
13661
  // src/inflate/inflate.ts
13648
- async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
13662
+ async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services, inflateDir, inflateSea, port, noBuild, noMinify, inflateOnlyAssets, inflateFlat }) {
13649
13663
  logger.trace("inflateApp");
13650
13664
  const errors = [];
13651
13665
  let routeFileMap = {};
@@ -13656,14 +13670,14 @@ async function inflateApp({ inflateParallel, serverInterface, logger, hotreload,
13656
13670
  const serviceRouteFileMap = {};
13657
13671
  const serviceStaticFileMap = inflateSea ? {} : null;
13658
13672
  const servicePath = getServicePath(service);
13659
- await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, errors);
13660
- router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
13673
+ await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, { noBuild }, errors);
13674
+ router.use(await setupHTTPRouter({ noBuild }, { noMinify, inflateOnlyAssets, inflateFlat }, serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
13661
13675
  routeFileMap = {
13662
13676
  ...routeFileMap,
13663
13677
  ...serviceRouteFileMap
13664
13678
  };
13665
- await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors);
13666
- await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : void 0, errors);
13679
+ await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors, { noBuild }, inflateFlat);
13680
+ await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : void 0, errors, { noBuild });
13667
13681
  if (inflateDir && inflateSea) {
13668
13682
  await inflateServiceForSea(logger, inflateDir, service, servicePath, serviceRouteFileMap, serviceStaticFileMap);
13669
13683
  }
@@ -13678,11 +13692,11 @@ async function inflateApp({ inflateParallel, serverInterface, logger, hotreload,
13678
13692
  var import_node_fs16 = require("node:fs");
13679
13693
  var import_node_path17 = require("node:path");
13680
13694
  var import_node_process13 = require("node:process");
13681
- async function setupServerConfig(logger, servicePath, service, serverConfigMap, inflateDir, errors) {
13695
+ async function setupServerConfig(logger, servicePath, service, serverConfigMap, inflateDir, errors, options) {
13682
13696
  const serverPath = getServerConfigPath(servicePath);
13683
13697
  if (serverPath) {
13684
13698
  try {
13685
- const serverConfig = await importServerConfigModule(serverPath, logger);
13699
+ const serverConfig = await importServerConfigModule(serverPath, options, logger);
13686
13700
  serverConfigMap[service] = serverConfig;
13687
13701
  if (inflateDir) {
13688
13702
  const inflatePath = (0, import_node_path17.resolve)(inflateDir, service, "server.cjs");
@@ -14022,14 +14036,14 @@ function setupExitHandlers(app) {
14022
14036
  var import_node_path28 = require("node:path");
14023
14037
  var import_node_fs25 = require("node:fs");
14024
14038
  var import_node_process15 = require("node:process");
14025
- async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors) {
14039
+ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, options, errors) {
14026
14040
  const servicePath = getServicePath(service);
14027
14041
  const dbConfigPath = getDBConfigPath(servicePath);
14028
14042
  if (dbConfigPath) {
14029
14043
  try {
14030
- const config = await importDBConfigModule(dbConfigPath, logger);
14044
+ const config = await importDBConfigModule(dbConfigPath, options, logger);
14031
14045
  if (config && dbConfigList && dbConfigList.filter((c) => c.name === config.name).length > 0) {
14032
- throw new Error(`ws path [${config.name}] already defined! error from [${dbConfigPath}]`);
14046
+ throw new Error(`db name [${config.name}] already defined! error from [${dbConfigPath}]`);
14033
14047
  } else if (config) {
14034
14048
  if (dbConfigList) {
14035
14049
  dbConfigList.push(config);
@@ -14064,7 +14078,7 @@ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors
14064
14078
  }
14065
14079
  return false;
14066
14080
  }
14067
- async function inflateDBMigrations(logger, service, dbName, inflateDir, errors) {
14081
+ async function inflateDBMigrations(logger, service, dbName, inflateDir, options, errors) {
14068
14082
  const servicePath = getServicePath(service);
14069
14083
  const migrationsFolderPath = getMigrationsPath(servicePath);
14070
14084
  if (migrationsFolderPath) {
@@ -14074,7 +14088,7 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
14074
14088
  for (const migrationName of serviceMigrations) {
14075
14089
  const migrationPath = (0, import_node_path28.resolve)(migrationsFolderPath, migrationName);
14076
14090
  try {
14077
- const migrationModule = await importMigrationModule(migrationPath);
14091
+ const migrationModule = await importMigrationModule(migrationPath, options, logger);
14078
14092
  migrationModules.push({
14079
14093
  name: migrationName,
14080
14094
  service,
@@ -14388,6 +14402,13 @@ function checkSigCryptoKey(key, alg, usage2) {
14388
14402
  throw unusable("Ed25519");
14389
14403
  break;
14390
14404
  }
14405
+ case "ML-DSA-44":
14406
+ case "ML-DSA-65":
14407
+ case "ML-DSA-87": {
14408
+ if (!isAlgorithm(key.algorithm, alg))
14409
+ throw unusable(alg);
14410
+ break;
14411
+ }
14391
14412
  case "ES256":
14392
14413
  case "ES384":
14393
14414
  case "ES512": {
@@ -14681,33 +14702,41 @@ var digest_default = async (algorithm, data) => {
14681
14702
  function lengthAndInput(input) {
14682
14703
  return concat(uint32be(input.length), input);
14683
14704
  }
14684
- async function concatKdf(secret, bits, value) {
14685
- const iterations = Math.ceil((bits >> 3) / 32);
14686
- const res = new Uint8Array(iterations * 32);
14687
- for (let iter = 0; iter < iterations; iter++) {
14688
- const buf = new Uint8Array(4 + secret.length + value.length);
14689
- buf.set(uint32be(iter + 1));
14690
- buf.set(secret, 4);
14691
- buf.set(value, 4 + secret.length);
14692
- res.set(await digest_default("sha256", buf), iter * 32);
14693
- }
14694
- return res.slice(0, bits >> 3);
14705
+ async function concatKdf(Z, L, OtherInfo) {
14706
+ const dkLen = L >> 3;
14707
+ const hashLen = 32;
14708
+ const reps = Math.ceil(dkLen / hashLen);
14709
+ const dk = new Uint8Array(reps * hashLen);
14710
+ for (let i = 1; i <= reps; i++) {
14711
+ const hashInput = new Uint8Array(4 + Z.length + OtherInfo.length);
14712
+ hashInput.set(uint32be(i), 0);
14713
+ hashInput.set(Z, 4);
14714
+ hashInput.set(OtherInfo, 4 + Z.length);
14715
+ const hashResult = await digest_default("sha256", hashInput);
14716
+ dk.set(hashResult, (i - 1) * hashLen);
14717
+ }
14718
+ return dk.slice(0, dkLen);
14695
14719
  }
14696
14720
  async function deriveKey(publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(0), apv = new Uint8Array(0)) {
14697
14721
  checkEncCryptoKey(publicKey, "ECDH");
14698
14722
  checkEncCryptoKey(privateKey, "ECDH", "deriveBits");
14699
- const value = concat(lengthAndInput(encoder.encode(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));
14700
- let length;
14701
- if (publicKey.algorithm.name === "X25519") {
14702
- length = 256;
14703
- } else {
14704
- length = Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3;
14705
- }
14706
- const sharedSecret = new Uint8Array(await crypto.subtle.deriveBits({
14723
+ const algorithmID = lengthAndInput(encoder.encode(algorithm));
14724
+ const partyUInfo = lengthAndInput(apu);
14725
+ const partyVInfo = lengthAndInput(apv);
14726
+ const suppPubInfo = uint32be(keyLength);
14727
+ const suppPrivInfo = new Uint8Array(0);
14728
+ const otherInfo = concat(algorithmID, partyUInfo, partyVInfo, suppPubInfo, suppPrivInfo);
14729
+ const Z = new Uint8Array(await crypto.subtle.deriveBits({
14707
14730
  name: publicKey.algorithm.name,
14708
14731
  public: publicKey
14709
- }, privateKey, length));
14710
- return concatKdf(sharedSecret, keyLength, value);
14732
+ }, privateKey, getEcdhBitLength(publicKey)));
14733
+ return concatKdf(Z, keyLength, otherInfo);
14734
+ }
14735
+ function getEcdhBitLength(publicKey) {
14736
+ if (publicKey.algorithm.name === "X25519") {
14737
+ return 256;
14738
+ }
14739
+ return Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3;
14711
14740
  }
14712
14741
  function allowed(key) {
14713
14742
  switch (key.algorithm.namedCurve) {
@@ -14812,6 +14841,19 @@ function subtleMapping(jwk) {
14812
14841
  let algorithm;
14813
14842
  let keyUsages;
14814
14843
  switch (jwk.kty) {
14844
+ case "AKP": {
14845
+ switch (jwk.alg) {
14846
+ case "ML-DSA-44":
14847
+ case "ML-DSA-65":
14848
+ case "ML-DSA-87":
14849
+ algorithm = { name: jwk.alg };
14850
+ keyUsages = jwk.priv ? ["sign"] : ["verify"];
14851
+ break;
14852
+ default:
14853
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
14854
+ }
14855
+ break;
14856
+ }
14815
14857
  case "RSA": {
14816
14858
  switch (jwk.alg) {
14817
14859
  case "PS256":
@@ -14897,9 +14939,11 @@ var jwk_to_key_default = async (jwk) => {
14897
14939
  }
14898
14940
  const { algorithm, keyUsages } = subtleMapping(jwk);
14899
14941
  const keyData = { ...jwk };
14900
- delete keyData.alg;
14942
+ if (keyData.kty !== "AKP") {
14943
+ delete keyData.alg;
14944
+ }
14901
14945
  delete keyData.use;
14902
- return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d ? false : true), jwk.key_ops ?? keyUsages);
14946
+ return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
14903
14947
  };
14904
14948
 
14905
14949
  // node_modules/jose/dist/webapi/key/import.js
@@ -14920,6 +14964,16 @@ async function importJWK(jwk, alg, options) {
14920
14964
  if ("oth" in jwk && jwk.oth !== void 0) {
14921
14965
  throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
14922
14966
  }
14967
+ return jwk_to_key_default({ ...jwk, alg, ext });
14968
+ case "AKP": {
14969
+ if (typeof jwk.alg !== "string" || !jwk.alg) {
14970
+ throw new TypeError('missing "alg" (Algorithm) Parameter value');
14971
+ }
14972
+ if (alg !== void 0 && alg !== jwk.alg) {
14973
+ throw new TypeError("JWK alg and alg option value mismatch");
14974
+ }
14975
+ return jwk_to_key_default({ ...jwk, ext });
14976
+ }
14923
14977
  case "EC":
14924
14978
  case "OKP":
14925
14979
  return jwk_to_key_default({ ...jwk, alg, ext });
@@ -15169,10 +15223,10 @@ function isJWK(key) {
15169
15223
  return is_object_default(key) && typeof key.kty === "string";
15170
15224
  }
15171
15225
  function isPrivateJWK(key) {
15172
- return key.kty !== "oct" && typeof key.d === "string";
15226
+ return key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
15173
15227
  }
15174
15228
  function isPublicJWK(key) {
15175
- return key.kty !== "oct" && typeof key.d === "undefined";
15229
+ return key.kty !== "oct" && typeof key.d === "undefined" && typeof key.priv === "undefined";
15176
15230
  }
15177
15231
  function isSecretJWK(key) {
15178
15232
  return key.kty === "oct" && typeof key.k === "string";
@@ -15225,6 +15279,18 @@ var handleKeyObject = (keyObject, alg) => {
15225
15279
  isPublic ? "verify" : "sign"
15226
15280
  ]);
15227
15281
  }
15282
+ switch (keyObject.asymmetricKeyType) {
15283
+ case "ml-dsa-44":
15284
+ case "ml-dsa-65":
15285
+ case "ml-dsa-87": {
15286
+ if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
15287
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
15288
+ }
15289
+ cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
15290
+ isPublic ? "verify" : "sign"
15291
+ ]);
15292
+ }
15293
+ }
15228
15294
  if (keyObject.asymmetricKeyType === "rsa") {
15229
15295
  let hash;
15230
15296
  switch (alg) {
@@ -15652,6 +15718,10 @@ async function keyToJWK(key) {
15652
15718
  throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");
15653
15719
  }
15654
15720
  const { ext, key_ops, alg, use, ...jwk } = await crypto.subtle.exportKey("jwk", key);
15721
+ if (jwk.kty === "AKP") {
15722
+ ;
15723
+ jwk.alg = alg;
15724
+ }
15655
15725
  return jwk;
15656
15726
  }
15657
15727
 
@@ -15917,6 +15987,10 @@ var subtle_dsa_default = (alg, algorithm) => {
15917
15987
  case "Ed25519":
15918
15988
  case "EdDSA":
15919
15989
  return { name: "Ed25519" };
15990
+ case "ML-DSA-44":
15991
+ case "ML-DSA-65":
15992
+ case "ML-DSA-87":
15993
+ return { name: alg };
15920
15994
  default:
15921
15995
  throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
15922
15996
  }
@@ -16845,6 +16919,10 @@ var MiqroJSONSchema = {
16845
16919
  properties: {
16846
16920
  name: "string?",
16847
16921
  services: "string[]?",
16922
+ noBuild: "boolean?",
16923
+ noMinify: "boolean?",
16924
+ inflateOnlyAssets: "boolean?",
16925
+ inflateFlat: "boolean?",
16848
16926
  port: "number?|string?",
16849
16927
  inflateDir: "string?",
16850
16928
  browser: "boolean?|string?",
@@ -16977,8 +17055,10 @@ var Miqro = class _Miqro {
16977
17055
  watcher;
16978
17056
  constructor(options) {
16979
17057
  this.options = {
17058
+ noMinify: false,
16980
17059
  editor: false,
16981
17060
  name: "server",
17061
+ noBuild: false,
16982
17062
  port: getPORT(),
16983
17063
  services: [],
16984
17064
  ...options ? options : {}
@@ -17042,6 +17122,7 @@ var Miqro = class _Miqro {
17042
17122
  name: miqroJSON.name ? miqroJSON.name : void 0,
17043
17123
  port: miqroJSON.port ? String(miqroJSON.port) : void 0,
17044
17124
  services: miqroJSON.services ? miqroJSON.services.map((s) => (0, import_node_path30.join)((0, import_node_path30.relative)((0, import_node_process16.cwd)(), miqroJSONDir), s)) : void 0,
17125
+ noBuild: miqroJSON.noBuild !== void 0 ? miqroJSON.noBuild : false,
17045
17126
  ...options ? options : {}
17046
17127
  });
17047
17128
  await app.inflate({
@@ -17093,7 +17174,7 @@ var Miqro = class _Miqro {
17093
17174
  const errors = [];
17094
17175
  for (const service of this.options.services) {
17095
17176
  const servicePath = getServicePath(service);
17096
- await setupServerConfig(this.logger, servicePath, service, serverConfigMap, options && options.inflateSea ? options.inflateDir : void 0, errors);
17177
+ await setupServerConfig(this.logger, servicePath, service, serverConfigMap, options && options.inflateSea ? options.inflateDir : void 0, errors, this.options);
17097
17178
  }
17098
17179
  return {
17099
17180
  serverConfigMap,
@@ -17105,9 +17186,9 @@ var Miqro = class _Miqro {
17105
17186
  const dbList = [];
17106
17187
  const dbConfigListALL = [];
17107
17188
  for (const service of this.options.services) {
17108
- const dbConfig = await inflateDBConfig(this.logger, service, dbConfigListALL, options?.inflateSea ? options?.inflateDir : void 0, errors);
17189
+ const dbConfig = await inflateDBConfig(this.logger, service, dbConfigListALL, options?.inflateSea ? options?.inflateDir : void 0, this.options, errors);
17109
17190
  if (dbConfig) {
17110
- const migrations = await inflateDBMigrations(this.logger, service, dbConfig.name, options?.inflateSea ? options?.inflateDir : void 0, errors);
17191
+ const migrations = await inflateDBMigrations(this.logger, service, dbConfig.name, options?.inflateSea ? options?.inflateDir : void 0, this.options, errors);
17111
17192
  dbList.push({
17112
17193
  service,
17113
17194
  dbConfig,
@@ -17160,7 +17241,7 @@ var Miqro = class _Miqro {
17160
17241
  }
17161
17242
  try {
17162
17243
  this.inflated = void 0;
17163
- if (_Miqro.initAssetsPromise === null) {
17244
+ if (_Miqro.initAssetsPromise === null && (this.options.noBuild === false || this.options.noMinify === false)) {
17164
17245
  _Miqro.initAssetsPromise = initAssets(this.logger);
17165
17246
  }
17166
17247
  await _Miqro.initAssetsPromise;
@@ -17182,6 +17263,10 @@ var Miqro = class _Miqro {
17182
17263
  wsConfigList.push({
17183
17264
  path: HOT_RELOAD_PATH
17184
17265
  });
17266
+ this.logger?.debug("setting up hot-reload script on [%s]", HOT_RELOAD_SCRIPT_PATH);
17267
+ const hotReloadScriptRouter = new Router2();
17268
+ hotReloadScriptRouter.get(HOT_RELOAD_SCRIPT_PATH, async (req, res) => res.js(HOT_RELOAD_JS_SCRIPT));
17269
+ router.use(hotReloadScriptRouter);
17185
17270
  }
17186
17271
  await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, serverConfigMap, "preload");
17187
17272
  const [serviceRouter, errors, fileMap, serviceWSConfigList, serviceLogConfigMap] = await inflateApp({
@@ -17194,7 +17279,11 @@ var Miqro = class _Miqro {
17194
17279
  inflateSea: options?.inflateSea ? true : false,
17195
17280
  //inflateTests: options?.inflateTests ? true : false,
17196
17281
  hotreload: this.options?.hotreload ? true : false,
17197
- inflateParallel: options?.inflateParallel
17282
+ inflateParallel: options?.inflateParallel,
17283
+ noBuild: this.options?.noBuild,
17284
+ noMinify: this.options?.noMinify,
17285
+ inflateOnlyAssets: options?.inflateOnlyAssets,
17286
+ inflateFlat: options?.inflateFlat
17198
17287
  });
17199
17288
  wsConfigList.push(...serviceWSConfigList);
17200
17289
  router.use(serviceRouter);