@prismicio/vue 3.1.0 → 3.1.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.
- package/dist/components/PrismicEmbed.cjs +36 -0
- package/dist/components/PrismicEmbed.cjs.map +1 -0
- package/dist/components/PrismicEmbed.d.ts +63 -0
- package/dist/components/PrismicEmbed.js +36 -0
- package/dist/components/PrismicEmbed.js.map +1 -0
- package/dist/components/PrismicImage.cjs +122 -0
- package/dist/components/PrismicImage.cjs.map +1 -0
- package/dist/components/PrismicImage.d.ts +162 -0
- package/dist/components/PrismicImage.js +122 -0
- package/dist/components/PrismicImage.js.map +1 -0
- package/dist/components/PrismicLink.cjs +115 -0
- package/dist/components/PrismicLink.cjs.map +1 -0
- package/dist/components/PrismicLink.d.ts +191 -0
- package/dist/components/PrismicLink.js +115 -0
- package/dist/components/PrismicLink.js.map +1 -0
- package/dist/components/PrismicRichText.cjs +103 -0
- package/dist/components/PrismicRichText.cjs.map +1 -0
- package/dist/components/PrismicRichText.d.ts +139 -0
- package/dist/components/PrismicRichText.js +103 -0
- package/dist/components/PrismicRichText.js.map +1 -0
- package/dist/components/PrismicText.cjs +57 -0
- package/dist/components/PrismicText.cjs.map +1 -0
- package/dist/components/PrismicText.d.ts +117 -0
- package/dist/components/PrismicText.js +57 -0
- package/dist/components/PrismicText.js.map +1 -0
- package/dist/components/SliceZone.cjs +134 -0
- package/dist/components/SliceZone.cjs.map +1 -0
- package/dist/components/SliceZone.d.ts +359 -0
- package/dist/components/SliceZone.js +134 -0
- package/dist/components/SliceZone.js.map +1 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/composables.cjs +40 -0
- package/dist/composables.cjs.map +1 -0
- package/dist/composables.d.ts +366 -0
- package/dist/composables.js +40 -0
- package/dist/composables.js.map +1 -0
- package/dist/createPrismic.cjs +87 -0
- package/dist/createPrismic.cjs.map +1 -0
- package/dist/createPrismic.d.ts +12 -0
- package/dist/createPrismic.js +69 -0
- package/dist/createPrismic.js.map +1 -0
- package/dist/globalExtensions.d.ts +11 -0
- package/dist/index.cjs +46 -764
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -1404
- package/dist/index.js +45 -707
- package/dist/index.js.map +1 -1
- package/dist/injectionSymbols.cjs +5 -0
- package/dist/injectionSymbols.cjs.map +1 -0
- package/dist/injectionSymbols.d.ts +9 -0
- package/dist/injectionSymbols.js +5 -0
- package/dist/injectionSymbols.js.map +1 -0
- package/dist/lib/__PRODUCTION__.cjs +8 -0
- package/dist/lib/__PRODUCTION__.cjs.map +1 -0
- package/dist/lib/__PRODUCTION__.d.ts +7 -0
- package/dist/lib/__PRODUCTION__.js +8 -0
- package/dist/lib/__PRODUCTION__.js.map +1 -0
- package/dist/lib/getSlots.cjs +19 -0
- package/dist/lib/getSlots.cjs.map +1 -0
- package/dist/lib/getSlots.d.ts +14 -0
- package/dist/lib/getSlots.js +19 -0
- package/dist/lib/getSlots.js.map +1 -0
- package/dist/lib/isInternalURL.cjs +9 -0
- package/dist/lib/isInternalURL.cjs.map +1 -0
- package/dist/lib/isInternalURL.d.ts +8 -0
- package/dist/lib/isInternalURL.js +9 -0
- package/dist/lib/isInternalURL.js.map +1 -0
- package/dist/lib/simplyResolveComponent.cjs +8 -0
- package/dist/lib/simplyResolveComponent.cjs.map +1 -0
- package/dist/lib/simplyResolveComponent.d.ts +12 -0
- package/dist/lib/simplyResolveComponent.js +8 -0
- package/dist/lib/simplyResolveComponent.js.map +1 -0
- package/dist/types.d.ts +357 -0
- package/dist/usePrismic.cjs +9 -0
- package/dist/usePrismic.cjs.map +1 -0
- package/dist/usePrismic.d.ts +21 -0
- package/dist/usePrismic.js +9 -0
- package/dist/usePrismic.js.map +1 -0
- package/dist/useStatefulPrismicClientMethod.cjs +36 -0
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -0
- package/dist/useStatefulPrismicClientMethod.d.ts +64 -0
- package/dist/useStatefulPrismicClientMethod.js +36 -0
- package/dist/useStatefulPrismicClientMethod.js.map +1 -0
- package/package.json +28 -28
- package/src/components/PrismicEmbed.ts +2 -1
- package/src/components/PrismicImage.ts +8 -5
- package/src/components/PrismicLink.ts +4 -2
- package/src/components/PrismicRichText.ts +4 -2
- package/src/components/PrismicText.ts +6 -3
- package/src/components/SliceZone.ts +12 -7
- package/src/composables.ts +56 -46
- package/src/injectionSymbols.ts +2 -1
- package/src/types.ts +14 -7
- package/src/useStatefulPrismicClientMethod.ts +6 -3
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import type { App, ConcreteComponent, 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
|
+
import type { SliceComponentType } from "./components/SliceZone";
|
|
5
|
+
/**
|
|
6
|
+
* Options used by `@prismicio/vue` components.
|
|
7
|
+
*/
|
|
8
|
+
type PrismicPluginComponentsOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Value of the `rel` attribute to use on links rendered with
|
|
11
|
+
* `target="_blank"`
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue `"noopener noreferrer"`
|
|
14
|
+
*/
|
|
15
|
+
linkBlankTargetRelAttribute?: string;
|
|
16
|
+
/**
|
|
17
|
+
* An HTML tag name, a component, or a functional component used to render
|
|
18
|
+
* internal links.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* HTML tag names will be rendered using the anchor tag interface (`href`,
|
|
22
|
+
* `target`, and `rel` attributes).
|
|
23
|
+
* @remarks
|
|
24
|
+
* Components will be rendered using Vue Router {@link RouterLink} interface
|
|
25
|
+
* (`to` props).
|
|
26
|
+
* @defaultValue {@link RouterLink}
|
|
27
|
+
*/
|
|
28
|
+
linkInternalComponent?: string | ConcreteComponent;
|
|
29
|
+
/**
|
|
30
|
+
* An HTML tag name, a component, or a functional component used to render
|
|
31
|
+
* external links.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* HTML tag names will be rendered using the anchor tag interface (`href`,
|
|
35
|
+
* `target`, and `rel` attributes).
|
|
36
|
+
* @remarks
|
|
37
|
+
* Components will be rendered using Vue Router {@link RouterLink} interface
|
|
38
|
+
* (`to` props).
|
|
39
|
+
* @defaultValue `"a"`
|
|
40
|
+
*/
|
|
41
|
+
linkExternalComponent?: string | ConcreteComponent;
|
|
42
|
+
/**
|
|
43
|
+
* An HTML tag name, a component, or a functional component used to render
|
|
44
|
+
* images.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* HTML tag names and components will be rendered using the `img` tag
|
|
48
|
+
* interface (`src` and `alt` attribute). Components will also receive an
|
|
49
|
+
* additional `copyright` props.
|
|
50
|
+
* @defaultValue `"img"`
|
|
51
|
+
*/
|
|
52
|
+
imageComponent?: string | ConcreteComponent;
|
|
53
|
+
/**
|
|
54
|
+
* Default widths to use when rendering an image with `widths="defaults"`
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Consider configuring image widths within your content type definition and
|
|
58
|
+
* using `widths="auto"` instead to give content writers the ability to crop
|
|
59
|
+
* images in the editor.
|
|
60
|
+
* @defaultValue `@prismicio/helpers` defaults
|
|
61
|
+
*/
|
|
62
|
+
imageWidthSrcSetDefaults?: number[];
|
|
63
|
+
/**
|
|
64
|
+
* Default pixel densities to use when rendering an image with
|
|
65
|
+
* `pixel-densities="defaults"`
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue `@prismicio/helpers` defaults
|
|
68
|
+
*/
|
|
69
|
+
imagePixelDensitySrcSetDefaults?: number[];
|
|
70
|
+
/**
|
|
71
|
+
* A component or a functional component rendered if a component mapping from
|
|
72
|
+
* the `components` prop cannot be found.
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* Components will be rendered using the {@link SliceComponentProps} interface.
|
|
76
|
+
*
|
|
77
|
+
* @defaultValue `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}
|
|
78
|
+
*/
|
|
79
|
+
sliceZoneDefaultComponent?: SliceComponentType;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Common options supported by `@prismicio/vue` plugin.
|
|
83
|
+
*/
|
|
84
|
+
type PrismicPluginOptionsBase = {
|
|
85
|
+
/**
|
|
86
|
+
* An optional link resolver function used to resolve links to Prismic
|
|
87
|
+
* documents when not using the route resolver parameter with
|
|
88
|
+
* `@prismicio/client`.
|
|
89
|
+
*
|
|
90
|
+
* @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
|
|
91
|
+
*/
|
|
92
|
+
linkResolver?: LinkResolverFunction;
|
|
93
|
+
/**
|
|
94
|
+
* An optional HTML serializer to customize the way rich text fields are
|
|
95
|
+
* rendered.
|
|
96
|
+
*
|
|
97
|
+
* @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
98
|
+
*/
|
|
99
|
+
htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
|
|
100
|
+
/**
|
|
101
|
+
* Whether or not to inject components globally.
|
|
102
|
+
*
|
|
103
|
+
* @defaultValue `true`
|
|
104
|
+
*/
|
|
105
|
+
injectComponents?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Options used by Prismic Vue components.
|
|
108
|
+
*
|
|
109
|
+
* @see Components options {@link PrismicPluginComponentsOptions}
|
|
110
|
+
*/
|
|
111
|
+
components?: PrismicPluginComponentsOptions;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Options to init `@prismicio/vue` plugin with a client instance.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link PrismicPluginOptionsBase} for shared options
|
|
117
|
+
*/
|
|
118
|
+
type PrismicPluginOptionsWithClient = PrismicPluginOptionsBase & {
|
|
119
|
+
/**
|
|
120
|
+
* A `@prismicio/client` instance used to fetch content from a Prismic
|
|
121
|
+
* repository to configure the plugin with.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* The client will be used by `@prismicio/vue` composables, such as
|
|
125
|
+
* {@link usePrismicDocuments} and exposed through `this.$prismic.client` and
|
|
126
|
+
* `usePrismic().client`.
|
|
127
|
+
* @see Prismic client documentation {@link https://prismic.io/docs/technologies/javascript}
|
|
128
|
+
*/
|
|
129
|
+
client: Client;
|
|
130
|
+
/**
|
|
131
|
+
* Ensures type union is a strict or.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
endpoint?: never;
|
|
136
|
+
/**
|
|
137
|
+
* Ensures type union is a strict or.
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
clientConfig?: never;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Options to init `@prismicio/vue` plugin with a repository ID or API endpoint.
|
|
145
|
+
*
|
|
146
|
+
* @see {@link PrismicPluginOptionsBase} for shared options
|
|
147
|
+
*/
|
|
148
|
+
type PrismicPluginOptionsWithEndpoint = PrismicPluginOptionsBase & {
|
|
149
|
+
/**
|
|
150
|
+
* A Prismic repository endpoint to init the plugin's `@prismicio/client`
|
|
151
|
+
* instance used to fetch content from a Prismic repository with.
|
|
152
|
+
*
|
|
153
|
+
* @remarks
|
|
154
|
+
* Said client will be used by `@prismicio/vue` composables, such as
|
|
155
|
+
* {@link usePrismicDocuments} and exposed through `this.$prismic.client` and
|
|
156
|
+
* `usePrismic().client`.
|
|
157
|
+
* @example A repository ID:
|
|
158
|
+
*
|
|
159
|
+
* "my-repo";
|
|
160
|
+
*
|
|
161
|
+
* @example A full repository endpoint:
|
|
162
|
+
*
|
|
163
|
+
* "https://my-repo.cdn.prismic.io/api/v2";
|
|
164
|
+
*
|
|
165
|
+
* @see Prismic client documentation {@link https://prismic.io/docs/technologies/javascript}
|
|
166
|
+
*/
|
|
167
|
+
endpoint: string;
|
|
168
|
+
/**
|
|
169
|
+
* An optional object to configure `@prismicio/client` instance further.
|
|
170
|
+
*
|
|
171
|
+
* @example Accessing a private private repository:
|
|
172
|
+
*
|
|
173
|
+
* ```javascript
|
|
174
|
+
* {
|
|
175
|
+
* "accessToken": "abc"
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @example Using a route resolver:
|
|
180
|
+
*
|
|
181
|
+
* ```javascript
|
|
182
|
+
* {
|
|
183
|
+
* "defaultParams": {
|
|
184
|
+
* "routes": [
|
|
185
|
+
* {
|
|
186
|
+
* "type": "page",
|
|
187
|
+
* "path": "/:uid"
|
|
188
|
+
* },
|
|
189
|
+
* {
|
|
190
|
+
* "type": "post",
|
|
191
|
+
* "path": "/blog/:uid"
|
|
192
|
+
* }
|
|
193
|
+
* ]
|
|
194
|
+
* }
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @see Prismic client documentation {@link https://prismic.io/docs/technologies/javascript}
|
|
199
|
+
* @see Route resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
200
|
+
*/
|
|
201
|
+
clientConfig?: ClientConfig;
|
|
202
|
+
/**
|
|
203
|
+
* Ensures type union is a strict or.
|
|
204
|
+
*
|
|
205
|
+
* @internal
|
|
206
|
+
*/
|
|
207
|
+
client?: never;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* `@prismicio/vue` plugin options.
|
|
211
|
+
*
|
|
212
|
+
* @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}
|
|
213
|
+
* @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}
|
|
214
|
+
*/
|
|
215
|
+
export type PrismicPluginOptions = PrismicPluginOptionsWithClient | PrismicPluginOptionsWithEndpoint;
|
|
216
|
+
/**
|
|
217
|
+
* `@prismicio/client` related methods and properties exposed by
|
|
218
|
+
* `@prismicio/vue` plugin and accessible through `this.$prismic` and
|
|
219
|
+
* `usePrismic()`.
|
|
220
|
+
*/
|
|
221
|
+
export type PrismicPluginClient = {
|
|
222
|
+
/**
|
|
223
|
+
* A `@prismicio/client` instance.
|
|
224
|
+
*/
|
|
225
|
+
client: Client;
|
|
226
|
+
/**
|
|
227
|
+
* Query predicates from `@prismicio/client`.
|
|
228
|
+
*/
|
|
229
|
+
predicate: typeof predicate;
|
|
230
|
+
/**
|
|
231
|
+
* Prismic cookies from `@prismicio/client`.
|
|
232
|
+
*/
|
|
233
|
+
cookie: typeof cookie;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* `@prismicio/helpers` related methods exposed by `@prismicio/vue` plugin and
|
|
237
|
+
* accessible through `this.$prismic` and `usePrismic()`.
|
|
238
|
+
*/
|
|
239
|
+
export type PrismicPluginHelpers = {
|
|
240
|
+
/**
|
|
241
|
+
* Serializes a rich text or title field to a plain text string. This is
|
|
242
|
+
* `@prismicio/helpers` {@link asText} function.
|
|
243
|
+
*
|
|
244
|
+
* @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
|
|
245
|
+
*/
|
|
246
|
+
asText: typeof asText;
|
|
247
|
+
/**
|
|
248
|
+
* Serializes a rich text or title field to an HTML string. This is
|
|
249
|
+
* `@prismicio/helpers` {@link asHTML} function.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* If no `linkResolver` is provided the function will use the one provided to
|
|
253
|
+
* the plugin at {@link PrismicPluginOptions.linkResolver} if available.
|
|
254
|
+
* @remarks
|
|
255
|
+
* If no `htmlSerializer` is provided the function will use the one provided
|
|
256
|
+
* to the plugin at {@link PrismicPluginOptions.htmlSerializer} if available.
|
|
257
|
+
* @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
|
|
258
|
+
*/
|
|
259
|
+
asHTML: typeof asHTML;
|
|
260
|
+
/**
|
|
261
|
+
* Resolves any type of link field or document to a URL. This is
|
|
262
|
+
* `@prismicio/helpers` {@link asLink} function.
|
|
263
|
+
*
|
|
264
|
+
* @remarks
|
|
265
|
+
* If no `linkResolver` is provided the function will use the one provided to
|
|
266
|
+
* the plugin at {@link PrismicPluginOptions.linkResolver} if available.
|
|
267
|
+
* @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
|
|
268
|
+
*/
|
|
269
|
+
asLink: (linkField: Parameters<typeof asLink>[0], linkResolver?: LinkResolverFunction) => string | null;
|
|
270
|
+
/**
|
|
271
|
+
* Transforms a date or timestamp field into a JavaScript Date object. This is
|
|
272
|
+
* `@prismicio/helpers` {@link asDate} function.
|
|
273
|
+
*/
|
|
274
|
+
asDate: typeof asDate;
|
|
275
|
+
/**
|
|
276
|
+
* Returns the URL of an Image field with optional image transformations (via
|
|
277
|
+
* Imgix URL parameters). This is `@prismicio/helpers` {@link asImageSrc}
|
|
278
|
+
* function.
|
|
279
|
+
*/
|
|
280
|
+
asImageSrc: typeof asImageSrc;
|
|
281
|
+
/**
|
|
282
|
+
* Creates a width-based `srcset` from an Image field with optional image
|
|
283
|
+
* transformations (via Imgix URL parameters). This is `@prismicio/helpers`
|
|
284
|
+
* {@link asImageWidthSrcSet} function.
|
|
285
|
+
*/
|
|
286
|
+
asImageWidthSrcSet: typeof asImageWidthSrcSet;
|
|
287
|
+
/**
|
|
288
|
+
* Creates a pixel-density-based `srcset` from an Image field with optional
|
|
289
|
+
* image transformations (via Imgix URL parameters). This is
|
|
290
|
+
* `@prismicio/helpers` {@link asImagePixelDensitySrcSet} function.
|
|
291
|
+
*/
|
|
292
|
+
asImagePixelDensitySrcSet: typeof asImagePixelDensitySrcSet;
|
|
293
|
+
/**
|
|
294
|
+
* Converts a document into a link field. This is `@prismicio/helpers`
|
|
295
|
+
* {@link documentToLinkField} function.
|
|
296
|
+
*
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
documentToLinkField: typeof documentToLinkField;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Methods and properties exposed by `@prismicio/vue` plugin and accessible
|
|
303
|
+
* through `this.$prismic` and `usePrismic()`.
|
|
304
|
+
*/
|
|
305
|
+
export type PrismicPlugin = {
|
|
306
|
+
/**
|
|
307
|
+
* Options uses to initialize the plugin.
|
|
308
|
+
*
|
|
309
|
+
* @see `@prismicio/vue` plugin options {@link PrismicPluginOptions}
|
|
310
|
+
*/
|
|
311
|
+
readonly options: PrismicPluginOptions;
|
|
312
|
+
/**
|
|
313
|
+
* `@prismicio/vue` plugin install function used by Vue.
|
|
314
|
+
*
|
|
315
|
+
* @internal
|
|
316
|
+
*/
|
|
317
|
+
install: (app: App) => void;
|
|
318
|
+
} & PrismicPluginClient & PrismicPluginHelpers;
|
|
319
|
+
/**
|
|
320
|
+
* States of a `@prismicio/client` composable.
|
|
321
|
+
*/
|
|
322
|
+
export declare const enum PrismicClientComposableState {
|
|
323
|
+
/**
|
|
324
|
+
* The composable has not started fetching.
|
|
325
|
+
*/
|
|
326
|
+
Idle = "idle",
|
|
327
|
+
/**
|
|
328
|
+
* The composable is fetching data.
|
|
329
|
+
*/
|
|
330
|
+
Pending = "pending",
|
|
331
|
+
/**
|
|
332
|
+
* The composable sucessfully fetched data.
|
|
333
|
+
*/
|
|
334
|
+
Success = "success",
|
|
335
|
+
/**
|
|
336
|
+
* The composable failed to fetch data.
|
|
337
|
+
*/
|
|
338
|
+
Error = "error"
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Type to transform a static object into one that allows passing Refs as
|
|
342
|
+
* values.
|
|
343
|
+
*
|
|
344
|
+
* @internal
|
|
345
|
+
*/
|
|
346
|
+
export type VueUseOptions<T> = {
|
|
347
|
+
[K in keyof T]: Ref<T[K]> | T[K];
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Type to transform a static tuple into one that allows passing Refs as values.
|
|
351
|
+
*
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
export type VueUseParameters<T> = {
|
|
355
|
+
[K in keyof T]: T extends number ? Ref<T[K]> | T[K] : T[K];
|
|
356
|
+
};
|
|
357
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const injectionSymbols = require("./injectionSymbols.cjs");
|
|
5
|
+
const usePrismic = () => {
|
|
6
|
+
return vue.inject(injectionSymbols.prismicKey, { options: { endpoint: "" } });
|
|
7
|
+
};
|
|
8
|
+
exports.usePrismic = usePrismic;
|
|
9
|
+
//# sourceMappingURL=usePrismic.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrismic.cjs","sources":["../../src/usePrismic.ts"],"sourcesContent":["import { inject } from \"vue\";\n\nimport { prismicKey } from \"./injectionSymbols\";\nimport { PrismicPlugin } from \"./types\";\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":";;;;AAwBO,MAAM,aAAa,MAAoB;AACtC,SAAAA,IAAAA,OAAOC,iBAAAA,YAAY,EAAE,SAAS,EAAE,UAAU,MAAuB;AACzE;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PrismicPlugin } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Accesses `@prismicio/vue` plugin interface.
|
|
4
|
+
*
|
|
5
|
+
* @example With the composition API:
|
|
6
|
+
*
|
|
7
|
+
* ```javascript
|
|
8
|
+
* import { usePrismic } from "@prismicio/vue";
|
|
9
|
+
*
|
|
10
|
+
* export default {
|
|
11
|
+
* setup() {
|
|
12
|
+
* const prismic = usePrismic();
|
|
13
|
+
*
|
|
14
|
+
* return {};
|
|
15
|
+
* },
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @returns The interface {@link PrismicPlugin}
|
|
20
|
+
*/
|
|
21
|
+
export declare const usePrismic: () => PrismicPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrismic.js","sources":["../../src/usePrismic.ts"],"sourcesContent":["import { inject } from \"vue\";\n\nimport { prismicKey } from \"./injectionSymbols\";\nimport { PrismicPlugin } from \"./types\";\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":";;AAwBO,MAAM,aAAa,MAAoB;AACtC,SAAA,OAAO,YAAY,EAAE,SAAS,EAAE,UAAU,MAAuB;AACzE;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const usePrismic = require("./usePrismic.cjs");
|
|
5
|
+
const isParams = (value) => {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
};
|
|
8
|
+
const useStatefulPrismicClientMethod = (methodName, args) => {
|
|
9
|
+
const { client } = usePrismic.usePrismic();
|
|
10
|
+
const state = vue.ref("idle");
|
|
11
|
+
const data = vue.shallowRef(null);
|
|
12
|
+
const error = vue.ref(null);
|
|
13
|
+
const refresh = async () => {
|
|
14
|
+
const lastArg = vue.unref(args[args.length - 1]);
|
|
15
|
+
const { client: explicitClient, ...params } = isParams(lastArg) ? lastArg : {};
|
|
16
|
+
const argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;
|
|
17
|
+
state.value = "pending";
|
|
18
|
+
data.value = null;
|
|
19
|
+
error.value = null;
|
|
20
|
+
try {
|
|
21
|
+
data.value = await (vue.unref(explicitClient) || client)[methodName](...argsWithoutParams.map((arg) => vue.unref(arg)), params);
|
|
22
|
+
state.value = "success";
|
|
23
|
+
} catch (err) {
|
|
24
|
+
state.value = "error";
|
|
25
|
+
error.value = err;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const refArgs = args.filter((arg) => vue.isRef(arg));
|
|
29
|
+
if (refArgs.length) {
|
|
30
|
+
vue.watch(refArgs, refresh, { deep: true });
|
|
31
|
+
}
|
|
32
|
+
refresh();
|
|
33
|
+
return { state, data, error, refresh };
|
|
34
|
+
};
|
|
35
|
+
exports.useStatefulPrismicClientMethod = useStatefulPrismicClientMethod;
|
|
36
|
+
//# sourceMappingURL=useStatefulPrismicClientMethod.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.cjs","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import { isRef, ref, Ref, shallowRef, unref, watch } from \"vue\";\n\nimport {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\n\nimport { usePrismic } from \"./usePrismic\";\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\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;AAEb,QAAA,QAAQC,QAAG,MAAA;AAGX,QAAA,OAAOC,eAA2C,IAAI;AACtD,QAAA,QAAQD,QAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAUE,IAAAA,MAAM,KAAK,KAAK,SAAS,EAAE;AACrC,UAAA,EAAE,QAAQ,mBAAmB,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,YAElC,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;;"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
import { Client, ForbiddenError, ParsingError, PrismicError } from "@prismicio/client";
|
|
3
|
+
import { PrismicClientComposableState, VueUseParameters } from "./types";
|
|
4
|
+
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
5
|
+
type ClientMethodLike = (...args: any[]) => Promise<any> | any;
|
|
6
|
+
type ClientMethods = typeof Client.prototype;
|
|
7
|
+
type ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export type ClientMethodParameters<TMethodName extends keyof ClientMethods> = ClientMethods[TMethodName] extends ClientMethodLike ? VueUseParameters<Parameters<ClientMethods[TMethodName]>> : never;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export type ClientMethodReturnType<TMethodName extends keyof ClientMethods> = ClientMethods[TMethodName] extends ClientMethodLike ? ReturnType<ClientMethods[TMethodName]> : never;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export type ComposableOnlyParameters = {
|
|
20
|
+
client?: Ref<Client> | Client;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The return type of a `@prismicio/client` Vue composable.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TData - The expected format of the `data` property of the returned
|
|
26
|
+
* object
|
|
27
|
+
*/
|
|
28
|
+
export type ClientComposableReturnType<TData = unknown> = {
|
|
29
|
+
/**
|
|
30
|
+
* The current state of the composable's client method call.
|
|
31
|
+
*/
|
|
32
|
+
state: Ref<PrismicClientComposableState>;
|
|
33
|
+
/**
|
|
34
|
+
* Data returned by the client.
|
|
35
|
+
*/
|
|
36
|
+
data: Ref<TData | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Error returned by the composable's client method call if in an errror
|
|
39
|
+
* state.
|
|
40
|
+
*/
|
|
41
|
+
error: Ref<ClientError | Error | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Perform the composable's client method call again.
|
|
44
|
+
*/
|
|
45
|
+
refresh: () => Promise<void>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A low level Vue composable that uses provided method name on plugin or
|
|
49
|
+
* provided client with given arguments. The composable has its own internal
|
|
50
|
+
* state manager to report async status, such as pending or error statuses.
|
|
51
|
+
*
|
|
52
|
+
* @typeParam TClientMethodName - A method name from `@prismicio/client`
|
|
53
|
+
* @typeParam TClientMethodArguments - The method expected arguments
|
|
54
|
+
* @typeParam TClientMethodReturnType - The method expected return type
|
|
55
|
+
*
|
|
56
|
+
* @param method - The `@prismicio/client` method name to use
|
|
57
|
+
* @param args - The arguments to use with requested method
|
|
58
|
+
*
|
|
59
|
+
* @returns The composable payload {@link ClientComposableReturnType}
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare const useStatefulPrismicClientMethod: <TClientMethodName extends keyof Client<any>, TClientMethodArguments extends ClientMethodParameters<TClientMethodName>, TClientMethodReturnType extends UnwrapPromise<ClientMethodReturnType<TClientMethodName>>>(methodName: TClientMethodName, args: TClientMethodArguments) => ClientComposableReturnType<TClientMethodReturnType>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ref, shallowRef, isRef, watch, unref } from "vue";
|
|
2
|
+
import { usePrismic } from "./usePrismic.js";
|
|
3
|
+
const isParams = (value) => {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
};
|
|
6
|
+
const useStatefulPrismicClientMethod = (methodName, args) => {
|
|
7
|
+
const { client } = usePrismic();
|
|
8
|
+
const state = ref("idle");
|
|
9
|
+
const data = shallowRef(null);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const refresh = async () => {
|
|
12
|
+
const lastArg = unref(args[args.length - 1]);
|
|
13
|
+
const { client: explicitClient, ...params } = isParams(lastArg) ? lastArg : {};
|
|
14
|
+
const argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;
|
|
15
|
+
state.value = "pending";
|
|
16
|
+
data.value = null;
|
|
17
|
+
error.value = null;
|
|
18
|
+
try {
|
|
19
|
+
data.value = await (unref(explicitClient) || client)[methodName](...argsWithoutParams.map((arg) => unref(arg)), params);
|
|
20
|
+
state.value = "success";
|
|
21
|
+
} catch (err) {
|
|
22
|
+
state.value = "error";
|
|
23
|
+
error.value = err;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const refArgs = args.filter((arg) => isRef(arg));
|
|
27
|
+
if (refArgs.length) {
|
|
28
|
+
watch(refArgs, refresh, { deep: true });
|
|
29
|
+
}
|
|
30
|
+
refresh();
|
|
31
|
+
return { state, data, error, refresh };
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
useStatefulPrismicClientMethod
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useStatefulPrismicClientMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import { isRef, ref, Ref, shallowRef, unref, watch } from \"vue\";\n\nimport {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\n\nimport { usePrismic } from \"./usePrismic\";\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\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;AAEb,QAAA,QAAQ,IAAG,MAAA;AAGX,QAAA,OAAO,WAA2C,IAAI;AACtD,QAAA,QAAQ,IAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAU,MAAM,KAAK,KAAK,SAAS,EAAE;AACrC,UAAA,EAAE,QAAQ,mBAAmB,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,YAElC,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.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Vue plugin, components, and composables to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"vetur"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"dev": "
|
|
35
|
+
"build": "vite build",
|
|
36
|
+
"dev": "vite build --watch",
|
|
37
37
|
"format": "prettier --write .",
|
|
38
38
|
"lint": "eslint --ext .js,.ts .",
|
|
39
39
|
"playground:build": "vite build playground",
|
|
@@ -50,40 +50,40 @@
|
|
|
50
50
|
"unit:watch": "vitest watch"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@prismicio/client": "^6.7.
|
|
54
|
-
"@prismicio/helpers": "^2.3.
|
|
55
|
-
"@prismicio/types": "^0.2.
|
|
53
|
+
"@prismicio/client": "^6.7.2",
|
|
54
|
+
"@prismicio/helpers": "^2.3.7",
|
|
55
|
+
"@prismicio/types": "^0.2.7",
|
|
56
56
|
"isomorphic-unfetch": "^3.1.0",
|
|
57
|
-
"vue-router": "^4.1.
|
|
57
|
+
"vue-router": "^4.1.6"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@prismicio/mock": "^0.1.1",
|
|
61
|
-
"@size-limit/preset-small-lib": "^8.0
|
|
61
|
+
"@size-limit/preset-small-lib": "^8.1.0",
|
|
62
62
|
"@types/escape-html": "^1.0.2",
|
|
63
|
-
"@types/jsdom-global": "^3.0.
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "
|
|
65
|
-
"@typescript-eslint/parser": "^5.
|
|
66
|
-
"@vitejs/plugin-vue": "^
|
|
67
|
-
"@vitest/coverage-c8": "0.
|
|
68
|
-
"@vue/compiler-sfc": "^3.2.
|
|
69
|
-
"@vue/eslint-config-typescript": "^11.0.
|
|
70
|
-
"@vue/test-utils": "^2.
|
|
71
|
-
"eslint": "^8.
|
|
63
|
+
"@types/jsdom-global": "^3.0.4",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
65
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
66
|
+
"@vitejs/plugin-vue": "^4.0.0",
|
|
67
|
+
"@vitest/coverage-c8": "^0.26.0",
|
|
68
|
+
"@vue/compiler-sfc": "^3.2.45",
|
|
69
|
+
"@vue/eslint-config-typescript": "^11.0.2",
|
|
70
|
+
"@vue/test-utils": "^2.2.6",
|
|
71
|
+
"eslint": "^8.30.0",
|
|
72
72
|
"eslint-config-prettier": "^8.5.0",
|
|
73
73
|
"eslint-plugin-prettier": "^4.2.1",
|
|
74
|
-
"eslint-plugin-tsdoc": "^0.2.
|
|
75
|
-
"eslint-plugin-vue": "^9.
|
|
76
|
-
"jsdom": "^20.0.
|
|
74
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
75
|
+
"eslint-plugin-vue": "^9.8.0",
|
|
76
|
+
"jsdom": "^20.0.3",
|
|
77
77
|
"jsdom-global": "^3.0.2",
|
|
78
|
-
"prettier": "^2.
|
|
79
|
-
"prettier-plugin-jsdoc": "^0.
|
|
80
|
-
"
|
|
81
|
-
"size-limit": "^8.0.1",
|
|
78
|
+
"prettier": "^2.8.1",
|
|
79
|
+
"prettier-plugin-jsdoc": "^0.4.2",
|
|
80
|
+
"size-limit": "^8.1.0",
|
|
82
81
|
"standard-version": "^9.5.0",
|
|
83
|
-
"typescript": "^4.
|
|
84
|
-
"vite": "^
|
|
85
|
-
"
|
|
86
|
-
"
|
|
82
|
+
"typescript": "^4.9.4",
|
|
83
|
+
"vite": "^4.0.2",
|
|
84
|
+
"vite-plugin-sdk": "^0.1.0",
|
|
85
|
+
"vitest": "^0.26.0",
|
|
86
|
+
"vue": "^3.2.45"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"vue": "^3.0.0"
|