feedsmith 2.1.1 → 2.2.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 (224) hide show
  1. package/LICENSE +18 -4
  2. package/README.md +32 -11
  3. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/common/config.cjs +161 -0
  5. package/dist/common/config.js +157 -0
  6. package/dist/common/parse.cjs +33 -0
  7. package/dist/common/parse.d.cts +23 -0
  8. package/dist/common/parse.d.ts +23 -0
  9. package/dist/common/parse.js +33 -0
  10. package/dist/common/types.d.cts +25 -0
  11. package/dist/common/types.d.ts +25 -0
  12. package/dist/common/utils.cjs +361 -0
  13. package/dist/common/utils.js +331 -0
  14. package/dist/feeds/atom/common/types.d.cts +104 -0
  15. package/dist/feeds/atom/common/types.d.ts +104 -0
  16. package/dist/feeds/atom/detect/index.cjs +13 -0
  17. package/dist/feeds/atom/detect/index.d.cts +4 -0
  18. package/dist/feeds/atom/detect/index.d.ts +4 -0
  19. package/dist/feeds/atom/detect/index.js +13 -0
  20. package/dist/feeds/atom/generate/config.cjs +10 -0
  21. package/dist/feeds/atom/generate/config.js +8 -0
  22. package/dist/feeds/atom/generate/index.cjs +14 -0
  23. package/dist/feeds/atom/generate/index.d.cts +7 -0
  24. package/dist/feeds/atom/generate/index.d.ts +7 -0
  25. package/dist/feeds/atom/generate/index.js +14 -0
  26. package/dist/feeds/atom/generate/utils.cjs +153 -0
  27. package/dist/feeds/atom/generate/utils.js +152 -0
  28. package/dist/feeds/atom/parse/config.cjs +74 -0
  29. package/dist/feeds/atom/parse/config.js +72 -0
  30. package/dist/feeds/atom/parse/index.cjs +16 -0
  31. package/dist/feeds/atom/parse/index.d.cts +7 -0
  32. package/dist/feeds/atom/parse/index.d.ts +7 -0
  33. package/dist/feeds/atom/parse/index.js +16 -0
  34. package/dist/feeds/atom/parse/utils.cjs +181 -0
  35. package/dist/feeds/atom/parse/utils.js +179 -0
  36. package/dist/feeds/json/common/types.d.cts +59 -0
  37. package/dist/feeds/json/common/types.d.ts +59 -0
  38. package/dist/feeds/json/detect/index.cjs +17 -0
  39. package/dist/feeds/json/detect/index.d.cts +4 -0
  40. package/dist/feeds/json/detect/index.d.ts +4 -0
  41. package/dist/feeds/json/detect/index.js +17 -0
  42. package/dist/feeds/json/generate/index.cjs +9 -0
  43. package/dist/feeds/json/generate/index.d.cts +7 -0
  44. package/dist/feeds/json/generate/index.d.ts +7 -0
  45. package/dist/feeds/json/generate/index.js +9 -0
  46. package/dist/feeds/json/generate/utils.cjs +20 -0
  47. package/dist/feeds/json/generate/utils.js +20 -0
  48. package/dist/feeds/json/parse/index.cjs +14 -0
  49. package/dist/feeds/json/parse/index.d.cts +7 -0
  50. package/dist/feeds/json/parse/index.d.ts +7 -0
  51. package/dist/feeds/json/parse/index.js +14 -0
  52. package/dist/feeds/json/parse/utils.cjs +91 -0
  53. package/dist/feeds/json/parse/utils.js +90 -0
  54. package/dist/feeds/rdf/common/types.d.cts +54 -0
  55. package/dist/feeds/rdf/common/types.d.ts +54 -0
  56. package/dist/feeds/rdf/detect/index.cjs +14 -0
  57. package/dist/feeds/rdf/detect/index.d.cts +4 -0
  58. package/dist/feeds/rdf/detect/index.d.ts +4 -0
  59. package/dist/feeds/rdf/detect/index.js +14 -0
  60. package/dist/feeds/rdf/parse/config.cjs +28 -0
  61. package/dist/feeds/rdf/parse/config.js +26 -0
  62. package/dist/feeds/rdf/parse/index.cjs +16 -0
  63. package/dist/feeds/rdf/parse/index.d.cts +7 -0
  64. package/dist/feeds/rdf/parse/index.d.ts +7 -0
  65. package/dist/feeds/rdf/parse/index.js +16 -0
  66. package/dist/feeds/rdf/parse/utils.cjs +80 -0
  67. package/dist/feeds/rdf/parse/utils.js +80 -0
  68. package/dist/feeds/rss/common/types.d.cts +129 -0
  69. package/dist/feeds/rss/common/types.d.ts +129 -0
  70. package/dist/feeds/rss/detect/index.cjs +13 -0
  71. package/dist/feeds/rss/detect/index.d.cts +4 -0
  72. package/dist/feeds/rss/detect/index.d.ts +4 -0
  73. package/dist/feeds/rss/detect/index.js +13 -0
  74. package/dist/feeds/rss/generate/config.cjs +10 -0
  75. package/dist/feeds/rss/generate/config.js +8 -0
  76. package/dist/feeds/rss/generate/index.cjs +14 -0
  77. package/dist/feeds/rss/generate/index.d.cts +7 -0
  78. package/dist/feeds/rss/generate/index.d.ts +7 -0
  79. package/dist/feeds/rss/generate/index.js +14 -0
  80. package/dist/feeds/rss/generate/utils.cjs +163 -0
  81. package/dist/feeds/rss/generate/utils.js +163 -0
  82. package/dist/feeds/rss/parse/config.cjs +53 -0
  83. package/dist/feeds/rss/parse/config.js +51 -0
  84. package/dist/feeds/rss/parse/index.cjs +16 -0
  85. package/dist/feeds/rss/parse/index.d.cts +7 -0
  86. package/dist/feeds/rss/parse/index.d.ts +7 -0
  87. package/dist/feeds/rss/parse/index.js +16 -0
  88. package/dist/feeds/rss/parse/utils.cjs +159 -0
  89. package/dist/feeds/rss/parse/utils.js +159 -0
  90. package/dist/index.cjs +29 -3619
  91. package/dist/index.d.cts +34 -1016
  92. package/dist/index.d.ts +34 -1016
  93. package/dist/index.js +14 -3579
  94. package/dist/namespaces/atom/common/types.d.cts +10 -0
  95. package/dist/namespaces/atom/common/types.d.ts +10 -0
  96. package/dist/namespaces/atom/generate/utils.cjs +19 -0
  97. package/dist/namespaces/atom/generate/utils.js +18 -0
  98. package/dist/namespaces/atom/parse/utils.cjs +19 -0
  99. package/dist/namespaces/atom/parse/utils.js +18 -0
  100. package/dist/namespaces/content/common/types.d.cts +8 -0
  101. package/dist/namespaces/content/common/types.d.ts +8 -0
  102. package/dist/namespaces/content/generate/utils.cjs +10 -0
  103. package/dist/namespaces/content/generate/utils.js +10 -0
  104. package/dist/namespaces/content/parse/utils.cjs +10 -0
  105. package/dist/namespaces/content/parse/utils.js +10 -0
  106. package/dist/namespaces/dc/common/types.d.cts +24 -0
  107. package/dist/namespaces/dc/common/types.d.ts +24 -0
  108. package/dist/namespaces/dc/generate/utils.cjs +26 -0
  109. package/dist/namespaces/dc/generate/utils.js +26 -0
  110. package/dist/namespaces/dc/parse/utils.cjs +26 -0
  111. package/dist/namespaces/dc/parse/utils.js +26 -0
  112. package/dist/namespaces/dcterms/common/types.d.cts +64 -0
  113. package/dist/namespaces/dcterms/common/types.d.ts +64 -0
  114. package/dist/namespaces/dcterms/generate/utils.cjs +66 -0
  115. package/dist/namespaces/dcterms/generate/utils.js +66 -0
  116. package/dist/namespaces/dcterms/parse/utils.cjs +66 -0
  117. package/dist/namespaces/dcterms/parse/utils.js +66 -0
  118. package/dist/namespaces/feedpress/common/types.d.cts +12 -0
  119. package/dist/namespaces/feedpress/common/types.d.ts +12 -0
  120. package/dist/namespaces/feedpress/generate/utils.cjs +16 -0
  121. package/dist/namespaces/feedpress/generate/utils.js +16 -0
  122. package/dist/namespaces/feedpress/parse/utils.cjs +16 -0
  123. package/dist/namespaces/feedpress/parse/utils.js +16 -0
  124. package/dist/namespaces/georss/common/types.d.cts +31 -0
  125. package/dist/namespaces/georss/common/types.d.ts +31 -0
  126. package/dist/namespaces/georss/generate/utils.cjs +51 -0
  127. package/dist/namespaces/georss/generate/utils.js +51 -0
  128. package/dist/namespaces/georss/parse/utils.cjs +65 -0
  129. package/dist/namespaces/georss/parse/utils.js +65 -0
  130. package/dist/namespaces/itunes/common/types.d.cts +49 -0
  131. package/dist/namespaces/itunes/common/types.d.ts +49 -0
  132. package/dist/namespaces/itunes/generate/utils.cjs +60 -0
  133. package/dist/namespaces/itunes/generate/utils.js +59 -0
  134. package/dist/namespaces/itunes/parse/utils.cjs +77 -0
  135. package/dist/namespaces/itunes/parse/utils.js +76 -0
  136. package/dist/namespaces/media/common/types.d.cts +178 -0
  137. package/dist/namespaces/media/common/types.d.ts +178 -0
  138. package/dist/namespaces/media/generate/utils.cjs +270 -0
  139. package/dist/namespaces/media/generate/utils.js +270 -0
  140. package/dist/namespaces/media/parse/utils.cjs +266 -0
  141. package/dist/namespaces/media/parse/utils.js +266 -0
  142. package/dist/namespaces/podcast/common/types.d.cts +201 -0
  143. package/dist/namespaces/podcast/common/types.d.ts +201 -0
  144. package/dist/namespaces/podcast/generate/utils.cjs +289 -0
  145. package/dist/namespaces/podcast/generate/utils.js +288 -0
  146. package/dist/namespaces/podcast/parse/utils.cjs +276 -0
  147. package/dist/namespaces/podcast/parse/utils.js +275 -0
  148. package/dist/namespaces/psc/common/types.d.cts +14 -0
  149. package/dist/namespaces/psc/common/types.d.ts +14 -0
  150. package/dist/namespaces/psc/generate/utils.cjs +22 -0
  151. package/dist/namespaces/psc/generate/utils.js +22 -0
  152. package/dist/namespaces/psc/parse/utils.cjs +22 -0
  153. package/dist/namespaces/psc/parse/utils.js +22 -0
  154. package/dist/namespaces/rawvoice/common/types.d.cts +54 -0
  155. package/dist/namespaces/rawvoice/common/types.d.ts +54 -0
  156. package/dist/namespaces/rawvoice/generate/utils.cjs +78 -0
  157. package/dist/namespaces/rawvoice/generate/utils.js +77 -0
  158. package/dist/namespaces/rawvoice/parse/utils.cjs +80 -0
  159. package/dist/namespaces/rawvoice/parse/utils.js +79 -0
  160. package/dist/namespaces/slash/common/types.d.cts +12 -0
  161. package/dist/namespaces/slash/common/types.d.ts +12 -0
  162. package/dist/namespaces/slash/generate/utils.cjs +15 -0
  163. package/dist/namespaces/slash/generate/utils.js +15 -0
  164. package/dist/namespaces/slash/parse/utils.cjs +18 -0
  165. package/dist/namespaces/slash/parse/utils.js +18 -0
  166. package/dist/namespaces/source/common/types.d.cts +37 -0
  167. package/dist/namespaces/source/common/types.d.ts +37 -0
  168. package/dist/namespaces/source/generate/utils.cjs +55 -0
  169. package/dist/namespaces/source/generate/utils.js +54 -0
  170. package/dist/namespaces/source/parse/utils.cjs +55 -0
  171. package/dist/namespaces/source/parse/utils.js +54 -0
  172. package/dist/namespaces/spotify/common/types.d.cts +12 -0
  173. package/dist/namespaces/spotify/common/types.d.ts +12 -0
  174. package/dist/namespaces/spotify/generate/utils.cjs +17 -0
  175. package/dist/namespaces/spotify/generate/utils.js +17 -0
  176. package/dist/namespaces/spotify/parse/utils.cjs +17 -0
  177. package/dist/namespaces/spotify/parse/utils.js +17 -0
  178. package/dist/namespaces/sy/common/types.d.cts +12 -0
  179. package/dist/namespaces/sy/common/types.d.ts +12 -0
  180. package/dist/namespaces/sy/generate/utils.cjs +14 -0
  181. package/dist/namespaces/sy/generate/utils.js +14 -0
  182. package/dist/namespaces/sy/parse/utils.cjs +14 -0
  183. package/dist/namespaces/sy/parse/utils.js +14 -0
  184. package/dist/namespaces/thr/common/types.d.cts +21 -0
  185. package/dist/namespaces/thr/common/types.d.ts +21 -0
  186. package/dist/namespaces/thr/generate/utils.cjs +30 -0
  187. package/dist/namespaces/thr/generate/utils.js +29 -0
  188. package/dist/namespaces/thr/parse/utils.cjs +30 -0
  189. package/dist/namespaces/thr/parse/utils.js +29 -0
  190. package/dist/namespaces/wfw/common/types.d.cts +9 -0
  191. package/dist/namespaces/wfw/common/types.d.ts +9 -0
  192. package/dist/namespaces/wfw/generate/utils.cjs +13 -0
  193. package/dist/namespaces/wfw/generate/utils.js +13 -0
  194. package/dist/namespaces/wfw/parse/utils.cjs +13 -0
  195. package/dist/namespaces/wfw/parse/utils.js +13 -0
  196. package/dist/namespaces/yt/common/types.d.cts +13 -0
  197. package/dist/namespaces/yt/common/types.d.ts +13 -0
  198. package/dist/namespaces/yt/generate/utils.cjs +21 -0
  199. package/dist/namespaces/yt/generate/utils.js +20 -0
  200. package/dist/namespaces/yt/parse/utils.cjs +21 -0
  201. package/dist/namespaces/yt/parse/utils.js +20 -0
  202. package/dist/opml/common/types.d.cts +48 -0
  203. package/dist/opml/common/types.d.ts +48 -0
  204. package/dist/opml/generate/config.cjs +10 -0
  205. package/dist/opml/generate/config.js +8 -0
  206. package/dist/opml/generate/index.cjs +14 -0
  207. package/dist/opml/generate/index.d.cts +7 -0
  208. package/dist/opml/generate/index.d.ts +7 -0
  209. package/dist/opml/generate/index.js +14 -0
  210. package/dist/opml/generate/utils.cjs +62 -0
  211. package/dist/opml/generate/utils.js +62 -0
  212. package/dist/opml/parse/config.cjs +29 -0
  213. package/dist/opml/parse/config.js +27 -0
  214. package/dist/opml/parse/index.cjs +13 -0
  215. package/dist/opml/parse/index.d.cts +7 -0
  216. package/dist/opml/parse/index.d.ts +7 -0
  217. package/dist/opml/parse/index.js +13 -0
  218. package/dist/opml/parse/utils.cjs +60 -0
  219. package/dist/opml/parse/utils.js +60 -0
  220. package/dist/types.cjs +0 -0
  221. package/dist/types.d.cts +7 -0
  222. package/dist/types.d.ts +7 -0
  223. package/dist/types.js +1 -0
  224. package/package.json +18 -16
package/LICENSE CHANGED
@@ -1,7 +1,21 @@
1
- Copyright 2025 Maciej Lamberski
1
+ MIT License
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ Copyright (c) 2025 Maciej Lamberski
4
4
 
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
6
11
 
7
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # Feedsmith
2
2
 
3
- [![tests](https://github.com/macieklamberski/feedsmith/actions/workflows/test.yml/badge.svg)](https://github.com/macieklamberski/feedsmith/actions/workflows/test.yml)
4
3
  [![codecov](https://codecov.io/gh/macieklamberski/feedsmith/branch/main/graph/badge.svg)](https://codecov.io/gh/macieklamberski/feedsmith)
5
4
  [![npm version](https://img.shields.io/npm/v/feedsmith.svg)](https://www.npmjs.com/package/feedsmith)
6
5
  [![license](https://img.shields.io/npm/l/feedsmith.svg)](https://github.com/macieklamberski/feedsmith/blob/main/LICENSE)
7
6
 
8
- Fast, all‑in‑one JavaScript parser and generator for RSS, Atom, RDF, and JSON Feed, with support for popular namespaces and OPML files.
7
+ Fast, all‑in‑one JavaScript feed parser and generator for RSS, Atom, RDF, and JSON Feed, with support for popular namespaces and OPML files.
9
8
 
10
9
  Feedsmith offers universal and format‑specific parsers that maintain the original feed structure in a clean, object-oriented format while intelligently normalizing legacy elements. Access all feed data without compromising simplicity.
11
10
 
@@ -31,6 +30,7 @@ Feedsmith offers universal and format‑specific parsers that maintain the origi
31
30
  ### Leniency
32
31
  * **Normalizes legacy elements** ✨ — Upgrades feed elements to their modern equivalents so that you never need to worry about reading feeds in older formats.
33
32
  * **CaSe INSENsiTive** 🐍 — Handles fields and attributes in any case (lowercase, uppercase, mixed).
33
+ * **Namespace URI tolerance** 🔧 — Accepts non-official namespace URIs (HTTPS variants, case variations, trailing slashes, whitespace).
34
34
  * **Forgiving** 🤝 — Gracefully handles malformed or incomplete feeds and extracts valid data. This makes it suitable for use with real-world feeds that may not strictly follow specifications.
35
35
 
36
36
  ### Performance and Type-Safety
@@ -74,13 +74,16 @@ Feedsmith aims to fully support all major feed formats and namespaces in complet
74
74
  | [Slash](http://purl.org/rss/1.0/modules/slash/) | `<slash:*>` | RSS, Atom, RDF | ✅ | ✅ |
75
75
  | [iTunes](http://www.itunes.com/dtds/podcast-1.0.dtd) | `<itunes:*>` | RSS, Atom | ✅ | ✅ |
76
76
  | [Podcast](https://podcastindex.org/namespace/1.0) | `<podcast:*>` | RSS | ✅ | ✅ |
77
+ | [RawVoice](https://blubrry.com/developer/rawvoice-rss/) | `<rawvoice:*>` | RSS | ✅ | ✅ |
77
78
  | [Podlove Simple Chapters](http://podlove.org/simple-chapters) | `<psc:*>` | RSS, Atom | ✅ | ✅ |
79
+ | [Spotify](http://www.spotify.com/ns/rss) | `<spotify:*>` | RSS | ✅ | ✅ |
78
80
  | [Media RSS](http://search.yahoo.com/mrss/) | `<media:*>` | RSS, Atom, RDF | ✅ | ✅ |
79
81
  | [GeoRSS-Simple](http://www.georss.org/georss) | `<georss:*>` | RSS, Atom, RDF | ✅ | ✅ |
80
82
  | [Atom Threading](https://www.ietf.org/rfc/rfc4685.txt) | `<thr:*>` | RSS, Atom | ✅ | ✅ |
81
83
  | [Dublin Core Terms](http://purl.org/dc/terms/) | `<dcterms:*>` | RSS, Atom, RDF | ✅ | ✅ |
82
84
  | [Well-Formed Web](http://wellformedweb.org/CommentAPI/) | `<wfw:*>` | RSS, Atom, RDF | ✅ | ✅ |
83
85
  | [Source](http://source.scripting.com/) | `<source:*>` | RSS | ✅ | ✅ |
86
+ | [FeedPress](https://feedpress.com/xmlns) | `<feedpress:*>` | RSS | ✅ | ✅ |
84
87
  | [YouTube](https://www.youtube.com/feeds/videos.xml) | `<yt:*>` | Atom | ✅ | ✅ |
85
88
 
86
89
  ### Other
@@ -182,15 +185,38 @@ console.log(rss) // Complete RSS XML
182
185
  // - generateOpml() for OPML files
183
186
  ```
184
187
 
185
- ### Handle Errors
188
+ ### Error Handling
189
+
190
+ If the feed is unrecognized or invalid, an `Error` will be thrown with a descriptive message.
186
191
 
187
192
  ```typescript
193
+ import { parseFeed, parseJsonFeed } from 'feedsmith'
194
+
188
195
  try {
189
- const { format, feed } = parseFeed(content)
190
- // Use the feed
196
+ const universalFeed = parseFeed('<not-a-feed></not-a-feed>')
191
197
  } catch (error) {
192
- console.error('Invalid feed:', error.message)
198
+ // Error: Unrecognized feed format
193
199
  }
200
+
201
+ try {
202
+ const jsonFeed = parseJsonFeed('{}')
203
+ } catch (error) {
204
+ // Error: Invalid feed format
205
+ }
206
+ ```
207
+
208
+ ### TypeScript Types
209
+
210
+ Feedsmith provides comprehensive TypeScript types for all feed formats:
211
+
212
+ ```typescript
213
+ import type { Rss, Atom, Json, Opml } from 'feedsmith/types'
214
+
215
+ // Access all types for a format
216
+ type Feed = Rss.Feed
217
+ type Item = Rss.Item
218
+ type Category = Rss.Category
219
+ type Enclosure = Rss.Enclosure
194
220
  ```
195
221
 
196
222
  ## Why Feedsmith?
@@ -213,8 +239,3 @@ While this approach can be useful for quick reading of feed data, it often resul
213
239
  * The library API is inspired by the [FeedKit library for Swift](https://github.com/nmdias/FeedKit).
214
240
  * XML parsing is provided by [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser).
215
241
  * HTML entity decoding is handled by [entities](https://github.com/fb55/entities).
216
-
217
- ## License
218
-
219
- Licensed under the [MIT](LICENSE) license.<br/>
220
- Copyright 2025 Maciej Lamberski
@@ -0,0 +1,25 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ exports.__toESM = __toESM;
@@ -0,0 +1,161 @@
1
+
2
+ //#region src/common/config.ts
3
+ const parserConfig = {
4
+ trimValues: false,
5
+ processEntities: false,
6
+ htmlEntities: false,
7
+ parseTagValue: false,
8
+ parseAttributeValue: false,
9
+ alwaysCreateTextNode: false,
10
+ ignoreAttributes: false,
11
+ ignorePiTags: true,
12
+ ignoreDeclaration: true,
13
+ attributeNamePrefix: "@",
14
+ transformTagName: (name) => name.toLowerCase(),
15
+ transformAttributeName: (name) => name.toLowerCase()
16
+ };
17
+ const builderConfig = {
18
+ processEntities: true,
19
+ ignoreAttributes: false,
20
+ suppressEmptyNode: true,
21
+ suppressBooleanAttributes: false,
22
+ attributeNamePrefix: "@",
23
+ format: true,
24
+ cdataPropName: "#cdata"
25
+ };
26
+ const locales = {
27
+ unrecognizedFeedFormat: "Unrecognized feed format",
28
+ invalidFeedFormat: "Invalid feed format",
29
+ invalidOpmlFormat: "Invalid OPML format",
30
+ invalidInputOpml: "Invalid input OPML",
31
+ invalidInputAtom: "Invalid input Atom",
32
+ invalidInputRss: "Invalid input RSS"
33
+ };
34
+ const namespaceUris = {
35
+ atom: [
36
+ "http://www.w3.org/2005/Atom",
37
+ "https://www.w3.org/2005/Atom",
38
+ "http://www.w3.org/2005/Atom/",
39
+ "https://www.w3.org/2005/Atom/"
40
+ ],
41
+ dc: [
42
+ "http://purl.org/dc/elements/1.1/",
43
+ "https://purl.org/dc/elements/1.1/",
44
+ "http://purl.org/dc/elements/1.1",
45
+ "https://purl.org/dc/elements/1.1"
46
+ ],
47
+ sy: [
48
+ "http://purl.org/rss/1.0/modules/syndication/",
49
+ "https://purl.org/rss/1.0/modules/syndication/",
50
+ "http://purl.org/rss/1.0/modules/syndication",
51
+ "https://purl.org/rss/1.0/modules/syndication"
52
+ ],
53
+ content: [
54
+ "http://purl.org/rss/1.0/modules/content/",
55
+ "https://purl.org/rss/1.0/modules/content/",
56
+ "http://purl.org/rss/1.0/modules/content",
57
+ "https://purl.org/rss/1.0/modules/content"
58
+ ],
59
+ slash: [
60
+ "http://purl.org/rss/1.0/modules/slash/",
61
+ "https://purl.org/rss/1.0/modules/slash/",
62
+ "http://purl.org/rss/1.0/modules/slash",
63
+ "https://purl.org/rss/1.0/modules/slash"
64
+ ],
65
+ itunes: ["http://www.itunes.com/dtds/podcast-1.0.dtd", "https://www.itunes.com/dtds/podcast-1.0.dtd"],
66
+ podcast: [
67
+ "https://podcastindex.org/namespace/1.0",
68
+ "http://podcastindex.org/namespace/1.0",
69
+ "https://podcastindex.org/namespace/1.0/",
70
+ "http://podcastindex.org/namespace/1.0/"
71
+ ],
72
+ psc: [
73
+ "http://podlove.org/simple-chapters",
74
+ "https://podlove.org/simple-chapters",
75
+ "http://podlove.org/simple-chapters/",
76
+ "https://podlove.org/simple-chapters/"
77
+ ],
78
+ media: [
79
+ "http://search.yahoo.com/mrss/",
80
+ "https://search.yahoo.com/mrss/",
81
+ "http://search.yahoo.com/mrss",
82
+ "https://search.yahoo.com/mrss",
83
+ "http://video.search.yahoo.com/mrss",
84
+ "http://video.search.yahoo.com/mrss/",
85
+ "https://video.search.yahoo.com/mrss",
86
+ "https://video.search.yahoo.com/mrss/",
87
+ "http://www.rssboard.org/media-rss",
88
+ "http://www.rssboard.org/media-rss/",
89
+ "https://www.rssboard.org/media-rss",
90
+ "https://www.rssboard.org/media-rss/"
91
+ ],
92
+ georss: [
93
+ "http://www.georss.org/georss",
94
+ "http://www.georss.org/georss/",
95
+ "https://www.georss.org/georss",
96
+ "https://www.georss.org/georss/"
97
+ ],
98
+ thr: [
99
+ "http://purl.org/syndication/thread/1.0",
100
+ "https://purl.org/syndication/thread/1.0",
101
+ "http://purl.org/syndication/thread/1.0/",
102
+ "https://purl.org/syndication/thread/1.0/"
103
+ ],
104
+ dcterms: [
105
+ "http://purl.org/dc/terms/",
106
+ "https://purl.org/dc/terms/",
107
+ "http://purl.org/dc/terms",
108
+ "https://purl.org/dc/terms"
109
+ ],
110
+ wfw: [
111
+ "http://wellformedweb.org/CommentAPI/",
112
+ "https://wellformedweb.org/CommentAPI/",
113
+ "http://wellformedweb.org/CommentAPI",
114
+ "https://wellformedweb.org/CommentAPI"
115
+ ],
116
+ source: [
117
+ "http://source.scripting.com/",
118
+ "https://source.scripting.com/",
119
+ "http://source.scripting.com",
120
+ "https://source.scripting.com"
121
+ ],
122
+ feedpress: [
123
+ "https://feed.press/xmlns",
124
+ "http://feed.press/xmlns",
125
+ "https://feed.press/xmlns/",
126
+ "http://feed.press/xmlns/",
127
+ "https://feedpress.com/xmlns",
128
+ "http://feedpress.com/xmlns",
129
+ "https://feedpress.com/xmlns/",
130
+ "http://feedpress.com/xmlns/"
131
+ ],
132
+ yt: [
133
+ "http://www.youtube.com/xml/schemas/2015",
134
+ "https://www.youtube.com/xml/schemas/2015",
135
+ "http://www.youtube.com/xml/schemas/2015/",
136
+ "https://www.youtube.com/xml/schemas/2015/"
137
+ ],
138
+ spotify: [
139
+ "http://www.spotify.com/ns/rss",
140
+ "https://www.spotify.com/ns/rss",
141
+ "http://www.spotify.com/ns/rss/",
142
+ "https://www.spotify.com/ns/rss/"
143
+ ],
144
+ rdf: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#", "https://www.w3.org/1999/02/22-rdf-syntax-ns#"],
145
+ rawvoice: [
146
+ "https://blubrry.com/developer/rawvoice-rss",
147
+ "http://blubrry.com/developer/rawvoice-rss",
148
+ "https://blubrry.com/developer/rawvoice-rss/",
149
+ "http://blubrry.com/developer/rawvoice-rss/",
150
+ "http://www.rawvoice.com/rawvoiceRssModule",
151
+ "https://www.rawvoice.com/rawvoiceRssModule",
152
+ "http://www.rawvoice.com/rawvoiceRssModule/",
153
+ "https://www.rawvoice.com/rawvoiceRssModule/"
154
+ ]
155
+ };
156
+
157
+ //#endregion
158
+ exports.builderConfig = builderConfig;
159
+ exports.locales = locales;
160
+ exports.namespaceUris = namespaceUris;
161
+ exports.parserConfig = parserConfig;
@@ -0,0 +1,157 @@
1
+ //#region src/common/config.ts
2
+ const parserConfig = {
3
+ trimValues: false,
4
+ processEntities: false,
5
+ htmlEntities: false,
6
+ parseTagValue: false,
7
+ parseAttributeValue: false,
8
+ alwaysCreateTextNode: false,
9
+ ignoreAttributes: false,
10
+ ignorePiTags: true,
11
+ ignoreDeclaration: true,
12
+ attributeNamePrefix: "@",
13
+ transformTagName: (name) => name.toLowerCase(),
14
+ transformAttributeName: (name) => name.toLowerCase()
15
+ };
16
+ const builderConfig = {
17
+ processEntities: true,
18
+ ignoreAttributes: false,
19
+ suppressEmptyNode: true,
20
+ suppressBooleanAttributes: false,
21
+ attributeNamePrefix: "@",
22
+ format: true,
23
+ cdataPropName: "#cdata"
24
+ };
25
+ const locales = {
26
+ unrecognizedFeedFormat: "Unrecognized feed format",
27
+ invalidFeedFormat: "Invalid feed format",
28
+ invalidOpmlFormat: "Invalid OPML format",
29
+ invalidInputOpml: "Invalid input OPML",
30
+ invalidInputAtom: "Invalid input Atom",
31
+ invalidInputRss: "Invalid input RSS"
32
+ };
33
+ const namespaceUris = {
34
+ atom: [
35
+ "http://www.w3.org/2005/Atom",
36
+ "https://www.w3.org/2005/Atom",
37
+ "http://www.w3.org/2005/Atom/",
38
+ "https://www.w3.org/2005/Atom/"
39
+ ],
40
+ dc: [
41
+ "http://purl.org/dc/elements/1.1/",
42
+ "https://purl.org/dc/elements/1.1/",
43
+ "http://purl.org/dc/elements/1.1",
44
+ "https://purl.org/dc/elements/1.1"
45
+ ],
46
+ sy: [
47
+ "http://purl.org/rss/1.0/modules/syndication/",
48
+ "https://purl.org/rss/1.0/modules/syndication/",
49
+ "http://purl.org/rss/1.0/modules/syndication",
50
+ "https://purl.org/rss/1.0/modules/syndication"
51
+ ],
52
+ content: [
53
+ "http://purl.org/rss/1.0/modules/content/",
54
+ "https://purl.org/rss/1.0/modules/content/",
55
+ "http://purl.org/rss/1.0/modules/content",
56
+ "https://purl.org/rss/1.0/modules/content"
57
+ ],
58
+ slash: [
59
+ "http://purl.org/rss/1.0/modules/slash/",
60
+ "https://purl.org/rss/1.0/modules/slash/",
61
+ "http://purl.org/rss/1.0/modules/slash",
62
+ "https://purl.org/rss/1.0/modules/slash"
63
+ ],
64
+ itunes: ["http://www.itunes.com/dtds/podcast-1.0.dtd", "https://www.itunes.com/dtds/podcast-1.0.dtd"],
65
+ podcast: [
66
+ "https://podcastindex.org/namespace/1.0",
67
+ "http://podcastindex.org/namespace/1.0",
68
+ "https://podcastindex.org/namespace/1.0/",
69
+ "http://podcastindex.org/namespace/1.0/"
70
+ ],
71
+ psc: [
72
+ "http://podlove.org/simple-chapters",
73
+ "https://podlove.org/simple-chapters",
74
+ "http://podlove.org/simple-chapters/",
75
+ "https://podlove.org/simple-chapters/"
76
+ ],
77
+ media: [
78
+ "http://search.yahoo.com/mrss/",
79
+ "https://search.yahoo.com/mrss/",
80
+ "http://search.yahoo.com/mrss",
81
+ "https://search.yahoo.com/mrss",
82
+ "http://video.search.yahoo.com/mrss",
83
+ "http://video.search.yahoo.com/mrss/",
84
+ "https://video.search.yahoo.com/mrss",
85
+ "https://video.search.yahoo.com/mrss/",
86
+ "http://www.rssboard.org/media-rss",
87
+ "http://www.rssboard.org/media-rss/",
88
+ "https://www.rssboard.org/media-rss",
89
+ "https://www.rssboard.org/media-rss/"
90
+ ],
91
+ georss: [
92
+ "http://www.georss.org/georss",
93
+ "http://www.georss.org/georss/",
94
+ "https://www.georss.org/georss",
95
+ "https://www.georss.org/georss/"
96
+ ],
97
+ thr: [
98
+ "http://purl.org/syndication/thread/1.0",
99
+ "https://purl.org/syndication/thread/1.0",
100
+ "http://purl.org/syndication/thread/1.0/",
101
+ "https://purl.org/syndication/thread/1.0/"
102
+ ],
103
+ dcterms: [
104
+ "http://purl.org/dc/terms/",
105
+ "https://purl.org/dc/terms/",
106
+ "http://purl.org/dc/terms",
107
+ "https://purl.org/dc/terms"
108
+ ],
109
+ wfw: [
110
+ "http://wellformedweb.org/CommentAPI/",
111
+ "https://wellformedweb.org/CommentAPI/",
112
+ "http://wellformedweb.org/CommentAPI",
113
+ "https://wellformedweb.org/CommentAPI"
114
+ ],
115
+ source: [
116
+ "http://source.scripting.com/",
117
+ "https://source.scripting.com/",
118
+ "http://source.scripting.com",
119
+ "https://source.scripting.com"
120
+ ],
121
+ feedpress: [
122
+ "https://feed.press/xmlns",
123
+ "http://feed.press/xmlns",
124
+ "https://feed.press/xmlns/",
125
+ "http://feed.press/xmlns/",
126
+ "https://feedpress.com/xmlns",
127
+ "http://feedpress.com/xmlns",
128
+ "https://feedpress.com/xmlns/",
129
+ "http://feedpress.com/xmlns/"
130
+ ],
131
+ yt: [
132
+ "http://www.youtube.com/xml/schemas/2015",
133
+ "https://www.youtube.com/xml/schemas/2015",
134
+ "http://www.youtube.com/xml/schemas/2015/",
135
+ "https://www.youtube.com/xml/schemas/2015/"
136
+ ],
137
+ spotify: [
138
+ "http://www.spotify.com/ns/rss",
139
+ "https://www.spotify.com/ns/rss",
140
+ "http://www.spotify.com/ns/rss/",
141
+ "https://www.spotify.com/ns/rss/"
142
+ ],
143
+ rdf: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#", "https://www.w3.org/1999/02/22-rdf-syntax-ns#"],
144
+ rawvoice: [
145
+ "https://blubrry.com/developer/rawvoice-rss",
146
+ "http://blubrry.com/developer/rawvoice-rss",
147
+ "https://blubrry.com/developer/rawvoice-rss/",
148
+ "http://blubrry.com/developer/rawvoice-rss/",
149
+ "http://www.rawvoice.com/rawvoiceRssModule",
150
+ "https://www.rawvoice.com/rawvoiceRssModule",
151
+ "http://www.rawvoice.com/rawvoiceRssModule/",
152
+ "https://www.rawvoice.com/rawvoiceRssModule/"
153
+ ]
154
+ };
155
+
156
+ //#endregion
157
+ export { builderConfig, locales, namespaceUris, parserConfig };
@@ -0,0 +1,33 @@
1
+ const require_index = require('../feeds/atom/detect/index.cjs');
2
+ const require_config = require('./config.cjs');
3
+ const require_index$1 = require('../feeds/atom/parse/index.cjs');
4
+ const require_index$2 = require('../feeds/json/detect/index.cjs');
5
+ const require_index$3 = require('../feeds/json/parse/index.cjs');
6
+ const require_index$4 = require('../feeds/rdf/detect/index.cjs');
7
+ const require_index$5 = require('../feeds/rdf/parse/index.cjs');
8
+ const require_index$6 = require('../feeds/rss/detect/index.cjs');
9
+ const require_index$7 = require('../feeds/rss/parse/index.cjs');
10
+
11
+ //#region src/common/parse.ts
12
+ const parse$4 = (value) => {
13
+ if (require_index$6.detect(value)) return {
14
+ format: "rss",
15
+ feed: require_index$7.parse(value)
16
+ };
17
+ if (require_index.detect(value)) return {
18
+ format: "atom",
19
+ feed: require_index$1.parse(value)
20
+ };
21
+ if (require_index$4.detect(value)) return {
22
+ format: "rdf",
23
+ feed: require_index$5.parse(value)
24
+ };
25
+ if (require_index$2.detect(value)) return {
26
+ format: "json",
27
+ feed: require_index$3.parse(value)
28
+ };
29
+ throw new Error(require_config.locales.unrecognizedFeedFormat);
30
+ };
31
+
32
+ //#endregion
33
+ exports.parse = parse$4;
@@ -0,0 +1,23 @@
1
+ import { DeepPartial } from "./types.cjs";
2
+ import { Atom } from "../feeds/atom/common/types.cjs";
3
+ import { Json } from "../feeds/json/common/types.cjs";
4
+ import { Rdf } from "../feeds/rdf/common/types.cjs";
5
+ import { Rss } from "../feeds/rss/common/types.cjs";
6
+
7
+ //#region src/common/parse.d.ts
8
+ type Parse = (value: unknown) => {
9
+ format: 'rss';
10
+ feed: DeepPartial<Rss.Feed<string>>;
11
+ } | {
12
+ format: 'atom';
13
+ feed: DeepPartial<Atom.Feed<string>>;
14
+ } | {
15
+ format: 'rdf';
16
+ feed: DeepPartial<Rdf.Feed<string>>;
17
+ } | {
18
+ format: 'json';
19
+ feed: DeepPartial<Json.Feed<string>>;
20
+ };
21
+ declare const parse: Parse;
22
+ //#endregion
23
+ export { parse };
@@ -0,0 +1,23 @@
1
+ import { DeepPartial } from "./types.js";
2
+ import { Atom } from "../feeds/atom/common/types.js";
3
+ import { Json } from "../feeds/json/common/types.js";
4
+ import { Rdf } from "../feeds/rdf/common/types.js";
5
+ import { Rss } from "../feeds/rss/common/types.js";
6
+
7
+ //#region src/common/parse.d.ts
8
+ type Parse = (value: unknown) => {
9
+ format: 'rss';
10
+ feed: DeepPartial<Rss.Feed<string>>;
11
+ } | {
12
+ format: 'atom';
13
+ feed: DeepPartial<Atom.Feed<string>>;
14
+ } | {
15
+ format: 'rdf';
16
+ feed: DeepPartial<Rdf.Feed<string>>;
17
+ } | {
18
+ format: 'json';
19
+ feed: DeepPartial<Json.Feed<string>>;
20
+ };
21
+ declare const parse: Parse;
22
+ //#endregion
23
+ export { parse };
@@ -0,0 +1,33 @@
1
+ import { detect } from "../feeds/atom/detect/index.js";
2
+ import { locales } from "./config.js";
3
+ import { parse } from "../feeds/atom/parse/index.js";
4
+ import { detect as detect$1 } from "../feeds/json/detect/index.js";
5
+ import { parse as parse$1 } from "../feeds/json/parse/index.js";
6
+ import { detect as detect$2 } from "../feeds/rdf/detect/index.js";
7
+ import { parse as parse$2 } from "../feeds/rdf/parse/index.js";
8
+ import { detect as detect$3 } from "../feeds/rss/detect/index.js";
9
+ import { parse as parse$3 } from "../feeds/rss/parse/index.js";
10
+
11
+ //#region src/common/parse.ts
12
+ const parse$4 = (value) => {
13
+ if (detect$3(value)) return {
14
+ format: "rss",
15
+ feed: parse$3(value)
16
+ };
17
+ if (detect(value)) return {
18
+ format: "atom",
19
+ feed: parse(value)
20
+ };
21
+ if (detect$2(value)) return {
22
+ format: "rdf",
23
+ feed: parse$2(value)
24
+ };
25
+ if (detect$1(value)) return {
26
+ format: "json",
27
+ feed: parse$1(value)
28
+ };
29
+ throw new Error(locales.unrecognizedFeedFormat);
30
+ };
31
+
32
+ //#endregion
33
+ export { parse$4 as parse };
@@ -0,0 +1,25 @@
1
+ //#region src/common/types.d.ts
2
+ type DateLike = Date | string;
3
+ type ExtraFields<F$1 extends ReadonlyArray<string>, V = unknown> = { [K in F$1[number]]?: V };
4
+ type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
5
+ type RemoveUndefined<T> = T extends undefined ? never : T;
6
+ type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
7
+ type XmlStylesheet = {
8
+ type: string;
9
+ href: string;
10
+ title?: string;
11
+ media?: string;
12
+ charset?: string;
13
+ alternate?: boolean;
14
+ };
15
+ type XmlGenerateOptions<O, F$1 extends boolean = false> = O & {
16
+ lenient?: F$1;
17
+ stylesheets?: Array<XmlStylesheet>;
18
+ };
19
+ type JsonGenerateOptions<O, F$1 extends boolean = false> = O & {
20
+ lenient?: F$1;
21
+ };
22
+ type XmlGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: XmlGenerateOptions<O, F>) => string;
23
+ type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
24
+ //#endregion
25
+ export { DateLike, DeepPartial, ExtraFields, JsonGenerateMain, XmlGenerateMain, XmlGenerateOptions };
@@ -0,0 +1,25 @@
1
+ //#region src/common/types.d.ts
2
+ type DateLike = Date | string;
3
+ type ExtraFields<F$1 extends ReadonlyArray<string>, V = unknown> = { [K in F$1[number]]?: V };
4
+ type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
5
+ type RemoveUndefined<T> = T extends undefined ? never : T;
6
+ type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
7
+ type XmlStylesheet = {
8
+ type: string;
9
+ href: string;
10
+ title?: string;
11
+ media?: string;
12
+ charset?: string;
13
+ alternate?: boolean;
14
+ };
15
+ type XmlGenerateOptions<O, F$1 extends boolean = false> = O & {
16
+ lenient?: F$1;
17
+ stylesheets?: Array<XmlStylesheet>;
18
+ };
19
+ type JsonGenerateOptions<O, F$1 extends boolean = false> = O & {
20
+ lenient?: F$1;
21
+ };
22
+ type XmlGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: XmlGenerateOptions<O, F>) => string;
23
+ type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
24
+ //#endregion
25
+ export { DateLike, DeepPartial, ExtraFields, JsonGenerateMain, XmlGenerateMain, XmlGenerateOptions };