pi-chrome 0.4.2 → 0.4.3

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Pi Existing Chrome Profile Bridge",
4
- "version": "0.4.0",
4
+ "version": "0.4.3",
5
5
  "description": "Lets Pi control tabs in this existing Chrome profile via a local bridge at 127.0.0.1.",
6
6
  "permissions": ["tabs", "scripting", "storage", "activeTab", "alarms"],
7
7
  "host_permissions": ["<all_urls>", "http://127.0.0.1:17318/*"],
@@ -41,13 +41,17 @@ async function pollLoop() {
41
41
  polling = true;
42
42
  try {
43
43
  while (true) {
44
+ // Long-poll /next continuously. The bridge holds the request for up to ~25s when no
45
+ // command is pending and returns {type:"none"}; we immediately re-issue the fetch so
46
+ // commands sent while the SW is otherwise idle still get picked up promptly. The open
47
+ // fetch also keeps the MV3 service worker alive between alarm wake-ups.
44
48
  const response = await fetch(`${BRIDGE_URL}/next?name=${encodeURIComponent(CLIENT_NAME)}`, {
45
49
  cache: "no-store",
46
50
  });
47
51
  if (!response.ok) throw new Error(`bridge /next HTTP ${response.status}`);
48
52
  const payload = await response.json();
49
- if (payload.type !== "command") break;
50
- await handleCommand(payload.command);
53
+ if (payload.type === "command") await handleCommand(payload.command);
54
+ // Otherwise (type:"none"), loop and re-issue the long-poll.
51
55
  }
52
56
  } catch (error) {
53
57
  await sleep(POLL_ERROR_BACKOFF_MS);
@@ -46,7 +46,7 @@ type BridgeResult = {
46
46
  error?: string;
47
47
  };
48
48
 
49
- const PI_CHROME_VERSION = "0.4.0";
49
+ const PI_CHROME_VERSION = "0.4.3";
50
50
  const DEFAULT_HOST = process.env.PI_CHROME_BRIDGE_HOST ?? "127.0.0.1";
51
51
  const DEFAULT_PORT = Number(process.env.PI_CHROME_BRIDGE_PORT ?? "17318");
52
52
  const DEFAULT_TIMEOUT_MS = 30_000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-chrome",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Drive your existing logged-in Chrome from Pi \u2014 no re-login, no throwaway profile, background by default.",
5
5
  "keywords": [
6
6
  "pi-package",