@duheso/zerocli 0.8.3 → 0.8.5
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/chrome-extension/background.js +16 -0
- package/chrome-extension/popup.js +16 -42
- package/dist/cli.mjs +1143 -1143
- package/package.json +1 -1
|
@@ -898,6 +898,22 @@ function setFileInputValue(selector, imageData, mediaType) {
|
|
|
898
898
|
}
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
+
// ─── Popup Status Query ──────────────────────────────────────────────────────
|
|
902
|
+
|
|
903
|
+
// Respond to popup (or any extension page) asking for current connection state.
|
|
904
|
+
// This avoids the popup spawning a second native host process just to check status.
|
|
905
|
+
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
|
906
|
+
if (message?.type === 'get_status') {
|
|
907
|
+
sendResponse({
|
|
908
|
+
isConnected,
|
|
909
|
+
nativePortAlive: nativePort !== null,
|
|
910
|
+
version: VERSION,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
// Return false: we handled synchronously.
|
|
914
|
+
return false;
|
|
915
|
+
});
|
|
916
|
+
|
|
901
917
|
// ─── Init ────────────────────────────────────────────────────────────────────
|
|
902
918
|
|
|
903
919
|
chrome.runtime.onInstalled.addListener(() => {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// ZeroCLI Browser Extension — Popup Script
|
|
2
2
|
|
|
3
|
-
const NATIVE_HOST_NAME = 'com.duheso.zerocli_browser_extension';
|
|
4
|
-
|
|
5
3
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
6
4
|
const statusDot = document.getElementById('statusDot');
|
|
7
5
|
const statusLabel = document.getElementById('statusLabel');
|
|
@@ -15,54 +13,30 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
15
13
|
// Show extension info
|
|
16
14
|
const manifest = chrome.runtime.getManifest();
|
|
17
15
|
const extId = chrome.runtime.id;
|
|
18
|
-
|
|
19
16
|
extensionIdEl.textContent = extId.slice(0, 20) + '...';
|
|
20
17
|
extensionIdEl.title = extId;
|
|
21
18
|
extensionVersionEl.textContent = manifest.version;
|
|
22
19
|
|
|
23
|
-
// Check connection status by probing native host
|
|
24
20
|
setStatus('checking', 'Checking...', 'Testing connection to ZeroCLI...');
|
|
25
21
|
|
|
22
|
+
// Ask the background service worker for status — no second native host process needed
|
|
26
23
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
port.onMessage.addListener((msg) => {
|
|
40
|
-
if (msg.type === 'pong' && !responded) {
|
|
41
|
-
responded = true;
|
|
42
|
-
clearTimeout(timeout);
|
|
43
|
-
port.disconnect();
|
|
44
|
-
setStatus('connected', 'Connected', 'ZeroCLI is connected and ready for browser automation.');
|
|
45
|
-
nativeHostStatus.textContent = 'Running';
|
|
46
|
-
infoSection.style.display = 'flex';
|
|
47
|
-
setupInstructions.style.display = 'none';
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
port.onDisconnect.addListener(() => {
|
|
52
|
-
if (!responded) {
|
|
53
|
-
clearTimeout(timeout);
|
|
54
|
-
const err = chrome.runtime.lastError?.message || 'Native host not found';
|
|
55
|
-
setStatus('disconnected', 'Disconnected', `Native host error: ${err}`);
|
|
56
|
-
nativeHostStatus.textContent = 'Not found';
|
|
57
|
-
infoSection.style.display = 'flex';
|
|
58
|
-
setupInstructions.style.display = 'block';
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
port.postMessage({ type: 'ping' });
|
|
24
|
+
const response = await chrome.runtime.sendMessage({ type: 'get_status' });
|
|
25
|
+
if (response?.isConnected) {
|
|
26
|
+
setStatus('connected', 'Connected', 'ZeroCLI is connected and ready for browser automation.');
|
|
27
|
+
nativeHostStatus.textContent = 'Running';
|
|
28
|
+
infoSection.style.display = 'flex';
|
|
29
|
+
setupInstructions.style.display = 'none';
|
|
30
|
+
} else {
|
|
31
|
+
setStatus('disconnected', 'Disconnected', 'ZeroCLI native host not responding. Run: zero --chrome');
|
|
32
|
+
nativeHostStatus.textContent = 'Not running';
|
|
33
|
+
infoSection.style.display = 'flex';
|
|
34
|
+
setupInstructions.style.display = 'block';
|
|
35
|
+
}
|
|
63
36
|
} catch (err) {
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
// Background not yet active (e.g. browser just started)
|
|
38
|
+
setStatus('disconnected', 'Disconnected', 'ZeroCLI native host not responding. Run: zero --chrome');
|
|
39
|
+
nativeHostStatus.textContent = 'Not running';
|
|
66
40
|
infoSection.style.display = 'flex';
|
|
67
41
|
setupInstructions.style.display = 'block';
|
|
68
42
|
}
|