bb-browser 0.5.0 → 0.5.2
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/cli.js +34 -0
- package/dist/cli.js.map +1 -1
- package/extension/background.js +1 -10
- package/extension/background.js.map +1 -1
- package/extension/dist/background.js +1 -10
- package/extension/dist/background.js.map +1 -1
- package/extension/dist/manifest.json +1 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -126,6 +126,21 @@ async function isDaemonRunning() {
|
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
async function isExtensionConnected() {
|
|
130
|
+
try {
|
|
131
|
+
const controller = new AbortController();
|
|
132
|
+
const timeoutId = setTimeout(() => controller.abort(), 2e3);
|
|
133
|
+
const response = await fetch(`${DAEMON_BASE_URL}/status`, {
|
|
134
|
+
signal: controller.signal
|
|
135
|
+
});
|
|
136
|
+
clearTimeout(timeoutId);
|
|
137
|
+
if (!response.ok) return false;
|
|
138
|
+
const data = await response.json();
|
|
139
|
+
return !!data.extensionConnected;
|
|
140
|
+
} catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
129
144
|
async function waitForDaemon(timeoutMs) {
|
|
130
145
|
const startTime = Date.now();
|
|
131
146
|
while (Date.now() - startTime < timeoutMs) {
|
|
@@ -156,6 +171,11 @@ async function ensureDaemonRunning() {
|
|
|
156
171
|
"\u65E0\u6CD5\u542F\u52A8 Daemon\u3002\u8BF7\u624B\u52A8\u8FD0\u884C bb-browser daemon \u6216 bb-daemon \u542F\u52A8\u670D\u52A1"
|
|
157
172
|
);
|
|
158
173
|
}
|
|
174
|
+
const extStart = Date.now();
|
|
175
|
+
while (Date.now() - extStart < 1e4) {
|
|
176
|
+
if (await isExtensionConnected()) return;
|
|
177
|
+
await new Promise((r) => setTimeout(r, POLL_INTERVAL));
|
|
178
|
+
}
|
|
159
179
|
}
|
|
160
180
|
async function stopDaemon() {
|
|
161
181
|
try {
|
|
@@ -717,6 +737,20 @@ async function siteCommand(args, options = {}) {
|
|
|
717
737
|
}
|
|
718
738
|
break;
|
|
719
739
|
}
|
|
740
|
+
silentUpdate();
|
|
741
|
+
}
|
|
742
|
+
function silentUpdate() {
|
|
743
|
+
const gitDir = join(COMMUNITY_SITES_DIR, ".git");
|
|
744
|
+
if (!existsSync2(gitDir)) return;
|
|
745
|
+
import("child_process").then(({ spawn: spawn3 }) => {
|
|
746
|
+
const child = spawn3("git", ["pull", "--ff-only"], {
|
|
747
|
+
cwd: COMMUNITY_SITES_DIR,
|
|
748
|
+
stdio: "ignore",
|
|
749
|
+
detached: true
|
|
750
|
+
});
|
|
751
|
+
child.unref();
|
|
752
|
+
}).catch(() => {
|
|
753
|
+
});
|
|
720
754
|
}
|
|
721
755
|
|
|
722
756
|
// packages/cli/src/commands/open.ts
|