@prismicio/client 7.22.1 → 7.22.2

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 (541) hide show
  1. package/dist/Client.cjs +11 -6
  2. package/dist/Client.cjs.map +1 -1
  3. package/dist/Client.d.cts +14 -16
  4. package/dist/Client.d.cts.map +1 -1
  5. package/dist/Client.d.ts +14 -16
  6. package/dist/Client.d.ts.map +1 -1
  7. package/dist/Client.js +11 -6
  8. package/dist/Client.js.map +1 -1
  9. package/dist/Migration.cjs +24 -23
  10. package/dist/Migration.cjs.map +1 -1
  11. package/dist/Migration.d.cts +1 -3
  12. package/dist/Migration.d.cts.map +1 -1
  13. package/dist/Migration.d.ts +1 -3
  14. package/dist/Migration.d.ts.map +1 -1
  15. package/dist/Migration.js +24 -23
  16. package/dist/Migration.js.map +1 -1
  17. package/dist/WriteClient.cjs +21 -19
  18. package/dist/WriteClient.cjs.map +1 -1
  19. package/dist/WriteClient.d.cts +18 -22
  20. package/dist/WriteClient.d.cts.map +1 -1
  21. package/dist/WriteClient.d.ts +18 -22
  22. package/dist/WriteClient.d.ts.map +1 -1
  23. package/dist/WriteClient.js +21 -19
  24. package/dist/WriteClient.js.map +1 -1
  25. package/dist/buildQueryURL.cjs.map +1 -1
  26. package/dist/buildQueryURL.d.cts +5 -6
  27. package/dist/buildQueryURL.d.cts.map +1 -1
  28. package/dist/buildQueryURL.d.ts +5 -6
  29. package/dist/buildQueryURL.d.ts.map +1 -1
  30. package/dist/buildQueryURL.js.map +1 -1
  31. package/dist/cookie.d.cts +1 -1
  32. package/dist/cookie.d.cts.map +1 -1
  33. package/dist/cookie.d.ts +1 -1
  34. package/dist/cookie.d.ts.map +1 -1
  35. package/dist/createClient.cjs.map +1 -1
  36. package/dist/createClient.d.cts +2 -4
  37. package/dist/createClient.d.cts.map +1 -1
  38. package/dist/createClient.d.ts +2 -4
  39. package/dist/createClient.d.ts.map +1 -1
  40. package/dist/createClient.js.map +1 -1
  41. package/dist/createMigration.cjs.map +1 -1
  42. package/dist/createMigration.d.cts +2 -4
  43. package/dist/createMigration.d.cts.map +1 -1
  44. package/dist/createMigration.d.ts +2 -4
  45. package/dist/createMigration.d.ts.map +1 -1
  46. package/dist/createMigration.js.map +1 -1
  47. package/dist/createWriteClient.cjs.map +1 -1
  48. package/dist/createWriteClient.d.cts +2 -4
  49. package/dist/createWriteClient.d.cts.map +1 -1
  50. package/dist/createWriteClient.d.ts +2 -4
  51. package/dist/createWriteClient.d.ts.map +1 -1
  52. package/dist/createWriteClient.js.map +1 -1
  53. package/dist/errors.cjs.map +1 -1
  54. package/dist/errors.d.cts +9 -10
  55. package/dist/errors.d.cts.map +1 -1
  56. package/dist/errors.d.ts +9 -10
  57. package/dist/errors.d.ts.map +1 -1
  58. package/dist/errors.js.map +1 -1
  59. package/dist/filter.cjs +175 -0
  60. package/dist/filter.cjs.map +1 -1
  61. package/dist/filter.d.cts +3 -4
  62. package/dist/filter.d.cts.map +1 -1
  63. package/dist/filter.d.ts +3 -4
  64. package/dist/filter.d.ts.map +1 -1
  65. package/dist/filter.js +175 -0
  66. package/dist/filter.js.map +1 -1
  67. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  68. package/dist/getGraphQLEndpoint.d.cts +1 -2
  69. package/dist/getGraphQLEndpoint.d.cts.map +1 -1
  70. package/dist/getGraphQLEndpoint.d.ts +1 -2
  71. package/dist/getGraphQLEndpoint.d.ts.map +1 -1
  72. package/dist/getGraphQLEndpoint.js.map +1 -1
  73. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  74. package/dist/getRepositoryEndpoint.d.cts +1 -2
  75. package/dist/getRepositoryEndpoint.d.cts.map +1 -1
  76. package/dist/getRepositoryEndpoint.d.ts +1 -2
  77. package/dist/getRepositoryEndpoint.d.ts.map +1 -1
  78. package/dist/getRepositoryEndpoint.js.map +1 -1
  79. package/dist/getRepositoryName.cjs.map +1 -1
  80. package/dist/getRepositoryName.d.cts +1 -2
  81. package/dist/getRepositoryName.d.cts.map +1 -1
  82. package/dist/getRepositoryName.d.ts +1 -2
  83. package/dist/getRepositoryName.d.ts.map +1 -1
  84. package/dist/getRepositoryName.js.map +1 -1
  85. package/dist/getToolbarSrc.cjs.map +1 -1
  86. package/dist/getToolbarSrc.d.cts +1 -2
  87. package/dist/getToolbarSrc.d.cts.map +1 -1
  88. package/dist/getToolbarSrc.d.ts +1 -2
  89. package/dist/getToolbarSrc.d.ts.map +1 -1
  90. package/dist/getToolbarSrc.js.map +1 -1
  91. package/dist/helpers/asDate.cjs.map +1 -1
  92. package/dist/helpers/asDate.d.cts +1 -3
  93. package/dist/helpers/asDate.d.cts.map +1 -1
  94. package/dist/helpers/asDate.d.ts +1 -3
  95. package/dist/helpers/asDate.d.ts.map +1 -1
  96. package/dist/helpers/asDate.js.map +1 -1
  97. package/dist/helpers/asHTML.cjs +7 -5
  98. package/dist/helpers/asHTML.cjs.map +1 -1
  99. package/dist/helpers/asHTML.d.cts +12 -11
  100. package/dist/helpers/asHTML.d.cts.map +1 -1
  101. package/dist/helpers/asHTML.d.ts +12 -11
  102. package/dist/helpers/asHTML.d.ts.map +1 -1
  103. package/dist/helpers/asHTML.js +7 -5
  104. package/dist/helpers/asHTML.js.map +1 -1
  105. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  106. package/dist/helpers/asImagePixelDensitySrcSet.d.cts +3 -4
  107. package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
  108. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +3 -4
  109. package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
  110. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  111. package/dist/helpers/asImageSrc.cjs.map +1 -1
  112. package/dist/helpers/asImageSrc.d.cts +1 -3
  113. package/dist/helpers/asImageSrc.d.cts.map +1 -1
  114. package/dist/helpers/asImageSrc.d.ts +1 -3
  115. package/dist/helpers/asImageSrc.d.ts.map +1 -1
  116. package/dist/helpers/asImageSrc.js.map +1 -1
  117. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  118. package/dist/helpers/asImageWidthSrcSet.d.cts +3 -4
  119. package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
  120. package/dist/helpers/asImageWidthSrcSet.d.ts +3 -4
  121. package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
  122. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  123. package/dist/helpers/asLink.cjs.map +1 -1
  124. package/dist/helpers/asLink.d.cts +3 -5
  125. package/dist/helpers/asLink.d.cts.map +1 -1
  126. package/dist/helpers/asLink.d.ts +3 -5
  127. package/dist/helpers/asLink.d.ts.map +1 -1
  128. package/dist/helpers/asLink.js.map +1 -1
  129. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  130. package/dist/helpers/asLinkAttrs.d.cts +2 -4
  131. package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
  132. package/dist/helpers/asLinkAttrs.d.ts +2 -4
  133. package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
  134. package/dist/helpers/asLinkAttrs.js.map +1 -1
  135. package/dist/helpers/asText.cjs.map +1 -1
  136. package/dist/helpers/asText.d.cts +1 -3
  137. package/dist/helpers/asText.d.cts.map +1 -1
  138. package/dist/helpers/asText.d.ts +1 -3
  139. package/dist/helpers/asText.d.ts.map +1 -1
  140. package/dist/helpers/asText.js.map +1 -1
  141. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  142. package/dist/helpers/documentToLinkField.d.cts +1 -3
  143. package/dist/helpers/documentToLinkField.d.cts.map +1 -1
  144. package/dist/helpers/documentToLinkField.d.ts +1 -3
  145. package/dist/helpers/documentToLinkField.d.ts.map +1 -1
  146. package/dist/helpers/documentToLinkField.js.map +1 -1
  147. package/dist/helpers/isFilled.cjs +20 -0
  148. package/dist/helpers/isFilled.cjs.map +1 -1
  149. package/dist/helpers/isFilled.d.cts +22 -24
  150. package/dist/helpers/isFilled.d.cts.map +1 -1
  151. package/dist/helpers/isFilled.d.ts +22 -24
  152. package/dist/helpers/isFilled.d.ts.map +1 -1
  153. package/dist/helpers/isFilled.js +1 -1
  154. package/dist/helpers/isFilled.js.map +1 -1
  155. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  156. package/dist/helpers/mapSliceZone.d.cts +10 -8
  157. package/dist/helpers/mapSliceZone.d.cts.map +1 -1
  158. package/dist/helpers/mapSliceZone.d.ts +10 -8
  159. package/dist/helpers/mapSliceZone.d.ts.map +1 -1
  160. package/dist/helpers/mapSliceZone.js.map +1 -1
  161. package/dist/index.d.cts +3 -4
  162. package/dist/index.d.cts.map +1 -1
  163. package/dist/index.d.ts +3 -4
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  166. package/dist/isRepositoryEndpoint.d.cts +1 -2
  167. package/dist/isRepositoryEndpoint.d.cts.map +1 -1
  168. package/dist/isRepositoryEndpoint.d.ts +1 -2
  169. package/dist/isRepositoryEndpoint.d.ts.map +1 -1
  170. package/dist/isRepositoryEndpoint.js.map +1 -1
  171. package/dist/isRepositoryName.cjs.map +1 -1
  172. package/dist/isRepositoryName.d.cts +1 -2
  173. package/dist/isRepositoryName.d.cts.map +1 -1
  174. package/dist/isRepositoryName.d.ts +1 -2
  175. package/dist/isRepositoryName.d.ts.map +1 -1
  176. package/dist/isRepositoryName.js.map +1 -1
  177. package/dist/lib/devMsg.cjs.map +1 -1
  178. package/dist/lib/devMsg.js.map +1 -1
  179. package/dist/lib/escapeHTML.cjs.map +1 -1
  180. package/dist/lib/escapeHTML.js.map +1 -1
  181. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  182. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  183. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  184. package/dist/lib/getPreviewCookie.js.map +1 -1
  185. package/dist/lib/isInternalURL.cjs.map +1 -1
  186. package/dist/lib/isInternalURL.js.map +1 -1
  187. package/dist/lib/isMigrationValue.cjs.map +1 -1
  188. package/dist/lib/isMigrationValue.js.map +1 -1
  189. package/dist/lib/isValue.cjs.map +1 -1
  190. package/dist/lib/isValue.js.map +1 -1
  191. package/dist/lib/pLimit.cjs.map +1 -1
  192. package/dist/lib/pLimit.js.map +1 -1
  193. package/dist/lib/request.cjs +1 -0
  194. package/dist/lib/request.cjs.map +1 -1
  195. package/dist/lib/request.d.cts +5 -6
  196. package/dist/lib/request.d.cts.map +1 -1
  197. package/dist/lib/request.d.ts +5 -6
  198. package/dist/lib/request.d.ts.map +1 -1
  199. package/dist/lib/request.js +1 -1
  200. package/dist/lib/request.js.map +1 -1
  201. package/dist/lib/resolveMigrationDocumentData.cjs +3 -0
  202. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  203. package/dist/lib/resolveMigrationDocumentData.js +1 -1
  204. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  205. package/dist/lib/serializerHelpers.cjs +10 -6
  206. package/dist/lib/serializerHelpers.cjs.map +1 -1
  207. package/dist/lib/serializerHelpers.js +10 -6
  208. package/dist/lib/serializerHelpers.js.map +1 -1
  209. package/dist/lib/throttledWarn.cjs.map +1 -1
  210. package/dist/lib/throttledWarn.js.map +1 -1
  211. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  212. package/dist/lib/validateAssetMetadata.js.map +1 -1
  213. package/dist/package.cjs +1 -1
  214. package/dist/package.js +1 -1
  215. package/dist/richtext/asText.cjs.map +1 -1
  216. package/dist/richtext/asText.d.cts +1 -3
  217. package/dist/richtext/asText.d.cts.map +1 -1
  218. package/dist/richtext/asText.d.ts +1 -3
  219. package/dist/richtext/asText.d.ts.map +1 -1
  220. package/dist/richtext/asText.js.map +1 -1
  221. package/dist/richtext/asTree.cjs.map +1 -1
  222. package/dist/richtext/asTree.d.cts +1 -3
  223. package/dist/richtext/asTree.d.cts.map +1 -1
  224. package/dist/richtext/asTree.d.ts +1 -3
  225. package/dist/richtext/asTree.d.ts.map +1 -1
  226. package/dist/richtext/asTree.js.map +1 -1
  227. package/dist/richtext/composeSerializers.cjs.map +1 -1
  228. package/dist/richtext/composeSerializers.d.cts +1 -3
  229. package/dist/richtext/composeSerializers.d.cts.map +1 -1
  230. package/dist/richtext/composeSerializers.d.ts +1 -3
  231. package/dist/richtext/composeSerializers.d.ts.map +1 -1
  232. package/dist/richtext/composeSerializers.js.map +1 -1
  233. package/dist/richtext/serialize.cjs.map +1 -1
  234. package/dist/richtext/serialize.d.cts +1 -3
  235. package/dist/richtext/serialize.d.cts.map +1 -1
  236. package/dist/richtext/serialize.d.ts +1 -3
  237. package/dist/richtext/serialize.d.ts.map +1 -1
  238. package/dist/richtext/serialize.js.map +1 -1
  239. package/dist/richtext/types.cjs.map +1 -1
  240. package/dist/richtext/types.d.cts +5 -7
  241. package/dist/richtext/types.d.cts.map +1 -1
  242. package/dist/richtext/types.d.ts +5 -7
  243. package/dist/richtext/types.d.ts.map +1 -1
  244. package/dist/richtext/types.js.map +1 -1
  245. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  246. package/dist/richtext/wrapMapSerializer.d.cts +1 -3
  247. package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
  248. package/dist/richtext/wrapMapSerializer.d.ts +1 -3
  249. package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
  250. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  251. package/dist/types/api/asset/asset.d.cts +35 -20
  252. package/dist/types/api/asset/asset.d.cts.map +1 -1
  253. package/dist/types/api/asset/asset.d.ts +35 -20
  254. package/dist/types/api/asset/asset.d.ts.map +1 -1
  255. package/dist/types/api/asset/tag.d.cts +12 -7
  256. package/dist/types/api/asset/tag.d.cts.map +1 -1
  257. package/dist/types/api/asset/tag.d.ts +12 -7
  258. package/dist/types/api/asset/tag.d.ts.map +1 -1
  259. package/dist/types/api/integration.d.cts +2 -4
  260. package/dist/types/api/integration.d.cts.map +1 -1
  261. package/dist/types/api/integration.d.ts +2 -4
  262. package/dist/types/api/integration.d.ts.map +1 -1
  263. package/dist/types/api/migration/release.d.cts +3 -7
  264. package/dist/types/api/migration/release.d.cts.map +1 -1
  265. package/dist/types/api/migration/release.d.ts +3 -7
  266. package/dist/types/api/migration/release.d.ts.map +1 -1
  267. package/dist/types/api/query.d.cts +1 -3
  268. package/dist/types/api/query.d.cts.map +1 -1
  269. package/dist/types/api/query.d.ts +1 -3
  270. package/dist/types/api/query.d.ts.map +1 -1
  271. package/dist/types/api/ref.d.cts +1 -2
  272. package/dist/types/api/ref.d.cts.map +1 -1
  273. package/dist/types/api/ref.d.ts +1 -2
  274. package/dist/types/api/ref.d.ts.map +1 -1
  275. package/dist/types/api/release.d.cts +1 -3
  276. package/dist/types/api/release.d.cts.map +1 -1
  277. package/dist/types/api/release.d.ts +1 -3
  278. package/dist/types/api/release.d.ts.map +1 -1
  279. package/dist/types/api/repository.d.cts +4 -6
  280. package/dist/types/api/repository.d.cts.map +1 -1
  281. package/dist/types/api/repository.d.ts +4 -6
  282. package/dist/types/api/repository.d.ts.map +1 -1
  283. package/dist/types/api/tags.d.cts +1 -2
  284. package/dist/types/api/tags.d.cts.map +1 -1
  285. package/dist/types/api/tags.d.ts +1 -2
  286. package/dist/types/api/tags.d.ts.map +1 -1
  287. package/dist/types/migration/Asset.cjs.map +1 -1
  288. package/dist/types/migration/Asset.d.cts +21 -15
  289. package/dist/types/migration/Asset.d.cts.map +1 -1
  290. package/dist/types/migration/Asset.d.ts +21 -15
  291. package/dist/types/migration/Asset.d.ts.map +1 -1
  292. package/dist/types/migration/Asset.js.map +1 -1
  293. package/dist/types/migration/ContentRelationship.d.cts +1 -3
  294. package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
  295. package/dist/types/migration/ContentRelationship.d.ts +1 -3
  296. package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
  297. package/dist/types/migration/Document.cjs.map +1 -1
  298. package/dist/types/migration/Document.d.cts +8 -8
  299. package/dist/types/migration/Document.d.cts.map +1 -1
  300. package/dist/types/migration/Document.d.ts +8 -8
  301. package/dist/types/migration/Document.d.ts.map +1 -1
  302. package/dist/types/migration/Document.js.map +1 -1
  303. package/dist/types/model/boolean.d.cts +1 -3
  304. package/dist/types/model/boolean.d.cts.map +1 -1
  305. package/dist/types/model/boolean.d.ts +1 -3
  306. package/dist/types/model/boolean.d.ts.map +1 -1
  307. package/dist/types/model/color.d.cts +1 -3
  308. package/dist/types/model/color.d.cts.map +1 -1
  309. package/dist/types/model/color.d.ts +1 -3
  310. package/dist/types/model/color.d.ts.map +1 -1
  311. package/dist/types/model/contentRelationship.d.cts +6 -8
  312. package/dist/types/model/contentRelationship.d.cts.map +1 -1
  313. package/dist/types/model/contentRelationship.d.ts +6 -8
  314. package/dist/types/model/contentRelationship.d.ts.map +1 -1
  315. package/dist/types/model/customType.d.cts +3 -5
  316. package/dist/types/model/customType.d.cts.map +1 -1
  317. package/dist/types/model/customType.d.ts +3 -5
  318. package/dist/types/model/customType.d.ts.map +1 -1
  319. package/dist/types/model/date.d.cts +1 -3
  320. package/dist/types/model/date.d.cts.map +1 -1
  321. package/dist/types/model/date.d.ts +1 -3
  322. package/dist/types/model/date.d.ts.map +1 -1
  323. package/dist/types/model/embed.d.cts +1 -3
  324. package/dist/types/model/embed.d.cts.map +1 -1
  325. package/dist/types/model/embed.d.ts +1 -3
  326. package/dist/types/model/embed.d.ts.map +1 -1
  327. package/dist/types/model/geoPoint.d.cts +1 -3
  328. package/dist/types/model/geoPoint.d.cts.map +1 -1
  329. package/dist/types/model/geoPoint.d.ts +1 -3
  330. package/dist/types/model/geoPoint.d.ts.map +1 -1
  331. package/dist/types/model/group.d.cts +2 -4
  332. package/dist/types/model/group.d.cts.map +1 -1
  333. package/dist/types/model/group.d.ts +2 -4
  334. package/dist/types/model/group.d.ts.map +1 -1
  335. package/dist/types/model/image.d.cts +3 -5
  336. package/dist/types/model/image.d.cts.map +1 -1
  337. package/dist/types/model/image.d.ts +3 -5
  338. package/dist/types/model/image.d.ts.map +1 -1
  339. package/dist/types/model/integration.d.cts +1 -3
  340. package/dist/types/model/integration.d.cts.map +1 -1
  341. package/dist/types/model/integration.d.ts +1 -3
  342. package/dist/types/model/integration.d.ts.map +1 -1
  343. package/dist/types/model/keyText.d.cts +1 -3
  344. package/dist/types/model/keyText.d.cts.map +1 -1
  345. package/dist/types/model/keyText.d.ts +1 -3
  346. package/dist/types/model/keyText.d.ts.map +1 -1
  347. package/dist/types/model/link.cjs.map +1 -1
  348. package/dist/types/model/link.d.cts +2 -4
  349. package/dist/types/model/link.d.cts.map +1 -1
  350. package/dist/types/model/link.d.ts +2 -4
  351. package/dist/types/model/link.d.ts.map +1 -1
  352. package/dist/types/model/link.js.map +1 -1
  353. package/dist/types/model/linkToMedia.d.cts +1 -3
  354. package/dist/types/model/linkToMedia.d.cts.map +1 -1
  355. package/dist/types/model/linkToMedia.d.ts +1 -3
  356. package/dist/types/model/linkToMedia.d.ts.map +1 -1
  357. package/dist/types/model/number.d.cts +1 -3
  358. package/dist/types/model/number.d.cts.map +1 -1
  359. package/dist/types/model/number.d.ts +1 -3
  360. package/dist/types/model/number.d.ts.map +1 -1
  361. package/dist/types/model/range.d.cts +1 -3
  362. package/dist/types/model/range.d.cts.map +1 -1
  363. package/dist/types/model/range.d.ts +1 -3
  364. package/dist/types/model/range.d.ts.map +1 -1
  365. package/dist/types/model/richText.d.cts +3 -5
  366. package/dist/types/model/richText.d.cts.map +1 -1
  367. package/dist/types/model/richText.d.ts +3 -5
  368. package/dist/types/model/richText.d.ts.map +1 -1
  369. package/dist/types/model/select.d.cts +1 -3
  370. package/dist/types/model/select.d.cts.map +1 -1
  371. package/dist/types/model/select.d.ts +1 -3
  372. package/dist/types/model/select.d.ts.map +1 -1
  373. package/dist/types/model/separator.d.cts +1 -3
  374. package/dist/types/model/separator.d.cts.map +1 -1
  375. package/dist/types/model/separator.d.ts +1 -3
  376. package/dist/types/model/separator.d.ts.map +1 -1
  377. package/dist/types/model/sharedSlice.d.cts +1 -3
  378. package/dist/types/model/sharedSlice.d.cts.map +1 -1
  379. package/dist/types/model/sharedSlice.d.ts +1 -3
  380. package/dist/types/model/sharedSlice.d.ts.map +1 -1
  381. package/dist/types/model/sharedSliceVariation.d.cts +1 -3
  382. package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
  383. package/dist/types/model/sharedSliceVariation.d.ts +1 -3
  384. package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
  385. package/dist/types/model/slice.cjs.map +1 -1
  386. package/dist/types/model/slice.d.cts +3 -5
  387. package/dist/types/model/slice.d.cts.map +1 -1
  388. package/dist/types/model/slice.d.ts +3 -5
  389. package/dist/types/model/slice.d.ts.map +1 -1
  390. package/dist/types/model/slice.js.map +1 -1
  391. package/dist/types/model/sliceZone.cjs.map +1 -1
  392. package/dist/types/model/sliceZone.d.cts +4 -6
  393. package/dist/types/model/sliceZone.d.cts.map +1 -1
  394. package/dist/types/model/sliceZone.d.ts +4 -6
  395. package/dist/types/model/sliceZone.d.ts.map +1 -1
  396. package/dist/types/model/sliceZone.js.map +1 -1
  397. package/dist/types/model/table.d.cts +1 -3
  398. package/dist/types/model/table.d.cts.map +1 -1
  399. package/dist/types/model/table.d.ts +1 -3
  400. package/dist/types/model/table.d.ts.map +1 -1
  401. package/dist/types/model/timestamp.d.cts +1 -3
  402. package/dist/types/model/timestamp.d.cts.map +1 -1
  403. package/dist/types/model/timestamp.d.ts +1 -3
  404. package/dist/types/model/timestamp.d.ts.map +1 -1
  405. package/dist/types/model/title.d.cts +1 -3
  406. package/dist/types/model/title.d.cts.map +1 -1
  407. package/dist/types/model/title.d.ts +1 -3
  408. package/dist/types/model/title.d.ts.map +1 -1
  409. package/dist/types/model/types.cjs +4 -0
  410. package/dist/types/model/types.cjs.map +1 -1
  411. package/dist/types/model/types.d.cts +13 -11
  412. package/dist/types/model/types.d.cts.map +1 -1
  413. package/dist/types/model/types.d.ts +13 -11
  414. package/dist/types/model/types.d.ts.map +1 -1
  415. package/dist/types/model/types.js +4 -0
  416. package/dist/types/model/types.js.map +1 -1
  417. package/dist/types/model/uid.d.cts +1 -3
  418. package/dist/types/model/uid.d.cts.map +1 -1
  419. package/dist/types/model/uid.d.ts +1 -3
  420. package/dist/types/model/uid.d.ts.map +1 -1
  421. package/dist/types/value/boolean.d.cts +1 -2
  422. package/dist/types/value/boolean.d.cts.map +1 -1
  423. package/dist/types/value/boolean.d.ts +1 -2
  424. package/dist/types/value/boolean.d.ts.map +1 -1
  425. package/dist/types/value/color.d.cts +1 -3
  426. package/dist/types/value/color.d.cts.map +1 -1
  427. package/dist/types/value/color.d.ts +1 -3
  428. package/dist/types/value/color.d.ts.map +1 -1
  429. package/dist/types/value/contentRelationship.d.cts +3 -5
  430. package/dist/types/value/contentRelationship.d.cts.map +1 -1
  431. package/dist/types/value/contentRelationship.d.ts +3 -5
  432. package/dist/types/value/contentRelationship.d.ts.map +1 -1
  433. package/dist/types/value/date.d.cts +1 -3
  434. package/dist/types/value/date.d.cts.map +1 -1
  435. package/dist/types/value/date.d.ts +1 -3
  436. package/dist/types/value/date.d.ts.map +1 -1
  437. package/dist/types/value/document.d.cts +5 -7
  438. package/dist/types/value/document.d.cts.map +1 -1
  439. package/dist/types/value/document.d.ts +5 -7
  440. package/dist/types/value/document.d.ts.map +1 -1
  441. package/dist/types/value/embed.cjs.map +1 -1
  442. package/dist/types/value/embed.d.cts +43 -25
  443. package/dist/types/value/embed.d.cts.map +1 -1
  444. package/dist/types/value/embed.d.ts +43 -25
  445. package/dist/types/value/embed.d.ts.map +1 -1
  446. package/dist/types/value/embed.js.map +1 -1
  447. package/dist/types/value/geoPoint.d.cts +1 -3
  448. package/dist/types/value/geoPoint.d.cts.map +1 -1
  449. package/dist/types/value/geoPoint.d.ts +1 -3
  450. package/dist/types/value/geoPoint.d.ts.map +1 -1
  451. package/dist/types/value/group.d.cts +2 -4
  452. package/dist/types/value/group.d.cts.map +1 -1
  453. package/dist/types/value/group.d.ts +2 -4
  454. package/dist/types/value/group.d.ts.map +1 -1
  455. package/dist/types/value/image.d.cts +4 -6
  456. package/dist/types/value/image.d.cts.map +1 -1
  457. package/dist/types/value/image.d.ts +4 -6
  458. package/dist/types/value/image.d.ts.map +1 -1
  459. package/dist/types/value/integration.d.cts +2 -4
  460. package/dist/types/value/integration.d.cts.map +1 -1
  461. package/dist/types/value/integration.d.ts +2 -4
  462. package/dist/types/value/integration.d.ts.map +1 -1
  463. package/dist/types/value/keyText.d.cts +1 -3
  464. package/dist/types/value/keyText.d.cts.map +1 -1
  465. package/dist/types/value/keyText.d.ts +1 -3
  466. package/dist/types/value/keyText.d.ts.map +1 -1
  467. package/dist/types/value/link.cjs.map +1 -1
  468. package/dist/types/value/link.d.cts +6 -8
  469. package/dist/types/value/link.d.cts.map +1 -1
  470. package/dist/types/value/link.d.ts +6 -8
  471. package/dist/types/value/link.d.ts.map +1 -1
  472. package/dist/types/value/link.js.map +1 -1
  473. package/dist/types/value/linkToMedia.d.cts +2 -4
  474. package/dist/types/value/linkToMedia.d.cts.map +1 -1
  475. package/dist/types/value/linkToMedia.d.ts +2 -4
  476. package/dist/types/value/linkToMedia.d.ts.map +1 -1
  477. package/dist/types/value/number.d.cts +1 -3
  478. package/dist/types/value/number.d.cts.map +1 -1
  479. package/dist/types/value/number.d.ts +1 -3
  480. package/dist/types/value/number.d.ts.map +1 -1
  481. package/dist/types/value/richText.cjs.map +1 -1
  482. package/dist/types/value/richText.d.cts +29 -31
  483. package/dist/types/value/richText.d.cts.map +1 -1
  484. package/dist/types/value/richText.d.ts +29 -31
  485. package/dist/types/value/richText.d.ts.map +1 -1
  486. package/dist/types/value/richText.js.map +1 -1
  487. package/dist/types/value/select.d.cts +1 -3
  488. package/dist/types/value/select.d.cts.map +1 -1
  489. package/dist/types/value/select.d.ts +1 -3
  490. package/dist/types/value/select.d.ts.map +1 -1
  491. package/dist/types/value/sharedSlice.d.cts +1 -3
  492. package/dist/types/value/sharedSlice.d.cts.map +1 -1
  493. package/dist/types/value/sharedSlice.d.ts +1 -3
  494. package/dist/types/value/sharedSlice.d.ts.map +1 -1
  495. package/dist/types/value/sharedSliceVariation.d.cts +1 -3
  496. package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
  497. package/dist/types/value/sharedSliceVariation.d.ts +1 -3
  498. package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
  499. package/dist/types/value/slice.d.cts +1 -3
  500. package/dist/types/value/slice.d.cts.map +1 -1
  501. package/dist/types/value/slice.d.ts +1 -3
  502. package/dist/types/value/slice.d.ts.map +1 -1
  503. package/dist/types/value/sliceZone.d.cts +1 -3
  504. package/dist/types/value/sliceZone.d.cts.map +1 -1
  505. package/dist/types/value/sliceZone.d.ts +1 -3
  506. package/dist/types/value/sliceZone.d.ts.map +1 -1
  507. package/dist/types/value/table.d.cts +26 -16
  508. package/dist/types/value/table.d.cts.map +1 -1
  509. package/dist/types/value/table.d.ts +26 -16
  510. package/dist/types/value/table.d.ts.map +1 -1
  511. package/dist/types/value/timestamp.d.cts +1 -3
  512. package/dist/types/value/timestamp.d.cts.map +1 -1
  513. package/dist/types/value/timestamp.d.ts +1 -3
  514. package/dist/types/value/timestamp.d.ts.map +1 -1
  515. package/dist/types/value/title.d.cts +1 -3
  516. package/dist/types/value/title.d.cts.map +1 -1
  517. package/dist/types/value/title.d.ts +1 -3
  518. package/dist/types/value/title.d.ts.map +1 -1
  519. package/dist/types/value/types.d.cts +6 -8
  520. package/dist/types/value/types.d.cts.map +1 -1
  521. package/dist/types/value/types.d.ts +6 -8
  522. package/dist/types/value/types.d.ts.map +1 -1
  523. package/dist/types/webhook/apiUpdate.d.cts +1 -3
  524. package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
  525. package/dist/types/webhook/apiUpdate.d.ts +1 -3
  526. package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
  527. package/dist/types/webhook/testTrigger.d.cts +1 -3
  528. package/dist/types/webhook/testTrigger.d.cts.map +1 -1
  529. package/dist/types/webhook/testTrigger.d.ts +1 -3
  530. package/dist/types/webhook/testTrigger.d.ts.map +1 -1
  531. package/dist/types/webhook/types.cjs.map +1 -1
  532. package/dist/types/webhook/types.d.cts +3 -5
  533. package/dist/types/webhook/types.d.cts.map +1 -1
  534. package/dist/types/webhook/types.d.ts +3 -5
  535. package/dist/types/webhook/types.d.ts.map +1 -1
  536. package/dist/types/webhook/types.js.map +1 -1
  537. package/package.json +11 -11
  538. package/src/Client.ts +3 -2
  539. package/src/WriteClient.ts +14 -19
  540. package/src/lib/resolveMigrationDocumentData.ts +1 -1
  541. package/src/types/api/migration/release.ts +2 -5
@@ -1 +1 @@
1
- {"version":3,"file":"serializerHelpers.js","names":[],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { HTMLRichTextMapSerializer, HTMLStrictRichTextMapSerializer } from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\nimport type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\nimport { escapeHTML } from \"./escapeHTML\"\n\ntype Attributes = Record<string, string | boolean | null | undefined>\nconst formatAttributes = (node: RTAnyNode, attributes: Attributes): string => {\n\tconst _attributes = { ...attributes }\n\n\t// Respect `ltr` and `rtl` direction\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\t_attributes.dir = node.direction\n\t}\n\n\t// Add label to attributes\n\tif (\"data\" in node && \"label\" in node.data && node.data.label) {\n\t\t_attributes.class = _attributes.class\n\t\t\t? `${_attributes.class} ${node.data.label}`\n\t\t\t: node.data.label\n\t}\n\n\tconst result = []\n\n\tfor (const key in _attributes) {\n\t\tconst value = _attributes[key]\n\n\t\tif (value) {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tresult.push(key)\n\t\t\t} else {\n\t\t\t\tresult.push(`${key}=\"${escapeHTML(value)}\"`)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add a space at the beginning if there's any result\n\tif (result.length) {\n\t\tresult.unshift(\"\")\n\t}\n\n\treturn result.join(\" \")\n}\n\nconst getGeneralAttributes = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[keyof HTMLRichTextMapSerializer],\n): Attributes => {\n\treturn serializerOrShorthand && typeof serializerOrShorthand !== \"function\"\n\t\t? serializerOrShorthand\n\t\t: {}\n}\n\nexport const serializeStandardTag = <BlockType extends keyof RichTextMapSerializer<string>>(\n\ttag: string,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[BlockType],\n): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn (({ node, children }) => {\n\t\treturn `<${tag}${formatAttributes(node, generalAttributes)}>${children}</${tag}>`\n\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n}\n\nexport const serializePreFormatted = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"preformatted\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"preformatted\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\treturn `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML(node.text)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver: LinkResolverFunction<string | null | undefined> | undefined | null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"image\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"image\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\tsrc: node.url,\n\t\t\talt: node.alt,\n\t\t\tcopyright: node.copyright,\n\t\t}\n\n\t\tlet imageTag = `<img${formatAttributes(node, attributes)} />`\n\n\t\t// If the image has a link, we wrap it with an anchor tag\n\t\tif (node.linkTo) {\n\t\t\timageTag = serializeHyperlink(linkResolver)({\n\t\t\t\ttype: \"hyperlink\",\n\t\t\t\tnode: {\n\t\t\t\t\ttype: \"hyperlink\",\n\t\t\t\t\tdata: node.linkTo,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t},\n\t\t\t\ttext: \"\",\n\t\t\t\tchildren: imageTag,\n\t\t\t\tkey: \"\",\n\t\t\t})!\n\t\t}\n\n\t\treturn `<p class=\"block-img\">${imageTag}</p>`\n\t}\n}\n\nexport const serializeEmbed = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"embed\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"embed\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\t[\"data-oembed\"]: node.oembed.embed_url,\n\t\t\t[\"data-oembed-type\"]: node.oembed.type,\n\t\t\t[\"data-oembed-provider\"]: node.oembed.provider_name,\n\t\t}\n\n\t\treturn `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`\n\t}\n}\n\nexport const serializeHyperlink = (\n\tlinkResolver: LinkResolverFunction<string | null | undefined> | undefined | null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"hyperlink\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"hyperlink\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node, children }): string => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t}\n\n\t\tif (node.data.link_type === LinkType.Web) {\n\t\t\tattributes.href = node.data.url\n\t\t\tattributes.target = node.data.target\n\t\t\tattributes.rel = \"noopener noreferrer\"\n\t\t} else if (node.data.link_type === LinkType.Document) {\n\t\t\tattributes.href = asLink(node.data, { linkResolver })\n\t\t} else if (node.data.link_type === LinkType.Media) {\n\t\t\tattributes.href = node.data.url\n\t\t}\n\n\t\treturn `<a${formatAttributes(node, attributes)}>${children}</a>`\n\t}\n}\n\nexport const serializeSpan = (): NonNullable<HTMLStrict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iBAAiB,MAPpB;GAClB,GAAG;GACH,KAAK,KAAK;GACV,KAAK,KAAK;GACV,WAAW,KAAK;GAChB,CAEuD,CAAC;AAGzD,MAAI,KAAK,OACR,YAAW,mBAAmB,aAAa,CAAC;GAC3C,MAAM;GACN,MAAM;IACL,MAAM;IACN,MAAM,KAAK;IACX,OAAO;IACP,KAAK;IACL;GACD,MAAM;GACN,UAAU;GACV,KAAK;GACL,CAAC;AAGH,SAAO,wBAAwB,SAAS;;;AAI1C,MAAa,kBACZ,0BAC2D;CAC3D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,WAAW;AAQpB,SAAO,OAAO,iBAAiB,MAPZ;GAClB,GAAG;IACF,gBAAgB,KAAK,OAAO;IAC5B,qBAAqB,KAAK,OAAO;IACjC,yBAAyB,KAAK,OAAO;GACtC,CAE+C,CAAC,GAAG,KAAK,OAAO,KAAK;;;AAIvE,MAAa,sBACZ,cACA,0BAC+D;CAC/D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,MAAM,eAAuB;EACtC,MAAM,aAAa,EAClB,GAAG,mBACH;AAED,MAAI,KAAK,KAAK,cAAc,SAAS,KAAK;AACzC,cAAW,OAAO,KAAK,KAAK;AAC5B,cAAW,SAAS,KAAK,KAAK;AAC9B,cAAW,MAAM;aACP,KAAK,KAAK,cAAc,SAAS,SAC3C,YAAW,OAAO,OAAO,KAAK,MAAM,EAAE,cAAc,CAAC;WAC3C,KAAK,KAAK,cAAc,SAAS,MAC3C,YAAW,OAAO,KAAK,KAAK;AAG7B,SAAO,KAAK,iBAAiB,MAAM,WAAW,CAAC,GAAG,SAAS;;;AAI7D,MAAa,sBAA4E;AACxF,SAAQ,EAAE,WAAmB;AAC5B,SAAO,OAAO,WAAW,KAAK,CAAC,QAAQ,OAAO,SAAS,GAAG"}
1
+ {"version":3,"file":"serializerHelpers.js","names":[],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { HTMLRichTextMapSerializer, HTMLStrictRichTextMapSerializer } from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\nimport type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\nimport { escapeHTML } from \"./escapeHTML\"\n\ntype Attributes = Record<string, string | boolean | null | undefined>\nconst formatAttributes = (node: RTAnyNode, attributes: Attributes): string => {\n\tconst _attributes = { ...attributes }\n\n\t// Respect `ltr` and `rtl` direction\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\t_attributes.dir = node.direction\n\t}\n\n\t// Add label to attributes\n\tif (\"data\" in node && \"label\" in node.data && node.data.label) {\n\t\t_attributes.class = _attributes.class\n\t\t\t? `${_attributes.class} ${node.data.label}`\n\t\t\t: node.data.label\n\t}\n\n\tconst result = []\n\n\tfor (const key in _attributes) {\n\t\tconst value = _attributes[key]\n\n\t\tif (value) {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tresult.push(key)\n\t\t\t} else {\n\t\t\t\tresult.push(`${key}=\"${escapeHTML(value)}\"`)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add a space at the beginning if there's any result\n\tif (result.length) {\n\t\tresult.unshift(\"\")\n\t}\n\n\treturn result.join(\" \")\n}\n\nconst getGeneralAttributes = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[keyof HTMLRichTextMapSerializer],\n): Attributes => {\n\treturn serializerOrShorthand && typeof serializerOrShorthand !== \"function\"\n\t\t? serializerOrShorthand\n\t\t: {}\n}\n\nexport const serializeStandardTag = <BlockType extends keyof RichTextMapSerializer<string>>(\n\ttag: string,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[BlockType],\n): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn (({ node, children }) => {\n\t\treturn `<${tag}${formatAttributes(node, generalAttributes)}>${children}</${tag}>`\n\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n}\n\nexport const serializePreFormatted = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"preformatted\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"preformatted\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\treturn `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML(node.text)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver: LinkResolverFunction<string | null | undefined> | undefined | null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"image\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"image\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\tsrc: node.url,\n\t\t\talt: node.alt,\n\t\t\tcopyright: node.copyright,\n\t\t}\n\n\t\tlet imageTag = `<img${formatAttributes(node, attributes)} />`\n\n\t\t// If the image has a link, we wrap it with an anchor tag\n\t\tif (node.linkTo) {\n\t\t\timageTag = serializeHyperlink(linkResolver)({\n\t\t\t\ttype: \"hyperlink\",\n\t\t\t\tnode: {\n\t\t\t\t\ttype: \"hyperlink\",\n\t\t\t\t\tdata: node.linkTo,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t},\n\t\t\t\ttext: \"\",\n\t\t\t\tchildren: imageTag,\n\t\t\t\tkey: \"\",\n\t\t\t})!\n\t\t}\n\n\t\treturn `<p class=\"block-img\">${imageTag}</p>`\n\t}\n}\n\nexport const serializeEmbed = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"embed\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"embed\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\t[\"data-oembed\"]: node.oembed.embed_url,\n\t\t\t[\"data-oembed-type\"]: node.oembed.type,\n\t\t\t[\"data-oembed-provider\"]: node.oembed.provider_name,\n\t\t}\n\n\t\treturn `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`\n\t}\n}\n\nexport const serializeHyperlink = (\n\tlinkResolver: LinkResolverFunction<string | null | undefined> | undefined | null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"hyperlink\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"hyperlink\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node, children }): string => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t}\n\n\t\tif (node.data.link_type === LinkType.Web) {\n\t\t\tattributes.href = node.data.url\n\t\t\tattributes.target = node.data.target\n\t\t\tattributes.rel = \"noopener noreferrer\"\n\t\t} else if (node.data.link_type === LinkType.Document) {\n\t\t\tattributes.href = asLink(node.data, { linkResolver })\n\t\t} else if (node.data.link_type === LinkType.Media) {\n\t\t\tattributes.href = node.data.url\n\t\t}\n\n\t\treturn `<a${formatAttributes(node, attributes)}>${children}</a>`\n\t}\n}\n\nexport const serializeSpan = (): NonNullable<HTMLStrictRichTextMapSerializer[\"span\"]> => {\n\treturn ({ text }): string => {\n\t\treturn text ? escapeHTML(text).replace(/\\n/g, \"<br />\") : \"\"\n\t}\n}\n"],"mappings":";;;;AASA,MAAM,oBAAoB,MAAiB,eAAmC;CAC7E,MAAM,cAAc,EAAE,GAAG,WAAW;CAGpC,IAAI,eAAe,QAAQ,KAAK,cAAc,OAC7C,YAAY,MAAM,KAAK;CAIxB,IAAI,UAAU,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,OACvD,YAAY,QAAQ,YAAY,QAC7B,GAAG,YAAY,MAAM,GAAG,KAAK,KAAK,UAClC,KAAK,KAAK;CAGd,MAAM,SAAS,CAAC;CAEhB,KAAK,MAAM,OAA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AQ,EAAE,WAAW;EACpB,MAAM,aAAa;GAClB,GAAG;IACF,gBAAgB,KAAK,OAAO;IAC5B,qBAAqB,KAAK,OAAO;IACjC,yBAAyB,KAAK,OAAO;EACvC;EAEA,OAAO,OAAO,iBAAiB,MAAM,UAAU,EAAE,GAAG,KAAK,OAAO,KAAK;CACtE;AACD;AAEA,MAAa,sBACZ,cACA,0BAC+D;CAC/D,MAAM,oBAAoB,qBAAqB,qBAAqB;CAEpE,QAAQ,EAAE,MAAM,eAAuB;EACtC,MAAM,aAAa,EAClB,GAAG,kBACJ;EAEA,IAAI,KAAK,KAAK,cAAc,SAAS,KAAK;GACzC,WAAW,OAAO,KAAK,KAAK;GAC5B,WAAW,SAAS,KAAK,KAAK;GAC9B,WAAW,MAAM;EAClB,OAAO,IAAI,KAAK,KAAK,cAAc,SAAS,UAC3C,WAAW,OAAO,OAAO,KAAK,MAAM,EAAE,aAAa,CAAC;OAC9C,IAAI,KAAK,KAAK,cAAc,SAAS,OAC3C,WAAW,OAAO,KAAK,KAAK;EAG7B,OAAO,KAAK,iBAAiB,MAAM,UAAU,EAAE,GAAG,SAAS;CAC5D;AACD;AAEA,MAAa,sBAA4E;CACxF,QAAQ,EAAE,WAAmB;EAC5B,OAAO,OAAO,WAAW,IAAI,CAAC,CAAC,QAAQ,OAAO,QAAQ,IAAI;CAC3D;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"throttledWarn.cjs","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;AACvD,KAAI,YAAY,eAAe,KAAK,KAAK,GAAG,eAAe,uBAAuB;AACjF,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
1
+ {"version":3,"file":"throttledWarn.cjs","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;CACvD,IAAI,YAAY,eAAe,KAAK,IAAI,IAAI,eAAe,uBAAuB;EACjF,eAAe,KAAK,IAAI;EAExB;CACD;CAEA,eAAe,KAAK,IAAI;CACxB,cAAc;CAEd,QAAQ,KAAK,OAAO;AACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"throttledWarn.js","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;AACvD,KAAI,YAAY,eAAe,KAAK,KAAK,GAAG,eAAe,uBAAuB;AACjF,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
1
+ {"version":3,"file":"throttledWarn.js","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;CACvD,IAAI,YAAY,eAAe,KAAK,IAAI,IAAI,eAAe,uBAAuB;EACjF,eAAe,KAAK,IAAI;EAExB;CACD;CAEA,eAAe,KAAK,IAAI;CACxB,cAAc;CAEd,QAAQ,KAAK,OAAO;AACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateAssetMetadata.cjs","names":["PrismicError"],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/** Max length for asset notes accepted by the API. */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/** Max length for asset credits accepted by the API. */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/** Max length for asset alt text accepted by the API. */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/** Min length for asset tags accepted by the API. */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/** Max length for asset tags accepted by the API. */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n * @internal\n */\nexport const validateAssetMetadata = ({ notes, credits, alt, tags }: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some((tag) => tag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH)\n\t) {\n\t\terrors.push(`tags must be at least 3 characters long and 20 characters at most`)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(`Errors validating asset metadata: ${errors.join(\", \")}`, undefined, {\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t})\n\t}\n}\n"],"mappings":";;;AAIA,MAAM,yBAAyB;;AAG/B,MAAM,2BAA2B;;AAGjC,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;;;;;;AAQ7B,MAAa,yBAAyB,EAAE,OAAO,SAAS,KAAK,WAAoC;CAChG,MAAM,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KAAK,6BAA6B,uBAAuB,aAAa;AAG9E,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KAAK,+BAA+B,yBAAyB,aAAa;AAGlF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MAAM,QAAQ,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBAAqB,CAE1F,QAAO,KAAK,oEAAoE;AAGjF,KAAI,OAAO,OACV,OAAM,IAAIA,eAAAA,aAAa,qCAAqC,OAAO,KAAK,KAAK,IAAI,KAAA,GAAW;EAC3F;EACA;EACA;EACA;EACA,CAAC"}
1
+ {"version":3,"file":"validateAssetMetadata.cjs","names":["PrismicError"],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/** Max length for asset notes accepted by the API. */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/** Max length for asset credits accepted by the API. */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/** Max length for asset alt text accepted by the API. */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/** Min length for asset tags accepted by the API. */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/** Max length for asset tags accepted by the API. */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n * @internal\n */\nexport const validateAssetMetadata = ({ notes, credits, alt, tags }: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some((tag) => tag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH)\n\t) {\n\t\terrors.push(`tags must be at least 3 characters long and 20 characters at most`)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(`Errors validating asset metadata: ${errors.join(\", \")}`, undefined, {\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t})\n\t}\n}\n"],"mappings":";;;AAIA,MAAM,yBAAyB;;AAG/B,MAAM,2BAA2B;;AAGjC,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;;;;;;AAQ7B,MAAa,yBAAyB,EAAE,OAAO,SAAS,KAAK,WAAoC;CAChG,MAAM,SAAmB,CAAC;CAE1B,IAAI,SAAS,MAAM,SAAS,wBAC3B,OAAO,KAAK,6BAA6B,uBAAuB,YAAY;CAG7E,IAAI,WAAW,QAAQ,SAAS,0BAC/B,OAAO,KAAK,+BAA+B,yBAAyB,YAAY;CAGjF,IAAI,OAAO,IAAI,SAAS,sBACvB,OAAO,KAAK,2BAA2B,qBAAqB,YAAY;CAGzE,IACC,QACA,KAAK,UACL,KAAK,MAAM,QAAQ,IAAI,SAAS,wBAAwB,IAAI,SAAS,oBAAoB,GAEzF,OAAO,KAAK,mEAAmE;CAGhF,IAAI,OAAO,QACV,MAAM,IAAIA,eAAAA,aAAa,qCAAqC,OAAO,KAAK,IAAI,KAAK,KAAA,GAAW;EAC3F;EACA;EACA;EACA;CACD,CAAC;AAEH"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateAssetMetadata.js","names":[],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/** Max length for asset notes accepted by the API. */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/** Max length for asset credits accepted by the API. */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/** Max length for asset alt text accepted by the API. */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/** Min length for asset tags accepted by the API. */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/** Max length for asset tags accepted by the API. */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n * @internal\n */\nexport const validateAssetMetadata = ({ notes, credits, alt, tags }: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some((tag) => tag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH)\n\t) {\n\t\terrors.push(`tags must be at least 3 characters long and 20 characters at most`)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(`Errors validating asset metadata: ${errors.join(\", \")}`, undefined, {\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t})\n\t}\n}\n"],"mappings":";;;AAIA,MAAM,yBAAyB;;AAG/B,MAAM,2BAA2B;;AAGjC,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;;;;;;AAQ7B,MAAa,yBAAyB,EAAE,OAAO,SAAS,KAAK,WAAoC;CAChG,MAAM,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KAAK,6BAA6B,uBAAuB,aAAa;AAG9E,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KAAK,+BAA+B,yBAAyB,aAAa;AAGlF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MAAM,QAAQ,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBAAqB,CAE1F,QAAO,KAAK,oEAAoE;AAGjF,KAAI,OAAO,OACV,OAAM,IAAI,aAAa,qCAAqC,OAAO,KAAK,KAAK,IAAI,KAAA,GAAW;EAC3F;EACA;EACA;EACA;EACA,CAAC"}
1
+ {"version":3,"file":"validateAssetMetadata.js","names":[],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/** Max length for asset notes accepted by the API. */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/** Max length for asset credits accepted by the API. */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/** Max length for asset alt text accepted by the API. */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/** Min length for asset tags accepted by the API. */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/** Max length for asset tags accepted by the API. */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n * @internal\n */\nexport const validateAssetMetadata = ({ notes, credits, alt, tags }: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some((tag) => tag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH)\n\t) {\n\t\terrors.push(`tags must be at least 3 characters long and 20 characters at most`)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(`Errors validating asset metadata: ${errors.join(\", \")}`, undefined, {\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t})\n\t}\n}\n"],"mappings":";;;AAIA,MAAM,yBAAyB;;AAG/B,MAAM,2BAA2B;;AAGjC,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;AAG7B,MAAM,uBAAuB;;;;;;;AAQ7B,MAAa,yBAAyB,EAAE,OAAO,SAAS,KAAK,WAAoC;CAChG,MAAM,SAAmB,CAAC;CAE1B,IAAI,SAAS,MAAM,SAAS,wBAC3B,OAAO,KAAK,6BAA6B,uBAAuB,YAAY;CAG7E,IAAI,WAAW,QAAQ,SAAS,0BAC/B,OAAO,KAAK,+BAA+B,yBAAyB,YAAY;CAGjF,IAAI,OAAO,IAAI,SAAS,sBACvB,OAAO,KAAK,2BAA2B,qBAAqB,YAAY;CAGzE,IACC,QACA,KAAK,UACL,KAAK,MAAM,QAAQ,IAAI,SAAS,wBAAwB,IAAI,SAAS,oBAAoB,GAEzF,OAAO,KAAK,mEAAmE;CAGhF,IAAI,OAAO,QACV,MAAM,IAAI,aAAa,qCAAqC,OAAO,KAAK,IAAI,KAAK,KAAA,GAAW;EAC3F;EACA;EACA;EACA;CACD,CAAC;AAEH"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.22.1";
3
+ var version = "7.22.2";
4
4
  //#endregion
5
5
  Object.defineProperty(exports, "name", {
6
6
  enumerable: true,
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.22.1";
3
+ var version = "7.22.2";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"asText.cjs","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Converts a rich text field to a plain text string.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param separator - Separator used to join each element. Defaults to a space.\n * @returns Plain text equivalent of the rich text field.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (richTextField: RichTextField, separator = \" \"): string => {\n\tlet result = \"\"\n\n\tfor (let i = 0; i < richTextField.length; i++) {\n\t\tif (\"text\" in richTextField[i]) {\n\t\t\tresult += (result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,UAAU,eAA8B,YAAY,QAAgB;CAChF,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YAAW,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIzE,QAAO"}
1
+ {"version":3,"file":"asText.cjs","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Converts a rich text field to a plain text string.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param separator - Separator used to join each element. Defaults to a space.\n * @returns Plain text equivalent of the rich text field.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (richTextField: RichTextField, separator = \" \"): string => {\n\tlet result = \"\"\n\n\tfor (let i = 0; i < richTextField.length; i++) {\n\t\tif (\"text\" in richTextField[i]) {\n\t\t\tresult += (result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,UAAU,eAA8B,YAAY,QAAgB;CAChF,IAAI,SAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACzC,IAAI,UAAU,cAAc,IAC3B,WAAW,SAAS,YAAY,MAAO,cAAc,EAAE,CAAgB;CAIzE,OAAO;AACR"}
@@ -1,5 +1,4 @@
1
1
  import { RichTextField } from "../types/value/richText.cjs";
2
-
3
2
  //#region src/richtext/asText.d.ts
4
3
  /**
5
4
  * Converts a rich text field to a plain text string.
@@ -9,7 +8,6 @@ import { RichTextField } from "../types/value/richText.cjs";
9
8
  * @returns Plain text equivalent of the rich text field.
10
9
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
11
10
  */
12
- declare const asText: (richTextField: RichTextField, separator?: string) => string;
11
+ export declare const asText: (richTextField: RichTextField, separator?: string) => string;
13
12
  //#endregion
14
- export { asText };
15
13
  //# sourceMappingURL=asText.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAUA;;;;;;cAAa,MAAA,GAAU,aAAA,EAAe,aAAA,EAAe,SAAA"}
1
+ {"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;;;;;;qBAUa,SAAM,eAAmB,eAAa"}
@@ -1,5 +1,4 @@
1
1
  import { RichTextField } from "../types/value/richText.js";
2
-
3
2
  //#region src/richtext/asText.d.ts
4
3
  /**
5
4
  * Converts a rich text field to a plain text string.
@@ -9,7 +8,6 @@ import { RichTextField } from "../types/value/richText.js";
9
8
  * @returns Plain text equivalent of the rich text field.
10
9
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
11
10
  */
12
- declare const asText: (richTextField: RichTextField, separator?: string) => string;
11
+ export declare const asText: (richTextField: RichTextField, separator?: string) => string;
13
12
  //#endregion
14
- export { asText };
15
13
  //# sourceMappingURL=asText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAUA;;;;;;cAAa,MAAA,GAAU,aAAA,EAAe,aAAA,EAAe,SAAA"}
1
+ {"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;;;;;;qBAUa,SAAM,eAAmB,eAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"asText.js","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Converts a rich text field to a plain text string.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param separator - Separator used to join each element. Defaults to a space.\n * @returns Plain text equivalent of the rich text field.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (richTextField: RichTextField, separator = \" \"): string => {\n\tlet result = \"\"\n\n\tfor (let i = 0; i < richTextField.length; i++) {\n\t\tif (\"text\" in richTextField[i]) {\n\t\t\tresult += (result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,UAAU,eAA8B,YAAY,QAAgB;CAChF,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YAAW,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIzE,QAAO"}
1
+ {"version":3,"file":"asText.js","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Converts a rich text field to a plain text string.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param separator - Separator used to join each element. Defaults to a space.\n * @returns Plain text equivalent of the rich text field.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (richTextField: RichTextField, separator = \" \"): string => {\n\tlet result = \"\"\n\n\tfor (let i = 0; i < richTextField.length; i++) {\n\t\tif (\"text\" in richTextField[i]) {\n\t\t\tresult += (result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,UAAU,eAA8B,YAAY,QAAgB;CAChF,IAAI,SAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACzC,IAAI,UAAU,cAAc,IAC3B,WAAW,SAAS,YAAY,MAAO,cAAc,EAAE,CAAgB;CAIzE,OAAO;AACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.cjs","names":["RichTextNodeType"],"sources":["../../src/richtext/asTree.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTListItemNode,\n\tRTNode,\n\tRTOListItemNode,\n\tRTTextNode,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { Tree, TreeNode } from \"./types\"\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString()\n}\nuuid.i = 0\n\n/**\n * Parses a rich text or title field into a tree\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages. Most users\n * aren't expected to this function directly.\n * @param nodes - A rich text or title field from Prismic\n * @returns Tree from given rich text or title field\n */\nexport const asTree = (nodes: RTNode[]): Tree => {\n\tconst preparedNodes = prepareNodes(nodes)\n\n\tconst children: TreeNode[] = []\n\tfor (let i = 0; i < preparedNodes.length; i++) {\n\t\tchildren.push(nodeToTreeNode(preparedNodes[i]))\n\t}\n\n\treturn {\n\t\tkey: uuid(),\n\t\tchildren,\n\t}\n}\n\nconst createTreeNode = (node: RTAnyNode, children: TreeNode[] = []): TreeNode => {\n\treturn {\n\t\tkey: uuid(),\n\t\ttype: node.type,\n\t\ttext: \"text\" in node ? node.text : undefined,\n\t\tnode,\n\t\tchildren,\n\t}\n}\n\nconst createTextTreeNode = (text: string): TreeNode => {\n\treturn createTreeNode({\n\t\ttype: RichTextNodeType.span,\n\t\ttext,\n\t\tspans: [],\n\t})\n}\n\nconst prepareNodes = (nodes: RTNode[]): RTBlockNode[] => {\n\tconst mutNodes: RTBlockNode[] = nodes.slice(0)\n\n\tfor (let i = 0; i < mutNodes.length; i++) {\n\t\tconst node = mutNodes[i]\n\n\t\tif (node.type === RichTextNodeType.listItem || node.type === RichTextNodeType.oListItem) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [node as RTListItemNode | RTOListItemNode]\n\n\t\t\twhile (mutNodes[i + 1] && mutNodes[i + 1].type === node.type) {\n\t\t\t\titems.push(mutNodes[i + 1] as RTListItemNode | RTOListItemNode)\n\t\t\t\tmutNodes.splice(i, 1)\n\t\t\t}\n\n\t\t\tif (node.type === RichTextNodeType.listItem) {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.list,\n\t\t\t\t\titems: items as RTListItemNode[],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.oList,\n\t\t\t\t\titems: items as RTOListItemNode[],\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mutNodes\n}\n\nconst nodeToTreeNode = (node: RTBlockNode): TreeNode => {\n\tif (\"text\" in node) {\n\t\treturn createTreeNode(node, textNodeSpansToTreeNodeChildren(node.spans, node))\n\t}\n\n\tif (\"items\" in node) {\n\t\tconst children: TreeNode[] = []\n\t\tfor (let i = 0; i < node.items.length; i++) {\n\t\t\tchildren.push(nodeToTreeNode(node.items[i]))\n\t\t}\n\n\t\treturn createTreeNode(node, children)\n\t}\n\n\treturn createTreeNode(node)\n}\n\nconst textNodeSpansToTreeNodeChildren = (\n\tspans: RTInlineNode[],\n\tnode: RTTextNode,\n\tparentSpan?: RTInlineNode,\n): TreeNode[] => {\n\tif (!spans.length) {\n\t\treturn [createTextTreeNode(node.text)]\n\t}\n\n\tconst mutSpans: RTInlineNode[] = spans.slice(0)\n\n\t// Sort spans using the following criteria:\n\t//\n\t// 1. By start index (ascending)\n\t// 2. If start indices are equal, by end index (descending)\n\t//\n\t// If start and end indices of more than one span are equal, use what\n\t// the API gives without modifications.\n\t//\n\t// Sorting using this algorithm ensures proper detection of child\n\t// spans.\n\tmutSpans.sort((a, b) => a.start - b.start || b.end - a.end)\n\n\tconst children: TreeNode[] = []\n\n\tfor (let i = 0; i < mutSpans.length; i++) {\n\t\tconst span = mutSpans[i]\n\t\tconst parentSpanStart = (parentSpan && parentSpan.start) || 0\n\t\tconst spanStart = span.start - parentSpanStart\n\t\tconst spanEnd = span.end - parentSpanStart\n\t\tconst text = node.text.slice(spanStart, spanEnd)\n\n\t\tconst childSpans: RTInlineNode[] = []\n\t\tfor (let j = i; j < mutSpans.length; j++) {\n\t\t\tconst siblingSpan = mutSpans[j]\n\n\t\t\tif (siblingSpan !== span) {\n\t\t\t\tif (siblingSpan.start >= span.start && siblingSpan.end <= span.end) {\n\t\t\t\t\tchildSpans.push(siblingSpan)\n\t\t\t\t\tmutSpans.splice(j, 1)\n\t\t\t\t\tj--\n\t\t\t\t} else if (siblingSpan.start < span.end && siblingSpan.end > span.start) {\n\t\t\t\t\tchildSpans.push({\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tend: span.end,\n\t\t\t\t\t})\n\t\t\t\t\tmutSpans[j] = {\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tstart: span.end,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (i === 0 && spanStart > 0) {\n\t\t\tchildren.push(createTextTreeNode(node.text.slice(0, spanStart)))\n\t\t}\n\n\t\tconst spanWithText = { ...span, text }\n\t\tchildren.push(\n\t\t\tcreateTreeNode(\n\t\t\t\tspanWithText,\n\t\t\t\ttextNodeSpansToTreeNodeChildren(\n\t\t\t\t\tchildSpans,\n\t\t\t\t\t{\n\t\t\t\t\t\t...node,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t},\n\t\t\t\t\tspan,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\n\t\tif (spanEnd < node.text.length) {\n\t\t\tchildren.push(\n\t\t\t\tcreateTextTreeNode(\n\t\t\t\t\tnode.text.slice(\n\t\t\t\t\t\tspanEnd,\n\t\t\t\t\t\tmutSpans[i + 1] ? mutSpans[i + 1].start - parentSpanStart : undefined,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn children\n}\n"],"mappings":";;AAYA,MAAM,aAAqB;AAC1B,SAAQ,EAAE,KAAK,GAAG,UAAU;;AAE7B,KAAK,IAAI;;;;;;;;;;AAWT,MAAa,UAAU,UAA0B;CAChD,MAAM,gBAAgB,aAAa,MAAM;CAEzC,MAAM,WAAuB,EAAE;AAC/B,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,UAAS,KAAK,eAAe,cAAc,GAAG,CAAC;AAGhD,QAAO;EACN,KAAK,MAAM;EACX;EACA;;AAGF,MAAM,kBAAkB,MAAiB,WAAuB,EAAE,KAAe;AAChF,QAAO;EACN,KAAK,MAAM;EACX,MAAM,KAAK;EACX,MAAM,U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AE,SAAS,EAAE,MAAM,EAAE,IAAI;CAE3D,MAAM,WAAuB,EAAE;AAE/B,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACzC,MAAM,OAAO,SAAS;EACtB,MAAM,kBAAmB,cAAc,WAAW,SAAU;EAC5D,MAAM,YAAY,KAAK,QAAQ;EAC/B,MAAM,UAAU,KAAK,MAAM;EAC3B,MAAM,OAAO,KAAK,KAAK,MAAM,WAAW,QAAQ;EAEhD,MAAM,aAA6B,EAAE;AACrC,OAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;GACzC,MAAM,cAAc,SAAS;AAE7B,OAAI,gBAAgB;QACf,YAAY,SAAS,KAAK,SAAS,YAAY,OAAO,KAAK,KAAK;AACnE,gBAAW,KAAK,YAAY;AAC5B,cAAS,OAAO,GAAG,EAAE;AACrB;eACU,YAAY,QAAQ,KAAK,OAAO,YAAY,MAAM,KAAK,OAAO;AACxE,gBAAW,KAAK;MACf,GAAG;MACH,KAAK,KAAK;MACV,CAAC;AACF,cAAS,KAAK;MACb,GAAG;MACH,OAAO,KAAK;MACZ;;;;AAKJ,MAAI,MAAM,KAAK,YAAY,EAC1B,UAAS,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,UAAU,CAAC,CAAC;EAGjE,MAAM,eAAe;GAAE,GAAG;GAAM;GAAM;AACtC,WAAS,KACR,eACC,cACA,gCACC,YACA;GACC,GAAG;GACH;GACA,EACD,KACA,CACD,CACD;AAED,MAAI,UAAU,KAAK,KAAK,OACvB,UAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,KAAK,SAAS,IAAI,GAAG,QAAQ,kBAAkB,KAAA,EAC5D,CACD,CACD;;AAIH,QAAO"}
1
+ {"version":3,"file":"asTree.cjs","names":["RichTextNodeType"],"sources":["../../src/richtext/asTree.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTListItemNode,\n\tRTNode,\n\tRTOListItemNode,\n\tRTTextNode,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { Tree, TreeNode } from \"./types\"\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString()\n}\nuuid.i = 0\n\n/**\n * Parses a rich text or title field into a tree\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages. Most users\n * aren't expected to this function directly.\n * @param nodes - A rich text or title field from Prismic\n * @returns Tree from given rich text or title field\n */\nexport const asTree = (nodes: RTNode[]): Tree => {\n\tconst preparedNodes = prepareNodes(nodes)\n\n\tconst children: TreeNode[] = []\n\tfor (let i = 0; i < preparedNodes.length; i++) {\n\t\tchildren.push(nodeToTreeNode(preparedNodes[i]))\n\t}\n\n\treturn {\n\t\tkey: uuid(),\n\t\tchildren,\n\t}\n}\n\nconst createTreeNode = (node: RTAnyNode, children: TreeNode[] = []): TreeNode => {\n\treturn {\n\t\tkey: uuid(),\n\t\ttype: node.type,\n\t\ttext: \"text\" in node ? node.text : undefined,\n\t\tnode,\n\t\tchildren,\n\t}\n}\n\nconst createTextTreeNode = (text: string): TreeNode => {\n\treturn createTreeNode({\n\t\ttype: RichTextNodeType.span,\n\t\ttext,\n\t\tspans: [],\n\t})\n}\n\nconst prepareNodes = (nodes: RTNode[]): RTBlockNode[] => {\n\tconst mutNodes: RTBlockNode[] = nodes.slice(0)\n\n\tfor (let i = 0; i < mutNodes.length; i++) {\n\t\tconst node = mutNodes[i]\n\n\t\tif (node.type === RichTextNodeType.listItem || node.type === RichTextNodeType.oListItem) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [node as RTListItemNode | RTOListItemNode]\n\n\t\t\twhile (mutNodes[i + 1] && mutNodes[i + 1].type === node.type) {\n\t\t\t\titems.push(mutNodes[i + 1] as RTListItemNode | RTOListItemNode)\n\t\t\t\tmutNodes.splice(i, 1)\n\t\t\t}\n\n\t\t\tif (node.type === RichTextNodeType.listItem) {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.list,\n\t\t\t\t\titems: items as RTListItemNode[],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.oList,\n\t\t\t\t\titems: items as RTOListItemNode[],\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mutNodes\n}\n\nconst nodeToTreeNode = (node: RTBlockNode): TreeNode => {\n\tif (\"text\" in node) {\n\t\treturn createTreeNode(node, textNodeSpansToTreeNodeChildren(node.spans, node))\n\t}\n\n\tif (\"items\" in node) {\n\t\tconst children: TreeNode[] = []\n\t\tfor (let i = 0; i < node.items.length; i++) {\n\t\t\tchildren.push(nodeToTreeNode(node.items[i]))\n\t\t}\n\n\t\treturn createTreeNode(node, children)\n\t}\n\n\treturn createTreeNode(node)\n}\n\nconst textNodeSpansToTreeNodeChildren = (\n\tspans: RTInlineNode[],\n\tnode: RTTextNode,\n\tparentSpan?: RTInlineNode,\n): TreeNode[] => {\n\tif (!spans.length) {\n\t\treturn [createTextTreeNode(node.text)]\n\t}\n\n\tconst mutSpans: RTInlineNode[] = spans.slice(0)\n\n\t// Sort spans using the following criteria:\n\t//\n\t// 1. By start index (ascending)\n\t// 2. If start indices are equal, by end index (descending)\n\t//\n\t// If start and end indices of more than one span are equal, use what\n\t// the API gives without modifications.\n\t//\n\t// Sorting using this algorithm ensures proper detection of child\n\t// spans.\n\tmutSpans.sort((a, b) => a.start - b.start || b.end - a.end)\n\n\tconst children: TreeNode[] = []\n\n\tfor (let i = 0; i < mutSpans.length; i++) {\n\t\tconst span = mutSpans[i]\n\t\tconst parentSpanStart = (parentSpan && parentSpan.start) || 0\n\t\tconst spanStart = span.start - parentSpanStart\n\t\tconst spanEnd = span.end - parentSpanStart\n\t\tconst text = node.text.slice(spanStart, spanEnd)\n\n\t\tconst childSpans: RTInlineNode[] = []\n\t\tfor (let j = i; j < mutSpans.length; j++) {\n\t\t\tconst siblingSpan = mutSpans[j]\n\n\t\t\tif (siblingSpan !== span) {\n\t\t\t\tif (siblingSpan.start >= span.start && siblingSpan.end <= span.end) {\n\t\t\t\t\tchildSpans.push(siblingSpan)\n\t\t\t\t\tmutSpans.splice(j, 1)\n\t\t\t\t\tj--\n\t\t\t\t} else if (siblingSpan.start < span.end && siblingSpan.end > span.start) {\n\t\t\t\t\tchildSpans.push({\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tend: span.end,\n\t\t\t\t\t})\n\t\t\t\t\tmutSpans[j] = {\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tstart: span.end,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (i === 0 && spanStart > 0) {\n\t\t\tchildren.push(createTextTreeNode(node.text.slice(0, spanStart)))\n\t\t}\n\n\t\tconst spanWithText = { ...span, text }\n\t\tchildren.push(\n\t\t\tcreateTreeNode(\n\t\t\t\tspanWithText,\n\t\t\t\ttextNodeSpansToTreeNodeChildren(\n\t\t\t\t\tchildSpans,\n\t\t\t\t\t{\n\t\t\t\t\t\t...node,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t},\n\t\t\t\t\tspan,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\n\t\tif (spanEnd < node.text.length) {\n\t\t\tchildren.push(\n\t\t\t\tcreateTextTreeNode(\n\t\t\t\t\tnode.text.slice(\n\t\t\t\t\t\tspanEnd,\n\t\t\t\t\t\tmutSpans[i + 1] ? mutSpans[i + 1].start - parentSpanStart : undefined,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn children\n}\n"],"mappings":";;AAYA,MAAM,aAAqB;CAC1B,QAAQ,EAAE,KAAK,EAAA,CAAG,SAAS;AAC5B;AACA,KAAK,IAAI;;;;;;;;;;AAWT,MAAa,UAAU,UAA0B;CAChD,MAAM,gBAAgB,aAAa,KAAK;CAExC,MAAM,WAAuB,CAAC;CAC9B,KA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IAAI,UAAU,KAAK,KAAK,QACvB,SAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,QAAQ,kBAAkB,KAAA,CAC7D,CACD,CACD;CAEF;CAEA,OAAO;AACR"}
@@ -1,6 +1,5 @@
1
1
  import { RTNode } from "../types/value/richText.cjs";
2
2
  import { Tree } from "./types.cjs";
3
-
4
3
  //#region src/richtext/asTree.d.ts
5
4
  /**
6
5
  * Parses a rich text or title field into a tree
@@ -11,7 +10,6 @@ import { Tree } from "./types.cjs";
11
10
  * @param nodes - A rich text or title field from Prismic
12
11
  * @returns Tree from given rich text or title field
13
12
  */
14
- declare const asTree: (nodes: RTNode[]) => Tree;
13
+ export declare const asTree: (nodes: RTNode[]) => Tree;
15
14
  //#endregion
16
- export { asTree };
17
15
  //# sourceMappingURL=asTree.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.d.cts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;AA0BA;;;;;;;cAAa,MAAA,GAAU,KAAA,EAAO,MAAA,OAAW,IAAA"}
1
+ {"version":3,"file":"asTree.d.cts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;;;;;;;qBA0Ba,SAAM,OAAW,aAAW"}
@@ -1,6 +1,5 @@
1
1
  import { RTNode } from "../types/value/richText.js";
2
2
  import { Tree } from "./types.js";
3
-
4
3
  //#region src/richtext/asTree.d.ts
5
4
  /**
6
5
  * Parses a rich text or title field into a tree
@@ -11,7 +10,6 @@ import { Tree } from "./types.js";
11
10
  * @param nodes - A rich text or title field from Prismic
12
11
  * @returns Tree from given rich text or title field
13
12
  */
14
- declare const asTree: (nodes: RTNode[]) => Tree;
13
+ export declare const asTree: (nodes: RTNode[]) => Tree;
15
14
  //#endregion
16
- export { asTree };
17
15
  //# sourceMappingURL=asTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.d.ts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;AA0BA;;;;;;;cAAa,MAAA,GAAU,KAAA,EAAO,MAAA,OAAW,IAAA"}
1
+ {"version":3,"file":"asTree.d.ts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;;;;;;;qBA0Ba,SAAM,OAAW,aAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.js","names":[],"sources":["../../src/richtext/asTree.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTListItemNode,\n\tRTNode,\n\tRTOListItemNode,\n\tRTTextNode,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { Tree, TreeNode } from \"./types\"\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString()\n}\nuuid.i = 0\n\n/**\n * Parses a rich text or title field into a tree\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages. Most users\n * aren't expected to this function directly.\n * @param nodes - A rich text or title field from Prismic\n * @returns Tree from given rich text or title field\n */\nexport const asTree = (nodes: RTNode[]): Tree => {\n\tconst preparedNodes = prepareNodes(nodes)\n\n\tconst children: TreeNode[] = []\n\tfor (let i = 0; i < preparedNodes.length; i++) {\n\t\tchildren.push(nodeToTreeNode(preparedNodes[i]))\n\t}\n\n\treturn {\n\t\tkey: uuid(),\n\t\tchildren,\n\t}\n}\n\nconst createTreeNode = (node: RTAnyNode, children: TreeNode[] = []): TreeNode => {\n\treturn {\n\t\tkey: uuid(),\n\t\ttype: node.type,\n\t\ttext: \"text\" in node ? node.text : undefined,\n\t\tnode,\n\t\tchildren,\n\t}\n}\n\nconst createTextTreeNode = (text: string): TreeNode => {\n\treturn createTreeNode({\n\t\ttype: RichTextNodeType.span,\n\t\ttext,\n\t\tspans: [],\n\t})\n}\n\nconst prepareNodes = (nodes: RTNode[]): RTBlockNode[] => {\n\tconst mutNodes: RTBlockNode[] = nodes.slice(0)\n\n\tfor (let i = 0; i < mutNodes.length; i++) {\n\t\tconst node = mutNodes[i]\n\n\t\tif (node.type === RichTextNodeType.listItem || node.type === RichTextNodeType.oListItem) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [node as RTListItemNode | RTOListItemNode]\n\n\t\t\twhile (mutNodes[i + 1] && mutNodes[i + 1].type === node.type) {\n\t\t\t\titems.push(mutNodes[i + 1] as RTListItemNode | RTOListItemNode)\n\t\t\t\tmutNodes.splice(i, 1)\n\t\t\t}\n\n\t\t\tif (node.type === RichTextNodeType.listItem) {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.list,\n\t\t\t\t\titems: items as RTListItemNode[],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.oList,\n\t\t\t\t\titems: items as RTOListItemNode[],\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mutNodes\n}\n\nconst nodeToTreeNode = (node: RTBlockNode): TreeNode => {\n\tif (\"text\" in node) {\n\t\treturn createTreeNode(node, textNodeSpansToTreeNodeChildren(node.spans, node))\n\t}\n\n\tif (\"items\" in node) {\n\t\tconst children: TreeNode[] = []\n\t\tfor (let i = 0; i < node.items.length; i++) {\n\t\t\tchildren.push(nodeToTreeNode(node.items[i]))\n\t\t}\n\n\t\treturn createTreeNode(node, children)\n\t}\n\n\treturn createTreeNode(node)\n}\n\nconst textNodeSpansToTreeNodeChildren = (\n\tspans: RTInlineNode[],\n\tnode: RTTextNode,\n\tparentSpan?: RTInlineNode,\n): TreeNode[] => {\n\tif (!spans.length) {\n\t\treturn [createTextTreeNode(node.text)]\n\t}\n\n\tconst mutSpans: RTInlineNode[] = spans.slice(0)\n\n\t// Sort spans using the following criteria:\n\t//\n\t// 1. By start index (ascending)\n\t// 2. If start indices are equal, by end index (descending)\n\t//\n\t// If start and end indices of more than one span are equal, use what\n\t// the API gives without modifications.\n\t//\n\t// Sorting using this algorithm ensures proper detection of child\n\t// spans.\n\tmutSpans.sort((a, b) => a.start - b.start || b.end - a.end)\n\n\tconst children: TreeNode[] = []\n\n\tfor (let i = 0; i < mutSpans.length; i++) {\n\t\tconst span = mutSpans[i]\n\t\tconst parentSpanStart = (parentSpan && parentSpan.start) || 0\n\t\tconst spanStart = span.start - parentSpanStart\n\t\tconst spanEnd = span.end - parentSpanStart\n\t\tconst text = node.text.slice(spanStart, spanEnd)\n\n\t\tconst childSpans: RTInlineNode[] = []\n\t\tfor (let j = i; j < mutSpans.length; j++) {\n\t\t\tconst siblingSpan = mutSpans[j]\n\n\t\t\tif (siblingSpan !== span) {\n\t\t\t\tif (siblingSpan.start >= span.start && siblingSpan.end <= span.end) {\n\t\t\t\t\tchildSpans.push(siblingSpan)\n\t\t\t\t\tmutSpans.splice(j, 1)\n\t\t\t\t\tj--\n\t\t\t\t} else if (siblingSpan.start < span.end && siblingSpan.end > span.start) {\n\t\t\t\t\tchildSpans.push({\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tend: span.end,\n\t\t\t\t\t})\n\t\t\t\t\tmutSpans[j] = {\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tstart: span.end,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (i === 0 && spanStart > 0) {\n\t\t\tchildren.push(createTextTreeNode(node.text.slice(0, spanStart)))\n\t\t}\n\n\t\tconst spanWithText = { ...span, text }\n\t\tchildren.push(\n\t\t\tcreateTreeNode(\n\t\t\t\tspanWithText,\n\t\t\t\ttextNodeSpansToTreeNodeChildren(\n\t\t\t\t\tchildSpans,\n\t\t\t\t\t{\n\t\t\t\t\t\t...node,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t},\n\t\t\t\t\tspan,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\n\t\tif (spanEnd < node.text.length) {\n\t\t\tchildren.push(\n\t\t\t\tcreateTextTreeNode(\n\t\t\t\t\tnode.text.slice(\n\t\t\t\t\t\t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AAK,YAAY,EAC1B,UAAS,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,UAAU,CAAC,CAAC;EAGjE,MAAM,eAAe;GAAE,GAAG;GAAM;GAAM;AACtC,WAAS,KACR,eACC,cACA,gCACC,YACA;GACC,GAAG;GACH;GACA,EACD,KACA,CACD,CACD;AAED,MAAI,UAAU,KAAK,KAAK,OACvB,UAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,KAAK,SAAS,IAAI,GAAG,QAAQ,kBAAkB,KAAA,EAC5D,CACD,CACD;;AAIH,QAAO"}
1
+ {"version":3,"file":"asTree.js","names":[],"sources":["../../src/richtext/asTree.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTListItemNode,\n\tRTNode,\n\tRTOListItemNode,\n\tRTTextNode,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { Tree, TreeNode } from \"./types\"\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString()\n}\nuuid.i = 0\n\n/**\n * Parses a rich text or title field into a tree\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages. Most users\n * aren't expected to this function directly.\n * @param nodes - A rich text or title field from Prismic\n * @returns Tree from given rich text or title field\n */\nexport const asTree = (nodes: RTNode[]): Tree => {\n\tconst preparedNodes = prepareNodes(nodes)\n\n\tconst children: TreeNode[] = []\n\tfor (let i = 0; i < preparedNodes.length; i++) {\n\t\tchildren.push(nodeToTreeNode(preparedNodes[i]))\n\t}\n\n\treturn {\n\t\tkey: uuid(),\n\t\tchildren,\n\t}\n}\n\nconst createTreeNode = (node: RTAnyNode, children: TreeNode[] = []): TreeNode => {\n\treturn {\n\t\tkey: uuid(),\n\t\ttype: node.type,\n\t\ttext: \"text\" in node ? node.text : undefined,\n\t\tnode,\n\t\tchildren,\n\t}\n}\n\nconst createTextTreeNode = (text: string): TreeNode => {\n\treturn createTreeNode({\n\t\ttype: RichTextNodeType.span,\n\t\ttext,\n\t\tspans: [],\n\t})\n}\n\nconst prepareNodes = (nodes: RTNode[]): RTBlockNode[] => {\n\tconst mutNodes: RTBlockNode[] = nodes.slice(0)\n\n\tfor (let i = 0; i < mutNodes.length; i++) {\n\t\tconst node = mutNodes[i]\n\n\t\tif (node.type === RichTextNodeType.listItem || node.type === RichTextNodeType.oListItem) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [node as RTListItemNode | RTOListItemNode]\n\n\t\t\twhile (mutNodes[i + 1] && mutNodes[i + 1].type === node.type) {\n\t\t\t\titems.push(mutNodes[i + 1] as RTListItemNode | RTOListItemNode)\n\t\t\t\tmutNodes.splice(i, 1)\n\t\t\t}\n\n\t\t\tif (node.type === RichTextNodeType.listItem) {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.list,\n\t\t\t\t\titems: items as RTListItemNode[],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.oList,\n\t\t\t\t\titems: items as RTOListItemNode[],\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mutNodes\n}\n\nconst nodeToTreeNode = (node: RTBlockNode): TreeNode => {\n\tif (\"text\" in node) {\n\t\treturn createTreeNode(node, textNodeSpansToTreeNodeChildren(node.spans, node))\n\t}\n\n\tif (\"items\" in node) {\n\t\tconst children: TreeNode[] = []\n\t\tfor (let i = 0; i < node.items.length; i++) {\n\t\t\tchildren.push(nodeToTreeNode(node.items[i]))\n\t\t}\n\n\t\treturn createTreeNode(node, children)\n\t}\n\n\treturn createTreeNode(node)\n}\n\nconst textNodeSpansToTreeNodeChildren = (\n\tspans: RTInlineNode[],\n\tnode: RTTextNode,\n\tparentSpan?: RTInlineNode,\n): TreeNode[] => {\n\tif (!spans.length) {\n\t\treturn [createTextTreeNode(node.text)]\n\t}\n\n\tconst mutSpans: RTInlineNode[] = spans.slice(0)\n\n\t// Sort spans using the following criteria:\n\t//\n\t// 1. By start index (ascending)\n\t// 2. If start indices are equal, by end index (descending)\n\t//\n\t// If start and end indices of more than one span are equal, use what\n\t// the API gives without modifications.\n\t//\n\t// Sorting using this algorithm ensures proper detection of child\n\t// spans.\n\tmutSpans.sort((a, b) => a.start - b.start || b.end - a.end)\n\n\tconst children: TreeNode[] = []\n\n\tfor (let i = 0; i < mutSpans.length; i++) {\n\t\tconst span = mutSpans[i]\n\t\tconst parentSpanStart = (parentSpan && parentSpan.start) || 0\n\t\tconst spanStart = span.start - parentSpanStart\n\t\tconst spanEnd = span.end - parentSpanStart\n\t\tconst text = node.text.slice(spanStart, spanEnd)\n\n\t\tconst childSpans: RTInlineNode[] = []\n\t\tfor (let j = i; j < mutSpans.length; j++) {\n\t\t\tconst siblingSpan = mutSpans[j]\n\n\t\t\tif (siblingSpan !== span) {\n\t\t\t\tif (siblingSpan.start >= span.start && siblingSpan.end <= span.end) {\n\t\t\t\t\tchildSpans.push(siblingSpan)\n\t\t\t\t\tmutSpans.splice(j, 1)\n\t\t\t\t\tj--\n\t\t\t\t} else if (siblingSpan.start < span.end && siblingSpan.end > span.start) {\n\t\t\t\t\tchildSpans.push({\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tend: span.end,\n\t\t\t\t\t})\n\t\t\t\t\tmutSpans[j] = {\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tstart: span.end,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (i === 0 && spanStart > 0) {\n\t\t\tchildren.push(createTextTreeNode(node.text.slice(0, spanStart)))\n\t\t}\n\n\t\tconst spanWithText = { ...span, text }\n\t\tchildren.push(\n\t\t\tcreateTreeNode(\n\t\t\t\tspanWithText,\n\t\t\t\ttextNodeSpansToTreeNodeChildren(\n\t\t\t\t\tchildSpans,\n\t\t\t\t\t{\n\t\t\t\t\t\t...node,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t},\n\t\t\t\t\tspan,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\n\t\tif (spanEnd < node.text.length) {\n\t\t\tchildren.push(\n\t\t\t\tcreateTextTreeNode(\n\t\t\t\t\tnode.text.slice(\n\t\t\t\t\t\tspanEnd,\n\t\t\t\t\t\tmutSpans[i + 1] ? mutSpans[i + 1].start - parentSpanStart : undefined,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn children\n}\n"],"mappings":";;AAYA,MAAM,aAAqB;CAC1B,QAAQ,EAAE,KAAK,EAAA,CAAG,SAAS;AAC5B;AACA,KAAK,IAAI;;;;;;;;;;AAWT,MAAa,UAAU,UAA0B;CAChD,MAAM,gBAAgB,aAAa,KAAK;CAExC,MAAM,WAAuB,CAAC;CAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACzC,SAAS,KAAK,eAAe,cAAc,EAAE,CAAC;CAG/C,OAAO;EACN,KAAK,KAAK;EACV;CACD;AACD;AAEA,MAAM,kBAAkB,MAAiB,WAAuB,CAAC,MAAgB;CAChF,OAAO;EACN,KAAK,KAAK;EACV,MAAM,KAAK;EACX,MAAM,UAAU,OAAO,KAAK,OAAO,KAAA;EACnC;EACA;CACD;AACD;AAEA,MAAM,sBAAsB,SAA2B;CACtD,OAAO,eAAe;EACrB,MAAM,iBAAiB;EACvB;EACA,OAAO,CAAC;CACT,CAAC;AACF;AAEA,MAAM,gBAAgB,UAAmC;CACxD,MAAM,WAA0B,MAAM,MAAM,CAAC;CAE7C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACzC,MAAM,OAAO,SAAS;EAEtB,IAAI,KAAK,SAAS,iBAAiB,YAAY,KAAK,SAAS,iBAAiB,WAAW;GACxF,MAAM,QAA8C,CAAC,IAAwC;GAE7F,OAAO,SAAS,IAAI,MAAM,SAAS,IAAI,EAAE,CAAC,SAAS,KAAK,MAAM;IAC7D,MAAM,KAAK,SAAS,IAAI,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AAS,OAAO,GAAG,CAAC;KACpB;IACD,OAAO,IAAI,YAAY,QAAQ,KAAK,OAAO,YAAY,MAAM,KAAK,OAAO;KACxE,WAAW,KAAK;MACf,GAAG;MACH,KAAK,KAAK;KACX,CAAC;KACD,SAAS,KAAK;MACb,GAAG;MACH,OAAO,KAAK;KACb;IACD;GACD;EACD;EAEA,IAAI,MAAM,KAAK,YAAY,GAC1B,SAAS,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;EAGhE,MAAM,eAAe;GAAE,GAAG;GAAM;EAAK;EACrC,SAAS,KACR,eACC,cACA,gCACC,YACA;GACC,GAAG;GACH;EACD,GACA,IACD,CACD,CACD;EAEA,IAAI,UAAU,KAAK,KAAK,QACvB,SAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,QAAQ,kBAAkB,KAAA,CAC7D,CACD,CACD;CAEF;CAEA,OAAO;AACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.cjs","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided serializers sequentially\n * until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages Most users\n * aren't expected to this function directly\n * @typeParam SerializerReturnType - Return type of serializers\n * @param serializers - Serializers to compose\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBACZ,GAAG,gBACmD;AACtD,SAAQ,GAAG,SAAS;AACnB,OAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;GAC5C,MAAM,aAAa,YAAY;AAE/B,OAAI,YAAY;IACf,MAAM,MAAM,WAAW,GAAG,KAAK;AAE/B,QAAI,OAAO,KACV,QAAO"}
1
+ {"version":3,"file":"composeSerializers.cjs","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided serializers sequentially\n * until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages Most users\n * aren't expected to this function directly\n * @typeParam SerializerReturnType - Return type of serializers\n * @param serializers - Serializers to compose\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBACZ,GAAG,gBACmD;CACtD,QAAQ,GAAG,SAAS;EACnB,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;GAC5C,MAAM,aAAa,YAAY;GAE/B,IAAI,YAAY;IACf,MAAM,MAAM,WAAW,GAAG,IAAI;IAE9B,IAAI,OAAO,MACV,OAAO;GAET;EACD;CACD;AACD"}
@@ -1,5 +1,4 @@
1
1
  import { RichTextFunctionSerializer } from "./types.cjs";
2
-
3
2
  //#region src/richtext/composeSerializers.d.ts
4
3
  /**
5
4
  * Takes an array of serializers and returns a serializer applying provided serializers sequentially
@@ -12,7 +11,6 @@ import { RichTextFunctionSerializer } from "./types.cjs";
12
11
  * @param serializers - Serializers to compose
13
12
  * @returns Composed serializer
14
13
  */
15
- declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
14
+ export declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
16
15
  //#endregion
17
- export { composeSerializers };
18
16
  //# sourceMappingURL=composeSerializers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.d.cts","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"mappings":";;;;;AAaA;;;;;;;;;cAAa,kBAAA,4BACT,WAAA,GAAc,0BAAA,CAA2B,oBAAA,qBAC1C,0BAAA,CAA2B,oBAAA"}
1
+ {"version":3,"file":"composeSerializers.d.cts","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"mappings":";;;;;;;;;;;;;qBAaa,qBAAsB,yBAAoB,cACrC,2BAA2B,yCAC1C,2BAA2B"}
@@ -1,5 +1,4 @@
1
1
  import { RichTextFunctionSerializer } from "./types.js";
2
-
3
2
  //#region src/richtext/composeSerializers.d.ts
4
3
  /**
5
4
  * Takes an array of serializers and returns a serializer applying provided serializers sequentially
@@ -12,7 +11,6 @@ import { RichTextFunctionSerializer } from "./types.js";
12
11
  * @param serializers - Serializers to compose
13
12
  * @returns Composed serializer
14
13
  */
15
- declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
14
+ export declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
16
15
  //#endregion
17
- export { composeSerializers };
18
16
  //# sourceMappingURL=composeSerializers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.d.ts","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"mappings":";;;;;AAaA;;;;;;;;;cAAa,kBAAA,4BACT,WAAA,GAAc,0BAAA,CAA2B,oBAAA,qBAC1C,0BAAA,CAA2B,oBAAA"}
1
+ {"version":3,"file":"composeSerializers.d.ts","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"mappings":";;;;;;;;;;;;;qBAaa,qBAAsB,yBAAoB,cACrC,2BAA2B,yCAC1C,2BAA2B"}
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.js","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided serializers sequentially\n * until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages Most users\n * aren't expected to this function directly\n * @typeParam SerializerReturnType - Return type of serializers\n * @param serializers - Serializers to compose\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBACZ,GAAG,gBACmD;AACtD,SAAQ,GAAG,SAAS;AACnB,OAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;GAC5C,MAAM,aAAa,YAAY;AAE/B,OAAI,YAAY;IACf,MAAM,MAAM,WAAW,GAAG,KAAK;AAE/B,QAAI,OAAO,KACV,QAAO"}
1
+ {"version":3,"file":"composeSerializers.js","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided serializers sequentially\n * until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level packages Most users\n * aren't expected to this function directly\n * @typeParam SerializerReturnType - Return type of serializers\n * @param serializers - Serializers to compose\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBACZ,GAAG,gBACmD;CACtD,QAAQ,GAAG,SAAS;EACnB,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;GAC5C,MAAM,aAAa,YAAY;GAE/B,IAAI,YAAY;IACf,MAAM,MAAM,WAAW,GAAG,IAAI;IAE9B,IAAI,OAAO,MACV,OAAO;GAET;EACD;CACD;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.cjs","names":["asTree"],"sources":["../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport { asTree } from \"./asTree\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level packages. Most users\n * aren't expected to use this function directly.\n * @typeParam SerializerReturnType - Return type of the serializer.\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n * @returns An array of serialized nodes.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(asTree(richTextField).children, serializer)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,aACZ,eACA,eAC4B;AAC5B,QAAO,mBAAyCA,eAAAA,OAAO,cAAc,CAAC,UAAU,WAAW;;AAG5F,MAAM,sBACL,OACA,eACS;CACT,MAAM,sBAA2B,EAAE;AAEnC,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,WAAW,MAAM;EACvB,MAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,WAAW,EACjD,SAAS,IACT;AAED,MAAI,sBAAsB,KACzB,qBAAoB,KAAK,mBAAmB;;AAI9C,QAAO"}
1
+ {"version":3,"file":"serialize.cjs","names":["asTree"],"sources":["../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport { asTree } from \"./asTree\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level packages. Most users\n * aren't expected to use this function directly.\n * @typeParam SerializerReturnType - Return type of the serializer.\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n * @returns An array of serialized nodes.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(asTree(richTextField).children, serializer)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,aACZ,eACA,eAC4B;CAC5B,OAAO,mBAAyCA,eAAAA,OAAO,aAAa,CAAC,CAAC,UAAU,UAAU;AAC3F;AAEA,MAAM,sBACL,OACA,eACS;CACT,MAAM,sBAA2B,CAAC;CAElC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,WAAW,MAAM;EACvB,MAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GACV;EAEA,IAAI,sBAAsB,MACzB,oBAAoB,KAAK,kBAAkB;CAE7C;CAEA,OAAO;AACR"}
@@ -1,6 +1,5 @@
1
1
  import { RichTextField } from "../types/value/richText.cjs";
2
2
  import { RichTextFunctionSerializer } from "./types.cjs";
3
-
4
3
  //#region src/richtext/serialize.d.ts
5
4
  /**
6
5
  * Serializes a rich text field with a given serializer.
@@ -14,7 +13,6 @@ import { RichTextFunctionSerializer } from "./types.cjs";
14
13
  * @returns An array of serialized nodes.
15
14
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
16
15
  */
17
- declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
16
+ export declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
18
17
  //#endregion
19
- export { serialize };
20
18
  //# sourceMappingURL=serialize.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.cts","names":[],"sources":["../../src/richtext/serialize.ts"],"mappings":";;;;;;AAgBA;;;;;;;;;;cAAa,SAAA,yBACZ,aAAA,EAAe,aAAA,EACf,UAAA,EAAY,0BAAA,CAA2B,oBAAA,MACrC,oBAAA"}
1
+ {"version":3,"file":"serialize.d.cts","names":[],"sources":["../../src/richtext/serialize.ts"],"mappings":";;;;;;;;;;;;;;;qBAgBa,YAAa,sBAAoB,eAC9B,eAAa,YAChB,2BAA2B,0BACrC"}
@@ -1,6 +1,5 @@
1
1
  import { RichTextField } from "../types/value/richText.js";
2
2
  import { RichTextFunctionSerializer } from "./types.js";
3
-
4
3
  //#region src/richtext/serialize.d.ts
5
4
  /**
6
5
  * Serializes a rich text field with a given serializer.
@@ -14,7 +13,6 @@ import { RichTextFunctionSerializer } from "./types.js";
14
13
  * @returns An array of serialized nodes.
15
14
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
16
15
  */
17
- declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
16
+ export declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
18
17
  //#endregion
19
- export { serialize };
20
18
  //# sourceMappingURL=serialize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","names":[],"sources":["../../src/richtext/serialize.ts"],"mappings":";;;;;;AAgBA;;;;;;;;;;cAAa,SAAA,yBACZ,aAAA,EAAe,aAAA,EACf,UAAA,EAAY,0BAAA,CAA2B,oBAAA,MACrC,oBAAA"}
1
+ {"version":3,"file":"serialize.d.ts","names":[],"sources":["../../src/richtext/serialize.ts"],"mappings":";;;;;;;;;;;;;;;qBAgBa,YAAa,sBAAoB,eAC9B,eAAa,YAChB,2BAA2B,0BACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.js","names":[],"sources":["../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport { asTree } from \"./asTree\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level packages. Most users\n * aren't expected to use this function directly.\n * @typeParam SerializerReturnType - Return type of the serializer.\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n * @returns An array of serialized nodes.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(asTree(richTextField).children, serializer)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,aACZ,eACA,eAC4B;AAC5B,QAAO,mBAAyC,OAAO,cAAc,CAAC,UAAU,WAAW;;AAG5F,MAAM,sBACL,OACA,eACS;CACT,MAAM,sBAA2B,EAAE;AAEnC,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,WAAW,MAAM;EACvB,MAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,WAAW,EACjD,SAAS,IACT;AAED,MAAI,sBAAsB,KACzB,qBAAoB,KAAK,mBAAmB;;AAI9C,QAAO"}
1
+ {"version":3,"file":"serialize.js","names":[],"sources":["../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport { asTree } from \"./asTree\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level packages. Most users\n * aren't expected to use this function directly.\n * @typeParam SerializerReturnType - Return type of the serializer.\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n * @returns An array of serialized nodes.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(asTree(richTextField).children, serializer)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,aACZ,eACA,eAC4B;CAC5B,OAAO,mBAAyC,OAAO,aAAa,CAAC,CAAC,UAAU,UAAU;AAC3F;AAEA,MAAM,sBACL,OACA,eACS;CACT,MAAM,sBAA2B,CAAC;CAElC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,WAAW,MAAM;EACvB,MAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GACV;EAEA,IAAI,sBAAsB,MACzB,oBAAoB,KAAK,kBAAkB;CAE7C;CAEA,OAAO;AACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":["RichTextNodeType"],"sources":["../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n * This type of serializer needs to be processed through {@link wrapMapSerializer} before being\n * used with {@link serialize}.\n * @typeParam ReturnType - Return type of the map serializer.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>\n\theading2?: RichTextMapSerializerFunction<ReturnType, RTHeading2Node, undefined>\n\theading3?: RichTextMapSerializerFunction<ReturnType, RTHeading3Node, undefined>\n\theading4?: RichTextMapSerializerFunction<ReturnType, RTHeading4Node, undefined>\n\theading5?: RichTextMapSerializerFunction<ReturnType, RTHeading5Node, undefined>\n\theading6?: RichTextMapSerializerFunction<ReturnType, RTHeading6Node, undefined>\n\tparagraph?: RichTextMapSerializerFunction<ReturnType, RTParagraphNode, undefined>\n\tpreformatted?: RichTextMapSerializerFunction<ReturnType, RTPreformattedNode, undefined>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<ReturnType, RTListItemNode, undefined>\n\toListItem?: RichTextMapSerializerFunction<ReturnType, RTOListItemNode, undefined>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"mappings":";;AAwGA,MAAa,2BAA2B;EACtCA,iBAAAA,iBAAiB,WAAW;EAC5BA,iBAAAA,iBAAiB,YAAY;EAC7BA,iBAAAA,iBAAiB,OAAO;EACxBA,iBAAAA,iBAAiB,QAAQ;CAC1B"}
1
+ {"version":3,"file":"types.cjs","names":["RichTextNodeType"],"sources":["../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n * This type of serializer needs to be processed through {@link wrapMapSerializer} before being\n * used with {@link serialize}.\n * @typeParam ReturnType - Return type of the map serializer.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>\n\theading2?: RichTextMapSerializerFunction<ReturnType, RTHeading2Node, undefined>\n\theading3?: RichTextMapSerializerFunction<ReturnType, RTHeading3Node, undefined>\n\theading4?: RichTextMapSerializerFunction<ReturnType, RTHeading4Node, undefined>\n\theading5?: RichTextMapSerializerFunction<ReturnType, RTHeading5Node, undefined>\n\theading6?: RichTextMapSerializerFunction<ReturnType, RTHeading6Node, undefined>\n\tparagraph?: RichTextMapSerializerFunction<ReturnType, RTParagraphNode, undefined>\n\tpreformatted?: RichTextMapSerializerFunction<ReturnType, RTPreformattedNode, undefined>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<ReturnType, RTListItemNode, undefined>\n\toListItem?: RichTextMapSerializerFunction<ReturnType, RTOListItemNode, undefined>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"mappings":";;AAwGA,MAAa,2BAA2B;EACtCA,iBAAAA,iBAAiB,WAAW;EAC5BA,iBAAAA,iBAAiB,YAAY;EAC7BA,iBAAAA,iBAAiB,OAAO;EACxBA,iBAAAA,iBAAiB,QAAQ;AAC3B"}
@@ -1,5 +1,4 @@
1
1
  import { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText.cjs";
2
-
3
2
  //#region src/richtext/types.d.ts
4
3
  /**
5
4
  * Serializes a node from a rich text or title field with a function
@@ -7,13 +6,13 @@ import { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHea
7
6
  * @typeParam ReturnType - Return type of the function serializer.
8
7
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
9
8
  */
10
- type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
9
+ export type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
11
10
  /**
12
11
  * Map serializer's tag function serializer, can be helpful for typing those handlers
13
12
  *
14
13
  * @typeParam ReturnType - Return type of the tag serializer
15
14
  */
16
- type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNode, TextType = string | undefined> = (payload: {
15
+ export type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNode, TextType = string | undefined> = (payload: {
17
16
  type: Node["type"];
18
17
  node: Node;
19
18
  text: TextType;
@@ -29,7 +28,7 @@ type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNod
29
28
  * @typeParam ReturnType - Return type of the map serializer.
30
29
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
31
30
  */
32
- type RichTextMapSerializer<ReturnType> = {
31
+ export type RichTextMapSerializer<ReturnType> = {
33
32
  heading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>;
34
33
  heading2?: RichTextMapSerializerFunction<ReturnType, RTHeading2Node, undefined>;
35
34
  heading3?: RichTextMapSerializerFunction<ReturnType, RTHeading3Node, undefined>;
@@ -50,11 +49,11 @@ type RichTextMapSerializer<ReturnType> = {
50
49
  label?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>;
51
50
  span?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>;
52
51
  };
53
- interface Tree {
52
+ export interface Tree {
54
53
  key: string;
55
54
  children: TreeNode[];
56
55
  }
57
- interface TreeNode {
56
+ export interface TreeNode {
58
57
  key: string;
59
58
  type: RichTextNodeTypes;
60
59
  text?: string;
@@ -62,5 +61,4 @@ interface TreeNode {
62
61
  children: TreeNode[];
63
62
  }
64
63
  //#endregion
65
- export { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction, Tree };
66
64
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/richtext/types.ts"],"mappings":";;;;;AAiCA;;;;KAAY,0BAAA,gBACX,IAAA,EAAM,iBAAA,EACN,IAAA,EAAM,SAAA,EACN,IAAA,sBACA,QAAA,EAAU,UAAA,IACV,GAAA,aACI,UAAA;;;;;;KAOO,6BAAA,0BAEE,SAAA,GAAY,SAAA,oCAErB,OAAA;EACJ,IAAA,EAAM,IAAA;EACN,IAAA,EAAM,IAAA;EACN,IAAA,EAAM,QAAA;EACN,QAAA,EAAU,UAAA;EACV,GAAA;AAAA,MACK,UAAA;;;;;AAVN;;;;;KAqBY,qBAAA;EACX,QAAA,GAAW,6BAAA,CAA8B,UAAA,EAAY,cAAA;EACrD,QAAA,GAAW,6BAAA,CAA8B,UAAA,EAAY,cAAA;EACrD,QAAA,GAAW,6BAAA,CAA8B,UAAA,EAAY,cAAA;EACrD,QAAA,GAAW,6BAAA,CAA8B,UAAA,EAAY,cAAA;EACrD,QAAA,GAAW,6BAAA,CAA8B,UAAA,EAAY,cAAA;EACrD,QAAA,GAAW,6BAAA,CAA8B,UAAA,EAAY,cAAA;EACrD,SAAA,GAAY,6BAAA,CAA8B,UAAA,EAAY,eAAA;EACtD,YAAA,GAAe,6BAAA,CAA8B,UAAA,EAAY,kBAAA;EACzD,MAAA,GAAS,6BAAA,CAA8B,UAAA,EAAY,YAAA;EACnD,EAAA,GAAK,6BAAA,CAA8B,UAAA,EAAY,QAAA;EAC/C,QAAA,GAAW,6BAAA,CAA8B,UAAA,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8B,YAAY;EAClD,QAAQ,8BAA8B,YAAY;EAClD,QAAQ,8BAA8B,YAAY;EAClD,YAAY,8BAA8B,YAAY;EACtD,QAAQ,8BAA8B,YAAY;EAClD,OAAO,8BAA8B,YAAY;;iBAIjC;EAChB;EACA,UAAU;;iBAGM;EAChB;EACA,MAAM;EACN;EACA,MAAM;EACN,UAAU"}
@@ -1,5 +1,4 @@
1
1
  import { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText.js";
2
-
3
2
  //#region src/richtext/types.d.ts
4
3
  /**
5
4
  * Serializes a node from a rich text or title field with a function
@@ -7,13 +6,13 @@ import { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHea
7
6
  * @typeParam ReturnType - Return type of the function serializer.
8
7
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
9
8
  */
10
- type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
9
+ export type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
11
10
  /**
12
11
  * Map serializer's tag function serializer, can be helpful for typing those handlers
13
12
  *
14
13
  * @typeParam ReturnType - Return type of the tag serializer
15
14
  */
16
- type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNode, TextType = string | undefined> = (payload: {
15
+ export type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNode, TextType = string | undefined> = (payload: {
17
16
  type: Node["type"];
18
17
  node: Node;
19
18
  text: TextType;
@@ -29,7 +28,7 @@ type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNod
29
28
  * @typeParam ReturnType - Return type of the map serializer.
30
29
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
31
30
  */
32
- type RichTextMapSerializer<ReturnType> = {
31
+ export type RichTextMapSerializer<ReturnType> = {
33
32
  heading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>;
34
33
  heading2?: RichTextMapSerializerFunction<ReturnType, RTHeading2Node, undefined>;
35
34
  heading3?: RichTextMapSerializerFunction<ReturnType, RTHeading3Node, undefined>;
@@ -50,11 +49,11 @@ type RichTextMapSerializer<ReturnType> = {
50
49
  label?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>;
51
50
  span?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>;
52
51
  };
53
- interface Tree {
52
+ export interface Tree {
54
53
  key: string;
55
54
  children: TreeNode[];
56
55
  }
57
- interface TreeNode {
56
+ export interface TreeNode {
58
57
  key: string;
59
58
  type: RichTextNodeTypes;
60
59
  text?: string;
@@ -62,5 +61,4 @@ interface TreeNode {
62
61
  children: TreeNode[];
63
62
  }
64
63
  //#endregion
65
- export { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction, Tree };
66
64
  //# sourceMappingURL=types.d.ts.map