@prismicio/client 7.21.7 → 7.21.8

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 (593) hide show
  1. package/dist/Client.cjs +190 -263
  2. package/dist/Client.cjs.map +1 -1
  3. package/dist/Client.d.cts +175 -241
  4. package/dist/Client.d.cts.map +1 -1
  5. package/dist/Client.d.ts +175 -241
  6. package/dist/Client.d.ts.map +1 -1
  7. package/dist/Client.js +190 -263
  8. package/dist/Client.js.map +1 -1
  9. package/dist/Migration.cjs +54 -86
  10. package/dist/Migration.cjs.map +1 -1
  11. package/dist/Migration.d.cts +50 -84
  12. package/dist/Migration.d.cts.map +1 -1
  13. package/dist/Migration.d.ts +50 -84
  14. package/dist/Migration.d.ts.map +1 -1
  15. package/dist/Migration.js +54 -86
  16. package/dist/Migration.js.map +1 -1
  17. package/dist/WriteClient.cjs +39 -77
  18. package/dist/WriteClient.cjs.map +1 -1
  19. package/dist/WriteClient.d.cts +24 -63
  20. package/dist/WriteClient.d.cts.map +1 -1
  21. package/dist/WriteClient.d.ts +24 -63
  22. package/dist/WriteClient.d.ts.map +1 -1
  23. package/dist/WriteClient.js +39 -77
  24. package/dist/WriteClient.js.map +1 -1
  25. package/dist/buildQueryURL.cjs +15 -22
  26. package/dist/buildQueryURL.cjs.map +1 -1
  27. package/dist/buildQueryURL.d.cts +53 -63
  28. package/dist/buildQueryURL.d.cts.map +1 -1
  29. package/dist/buildQueryURL.d.ts +53 -63
  30. package/dist/buildQueryURL.d.ts.map +1 -1
  31. package/dist/buildQueryURL.js +15 -22
  32. package/dist/buildQueryURL.js.map +1 -1
  33. package/dist/cookie.cjs +1 -4
  34. package/dist/cookie.cjs.map +1 -1
  35. package/dist/cookie.d.cts +1 -4
  36. package/dist/cookie.d.cts.map +1 -1
  37. package/dist/cookie.d.ts +1 -4
  38. package/dist/cookie.d.ts.map +1 -1
  39. package/dist/cookie.js +1 -4
  40. package/dist/cookie.js.map +1 -1
  41. package/dist/createClient.cjs +10 -14
  42. package/dist/createClient.cjs.map +1 -1
  43. package/dist/createClient.d.cts +11 -18
  44. package/dist/createClient.d.cts.map +1 -1
  45. package/dist/createClient.d.ts +11 -18
  46. package/dist/createClient.d.ts.map +1 -1
  47. package/dist/createClient.js +10 -14
  48. package/dist/createClient.js.map +1 -1
  49. package/dist/createMigration.cjs +4 -7
  50. package/dist/createMigration.cjs.map +1 -1
  51. package/dist/createMigration.d.cts +5 -11
  52. package/dist/createMigration.d.cts.map +1 -1
  53. package/dist/createMigration.d.ts +5 -11
  54. package/dist/createMigration.d.ts.map +1 -1
  55. package/dist/createMigration.js +4 -7
  56. package/dist/createMigration.js.map +1 -1
  57. package/dist/createWriteClient.cjs +8 -13
  58. package/dist/createWriteClient.cjs.map +1 -1
  59. package/dist/createWriteClient.d.cts +10 -15
  60. package/dist/createWriteClient.d.cts.map +1 -1
  61. package/dist/createWriteClient.d.ts +10 -15
  62. package/dist/createWriteClient.d.ts.map +1 -1
  63. package/dist/createWriteClient.js +8 -13
  64. package/dist/createWriteClient.js.map +1 -1
  65. package/dist/errors.cjs.map +1 -1
  66. package/dist/errors.d.cts.map +1 -1
  67. package/dist/errors.d.ts.map +1 -1
  68. package/dist/errors.js.map +1 -1
  69. package/dist/filter.cjs +5 -18
  70. package/dist/filter.cjs.map +1 -1
  71. package/dist/filter.d.cts +59 -63
  72. package/dist/filter.d.cts.map +1 -1
  73. package/dist/filter.d.ts +59 -63
  74. package/dist/filter.d.ts.map +1 -1
  75. package/dist/filter.js +5 -18
  76. package/dist/filter.js.map +1 -1
  77. package/dist/getGraphQLEndpoint.cjs +0 -2
  78. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  79. package/dist/getGraphQLEndpoint.d.cts +0 -2
  80. package/dist/getGraphQLEndpoint.d.cts.map +1 -1
  81. package/dist/getGraphQLEndpoint.d.ts +0 -2
  82. package/dist/getGraphQLEndpoint.d.ts.map +1 -1
  83. package/dist/getGraphQLEndpoint.js +0 -2
  84. package/dist/getGraphQLEndpoint.js.map +1 -1
  85. package/dist/getRepositoryEndpoint.cjs +4 -8
  86. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  87. package/dist/getRepositoryEndpoint.d.cts +4 -8
  88. package/dist/getRepositoryEndpoint.d.cts.map +1 -1
  89. package/dist/getRepositoryEndpoint.d.ts +4 -8
  90. package/dist/getRepositoryEndpoint.d.ts.map +1 -1
  91. package/dist/getRepositoryEndpoint.js +4 -8
  92. package/dist/getRepositoryEndpoint.js.map +1 -1
  93. package/dist/getRepositoryName.cjs +2 -5
  94. package/dist/getRepositoryName.cjs.map +1 -1
  95. package/dist/getRepositoryName.d.cts +2 -5
  96. package/dist/getRepositoryName.d.cts.map +1 -1
  97. package/dist/getRepositoryName.d.ts +2 -5
  98. package/dist/getRepositoryName.d.ts.map +1 -1
  99. package/dist/getRepositoryName.js +2 -5
  100. package/dist/getRepositoryName.js.map +1 -1
  101. package/dist/getToolbarSrc.cjs +17 -19
  102. package/dist/getToolbarSrc.cjs.map +1 -1
  103. package/dist/getToolbarSrc.d.cts +17 -19
  104. package/dist/getToolbarSrc.d.cts.map +1 -1
  105. package/dist/getToolbarSrc.d.ts +17 -19
  106. package/dist/getToolbarSrc.d.ts.map +1 -1
  107. package/dist/getToolbarSrc.js +17 -19
  108. package/dist/getToolbarSrc.js.map +1 -1
  109. package/dist/helpers/asDate.cjs +6 -9
  110. package/dist/helpers/asDate.cjs.map +1 -1
  111. package/dist/helpers/asDate.d.cts +5 -10
  112. package/dist/helpers/asDate.d.cts.map +1 -1
  113. package/dist/helpers/asDate.d.ts +5 -10
  114. package/dist/helpers/asDate.d.ts.map +1 -1
  115. package/dist/helpers/asDate.js +6 -9
  116. package/dist/helpers/asDate.js.map +1 -1
  117. package/dist/helpers/asHTML.cjs +25 -26
  118. package/dist/helpers/asHTML.cjs.map +1 -1
  119. package/dist/helpers/asHTML.d.cts +29 -55
  120. package/dist/helpers/asHTML.d.cts.map +1 -1
  121. package/dist/helpers/asHTML.d.ts +29 -55
  122. package/dist/helpers/asHTML.d.ts.map +1 -1
  123. package/dist/helpers/asHTML.js +25 -26
  124. package/dist/helpers/asHTML.js.map +1 -1
  125. package/dist/helpers/asImagePixelDensitySrcSet.cjs +21 -27
  126. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  127. package/dist/helpers/asImagePixelDensitySrcSet.d.cts +25 -36
  128. package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
  129. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +25 -36
  130. package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
  131. package/dist/helpers/asImagePixelDensitySrcSet.js +21 -27
  132. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  133. package/dist/helpers/asImageSrc.cjs +7 -12
  134. package/dist/helpers/asImageSrc.cjs.map +1 -1
  135. package/dist/helpers/asImageSrc.d.cts +8 -15
  136. package/dist/helpers/asImageSrc.d.cts.map +1 -1
  137. package/dist/helpers/asImageSrc.d.ts +8 -15
  138. package/dist/helpers/asImageSrc.d.ts.map +1 -1
  139. package/dist/helpers/asImageSrc.js +7 -12
  140. package/dist/helpers/asImageSrc.js.map +1 -1
  141. package/dist/helpers/asImageWidthSrcSet.cjs +25 -32
  142. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  143. package/dist/helpers/asImageWidthSrcSet.d.cts +29 -41
  144. package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
  145. package/dist/helpers/asImageWidthSrcSet.d.ts +29 -41
  146. package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
  147. package/dist/helpers/asImageWidthSrcSet.js +25 -32
  148. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  149. package/dist/helpers/asLink.cjs.map +1 -1
  150. package/dist/helpers/asLink.d.cts +15 -32
  151. package/dist/helpers/asLink.d.cts.map +1 -1
  152. package/dist/helpers/asLink.d.ts +15 -32
  153. package/dist/helpers/asLink.d.ts.map +1 -1
  154. package/dist/helpers/asLink.js.map +1 -1
  155. package/dist/helpers/asLinkAttrs.cjs +8 -11
  156. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  157. package/dist/helpers/asLinkAttrs.d.cts +9 -14
  158. package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
  159. package/dist/helpers/asLinkAttrs.d.ts +9 -14
  160. package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
  161. package/dist/helpers/asLinkAttrs.js +8 -11
  162. package/dist/helpers/asLinkAttrs.js.map +1 -1
  163. package/dist/helpers/asText.cjs.map +1 -1
  164. package/dist/helpers/asText.d.cts +10 -23
  165. package/dist/helpers/asText.d.cts.map +1 -1
  166. package/dist/helpers/asText.d.ts +10 -23
  167. package/dist/helpers/asText.d.ts.map +1 -1
  168. package/dist/helpers/asText.js.map +1 -1
  169. package/dist/helpers/documentToLinkField.cjs +2 -7
  170. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  171. package/dist/helpers/documentToLinkField.d.cts +1 -5
  172. package/dist/helpers/documentToLinkField.d.cts.map +1 -1
  173. package/dist/helpers/documentToLinkField.d.ts +1 -5
  174. package/dist/helpers/documentToLinkField.d.ts.map +1 -1
  175. package/dist/helpers/documentToLinkField.js +2 -7
  176. package/dist/helpers/documentToLinkField.js.map +1 -1
  177. package/dist/helpers/isFilled.cjs +8 -35
  178. package/dist/helpers/isFilled.cjs.map +1 -1
  179. package/dist/helpers/isFilled.d.cts +8 -32
  180. package/dist/helpers/isFilled.d.cts.map +1 -1
  181. package/dist/helpers/isFilled.d.ts +8 -32
  182. package/dist/helpers/isFilled.d.ts.map +1 -1
  183. package/dist/helpers/isFilled.js +8 -35
  184. package/dist/helpers/isFilled.js.map +1 -1
  185. package/dist/helpers/mapSliceZone.cjs +8 -10
  186. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  187. package/dist/helpers/mapSliceZone.d.cts +35 -63
  188. package/dist/helpers/mapSliceZone.d.cts.map +1 -1
  189. package/dist/helpers/mapSliceZone.d.ts +35 -63
  190. package/dist/helpers/mapSliceZone.d.ts.map +1 -1
  191. package/dist/helpers/mapSliceZone.js +8 -10
  192. package/dist/helpers/mapSliceZone.js.map +1 -1
  193. package/dist/index.cjs +11 -17
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.d.cts +36 -50
  196. package/dist/index.d.cts.map +1 -1
  197. package/dist/index.d.ts +36 -50
  198. package/dist/index.d.ts.map +1 -1
  199. package/dist/index.js +11 -17
  200. package/dist/index.js.map +1 -1
  201. package/dist/isRepositoryEndpoint.cjs +3 -4
  202. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  203. package/dist/isRepositoryEndpoint.d.cts +3 -4
  204. package/dist/isRepositoryEndpoint.d.cts.map +1 -1
  205. package/dist/isRepositoryEndpoint.d.ts +3 -4
  206. package/dist/isRepositoryEndpoint.d.ts.map +1 -1
  207. package/dist/isRepositoryEndpoint.js +3 -4
  208. package/dist/isRepositoryEndpoint.js.map +1 -1
  209. package/dist/isRepositoryName.cjs +1 -2
  210. package/dist/isRepositoryName.cjs.map +1 -1
  211. package/dist/isRepositoryName.d.cts +1 -2
  212. package/dist/isRepositoryName.d.cts.map +1 -1
  213. package/dist/isRepositoryName.d.ts +1 -2
  214. package/dist/isRepositoryName.d.ts.map +1 -1
  215. package/dist/isRepositoryName.js +1 -2
  216. package/dist/isRepositoryName.js.map +1 -1
  217. package/dist/lib/devMsg.cjs +6 -8
  218. package/dist/lib/devMsg.cjs.map +1 -1
  219. package/dist/lib/devMsg.js +6 -8
  220. package/dist/lib/devMsg.js.map +1 -1
  221. package/dist/lib/getOptionalLinkProperties.cjs +5 -6
  222. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  223. package/dist/lib/getOptionalLinkProperties.js +5 -6
  224. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  225. package/dist/lib/getPreviewCookie.cjs +1 -3
  226. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  227. package/dist/lib/getPreviewCookie.js +1 -3
  228. package/dist/lib/getPreviewCookie.js.map +1 -1
  229. package/dist/lib/isInternalURL.cjs +0 -1
  230. package/dist/lib/isInternalURL.cjs.map +1 -1
  231. package/dist/lib/isInternalURL.js +0 -1
  232. package/dist/lib/isInternalURL.js.map +1 -1
  233. package/dist/lib/isMigrationValue.cjs +7 -17
  234. package/dist/lib/isMigrationValue.cjs.map +1 -1
  235. package/dist/lib/isMigrationValue.js +7 -17
  236. package/dist/lib/isMigrationValue.js.map +1 -1
  237. package/dist/lib/isValue.cjs +2 -16
  238. package/dist/lib/isValue.cjs.map +1 -1
  239. package/dist/lib/isValue.js +2 -16
  240. package/dist/lib/isValue.js.map +1 -1
  241. package/dist/lib/pLimit.cjs +5 -7
  242. package/dist/lib/pLimit.cjs.map +1 -1
  243. package/dist/lib/pLimit.js +5 -7
  244. package/dist/lib/pLimit.js.map +1 -1
  245. package/dist/lib/request.cjs +12 -23
  246. package/dist/lib/request.cjs.map +1 -1
  247. package/dist/lib/request.d.cts +7 -20
  248. package/dist/lib/request.d.cts.map +1 -1
  249. package/dist/lib/request.d.ts +7 -20
  250. package/dist/lib/request.d.ts.map +1 -1
  251. package/dist/lib/request.js +12 -23
  252. package/dist/lib/request.js.map +1 -1
  253. package/dist/lib/resolveMigrationDocumentData.cjs +7 -15
  254. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  255. package/dist/lib/resolveMigrationDocumentData.js +7 -15
  256. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  257. package/dist/lib/serializerHelpers.cjs.map +1 -1
  258. package/dist/lib/serializerHelpers.js.map +1 -1
  259. package/dist/lib/throttledWarn.cjs +3 -4
  260. package/dist/lib/throttledWarn.cjs.map +1 -1
  261. package/dist/lib/throttledWarn.js +3 -4
  262. package/dist/lib/throttledWarn.js.map +1 -1
  263. package/dist/lib/validateAssetMetadata.cjs +6 -18
  264. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  265. package/dist/lib/validateAssetMetadata.js +6 -18
  266. package/dist/lib/validateAssetMetadata.js.map +1 -1
  267. package/dist/package.cjs +1 -1
  268. package/dist/package.js +1 -1
  269. package/dist/richtext/asText.cjs +0 -2
  270. package/dist/richtext/asText.cjs.map +1 -1
  271. package/dist/richtext/asText.d.cts +0 -2
  272. package/dist/richtext/asText.d.cts.map +1 -1
  273. package/dist/richtext/asText.d.ts +0 -2
  274. package/dist/richtext/asText.d.ts.map +1 -1
  275. package/dist/richtext/asText.js +0 -2
  276. package/dist/richtext/asText.js.map +1 -1
  277. package/dist/richtext/asTree.cjs +2 -4
  278. package/dist/richtext/asTree.cjs.map +1 -1
  279. package/dist/richtext/asTree.d.cts +2 -4
  280. package/dist/richtext/asTree.d.cts.map +1 -1
  281. package/dist/richtext/asTree.d.ts +2 -4
  282. package/dist/richtext/asTree.d.ts.map +1 -1
  283. package/dist/richtext/asTree.js +2 -4
  284. package/dist/richtext/asTree.js.map +1 -1
  285. package/dist/richtext/composeSerializers.cjs +4 -7
  286. package/dist/richtext/composeSerializers.cjs.map +1 -1
  287. package/dist/richtext/composeSerializers.d.cts +4 -7
  288. package/dist/richtext/composeSerializers.d.cts.map +1 -1
  289. package/dist/richtext/composeSerializers.d.ts +4 -7
  290. package/dist/richtext/composeSerializers.d.ts.map +1 -1
  291. package/dist/richtext/composeSerializers.js +4 -7
  292. package/dist/richtext/composeSerializers.js.map +1 -1
  293. package/dist/richtext/serialize.cjs +2 -6
  294. package/dist/richtext/serialize.cjs.map +1 -1
  295. package/dist/richtext/serialize.d.cts +2 -6
  296. package/dist/richtext/serialize.d.cts.map +1 -1
  297. package/dist/richtext/serialize.d.ts +2 -6
  298. package/dist/richtext/serialize.d.ts.map +1 -1
  299. package/dist/richtext/serialize.js +2 -6
  300. package/dist/richtext/serialize.js.map +1 -1
  301. package/dist/richtext/types.cjs.map +1 -1
  302. package/dist/richtext/types.d.cts +3 -7
  303. package/dist/richtext/types.d.cts.map +1 -1
  304. package/dist/richtext/types.d.ts +3 -7
  305. package/dist/richtext/types.d.ts.map +1 -1
  306. package/dist/richtext/types.js.map +1 -1
  307. package/dist/richtext/wrapMapSerializer.cjs +2 -5
  308. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  309. package/dist/richtext/wrapMapSerializer.d.cts +2 -5
  310. package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
  311. package/dist/richtext/wrapMapSerializer.d.ts +2 -5
  312. package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
  313. package/dist/richtext/wrapMapSerializer.js +2 -5
  314. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  315. package/dist/types/api/asset/asset.d.cts +17 -70
  316. package/dist/types/api/asset/asset.d.cts.map +1 -1
  317. package/dist/types/api/asset/asset.d.ts +17 -70
  318. package/dist/types/api/asset/asset.d.ts.map +1 -1
  319. package/dist/types/api/asset/tag.d.cts +5 -23
  320. package/dist/types/api/asset/tag.d.cts.map +1 -1
  321. package/dist/types/api/asset/tag.d.ts +5 -23
  322. package/dist/types/api/asset/tag.d.ts.map +1 -1
  323. package/dist/types/api/integration.d.cts +2 -4
  324. package/dist/types/api/integration.d.cts.map +1 -1
  325. package/dist/types/api/integration.d.ts +2 -4
  326. package/dist/types/api/integration.d.ts.map +1 -1
  327. package/dist/types/api/query.d.cts +10 -27
  328. package/dist/types/api/query.d.cts.map +1 -1
  329. package/dist/types/api/query.d.ts +10 -27
  330. package/dist/types/api/query.d.ts.map +1 -1
  331. package/dist/types/api/ref.d.cts +6 -16
  332. package/dist/types/api/ref.d.cts.map +1 -1
  333. package/dist/types/api/ref.d.ts +6 -16
  334. package/dist/types/api/ref.d.ts.map +1 -1
  335. package/dist/types/api/release.d.cts +1 -2
  336. package/dist/types/api/release.d.cts.map +1 -1
  337. package/dist/types/api/release.d.ts +1 -2
  338. package/dist/types/api/release.d.ts.map +1 -1
  339. package/dist/types/api/repository.d.cts +18 -45
  340. package/dist/types/api/repository.d.cts.map +1 -1
  341. package/dist/types/api/repository.d.ts +18 -45
  342. package/dist/types/api/repository.d.ts.map +1 -1
  343. package/dist/types/api/tags.d.cts +2 -3
  344. package/dist/types/api/tags.d.cts.map +1 -1
  345. package/dist/types/api/tags.d.ts +2 -3
  346. package/dist/types/api/tags.d.ts.map +1 -1
  347. package/dist/types/migration/Asset.cjs +4 -13
  348. package/dist/types/migration/Asset.cjs.map +1 -1
  349. package/dist/types/migration/Asset.d.cts +20 -66
  350. package/dist/types/migration/Asset.d.cts.map +1 -1
  351. package/dist/types/migration/Asset.d.ts +20 -66
  352. package/dist/types/migration/Asset.d.ts.map +1 -1
  353. package/dist/types/migration/Asset.js +4 -13
  354. package/dist/types/migration/Asset.js.map +1 -1
  355. package/dist/types/migration/ContentRelationship.d.cts +1 -3
  356. package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
  357. package/dist/types/migration/ContentRelationship.d.ts +1 -3
  358. package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
  359. package/dist/types/migration/Document.cjs +10 -19
  360. package/dist/types/migration/Document.cjs.map +1 -1
  361. package/dist/types/migration/Document.d.cts +12 -31
  362. package/dist/types/migration/Document.d.cts.map +1 -1
  363. package/dist/types/migration/Document.d.ts +12 -31
  364. package/dist/types/migration/Document.d.ts.map +1 -1
  365. package/dist/types/migration/Document.js +10 -19
  366. package/dist/types/migration/Document.js.map +1 -1
  367. package/dist/types/model/contentRelationship.d.cts +5 -15
  368. package/dist/types/model/contentRelationship.d.cts.map +1 -1
  369. package/dist/types/model/contentRelationship.d.ts +5 -15
  370. package/dist/types/model/contentRelationship.d.ts.map +1 -1
  371. package/dist/types/model/customType.d.cts +6 -17
  372. package/dist/types/model/customType.d.cts.map +1 -1
  373. package/dist/types/model/customType.d.ts +6 -17
  374. package/dist/types/model/customType.d.ts.map +1 -1
  375. package/dist/types/model/image.d.cts.map +1 -1
  376. package/dist/types/model/image.d.ts.map +1 -1
  377. package/dist/types/model/linkToMedia.d.cts.map +1 -1
  378. package/dist/types/model/linkToMedia.d.ts.map +1 -1
  379. package/dist/types/model/range.d.cts +1 -3
  380. package/dist/types/model/range.d.cts.map +1 -1
  381. package/dist/types/model/range.d.ts +1 -3
  382. package/dist/types/model/range.d.ts.map +1 -1
  383. package/dist/types/model/separator.d.cts +1 -3
  384. package/dist/types/model/separator.d.cts.map +1 -1
  385. package/dist/types/model/separator.d.ts +1 -3
  386. package/dist/types/model/separator.d.ts.map +1 -1
  387. package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
  388. package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
  389. package/dist/types/model/slice.cjs.map +1 -1
  390. package/dist/types/model/slice.d.cts +1 -3
  391. package/dist/types/model/slice.d.cts.map +1 -1
  392. package/dist/types/model/slice.d.ts +1 -3
  393. package/dist/types/model/slice.d.ts.map +1 -1
  394. package/dist/types/model/slice.js.map +1 -1
  395. package/dist/types/model/sliceZone.cjs.map +1 -1
  396. package/dist/types/model/sliceZone.d.cts.map +1 -1
  397. package/dist/types/model/sliceZone.d.ts.map +1 -1
  398. package/dist/types/model/sliceZone.js.map +1 -1
  399. package/dist/types/model/types.cjs +1 -3
  400. package/dist/types/model/types.cjs.map +1 -1
  401. package/dist/types/model/types.d.cts +9 -31
  402. package/dist/types/model/types.d.cts.map +1 -1
  403. package/dist/types/model/types.d.ts +9 -31
  404. package/dist/types/model/types.d.ts.map +1 -1
  405. package/dist/types/model/types.js +1 -3
  406. package/dist/types/model/types.js.map +1 -1
  407. package/dist/types/value/color.d.cts +0 -1
  408. package/dist/types/value/color.d.cts.map +1 -1
  409. package/dist/types/value/color.d.ts +0 -1
  410. package/dist/types/value/color.d.ts.map +1 -1
  411. package/dist/types/value/contentRelationship.d.cts +3 -5
  412. package/dist/types/value/contentRelationship.d.cts.map +1 -1
  413. package/dist/types/value/contentRelationship.d.ts +3 -5
  414. package/dist/types/value/contentRelationship.d.ts.map +1 -1
  415. package/dist/types/value/date.d.cts +0 -1
  416. package/dist/types/value/date.d.cts.map +1 -1
  417. package/dist/types/value/date.d.ts +0 -1
  418. package/dist/types/value/date.d.ts.map +1 -1
  419. package/dist/types/value/document.d.cts +23 -50
  420. package/dist/types/value/document.d.cts.map +1 -1
  421. package/dist/types/value/document.d.ts +23 -50
  422. package/dist/types/value/document.d.ts.map +1 -1
  423. package/dist/types/value/embed.cjs +1 -1
  424. package/dist/types/value/embed.cjs.map +1 -1
  425. package/dist/types/value/embed.d.cts +28 -95
  426. package/dist/types/value/embed.d.cts.map +1 -1
  427. package/dist/types/value/embed.d.ts +28 -95
  428. package/dist/types/value/embed.d.ts.map +1 -1
  429. package/dist/types/value/embed.js +1 -1
  430. package/dist/types/value/embed.js.map +1 -1
  431. package/dist/types/value/geoPoint.d.cts +0 -1
  432. package/dist/types/value/geoPoint.d.cts.map +1 -1
  433. package/dist/types/value/geoPoint.d.ts +0 -1
  434. package/dist/types/value/geoPoint.d.ts.map +1 -1
  435. package/dist/types/value/group.d.cts.map +1 -1
  436. package/dist/types/value/group.d.ts.map +1 -1
  437. package/dist/types/value/image.d.cts +5 -8
  438. package/dist/types/value/image.d.cts.map +1 -1
  439. package/dist/types/value/image.d.ts +5 -8
  440. package/dist/types/value/image.d.ts.map +1 -1
  441. package/dist/types/value/integration.d.cts +0 -1
  442. package/dist/types/value/integration.d.cts.map +1 -1
  443. package/dist/types/value/integration.d.ts +0 -1
  444. package/dist/types/value/integration.d.ts.map +1 -1
  445. package/dist/types/value/keyText.d.cts +0 -1
  446. package/dist/types/value/keyText.d.cts.map +1 -1
  447. package/dist/types/value/keyText.d.ts +0 -1
  448. package/dist/types/value/keyText.d.ts.map +1 -1
  449. package/dist/types/value/link.cjs +1 -3
  450. package/dist/types/value/link.cjs.map +1 -1
  451. package/dist/types/value/link.d.cts +8 -12
  452. package/dist/types/value/link.d.cts.map +1 -1
  453. package/dist/types/value/link.d.ts +8 -12
  454. package/dist/types/value/link.d.ts.map +1 -1
  455. package/dist/types/value/link.js +1 -3
  456. package/dist/types/value/link.js.map +1 -1
  457. package/dist/types/value/linkToMedia.d.cts.map +1 -1
  458. package/dist/types/value/linkToMedia.d.ts.map +1 -1
  459. package/dist/types/value/number.d.cts +0 -1
  460. package/dist/types/value/number.d.cts.map +1 -1
  461. package/dist/types/value/number.d.ts +0 -1
  462. package/dist/types/value/number.d.ts.map +1 -1
  463. package/dist/types/value/richText.cjs.map +1 -1
  464. package/dist/types/value/richText.d.cts +26 -77
  465. package/dist/types/value/richText.d.cts.map +1 -1
  466. package/dist/types/value/richText.d.ts +26 -77
  467. package/dist/types/value/richText.d.ts.map +1 -1
  468. package/dist/types/value/richText.js.map +1 -1
  469. package/dist/types/value/select.d.cts +0 -1
  470. package/dist/types/value/select.d.cts.map +1 -1
  471. package/dist/types/value/select.d.ts +0 -1
  472. package/dist/types/value/select.d.ts.map +1 -1
  473. package/dist/types/value/sharedSliceVariation.d.cts +1 -3
  474. package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
  475. package/dist/types/value/sharedSliceVariation.d.ts +1 -3
  476. package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
  477. package/dist/types/value/slice.d.cts.map +1 -1
  478. package/dist/types/value/slice.d.ts.map +1 -1
  479. package/dist/types/value/sliceZone.d.cts +3 -4
  480. package/dist/types/value/sliceZone.d.cts.map +1 -1
  481. package/dist/types/value/sliceZone.d.ts +3 -4
  482. package/dist/types/value/sliceZone.d.ts.map +1 -1
  483. package/dist/types/value/table.d.cts +14 -63
  484. package/dist/types/value/table.d.cts.map +1 -1
  485. package/dist/types/value/table.d.ts +14 -63
  486. package/dist/types/value/table.d.ts.map +1 -1
  487. package/dist/types/value/timestamp.d.cts.map +1 -1
  488. package/dist/types/value/timestamp.d.ts.map +1 -1
  489. package/dist/types/value/title.d.cts +1 -1
  490. package/dist/types/value/title.d.cts.map +1 -1
  491. package/dist/types/value/title.d.ts +1 -1
  492. package/dist/types/value/title.d.ts.map +1 -1
  493. package/dist/types/value/types.d.cts +11 -24
  494. package/dist/types/value/types.d.cts.map +1 -1
  495. package/dist/types/value/types.d.ts +11 -24
  496. package/dist/types/value/types.d.ts.map +1 -1
  497. package/dist/types/webhook/apiUpdate.d.cts +1 -3
  498. package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
  499. package/dist/types/webhook/apiUpdate.d.ts +1 -3
  500. package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
  501. package/package.json +32 -34
  502. package/src/Client.ts +236 -399
  503. package/src/Migration.ts +80 -139
  504. package/src/WriteClient.ts +64 -174
  505. package/src/buildQueryURL.ts +68 -100
  506. package/src/cookie.ts +1 -4
  507. package/src/createClient.ts +12 -20
  508. package/src/createMigration.ts +8 -16
  509. package/src/createWriteClient.ts +11 -19
  510. package/src/errors.ts +5 -15
  511. package/src/filter.ts +79 -122
  512. package/src/getGraphQLEndpoint.ts +0 -3
  513. package/src/getRepositoryEndpoint.ts +4 -9
  514. package/src/getRepositoryName.ts +2 -5
  515. package/src/getToolbarSrc.ts +17 -20
  516. package/src/helpers/asDate.ts +13 -18
  517. package/src/helpers/asHTML.ts +55 -102
  518. package/src/helpers/asImagePixelDensitySrcSet.ts +29 -49
  519. package/src/helpers/asImageSrc.ts +8 -16
  520. package/src/helpers/asImageWidthSrcSet.ts +33 -52
  521. package/src/helpers/asLink.ts +26 -54
  522. package/src/helpers/asLinkAttrs.ts +14 -29
  523. package/src/helpers/asText.ts +15 -31
  524. package/src/helpers/documentToLinkField.ts +4 -15
  525. package/src/helpers/isFilled.ts +14 -51
  526. package/src/helpers/mapSliceZone.ts +42 -84
  527. package/src/index.ts +18 -68
  528. package/src/isRepositoryEndpoint.ts +3 -4
  529. package/src/isRepositoryName.ts +1 -2
  530. package/src/lib/devMsg.ts +6 -8
  531. package/src/lib/getOptionalLinkProperties.ts +5 -6
  532. package/src/lib/getPreviewCookie.ts +1 -3
  533. package/src/lib/isInternalURL.ts +0 -1
  534. package/src/lib/isMigrationValue.ts +9 -22
  535. package/src/lib/isValue.ts +9 -38
  536. package/src/lib/pLimit.ts +9 -16
  537. package/src/lib/request.ts +15 -40
  538. package/src/lib/resolveMigrationDocumentData.ts +8 -27
  539. package/src/lib/serializerHelpers.ts +9 -29
  540. package/src/lib/throttledWarn.ts +4 -8
  541. package/src/lib/validateAssetMetadata.ts +17 -43
  542. package/src/richtext/asText.ts +2 -8
  543. package/src/richtext/asTree.ts +8 -26
  544. package/src/richtext/composeSerializers.ts +5 -11
  545. package/src/richtext/serialize.ts +4 -12
  546. package/src/richtext/types.ts +13 -57
  547. package/src/richtext/wrapMapSerializer.ts +4 -8
  548. package/src/types/api/asset/asset.ts +26 -77
  549. package/src/types/api/asset/tag.ts +6 -18
  550. package/src/types/api/integration.ts +4 -10
  551. package/src/types/api/migration/document.ts +11 -27
  552. package/src/types/api/query.ts +10 -27
  553. package/src/types/api/ref.ts +6 -16
  554. package/src/types/api/release.ts +1 -2
  555. package/src/types/api/repository.ts +18 -45
  556. package/src/types/api/tags.ts +2 -3
  557. package/src/types/migration/Asset.ts +26 -82
  558. package/src/types/migration/ContentRelationship.ts +5 -12
  559. package/src/types/migration/Document.ts +26 -52
  560. package/src/types/migration/Link.ts +7 -9
  561. package/src/types/model/contentRelationship.ts +7 -20
  562. package/src/types/model/customType.ts +7 -21
  563. package/src/types/model/image.ts +4 -5
  564. package/src/types/model/linkToMedia.ts +1 -2
  565. package/src/types/model/range.ts +1 -3
  566. package/src/types/model/separator.ts +1 -3
  567. package/src/types/model/sharedSliceVariation.ts +4 -4
  568. package/src/types/model/slice.ts +7 -12
  569. package/src/types/model/sliceZone.ts +4 -11
  570. package/src/types/model/types.ts +10 -31
  571. package/src/types/value/color.ts +3 -3
  572. package/src/types/value/contentRelationship.ts +8 -13
  573. package/src/types/value/date.ts +1 -3
  574. package/src/types/value/document.ts +24 -52
  575. package/src/types/value/embed.ts +33 -80
  576. package/src/types/value/geoPoint.ts +6 -8
  577. package/src/types/value/group.ts +1 -4
  578. package/src/types/value/image.ts +10 -14
  579. package/src/types/value/integration.ts +0 -1
  580. package/src/types/value/keyText.ts +3 -3
  581. package/src/types/value/link.ts +14 -22
  582. package/src/types/value/linkToMedia.ts +2 -5
  583. package/src/types/value/number.ts +3 -3
  584. package/src/types/value/richText.ts +30 -82
  585. package/src/types/value/select.ts +0 -1
  586. package/src/types/value/sharedSliceVariation.ts +3 -11
  587. package/src/types/value/slice.ts +2 -8
  588. package/src/types/value/sliceZone.ts +4 -6
  589. package/src/types/value/table.ts +25 -64
  590. package/src/types/value/timestamp.ts +3 -2
  591. package/src/types/value/title.ts +16 -18
  592. package/src/types/value/types.ts +8 -21
  593. package/src/types/webhook/apiUpdate.ts +1 -3
@@ -1 +1 @@
1
- {"version":3,"file":"serializerHelpers.js","names":[],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\n\nimport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLStrictRichTextMapSerializer,\n} from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\n\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 = <\n\tBlockType extends keyof RichTextMapSerializer<string>,\n>(\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(\n\t\t\tnode,\n\t\t\tgeneralAttributes,\n\t\t)}>${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(\n\t\t\tnode.text,\n\t\t)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| 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:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| 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<\n\tHTMLStrictRichTextMapSerializer[\"span\"]\n> => {\n\treturn ({ text }): string => {\n\t\treturn text ? escapeHTML(text).replace(/\\n/g, \"<br />\") : \"\"\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,oBAAoB,MAAiB,eAAmC;CAC7E,MAAM,cAAc,EAAE,GAAG,YAAY;AAGrC,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,aAAY,MAAM,KAAK;AAIxB,KAAI,UAAU,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,MACvD,aAAY,QAAQ,YAAY,QAC7B,GAAG,YAAY,MAAM,GAAG,KAAK,KAAK,UAClC,KAAK,KAAK;CAGd,MAAM,SAAS,EAAE;AAEjB,MAAK,MAAM,OAAO,aAAa;EAC9B,MAAM,QAAQ,YAAY;AAE1B,MAAI,MACH,KAAI,OAAO,UAAU,UACpB,QAAO,KAAK,IAAI;MAEhB,QAAO,KAAK,GAAG,IAAI,IAAI,WAAW,MAAM,CAAC,GAAG;;AAM/C,KAAI,OAAO,OACV,QAAO,QAAQ,GAAG;AAGnB,QAAO,OAAO,KAAK,IAAI;;AAGxB,MAAM,wBACL,0BACgB;AAChB,QAAO,yBAAyB,OAAO,0BAA0B,aAC9D,wBACA,EAAE;;AAGN,MAAa,wBAGZ,KACA,0BAC6D;CAC7D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,UAAS,EAAE,MAAM,eAAe;AAC/B,SAAO,IAAI,MAAM,iBAChB,MACA,kBACA,CAAC,GAAG,SAAS,IAAI,IAAI;;;AAIxB,MAAa,yBACZ,0BACkE;CAClE,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,WAAW;AACpB,SAAO,OAAO,iBAAiB,MAAM,kBAAkB,CAAC,GAAG,WAC1D,KAAK,KACL,CAAC;;;AAIJ,MAAa,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,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,YAAY;AAGrC,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,aAAY,MAAM,KAAK;AAIxB,KAAI,UAAU,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,MACvD,aAAY,QAAQ,YAAY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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"}
@@ -3,10 +3,9 @@ const THROTTLE_THRESHOLD_MS = 5e3;
3
3
  let lastMessage;
4
4
  let lastCalledAt = 0;
5
5
  /**
6
- * Logs a warning. If the message is identical the immediate previous logged
7
- * message and that message was logged within 5 seconds of the current call, the
8
- * log is ignored. This throttle behavior prevents identical messages from
9
- * flooding the console.
6
+ * Logs a warning. If the message is identical the immediate previous logged message and that
7
+ * message was logged within 5 seconds of the current call, the log is ignored. This throttle
8
+ * behavior prevents identical messages from flooding the console.
10
9
  *
11
10
  * @param message - A message to log.
12
11
  * @param config - Configuration for the log.
@@ -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\n * message and that message was logged within 5 seconds of the current call, the\n * log is ignored. This throttle behavior prevents identical messages from\n * 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 (\n\t\tmessage === lastMessage &&\n\t\tDate.now() - lastCalledAt < THROTTLE_THRESHOLD_MS\n\t) {\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;;;;;;;;;;AAWnB,MAAa,iBAAiB,YAA0B;AACvD,KACC,YAAY,eACZ,KAAK,KAAK,GAAG,eAAe,uBAC3B;AACD,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;AACvD,KAAI,YAAY,eAAe,KAAK,KAAK,GAAG,eAAe,uBAAuB;AACjF,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
@@ -3,10 +3,9 @@ const THROTTLE_THRESHOLD_MS = 5e3;
3
3
  let lastMessage;
4
4
  let lastCalledAt = 0;
5
5
  /**
6
- * Logs a warning. If the message is identical the immediate previous logged
7
- * message and that message was logged within 5 seconds of the current call, the
8
- * log is ignored. This throttle behavior prevents identical messages from
9
- * flooding the console.
6
+ * Logs a warning. If the message is identical the immediate previous logged message and that
7
+ * message was logged within 5 seconds of the current call, the log is ignored. This throttle
8
+ * behavior prevents identical messages from flooding the console.
10
9
  *
11
10
  * @param message - A message to log.
12
11
  * @param config - Configuration for the log.
@@ -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\n * message and that message was logged within 5 seconds of the current call, the\n * log is ignored. This throttle behavior prevents identical messages from\n * 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 (\n\t\tmessage === lastMessage &&\n\t\tDate.now() - lastCalledAt < THROTTLE_THRESHOLD_MS\n\t) {\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;;;;;;;;;;AAWnB,MAAa,iBAAiB,YAA0B;AACvD,KACC,YAAY,eACZ,KAAK,KAAK,GAAG,eAAe,uBAC3B;AACD,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;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,31 +1,19 @@
1
1
  const require_errors = require("../errors.cjs");
2
2
  //#region src/lib/validateAssetMetadata.ts
3
- /**
4
- * Max length for asset notes accepted by the API.
5
- */
3
+ /** Max length for asset notes accepted by the API. */
6
4
  const ASSET_NOTES_MAX_LENGTH = 500;
7
- /**
8
- * Max length for asset credits accepted by the API.
9
- */
5
+ /** Max length for asset credits accepted by the API. */
10
6
  const ASSET_CREDITS_MAX_LENGTH = 500;
11
- /**
12
- * Max length for asset alt text accepted by the API.
13
- */
7
+ /** Max length for asset alt text accepted by the API. */
14
8
  const ASSET_ALT_MAX_LENGTH = 500;
15
- /**
16
- * Min length for asset tags accepted by the API.
17
- */
9
+ /** Min length for asset tags accepted by the API. */
18
10
  const ASSET_TAG_MIN_LENGTH = 3;
19
- /**
20
- * Max length for asset tags accepted by the API.
21
- */
11
+ /** Max length for asset tags accepted by the API. */
22
12
  const ASSET_TAG_MAX_LENGTH = 20;
23
13
  /**
24
- * Validates an asset's metadata, throwing an error if any of the metadata are
25
- * invalid.
14
+ * Validates an asset's metadata, throwing an error if any of the metadata are invalid.
26
15
  *
27
16
  * @param assetMetadata - The asset metadata to validate.
28
- *
29
17
  * @internal
30
18
  */
31
19
  const validateAssetMetadata = ({ notes, credits, alt, tags }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"validateAssetMetadata.cjs","names":["PrismicError"],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\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(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"mappings":";;;;;AAOA,MAAM,yBAAyB;;;;AAK/B,MAAM,2BAA2B;;;;AAKjC,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;;;;;AAU7B,MAAa,yBAAyB,EACrC,OACA,SACA,KACA,WAC8B;CAC9B,MAAM,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KACN,6BAA6B,uBAAuB,aACpD;AAGF,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KACN,+BAA+B,yBAAyB,aACxD;AAGF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MACH,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBACnD,CAED,QAAO,KACN,oEACA;AAGF,KAAI,OAAO,OACV,OAAM,IAAIA,eAAAA,aACT,qCAAqC,OAAO,KAAK,KAAK,IACtD,KAAA,GACA;EAAE;EAAO;EAAS;EAAK;EAAM,CAC7B"}
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,31 +1,19 @@
1
1
  import { PrismicError } from "../errors.js";
2
2
  //#region src/lib/validateAssetMetadata.ts
3
- /**
4
- * Max length for asset notes accepted by the API.
5
- */
3
+ /** Max length for asset notes accepted by the API. */
6
4
  const ASSET_NOTES_MAX_LENGTH = 500;
7
- /**
8
- * Max length for asset credits accepted by the API.
9
- */
5
+ /** Max length for asset credits accepted by the API. */
10
6
  const ASSET_CREDITS_MAX_LENGTH = 500;
11
- /**
12
- * Max length for asset alt text accepted by the API.
13
- */
7
+ /** Max length for asset alt text accepted by the API. */
14
8
  const ASSET_ALT_MAX_LENGTH = 500;
15
- /**
16
- * Min length for asset tags accepted by the API.
17
- */
9
+ /** Min length for asset tags accepted by the API. */
18
10
  const ASSET_TAG_MIN_LENGTH = 3;
19
- /**
20
- * Max length for asset tags accepted by the API.
21
- */
11
+ /** Max length for asset tags accepted by the API. */
22
12
  const ASSET_TAG_MAX_LENGTH = 20;
23
13
  /**
24
- * Validates an asset's metadata, throwing an error if any of the metadata are
25
- * invalid.
14
+ * Validates an asset's metadata, throwing an error if any of the metadata are invalid.
26
15
  *
27
16
  * @param assetMetadata - The asset metadata to validate.
28
- *
29
17
  * @internal
30
18
  */
31
19
  const validateAssetMetadata = ({ notes, credits, alt, tags }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"validateAssetMetadata.js","names":[],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\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(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"mappings":";;;;;AAOA,MAAM,yBAAyB;;;;AAK/B,MAAM,2BAA2B;;;;AAKjC,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;;;;;AAU7B,MAAa,yBAAyB,EACrC,OACA,SACA,KACA,WAC8B;CAC9B,MAAM,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KACN,6BAA6B,uBAAuB,aACpD;AAGF,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KACN,+BAA+B,yBAAyB,aACxD;AAGF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MACH,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBACnD,CAED,QAAO,KACN,oEACA;AAGF,KAAI,OAAO,OACV,OAAM,IAAI,aACT,qCAAqC,OAAO,KAAK,KAAK,IACtD,KAAA,GACA;EAAE;EAAO;EAAS;EAAK;EAAM,CAC7B"}
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"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.21.7";
3
+ var version = "7.21.8";
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.21.7";
3
+ var version = "7.21.8";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -4,9 +4,7 @@
4
4
  *
5
5
  * @param richTextField - A rich text field from Prismic.
6
6
  * @param separator - Separator used to join each element. Defaults to a space.
7
- *
8
7
  * @returns Plain text equivalent of the rich text field.
9
- *
10
8
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
11
9
  */
12
10
  const asText = (richTextField, separator = " ") => {
@@ -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 *\n * @returns Plain text equivalent of the rich text field.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (\n\trichTextField: RichTextField,\n\tseparator = \" \",\n): 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 +=\n\t\t\t\t(result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UACZ,eACA,YAAY,QACA;CACZ,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YACE,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIhE,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;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YAAW,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIzE,QAAO"}
@@ -6,9 +6,7 @@ import { RichTextField } from "../types/value/richText.cjs";
6
6
  *
7
7
  * @param richTextField - A rich text field from Prismic.
8
8
  * @param separator - Separator used to join each element. Defaults to a space.
9
- *
10
9
  * @returns Plain text equivalent of the rich text field.
11
- *
12
10
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
13
11
  */
14
12
  declare const asText: (richTextField: RichTextField, separator?: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAYA;;;;;;;;cAAa,MAAA,GACZ,aAAA,EAAe,aAAA,EACf,SAAA"}
1
+ {"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAUA;;;;;;cAAa,MAAA,GAAU,aAAA,EAAe,aAAA,EAAe,SAAA"}
@@ -6,9 +6,7 @@ import { RichTextField } from "../types/value/richText.js";
6
6
  *
7
7
  * @param richTextField - A rich text field from Prismic.
8
8
  * @param separator - Separator used to join each element. Defaults to a space.
9
- *
10
9
  * @returns Plain text equivalent of the rich text field.
11
- *
12
10
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
13
11
  */
14
12
  declare const asText: (richTextField: RichTextField, separator?: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAYA;;;;;;;;cAAa,MAAA,GACZ,aAAA,EAAe,aAAA,EACf,SAAA"}
1
+ {"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAUA;;;;;;cAAa,MAAA,GAAU,aAAA,EAAe,aAAA,EAAe,SAAA"}
@@ -4,9 +4,7 @@
4
4
  *
5
5
  * @param richTextField - A rich text field from Prismic.
6
6
  * @param separator - Separator used to join each element. Defaults to a space.
7
- *
8
7
  * @returns Plain text equivalent of the rich text field.
9
- *
10
8
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
11
9
  */
12
10
  const asText = (richTextField, separator = " ") => {
@@ -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 *\n * @returns Plain text equivalent of the rich text field.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (\n\trichTextField: RichTextField,\n\tseparator = \" \",\n): 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 +=\n\t\t\t\t(result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UACZ,eACA,YAAY,QACA;CACZ,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YACE,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIhE,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;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YAAW,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIzE,QAAO"}
@@ -8,11 +8,9 @@ uuid.i = 0;
8
8
  * Parses a rich text or title field into a tree
9
9
  *
10
10
  * @remarks
11
- * This is a low level helper mainly intended to be used by higher level
12
- * packages. Most users aren't expected to this function directly.
13
- *
11
+ * This is a low level helper mainly intended to be used by higher level packages. Most users
12
+ * aren't expected to this function directly.
14
13
  * @param nodes - A rich text or title field from Prismic
15
- *
16
14
  * @returns Tree from given rich text or title field
17
15
  */
18
16
  const asTree = (nodes) => {
@@ -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\n * packages. Most users aren't expected to this function directly.\n *\n * @param nodes - A rich text or title field from Prismic\n *\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 = (\n\tnode: RTAnyNode,\n\tchildren: TreeNode[] = [],\n): 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 (\n\t\t\tnode.type === RichTextNodeType.listItem ||\n\t\t\tnode.type === RichTextNodeType.oListItem\n\t\t) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [\n\t\t\t\tnode as RTListItemNode | RTOListItemNode,\n\t\t\t]\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(\n\t\t\tnode,\n\t\t\ttextNodeSpansToTreeNodeChildren(node.spans, node),\n\t\t)\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 (\n\t\t\t\t\tsiblingSpan.start < span.end &&\n\t\t\t\t\tsiblingSpan.end > span.start\n\t\t\t\t) {\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]\n\t\t\t\t\t\t\t? mutSpans[i + 1].start - parentSpanStart\n\t\t\t\t\t\t\t: 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;;;;;;;;;;;;AAaT,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,kBACL,MACA,WAAuB,EAAE,KACX;AACd,QAAO;EACN,KAAK,MAAM;EACX,MAAM,KAAK;EACX,MAAM,UAAU,OAAO,KAAK,OAAO,KAAA;EACnC;EACA;EACA;;AAGF,MAAM,sBAAsB,SAA2B;AACtD,QAAO,eAAe;EACrB,MAAMA,iBAAAA,iBAAiB;EACvB;EACA,OAAO,EAAE;EACT,CAAC;;AAGH,MAAM,gBAAgB,UAAmC;CACxD,MAAM,WAA0B,MAAM,MAAM,EAAE;AAE9C,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACzC,MAAM,OAAO,SAAS;AAEtB,MACC,KAAK,SAASA,iBAAAA,iBAAiB,YAC/B,KAAK,SAASA,iBAAAA,iBA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AAM,cAAc,SAAS;AAE7B,OAAI,gBAAgB;QACf,YAAY,SAAS,KAAK,SAAS,YAAY,OAAO,KAAK,KAAK;AACnE,gBAAW,KAAK,YAAY;AAC5B,cAAS,OAAO,GAAG,EAAE;AACrB;eAEA,YAAY,QAAQ,KAAK,OACzB,YAAY,MAAM,KAAK,OACtB;AACD,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,KACV,SAAS,IAAI,GAAG,QAAQ,kBACxB,KAAA,EACH,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;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,UAAU,OAAO,KAAK,OAAO,KAAA;EACnC;EACA;EACA;;AAGF,MAAM,sBAAsB,SAA2B;AACtD,QAAO,eAAe;EACrB,MAAMA,iBAAAA,iBAAiB;EACvB;EACA,OAAO,EAAE;EACT,CAAC;;AAGH,MAAM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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"}
@@ -6,11 +6,9 @@ import { Tree } from "./types.cjs";
6
6
  * Parses a rich text or title field into a tree
7
7
  *
8
8
  * @remarks
9
- * This is a low level helper mainly intended to be used by higher level
10
- * packages. Most users aren't expected to this function directly.
11
- *
9
+ * This is a low level helper mainly intended to be used by higher level packages. Most users
10
+ * aren't expected to this function directly.
12
11
  * @param nodes - A rich text or title field from Prismic
13
- *
14
12
  * @returns Tree from given rich text or title field
15
13
  */
16
14
  declare const asTree: (nodes: RTNode[]) => Tree;
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.d.cts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;AA4BA;;;;;;;;;cAAa,MAAA,GAAU,KAAA,EAAO,MAAA,OAAW,IAAA"}
1
+ {"version":3,"file":"asTree.d.cts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;AA0BA;;;;;;;cAAa,MAAA,GAAU,KAAA,EAAO,MAAA,OAAW,IAAA"}
@@ -6,11 +6,9 @@ import { Tree } from "./types.js";
6
6
  * Parses a rich text or title field into a tree
7
7
  *
8
8
  * @remarks
9
- * This is a low level helper mainly intended to be used by higher level
10
- * packages. Most users aren't expected to this function directly.
11
- *
9
+ * This is a low level helper mainly intended to be used by higher level packages. Most users
10
+ * aren't expected to this function directly.
12
11
  * @param nodes - A rich text or title field from Prismic
13
- *
14
12
  * @returns Tree from given rich text or title field
15
13
  */
16
14
  declare const asTree: (nodes: RTNode[]) => Tree;
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.d.ts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;AA4BA;;;;;;;;;cAAa,MAAA,GAAU,KAAA,EAAO,MAAA,OAAW,IAAA"}
1
+ {"version":3,"file":"asTree.d.ts","names":[],"sources":["../../src/richtext/asTree.ts"],"mappings":";;;;;;AA0BA;;;;;;;cAAa,MAAA,GAAU,KAAA,EAAO,MAAA,OAAW,IAAA"}
@@ -8,11 +8,9 @@ uuid.i = 0;
8
8
  * Parses a rich text or title field into a tree
9
9
  *
10
10
  * @remarks
11
- * This is a low level helper mainly intended to be used by higher level
12
- * packages. Most users aren't expected to this function directly.
13
- *
11
+ * This is a low level helper mainly intended to be used by higher level packages. Most users
12
+ * aren't expected to this function directly.
14
13
  * @param nodes - A rich text or title field from Prismic
15
- *
16
14
  * @returns Tree from given rich text or title field
17
15
  */
18
16
  const asTree = (nodes) => {
@@ -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\n * packages. Most users aren't expected to this function directly.\n *\n * @param nodes - A rich text or title field from Prismic\n *\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 = (\n\tnode: RTAnyNode,\n\tchildren: TreeNode[] = [],\n): 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 (\n\t\t\tnode.type === RichTextNodeType.listItem ||\n\t\t\tnode.type === RichTextNodeType.oListItem\n\t\t) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [\n\t\t\t\tnode as RTListItemNode | RTOListItemNode,\n\t\t\t]\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(\n\t\t\tnode,\n\t\t\ttextNodeSpansToTreeNodeChildren(node.spans, node),\n\t\t)\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 (\n\t\t\t\t\tsiblingSpan.start < span.end &&\n\t\t\t\t\tsiblingSpan.end > span.start\n\t\t\t\t) {\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]\n\t\t\t\t\t\t\t? mutSpans[i + 1].start - parentSpanStart\n\t\t\t\t\t\t\t: undefined,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GjE,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,KACV,SAAS,IAAI,GAAG,QAAQ,kBACxB,KAAA,EACH,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(\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,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,16 +1,13 @@
1
1
  //#region src/richtext/composeSerializers.ts
2
2
  /**
3
- * Takes an array of serializers and returns a serializer applying provided
4
- * serializers sequentially until a result is returned
3
+ * Takes an array of serializers and returns a serializer applying provided serializers sequentially
4
+ * until a result is returned
5
5
  *
6
6
  * @remarks
7
- * This is a low level helper mainly intended to be used by higher level
8
- * packages Most users aren't expected to this function directly
9
- *
7
+ * This is a low level helper mainly intended to be used by higher level packages Most users
8
+ * aren't expected to this function directly
10
9
  * @typeParam SerializerReturnType - Return type of serializers
11
- *
12
10
  * @param serializers - Serializers to compose
13
- *
14
11
  * @returns Composed serializer
15
12
  */
16
13
  const composeSerializers = (...serializers) => {
@@ -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\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\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":";;;;;;;;;;;;;;;AAgBA,MAAa,sBACZ,GAAG,gBAImD;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;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"}
@@ -2,17 +2,14 @@ import { RichTextFunctionSerializer } from "./types.cjs";
2
2
 
3
3
  //#region src/richtext/composeSerializers.d.ts
4
4
  /**
5
- * Takes an array of serializers and returns a serializer applying provided
6
- * serializers sequentially until a result is returned
5
+ * Takes an array of serializers and returns a serializer applying provided serializers sequentially
6
+ * until a result is returned
7
7
  *
8
8
  * @remarks
9
- * This is a low level helper mainly intended to be used by higher level
10
- * packages Most users aren't expected to this function directly
11
- *
9
+ * This is a low level helper mainly intended to be used by higher level packages Most users
10
+ * aren't expected to this function directly
12
11
  * @typeParam SerializerReturnType - Return type of serializers
13
- *
14
12
  * @param serializers - Serializers to compose
15
- *
16
13
  * @returns Composed serializer
17
14
  */
18
15
  declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.d.cts","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"mappings":";;;;;AAgBA;;;;;;;;;;;;cAAa,kBAAA,4BACT,WAAA,GACA,0BAAA,CAA2B,oBAAA,qBAG5B,0BAAA,CAA2B,oBAAA"}
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"}
@@ -2,17 +2,14 @@ import { RichTextFunctionSerializer } from "./types.js";
2
2
 
3
3
  //#region src/richtext/composeSerializers.d.ts
4
4
  /**
5
- * Takes an array of serializers and returns a serializer applying provided
6
- * serializers sequentially until a result is returned
5
+ * Takes an array of serializers and returns a serializer applying provided serializers sequentially
6
+ * until a result is returned
7
7
  *
8
8
  * @remarks
9
- * This is a low level helper mainly intended to be used by higher level
10
- * packages Most users aren't expected to this function directly
11
- *
9
+ * This is a low level helper mainly intended to be used by higher level packages Most users
10
+ * aren't expected to this function directly
12
11
  * @typeParam SerializerReturnType - Return type of serializers
13
- *
14
12
  * @param serializers - Serializers to compose
15
- *
16
13
  * @returns Composed serializer
17
14
  */
18
15
  declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.d.ts","names":[],"sources":["../../src/richtext/composeSerializers.ts"],"mappings":";;;;;AAgBA;;;;;;;;;;;;cAAa,kBAAA,4BACT,WAAA,GACA,0BAAA,CAA2B,oBAAA,qBAG5B,0BAAA,CAA2B,oBAAA"}
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,16 +1,13 @@
1
1
  //#region src/richtext/composeSerializers.ts
2
2
  /**
3
- * Takes an array of serializers and returns a serializer applying provided
4
- * serializers sequentially until a result is returned
3
+ * Takes an array of serializers and returns a serializer applying provided serializers sequentially
4
+ * until a result is returned
5
5
  *
6
6
  * @remarks
7
- * This is a low level helper mainly intended to be used by higher level
8
- * packages Most users aren't expected to this function directly
9
- *
7
+ * This is a low level helper mainly intended to be used by higher level packages Most users
8
+ * aren't expected to this function directly
10
9
  * @typeParam SerializerReturnType - Return type of serializers
11
- *
12
10
  * @param serializers - Serializers to compose
13
- *
14
11
  * @returns Composed serializer
15
12
  */
16
13
  const composeSerializers = (...serializers) => {
@@ -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\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\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":";;;;;;;;;;;;;;;AAgBA,MAAa,sBACZ,GAAG,gBAImD;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;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"}
@@ -4,16 +4,12 @@ const require_asTree = require("./asTree.cjs");
4
4
  * Serializes a rich text field with a given serializer.
5
5
  *
6
6
  * @remarks
7
- * This is a low-level helper mainly intended to be used by higher-level
8
- * packages. Most users aren't expected to use this function directly.
9
- *
7
+ * This is a low-level helper mainly intended to be used by higher-level packages. Most users
8
+ * aren't expected to use this function directly.
10
9
  * @typeParam SerializerReturnType - Return type of the serializer.
11
- *
12
10
  * @param richTextField - A rich text field from Prismic.
13
11
  * @param serializer - A function serializer to apply.
14
- *
15
12
  * @returns An array of serialized nodes.
16
- *
17
13
  * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
18
14
  */
19
15
  const serialize = (richTextField, serializer) => {