@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,47 @@
1
+ /** Types of elements found in htmlparser2's DOM */
2
+ export declare enum ElementType {
3
+ /** Type for the root element of a document */
4
+ Root = "root",
5
+ /** Type for Text */
6
+ Text = "text",
7
+ /** Type for <? ... ?> */
8
+ Directive = "directive",
9
+ /** Type for <!-- ... --> */
10
+ Comment = "comment",
11
+ /** Type for <script> tags */
12
+ Script = "script",
13
+ /** Type for <style> tags */
14
+ Style = "style",
15
+ /** Type for Any tag */
16
+ Tag = "tag",
17
+ /** Type for <![CDATA[ ... ]]> */
18
+ CDATA = "cdata",
19
+ /** Type for <!doctype ...> */
20
+ Doctype = "doctype"
21
+ }
22
+ /**
23
+ * Tests whether an element is a tag or not.
24
+ *
25
+ * @param elem Element to test
26
+ */
27
+ export declare function isTag(elem: {
28
+ type: ElementType;
29
+ }): boolean;
30
+ /** Type for the root element of a document */
31
+ export declare const Root = ElementType.Root;
32
+ /** Type for Text */
33
+ export declare const Text = ElementType.Text;
34
+ /** Type for <? ... ?> */
35
+ export declare const Directive = ElementType.Directive;
36
+ /** Type for <!-- ... --> */
37
+ export declare const Comment = ElementType.Comment;
38
+ /** Type for <script> tags */
39
+ export declare const Script = ElementType.Script;
40
+ /** Type for <style> tags */
41
+ export declare const Style = ElementType.Style;
42
+ /** Type for Any tag */
43
+ export declare const Tag = ElementType.Tag;
44
+ /** Type for <![CDATA[ ... ]]> */
45
+ export declare const CDATA = ElementType.CDATA;
46
+ /** Type for <!doctype ...> */
47
+ export declare const Doctype = ElementType.Doctype;
@@ -0,0 +1,51 @@
1
+ /** Types of elements found in htmlparser2's DOM */
2
+ export var ElementType;
3
+ (function (ElementType) {
4
+ /** Type for the root element of a document */
5
+ ElementType["Root"] = "root";
6
+ /** Type for Text */
7
+ ElementType["Text"] = "text";
8
+ /** Type for <? ... ?> */
9
+ ElementType["Directive"] = "directive";
10
+ /** Type for <!-- ... --> */
11
+ ElementType["Comment"] = "comment";
12
+ /** Type for <script> tags */
13
+ ElementType["Script"] = "script";
14
+ /** Type for <style> tags */
15
+ ElementType["Style"] = "style";
16
+ /** Type for Any tag */
17
+ ElementType["Tag"] = "tag";
18
+ /** Type for <![CDATA[ ... ]]> */
19
+ ElementType["CDATA"] = "cdata";
20
+ /** Type for <!doctype ...> */
21
+ ElementType["Doctype"] = "doctype";
22
+ })(ElementType || (ElementType = {}));
23
+ /**
24
+ * Tests whether an element is a tag or not.
25
+ *
26
+ * @param elem Element to test
27
+ */
28
+ export function isTag(elem) {
29
+ return (elem.type === ElementType.Tag ||
30
+ elem.type === ElementType.Script ||
31
+ elem.type === ElementType.Style);
32
+ }
33
+ // Exports for backwards compatibility
34
+ /** Type for the root element of a document */
35
+ export const Root = ElementType.Root;
36
+ /** Type for Text */
37
+ export const Text = ElementType.Text;
38
+ /** Type for <? ... ?> */
39
+ export const Directive = ElementType.Directive;
40
+ /** Type for <!-- ... --> */
41
+ export const Comment = ElementType.Comment;
42
+ /** Type for <script> tags */
43
+ export const Script = ElementType.Script;
44
+ /** Type for <style> tags */
45
+ export const Style = ElementType.Style;
46
+ /** Type for Any tag */
47
+ export const Tag = ElementType.Tag;
48
+ /** Type for <![CDATA[ ... ]]> */
49
+ export const CDATA = ElementType.CDATA;
50
+ /** Type for <!doctype ...> */
51
+ export const Doctype = ElementType.Doctype;
@@ -0,0 +1,66 @@
1
+ import DomHandler, { DomHandlerOptions } from './DomHandler.js';
2
+ import { ParserOptions } from './Parser.js';
3
+ declare enum FeedItemMediaMedium {
4
+ image = 0,
5
+ audio = 1,
6
+ video = 2,
7
+ document = 3,
8
+ executable = 4
9
+ }
10
+ declare enum FeedItemMediaExpression {
11
+ sample = 0,
12
+ full = 1,
13
+ nonstop = 2
14
+ }
15
+ interface FeedItemMedia {
16
+ url?: string;
17
+ fileSize?: number;
18
+ type?: string;
19
+ medium: FeedItemMediaMedium | undefined;
20
+ isDefault: boolean;
21
+ expression?: FeedItemMediaExpression;
22
+ bitrate?: number;
23
+ framerate?: number;
24
+ samplingrate?: number;
25
+ channels?: number;
26
+ duration?: number;
27
+ height?: number;
28
+ width?: number;
29
+ lang?: string;
30
+ }
31
+ interface FeedItem {
32
+ id?: string;
33
+ title?: string;
34
+ link?: string;
35
+ description?: string;
36
+ pubDate?: Date;
37
+ media?: FeedItemMedia[];
38
+ }
39
+ interface Feed {
40
+ type?: string;
41
+ id?: string;
42
+ title?: string;
43
+ link?: string;
44
+ description?: string;
45
+ updated?: Date;
46
+ author?: string;
47
+ items?: FeedItem[];
48
+ }
49
+ export declare class FeedHandler extends DomHandler {
50
+ feed?: Feed;
51
+ /**
52
+ *
53
+ * @param callback
54
+ * @param options
55
+ */
56
+ constructor(callback?: ((error: Error | null) => void) | DomHandlerOptions, options?: DomHandlerOptions);
57
+ onend(): void;
58
+ }
59
+ /**
60
+ * Parse a feed.
61
+ *
62
+ * @param feed The feed that should be parsed, as a string.
63
+ * @param options Optionally, options for parsing. When using this option, you should set `xmlMode` to `true`.
64
+ */
65
+ export declare function parseFeed(feed: string, options?: ParserOptions & DomHandlerOptions): Feed | undefined;
66
+ export {};
@@ -0,0 +1,191 @@
1
+ import DomHandler from './DomHandler.js';
2
+ import * as DomUtils from './utils/mod.js';
3
+ import { Parser } from './Parser.js';
4
+ var FeedItemMediaMedium;
5
+ (function (FeedItemMediaMedium) {
6
+ FeedItemMediaMedium[FeedItemMediaMedium["image"] = 0] = "image";
7
+ FeedItemMediaMedium[FeedItemMediaMedium["audio"] = 1] = "audio";
8
+ FeedItemMediaMedium[FeedItemMediaMedium["video"] = 2] = "video";
9
+ FeedItemMediaMedium[FeedItemMediaMedium["document"] = 3] = "document";
10
+ FeedItemMediaMedium[FeedItemMediaMedium["executable"] = 4] = "executable";
11
+ })(FeedItemMediaMedium || (FeedItemMediaMedium = {}));
12
+ var FeedItemMediaExpression;
13
+ (function (FeedItemMediaExpression) {
14
+ FeedItemMediaExpression[FeedItemMediaExpression["sample"] = 0] = "sample";
15
+ FeedItemMediaExpression[FeedItemMediaExpression["full"] = 1] = "full";
16
+ FeedItemMediaExpression[FeedItemMediaExpression["nonstop"] = 2] = "nonstop";
17
+ })(FeedItemMediaExpression || (FeedItemMediaExpression = {}));
18
+ // TODO: Consume data as it is coming in
19
+ export class FeedHandler extends DomHandler {
20
+ /**
21
+ *
22
+ * @param callback
23
+ * @param options
24
+ */
25
+ constructor(callback, options) {
26
+ if (typeof callback === 'object') {
27
+ callback = undefined;
28
+ options = callback;
29
+ }
30
+ super(callback, options);
31
+ Object.defineProperty(this, "feed", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: void 0
36
+ });
37
+ }
38
+ onend() {
39
+ const feedRoot = getOneElement(isValidFeed, this.dom);
40
+ if (!feedRoot) {
41
+ this.handleCallback(new Error("couldn't find root of feed"));
42
+ return;
43
+ }
44
+ const feed = {};
45
+ if (feedRoot.name === 'feed') {
46
+ const childs = feedRoot.children;
47
+ feed.type = 'atom';
48
+ addConditionally(feed, 'id', 'id', childs);
49
+ addConditionally(feed, 'title', 'title', childs);
50
+ const href = getAttribute('href', getOneElement('link', childs));
51
+ if (href) {
52
+ feed.link = href;
53
+ }
54
+ addConditionally(feed, 'description', 'subtitle', childs);
55
+ const updated = fetch('updated', childs);
56
+ if (updated) {
57
+ feed.updated = new Date(updated);
58
+ }
59
+ addConditionally(feed, 'author', 'email', childs, true);
60
+ feed.items = getElements('entry', childs).map(item => {
61
+ const entry = {};
62
+ const { children } = item;
63
+ addConditionally(entry, 'id', 'id', children);
64
+ addConditionally(entry, 'title', 'title', children);
65
+ const href = getAttribute('href', getOneElement('link', children));
66
+ if (href) {
67
+ entry.link = href;
68
+ }
69
+ const description = fetch('summary', children) || fetch('content', children);
70
+ if (description) {
71
+ entry.description = description;
72
+ }
73
+ const pubDate = fetch('updated', children);
74
+ if (pubDate) {
75
+ entry.pubDate = new Date(pubDate);
76
+ }
77
+ entry.media = getMediaElements(children);
78
+ return entry;
79
+ });
80
+ }
81
+ else {
82
+ const childs = getOneElement('channel', feedRoot.children)?.children ?? [];
83
+ feed.type = feedRoot.name.substr(0, 3);
84
+ feed.id = '';
85
+ addConditionally(feed, 'title', 'title', childs);
86
+ addConditionally(feed, 'link', 'link', childs);
87
+ addConditionally(feed, 'description', 'description', childs);
88
+ const updated = fetch('lastBuildDate', childs);
89
+ if (updated) {
90
+ feed.updated = new Date(updated);
91
+ }
92
+ addConditionally(feed, 'author', 'managingEditor', childs, true);
93
+ feed.items = getElements('item', feedRoot.children).map((item) => {
94
+ const entry = {};
95
+ const { children } = item;
96
+ addConditionally(entry, 'id', 'guid', children);
97
+ addConditionally(entry, 'title', 'title', children);
98
+ addConditionally(entry, 'link', 'link', children);
99
+ addConditionally(entry, 'description', 'description', children);
100
+ const pubDate = fetch('pubDate', children);
101
+ if (pubDate)
102
+ entry.pubDate = new Date(pubDate);
103
+ entry.media = getMediaElements(children);
104
+ return entry;
105
+ });
106
+ }
107
+ this.feed = feed;
108
+ this.handleCallback(null);
109
+ }
110
+ }
111
+ function getMediaElements(where) {
112
+ return getElements('media:content', where).map(elem => {
113
+ const media = {
114
+ medium: elem.attribs.medium,
115
+ isDefault: !!elem.attribs.isDefault,
116
+ };
117
+ if (elem.attribs.url) {
118
+ media.url = elem.attribs.url;
119
+ }
120
+ if (elem.attribs.fileSize) {
121
+ media.fileSize = parseInt(elem.attribs.fileSize, 10);
122
+ }
123
+ if (elem.attribs.type) {
124
+ media.type = elem.attribs.type;
125
+ }
126
+ if (elem.attribs.expression) {
127
+ media.expression = elem.attribs
128
+ .expression;
129
+ }
130
+ if (elem.attribs.bitrate) {
131
+ media.bitrate = parseInt(elem.attribs.bitrate, 10);
132
+ }
133
+ if (elem.attribs.framerate) {
134
+ media.framerate = parseInt(elem.attribs.framerate, 10);
135
+ }
136
+ if (elem.attribs.samplingrate) {
137
+ media.samplingrate = parseInt(elem.attribs.samplingrate, 10);
138
+ }
139
+ if (elem.attribs.channels) {
140
+ media.channels = parseInt(elem.attribs.channels, 10);
141
+ }
142
+ if (elem.attribs.duration) {
143
+ media.duration = parseInt(elem.attribs.duration, 10);
144
+ }
145
+ if (elem.attribs.height) {
146
+ media.height = parseInt(elem.attribs.height, 10);
147
+ }
148
+ if (elem.attribs.width) {
149
+ media.width = parseInt(elem.attribs.width, 10);
150
+ }
151
+ if (elem.attribs.lang) {
152
+ media.lang = elem.attribs.lang;
153
+ }
154
+ return media;
155
+ });
156
+ }
157
+ function getElements(tagName, where) {
158
+ return DomUtils.getElementsByTagName(tagName, where, true);
159
+ }
160
+ function getOneElement(tagName, node) {
161
+ return DomUtils.getElementsByTagName(tagName, node, true, 1)[0];
162
+ }
163
+ function fetch(tagName, where, recurse = false) {
164
+ return DomUtils.getText(DomUtils.getElementsByTagName(tagName, where, recurse, 1)).trim();
165
+ }
166
+ function getAttribute(name, elem) {
167
+ if (!elem) {
168
+ return null;
169
+ }
170
+ const { attribs } = elem;
171
+ return attribs[name];
172
+ }
173
+ function addConditionally(obj, prop, what, where, recurse = false) {
174
+ const tmp = fetch(what, where, recurse);
175
+ if (tmp)
176
+ obj[prop] = tmp;
177
+ }
178
+ function isValidFeed(value) {
179
+ return value === 'rss' || value === 'feed' || value === 'rdf:RDF';
180
+ }
181
+ /**
182
+ * Parse a feed.
183
+ *
184
+ * @param feed The feed that should be parsed, as a string.
185
+ * @param options Optionally, options for parsing. When using this option, you should set `xmlMode` to `true`.
186
+ */
187
+ export function parseFeed(feed, options = { xmlMode: true }) {
188
+ const handler = new FeedHandler(options);
189
+ new Parser(handler, options).end(feed);
190
+ return handler.feed;
191
+ }
@@ -0,0 +1,168 @@
1
+ import { ElementType } from './ElementType.js';
2
+ /**
3
+ * This object will be used as the prototype for Nodes when creating a
4
+ * DOM-Level-1-compliant structure.
5
+ */
6
+ export declare class Node {
7
+ type: ElementType;
8
+ /** Parent of the node */
9
+ parent: NodeWithChildren | null;
10
+ /** Previous sibling */
11
+ prev: Node | null;
12
+ /** Next sibling */
13
+ next: Node | null;
14
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
15
+ startIndex: number | null;
16
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
17
+ endIndex: number | null;
18
+ /**
19
+ *
20
+ * @param type The type of the node.
21
+ */
22
+ constructor(type: ElementType);
23
+ get nodeType(): number;
24
+ get parentNode(): NodeWithChildren | null;
25
+ set parentNode(parent: NodeWithChildren | null);
26
+ get previousSibling(): Node | null;
27
+ set previousSibling(prev: Node | null);
28
+ get nextSibling(): Node | null;
29
+ set nextSibling(next: Node | null);
30
+ /**
31
+ * Clone this node, and optionally its children.
32
+ *
33
+ * @param recursive Clone child nodes as well.
34
+ * @returns A clone of the node.
35
+ */
36
+ cloneNode<T extends Node>(this: T, recursive?: boolean): T;
37
+ }
38
+ /**
39
+ * A node that contains some data.
40
+ */
41
+ export declare class DataNode extends Node {
42
+ data: string;
43
+ /**
44
+ * @param type The type of the node
45
+ * @param data The content of the data node
46
+ */
47
+ constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
48
+ get nodeValue(): string;
49
+ set nodeValue(data: string);
50
+ }
51
+ /**
52
+ * Text within the document.
53
+ */
54
+ export declare class Text extends DataNode {
55
+ constructor(data: string);
56
+ }
57
+ /**
58
+ * Comments within the document.
59
+ */
60
+ export declare class Comment extends DataNode {
61
+ constructor(data: string);
62
+ }
63
+ /**
64
+ * Processing instructions, including doc types.
65
+ */
66
+ export declare class ProcessingInstruction extends DataNode {
67
+ name: string;
68
+ constructor(name: string, data: string);
69
+ 'x-name'?: string;
70
+ 'x-publicId'?: string;
71
+ 'x-systemId'?: string;
72
+ }
73
+ /**
74
+ * A `Node` that can have children.
75
+ */
76
+ export declare class NodeWithChildren extends Node {
77
+ children: Node[];
78
+ /**
79
+ * @param type Type of the node.
80
+ * @param children Children of the node. Only certain node types can have children.
81
+ */
82
+ constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
83
+ get firstChild(): Node | null;
84
+ get lastChild(): Node | null;
85
+ get childNodes(): Node[];
86
+ set childNodes(children: Node[]);
87
+ }
88
+ /**
89
+ * The root node of the document.
90
+ */
91
+ export declare class Document extends NodeWithChildren {
92
+ constructor(children: Node[]);
93
+ 'x-mode'?: 'no-quirks' | 'quirks' | 'limited-quirks';
94
+ }
95
+ /**
96
+ * The description of an individual attribute.
97
+ */
98
+ interface Attribute {
99
+ name: string;
100
+ value: string;
101
+ namespace?: string;
102
+ prefix?: string;
103
+ }
104
+ /**
105
+ * An element within the DOM.
106
+ */
107
+ export declare class Element extends NodeWithChildren {
108
+ name: string;
109
+ attribs: {
110
+ [name: string]: string;
111
+ };
112
+ /**
113
+ * @param name Name of the tag, eg. `div`, `span`.
114
+ * @param attribs Object mapping attribute names to attribute values.
115
+ * @param children Children of the node.
116
+ */
117
+ constructor(name: string, attribs: {
118
+ [name: string]: string;
119
+ }, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
120
+ get tagName(): string;
121
+ set tagName(name: string);
122
+ get attributes(): Attribute[];
123
+ 'x-attribsNamespace'?: Record<string, string>;
124
+ 'x-attribsPrefix'?: Record<string, string>;
125
+ }
126
+ /**
127
+ * @param node Node to check.
128
+ * @returns `true` if the node is a `Element`, `false` otherwise.
129
+ */
130
+ export declare function isTag(node: Node): node is Element;
131
+ /**
132
+ * @param node Node to check.
133
+ * @returns `true` if the node has the type `CDATA`, `false` otherwise.
134
+ */
135
+ export declare function isCDATA(node: Node): node is NodeWithChildren;
136
+ /**
137
+ * @param node Node to check.
138
+ * @returns `true` if the node has the type `Text`, `false` otherwise.
139
+ */
140
+ export declare function isText(node: Node): node is Text;
141
+ /**
142
+ * @param node Node to check.
143
+ * @returns `true` if the node has the type `Comment`, `false` otherwise.
144
+ */
145
+ export declare function isComment(node: Node): node is DataNode;
146
+ /**
147
+ * @param node Node to check.
148
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
149
+ */
150
+ export declare function isDirective(node: Node): node is ProcessingInstruction;
151
+ /**
152
+ * @param node Node to check.
153
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
154
+ */
155
+ export declare function isDocument(node: Node): node is Document;
156
+ /**
157
+ * @param node Node to check.
158
+ * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
159
+ */
160
+ export declare function hasChildren(node: Node): node is NodeWithChildren;
161
+ /**
162
+ * Clone a node, and optionally its children.
163
+ *
164
+ * @param recursive Clone child nodes as well.
165
+ * @returns A clone of the node.
166
+ */
167
+ export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
168
+ export {};