@mtkruto/node 0.1.289 → 0.1.299

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 (114) hide show
  1. package/README.md +77 -1
  2. package/esm/client/4_client.js +1 -1
  3. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +83 -0
  4. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +203 -0
  5. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +50 -0
  6. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +274 -0
  7. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +47 -0
  8. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +51 -0
  9. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +66 -0
  10. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +191 -0
  11. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +168 -0
  12. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +385 -0
  13. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +159 -0
  14. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +431 -0
  15. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +181 -0
  16. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +1046 -0
  17. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +42 -0
  18. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +52 -0
  19. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +11 -0
  20. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +122 -0
  21. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +1 -0
  22. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +24 -0
  23. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +46 -0
  24. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +121 -0
  25. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +31 -0
  26. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +30 -0
  27. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +2128 -0
  28. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +2127 -0
  29. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +109 -0
  30. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +108 -0
  31. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +8 -0
  32. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +1 -0
  33. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +90 -0
  34. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +95 -0
  35. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +50 -0
  36. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +128 -0
  37. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +46 -0
  38. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +110 -0
  39. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +42 -0
  40. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +120 -0
  41. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +6 -0
  42. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +6 -0
  43. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +54 -0
  44. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +110 -0
  45. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +40 -0
  46. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +75 -0
  47. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +58 -0
  48. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +101 -0
  49. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.d.ts +2 -0
  50. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.js +5 -1
  51. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.d.ts +2 -2
  52. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.js +5 -1
  53. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/crc32.js +1 -1
  54. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/deflate.js +8 -8
  55. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inffast.js +2 -2
  56. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inflate.js +19 -21
  57. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/trees.js +3 -3
  58. package/package.json +1 -1
  59. package/script/client/4_client.js +1 -1
  60. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +83 -0
  61. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +207 -0
  62. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +50 -0
  63. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +301 -0
  64. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +47 -0
  65. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +55 -0
  66. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +66 -0
  67. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +222 -0
  68. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +168 -0
  69. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +404 -0
  70. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +159 -0
  71. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +438 -0
  72. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +181 -0
  73. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +1052 -0
  74. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +42 -0
  75. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +88 -0
  76. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +11 -0
  77. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +128 -0
  78. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +1 -0
  79. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +30 -0
  80. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +46 -0
  81. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +129 -0
  82. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +31 -0
  83. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +32 -0
  84. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +2128 -0
  85. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +2129 -0
  86. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +109 -0
  87. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +110 -0
  88. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +8 -0
  89. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +3 -0
  90. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +90 -0
  91. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +114 -0
  92. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +50 -0
  93. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +134 -0
  94. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +46 -0
  95. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +118 -0
  96. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +42 -0
  97. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +129 -0
  98. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +6 -0
  99. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +22 -0
  100. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +54 -0
  101. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +119 -0
  102. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +40 -0
  103. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +86 -0
  104. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +58 -0
  105. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +112 -0
  106. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.d.ts +2 -0
  107. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.js +7 -1
  108. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.d.ts +2 -2
  109. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.js +7 -1
  110. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/crc32.js +1 -1
  111. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/deflate.js +8 -8
  112. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inffast.js +2 -2
  113. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inflate.js +19 -21
  114. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/trees.js +3 -3
@@ -0,0 +1,109 @@
1
+ declare const _default: {
2
+ Aacute: string;
3
+ aacute: string;
4
+ Acirc: string;
5
+ acirc: string;
6
+ acute: string;
7
+ AElig: string;
8
+ aelig: string;
9
+ Agrave: string;
10
+ agrave: string;
11
+ amp: string;
12
+ AMP: string;
13
+ Aring: string;
14
+ aring: string;
15
+ Atilde: string;
16
+ atilde: string;
17
+ Auml: string;
18
+ auml: string;
19
+ brvbar: string;
20
+ Ccedil: string;
21
+ ccedil: string;
22
+ cedil: string;
23
+ cent: string;
24
+ copy: string;
25
+ COPY: string;
26
+ curren: string;
27
+ deg: string;
28
+ divide: string;
29
+ Eacute: string;
30
+ eacute: string;
31
+ Ecirc: string;
32
+ ecirc: string;
33
+ Egrave: string;
34
+ egrave: string;
35
+ ETH: string;
36
+ eth: string;
37
+ Euml: string;
38
+ euml: string;
39
+ frac12: string;
40
+ frac14: string;
41
+ frac34: string;
42
+ gt: string;
43
+ GT: string;
44
+ Iacute: string;
45
+ iacute: string;
46
+ Icirc: string;
47
+ icirc: string;
48
+ iexcl: string;
49
+ Igrave: string;
50
+ igrave: string;
51
+ iquest: string;
52
+ Iuml: string;
53
+ iuml: string;
54
+ laquo: string;
55
+ lt: string;
56
+ LT: string;
57
+ macr: string;
58
+ micro: string;
59
+ middot: string;
60
+ nbsp: string;
61
+ not: string;
62
+ Ntilde: string;
63
+ ntilde: string;
64
+ Oacute: string;
65
+ oacute: string;
66
+ Ocirc: string;
67
+ ocirc: string;
68
+ Ograve: string;
69
+ ograve: string;
70
+ ordf: string;
71
+ ordm: string;
72
+ Oslash: string;
73
+ oslash: string;
74
+ Otilde: string;
75
+ otilde: string;
76
+ Ouml: string;
77
+ ouml: string;
78
+ para: string;
79
+ plusmn: string;
80
+ pound: string;
81
+ quot: string;
82
+ QUOT: string;
83
+ raquo: string;
84
+ reg: string;
85
+ REG: string;
86
+ sect: string;
87
+ shy: string;
88
+ sup1: string;
89
+ sup2: string;
90
+ sup3: string;
91
+ szlig: string;
92
+ THORN: string;
93
+ thorn: string;
94
+ times: string;
95
+ Uacute: string;
96
+ uacute: string;
97
+ Ucirc: string;
98
+ ucirc: string;
99
+ Ugrave: string;
100
+ ugrave: string;
101
+ uml: string;
102
+ Uuml: string;
103
+ uuml: string;
104
+ Yacute: string;
105
+ yacute: string;
106
+ yen: string;
107
+ yuml: string;
108
+ };
109
+ export default _default;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ Aacute: 'Á',
5
+ aacute: 'á',
6
+ Acirc: 'Â',
7
+ acirc: 'â',
8
+ acute: '´',
9
+ AElig: 'Æ',
10
+ aelig: 'æ',
11
+ Agrave: 'À',
12
+ agrave: 'à',
13
+ amp: '&',
14
+ AMP: '&',
15
+ Aring: 'Å',
16
+ aring: 'å',
17
+ Atilde: 'Ã',
18
+ atilde: 'ã',
19
+ Auml: 'Ä',
20
+ auml: 'ä',
21
+ brvbar: '¦',
22
+ Ccedil: 'Ç',
23
+ ccedil: 'ç',
24
+ cedil: '¸',
25
+ cent: '¢',
26
+ copy: '©',
27
+ COPY: '©',
28
+ curren: '¤',
29
+ deg: '°',
30
+ divide: '÷',
31
+ Eacute: 'É',
32
+ eacute: 'é',
33
+ Ecirc: 'Ê',
34
+ ecirc: 'ê',
35
+ Egrave: 'È',
36
+ egrave: 'è',
37
+ ETH: 'Ð',
38
+ eth: 'ð',
39
+ Euml: 'Ë',
40
+ euml: 'ë',
41
+ frac12: '½',
42
+ frac14: '¼',
43
+ frac34: '¾',
44
+ gt: '>',
45
+ GT: '>',
46
+ Iacute: 'Í',
47
+ iacute: 'í',
48
+ Icirc: 'Î',
49
+ icirc: 'î',
50
+ iexcl: '¡',
51
+ Igrave: 'Ì',
52
+ igrave: 'ì',
53
+ iquest: '¿',
54
+ Iuml: 'Ï',
55
+ iuml: 'ï',
56
+ laquo: '«',
57
+ lt: '<',
58
+ LT: '<',
59
+ macr: '¯',
60
+ micro: 'µ',
61
+ middot: '·',
62
+ nbsp: ' ',
63
+ not: '¬',
64
+ Ntilde: 'Ñ',
65
+ ntilde: 'ñ',
66
+ Oacute: 'Ó',
67
+ oacute: 'ó',
68
+ Ocirc: 'Ô',
69
+ ocirc: 'ô',
70
+ Ograve: 'Ò',
71
+ ograve: 'ò',
72
+ ordf: 'ª',
73
+ ordm: 'º',
74
+ Oslash: 'Ø',
75
+ oslash: 'ø',
76
+ Otilde: 'Õ',
77
+ otilde: 'õ',
78
+ Ouml: 'Ö',
79
+ ouml: 'ö',
80
+ para: '¶',
81
+ plusmn: '±',
82
+ pound: '£',
83
+ quot: '"',
84
+ QUOT: '"',
85
+ raquo: '»',
86
+ reg: '®',
87
+ REG: '®',
88
+ sect: '§',
89
+ shy: '­',
90
+ sup1: '¹',
91
+ sup2: '²',
92
+ sup3: '³',
93
+ szlig: 'ß',
94
+ THORN: 'Þ',
95
+ thorn: 'þ',
96
+ times: '×',
97
+ Uacute: 'Ú',
98
+ uacute: 'ú',
99
+ Ucirc: 'Û',
100
+ ucirc: 'û',
101
+ Ugrave: 'Ù',
102
+ ugrave: 'ù',
103
+ uml: '¨',
104
+ Uuml: 'Ü',
105
+ uuml: 'ü',
106
+ Yacute: 'Ý',
107
+ yacute: 'ý',
108
+ yen: '¥',
109
+ yuml: 'ÿ',
110
+ };
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ amp: string;
3
+ apos: string;
4
+ gt: string;
5
+ lt: string;
6
+ quot: string;
7
+ };
8
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = { amp: '&', apos: "'", gt: '>', lt: '<', quot: '"' };
@@ -0,0 +1,90 @@
1
+ /** The level of entities to support. */
2
+ export declare enum EntityLevel {
3
+ /** Support only XML entities. */
4
+ XML = 0,
5
+ /** Support HTML entities, which are a superset of XML entities. */
6
+ HTML = 1
7
+ }
8
+ /** Determines whether some entities are allowed to be written without a trailing `;`. */
9
+ export declare enum DecodingMode {
10
+ /** Support legacy HTML entities. */
11
+ Legacy = 0,
12
+ /** Do not support legacy HTML entities. */
13
+ Strict = 1
14
+ }
15
+ export declare enum EncodingMode {
16
+ /**
17
+ * The output is UTF-8 encoded. Only characters that need escaping within
18
+ * HTML will be escaped.
19
+ */
20
+ UTF8 = 0,
21
+ /**
22
+ * The output consists only of ASCII characters. Characters that need
23
+ * escaping within HTML, and characters that aren't ASCII characters will
24
+ * be escaped.
25
+ */
26
+ ASCII = 1,
27
+ /**
28
+ * Encode all characters that have an equivalent entity, as well as all
29
+ * characters that are not ASCII characters.
30
+ */
31
+ Extensive = 2
32
+ }
33
+ interface DecodingOptions {
34
+ /**
35
+ * The level of entities to support.
36
+ * @default EntityLevel.XML
37
+ */
38
+ level?: EntityLevel;
39
+ /**
40
+ * Decoding mode. If `Legacy`, will support legacy entities not terminated
41
+ * with a semicolon (`;`).
42
+ *
43
+ * Always `Strict` for XML. For HTML, set this to `true` if you are parsing
44
+ * an attribute value.
45
+ *
46
+ * The deprecated `decodeStrict` function defaults this to `Strict`.
47
+ *
48
+ * @default DecodingMode.Legacy
49
+ */
50
+ mode?: DecodingMode;
51
+ }
52
+ /**
53
+ * Decodes a string with entities.
54
+ *
55
+ * @param data String to decode.
56
+ * @param options Decoding options.
57
+ */
58
+ export declare function decode(data: string, options?: DecodingOptions | EntityLevel): string;
59
+ /**
60
+ * Decodes a string with entities. Does not allow missing trailing semicolons for entities.
61
+ *
62
+ * @param data String to decode.
63
+ * @param options Decoding options.
64
+ * @deprecated Use `decode` with the `mode` set to `Strict`.
65
+ */
66
+ export declare function decodeStrict(data: string, options?: DecodingOptions | EntityLevel): string;
67
+ /**
68
+ * Options for `encode`.
69
+ */
70
+ export interface EncodingOptions {
71
+ /**
72
+ * The level of entities to support.
73
+ * @default EntityLevel.XML
74
+ */
75
+ level?: EntityLevel;
76
+ /**
77
+ * Output format.
78
+ * @default EncodingMode.Extensive
79
+ */
80
+ mode?: EncodingMode;
81
+ }
82
+ /**
83
+ * Encodes a string with entities.
84
+ *
85
+ * @param data String to encode.
86
+ * @param options Encoding options.
87
+ */
88
+ export declare function encode(data: string, options?: EncodingOptions | EntityLevel): string;
89
+ export { encodeXML, encodeHTML, encodeNonAsciiHTML, escape, escapeUTF8, encodeHTML as encodeHTML4, encodeHTML as encodeHTML5, } from './encode.js';
90
+ export { decodeXML, decodeHTML, decodeHTMLStrict, decodeHTML as decodeHTML4, decodeHTML as decodeHTML5, decodeHTMLStrict as decodeHTML4Strict, decodeHTMLStrict as decodeHTML5Strict, decodeXML as decodeXMLStrict, } from './decode.js';
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.encodeHTML5 = exports.encodeHTML4 = exports.escapeUTF8 = exports.escape = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = exports.EncodingMode = exports.DecodingMode = exports.EntityLevel = void 0;
4
+ const decode_js_1 = require("./decode.js");
5
+ const encode_js_1 = require("./encode.js");
6
+ /** The level of entities to support. */
7
+ var EntityLevel;
8
+ (function (EntityLevel) {
9
+ /** Support only XML entities. */
10
+ EntityLevel[EntityLevel["XML"] = 0] = "XML";
11
+ /** Support HTML entities, which are a superset of XML entities. */
12
+ EntityLevel[EntityLevel["HTML"] = 1] = "HTML";
13
+ })(EntityLevel || (exports.EntityLevel = EntityLevel = {}));
14
+ /** Determines whether some entities are allowed to be written without a trailing `;`. */
15
+ var DecodingMode;
16
+ (function (DecodingMode) {
17
+ /** Support legacy HTML entities. */
18
+ DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
19
+ /** Do not support legacy HTML entities. */
20
+ DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
21
+ })(DecodingMode || (exports.DecodingMode = DecodingMode = {}));
22
+ var EncodingMode;
23
+ (function (EncodingMode) {
24
+ /**
25
+ * The output is UTF-8 encoded. Only characters that need escaping within
26
+ * HTML will be escaped.
27
+ */
28
+ EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8";
29
+ /**
30
+ * The output consists only of ASCII characters. Characters that need
31
+ * escaping within HTML, and characters that aren't ASCII characters will
32
+ * be escaped.
33
+ */
34
+ EncodingMode[EncodingMode["ASCII"] = 1] = "ASCII";
35
+ /**
36
+ * Encode all characters that have an equivalent entity, as well as all
37
+ * characters that are not ASCII characters.
38
+ */
39
+ EncodingMode[EncodingMode["Extensive"] = 2] = "Extensive";
40
+ })(EncodingMode || (exports.EncodingMode = EncodingMode = {}));
41
+ /**
42
+ * Decodes a string with entities.
43
+ *
44
+ * @param data String to decode.
45
+ * @param options Decoding options.
46
+ */
47
+ function decode(data, options = EntityLevel.XML) {
48
+ const opts = typeof options === 'number' ? { level: options } : options;
49
+ if (opts.level === EntityLevel.HTML) {
50
+ if (opts.mode === DecodingMode.Strict) {
51
+ return (0, decode_js_1.decodeHTMLStrict)(data);
52
+ }
53
+ return (0, decode_js_1.decodeHTML)(data);
54
+ }
55
+ return (0, decode_js_1.decodeXML)(data);
56
+ }
57
+ exports.decode = decode;
58
+ /**
59
+ * Decodes a string with entities. Does not allow missing trailing semicolons for entities.
60
+ *
61
+ * @param data String to decode.
62
+ * @param options Decoding options.
63
+ * @deprecated Use `decode` with the `mode` set to `Strict`.
64
+ */
65
+ function decodeStrict(data, options = EntityLevel.XML) {
66
+ const opts = typeof options === 'number' ? { level: options } : options;
67
+ if (opts.level === EntityLevel.HTML) {
68
+ if (opts.mode === DecodingMode.Legacy) {
69
+ return (0, decode_js_1.decodeHTML)(data);
70
+ }
71
+ return (0, decode_js_1.decodeHTMLStrict)(data);
72
+ }
73
+ return (0, decode_js_1.decodeXML)(data);
74
+ }
75
+ exports.decodeStrict = decodeStrict;
76
+ /**
77
+ * Encodes a string with entities.
78
+ *
79
+ * @param data String to encode.
80
+ * @param options Encoding options.
81
+ */
82
+ function encode(data, options = EntityLevel.XML) {
83
+ const opts = typeof options === 'number' ? { level: options } : options;
84
+ if (opts.level === EntityLevel.HTML) {
85
+ if (opts.mode === EncodingMode.ASCII) {
86
+ return (0, encode_js_1.encodeNonAsciiHTML)(data);
87
+ }
88
+ // TODO Support opts.mode === 'UTF8'
89
+ return (0, encode_js_1.encodeHTML)(data);
90
+ }
91
+ // TODO Support opts.mode === 'UTF8'
92
+ // ASCII and Extensive are equivalent
93
+ return (0, encode_js_1.encodeXML)(data);
94
+ }
95
+ exports.encode = encode;
96
+ var encode_js_2 = require("./encode.js");
97
+ Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function () { return encode_js_2.encodeXML; } });
98
+ Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function () { return encode_js_2.encodeHTML; } });
99
+ Object.defineProperty(exports, "encodeNonAsciiHTML", { enumerable: true, get: function () { return encode_js_2.encodeNonAsciiHTML; } });
100
+ Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return encode_js_2.escape; } });
101
+ Object.defineProperty(exports, "escapeUTF8", { enumerable: true, get: function () { return encode_js_2.escapeUTF8; } });
102
+ // Legacy aliases (deprecated)
103
+ Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function () { return encode_js_2.encodeHTML; } });
104
+ Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function () { return encode_js_2.encodeHTML; } });
105
+ var decode_js_2 = require("./decode.js");
106
+ Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function () { return decode_js_2.decodeXML; } });
107
+ Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return decode_js_2.decodeHTML; } });
108
+ Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } });
109
+ // Legacy aliases (deprecated)
110
+ Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function () { return decode_js_2.decodeHTML; } });
111
+ Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function () { return decode_js_2.decodeHTML; } });
112
+ Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } });
113
+ Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } });
114
+ Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function () { return decode_js_2.decodeXML; } });
@@ -0,0 +1,50 @@
1
+ import { Node } from '../Node.js';
2
+ /**
3
+ * Given an array of nodes, remove any member that is contained by another.
4
+ *
5
+ * @param nodes Nodes to filter.
6
+ * @returns Remaining nodes that aren't subtrees of each other.
7
+ */
8
+ export declare function removeSubsets(nodes: Node[]): Node[];
9
+ export declare const enum DocumentPosition {
10
+ DISCONNECTED = 1,
11
+ PRECEDING = 2,
12
+ FOLLOWING = 4,
13
+ CONTAINS = 8,
14
+ CONTAINED_BY = 16
15
+ }
16
+ /**
17
+ * Compare the position of one node against another node in any other document.
18
+ * The return value is a bitmask with the following values:
19
+ *
20
+ * Document order:
21
+ * > There is an ordering, document order, defined on all the nodes in the
22
+ * > document corresponding to the order in which the first character of the
23
+ * > XML representation of each node occurs in the XML representation of the
24
+ * > document after expansion of general entities. Thus, the document element
25
+ * > node will be the first node. Element nodes occur before their children.
26
+ * > Thus, document order orders element nodes in order of the occurrence of
27
+ * > their start-tag in the XML (after expansion of entities). The attribute
28
+ * > nodes of an element occur after the element and before its children. The
29
+ * > relative order of attribute nodes is implementation-dependent./
30
+ *
31
+ * Source:
32
+ * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
33
+ *
34
+ * @param nodeA The first node to use in the comparison
35
+ * @param nodeB The second node to use in the comparison
36
+ * @returns A bitmask describing the input nodes' relative position.
37
+ *
38
+ * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
39
+ * a description of these values.
40
+ */
41
+ export declare function compareDocumentPosition(nodeA: Node, nodeB: Node): number;
42
+ /**
43
+ * Sort an array of nodes based on their relative position in the document and
44
+ * remove any duplicate nodes. If the array contains nodes that do not belong
45
+ * to the same document, sort order is unspecified.
46
+ *
47
+ * @param nodes Array of DOM nodes.
48
+ * @returns Collection of unique nodes, sorted in document order.
49
+ */
50
+ export declare function uniqueSort<T extends Node>(nodes: T[]): T[];
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uniqueSort = exports.compareDocumentPosition = exports.DocumentPosition = exports.removeSubsets = void 0;
4
+ const Node_js_1 = require("../Node.js");
5
+ /**
6
+ * Given an array of nodes, remove any member that is contained by another.
7
+ *
8
+ * @param nodes Nodes to filter.
9
+ * @returns Remaining nodes that aren't subtrees of each other.
10
+ */
11
+ function removeSubsets(nodes) {
12
+ let idx = nodes.length;
13
+ /*
14
+ * Check if each node (or one of its ancestors) is already contained in the
15
+ * array.
16
+ */
17
+ while (--idx >= 0) {
18
+ const node = nodes[idx];
19
+ /*
20
+ * Remove the node if it is not unique.
21
+ * We are going through the array from the end, so we only
22
+ * have to check nodes that preceed the node under consideration in the array.
23
+ */
24
+ if (idx > 0 && nodes.lastIndexOf(node, idx - 1) >= 0) {
25
+ nodes.splice(idx, 1);
26
+ continue;
27
+ }
28
+ for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
29
+ if (nodes.includes(ancestor)) {
30
+ nodes.splice(idx, 1);
31
+ break;
32
+ }
33
+ }
34
+ }
35
+ return nodes;
36
+ }
37
+ exports.removeSubsets = removeSubsets;
38
+ // Source: http://dom.spec.whatwg.org/#dom-node-comparedocumentposition
39
+ var DocumentPosition;
40
+ (function (DocumentPosition) {
41
+ DocumentPosition[DocumentPosition["DISCONNECTED"] = 1] = "DISCONNECTED";
42
+ DocumentPosition[DocumentPosition["PRECEDING"] = 2] = "PRECEDING";
43
+ DocumentPosition[DocumentPosition["FOLLOWING"] = 4] = "FOLLOWING";
44
+ DocumentPosition[DocumentPosition["CONTAINS"] = 8] = "CONTAINS";
45
+ DocumentPosition[DocumentPosition["CONTAINED_BY"] = 16] = "CONTAINED_BY";
46
+ })(DocumentPosition || (exports.DocumentPosition = DocumentPosition = {}));
47
+ /**
48
+ * Compare the position of one node against another node in any other document.
49
+ * The return value is a bitmask with the following values:
50
+ *
51
+ * Document order:
52
+ * > There is an ordering, document order, defined on all the nodes in the
53
+ * > document corresponding to the order in which the first character of the
54
+ * > XML representation of each node occurs in the XML representation of the
55
+ * > document after expansion of general entities. Thus, the document element
56
+ * > node will be the first node. Element nodes occur before their children.
57
+ * > Thus, document order orders element nodes in order of the occurrence of
58
+ * > their start-tag in the XML (after expansion of entities). The attribute
59
+ * > nodes of an element occur after the element and before its children. The
60
+ * > relative order of attribute nodes is implementation-dependent./
61
+ *
62
+ * Source:
63
+ * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
64
+ *
65
+ * @param nodeA The first node to use in the comparison
66
+ * @param nodeB The second node to use in the comparison
67
+ * @returns A bitmask describing the input nodes' relative position.
68
+ *
69
+ * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
70
+ * a description of these values.
71
+ */
72
+ function compareDocumentPosition(nodeA, nodeB) {
73
+ const aParents = [];
74
+ const bParents = [];
75
+ if (nodeA === nodeB) {
76
+ return 0;
77
+ }
78
+ let current = (0, Node_js_1.hasChildren)(nodeA) ? nodeA : nodeA.parent;
79
+ while (current) {
80
+ aParents.unshift(current);
81
+ current = current.parent;
82
+ }
83
+ current = (0, Node_js_1.hasChildren)(nodeB) ? nodeB : nodeB.parent;
84
+ while (current) {
85
+ bParents.unshift(current);
86
+ current = current.parent;
87
+ }
88
+ const maxIdx = Math.min(aParents.length, bParents.length);
89
+ let idx = 0;
90
+ while (idx < maxIdx && aParents[idx] === bParents[idx]) {
91
+ idx++;
92
+ }
93
+ if (idx === 0) {
94
+ return DocumentPosition.DISCONNECTED;
95
+ }
96
+ const sharedParent = aParents[idx - 1];
97
+ const siblings = sharedParent.children;
98
+ const aSibling = aParents[idx];
99
+ const bSibling = bParents[idx];
100
+ if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
101
+ if (sharedParent === nodeB) {
102
+ return DocumentPosition.FOLLOWING | DocumentPosition.CONTAINED_BY;
103
+ }
104
+ return DocumentPosition.FOLLOWING;
105
+ }
106
+ if (sharedParent === nodeA) {
107
+ return DocumentPosition.PRECEDING | DocumentPosition.CONTAINS;
108
+ }
109
+ return DocumentPosition.PRECEDING;
110
+ }
111
+ exports.compareDocumentPosition = compareDocumentPosition;
112
+ /**
113
+ * Sort an array of nodes based on their relative position in the document and
114
+ * remove any duplicate nodes. If the array contains nodes that do not belong
115
+ * to the same document, sort order is unspecified.
116
+ *
117
+ * @param nodes Array of DOM nodes.
118
+ * @returns Collection of unique nodes, sorted in document order.
119
+ */
120
+ function uniqueSort(nodes) {
121
+ nodes = nodes.filter((node, i, arr) => !arr.includes(node, i + 1));
122
+ nodes.sort((a, b) => {
123
+ const relative = compareDocumentPosition(a, b);
124
+ if (relative & DocumentPosition.PRECEDING) {
125
+ return -1;
126
+ }
127
+ else if (relative & DocumentPosition.FOLLOWING) {
128
+ return 1;
129
+ }
130
+ return 0;
131
+ });
132
+ return nodes;
133
+ }
134
+ exports.uniqueSort = uniqueSort;
@@ -0,0 +1,46 @@
1
+ import { Node, Element } from '../Node.js';
2
+ import { ElementType } from '../ElementType.js';
3
+ interface TestElementOpts {
4
+ tag_name?: string | ((name: string) => boolean);
5
+ tag_type?: string | ((name: string) => boolean);
6
+ tag_contains?: string | ((data?: string) => boolean);
7
+ [attributeName: string]: undefined | string | ((attributeValue: string) => boolean);
8
+ }
9
+ /**
10
+ * @param options An object describing nodes to look for.
11
+ * @param node The element to test.
12
+ * @returns Whether the element matches the description in `options`.
13
+ */
14
+ export declare function testElement(options: TestElementOpts, node: Node): boolean;
15
+ /**
16
+ * @param options An object describing nodes to look for.
17
+ * @param nodes Nodes to search through.
18
+ * @param recurse Also consider child nodes.
19
+ * @param limit Maximum number of nodes to return.
20
+ * @returns All nodes that match `options`.
21
+ */
22
+ export declare function getElements(options: TestElementOpts, nodes: Node | Node[], recurse: boolean, limit?: number): Node[];
23
+ /**
24
+ * @param id The unique ID attribute value to look for.
25
+ * @param nodes Nodes to search through.
26
+ * @param recurse Also consider child nodes.
27
+ * @returns The node with the supplied ID.
28
+ */
29
+ export declare function getElementById(id: string | ((id: string) => boolean), nodes: Node | Node[], recurse?: boolean): Element | null;
30
+ /**
31
+ * @param tagName Tag name to search for.
32
+ * @param nodes Nodes to search through.
33
+ * @param recurse Also consider child nodes.
34
+ * @param limit Maximum number of nodes to return.
35
+ * @returns All nodes with the supplied `tagName`.
36
+ */
37
+ export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Element[];
38
+ /**
39
+ * @param type Element type to look for.
40
+ * @param nodes Nodes to search through.
41
+ * @param recurse Also consider child nodes.
42
+ * @param limit Maximum number of nodes to return.
43
+ * @returns All nodes with the supplied `type`.
44
+ */
45
+ export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Node[];
46
+ export {};