@prismicio/client 7.22.0 → 7.22.1-canary.1615579
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.
- package/README.md +6 -0
- package/dist/Client.cjs +8 -4
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +14 -16
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +14 -16
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +8 -4
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +24 -23
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +1 -3
- package/dist/Migration.d.cts.map +1 -1
- package/dist/Migration.d.ts +1 -3
- package/dist/Migration.d.ts.map +1 -1
- package/dist/Migration.js +24 -23
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +21 -19
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +18 -22
- package/dist/WriteClient.d.cts.map +1 -1
- package/dist/WriteClient.d.ts +18 -22
- package/dist/WriteClient.d.ts.map +1 -1
- package/dist/WriteClient.js +21 -19
- package/dist/WriteClient.js.map +1 -1
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.cts +5 -6
- package/dist/buildQueryURL.d.cts.map +1 -1
- package/dist/buildQueryURL.d.ts +5 -6
- package/dist/buildQueryURL.d.ts.map +1 -1
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.d.cts +1 -1
- package/dist/cookie.d.cts.map +1 -1
- package/dist/cookie.d.ts +1 -1
- package/dist/cookie.d.ts.map +1 -1
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +2 -4
- package/dist/createClient.d.cts.map +1 -1
- package/dist/createClient.d.ts +2 -4
- package/dist/createClient.d.ts.map +1 -1
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +2 -4
- package/dist/createMigration.d.cts.map +1 -1
- package/dist/createMigration.d.ts +2 -4
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +2 -4
- package/dist/createWriteClient.d.cts.map +1 -1
- package/dist/createWriteClient.d.ts +2 -4
- package/dist/createWriteClient.d.ts.map +1 -1
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +9 -10
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts +9 -10
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/filter.cjs +175 -0
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.cts +3 -4
- package/dist/filter.d.cts.map +1 -1
- package/dist/filter.d.ts +3 -4
- package/dist/filter.d.ts.map +1 -1
- package/dist/filter.js +175 -0
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.cts +1 -2
- package/dist/getGraphQLEndpoint.d.cts.map +1 -1
- package/dist/getGraphQLEndpoint.d.ts +1 -2
- package/dist/getGraphQLEndpoint.d.ts.map +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.cts +1 -2
- package/dist/getRepositoryEndpoint.d.cts.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts +1 -2
- package/dist/getRepositoryEndpoint.d.ts.map +1 -1
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.cts +1 -2
- package/dist/getRepositoryName.d.cts.map +1 -1
- package/dist/getRepositoryName.d.ts +1 -2
- package/dist/getRepositoryName.d.ts.map +1 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +1 -2
- package/dist/getToolbarSrc.d.cts.map +1 -1
- package/dist/getToolbarSrc.d.ts +1 -2
- package/dist/getToolbarSrc.d.ts.map +1 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +1 -3
- package/dist/helpers/asDate.d.cts.map +1 -1
- package/dist/helpers/asDate.d.ts +1 -3
- package/dist/helpers/asDate.d.ts.map +1 -1
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +7 -5
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +12 -11
- package/dist/helpers/asHTML.d.cts.map +1 -1
- package/dist/helpers/asHTML.d.ts +12 -11
- package/dist/helpers/asHTML.d.ts.map +1 -1
- package/dist/helpers/asHTML.js +7 -5
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +3 -4
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +3 -4
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +1 -3
- package/dist/helpers/asImageSrc.d.cts.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +1 -3
- package/dist/helpers/asImageSrc.d.ts.map +1 -1
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +3 -4
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +3 -4
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +3 -5
- package/dist/helpers/asLink.d.cts.map +1 -1
- package/dist/helpers/asLink.d.ts +3 -5
- package/dist/helpers/asLink.d.ts.map +1 -1
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.cts +2 -4
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +2 -4
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +1 -3
- package/dist/helpers/asText.d.cts.map +1 -1
- package/dist/helpers/asText.d.ts +1 -3
- package/dist/helpers/asText.d.ts.map +1 -1
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.cts +1 -3
- package/dist/helpers/documentToLinkField.d.cts.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts +1 -3
- package/dist/helpers/documentToLinkField.d.ts.map +1 -1
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +20 -0
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.cts +22 -24
- package/dist/helpers/isFilled.d.cts.map +1 -1
- package/dist/helpers/isFilled.d.ts +22 -24
- package/dist/helpers/isFilled.d.ts.map +1 -1
- package/dist/helpers/isFilled.js +1 -1
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +10 -8
- package/dist/helpers/mapSliceZone.d.cts.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +10 -8
- package/dist/helpers/mapSliceZone.d.ts.map +1 -1
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.cts +1 -2
- package/dist/isRepositoryEndpoint.d.cts.map +1 -1
- package/dist/isRepositoryEndpoint.d.ts +1 -2
- package/dist/isRepositoryEndpoint.d.ts.map +1 -1
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.cts +1 -2
- package/dist/isRepositoryName.d.cts.map +1 -1
- package/dist/isRepositoryName.d.ts +1 -2
- package/dist/isRepositoryName.d.ts.map +1 -1
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +1 -0
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +5 -6
- package/dist/lib/request.d.cts.map +1 -1
- package/dist/lib/request.d.ts +5 -6
- package/dist/lib/request.d.ts.map +1 -1
- package/dist/lib/request.js +1 -1
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +3 -0
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +1 -1
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +10 -6
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +10 -6
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/throttledWarn.cjs.map +1 -1
- package/dist/lib/throttledWarn.js.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +1 -3
- package/dist/richtext/asText.d.cts.map +1 -1
- package/dist/richtext/asText.d.ts +1 -3
- package/dist/richtext/asText.d.ts.map +1 -1
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +1 -3
- package/dist/richtext/asTree.d.cts.map +1 -1
- package/dist/richtext/asTree.d.ts +1 -3
- package/dist/richtext/asTree.d.ts.map +1 -1
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +1 -3
- package/dist/richtext/composeSerializers.d.cts.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +1 -3
- package/dist/richtext/composeSerializers.d.ts.map +1 -1
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +1 -3
- package/dist/richtext/serialize.d.cts.map +1 -1
- package/dist/richtext/serialize.d.ts +1 -3
- package/dist/richtext/serialize.d.ts.map +1 -1
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +5 -7
- package/dist/richtext/types.d.cts.map +1 -1
- package/dist/richtext/types.d.ts +5 -7
- package/dist/richtext/types.d.ts.map +1 -1
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +1 -3
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +1 -3
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/types/api/asset/asset.d.cts +35 -20
- package/dist/types/api/asset/asset.d.cts.map +1 -1
- package/dist/types/api/asset/asset.d.ts +35 -20
- package/dist/types/api/asset/asset.d.ts.map +1 -1
- package/dist/types/api/asset/tag.d.cts +12 -7
- package/dist/types/api/asset/tag.d.cts.map +1 -1
- package/dist/types/api/asset/tag.d.ts +12 -7
- package/dist/types/api/asset/tag.d.ts.map +1 -1
- package/dist/types/api/integration.d.cts +2 -4
- package/dist/types/api/integration.d.cts.map +1 -1
- package/dist/types/api/integration.d.ts +2 -4
- package/dist/types/api/integration.d.ts.map +1 -1
- package/dist/types/api/migration/release.d.cts +3 -7
- package/dist/types/api/migration/release.d.cts.map +1 -1
- package/dist/types/api/migration/release.d.ts +3 -7
- package/dist/types/api/migration/release.d.ts.map +1 -1
- package/dist/types/api/query.d.cts +1 -3
- package/dist/types/api/query.d.cts.map +1 -1
- package/dist/types/api/query.d.ts +1 -3
- package/dist/types/api/query.d.ts.map +1 -1
- package/dist/types/api/ref.d.cts +1 -2
- package/dist/types/api/ref.d.cts.map +1 -1
- package/dist/types/api/ref.d.ts +1 -2
- package/dist/types/api/ref.d.ts.map +1 -1
- package/dist/types/api/release.d.cts +1 -3
- package/dist/types/api/release.d.cts.map +1 -1
- package/dist/types/api/release.d.ts +1 -3
- package/dist/types/api/release.d.ts.map +1 -1
- package/dist/types/api/repository.d.cts +4 -6
- package/dist/types/api/repository.d.cts.map +1 -1
- package/dist/types/api/repository.d.ts +4 -6
- package/dist/types/api/repository.d.ts.map +1 -1
- package/dist/types/api/tags.d.cts +1 -2
- package/dist/types/api/tags.d.cts.map +1 -1
- package/dist/types/api/tags.d.ts +1 -2
- package/dist/types/api/tags.d.ts.map +1 -1
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +21 -15
- package/dist/types/migration/Asset.d.cts.map +1 -1
- package/dist/types/migration/Asset.d.ts +21 -15
- package/dist/types/migration/Asset.d.ts.map +1 -1
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.cts +1 -3
- package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
- package/dist/types/migration/ContentRelationship.d.ts +1 -3
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +8 -8
- package/dist/types/migration/Document.d.cts.map +1 -1
- package/dist/types/migration/Document.d.ts +8 -8
- package/dist/types/migration/Document.d.ts.map +1 -1
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/model/boolean.d.cts +1 -3
- package/dist/types/model/boolean.d.cts.map +1 -1
- package/dist/types/model/boolean.d.ts +1 -3
- package/dist/types/model/boolean.d.ts.map +1 -1
- package/dist/types/model/color.d.cts +1 -3
- package/dist/types/model/color.d.cts.map +1 -1
- package/dist/types/model/color.d.ts +1 -3
- package/dist/types/model/color.d.ts.map +1 -1
- package/dist/types/model/contentRelationship.d.cts +6 -8
- package/dist/types/model/contentRelationship.d.cts.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +6 -8
- package/dist/types/model/contentRelationship.d.ts.map +1 -1
- package/dist/types/model/customType.d.cts +3 -5
- package/dist/types/model/customType.d.cts.map +1 -1
- package/dist/types/model/customType.d.ts +3 -5
- package/dist/types/model/customType.d.ts.map +1 -1
- package/dist/types/model/date.d.cts +1 -3
- package/dist/types/model/date.d.cts.map +1 -1
- package/dist/types/model/date.d.ts +1 -3
- package/dist/types/model/date.d.ts.map +1 -1
- package/dist/types/model/embed.d.cts +1 -3
- package/dist/types/model/embed.d.cts.map +1 -1
- package/dist/types/model/embed.d.ts +1 -3
- package/dist/types/model/embed.d.ts.map +1 -1
- package/dist/types/model/geoPoint.d.cts +1 -3
- package/dist/types/model/geoPoint.d.cts.map +1 -1
- package/dist/types/model/geoPoint.d.ts +1 -3
- package/dist/types/model/geoPoint.d.ts.map +1 -1
- package/dist/types/model/group.d.cts +2 -4
- package/dist/types/model/group.d.cts.map +1 -1
- package/dist/types/model/group.d.ts +2 -4
- package/dist/types/model/group.d.ts.map +1 -1
- package/dist/types/model/image.d.cts +3 -5
- package/dist/types/model/image.d.cts.map +1 -1
- package/dist/types/model/image.d.ts +3 -5
- package/dist/types/model/image.d.ts.map +1 -1
- package/dist/types/model/integration.d.cts +1 -3
- package/dist/types/model/integration.d.cts.map +1 -1
- package/dist/types/model/integration.d.ts +1 -3
- package/dist/types/model/integration.d.ts.map +1 -1
- package/dist/types/model/keyText.d.cts +1 -3
- package/dist/types/model/keyText.d.cts.map +1 -1
- package/dist/types/model/keyText.d.ts +1 -3
- package/dist/types/model/keyText.d.ts.map +1 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.cts +2 -4
- package/dist/types/model/link.d.cts.map +1 -1
- package/dist/types/model/link.d.ts +2 -4
- package/dist/types/model/link.d.ts.map +1 -1
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.cts +1 -3
- package/dist/types/model/linkToMedia.d.cts.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +1 -3
- package/dist/types/model/linkToMedia.d.ts.map +1 -1
- package/dist/types/model/number.d.cts +1 -3
- package/dist/types/model/number.d.cts.map +1 -1
- package/dist/types/model/number.d.ts +1 -3
- package/dist/types/model/number.d.ts.map +1 -1
- package/dist/types/model/range.d.cts +1 -3
- package/dist/types/model/range.d.cts.map +1 -1
- package/dist/types/model/range.d.ts +1 -3
- package/dist/types/model/range.d.ts.map +1 -1
- package/dist/types/model/richText.d.cts +3 -5
- package/dist/types/model/richText.d.cts.map +1 -1
- package/dist/types/model/richText.d.ts +3 -5
- package/dist/types/model/richText.d.ts.map +1 -1
- package/dist/types/model/select.d.cts +1 -3
- package/dist/types/model/select.d.cts.map +1 -1
- package/dist/types/model/select.d.ts +1 -3
- package/dist/types/model/select.d.ts.map +1 -1
- package/dist/types/model/separator.d.cts +1 -3
- package/dist/types/model/separator.d.cts.map +1 -1
- package/dist/types/model/separator.d.ts +1 -3
- package/dist/types/model/separator.d.ts.map +1 -1
- package/dist/types/model/sharedSlice.d.cts +1 -3
- package/dist/types/model/sharedSlice.d.cts.map +1 -1
- package/dist/types/model/sharedSlice.d.ts +1 -3
- package/dist/types/model/sharedSlice.d.ts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.cts +1 -3
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.ts +1 -3
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +3 -5
- package/dist/types/model/slice.d.cts.map +1 -1
- package/dist/types/model/slice.d.ts +3 -5
- package/dist/types/model/slice.d.ts.map +1 -1
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts +4 -6
- package/dist/types/model/sliceZone.d.cts.map +1 -1
- package/dist/types/model/sliceZone.d.ts +4 -6
- package/dist/types/model/sliceZone.d.ts.map +1 -1
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/table.d.cts +1 -3
- package/dist/types/model/table.d.cts.map +1 -1
- package/dist/types/model/table.d.ts +1 -3
- package/dist/types/model/table.d.ts.map +1 -1
- package/dist/types/model/timestamp.d.cts +1 -3
- package/dist/types/model/timestamp.d.cts.map +1 -1
- package/dist/types/model/timestamp.d.ts +1 -3
- package/dist/types/model/timestamp.d.ts.map +1 -1
- package/dist/types/model/title.d.cts +1 -3
- package/dist/types/model/title.d.cts.map +1 -1
- package/dist/types/model/title.d.ts +1 -3
- package/dist/types/model/title.d.ts.map +1 -1
- package/dist/types/model/types.cjs +4 -0
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +13 -11
- package/dist/types/model/types.d.cts.map +1 -1
- package/dist/types/model/types.d.ts +13 -11
- package/dist/types/model/types.d.ts.map +1 -1
- package/dist/types/model/types.js +4 -0
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/model/uid.d.cts +1 -3
- package/dist/types/model/uid.d.cts.map +1 -1
- package/dist/types/model/uid.d.ts +1 -3
- package/dist/types/model/uid.d.ts.map +1 -1
- package/dist/types/value/boolean.d.cts +1 -2
- package/dist/types/value/boolean.d.cts.map +1 -1
- package/dist/types/value/boolean.d.ts +1 -2
- package/dist/types/value/boolean.d.ts.map +1 -1
- package/dist/types/value/color.d.cts +1 -3
- package/dist/types/value/color.d.cts.map +1 -1
- package/dist/types/value/color.d.ts +1 -3
- package/dist/types/value/color.d.ts.map +1 -1
- package/dist/types/value/contentRelationship.d.cts +3 -5
- package/dist/types/value/contentRelationship.d.cts.map +1 -1
- package/dist/types/value/contentRelationship.d.ts +3 -5
- package/dist/types/value/contentRelationship.d.ts.map +1 -1
- package/dist/types/value/date.d.cts +1 -3
- package/dist/types/value/date.d.cts.map +1 -1
- package/dist/types/value/date.d.ts +1 -3
- package/dist/types/value/date.d.ts.map +1 -1
- package/dist/types/value/document.d.cts +5 -7
- package/dist/types/value/document.d.cts.map +1 -1
- package/dist/types/value/document.d.ts +5 -7
- package/dist/types/value/document.d.ts.map +1 -1
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +43 -25
- package/dist/types/value/embed.d.cts.map +1 -1
- package/dist/types/value/embed.d.ts +43 -25
- package/dist/types/value/embed.d.ts.map +1 -1
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.cts +1 -3
- package/dist/types/value/geoPoint.d.cts.map +1 -1
- package/dist/types/value/geoPoint.d.ts +1 -3
- package/dist/types/value/geoPoint.d.ts.map +1 -1
- package/dist/types/value/group.d.cts +2 -4
- package/dist/types/value/group.d.cts.map +1 -1
- package/dist/types/value/group.d.ts +2 -4
- package/dist/types/value/group.d.ts.map +1 -1
- package/dist/types/value/image.d.cts +4 -6
- package/dist/types/value/image.d.cts.map +1 -1
- package/dist/types/value/image.d.ts +4 -6
- package/dist/types/value/image.d.ts.map +1 -1
- package/dist/types/value/integration.d.cts +2 -4
- package/dist/types/value/integration.d.cts.map +1 -1
- package/dist/types/value/integration.d.ts +2 -4
- package/dist/types/value/integration.d.ts.map +1 -1
- package/dist/types/value/keyText.d.cts +1 -3
- package/dist/types/value/keyText.d.cts.map +1 -1
- package/dist/types/value/keyText.d.ts +1 -3
- package/dist/types/value/keyText.d.ts.map +1 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +6 -8
- package/dist/types/value/link.d.cts.map +1 -1
- package/dist/types/value/link.d.ts +6 -8
- package/dist/types/value/link.d.ts.map +1 -1
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.cts +2 -4
- package/dist/types/value/linkToMedia.d.cts.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +2 -4
- package/dist/types/value/linkToMedia.d.ts.map +1 -1
- package/dist/types/value/number.d.cts +1 -3
- package/dist/types/value/number.d.cts.map +1 -1
- package/dist/types/value/number.d.ts +1 -3
- package/dist/types/value/number.d.ts.map +1 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +29 -31
- package/dist/types/value/richText.d.cts.map +1 -1
- package/dist/types/value/richText.d.ts +29 -31
- package/dist/types/value/richText.d.ts.map +1 -1
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.cts +1 -3
- package/dist/types/value/select.d.cts.map +1 -1
- package/dist/types/value/select.d.ts +1 -3
- package/dist/types/value/select.d.ts.map +1 -1
- package/dist/types/value/sharedSlice.d.cts +1 -3
- package/dist/types/value/sharedSlice.d.cts.map +1 -1
- package/dist/types/value/sharedSlice.d.ts +1 -3
- package/dist/types/value/sharedSlice.d.ts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.cts +1 -3
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +1 -3
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/value/slice.d.cts +1 -3
- package/dist/types/value/slice.d.cts.map +1 -1
- package/dist/types/value/slice.d.ts +1 -3
- package/dist/types/value/slice.d.ts.map +1 -1
- package/dist/types/value/sliceZone.d.cts +1 -3
- package/dist/types/value/sliceZone.d.cts.map +1 -1
- package/dist/types/value/sliceZone.d.ts +1 -3
- package/dist/types/value/sliceZone.d.ts.map +1 -1
- package/dist/types/value/table.d.cts +26 -16
- package/dist/types/value/table.d.cts.map +1 -1
- package/dist/types/value/table.d.ts +26 -16
- package/dist/types/value/table.d.ts.map +1 -1
- package/dist/types/value/timestamp.d.cts +1 -3
- package/dist/types/value/timestamp.d.cts.map +1 -1
- package/dist/types/value/timestamp.d.ts +1 -3
- package/dist/types/value/timestamp.d.ts.map +1 -1
- package/dist/types/value/title.d.cts +1 -3
- package/dist/types/value/title.d.cts.map +1 -1
- package/dist/types/value/title.d.ts +1 -3
- package/dist/types/value/title.d.ts.map +1 -1
- package/dist/types/value/types.d.cts +6 -8
- package/dist/types/value/types.d.cts.map +1 -1
- package/dist/types/value/types.d.ts +6 -8
- package/dist/types/value/types.d.ts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.cts +1 -3
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.ts +1 -3
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
- package/dist/types/webhook/testTrigger.d.cts +1 -3
- package/dist/types/webhook/testTrigger.d.cts.map +1 -1
- package/dist/types/webhook/testTrigger.d.ts +1 -3
- package/dist/types/webhook/testTrigger.d.ts.map +1 -1
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.cts +3 -5
- package/dist/types/webhook/types.d.cts.map +1 -1
- package/dist/types/webhook/types.d.ts +3 -5
- package/dist/types/webhook/types.d.ts.map +1 -1
- package/dist/types/webhook/types.js.map +1 -1
- package/package.json +11 -11
- package/src/WriteClient.ts +14 -19
- package/src/lib/resolveMigrationDocumentData.ts +1 -1
- package/src/types/api/migration/release.ts +2 -5
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ImageFieldImage } from "../types/value/image.js";
|
|
2
2
|
import { ImgixURLParams } from "imgix-url-builder";
|
|
3
|
-
|
|
4
3
|
//#region src/helpers/asImageSrc.d.ts
|
|
5
4
|
/** The return type of `asImageSrc()`. */
|
|
6
5
|
type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> = Field extends ImageFieldImage<"filled"> ? string : null;
|
|
@@ -20,7 +19,6 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> = Fi
|
|
|
20
19
|
* @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}
|
|
21
20
|
* @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}
|
|
22
21
|
*/
|
|
23
|
-
declare const asImageSrc: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
|
|
22
|
+
export declare const asImageSrc: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
|
|
24
23
|
//#endregion
|
|
25
|
-
export { asImageSrc };
|
|
26
24
|
//# sourceMappingURL=asImageSrc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asImageSrc.d.ts","names":[],"sources":["../../src/helpers/asImageSrc.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asImageSrc.d.ts","names":[],"sources":["../../src/helpers/asImageSrc.ts"],"mappings":";;;;KAOK,qBAAqB,cAAc,sCACvC,cAAc;;;;;;;;;;;;;;;;;qBAkBF,aAAc,cAAc,oCAAkC,OACnE,OAAK,SACJ,mBACN,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asImageSrc.js","names":["isImageThumbnailFilled"],"sources":["../../src/helpers/asImageSrc.ts"],"sourcesContent":["import type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\n\nimport type { ImageFieldImage } from \"../types/value/image\"\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\"\n\n/** The return type of `asImageSrc()`. */\ntype AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\"> ? string : null\n\n/**\n * Returns the URL of an image field with optional image transformations via imgix URL parameters.\n *\n * @example\n * \t;```ts\n * \tconst src = asImageSrc(document.data.photo, { sat: -100 })\n * \t// => \"https://images.prismic.io/repo/image.png?sat=-100\"\n * \t```\n *\n * @param field - An image field (or one of its responsive views) from which to get an image URL.\n * @param config - An object of imgix URL API parameters to transform the image.\n * @returns The image field's URL with transformations applied, or `null` if the\n * field is empty.\n * @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}\n * @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}\n */\nexport const asImageSrc = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: ImgixURLParams = {},\n): AsImageSrcReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\treturn buildURL(field.url, config) as AsImageSrcReturnType<Field>\n\t} else {\n\t\treturn null as AsImageSrcReturnType<Field>\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,MAAa,cACZ,OACA,SAAyB,
|
|
1
|
+
{"version":3,"file":"asImageSrc.js","names":["isImageThumbnailFilled"],"sources":["../../src/helpers/asImageSrc.ts"],"sourcesContent":["import type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\n\nimport type { ImageFieldImage } from \"../types/value/image\"\nimport { imageThumbnail as isImageThumbnailFilled } from \"./isFilled\"\n\n/** The return type of `asImageSrc()`. */\ntype AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\"> ? string : null\n\n/**\n * Returns the URL of an image field with optional image transformations via imgix URL parameters.\n *\n * @example\n * \t;```ts\n * \tconst src = asImageSrc(document.data.photo, { sat: -100 })\n * \t// => \"https://images.prismic.io/repo/image.png?sat=-100\"\n * \t```\n *\n * @param field - An image field (or one of its responsive views) from which to get an image URL.\n * @param config - An object of imgix URL API parameters to transform the image.\n * @returns The image field's URL with transformations applied, or `null` if the\n * field is empty.\n * @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}\n * @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}\n */\nexport const asImageSrc = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: ImgixURLParams = {},\n): AsImageSrcReturnType<Field> => {\n\tif (field && isImageThumbnailFilled(field)) {\n\t\treturn buildURL(field.url, config) as AsImageSrcReturnType<Field>\n\t} else {\n\t\treturn null as AsImageSrcReturnType<Field>\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,MAAa,cACZ,OACA,SAAyB,CAAC,MACO;CACjC,IAAI,SAASA,eAAuB,KAAK,GACxC,OAAO,SAAS,MAAM,KAAK,MAAM;MAEjC,OAAO;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asImageWidthSrcSet.cjs","names":[],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import type { BuildWidthSrcSetParams } from \"imgix-url-builder\"\nimport { buildURL, buildWidthSrcSet } from \"imgix-url-builder\"\n\nimport type { ImageFieldImage } from \"../types/value/image\"\nimport * as isFilled from \"./isFilled\"\n\n/** The default widths used to generate a `srcset` value. */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840]\n\n/** The return type of `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\">\n\t\t? {\n\t\t\t\t/** The image field's URL with imgix URL parameters (if given). */\n\t\t\t\tsrc: string\n\n\t\t\t\t/**\n\t\t\t\t * A width-based `srcset` attribute value for the image field with imgix URL parameters (if\n\t\t\t\t * given).\n\t\t\t\t */\n\t\t\t\tsrcset: string\n\t\t\t}\n\t\t: null\n\n/** Configuration for `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"]\n}\n\n/**\n * Creates a width-based `srcset` from an image field with optional image transformations via imgix\n * URL parameters.\n *\n * If a `widths` parameter is not given, the following widths (in pixels) will be used by default:\n * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be used as a width in the\n * resulting `srcset` by passing `\"thumbnails\"` as the `widths` parameter.\n *\n * @example\n * \t;```ts\n * \tconst srcset = asImageWidthSrcSet(document.data.photo, {\n * \t\twidths: [400, 800, 1600],\n * \t\tsat: -100,\n * \t})\n * \t// => {\n * \t// src: \"https://images.prismic.io/repo/image.png?sat=-100\",\n * \t// srcset: \"https://images.prismic.io/repo/image.png?sat=-100&width=400 400w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=800 800w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w\"\n * \t// }\n * \t```\n *\n * @param field - An image field (or one of its responsive views) from which to get an image URL.\n * @param config - An object of imgix URL API parameters. The `widths` parameter defines the\n * resulting `srcset` widths. Pass `\"thumbnails\"` to automatically use the field's responsive\n * views.\n * @returns A `srcset` attribute value for the image field with imgix URL parameters, or `null` if\n * the field is empty.\n * @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}\n * @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}\n */\nexport const asImageWidthSrcSet = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\t// oxlint-disable-next-line prefer-const\n\t\tlet { widths = DEFAULT_WIDTHS, ...imgixParams } = config\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tid: _id,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\tedit: _edit,\n\t\t\t...responsiveViews\n\t\t} = field\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] = Object.values(responsiveViews)\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t\t}),\n\t\t} as AsImageWidthSrcSetReturnType<Field>\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>\n\t}\n}\n"],"mappings":";;;;AAOA,MAAM,iBAAiB;CAAC;CAAK;CAAK;CAAM;CAAM;
|
|
1
|
+
{"version":3,"file":"asImageWidthSrcSet.cjs","names":["buildURL","buildWidthSrcSet"],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import type { BuildWidthSrcSetParams } from \"imgix-url-builder\"\nimport { buildURL, buildWidthSrcSet } from \"imgix-url-builder\"\n\nimport type { ImageFieldImage } from \"../types/value/image\"\nimport * as isFilled from \"./isFilled\"\n\n/** The default widths used to generate a `srcset` value. */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840]\n\n/** The return type of `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\">\n\t\t? {\n\t\t\t\t/** The image field's URL with imgix URL parameters (if given). */\n\t\t\t\tsrc: string\n\n\t\t\t\t/**\n\t\t\t\t * A width-based `srcset` attribute value for the image field with imgix URL parameters (if\n\t\t\t\t * given).\n\t\t\t\t */\n\t\t\t\tsrcset: string\n\t\t\t}\n\t\t: null\n\n/** Configuration for `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"]\n}\n\n/**\n * Creates a width-based `srcset` from an image field with optional image transformations via imgix\n * URL parameters.\n *\n * If a `widths` parameter is not given, the following widths (in pixels) will be used by default:\n * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be used as a width in the\n * resulting `srcset` by passing `\"thumbnails\"` as the `widths` parameter.\n *\n * @example\n * \t;```ts\n * \tconst srcset = asImageWidthSrcSet(document.data.photo, {\n * \t\twidths: [400, 800, 1600],\n * \t\tsat: -100,\n * \t})\n * \t// => {\n * \t// src: \"https://images.prismic.io/repo/image.png?sat=-100\",\n * \t// srcset: \"https://images.prismic.io/repo/image.png?sat=-100&width=400 400w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=800 800w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w\"\n * \t// }\n * \t```\n *\n * @param field - An image field (or one of its responsive views) from which to get an image URL.\n * @param config - An object of imgix URL API parameters. The `widths` parameter defines the\n * resulting `srcset` widths. Pass `\"thumbnails\"` to automatically use the field's responsive\n * views.\n * @returns A `srcset` attribute value for the image field with imgix URL parameters, or `null` if\n * the field is empty.\n * @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}\n * @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}\n */\nexport const asImageWidthSrcSet = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\t// oxlint-disable-next-line prefer-const\n\t\tlet { widths = DEFAULT_WIDTHS, ...imgixParams } = config\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tid: _id,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\tedit: _edit,\n\t\t\t...responsiveViews\n\t\t} = field\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] = Object.values(responsiveViews)\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t\t}),\n\t\t} as AsImageWidthSrcSetReturnType<Field>\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>\n\t}\n}\n"],"mappings":";;;;AAOA,MAAM,iBAAiB;CAAC;CAAK;CAAK;CAAM;CAAM;AAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDlD,MAAa,sBACZ,OACA,SAAmC,CAAC,MACK;CACzC,IAAI,SAAA,iBAAA,eAAiC,KAAK,GAAG;EAI5C,IAAI,EAAE,SAAS,gBAAgB,GAAG,gBAAgB;EAClD,MAAM,EACL,KACA,YACA,IAAI,KACJ,KAAK,MACL,WAAW,YACX,MAAM,OACN,GAAG,oBACA;EAIJ,MAAM,wBAAqD,OAAO,OAAO,eAAe;EAKxF,IAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAC7D,SAAS;EAGV,OAAO;GACN,MAAA,GAAKA,kBAAAA,SAAAA,CAAS,KAAK,WAAW;GAC9B,QAGC,WAAW,eACR,EAAA,GACAC,kBAAAA,iBAAAA,CAAiB,KAAK;IACrB,GAAG;IACH,QAAQ,CAAC,WAAW,KAAK;GAC1B,CAAC,GACD,GAAG,sBAAsB,KAAK,cAAc;IAC3C,QAAA,GAAOA,kBAAAA,iBAAAA,CAAiB,UAAU,KAAK;KACtC,GAAG;KACH,QAAQ,CAAC,UAAU,WAAW,KAAK;IACpC,CAAC;GACF,CAAC,CACF,CAAC,CAAC,KAAK,IAAI,KAAA,GACVA,kBAAAA,iBAAAA,CAAiB,MAAM,KAAK;IAC5B,GAAG;IACH;GACD,CAAC;EACL;CACD,OACC,OAAO;AAET"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ImageFieldImage } from "../types/value/image.cjs";
|
|
2
2
|
import { BuildWidthSrcSetParams } from "imgix-url-builder";
|
|
3
|
-
|
|
4
3
|
//#region src/helpers/asImageWidthSrcSet.d.ts
|
|
5
4
|
/** The return type of `asImageWidthSrcSet()`. */
|
|
6
5
|
type AsImageWidthSrcSetReturnType<Field extends ImageFieldImage | null | undefined> = Field extends ImageFieldImage<"filled"> ? {
|
|
7
|
-
/** The image field's URL with imgix URL parameters (if given). */
|
|
6
|
+
/** The image field's URL with imgix URL parameters (if given). */
|
|
7
|
+
src: string;
|
|
8
8
|
/**
|
|
9
9
|
* A width-based `srcset` attribute value for the image field with imgix URL parameters (if
|
|
10
10
|
* given).
|
|
@@ -48,7 +48,6 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
48
48
|
* @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}
|
|
49
49
|
* @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}
|
|
50
50
|
*/
|
|
51
|
-
declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
|
|
51
|
+
export declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { asImageWidthSrcSet };
|
|
54
53
|
//# sourceMappingURL=asImageWidthSrcSet.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asImageWidthSrcSet.d.cts","names":[],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asImageWidthSrcSet.d.cts","names":[],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"mappings":";;;;KAUK,6BAA6B,cAAc,sCAC/C,cAAc;;EAGX;;;;;EAMA;;;KAKC,2BAA2B,KAAK;EACpC,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCZ,qBAAsB,cAAc,oCAAkC,OAC3E,OAAK,SACJ,6BACN,6BAA6B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ImageFieldImage } from "../types/value/image.js";
|
|
2
2
|
import { BuildWidthSrcSetParams } from "imgix-url-builder";
|
|
3
|
-
|
|
4
3
|
//#region src/helpers/asImageWidthSrcSet.d.ts
|
|
5
4
|
/** The return type of `asImageWidthSrcSet()`. */
|
|
6
5
|
type AsImageWidthSrcSetReturnType<Field extends ImageFieldImage | null | undefined> = Field extends ImageFieldImage<"filled"> ? {
|
|
7
|
-
/** The image field's URL with imgix URL parameters (if given). */
|
|
6
|
+
/** The image field's URL with imgix URL parameters (if given). */
|
|
7
|
+
src: string;
|
|
8
8
|
/**
|
|
9
9
|
* A width-based `srcset` attribute value for the image field with imgix URL parameters (if
|
|
10
10
|
* given).
|
|
@@ -48,7 +48,6 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
48
48
|
* @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}
|
|
49
49
|
* @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}
|
|
50
50
|
*/
|
|
51
|
-
declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
|
|
51
|
+
export declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { asImageWidthSrcSet };
|
|
54
53
|
//# sourceMappingURL=asImageWidthSrcSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asImageWidthSrcSet.d.ts","names":[],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asImageWidthSrcSet.d.ts","names":[],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"mappings":";;;;KAUK,6BAA6B,cAAc,sCAC/C,cAAc;;EAGX;;;;;EAMA;;;KAKC,2BAA2B,KAAK;EACpC,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCZ,qBAAsB,cAAc,oCAAkC,OAC3E,OAAK,SACJ,6BACN,6BAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asImageWidthSrcSet.js","names":["isFilled.imageThumbnail"],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import type { BuildWidthSrcSetParams } from \"imgix-url-builder\"\nimport { buildURL, buildWidthSrcSet } from \"imgix-url-builder\"\n\nimport type { ImageFieldImage } from \"../types/value/image\"\nimport * as isFilled from \"./isFilled\"\n\n/** The default widths used to generate a `srcset` value. */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840]\n\n/** The return type of `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\">\n\t\t? {\n\t\t\t\t/** The image field's URL with imgix URL parameters (if given). */\n\t\t\t\tsrc: string\n\n\t\t\t\t/**\n\t\t\t\t * A width-based `srcset` attribute value for the image field with imgix URL parameters (if\n\t\t\t\t * given).\n\t\t\t\t */\n\t\t\t\tsrcset: string\n\t\t\t}\n\t\t: null\n\n/** Configuration for `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"]\n}\n\n/**\n * Creates a width-based `srcset` from an image field with optional image transformations via imgix\n * URL parameters.\n *\n * If a `widths` parameter is not given, the following widths (in pixels) will be used by default:\n * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be used as a width in the\n * resulting `srcset` by passing `\"thumbnails\"` as the `widths` parameter.\n *\n * @example\n * \t;```ts\n * \tconst srcset = asImageWidthSrcSet(document.data.photo, {\n * \t\twidths: [400, 800, 1600],\n * \t\tsat: -100,\n * \t})\n * \t// => {\n * \t// src: \"https://images.prismic.io/repo/image.png?sat=-100\",\n * \t// srcset: \"https://images.prismic.io/repo/image.png?sat=-100&width=400 400w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=800 800w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w\"\n * \t// }\n * \t```\n *\n * @param field - An image field (or one of its responsive views) from which to get an image URL.\n * @param config - An object of imgix URL API parameters. The `widths` parameter defines the\n * resulting `srcset` widths. Pass `\"thumbnails\"` to automatically use the field's responsive\n * views.\n * @returns A `srcset` attribute value for the image field with imgix URL parameters, or `null` if\n * the field is empty.\n * @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}\n * @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}\n */\nexport const asImageWidthSrcSet = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\t// oxlint-disable-next-line prefer-const\n\t\tlet { widths = DEFAULT_WIDTHS, ...imgixParams } = config\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tid: _id,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\tedit: _edit,\n\t\t\t...responsiveViews\n\t\t} = field\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] = Object.values(responsiveViews)\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t\t}),\n\t\t} as AsImageWidthSrcSetReturnType<Field>\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>\n\t}\n}\n"],"mappings":";;;;AAOA,MAAM,iBAAiB;CAAC;CAAK;CAAK;CAAM;CAAM;
|
|
1
|
+
{"version":3,"file":"asImageWidthSrcSet.js","names":["isFilled.imageThumbnail"],"sources":["../../src/helpers/asImageWidthSrcSet.ts"],"sourcesContent":["import type { BuildWidthSrcSetParams } from \"imgix-url-builder\"\nimport { buildURL, buildWidthSrcSet } from \"imgix-url-builder\"\n\nimport type { ImageFieldImage } from \"../types/value/image\"\nimport * as isFilled from \"./isFilled\"\n\n/** The default widths used to generate a `srcset` value. */\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840]\n\n/** The return type of `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetReturnType<Field extends ImageFieldImage | null | undefined> =\n\tField extends ImageFieldImage<\"filled\">\n\t\t? {\n\t\t\t\t/** The image field's URL with imgix URL parameters (if given). */\n\t\t\t\tsrc: string\n\n\t\t\t\t/**\n\t\t\t\t * A width-based `srcset` attribute value for the image field with imgix URL parameters (if\n\t\t\t\t * given).\n\t\t\t\t */\n\t\t\t\tsrcset: string\n\t\t\t}\n\t\t: null\n\n/** Configuration for `asImageWidthSrcSet()`. */\ntype AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, \"widths\"> & {\n\twidths?: \"thumbnails\" | BuildWidthSrcSetParams[\"widths\"]\n}\n\n/**\n * Creates a width-based `srcset` from an image field with optional image transformations via imgix\n * URL parameters.\n *\n * If a `widths` parameter is not given, the following widths (in pixels) will be used by default:\n * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n *\n * If the image field contains responsive views, each responsive view can be used as a width in the\n * resulting `srcset` by passing `\"thumbnails\"` as the `widths` parameter.\n *\n * @example\n * \t;```ts\n * \tconst srcset = asImageWidthSrcSet(document.data.photo, {\n * \t\twidths: [400, 800, 1600],\n * \t\tsat: -100,\n * \t})\n * \t// => {\n * \t// src: \"https://images.prismic.io/repo/image.png?sat=-100\",\n * \t// srcset: \"https://images.prismic.io/repo/image.png?sat=-100&width=400 400w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=800 800w, \" +\n * \t// \"https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w\"\n * \t// }\n * \t```\n *\n * @param field - An image field (or one of its responsive views) from which to get an image URL.\n * @param config - An object of imgix URL API parameters. The `widths` parameter defines the\n * resulting `srcset` widths. Pass `\"thumbnails\"` to automatically use the field's responsive\n * views.\n * @returns A `srcset` attribute value for the image field with imgix URL parameters, or `null` if\n * the field is empty.\n * @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}\n * @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}\n */\nexport const asImageWidthSrcSet = <Field extends ImageFieldImage | null | undefined>(\n\tfield: Field,\n\tconfig: AsImageWidthSrcSetConfig = {},\n): AsImageWidthSrcSetReturnType<Field> => {\n\tif (field && isFilled.imageThumbnail(field)) {\n\t\t// We are using destructuring to omit `widths` from the object\n\t\t// we will pass to `buildURL()`.\n\t\t// oxlint-disable-next-line prefer-const\n\t\tlet { widths = DEFAULT_WIDTHS, ...imgixParams } = config\n\t\tconst {\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tid: _id,\n\t\t\talt: _alt,\n\t\t\tcopyright: _copyright,\n\t\t\tedit: _edit,\n\t\t\t...responsiveViews\n\t\t} = field\n\n\t\t// The Prismic Rest API will always return thumbnail values if\n\t\t// the base size is filled.\n\t\tconst responsiveViewObjects: ImageFieldImage<\"filled\">[] = Object.values(responsiveViews)\n\n\t\t// If this `asImageWidthSrcSet()` call is configured to use\n\t\t// thumbnail widths, but the field does not have thumbnails, we\n\t\t// fall back to the default set of widths.\n\t\tif (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n\t\t\twidths = DEFAULT_WIDTHS\n\t\t}\n\n\t\treturn {\n\t\t\tsrc: buildURL(url, imgixParams),\n\t\t\tsrcset:\n\t\t\t\t// By this point, we know `widths` can only be\n\t\t\t\t// `\"thubmanils\"` if the field has thumbnails.\n\t\t\t\twidths === \"thumbnails\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tbuildWidthSrcSet(url, {\n\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\twidths: [dimensions.width],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...responsiveViewObjects.map((thumbnail) => {\n\t\t\t\t\t\t\t\treturn buildWidthSrcSet(thumbnail.url, {\n\t\t\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\t\t\twidths: [thumbnail.dimensions.width],\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t].join(\", \")\n\t\t\t\t\t: buildWidthSrcSet(field.url, {\n\t\t\t\t\t\t\t...imgixParams,\n\t\t\t\t\t\t\twidths,\n\t\t\t\t\t\t}),\n\t\t} as AsImageWidthSrcSetReturnType<Field>\n\t} else {\n\t\treturn null as AsImageWidthSrcSetReturnType<Field>\n\t}\n}\n"],"mappings":";;;;AAOA,MAAM,iBAAiB;CAAC;CAAK;CAAK;CAAM;CAAM;AAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDlD,MAAa,sBACZ,OACA,SAAmC,CAAC,MACK;CACzC,IAAI,SAASA,eAAwB,KAAK,GAAG;EAI5C,IAAI,EAAE,SAAS,gBAAgB,GAAG,gBAAgB;EAClD,MAAM,EACL,KACA,YACA,IAAI,KACJ,KAAK,MACL,WAAW,YACX,MAAM,OACN,GAAG,oBACA;EAIJ,MAAM,wBAAqD,OAAO,OAAO,eAAe;EAKxF,IAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAC7D,SAAS;EAGV,OAAO;GACN,KAAK,SAAS,KAAK,WAAW;GAC9B,QAGC,WAAW,eACR,CACA,iBAAiB,KAAK;IACrB,GAAG;IACH,QAAQ,CAAC,WAAW,KAAK;GAC1B,CAAC,GACD,GAAG,sBAAsB,KAAK,cAAc;IAC3C,OAAO,iBAAiB,UAAU,KAAK;KACtC,GAAG;KACH,QAAQ,CAAC,UAAU,WAAW,KAAK;IACpC,CAAC;GACF,CAAC,CACF,CAAC,CAAC,KAAK,IAAI,IACV,iBAAiB,MAAM,KAAK;IAC5B,GAAG;IACH;GACD,CAAC;EACL;CACD,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;
|
|
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"}
|
|
@@ -2,7 +2,6 @@ import { FilledContentRelationshipField } from "../types/value/contentRelationsh
|
|
|
2
2
|
import { FilledLinkToMediaField } from "../types/value/linkToMedia.cjs";
|
|
3
3
|
import { FilledLinkToWebField, LinkField } from "../types/value/link.cjs";
|
|
4
4
|
import { PrismicDocument } from "../types/value/document.cjs";
|
|
5
|
-
|
|
6
5
|
//#region src/helpers/asLink.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Resolves a link to a Prismic page to a URL.
|
|
@@ -13,7 +12,7 @@ import { PrismicDocument } from "../types/value/document.cjs";
|
|
|
13
12
|
* @returns Resolved URL.
|
|
14
13
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
15
14
|
*/
|
|
16
|
-
type LinkResolverFunction<ReturnType = string | null | undefined> = (linkToDocumentField: FilledContentRelationshipField) => ReturnType;
|
|
15
|
+
export type LinkResolverFunction<ReturnType = string | null | undefined> = (linkToDocumentField: FilledContentRelationshipField) => ReturnType;
|
|
17
16
|
/** Configuration that determines the output of `asLink()`. */
|
|
18
17
|
type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> = {
|
|
19
18
|
/**
|
|
@@ -25,8 +24,8 @@ type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =
|
|
|
25
24
|
/** @deprecated Use object-style configuration instead. */
|
|
26
25
|
type AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType = string | null | undefined> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null];
|
|
27
26
|
/** The return type of `asLink()`. */
|
|
28
|
-
type AsLinkReturnType<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = Field extends FilledLinkToWebField | FilledLinkToMediaField | FilledContentRelationshipField | PrismicDocument ? LinkResolverFunctionReturnType | string | null : null;
|
|
29
|
-
declare const asLink: {
|
|
27
|
+
export type AsLinkReturnType<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = Field extends FilledLinkToWebField | FilledLinkToMediaField | FilledContentRelationshipField | PrismicDocument ? LinkResolverFunctionReturnType | string | null : null;
|
|
28
|
+
export declare const asLink: {
|
|
30
29
|
/**
|
|
31
30
|
* Converts any type of link field or Prismic page to a URL.
|
|
32
31
|
*
|
|
@@ -61,5 +60,4 @@ declare const asLink: {
|
|
|
61
60
|
<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, ...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
|
|
62
61
|
};
|
|
63
62
|
//#endregion
|
|
64
|
-
export { AsLinkReturnType, LinkResolverFunction, asLink };
|
|
65
63
|
//# sourceMappingURL=asLink.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLink.d.cts","names":[],"sources":["../../src/helpers/asLink.ts"],"mappings":"
|
|
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"}
|
package/dist/helpers/asLink.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { FilledContentRelationshipField } from "../types/value/contentRelationsh
|
|
|
2
2
|
import { FilledLinkToMediaField } from "../types/value/linkToMedia.js";
|
|
3
3
|
import { FilledLinkToWebField, LinkField } from "../types/value/link.js";
|
|
4
4
|
import { PrismicDocument } from "../types/value/document.js";
|
|
5
|
-
|
|
6
5
|
//#region src/helpers/asLink.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Resolves a link to a Prismic page to a URL.
|
|
@@ -13,7 +12,7 @@ import { PrismicDocument } from "../types/value/document.js";
|
|
|
13
12
|
* @returns Resolved URL.
|
|
14
13
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
15
14
|
*/
|
|
16
|
-
type LinkResolverFunction<ReturnType = string | null | undefined> = (linkToDocumentField: FilledContentRelationshipField) => ReturnType;
|
|
15
|
+
export type LinkResolverFunction<ReturnType = string | null | undefined> = (linkToDocumentField: FilledContentRelationshipField) => ReturnType;
|
|
17
16
|
/** Configuration that determines the output of `asLink()`. */
|
|
18
17
|
type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> = {
|
|
19
18
|
/**
|
|
@@ -25,8 +24,8 @@ type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =
|
|
|
25
24
|
/** @deprecated Use object-style configuration instead. */
|
|
26
25
|
type AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType = string | null | undefined> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null];
|
|
27
26
|
/** The return type of `asLink()`. */
|
|
28
|
-
type AsLinkReturnType<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = Field extends FilledLinkToWebField | FilledLinkToMediaField | FilledContentRelationshipField | PrismicDocument ? LinkResolverFunctionReturnType | string | null : null;
|
|
29
|
-
declare const asLink: {
|
|
27
|
+
export type AsLinkReturnType<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = Field extends FilledLinkToWebField | FilledLinkToMediaField | FilledContentRelationshipField | PrismicDocument ? LinkResolverFunctionReturnType | string | null : null;
|
|
28
|
+
export declare const asLink: {
|
|
30
29
|
/**
|
|
31
30
|
* Converts any type of link field or Prismic page to a URL.
|
|
32
31
|
*
|
|
@@ -61,5 +60,4 @@ declare const asLink: {
|
|
|
61
60
|
<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, ...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
|
|
62
61
|
};
|
|
63
62
|
//#endregion
|
|
64
|
-
export { AsLinkReturnType, LinkResolverFunction, asLink };
|
|
65
63
|
//# sourceMappingURL=asLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLink.d.ts","names":[],"sources":["../../src/helpers/asLink.ts"],"mappings":"
|
|
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 +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;
|
|
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 +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,
|
|
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"}
|
|
@@ -3,14 +3,13 @@ import { FilledLinkToMediaField } from "../types/value/linkToMedia.cjs";
|
|
|
3
3
|
import { FilledLinkToWebField, LinkField } from "../types/value/link.cjs";
|
|
4
4
|
import { PrismicDocument } from "../types/value/document.cjs";
|
|
5
5
|
import { AsLinkReturnType, LinkResolverFunction } from "./asLink.cjs";
|
|
6
|
-
|
|
7
6
|
//#region src/helpers/asLinkAttrs.d.ts
|
|
8
7
|
type AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = {
|
|
9
8
|
href: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | undefined;
|
|
10
9
|
isExternal: boolean;
|
|
11
10
|
target?: string;
|
|
12
11
|
};
|
|
13
|
-
type AsLinkAttrsConfig<LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = {
|
|
12
|
+
export type AsLinkAttrsConfig<LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = {
|
|
14
13
|
linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>;
|
|
15
14
|
rel?: (args: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>) => string | undefined | void;
|
|
16
15
|
};
|
|
@@ -40,7 +39,6 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
|
|
|
40
39
|
* empty object
|
|
41
40
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
42
41
|
*/
|
|
43
|
-
declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
42
|
+
export declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
44
43
|
//#endregion
|
|
45
|
-
export { AsLinkAttrsConfig, asLinkAttrs };
|
|
46
44
|
//# sourceMappingURL=asLinkAttrs.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLinkAttrs.d.cts","names":[],"sources":["../../src/helpers/asLinkAttrs.ts"],"mappings":"
|
|
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"}
|
|
@@ -3,14 +3,13 @@ import { FilledLinkToMediaField } from "../types/value/linkToMedia.js";
|
|
|
3
3
|
import { FilledLinkToWebField, LinkField } from "../types/value/link.js";
|
|
4
4
|
import { PrismicDocument } from "../types/value/document.js";
|
|
5
5
|
import { AsLinkReturnType, LinkResolverFunction } from "./asLink.js";
|
|
6
|
-
|
|
7
6
|
//#region src/helpers/asLinkAttrs.d.ts
|
|
8
7
|
type AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = {
|
|
9
8
|
href: NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>> | undefined;
|
|
10
9
|
isExternal: boolean;
|
|
11
10
|
target?: string;
|
|
12
11
|
};
|
|
13
|
-
type AsLinkAttrsConfig<LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = {
|
|
12
|
+
export type AsLinkAttrsConfig<LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined> = {
|
|
14
13
|
linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>;
|
|
15
14
|
rel?: (args: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>) => string | undefined | void;
|
|
16
15
|
};
|
|
@@ -40,7 +39,6 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
|
|
|
40
39
|
* empty object
|
|
41
40
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
42
41
|
*/
|
|
43
|
-
declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
42
|
+
export declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
44
43
|
//#endregion
|
|
45
|
-
export { AsLinkAttrsConfig, asLinkAttrs };
|
|
46
44
|
//# sourceMappingURL=asLinkAttrs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLinkAttrs.d.ts","names":[],"sources":["../../src/helpers/asLinkAttrs.ts"],"mappings":"
|
|
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 +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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.cjs","names":["baseAsText"],"sources":["../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"../richtext/asText\"\nimport type { RichTextField } from \"../types/value/richText\"\n\n/** Configuration that determines the output of `asText()`. */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/** The return type of `asText()`. */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField\n\t? string\n\t: null\n\nexport const asText: {\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst text = asText(document.data.content)\n\t * \t// => \"Hello world\"\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 `asText()`.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param separator - Separator used to join each element. Defaults to a space.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(richTextField, config.separator) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"mappings":";;AAsBA,MAAa,UAoCZ,eAEA,GAAG,wBAC0B;
|
|
1
|
+
{"version":3,"file":"asText.cjs","names":["baseAsText"],"sources":["../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"../richtext/asText\"\nimport type { RichTextField } from \"../types/value/richText\"\n\n/** Configuration that determines the output of `asText()`. */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/** The return type of `asText()`. */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField\n\t? string\n\t: null\n\nexport const asText: {\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst text = asText(document.data.content)\n\t * \t// => \"Hello world\"\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 `asText()`.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param separator - Separator used to join each element. Defaults to a space.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(richTextField, config.separator) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"mappings":";;AAsBA,MAAa,UAoCZ,eAEA,GAAG,wBAC0B;CAC7B,IAAI,eAAe;EAElB,MAAM,CAAC,2BAA2B;EAClC,IAAI;EACJ,IAAI,OAAO,4BAA4B,UACtC,SAAS,EACR,WAAW,wBACZ;OAEA,SAAS,EAAE,GAAG,wBAAwB;EAGvC,OAAOA,eAAAA,OAAW,eAAe,OAAO,SAAS;CAClD,OACC,OAAO;AAET"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RichTextField } from "../types/value/richText.cjs";
|
|
2
|
-
|
|
3
2
|
//#region src/helpers/asText.d.ts
|
|
4
3
|
/** Configuration that determines the output of `asText()`. */
|
|
5
4
|
type AsTextConfig = {
|
|
@@ -14,7 +13,7 @@ type AsTextConfig = {
|
|
|
14
13
|
type AsTextDeprecatedTupleConfig = [separator?: string];
|
|
15
14
|
/** The return type of `asText()`. */
|
|
16
15
|
type AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField ? string : null;
|
|
17
|
-
declare const asText: {
|
|
16
|
+
export declare const asText: {
|
|
18
17
|
/**
|
|
19
18
|
* Converts a rich text field to a plain text string.
|
|
20
19
|
*
|
|
@@ -44,5 +43,4 @@ declare const asText: {
|
|
|
44
43
|
<Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsTextDeprecatedTupleConfig): AsTextReturnType<Field>;
|
|
45
44
|
};
|
|
46
45
|
//#endregion
|
|
47
|
-
export { asText };
|
|
48
46
|
//# sourceMappingURL=asText.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/helpers/asText.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/helpers/asText.ts"],"mappings":";;;KAIK;;;;;;EAMJ;;;KAKI,+BAA+B;;KAG/B,iBAAiB,cAAc,oCAAoC,cAAc;qBAIzE;;;;;;;;;;;;;;;;GAgBX,cAAc,kCACd,eAAe,OACf,SAAS,eACP,iBAAiB;;;;;;;;;;;GAYnB,cAAc,kCACd,eAAe,UACZ,QAAQ,8BACT,iBAAiB"}
|
package/dist/helpers/asText.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RichTextField } from "../types/value/richText.js";
|
|
2
|
-
|
|
3
2
|
//#region src/helpers/asText.d.ts
|
|
4
3
|
/** Configuration that determines the output of `asText()`. */
|
|
5
4
|
type AsTextConfig = {
|
|
@@ -14,7 +13,7 @@ type AsTextConfig = {
|
|
|
14
13
|
type AsTextDeprecatedTupleConfig = [separator?: string];
|
|
15
14
|
/** The return type of `asText()`. */
|
|
16
15
|
type AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField ? string : null;
|
|
17
|
-
declare const asText: {
|
|
16
|
+
export declare const asText: {
|
|
18
17
|
/**
|
|
19
18
|
* Converts a rich text field to a plain text string.
|
|
20
19
|
*
|
|
@@ -44,5 +43,4 @@ declare const asText: {
|
|
|
44
43
|
<Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsTextDeprecatedTupleConfig): AsTextReturnType<Field>;
|
|
45
44
|
};
|
|
46
45
|
//#endregion
|
|
47
|
-
export { asText };
|
|
48
46
|
//# sourceMappingURL=asText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/helpers/asText.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/helpers/asText.ts"],"mappings":";;;KAIK;;;;;;EAMJ;;;KAKI,+BAA+B;;KAG/B,iBAAiB,cAAc,oCAAoC,cAAc;qBAIzE;;;;;;;;;;;;;;;;GAgBX,cAAc,kCACd,eAAe,OACf,SAAS,eACP,iBAAiB;;;;;;;;;;;GAYnB,cAAc,kCACd,eAAe,UACZ,QAAQ,8BACT,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.js","names":["baseAsText"],"sources":["../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"../richtext/asText\"\nimport type { RichTextField } from \"../types/value/richText\"\n\n/** Configuration that determines the output of `asText()`. */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/** The return type of `asText()`. */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField\n\t? string\n\t: null\n\nexport const asText: {\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst text = asText(document.data.content)\n\t * \t// => \"Hello world\"\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 `asText()`.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param separator - Separator used to join each element. Defaults to a space.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(richTextField, config.separator) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"mappings":";;AAsBA,MAAa,UAoCZ,eAEA,GAAG,wBAC0B;
|
|
1
|
+
{"version":3,"file":"asText.js","names":["baseAsText"],"sources":["../../src/helpers/asText.ts"],"sourcesContent":["import { asText as baseAsText } from \"../richtext/asText\"\nimport type { RichTextField } from \"../types/value/richText\"\n\n/** Configuration that determines the output of `asText()`. */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/** @deprecated Use object-style configuration instead. */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/** The return type of `asText()`. */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField\n\t? string\n\t: null\n\nexport const asText: {\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst text = asText(document.data.content)\n\t * \t// => \"Hello world\"\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 `asText()`.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Converts a rich text field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t * @param richTextField - A rich text field from Prismic.\n\t * @param separator - Separator used to join each element. Defaults to a space.\n\t * @returns Plain text equivalent of the rich text field, or `null` if the\n\t * field is empty.\n\t * @see Learn how to work with rich text fields: {@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: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(richTextField, config.separator) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"mappings":";;AAsBA,MAAa,UAoCZ,eAEA,GAAG,wBAC0B;CAC7B,IAAI,eAAe;EAElB,MAAM,CAAC,2BAA2B;EAClC,IAAI;EACJ,IAAI,OAAO,4BAA4B,UACtC,SAAS,EACR,WAAW,wBACZ;OAEA,SAAS,EAAE,GAAG,wBAAwB;EAGvC,OAAOA,SAAW,eAAe,OAAO,SAAS;CAClD,OACC,OAAO;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentToLinkField.cjs","names":["LinkType"],"sources":["../../src/helpers/documentToLinkField.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport { LinkType } from \"../types/value/link\"\n\ntype SetOptional<T, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys>>\n\n/**\n * Converts a document into a link field, this is useful when crawling the API for document links\n *\n * @typeParam TDocument - Specific interface of the provided document\n * @param prismicDocument - A document coming from Prismic\n * @returns The equivalent link field to use with `asLink()`\n * @internal\n */\nexport const documentToLinkField = <TDocument extends SetOptional<PrismicDocument, \"slugs\">>(\n\tprismicDocument: TDocument,\n): FilledContentRelationshipField<TDocument[\"type\"], TDocument[\"lang\"], TDocument[\"data\"]> => {\n\treturn {\n\t\tlink_type: LinkType.Document,\n\t\tid: prismicDocument.id,\n\t\tuid: prismicDocument.uid || undefined,\n\t\ttype: prismicDocument.type,\n\t\ttags: prismicDocument.tags,\n\t\tlang: prismicDocument.lang,\n\t\turl: prismicDocument.url == null ? undefined : prismicDocument.url,\n\t\tslug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL\n\t\t// The REST API does not include a `data` property if the data\n\t\t// object is empty.\n\t\t//\n\t\t// A presence check for `prismicDocument.data` is done to\n\t\t// support partial documents. While `documentToLinkField` is\n\t\t// not typed to accept partial documents, passing a partial\n\t\t// document can happen in untyped projects.\n\t\t...(prismicDocument.data && Object.keys(prismicDocument.data).length > 0\n\t\t\t? { data: prismicDocument.data }\n\t\t\t: {}),\n\t}\n}\n"],"mappings":";;;;;;;;;;AAcA,MAAa,uBACZ,oBAC6F;
|
|
1
|
+
{"version":3,"file":"documentToLinkField.cjs","names":["LinkType"],"sources":["../../src/helpers/documentToLinkField.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport { LinkType } from \"../types/value/link\"\n\ntype SetOptional<T, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys>>\n\n/**\n * Converts a document into a link field, this is useful when crawling the API for document links\n *\n * @typeParam TDocument - Specific interface of the provided document\n * @param prismicDocument - A document coming from Prismic\n * @returns The equivalent link field to use with `asLink()`\n * @internal\n */\nexport const documentToLinkField = <TDocument extends SetOptional<PrismicDocument, \"slugs\">>(\n\tprismicDocument: TDocument,\n): FilledContentRelationshipField<TDocument[\"type\"], TDocument[\"lang\"], TDocument[\"data\"]> => {\n\treturn {\n\t\tlink_type: LinkType.Document,\n\t\tid: prismicDocument.id,\n\t\tuid: prismicDocument.uid || undefined,\n\t\ttype: prismicDocument.type,\n\t\ttags: prismicDocument.tags,\n\t\tlang: prismicDocument.lang,\n\t\turl: prismicDocument.url == null ? undefined : prismicDocument.url,\n\t\tslug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL\n\t\t// The REST API does not include a `data` property if the data\n\t\t// object is empty.\n\t\t//\n\t\t// A presence check for `prismicDocument.data` is done to\n\t\t// support partial documents. While `documentToLinkField` is\n\t\t// not typed to accept partial documents, passing a partial\n\t\t// document can happen in untyped projects.\n\t\t...(prismicDocument.data && Object.keys(prismicDocument.data).length > 0\n\t\t\t? { data: prismicDocument.data }\n\t\t\t: {}),\n\t}\n}\n"],"mappings":";;;;;;;;;;AAcA,MAAa,uBACZ,oBAC6F;CAC7F,OAAO;EACN,WAAWA,aAAAA,SAAS;EACpB,IAAI,gBAAgB;EACpB,KAAK,gBAAgB,OAAO,KAAA;EAC5B,MAAM,gBAAgB;EACtB,MAAM,gBAAgB;EACtB,MAAM,gBAAgB;EACtB,KAAK,gBAAgB,OAAO,OAAO,KAAA,IAAY,gBAAgB;EAC/D,MAAM,gBAAgB,QAAQ;EAQ9B,GAAI,gBAAgB,QAAQ,OAAO,KAAK,gBAAgB,IAAI,CAAC,CAAC,SAAS,IACpE,EAAE,MAAM,gBAAgB,KAAK,IAC7B,CAAC;CACL;AACD"}
|