@flrande/bak-extension 0.6.8 → 0.6.9

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 +1 @@
1
- 2026-03-13T08:51:15.417Z
1
+ 2026-03-13T09:31:23.678Z
@@ -62,7 +62,7 @@
62
62
  // package.json
63
63
  var package_default = {
64
64
  name: "@flrande/bak-extension",
65
- version: "0.6.8",
65
+ version: "0.6.9",
66
66
  type: "module",
67
67
  scripts: {
68
68
  build: "tsup src/background.ts src/content.ts src/popup.ts --format iife --out-dir dist --clean && node scripts/copy-assets.mjs",
@@ -1202,6 +1202,7 @@
1202
1202
  const candidateWindowIds = [];
1203
1203
  const peerTabIds = /* @__PURE__ */ new Set();
1204
1204
  const peerGroupIds = /* @__PURE__ */ new Set();
1205
+ const reusablePeerIds = /* @__PURE__ */ new Set();
1205
1206
  const pushWindowId = (windowId) => {
1206
1207
  if (typeof windowId !== "number") {
1207
1208
  return;
@@ -1212,11 +1213,20 @@
1212
1213
  candidateWindowIds.push(windowId);
1213
1214
  };
1214
1215
  for (const peer of peers) {
1215
- pushWindowId(peer.windowId);
1216
- if (peer.groupId !== null) {
1217
- peerGroupIds.add(peer.groupId);
1218
- const group = await this.waitForGroup(peer.groupId, 300);
1219
- pushWindowId(group?.windowId);
1216
+ if (peer.groupId === null) {
1217
+ continue;
1218
+ }
1219
+ const group = await this.waitForGroup(peer.groupId, 300);
1220
+ if (!group) {
1221
+ continue;
1222
+ }
1223
+ reusablePeerIds.add(peer.id);
1224
+ peerGroupIds.add(group.id);
1225
+ pushWindowId(group.windowId);
1226
+ }
1227
+ for (const peer of peers) {
1228
+ if (!reusablePeerIds.has(peer.id)) {
1229
+ continue;
1220
1230
  }
1221
1231
  const trackedTabIds = this.collectCandidateTabIds(peer);
1222
1232
  for (const trackedTabId of trackedTabIds) {
@@ -1224,7 +1234,9 @@
1224
1234
  }
1225
1235
  const trackedTabs = await this.readLooseTrackedTabs(trackedTabIds);
1226
1236
  for (const tab of trackedTabs) {
1227
- pushWindowId(tab.windowId);
1237
+ if (tab.groupId !== null && peerGroupIds.has(tab.groupId)) {
1238
+ pushWindowId(tab.windowId);
1239
+ }
1228
1240
  }
1229
1241
  }
1230
1242
  for (const windowId of candidateWindowIds) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Agent Kit",
4
- "version": "0.6.8",
4
+ "version": "0.6.9",
5
5
  "action": {
6
6
  "default_popup": "popup.html"
7
7
  },
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@flrande/bak-extension",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "@flrande/bak-protocol": "0.6.8"
6
+ "@flrande/bak-protocol": "0.6.9"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@types/chrome": "^0.1.14",
@@ -882,6 +882,7 @@ class SessionBindingManager {
882
882
  const candidateWindowIds: number[] = [];
883
883
  const peerTabIds = new Set<number>();
884
884
  const peerGroupIds = new Set<number>();
885
+ const reusablePeerIds = new Set<string>();
885
886
  const pushWindowId = (windowId: number | null | undefined): void => {
886
887
  if (typeof windowId !== 'number') {
887
888
  return;
@@ -893,11 +894,21 @@ class SessionBindingManager {
893
894
  };
894
895
 
895
896
  for (const peer of peers) {
896
- pushWindowId(peer.windowId);
897
- if (peer.groupId !== null) {
898
- peerGroupIds.add(peer.groupId);
899
- const group = await this.waitForGroup(peer.groupId, 300);
900
- pushWindowId(group?.windowId);
897
+ if (peer.groupId === null) {
898
+ continue;
899
+ }
900
+ const group = await this.waitForGroup(peer.groupId, 300);
901
+ if (!group) {
902
+ continue;
903
+ }
904
+ reusablePeerIds.add(peer.id);
905
+ peerGroupIds.add(group.id);
906
+ pushWindowId(group.windowId);
907
+ }
908
+
909
+ for (const peer of peers) {
910
+ if (!reusablePeerIds.has(peer.id)) {
911
+ continue;
901
912
  }
902
913
  const trackedTabIds = this.collectCandidateTabIds(peer);
903
914
  for (const trackedTabId of trackedTabIds) {
@@ -905,7 +916,9 @@ class SessionBindingManager {
905
916
  }
906
917
  const trackedTabs = await this.readLooseTrackedTabs(trackedTabIds);
907
918
  for (const tab of trackedTabs) {
908
- pushWindowId(tab.windowId);
919
+ if (tab.groupId !== null && peerGroupIds.has(tab.groupId)) {
920
+ pushWindowId(tab.windowId);
921
+ }
909
922
  }
910
923
  }
911
924