@prismicio/vue 4.3.0 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/components/PrismicEmbed.cjs.map +1 -1
  2. package/dist/components/PrismicEmbed.d.ts +7 -7
  3. package/dist/components/PrismicEmbed.js.map +1 -1
  4. package/dist/components/PrismicImage.cjs.map +1 -1
  5. package/dist/components/PrismicImage.d.ts +10 -8
  6. package/dist/components/PrismicImage.js.map +1 -1
  7. package/dist/components/PrismicLink.cjs.map +1 -1
  8. package/dist/components/PrismicLink.d.ts +10 -8
  9. package/dist/components/PrismicLink.js.map +1 -1
  10. package/dist/components/PrismicRichText.cjs +5 -1
  11. package/dist/components/PrismicRichText.cjs.map +1 -1
  12. package/dist/components/PrismicRichText.d.ts +8 -8
  13. package/dist/components/PrismicRichText.js +6 -2
  14. package/dist/components/PrismicRichText.js.map +1 -1
  15. package/dist/components/PrismicText.cjs.map +1 -1
  16. package/dist/components/PrismicText.d.ts +8 -8
  17. package/dist/components/PrismicText.js.map +1 -1
  18. package/dist/components/SliceZone.cjs.map +1 -1
  19. package/dist/components/SliceZone.d.ts +14 -12
  20. package/dist/components/SliceZone.js.map +1 -1
  21. package/dist/components/index.d.ts +1 -1
  22. package/dist/composables.cjs.map +1 -1
  23. package/dist/composables.d.ts +20 -2
  24. package/dist/composables.js.map +1 -1
  25. package/dist/createPrismic.cjs.map +1 -1
  26. package/dist/createPrismic.js.map +1 -1
  27. package/dist/injectionSymbols.cjs.map +1 -1
  28. package/dist/injectionSymbols.js.map +1 -1
  29. package/dist/lib/__PRODUCTION__.cjs.map +1 -1
  30. package/dist/lib/__PRODUCTION__.js.map +1 -1
  31. package/dist/lib/getSlots.cjs +7 -5
  32. package/dist/lib/getSlots.cjs.map +1 -1
  33. package/dist/lib/getSlots.d.ts +2 -2
  34. package/dist/lib/getSlots.js +7 -5
  35. package/dist/lib/getSlots.js.map +1 -1
  36. package/dist/lib/isInternalURL.cjs.map +1 -1
  37. package/dist/lib/isInternalURL.js.map +1 -1
  38. package/dist/lib/simplyResolveComponent.cjs.map +1 -1
  39. package/dist/lib/simplyResolveComponent.d.ts +1 -1
  40. package/dist/lib/simplyResolveComponent.js.map +1 -1
  41. package/dist/types.d.ts +11 -2
  42. package/dist/usePrismic.cjs.map +1 -1
  43. package/dist/usePrismic.d.ts +5 -5
  44. package/dist/usePrismic.js.map +1 -1
  45. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
  46. package/dist/useStatefulPrismicClientMethod.d.ts +4 -3
  47. package/dist/useStatefulPrismicClientMethod.js.map +1 -1
  48. package/package.json +27 -28
  49. package/src/components/PrismicEmbed.ts +16 -17
  50. package/src/components/PrismicImage.ts +57 -59
  51. package/src/components/PrismicLink.ts +68 -70
  52. package/src/components/PrismicRichText.ts +71 -68
  53. package/src/components/PrismicText.ts +30 -32
  54. package/src/components/SliceZone.ts +94 -96
  55. package/src/components/index.ts +12 -16
  56. package/src/composables.ts +41 -23
  57. package/src/createPrismic.ts +40 -34
  58. package/src/globalExtensions.ts +2 -2
  59. package/src/index.ts +10 -10
  60. package/src/injectionSymbols.ts +4 -4
  61. package/src/lib/__PRODUCTION__.ts +2 -2
  62. package/src/lib/getSlots.ts +18 -12
  63. package/src/lib/isInternalURL.ts +4 -4
  64. package/src/lib/simplyResolveComponent.ts +4 -9
  65. package/src/types.ts +61 -52
  66. package/src/usePrismic.ts +9 -9
  67. package/src/useStatefulPrismicClientMethod.ts +42 -40
@@ -1,16 +1,16 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
2
  // Imports for @link references:
3
- import type { Client } from "@prismicio/client";
3
+ import type { Client } from "@prismicio/client"
4
4
 
5
5
  /* eslint-enable @typescript-eslint/no-unused-vars */
6
- import { PrismicDocument, Query } from "@prismicio/client";
6
+ import type { PrismicDocument, Query } from "@prismicio/client"
7
7
 
8
- import {
8
+ import type {
9
9
  ClientComposableReturnType,
10
10
  ClientMethodParameters,
11
11
  ComposableOnlyParameters,
12
- useStatefulPrismicClientMethod,
13
- } from "./useStatefulPrismicClientMethod";
12
+ } from "./useStatefulPrismicClientMethod"
13
+ import { useStatefulPrismicClientMethod } from "./useStatefulPrismicClientMethod"
14
14
 
15
15
  // Composables
16
16
 
@@ -20,6 +20,7 @@ import {
20
20
  * @remarks
21
21
  * An additional `@prismicio/client` instance can be provided at
22
22
  * `params.client`.
23
+ *
23
24
  * @typeParam TDocument - Type of Prismic documents returned
24
25
  *
25
26
  * @param params - Parameters to filter, sort, and paginate results
@@ -33,7 +34,7 @@ export const usePrismicDocuments = <TDocument extends PrismicDocument>(
33
34
  params?: ClientMethodParameters<"get">[0] & ComposableOnlyParameters,
34
35
  ]
35
36
  ): ClientComposableReturnType<Query<TDocument>> =>
36
- useStatefulPrismicClientMethod("get", args);
37
+ useStatefulPrismicClientMethod("get", args)
37
38
 
38
39
  /**
39
40
  * A composable that queries content from the Prismic repository and returns
@@ -42,6 +43,7 @@ export const usePrismicDocuments = <TDocument extends PrismicDocument>(
42
43
  * @remarks
43
44
  * An additional `@prismicio/client` instance can be provided at
44
45
  * `params.client`.
46
+ *
45
47
  * @typeParam TDocument - Type of the Prismic document returned
46
48
  *
47
49
  * @param params - Parameters to filter, sort, and paginate results
@@ -55,7 +57,7 @@ export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
55
57
  params?: ClientMethodParameters<"getFirst">[0] & ComposableOnlyParameters,
56
58
  ]
57
59
  ): ClientComposableReturnType<TDocument> =>
58
- useStatefulPrismicClientMethod("getFirst", args);
60
+ useStatefulPrismicClientMethod("getFirst", args)
59
61
 
60
62
  /**
61
63
  * A composable that queries a document from the Prismic repository with a
@@ -64,6 +66,7 @@ export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
64
66
  * @remarks
65
67
  * An additional `@prismicio/client` instance can be provided at
66
68
  * `params.client`.
69
+ *
67
70
  * @typeParam TDocument - Type of the Prismic document returned
68
71
  *
69
72
  * @param id - ID of the document
@@ -79,7 +82,7 @@ export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
79
82
  params?: ClientMethodParameters<"getByID">[1] & ComposableOnlyParameters,
80
83
  ]
81
84
  ): ClientComposableReturnType<TDocument> =>
82
- useStatefulPrismicClientMethod("getByID", args);
85
+ useStatefulPrismicClientMethod("getByID", args)
83
86
 
84
87
  /**
85
88
  * A composable that queries documents from the Prismic repository with specific
@@ -88,6 +91,7 @@ export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
88
91
  * @remarks
89
92
  * An additional `@prismicio/client` instance can be provided at
90
93
  * `params.client`.
94
+ *
91
95
  * @typeParam TDocument - Type of Prismic documents returned
92
96
  *
93
97
  * @param ids - A list of document IDs
@@ -103,7 +107,7 @@ export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
103
107
  params?: ClientMethodParameters<"getByIDs">[1] & ComposableOnlyParameters,
104
108
  ]
105
109
  ): ClientComposableReturnType<Query<TDocument>> =>
106
- useStatefulPrismicClientMethod("getByIDs", args);
110
+ useStatefulPrismicClientMethod("getByIDs", args)
107
111
 
108
112
  /**
109
113
  * A composable that queries all documents from the Prismic repository with
@@ -112,6 +116,7 @@ export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
112
116
  * @remarks
113
117
  * An additional `@prismicio/client` instance can be provided at
114
118
  * `params.client`.
119
+ *
115
120
  * @typeParam TDocument - Type of Prismic documents returned
116
121
  *
117
122
  * @param ids - A list of document IDs
@@ -128,7 +133,7 @@ export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
128
133
  ComposableOnlyParameters,
129
134
  ]
130
135
  ): ClientComposableReturnType<TDocument[]> =>
131
- useStatefulPrismicClientMethod("getAllByIDs", args);
136
+ useStatefulPrismicClientMethod("getAllByIDs", args)
132
137
 
133
138
  /**
134
139
  * A composable that queries a document from the Prismic repository with a
@@ -137,6 +142,7 @@ export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
137
142
  * @remarks
138
143
  * An additional `@prismicio/client` instance can be provided at
139
144
  * `params.client`.
145
+ *
140
146
  * @typeParam TDocument - Type of the Prismic document returned
141
147
  *
142
148
  * @param documentType - The API ID of the document's Custom Type
@@ -154,7 +160,7 @@ export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
154
160
  params?: ClientMethodParameters<"getByUID">[2] & ComposableOnlyParameters,
155
161
  ]
156
162
  ): ClientComposableReturnType<TDocument> =>
157
- useStatefulPrismicClientMethod("getByUID", args);
163
+ useStatefulPrismicClientMethod("getByUID", args)
158
164
 
159
165
  /**
160
166
  * A composable that queries documents from the Prismic repository with specific
@@ -163,6 +169,7 @@ export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
163
169
  * @remarks
164
170
  * An additional `@prismicio/client` instance can be provided at
165
171
  * `params.client`.
172
+ *
166
173
  * @typeParam TDocument - Type of Prismic documents returned
167
174
  *
168
175
  * @param documentType - The API ID of the document's Custom Type
@@ -180,7 +187,7 @@ export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
180
187
  params?: ClientMethodParameters<"getByUIDs">[2] & ComposableOnlyParameters,
181
188
  ]
182
189
  ): ClientComposableReturnType<Query<TDocument>> =>
183
- useStatefulPrismicClientMethod("getByUIDs", args);
190
+ useStatefulPrismicClientMethod("getByUIDs", args)
184
191
 
185
192
  /**
186
193
  * A composable that queries all documents from the Prismic repository with
@@ -189,6 +196,7 @@ export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
189
196
  * @remarks
190
197
  * An additional `@prismicio/client` instance can be provided at
191
198
  * `params.client`.
199
+ *
192
200
  * @typeParam TDocument - Type of Prismic documents returned
193
201
  *
194
202
  * @param documentType - The API ID of the document's Custom Type
@@ -207,7 +215,7 @@ export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
207
215
  ComposableOnlyParameters,
208
216
  ]
209
217
  ): ClientComposableReturnType<TDocument[]> =>
210
- useStatefulPrismicClientMethod("getAllByUIDs", args);
218
+ useStatefulPrismicClientMethod("getAllByUIDs", args)
211
219
 
212
220
  /**
213
221
  * A composable that queries a singleton document from the Prismic repository
@@ -216,6 +224,7 @@ export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
216
224
  * @remarks
217
225
  * An additional `@prismicio/client` instance can be provided at
218
226
  * `params.client`.
227
+ *
219
228
  * @typeParam TDocument - Type of the Prismic document returned
220
229
  *
221
230
  * @param documentType - The API ID of the singleton Custom Type
@@ -231,7 +240,7 @@ export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
231
240
  params?: ClientMethodParameters<"getSingle">[1] & ComposableOnlyParameters,
232
241
  ]
233
242
  ): ClientComposableReturnType<TDocument> =>
234
- useStatefulPrismicClientMethod("getSingle", args);
243
+ useStatefulPrismicClientMethod("getSingle", args)
235
244
 
236
245
  /**
237
246
  * A composable that queries documents from the Prismic repository for a
@@ -240,6 +249,7 @@ export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
240
249
  * @remarks
241
250
  * An additional `@prismicio/client` instance can be provided at
242
251
  * `params.client`.
252
+ *
243
253
  * @typeParam TDocument - Type of Prismic documents returned
244
254
  *
245
255
  * @param documentType - The API ID of the Custom Type
@@ -255,7 +265,7 @@ export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
255
265
  params?: ClientMethodParameters<"getByType">[1] & ComposableOnlyParameters,
256
266
  ]
257
267
  ): ClientComposableReturnType<Query<TDocument>> =>
258
- useStatefulPrismicClientMethod("getByType", args);
268
+ useStatefulPrismicClientMethod("getByType", args)
259
269
 
260
270
  /**
261
271
  * A composable that queries all documents from the Prismic repository for a
@@ -264,6 +274,7 @@ export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
264
274
  * @remarks
265
275
  * An additional `@prismicio/client` instance can be provided at
266
276
  * `params.client`.
277
+ *
267
278
  * @typeParam TDocument - Type of Prismic documents returned
268
279
  *
269
280
  * @param documentType - The API ID of the Custom Type
@@ -280,7 +291,7 @@ export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
280
291
  ComposableOnlyParameters,
281
292
  ]
282
293
  ): ClientComposableReturnType<TDocument[]> =>
283
- useStatefulPrismicClientMethod("getAllByType", args);
294
+ useStatefulPrismicClientMethod("getAllByType", args)
284
295
 
285
296
  /**
286
297
  * A composable that queries documents from the Prismic repository with a
@@ -289,6 +300,7 @@ export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
289
300
  * @remarks
290
301
  * An additional `@prismicio/client` instance can be provided at
291
302
  * `params.client`.
303
+ *
292
304
  * @typeParam TDocument - Type of Prismic documents returned
293
305
  *
294
306
  * @param tag - The tag that must be included on a document
@@ -304,7 +316,7 @@ export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
304
316
  params?: ClientMethodParameters<"getByTag">[1] & ComposableOnlyParameters,
305
317
  ]
306
318
  ): ClientComposableReturnType<Query<TDocument>> =>
307
- useStatefulPrismicClientMethod("getByTag", args);
319
+ useStatefulPrismicClientMethod("getByTag", args)
308
320
 
309
321
  /**
310
322
  * A composable that queries all documents from the Prismic repository with a
@@ -313,6 +325,7 @@ export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
313
325
  * @remarks
314
326
  * An additional `@prismicio/client` instance can be provided at
315
327
  * `params.client`.
328
+ *
316
329
  * @typeParam TDocument - Type of Prismic documents returned
317
330
  *
318
331
  * @param tag - The tag that must be included on a document
@@ -329,7 +342,7 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
329
342
  ComposableOnlyParameters,
330
343
  ]
331
344
  ): ClientComposableReturnType<TDocument[]> =>
332
- useStatefulPrismicClientMethod("getAllByTag", args);
345
+ useStatefulPrismicClientMethod("getAllByTag", args)
333
346
 
334
347
  /**
335
348
  * A composable that queries documents from the Prismic repository with specific
@@ -338,6 +351,7 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
338
351
  * @remarks
339
352
  * An additional `@prismicio/client` instance can be provided at
340
353
  * `params.client`.
354
+ *
341
355
  * @typeParam TDocument - Type of Prismic documents returned
342
356
  *
343
357
  * @param tags - A list of tags that must be included on a document
@@ -356,7 +370,7 @@ export const usePrismicDocumentsByEveryTag = <
356
370
  ComposableOnlyParameters,
357
371
  ]
358
372
  ): ClientComposableReturnType<Query<TDocument>> =>
359
- useStatefulPrismicClientMethod("getByEveryTag", args);
373
+ useStatefulPrismicClientMethod("getByEveryTag", args)
360
374
 
361
375
  /**
362
376
  * A composable that queries all documents from the Prismic repository with
@@ -366,6 +380,7 @@ export const usePrismicDocumentsByEveryTag = <
366
380
  * @remarks
367
381
  * An additional `@prismicio/client` instance can be provided at
368
382
  * `params.client`.
383
+ *
369
384
  * @typeParam TDocument - Type of Prismic documents returned
370
385
  *
371
386
  * @param tags - A list of tags that must be included on a document
@@ -384,7 +399,7 @@ export const useAllPrismicDocumentsByEveryTag = <
384
399
  ComposableOnlyParameters,
385
400
  ]
386
401
  ): ClientComposableReturnType<TDocument[]> =>
387
- useStatefulPrismicClientMethod("getAllByEveryTag", args);
402
+ useStatefulPrismicClientMethod("getAllByEveryTag", args)
388
403
 
389
404
  /**
390
405
  * A composable that queries documents from the Prismic repository with specific
@@ -394,6 +409,7 @@ export const useAllPrismicDocumentsByEveryTag = <
394
409
  * @remarks
395
410
  * An additional `@prismicio/client` instance can be provided at
396
411
  * `params.client`.
412
+ *
397
413
  * @typeParam TDocument - Type of Prismic documents returned
398
414
  *
399
415
  * @param tags - A list of tags that must be included on a document
@@ -412,7 +428,7 @@ export const usePrismicDocumentsBySomeTags = <
412
428
  ComposableOnlyParameters,
413
429
  ]
414
430
  ): ClientComposableReturnType<Query<TDocument>> =>
415
- useStatefulPrismicClientMethod("getBySomeTags", args);
431
+ useStatefulPrismicClientMethod("getBySomeTags", args)
416
432
 
417
433
  /**
418
434
  * A composable that queries all documents from the Prismic repository with
@@ -422,6 +438,7 @@ export const usePrismicDocumentsBySomeTags = <
422
438
  * @remarks
423
439
  * An additional `@prismicio/client` instance can be provided at
424
440
  * `params.client`.
441
+ *
425
442
  * @typeParam TDocument - Type of Prismic documents returned
426
443
  *
427
444
  * @param tags - A list of tags that must be included on a document
@@ -440,7 +457,7 @@ export const useAllPrismicDocumentsBySomeTags = <
440
457
  ComposableOnlyParameters,
441
458
  ]
442
459
  ): ClientComposableReturnType<TDocument[]> =>
443
- useStatefulPrismicClientMethod("getAllBySomeTags", args);
460
+ useStatefulPrismicClientMethod("getAllBySomeTags", args)
444
461
 
445
462
  /**
446
463
  * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be
@@ -455,6 +472,7 @@ export const useAllPrismicDocumentsBySomeTags = <
455
472
  * @remarks
456
473
  * An additional `@prismicio/client` instance can be provided at
457
474
  * `params.client`.
475
+ *
458
476
  * @typeParam TDocument - Type of Prismic documents returned
459
477
  *
460
478
  * @param params - Parameters to filter and sort results
@@ -471,4 +489,4 @@ export const dangerouslyUseAllPrismicDocuments = <
471
489
  ComposableOnlyParameters,
472
490
  ]
473
491
  ): ClientComposableReturnType<TDocument[]> =>
474
- useStatefulPrismicClientMethod("dangerouslyGetAll", args);
492
+ useStatefulPrismicClientMethod("dangerouslyGetAll", args)
@@ -1,7 +1,11 @@
1
- import {
1
+ import type {
2
2
  Client,
3
3
  FetchLike,
4
+ HTMLRichTextFunctionSerializer,
5
+ HTMLRichTextMapSerializer,
4
6
  LinkResolverFunction,
7
+ } from "@prismicio/client"
8
+ import {
5
9
  asDate,
6
10
  asHTML,
7
11
  asImagePixelDensitySrcSet,
@@ -15,15 +19,15 @@ import {
15
19
  documentToLinkField,
16
20
  filter,
17
21
  isFilled,
18
- } from "@prismicio/client";
19
- import { App } from "vue";
22
+ } from "@prismicio/client"
23
+ import type { App } from "vue"
20
24
 
21
25
  import type {
22
26
  PrismicPlugin,
23
27
  PrismicPluginClient,
24
28
  PrismicPluginHelpers,
25
29
  PrismicPluginOptions,
26
- } from "./types";
30
+ } from "./types"
27
31
 
28
32
  import {
29
33
  PrismicEmbed,
@@ -32,8 +36,8 @@ import {
32
36
  PrismicRichText,
33
37
  PrismicText,
34
38
  SliceZone,
35
- } from "./components";
36
- import { prismicKey } from "./injectionSymbols";
39
+ } from "./components"
40
+ import { prismicKey } from "./injectionSymbols"
37
41
 
38
42
  /**
39
43
  * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.
@@ -47,36 +51,36 @@ import { prismicKey } from "./injectionSymbols";
47
51
  */
48
52
  export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
49
53
  // Create plugin client
50
- let client: Client;
54
+ let client: Client
51
55
  if (options.client) {
52
- client = options.client;
56
+ client = options.client
53
57
  } else {
54
58
  client = createClient(options.endpoint, {
55
59
  fetch: async (endpoint, options) => {
56
- let fetchFunction: FetchLike;
60
+ let fetchFunction: FetchLike
57
61
  if (typeof globalThis.fetch === "function") {
58
- fetchFunction = globalThis.fetch;
62
+ fetchFunction = globalThis.fetch
59
63
  } else {
60
- fetchFunction = (await import("isomorphic-unfetch")).default;
64
+ fetchFunction = (await import("isomorphic-unfetch")).default
61
65
  }
62
66
 
63
- return await fetchFunction(endpoint, options);
67
+ return await fetchFunction(endpoint, options)
64
68
  },
65
69
  ...options.clientConfig,
66
- });
70
+ })
67
71
  }
68
72
 
69
73
  const prismicClient: PrismicPluginClient = {
70
74
  client,
71
75
  filter,
72
76
  cookie,
73
- };
77
+ }
74
78
 
75
79
  // Create plugin helpers
76
80
  const prismicHelpers: PrismicPluginHelpers = {
77
81
  asText,
78
82
  asHTML: (richTextField, ...config) => {
79
- const [configOrLinkResolver, maybeHTMLSerializer] = config;
83
+ const [configOrLinkResolver, maybeHTMLSerializer] = config
80
84
 
81
85
  return asHTML(
82
86
  richTextField,
@@ -85,16 +89,18 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
85
89
  ? {
86
90
  linkResolver: configOrLinkResolver || options.linkResolver,
87
91
  serializer:
88
- maybeHTMLSerializer ||
92
+ (maybeHTMLSerializer as
93
+ | HTMLRichTextFunctionSerializer
94
+ | HTMLRichTextMapSerializer) ||
89
95
  options.richTextSerializer ||
90
96
  options.htmlSerializer,
91
- }
97
+ }
92
98
  : {
93
99
  linkResolver: options.linkResolver,
94
100
  serializer: options.richTextSerializer || options.htmlSerializer,
95
101
  ...configOrLinkResolver,
96
- },
97
- );
102
+ },
103
+ )
98
104
  },
99
105
  asLink: (linkField, config) => {
100
106
  return asLink(
@@ -106,8 +112,8 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
106
112
  // TODO: For some reasons, TypeScript narrows the type to "unknown" where it's supposed to be a union
107
113
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
114
  ...(config as any),
109
- },
110
- );
115
+ },
116
+ )
111
117
  },
112
118
  asLinkAttrs: (linkField, config) => {
113
119
  return asLinkAttrs(linkField, {
@@ -115,7 +121,7 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
115
121
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
122
  linkResolver: options.linkResolver as LinkResolverFunction<any>,
117
123
  ...config,
118
- });
124
+ })
119
125
  },
120
126
  asDate,
121
127
  asImageSrc,
@@ -123,7 +129,7 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
123
129
  asImagePixelDensitySrcSet,
124
130
  isFilled,
125
131
  documentToLinkField,
126
- };
132
+ }
127
133
 
128
134
  // Create plugin interface
129
135
  const prismic: PrismicPlugin = {
@@ -133,19 +139,19 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
133
139
  ...prismicHelpers,
134
140
 
135
141
  install(app: App): void {
136
- app.provide(prismicKey, this);
137
- app.config.globalProperties.$prismic = this;
142
+ app.provide(prismicKey, this)
143
+ app.config.globalProperties.$prismic = this
138
144
 
139
145
  if (options.injectComponents !== false) {
140
- app.component(PrismicLink.name, PrismicLink);
141
- app.component(PrismicEmbed.name, PrismicEmbed);
142
- app.component(PrismicImage.name, PrismicImage);
143
- app.component(PrismicText.name, PrismicText);
144
- app.component(PrismicRichText.name, PrismicRichText);
145
- app.component(SliceZone.name, SliceZone);
146
+ app.component(PrismicLink.name, PrismicLink)
147
+ app.component(PrismicEmbed.name, PrismicEmbed)
148
+ app.component(PrismicImage.name, PrismicImage)
149
+ app.component(PrismicText.name, PrismicText)
150
+ app.component(PrismicRichText.name, PrismicRichText)
151
+ app.component(SliceZone.name, SliceZone)
146
152
  }
147
153
  },
148
- };
154
+ }
149
155
 
150
- return prismic;
151
- };
156
+ return prismic
157
+ }
@@ -1,4 +1,4 @@
1
- import type { PrismicPlugin } from "./types";
1
+ import type { PrismicPlugin } from "./types"
2
2
 
3
3
  declare module "vue" {
4
4
  export interface ComponentCustomProperties {
@@ -7,6 +7,6 @@ declare module "vue" {
7
7
  *
8
8
  * @see `@prismicio/vue` plugin interface {@link PrismicPlugin}
9
9
  */
10
- $prismic: PrismicPlugin;
10
+ $prismic: PrismicPlugin
11
11
  }
12
12
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { createPrismic } from "./createPrismic";
2
- export { usePrismic } from "./usePrismic";
1
+ export { createPrismic } from "./createPrismic"
2
+ export { usePrismic } from "./usePrismic"
3
3
 
4
4
  export {
5
5
  // Composables
@@ -18,7 +18,7 @@ export {
18
18
  TODOSliceComponent,
19
19
  defineSliceZoneComponents,
20
20
  SliceZone,
21
- } from "./components";
21
+ } from "./components"
22
22
  export type {
23
23
  // Composables
24
24
  UsePrismicImageOptions,
@@ -42,7 +42,7 @@ export type {
42
42
  SliceZoneResolver,
43
43
  SliceZoneLike,
44
44
  SliceZoneProps,
45
- } from "./components";
45
+ } from "./components"
46
46
 
47
47
  export {
48
48
  useAllPrismicDocumentsByIDs,
@@ -63,13 +63,13 @@ export {
63
63
  usePrismicDocumentsByType,
64
64
  useSinglePrismicDocument,
65
65
  dangerouslyUseAllPrismicDocuments,
66
- } from "./composables";
66
+ } from "./composables"
67
67
 
68
- export type { ClientComposableReturnType } from "./useStatefulPrismicClientMethod";
68
+ export type { ClientComposableReturnType } from "./useStatefulPrismicClientMethod"
69
69
 
70
- export { PrismicClientComposableState } from "./types";
71
- export type { PrismicPluginOptions, PrismicPlugin } from "./types";
70
+ export { PrismicClientComposableState } from "./types"
71
+ export type { PrismicPluginOptions, PrismicPlugin } from "./types"
72
72
 
73
- export { prismicKey } from "./injectionSymbols";
73
+ export { prismicKey } from "./injectionSymbols"
74
74
 
75
- export * from "./globalExtensions";
75
+ export * from "./globalExtensions"
@@ -1,10 +1,10 @@
1
- import type { InjectionKey } from "vue";
1
+ import type { InjectionKey } from "vue"
2
2
 
3
- import type { PrismicPlugin } from "./types";
3
+ import type { PrismicPlugin } from "./types"
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-unused-vars */
6
6
  // Imports for @link references:
7
- import type { usePrismic } from "./usePrismic";
7
+ import type { usePrismic } from "./usePrismic"
8
8
 
9
9
  /* eslint-enable @typescript-eslint/no-unused-vars */
10
10
 
@@ -14,4 +14,4 @@ import type { usePrismic } from "./usePrismic";
14
14
  *
15
15
  * @internal
16
16
  */
17
- export const prismicKey = Symbol("prismic") as InjectionKey<PrismicPlugin>;
17
+ export const prismicKey = Symbol("prismic") as InjectionKey<PrismicPlugin>
@@ -1,6 +1,6 @@
1
1
  // We need to polyfill process if it doesn't exist, such as in the browser.
2
2
  if (typeof process === "undefined") {
3
- globalThis.process = { env: {} } as typeof process;
3
+ globalThis.process = { env: {} } as typeof process
4
4
  }
5
5
 
6
6
  /**
@@ -9,4 +9,4 @@ if (typeof process === "undefined") {
9
9
  * This boolean can be used to perform actions only in development environments,
10
10
  * such as logging.
11
11
  */
12
- export const __PRODUCTION__ = process.env.NODE_ENV === "production";
12
+ export const __PRODUCTION__ = process.env.NODE_ENV === "production"
@@ -1,4 +1,11 @@
1
- import { ConcreteComponent, Slots, VNode } from "vue";
1
+ import {
2
+ type ConcreteComponent,
3
+ type Slot,
4
+ type Slots,
5
+ Text,
6
+ type VNode,
7
+ h,
8
+ } from "vue"
2
9
 
3
10
  /**
4
11
  * Get the appropriate `slots` object/array according to the provided parent,
@@ -17,21 +24,20 @@ export const getSlots = (
17
24
  slots: Slots,
18
25
  defaultPayload?: unknown,
19
26
  fallback?: string,
20
- ): VNode[] | undefined | Slots | string => {
27
+ ): VNode[] | Slots | Slot | undefined => {
28
+ const fallbackSlot = fallback ? () => [h(Text, fallback)] : undefined
21
29
  if (typeof parent === "string") {
22
- return slots.default ? slots.default(defaultPayload) : fallback;
30
+ return slots.default ? slots.default(defaultPayload) : fallbackSlot?.()
23
31
  } else {
24
32
  if (slots.default) {
25
- const content = slots.default(defaultPayload);
33
+ const content = slots.default(defaultPayload)
26
34
 
27
- return content.length
28
- ? {
29
- ...slots,
30
- default: () => content,
31
- }
32
- : fallback;
35
+ return {
36
+ ...slots,
37
+ default: content.length ? () => content : fallbackSlot,
38
+ }
33
39
  } else {
34
- return fallback;
40
+ return fallbackSlot
35
41
  }
36
42
  }
37
- };
43
+ }
@@ -10,11 +10,11 @@ export const isInternalURL = (url: string): boolean => {
10
10
  /**
11
11
  * @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
12
12
  */
13
- const isInternal = /^\/(?!\/)/.test(url);
13
+ const isInternal = /^\/(?!\/)/.test(url)
14
14
  /**
15
15
  * @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1}
16
16
  */
17
- const isSpecialLink = !isInternal && !/^https?:\/\//i.test(url);
17
+ const isSpecialLink = !isInternal && !/^https?:\/\//i.test(url)
18
18
 
19
- return isInternal && !isSpecialLink;
20
- };
19
+ return isInternal && !isSpecialLink
20
+ }
@@ -1,10 +1,5 @@
1
- import {
2
- ConcreteComponent,
3
- DefineComponent,
4
- Raw,
5
- VNode,
6
- resolveDynamicComponent,
7
- } from "vue";
1
+ import type { ConcreteComponent, DefineComponent, Raw, VNode } from "vue"
2
+ import { resolveDynamicComponent } from "vue"
8
3
 
9
4
  /**
10
5
  * A stricter version of {@link resolveDynamicComponent} that resolves only type
@@ -19,5 +14,5 @@ import {
19
14
  export const simplyResolveComponent = (
20
15
  component: string | ConcreteComponent | Raw<DefineComponent>,
21
16
  ): string | VNode => {
22
- return resolveDynamicComponent(component) as string | VNode;
23
- };
17
+ return resolveDynamicComponent(component) as string | VNode
18
+ }