bitfab-cli 0.2.85 → 0.2.86
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 +26 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8742,6 +8742,12 @@ var NotAuthenticatedError = class extends Error {
|
|
|
8742
8742
|
this.name = "NotAuthenticatedError";
|
|
8743
8743
|
}
|
|
8744
8744
|
};
|
|
8745
|
+
var DaemonUnavailableError = class extends Error {
|
|
8746
|
+
constructor(message) {
|
|
8747
|
+
super(message);
|
|
8748
|
+
this.name = "DaemonUnavailableError";
|
|
8749
|
+
}
|
|
8750
|
+
};
|
|
8745
8751
|
var StudioNavigationError = class extends Error {
|
|
8746
8752
|
reason;
|
|
8747
8753
|
blockedReason;
|
|
@@ -9908,7 +9914,7 @@ function spawnDaemon(socketPath, pidPath) {
|
|
|
9908
9914
|
const thisDir = path8.dirname(fileURLToPath2(import.meta.url));
|
|
9909
9915
|
const mainPath = path8.join(thisDir, "main.js");
|
|
9910
9916
|
if (!fs9.existsSync(mainPath)) {
|
|
9911
|
-
throw new
|
|
9917
|
+
throw new DaemonUnavailableError(`daemon entry point not found: ${mainPath}`);
|
|
9912
9918
|
}
|
|
9913
9919
|
const child = fork(mainPath, [socketPath, pidPath], {
|
|
9914
9920
|
detached: true,
|
|
@@ -10119,6 +10125,22 @@ var DirectChannel = class {
|
|
|
10119
10125
|
this.apiKey = apiKey;
|
|
10120
10126
|
}
|
|
10121
10127
|
async openOrNavigate(path18, opts) {
|
|
10128
|
+
if (!this.apiKey) {
|
|
10129
|
+
const sessionId2 = opts?.sessionId ?? crypto6.randomUUID();
|
|
10130
|
+
const initialPath = path18.startsWith("/studio") ? path18 : "/studio";
|
|
10131
|
+
if (!isValidStudioRoute(initialPath)) {
|
|
10132
|
+
throw new Error(`Studio route not allowed: ${initialPath}`);
|
|
10133
|
+
}
|
|
10134
|
+
const url2 = initialPath.includes("session=") ? `${this.serviceUrl}${initialPath}` : `${this.serviceUrl}${initialPath}${initialPath.includes("?") ? "&" : "?"}session=${encodeURIComponent(sessionId2)}`;
|
|
10135
|
+
const windowPid = openChromelessWindow(url2);
|
|
10136
|
+
writeActiveStudioSession({
|
|
10137
|
+
sessionId: sessionId2,
|
|
10138
|
+
serviceUrl: this.serviceUrl,
|
|
10139
|
+
windowPid,
|
|
10140
|
+
currentPath: initialPath
|
|
10141
|
+
});
|
|
10142
|
+
return { sessionId: sessionId2, opened: true };
|
|
10143
|
+
}
|
|
10122
10144
|
const existing = readActiveStudioSession();
|
|
10123
10145
|
if (existing && existing.windowState !== "closed") {
|
|
10124
10146
|
const ack = await navigateStudioAndAwaitAck({
|
|
@@ -10302,7 +10324,9 @@ async function resolveChannel(apiKey, serviceUrl) {
|
|
|
10302
10324
|
if (err instanceof StudioNavigationError) {
|
|
10303
10325
|
throw err;
|
|
10304
10326
|
}
|
|
10305
|
-
|
|
10327
|
+
if (!(err instanceof DaemonUnavailableError)) {
|
|
10328
|
+
console.error(`daemon unavailable, falling back to direct: ${err instanceof Error ? err.message : String(err)}`);
|
|
10329
|
+
}
|
|
10306
10330
|
}
|
|
10307
10331
|
}
|
|
10308
10332
|
return new DirectChannel(apiKey, serviceUrl);
|