@purescraps/purehtml 0.6.0 → 0.7.0

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.
@@ -6417,7 +6417,7 @@ var require_ajv = __commonJS({
6417
6417
  });
6418
6418
 
6419
6419
  // examples/simple.ts
6420
- var import_fs = require("fs");
6420
+ var import_node_fs = require("fs");
6421
6421
 
6422
6422
  // src/backends/cheerio.ts
6423
6423
  var import_cheerio = require("cheerio");
@@ -6782,7 +6782,9 @@ var RemoveUrlQueryParam = class _RemoveUrlQueryParam extends Transformer {
6782
6782
  }
6783
6783
  if (args.length === 0) return val;
6784
6784
  const url = new URL(val);
6785
- args.forEach((paramName) => url.searchParams.delete(paramName));
6785
+ for (const paramName of args) {
6786
+ url.searchParams.delete(paramName);
6787
+ }
6786
6788
  return url.toString();
6787
6789
  }
6788
6790
  };
@@ -6867,15 +6869,18 @@ var UrlQueryParamTransformer = class _UrlQueryParamTransformer extends Transform
6867
6869
  if (args.length === 1) {
6868
6870
  return url.searchParams.get(args[0]);
6869
6871
  }
6870
- return args.reduce((acc, arg) => {
6871
- acc[arg] = url.searchParams.get(arg);
6872
- return acc;
6873
- }, {});
6872
+ return args.reduce(
6873
+ (acc, arg) => {
6874
+ acc[arg] = url.searchParams.get(arg);
6875
+ return acc;
6876
+ },
6877
+ {}
6878
+ );
6874
6879
  }
6875
6880
  };
6876
6881
 
6877
6882
  // src/transformers/transformers.ts
6878
- var Transformers = class {
6883
+ var Transformers = class _Transformers {
6879
6884
  static transformers = [
6880
6885
  AttributeTransformer,
6881
6886
  Exists,
@@ -6889,7 +6894,7 @@ var Transformers = class {
6889
6894
  UrlQueryParamTransformer
6890
6895
  ];
6891
6896
  static getByName(name) {
6892
- return this.transformers.find((tr) => tr.getName() === name);
6897
+ return _Transformers.transformers.find((tr) => tr.getName() === name);
6893
6898
  }
6894
6899
  };
6895
6900
 
@@ -7009,21 +7014,20 @@ var UnionConfig = class _UnionConfig extends Config {
7009
7014
  const $parent = params.$el;
7010
7015
  for (const config2 of this.configs) {
7011
7016
  if (config2 instanceof ConfigWithSelector) {
7012
- const $el = config2.getFirstMatch($parent, {
7017
+ const $matches = config2.getAllMatches($parent, {
7013
7018
  alreadyMatched: false,
7014
7019
  includeRoot: true
7015
7020
  });
7016
- if (!$el) {
7021
+ if (!$matches || Array.isArray($matches) && $matches.length === 0)
7017
7022
  continue;
7018
- }
7019
7023
  return config2.extract({
7020
7024
  ...params,
7021
- $el,
7022
- elementAlreadyMatched: true
7025
+ $el: Array.isArray($matches) ? $matches.length > 1 ? $parent : $matches[0] : $matches,
7026
+ // arrays must be matched again
7027
+ elementAlreadyMatched: !Array.isArray($matches) || $matches.length === 1
7023
7028
  });
7024
- } else {
7025
- return config2.extract({ ...params, $el: params.$el });
7026
7029
  }
7030
+ return config2.extract({ ...params, $el: params.$el });
7027
7031
  }
7028
7032
  return null;
7029
7033
  }
@@ -7321,9 +7325,9 @@ function extract(backend, $, config2, url) {
7321
7325
  }
7322
7326
 
7323
7327
  // examples/simple.ts
7324
- var html = (0, import_fs.readFileSync)("examples/simple.html").toString();
7328
+ var html = (0, import_node_fs.readFileSync)("examples/simple.html").toString();
7325
7329
  var config = ConfigFactory.fromYAML(
7326
- (0, import_fs.readFileSync)("examples/simple.yaml").toString()
7330
+ (0, import_node_fs.readFileSync)("examples/simple.yaml").toString()
7327
7331
  );
7328
7332
  console.log(
7329
7333
  "Simple parse result:",