poke-browser 0.4.4 → 0.4.6

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.
@@ -259,7 +259,7 @@ function handleResolveClickPoint(message, sendResponse) {
259
259
  /**
260
260
  * React / Draft.js-style editors listen for `beforeinput` + `input` (InputEvent) rather than only
261
261
  * mutating textContent. Mirror native insertion order: beforeinput → DOM update → input → change.
262
- * Clears placeholder text and enables Post buttons on Draft.js editors (X.com, LinkedIn, etc.).
262
+ * Helps placeholder clearing and submit affordances on Draft.js surfaces (e.g. X.com, LinkedIn).
263
263
  * @param {HTMLElement} el
264
264
  * @param {string} text
265
265
  * @param {boolean} shouldClear
@@ -298,9 +298,7 @@ function insertTextIntoContentEditable(el, text, shouldClear) {
298
298
  inputType: "insertText",
299
299
  data: text,
300
300
  });
301
- el.dispatchEvent(
302
- new InputEvent("beforeinput", { ...evInit, cancelable: true })
303
- );
301
+ el.dispatchEvent(new InputEvent("beforeinput", { ...evInit, cancelable: true }));
304
302
 
305
303
  if (shouldClear) {
306
304
  el.textContent = text;
@@ -339,6 +337,49 @@ function insertTextIntoContentEditable(el, text, shouldClear) {
339
337
  el.dispatchEvent(new Event("change", { bubbles: true }));
340
338
  }
341
339
 
340
+ /**
341
+ * Same InputEvent ordering for `<input>` / `<textarea>` (React-controlled fields).
342
+ * @param {HTMLInputElement | HTMLTextAreaElement} input
343
+ * @param {string} text
344
+ * @param {boolean} shouldClear
345
+ */
346
+ function insertTextIntoFormControl(input, text, shouldClear) {
347
+ let start = 0;
348
+ let end = input.value.length;
349
+ if (!shouldClear) {
350
+ start = typeof input.selectionStart === "number" ? input.selectionStart : input.value.length;
351
+ end = typeof input.selectionEnd === "number" ? input.selectionEnd : input.value.length;
352
+ }
353
+
354
+ input.focus();
355
+ if (shouldClear) {
356
+ input.select();
357
+ document.execCommand("delete");
358
+ }
359
+
360
+ const evInit = /** @type {InputEventInit} */ ({
361
+ bubbles: true,
362
+ composed: true,
363
+ inputType: "insertText",
364
+ data: text,
365
+ });
366
+ input.dispatchEvent(new InputEvent("beforeinput", { ...evInit, cancelable: true }));
367
+
368
+ if (shouldClear) {
369
+ input.value = text;
370
+ } else {
371
+ const v = input.value;
372
+ input.value = v.slice(0, start) + text + v.slice(end);
373
+ const pos = start + text.length;
374
+ if (typeof input.setSelectionRange === "function") {
375
+ input.setSelectionRange(pos, pos);
376
+ }
377
+ }
378
+
379
+ input.dispatchEvent(new InputEvent("input", { ...evInit, cancelable: false }));
380
+ input.dispatchEvent(new Event("change", { bubbles: true }));
381
+ }
382
+
342
383
  /**
343
384
  * @param {unknown} message
344
385
  * @param {(r: unknown) => void} sendResponse
@@ -368,17 +409,7 @@ function handleTypeText(message, sendResponse) {
368
409
 
369
410
  const tag = el.tagName.toLowerCase();
370
411
  if (tag === "input" || tag === "textarea") {
371
- const input = /** @type {HTMLInputElement | HTMLTextAreaElement} */ (el);
372
- input.focus();
373
- if (shouldClear) {
374
- input.select();
375
- document.execCommand("delete");
376
- input.value = text;
377
- } else {
378
- input.value = (input.value || "") + text;
379
- }
380
- input.dispatchEvent(new InputEvent("input", { bubbles: true, data: text, inputType: "insertText" }));
381
- input.dispatchEvent(new Event("change", { bubbles: true }));
412
+ insertTextIntoFormControl(/** @type {HTMLInputElement | HTMLTextAreaElement} */ (el), text, shouldClear);
382
413
  sendResponse({ success: true, charsTyped: text.length });
383
414
  return;
384
415
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "poke-browser",
4
- "version": "0.4.3",
4
+ "version": "0.4.5",
5
5
  "description": "Browser automation bridge for MCP agents via WebSocket.",
6
6
  "permissions": [
7
7
  "tabs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poke-browser",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "MCP server + WebSocket bridge for the poke-browser Chrome extension",
5
5
  "type": "module",
6
6
  "engines": {
@@ -62,7 +62,6 @@
62
62
  "@types/express": "^5.0.0",
63
63
  "@types/node": "^22.13.10",
64
64
  "@types/ws": "^8.18.1",
65
- "jsdom": "^29.0.1",
66
65
  "semantic-release": "^24.2.0",
67
66
  "tsx": "^4.19.3",
68
67
  "typescript": "^5.8.2",