lucid-package 0.0.84 → 0.0.85
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 +1 -1
- package/src/editorextension.js +22 -1
package/package.json
CHANGED
package/src/editorextension.js
CHANGED
|
@@ -15,6 +15,8 @@ const shapelibrary_1 = require("./shapelibrary");
|
|
|
15
15
|
const shellutil_1 = require("./shellutil");
|
|
16
16
|
const supportedproduct_1 = require("./supportedproduct");
|
|
17
17
|
const WebPackCLI = require('webpack-cli');
|
|
18
|
+
const ws = require('ws');
|
|
19
|
+
const chokidar = require('chokidar');
|
|
18
20
|
async function createEditorExtension(name, isInternalTesting, skipSDKDependency) {
|
|
19
21
|
const editorExtensionSource = path.join(__dirname, '..', 'templates', 'editorextension');
|
|
20
22
|
const editorExtensionTargetFolder = path.join('editorextensions', name);
|
|
@@ -184,8 +186,27 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
184
186
|
}
|
|
185
187
|
app.use('/resources', express.static('public'));
|
|
186
188
|
const listen = () => {
|
|
187
|
-
app.listen(port, 'localhost', () => {
|
|
189
|
+
const server = app.listen(port, 'localhost', () => {
|
|
188
190
|
console.log('Listening at http://localhost:' + port + '/extension.js');
|
|
191
|
+
// Watch for any editor extension changes, and inform watchers that they need to refresh them.
|
|
192
|
+
const wss = new ws.Server({ server, path: '/editorExtensions/changes' });
|
|
193
|
+
const sockets = [];
|
|
194
|
+
wss.on('connection', (ws) => {
|
|
195
|
+
sockets.push(ws);
|
|
196
|
+
});
|
|
197
|
+
// Changes to a file can trigger changes in other files. We debounce all changes so that
|
|
198
|
+
// we don't send multiple "refresh" messages.
|
|
199
|
+
let timeout = null;
|
|
200
|
+
chokidar.watch([['./']]).on('all', () => {
|
|
201
|
+
if (timeout) {
|
|
202
|
+
clearTimeout(timeout);
|
|
203
|
+
}
|
|
204
|
+
timeout = setTimeout(() => {
|
|
205
|
+
for (const socket of sockets) {
|
|
206
|
+
socket.send('refresh');
|
|
207
|
+
}
|
|
208
|
+
}, 100);
|
|
209
|
+
});
|
|
189
210
|
(0, shapelibrary_1.debugShapeLibraries)(undefined, pickAnyPort);
|
|
190
211
|
}).on('error', (err) => {
|
|
191
212
|
if (err.code === 'EADDRINUSE') {
|