@flrande/bak-extension 0.3.6 → 0.3.8

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-09T12:16:27.259Z
1
+ 2026-03-09T16:21:56.905Z
@@ -1048,13 +1048,14 @@
1048
1048
  });
1049
1049
  }
1050
1050
  async function waitForTabUrl(tabId, expectedUrl, timeoutMs = 1e4) {
1051
+ const normalizedExpectedUrl = normalizeComparableTabUrl(expectedUrl);
1051
1052
  const deadline = Date.now() + timeoutMs;
1052
1053
  while (Date.now() < deadline) {
1053
1054
  try {
1054
1055
  const tab = await chrome.tabs.get(tabId);
1055
1056
  const currentUrl = tab.url ?? "";
1056
1057
  const pendingUrl = "pendingUrl" in tab && typeof tab.pendingUrl === "string" ? tab.pendingUrl : "";
1057
- if (currentUrl === expectedUrl || pendingUrl === expectedUrl) {
1058
+ if (normalizeComparableTabUrl(currentUrl) === normalizedExpectedUrl || normalizeComparableTabUrl(pendingUrl) === normalizedExpectedUrl) {
1058
1059
  return;
1059
1060
  }
1060
1061
  } catch {
@@ -1063,6 +1064,19 @@
1063
1064
  }
1064
1065
  throw new Error(`tab url timeout: ${tabId} -> ${expectedUrl}`);
1065
1066
  }
1067
+ function normalizeComparableTabUrl(url) {
1068
+ const raw = url.trim();
1069
+ if (!raw) {
1070
+ return raw;
1071
+ }
1072
+ try {
1073
+ const parsed = new URL(raw);
1074
+ parsed.hash = "";
1075
+ return parsed.href;
1076
+ } catch {
1077
+ return raw;
1078
+ }
1079
+ }
1066
1080
  async function finalizeOpenedWorkspaceTab(opened, expectedUrl) {
1067
1081
  if (expectedUrl && expectedUrl !== "about:blank") {
1068
1082
  await waitForTabUrl(opened.tab.id, expectedUrl).catch(() => void 0);
@@ -1605,7 +1619,7 @@
1605
1619
  ws?.send(JSON.stringify({
1606
1620
  type: "hello",
1607
1621
  role: "extension",
1608
- version: "0.1.0",
1622
+ version: "0.3.8",
1609
1623
  ts: Date.now()
1610
1624
  }));
1611
1625
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Agent Kit",
4
- "version": "0.1.0",
4
+ "version": "0.3.8",
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.3.6",
3
+ "version": "0.3.8",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "@flrande/bak-protocol": "0.3.6"
6
+ "@flrande/bak-protocol": "0.3.8"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@types/chrome": "^0.1.14",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Agent Kit",
4
- "version": "0.1.0",
4
+ "version": "0.3.8",
5
5
  "action": {
6
6
  "default_popup": "popup.html"
7
7
  },
package/src/background.ts CHANGED
@@ -372,13 +372,17 @@ async function waitForTabComplete(tabId: number, timeoutMs = DEFAULT_TAB_LOAD_TI
372
372
  }
373
373
 
374
374
  async function waitForTabUrl(tabId: number, expectedUrl: string, timeoutMs = 10_000): Promise<void> {
375
+ const normalizedExpectedUrl = normalizeComparableTabUrl(expectedUrl);
375
376
  const deadline = Date.now() + timeoutMs;
376
377
  while (Date.now() < deadline) {
377
378
  try {
378
379
  const tab = await chrome.tabs.get(tabId);
379
380
  const currentUrl = tab.url ?? '';
380
381
  const pendingUrl = 'pendingUrl' in tab && typeof tab.pendingUrl === 'string' ? tab.pendingUrl : '';
381
- if (currentUrl === expectedUrl || pendingUrl === expectedUrl) {
382
+ if (
383
+ normalizeComparableTabUrl(currentUrl) === normalizedExpectedUrl ||
384
+ normalizeComparableTabUrl(pendingUrl) === normalizedExpectedUrl
385
+ ) {
382
386
  return;
383
387
  }
384
388
  } catch {
@@ -390,6 +394,20 @@ async function waitForTabUrl(tabId: number, expectedUrl: string, timeoutMs = 10_
390
394
  throw new Error(`tab url timeout: ${tabId} -> ${expectedUrl}`);
391
395
  }
392
396
 
397
+ function normalizeComparableTabUrl(url: string): string {
398
+ const raw = url.trim();
399
+ if (!raw) {
400
+ return raw;
401
+ }
402
+ try {
403
+ const parsed = new URL(raw);
404
+ parsed.hash = '';
405
+ return parsed.href;
406
+ } catch {
407
+ return raw;
408
+ }
409
+ }
410
+
393
411
  async function finalizeOpenedWorkspaceTab(
394
412
  opened: Awaited<ReturnType<WorkspaceManager['openTab']>>,
395
413
  expectedUrl?: string
@@ -1001,7 +1019,7 @@ async function connectWebSocket(): Promise<void> {
1001
1019
  ws?.send(JSON.stringify({
1002
1020
  type: 'hello',
1003
1021
  role: 'extension',
1004
- version: '0.1.0',
1022
+ version: '0.3.8',
1005
1023
  ts: Date.now()
1006
1024
  }));
1007
1025
  });