bb-browser 0.1.0 → 0.1.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/daemon.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  COMMAND_TIMEOUT,
4
4
  DAEMON_PORT,
5
5
  SSE_HEARTBEAT_INTERVAL
6
- } from "./chunk-KATHFDYJ.js";
6
+ } from "./chunk-YAVLEXUJ.js";
7
7
 
8
8
  // packages/daemon/src/index.ts
9
9
  import { parseArgs } from "util";
@@ -2344,23 +2344,30 @@ async function handleTabNew(command) {
2344
2344
  }
2345
2345
  async function handleTabSelect(command) {
2346
2346
  const index = command.index;
2347
- if (index === void 0 || index < 0) {
2347
+ const tabIdParam = command.tabId;
2348
+ if (index === void 0 && tabIdParam === void 0) {
2348
2349
  return {
2349
2350
  id: command.id,
2350
2351
  success: false,
2351
- error: "Missing or invalid index parameter"
2352
+ error: "Missing index or tabId parameter"
2352
2353
  };
2353
2354
  }
2354
- console.log("[CommandHandler] Selecting tab at index:", index);
2355
+ console.log("[CommandHandler] Selecting tab:", tabIdParam !== void 0 ? `tabId=${tabIdParam}` : `index=${index}`);
2355
2356
  try {
2356
- const tabs = await chrome.tabs.query({ currentWindow: true });
2357
- const targetTab = tabs.find((t) => t.index === index);
2358
- if (!targetTab || !targetTab.id) {
2359
- return {
2360
- id: command.id,
2361
- success: false,
2362
- error: `No tab found at index ${index} (total tabs: ${tabs.length})`
2363
- };
2357
+ let targetTab;
2358
+ if (tabIdParam !== void 0) {
2359
+ targetTab = await chrome.tabs.get(tabIdParam);
2360
+ } else {
2361
+ const tabs = await chrome.tabs.query({ currentWindow: true });
2362
+ const found = tabs.find((t) => t.index === index);
2363
+ if (!found || !found.id) {
2364
+ return {
2365
+ id: command.id,
2366
+ success: false,
2367
+ error: `No tab found at index ${index} (total tabs: ${tabs.length})`
2368
+ };
2369
+ }
2370
+ targetTab = found;
2364
2371
  }
2365
2372
  await chrome.tabs.update(targetTab.id, { active: true });
2366
2373
  return {
@@ -2383,10 +2390,13 @@ async function handleTabSelect(command) {
2383
2390
  }
2384
2391
  async function handleTabClose(command) {
2385
2392
  const index = command.index;
2386
- console.log("[CommandHandler] Closing tab at index:", index ?? "current");
2393
+ const tabIdParam = command.tabId;
2394
+ console.log("[CommandHandler] Closing tab:", tabIdParam !== void 0 ? `tabId=${tabIdParam}` : index !== void 0 ? `index=${index}` : "current");
2387
2395
  try {
2388
2396
  let targetTab;
2389
- if (index !== void 0) {
2397
+ if (tabIdParam !== void 0) {
2398
+ targetTab = await chrome.tabs.get(tabIdParam);
2399
+ } else if (index !== void 0) {
2390
2400
  const tabs = await chrome.tabs.query({ currentWindow: true });
2391
2401
  const found = tabs.find((t) => t.index === index);
2392
2402
  if (!found || !found.id) {