lucid-package 0.0.119 → 0.0.121
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 +13 -10
package/package.json
CHANGED
package/src/editorextension.js
CHANGED
|
@@ -115,11 +115,11 @@ exports.watchEditorExtension = watchEditorExtension;
|
|
|
115
115
|
* @param watchIgnoreNodeModules If true, while serving, will not autoreload on changes to node_modules files
|
|
116
116
|
*/
|
|
117
117
|
async function debugEditorExtension(extensionNames, isInternal, quiet = false, pickAnyPort = false, watchIgnoreNodeModules = false) {
|
|
118
|
-
const port = 9900;
|
|
119
118
|
const watchers = await Promise.all(extensionNames.map(async (name) => watchEditorExtension(name, isInternal, quiet, watchIgnoreNodeModules)));
|
|
120
119
|
const app = express();
|
|
121
|
-
const
|
|
122
|
-
|
|
120
|
+
const initialPortToTry = 9900;
|
|
121
|
+
// The actual port number (that the server serves from)can change, depending on anyport behavior.
|
|
122
|
+
listen(app, initialPortToTry, pickAnyPort);
|
|
123
123
|
const errorLog = new Map();
|
|
124
124
|
recordErrors(watchers, errorLog);
|
|
125
125
|
app.use(cors_1.corsAllowLucid);
|
|
@@ -145,10 +145,12 @@ async function debugEditorExtension(extensionNames, isInternal, quiet = false, p
|
|
|
145
145
|
});
|
|
146
146
|
app.get(['/editorextension', '/editorextension/:name'], async (req, res) => {
|
|
147
147
|
const name = req.params['name'] ?? extensionNames[0];
|
|
148
|
+
const port = req.socket.localPort;
|
|
148
149
|
const rawExtension = await getRawEditorExtension(name, port);
|
|
149
150
|
res.send(rawExtension);
|
|
150
151
|
});
|
|
151
152
|
app.get('/editorextensions', async (req, res) => {
|
|
153
|
+
const port = req.socket.localPort;
|
|
152
154
|
res.send(await Promise.all(extensionNames.map((name) => getRawEditorExtension(name, port))));
|
|
153
155
|
});
|
|
154
156
|
app.get('/settings', async (req, res) => {
|
|
@@ -229,17 +231,18 @@ async function debugEditorExtension(extensionNames, isInternal, quiet = false, p
|
|
|
229
231
|
app.use('/resources', express.static('public'));
|
|
230
232
|
}
|
|
231
233
|
exports.debugEditorExtension = debugEditorExtension;
|
|
232
|
-
function listen(app,
|
|
233
|
-
|
|
234
|
-
.listen(
|
|
235
|
-
console.log((0, theme_1.success)('Listening at http://localhost:' +
|
|
234
|
+
function listen(app, portToTry, pickAnyPort) {
|
|
235
|
+
const server = app
|
|
236
|
+
.listen(portToTry, 'localhost', () => {
|
|
237
|
+
console.log((0, theme_1.success)('Listening at http://localhost:' + portToTry + '/extension.js'));
|
|
236
238
|
(0, shapelibrary_1.debugShapeLibraries)(undefined, pickAnyPort);
|
|
239
|
+
setupWebSockets(server);
|
|
237
240
|
})
|
|
238
241
|
.on('error', (err) => {
|
|
239
242
|
if (err.code === 'EADDRINUSE') {
|
|
240
|
-
if (pickAnyPort &&
|
|
241
|
-
|
|
242
|
-
listen(app,
|
|
243
|
+
if (pickAnyPort && portToTry < 15000) {
|
|
244
|
+
portToTry++;
|
|
245
|
+
listen(app, portToTry, pickAnyPort);
|
|
243
246
|
}
|
|
244
247
|
else {
|
|
245
248
|
console.error('Failed to listen for extension');
|