@prismicio/client 7.23.1-pr.493.6b3afad → 7.23.1-pr.494.95ca2ea

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 (49) hide show
  1. package/dist/WriteClient.cjs +1 -1
  2. package/dist/WriteClient.cjs.map +1 -1
  3. package/dist/WriteClient.d.cts +1 -1
  4. package/dist/WriteClient.d.ts +1 -1
  5. package/dist/WriteClient.js +1 -1
  6. package/dist/WriteClient.js.map +1 -1
  7. package/dist/createClient.cjs +1 -2
  8. package/dist/createClient.cjs.map +1 -1
  9. package/dist/createClient.d.cts +1 -2
  10. package/dist/createClient.d.cts.map +1 -1
  11. package/dist/createClient.d.ts +1 -2
  12. package/dist/createClient.d.ts.map +1 -1
  13. package/dist/createClient.js +1 -2
  14. package/dist/createClient.js.map +1 -1
  15. package/dist/helpers/asHTML.cjs.map +1 -1
  16. package/dist/helpers/asHTML.d.cts +2 -4
  17. package/dist/helpers/asHTML.d.cts.map +1 -1
  18. package/dist/helpers/asHTML.d.ts +2 -4
  19. package/dist/helpers/asHTML.d.ts.map +1 -1
  20. package/dist/helpers/asHTML.js.map +1 -1
  21. package/dist/helpers/asLink.cjs.map +1 -1
  22. package/dist/helpers/asLink.d.cts +2 -4
  23. package/dist/helpers/asLink.d.cts.map +1 -1
  24. package/dist/helpers/asLink.d.ts +2 -4
  25. package/dist/helpers/asLink.d.ts.map +1 -1
  26. package/dist/helpers/asLink.js.map +1 -1
  27. package/dist/helpers/asLinkAttrs.cjs +1 -2
  28. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  29. package/dist/helpers/asLinkAttrs.d.cts +1 -2
  30. package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
  31. package/dist/helpers/asLinkAttrs.d.ts +1 -2
  32. package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
  33. package/dist/helpers/asLinkAttrs.js +1 -2
  34. package/dist/helpers/asLinkAttrs.js.map +1 -1
  35. package/dist/package.cjs +1 -1
  36. package/dist/package.js +1 -1
  37. package/dist/types/value/link.cjs.map +1 -1
  38. package/dist/types/value/link.d.cts +1 -2
  39. package/dist/types/value/link.d.cts.map +1 -1
  40. package/dist/types/value/link.d.ts +1 -2
  41. package/dist/types/value/link.d.ts.map +1 -1
  42. package/dist/types/value/link.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/WriteClient.ts +1 -1
  45. package/src/createClient.ts +1 -2
  46. package/src/helpers/asHTML.ts +2 -4
  47. package/src/helpers/asLink.ts +2 -4
  48. package/src/helpers/asLinkAttrs.ts +1 -2
  49. package/src/types/value/link.ts +1 -2
@@ -45,15 +45,13 @@ type HTMLRichTextMapSerializerFunction<BlockType extends keyof RichTextMapSerial
45
45
  /**
46
46
  * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.
47
47
  *
48
- * @typeParam T - The `RichTextMapSerializerFunction` containing the needed
49
- * `Node` generic.
48
+ * @typeParam T - The `RichTextMapSerializerFunction` containing the needed `Node` generic.
50
49
  */
51
50
  type ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<any, infer U, any> ? U : never;
52
51
  /**
53
52
  * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.
54
53
  *
55
- * @typeParam T - The `RichTextMapSerializerFunction` containing the needed
56
- * `TextType` generic.
54
+ * @typeParam T - The `RichTextMapSerializerFunction` containing the needed `TextType` generic.
57
55
  */
58
56
  type ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<any, any, infer U> ? U : never;
59
57
  /** A shorthand definition for {@link HTMLRichTextMapSerializer} element types. */
@@ -1 +1 @@
1
- {"version":3,"file":"asHTML.d.ts","names":[],"sources":["../../src/helpers/asHTML.ts"],"mappings":";;;;;;;;;;;YAyBY,kCACX,MAAM,WAAW,wCACjB,MAAM,WAAW,wCACjB,MAAM,WAAW,wCACjB,UAAU,WAAW,gDACrB,KAAK,WAAW;;;;;;;;;;YAYL,+BACV,WAAW,gCAAgC,UAAU,wCACnD,gCAAgC,KAChC,gCAAgC,KAAK;;;;;;;;;;YAY7B,qCACV,WAAW,iCAAiC;EAC5C,MAAM,WAAW,kCAAkC;EACnD,MAAM,WAAW,kCAAkC;EACnD,MAAM,WAAW,kCAAkC;EACnD,UAAU,WAAW,kCAAkC;EACvD,KAAK,WAAW,kCAAkC;;;;;;;KAS/C,kCAAkC,wBAAwB,iCAC9D,sCAEC,mBAAmB,8BAA8B,aACjD,uBAAuB,8BAA8B;;;;;;;KASlD,mBAAmB,KACvB,UAAU,yCAGH,UAIJ;;;;;;;KASC,uBAAuB,KAC3B,UAAU,8CAKH,KAEJ;;YAIQ;;EAEX;;GAGC;;;;;;;;YASU,yBAAyB,4BAA4B;;KAuI5D;;;;;EAKJ,eAAe;;EAGf,aAAa;;;KAKT,+BACJ,eAAe,6BACf,aAAa;;KAIT,iBAAiB,cAAc,oCAAoC,cAAc;qBAKzE;;;;;;;;;;;;;;;;GAgBX,cAAc,kCACd,eAAe,OACf,SAAS,eACP,iBAAiB;;;;;;;;;;;;;;GAenB,cAAc,kCACd,eAAe,UACZ,QAAQ,8BACT,iBAAiB"}
1
+ {"version":3,"file":"asHTML.d.ts","names":[],"sources":["../../src/helpers/asHTML.ts"],"mappings":";;;;;;;;;;;YAyBY,kCACX,MAAM,WAAW,wCACjB,MAAM,WAAW,wCACjB,MAAM,WAAW,wCACjB,UAAU,WAAW,gDACrB,KAAK,WAAW;;;;;;;;;;YAYL,+BACV,WAAW,gCAAgC,UAAU,wCACnD,gCAAgC,KAChC,gCAAgC,KAAK;;;;;;;;;;YAY7B,qCACV,WAAW,iCAAiC;EAC5C,MAAM,WAAW,kCAAkC;EACnD,MAAM,WAAW,kCAAkC;EACnD,MAAM,WAAW,kCAAkC;EACnD,UAAU,WAAW,kCAAkC;EACvD,KAAK,WAAW,kCAAkC;;;;;;;KAS/C,kCAAkC,wBAAwB,iCAC9D,sCAEC,mBAAmB,8BAA8B,aACjD,uBAAuB,8BAA8B;;;;;;KAQlD,mBAAmB,KACvB,UAAU,yCAGH,UAIJ;;;;;;KAQC,uBAAuB,KAC3B,UAAU,8CAKH,KAEJ;;YAIQ;;EAEX;;GAGC;;;;;;;;YASU,yBAAyB,4BAA4B;;KAuI5D;;;;;EAKJ,eAAe;;EAGf,aAAa;;;KAKT,+BACJ,eAAe,6BACf,aAAa;;KAIT,iBAAiB,cAAc,oCAAoC,cAAc;qBAKzE;;;;;;;;;;;;;;;;GAgBX,cAAc,kCACd,eAAe,OACf,SAAS,eACP,iBAAiB;;;;;;;;;;;;;;GAenB,cAAc,kCACd,eAAe,UACZ,QAAQ,8BACT,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"asHTML.js","names":[],"sources":["../../src/helpers/asHTML.ts"],"sourcesContent":["import {\n\tserializeEmbed,\n\tserializeHyperlink,\n\tserializeImage,\n\tserializePreFormatted,\n\tserializeSpan,\n\tserializeStandardTag,\n} from \"../lib/serializerHelpers\"\nimport type {\n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n\tRichTextMapSerializerFunction,\n} from \"../richtext\"\nimport { composeSerializers, serialize, wrapMapSerializer } from \"../richtext\"\nimport type { RichTextField } from \"../types/value/richText\"\nimport type { LinkResolverFunction } from \"./asLink\"\n\n/**\n * Serializes a node from a rich text field with a function to HTML.\n *\n * Unlike a typical `@prismicio/client/richtext` function serializer, this serializer converts the\n * `children` argument to a single string rather than an array of strings.\n *\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLRichTextFunctionSerializer = (\n\ttype: Parameters<RichTextFunctionSerializer<string>>[0],\n\tnode: Parameters<RichTextFunctionSerializer<string>>[1],\n\ttext: Parameters<RichTextFunctionSerializer<string>>[2],\n\tchildren: Parameters<RichTextFunctionSerializer<string>>[3][number],\n\tkey: Parameters<RichTextFunctionSerializer<string>>[4],\n) => string | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map to HTML.\n *\n * Unlike a typical `@prismicio/client/richtext` map serializer, this serializer converts the\n * `children` property to a single string rather than an array of strings and accepts shorthand\n * declarations.\n *\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: P extends RichTextMapSerializer<string>[\"span\"]\n\t\t? HTMLStrictRichTextMapSerializer[P]\n\t\t: HTMLStrictRichTextMapSerializer[P] | HTMLRichTextMapSerializerShorthand\n}\n\n/**\n * Serializes a node from a rich text field with a map to HTML.\n *\n * Unlike a typical `@prismicio/client/richtext` map serializer, this serializer converts the\n * `children` property to a single string rather than an array of strings but doesn't accept\n * shorthand declarations.\n *\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLStrictRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: (payload: {\n\t\ttype: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"type\"]\n\t\tnode: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"node\"]\n\t\ttext: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"text\"]\n\t\tchildren: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"children\"][number]\n\t\tkey: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"key\"]\n\t}) => string | null | undefined\n}\n\n/**\n * A {@link RichTextMapSerializerFunction} type specifically for {@link HTMLRichTextMapSerializer}.\n *\n * @typeParam BlockName - The serializer's rich text block type.\n */\ntype HTMLRichTextMapSerializerFunction<BlockType extends keyof RichTextMapSerializer<string>> =\n\tRichTextMapSerializerFunction<\n\t\tstring,\n\t\tExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,\n\t\tExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>\n\t>\n\n/**\n * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `Node` generic.\n */\ntype ExtractNodeGeneric<T> =\n\tT extends RichTextMapSerializerFunction<\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany,\n\t\tinfer U,\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany\n\t>\n\t\t? U\n\t\t: never\n\n/**\n * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed\n * `TextType` generic.\n */\ntype ExtractTextTypeGeneric<T> =\n\tT extends RichTextMapSerializerFunction<\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany,\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany,\n\t\tinfer U\n\t>\n\t\t? U\n\t\t: never\n\n/** A shorthand definition for {@link HTMLRichTextMapSerializer} element types. */\nexport type HTMLRichTextMapSerializerShorthand = {\n\t/** Classes to apply to the element type. */\n\tclass?: string\n\n\t/** Other attributes to apply to the element type. */\n\t[Attribute: string]: string | boolean | null | undefined\n}\n\n/**\n * Serializes a node from a rich text field with a map or a function to HTML.\n *\n * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLRichTextSerializer = HTMLRichTextMapSerializer | HTMLRichTextFunctionSerializer\n\n/**\n * Creates a HTML rich text serializer with a given link resolver and provide sensible and safe\n * defaults for every node type\n *\n * @internal\n */\nconst createHTMLRichTextSerializer = (\n\tlinkResolver: LinkResolverFunction | undefined | null,\n\tserializer?: HTMLRichTextMapSerializer | null,\n): RichTextFunctionSerializer<string> => {\n\tconst useSerializerOrDefault = <BlockType extends keyof RichTextMapSerializer<string>>(\n\t\tnodeSerializerOrShorthand: HTMLRichTextMapSerializer[BlockType],\n\t\tdefaultWithShorthand: NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>,\n\t): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\t\tif (typeof nodeSerializerOrShorthand === \"function\") {\n\t\t\treturn ((payload) => {\n\t\t\t\treturn (\n\t\t\t\t\t(nodeSerializerOrShorthand as HTMLStrictRichTextMapSerializer[BlockType])?.(payload) ||\n\t\t\t\t\tdefaultWithShorthand(payload)\n\t\t\t\t)\n\t\t\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n\t\t}\n\n\t\treturn defaultWithShorthand\n\t}\n\n\tconst mapSerializer: Required<HTMLStrictRichTextMapSerializer> = {\n\t\theading1: useSerializerOrDefault<\"heading1\">(\n\t\t\tserializer?.heading1,\n\t\t\tserializeStandardTag<\"heading1\">(\"h1\", serializer?.heading1),\n\t\t),\n\t\theading2: useSerializerOrDefault<\"heading2\">(\n\t\t\tserializer?.heading2,\n\t\t\tserializeStandardTag<\"heading2\">(\"h2\", serializer?.heading2),\n\t\t),\n\t\theading3: useSerializerOrDefault<\"heading3\">(\n\t\t\tserializer?.heading3,\n\t\t\tserializeStandardTag<\"heading3\">(\"h3\", serializer?.heading3),\n\t\t),\n\t\theading4: useSerializerOrDefault<\"heading4\">(\n\t\t\tserializer?.heading4,\n\t\t\tserializeStandardTag<\"heading4\">(\"h4\", serializer?.heading4),\n\t\t),\n\t\theading5: useSerializerOrDefault<\"heading5\">(\n\t\t\tserializer?.heading5,\n\t\t\tserializeStandardTag<\"heading5\">(\"h5\", serializer?.heading5),\n\t\t),\n\t\theading6: useSerializerOrDefault<\"heading6\">(\n\t\t\tserializer?.heading6,\n\t\t\tserializeStandardTag<\"heading6\">(\"h6\", serializer?.heading6),\n\t\t),\n\t\tparagraph: useSerializerOrDefault<\"paragraph\">(\n\t\t\tserializer?.paragraph,\n\t\t\tserializeStandardTag<\"paragraph\">(\"p\", serializer?.paragraph),\n\t\t),\n\t\tpreformatted: useSerializerOrDefault<\"preformatted\">(\n\t\t\tserializer?.preformatted,\n\t\t\tserializePreFormatted(serializer?.preformatted),\n\t\t),\n\t\tstrong: useSerializerOrDefault<\"strong\">(\n\t\t\tserializer?.strong,\n\t\t\tserializeStandardTag<\"strong\">(\"strong\", serializer?.strong),\n\t\t),\n\t\tem: useSerializerOrDefault<\"em\">(\n\t\t\tserializer?.em,\n\t\t\tserializeStandardTag<\"em\">(\"em\", serializer?.em),\n\t\t),\n\t\tlistItem: useSerializerOrDefault<\"listItem\">(\n\t\t\tserializer?.listItem,\n\t\t\tserializeStandardTag<\"listItem\">(\"li\", serializer?.listItem),\n\t\t),\n\t\toListItem: useSerializerOrDefault<\"oListItem\">(\n\t\t\tserializer?.oListItem,\n\t\t\tserializeStandardTag<\"oListItem\">(\"li\", serializer?.oListItem),\n\t\t),\n\t\tlist: useSerializerOrDefault<\"list\">(\n\t\t\tserializer?.list,\n\t\t\tserializeStandardTag<\"list\">(\"ul\", serializer?.list),\n\t\t),\n\t\toList: useSerializerOrDefault<\"oList\">(\n\t\t\tserializer?.oList,\n\t\t\tserializeStandardTag<\"oList\">(\"ol\", serializer?.oList),\n\t\t),\n\t\timage: useSerializerOrDefault<\"image\">(\n\t\t\tserializer?.image,\n\t\t\tserializeImage(linkResolver, serializer?.image),\n\t\t),\n\t\tembed: useSerializerOrDefault<\"embed\">(serializer?.embed, serializeEmbed(serializer?.embed)),\n\t\thyperlink: useSerializerOrDefault<\"hyperlink\">(\n\t\t\tserializer?.hyperlink,\n\t\t\tserializeHyperlink(linkResolver, serializer?.hyperlink),\n\t\t),\n\t\tlabel: useSerializerOrDefault<\"label\">(\n\t\t\tserializer?.label,\n\t\t\tserializeStandardTag<\"label\">(\"span\", serializer?.label),\n\t\t),\n\t\tspan: useSerializerOrDefault<\"span\">(serializer?.span, serializeSpan()),\n\t}\n\n\treturn wrapMapSerializerWithStringChildren(mapSerializer)\n}\n\n/**\n * Wraps a map serializer into a regular function serializer. The given map serializer should accept\n * children as a string, not as an array of strings like `@prismicio/client/richtext`'s\n * `wrapMapSerializer`.\n *\n * @param mapSerializer - Map serializer to wrap\n * @returns A regular function serializer\n */\nconst wrapMapSerializerWithStringChildren = (\n\tmapSerializer: HTMLStrictRichTextMapSerializer,\n): RichTextFunctionSerializer<string> => {\n\tconst modifiedMapSerializer = {} as RichTextMapSerializer<string>\n\n\tfor (const tag in mapSerializer) {\n\t\tconst tagSerializer = mapSerializer[tag as keyof typeof mapSerializer]\n\n\t\tif (tagSerializer) {\n\t\t\tmodifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {\n\t\t\t\treturn tagSerializer({\n\t\t\t\t\t...payload,\n\t\t\t\t\t// @ts-expect-error - merging blockSerializer types causes TS to bail to a never type\n\t\t\t\t\tchildren: payload.children.join(\"\"),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn wrapMapSerializer(modifiedMapSerializer)\n}\n\n/** Configuration that determines the output of `asHTML()`. */\ntype AsHTMLConfig = {\n\t/**\n\t * An optional link resolver function to resolve links. Without it, you're expected to use the\n\t * `routes` option from the API.\n\t */\n\tlinkResolver?: LinkResolverFunction | null\n\n\t/** An optional rich text serializer. Unhandled cases will fall back to the default serializer. */\n\tserializer?: HTMLRichTextSerializer | null\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsHTMLDeprecatedTupleConfig = [\n\tlinkResolver?: LinkResolverFunction | null,\n\tserializer?: HTMLRichTextSerializer | null,\n]\n\n/** The return type of `asHTML()`. */\ntype AsHTMLReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField\n\t? string\n\t: null\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asHTML: {\n\t/**\n\t * Converts a rich text field to an HTML string.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst html = asHTML(document.data.content)\n\t * \t// => \"<p>Hello world</p>\"\n\t * \t```\n\t *\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param config - Configuration that determines the output of `asHTML()`.\n\t * @returns HTML equivalent of the rich text field, or `null` if the field is\n\t * empty.\n\t * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsHTMLConfig,\n\t): AsHTMLReturnType<Field>\n\n\t/**\n\t * Converts a rich text field to an HTML string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param linkResolver - An optional link resolver function to resolve links. Without it, you're\n\t * expected to use the `routes` option from the API.\n\t * @param serializer - An optional rich text serializer. Unhandled cases will fall back to the\n\t * default serializer.\n\t * @returns HTML equivalent of the rich text field, or `null` if the field is\n\t * empty.\n\t * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsHTMLDeprecatedTupleConfig\n\t): AsHTMLReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsHTMLConfig] | AsHTMLDeprecatedTupleConfig\n): AsHTMLReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple\n\t\tlet config: AsHTMLConfig\n\t\tif (typeof configObjectOrLinkResolver === \"function\" || configObjectOrLinkResolver == null) {\n\t\t\tconfig = {\n\t\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t\t\tserializer: maybeSerializer,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrLinkResolver }\n\t\t}\n\n\t\tlet serializer: RichTextFunctionSerializer<string>\n\t\tif (config.serializer) {\n\t\t\tif (typeof config.serializer === \"function\") {\n\t\t\t\tserializer = composeSerializers(\n\t\t\t\t\t(type, node, text, children, key) =>\n\t\t\t\t\t\t// TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.\n\t\t\t\t\t\t(config.serializer as HTMLRichTextFunctionSerializer)(\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\tchildren.join(\"\"),\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t),\n\t\t\t\t\tcreateHTMLRichTextSerializer(config.linkResolver),\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tserializer = createHTMLRichTextSerializer(config.linkResolver, config.serializer)\n\t\t\t}\n\t\t} else {\n\t\t\tserializer = createHTMLRichTextSerializer(config.linkResolver)\n\t\t}\n\n\t\treturn serialize(richTextField, serializer).join(\"\") as AsHTMLReturnType<Field>\n\t} else {\n\t\treturn null as AsHTMLReturnType<Field>\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAwIA,MAAM,gCACL,cACA,eACwC;CACxC,MAAM,0BACL,2BACA,yBAC6D;EAC7D,IAAI,OAAO,8BAA8B,YACxC,SAAS,YAAY;GACpB,OACE,4BAA2E,OAAO,KACnF,qBAAqB,OAAO;EAE9B;EAGD,OAAO;CACR;CAEA,MAAM,gBAA2D;EAChE,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,WAAW,uBACV,YAAY,WACZ,qBAAkC,KAAK,YAAY,SAAS,CAC7D;EACA,cAAc,uBACb,YAAY,cACZ,sBAAsB,YAAY,YAAY,CAC/C;EACA,QAAQ,uBACP,YAAY,QACZ,qBAA+B,UAAU,YAAY,MAAM,CAC5D;EACA,IAAI,uBACH,YAAY,IACZ,qBAA2B,MAAM,YAAY,EAAE,CAChD;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,WAAW,uBACV,YAAY,WACZ,qBAAkC,MAAM,YAAY,SAAS,CAC9D;EACA,MAAM,uBACL,YAAY,MACZ,qBAA6B,MAAM,YAAY,IAAI,CACpD;EACA,OAAO,uBACN,YAAY,OACZ,qBAA8B,MAAM,YAAY,KAAK,CACtD;EACA,OAAO,uBACN,YAAY,OACZ,eAAe,cAAc,YAAY,KAAK,CAC/C;EACA,OAAO,uBAAgC,YAAY,OAAO,eAAe,YAAY,KAAK,CAAC;EAC3F,WAAW,uBACV,YAAY,WACZ,mBAAmB,cAAc,YAAY,SAAS,CACvD;EACA,OAAO,uBACN,YAAY,OACZ,qBAA8B,QAAQ,YAAY,KAAK,CACxD;EACA,MAAM,uBAA+B,YAAY,MAAM,cAAc,CAAC;CACvE;CAEA,OAAO,oCAAoC,aAAa;AACzD;;;;;;;;;AAUA,MAAM,uCACL,kBACwC;CACxC,MAAM,wBAAwB,CAAC;CAE/B,KAAK,MAAM,OAAO,eAAe;EAChC,MAAM,gBAAgB,cAAc;EAEpC,IAAI,eACH,sBAAsB,QAAsC,YAAY;GACvE,OAAO,cAAc;IACpB,GAAG;IAEH,UAAU,QAAQ,SAAS,KAAK,EAAE;GACnC,CAAC;EACF;CAEF;CAEA,OAAO,kBAAkB,qBAAqB;AAC/C;AA2BA,MAAa,UAuCZ,eAEA,GAAG,wBAC0B;CAC7B,IAAI,eAAe;EAElB,MAAM,CAAC,4BAA4B,mBAAmB;EACtD,IAAI;EACJ,IAAI,OAAO,+BAA+B,cAAc,8BAA8B,MACrF,SAAS;GACR,cAAc;GACd,YAAY;EACb;OAEA,SAAS,EAAE,GAAG,2BAA2B;EAG1C,IAAI;EACJ,IAAI,OAAO,YAAY;GACtB,IAAI,OAAO,OAAO,eAAe,YAChC,aAAa,oBACX,MAAM,MAAM,MAAM,UAAU,QAE3B,OAAO,WACP,MACA,MACA,MACA,SAAS,KAAK,EAAE,GAChB,GACD,GACD,6BAA6B,OAAO,YAAY,CACjD;QAEA,aAAa,6BAA6B,OAAO,cAAc,OAAO,UAAU;EAElF,OACC,aAAa,6BAA6B,OAAO,YAAY;EAG9D,OAAO,UAAU,eAAe,UAAU,CAAC,CAAC,KAAK,EAAE;CACpD,OACC,OAAO;AAET"}
1
+ {"version":3,"file":"asHTML.js","names":[],"sources":["../../src/helpers/asHTML.ts"],"sourcesContent":["import {\n\tserializeEmbed,\n\tserializeHyperlink,\n\tserializeImage,\n\tserializePreFormatted,\n\tserializeSpan,\n\tserializeStandardTag,\n} from \"../lib/serializerHelpers\"\nimport type {\n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n\tRichTextMapSerializerFunction,\n} from \"../richtext\"\nimport { composeSerializers, serialize, wrapMapSerializer } from \"../richtext\"\nimport type { RichTextField } from \"../types/value/richText\"\nimport type { LinkResolverFunction } from \"./asLink\"\n\n/**\n * Serializes a node from a rich text field with a function to HTML.\n *\n * Unlike a typical `@prismicio/client/richtext` function serializer, this serializer converts the\n * `children` argument to a single string rather than an array of strings.\n *\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLRichTextFunctionSerializer = (\n\ttype: Parameters<RichTextFunctionSerializer<string>>[0],\n\tnode: Parameters<RichTextFunctionSerializer<string>>[1],\n\ttext: Parameters<RichTextFunctionSerializer<string>>[2],\n\tchildren: Parameters<RichTextFunctionSerializer<string>>[3][number],\n\tkey: Parameters<RichTextFunctionSerializer<string>>[4],\n) => string | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map to HTML.\n *\n * Unlike a typical `@prismicio/client/richtext` map serializer, this serializer converts the\n * `children` property to a single string rather than an array of strings and accepts shorthand\n * declarations.\n *\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: P extends RichTextMapSerializer<string>[\"span\"]\n\t\t? HTMLStrictRichTextMapSerializer[P]\n\t\t: HTMLStrictRichTextMapSerializer[P] | HTMLRichTextMapSerializerShorthand\n}\n\n/**\n * Serializes a node from a rich text field with a map to HTML.\n *\n * Unlike a typical `@prismicio/client/richtext` map serializer, this serializer converts the\n * `children` property to a single string rather than an array of strings but doesn't accept\n * shorthand declarations.\n *\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLStrictRichTextMapSerializer = {\n\t[P in keyof RichTextMapSerializer<string>]: (payload: {\n\t\ttype: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"type\"]\n\t\tnode: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"node\"]\n\t\ttext: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"text\"]\n\t\tchildren: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"children\"][number]\n\t\tkey: Parameters<HTMLRichTextMapSerializerFunction<P>>[0][\"key\"]\n\t}) => string | null | undefined\n}\n\n/**\n * A {@link RichTextMapSerializerFunction} type specifically for {@link HTMLRichTextMapSerializer}.\n *\n * @typeParam BlockName - The serializer's rich text block type.\n */\ntype HTMLRichTextMapSerializerFunction<BlockType extends keyof RichTextMapSerializer<string>> =\n\tRichTextMapSerializerFunction<\n\t\tstring,\n\t\tExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,\n\t\tExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>\n\t>\n\n/**\n * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed `Node` generic.\n */\ntype ExtractNodeGeneric<T> =\n\tT extends RichTextMapSerializerFunction<\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany,\n\t\tinfer U,\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany\n\t>\n\t\t? U\n\t\t: never\n\n/**\n * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.\n *\n * @typeParam T - The `RichTextMapSerializerFunction` containing the needed `TextType` generic.\n */\ntype ExtractTextTypeGeneric<T> =\n\tT extends RichTextMapSerializerFunction<\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany,\n\t\t// oxlint-disable-next-line no-explicit-any\n\t\tany,\n\t\tinfer U\n\t>\n\t\t? U\n\t\t: never\n\n/** A shorthand definition for {@link HTMLRichTextMapSerializer} element types. */\nexport type HTMLRichTextMapSerializerShorthand = {\n\t/** Classes to apply to the element type. */\n\tclass?: string\n\n\t/** Other attributes to apply to the element type. */\n\t[Attribute: string]: string | boolean | null | undefined\n}\n\n/**\n * Serializes a node from a rich text field with a map or a function to HTML.\n *\n * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}\n * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type HTMLRichTextSerializer = HTMLRichTextMapSerializer | HTMLRichTextFunctionSerializer\n\n/**\n * Creates a HTML rich text serializer with a given link resolver and provide sensible and safe\n * defaults for every node type\n *\n * @internal\n */\nconst createHTMLRichTextSerializer = (\n\tlinkResolver: LinkResolverFunction | undefined | null,\n\tserializer?: HTMLRichTextMapSerializer | null,\n): RichTextFunctionSerializer<string> => {\n\tconst useSerializerOrDefault = <BlockType extends keyof RichTextMapSerializer<string>>(\n\t\tnodeSerializerOrShorthand: HTMLRichTextMapSerializer[BlockType],\n\t\tdefaultWithShorthand: NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>,\n\t): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\t\tif (typeof nodeSerializerOrShorthand === \"function\") {\n\t\t\treturn ((payload) => {\n\t\t\t\treturn (\n\t\t\t\t\t(nodeSerializerOrShorthand as HTMLStrictRichTextMapSerializer[BlockType])?.(payload) ||\n\t\t\t\t\tdefaultWithShorthand(payload)\n\t\t\t\t)\n\t\t\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n\t\t}\n\n\t\treturn defaultWithShorthand\n\t}\n\n\tconst mapSerializer: Required<HTMLStrictRichTextMapSerializer> = {\n\t\theading1: useSerializerOrDefault<\"heading1\">(\n\t\t\tserializer?.heading1,\n\t\t\tserializeStandardTag<\"heading1\">(\"h1\", serializer?.heading1),\n\t\t),\n\t\theading2: useSerializerOrDefault<\"heading2\">(\n\t\t\tserializer?.heading2,\n\t\t\tserializeStandardTag<\"heading2\">(\"h2\", serializer?.heading2),\n\t\t),\n\t\theading3: useSerializerOrDefault<\"heading3\">(\n\t\t\tserializer?.heading3,\n\t\t\tserializeStandardTag<\"heading3\">(\"h3\", serializer?.heading3),\n\t\t),\n\t\theading4: useSerializerOrDefault<\"heading4\">(\n\t\t\tserializer?.heading4,\n\t\t\tserializeStandardTag<\"heading4\">(\"h4\", serializer?.heading4),\n\t\t),\n\t\theading5: useSerializerOrDefault<\"heading5\">(\n\t\t\tserializer?.heading5,\n\t\t\tserializeStandardTag<\"heading5\">(\"h5\", serializer?.heading5),\n\t\t),\n\t\theading6: useSerializerOrDefault<\"heading6\">(\n\t\t\tserializer?.heading6,\n\t\t\tserializeStandardTag<\"heading6\">(\"h6\", serializer?.heading6),\n\t\t),\n\t\tparagraph: useSerializerOrDefault<\"paragraph\">(\n\t\t\tserializer?.paragraph,\n\t\t\tserializeStandardTag<\"paragraph\">(\"p\", serializer?.paragraph),\n\t\t),\n\t\tpreformatted: useSerializerOrDefault<\"preformatted\">(\n\t\t\tserializer?.preformatted,\n\t\t\tserializePreFormatted(serializer?.preformatted),\n\t\t),\n\t\tstrong: useSerializerOrDefault<\"strong\">(\n\t\t\tserializer?.strong,\n\t\t\tserializeStandardTag<\"strong\">(\"strong\", serializer?.strong),\n\t\t),\n\t\tem: useSerializerOrDefault<\"em\">(\n\t\t\tserializer?.em,\n\t\t\tserializeStandardTag<\"em\">(\"em\", serializer?.em),\n\t\t),\n\t\tlistItem: useSerializerOrDefault<\"listItem\">(\n\t\t\tserializer?.listItem,\n\t\t\tserializeStandardTag<\"listItem\">(\"li\", serializer?.listItem),\n\t\t),\n\t\toListItem: useSerializerOrDefault<\"oListItem\">(\n\t\t\tserializer?.oListItem,\n\t\t\tserializeStandardTag<\"oListItem\">(\"li\", serializer?.oListItem),\n\t\t),\n\t\tlist: useSerializerOrDefault<\"list\">(\n\t\t\tserializer?.list,\n\t\t\tserializeStandardTag<\"list\">(\"ul\", serializer?.list),\n\t\t),\n\t\toList: useSerializerOrDefault<\"oList\">(\n\t\t\tserializer?.oList,\n\t\t\tserializeStandardTag<\"oList\">(\"ol\", serializer?.oList),\n\t\t),\n\t\timage: useSerializerOrDefault<\"image\">(\n\t\t\tserializer?.image,\n\t\t\tserializeImage(linkResolver, serializer?.image),\n\t\t),\n\t\tembed: useSerializerOrDefault<\"embed\">(serializer?.embed, serializeEmbed(serializer?.embed)),\n\t\thyperlink: useSerializerOrDefault<\"hyperlink\">(\n\t\t\tserializer?.hyperlink,\n\t\t\tserializeHyperlink(linkResolver, serializer?.hyperlink),\n\t\t),\n\t\tlabel: useSerializerOrDefault<\"label\">(\n\t\t\tserializer?.label,\n\t\t\tserializeStandardTag<\"label\">(\"span\", serializer?.label),\n\t\t),\n\t\tspan: useSerializerOrDefault<\"span\">(serializer?.span, serializeSpan()),\n\t}\n\n\treturn wrapMapSerializerWithStringChildren(mapSerializer)\n}\n\n/**\n * Wraps a map serializer into a regular function serializer. The given map serializer should accept\n * children as a string, not as an array of strings like `@prismicio/client/richtext`'s\n * `wrapMapSerializer`.\n *\n * @param mapSerializer - Map serializer to wrap\n * @returns A regular function serializer\n */\nconst wrapMapSerializerWithStringChildren = (\n\tmapSerializer: HTMLStrictRichTextMapSerializer,\n): RichTextFunctionSerializer<string> => {\n\tconst modifiedMapSerializer = {} as RichTextMapSerializer<string>\n\n\tfor (const tag in mapSerializer) {\n\t\tconst tagSerializer = mapSerializer[tag as keyof typeof mapSerializer]\n\n\t\tif (tagSerializer) {\n\t\t\tmodifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {\n\t\t\t\treturn tagSerializer({\n\t\t\t\t\t...payload,\n\t\t\t\t\t// @ts-expect-error - merging blockSerializer types causes TS to bail to a never type\n\t\t\t\t\tchildren: payload.children.join(\"\"),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn wrapMapSerializer(modifiedMapSerializer)\n}\n\n/** Configuration that determines the output of `asHTML()`. */\ntype AsHTMLConfig = {\n\t/**\n\t * An optional link resolver function to resolve links. Without it, you're expected to use the\n\t * `routes` option from the API.\n\t */\n\tlinkResolver?: LinkResolverFunction | null\n\n\t/** An optional rich text serializer. Unhandled cases will fall back to the default serializer. */\n\tserializer?: HTMLRichTextSerializer | null\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsHTMLDeprecatedTupleConfig = [\n\tlinkResolver?: LinkResolverFunction | null,\n\tserializer?: HTMLRichTextSerializer | null,\n]\n\n/** The return type of `asHTML()`. */\ntype AsHTMLReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField\n\t? string\n\t: null\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asHTML: {\n\t/**\n\t * Converts a rich text field to an HTML string.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst html = asHTML(document.data.content)\n\t * \t// => \"<p>Hello world</p>\"\n\t * \t```\n\t *\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param config - Configuration that determines the output of `asHTML()`.\n\t * @returns HTML equivalent of the rich text field, or `null` if the field is\n\t * empty.\n\t * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsHTMLConfig,\n\t): AsHTMLReturnType<Field>\n\n\t/**\n\t * Converts a rich text field to an HTML string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param linkResolver - An optional link resolver function to resolve links. Without it, you're\n\t * expected to use the `routes` option from the API.\n\t * @param serializer - An optional rich text serializer. Unhandled cases will fall back to the\n\t * default serializer.\n\t * @returns HTML equivalent of the rich text field, or `null` if the field is\n\t * empty.\n\t * @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsHTMLDeprecatedTupleConfig\n\t): AsHTMLReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsHTMLConfig] | AsHTMLDeprecatedTupleConfig\n): AsHTMLReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple\n\t\tlet config: AsHTMLConfig\n\t\tif (typeof configObjectOrLinkResolver === \"function\" || configObjectOrLinkResolver == null) {\n\t\t\tconfig = {\n\t\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t\t\tserializer: maybeSerializer,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrLinkResolver }\n\t\t}\n\n\t\tlet serializer: RichTextFunctionSerializer<string>\n\t\tif (config.serializer) {\n\t\t\tif (typeof config.serializer === \"function\") {\n\t\t\t\tserializer = composeSerializers(\n\t\t\t\t\t(type, node, text, children, key) =>\n\t\t\t\t\t\t// TypeScript doesn't narrow the type correctly here since it is now in a callback function, so we have to cast it here.\n\t\t\t\t\t\t(config.serializer as HTMLRichTextFunctionSerializer)(\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\tchildren.join(\"\"),\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t),\n\t\t\t\t\tcreateHTMLRichTextSerializer(config.linkResolver),\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tserializer = createHTMLRichTextSerializer(config.linkResolver, config.serializer)\n\t\t\t}\n\t\t} else {\n\t\t\tserializer = createHTMLRichTextSerializer(config.linkResolver)\n\t\t}\n\n\t\treturn serialize(richTextField, serializer).join(\"\") as AsHTMLReturnType<Field>\n\t} else {\n\t\treturn null as AsHTMLReturnType<Field>\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAsIA,MAAM,gCACL,cACA,eACwC;CACxC,MAAM,0BACL,2BACA,yBAC6D;EAC7D,IAAI,OAAO,8BAA8B,YACxC,SAAS,YAAY;GACpB,OACE,4BAA2E,OAAO,KACnF,qBAAqB,OAAO;EAE9B;EAGD,OAAO;CACR;CAEA,MAAM,gBAA2D;EAChE,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,WAAW,uBACV,YAAY,WACZ,qBAAkC,KAAK,YAAY,SAAS,CAC7D;EACA,cAAc,uBACb,YAAY,cACZ,sBAAsB,YAAY,YAAY,CAC/C;EACA,QAAQ,uBACP,YAAY,QACZ,qBAA+B,UAAU,YAAY,MAAM,CAC5D;EACA,IAAI,uBACH,YAAY,IACZ,qBAA2B,MAAM,YAAY,EAAE,CAChD;EACA,UAAU,uBACT,YAAY,UACZ,qBAAiC,MAAM,YAAY,QAAQ,CAC5D;EACA,WAAW,uBACV,YAAY,WACZ,qBAAkC,MAAM,YAAY,SAAS,CAC9D;EACA,MAAM,uBACL,YAAY,MACZ,qBAA6B,MAAM,YAAY,IAAI,CACpD;EACA,OAAO,uBACN,YAAY,OACZ,qBAA8B,MAAM,YAAY,KAAK,CACtD;EACA,OAAO,uBACN,YAAY,OACZ,eAAe,cAAc,YAAY,KAAK,CAC/C;EACA,OAAO,uBAAgC,YAAY,OAAO,eAAe,YAAY,KAAK,CAAC;EAC3F,WAAW,uBACV,YAAY,WACZ,mBAAmB,cAAc,YAAY,SAAS,CACvD;EACA,OAAO,uBACN,YAAY,OACZ,qBAA8B,QAAQ,YAAY,KAAK,CACxD;EACA,MAAM,uBAA+B,YAAY,MAAM,cAAc,CAAC;CACvE;CAEA,OAAO,oCAAoC,aAAa;AACzD;;;;;;;;;AAUA,MAAM,uCACL,kBACwC;CACxC,MAAM,wBAAwB,CAAC;CAE/B,KAAK,MAAM,OAAO,eAAe;EAChC,MAAM,gBAAgB,cAAc;EAEpC,IAAI,eACH,sBAAsB,QAAsC,YAAY;GACvE,OAAO,cAAc;IACpB,GAAG;IAEH,UAAU,QAAQ,SAAS,KAAK,EAAE;GACnC,CAAC;EACF;CAEF;CAEA,OAAO,kBAAkB,qBAAqB;AAC/C;AA2BA,MAAa,UAuCZ,eAEA,GAAG,wBAC0B;CAC7B,IAAI,eAAe;EAElB,MAAM,CAAC,4BAA4B,mBAAmB;EACtD,IAAI;EACJ,IAAI,OAAO,+BAA+B,cAAc,8BAA8B,MACrF,SAAS;GACR,cAAc;GACd,YAAY;EACb;OAEA,SAAS,EAAE,GAAG,2BAA2B;EAG1C,IAAI;EACJ,IAAI,OAAO,YAAY;GACtB,IAAI,OAAO,OAAO,eAAe,YAChC,aAAa,oBACX,MAAM,MAAM,MAAM,UAAU,QAE3B,OAAO,WACP,MACA,MACA,MACA,SAAS,KAAK,EAAE,GAChB,GACD,GACD,6BAA6B,OAAO,YAAY,CACjD;QAEA,aAAa,6BAA6B,OAAO,cAAc,OAAO,UAAU;EAElF,OACC,aAAa,6BAA6B,OAAO,YAAY;EAG9D,OAAO,UAAU,eAAe,UAAU,CAAC,CAAC,KAAK,EAAE;CACpD,OACC,OAAO;AAET"}
@@ -1 +1 @@
1
- {"version":3,"file":"asLink.cjs","names":["documentToLinkField","LinkType"],"sources":["../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic page to a URL.\n *\n * @typeParam ReturnType - Return type of your link resolver function. Useful if you prefer to\n * return a complex object.\n * @param linkToDocumentField - A page link field to resolve.\n * @returns Resolved URL.\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/** Configuration that determines the output of `asLink()`. */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> = {\n\t/**\n\t * An optional link resolver function. Without it, you're expected to use the `routes` option from\n\t * the API.\n\t */\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType = string | null | undefined> = [\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null,\n]\n\n/** The return type of `asLink()`. */\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst url = asLink(document.data.link)\n\t * \t// => \"/blog/my-post\"\n\t * \t```\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return\n\t * type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param config - Configuration that determines the output of `asLink()`.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return\n\t * type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param linkResolver - An optional link resolver function. Without it, you're expected to use\n\t * the `routes` option from the API.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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\"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 (typeof configObjectOrLinkResolver === \"function\" || configObjectOrLinkResolver == null) {\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<LinkResolverFunctionReturnType, Field>\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<LinkResolverFunctionReturnType, Field>\n\t\t\t}\n\n\t\t\t// When empty or route resolver and link 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"],"mappings":";;;AAoDA,MAAa,UA8DZ,qBAEA,GAAG,wBAG0D;CAC7D,IAAI,CAAC,qBACJ,OAAO;CAIR,MAAM,YAGJ,eAAe,sBACZ,sBACAA,4BAAAA,oBAAoB,mBAAmB;CAI5C,MAAM,CAAC,8BAA8B;CACrC,IAAI;CACJ,IAAI,OAAO,+BAA+B,cAAc,8BAA8B,MACrF,SAAS,EACR,cAAc,2BACf;MAEA,SAAS,EAAE,GAAG,2BAA2B;CAG1C,QAAQ,UAAU,WAAlB;EACC,KAAKC,aAAAA,SAAS;EACd,KAAKA,aAAAA,SAAS,KACb,OAAQ,SAAS,YAAY,UAAU,MAAM;EAK9C,KAAKA,aAAAA,SAAS;GACb,IAAI,QAAQ,aAAa,OAAO,cAAc;IAE7C,MAAM,cAAc,OAAO,aAAa,SAAS;IAEjD,IAAI,eAAe,MAClB,OAAO;GAET;GAEA,IAAI,SAAS,aAAa,UAAU,KAEnC,OAAO,UAAU;GAIlB,OAAO;EAGR,KAAKA,aAAAA,SAAS;EACd,SACC,OAAO;CACT;AACD"}
1
+ {"version":3,"file":"asLink.cjs","names":["documentToLinkField","LinkType"],"sources":["../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic page to a URL.\n *\n * @typeParam ReturnType - Return type of your link resolver function. Useful if you prefer to\n * return a complex object.\n * @param linkToDocumentField - A page link field to resolve.\n * @returns Resolved URL.\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/** Configuration that determines the output of `asLink()`. */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> = {\n\t/**\n\t * An optional link resolver function. Without it, you're expected to use the `routes` option from\n\t * the API.\n\t */\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType = string | null | undefined> = [\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null,\n]\n\n/** The return type of `asLink()`. */\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst url = asLink(document.data.link)\n\t * \t// => \"/blog/my-post\"\n\t * \t```\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param config - Configuration that determines the output of `asLink()`.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param linkResolver - An optional link resolver function. Without it, you're expected to use\n\t * the `routes` option from the API.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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\"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 (typeof configObjectOrLinkResolver === \"function\" || configObjectOrLinkResolver == null) {\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<LinkResolverFunctionReturnType, Field>\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<LinkResolverFunctionReturnType, Field>\n\t\t\t}\n\n\t\t\t// When empty or route resolver and link 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"],"mappings":";;;AAoDA,MAAa,UA4DZ,qBAEA,GAAG,wBAG0D;CAC7D,IAAI,CAAC,qBACJ,OAAO;CAIR,MAAM,YAGJ,eAAe,sBACZ,sBACAA,4BAAAA,oBAAoB,mBAAmB;CAI5C,MAAM,CAAC,8BAA8B;CACrC,IAAI;CACJ,IAAI,OAAO,+BAA+B,cAAc,8BAA8B,MACrF,SAAS,EACR,cAAc,2BACf;MAEA,SAAS,EAAE,GAAG,2BAA2B;CAG1C,QAAQ,UAAU,WAAlB;EACC,KAAKC,aAAAA,SAAS;EACd,KAAKA,aAAAA,SAAS,KACb,OAAQ,SAAS,YAAY,UAAU,MAAM;EAK9C,KAAKA,aAAAA,SAAS;GACb,IAAI,QAAQ,aAAa,OAAO,cAAc;IAE7C,MAAM,cAAc,OAAO,aAAa,SAAS;IAEjD,IAAI,eAAe,MAClB,OAAO;GAET;GAEA,IAAI,SAAS,aAAa,UAAU,KAEnC,OAAO,UAAU;GAIlB,OAAO;EAGR,KAAKA,aAAAA,SAAS;EACd,SACC,OAAO;CACT;AACD"}
@@ -34,8 +34,7 @@ export declare const asLink: {
34
34
  * // => "/blog/my-post"
35
35
  * ```
36
36
  *
37
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
38
- * type.
37
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.
39
38
  * @typeParam Field - Link field or Prismic page to resolve to a URL.
40
39
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve.
41
40
  * @param config - Configuration that determines the output of `asLink()`.
@@ -47,8 +46,7 @@ export declare const asLink: {
47
46
  * Converts any type of link field or Prismic page to a URL.
48
47
  *
49
48
  * @deprecated Use object-style configuration instead.
50
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
51
- * type.
49
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.
52
50
  * @typeParam Field - Link field or Prismic page to resolve to a URL.
53
51
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve.
54
52
  * @param linkResolver - An optional link resolver function. Without it, you're expected to use
@@ -1 +1 @@
1
- {"version":3,"file":"asLink.d.cts","names":[],"sources":["../../src/helpers/asLink.ts"],"mappings":";;;;;;;;;;;;;YAgBY,qBAAqB,2CAChC,qBAAqB,mCACjB;;KAGA,aAAa;;;;;EAKjB,eAAe,qBAAqB;;;KAKhC,4BAA4B,+DAChC,eAAe,qBAAqB;;YAIzB,iBACX,4DACA,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA,kBACA;qBAIU;;;;;;;;;;;;;;;;;;GAmBX,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,OACrB,SAAS,aAAa,kCACpB,iBAAiB,gCAAgC;;;;;;;;;;;;;;GAgBnD,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,UAClB,QAAQ,4BAA4B,kCACrC,iBAAiB,gCAAgC"}
1
+ {"version":3,"file":"asLink.d.cts","names":[],"sources":["../../src/helpers/asLink.ts"],"mappings":";;;;;;;;;;;;;YAgBY,qBAAqB,2CAChC,qBAAqB,mCACjB;;KAGA,aAAa;;;;;EAKjB,eAAe,qBAAqB;;;KAKhC,4BAA4B,+DAChC,eAAe,qBAAqB;;YAIzB,iBACX,4DACA,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA,kBACA;qBAIU;;;;;;;;;;;;;;;;;GAkBX,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,OACrB,SAAS,aAAa,kCACpB,iBAAiB,gCAAgC;;;;;;;;;;;;;GAenD,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,UAClB,QAAQ,4BAA4B,kCACrC,iBAAiB,gCAAgC"}
@@ -34,8 +34,7 @@ export declare const asLink: {
34
34
  * // => "/blog/my-post"
35
35
  * ```
36
36
  *
37
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
38
- * type.
37
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.
39
38
  * @typeParam Field - Link field or Prismic page to resolve to a URL.
40
39
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve.
41
40
  * @param config - Configuration that determines the output of `asLink()`.
@@ -47,8 +46,7 @@ export declare const asLink: {
47
46
  * Converts any type of link field or Prismic page to a URL.
48
47
  *
49
48
  * @deprecated Use object-style configuration instead.
50
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
51
- * type.
49
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.
52
50
  * @typeParam Field - Link field or Prismic page to resolve to a URL.
53
51
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve.
54
52
  * @param linkResolver - An optional link resolver function. Without it, you're expected to use
@@ -1 +1 @@
1
- {"version":3,"file":"asLink.d.ts","names":[],"sources":["../../src/helpers/asLink.ts"],"mappings":";;;;;;;;;;;;;YAgBY,qBAAqB,2CAChC,qBAAqB,mCACjB;;KAGA,aAAa;;;;;EAKjB,eAAe,qBAAqB;;;KAKhC,4BAA4B,+DAChC,eAAe,qBAAqB;;YAIzB,iBACX,4DACA,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA,kBACA;qBAIU;;;;;;;;;;;;;;;;;;GAmBX,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,OACrB,SAAS,aAAa,kCACpB,iBAAiB,gCAAgC;;;;;;;;;;;;;;GAgBnD,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,UAClB,QAAQ,4BAA4B,kCACrC,iBAAiB,gCAAgC"}
1
+ {"version":3,"file":"asLink.d.ts","names":[],"sources":["../../src/helpers/asLink.ts"],"mappings":";;;;;;;;;;;;;YAgBY,qBAAqB,2CAChC,qBAAqB,mCACjB;;KAGA,aAAa;;;;;EAKjB,eAAe,qBAAqB;;;KAKhC,4BAA4B,+DAChC,eAAe,qBAAqB;;YAIzB,iBACX,4DACA,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA,kBACA;qBAIU;;;;;;;;;;;;;;;;;GAkBX,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,OACrB,SAAS,aAAa,kCACpB,iBAAiB,gCAAgC;;;;;;;;;;;;;GAenD,4DACA,cAAc,YAAY,qCACvB,YACA,oCAIH,qBAAqB,UAClB,QAAQ,4BAA4B,kCACrC,iBAAiB,gCAAgC"}
@@ -1 +1 @@
1
- {"version":3,"file":"asLink.js","names":[],"sources":["../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic page to a URL.\n *\n * @typeParam ReturnType - Return type of your link resolver function. Useful if you prefer to\n * return a complex object.\n * @param linkToDocumentField - A page link field to resolve.\n * @returns Resolved URL.\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/** Configuration that determines the output of `asLink()`. */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> = {\n\t/**\n\t * An optional link resolver function. Without it, you're expected to use the `routes` option from\n\t * the API.\n\t */\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType = string | null | undefined> = [\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null,\n]\n\n/** The return type of `asLink()`. */\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst url = asLink(document.data.link)\n\t * \t// => \"/blog/my-post\"\n\t * \t```\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return\n\t * type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param config - Configuration that determines the output of `asLink()`.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return\n\t * type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param linkResolver - An optional link resolver function. Without it, you're expected to use\n\t * the `routes` option from the API.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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\"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 (typeof configObjectOrLinkResolver === \"function\" || configObjectOrLinkResolver == null) {\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<LinkResolverFunctionReturnType, Field>\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<LinkResolverFunctionReturnType, Field>\n\t\t\t}\n\n\t\t\t// When empty or route resolver and link 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"],"mappings":";;;AAoDA,MAAa,UA8DZ,qBAEA,GAAG,wBAG0D;CAC7D,IAAI,CAAC,qBACJ,OAAO;CAIR,MAAM,YAGJ,eAAe,sBACZ,sBACA,oBAAoB,mBAAmB;CAI5C,MAAM,CAAC,8BAA8B;CACrC,IAAI;CACJ,IAAI,OAAO,+BAA+B,cAAc,8BAA8B,MACrF,SAAS,EACR,cAAc,2BACf;MAEA,SAAS,EAAE,GAAG,2BAA2B;CAG1C,QAAQ,UAAU,WAAlB;EACC,KAAK,SAAS;EACd,KAAK,SAAS,KACb,OAAQ,SAAS,YAAY,UAAU,MAAM;EAK9C,KAAK,SAAS;GACb,IAAI,QAAQ,aAAa,OAAO,cAAc;IAE7C,MAAM,cAAc,OAAO,aAAa,SAAS;IAEjD,IAAI,eAAe,MAClB,OAAO;GAET;GAEA,IAAI,SAAS,aAAa,UAAU,KAEnC,OAAO,UAAU;GAIlB,OAAO;EAGR,KAAK,SAAS;EACd,SACC,OAAO;CACT;AACD"}
1
+ {"version":3,"file":"asLink.js","names":[],"sources":["../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic page to a URL.\n *\n * @typeParam ReturnType - Return type of your link resolver function. Useful if you prefer to\n * return a complex object.\n * @param linkToDocumentField - A page link field to resolve.\n * @returns Resolved URL.\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/** Configuration that determines the output of `asLink()`. */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> = {\n\t/**\n\t * An optional link resolver function. Without it, you're expected to use the `routes` option from\n\t * the API.\n\t */\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType = string | null | undefined> = [\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null,\n]\n\n/** The return type of `asLink()`. */\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst url = asLink(document.data.link)\n\t * \t// => \"/blog/my-post\"\n\t * \t```\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param config - Configuration that determines the output of `asLink()`.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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 * Converts any type of link field or Prismic page to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.\n\t * @typeParam Field - Link field or Prismic page to resolve to a URL.\n\t * @param linkFieldOrDocument - Any kind of link field or a page to resolve.\n\t * @param linkResolver - An optional link resolver function. Without it, you're expected to use\n\t * the `routes` option from the API.\n\t * @returns Resolved URL, or `null` if the link field or page is empty.\n\t * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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\"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 (typeof configObjectOrLinkResolver === \"function\" || configObjectOrLinkResolver == null) {\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<LinkResolverFunctionReturnType, Field>\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<LinkResolverFunctionReturnType, Field>\n\t\t\t}\n\n\t\t\t// When empty or route resolver and link 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"],"mappings":";;;AAoDA,MAAa,UA4DZ,qBAEA,GAAG,wBAG0D;CAC7D,IAAI,CAAC,qBACJ,OAAO;CAIR,MAAM,YAGJ,eAAe,sBACZ,sBACA,oBAAoB,mBAAmB;CAI5C,MAAM,CAAC,8BAA8B;CACrC,IAAI;CACJ,IAAI,OAAO,+BAA+B,cAAc,8BAA8B,MACrF,SAAS,EACR,cAAc,2BACf;MAEA,SAAS,EAAE,GAAG,2BAA2B;CAG1C,QAAQ,UAAU,WAAlB;EACC,KAAK,SAAS;EACd,KAAK,SAAS,KACb,OAAQ,SAAS,YAAY,UAAU,MAAM;EAK9C,KAAK,SAAS;GACb,IAAI,QAAQ,aAAa,OAAO,cAAc;IAE7C,MAAM,cAAc,OAAO,aAAa,SAAS;IAEjD,IAAI,eAAe,MAClB,OAAO;GAET;GAEA,IAAI,SAAS,aAAa,UAAU,KAEnC,OAAO,UAAU;GAIlB,OAAO;EAGR,KAAK,SAAS;EACd,SACC,OAAO;CACT;AACD"}
@@ -9,8 +9,7 @@ const require_isFilled = require("./isFilled.cjs");
9
9
  * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as
10
10
  * `"noreferrer"`.
11
11
  *
12
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
13
- * type
12
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type
14
13
  * @typeParam Field - Link field or Prismic page to resolve to link attributes
15
14
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve
16
15
  * @param config - Configuration that determines the output of `asLinkAttrs()`
@@ -1 +1 @@
1
- {"version":3,"file":"asLinkAttrs.cjs","names":["isFilledLink","asLink","isInternalURL"],"sources":["../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { 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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | 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/** The return type of `asLinkAttrs()`. */\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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic page to a set of link attributes. The attributes are\n * designed to be passed to link HTML elements, like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as\n * `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - Link resolver function return\n * type\n * @typeParam Field - Link field or Prismic page to resolve to link attributes\n * @param linkFieldOrDocument - Any kind of link field or a page to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n * @returns Resolved set of link attributes or, if the provided link field or page is empty, and\n * empty object\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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(\"link_type\" in linkFieldOrDocument ? isFilledLink(linkFieldOrDocument) : linkFieldOrDocument)\n\t) {\n\t\tconst target = \"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href = rawHref == 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\t? \"noreferrer\"\n\t\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4EA,MAAa,eAQZ,qBACA,SAA4D,CAAC,MACF;CAC3D,IACC,wBACC,eAAe,sBAAsBA,iBAAAA,KAAa,mBAAmB,IAAI,sBACzE;EACD,MAAM,SAAS,YAAY,sBAAsB,oBAAoB,SAAS,KAAA;EAE9E,MAAM,UAAUC,eAAAA,OAAO,qBAAqB,OAAO,YAAY;EAC/D,MAAM,OAAO,WAAW,OAAO,KAAA,IAAa;EAE5C,MAAM,aAAa,OAAO,SAAS,WAAW,CAACC,sBAAAA,cAAc,IAAI,IAAI;EAErE,MAAM,MAAM,OAAO,MAChB,OAAO,IAAI;GAAE;GAAM;GAAY;EAAO,CAAC,IACvC,aACC,eACA,KAAA;EAEJ,OAAO;GACN;GACA;GACA,KAAK,OAAO,OAAO,KAAA,IAAY;EAChC;CACD;CAEA,OAAO,CAAC;AACT"}
1
+ {"version":3,"file":"asLinkAttrs.cjs","names":["isFilledLink","asLink","isInternalURL"],"sources":["../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { 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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | 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/** The return type of `asLinkAttrs()`. */\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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic page to a set of link attributes. The attributes are\n * designed to be passed to link HTML elements, like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as\n * `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - Link resolver function return type\n * @typeParam Field - Link field or Prismic page to resolve to link attributes\n * @param linkFieldOrDocument - Any kind of link field or a page to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n * @returns Resolved set of link attributes or, if the provided link field or page is empty, and\n * empty object\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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(\"link_type\" in linkFieldOrDocument ? isFilledLink(linkFieldOrDocument) : linkFieldOrDocument)\n\t) {\n\t\tconst target = \"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href = rawHref == 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\t? \"noreferrer\"\n\t\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"],"mappings":";;;;;;;;;;;;;;;;;;;AA2EA,MAAa,eAQZ,qBACA,SAA4D,CAAC,MACF;CAC3D,IACC,wBACC,eAAe,sBAAsBA,iBAAAA,KAAa,mBAAmB,IAAI,sBACzE;EACD,MAAM,SAAS,YAAY,sBAAsB,oBAAoB,SAAS,KAAA;EAE9E,MAAM,UAAUC,eAAAA,OAAO,qBAAqB,OAAO,YAAY;EAC/D,MAAM,OAAO,WAAW,OAAO,KAAA,IAAa;EAE5C,MAAM,aAAa,OAAO,SAAS,WAAW,CAACC,sBAAAA,cAAc,IAAI,IAAI;EAErE,MAAM,MAAM,OAAO,MAChB,OAAO,IAAI;GAAE;GAAM;GAAY;EAAO,CAAC,IACvC,aACC,eACA,KAAA;EAEJ,OAAO;GACN;GACA;GACA,KAAK,OAAO,OAAO,KAAA,IAAY;EAChC;CACD;CAEA,OAAO,CAAC;AACT"}
@@ -29,8 +29,7 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
29
29
  * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as
30
30
  * `"noreferrer"`.
31
31
  *
32
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
33
- * type
32
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type
34
33
  * @typeParam Field - Link field or Prismic page to resolve to link attributes
35
34
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve
36
35
  * @param config - Configuration that determines the output of `asLinkAttrs()`
@@ -1 +1 @@
1
- {"version":3,"file":"asLinkAttrs.d.cts","names":[],"sources":["../../src/helpers/asLinkAttrs.ts"],"mappings":";;;;;KASK,yBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;YAGW,kBACX,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,eAAe,qBAAqB;EACpC,OACC,MAAM,yBAAyB,gCAAgC;;;KAK5D,sBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA;EAEA,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;EAGA;EACA;EACA;;;;;;;;;;;;;;;;;;qBAmBU,cACZ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,oCAES,qBAES,OAAK,SAClB,kBAAkB,oCACxB,sBAAsB"}
1
+ {"version":3,"file":"asLinkAttrs.d.cts","names":[],"sources":["../../src/helpers/asLinkAttrs.ts"],"mappings":";;;;;KASK,yBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;YAGW,kBACX,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,eAAe,qBAAqB;EACpC,OACC,MAAM,yBAAyB,gCAAgC;;;KAK5D,sBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA;EAEA,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;EAGA;EACA;EACA;;;;;;;;;;;;;;;;;qBAkBU,cACZ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,oCAES,qBAES,OAAK,SAClB,kBAAkB,oCACxB,sBAAsB"}
@@ -29,8 +29,7 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
29
29
  * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as
30
30
  * `"noreferrer"`.
31
31
  *
32
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
33
- * type
32
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type
34
33
  * @typeParam Field - Link field or Prismic page to resolve to link attributes
35
34
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve
36
35
  * @param config - Configuration that determines the output of `asLinkAttrs()`
@@ -1 +1 @@
1
- {"version":3,"file":"asLinkAttrs.d.ts","names":[],"sources":["../../src/helpers/asLinkAttrs.ts"],"mappings":";;;;;KASK,yBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;YAGW,kBACX,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,eAAe,qBAAqB;EACpC,OACC,MAAM,yBAAyB,gCAAgC;;;KAK5D,sBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA;EAEA,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;EAGA;EACA;EACA;;;;;;;;;;;;;;;;;;qBAmBU,cACZ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,oCAES,qBAES,OAAK,SAClB,kBAAkB,oCACxB,sBAAsB"}
1
+ {"version":3,"file":"asLinkAttrs.d.ts","names":[],"sources":["../../src/helpers/asLinkAttrs.ts"],"mappings":";;;;;KASK,yBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;YAGW,kBACX,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA;EAIH,eAAe,qBAAqB;EACpC,OACC,MAAM,yBAAyB,gCAAgC;;;KAK5D,sBACJ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,sCAGA,cACD,uBACA,yBACA,iCACA;EAEA,MAAM,YAAY,iBAAiB,gCAAgC;EACnE;EACA;;EAGA;EACA;EACA;;;;;;;;;;;;;;;;;qBAkBU,cACZ,iCAAiC,WAAW,uBAC5C,cAAc,YAAY,qCACvB,YACA,oCAES,qBAES,OAAK,SAClB,kBAAkB,oCACxB,sBAAsB"}
@@ -9,8 +9,7 @@ import { link } from "./isFilled.js";
9
9
  * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as
10
10
  * `"noreferrer"`.
11
11
  *
12
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
13
- * type
12
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type
14
13
  * @typeParam Field - Link field or Prismic page to resolve to link attributes
15
14
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve
16
15
  * @param config - Configuration that determines the output of `asLinkAttrs()`
@@ -1 +1 @@
1
- {"version":3,"file":"asLinkAttrs.js","names":["isFilledLink"],"sources":["../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { 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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | 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/** The return type of `asLinkAttrs()`. */\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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic page to a set of link attributes. The attributes are\n * designed to be passed to link HTML elements, like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as\n * `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - Link resolver function return\n * type\n * @typeParam Field - Link field or Prismic page to resolve to link attributes\n * @param linkFieldOrDocument - Any kind of link field or a page to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n * @returns Resolved set of link attributes or, if the provided link field or page is empty, and\n * empty object\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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(\"link_type\" in linkFieldOrDocument ? isFilledLink(linkFieldOrDocument) : linkFieldOrDocument)\n\t) {\n\t\tconst target = \"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href = rawHref == 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\t? \"noreferrer\"\n\t\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4EA,MAAa,eAQZ,qBACA,SAA4D,CAAC,MACF;CAC3D,IACC,wBACC,eAAe,sBAAsBA,KAAa,mBAAmB,IAAI,sBACzE;EACD,MAAM,SAAS,YAAY,sBAAsB,oBAAoB,SAAS,KAAA;EAE9E,MAAM,UAAU,OAAO,qBAAqB,OAAO,YAAY;EAC/D,MAAM,OAAO,WAAW,OAAO,KAAA,IAAa;EAE5C,MAAM,aAAa,OAAO,SAAS,WAAW,CAAC,cAAc,IAAI,IAAI;EAErE,MAAM,MAAM,OAAO,MAChB,OAAO,IAAI;GAAE;GAAM;GAAY;EAAO,CAAC,IACvC,aACC,eACA,KAAA;EAEJ,OAAO;GACN;GACA;GACA,KAAK,OAAO,OAAO,KAAA,IAAY;EAChC;CACD;CAEA,OAAO,CAAC;AACT"}
1
+ {"version":3,"file":"asLinkAttrs.js","names":["isFilledLink"],"sources":["../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { 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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | 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/** The return type of `asLinkAttrs()`. */\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: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic page to a set of link attributes. The attributes are\n * designed to be passed to link HTML elements, like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as\n * `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - Link resolver function return type\n * @typeParam Field - Link field or Prismic page to resolve to link attributes\n * @param linkFieldOrDocument - Any kind of link field or a page to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n * @returns Resolved set of link attributes or, if the provided link field or page is empty, and\n * empty object\n * @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}\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(\"link_type\" in linkFieldOrDocument ? isFilledLink(linkFieldOrDocument) : linkFieldOrDocument)\n\t) {\n\t\tconst target = \"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href = rawHref == 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\t? \"noreferrer\"\n\t\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"],"mappings":";;;;;;;;;;;;;;;;;;;AA2EA,MAAa,eAQZ,qBACA,SAA4D,CAAC,MACF;CAC3D,IACC,wBACC,eAAe,sBAAsBA,KAAa,mBAAmB,IAAI,sBACzE;EACD,MAAM,SAAS,YAAY,sBAAsB,oBAAoB,SAAS,KAAA;EAE9E,MAAM,UAAU,OAAO,qBAAqB,OAAO,YAAY;EAC/D,MAAM,OAAO,WAAW,OAAO,KAAA,IAAa;EAE5C,MAAM,aAAa,OAAO,SAAS,WAAW,CAAC,cAAc,IAAI,IAAI;EAErE,MAAM,MAAM,OAAO,MAChB,OAAO,IAAI;GAAE;GAAM;GAAY;EAAO,CAAC,IACvC,aACC,eACA,KAAA;EAEJ,OAAO;GACN;GACA;GACA,KAAK,OAAO,OAAO,KAAA,IAAY;EAChC;CACD;CAEA,OAAO,CAAC;AACT"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.23.1-pr.493.6b3afad";
3
+ var version = "7.23.1-pr.494.95ca2ea";
4
4
  Object.defineProperty(exports, "name", {
5
5
  enumerable: true,
6
6
  get: function() {
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.23.1-pr.493.6b3afad";
3
+ var version = "7.23.1-pr.494.95ca2ea";
4
4
  export { name, version };
5
5
 
6
6
  //# sourceMappingURL=package.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"link.cjs","names":[],"sources":["../../../src/types/value/link.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { FilledLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\nimport type { AnyRegularField, FieldState } from \"./types\"\n\n/** Link types */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam State - State of the field which determines its shape.\n * @typeParam Variant - Variants of the link.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tState extends FieldState = FieldState,\n\tVariant = string,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any, Variant>\n\t: FilledLinkField<TypeEnum, LangEnum, DataInterface, Variant>\n\n/**\n * A link field that is filled.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tVariant = string,\n> =\n\t| (FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> &\n\t\t\tOptionalLinkProperties<Variant>)\n\t| FilledLinkToMediaField<Variant>\n\t| FilledLinkToWebField<Variant>\n\n/**\n * A link field that is not filled.\n *\n * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,\n * **please remove it**.\n * @typeParam Variant - Variants of the link.\n */\nexport type EmptyLinkField<\n\t_Unused extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n\tVariant = string,\n> = {\n\tlink_type: \"Any\"\n} & OptionalLinkProperties<Variant>\n\n/**\n * A link field pointing to a relative or absolute URL.\n *\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkToWebField<Variant = string> = {\n\tlink_type: \"Web\"\n\turl: string\n\ttarget?: string\n} & OptionalLinkProperties<Variant>\n\n/**\n * Optional properties available to link fields. It is used to augment existing link-like fields\n * (like content relationship fields) with field-specific properties.\n *\n * @typeParam Variant - Variants of the link.\n * @internal\n */\n// Remember to update the `getOptionalLinkProperties()` function when updating\n// this type. The function should check for every property.\nexport type OptionalLinkProperties<Variant = string> = {\n\ttext?: string\n\tvariant?: Variant\n}\n"],"mappings":";;AAOA,MAAa,WAAW;CACvB,KAAK;CACL,UAAU;CACV,OAAO;CACP,KAAK;AACN"}
1
+ {"version":3,"file":"link.cjs","names":[],"sources":["../../../src/types/value/link.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { FilledLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\nimport type { AnyRegularField, FieldState } from \"./types\"\n\n/** Link types */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam State - State of the field which determines its shape.\n * @typeParam Variant - Variants of the link.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tState extends FieldState = FieldState,\n\tVariant = string,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any, Variant>\n\t: FilledLinkField<TypeEnum, LangEnum, DataInterface, Variant>\n\n/**\n * A link field that is filled.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tVariant = string,\n> =\n\t| (FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> &\n\t\t\tOptionalLinkProperties<Variant>)\n\t| FilledLinkToMediaField<Variant>\n\t| FilledLinkToWebField<Variant>\n\n/**\n * A link field that is not filled.\n *\n * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type, **please remove it**.\n * @typeParam Variant - Variants of the link.\n */\nexport type EmptyLinkField<\n\t_Unused extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n\tVariant = string,\n> = {\n\tlink_type: \"Any\"\n} & OptionalLinkProperties<Variant>\n\n/**\n * A link field pointing to a relative or absolute URL.\n *\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkToWebField<Variant = string> = {\n\tlink_type: \"Web\"\n\turl: string\n\ttarget?: string\n} & OptionalLinkProperties<Variant>\n\n/**\n * Optional properties available to link fields. It is used to augment existing link-like fields\n * (like content relationship fields) with field-specific properties.\n *\n * @typeParam Variant - Variants of the link.\n * @internal\n */\n// Remember to update the `getOptionalLinkProperties()` function when updating\n// this type. The function should check for every property.\nexport type OptionalLinkProperties<Variant = string> = {\n\ttext?: string\n\tvariant?: Variant\n}\n"],"mappings":";;AAOA,MAAa,WAAW;CACvB,KAAK;CACL,UAAU;CACV,OAAO;CACP,KAAK;AACN"}
@@ -34,8 +34,7 @@ export type FilledLinkField<TypeEnum = string, LangEnum = string, DataInterface
34
34
  /**
35
35
  * A link field that is not filled.
36
36
  *
37
- * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,
38
- * **please remove it**.
37
+ * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type, **please remove it**.
39
38
  * @typeParam Variant - Variants of the link.
40
39
  */
41
40
  export type EmptyLinkField<_Unused extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any, Variant = string> = {
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.cts","names":[],"sources":["../../../src/types/value/link.ts"],"mappings":";;;;;;qBAOa;WACZ;WACA;WACA;WACA;;;;;;;;;;;;YAaW,UACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,cAAc,aAAa,YAC3B,oBACG,wBACD,sBAAsB,SAAS,KAAK,WACpC,gBAAgB,UAAU,UAAU,eAAe;;;;;;;;;;YAW1C,gBACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,qBAEG,+BAA+B,UAAU,UAAU,iBACpD,uBAAuB,YACvB,uBAAuB,WACvB,qBAAqB;;;;;;;;YASZ,eACX,wBAAwB,uBAAuB,mBAAmB,SAAS,KAC3E;EAEA;IACG,uBAAuB;;;;;;YAOf,qBAAqB;EAChC;EACA;EACA;IACG,uBAAuB;;;;;;;;YAWf,uBAAuB;EAClC;EACA,UAAU"}
1
+ {"version":3,"file":"link.d.cts","names":[],"sources":["../../../src/types/value/link.ts"],"mappings":";;;;;;qBAOa;WACZ;WACA;WACA;WACA;;;;;;;;;;;;YAaW,UACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,cAAc,aAAa,YAC3B,oBACG,wBACD,sBAAsB,SAAS,KAAK,WACpC,gBAAgB,UAAU,UAAU,eAAe;;;;;;;;;;YAW1C,gBACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,qBAEG,+BAA+B,UAAU,UAAU,iBACpD,uBAAuB,YACvB,uBAAuB,WACvB,qBAAqB;;;;;;;YAQZ,eACX,wBAAwB,uBAAuB,mBAAmB,SAAS,KAC3E;EAEA;IACG,uBAAuB;;;;;;YAOf,qBAAqB;EAChC;EACA;EACA;IACG,uBAAuB;;;;;;;;YAWf,uBAAuB;EAClC;EACA,UAAU"}
@@ -34,8 +34,7 @@ export type FilledLinkField<TypeEnum = string, LangEnum = string, DataInterface
34
34
  /**
35
35
  * A link field that is not filled.
36
36
  *
37
- * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,
38
- * **please remove it**.
37
+ * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type, **please remove it**.
39
38
  * @typeParam Variant - Variants of the link.
40
39
  */
41
40
  export type EmptyLinkField<_Unused extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any, Variant = string> = {
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","names":[],"sources":["../../../src/types/value/link.ts"],"mappings":";;;;;;qBAOa;WACZ;WACA;WACA;WACA;;;;;;;;;;;;YAaW,UACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,cAAc,aAAa,YAC3B,oBACG,wBACD,sBAAsB,SAAS,KAAK,WACpC,gBAAgB,UAAU,UAAU,eAAe;;;;;;;;;;YAW1C,gBACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,qBAEG,+BAA+B,UAAU,UAAU,iBACpD,uBAAuB,YACvB,uBAAuB,WACvB,qBAAqB;;;;;;;;YASZ,eACX,wBAAwB,uBAAuB,mBAAmB,SAAS,KAC3E;EAEA;IACG,uBAAuB;;;;;;YAOf,qBAAqB;EAChC;EACA;EACA;IACG,uBAAuB;;;;;;;;YAWf,uBAAuB;EAClC;EACA,UAAU"}
1
+ {"version":3,"file":"link.d.ts","names":[],"sources":["../../../src/types/value/link.ts"],"mappings":";;;;;;qBAOa;WACZ;WACA;WACA;WACA;;;;;;;;;;;;YAaW,UACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,cAAc,aAAa,YAC3B,oBACG,wBACD,sBAAsB,SAAS,KAAK,WACpC,gBAAgB,UAAU,UAAU,eAAe;;;;;;;;;;YAW1C,gBACX,mBACA,mBACA,sBAAsB,eAAe,kBAAkB,aAAa,gCAEpE,qBAEG,+BAA+B,UAAU,UAAU,iBACpD,uBAAuB,YACvB,uBAAuB,WACvB,qBAAqB;;;;;;;YAQZ,eACX,wBAAwB,uBAAuB,mBAAmB,SAAS,KAC3E;EAEA;IACG,uBAAuB;;;;;;YAOf,qBAAqB;EAChC;EACA;EACA;IACG,uBAAuB;;;;;;;;YAWf,uBAAuB;EAClC;EACA,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"link.js","names":[],"sources":["../../../src/types/value/link.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { FilledLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\nimport type { AnyRegularField, FieldState } from \"./types\"\n\n/** Link types */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam State - State of the field which determines its shape.\n * @typeParam Variant - Variants of the link.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tState extends FieldState = FieldState,\n\tVariant = string,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any, Variant>\n\t: FilledLinkField<TypeEnum, LangEnum, DataInterface, Variant>\n\n/**\n * A link field that is filled.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tVariant = string,\n> =\n\t| (FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> &\n\t\t\tOptionalLinkProperties<Variant>)\n\t| FilledLinkToMediaField<Variant>\n\t| FilledLinkToWebField<Variant>\n\n/**\n * A link field that is not filled.\n *\n * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,\n * **please remove it**.\n * @typeParam Variant - Variants of the link.\n */\nexport type EmptyLinkField<\n\t_Unused extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n\tVariant = string,\n> = {\n\tlink_type: \"Any\"\n} & OptionalLinkProperties<Variant>\n\n/**\n * A link field pointing to a relative or absolute URL.\n *\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkToWebField<Variant = string> = {\n\tlink_type: \"Web\"\n\turl: string\n\ttarget?: string\n} & OptionalLinkProperties<Variant>\n\n/**\n * Optional properties available to link fields. It is used to augment existing link-like fields\n * (like content relationship fields) with field-specific properties.\n *\n * @typeParam Variant - Variants of the link.\n * @internal\n */\n// Remember to update the `getOptionalLinkProperties()` function when updating\n// this type. The function should check for every property.\nexport type OptionalLinkProperties<Variant = string> = {\n\ttext?: string\n\tvariant?: Variant\n}\n"],"mappings":";;AAOA,MAAa,WAAW;CACvB,KAAK;CACL,UAAU;CACV,OAAO;CACP,KAAK;AACN"}
1
+ {"version":3,"file":"link.js","names":[],"sources":["../../../src/types/value/link.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { FilledLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\nimport type { AnyRegularField, FieldState } from \"./types\"\n\n/** Link types */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam State - State of the field which determines its shape.\n * @typeParam Variant - Variants of the link.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tState extends FieldState = FieldState,\n\tVariant = string,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any, Variant>\n\t: FilledLinkField<TypeEnum, LangEnum, DataInterface, Variant>\n\n/**\n * A link field that is filled.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the `fetchLinks` or\n * `graphQuery` query parameter).\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown =\n\t\tunknown,\n\tVariant = string,\n> =\n\t| (FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> &\n\t\t\tOptionalLinkProperties<Variant>)\n\t| FilledLinkToMediaField<Variant>\n\t| FilledLinkToWebField<Variant>\n\n/**\n * A link field that is not filled.\n *\n * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type, **please remove it**.\n * @typeParam Variant - Variants of the link.\n */\nexport type EmptyLinkField<\n\t_Unused extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n\tVariant = string,\n> = {\n\tlink_type: \"Any\"\n} & OptionalLinkProperties<Variant>\n\n/**\n * A link field pointing to a relative or absolute URL.\n *\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkToWebField<Variant = string> = {\n\tlink_type: \"Web\"\n\turl: string\n\ttarget?: string\n} & OptionalLinkProperties<Variant>\n\n/**\n * Optional properties available to link fields. It is used to augment existing link-like fields\n * (like content relationship fields) with field-specific properties.\n *\n * @typeParam Variant - Variants of the link.\n * @internal\n */\n// Remember to update the `getOptionalLinkProperties()` function when updating\n// this type. The function should check for every property.\nexport type OptionalLinkProperties<Variant = string> = {\n\ttext?: string\n\tvariant?: Variant\n}\n"],"mappings":";;AAOA,MAAa,WAAW;CACvB,KAAK;CACL,UAAU;CACV,OAAO;CACP,KAAK;AACN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/client",
3
- "version": "7.23.1-pr.493.6b3afad",
3
+ "version": "7.23.1-pr.494.95ca2ea",
4
4
  "description": "The official JavaScript + TypeScript client library for Prismic",
5
5
  "keywords": [
6
6
  "client",
@@ -241,7 +241,7 @@ export class WriteClient<
241
241
  * published content.
242
242
  *
243
243
  * @example
244
- * ```ts
244
+ * ;```ts
245
245
  * const migration = createMigration()
246
246
  *
247
247
  * // Prepare and run a migration.
@@ -21,8 +21,7 @@ export interface CreateClient {
21
21
  * createClient("https://my-repo.cdn.prismic.io/api/v2")
22
22
  * ```
23
23
  *
24
- * @typeParam TDocuments - A union of Prismic page and custom types for the
25
- * repository.
24
+ * @typeParam TDocuments - A union of Prismic page and custom types for the repository.
26
25
  * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for
27
26
  * the repository.
28
27
  * @param options - Configuration that determines how content will be queried from the Prismic
@@ -80,8 +80,7 @@ type HTMLRichTextMapSerializerFunction<BlockType extends keyof RichTextMapSerial
80
80
  /**
81
81
  * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.
82
82
  *
83
- * @typeParam T - The `RichTextMapSerializerFunction` containing the needed
84
- * `Node` generic.
83
+ * @typeParam T - The `RichTextMapSerializerFunction` containing the needed `Node` generic.
85
84
  */
86
85
  type ExtractNodeGeneric<T> =
87
86
  T extends RichTextMapSerializerFunction<
@@ -97,8 +96,7 @@ type ExtractNodeGeneric<T> =
97
96
  /**
98
97
  * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.
99
98
  *
100
- * @typeParam T - The `RichTextMapSerializerFunction` containing the needed
101
- * `TextType` generic.
99
+ * @typeParam T - The `RichTextMapSerializerFunction` containing the needed `TextType` generic.
102
100
  */
103
101
  type ExtractTextTypeGeneric<T> =
104
102
  T extends RichTextMapSerializerFunction<
@@ -60,8 +60,7 @@ export const asLink: {
60
60
  * // => "/blog/my-post"
61
61
  * ```
62
62
  *
63
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
64
- * type.
63
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.
65
64
  * @typeParam Field - Link field or Prismic page to resolve to a URL.
66
65
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve.
67
66
  * @param config - Configuration that determines the output of `asLink()`.
@@ -84,8 +83,7 @@ export const asLink: {
84
83
  * Converts any type of link field or Prismic page to a URL.
85
84
  *
86
85
  * @deprecated Use object-style configuration instead.
87
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
88
- * type.
86
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type.
89
87
  * @typeParam Field - Link field or Prismic page to resolve to a URL.
90
88
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve.
91
89
  * @param linkResolver - An optional link resolver function. Without it, you're expected to use
@@ -65,8 +65,7 @@ type AsLinkAttrsReturnType<
65
65
  * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as
66
66
  * `"noreferrer"`.
67
67
  *
68
- * @typeParam LinkResolverFunctionReturnType - Link resolver function return
69
- * type
68
+ * @typeParam LinkResolverFunctionReturnType - Link resolver function return type
70
69
  * @typeParam Field - Link field or Prismic page to resolve to link attributes
71
70
  * @param linkFieldOrDocument - Any kind of link field or a page to resolve
72
71
  * @param config - Configuration that determines the output of `asLinkAttrs()`
@@ -57,8 +57,7 @@ export type FilledLinkField<
57
57
  /**
58
58
  * A link field that is not filled.
59
59
  *
60
- * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,
61
- * **please remove it**.
60
+ * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type, **please remove it**.
62
61
  * @typeParam Variant - Variants of the link.
63
62
  */
64
63
  export type EmptyLinkField<