miqro 6.0.8 → 6.0.10

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 (70) hide show
  1. package/build/editor.bundle.js +24 -7
  2. package/build/esm/editor/common/log-socket.d.ts +3 -1
  3. package/build/esm/editor/common/log-socket.js +4 -1
  4. package/build/esm/editor/common/log-socket.js.map +1 -1
  5. package/build/esm/editor/components/editor.js +4 -1
  6. package/build/esm/editor/components/editor.js.map +1 -1
  7. package/build/esm/editor/components/file-browser.js +28 -23
  8. package/build/esm/editor/components/file-browser.js.map +1 -1
  9. package/build/esm/editor/components/file-editor-toolbar.js +4 -4
  10. package/build/esm/editor/components/file-editor-toolbar.js.map +1 -1
  11. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +2 -1
  12. package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +1 -1
  13. package/build/esm/editor/http/admin/editor/index.api.js +1 -1
  14. package/build/esm/src/common/arguments.js +12 -7
  15. package/build/esm/src/common/arguments.js.map +1 -1
  16. package/build/esm/src/common/assets.d.ts +1 -0
  17. package/build/esm/src/common/assets.js +1 -1
  18. package/build/esm/src/common/assets.js.map +1 -1
  19. package/build/esm/src/common/jsx.d.ts +3 -3
  20. package/build/esm/src/common/jsx.js +36 -22
  21. package/build/esm/src/common/jsx.js.map +1 -1
  22. package/build/esm/src/common/watch.d.ts +3 -1
  23. package/build/esm/src/common/watch.js +5 -0
  24. package/build/esm/src/common/watch.js.map +1 -1
  25. package/build/esm/src/services/app.d.ts +6 -1
  26. package/build/esm/src/services/app.js +36 -117
  27. package/build/esm/src/services/app.js.map +1 -1
  28. package/build/esm/src/services/utils/admin-interface.d.ts +3 -0
  29. package/build/esm/src/services/utils/admin-interface.js +34 -0
  30. package/build/esm/src/services/utils/admin-interface.js.map +1 -0
  31. package/build/esm/src/services/utils/cluster-cache.d.ts +2 -1
  32. package/build/esm/src/services/utils/cluster-cache.js +5 -1
  33. package/build/esm/src/services/utils/cluster-cache.js.map +1 -1
  34. package/build/esm/src/services/utils/cluster-ws.d.ts +1 -0
  35. package/build/esm/src/services/utils/cluster-ws.js +4 -0
  36. package/build/esm/src/services/utils/cluster-ws.js.map +1 -1
  37. package/build/esm/src/services/utils/db-manager.d.ts +1 -0
  38. package/build/esm/src/services/utils/db-manager.js +12 -0
  39. package/build/esm/src/services/utils/db-manager.js.map +1 -1
  40. package/build/esm/src/services/utils/log-transport.d.ts +7 -0
  41. package/build/esm/src/services/utils/log-transport.js +75 -0
  42. package/build/esm/src/services/utils/log-transport.js.map +1 -0
  43. package/build/esm/src/services/utils/websocketmanager.d.ts +1 -0
  44. package/build/esm/src/services/utils/websocketmanager.js +11 -3
  45. package/build/esm/src/services/utils/websocketmanager.js.map +1 -1
  46. package/build/lib.cjs +204 -129
  47. package/editor/common/log-socket.tsx +4 -1
  48. package/editor/components/editor.tsx +4 -1
  49. package/editor/components/file-browser.tsx +48 -35
  50. package/editor/components/file-editor-toolbar.tsx +4 -0
  51. package/editor/http/admin/editor/api/server/reload.api.ts +2 -1
  52. package/editor/http/admin/editor/index.api.tsx +4 -4
  53. package/package.json +9 -7
  54. package/sea/compile.sh +8 -5
  55. package/sea/install-esbuild.sh +1 -1
  56. package/sea/install-nodejs.sh +1 -1
  57. package/sea/node.version.tag +1 -1
  58. package/sea/version.tag.js +11 -0
  59. package/src/common/arguments.ts +11 -7
  60. package/src/common/assets.ts +1 -1
  61. package/src/common/jsx.ts +35 -23
  62. package/src/common/watch.ts +5 -0
  63. package/src/services/app.ts +37 -115
  64. package/src/services/utils/admin-interface.ts +37 -0
  65. package/src/services/utils/cluster-cache.ts +6 -1
  66. package/src/services/utils/cluster-ws.ts +6 -1
  67. package/src/services/utils/db-manager.ts +13 -0
  68. package/src/services/utils/log-transport.ts +75 -0
  69. package/src/services/utils/websocketmanager.ts +13 -3
  70. package/package.json--OLD +0 -36
@@ -1,5 +1,5 @@
1
1
  import cluster from "node:cluster";
2
- import { App, Router, Logger, LoggerHandler, ConsoleTransport, FileTransport, LogLevel, LoggerTransportWriteArgs } from "@miqro/core";
2
+ import { App, Router, Logger, LoggerHandler } from "@miqro/core";
3
3
  import { migration } from "@miqro/query";
4
4
  import { WebSocketManager } from "./utils/websocketmanager.js";
5
5
  import { DBManager } from "./utils/db-manager.js";
@@ -8,7 +8,7 @@ import { InflateError } from "../common/jsx.js";
8
8
  import { DBConfig, MigrateOptions, ServerInterface, ServerRequest, WSConfig } from "../types.js";
9
9
  import { RouteFileMap } from "../inflate/setup-http.js";
10
10
  import { ServerConfigMap, setupServerConfig } from "../inflate/setup-server-config.js";
11
- import { BASEEDITOR_PATH, LOG_SOCKET_PATH, LOG_WRITE_EVENT } from "../../editor/common/constants.js";
11
+ import { BASEEDITOR_PATH, LOG_SOCKET_PATH } from "../../editor/common/constants.js";
12
12
  import editorWSConfig from "../../editor/ws.js";
13
13
  import editorServerConfig from "../../editor/server.js";
14
14
 
@@ -19,16 +19,16 @@ import { watchAndServer } from "../common/watch.js";
19
19
  import { LocalCache } from "./utils/cache.js";
20
20
  import { initGlobals } from "./globals.js";
21
21
  import { EditorAdminInterface } from "../../editor/common/admin-interface.js";
22
- import { getHotReloadScript } from "./hot-reload.js";
23
22
  import { LogProvider, LogProviderOptions } from "./utils/log.js";
24
23
  import { initAssets } from "../common/assets.js";
25
24
  import { setupExitHandlers } from "../common/exit.js";
26
25
  import { inflateDBConfig, inflateDBMigrations, MigrationModule } from "../inflate/setup-db.js";
27
26
  import { getServicePath } from "../common/paths.js";
28
27
  import { LogConfigMap } from "../inflate/setup-log.js";
29
- import { format } from "node:util";
30
28
  import { ServerInterfaceImpl } from "./utils/server-interface.js";
31
29
  import { getPORT } from "../common/arguments.js";
30
+ import { createLogProviderOptions } from "./utils/log-transport.js";
31
+ import { createAdminInterface } from "./utils/admin-interface.js";
32
32
 
33
33
  export interface MiqroOptions {
34
34
  name: string;
@@ -69,6 +69,7 @@ export interface MiqroClusterMessage {
69
69
  }
70
70
 
71
71
  export class Miqro {
72
+ public status: "stopped" | "starting" | "stopping" | "reloading" | "started" = "stopped";
72
73
  public options: MiqroOptions;
73
74
  public server?: App | null = null;
74
75
  public cache: ClusterCache;
@@ -85,6 +86,7 @@ export class Miqro {
85
86
  public logger?: Logger;
86
87
  public loggerProvider: LogProvider;
87
88
  public static initAssetsPromise: Promise<any> | null = null;
89
+ public watcher?: { stopWatch: () => void; };
88
90
 
89
91
  constructor(options?: Partial<MiqroOptions>) {
90
92
  this.options = {
@@ -94,72 +96,7 @@ export class Miqro {
94
96
  services: [],
95
97
  ...(options ? options : {})
96
98
  };
97
- const defaultConsole = ConsoleTransport();
98
- const defaultFile = FileTransport();
99
- const defaultWrite = async (args: LoggerTransportWriteArgs, level?: LogLevel) => {
100
- try {
101
- const serviceNamesWithLogConfigReplaceConsole = level === undefined && this.inflated ?
102
- Object.keys(this.inflated.logConfigMap).filter(serviceName => this.inflated.logConfigMap[serviceName].replaceConsoleTransport) : [];
103
- const serviceNamesWithLogConfigReplaceFile = level === undefined && this.inflated ?
104
- Object.keys(this.inflated.logConfigMap).filter(serviceName => this.inflated.logConfigMap[serviceName].replaceFileTransport) : [];
105
- await Promise.allSettled((level === undefined ?
106
- [
107
- level === undefined && serviceNamesWithLogConfigReplaceConsole.length === 0 ?
108
- defaultConsole.write(args) : Promise.resolve(),
109
- level === undefined && serviceNamesWithLogConfigReplaceFile.length === 0 ?
110
- defaultFile.write(args) : Promise.resolve()
111
- ] : []).concat(this.inflated ?
112
- Object.keys(this.inflated.logConfigMap).map(serviceName => this.inflated.logConfigMap[serviceName]).filter(c => c.level === level).map(c => c.write(args)) : []
113
- ));
114
- } catch (e) {
115
- console.error(e);
116
- }
117
- }
118
- this.loggerProvider = new LogProvider({
119
- name: this.options.name,
120
- formatter: ({ identifier, level, message, optionalParams }) => format(`${new Date().toISOString()} PID[${process.pid}] ` +
121
- `${identifier ? `[${identifier}] ` : ""}` +
122
- `${level !== "info" ? (level === "error" || level === "warn" ? `[${level.toUpperCase()}] ` : `[${level}] `) : ""}` +
123
- `${message}`, ...optionalParams),
124
- transports: [
125
- ...(([undefined, "error", "warn", "info", "debug", "trace"] as LogLevel[]).map(level => {
126
- return level ? {
127
- level,
128
- write: async (args) => {
129
- await defaultWrite(args, level);
130
- }
131
- } : {
132
- write: async (args) => {
133
- await defaultWrite(args, undefined);
134
- }
135
- }
136
- })), {
137
- level: "trace",
138
- write: async (args) => {
139
- try {
140
- if (this.options.editor) {
141
- try {
142
- const ws = this.webSocketManager.getWS(LOG_SOCKET_PATH);
143
- if (ws) {
144
- //console.log("\n\n" + process.pid + " broadcasting " + LOG_SOCKET_PATH + "\n\n\n")
145
- await ws.broadcast(JSON.stringify({
146
- type: LOG_WRITE_EVENT,
147
- level: args.level,
148
- identifier: args.identifier,
149
- out: args.out
150
- }));
151
- }
152
- } catch (e) {
153
- console.error(e);
154
- }
155
- }
156
- } catch (e) {
157
- console.error(e);
158
- }
159
- }
160
- }],
161
- ...(this.options.logProviderOptions ? this.options.logProviderOptions : {})
162
- });
99
+ this.loggerProvider = new LogProvider(createLogProviderOptions(this));
163
100
  //if (!this.options.logger) {
164
101
  const SERVER_IDENTIFIER = cluster.isPrimary ?
165
102
  "" :
@@ -220,59 +157,30 @@ export class Miqro {
220
157
  port: this.options.port
221
158
  });
222
159
  this.serverRequestHandler = ServerRequestHandler(this.serverInterface);
223
- const adminCache = new ClusterCache("EditorCache[" + this.options.name + "]");
224
-
225
- this.adminInterface = {
226
- getCache: () => adminCache,
227
- stop: () => this.stop(),
228
- restart: () => this.restart(),
229
- reload: () => this.reload(),
230
- getHotReloadHTML: getHotReloadScript,
231
- getMigrations: () => {
232
- if (this.inflated) {
233
- const ret: MigrationModule[] = [];
234
- for (const db of this.inflated.dbList) {
235
- for (const m of db.migrations) {
236
- ret.push(m);
237
- }
238
- }
239
- return ret;
240
- }
241
- return [];
242
- },
243
- getServices: () => {
244
- return this.options.services;
245
- },
246
- getRouteFileMap: () => {
247
- return this.inflated ? this.inflated.fileMap : {};
248
- },
249
- getInflateErrors: () => {
250
- return this.inflated ? this.inflated.errors : [];
251
- }/*,
252
- inflateJSX: async function inflateJSX(path, minify: boolean = true) {
253
- return realInflateJSX(path, {
254
- embemedJSX: true,
255
- minify,
256
- useExport: true
257
- });
258
- }*/
259
- };
160
+
161
+ this.adminInterface = createAdminInterface(this);
260
162
 
261
163
  setupExitHandlers(this);
164
+ }
262
165
 
166
+ public connect() {
263
167
  if (process.send) {
168
+ process.removeListener("message", this.listener);
264
169
  process.on("message", this.listener);
265
170
  }
171
+ this.cache.connect();
172
+ (this.adminInterface?.getCache() as ClusterCache)?.connect();
266
173
  }
267
174
 
268
- public dispose() {
175
+ public disconnect() {
269
176
  if (this.server !== null) {
270
177
  throw new Error("already running! call stop() first");
271
178
  }
272
179
  if (process.send) {
273
180
  process.removeListener("message", this.listener);
274
181
  }
275
- this.cache.dispose();
182
+ this.cache.disconnect();
183
+ (this.adminInterface?.getCache() as ClusterCache)?.disconnect();
276
184
  this.webSocketManager.disconnectAll();
277
185
  this.dbManager.closeAll();
278
186
  }
@@ -482,7 +390,7 @@ export class Miqro {
482
390
  }
483
391
 
484
392
  public async start() {
485
- if (this.server !== null) {
393
+ if (this.server !== null || this.status !== "stopped") {
486
394
  throw new Error("cannot start app already running.");
487
395
  }
488
396
  if (!this.isInflated()) {
@@ -491,7 +399,11 @@ export class Miqro {
491
399
  //this.logger?.debug("starting");
492
400
  this.logger?.debug("\t\t==start==");
493
401
 
402
+ //this.disconnect();
403
+ this.status = "starting";
494
404
  this.server = undefined;
405
+ this.connect();
406
+ await this.dbManager.connectAll();
495
407
  this.server = new App({
496
408
  onUpgrade: (req: ServerRequest, socket, head) => {
497
409
  req.server = this.serverInterface;
@@ -531,20 +443,27 @@ export class Miqro {
531
443
  await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "start");
532
444
 
533
445
  if (this.options.hotreload && (cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
534
- await watchAndServer(this);
446
+ this.watcher = await watchAndServer(this);
535
447
  }
536
448
 
537
449
  this.logger?.debug("\t\t==start done==");
538
450
 
451
+ this.status = "started";
539
452
  return this.inflated.errors && this.inflated.errors.length > 0 ? this.inflated.errors : null;
540
453
  }
541
454
 
542
455
  public async stop() {
543
- if (!this.server || !this.inflated) {
456
+ if (!this.server || !this.inflated || this.status !== "started") {
544
457
  throw new Error("cannot stop server not running");
545
458
  }
459
+ this.status = "stopping";
460
+ if (this.watcher) {
461
+ this.watcher.stopWatch();
462
+ this.watcher = null;
463
+ }
546
464
  const server = this.server;
547
465
  this.server = null;
466
+ this.disconnect();
548
467
  this.logger?.debug("\t\t==stop==");
549
468
  this.logger?.debug("clear running server routes");
550
469
  server.clear();
@@ -555,14 +474,15 @@ export class Miqro {
555
474
  //server.ws.disconnectAll();
556
475
  this.logger?.debug("stopping");
557
476
  const p = server.close();
558
- notifiyServerConfigSync(this, "stop");
559
477
  await p;
560
478
  await pD;
479
+ this.status = "stopped";
480
+ notifiyServerConfigSync(this, "stop");
561
481
  this.logger?.debug("\t\t==stop done==");
562
482
  }
563
483
 
564
484
  public async restart(avoidSend?: boolean) {
565
- if (!this.server || !this.inflated) {
485
+ if (!this.server || !this.inflated || this.status !== "started") {
566
486
  throw new Error("cannot start server not running");
567
487
  }
568
488
  this.logger?.debug("\t\t==restart==");
@@ -581,9 +501,10 @@ export class Miqro {
581
501
  }
582
502
 
583
503
  public async reload(avoidSend?: boolean) {
584
- if (!this.server || !this.inflated) {
504
+ if (!this.server || !this.inflated || this.status !== "started") {
585
505
  throw new Error("cannot reload server not running");
586
506
  }
507
+ this.status = "reloading";
587
508
  /*this.logger?.log("====================");
588
509
  this.logger?.log("=======reload=======");
589
510
  this.logger?.log("====================");*/
@@ -642,6 +563,7 @@ export class Miqro {
642
563
  this.logger?.debug("\t\t==reload done==");
643
564
  //this.logger?.log("=====================");
644
565
 
566
+ this.status = "started";
645
567
  return this.inflated.errors && this.inflated.errors.length > 0 ? this.inflated.errors : null;
646
568
 
647
569
  }
@@ -0,0 +1,37 @@
1
+ import { EditorAdminInterface } from "../../../editor/common/admin-interface.js";
2
+ import { MigrationModule } from "../../inflate/setup-db.js";
3
+ import { Miqro } from "../app.js";
4
+ import { getHotReloadScript } from "../hot-reload.js";
5
+ import { ClusterCache } from "./cluster-cache.js";
6
+
7
+ export function createAdminInterface(app: Miqro): EditorAdminInterface {
8
+ const adminCache = new ClusterCache("EditorCache[" + app.options.name + "]");
9
+ return {
10
+ getCache: () => adminCache,
11
+ stop: () => app.stop(),
12
+ restart: () => app.restart(),
13
+ reload: () => app.reload(),
14
+ getHotReloadHTML: getHotReloadScript,
15
+ getMigrations: () => {
16
+ if (app.inflated) {
17
+ const ret: MigrationModule[] = [];
18
+ for (const db of app.inflated.dbList) {
19
+ for (const m of db.migrations) {
20
+ ret.push(m);
21
+ }
22
+ }
23
+ return ret;
24
+ }
25
+ return [];
26
+ },
27
+ getServices: () => {
28
+ return app.options.services;
29
+ },
30
+ getRouteFileMap: () => {
31
+ return app.inflated ? app.inflated.fileMap : {};
32
+ },
33
+ getInflateErrors: () => {
34
+ return app.inflated ? app.inflated.errors : [];
35
+ }
36
+ }
37
+ }
@@ -79,12 +79,17 @@ export class ClusterCache implements CacheInterface {
79
79
  this.logger?.error(e);
80
80
  }
81
81
  };
82
+ this.connect();
83
+ }
84
+
85
+ connect() {
82
86
  if (process.send) {
87
+ process.removeListener("message", this.listener);
83
88
  process.on("message", this.listener);
84
89
  }
85
90
  }
86
91
 
87
- dispose() {
92
+ disconnect() {
88
93
  process.removeListener("message", this.listener);
89
94
  }
90
95
 
@@ -135,7 +135,12 @@ export class ClusterWebSocketServer2 extends WebSocketServer {
135
135
  }
136
136
  };
137
137
 
138
+ this.connect();
139
+ }
140
+
141
+ public connect() {
138
142
  if (process.send) {
143
+ process.removeListener("message", this.listener);
139
144
  process.on("message", this.listener);
140
145
  process.send({
141
146
  type: ClusterWebSocketServer2MessageType,
@@ -146,7 +151,7 @@ export class ClusterWebSocketServer2 extends WebSocketServer {
146
151
  }
147
152
  }
148
153
 
149
- dispose() {
154
+ public dispose() {
150
155
  process.removeListener("message", this.listener);
151
156
  }
152
157
 
@@ -47,6 +47,19 @@ export class DBManager {
47
47
  }
48
48
  }
49
49
 
50
+ async connectAll() {
51
+ this.options?.logger?.debug("connection all db connections");
52
+ const tR = [];
53
+ for (const name of this.map.keys()) {
54
+ const db = this.map.get(name);
55
+ if (db && db.status === "disconnected") {
56
+ this.options?.logger?.debug("connecting db connection [%s]", name);
57
+ tR.push(db.connect());
58
+ }
59
+ }
60
+ await Promise.all(tR);
61
+ }
62
+
50
63
  async closeAll() {
51
64
  this.options?.logger?.debug("closing all db connections");
52
65
  for (const name of this.map.keys()) {
@@ -0,0 +1,75 @@
1
+ import { ConsoleTransport, FileTransport, LoggerTransportWriteArgs, LogLevel, WriteArgs } from "@miqro/core";
2
+ import { format } from "node:util";
3
+ import { LOG_SOCKET_PATH, LOG_WRITE_EVENT } from "../../../editor/common/constants.js";
4
+ import { Miqro } from "../app.js";
5
+
6
+ export function createLogProviderOptions(app: Miqro) {
7
+ const defaultConsole = ConsoleTransport();
8
+ const defaultFile = FileTransport();
9
+ const defaultWrite = async (args: LoggerTransportWriteArgs, level?: LogLevel) => {
10
+ try {
11
+ const serviceNamesWithLogConfigReplaceConsole = level === undefined && app.inflated ?
12
+ Object.keys(app.inflated.logConfigMap).filter(serviceName => app.inflated.logConfigMap[serviceName].replaceConsoleTransport) : [];
13
+ const serviceNamesWithLogConfigReplaceFile = level === undefined && app.inflated ?
14
+ Object.keys(app.inflated.logConfigMap).filter(serviceName => app.inflated.logConfigMap[serviceName].replaceFileTransport) : [];
15
+ await Promise.allSettled((level === undefined ?
16
+ [
17
+ level === undefined && serviceNamesWithLogConfigReplaceConsole.length === 0 ?
18
+ defaultConsole.write(args) : Promise.resolve(),
19
+ level === undefined && serviceNamesWithLogConfigReplaceFile.length === 0 ?
20
+ defaultFile.write(args) : Promise.resolve()
21
+ ] : []).concat(app.inflated ?
22
+ Object.keys(app.inflated.logConfigMap).map(serviceName => app.inflated.logConfigMap[serviceName]).filter(c => c.level === level).map(c => c.write(args)) : []
23
+ ));
24
+ } catch (e) {
25
+ console.error(e);
26
+ }
27
+ }
28
+ return {
29
+ name: app.options.name,
30
+ formatter: (args: WriteArgs) => {
31
+ const params: string[] = args.optionalParams;
32
+ return format(
33
+ `${new Date().toISOString()} PID[${process.pid}] ${args.identifier ? `[${args.identifier}] ` : ""}${args.level !== "info" ? (args.level === "error" || args.level === "warn" ? `[${args.level.toUpperCase()}] ` : `[${args.level}] `) : ""}${args.message}`,
34
+ ...params)
35
+ },
36
+ transports: [
37
+ ...(([undefined, "error", "warn", "info", "debug", "trace"] as LogLevel[]).map(level => {
38
+ return level ? {
39
+ level,
40
+ write: async (args) => {
41
+ await defaultWrite(args, level);
42
+ }
43
+ } : {
44
+ write: async (args) => {
45
+ await defaultWrite(args, undefined);
46
+ }
47
+ }
48
+ })), {
49
+ level: "trace" as LogLevel,
50
+ write: async (args) => {
51
+ try {
52
+ if (app.options.editor) {
53
+ try {
54
+ const ws = app.webSocketManager.getWS(LOG_SOCKET_PATH);
55
+ if (ws) {
56
+ //console.log("\n\n" + process.pid + " broadcasting " + LOG_SOCKET_PATH + "\n\n\n")
57
+ await ws.broadcast(JSON.stringify({
58
+ type: LOG_WRITE_EVENT,
59
+ level: args.level,
60
+ identifier: args.identifier,
61
+ out: args.out
62
+ }));
63
+ }
64
+ } catch (e) {
65
+ console.error(e);
66
+ }
67
+ }
68
+ } catch (e) {
69
+ console.error(e);
70
+ }
71
+ }
72
+ }],
73
+ ...(app.options.logProviderOptions ? app.options.logProviderOptions : {})
74
+ };
75
+ }
@@ -20,8 +20,18 @@ export class WebSocketManager {
20
20
  this.name = options && options.name ? options.name : "WebSocketManager";
21
21
  this.avoidLogSocket = options && options.avoidLogSocket ? options.avoidLogSocket : false;
22
22
  }
23
+
24
+ public deleteWS(path: string) {
25
+ const ws = this.runningGlobalWSMap.get(path);
26
+ this.disconnectAllFrom(path);
27
+ ws.dispose();
28
+ this.runningGlobalWSMap.delete(path);
29
+ }
30
+
23
31
  public deleteAllWS() {
24
- this.runningGlobalWSMap.clear();
32
+ for (const path of this.runningGlobalWSMap.keys()) {
33
+ this.deleteWS(path);
34
+ }
25
35
  }
26
36
 
27
37
  public getWS(path: string): ClusterWebSocketServer2 | undefined {
@@ -45,7 +55,7 @@ export class WebSocketManager {
45
55
  public replaceALLWSBuLOGSocket(list: WSConfig[]) {
46
56
  for (const path of this.runningGlobalWSMap.keys()) {
47
57
  if (path !== LOG_SOCKET_PATH || !this.avoidLogSocket) {
48
- this.runningGlobalWSMap.delete(path);
58
+ this.deleteWS(path);
49
59
  }
50
60
  }
51
61
  for (const wsConfig of list) {
@@ -85,7 +95,7 @@ export class WebSocketManager {
85
95
  }
86
96
  }
87
97
  }
88
- ws.dispose();
98
+ //ws.dispose();
89
99
  }
90
100
  } catch (e) {
91
101
  this.logger?.error("error disconnecting web socket clients");
package/package.json--OLD DELETED
@@ -1,36 +0,0 @@
1
- {
2
- "name": "miqro",
3
- "version": "5.0.5",
4
- "description": "",
5
- "main": "build/index.js",
6
- "types": "build/index.d.ts",
7
- "type": "module",
8
- "bin": {
9
- "miqro": "build/cli.js"
10
- },
11
- "scripts": {
12
- "prepare2": "npm run build",
13
- "prebuild": "rm -Rf build;",
14
- "build": "tsc",
15
- "pretest": "npm run build",
16
- "test": "node --enable-source-maps --test test/**.test.js",
17
- "coverage": "node --enable-source-maps --experimental-test-coverage --test test/**.test.js"
18
- },
19
- "author": "claukers",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@miqro/core": "^5.0.12",
23
- "@miqro/query": "^0.0.3",
24
- "@miqro/parser": "^2.0.4",
25
- "@miqro/runner": "^2.0.1"
26
- },
27
- "devDependencies": {
28
- "@types/cookie": "0.6.0",
29
- "@types/node": "^20.4.5",
30
- "typescript": "5.3.3"
31
- },
32
- "engines": {
33
- "node": ">=18.0.0",
34
- "npm": ">=6.0.0"
35
- }
36
- }