miqro 7.3.6 → 8.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 (203) hide show
  1. package/README.md +3 -7
  2. package/build/esm/{src/bin → bin}/types.js +1 -2
  3. package/build/esm/{src/common → common}/arguments.d.ts +0 -2
  4. package/build/esm/{src/common → common}/arguments.js +5 -38
  5. package/build/esm/{src/common → common}/assets.js +1 -1
  6. package/build/esm/{src/common → common}/constants.d.ts +11 -0
  7. package/build/esm/{editor/common/templates.js → common/constants.js} +14 -0
  8. package/build/esm/{src/common → common}/esbuild.js +0 -1
  9. package/build/esm/common/help.d.ts +3 -0
  10. package/build/esm/{src/common → common}/help.js +0 -1
  11. package/build/esm/{src/inflate → inflate}/inflate-sea.js +3 -0
  12. package/build/esm/inflate/md.d.ts +1 -0
  13. package/build/esm/inflate/md.js +4 -0
  14. package/build/esm/{src/inflate → inflate}/setup-http.js +2 -3
  15. package/build/esm/{src/main.js → main.js} +0 -1
  16. package/build/esm/{src/services → services}/app.d.ts +0 -1
  17. package/build/esm/{src/services → services}/app.js +1 -53
  18. package/build/esm/{src/services → services}/utils/server-interface.js +18 -3
  19. package/build/esm/{src/services → services}/utils/websocketmanager.d.ts +0 -1
  20. package/build/esm/{src/services → services}/utils/websocketmanager.js +10 -20
  21. package/build/esm/{src/types.d.ts → types.d.ts} +2 -1
  22. package/build/lib.cjs +8291 -11616
  23. package/package.json +10 -22
  24. package/build/editor.bundle.js +0 -12329
  25. package/build/esm/editor/auth.d.ts +0 -6
  26. package/build/esm/editor/auth.js +0 -44
  27. package/build/esm/editor/common/constants.d.ts +0 -4
  28. package/build/esm/editor/common/constants.js +0 -20
  29. package/build/esm/editor/common/constants.server.d.ts +0 -2
  30. package/build/esm/editor/common/constants.server.js +0 -4
  31. package/build/esm/editor/common/editor-index.d.ts +0 -2
  32. package/build/esm/editor/common/editor-index.js +0 -14
  33. package/build/esm/editor/common/html-encode.d.ts +0 -1
  34. package/build/esm/editor/common/html-encode.js +0 -14
  35. package/build/esm/editor/common/log-socket.d.ts +0 -15
  36. package/build/esm/editor/common/log-socket.js +0 -71
  37. package/build/esm/editor/common/templates.d.ts +0 -11
  38. package/build/esm/editor/components/api-preview.d.ts +0 -11
  39. package/build/esm/editor/components/api-preview.js +0 -92
  40. package/build/esm/editor/components/editor.d.ts +0 -16
  41. package/build/esm/editor/components/editor.js +0 -367
  42. package/build/esm/editor/components/file-browser.d.ts +0 -37
  43. package/build/esm/editor/components/file-browser.js +0 -127
  44. package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
  45. package/build/esm/editor/components/file-editor-toolbar.js +0 -95
  46. package/build/esm/editor/components/file-editor.d.ts +0 -32
  47. package/build/esm/editor/components/file-editor.js +0 -61
  48. package/build/esm/editor/components/filter-query.d.ts +0 -1
  49. package/build/esm/editor/components/filter-query.js +0 -23
  50. package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
  51. package/build/esm/editor/components/highlight-text-area.js +0 -127
  52. package/build/esm/editor/components/log-viewer.d.ts +0 -6
  53. package/build/esm/editor/components/log-viewer.js +0 -71
  54. package/build/esm/editor/components/new-file.d.ts +0 -10
  55. package/build/esm/editor/components/new-file.js +0 -119
  56. package/build/esm/editor/components/scroll-query.d.ts +0 -7
  57. package/build/esm/editor/components/scroll-query.js +0 -22
  58. package/build/esm/editor/components/start-page.d.ts +0 -13
  59. package/build/esm/editor/components/start-page.js +0 -32
  60. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -4
  61. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -30
  62. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -7
  63. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -50
  64. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -7
  65. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -40
  66. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
  67. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -150
  68. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
  69. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -39
  70. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
  71. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
  72. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
  73. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -46
  74. package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
  75. package/build/esm/editor/http/admin/editor/editor.js +0 -8
  76. package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
  77. package/build/esm/editor/http/admin/editor/index.api.js +0 -23
  78. package/build/esm/editor/server.d.ts +0 -3
  79. package/build/esm/editor/server.js +0 -49
  80. package/build/esm/editor/ws.d.ts +0 -3
  81. package/build/esm/editor/ws.js +0 -12
  82. package/build/esm/src/common/constants.js +0 -14
  83. package/build/esm/src/common/help.d.ts +0 -3
  84. package/build/esm/src/inflate/md.d.ts +0 -3
  85. package/build/esm/src/inflate/md.js +0 -22
  86. package/build/esm/src/services/editor.d.ts +0 -3
  87. package/build/esm/src/services/editor.js +0 -66
  88. package/build/esm/src/services/utils/admin-interface.d.ts +0 -3
  89. package/build/esm/src/services/utils/admin-interface.js +0 -33
  90. package/build/style.css +0 -620
  91. package/editor/auth.ts +0 -53
  92. package/editor/common/constants.server.ts +0 -5
  93. package/editor/common/constants.ts +0 -21
  94. package/editor/common/editor-index.tsx +0 -17
  95. package/editor/common/html-encode.ts +0 -14
  96. package/editor/common/log-socket.tsx +0 -87
  97. package/editor/common/templates.ts +0 -481
  98. package/editor/components/api-preview.tsx +0 -118
  99. package/editor/components/editor.tsx +0 -496
  100. package/editor/components/file-browser.tsx +0 -311
  101. package/editor/components/file-editor-toolbar.tsx +0 -194
  102. package/editor/components/file-editor.tsx +0 -125
  103. package/editor/components/filter-query.tsx +0 -26
  104. package/editor/components/highlight-text-area.tsx +0 -148
  105. package/editor/components/log-viewer.tsx +0 -113
  106. package/editor/components/new-file.tsx +0 -172
  107. package/editor/components/scroll-query.tsx +0 -25
  108. package/editor/components/start-page.tsx +0 -52
  109. package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
  110. package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
  111. package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
  112. package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
  113. package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
  114. package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
  115. package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
  116. package/editor/http/admin/editor/editor.tsx +0 -10
  117. package/editor/http/admin/editor/index.api.tsx +0 -43
  118. package/editor/server.ts +0 -57
  119. package/editor/ws.ts +0 -17
  120. /package/build/esm/{src/bin → bin}/compile.d.ts +0 -0
  121. /package/build/esm/{src/bin → bin}/compile.js +0 -0
  122. /package/build/esm/{src/bin → bin}/doc-md.d.ts +0 -0
  123. /package/build/esm/{src/bin → bin}/doc-md.js +0 -0
  124. /package/build/esm/{src/bin → bin}/generate-doc.d.ts +0 -0
  125. /package/build/esm/{src/bin → bin}/generate-doc.js +0 -0
  126. /package/build/esm/{src/bin → bin}/test.d.ts +0 -0
  127. /package/build/esm/{src/bin → bin}/test.js +0 -0
  128. /package/build/esm/{src/bin → bin}/types.d.ts +0 -0
  129. /package/build/esm/{src/cluster.d.ts → cluster.d.ts} +0 -0
  130. /package/build/esm/{src/cluster.js → cluster.js} +0 -0
  131. /package/build/esm/{src/common → common}/admin-interface.d.ts +0 -0
  132. /package/build/esm/{src/common → common}/admin-interface.js +0 -0
  133. /package/build/esm/{src/common → common}/assets.d.ts +0 -0
  134. /package/build/esm/{src/common → common}/checksum.d.ts +0 -0
  135. /package/build/esm/{src/common → common}/checksum.js +0 -0
  136. /package/build/esm/{src/common → common}/content-type.d.ts +0 -0
  137. /package/build/esm/{src/common → common}/content-type.js +0 -0
  138. /package/build/esm/{src/common → common}/esbuild.d.ts +0 -0
  139. /package/build/esm/{src/common → common}/exit.d.ts +0 -0
  140. /package/build/esm/{src/common → common}/exit.js +0 -0
  141. /package/build/esm/{src/common → common}/fs.d.ts +0 -0
  142. /package/build/esm/{src/common → common}/fs.js +0 -0
  143. /package/build/esm/{src/common → common}/jsx.d.ts +0 -0
  144. /package/build/esm/{src/common → common}/jsx.js +0 -0
  145. /package/build/esm/{src/common → common}/jwt.d.ts +0 -0
  146. /package/build/esm/{src/common → common}/jwt.js +0 -0
  147. /package/build/esm/{src/common → common}/paths.d.ts +0 -0
  148. /package/build/esm/{src/common → common}/paths.js +0 -0
  149. /package/build/esm/{src/common → common}/watch.d.ts +0 -0
  150. /package/build/esm/{src/common → common}/watch.js +0 -0
  151. /package/build/esm/{src/inflate → inflate}/inflate-sea.d.ts +0 -0
  152. /package/build/esm/{src/inflate → inflate}/inflate.d.ts +0 -0
  153. /package/build/esm/{src/inflate → inflate}/inflate.js +0 -0
  154. /package/build/esm/{src/inflate → inflate}/setup-auth.d.ts +0 -0
  155. /package/build/esm/{src/inflate → inflate}/setup-auth.js +0 -0
  156. /package/build/esm/{src/inflate → inflate}/setup-cors.d.ts +0 -0
  157. /package/build/esm/{src/inflate → inflate}/setup-cors.js +0 -0
  158. /package/build/esm/{src/inflate → inflate}/setup-db.d.ts +0 -0
  159. /package/build/esm/{src/inflate → inflate}/setup-db.js +0 -0
  160. /package/build/esm/{src/inflate → inflate}/setup-error.d.ts +0 -0
  161. /package/build/esm/{src/inflate → inflate}/setup-error.js +0 -0
  162. /package/build/esm/{src/inflate → inflate}/setup-http.d.ts +0 -0
  163. /package/build/esm/{src/inflate → inflate}/setup-log.d.ts +0 -0
  164. /package/build/esm/{src/inflate → inflate}/setup-log.js +0 -0
  165. /package/build/esm/{src/inflate → inflate}/setup-middleware.d.ts +0 -0
  166. /package/build/esm/{src/inflate → inflate}/setup-middleware.js +0 -0
  167. /package/build/esm/{src/inflate → inflate}/setup-server-config.d.ts +0 -0
  168. /package/build/esm/{src/inflate → inflate}/setup-server-config.js +0 -0
  169. /package/build/esm/{src/inflate → inflate}/setup-test.d.ts +0 -0
  170. /package/build/esm/{src/inflate → inflate}/setup-test.js +0 -0
  171. /package/build/esm/{src/inflate → inflate}/setup-ws.d.ts +0 -0
  172. /package/build/esm/{src/inflate → inflate}/setup-ws.js +0 -0
  173. /package/build/esm/{src/inflate → inflate}/setup.doc.d.ts +0 -0
  174. /package/build/esm/{src/inflate → inflate}/setup.doc.js +0 -0
  175. /package/build/esm/{src/inflate → inflate}/utils/sea-utils.d.ts +0 -0
  176. /package/build/esm/{src/inflate → inflate}/utils/sea-utils.js +0 -0
  177. /package/build/esm/{src/lib.d.ts → lib.d.ts} +0 -0
  178. /package/build/esm/{src/lib.js → lib.js} +0 -0
  179. /package/build/esm/{src/main.d.ts → main.d.ts} +0 -0
  180. /package/build/esm/{src/services → services}/hot-reload.d.ts +0 -0
  181. /package/build/esm/{src/services → services}/hot-reload.js +0 -0
  182. /package/build/esm/{src/services → services}/migrations.d.ts +0 -0
  183. /package/build/esm/{src/services → services}/migrations.js +0 -0
  184. /package/build/esm/{src/services → services}/utils/cache.d.ts +0 -0
  185. /package/build/esm/{src/services → services}/utils/cache.js +0 -0
  186. /package/build/esm/{src/services → services}/utils/cluster-cache.d.ts +0 -0
  187. /package/build/esm/{src/services → services}/utils/cluster-cache.js +0 -0
  188. /package/build/esm/{src/services → services}/utils/cluster-ws.d.ts +0 -0
  189. /package/build/esm/{src/services → services}/utils/cluster-ws.js +0 -0
  190. /package/build/esm/{src/services → services}/utils/db-manager.d.ts +0 -0
  191. /package/build/esm/{src/services → services}/utils/db-manager.js +0 -0
  192. /package/build/esm/{src/services → services}/utils/get-route.d.ts +0 -0
  193. /package/build/esm/{src/services → services}/utils/get-route.js +0 -0
  194. /package/build/esm/{src/services → services}/utils/jwt.d.ts +0 -0
  195. /package/build/esm/{src/services → services}/utils/jwt.js +0 -0
  196. /package/build/esm/{src/services → services}/utils/log-transport.d.ts +0 -0
  197. /package/build/esm/{src/services → services}/utils/log-transport.js +0 -0
  198. /package/build/esm/{src/services → services}/utils/log.d.ts +0 -0
  199. /package/build/esm/{src/services → services}/utils/log.js +0 -0
  200. /package/build/esm/{src/services → services}/utils/middleware.d.ts +0 -0
  201. /package/build/esm/{src/services → services}/utils/middleware.js +0 -0
  202. /package/build/esm/{src/services → services}/utils/server-interface.d.ts +0 -0
  203. /package/build/esm/{src/types.js → types.js} +0 -0
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  fully typed TypeScript · REST · WebSocket · SQL · JWT · HTTP
6
6
 
7
- runtime dependencies: `jose`, `esbuild`, `cookie`, `showdown`
7
+ runtime dependencies: `jose`, `esbuild`, `cookie`, `marked`
8
8
 
9
9
  - **Web Components** using JSX — server-rendered and client-side
10
10
  - **static site generation** — `.html.tsx` handlers run against a live DB at build time
@@ -12,7 +12,7 @@ runtime dependencies: `jose`, `esbuild`, `cookie`, `showdown`
12
12
  - **database** — `sqlite3`, `node:sqlite`, `postgres` with migrations
13
13
  - **cluster** — multi-worker with shared cache and hot reload
14
14
  - **NODE:SEA** — compile to single binary, no Node.js required on target machine
15
- - **built-in editor**, **test runner**, **API doc generation**
15
+ - **test runner**, **API doc generation**
16
16
 
17
17
  ## packages
18
18
 
@@ -169,7 +169,6 @@ all files and folders are optional.
169
169
 
170
170
  ```
171
171
  miqro --service app/
172
- miqro --service app/ --editor
173
172
  ```
174
173
 
175
174
  ## http folder
@@ -899,8 +898,7 @@ const app = new Miqro({
899
898
  services: ["app/"],
900
899
  port: "3000",
901
900
  name: "myapp", // required in cluster mode
902
- hotreload: false,
903
- editor: false
901
+ hotreload: false
904
902
  });
905
903
 
906
904
  await app.inflate({ inflateDir: "build/" }); // generate static files
@@ -1023,7 +1021,6 @@ via env or `miqro.json`:
1023
1021
  ```
1024
1022
  miqro --service app/
1025
1023
  miqro --watch --service app/
1026
- miqro --editor --service app/
1027
1024
  miqro --test --service app/
1028
1025
  miqro --migrate-up --service app/
1029
1026
  miqro --migrate-down --service app/
@@ -1042,7 +1039,6 @@ flags:
1042
1039
  --migrate-down run migrations down
1043
1040
  --inflate generate static files
1044
1041
  --inflate-dir output directory (default: inflated/)
1045
- --editor run with built-in editor
1046
1042
  --generate-doc generate API documentation
1047
1043
  --generate-doc-out output file (default: API.md)
1048
1044
  --generate-doc-type MD | JSON | HTML (default: MD)
@@ -1,7 +1,6 @@
1
1
  // import { initTypes } from "../common/assets.js";
2
2
  import { existsSync, writeFileSync } from "node:fs";
3
- import { TEMPLATES } from "../../editor/common/templates.js";
4
- import { EXIT_CODES } from "../common/constants.js";
3
+ import { EXIT_CODES, TEMPLATES } from "../common/constants.js";
5
4
  import { installAsset } from "../common/assets.js";
6
5
  export async function installTypings(args, logger) {
7
6
  /*if (args.installTypes) {
@@ -6,7 +6,6 @@ interface MiqroJSON {
6
6
  name?: string;
7
7
  browser?: string | boolean;
8
8
  logFile?: string | boolean;
9
- editor?: boolean;
10
9
  etag?: boolean;
11
10
  https?: boolean;
12
11
  serverOptions?: ServerOptions;
@@ -46,7 +45,6 @@ export interface Arguments {
46
45
  inflateSEA: boolean;
47
46
  inflateDir: string;
48
47
  services: string[];
49
- editor: boolean;
50
48
  hotreload: boolean;
51
49
  watch: boolean;
52
50
  https: boolean;
@@ -26,7 +26,6 @@ const MiqroJSONSchema = {
26
26
  inflateDir: "string?",
27
27
  browser: "boolean?|string?",
28
28
  logFile: "boolean?|string?",
29
- editor: "boolean?",
30
29
  https: "boolean?",
31
30
  serverOptions: "any?",
32
31
  httpsRedirect: "number?",
@@ -84,7 +83,6 @@ export function parseArguments() {
84
83
  generateDocAll: null,
85
84
  generateDocOut: null,
86
85
  generateDocType: null,
87
- editor: null,
88
86
  inflateDir: null
89
87
  };
90
88
  const services = [];
@@ -395,22 +393,6 @@ export function parseArguments() {
395
393
  flags.inflateSEA = true;
396
394
  flags.inflate = true;
397
395
  continue;
398
- /*case "--install-types":
399
- if (flags.inflate !== null || flags.installTypes !== null) {
400
- console.error("bad arguments.");
401
- console.error(usage);
402
- process.exit(EXIT_CODES.BAD_ARGUMENTS);
403
- }
404
- flags.installTypes = true;
405
- continue;*/
406
- case "--editor":
407
- if (flags.editor !== null) {
408
- console.error("bad arguments.");
409
- console.error(usage);
410
- process.exit(EXIT_CODES.BAD_ARGUMENTS);
411
- }
412
- flags.editor = true;
413
- continue;
414
396
  case "--install-miqrojson":
415
397
  if (flags.installMiqroJSON !== null) {
416
398
  console.error("bad arguments. --install-miqrojson already set.");
@@ -611,18 +593,12 @@ export function parseArguments() {
611
593
  flags.browser = miqroRC.browser;
612
594
  }
613
595
  }
614
- if (flags.editor === null) {
615
- if (miqroRC.editor !== undefined) {
616
- flags.editor = miqroRC.editor;
617
- }
618
- }
619
596
  if (flags.inflateParallel === null) {
620
597
  if (miqroRC.inflateParallel !== undefined) {
621
598
  flags.inflateParallel = miqroRC.inflateParallel;
622
599
  }
623
600
  }
624
601
  }
625
- flags.editor = flags.editor ? flags.editor : false;
626
602
  if (services.length === 0 && (!flags.installTSConfig /* && !flags.installTypes*/ && !flags.installMiqroJSON)) {
627
603
  flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
628
604
  console.error(`bad arguments. missing --service argument`);
@@ -653,10 +629,6 @@ export function parseArguments() {
653
629
  console.error("bad arguments. cannot use --install with --inflate");
654
630
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
655
631
  }
656
- if (flags.inflate && flags.editor) {
657
- console.error("bad arguments. cannot use --inflate with --editor");
658
- process.exit(EXIT_CODES.BAD_ARGUMENTS);
659
- }
660
632
  if (flags.inflate && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON || flags.install)) {
661
633
  console.error("bad arguments. cannot use --inflate with --install, --install-tsconfig or --install-miqrojson");
662
634
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
@@ -677,23 +649,19 @@ export function parseArguments() {
677
649
  console.error("bad arguments. cannot use --inflate-only-assets with --inflate-sea");
678
650
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
679
651
  }
680
- if (flags.editor && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON)) {
681
- console.error("bad arguments. cannot use --editor with--install-types, --install-tsconfig or --install-miqrojson");
682
- process.exit(EXIT_CODES.BAD_ARGUMENTS);
683
- }
684
- if (flags.test && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
685
- console.error("bad arguments. cannot use --editor with --test");
652
+ if (flags.test && (flags.watch || flags.hotreload || flags.compile || flags.inflate)) {
653
+ console.error("bad arguments. cannot use --inflage with --test");
686
654
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
687
655
  }
688
- if (flags.migrateUp && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
656
+ if (flags.migrateUp && (flags.watch || flags.hotreload || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
689
657
  console.error("bad arguments. cannot use with --migrate-up");
690
658
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
691
659
  }
692
- if (flags.migrateDown && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
660
+ if (flags.migrateDown && (flags.watch || flags.hotreload || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
693
661
  console.error("bad arguments. cannot use with --migrate-down");
694
662
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
695
663
  }
696
- if (flags.generateDoc && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
664
+ if (flags.generateDoc && (flags.watch || flags.hotreload || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
697
665
  console.error("bad arguments. cannot use with --generate-doc");
698
666
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
699
667
  }
@@ -745,7 +713,6 @@ export function parseArguments() {
745
713
  generateDocOut: flags.generateDocOut ? resolve(process.cwd(), flags.generateDocOut) : generateDocType === "MD" ? resolve(process.cwd(), "API.md") : resolve(process.cwd(), "API.json"),
746
714
  generateDocType,
747
715
  services,
748
- editor: flags.editor ? true : false,
749
716
  https: flags.https ? true : false,
750
717
  httpsRedirect: flags.httpsRedirect ? flags.httpsRedirect : undefined,
751
718
  serverOptions: flags.serverOptions
@@ -8,7 +8,7 @@ import { initESBuild } from "./esbuild.js";
8
8
  import { mkdirASync, unlinkASync, writeFileASync } from "./fs.js";
9
9
  // import { initJSXJS } from "./jsx.js";
10
10
  //const require = createRequire(import.meta.url);
11
- export const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..") : null;
11
+ export const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..") : null;
12
12
  const ASSETS_ROUTER = {
13
13
  "lib.cjs": "build/lib.cjs",
14
14
  "version.tag": "sea/version.tag",
@@ -10,3 +10,14 @@ export declare const CLEAR_JSX_CACHE: boolean;
10
10
  export declare const EDITOR_CONFIG_KEY = "$$editor$$";
11
11
  export declare const HOT_RELOAD_PATH = "/hot-reload";
12
12
  export declare const HOT_RELOAD_SCRIPT_PATH = "/hot-reload.js";
13
+ export declare const TEMPLATES: {
14
+ [name: string]: {
15
+ displayName: string;
16
+ template?: ((filename: string, httpPath: string) => string);
17
+ httpSufix?: string;
18
+ sufix?: string;
19
+ prefix?: string;
20
+ language: string;
21
+ filename?: string;
22
+ };
23
+ };
@@ -1,3 +1,17 @@
1
+ export const EXIT_CODES = {
2
+ BAD_ARGUMENTS: 10,
3
+ NORMAL_EXIT: 0,
4
+ GLOBALS_ALTERED: 80,
5
+ ABNORMAL: 98,
6
+ ABNORMAL_UNCONTROLLED: 99,
7
+ TEST_FAILED: 30,
8
+ };
9
+ export const CLEAR_JSX_CACHE = (process.env["CLEAR_JSX_CACHE"] !== undefined ? process.env["CLEAR_JSX_CACHE"] : "1") === "1";
10
+ export const EDITOR_CONFIG_KEY = "$$editor$$";
11
+ export const HOT_RELOAD_PATH = "/hot-reload";
12
+ export const HOT_RELOAD_SCRIPT_PATH = "/hot-reload.js";
13
+ //export const SERVER_IDENTIFIER = cluster.isPrimary ? "SERVER" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}` : "WORKER";
14
+ //export const DB_IDENTIFIER = cluster.isPrimary ? "DATABASE" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}_DATABASE` : "WORKER_DATABASE";
1
15
  export const TEMPLATES = {
2
16
  EMPTY: {
3
17
  displayName: "empty file",
@@ -41,7 +41,6 @@ export async function initESBuild(logger) {
41
41
  "pg"
42
42
  ];*/
43
43
  export const NODEJS_EXTERNAL = [
44
- "sqlite3",
45
44
  "pg",
46
45
  "node:*"
47
46
  ];
@@ -0,0 +1,3 @@
1
+ export declare const BIN_NAME = "miqro";
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--disable-etag\n\tuse to disable etag generation by default. each route can still enable this.\n--enable-etag\n\tuse to enable etag generation by default. each route can still disable this. ( by default etag is enabled )\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 into a directory using esbuild.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\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--no-build\n\tdisables calling esbuild during imports in runtime. Notice that to use jsx you will need to run tsc or esbuild on your jsx files to transpile them to js.\n--no-minify\n\tdisables calling minifing min.js files.\n--inflate-only-assets\n\tinflates ONLY the application assets. must be used with --inflate.\n--inflate-flat\n\tinflates files into the inflate-dir directly.\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--install\n\tcreates a node_modules folder from binary cache (only available in sea binary).\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";
@@ -24,7 +24,6 @@ export const help = `
24
24
  --migrate-down\n\tmigrations down.
25
25
  --inflate\n\tinflates the application into a directory using esbuild.
26
26
  --inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.
27
- --editor\n\truns the application with a built-in editor.
28
27
  --generate-doc\n\tgenerates a documentation for the api endpoints of the service.
29
28
  --generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.
30
29
  --generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.
@@ -61,6 +61,8 @@ export async function inflateAppForSea(logger, inflateDir, services, port) {
61
61
  writeFile(logger, join(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
62
62
  writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createLogProviderOptions, createServerInterface, ServerRequestHandler, WebSocketManager, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
63
63
 
64
+ const pg = require("pg");
65
+
64
66
  async function main() {
65
67
  const PORT = "${PORT}";
66
68
 
@@ -131,6 +133,7 @@ main().catch(e=>console.error(e));
131
133
  jsxFactory: "JSX.createElement",
132
134
  jsxFragment: "JSX.Fragment",
133
135
  platform: "node",
136
+ external: ["node:*"],
134
137
  outfile: join(inflateDir, "sea", "app.bundle.cjs")
135
138
  });
136
139
  const miqroRCPath = getMiqroJSONPath();
@@ -0,0 +1 @@
1
+ export declare function inflateMDString2HTML(text: string): Promise<string>;
@@ -0,0 +1,4 @@
1
+ import { marked } from "marked";
2
+ export async function inflateMDString2HTML(text) {
3
+ return marked.parse(text, {});
4
+ }
@@ -6,13 +6,12 @@ import { importHTMLModule, importAPIRoute, inflateJSX, importJSONModule, jsx2HTM
6
6
  import { createNodeRuntime } from "@miqro/jsx-node";
7
7
  import { getHotReloadScript } from "../services/hot-reload.js";
8
8
  import { cwd } from "node:process";
9
- // import { assertGlobalTampered } from "../services/globals.js";
10
9
  import { getHTTPRouterPath, getStaticFilesPath } from "../common/paths.js";
11
10
  import { setupCORS } from "./setup-cors.js";
12
11
  import { setupAUTH } from "./setup-auth.js";
13
12
  import { getRoutes } from "../services/utils/get-route.js";
14
13
  import { describeFilePath, mkdirASync, writeFileASync } from "../common/fs.js";
15
- import { inflateMD2HTML } from "./md.js";
14
+ import { inflateMDString2HTML } from "./md.js";
16
15
  import { setupMiddleware } from "./setup-middleware.js";
17
16
  import { setupError } from "./setup-error.js";
18
17
  export async function setupHTTPRouter(importOptions, inflateOptions, server, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors, inflateParallel) {
@@ -387,7 +386,7 @@ async function createRouterFromDirectory(importOptions, inflateJSXOptions, serve
387
386
  case ".md": {
388
387
  switch (file.subExt) {
389
388
  case ".html": {
390
- const code = await inflateMD2HTML(file.filePath, logger);
389
+ const code = await inflateMDString2HTML(readFileSync(file.filePath).toString());
391
390
  const contentType = CONTENT_TYPE_MAP[".html"];
392
391
  const path = join("/", dirname(relative(dir, file.filePath)), file.name);
393
392
  routeFileMap[file.filePath] = {
@@ -15,7 +15,6 @@ async function main(args) {
15
15
  }
16
16
  else {
17
17
  const app = new Miqro({
18
- editor: args.editor,
19
18
  etag: args.etag,
20
19
  name: args.name ? args.name : undefined,
21
20
  port: args.test ? TEST_SOCKET : args.port,
@@ -17,7 +17,6 @@ export interface MiqroOptions extends ImportJSXFileOptions {
17
17
  logger?: Logger;
18
18
  logProviderOptions?: LogProviderOptions;
19
19
  services: string[];
20
- editor: boolean;
21
20
  port: string;
22
21
  browser?: string | boolean;
23
22
  logFile?: string | boolean;
@@ -5,11 +5,7 @@ import { WebSocketManager } from "./utils/websocketmanager.js";
5
5
  import { DBManager } from "./utils/db-manager.js";
6
6
  import { inflateApp } from "../inflate/inflate.js";
7
7
  import { setupServerConfig } from "../inflate/setup-server-config.js";
8
- import { BASEEDITOR_PATH, LOG_SOCKET_PATH, LOG_WRITE_EVENT } from "../../editor/common/constants.js";
9
- import editorWSConfig from "../../editor/ws.js";
10
- import editorServerConfig from "../../editor/server.js";
11
8
  import { ClusterCache } from "./utils/cluster-cache.js";
12
- import { createEditorRouter } from "./editor.js";
13
9
  import { EDITOR_CONFIG_KEY, HOT_RELOAD_PATH, HOT_RELOAD_SCRIPT_PATH } from "../common/constants.js";
14
10
  import { watchAndServer } from "../common/watch.js";
15
11
  import { LocalCache } from "./utils/cache.js";
@@ -21,7 +17,6 @@ import { getServicePath } from "../common/paths.js";
21
17
  import { createServerInterface } from "./utils/server-interface.js";
22
18
  import { getPORT, importMiqroJSON } from "../common/arguments.js";
23
19
  import { createLogProviderOptions } from "./utils/log-transport.js";
24
- import { createAdminInterface } from "./utils/admin-interface.js";
25
20
  import { dirname, join, relative, resolve } from "node:path";
26
21
  import { cwd } from "node:process";
27
22
  import { HOT_RELOAD_JS_SCRIPT } from "./hot-reload.js";
@@ -48,7 +43,6 @@ export class Miqro {
48
43
  this.options = {
49
44
  noMinify: false,
50
45
  etag: true,
51
- editor: false,
52
46
  name: "server",
53
47
  noBuild: false,
54
48
  port: getPORT(),
@@ -56,7 +50,6 @@ export class Miqro {
56
50
  ...(options ? options : {})
57
51
  };
58
52
  const loggerOptions = createLogProviderOptions(this);
59
- loggerOptions.transports.push(createEditorLoggerTransport(this));
60
53
  this.loggerProvider = new LogProvider(loggerOptions);
61
54
  //if (!this.options.logger) {
62
55
  const SERVER_IDENTIFIER = cluster.isPrimary ?
@@ -97,8 +90,7 @@ export class Miqro {
97
90
  this.webSocketManager = new WebSocketManager({
98
91
  logger: this.logger,
99
92
  loggerProvider: this.loggerProvider,
100
- name: `MiqroApplicationWebsocketManager[${this.options.name}]`,
101
- avoidLogSocket: this.options.editor
93
+ name: `MiqroApplicationWebsocketManager[${this.options.name}]`
102
94
  });
103
95
  this.listener = this.listener.bind(this);
104
96
  //this.requestLoggerFactory = this.requestLoggerFactory.bind(this);
@@ -118,7 +110,6 @@ export class Miqro {
118
110
  port: this.options.port
119
111
  });
120
112
  this.serverRequestHandler = ServerRequestHandler(this.serverInterface);
121
- this.adminInterface = createAdminInterface(this);
122
113
  this.webSocketManager.adminInterface = this.adminInterface;
123
114
  setupExitHandlers(this);
124
115
  }
@@ -272,15 +263,6 @@ export class Miqro {
272
263
  await Promise.all(dbList.map(db => this.dbManager.setupDB(db.dbConfig)));
273
264
  /* setup server config before inflate app router and ws and bs for preload*/
274
265
  const { errors: serviceConfigErrors, serverConfigMap } = await this.loadServerConfig(options);
275
- // editor WSConfig must be put a head of the service WSConfig to avoid LOG_SOCKET replacement
276
- if (this.options.editor) {
277
- this.logger?.debug("setting up editor on %s", BASEEDITOR_PATH);
278
- const editorRouter = await createEditorRouter(this.adminInterface);
279
- router.use(editorRouter);
280
- this.logger?.debug("setting up log websocket on [%s]", LOG_SOCKET_PATH);
281
- wsConfigList.push(editorWSConfig);
282
- serverConfigMap[EDITOR_CONFIG_KEY] = editorServerConfig;
283
- }
284
266
  if (this.options?.hotreload /* && !options?.inflateTests*/) {
285
267
  this.logger?.debug("setting up websocket on [%s]", HOT_RELOAD_PATH);
286
268
  wsConfigList.push({
@@ -562,11 +544,6 @@ function reloadInflatedRouter(app) {
562
544
  app.logger?.debug("load running server with new routes");
563
545
  app.server.use(app.serverRequestHandler);
564
546
  app.server.use(LoggerHandler());
565
- if (app.options.editor) {
566
- app.server.use(async (req, res) => {
567
- res.setHeader("x-uuid", req.uuid);
568
- });
569
- }
570
547
  app.server.use(app.inflated.router);
571
548
  }
572
549
  async function notifiyServerConfig(logger, serverInterface, adminInterface, serverConfigMap, method) {
@@ -610,32 +587,3 @@ export function notifiyServerConfigSync(app, method) {
610
587
  });
611
588
  }
612
589
  }
613
- function createEditorLoggerTransport(app) {
614
- return {
615
- level: "trace",
616
- write: async (args) => {
617
- try {
618
- if (app.options.editor) {
619
- try {
620
- const ws = app.webSocketManager.getWS(LOG_SOCKET_PATH);
621
- if (ws) {
622
- //console.log("\n\n" + process.pid + " broadcasting " + LOG_SOCKET_PATH + "\n\n\n")
623
- await ws.broadcast(JSON.stringify({
624
- type: LOG_WRITE_EVENT,
625
- level: args.level,
626
- identifier: args.identifier,
627
- out: args.out
628
- }));
629
- }
630
- }
631
- catch (e) {
632
- console.error(e);
633
- }
634
- }
635
- }
636
- catch (e) {
637
- console.error(e);
638
- }
639
- }
640
- };
641
- }
@@ -1,18 +1,33 @@
1
1
  import cluster from "node:cluster";
2
2
  import { execSync } from "node:child_process";
3
- import { HTMLEncode } from "../../../editor/common/html-encode.js";
4
- import { inflateMD2HTML } from "../../inflate/md.js";
5
3
  import { Parser } from "@miqro/parser";
6
4
  import { ClusterCache } from "./cluster-cache.js";
7
5
  import { LocalCache } from "./cache.js";
8
6
  import { middleware } from "./middleware.js";
9
7
  import { jwt } from "./jwt.js";
8
+ import { inflateMDString2HTML } from "../../inflate/md.js";
9
+ import { jsx2HTML } from "../../lib.js";
10
+ function HTMLEncode(str) {
11
+ let i = str.length;
12
+ const aRet = [];
13
+ while (i--) {
14
+ const iC = str[i].charCodeAt(0);
15
+ if (iC < 65 || iC > 127 || (iC > 90 && iC < 97)) {
16
+ aRet[i] = '&#' + iC + ';';
17
+ }
18
+ else {
19
+ aRet[i] = str[i];
20
+ }
21
+ }
22
+ return aRet.join('');
23
+ }
10
24
  export function createServerInterface(options) {
11
25
  // initGlobals();
12
26
  return Object.freeze({
13
27
  middleware,
28
+ getHTML: jsx2HTML,
14
29
  encodeHTML: HTMLEncode,
15
- inflateMDtoHTML: inflateMD2HTML,
30
+ inflateMDtoHTML: inflateMDString2HTML,
16
31
  newParser() {
17
32
  return new Parser();
18
33
  },
@@ -7,7 +7,6 @@ export interface WebSocketManagerOptions {
7
7
  logger?: Logger | Console;
8
8
  loggerProvider?: LogProvider;
9
9
  name?: string;
10
- avoidLogSocket?: boolean;
11
10
  }
12
11
  export declare class WebSocketManager {
13
12
  runningGlobalWSMap: Map<string, ClusterWebSocketServer2>;
@@ -1,4 +1,3 @@
1
- import { LOG_SOCKET_PATH } from "../../../editor/common/constants.js";
2
1
  import { ClusterWebSocketServer2 } from "./cluster-ws.js";
3
2
  export class WebSocketManager {
4
3
  runningGlobalWSMap = new Map();
@@ -12,7 +11,6 @@ export class WebSocketManager {
12
11
  this.logger = options && options.logger ? options.logger : null;
13
12
  this.name = options && options.name ? options.name : "WebSocketManager";
14
13
  this.loggerProvider = options && options.loggerProvider;
15
- this.avoidLogSocket = options && options.avoidLogSocket ? options.avoidLogSocket : false;
16
14
  }
17
15
  deleteWS(path) {
18
16
  const ws = this.runningGlobalWSMap.get(path);
@@ -46,22 +44,18 @@ export class WebSocketManager {
46
44
  }
47
45
  replaceALLWSBuLOGSocket(list) {
48
46
  for (const path of this.runningGlobalWSMap.keys()) {
49
- if (path !== LOG_SOCKET_PATH || !this.avoidLogSocket) {
50
- this.deleteWS(path);
51
- }
47
+ this.deleteWS(path);
52
48
  }
53
49
  for (const wsConfig of list) {
54
50
  if (!wsConfig.disabled) {
55
- if (wsConfig.path !== LOG_SOCKET_PATH || !this.avoidLogSocket) {
56
- if (this.runningGlobalWSMap.has(wsConfig.path)) {
57
- throw new Error(`ws on path ${wsConfig.path} already setup!`);
58
- }
59
- this.logger?.debug("setting up websocket on [%s]", wsConfig.path);
60
- const identifier = wsConfig.path.replaceAll("/", "_").toUpperCase();
61
- const logger = this.loggerProvider && identifier.length >= 0 ? this.loggerProvider.getLogger(identifier.substring(identifier.charAt(0) === "_" ? 1 : 0)) : this.logger;
62
- const server = new ClusterWebSocketServer2(this.name + wsConfig.path, wsConfig.path, logger, wsConfig);
63
- this.runningGlobalWSMap.set(wsConfig.path, server);
51
+ if (this.runningGlobalWSMap.has(wsConfig.path)) {
52
+ throw new Error(`ws on path ${wsConfig.path} already setup!`);
64
53
  }
54
+ this.logger?.debug("setting up websocket on [%s]", wsConfig.path);
55
+ const identifier = wsConfig.path.replaceAll("/", "_").toUpperCase();
56
+ const logger = this.loggerProvider && identifier.length >= 0 ? this.loggerProvider.getLogger(identifier.substring(identifier.charAt(0) === "_" ? 1 : 0)) : this.logger;
57
+ const server = new ClusterWebSocketServer2(this.name + wsConfig.path, wsConfig.path, logger, wsConfig);
58
+ this.runningGlobalWSMap.set(wsConfig.path, server);
65
59
  }
66
60
  }
67
61
  }
@@ -99,9 +93,7 @@ export class WebSocketManager {
99
93
  disconnectAllButLOGSocket() {
100
94
  try {
101
95
  for (const wsPath of this.runningGlobalWSMap.keys()) {
102
- if (wsPath !== LOG_SOCKET_PATH || !this.avoidLogSocket) {
103
- this.disconnectAllFrom(wsPath);
104
- }
96
+ this.disconnectAllFrom(wsPath);
105
97
  }
106
98
  }
107
99
  catch (e) {
@@ -124,9 +116,7 @@ export class WebSocketManager {
124
116
  try {
125
117
  const wsServer = this.getWS(req.path);
126
118
  if (wsServer) {
127
- if (LOG_SOCKET_PATH === req.path) {
128
- req.editor = this.adminInterface;
129
- }
119
+ req.editor = this.adminInterface;
130
120
  const ret = wsServer.onUpgrade(req, socket, head);
131
121
  delete req.editor;
132
122
  return ret;
@@ -75,8 +75,9 @@ export interface JWTInterface {
75
75
  decode: <PayloadType = JWTPayload>(jwt: string) => PayloadType & JWTPayload;
76
76
  }
77
77
  export interface ServerGlobal {
78
+ getHTML: (out: JSX.Element, runtime?: Runtime) => string;
78
79
  encodeHTML: (str: string) => string;
79
- inflateMDtoHTML: (str: string) => string;
80
+ inflateMDtoHTML: (str: string) => Promise<string>;
80
81
  middleware: {
81
82
  buffer: typeof ReadBuffer;
82
83
  url: typeof URLEncodedParser;