@crawlee/jsdom 4.0.0-beta.105 → 4.0.0-beta.106

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.
@@ -57,6 +57,7 @@ JSONData extends Dictionary = any> extends InternalHttpCrawlingContext<UserData,
57
57
  export type JSDOMRequestHandler<UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
58
58
  JSONData extends Dictionary = any> = RequestHandler<JSDOMCrawlingContext<UserData, JSONData>>;
59
59
  export declare class JSDOMCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends JSDOMCrawlingContext = JSDOMCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<JSDOMCrawlingContext['request']>>> extends HttpCrawler<JSDOMCrawlingContext, ContextExtension, ExtendedContext, Routes> {
60
+ #private;
60
61
  protected static optionsShape: {
61
62
  // @ts-ignore optional peer dependency or compatibility with es2022
62
63
  runScripts: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
@@ -151,9 +152,6 @@ export declare class JSDOMCrawler<ContextExtension = Dictionary<never>, Extended
151
152
  // @ts-ignore optional peer dependency or compatibility with es2022
152
153
  id: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
153
154
  };
154
- private runScripts;
155
- private hideInternalConsole;
156
- private virtualConsole;
157
155
  constructor(options?: JSDOMCrawlerOptions<ContextExtension, ExtendedContext, any, any, Routes>);
158
156
  // @ts-ignore optional peer dependency or compatibility with es2022
159
157
  protected buildContextPipeline(): import("@crawlee/http").ContextPipeline<CrawlingContext<Dictionary>, InternalHttpCrawlingContext<any, any> & {
@@ -89,17 +89,17 @@ export class JSDOMCrawler extends HttpCrawler {
89
89
  runScripts: ow.optional.boolean,
90
90
  hideInternalConsole: ow.optional.boolean,
91
91
  };
92
- runScripts;
93
- hideInternalConsole;
94
- virtualConsole = null;
92
+ #runScripts;
93
+ #hideInternalConsole;
94
+ #virtualConsole = null;
95
95
  constructor(options = {}) {
96
96
  const { runScripts = false, hideInternalConsole = false, contextPipelineBuilder, ...httpOptions } = options;
97
97
  super({
98
98
  ...httpOptions,
99
99
  contextPipelineBuilder: contextPipelineBuilder ?? (() => this.buildContextPipeline()),
100
100
  });
101
- this.runScripts = runScripts;
102
- this.hideInternalConsole = hideInternalConsole;
101
+ this.#runScripts = runScripts;
102
+ this.#hideInternalConsole = hideInternalConsole;
103
103
  }
104
104
  buildContextPipeline() {
105
105
  return super
@@ -128,15 +128,15 @@ export class JSDOMCrawler extends HttpCrawler {
128
128
  * ```
129
129
  */
130
130
  getVirtualConsole() {
131
- if (this.virtualConsole) {
132
- return this.virtualConsole;
131
+ if (this.#virtualConsole) {
132
+ return this.#virtualConsole;
133
133
  }
134
- this.virtualConsole = new VirtualConsole();
135
- if (!this.hideInternalConsole) {
136
- this.virtualConsole.sendTo(console, { omitJSDOMErrors: true });
134
+ this.#virtualConsole = new VirtualConsole();
135
+ if (!this.#hideInternalConsole) {
136
+ this.#virtualConsole.sendTo(console, { omitJSDOMErrors: true });
137
137
  }
138
- this.virtualConsole.on('jsdomError', this.jsdomErrorHandler);
139
- return this.virtualConsole;
138
+ this.#virtualConsole.on('jsdomError', this.jsdomErrorHandler);
139
+ return this.#virtualConsole;
140
140
  }
141
141
  jsdomErrorHandler = (error) => this.log.debug('JSDOM error from console', { error });
142
142
  async parseContent(crawlingContext) {
@@ -146,7 +146,7 @@ export class JSDOMCrawler extends HttpCrawler {
146
146
  const { window } = new JSDOM(crawlingContext.body.toString(), {
147
147
  url: crawlingContext.response.url,
148
148
  contentType: isXml ? 'text/xml' : 'text/html',
149
- runScripts: this.runScripts ? 'dangerously' : undefined,
149
+ runScripts: this.#runScripts ? 'dangerously' : undefined,
150
150
  resources,
151
151
  virtualConsole: this.getVirtualConsole(),
152
152
  pretendToBeVisual: true,
@@ -171,7 +171,7 @@ export class JSDOMCrawler extends HttpCrawler {
171
171
  range.getClientRects = () => ({ item: () => null, length: 0 });
172
172
  return range;
173
173
  };
174
- if (this.runScripts) {
174
+ if (this.#runScripts) {
175
175
  try {
176
176
  await addTimeoutToPromise(async () => {
177
177
  return new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/jsdom",
3
- "version": "4.0.0-beta.105",
3
+ "version": "4.0.0-beta.106",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -49,9 +49,9 @@
49
49
  "dependencies": {
50
50
  "@apify/timeout": "^0.4.4",
51
51
  "@apify/utilities": "^2.7.10",
52
- "@crawlee/http": "4.0.0-beta.105",
53
- "@crawlee/types": "4.0.0-beta.105",
54
- "@crawlee/utils": "4.0.0-beta.105",
52
+ "@crawlee/http": "4.0.0-beta.106",
53
+ "@crawlee/types": "4.0.0-beta.106",
54
+ "@crawlee/utils": "4.0.0-beta.106",
55
55
  "@types/jsdom": "^21.1.7",
56
56
  "cheerio": "^1.0.0",
57
57
  "jsdom": "^26.1.0",
@@ -65,5 +65,5 @@
65
65
  }
66
66
  }
67
67
  },
68
- "gitHead": "26073a822c7699ac487931383a39192bc3daae7a"
68
+ "gitHead": "c622f1fc65e65221ea245817c58ecc0ffb4a5cb0"
69
69
  }