@prismicio/client 7.0.0-alpha.4 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/buildQueryURL.cjs.map +1 -1
  2. package/dist/buildQueryURL.d.ts +4 -4
  3. package/dist/buildQueryURL.js.map +1 -1
  4. package/dist/createClient.cjs +24 -24
  5. package/dist/createClient.cjs.map +1 -1
  6. package/dist/createClient.d.ts +28 -28
  7. package/dist/createClient.js +24 -24
  8. package/dist/createClient.js.map +1 -1
  9. package/dist/filter.cjs +1 -1
  10. package/dist/filter.cjs.map +1 -1
  11. package/dist/filter.d.ts +1 -1
  12. package/dist/filter.js +1 -1
  13. package/dist/filter.js.map +1 -1
  14. package/dist/helpers/asDate.cjs.map +1 -1
  15. package/dist/helpers/asDate.d.ts +2 -2
  16. package/dist/helpers/asDate.js.map +1 -1
  17. package/dist/helpers/asHTML.cjs +5 -5
  18. package/dist/helpers/asHTML.cjs.map +1 -1
  19. package/dist/helpers/asHTML.d.ts +21 -21
  20. package/dist/helpers/asHTML.js +5 -5
  21. package/dist/helpers/asHTML.js.map +1 -1
  22. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  23. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +5 -5
  24. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  25. package/dist/helpers/asImageSrc.cjs.map +1 -1
  26. package/dist/helpers/asImageSrc.d.ts +3 -3
  27. package/dist/helpers/asImageSrc.js.map +1 -1
  28. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  29. package/dist/helpers/asImageWidthSrcSet.d.ts +6 -6
  30. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  31. package/dist/helpers/asLink.cjs.map +1 -1
  32. package/dist/helpers/asLink.d.ts +14 -14
  33. package/dist/helpers/asLink.js.map +1 -1
  34. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  35. package/dist/helpers/asLinkAttrs.d.ts +5 -5
  36. package/dist/helpers/asLinkAttrs.js.map +1 -1
  37. package/dist/helpers/asText.cjs.map +1 -1
  38. package/dist/helpers/asText.d.ts +8 -8
  39. package/dist/helpers/asText.js.map +1 -1
  40. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  41. package/dist/helpers/documentToLinkField.js.map +1 -1
  42. package/dist/helpers/isFilled.cjs +3 -1
  43. package/dist/helpers/isFilled.cjs.map +1 -1
  44. package/dist/helpers/isFilled.d.ts +24 -20
  45. package/dist/helpers/isFilled.js +3 -1
  46. package/dist/helpers/isFilled.js.map +1 -1
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +12 -2
  49. package/dist/index.js.map +1 -1
  50. package/dist/package.json.cjs +1 -1
  51. package/dist/package.json.js +1 -1
  52. package/dist/types/api/repository.d.ts +2 -2
  53. package/dist/types/model/boolean.d.ts +1 -1
  54. package/dist/types/model/color.d.ts +1 -1
  55. package/dist/types/model/contentRelationship.d.ts +1 -1
  56. package/dist/types/model/customType.d.ts +11 -11
  57. package/dist/types/model/date.d.ts +1 -1
  58. package/dist/types/model/embed.d.ts +1 -1
  59. package/dist/types/model/geoPoint.d.ts +1 -1
  60. package/dist/types/model/group.d.ts +1 -1
  61. package/dist/types/model/image.d.ts +3 -3
  62. package/dist/types/model/{integrationFields.d.ts → integration.d.ts} +3 -3
  63. package/dist/types/model/keyText.d.ts +1 -1
  64. package/dist/types/model/link.cjs.map +1 -1
  65. package/dist/types/model/link.d.ts +2 -2
  66. package/dist/types/model/link.js.map +1 -1
  67. package/dist/types/model/linkToMedia.d.ts +1 -1
  68. package/dist/types/model/number.d.ts +1 -1
  69. package/dist/types/model/richText.d.ts +3 -3
  70. package/dist/types/model/select.d.ts +1 -1
  71. package/dist/types/model/sharedSlice.d.ts +2 -2
  72. package/dist/types/model/sharedSliceVariation.d.ts +1 -1
  73. package/dist/types/model/slice.cjs.map +1 -1
  74. package/dist/types/model/slice.d.ts +1 -1
  75. package/dist/types/model/slice.js.map +1 -1
  76. package/dist/types/model/sliceZone.cjs.map +1 -1
  77. package/dist/types/model/sliceZone.d.ts +2 -2
  78. package/dist/types/model/sliceZone.js.map +1 -1
  79. package/dist/types/model/timestamp.d.ts +1 -1
  80. package/dist/types/model/title.d.ts +1 -1
  81. package/dist/types/model/types.cjs +5 -1
  82. package/dist/types/model/types.cjs.map +1 -1
  83. package/dist/types/model/types.d.ts +10 -6
  84. package/dist/types/model/types.js +5 -1
  85. package/dist/types/model/types.js.map +1 -1
  86. package/dist/types/model/uid.d.ts +1 -1
  87. package/dist/types/value/boolean.d.ts +1 -1
  88. package/dist/types/value/color.d.ts +1 -1
  89. package/dist/types/value/contentRelationship.d.ts +1 -1
  90. package/dist/types/value/date.d.ts +1 -1
  91. package/dist/types/value/document.d.ts +4 -4
  92. package/dist/types/value/embed.cjs.map +1 -1
  93. package/dist/types/value/embed.d.ts +1 -1
  94. package/dist/types/value/embed.js.map +1 -1
  95. package/dist/types/value/geoPoint.d.ts +1 -1
  96. package/dist/types/value/group.d.ts +1 -1
  97. package/dist/types/value/image.d.ts +3 -3
  98. package/dist/types/value/{integrationFields.d.ts → integration.d.ts} +2 -2
  99. package/dist/types/value/keyText.d.ts +1 -1
  100. package/dist/types/value/link.cjs.map +1 -1
  101. package/dist/types/value/link.d.ts +2 -2
  102. package/dist/types/value/link.js.map +1 -1
  103. package/dist/types/value/linkToMedia.d.ts +2 -2
  104. package/dist/types/value/number.d.ts +1 -1
  105. package/dist/types/value/richText.cjs.map +1 -1
  106. package/dist/types/value/richText.d.ts +26 -26
  107. package/dist/types/value/richText.js.map +1 -1
  108. package/dist/types/value/select.d.ts +1 -1
  109. package/dist/types/value/sharedSlice.d.ts +1 -1
  110. package/dist/types/value/sharedSliceVariation.d.ts +3 -0
  111. package/dist/types/value/slice.d.ts +1 -1
  112. package/dist/types/value/timestamp.d.ts +1 -1
  113. package/dist/types/value/title.d.ts +1 -1
  114. package/dist/types/value/types.d.ts +2 -2
  115. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  116. package/package.json +2 -2
  117. package/src/buildQueryURL.ts +4 -4
  118. package/src/createClient.ts +28 -28
  119. package/src/filter.ts +1 -1
  120. package/src/helpers/asDate.ts +2 -2
  121. package/src/helpers/asHTML.ts +28 -29
  122. package/src/helpers/asImagePixelDensitySrcSet.ts +5 -5
  123. package/src/helpers/asImageSrc.ts +3 -3
  124. package/src/helpers/asImageWidthSrcSet.ts +6 -6
  125. package/src/helpers/asLink.ts +18 -18
  126. package/src/helpers/asLinkAttrs.ts +5 -5
  127. package/src/helpers/asText.ts +8 -8
  128. package/src/helpers/documentToLinkField.ts +1 -1
  129. package/src/helpers/isFilled.ts +27 -22
  130. package/src/index.ts +19 -3
  131. package/src/types/api/repository.ts +2 -2
  132. package/src/types/model/boolean.ts +1 -1
  133. package/src/types/model/color.ts +1 -1
  134. package/src/types/model/contentRelationship.ts +1 -1
  135. package/src/types/model/customType.ts +11 -11
  136. package/src/types/model/date.ts +1 -1
  137. package/src/types/model/embed.ts +1 -1
  138. package/src/types/model/geoPoint.ts +1 -1
  139. package/src/types/model/group.ts +1 -1
  140. package/src/types/model/image.ts +3 -3
  141. package/src/types/model/{integrationFields.ts → integration.ts} +3 -3
  142. package/src/types/model/keyText.ts +1 -1
  143. package/src/types/model/link.ts +2 -2
  144. package/src/types/model/linkToMedia.ts +1 -1
  145. package/src/types/model/number.ts +1 -1
  146. package/src/types/model/richText.ts +3 -3
  147. package/src/types/model/select.ts +1 -1
  148. package/src/types/model/sharedSlice.ts +2 -2
  149. package/src/types/model/sharedSliceVariation.ts +1 -1
  150. package/src/types/model/slice.ts +1 -1
  151. package/src/types/model/sliceZone.ts +2 -2
  152. package/src/types/model/timestamp.ts +1 -1
  153. package/src/types/model/title.ts +1 -1
  154. package/src/types/model/types.ts +10 -6
  155. package/src/types/model/uid.ts +1 -1
  156. package/src/types/value/boolean.ts +1 -1
  157. package/src/types/value/color.ts +1 -1
  158. package/src/types/value/contentRelationship.ts +1 -1
  159. package/src/types/value/date.ts +1 -1
  160. package/src/types/value/document.ts +4 -4
  161. package/src/types/value/embed.ts +1 -1
  162. package/src/types/value/geoPoint.ts +1 -1
  163. package/src/types/value/group.ts +1 -1
  164. package/src/types/value/image.ts +4 -4
  165. package/src/types/value/{integrationFields.ts → integration.ts} +2 -2
  166. package/src/types/value/keyText.ts +1 -1
  167. package/src/types/value/link.ts +2 -2
  168. package/src/types/value/linkToMedia.ts +2 -2
  169. package/src/types/value/number.ts +1 -1
  170. package/src/types/value/richText.ts +26 -26
  171. package/src/types/value/select.ts +1 -1
  172. package/src/types/value/sharedSlice.ts +1 -1
  173. package/src/types/value/sharedSliceVariation.ts +3 -0
  174. package/src/types/value/slice.ts +1 -1
  175. package/src/types/value/timestamp.ts +1 -1
  176. package/src/types/value/title.ts +1 -1
  177. package/src/types/value/types.ts +2 -2
  178. package/src/types/webhook/apiUpdate.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"filter.cjs","sources":["../../src/filter.ts"],"sourcesContent":["/**\n * Formats the value of a filter element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a filter builder function for filters with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the filter.\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathWithArgsFilter = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only a path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathFilter = (name: string) => {\n\tconst filterFn = pathWithArgsFilter(name);\n\n\t/**\n\t * @param path - Path for the filter.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn filterFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only arguments and\n * no path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst argsFilter = <Args extends unknown[]>(name: string) => {\n\tconst filterFn = pathWithArgsFilter<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the filter.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn filterFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const filter = {\n\t/**\n\t * The `at` filter checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#at}\n\t */\n\tat: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"at\",\n\t),\n\n\t/**\n\t * The `not` filter checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#not}\n\t */\n\tnot: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"not\",\n\t),\n\n\t/**\n\t * The `any` filter takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#any}\n\t */\n\tany: pathWithArgsFilter<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` filter is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This filter is much more efficient at this than\n\t * the any filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#in}\n\t */\n\tin: pathWithArgsFilter<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` filter provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fulltext}\n\t */\n\tfulltext: pathWithArgsFilter<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` filter checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#has}\n\t */\n\thas: pathFilter(\"has\"),\n\n\t/**\n\t * The `missing` filter checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#missing}\n\t */\n\tmissing: pathFilter(\"missing\"),\n\n\t/**\n\t * The `similar` filter takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#similar}\n\t */\n\tsimilar: argsFilter<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` filter checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This filter will only work for a GeoPoint field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsFilter<[latitude: number, longitude: number, radius: number]>(\n\t\t\t\"geopoint.near\",\n\t\t),\n\n\t/**\n\t * The `number.lt` filter checks that the value in the number field is less\n\t * than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberlessthan}\n\t */\n\tnumberLessThan: pathWithArgsFilter<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` filter checks that the value in the number field is\n\t * greater than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numbergreaterthan}\n\t */\n\tnumberGreaterThan: pathWithArgsFilter<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` filter checks that the value in the path is within\n\t * the two values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberinrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsFilter<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` filter checks that the value in the path is after the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateAfter: pathWithArgsFilter<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` filter checks that the value in the path is before the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBefore: pathWithArgsFilter<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` filter checks that the value in the path is within\n\t * the date values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBetween:\n\t\tpathWithArgsFilter<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` filter checks that the value in the path is\n\t * equal to the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonth: pathWithArgsFilter<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` filter checks that the value in the path\n\t * is after the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` filter checks that the value in the path\n\t * is before the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` filter checks that the value in the path is equal\n\t * to the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeek: pathWithArgsFilter<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` filter checks that the value in the path is\n\t * after the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before filter checks that the value in the path is\n\t * before the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` filter checks that the value in the path occurs in the\n\t * month value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonth: pathWithArgsFilter<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` filter checks that the value in the path occurs\n\t * in any month after the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` filter checks that the value in the path occurs\n\t * in any month before the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` filter checks that the value in the path occurs in the\n\t * year value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateYear: pathWithArgsFilter<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` filter checks that the value in the path occurs within\n\t * the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHour: pathWithArgsFilter<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` filter checks that the value in the path occurs\n\t * after the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourAfter: pathWithArgsFilter<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` filter checks that the value in the path occurs\n\t * before the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourBefore: pathWithArgsFilter<[hour: number]>(\"date.hour-before\"),\n};\n"],"names":[],"mappings":";;AAQA,MAAM,cAAc,CACnB,UAMW;AACP,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,IAAI,MAAM,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAC3C;AAEG,MAAA,OAAO,UAAU,UAAU;AAC9B,WAAO,IAAI;AAAA,EACX;AAED,MAAI,iBAAiB,MAAM;AACnB,WAAA,GAAG,MAAM,QAAO;AAAA,EACvB;AAED,SAAO,GAAG;AACX;AAWA,MAAM,qBAAqB,CAAyB,SAAgB;AAI7D,QAAA,KAAK,CAAC,SAAiB,SAAsB;AAClD,UAAM,gBAAgB,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI;AACrD,UAAM,SAA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;"}
1
+ {"version":3,"file":"filter.cjs","sources":["../../src/filter.ts"],"sourcesContent":["/**\n * Formats the value of a filter element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a filter builder function for filters with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the filter.\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathWithArgsFilter = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only a path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathFilter = (name: string) => {\n\tconst filterFn = pathWithArgsFilter(name);\n\n\t/**\n\t * @param path - Path for the filter.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn filterFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only arguments and\n * no path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst argsFilter = <Args extends unknown[]>(name: string) => {\n\tconst filterFn = pathWithArgsFilter<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the filter.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn filterFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const filter = {\n\t/**\n\t * The `at` filter checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#at}\n\t */\n\tat: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"at\",\n\t),\n\n\t/**\n\t * The `not` filter checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#not}\n\t */\n\tnot: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"not\",\n\t),\n\n\t/**\n\t * The `any` filter takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#any}\n\t */\n\tany: pathWithArgsFilter<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` filter is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This filter is much more efficient at this than\n\t * the any filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#in}\n\t */\n\tin: pathWithArgsFilter<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` filter provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fulltext}\n\t */\n\tfulltext: pathWithArgsFilter<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` filter checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#has}\n\t */\n\thas: pathFilter(\"has\"),\n\n\t/**\n\t * The `missing` filter checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#missing}\n\t */\n\tmissing: pathFilter(\"missing\"),\n\n\t/**\n\t * The `similar` filter takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#similar}\n\t */\n\tsimilar: argsFilter<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` filter checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This filter will only work for a geopoint field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsFilter<[latitude: number, longitude: number, radius: number]>(\n\t\t\t\"geopoint.near\",\n\t\t),\n\n\t/**\n\t * The `number.lt` filter checks that the value in the number field is less\n\t * than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberlessthan}\n\t */\n\tnumberLessThan: pathWithArgsFilter<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` filter checks that the value in the number field is\n\t * greater than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numbergreaterthan}\n\t */\n\tnumberGreaterThan: pathWithArgsFilter<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` filter checks that the value in the path is within\n\t * the two values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberinrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsFilter<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` filter checks that the value in the path is after the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateAfter: pathWithArgsFilter<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` filter checks that the value in the path is before the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBefore: pathWithArgsFilter<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` filter checks that the value in the path is within\n\t * the date values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBetween:\n\t\tpathWithArgsFilter<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` filter checks that the value in the path is\n\t * equal to the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonth: pathWithArgsFilter<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` filter checks that the value in the path\n\t * is after the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` filter checks that the value in the path\n\t * is before the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` filter checks that the value in the path is equal\n\t * to the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeek: pathWithArgsFilter<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` filter checks that the value in the path is\n\t * after the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before filter checks that the value in the path is\n\t * before the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` filter checks that the value in the path occurs in the\n\t * month value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonth: pathWithArgsFilter<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` filter checks that the value in the path occurs\n\t * in any month after the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` filter checks that the value in the path occurs\n\t * in any month before the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` filter checks that the value in the path occurs in the\n\t * year value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateYear: pathWithArgsFilter<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` filter checks that the value in the path occurs within\n\t * the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHour: pathWithArgsFilter<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` filter checks that the value in the path occurs\n\t * after the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourAfter: pathWithArgsFilter<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` filter checks that the value in the path occurs\n\t * before the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourBefore: pathWithArgsFilter<[hour: number]>(\"date.hour-before\"),\n};\n"],"names":[],"mappings":";;AAQA,MAAM,cAAc,CACnB,UAMW;AACP,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,IAAI,MAAM,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAC3C;AAEG,MAAA,OAAO,UAAU,UAAU;AAC9B,WAAO,IAAI;AAAA,EACX;AAED,MAAI,iBAAiB,MAAM;AACnB,WAAA,GAAG,MAAM,QAAO;AAAA,EACvB;AAED,SAAO,GAAG;AACX;AAWA,MAAM,qBAAqB,CAAyB,SAAgB;AAI7D,QAAA,KAAK,CAAC,SAAiB,SAAsB;AAClD,UAAM,gBAAgB,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI;AACrD,UAAM,SAAS,QAAQ,KAAK,SAAS,OAAO;AAErC,WAAA,IAAI,QAAQ,OAAO,SAAS;AAAA,EAAA;AAG7B,SAAA;AACR;AASA,MAAM,aAAa,CAAC,SAAgB;AAC7B,QAAA,WAAW,mBAAmB,IAAI;AAKlC,QAAA,KAAK,CAAC,SAAwB;AACnC,WAAO,SAAS,IAAI;AAAA,EAAA;AAGd,SAAA;AACR;AAUA,MAAM,aAAa,CAAyB,SAAgB;AACrD,QAAA,WAAW,mBAAyB,IAAI;AAKxC,QAAA,KAAK,IAAI,SAAsB;AAC7B,WAAA,SAAS,IAAI,GAAG,IAAI;AAAA,EAAA;AAGrB,SAAA;AACR;AAEO,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrB,IAAI,mBACH,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAK,mBACJ,KAAK;AAAA;AAAA;AAAA;AAAA;A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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5E,oBAAoB,mBACnB,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzB,qBAAqB,mBACpB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS1B,WAAW,mBAA6C,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpE,gBACC,mBAA6C,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhE,iBACC,mBAA6C,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjE,UAAU,mBAAmC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxD,UAAU,mBAAmC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxD,eAAe,mBAAmC,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnE,gBAAgB,mBAAmC,kBAAkB;;;"}
package/dist/filter.d.ts CHANGED
@@ -68,7 +68,7 @@ export declare const filter: {
68
68
  * The `geopoint.near` filter checks that the value in the path is within
69
69
  * the radius of the given coordinates.
70
70
  *
71
- * This filter will only work for a GeoPoint field.
71
+ * This filter will only work for a geopoint field.
72
72
  *
73
73
  * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}
74
74
  */
package/dist/filter.js CHANGED
@@ -102,7 +102,7 @@ const filter = {
102
102
  * The `geopoint.near` filter checks that the value in the path is within
103
103
  * the radius of the given coordinates.
104
104
  *
105
- * This filter will only work for a GeoPoint field.
105
+ * This filter will only work for a geopoint field.
106
106
  *
107
107
  * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}
108
108
  */
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","sources":["../../src/filter.ts"],"sourcesContent":["/**\n * Formats the value of a filter element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a filter builder function for filters with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the filter.\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathWithArgsFilter = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only a path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathFilter = (name: string) => {\n\tconst filterFn = pathWithArgsFilter(name);\n\n\t/**\n\t * @param path - Path for the filter.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn filterFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only arguments and\n * no path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst argsFilter = <Args extends unknown[]>(name: string) => {\n\tconst filterFn = pathWithArgsFilter<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the filter.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn filterFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const filter = {\n\t/**\n\t * The `at` filter checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#at}\n\t */\n\tat: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"at\",\n\t),\n\n\t/**\n\t * The `not` filter checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#not}\n\t */\n\tnot: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"not\",\n\t),\n\n\t/**\n\t * The `any` filter takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#any}\n\t */\n\tany: pathWithArgsFilter<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` filter is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This filter is much more efficient at this than\n\t * the any filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#in}\n\t */\n\tin: pathWithArgsFilter<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` filter provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fulltext}\n\t */\n\tfulltext: pathWithArgsFilter<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` filter checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#has}\n\t */\n\thas: pathFilter(\"has\"),\n\n\t/**\n\t * The `missing` filter checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#missing}\n\t */\n\tmissing: pathFilter(\"missing\"),\n\n\t/**\n\t * The `similar` filter takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#similar}\n\t */\n\tsimilar: argsFilter<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` filter checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This filter will only work for a GeoPoint field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsFilter<[latitude: number, longitude: number, radius: number]>(\n\t\t\t\"geopoint.near\",\n\t\t),\n\n\t/**\n\t * The `number.lt` filter checks that the value in the number field is less\n\t * than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberlessthan}\n\t */\n\tnumberLessThan: pathWithArgsFilter<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` filter checks that the value in the number field is\n\t * greater than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numbergreaterthan}\n\t */\n\tnumberGreaterThan: pathWithArgsFilter<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` filter checks that the value in the path is within\n\t * the two values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberinrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsFilter<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` filter checks that the value in the path is after the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateAfter: pathWithArgsFilter<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` filter checks that the value in the path is before the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBefore: pathWithArgsFilter<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` filter checks that the value in the path is within\n\t * the date values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBetween:\n\t\tpathWithArgsFilter<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` filter checks that the value in the path is\n\t * equal to the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonth: pathWithArgsFilter<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` filter checks that the value in the path\n\t * is after the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` filter checks that the value in the path\n\t * is before the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` filter checks that the value in the path is equal\n\t * to the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeek: pathWithArgsFilter<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` filter checks that the value in the path is\n\t * after the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before filter checks that the value in the path is\n\t * before the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` filter checks that the value in the path occurs in the\n\t * month value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonth: pathWithArgsFilter<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` filter checks that the value in the path occurs\n\t * in any month after the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` filter checks that the value in the path occurs\n\t * in any month before the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` filter checks that the value in the path occurs in the\n\t * year value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateYear: pathWithArgsFilter<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` filter checks that the value in the path occurs within\n\t * the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHour: pathWithArgsFilter<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` filter checks that the value in the path occurs\n\t * after the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourAfter: pathWithArgsFilter<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` filter checks that the value in the path occurs\n\t * before the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-techn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B,mBACpB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS1B,WAAW,mBAA6C,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpE,gBACC,mBAA6C,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhE,iBACC,mBAA6C,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjE,UAAU,mBAAmC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxD,UAAU,mBAAmC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxD,eAAe,mBAAmC,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnE,gBAAgB,mBAAmC,kBAAkB;;"}
1
+ {"version":3,"file":"filter.js","sources":["../../src/filter.ts"],"sourcesContent":["/**\n * Formats the value of a filter element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a filter builder function for filters with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the filter.\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathWithArgsFilter = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only a path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst pathFilter = (name: string) => {\n\tconst filterFn = pathWithArgsFilter(name);\n\n\t/**\n\t * @param path - Path for the filter.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn filterFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a filter builder function for filters with only arguments and\n * no path.\n *\n * @param name - Name of the filter used in the resulting string.\n *\n * @returns Filter builder function for the given name.\n */\nconst argsFilter = <Args extends unknown[]>(name: string) => {\n\tconst filterFn = pathWithArgsFilter<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the filter.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn filterFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const filter = {\n\t/**\n\t * The `at` filter checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#at}\n\t */\n\tat: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"at\",\n\t),\n\n\t/**\n\t * The `not` filter checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#not}\n\t */\n\tnot: pathWithArgsFilter<[value: string | number | boolean | Date | string[]]>(\n\t\t\"not\",\n\t),\n\n\t/**\n\t * The `any` filter takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#any}\n\t */\n\tany: pathWithArgsFilter<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` filter is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This filter is much more efficient at this than\n\t * the any filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#in}\n\t */\n\tin: pathWithArgsFilter<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` filter provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fulltext}\n\t */\n\tfulltext: pathWithArgsFilter<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` filter checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#has}\n\t */\n\thas: pathFilter(\"has\"),\n\n\t/**\n\t * The `missing` filter checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#missing}\n\t */\n\tmissing: pathFilter(\"missing\"),\n\n\t/**\n\t * The `similar` filter takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#similar}\n\t */\n\tsimilar: argsFilter<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` filter checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This filter will only work for a geopoint field.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsFilter<[latitude: number, longitude: number, radius: number]>(\n\t\t\t\"geopoint.near\",\n\t\t),\n\n\t/**\n\t * The `number.lt` filter checks that the value in the number field is less\n\t * than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberlessthan}\n\t */\n\tnumberLessThan: pathWithArgsFilter<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` filter checks that the value in the number field is\n\t * greater than the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numbergreaterthan}\n\t */\n\tnumberGreaterThan: pathWithArgsFilter<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` filter checks that the value in the path is within\n\t * the two values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#numberinrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsFilter<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` filter checks that the value in the path is after the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateAfter: pathWithArgsFilter<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` filter checks that the value in the path is before the\n\t * date value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBefore: pathWithArgsFilter<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` filter checks that the value in the path is within\n\t * the date values passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateBetween:\n\t\tpathWithArgsFilter<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` filter checks that the value in the path is\n\t * equal to the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonth: pathWithArgsFilter<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` filter checks that the value in the path\n\t * is after the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` filter checks that the value in the path\n\t * is before the day of the month passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsFilter<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` filter checks that the value in the path is equal\n\t * to the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeek: pathWithArgsFilter<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` filter checks that the value in the path is\n\t * after the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before filter checks that the value in the path is\n\t * before the day of the week passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsFilter<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` filter checks that the value in the path occurs in the\n\t * month value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonth: pathWithArgsFilter<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` filter checks that the value in the path occurs\n\t * in any month after the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` filter checks that the value in the path occurs\n\t * in any month before the value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsFilter<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` filter checks that the value in the path occurs in the\n\t * year value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateYear: pathWithArgsFilter<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` filter checks that the value in the path occurs within\n\t * the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHour: pathWithArgsFilter<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` filter checks that the value in the path occurs\n\t * after the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourAfter: pathWithArgsFilter<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` filter checks that the value in the path occurs\n\t * before the hour value passed into the filter.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}\n\t */\n\tdateHourBefore: pathWithArgsFilter<[hour: number]>(\"date.hour-before\"),\n};\n"],"names":[],"mappings":"AAQA,MAAM,cAAc,CACnB,UAMW;AACP,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,IAAI,MAAM,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAC3C;AAEG,MAAA,OAAO,UAAU,UAAU;AAC9B,WAAO,IAAI;AAAA,EACX;AAED,MAAI,iBAAiB,MAAM;AACnB,WAAA,GAAG,MAAM,QAAO;AAAA,EACvB;AAED,SAAO,GAAG;AACX;AAWA,MAAM,qBAAqB,CAAyB,SAAgB;AAI7D,QAAA,KAAK,CAAC,SAAiB,SAAsB;AAClD,UAAM,gBAAgB,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI;AACrD,UAAM,SAAS,QAAQ,KAAK,SAAS,OAAO;AAErC,WAAA,IAAI,QAAQ,OAAO,SAAS;AAAA,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ourcesContent":["import type { DateField } from \"../types/value/date\";\nimport type { TimestampField } from \"../types/value/timestamp\";\n\n/**\n * The return type of `asDate()`.\n */\ntype AsDateReturnType<\n\tField extends DateField | TimestampField | null | undefined,\n> = Field extends DateField<\"filled\"> | TimestampField<\"filled\"> ? Date : null;\n\n/**\n * Transforms a Date or Timestamp field into a JavaScript Date object\n *\n * @param dateOrTimestampField - A Date or Timestamp field from Prismic\n *\n * @returns A Date object, null if provided date is falsy\n * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp}\n */\nexport const asDate = <\n\tField extends DateField | TimestampField | null | undefined,\n>(\n\tdateOrTimestampField: Field,\n): AsDateReturnType<Field> => {\n\tif (!dateOrTimestampField) {\n\t\treturn null as AsDateReturnType<Field>;\n\t}\n\n\t// If field is a timestamp field...\n\tif (dateOrTimestampField.length === 24) {\n\t\t/**\n\t\t * Converts basic ISO 8601 to ECMAScript simplified ISO 8601 format for\n\t\t * browser compatibility issues\n\t\t *\n\t\t * From: YYYY-MM-DDTHH:mm:ssZ To: YYYY-MM-DDTHH:mm:ss.sssZ\n\t\t *\n\t\t * @see MDN documentation: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#timestamp_string}\n\t\t * @see ECMAScript 2020 language specification: {@link https://262.ecma-international.org/11.0/#sec-date-time-string-format}\n\t\t * @see Related forum issue: {@link https://community.prismic.io/t/prismics-date-api/2520}\n\t\t * @see Regex101 expression: {@link https://regex101.com/r/jxyETT/1}\n\t\t */\n\t\treturn new Date(\n\t\t\tdateOrTimestampField.replace(/(\\+|-)(\\d{2})(\\d{2})$/, \".000$1$2:$3\"),\n\t\t) as AsDateReturnType<Field>;\n\t} else {\n\t\t// ...else field is a date field\n\t\treturn new Date(dateOrTimestampField) as AsDateReturnType<Field>;\n\t}\n};\n"],"names":[],"mappings":";;AAkBa,MAAA,SAAS,CAGrB,yBAC4B;AAC5B,MAAI,CAAC,sBAAsB;AACnB,WAAA;AAAA,EACP;AAGG,MAAA,qBAAqB,WAAW,IAAI;AAYvC,WAAO,IAAI,KACV,qBAAqB,QAAQ,yBAAyB,aAAa,CAAC;AAAA,EAAA,OAE/D;AAEC,WAAA,IAAI,KAAK,oBAAoB;AAAA,EACpC;AACF;;"}
1
+ {"version":3,"file":"asDate.cjs","sources":["../../../src/helpers/asDate.ts"],"sourcesContent":["import type { DateField } from \"../types/value/date\";\nimport type { TimestampField } from \"../types/value/timestamp\";\n\n/**\n * The return type of `asDate()`.\n */\ntype AsDateReturnType<\n\tField extends DateField | TimestampField | null | undefined,\n> = Field extends DateField<\"filled\"> | TimestampField<\"filled\"> ? Date : null;\n\n/**\n * Transforms a date or timestamp field into a JavaScript Date object\n *\n * @param dateOrTimestampField - A date or timestamp field from Prismic\n *\n * @returns A Date object, null if provided date is falsy\n * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp}\n */\nexport const asDate = <\n\tField extends DateField | TimestampField | null | undefined,\n>(\n\tdateOrTimestampField: Field,\n): AsDateReturnType<Field> => {\n\tif (!dateOrTimestampField) {\n\t\treturn null as AsDateReturnType<Field>;\n\t}\n\n\t// If field is a timestamp field...\n\tif (dateOrTimestampField.length === 24) {\n\t\t/**\n\t\t * Converts basic ISO 8601 to ECMAScript simplified ISO 8601 format for\n\t\t * browser compatibility issues\n\t\t *\n\t\t * From: YYYY-MM-DDTHH:mm:ssZ To: YYYY-MM-DDTHH:mm:ss.sssZ\n\t\t *\n\t\t * @see MDN documentation: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#timestamp_string}\n\t\t * @see ECMAScript 2020 language specification: {@link https://262.ecma-international.org/11.0/#sec-date-time-string-format}\n\t\t * @see Related forum issue: {@link https://community.prismic.io/t/prismics-date-api/2520}\n\t\t * @see Regex101 expression: {@link https://regex101.com/r/jxyETT/1}\n\t\t */\n\t\treturn new Date(\n\t\t\tdateOrTimestampField.replace(/(\\+|-)(\\d{2})(\\d{2})$/, \".000$1$2:$3\"),\n\t\t) as AsDateReturnType<Field>;\n\t} else {\n\t\t// ...else field is a date field\n\t\treturn new Date(dateOrTimestampField) as AsDateReturnType<Field>;\n\t}\n};\n"],"names":[],"mappings":";;AAkBa,MAAA,SAAS,CAGrB,yBAC4B;AAC5B,MAAI,CAAC,sBAAsB;AACnB,WAAA;AAAA,EACP;AAGG,MAAA,qBAAqB,WAAW,IAAI;AAYvC,WAAO,IAAI,KACV,qBAAqB,QAAQ,yBAAyB,aAAa,CAAC;AAAA,EAAA,OAE/D;AAEC,WAAA,IAAI,KAAK,oBAAoB;AAAA,EACpC;AACF;;"}
@@ -5,9 +5,9 @@ import type { TimestampField } from "../types/value/timestamp";
5
5
  */
6
6
  type AsDateReturnType<Field extends DateField | TimestampField | null | undefined> = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null;
7
7
  /**
8
- * Transforms a Date or Timestamp field into a JavaScript Date object
8
+ * Transforms a date or timestamp field into a JavaScript Date object
9
9
  *
10
- * @param dateOrTimestampField - A Date or Timestamp field from Prismic
10
+ * @param dateOrTimestampField - A date or timestamp field from Prismic
11
11
  *
12
12
  * @returns A Date object, null if provided date is falsy
13
13
  * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp}
@@ -1 +1 @@
1
- {"version":3,"file":"asDate.js","sources":["../../../src/helpers/asDate.ts"],"sourcesContent":["import type { DateField } from \"../types/value/date\";\nimport type { TimestampField } from \"../types/value/timestamp\";\n\n/**\n * The return type of `asDate()`.\n */\ntype AsDateReturnType<\n\tField extends DateField | TimestampField | null | undefined,\n> = Field extends DateField<\"filled\"> | TimestampField<\"filled\"> ? Date : null;\n\n/**\n * Transforms a Date or Timestamp field into a JavaScript Date object\n *\n * @param dateOrTimestampField - A Date or Timestamp field from Prismic\n *\n * @returns A Date object, null if provided date is falsy\n * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp}\n */\nexport const asDate = <\n\tField extends DateField | TimestampField | null | undefined,\n>(\n\tdateOrTimestampField: Field,\n): AsDateReturnType<Field> => {\n\tif (!dateOrTimestampField) {\n\t\treturn null as AsDateReturnType<Field>;\n\t}\n\n\t// If field is a timestamp field...\n\tif (dateOrTimestampField.length === 24) {\n\t\t/**\n\t\t * Converts basic ISO 8601 to ECMAScript simplified ISO 8601 format for\n\t\t * browser compatibility issues\n\t\t *\n\t\t * From: YYYY-MM-DDTHH:mm:ssZ To: YYYY-MM-DDTHH:mm:ss.sssZ\n\t\t *\n\t\t * @see MDN documentation: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#timestamp_string}\n\t\t * @see ECMAScript 2020 language specification: {@link https://262.ecma-international.org/11.0/#sec-date-time-string-format}\n\t\t * @see Related forum issue: {@link https://community.prismic.io/t/prismics-date-api/2520}\n\t\t * @see Regex101 expression: {@link https://regex101.com/r/jxyETT/1}\n\t\t */\n\t\treturn new Date(\n\t\t\tdateOrTimestampField.replace(/(\\+|-)(\\d{2})(\\d{2})$/, \".000$1$2:$3\"),\n\t\t) as AsDateReturnType<Field>;\n\t} else {\n\t\t// ...else field is a date field\n\t\treturn new Date(dateOrTimestampField) as AsDateReturnType<Field>;\n\t}\n};\n"],"names":[],"mappings":"AAkBa,MAAA,SAAS,CAGrB,yBAC4B;AAC5B,MAAI,CAAC,sBAAsB;AACnB,WAAA;AAAA,EACP;AAGG,MAAA,qBAAqB,WAAW,IAAI;AAYvC,WAAO,IAAI,KACV,qBAAqB,QAAQ,yBAAyB,aAAa,CAAC;AAAA,EAAA,OAE/D;AAEC,WAAA,IAAI,KAAK,oBAAoB;AAAA,EACpC;AACF;"}
1
+ {"version":3,"file":"asDate.js","sources":["../../../src/helpers/asDate.ts"],"sourcesContent":["import type { DateField } from \"../types/value/date\";\nimport type { TimestampField } from \"../types/value/timestamp\";\n\n/**\n * The return type of `asDate()`.\n */\ntype AsDateReturnType<\n\tField extends DateField | TimestampField | null | undefined,\n> = Field extends DateField<\"filled\"> | TimestampField<\"filled\"> ? Date : null;\n\n/**\n * Transforms a date or timestamp field into a JavaScript Date object\n *\n * @param dateOrTimestampField - A date or timestamp field from Prismic\n *\n * @returns A Date object, null if provided date is falsy\n * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp}\n */\nexport const asDate = <\n\tField extends DateField | TimestampField | null | undefined,\n>(\n\tdateOrTimestampField: Field,\n): AsDateReturnType<Field> => {\n\tif (!dateOrTimestampField) {\n\t\treturn null as AsDateReturnType<Field>;\n\t}\n\n\t// If field is a timestamp field...\n\tif (dateOrTimestampField.length === 24) {\n\t\t/**\n\t\t * Converts basic ISO 8601 to ECMAScript simplified ISO 8601 format for\n\t\t * browser compatibility issues\n\t\t *\n\t\t * From: YYYY-MM-DDTHH:mm:ssZ To: YYYY-MM-DDTHH:mm:ss.sssZ\n\t\t *\n\t\t * @see MDN documentation: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#timestamp_string}\n\t\t * @see ECMAScript 2020 language specification: {@link https://262.ecma-international.org/11.0/#sec-date-time-string-format}\n\t\t * @see Related forum issue: {@link https://community.prismic.io/t/prismics-date-api/2520}\n\t\t * @see Regex101 expression: {@link https://regex101.com/r/jxyETT/1}\n\t\t */\n\t\treturn new Date(\n\t\t\tdateOrTimestampField.replace(/(\\+|-)(\\d{2})(\\d{2})$/, \".000$1$2:$3\"),\n\t\t) as AsDateReturnType<Field>;\n\t} else {\n\t\t// ...else field is a date field\n\t\treturn new Date(dateOrTimestampField) as AsDateReturnType<Field>;\n\t}\n};\n"],"names":[],"mappings":"AAkBa,MAAA,SAAS,CAGrB,yBAC4B;AAC5B,MAAI,CAAC,sBAAsB;AACnB,WAAA;AAAA,EACP;AAGG,MAAA,qBAAqB,WAAW,IAAI;AAYvC,WAAO,IAAI,KACV,qBAAqB,QAAQ,yBAAyB,aAAa,CAAC;AAAA,EAAA,OAE/D;AAEC,WAAA,IAAI,KAAK,oBAAoB;AAAA,EACpC;AACF;"}
@@ -65,21 +65,21 @@ const wrapMapSerializerWithStringChildren = (mapSerializer) => {
65
65
  };
66
66
  const asHTML = (richTextField, ...configObjectOrTuple) => {
67
67
  if (richTextField) {
68
- const [configObjectOrLinkResolver, maybeHTMLRichTextSerializer] = configObjectOrTuple;
68
+ const [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple;
69
69
  let config;
70
70
  if (typeof configObjectOrLinkResolver === "function" || configObjectOrLinkResolver == null) {
71
71
  config = {
72
72
  linkResolver: configObjectOrLinkResolver,
73
- htmlRichTextSerializer: maybeHTMLRichTextSerializer
73
+ serializer: maybeSerializer
74
74
  };
75
75
  } else {
76
76
  config = { ...configObjectOrLinkResolver };
77
77
  }
78
78
  let serializer;
79
- if (config.htmlRichTextSerializer) {
80
- serializer = richtext.composeSerializers(typeof config.htmlRichTextSerializer === "object" ? wrapMapSerializerWithStringChildren(config.htmlRichTextSerializer) : (type, node, text, children, key) => (
79
+ if (config.serializer) {
80
+ serializer = richtext.composeSerializers(typeof config.serializer === "object" ? wrapMapSerializerWithStringChildren(config.serializer) : (type, node, text, children, key) => (
81
81
  // TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.
82
- config.htmlRichTextSerializer(type, node, text, children.join(""), key)
82
+ config.serializer(type, node, text, children.join(""), key)
83
83
  ), createDefaultHTMLRichTextSerializer(config.linkResolver));
84
84
  } else {
85
85
  serializer = createDefaultHTMLRichTextSerializer(config.linkResolver);
@@ -1 +1 @@
1
- {"version":3,"file":"asHTML.cjs","sources":["../../../src/helpers/asHTML.ts"],"sourcesContent":["import {\n\tElement,\n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n\tRichTextMapSerializerFunction,\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n} from \"@prismicio/richtext\";\n\nimport {\n\tserializeEmbed,\n\tserializeHyperlink,\n\tserializeImage,\n\tserializePreFormatted,\n\tserializeSpan,\n\tserializeStandardTag,\n} from \"../lib/serializerHelpers\";\n\nimport type { RichTextField } from \"../types/value/richText\";\n\nimport { LinkResolverFunction } from \"./asLink\";\n\n/**\n * Serializes a node from a Rich Text or Title field with a function to HTML.\n *\n * Unlike a typical `@prismicio/richtext` function serializer, this serializer\n * converts the `children` argument to a single string rather than an array of\n * strings.\n *\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextFunctionSerializer = (\n\ttype: Parameters<RichTextFunctionSerializer<string>>[0],\n\tnode: Parameters<RichTextFunctionSerializer<string>>[1],\n\ttext: Parameters<RichTextFunctionSerializer<string>>[2],\n\tchildren: Parameters<RichTextFunctionSerializer<string>>[3][number],\n\tkey: Parameters<RichTextFunctionSerializer<string>>[4],\n) => string | null | undefined;\n\n/**\n * Serializes a node from a Rich Text or Title field with a map to HTML\n *\n * Unlike a typical `@prismicio/richtext` map serializer, this serializer\n * converts the `children` property to a single string rather than an array of\n * strings.\n *\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: (payload: {\n\t\ttype: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"type\"];\n\t\tnode: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"node\"];\n\t\ttext: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"text\"];\n\t\tchildren: Parameters<\n\t\t\tHTMLRichTextMapSerializerFunction<P>\n\t\t>[0][\"children\"][number];\n\t\tkey: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"key\"];\n\t}) => string | null | undefined;\n};\n\n/**\n * A {@link RichTextMapSerializerFunction} type specifically for\n * {@link HTMLRichTextMapSerializer}.\n *\n * @typeParam BlockName - The serializer's Rich Text block type.\n */\ntype HTMLRichTextMapSerializerFunction<\n\tBlockType extends keyof RichTextMapSerializer<string>,\n> = RichTextMapSerializerFunction<\n\tstring,\n\tExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,\n\tExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>\n>;\n\n/**\n * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `Node` generic.\n */\ntype ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany\n>\n\t? U\n\t: never;\n\n/**\n * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `TextType` generic.\n */\ntype ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U\n>\n\t? U\n\t: never;\n\n/**\n * Serializes a node from a Rich Text or Title field with a map or a function to HTML\n *\n * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextSerializer =\n\t| HTMLRichTextMapSerializer\n\t| HTMLRichTextFunctionSerializer;\n\n/**\n * Creates a default HTML Rich Text Serializer with a given Link Resolver providing\n * sensible and safe defaults for every node type\n *\n * @internal\n */\nconst createDefaultHTMLRichTextSerializer = (\n\tlinkResolver: LinkResolverFunction | undefined | null,\n): RichTextFunctionSerializer<string> => {\n\treturn (_type, node, text, children, _key) => {\n\t\tswitch (node.type) {\n\t\t\tcase Element.heading1:\n\t\t\t\treturn serializeStandardTag(\"h1\", node, children);\n\t\t\tcase Element.heading2:\n\t\t\t\treturn serializeStandardTag(\"h2\", node, children);\n\t\t\tcase Element.heading3:\n\t\t\t\treturn serializeStandardTag(\"h3\", node, children);\n\t\t\tcase Element.heading4:\n\t\t\t\treturn serializeStandardTag(\"h4\", node, children);\n\t\t\tcase Element.heading5:\n\t\t\t\treturn serializeStandardTag(\"h5\", node, children);\n\t\t\tcase Element.heading6:\n\t\t\t\treturn serializeStandardTag(\"h6\", node, children);\n\t\t\tcase Element.paragraph:\n\t\t\t\treturn serializeStandardTag(\"p\", node, children);\n\t\t\tcase Element.preformatted:\n\t\t\t\treturn serializePreFormatted(node);\n\t\t\tcase Element.strong:\n\t\t\t\treturn serializeStandardTag(\"strong\", node, children);\n\t\t\tcase Element.em:\n\t\t\t\treturn serializeStandardTag(\"em\", node, children);\n\t\t\tcase Element.listItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.oListItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.list:\n\t\t\t\treturn serializeStandardTag(\"ul\", node, children);\n\t\t\tcase Element.oList:\n\t\t\t\treturn serializeStandardTag(\"ol\", node, children);\n\t\t\tcase Element.image:\n\t\t\t\treturn serializeImage(linkResolver, node);\n\t\t\tcase Element.embed:\n\t\t\t\treturn serializeEmbed(node);\n\t\t\tcase Element.hyperlink:\n\t\t\t\treturn serializeHyperlink(linkResolver, node, children);\n\t\t\tcase Element.label:\n\t\t\t\treturn serializeStandardTag(\"span\", node, children);\n\t\t\tcase Element.span:\n\t\t\tdefault:\n\t\t\t\treturn serializeSpan(text);\n\t\t}\n\t};\n};\n\n/**\n * Wraps a map serializer into a regular function serializer. The given map\n * serializer should accept children as a string, not as an array of strings\n * like `@prismicio/richtext`'s `wrapMapSerializer`.\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nconst wrapMapSerializerWithStringChildren = (\n\tmapSerializer: HTMLRichTextMapSerializer,\n): RichTextFunctionSerializer<string> => {\n\tconst modifiedMapSerializer = {} as RichTextMapSerializer<string>;\n\n\tfor (const tag in mapSerializer) {\n\t\tconst tagSerializer = mapSerializer[tag as keyof typeof mapSerializer];\n\n\t\tif (tagSerializer) {\n\t\t\tmodifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {\n\t\t\t\treturn tagSerializer({\n\t\t\t\t\t...payload,\n\t\t\t\t\t// @ts-expect-error - merging blockSerializer types causes TS to bail to a never type\n\t\t\t\t\tchildren: payload.children.join(\"\"),\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\t}\n\n\treturn wrapMapSerializer(modifiedMapSerializer);\n};\n\n/**\n * Configuration that determines the output of `asHTML()`.\n */\ntype AsHTMLConfig = {\n\t/**\n\t * An optional link resolver function to resolve links.\n\t * Without it you're expected to use the `routes` options from the API.\n\t */\n\tlinkResolver?: LinkResolverFunction | null;\n\n\t/**\n\t * An optional Rich Text Serializer, unhandled cases will fallback to the default serializer\n\t */\n\thtmlRichTextSerializer?: HTMLRichTextSerializer | null;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsHTMLDeprecatedTupleConfig = [\n\tlinkResolver?: LinkResolverFunction | null,\n\thtmlRichTextSerializer?: HTMLRichTextSerializer | null,\n];\n\n/**\n * The return type of `asHTML()`.\n */\ntype AsHTMLReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asHTML: {\n\t/**\n\t * Serializes a Rich Text or Title field to an HTML string.\n\t *\n\t * @param richTextField - A Rich Text or Title field from Prismic\n\t * @param config - Configuration that determines the output of `asHTML()`\n\t *\n\t * @returns HTML equivalent of the provided Rich Text or Title field\n\t * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsHTMLConfig,\n\t): AsHTMLReturnType<Field>;\n\n\t/**\n\t * Serializes a Rich Text or Title field to an HTML string.\n\t *\n\t * @param richTextField - A Rich Text or Title field from Prismic\n\t * @param linkResolver - An optional link resolver function to resolve links,\n\t * without it you're expected to use the `routes` options from the API\n\t * @param htmlRichTextSerializer - An optional Rich Text Serializer, unhandled cases will fallback\n\t * to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided Rich Text or Title field\n\t * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asHTML(field);\n\t * asHTML(field, { linkResolver });\n\t * asHTML(field, { htmlRichTextSerializer });\n\t * asHTML(field, { linkResolver, htmlRichTextSerializer });\n\t * ```\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsHTMLDeprecatedTupleConfig\n\t): AsHTMLReturnType<Field>;\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsHTMLConfig] | AsHTMLDeprecatedTupleConfig\n): AsHTMLReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrLinkResolver, maybeHTMLRichTextSerializer] =\n\t\t\tconfigObjectOrTuple;\n\t\tlet config: AsHTMLConfig;\n\t\tif (\n\t\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\t\tconfigObjectOrLinkResolver == null\n\t\t) {\n\t\t\tconfig = {\n\t\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t\t\thtmlRichTextSerializer: maybeHTMLRichTextSerializer,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrLinkResolver };\n\t\t}\n\n\t\tlet serializer: RichTextFunctionSerializer<string>;\n\t\tif (config.htmlRichTextSerializer) {\n\t\t\tserializer = composeSerializers(\n\t\t\t\ttypeof config.htmlRichTextSerializer === \"object\"\n\t\t\t\t\t? wrapMapSerializerWithStringChildren(config.htmlRichTextSerializer)\n\t\t\t\t\t: (type, node, text, children, key) =>\n\t\t\t\t\t\t\t// TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.\n\t\t\t\t\t\t\t(config.htmlRichTextSerializer as HTMLRichTextFunctionSerializer)(\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t\tchildren.join(\"\"),\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t),\n\t\t\t\tcreateDefaultHTMLRichTextSerializer(config.linkResolver),\n\t\t\t);\n\t\t} else {\n\t\t\tserializer = createDefaultHTMLRichTextSerializer(config.linkResolver);\n\t\t}\n\n\t\treturn serialize(richTextField, serializer).join(\n\t\t\t\"\",\n\t\t) as AsHTMLReturnType<Field>;\n\t} else {\n\t\treturn null as AsHTMLReturnType<Field>;\n\t}\n};\n"],"names":["Element","serializeStandardTag","serializePreFormatted","serializeImage","serializeEmbed","serializeHyperlink","serializeSpan","wrapMapSerializer","composeSerializers","serialize"],"mappings":";;;;AA2HA,MAAM,sCAAsC,CAC3C,iBACuC;AACvC,SAAO,CAAC,OAAO,MAAM,MAAM,UAAU,SAAQ;AAC5C,YAAQ,KAAK,MAAM;AAAA,MAClB,KAAKA,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACj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pB,GAAG;AAAA;AAAA,UAEH,UAAU,QAAQ,SAAS,KAAK,EAAE;AAAA,QAAA,CAClC;AAAA,MAAA;AAAA,IAEF;AAAA,EACD;AAED,SAAOC,SAAAA,kBAAkB,qBAAqB;AAC/C;AAkCa,MAAA,SAwCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,4BAA4B,2BAA2B,IAC7D;AACG,QAAA;AACJ,QACC,OAAO,+BAA+B,cACtC,8BAA8B,MAC7B;AACQ,eAAA;AAAA,QACR,cAAc;AAAA,QACd,wBAAwB;AAAA,MAAA;AAAA,WAEnB;AACG,eAAA,EAAE,GAAG;IACd;AAEG,QAAA;AACJ,QAAI,OAAO,wBAAwB;AAClC,mBAAaC,SAAAA,mBACZ,OAAO,OAAO,2BAA2B,WACtC,oCAAoC,OAAO,sBAAsB,IACjE,CAAC,MAAM,MAAM,MAAM,UAAU;AAAA;AAAA,QAE5B,OAAO,uBACP,MACA,MACA,MACA,SAAS,KAAK,EAAE,GAChB,GAAG;AAAA,SAEP,oCAAoC,OAAO,YAAY,CAAC;AAAA,IAAA,OAEnD;AACO,mBAAA,oCAAoC,OAAO,YAAY;AAAA,IACpE;AAED,WAAOC,SAAAA,UAAU,eAAe,UAAU,EAAE,KAC3C,EAAE;AAAA,EAAA,OAEG;AACC,WAAA;AAAA,EACP;AACF;;"}
1
+ {"version":3,"file":"asHTML.cjs","sources":["../../../src/helpers/asHTML.ts"],"sourcesContent":["import {\n\tElement,\n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n\tRichTextMapSerializerFunction,\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n} from \"@prismicio/richtext\";\n\nimport {\n\tserializeEmbed,\n\tserializeHyperlink,\n\tserializeImage,\n\tserializePreFormatted,\n\tserializeSpan,\n\tserializeStandardTag,\n} from \"../lib/serializerHelpers\";\n\nimport type { RichTextField } from \"../types/value/richText\";\n\nimport { LinkResolverFunction } from \"./asLink\";\n\n/**\n * Serializes a node from a rich text or title field with a function to HTML.\n *\n * Unlike a typical `@prismicio/richtext` function serializer, this serializer\n * converts the `children` argument to a single string rather than an array of\n * strings.\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextFunctionSerializer = (\n\ttype: Parameters<RichTextFunctionSerializer<string>>[0],\n\tnode: Parameters<RichTextFunctionSerializer<string>>[1],\n\ttext: Parameters<RichTextFunctionSerializer<string>>[2],\n\tchildren: Parameters<RichTextFunctionSerializer<string>>[3][number],\n\tkey: Parameters<RichTextFunctionSerializer<string>>[4],\n) => string | null | undefined;\n\n/**\n * Serializes a node from a rich text or title field with a map to HTML\n *\n * Unlike a typical `@prismicio/richtext` map serializer, this serializer\n * converts the `children` property to a single string rather than an array of\n * strings.\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: (payload: {\n\t\ttype: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"type\"];\n\t\tnode: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"node\"];\n\t\ttext: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"text\"];\n\t\tchildren: Parameters<\n\t\t\tHTMLRichTextMapSerializerFunction<P>\n\t\t>[0][\"children\"][number];\n\t\tkey: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"key\"];\n\t}) => string | null | undefined;\n};\n\n/**\n * A {@link RichTextMapSerializerFunction} type specifically for\n * {@link HTMLRichTextMapSerializer}.\n *\n * @typeParam BlockName - The serializer's rich text block type.\n */\ntype HTMLRichTextMapSerializerFunction<\n\tBlockType extends keyof RichTextMapSerializer<string>,\n> = RichTextMapSerializerFunction<\n\tstring,\n\tExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,\n\tExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>\n>;\n\n/**\n * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `Node` generic.\n */\ntype ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany\n>\n\t? U\n\t: never;\n\n/**\n * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `TextType` generic.\n */\ntype ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U\n>\n\t? U\n\t: never;\n\n/**\n * Serializes a node from a rich text or title field with a map or a function to HTML\n *\n * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextSerializer =\n\t| HTMLRichTextMapSerializer\n\t| HTMLRichTextFunctionSerializer;\n\n/**\n * Creates a default HTML rich text serializer with a given link resolver providing\n * sensible and safe defaults for every node type\n *\n * @internal\n */\nconst createDefaultHTMLRichTextSerializer = (\n\tlinkResolver: LinkResolverFunction | undefined | null,\n): RichTextFunctionSerializer<string> => {\n\treturn (_type, node, text, children, _key) => {\n\t\tswitch (node.type) {\n\t\t\tcase Element.heading1:\n\t\t\t\treturn serializeStandardTag(\"h1\", node, children);\n\t\t\tcase Element.heading2:\n\t\t\t\treturn serializeStandardTag(\"h2\", node, children);\n\t\t\tcase Element.heading3:\n\t\t\t\treturn serializeStandardTag(\"h3\", node, children);\n\t\t\tcase Element.heading4:\n\t\t\t\treturn serializeStandardTag(\"h4\", node, children);\n\t\t\tcase Element.heading5:\n\t\t\t\treturn serializeStandardTag(\"h5\", node, children);\n\t\t\tcase Element.heading6:\n\t\t\t\treturn serializeStandardTag(\"h6\", node, children);\n\t\t\tcase Element.paragraph:\n\t\t\t\treturn serializeStandardTag(\"p\", node, children);\n\t\t\tcase Element.preformatted:\n\t\t\t\treturn serializePreFormatted(node);\n\t\t\tcase Element.strong:\n\t\t\t\treturn serializeStandardTag(\"strong\", node, children);\n\t\t\tcase Element.em:\n\t\t\t\treturn serializeStandardTag(\"em\", node, children);\n\t\t\tcase Element.listItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.oListItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.list:\n\t\t\t\treturn serializeStandardTag(\"ul\", node, children);\n\t\t\tcase Element.oList:\n\t\t\t\treturn serializeStandardTag(\"ol\", node, children);\n\t\t\tcase Element.image:\n\t\t\t\treturn serializeImage(linkResolver, node);\n\t\t\tcase Element.embed:\n\t\t\t\treturn serializeEmbed(node);\n\t\t\tcase Element.hyperlink:\n\t\t\t\treturn serializeHyperlink(linkResolver, node, children);\n\t\t\tcase Element.label:\n\t\t\t\treturn serializeStandardTag(\"span\", node, children);\n\t\t\tcase Element.span:\n\t\t\tdefault:\n\t\t\t\treturn serializeSpan(text);\n\t\t}\n\t};\n};\n\n/**\n * Wraps a map serializer into a regular function serializer. The given map\n * serializer should accept children as a string, not as an array of strings\n * like `@prismicio/richtext`'s `wrapMapSerializer`.\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nconst wrapMapSerializerWithStringChildren = (\n\tmapSerializer: HTMLRichTextMapSerializer,\n): RichTextFunctionSerializer<string> => {\n\tconst modifiedMapSerializer = {} as RichTextMapSerializer<string>;\n\n\tfor (const tag in mapSerializer) {\n\t\tconst tagSerializer = mapSerializer[tag as keyof typeof mapSerializer];\n\n\t\tif (tagSerializer) {\n\t\t\tmodifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {\n\t\t\t\treturn tagSerializer({\n\t\t\t\t\t...payload,\n\t\t\t\t\t// @ts-expect-error - merging blockSerializer types causes TS to bail to a never type\n\t\t\t\t\tchildren: payload.children.join(\"\"),\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\t}\n\n\treturn wrapMapSerializer(modifiedMapSerializer);\n};\n\n/**\n * Configuration that determines the output of `asHTML()`.\n */\ntype AsHTMLConfig = {\n\t/**\n\t * An optional link resolver function to resolve links.\n\t * Without it you're expected to use the `routes` options from the API.\n\t */\n\tlinkResolver?: LinkResolverFunction | null;\n\n\t/**\n\t * An optional rich text serializer, unhandled cases will fallback to the default serializer\n\t */\n\tserializer?: HTMLRichTextSerializer | null;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsHTMLDeprecatedTupleConfig = [\n\tlinkResolver?: LinkResolverFunction | null,\n\tserializer?: HTMLRichTextSerializer | null,\n];\n\n/**\n * The return type of `asHTML()`.\n */\ntype AsHTMLReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asHTML: {\n\t/**\n\t * Serializes a rich text or title field to an HTML string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param config - Configuration that determines the output of `asHTML()`\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsHTMLConfig,\n\t): AsHTMLReturnType<Field>;\n\n\t/**\n\t * Serializes a rich text or title field to an HTML string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param linkResolver - An optional link resolver function to resolve links,\n\t * without it you're expected to use the `routes` options from the API\n\t * @param serializer - An optional rich text serializer, unhandled cases will fallback\n\t * to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asHTML(field);\n\t * asHTML(field, { linkResolver });\n\t * asHTML(field, { serializer });\n\t * asHTML(field, { linkResolver, serializer });\n\t * ```\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsHTMLDeprecatedTupleConfig\n\t): AsHTMLReturnType<Field>;\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsHTMLConfig] | AsHTMLDeprecatedTupleConfig\n): AsHTMLReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple;\n\t\tlet config: AsHTMLConfig;\n\t\tif (\n\t\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\t\tconfigObjectOrLinkResolver == null\n\t\t) {\n\t\t\tconfig = {\n\t\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t\t\tserializer: maybeSerializer,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrLinkResolver };\n\t\t}\n\n\t\tlet serializer: RichTextFunctionSerializer<string>;\n\t\tif (config.serializer) {\n\t\t\tserializer = composeSerializers(\n\t\t\t\ttypeof config.serializer === \"object\"\n\t\t\t\t\t? wrapMapSerializerWithStringChildren(config.serializer)\n\t\t\t\t\t: (type, node, text, children, key) =>\n\t\t\t\t\t\t\t// TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.\n\t\t\t\t\t\t\t(config.serializer as HTMLRichTextFunctionSerializer)(\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t\tchildren.join(\"\"),\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t),\n\t\t\t\tcreateDefaultHTMLRichTextSerializer(config.linkResolver),\n\t\t\t);\n\t\t} else {\n\t\t\tserializer = createDefaultHTMLRichTextSerializer(config.linkResolver);\n\t\t}\n\n\t\treturn serialize(richTextField, serializer).join(\n\t\t\t\"\",\n\t\t) as AsHTMLReturnType<Field>;\n\t} else {\n\t\treturn null as AsHTMLReturnType<Field>;\n\t}\n};\n"],"names":["Element","serializeStandardTag","serializePreFormatted","serializeImage","serializeEmbed","serializeHyperlink","serializeSpan","wrapMapSerializer","composeSerializers","serialize"],"mappings":";;;;AA2HA,MAAM,sCAAsC,CAC3C,iBACuC;AACvC,SAAO,CAAC,OAAO,MAAM,MAAM,UAAU,SAAQ;AAC5C,YAAQ,KAAK,MAAM;AAAA,MAClB,KAAKA,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAKD,SAAQ,QAAA;AACL,eAAAC,uCAAqB,KAAK,MAAM,QAAQ;AAAA,MAChD,KAAKD,SAAQ,QAAA;AACZ,eAAOE,kBAAAA,sBAAsB,IAAI;AAAA,MAClC,KAAKF,SAAQ,QAAA;AACL,eAAAC,uCAAqB,UAAU,MAAM,QAAQ;AAAA,MACrD,KAAKD,SAAQ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A8B,MAC7B;AACQ,eAAA;AAAA,QACR,cAAc;AAAA,QACd,YAAY;AAAA,MAAA;AAAA,WAEP;AACG,eAAA,EAAE,GAAG;IACd;AAEG,QAAA;AACJ,QAAI,OAAO,YAAY;AACtB,mBAAaC,SAAAA,mBACZ,OAAO,OAAO,eAAe,WAC1B,oCAAoC,OAAO,UAAU,IACrD,CAAC,MAAM,MAAM,MAAM,UAAU;AAAA;AAAA,QAE5B,OAAO,WACP,MACA,MACA,MACA,SAAS,KAAK,EAAE,GAChB,GAAG;AAAA,SAEP,oCAAoC,OAAO,YAAY,CAAC;AAAA,IAAA,OAEnD;AACO,mBAAA,oCAAoC,OAAO,YAAY;AAAA,IACpE;AAED,WAAOC,SAAAA,UAAU,eAAe,UAAU,EAAE,KAC3C,EAAE;AAAA,EAAA,OAEG;AACC,WAAA;AAAA,EACP;AACF;;"}
@@ -2,23 +2,23 @@ import { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerialize
2
2
  import type { RichTextField } from "../types/value/richText";
3
3
  import { LinkResolverFunction } from "./asLink";
4
4
  /**
5
- * Serializes a node from a Rich Text or Title field with a function to HTML.
5
+ * Serializes a node from a rich text or title field with a function to HTML.
6
6
  *
7
7
  * Unlike a typical `@prismicio/richtext` function serializer, this serializer
8
8
  * converts the `children` argument to a single string rather than an array of
9
9
  * strings.
10
10
  *
11
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
11
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
12
12
  */
13
13
  export type HTMLRichTextFunctionSerializer = (type: Parameters<RichTextFunctionSerializer<string>>[0], node: Parameters<RichTextFunctionSerializer<string>>[1], text: Parameters<RichTextFunctionSerializer<string>>[2], children: Parameters<RichTextFunctionSerializer<string>>[3][number], key: Parameters<RichTextFunctionSerializer<string>>[4]) => string | null | undefined;
14
14
  /**
15
- * Serializes a node from a Rich Text or Title field with a map to HTML
15
+ * Serializes a node from a rich text or title field with a map to HTML
16
16
  *
17
17
  * Unlike a typical `@prismicio/richtext` map serializer, this serializer
18
18
  * converts the `children` property to a single string rather than an array of
19
19
  * strings.
20
20
  *
21
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
21
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
22
22
  */
23
23
  export type HTMLRichTextMapSerializer = {
24
24
  [P in keyof RichTextMapSerializer<string>]: (payload: {
@@ -33,7 +33,7 @@ export type HTMLRichTextMapSerializer = {
33
33
  * A {@link RichTextMapSerializerFunction} type specifically for
34
34
  * {@link HTMLRichTextMapSerializer}.
35
35
  *
36
- * @typeParam BlockName - The serializer's Rich Text block type.
36
+ * @typeParam BlockName - The serializer's rich text block type.
37
37
  */
38
38
  type HTMLRichTextMapSerializerFunction<BlockType extends keyof RichTextMapSerializer<string>> = RichTextMapSerializerFunction<string, ExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>, ExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>>;
39
39
  /**
@@ -51,10 +51,10 @@ type ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<any, infer
51
51
  */
52
52
  type ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<any, any, infer U> ? U : never;
53
53
  /**
54
- * Serializes a node from a Rich Text or Title field with a map or a function to HTML
54
+ * Serializes a node from a rich text or title field with a map or a function to HTML
55
55
  *
56
56
  * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}
57
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
57
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
58
58
  */
59
59
  export type HTMLRichTextSerializer = HTMLRichTextMapSerializer | HTMLRichTextFunctionSerializer;
60
60
  /**
@@ -67,16 +67,16 @@ type AsHTMLConfig = {
67
67
  */
68
68
  linkResolver?: LinkResolverFunction | null;
69
69
  /**
70
- * An optional Rich Text Serializer, unhandled cases will fallback to the default serializer
70
+ * An optional rich text serializer, unhandled cases will fallback to the default serializer
71
71
  */
72
- htmlRichTextSerializer?: HTMLRichTextSerializer | null;
72
+ serializer?: HTMLRichTextSerializer | null;
73
73
  };
74
74
  /**
75
75
  * @deprecated Use object-style configuration instead.
76
76
  */
77
77
  type AsHTMLDeprecatedTupleConfig = [
78
78
  linkResolver?: LinkResolverFunction | null,
79
- htmlRichTextSerializer?: HTMLRichTextSerializer | null
79
+ serializer?: HTMLRichTextSerializer | null
80
80
  ];
81
81
  /**
82
82
  * The return type of `asHTML()`.
@@ -84,34 +84,34 @@ type AsHTMLDeprecatedTupleConfig = [
84
84
  type AsHTMLReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField ? string : null;
85
85
  export declare const asHTML: {
86
86
  /**
87
- * Serializes a Rich Text or Title field to an HTML string.
87
+ * Serializes a rich text or title field to an HTML string.
88
88
  *
89
- * @param richTextField - A Rich Text or Title field from Prismic
89
+ * @param richTextField - A rich text or title field from Prismic
90
90
  * @param config - Configuration that determines the output of `asHTML()`
91
91
  *
92
- * @returns HTML equivalent of the provided Rich Text or Title field
93
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
92
+ * @returns HTML equivalent of the provided rich text or title field
93
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
94
94
  */
95
95
  <Field extends RichTextField | null | undefined>(richTextField: Field, config?: AsHTMLConfig): AsHTMLReturnType<Field>;
96
96
  /**
97
- * Serializes a Rich Text or Title field to an HTML string.
97
+ * Serializes a rich text or title field to an HTML string.
98
98
  *
99
- * @param richTextField - A Rich Text or Title field from Prismic
99
+ * @param richTextField - A rich text or title field from Prismic
100
100
  * @param linkResolver - An optional link resolver function to resolve links,
101
101
  * without it you're expected to use the `routes` options from the API
102
- * @param htmlRichTextSerializer - An optional Rich Text Serializer, unhandled cases will fallback
102
+ * @param serializer - An optional rich text serializer, unhandled cases will fallback
103
103
  * to the default serializer
104
104
  *
105
- * @returns HTML equivalent of the provided Rich Text or Title field
106
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
105
+ * @returns HTML equivalent of the provided rich text or title field
106
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
107
107
  *
108
108
  * @deprecated Use object-style configuration instead.
109
109
  *
110
110
  * ```ts
111
111
  * asHTML(field);
112
112
  * asHTML(field, { linkResolver });
113
- * asHTML(field, { htmlRichTextSerializer });
114
- * asHTML(field, { linkResolver, htmlRichTextSerializer });
113
+ * asHTML(field, { serializer });
114
+ * asHTML(field, { linkResolver, serializer });
115
115
  * ```
116
116
  */
117
117
  <Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsHTMLDeprecatedTupleConfig): AsHTMLReturnType<Field>;
@@ -63,21 +63,21 @@ const wrapMapSerializerWithStringChildren = (mapSerializer) => {
63
63
  };
64
64
  const asHTML = (richTextField, ...configObjectOrTuple) => {
65
65
  if (richTextField) {
66
- const [configObjectOrLinkResolver, maybeHTMLRichTextSerializer] = configObjectOrTuple;
66
+ const [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple;
67
67
  let config;
68
68
  if (typeof configObjectOrLinkResolver === "function" || configObjectOrLinkResolver == null) {
69
69
  config = {
70
70
  linkResolver: configObjectOrLinkResolver,
71
- htmlRichTextSerializer: maybeHTMLRichTextSerializer
71
+ serializer: maybeSerializer
72
72
  };
73
73
  } else {
74
74
  config = { ...configObjectOrLinkResolver };
75
75
  }
76
76
  let serializer;
77
- if (config.htmlRichTextSerializer) {
78
- serializer = composeSerializers(typeof config.htmlRichTextSerializer === "object" ? wrapMapSerializerWithStringChildren(config.htmlRichTextSerializer) : (type, node, text, children, key) => (
77
+ if (config.serializer) {
78
+ serializer = composeSerializers(typeof config.serializer === "object" ? wrapMapSerializerWithStringChildren(config.serializer) : (type, node, text, children, key) => (
79
79
  // TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.
80
- config.htmlRichTextSerializer(type, node, text, children.join(""), key)
80
+ config.serializer(type, node, text, children.join(""), key)
81
81
  ), createDefaultHTMLRichTextSerializer(config.linkResolver));
82
82
  } else {
83
83
  serializer = createDefaultHTMLRichTextSerializer(config.linkResolver);
@@ -1 +1 @@
1
- {"version":3,"file":"asHTML.js","sources":["../../../src/helpers/asHTML.ts"],"sourcesContent":["import {\n\tElement,\n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n\tRichTextMapSerializerFunction,\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n} from \"@prismicio/richtext\";\n\nimport {\n\tserializeEmbed,\n\tserializeHyperlink,\n\tserializeImage,\n\tserializePreFormatted,\n\tserializeSpan,\n\tserializeStandardTag,\n} from \"../lib/serializerHelpers\";\n\nimport type { RichTextField } from \"../types/value/richText\";\n\nimport { LinkResolverFunction } from \"./asLink\";\n\n/**\n * Serializes a node from a Rich Text or Title field with a function to HTML.\n *\n * Unlike a typical `@prismicio/richtext` function serializer, this serializer\n * converts the `children` argument to a single string rather than an array of\n * strings.\n *\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextFunctionSerializer = (\n\ttype: Parameters<RichTextFunctionSerializer<string>>[0],\n\tnode: Parameters<RichTextFunctionSerializer<string>>[1],\n\ttext: Parameters<RichTextFunctionSerializer<string>>[2],\n\tchildren: Parameters<RichTextFunctionSerializer<string>>[3][number],\n\tkey: Parameters<RichTextFunctionSerializer<string>>[4],\n) => string | null | undefined;\n\n/**\n * Serializes a node from a Rich Text or Title field with a map to HTML\n *\n * Unlike a typical `@prismicio/richtext` map serializer, this serializer\n * converts the `children` property to a single string rather than an array of\n * strings.\n *\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: (payload: {\n\t\ttype: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"type\"];\n\t\tnode: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"node\"];\n\t\ttext: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"text\"];\n\t\tchildren: Parameters<\n\t\t\tHTMLRichTextMapSerializerFunction<P>\n\t\t>[0][\"children\"][number];\n\t\tkey: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"key\"];\n\t}) => string | null | undefined;\n};\n\n/**\n * A {@link RichTextMapSerializerFunction} type specifically for\n * {@link HTMLRichTextMapSerializer}.\n *\n * @typeParam BlockName - The serializer's Rich Text block type.\n */\ntype HTMLRichTextMapSerializerFunction<\n\tBlockType extends keyof RichTextMapSerializer<string>,\n> = RichTextMapSerializerFunction<\n\tstring,\n\tExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,\n\tExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>\n>;\n\n/**\n * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `Node` generic.\n */\ntype ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany\n>\n\t? U\n\t: never;\n\n/**\n * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `TextType` generic.\n */\ntype ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U\n>\n\t? U\n\t: never;\n\n/**\n * Serializes a node from a Rich Text or Title field with a map or a function to HTML\n *\n * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}\n * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextSerializer =\n\t| HTMLRichTextMapSerializer\n\t| HTMLRichTextFunctionSerializer;\n\n/**\n * Creates a default HTML Rich Text Serializer with a given Link Resolver providing\n * sensible and safe defaults for every node type\n *\n * @internal\n */\nconst createDefaultHTMLRichTextSerializer = (\n\tlinkResolver: LinkResolverFunction | undefined | null,\n): RichTextFunctionSerializer<string> => {\n\treturn (_type, node, text, children, _key) => {\n\t\tswitch (node.type) {\n\t\t\tcase Element.heading1:\n\t\t\t\treturn serializeStandardTag(\"h1\", node, children);\n\t\t\tcase Element.heading2:\n\t\t\t\treturn serializeStandardTag(\"h2\", node, children);\n\t\t\tcase Element.heading3:\n\t\t\t\treturn serializeStandardTag(\"h3\", node, children);\n\t\t\tcase Element.heading4:\n\t\t\t\treturn serializeStandardTag(\"h4\", node, children);\n\t\t\tcase Element.heading5:\n\t\t\t\treturn serializeStandardTag(\"h5\", node, children);\n\t\t\tcase Element.heading6:\n\t\t\t\treturn serializeStandardTag(\"h6\", node, children);\n\t\t\tcase Element.paragraph:\n\t\t\t\treturn serializeStandardTag(\"p\", node, children);\n\t\t\tcase Element.preformatted:\n\t\t\t\treturn serializePreFormatted(node);\n\t\t\tcase Element.strong:\n\t\t\t\treturn serializeStandardTag(\"strong\", node, children);\n\t\t\tcase Element.em:\n\t\t\t\treturn serializeStandardTag(\"em\", node, children);\n\t\t\tcase Element.listItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.oListItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.list:\n\t\t\t\treturn serializeStandardTag(\"ul\", node, children);\n\t\t\tcase Element.oList:\n\t\t\t\treturn serializeStandardTag(\"ol\", node, children);\n\t\t\tcase Element.image:\n\t\t\t\treturn serializeImage(linkResolver, node);\n\t\t\tcase Element.embed:\n\t\t\t\treturn serializeEmbed(node);\n\t\t\tcase Element.hyperlink:\n\t\t\t\treturn serializeHyperlink(linkResolver, node, children);\n\t\t\tcase Element.label:\n\t\t\t\treturn serializeStandardTag(\"span\", node, children);\n\t\t\tcase Element.span:\n\t\t\tdefault:\n\t\t\t\treturn serializeSpan(text);\n\t\t}\n\t};\n};\n\n/**\n * Wraps a map serializer into a regular function serializer. The given map\n * serializer should accept children as a string, not as an array of strings\n * like `@prismicio/richtext`'s `wrapMapSerializer`.\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nconst wrapMapSerializerWithStringChildren = (\n\tmapSerializer: HTMLRichTextMapSerializer,\n): RichTextFunctionSerializer<string> => {\n\tconst modifiedMapSerializer = {} as RichTextMapSerializer<string>;\n\n\tfor (const tag in mapSerializer) {\n\t\tconst tagSerializer = mapSerializer[tag as keyof typeof mapSerializer];\n\n\t\tif (tagSerializer) {\n\t\t\tmodifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {\n\t\t\t\treturn tagSerializer({\n\t\t\t\t\t...payload,\n\t\t\t\t\t// @ts-expect-error - merging blockSerializer types causes TS to bail to a never type\n\t\t\t\t\tchildren: payload.children.join(\"\"),\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\t}\n\n\treturn wrapMapSerializer(modifiedMapSerializer);\n};\n\n/**\n * Configuration that determines the output of `asHTML()`.\n */\ntype AsHTMLConfig = {\n\t/**\n\t * An optional link resolver function to resolve links.\n\t * Without it you're expected to use the `routes` options from the API.\n\t */\n\tlinkResolver?: LinkResolverFunction | null;\n\n\t/**\n\t * An optional Rich Text Serializer, unhandled cases will fallback to the default serializer\n\t */\n\thtmlRichTextSerializer?: HTMLRichTextSerializer | null;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsHTMLDeprecatedTupleConfig = [\n\tlinkResolver?: LinkResolverFunction | null,\n\thtmlRichTextSerializer?: HTMLRichTextSerializer | null,\n];\n\n/**\n * The return type of `asHTML()`.\n */\ntype AsHTMLReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asHTML: {\n\t/**\n\t * Serializes a Rich Text or Title field to an HTML string.\n\t *\n\t * @param richTextField - A Rich Text or Title field from Prismic\n\t * @param config - Configuration that determines the output of `asHTML()`\n\t *\n\t * @returns HTML equivalent of the provided Rich Text or Title field\n\t * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsHTMLConfig,\n\t): AsHTMLReturnType<Field>;\n\n\t/**\n\t * Serializes a Rich Text or Title field to an HTML string.\n\t *\n\t * @param richTextField - A Rich Text or Title field from Prismic\n\t * @param linkResolver - An optional link resolver function to resolve links,\n\t * without it you're expected to use the `routes` options from the API\n\t * @param htmlRichTextSerializer - An optional Rich Text Serializer, unhandled cases will fallback\n\t * to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided Rich Text or Title field\n\t * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asHTML(field);\n\t * asHTML(field, { linkResolver });\n\t * asHTML(field, { htmlRichTextSerializer });\n\t * asHTML(field, { linkResolver, htmlRichTextSerializer });\n\t * ```\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsHTMLDeprecatedTupleConfig\n\t): AsHTMLReturnType<Field>;\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsHTMLConfig] | AsHTMLDeprecatedTupleConfig\n): AsHTMLReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrLinkResolver, maybeHTMLRichTextSerializer] =\n\t\t\tconfigObjectOrTuple;\n\t\tlet config: AsHTMLConfig;\n\t\tif (\n\t\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\t\tconfigObjectOrLinkResolver == null\n\t\t) {\n\t\t\tconfig = {\n\t\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t\t\thtmlRichTextSerializer: maybeHTMLRichTextSerializer,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrLinkResolver };\n\t\t}\n\n\t\tlet serializer: RichTextFunctionSerializer<string>;\n\t\tif (config.htmlRichTextSerializer) {\n\t\t\tserializer = composeSerializers(\n\t\t\t\ttypeof config.htmlRichTextSerializer === \"object\"\n\t\t\t\t\t? wrapMapSerializerWithStringChildren(config.htmlRichTextSerializer)\n\t\t\t\t\t: (type, node, text, children, key) =>\n\t\t\t\t\t\t\t// TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.\n\t\t\t\t\t\t\t(config.htmlRichTextSerializer as HTMLRichTextFunctionSerializer)(\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t\tchildren.join(\"\"),\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t),\n\t\t\t\tcreateDefaultHTMLRichTextSerializer(config.linkResolver),\n\t\t\t);\n\t\t} else {\n\t\t\tserializer = createDefaultHTMLRichTextSerializer(config.linkResolver);\n\t\t}\n\n\t\treturn serialize(richTextField, serializer).join(\n\t\t\t\"\",\n\t\t) as AsHTMLReturnType<Field>;\n\t} else {\n\t\treturn null as AsH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n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n\tRichTextMapSerializerFunction,\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n} from \"@prismicio/richtext\";\n\nimport {\n\tserializeEmbed,\n\tserializeHyperlink,\n\tserializeImage,\n\tserializePreFormatted,\n\tserializeSpan,\n\tserializeStandardTag,\n} from \"../lib/serializerHelpers\";\n\nimport type { RichTextField } from \"../types/value/richText\";\n\nimport { LinkResolverFunction } from \"./asLink\";\n\n/**\n * Serializes a node from a rich text or title field with a function to HTML.\n *\n * Unlike a typical `@prismicio/richtext` function serializer, this serializer\n * converts the `children` argument to a single string rather than an array of\n * strings.\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextFunctionSerializer = (\n\ttype: Parameters<RichTextFunctionSerializer<string>>[0],\n\tnode: Parameters<RichTextFunctionSerializer<string>>[1],\n\ttext: Parameters<RichTextFunctionSerializer<string>>[2],\n\tchildren: Parameters<RichTextFunctionSerializer<string>>[3][number],\n\tkey: Parameters<RichTextFunctionSerializer<string>>[4],\n) => string | null | undefined;\n\n/**\n * Serializes a node from a rich text or title field with a map to HTML\n *\n * Unlike a typical `@prismicio/richtext` map serializer, this serializer\n * converts the `children` property to a single string rather than an array of\n * strings.\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: (payload: {\n\t\ttype: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"type\"];\n\t\tnode: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"node\"];\n\t\ttext: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"text\"];\n\t\tchildren: Parameters<\n\t\t\tHTMLRichTextMapSerializerFunction<P>\n\t\t>[0][\"children\"][number];\n\t\tkey: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"key\"];\n\t}) => string | null | undefined;\n};\n\n/**\n * A {@link RichTextMapSerializerFunction} type specifically for\n * {@link HTMLRichTextMapSerializer}.\n *\n * @typeParam BlockName - The serializer's rich text block type.\n */\ntype HTMLRichTextMapSerializerFunction<\n\tBlockType extends keyof RichTextMapSerializer<string>,\n> = RichTextMapSerializerFunction<\n\tstring,\n\tExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,\n\tExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>\n>;\n\n/**\n * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `Node` generic.\n */\ntype ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany\n>\n\t? U\n\t: never;\n\n/**\n * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `TextType` generic.\n */\ntype ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tany,\n\tinfer U\n>\n\t? U\n\t: never;\n\n/**\n * Serializes a node from a rich text or title field with a map or a function to HTML\n *\n * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n */\nexport type HTMLRichTextSerializer =\n\t| HTMLRichTextMapSerializer\n\t| HTMLRichTextFunctionSerializer;\n\n/**\n * Creates a default HTML rich text serializer with a given link resolver providing\n * sensible and safe defaults for every node type\n *\n * @internal\n */\nconst createDefaultHTMLRichTextSerializer = (\n\tlinkResolver: LinkResolverFunction | undefined | null,\n): RichTextFunctionSerializer<string> => {\n\treturn (_type, node, text, children, _key) => {\n\t\tswitch (node.type) {\n\t\t\tcase Element.heading1:\n\t\t\t\treturn serializeStandardTag(\"h1\", node, children);\n\t\t\tcase Element.heading2:\n\t\t\t\treturn serializeStandardTag(\"h2\", node, children);\n\t\t\tcase Element.heading3:\n\t\t\t\treturn serializeStandardTag(\"h3\", node, children);\n\t\t\tcase Element.heading4:\n\t\t\t\treturn serializeStandardTag(\"h4\", node, children);\n\t\t\tcase Element.heading5:\n\t\t\t\treturn serializeStandardTag(\"h5\", node, children);\n\t\t\tcase Element.heading6:\n\t\t\t\treturn serializeStandardTag(\"h6\", node, children);\n\t\t\tcase Element.paragraph:\n\t\t\t\treturn serializeStandardTag(\"p\", node, children);\n\t\t\tcase Element.preformatted:\n\t\t\t\treturn serializePreFormatted(node);\n\t\t\tcase Element.strong:\n\t\t\t\treturn serializeStandardTag(\"strong\", node, children);\n\t\t\tcase Element.em:\n\t\t\t\treturn serializeStandardTag(\"em\", node, children);\n\t\t\tcase Element.listItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.oListItem:\n\t\t\t\treturn serializeStandardTag(\"li\", node, children);\n\t\t\tcase Element.list:\n\t\t\t\treturn serializeStandardTag(\"ul\", node, children);\n\t\t\tcase Element.oList:\n\t\t\t\treturn serializeStandardTag(\"ol\", node, children);\n\t\t\tcase Element.image:\n\t\t\t\treturn serializeImage(linkResolver, node);\n\t\t\tcase Element.embed:\n\t\t\t\treturn serializeEmbed(node);\n\t\t\tcase Element.hyperlink:\n\t\t\t\treturn serializeHyperlink(linkResolver, node, children);\n\t\t\tcase Element.label:\n\t\t\t\treturn serializeStandardTag(\"span\", node, children);\n\t\t\tcase Element.span:\n\t\t\tdefault:\n\t\t\t\treturn serializeSpan(text);\n\t\t}\n\t};\n};\n\n/**\n * Wraps a map serializer into a regular function serializer. The given map\n * serializer should accept children as a string, not as an array of strings\n * like `@prismicio/richtext`'s `wrapMapSerializer`.\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nconst wrapMapSerializerWithStringChildren = (\n\tmapSerializer: HTMLRichTextMapSerializer,\n): RichTextFunctionSerializer<string> => {\n\tconst modifiedMapSerializer = {} as RichTextMapSerializer<string>;\n\n\tfor (const tag in mapSerializer) {\n\t\tconst tagSerializer = mapSerializer[tag as keyof typeof mapSerializer];\n\n\t\tif (tagSerializer) {\n\t\t\tmodifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {\n\t\t\t\treturn tagSerializer({\n\t\t\t\t\t...payload,\n\t\t\t\t\t// @ts-expect-error - merging blockSerializer types causes TS to bail to a never type\n\t\t\t\t\tchildren: payload.children.join(\"\"),\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\t}\n\n\treturn wrapMapSerializer(modifiedMapSerializer);\n};\n\n/**\n * Configuration that determines the output of `asHTML()`.\n */\ntype AsHTMLConfig = {\n\t/**\n\t * An optional link resolver function to resolve links.\n\t * Without it you're expected to use the `routes` options from the API.\n\t */\n\tlinkResolver?: LinkResolverFunction | null;\n\n\t/**\n\t * An optional rich text serializer, unhandled cases will fallback to the default serializer\n\t */\n\tserializer?: HTMLRichTextSerializer | null;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsHTMLDeprecatedTupleConfig = [\n\tlinkResolver?: LinkResolverFunction | null,\n\tserializer?: HTMLRichTextSerializer | null,\n];\n\n/**\n * The return type of `asHTML()`.\n */\ntype AsHTMLReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asHTML: {\n\t/**\n\t * Serializes a rich text or title field to an HTML string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param config - Configuration that determines the output of `asHTML()`\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsHTMLConfig,\n\t): AsHTMLReturnType<Field>;\n\n\t/**\n\t * Serializes a rich text or title field to an HTML string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param linkResolver - An optional link resolver function to resolve links,\n\t * without it you're expected to use the `routes` options from the API\n\t * @param serializer - An optional rich text serializer, unhandled cases will fallback\n\t * to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asHTML(field);\n\t * asHTML(field, { linkResolver });\n\t * asHTML(field, { serializer });\n\t * asHTML(field, { linkResolver, serializer });\n\t * ```\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsHTMLDeprecatedTupleConfig\n\t): AsHTMLReturnType<Field>;\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsHTMLConfig] | AsHTMLDeprecatedTupleConfig\n): AsHTMLReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple;\n\t\tlet config: AsHTMLConfig;\n\t\tif (\n\t\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\t\tconfigObjectOrLinkResolver == null\n\t\t) {\n\t\t\tconfig = {\n\t\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t\t\tserializer: maybeSerializer,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrLinkResolver };\n\t\t}\n\n\t\tlet serializer: RichTextFunctionSerializer<string>;\n\t\tif (config.serializer) {\n\t\t\tserializer = composeSerializers(\n\t\t\t\ttypeof config.serializer === \"object\"\n\t\t\t\t\t? wrapMapSerializerWithStringChildren(config.serializer)\n\t\t\t\t\t: (type, node, text, children, key) =>\n\t\t\t\t\t\t\t// TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.\n\t\t\t\t\t\t\t(config.serializer as HTMLRichTextFunctionSerializer)(\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t\tchildren.join(\"\"),\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t),\n\t\t\t\tcreateDefaultHTMLRichTextSerializer(config.linkResolver),\n\t\t\t);\n\t\t} else {\n\t\t\tserializer = createDefaultHTMLRichTextSerializer(config.linkResolver);\n\t\t}\n\n\t\treturn serialize(richTextField, serializer).join(\n\t\t\t\"\",\n\t\t) as AsHTMLReturnType<Field>;\n\t} else {\n\t\treturn null as AsHTMLReturnType<Field>;\n\t}\n};\n"],"names":[],"mappings":";;AA2HA,MAAM,sCAAsC,CAC3C,iBACuC;AACvC,SAAO,CAAC,OAAO,MAAM,MAAM,UAAU,SAAQ;AAC5C,YAAQ,KAAK,MAAM;AAAA,MAClB,KAAK,QAAQ;AACL,eAAA,qBAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAK,QAAQ;AACL,eAAA,qBAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAK,QAAQ;AACL,eAAA,qBAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAK,QAAQ;AACL,eAAA,qBAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAK,QAAQ;AACL,eAAA,qBAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAK,QAAQ;AACL,eAAA,qBAAqB,MAAM,MAAM,QAAQ;AAAA,MACjD,KAAK,QAAQ;AACL,eAAA,qBAAqB,KAAK,MAAM,QAAQ;AAAA,MAChD,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cACtC,8BAA8B,MAC7B;AACQ,eAAA;AAAA,QACR,cAAc;AAAA,QACd,YAAY;AAAA,MAAA;AAAA,WAEP;AACG,eAAA,EAAE,GAAG;IACd;AAEG,QAAA;AACJ,QAAI,OAAO,YAAY;AACtB,mBAAa,mBACZ,OAAO,OAAO,eAAe,WAC1B,oCAAoC,OAAO,UAAU,IACrD,CAAC,MAAM,MAAM,MAAM,UAAU;AAAA;AAAA,QAE5B,OAAO,WACP,MACA,MACA,MACA,SAAS,KAAK,EAAE,GAChB,GAAG;AAAA,SAEP,oCAAoC,OAAO,YAAY,CAAC;AAAA,IAAA,OAEnD;AACO,mBAAA,oCAAoC,OAAO,YAAY;AAAA,IACpE;AAED,WAAO,UAAU,eAAe,UAAU,EAAE,KAC3C,EAAE;AAAA,EAAA,OAEG;AACC,WAAA;AAAA,EACP;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asImagePixelDensitySrcSet.cjs","sources":["../../../src/helpers/asImagePixelDensitySrcSet.ts"],"sourcesContent":["import {\n\tBuildPixelDensitySrcSetParams,\n\tbuildPixelDensitySrcSet,\n\tbuildURL,\n} from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\";\n\n/**\n * The default pixel densities used to generate a `srcset` value.\n */\nconst DEFAULT_PIXEL_DENSITIES = [1, 2, 3];\n\n/**\n * Configuration for `asImagePixelDensitySrcSet()`.\n */\ntype AsImagePixelDensitySrcSetConfig = Omit<\n\tBuildPixelDensitySrcSetParams,\n\t\"pixelDensities\"\n> &\n\tPartial<Pick<BuildPixelDensitySrcSetParams, \"pixelDensities\">>;\n\n/**\n * The return type of `asImagePixelDensitySrcSet()`.\n */\ntype AsImagePixelDensitySrcSetReturnType<\n\tField extends ImageFieldImage | null | undefined,\n> = Field extends ImageFieldImage<\"filled\">\n\t? {\n\t\t\t/**\n\t\t\t * The Image field's image URL with Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrc: string;\n\n\t\t\t/**\n\t\t\t * A pixel-densitye-based `srcset` attribute value for the Image field's\n\t\t\t * image with Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrcset: string;\n\t }\n\t: null;\n\n/**\n * Creates a pixel-density-based `srcset` from an Image field with optional\n * image transformations (via Imgix URL parameters).\n *\n * If a `pixelDensities` parameter is not given, the following pixel densities\n * will be used by default: 1, 2, 3.\n *\n * @example\n *\n * ```ts\n * const srcset = asImagePixelDensitySrcSet(document.data.imageField, {\n * \tpixelDensities: [1, 2],\n * \tsat: -100,\n * });\n * // => {\n * // src: 'https://images.prismic.io/repo/image.png?sat=-100',\n * // srcset: 'https://images.prismic.io/repo/image.png?sat=-100&dpr=1 1x, ' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&dpr=2 2x'\n * // }\n * ```\n *\n * @param field - Image field (or one of its responsive views) from which to get\n * an image URL.\n * @param config - An object of Imgix URL API parameters. The `pixelDensities`\n * parameter defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for the Image field with Imgix URL\n * parameters (if given). If the Image field is empty, `null` is returned.\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImagePixelDensitySrcSet = <\n\tField extends ImageFieldImage | null | undefined,\n>(\n\tfield: Field,\n\tconfig: AsImagePixelDensitySrcSetConfig = {},\n): AsImagePixelDensitySrcSetReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\t// We are using destructuring to omit `pixelDensities` from the\n\t\t// object we will pass to `buildURL()`.\n\t\tconst { pixelDensities = DEFAULT_PIXEL_DENSITIES, ...imgixParams } = config;\n\n\t\treturn {\n\t\t\tsrc: buildURL(field.url, imgixParams),\n\t\t\tsrcset: buildPixelDensitySrcSet(field.url, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities,\n\t\t\t}),\n\t\t} as AsImagePixelDensitySrcSetReturnType<Field>;\n\t} else {\n\t\treturn null as AsImagePixelDensitySrcSetReturnType<Field>;\n\t}\n};\n"],"names":["isImageThumbnailFilled","buildURL","buildPixelDensitySrcSet"],"mappings":";;;;AAaA,MAAM,0BAA0B,CAAC,GAAG,GAAG,CAAC;AA6DjC,MAAM,4BAA4B,CAGxC,OACA,SAA0C,OACK;AAC3C,MAAA,SAASA,wBAAuB,KAAK,GAAG;AAG3C,UAAM,EAAE,iBAAiB,yBAAyB,GAAG,gBAAgB;AAE9D,WAAA;AAAA,MACN,KAAKC,gBAAA,SAAS,MAAM,KAAK,WAAW;AAAA,MACpC,QAAQC,gBAAAA,wBAAwB,MAAM,KAAK;AAAA,QAC1C,GAAG;AAAA,QACH;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,SAEI;AACC,WAAA;AAAA,EACP;AACF;;"}
1
+ {"version":3,"file":"asImagePixelDensitySrcSet.cjs","sources":["../../../src/helpers/asImagePixelDensitySrcSet.ts"],"sourcesContent":["import {\n\tBuildPixelDensitySrcSetParams,\n\tbuildPixelDensitySrcSet,\n\tbuildURL,\n} from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\";\n\n/**\n * The default pixel densities used to generate a `srcset` value.\n */\nconst DEFAULT_PIXEL_DENSITIES = [1, 2, 3];\n\n/**\n * Configuration for `asImagePixelDensitySrcSet()`.\n */\ntype AsImagePixelDensitySrcSetConfig = Omit<\n\tBuildPixelDensitySrcSetParams,\n\t\"pixelDensities\"\n> &\n\tPartial<Pick<BuildPixelDensitySrcSetParams, \"pixelDensities\">>;\n\n/**\n * The return type of `asImagePixelDensitySrcSet()`.\n */\ntype AsImagePixelDensitySrcSetReturnType<\n\tField extends ImageFieldImage | null | undefined,\n> = Field extends ImageFieldImage<\"filled\">\n\t? {\n\t\t\t/**\n\t\t\t * The image field's image URL with Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrc: string;\n\n\t\t\t/**\n\t\t\t * A pixel-densitye-based `srcset` attribute value for the image field's\n\t\t\t * image with Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrcset: string;\n\t }\n\t: null;\n\n/**\n * Creates a pixel-density-based `srcset` from an image field with optional\n * image transformations (via Imgix URL parameters).\n *\n * If a `pixelDensities` parameter is not given, the following pixel densities\n * will be used by default: 1, 2, 3.\n *\n * @example\n *\n * ```ts\n * const srcset = asImagePixelDensitySrcSet(document.data.imageField, {\n * \tpixelDensities: [1, 2],\n * \tsat: -100,\n * });\n * // => {\n * // src: 'https://images.prismic.io/repo/image.png?sat=-100',\n * // srcset: 'https://images.prismic.io/repo/image.png?sat=-100&dpr=1 1x, ' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&dpr=2 2x'\n * // }\n * ```\n *\n * @param field - Image field (or one of its responsive views) from which to get\n * an image URL.\n * @param config - An object of Imgix URL API parameters. The `pixelDensities`\n * parameter defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for the image field with Imgix URL\n * parameters (if given). If the image field is empty, `null` is returned.\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImagePixelDensitySrcSet = <\n\tField extends ImageFieldImage | null | undefined,\n>(\n\tfield: Field,\n\tconfig: AsImagePixelDensitySrcSetConfig = {},\n): AsImagePixelDensitySrcSetReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\t// We are using destructuring to omit `pixelDensities` from the\n\t\t// object we will pass to `buildURL()`.\n\t\tconst { pixelDensities = DEFAULT_PIXEL_DENSITIES, ...imgixParams } = config;\n\n\t\treturn {\n\t\t\tsrc: buildURL(field.url, imgixParams),\n\t\t\tsrcset: buildPixelDensitySrcSet(field.url, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities,\n\t\t\t}),\n\t\t} as AsImagePixelDensitySrcSetReturnType<Field>;\n\t} else {\n\t\treturn null as AsImagePixelDensitySrcSetReturnType<Field>;\n\t}\n};\n"],"names":["isImageThumbnailFilled","buildURL","buildPixelDensitySrcSet"],"mappings":";;;;AAaA,MAAM,0BAA0B,CAAC,GAAG,GAAG,CAAC;AA6DjC,MAAM,4BAA4B,CAGxC,OACA,SAA0C,OACK;AAC3C,MAAA,SAASA,wBAAuB,KAAK,GAAG;AAG3C,UAAM,EAAE,iBAAiB,yBAAyB,GAAG,gBAAgB;AAE9D,WAAA;AAAA,MACN,KAAKC,gBAAA,SAAS,MAAM,KAAK,WAAW;AAAA,MACpC,QAAQC,gBAAAA,wBAAwB,MAAM,KAAK;AAAA,QAC1C,GAAG;AAAA,QACH;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,SAEI;AACC,WAAA;AAAA,EACP;AACF;;"}
@@ -9,17 +9,17 @@ type AsImagePixelDensitySrcSetConfig = Omit<BuildPixelDensitySrcSetParams, "pixe
9
9
  */
10
10
  type AsImagePixelDensitySrcSetReturnType<Field extends ImageFieldImage | null | undefined> = Field extends ImageFieldImage<"filled"> ? {
11
11
  /**
12
- * The Image field's image URL with Imgix URL parameters (if given).
12
+ * The image field's image URL with Imgix URL parameters (if given).
13
13
  */
14
14
  src: string;
15
15
  /**
16
- * A pixel-densitye-based `srcset` attribute value for the Image field's
16
+ * A pixel-densitye-based `srcset` attribute value for the image field's
17
17
  * image with Imgix URL parameters (if given).
18
18
  */
19
19
  srcset: string;
20
20
  } : null;
21
21
  /**
22
- * Creates a pixel-density-based `srcset` from an Image field with optional
22
+ * Creates a pixel-density-based `srcset` from an image field with optional
23
23
  * image transformations (via Imgix URL parameters).
24
24
  *
25
25
  * If a `pixelDensities` parameter is not given, the following pixel densities
@@ -44,8 +44,8 @@ type AsImagePixelDensitySrcSetReturnType<Field extends ImageFieldImage | null |
44
44
  * @param config - An object of Imgix URL API parameters. The `pixelDensities`
45
45
  * parameter defines the resulting `srcset` widths.
46
46
  *
47
- * @returns A `srcset` attribute value for the Image field with Imgix URL
48
- * parameters (if given). If the Image field is empty, `null` is returned.
47
+ * @returns A `srcset` attribute value for the image field with Imgix URL
48
+ * parameters (if given). If the image field is empty, `null` is returned.
49
49
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
50
50
  */
51
51
  export declare const asImagePixelDensitySrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImagePixelDensitySrcSetConfig) => AsImagePixelDensitySrcSetReturnType<Field>;