@prismicio/client 7.1.0 → 7.1.1

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 (66) hide show
  1. package/dist/buildQueryURL.cjs.map +1 -1
  2. package/dist/buildQueryURL.d.ts +1 -0
  3. package/dist/buildQueryURL.js.map +1 -1
  4. package/dist/createClient.cjs +8 -1
  5. package/dist/createClient.cjs.map +1 -1
  6. package/dist/createClient.d.ts +8 -0
  7. package/dist/createClient.js +8 -1
  8. package/dist/createClient.js.map +1 -1
  9. package/dist/filter.cjs.map +1 -1
  10. package/dist/filter.js.map +1 -1
  11. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  12. package/dist/getGraphQLEndpoint.js.map +1 -1
  13. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  14. package/dist/getRepositoryEndpoint.js.map +1 -1
  15. package/dist/getRepositoryName.cjs.map +1 -1
  16. package/dist/getRepositoryName.d.ts +1 -0
  17. package/dist/getRepositoryName.js.map +1 -1
  18. package/dist/getToolbarSrc.cjs.map +1 -1
  19. package/dist/getToolbarSrc.js.map +1 -1
  20. package/dist/helpers/asHTML.cjs.map +1 -1
  21. package/dist/helpers/asHTML.d.ts +0 -6
  22. package/dist/helpers/asHTML.js.map +1 -1
  23. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  24. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -1
  25. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  26. package/dist/helpers/asImageSrc.cjs.map +1 -1
  27. package/dist/helpers/asImageSrc.d.ts +2 -1
  28. package/dist/helpers/asImageSrc.js.map +1 -1
  29. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  30. package/dist/helpers/asImageWidthSrcSet.d.ts +2 -1
  31. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  32. package/dist/helpers/asLink.cjs.map +1 -1
  33. package/dist/helpers/asLink.d.ts +3 -4
  34. package/dist/helpers/asLink.js.map +1 -1
  35. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  36. package/dist/helpers/asLinkAttrs.d.ts +3 -1
  37. package/dist/helpers/asLinkAttrs.js.map +1 -1
  38. package/dist/helpers/asText.cjs.map +1 -1
  39. package/dist/helpers/asText.d.ts +0 -4
  40. package/dist/helpers/asText.js.map +1 -1
  41. package/dist/helpers/isFilled.d.ts +13 -10
  42. package/dist/helpers/unstable_mapSliceZone.cjs.map +1 -1
  43. package/dist/helpers/unstable_mapSliceZone.d.ts +12 -5
  44. package/dist/helpers/unstable_mapSliceZone.js.map +1 -1
  45. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  46. package/dist/isRepositoryEndpoint.js.map +1 -1
  47. package/dist/lib/devMsg.cjs.map +1 -1
  48. package/dist/lib/devMsg.js.map +1 -1
  49. package/dist/lib/serializerHelpers.cjs.map +1 -1
  50. package/dist/lib/serializerHelpers.js.map +1 -1
  51. package/dist/package.json.cjs +1 -1
  52. package/dist/package.json.js +1 -1
  53. package/dist/types/api/repository.d.ts +6 -1
  54. package/package.json +20 -20
  55. package/src/buildQueryURL.ts +1 -0
  56. package/src/createClient.ts +9 -1
  57. package/src/getRepositoryName.ts +1 -0
  58. package/src/helpers/asHTML.ts +0 -6
  59. package/src/helpers/asImagePixelDensitySrcSet.ts +1 -0
  60. package/src/helpers/asImageSrc.ts +1 -0
  61. package/src/helpers/asImageWidthSrcSet.ts +1 -0
  62. package/src/helpers/asLink.ts +3 -4
  63. package/src/helpers/asLinkAttrs.ts +2 -0
  64. package/src/helpers/asText.ts +0 -4
  65. package/src/helpers/unstable_mapSliceZone.ts +19 -8
  66. package/src/types/api/repository.ts +6 -2
@@ -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 arguments.\n *\n * @typeParam Args - Arguments for the filter.\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 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 no\n * 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 exactly.\n\t * 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 as\n\t * 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 by\n\t * their IDs or UIDs. This filter is much more efficient at this than the any\n\t * 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 all\n\t * the documents of the specified type that contain a value for the specified\n\t * 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 the\n\t * 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 greater\n\t * 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 the\n\t * 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 date\n\t * 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 the\n\t * 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 equal\n\t * 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 is\n\t * 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 is\n\t * 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 to\n\t * 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 in\n\t * 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 in\n\t * 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 year\n\t * 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 the\n\t * 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 after\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\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;AAAA;AAAA;AAAA;AAAA,EAUN,KAAK,mBACJ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUN,IAAI,mBAAuC,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY/C,UAAU,mBAA0C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS9D,KAAK,WAAW,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrB,SAAS,WAAW,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7B,SAAS,WAAwC,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU1D,cACC,mBACC,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjB,gBAAgB,mBAAoC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/D,mBAAmB,mBAAoC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlE,eACC,mBACC,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlB,WAAW,mBAAmD,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1E,YAAY,mBAAmD,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5E,aACC,mBAEE,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,gBAAgB,mBAAkC,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrE,qBAAqB,mBACpB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS1B,sBAAsB,mBACrB,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS3B,eAAe,mBAA2C,kBAAkB;AAAA;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;;"}
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 arguments.\n *\n * @typeParam Args - Arguments for the filter.\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 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 no\n * 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 exactly.\n\t * 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 as\n\t * 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 by\n\t * their IDs or UIDs. This filter is much more efficient at this than the any\n\t * 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 all\n\t * the documents of the specified type that contain a value for the specified\n\t * 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 the\n\t * 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 greater\n\t * 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 the\n\t * 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 date\n\t * 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 the\n\t * 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 equal\n\t * 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 is\n\t * 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 is\n\t * 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 to\n\t * 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 in\n\t * 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 in\n\t * 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 year\n\t * 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 the\n\t * 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 after\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\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":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"getGraphQLEndpoint.cjs","sources":["../../src/getGraphQLEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic GraphQL endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic REST API V2 endpoint\n */\nexport const getGraphQLEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/graphql` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/graphql` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAaa,MAAA,qBAAqB,CACjC,mBACuD;AACnD,MAAAA,iBAAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW;AAAA,EAAA,OACZ;AACN,UAAM,IAAIC,aAAAA,aACT,iDAAiD,kBACjD,QACA,MAAS;AAAA,EAEV;AACF;;"}
1
+ {"version":3,"file":"getGraphQLEndpoint.cjs","sources":["../../src/getGraphQLEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic GraphQL endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic REST API V2 endpoint\n */\nexport const getGraphQLEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/graphql` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/graphql` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAaa,MAAA,qBAAqB,CACjC,mBACuD;AACnD,MAAAA,iBAAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW,cAAc;AAAA,EAAA,OAC1B;AACN,UAAM,IAAIC,aAAAA,aACT,iDAAiD,cAAc,IAC/D,QACA,MAAS;AAAA,EAEV;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getGraphQLEndpoint.js","sources":["../../src/getGraphQLEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic GraphQL endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic REST API V2 endpoint\n */\nexport const getGraphQLEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/graphql` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/graphql` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";;AAaa,MAAA,qBAAqB,CACjC,mBACuD;AACnD,MAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW;AAAA,EAAA,OACZ;AACN,UAAM,IAAI,aACT,iDAAiD,kBACjD,QACA,MAAS;AAAA,EAEV;AACF;"}
1
+ {"version":3,"file":"getGraphQLEndpoint.js","sources":["../../src/getGraphQLEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic GraphQL endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic REST API V2 endpoint\n */\nexport const getGraphQLEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/graphql` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/graphql` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";;AAaa,MAAA,qBAAqB,CACjC,mBACuD;AACnD,MAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW,cAAc;AAAA,EAAA,OAC1B;AACN,UAAM,IAAI,aACT,iDAAiD,cAAc,IAC/D,QACA,MAAS;AAAA,EAEV;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getRepositoryEndpoint.cjs","sources":["../../src/getRepositoryEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic Rest API V2 endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic Rest API V2 endpoint\n *\n * @throws {@link Error} Thrown if an invalid repository name is provided.\n */\nexport const getRepositoryEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/api/v2` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/api/v2` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAea,MAAA,wBAAwB,CACpC,mBACsD;AAClD,MAAAA,iBAAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW;AAAA,EAAA,OACZ;AACN,UAAM,IAAIC,aAAAA,aACT,iDAAiD,kBACjD,QACA,MAAS;AAAA,EAEV;AACF;;"}
1
+ {"version":3,"file":"getRepositoryEndpoint.cjs","sources":["../../src/getRepositoryEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic Rest API V2 endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic Rest API V2 endpoint\n *\n * @throws {@link Error} Thrown if an invalid repository name is provided.\n */\nexport const getRepositoryEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/api/v2` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/api/v2` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAea,MAAA,wBAAwB,CACpC,mBACsD;AAClD,MAAAA,iBAAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW,cAAc;AAAA,EAAA,OAC1B;AACN,UAAM,IAAIC,aAAAA,aACT,iDAAiD,cAAc,IAC/D,QACA,MAAS;AAAA,EAEV;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getRepositoryEndpoint.js","sources":["../../src/getRepositoryEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic Rest API V2 endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic Rest API V2 endpoint\n *\n * @throws {@link Error} Thrown if an invalid repository name is provided.\n */\nexport const getRepositoryEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/api/v2` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/api/v2` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";;AAea,MAAA,wBAAwB,CACpC,mBACsD;AAClD,MAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW;AAAA,EAAA,OACZ;AACN,UAAM,IAAI,aACT,iDAAiD,kBACjD,QACA,MAAS;AAAA,EAEV;AACF;"}
1
+ {"version":3,"file":"getRepositoryEndpoint.js","sources":["../../src/getRepositoryEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Get a repository's Prismic Rest API V2 endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic Rest API V2 endpoint\n *\n * @throws {@link Error} Thrown if an invalid repository name is provided.\n */\nexport const getRepositoryEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/api/v2` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/api/v2` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";;AAea,MAAA,wBAAwB,CACpC,mBACsD;AAClD,MAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,WAAW,cAAc;AAAA,EAAA,OAC1B;AACN,UAAM,IAAI,aACT,iDAAiD,cAAc,IAC/D,QACA,MAAS;AAAA,EAEV;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getRepositoryName.cjs","sources":["../../src/getRepositoryName.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\n/**\n * Get a Prismic repository's name from its standard Prismic Rest API V2 or\n * GraphQL endpoint.\n *\n * @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the\n * repository.\n * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.\n *\n * @returns The Prismic repository's name.\n *\n * @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is\n * provided.\n */\nexport const getRepositoryName = (repositoryEndpoint: string): string => {\n\ttry {\n\t\treturn new URL(repositoryEndpoint).hostname.split(\".\")[0];\n\t} catch {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic Rest API V2 endpoint was provided: ${repositoryEndpoint}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["PrismicError"],"mappings":";;;AAea,MAAA,oBAAoB,CAAC,uBAAsC;AACnE,MAAA;AACI,WAAA,IAAI,IAAI,kBAAkB,EAAE,SAAS,MAAM,GAAG,EAAE,CAAC;AAAA,EAAA,QACvD;AACD,UAAM,IAAIA,aAAAA,aACT,yDAAyD,sBACzD,QACA,MAAS;AAAA,EAEV;AACF;;"}
1
+ {"version":3,"file":"getRepositoryName.cjs","sources":["../../src/getRepositoryName.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\n/**\n * Get a Prismic repository's name from its standard Prismic Rest API V2 or\n * GraphQL endpoint.\n *\n * @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the\n * repository.\n *\n * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.\n *\n * @returns The Prismic repository's name.\n *\n * @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is\n * provided.\n */\nexport const getRepositoryName = (repositoryEndpoint: string): string => {\n\ttry {\n\t\treturn new URL(repositoryEndpoint).hostname.split(\".\")[0];\n\t} catch {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic Rest API V2 endpoint was provided: ${repositoryEndpoint}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["PrismicError"],"mappings":";;;AAgBa,MAAA,oBAAoB,CAAC,uBAAsC;AACnE,MAAA;AACI,WAAA,IAAI,IAAI,kBAAkB,EAAE,SAAS,MAAM,GAAG,EAAE,CAAC;AAAA,EAAA,QACjD;AACP,UAAM,IAAIA,aAAAA,aACT,yDAAyD,kBAAkB,IAC3E,QACA,MAAS;AAAA,EAEV;AACF;;"}
@@ -4,6 +4,7 @@
4
4
  *
5
5
  * @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the
6
6
  * repository.
7
+ *
7
8
  * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
8
9
  *
9
10
  * @returns The Prismic repository's name.
@@ -1 +1 @@
1
- {"version":3,"file":"getRepositoryName.js","sources":["../../src/getRepositoryName.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\n/**\n * Get a Prismic repository's name from its standard Prismic Rest API V2 or\n * GraphQL endpoint.\n *\n * @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the\n * repository.\n * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.\n *\n * @returns The Prismic repository's name.\n *\n * @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is\n * provided.\n */\nexport const getRepositoryName = (repositoryEndpoint: string): string => {\n\ttry {\n\t\treturn new URL(repositoryEndpoint).hostname.split(\".\")[0];\n\t} catch {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic Rest API V2 endpoint was provided: ${repositoryEndpoint}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";AAea,MAAA,oBAAoB,CAAC,uBAAsC;AACnE,MAAA;AACI,WAAA,IAAI,IAAI,kBAAkB,EAAE,SAAS,MAAM,GAAG,EAAE,CAAC;AAAA,EAAA,QACvD;AACD,UAAM,IAAI,aACT,yDAAyD,sBACzD,QACA,MAAS;AAAA,EAEV;AACF;"}
1
+ {"version":3,"file":"getRepositoryName.js","sources":["../../src/getRepositoryName.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\n/**\n * Get a Prismic repository's name from its standard Prismic Rest API V2 or\n * GraphQL endpoint.\n *\n * @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the\n * repository.\n *\n * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.\n *\n * @returns The Prismic repository's name.\n *\n * @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is\n * provided.\n */\nexport const getRepositoryName = (repositoryEndpoint: string): string => {\n\ttry {\n\t\treturn new URL(repositoryEndpoint).hostname.split(\".\")[0];\n\t} catch {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic Rest API V2 endpoint was provided: ${repositoryEndpoint}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";AAgBa,MAAA,oBAAoB,CAAC,uBAAsC;AACnE,MAAA;AACI,WAAA,IAAI,IAAI,kBAAkB,EAAE,SAAS,MAAM,GAAG,EAAE,CAAC;AAAA,EAAA,QACjD;AACP,UAAM,IAAI,aACT,yDAAyD,kBAAkB,IAC3E,QACA,MAAS;AAAA,EAEV;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.cjs","sources":["../../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the\n * URL to inject the script into your app.\n *\n * @example\n *\n * ```typescriptreact\n * // In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * import Script from \"next/script\";\n * import * as prismic from \"@prismicio/client\";\n *\n * export default function RootLayout({\n * \tchildren,\n * }: {\n * \tchildren: React.ReactNode,\n * }) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t\t<html lang=\"en\">\n * \t\t\t<body>{children}</body>\n * \t\t\t<Script src={toolbarSrc} />\n * \t\t</html>\n * \t);\n * }\n * ```\n *\n * @param repositoryName - The name of the Prismic repository. For example,\n * `\"my-repo\"` if the repository URL is `my-repo.prismic.io`.\n *\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAqCa,MAAA,gBAAgB,CAC5B,mBACgF;AAC5E,MAAAA,iBAAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,0DAA0D;AAAA,EAAA,OAC3D;AACN,UAAM,IAAIC,aAAAA,aACT,iDAAiD,kBACjD,QACA,MAAS;AAAA,EAEV;AACF;;"}
1
+ {"version":3,"file":"getToolbarSrc.cjs","sources":["../../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the\n * URL to inject the script into your app.\n *\n * @example\n *\n * ```typescriptreact\n * // In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * import Script from \"next/script\";\n * import * as prismic from \"@prismicio/client\";\n *\n * export default function RootLayout({\n * \tchildren,\n * }: {\n * \tchildren: React.ReactNode,\n * }) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t\t<html lang=\"en\">\n * \t\t\t<body>{children}</body>\n * \t\t\t<Script src={toolbarSrc} />\n * \t\t</html>\n * \t);\n * }\n * ```\n *\n * @param repositoryName - The name of the Prismic repository. For example,\n * `\"my-repo\"` if the repository URL is `my-repo.prismic.io`.\n *\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAqCa,MAAA,gBAAgB,CAC5B,mBACgF;AAC5E,MAAAA,iBAAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,0DAA0D,cAAc;AAAA,EAAA,OACzE;AACN,UAAM,IAAIC,aAAAA,aACT,iDAAiD,cAAc,IAC/D,QACA,MAAS;AAAA,EAEV;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.js","sources":["../../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the\n * URL to inject the script into your app.\n *\n * @example\n *\n * ```typescriptreact\n * // In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * import Script from \"next/script\";\n * import * as prismic from \"@prismicio/client\";\n *\n * export default function RootLayout({\n * \tchildren,\n * }: {\n * \tchildren: React.ReactNode,\n * }) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t\t<html lang=\"en\">\n * \t\t\t<body>{children}</body>\n * \t\t\t<Script src={toolbarSrc} />\n * \t\t</html>\n * \t);\n * }\n * ```\n *\n * @param repositoryName - The name of the Prismic repository. For example,\n * `\"my-repo\"` if the repository URL is `my-repo.prismic.io`.\n *\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";;AAqCa,MAAA,gBAAgB,CAC5B,mBACgF;AAC5E,MAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,0DAA0D;AAAA,EAAA,OAC3D;AACN,UAAM,IAAI,aACT,iDAAiD,kBACjD,QACA,MAAS;AAAA,EAEV;AACF;"}
1
+ {"version":3,"file":"getToolbarSrc.js","sources":["../../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError\";\n\nimport { isRepositoryName } from \"./isRepositoryName\";\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the\n * URL to inject the script into your app.\n *\n * @example\n *\n * ```typescriptreact\n * // In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * import Script from \"next/script\";\n * import * as prismic from \"@prismicio/client\";\n *\n * export default function RootLayout({\n * \tchildren,\n * }: {\n * \tchildren: React.ReactNode,\n * }) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t\t<html lang=\"en\">\n * \t\t\t<body>{children}</body>\n * \t\t\t<Script src={toolbarSrc} />\n * \t\t</html>\n * \t);\n * }\n * ```\n *\n * @param repositoryName - The name of the Prismic repository. For example,\n * `\"my-repo\"` if the repository URL is `my-repo.prismic.io`.\n *\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const;\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\t}\n};\n"],"names":[],"mappings":";;AAqCa,MAAA,gBAAgB,CAC5B,mBACgF;AAC5E,MAAA,iBAAiB,cAAc,GAAG;AACrC,WAAO,0DAA0D,cAAc;AAAA,EAAA,OACzE;AACN,UAAM,IAAI,aACT,iDAAiD,cAAc,IAC/D,QACA,MAAS;AAAA,EAEV;AACF;"}
@@ -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\n * 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\n * providing 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. Without it you're\n\t * 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\n\t * 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 *\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 * @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 * @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\n\t * fallback to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t *\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\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":"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"}
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\n * 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\n * providing 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. Without it you're\n\t * 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\n\t * 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 *\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 * @deprecated Use object-style configuration instead.\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\n\t * fallback to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t *\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\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":";;;;AA4HA,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,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,eAAAG,kBAAA,eAAe,cAAc,IAAI;AAAA,MACzC,KAAKH,SAAQ,QAAA;AACZ,eAAOI,kBAAAA,eAAe,IAAI;AAAA,MAC3B,KAAKJ,SAAQ,QAAA;AACL,eAAAK,qCAAmB,cAAc,MAAM,QAAQ;AAAA,MACvD,KAAKL,SAAQ,QAAA;AACL,eAAAC,uCAAqB,QAAQ,MAAM,QAAQ;AAAA,MACnD,KAAKD,SAAAA,QAAQ;AAAA,MACb;AACC,eAAOM,kBAAAA,cAAc,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEH;AAWA,MAAM,sCAAsC,CAC3C,kBACuC;AACvC,QAAM,wBAAwB,CAAA;AAE9B,aAAW,OAAO,eAAe;AAC1B,UAAA,gBAAgB,cAAc,GAAiC;AAErE,QAAI,eAAe;AACI,4BAAA,GAAiC,IAAI,CAAC,YAAW;AACtE,eAAO,cAAc;AAAA,UACpB,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;AAmCa,MAAA,SAmCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,4BAA4B,eAAe,IAAI;AAClD,QAAA;AACJ,QACC,OAAO,+BAA+B,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,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;;"}
@@ -101,12 +101,6 @@ export declare const asHTML: {
101
101
  *
102
102
  * @deprecated Use object-style configuration instead.
103
103
  *
104
- * ```ts
105
- * asHTML(field);
106
- * asHTML(field, { linkResolver });
107
- * asHTML(field, { serializer });
108
- * asHTML(field, { linkResolver, serializer });
109
- * ```
110
104
  * @param richTextField - A rich text or title field from Prismic
111
105
  * @param linkResolver - An optional link resolver function to resolve links,
112
106
  * without it you're expected to use the `routes` options from the API
@@ -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\n * 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\n * providing 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. Without it you're\n\t * 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\n\t * 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 *\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 * @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 * @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\n\t * fallback to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t *\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\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":";;AA4HA,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,KAAK,QAAQ;AACZ,eAAO,sBAAsB,IAAI;AAAA,MAClC,KAAK,QAAQ;AACL,eAAA,qBAAqB,UAAU,MAAM,QAAQ;AAAA,MACrD,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,eAAe,cAAc,IAAI;AAAA,MACzC,KAAK,QAAQ;AACZ,eAAO,eAAe,IAAI;AAAA,MAC3B,KAAK,QAAQ;AACL,eAAA,mBAAmB,cAAc,MAAM,QAAQ;AAAA,MACvD,KAAK,QAAQ;AACL,eAAA,qBAAqB,QAAQ,MAAM,QAAQ;AAAA,MACnD,KAAK,QAAQ;AAAA,MACb;AACC,eAAO,cAAc,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEH;AAWA,MAAM,sCAAsC,CAC3C,kBACuC;AACvC,QAAM,wBAAwB,CAAA;AAE9B,aAAW,OAAO,eAAe;AAC1B,UAAA,gBAAgB,cAAc,GAAiC;AAErE,QAAI,eAAe;AACI,4BAAA,GAAiC,IAAI,CAAC,YAAW;AACtE,eAAO,cAAc;AAAA,UACpB,GAAG;AAAA;AAAA,UAEH,UAAU,QAAQ,SAAS,KAAK,EAAE;AAAA,QAAA,CAClC;AAAA,MAAA;AAAA,IAEF;AAAA,EACD;AAED,SAAO,kBAAkB,qBAAqB;AAC/C;AAmCa,MAAA,SAyCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,4BAA4B,eAAe,IAAI;AAClD,QAAA;AACJ,QACC,OAAO,+BAA+B,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
+ {"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\n * 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\n * providing 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. Without it you're\n\t * 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\n\t * 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 *\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 * @deprecated Use object-style configuration instead.\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\n\t * fallback to the default serializer\n\t *\n\t * @returns HTML equivalent of the provided rich text or title field\n\t *\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\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":";;AA4HA,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,KAAK,QAAQ;AACZ,eAAO,sBAAsB,IAAI;AAAA,MAClC,KAAK,QAAQ;AACL,eAAA,qBAAqB,UAAU,MAAM,QAAQ;AAAA,MACrD,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,eAAe,cAAc,IAAI;AAAA,MACzC,KAAK,QAAQ;AACZ,eAAO,eAAe,IAAI;AAAA,MAC3B,KAAK,QAAQ;AACL,eAAA,mBAAmB,cAAc,MAAM,QAAQ;AAAA,MACvD,KAAK,QAAQ;AACL,eAAA,qBAAqB,QAAQ,MAAM,QAAQ;AAAA,MACnD,KAAK,QAAQ;AAAA,MACb;AACC,eAAO,cAAc,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEH;AAWA,MAAM,sCAAsC,CAC3C,kBACuC;AACvC,QAAM,wBAAwB,CAAA;AAE9B,aAAW,OAAO,eAAe;AAC1B,UAAA,gBAAgB,cAAc,GAAiC;AAErE,QAAI,eAAe;AACI,4BAAA,GAAiC,IAAI,CAAC,YAAW;AACtE,eAAO,cAAc;AAAA,UACpB,GAAG;AAAA;AAAA,UAEH,UAAU,QAAQ,SAAS,KAAK,EAAE;AAAA,QAAA,CAClC;AAAA,MAAA;AAAA,IAEF;AAAA,EACD;AAED,SAAO,kBAAkB,qBAAqB;AAC/C;AAmCa,MAAA,SAmCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,4BAA4B,eAAe,IAAI;AAClD,QAAA;AACJ,QACC,OAAO,+BAA+B,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 *\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;AA8DjC,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;;"}
@@ -46,7 +46,8 @@ type AsImagePixelDensitySrcSetReturnType<Field extends ImageFieldImage | null |
46
46
  *
47
47
  * @returns A `srcset` attribute value for the image field with Imgix URL
48
48
  * parameters (if given). If the image field is empty, `null` is returned.
49
+ *
49
50
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
50
51
  */
51
- export declare const asImagePixelDensitySrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImagePixelDensitySrcSetConfig) => AsImagePixelDensitySrcSetReturnType<Field>;
52
+ export declare const asImagePixelDensitySrcSet: <Field extends import("../types/value/image").EmptyImageFieldImage | import("../types/value/image").FilledImageFieldImage | null | undefined>(field: Field, config?: AsImagePixelDensitySrcSetConfig) => AsImagePixelDensitySrcSetReturnType<Field>;
52
53
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"asImagePixelDensitySrcSet.js","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"],"mappings":";;AAaA,MAAM,0BAA0B,CAAC,GAAG,GAAG,CAAC;AA6DjC,MAAM,4BAA4B,CAGxC,OACA,SAA0C,OACK;AAC3C,MAAA,SAASA,eAAuB,KAAK,GAAG;AAG3C,UAAM,EAAE,iBAAiB,yBAAyB,GAAG,gBAAgB;AAE9D,WAAA;AAAA,MACN,KAAK,SAAS,MAAM,KAAK,WAAW;AAAA,MACpC,QAAQ,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.js","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 *\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"],"mappings":";;AAaA,MAAM,0BAA0B,CAAC,GAAG,GAAG,CAAC;AA8DjC,MAAM,4BAA4B,CAGxC,OACA,SAA0C,OACK;AAC3C,MAAA,SAASA,eAAuB,KAAK,GAAG;AAG3C,UAAM,EAAE,iBAAiB,yBAAyB,GAAG,gBAAgB;AAE9D,WAAA;AAAA,MACN,KAAK,SAAS,MAAM,KAAK,WAAW;AAAA,MACpC,QAAQ,wBAAwB,MAAM,KAAK;AAAA,QAC1C,GAAG;AAAA,QACH;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,SAEI;AACC,WAAA;AAAA,EACP;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asImageSrc.cjs","sources":["../../../src/helpers/asImageSrc.ts"],"sourcesContent":["import { ImgixURLParams, buildURL } from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\";\n\n/**\n * The return type of `asImageSrc()`.\n */\ntype AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\"> ? string : null;\n\n/**\n * Returns the URL of an image field with optional image transformations (via\n * Imgix URL parameters).\n *\n * @example\n *\n * ```ts\n * const src = asImageSrc(document.data.imageField, { sat: -100 });\n * // => https://images.prismic.io/repo/image.png?sat=-100\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 to transform the image.\n *\n * @returns The image field's image URL with transformations applied (if given).\n * If the image field is empty, `null` is returned.\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImageSrc = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: ImgixURLParams = {},\n): AsImageSrcReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\treturn buildURL(field.url, config) as AsImageSrcReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageSrcReturnType<Field>;\n\t}\n};\n"],"names":["isImageThumbnailFilled","buildURL"],"mappings":";;;;AA+BO,MAAM,aAAa,CACzB,OACA,SAAyB,OACO;AAC5B,MAAA,SAASA,wBAAuB,KAAK,GAAG;AACpC,WAAAC,yBAAS,MAAM,KAAK,MAAM;AAAA,EAAA,OAC3B;AACC,WAAA;AAAA,EACP;AACF;;"}
1
+ {"version":3,"file":"asImageSrc.cjs","sources":["../../../src/helpers/asImageSrc.ts"],"sourcesContent":["import { ImgixURLParams, buildURL } from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\";\n\n/**\n * The return type of `asImageSrc()`.\n */\ntype AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\"> ? string : null;\n\n/**\n * Returns the URL of an image field with optional image transformations (via\n * Imgix URL parameters).\n *\n * @example\n *\n * ```ts\n * const src = asImageSrc(document.data.imageField, { sat: -100 });\n * // => https://images.prismic.io/repo/image.png?sat=-100\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 to transform the image.\n *\n * @returns The image field's image URL with transformations applied (if given).\n * If the image field is empty, `null` is returned.\n *\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImageSrc = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: ImgixURLParams = {},\n): AsImageSrcReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\treturn buildURL(field.url, config) as AsImageSrcReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageSrcReturnType<Field>;\n\t}\n};\n"],"names":["isImageThumbnailFilled","buildURL"],"mappings":";;;;AAgCO,MAAM,aAAa,CACzB,OACA,SAAyB,OACO;AAC5B,MAAA,SAASA,wBAAuB,KAAK,GAAG;AACpC,WAAAC,yBAAS,MAAM,KAAK,MAAM;AAAA,EAAA,OAC3B;AACC,WAAA;AAAA,EACP;AACF;;"}
@@ -21,7 +21,8 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> = Fi
21
21
  *
22
22
  * @returns The image field's image URL with transformations applied (if given).
23
23
  * If the image field is empty, `null` is returned.
24
+ *
24
25
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
25
26
  */
26
- export declare const asImageSrc: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
27
+ export declare const asImageSrc: <Field extends import("../types/value/image").EmptyImageFieldImage | import("../types/value/image").FilledImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
27
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"asImageSrc.js","sources":["../../../src/helpers/asImageSrc.ts"],"sourcesContent":["import { ImgixURLParams, buildURL } from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\";\n\n/**\n * The return type of `asImageSrc()`.\n */\ntype AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\"> ? string : null;\n\n/**\n * Returns the URL of an image field with optional image transformations (via\n * Imgix URL parameters).\n *\n * @example\n *\n * ```ts\n * const src = asImageSrc(document.data.imageField, { sat: -100 });\n * // => https://images.prismic.io/repo/image.png?sat=-100\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 to transform the image.\n *\n * @returns The image field's image URL with transformations applied (if given).\n * If the image field is empty, `null` is returned.\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImageSrc = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: ImgixURLParams = {},\n): AsImageSrcReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\treturn buildURL(field.url, config) as AsImageSrcReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageSrcReturnType<Field>;\n\t}\n};\n"],"names":["isImageThumbnailFilled"],"mappings":";;AA+BO,MAAM,aAAa,CACzB,OACA,SAAyB,OACO;AAC5B,MAAA,SAASA,eAAuB,KAAK,GAAG;AACpC,WAAA,SAAS,MAAM,KAAK,MAAM;AAAA,EAAA,OAC3B;AACC,WAAA;AAAA,EACP;AACF;"}
1
+ {"version":3,"file":"asImageSrc.js","sources":["../../../src/helpers/asImageSrc.ts"],"sourcesContent":["import { ImgixURLParams, buildURL } from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\";\n\n/**\n * The return type of `asImageSrc()`.\n */\ntype AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\"> ? string : null;\n\n/**\n * Returns the URL of an image field with optional image transformations (via\n * Imgix URL parameters).\n *\n * @example\n *\n * ```ts\n * const src = asImageSrc(document.data.imageField, { sat: -100 });\n * // => https://images.prismic.io/repo/image.png?sat=-100\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 to transform the image.\n *\n * @returns The image field's image URL with transformations applied (if given).\n * If the image field is empty, `null` is returned.\n *\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImageSrc = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: ImgixURLParams = {},\n): AsImageSrcReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\treturn buildURL(field.url, config) as AsImageSrcReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageSrcReturnType<Field>;\n\t}\n};\n"],"names":["isImageThumbnailFilled"],"mappings":";;AAgCO,MAAM,aAAa,CACzB,OACA,SAAyB,OACO;AAC5B,MAAA,SAASA,eAAuB,KAAK,GAAG;AACpC,WAAA,SAAS,MAAM,KAAK,MAAM;AAAA,EAAA,OAC3B;AACC,WAAA;AAAA,EACP;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asImageWidthSrcSet.cjs","sources":["../../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import {\n\tBuildWidthSrcSetParams,\n\tbuildURL,\n\tbuildWidthSrcSet,\n} from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport * as isFilled from \"./isFilled\";\n\n/**\n * The default widths used to generate a `srcset` value.\n */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];\n\n/**\n * The return type of `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetReturnType<\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 width-based `srcset` attribute value for the image field's image with\n\t\t\t * Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrcset: string;\n\t }\n\t: null;\n\n/**\n * Configuration for `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"];\n};\n\n/**\n * Creates a width-based `srcset` from an image field with optional image\n * transformations (via Imgix URL parameters).\n *\n * If a `widths` parameter is not given, the following widths will be used by\n * default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be\n * used as a width in the resulting `srcset` by passing `\"thumbnails\"` as the\n * `widths` parameter.\n *\n * @example\n *\n * ```ts\n * const srcset = asImageWidthSrcSet(document.data.imageField, {\n * \twidths: [400, 800, 1600],\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&width=400 400w, ' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=800 800w,' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w'\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 `widths` parameter\n * defines the resulting `srcset` widths. Pass `\"thumbnails\"` to automatically\n * use the field's responsive views.\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 asImageWidthSrcSet = <\n\tField extends ImageFieldImage | null | undefined,\n>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\tlet {\n\t\t\twidths = DEFAULT_WIDTHS,\n\t\t\t// eslint-disable-next-line prefer-const\n\t\t\t...imgixParams\n\t\t} = config;\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\t...responsiveViews\n\t\t} = field;\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] =\n\t\t\tObject.values(responsiveViews);\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS;\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t ].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t }),\n\t\t} as AsImageWidthSrcSetReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>;\n\t}\n};\n"],"names":["isFilled.imageThumbnail","buildURL","buildWidthSrcSet"],"mappings":";;;;AAaA,MAAM,iBAAiB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAiE3C,MAAM,qBAAqB,CAGjC,OACA,SAAmC,OACK;AACxC,MAAI,SAASA,wBAAwB,KAAK,GAAG;AAGxC,QAAA;AAAA,MACH,SAAS;AAAA;AAAA,MAET,GAAG;AAAA,IACA,IAAA;AACE,UAAA,EACL,KACA,YACA,KAAK,MACL,WAAW,YACX,GAAG,gBACA,IAAA;AAIE,UAAA,wBACL,OAAO,OAAO,eAAe;AAK9B,QAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAAG;AACvD,eAAA;AAAA,IACT;AAEM,WAAA;AAAA,MACN,KAAKC,gBAAAA,SAAS,KAAK,WAAW;AAAA,MAC9B;AAAA;AAAA;AAAA,QAGC,WAAW,eACR;AAAA,UACAC,gBAAAA,iBAAiB,KAAK;AAAA,YACrB,GAAG;AAAA,YACH,QAAQ,CAAC,WAAW,KAAK;AAAA,UAAA,CACzB;AAAA,UACD,GAAG,sBAAsB,IAAI,CAAC,cAAa;AACnC,mBAAAA,gBAAA,iBAAiB,UAAU,KAAK;AAAA,cACtC,GAAG;AAAA,cACH,QAAQ,CAAC,UAAU,WAAW,KAAK;AAAA,YAAA,CACnC;AAAA,UAAA,CACD;AAAA,UACC,KAAK,IAAI,IACXA,gBAAAA,iBAAiB,MAAM,KAAK;AAAA,UAC5B,GAAG;AAAA,UACH;AAAA,QAAA,CACC;AAAA;AAAA,IAAA;AAAA,SAEA;AACC,WAAA;AAAA,EACP;AACF;;"}
1
+ {"version":3,"file":"asImageWidthSrcSet.cjs","sources":["../../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import {\n\tBuildWidthSrcSetParams,\n\tbuildURL,\n\tbuildWidthSrcSet,\n} from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport * as isFilled from \"./isFilled\";\n\n/**\n * The default widths used to generate a `srcset` value.\n */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];\n\n/**\n * The return type of `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetReturnType<\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 width-based `srcset` attribute value for the image field's image with\n\t\t\t * Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrcset: string;\n\t }\n\t: null;\n\n/**\n * Configuration for `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"];\n};\n\n/**\n * Creates a width-based `srcset` from an image field with optional image\n * transformations (via Imgix URL parameters).\n *\n * If a `widths` parameter is not given, the following widths will be used by\n * default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be\n * used as a width in the resulting `srcset` by passing `\"thumbnails\"` as the\n * `widths` parameter.\n *\n * @example\n *\n * ```ts\n * const srcset = asImageWidthSrcSet(document.data.imageField, {\n * \twidths: [400, 800, 1600],\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&width=400 400w, ' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=800 800w,' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w'\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 `widths` parameter\n * defines the resulting `srcset` widths. Pass `\"thumbnails\"` to automatically\n * use the field's responsive views.\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 *\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImageWidthSrcSet = <\n\tField extends ImageFieldImage | null | undefined,\n>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\tlet {\n\t\t\twidths = DEFAULT_WIDTHS,\n\t\t\t// eslint-disable-next-line prefer-const\n\t\t\t...imgixParams\n\t\t} = config;\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\t...responsiveViews\n\t\t} = field;\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] =\n\t\t\tObject.values(responsiveViews);\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS;\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t ].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t }),\n\t\t} as AsImageWidthSrcSetReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>;\n\t}\n};\n"],"names":["isFilled.imageThumbnail","buildURL","buildWidthSrcSet"],"mappings":";;;;AAaA,MAAM,iBAAiB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAkE3C,MAAM,qBAAqB,CAGjC,OACA,SAAmC,OACK;AACxC,MAAI,SAASA,wBAAwB,KAAK,GAAG;AAGxC,QAAA;AAAA,MACH,SAAS;AAAA;AAAA,MAET,GAAG;AAAA,IACA,IAAA;AACE,UAAA,EACL,KACA,YACA,KAAK,MACL,WAAW,YACX,GAAG,gBACA,IAAA;AAIE,UAAA,wBACL,OAAO,OAAO,eAAe;AAK9B,QAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAAG;AACvD,eAAA;AAAA,IACT;AAEM,WAAA;AAAA,MACN,KAAKC,gBAAAA,SAAS,KAAK,WAAW;AAAA,MAC9B;AAAA;AAAA;AAAA,QAGC,WAAW,eACR;AAAA,UACAC,gBAAAA,iBAAiB,KAAK;AAAA,YACrB,GAAG;AAAA,YACH,QAAQ,CAAC,WAAW,KAAK;AAAA,UAAA,CACzB;AAAA,UACD,GAAG,sBAAsB,IAAI,CAAC,cAAa;AACnC,mBAAAA,gBAAA,iBAAiB,UAAU,KAAK;AAAA,cACtC,GAAG;AAAA,cACH,QAAQ,CAAC,UAAU,WAAW,KAAK;AAAA,YAAA,CACnC;AAAA,UAAA,CACD;AAAA,UACC,KAAK,IAAI,IACXA,gBAAAA,iBAAiB,MAAM,KAAK;AAAA,UAC5B,GAAG;AAAA,UACH;AAAA,QAAA,CACC;AAAA;AAAA,IAAA;AAAA,SAEA;AACC,WAAA;AAAA,EACP;AACF;;"}
@@ -54,7 +54,8 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
54
54
  *
55
55
  * @returns A `srcset` attribute value for the image field with Imgix URL
56
56
  * parameters (if given). If the image field is empty, `null` is returned.
57
+ *
57
58
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
58
59
  */
59
- export declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
60
+ export declare const asImageWidthSrcSet: <Field extends import("../types/value/image").EmptyImageFieldImage | import("../types/value/image").FilledImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
60
61
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"asImageWidthSrcSet.js","sources":["../../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import {\n\tBuildWidthSrcSetParams,\n\tbuildURL,\n\tbuildWidthSrcSet,\n} from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport * as isFilled from \"./isFilled\";\n\n/**\n * The default widths used to generate a `srcset` value.\n */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];\n\n/**\n * The return type of `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetReturnType<\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 width-based `srcset` attribute value for the image field's image with\n\t\t\t * Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrcset: string;\n\t }\n\t: null;\n\n/**\n * Configuration for `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"];\n};\n\n/**\n * Creates a width-based `srcset` from an image field with optional image\n * transformations (via Imgix URL parameters).\n *\n * If a `widths` parameter is not given, the following widths will be used by\n * default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be\n * used as a width in the resulting `srcset` by passing `\"thumbnails\"` as the\n * `widths` parameter.\n *\n * @example\n *\n * ```ts\n * const srcset = asImageWidthSrcSet(document.data.imageField, {\n * \twidths: [400, 800, 1600],\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&width=400 400w, ' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=800 800w,' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w'\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 `widths` parameter\n * defines the resulting `srcset` widths. Pass `\"thumbnails\"` to automatically\n * use the field's responsive views.\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 asImageWidthSrcSet = <\n\tField extends ImageFieldImage | null | undefined,\n>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\tlet {\n\t\t\twidths = DEFAULT_WIDTHS,\n\t\t\t// eslint-disable-next-line prefer-const\n\t\t\t...imgixParams\n\t\t} = config;\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\t...responsiveViews\n\t\t} = field;\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] =\n\t\t\tObject.values(responsiveViews);\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS;\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t ].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t }),\n\t\t} as AsImageWidthSrcSetReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>;\n\t}\n};\n"],"names":["isFilled.imageThumbnail"],"mappings":";;AAaA,MAAM,iBAAiB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAiE3C,MAAM,qBAAqB,CAGjC,OACA,SAAmC,OACK;AACxC,MAAI,SAASA,eAAwB,KAAK,GAAG;AAGxC,QAAA;AAAA,MACH,SAAS;AAAA;AAAA,MAET,GAAG;AAAA,IACA,IAAA;AACE,UAAA,EACL,KACA,YACA,KAAK,MACL,WAAW,YACX,GAAG,gBACA,IAAA;AAIE,UAAA,wBACL,OAAO,OAAO,eAAe;AAK9B,QAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAAG;AACvD,eAAA;AAAA,IACT;AAEM,WAAA;AAAA,MACN,KAAK,SAAS,KAAK,WAAW;AAAA,MAC9B;AAAA;AAAA;AAAA,QAGC,WAAW,eACR;AAAA,UACA,iBAAiB,KAAK;AAAA,YACrB,GAAG;AAAA,YACH,QAAQ,CAAC,WAAW,KAAK;AAAA,UAAA,CACzB;AAAA,UACD,GAAG,sBAAsB,IAAI,CAAC,cAAa;AACnC,mBAAA,iBAAiB,UAAU,KAAK;AAAA,cACtC,GAAG;AAAA,cACH,QAAQ,CAAC,UAAU,WAAW,KAAK;AAAA,YAAA,CACnC;AAAA,UAAA,CACD;AAAA,UACC,KAAK,IAAI,IACX,iBAAiB,MAAM,KAAK;AAAA,UAC5B,GAAG;AAAA,UACH;AAAA,QAAA,CACC;AAAA;AAAA,IAAA;AAAA,SAEA;AACC,WAAA;AAAA,EACP;AACF;"}
1
+ {"version":3,"file":"asImageWidthSrcSet.js","sources":["../../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import {\n\tBuildWidthSrcSetParams,\n\tbuildURL,\n\tbuildWidthSrcSet,\n} from \"imgix-url-builder\";\n\nimport type { ImageFieldImage } from \"../types/value/image\";\n\nimport * as isFilled from \"./isFilled\";\n\n/**\n * The default widths used to generate a `srcset` value.\n */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];\n\n/**\n * The return type of `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetReturnType<\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 width-based `srcset` attribute value for the image field's image with\n\t\t\t * Imgix URL parameters (if given).\n\t\t\t */\n\t\t\tsrcset: string;\n\t }\n\t: null;\n\n/**\n * Configuration for `asImageWidthSrcSet()`.\n */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"];\n};\n\n/**\n * Creates a width-based `srcset` from an image field with optional image\n * transformations (via Imgix URL parameters).\n *\n * If a `widths` parameter is not given, the following widths will be used by\n * default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be\n * used as a width in the resulting `srcset` by passing `\"thumbnails\"` as the\n * `widths` parameter.\n *\n * @example\n *\n * ```ts\n * const srcset = asImageWidthSrcSet(document.data.imageField, {\n * \twidths: [400, 800, 1600],\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&width=400 400w, ' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=800 800w,' +\n * // 'https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w'\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 `widths` parameter\n * defines the resulting `srcset` widths. Pass `\"thumbnails\"` to automatically\n * use the field's responsive views.\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 *\n * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n */\nexport const asImageWidthSrcSet = <\n\tField extends ImageFieldImage | null | undefined,\n>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\tlet {\n\t\t\twidths = DEFAULT_WIDTHS,\n\t\t\t// eslint-disable-next-line prefer-const\n\t\t\t...imgixParams\n\t\t} = config;\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\t...responsiveViews\n\t\t} = field;\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] =\n\t\t\tObject.values(responsiveViews);\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS;\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t ].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t }),\n\t\t} as AsImageWidthSrcSetReturnType<Field>;\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>;\n\t}\n};\n"],"names":["isFilled.imageThumbnail"],"mappings":";;AAaA,MAAM,iBAAiB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAkE3C,MAAM,qBAAqB,CAGjC,OACA,SAAmC,OACK;AACxC,MAAI,SAASA,eAAwB,KAAK,GAAG;AAGxC,QAAA;AAAA,MACH,SAAS;AAAA;AAAA,MAET,GAAG;AAAA,IACA,IAAA;AACE,UAAA,EACL,KACA,YACA,KAAK,MACL,WAAW,YACX,GAAG,gBACA,IAAA;AAIE,UAAA,wBACL,OAAO,OAAO,eAAe;AAK9B,QAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAAG;AACvD,eAAA;AAAA,IACT;AAEM,WAAA;AAAA,MACN,KAAK,SAAS,KAAK,WAAW;AAAA,MAC9B;AAAA;AAAA;AAAA,QAGC,WAAW,eACR;AAAA,UACA,iBAAiB,KAAK;AAAA,YACrB,GAAG;AAAA,YACH,QAAQ,CAAC,WAAW,KAAK;AAAA,UAAA,CACzB;AAAA,UACD,GAAG,sBAAsB,IAAI,CAAC,cAAa;AACnC,mBAAA,iBAAiB,UAAU,KAAK;AAAA,cACtC,GAAG;AAAA,cACH,QAAQ,CAAC,UAAU,WAAW,KAAK;AAAA,YAAA,CACnC;AAAA,UAAA,CACD;AAAA,UACC,KAAK,IAAI,IACX,iBAAiB,MAAM,KAAK;AAAA,UAC5B,GAAG;AAAA,UACH;AAAA,QAAA,CACC;AAAA;AAAA,IAAA;AAAA,SAEA;AACC,WAAA;AAAA,EACP;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asLink.cjs","sources":["../../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\";\nimport type { PrismicDocument } from \"../types/value/document\";\nimport { FilledLinkToWebField, LinkField, LinkType } from \"../types/value/link\";\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\";\n\nimport { documentToLinkField } from \"./documentToLinkField\";\n\n/**\n * Resolves a link to a Prismic document to a URL\n *\n * @typeParam ReturnType - Return type of your link resolver function, useful if\n * you prefer to return a complex object\n * @param linkToDocumentField - A document link field to resolve\n *\n * @returns Resolved URL\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType;\n\n/**\n * Configuration that determines the output of `asLink()`.\n */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =\n\t{\n\t\t/**\n\t\t * An optional link resolver function. Without it, you are expected to use\n\t\t * the `routes` options from the API.\n\t\t */\n\t\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null;\n\t};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsLinkDeprecatedTupleConfig<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n> = [\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null,\n];\n\n/**\n * The return type of `asLink()`.\n */\nexport type AsLinkReturnType<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? LinkResolverFunctionReturnType | string | null\n\t: null;\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asLink: {\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param config - Configuration that determines the output of `asLink()`\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\tconfig?: AsLinkConfig<LinkResolverFunctionReturnType>,\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asLink(field);\n\t * asLink(field, { linkResolver });\n\t * ```\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param linkResolver - An optional link resolver function. Without it, you\n\t * are expected to use the `routes` options from the API\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\t...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n} = <\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple:\n\t\t| [config?: AsLinkConfig<LinkResolverFunctionReturnType>]\n\t\t| AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n): AsLinkReturnType<LinkResolverFunctionReturnType, Field> => {\n\tif (!linkFieldOrDocument) {\n\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\t}\n\n\t// Converts document to link field if needed\n\tconst linkField =\n\t\t// prettier-ignore\n\t\t(\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t// TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n\t\t\t\"link_type\" in linkFieldOrDocument\n\t\t\t\t? linkFieldOrDocument\n\t\t\t\t: documentToLinkField(linkFieldOrDocument)\n\t\t) as LinkField;\n\n\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\tconst [configObjectOrLinkResolver] = configObjectOrTuple;\n\tlet config: AsLinkConfig<LinkResolverFunctionReturnType>;\n\tif (\n\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\tconfigObjectOrLinkResolver == null\n\t) {\n\t\tconfig = {\n\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t};\n\t} else {\n\t\tconfig = { ...configObjectOrLinkResolver };\n\t}\n\n\tswitch (linkField.link_type) {\n\t\tcase LinkType.Media:\n\t\tcase LinkType.Web:\n\t\t\treturn (\"url\" in linkField ? linkField.url : null) as AsLinkReturnType<\n\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\tField\n\t\t\t>;\n\n\t\tcase LinkType.Document: {\n\t\t\tif (\"id\" in linkField && config.linkResolver) {\n\t\t\t\t// When using link resolver...\n\t\t\t\tconst resolvedURL = config.linkResolver(linkField);\n\n\t\t\t\tif (resolvedURL != null) {\n\t\t\t\t\treturn resolvedURL as AsLinkReturnType<\n\t\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\t\tField\n\t\t\t\t\t>;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"url\" in linkField && linkField.url) {\n\t\t\t\t// When using route resolver...\n\t\t\t\treturn linkField.url as AsLinkReturnType<\n\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\tField\n\t\t\t\t>;\n\t\t\t}\n\n\t\t\t// When empty or link resolver and route resolver are not used...\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\t\t}\n\n\t\tcase LinkType.Any:\n\t\tdefault:\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\t}\n};\n"],"names":["documentToLinkField","LinkType"],"mappings":";;;;AA+Da,MAAA,SA+DT,CAQH,wBAEG,wBAGyD;AAC5D,MAAI,CAAC,qBAAqB;AAClB,WAAA;AAAA,EACP;AAGK,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMJ,eAAe,sBACZ,sBACAA,oBAAAA,oBAAoB,mBAAmB;AAAA;AAItC,QAAA,CAAC,0BAA0B,IAAI;AACjC,MAAA;AACJ,MACC,OAAO,+BAA+B,cACtC,8BAA8B,MAC7B;AACQ,aAAA;AAAA,MACR,cAAc;AAAA,IAAA;AAAA,SAET;AACG,aAAA,EAAE,GAAG;EACd;AAED,UAAQ,UAAU,WAAW;AAAA,IAC5B,KAAKC,KAAAA,SAAS;AAAA,IACd,KAAKA,KAAS,SAAA;AACL,aAAA,SAAS,YAAY,UAAU,MAAM;AAAA,IAK9C,KAAKA,KAAAA,SAAS,UAAU;AACnB,UAAA,QAAQ,aAAa,OAAO,cAAc;AAEvC,cAAA,cAAc,OAAO,aAAa,SAAS;AAEjD,YAAI,eAAe,MAAM;AACjB,iBAAA;AAAA,QAIP;AAAA,MACD;AAEG,UAAA,SAAS,aAAa,UAAU,KAAK;AAExC,eAAO,UAAU;AAAA,MAIjB;AAGM,aAAA;AAAA,IACP;AAAA,IAED,KAAKA,KAAAA,SAAS;AAAA,IACd;AACQ,aAAA;AAAA,EACR;AACF;;"}
1
+ {"version":3,"file":"asLink.cjs","sources":["../../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\";\nimport type { PrismicDocument } from \"../types/value/document\";\nimport { FilledLinkToWebField, LinkField, LinkType } from \"../types/value/link\";\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\";\n\nimport { documentToLinkField } from \"./documentToLinkField\";\n\n/**\n * Resolves a link to a Prismic document to a URL\n *\n * @typeParam ReturnType - Return type of your link resolver function, useful if\n * you prefer to return a complex object\n *\n * @param linkToDocumentField - A document link field to resolve\n *\n * @returns Resolved URL\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType;\n\n/**\n * Configuration that determines the output of `asLink()`.\n */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =\n\t{\n\t\t/**\n\t\t * An optional link resolver function. Without it, you are expected to use\n\t\t * the `routes` options from the API.\n\t\t */\n\t\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null;\n\t};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsLinkDeprecatedTupleConfig<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n> = [\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null,\n];\n\n/**\n * The return type of `asLink()`.\n */\nexport type AsLinkReturnType<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? LinkResolverFunctionReturnType | string | null\n\t: null;\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asLink: {\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param config - Configuration that determines the output of `asLink()`\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\tconfig?: AsLinkConfig<LinkResolverFunctionReturnType>,\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param linkResolver - An optional link resolver function. Without it, you\n\t * are expected to use the `routes` options from the API\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\t...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n} = <\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple:\n\t\t| [config?: AsLinkConfig<LinkResolverFunctionReturnType>]\n\t\t| AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n): AsLinkReturnType<LinkResolverFunctionReturnType, Field> => {\n\tif (!linkFieldOrDocument) {\n\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\t}\n\n\t// Converts document to link field if needed\n\tconst linkField =\n\t\t// prettier-ignore\n\t\t(\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t// TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n\t\t\t\"link_type\" in linkFieldOrDocument\n\t\t\t\t? linkFieldOrDocument\n\t\t\t\t: documentToLinkField(linkFieldOrDocument)\n\t\t) as LinkField;\n\n\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\tconst [configObjectOrLinkResolver] = configObjectOrTuple;\n\tlet config: AsLinkConfig<LinkResolverFunctionReturnType>;\n\tif (\n\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\tconfigObjectOrLinkResolver == null\n\t) {\n\t\tconfig = {\n\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t};\n\t} else {\n\t\tconfig = { ...configObjectOrLinkResolver };\n\t}\n\n\tswitch (linkField.link_type) {\n\t\tcase LinkType.Media:\n\t\tcase LinkType.Web:\n\t\t\treturn (\"url\" in linkField ? linkField.url : null) as AsLinkReturnType<\n\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\tField\n\t\t\t>;\n\n\t\tcase LinkType.Document: {\n\t\t\tif (\"id\" in linkField && config.linkResolver) {\n\t\t\t\t// When using link resolver...\n\t\t\t\tconst resolvedURL = config.linkResolver(linkField);\n\n\t\t\t\tif (resolvedURL != null) {\n\t\t\t\t\treturn resolvedURL as AsLinkReturnType<\n\t\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\t\tField\n\t\t\t\t\t>;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"url\" in linkField && linkField.url) {\n\t\t\t\t// When using route resolver...\n\t\t\t\treturn linkField.url as AsLinkReturnType<\n\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\tField\n\t\t\t\t>;\n\t\t\t}\n\n\t\t\t// When empty or link resolver and route resolver are not used...\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\t\t}\n\n\t\tcase LinkType.Any:\n\t\tdefault:\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;\n\t}\n};\n"],"names":["documentToLinkField","LinkType"],"mappings":";;;;AAgEa,MAAA,SA6DT,CAQH,wBAEG,wBAGyD;AAC5D,MAAI,CAAC,qBAAqB;AAClB,WAAA;AAAA,EACP;AAGK,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMJ,eAAe,sBACZ,sBACAA,oBAAAA,oBAAoB,mBAAmB;AAAA;AAItC,QAAA,CAAC,0BAA0B,IAAI;AACjC,MAAA;AACJ,MACC,OAAO,+BAA+B,cACtC,8BAA8B,MAC7B;AACQ,aAAA;AAAA,MACR,cAAc;AAAA,IAAA;AAAA,SAET;AACG,aAAA,EAAE,GAAG;EACd;AAED,UAAQ,UAAU,WAAW;AAAA,IAC5B,KAAKC,KAAAA,SAAS;AAAA,IACd,KAAKA,KAAS,SAAA;AACL,aAAA,SAAS,YAAY,UAAU,MAAM;AAAA,IAK9C,KAAKA,KAAAA,SAAS,UAAU;AACnB,UAAA,QAAQ,aAAa,OAAO,cAAc;AAEvC,cAAA,cAAc,OAAO,aAAa,SAAS;AAEjD,YAAI,eAAe,MAAM;AACjB,iBAAA;AAAA,QAIP;AAAA,MACD;AAEG,UAAA,SAAS,aAAa,UAAU,KAAK;AAExC,eAAO,UAAU;AAAA,MAIjB;AAGM,aAAA;AAAA,IACP;AAAA,IAED,KAAKA,KAAAA,SAAS;AAAA,IACd;AACQ,aAAA;AAAA,EACR;AACF;;"}
@@ -7,6 +7,7 @@ import type { FilledLinkToMediaField } from "../types/value/linkToMedia";
7
7
  *
8
8
  * @typeParam ReturnType - Return type of your link resolver function, useful if
9
9
  * you prefer to return a complex object
10
+ *
10
11
  * @param linkToDocumentField - A document link field to resolve
11
12
  *
12
13
  * @returns Resolved URL
@@ -48,6 +49,7 @@ export declare const asLink: {
48
49
  *
49
50
  * @returns Resolved URL or, if the provided link field or document is empty,
50
51
  * `null`
52
+ *
51
53
  * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
52
54
  * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
53
55
  */
@@ -57,10 +59,6 @@ export declare const asLink: {
57
59
  *
58
60
  * @deprecated Use object-style configuration instead.
59
61
  *
60
- * ```ts
61
- * asLink(field);
62
- * asLink(field, { linkResolver });
63
- * ```
64
62
  * @typeParam LinkResolverFunctionReturnType - link resolver function return
65
63
  * type
66
64
  * @typeParam Field - Link field or Prismic document to resolve to a URL
@@ -72,6 +70,7 @@ export declare const asLink: {
72
70
  *
73
71
  * @returns Resolved URL or, if the provided link field or document is empty,
74
72
  * `null`
73
+ *
75
74
  * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
76
75
  * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
77
76
  */