@vuu-ui/vuu-data-remote 0.8.26-debug → 0.8.27-debug
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/cjs/index.js +30 -14
- package/cjs/index.js.map +2 -2
- package/esm/index.js +30 -14
- package/esm/index.js.map +2 -2
- package/package.json +7 -7
- package/types/connection-manager.d.ts +5 -0
- package/types/inlined-worker.d.ts +1 -1
package/esm/index.js
CHANGED
|
@@ -2362,6 +2362,12 @@ async function makeConnection(url, protocol, callback, connection) {
|
|
|
2362
2362
|
if (retry) {
|
|
2363
2363
|
return makeConnectionIn(url, protocol, callback, connection, 2e3);
|
|
2364
2364
|
} else {
|
|
2365
|
+
callback({
|
|
2366
|
+
type: "connection-status",
|
|
2367
|
+
status: "failed",
|
|
2368
|
+
reason: "unable to connect",
|
|
2369
|
+
retry
|
|
2370
|
+
});
|
|
2365
2371
|
throw Error("Failed to establish connection");
|
|
2366
2372
|
}
|
|
2367
2373
|
}
|
|
@@ -2528,16 +2534,20 @@ var handleMessageFromClient = async ({
|
|
|
2528
2534
|
}) => {
|
|
2529
2535
|
switch (message.type) {
|
|
2530
2536
|
case "connect":
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2537
|
+
try {
|
|
2538
|
+
await connectToServer(
|
|
2539
|
+
message.url,
|
|
2540
|
+
message.protocol,
|
|
2541
|
+
message.token,
|
|
2542
|
+
message.username,
|
|
2543
|
+
postMessage,
|
|
2544
|
+
message.retryLimitDisconnect,
|
|
2545
|
+
message.retryLimitStartup
|
|
2546
|
+
);
|
|
2547
|
+
postMessage({ type: "connected" });
|
|
2548
|
+
} catch (err) {
|
|
2549
|
+
postMessage({ type: "connection-failed", reason: String(err) });
|
|
2550
|
+
}
|
|
2541
2551
|
break;
|
|
2542
2552
|
case "subscribe":
|
|
2543
2553
|
infoEnabled4 && info4(\`client subscribe: \${JSON.stringify(message)}\`);
|
|
@@ -2584,15 +2594,15 @@ var getWorker = async ({
|
|
|
2584
2594
|
url
|
|
2585
2595
|
}) => {
|
|
2586
2596
|
if (token === "" && pendingWorker === void 0) {
|
|
2587
|
-
return new Promise((resolve) => {
|
|
2588
|
-
pendingWorkerNoToken.push({ resolve });
|
|
2597
|
+
return new Promise((resolve, reject) => {
|
|
2598
|
+
pendingWorkerNoToken.push({ resolve, reject });
|
|
2589
2599
|
});
|
|
2590
2600
|
}
|
|
2591
2601
|
return pendingWorker || // we get this far when we receive the first request with auth token
|
|
2592
|
-
(pendingWorker = new Promise((resolve) => {
|
|
2602
|
+
(pendingWorker = new Promise((resolve, reject) => {
|
|
2593
2603
|
const worker2 = new Worker(workerBlobUrl);
|
|
2594
2604
|
const timer = window.setTimeout(() => {
|
|
2595
|
-
|
|
2605
|
+
reject(Error("timed out waiting for worker to load"));
|
|
2596
2606
|
}, 1e3);
|
|
2597
2607
|
worker2.onmessage = (msg) => {
|
|
2598
2608
|
const { data: message } = msg;
|
|
@@ -2616,6 +2626,12 @@ var getWorker = async ({
|
|
|
2616
2626
|
pendingWorkerNoToken.length = 0;
|
|
2617
2627
|
} else if (isConnectionStatusMessage(message)) {
|
|
2618
2628
|
handleConnectionStatusChange({ data: message });
|
|
2629
|
+
} else if (message.type === "connection-failed") {
|
|
2630
|
+
reject(message.reason);
|
|
2631
|
+
for (const pendingWorkerRequest of pendingWorkerNoToken) {
|
|
2632
|
+
pendingWorkerRequest.reject(message.reason);
|
|
2633
|
+
}
|
|
2634
|
+
pendingWorkerNoToken.length = 0;
|
|
2619
2635
|
} else {
|
|
2620
2636
|
console.warn("ConnectionManager: Unexpected message from the worker");
|
|
2621
2637
|
}
|