@monostate/node-scraper 2.2.0 → 2.2.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.
@@ -521,10 +521,18 @@ export class BrowserSession {
521
521
 
522
522
  async typeText(text) {
523
523
  this._ensureConnected();
524
- this._ensureProvider();
525
- const result = await this.provider.typeText(text);
524
+ // Use Puppeteer keyboard when we have a page — works with both selector
525
+ // clicks (CDP focus) and coordinate clicks (X11 focus propagates to DOM).
526
+ // xdotool typeText only reaches the X11-focused window, not the DOM-focused
527
+ // element, so it fails when mixed with selector-based click.
528
+ if (this.page) {
529
+ await this.page.keyboard.type(text);
530
+ } else {
531
+ this._ensureProvider();
532
+ await this.provider.typeText(text);
533
+ }
526
534
  this._logAction('typeText', { text: text.substring(0, 20) + (text.length > 20 ? '...' : '') });
527
- return result;
535
+ return { success: true };
528
536
  }
529
537
 
530
538
  async getCursorPosition() {
package/index.js CHANGED
@@ -4,7 +4,7 @@ import { existsSync, statSync } from 'fs';
4
4
  import path from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { promises as fsPromises } from 'fs';
7
- import { PDFParse } from 'pdf-parse';
7
+ let PDFParse = null;
8
8
  import browserPool from './browser-pool.js';
9
9
 
10
10
  let puppeteer = null;
@@ -860,7 +860,11 @@ ${parsedContent.headings?.length ? `\nHeadings:\n${parsedContent.headings.map(h
860
860
  };
861
861
  }
862
862
 
863
- // Parse PDF with pdf-parse v2 API
863
+ // Lazy-load pdf-parse (pdfjs-dist requires DOMMatrix, only available in Node 22+)
864
+ if (!PDFParse) {
865
+ const mod = await import('pdf-parse');
866
+ PDFParse = mod.PDFParse;
867
+ }
864
868
  const parser = new PDFParse({ data: new Uint8Array(buffer) });
865
869
  await parser.load();
866
870
  const textResult = await parser.getText();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monostate/node-scraper",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Intelligent web scraping with AI Q&A, PDF support and multi-level fallback system - 11x faster than traditional scrapers",
5
5
  "type": "module",
6
6
  "main": "index.js",