@prismicio/next 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  Helpers to integrate Prismic into Next.js apps.
11
11
 
12
12
  - 👁️  Easily set up Prismic Preview
13
- - _More features coming!_
13
+ - 🖼️  Render optimized images using [`next/image`][next-image] and Prismic's built-in [Imgix][imgix] integration
14
14
 
15
15
  ## Install
16
16
 
@@ -57,6 +57,8 @@ For more clarity on this project and its structure you can also check out the de
57
57
  <!-- Links -->
58
58
 
59
59
  [prismic]: https://prismic.io
60
+ [imgix]: https://imgix.com/
61
+ [next-image]: https://nextjs.org/docs/basic-features/image-optimization
60
62
 
61
63
  <!-- TODO: Replace link with a more useful one if available -->
62
64
 
@@ -0,0 +1,60 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import Image from 'next/image';
3
+ import { buildURL } from 'imgix-url-builder';
4
+ import * as prismicH from '@prismicio/helpers';
5
+ import { __PRODUCTION__ } from './lib/__PRODUCTION__.mjs';
6
+ import { devMsg } from './lib/devMsg.mjs';
7
+
8
+ const imgixLoader = (args) => {
9
+ const url = new URL(args.src);
10
+ const params = {
11
+ fit: url.searchParams.get("fit") || "max",
12
+ w: args.width,
13
+ h: void 0
14
+ };
15
+ if (args.quality) {
16
+ params.q = args.quality;
17
+ }
18
+ return buildURL(args.src, params);
19
+ };
20
+ const PrismicNextImage = ({
21
+ field,
22
+ imgixParams = {},
23
+ alt,
24
+ fallbackAlt,
25
+ layout,
26
+ ...restProps
27
+ }) => {
28
+ if (!__PRODUCTION__) {
29
+ if (typeof alt === "string" && alt !== "") {
30
+ console.warn(
31
+ `[PrismicNextImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg(
32
+ "alt-must-be-an-empty-string"
33
+ )}`
34
+ );
35
+ }
36
+ if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
37
+ console.warn(
38
+ `[PrismicNextImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg(
39
+ "alt-must-be-an-empty-string"
40
+ )}`
41
+ );
42
+ }
43
+ }
44
+ if (prismicH.isFilled.imageThumbnail(field)) {
45
+ const src = buildURL(field.url, imgixParams);
46
+ return /* @__PURE__ */ jsx(Image, {
47
+ src,
48
+ width: layout === "fill" ? void 0 : field.dimensions.width,
49
+ height: layout === "fill" ? void 0 : field.dimensions.height,
50
+ alt: alt ?? (field.alt || fallbackAlt),
51
+ loader: imgixLoader,
52
+ layout,
53
+ ...restProps
54
+ });
55
+ } else {
56
+ return null;
57
+ }
58
+ };
59
+
60
+ export { PrismicNextImage };
@@ -0,0 +1,87 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { PrismicToolbar } from '@prismicio/react';
4
+ import { useRouter } from 'next/router';
5
+ import { getPrismicPreviewCookie } from './lib/getPrismicPreviewCookie.mjs';
6
+ import { getPreviewCookieRepositoryName } from './lib/getPreviewCookieRepositoryName.mjs';
7
+
8
+ function PrismicPreview({
9
+ repositoryName,
10
+ children,
11
+ updatePreviewURL = "/api/preview",
12
+ exitPreviewURL = "/api/exit-preview"
13
+ }) {
14
+ const router = useRouter();
15
+ const resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;
16
+ const resolvedExitPreviewURL = router.basePath + exitPreviewURL;
17
+ React.useEffect(() => {
18
+ const startPreviewMode = async () => {
19
+ const res = await globalThis.fetch(resolvedUpdatePreviewURL);
20
+ if (res.ok) {
21
+ globalThis.location.reload();
22
+ } else {
23
+ console.error(
24
+ `[<PrismicPreview>] Failed to start or update Preview Mode using the "${resolvedUpdatePreviewURL}" API endpoint. Does it exist?`
25
+ );
26
+ }
27
+ };
28
+ const handlePrismicPreviewUpdate = async (event) => {
29
+ event.preventDefault();
30
+ await startPreviewMode();
31
+ };
32
+ const handlePrismicPreviewEnd = async (event) => {
33
+ event.preventDefault();
34
+ const res = await globalThis.fetch(resolvedExitPreviewURL);
35
+ if (res.ok) {
36
+ globalThis.location.reload();
37
+ } else {
38
+ console.error(
39
+ `[<PrismicPreview>] Failed to exit Preview Mode using the "${resolvedExitPreviewURL}" API endpoint. Does it exist?`
40
+ );
41
+ }
42
+ };
43
+ if (router.isPreview) {
44
+ window.addEventListener(
45
+ "prismicPreviewUpdate",
46
+ handlePrismicPreviewUpdate
47
+ );
48
+ window.addEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
49
+ } else {
50
+ const prismicPreviewCookie = getPrismicPreviewCookie(
51
+ globalThis.document.cookie
52
+ );
53
+ if (prismicPreviewCookie) {
54
+ const locationIsDescendantOfBasePath = window.location.href.startsWith(
55
+ window.location.origin + router.basePath
56
+ );
57
+ const prismicPreviewCookieRepositoryName = getPreviewCookieRepositoryName(prismicPreviewCookie);
58
+ if (locationIsDescendantOfBasePath && prismicPreviewCookieRepositoryName === repositoryName) {
59
+ startPreviewMode();
60
+ }
61
+ }
62
+ }
63
+ return () => {
64
+ window.removeEventListener(
65
+ "prismicPreviewUpdate",
66
+ handlePrismicPreviewUpdate
67
+ );
68
+ window.removeEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
69
+ };
70
+ }, [
71
+ repositoryName,
72
+ resolvedExitPreviewURL,
73
+ resolvedUpdatePreviewURL,
74
+ router.isPreview,
75
+ router.basePath
76
+ ]);
77
+ return /* @__PURE__ */ jsxs(Fragment, {
78
+ children: [
79
+ children,
80
+ /* @__PURE__ */ jsx(PrismicToolbar, {
81
+ repositoryName
82
+ })
83
+ ]
84
+ });
85
+ }
86
+
87
+ export { PrismicPreview };
@@ -0,0 +1,15 @@
1
+ const isPrismicNextPreviewData = (previewData) => {
2
+ return typeof previewData === "object" && "ref" in previewData;
3
+ };
4
+ const enableAutoPreviews = (config) => {
5
+ if ("previewData" in config && config.previewData) {
6
+ const { previewData } = config;
7
+ if (isPrismicNextPreviewData(previewData) && previewData.ref) {
8
+ config.client.queryContentFromRef(previewData.ref);
9
+ }
10
+ } else if ("req" in config && config.req) {
11
+ config.client.enableAutoPreviewsFromReq(config.req);
12
+ }
13
+ };
14
+
15
+ export { enableAutoPreviews };
@@ -0,0 +1,6 @@
1
+ function exitPreview(config) {
2
+ config.res.clearPreviewData();
3
+ config.res.status(205).json({ success: true });
4
+ }
5
+
6
+ export { exitPreview };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { NextApiRequest, NextApiResponse, PreviewData } from 'next';
2
- import { Client, HttpRequestLike } from '@prismicio/client';
3
- import React from 'react';
2
+ import * as React from 'react';
3
+ import { Client, HttpRequestLike, ClientConfig } from '@prismicio/client';
4
4
  import { LinkResolverFunction } from '@prismicio/helpers';
5
+ import { ImageProps } from 'next/image';
6
+ import { ImgixURLParams } from 'imgix-url-builder';
7
+ import * as prismicT from '@prismicio/types';
5
8
 
6
9
  /**
7
10
  * Configuration for `setPreviewData`.
@@ -32,42 +35,6 @@ declare type SetPreviewDataConfig = {
32
35
  */
33
36
  declare function setPreviewData({ req, res }: SetPreviewDataConfig): void;
34
37
 
35
- /**
36
- * Configuration for `enableAutoPreviews`.
37
- *
38
- * @typeParam TPreviewData - Next.js preview data object.
39
- */
40
- declare type EnableAutoPreviewsConfig<TPreviewData extends PreviewData = PreviewData> = {
41
- /**
42
- * Prismic client with which automatic previews will be enabled.
43
- */
44
- client: Client;
45
- } & ({
46
- /**
47
- * A Next.js context object (such as the context object from
48
- * `getStaticProps` or `getServerSideProps`).
49
- *
50
- * Pass a `context` object when using `enableAutoPreviews` outside a
51
- * Next.js API endpoint.
52
- */
53
- previewData?: TPreviewData;
54
- } | {
55
- /**
56
- * A Next.js API endpoint request object.
57
- *
58
- * Pass a `req` object when using `enableAutoPreviews` in a Next.js API endpoint.
59
- */
60
- req?: HttpRequestLike;
61
- });
62
- /**
63
- * Configures a Prismic client to automatically query draft content during a
64
- * preview session. It either takes in a Next.js `getStaticProps` context object
65
- * or a Next.js API endpoint request object.
66
- *
67
- * @param config - Configuration for the function.
68
- */
69
- declare const enableAutoPreviews: <TPreviewData extends PreviewData>(config: EnableAutoPreviewsConfig<TPreviewData>) => void;
70
-
71
38
  /**
72
39
  * Configuration for `exitPreview`.
73
40
  */
@@ -79,9 +46,7 @@ declare type ExitPreviewConfig = {
79
46
  * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}
80
47
  */
81
48
  req: {
82
- headers: {
83
- referer?: NextApiRequest["headers"]["referer"];
84
- };
49
+ headers: NextApiRequest["headers"];
85
50
  };
86
51
  /**
87
52
  * The `res` object from a Next.js API route. This is given as a parameter to
@@ -91,14 +56,16 @@ declare type ExitPreviewConfig = {
91
56
  */
92
57
  res: {
93
58
  clearPreviewData: NextApiResponse["clearPreviewData"];
94
- redirect: NextApiResponse["redirect"];
59
+ status: NextApiResponse["status"];
60
+ json: NextApiResponse["json"];
95
61
  };
62
+ /**
63
+ * @deprecated - This property is no longer used. It can be deleted safely.
64
+ */
65
+ exitPreviewURL?: string;
96
66
  };
97
67
  /**
98
68
  * Exits Next.js's Preview Mode from within a Next.js API route.
99
- *
100
- * If the user was sent to the endpoint from a page, the user will be redirected
101
- * back to that page after exiting Preview Mode.
102
69
  */
103
70
  declare function exitPreview(config: ExitPreviewConfig): void;
104
71
 
@@ -114,13 +81,23 @@ declare type PrismicPreviewProps = {
114
81
  /**
115
82
  * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
116
83
  * This URL will be fetched on preview update events.
84
+ *
85
+ * **Note**: If your `next.config.js` file contains a `basePath`, it is
86
+ * automatically included.
117
87
  */
118
88
  updatePreviewURL?: string;
119
89
  /**
120
90
  * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
121
91
  * This URL will be fetched on preview exit events.
92
+ *
93
+ * **Note**: If your `next.config.js` file contains a `basePath`, it is
94
+ * automatically included.
122
95
  */
123
96
  exitPreviewURL?: string;
97
+ /**
98
+ * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar
99
+ * will be rendered last.
100
+ */
124
101
  children?: React.ReactNode;
125
102
  };
126
103
  /**
@@ -135,34 +112,46 @@ declare type PrismicPreviewProps = {
135
112
  declare function PrismicPreview({ repositoryName, children, updatePreviewURL, exitPreviewURL, }: PrismicPreviewProps): JSX.Element;
136
113
 
137
114
  /**
138
- * Redirects a user to the URL of a previewed Prismic document from within a
139
- * Next.js API route.
140
- */
141
- declare function redirectToPreviewURL<TLinkResolverFunction extends LinkResolverFunction<any>>({ req, res, client, linkResolver, defaultURL, }: PreviewConfig<TLinkResolverFunction>): Promise<void>;
142
-
143
- /**
144
- * Configuration for creating a Prismic client with automatic preview support in
145
- * Next.js apps.
115
+ * Configuration for `enableAutoPreviews`.
116
+ *
117
+ * @typeParam TPreviewData - Next.js preview data object.
146
118
  */
147
- declare type CreateClientConfig = {
119
+ declare type EnableAutoPreviewsConfig<TPreviewData extends PreviewData = PreviewData> = {
148
120
  /**
149
- * Preview data coming from Next.js context object. This context object comes
150
- * from `getStaticProps` or `getServerSideProps`.
121
+ * Prismic client with which automatic previews will be enabled.
122
+ */
123
+ client: Client;
124
+ } & ({
125
+ /**
126
+ * A Next.js context object (such as the context object from
127
+ * `getStaticProps` or `getServerSideProps`).
151
128
  *
152
- * Pass `previewData` when using outside a Next.js API endpoint.
129
+ * Pass a `context` object when using `enableAutoPreviews` outside a
130
+ * Next.js API endpoint.
153
131
  */
154
- previewData?: PreviewData;
132
+ previewData?: TPreviewData;
133
+ } | {
155
134
  /**
156
135
  * A Next.js API endpoint request object.
157
136
  *
158
- * Pass a `req` object when using in a Next.js API endpoint.
137
+ * Pass a `req` object when using `enableAutoPreviews` in a Next.js API
138
+ * endpoint.
159
139
  */
160
- req?: NextApiRequest;
161
- };
140
+ req?: HttpRequestLike;
141
+ });
142
+ /**
143
+ * Configures a Prismic client to automatically query draft content during a
144
+ * preview session. It either takes in a Next.js `getStaticProps` context object
145
+ * or a Next.js API endpoint request object.
146
+ *
147
+ * @param config - Configuration for the function.
148
+ */
149
+ declare const enableAutoPreviews: <TPreviewData extends PreviewData>(config: EnableAutoPreviewsConfig<TPreviewData>) => void;
150
+
162
151
  /**
163
152
  * Preview config for enabling previews with redirectToPreviewURL
164
153
  */
165
- declare type PreviewConfig<TLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction> = {
154
+ declare type RedirectToPreviewURLConfig<TLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction> = {
166
155
  /**
167
156
  * The `req` object from a Next.js API route. This is given as a parameter to
168
157
  * the API route.
@@ -192,9 +181,93 @@ declare type PreviewConfig<TLinkResolverFunction extends LinkResolverFunction<an
192
181
  */
193
182
  linkResolver?: TLinkResolverFunction;
194
183
  /**
195
- * The default redirect URL if a URL cannot be determined for the previewed document.
184
+ * The default redirect URL if a URL cannot be determined for the previewed
185
+ * document.
186
+ *
187
+ * **Note**: If you `next.config.js` file contains a `basePath`, the
188
+ * `defaultURL` option must _not_ include it. Instead, provide the `basePath`
189
+ * property using the `basePath` option.
196
190
  */
197
191
  defaultURL?: string;
192
+ /**
193
+ * The `basePath` for the Next.js app as it is defined in `next.config.js`.
194
+ * This option can be omitted if the app does not have a `basePath`.
195
+ *
196
+ * @remarks
197
+ * The API route is unable to detect the app's `basePath` automatically. It
198
+ * must be provided to `redirectToPreviewURL()` manually.
199
+ */
200
+ basePath?: string;
198
201
  };
202
+ /**
203
+ * Redirects a user to the URL of a previewed Prismic document from within a
204
+ * Next.js API route.
205
+ */
206
+ declare function redirectToPreviewURL<TLinkResolverFunction extends LinkResolverFunction<any>>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void>;
207
+
208
+ declare type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "width" | "height"> & {
209
+ /**
210
+ * The Prismic Image field or thumbnail to render.
211
+ */
212
+ field: prismicT.ImageFieldImage | null | undefined;
213
+ /**
214
+ * An object of Imgix URL API parameters to transform the image.
215
+ *
216
+ * @see https://docs.imgix.com/apis/rendering
217
+ */
218
+ imgixParams?: ImgixURLParams;
219
+ /**
220
+ * Declare an image as decorative by providing `alt=""`.
221
+ *
222
+ * See:
223
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
224
+ */
225
+ alt?: "";
226
+ /**
227
+ * Declare an image as decorative only if the Image field does not have
228
+ * alternative text by providing `fallbackAlt=""`.
229
+ *
230
+ * See:
231
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
232
+ */
233
+ fallbackAlt?: "";
234
+ };
235
+ /**
236
+ * React component that renders an image from a Prismic Image field or one of
237
+ * its thumbnails using `next/image`. It will automatically set the `alt`
238
+ * attribute using the Image field's `alt` property.
239
+ *
240
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided
241
+ * with the `loader` prop. If you would like to use the Next.js Image
242
+ * Optimization API instead, set `loader={undefined}`.
243
+ *
244
+ * @param props - Props for the component.
245
+ *
246
+ * @returns A responsive image component using `next/image` for the given Image
247
+ * field.
248
+ *
249
+ * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
250
+ */
251
+ declare const PrismicNextImage: ({ field, imgixParams, alt, fallbackAlt, layout, ...restProps }: PrismicNextImageProps) => JSX.Element | null;
252
+
253
+ /**
254
+ * Configuration for creating a Prismic client with automatic preview support in
255
+ * Next.js apps.
256
+ */
257
+ declare type CreateClientConfig = {
258
+ /**
259
+ * Preview data coming from Next.js context object. This context object comes
260
+ * from `getStaticProps` or `getServerSideProps`.
261
+ *
262
+ * Pass `previewData` when using outside a Next.js API endpoint.
263
+ */
264
+ previewData?: PreviewData;
265
+ /**
266
+ * A Next.js API endpoint request object.
267
+ *
268
+ * Pass a `req` object when using in a Next.js API endpoint.
269
+ */
270
+ req?: NextApiRequest;
271
+ } & ClientConfig;
199
272
 
200
- export { CreateClientConfig, EnableAutoPreviewsConfig, ExitPreviewConfig as ExitPreviewParams, PreviewConfig, PrismicPreview, PrismicPreviewProps, SetPreviewDataConfig, enableAutoPreviews, exitPreview, redirectToPreviewURL, setPreviewData };
273
+ export { CreateClientConfig, EnableAutoPreviewsConfig, ExitPreviewConfig, PrismicNextImage, PrismicNextImageProps, PrismicPreview, PrismicPreviewProps, RedirectToPreviewURLConfig, SetPreviewDataConfig, enableAutoPreviews, exitPreview, redirectToPreviewURL, setPreviewData };
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ export { setPreviewData } from './setPreviewData.mjs';
2
+ export { exitPreview } from './exitPreview.mjs';
3
+ export { PrismicPreview } from './PrismicPreview.mjs';
4
+ export { enableAutoPreviews } from './enableAutoPreviews.mjs';
5
+ export { redirectToPreviewURL } from './redirectToPreviewURL.mjs';
6
+ export { PrismicNextImage } from './PrismicNextImage.mjs';
@@ -0,0 +1,3 @@
1
+ const __PRODUCTION__ = process.env.NODE_ENV === "production";
2
+
3
+ export { __PRODUCTION__ };
@@ -0,0 +1,7 @@
1
+ import { version } from '../package.mjs';
2
+
3
+ const devMsg = (slug) => {
4
+ return `https://prismic.dev/msg/next/v${version}/${slug}`;
5
+ };
6
+
7
+ export { devMsg };
@@ -0,0 +1,5 @@
1
+ const getPreviewCookieRepositoryName = (previewCookie) => {
2
+ return (decodeURIComponent(previewCookie).match(/"(.+).prismic.io"/) || [])[1];
3
+ };
4
+
5
+ export { getPreviewCookieRepositoryName };
@@ -0,0 +1,20 @@
1
+ import * as prismic from '@prismicio/client';
2
+
3
+ const readValue = (value) => {
4
+ return value.replace(/%3B/g, ";");
5
+ };
6
+ const getPrismicPreviewCookie = (cookieJar) => {
7
+ const cookies = cookieJar.split("; ");
8
+ let value;
9
+ for (const cookie of cookies) {
10
+ const parts = cookie.split("=");
11
+ const name = readValue(parts[0]).replace(/%3D/g, "=");
12
+ if (name === prismic.cookie.preview) {
13
+ value = readValue(parts.slice(1).join("="));
14
+ continue;
15
+ }
16
+ }
17
+ return value;
18
+ };
19
+
20
+ export { getPrismicPreviewCookie };
@@ -0,0 +1,3 @@
1
+ const version = "0.1.4";
2
+
3
+ export { version };
@@ -0,0 +1,20 @@
1
+ const isPrismicNextQuery = (query) => {
2
+ return typeof query.documentId === "string" && typeof query.token === "string";
3
+ };
4
+ async function redirectToPreviewURL(config) {
5
+ const defaultURL = config.defaultURL || "/";
6
+ const basePath = config.basePath || "";
7
+ if (isPrismicNextQuery(config.req.query)) {
8
+ const previewUrl = await config.client.resolvePreviewURL({
9
+ linkResolver: config.linkResolver,
10
+ defaultURL,
11
+ documentID: config.req.query.documentId,
12
+ previewToken: config.req.query.token
13
+ });
14
+ config.res.redirect(basePath + previewUrl);
15
+ return;
16
+ }
17
+ config.res.redirect(basePath + defaultURL);
18
+ }
19
+
20
+ export { redirectToPreviewURL };
@@ -0,0 +1,10 @@
1
+ import * as prismic from '@prismicio/client';
2
+
3
+ function setPreviewData({ req, res }) {
4
+ const ref = req.query.token || req.cookies[prismic.cookie.preview];
5
+ if (ref) {
6
+ res.setPreviewData({ ref });
7
+ }
8
+ }
9
+
10
+ export { setPreviewData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "typescript",
@@ -15,23 +15,19 @@
15
15
  },
16
16
  "license": "Apache-2.0",
17
17
  "author": "Prismic <contact@prismic.io> (https://prismic.io)",
18
+ "sideEffects": false,
19
+ "type": "module",
18
20
  "exports": {
19
- ".": {
20
- "require": "./dist/index.cjs",
21
- "import": "./dist/index.js"
22
- },
23
- "./package.json": "./package.json"
21
+ ".": "./dist/index.mjs"
24
22
  },
25
- "main": "./dist/index.cjs",
26
- "module": "dist/index.js",
27
23
  "types": "dist/index.d.ts",
28
24
  "files": [
29
25
  "dist",
30
26
  "src"
31
27
  ],
32
28
  "scripts": {
33
- "build": "siroc build",
34
- "dev": "siroc build --watch",
29
+ "build": "unbuild",
30
+ "dev": "chokidar src --initial --command unbuild",
35
31
  "format": "prettier --write .",
36
32
  "lint": "eslint --ext .js,.ts .",
37
33
  "prepare": "npm run build",
@@ -41,44 +37,42 @@
41
37
  "release:dry": "standard-version --dry-run",
42
38
  "size": "size-limit",
43
39
  "test": "npm run lint && npm run unit && npm run build && npm run size",
44
- "unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
40
+ "unit": "vitest run --coverage",
41
+ "unit:watch": "vitest watch"
45
42
  },
46
43
  "dependencies": {
47
- "@prismicio/react": "^2.2.0"
44
+ "@prismicio/client": "^6.7.1",
45
+ "@prismicio/helpers": "^2.3.3",
46
+ "@prismicio/react": "^2.5.0",
47
+ "@prismicio/types": "^0.2.3",
48
+ "eslint-plugin-react": "^7.31.7",
49
+ "eslint-plugin-react-hooks": "^4.6.0",
50
+ "imgix-url-builder": "^0.0.3"
48
51
  },
49
52
  "devDependencies": {
50
- "@prismicio/client": "^6.4.2",
51
- "@prismicio/mock": "^0.0.9",
52
- "@prismicio/types": "^0.1.27",
53
- "@size-limit/preset-small-lib": "^7.0.8",
54
- "@testing-library/react": "^13.0.0",
55
- "@types/jsdom": "^16.2.14",
56
- "@types/jsdom-global": "^3.0.2",
57
- "@types/react-test-renderer": "^17.0.1",
58
- "@types/sinon": "^10.0.11",
59
- "@typescript-eslint/eslint-plugin": "^5.17.0",
60
- "@typescript-eslint/parser": "^5.17.0",
61
- "ava": "^4.1.0",
62
- "eslint": "^8.12.0",
53
+ "@prismicio/mock": "^0.1.1",
54
+ "@size-limit/preset-small-lib": "^8.1.0",
55
+ "@types/react-test-renderer": "^18.0.0",
56
+ "@typescript-eslint/eslint-plugin": "^5.36.2",
57
+ "@typescript-eslint/parser": "^5.36.2",
58
+ "@vitest/coverage-c8": "^0.23.1",
59
+ "chokidar-cli": "^3.0.0",
60
+ "eslint": "^8.23.0",
63
61
  "eslint-config-prettier": "^8.5.0",
64
- "eslint-plugin-prettier": "^4.0.0",
65
- "eslint-plugin-tsdoc": "^0.2.14",
66
- "jsdom": "^19.0.0",
67
- "jsdom-global": "^3.0.2",
68
- "msw": "^0.39.2",
62
+ "eslint-plugin-prettier": "^4.2.1",
63
+ "eslint-plugin-tsdoc": "^0.2.16",
64
+ "happy-dom": "^6.0.4",
69
65
  "next": "^12.1.4",
70
- "node-fetch": "^3.2.3",
71
66
  "nyc": "^15.1.0",
72
- "prettier": "^2.6.1",
73
- "prettier-plugin-jsdoc": "^0.3.35",
74
- "react": "^18.0.0",
75
- "react-dom": "^18.0.0",
76
- "sinon": "^13.0.1",
77
- "siroc": "^0.16.0",
78
- "size-limit": "^7.0.8",
79
- "standard-version": "^9.3.2",
80
- "ts-eager": "^2.0.2",
81
- "typescript": "^4.6.3"
67
+ "prettier": "^2.7.1",
68
+ "prettier-plugin-jsdoc": "^0.4.2",
69
+ "react": "^18.1.0",
70
+ "react-test-renderer": "^18.2.0",
71
+ "size-limit": "^8.1.0",
72
+ "standard-version": "^9.5.0",
73
+ "typescript": "^4.8.3",
74
+ "unbuild": "^0.8.10",
75
+ "vitest": "^0.23.1"
82
76
  },
83
77
  "peerDependencies": {
84
78
  "@prismicio/client": "^6.0.0",