@mavogel/cdk-vscode-server 0.0.54 → 0.0.56

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 (62) hide show
  1. package/.claude/hooks/file_checker.sh +0 -0
  2. package/.jsii +96 -24
  3. package/API.md +56 -0
  4. package/CLAUDE.md +84 -118
  5. package/README.md +48 -0
  6. package/assets/installer/installer.lambda/index.js +14 -2
  7. package/examples/custom-domain/main.ts +49 -0
  8. package/integ-tests/integ.al2023.ts.snapshot/IntegSetupVSCodeOnAl2023DefaultTestDeployAssert74D8F645.assets.json +7 -6
  9. package/integ-tests/integ.al2023.ts.snapshot/IntegSetupVSCodeOnAl2023DefaultTestDeployAssert74D8F645.template.json +6 -6
  10. package/integ-tests/integ.al2023.ts.snapshot/IntegTestStackAl2023.assets.json +20 -12
  11. package/integ-tests/integ.al2023.ts.snapshot/IntegTestStackAl2023.template.json +36 -152
  12. package/integ-tests/integ.al2023.ts.snapshot/{asset.23732f3d1982f7fb0da3bd6638a8107337bb767fea165b45eae12000a1dd67ce → asset.0ad50fc42afd768c3d0bfdd4701e43284fb077a25f19eea1e8c51a5ca36ebfe4}/index.js +988 -1165
  13. package/integ-tests/{integ.ubuntu.ts.snapshot/asset.a9865c9d36c7aa999e28cb7926e7a3a8e0b6d0854b25131a172024c5777442fa.lambda → integ.al2023.ts.snapshot/asset.33da23274e25bd9f43638c5d83dad26e3931cbe78d462ffd9a9f565e948b4f5f.lambda}/index.js +14 -2
  14. package/integ-tests/{integ.ubuntu.ts.snapshot/asset.f692c9f68e4daba2abc99103efd3518bced1e9d7a2a89847b9b5d5473c64f1bd.bundle → integ.al2023.ts.snapshot/asset.530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.bundle}/index.js +296 -191
  15. package/integ-tests/{integ.ubuntu.ts.snapshot/asset.ce2f3595a340d6c519a65888ef97e3b9b64f053f83608e32cc28162e22d7d99a → integ.al2023.ts.snapshot/asset.9d043014be736e8162bcc7ec5590cc6d2ff24fd0d9c73a5c5d595151c5fdad00}/index.js +1 -1
  16. package/integ-tests/integ.al2023.ts.snapshot/cdk.out +1 -1
  17. package/integ-tests/integ.al2023.ts.snapshot/integ.json +4 -3
  18. package/integ-tests/integ.al2023.ts.snapshot/manifest.json +956 -7
  19. package/integ-tests/integ.al2023.ts.snapshot/tree.json +1 -3228
  20. package/integ-tests/integ.custom-domain.ts +87 -0
  21. package/integ-tests/integ.custom-domain.ts.snapshot/IntegSetupVSCodeOnCustomDomainDefaultTestDeployAssert6982D514.assets.json +33 -0
  22. package/integ-tests/integ.custom-domain.ts.snapshot/IntegSetupVSCodeOnCustomDomainDefaultTestDeployAssert6982D514.template.json +333 -0
  23. package/integ-tests/integ.custom-domain.ts.snapshot/IntegTestStackCustomDomain.assets.json +132 -0
  24. package/integ-tests/integ.custom-domain.ts.snapshot/IntegTestStackCustomDomain.template.json +2862 -0
  25. package/integ-tests/{integ.ubuntu.ts.snapshot/asset.23732f3d1982f7fb0da3bd6638a8107337bb767fea165b45eae12000a1dd67ce → integ.custom-domain.ts.snapshot/asset.0ad50fc42afd768c3d0bfdd4701e43284fb077a25f19eea1e8c51a5ca36ebfe4}/index.js +988 -1165
  26. package/integ-tests/integ.custom-domain.ts.snapshot/asset.2819175352ad1ce0dae768e83fc328fb70fb5f10b4a8ff0ccbcb791f02b0716d/index.js +1 -0
  27. package/integ-tests/{integ.al2023.ts.snapshot/asset.a9865c9d36c7aa999e28cb7926e7a3a8e0b6d0854b25131a172024c5777442fa.lambda → integ.custom-domain.ts.snapshot/asset.33da23274e25bd9f43638c5d83dad26e3931cbe78d462ffd9a9f565e948b4f5f.lambda}/index.js +14 -2
  28. package/integ-tests/{integ.al2023.ts.snapshot/asset.f692c9f68e4daba2abc99103efd3518bced1e9d7a2a89847b9b5d5473c64f1bd.bundle → integ.custom-domain.ts.snapshot/asset.530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.bundle}/index.js +296 -191
  29. package/integ-tests/integ.custom-domain.ts.snapshot/asset.781ab0ab74634cdaf61539ab208ab777829ef07097ac21f95b9e15a3b1eedc1b.lambda/index.js +57 -0
  30. package/integ-tests/integ.custom-domain.ts.snapshot/asset.7fa1e366ee8a9ded01fc355f704cff92bfd179574e6f9cfee800a3541df1b200/__entrypoint__.js +1 -0
  31. package/integ-tests/integ.custom-domain.ts.snapshot/asset.7fa1e366ee8a9ded01fc355f704cff92bfd179574e6f9cfee800a3541df1b200/index.js +1 -0
  32. package/integ-tests/{integ.al2023.ts.snapshot/asset.ce2f3595a340d6c519a65888ef97e3b9b64f053f83608e32cc28162e22d7d99a → integ.custom-domain.ts.snapshot/asset.9d043014be736e8162bcc7ec5590cc6d2ff24fd0d9c73a5c5d595151c5fdad00}/index.js +1 -1
  33. package/integ-tests/integ.custom-domain.ts.snapshot/asset.b073cebcf4d61fb152a30f5a5e57a94df7f980a549fdf1a79a0b18c5750522d8/index.js +1 -0
  34. package/integ-tests/integ.custom-domain.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/cfn-response.js +1 -0
  35. package/integ-tests/integ.custom-domain.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/consts.js +1 -0
  36. package/integ-tests/integ.custom-domain.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/framework.js +3 -0
  37. package/integ-tests/integ.custom-domain.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/outbound.js +1 -0
  38. package/integ-tests/integ.custom-domain.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/util.js +1 -0
  39. package/integ-tests/integ.custom-domain.ts.snapshot/integ.json +23 -0
  40. package/integ-tests/integ.custom-domain.ts.snapshot/manifest.json +1653 -0
  41. package/integ-tests/integ.custom-domain.ts.snapshot/tree.json +1 -0
  42. package/integ-tests/integ.ubuntu.ts.snapshot/IntegSetupVSCodeOnUbuntuDefaultTestDeployAssertFF8DF2C5.assets.json +7 -6
  43. package/integ-tests/integ.ubuntu.ts.snapshot/IntegSetupVSCodeOnUbuntuDefaultTestDeployAssertFF8DF2C5.template.json +6 -6
  44. package/integ-tests/integ.ubuntu.ts.snapshot/IntegTestStackUbuntu22.assets.json +20 -12
  45. package/integ-tests/integ.ubuntu.ts.snapshot/IntegTestStackUbuntu22.template.json +36 -72
  46. package/integ-tests/integ.ubuntu.ts.snapshot/asset.0ad50fc42afd768c3d0bfdd4701e43284fb077a25f19eea1e8c51a5ca36ebfe4/index.js +5992 -0
  47. package/integ-tests/integ.ubuntu.ts.snapshot/asset.33da23274e25bd9f43638c5d83dad26e3931cbe78d462ffd9a9f565e948b4f5f.lambda/index.js +143 -0
  48. package/integ-tests/integ.ubuntu.ts.snapshot/asset.530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.bundle/index.js +30676 -0
  49. package/integ-tests/integ.ubuntu.ts.snapshot/asset.9d043014be736e8162bcc7ec5590cc6d2ff24fd0d9c73a5c5d595151c5fdad00/index.js +1 -0
  50. package/integ-tests/integ.ubuntu.ts.snapshot/cdk.out +1 -1
  51. package/integ-tests/integ.ubuntu.ts.snapshot/integ.json +3 -2
  52. package/integ-tests/integ.ubuntu.ts.snapshot/manifest.json +956 -7
  53. package/integ-tests/integ.ubuntu.ts.snapshot/tree.json +1 -3070
  54. package/lib/installer/installer.d.ts +7 -0
  55. package/lib/installer/installer.js +15 -7
  56. package/lib/installer/installer.lambda.js +20 -3
  57. package/lib/vscode-server.d.ts +33 -0
  58. package/lib/vscode-server.js +165 -5
  59. package/mavogelcdkvscodeserver/go.mod +1 -1
  60. package/mavogelcdkvscodeserver/jsii/jsii.go +2 -2
  61. package/mavogelcdkvscodeserver/version +1 -1
  62. package/package.json +4 -4
@@ -286,53 +286,40 @@ var require_node = __commonJS({
286
286
  "use strict";
287
287
  Object.defineProperty(exports2, "__esModule", { value: true });
288
288
  var he_1 = require_he();
289
- var Node = (
290
- /** @class */
291
- function() {
292
- function Node2(parentNode, range) {
293
- if (parentNode === void 0) {
294
- parentNode = null;
295
- }
296
- this.parentNode = parentNode;
297
- this.childNodes = [];
298
- Object.defineProperty(this, "range", {
299
- enumerable: false,
300
- writable: true,
301
- configurable: true,
302
- value: range !== null && range !== void 0 ? range : [-1, -1]
303
- });
304
- }
305
- Node2.prototype.remove = function() {
306
- var _this = this;
307
- if (this.parentNode) {
308
- var children = this.parentNode.childNodes;
309
- this.parentNode.childNodes = children.filter(function(child) {
310
- return _this !== child;
311
- });
312
- this.parentNode = null;
313
- }
314
- return this;
315
- };
316
- Object.defineProperty(Node2.prototype, "innerText", {
317
- get: function() {
318
- return this.rawText;
319
- },
320
- enumerable: false,
321
- configurable: true
322
- });
323
- Object.defineProperty(Node2.prototype, "textContent", {
324
- get: function() {
325
- return (0, he_1.decode)(this.rawText);
326
- },
327
- set: function(val) {
328
- this.rawText = (0, he_1.encode)(val);
329
- },
289
+ var Node = class {
290
+ constructor(parentNode = null, range) {
291
+ this.parentNode = parentNode;
292
+ this.childNodes = [];
293
+ Object.defineProperty(this, "range", {
330
294
  enumerable: false,
331
- configurable: true
295
+ writable: true,
296
+ configurable: true,
297
+ value: range !== null && range !== void 0 ? range : [-1, -1]
332
298
  });
333
- return Node2;
334
- }()
335
- );
299
+ }
300
+ /**
301
+ * Remove current node
302
+ */
303
+ remove() {
304
+ if (this.parentNode) {
305
+ const children = this.parentNode.childNodes;
306
+ this.parentNode.childNodes = children.filter((child) => {
307
+ return this !== child;
308
+ });
309
+ this.parentNode = null;
310
+ }
311
+ return this;
312
+ }
313
+ get innerText() {
314
+ return this.rawText;
315
+ }
316
+ get textContent() {
317
+ return (0, he_1.decode)(this.rawText);
318
+ }
319
+ set textContent(val) {
320
+ this.rawText = (0, he_1.encode)(val);
321
+ }
322
+ };
336
323
  exports2.default = Node;
337
324
  }
338
325
  });
@@ -356,68 +343,33 @@ var require_type = __commonJS({
356
343
  var require_comment = __commonJS({
357
344
  "node_modules/node-html-parser/dist/nodes/comment.js"(exports2) {
358
345
  "use strict";
359
- var __extends = exports2 && exports2.__extends || /* @__PURE__ */ function() {
360
- var extendStatics = function(d, b) {
361
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
362
- d2.__proto__ = b2;
363
- } || function(d2, b2) {
364
- for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
365
- };
366
- return extendStatics(d, b);
367
- };
368
- return function(d, b) {
369
- if (typeof b !== "function" && b !== null)
370
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
371
- extendStatics(d, b);
372
- function __() {
373
- this.constructor = d;
374
- }
375
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
376
- };
377
- }();
378
346
  var __importDefault = exports2 && exports2.__importDefault || function(mod) {
379
347
  return mod && mod.__esModule ? mod : { "default": mod };
380
348
  };
381
349
  Object.defineProperty(exports2, "__esModule", { value: true });
382
350
  var node_1 = __importDefault(require_node());
383
351
  var type_1 = __importDefault(require_type());
384
- var CommentNode = (
385
- /** @class */
386
- function(_super) {
387
- __extends(CommentNode2, _super);
388
- function CommentNode2(rawText, parentNode, range, rawTagName) {
389
- if (parentNode === void 0) {
390
- parentNode = null;
391
- }
392
- if (rawTagName === void 0) {
393
- rawTagName = "!--";
394
- }
395
- var _this = _super.call(this, parentNode, range) || this;
396
- _this.rawText = rawText;
397
- _this.rawTagName = rawTagName;
398
- _this.nodeType = type_1.default.COMMENT_NODE;
399
- return _this;
400
- }
401
- CommentNode2.prototype.clone = function() {
402
- return new CommentNode2(this.rawText, null, void 0, this.rawTagName);
403
- };
404
- Object.defineProperty(CommentNode2.prototype, "text", {
405
- /**
406
- * Get unescaped text value of current node and its children.
407
- * @return {string} text content
408
- */
409
- get: function() {
410
- return this.rawText;
411
- },
412
- enumerable: false,
413
- configurable: true
414
- });
415
- CommentNode2.prototype.toString = function() {
416
- return "<!--".concat(this.rawText, "-->");
417
- };
418
- return CommentNode2;
419
- }(node_1.default)
420
- );
352
+ var CommentNode = class _CommentNode extends node_1.default {
353
+ clone() {
354
+ return new _CommentNode(this.rawText, null, void 0, this.rawTagName);
355
+ }
356
+ constructor(rawText, parentNode = null, range, rawTagName = "!--") {
357
+ super(parentNode, range);
358
+ this.rawText = rawText;
359
+ this.rawTagName = rawTagName;
360
+ this.nodeType = type_1.default.COMMENT_NODE;
361
+ }
362
+ /**
363
+ * Get unescaped text value of current node and its children.
364
+ * @return {string} text content
365
+ */
366
+ get text() {
367
+ return this.rawText;
368
+ }
369
+ toString() {
370
+ return `<!--${this.rawText}-->`;
371
+ }
372
+ };
421
373
  exports2.default = CommentNode;
422
374
  }
423
375
  });
@@ -460,7 +412,7 @@ var require_lib = __commonJS({
460
412
  var require_node2 = __commonJS({
461
413
  "node_modules/domhandler/lib/node.js"(exports2) {
462
414
  "use strict";
463
- var __extends = exports2 && exports2.__extends || /* @__PURE__ */ function() {
415
+ var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
464
416
  var extendStatics = function(d, b) {
465
417
  extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
466
418
  d2.__proto__ = b2;
@@ -478,7 +430,7 @@ var require_node2 = __commonJS({
478
430
  }
479
431
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
480
432
  };
481
- }();
433
+ })();
482
434
  var __assign = exports2 && exports2.__assign || function() {
483
435
  __assign = Object.assign || function(t) {
484
436
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -495,7 +447,7 @@ var require_node2 = __commonJS({
495
447
  var domelementtype_1 = require_lib();
496
448
  var Node = (
497
449
  /** @class */
498
- function() {
450
+ (function() {
499
451
  function Node2() {
500
452
  this.parent = null;
501
453
  this.prev = null;
@@ -553,12 +505,12 @@ var require_node2 = __commonJS({
553
505
  return cloneNode(this, recursive);
554
506
  };
555
507
  return Node2;
556
- }()
508
+ })()
557
509
  );
558
510
  exports2.Node = Node;
559
511
  var DataNode = (
560
512
  /** @class */
561
- function(_super) {
513
+ (function(_super) {
562
514
  __extends(DataNode2, _super);
563
515
  function DataNode2(data) {
564
516
  var _this = _super.call(this) || this;
@@ -580,12 +532,12 @@ var require_node2 = __commonJS({
580
532
  configurable: true
581
533
  });
582
534
  return DataNode2;
583
- }(Node)
535
+ })(Node)
584
536
  );
585
537
  exports2.DataNode = DataNode;
586
538
  var Text = (
587
539
  /** @class */
588
- function(_super) {
540
+ (function(_super) {
589
541
  __extends(Text2, _super);
590
542
  function Text2() {
591
543
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -600,12 +552,12 @@ var require_node2 = __commonJS({
600
552
  configurable: true
601
553
  });
602
554
  return Text2;
603
- }(DataNode)
555
+ })(DataNode)
604
556
  );
605
557
  exports2.Text = Text;
606
558
  var Comment = (
607
559
  /** @class */
608
- function(_super) {
560
+ (function(_super) {
609
561
  __extends(Comment2, _super);
610
562
  function Comment2() {
611
563
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -620,12 +572,12 @@ var require_node2 = __commonJS({
620
572
  configurable: true
621
573
  });
622
574
  return Comment2;
623
- }(DataNode)
575
+ })(DataNode)
624
576
  );
625
577
  exports2.Comment = Comment;
626
578
  var ProcessingInstruction = (
627
579
  /** @class */
628
- function(_super) {
580
+ (function(_super) {
629
581
  __extends(ProcessingInstruction2, _super);
630
582
  function ProcessingInstruction2(name, data) {
631
583
  var _this = _super.call(this, data) || this;
@@ -641,12 +593,12 @@ var require_node2 = __commonJS({
641
593
  configurable: true
642
594
  });
643
595
  return ProcessingInstruction2;
644
- }(DataNode)
596
+ })(DataNode)
645
597
  );
646
598
  exports2.ProcessingInstruction = ProcessingInstruction;
647
599
  var NodeWithChildren = (
648
600
  /** @class */
649
- function(_super) {
601
+ (function(_super) {
650
602
  __extends(NodeWithChildren2, _super);
651
603
  function NodeWithChildren2(children) {
652
604
  var _this = _super.call(this) || this;
@@ -686,12 +638,12 @@ var require_node2 = __commonJS({
686
638
  configurable: true
687
639
  });
688
640
  return NodeWithChildren2;
689
- }(Node)
641
+ })(Node)
690
642
  );
691
643
  exports2.NodeWithChildren = NodeWithChildren;
692
644
  var CDATA = (
693
645
  /** @class */
694
- function(_super) {
646
+ (function(_super) {
695
647
  __extends(CDATA2, _super);
696
648
  function CDATA2() {
697
649
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -706,12 +658,12 @@ var require_node2 = __commonJS({
706
658
  configurable: true
707
659
  });
708
660
  return CDATA2;
709
- }(NodeWithChildren)
661
+ })(NodeWithChildren)
710
662
  );
711
663
  exports2.CDATA = CDATA;
712
664
  var Document = (
713
665
  /** @class */
714
- function(_super) {
666
+ (function(_super) {
715
667
  __extends(Document2, _super);
716
668
  function Document2() {
717
669
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -726,12 +678,12 @@ var require_node2 = __commonJS({
726
678
  configurable: true
727
679
  });
728
680
  return Document2;
729
- }(NodeWithChildren)
681
+ })(NodeWithChildren)
730
682
  );
731
683
  exports2.Document = Document;
732
684
  var Element = (
733
685
  /** @class */
734
- function(_super) {
686
+ (function(_super) {
735
687
  __extends(Element2, _super);
736
688
  function Element2(name, attribs, children, type) {
737
689
  if (children === void 0) {
@@ -785,7 +737,7 @@ var require_node2 = __commonJS({
785
737
  configurable: true
786
738
  });
787
739
  return Element2;
788
- }(NodeWithChildren)
740
+ })(NodeWithChildren)
789
741
  );
790
742
  exports2.Element = Element;
791
743
  function isTag(node) {
@@ -894,7 +846,7 @@ var require_node2 = __commonJS({
894
846
  var require_lib2 = __commonJS({
895
847
  "node_modules/domhandler/lib/index.js"(exports2) {
896
848
  "use strict";
897
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
849
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
898
850
  if (k2 === void 0) k2 = k;
899
851
  var desc = Object.getOwnPropertyDescriptor(m, k);
900
852
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -903,10 +855,10 @@ var require_lib2 = __commonJS({
903
855
  } };
904
856
  }
905
857
  Object.defineProperty(o, k2, desc);
906
- } : function(o, m, k, k2) {
858
+ }) : (function(o, m, k, k2) {
907
859
  if (k2 === void 0) k2 = k;
908
860
  o[k2] = m[k];
909
- });
861
+ }));
910
862
  var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
911
863
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
912
864
  };
@@ -922,7 +874,7 @@ var require_lib2 = __commonJS({
922
874
  };
923
875
  var DomHandler = (
924
876
  /** @class */
925
- function() {
877
+ (function() {
926
878
  function DomHandler2(callback, options, elementCB) {
927
879
  this.dom = [];
928
880
  this.root = new node_js_1.Document(this.dom);
@@ -1042,7 +994,7 @@ var require_lib2 = __commonJS({
1042
994
  this.lastNode = null;
1043
995
  };
1044
996
  return DomHandler2;
1045
- }()
997
+ })()
1046
998
  );
1047
999
  exports2.DomHandler = DomHandler;
1048
1000
  exports2.default = DomHandler;
@@ -1145,7 +1097,7 @@ var require_decode_codepoint = __commonJS({
1145
1097
  var require_decode = __commonJS({
1146
1098
  "node_modules/entities/lib/decode.js"(exports2) {
1147
1099
  "use strict";
1148
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
1100
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
1149
1101
  if (k2 === void 0) k2 = k;
1150
1102
  var desc = Object.getOwnPropertyDescriptor(m, k);
1151
1103
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -1154,13 +1106,13 @@ var require_decode = __commonJS({
1154
1106
  } };
1155
1107
  }
1156
1108
  Object.defineProperty(o, k2, desc);
1157
- } : function(o, m, k, k2) {
1109
+ }) : (function(o, m, k, k2) {
1158
1110
  if (k2 === void 0) k2 = k;
1159
1111
  o[k2] = m[k];
1160
- });
1161
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
1112
+ }));
1113
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
1162
1114
  Object.defineProperty(o, "default", { enumerable: true, value: v });
1163
- } : function(o, v) {
1115
+ }) : function(o, v) {
1164
1116
  o["default"] = v;
1165
1117
  });
1166
1118
  var __importStar = exports2 && exports2.__importStar || function(mod) {
@@ -1240,7 +1192,7 @@ var require_decode = __commonJS({
1240
1192
  })(DecodingMode = exports2.DecodingMode || (exports2.DecodingMode = {}));
1241
1193
  var EntityDecoder = (
1242
1194
  /** @class */
1243
- function() {
1195
+ (function() {
1244
1196
  function EntityDecoder2(decodeTree, emitCodePoint, errors) {
1245
1197
  this.decodeTree = decodeTree;
1246
1198
  this.emitCodePoint = emitCodePoint;
@@ -1419,7 +1371,7 @@ var require_decode = __commonJS({
1419
1371
  }
1420
1372
  };
1421
1373
  return EntityDecoder2;
1422
- }()
1374
+ })()
1423
1375
  );
1424
1376
  exports2.EntityDecoder = EntityDecoder;
1425
1377
  function getDecoder(decodeTree) {
@@ -1901,7 +1853,7 @@ var require_lib4 = __commonJS({
1901
1853
  };
1902
1854
  return __assign.apply(this, arguments);
1903
1855
  };
1904
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
1856
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
1905
1857
  if (k2 === void 0) k2 = k;
1906
1858
  var desc = Object.getOwnPropertyDescriptor(m, k);
1907
1859
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -1910,13 +1862,13 @@ var require_lib4 = __commonJS({
1910
1862
  } };
1911
1863
  }
1912
1864
  Object.defineProperty(o, k2, desc);
1913
- } : function(o, m, k, k2) {
1865
+ }) : (function(o, m, k, k2) {
1914
1866
  if (k2 === void 0) k2 = k;
1915
1867
  o[k2] = m[k];
1916
- });
1917
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
1868
+ }));
1869
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
1918
1870
  Object.defineProperty(o, "default", { enumerable: true, value: v });
1919
- } : function(o, v) {
1871
+ }) : function(o, v) {
1920
1872
  o["default"] = v;
1921
1873
  });
1922
1874
  var __importStar = exports2 && exports2.__importStar || function(mod) {
@@ -2762,7 +2714,7 @@ var require_feeds = __commonJS({
2762
2714
  var require_lib5 = __commonJS({
2763
2715
  "node_modules/domutils/lib/index.js"(exports2) {
2764
2716
  "use strict";
2765
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
2717
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
2766
2718
  if (k2 === void 0) k2 = k;
2767
2719
  var desc = Object.getOwnPropertyDescriptor(m, k);
2768
2720
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -2771,10 +2723,10 @@ var require_lib5 = __commonJS({
2771
2723
  } };
2772
2724
  }
2773
2725
  Object.defineProperty(o, k2, desc);
2774
- } : function(o, m, k, k2) {
2726
+ }) : (function(o, m, k, k2) {
2775
2727
  if (k2 === void 0) k2 = k;
2776
2728
  o[k2] = m[k];
2777
- });
2729
+ }));
2778
2730
  var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
2779
2731
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
2780
2732
  };
@@ -3346,7 +3298,7 @@ var require_stringify2 = __commonJS({
3346
3298
  var require_commonjs = __commonJS({
3347
3299
  "node_modules/css-what/lib/commonjs/index.js"(exports2) {
3348
3300
  "use strict";
3349
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
3301
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
3350
3302
  if (k2 === void 0) k2 = k;
3351
3303
  var desc = Object.getOwnPropertyDescriptor(m, k);
3352
3304
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -3355,10 +3307,10 @@ var require_commonjs = __commonJS({
3355
3307
  } };
3356
3308
  }
3357
3309
  Object.defineProperty(o, k2, desc);
3358
- } : function(o, m, k, k2) {
3310
+ }) : (function(o, m, k, k2) {
3359
3311
  if (k2 === void 0) k2 = k;
3360
3312
  o[k2] = m[k];
3361
- });
3313
+ }));
3362
3314
  var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
3363
3315
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
3364
3316
  };
@@ -4408,7 +4360,7 @@ var require_general = __commonJS({
4408
4360
  var require_compile2 = __commonJS({
4409
4361
  "node_modules/css-select/lib/compile.js"(exports2) {
4410
4362
  "use strict";
4411
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
4363
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
4412
4364
  if (k2 === void 0) k2 = k;
4413
4365
  var desc = Object.getOwnPropertyDescriptor(m, k);
4414
4366
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -4417,13 +4369,13 @@ var require_compile2 = __commonJS({
4417
4369
  } };
4418
4370
  }
4419
4371
  Object.defineProperty(o, k2, desc);
4420
- } : function(o, m, k, k2) {
4372
+ }) : (function(o, m, k, k2) {
4421
4373
  if (k2 === void 0) k2 = k;
4422
4374
  o[k2] = m[k];
4423
- });
4424
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
4375
+ }));
4376
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
4425
4377
  Object.defineProperty(o, "default", { enumerable: true, value: v });
4426
- } : function(o, v) {
4378
+ }) : function(o, v) {
4427
4379
  o["default"] = v;
4428
4380
  });
4429
4381
  var __importStar = exports2 && exports2.__importStar || function(mod) {
@@ -4540,7 +4492,7 @@ var require_compile2 = __commonJS({
4540
4492
  var require_lib7 = __commonJS({
4541
4493
  "node_modules/css-select/lib/index.js"(exports2) {
4542
4494
  "use strict";
4543
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
4495
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
4544
4496
  if (k2 === void 0) k2 = k;
4545
4497
  var desc = Object.getOwnPropertyDescriptor(m, k);
4546
4498
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -4549,13 +4501,13 @@ var require_lib7 = __commonJS({
4549
4501
  } };
4550
4502
  }
4551
4503
  Object.defineProperty(o, k2, desc);
4552
- } : function(o, m, k, k2) {
4504
+ }) : (function(o, m, k, k2) {
4553
4505
  if (k2 === void 0) k2 = k;
4554
4506
  o[k2] = m[k];
4555
- });
4556
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
4507
+ }));
4508
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
4557
4509
  Object.defineProperty(o, "default", { enumerable: true, value: v });
4558
- } : function(o, v) {
4510
+ }) : function(o, v) {
4559
4511
  o["default"] = v;
4560
4512
  });
4561
4513
  var __importStar = exports2 && exports2.__importStar || function(mod) {
@@ -4693,10 +4645,10 @@ var require_matcher = __commonJS({
4693
4645
  return node.text;
4694
4646
  }
4695
4647
  function removeSubsets(nodes) {
4696
- var idx = nodes.length;
4697
- var node;
4698
- var ancestor;
4699
- var replace;
4648
+ let idx = nodes.length;
4649
+ let node;
4650
+ let ancestor;
4651
+ let replace;
4700
4652
  while (--idx > -1) {
4701
4653
  node = ancestor = nodes[idx];
4702
4654
  nodes[idx] = null;
@@ -4716,25 +4668,25 @@ var require_matcher = __commonJS({
4716
4668
  return nodes;
4717
4669
  }
4718
4670
  function existsOne(test, elems) {
4719
- return elems.some(function(elem) {
4671
+ return elems.some((elem) => {
4720
4672
  return isTag(elem) ? test(elem) || existsOne(test, getChildren(elem)) : false;
4721
4673
  });
4722
4674
  }
4723
4675
  function getSiblings(node) {
4724
- var parent = getParent(node);
4676
+ const parent = getParent(node);
4725
4677
  return parent ? getChildren(parent) : [];
4726
4678
  }
4727
4679
  function hasAttrib(elem, name) {
4728
4680
  return getAttributeValue(elem, name) !== void 0;
4729
4681
  }
4730
4682
  function findOne(test, elems) {
4731
- var elem = null;
4732
- for (var i = 0, l = elems === null || elems === void 0 ? void 0 : elems.length; i < l && !elem; i++) {
4733
- var el = elems[i];
4683
+ let elem = null;
4684
+ for (let i = 0, l = elems === null || elems === void 0 ? void 0 : elems.length; i < l && !elem; i++) {
4685
+ const el = elems[i];
4734
4686
  if (test(el)) {
4735
4687
  elem = el;
4736
4688
  } else {
4737
- var childs = getChildren(el);
4689
+ const childs = getChildren(el);
4738
4690
  if (childs && childs.length > 0) {
4739
4691
  elem = findOne(test, childs);
4740
4692
  }
@@ -4743,13 +4695,13 @@ var require_matcher = __commonJS({
4743
4695
  return elem;
4744
4696
  }
4745
4697
  function findAll(test, nodes) {
4746
- var result = [];
4747
- for (var i = 0, j = nodes.length; i < j; i++) {
4698
+ let result = [];
4699
+ for (let i = 0, j = nodes.length; i < j; i++) {
4748
4700
  if (!isTag(nodes[i]))
4749
4701
  continue;
4750
4702
  if (test(nodes[i]))
4751
4703
  result.push(nodes[i]);
4752
- var childs = getChildren(nodes[i]);
4704
+ const childs = getChildren(nodes[i]);
4753
4705
  if (childs)
4754
4706
  result = result.concat(findAll(test, childs));
4755
4707
  }
@@ -4777,36 +4729,29 @@ var require_void_tag = __commonJS({
4777
4729
  "node_modules/node-html-parser/dist/void-tag.js"(exports2) {
4778
4730
  "use strict";
4779
4731
  Object.defineProperty(exports2, "__esModule", { value: true });
4780
- var VoidTag = (
4781
- /** @class */
4782
- function() {
4783
- function VoidTag2(addClosingSlash, tags) {
4784
- if (addClosingSlash === void 0) {
4785
- addClosingSlash = false;
4786
- }
4787
- this.addClosingSlash = addClosingSlash;
4788
- if (Array.isArray(tags)) {
4789
- this.voidTags = tags.reduce(function(set, tag) {
4790
- return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
4791
- }, /* @__PURE__ */ new Set());
4792
- } else {
4793
- this.voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"].reduce(function(set, tag) {
4794
- return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
4795
- }, /* @__PURE__ */ new Set());
4796
- }
4732
+ var VoidTag = class {
4733
+ constructor(addClosingSlash = false, tags) {
4734
+ this.addClosingSlash = addClosingSlash;
4735
+ if (Array.isArray(tags)) {
4736
+ this.voidTags = tags.reduce((set, tag) => {
4737
+ return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
4738
+ }, /* @__PURE__ */ new Set());
4739
+ } else {
4740
+ this.voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"].reduce((set, tag) => {
4741
+ return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
4742
+ }, /* @__PURE__ */ new Set());
4797
4743
  }
4798
- VoidTag2.prototype.formatNode = function(tag, attrs, innerHTML) {
4799
- var addClosingSlash = this.addClosingSlash;
4800
- var closingSpace = addClosingSlash && attrs && !attrs.endsWith(" ") ? " " : "";
4801
- var closingSlash = addClosingSlash ? "".concat(closingSpace, "/") : "";
4802
- return this.isVoidElement(tag.toLowerCase()) ? "<".concat(tag).concat(attrs).concat(closingSlash, ">") : "<".concat(tag).concat(attrs, ">").concat(innerHTML, "</").concat(tag, ">");
4803
- };
4804
- VoidTag2.prototype.isVoidElement = function(tag) {
4805
- return this.voidTags.has(tag);
4806
- };
4807
- return VoidTag2;
4808
- }()
4809
- );
4744
+ }
4745
+ formatNode(tag, attrs, innerHTML) {
4746
+ const addClosingSlash = this.addClosingSlash;
4747
+ const closingSpace = addClosingSlash && attrs && !attrs.endsWith(" ") ? " " : "";
4748
+ const closingSlash = addClosingSlash ? `${closingSpace}/` : "";
4749
+ return this.isVoidElement(tag.toLowerCase()) ? `<${tag}${attrs}${closingSlash}>` : `<${tag}${attrs}>${innerHTML}</${tag}>`;
4750
+ }
4751
+ isVoidElement(tag) {
4752
+ return this.voidTags.has(tag);
4753
+ }
4754
+ };
4810
4755
  exports2.default = VoidTag;
4811
4756
  }
4812
4757
  });
@@ -4815,25 +4760,6 @@ var require_void_tag = __commonJS({
4815
4760
  var require_text = __commonJS({
4816
4761
  "node_modules/node-html-parser/dist/nodes/text.js"(exports2) {
4817
4762
  "use strict";
4818
- var __extends = exports2 && exports2.__extends || /* @__PURE__ */ function() {
4819
- var extendStatics = function(d, b) {
4820
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
4821
- d2.__proto__ = b2;
4822
- } || function(d2, b2) {
4823
- for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
4824
- };
4825
- return extendStatics(d, b);
4826
- };
4827
- return function(d, b) {
4828
- if (typeof b !== "function" && b !== null)
4829
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4830
- extendStatics(d, b);
4831
- function __() {
4832
- this.constructor = d;
4833
- }
4834
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4835
- };
4836
- }();
4837
4763
  var __importDefault = exports2 && exports2.__importDefault || function(mod) {
4838
4764
  return mod && mod.__esModule ? mod : { "default": mod };
4839
4765
  };
@@ -4841,97 +4767,68 @@ var require_text = __commonJS({
4841
4767
  var he_1 = require_he();
4842
4768
  var node_1 = __importDefault(require_node());
4843
4769
  var type_1 = __importDefault(require_type());
4844
- var TextNode = (
4845
- /** @class */
4846
- function(_super) {
4847
- __extends(TextNode2, _super);
4848
- function TextNode2(rawText, parentNode, range) {
4849
- if (parentNode === void 0) {
4850
- parentNode = null;
4851
- }
4852
- var _this = _super.call(this, parentNode, range) || this;
4853
- _this.nodeType = type_1.default.TEXT_NODE;
4854
- _this.rawTagName = "";
4855
- _this._rawText = rawText;
4856
- return _this;
4857
- }
4858
- TextNode2.prototype.clone = function() {
4859
- return new TextNode2(this._rawText, null);
4860
- };
4861
- Object.defineProperty(TextNode2.prototype, "rawText", {
4862
- get: function() {
4863
- return this._rawText;
4864
- },
4865
- /**
4866
- * Set rawText and invalidate trimmed caches
4867
- */
4868
- set: function(text) {
4869
- this._rawText = text;
4870
- this._trimmedRawText = void 0;
4871
- this._trimmedText = void 0;
4872
- },
4873
- enumerable: false,
4874
- configurable: true
4875
- });
4876
- Object.defineProperty(TextNode2.prototype, "trimmedRawText", {
4877
- /**
4878
- * Returns raw text with all whitespace trimmed except single leading/trailing non-breaking space
4879
- */
4880
- get: function() {
4881
- if (this._trimmedRawText !== void 0)
4882
- return this._trimmedRawText;
4883
- this._trimmedRawText = trimText(this.rawText);
4884
- return this._trimmedRawText;
4885
- },
4886
- enumerable: false,
4887
- configurable: true
4888
- });
4889
- Object.defineProperty(TextNode2.prototype, "trimmedText", {
4890
- /**
4891
- * Returns text with all whitespace trimmed except single leading/trailing non-breaking space
4892
- */
4893
- get: function() {
4894
- if (this._trimmedText !== void 0)
4895
- return this._trimmedText;
4896
- this._trimmedText = trimText(this.text);
4897
- return this._trimmedText;
4898
- },
4899
- enumerable: false,
4900
- configurable: true
4901
- });
4902
- Object.defineProperty(TextNode2.prototype, "text", {
4903
- /**
4904
- * Get unescaped text value of current node and its children.
4905
- * @return {string} text content
4906
- */
4907
- get: function() {
4908
- return (0, he_1.decode)(this.rawText);
4909
- },
4910
- enumerable: false,
4911
- configurable: true
4912
- });
4913
- Object.defineProperty(TextNode2.prototype, "isWhitespace", {
4914
- /**
4915
- * Detect if the node contains only white space.
4916
- * @return {boolean}
4917
- */
4918
- get: function() {
4919
- return /^(\s|&nbsp;)*$/.test(this.rawText);
4920
- },
4921
- enumerable: false,
4922
- configurable: true
4923
- });
4924
- TextNode2.prototype.toString = function() {
4925
- return this.rawText;
4926
- };
4927
- return TextNode2;
4928
- }(node_1.default)
4929
- );
4770
+ var TextNode = class _TextNode extends node_1.default {
4771
+ clone() {
4772
+ return new _TextNode(this._rawText, null);
4773
+ }
4774
+ constructor(rawText, parentNode = null, range) {
4775
+ super(parentNode, range);
4776
+ this.nodeType = type_1.default.TEXT_NODE;
4777
+ this.rawTagName = "";
4778
+ this._rawText = rawText;
4779
+ }
4780
+ get rawText() {
4781
+ return this._rawText;
4782
+ }
4783
+ /**
4784
+ * Set rawText and invalidate trimmed caches
4785
+ */
4786
+ set rawText(text) {
4787
+ this._rawText = text;
4788
+ this._trimmedRawText = void 0;
4789
+ this._trimmedText = void 0;
4790
+ }
4791
+ /**
4792
+ * Returns raw text with all whitespace trimmed except single leading/trailing non-breaking space
4793
+ */
4794
+ get trimmedRawText() {
4795
+ if (this._trimmedRawText !== void 0)
4796
+ return this._trimmedRawText;
4797
+ this._trimmedRawText = trimText(this.rawText);
4798
+ return this._trimmedRawText;
4799
+ }
4800
+ /**
4801
+ * Returns text with all whitespace trimmed except single leading/trailing non-breaking space
4802
+ */
4803
+ get trimmedText() {
4804
+ if (this._trimmedText !== void 0)
4805
+ return this._trimmedText;
4806
+ this._trimmedText = trimText(this.text);
4807
+ return this._trimmedText;
4808
+ }
4809
+ /**
4810
+ * Get unescaped text value of current node and its children.
4811
+ * @return {string} text content
4812
+ */
4813
+ get text() {
4814
+ return (0, he_1.decode)(this.rawText);
4815
+ }
4816
+ /**
4817
+ * Detect if the node contains only white space.
4818
+ * @return {boolean}
4819
+ */
4820
+ get isWhitespace() {
4821
+ return /^(\s|&nbsp;)*$/.test(this.rawText);
4822
+ }
4823
+ toString() {
4824
+ return this.rawText;
4825
+ }
4826
+ };
4930
4827
  exports2.default = TextNode;
4931
4828
  function trimText(text) {
4932
- var i = 0;
4933
- var startPos;
4934
- var endPos;
4829
+ let i = 0;
4830
+ let startPos;
4831
+ let endPos;
4935
4832
  while (i >= 0 && i < text.length) {
4936
4833
  if (/\S/.test(text[i])) {
4937
4834
  if (startPos === void 0) {
@@ -4951,8 +4848,8 @@ var require_text = __commonJS({
4951
4848
  startPos = 0;
4952
4849
  if (endPos === void 0)
4953
4850
  endPos = text.length - 1;
4954
- var hasLeadingSpace = startPos > 0 && /[^\S\r\n]/.test(text[startPos - 1]);
4955
- var hasTrailingSpace = endPos < text.length - 1 && /[^\S\r\n]/.test(text[endPos + 1]);
4851
+ const hasLeadingSpace = startPos > 0 && /[^\S\r\n]/.test(text[startPos - 1]);
4852
+ const hasTrailingSpace = endPos < text.length - 1 && /[^\S\r\n]/.test(text[endPos + 1]);
4956
4853
  return (hasLeadingSpace ? " " : "") + text.slice(startPos, endPos + 1) + (hasTrailingSpace ? " " : "");
4957
4854
  }
4958
4855
  }
@@ -4962,45 +4859,6 @@ var require_text = __commonJS({
4962
4859
  var require_html = __commonJS({
4963
4860
  "node_modules/node-html-parser/dist/nodes/html.js"(exports2) {
4964
4861
  "use strict";
4965
- var __extends = exports2 && exports2.__extends || /* @__PURE__ */ function() {
4966
- var extendStatics = function(d, b) {
4967
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
4968
- d2.__proto__ = b2;
4969
- } || function(d2, b2) {
4970
- for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
4971
- };
4972
- return extendStatics(d, b);
4973
- };
4974
- return function(d, b) {
4975
- if (typeof b !== "function" && b !== null)
4976
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4977
- extendStatics(d, b);
4978
- function __() {
4979
- this.constructor = d;
4980
- }
4981
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4982
- };
4983
- }();
4984
- var __assign = exports2 && exports2.__assign || function() {
4985
- __assign = Object.assign || function(t) {
4986
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4987
- s = arguments[i];
4988
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4989
- t[p] = s[p];
4990
- }
4991
- return t;
4992
- };
4993
- return __assign.apply(this, arguments);
4994
- };
4995
- var __spreadArray = exports2 && exports2.__spreadArray || function(to, from, pack) {
4996
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4997
- if (ar || !(i in from)) {
4998
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4999
- ar[i] = from[i];
5000
- }
5001
- }
5002
- return to.concat(ar || Array.prototype.slice.call(from));
5003
- };
5004
4862
  var __importDefault = exports2 && exports2.__importDefault || function(mod) {
5005
4863
  return mod && mod.__esModule ? mod : { "default": mod };
5006
4864
  };
@@ -5024,794 +4882,777 @@ var require_html = __commonJS({
5024
4882
  var tableTags = ["table", "td", "tr"];
5025
4883
  var htmlTags = ["address", "article", "aside", "blockquote", "br", "hr", "li", "main", "nav", "ol", "p", "pre", "section", "ul"];
5026
4884
  var kBlockElements = /* @__PURE__ */ new Set();
5027
- function addToKBlockElement() {
5028
- var args = [];
5029
- for (var _i = 0; _i < arguments.length; _i++) {
5030
- args[_i] = arguments[_i];
5031
- }
5032
- var addToSet = function(array) {
5033
- for (var index = 0; index < array.length; index++) {
5034
- var element = array[index];
4885
+ function addToKBlockElement(...args) {
4886
+ const addToSet = (array) => {
4887
+ for (let index = 0; index < array.length; index++) {
4888
+ const element = array[index];
5035
4889
  kBlockElements.add(element);
5036
4890
  kBlockElements.add(element.toUpperCase());
5037
4891
  }
5038
4892
  };
5039
- for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
5040
- var arg = args_1[_a];
4893
+ for (const arg of args)
5041
4894
  addToSet(arg);
5042
- }
5043
4895
  }
5044
4896
  addToKBlockElement(Htags, Dtags, Ftags, tableTags, htmlTags);
5045
- var DOMTokenList = (
5046
- /** @class */
5047
- function() {
5048
- function DOMTokenList2(valuesInit, afterUpdate) {
5049
- if (valuesInit === void 0) {
5050
- valuesInit = [];
4897
+ var DOMTokenList = class {
4898
+ _validate(c) {
4899
+ if (/\s/.test(c)) {
4900
+ throw new Error(`DOMException in DOMTokenList.add: The token '${c}' contains HTML space characters, which are not valid in tokens.`);
4901
+ }
4902
+ }
4903
+ constructor(valuesInit = [], afterUpdate = () => null) {
4904
+ this._set = new Set(valuesInit);
4905
+ this._afterUpdate = afterUpdate;
4906
+ }
4907
+ add(c) {
4908
+ this._validate(c);
4909
+ this._set.add(c);
4910
+ this._afterUpdate(this);
4911
+ }
4912
+ replace(c1, c2) {
4913
+ this._validate(c2);
4914
+ this._set.delete(c1);
4915
+ this._set.add(c2);
4916
+ this._afterUpdate(this);
4917
+ }
4918
+ remove(c) {
4919
+ this._set.delete(c) && this._afterUpdate(this);
4920
+ }
4921
+ toggle(c) {
4922
+ this._validate(c);
4923
+ if (this._set.has(c))
4924
+ this._set.delete(c);
4925
+ else
4926
+ this._set.add(c);
4927
+ this._afterUpdate(this);
4928
+ }
4929
+ contains(c) {
4930
+ return this._set.has(c);
4931
+ }
4932
+ get length() {
4933
+ return this._set.size;
4934
+ }
4935
+ values() {
4936
+ return this._set.values();
4937
+ }
4938
+ get value() {
4939
+ return Array.from(this._set.values());
4940
+ }
4941
+ toString() {
4942
+ return Array.from(this._set.values()).join(" ");
4943
+ }
4944
+ };
4945
+ var HTMLElement = class _HTMLElement extends node_1.default {
4946
+ /**
4947
+ * Quote attribute values
4948
+ * @param attr attribute value
4949
+ * @returns {string} quoted value
4950
+ */
4951
+ quoteAttribute(attr) {
4952
+ if (attr == null) {
4953
+ return "null";
4954
+ }
4955
+ return JSON.stringify(attr.replace(/"/g, "&quot;")).replace(/\\t/g, " ").replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\/g, "");
4956
+ }
4957
+ /**
4958
+ * Creates an instance of HTMLElement.
4959
+ * @param keyAttrs id and class attribute
4960
+ * @param [rawAttrs] attributes in string
4961
+ *
4962
+ * @memberof HTMLElement
4963
+ */
4964
+ constructor(tagName, keyAttrs, rawAttrs = "", parentNode = null, range, voidTag = new void_tag_1.default(), _parseOptions = {}) {
4965
+ super(parentNode, range);
4966
+ this.rawAttrs = rawAttrs;
4967
+ this.voidTag = voidTag;
4968
+ this.nodeType = type_1.default.ELEMENT_NODE;
4969
+ this.rawTagName = tagName;
4970
+ this.rawAttrs = rawAttrs || "";
4971
+ this.id = keyAttrs.id || "";
4972
+ this.childNodes = [];
4973
+ this._parseOptions = _parseOptions;
4974
+ this.classList = new DOMTokenList(
4975
+ keyAttrs.class ? keyAttrs.class.split(/\s+/) : [],
4976
+ (classList) => this.setAttribute("class", classList.toString())
4977
+ // eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
4978
+ );
4979
+ if (keyAttrs.id) {
4980
+ if (!rawAttrs) {
4981
+ this.rawAttrs = `id="${keyAttrs.id}"`;
5051
4982
  }
5052
- if (afterUpdate === void 0) {
5053
- afterUpdate = function() {
5054
- return null;
5055
- };
4983
+ }
4984
+ if (keyAttrs.class) {
4985
+ if (!rawAttrs) {
4986
+ const cls = `class="${this.classList.toString()}"`;
4987
+ if (this.rawAttrs) {
4988
+ this.rawAttrs += ` ${cls}`;
4989
+ } else {
4990
+ this.rawAttrs = cls;
4991
+ }
5056
4992
  }
5057
- this._set = new Set(valuesInit);
5058
- this._afterUpdate = afterUpdate;
5059
4993
  }
5060
- DOMTokenList2.prototype._validate = function(c) {
5061
- if (/\s/.test(c)) {
5062
- throw new Error("DOMException in DOMTokenList.add: The token '".concat(c, "' contains HTML space characters, which are not valid in tokens."));
4994
+ }
4995
+ /**
4996
+ * Remove Child element from childNodes array
4997
+ * @param {HTMLElement} node node to remove
4998
+ */
4999
+ removeChild(node) {
5000
+ this.childNodes = this.childNodes.filter((child) => {
5001
+ return child !== node;
5002
+ });
5003
+ return this;
5004
+ }
5005
+ /**
5006
+ * Exchanges given child with new child
5007
+ * @param {HTMLElement} oldNode node to exchange
5008
+ * @param {HTMLElement} newNode new node
5009
+ */
5010
+ exchangeChild(oldNode, newNode) {
5011
+ const children = this.childNodes;
5012
+ this.childNodes = children.map((child) => {
5013
+ if (child === oldNode) {
5014
+ return newNode;
5063
5015
  }
5064
- };
5065
- DOMTokenList2.prototype.add = function(c) {
5066
- this._validate(c);
5067
- this._set.add(c);
5068
- this._afterUpdate(this);
5069
- };
5070
- DOMTokenList2.prototype.replace = function(c1, c2) {
5071
- this._validate(c2);
5072
- this._set.delete(c1);
5073
- this._set.add(c2);
5074
- this._afterUpdate(this);
5075
- };
5076
- DOMTokenList2.prototype.remove = function(c) {
5077
- this._set.delete(c) && this._afterUpdate(this);
5078
- };
5079
- DOMTokenList2.prototype.toggle = function(c) {
5080
- this._validate(c);
5081
- if (this._set.has(c))
5082
- this._set.delete(c);
5083
- else
5084
- this._set.add(c);
5085
- this._afterUpdate(this);
5086
- };
5087
- DOMTokenList2.prototype.contains = function(c) {
5088
- return this._set.has(c);
5089
- };
5090
- Object.defineProperty(DOMTokenList2.prototype, "length", {
5091
- get: function() {
5092
- return this._set.size;
5093
- },
5094
- enumerable: false,
5095
- configurable: true
5016
+ return child;
5096
5017
  });
5097
- DOMTokenList2.prototype.values = function() {
5098
- return this._set.values();
5099
- };
5100
- Object.defineProperty(DOMTokenList2.prototype, "value", {
5101
- get: function() {
5102
- return Array.from(this._set.values());
5103
- },
5104
- enumerable: false,
5105
- configurable: true
5106
- });
5107
- DOMTokenList2.prototype.toString = function() {
5108
- return Array.from(this._set.values()).join(" ");
5109
- };
5110
- return DOMTokenList2;
5111
- }()
5112
- );
5113
- var HTMLElement = (
5114
- /** @class */
5115
- function(_super) {
5116
- __extends(HTMLElement2, _super);
5117
- function HTMLElement2(tagName, keyAttrs, rawAttrs, parentNode, range, voidTag, _parseOptions) {
5118
- if (rawAttrs === void 0) {
5119
- rawAttrs = "";
5120
- }
5121
- if (parentNode === void 0) {
5122
- parentNode = null;
5123
- }
5124
- if (voidTag === void 0) {
5125
- voidTag = new void_tag_1.default();
5126
- }
5127
- if (_parseOptions === void 0) {
5128
- _parseOptions = {};
5129
- }
5130
- var _this = _super.call(this, parentNode, range) || this;
5131
- _this.rawAttrs = rawAttrs;
5132
- _this.voidTag = voidTag;
5133
- _this.nodeType = type_1.default.ELEMENT_NODE;
5134
- _this.rawTagName = tagName;
5135
- _this.rawAttrs = rawAttrs || "";
5136
- _this.id = keyAttrs.id || "";
5137
- _this.childNodes = [];
5138
- _this._parseOptions = _parseOptions;
5139
- _this.classList = new DOMTokenList(
5140
- keyAttrs.class ? keyAttrs.class.split(/\s+/) : [],
5141
- function(classList) {
5142
- return _this.setAttribute("class", classList.toString());
5143
- }
5144
- // eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
5145
- );
5146
- if (keyAttrs.id) {
5147
- if (!rawAttrs) {
5148
- _this.rawAttrs = 'id="'.concat(keyAttrs.id, '"');
5018
+ return this;
5019
+ }
5020
+ get tagName() {
5021
+ return this.rawTagName ? this.rawTagName.toUpperCase() : this.rawTagName;
5022
+ }
5023
+ set tagName(newname) {
5024
+ this.rawTagName = newname.toLowerCase();
5025
+ }
5026
+ get localName() {
5027
+ return this.rawTagName.toLowerCase();
5028
+ }
5029
+ get isVoidElement() {
5030
+ return this.voidTag.isVoidElement(this.localName);
5031
+ }
5032
+ /**
5033
+ * Get escpaed (as-it) text value of current node and its children.
5034
+ * @return {string} text content
5035
+ */
5036
+ get rawText() {
5037
+ if (/^br$/i.test(this.rawTagName)) {
5038
+ return "\n";
5039
+ }
5040
+ return this.childNodes.reduce((pre, cur) => {
5041
+ return pre += cur.rawText;
5042
+ }, "");
5043
+ }
5044
+ get textContent() {
5045
+ return decode(this.rawText);
5046
+ }
5047
+ set textContent(val) {
5048
+ const content = [new text_1.default(val, this)];
5049
+ this.childNodes = content;
5050
+ }
5051
+ /**
5052
+ * Get unescaped text value of current node and its children.
5053
+ * @return {string} text content
5054
+ */
5055
+ get text() {
5056
+ return decode(this.rawText);
5057
+ }
5058
+ /**
5059
+ * Get structured Text (with '\n' etc.)
5060
+ * @return {string} structured text
5061
+ */
5062
+ get structuredText() {
5063
+ let currentBlock = [];
5064
+ const blocks = [currentBlock];
5065
+ function dfs(node) {
5066
+ if (node.nodeType === type_1.default.ELEMENT_NODE) {
5067
+ if (kBlockElements.has(node.rawTagName)) {
5068
+ if (currentBlock.length > 0) {
5069
+ blocks.push(currentBlock = []);
5070
+ }
5071
+ node.childNodes.forEach(dfs);
5072
+ if (currentBlock.length > 0) {
5073
+ blocks.push(currentBlock = []);
5074
+ }
5075
+ } else {
5076
+ node.childNodes.forEach(dfs);
5149
5077
  }
5150
- }
5151
- if (keyAttrs.class) {
5152
- if (!rawAttrs) {
5153
- var cls = 'class="'.concat(_this.classList.toString(), '"');
5154
- if (_this.rawAttrs) {
5155
- _this.rawAttrs += " ".concat(cls);
5156
- } else {
5157
- _this.rawAttrs = cls;
5078
+ } else if (node.nodeType === type_1.default.TEXT_NODE) {
5079
+ if (node.isWhitespace) {
5080
+ currentBlock.prependWhitespace = true;
5081
+ } else {
5082
+ let text = node.trimmedText;
5083
+ if (currentBlock.prependWhitespace) {
5084
+ text = ` ${text}`;
5085
+ currentBlock.prependWhitespace = false;
5158
5086
  }
5087
+ currentBlock.push(text);
5159
5088
  }
5160
5089
  }
5161
- return _this;
5162
5090
  }
5163
- HTMLElement2.prototype.quoteAttribute = function(attr) {
5164
- if (attr == null) {
5165
- return "null";
5091
+ dfs(this);
5092
+ return blocks.map((block) => {
5093
+ return block.join("").replace(/\s{2,}/g, " ");
5094
+ }).join("\n").replace(/\s+$/, "");
5095
+ }
5096
+ toString() {
5097
+ const tag = this.rawTagName;
5098
+ if (tag) {
5099
+ const attrs = this.rawAttrs ? ` ${this.rawAttrs}` : "";
5100
+ return this.voidTag.formatNode(tag, attrs, this.innerHTML);
5101
+ }
5102
+ return this.innerHTML;
5103
+ }
5104
+ get innerHTML() {
5105
+ return this.childNodes.map((child) => {
5106
+ return child.toString();
5107
+ }).join("");
5108
+ }
5109
+ set innerHTML(content) {
5110
+ const r = parse2(content, this._parseOptions);
5111
+ const nodes = r.childNodes.length ? r.childNodes : [new text_1.default(content, this)];
5112
+ resetParent(nodes, this);
5113
+ resetParent(this.childNodes, null);
5114
+ this.childNodes = nodes;
5115
+ }
5116
+ set_content(content, options = {}) {
5117
+ if (content instanceof node_1.default) {
5118
+ content = [content];
5119
+ } else if (typeof content == "string") {
5120
+ options = Object.assign(Object.assign({}, this._parseOptions), options);
5121
+ const r = parse2(content, options);
5122
+ content = r.childNodes.length ? r.childNodes : [new text_1.default(r.innerHTML, this)];
5123
+ }
5124
+ resetParent(this.childNodes, null);
5125
+ resetParent(content, this);
5126
+ this.childNodes = content;
5127
+ return this;
5128
+ }
5129
+ replaceWith(...nodes) {
5130
+ const parent = this.parentNode;
5131
+ const content = nodes.map((node) => {
5132
+ if (node instanceof node_1.default) {
5133
+ return [node];
5134
+ } else if (typeof node == "string") {
5135
+ const r = parse2(node, this._parseOptions);
5136
+ return r.childNodes.length ? r.childNodes : [new text_1.default(node, this)];
5166
5137
  }
5167
- return JSON.stringify(attr.replace(/"/g, "&quot;")).replace(/\\t/g, " ").replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\/g, "");
5168
- };
5169
- HTMLElement2.prototype.removeChild = function(node) {
5170
- this.childNodes = this.childNodes.filter(function(child) {
5171
- return child !== node;
5172
- });
5173
- return this;
5174
- };
5175
- HTMLElement2.prototype.exchangeChild = function(oldNode, newNode) {
5176
- var children = this.childNodes;
5177
- this.childNodes = children.map(function(child) {
5178
- if (child === oldNode) {
5179
- return newNode;
5180
- }
5181
- return child;
5182
- });
5183
- return this;
5184
- };
5185
- Object.defineProperty(HTMLElement2.prototype, "tagName", {
5186
- get: function() {
5187
- return this.rawTagName ? this.rawTagName.toUpperCase() : this.rawTagName;
5188
- },
5189
- set: function(newname) {
5190
- this.rawTagName = newname.toLowerCase();
5191
- },
5192
- enumerable: false,
5193
- configurable: true
5138
+ return [];
5139
+ }).flat();
5140
+ const idx = parent.childNodes.findIndex((child) => {
5141
+ return child === this;
5194
5142
  });
5195
- Object.defineProperty(HTMLElement2.prototype, "localName", {
5196
- get: function() {
5197
- return this.rawTagName.toLowerCase();
5198
- },
5199
- enumerable: false,
5200
- configurable: true
5201
- });
5202
- Object.defineProperty(HTMLElement2.prototype, "isVoidElement", {
5203
- get: function() {
5204
- return this.voidTag.isVoidElement(this.localName);
5205
- },
5206
- enumerable: false,
5207
- configurable: true
5208
- });
5209
- Object.defineProperty(HTMLElement2.prototype, "rawText", {
5210
- /**
5211
- * Get escpaed (as-it) text value of current node and its children.
5212
- * @return {string} text content
5213
- */
5214
- get: function() {
5215
- if (/^br$/i.test(this.rawTagName)) {
5216
- return "\n";
5217
- }
5218
- return this.childNodes.reduce(function(pre, cur) {
5219
- return pre += cur.rawText;
5220
- }, "");
5221
- },
5222
- enumerable: false,
5223
- configurable: true
5224
- });
5225
- Object.defineProperty(HTMLElement2.prototype, "textContent", {
5226
- get: function() {
5227
- return decode(this.rawText);
5228
- },
5229
- set: function(val) {
5230
- var content = [new text_1.default(val, this)];
5231
- this.childNodes = content;
5232
- },
5233
- enumerable: false,
5234
- configurable: true
5235
- });
5236
- Object.defineProperty(HTMLElement2.prototype, "text", {
5237
- /**
5238
- * Get unescaped text value of current node and its children.
5239
- * @return {string} text content
5240
- */
5241
- get: function() {
5242
- return decode(this.rawText);
5243
- },
5244
- enumerable: false,
5245
- configurable: true
5246
- });
5247
- Object.defineProperty(HTMLElement2.prototype, "structuredText", {
5248
- /**
5249
- * Get structured Text (with '\n' etc.)
5250
- * @return {string} structured text
5251
- */
5252
- get: function() {
5253
- var currentBlock = [];
5254
- var blocks = [currentBlock];
5255
- function dfs(node) {
5256
- if (node.nodeType === type_1.default.ELEMENT_NODE) {
5257
- if (kBlockElements.has(node.rawTagName)) {
5258
- if (currentBlock.length > 0) {
5259
- blocks.push(currentBlock = []);
5260
- }
5261
- node.childNodes.forEach(dfs);
5262
- if (currentBlock.length > 0) {
5263
- blocks.push(currentBlock = []);
5264
- }
5265
- } else {
5266
- node.childNodes.forEach(dfs);
5267
- }
5268
- } else if (node.nodeType === type_1.default.TEXT_NODE) {
5269
- if (node.isWhitespace) {
5270
- currentBlock.prependWhitespace = true;
5271
- } else {
5272
- var text = node.trimmedText;
5273
- if (currentBlock.prependWhitespace) {
5274
- text = " ".concat(text);
5275
- currentBlock.prependWhitespace = false;
5276
- }
5277
- currentBlock.push(text);
5278
- }
5279
- }
5143
+ resetParent([this], null);
5144
+ parent.childNodes = [...parent.childNodes.slice(0, idx), ...resetParent(content, parent), ...parent.childNodes.slice(idx + 1)];
5145
+ return this;
5146
+ }
5147
+ get outerHTML() {
5148
+ return this.toString();
5149
+ }
5150
+ /**
5151
+ * Trim element from right (in block) after seeing pattern in a TextNode.
5152
+ * @param {RegExp} pattern pattern to find
5153
+ * @return {HTMLElement} reference to current node
5154
+ */
5155
+ trimRight(pattern) {
5156
+ for (let i = 0; i < this.childNodes.length; i++) {
5157
+ const childNode = this.childNodes[i];
5158
+ if (childNode.nodeType === type_1.default.ELEMENT_NODE) {
5159
+ childNode.trimRight(pattern);
5160
+ } else {
5161
+ const index = childNode.rawText.search(pattern);
5162
+ if (index > -1) {
5163
+ childNode.rawText = childNode.rawText.substr(0, index);
5164
+ this.childNodes.length = i + 1;
5280
5165
  }
5281
- dfs(this);
5282
- return blocks.map(function(block) {
5283
- return block.join("").replace(/\s{2,}/g, " ");
5284
- }).join("\n").replace(/\s+$/, "");
5285
- },
5286
- enumerable: false,
5287
- configurable: true
5288
- });
5289
- HTMLElement2.prototype.toString = function() {
5290
- var tag = this.rawTagName;
5291
- if (tag) {
5292
- var attrs = this.rawAttrs ? " ".concat(this.rawAttrs) : "";
5293
- return this.voidTag.formatNode(tag, attrs, this.innerHTML);
5294
- }
5295
- return this.innerHTML;
5296
- };
5297
- Object.defineProperty(HTMLElement2.prototype, "innerHTML", {
5298
- get: function() {
5299
- return this.childNodes.map(function(child) {
5300
- return child.toString();
5301
- }).join("");
5302
- },
5303
- set: function(content) {
5304
- var r = parse2(content, this._parseOptions);
5305
- var nodes = r.childNodes.length ? r.childNodes : [new text_1.default(content, this)];
5306
- resetParent(nodes, this);
5307
- resetParent(this.childNodes, null);
5308
- this.childNodes = nodes;
5309
- },
5310
- enumerable: false,
5311
- configurable: true
5312
- });
5313
- HTMLElement2.prototype.set_content = function(content, options) {
5314
- if (options === void 0) {
5315
- options = {};
5316
- }
5317
- if (content instanceof node_1.default) {
5318
- content = [content];
5319
- } else if (typeof content == "string") {
5320
- options = __assign(__assign({}, this._parseOptions), options);
5321
- var r = parse2(content, options);
5322
- content = r.childNodes.length ? r.childNodes : [new text_1.default(r.innerHTML, this)];
5323
- }
5324
- resetParent(this.childNodes, null);
5325
- resetParent(content, this);
5326
- this.childNodes = content;
5327
- return this;
5328
- };
5329
- HTMLElement2.prototype.replaceWith = function() {
5330
- var _this = this;
5331
- var nodes = [];
5332
- for (var _i = 0; _i < arguments.length; _i++) {
5333
- nodes[_i] = arguments[_i];
5334
5166
  }
5335
- var parent = this.parentNode;
5336
- var content = nodes.map(function(node) {
5337
- if (node instanceof node_1.default) {
5338
- return [node];
5339
- } else if (typeof node == "string") {
5340
- var r = parse2(node, _this._parseOptions);
5341
- return r.childNodes.length ? r.childNodes : [new text_1.default(node, _this)];
5342
- }
5343
- return [];
5344
- }).flat();
5345
- var idx = parent.childNodes.findIndex(function(child) {
5346
- return child === _this;
5347
- });
5348
- resetParent([this], null);
5349
- parent.childNodes = __spreadArray(__spreadArray(__spreadArray([], parent.childNodes.slice(0, idx), true), resetParent(content, parent), true), parent.childNodes.slice(idx + 1), true);
5350
- return this;
5351
- };
5352
- Object.defineProperty(HTMLElement2.prototype, "outerHTML", {
5353
- get: function() {
5354
- return this.toString();
5355
- },
5356
- enumerable: false,
5357
- configurable: true
5358
- });
5359
- HTMLElement2.prototype.trimRight = function(pattern) {
5360
- for (var i = 0; i < this.childNodes.length; i++) {
5361
- var childNode = this.childNodes[i];
5167
+ }
5168
+ return this;
5169
+ }
5170
+ /**
5171
+ * Get DOM structure
5172
+ * @return {string} structure
5173
+ */
5174
+ get structure() {
5175
+ const res = [];
5176
+ let indention = 0;
5177
+ function write(str) {
5178
+ res.push(" ".repeat(indention) + str);
5179
+ }
5180
+ function dfs(node) {
5181
+ const idStr = node.id ? `#${node.id}` : "";
5182
+ const classStr = node.classList.length ? `.${node.classList.value.join(".")}` : "";
5183
+ write(`${node.rawTagName}${idStr}${classStr}`);
5184
+ indention++;
5185
+ node.childNodes.forEach((childNode) => {
5362
5186
  if (childNode.nodeType === type_1.default.ELEMENT_NODE) {
5363
- childNode.trimRight(pattern);
5364
- } else {
5365
- var index = childNode.rawText.search(pattern);
5366
- if (index > -1) {
5367
- childNode.rawText = childNode.rawText.substr(0, index);
5368
- this.childNodes.length = i + 1;
5369
- }
5370
- }
5371
- }
5372
- return this;
5373
- };
5374
- Object.defineProperty(HTMLElement2.prototype, "structure", {
5375
- /**
5376
- * Get DOM structure
5377
- * @return {string} structure
5378
- */
5379
- get: function() {
5380
- var res = [];
5381
- var indention = 0;
5382
- function write(str) {
5383
- res.push(" ".repeat(indention) + str);
5384
- }
5385
- function dfs(node) {
5386
- var idStr = node.id ? "#".concat(node.id) : "";
5387
- var classStr = node.classList.length ? ".".concat(node.classList.value.join(".")) : "";
5388
- write("".concat(node.rawTagName).concat(idStr).concat(classStr));
5389
- indention++;
5390
- node.childNodes.forEach(function(childNode) {
5391
- if (childNode.nodeType === type_1.default.ELEMENT_NODE) {
5392
- dfs(childNode);
5393
- } else if (childNode.nodeType === type_1.default.TEXT_NODE) {
5394
- if (!childNode.isWhitespace) {
5395
- write("#text");
5396
- }
5397
- }
5398
- });
5399
- indention--;
5400
- }
5401
- dfs(this);
5402
- return res.join("\n");
5403
- },
5404
- enumerable: false,
5405
- configurable: true
5406
- });
5407
- HTMLElement2.prototype.removeWhitespace = function() {
5408
- var _this = this;
5409
- var o = 0;
5410
- this.childNodes.forEach(function(node) {
5411
- if (node.nodeType === type_1.default.TEXT_NODE) {
5412
- if (node.isWhitespace) {
5413
- return;
5187
+ dfs(childNode);
5188
+ } else if (childNode.nodeType === type_1.default.TEXT_NODE) {
5189
+ if (!childNode.isWhitespace) {
5190
+ write("#text");
5414
5191
  }
5415
- node.rawText = node.trimmedRawText;
5416
- } else if (node.nodeType === type_1.default.ELEMENT_NODE) {
5417
- node.removeWhitespace();
5418
5192
  }
5419
- _this.childNodes[o++] = node;
5420
- });
5421
- this.childNodes.length = o;
5422
- return this;
5423
- };
5424
- HTMLElement2.prototype.querySelectorAll = function(selector) {
5425
- return (0, css_select_1.selectAll)(selector, this, {
5426
- xmlMode: true,
5427
- adapter: matcher_1.default
5428
- });
5429
- };
5430
- HTMLElement2.prototype.querySelector = function(selector) {
5431
- return (0, css_select_1.selectOne)(selector, this, {
5432
- xmlMode: true,
5433
- adapter: matcher_1.default
5434
5193
  });
5435
- };
5436
- HTMLElement2.prototype.getElementsByTagName = function(tagName) {
5437
- var upperCasedTagName = tagName.toUpperCase();
5438
- var re = [];
5439
- var stack = [];
5440
- var currentNodeReference = this;
5441
- var index = 0;
5442
- while (index !== void 0) {
5443
- var child = void 0;
5444
- do {
5445
- child = currentNodeReference.childNodes[index++];
5446
- } while (index < currentNodeReference.childNodes.length && child === void 0);
5447
- if (child === void 0) {
5448
- currentNodeReference = currentNodeReference.parentNode;
5449
- index = stack.pop();
5450
- continue;
5194
+ indention--;
5195
+ }
5196
+ dfs(this);
5197
+ return res.join("\n");
5198
+ }
5199
+ /**
5200
+ * Remove whitespaces in this sub tree.
5201
+ * @return {HTMLElement} pointer to this
5202
+ */
5203
+ removeWhitespace() {
5204
+ let o = 0;
5205
+ this.childNodes.forEach((node) => {
5206
+ if (node.nodeType === type_1.default.TEXT_NODE) {
5207
+ if (node.isWhitespace) {
5208
+ return;
5451
5209
  }
5452
- if (child.nodeType === type_1.default.ELEMENT_NODE) {
5453
- if (tagName === "*" || child.tagName === upperCasedTagName)
5454
- re.push(child);
5455
- if (child.childNodes.length > 0) {
5456
- stack.push(index);
5457
- currentNodeReference = child;
5458
- index = 0;
5459
- }
5210
+ node.rawText = node.trimmedRawText;
5211
+ } else if (node.nodeType === type_1.default.ELEMENT_NODE) {
5212
+ node.removeWhitespace();
5213
+ }
5214
+ this.childNodes[o++] = node;
5215
+ });
5216
+ this.childNodes.length = o;
5217
+ const attrs = Object.keys(this.rawAttributes).map((key) => {
5218
+ const val = this.rawAttributes[key];
5219
+ return `${key}=${JSON.stringify(val)}`;
5220
+ }).join(" ");
5221
+ this.rawAttrs = attrs;
5222
+ delete this._rawAttrs;
5223
+ return this;
5224
+ }
5225
+ /**
5226
+ * Query CSS selector to find matching nodes.
5227
+ * @param {string} selector Simplified CSS selector
5228
+ * @return {HTMLElement[]} matching elements
5229
+ */
5230
+ querySelectorAll(selector) {
5231
+ return (0, css_select_1.selectAll)(selector, this, {
5232
+ xmlMode: true,
5233
+ adapter: matcher_1.default
5234
+ });
5235
+ }
5236
+ /**
5237
+ * Query CSS Selector to find matching node.
5238
+ * @param {string} selector Simplified CSS selector
5239
+ * @return {(HTMLElement|null)} matching node
5240
+ */
5241
+ querySelector(selector) {
5242
+ return (0, css_select_1.selectOne)(selector, this, {
5243
+ xmlMode: true,
5244
+ adapter: matcher_1.default
5245
+ });
5246
+ }
5247
+ /**
5248
+ * find elements by their tagName
5249
+ * @param {string} tagName the tagName of the elements to select
5250
+ */
5251
+ getElementsByTagName(tagName) {
5252
+ const upperCasedTagName = tagName.toUpperCase();
5253
+ const re = [];
5254
+ const stack = [];
5255
+ let currentNodeReference = this;
5256
+ let index = 0;
5257
+ while (index !== void 0) {
5258
+ let child;
5259
+ do {
5260
+ child = currentNodeReference.childNodes[index++];
5261
+ } while (index < currentNodeReference.childNodes.length && child === void 0);
5262
+ if (child === void 0) {
5263
+ currentNodeReference = currentNodeReference.parentNode;
5264
+ index = stack.pop();
5265
+ continue;
5266
+ }
5267
+ if (child.nodeType === type_1.default.ELEMENT_NODE) {
5268
+ if (tagName === "*" || child.tagName === upperCasedTagName)
5269
+ re.push(child);
5270
+ if (child.childNodes.length > 0) {
5271
+ stack.push(index);
5272
+ currentNodeReference = child;
5273
+ index = 0;
5460
5274
  }
5461
5275
  }
5462
- return re;
5463
- };
5464
- HTMLElement2.prototype.getElementById = function(id) {
5465
- var stack = [];
5466
- var currentNodeReference = this;
5467
- var index = 0;
5468
- while (index !== void 0) {
5469
- var child = void 0;
5470
- do {
5471
- child = currentNodeReference.childNodes[index++];
5472
- } while (index < currentNodeReference.childNodes.length && child === void 0);
5473
- if (child === void 0) {
5474
- currentNodeReference = currentNodeReference.parentNode;
5475
- index = stack.pop();
5476
- continue;
5276
+ }
5277
+ return re;
5278
+ }
5279
+ /**
5280
+ * find element by it's id
5281
+ * @param {string} id the id of the element to select
5282
+ * @returns {HTMLElement | null} the element with the given id or null if not found
5283
+ */
5284
+ getElementById(id) {
5285
+ const stack = [];
5286
+ let currentNodeReference = this;
5287
+ let index = 0;
5288
+ while (index !== void 0) {
5289
+ let child;
5290
+ do {
5291
+ child = currentNodeReference.childNodes[index++];
5292
+ } while (index < currentNodeReference.childNodes.length && child === void 0);
5293
+ if (child === void 0) {
5294
+ currentNodeReference = currentNodeReference.parentNode;
5295
+ index = stack.pop();
5296
+ continue;
5297
+ }
5298
+ if (child.nodeType === type_1.default.ELEMENT_NODE) {
5299
+ if (child.id === id) {
5300
+ return child;
5477
5301
  }
5478
- if (child.nodeType === type_1.default.ELEMENT_NODE) {
5479
- if (child.id === id) {
5480
- return child;
5481
- }
5482
- ;
5483
- if (child.childNodes.length > 0) {
5484
- stack.push(index);
5485
- currentNodeReference = child;
5486
- index = 0;
5487
- }
5302
+ if (child.childNodes.length > 0) {
5303
+ stack.push(index);
5304
+ currentNodeReference = child;
5305
+ index = 0;
5488
5306
  }
5489
5307
  }
5490
- return null;
5491
- };
5492
- HTMLElement2.prototype.closest = function(selector) {
5493
- var mapChild = /* @__PURE__ */ new Map();
5494
- var el = this;
5495
- var old = null;
5496
- function findOne(test, elems) {
5497
- var elem = null;
5498
- for (var i = 0, l = elems.length; i < l && !elem; i++) {
5499
- var el_1 = elems[i];
5500
- if (test(el_1)) {
5501
- elem = el_1;
5502
- } else {
5503
- var child = mapChild.get(el_1);
5504
- if (child) {
5505
- elem = findOne(test, [child]);
5506
- }
5308
+ }
5309
+ return null;
5310
+ }
5311
+ /**
5312
+ * traverses the Element and its parents (heading toward the document root) until it finds a node that matches the provided selector string. Will return itself or the matching ancestor. If no such element exists, it returns null.
5313
+ * @param selector a DOMString containing a selector list
5314
+ * @returns {HTMLElement | null} the element with the given id or null if not found
5315
+ */
5316
+ closest(selector) {
5317
+ const mapChild = /* @__PURE__ */ new Map();
5318
+ let el = this;
5319
+ let old = null;
5320
+ function findOne(test, elems) {
5321
+ let elem = null;
5322
+ for (let i = 0, l = elems.length; i < l && !elem; i++) {
5323
+ const el2 = elems[i];
5324
+ if (test(el2)) {
5325
+ elem = el2;
5326
+ } else {
5327
+ const child = mapChild.get(el2);
5328
+ if (child) {
5329
+ elem = findOne(test, [child]);
5507
5330
  }
5508
5331
  }
5509
- return elem;
5510
- }
5511
- while (el) {
5512
- mapChild.set(el, old);
5513
- old = el;
5514
- el = el.parentNode;
5515
5332
  }
5516
- el = this;
5517
- while (el) {
5518
- var e = (0, css_select_1.selectOne)(selector, el, {
5519
- xmlMode: true,
5520
- adapter: __assign(__assign({}, matcher_1.default), { getChildren: function(node) {
5521
- var child = mapChild.get(node);
5333
+ return elem;
5334
+ }
5335
+ while (el) {
5336
+ mapChild.set(el, old);
5337
+ old = el;
5338
+ el = el.parentNode;
5339
+ }
5340
+ el = this;
5341
+ while (el) {
5342
+ const e = (0, css_select_1.selectOne)(selector, el, {
5343
+ xmlMode: true,
5344
+ adapter: Object.assign(Object.assign({}, matcher_1.default), {
5345
+ getChildren(node) {
5346
+ const child = mapChild.get(node);
5522
5347
  return child && [child];
5523
- }, getSiblings: function(node) {
5348
+ },
5349
+ getSiblings(node) {
5524
5350
  return [node];
5525
- }, findOne, findAll: function() {
5351
+ },
5352
+ findOne,
5353
+ findAll() {
5526
5354
  return [];
5527
- } })
5528
- });
5529
- if (e) {
5530
- return e;
5531
- }
5532
- el = el.parentNode;
5533
- }
5534
- return null;
5535
- };
5536
- HTMLElement2.prototype.appendChild = function(node) {
5537
- node.remove();
5538
- this.childNodes.push(node);
5539
- node.parentNode = this;
5540
- return node;
5541
- };
5542
- Object.defineProperty(HTMLElement2.prototype, "firstChild", {
5543
- /**
5544
- * Get first child node
5545
- * @return {Node | undefined} first child node; or undefined if none
5546
- */
5547
- get: function() {
5548
- return this.childNodes[0];
5549
- },
5550
- enumerable: false,
5551
- configurable: true
5552
- });
5553
- Object.defineProperty(HTMLElement2.prototype, "lastChild", {
5554
- /**
5555
- * Get last child node
5556
- * @return {Node | undefined} last child node; or undefined if none
5557
- */
5558
- get: function() {
5559
- return (0, back_1.default)(this.childNodes);
5560
- },
5561
- enumerable: false,
5562
- configurable: true
5563
- });
5564
- Object.defineProperty(HTMLElement2.prototype, "attrs", {
5565
- /**
5566
- * Get attributes
5567
- * @access private
5568
- * @return {Object} parsed and unescaped attributes
5569
- */
5570
- get: function() {
5571
- if (this._attrs) {
5572
- return this._attrs;
5573
- }
5574
- this._attrs = {};
5575
- var attrs = this.rawAttributes;
5576
- for (var key in attrs) {
5577
- var val = attrs[key] || "";
5578
- this._attrs[key.toLowerCase()] = decode(val);
5579
- }
5580
- return this._attrs;
5581
- },
5582
- enumerable: false,
5583
- configurable: true
5584
- });
5585
- Object.defineProperty(HTMLElement2.prototype, "attributes", {
5586
- get: function() {
5587
- var ret_attrs = {};
5588
- var attrs = this.rawAttributes;
5589
- for (var key in attrs) {
5590
- var val = attrs[key] || "";
5591
- ret_attrs[key] = decode(val);
5592
- }
5593
- return ret_attrs;
5594
- },
5595
- enumerable: false,
5596
- configurable: true
5597
- });
5598
- Object.defineProperty(HTMLElement2.prototype, "rawAttributes", {
5599
- /**
5600
- * Get escaped (as-is) attributes
5601
- * @return {Object} parsed attributes
5602
- */
5603
- get: function() {
5604
- if (this._rawAttrs) {
5605
- return this._rawAttrs;
5606
- }
5607
- var attrs = {};
5608
- if (this.rawAttrs) {
5609
- var re = /([a-zA-Z()[\]#@$.?:][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
5610
- var match = void 0;
5611
- while (match = re.exec(this.rawAttrs)) {
5612
- var key = match[1];
5613
- var val = match[2] || null;
5614
- if (val && (val[0] === "'" || val[0] === '"'))
5615
- val = val.slice(1, val.length - 1);
5616
- attrs[key] = attrs[key] || val;
5617
5355
  }
5618
- }
5619
- this._rawAttrs = attrs;
5620
- return attrs;
5621
- },
5622
- enumerable: false,
5623
- configurable: true
5624
- });
5625
- HTMLElement2.prototype.removeAttribute = function(key) {
5626
- var _this = this;
5627
- var attrs = this.rawAttributes;
5628
- delete attrs[key];
5629
- if (this._attrs) {
5630
- delete this._attrs[key];
5631
- }
5632
- this.rawAttrs = Object.keys(attrs).map(function(name) {
5633
- var val = _this.quoteAttribute(attrs[name]);
5634
- if (val === "null" || val === '""')
5635
- return name;
5636
- return "".concat(name, "=").concat(val);
5637
- }).join(" ");
5638
- if (key === "id") {
5639
- this.id = "";
5640
- }
5641
- return this;
5642
- };
5643
- HTMLElement2.prototype.hasAttribute = function(key) {
5644
- return key.toLowerCase() in this.attrs;
5645
- };
5646
- HTMLElement2.prototype.getAttribute = function(key) {
5647
- return this.attrs[key.toLowerCase()];
5648
- };
5649
- HTMLElement2.prototype.setAttribute = function(key, value) {
5650
- var _this = this;
5651
- if (arguments.length < 2) {
5652
- throw new Error("Failed to execute 'setAttribute' on 'Element'");
5653
- }
5654
- var k2 = key.toLowerCase();
5655
- var attrs = this.rawAttributes;
5656
- for (var k in attrs) {
5657
- if (k.toLowerCase() === k2) {
5658
- key = k;
5659
- break;
5660
- }
5661
- }
5662
- attrs[key] = String(value);
5663
- if (this._attrs) {
5664
- this._attrs[k2] = decode(attrs[key]);
5665
- }
5666
- this.rawAttrs = Object.keys(attrs).map(function(name) {
5667
- var val = _this.quoteAttribute(attrs[name]);
5668
- if (val === "null" || val === '""')
5669
- return name;
5670
- return "".concat(name, "=").concat(val);
5671
- }).join(" ");
5672
- if (key === "id") {
5673
- this.id = value;
5674
- }
5675
- return this;
5676
- };
5677
- HTMLElement2.prototype.setAttributes = function(attributes) {
5678
- var _this = this;
5679
- if (this._attrs) {
5680
- delete this._attrs;
5356
+ })
5357
+ });
5358
+ if (e) {
5359
+ return e;
5681
5360
  }
5682
- if (this._rawAttrs) {
5683
- delete this._rawAttrs;
5361
+ el = el.parentNode;
5362
+ }
5363
+ return null;
5364
+ }
5365
+ /**
5366
+ * Append a child node to childNodes
5367
+ * @param {Node} node node to append
5368
+ * @return {Node} node appended
5369
+ */
5370
+ appendChild(node) {
5371
+ this.append(node);
5372
+ return node;
5373
+ }
5374
+ /**
5375
+ * Get attributes
5376
+ * @access private
5377
+ * @return {Object} parsed and unescaped attributes
5378
+ */
5379
+ get attrs() {
5380
+ if (this._attrs) {
5381
+ return this._attrs;
5382
+ }
5383
+ this._attrs = {};
5384
+ const attrs = this.rawAttributes;
5385
+ for (const key in attrs) {
5386
+ const val = attrs[key] || "";
5387
+ this._attrs[key.toLowerCase()] = decode(val);
5388
+ }
5389
+ return this._attrs;
5390
+ }
5391
+ get attributes() {
5392
+ const ret_attrs = {};
5393
+ const attrs = this.rawAttributes;
5394
+ for (const key in attrs) {
5395
+ const val = attrs[key] || "";
5396
+ ret_attrs[key] = decode(val);
5397
+ }
5398
+ return ret_attrs;
5399
+ }
5400
+ /**
5401
+ * Get escaped (as-is) attributes
5402
+ * @return {Object} parsed attributes
5403
+ */
5404
+ get rawAttributes() {
5405
+ if (this._rawAttrs) {
5406
+ return this._rawAttrs;
5407
+ }
5408
+ const attrs = {};
5409
+ if (this.rawAttrs) {
5410
+ const re = /([a-zA-Z()[\]#@$.?:][a-zA-Z0-9-._:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
5411
+ let match;
5412
+ while (match = re.exec(this.rawAttrs)) {
5413
+ const key = match[1];
5414
+ let val = match[2] || null;
5415
+ if (val && (val[0] === `'` || val[0] === `"`))
5416
+ val = val.slice(1, val.length - 1);
5417
+ attrs[key] = attrs[key] || val;
5684
5418
  }
5685
- this.rawAttrs = Object.keys(attributes).map(function(name) {
5686
- var val = attributes[name];
5687
- if (val === "null" || val === '""')
5688
- return name;
5689
- return "".concat(name, "=").concat(_this.quoteAttribute(String(val)));
5690
- }).join(" ");
5691
- return this;
5692
- };
5693
- HTMLElement2.prototype.insertAdjacentHTML = function(where, html) {
5694
- var _a, _b, _c;
5695
- var _this = this;
5696
- if (arguments.length < 2) {
5697
- throw new Error("2 arguments required");
5419
+ }
5420
+ this._rawAttrs = attrs;
5421
+ return attrs;
5422
+ }
5423
+ removeAttribute(key) {
5424
+ const attrs = this.rawAttributes;
5425
+ delete attrs[key];
5426
+ if (this._attrs) {
5427
+ delete this._attrs[key];
5428
+ }
5429
+ this.rawAttrs = Object.keys(attrs).map((name) => {
5430
+ const val = this.quoteAttribute(attrs[name]);
5431
+ if (val === "null" || val === '""')
5432
+ return name;
5433
+ return `${name}=${val}`;
5434
+ }).join(" ");
5435
+ if (key === "id") {
5436
+ this.id = "";
5437
+ }
5438
+ return this;
5439
+ }
5440
+ hasAttribute(key) {
5441
+ return key.toLowerCase() in this.attrs;
5442
+ }
5443
+ /**
5444
+ * Get an attribute
5445
+ * @return {string | undefined} value of the attribute; or undefined if not exist
5446
+ */
5447
+ getAttribute(key) {
5448
+ return this.attrs[key.toLowerCase()];
5449
+ }
5450
+ /**
5451
+ * Set an attribute value to the HTMLElement
5452
+ * @param {string} key The attribute name
5453
+ * @param {string} value The value to set, or null / undefined to remove an attribute
5454
+ */
5455
+ setAttribute(key, value) {
5456
+ if (arguments.length < 2) {
5457
+ throw new Error("Failed to execute 'setAttribute' on 'Element'");
5458
+ }
5459
+ const k2 = key.toLowerCase();
5460
+ const attrs = this.rawAttributes;
5461
+ for (const k in attrs) {
5462
+ if (k.toLowerCase() === k2) {
5463
+ key = k;
5464
+ break;
5698
5465
  }
5699
- var p = parse2(html, this._parseOptions);
5700
- if (where === "afterend") {
5701
- var idx = this.parentNode.childNodes.findIndex(function(child) {
5702
- return child === _this;
5703
- });
5704
- resetParent(p.childNodes, this.parentNode);
5705
- (_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
5706
- } else if (where === "afterbegin") {
5707
- resetParent(p.childNodes, this);
5708
- (_b = this.childNodes).unshift.apply(_b, p.childNodes);
5709
- } else if (where === "beforeend") {
5710
- p.childNodes.forEach(function(n) {
5711
- _this.appendChild(n);
5712
- });
5713
- } else if (where === "beforebegin") {
5714
- var idx = this.parentNode.childNodes.findIndex(function(child) {
5715
- return child === _this;
5716
- });
5717
- resetParent(p.childNodes, this.parentNode);
5718
- (_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
5719
- } else {
5720
- throw new Error("The value provided ('".concat(where, "') is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'"));
5466
+ }
5467
+ attrs[key] = String(value);
5468
+ if (this._attrs) {
5469
+ this._attrs[k2] = decode(attrs[key]);
5470
+ }
5471
+ this.rawAttrs = Object.keys(attrs).map((name) => {
5472
+ const val = this.quoteAttribute(attrs[name]);
5473
+ if (val === "null" || val === '""')
5474
+ return name;
5475
+ return `${name}=${val}`;
5476
+ }).join(" ");
5477
+ if (key === "id") {
5478
+ this.id = value;
5479
+ }
5480
+ return this;
5481
+ }
5482
+ /**
5483
+ * Replace all the attributes of the HTMLElement by the provided attributes
5484
+ * @param {Attributes} attributes the new attribute set
5485
+ */
5486
+ setAttributes(attributes) {
5487
+ if (this._attrs) {
5488
+ delete this._attrs;
5489
+ }
5490
+ if (this._rawAttrs) {
5491
+ delete this._rawAttrs;
5492
+ }
5493
+ this.rawAttrs = Object.keys(attributes).map((name) => {
5494
+ const val = attributes[name];
5495
+ if (val === "null" || val === '""')
5496
+ return name;
5497
+ return `${name}=${this.quoteAttribute(String(val))}`;
5498
+ }).join(" ");
5499
+ return this;
5500
+ }
5501
+ insertAdjacentHTML(where, html) {
5502
+ if (arguments.length < 2) {
5503
+ throw new Error("2 arguments required");
5504
+ }
5505
+ const p = parse2(html, this._parseOptions);
5506
+ if (where === "afterend") {
5507
+ this.after(...p.childNodes);
5508
+ } else if (where === "afterbegin") {
5509
+ this.prepend(...p.childNodes);
5510
+ } else if (where === "beforeend") {
5511
+ this.append(...p.childNodes);
5512
+ } else if (where === "beforebegin") {
5513
+ this.before(...p.childNodes);
5514
+ } else {
5515
+ throw new Error(`The value provided ('${where}') is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'`);
5516
+ }
5517
+ return this;
5518
+ }
5519
+ /** Prepend nodes or strings to this node's children. */
5520
+ prepend(...insertable) {
5521
+ const nodes = resolveInsertable(insertable);
5522
+ resetParent(nodes, this);
5523
+ this.childNodes.unshift(...nodes);
5524
+ }
5525
+ /** Append nodes or strings to this node's children. */
5526
+ append(...insertable) {
5527
+ const nodes = resolveInsertable(insertable);
5528
+ resetParent(nodes, this);
5529
+ this.childNodes.push(...nodes);
5530
+ }
5531
+ /** Insert nodes or strings before this node. */
5532
+ before(...insertable) {
5533
+ const nodes = resolveInsertable(insertable);
5534
+ const siblings = this.parentNode.childNodes;
5535
+ resetParent(nodes, this.parentNode);
5536
+ siblings.splice(siblings.indexOf(this), 0, ...nodes);
5537
+ }
5538
+ /** Insert nodes or strings after this node. */
5539
+ after(...insertable) {
5540
+ const nodes = resolveInsertable(insertable);
5541
+ const siblings = this.parentNode.childNodes;
5542
+ resetParent(nodes, this.parentNode);
5543
+ siblings.splice(siblings.indexOf(this) + 1, 0, ...nodes);
5544
+ }
5545
+ get nextSibling() {
5546
+ if (this.parentNode) {
5547
+ const children = this.parentNode.childNodes;
5548
+ let i = 0;
5549
+ while (i < children.length) {
5550
+ const child = children[i++];
5551
+ if (this === child)
5552
+ return children[i] || null;
5721
5553
  }
5722
- return this;
5723
- };
5724
- Object.defineProperty(HTMLElement2.prototype, "nextSibling", {
5725
- get: function() {
5726
- if (this.parentNode) {
5727
- var children = this.parentNode.childNodes;
5728
- var i = 0;
5729
- while (i < children.length) {
5730
- var child = children[i++];
5731
- if (this === child)
5732
- return children[i] || null;
5733
- }
5734
- return null;
5735
- }
5736
- },
5737
- enumerable: false,
5738
- configurable: true
5739
- });
5740
- Object.defineProperty(HTMLElement2.prototype, "nextElementSibling", {
5741
- get: function() {
5742
- if (this.parentNode) {
5743
- var children = this.parentNode.childNodes;
5744
- var i = 0;
5745
- var find = false;
5746
- while (i < children.length) {
5747
- var child = children[i++];
5748
- if (find) {
5749
- if (child instanceof HTMLElement2) {
5750
- return child || null;
5751
- }
5752
- } else if (this === child) {
5753
- find = true;
5754
- }
5755
- }
5756
- return null;
5757
- }
5758
- },
5759
- enumerable: false,
5760
- configurable: true
5761
- });
5762
- Object.defineProperty(HTMLElement2.prototype, "previousSibling", {
5763
- get: function() {
5764
- if (this.parentNode) {
5765
- var children = this.parentNode.childNodes;
5766
- var i = children.length;
5767
- while (i > 0) {
5768
- var child = children[--i];
5769
- if (this === child)
5770
- return children[i - 1] || null;
5554
+ return null;
5555
+ }
5556
+ }
5557
+ get nextElementSibling() {
5558
+ if (this.parentNode) {
5559
+ const children = this.parentNode.childNodes;
5560
+ let i = 0;
5561
+ let find = false;
5562
+ while (i < children.length) {
5563
+ const child = children[i++];
5564
+ if (find) {
5565
+ if (child instanceof _HTMLElement) {
5566
+ return child || null;
5771
5567
  }
5772
- return null;
5568
+ } else if (this === child) {
5569
+ find = true;
5773
5570
  }
5774
- },
5775
- enumerable: false,
5776
- configurable: true
5777
- });
5778
- Object.defineProperty(HTMLElement2.prototype, "previousElementSibling", {
5779
- get: function() {
5780
- if (this.parentNode) {
5781
- var children = this.parentNode.childNodes;
5782
- var i = children.length;
5783
- var find = false;
5784
- while (i > 0) {
5785
- var child = children[--i];
5786
- if (find) {
5787
- if (child instanceof HTMLElement2) {
5788
- return child || null;
5789
- }
5790
- } else if (this === child) {
5791
- find = true;
5792
- }
5571
+ }
5572
+ return null;
5573
+ }
5574
+ }
5575
+ get previousSibling() {
5576
+ if (this.parentNode) {
5577
+ const children = this.parentNode.childNodes;
5578
+ let i = children.length;
5579
+ while (i > 0) {
5580
+ const child = children[--i];
5581
+ if (this === child)
5582
+ return children[i - 1] || null;
5583
+ }
5584
+ return null;
5585
+ }
5586
+ }
5587
+ get previousElementSibling() {
5588
+ if (this.parentNode) {
5589
+ const children = this.parentNode.childNodes;
5590
+ let i = children.length;
5591
+ let find = false;
5592
+ while (i > 0) {
5593
+ const child = children[--i];
5594
+ if (find) {
5595
+ if (child instanceof _HTMLElement) {
5596
+ return child || null;
5793
5597
  }
5794
- return null;
5598
+ } else if (this === child) {
5599
+ find = true;
5795
5600
  }
5796
- },
5797
- enumerable: false,
5798
- configurable: true
5799
- });
5800
- Object.defineProperty(HTMLElement2.prototype, "classNames", {
5801
- get: function() {
5802
- return this.classList.toString();
5803
- },
5804
- enumerable: false,
5805
- configurable: true
5806
- });
5807
- HTMLElement2.prototype.clone = function() {
5808
- return parse2(this.toString(), this._parseOptions).firstChild;
5809
- };
5810
- return HTMLElement2;
5811
- }(node_1.default)
5812
- );
5601
+ }
5602
+ return null;
5603
+ }
5604
+ }
5605
+ /** Get all childNodes of type {@link HTMLElement}. */
5606
+ get children() {
5607
+ const children = [];
5608
+ for (const childNode of this.childNodes) {
5609
+ if (childNode instanceof _HTMLElement) {
5610
+ children.push(childNode);
5611
+ }
5612
+ }
5613
+ return children;
5614
+ }
5615
+ /**
5616
+ * Get the first child node.
5617
+ * @return The first child or undefined if none exists.
5618
+ */
5619
+ get firstChild() {
5620
+ return this.childNodes[0];
5621
+ }
5622
+ /**
5623
+ * Get the first child node of type {@link HTMLElement}.
5624
+ * @return The first child element or undefined if none exists.
5625
+ */
5626
+ get firstElementChild() {
5627
+ return this.children[0];
5628
+ }
5629
+ /**
5630
+ * Get the last child node.
5631
+ * @return The last child or undefined if none exists.
5632
+ */
5633
+ get lastChild() {
5634
+ return (0, back_1.default)(this.childNodes);
5635
+ }
5636
+ /**
5637
+ * Get the last child node of type {@link HTMLElement}.
5638
+ * @return The last child element or undefined if none exists.
5639
+ */
5640
+ get lastElementChild() {
5641
+ return this.children[this.children.length - 1];
5642
+ }
5643
+ get childElementCount() {
5644
+ return this.children.length;
5645
+ }
5646
+ get classNames() {
5647
+ return this.classList.toString();
5648
+ }
5649
+ /** Clone this Node */
5650
+ clone() {
5651
+ return parse2(this.toString(), this._parseOptions).firstChild;
5652
+ }
5653
+ };
5813
5654
  exports2.default = HTMLElement;
5814
- var kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;
5655
+ var kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z@\xB7\xC0-\xD6\xD8-\xF6\u00F8-\u03A1\u03A3-\u03D9\u03DB-\u03EF\u03F7-\u03FF\u0400-\u04FF\u0500-\u052F\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E00-\u1E9B\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA78E\uA790-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64-\uAB65\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\x37F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/gu;
5815
5656
  var kAttributePattern = /(?:^|\s)(id|class)\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+)/gi;
5816
5657
  var kElementsClosedByOpening = {
5817
5658
  li: { li: true, LI: true },
@@ -5854,58 +5695,43 @@ var require_html = __commonJS({
5854
5695
  TH: { tr: true, table: true, TR: true, TABLE: true }
5855
5696
  };
5856
5697
  var frameflag = "documentfragmentcontainer";
5857
- function base_parse(data, options) {
5698
+ function base_parse(data, options = {}) {
5858
5699
  var _a, _b;
5859
- if (options === void 0) {
5860
- options = {};
5861
- }
5862
- var voidTag = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
5863
- var elements = options.blockTextElements || {
5700
+ const voidTag = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
5701
+ const elements = options.blockTextElements || {
5864
5702
  script: true,
5865
5703
  noscript: true,
5866
5704
  style: true,
5867
5705
  pre: true
5868
5706
  };
5869
- var element_names = Object.keys(elements);
5870
- var kBlockTextElements = element_names.map(function(it) {
5871
- return new RegExp("^".concat(it, "$"), "i");
5872
- });
5873
- var kIgnoreElements = element_names.filter(function(it) {
5874
- return Boolean(elements[it]);
5875
- }).map(function(it) {
5876
- return new RegExp("^".concat(it, "$"), "i");
5877
- });
5707
+ const element_names = Object.keys(elements);
5708
+ const kBlockTextElements = element_names.map((it) => new RegExp(`^${it}$`, "i"));
5709
+ const kIgnoreElements = element_names.filter((it) => Boolean(elements[it])).map((it) => new RegExp(`^${it}$`, "i"));
5878
5710
  function element_should_be_ignore(tag) {
5879
- return kIgnoreElements.some(function(it) {
5880
- return it.test(tag);
5881
- });
5711
+ return kIgnoreElements.some((it) => it.test(tag));
5882
5712
  }
5883
5713
  function is_block_text_element(tag) {
5884
- return kBlockTextElements.some(function(it) {
5885
- return it.test(tag);
5886
- });
5887
- }
5888
- var createRange = function(startPos, endPos) {
5889
- return [startPos - frameFlagOffset, endPos - frameFlagOffset];
5890
- };
5891
- var root = new HTMLElement(null, {}, "", null, [0, data.length], voidTag, options);
5892
- var currentParent = root;
5893
- var stack = [root];
5894
- var lastTextPos = -1;
5895
- var noNestedTagIndex = void 0;
5896
- var match;
5897
- data = "<".concat(frameflag, ">").concat(data, "</").concat(frameflag, ">");
5898
- var lowerCaseTagName = options.lowerCaseTagName, fixNestedATags = options.fixNestedATags;
5899
- var dataEndPos = data.length - (frameflag.length + 2);
5900
- var frameFlagOffset = frameflag.length + 2;
5714
+ return kBlockTextElements.some((it) => it.test(tag));
5715
+ }
5716
+ const createRange = (startPos, endPos) => [startPos - frameFlagOffset, endPos - frameFlagOffset];
5717
+ const root = new HTMLElement(null, {}, "", null, [0, data.length], voidTag, options);
5718
+ let currentParent = root;
5719
+ const stack = [root];
5720
+ let lastTextPos = -1;
5721
+ let noNestedTagIndex = void 0;
5722
+ let match;
5723
+ data = `<${frameflag}>${data}</${frameflag}>`;
5724
+ const { lowerCaseTagName, fixNestedATags } = options;
5725
+ const dataEndPos = data.length - (frameflag.length + 2);
5726
+ const frameFlagOffset = frameflag.length + 2;
5901
5727
  while (match = kMarkupPattern.exec(data)) {
5902
- var matchText = match[0], leadingSlash = match[1], tagName = match[2], attributes = match[3], closingSlash = match[4];
5903
- var matchLength = matchText.length;
5904
- var tagStartPos = kMarkupPattern.lastIndex - matchLength;
5905
- var tagEndPos = kMarkupPattern.lastIndex;
5728
+ let { 0: matchText, 1: leadingSlash, 2: tagName, 3: attributes, 4: closingSlash } = match;
5729
+ const matchLength = matchText.length;
5730
+ const tagStartPos = kMarkupPattern.lastIndex - matchLength;
5731
+ const tagEndPos = kMarkupPattern.lastIndex;
5906
5732
  if (lastTextPos > -1) {
5907
5733
  if (lastTextPos + matchLength < tagEndPos) {
5908
- var text = data.substring(lastTextPos, tagStartPos);
5734
+ const text = data.substring(lastTextPos, tagStartPos);
5909
5735
  currentParent.appendChild(new text_1.default(text, currentParent, createRange(lastTextPos, tagStartPos)));
5910
5736
  }
5911
5737
  }
@@ -5914,7 +5740,7 @@ var require_html = __commonJS({
5914
5740
  continue;
5915
5741
  if (matchText[1] === "!") {
5916
5742
  if (options.comment) {
5917
- var text = data.substring(tagStartPos + 4, tagEndPos - 3);
5743
+ const text = data.substring(tagStartPos + 4, tagEndPos - 3);
5918
5744
  currentParent.appendChild(new comment_1.default(text, currentParent, createRange(tagStartPos, tagEndPos)));
5919
5745
  }
5920
5746
  continue;
@@ -5922,13 +5748,13 @@ var require_html = __commonJS({
5922
5748
  if (lowerCaseTagName)
5923
5749
  tagName = tagName.toLowerCase();
5924
5750
  if (!leadingSlash) {
5925
- var attrs = {};
5926
- for (var attMatch = void 0; attMatch = kAttributePattern.exec(attributes); ) {
5927
- var key = attMatch[1], val = attMatch[2];
5928
- var isQuoted = val[0] === "'" || val[0] === '"';
5751
+ const attrs = {};
5752
+ for (let attMatch; attMatch = kAttributePattern.exec(attributes); ) {
5753
+ const { 1: key, 2: val } = attMatch;
5754
+ const isQuoted = val[0] === `'` || val[0] === `"`;
5929
5755
  attrs[key.toLowerCase()] = isQuoted ? val.slice(1, val.length - 1) : val;
5930
5756
  }
5931
- var parentTagName = currentParent.rawTagName;
5757
+ const parentTagName = currentParent.rawTagName;
5932
5758
  if (!closingSlash && kElementsClosedByOpening[parentTagName]) {
5933
5759
  if (kElementsClosedByOpening[parentTagName][tagName]) {
5934
5760
  stack.pop();
@@ -5942,21 +5768,21 @@ var require_html = __commonJS({
5942
5768
  }
5943
5769
  noNestedTagIndex = stack.length;
5944
5770
  }
5945
- var tagEndPos_1 = kMarkupPattern.lastIndex;
5946
- var tagStartPos_1 = tagEndPos_1 - matchLength;
5771
+ const tagEndPos2 = kMarkupPattern.lastIndex;
5772
+ const tagStartPos2 = tagEndPos2 - matchLength;
5947
5773
  currentParent = currentParent.appendChild(
5948
5774
  // Initialize range (end position updated later for closed tags)
5949
- new HTMLElement(tagName, attrs, attributes.slice(1), null, createRange(tagStartPos_1, tagEndPos_1), voidTag, options)
5775
+ new HTMLElement(tagName, attrs, attributes.slice(1), null, createRange(tagStartPos2, tagEndPos2), voidTag, options)
5950
5776
  );
5951
5777
  stack.push(currentParent);
5952
5778
  if (is_block_text_element(tagName)) {
5953
- var closeMarkup = "</".concat(tagName, ">");
5954
- var closeIndex = lowerCaseTagName ? data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex) : data.indexOf(closeMarkup, kMarkupPattern.lastIndex);
5955
- var textEndPos = closeIndex === -1 ? dataEndPos : closeIndex;
5779
+ const closeMarkup = `</${tagName}>`;
5780
+ const closeIndex = lowerCaseTagName ? data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex) : data.indexOf(closeMarkup, kMarkupPattern.lastIndex);
5781
+ const textEndPos = closeIndex === -1 ? dataEndPos : closeIndex;
5956
5782
  if (element_should_be_ignore(tagName)) {
5957
- var text = data.substring(tagEndPos_1, textEndPos);
5783
+ const text = data.substring(tagEndPos2, textEndPos);
5958
5784
  if (text.length > 0 && /\S/.test(text)) {
5959
- currentParent.appendChild(new text_1.default(text, currentParent, createRange(tagEndPos_1, textEndPos)));
5785
+ currentParent.appendChild(new text_1.default(text, currentParent, createRange(tagEndPos2, textEndPos)));
5960
5786
  }
5961
5787
  }
5962
5788
  if (closeIndex === -1) {
@@ -5977,7 +5803,7 @@ var require_html = __commonJS({
5977
5803
  currentParent = (0, back_1.default)(stack);
5978
5804
  break;
5979
5805
  } else {
5980
- var parentTagName = currentParent.tagName;
5806
+ const parentTagName = currentParent.tagName;
5981
5807
  if (kElementsClosedByClosing[parentTagName]) {
5982
5808
  if (kElementsClosedByClosing[parentTagName][tagName]) {
5983
5809
  stack.pop();
@@ -5993,20 +5819,17 @@ var require_html = __commonJS({
5993
5819
  return stack;
5994
5820
  }
5995
5821
  exports2.base_parse = base_parse;
5996
- function parse2(data, options) {
5997
- if (options === void 0) {
5998
- options = {};
5999
- }
6000
- var stack = base_parse(data, options);
6001
- var root = stack[0];
6002
- var _loop_1 = function() {
6003
- var last = stack.pop();
6004
- var oneBefore = (0, back_1.default)(stack);
5822
+ function parse2(data, options = {}) {
5823
+ const stack = base_parse(data, options);
5824
+ const [root] = stack;
5825
+ while (stack.length > 1) {
5826
+ const last = stack.pop();
5827
+ const oneBefore = (0, back_1.default)(stack);
6005
5828
  if (last.parentNode && last.parentNode.parentNode) {
6006
5829
  if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
6007
5830
  if (options.parseNoneClosedTags !== true) {
6008
5831
  oneBefore.removeChild(last);
6009
- last.childNodes.forEach(function(child) {
5832
+ last.childNodes.forEach((child) => {
6010
5833
  oneBefore.parentNode.appendChild(child);
6011
5834
  });
6012
5835
  stack.pop();
@@ -6014,22 +5837,28 @@ var require_html = __commonJS({
6014
5837
  } else {
6015
5838
  if (options.parseNoneClosedTags !== true) {
6016
5839
  oneBefore.removeChild(last);
6017
- last.childNodes.forEach(function(child) {
5840
+ last.childNodes.forEach((child) => {
6018
5841
  oneBefore.appendChild(child);
6019
5842
  });
6020
5843
  }
6021
5844
  }
6022
5845
  } else {
6023
5846
  }
6024
- };
6025
- while (stack.length > 1) {
6026
- _loop_1();
6027
5847
  }
6028
5848
  return root;
6029
5849
  }
6030
5850
  exports2.parse = parse2;
5851
+ function resolveInsertable(insertable) {
5852
+ return insertable.map((val) => {
5853
+ if (typeof val === "string") {
5854
+ return new text_1.default(val);
5855
+ }
5856
+ val.remove();
5857
+ return val;
5858
+ });
5859
+ }
6031
5860
  function resetParent(nodes, parent) {
6032
- return nodes.map(function(node) {
5861
+ return nodes.map((node) => {
6033
5862
  node.parentNode = parent;
6034
5863
  return node;
6035
5864
  });
@@ -6056,11 +5885,8 @@ var require_valid = __commonJS({
6056
5885
  "use strict";
6057
5886
  Object.defineProperty(exports2, "__esModule", { value: true });
6058
5887
  var html_1 = require_html();
6059
- function valid(data, options) {
6060
- if (options === void 0) {
6061
- options = {};
6062
- }
6063
- var stack = (0, html_1.base_parse)(data, options);
5888
+ function valid(data, options = {}) {
5889
+ const stack = (0, html_1.base_parse)(data, options);
6064
5890
  return Boolean(stack.length === 1);
6065
5891
  }
6066
5892
  exports2.default = valid;
@@ -6089,10 +5915,7 @@ var require_dist = __commonJS({
6089
5915
  var parse_1 = __importDefault(require_parse3());
6090
5916
  var valid_1 = __importDefault(require_valid());
6091
5917
  exports2.valid = valid_1.default;
6092
- function parse2(data, options) {
6093
- if (options === void 0) {
6094
- options = {};
6095
- }
5918
+ function parse2(data, options = {}) {
6096
5919
  return (0, parse_1.default)(data, options);
6097
5920
  }
6098
5921
  exports2.default = parse2;