@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.
Files changed (61) hide show
  1. package/dist/components/PrismicEmbed.cjs.map +1 -1
  2. package/dist/components/PrismicEmbed.d.ts +2 -2
  3. package/dist/components/PrismicEmbed.js.map +1 -1
  4. package/dist/components/PrismicImage.cjs +6 -6
  5. package/dist/components/PrismicImage.cjs.map +1 -1
  6. package/dist/components/PrismicImage.d.ts +3 -4
  7. package/dist/components/PrismicImage.js +2 -2
  8. package/dist/components/PrismicImage.js.map +1 -1
  9. package/dist/components/PrismicLink.cjs +4 -4
  10. package/dist/components/PrismicLink.cjs.map +1 -1
  11. package/dist/components/PrismicLink.d.ts +5 -6
  12. package/dist/components/PrismicLink.js +3 -3
  13. package/dist/components/PrismicLink.js.map +1 -1
  14. package/dist/components/PrismicRichText.cjs +5 -5
  15. package/dist/components/PrismicRichText.cjs.map +1 -1
  16. package/dist/components/PrismicRichText.d.ts +8 -9
  17. package/dist/components/PrismicRichText.js +3 -3
  18. package/dist/components/PrismicRichText.js.map +1 -1
  19. package/dist/components/PrismicText.cjs +3 -3
  20. package/dist/components/PrismicText.cjs.map +1 -1
  21. package/dist/components/PrismicText.d.ts +2 -2
  22. package/dist/components/PrismicText.js +1 -1
  23. package/dist/components/PrismicText.js.map +1 -1
  24. package/dist/components/SliceZone.cjs +1 -1
  25. package/dist/components/SliceZone.cjs.map +1 -1
  26. package/dist/components/SliceZone.d.ts +10 -9
  27. package/dist/components/SliceZone.js +1 -1
  28. package/dist/components/SliceZone.js.map +1 -1
  29. package/dist/composables.cjs.map +1 -1
  30. package/dist/composables.d.ts +19 -1
  31. package/dist/composables.js.map +1 -1
  32. package/dist/createPrismic.cjs +32 -12
  33. package/dist/createPrismic.cjs.map +1 -1
  34. package/dist/createPrismic.js +27 -7
  35. package/dist/createPrismic.js.map +1 -1
  36. package/dist/injectionSymbols.cjs.map +1 -1
  37. package/dist/injectionSymbols.js.map +1 -1
  38. package/dist/lib/simplyResolveComponent.cjs.map +1 -1
  39. package/dist/lib/simplyResolveComponent.js.map +1 -1
  40. package/dist/types.d.ts +29 -20
  41. package/dist/usePrismic.cjs.map +1 -1
  42. package/dist/usePrismic.js.map +1 -1
  43. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
  44. package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
  45. package/dist/useStatefulPrismicClientMethod.js.map +1 -1
  46. package/package.json +30 -24
  47. package/src/components/PrismicEmbed.ts +3 -3
  48. package/src/components/PrismicImage.ts +17 -16
  49. package/src/components/PrismicLink.ts +19 -14
  50. package/src/components/PrismicRichText.ts +15 -14
  51. package/src/components/PrismicText.ts +6 -7
  52. package/src/components/SliceZone.ts +14 -13
  53. package/src/composables.ts +3 -6
  54. package/src/createPrismic.ts +56 -24
  55. package/src/injectionSymbols.ts +0 -2
  56. package/src/lib/simplyResolveComponent.ts +1 -1
  57. package/src/types.ts +45 -39
  58. package/src/usePrismic.ts +2 -1
  59. package/src/useStatefulPrismicClientMethod.ts +3 -3
  60. package/vetur/attributes.json +1 -6
  61. package/vetur/tags.json +17 -3
package/src/types.ts CHANGED
@@ -1,29 +1,25 @@
1
- import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue";
2
-
3
1
  import type {
4
- Client,
5
2
  ClientConfig,
6
- cookie,
7
- predicate,
8
- } from "@prismicio/client";
9
- import type {
10
- asText,
11
- asHTML,
12
- asLink,
13
- asDate,
14
- documentToLinkField,
15
- HTMLFunctionSerializer,
16
- HTMLMapSerializer,
3
+ CreateClient,
4
+ HTMLRichTextFunctionSerializer,
5
+ HTMLRichTextMapSerializer,
17
6
  LinkResolverFunction,
7
+ asDate,
8
+ asHTML,
9
+ asImagePixelDensitySrcSet,
18
10
  asImageSrc,
19
11
  asImageWidthSrcSet,
20
- asImagePixelDensitySrcSet,
21
- } from "@prismicio/helpers";
12
+ asLink,
13
+ asLinkAttrs,
14
+ asText,
15
+ cookie,
16
+ documentToLinkField,
17
+ filter,
18
+ } from "@prismicio/client";
19
+ import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue";
22
20
 
23
21
  /* eslint-disable @typescript-eslint/no-unused-vars */
24
-
25
22
  // Imports for @link references:
26
-
27
23
  import type { RouterLink } from "vue-router";
28
24
 
29
25
  import type {
@@ -95,7 +91,7 @@ type PrismicPluginComponentsOptions = {
95
91
  * Consider configuring image widths within your content type definition and
96
92
  * using `widths="auto"` instead to give content writers the ability to crop
97
93
  * images in the editor.
98
- * @defaultValue `@prismicio/helpers` defaults
94
+ * @defaultValue `@prismicio/client` defaults
99
95
  */
100
96
  imageWidthSrcSetDefaults?: number[];
101
97
 
@@ -103,7 +99,7 @@ type PrismicPluginComponentsOptions = {
103
99
  * Default pixel densities to use when rendering an image with
104
100
  * `pixel-densities="defaults"`
105
101
  *
106
- * @defaultValue `@prismicio/helpers` defaults
102
+ * @defaultValue `@prismicio/client` defaults
107
103
  */
108
104
  imagePixelDensitySrcSetDefaults?: number[];
109
105
 
@@ -138,7 +134,9 @@ type PrismicPluginOptionsBase = {
138
134
  *
139
135
  * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
140
136
  */
141
- richTextSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
137
+ richTextSerializer?:
138
+ | HTMLRichTextFunctionSerializer
139
+ | HTMLRichTextMapSerializer;
142
140
 
143
141
  /**
144
142
  * An optional HTML serializer to customize the way rich text fields are
@@ -149,7 +147,7 @@ type PrismicPluginOptionsBase = {
149
147
  * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
150
148
  */
151
149
  // TODO: Remove in v5
152
- htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
150
+ htmlSerializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer;
153
151
 
154
152
  /**
155
153
  * Whether or not to inject components globally.
@@ -182,7 +180,7 @@ type PrismicPluginOptionsWithClient = PrismicPluginOptionsBase & {
182
180
  * `usePrismic().client`.
183
181
  * @see Prismic client documentation {@link https://prismic.io/docs/technologies/javascript}
184
182
  */
185
- client: Client;
183
+ client: ReturnType<CreateClient>;
186
184
 
187
185
  /**
188
186
  * Ensures type union is a strict or.
@@ -287,12 +285,12 @@ export type PrismicPluginClient = {
287
285
  /**
288
286
  * A `@prismicio/client` instance.
289
287
  */
290
- client: Client;
288
+ client: ReturnType<CreateClient>;
291
289
 
292
290
  /**
293
- * Query predicates from `@prismicio/client`.
291
+ * Query filters from `@prismicio/client`.
294
292
  */
295
- predicate: typeof predicate;
293
+ filter: typeof filter;
296
294
 
297
295
  /**
298
296
  * Prismic cookies from `@prismicio/client`.
@@ -301,13 +299,13 @@ export type PrismicPluginClient = {
301
299
  };
302
300
 
303
301
  /**
304
- * `@prismicio/helpers` related methods exposed by `@prismicio/vue` plugin and
302
+ * `@prismicio/client` related methods exposed by `@prismicio/vue` plugin and
305
303
  * accessible through `this.$prismic` and `usePrismic()`.
306
304
  */
307
305
  export type PrismicPluginHelpers = {
308
306
  /**
309
307
  * Serializes a rich text or title field to a plain text string. This is
310
- * `@prismicio/helpers` {@link asText} function.
308
+ * `@prismicio/client` {@link asText} function.
311
309
  *
312
310
  * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
313
311
  */
@@ -315,7 +313,7 @@ export type PrismicPluginHelpers = {
315
313
 
316
314
  /**
317
315
  * Serializes a rich text or title field to an HTML string. This is
318
- * `@prismicio/helpers` {@link asHTML} function.
316
+ * `@prismicio/client` {@link asHTML} function.
319
317
  *
320
318
  * @remarks
321
319
  * If no `linkResolver` is provided the function will use the one provided to
@@ -329,34 +327,42 @@ export type PrismicPluginHelpers = {
329
327
 
330
328
  /**
331
329
  * Resolves any type of link field or document to a URL. This is
332
- * `@prismicio/helpers` {@link asLink} function.
330
+ * `@prismicio/client` {@link asLink} function.
331
+ *
332
+ * @remarks
333
+ * If no `linkResolver` is provided the function will use the one provided to
334
+ * the plugin at {@link PrismicPluginOptions.linkResolver} if available.
335
+ * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
336
+ */
337
+ asLink: typeof asLink;
338
+
339
+ /**
340
+ * Resolves any type of link field or document to a set of link attributes.
341
+ * This is `@prismicio/client` {@link asLinkAttrs} function.
333
342
  *
334
343
  * @remarks
335
344
  * If no `linkResolver` is provided the function will use the one provided to
336
345
  * the plugin at {@link PrismicPluginOptions.linkResolver} if available.
337
346
  * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
338
347
  */
339
- asLink: (
340
- linkField: Parameters<typeof asLink>[0],
341
- linkResolver?: LinkResolverFunction,
342
- ) => string | null;
348
+ asLinkAttrs: typeof asLinkAttrs;
343
349
 
344
350
  /**
345
351
  * Transforms a date or timestamp field into a JavaScript Date object. This is
346
- * `@prismicio/helpers` {@link asDate} function.
352
+ * `@prismicio/client` {@link asDate} function.
347
353
  */
348
354
  asDate: typeof asDate;
349
355
 
350
356
  /**
351
357
  * Returns the URL of an Image field with optional image transformations (via
352
- * Imgix URL parameters). This is `@prismicio/helpers` {@link asImageSrc}
358
+ * Imgix URL parameters). This is `@prismicio/client` {@link asImageSrc}
353
359
  * function.
354
360
  */
355
361
  asImageSrc: typeof asImageSrc;
356
362
 
357
363
  /**
358
364
  * Creates a width-based `srcset` from an Image field with optional image
359
- * transformations (via Imgix URL parameters). This is `@prismicio/helpers`
365
+ * transformations (via Imgix URL parameters). This is `@prismicio/client`
360
366
  * {@link asImageWidthSrcSet} function.
361
367
  */
362
368
  asImageWidthSrcSet: typeof asImageWidthSrcSet;
@@ -364,12 +370,12 @@ export type PrismicPluginHelpers = {
364
370
  /**
365
371
  * Creates a pixel-density-based `srcset` from an Image field with optional
366
372
  * image transformations (via Imgix URL parameters). This is
367
- * `@prismicio/helpers` {@link asImagePixelDensitySrcSet} function.
373
+ * `@prismicio/client` {@link asImagePixelDensitySrcSet} function.
368
374
  */
369
375
  asImagePixelDensitySrcSet: typeof asImagePixelDensitySrcSet;
370
376
 
371
377
  /**
372
- * Converts a document into a link field. This is `@prismicio/helpers`
378
+ * Converts a document into a link field. This is `@prismicio/client`
373
379
  * {@link documentToLinkField} function.
374
380
  *
375
381
  * @internal
package/src/usePrismic.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { inject } from "vue";
2
2
 
3
- import { prismicKey } from "./injectionSymbols";
4
3
  import { PrismicPlugin } from "./types";
5
4
 
5
+ import { prismicKey } from "./injectionSymbols";
6
+
6
7
  /**
7
8
  * Accesses `@prismicio/vue` plugin interface.
8
9
  *
@@ -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
@@ -7,7 +7,6 @@
7
7
  "type": "string | object | function",
8
8
  "description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
9
9
  },
10
-
11
10
  "prismic-image/field": {
12
11
  "type": "object",
13
12
  "description": "The Prismic image field to render."
@@ -28,7 +27,6 @@
28
27
  "type": "array | string",
29
28
  "description": "Adds an additional `srcset` attribute to the image following giving pixel densities."
30
29
  },
31
-
32
30
  "prismic-link/field": {
33
31
  "type": "object",
34
32
  "description": "The Prismic link field or document to render."
@@ -57,7 +55,6 @@
57
55
  "type": "string | object | function",
58
56
  "description": "An HTML tag name, a component, or a functional component used to render external links. Defaults to the one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise."
59
57
  },
60
-
61
58
  "prismic-rich-text/field": {
62
59
  "type": "array",
63
60
  "description": "The Prismic rich text or title field to render."
@@ -66,7 +63,7 @@
66
63
  "type": "function",
67
64
  "description": "A link resolver function used to resolve links when not using the route resolver parameter with `@prismicio/client`. Defaults to the link resolver provided to `@prismicio/vue` plugin if configured."
68
65
  },
69
- "prismic-rich-text/html-serializer": {
66
+ "prismic-rich-text/serializer": {
70
67
  "type": "function | object",
71
68
  "description": "An HTML serializer to customize the way rich text fields are rendered. Defaults to the HTML serializer provided to `@prismicio/vue` plugin if configured."
72
69
  },
@@ -78,7 +75,6 @@
78
75
  "type": "string",
79
76
  "description": "The HTML value to be rendered when the field is empty. If a fallback is not given, `\"\"` (nothing) will be rendered."
80
77
  },
81
-
82
78
  "prismic-text/field": {
83
79
  "type": "array",
84
80
  "description": "The Prismic rich text or title field to render."
@@ -95,7 +91,6 @@
95
91
  "type": "string",
96
92
  "description": "The string value to be rendered when the field is empty. If a fallback is not given, `\"\"` (nothing) will be rendered."
97
93
  },
98
-
99
94
  "slice-zone/slices": {
100
95
  "type": "array",
101
96
  "description": "List of Slice data from the Slice Zone."
package/vetur/tags.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "prismic-embed": {
3
- "attributes": ["field", "wrapper"],
3
+ "attributes": [
4
+ "field",
5
+ "wrapper"
6
+ ],
4
7
  "description": "Component to render a Prismic embed field."
5
8
  },
6
9
  "prismic-image": {
@@ -26,11 +29,22 @@
26
29
  "description": "Component to render a Prismic link field."
27
30
  },
28
31
  "prismic-rich-text": {
29
- "attributes": ["field", "link-resolver", "html-serializer", "wrapper", "fallback"],
32
+ "attributes": [
33
+ "field",
34
+ "link-resolver",
35
+ "serializer",
36
+ "wrapper",
37
+ "fallback"
38
+ ],
30
39
  "description": "Component to render a Prismic rich text field as HTML."
31
40
  },
32
41
  "prismic-text": {
33
- "attributes": ["field", "separator", "wrapper", "fallback"],
42
+ "attributes": [
43
+ "field",
44
+ "separator",
45
+ "wrapper",
46
+ "fallback"
47
+ ],
34
48
  "description": "Component to render a Prismic rich text field as plain text."
35
49
  },
36
50
  "slice-zone": {