@airmoney-degn/airmoney-cli 0.13.1 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,7 +97,12 @@ async function createCommand(name, network, template, locationFolder) {
97
97
  console.log(` cd ${name}`);
98
98
  if (template) {
99
99
  console.log(' npm install');
100
- console.log(` npm run serve`);
100
+ console.log('\n- Development mode:');
101
+ console.log(' npm run dev');
102
+ console.log(' airmoney-cli serve -u http://localhost:5173');
103
+ console.log('\n- Production build:');
104
+ console.log(' npm run build');
105
+ console.log(' airmoney-cli serve -f dist');
101
106
  }
102
107
  else {
103
108
  console.log(' airmoney-cli serve');
package/dist/config.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.13.1"
2
+ "version": "0.13.3"
3
3
  }
@@ -44,11 +44,10 @@ class ServeOrchestrator {
44
44
  }
45
45
  // Start simulator service
46
46
  await this.simulatorService.start();
47
- // Connect simulator client to airmoney service
48
- const simulatorClient = this.simulatorService.getClient();
49
- if (simulatorClient) {
50
- this.airmoneyService.setSimulatorClient(simulatorClient);
51
- }
47
+ // Set up callback to handle simulator client connections
48
+ this.simulatorService.setOnClientConnected((client) => {
49
+ this.airmoneyService.setSimulatorClient(client);
50
+ });
52
51
  // Start airmoney service
53
52
  await this.airmoneyService.start();
54
53
  // Start crypto service
@@ -13,6 +13,7 @@ const http_proxy_middleware_1 = require("http-proxy-middleware");
13
13
  class BaseSimulatorService {
14
14
  constructor(config) {
15
15
  this.simulatorClient = null;
16
+ this.onClientConnectedCallback = null;
16
17
  this.config = config;
17
18
  this.app = (0, express_ws_1.default)((0, express_1.default)()).app;
18
19
  this.setupMiddleware();
@@ -31,9 +32,28 @@ class BaseSimulatorService {
31
32
  setupWebSocket() {
32
33
  this.app.ws('/ws', (ws, req) => {
33
34
  this.simulatorClient = ws;
35
+ // Notify callback about new connection
36
+ if (this.onClientConnectedCallback) {
37
+ this.onClientConnectedCallback(this.getClient());
38
+ }
34
39
  ws.on('message', (msg) => {
35
40
  console.log(msg);
36
41
  });
42
+ ws.on('close', () => {
43
+ this.simulatorClient = null;
44
+ // Notify callback about disconnection
45
+ if (this.onClientConnectedCallback) {
46
+ this.onClientConnectedCallback(null);
47
+ }
48
+ });
49
+ ws.on('error', (error) => {
50
+ console.error('WebSocket error:', error);
51
+ this.simulatorClient = null;
52
+ // Notify callback about disconnection due to error
53
+ if (this.onClientConnectedCallback) {
54
+ this.onClientConnectedCallback(null);
55
+ }
56
+ });
37
57
  });
38
58
  }
39
59
  setupStaticFiles() {
@@ -84,6 +104,9 @@ class BaseSimulatorService {
84
104
  }
85
105
  return false;
86
106
  }
107
+ setOnClientConnected(callback) {
108
+ this.onClientConnectedCallback = callback;
109
+ }
87
110
  async start() {
88
111
  this.setupWebSocket();
89
112
  this.setupStaticFiles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airmoney-degn/airmoney-cli",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
4
4
  "description": "airmoney-cli is a command-line interface tool designed to facilitate the development and management of decentralized applications (DApps) for Airmoney.",
5
5
  "publishConfig": {
6
6
  "access": "public"