feedsmith 2.0.0-next.7 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +9 -8
  2. package/dist/index.cjs +3619 -0
  3. package/dist/index.d.ts +1016 -19
  4. package/dist/index.js +3581 -14
  5. package/package.json +15 -11
  6. package/dist/common/config.d.ts +0 -24
  7. package/dist/common/config.js +0 -44
  8. package/dist/common/parse.d.ts +0 -19
  9. package/dist/common/parse.js +0 -24
  10. package/dist/common/types.d.ts +0 -41
  11. package/dist/common/types.js +0 -1
  12. package/dist/common/utils.d.ts +0 -37
  13. package/dist/common/utils.js +0 -477
  14. package/dist/feeds/atom/common/types.d.ts +0 -103
  15. package/dist/feeds/atom/common/types.js +0 -2
  16. package/dist/feeds/atom/detect/index.d.ts +0 -1
  17. package/dist/feeds/atom/detect/index.js +0 -13
  18. package/dist/feeds/atom/generate/config.d.ts +0 -2
  19. package/dist/feeds/atom/generate/config.js +0 -5
  20. package/dist/feeds/atom/generate/index.d.ts +0 -3
  21. package/dist/feeds/atom/generate/index.js +0 -10
  22. package/dist/feeds/atom/generate/utils.d.ts +0 -11
  23. package/dist/feeds/atom/generate/utils.js +0 -181
  24. package/dist/feeds/atom/parse/config.d.ts +0 -3
  25. package/dist/feeds/atom/parse/config.js +0 -68
  26. package/dist/feeds/atom/parse/index.d.ts +0 -3
  27. package/dist/feeds/atom/parse/index.js +0 -18
  28. package/dist/feeds/atom/parse/utils.d.ts +0 -16
  29. package/dist/feeds/atom/parse/utils.js +0 -206
  30. package/dist/feeds/json/common/types.d.ts +0 -53
  31. package/dist/feeds/json/common/types.js +0 -2
  32. package/dist/feeds/json/detect/index.d.ts +0 -1
  33. package/dist/feeds/json/detect/index.js +0 -16
  34. package/dist/feeds/json/generate/index.d.ts +0 -3
  35. package/dist/feeds/json/generate/index.js +0 -4
  36. package/dist/feeds/json/generate/utils.d.ts +0 -1971
  37. package/dist/feeds/json/generate/utils.js +0 -17
  38. package/dist/feeds/json/parse/index.d.ts +0 -3
  39. package/dist/feeds/json/parse/index.js +0 -13
  40. package/dist/feeds/json/parse/utils.d.ts +0 -9
  41. package/dist/feeds/json/parse/utils.js +0 -114
  42. package/dist/feeds/rdf/common/types.d.ts +0 -48
  43. package/dist/feeds/rdf/common/types.js +0 -2
  44. package/dist/feeds/rdf/detect/index.d.ts +0 -1
  45. package/dist/feeds/rdf/detect/index.js +0 -14
  46. package/dist/feeds/rdf/parse/config.d.ts +0 -3
  47. package/dist/feeds/rdf/parse/config.js +0 -22
  48. package/dist/feeds/rdf/parse/index.d.ts +0 -3
  49. package/dist/feeds/rdf/parse/index.js +0 -18
  50. package/dist/feeds/rdf/parse/utils.d.ts +0 -10
  51. package/dist/feeds/rdf/parse/utils.js +0 -90
  52. package/dist/feeds/rss/common/types.d.ts +0 -114
  53. package/dist/feeds/rss/common/types.js +0 -2
  54. package/dist/feeds/rss/detect/index.d.ts +0 -1
  55. package/dist/feeds/rss/detect/index.js +0 -13
  56. package/dist/feeds/rss/generate/config.d.ts +0 -2
  57. package/dist/feeds/rss/generate/config.js +0 -5
  58. package/dist/feeds/rss/generate/index.d.ts +0 -3
  59. package/dist/feeds/rss/generate/index.js +0 -10
  60. package/dist/feeds/rss/generate/utils.d.ts +0 -14
  61. package/dist/feeds/rss/generate/utils.js +0 -184
  62. package/dist/feeds/rss/parse/config.d.ts +0 -3
  63. package/dist/feeds/rss/parse/config.js +0 -49
  64. package/dist/feeds/rss/parse/index.d.ts +0 -3
  65. package/dist/feeds/rss/parse/index.js +0 -18
  66. package/dist/feeds/rss/parse/utils.d.ts +0 -15
  67. package/dist/feeds/rss/parse/utils.js +0 -166
  68. package/dist/namespaces/atom/common/types.d.ts +0 -4
  69. package/dist/namespaces/atom/common/types.js +0 -2
  70. package/dist/namespaces/atom/generate/utils.d.ts +0 -4
  71. package/dist/namespaces/atom/generate/utils.js +0 -7
  72. package/dist/namespaces/atom/parse/utils.d.ts +0 -4
  73. package/dist/namespaces/atom/parse/utils.js +0 -7
  74. package/dist/namespaces/content/common/types.d.ts +0 -3
  75. package/dist/namespaces/content/common/types.js +0 -2
  76. package/dist/namespaces/content/generate/utils.d.ts +0 -3
  77. package/dist/namespaces/content/generate/utils.js +0 -10
  78. package/dist/namespaces/content/parse/utils.d.ts +0 -3
  79. package/dist/namespaces/content/parse/utils.js +0 -10
  80. package/dist/namespaces/dc/common/types.d.ts +0 -18
  81. package/dist/namespaces/dc/common/types.js +0 -2
  82. package/dist/namespaces/dc/generate/utils.d.ts +0 -3
  83. package/dist/namespaces/dc/generate/utils.js +0 -24
  84. package/dist/namespaces/dc/parse/utils.d.ts +0 -3
  85. package/dist/namespaces/dc/parse/utils.js +0 -24
  86. package/dist/namespaces/dcterms/common/types.d.ts +0 -58
  87. package/dist/namespaces/dcterms/common/types.js +0 -2
  88. package/dist/namespaces/dcterms/generate/utils.d.ts +0 -3
  89. package/dist/namespaces/dcterms/generate/utils.js +0 -64
  90. package/dist/namespaces/dcterms/parse/utils.d.ts +0 -3
  91. package/dist/namespaces/dcterms/parse/utils.js +0 -64
  92. package/dist/namespaces/georss/common/types.d.ts +0 -26
  93. package/dist/namespaces/georss/common/types.js +0 -2
  94. package/dist/namespaces/georss/generate/utils.d.ts +0 -11
  95. package/dist/namespaces/georss/generate/utils.js +0 -60
  96. package/dist/namespaces/georss/parse/utils.d.ts +0 -11
  97. package/dist/namespaces/georss/parse/utils.js +0 -68
  98. package/dist/namespaces/itunes/common/types.d.ts +0 -44
  99. package/dist/namespaces/itunes/common/types.js +0 -2
  100. package/dist/namespaces/itunes/generate/utils.d.ts +0 -7
  101. package/dist/namespaces/itunes/generate/utils.js +0 -70
  102. package/dist/namespaces/itunes/parse/utils.d.ts +0 -9
  103. package/dist/namespaces/itunes/parse/utils.js +0 -99
  104. package/dist/namespaces/media/common/types.d.ts +0 -172
  105. package/dist/namespaces/media/common/types.js +0 -2
  106. package/dist/namespaces/media/generate/utils.d.ts +0 -33
  107. package/dist/namespaces/media/generate/utils.js +0 -350
  108. package/dist/namespaces/media/parse/utils.d.ts +0 -35
  109. package/dist/namespaces/media/parse/utils.js +0 -344
  110. package/dist/namespaces/podcast/common/types.d.ts +0 -182
  111. package/dist/namespaces/podcast/common/types.js +0 -2
  112. package/dist/namespaces/podcast/generate/utils.d.ts +0 -32
  113. package/dist/namespaces/podcast/generate/utils.js +0 -362
  114. package/dist/namespaces/podcast/parse/utils.d.ts +0 -31
  115. package/dist/namespaces/podcast/parse/utils.js +0 -330
  116. package/dist/namespaces/slash/common/types.d.ts +0 -7
  117. package/dist/namespaces/slash/common/types.js +0 -2
  118. package/dist/namespaces/slash/generate/utils.d.ts +0 -3
  119. package/dist/namespaces/slash/generate/utils.js +0 -13
  120. package/dist/namespaces/slash/parse/utils.d.ts +0 -4
  121. package/dist/namespaces/slash/parse/utils.js +0 -16
  122. package/dist/namespaces/source/common/types.d.ts +0 -32
  123. package/dist/namespaces/source/common/types.js +0 -2
  124. package/dist/namespaces/source/generate/utils.d.ts +0 -8
  125. package/dist/namespaces/source/generate/utils.js +0 -68
  126. package/dist/namespaces/source/parse/utils.d.ts +0 -8
  127. package/dist/namespaces/source/parse/utils.js +0 -69
  128. package/dist/namespaces/sy/common/types.d.ts +0 -6
  129. package/dist/namespaces/sy/common/types.js +0 -2
  130. package/dist/namespaces/sy/generate/utils.d.ts +0 -3
  131. package/dist/namespaces/sy/generate/utils.js +0 -12
  132. package/dist/namespaces/sy/parse/utils.d.ts +0 -3
  133. package/dist/namespaces/sy/parse/utils.js +0 -12
  134. package/dist/namespaces/thr/common/types.d.ts +0 -15
  135. package/dist/namespaces/thr/common/types.js +0 -2
  136. package/dist/namespaces/thr/generate/utils.d.ts +0 -5
  137. package/dist/namespaces/thr/generate/utils.js +0 -33
  138. package/dist/namespaces/thr/parse/utils.d.ts +0 -5
  139. package/dist/namespaces/thr/parse/utils.js +0 -33
  140. package/dist/namespaces/wfw/common/types.d.ts +0 -4
  141. package/dist/namespaces/wfw/common/types.js +0 -2
  142. package/dist/namespaces/wfw/generate/utils.d.ts +0 -3
  143. package/dist/namespaces/wfw/generate/utils.js +0 -11
  144. package/dist/namespaces/wfw/parse/utils.d.ts +0 -3
  145. package/dist/namespaces/wfw/parse/utils.js +0 -11
  146. package/dist/namespaces/yt/common/types.d.ts +0 -8
  147. package/dist/namespaces/yt/common/types.js +0 -2
  148. package/dist/namespaces/yt/generate/utils.d.ts +0 -4
  149. package/dist/namespaces/yt/generate/utils.js +0 -21
  150. package/dist/namespaces/yt/parse/utils.d.ts +0 -4
  151. package/dist/namespaces/yt/parse/utils.js +0 -21
  152. package/dist/opml/common/types.d.ts +0 -39
  153. package/dist/opml/common/types.js +0 -2
  154. package/dist/opml/generate/config.d.ts +0 -2
  155. package/dist/opml/generate/config.js +0 -5
  156. package/dist/opml/generate/index.d.ts +0 -3
  157. package/dist/opml/generate/index.js +0 -10
  158. package/dist/opml/generate/utils.d.ts +0 -6
  159. package/dist/opml/generate/utils.js +0 -66
  160. package/dist/opml/parse/config.d.ts +0 -3
  161. package/dist/opml/parse/config.js +0 -22
  162. package/dist/opml/parse/index.d.ts +0 -3
  163. package/dist/opml/parse/index.js +0 -10
  164. package/dist/opml/parse/utils.d.ts +0 -6
  165. package/dist/opml/parse/utils.js +0 -63
@@ -1,33 +0,0 @@
1
- import { generateNumber, generatePlainString, generateRfc3339Date, isObject, trimArray, trimObject, } from '../../../common/utils.js';
2
- export const generateInReplyTo = (inReplyTo) => {
3
- if (!isObject(inReplyTo)) {
4
- return;
5
- }
6
- const value = {
7
- '@ref': generatePlainString(inReplyTo.ref),
8
- '@href': generatePlainString(inReplyTo.href),
9
- '@type': generatePlainString(inReplyTo.type),
10
- '@source': generatePlainString(inReplyTo.source),
11
- };
12
- return trimObject(value);
13
- };
14
- export const generateLink = (link) => {
15
- if (!isObject(link)) {
16
- return;
17
- }
18
- const value = {
19
- '@thr:count': generateNumber(link.count),
20
- '@thr:updated': generateRfc3339Date(link.updated),
21
- };
22
- return trimObject(value);
23
- };
24
- export const generateItem = (item) => {
25
- if (!isObject(item)) {
26
- return;
27
- }
28
- const value = {
29
- 'thr:total': generateNumber(item.total),
30
- 'thr:in-reply-to': trimArray(item.inReplyTos, generateInReplyTo),
31
- };
32
- return trimObject(value);
33
- };
@@ -1,5 +0,0 @@
1
- import type { ParsePartialFunction } from '../../../common/types.js';
2
- import type { InReplyTo, Item, Link } from '../common/types.js';
3
- export declare const parseInReplyTo: ParsePartialFunction<InReplyTo>;
4
- export declare const retrieveLink: ParsePartialFunction<Link<string>>;
5
- export declare const retrieveItem: ParsePartialFunction<Item>;
@@ -1,33 +0,0 @@
1
- import { isObject, parseArrayOf, parseDate, parseNumber, parseSingularOf, parseString, retrieveText, trimObject, } from '../../../common/utils.js';
2
- export const parseInReplyTo = (value) => {
3
- if (!isObject(value)) {
4
- return;
5
- }
6
- const inReplyTo = {
7
- ref: parseString(value['@ref']),
8
- href: parseString(value['@href']),
9
- type: parseString(value['@type']),
10
- source: parseString(value['@source']),
11
- };
12
- return trimObject(inReplyTo);
13
- };
14
- export const retrieveLink = (value) => {
15
- if (!isObject(value)) {
16
- return;
17
- }
18
- const link = {
19
- count: parseNumber(value['@thr:count']),
20
- updated: parseDate(value['@thr:updated']),
21
- };
22
- return trimObject(link);
23
- };
24
- export const retrieveItem = (value) => {
25
- if (!isObject(value)) {
26
- return;
27
- }
28
- const item = {
29
- total: parseSingularOf(value['thr:total'], (value) => parseNumber(retrieveText(value))),
30
- inReplyTos: parseArrayOf(value['thr:in-reply-to'], parseInReplyTo),
31
- };
32
- return trimObject(item);
33
- };
@@ -1,4 +0,0 @@
1
- export type Item = {
2
- comment?: string;
3
- commentRss?: string;
4
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- // #endregion reference
@@ -1,3 +0,0 @@
1
- import type { GenerateFunction } from '../../../common/types.js';
2
- import type { Item } from '../common/types.js';
3
- export declare const generateItem: GenerateFunction<Item>;
@@ -1,11 +0,0 @@
1
- import { generateCdataString, isObject, trimObject } from '../../../common/utils.js';
2
- export const generateItem = (item) => {
3
- if (!isObject(item)) {
4
- return;
5
- }
6
- const value = {
7
- 'wfw:comment': generateCdataString(item.comment),
8
- 'wfw:commentRss': generateCdataString(item.commentRss),
9
- };
10
- return trimObject(value);
11
- };
@@ -1,3 +0,0 @@
1
- import type { ParsePartialFunction } from '../../../common/types.js';
2
- import type { Item } from '../common/types.js';
3
- export declare const retrieveItem: ParsePartialFunction<Item>;
@@ -1,11 +0,0 @@
1
- import { isObject, parseSingularOf, parseString, retrieveText, trimObject, } from '../../../common/utils.js';
2
- export const retrieveItem = (value) => {
3
- if (!isObject(value)) {
4
- return;
5
- }
6
- const item = {
7
- comment: parseSingularOf(value['wfw:comment'], (value) => parseString(retrieveText(value))),
8
- commentRss: parseSingularOf(value['wfw:commentrss'], (value) => parseString(retrieveText(value))),
9
- };
10
- return trimObject(item);
11
- };
@@ -1,8 +0,0 @@
1
- export type Item = {
2
- videoId?: string;
3
- channelId?: string;
4
- };
5
- export type Feed = {
6
- channelId?: string;
7
- playlistId?: string;
8
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- // #endregion reference
@@ -1,4 +0,0 @@
1
- import type { GenerateFunction } from '../../../common/types.js';
2
- import type { Feed, Item } from '../common/types.js';
3
- export declare const generateItem: GenerateFunction<Item>;
4
- export declare const generateFeed: GenerateFunction<Feed>;
@@ -1,21 +0,0 @@
1
- import { generateCdataString, isObject, trimObject } from '../../../common/utils.js';
2
- export const generateItem = (item) => {
3
- if (!isObject(item)) {
4
- return;
5
- }
6
- const value = {
7
- 'yt:videoId': generateCdataString(item.videoId),
8
- 'yt:channelId': generateCdataString(item.channelId),
9
- };
10
- return trimObject(value);
11
- };
12
- export const generateFeed = (feed) => {
13
- if (!isObject(feed)) {
14
- return;
15
- }
16
- const value = {
17
- 'yt:channelId': generateCdataString(feed.channelId),
18
- 'yt:playlistId': generateCdataString(feed.playlistId),
19
- };
20
- return trimObject(value);
21
- };
@@ -1,4 +0,0 @@
1
- import type { ParsePartialFunction } from '../../../common/types.js';
2
- import type { Feed, Item } from '../common/types.js';
3
- export declare const retrieveItem: ParsePartialFunction<Item>;
4
- export declare const retrieveFeed: ParsePartialFunction<Feed>;
@@ -1,21 +0,0 @@
1
- import { isObject, parseSingularOf, parseString, retrieveText, trimObject, } from '../../../common/utils.js';
2
- export const retrieveItem = (value) => {
3
- if (!isObject(value)) {
4
- return;
5
- }
6
- const item = {
7
- videoId: parseSingularOf(value['yt:videoid'], (value) => parseString(retrieveText(value))),
8
- channelId: parseSingularOf(value['yt:channelid'], (value) => parseString(retrieveText(value))),
9
- };
10
- return trimObject(item);
11
- };
12
- export const retrieveFeed = (value) => {
13
- if (!isObject(value)) {
14
- return;
15
- }
16
- const feed = {
17
- channelId: parseSingularOf(value['yt:channelid'], (value) => parseString(retrieveText(value))),
18
- playlistId: parseSingularOf(value['yt:playlistid'], (value) => parseString(retrieveText(value))),
19
- };
20
- return trimObject(feed);
21
- };
@@ -1,39 +0,0 @@
1
- import type { DateLike } from '../../common/types.js';
2
- export type Outline<TDate extends DateLike> = {
3
- text: string;
4
- type?: string;
5
- isComment?: boolean;
6
- isBreakpoint?: boolean;
7
- created?: TDate;
8
- category?: string;
9
- description?: string;
10
- xmlUrl?: string;
11
- htmlUrl?: string;
12
- language?: string;
13
- title?: string;
14
- version?: string;
15
- url?: string;
16
- outlines?: Array<Outline<TDate>>;
17
- };
18
- export type Head<TDate extends DateLike> = {
19
- title?: string;
20
- dateCreated?: TDate;
21
- dateModified?: TDate;
22
- ownerName?: string;
23
- ownerEmail?: string;
24
- ownerId?: string;
25
- docs?: string;
26
- expansionState?: Array<number>;
27
- vertScrollState?: number;
28
- windowTop?: number;
29
- windowLeft?: number;
30
- windowBottom?: number;
31
- windowRight?: number;
32
- };
33
- export type Body<TDate extends DateLike> = {
34
- outlines?: Array<Outline<TDate>>;
35
- };
36
- export type Opml<TDate extends DateLike> = {
37
- head?: Head<TDate>;
38
- body?: Body<TDate>;
39
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- // #endregion reference
@@ -1,2 +0,0 @@
1
- import { XMLBuilder } from 'fast-xml-parser';
2
- export declare const builder: XMLBuilder;
@@ -1,5 +0,0 @@
1
- import { XMLBuilder } from 'fast-xml-parser';
2
- import { builderConfig } from '../../common/config.js';
3
- export const builder = new XMLBuilder({
4
- ...builderConfig,
5
- });
@@ -1,3 +0,0 @@
1
- import type { DateLike, DeepPartial, XmlGenerateFunction } from '../../common/types.js';
2
- import type { Opml } from '../common/types.js';
3
- export declare const generate: XmlGenerateFunction<Opml<Date>, DeepPartial<Opml<DateLike>>>;
@@ -1,10 +0,0 @@
1
- import { generateXml } from '../../common/utils.js';
2
- import { builder } from './config.js';
3
- import { generateOpml } from './utils.js';
4
- export const generate = (value, options) => {
5
- const generated = generateOpml(value);
6
- if (!generated) {
7
- throw new Error('Invalid input OPML');
8
- }
9
- return generateXml(builder, generated, options);
10
- };
@@ -1,6 +0,0 @@
1
- import type { DateLike, GenerateFunction } from '../../common/types.js';
2
- import type { Body, Head, Opml, Outline } from '../common/types.js';
3
- export declare const generateOutline: GenerateFunction<Outline<DateLike>>;
4
- export declare const generateHead: GenerateFunction<Head<DateLike>>;
5
- export declare const generateBody: GenerateFunction<Body<DateLike>>;
6
- export declare const generateOpml: GenerateFunction<Opml<DateLike>>;
@@ -1,66 +0,0 @@
1
- import { generateBoolean, generateCdataString, generateCsvOf, generateNumber, generatePlainString, generateRfc822Date, isObject, trimArray, trimObject, } from '../../common/utils.js';
2
- export const generateOutline = (outline) => {
3
- if (!isObject(outline)) {
4
- return;
5
- }
6
- const value = {
7
- '@text': generatePlainString(outline.text),
8
- '@type': generatePlainString(outline.type),
9
- '@isComment': generateBoolean(outline.isComment),
10
- '@isBreakpoint': generateBoolean(outline.isBreakpoint),
11
- '@created': generateRfc822Date(outline.created),
12
- '@category': generatePlainString(outline.category),
13
- '@description': generatePlainString(outline.description),
14
- '@xmlUrl': generatePlainString(outline.xmlUrl),
15
- '@htmlUrl': generatePlainString(outline.htmlUrl),
16
- '@language': generatePlainString(outline.language),
17
- '@title': generatePlainString(outline.title),
18
- '@version': generatePlainString(outline.version),
19
- '@url': generatePlainString(outline.url),
20
- outline: trimArray(outline.outlines, generateOutline),
21
- };
22
- return trimObject(value);
23
- };
24
- export const generateHead = (head) => {
25
- if (!isObject(head)) {
26
- return;
27
- }
28
- const value = {
29
- title: generateCdataString(head.title),
30
- dateCreated: generateRfc822Date(head.dateCreated),
31
- dateModified: generateRfc822Date(head.dateModified),
32
- ownerName: generateCdataString(head.ownerName),
33
- ownerEmail: generateCdataString(head.ownerEmail),
34
- ownerId: generateCdataString(head.ownerId),
35
- docs: generateCdataString(head.docs),
36
- expansionState: generateCsvOf(head.expansionState, generateNumber),
37
- vertScrollState: generateNumber(head.vertScrollState),
38
- windowTop: generateNumber(head.windowTop),
39
- windowLeft: generateNumber(head.windowLeft),
40
- windowBottom: generateNumber(head.windowBottom),
41
- windowRight: generateNumber(head.windowRight),
42
- };
43
- return trimObject(value);
44
- };
45
- export const generateBody = (body) => {
46
- if (!isObject(body)) {
47
- return;
48
- }
49
- const value = {
50
- outline: trimArray(body.outlines, generateOutline),
51
- };
52
- return trimObject(value);
53
- };
54
- export const generateOpml = (opml) => {
55
- if (!isObject(opml)) {
56
- return;
57
- }
58
- const value = trimObject({
59
- '@version': '2.0',
60
- head: generateHead(opml.head),
61
- body: generateBody(opml.body),
62
- });
63
- if (value?.body !== undefined) {
64
- return { opml: value };
65
- }
66
- };
@@ -1,3 +0,0 @@
1
- import { XMLParser } from 'fast-xml-parser';
2
- export declare const stopNodes: string[];
3
- export declare const parser: XMLParser;
@@ -1,22 +0,0 @@
1
- import { XMLParser } from 'fast-xml-parser';
2
- import { parserConfig } from '../../common/config.js';
3
- export const stopNodes = [
4
- 'opml.head.title',
5
- 'opml.head.dateCreated',
6
- 'opml.head.dateModified',
7
- 'opml.head.ownerName',
8
- 'opml.head.ownerEmail',
9
- 'opml.head.ownerId',
10
- 'opml.head.docs',
11
- 'opml.head.expansionState',
12
- 'opml.head.vertScrollState',
13
- 'opml.head.windowTop',
14
- 'opml.head.windowLeft',
15
- 'opml.head.windowBottom',
16
- 'opml.head.windowRight',
17
- '*.outline.outline',
18
- ];
19
- export const parser = new XMLParser({
20
- ...parserConfig,
21
- stopNodes,
22
- });
@@ -1,3 +0,0 @@
1
- import type { DeepPartial } from '../../common/types.js';
2
- import type { Opml } from '../common/types.js';
3
- export declare const parse: (value: string) => DeepPartial<Opml<string>>;
@@ -1,10 +0,0 @@
1
- import { parser } from './config.js';
2
- import { parseOpml } from './utils.js';
3
- export const parse = (value) => {
4
- const object = parser.parse(value);
5
- const parsed = parseOpml(object);
6
- if (!parsed) {
7
- throw new Error('Invalid OPML format');
8
- }
9
- return parsed;
10
- };
@@ -1,6 +0,0 @@
1
- import type { ParsePartialFunction } from '../../common/types.js';
2
- import type { Body, Head, Opml, Outline } from '../common/types.js';
3
- export declare const parseOutline: ParsePartialFunction<Outline<string>>;
4
- export declare const parseHead: ParsePartialFunction<Head<string>>;
5
- export declare const parseBody: ParsePartialFunction<Body<string>>;
6
- export declare const parseOpml: ParsePartialFunction<Opml<string>>;
@@ -1,63 +0,0 @@
1
- import { isObject, parseArrayOf, parseBoolean, parseCsvOf, parseDate, parseNumber, parseSingularOf, parseString, retrieveText, trimObject, } from '../../common/utils.js';
2
- export const parseOutline = (value) => {
3
- if (!isObject(value)) {
4
- return;
5
- }
6
- const outline = {
7
- text: parseString(value['@text']),
8
- type: parseString(value['@type']),
9
- isComment: parseBoolean(value['@iscomment']),
10
- isBreakpoint: parseBoolean(value['@isbreakpoint']),
11
- created: parseDate(value['@created']),
12
- category: parseString(value['@category']),
13
- description: parseString(value['@description']),
14
- xmlUrl: parseString(value['@xmlurl']),
15
- htmlUrl: parseString(value['@htmlurl']),
16
- language: parseString(value['@language']),
17
- title: parseString(value['@title']),
18
- version: parseString(value['@version']),
19
- url: parseString(value['@url']),
20
- outlines: parseArrayOf(value.outline, parseOutline),
21
- };
22
- return trimObject(outline);
23
- };
24
- export const parseHead = (value) => {
25
- if (!isObject(value)) {
26
- return;
27
- }
28
- const head = {
29
- title: parseSingularOf(value.title, (value) => parseString(retrieveText(value))),
30
- dateCreated: parseSingularOf(value.datecreated, (value) => parseDate(retrieveText(value))),
31
- dateModified: parseSingularOf(value.datemodified, (value) => parseDate(retrieveText(value))),
32
- ownerName: parseSingularOf(value.ownername, (value) => parseString(retrieveText(value))),
33
- ownerEmail: parseSingularOf(value.owneremail, (value) => parseString(retrieveText(value))),
34
- ownerId: parseSingularOf(value.ownerid, (value) => parseString(retrieveText(value))),
35
- docs: parseSingularOf(value.docs, (value) => parseString(retrieveText(value))),
36
- expansionState: parseSingularOf(value.expansionstate, (value) => parseCsvOf(retrieveText(value), parseNumber)),
37
- vertScrollState: parseSingularOf(value.vertscrollstate, (value) => parseNumber(retrieveText(value))),
38
- windowTop: parseSingularOf(value.windowtop, (value) => parseNumber(retrieveText(value))),
39
- windowLeft: parseSingularOf(value.windowleft, (value) => parseNumber(retrieveText(value))),
40
- windowBottom: parseSingularOf(value.windowbottom, (value) => parseNumber(retrieveText(value))),
41
- windowRight: parseSingularOf(value.windowright, (value) => parseNumber(retrieveText(value))),
42
- };
43
- return trimObject(head);
44
- };
45
- export const parseBody = (value) => {
46
- if (!isObject(value)) {
47
- return;
48
- }
49
- const body = {
50
- outlines: parseArrayOf(value.outline, parseOutline),
51
- };
52
- return trimObject(body);
53
- };
54
- export const parseOpml = (value) => {
55
- if (!isObject(value?.opml)) {
56
- return;
57
- }
58
- const opml = {
59
- head: parseHead(value.opml.head),
60
- body: parseBody(value.opml.body),
61
- };
62
- return trimObject(opml);
63
- };