@salla.sa/twilight 2.2.2 → 2.2.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,9 +44,9 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/core": "^7.18.10",
47
- "@babel/preset-env": "^7.18.9",
47
+ "@babel/preset-env": "^7.18.10",
48
48
  "@rollup/plugin-babel": "^5.3.1",
49
- "@rollup/plugin-commonjs": "^22.0.1",
49
+ "@rollup/plugin-commonjs": "^22.0.2",
50
50
  "@rollup/plugin-node-resolve": "^13.1.3",
51
51
  "babel-loader": "^8.2.5",
52
52
  "glob": "^8.0.3",
package/watcher.js CHANGED
@@ -70,22 +70,31 @@ class WatcherPlugin {
70
70
  this.draft_id = args.draft_id;
71
71
  port = args.port || 8000;
72
72
  }
73
-
74
- let client = new WebSocketClient();
75
-
76
- client.on('connectFailed', function(error) {
77
- console.error('[x] Oops! Hot reload is currently not working. Check the error message for details: ',error.toString());
78
- });
79
-
80
- client.on('connect', (connection)=> {
81
- this.connection = connection;
82
- console.log(color.green, `✓ Performing hot reload on port ws://localhost:${port}`, color.normal);
83
- });
84
-
85
- client.connect(`ws://localhost:${port}`, 'echo-protocol');
73
+ // try to connect to ws server
74
+ this.wsConnectingTries = 1;
75
+ this.tryConnectWebsocket(port);
86
76
 
87
77
  }
88
-
78
+
79
+ tryConnectWebsocket(port){
80
+ let client = new WebSocketClient();
81
+ client.on('connectFailed', (error)=> {
82
+ if(this.wsConnectingTries===10){
83
+ console.error('[x] Oops! Hot reload is currently not working. Check the error message for details: ',error.toString());
84
+ }else{
85
+ this.wsConnectingTries++;
86
+ setTimeout(()=>{
87
+ this.tryConnectWebsocket(port);
88
+ },1000);
89
+ }
90
+ });
91
+
92
+ client.on('connect', (connection)=> {
93
+ this.connection = connection;
94
+ console.log(color.green, `✓ Performing hot reload on port ws://localhost:${port}`, color.normal);
95
+ });
96
+ client.connect(`ws://localhost:${port}`, 'echo-protocol');
97
+ }
89
98
  /**
90
99
  * @param {Compiler} compiler
91
100
  */