next-sanity 8.2.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/image/Image.cjs +1 -0
- package/dist/image/Image.cjs.map +1 -0
- package/dist/image/Image.js +1 -0
- package/dist/image/Image.js.map +1 -0
- package/dist/image/imageLoader.cjs +1 -0
- package/dist/image/imageLoader.cjs.map +1 -0
- package/dist/image/imageLoader.js +1 -0
- package/dist/image/imageLoader.js.map +1 -0
- package/dist/image/index.cjs +1 -0
- package/dist/image/index.cjs.map +1 -0
- package/dist/image/index.d.ts +31 -0
- package/dist/image/index.js +1 -0
- package/dist/image/index.js.map +1 -0
- package/dist/visual-editing/actions.cjs +1 -1
- package/dist/visual-editing/actions.cjs.map +1 -1
- package/dist/visual-editing/actions.js +1 -1
- package/dist/visual-editing/actions.js.map +1 -1
- package/package.json +22 -41
- package/src/image/Image.tsx +45 -0
- package/src/image/imageLoader.ts +22 -0
- package/src/image/index.ts +2 -0
- package/src/visual-editing/actions.ts +12 -3
- package/dist/index.cjs.js +0 -12
- package/dist/preview/index.cjs.js +0 -6
- package/dist/preview/live-query.cjs.js +0 -5
- package/dist/studio/index.cjs.js +0 -8
- package/dist/studio/metadata.cjs.js +0 -4
- package/dist/studio/viewport.cjs.js +0 -4
- package/dist/webhook.cjs.js +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("next/image"),t=require("./imageLoader.cjs");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(r);exports.Image=function(r){const{loader:a,src:s,...i}=r;if(a)throw new TypeError("The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.");let n;try{n=new URL(s),r.height&&n.searchParams.set("h",`${r.height}`),r.width&&n.searchParams.set("w",`${r.width}`)}catch(e){throw new TypeError("The `src` prop must be a valid URL to an image on the Sanity Image CDN.",{cause:e})}return e.jsx(o.default,{...i,src:n.toString(),loader:t.imageLoader})};//# sourceMappingURL=Image.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.cjs","sources":["../../src/image/Image.tsx"],"sourcesContent":["import NextImage, {ImageProps as NextImageProps} from 'next/image'\n\nimport {imageLoader} from './imageLoader'\n\n/**\n * @alpha\n */\nexport interface ImageProps extends Omit<NextImageProps, 'loader' | 'src'> {\n /**\n * The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.\n */\n loader?: never\n /**\n * Must be a string that is a valid URL to an image on the Sanity Image CDN.\n */\n src: string\n}\n\n/**\n * @alpha\n */\nexport function Image(props: ImageProps): JSX.Element {\n const {loader, src, ...rest} = props\n if (loader) {\n throw new TypeError(\n 'The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.',\n )\n }\n let srcUrl: URL\n try {\n srcUrl = new URL(src)\n if (props.height) {\n srcUrl.searchParams.set('h', `${props.height}`)\n }\n if (props.width) {\n srcUrl.searchParams.set('w', `${props.width}`)\n }\n } catch (err) {\n throw new TypeError(\n 'The `src` prop must be a valid URL to an image on the Sanity Image CDN.',\n {cause: err},\n )\n }\n return <NextImage {...rest} src={srcUrl.toString()} loader={imageLoader} />\n}\n"],"names":["exports","Image","props","loader","src","rest","TypeError","srcUrl","URL","height","searchParams","set","width","err","cause","NextImage","toString","imageLoader"],"mappings":"iPA4CAA,QAAAC,MAvBO,SAAeC,GACpB,MAAMC,OAACA,EAAAC,IAAQA,KAAQC,GAAQH,EAC3B,GAAAC,EACF,MAAM,IAAIG,UACR,+GAGA,IAAAC,EACA,IACOA,EAAA,IAAIC,IAAIJ,GACbF,EAAMO,QACRF,EAAOG,aAAaC,IAAI,IAAK,GAAGT,EAAMO,UAEpCP,EAAMU,OACRL,EAAOG,aAAaC,IAAI,IAAK,GAAGT,EAAMU,eAEjCC,GACP,MAAM,IAAIP,UACR,0EACA,CAACQ,MAAOD,GAEZ,CACO,aAACE,EAAAA,YAAcV,EAAMD,IAAKG,EAAOS,WAAYb,OAAQc,EAAAA,aAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r from"next/image";import{imageLoader as t}from"./imageLoader.js";function o(o){const{loader:a,src:s,...i}=o;if(a)throw new TypeError("The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.");let m;try{m=new URL(s),o.height&&m.searchParams.set("h",`${o.height}`),o.width&&m.searchParams.set("w",`${o.width}`)}catch(e){throw new TypeError("The `src` prop must be a valid URL to an image on the Sanity Image CDN.",{cause:e})}return e(r,{...i,src:m.toString(),loader:t})}export{o as Image};//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.js","sources":["../../src/image/Image.tsx"],"sourcesContent":["import NextImage, {ImageProps as NextImageProps} from 'next/image'\n\nimport {imageLoader} from './imageLoader'\n\n/**\n * @alpha\n */\nexport interface ImageProps extends Omit<NextImageProps, 'loader' | 'src'> {\n /**\n * The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.\n */\n loader?: never\n /**\n * Must be a string that is a valid URL to an image on the Sanity Image CDN.\n */\n src: string\n}\n\n/**\n * @alpha\n */\nexport function Image(props: ImageProps): JSX.Element {\n const {loader, src, ...rest} = props\n if (loader) {\n throw new TypeError(\n 'The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.',\n )\n }\n let srcUrl: URL\n try {\n srcUrl = new URL(src)\n if (props.height) {\n srcUrl.searchParams.set('h', `${props.height}`)\n }\n if (props.width) {\n srcUrl.searchParams.set('w', `${props.width}`)\n }\n } catch (err) {\n throw new TypeError(\n 'The `src` prop must be a valid URL to an image on the Sanity Image CDN.',\n {cause: err},\n )\n }\n return <NextImage {...rest} src={srcUrl.toString()} loader={imageLoader} />\n}\n"],"names":["Image","props","loader","src","rest","TypeError","srcUrl","URL","height","searchParams","set","width","err","cause","jsx","NextImage","toString","imageLoader"],"mappings":"iHAqBO,SAASA,EAAMC,GACpB,MAAMC,OAACA,EAAAC,IAAQA,KAAQC,GAAQH,EAC3B,GAAAC,EACF,MAAM,IAAIG,UACR,+GAGA,IAAAC,EACA,IACOA,EAAA,IAAIC,IAAIJ,GACbF,EAAMO,QACRF,EAAOG,aAAaC,IAAI,IAAK,GAAGT,EAAMO,UAEpCP,EAAMU,OACRL,EAAOG,aAAaC,IAAI,IAAK,GAAGT,EAAMU,eAEjCC,GACP,MAAM,IAAIP,UACR,0EACA,CAACQ,MAAOD,GAEZ,CACO,OAAAE,EAACC,MAAcX,EAAMD,IAAKG,EAAOU,WAAYd,OAAQe,GAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.imageLoader=({src:a,width:s,quality:e})=>{const r=new URL(a);if(r.searchParams.set("auto","format"),r.searchParams.set("fit",r.searchParams.get("fit")||"min"),r.searchParams.has("h")&&r.searchParams.has("w")){const a=parseInt(r.searchParams.get("h"),10),e=parseInt(r.searchParams.get("w"),10);r.searchParams.set("h",Math.round(a/e*s).toString())}return r.searchParams.set("w",s.toString()),e&&r.searchParams.set("q",e.toString()),r.href};//# sourceMappingURL=imageLoader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageLoader.cjs","sources":["../../src/image/imageLoader.ts"],"sourcesContent":["'use client'\n\nimport type {ImageLoader} from 'next/image'\n\n/**\n * @alpha\n */\nexport const imageLoader = (({src, width, quality}) => {\n const url = new URL(src)\n url.searchParams.set('auto', 'format')\n url.searchParams.set('fit', url.searchParams.get('fit') || 'min')\n if (url.searchParams.has('h') && url.searchParams.has('w')) {\n const originalHeight = parseInt(url.searchParams.get('h')!, 10)\n const originalWidth = parseInt(url.searchParams.get('w')!, 10)\n url.searchParams.set('h', Math.round((originalHeight / originalWidth) * width).toString())\n }\n url.searchParams.set('w', width.toString())\n if (quality) {\n url.searchParams.set('q', quality.toString())\n }\n return url.href\n}) satisfies ImageLoader\n"],"names":["exports","imageLoader","src","width","quality","url","URL","searchParams","set","get","has","originalHeight","parseInt","originalWidth","Math","round","toString","href"],"mappings":"iFAqBAA,QAAAC,YAd4B,EAAEC,MAAKC,QAAOC,cAClC,MAAAC,EAAM,IAAIC,IAAIJ,GACpB,GAAAG,EAAIE,aAAaC,IAAI,OAAQ,UAC7BH,EAAIE,aAAaC,IAAI,MAAOH,EAAIE,aAAaE,IAAI,QAAU,OACvDJ,EAAIE,aAAaG,IAAI,MAAQL,EAAIE,aAAaG,IAAI,KAAM,CAC1D,MAAMC,EAAiBC,SAASP,EAAIE,aAAaE,IAAI,KAAO,IACtDI,EAAgBD,SAASP,EAAIE,aAAaE,IAAI,KAAO,IACvDJ,EAAAE,aAAaC,IAAI,IAAKM,KAAKC,MAAOJ,EAAiBE,EAAiBV,GAAOa,WACjF,CACA,OAAAX,EAAIE,aAAaC,IAAI,IAAKL,EAAMa,YAC5BZ,GACFC,EAAIE,aAAaC,IAAI,IAAKJ,EAAQY,YAE7BX,EAAIY,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const a=({src:a,width:s,quality:r})=>{const t=new URL(a);if(t.searchParams.set("auto","format"),t.searchParams.set("fit",t.searchParams.get("fit")||"min"),t.searchParams.has("h")&&t.searchParams.has("w")){const a=parseInt(t.searchParams.get("h"),10),r=parseInt(t.searchParams.get("w"),10);t.searchParams.set("h",Math.round(a/r*s).toString())}return t.searchParams.set("w",s.toString()),r&&t.searchParams.set("q",r.toString()),t.href};export{a as imageLoader};//# sourceMappingURL=imageLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageLoader.js","sources":["../../src/image/imageLoader.ts"],"sourcesContent":["'use client'\n\nimport type {ImageLoader} from 'next/image'\n\n/**\n * @alpha\n */\nexport const imageLoader = (({src, width, quality}) => {\n const url = new URL(src)\n url.searchParams.set('auto', 'format')\n url.searchParams.set('fit', url.searchParams.get('fit') || 'min')\n if (url.searchParams.has('h') && url.searchParams.has('w')) {\n const originalHeight = parseInt(url.searchParams.get('h')!, 10)\n const originalWidth = parseInt(url.searchParams.get('w')!, 10)\n url.searchParams.set('h', Math.round((originalHeight / originalWidth) * width).toString())\n }\n url.searchParams.set('w', width.toString())\n if (quality) {\n url.searchParams.set('q', quality.toString())\n }\n return url.href\n}) satisfies ImageLoader\n"],"names":["imageLoader","src","width","quality","url","URL","searchParams","set","get","has","originalHeight","parseInt","originalWidth","Math","round","toString","href"],"mappings":"aAOO,MAAMA,EAAe,EAAEC,MAAKC,QAAOC,cAClC,MAAAC,EAAM,IAAIC,IAAIJ,GACpB,GAAAG,EAAIE,aAAaC,IAAI,OAAQ,UAC7BH,EAAIE,aAAaC,IAAI,MAAOH,EAAIE,aAAaE,IAAI,QAAU,OACvDJ,EAAIE,aAAaG,IAAI,MAAQL,EAAIE,aAAaG,IAAI,KAAM,CAC1D,MAAMC,EAAiBC,SAASP,EAAIE,aAAaE,IAAI,KAAO,IACtDI,EAAgBD,SAASP,EAAIE,aAAaE,IAAI,KAAO,IACvDJ,EAAAE,aAAaC,IAAI,IAAKM,KAAKC,MAAOJ,EAAiBE,EAAiBV,GAAOa,WACjF,CACA,OAAAX,EAAIE,aAAaC,IAAI,IAAKL,EAAMa,YAC5BZ,GACFC,EAAIE,aAAaC,IAAI,IAAKJ,EAAQY,YAE7BX,EAAIY,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./Image.cjs"),r=require("./imageLoader.cjs");exports.Image=e.Image,exports.imageLoader=r.imageLoader;//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
import {ImageLoaderProps} from 'next/image'
|
|
4
|
+
import {ImageProps as ImageProps_2} from 'next/image'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
declare function Image_2(props: ImageProps): JSX.Element
|
|
10
|
+
export {Image_2 as Image}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
export declare const imageLoader: ({src, width, quality}: ImageLoaderProps) => string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
export declare interface ImageProps extends Omit<ImageProps_2, 'loader' | 'src'> {
|
|
21
|
+
/**
|
|
22
|
+
* The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.
|
|
23
|
+
*/
|
|
24
|
+
loader?: never
|
|
25
|
+
/**
|
|
26
|
+
* Must be a string that is a valid URL to an image on the Sanity Image CDN.
|
|
27
|
+
*/
|
|
28
|
+
src: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Image as m}from"./Image.js";import{imageLoader as o}from"./imageLoader.js";export{m as Image,o as imageLoader};//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use server";"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/cache.js"),
|
|
1
|
+
"use server";"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/cache.js"),r=require("next/headers.js");exports.revalidateRootLayout=async function(){try{if(!r.draftMode().isEnabled)return void console.debug("Skipped revalidatePath request because draft mode is not enabled")}catch(e){if(console.error("Error while checking if Draft Mode is enabled",e),null==e||!e.message.includes("requestAsyncStorage"))return void console.warn("Ignoring")}await e.revalidatePath("/","layout")};//# sourceMappingURL=actions.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.cjs","sources":["../../src/visual-editing/actions.ts"],"sourcesContent":["'use server'\n/**\n * The code in this file will be ported to `next-sanity`\n */\nimport {revalidatePath} from 'next/cache.js'\nimport {draftMode} from 'next/headers.js'\n\nexport async function revalidateRootLayout(): Promise<void> {\n if (!draftMode().isEnabled) {\n
|
|
1
|
+
{"version":3,"file":"actions.cjs","sources":["../../src/visual-editing/actions.ts"],"sourcesContent":["'use server'\n/**\n * The code in this file will be ported to `next-sanity`\n */\nimport {revalidatePath} from 'next/cache.js'\nimport {draftMode} from 'next/headers.js'\n\nexport async function revalidateRootLayout(): Promise<void> {\n try {\n if (!draftMode().isEnabled) {\n // eslint-disable-next-line no-console\n console.debug('Skipped revalidatePath request because draft mode is not enabled')\n return\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('Error while checking if Draft Mode is enabled', err)\n if (!(err as Error)?.message.includes('requestAsyncStorage')) {\n console.warn('Ignoring')\n return\n }\n }\n await revalidatePath('/', 'layout')\n}\n"],"names":["Object","defineProperty","exports","value","cache_js","require","headers_js","revalidateRootLayout","async","draftMode","isEnabled","console","debug","err","error","message","includes","warn","revalidatePath"],"mappings":"0BAOAA,OAAAC,eAAAC,QAAA,aAAA,CAAAC,OAAA,IAAA,IAAAC,EAAAC,QAAA,iBAAAC,EAAAD,QAAA,mBAgBAH,QAAAK,qBAhBAC,iBACM,IACE,IAACC,EAAAA,YAAYC,UAGf,YADAC,QAAQC,MAAM,0EAGTC,GAEP,GAAAF,QAAQG,MAAM,gDAAiDD,GACzD,MAAAA,IAAAA,EAAeE,QAAQC,SAAS,uBAEpC,YADAL,QAAQM,KAAK,WAGjB,OACMC,EAAAA,eAAe,IAAK,SAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use server";import{revalidatePath as e}from"next/cache.js";import{draftMode as
|
|
1
|
+
"use server";import{revalidatePath as e}from"next/cache.js";import{draftMode as r}from"next/headers.js";async function o(){try{if(!r().isEnabled)return void console.debug("Skipped revalidatePath request because draft mode is not enabled")}catch(e){if(console.error("Error while checking if Draft Mode is enabled",e),null==e||!e.message.includes("requestAsyncStorage"))return void console.warn("Ignoring")}await e("/","layout")}export{o as revalidateRootLayout};//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sources":["../../src/visual-editing/actions.ts"],"sourcesContent":["'use server'\n/**\n * The code in this file will be ported to `next-sanity`\n */\nimport {revalidatePath} from 'next/cache.js'\nimport {draftMode} from 'next/headers.js'\n\nexport async function revalidateRootLayout(): Promise<void> {\n if (!draftMode().isEnabled) {\n
|
|
1
|
+
{"version":3,"file":"actions.js","sources":["../../src/visual-editing/actions.ts"],"sourcesContent":["'use server'\n/**\n * The code in this file will be ported to `next-sanity`\n */\nimport {revalidatePath} from 'next/cache.js'\nimport {draftMode} from 'next/headers.js'\n\nexport async function revalidateRootLayout(): Promise<void> {\n try {\n if (!draftMode().isEnabled) {\n // eslint-disable-next-line no-console\n console.debug('Skipped revalidatePath request because draft mode is not enabled')\n return\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('Error while checking if Draft Mode is enabled', err)\n if (!(err as Error)?.message.includes('requestAsyncStorage')) {\n console.warn('Ignoring')\n return\n }\n }\n await revalidatePath('/', 'layout')\n}\n"],"names":["revalidatePath","draftMode","async","revalidateRootLayout","isEnabled","console","debug","err","error","message","includes","warn"],"mappings":"sCAOAA,MAAA,oCAAAC,MAAA,kBAAAC,eAAsBC,IAChB,IACE,IAACF,IAAYG,UAGf,YADAC,QAAQC,MAAM,0EAGTC,GAEP,GAAAF,QAAQG,MAAM,gDAAiDD,GACzD,MAAAA,IAAAA,EAAeE,QAAQC,SAAS,uBAEpC,YADAL,QAAQM,KAAK,WAGjB,OACMX,EAAe,IAAK,SAC5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-sanity",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -28,78 +28,57 @@
|
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"source": "./src/index.ts",
|
|
31
|
-
"require": "./dist/index.cjs",
|
|
32
|
-
"node": {
|
|
33
|
-
"module": "./dist/index.js",
|
|
34
|
-
"import": "./dist/index.cjs.js"
|
|
35
|
-
},
|
|
36
31
|
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs",
|
|
37
33
|
"default": "./dist/index.js"
|
|
38
34
|
},
|
|
35
|
+
"./image": {
|
|
36
|
+
"types": "./dist/image/index.d.ts",
|
|
37
|
+
"source": "./src/image/index.ts",
|
|
38
|
+
"import": "./dist/image/index.js",
|
|
39
|
+
"require": "./dist/image/index.cjs",
|
|
40
|
+
"default": "./dist/image/index.js"
|
|
41
|
+
},
|
|
39
42
|
"./preview": {
|
|
40
43
|
"types": "./dist/preview/index.d.ts",
|
|
41
44
|
"source": "./src/preview/index.ts",
|
|
42
|
-
"require": "./dist/preview/index.cjs",
|
|
43
|
-
"node": {
|
|
44
|
-
"module": "./dist/preview/index.js",
|
|
45
|
-
"import": "./dist/preview/index.cjs.js"
|
|
46
|
-
},
|
|
47
45
|
"import": "./dist/preview/index.js",
|
|
46
|
+
"require": "./dist/preview/index.cjs",
|
|
48
47
|
"default": "./dist/preview/index.js"
|
|
49
48
|
},
|
|
50
49
|
"./preview/live-query": {
|
|
51
50
|
"types": "./dist/preview/live-query.d.ts",
|
|
52
51
|
"source": "./src/preview/LiveQuery/index.ts",
|
|
53
|
-
"require": "./dist/preview/live-query.cjs",
|
|
54
|
-
"node": {
|
|
55
|
-
"module": "./dist/preview/live-query.js",
|
|
56
|
-
"import": "./dist/preview/live-query.cjs.js"
|
|
57
|
-
},
|
|
58
52
|
"import": "./dist/preview/live-query.js",
|
|
53
|
+
"require": "./dist/preview/live-query.cjs",
|
|
59
54
|
"default": "./dist/preview/live-query.js"
|
|
60
55
|
},
|
|
61
56
|
"./studio": {
|
|
62
57
|
"types": "./dist/studio/index.d.ts",
|
|
63
58
|
"source": "./src/studio/index.ts",
|
|
64
|
-
"require": "./dist/studio/index.cjs",
|
|
65
|
-
"node": {
|
|
66
|
-
"module": "./dist/studio/index.js",
|
|
67
|
-
"import": "./dist/studio/index.cjs.js"
|
|
68
|
-
},
|
|
69
59
|
"import": "./dist/studio/index.js",
|
|
60
|
+
"require": "./dist/studio/index.cjs",
|
|
70
61
|
"default": "./dist/studio/index.js"
|
|
71
62
|
},
|
|
72
63
|
"./studio/metadata": {
|
|
73
64
|
"types": "./dist/studio/metadata.d.ts",
|
|
74
65
|
"source": "./src/studio/metadata.ts",
|
|
75
|
-
"require": "./dist/studio/metadata.cjs",
|
|
76
|
-
"node": {
|
|
77
|
-
"module": "./dist/studio/metadata.js",
|
|
78
|
-
"import": "./dist/studio/metadata.cjs.js"
|
|
79
|
-
},
|
|
80
66
|
"import": "./dist/studio/metadata.js",
|
|
67
|
+
"require": "./dist/studio/metadata.cjs",
|
|
81
68
|
"default": "./dist/studio/metadata.js"
|
|
82
69
|
},
|
|
83
70
|
"./studio/viewport": {
|
|
84
71
|
"types": "./dist/studio/viewport.d.ts",
|
|
85
72
|
"source": "./src/studio/viewport.ts",
|
|
86
|
-
"require": "./dist/studio/viewport.cjs",
|
|
87
|
-
"node": {
|
|
88
|
-
"module": "./dist/studio/viewport.js",
|
|
89
|
-
"import": "./dist/studio/viewport.cjs.js"
|
|
90
|
-
},
|
|
91
73
|
"import": "./dist/studio/viewport.js",
|
|
74
|
+
"require": "./dist/studio/viewport.cjs",
|
|
92
75
|
"default": "./dist/studio/viewport.js"
|
|
93
76
|
},
|
|
94
77
|
"./webhook": {
|
|
95
78
|
"types": "./dist/webhook.d.ts",
|
|
96
79
|
"source": "./src/webhook/index.ts",
|
|
97
|
-
"require": "./dist/webhook.cjs",
|
|
98
|
-
"node": {
|
|
99
|
-
"module": "./dist/webhook.js",
|
|
100
|
-
"import": "./dist/webhook.cjs.js"
|
|
101
|
-
},
|
|
102
80
|
"import": "./dist/webhook.js",
|
|
81
|
+
"require": "./dist/webhook.cjs",
|
|
103
82
|
"default": "./dist/webhook.js"
|
|
104
83
|
},
|
|
105
84
|
"./package.json": "./package.json"
|
|
@@ -110,6 +89,9 @@
|
|
|
110
89
|
"types": "./dist/index.d.ts",
|
|
111
90
|
"typesVersions": {
|
|
112
91
|
"*": {
|
|
92
|
+
"image": [
|
|
93
|
+
"./dist/image/index.d.ts"
|
|
94
|
+
],
|
|
113
95
|
"preview": [
|
|
114
96
|
"./dist/preview/index.d.ts"
|
|
115
97
|
],
|
|
@@ -139,8 +121,8 @@
|
|
|
139
121
|
"dependencies": {
|
|
140
122
|
"@portabletext/react": "^3.0.11",
|
|
141
123
|
"@portabletext/types": "^2.0.8",
|
|
142
|
-
"@sanity/client": "^6.15.
|
|
143
|
-
"@sanity/preview-kit": "5.0.
|
|
124
|
+
"@sanity/client": "^6.15.3",
|
|
125
|
+
"@sanity/preview-kit": "5.0.31",
|
|
144
126
|
"@sanity/visual-editing": "1.7.0",
|
|
145
127
|
"@sanity/webhook": "4.0.2-bc",
|
|
146
128
|
"groq": "^3.19"
|
|
@@ -148,7 +130,7 @@
|
|
|
148
130
|
"devDependencies": {
|
|
149
131
|
"@sanity/browserslist-config": "^1.0.3",
|
|
150
132
|
"@sanity/eslint-config-studio": "^3.0.1",
|
|
151
|
-
"@sanity/pkg-utils": "^
|
|
133
|
+
"@sanity/pkg-utils": "^5.0.0",
|
|
152
134
|
"@types/react": "^18.2.64",
|
|
153
135
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
154
136
|
"@vitest/coverage-v8": "^1.3.1",
|
|
@@ -163,12 +145,11 @@
|
|
|
163
145
|
"rimraf": "^5.0.5",
|
|
164
146
|
"styled-components": "^6.1.8",
|
|
165
147
|
"typescript": "5.3.3",
|
|
166
|
-
"url-loader": "^4.1.1",
|
|
167
148
|
"vitest": "^1.3.1",
|
|
168
149
|
"vitest-github-actions-reporter": "^0.11.1"
|
|
169
150
|
},
|
|
170
151
|
"peerDependencies": {
|
|
171
|
-
"@sanity/client": "^6.15.
|
|
152
|
+
"@sanity/client": "^6.15.3",
|
|
172
153
|
"@sanity/icons": "^2.8",
|
|
173
154
|
"@sanity/types": "^3.25",
|
|
174
155
|
"@sanity/ui": "^1.8 || ^2.0.0-beta || ^2.0",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import NextImage, {ImageProps as NextImageProps} from 'next/image'
|
|
2
|
+
|
|
3
|
+
import {imageLoader} from './imageLoader'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
8
|
+
export interface ImageProps extends Omit<NextImageProps, 'loader' | 'src'> {
|
|
9
|
+
/**
|
|
10
|
+
* The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.
|
|
11
|
+
*/
|
|
12
|
+
loader?: never
|
|
13
|
+
/**
|
|
14
|
+
* Must be a string that is a valid URL to an image on the Sanity Image CDN.
|
|
15
|
+
*/
|
|
16
|
+
src: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
|
+
export function Image(props: ImageProps): JSX.Element {
|
|
23
|
+
const {loader, src, ...rest} = props
|
|
24
|
+
if (loader) {
|
|
25
|
+
throw new TypeError(
|
|
26
|
+
'The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.',
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
let srcUrl: URL
|
|
30
|
+
try {
|
|
31
|
+
srcUrl = new URL(src)
|
|
32
|
+
if (props.height) {
|
|
33
|
+
srcUrl.searchParams.set('h', `${props.height}`)
|
|
34
|
+
}
|
|
35
|
+
if (props.width) {
|
|
36
|
+
srcUrl.searchParams.set('w', `${props.width}`)
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
throw new TypeError(
|
|
40
|
+
'The `src` prop must be a valid URL to an image on the Sanity Image CDN.',
|
|
41
|
+
{cause: err},
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
return <NextImage {...rest} src={srcUrl.toString()} loader={imageLoader} />
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type {ImageLoader} from 'next/image'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
8
|
+
export const imageLoader = (({src, width, quality}) => {
|
|
9
|
+
const url = new URL(src)
|
|
10
|
+
url.searchParams.set('auto', 'format')
|
|
11
|
+
url.searchParams.set('fit', url.searchParams.get('fit') || 'min')
|
|
12
|
+
if (url.searchParams.has('h') && url.searchParams.has('w')) {
|
|
13
|
+
const originalHeight = parseInt(url.searchParams.get('h')!, 10)
|
|
14
|
+
const originalWidth = parseInt(url.searchParams.get('w')!, 10)
|
|
15
|
+
url.searchParams.set('h', Math.round((originalHeight / originalWidth) * width).toString())
|
|
16
|
+
}
|
|
17
|
+
url.searchParams.set('w', width.toString())
|
|
18
|
+
if (quality) {
|
|
19
|
+
url.searchParams.set('q', quality.toString())
|
|
20
|
+
}
|
|
21
|
+
return url.href
|
|
22
|
+
}) satisfies ImageLoader
|
|
@@ -6,10 +6,19 @@ import {revalidatePath} from 'next/cache.js'
|
|
|
6
6
|
import {draftMode} from 'next/headers.js'
|
|
7
7
|
|
|
8
8
|
export async function revalidateRootLayout(): Promise<void> {
|
|
9
|
-
|
|
9
|
+
try {
|
|
10
|
+
if (!draftMode().isEnabled) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.debug('Skipped revalidatePath request because draft mode is not enabled')
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
} catch (err) {
|
|
10
16
|
// eslint-disable-next-line no-console
|
|
11
|
-
console.
|
|
12
|
-
|
|
17
|
+
console.error('Error while checking if Draft Mode is enabled', err)
|
|
18
|
+
if (!(err as Error)?.message.includes('requestAsyncStorage')) {
|
|
19
|
+
console.warn('Ignoring')
|
|
20
|
+
return
|
|
21
|
+
}
|
|
13
22
|
}
|
|
14
23
|
await revalidatePath('/', 'layout')
|
|
15
24
|
}
|
package/dist/index.cjs.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import cjs from './index.cjs';
|
|
2
|
-
|
|
3
|
-
export const createClient = cjs.createClient;
|
|
4
|
-
export const unstable__adapter = cjs.unstable__adapter;
|
|
5
|
-
export const unstable__environment = cjs.unstable__environment;
|
|
6
|
-
export const VisualEditing = cjs.VisualEditing;
|
|
7
|
-
export const groq = cjs.groq;
|
|
8
|
-
export const toPlainText = cjs.toPlainText;
|
|
9
|
-
export const PortableText = cjs.PortableText;
|
|
10
|
-
export const defaultComponents = cjs.defaultComponents;
|
|
11
|
-
export const mergeComponents = cjs.mergeComponents;
|
|
12
|
-
|
package/dist/studio/index.cjs.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import cjs from './index.cjs';
|
|
2
|
-
|
|
3
|
-
export const metadata = cjs.metadata;
|
|
4
|
-
export const viewport = cjs.viewport;
|
|
5
|
-
export const NextStudio = cjs.NextStudio;
|
|
6
|
-
export const NextStudioLayout = cjs.NextStudioLayout;
|
|
7
|
-
export const NextStudioNoScript = cjs.NextStudioNoScript;
|
|
8
|
-
|