@prismicio/vue 3.2.0 → 4.0.0
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 +2 -2
- package/dist/components/PrismicEmbed.js.map +1 -1
- package/dist/components/PrismicImage.cjs +6 -6
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +3 -4
- package/dist/components/PrismicImage.js +2 -2
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs +4 -4
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +5 -6
- package/dist/components/PrismicLink.js +3 -3
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.cjs +5 -5
- package/dist/components/PrismicRichText.cjs.map +1 -1
- package/dist/components/PrismicRichText.d.ts +8 -9
- package/dist/components/PrismicRichText.js +3 -3
- 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 +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 +10 -9
- 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.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/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 +29 -20
- 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 +30 -24
- package/src/components/PrismicEmbed.ts +3 -3
- package/src/components/PrismicImage.ts +17 -16
- package/src/components/PrismicLink.ts +19 -14
- package/src/components/PrismicRichText.ts +15 -14
- package/src/components/PrismicText.ts +6 -7
- package/src/components/SliceZone.ts +14 -13
- package/src/composables.ts +3 -6
- package/src/createPrismic.ts +56 -24
- package/src/injectionSymbols.ts +0 -2
- package/src/lib/simplyResolveComponent.ts +1 -1
- package/src/types.ts +45 -39
- package/src/usePrismic.ts +2 -1
- package/src/useStatefulPrismicClientMethod.ts +3 -3
- package/vetur/attributes.json +1 -6
- package/vetur/tags.json +17 -3
|
@@ -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
|
+
"version": "4.0.0",
|
|
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,43 +41,43 @@
|
|
|
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",
|
|
42
47
|
"release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
48
|
+
"release:dry": "standard-version --dry-run",
|
|
43
49
|
"release:beta": "npm run test && standard-version --release-as major --prerelease beta && git push --follow-tags && npm run build && npm publish --tag beta",
|
|
44
50
|
"release:beta:dry": "standard-version --release-as major --prerelease beta --dry-run",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"types": "tsc --noEmit",
|
|
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
|
-
"@prismicio/client": "^
|
|
54
|
-
"@prismicio/helpers": "^2.3.9",
|
|
55
|
-
"@prismicio/types": "^0.2.7",
|
|
60
|
+
"@prismicio/client": "^7.0.1",
|
|
56
61
|
"isomorphic-unfetch": "^3.1.0",
|
|
57
|
-
"vue-router": "^4.1
|
|
62
|
+
"vue-router": "^4.2.1"
|
|
58
63
|
},
|
|
59
64
|
"devDependencies": {
|
|
60
65
|
"@prismicio/mock": "^0.2.0",
|
|
61
66
|
"@size-limit/preset-small-lib": "^8.2.4",
|
|
67
|
+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
62
68
|
"@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.
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
70
|
+
"@typescript-eslint/parser": "^5.59.7",
|
|
71
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
72
|
+
"@vitest/coverage-c8": "^0.31.1",
|
|
73
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
68
74
|
"@vue/eslint-config-typescript": "^11.0.3",
|
|
69
75
|
"@vue/test-utils": "^2.3.2",
|
|
70
|
-
"eslint": "^8.
|
|
76
|
+
"eslint": "^8.41.0",
|
|
71
77
|
"eslint-config-prettier": "^8.8.0",
|
|
72
78
|
"eslint-plugin-prettier": "^4.2.1",
|
|
73
79
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
74
|
-
"eslint-plugin-vue": "^9.
|
|
80
|
+
"eslint-plugin-vue": "^9.14.0",
|
|
75
81
|
"jsdom": "^22.0.0",
|
|
76
82
|
"jsdom-global": "^3.0.2",
|
|
77
83
|
"prettier": "^2.8.8",
|
|
@@ -79,16 +85,16 @@
|
|
|
79
85
|
"size-limit": "^8.2.4",
|
|
80
86
|
"standard-version": "^9.5.0",
|
|
81
87
|
"typescript": "^5.0.4",
|
|
82
|
-
"vite": "^4.3.
|
|
88
|
+
"vite": "^4.3.8",
|
|
83
89
|
"vite-plugin-sdk": "^0.1.1",
|
|
84
|
-
"vitest": "^0.31.
|
|
85
|
-
"vue": "^3.
|
|
90
|
+
"vitest": "^0.31.1",
|
|
91
|
+
"vue": "^3.3.4"
|
|
86
92
|
},
|
|
87
93
|
"peerDependencies": {
|
|
88
94
|
"vue": "^3.0.0"
|
|
89
95
|
},
|
|
90
96
|
"engines": {
|
|
91
|
-
"node": ">=
|
|
97
|
+
"node": ">=16.10.0"
|
|
92
98
|
},
|
|
93
99
|
"publishConfig": {
|
|
94
100
|
"access": "public"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { EmbedField } from "@prismicio/client";
|
|
1
2
|
import {
|
|
2
3
|
AllowedComponentProps,
|
|
3
4
|
ComponentCustomProps,
|
|
4
5
|
ConcreteComponent,
|
|
5
6
|
DefineComponent,
|
|
6
|
-
defineComponent,
|
|
7
|
-
h,
|
|
8
7
|
PropType,
|
|
9
8
|
Raw,
|
|
10
9
|
VNodeProps,
|
|
10
|
+
defineComponent,
|
|
11
|
+
h,
|
|
11
12
|
} from "vue";
|
|
12
13
|
|
|
13
|
-
import { EmbedField } from "@prismicio/types";
|
|
14
14
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ImageField,
|
|
3
|
+
asImagePixelDensitySrcSet,
|
|
4
|
+
asImageSrc,
|
|
5
|
+
asImageWidthSrcSet,
|
|
6
|
+
isFilled,
|
|
7
|
+
} from "@prismicio/client";
|
|
1
8
|
import {
|
|
2
9
|
AllowedComponentProps,
|
|
3
10
|
ComponentCustomProps,
|
|
4
|
-
computed,
|
|
5
|
-
ConcreteComponent,
|
|
6
11
|
ComputedRef,
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
ConcreteComponent,
|
|
13
|
+
DefineComponent,
|
|
9
14
|
PropType,
|
|
15
|
+
Raw,
|
|
10
16
|
VNodeProps,
|
|
17
|
+
computed,
|
|
18
|
+
defineComponent,
|
|
19
|
+
h,
|
|
11
20
|
unref,
|
|
12
|
-
DefineComponent,
|
|
13
|
-
Raw,
|
|
14
21
|
} from "vue";
|
|
15
22
|
|
|
16
|
-
import { ImageField } from "@prismicio/types";
|
|
17
|
-
import {
|
|
18
|
-
asImageSrc,
|
|
19
|
-
asImageWidthSrcSet,
|
|
20
|
-
asImagePixelDensitySrcSet,
|
|
21
|
-
isFilled,
|
|
22
|
-
} from "@prismicio/helpers";
|
|
23
|
-
|
|
24
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
25
23
|
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
26
|
-
import {
|
|
24
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
25
|
+
|
|
27
26
|
import { VueUseOptions } from "../types";
|
|
28
27
|
|
|
28
|
+
import { usePrismic } from "../usePrismic";
|
|
29
|
+
|
|
29
30
|
/**
|
|
30
31
|
* The default component rendered for images.
|
|
31
32
|
*/
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LinkField,
|
|
3
|
+
LinkResolverFunction,
|
|
4
|
+
PrismicDocument,
|
|
5
|
+
asLink,
|
|
6
|
+
} from "@prismicio/client";
|
|
1
7
|
import {
|
|
2
8
|
AllowedComponentProps,
|
|
3
9
|
ComponentCustomProps,
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
ComputedRef,
|
|
11
|
+
ConcreteComponent,
|
|
12
|
+
DefineComponent,
|
|
6
13
|
PropType,
|
|
14
|
+
Raw,
|
|
7
15
|
VNodeProps,
|
|
8
|
-
unref,
|
|
9
|
-
reactive,
|
|
10
|
-
ConcreteComponent,
|
|
11
16
|
computed,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
defineComponent,
|
|
18
|
+
h,
|
|
19
|
+
reactive,
|
|
20
|
+
unref,
|
|
15
21
|
} from "vue";
|
|
16
22
|
|
|
17
|
-
import {
|
|
18
|
-
import { LinkField, PrismicDocument } from "@prismicio/types";
|
|
19
|
-
|
|
23
|
+
import { getSlots } from "../lib/getSlots";
|
|
20
24
|
import { isInternalURL } from "../lib/isInternalURL";
|
|
21
|
-
import { usePrismic } from "../usePrismic";
|
|
22
|
-
import { VueUseOptions } from "../types";
|
|
23
25
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
import { VueUseOptions } from "../types";
|
|
28
|
+
|
|
29
|
+
import { usePrismic } from "../usePrismic";
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* The default component rendered for internal URLs.
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HTMLFunctionSerializer,
|
|
3
|
+
HTMLMapSerializer,
|
|
4
|
+
LinkResolverFunction,
|
|
5
|
+
RichTextField,
|
|
6
|
+
asHTML,
|
|
7
|
+
isFilled,
|
|
8
|
+
} from "@prismicio/client";
|
|
1
9
|
import {
|
|
2
10
|
AllowedComponentProps,
|
|
3
11
|
Component,
|
|
4
12
|
ComponentCustomProps,
|
|
5
|
-
computed,
|
|
6
13
|
ComputedRef,
|
|
7
14
|
ConcreteComponent,
|
|
8
15
|
DefineComponent,
|
|
16
|
+
PropType,
|
|
17
|
+
Raw,
|
|
18
|
+
VNodeProps,
|
|
19
|
+
computed,
|
|
9
20
|
defineComponent,
|
|
10
21
|
h,
|
|
11
22
|
inject,
|
|
12
23
|
nextTick,
|
|
13
24
|
onBeforeUnmount,
|
|
14
|
-
PropType,
|
|
15
|
-
Raw,
|
|
16
25
|
ref,
|
|
17
26
|
unref,
|
|
18
|
-
VNodeProps,
|
|
19
27
|
watch,
|
|
20
28
|
} from "vue";
|
|
21
29
|
import { routerKey } from "vue-router";
|
|
22
30
|
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
HTMLFunctionSerializer,
|
|
26
|
-
HTMLMapSerializer,
|
|
27
|
-
isFilled,
|
|
28
|
-
LinkResolverFunction,
|
|
29
|
-
} from "@prismicio/helpers";
|
|
30
|
-
import { RichTextField } from "@prismicio/types";
|
|
31
|
+
import { isInternalURL } from "../lib/isInternalURL";
|
|
32
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
31
33
|
|
|
32
34
|
import { VueUseOptions } from "../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,23 @@
|
|
|
1
|
+
import { RichTextField, asText, isFilled } from "@prismicio/client";
|
|
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 { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* The default component rendered to wrap the text output.
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import { Slice } from "@prismicio/client";
|
|
1
2
|
import {
|
|
2
3
|
AllowedComponentProps,
|
|
3
4
|
ComponentCustomProps,
|
|
4
|
-
computed,
|
|
5
5
|
ConcreteComponent,
|
|
6
6
|
DefineComponent,
|
|
7
|
-
defineComponent,
|
|
8
7
|
FunctionalComponent,
|
|
9
|
-
h,
|
|
10
|
-
markRaw,
|
|
11
8
|
PropType,
|
|
12
9
|
Raw,
|
|
13
10
|
VNodeProps,
|
|
11
|
+
computed,
|
|
12
|
+
defineComponent,
|
|
13
|
+
h,
|
|
14
|
+
markRaw,
|
|
14
15
|
watchEffect,
|
|
15
16
|
} from "vue";
|
|
16
17
|
|
|
17
|
-
import { Slice } from "@prismicio/types";
|
|
18
|
-
|
|
19
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
20
18
|
import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
|
|
19
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent";
|
|
20
|
+
|
|
21
21
|
import { usePrismic } from "../usePrismic";
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -36,7 +36,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
|
|
|
36
36
|
* Rest API V2 for the `<SliceZone>` component.
|
|
37
37
|
*
|
|
38
38
|
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
39
|
-
* `@prismicio/
|
|
39
|
+
* `@prismicio/client` for a full interface.
|
|
40
40
|
*
|
|
41
41
|
* @typeParam TSliceType - Type name of the Slice.
|
|
42
42
|
*/
|
|
@@ -59,7 +59,7 @@ export type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
|
59
59
|
* The minimum required properties to represent a Prismic Slice for the
|
|
60
60
|
* `<SliceZone />` component.
|
|
61
61
|
*
|
|
62
|
-
* 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`
|
|
63
63
|
* for a full interface.
|
|
64
64
|
*
|
|
65
65
|
* @typeParam TSliceType - Type name of the Slice
|
|
@@ -69,11 +69,11 @@ export type SliceLike<TSliceType extends string = string> =
|
|
|
69
69
|
| SliceLikeGraphQL<TSliceType>;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* A looser version of the `SliceZone` type from `@prismicio/
|
|
72
|
+
* A looser version of the `SliceZone` type from `@prismicio/client` using
|
|
73
73
|
* `SliceLike`.
|
|
74
74
|
*
|
|
75
75
|
* If using Prismic's REST API, use the `SliceZone` export from
|
|
76
|
-
* `@prismicio/
|
|
76
|
+
* `@prismicio/client` for the full type.
|
|
77
77
|
*
|
|
78
78
|
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
79
79
|
*/
|
|
@@ -152,8 +152,9 @@ export type DefineComponentSliceComponentProps<
|
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* Gets native Vue props for a component rendering content from a Prismic Slice
|
|
155
|
-
* using the `<SliceZone />` component.
|
|
156
|
-
*
|
|
155
|
+
* using the `<SliceZone />` component.
|
|
156
|
+
*
|
|
157
|
+
* Props are: `["slice", "index", "slices", "context"]`
|
|
157
158
|
*
|
|
158
159
|
* @example Defining a new slice component:
|
|
159
160
|
*
|
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
|
-
import { PrismicDocument, Query } from "@prismicio/types";
|
|
6
|
+
import { PrismicDocument, Query } from "@prismicio/client";
|
|
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,
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
asText,
|
|
12
|
-
asHTML,
|
|
13
|
-
asLink,
|
|
4
|
+
LinkResolverFunction,
|
|
14
5
|
asDate,
|
|
6
|
+
asHTML,
|
|
7
|
+
asImagePixelDensitySrcSet,
|
|
15
8
|
asImageSrc,
|
|
16
9
|
asImageWidthSrcSet,
|
|
17
|
-
|
|
10
|
+
asLink,
|
|
11
|
+
asLinkAttrs,
|
|
12
|
+
asText,
|
|
13
|
+
cookie,
|
|
14
|
+
createClient,
|
|
18
15
|
documentToLinkField,
|
|
19
|
-
|
|
16
|
+
filter,
|
|
17
|
+
} from "@prismicio/client";
|
|
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.
|
|
@@ -67,22 +67,54 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
|
|
|
67
67
|
|
|
68
68
|
const prismicClient: PrismicPluginClient = {
|
|
69
69
|
client,
|
|
70
|
-
|
|
70
|
+
filter,
|
|
71
71
|
cookie,
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
// Create plugin helpers
|
|
75
75
|
const prismicHelpers: PrismicPluginHelpers = {
|
|
76
76
|
asText,
|
|
77
|
-
asHTML: (richTextField,
|
|
77
|
+
asHTML: (richTextField, ...config) => {
|
|
78
|
+
const [configOrLinkResolver, maybeHTMLSerializer] = config;
|
|
79
|
+
|
|
78
80
|
return asHTML(
|
|
79
81
|
richTextField,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
typeof configOrLinkResolver === "function" ||
|
|
83
|
+
configOrLinkResolver == null
|
|
84
|
+
? {
|
|
85
|
+
linkResolver: configOrLinkResolver || options.linkResolver,
|
|
86
|
+
serializer:
|
|
87
|
+
maybeHTMLSerializer ||
|
|
88
|
+
options.richTextSerializer ||
|
|
89
|
+
options.htmlSerializer,
|
|
90
|
+
}
|
|
91
|
+
: {
|
|
92
|
+
linkResolver: options.linkResolver,
|
|
93
|
+
serializer: options.richTextSerializer || options.htmlSerializer,
|
|
94
|
+
...config,
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
asLink: (linkField, config) => {
|
|
99
|
+
return asLink(
|
|
100
|
+
linkField,
|
|
101
|
+
typeof config === "function"
|
|
102
|
+
? { linkResolver: config }
|
|
103
|
+
: {
|
|
104
|
+
linkResolver: options.linkResolver,
|
|
105
|
+
// TODO: For some reasons, TypeScript narrows the type to "unknown" where it's supposed to be a union
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
...(config as any),
|
|
108
|
+
},
|
|
82
109
|
);
|
|
83
110
|
},
|
|
84
|
-
|
|
85
|
-
return
|
|
111
|
+
asLinkAttrs: (linkField, config) => {
|
|
112
|
+
return asLinkAttrs(linkField, {
|
|
113
|
+
// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
+
linkResolver: options.linkResolver as LinkResolverFunction<any>,
|
|
116
|
+
...config,
|
|
117
|
+
});
|
|
86
118
|
},
|
|
87
119
|
asDate,
|
|
88
120
|
asImageSrc,
|
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 */
|