bitfab-cli 0.2.43 → 0.2.45
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/dist/index.js +42 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7428,6 +7428,36 @@ function readActiveStudioSession() {
|
|
|
7428
7428
|
return readActiveStudioSessionRaw();
|
|
7429
7429
|
}
|
|
7430
7430
|
|
|
7431
|
+
// ../bitfab-plugin-lib/dist/studioTeardown.js
|
|
7432
|
+
var WINDOW_CLOSE_GRACE_PERIOD_MS = 1e4;
|
|
7433
|
+
function createWindowCloseArbiter(handlers) {
|
|
7434
|
+
let graceTimer = null;
|
|
7435
|
+
const cancel3 = () => {
|
|
7436
|
+
if (graceTimer) {
|
|
7437
|
+
clearTimeout(graceTimer);
|
|
7438
|
+
graceTimer = null;
|
|
7439
|
+
}
|
|
7440
|
+
};
|
|
7441
|
+
return {
|
|
7442
|
+
handleEvent(event) {
|
|
7443
|
+
if (event.type === "studio:window-closed") {
|
|
7444
|
+
cancel3();
|
|
7445
|
+
graceTimer = setTimeout(() => {
|
|
7446
|
+
graceTimer = null;
|
|
7447
|
+
handlers.onConfirmed(event);
|
|
7448
|
+
}, WINDOW_CLOSE_GRACE_PERIOD_MS);
|
|
7449
|
+
return;
|
|
7450
|
+
}
|
|
7451
|
+
if (event.type === "studio:session-started" && graceTimer) {
|
|
7452
|
+
cancel3();
|
|
7453
|
+
handlers.onRefuted?.();
|
|
7454
|
+
}
|
|
7455
|
+
},
|
|
7456
|
+
hasPendingCandidate: () => graceTimer != null,
|
|
7457
|
+
cancel: cancel3
|
|
7458
|
+
};
|
|
7459
|
+
}
|
|
7460
|
+
|
|
7431
7461
|
// ../bitfab-plugin-lib/dist/browser.js
|
|
7432
7462
|
import { execSync, spawn } from "child_process";
|
|
7433
7463
|
import fs7 from "fs";
|
|
@@ -7933,7 +7963,6 @@ async function waitForSessionReady(opts) {
|
|
|
7933
7963
|
}
|
|
7934
7964
|
|
|
7935
7965
|
// ../bitfab-plugin-lib/dist/commands/openStudioTo.js
|
|
7936
|
-
var WINDOW_CLOSE_GRACE_PERIOD_MS = 1e4;
|
|
7937
7966
|
var LOGIN_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
7938
7967
|
var StudioNavigationError = class extends Error {
|
|
7939
7968
|
reason;
|
|
@@ -8050,14 +8079,7 @@ async function openStudioTo(path15, opts = {}) {
|
|
|
8050
8079
|
}
|
|
8051
8080
|
function startEventPoller(serviceUrl, apiKey, sessionId, onEvent, restoreFocus) {
|
|
8052
8081
|
const abortController = new AbortController();
|
|
8053
|
-
let graceTimer = null;
|
|
8054
8082
|
let endedNotified = false;
|
|
8055
|
-
const clearGraceTimer = () => {
|
|
8056
|
-
if (graceTimer) {
|
|
8057
|
-
clearTimeout(graceTimer);
|
|
8058
|
-
graceTimer = null;
|
|
8059
|
-
}
|
|
8060
|
-
};
|
|
8061
8083
|
const notifyEnded = (baseEvent) => {
|
|
8062
8084
|
if (!endedNotified) {
|
|
8063
8085
|
endedNotified = true;
|
|
@@ -8066,6 +8088,15 @@ function startEventPoller(serviceUrl, apiKey, sessionId, onEvent, restoreFocus)
|
|
|
8066
8088
|
}
|
|
8067
8089
|
abortController.abort();
|
|
8068
8090
|
};
|
|
8091
|
+
const arbiter = createWindowCloseArbiter({
|
|
8092
|
+
onConfirmed: (event) => {
|
|
8093
|
+
clearActiveStudioSession(sessionId);
|
|
8094
|
+
notifyEnded(event);
|
|
8095
|
+
},
|
|
8096
|
+
onRefuted: () => {
|
|
8097
|
+
console.error("Studio reconnected after page refresh");
|
|
8098
|
+
}
|
|
8099
|
+
});
|
|
8069
8100
|
const done = (async () => {
|
|
8070
8101
|
const startCursor = await fetchStreamTip({ serviceUrl, apiKey, sessionId });
|
|
8071
8102
|
if (abortController.signal.aborted) {
|
|
@@ -8078,24 +8109,12 @@ function startEventPoller(serviceUrl, apiKey, sessionId, onEvent, restoreFocus)
|
|
|
8078
8109
|
startCursor,
|
|
8079
8110
|
abortSignal: abortController.signal,
|
|
8080
8111
|
onEvent: (event) => {
|
|
8081
|
-
if (event.type === "studio:window-closed") {
|
|
8082
|
-
|
|
8083
|
-
graceTimer = setTimeout(() => {
|
|
8084
|
-
graceTimer = null;
|
|
8085
|
-
clearActiveStudioSession(sessionId);
|
|
8086
|
-
notifyEnded(event);
|
|
8087
|
-
}, WINDOW_CLOSE_GRACE_PERIOD_MS);
|
|
8088
|
-
return;
|
|
8089
|
-
}
|
|
8090
|
-
if (event.type === "studio:session-started") {
|
|
8091
|
-
if (graceTimer) {
|
|
8092
|
-
clearGraceTimer();
|
|
8093
|
-
console.error("Studio reconnected after page refresh");
|
|
8094
|
-
}
|
|
8112
|
+
if (event.type === "studio:window-closed" || event.type === "studio:session-started") {
|
|
8113
|
+
arbiter.handleEvent(event);
|
|
8095
8114
|
return;
|
|
8096
8115
|
}
|
|
8097
8116
|
if (event.type === "studio:session-ended") {
|
|
8098
|
-
|
|
8117
|
+
arbiter.cancel();
|
|
8099
8118
|
notifyEnded(event);
|
|
8100
8119
|
return;
|
|
8101
8120
|
}
|