@prismicio/vue 3.2.0 → 3.2.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 +2 -2
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +4 -4
- package/dist/components/PrismicImage.js +2 -2
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs +3 -3
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +5 -5
- package/dist/components/PrismicLink.js +3 -3
- 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 +3 -3
- package/dist/components/PrismicRichText.js +3 -3
- package/dist/components/PrismicRichText.js.map +1 -1
- package/dist/components/PrismicText.cjs +1 -1
- package/dist/components/PrismicText.cjs.map +1 -1
- package/dist/components/PrismicText.d.ts +2 -2
- package/dist/components/PrismicText.js +1 -1
- package/dist/components/PrismicText.js.map +1 -1
- package/dist/components/SliceZone.cjs +1 -1
- package/dist/components/SliceZone.cjs.map +1 -1
- package/dist/components/SliceZone.d.ts +2 -2
- package/dist/components/SliceZone.js +1 -1
- package/dist/components/SliceZone.js.map +1 -1
- package/dist/composables.cjs.map +1 -1
- package/dist/composables.js.map +1 -1
- package/dist/createPrismic.cjs.map +1 -1
- package/dist/createPrismic.js.map +1 -1
- package/dist/injectionSymbols.cjs.map +1 -1
- package/dist/injectionSymbols.js.map +1 -1
- package/dist/lib/simplyResolveComponent.cjs.map +1 -1
- package/dist/lib/simplyResolveComponent.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/usePrismic.cjs.map +1 -1
- package/dist/usePrismic.js.map +1 -1
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
- package/dist/useStatefulPrismicClientMethod.js.map +1 -1
- package/package.json +27 -19
- package/src/components/PrismicEmbed.ts +4 -3
- package/src/components/PrismicImage.ts +16 -15
- package/src/components/PrismicLink.ts +14 -13
- package/src/components/PrismicRichText.ts +15 -14
- package/src/components/PrismicText.ts +7 -7
- package/src/components/SliceZone.ts +7 -6
- package/src/composables.ts +2 -5
- package/src/createPrismic.ts +15 -15
- package/src/injectionSymbols.ts +0 -2
- package/src/lib/simplyResolveComponent.ts +1 -1
- package/src/types.ts +10 -13
- package/src/usePrismic.ts +2 -1
- package/src/useStatefulPrismicClientMethod.ts +3 -3
- package/vetur/attributes.json +1 -6
- package/vetur/tags.json +17 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ClientConfig, CreateClient, cookie, predicate } from "@prismicio/client";
|
|
2
|
+
import type { HTMLFunctionSerializer, HTMLMapSerializer, LinkResolverFunction, asDate, asHTML, asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet, asLink, asText, documentToLinkField } from "@prismicio/helpers";
|
|
1
3
|
import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue";
|
|
2
|
-
import type { Client, ClientConfig, cookie, predicate } from "@prismicio/client";
|
|
3
|
-
import type { asText, asHTML, asLink, asDate, documentToLinkField, HTMLFunctionSerializer, HTMLMapSerializer, LinkResolverFunction, asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet } from "@prismicio/helpers";
|
|
4
4
|
import type { SliceComponentType } from "./components/SliceZone";
|
|
5
5
|
/**
|
|
6
6
|
* Options used by `@prismicio/vue` components.
|
|
@@ -135,7 +135,7 @@ type PrismicPluginOptionsWithClient = PrismicPluginOptionsBase & {
|
|
|
135
135
|
* `usePrismic().client`.
|
|
136
136
|
* @see Prismic client documentation {@link https://prismic.io/docs/technologies/javascript}
|
|
137
137
|
*/
|
|
138
|
-
client:
|
|
138
|
+
client: ReturnType<CreateClient>;
|
|
139
139
|
/**
|
|
140
140
|
* Ensures type union is a strict or.
|
|
141
141
|
*
|
|
@@ -231,7 +231,7 @@ export type PrismicPluginClient = {
|
|
|
231
231
|
/**
|
|
232
232
|
* A `@prismicio/client` instance.
|
|
233
233
|
*/
|
|
234
|
-
client:
|
|
234
|
+
client: ReturnType<CreateClient>;
|
|
235
235
|
/**
|
|
236
236
|
* Query predicates from `@prismicio/client`.
|
|
237
237
|
*/
|
package/dist/usePrismic.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrismic.cjs","sources":["../../src/usePrismic.ts"],"sourcesContent":["import { inject } from \"vue\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"usePrismic.cjs","sources":["../../src/usePrismic.ts"],"sourcesContent":["import { inject } from \"vue\";\n\nimport { PrismicPlugin } from \"./types\";\n\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Accesses `@prismicio/vue` plugin interface.\n *\n * @example With the composition API:\n *\n * ```javascript\n * import { usePrismic } from \"@prismicio/vue\";\n *\n * export default {\n * \tsetup() {\n * \t\tconst prismic = usePrismic();\n *\n * \t\treturn {};\n * \t},\n * };\n * ```\n *\n * @returns The interface {@link PrismicPlugin}\n */\nexport const usePrismic = (): PrismicPlugin => {\n\treturn inject(prismicKey, { options: { endpoint: \"\" } } as PrismicPlugin);\n};\n"],"names":["inject","prismicKey"],"mappings":";;;;AAyBO,MAAM,aAAa,MAAoB;AACtC,SAAAA,IAAAA,OAAOC,iBAAAA,YAAY,EAAE,SAAS,EAAE,UAAU,MAAuB;AACzE;;"}
|
package/dist/usePrismic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrismic.js","sources":["../../src/usePrismic.ts"],"sourcesContent":["import { inject } from \"vue\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"usePrismic.js","sources":["../../src/usePrismic.ts"],"sourcesContent":["import { inject } from \"vue\";\n\nimport { PrismicPlugin } from \"./types\";\n\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Accesses `@prismicio/vue` plugin interface.\n *\n * @example With the composition API:\n *\n * ```javascript\n * import { usePrismic } from \"@prismicio/vue\";\n *\n * export default {\n * \tsetup() {\n * \t\tconst prismic = usePrismic();\n *\n * \t\treturn {};\n * \t},\n * };\n * ```\n *\n * @returns The interface {@link PrismicPlugin}\n */\nexport const usePrismic = (): PrismicPlugin => {\n\treturn inject(prismicKey, { options: { endpoint: \"\" } } as PrismicPlugin);\n};\n"],"names":[],"mappings":";;AAyBO,MAAM,aAAa,MAAoB;AACtC,SAAA,OAAO,YAAY,EAAE,SAAS,EAAE,UAAU,MAAuB;AACzE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatefulPrismicClientMethod.cjs","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.cjs","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\nimport { Ref, isRef, ref, shallowRef, unref, watch } from \"vue\";\n\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\n\nimport { usePrismic } from \"./usePrismic\";\n\n// Helpers\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ClientMethodLike = (...args: any[]) => Promise<any> | any;\ntype ClientMethods = typeof Client.prototype;\ntype ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;\n\n// Interfaces\n\n/**\n * @internal\n */\nexport type ClientMethodParameters<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? VueUseParameters<Parameters<ClientMethods[TMethodName]>>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ClientMethodReturnType<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? ReturnType<ClientMethods[TMethodName]>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ComposableOnlyParameters = {\n\tclient?: Ref<Client> | Client;\n};\n\n/**\n * The return type of a `@prismicio/client` Vue composable.\n *\n * @typeParam TData - The expected format of the `data` property of the returned\n * object\n */\nexport type ClientComposableReturnType<TData = unknown> = {\n\t/**\n\t * The current state of the composable's client method call.\n\t */\n\tstate: Ref<PrismicClientComposableState>;\n\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: Ref<TData | null>;\n\n\t/**\n\t * Error returned by the composable's client method call if in an errror\n\t * state.\n\t */\n\terror: Ref<ClientError | Error | null>;\n\n\t/**\n\t * Perform the composable's client method call again.\n\t */\n\trefresh: () => Promise<void>;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A low level Vue composable that uses provided method name on plugin or\n * provided client with given arguments. The composable has its own internal\n * state manager to report async status, such as pending or error statuses.\n *\n * @typeParam TClientMethodName - A method name from `@prismicio/client`\n * @typeParam TClientMethodArguments - The method expected arguments\n * @typeParam TClientMethodReturnType - The method expected return type\n *\n * @param method - The `@prismicio/client` method name to use\n * @param args - The arguments to use with requested method\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTClientMethodName extends keyof ClientMethods,\n\tTClientMethodArguments extends ClientMethodParameters<TClientMethodName>,\n\tTClientMethodReturnType extends UnwrapPromise<\n\t\tClientMethodReturnType<TClientMethodName>\n\t>,\n>(\n\tmethodName: TClientMethodName,\n\targs: TClientMethodArguments,\n): ClientComposableReturnType<TClientMethodReturnType> => {\n\tconst { client } = usePrismic();\n\n\tconst state = ref<PrismicClientComposableState>(\n\t\tPrismicClientComposableState.Idle,\n\t);\n\tconst data = shallowRef<TClientMethodReturnType | null>(null);\n\tconst error = ref<ClientError | Error | null>(null);\n\tconst refresh = async (): Promise<void> => {\n\t\tconst lastArg = unref(args[args.length - 1]);\n\t\tconst { client: explicitClient, ...params } = isParams(lastArg)\n\t\t\t? (lastArg as ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters)\n\t\t\t: ({} as ComposableOnlyParameters);\n\t\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\t\tstate.value = PrismicClientComposableState.Pending;\n\t\tdata.value = null;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tdata.value = await (\n\t\t\t\t(unref(explicitClient) || client)[methodName] as ClientMethodLike\n\t\t\t)(\n\t\t\t\t...argsWithoutParams.map((arg: Ref<unknown> | unknown) => unref(arg)),\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tstate.value = PrismicClientComposableState.Success;\n\t\t} catch (err) {\n\t\t\tstate.value = PrismicClientComposableState.Error;\n\t\t\terror.value = err as ClientError | Error;\n\t\t}\n\t};\n\n\t// Watch reactive args\n\tconst refArgs = args.filter((arg) => isRef(arg));\n\tif (refArgs.length) {\n\t\twatch(refArgs, refresh, { deep: true });\n\t}\n\n\t// Fetch once\n\trefresh();\n\n\treturn { state, data, error, refresh };\n};\n"],"names":["usePrismic","ref","shallowRef","unref","isRef","watch"],"mappings":";;;;AAiFA,MAAM,WAAW,CAChB,UACyE;AAElE,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAkBa,MAAA,iCAAiC,CAO7C,YACA,SACwD;AAClD,QAAA,EAAE,WAAWA,WAAAA;AAEnB,QAAM,QAAQC,IAAA;AAAA,IAAG;AAAA;AAAA,EAAA;AAGX,QAAA,OAAOC,eAA2C,IAAI;AACtD,QAAA,QAAQD,QAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAUE,IAAAA,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC;AACrC,UAAA,EAAE,QAAQ,gBAAgB,GAAG,OAAA,IAAW,SAAS,OAAO,IAC1D,UACA;AACE,UAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAElE,UAAM,QAAK;AACX,SAAK,QAAQ;AACb,UAAM,QAAQ;AACV,QAAA;AACH,WAAK,QAAQ,OACXA,IAAAA,MAAM,cAAc,KAAK,QAAQ,UAAU,EAE5C,GAAG,kBAAkB,IAAI,CAAC,QAAgCA,IAAAA,MAAM,GAAG,CAAC,GACpE,MAAM;AAEP,YAAM,QAAK;AAAA,aACH;AACR,YAAM,QAAK;AACX,YAAM,QAAQ;AAAA,IACd;AAAA,EAAA;AAIF,QAAM,UAAU,KAAK,OAAO,CAAC,QAAQC,IAAA,MAAM,GAAG,CAAC;AAC/C,MAAI,QAAQ,QAAQ;AACnBC,QAAA,MAAM,SAAS,SAAS,EAAE,MAAM,KAAM,CAAA;AAAA,EACtC;;AAKD,SAAO,EAAE,OAAO,MAAM,OAAO,QAAO;AACrC;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
2
1
|
import { Client, ForbiddenError, ParsingError, PrismicError } from "@prismicio/client";
|
|
2
|
+
import { Ref } from "vue";
|
|
3
3
|
import { PrismicClientComposableState, VueUseParameters } from "./types";
|
|
4
4
|
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
5
5
|
type ClientMethodLike = (...args: any[]) => Promise<any> | any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\nimport { Ref, isRef, ref, shallowRef, unref, watch } from \"vue\";\n\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\n\nimport { usePrismic } from \"./usePrismic\";\n\n// Helpers\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ClientMethodLike = (...args: any[]) => Promise<any> | any;\ntype ClientMethods = typeof Client.prototype;\ntype ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;\n\n// Interfaces\n\n/**\n * @internal\n */\nexport type ClientMethodParameters<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? VueUseParameters<Parameters<ClientMethods[TMethodName]>>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ClientMethodReturnType<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? ReturnType<ClientMethods[TMethodName]>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ComposableOnlyParameters = {\n\tclient?: Ref<Client> | Client;\n};\n\n/**\n * The return type of a `@prismicio/client` Vue composable.\n *\n * @typeParam TData - The expected format of the `data` property of the returned\n * object\n */\nexport type ClientComposableReturnType<TData = unknown> = {\n\t/**\n\t * The current state of the composable's client method call.\n\t */\n\tstate: Ref<PrismicClientComposableState>;\n\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: Ref<TData | null>;\n\n\t/**\n\t * Error returned by the composable's client method call if in an errror\n\t * state.\n\t */\n\terror: Ref<ClientError | Error | null>;\n\n\t/**\n\t * Perform the composable's client method call again.\n\t */\n\trefresh: () => Promise<void>;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A low level Vue composable that uses provided method name on plugin or\n * provided client with given arguments. The composable has its own internal\n * state manager to report async status, such as pending or error statuses.\n *\n * @typeParam TClientMethodName - A method name from `@prismicio/client`\n * @typeParam TClientMethodArguments - The method expected arguments\n * @typeParam TClientMethodReturnType - The method expected return type\n *\n * @param method - The `@prismicio/client` method name to use\n * @param args - The arguments to use with requested method\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTClientMethodName extends keyof ClientMethods,\n\tTClientMethodArguments extends ClientMethodParameters<TClientMethodName>,\n\tTClientMethodReturnType extends UnwrapPromise<\n\t\tClientMethodReturnType<TClientMethodName>\n\t>,\n>(\n\tmethodName: TClientMethodName,\n\targs: TClientMethodArguments,\n): ClientComposableReturnType<TClientMethodReturnType> => {\n\tconst { client } = usePrismic();\n\n\tconst state = ref<PrismicClientComposableState>(\n\t\tPrismicClientComposableState.Idle,\n\t);\n\tconst data = shallowRef<TClientMethodReturnType | null>(null);\n\tconst error = ref<ClientError | Error | null>(null);\n\tconst refresh = async (): Promise<void> => {\n\t\tconst lastArg = unref(args[args.length - 1]);\n\t\tconst { client: explicitClient, ...params } = isParams(lastArg)\n\t\t\t? (lastArg as ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters)\n\t\t\t: ({} as ComposableOnlyParameters);\n\t\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\t\tstate.value = PrismicClientComposableState.Pending;\n\t\tdata.value = null;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tdata.value = await (\n\t\t\t\t(unref(explicitClient) || client)[methodName] as ClientMethodLike\n\t\t\t)(\n\t\t\t\t...argsWithoutParams.map((arg: Ref<unknown> | unknown) => unref(arg)),\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tstate.value = PrismicClientComposableState.Success;\n\t\t} catch (err) {\n\t\t\tstate.value = PrismicClientComposableState.Error;\n\t\t\terror.value = err as ClientError | Error;\n\t\t}\n\t};\n\n\t// Watch reactive args\n\tconst refArgs = args.filter((arg) => isRef(arg));\n\tif (refArgs.length) {\n\t\twatch(refArgs, refresh, { deep: true });\n\t}\n\n\t// Fetch once\n\trefresh();\n\n\treturn { state, data, error, refresh };\n};\n"],"names":[],"mappings":";;AAiFA,MAAM,WAAW,CAChB,UACyE;AAElE,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAkBa,MAAA,iCAAiC,CAO7C,YACA,SACwD;AAClD,QAAA,EAAE,WAAW;AAEnB,QAAM,QAAQ;AAAA,IAAG;AAAA;AAAA,EAAA;AAGX,QAAA,OAAO,WAA2C,IAAI;AACtD,QAAA,QAAQ,IAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAU,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC;AACrC,UAAA,EAAE,QAAQ,gBAAgB,GAAG,OAAA,IAAW,SAAS,OAAO,IAC1D,UACA;AACE,UAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAElE,UAAM,QAAK;AACX,SAAK,QAAQ;AACb,UAAM,QAAQ;AACV,QAAA;AACH,WAAK,QAAQ,OACX,MAAM,cAAc,KAAK,QAAQ,UAAU,EAE5C,GAAG,kBAAkB,IAAI,CAAC,QAAgC,MAAM,GAAG,CAAC,GACpE,MAAM;AAEP,YAAM,QAAK;AAAA,aACH;AACR,YAAM,QAAK;AACX,YAAM,QAAQ;AAAA,IACd;AAAA,EAAA;AAIF,QAAM,UAAU,KAAK,OAAO,CAAC,QAAQ,MAAM,GAAG,CAAC;AAC/C,MAAI,QAAQ,QAAQ;AACnB,UAAM,SAAS,SAAS,EAAE,MAAM,KAAM,CAAA;AAAA,EACtC;;AAKD,SAAO,EAAE,OAAO,MAAM,OAAO,QAAO;AACrC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/vue",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Vue plugin, components, and composables to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
"type": "module",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"require":
|
|
22
|
-
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
23
29
|
},
|
|
24
30
|
"./package.json": "./package.json"
|
|
25
31
|
},
|
|
@@ -35,7 +41,6 @@
|
|
|
35
41
|
"build": "vite build",
|
|
36
42
|
"dev": "vite build --watch",
|
|
37
43
|
"format": "prettier --write .",
|
|
38
|
-
"lint": "eslint --ext .js,.ts .",
|
|
39
44
|
"playground:build": "vite build playground",
|
|
40
45
|
"playground:dev": "vite playground",
|
|
41
46
|
"prepare": "npm run build",
|
|
@@ -43,35 +48,38 @@
|
|
|
43
48
|
"release:beta": "npm run test && standard-version --release-as major --prerelease beta && git push --follow-tags && npm run build && npm publish --tag beta",
|
|
44
49
|
"release:beta:dry": "standard-version --release-as major --prerelease beta --dry-run",
|
|
45
50
|
"release:dry": "standard-version --dry-run",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"types": "
|
|
51
|
+
"lint": "eslint --ext .js,.ts .",
|
|
52
|
+
"types": "vitest typecheck --run && tsc --noEmit",
|
|
53
|
+
"types:watch": "vitest typecheck",
|
|
49
54
|
"unit": "vitest run --coverage",
|
|
50
|
-
"unit:watch": "vitest watch"
|
|
55
|
+
"unit:watch": "vitest watch",
|
|
56
|
+
"size": "size-limit",
|
|
57
|
+
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
|
|
51
58
|
},
|
|
52
59
|
"dependencies": {
|
|
53
60
|
"@prismicio/client": "^6.7.3",
|
|
54
61
|
"@prismicio/helpers": "^2.3.9",
|
|
55
62
|
"@prismicio/types": "^0.2.7",
|
|
56
63
|
"isomorphic-unfetch": "^3.1.0",
|
|
57
|
-
"vue-router": "^4.1
|
|
64
|
+
"vue-router": "^4.2.1"
|
|
58
65
|
},
|
|
59
66
|
"devDependencies": {
|
|
60
67
|
"@prismicio/mock": "^0.2.0",
|
|
61
68
|
"@size-limit/preset-small-lib": "^8.2.4",
|
|
69
|
+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
62
70
|
"@types/jsdom-global": "^3.0.4",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
64
|
-
"@typescript-eslint/parser": "^5.59.
|
|
65
|
-
"@vitejs/plugin-vue": "^4.2.
|
|
66
|
-
"@vitest/coverage-c8": "^0.31.
|
|
67
|
-
"@vue/compiler-sfc": "^3.
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
72
|
+
"@typescript-eslint/parser": "^5.59.7",
|
|
73
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
74
|
+
"@vitest/coverage-c8": "^0.31.1",
|
|
75
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
68
76
|
"@vue/eslint-config-typescript": "^11.0.3",
|
|
69
77
|
"@vue/test-utils": "^2.3.2",
|
|
70
|
-
"eslint": "^8.
|
|
78
|
+
"eslint": "^8.41.0",
|
|
71
79
|
"eslint-config-prettier": "^8.8.0",
|
|
72
80
|
"eslint-plugin-prettier": "^4.2.1",
|
|
73
81
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
74
|
-
"eslint-plugin-vue": "^9.
|
|
82
|
+
"eslint-plugin-vue": "^9.14.0",
|
|
75
83
|
"jsdom": "^22.0.0",
|
|
76
84
|
"jsdom-global": "^3.0.2",
|
|
77
85
|
"prettier": "^2.8.8",
|
|
@@ -79,10 +87,10 @@
|
|
|
79
87
|
"size-limit": "^8.2.4",
|
|
80
88
|
"standard-version": "^9.5.0",
|
|
81
89
|
"typescript": "^5.0.4",
|
|
82
|
-
"vite": "^4.3.
|
|
90
|
+
"vite": "^4.3.8",
|
|
83
91
|
"vite-plugin-sdk": "^0.1.1",
|
|
84
|
-
"vitest": "^0.31.
|
|
85
|
-
"vue": "^3.
|
|
92
|
+
"vitest": "^0.31.1",
|
|
93
|
+
"vue": "^3.3.4"
|
|
86
94
|
},
|
|
87
95
|
"peerDependencies": {
|
|
88
96
|
"vue": "^3.0.0"
|
|
@@ -3,16 +3,17 @@ import {
|
|
|
3
3
|
ComponentCustomProps,
|
|
4
4
|
ConcreteComponent,
|
|
5
5
|
DefineComponent,
|
|
6
|
-
defineComponent,
|
|
7
|
-
h,
|
|
8
6
|
PropType,
|
|
9
7
|
Raw,
|
|
10
8
|
VNodeProps,
|
|
9
|
+
defineComponent,
|
|
10
|
+
h,
|
|
11
11
|
} from "vue";
|
|
12
12
|
|
|
13
|
-
import { EmbedField } from "@prismicio/types";
|
|
14
13
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
15
14
|
|
|
15
|
+
import { EmbedField } from "@prismicio/types";
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
18
|
* The default component rendered to wrap the embed.
|
|
18
19
|
*/
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asImagePixelDensitySrcSet,
|
|
3
|
+
asImageSrc,
|
|
4
|
+
asImageWidthSrcSet,
|
|
5
|
+
isFilled,
|
|
6
|
+
} from "@prismicio/helpers";
|
|
1
7
|
import {
|
|
2
8
|
AllowedComponentProps,
|
|
3
9
|
ComponentCustomProps,
|
|
4
|
-
computed,
|
|
5
|
-
ConcreteComponent,
|
|
6
10
|
ComputedRef,
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
ConcreteComponent,
|
|
12
|
+
DefineComponent,
|
|
9
13
|
PropType,
|
|
14
|
+
Raw,
|
|
10
15
|
VNodeProps,
|
|
16
|
+
computed,
|
|
17
|
+
defineComponent,
|
|
18
|
+
h,
|
|
11
19
|
unref,
|
|
12
|
-
DefineComponent,
|
|
13
|
-
Raw,
|
|
14
20
|
} from "vue";
|
|
15
21
|
|
|
22
|
+
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
23
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
24
|
+
|
|
25
|
+
import { VueUseOptions } from "../types";
|
|
16
26
|
import { ImageField } from "@prismicio/types";
|
|
17
|
-
import {
|
|
18
|
-
asImageSrc,
|
|
19
|
-
asImageWidthSrcSet,
|
|
20
|
-
asImagePixelDensitySrcSet,
|
|
21
|
-
isFilled,
|
|
22
|
-
} from "@prismicio/helpers";
|
|
23
27
|
|
|
24
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
25
|
-
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
26
28
|
import { usePrismic } from "../usePrismic";
|
|
27
|
-
import { VueUseOptions } from "../types";
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* The default component rendered for images.
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
+
import { LinkResolverFunction, asLink } from "@prismicio/helpers";
|
|
1
2
|
import {
|
|
2
3
|
AllowedComponentProps,
|
|
3
4
|
ComponentCustomProps,
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
ComputedRef,
|
|
6
|
+
ConcreteComponent,
|
|
7
|
+
DefineComponent,
|
|
6
8
|
PropType,
|
|
9
|
+
Raw,
|
|
7
10
|
VNodeProps,
|
|
8
|
-
unref,
|
|
9
|
-
reactive,
|
|
10
|
-
ConcreteComponent,
|
|
11
11
|
computed,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
defineComponent,
|
|
13
|
+
h,
|
|
14
|
+
reactive,
|
|
15
|
+
unref,
|
|
15
16
|
} from "vue";
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
+
import { getSlots } from "../lib/getSlots";
|
|
19
|
+
import { isInternalURL } from "../lib/isInternalURL";
|
|
20
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
21
|
+
|
|
22
|
+
import { VueUseOptions } from "../types";
|
|
18
23
|
import { LinkField, PrismicDocument } from "@prismicio/types";
|
|
19
24
|
|
|
20
|
-
import { isInternalURL } from "../lib/isInternalURL";
|
|
21
25
|
import { usePrismic } from "../usePrismic";
|
|
22
|
-
import { VueUseOptions } from "../types";
|
|
23
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
24
|
-
import { getSlots } from "../lib/getSlots";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* The default component rendered for internal URLs.
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HTMLFunctionSerializer,
|
|
3
|
+
HTMLMapSerializer,
|
|
4
|
+
LinkResolverFunction,
|
|
5
|
+
asHTML,
|
|
6
|
+
isFilled,
|
|
7
|
+
} from "@prismicio/helpers";
|
|
1
8
|
import {
|
|
2
9
|
AllowedComponentProps,
|
|
3
10
|
Component,
|
|
4
11
|
ComponentCustomProps,
|
|
5
|
-
computed,
|
|
6
12
|
ComputedRef,
|
|
7
13
|
ConcreteComponent,
|
|
8
14
|
DefineComponent,
|
|
15
|
+
PropType,
|
|
16
|
+
Raw,
|
|
17
|
+
VNodeProps,
|
|
18
|
+
computed,
|
|
9
19
|
defineComponent,
|
|
10
20
|
h,
|
|
11
21
|
inject,
|
|
12
22
|
nextTick,
|
|
13
23
|
onBeforeUnmount,
|
|
14
|
-
PropType,
|
|
15
|
-
Raw,
|
|
16
24
|
ref,
|
|
17
25
|
unref,
|
|
18
|
-
VNodeProps,
|
|
19
26
|
watch,
|
|
20
27
|
} from "vue";
|
|
21
28
|
import { routerKey } from "vue-router";
|
|
22
29
|
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
HTMLFunctionSerializer,
|
|
26
|
-
HTMLMapSerializer,
|
|
27
|
-
isFilled,
|
|
28
|
-
LinkResolverFunction,
|
|
29
|
-
} from "@prismicio/helpers";
|
|
30
|
-
import { RichTextField } from "@prismicio/types";
|
|
30
|
+
import { isInternalURL } from "../lib/isInternalURL";
|
|
31
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
31
32
|
|
|
32
33
|
import { VueUseOptions } from "../types";
|
|
34
|
+
import { RichTextField } from "@prismicio/types";
|
|
35
|
+
|
|
33
36
|
import { usePrismic } from "../usePrismic";
|
|
34
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
35
|
-
import { isInternalURL } from "../lib/isInternalURL";
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* The default component rendered to wrap the HTML output.
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
+
import { asText, isFilled } from "@prismicio/helpers";
|
|
1
2
|
import {
|
|
2
3
|
AllowedComponentProps,
|
|
3
4
|
ComponentCustomProps,
|
|
4
|
-
computed,
|
|
5
5
|
ComputedRef,
|
|
6
6
|
ConcreteComponent,
|
|
7
7
|
DefineComponent,
|
|
8
|
-
defineComponent,
|
|
9
|
-
h,
|
|
10
8
|
PropType,
|
|
11
9
|
Raw,
|
|
12
|
-
unref,
|
|
13
10
|
VNode,
|
|
14
11
|
VNodeProps,
|
|
12
|
+
computed,
|
|
13
|
+
defineComponent,
|
|
14
|
+
h,
|
|
15
|
+
unref,
|
|
15
16
|
} from "vue";
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
-
import { RichTextField } from "@prismicio/types";
|
|
18
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
19
19
|
|
|
20
20
|
import { VueUseOptions } from "../types";
|
|
21
|
-
import {
|
|
21
|
+
import { RichTextField } from "@prismicio/types";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The default component rendered to wrap the text output.
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AllowedComponentProps,
|
|
3
3
|
ComponentCustomProps,
|
|
4
|
-
computed,
|
|
5
4
|
ConcreteComponent,
|
|
6
5
|
DefineComponent,
|
|
7
|
-
defineComponent,
|
|
8
6
|
FunctionalComponent,
|
|
9
|
-
h,
|
|
10
|
-
markRaw,
|
|
11
7
|
PropType,
|
|
12
8
|
Raw,
|
|
13
9
|
VNodeProps,
|
|
10
|
+
computed,
|
|
11
|
+
defineComponent,
|
|
12
|
+
h,
|
|
13
|
+
markRaw,
|
|
14
14
|
watchEffect,
|
|
15
15
|
} from "vue";
|
|
16
16
|
|
|
17
|
+
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
18
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
19
|
+
|
|
17
20
|
import { Slice } from "@prismicio/types";
|
|
18
21
|
|
|
19
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
20
|
-
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
21
22
|
import { usePrismic } from "../usePrismic";
|
|
22
23
|
|
|
23
24
|
/**
|
package/src/composables.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
|
|
3
2
|
// Imports for @link references:
|
|
4
|
-
|
|
5
3
|
import type { Client } from "@prismicio/client";
|
|
6
4
|
|
|
7
5
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
8
|
-
|
|
9
6
|
import { PrismicDocument, Query } from "@prismicio/types";
|
|
10
7
|
|
|
11
8
|
import {
|
|
12
|
-
ClientMethodParameters,
|
|
13
9
|
ClientComposableReturnType,
|
|
14
|
-
|
|
10
|
+
ClientMethodParameters,
|
|
15
11
|
ComposableOnlyParameters,
|
|
12
|
+
useStatefulPrismicClientMethod,
|
|
16
13
|
} from "./useStatefulPrismicClientMethod";
|
|
17
14
|
|
|
18
15
|
// Composables
|
package/src/createPrismic.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
import { App } from "vue";
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
|
-
createClient,
|
|
5
|
-
predicate,
|
|
6
|
-
cookie,
|
|
7
2
|
Client,
|
|
8
3
|
FetchLike,
|
|
4
|
+
cookie,
|
|
5
|
+
createClient,
|
|
6
|
+
predicate,
|
|
9
7
|
} from "@prismicio/client";
|
|
10
8
|
import {
|
|
11
|
-
asText,
|
|
12
|
-
asHTML,
|
|
13
|
-
asLink,
|
|
14
9
|
asDate,
|
|
10
|
+
asHTML,
|
|
11
|
+
asImagePixelDensitySrcSet,
|
|
15
12
|
asImageSrc,
|
|
16
13
|
asImageWidthSrcSet,
|
|
17
|
-
|
|
14
|
+
asLink,
|
|
15
|
+
asText,
|
|
18
16
|
documentToLinkField,
|
|
19
17
|
} from "@prismicio/helpers";
|
|
18
|
+
import { App } from "vue";
|
|
19
|
+
|
|
20
|
+
import type {
|
|
21
|
+
PrismicPlugin,
|
|
22
|
+
PrismicPluginClient,
|
|
23
|
+
PrismicPluginHelpers,
|
|
24
|
+
PrismicPluginOptions,
|
|
25
|
+
} from "./types";
|
|
20
26
|
|
|
21
27
|
import {
|
|
22
28
|
PrismicEmbed,
|
|
@@ -27,12 +33,6 @@ import {
|
|
|
27
33
|
SliceZone,
|
|
28
34
|
} from "./components";
|
|
29
35
|
import { prismicKey } from "./injectionSymbols";
|
|
30
|
-
import type {
|
|
31
|
-
PrismicPlugin,
|
|
32
|
-
PrismicPluginClient,
|
|
33
|
-
PrismicPluginHelpers,
|
|
34
|
-
PrismicPluginOptions,
|
|
35
|
-
} from "./types";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.
|
package/src/injectionSymbols.ts
CHANGED
|
@@ -3,9 +3,7 @@ import type { InjectionKey } from "vue";
|
|
|
3
3
|
import type { PrismicPlugin } from "./types";
|
|
4
4
|
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
|
-
|
|
7
6
|
// Imports for @link references:
|
|
8
|
-
|
|
9
7
|
import type { usePrismic } from "./usePrismic";
|
|
10
8
|
|
|
11
9
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
package/src/types.ts
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue";
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
|
-
Client,
|
|
5
2
|
ClientConfig,
|
|
3
|
+
CreateClient,
|
|
6
4
|
cookie,
|
|
7
5
|
predicate,
|
|
8
6
|
} from "@prismicio/client";
|
|
9
7
|
import type {
|
|
10
|
-
asText,
|
|
11
|
-
asHTML,
|
|
12
|
-
asLink,
|
|
13
|
-
asDate,
|
|
14
|
-
documentToLinkField,
|
|
15
8
|
HTMLFunctionSerializer,
|
|
16
9
|
HTMLMapSerializer,
|
|
17
10
|
LinkResolverFunction,
|
|
11
|
+
asDate,
|
|
12
|
+
asHTML,
|
|
13
|
+
asImagePixelDensitySrcSet,
|
|
18
14
|
asImageSrc,
|
|
19
15
|
asImageWidthSrcSet,
|
|
20
|
-
|
|
16
|
+
asLink,
|
|
17
|
+
asText,
|
|
18
|
+
documentToLinkField,
|
|
21
19
|
} from "@prismicio/helpers";
|
|
20
|
+
import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue";
|
|
22
21
|
|
|
23
22
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
24
|
-
|
|
25
23
|
// Imports for @link references:
|
|
26
|
-
|
|
27
24
|
import type { RouterLink } from "vue-router";
|
|
28
25
|
|
|
29
26
|
import type {
|
|
@@ -182,7 +179,7 @@ type PrismicPluginOptionsWithClient = PrismicPluginOptionsBase & {
|
|
|
182
179
|
* `usePrismic().client`.
|
|
183
180
|
* @see Prismic client documentation {@link https://prismic.io/docs/technologies/javascript}
|
|
184
181
|
*/
|
|
185
|
-
client:
|
|
182
|
+
client: ReturnType<CreateClient>;
|
|
186
183
|
|
|
187
184
|
/**
|
|
188
185
|
* Ensures type union is a strict or.
|
|
@@ -287,7 +284,7 @@ export type PrismicPluginClient = {
|
|
|
287
284
|
/**
|
|
288
285
|
* A `@prismicio/client` instance.
|
|
289
286
|
*/
|
|
290
|
-
client:
|
|
287
|
+
client: ReturnType<CreateClient>;
|
|
291
288
|
|
|
292
289
|
/**
|
|
293
290
|
* Query predicates from `@prismicio/client`.
|
package/src/usePrismic.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { isRef, ref, Ref, shallowRef, unref, watch } from "vue";
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
Client,
|
|
5
3
|
ForbiddenError,
|
|
6
4
|
ParsingError,
|
|
7
5
|
PrismicError,
|
|
8
6
|
} from "@prismicio/client";
|
|
7
|
+
import { Ref, isRef, ref, shallowRef, unref, watch } from "vue";
|
|
9
8
|
|
|
10
|
-
import { usePrismic } from "./usePrismic";
|
|
11
9
|
import { PrismicClientComposableState, VueUseParameters } from "./types";
|
|
12
10
|
|
|
11
|
+
import { usePrismic } from "./usePrismic";
|
|
12
|
+
|
|
13
13
|
// Helpers
|
|
14
14
|
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|