@prismicio/vue 3.2.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/PrismicEmbed.cjs.map +1 -1
- package/dist/components/PrismicEmbed.d.ts +1 -1
- package/dist/components/PrismicEmbed.js.map +1 -1
- package/dist/components/PrismicImage.cjs +5 -5
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +1 -2
- package/dist/components/PrismicImage.js +1 -1
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs +2 -2
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +1 -2
- package/dist/components/PrismicLink.js +1 -1
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.cjs +3 -3
- package/dist/components/PrismicRichText.cjs.map +1 -1
- package/dist/components/PrismicRichText.d.ts +7 -8
- package/dist/components/PrismicRichText.js +1 -1
- package/dist/components/PrismicRichText.js.map +1 -1
- package/dist/components/PrismicText.cjs +3 -3
- package/dist/components/PrismicText.cjs.map +1 -1
- package/dist/components/PrismicText.d.ts +1 -1
- package/dist/components/PrismicText.js +1 -1
- package/dist/components/PrismicText.js.map +1 -1
- package/dist/components/SliceZone.cjs.map +1 -1
- package/dist/components/SliceZone.d.ts +8 -7
- package/dist/components/SliceZone.js.map +1 -1
- package/dist/composables.cjs.map +1 -1
- package/dist/composables.d.ts +19 -1
- package/dist/composables.js.map +1 -1
- package/dist/createPrismic.cjs +32 -12
- package/dist/createPrismic.cjs.map +1 -1
- package/dist/createPrismic.js +27 -7
- package/dist/createPrismic.js.map +1 -1
- package/dist/types.d.ts +27 -18
- package/package.json +4 -6
- package/src/components/PrismicEmbed.ts +1 -2
- package/src/components/PrismicImage.ts +2 -2
- package/src/components/PrismicLink.ts +6 -2
- package/src/components/PrismicRichText.ts +2 -2
- package/src/components/PrismicText.ts +1 -2
- package/src/components/SliceZone.ts +8 -8
- package/src/composables.ts +1 -1
- package/src/createPrismic.ts +44 -12
- package/src/types.ts +35 -26
package/dist/composables.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composables.js","sources":["../../src/composables.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n// Imports for @link references:\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\nimport { PrismicDocument, Query } from \"@prismicio/types\";\n\nimport {\n\tClientComposableReturnType,\n\tClientMethodParameters,\n\tComposableOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n// Composables\n\n/**\n * A composable that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.get}\n */\nexport const usePrismicDocuments = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A composable that queries content from the Prismic repository and returns\n * only the first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getFirst}\n */\nexport const useFirstPrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"getFirst\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByID}\n */\nexport const usePrismicDocumentByID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByUID}\n */\nexport const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByUIDs\">[0],\n\t\tids: ClientMethodParameters<\"getAllByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getAllByUIDs\">[2] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A composable that queries a singleton document from the Prismic repository\n * for a specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getSingle}\n */\nexport const useSinglePrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A composable that queries documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByType}\n */\nexport const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTag}\n */\nexport const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with all of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with at least one of the queried\n * tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be\n * slower and require more resources than other composables. Prefer using other\n * composables that filter by predicates such as\n * `useAllPrismicDocumentsByType`.\n *\n * A composable that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAll}\n */\nexport const dangerouslyUseAllPrismicDocuments = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n"],"names":[],"mappings":";AA8BO,MAAM,sBAAsB,IAC/B,SAIH,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IACnC,SAIH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,yBAAyB,IAClC,SAKH,+BAA+B,WAAW,IAAI;AAkBxC,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IACnC,SAMH,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IACrC,SAMH,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IACxC,SAOH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IACrC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IACxC,SAMH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAkB5C,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAmBjD,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAuBjD,MAAM,oCAAoC,IAG7C,SAKH,+BAA+B,qBAAqB,IAAI;"}
|
|
1
|
+
{"version":3,"file":"composables.js","sources":["../../src/composables.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n// Imports for @link references:\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\nimport { PrismicDocument, Query } from \"@prismicio/client\";\n\nimport {\n\tClientComposableReturnType,\n\tClientMethodParameters,\n\tComposableOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n// Composables\n\n/**\n * A composable that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.get}\n */\nexport const usePrismicDocuments = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A composable that queries content from the Prismic repository and returns\n * only the first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getFirst}\n */\nexport const useFirstPrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"getFirst\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByID}\n */\nexport const usePrismicDocumentByID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByUID}\n */\nexport const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByUIDs\">[0],\n\t\tids: ClientMethodParameters<\"getAllByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getAllByUIDs\">[2] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A composable that queries a singleton document from the Prismic repository\n * for a specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getSingle}\n */\nexport const useSinglePrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A composable that queries documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByType}\n */\nexport const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTag}\n */\nexport const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with all of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with at least one of the queried\n * tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be\n * slower and require more resources than other composables. Prefer using other\n * composables that filter by predicates such as\n * `useAllPrismicDocumentsByType`.\n *\n * A composable that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAll}\n */\nexport const dangerouslyUseAllPrismicDocuments = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n"],"names":[],"mappings":";AA8BO,MAAM,sBAAsB,IAC/B,SAIH,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IACnC,SAIH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,yBAAyB,IAClC,SAKH,+BAA+B,WAAW,IAAI;AAkBxC,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IACnC,SAMH,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IACrC,SAMH,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IACxC,SAOH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IACrC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IACxC,SAMH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAkB5C,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAmBjD,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAuBjD,MAAM,oCAAoC,IAG7C,SAKH,+BAA+B,qBAAqB,IAAI;"}
|
package/dist/createPrismic.cjs
CHANGED
|
@@ -23,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
25
|
const client = require("@prismicio/client");
|
|
26
|
-
const helpers = require("@prismicio/helpers");
|
|
27
26
|
const injectionSymbols = require("./injectionSymbols.cjs");
|
|
28
27
|
const PrismicLink = require("./components/PrismicLink.cjs");
|
|
29
28
|
const PrismicEmbed = require("./components/PrismicEmbed.cjs");
|
|
@@ -51,22 +50,43 @@ const createPrismic = (options) => {
|
|
|
51
50
|
}
|
|
52
51
|
const prismicClient = {
|
|
53
52
|
client: client$1,
|
|
54
|
-
|
|
53
|
+
filter: client.filter,
|
|
55
54
|
cookie: client.cookie
|
|
56
55
|
};
|
|
57
56
|
const prismicHelpers = {
|
|
58
|
-
asText:
|
|
59
|
-
asHTML: (richTextField,
|
|
60
|
-
|
|
57
|
+
asText: client.asText,
|
|
58
|
+
asHTML: (richTextField, ...config) => {
|
|
59
|
+
const [configOrLinkResolver, maybeHTMLSerializer] = config;
|
|
60
|
+
return client.asHTML(richTextField, typeof configOrLinkResolver === "function" || configOrLinkResolver == null ? {
|
|
61
|
+
linkResolver: configOrLinkResolver || options.linkResolver,
|
|
62
|
+
serializer: maybeHTMLSerializer || options.richTextSerializer || options.htmlSerializer
|
|
63
|
+
} : {
|
|
64
|
+
linkResolver: options.linkResolver,
|
|
65
|
+
serializer: options.richTextSerializer || options.htmlSerializer,
|
|
66
|
+
...configOrLinkResolver
|
|
67
|
+
});
|
|
61
68
|
},
|
|
62
|
-
asLink: (linkField,
|
|
63
|
-
return
|
|
69
|
+
asLink: (linkField, config) => {
|
|
70
|
+
return client.asLink(linkField, typeof config === "function" ? { linkResolver: config } : {
|
|
71
|
+
linkResolver: options.linkResolver,
|
|
72
|
+
// TODO: For some reasons, TypeScript narrows the type to "unknown" where it's supposed to be a union
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
...config
|
|
75
|
+
});
|
|
64
76
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
asLinkAttrs: (linkField, config) => {
|
|
78
|
+
return client.asLinkAttrs(linkField, {
|
|
79
|
+
// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
linkResolver: options.linkResolver,
|
|
82
|
+
...config
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
asDate: client.asDate,
|
|
86
|
+
asImageSrc: client.asImageSrc,
|
|
87
|
+
asImageWidthSrcSet: client.asImageWidthSrcSet,
|
|
88
|
+
asImagePixelDensitySrcSet: client.asImagePixelDensitySrcSet,
|
|
89
|
+
documentToLinkField: client.documentToLinkField
|
|
70
90
|
};
|
|
71
91
|
const prismic = {
|
|
72
92
|
options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrismic.cjs","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\
|
|
1
|
+
{"version":3,"file":"createPrismic.cjs","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tLinkResolverFunction,\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasLinkAttrs,\n\tasText,\n\tcookie,\n\tcreateClient,\n\tdocumentToLinkField,\n\tfilter,\n} from \"@prismicio/client\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tfilter,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, ...config) => {\n\t\t\tconst [configOrLinkResolver, maybeHTMLSerializer] = config;\n\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\ttypeof configOrLinkResolver === \"function\" ||\n\t\t\t\t\tconfigOrLinkResolver == null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tlinkResolver: configOrLinkResolver || options.linkResolver,\n\t\t\t\t\t\t\tserializer:\n\t\t\t\t\t\t\t\tmaybeHTMLSerializer ||\n\t\t\t\t\t\t\t\toptions.richTextSerializer ||\n\t\t\t\t\t\t\t\toptions.htmlSerializer,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\tserializer: options.richTextSerializer || options.htmlSerializer,\n\t\t\t\t\t\t\t...configOrLinkResolver,\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, config) => {\n\t\t\treturn asLink(\n\t\t\t\tlinkField,\n\t\t\t\ttypeof config === \"function\"\n\t\t\t\t\t? { linkResolver: config }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\t// TODO: For some reasons, TypeScript narrows the type to \"unknown\" where it's supposed to be a union\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\t...(config as any),\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLinkAttrs: (linkField, config) => {\n\t\t\treturn asLinkAttrs(linkField, {\n\t\t\t\t// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tlinkResolver: options.linkResolver as LinkResolverFunction<any>,\n\t\t\t\t...config,\n\t\t\t});\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["client","createClient","options","filter","cookie","asText","asHTML","asLink","asLinkAttrs","asDate","asImageSrc","asImageWidthSrcSet","asImagePixelDensitySrcSet","documentToLinkField","prismicKey","PrismicLink","PrismicEmbed","PrismicImage","PrismicText","PrismicRichText","SliceZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAAA;AACJ,MAAI,QAAQ,QAAQ;AACnBA,eAAS,QAAQ;AAAA,EAAA,OACX;AACGA,eAAAC,OAAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUC,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,QACrD;AAEM,eAAA,MAAM,cAAc,UAAUA,QAAO;AAAA,MAC7C;AAAA,MACA,GAAG,QAAQ;AAAA,IAAA,CACX;AAAA,EACD;AAED,QAAM,gBAAqC;AAAA,IAAA,QAC1CF;AAAAA,IAAA,QACAG,OAAA;AAAA,IAAA,QACAC,OAAA;AAAA,EAAA;AAID,QAAM,iBAAuC;AAAA,IAAA,QAC5CC,OAAA;AAAA,IACA,QAAQ,CAAC,kBAAkB,WAAU;AAC9B,YAAA,CAAC,sBAAsB,mBAAmB,IAAI;AAEpD,aAAOC,OAAAA,OACN,eACA,OAAO,yBAAyB,cAC/B,wBAAwB,OACtB;AAAA,QACA,cAAc,wBAAwB,QAAQ;AAAA,QAC9C,YACC,uBACA,QAAQ,sBACR,QAAQ;AAAA,MAAA,IAET;AAAA,QACA,cAAc,QAAQ;AAAA,QACtB,YAAY,QAAQ,sBAAsB,QAAQ;AAAA,QAClD,GAAG;AAAA,MAAA,CACF;AAAA,IAEN;AAAA,IACA,QAAQ,CAAC,WAAW,WAAU;AACtB,aAAAC,OAAAA,OACN,WACA,OAAO,WAAW,aACf,EAAE,cAAc,WAChB;AAAA,QACA,cAAc,QAAQ;AAAA;AAAA;AAAA,QAGtB,GAAI;AAAA,MAAA,CACH;AAAA,IAEN;AAAA,IACA,aAAa,CAAC,WAAW,WAAU;AAClC,aAAOC,OAAAA,YAAY,WAAW;AAAA;AAAA;AAAA,QAG7B,cAAc,QAAQ;AAAA,QACtB,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,IAAA,QACAC,OAAA;AAAA,IAAA,YACAC,OAAA;AAAA,IAAA,oBACAC,OAAA;AAAA,IAAA,2BACAC,OAAA;AAAA,IAAA,qBACAC,OAAA;AAAA,EAAA;AAID,QAAM,UAAyB;AAAA,IAC9B;AAAA,IAEA,GAAG;AAAA,IACH,GAAG;AAAA,IAEH,QAAQ,KAAQ;AACX,UAAA,QAAQC,6BAAY,IAAI;AACxB,UAAA,OAAO,iBAAiB,WAAW;AAEnC,UAAA,QAAQ,qBAAqB,OAAO;AACnC,YAAA,UAAUC,YAAAA,YAAY,MAAMA,YAAW,WAAA;AACvC,YAAA,UAAUC,aAAAA,aAAa,MAAMA,aAAY,YAAA;AACzC,YAAA,UAAUC,aAAAA,aAAa,MAAMA,aAAY,YAAA;AACzC,YAAA,UAAUC,YAAAA,YAAY,MAAMA,YAAW,WAAA;AACvC,YAAA,UAAUC,gBAAAA,gBAAgB,MAAMA,gBAAe,eAAA;AAC/C,YAAA,UAAUC,UAAAA,UAAU,MAAMA,UAAS,SAAA;AAAA,MACvC;AAAA,IACF;AAAA,EAAA;AAGM,SAAA;AACR;;"}
|
package/dist/createPrismic.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createClient,
|
|
2
|
-
import { asText, asHTML, asLink, asDate, asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet, documentToLinkField } from "@prismicio/helpers";
|
|
1
|
+
import { createClient, filter, cookie, asText, asHTML, asLink, asLinkAttrs, asDate, asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet, documentToLinkField } from "@prismicio/client";
|
|
3
2
|
import { prismicKey } from "./injectionSymbols.js";
|
|
4
3
|
import { PrismicLink } from "./components/PrismicLink.js";
|
|
5
4
|
import { PrismicEmbed } from "./components/PrismicEmbed.js";
|
|
@@ -27,16 +26,37 @@ const createPrismic = (options) => {
|
|
|
27
26
|
}
|
|
28
27
|
const prismicClient = {
|
|
29
28
|
client,
|
|
30
|
-
|
|
29
|
+
filter,
|
|
31
30
|
cookie
|
|
32
31
|
};
|
|
33
32
|
const prismicHelpers = {
|
|
34
33
|
asText,
|
|
35
|
-
asHTML: (richTextField,
|
|
36
|
-
|
|
34
|
+
asHTML: (richTextField, ...config) => {
|
|
35
|
+
const [configOrLinkResolver, maybeHTMLSerializer] = config;
|
|
36
|
+
return asHTML(richTextField, typeof configOrLinkResolver === "function" || configOrLinkResolver == null ? {
|
|
37
|
+
linkResolver: configOrLinkResolver || options.linkResolver,
|
|
38
|
+
serializer: maybeHTMLSerializer || options.richTextSerializer || options.htmlSerializer
|
|
39
|
+
} : {
|
|
40
|
+
linkResolver: options.linkResolver,
|
|
41
|
+
serializer: options.richTextSerializer || options.htmlSerializer,
|
|
42
|
+
...configOrLinkResolver
|
|
43
|
+
});
|
|
37
44
|
},
|
|
38
|
-
asLink: (linkField,
|
|
39
|
-
return asLink(linkField, linkResolver
|
|
45
|
+
asLink: (linkField, config) => {
|
|
46
|
+
return asLink(linkField, typeof config === "function" ? { linkResolver: config } : {
|
|
47
|
+
linkResolver: options.linkResolver,
|
|
48
|
+
// TODO: For some reasons, TypeScript narrows the type to "unknown" where it's supposed to be a union
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
...config
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
asLinkAttrs: (linkField, config) => {
|
|
54
|
+
return asLinkAttrs(linkField, {
|
|
55
|
+
// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
linkResolver: options.linkResolver,
|
|
58
|
+
...config
|
|
59
|
+
});
|
|
40
60
|
},
|
|
41
61
|
asDate,
|
|
42
62
|
asImageSrc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrismic.js","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\
|
|
1
|
+
{"version":3,"file":"createPrismic.js","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tLinkResolverFunction,\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasLinkAttrs,\n\tasText,\n\tcookie,\n\tcreateClient,\n\tdocumentToLinkField,\n\tfilter,\n} from \"@prismicio/client\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tfilter,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, ...config) => {\n\t\t\tconst [configOrLinkResolver, maybeHTMLSerializer] = config;\n\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\ttypeof configOrLinkResolver === \"function\" ||\n\t\t\t\t\tconfigOrLinkResolver == null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tlinkResolver: configOrLinkResolver || options.linkResolver,\n\t\t\t\t\t\t\tserializer:\n\t\t\t\t\t\t\t\tmaybeHTMLSerializer ||\n\t\t\t\t\t\t\t\toptions.richTextSerializer ||\n\t\t\t\t\t\t\t\toptions.htmlSerializer,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\tserializer: options.richTextSerializer || options.htmlSerializer,\n\t\t\t\t\t\t\t...configOrLinkResolver,\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, config) => {\n\t\t\treturn asLink(\n\t\t\t\tlinkField,\n\t\t\t\ttypeof config === \"function\"\n\t\t\t\t\t? { linkResolver: config }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\t// TODO: For some reasons, TypeScript narrows the type to \"unknown\" where it's supposed to be a union\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\t...(config as any),\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLinkAttrs: (linkField, config) => {\n\t\t\treturn asLinkAttrs(linkField, {\n\t\t\t\t// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tlinkResolver: options.linkResolver as LinkResolverFunction<any>,\n\t\t\t\t...config,\n\t\t\t});\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["options"],"mappings":";;;;;;;;AA8Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAA;AACJ,MAAI,QAAQ,QAAQ;AACnB,aAAS,QAAQ;AAAA,EAAA,OACX;AACG,aAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUA,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,QACrD;AAEM,eAAA,MAAM,cAAc,UAAUA,QAAO;AAAA,MAC7C;AAAA,MACA,GAAG,QAAQ;AAAA,IAAA,CACX;AAAA,EACD;AAED,QAAM,gBAAqC;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAID,QAAM,iBAAuC;AAAA,IAC5C;AAAA,IACA,QAAQ,CAAC,kBAAkB,WAAU;AAC9B,YAAA,CAAC,sBAAsB,mBAAmB,IAAI;AAEpD,aAAO,OACN,eACA,OAAO,yBAAyB,cAC/B,wBAAwB,OACtB;AAAA,QACA,cAAc,wBAAwB,QAAQ;AAAA,QAC9C,YACC,uBACA,QAAQ,sBACR,QAAQ;AAAA,MAAA,IAET;AAAA,QACA,cAAc,QAAQ;AAAA,QACtB,YAAY,QAAQ,sBAAsB,QAAQ;AAAA,QAClD,GAAG;AAAA,MAAA,CACF;AAAA,IAEN;AAAA,IACA,QAAQ,CAAC,WAAW,WAAU;AACtB,aAAA,OACN,WACA,OAAO,WAAW,aACf,EAAE,cAAc,WAChB;AAAA,QACA,cAAc,QAAQ;AAAA;AAAA;AAAA,QAGtB,GAAI;AAAA,MAAA,CACH;AAAA,IAEN;AAAA,IACA,aAAa,CAAC,WAAW,WAAU;AAClC,aAAO,YAAY,WAAW;AAAA;AAAA;AAAA,QAG7B,cAAc,QAAQ;AAAA,QACtB,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAID,QAAM,UAAyB;AAAA,IAC9B;AAAA,IAEA,GAAG;AAAA,IACH,GAAG;AAAA,IAEH,QAAQ,KAAQ;AACX,UAAA,QAAQ,YAAY,IAAI;AACxB,UAAA,OAAO,iBAAiB,WAAW;AAEnC,UAAA,QAAQ,qBAAqB,OAAO;AACnC,YAAA,UAAU,YAAY,MAAM,WAAW;AACvC,YAAA,UAAU,aAAa,MAAM,YAAY;AACzC,YAAA,UAAU,aAAa,MAAM,YAAY;AACzC,YAAA,UAAU,YAAY,MAAM,WAAW;AACvC,YAAA,UAAU,gBAAgB,MAAM,eAAe;AAC/C,YAAA,UAAU,UAAU,MAAM,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,EAAA;AAGM,SAAA;AACR;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ClientConfig, CreateClient, cookie,
|
|
2
|
-
import type { HTMLFunctionSerializer, HTMLMapSerializer, LinkResolverFunction, asDate, asHTML, asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet, asLink, asText, documentToLinkField } from "@prismicio/helpers";
|
|
1
|
+
import type { ClientConfig, CreateClient, HTMLRichTextFunctionSerializer, HTMLRichTextMapSerializer, LinkResolverFunction, asDate, asHTML, asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet, asLink, asLinkAttrs, asText, cookie, documentToLinkField, filter } from "@prismicio/client";
|
|
3
2
|
import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue";
|
|
4
3
|
import type { SliceComponentType } from "./components/SliceZone";
|
|
5
4
|
/**
|
|
@@ -57,14 +56,14 @@ type PrismicPluginComponentsOptions = {
|
|
|
57
56
|
* Consider configuring image widths within your content type definition and
|
|
58
57
|
* using `widths="auto"` instead to give content writers the ability to crop
|
|
59
58
|
* images in the editor.
|
|
60
|
-
* @defaultValue `@prismicio/
|
|
59
|
+
* @defaultValue `@prismicio/client` defaults
|
|
61
60
|
*/
|
|
62
61
|
imageWidthSrcSetDefaults?: number[];
|
|
63
62
|
/**
|
|
64
63
|
* Default pixel densities to use when rendering an image with
|
|
65
64
|
* `pixel-densities="defaults"`
|
|
66
65
|
*
|
|
67
|
-
* @defaultValue `@prismicio/
|
|
66
|
+
* @defaultValue `@prismicio/client` defaults
|
|
68
67
|
*/
|
|
69
68
|
imagePixelDensitySrcSetDefaults?: number[];
|
|
70
69
|
/**
|
|
@@ -96,7 +95,7 @@ type PrismicPluginOptionsBase = {
|
|
|
96
95
|
*
|
|
97
96
|
* @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
98
97
|
*/
|
|
99
|
-
richTextSerializer?:
|
|
98
|
+
richTextSerializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer;
|
|
100
99
|
/**
|
|
101
100
|
* An optional HTML serializer to customize the way rich text fields are
|
|
102
101
|
* rendered.
|
|
@@ -105,7 +104,7 @@ type PrismicPluginOptionsBase = {
|
|
|
105
104
|
*
|
|
106
105
|
* @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
107
106
|
*/
|
|
108
|
-
htmlSerializer?:
|
|
107
|
+
htmlSerializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer;
|
|
109
108
|
/**
|
|
110
109
|
* Whether or not to inject components globally.
|
|
111
110
|
*
|
|
@@ -233,29 +232,29 @@ export type PrismicPluginClient = {
|
|
|
233
232
|
*/
|
|
234
233
|
client: ReturnType<CreateClient>;
|
|
235
234
|
/**
|
|
236
|
-
* Query
|
|
235
|
+
* Query filters from `@prismicio/client`.
|
|
237
236
|
*/
|
|
238
|
-
|
|
237
|
+
filter: typeof filter;
|
|
239
238
|
/**
|
|
240
239
|
* Prismic cookies from `@prismicio/client`.
|
|
241
240
|
*/
|
|
242
241
|
cookie: typeof cookie;
|
|
243
242
|
};
|
|
244
243
|
/**
|
|
245
|
-
* `@prismicio/
|
|
244
|
+
* `@prismicio/client` related methods exposed by `@prismicio/vue` plugin and
|
|
246
245
|
* accessible through `this.$prismic` and `usePrismic()`.
|
|
247
246
|
*/
|
|
248
247
|
export type PrismicPluginHelpers = {
|
|
249
248
|
/**
|
|
250
249
|
* Serializes a rich text or title field to a plain text string. This is
|
|
251
|
-
* `@prismicio/
|
|
250
|
+
* `@prismicio/client` {@link asText} function.
|
|
252
251
|
*
|
|
253
252
|
* @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
|
|
254
253
|
*/
|
|
255
254
|
asText: typeof asText;
|
|
256
255
|
/**
|
|
257
256
|
* Serializes a rich text or title field to an HTML string. This is
|
|
258
|
-
* `@prismicio/
|
|
257
|
+
* `@prismicio/client` {@link asHTML} function.
|
|
259
258
|
*
|
|
260
259
|
* @remarks
|
|
261
260
|
* If no `linkResolver` is provided the function will use the one provided to
|
|
@@ -268,39 +267,49 @@ export type PrismicPluginHelpers = {
|
|
|
268
267
|
asHTML: typeof asHTML;
|
|
269
268
|
/**
|
|
270
269
|
* Resolves any type of link field or document to a URL. This is
|
|
271
|
-
* `@prismicio/
|
|
270
|
+
* `@prismicio/client` {@link asLink} function.
|
|
272
271
|
*
|
|
273
272
|
* @remarks
|
|
274
273
|
* If no `linkResolver` is provided the function will use the one provided to
|
|
275
274
|
* the plugin at {@link PrismicPluginOptions.linkResolver} if available.
|
|
276
275
|
* @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
|
|
277
276
|
*/
|
|
278
|
-
asLink:
|
|
277
|
+
asLink: typeof asLink;
|
|
278
|
+
/**
|
|
279
|
+
* Resolves any type of link field or document to a set of link attributes.
|
|
280
|
+
* This is `@prismicio/client` {@link asLinkAttrs} function.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* If no `linkResolver` is provided the function will use the one provided to
|
|
284
|
+
* the plugin at {@link PrismicPluginOptions.linkResolver} if available.
|
|
285
|
+
* @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
|
|
286
|
+
*/
|
|
287
|
+
asLinkAttrs: typeof asLinkAttrs;
|
|
279
288
|
/**
|
|
280
289
|
* Transforms a date or timestamp field into a JavaScript Date object. This is
|
|
281
|
-
* `@prismicio/
|
|
290
|
+
* `@prismicio/client` {@link asDate} function.
|
|
282
291
|
*/
|
|
283
292
|
asDate: typeof asDate;
|
|
284
293
|
/**
|
|
285
294
|
* Returns the URL of an Image field with optional image transformations (via
|
|
286
|
-
* Imgix URL parameters). This is `@prismicio/
|
|
295
|
+
* Imgix URL parameters). This is `@prismicio/client` {@link asImageSrc}
|
|
287
296
|
* function.
|
|
288
297
|
*/
|
|
289
298
|
asImageSrc: typeof asImageSrc;
|
|
290
299
|
/**
|
|
291
300
|
* Creates a width-based `srcset` from an Image field with optional image
|
|
292
|
-
* transformations (via Imgix URL parameters). This is `@prismicio/
|
|
301
|
+
* transformations (via Imgix URL parameters). This is `@prismicio/client`
|
|
293
302
|
* {@link asImageWidthSrcSet} function.
|
|
294
303
|
*/
|
|
295
304
|
asImageWidthSrcSet: typeof asImageWidthSrcSet;
|
|
296
305
|
/**
|
|
297
306
|
* Creates a pixel-density-based `srcset` from an Image field with optional
|
|
298
307
|
* image transformations (via Imgix URL parameters). This is
|
|
299
|
-
* `@prismicio/
|
|
308
|
+
* `@prismicio/client` {@link asImagePixelDensitySrcSet} function.
|
|
300
309
|
*/
|
|
301
310
|
asImagePixelDensitySrcSet: typeof asImagePixelDensitySrcSet;
|
|
302
311
|
/**
|
|
303
|
-
* Converts a document into a link field. This is `@prismicio/
|
|
312
|
+
* Converts a document into a link field. This is `@prismicio/client`
|
|
304
313
|
* {@link documentToLinkField} function.
|
|
305
314
|
*
|
|
306
315
|
* @internal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Vue plugin, components, and composables to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"playground:dev": "vite playground",
|
|
46
46
|
"prepare": "npm run build",
|
|
47
47
|
"release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
48
|
+
"release:dry": "standard-version --dry-run",
|
|
48
49
|
"release:beta": "npm run test && standard-version --release-as major --prerelease beta && git push --follow-tags && npm run build && npm publish --tag beta",
|
|
49
50
|
"release:beta:dry": "standard-version --release-as major --prerelease beta --dry-run",
|
|
50
|
-
"release:dry": "standard-version --dry-run",
|
|
51
51
|
"lint": "eslint --ext .js,.ts .",
|
|
52
52
|
"types": "vitest typecheck --run && tsc --noEmit",
|
|
53
53
|
"types:watch": "vitest typecheck",
|
|
@@ -57,9 +57,7 @@
|
|
|
57
57
|
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@prismicio/client": "^
|
|
61
|
-
"@prismicio/helpers": "^2.3.9",
|
|
62
|
-
"@prismicio/types": "^0.2.7",
|
|
60
|
+
"@prismicio/client": "^7.0.1",
|
|
63
61
|
"isomorphic-unfetch": "^3.1.0",
|
|
64
62
|
"vue-router": "^4.2.1"
|
|
65
63
|
},
|
|
@@ -96,7 +94,7 @@
|
|
|
96
94
|
"vue": "^3.0.0"
|
|
97
95
|
},
|
|
98
96
|
"engines": {
|
|
99
|
-
"node": ">=
|
|
97
|
+
"node": ">=16.10.0"
|
|
100
98
|
},
|
|
101
99
|
"publishConfig": {
|
|
102
100
|
"access": "public"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EmbedField } from "@prismicio/client";
|
|
1
2
|
import {
|
|
2
3
|
AllowedComponentProps,
|
|
3
4
|
ComponentCustomProps,
|
|
@@ -12,8 +13,6 @@ import {
|
|
|
12
13
|
|
|
13
14
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
14
15
|
|
|
15
|
-
import { EmbedField } from "@prismicio/types";
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* The default component rendered to wrap the embed.
|
|
19
18
|
*/
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ImageField,
|
|
2
3
|
asImagePixelDensitySrcSet,
|
|
3
4
|
asImageSrc,
|
|
4
5
|
asImageWidthSrcSet,
|
|
5
6
|
isFilled,
|
|
6
|
-
} from "@prismicio/
|
|
7
|
+
} from "@prismicio/client";
|
|
7
8
|
import {
|
|
8
9
|
AllowedComponentProps,
|
|
9
10
|
ComponentCustomProps,
|
|
@@ -23,7 +24,6 @@ import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
|
23
24
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
24
25
|
|
|
25
26
|
import { VueUseOptions } from "../types";
|
|
26
|
-
import { ImageField } from "@prismicio/types";
|
|
27
27
|
|
|
28
28
|
import { usePrismic } from "../usePrismic";
|
|
29
29
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
LinkField,
|
|
3
|
+
LinkResolverFunction,
|
|
4
|
+
PrismicDocument,
|
|
5
|
+
asLink,
|
|
6
|
+
} from "@prismicio/client";
|
|
2
7
|
import {
|
|
3
8
|
AllowedComponentProps,
|
|
4
9
|
ComponentCustomProps,
|
|
@@ -20,7 +25,6 @@ import { isInternalURL } from "../lib/isInternalURL";
|
|
|
20
25
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
21
26
|
|
|
22
27
|
import { VueUseOptions } from "../types";
|
|
23
|
-
import { LinkField, PrismicDocument } from "@prismicio/types";
|
|
24
28
|
|
|
25
29
|
import { usePrismic } from "../usePrismic";
|
|
26
30
|
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
HTMLFunctionSerializer,
|
|
3
3
|
HTMLMapSerializer,
|
|
4
4
|
LinkResolverFunction,
|
|
5
|
+
RichTextField,
|
|
5
6
|
asHTML,
|
|
6
7
|
isFilled,
|
|
7
|
-
} from "@prismicio/
|
|
8
|
+
} from "@prismicio/client";
|
|
8
9
|
import {
|
|
9
10
|
AllowedComponentProps,
|
|
10
11
|
Component,
|
|
@@ -31,7 +32,6 @@ import { isInternalURL } from "../lib/isInternalURL";
|
|
|
31
32
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
32
33
|
|
|
33
34
|
import { VueUseOptions } from "../types";
|
|
34
|
-
import { RichTextField } from "@prismicio/types";
|
|
35
35
|
|
|
36
36
|
import { usePrismic } from "../usePrismic";
|
|
37
37
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asText, isFilled } from "@prismicio/
|
|
1
|
+
import { RichTextField, asText, isFilled } from "@prismicio/client";
|
|
2
2
|
import {
|
|
3
3
|
AllowedComponentProps,
|
|
4
4
|
ComponentCustomProps,
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
19
19
|
|
|
20
20
|
import { VueUseOptions } from "../types";
|
|
21
|
-
import { RichTextField } from "@prismicio/types";
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* The default component rendered to wrap the text output.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Slice } from "@prismicio/client";
|
|
1
2
|
import {
|
|
2
3
|
AllowedComponentProps,
|
|
3
4
|
ComponentCustomProps,
|
|
@@ -17,8 +18,6 @@ import {
|
|
|
17
18
|
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
18
19
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
19
20
|
|
|
20
|
-
import { Slice } from "@prismicio/types";
|
|
21
|
-
|
|
22
21
|
import { usePrismic } from "../usePrismic";
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -37,7 +36,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
|
|
|
37
36
|
* Rest API V2 for the `<SliceZone>` component.
|
|
38
37
|
*
|
|
39
38
|
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
40
|
-
* `@prismicio/
|
|
39
|
+
* `@prismicio/client` for a full interface.
|
|
41
40
|
*
|
|
42
41
|
* @typeParam TSliceType - Type name of the Slice.
|
|
43
42
|
*/
|
|
@@ -60,7 +59,7 @@ export type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
|
60
59
|
* The minimum required properties to represent a Prismic Slice for the
|
|
61
60
|
* `<SliceZone />` component.
|
|
62
61
|
*
|
|
63
|
-
* If using Prismic's REST API, use the `Slice` export from `@prismicio/
|
|
62
|
+
* If using Prismic's REST API, use the `Slice` export from `@prismicio/client`
|
|
64
63
|
* for a full interface.
|
|
65
64
|
*
|
|
66
65
|
* @typeParam TSliceType - Type name of the Slice
|
|
@@ -70,11 +69,11 @@ export type SliceLike<TSliceType extends string = string> =
|
|
|
70
69
|
| SliceLikeGraphQL<TSliceType>;
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
|
-
* A looser version of the `SliceZone` type from `@prismicio/
|
|
72
|
+
* A looser version of the `SliceZone` type from `@prismicio/client` using
|
|
74
73
|
* `SliceLike`.
|
|
75
74
|
*
|
|
76
75
|
* If using Prismic's REST API, use the `SliceZone` export from
|
|
77
|
-
* `@prismicio/
|
|
76
|
+
* `@prismicio/client` for the full type.
|
|
78
77
|
*
|
|
79
78
|
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
80
79
|
*/
|
|
@@ -153,8 +152,9 @@ export type DefineComponentSliceComponentProps<
|
|
|
153
152
|
|
|
154
153
|
/**
|
|
155
154
|
* Gets native Vue props for a component rendering content from a Prismic Slice
|
|
156
|
-
* using the `<SliceZone />` component.
|
|
157
|
-
*
|
|
155
|
+
* using the `<SliceZone />` component.
|
|
156
|
+
*
|
|
157
|
+
* Props are: `["slice", "index", "slices", "context"]`
|
|
158
158
|
*
|
|
159
159
|
* @example Defining a new slice component:
|
|
160
160
|
*
|
package/src/composables.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { Client } from "@prismicio/client";
|
|
4
4
|
|
|
5
5
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
6
|
-
import { PrismicDocument, Query } from "@prismicio/
|
|
6
|
+
import { PrismicDocument, Query } from "@prismicio/client";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
ClientComposableReturnType,
|