@salla.sa/twilight 2.6.11 → 2.6.12
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/dist/@salla.sa/twilight.min.js +1 -1
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/watcher.js +12 -40
package/package.json
CHANGED
package/watcher.js
CHANGED
|
@@ -4,8 +4,6 @@ const color = {normal: "\x1b[0m", red: "\x1b[31m", green: "\x1b[32m", yellow: "\
|
|
|
4
4
|
const {execSync} = require("child_process");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const WebSocketClient = require('websocket').client;
|
|
7
|
-
const WebSocketServer = require("websocket").server;
|
|
8
|
-
const http = require("http");
|
|
9
7
|
//const webpack = require("webpack");
|
|
10
8
|
/**
|
|
11
9
|
* @callback HookCallback
|
|
@@ -68,8 +66,18 @@ class WatcherPlugin {
|
|
|
68
66
|
this.upload_url = upload_url;
|
|
69
67
|
this.store_id = store_id;
|
|
70
68
|
this.draft_id = draft_id;
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
// connect to live reload server
|
|
70
|
+
let client = new WebSocketClient();
|
|
71
|
+
client.on('connectFailed', (error)=> {
|
|
72
|
+
console.error('[x] Oops! Hot reload is currently not working. Check the error message for details: ',error.toString());
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
client.on('connect', (connection)=> {
|
|
76
|
+
this.connection = connection;
|
|
77
|
+
console.log(color.green, `✓ Performing hot reload on port ws://localhost:${wsport}`, color.normal);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
client.connect(`ws://localhost:${wsport}`, 'echo-protocol');
|
|
73
81
|
|
|
74
82
|
}
|
|
75
83
|
|
|
@@ -138,42 +146,6 @@ class WatcherPlugin {
|
|
|
138
146
|
|
|
139
147
|
return !!this.theme_id;
|
|
140
148
|
}
|
|
141
|
-
startWebsocketServer(wsport){
|
|
142
|
-
// start the live reload ws server
|
|
143
|
-
const wsServer = new WebSocketServer({
|
|
144
|
-
httpServer: http.createServer().listen(wsport),
|
|
145
|
-
});
|
|
146
|
-
let users = [];
|
|
147
|
-
wsServer.on("request", function (request) {
|
|
148
|
-
let connection = request.accept("echo-protocol", request.origin);
|
|
149
|
-
users.push(connection);
|
|
150
|
-
|
|
151
|
-
connection.on("error", function (message) {
|
|
152
|
-
console.log("error", message);
|
|
153
|
-
});
|
|
154
|
-
connection.on("message", function (message) {
|
|
155
|
-
// mirror to all users
|
|
156
|
-
users.map((user) => {
|
|
157
|
-
// check user
|
|
158
|
-
if(user.connected)
|
|
159
|
-
user.sendUTF(message.utf8Data);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// connect to live reload server
|
|
165
|
-
let client = new WebSocketClient();
|
|
166
|
-
client.on('connectFailed', (error)=> {
|
|
167
|
-
console.error('[x] Oops! Hot reload is currently not working. Check the error message for details: ',error.toString());
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
client.on('connect', (connection)=> {
|
|
171
|
-
this.connection = connection;
|
|
172
|
-
console.log(color.green, `✓ Performing hot reload on port ws://localhost:${wsport}`, color.normal);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
client.connect(`ws://localhost:${wsport}`, 'echo-protocol');
|
|
176
|
-
}
|
|
177
149
|
}
|
|
178
150
|
|
|
179
151
|
module.exports = WatcherPlugin;
|