@prismicio/client 7.21.0-alpha.0 → 7.21.0-alpha.2
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/dist/index.cjs +3880 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4424 -0
- package/dist/index.d.mts +4424 -0
- package/dist/index.d.ts +4349 -128
- package/dist/index.mjs +3837 -0
- package/dist/index.mjs.map +1 -0
- package/dist/richtext/index.cjs +244 -0
- package/dist/richtext/index.cjs.map +1 -0
- package/dist/richtext/index.d.cts +78 -0
- package/dist/richtext/index.d.mts +78 -0
- package/dist/richtext/index.d.ts +78 -7
- package/dist/richtext/index.mjs +237 -0
- package/dist/richtext/index.mjs.map +1 -0
- package/dist/shared/client.TSGr56lO.d.cts +899 -0
- package/dist/shared/client.TSGr56lO.d.mts +899 -0
- package/dist/shared/client.TSGr56lO.d.ts +899 -0
- package/package.json +19 -42
- package/src/buildQueryURL.ts +29 -21
- package/src/createClient.ts +11 -8
- package/src/getRepositoryEndpoint.ts +9 -2
- package/src/helpers/asDate.ts +11 -4
- package/src/helpers/asHTML.ts +34 -26
- package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
- package/src/helpers/asImageSrc.ts +11 -10
- package/src/helpers/asImageWidthSrcSet.ts +18 -17
- package/src/helpers/asLink.ts +33 -32
- package/src/helpers/asLinkAttrs.ts +6 -9
- package/src/helpers/asText.ts +20 -10
- package/src/helpers/isFilled.ts +15 -14
- package/src/helpers/mapSliceZone.ts +10 -10
- package/src/index.ts +2 -2
- package/src/isRepositoryEndpoint.ts +2 -2
- package/src/richtext/asText.ts +5 -5
- package/src/richtext/serialize.ts +8 -8
- package/src/richtext/types.ts +6 -6
- package/src/types/migration/Asset.ts +10 -2
- package/src/types/model/types.ts +0 -2
- package/dist/Client.cjs +0 -1274
- package/dist/Client.cjs.map +0 -1
- package/dist/Client.d.ts +0 -981
- package/dist/Client.js +0 -1274
- package/dist/Client.js.map +0 -1
- package/dist/Migration.cjs +0 -315
- package/dist/Migration.cjs.map +0 -1
- package/dist/Migration.d.ts +0 -213
- package/dist/Migration.js +0 -315
- package/dist/Migration.js.map +0 -1
- package/dist/WriteClient.cjs +0 -560
- package/dist/WriteClient.cjs.map +0 -1
- package/dist/WriteClient.d.ts +0 -281
- package/dist/WriteClient.js +0 -560
- package/dist/WriteClient.js.map +0 -1
- package/dist/buildQueryURL.cjs +0 -66
- package/dist/buildQueryURL.cjs.map +0 -1
- package/dist/buildQueryURL.d.ts +0 -209
- package/dist/buildQueryURL.js +0 -66
- package/dist/buildQueryURL.js.map +0 -1
- package/dist/cookie.cjs +0 -5
- package/dist/cookie.cjs.map +0 -1
- package/dist/cookie.d.ts +0 -5
- package/dist/cookie.js +0 -5
- package/dist/cookie.js.map +0 -1
- package/dist/createClient.cjs +0 -6
- package/dist/createClient.cjs.map +0 -1
- package/dist/createClient.d.ts +0 -32
- package/dist/createClient.js +0 -6
- package/dist/createClient.js.map +0 -1
- package/dist/createMigration.cjs +0 -6
- package/dist/createMigration.cjs.map +0 -1
- package/dist/createMigration.d.ts +0 -24
- package/dist/createMigration.js +0 -6
- package/dist/createMigration.js.map +0 -1
- package/dist/createWriteClient.cjs +0 -6
- package/dist/createWriteClient.cjs.map +0 -1
- package/dist/createWriteClient.d.ts +0 -32
- package/dist/createWriteClient.js +0 -6
- package/dist/createWriteClient.js.map +0 -1
- package/dist/errors/ForbiddenError.cjs +0 -7
- package/dist/errors/ForbiddenError.cjs.map +0 -1
- package/dist/errors/ForbiddenError.d.ts +0 -11
- package/dist/errors/ForbiddenError.js +0 -7
- package/dist/errors/ForbiddenError.js.map +0 -1
- package/dist/errors/InvalidDataError.cjs +0 -7
- package/dist/errors/InvalidDataError.cjs.map +0 -1
- package/dist/errors/InvalidDataError.d.ts +0 -3
- package/dist/errors/InvalidDataError.js +0 -7
- package/dist/errors/InvalidDataError.js.map +0 -1
- package/dist/errors/NotFoundError.cjs +0 -7
- package/dist/errors/NotFoundError.cjs.map +0 -1
- package/dist/errors/NotFoundError.d.ts +0 -3
- package/dist/errors/NotFoundError.js +0 -7
- package/dist/errors/NotFoundError.js.map +0 -1
- package/dist/errors/ParsingError.cjs +0 -7
- package/dist/errors/ParsingError.cjs.map +0 -1
- package/dist/errors/ParsingError.d.ts +0 -14
- package/dist/errors/ParsingError.js +0 -7
- package/dist/errors/ParsingError.js.map +0 -1
- package/dist/errors/PreviewTokenExpired.cjs +0 -7
- package/dist/errors/PreviewTokenExpired.cjs.map +0 -1
- package/dist/errors/PreviewTokenExpired.d.ts +0 -8
- package/dist/errors/PreviewTokenExpired.js +0 -7
- package/dist/errors/PreviewTokenExpired.js.map +0 -1
- package/dist/errors/PrismicError.cjs +0 -16
- package/dist/errors/PrismicError.cjs.map +0 -1
- package/dist/errors/PrismicError.d.ts +0 -5
- package/dist/errors/PrismicError.js +0 -16
- package/dist/errors/PrismicError.js.map +0 -1
- package/dist/errors/RefExpiredError.cjs +0 -7
- package/dist/errors/RefExpiredError.cjs.map +0 -1
- package/dist/errors/RefExpiredError.d.ts +0 -8
- package/dist/errors/RefExpiredError.js +0 -7
- package/dist/errors/RefExpiredError.js.map +0 -1
- package/dist/errors/RefNotFoundError.cjs +0 -7
- package/dist/errors/RefNotFoundError.cjs.map +0 -1
- package/dist/errors/RefNotFoundError.d.ts +0 -8
- package/dist/errors/RefNotFoundError.js +0 -7
- package/dist/errors/RefNotFoundError.js.map +0 -1
- package/dist/errors/RepositoryNotFoundError.cjs +0 -7
- package/dist/errors/RepositoryNotFoundError.cjs.map +0 -1
- package/dist/errors/RepositoryNotFoundError.d.ts +0 -3
- package/dist/errors/RepositoryNotFoundError.js +0 -7
- package/dist/errors/RepositoryNotFoundError.js.map +0 -1
- package/dist/filter.cjs +0 -247
- package/dist/filter.cjs.map +0 -1
- package/dist/filter.d.ts +0 -209
- package/dist/filter.js +0 -247
- package/dist/filter.js.map +0 -1
- package/dist/getGraphQLEndpoint.cjs +0 -13
- package/dist/getGraphQLEndpoint.cjs.map +0 -1
- package/dist/getGraphQLEndpoint.d.ts +0 -10
- package/dist/getGraphQLEndpoint.js +0 -13
- package/dist/getGraphQLEndpoint.js.map +0 -1
- package/dist/getRepositoryEndpoint.cjs +0 -13
- package/dist/getRepositoryEndpoint.cjs.map +0 -1
- package/dist/getRepositoryEndpoint.d.ts +0 -12
- package/dist/getRepositoryEndpoint.js +0 -13
- package/dist/getRepositoryEndpoint.js.map +0 -1
- package/dist/getRepositoryName.cjs +0 -17
- package/dist/getRepositoryName.cjs.map +0 -1
- package/dist/getRepositoryName.d.ts +0 -12
- package/dist/getRepositoryName.js +0 -17
- package/dist/getRepositoryName.js.map +0 -1
- package/dist/getToolbarSrc.cjs +0 -13
- package/dist/getToolbarSrc.cjs.map +0 -1
- package/dist/getToolbarSrc.d.ts +0 -34
- package/dist/getToolbarSrc.js +0 -13
- package/dist/getToolbarSrc.js.map +0 -1
- package/dist/helpers/asDate.cjs +0 -14
- package/dist/helpers/asDate.cjs.map +0 -1
- package/dist/helpers/asDate.d.ts +0 -17
- package/dist/helpers/asDate.js +0 -14
- package/dist/helpers/asDate.js.map +0 -1
- package/dist/helpers/asHTML.cjs +0 -86
- package/dist/helpers/asHTML.cjs.map +0 -1
- package/dist/helpers/asHTML.d.ts +0 -141
- package/dist/helpers/asHTML.js +0 -86
- package/dist/helpers/asHTML.js.map +0 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +0 -21
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +0 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +0 -53
- package/dist/helpers/asImagePixelDensitySrcSet.js +0 -21
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +0 -1
- package/dist/helpers/asImageSrc.cjs +0 -13
- package/dist/helpers/asImageSrc.cjs.map +0 -1
- package/dist/helpers/asImageSrc.d.ts +0 -28
- package/dist/helpers/asImageSrc.js +0 -13
- package/dist/helpers/asImageSrc.js.map +0 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +0 -45
- package/dist/helpers/asImageWidthSrcSet.cjs.map +0 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +0 -61
- package/dist/helpers/asImageWidthSrcSet.js +0 -45
- package/dist/helpers/asImageWidthSrcSet.js.map +0 -1
- package/dist/helpers/asLink.cjs +0 -47
- package/dist/helpers/asLink.cjs.map +0 -1
- package/dist/helpers/asLink.d.ts +0 -77
- package/dist/helpers/asLink.js +0 -47
- package/dist/helpers/asLink.js.map +0 -1
- package/dist/helpers/asLinkAttrs.cjs +0 -28
- package/dist/helpers/asLinkAttrs.cjs.map +0 -1
- package/dist/helpers/asLinkAttrs.d.ts +0 -50
- package/dist/helpers/asLinkAttrs.js +0 -28
- package/dist/helpers/asLinkAttrs.js.map +0 -1
- package/dist/helpers/asText.cjs +0 -21
- package/dist/helpers/asText.cjs.map +0 -1
- package/dist/helpers/asText.d.ts +0 -47
- package/dist/helpers/asText.js +0 -21
- package/dist/helpers/asText.js.map +0 -1
- package/dist/helpers/documentToLinkField.cjs +0 -27
- package/dist/helpers/documentToLinkField.cjs.map +0 -1
- package/dist/helpers/documentToLinkField.d.ts +0 -17
- package/dist/helpers/documentToLinkField.js +0 -27
- package/dist/helpers/documentToLinkField.js.map +0 -1
- package/dist/helpers/isFilled.cjs +0 -77
- package/dist/helpers/isFilled.cjs.map +0 -1
- package/dist/helpers/isFilled.d.ts +0 -190
- package/dist/helpers/isFilled.js +0 -77
- package/dist/helpers/isFilled.js.map +0 -1
- package/dist/helpers/mapSliceZone.cjs +0 -42
- package/dist/helpers/mapSliceZone.cjs.map +0 -1
- package/dist/helpers/mapSliceZone.d.ts +0 -136
- package/dist/helpers/mapSliceZone.js +0 -42
- package/dist/helpers/mapSliceZone.js.map +0 -1
- package/dist/index.js +0 -97
- package/dist/index.js.map +0 -1
- package/dist/isRepositoryEndpoint.cjs +0 -12
- package/dist/isRepositoryEndpoint.cjs.map +0 -1
- package/dist/isRepositoryEndpoint.d.ts +0 -10
- package/dist/isRepositoryEndpoint.js +0 -12
- package/dist/isRepositoryEndpoint.js.map +0 -1
- package/dist/isRepositoryName.cjs +0 -7
- package/dist/isRepositoryName.cjs.map +0 -1
- package/dist/isRepositoryName.d.ts +0 -9
- package/dist/isRepositoryName.js +0 -7
- package/dist/isRepositoryName.js.map +0 -1
- package/dist/lib/appendFilters.cjs +0 -11
- package/dist/lib/appendFilters.cjs.map +0 -1
- package/dist/lib/appendFilters.d.ts +0 -18
- package/dist/lib/appendFilters.js +0 -11
- package/dist/lib/appendFilters.js.map +0 -1
- package/dist/lib/castArray.cjs +0 -7
- package/dist/lib/castArray.cjs.map +0 -1
- package/dist/lib/castArray.d.ts +0 -12
- package/dist/lib/castArray.js +0 -7
- package/dist/lib/castArray.js.map +0 -1
- package/dist/lib/castThunk.cjs +0 -7
- package/dist/lib/castThunk.cjs.map +0 -1
- package/dist/lib/castThunk.d.ts +0 -11
- package/dist/lib/castThunk.js +0 -7
- package/dist/lib/castThunk.js.map +0 -1
- package/dist/lib/devMsg.cjs +0 -8
- package/dist/lib/devMsg.cjs.map +0 -1
- package/dist/lib/devMsg.d.ts +0 -16
- package/dist/lib/devMsg.js +0 -8
- package/dist/lib/devMsg.js.map +0 -1
- package/dist/lib/escapeHTML.cjs +0 -43
- package/dist/lib/escapeHTML.cjs.map +0 -1
- package/dist/lib/escapeHTML.d.ts +0 -1
- package/dist/lib/escapeHTML.js +0 -43
- package/dist/lib/escapeHTML.js.map +0 -1
- package/dist/lib/everyTagFilter.cjs +0 -9
- package/dist/lib/everyTagFilter.cjs.map +0 -1
- package/dist/lib/everyTagFilter.d.ts +0 -9
- package/dist/lib/everyTagFilter.js +0 -9
- package/dist/lib/everyTagFilter.js.map +0 -1
- package/dist/lib/findMasterRef.cjs +0 -8
- package/dist/lib/findMasterRef.cjs.map +0 -1
- package/dist/lib/findMasterRef.d.ts +0 -11
- package/dist/lib/findMasterRef.js +0 -8
- package/dist/lib/findMasterRef.js.map +0 -1
- package/dist/lib/findRef.cjs +0 -12
- package/dist/lib/findRef.cjs.map +0 -1
- package/dist/lib/findRef.d.ts +0 -14
- package/dist/lib/findRef.js +0 -12
- package/dist/lib/findRef.js.map +0 -1
- package/dist/lib/findRefByID.cjs +0 -8
- package/dist/lib/findRefByID.cjs.map +0 -1
- package/dist/lib/findRefByID.d.ts +0 -12
- package/dist/lib/findRefByID.js +0 -8
- package/dist/lib/findRefByID.js.map +0 -1
- package/dist/lib/findRefByLabel.cjs +0 -8
- package/dist/lib/findRefByLabel.cjs.map +0 -1
- package/dist/lib/findRefByLabel.d.ts +0 -12
- package/dist/lib/findRefByLabel.js +0 -8
- package/dist/lib/findRefByLabel.js.map +0 -1
- package/dist/lib/getOptionalLinkProperties.cjs +0 -14
- package/dist/lib/getOptionalLinkProperties.cjs.map +0 -1
- package/dist/lib/getOptionalLinkProperties.d.ts +0 -12
- package/dist/lib/getOptionalLinkProperties.js +0 -14
- package/dist/lib/getOptionalLinkProperties.js.map +0 -1
- package/dist/lib/getPreviewCookie.cjs +0 -21
- package/dist/lib/getPreviewCookie.cjs.map +0 -1
- package/dist/lib/getPreviewCookie.d.ts +0 -9
- package/dist/lib/getPreviewCookie.js +0 -21
- package/dist/lib/getPreviewCookie.js.map +0 -1
- package/dist/lib/isInternalURL.cjs +0 -9
- package/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/lib/isInternalURL.d.ts +0 -8
- package/dist/lib/isInternalURL.js +0 -9
- package/dist/lib/isInternalURL.js.map +0 -1
- package/dist/lib/isMigrationValue.cjs +0 -24
- package/dist/lib/isMigrationValue.cjs.map +0 -1
- package/dist/lib/isMigrationValue.d.ts +0 -71
- package/dist/lib/isMigrationValue.js +0 -24
- package/dist/lib/isMigrationValue.js.map +0 -1
- package/dist/lib/isValue.cjs +0 -53
- package/dist/lib/isValue.cjs.map +0 -1
- package/dist/lib/isValue.d.ts +0 -78
- package/dist/lib/isValue.js +0 -53
- package/dist/lib/isValue.js.map +0 -1
- package/dist/lib/minifyGraphQLQuery.cjs +0 -7
- package/dist/lib/minifyGraphQLQuery.cjs.map +0 -1
- package/dist/lib/minifyGraphQLQuery.d.ts +0 -8
- package/dist/lib/minifyGraphQLQuery.js +0 -7
- package/dist/lib/minifyGraphQLQuery.js.map +0 -1
- package/dist/lib/pLimit.cjs +0 -49
- package/dist/lib/pLimit.cjs.map +0 -1
- package/dist/lib/pLimit.d.ts +0 -22
- package/dist/lib/pLimit.js +0 -49
- package/dist/lib/pLimit.js.map +0 -1
- package/dist/lib/request.cjs +0 -43
- package/dist/lib/request.cjs.map +0 -1
- package/dist/lib/request.d.ts +0 -73
- package/dist/lib/request.js +0 -43
- package/dist/lib/request.js.map +0 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +0 -134
- package/dist/lib/resolveMigrationDocumentData.cjs.map +0 -1
- package/dist/lib/resolveMigrationDocumentData.d.ts +0 -54
- package/dist/lib/resolveMigrationDocumentData.js +0 -134
- package/dist/lib/resolveMigrationDocumentData.js.map +0 -1
- package/dist/lib/serializerHelpers.cjs +0 -113
- package/dist/lib/serializerHelpers.cjs.map +0 -1
- package/dist/lib/serializerHelpers.d.ts +0 -9
- package/dist/lib/serializerHelpers.js +0 -113
- package/dist/lib/serializerHelpers.js.map +0 -1
- package/dist/lib/someTagsFilter.cjs +0 -9
- package/dist/lib/someTagsFilter.cjs.map +0 -1
- package/dist/lib/someTagsFilter.d.ts +0 -9
- package/dist/lib/someTagsFilter.js +0 -9
- package/dist/lib/someTagsFilter.js.map +0 -1
- package/dist/lib/throttledLog.cjs +0 -17
- package/dist/lib/throttledLog.cjs.map +0 -1
- package/dist/lib/throttledLog.d.ts +0 -15
- package/dist/lib/throttledLog.js +0 -17
- package/dist/lib/throttledLog.js.map +0 -1
- package/dist/lib/typeFilter.cjs +0 -8
- package/dist/lib/typeFilter.cjs.map +0 -1
- package/dist/lib/typeFilter.d.ts +0 -8
- package/dist/lib/typeFilter.js +0 -8
- package/dist/lib/typeFilter.js.map +0 -1
- package/dist/lib/validateAssetMetadata.cjs +0 -28
- package/dist/lib/validateAssetMetadata.cjs.map +0 -1
- package/dist/lib/validateAssetMetadata.d.ts +0 -10
- package/dist/lib/validateAssetMetadata.js +0 -28
- package/dist/lib/validateAssetMetadata.js.map +0 -1
- package/dist/package.json.cjs +0 -7
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -7
- package/dist/package.json.js.map +0 -1
- package/dist/richtext/asText.cjs +0 -13
- package/dist/richtext/asText.cjs.map +0 -1
- package/dist/richtext/asText.d.ts +0 -12
- package/dist/richtext/asText.js +0 -13
- package/dist/richtext/asText.js.map +0 -1
- package/dist/richtext/asTree.cjs +0 -123
- package/dist/richtext/asTree.cjs.map +0 -1
- package/dist/richtext/asTree.d.ts +0 -14
- package/dist/richtext/asTree.js +0 -123
- package/dist/richtext/asTree.js.map +0 -1
- package/dist/richtext/composeSerializers.cjs +0 -17
- package/dist/richtext/composeSerializers.cjs.map +0 -1
- package/dist/richtext/composeSerializers.d.ts +0 -16
- package/dist/richtext/composeSerializers.js +0 -17
- package/dist/richtext/composeSerializers.js.map +0 -1
- package/dist/richtext/serialize.cjs +0 -19
- package/dist/richtext/serialize.cjs.map +0 -1
- package/dist/richtext/serialize.d.ts +0 -19
- package/dist/richtext/serialize.js +0 -19
- package/dist/richtext/serialize.js.map +0 -1
- package/dist/richtext/types.cjs +0 -11
- package/dist/richtext/types.cjs.map +0 -1
- package/dist/richtext/types.d.ts +0 -71
- package/dist/richtext/types.js +0 -11
- package/dist/richtext/types.js.map +0 -1
- package/dist/richtext/wrapMapSerializer.cjs +0 -24
- package/dist/richtext/wrapMapSerializer.cjs.map +0 -1
- package/dist/richtext/wrapMapSerializer.d.ts +0 -15
- package/dist/richtext/wrapMapSerializer.js +0 -24
- package/dist/richtext/wrapMapSerializer.js.map +0 -1
- package/dist/richtext.cjs +0 -15
- package/dist/richtext.cjs.map +0 -1
- package/dist/richtext.js +0 -15
- package/dist/richtext.js.map +0 -1
- package/dist/types/api/asset/asset.d.ts +0 -177
- package/dist/types/api/asset/tag.d.ts +0 -53
- package/dist/types/api/integration.d.ts +0 -28
- package/dist/types/api/migration/document.d.ts +0 -60
- package/dist/types/api/query.d.ts +0 -43
- package/dist/types/api/ref.d.ts +0 -32
- package/dist/types/api/release.d.ts +0 -11
- package/dist/types/api/repository.d.ts +0 -109
- package/dist/types/api/tags.d.ts +0 -9
- package/dist/types/migration/Asset.cjs +0 -33
- package/dist/types/migration/Asset.cjs.map +0 -1
- package/dist/types/migration/Asset.d.ts +0 -108
- package/dist/types/migration/Asset.js +0 -33
- package/dist/types/migration/Asset.js.map +0 -1
- package/dist/types/migration/ContentRelationship.d.ts +0 -16
- package/dist/types/migration/Document.cjs +0 -47
- package/dist/types/migration/Document.cjs.map +0 -1
- package/dist/types/migration/Document.d.ts +0 -94
- package/dist/types/migration/Document.js +0 -47
- package/dist/types/migration/Document.js.map +0 -1
- package/dist/types/migration/Link.d.ts +0 -19
- package/dist/types/model/boolean.d.ts +0 -15
- package/dist/types/model/color.d.ts +0 -13
- package/dist/types/model/contentRelationship.d.ts +0 -52
- package/dist/types/model/customType.d.ts +0 -48
- package/dist/types/model/date.d.ts +0 -14
- package/dist/types/model/embed.d.ts +0 -13
- package/dist/types/model/geoPoint.d.ts +0 -12
- package/dist/types/model/group.d.ts +0 -23
- package/dist/types/model/image.d.ts +0 -31
- package/dist/types/model/integration.d.ts +0 -14
- package/dist/types/model/keyText.d.ts +0 -13
- package/dist/types/model/link.cjs +0 -9
- package/dist/types/model/link.cjs.map +0 -1
- package/dist/types/model/link.d.ts +0 -28
- package/dist/types/model/link.js +0 -9
- package/dist/types/model/link.js.map +0 -1
- package/dist/types/model/linkToMedia.d.ts +0 -17
- package/dist/types/model/number.d.ts +0 -15
- package/dist/types/model/range.d.ts +0 -14
- package/dist/types/model/richText.d.ts +0 -37
- package/dist/types/model/select.d.ts +0 -18
- package/dist/types/model/separator.d.ts +0 -10
- package/dist/types/model/sharedSlice.d.ts +0 -16
- package/dist/types/model/sharedSliceVariation.d.ts +0 -19
- package/dist/types/model/slice.cjs +0 -8
- package/dist/types/model/slice.cjs.map +0 -1
- package/dist/types/model/slice.d.ts +0 -33
- package/dist/types/model/slice.js +0 -8
- package/dist/types/model/slice.js.map +0 -1
- package/dist/types/model/sliceZone.cjs +0 -8
- package/dist/types/model/sliceZone.cjs.map +0 -1
- package/dist/types/model/sliceZone.d.ts +0 -41
- package/dist/types/model/sliceZone.js +0 -8
- package/dist/types/model/sliceZone.js.map +0 -1
- package/dist/types/model/table.d.ts +0 -12
- package/dist/types/model/timestamp.d.ts +0 -14
- package/dist/types/model/title.d.ts +0 -7
- package/dist/types/model/types.cjs +0 -39
- package/dist/types/model/types.cjs.map +0 -1
- package/dist/types/model/types.d.ts +0 -77
- package/dist/types/model/types.js +0 -39
- package/dist/types/model/types.js.map +0 -1
- package/dist/types/model/uid.d.ts +0 -13
- package/dist/types/value/boolean.d.ts +0 -6
- package/dist/types/value/color.d.ts +0 -9
- package/dist/types/value/contentRelationship.d.ts +0 -31
- package/dist/types/value/date.d.ts +0 -9
- package/dist/types/value/document.d.ts +0 -114
- package/dist/types/value/embed.cjs +0 -10
- package/dist/types/value/embed.cjs.map +0 -1
- package/dist/types/value/embed.d.ts +0 -168
- package/dist/types/value/embed.js +0 -10
- package/dist/types/value/embed.js.map +0 -1
- package/dist/types/value/geoPoint.d.ts +0 -12
- package/dist/types/value/group.d.ts +0 -13
- package/dist/types/value/image.d.ts +0 -47
- package/dist/types/value/integration.d.ts +0 -16
- package/dist/types/value/keyText.d.ts +0 -9
- package/dist/types/value/link.cjs +0 -10
- package/dist/types/value/link.cjs.map +0 -1
- package/dist/types/value/link.d.ts +0 -68
- package/dist/types/value/link.js +0 -10
- package/dist/types/value/link.js.map +0 -1
- package/dist/types/value/linkToMedia.d.ts +0 -28
- package/dist/types/value/number.d.ts +0 -9
- package/dist/types/value/richText.cjs +0 -25
- package/dist/types/value/richText.cjs.map +0 -1
- package/dist/types/value/richText.d.ts +0 -215
- package/dist/types/value/richText.js +0 -25
- package/dist/types/value/richText.js.map +0 -1
- package/dist/types/value/select.d.ts +0 -10
- package/dist/types/value/sharedSlice.d.ts +0 -11
- package/dist/types/value/sharedSliceVariation.d.ts +0 -10
- package/dist/types/value/slice.d.ts +0 -13
- package/dist/types/value/sliceZone.d.ts +0 -12
- package/dist/types/value/table.d.ts +0 -91
- package/dist/types/value/timestamp.d.ts +0 -8
- package/dist/types/value/title.d.ts +0 -12
- package/dist/types/value/types.d.ts +0 -58
- package/dist/types/webhook/apiUpdate.d.ts +0 -52
- package/dist/types/webhook/testTrigger.d.ts +0 -9
- package/dist/types/webhook/types.cjs +0 -8
- package/dist/types/webhook/types.cjs.map +0 -1
- package/dist/types/webhook/types.d.ts +0 -18
- package/dist/types/webhook/types.js +0 -8
- package/dist/types/webhook/types.js.map +0 -1
package/dist/richtext/asTree.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { RichTextNodeType } from "../types/value/richText.js";
|
|
2
|
-
const uuid = () => {
|
|
3
|
-
return (++uuid.i).toString();
|
|
4
|
-
};
|
|
5
|
-
uuid.i = 0;
|
|
6
|
-
const asTree = (nodes) => {
|
|
7
|
-
const preparedNodes = prepareNodes(nodes);
|
|
8
|
-
const children = [];
|
|
9
|
-
for (let i = 0; i < preparedNodes.length; i++) {
|
|
10
|
-
children.push(nodeToTreeNode(preparedNodes[i]));
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
key: uuid(),
|
|
14
|
-
children
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const createTreeNode = (node, children = []) => {
|
|
18
|
-
return {
|
|
19
|
-
key: uuid(),
|
|
20
|
-
type: node.type,
|
|
21
|
-
text: "text" in node ? node.text : void 0,
|
|
22
|
-
node,
|
|
23
|
-
children
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const createTextTreeNode = (text) => {
|
|
27
|
-
return createTreeNode({
|
|
28
|
-
type: RichTextNodeType.span,
|
|
29
|
-
text,
|
|
30
|
-
spans: []
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
const prepareNodes = (nodes) => {
|
|
34
|
-
const mutNodes = nodes.slice(0);
|
|
35
|
-
for (let i = 0; i < mutNodes.length; i++) {
|
|
36
|
-
const node = mutNodes[i];
|
|
37
|
-
if (node.type === RichTextNodeType.listItem || node.type === RichTextNodeType.oListItem) {
|
|
38
|
-
const items = [
|
|
39
|
-
node
|
|
40
|
-
];
|
|
41
|
-
while (mutNodes[i + 1] && mutNodes[i + 1].type === node.type) {
|
|
42
|
-
items.push(mutNodes[i + 1]);
|
|
43
|
-
mutNodes.splice(i, 1);
|
|
44
|
-
}
|
|
45
|
-
if (node.type === RichTextNodeType.listItem) {
|
|
46
|
-
mutNodes[i] = {
|
|
47
|
-
type: RichTextNodeType.list,
|
|
48
|
-
items
|
|
49
|
-
};
|
|
50
|
-
} else {
|
|
51
|
-
mutNodes[i] = {
|
|
52
|
-
type: RichTextNodeType.oList,
|
|
53
|
-
items
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return mutNodes;
|
|
59
|
-
};
|
|
60
|
-
const nodeToTreeNode = (node) => {
|
|
61
|
-
if ("text" in node) {
|
|
62
|
-
return createTreeNode(node, textNodeSpansToTreeNodeChildren(node.spans, node));
|
|
63
|
-
}
|
|
64
|
-
if ("items" in node) {
|
|
65
|
-
const children = [];
|
|
66
|
-
for (let i = 0; i < node.items.length; i++) {
|
|
67
|
-
children.push(nodeToTreeNode(node.items[i]));
|
|
68
|
-
}
|
|
69
|
-
return createTreeNode(node, children);
|
|
70
|
-
}
|
|
71
|
-
return createTreeNode(node);
|
|
72
|
-
};
|
|
73
|
-
const textNodeSpansToTreeNodeChildren = (spans, node, parentSpan) => {
|
|
74
|
-
if (!spans.length) {
|
|
75
|
-
return [createTextTreeNode(node.text)];
|
|
76
|
-
}
|
|
77
|
-
const mutSpans = spans.slice(0);
|
|
78
|
-
mutSpans.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
79
|
-
const children = [];
|
|
80
|
-
for (let i = 0; i < mutSpans.length; i++) {
|
|
81
|
-
const span = mutSpans[i];
|
|
82
|
-
const parentSpanStart = parentSpan && parentSpan.start || 0;
|
|
83
|
-
const spanStart = span.start - parentSpanStart;
|
|
84
|
-
const spanEnd = span.end - parentSpanStart;
|
|
85
|
-
const text = node.text.slice(spanStart, spanEnd);
|
|
86
|
-
const childSpans = [];
|
|
87
|
-
for (let j = i; j < mutSpans.length; j++) {
|
|
88
|
-
const siblingSpan = mutSpans[j];
|
|
89
|
-
if (siblingSpan !== span) {
|
|
90
|
-
if (siblingSpan.start >= span.start && siblingSpan.end <= span.end) {
|
|
91
|
-
childSpans.push(siblingSpan);
|
|
92
|
-
mutSpans.splice(j, 1);
|
|
93
|
-
j--;
|
|
94
|
-
} else if (siblingSpan.start < span.end && siblingSpan.end > span.start) {
|
|
95
|
-
childSpans.push({
|
|
96
|
-
...siblingSpan,
|
|
97
|
-
end: span.end
|
|
98
|
-
});
|
|
99
|
-
mutSpans[j] = {
|
|
100
|
-
...siblingSpan,
|
|
101
|
-
start: span.end
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (i === 0 && spanStart > 0) {
|
|
107
|
-
children.push(createTextTreeNode(node.text.slice(0, spanStart)));
|
|
108
|
-
}
|
|
109
|
-
const spanWithText = { ...span, text };
|
|
110
|
-
children.push(createTreeNode(spanWithText, textNodeSpansToTreeNodeChildren(childSpans, {
|
|
111
|
-
...node,
|
|
112
|
-
text
|
|
113
|
-
}, span)));
|
|
114
|
-
if (spanEnd < node.text.length) {
|
|
115
|
-
children.push(createTextTreeNode(node.text.slice(spanEnd, mutSpans[i + 1] ? mutSpans[i + 1].start - parentSpanStart : void 0)));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return children;
|
|
119
|
-
};
|
|
120
|
-
export {
|
|
121
|
-
asTree
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=asTree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asTree.js","sources":["../../../src/richtext/asTree.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTListItemNode,\n\tRTNode,\n\tRTOListItemNode,\n\tRTTextNode,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { Tree, TreeNode } from \"./types\"\n\nconst uuid = (): string => {\n\treturn (++uuid.i).toString()\n}\nuuid.i = 0\n\n/**\n * Parses a rich text or title field into a tree\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages. Most users aren't expected to this function directly.\n *\n * @param nodes - A rich text or title field from Prismic\n *\n * @returns Tree from given rich text or title field\n */\nexport const asTree = (nodes: RTNode[]): Tree => {\n\tconst preparedNodes = prepareNodes(nodes)\n\n\tconst children: TreeNode[] = []\n\tfor (let i = 0; i < preparedNodes.length; i++) {\n\t\tchildren.push(nodeToTreeNode(preparedNodes[i]))\n\t}\n\n\treturn {\n\t\tkey: uuid(),\n\t\tchildren,\n\t}\n}\n\nconst createTreeNode = (\n\tnode: RTAnyNode,\n\tchildren: TreeNode[] = [],\n): TreeNode => {\n\treturn {\n\t\tkey: uuid(),\n\t\ttype: node.type,\n\t\ttext: \"text\" in node ? node.text : undefined,\n\t\tnode,\n\t\tchildren,\n\t}\n}\n\nconst createTextTreeNode = (text: string): TreeNode => {\n\treturn createTreeNode({\n\t\ttype: RichTextNodeType.span,\n\t\ttext,\n\t\tspans: [],\n\t})\n}\n\nconst prepareNodes = (nodes: RTNode[]): RTBlockNode[] => {\n\tconst mutNodes: RTBlockNode[] = nodes.slice(0)\n\n\tfor (let i = 0; i < mutNodes.length; i++) {\n\t\tconst node = mutNodes[i]\n\n\t\tif (\n\t\t\tnode.type === RichTextNodeType.listItem ||\n\t\t\tnode.type === RichTextNodeType.oListItem\n\t\t) {\n\t\t\tconst items: (RTListItemNode | RTOListItemNode)[] = [\n\t\t\t\tnode as RTListItemNode | RTOListItemNode,\n\t\t\t]\n\n\t\t\twhile (mutNodes[i + 1] && mutNodes[i + 1].type === node.type) {\n\t\t\t\titems.push(mutNodes[i + 1] as RTListItemNode | RTOListItemNode)\n\t\t\t\tmutNodes.splice(i, 1)\n\t\t\t}\n\n\t\t\tif (node.type === RichTextNodeType.listItem) {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.list,\n\t\t\t\t\titems: items as RTListItemNode[],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmutNodes[i] = {\n\t\t\t\t\ttype: RichTextNodeType.oList,\n\t\t\t\t\titems: items as RTOListItemNode[],\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mutNodes\n}\n\nconst nodeToTreeNode = (node: RTBlockNode): TreeNode => {\n\tif (\"text\" in node) {\n\t\treturn createTreeNode(\n\t\t\tnode,\n\t\t\ttextNodeSpansToTreeNodeChildren(node.spans, node),\n\t\t)\n\t}\n\n\tif (\"items\" in node) {\n\t\tconst children: TreeNode[] = []\n\t\tfor (let i = 0; i < node.items.length; i++) {\n\t\t\tchildren.push(nodeToTreeNode(node.items[i]))\n\t\t}\n\n\t\treturn createTreeNode(node, children)\n\t}\n\n\treturn createTreeNode(node)\n}\n\nconst textNodeSpansToTreeNodeChildren = (\n\tspans: RTInlineNode[],\n\tnode: RTTextNode,\n\tparentSpan?: RTInlineNode,\n): TreeNode[] => {\n\tif (!spans.length) {\n\t\treturn [createTextTreeNode(node.text)]\n\t}\n\n\tconst mutSpans: RTInlineNode[] = spans.slice(0)\n\n\t// Sort spans using the following criteria:\n\t//\n\t// 1. By start index (ascending)\n\t// 2. If start indices are equal, by end index (descending)\n\t//\n\t// If start and end indices of more than one span are equal, use what\n\t// the API gives without modifications.\n\t//\n\t// Sorting using this algorithm ensures proper detection of child\n\t// spans.\n\tmutSpans.sort((a, b) => a.start - b.start || b.end - a.end)\n\n\tconst children: TreeNode[] = []\n\n\tfor (let i = 0; i < mutSpans.length; i++) {\n\t\tconst span = mutSpans[i]\n\t\tconst parentSpanStart = (parentSpan && parentSpan.start) || 0\n\t\tconst spanStart = span.start - parentSpanStart\n\t\tconst spanEnd = span.end - parentSpanStart\n\t\tconst text = node.text.slice(spanStart, spanEnd)\n\n\t\tconst childSpans: RTInlineNode[] = []\n\t\tfor (let j = i; j < mutSpans.length; j++) {\n\t\t\tconst siblingSpan = mutSpans[j]\n\n\t\t\tif (siblingSpan !== span) {\n\t\t\t\tif (siblingSpan.start >= span.start && siblingSpan.end <= span.end) {\n\t\t\t\t\tchildSpans.push(siblingSpan)\n\t\t\t\t\tmutSpans.splice(j, 1)\n\t\t\t\t\tj--\n\t\t\t\t} else if (\n\t\t\t\t\tsiblingSpan.start < span.end &&\n\t\t\t\t\tsiblingSpan.end > span.start\n\t\t\t\t) {\n\t\t\t\t\tchildSpans.push({\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tend: span.end,\n\t\t\t\t\t})\n\t\t\t\t\tmutSpans[j] = {\n\t\t\t\t\t\t...siblingSpan,\n\t\t\t\t\t\tstart: span.end,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (i === 0 && spanStart > 0) {\n\t\t\tchildren.push(createTextTreeNode(node.text.slice(0, spanStart)))\n\t\t}\n\n\t\tconst spanWithText = { ...span, text }\n\t\tchildren.push(\n\t\t\tcreateTreeNode(\n\t\t\t\tspanWithText,\n\t\t\t\ttextNodeSpansToTreeNodeChildren(\n\t\t\t\t\tchildSpans,\n\t\t\t\t\t{\n\t\t\t\t\t\t...node,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t},\n\t\t\t\t\tspan,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\n\t\tif (spanEnd < node.text.length) {\n\t\t\tchildren.push(\n\t\t\t\tcreateTextTreeNode(\n\t\t\t\t\tnode.text.slice(\n\t\t\t\t\t\tspanEnd,\n\t\t\t\t\t\tmutSpans[i + 1]\n\t\t\t\t\t\t\t? mutSpans[i + 1].start - parentSpanStart\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn children\n}\n"],"names":[],"mappings":";AAYA,MAAM,OAAO,MAAa;AACjB,UAAA,EAAE,KAAK,GAAG,SAAQ;AAC3B;AACA,KAAK,IAAI;AAaI,MAAA,SAAS,CAAC,UAAyB;AACzC,QAAA,gBAAgB,aAAa,KAAK;AAExC,QAAM,WAAuB,CAAA;AAC7B,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C,aAAS,KAAK,eAAe,cAAc,CAAC,CAAC,CAAC;AAAA,EAAA;AAGxC,SAAA;AAAA,IACN,KAAK,KAAM;AAAA,IACX;AAAA;AAEF;AAEA,MAAM,iBAAiB,CACtB,MACA,WAAuB,OACV;AACN,SAAA;AAAA,IACN,KAAK,KAAM;AAAA,IACX,MAAM,KAAK;AAAA,IACX,MAAM,UAAU,OAAO,KAAK,OAAO;AAAA,IACnC;AAAA,IACA;AAAA;AAEF;AAEA,MAAM,qBAAqB,CAAC,SAA0B;AACrD,SAAO,eAAe;AAAA,IACrB,MAAM,iBAAiB;AAAA,IACvB;AAAA,IACA,OAAO,CAAA;AAAA,EAAE,CACT;AACF;AAEA,MAAM,eAAe,CAAC,UAAkC;AACjD,QAAA,WAA0B,MAAM,MAAM,CAAC;AAE7C,WAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACnC,UAAA,OAAO,SAAS,CAAC;AAEvB,QACC,KAAK,SAAS,iBAAiB,YAC/B,KAAK,SAAS,iBAAiB,WAC9B;AACD,YAAM,QAA8C;AAAA,QACnD;AAAA;AAGM,aAAA,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM;AAC7D,cAAM,KAAK,SAAS,IAAI,CAAC,CAAqC;AACrD,iBAAA,OAAO,GAAG,CAAC;AAAA,MAAA;AAGjB,UAAA,KAAK,SAAS,iBAAiB,UAAU;AAC5C,iBAAS,CAAC,IAAI;AAAA,UACb,MAAM,iBAAiB;AAAA,UACvB;AAAA;aAEK;AACN,iBAAS,CAAC,IAAI;AAAA,UACb,MAAM,iBAAiB;AAAA,UACvB;AAAA;;IAEF;AAAA,EACD;AAGM,SAAA;AACR;AAEA,MAAM,iBAAiB,CAAC,SAA+B;AACtD,MAAI,UAAU,MAAM;AACnB,WAAO,eACN,MACA,gCAAgC,KAAK,OAAO,IAAI,CAAC;AAAA,EAAA;AAInD,MAAI,WAAW,MAAM;AACpB,UAAM,WAAuB,CAAA;AAC7B,aAAS,IAAI,GAAG,IAAI,KAAK,MAAM,QAAQ,KAAK;AAC3C,eAAS,KAAK,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC;AAAA,IAAA;AAGrC,WAAA,eAAe,MAAM,QAAQ;AAAA,EAAA;AAGrC,SAAO,eAAe,IAAI;AAC3B;AAEA,MAAM,kCAAkC,CACvC,OACA,MACA,eACe;AACX,MAAA,CAAC,MAAM,QAAQ;AAClB,WAAO,CAAC,mBAAmB,KAAK,IAAI,CAAC;AAAA,EAAA;AAGhC,QAAA,WAA2B,MAAM,MAAM,CAAC;AAYrC,WAAA,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG;AAE1D,QAAM,WAAuB,CAAA;AAE7B,WAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACnC,UAAA,OAAO,SAAS,CAAC;AACjB,UAAA,kBAAmB,cAAc,WAAW,SAAU;AACtD,UAAA,YAAY,KAAK,QAAQ;AACzB,UAAA,UAAU,KAAK,MAAM;AAC3B,UAAM,OAAO,KAAK,KAAK,MAAM,WAAW,OAAO;AAE/C,UAAM,aAA6B,CAAA;AACnC,aAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACnC,YAAA,cAAc,SAAS,CAAC;AAE9B,UAAI,gBAAgB,MAAM;AACzB,YAAI,YAAY,SAAS,KAAK,SAAS,YAAY,OAAO,KAAK,KAAK;AACnE,qBAAW,KAAK,WAAW;AAClB,mBAAA,OAAO,GAAG,CAAC;AACpB;AAAA,QAAA,WAEA,YAAY,QAAQ,KAAK,OACzB,YAAY,MAAM,KAAK,OACtB;AACD,qBAAW,KAAK;AAAA,YACf,GAAG;AAAA,YACH,KAAK,KAAK;AAAA,UAAA,CACV;AACD,mBAAS,CAAC,IAAI;AAAA,YACb,GAAG;AAAA,YACH,OAAO,KAAK;AAAA;;MAEd;AAAA,IACD;AAGG,QAAA,MAAM,KAAK,YAAY,GAAG;AACpB,eAAA,KAAK,mBAAmB,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AAAA,IAAA;AAGhE,UAAM,eAAe,EAAE,GAAG,MAAM;AAChC,aAAS,KACR,eACC,cACA,gCACC,YACA;AAAA,MACC,GAAG;AAAA,MACH;AAAA,IAAA,GAED,IAAI,CACJ,CACD;AAGE,QAAA,UAAU,KAAK,KAAK,QAAQ;AAC/B,eAAS,KACR,mBACC,KAAK,KAAK,MACT,SACA,SAAS,IAAI,CAAC,IACX,SAAS,IAAI,CAAC,EAAE,QAAQ,kBACxB,MAAS,CACZ,CACD;AAAA,IAAA;AAAA,EAEH;AAGM,SAAA;AACR;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const composeSerializers = (...serializers) => {
|
|
4
|
-
return (...args) => {
|
|
5
|
-
for (let i = 0; i < serializers.length; i++) {
|
|
6
|
-
const serializer = serializers[i];
|
|
7
|
-
if (serializer) {
|
|
8
|
-
const res = serializer(...args);
|
|
9
|
-
if (res != null) {
|
|
10
|
-
return res;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
exports.composeSerializers = composeSerializers;
|
|
17
|
-
//# sourceMappingURL=composeSerializers.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composeSerializers.cjs","sources":["../../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAgBa,MAAA,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AACtC,YAAA,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACT,cAAA,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AACT,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IACD;AAAA,EAEF;AACD;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { RichTextFunctionSerializer } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Takes an array of serializers and returns a serializer applying provided
|
|
4
|
-
* serializers sequentially until a result is returned
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* This is a low level helper mainly intended to be used by higher level
|
|
8
|
-
* packages Most users aren't expected to this function directly
|
|
9
|
-
*
|
|
10
|
-
* @typeParam SerializerReturnType - Return type of serializers
|
|
11
|
-
*
|
|
12
|
-
* @param serializers - Serializers to compose
|
|
13
|
-
*
|
|
14
|
-
* @returns Composed serializer
|
|
15
|
-
*/
|
|
16
|
-
export declare const composeSerializers: <SerializerReturnType>(...serializers: (RichTextFunctionSerializer<SerializerReturnType> | undefined)[]) => RichTextFunctionSerializer<SerializerReturnType>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const composeSerializers = (...serializers) => {
|
|
2
|
-
return (...args) => {
|
|
3
|
-
for (let i = 0; i < serializers.length; i++) {
|
|
4
|
-
const serializer = serializers[i];
|
|
5
|
-
if (serializer) {
|
|
6
|
-
const res = serializer(...args);
|
|
7
|
-
if (res != null) {
|
|
8
|
-
return res;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
composeSerializers
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=composeSerializers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composeSerializers.js","sources":["../../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAgBa,MAAA,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AACtC,YAAA,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACT,cAAA,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AACT,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IACD;AAAA,EAEF;AACD;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const asTree = require("./asTree.cjs");
|
|
4
|
-
const serialize = (richTextField, serializer) => {
|
|
5
|
-
return serializeTreeNodes(asTree.asTree(richTextField).children, serializer);
|
|
6
|
-
};
|
|
7
|
-
const serializeTreeNodes = (nodes, serializer) => {
|
|
8
|
-
const serializedTreeNodes = [];
|
|
9
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
10
|
-
const treeNode = nodes[i];
|
|
11
|
-
const serializedTreeNode = serializer(treeNode.type, treeNode.node, treeNode.text, serializeTreeNodes(treeNode.children, serializer), treeNode.key);
|
|
12
|
-
if (serializedTreeNode != null) {
|
|
13
|
-
serializedTreeNodes.push(serializedTreeNode);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return serializedTreeNodes;
|
|
17
|
-
};
|
|
18
|
-
exports.serialize = serialize;
|
|
19
|
-
//# sourceMappingURL=serialize.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.cjs","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text or title field with a given serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the serializer\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param serializer - A function serializer to apply\n *\n * @returns An array of serialized nodes\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":["asTree"],"mappings":";;;AAqBa,MAAA,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACNA,OAAA,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAChC,UAAA,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAAA;AAAA,EAC5C;AAGM,SAAA;AACR;;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { RichTextField } from "../types/value/richText";
|
|
2
|
-
import type { RichTextFunctionSerializer } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Serializes a rich text or title field with a given serializer
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* This is a low level helper mainly intended to be used by higher level
|
|
8
|
-
* packages Most users aren't expected to this function directly
|
|
9
|
-
*
|
|
10
|
-
* @typeParam SerializerReturnType - Return type of the serializer
|
|
11
|
-
*
|
|
12
|
-
* @param richTextField - A rich text or title field from Prismic
|
|
13
|
-
* @param serializer - A function serializer to apply
|
|
14
|
-
*
|
|
15
|
-
* @returns An array of serialized nodes
|
|
16
|
-
*
|
|
17
|
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
18
|
-
*/
|
|
19
|
-
export declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { asTree } from "./asTree.js";
|
|
2
|
-
const serialize = (richTextField, serializer) => {
|
|
3
|
-
return serializeTreeNodes(asTree(richTextField).children, serializer);
|
|
4
|
-
};
|
|
5
|
-
const serializeTreeNodes = (nodes, serializer) => {
|
|
6
|
-
const serializedTreeNodes = [];
|
|
7
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
8
|
-
const treeNode = nodes[i];
|
|
9
|
-
const serializedTreeNode = serializer(treeNode.type, treeNode.node, treeNode.text, serializeTreeNodes(treeNode.children, serializer), treeNode.key);
|
|
10
|
-
if (serializedTreeNode != null) {
|
|
11
|
-
serializedTreeNodes.push(serializedTreeNode);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return serializedTreeNodes;
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
serialize
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text or title field with a given serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the serializer\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param serializer - A function serializer to apply\n *\n * @returns An array of serialized nodes\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":[],"mappings":";AAqBa,MAAA,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACN,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAChC,UAAA,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAAA;AAAA,EAC5C;AAGM,SAAA;AACR;"}
|
package/dist/richtext/types.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const richText = require("../types/value/richText.cjs");
|
|
4
|
-
const RichTextReversedNodeType = {
|
|
5
|
-
[richText.RichTextNodeType.listItem]: "listItem",
|
|
6
|
-
[richText.RichTextNodeType.oListItem]: "oListItem",
|
|
7
|
-
[richText.RichTextNodeType.list]: "list",
|
|
8
|
-
[richText.RichTextNodeType.oList]: "oList"
|
|
9
|
-
};
|
|
10
|
-
exports.RichTextReversedNodeType = RichTextReversedNodeType;
|
|
11
|
-
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text or title field with a map\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}\n *\n * @typeParam ReturnType - Return type of the map serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":["RichTextNodeType"],"mappings":";;;AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAACA,SAAAA,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAACA,SAAAA,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAACA,SAAAA,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAACA,SAAAA,iBAAiB,KAAK,GAAG;;;"}
|
package/dist/richtext/types.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText";
|
|
2
|
-
/**
|
|
3
|
-
* Serializes a node from a rich text or title field with a function
|
|
4
|
-
*
|
|
5
|
-
* @typeParam ReturnType - Return type of the function serializer
|
|
6
|
-
*
|
|
7
|
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
8
|
-
*/
|
|
9
|
-
export type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Map serializer's tag function serializer, can be helpful for typing those
|
|
12
|
-
* handlers
|
|
13
|
-
*
|
|
14
|
-
* @typeParam ReturnType - Return type of the tag serializer
|
|
15
|
-
*/
|
|
16
|
-
export type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = RTAnyNode, TextType = string | undefined> = (payload: {
|
|
17
|
-
type: Node["type"];
|
|
18
|
-
node: Node;
|
|
19
|
-
text: TextType;
|
|
20
|
-
children: ReturnType[];
|
|
21
|
-
key: string;
|
|
22
|
-
}) => ReturnType | null | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Serializes a node from a rich text or title field with a map
|
|
25
|
-
*
|
|
26
|
-
* @remarks
|
|
27
|
-
* This type of serializer needs to be processed through
|
|
28
|
-
* {@link wrapMapSerializer} before being used with {@link serialize}
|
|
29
|
-
*
|
|
30
|
-
* @typeParam ReturnType - Return type of the map serializer
|
|
31
|
-
*
|
|
32
|
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
33
|
-
*/
|
|
34
|
-
export type RichTextMapSerializer<ReturnType> = {
|
|
35
|
-
heading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>;
|
|
36
|
-
heading2?: RichTextMapSerializerFunction<ReturnType, RTHeading2Node, undefined>;
|
|
37
|
-
heading3?: RichTextMapSerializerFunction<ReturnType, RTHeading3Node, undefined>;
|
|
38
|
-
heading4?: RichTextMapSerializerFunction<ReturnType, RTHeading4Node, undefined>;
|
|
39
|
-
heading5?: RichTextMapSerializerFunction<ReturnType, RTHeading5Node, undefined>;
|
|
40
|
-
heading6?: RichTextMapSerializerFunction<ReturnType, RTHeading6Node, undefined>;
|
|
41
|
-
paragraph?: RichTextMapSerializerFunction<ReturnType, RTParagraphNode, undefined>;
|
|
42
|
-
preformatted?: RichTextMapSerializerFunction<ReturnType, RTPreformattedNode, undefined>;
|
|
43
|
-
strong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>;
|
|
44
|
-
em?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>;
|
|
45
|
-
listItem?: RichTextMapSerializerFunction<ReturnType, RTListItemNode, undefined>;
|
|
46
|
-
oListItem?: RichTextMapSerializerFunction<ReturnType, RTOListItemNode, undefined>;
|
|
47
|
-
list?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>;
|
|
48
|
-
oList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>;
|
|
49
|
-
image?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>;
|
|
50
|
-
embed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>;
|
|
51
|
-
hyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>;
|
|
52
|
-
label?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>;
|
|
53
|
-
span?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>;
|
|
54
|
-
};
|
|
55
|
-
export interface Tree {
|
|
56
|
-
key: string;
|
|
57
|
-
children: TreeNode[];
|
|
58
|
-
}
|
|
59
|
-
export interface TreeNode {
|
|
60
|
-
key: string;
|
|
61
|
-
type: RichTextNodeTypes;
|
|
62
|
-
text?: string;
|
|
63
|
-
node: RTAnyNode;
|
|
64
|
-
children: TreeNode[];
|
|
65
|
-
}
|
|
66
|
-
export declare const RichTextReversedNodeType: {
|
|
67
|
-
readonly "list-item": "listItem";
|
|
68
|
-
readonly "o-list-item": "oListItem";
|
|
69
|
-
readonly "group-list-item": "list";
|
|
70
|
-
readonly "group-o-list-item": "oList";
|
|
71
|
-
};
|
package/dist/richtext/types.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RichTextNodeType } from "../types/value/richText.js";
|
|
2
|
-
const RichTextReversedNodeType = {
|
|
3
|
-
[RichTextNodeType.listItem]: "listItem",
|
|
4
|
-
[RichTextNodeType.oListItem]: "oListItem",
|
|
5
|
-
[RichTextNodeType.list]: "list",
|
|
6
|
-
[RichTextNodeType.oList]: "oList"
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
RichTextReversedNodeType
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text or title field with a map\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}\n *\n * @typeParam ReturnType - Return type of the map serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":[],"mappings":";AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAAC,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAAC,iBAAiB,KAAK,GAAG;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const types = require("./types.cjs");
|
|
4
|
-
const wrapMapSerializer = (mapSerializer) => {
|
|
5
|
-
return (type, node, text, children, key) => {
|
|
6
|
-
const tagSerializer = mapSerializer[types.RichTextReversedNodeType[type] || type];
|
|
7
|
-
if (tagSerializer) {
|
|
8
|
-
return tagSerializer({
|
|
9
|
-
// @ts-expect-error cannot type check here
|
|
10
|
-
type,
|
|
11
|
-
// @ts-expect-error cannot type check here
|
|
12
|
-
node,
|
|
13
|
-
// @ts-expect-error cannot type check here
|
|
14
|
-
text,
|
|
15
|
-
// @ts-expect-error cannot type check here
|
|
16
|
-
children,
|
|
17
|
-
// @ts-expect-error cannot type check here
|
|
18
|
-
key
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
exports.wrapMapSerializer = wrapMapSerializer;
|
|
24
|
-
//# sourceMappingURL=wrapMapSerializer.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapMapSerializer.cjs","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["RichTextReversedNodeType"],"mappings":";;;AAgBa,MAAA,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACEA,MACA,yBAAA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,EAEH;AACD;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { RichTextFunctionSerializer, RichTextMapSerializer } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Wraps a map serializer into a regular function serializer
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* This is a low level helper mainly intended to be used by higher level
|
|
7
|
-
* packages Most users aren't expected to this function directly
|
|
8
|
-
*
|
|
9
|
-
* @typeParam SerializerReturnType - Return type of the map serializer
|
|
10
|
-
*
|
|
11
|
-
* @param mapSerializer - Map serializer to wrap
|
|
12
|
-
*
|
|
13
|
-
* @returns A regular function serializer
|
|
14
|
-
*/
|
|
15
|
-
export declare const wrapMapSerializer: <SerializerReturnType>(mapSerializer: RichTextMapSerializer<SerializerReturnType>) => RichTextFunctionSerializer<SerializerReturnType>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { RichTextReversedNodeType } from "./types.js";
|
|
2
|
-
const wrapMapSerializer = (mapSerializer) => {
|
|
3
|
-
return (type, node, text, children, key) => {
|
|
4
|
-
const tagSerializer = mapSerializer[RichTextReversedNodeType[type] || type];
|
|
5
|
-
if (tagSerializer) {
|
|
6
|
-
return tagSerializer({
|
|
7
|
-
// @ts-expect-error cannot type check here
|
|
8
|
-
type,
|
|
9
|
-
// @ts-expect-error cannot type check here
|
|
10
|
-
node,
|
|
11
|
-
// @ts-expect-error cannot type check here
|
|
12
|
-
text,
|
|
13
|
-
// @ts-expect-error cannot type check here
|
|
14
|
-
children,
|
|
15
|
-
// @ts-expect-error cannot type check here
|
|
16
|
-
key
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
wrapMapSerializer
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=wrapMapSerializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapMapSerializer.js","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAgBa,MAAA,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACE,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,EAEH;AACD;"}
|
package/dist/richtext.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const asTree = require("./richtext/asTree.cjs");
|
|
4
|
-
const asText = require("./richtext/asText.cjs");
|
|
5
|
-
const serialize = require("./richtext/serialize.cjs");
|
|
6
|
-
const wrapMapSerializer = require("./richtext/wrapMapSerializer.cjs");
|
|
7
|
-
const composeSerializers = require("./richtext/composeSerializers.cjs");
|
|
8
|
-
const richText = require("./types/value/richText.cjs");
|
|
9
|
-
exports.asTree = asTree.asTree;
|
|
10
|
-
exports.asText = asText.asText;
|
|
11
|
-
exports.serialize = serialize.serialize;
|
|
12
|
-
exports.wrapMapSerializer = wrapMapSerializer.wrapMapSerializer;
|
|
13
|
-
exports.composeSerializers = composeSerializers.composeSerializers;
|
|
14
|
-
exports.Element = richText.RichTextNodeType;
|
|
15
|
-
//# sourceMappingURL=richtext.cjs.map
|
package/dist/richtext.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"richtext.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
package/dist/richtext.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { asTree } from "./richtext/asTree.js";
|
|
2
|
-
import { asText } from "./richtext/asText.js";
|
|
3
|
-
import { serialize } from "./richtext/serialize.js";
|
|
4
|
-
import { wrapMapSerializer } from "./richtext/wrapMapSerializer.js";
|
|
5
|
-
import { composeSerializers } from "./richtext/composeSerializers.js";
|
|
6
|
-
import { RichTextNodeType } from "./types/value/richText.js";
|
|
7
|
-
export {
|
|
8
|
-
RichTextNodeType as Element,
|
|
9
|
-
asText,
|
|
10
|
-
asTree,
|
|
11
|
-
composeSerializers,
|
|
12
|
-
serialize,
|
|
13
|
-
wrapMapSerializer
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=richtext.js.map
|
package/dist/richtext.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"richtext.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|