@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/cjs/index.js
CHANGED
|
@@ -2398,6 +2398,12 @@ async function makeConnection(url, protocol, callback, connection) {
|
|
|
2398
2398
|
if (retry) {
|
|
2399
2399
|
return makeConnectionIn(url, protocol, callback, connection, 2e3);
|
|
2400
2400
|
} else {
|
|
2401
|
+
callback({
|
|
2402
|
+
type: "connection-status",
|
|
2403
|
+
status: "failed",
|
|
2404
|
+
reason: "unable to connect",
|
|
2405
|
+
retry
|
|
2406
|
+
});
|
|
2401
2407
|
throw Error("Failed to establish connection");
|
|
2402
2408
|
}
|
|
2403
2409
|
}
|
|
@@ -2564,16 +2570,20 @@ var handleMessageFromClient = async ({
|
|
|
2564
2570
|
}) => {
|
|
2565
2571
|
switch (message.type) {
|
|
2566
2572
|
case "connect":
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2573
|
+
try {
|
|
2574
|
+
await connectToServer(
|
|
2575
|
+
message.url,
|
|
2576
|
+
message.protocol,
|
|
2577
|
+
message.token,
|
|
2578
|
+
message.username,
|
|
2579
|
+
postMessage,
|
|
2580
|
+
message.retryLimitDisconnect,
|
|
2581
|
+
message.retryLimitStartup
|
|
2582
|
+
);
|
|
2583
|
+
postMessage({ type: "connected" });
|
|
2584
|
+
} catch (err) {
|
|
2585
|
+
postMessage({ type: "connection-failed", reason: String(err) });
|
|
2586
|
+
}
|
|
2577
2587
|
break;
|
|
2578
2588
|
case "subscribe":
|
|
2579
2589
|
infoEnabled4 && info4(\`client subscribe: \${JSON.stringify(message)}\`);
|
|
@@ -2620,15 +2630,15 @@ var getWorker = async ({
|
|
|
2620
2630
|
url
|
|
2621
2631
|
}) => {
|
|
2622
2632
|
if (token === "" && pendingWorker === void 0) {
|
|
2623
|
-
return new Promise((resolve) => {
|
|
2624
|
-
pendingWorkerNoToken.push({ resolve });
|
|
2633
|
+
return new Promise((resolve, reject) => {
|
|
2634
|
+
pendingWorkerNoToken.push({ resolve, reject });
|
|
2625
2635
|
});
|
|
2626
2636
|
}
|
|
2627
2637
|
return pendingWorker || // we get this far when we receive the first request with auth token
|
|
2628
|
-
(pendingWorker = new Promise((resolve) => {
|
|
2638
|
+
(pendingWorker = new Promise((resolve, reject) => {
|
|
2629
2639
|
const worker2 = new Worker(workerBlobUrl);
|
|
2630
2640
|
const timer = window.setTimeout(() => {
|
|
2631
|
-
|
|
2641
|
+
reject(Error("timed out waiting for worker to load"));
|
|
2632
2642
|
}, 1e3);
|
|
2633
2643
|
worker2.onmessage = (msg) => {
|
|
2634
2644
|
const { data: message } = msg;
|
|
@@ -2652,6 +2662,12 @@ var getWorker = async ({
|
|
|
2652
2662
|
pendingWorkerNoToken.length = 0;
|
|
2653
2663
|
} else if ((0, import_vuu_utils.isConnectionStatusMessage)(message)) {
|
|
2654
2664
|
handleConnectionStatusChange({ data: message });
|
|
2665
|
+
} else if (message.type === "connection-failed") {
|
|
2666
|
+
reject(message.reason);
|
|
2667
|
+
for (const pendingWorkerRequest of pendingWorkerNoToken) {
|
|
2668
|
+
pendingWorkerRequest.reject(message.reason);
|
|
2669
|
+
}
|
|
2670
|
+
pendingWorkerNoToken.length = 0;
|
|
2655
2671
|
} else {
|
|
2656
2672
|
console.warn("ConnectionManager: Unexpected message from the worker");
|
|
2657
2673
|
}
|