@html-validate/puppeteer-fetch 2.0.0 → 2.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -85
  2. package/package.json +7 -5
package/dist/index.js CHANGED
@@ -27,33 +27,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
 
28
28
  // node_modules/argparse/lib/sub.js
29
29
  var require_sub = __commonJS({
30
- "node_modules/argparse/lib/sub.js"(exports, module2) {
30
+ "node_modules/argparse/lib/sub.js"(exports2, module2) {
31
31
  "use strict";
32
32
  var { inspect } = require("util");
33
33
  module2.exports = function sub(pattern, ...values) {
34
34
  let regex = /%(?:(%)|(-)?(\*)?(?:\((\w+)\))?([A-Za-z]))/g;
35
35
  let result = pattern.replace(regex, function(_, is_literal, is_left_align, is_padded, name, format) {
36
- if (is_literal)
37
- return "%";
36
+ if (is_literal) return "%";
38
37
  let padded_count = 0;
39
38
  if (is_padded) {
40
- if (values.length === 0)
41
- throw new TypeError("not enough arguments for format string");
39
+ if (values.length === 0) throw new TypeError("not enough arguments for format string");
42
40
  padded_count = values.shift();
43
- if (!Number.isInteger(padded_count))
44
- throw new TypeError("* wants int");
41
+ if (!Number.isInteger(padded_count)) throw new TypeError("* wants int");
45
42
  }
46
43
  let str;
47
44
  if (name !== void 0) {
48
45
  let dict = values[0];
49
- if (typeof dict !== "object" || dict === null)
50
- throw new TypeError("format requires a mapping");
51
- if (!(name in dict))
52
- throw new TypeError(`no such key: '${name}'`);
46
+ if (typeof dict !== "object" || dict === null) throw new TypeError("format requires a mapping");
47
+ if (!(name in dict)) throw new TypeError(`no such key: '${name}'`);
53
48
  str = dict[name];
54
49
  } else {
55
- if (values.length === 0)
56
- throw new TypeError("not enough arguments for format string");
50
+ if (values.length === 0) throw new TypeError("not enough arguments for format string");
57
51
  str = values.shift();
58
52
  }
59
53
  switch (format) {
@@ -92,7 +86,7 @@ var require_sub = __commonJS({
92
86
 
93
87
  // node_modules/argparse/lib/textwrap.js
94
88
  var require_textwrap = __commonJS({
95
- "node_modules/argparse/lib/textwrap.js"(exports, module2) {
89
+ "node_modules/argparse/lib/textwrap.js"(exports2, module2) {
96
90
  "use strict";
97
91
  var wordsep_simple_re = /([\t\n\x0b\x0c\r ]+)/;
98
92
  var TextWrapper = class {
@@ -335,7 +329,7 @@ var require_textwrap = __commonJS({
335
329
 
336
330
  // node_modules/argparse/argparse.js
337
331
  var require_argparse = __commonJS({
338
- "node_modules/argparse/argparse.js"(exports, module2) {
332
+ "node_modules/argparse/argparse.js"(exports2, module2) {
339
333
  "use strict";
340
334
  var SUPPRESS = "==SUPPRESS==";
341
335
  var OPTIONAL = "?";
@@ -368,28 +362,23 @@ var require_argparse = __commonJS({
368
362
  object[name] = value;
369
363
  }
370
364
  function setdefault(object, name, value) {
371
- if (!hasattr(object, name))
372
- object[name] = value;
365
+ if (!hasattr(object, name)) object[name] = value;
373
366
  return object[name];
374
367
  }
375
368
  function delattr(object, name) {
376
369
  delete object[name];
377
370
  }
378
371
  function range(from, to, step = 1) {
379
- if (arguments.length === 1)
380
- [to, from] = [from, 0];
372
+ if (arguments.length === 1) [to, from] = [from, 0];
381
373
  if (typeof from !== "number" || typeof to !== "number" || typeof step !== "number") {
382
374
  throw new TypeError("argument cannot be interpreted as an integer");
383
375
  }
384
- if (step === 0)
385
- throw new TypeError("range() arg 3 must not be zero");
376
+ if (step === 0) throw new TypeError("range() arg 3 must not be zero");
386
377
  let result = [];
387
378
  if (step > 0) {
388
- for (let i = from; i < to; i += step)
389
- result.push(i);
379
+ for (let i = from; i < to; i += step) result.push(i);
390
380
  } else {
391
- for (let i = from; i > to; i += step)
392
- result.push(i);
381
+ for (let i = from; i > to; i += step) result.push(i);
393
382
  }
394
383
  return result;
395
384
  }
@@ -404,14 +393,12 @@ var require_argparse = __commonJS({
404
393
  result.push(parts[i] + (i + 1 < parts.length ? parts[i + 1] : ""));
405
394
  }
406
395
  }
407
- if (!result[result.length - 1])
408
- result.pop();
396
+ if (!result[result.length - 1]) result.pop();
409
397
  return result;
410
398
  }
411
399
  function _string_lstrip(string, prefix_chars) {
412
400
  let idx = 0;
413
- while (idx < string.length && prefix_chars.includes(string[idx]))
414
- idx++;
401
+ while (idx < string.length && prefix_chars.includes(string[idx])) idx++;
415
402
  return idx ? string.slice(idx) : string;
416
403
  }
417
404
  function _string_split(string, sep, maxsplit) {
@@ -422,18 +409,15 @@ var require_argparse = __commonJS({
422
409
  return result;
423
410
  }
424
411
  function _array_equal(array1, array2) {
425
- if (array1.length !== array2.length)
426
- return false;
412
+ if (array1.length !== array2.length) return false;
427
413
  for (let i = 0; i < array1.length; i++) {
428
- if (array1[i] !== array2[i])
429
- return false;
414
+ if (array1[i] !== array2[i]) return false;
430
415
  }
431
416
  return true;
432
417
  }
433
418
  function _array_remove(array, item) {
434
419
  let idx = array.indexOf(item);
435
- if (idx === -1)
436
- throw new TypeError(sub("%r not in list", item));
420
+ if (idx === -1) throw new TypeError(sub("%r not in list", item));
437
421
  array.splice(idx, 1);
438
422
  }
439
423
  function _choices_to_array(choices) {
@@ -480,24 +464,19 @@ var require_argparse = __commonJS({
480
464
  function _camelcase_alias(_class) {
481
465
  for (let name of Object.getOwnPropertyNames(_class.prototype)) {
482
466
  let camelcase = name.replace(/\w_[a-z]/g, (s) => s[0] + s[2].toUpperCase());
483
- if (camelcase !== name)
484
- _alias(_class.prototype, camelcase, name);
467
+ if (camelcase !== name) _alias(_class.prototype, camelcase, name);
485
468
  }
486
469
  return _class;
487
470
  }
488
471
  function _to_legacy_name(key) {
489
472
  key = key.replace(/\w_[a-z]/g, (s) => s[0] + s[2].toUpperCase());
490
- if (key === "default")
491
- key = "defaultValue";
492
- if (key === "const")
493
- key = "constant";
473
+ if (key === "default") key = "defaultValue";
474
+ if (key === "const") key = "constant";
494
475
  return key;
495
476
  }
496
477
  function _to_new_name(key) {
497
- if (key === "defaultValue")
498
- key = "default";
499
- if (key === "constant")
500
- key = "const";
478
+ if (key === "defaultValue") key = "default";
479
+ if (key === "constant") key = "const";
501
480
  key = key.replace(/[A-Z]/g, (c) => "_" + c.toLowerCase());
502
481
  return key;
503
482
  }
@@ -505,10 +484,8 @@ var require_argparse = __commonJS({
505
484
  function _parse_opts(args, descriptor) {
506
485
  function get_name() {
507
486
  let stack = new Error().stack.split("\n").map((x) => x.match(/^ at (.*) \(.*\)$/)).filter(Boolean).map((m) => m[1]).map((fn) => fn.match(/[^ .]*$/)[0]);
508
- if (stack.length && stack[0] === get_name.name)
509
- stack.shift();
510
- if (stack.length && stack[0] === _parse_opts.name)
511
- stack.shift();
487
+ if (stack.length && stack[0] === get_name.name) stack.shift();
488
+ if (stack.length && stack[0] === _parse_opts.name) stack.shift();
512
489
  return stack.length ? stack[0] : "";
513
490
  }
514
491
  args = Array.from(args);
@@ -603,8 +580,7 @@ var require_argparse = __commonJS({
603
580
  }
604
581
  if (missing_positionals.length) {
605
582
  let strs = missing_positionals.map(repr);
606
- if (strs.length > 1)
607
- strs[strs.length - 1] = "and " + strs[strs.length - 1];
583
+ if (strs.length > 1) strs[strs.length - 1] = "and " + strs[strs.length - 1];
608
584
  let str_joined = strs.join(strs.length === 2 ? "" : ", ");
609
585
  throw new TypeError(sub(
610
586
  "%s() missing %i required positional argument%s: %s",
@@ -1879,22 +1855,14 @@ var require_argparse = __commonJS({
1879
1855
  });
1880
1856
  this._flags = flags;
1881
1857
  this._options = {};
1882
- if (encoding !== void 0)
1883
- this._options.encoding = encoding;
1884
- if (mode !== void 0)
1885
- this._options.mode = mode;
1886
- if (autoClose !== void 0)
1887
- this._options.autoClose = autoClose;
1888
- if (emitClose !== void 0)
1889
- this._options.emitClose = emitClose;
1890
- if (start !== void 0)
1891
- this._options.start = start;
1892
- if (end !== void 0)
1893
- this._options.end = end;
1894
- if (highWaterMark !== void 0)
1895
- this._options.highWaterMark = highWaterMark;
1896
- if (fs3 !== void 0)
1897
- this._options.fs = fs3;
1858
+ if (encoding !== void 0) this._options.encoding = encoding;
1859
+ if (mode !== void 0) this._options.mode = mode;
1860
+ if (autoClose !== void 0) this._options.autoClose = autoClose;
1861
+ if (emitClose !== void 0) this._options.emitClose = emitClose;
1862
+ if (start !== void 0) this._options.start = start;
1863
+ if (end !== void 0) this._options.end = end;
1864
+ if (highWaterMark !== void 0) this._options.highWaterMark = highWaterMark;
1865
+ if (fs3 !== void 0) this._options.fs = fs3;
1898
1866
  }
1899
1867
  call(string) {
1900
1868
  if (string === "-") {
@@ -1928,10 +1896,9 @@ var require_argparse = __commonJS({
1928
1896
  [util.inspect.custom]() {
1929
1897
  let args = [this._flags];
1930
1898
  let kwargs = Object.entries(this._options).map(([k, v]) => {
1931
- if (k === "mode")
1932
- v = { value: v, [util.inspect.custom]() {
1933
- return "0o" + this.value.toString(8);
1934
- } };
1899
+ if (k === "mode") v = { value: v, [util.inspect.custom]() {
1900
+ return "0o" + this.value.toString(8);
1901
+ } };
1935
1902
  return [k, v];
1936
1903
  });
1937
1904
  let args_str = [].concat(args.filter((arg) => arg !== -1).map(repr)).concat(kwargs.filter(([, arg]) => arg !== void 0).map(([kw, arg]) => sub("%s=%r", kw, arg))).join(", ");
@@ -3149,19 +3116,16 @@ var require_argparse = __commonJS({
3149
3116
  // Help-printing methods
3150
3117
  // =====================
3151
3118
  print_usage(file = void 0) {
3152
- if (file === void 0)
3153
- file = process.stdout;
3119
+ if (file === void 0) file = process.stdout;
3154
3120
  this._print_message(this.format_usage(), file);
3155
3121
  }
3156
3122
  print_help(file = void 0) {
3157
- if (file === void 0)
3158
- file = process.stdout;
3123
+ if (file === void 0) file = process.stdout;
3159
3124
  this._print_message(this.format_help(), file);
3160
3125
  }
3161
3126
  _print_message(message, file = void 0) {
3162
3127
  if (message) {
3163
- if (file === void 0)
3164
- file = process.stderr;
3128
+ if (file === void 0) file = process.stderr;
3165
3129
  file.write(message);
3166
3130
  }
3167
3131
  }
@@ -3175,8 +3139,7 @@ var require_argparse = __commonJS({
3175
3139
  process.exit(status);
3176
3140
  }
3177
3141
  error(message) {
3178
- if (this.debug === true)
3179
- throw new Error(message);
3142
+ if (this.debug === true) throw new Error(message);
3180
3143
  this.print_usage(process.stderr);
3181
3144
  let args = { prog: this.prog, message };
3182
3145
  this.exit(2, sub("%(prog)s: error: %(message)s\n", args));
@@ -3229,19 +3192,19 @@ var require_argparse = __commonJS({
3229
3192
  });
3230
3193
 
3231
3194
  // src/index.ts
3232
- var import_fs = require("fs");
3233
- var import_path = __toESM(require("path"));
3234
- var import_puppeteer = __toESM(require("puppeteer"));
3195
+ var import_node_fs = require("node:fs");
3196
+ var import_node_path = __toESM(require("node:path"));
3235
3197
  var import_argparse = __toESM(require_argparse());
3198
+ var import_puppeteer = require("puppeteer");
3236
3199
  function normalizeUrl(url) {
3237
- if (url.match(/:\/\//)) {
3200
+ if (/:\/\//.exec(url)) {
3238
3201
  return url;
3239
3202
  } else {
3240
3203
  return `https://${url}`;
3241
3204
  }
3242
3205
  }
3243
3206
  async function run() {
3244
- const content = await import_fs.promises.readFile(import_path.default.join(__dirname, "../package.json"), "utf-8");
3207
+ const content = await import_node_fs.promises.readFile(import_node_path.default.join(__dirname, "../package.json"), "utf-8");
3245
3208
  const pkg = JSON.parse(content);
3246
3209
  const parser = new import_argparse.ArgumentParser({
3247
3210
  description: pkg.description
@@ -3252,7 +3215,7 @@ async function run() {
3252
3215
  parser.add_argument("url", { help: "URL to fetch", metavar: "URL" });
3253
3216
  const args = parser.parse_args();
3254
3217
  const url = normalizeUrl(args.url);
3255
- const browser = await import_puppeteer.default.launch({ headless: false });
3218
+ const browser = await (0, import_puppeteer.launch)({ headless: false });
3256
3219
  const page = await browser.newPage();
3257
3220
  await page.goto(url);
3258
3221
  const source = await page.content();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/puppeteer-fetch",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Fetch HTML source from a webpage using Chrome as backend",
5
5
  "keywords": [
6
6
  "puppeteer",
@@ -14,21 +14,23 @@
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://gitlab.com/html-validate/puppeteer-fetch.git"
17
+ "url": "git+https://gitlab.com/html-validate/puppeteer-fetch.git"
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "David Sveningsson <ext@sidvind.com>",
21
21
  "main": "dist/index.js",
22
- "bin": "puppeteer-fetch.js",
22
+ "bin": {
23
+ "puppeteer-fetch": "puppeteer-fetch.js"
24
+ },
23
25
  "files": [
24
26
  "dist",
25
27
  "puppeteer-fetch.js"
26
28
  ],
27
29
  "dependencies": {
28
- "puppeteer": "20.1.1"
30
+ "puppeteer": "24.29.1"
29
31
  },
30
32
  "engines": {
31
- "node": ">= 16",
33
+ "node": ">= 20",
32
34
  "npm": ">= 7"
33
35
  },
34
36
  "publishConfig": {