next-sanity 0.0.0-dev.2 → 0.0.0-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -520,7 +520,6 @@ Both the Next `/app` and `/pages` examples uses this config file:
520
520
  `sanity.config.ts`:
521
521
 
522
522
  ```ts
523
- import {visionTool} from '@sanity/vision'
524
523
  import {defineConfig} from 'sanity'
525
524
  import {deskTool} from 'sanity/desk'
526
525
 
@@ -535,7 +534,7 @@ export default defineConfig({
535
534
  projectId,
536
535
  dataset,
537
536
 
538
- plugins: [deskTool(), visionTool()],
537
+ plugins: [deskTool()],
539
538
 
540
539
  schema: {
541
540
  types: schemaTypes,
@@ -1 +1 @@
1
- {"version":3,"file":"NextStudioLoading-8cf56cdf.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/** @alpha */\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\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: theme.color[scheme].default.muted.default.enabled.muted.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].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: theme.color[scheme].default.muted.default.enabled.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","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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AA,CAAA;UACXC,UAAY,EAAA,QAAA;UACZC,cAAgB,EAAA,QAAA;UAChBC,aAAe,EAAA,QAAA;UACfjB,MAAQ,EAAA,MAAA;UACRE,MAAQ,EAAA,CAAA;UACRgB,OAAS,EAAA,CAAA;UAAA;UAETC,GAAK,EAAA;QACP,CAAA;QAEArD,QAAA,EAAA,CAAA,eAAAD,GAAA,CAAC,OAAoB,EAAA;UAAAC,QAAA,uBAAcW,EAAO,eAAAL,SAAA;QAAA,CAAA,EAA9BG,MAA2C,CAAA,EAAA,eACvDV,GAAA,CAAC,KAAA,EAAA;UACC,SAAQ,EAAA,MAAA;UACRH,KAAO,EAAA;YACL0D,QAAU,EAAA,UAAA;YAAA;YAEVC,UAAY,EAAA,GAAA;YAAA;YAEZH,OAAS,EAAA,SAAA;YAAA;YAETI,QAAU,EAAA,MAAA;YAAA;YAEVrC,UAAY,EAAA,cAAA;YAAA;YAEZsC,SAAW,EAAA,kBAAA;YACX9B,KAAA,EAAOjC,MAAMiC,KAAM,CAAAlB,MAAM,EAAEmB,OAAQ,CAAAC,KAAA,CAAMD,OAAQ,CAAAE,OAAA,CAAQD,KAAM,CAAAE;UACjE,CAAA;UAEA/B,QAAA,EAAA,eAAAD,GAAA,CAAC;YAAKC,QAAQ,EAAA;UAAA,CAAA;QAAA,CAAA,CAChB,EAAA,eACCD,GAAA,CAAA,KAAA,EAAA;UAAI,SAAQ,EAAA,SAAA;UAAUH,KAAO,EAAAkB,MAAA,CAAOU,OACnC;UAAAxB,QAAA,EAAA,eAAAD,GAAA,CAAC2D,WAAY,EAAA;YAAA9D,KAAA,EAAOkB,MAAO,CAAAqB;UAAK,CAAA;SAClC,CAAA;MAAA,CAAA;IACF,CAAA,CACF;EACF,CAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"NextStudioLoading-8cf56cdf.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/** @alpha */\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\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: theme.color[scheme].default.muted.default.enabled.muted.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].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: theme.color[scheme].default.muted.default.enabled.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","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","concat","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;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,EAAA;Q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A;YAAA;YAEZuC,SAAW,EAAA,kBAAA;YACX/B,KAAA,EAAOjC,MAAMiC,KAAM,CAAAlB,MAAM,EAAEmB,OAAQ,CAAAC,KAAA,CAAMD,OAAQ,CAAAE,OAAA,CAAQD,KAAM,CAAAE;UACjE,CAAA;UAEA/B,QAAA,EAAA,eAAAD,GAAA,CAAC;YAAKC,QAAQ,EAAA;UAAA,CAAA;QAAA,CAAA,CAChB,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,CAAAqB;UAAK,CAAA;SAClC,CAAA;MAAA,CAAA;IACF,CAAA,CACF;EACF,CAAA,CAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NextStudioLoading-bf57e61a.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/** @alpha */\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\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: theme.color[scheme].default.muted.default.enabled.muted.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].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: theme.color[scheme].default.muted.default.enabled.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","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,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AAxB,QAAA,EAAA,eAAAD,UAAA,CAAAA,GAAA,CAAC2D,KAAY,CAAAA,WAAA,EAAA;YAAA9D,KAAA,EAAOkB,MAAO,CAAAqB;UAAK,CAAA;SAClC,CAAA;MAAA,CAAA;IACF,CAAA,CACF;EACF,CAAA,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"NextStudioLoading-bf57e61a.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/** @alpha */\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\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: theme.color[scheme].default.muted.default.enabled.muted.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].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: theme.color[scheme].default.muted.default.enabled.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","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","concat","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;AAoBV,CAAA;AAGa,MAAAC,kBAAA,GAAqBA,CAAA,KAChCC,eAAAA,UAAAA,CAAAA,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= require('@sanity/preview-kit/client');
7
7
  var groq = require('groq');
8
8
  function _interopDefaultCompat(e) {
9
9
  return e && typeof e === 'object' && 'default' in e ? e : {
@@ -11,16 +11,26 @@ function _interopDefaultCompat(e) {
11
11
  };
12
12
  }
13
13
  var groq__default = /*#__PURE__*/_interopDefaultCompat(groq);
14
- Object.defineProperty(exports, 'createClient', {
15
- enumerable: true,
16
- get: function () {
17
- return client.createClient;
14
+ function createClient(config) {
15
+ let {
16
+ // eslint-disable-next-line prefer-const
17
+ studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL,
18
+ encodeSourceMap = studioUrl ? "auto" : "none"
19
+ } = config;
20
+ if (encodeSourceMap === "auto" && process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
21
+ encodeSourceMap = "stega";
18
22
  }
19
- });
23
+ return client.createClient({
24
+ ...config,
25
+ studioUrl,
26
+ encodeSourceMap
27
+ });
28
+ }
20
29
  Object.defineProperty(exports, 'groq', {
21
30
  enumerable: true,
22
31
  get: function () {
23
32
  return groq__default.default;
24
33
  }
25
34
  });
35
+ exports.createClient = createClient;
26
36
  //# sourceMappingURL=index.cjs.map
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import cjs from './index.cjs';
2
2
 
3
- export const createClient = cjs.createClient;
4
3
  export const groq = cjs.groq;
4
+ export const createClient = cjs.createClient;
5
5
 
6
6
  export default cjs.default;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/client.ts"],"sourcesContent":["import {\n type ClientConfig as _ClientConfig,\n createClient as _createClient,\n} from '@sanity/preview-kit/client'\n\n/** @public */\nexport interface ClientConfig extends Omit<_ClientConfig, 'studioUrl' | 'encodeSourceMap'> {\n /**\n * Where the Studio is hosted.\n * If it's embedded in the app, use the base path for example `/studio`.\n * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.\n * @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL\n * @alpha\n */\n studioUrl?: _ClientConfig['studioUrl']\n /**\n * If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.\n * @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'\n * @alpha\n */\n encodeSourceMap?: _ClientConfig['encodeSourceMap']\n}\n\n/**\n * @public\n */\nexport function createClient(config: ClientConfig): ReturnType<typeof _createClient> {\n let {\n // eslint-disable-next-line prefer-const\n studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL! as _ClientConfig['studioUrl'],\n encodeSourceMap = studioUrl ? 'auto' : 'none',\n } = config\n if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {\n encodeSourceMap = 'stega'\n }\n return _createClient({...config, studioUrl, encodeSourceMap})\n}\n"],"names":["createClient","config","studioUrl","process","env","NEXT_PUBLIC_SANITY_STUDIO_URL","encodeSourceMap","NEXT_PUBLIC_VERCEL_ENV","_createClient"],"mappings":";;;;;;;;;;;;;AA0BO,SAASA,aAAaC,MAAwD,EAAA;EAC/E,IAAA;IAAA;IAEFC,SAAA,GAAYC,QAAQC,GAAI,CAAAC,6BAAA;IACxBC,eAAA,GAAkBJ,YAAY,MAAS,GAAA;EACrC,CAAA,GAAAD,MAAA;EACJ,IAAIK,eAAoB,KAAA,MAAA,IAAUH,OAAQ,CAAAC,GAAA,CAAIG,2BAA2B,SAAW,EAAA;IAChED,eAAA,GAAA,OAAA;EACpB;EACA,OAAOE,MAAAA,CAAAA,aAAc;IAAC,GAAGP,MAAQ;IAAAC,SAAA;IAAWI;EAAgB,CAAA,CAAA;AAC9D;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,33 @@
1
1
  import {ClientConfig} from '@sanity/client'
2
- import {createClient} from '@sanity/client'
2
+ import {ClientConfig as ClientConfig_3} from '@sanity/preview-kit/client'
3
+ import {createClient as createClient_2} from '@sanity/preview-kit/client'
3
4
  import {default as groq} from 'groq'
4
5
  import {SanityClient} from '@sanity/client'
5
6
 
6
7
  export {ClientConfig}
7
8
 
8
- export {createClient}
9
+ /** @public */
10
+ declare interface ClientConfig_2 extends Omit<ClientConfig_3, 'studioUrl' | 'encodeSourceMap'> {
11
+ /**
12
+ * Where the Studio is hosted.
13
+ * If it's embedded in the app, use the base path for example `/studio`.
14
+ * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
15
+ * @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL
16
+ * @alpha
17
+ */
18
+ studioUrl?: ClientConfig_3['studioUrl']
19
+ /**
20
+ * If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.
21
+ * @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'
22
+ * @alpha
23
+ */
24
+ encodeSourceMap?: ClientConfig_3['encodeSourceMap']
25
+ }
26
+
27
+ /**
28
+ * @public
29
+ */
30
+ export declare function createClient(config: ClientConfig_2): ReturnType<typeof createClient_2>
9
31
 
10
32
  export {groq}
11
33
 
package/dist/index.js CHANGED
@@ -1,3 +1,19 @@
1
- export { createClient } from '@sanity/client';
1
+ import { createClient as createClient$1 } from '@sanity/preview-kit/client';
2
2
  export { default as groq } from 'groq';
3
+ function createClient(config) {
4
+ let {
5
+ // eslint-disable-next-line prefer-const
6
+ studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL,
7
+ encodeSourceMap = studioUrl ? "auto" : "none"
8
+ } = config;
9
+ if (encodeSourceMap === "auto" && process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
10
+ encodeSourceMap = "stega";
11
+ }
12
+ return createClient$1({
13
+ ...config,
14
+ studioUrl,
15
+ encodeSourceMap
16
+ });
17
+ }
18
+ export { createClient };
3
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.js","sources":["../src/client.ts"],"sourcesContent":["import {\n type ClientConfig as _ClientConfig,\n createClient as _createClient,\n} from '@sanity/preview-kit/client'\n\n/** @public */\nexport interface ClientConfig extends Omit<_ClientConfig, 'studioUrl' | 'encodeSourceMap'> {\n /**\n * Where the Studio is hosted.\n * If it's embedded in the app, use the base path for example `/studio`.\n * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.\n * @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL\n * @alpha\n */\n studioUrl?: _ClientConfig['studioUrl']\n /**\n * If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.\n * @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'\n * @alpha\n */\n encodeSourceMap?: _ClientConfig['encodeSourceMap']\n}\n\n/**\n * @public\n */\nexport function createClient(config: ClientConfig): ReturnType<typeof _createClient> {\n let {\n // eslint-disable-next-line prefer-const\n studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL! as _ClientConfig['studioUrl'],\n encodeSourceMap = studioUrl ? 'auto' : 'none',\n } = config\n if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {\n encodeSourceMap = 'stega'\n }\n return _createClient({...config, studioUrl, encodeSourceMap})\n}\n"],"names":["createClient","config","studioUrl","process","env","NEXT_PUBLIC_SANITY_STUDIO_URL","encodeSourceMap","NEXT_PUBLIC_VERCEL_ENV","_createClient"],"mappings":";;AA0BO,SAASA,aAAaC,MAAwD,EAAA;EAC/E,IAAA;IAAA;IAEFC,SAAA,GAAYC,QAAQC,GAAI,CAAAC,6BAAA;IACxBC,eAAA,GAAkBJ,YAAY,MAAS,GAAA;EACrC,CAAA,GAAAD,MAAA;EACJ,IAAIK,eAAoB,KAAA,MAAA,IAAUH,OAAQ,CAAAC,GAAA,CAAIG,2BAA2B,SAAW,EAAA;IAChED,eAAA,GAAA,OAAA;EACpB;EACA,OAAOE,eAAc;IAAC,GAAGP,MAAQ;IAAAC,SAAA;IAAWI;EAAgB,CAAA,CAAA;AAC9D;"}
package/dist/preview.cjs CHANGED
@@ -16,10 +16,4 @@ Object.defineProperty(exports, 'definePreview', {
16
16
  return previewKit.definePreview;
17
17
  }
18
18
  });
19
- Object.defineProperty(exports, 'unstable_usePreview', {
20
- enumerable: true,
21
- get: function () {
22
- return previewKit.unstable_usePreview;
23
- }
24
- });
25
19
  //# sourceMappingURL=preview.cjs.map
@@ -2,6 +2,5 @@ import cjs from './preview.cjs';
2
2
 
3
3
  export const PreviewSuspense = cjs.PreviewSuspense;
4
4
  export const definePreview = cjs.definePreview;
5
- export const unstable_usePreview = cjs.unstable_usePreview;
6
5
 
7
6
  export default cjs.default;
@@ -1 +1 @@
1
- {"version":3,"file":"preview.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"preview.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
package/dist/preview.d.ts CHANGED
@@ -3,8 +3,6 @@ import {Params} from '@sanity/preview-kit'
3
3
  import {PreviewConfig} from '@sanity/preview-kit'
4
4
  import {PreviewSuspense} from '@sanity/preview-kit'
5
5
  import {PreviewSuspenseProps} from '@sanity/preview-kit'
6
- import {unstable_PreviewConfig} from '@sanity/preview-kit'
7
- import {unstable_usePreview} from '@sanity/preview-kit'
8
6
  import {UsePreview} from '@sanity/preview-kit'
9
7
 
10
8
  export {definePreview}
@@ -17,10 +15,6 @@ export {PreviewSuspense}
17
15
 
18
16
  export {PreviewSuspenseProps}
19
17
 
20
- export {unstable_PreviewConfig}
21
-
22
- export {unstable_usePreview}
23
-
24
18
  export {UsePreview}
25
19
 
26
20
  export {}
package/dist/preview.js CHANGED
@@ -1,2 +1,2 @@
1
- export { PreviewSuspense, definePreview, unstable_usePreview } from '@sanity/preview-kit';
1
+ export { PreviewSuspense, definePreview } from '@sanity/preview-kit';
2
2
  //# sourceMappingURL=preview.js.map
@@ -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].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, type NextStudioLoadingProps} from './NextStudioLoading'\n\nexport type {NextStudioLoadingProps}\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?: NextStudioLoadingProps['unstable__noScript']\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,\n scheme,\n ...props\n}: NextStudioProps) => (\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 || <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />}\n </NextStudioLayout>\n </NextStudioClientOnly>\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","children","fallback","mounted","setMounted","useState","useEffect","startTransition","jsx","Fragment","Layout","styled","default","div","$fontFamily","$bg","NextStudioLayoutComponent","config","scheme","theme","useTheme","fonts","text","family","color","base","bg","NextStudioLayout","memo","NextStudioComponent","unstable__noScript","props","NextStudioLoading","Studio","unstable_globalStyles","NextStudio","createStore","document","subscribe","getSnapshot","getServerSnapshot","matchMedia","window","onStoreChange","addEventListener","removeEventListener","matches","store","usePrefersColorScheme","useSyncExternalStore"],"mappings":";;;;;;;;;;;;;;;;;;AASO,SAASA,oBAAqB,OAAiD;EAAA,IAAjD;IAACC,QAAU;IAAAC;GAAsC;EACpF,MAAM,CAACC,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;ACEA,MAAMQ,SAASC,eAAO,CAAAC,OAAA,CAAAC,GAAA,2PACL;EAAA,IAAC;IAACC;EAAiB,CAAA;EAAA,OAAAA,WAAA;AAAA,GACd;EAAA,IAAC;IAACC;EAAc,CAAA;EAAA,OAAAA,GAAA;AAAA,EAAA;AAQtC,MAAMC,4BAA4B,SAIL;EAAA,IAJM;IACjCf,QAAA;IACAgB,MAAA;IACAC,MAAS,GAAA;EAC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C,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,EAAA,MAAOE,UAAW,CAAAK,OAAA,GAAU,MAAS,GAAA,OAAA;IAClDN,mBAAmB,MAAM;EAAA,CAC3B;AACF;AACA,MAAMO,QAAQX,WAAY,EAAA;AAGnB,SAASY,qBAA6C,GAAA;EAC3D,OAAOC,KAAAA,CAAAA,qBAAqBF,KAAM,CAAAT,SAAA,EAAWS,KAAM,CAAAR,WAAA,EAAaQ,MAAMP,iBAAiB,CAAA;AACzF;;;;;;"}
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].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, type NextStudioLoadingProps} from './NextStudioLoading'\n\nexport type {NextStudioLoadingProps}\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?: NextStudioLoadingProps['unstable__noScript']\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,\n scheme,\n ...props\n}: NextStudioProps) => (\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 || <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />}\n </NextStudioLayout>\n </NextStudioClientOnly>\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","default","div","_templateObject","_taggedTemplateLiteral","_ref2","$fontFamily","_ref3","$bg","NextStudioLayoutComponent","_ref4","config","scheme","theme","useTheme","fonts","text","family","color","base","bg","NextStudioLayout","memo","NextStudioComponent","_ref5","unstable__noScript","props","NextStudioLoading","Studio","unstable_globalStyles","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,OAA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AAAA,GAAA,CAAAwB,gBAAA,EAAA;MAAiBV,MAAgB;MAAAC,MAAA;MAC/BtB,QAAY,EAAAA,QAAA,IAAAO,eAAAA,UAAAA,CAAAA,GAAA,CAAC+B,MAAAA,CAAAA,MAAO,EAAA;QAAAjB,MAAA;QAAgBC,MAAgB;QAAAiB,qBAAA,EAAqB,IAAE;QAAA,GAAGH;MAAO,CAAA;KACxF;EAAA,CAAA,CACF;AAAA;AAkBW,MAAAI,UAAA,GAAaR,WAAKC,mBAAmB,CAAA;ACxDlD,SAASQ,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,EAAA;AAGnB,SAASY,qBAA6CA,CAAA,EAAA;EAC3D,OAAOC,KAAAA,CAAAA,qBAAqBF,KAAM,CAAAT,SAAA,EAAWS,KAAM,CAAAR,WAAA,EAAaQ,MAAMP,iBAAiB,CAAA;AACzF;;;;;;"}
@@ -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].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, type NextStudioLoadingProps} from './NextStudioLoading'\n\nexport type {NextStudioLoadingProps}\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?: NextStudioLoadingProps['unstable__noScript']\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,\n scheme,\n ...props\n}: NextStudioProps) => (\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 || <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />}\n </NextStudioLayout>\n </NextStudioClientOnly>\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","children","fallback","mounted","setMounted","useState","useEffect","startTransition","jsx","Fragment","Layout","styled","div","$fontFamily","$bg","NextStudioLayoutComponent","config","scheme","theme","useTheme","fonts","text","family","color","default","base","bg","NextStudioLayout","memo","NextStudioComponent","unstable__noScript","props","NextStudioLoading","Studio","unstable_globalStyles","NextStudio","createStore","document","subscribe","getSnapshot","getServerSnapshot","matchMedia","window","onStoreChange","addEventListener","removeEventListener","matches","store","usePrefersColorScheme","useSyncExternalStore"],"mappings":";;;;;;;;AASO,SAASA,oBAAqB,OAAiD;EAAA,IAAjD;IAACC,QAAU;IAAAC;GAAsC;EACpF,MAAM,CAACC,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;ACEA,MAAMQ,SAASC,MAAO,CAAAC,GAAA,2PACL;EAAA,IAAC;IAACC;EAAiB,CAAA;EAAA,OAAAA,WAAA;AAAA,GACd;EAAA,IAAC;IAACC;EAAc,CAAA;EAAA,OAAAA,GAAA;AAAA,EAAA;AAQtC,MAAMC,4BAA4B,SAIL;EAAA,IAJM;IACjCd,QAAA;IACAe,MAAA;IACAC,MAAS,GAAA;EACX,CAA6B;EACrB,MAAAC,KAAA,GAAQC,SAASH,MAAM,CAAA;EAG3B,sBAAAR,GAAA,CAACE,MAAA,EAAA;IACC,SAAQ,EAAA,kBAAA;IACRG,WAAA,EAAaK,KAAM,CAAAE,KAAA,CAAMC,IAAK,CAAAC,MAAA;IAC9BR,KAAKI,KAAM,CAAAK,KAAA,CAAMN,MAAM,CAAA,CAAEO,QAAQC,IAAK,CAAAC,EAAA;IAErCzB;EAAA,CAAA,CACH;AAEJ,CAAA;AAGa,MAAA0B,gBAAA,GAAmBC,KAAKb,yBAAyB,CAAA;ACtB9D,MAAMc,sBAAsB;EAAA,IA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ACzF;"}
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].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, type NextStudioLoadingProps} from './NextStudioLoading'\n\nexport type {NextStudioLoadingProps}\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?: NextStudioLoadingProps['unstable__noScript']\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,\n scheme,\n ...props\n}: NextStudioProps) => (\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 || <Studio config={config} scheme={scheme} unstable_globalStyles {...props} />}\n </NextStudioLayout>\n </NextStudioClientOnly>\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","_templateObject","_taggedTemplateLiteral","_ref2","$fontFamily","_ref3","$bg","NextStudioLayoutComponent","_ref4","config","scheme","theme","useTheme","fonts","text","family","color","default","base","bg","NextStudioLayout","memo","NextStudioComponent","_ref5","unstable__noScript","props","NextStudioLoading","Studio","unstable_globalStyles","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;ACEA,MAAMQ,SAASC,MAAO,CAAAC,GAAA,CAAAC,eAAA,KAAAA,eAAA,GAAAC,sBAAA,8LACLC,KAAA;EAAA,IAAC;IAACC;EAAiB,CAAA,GAAAD,KAAA;EAAA,OAAAC,WAAA;AAAA,GACdC,KAAA;EAAA,IAAC;IAACC;EAAc,CAAA,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,CAACE,MAAA,EAAA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A;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,EAAA;AAGnB,SAASY,qBAA6CA,CAAA,EAAA;EAC3D,OAAOC,qBAAqBF,KAAM,CAAAT,SAAA,EAAWS,KAAM,CAAAR,WAAA,EAAaQ,MAAMP,iBAAiB,CAAA;AACzF;"}
@@ -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 sanityWebhook from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\n\n// As `@sanity/webhook` isn't shipping ESM, extracting from the default export have the best ecosystem support\nconst {isValidSignature, SIGNATURE_HEADER_NAME} = sanityWebhook\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"],"names":["config","api","bodyParser","runtime","_readBody","readable","chunks","chunk","push","Buffer","from","concat","toString","isValidSignature","SIGNATURE_HEADER_NAME","sanityWebhook","parseBody","req","secret","waitForContentLakeEventualConsistency","signature","headers","Array","isArray","body","readBody","validSignature","trim","Promise","resolve","setTimeout","JSON","parse"],"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;ACJA,MAAM;EAACC,gBAAkB;EAAAC;AAAyB,CAAA,GAAAC,8BAAA;AAiBlD,eAAsBC,SACpB,CAAAC,GAAA,EACAC,MACA,EACoB;EAAA,IADpBC,qCAAA,uEAAiD,IAC7B;EAChB,IAAAC,SAAA,GAAYH,GAAI,CAAAI,OAAA,CAAQP,qBAAqB,CAAA;EAC7C,IAAAQ,KAAA,CAAMC,OAAQ,CAAAH,SAAS,CAAG,EAAA;IAC5BA,SAAA,GAAYA,UAAU,CAAC,CAAA;EACzB;EAEM,MAAAI,IAAA,GAAO,MAAMC,SAAA,CAASR,GAAG,CAAA;EACzB,MAAAS,cAAA,GAAiBR,SAASL,gBAAiB,CAAAW,IAAA,EAAMJ,WAAWF,MAAO,CAAAS,IAAA,EAAM,CAAI,GAAA,IAAA;EAE/E,IAAAD,cAAA,KAAmB,SAASP,qCAAuC,EAAA;IACrE,MAAM,IAAIS,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLL,MAAMA,IAAK,CAAAG,IAAA,EAAU,IAAAI,IAAA,CAAKC,MAAMR,IAAI,CAAA;IACpCX,gBAAkB,EAAAa;EAAA,CACpB;AACF;;"}
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 sanityWebhook from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\n\n// As `@sanity/webhook` isn't shipping ESM, extracting from the default export have the best ecosystem support\nconst {isValidSignature, SIGNATURE_HEADER_NAME} = sanityWebhook\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"],"names":["config","api","bodyParser","runtime","_readBody","readable","chunks","chunk","push","Buffer","from","concat","toString","isValidSignature","SIGNATURE_HEADER_NAME","sanityWebhook","parseBody","req","secret","waitForContentLakeEventualConsistency","arguments","length","undefined","signature","headers","Array","isArray","body","readBody","validSignature","trim","Promise","resolve","setTimeout","JSON","parse"],"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;ACJA,MAAM;EAACC,gBAAkB;EAAAC;AAAyB,CAAA,GAAAC,8BAAA;AAiBlD,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,CAAQV,qBAAqB,CAAA;EAC7C,IAAAW,KAAA,CAAMC,OAAQ,CAAAH,SAAS,CAAG,EAAA;IAC5BA,SAAA,GAAYA,UAAU,CAAC,CAAA;EACzB;EAEM,MAAAI,IAAA,GAAO,MAAMC,SAAA,CAASX,GAAG,CAAA;EACzB,MAAAY,cAAA,GAAiBX,SAASL,gBAAiB,CAAAc,IAAA,EAAMJ,WAAWL,MAAO,CAAAY,IAAA,EAAM,CAAI,GAAA,IAAA;EAE/E,IAAAD,cAAA,KAAmB,SAASV,qCAAuC,EAAA;IACrE,MAAM,IAAIY,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLL,MAAMA,IAAK,CAAAG,IAAA,EAAU,IAAAI,IAAA,CAAKC,MAAMR,IAAI,CAAA;IACpCd,gBAAkB,EAAAgB;EAAA,CACpB;AACF;;"}
@@ -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 sanityWebhook from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\n\n// As `@sanity/webhook` isn't shipping ESM, extracting from the default export have the best ecosystem support\nconst {isValidSignature, SIGNATURE_HEADER_NAME} = sanityWebhook\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"],"names":["config","api","bodyParser","runtime","_readBody","readable","chunks","chunk","push","Buffer","from","concat","toString","isValidSignature","SIGNATURE_HEADER_NAME","sanityWebhook","parseBody","req","secret","waitForContentLakeEventualConsistency","signature","headers","Array","isArray","body","readBody","validSignature","trim","Promise","resolve","setTimeout","JSON","parse"],"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;ACJA,MAAM;EAACC,gBAAkB;EAAAC;AAAyB,CAAA,GAAAC,aAAA;AAiBlD,eAAsBC,SACpB,CAAAC,GAAA,EACAC,MACA,EACoB;EAAA,IADpBC,qCAAA,uEAAiD,IAC7B;EAChB,IAAAC,SAAA,GAAYH,GAAI,CAAAI,OAAA,CAAQP,qBAAqB,CAAA;EAC7C,IAAAQ,KAAA,CAAMC,OAAQ,CAAAH,SAAS,CAAG,EAAA;IAC5BA,SAAA,GAAYA,UAAU,CAAC,CAAA;EACzB;EAEM,MAAAI,IAAA,GAAO,MAAMC,SAAA,CAASR,GAAG,CAAA;EACzB,MAAAS,cAAA,GAAiBR,SAASL,gBAAiB,CAAAW,IAAA,EAAMJ,WAAWF,MAAO,CAAAS,IAAA,EAAM,CAAI,GAAA,IAAA;EAE/E,IAAAD,cAAA,KAAmB,SAASP,qCAAuC,EAAA;IACrE,MAAM,IAAIS,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLL,MAAMA,IAAK,CAAAG,IAAA,EAAU,IAAAI,IAAA,CAAKC,MAAMR,IAAI,CAAA;IACpCX,gBAAkB,EAAAa;EAAA,CACpB;AACF;"}
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 sanityWebhook from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\n\n// As `@sanity/webhook` isn't shipping ESM, extracting from the default export have the best ecosystem support\nconst {isValidSignature, SIGNATURE_HEADER_NAME} = sanityWebhook\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"],"names":["config","api","bodyParser","runtime","_readBody","readable","chunks","chunk","push","Buffer","from","concat","toString","isValidSignature","SIGNATURE_HEADER_NAME","sanityWebhook","parseBody","req","secret","waitForContentLakeEventualConsistency","arguments","length","undefined","signature","headers","Array","isArray","body","readBody","validSignature","trim","Promise","resolve","setTimeout","JSON","parse"],"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;ACJA,MAAM;EAACC,gBAAkB;EAAAC;AAAyB,CAAA,GAAAC,aAAA;AAiBlD,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,CAAQV,qBAAqB,CAAA;EAC7C,IAAAW,KAAA,CAAMC,OAAQ,CAAAH,SAAS,CAAG,EAAA;IAC5BA,SAAA,GAAYA,UAAU,CAAC,CAAA;EACzB;EAEM,MAAAI,IAAA,GAAO,MAAMC,SAAA,CAASX,GAAG,CAAA;EACzB,MAAAY,cAAA,GAAiBX,SAASL,gBAAiB,CAAAc,IAAA,EAAMJ,WAAWL,MAAO,CAAAY,IAAA,EAAM,CAAI,GAAA,IAAA;EAE/E,IAAAD,cAAA,KAAmB,SAASV,qCAAuC,EAAA;IACrE,MAAM,IAAIY,OAAQ,CAACC,WAAYC,UAAW,CAAAD,OAAA,EAAS,GAAI,CAAC,CAAA;EAC1D;EAEO,OAAA;IACLL,MAAMA,IAAK,CAAAG,IAAA,EAAU,IAAAI,IAAA,CAAKC,MAAMR,IAAI,CAAA;IACpCd,gBAAkB,EAAAgB;EAAA,CACpB;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "0.0.0-dev.2",
3
+ "version": "0.0.0-dev.20",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "sanity",
@@ -146,59 +146,59 @@
146
146
  "singleQuote": true
147
147
  },
148
148
  "dependencies": {
149
- "@sanity/client": "0.0.0-dev.3",
150
- "@sanity/preview-kit": "0.0.0-dev.2",
151
- "@sanity/webhook": "^2",
152
- "groq": "^3"
149
+ "@sanity/client": "0.0.0-dev.7",
150
+ "@sanity/preview-kit": "0.0.0-dev.21",
151
+ "@sanity/webhook": "2",
152
+ "groq": "3"
153
153
  },
154
154
  "devDependencies": {
155
155
  "@rollup/plugin-url": "^8.0.1",
156
156
  "@sanity/eslint-config-studio": "^2.0.1",
157
157
  "@sanity/image-url": "^1.0.2",
158
- "@sanity/pkg-utils": "^2.2.5",
159
- "@sanity/semantic-release-preset": "^4.0.0",
160
- "@sanity/ui": "^1.2.4",
161
- "@sanity/vision": "^3.4.0",
158
+ "@sanity/pkg-utils": "^2.2.13",
159
+ "@sanity/semantic-release-preset": "^4.0.1",
160
+ "@sanity/ui": "^1.3.0",
161
+ "@sanity/vision": "^3.6.0",
162
162
  "@types/eventsource": "^1.1.11",
163
- "@types/jest": "^29.4.0",
163
+ "@types/jest": "^29.5.0",
164
164
  "@types/react": "^18.0.28",
165
165
  "@types/react-dom": "^18.0.11",
166
166
  "@types/styled-components": "^5.1.26",
167
- "@typescript-eslint/eslint-plugin": "^5.52.0",
168
- "autoprefixer": "^10.4.13",
169
- "eslint": "^8.34.0",
170
- "eslint-config-next": "13.1.6",
171
- "eslint-config-prettier": "^8.6.0",
167
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
168
+ "autoprefixer": "^10.4.14",
169
+ "eslint": "^8.36.0",
170
+ "eslint-config-next": "13.2.4",
171
+ "eslint-config-prettier": "^8.7.0",
172
172
  "eslint-config-sanity": "^6.0.0",
173
173
  "eslint-gitignore": "^0.1.0",
174
174
  "eslint-plugin-prettier": "^4.2.1",
175
175
  "eslint-plugin-simple-import-sort": "^10.0.0",
176
- "groqd": "^0.7.0",
177
- "jest": "^29.4.3",
178
- "jest-environment-jsdom": "^29.4.3",
176
+ "groqd": "^0.12.0",
177
+ "jest": "^29.5.0",
178
+ "jest-environment-jsdom": "^29.5.0",
179
179
  "ls-engines": "^0.9.0",
180
- "next": "13.1.6",
180
+ "next": "13.2.4",
181
181
  "postcss": "^8.4.21",
182
182
  "prettier": "^2.8.4",
183
183
  "prettier-plugin-packagejson": "^2.4.3",
184
- "prettier-plugin-tailwindcss": "^0.2.3",
184
+ "prettier-plugin-tailwindcss": "^0.2.5",
185
185
  "react": "^18.2.0",
186
186
  "react-dom": "^18.2.0",
187
187
  "react-is": "^18.2.0",
188
- "rollup": "^3.16.0",
189
- "sanity": "^3.4.0",
190
- "styled-components": "^5.3.6",
188
+ "rollup": "^3.19.1",
189
+ "sanity": "^3.6.0",
190
+ "styled-components": "^5.3.9",
191
191
  "tailwindcss": "^3.2.7",
192
- "typescript": "^4.9.5",
192
+ "typescript": "^5.0.0",
193
193
  "url-loader": "^4.1.1"
194
194
  },
195
195
  "peerDependencies": {
196
- "@sanity/icons": "^2",
197
- "@sanity/types": "^3",
198
- "@sanity/ui": "^1",
199
- "next": "^13",
200
- "react": "^18",
201
- "sanity": "^3",
196
+ "@sanity/icons": "2",
197
+ "@sanity/types": "3",
198
+ "@sanity/ui": "1",
199
+ "next": "13",
200
+ "react": "18",
201
+ "sanity": "3",
202
202
  "styled-components": "^5.2"
203
203
  },
204
204
  "engines": {
package/src/client.ts CHANGED
@@ -1,2 +1,37 @@
1
+ import {
2
+ type ClientConfig as _ClientConfig,
3
+ createClient as _createClient,
4
+ } from '@sanity/preview-kit/client'
5
+
1
6
  /** @public */
2
- export {type ClientConfig, createClient} from '@sanity/client'
7
+ export interface ClientConfig extends Omit<_ClientConfig, 'studioUrl' | 'encodeSourceMap'> {
8
+ /**
9
+ * Where the Studio is hosted.
10
+ * If it's embedded in the app, use the base path for example `/studio`.
11
+ * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
12
+ * @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL
13
+ * @alpha
14
+ */
15
+ studioUrl?: _ClientConfig['studioUrl']
16
+ /**
17
+ * If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.
18
+ * @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'
19
+ * @alpha
20
+ */
21
+ encodeSourceMap?: _ClientConfig['encodeSourceMap']
22
+ }
23
+
24
+ /**
25
+ * @public
26
+ */
27
+ export function createClient(config: ClientConfig): ReturnType<typeof _createClient> {
28
+ let {
29
+ // eslint-disable-next-line prefer-const
30
+ studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL! as _ClientConfig['studioUrl'],
31
+ encodeSourceMap = studioUrl ? 'auto' : 'none',
32
+ } = config
33
+ if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
34
+ encodeSourceMap = 'stega'
35
+ }
36
+ return _createClient({...config, studioUrl, encodeSourceMap})
37
+ }
@@ -33,5 +33,5 @@ export const definePreview = (config: PreviewConfig): UsePreview =>
33
33
  })
34
34
  // */
35
35
 
36
- export type {Params, PreviewConfig, unstable_PreviewConfig, UsePreview} from '@sanity/preview-kit'
37
- export {definePreview, unstable_usePreview} from '@sanity/preview-kit'
36
+ export type {Params, PreviewConfig, UsePreview} from '@sanity/preview-kit'
37
+ export {definePreview} from '@sanity/preview-kit'