next-sanity 5.2.0-fetch.0 → 5.2.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/_chunks/loading-2003f32a.js.map +1 -1
- package/dist/_chunks/loading-225bb240.cjs.map +1 -1
- package/dist/index.cjs.js +0 -1
- package/dist/preview/index.cjs.js +0 -1
- package/dist/studio/head.cjs.js +0 -1
- package/dist/studio/index.cjs +7 -3
- package/dist/studio/index.cjs.js +0 -1
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/index.d.ts +1 -1
- package/dist/studio/index.js +7 -3
- package/dist/studio/index.js.map +1 -1
- package/dist/studio/loading.cjs.js +0 -1
- package/dist/studio/metadata.cjs.js +0 -1
- package/dist/webhook.cjs +17 -13
- package/dist/webhook.cjs.js +1 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.ts +22 -1
- package/dist/webhook.js +15 -6
- package/dist/webhook.js.map +1 -1
- package/package.json +32 -29
- package/src/studio/useTheme.ts +1 -1
- package/src/webhook/parseBody.ts +36 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-2003f32a.js","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {studioTheme} from '@sanity/ui'\nimport {useMemo} from 'react'\nimport type {Config, SingleWorkspace, StudioTheme} from 'sanity'\n\n/** @alpha */\nexport function useTheme(\n config?: Config | Required<Pick<SingleWorkspace, 'theme'
|
|
1
|
+
{"version":3,"file":"loading-2003f32a.js","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {studioTheme} from '@sanity/ui'\nimport {useMemo} from 'react'\nimport type {Config, SingleWorkspace, StudioTheme} from 'sanity'\n\n/** @alpha */\nexport function useTheme(\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>,\n): StudioTheme {\n const workspace = useMemo<\n SingleWorkspace | Required<Pick<SingleWorkspace, 'theme'>> | undefined\n >(() => (Array.isArray(config) ? config[0] : config), [config])\n return useMemo<StudioTheme>(() => workspace?.theme || studioTheme, [workspace])\n}\n","/* eslint-disable react/no-danger */\n\nconst style = {\n __html: `\n.sanity-app-no-js__root {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n background: #fff;\n z-index: 1;\n}\n\n.sanity-app-no-js__content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n text-align: center;\n font-family: helvetica, arial, sans-serif;\n}\n`,\n} as const\n\n/** @alpha */\nexport const NextStudioNoScript = () => (\n <noscript>\n <div className=\"sanity-app-no-js__root\">\n <div className=\"sanity-app-no-js__content\">\n <style type=\"text/css\" dangerouslySetInnerHTML={style} />\n <h1>JavaScript disabled</h1>\n <p>\n Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your\n browser and reload the page to proceed.\n </p>\n </div>\n </div>\n </noscript>\n)\n","/* eslint-disable no-warning-comments */\n// Intentionally not using `styled-components` to ensure it works in any `next` setup.\n// Whether 'styled-components' SSR is setup or not.\n\nimport {SpinnerIcon} from '@sanity/icons'\nimport {_responsive, rem} from '@sanity/ui'\nimport type {Config, SingleWorkspace, StudioProps} from 'sanity'\n\nimport {NextStudioNoScript} from './NextStudioNoScript'\nimport {useTheme} from './useTheme'\n\n/**\n * @alpha\n * @deprecated Will be removed in the next major release\n */\nexport interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {\n /**\n * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.\n */\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n}\n\nconst keyframes = `\nfrom {\n transform: rotate(0deg);\n}\n\nto {\n transform: rotate(360deg);\n}\n`\n\n/**\n * @alpha\n * @deprecated Will be removed in the next major release\n */\nexport function NextStudioLoading(props: NextStudioLoadingProps) {\n const {config, scheme = 'light', unstable__noScript = true} = props\n const id = 'next-sanity-spinner'\n const theme = useTheme(config)\n const {fonts, media} = theme\n\n const styles: any = _responsive(media, [2], (size: number) => {\n const {ascenderHeight, descenderHeight, lineHeight, iconSize} = fonts.text.sizes[size]\n const capHeight = lineHeight - ascenderHeight - descenderHeight\n\n return {\n wrapper: {\n display: 'block',\n animation: `${id} 500ms linear infinite`,\n color:\n theme.color[scheme === 'dark' ? 'dark' : 'light'].default.muted.default.enabled.muted\n .fg,\n width: rem(capHeight),\n height: rem(capHeight),\n },\n svg: {\n display: 'block',\n width: rem(iconSize),\n height: rem(iconSize),\n margin: (capHeight - iconSize) / 2,\n },\n }\n })[0]\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <div\n style={{\n fontFamily: fonts.text.family,\n backgroundColor: theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg,\n height: '100vh',\n maxHeight: '100dvh',\n overscrollBehavior: 'none',\n WebkitFontSmoothing: 'antialiased',\n overflow: 'auto',\n }}\n >\n <div\n data-ui=\"Flex\"\n style={{\n display: 'flex',\n minWidth: 0,\n minHeight: 0,\n alignItems: 'center',\n justifyContent: 'center',\n flexDirection: 'column',\n height: '100%',\n margin: 0,\n padding: 0,\n // @TODO use rem calc\n gap: '10px',\n }}\n >\n <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>\n <div\n data-ui=\"Text\"\n style={{\n position: 'relative',\n // @TODO read from theme\n fontWeight: 400,\n // @TODO read from theme\n padding: '1px 0px',\n // @TODO use rem calc\n fontSize: '1rem',\n // @TODO use rem calc\n lineHeight: 'calc(1.3125)',\n // @TODO use rem calc\n transform: 'translateY(-5px)',\n color:\n theme.color[scheme === 'dark' ? 'dark' : 'light'].default.muted.default.enabled\n .muted.fg,\n }}\n >\n <span>Loading…</span>\n </div>\n <div data-ui=\"Spinner\" style={styles.wrapper}>\n <SpinnerIcon style={styles.svg} />\n </div>\n </div>\n </div>\n </>\n )\n}\n"],"names":["useTheme","config","workspace","useMemo","Array","isArray","theme","studioTheme","style","__html","NextStudioNoScript","jsx","children","className","jsxs","type","dangerouslySetInnerHTML","href","keyframes","NextStudioLoading","props","scheme","unstable__noScript","id","fonts","media","styles","_responsive","size","ascenderHeight","descenderHeight","lineHeight","iconSize","text","sizes","capHeight","wrapper","display","animation","concat","color","default","muted","enabled","fg","width","rem","height","svg","margin","Fragment","fontFamily","family","backgroundColor","base","bg","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","minWidth","minHeight","alignItems","justifyContent","flexDirection","padding","gap","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;AAKO,SAASA,SACdC,MACa,EAAA;EACb,MAAMC,SAAY,GAAAC,OAAA,CAEhB,MAAOC,KAAA,CAAMC,OAAQ,CAAAJ,MAAM,CAAI,GAAAA,MAAA,CAAO,CAAC,CAAA,GAAIA,MAAS,EAAA,CAACA,MAAM,CAAC,CAAA;EAC9D,OAAOE,QAAqB,MAAM,CAAAD,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,SAAA,CAAWI,UAASC,WAAa,EAAA,CAACL,SAAS,CAAC,CAAA;AAChF;ACVA,MAAMM,KAAQ,GAAA;EACZC,MAAQ,EAAA;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqBA,CAAA,KAChC,eAAAC,GAAA,CAAC,UACC,EAAA;EAAAC,QAAA,EAAA,eAAAD,GAAA,CAAC,KAAI,EAAA;IAAAE,SAAA,EAAU,wBACb;IAAAD,QAAA,EAAA,eAAAE,IAAA,CAAC,KAAI,EAAA;MAAAD,SAAA,EAAU,2BACb;MAAAD,QAAA,EAAA,CAAA,eAAAD,GAAA,CAAC,OAAM,EAAA;QAAAI,IAAA,EAAK,UAAW;QAAAC,uBAAA,EAAyBR;OAAO,CAAA,EACvD,eAAAG,GAAA,CAAC;QAAGC,QAAmB,EAAA;MAAA,CAAA,CAAA,EAAA,oBACtB,GAAE,EAA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AU,EAAA,UAAA;YAAA;YAEVC,UAAY,EAAA,GAAA;YAAA;YAEZH,OAAS,EAAA,SAAA;YAAA;YAETI,QAAU,EAAA,MAAA;YAAA;YAEVtC,UAAY,EAAA,cAAA;YAAA;YAEZuC,SAAW,EAAA,kBAAA;YACX9B,KACE,EAAAlC,KAAA,CAAMkC,KAAM,CAAAnB,MAAA,KAAW,MAAS,GAAA,MAAA,GAAS,OAAO,CAAA,CAAEoB,OAAQ,CAAAC,KAAA,CAAMD,OAAQ,CAAAE,OAAA,CACrED,KAAM,CAAAE;UACb,CAAA;UAEAhC,QAAA,EAAA,eAAAD,GAAA,CAAC;YAAKC,QAAQ,EAAA;UAAA,CAAA;QAAA,CAChB,CAAA,EAAA,eACCD,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,KAAO,EAAAkB,MAAA,CAAOU,OACnC;UAAAxB,QAAA,EAAA,eAAAD,GAAA,CAAC4D,WAAY,EAAA;YAAA/D,KAAA,EAAOkB,MAAO,CAAAsB;UAAK,CAAA;SAClC,CAAA;MAAA,CACF;IAAA,CACF,CAAA;EACF,CAAA,CAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-225bb240.cjs","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {studioTheme} from '@sanity/ui'\nimport {useMemo} from 'react'\nimport type {Config, SingleWorkspace, StudioTheme} from 'sanity'\n\n/** @alpha */\nexport function useTheme(\n config?: Config | Required<Pick<SingleWorkspace, 'theme'
|
|
1
|
+
{"version":3,"file":"loading-225bb240.cjs","sources":["../../src/studio/useTheme.ts","../../src/studio/NextStudioNoScript.tsx","../../src/studio/NextStudioLoading.tsx"],"sourcesContent":["import {studioTheme} from '@sanity/ui'\nimport {useMemo} from 'react'\nimport type {Config, SingleWorkspace, StudioTheme} from 'sanity'\n\n/** @alpha */\nexport function useTheme(\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>,\n): StudioTheme {\n const workspace = useMemo<\n SingleWorkspace | Required<Pick<SingleWorkspace, 'theme'>> | undefined\n >(() => (Array.isArray(config) ? config[0] : config), [config])\n return useMemo<StudioTheme>(() => workspace?.theme || studioTheme, [workspace])\n}\n","/* eslint-disable react/no-danger */\n\nconst style = {\n __html: `\n.sanity-app-no-js__root {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n background: #fff;\n z-index: 1;\n}\n\n.sanity-app-no-js__content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n text-align: center;\n font-family: helvetica, arial, sans-serif;\n}\n`,\n} as const\n\n/** @alpha */\nexport const NextStudioNoScript = () => (\n <noscript>\n <div className=\"sanity-app-no-js__root\">\n <div className=\"sanity-app-no-js__content\">\n <style type=\"text/css\" dangerouslySetInnerHTML={style} />\n <h1>JavaScript disabled</h1>\n <p>\n Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your\n browser and reload the page to proceed.\n </p>\n </div>\n </div>\n </noscript>\n)\n","/* eslint-disable no-warning-comments */\n// Intentionally not using `styled-components` to ensure it works in any `next` setup.\n// Whether 'styled-components' SSR is setup or not.\n\nimport {SpinnerIcon} from '@sanity/icons'\nimport {_responsive, rem} from '@sanity/ui'\nimport type {Config, SingleWorkspace, StudioProps} from 'sanity'\n\nimport {NextStudioNoScript} from './NextStudioNoScript'\nimport {useTheme} from './useTheme'\n\n/**\n * @alpha\n * @deprecated Will be removed in the next major release\n */\nexport interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {\n /**\n * If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.\n */\n config?: Config | Required<Pick<SingleWorkspace, 'theme'>>\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n}\n\nconst keyframes = `\nfrom {\n transform: rotate(0deg);\n}\n\nto {\n transform: rotate(360deg);\n}\n`\n\n/**\n * @alpha\n * @deprecated Will be removed in the next major release\n */\nexport function NextStudioLoading(props: NextStudioLoadingProps) {\n const {config, scheme = 'light', unstable__noScript = true} = props\n const id = 'next-sanity-spinner'\n const theme = useTheme(config)\n const {fonts, media} = theme\n\n const styles: any = _responsive(media, [2], (size: number) => {\n const {ascenderHeight, descenderHeight, lineHeight, iconSize} = fonts.text.sizes[size]\n const capHeight = lineHeight - ascenderHeight - descenderHeight\n\n return {\n wrapper: {\n display: 'block',\n animation: `${id} 500ms linear infinite`,\n color:\n theme.color[scheme === 'dark' ? 'dark' : 'light'].default.muted.default.enabled.muted\n .fg,\n width: rem(capHeight),\n height: rem(capHeight),\n },\n svg: {\n display: 'block',\n width: rem(iconSize),\n height: rem(iconSize),\n margin: (capHeight - iconSize) / 2,\n },\n }\n })[0]\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <div\n style={{\n fontFamily: fonts.text.family,\n backgroundColor: theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg,\n height: '100vh',\n maxHeight: '100dvh',\n overscrollBehavior: 'none',\n WebkitFontSmoothing: 'antialiased',\n overflow: 'auto',\n }}\n >\n <div\n data-ui=\"Flex\"\n style={{\n display: 'flex',\n minWidth: 0,\n minHeight: 0,\n alignItems: 'center',\n justifyContent: 'center',\n flexDirection: 'column',\n height: '100%',\n margin: 0,\n padding: 0,\n // @TODO use rem calc\n gap: '10px',\n }}\n >\n <style key={scheme}>{`@keyframes ${id} {${keyframes}}`}</style>\n <div\n data-ui=\"Text\"\n style={{\n position: 'relative',\n // @TODO read from theme\n fontWeight: 400,\n // @TODO read from theme\n padding: '1px 0px',\n // @TODO use rem calc\n fontSize: '1rem',\n // @TODO use rem calc\n lineHeight: 'calc(1.3125)',\n // @TODO use rem calc\n transform: 'translateY(-5px)',\n color:\n theme.color[scheme === 'dark' ? 'dark' : 'light'].default.muted.default.enabled\n .muted.fg,\n }}\n >\n <span>Loading…</span>\n </div>\n <div data-ui=\"Spinner\" style={styles.wrapper}>\n <SpinnerIcon style={styles.svg} />\n </div>\n </div>\n </div>\n </>\n )\n}\n"],"names":["useTheme","config","workspace","useMemo","Array","isArray","theme","studioTheme","style","__html","NextStudioNoScript","jsx","children","className","jsxs","type","dangerouslySetInnerHTML","href","keyframes","NextStudioLoading","props","scheme","unstable__noScript","id","fonts","media","styles","_responsive","size","ascenderHeight","descenderHeight","lineHeight","iconSize","text","sizes","capHeight","wrapper","display","animation","concat","color","default","muted","enabled","fg","width","rem","height","svg","margin","Fragment","fontFamily","family","backgroundColor","base","bg","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","minWidth","minHeight","alignItems","justifyContent","flexDirection","padding","gap","position","fontWeight","fontSize","transform","SpinnerIcon"],"mappings":";;;;;;AAKO,SAASA,SACdC,MACa,EAAA;EACb,MAAMC,SAAY,GAAAC,KAAA,CAAAA,OAAA,CAEhB,MAAOC,KAAA,CAAMC,OAAQ,CAAAJ,MAAM,CAAI,GAAAA,MAAA,CAAO,CAAC,CAAA,GAAIA,MAAS,EAAA,CAACA,MAAM,CAAC,CAAA;EAC9D,OAAOE,cAAqB,MAAM,CAAAD,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,SAAA,CAAWI,UAASC,EAAAA,CAAAA,WAAa,EAAA,CAACL,SAAS,CAAC,CAAA;AAChF;ACVA,MAAMM,KAAQ,GAAA;EACZC,MAAQ,EAAA;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqBA,CAAA,KAChCC,eAAAA,UAAAA,CAAAA,GAAA,CAAC,UACC,EAAA;EAAAC,QAAA,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAC,KAAI,EAAA;IAAAE,SAAA,EAAU,wBACb;IAAAD,QAAA,EAAA,eAAAE,eAAA,CAAC,KAAI,EAAA;MAAAD,SAAA,EAAU,2BACb;MAAAD,QAAA,EAAA,CAAA,eAAAD,UAAA,CAAAA,GAAA,CAAC,OAAM,EAAA;QAAAI,IAAA,EAAK,U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A,CAAC;UAAoBC,QAAc,EAAA,aAAA,CAAA2B,MAAA,CAAAhB,EAAA,EAAE,IAAK,CAAA,CAAAgB,MAAA,CAAArB,SAAA,EAAS;WAAvCG,MAA2C,CAAA,EAAA,eACvDV,UAAA,CAAAA,GAAA,CAAC,KAAA,EAAA;UACC,SAAQ,EAAA,MAAA;UACRH,KAAO,EAAA;YACL2D,QAAU,EAAA,UAAA;YAAA;YAEVC,UAAY,EAAA,GAAA;YAAA;YAEZH,OAAS,EAAA,SAAA;YAAA;YAETI,QAAU,EAAA,MAAA;YAAA;YAEVtC,UAAY,EAAA,cAAA;YAAA;YAEZuC,SAAW,EAAA,kBAAA;YACX9B,KACE,EAAAlC,KAAA,CAAMkC,KAAM,CAAAnB,MAAA,KAAW,MAAS,GAAA,MAAA,GAAS,OAAO,CAAA,CAAEoB,OAAQ,CAAAC,KAAA,CAAMD,OAAQ,CAAAE,OAAA,CACrED,KAAM,CAAAE;UACb,CAAA;UAEAhC,QAAA,EAAAD,eAAAA,UAAAA,CAAAA,GAAA,CAAC;YAAKC,QAAQ,EAAA;UAAA,CAAA;QAAA,CAChB,CAAA,EAAA,eACCD,UAAA,CAAAA,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,KAAO,EAAAkB,MAAA,CAAOU,OACnC;UAAAxB,QAAA,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAC4D,KAAY,CAAAA,WAAA,EAAA;YAAA/D,KAAA,EAAOkB,MAAO,CAAAsB;UAAK,CAAA;SAClC,CAAA;MAAA,CACF;IAAA,CACF,CAAA;EACF,CAAA,CAAA;AAEJ;;;"}
|
package/dist/index.cjs.js
CHANGED
package/dist/studio/head.cjs.js
CHANGED
package/dist/studio/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _templateObject;
|
|
4
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
5
3
|
Object.defineProperty(exports, '__esModule', {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -27,7 +25,13 @@ function NextStudioClientOnly(_ref) {
|
|
|
27
25
|
children: mounted ? children : fallback
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
|
|
28
|
+
var __freeze = Object.freeze;
|
|
29
|
+
var __defProp = Object.defineProperty;
|
|
30
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", {
|
|
31
|
+
value: __freeze(raw || cooked.slice())
|
|
32
|
+
}));
|
|
33
|
+
var _a;
|
|
34
|
+
const Layout = styled__default.default.div(_a || (_a = __template(["\n font-family: ", ";\n background-color: ", ";\n height: 100vh;\n max-height: 100dvh;\n overscroll-behavior: none;\n -webkit-font-smoothing: antialiased;\n overflow: auto;\n"])), _ref2 => {
|
|
31
35
|
let {
|
|
32
36
|
$fontFamily
|
|
33
37
|
} = _ref2;
|
package/dist/studio/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/studio/NextStudioClientOnly.tsx","../../src/studio/NextStudioLayout.tsx","../../src/studio/NextStudio.tsx","../../src/studio/usePrefersColorScheme.ts"],"sourcesContent":["import {type ReactNode, startTransition, useEffect, useState} from 'react'\n\n/** @alpha */\nexport type NextStudioClientOnlyProps = {\n children: ReactNode\n fallback: ReactNode\n}\n\n/** @alpha */\nexport function NextStudioClientOnly({children, fallback}: NextStudioClientOnlyProps) {\n const [mounted, setMounted] = useState(false)\n useEffect(() => startTransition(() => setMounted(true)), [])\n\n return <>{mounted ? children : fallback}</>\n}\n","/* eslint-disable camelcase */\nimport {memo} from 'react'\nimport type {StudioProps} from 'sanity'\nimport styled from 'styled-components'\n\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLayoutProps extends Pick<StudioProps, 'config' | 'scheme'> {\n children: React.ReactNode\n}\n\ntype LayoutProps = {\n $bg: string\n $fontFamily: string\n}\nconst Layout = styled.div<LayoutProps>`\n font-family: ${({$fontFamily}) => $fontFamily};\n background-color: ${({$bg}: any) => $bg};\n height: 100vh;\n max-height: 100dvh;\n overscroll-behavior: none;\n -webkit-font-smoothing: antialiased;\n overflow: auto;\n`\n\nconst NextStudioLayoutComponent = ({\n children,\n config,\n scheme = 'light',\n}: NextStudioLayoutProps) => {\n const theme = useTheme(config)\n\n return (\n <Layout\n data-ui=\"NextStudioLayout\"\n $fontFamily={theme.fonts.text.family}\n $bg={theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg}\n >\n {children}\n </Layout>\n )\n}\n\n/** @alpha */\nexport const NextStudioLayout = memo(NextStudioLayoutComponent)\n","import {memo} from 'react'\nimport {Studio, type StudioProps} from 'sanity'\n\nimport {NextStudioClientOnly} from './NextStudioClientOnly'\nimport {NextStudioLayout} from './NextStudioLayout'\nimport {NextStudioLoading} from './NextStudioLoading'\nimport {NextStudioNoScript} from './NextStudioNoScript'\n\nexport type {NextStudioLoadingProps} from './NextStudioLoading'\n\n/** @beta */\nexport interface NextStudioProps extends StudioProps {\n children?: React.ReactNode\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n /**\n * Render in a faster mode that requires `styled-components` SSR to be setup.\n * @defaultValue false\n * @alpha\n */\n unstable__fastRender?: boolean\n}\n/**\n * Intended to render at the root of a page, letting the Studio own that page and render much like it would if you used `npx sanity start` to render\n * It's a drop-in replacement for `import {Studio} from 'sanity'`\n */\nconst NextStudioComponent = ({\n children,\n config,\n unstable__noScript = true,\n unstable__fastRender,\n scheme,\n ...props\n}: NextStudioProps) => {\n if (unstable__fastRender) {\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </>\n )\n }\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioClientOnly\n fallback={\n <NextStudioLoading\n unstable__noScript={unstable__noScript}\n config={config}\n scheme={scheme}\n />\n }\n >\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </NextStudioClientOnly>\n </>\n )\n}\n\n/**\n * Override how the Studio renders by passing children.\n * This is useful for advanced use cases where you're using StudioProvider and StudioLayout instead of Studio:\n * ```\n * import {StudioProvider, StudioLayout} from 'sanity'\n * import {NextStudio} from 'next-sanity/studio'\n * <NextStudio config={config}>\n * <StudioProvider config={config}>\n * <CustomComponentThatUsesContextFromStudioProvider />\n * <StudioLayout />\n * </StudioProvider>\n * </NextStudio>\n * ```\n * @beta\n */\nexport const NextStudio = memo(NextStudioComponent)\n","/* eslint-disable @typescript-eslint/no-empty-function */\nimport type {ThemeColorSchemeKey} from '@sanity/ui'\nimport {useSyncExternalStore} from 'react'\n\nfunction createStore() {\n if (typeof document === 'undefined') {\n return {\n subscribe: () => () => {},\n getSnapshot: () => 'light' as const,\n getServerSnapshot: () => 'light' as const,\n }\n }\n\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)')\n\n return {\n subscribe: (onStoreChange: () => void) => {\n matchMedia.addEventListener('change', onStoreChange)\n return () => matchMedia.removeEventListener('change', onStoreChange)\n },\n getSnapshot: () => (matchMedia.matches ? 'dark' : 'light'),\n getServerSnapshot: () => 'light' as const,\n }\n}\nconst store = createStore()\n\n/** @alpha */\nexport function usePrefersColorScheme(): ThemeColorSchemeKey {\n return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot)\n}\n"],"names":["NextStudioClientOnly","_ref","children","fallback","mounted","setMounted","useState","useEffect","startTransition","jsx","Fragment","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/studio/NextStudioClientOnly.tsx","../../src/studio/NextStudioLayout.tsx","../../src/studio/NextStudio.tsx","../../src/studio/usePrefersColorScheme.ts"],"sourcesContent":["import {type ReactNode, startTransition, useEffect, useState} from 'react'\n\n/** @alpha */\nexport type NextStudioClientOnlyProps = {\n children: ReactNode\n fallback: ReactNode\n}\n\n/** @alpha */\nexport function NextStudioClientOnly({children, fallback}: NextStudioClientOnlyProps) {\n const [mounted, setMounted] = useState(false)\n useEffect(() => startTransition(() => setMounted(true)), [])\n\n return <>{mounted ? children : fallback}</>\n}\n","/* eslint-disable camelcase */\nimport {memo} from 'react'\nimport type {StudioProps} from 'sanity'\nimport styled from 'styled-components'\n\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLayoutProps extends Pick<StudioProps, 'config' | 'scheme'> {\n children: React.ReactNode\n}\n\ntype LayoutProps = {\n $bg: string\n $fontFamily: string\n}\nconst Layout = styled.div<LayoutProps>`\n font-family: ${({$fontFamily}) => $fontFamily};\n background-color: ${({$bg}: any) => $bg};\n height: 100vh;\n max-height: 100dvh;\n overscroll-behavior: none;\n -webkit-font-smoothing: antialiased;\n overflow: auto;\n`\n\nconst NextStudioLayoutComponent = ({\n children,\n config,\n scheme = 'light',\n}: NextStudioLayoutProps) => {\n const theme = useTheme(config)\n\n return (\n <Layout\n data-ui=\"NextStudioLayout\"\n $fontFamily={theme.fonts.text.family}\n $bg={theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg}\n >\n {children}\n </Layout>\n )\n}\n\n/** @alpha */\nexport const NextStudioLayout = memo(NextStudioLayoutComponent)\n","import {memo} from 'react'\nimport {Studio, type StudioProps} from 'sanity'\n\nimport {NextStudioClientOnly} from './NextStudioClientOnly'\nimport {NextStudioLayout} from './NextStudioLayout'\nimport {NextStudioLoading} from './NextStudioLoading'\nimport {NextStudioNoScript} from './NextStudioNoScript'\n\nexport type {NextStudioLoadingProps} from './NextStudioLoading'\n\n/** @beta */\nexport interface NextStudioProps extends StudioProps {\n children?: React.ReactNode\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n /**\n * Render in a faster mode that requires `styled-components` SSR to be setup.\n * @defaultValue false\n * @alpha\n */\n unstable__fastRender?: boolean\n}\n/**\n * Intended to render at the root of a page, letting the Studio own that page and render much like it would if you used `npx sanity start` to render\n * It's a drop-in replacement for `import {Studio} from 'sanity'`\n */\nconst NextStudioComponent = ({\n children,\n config,\n unstable__noScript = true,\n unstable__fastRender,\n scheme,\n ...props\n}: NextStudioProps) => {\n if (unstable__fastRender) {\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </>\n )\n }\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioClientOnly\n fallback={\n <NextStudioLoading\n unstable__noScript={unstable__noScript}\n config={config}\n scheme={scheme}\n />\n }\n >\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </NextStudioClientOnly>\n </>\n )\n}\n\n/**\n * Override how the Studio renders by passing children.\n * This is useful for advanced use cases where you're using StudioProvider and StudioLayout instead of Studio:\n * ```\n * import {StudioProvider, StudioLayout} from 'sanity'\n * import {NextStudio} from 'next-sanity/studio'\n * <NextStudio config={config}>\n * <StudioProvider config={config}>\n * <CustomComponentThatUsesContextFromStudioProvider />\n * <StudioLayout />\n * </StudioProvider>\n * </NextStudio>\n * ```\n * @beta\n */\nexport const NextStudio = memo(NextStudioComponent)\n","/* eslint-disable @typescript-eslint/no-empty-function */\nimport type {ThemeColorSchemeKey} from '@sanity/ui'\nimport {useSyncExternalStore} from 'react'\n\nfunction createStore() {\n if (typeof document === 'undefined') {\n return {\n subscribe: () => () => {},\n getSnapshot: () => 'light' as const,\n getServerSnapshot: () => 'light' as const,\n }\n }\n\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)')\n\n return {\n subscribe: (onStoreChange: () => void) => {\n matchMedia.addEventListener('change', onStoreChange)\n return () => matchMedia.removeEventListener('change', onStoreChange)\n },\n getSnapshot: () => (matchMedia.matches ? 'dark' : 'light'),\n getServerSnapshot: () => 'light' as const,\n }\n}\nconst store = createStore()\n\n/** @alpha */\nexport function usePrefersColorScheme(): ThemeColorSchemeKey {\n return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot)\n}\n"],"names":["NextStudioClientOnly","_ref","children","fallback","mounted","setMounted","useState","useEffect","startTransition","jsx","Fragment","_a","Layout","styled","div","__template","_ref2","$fontFamily","_ref3","$bg","NextStudioLayoutComponent","_ref4","config","scheme","theme","useTheme","fonts","text","family","color","default","base","bg","NextStudioLayout","memo","NextStudioComponent","_ref5","unstable__noScript","unstable__fastRender","props","jsxs","NextStudioNoScript","Studio","unstable_globalStyles","NextStudioLoading","NextStudio","createStore","document","subscribe","getSnapshot","getServerSnapshot","matchMedia","window","onStoreChange","addEventListener","removeEventListener","matches","store","usePrefersColorScheme","useSyncExternalStore"],"mappings":";;;;;;;;;;;;;;;;AASO,SAASA,oBAAqBA,CAAAC,IAAA,EAAiD;EAAA,IAAjD;IAACC,QAAU;IAAAC;GAAsC,GAAAF,IAAA;EACpF,MAAM,CAACG,OAAA,EAASC,UAAU,CAAA,GAAIC,eAAS,KAAK,CAAA;EAClCC,KAAA,CAAAA,SAAA,CAAA,MAAMC,KAAAA,CAAAA,gBAAgB,MAAMH,UAAA,CAAW,IAAI,CAAC,CAAA,EAAG,EAAE,CAAA;EAEpD,OAAAI,eAAAA,UAAAA,CAAAA,GAAA,CAAAC,UAAAA,CAAAA,QAAA,EAAA;IAAGR,QAAU,EAAAE,OAAA,GAAAF,QAAA,GAAWC;EAAS,CAAA,CAAA;AAC1C;;;;;;ACdA,IAAAQ,EAAA;AAgBA,MAAMC,MAAS,GAAAC,eAAAA,CAAAA,OAAA,CAAOC,GAAP,CAAAH,EAAA,KAAAA,EAAA,GAAuBI,iCACS,yBACN,EAA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AA,EAAUF,aAAa,CAAA;IACrE,CAAA;IACAJ,WAAa,EAAAA,CAAA,KAAOE,UAAW,CAAAK,OAAA,GAAU,MAAS,GAAA,OAAA;IAClDN,mBAAmBA,CAAA,KAAM;EAAA,CAC3B;AACF;AACA,MAAMO,QAAQX,WAAY,CAAA,CAAA;AAGnB,SAASY,qBAA6CA,CAAA,EAAA;EAC3D,OAAOC,KAAAA,CAAAA,qBAAqBF,KAAM,CAAAT,SAAA,EAAWS,KAAM,CAAAR,WAAA,EAAaQ,MAAMP,iBAAiB,CAAA;AACzF;;;;;;"}
|
package/dist/studio/index.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare function usePrefersColorScheme(): ThemeColorSchemeKey
|
|
|
99
99
|
|
|
100
100
|
/** @alpha */
|
|
101
101
|
export declare function useTheme(
|
|
102
|
-
config?: Config | Required<Pick<SingleWorkspace, 'theme'
|
|
102
|
+
config?: Config | Required<Pick<SingleWorkspace, 'theme'>>,
|
|
103
103
|
): StudioTheme
|
|
104
104
|
|
|
105
105
|
export {}
|
package/dist/studio/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var _templateObject;
|
|
2
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
2
|
import { useState, useEffect, startTransition, memo, useSyncExternalStore } from 'react';
|
|
5
3
|
import { Studio } from 'sanity';
|
|
@@ -16,7 +14,13 @@ function NextStudioClientOnly(_ref) {
|
|
|
16
14
|
children: mounted ? children : fallback
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
|
-
|
|
17
|
+
var __freeze = Object.freeze;
|
|
18
|
+
var __defProp = Object.defineProperty;
|
|
19
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", {
|
|
20
|
+
value: __freeze(raw || cooked.slice())
|
|
21
|
+
}));
|
|
22
|
+
var _a;
|
|
23
|
+
const Layout = styled.div(_a || (_a = __template(["\n font-family: ", ";\n background-color: ", ";\n height: 100vh;\n max-height: 100dvh;\n overscroll-behavior: none;\n -webkit-font-smoothing: antialiased;\n overflow: auto;\n"])), _ref2 => {
|
|
20
24
|
let {
|
|
21
25
|
$fontFamily
|
|
22
26
|
} = _ref2;
|
package/dist/studio/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/studio/NextStudioClientOnly.tsx","../../src/studio/NextStudioLayout.tsx","../../src/studio/NextStudio.tsx","../../src/studio/usePrefersColorScheme.ts"],"sourcesContent":["import {type ReactNode, startTransition, useEffect, useState} from 'react'\n\n/** @alpha */\nexport type NextStudioClientOnlyProps = {\n children: ReactNode\n fallback: ReactNode\n}\n\n/** @alpha */\nexport function NextStudioClientOnly({children, fallback}: NextStudioClientOnlyProps) {\n const [mounted, setMounted] = useState(false)\n useEffect(() => startTransition(() => setMounted(true)), [])\n\n return <>{mounted ? children : fallback}</>\n}\n","/* eslint-disable camelcase */\nimport {memo} from 'react'\nimport type {StudioProps} from 'sanity'\nimport styled from 'styled-components'\n\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLayoutProps extends Pick<StudioProps, 'config' | 'scheme'> {\n children: React.ReactNode\n}\n\ntype LayoutProps = {\n $bg: string\n $fontFamily: string\n}\nconst Layout = styled.div<LayoutProps>`\n font-family: ${({$fontFamily}) => $fontFamily};\n background-color: ${({$bg}: any) => $bg};\n height: 100vh;\n max-height: 100dvh;\n overscroll-behavior: none;\n -webkit-font-smoothing: antialiased;\n overflow: auto;\n`\n\nconst NextStudioLayoutComponent = ({\n children,\n config,\n scheme = 'light',\n}: NextStudioLayoutProps) => {\n const theme = useTheme(config)\n\n return (\n <Layout\n data-ui=\"NextStudioLayout\"\n $fontFamily={theme.fonts.text.family}\n $bg={theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg}\n >\n {children}\n </Layout>\n )\n}\n\n/** @alpha */\nexport const NextStudioLayout = memo(NextStudioLayoutComponent)\n","import {memo} from 'react'\nimport {Studio, type StudioProps} from 'sanity'\n\nimport {NextStudioClientOnly} from './NextStudioClientOnly'\nimport {NextStudioLayout} from './NextStudioLayout'\nimport {NextStudioLoading} from './NextStudioLoading'\nimport {NextStudioNoScript} from './NextStudioNoScript'\n\nexport type {NextStudioLoadingProps} from './NextStudioLoading'\n\n/** @beta */\nexport interface NextStudioProps extends StudioProps {\n children?: React.ReactNode\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n /**\n * Render in a faster mode that requires `styled-components` SSR to be setup.\n * @defaultValue false\n * @alpha\n */\n unstable__fastRender?: boolean\n}\n/**\n * Intended to render at the root of a page, letting the Studio own that page and render much like it would if you used `npx sanity start` to render\n * It's a drop-in replacement for `import {Studio} from 'sanity'`\n */\nconst NextStudioComponent = ({\n children,\n config,\n unstable__noScript = true,\n unstable__fastRender,\n scheme,\n ...props\n}: NextStudioProps) => {\n if (unstable__fastRender) {\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </>\n )\n }\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioClientOnly\n fallback={\n <NextStudioLoading\n unstable__noScript={unstable__noScript}\n config={config}\n scheme={scheme}\n />\n }\n >\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </NextStudioClientOnly>\n </>\n )\n}\n\n/**\n * Override how the Studio renders by passing children.\n * This is useful for advanced use cases where you're using StudioProvider and StudioLayout instead of Studio:\n * ```\n * import {StudioProvider, StudioLayout} from 'sanity'\n * import {NextStudio} from 'next-sanity/studio'\n * <NextStudio config={config}>\n * <StudioProvider config={config}>\n * <CustomComponentThatUsesContextFromStudioProvider />\n * <StudioLayout />\n * </StudioProvider>\n * </NextStudio>\n * ```\n * @beta\n */\nexport const NextStudio = memo(NextStudioComponent)\n","/* eslint-disable @typescript-eslint/no-empty-function */\nimport type {ThemeColorSchemeKey} from '@sanity/ui'\nimport {useSyncExternalStore} from 'react'\n\nfunction createStore() {\n if (typeof document === 'undefined') {\n return {\n subscribe: () => () => {},\n getSnapshot: () => 'light' as const,\n getServerSnapshot: () => 'light' as const,\n }\n }\n\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)')\n\n return {\n subscribe: (onStoreChange: () => void) => {\n matchMedia.addEventListener('change', onStoreChange)\n return () => matchMedia.removeEventListener('change', onStoreChange)\n },\n getSnapshot: () => (matchMedia.matches ? 'dark' : 'light'),\n getServerSnapshot: () => 'light' as const,\n }\n}\nconst store = createStore()\n\n/** @alpha */\nexport function usePrefersColorScheme(): ThemeColorSchemeKey {\n return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot)\n}\n"],"names":["NextStudioClientOnly","_ref","children","fallback","mounted","setMounted","useState","useEffect","startTransition","jsx","Fragment","Layout","styled","div","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/studio/NextStudioClientOnly.tsx","../../src/studio/NextStudioLayout.tsx","../../src/studio/NextStudio.tsx","../../src/studio/usePrefersColorScheme.ts"],"sourcesContent":["import {type ReactNode, startTransition, useEffect, useState} from 'react'\n\n/** @alpha */\nexport type NextStudioClientOnlyProps = {\n children: ReactNode\n fallback: ReactNode\n}\n\n/** @alpha */\nexport function NextStudioClientOnly({children, fallback}: NextStudioClientOnlyProps) {\n const [mounted, setMounted] = useState(false)\n useEffect(() => startTransition(() => setMounted(true)), [])\n\n return <>{mounted ? children : fallback}</>\n}\n","/* eslint-disable camelcase */\nimport {memo} from 'react'\nimport type {StudioProps} from 'sanity'\nimport styled from 'styled-components'\n\nimport {useTheme} from './useTheme'\n\n/** @alpha */\nexport interface NextStudioLayoutProps extends Pick<StudioProps, 'config' | 'scheme'> {\n children: React.ReactNode\n}\n\ntype LayoutProps = {\n $bg: string\n $fontFamily: string\n}\nconst Layout = styled.div<LayoutProps>`\n font-family: ${({$fontFamily}) => $fontFamily};\n background-color: ${({$bg}: any) => $bg};\n height: 100vh;\n max-height: 100dvh;\n overscroll-behavior: none;\n -webkit-font-smoothing: antialiased;\n overflow: auto;\n`\n\nconst NextStudioLayoutComponent = ({\n children,\n config,\n scheme = 'light',\n}: NextStudioLayoutProps) => {\n const theme = useTheme(config)\n\n return (\n <Layout\n data-ui=\"NextStudioLayout\"\n $fontFamily={theme.fonts.text.family}\n $bg={theme.color[scheme === 'dark' ? 'dark' : 'light'].default.base.bg}\n >\n {children}\n </Layout>\n )\n}\n\n/** @alpha */\nexport const NextStudioLayout = memo(NextStudioLayoutComponent)\n","import {memo} from 'react'\nimport {Studio, type StudioProps} from 'sanity'\n\nimport {NextStudioClientOnly} from './NextStudioClientOnly'\nimport {NextStudioLayout} from './NextStudioLayout'\nimport {NextStudioLoading} from './NextStudioLoading'\nimport {NextStudioNoScript} from './NextStudioNoScript'\n\nexport type {NextStudioLoadingProps} from './NextStudioLoading'\n\n/** @beta */\nexport interface NextStudioProps extends StudioProps {\n children?: React.ReactNode\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n /**\n * Render in a faster mode that requires `styled-components` SSR to be setup.\n * @defaultValue false\n * @alpha\n */\n unstable__fastRender?: boolean\n}\n/**\n * Intended to render at the root of a page, letting the Studio own that page and render much like it would if you used `npx sanity start` to render\n * It's a drop-in replacement for `import {Studio} from 'sanity'`\n */\nconst NextStudioComponent = ({\n children,\n config,\n unstable__noScript = true,\n unstable__fastRender,\n scheme,\n ...props\n}: NextStudioProps) => {\n if (unstable__fastRender) {\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </>\n )\n }\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <NextStudioClientOnly\n fallback={\n <NextStudioLoading\n unstable__noScript={unstable__noScript}\n config={config}\n scheme={scheme}\n />\n }\n >\n <NextStudioLayout config={config} scheme={scheme}>\n {children || (\n <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />\n )}\n </NextStudioLayout>\n </NextStudioClientOnly>\n </>\n )\n}\n\n/**\n * Override how the Studio renders by passing children.\n * This is useful for advanced use cases where you're using StudioProvider and StudioLayout instead of Studio:\n * ```\n * import {StudioProvider, StudioLayout} from 'sanity'\n * import {NextStudio} from 'next-sanity/studio'\n * <NextStudio config={config}>\n * <StudioProvider config={config}>\n * <CustomComponentThatUsesContextFromStudioProvider />\n * <StudioLayout />\n * </StudioProvider>\n * </NextStudio>\n * ```\n * @beta\n */\nexport const NextStudio = memo(NextStudioComponent)\n","/* eslint-disable @typescript-eslint/no-empty-function */\nimport type {ThemeColorSchemeKey} from '@sanity/ui'\nimport {useSyncExternalStore} from 'react'\n\nfunction createStore() {\n if (typeof document === 'undefined') {\n return {\n subscribe: () => () => {},\n getSnapshot: () => 'light' as const,\n getServerSnapshot: () => 'light' as const,\n }\n }\n\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)')\n\n return {\n subscribe: (onStoreChange: () => void) => {\n matchMedia.addEventListener('change', onStoreChange)\n return () => matchMedia.removeEventListener('change', onStoreChange)\n },\n getSnapshot: () => (matchMedia.matches ? 'dark' : 'light'),\n getServerSnapshot: () => 'light' as const,\n }\n}\nconst store = createStore()\n\n/** @alpha */\nexport function usePrefersColorScheme(): ThemeColorSchemeKey {\n return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot)\n}\n"],"names":["NextStudioClientOnly","_ref","children","fallback","mounted","setMounted","useState","useEffect","startTransition","jsx","Fragment","_a","Layout","styled","div","__template","_ref2","$fontFamily","_ref3","$bg","NextStudioLayoutComponent","_ref4","config","scheme","theme","useTheme","fonts","text","family","color","default","base","bg","NextStudioLayout","memo","NextStudioComponent","_ref5","unstable__noScript","unstable__fastRender","props","jsxs","NextStudioNoScript","Studio","unstable_globalStyles","NextStudioLoading","NextStudio","createStore","document","subscribe","getSnapshot","getServerSnapshot","matchMedia","window","onStoreChange","addEventListener","removeEventListener","matches","store","usePrefersColorScheme","useSyncExternalStore"],"mappings":";;;;;AASO,SAASA,oBAAqBA,CAAAC,IAAA,EAAiD;EAAA,IAAjD;IAACC,QAAU;IAAAC;GAAsC,GAAAF,IAAA;EACpF,MAAM,CAACG,OAAA,EAASC,UAAU,CAAA,GAAIC,SAAS,KAAK,CAAA;EAClCC,SAAA,CAAA,MAAMC,gBAAgB,MAAMH,UAAA,CAAW,IAAI,CAAC,CAAA,EAAG,EAAE,CAAA;EAEpD,OAAA,eAAAI,GAAA,CAAAC,QAAA,EAAA;IAAGR,QAAU,EAAAE,OAAA,GAAAF,QAAA,GAAWC;EAAS,CAAA,CAAA;AAC1C;;;;;;ACdA,IAAAQ,EAAA;AAgBA,MAAMC,MAAS,GAAAC,MAAA,CAAOC,GAAP,CAAAH,EAAA,KAAAA,EAAA,GAAuBI,iCACS,yBACN,EAAA,uIAAA,CAAA,CAAA,CAAA,EADxBC,KAAA;EAAA,IAAC;IAACC;GAAiB,GAAAD,KAAA;EAAA,OAAAC,WAAA;AAAA,GACdC,KAAA;EAAA,IAAC;IAACC;GAAc,GAAAD,KAAA;EAAA,OAAAC,GAAA;AAAA,EAAA;AAQtC,MAAMC,4BAA4BC,KAAA,IAIL;EAAA,IAJM;IACjCnB,QAAA;IACAoB,MAAA;IACAC,MAAS,GAAA;EACX,CAA6B,GAAAF,KAAA;EACrB,MAAAG,KAAA,GAAQC,SAASH,MAAM,CAAA;EAG3B,sBAAAb,GAAA,CAACG,MAAA,EAAA;IACC,SAAQ,EAAA,kBAAA;IACRK,WAAA,EAAaO,KAAM,CAAAE,KAAA,CAAMC,IAAK,CAAAC,MA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AAE;UAAA,GAAGJ;QAAO,CAAA;OAE7E;IAAA,CACF,CAAA;EACF,CAAA,CAAA;AAEJ,CAAA;AAiBa,MAAAM,UAAA,GAAaX,KAAKC,mBAAmB,CAAA;ACpFlD,SAASW,WAAcA,CAAA,EAAA;EACjB,IAAA,OAAOC,aAAa,WAAa,EAAA;IAC5B,OAAA;MACLC,SAAA,EAAWA,CAAA,KAAM,MAAM,CAAC,CAAA;MACxBC,aAAaA,CAAA,KAAM,OAAA;MACnBC,mBAAmBA,CAAA,KAAM;IAAA,CAC3B;EACF;EAEM,MAAAC,UAAA,GAAaC,MAAO,CAAAD,UAAA,CAAW,8BAA8B,CAAA;EAE5D,OAAA;IACLH,SAAA,EAAYK,aAA8B,IAAA;MAC7BF,UAAA,CAAAG,gBAAA,CAAiB,UAAUD,aAAa,CAAA;MACnD,OAAO,MAAMF,UAAA,CAAWI,mBAAoB,CAAA,QAAA,EAAUF,aAAa,CAAA;IACrE,CAAA;IACAJ,WAAa,EAAAA,CAAA,KAAOE,UAAW,CAAAK,OAAA,GAAU,MAAS,GAAA,OAAA;IAClDN,mBAAmBA,CAAA,KAAM;EAAA,CAC3B;AACF;AACA,MAAMO,QAAQX,WAAY,CAAA,CAAA;AAGnB,SAASY,qBAA6CA,CAAA,EAAA;EAC3D,OAAOC,qBAAqBF,KAAM,CAAAT,SAAA,EAAWS,KAAM,CAAAR,WAAA,EAAaQ,MAAMP,iBAAiB,CAAA;AACzF;"}
|
package/dist/webhook.cjs
CHANGED
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
function _interopDefaultCompat(e) {
|
|
8
|
-
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
9
|
-
default: e
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
var sanityWebhook__default = /*#__PURE__*/_interopDefaultCompat(sanityWebhook);
|
|
6
|
+
var webhook = require('@sanity/webhook');
|
|
13
7
|
const config = {
|
|
14
8
|
api: {
|
|
15
9
|
/**
|
|
@@ -29,18 +23,27 @@ async function _readBody(readable) {
|
|
|
29
23
|
}
|
|
30
24
|
return Buffer.concat(chunks).toString("utf8");
|
|
31
25
|
}
|
|
32
|
-
const {
|
|
33
|
-
isValidSignature,
|
|
34
|
-
SIGNATURE_HEADER_NAME
|
|
35
|
-
} = sanityWebhook__default.default;
|
|
36
26
|
async function parseBody(req, secret) {
|
|
37
27
|
let waitForContentLakeEventualConsistency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
38
|
-
let signature = req.headers[SIGNATURE_HEADER_NAME];
|
|
28
|
+
let signature = req.headers[webhook.SIGNATURE_HEADER_NAME];
|
|
39
29
|
if (Array.isArray(signature)) {
|
|
40
30
|
signature = signature[0];
|
|
41
31
|
}
|
|
42
32
|
const body = await _readBody(req);
|
|
43
|
-
const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null;
|
|
33
|
+
const validSignature = secret ? webhook.isValidSignature(body, signature, secret.trim()) : null;
|
|
34
|
+
if (validSignature !== false && waitForContentLakeEventualConsistency) {
|
|
35
|
+
await new Promise(resolve => setTimeout(resolve, 1e3));
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
body: body.trim() && JSON.parse(body),
|
|
39
|
+
isValidSignature: validSignature
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function parseAppBody(req, secret) {
|
|
43
|
+
let waitForContentLakeEventualConsistency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
44
|
+
const signature = req.headers.get(webhook.SIGNATURE_HEADER_NAME);
|
|
45
|
+
const body = await req.text();
|
|
46
|
+
const validSignature = secret ? webhook.isValidSignature(body, signature, secret.trim()) : null;
|
|
44
47
|
if (validSignature !== false && waitForContentLakeEventualConsistency) {
|
|
45
48
|
await new Promise(resolve => setTimeout(resolve, 1e3));
|
|
46
49
|
}
|
|
@@ -50,5 +53,6 @@ async function parseBody(req, secret) {
|
|
|
50
53
|
};
|
|
51
54
|
}
|
|
52
55
|
exports.config = config;
|
|
56
|
+
exports.parseAppBody = parseAppBody;
|
|
53
57
|
exports.parseBody = parseBody;
|
|
54
58
|
//# sourceMappingURL=webhook.cjs.map
|
package/dist/webhook.cjs.js
CHANGED
package/dist/webhook.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.cjs","sources":["../src/webhook/config.ts","../src/webhook/readBody.ts","../src/webhook/parseBody.ts"],"sourcesContent":["import type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n /**\n * `@sanity/webhook` isn't updated to support the edge runtime yet, and currently requires Node.js APIs such as Buffer.\n */\n runtime: 'nodejs',\n}\n","import type {NextApiRequest} from 'next'\n\n/** @internal */\nexport async function _readBody(readable: NextApiRequest): Promise<string> {\n const chunks = []\n for await (const chunk of readable) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)\n }\n return Buffer.concat(chunks).toString('utf8')\n}\n","import type {SanityDocument} from '@sanity/types'\nimport
|
|
1
|
+
{"version":3,"file":"webhook.cjs","sources":["../src/webhook/config.ts","../src/webhook/readBody.ts","../src/webhook/parseBody.ts"],"sourcesContent":["import type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n /**\n * `@sanity/webhook` isn't updated to support the edge runtime yet, and currently requires Node.js APIs such as Buffer.\n */\n runtime: 'nodejs',\n}\n","import type {NextApiRequest} from 'next'\n\n/** @internal */\nexport async function _readBody(readable: NextApiRequest): Promise<string> {\n const chunks = []\n for await (const chunk of readable) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)\n }\n return Buffer.concat(chunks).toString('utf8')\n}\n","import type {SanityDocument} from '@sanity/types'\nimport {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\nimport type {NextRequest} from 'next/server'\n\nimport {_readBody as readBody} from './readBody'\n\n/** @public */\nexport type ParseBody = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: SanityDocument\n}\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n */\nexport async function parseBody(\n req: NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParseBody> {\n let signature = req.headers[SIGNATURE_HEADER_NAME]!\n if (Array.isArray(signature)) {\n signature = signature[0]\n }\n\n const body = await readBody(req)\n const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 1000))\n }\n\n return {\n body: body.trim() && JSON.parse(body),\n isValidSignature: validSignature,\n }\n}\n\n/** @public */\nexport type ParseAppBody = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: SanityDocument\n}\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n */\nexport async function parseAppBody(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParseAppBody> {\n const signature = req.headers.get(SIGNATURE_HEADER_NAME)!\n\n const body = await req.text()\n const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 1000))\n }\n\n return {\n body: body.trim() && JSON.parse(body),\n isValidSignature: validSignature,\n }\n}\n"],"names":["config","api","bodyParser","runtime","_readBody","readable","chunks","chunk","push","Buffer","from","concat","toString","parseBody","req","secret","waitForContentLakeEventualConsistency","arguments","length","undefined","signature","headers","SIGNATURE_HEADER_NAME","Array","isArray","body","readBody","validSignature","isValidSignature","trim","Promise","resolve","setTimeout","JSON","parse","parseAppBody","get","text"],"mappings":";;;;;;AAMO,MAAMA,MAAqB,GAAA;EAChCC,GAAK,EAAA;IAAA;AAAA;AAAA;IAIHC,UAAY,EAAA;EACd,CAAA;EAAA;AAAA;AAAA;EAIAC,OAAS,EAAA;AACX,CAAA;ACdA,eAAsBC,UAAUC,QAA2C,EAAA;EACzE,MAAMC,SAAS,EAAC;EAChB,WAAA,MAAiBC,SAASF,QAAU,EAAA;IAC3BC,MAAA,CAAAE,IAAA,CAAK,OAAOD,KAAU,KAAA,QAAA,GAAWE,OAAOC,IAAK,CAAAH,KAAK,IAAIA,KAAK,CAAA;EACpE;EACA,OAAOE,MAAO,CAAAE,MAAA,CAAOL,MAAM,CAAA,CAAEM,SAAS,MAAM,CAAA;AAC9C;ACWA,eAAsBC,SACpBA,CAAAC,GAAA,EACAC,MACA,EACoB;EAAA,IADpBC,qCAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAiD,IAC7B;EAChB,IAAAG,SAAA,GAAYN,GAAI,CAAAO,OAAA,CAAQC,OAAqB,CAAAA,qBAAA,CAAA;EAC7C,IAAAC,KAAA,CAAMC,OAAQ,CAAAJ,SAAS,CAAG,EAAA;IAC5BA,SAAA,GAAYA,UAAU,CAAC,CAAA;EACzB;EAEM,MAAAK,IAAA,GAAO,MAAMC,SAAA,CAASZ,GAAG,CAAA;EACzB,MAAAa,cAAA,GAAiBZ,SAASa,OAAAA,CAAAA,gBAAiB,CAAAH,IAAA,EAAML,WAAWL,MAAO,CAAAc,IAAA,EAAM,CAAI,GAAA,IAAA;EAE/E,IAAAF,cAAA,KAAmB,SAASX,qCAAuC,EAAA;IACrE,MAAM,IAAIc,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLN,MAAMA,IAAK,CAAAI,IAAA,CAAA,CAAU,IAAAI,IAAA,CAAKC,MAAMT,IAAI,CAAA;IACpCG,gBAAkB,EAAAD;EAAA,CACpB;AACF;AAeA,eAAsBQ,YACpBA,CAAArB,GAAA,EACAC,MACA,EACuB;EAAA,IADvBC,qCAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAiD,IAC1B;EACvB,MAAMG,SAAY,GAAAN,GAAA,CAAIO,OAAQ,CAAAe,GAAA,CAAId,OAAqB,CAAAA,qBAAA,CAAA;EAEjD,MAAAG,IAAA,GAAO,MAAMX,GAAA,CAAIuB,IAAK,EAAA;EACtB,MAAAV,cAAA,GAAiBZ,SAASa,OAAAA,CAAAA,gBAAiB,CAAAH,IAAA,EAAML,WAAWL,MAAO,CAAAc,IAAA,EAAM,CAAI,GAAA,IAAA;EAE/E,IAAAF,cAAA,KAAmB,SAASX,qCAAuC,EAAA;IACrE,MAAM,IAAIc,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLN,MAAMA,IAAK,CAAAI,IAAA,CAAA,CAAU,IAAAI,IAAA,CAAKC,MAAMT,IAAI,CAAA;IACpCG,gBAAkB,EAAAD;EAAA,CACpB;AACF;;;"}
|
package/dist/webhook.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {NextApiRequest} from 'next'
|
|
2
|
+
import type {NextRequest} from 'next/server'
|
|
2
3
|
import type {PageConfig} from 'next/types'
|
|
3
4
|
import type {SanityDocument} from '@sanity/types'
|
|
4
5
|
|
|
@@ -8,6 +9,26 @@ import type {SanityDocument} from '@sanity/types'
|
|
|
8
9
|
*/
|
|
9
10
|
export declare const config: PageConfig
|
|
10
11
|
|
|
12
|
+
/** @public */
|
|
13
|
+
export declare type ParseAppBody = {
|
|
14
|
+
/**
|
|
15
|
+
* If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`
|
|
16
|
+
*/
|
|
17
|
+
isValidSignature: boolean | null
|
|
18
|
+
body: SanityDocument
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
|
|
23
|
+
* without worrying about getting stale data.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseAppBody(
|
|
27
|
+
req: NextRequest,
|
|
28
|
+
secret?: string,
|
|
29
|
+
waitForContentLakeEventualConsistency?: boolean,
|
|
30
|
+
): Promise<ParseAppBody>
|
|
31
|
+
|
|
11
32
|
/** @public */
|
|
12
33
|
export declare type ParseBody = {
|
|
13
34
|
/**
|
|
@@ -25,7 +46,7 @@ export declare type ParseBody = {
|
|
|
25
46
|
export declare function parseBody(
|
|
26
47
|
req: NextApiRequest,
|
|
27
48
|
secret?: string,
|
|
28
|
-
waitForContentLakeEventualConsistency?: boolean
|
|
49
|
+
waitForContentLakeEventualConsistency?: boolean,
|
|
29
50
|
): Promise<ParseBody>
|
|
30
51
|
|
|
31
52
|
export {}
|
package/dist/webhook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isValidSignature, SIGNATURE_HEADER_NAME } from '@sanity/webhook';
|
|
2
2
|
const config = {
|
|
3
3
|
api: {
|
|
4
4
|
/**
|
|
@@ -18,10 +18,6 @@ async function _readBody(readable) {
|
|
|
18
18
|
}
|
|
19
19
|
return Buffer.concat(chunks).toString("utf8");
|
|
20
20
|
}
|
|
21
|
-
const {
|
|
22
|
-
isValidSignature,
|
|
23
|
-
SIGNATURE_HEADER_NAME
|
|
24
|
-
} = sanityWebhook;
|
|
25
21
|
async function parseBody(req, secret) {
|
|
26
22
|
let waitForContentLakeEventualConsistency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
27
23
|
let signature = req.headers[SIGNATURE_HEADER_NAME];
|
|
@@ -38,5 +34,18 @@ async function parseBody(req, secret) {
|
|
|
38
34
|
isValidSignature: validSignature
|
|
39
35
|
};
|
|
40
36
|
}
|
|
41
|
-
|
|
37
|
+
async function parseAppBody(req, secret) {
|
|
38
|
+
let waitForContentLakeEventualConsistency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
39
|
+
const signature = req.headers.get(SIGNATURE_HEADER_NAME);
|
|
40
|
+
const body = await req.text();
|
|
41
|
+
const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null;
|
|
42
|
+
if (validSignature !== false && waitForContentLakeEventualConsistency) {
|
|
43
|
+
await new Promise(resolve => setTimeout(resolve, 1e3));
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
body: body.trim() && JSON.parse(body),
|
|
47
|
+
isValidSignature: validSignature
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export { config, parseAppBody, parseBody };
|
|
42
51
|
//# sourceMappingURL=webhook.js.map
|
package/dist/webhook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sources":["../src/webhook/config.ts","../src/webhook/readBody.ts","../src/webhook/parseBody.ts"],"sourcesContent":["import type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n /**\n * `@sanity/webhook` isn't updated to support the edge runtime yet, and currently requires Node.js APIs such as Buffer.\n */\n runtime: 'nodejs',\n}\n","import type {NextApiRequest} from 'next'\n\n/** @internal */\nexport async function _readBody(readable: NextApiRequest): Promise<string> {\n const chunks = []\n for await (const chunk of readable) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)\n }\n return Buffer.concat(chunks).toString('utf8')\n}\n","import type {SanityDocument} from '@sanity/types'\nimport
|
|
1
|
+
{"version":3,"file":"webhook.js","sources":["../src/webhook/config.ts","../src/webhook/readBody.ts","../src/webhook/parseBody.ts"],"sourcesContent":["import type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n /**\n * `@sanity/webhook` isn't updated to support the edge runtime yet, and currently requires Node.js APIs such as Buffer.\n */\n runtime: 'nodejs',\n}\n","import type {NextApiRequest} from 'next'\n\n/** @internal */\nexport async function _readBody(readable: NextApiRequest): Promise<string> {\n const chunks = []\n for await (const chunk of readable) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)\n }\n return Buffer.concat(chunks).toString('utf8')\n}\n","import type {SanityDocument} from '@sanity/types'\nimport {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\nimport type {NextRequest} from 'next/server'\n\nimport {_readBody as readBody} from './readBody'\n\n/** @public */\nexport type ParseBody = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: SanityDocument\n}\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n */\nexport async function parseBody(\n req: NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParseBody> {\n let signature = req.headers[SIGNATURE_HEADER_NAME]!\n if (Array.isArray(signature)) {\n signature = signature[0]\n }\n\n const body = await readBody(req)\n const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 1000))\n }\n\n return {\n body: body.trim() && JSON.parse(body),\n isValidSignature: validSignature,\n }\n}\n\n/** @public */\nexport type ParseAppBody = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: SanityDocument\n}\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n */\nexport async function parseAppBody(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParseAppBody> {\n const signature = req.headers.get(SIGNATURE_HEADER_NAME)!\n\n const body = await req.text()\n const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 1000))\n }\n\n return {\n body: body.trim() && JSON.parse(body),\n isValidSignature: validSignature,\n }\n}\n"],"names":["config","api","bodyParser","runtime","_readBody","readable","chunks","chunk","push","Buffer","from","concat","toString","parseBody","req","secret","waitForContentLakeEventualConsistency","arguments","length","undefined","signature","headers","SIGNATURE_HEADER_NAME","Array","isArray","body","readBody","validSignature","isValidSignature","trim","Promise","resolve","setTimeout","JSON","parse","parseAppBody","get","text"],"mappings":";AAMO,MAAMA,MAAqB,GAAA;EAChCC,GAAK,EAAA;IAAA;AAAA;AAAA;IAIHC,UAAY,EAAA;EACd,CAAA;EAAA;AAAA;AAAA;EAIAC,OAAS,EAAA;AACX,CAAA;ACdA,eAAsBC,UAAUC,QAA2C,EAAA;EACzE,MAAMC,SAAS,EAAC;EAChB,WAAA,MAAiBC,SAASF,QAAU,EAAA;IAC3BC,MAAA,CAAAE,IAAA,CAAK,OAAOD,KAAU,KAAA,QAAA,GAAWE,OAAOC,IAAK,CAAAH,KAAK,IAAIA,KAAK,CAAA;EACpE;EACA,OAAOE,MAAO,CAAAE,MAAA,CAAOL,MA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AAF,cAAA,KAAmB,SAASX,qCAAuC,EAAA;IACrE,MAAM,IAAIc,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLN,MAAMA,IAAK,CAAAI,IAAA,CAAA,CAAU,IAAAI,IAAA,CAAKC,MAAMT,IAAI,CAAA;IACpCG,gBAAkB,EAAAD;EAAA,CACpB;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-sanity",
|
|
3
|
-
"version": "5.2.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -160,54 +160,54 @@
|
|
|
160
160
|
"singleQuote": true
|
|
161
161
|
},
|
|
162
162
|
"dependencies": {
|
|
163
|
-
"@sanity/preview-kit": "2.4.
|
|
163
|
+
"@sanity/preview-kit": "2.4.7",
|
|
164
164
|
"@sanity/webhook": "2.0.0",
|
|
165
165
|
"groq": "^3.0.0"
|
|
166
166
|
},
|
|
167
167
|
"devDependencies": {
|
|
168
|
-
"@next/eslint-plugin-next": "13.4.
|
|
168
|
+
"@next/eslint-plugin-next": "13.4.12",
|
|
169
169
|
"@rollup/plugin-url": "^8.0.1",
|
|
170
|
-
"@sanity/client": "6.
|
|
171
|
-
"@sanity/eslint-config-studio": "^
|
|
170
|
+
"@sanity/client": "6.4.0",
|
|
171
|
+
"@sanity/eslint-config-studio": "^3.0.0",
|
|
172
172
|
"@sanity/image-url": "^1.0.2",
|
|
173
|
-
"@sanity/pkg-utils": "^2.3.
|
|
174
|
-
"@sanity/semantic-release-preset": "^4.1.
|
|
175
|
-
"@sanity/ui": "^1.
|
|
176
|
-
"@sanity/vision": "3.14.
|
|
173
|
+
"@sanity/pkg-utils": "^2.3.12",
|
|
174
|
+
"@sanity/semantic-release-preset": "^4.1.2",
|
|
175
|
+
"@sanity/ui": "^1.7.4",
|
|
176
|
+
"@sanity/vision": "3.14.5",
|
|
177
177
|
"@types/eventsource": "^1.1.11",
|
|
178
|
-
"@types/jest": "^29.5.
|
|
179
|
-
"@types/react": "^18.2.
|
|
180
|
-
"@types/react-dom": "^18.2.
|
|
178
|
+
"@types/jest": "^29.5.3",
|
|
179
|
+
"@types/react": "^18.2.18",
|
|
180
|
+
"@types/react-dom": "^18.2.7",
|
|
181
181
|
"@types/styled-components": "^5.1.26",
|
|
182
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
182
|
+
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
|
183
183
|
"autoprefixer": "^10.4.14",
|
|
184
|
-
"eslint": "^8.
|
|
185
|
-
"eslint-config-prettier": "^
|
|
184
|
+
"eslint": "^8.46.0",
|
|
185
|
+
"eslint-config-prettier": "^9.0.0",
|
|
186
186
|
"eslint-config-sanity": "^6.0.0",
|
|
187
187
|
"eslint-gitignore": "^0.1.0",
|
|
188
|
-
"eslint-plugin-prettier": "^
|
|
188
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
189
189
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
190
|
-
"groqd": "^0.15.
|
|
191
|
-
"jest": "^29.
|
|
192
|
-
"jest-environment-jsdom": "^29.
|
|
190
|
+
"groqd": "^0.15.7",
|
|
191
|
+
"jest": "^29.6.2",
|
|
192
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
193
193
|
"ls-engines": "^0.9.0",
|
|
194
|
-
"next": "13.4.
|
|
195
|
-
"postcss": "^8.4.
|
|
196
|
-
"prettier": "^
|
|
197
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
198
|
-
"prettier-plugin-tailwindcss": "^0.
|
|
194
|
+
"next": "13.4.13-canary.16",
|
|
195
|
+
"postcss": "^8.4.27",
|
|
196
|
+
"prettier": "^3.0.1",
|
|
197
|
+
"prettier-plugin-packagejson": "^2.4.5",
|
|
198
|
+
"prettier-plugin-tailwindcss": "^0.4.1",
|
|
199
199
|
"react": "^18.2.0",
|
|
200
200
|
"react-dom": "^18.2.0",
|
|
201
201
|
"react-is": "^18.2.0",
|
|
202
|
-
"rollup": "^3.
|
|
203
|
-
"sanity": "3.14.
|
|
202
|
+
"rollup": "^3.27.2",
|
|
203
|
+
"sanity": "3.14.5",
|
|
204
204
|
"styled-components": "^5.3.11",
|
|
205
|
-
"tailwindcss": "^3.3.
|
|
206
|
-
"typescript": "^5.1.
|
|
205
|
+
"tailwindcss": "^3.3.3",
|
|
206
|
+
"typescript": "^5.1.6",
|
|
207
207
|
"url-loader": "^4.1.1"
|
|
208
208
|
},
|
|
209
209
|
"peerDependencies": {
|
|
210
|
-
"@sanity/client": "^6.1.4
|
|
210
|
+
"@sanity/client": "^6.1.4",
|
|
211
211
|
"@sanity/icons": "^2.0.0",
|
|
212
212
|
"@sanity/types": "^3.0.0",
|
|
213
213
|
"@sanity/ui": "^1.0.0",
|
|
@@ -219,5 +219,8 @@
|
|
|
219
219
|
},
|
|
220
220
|
"engines": {
|
|
221
221
|
"node": ">=16.14"
|
|
222
|
+
},
|
|
223
|
+
"publishConfig": {
|
|
224
|
+
"provenance": true
|
|
222
225
|
}
|
|
223
226
|
}
|
package/src/studio/useTheme.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {Config, SingleWorkspace, StudioTheme} from 'sanity'
|
|
|
4
4
|
|
|
5
5
|
/** @alpha */
|
|
6
6
|
export function useTheme(
|
|
7
|
-
config?: Config | Required<Pick<SingleWorkspace, 'theme'
|
|
7
|
+
config?: Config | Required<Pick<SingleWorkspace, 'theme'>>,
|
|
8
8
|
): StudioTheme {
|
|
9
9
|
const workspace = useMemo<
|
|
10
10
|
SingleWorkspace | Required<Pick<SingleWorkspace, 'theme'>> | undefined
|
package/src/webhook/parseBody.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type {SanityDocument} from '@sanity/types'
|
|
2
|
-
import
|
|
2
|
+
import {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'
|
|
3
3
|
import type {NextApiRequest} from 'next'
|
|
4
|
-
|
|
5
|
-
// As `@sanity/webhook` isn't shipping ESM, extracting from the default export have the best ecosystem support
|
|
6
|
-
const {isValidSignature, SIGNATURE_HEADER_NAME} = sanityWebhook
|
|
4
|
+
import type {NextRequest} from 'next/server'
|
|
7
5
|
|
|
8
6
|
import {_readBody as readBody} from './readBody'
|
|
9
7
|
|
|
@@ -23,7 +21,7 @@ export type ParseBody = {
|
|
|
23
21
|
export async function parseBody(
|
|
24
22
|
req: NextApiRequest,
|
|
25
23
|
secret?: string,
|
|
26
|
-
waitForContentLakeEventualConsistency: boolean = true
|
|
24
|
+
waitForContentLakeEventualConsistency: boolean = true,
|
|
27
25
|
): Promise<ParseBody> {
|
|
28
26
|
let signature = req.headers[SIGNATURE_HEADER_NAME]!
|
|
29
27
|
if (Array.isArray(signature)) {
|
|
@@ -42,3 +40,36 @@ export async function parseBody(
|
|
|
42
40
|
isValidSignature: validSignature,
|
|
43
41
|
}
|
|
44
42
|
}
|
|
43
|
+
|
|
44
|
+
/** @public */
|
|
45
|
+
export type ParseAppBody = {
|
|
46
|
+
/**
|
|
47
|
+
* If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`
|
|
48
|
+
*/
|
|
49
|
+
isValidSignature: boolean | null
|
|
50
|
+
body: SanityDocument
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
|
|
54
|
+
* without worrying about getting stale data.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export async function parseAppBody(
|
|
58
|
+
req: NextRequest,
|
|
59
|
+
secret?: string,
|
|
60
|
+
waitForContentLakeEventualConsistency: boolean = true,
|
|
61
|
+
): Promise<ParseAppBody> {
|
|
62
|
+
const signature = req.headers.get(SIGNATURE_HEADER_NAME)!
|
|
63
|
+
|
|
64
|
+
const body = await req.text()
|
|
65
|
+
const validSignature = secret ? isValidSignature(body, signature, secret.trim()) : null
|
|
66
|
+
|
|
67
|
+
if (validSignature !== false && waitForContentLakeEventualConsistency) {
|
|
68
|
+
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
body: body.trim() && JSON.parse(body),
|
|
73
|
+
isValidSignature: validSignature,
|
|
74
|
+
}
|
|
75
|
+
}
|