miqro 6.2.13 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +9 -17
  2. package/build/editor.bundle.js +11601 -10129
  3. package/build/esm/src/bin/types.js +10 -5
  4. package/build/esm/src/cluster.js +1 -1
  5. package/build/esm/src/common/arguments.d.ts +2 -1
  6. package/build/esm/src/common/arguments.js +42 -18
  7. package/build/esm/src/common/assets.d.ts +1 -1
  8. package/build/esm/src/common/assets.js +34 -13
  9. package/build/esm/src/common/esbuild.d.ts +4 -1
  10. package/build/esm/src/common/esbuild.js +31 -26
  11. package/build/esm/src/common/exit.js +4 -4
  12. package/build/esm/src/common/help.d.ts +1 -1
  13. package/build/esm/src/common/help.js +2 -2
  14. package/build/esm/src/common/jsx.d.ts +2 -3
  15. package/build/esm/src/common/jsx.js +70 -75
  16. package/build/esm/src/common/paths.d.ts +0 -1
  17. package/build/esm/src/common/paths.js +3 -3
  18. package/build/esm/src/common/watch.d.ts +0 -1
  19. package/build/esm/src/common/watch.js +4 -1
  20. package/build/esm/src/inflate/inflate-sea.js +35 -24
  21. package/build/esm/src/inflate/inflate.js +4 -4
  22. package/build/esm/src/inflate/setup-auth.js +1 -1
  23. package/build/esm/src/inflate/setup-cors.js +1 -1
  24. package/build/esm/src/inflate/setup-db.js +2 -2
  25. package/build/esm/src/inflate/setup-error.js +1 -1
  26. package/build/esm/src/inflate/setup-http.js +16 -16
  27. package/build/esm/src/inflate/setup-log.js +1 -1
  28. package/build/esm/src/inflate/setup-middleware.js +1 -1
  29. package/build/esm/src/inflate/setup-server-config.js +1 -1
  30. package/build/esm/src/inflate/setup-ws.js +1 -1
  31. package/build/esm/src/inflate/setup.doc.d.ts +2 -2
  32. package/build/esm/src/inflate/setup.doc.js +23 -2
  33. package/build/esm/src/inflate/utils/sea-utils.js +2 -2
  34. package/build/esm/src/lib.d.ts +10 -1
  35. package/build/esm/src/lib.js +16 -1
  36. package/build/esm/src/main.js +2 -1
  37. package/build/esm/src/services/app.d.ts +1 -0
  38. package/build/esm/src/services/app.js +4 -5
  39. package/build/esm/src/services/migrations.js +2 -2
  40. package/build/esm/src/services/utils/jwt.d.ts +2 -0
  41. package/build/esm/src/services/utils/jwt.js +23 -0
  42. package/build/esm/src/services/utils/middleware.d.ts +9 -0
  43. package/build/esm/src/services/utils/middleware.js +9 -0
  44. package/build/esm/src/services/utils/server-interface.js +33 -4
  45. package/build/esm/src/types.d.ts +50 -83
  46. package/build/lib.cjs +15694 -15619
  47. package/package.json +6 -8
  48. package/sea/basic-compile.base64.sh +1 -1
  49. package/sea/basic-compile.sh +1 -1
  50. package/sea/install-nodejs.sh +1 -1
  51. package/sea/node.version.tag +1 -1
  52. package/.eslintrc +0 -15
  53. package/build/esm/editor/auth.d.ts +0 -6
  54. package/build/esm/editor/auth.js +0 -41
  55. package/build/esm/editor/common/admin-interface.d.ts +0 -36
  56. package/build/esm/editor/common/admin-interface.js +0 -44
  57. package/build/esm/editor/common/constants.d.ts +0 -4
  58. package/build/esm/editor/common/constants.js +0 -20
  59. package/build/esm/editor/common/constants.server.d.ts +0 -2
  60. package/build/esm/editor/common/constants.server.js +0 -4
  61. package/build/esm/editor/common/editor-index.d.ts +0 -2
  62. package/build/esm/editor/common/editor-index.js +0 -14
  63. package/build/esm/editor/common/html-encode.d.ts +0 -1
  64. package/build/esm/editor/common/html-encode.js +0 -14
  65. package/build/esm/editor/common/log-socket.d.ts +0 -15
  66. package/build/esm/editor/common/log-socket.js +0 -70
  67. package/build/esm/editor/common/templates.d.ts +0 -11
  68. package/build/esm/editor/common/templates.js +0 -477
  69. package/build/esm/editor/components/api-preview.d.ts +0 -11
  70. package/build/esm/editor/components/api-preview.js +0 -90
  71. package/build/esm/editor/components/editor.d.ts +0 -16
  72. package/build/esm/editor/components/editor.js +0 -365
  73. package/build/esm/editor/components/file-browser.d.ts +0 -37
  74. package/build/esm/editor/components/file-browser.js +0 -126
  75. package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
  76. package/build/esm/editor/components/file-editor-toolbar.js +0 -93
  77. package/build/esm/editor/components/file-editor.d.ts +0 -32
  78. package/build/esm/editor/components/file-editor.js +0 -59
  79. package/build/esm/editor/components/filter-query.d.ts +0 -1
  80. package/build/esm/editor/components/filter-query.js +0 -22
  81. package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
  82. package/build/esm/editor/components/highlight-text-area.js +0 -125
  83. package/build/esm/editor/components/log-viewer.d.ts +0 -6
  84. package/build/esm/editor/components/log-viewer.js +0 -69
  85. package/build/esm/editor/components/new-file.d.ts +0 -10
  86. package/build/esm/editor/components/new-file.js +0 -117
  87. package/build/esm/editor/components/scroll-query.d.ts +0 -7
  88. package/build/esm/editor/components/scroll-query.js +0 -21
  89. package/build/esm/editor/components/start-page.d.ts +0 -13
  90. package/build/esm/editor/components/start-page.js +0 -30
  91. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
  92. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
  93. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
  94. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
  95. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
  96. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
  97. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
  98. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
  99. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
  100. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
  101. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
  102. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
  103. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
  104. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
  105. package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
  106. package/build/esm/editor/http/admin/editor/editor.js +0 -7
  107. package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
  108. package/build/esm/editor/http/admin/editor/index.api.js +0 -21
  109. package/build/esm/editor/server.d.ts +0 -3
  110. package/build/esm/editor/server.js +0 -49
  111. package/build/esm/editor/ws.d.ts +0 -3
  112. package/build/esm/editor/ws.js +0 -11
  113. package/build/esm/src/services/globals.d.ts +0 -3
  114. package/build/esm/src/services/globals.js +0 -182
  115. package/build/jsx.dom.js +0 -1587
  116. package/build/postject.base64.cjs +0 -1
  117. package/editor/auth.ts +0 -51
  118. package/editor/common/admin-interface.ts +0 -84
  119. package/editor/common/constants.server.ts +0 -5
  120. package/editor/common/constants.ts +0 -21
  121. package/editor/common/editor-index.tsx +0 -17
  122. package/editor/common/html-encode.ts +0 -14
  123. package/editor/common/log-socket.tsx +0 -85
  124. package/editor/common/templates.ts +0 -481
  125. package/editor/components/api-preview.tsx +0 -116
  126. package/editor/components/editor.tsx +0 -494
  127. package/editor/components/file-browser.tsx +0 -308
  128. package/editor/components/file-editor-toolbar.tsx +0 -191
  129. package/editor/components/file-editor.tsx +0 -122
  130. package/editor/components/filter-query.tsx +0 -22
  131. package/editor/components/highlight-text-area.tsx +0 -145
  132. package/editor/components/log-viewer.tsx +0 -110
  133. package/editor/components/new-file.tsx +0 -169
  134. package/editor/components/scroll-query.tsx +0 -22
  135. package/editor/components/start-page.tsx +0 -49
  136. package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
  137. package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
  138. package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
  139. package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
  140. package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
  141. package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
  142. package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
  143. package/editor/http/admin/editor/editor.tsx +0 -8
  144. package/editor/http/admin/editor/index.api.tsx +0 -39
  145. package/editor/server.ts +0 -57
  146. package/editor/ws.ts +0 -15
  147. package/sea/types.json +0 -1
  148. package/src/bin/compile.ts +0 -35
  149. package/src/bin/doc-md.ts +0 -210
  150. package/src/bin/generate-doc.ts +0 -64
  151. package/src/bin/test.ts +0 -92
  152. package/src/bin/types.ts +0 -29
  153. package/src/cluster.ts +0 -27
  154. package/src/common/arguments.ts +0 -733
  155. package/src/common/assets.ts +0 -128
  156. package/src/common/checksum.ts +0 -58
  157. package/src/common/constants.ts +0 -18
  158. package/src/common/content-type.ts +0 -84
  159. package/src/common/esbuild.ts +0 -94
  160. package/src/common/exit.ts +0 -91
  161. package/src/common/fs.ts +0 -82
  162. package/src/common/help.ts +0 -60
  163. package/src/common/jsx.ts +0 -547
  164. package/src/common/jwt.ts +0 -85
  165. package/src/common/paths.ts +0 -107
  166. package/src/common/watch.ts +0 -85
  167. package/src/inflate/inflate-sea.ts +0 -226
  168. package/src/inflate/inflate.ts +0 -101
  169. package/src/inflate/md.ts +0 -25
  170. package/src/inflate/setup-auth.ts +0 -41
  171. package/src/inflate/setup-cors.ts +0 -41
  172. package/src/inflate/setup-db.ts +0 -117
  173. package/src/inflate/setup-error.ts +0 -44
  174. package/src/inflate/setup-http.ts +0 -704
  175. package/src/inflate/setup-log.ts +0 -45
  176. package/src/inflate/setup-middleware.ts +0 -47
  177. package/src/inflate/setup-server-config.ts +0 -48
  178. package/src/inflate/setup-test.ts +0 -23
  179. package/src/inflate/setup-ws.ts +0 -50
  180. package/src/inflate/setup.doc.ts +0 -68
  181. package/src/inflate/utils/sea-utils.ts +0 -14
  182. package/src/lib.ts +0 -19
  183. package/src/main.ts +0 -100
  184. package/src/services/app.ts +0 -698
  185. package/src/services/editor.tsx +0 -101
  186. package/src/services/globals.ts +0 -186
  187. package/src/services/hot-reload.ts +0 -51
  188. package/src/services/migrations.ts +0 -68
  189. package/src/services/utils/admin-interface.ts +0 -37
  190. package/src/services/utils/cache.ts +0 -88
  191. package/src/services/utils/cluster-cache.ts +0 -230
  192. package/src/services/utils/cluster-ws.ts +0 -202
  193. package/src/services/utils/db-manager.ts +0 -92
  194. package/src/services/utils/get-route.ts +0 -70
  195. package/src/services/utils/log-transport.ts +0 -81
  196. package/src/services/utils/log.ts +0 -92
  197. package/src/services/utils/server-interface.ts +0 -92
  198. package/src/services/utils/websocketmanager.ts +0 -157
  199. package/src/types/@esbuild.d.ts +0 -1
  200. package/src/types/@miqro/core.d.ts +0 -2
  201. package/src/types/@miqro/jsx.d.ts +0 -2
  202. package/src/types/@miqro/parser.d.ts +0 -2
  203. package/src/types/@miqro/query.d.ts +0 -2
  204. package/src/types/@miqro/request.d.ts +0 -2
  205. package/src/types/@miqro/test.d.ts +0 -2
  206. package/src/types/@miqro.d.ts +0 -1
  207. package/src/types/@types.d.ts +0 -1
  208. package/src/types/browser.globals.d.ts +0 -1
  209. package/src/types/cookie.d.ts +0 -2
  210. package/src/types/globals.d.ts +0 -2
  211. package/src/types/jose.d.ts +0 -2
  212. package/src/types/jsx.globals.d.ts +0 -38
  213. package/src/types/miqro.d.ts +0 -228
  214. package/src/types/postject.d.ts +0 -1
  215. package/src/types/server.globals.d.ts +0 -47
  216. package/src/types.ts +0 -304
  217. package/tsconfig.json +0 -35
@@ -1,12 +1,17 @@
1
- import { initTypes } from "../common/assets.js";
1
+ // import { initTypes } from "../common/assets.js";
2
2
  import { existsSync, writeFileSync } from "node:fs";
3
3
  import { TEMPLATES } from "../../editor/common/templates.js";
4
4
  import { EXIT_CODES } from "../common/constants.js";
5
+ import { installAsset } from "../common/assets.js";
5
6
  export async function installTypings(args, logger) {
6
- if (args.installTypes) {
7
- logger.debug("writing types");
8
- // install typing for typescript only if argument --install-types is set
9
- await initTypes(logger);
7
+ /*if (args.installTypes) {
8
+ logger.debug("writing types");
9
+ // install typing for typescript only if argument --install-types is set
10
+ await initTypes(logger);
11
+ }*/
12
+ if (args.install) {
13
+ logger.debug("writing node_modules");
14
+ await installAsset(logger, ["node_modules/"]);
10
15
  }
11
16
  if (args.installTSConfig && !existsSync("tsconfig.json")) {
12
17
  logger.info("writing tsconfig.json");
@@ -10,7 +10,7 @@ const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import
10
10
  //const usage = "CLUSTER_COUNT=os.cpus().length [CLUSTER_AUTO_BROADCAST=true|false] [CLUSTER_DISABLE_RESTART=true|false]";
11
11
  const CLUSTER_COUNT = checkEnvVariable("CLUSTER_COUNT", String(cpus().length));
12
12
  const args = parseArguments();
13
- if (args.inflate || args.test || args.compile || args.installTSConfig || args.installTypes || args.migrateDown || args.migrateUp) {
13
+ if (args.inflate || args.test || args.compile || args.installTSConfig /* || args.installTypes */ || args.migrateDown || args.migrateUp) {
14
14
  await import("./main.js");
15
15
  }
16
16
  else {
@@ -18,9 +18,9 @@ export interface Arguments {
18
18
  name?: string;
19
19
  browser?: string | boolean;
20
20
  logFile?: string | boolean;
21
- installTypes: boolean;
22
21
  installMiqroJSON: boolean;
23
22
  installTSConfig: boolean;
23
+ install: boolean;
24
24
  test: boolean;
25
25
  port: string;
26
26
  inflate: boolean;
@@ -38,6 +38,7 @@ export interface Arguments {
38
38
  services: string[];
39
39
  editor: boolean;
40
40
  hotreload: boolean;
41
+ watch: boolean;
41
42
  https: boolean;
42
43
  serverOptions: ServerOptions;
43
44
  httpsRedirect?: number;
@@ -56,10 +56,12 @@ export function parseArguments() {
56
56
  browser: null,
57
57
  logFile: null,
58
58
  hotreload: null,
59
+ watch: null,
59
60
  miqroJSONPath: null,
60
61
  installMiqroJSON: null,
62
+ install: null,
61
63
  disableMiqroJSON: null,
62
- installTypes: null,
64
+ // installTypes: null,
63
65
  port: null,
64
66
  installTSConfig: null,
65
67
  migrateUp: null,
@@ -132,7 +134,23 @@ export function parseArguments() {
132
134
  }
133
135
  flags.installTSConfig = true;
134
136
  continue;
137
+ case "--install":
138
+ if (flags.inflate !== null || flags.installTSConfig !== null) {
139
+ console.error("bad arguments.");
140
+ console.error(usage);
141
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
142
+ }
143
+ flags.install = true;
144
+ continue;
135
145
  case "--watch":
146
+ if (flags.watch !== null) {
147
+ console.error("bad arguments.");
148
+ console.error(usage);
149
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
150
+ }
151
+ flags.watch = true;
152
+ continue;
153
+ case "--hot-reload":
136
154
  if (flags.hotreload !== null) {
137
155
  console.error("bad arguments.");
138
156
  console.error(usage);
@@ -319,14 +337,14 @@ export function parseArguments() {
319
337
  flags.inflateSEA = true;
320
338
  flags.inflate = true;
321
339
  continue;
322
- case "--install-types":
323
- if (flags.inflate !== null || flags.installTypes !== null) {
324
- console.error("bad arguments.");
325
- console.error(usage);
326
- process.exit(EXIT_CODES.BAD_ARGUMENTS);
327
- }
328
- flags.installTypes = true;
329
- continue;
340
+ /*case "--install-types":
341
+ if (flags.inflate !== null || flags.installTypes !== null) {
342
+ console.error("bad arguments.");
343
+ console.error(usage);
344
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
345
+ }
346
+ flags.installTypes = true;
347
+ continue;*/
330
348
  case "--editor":
331
349
  if (flags.editor !== null) {
332
350
  console.error("bad arguments.");
@@ -522,7 +540,7 @@ export function parseArguments() {
522
540
  }
523
541
  }
524
542
  flags.editor = flags.editor ? flags.editor : false;
525
- if (services.length === 0 && (!flags.installTSConfig && !flags.installTypes && !flags.installMiqroJSON)) {
543
+ if (services.length === 0 && (!flags.installTSConfig /* && !flags.installTypes*/ && !flags.installMiqroJSON)) {
526
544
  flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
527
545
  console.error(`bad arguments. missing --service argument`);
528
546
  console.error(usage);
@@ -548,35 +566,39 @@ export function parseArguments() {
548
566
  console.error("for ts");
549
567
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
550
568
  }
569
+ if (flags.install && flags.inflate) {
570
+ console.error("bad arguments. cannot use --install with --inflate");
571
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
572
+ }
551
573
  if (flags.inflate && flags.editor) {
552
574
  console.error("bad arguments. cannot use --inflate with --editor");
553
575
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
554
576
  }
555
- if (flags.inflate && (flags.installTypes || flags.installTSConfig || flags.installMiqroJSON)) {
556
- console.error("bad arguments. cannot use --inflate with --install-types, --install-tsconfig or --install-miqrojson");
577
+ if (flags.inflate && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON || flags.install)) {
578
+ console.error("bad arguments. cannot use --inflate with --install, --install-tsconfig or --install-miqrojson");
557
579
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
558
580
  }
559
581
  if (flags.inflateSEA && !flags.inflate) {
560
582
  console.error("bad arguments. cannot use --inflate-sea without --inflate");
561
583
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
562
584
  }
563
- if (flags.editor && (flags.installTypes || flags.installTSConfig || flags.installMiqroJSON)) {
585
+ if (flags.editor && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON)) {
564
586
  console.error("bad arguments. cannot use --editor with--install-types, --install-tsconfig or --install-miqrojson");
565
587
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
566
588
  }
567
- if (flags.test && (flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
589
+ if (flags.test && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
568
590
  console.error("bad arguments. cannot use --editor with --test");
569
591
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
570
592
  }
571
- if (flags.migrateUp && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
593
+ if (flags.migrateUp && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
572
594
  console.error("bad arguments. cannot use with --migrate-up");
573
595
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
574
596
  }
575
- if (flags.migrateDown && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
597
+ if (flags.migrateDown && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
576
598
  console.error("bad arguments. cannot use with --migrate-down");
577
599
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
578
600
  }
579
- if (flags.generateDoc && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
601
+ if (flags.generateDoc && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
580
602
  console.error("bad arguments. cannot use with --generate-doc");
581
603
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
582
604
  }
@@ -604,11 +626,13 @@ export function parseArguments() {
604
626
  logFile: flags.logFile !== null ? flags.logFile : undefined,
605
627
  generateDocAll: flags.generateDocAll ? true : false,
606
628
  hotreload: flags.hotreload ? true : false,
629
+ watch: flags.watch ? true : false,
607
630
  disableMiqroJSON: flags.disableMiqroJSON !== null ? flags.disableMiqroJSON : false,
608
631
  miqroJSONPath: miqroJSONPath ? miqroJSONPath : false,
609
- installTypes: flags.installTypes ? true : false,
632
+ // installTypes: flags.installTypes ? true : false,
610
633
  installMiqroJSON: flags.installMiqroJSON ? true : false,
611
634
  installTSConfig: flags.installTSConfig ? true : false,
635
+ install: flags.install,
612
636
  inflate: flags.inflate,
613
637
  port: flags.port ? flags.port : getPORT(),
614
638
  migrateUp: flags.migrateUp ? true : false,
@@ -7,6 +7,6 @@ export declare function getVersion(): {
7
7
  ESBUILD_VERSION: string;
8
8
  };
9
9
  export declare function initAssets(logger: Logger): Promise<void>;
10
- export declare function initTypes(logger: MinimalLogger): Promise<void>;
10
+ export declare function installAsset(logger: MinimalLogger, include: string[]): Promise<void>;
11
11
  export declare function validateAsset(logger: MinimalLogger | undefined, path: string, internalChecksum: string): Promise<boolean>;
12
12
  export declare function initAsset(logger: MinimalLogger, path: string, buffer: Buffer, executable?: boolean, checksum?: Promise<string>, logInstallasInfo?: boolean): Promise<void>;
@@ -1,11 +1,12 @@
1
- import { chmodSync, constants, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
1
+ import { chmodSync, constants, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
2
2
  import { getAsset as seaGetAsset, isSea } from "node:sea";
3
- import { dirname, resolve } from "node:path";
3
+ import { dirname, join, resolve } from "node:path";
4
4
  import { calculateChecksum, calculateChecksumFromBuffer } from "./checksum.js";
5
5
  import { arch, cwd, platform } from "node:process";
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { initESBuild } from "./esbuild.js";
8
- import { initJSXJS } from "./jsx.js";
8
+ import { mkdirASync, unlinkASync, writeFileASync } from "./fs.js";
9
+ // import { initJSXJS } from "./jsx.js";
9
10
  //const require = createRequire(import.meta.url);
10
11
  export const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..") : null;
11
12
  const ASSETS_ROUTER = {
@@ -13,7 +14,7 @@ const ASSETS_ROUTER = {
13
14
  "version.tag": "sea/version.tag",
14
15
  "node.version.tag": "sea/node.version.tag",
15
16
  "esbuild.version.tag": "sea/esbuild.version.tag",
16
- "postject.base64.cjs": "build/postject.base64.cjs",
17
+ // "postject.base64.cjs": "build/postject.base64.cjs",
17
18
  "sea.basic.config.json": "sea/basic-config.json",
18
19
  "node.sh": "sea/node.sh",
19
20
  "install-nodejs.sh": "sea/install-nodejs.sh",
@@ -21,8 +22,9 @@ const ASSETS_ROUTER = {
21
22
  "sign-remove.sh": "sea/sign-remove.sh",
22
23
  "sign-add.sh": "sea/sign-add.sh",
23
24
  "app.sh": "sea/app.sh",
24
- "jsx.dom.js": "build/jsx.dom.js",
25
- "types.json": "sea/types.json",
25
+ // "jsx.dom.js": "build/jsx.dom.js",
26
+ // "types.json": "sea/types.json",
27
+ "assets.base64.json": "sea/assets.base64.json",
26
28
  "editor-assets/editor.bundle.js": "build/editor.bundle.js",
27
29
  "editor-assets/style.css": "build/style.css",
28
30
  "editor-assets/font.ttf": "build/font.ttf"
@@ -68,11 +70,25 @@ export async function initAssets(logger) {
68
70
  logger.debug("esbuild version [%s]", ESBUILD_VERSION);
69
71
  }
70
72
  logger.debug("platform [%s-%s]", platform, arch);
71
- await Promise.all([initJSXJS(logger), initESBuild(logger)]);
73
+ // await Promise.all([initJSXJS(logger), initESBuild(logger)]);
74
+ await Promise.all([initESBuild(logger)]);
72
75
  }
73
- export async function initTypes(logger) {
74
- const typesJSON = JSON.parse(Buffer.from(getAsset("types.json")).toString("utf-8"));
75
- await Promise.all(Object.keys(typesJSON).map(typeFile => initAsset(logger, resolve(cwd(), "." + typeFile), Buffer.from(typesJSON[typeFile], "base64"))));
76
+ /*export async function initTypes(logger: MinimalLogger) {
77
+ const typesJSON = JSON.parse(Buffer.from(getAsset("types.json")).toString("utf-8"));
78
+ await Promise.all(Object.keys(typesJSON).map(typeFile =>
79
+ initAsset(logger, resolve(cwd(), "." + typeFile), Buffer.from(typesJSON[typeFile], "base64"))
80
+ ));
81
+ }*/
82
+ export async function installAsset(logger, include) {
83
+ const assetsJSON = JSON.parse(Buffer.from(getAsset("assets.base64.json")).toString("utf-8"));
84
+ await Promise.all(assetsJSON.map(asset => {
85
+ for (const i of include) {
86
+ if (asset.path.indexOf(i) === 0) {
87
+ return initAsset(logger, join(cwd(), asset.path), Buffer.from(asset.content, "base64"));
88
+ }
89
+ }
90
+ return Promise.resolve();
91
+ }));
76
92
  }
77
93
  export async function validateAsset(logger, path, internalChecksum) {
78
94
  mkdirSync(dirname(path), {
@@ -101,8 +117,13 @@ export async function initAsset(logger, path, buffer, executable, checksum, logI
101
117
  if (existsSync(path)) {
102
118
  if (!valid) {
103
119
  logger.info("updating [%s]", path);
104
- unlinkSync(path);
105
- writeFileSync(path, buffer);
120
+ await unlinkASync(path);
121
+ if (!statSync(dirname(path)).isDirectory()) {
122
+ await mkdirASync(dirname(path), {
123
+ recursive: true
124
+ });
125
+ }
126
+ await writeFileASync(path, buffer);
106
127
  if (executable) {
107
128
  chmodSync(path, constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
108
129
  }
@@ -115,7 +136,7 @@ export async function initAsset(logger, path, buffer, executable, checksum, logI
115
136
  else {
116
137
  logger.info("installing [%s]", path);
117
138
  }
118
- writeFileSync(path, buffer);
139
+ await writeFileASync(path, buffer);
119
140
  if (executable) {
120
141
  chmodSync(path, constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
121
142
  }
@@ -1,14 +1,17 @@
1
1
  import { Logger } from "@miqro/core";
2
2
  export declare function validateESBuild(logger?: Logger): Promise<boolean>;
3
3
  export declare function initESBuild(logger: Logger): Promise<void>;
4
+ export declare const NODEJS_EXTERNAL: string[];
4
5
  export declare function esBuild(options: {
5
- platform?: string;
6
+ platform?: string | false;
6
7
  entryPoints: [string];
8
+ mainFields?: string;
7
9
  bundle?: boolean;
8
10
  jsxFactory?: string;
9
11
  jsxFragment?: string;
10
12
  minify?: boolean;
11
13
  outfile?: string;
14
+ external?: string[];
12
15
  }, logger?: Logger): Promise<{
13
16
  outputFiles: {
14
17
  path: string;
@@ -13,39 +13,44 @@ export async function initESBuild(logger) {
13
13
  esbuildBinaryChecksumPromise = esbuildBinaryChecksumPromise ? esbuildBinaryChecksumPromise : calculateChecksumFromBuffer(esbuildBinaryBuffer);
14
14
  return initAsset(logger, getESBuildBinaryPath(), esbuildBinaryBuffer, true, esbuildBinaryChecksumPromise, false);
15
15
  }
16
- const NODEJS_EXTERNAL = [
17
- "node:cluster",
18
- "node:assert",
19
- "node:util",
20
- "node:path",
21
- "node:fs",
22
- "node:crypto",
23
- "node:http",
24
- "node:https",
25
- "node:os",
26
- "node:dns",
27
- "node:string_decoder",
28
- "node:stream",
29
- "node:http2",
30
- "node:net",
31
- "node:worker_threads",
32
- "node:process",
33
- "child_process",
34
- "node:child_process",
35
- "core",
36
- "globals",
37
- "jsx.globals",
38
- "server.globals",
39
- "browser.globals",
16
+ /*const NODEJS_EXTERNAL = [
17
+ "node:cluster",
18
+ "node:assert",
19
+ "node:util",
20
+ "node:path",
21
+ "node:fs",
22
+ "node:crypto",
23
+ "node:http",
24
+ "node:https",
25
+ "node:os",
26
+ "node:dns",
27
+ "node:string_decoder",
28
+ "node:stream",
29
+ "node:http2",
30
+ "node:net",
31
+ "node:worker_threads",
32
+ "node:process",
33
+ "child_process",
34
+ "node:child_process",
35
+ "core",
36
+ "globals",
37
+ "jsx.globals",
38
+ "server.globals",
39
+ "browser.globals",
40
+ "sqlite3",
41
+ "pg"
42
+ ];*/
43
+ export const NODEJS_EXTERNAL = [
40
44
  "sqlite3",
41
- "pg"
45
+ "pg",
46
+ "node:*"
42
47
  ];
43
48
  export async function esBuild(options, logger) {
44
49
  return new Promise(async (resolve, reject) => {
45
50
  try {
46
51
  //const logger = getLogger(`${SERVER_IDENTIFIER}_ESBUILD`);
47
52
  const valid = await validateESBuild(logger);
48
- const esBuildCMD = `${getESBuildBinaryPath()} "${options.entryPoints[0]}" ${NODEJS_EXTERNAL.map(e => `--external:${e}`).join(" ")} --loader:.js=jsx --jsx-factory=${options.jsxFactory} --jsx-fragment=${options.jsxFragment} ${options.bundle ? " --bundle" : ""}${options.minify ? " --minify" : ""}${options.outfile ? ` --outfile="${options.outfile}"` : ""}${options.platform ? ` --platform=${options.platform}` : ""}`;
53
+ const esBuildCMD = `${getESBuildBinaryPath()} "${options.entryPoints[0]}" ${(options.external ? options.external : NODEJS_EXTERNAL).map(e => `--external:${e}`).join(" ")} --loader:.js=jsx --jsx-factory=${options.jsxFactory} --jsx-fragment=${options.jsxFragment} ${options.bundle ? " --bundle" : ""}${options.minify ? " --minify" : ""}${options.outfile ? ` --outfile="${options.outfile}"` : ""}${options.platform ? ` --platform=${options.platform}` : ""}${options.mainFields ? ` --main-fields=${options.mainFields}` : ""}`;
49
54
  logger?.trace(esBuildCMD);
50
55
  if (!valid) {
51
56
  const err = new Error(`esbuild installation at [${getESBuildBinaryPath()}] tampered`);
@@ -1,6 +1,6 @@
1
1
  import { existsSync, rmdirSync, unlinkSync } from "node:fs";
2
2
  //import { notifiyServerStop, notifiyServerUnLoad } from "../services/server.js";
3
- import { getESBuildBinaryPath, getJSXJSPath, JSX_TMP_DIR } from "./paths.js";
3
+ import { getESBuildBinaryPath /*, getJSXJSPath*/, JSX_TMP_DIR } from "./paths.js";
4
4
  import { CLEAR_JSX_CACHE } from "./constants.js";
5
5
  import { resolve } from "node:path";
6
6
  import { EXIT_CODES } from "./constants.js";
@@ -10,10 +10,10 @@ function cleanJSX(app) {
10
10
  unlinkSync(getESBuildBinaryPath());
11
11
  }
12
12
  if (CLEAR_JSX_CACHE) {
13
- app.logger?.trace("trying to clean up jsx.js installation at [%s]", getJSXJSPath());
13
+ /*app.logger?.trace("trying to clean up jsx.js installation at [%s]", getJSXJSPath());
14
14
  if (existsSync(getJSXJSPath())) {
15
- unlinkSync(getJSXJSPath());
16
- }
15
+ unlinkSync(getJSXJSPath());
16
+ }*/
17
17
  const buildParendDir = resolve(JSX_TMP_DIR, String(process.pid));
18
18
  app.logger?.trace("trying to clean up jsx build/import folders at [%s]", buildParendDir);
19
19
  const buildDir = resolve(buildParendDir, "build");
@@ -1,3 +1,3 @@
1
1
  export declare const BIN_NAME = "miqro";
2
2
  export declare const usage = "usage: miqro [...FLAGS] --service app/\n\n==examples==\n\nmiqro --watch --service front/\nPORT=8181 miqro --service api/ --service front/\nmiqro --test --service front/\nmiqro --inflate --service front/\nmiqro --generate-doc --generate-doc-out API.md --service front/\nCLUSTER_COUNT=10 miqro-cluster --service api/";
3
- export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--watch\n\tuse to enable the hot-reload functionality.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\n\truns the application with a built-in editor.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-types\n\tcreates and updates the .types/ folder use together with --install-tsconfig.\n--install-miqrojson\n\tcreates a default miqro.json file.\n--disable-miqrojson\n\tdisables the load of miqro.json file.\n--log-file\n\toverrides the default log file from LOG_FILE.\n--browser\n\toverrides the default browser from BROWSER.\n--config\n\toverrides the default miqro.json path.\n--port\n\toverrides the default port from PORT.\n--name\n\toverrides the default name of the server.\n--https\n\tserves the server in https instead of http\n--https-key\n\tpoint to a server.key file for https.\n--https-cert\n\tpoint to a server.cert file for https.\n--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.\n--inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.\n\n==environment variables==\n\nPORT\n\toverride the default 8080 port.\nBROWSER\n\toverride the default browser. change to none to disable.\".\nLOG_FILE\n\toverride the default ./server.log file\nDB\n\tenable the server.db features\nDB_STORAGE\n\toverride the default local db location ./db.sqlite3\nDB_DIALECT\n\toverride the default node:sqlite\nDB_CONNECTION\n\toverride the default connection url\nCLEAR_JSX_CACHE\n\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\n\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
3
+ export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--watch\n\tuse to auto reload the server when files change.\n--hot-reload\n\tenables the hot-reload functionality use with --watch.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\n\truns the application with a built-in editor.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-miqrojson\n\tcreates a default miqro.json file.\n--disable-miqrojson\n\tdisables the load of miqro.json file.\n--log-file\n\toverrides the default log file from LOG_FILE.\n--browser\n\toverrides the default browser from BROWSER.\n--config\n\toverrides the default miqro.json path.\n--port\n\toverrides the default port from PORT.\n--name\n\toverrides the default name of the server.\n--https\n\tserves the server in https instead of http\n--https-key\n\tpoint to a server.key file for https.\n--https-cert\n\tpoint to a server.cert file for https.\n--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.\n--inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.\n\n==environment variables==\n\nPORT\n\toverride the default 8080 port.\nBROWSER\n\toverride the default browser. change to none to disable.\".\nLOG_FILE\n\toverride the default ./server.log file\nDB\n\tenable the server.db features\nDB_STORAGE\n\toverride the default local db location ./db.sqlite3\nDB_DIALECT\n\toverride the default node:sqlite\nDB_CONNECTION\n\toverride the default connection url\nCLEAR_JSX_CACHE\n\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\n\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
@@ -15,7 +15,8 @@ export const help = `
15
15
 
16
16
  -v, --version\n\toutputs the version number
17
17
  -h, --help\n\toutputs this page.
18
- --watch\n\tuse to enable the hot-reload functionality.
18
+ --watch\n\tuse to auto reload the server when files change.
19
+ --hot-reload\n\tenables the hot-reload functionality use with --watch.
19
20
  --test\n\trun the tests for a service.
20
21
  --migrate-up\n\tmigrations up.
21
22
  --migrate-down\n\tmigrations down.
@@ -29,7 +30,6 @@ export const help = `
29
30
  --compile\n\tinflates the application and tries to create a NODE SEA binary.
30
31
  --inflate-sea\n\tinflates the application with sea compilation scripts.
31
32
  --install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.
32
- --install-types\n\tcreates and updates the .types/ folder use together with --install-tsconfig.
33
33
  --install-miqrojson\n\tcreates a default miqro.json file.
34
34
  --disable-miqrojson\n\tdisables the load of miqro.json file.
35
35
  --log-file\n\toverrides the default log file from LOG_FILE.
@@ -3,8 +3,6 @@ import { Request, Response, CORSOptions, Logger, APIRoute } from "@miqro/core";
3
3
  import { Schema } from "@miqro/parser";
4
4
  import { APIOptions, ServerConfig, WSConfig, AuthConfig, DBConfig, LogConfig, MiddlewareConfig, ErrorConfig, DocConfig } from "../types.js";
5
5
  import { Migration } from "@miqro/query";
6
- export declare function initJSXJS(logger: Logger): Promise<void>;
7
- export declare function validateJSXJS(logger: Logger): Promise<boolean>;
8
6
  export interface Dict<T> {
9
7
  [key: string]: T | Dict<T>;
10
8
  }
@@ -13,10 +11,11 @@ export interface InflateError {
13
11
  error: Error;
14
12
  }
15
13
  export interface InflateOptions {
16
- embemedJSX: boolean;
17
14
  minify: boolean;
18
15
  useExport: boolean;
19
16
  platform?: string;
17
+ mainFields?: string;
18
+ external?: string[];
20
19
  logger?: Logger | Console;
21
20
  }
22
21
  export declare function inflateJSX(inFile: string, options: InflateOptions): Promise<string>;