@prismicio/client 7.20.2-alpha.0 → 7.20.3

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 (276) hide show
  1. package/dist/Client.cjs +120 -132
  2. package/dist/Client.cjs.map +1 -1
  3. package/dist/Client.d.ts +7 -7
  4. package/dist/Client.js +120 -132
  5. package/dist/Client.js.map +1 -1
  6. package/dist/Migration.cjs +83 -101
  7. package/dist/Migration.cjs.map +1 -1
  8. package/dist/Migration.d.ts +9 -9
  9. package/dist/Migration.js +83 -101
  10. package/dist/Migration.js.map +1 -1
  11. package/dist/WriteClient.cjs +115 -92
  12. package/dist/WriteClient.cjs.map +1 -1
  13. package/dist/WriteClient.d.ts +6 -6
  14. package/dist/WriteClient.js +115 -92
  15. package/dist/WriteClient.js.map +1 -1
  16. package/dist/buildQueryURL.cjs.map +1 -1
  17. package/dist/buildQueryURL.d.ts +29 -21
  18. package/dist/buildQueryURL.js.map +1 -1
  19. package/dist/createClient.cjs.map +1 -1
  20. package/dist/createClient.d.ts +13 -10
  21. package/dist/createClient.js.map +1 -1
  22. package/dist/createMigration.cjs.map +1 -1
  23. package/dist/createMigration.d.ts +2 -2
  24. package/dist/createMigration.js.map +1 -1
  25. package/dist/createWriteClient.cjs.map +1 -1
  26. package/dist/createWriteClient.d.ts +2 -2
  27. package/dist/errors/ForbiddenError.d.ts +1 -1
  28. package/dist/errors/InvalidDataError.d.ts +1 -1
  29. package/dist/errors/NotFoundError.d.ts +1 -1
  30. package/dist/errors/ParsingError.d.ts +1 -1
  31. package/dist/errors/PreviewTokenExpired.d.ts +1 -1
  32. package/dist/errors/PrismicError.cjs +2 -5
  33. package/dist/errors/PrismicError.cjs.map +1 -1
  34. package/dist/errors/PrismicError.js +2 -5
  35. package/dist/errors/PrismicError.js.map +1 -1
  36. package/dist/errors/RefExpiredError.d.ts +1 -1
  37. package/dist/errors/RefNotFoundError.d.ts +1 -1
  38. package/dist/errors/RepositoryNotFoundError.d.ts +1 -1
  39. package/dist/filter.cjs.map +1 -1
  40. package/dist/filter.js.map +1 -1
  41. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  42. package/dist/getGraphQLEndpoint.js.map +1 -1
  43. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  44. package/dist/getRepositoryEndpoint.d.ts +9 -2
  45. package/dist/getRepositoryEndpoint.js.map +1 -1
  46. package/dist/getRepositoryName.cjs.map +1 -1
  47. package/dist/getRepositoryName.js.map +1 -1
  48. package/dist/getToolbarSrc.cjs.map +1 -1
  49. package/dist/getToolbarSrc.js.map +1 -1
  50. package/dist/helpers/asDate.cjs.map +1 -1
  51. package/dist/helpers/asDate.d.ts +13 -6
  52. package/dist/helpers/asDate.js.map +1 -1
  53. package/dist/helpers/asHTML.cjs +22 -22
  54. package/dist/helpers/asHTML.cjs.map +1 -1
  55. package/dist/helpers/asHTML.d.ts +37 -29
  56. package/dist/helpers/asHTML.js +22 -22
  57. package/dist/helpers/asHTML.js.map +1 -1
  58. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  59. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +17 -16
  60. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  61. package/dist/helpers/asImageSrc.cjs.map +1 -1
  62. package/dist/helpers/asImageSrc.d.ts +12 -11
  63. package/dist/helpers/asImageSrc.js.map +1 -1
  64. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  65. package/dist/helpers/asImageWidthSrcSet.d.ts +19 -18
  66. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  67. package/dist/helpers/asLink.cjs.map +1 -1
  68. package/dist/helpers/asLink.d.ts +36 -35
  69. package/dist/helpers/asLink.js.map +1 -1
  70. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  71. package/dist/helpers/asLinkAttrs.d.ts +11 -14
  72. package/dist/helpers/asLinkAttrs.js.map +1 -1
  73. package/dist/helpers/asText.cjs.map +1 -1
  74. package/dist/helpers/asText.d.ts +21 -11
  75. package/dist/helpers/asText.js.map +1 -1
  76. package/dist/helpers/documentToLinkField.cjs +1 -2
  77. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  78. package/dist/helpers/documentToLinkField.d.ts +2 -2
  79. package/dist/helpers/documentToLinkField.js +1 -2
  80. package/dist/helpers/documentToLinkField.js.map +1 -1
  81. package/dist/helpers/isFilled.cjs +1 -1
  82. package/dist/helpers/isFilled.cjs.map +1 -1
  83. package/dist/helpers/isFilled.d.ts +35 -34
  84. package/dist/helpers/isFilled.js +1 -1
  85. package/dist/helpers/isFilled.js.map +1 -1
  86. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  87. package/dist/helpers/mapSliceZone.d.ts +11 -11
  88. package/dist/helpers/mapSliceZone.js.map +1 -1
  89. package/dist/index.cjs.map +1 -1
  90. package/dist/index.d.ts +120 -120
  91. package/dist/index.js.map +1 -1
  92. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  93. package/dist/isRepositoryEndpoint.d.ts +2 -2
  94. package/dist/isRepositoryEndpoint.js.map +1 -1
  95. package/dist/isRepositoryName.cjs.map +1 -1
  96. package/dist/isRepositoryName.js.map +1 -1
  97. package/dist/lib/appendFilters.cjs.map +1 -1
  98. package/dist/lib/appendFilters.js.map +1 -1
  99. package/dist/lib/castArray.cjs.map +1 -1
  100. package/dist/lib/castArray.js.map +1 -1
  101. package/dist/lib/castThunk.cjs.map +1 -1
  102. package/dist/lib/castThunk.js.map +1 -1
  103. package/dist/lib/devMsg.cjs.map +1 -1
  104. package/dist/lib/devMsg.js.map +1 -1
  105. package/dist/lib/escapeHTML.cjs.map +1 -1
  106. package/dist/lib/escapeHTML.js.map +1 -1
  107. package/dist/lib/everyTagFilter.cjs.map +1 -1
  108. package/dist/lib/everyTagFilter.js.map +1 -1
  109. package/dist/lib/findMasterRef.cjs.map +1 -1
  110. package/dist/lib/findMasterRef.d.ts +1 -1
  111. package/dist/lib/findMasterRef.js.map +1 -1
  112. package/dist/lib/findRef.cjs.map +1 -1
  113. package/dist/lib/findRef.d.ts +1 -1
  114. package/dist/lib/findRef.js.map +1 -1
  115. package/dist/lib/findRefByID.cjs.map +1 -1
  116. package/dist/lib/findRefByID.d.ts +1 -1
  117. package/dist/lib/findRefByID.js.map +1 -1
  118. package/dist/lib/findRefByLabel.cjs.map +1 -1
  119. package/dist/lib/findRefByLabel.d.ts +1 -1
  120. package/dist/lib/findRefByLabel.js.map +1 -1
  121. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  122. package/dist/lib/getOptionalLinkProperties.d.ts +1 -1
  123. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  124. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  125. package/dist/lib/getPreviewCookie.js.map +1 -1
  126. package/dist/lib/isInternalURL.cjs.map +1 -1
  127. package/dist/lib/isInternalURL.js.map +1 -1
  128. package/dist/lib/isMigrationValue.cjs.map +1 -1
  129. package/dist/lib/isMigrationValue.d.ts +8 -8
  130. package/dist/lib/isMigrationValue.js.map +1 -1
  131. package/dist/lib/isValue.cjs.map +1 -1
  132. package/dist/lib/isValue.d.ts +10 -10
  133. package/dist/lib/isValue.js.map +1 -1
  134. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  135. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  136. package/dist/lib/pLimit.cjs +3 -4
  137. package/dist/lib/pLimit.cjs.map +1 -1
  138. package/dist/lib/pLimit.js +3 -4
  139. package/dist/lib/pLimit.js.map +1 -1
  140. package/dist/lib/request.cjs +8 -10
  141. package/dist/lib/request.cjs.map +1 -1
  142. package/dist/lib/request.js +8 -10
  143. package/dist/lib/request.js.map +1 -1
  144. package/dist/lib/resolveMigrationDocumentData.cjs +4 -6
  145. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  146. package/dist/lib/resolveMigrationDocumentData.d.ts +8 -8
  147. package/dist/lib/resolveMigrationDocumentData.js +4 -6
  148. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  149. package/dist/lib/serializerHelpers.cjs +2 -2
  150. package/dist/lib/serializerHelpers.cjs.map +1 -1
  151. package/dist/lib/serializerHelpers.d.ts +3 -3
  152. package/dist/lib/serializerHelpers.js +2 -2
  153. package/dist/lib/serializerHelpers.js.map +1 -1
  154. package/dist/lib/someTagsFilter.cjs.map +1 -1
  155. package/dist/lib/someTagsFilter.js.map +1 -1
  156. package/dist/lib/throttledLog.cjs.map +1 -1
  157. package/dist/lib/throttledLog.js.map +1 -1
  158. package/dist/lib/typeFilter.cjs.map +1 -1
  159. package/dist/lib/typeFilter.js.map +1 -1
  160. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  161. package/dist/lib/validateAssetMetadata.d.ts +1 -1
  162. package/dist/lib/validateAssetMetadata.js.map +1 -1
  163. package/dist/package.json.cjs +1 -1
  164. package/dist/package.json.js +1 -1
  165. package/dist/richtext/asText.cjs.map +1 -1
  166. package/dist/richtext/asText.d.ts +6 -6
  167. package/dist/richtext/asText.js.map +1 -1
  168. package/dist/richtext/asTree.cjs.map +1 -1
  169. package/dist/richtext/asTree.d.ts +2 -2
  170. package/dist/richtext/asTree.js.map +1 -1
  171. package/dist/richtext/composeSerializers.cjs.map +1 -1
  172. package/dist/richtext/composeSerializers.d.ts +1 -1
  173. package/dist/richtext/composeSerializers.js.map +1 -1
  174. package/dist/richtext/index.d.ts +7 -7
  175. package/dist/richtext/serialize.cjs.map +1 -1
  176. package/dist/richtext/serialize.d.ts +10 -10
  177. package/dist/richtext/serialize.js.map +1 -1
  178. package/dist/richtext/types.cjs.map +1 -1
  179. package/dist/richtext/types.d.ts +7 -7
  180. package/dist/richtext/types.js.map +1 -1
  181. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  182. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  183. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  184. package/dist/types/api/asset/asset.d.ts +1 -1
  185. package/dist/types/api/integration.d.ts +1 -1
  186. package/dist/types/api/migration/document.d.ts +1 -1
  187. package/dist/types/api/query.d.ts +1 -1
  188. package/dist/types/api/release.d.ts +1 -1
  189. package/dist/types/api/repository.d.ts +1 -1
  190. package/dist/types/migration/Asset.cjs +12 -15
  191. package/dist/types/migration/Asset.cjs.map +1 -1
  192. package/dist/types/migration/Asset.d.ts +7 -7
  193. package/dist/types/migration/Asset.js +12 -15
  194. package/dist/types/migration/Asset.js.map +1 -1
  195. package/dist/types/migration/ContentRelationship.d.ts +3 -3
  196. package/dist/types/migration/Document.cjs +24 -27
  197. package/dist/types/migration/Document.cjs.map +1 -1
  198. package/dist/types/migration/Document.d.ts +9 -9
  199. package/dist/types/migration/Document.js +24 -27
  200. package/dist/types/migration/Document.js.map +1 -1
  201. package/dist/types/migration/Link.d.ts +1 -1
  202. package/dist/types/model/boolean.d.ts +1 -1
  203. package/dist/types/model/color.d.ts +1 -1
  204. package/dist/types/model/contentRelationship.d.ts +3 -2
  205. package/dist/types/model/customType.d.ts +1 -1
  206. package/dist/types/model/date.d.ts +1 -1
  207. package/dist/types/model/embed.d.ts +1 -1
  208. package/dist/types/model/geoPoint.d.ts +1 -1
  209. package/dist/types/model/group.d.ts +1 -1
  210. package/dist/types/model/image.d.ts +1 -1
  211. package/dist/types/model/integration.d.ts +1 -1
  212. package/dist/types/model/keyText.d.ts +1 -1
  213. package/dist/types/model/link.d.ts +1 -1
  214. package/dist/types/model/linkToMedia.d.ts +2 -2
  215. package/dist/types/model/number.d.ts +1 -1
  216. package/dist/types/model/range.d.ts +1 -1
  217. package/dist/types/model/richText.d.ts +1 -1
  218. package/dist/types/model/select.d.ts +1 -1
  219. package/dist/types/model/separator.d.ts +1 -1
  220. package/dist/types/model/sharedSlice.d.ts +2 -2
  221. package/dist/types/model/sharedSliceVariation.d.ts +1 -1
  222. package/dist/types/model/slice.d.ts +3 -3
  223. package/dist/types/model/sliceZone.d.ts +2 -2
  224. package/dist/types/model/table.d.ts +1 -1
  225. package/dist/types/model/timestamp.d.ts +1 -1
  226. package/dist/types/model/title.d.ts +1 -1
  227. package/dist/types/model/types.d.ts +22 -22
  228. package/dist/types/model/uid.d.ts +1 -1
  229. package/dist/types/value/color.d.ts +1 -1
  230. package/dist/types/value/contentRelationship.d.ts +3 -3
  231. package/dist/types/value/date.d.ts +1 -1
  232. package/dist/types/value/document.d.ts +4 -4
  233. package/dist/types/value/embed.d.ts +1 -1
  234. package/dist/types/value/geoPoint.d.ts +1 -1
  235. package/dist/types/value/group.d.ts +1 -1
  236. package/dist/types/value/image.d.ts +1 -1
  237. package/dist/types/value/integration.d.ts +1 -1
  238. package/dist/types/value/keyText.d.ts +1 -1
  239. package/dist/types/value/link.d.ts +5 -5
  240. package/dist/types/value/linkToMedia.d.ts +2 -2
  241. package/dist/types/value/number.d.ts +1 -1
  242. package/dist/types/value/richText.d.ts +3 -3
  243. package/dist/types/value/select.d.ts +1 -1
  244. package/dist/types/value/sharedSlice.d.ts +1 -1
  245. package/dist/types/value/sharedSliceVariation.d.ts +1 -1
  246. package/dist/types/value/slice.d.ts +1 -1
  247. package/dist/types/value/sliceZone.d.ts +3 -3
  248. package/dist/types/value/table.d.ts +2 -2
  249. package/dist/types/value/timestamp.d.ts +2 -2
  250. package/dist/types/value/title.d.ts +2 -2
  251. package/dist/types/value/types.d.ts +18 -18
  252. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  253. package/dist/types/webhook/testTrigger.d.ts +1 -1
  254. package/dist/types/webhook/types.d.ts +2 -2
  255. package/package.json +11 -11
  256. package/src/WriteClient.ts +32 -21
  257. package/src/buildQueryURL.ts +29 -21
  258. package/src/createClient.ts +11 -8
  259. package/src/getRepositoryEndpoint.ts +9 -2
  260. package/src/helpers/asDate.ts +11 -4
  261. package/src/helpers/asHTML.ts +34 -26
  262. package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
  263. package/src/helpers/asImageSrc.ts +11 -10
  264. package/src/helpers/asImageWidthSrcSet.ts +18 -17
  265. package/src/helpers/asLink.ts +33 -32
  266. package/src/helpers/asLinkAttrs.ts +6 -9
  267. package/src/helpers/asText.ts +20 -10
  268. package/src/helpers/isFilled.ts +15 -14
  269. package/src/helpers/mapSliceZone.ts +10 -10
  270. package/src/index.ts +2 -2
  271. package/src/isRepositoryEndpoint.ts +2 -2
  272. package/src/richtext/asText.ts +5 -5
  273. package/src/richtext/serialize.ts +8 -8
  274. package/src/richtext/types.ts +6 -6
  275. package/src/types/migration/Asset.ts +10 -2
  276. package/src/types/model/contentRelationship.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"asText.cjs","sources":["../../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Serializes a rich text or title field to a plain text string\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param separator - Separator used to join each element, defaults to a space\n *\n * @returns Plain text equivalent of the provided rich text or title field\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\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"],"names":[],"mappings":";;AAYO,MAAM,SAAS,CACrB,eACA,YAAY,QACD;AACX,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC1C,QAAA,UAAU,cAAc,CAAC,GAAG;AAC/B,iBACE,SAAS,YAAY,MAAO,cAAc,CAAC,EAAiB;AAAA,IAAA;AAAA,EAC/D;AAGM,SAAA;AACR;;"}
1
+ {"version":3,"file":"asText.cjs","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"],"names":[],"mappings":";;AAYO,MAAM,SAAS,CACrB,eACA,YAAY,QACD;AACX,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C,QAAI,UAAU,cAAc,CAAC,GAAG;AAC/B,iBACE,SAAS,YAAY,MAAO,cAAc,CAAC,EAAiB;AAAA,IAC/D;AAAA,EACD;AAEA,SAAO;AACR;;"}
@@ -1,12 +1,12 @@
1
- import type { RichTextField } from "../types/value/richText";
1
+ import type { RichTextField } from "../types/value/richText.js";
2
2
  /**
3
- * Serializes a rich text or title field to a plain text string
3
+ * Converts a rich text field to a plain text string.
4
4
  *
5
- * @param richTextField - A rich text or title field from Prismic
6
- * @param separator - Separator used to join each element, defaults to a space
5
+ * @param richTextField - A rich text field from Prismic.
6
+ * @param separator - Separator used to join each element. Defaults to a space.
7
7
  *
8
- * @returns Plain text equivalent of the provided rich text or title field
8
+ * @returns Plain text equivalent of the rich text field.
9
9
  *
10
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
10
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
11
11
  */
12
12
  export declare const asText: (richTextField: RichTextField, separator?: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"asText.js","sources":["../../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Serializes a rich text or title field to a plain text string\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param separator - Separator used to join each element, defaults to a space\n *\n * @returns Plain text equivalent of the provided rich text or title field\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\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"],"names":[],"mappings":"AAYO,MAAM,SAAS,CACrB,eACA,YAAY,QACD;AACX,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC1C,QAAA,UAAU,cAAc,CAAC,GAAG;AAC/B,iBACE,SAAS,YAAY,MAAO,cAAc,CAAC,EAAiB;AAAA,IAAA;AAAA,EAC/D;AAGM,SAAA;AACR;"}
1
+ {"version":3,"file":"asText.js","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"],"names":[],"mappings":"AAYO,MAAM,SAAS,CACrB,eACA,YAAY,QACD;AACX,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C,QAAI,UAAU,cAAc,CAAC,GAAG;AAC/B,iBACE,SAAS,YAAY,MAAO,cAAc,CAAC,EAAiB;AAAA,IAC/D;AAAA,EACD;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.cjs","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"],"names":["RichTextNodeType"],"mappings":";;;AAYA,MAAM,OAAO,MAAa;AACjB,UAAA,EAAE,KAAK,GAAG,SAAQ;AAC3B;AACA,KAAK,IAAI;AAaI,MAAA,SAAS,CAAC,UAAyB;AACzC,QAAA,gBAAgB,aAAa,KAAK;AAExC,QAAM,WAAuB,CAAA;AAC7B,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C,aAAS,KAAK,eAAe,cAAc,CAAC,CAAC,CAAC;AAAA,EAAA;AAGxC,SAAA;AAAA,IACN,KAAK,KAAM;AAAA,IACX;AAAA;AAEF;AAEA,MAAM,iBAAiB,CACtB,MACA,WAAuB,OACV;AACN,SAAA;AAAA,IACN,KAAK,KAAM;AAAA,IACX,MAAM,KAAK;AAAA,IACX,MAAM,UAAU,OAAO,KAAK,OAAO;AAAA,IACnC;AAAA,IACA;AAAA;AAEF;AAEA,MAAM,qBAAqB,CAAC,SAA0B;AACrD,SAAO,eAAe;AAAA,IACrB,MAAMA,SAAiB,iBAAA;AAAA,IACvB;AAAA,IACA,OAAO,CAAA;AAAA,EAAE,CACT;AACF;AAEA,MAAM,eAAe,CAAC,UAAkC;AACjD,QAAA,WAA0B,MAAM,MAAM,CAAC;AAE7C,WAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACnC,UAAA,OAAO,SAAS,CAAC;AAEvB,QACC,KAAK,SAASA,0BAAiB,YAC/B,KAAK,SAASA,0BAAiB,WAC9B;AACD,YAAM,QAA8C;AAAA,QACnD;AAAA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,MAAM;AAC3B,UAAM,OAAO,KAAK,KAAK,MAAM,WAAW,OAAO;AAE/C,UAAM,aAA6B,CAAA;AACnC,aAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACnC,YAAA,cAAc,SAAS,CAAC;AAE9B,UAAI,gBAAgB,MAAM;AACzB,YAAI,YAAY,SAAS,KAAK,SAAS,YAAY,OAAO,KAAK,KAAK;AACnE,qBAAW,KAAK,WAAW;AAClB,mBAAA,OAAO,GAAG,CAAC;AACpB;AAAA,QAAA,WAEA,YAAY,QAAQ,KAAK,OACzB,YAAY,MAAM,KAAK,OACtB;AACD,qBAAW,KAAK;AAAA,YACf,GAAG;AAAA,YACH,KAAK,KAAK;AAAA,UAAA,CACV;AACD,mBAAS,CAAC,IAAI;AAAA,YACb,GAAG;AAAA,YACH,OAAO,KAAK;AAAA;;MAEd;AAAA,IACD;AAGG,QAAA,MAAM,KAAK,YAAY,GAAG;AACpB,eAAA,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AAAA,IAAA;AAGhE,UAAM,eAAe,EAAE,GAAG,MAAM;AAChC,aAAS,KACR,eACC,cACA,gCACC,YACA;AAAA,MACC,GAAG;AAAA,MACH;AAAA,IAAA,GAED,IAAI,CACJ,CACD;AAGE,QAAA,UAAU,KAAK,KAAK,QAAQ;AAC/B,eAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,CAAC,IACX,SAAS,IAAI,CAAC,EAAE,QAAQ,kBACxB,MAAS,CACZ,CACD;AAAA,IAAA;AAAA,EAEH;AAGM,SAAA;AACR;;"}
1
+ {"version":3,"file":"asTree.cjs","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"],"names":["RichTextNodeType"],"mappings":";;;AAYA,MAAM,OAAO,MAAa;AACzB,UAAQ,EAAE,KAAK,GAAG,SAAA;AACnB;AACA,KAAK,IAAI;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AAY,QAAQ,KAAK,OACzB,YAAY,MAAM,KAAK,OACtB;AACD,qBAAW,KAAK;AAAA,YACf,GAAG;AAAA,YACH,KAAK,KAAK;AAAA,UAAA,CACV;AACD,mBAAS,CAAC,IAAI;AAAA,YACb,GAAG;AAAA,YACH,OAAO,KAAK;AAAA,UAAA;AAAA,QAEd;AAAA,MACD;AAAA,IACD;AAEA,QAAI,MAAM,KAAK,YAAY,GAAG;AAC7B,eAAS,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AAAA,IAChE;AAEA,UAAM,eAAe,EAAE,GAAG,MAAM,KAAA;AAChC,aAAS,KACR,eACC,cACA,gCACC,YACA;AAAA,MACC,GAAG;AAAA,MACH;AAAA,IAAA,GAED,IAAI,CACJ,CACD;AAGF,QAAI,UAAU,KAAK,KAAK,QAAQ;AAC/B,eAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,CAAC,IACX,SAAS,IAAI,CAAC,EAAE,QAAQ,kBACxB,MAAS,CACZ,CACD;AAAA,IAEH;AAAA,EACD;AAEA,SAAO;AACR;;"}
@@ -1,5 +1,5 @@
1
- import type { RTNode } from "../types/value/richText";
2
- import type { Tree } from "./types";
1
+ import type { RTNode } from "../types/value/richText.js";
2
+ import type { Tree } from "./types.js";
3
3
  /**
4
4
  * Parses a rich text or title field into a tree
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"asTree.js","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"],"names":[],"mappings":";AAYA,MAAM,OAAO,MAAa;AACjB,UAAA,EAAE,KAAK,GAAG,SAAQ;AAC3B;AACA,KAAK,IAAI;AAaI,MAAA,SAAS,CAAC,UAAyB;AACzC,QAAA,gBAAgB,aAAa,KAAK;AAExC,QAAM,WAAuB,CAAA;AAC7B,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C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G;AACpB,eAAA,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AAAA,IAAA;AAGhE,UAAM,eAAe,EAAE,GAAG,MAAM;AAChC,aAAS,KACR,eACC,cACA,gCACC,YACA;AAAA,MACC,GAAG;AAAA,MACH;AAAA,IAAA,GAED,IAAI,CACJ,CACD;AAGE,QAAA,UAAU,KAAK,KAAK,QAAQ;AAC/B,eAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,CAAC,IACX,SAAS,IAAI,CAAC,EAAE,QAAQ,kBACxB,MAAS,CACZ,CACD;AAAA,IAAA;AAAA,EAEH;AAGM,SAAA;AACR;"}
1
+ {"version":3,"file":"asTree.js","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"],"names":[],"mappings":";AAYA,MAAM,OAAO,MAAa;AACzB,UAAQ,EAAE,KAAK,GAAG,SAAA;AACnB;AACA,KAAK,IAAI;AAaF,MAAM,SAAS,CAAC,UAAyB;AAC/C,QAAM,gBAAgB,aAAa,KAAK;AAExC,QAAM,WAAuB,CAAA;AAC7B,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C,aAAS,KAAK,eAAe,cAAc,CAAC,CAAC,CAAC;AAAA,EAC/C;AAEA,SAAO;AAAA,IACN,KAAK,KAAA;AAAA,IACL;AAAA,EAAA;AAEF;AAEA,MAAM,iBAAiB,CACtB,MACA,WAAuB,OACV;AACb,SAAO;AAAA,IACN,KAAK,KAAA;AAAA,IACL,MAAM,KAAK;AAAA,IACX,MAAM,UAAU,OAAO,KAAK,OAAO;AAAA,IACnC;AAAA,IACA;AAAA,EAAA;AAEF;AAEA,MAAM,qBAAqB,CAAC,SAA0B;AACrD,SAAO,eAAe;AAAA,IACrB,MAAM,iBAAiB;AAAA,IACvB;AAAA,IACA,OAAO,CAAA;AAAA,EAAA,CACP;AACF;AAEA,MAA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B,MAAS,CACZ,CACD;AAAA,IAEH;AAAA,EACD;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.cjs","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"],"names":[],"mappings":";;AAgBa,MAAA,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AACtC,YAAA,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACT,cAAA,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AACT,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IACD;AAAA,EAEF;AACD;;"}
1
+ {"version":3,"file":"composeSerializers.cjs","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"],"names":[],"mappings":";;AAgBO,MAAM,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAC5C,YAAM,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACf,cAAM,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AAChB,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;;"}
@@ -1,4 +1,4 @@
1
- import type { RichTextFunctionSerializer } from "./types";
1
+ import type { RichTextFunctionSerializer } from "./types.js";
2
2
  /**
3
3
  * Takes an array of serializers and returns a serializer applying provided
4
4
  * serializers sequentially until a result is returned
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.js","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"],"names":[],"mappings":"AAgBa,MAAA,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AACtC,YAAA,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACT,cAAA,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AACT,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IACD;AAAA,EAEF;AACD;"}
1
+ {"version":3,"file":"composeSerializers.js","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"],"names":[],"mappings":"AAgBO,MAAM,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAC5C,YAAM,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACf,cAAM,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AAChB,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;"}
@@ -1,7 +1,7 @@
1
- export { asTree } from "./asTree";
2
- export { asText } from "./asText";
3
- export { serialize } from "./serialize";
4
- export { wrapMapSerializer } from "./wrapMapSerializer";
5
- export { composeSerializers } from "./composeSerializers";
6
- export { RichTextNodeType as Element } from "../types/value/richText";
7
- export type { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction, } from "./types";
1
+ export { asTree } from "./asTree.js";
2
+ export { asText } from "./asText.js";
3
+ export { serialize } from "./serialize.js";
4
+ export { wrapMapSerializer } from "./wrapMapSerializer.js";
5
+ export { composeSerializers } from "./composeSerializers.js";
6
+ export { RichTextNodeType as Element } from "../types/value/richText.js";
7
+ export type { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction, } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.cjs","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text or title field with a given serializer\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 the serializer\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param serializer - A function serializer to apply\n *\n * @returns An array of serialized nodes\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":["asTree"],"mappings":";;;AAqBa,MAAA,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACNA,OAAA,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAChC,UAAA,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAAA;AAAA,EAC5C;AAGM,SAAA;AACR;;"}
1
+ {"version":3,"file":"serialize.cjs","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level\n * packages. Most users aren't expected to use this function directly.\n *\n * @typeParam SerializerReturnType - Return type of the serializer.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n *\n * @returns An array of serialized nodes.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":["asTree"],"mappings":";;;AAqBO,MAAM,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACNA,OAAAA,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,UAAM,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAC5C;AAAA,EACD;AAEA,SAAO;AACR;;"}
@@ -1,19 +1,19 @@
1
- import type { RichTextField } from "../types/value/richText";
2
- import type { RichTextFunctionSerializer } from "./types";
1
+ import type { RichTextField } from "../types/value/richText.js";
2
+ import type { RichTextFunctionSerializer } from "./types.js";
3
3
  /**
4
- * Serializes a rich text or title field with a given serializer
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 this function directly
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
9
  *
10
- * @typeParam SerializerReturnType - Return type of the serializer
10
+ * @typeParam SerializerReturnType - Return type of the serializer.
11
11
  *
12
- * @param richTextField - A rich text or title field from Prismic
13
- * @param serializer - A function serializer to apply
12
+ * @param richTextField - A rich text field from Prismic.
13
+ * @param serializer - A function serializer to apply.
14
14
  *
15
- * @returns An array of serialized nodes
15
+ * @returns An array of serialized nodes.
16
16
  *
17
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
17
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
18
18
  */
19
19
  export declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.js","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text or title field with a given serializer\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 the serializer\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param serializer - A function serializer to apply\n *\n * @returns An array of serialized nodes\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":[],"mappings":";AAqBa,MAAA,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACN,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAChC,UAAA,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAAA;AAAA,EAC5C;AAGM,SAAA;AACR;"}
1
+ {"version":3,"file":"serialize.js","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level\n * packages. Most users aren't expected to use this function directly.\n *\n * @typeParam SerializerReturnType - Return type of the serializer.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n *\n * @returns An array of serialized nodes.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":[],"mappings":";AAqBO,MAAM,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACN,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,UAAM,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAC5C;AAAA,EACD;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text or title field with a map\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}\n *\n * @typeParam ReturnType - Return type of the map serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":["RichTextNodeType"],"mappings":";;;AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAACA,SAAAA,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAACA,SAAAA,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAACA,SAAAA,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAACA,SAAAA,iBAAiB,KAAK,GAAG;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}.\n *\n * @typeParam ReturnType - Return type of the map serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":["RichTextNodeType"],"mappings":";;;AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAACA,SAAAA,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAACA,SAAAA,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAACA,SAAAA,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAACA,SAAAA,iBAAiB,KAAK,GAAG;;;"}
@@ -1,10 +1,10 @@
1
- import type { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText";
1
+ import type { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText.js";
2
2
  /**
3
3
  * Serializes a node from a rich text or title field with a function
4
4
  *
5
- * @typeParam ReturnType - Return type of the function serializer
5
+ * @typeParam ReturnType - Return type of the function serializer.
6
6
  *
7
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
7
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
8
8
  */
9
9
  export type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
10
10
  /**
@@ -21,15 +21,15 @@ export type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = R
21
21
  key: string;
22
22
  }) => ReturnType | null | undefined;
23
23
  /**
24
- * Serializes a node from a rich text or title field with a map
24
+ * Serializes a node from a rich text field with a map.
25
25
  *
26
26
  * @remarks
27
27
  * This type of serializer needs to be processed through
28
- * {@link wrapMapSerializer} before being used with {@link serialize}
28
+ * {@link wrapMapSerializer} before being used with {@link serialize}.
29
29
  *
30
- * @typeParam ReturnType - Return type of the map serializer
30
+ * @typeParam ReturnType - Return type of the map serializer.
31
31
  *
32
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
32
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
33
33
  */
34
34
  export type RichTextMapSerializer<ReturnType> = {
35
35
  heading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text or title field with a map\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}\n *\n * @typeParam ReturnType - Return type of the map serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":[],"mappings":";AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAAC,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAAC,iBAAiB,KAAK,GAAG;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}.\n *\n * @typeParam ReturnType - Return type of the map serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":[],"mappings":";AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAAC,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAAC,iBAAiB,KAAK,GAAG;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMapSerializer.cjs","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\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 the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["RichTextReversedNodeType"],"mappings":";;;AAgBa,MAAA,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACEA,MACA,yBAAA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,EAEH;AACD;;"}
1
+ {"version":3,"file":"wrapMapSerializer.cjs","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\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 the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["RichTextReversedNodeType"],"mappings":";;;AAgBO,MAAM,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACEA,MAAAA,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IACF;AAAA,EACD;AACD;;"}
@@ -1,4 +1,4 @@
1
- import type { RichTextFunctionSerializer, RichTextMapSerializer } from "./types";
1
+ import type { RichTextFunctionSerializer, RichTextMapSerializer } from "./types.js";
2
2
  /**
3
3
  * Wraps a map serializer into a regular function serializer
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMapSerializer.js","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\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 the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAgBa,MAAA,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACE,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,EAEH;AACD;"}
1
+ {"version":3,"file":"wrapMapSerializer.js","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\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 the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAgBO,MAAM,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACE,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IACF;AAAA,EACD;AACD;"}
@@ -1,4 +1,4 @@
1
- import type { AssetTag } from "./tag";
1
+ import type { AssetTag } from "./tag.js";
2
2
  /**
3
3
  * Asset types.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IntegrationFieldData } from "../value/integration";
1
+ import type { IntegrationFieldData } from "../value/integration.js";
2
2
  /**
3
3
  * A catalog item from an integration field.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { PrismicDocument, PrismicDocumentWithUID } from "../../value/document";
1
+ import type { PrismicDocument, PrismicDocumentWithUID } from "../../value/document.js";
2
2
  /**
3
3
  * An object representing the parameters required when creating a document
4
4
  * through the Migration API.
@@ -1,4 +1,4 @@
1
- import type { PrismicDocument } from "../value/document";
1
+ import type { PrismicDocument } from "../value/document.js";
2
2
  /**
3
3
  * A query response from the Prismic REST API V2. The response contains
4
4
  * paginated metadata and a list of matching results for the query.
@@ -1,4 +1,4 @@
1
- import type { Ref } from "./ref";
1
+ import type { Ref } from "./ref.js";
2
2
  /**
3
3
  * Metadata for a Release.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { Ref } from "./ref";
1
+ import type { Ref } from "./ref.js";
2
2
  /**
3
3
  * Repository metadata returned from the Prismic REST API V2. This data can be
4
4
  * fetched by sending a `GET` a request to a repository's `/api/v2` endpoint.
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
3
  class PrismicMigrationAsset {
4
+ /**
5
+ * Asset object from Prismic, available once created.
6
+ */
7
+ asset;
8
+ /**
9
+ * Configuration of the asset.
10
+ */
11
+ config;
12
+ /**
13
+ * The initial field value this migration field was created with.
14
+ */
15
+ originalField;
7
16
  /**
8
17
  * Creates a migration asset used with the Prismic Migration API.
9
18
  *
@@ -13,18 +22,6 @@ class PrismicMigrationAsset {
13
22
  * @returns A migration asset instance.
14
23
  */
15
24
  constructor(config, initialField) {
16
- /**
17
- * Asset object from Prismic, available once created.
18
- */
19
- __publicField(this, "asset");
20
- /**
21
- * Configuration of the asset.
22
- */
23
- __publicField(this, "config");
24
- /**
25
- * The initial field value this migration field was created with.
26
- */
27
- __publicField(this, "originalField");
28
25
  this.config = config;
29
26
  this.originalField = initialField;
30
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;;;MA2Ga,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EAAA;AAEtB;;"}
1
+ {"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;MAmHa,sBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,YACC,QACA,cAGc;AAEd,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACtB;AACA;;"}
@@ -1,8 +1,8 @@
1
- import type { Asset } from "../api/asset/asset";
2
- import type { FilledImageFieldImage } from "../value/image";
3
- import type { LinkToMediaField } from "../value/linkToMedia";
4
- import { type RTImageNode } from "../value/richText";
5
- import type { InjectMigrationSpecificTypes } from "./Document";
1
+ import type { Asset } from "../api/asset/asset.js";
2
+ import type { FilledImageFieldImage } from "../value/image.js";
3
+ import type { LinkToMediaField } from "../value/linkToMedia.js";
4
+ import { type RTImageNode } from "../value/richText.js";
5
+ import type { InjectMigrationSpecificTypes } from "./Document.js";
6
6
  /**
7
7
  * An asset to be uploaded to Prismic media library.
8
8
  */
@@ -15,11 +15,11 @@ export type MigrationAssetConfig = {
15
15
  * `file` property. It is mainly used for deduplication within a `Migration`
16
16
  * instance.
17
17
  */
18
- id: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0];
18
+ id: string | URL | File | NonNullable<ConstructorParameters<typeof File>[0]>[0];
19
19
  /**
20
20
  * File to be uploaded as an asset.
21
21
  */
22
- file: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0];
22
+ file: string | URL | File | NonNullable<ConstructorParameters<typeof File>[0]>[0];
23
23
  /**
24
24
  * Filename of the asset.
25
25
  */
@@ -1,7 +1,16 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
1
  class PrismicMigrationAsset {
2
+ /**
3
+ * Asset object from Prismic, available once created.
4
+ */
5
+ asset;
6
+ /**
7
+ * Configuration of the asset.
8
+ */
9
+ config;
10
+ /**
11
+ * The initial field value this migration field was created with.
12
+ */
13
+ originalField;
5
14
  /**
6
15
  * Creates a migration asset used with the Prismic Migration API.
7
16
  *
@@ -11,18 +20,6 @@ class PrismicMigrationAsset {
11
20
  * @returns A migration asset instance.
12
21
  */
13
22
  constructor(config, initialField) {
14
- /**
15
- * Asset object from Prismic, available once created.
16
- */
17
- __publicField(this, "asset");
18
- /**
19
- * Configuration of the asset.
20
- */
21
- __publicField(this, "config");
22
- /**
23
- * The initial field value this migration field was created with.
24
- */
25
- __publicField(this, "originalField");
26
23
  this.config = config;
27
24
  this.originalField = initialField;
28
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Asset.js","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;MA2Ga,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EAAA;AAEtB;"}
1
+ {"version":3,"file":"Asset.js","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":"MAmHa,sBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,YACC,QACA,cAGc;AAEd,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACtB;AACA;"}
@@ -1,6 +1,6 @@
1
- import type { ContentRelationshipField, EmptyContentRelationshipField, FilledContentRelationshipField } from "../value/contentRelationship";
2
- import type { PrismicDocument } from "../value/document";
3
- import type { PrismicMigrationDocument } from "./Document";
1
+ import type { ContentRelationshipField, EmptyContentRelationshipField, FilledContentRelationshipField } from "../value/contentRelationship.js";
2
+ import type { PrismicDocument } from "../value/document.js";
3
+ import type { PrismicMigrationDocument } from "./Document.js";
4
4
  type ValueOrThunk<T> = T | (() => Promise<T> | T);
5
5
  /**
6
6
  * A content relationship field in a migration.