@lvce-editor/extension-management-worker 4.41.1 → 4.42.0
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.
|
@@ -1200,19 +1200,58 @@ const create$5 = async ({
|
|
|
1200
1200
|
return rpc;
|
|
1201
1201
|
};
|
|
1202
1202
|
|
|
1203
|
+
const reconnectDelay = 2000;
|
|
1204
|
+
const waitForReconnect = async () => {
|
|
1205
|
+
await new Promise(resolve => {
|
|
1206
|
+
setTimeout(resolve, reconnectDelay);
|
|
1207
|
+
});
|
|
1208
|
+
};
|
|
1209
|
+
const connect = async ({
|
|
1210
|
+
commandMap,
|
|
1211
|
+
wsUrl
|
|
1212
|
+
}) => {
|
|
1213
|
+
const webSocket = new WebSocket(wsUrl);
|
|
1214
|
+
try {
|
|
1215
|
+
const rpc = await create$5({
|
|
1216
|
+
commandMap,
|
|
1217
|
+
webSocket
|
|
1218
|
+
});
|
|
1219
|
+
return {
|
|
1220
|
+
rpc,
|
|
1221
|
+
webSocket
|
|
1222
|
+
};
|
|
1223
|
+
} catch (error) {
|
|
1224
|
+
webSocket.close();
|
|
1225
|
+
throw error;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1203
1228
|
const create$4 = async ({
|
|
1204
1229
|
commandMap,
|
|
1230
|
+
onClose,
|
|
1205
1231
|
type
|
|
1206
1232
|
}) => {
|
|
1207
1233
|
const host = getHost();
|
|
1208
1234
|
const protocol = getProtocol();
|
|
1209
1235
|
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1236
|
+
let connection;
|
|
1237
|
+
try {
|
|
1238
|
+
connection = await connect({
|
|
1239
|
+
commandMap,
|
|
1240
|
+
wsUrl
|
|
1241
|
+
});
|
|
1242
|
+
} catch {
|
|
1243
|
+
await waitForReconnect();
|
|
1244
|
+
connection = await connect({
|
|
1245
|
+
commandMap,
|
|
1246
|
+
wsUrl
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
if (onClose) {
|
|
1250
|
+
connection.webSocket.addEventListener('close', onClose, {
|
|
1251
|
+
once: true
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
return connection.rpc;
|
|
1216
1255
|
};
|
|
1217
1256
|
|
|
1218
1257
|
const create$3 = async ({
|
|
@@ -1591,11 +1630,11 @@ const tryToGetActualImportErrorMessage = async (url, error) => {
|
|
|
1591
1630
|
return `Failed to import ${url}: ${error}`;
|
|
1592
1631
|
}
|
|
1593
1632
|
if (response.ok) {
|
|
1594
|
-
|
|
1633
|
+
return `Failed to import ${url}: ${error}`;
|
|
1595
1634
|
}
|
|
1596
1635
|
switch (response.status) {
|
|
1597
1636
|
case NotFound:
|
|
1598
|
-
|
|
1637
|
+
return `Failed to import ${url}: Not found (404)`;
|
|
1599
1638
|
default:
|
|
1600
1639
|
return `Failed to import ${url}: ${error}`;
|
|
1601
1640
|
}
|