dsh-site-bridge 0.5.2 → 0.5.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.
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 3,
3
3
  "default_locale": "en",
4
4
  "name": "__MSG_appName__",
5
- "version": "0.5.2",
5
+ "version": "0.5.3",
6
6
  "description": "__MSG_appDesc__",
7
7
  "minimum_chrome_version": "116",
8
8
  "permissions": [
@@ -239,16 +239,33 @@ $('import-file').addEventListener('change', async (event) => {
239
239
  }
240
240
  })
241
241
 
242
- $('claim').addEventListener('click', async () => {
243
- const [tab] = await chrome.tabs.query({ active: true, currentWindow: true })
244
- if (!tab?.id) return
245
- const result = await send({ type: 'claim', tabId: tab.id })
246
- if (!result?.ok) {
247
- setNote(t('claimFailed', [String(result?.error ?? t('claimFailedUnknown'))]), true)
242
+ async function attachCurrentTab() {
243
+ let tabId = null
244
+ try {
245
+ const [tab] = await chrome.tabs.query({ active: true, currentWindow: true })
246
+ tabId = tab?.id ?? null
247
+ } catch {
248
+ tabId = null
249
+ }
250
+ if (tabId == null) {
251
+ setNote(t('claimFailed', [t('claimFailedUnknown')]), true)
252
+ return
253
+ }
254
+ try {
255
+ const result = await send({ type: 'claim', tabId })
256
+ if (!result?.ok) {
257
+ setNote(t('claimFailed', [String(result?.error ?? t('claimFailedUnknown'))]), true)
258
+ return
259
+ }
260
+ setNote('')
261
+ } catch (error) {
262
+ setNote(t('claimFailed', [String(error?.message ?? error)]), true)
248
263
  return
249
264
  }
250
265
  await refresh()
251
- })
266
+ }
267
+
268
+ $('claim').addEventListener('click', attachCurrentTab)
252
269
 
253
270
  $('capture').addEventListener('click', async () => {
254
271
  const status = await send({ type: 'status' })
@@ -277,11 +294,7 @@ $('pick').addEventListener('click', async () => {
277
294
  await refresh()
278
295
  })
279
296
 
280
- $('claim-more').addEventListener('click', async () => {
281
- const result = await send({ type: 'claim' })
282
- if (!result?.ok && result?.error) setNote(String(result.error), true)
283
- await refresh()
284
- })
297
+ $('claim-more').addEventListener('click', attachCurrentTab)
285
298
 
286
299
  $('tabs-select').addEventListener('change', async (event) => {
287
300
  const tabId = Number(event.target.value)
package/extension/sw.js CHANGED
@@ -272,11 +272,19 @@ async function attach(tabId) {
272
272
  }
273
273
 
274
274
  async function claimTab(tabId) {
275
- const tab = await chrome.tabs.get(tabId)
275
+ // Without an explicit id, claim whatever tab the user is looking at, so a
276
+ // caller that only knows "this tab" cannot silently pass NaN.
277
+ let id = Number(tabId)
278
+ if (!Number.isFinite(id)) {
279
+ const [active] = await chrome.tabs.query({ active: true, lastFocusedWindow: true })
280
+ id = active?.id
281
+ }
282
+ if (!Number.isFinite(id)) throw new Error('no tab to claim: pass tabId or open a page first')
283
+ const tab = await chrome.tabs.get(id)
276
284
  if (!/^https?:|^file:/.test(tab.url ?? '')) {
277
285
  throw new Error(`cannot drive ${tab.url || 'this tab'}: only http(s) and file:// pages are supported`)
278
286
  }
279
- return attach(tabId)
287
+ return attach(id)
280
288
  }
281
289
 
282
290
  chrome.debugger.onDetach.addListener((source, reason) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-site-bridge",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Chrome/Edge MV3 bridge for DeepSeek Harness: capture page markup (DOM, styles, selectors) and BFF traffic (xhr/fetch with headers and bodies) into a workspace snapshot bundle, drive the page with trusted CDP input, and verify injected scripts. Authorization never leaves the browser and is never written to disk.",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",