@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":"asLink.js","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":[],"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,sBACA,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,KAAK,SAAS;AAAA,IACd,KAAK,SAAS;AACL,aAAA,SAAS,YAAY,UAAU,MAAM;AAAA,IAK9C,KAAK,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,KAAK,SAAS;AAAA,IACd;AACQ,aAAA;AAAA,EACR;AACF;"}
1
+ {"version":3,"file":"asLink.js","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":[],"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,sBACA,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,KAAK,SAAS;AAAA,IACd,KAAK,SAAS;AACL,aAAA,SAAS,YAAY,UAAU,MAAM;AAAA,IAK9C,KAAK,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,KAAK,SAAS;AAAA,IACd;AACQ,aAAA;AAAA,EACR;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asLinkAttrs.cjs","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\";\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\";\nimport type { PrismicDocument } from \"../types/value/document\";\nimport { FilledLinkToWebField, LinkField } from \"../types/value/link\";\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\";\n\nimport { AsLinkReturnType, LinkResolverFunction, asLink } from \"./asLink\";\nimport { link as isFilledLink } from \"./isFilled\";\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined;\n\tisExternal: boolean;\n\ttarget?: string;\n};\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>;\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void;\n};\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined;\n\t\t\ttarget?: string;\n\t\t\trel?: string;\n\t }\n\t: {\n\t\t\thref?: undefined;\n\t\t\ttarget?: undefined;\n\t\t\trel?: undefined;\n\t };\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\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\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined;\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver);\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>);\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false;\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t? \"noreferrer\"\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t};\n\t}\n\n\treturn {};\n};\n"],"names":["isFilledLink","asLink","isInternalURL"],"mappings":";;;;;AAuFO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,SAAAA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAUC,OAAA,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAACC,4BAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,OAAM,CAAE,IACvC,aACA,eACA;AAEI,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,KAAK,OAAO,OAAO,SAAY;AAAA,IAAA;AAAA,EAEhC;AAED,SAAO;AACR;;"}
1
+ {"version":3,"file":"asLinkAttrs.cjs","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\";\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\";\nimport type { PrismicDocument } from \"../types/value/document\";\nimport { FilledLinkToWebField, LinkField } from \"../types/value/link\";\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\";\n\nimport { AsLinkReturnType, LinkResolverFunction, asLink } from \"./asLink\";\nimport { link as isFilledLink } from \"./isFilled\";\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined;\n\tisExternal: boolean;\n\ttarget?: string;\n};\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>;\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void;\n};\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined;\n\t\t\ttarget?: string;\n\t\t\trel?: string;\n\t }\n\t: {\n\t\t\thref?: undefined;\n\t\t\ttarget?: undefined;\n\t\t\trel?: undefined;\n\t };\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n *\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\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\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined;\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver);\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>);\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false;\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t? \"noreferrer\"\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t};\n\t}\n\n\treturn {};\n};\n"],"names":["isFilledLink","asLink","isInternalURL"],"mappings":";;;;;AAyFO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,SAAAA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAUC,OAAA,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAACC,4BAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,OAAM,CAAE,IACvC,aACA,eACA;AAEI,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,KAAK,OAAO,OAAO,SAAY;AAAA,IAAA;AAAA,EAEhC;AAED,SAAO;AACR;;"}
@@ -36,15 +36,17 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
36
36
  * type
37
37
  * @typeParam Field - Link field or Prismic document to resolve to link
38
38
  * attributes
39
+ *
39
40
  * @param linkFieldOrDocument - Any kind of link field or a document to resolve
40
41
  * @param config - Configuration that determines the output of `asLinkAttrs()`
41
42
  *
42
43
  * @returns Resolved set of link attributes or, if the provided link field or
43
44
  * document is empty, and empty object
45
+ *
44
46
  * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
45
47
  * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
46
48
  */
47
- export declare const asLinkAttrs: <LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument<Record<string, any>, string, string> | null | undefined = LinkField | PrismicDocument<Record<string, any>, string, string> | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType, LinkField | PrismicDocument<Record<string, any>, string, string> | null | undefined>) => {
49
+ export declare const asLinkAttrs: <LinkResolverFunctionReturnType = string | null | undefined, Field extends FilledContentRelationshipField<string, string, unknown> | import("../types/value/link").EmptyLinkField<"Any"> | FilledLinkToWebField | FilledLinkToMediaField | PrismicDocument<Record<string, any>, string, string> | null | undefined = FilledContentRelationshipField<string, string, unknown> | import("../types/value/link").EmptyLinkField<"Any"> | FilledLinkToWebField | FilledLinkToMediaField | PrismicDocument<Record<string, any>, string, string> | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType, FilledContentRelationshipField<string, string, unknown> | import("../types/value/link").EmptyLinkField<"Any"> | FilledLinkToWebField | FilledLinkToMediaField | PrismicDocument<Record<string, any>, string, string> | null | undefined>) => {
48
50
  href?: undefined;
49
51
  target?: undefined;
50
52
  rel?: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"asLinkAttrs.js","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\";\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\";\nimport type { PrismicDocument } from \"../types/value/document\";\nimport { FilledLinkToWebField, LinkField } from \"../types/value/link\";\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\";\n\nimport { AsLinkReturnType, LinkResolverFunction, asLink } from \"./asLink\";\nimport { link as isFilledLink } from \"./isFilled\";\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined;\n\tisExternal: boolean;\n\ttarget?: string;\n};\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>;\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void;\n};\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined;\n\t\t\ttarget?: string;\n\t\t\trel?: string;\n\t }\n\t: {\n\t\t\thref?: undefined;\n\t\t\ttarget?: undefined;\n\t\t\trel?: undefined;\n\t };\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\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\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined;\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver);\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>);\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false;\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t? \"noreferrer\"\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t};\n\t}\n\n\treturn {};\n};\n"],"names":["isFilledLink"],"mappings":";;;AAuFO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAU,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAAC,cAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,OAAM,CAAE,IACvC,aACA,eACA;AAEI,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,KAAK,OAAO,OAAO,SAAY;AAAA,IAAA;AAAA,EAEhC;AAED,SAAO;AACR;"}
1
+ {"version":3,"file":"asLinkAttrs.js","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\";\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\";\nimport type { PrismicDocument } from \"../types/value/document\";\nimport { FilledLinkToWebField, LinkField } from \"../types/value/link\";\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\";\n\nimport { AsLinkReturnType, LinkResolverFunction, asLink } from \"./asLink\";\nimport { link as isFilledLink } from \"./isFilled\";\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined;\n\tisExternal: boolean;\n\ttarget?: string;\n};\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>;\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void;\n};\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined;\n\t\t\ttarget?: string;\n\t\t\trel?: string;\n\t }\n\t: {\n\t\t\thref?: undefined;\n\t\t\ttarget?: undefined;\n\t\t\trel?: undefined;\n\t };\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n *\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\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\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\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\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined;\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver);\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>);\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false;\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t? \"noreferrer\"\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t};\n\t}\n\n\treturn {};\n};\n"],"names":["isFilledLink"],"mappings":";;;AAyFO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAU,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAAC,cAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,OAAM,CAAE,IACvC,aACA,eACA;AAEI,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,KAAK,OAAO,OAAO,SAAY;AAAA,IAAA;AAAA,EAEhC;AAED,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"asText.cjs","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"@prismicio/richtext\";\n\nimport { RichTextField } from \"../types/value/richText\";\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string];\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text 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 `asText()`\n\t *\n\t * @returns Plain text 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?: AsTextConfig,\n\t): AsTextReturnType<Field>;\n\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asText(field);\n\t * asText(field, { separator });\n\t * ```\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text 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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<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?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple;\n\t\tlet config: AsTextConfig;\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator };\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>;\n\t} else {\n\t\treturn null as AsTextReturnType<Field>;\n\t}\n};\n"],"names":["baseAsText"],"mappings":";;;AA4Ba,MAAA,SAoCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA,MAAA;AAAA,WAEN;AACG,eAAA,EAAE,GAAG;IACd;AAEM,WAAAA,gBACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EACP;AACF;;"}
1
+ {"version":3,"file":"asText.cjs","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"@prismicio/richtext\";\n\nimport { RichTextField } from \"../types/value/richText\";\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string];\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text 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 `asText()`\n\t *\n\t * @returns Plain text 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?: AsTextConfig,\n\t): AsTextReturnType<Field>;\n\n\t/**\n\t * Serializes a rich text or title field to a plain text 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 separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text 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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<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?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple;\n\t\tlet config: AsTextConfig;\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator };\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>;\n\t} else {\n\t\treturn null as AsTextReturnType<Field>;\n\t}\n};\n"],"names":["baseAsText"],"mappings":";;;AA4Ba,MAAA,SAgCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA,MAAA;AAAA,WAEN;AACG,eAAA,EAAE,GAAG;IACd;AAEM,WAAAA,gBACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EACP;AACF;;"}
@@ -35,10 +35,6 @@ export declare const asText: {
35
35
  *
36
36
  * @deprecated Use object-style configuration instead.
37
37
  *
38
- * ```ts
39
- * asText(field);
40
- * asText(field, { separator });
41
- * ```
42
38
  * @param richTextField - A rich text or title field from Prismic
43
39
  * @param separator - Separator used to join each element, defaults to a space
44
40
  *
@@ -1 +1 @@
1
- {"version":3,"file":"asText.js","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"@prismicio/richtext\";\n\nimport { RichTextField } from \"../types/value/richText\";\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string];\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text 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 `asText()`\n\t *\n\t * @returns Plain text 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?: AsTextConfig,\n\t): AsTextReturnType<Field>;\n\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * ```ts\n\t * asText(field);\n\t * asText(field, { separator });\n\t * ```\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text 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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<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?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple;\n\t\tlet config: AsTextConfig;\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator };\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>;\n\t} else {\n\t\treturn null as AsTextReturnType<Field>;\n\t}\n};\n"],"names":["baseAsText"],"mappings":";AA4Ba,MAAA,SAoCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA,MAAA;AAAA,WAEN;AACG,eAAA,EAAE,GAAG;IACd;AAEM,WAAAA,SACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EACP;AACF;"}
1
+ {"version":3,"file":"asText.js","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"@prismicio/richtext\";\n\nimport { RichTextField } from \"../types/value/richText\";\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string;\n};\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string];\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null;\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text 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 `asText()`\n\t *\n\t * @returns Plain text 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?: AsTextConfig,\n\t): AsTextReturnType<Field>;\n\n\t/**\n\t * Serializes a rich text or title field to a plain text 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 separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text 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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<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?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple;\n\t\tlet config: AsTextConfig;\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t};\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator };\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>;\n\t} else {\n\t\treturn null as AsTextReturnType<Field>;\n\t}\n};\n"],"names":["baseAsText"],"mappings":";AA4Ba,MAAA,SAgCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA,MAAA;AAAA,WAEN;AACG,eAAA,EAAE,GAAG;IACd;AAEM,WAAAA,SACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EACP;AACF;"}
@@ -1,7 +1,7 @@
1
1
  import type { ColorField } from "../types/value/color";
2
2
  import type { ContentRelationshipField } from "../types/value/contentRelationship";
3
3
  import type { DateField } from "../types/value/date";
4
- import type { AnyOEmbed, EmbedField } from "../types/value/embed";
4
+ import type { AnyOEmbed } from "../types/value/embed";
5
5
  import type { GeoPointField } from "../types/value/geoPoint";
6
6
  import type { GroupField } from "../types/value/group";
7
7
  import type { ImageField, ImageFieldImage } from "../types/value/image";
@@ -51,7 +51,7 @@ export declare const imageThumbnail: (thumbnail: ImageFieldImage | null | undefi
51
51
  *
52
52
  * @returns `true` if `field` is filled, `false` otherwise.
53
53
  */
54
- export declare const image: <ThumbnailNames extends string | null = never>(field: ImageField<ThumbnailNames> | null | undefined) => field is import("../types/value/types").Simplify<import("../types/value/image").FilledImageFieldImage & Record<Extract<ThumbnailNames, string>, import("../types/value/image").FilledImageFieldImage>>;
54
+ export declare const image: <ThumbnailNames extends string | null = never>(field: import("../types/value/types").Simplify<(import("../types/value/image").EmptyImageFieldImage & Record<Extract<ThumbnailNames, string>, import("../types/value/image").EmptyImageFieldImage>) | (import("../types/value/image").FilledImageFieldImage & Record<Extract<ThumbnailNames, string>, import("../types/value/image").FilledImageFieldImage>)> | null | undefined) => field is import("../types/value/types").Simplify<import("../types/value/image").FilledImageFieldImage & Record<Extract<ThumbnailNames, string>, import("../types/value/image").FilledImageFieldImage>>;
55
55
  /**
56
56
  * Determines if a link field is filled.
57
57
  *
@@ -59,7 +59,7 @@ export declare const image: <ThumbnailNames extends string | null = never>(field
59
59
  *
60
60
  * @returns `true` if `field` is filled, `false` otherwise.
61
61
  */
62
- export declare const link: <TypeEnum = string, LangEnum = string, DataInterface extends unknown = unknown>(field: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined) => field is import("../types/value/link").FilledLinkToWebField | import("../types/value/linkToMedia").FilledLinkToMediaField | import("../types/value/contentRelationship").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>;
62
+ export declare const link: <TypeEnum = string, LangEnum = string, DataInterface extends unknown = unknown>(field: import("../types/value/link").EmptyLinkField<"Any"> | import("../types/value/link").FilledLinkToWebField | import("../types/value/linkToMedia").FilledLinkToMediaField | import("../types/value/contentRelationship").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> | null | undefined) => field is import("../types/value/link").FilledLinkToWebField | import("../types/value/linkToMedia").FilledLinkToMediaField | import("../types/value/contentRelationship").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>;
63
63
  /**
64
64
  * Determines if a link to media field is filled.
65
65
  *
@@ -75,7 +75,7 @@ export declare const linkToMedia: (field: LinkToMediaField | null | undefined) =
75
75
  *
76
76
  * @returns `true` if `field` is filled, `false` otherwise.
77
77
  */
78
- export declare const contentRelationship: <TypeEnum = string, LangEnum = string, DataInterface extends unknown = unknown>(field: ContentRelationshipField<TypeEnum, LangEnum, DataInterface> | null | undefined) => field is import("../types/value/contentRelationship").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>;
78
+ export declare const contentRelationship: <TypeEnum = string, LangEnum = string, DataInterface extends unknown = unknown>(field: import("../types/value/link").EmptyLinkField<"Document"> | import("../types/value/contentRelationship").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> | null | undefined) => field is import("../types/value/contentRelationship").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>;
79
79
  /**
80
80
  * Determines if a date field is filled.
81
81
  *
@@ -123,7 +123,7 @@ export declare const keyText: (field: KeyTextField | null | undefined) => field
123
123
  *
124
124
  * @returns `true` if `field` is filled, `false` otherwise.
125
125
  */
126
- export declare const select: <Enum extends string>(field: SelectField<Enum> | undefined) => field is Enum;
126
+ export declare const select: <Enum extends string>(field: Enum | null | undefined) => field is Enum;
127
127
  /**
128
128
  * Determines if an embed field is filled.
129
129
  *
@@ -131,7 +131,10 @@ export declare const select: <Enum extends string>(field: SelectField<Enum> | un
131
131
  *
132
132
  * @returns `true` if `field` is filled, `false` otherwise.
133
133
  */
134
- export declare const embed: <Field extends EmbedField<AnyOEmbed>>(field: Field | null | undefined) => field is Extract<Field, AnyOEmbed & {
134
+ export declare const embed: <Field extends import("../types/value/types").EmptyObjectField | (AnyOEmbed & {
135
+ embed_url: string;
136
+ html: string | null;
137
+ })>(field: Field | null | undefined) => field is Extract<Field, AnyOEmbed & {
135
138
  embed_url: string;
136
139
  html: string | null;
137
140
  }>;
@@ -153,11 +156,11 @@ export declare const geoPoint: (field: GeoPointField | null | undefined) => fiel
153
156
  *
154
157
  * @returns `true` if `field` is filled, `false` otherwise.
155
158
  */
156
- export declare const integrationField: <Data extends Record<string, unknown>>(field: IntegrationField<Data> | undefined) => field is Data;
159
+ export declare const integrationField: <Data extends Record<string, unknown>>(field: Data | null | undefined) => field is Data;
157
160
  /**
158
161
  * @deprecated Renamed to `integrationField`.
159
162
  */
160
- export declare const integrationFields: <Data extends Record<string, unknown>>(field: IntegrationField<Data> | undefined) => field is Data;
163
+ export declare const integrationFields: <Data extends Record<string, unknown>>(field: Data | null | undefined) => field is Data;
161
164
  /**
162
165
  * Determines if a Group has at least one item.
163
166
  *
@@ -165,7 +168,7 @@ export declare const integrationFields: <Data extends Record<string, unknown>>(f
165
168
  *
166
169
  * @returns `true` if `group` contains at least one item, `false` otherwise.
167
170
  */
168
- export declare const group: <Fields extends Record<string, AnyRegularField>>(group: GroupField<Fields> | null | undefined) => group is [Fields, ...Fields[]];
171
+ export declare const group: <Fields extends Record<string, AnyRegularField>>(group: [] | [Fields, ...Fields[]] | null | undefined) => group is [Fields, ...Fields[]];
169
172
  /**
170
173
  * Determines if a Slice Zone has at least one Slice.
171
174
  *
@@ -173,4 +176,4 @@ export declare const group: <Fields extends Record<string, AnyRegularField>>(gro
173
176
  *
174
177
  * @returns `true` if `slices` contains at least one Slice, `false` otherwise.
175
178
  */
176
- export declare const sliceZone: <Slices extends Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice>(slices: SliceZone<Slices> | null | undefined) => slices is [Slices, ...Slices[]];
179
+ export declare const sliceZone: <Slices extends Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, import("..").SharedSliceVariation<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>>>>(slices: [] | [Slices, ...Slices[]] | null | undefined) => slices is [Slices, ...Slices[]];
@@ -1 +1 @@
1
- {"version":3,"file":"unstable_mapSliceZone.cjs","sources":["../../../src/helpers/unstable_mapSliceZone.ts"],"sourcesContent":["import { Slice } from \"../types/value/slice\";\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>;\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>;\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceGraphQLLike\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceGraphQLLike<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `unstable_mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| Slice<TSliceType>\n\t| SliceGraphQLLike<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true;\n};\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `unstable_mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `unstable_mapSliceZone()` and\n * made available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceGraphQLLike ? SliceGraphQLLike : Slice\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `unstable_mapSliceZone()` and made available to\n\t * all Slice mappers.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A record of mappers.\n */\nexport type Mappers<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t[P in ExtractSliceType<TSlice>]: MaybeLazyModule<\n\t\tMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>;\n};\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type Mapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: MapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>;\n\n/**\n * Arguments provided to a mapper function.\n */\nexport type MapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = SliceMapperArgs<TSlice, TContext>;\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazyMapperModule<TMapper extends Mapper | LazyModule<Mapper>> =\n\tTMapper extends LazyModule<Mapper>\n\t\t? Awaited<ReturnType<TMapper>> extends {\n\t\t\t\tdefault: unknown;\n\t\t }\n\t\t\t? Awaited<ReturnType<TMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TMapper>>\n\t\t: TMapper;\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TMappers\n\t\t? Slice<TSliceLike[\"slice_type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<\n\t\t\t\t\t\tResolveLazyMapperModule<TMappers[TSliceLike[\"slice_type\"]]>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: TSliceLike extends SliceGraphQLLike\n\t? TSliceLike[\"type\"] extends keyof TMappers\n\t\t? SliceGraphQLLike<TSliceLike[\"type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<ResolveLazyMapperModule<TMappers[TSliceLike[\"type\"]]>>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: never;\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await unstable_mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n *\n * @experimental Names and implementations may change in the future.\n * `unstable_mapSliceZone()` does not follow SemVer.\n */\nexport function unstable_mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice;\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type;\n\n\t\t\tconst mapper = mappers[sliceType];\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice;\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context };\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(mapperArgs);\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result;\n\t\t\t\tresult = await result(mapperArgs);\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"names":[],"mappings":";;AAmNgB,SAAA,sBAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAS;AAEhC,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IACP;AAED,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAI9C,QAAA,SAAS,MAAM,OAAO,UAAU;AAKpC;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAChC;AAED,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA,MAAA;AAAA,WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEJ;AAAA,EACD,CAAA,CAAC;AAEJ;;"}
1
+ {"version":3,"file":"unstable_mapSliceZone.cjs","sources":["../../../src/helpers/unstable_mapSliceZone.ts"],"sourcesContent":["import { Slice } from \"../types/value/slice\";\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>;\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>;\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `unstable_mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true;\n};\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `unstable_mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `unstable_mapSliceZone()` and\n * made available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `unstable_mapSliceZone()` and made available to\n\t * all Slice mappers.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A record of mappers.\n */\nexport type Mappers<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t[P in ExtractSliceType<TSlice>]: MaybeLazyModule<\n\t\tMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>;\n};\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type Mapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: MapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>;\n\n/**\n * Arguments provided to a mapper function.\n */\nexport type MapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = SliceMapperArgs<TSlice, TContext>;\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazyMapperModule<TMapper extends Mapper | LazyModule<Mapper>> =\n\tTMapper extends LazyModule<Mapper>\n\t\t? Awaited<ReturnType<TMapper>> extends {\n\t\t\t\tdefault: unknown;\n\t\t }\n\t\t\t? Awaited<ReturnType<TMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TMapper>>\n\t\t: TMapper;\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TMappers\n\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<\n\t\t\t\t\t\tResolveLazyMapperModule<TMappers[TSliceLike[\"slice_type\"]]>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t? TSliceLike[\"type\"] extends keyof TMappers\n\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<ResolveLazyMapperModule<TMappers[TSliceLike[\"type\"]]>>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: never;\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await unstable_mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n *\n * @experimental Names and implementations may change in the future.\n * `unstable_mapSliceZone()` does not follow SemVer.\n */\nexport function unstable_mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice;\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type;\n\n\t\t\tconst mapper = mappers[sliceType];\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice;\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context };\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(mapperArgs);\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result;\n\t\t\t\tresult = await result(mapperArgs);\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"names":[],"mappings":";;AA8NgB,SAAA,sBAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAS;AAEhC,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IACP;AAED,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAI9C,QAAA,SAAS,MAAM,OAAO,UAAU;AAKpC;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAChC;AAED,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA,MAAA;AAAA,WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEJ;AAAA,EACD,CAAA,CAAC;AAEJ;;"}
@@ -15,14 +15,21 @@ type MaybeLazyModule<T> = T | LazyModule<T>;
15
15
  *
16
16
  * @typeParam Slice - The Slice from which the type will be extracted.
17
17
  */
18
- type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice ? TSlice["slice_type"] : TSlice extends SliceGraphQLLike ? TSlice["type"] : never;
18
+ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
19
+ /**
20
+ * The minimum required properties to represent a Prismic Slice from the Prismic
21
+ * Rest API V2 for the `unstable_mapSliceZone()` helper.
22
+ *
23
+ * @typeParam SliceType - Type name of the Slice.
24
+ */
25
+ type SliceLikeRestV2<TSliceType extends string = string> = Pick<Slice<TSliceType>, "id" | "slice_type">;
19
26
  /**
20
27
  * The minimum required properties to represent a Prismic Slice from the Prismic
21
28
  * GraphQL API for the `unstable_mapSliceZone()` helper.
22
29
  *
23
30
  * @typeParam SliceType - Type name of the Slice.
24
31
  */
25
- type SliceGraphQLLike<TSliceType extends string = string> = {
32
+ type SliceLikeGraphQL<TSliceType extends string = string> = {
26
33
  type: Slice<TSliceType>["slice_type"];
27
34
  };
28
35
  /**
@@ -34,7 +41,7 @@ type SliceGraphQLLike<TSliceType extends string = string> = {
34
41
  *
35
42
  * @typeParam SliceType - Type name of the Slice.
36
43
  */
37
- type SliceLike<TSliceType extends string = string> = Slice<TSliceType> | SliceGraphQLLike<TSliceType>;
44
+ type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>;
38
45
  /**
39
46
  * A looser version of the `SliceZone` type from `@prismicio/client` using
40
47
  * `SliceLike`.
@@ -79,7 +86,7 @@ type SliceMapperArgs<TSlice extends SliceLike = SliceLike, TContext = unknown> =
79
86
  /**
80
87
  * All Slices from the Slice Zone to which the Slice belongs.
81
88
  */
82
- slices: SliceZoneLike<TSlice extends SliceGraphQLLike ? SliceGraphQLLike : Slice>;
89
+ slices: SliceZoneLike<TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2>;
83
90
  /**
84
91
  * Arbitrary data passed to `unstable_mapSliceZone()` and made available to
85
92
  * all Slice mappers.
@@ -110,7 +117,7 @@ type ResolveLazyMapperModule<TMapper extends Mapper | LazyModule<Mapper>> = TMap
110
117
  /**
111
118
  * Transforms a Slice into its mapped version.
112
119
  */
113
- type MapSliceLike<TSliceLike extends SliceLike, TMappers extends Mappers> = TSliceLike extends Slice ? TSliceLike["slice_type"] extends keyof TMappers ? Slice<TSliceLike["slice_type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["slice_type"]]>>> : TSliceLike : TSliceLike extends SliceGraphQLLike ? TSliceLike["type"] extends keyof TMappers ? SliceGraphQLLike<TSliceLike["type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["type"]]>>> : TSliceLike : never;
120
+ type MapSliceLike<TSliceLike extends SliceLike, TMappers extends Mappers> = TSliceLike extends Slice ? TSliceLike["slice_type"] extends keyof TMappers ? SliceLikeRestV2<TSliceLike["slice_type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["slice_type"]]>>> : TSliceLike : TSliceLike extends SliceLikeGraphQL ? TSliceLike["type"] extends keyof TMappers ? SliceLikeGraphQL<TSliceLike["type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["type"]]>>> : TSliceLike : never;
114
121
  /**
115
122
  * Transforms a Slice Zone using a set of mapping functions, one for each type
116
123
  * of Slice. Mapping functions can be async.
@@ -1 +1 @@
1
- {"version":3,"file":"unstable_mapSliceZone.js","sources":["../../../src/helpers/unstable_mapSliceZone.ts"],"sourcesContent":["import { Slice } from \"../types/value/slice\";\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>;\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>;\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceGraphQLLike\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceGraphQLLike<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `unstable_mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| Slice<TSliceType>\n\t| SliceGraphQLLike<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true;\n};\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `unstable_mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `unstable_mapSliceZone()` and\n * made available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceGraphQLLike ? SliceGraphQLLike : Slice\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `unstable_mapSliceZone()` and made available to\n\t * all Slice mappers.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A record of mappers.\n */\nexport type Mappers<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t[P in ExtractSliceType<TSlice>]: MaybeLazyModule<\n\t\tMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>;\n};\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type Mapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: MapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>;\n\n/**\n * Arguments provided to a mapper function.\n */\nexport type MapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = SliceMapperArgs<TSlice, TContext>;\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazyMapperModule<TMapper extends Mapper | LazyModule<Mapper>> =\n\tTMapper extends LazyModule<Mapper>\n\t\t? Awaited<ReturnType<TMapper>> extends {\n\t\t\t\tdefault: unknown;\n\t\t }\n\t\t\t? Awaited<ReturnType<TMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TMapper>>\n\t\t: TMapper;\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TMappers\n\t\t? Slice<TSliceLike[\"slice_type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<\n\t\t\t\t\t\tResolveLazyMapperModule<TMappers[TSliceLike[\"slice_type\"]]>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: TSliceLike extends SliceGraphQLLike\n\t? TSliceLike[\"type\"] extends keyof TMappers\n\t\t? SliceGraphQLLike<TSliceLike[\"type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<ResolveLazyMapperModule<TMappers[TSliceLike[\"type\"]]>>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: never;\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await unstable_mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n *\n * @experimental Names and implementations may change in the future.\n * `unstable_mapSliceZone()` does not follow SemVer.\n */\nexport function unstable_mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice;\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type;\n\n\t\t\tconst mapper = mappers[sliceType];\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice;\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context };\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(mapperArgs);\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result;\n\t\t\t\tresult = await result(mapperArgs);\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"names":[],"mappings":"AAmNgB,SAAA,sBAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAS;AAEhC,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IACP;AAED,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAI9C,QAAA,SAAS,MAAM,OAAO,UAAU;AAKpC;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAChC;AAED,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA,MAAA;AAAA,WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEJ;AAAA,EACD,CAAA,CAAC;AAEJ;"}
1
+ {"version":3,"file":"unstable_mapSliceZone.js","sources":["../../../src/helpers/unstable_mapSliceZone.ts"],"sourcesContent":["import { Slice } from \"../types/value/slice\";\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>;\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>;\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `unstable_mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true;\n};\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `unstable_mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `unstable_mapSliceZone()` and\n * made available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `unstable_mapSliceZone()` and made available to\n\t * all Slice mappers.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A record of mappers.\n */\nexport type Mappers<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t[P in ExtractSliceType<TSlice>]: MaybeLazyModule<\n\t\tMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>;\n};\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type Mapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: MapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>;\n\n/**\n * Arguments provided to a mapper function.\n */\nexport type MapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = SliceMapperArgs<TSlice, TContext>;\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazyMapperModule<TMapper extends Mapper | LazyModule<Mapper>> =\n\tTMapper extends LazyModule<Mapper>\n\t\t? Awaited<ReturnType<TMapper>> extends {\n\t\t\t\tdefault: unknown;\n\t\t }\n\t\t\t? Awaited<ReturnType<TMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TMapper>>\n\t\t: TMapper;\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TMappers\n\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<\n\t\t\t\t\t\tResolveLazyMapperModule<TMappers[TSliceLike[\"slice_type\"]]>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t? TSliceLike[\"type\"] extends keyof TMappers\n\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\tMappedSliceLike &\n\t\t\t\tAwaited<\n\t\t\t\t\tReturnType<ResolveLazyMapperModule<TMappers[TSliceLike[\"type\"]]>>\n\t\t\t\t>\n\t\t: TSliceLike\n\t: never;\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await unstable_mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n *\n * @experimental Names and implementations may change in the future.\n * `unstable_mapSliceZone()` does not follow SemVer.\n */\nexport function unstable_mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTMappers extends Mappers,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice;\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type;\n\n\t\t\tconst mapper = mappers[sliceType];\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice;\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context };\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(mapperArgs);\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result;\n\t\t\t\tresult = await result(mapperArgs);\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"names":[],"mappings":"AA8NgB,SAAA,sBAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAS;AAEhC,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IACP;AAED,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAI9C,QAAA,SAAS,MAAM,OAAO,UAAU;AAKpC;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAChC;AAED,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA,MAAA;AAAA,WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEJ;AAAA,EACD,CAAA,CAAC;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isRepositoryEndpoint.cjs","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n"],"names":[],"mappings":";;AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACN;AACM,WAAA;AAAA,EACP;AACF;;"}
1
+ {"version":3,"file":"isRepositoryEndpoint.cjs","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n"],"names":[],"mappings":";;AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,EACP;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isRepositoryEndpoint.js","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n"],"names":[],"mappings":"AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACN;AACM,WAAA;AAAA,EACP;AACF;"}
1
+ {"version":3,"file":"isRepositoryEndpoint.js","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n"],"names":[],"mappings":"AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,EACP;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"devMsg.cjs","sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/client/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/client/v${version}/${slug}`;\n};\n"],"names":["version"],"mappings":";;;AAiBa,MAAA,SAAS,CAAC,SAAwB;AAC9C,SAAO,mCAAmCA,SAAAA,WAAW;AACtD;;"}
1
+ {"version":3,"file":"devMsg.cjs","sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/client/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/client/v${version}/${slug}`;\n};\n"],"names":["version"],"mappings":";;;AAiBa,MAAA,SAAS,CAAC,SAAwB;AACvC,SAAA,mCAAmCA,SAAAA,OAAO,IAAI,IAAI;AAC1D;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"devMsg.js","sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/client/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/client/v${version}/${slug}`;\n};\n"],"names":[],"mappings":";AAiBa,MAAA,SAAS,CAAC,SAAwB;AAC9C,SAAO,mCAAmC,WAAW;AACtD;"}
1
+ {"version":3,"file":"devMsg.js","sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/client/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/client/v${version}/${slug}`;\n};\n"],"names":[],"mappings":";AAiBa,MAAA,SAAS,CAAC,SAAwB;AACvC,SAAA,mCAAmC,OAAO,IAAI,IAAI;AAC1D;"}
@@ -1 +1 @@
1
- {"version":3,"file":"serializerHelpers.cjs","sources":["../../../src/lib/serializerHelpers.ts"],"sourcesContent":["import { LinkType } from \"../types/value/link\";\nimport {\n\tRTBlockNode,\n\tRTEmbedNode,\n\tRTImageNode,\n\tRTInlineNode,\n\tRTLinkNode,\n\tRTPreformattedNode,\n\tRichTextNodeType,\n} from \"../types/value/richText\";\n\nimport { LinkResolverFunction, asLink } from \"../helpers/asLink\";\n\nimport { escapeHTML } from \"./escapeHTML\";\n\nexport const getLabel = (node: RTBlockNode | RTInlineNode): string => {\n\treturn \"data\" in node && \"label\" in node.data\n\t\t? ` class=\"${node.data.label}\"`\n\t\t: \"\";\n};\n\nexport const serializeStandardTag = (\n\ttag: string,\n\tnode: RTBlockNode | RTInlineNode,\n\tchildren: string[],\n): string => {\n\treturn `<${tag}${getLabel(node)}>${children.join(\"\")}</${tag}>`;\n};\n\nexport const serializePreFormatted = (node: RTPreformattedNode): string => {\n\treturn `<pre${getLabel(node)}>${escapeHTML(node.text)}</pre>`;\n};\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTImageNode,\n): string => {\n\tlet imageTag = `<img src=\"${node.url}\" alt=\"${escapeHTML(node.alt)}\"${\n\t\tnode.copyright ? ` copyright=\"${escapeHTML(node.copyright)}\"` : \"\"\n\t} />`;\n\n\t// If the image has a link, we wrap it with an anchor tag\n\tif (node.linkTo) {\n\t\timageTag = serializeHyperlink(\n\t\t\tlinkResolver,\n\t\t\t{\n\t\t\t\ttype: RichTextNodeType.hyperlink,\n\t\t\t\tdata: node.linkTo,\n\t\t\t\tstart: 0,\n\t\t\t\tend: 0,\n\t\t\t},\n\t\t\t[imageTag],\n\t\t);\n\t}\n\n\treturn `<p class=\"block-img\">${imageTag}</p>`;\n};\n\nexport const serializeEmbed = (node: RTEmbedNode): string => {\n\treturn `<div data-oembed=\"${node.oembed.embed_url}\" data-oembed-type=\"${\n\t\tnode.oembed.type\n\t}\" data-oembed-provider=\"${node.oembed.provider_name}\"${getLabel(node)}>${\n\t\tnode.oembed.html\n\t}</div>`;\n};\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTLinkNode,\n\tchildren: string[],\n): string => {\n\tswitch (node.data.link_type) {\n\t\tcase LinkType.Web: {\n\t\t\treturn `<a href=\"${escapeHTML(node.data.url)}\" ${\n\t\t\t\tnode.data.target ? `target=\"${node.data.target}\" ` : \"\"\n\t\t\t}rel=\"noopener noreferrer\"${getLabel(node)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Document: {\n\t\t\treturn `<a href=\"${asLink(node.data, linkResolver)}\"${getLabel(\n\t\t\t\tnode,\n\t\t\t)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Media: {\n\t\t\treturn `<a href=\"${node.data.url}\"${getLabel(node)}>${children.join(\n\t\t\t\t\"\",\n\t\t\t)}</a>`;\n\t\t}\n\t}\n};\n\nexport const serializeSpan = (content?: string): string => {\n\treturn content ? escapeHTML(content).replace(/\\n/g, \"<br />\") : \"\";\n};\n"],"names":["escapeHTML","RichTextNodeType","LinkType","asLink"],"mappings":";;;;;;AAea,MAAA,WAAW,CAAC,SAA4C;AAC7D,SAAA,UAAU,QAAQ,WAAW,KAAK,OACtC,WAAW,KAAK,KAAK,WACrB;AACJ;AAEO,MAAM,uBAAuB,CACnC,KACA,MACA,aACW;AACJ,SAAA,IAAI,MAAM,SAAS,IAAI,KAAK,SAAS,KAAK,EAAE,MAAM;AAC1D;AAEa,MAAA,wBAAwB,CAAC,SAAoC;AACzE,SAAO,OAAO,SAAS,IAAI,KAAKA,WAAA,WAAW,KAAK,IAAI;AACrD;AAEa,MAAA,iBAAiB,CAC7B,cAIA,SACW;AACX,MAAI,WAAW,aAAa,KAAK,aAAaA,sBAAW,KAAK,GAAG,KAChE,KAAK,YAAY,eAAeA,WAAAA,WAAW,KAAK,SAAS,OAAO;AAIjE,MAAI,KAAK,QAAQ;AAChB,eAAW,mBACV,cACA;AAAA,MACC,MAAMC,SAAiB,iBAAA;AAAA,MACvB,MAAM,KAAK;AAAA,MACX,OAAO;AAAA,MACP,KAAK;AAAA,IAAA,GAEN,CAAC,QAAQ,CAAC;AAAA,EAEX;AAED,SAAO,wBAAwB;AAChC;AAEa,MAAA,iBAAiB,CAAC,SAA6B;AAC3D,SAAO,qBAAqB,KAAK,OAAO,gCACvC,KAAK,OAAO,+BACc,KAAK,OAAO,iBAAiB,SAAS,IAAI,KACpE,KAAK,OAAO;AAEd;AAEO,MAAM,qBAAqB,CACjC,cAIA,MACA,aACW;AACH,UAAA,KAAK,KAAK,WAAW;AAAA,IAC5B,KAAKC,KAAAA,SAAS,KAAK;AAClB,aAAO,YAAYF,WAAAA,WAAW,KAAK,KAAK,GAAG,MAC1C,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,aAAa,8BAC1B,SAAS,IAAI,KAAK,SAAS,KAAK,EAAE;AAAA,IAC9D;AAAA,IAED,KAAKE,KAAAA,SAAS,UAAU;AAChB,aAAA,YAAYC,OAAO,OAAA,KAAK,MAAM,YAAY,KAAK,SACrD,IAAI,KACA,SAAS,KAAK,EAAE;AAAA,IACrB;AAAA,IAED,KAAKD,KAAAA,SAAS,OAAO;AACb,aAAA,YAAY,KAAK,KAAK,OAAO,SAAS,IAAI,KAAK,SAAS,KAC9D,EAAE;AAAA,IAEH;AAAA,EACD;AACF;AAEa,MAAA,gBAAgB,CAAC,YAA4B;AACzD,SAAO,UAAUF,WAAW,WAAA,OAAO,EAAE,QAAQ,OAAO,QAAQ,IAAI;AACjE;;;;;;;;"}
1
+ {"version":3,"file":"serializerHelpers.cjs","sources":["../../../src/lib/serializerHelpers.ts"],"sourcesContent":["import { LinkType } from \"../types/value/link\";\nimport {\n\tRTBlockNode,\n\tRTEmbedNode,\n\tRTImageNode,\n\tRTInlineNode,\n\tRTLinkNode,\n\tRTPreformattedNode,\n\tRichTextNodeType,\n} from \"../types/value/richText\";\n\nimport { LinkResolverFunction, asLink } from \"../helpers/asLink\";\n\nimport { escapeHTML } from \"./escapeHTML\";\n\nexport const getLabel = (node: RTBlockNode | RTInlineNode): string => {\n\treturn \"data\" in node && \"label\" in node.data\n\t\t? ` class=\"${node.data.label}\"`\n\t\t: \"\";\n};\n\nexport const serializeStandardTag = (\n\ttag: string,\n\tnode: RTBlockNode | RTInlineNode,\n\tchildren: string[],\n): string => {\n\treturn `<${tag}${getLabel(node)}>${children.join(\"\")}</${tag}>`;\n};\n\nexport const serializePreFormatted = (node: RTPreformattedNode): string => {\n\treturn `<pre${getLabel(node)}>${escapeHTML(node.text)}</pre>`;\n};\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTImageNode,\n): string => {\n\tlet imageTag = `<img src=\"${node.url}\" alt=\"${escapeHTML(node.alt)}\"${\n\t\tnode.copyright ? ` copyright=\"${escapeHTML(node.copyright)}\"` : \"\"\n\t} />`;\n\n\t// If the image has a link, we wrap it with an anchor tag\n\tif (node.linkTo) {\n\t\timageTag = serializeHyperlink(\n\t\t\tlinkResolver,\n\t\t\t{\n\t\t\t\ttype: RichTextNodeType.hyperlink,\n\t\t\t\tdata: node.linkTo,\n\t\t\t\tstart: 0,\n\t\t\t\tend: 0,\n\t\t\t},\n\t\t\t[imageTag],\n\t\t);\n\t}\n\n\treturn `<p class=\"block-img\">${imageTag}</p>`;\n};\n\nexport const serializeEmbed = (node: RTEmbedNode): string => {\n\treturn `<div data-oembed=\"${node.oembed.embed_url}\" data-oembed-type=\"${\n\t\tnode.oembed.type\n\t}\" data-oembed-provider=\"${node.oembed.provider_name}\"${getLabel(node)}>${\n\t\tnode.oembed.html\n\t}</div>`;\n};\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTLinkNode,\n\tchildren: string[],\n): string => {\n\tswitch (node.data.link_type) {\n\t\tcase LinkType.Web: {\n\t\t\treturn `<a href=\"${escapeHTML(node.data.url)}\" ${\n\t\t\t\tnode.data.target ? `target=\"${node.data.target}\" ` : \"\"\n\t\t\t}rel=\"noopener noreferrer\"${getLabel(node)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Document: {\n\t\t\treturn `<a href=\"${asLink(node.data, linkResolver)}\"${getLabel(\n\t\t\t\tnode,\n\t\t\t)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Media: {\n\t\t\treturn `<a href=\"${node.data.url}\"${getLabel(node)}>${children.join(\n\t\t\t\t\"\",\n\t\t\t)}</a>`;\n\t\t}\n\t}\n};\n\nexport const serializeSpan = (content?: string): string => {\n\treturn content ? escapeHTML(content).replace(/\\n/g, \"<br />\") : \"\";\n};\n"],"names":["escapeHTML","RichTextNodeType","LinkType","asLink"],"mappings":";;;;;;AAea,MAAA,WAAW,CAAC,SAA4C;AAC7D,SAAA,UAAU,QAAQ,WAAW,KAAK,OACtC,WAAW,KAAK,KAAK,KAAK,MAC1B;AACJ;AAEO,MAAM,uBAAuB,CACnC,KACA,MACA,aACW;AACX,SAAO,IAAI,GAAG,GAAG,SAAS,IAAI,CAAC,IAAI,SAAS,KAAK,EAAE,CAAC,KAAK,GAAG;AAC7D;AAEa,MAAA,wBAAwB,CAAC,SAAoC;AAClE,SAAA,OAAO,SAAS,IAAI,CAAC,IAAIA,WAAW,WAAA,KAAK,IAAI,CAAC;AACtD;AAEa,MAAA,iBAAiB,CAC7B,cAIA,SACW;AACX,MAAI,WAAW,aAAa,KAAK,GAAG,UAAUA,sBAAW,KAAK,GAAG,CAAC,IACjE,KAAK,YAAY,eAAeA,WAAAA,WAAW,KAAK,SAAS,CAAC,MAAM,EACjE;AAGA,MAAI,KAAK,QAAQ;AAChB,eAAW,mBACV,cACA;AAAA,MACC,MAAMC,SAAiB,iBAAA;AAAA,MACvB,MAAM,KAAK;AAAA,MACX,OAAO;AAAA,MACP,KAAK;AAAA,IAAA,GAEN,CAAC,QAAQ,CAAC;AAAA,EAEX;AAED,SAAO,wBAAwB,QAAQ;AACxC;AAEa,MAAA,iBAAiB,CAAC,SAA6B;AAC3D,SAAO,qBAAqB,KAAK,OAAO,SAAS,uBAChD,KAAK,OAAO,IACb,2BAA2B,KAAK,OAAO,aAAa,IAAI,SAAS,IAAI,CAAC,IACrE,KAAK,OAAO,IACb;AACD;AAEO,MAAM,qBAAqB,CACjC,cAIA,MACA,aACW;AACH,UAAA,KAAK,KAAK,WAAW;AAAA,IAC5B,KAAKC,KAAAA,SAAS,KAAK;AACX,aAAA,YAAYF,WAAAA,WAAW,KAAK,KAAK,GAAG,CAAC,KAC3C,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,MAAM,OAAO,EACtD,4BAA4B,SAAS,IAAI,CAAC,IAAI,SAAS,KAAK,EAAE,CAAC;AAAA,IAC/D;AAAA,IAED,KAAKE,KAAAA,SAAS,UAAU;AACvB,aAAO,YAAYC,OAAA,OAAO,KAAK,MAAM,YAAY,CAAC,IAAI,SACrD,IAAI,CACJ,IAAI,SAAS,KAAK,EAAE,CAAC;AAAA,IACtB;AAAA,IAED,KAAKD,KAAAA,SAAS,OAAO;AACpB,aAAO,YAAY,KAAK,KAAK,GAAG,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,KAC9D,EAAE,CACF;AAAA,IACD;AAAA,EACD;AACF;AAEa,MAAA,gBAAgB,CAAC,YAA4B;AACzD,SAAO,UAAUF,WAAW,WAAA,OAAO,EAAE,QAAQ,OAAO,QAAQ,IAAI;AACjE;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"serializerHelpers.js","sources":["../../../src/lib/serializerHelpers.ts"],"sourcesContent":["import { LinkType } from \"../types/value/link\";\nimport {\n\tRTBlockNode,\n\tRTEmbedNode,\n\tRTImageNode,\n\tRTInlineNode,\n\tRTLinkNode,\n\tRTPreformattedNode,\n\tRichTextNodeType,\n} from \"../types/value/richText\";\n\nimport { LinkResolverFunction, asLink } from \"../helpers/asLink\";\n\nimport { escapeHTML } from \"./escapeHTML\";\n\nexport const getLabel = (node: RTBlockNode | RTInlineNode): string => {\n\treturn \"data\" in node && \"label\" in node.data\n\t\t? ` class=\"${node.data.label}\"`\n\t\t: \"\";\n};\n\nexport const serializeStandardTag = (\n\ttag: string,\n\tnode: RTBlockNode | RTInlineNode,\n\tchildren: string[],\n): string => {\n\treturn `<${tag}${getLabel(node)}>${children.join(\"\")}</${tag}>`;\n};\n\nexport const serializePreFormatted = (node: RTPreformattedNode): string => {\n\treturn `<pre${getLabel(node)}>${escapeHTML(node.text)}</pre>`;\n};\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTImageNode,\n): string => {\n\tlet imageTag = `<img src=\"${node.url}\" alt=\"${escapeHTML(node.alt)}\"${\n\t\tnode.copyright ? ` copyright=\"${escapeHTML(node.copyright)}\"` : \"\"\n\t} />`;\n\n\t// If the image has a link, we wrap it with an anchor tag\n\tif (node.linkTo) {\n\t\timageTag = serializeHyperlink(\n\t\t\tlinkResolver,\n\t\t\t{\n\t\t\t\ttype: RichTextNodeType.hyperlink,\n\t\t\t\tdata: node.linkTo,\n\t\t\t\tstart: 0,\n\t\t\t\tend: 0,\n\t\t\t},\n\t\t\t[imageTag],\n\t\t);\n\t}\n\n\treturn `<p class=\"block-img\">${imageTag}</p>`;\n};\n\nexport const serializeEmbed = (node: RTEmbedNode): string => {\n\treturn `<div data-oembed=\"${node.oembed.embed_url}\" data-oembed-type=\"${\n\t\tnode.oembed.type\n\t}\" data-oembed-provider=\"${node.oembed.provider_name}\"${getLabel(node)}>${\n\t\tnode.oembed.html\n\t}</div>`;\n};\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTLinkNode,\n\tchildren: string[],\n): string => {\n\tswitch (node.data.link_type) {\n\t\tcase LinkType.Web: {\n\t\t\treturn `<a href=\"${escapeHTML(node.data.url)}\" ${\n\t\t\t\tnode.data.target ? `target=\"${node.data.target}\" ` : \"\"\n\t\t\t}rel=\"noopener noreferrer\"${getLabel(node)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Document: {\n\t\t\treturn `<a href=\"${asLink(node.data, linkResolver)}\"${getLabel(\n\t\t\t\tnode,\n\t\t\t)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Media: {\n\t\t\treturn `<a href=\"${node.data.url}\"${getLabel(node)}>${children.join(\n\t\t\t\t\"\",\n\t\t\t)}</a>`;\n\t\t}\n\t}\n};\n\nexport const serializeSpan = (content?: string): string => {\n\treturn content ? escapeHTML(content).replace(/\\n/g, \"<br />\") : \"\";\n};\n"],"names":[],"mappings":";;;;AAea,MAAA,WAAW,CAAC,SAA4C;AAC7D,SAAA,UAAU,QAAQ,WAAW,KAAK,OACtC,WAAW,KAAK,KAAK,WACrB;AACJ;AAEO,MAAM,uBAAuB,CACnC,KACA,MACA,aACW;AACJ,SAAA,IAAI,MAAM,SAAS,IAAI,KAAK,SAAS,KAAK,EAAE,MAAM;AAC1D;AAEa,MAAA,wBAAwB,CAAC,SAAoC;AACzE,SAAO,OAAO,SAAS,IAAI,KAAK,WAAW,KAAK,IAAI;AACrD;AAEa,MAAA,iBAAiB,CAC7B,cAIA,SACW;AACX,MAAI,WAAW,aAAa,KAAK,aAAa,WAAW,KAAK,GAAG,KAChE,KAAK,YAAY,eAAe,WAAW,KAAK,SAAS,OAAO;AAIjE,MAAI,KAAK,QAAQ;AAChB,eAAW,mBACV,cACA;AAAA,MACC,MAAM,iBAAiB;AAAA,MACvB,MAAM,KAAK;AAAA,MACX,OAAO;AAAA,MACP,KAAK;AAAA,IAAA,GAEN,CAAC,QAAQ,CAAC;AAAA,EAEX;AAED,SAAO,wBAAwB;AAChC;AAEa,MAAA,iBAAiB,CAAC,SAA6B;AAC3D,SAAO,qBAAqB,KAAK,OAAO,gCACvC,KAAK,OAAO,+BACc,KAAK,OAAO,iBAAiB,SAAS,IAAI,KACpE,KAAK,OAAO;AAEd;AAEO,MAAM,qBAAqB,CACjC,cAIA,MACA,aACW;AACH,UAAA,KAAK,KAAK,WAAW;AAAA,IAC5B,KAAK,SAAS,KAAK;AAClB,aAAO,YAAY,WAAW,KAAK,KAAK,GAAG,MAC1C,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,aAAa,8BAC1B,SAAS,IAAI,KAAK,SAAS,KAAK,EAAE;AAAA,IAC9D;AAAA,IAED,KAAK,SAAS,UAAU;AAChB,aAAA,YAAY,OAAO,KAAK,MAAM,YAAY,KAAK,SACrD,IAAI,KACA,SAAS,KAAK,EAAE;AAAA,IACrB;AAAA,IAED,KAAK,SAAS,OAAO;AACb,aAAA,YAAY,KAAK,KAAK,OAAO,SAAS,IAAI,KAAK,SAAS,KAC9D,EAAE;AAAA,IAEH;AAAA,EACD;AACF;AAEa,MAAA,gBAAgB,CAAC,YAA4B;AACzD,SAAO,UAAU,WAAW,OAAO,EAAE,QAAQ,OAAO,QAAQ,IAAI;AACjE;"}
1
+ {"version":3,"file":"serializerHelpers.js","sources":["../../../src/lib/serializerHelpers.ts"],"sourcesContent":["import { LinkType } from \"../types/value/link\";\nimport {\n\tRTBlockNode,\n\tRTEmbedNode,\n\tRTImageNode,\n\tRTInlineNode,\n\tRTLinkNode,\n\tRTPreformattedNode,\n\tRichTextNodeType,\n} from \"../types/value/richText\";\n\nimport { LinkResolverFunction, asLink } from \"../helpers/asLink\";\n\nimport { escapeHTML } from \"./escapeHTML\";\n\nexport const getLabel = (node: RTBlockNode | RTInlineNode): string => {\n\treturn \"data\" in node && \"label\" in node.data\n\t\t? ` class=\"${node.data.label}\"`\n\t\t: \"\";\n};\n\nexport const serializeStandardTag = (\n\ttag: string,\n\tnode: RTBlockNode | RTInlineNode,\n\tchildren: string[],\n): string => {\n\treturn `<${tag}${getLabel(node)}>${children.join(\"\")}</${tag}>`;\n};\n\nexport const serializePreFormatted = (node: RTPreformattedNode): string => {\n\treturn `<pre${getLabel(node)}>${escapeHTML(node.text)}</pre>`;\n};\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTImageNode,\n): string => {\n\tlet imageTag = `<img src=\"${node.url}\" alt=\"${escapeHTML(node.alt)}\"${\n\t\tnode.copyright ? ` copyright=\"${escapeHTML(node.copyright)}\"` : \"\"\n\t} />`;\n\n\t// If the image has a link, we wrap it with an anchor tag\n\tif (node.linkTo) {\n\t\timageTag = serializeHyperlink(\n\t\t\tlinkResolver,\n\t\t\t{\n\t\t\t\ttype: RichTextNodeType.hyperlink,\n\t\t\t\tdata: node.linkTo,\n\t\t\t\tstart: 0,\n\t\t\t\tend: 0,\n\t\t\t},\n\t\t\t[imageTag],\n\t\t);\n\t}\n\n\treturn `<p class=\"block-img\">${imageTag}</p>`;\n};\n\nexport const serializeEmbed = (node: RTEmbedNode): string => {\n\treturn `<div data-oembed=\"${node.oembed.embed_url}\" data-oembed-type=\"${\n\t\tnode.oembed.type\n\t}\" data-oembed-provider=\"${node.oembed.provider_name}\"${getLabel(node)}>${\n\t\tnode.oembed.html\n\t}</div>`;\n};\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tnode: RTLinkNode,\n\tchildren: string[],\n): string => {\n\tswitch (node.data.link_type) {\n\t\tcase LinkType.Web: {\n\t\t\treturn `<a href=\"${escapeHTML(node.data.url)}\" ${\n\t\t\t\tnode.data.target ? `target=\"${node.data.target}\" ` : \"\"\n\t\t\t}rel=\"noopener noreferrer\"${getLabel(node)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Document: {\n\t\t\treturn `<a href=\"${asLink(node.data, linkResolver)}\"${getLabel(\n\t\t\t\tnode,\n\t\t\t)}>${children.join(\"\")}</a>`;\n\t\t}\n\n\t\tcase LinkType.Media: {\n\t\t\treturn `<a href=\"${node.data.url}\"${getLabel(node)}>${children.join(\n\t\t\t\t\"\",\n\t\t\t)}</a>`;\n\t\t}\n\t}\n};\n\nexport const serializeSpan = (content?: string): string => {\n\treturn content ? escapeHTML(content).replace(/\\n/g, \"<br />\") : \"\";\n};\n"],"names":[],"mappings":";;;;AAea,MAAA,WAAW,CAAC,SAA4C;AAC7D,SAAA,UAAU,QAAQ,WAAW,KAAK,OACtC,WAAW,KAAK,KAAK,KAAK,MAC1B;AACJ;AAEO,MAAM,uBAAuB,CACnC,KACA,MACA,aACW;AACX,SAAO,IAAI,GAAG,GAAG,SAAS,IAAI,CAAC,IAAI,SAAS,KAAK,EAAE,CAAC,KAAK,GAAG;AAC7D;AAEa,MAAA,wBAAwB,CAAC,SAAoC;AAClE,SAAA,OAAO,SAAS,IAAI,CAAC,IAAI,WAAW,KAAK,IAAI,CAAC;AACtD;AAEa,MAAA,iBAAiB,CAC7B,cAIA,SACW;AACX,MAAI,WAAW,aAAa,KAAK,GAAG,UAAU,WAAW,KAAK,GAAG,CAAC,IACjE,KAAK,YAAY,eAAe,WAAW,KAAK,SAAS,CAAC,MAAM,EACjE;AAGA,MAAI,KAAK,QAAQ;AAChB,eAAW,mBACV,cACA;AAAA,MACC,MAAM,iBAAiB;AAAA,MACvB,MAAM,KAAK;AAAA,MACX,OAAO;AAAA,MACP,KAAK;AAAA,IAAA,GAEN,CAAC,QAAQ,CAAC;AAAA,EAEX;AAED,SAAO,wBAAwB,QAAQ;AACxC;AAEa,MAAA,iBAAiB,CAAC,SAA6B;AAC3D,SAAO,qBAAqB,KAAK,OAAO,SAAS,uBAChD,KAAK,OAAO,IACb,2BAA2B,KAAK,OAAO,aAAa,IAAI,SAAS,IAAI,CAAC,IACrE,KAAK,OAAO,IACb;AACD;AAEO,MAAM,qBAAqB,CACjC,cAIA,MACA,aACW;AACH,UAAA,KAAK,KAAK,WAAW;AAAA,IAC5B,KAAK,SAAS,KAAK;AACX,aAAA,YAAY,WAAW,KAAK,KAAK,GAAG,CAAC,KAC3C,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,MAAM,OAAO,EACtD,4BAA4B,SAAS,IAAI,CAAC,IAAI,SAAS,KAAK,EAAE,CAAC;AAAA,IAC/D;AAAA,IAED,KAAK,SAAS,UAAU;AACvB,aAAO,YAAY,OAAO,KAAK,MAAM,YAAY,CAAC,IAAI,SACrD,IAAI,CACJ,IAAI,SAAS,KAAK,EAAE,CAAC;AAAA,IACtB;AAAA,IAED,KAAK,SAAS,OAAO;AACpB,aAAO,YAAY,KAAK,KAAK,GAAG,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,KAC9D,EAAE,CACF;AAAA,IACD;AAAA,EACD;AACF;AAEa,MAAA,gBAAgB,CAAC,YAA4B;AACzD,SAAO,UAAU,WAAW,OAAO,EAAE,QAAQ,OAAO,QAAQ,IAAI;AACjE;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "7.1.0";
3
+ const version = "7.1.1";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- const version = "7.1.0";
1
+ const version = "7.1.1";
2
2
  export {
3
3
  version
4
4
  };
@@ -29,7 +29,9 @@ export interface Repository {
29
29
  */
30
30
  types: Record<string, string>;
31
31
  /**
32
- * A list of tags for the repository.
32
+ * @deprecated Tags are only available in the forms object.
33
+ *
34
+ * @see More details in the blog post "A change to how the Prismic API handles tags": {@link https://prismic.io/blog/a-change-to-how-the-prismic-api-handles-tags}
33
35
  */
34
36
  tags: string[];
35
37
  /**
@@ -42,6 +44,9 @@ export interface Repository {
42
44
  * The URL used to begin the OAuth process for the repository.
43
45
  */
44
46
  oauth_initiate: string;
47
+ /**
48
+ * The token used for the OAuth process for the repository.
49
+ */
45
50
  oauth_token: string;
46
51
  /**
47
52
  * The version of the API.