next-sanity 4.2.1-dev.0 → 4.2.1
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 +31 -41
- package/dist/_chunks/{NextStudioLoading-8cf56cdf.js → NextStudioLoading-2003f32a.js} +4 -4
- package/dist/_chunks/NextStudioLoading-2003f32a.js.map +1 -0
- package/dist/_chunks/{NextStudioLoading-bf57e61a.cjs → NextStudioLoading-225bb240.cjs} +4 -4
- package/dist/_chunks/NextStudioLoading-225bb240.cjs.map +1 -0
- package/dist/index.cjs +6 -16
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -24
- package/dist/index.js +1 -17
- package/dist/index.js.map +1 -1
- package/dist/studio/head.cjs.map +1 -1
- package/dist/studio/head.d.ts +1 -2
- package/dist/studio/head.js.map +1 -1
- package/dist/studio/index.cjs +33 -16
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/index.d.ts +19 -3
- package/dist/studio/index.js +35 -19
- package/dist/studio/index.js.map +1 -1
- package/dist/studio/loading.cjs +1 -1
- package/dist/studio/loading.d.ts +4 -3
- package/dist/studio/loading.js +1 -1
- package/dist/studio/metadata.cjs +13 -0
- package/dist/studio/metadata.cjs.js +5 -0
- package/dist/studio/metadata.cjs.map +1 -0
- package/dist/studio/metadata.d.ts +43 -0
- package/dist/studio/metadata.js +8 -0
- package/dist/studio/metadata.js.map +1 -0
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +29 -14
- package/src/client.ts +1 -36
- package/src/studio/NextStudio.tsx +47 -19
- package/src/studio/NextStudioLayout.tsx +1 -1
- package/src/studio/NextStudioLoading.tsx +11 -4
- package/src/studio/head/NextStudioHead.tsx +1 -0
- package/src/studio/metadata.ts +44 -0
- package/dist/_chunks/NextStudioLoading-8cf56cdf.js.map +0 -1
- package/dist/_chunks/NextStudioLoading-bf57e61a.cjs.map +0 -1
package/dist/studio/index.cjs
CHANGED
|
@@ -9,7 +9,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var sanity = require('sanity');
|
|
11
11
|
var styled = require('styled-components');
|
|
12
|
-
var NextStudioLoading = require('../_chunks/NextStudioLoading-
|
|
12
|
+
var NextStudioLoading = require('../_chunks/NextStudioLoading-225bb240.cjs');
|
|
13
13
|
function _interopDefaultCompat(e) {
|
|
14
14
|
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
15
15
|
default: e
|
|
@@ -48,7 +48,7 @@ const NextStudioLayoutComponent = _ref4 => {
|
|
|
48
48
|
return /* @__PURE__ */jsxRuntime.jsx(Layout, {
|
|
49
49
|
"data-ui": "NextStudioLayout",
|
|
50
50
|
$fontFamily: theme.fonts.text.family,
|
|
51
|
-
$bg: theme.color[scheme].default.base.bg,
|
|
51
|
+
$bg: theme.color[scheme === "dark" ? "dark" : "light"].default.base.bg,
|
|
52
52
|
children
|
|
53
53
|
});
|
|
54
54
|
};
|
|
@@ -57,26 +57,43 @@ const NextStudioComponent = _ref5 => {
|
|
|
57
57
|
let {
|
|
58
58
|
children,
|
|
59
59
|
config,
|
|
60
|
-
unstable__noScript,
|
|
60
|
+
unstable__noScript = true,
|
|
61
|
+
unstable__fastRender,
|
|
61
62
|
scheme,
|
|
62
63
|
...props
|
|
63
64
|
} = _ref5;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
unstable__noScript,
|
|
67
|
-
config,
|
|
68
|
-
scheme
|
|
69
|
-
}),
|
|
70
|
-
children: /* @__PURE__ */jsxRuntime.jsx(NextStudioLayout, {
|
|
71
|
-
config,
|
|
72
|
-
scheme,
|
|
73
|
-
children: children || /* @__PURE__ */jsxRuntime.jsx(sanity.Studio, {
|
|
65
|
+
if (unstable__fastRender) {
|
|
66
|
+
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
67
|
+
children: [unstable__noScript && /* @__PURE__ */jsxRuntime.jsx(NextStudioLoading.NextStudioNoScript, {}), /* @__PURE__ */jsxRuntime.jsx(NextStudioLayout, {
|
|
74
68
|
config,
|
|
75
69
|
scheme,
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
children: children || /* @__PURE__ */jsxRuntime.jsx(sanity.Studio, {
|
|
71
|
+
config,
|
|
72
|
+
scheme,
|
|
73
|
+
unstable_globalStyles: true,
|
|
74
|
+
...props
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
80
|
+
children: [unstable__noScript && /* @__PURE__ */jsxRuntime.jsx(NextStudioLoading.NextStudioNoScript, {}), /* @__PURE__ */jsxRuntime.jsx(NextStudioClientOnly, {
|
|
81
|
+
fallback: /* @__PURE__ */jsxRuntime.jsx(NextStudioLoading.NextStudioLoading, {
|
|
82
|
+
unstable__noScript,
|
|
83
|
+
config,
|
|
84
|
+
scheme
|
|
85
|
+
}),
|
|
86
|
+
children: /* @__PURE__ */jsxRuntime.jsx(NextStudioLayout, {
|
|
87
|
+
config,
|
|
88
|
+
scheme,
|
|
89
|
+
children: children || /* @__PURE__ */jsxRuntime.jsx(sanity.Studio, {
|
|
90
|
+
config,
|
|
91
|
+
scheme,
|
|
92
|
+
unstable_globalStyles: true,
|
|
93
|
+
...props
|
|
94
|
+
})
|
|
78
95
|
})
|
|
79
|
-
})
|
|
96
|
+
})]
|
|
80
97
|
});
|
|
81
98
|
};
|
|
82
99
|
const NextStudio = react.memo(NextStudioComponent);
|
|
@@ -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
|
|
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","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","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;ACEA,MAAMQ,SAASC,eAAO,CAAAC,OAAA,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;IACjCpB,QAAA;IACAqB,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AA,CAAAA,qBAAqBF,KAAM,CAAAT,SAAA,EAAWS,KAAM,CAAAR,WAAA,EAAaQ,MAAMP,iBAAiB,CAAA;AACzF;;;;;;"}
|
package/dist/studio/index.d.ts
CHANGED
|
@@ -24,7 +24,14 @@ import type {ThemeColorSchemeKey} from '@sanity/ui'
|
|
|
24
24
|
* @beta
|
|
25
25
|
*/
|
|
26
26
|
export declare const NextStudio: MemoExoticComponent<
|
|
27
|
-
({
|
|
27
|
+
({
|
|
28
|
+
children,
|
|
29
|
+
config,
|
|
30
|
+
unstable__noScript,
|
|
31
|
+
unstable__fastRender,
|
|
32
|
+
scheme,
|
|
33
|
+
...props
|
|
34
|
+
}: NextStudioProps) => JSX.Element
|
|
28
35
|
>
|
|
29
36
|
|
|
30
37
|
/** @alpha */
|
|
@@ -49,7 +56,10 @@ export declare interface NextStudioLayoutProps extends Pick<StudioProps, 'config
|
|
|
49
56
|
children: React.ReactNode
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* @alpha
|
|
61
|
+
* @deprecated Will be removed in the next major release
|
|
62
|
+
*/
|
|
53
63
|
export declare interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {
|
|
54
64
|
/**
|
|
55
65
|
* If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.
|
|
@@ -74,7 +84,13 @@ export declare interface NextStudioProps extends StudioProps {
|
|
|
74
84
|
* @defaultValue true
|
|
75
85
|
* @alpha
|
|
76
86
|
*/
|
|
77
|
-
unstable__noScript?:
|
|
87
|
+
unstable__noScript?: boolean
|
|
88
|
+
/**
|
|
89
|
+
* Render in a faster mode that requires `styled-components` SSR to be setup.
|
|
90
|
+
* @defaultValue false
|
|
91
|
+
* @alpha
|
|
92
|
+
*/
|
|
93
|
+
unstable__fastRender?: boolean
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
/** @alpha */
|
package/dist/studio/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { useState, useEffect, startTransition, memo, useSyncExternalStore } from 'react';
|
|
5
5
|
import { Studio } from 'sanity';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { useTheme, NextStudioLoading } from '../_chunks/NextStudioLoading-
|
|
8
|
-
export { NextStudioNoScript } from '../_chunks/NextStudioLoading-8cf56cdf.js';
|
|
7
|
+
import { useTheme, NextStudioNoScript, NextStudioLoading } from '../_chunks/NextStudioLoading-2003f32a.js';
|
|
9
8
|
function NextStudioClientOnly(_ref) {
|
|
10
9
|
let {
|
|
11
10
|
children,
|
|
@@ -38,7 +37,7 @@ const NextStudioLayoutComponent = _ref4 => {
|
|
|
38
37
|
return /* @__PURE__ */jsx(Layout, {
|
|
39
38
|
"data-ui": "NextStudioLayout",
|
|
40
39
|
$fontFamily: theme.fonts.text.family,
|
|
41
|
-
$bg: theme.color[scheme].default.base.bg,
|
|
40
|
+
$bg: theme.color[scheme === "dark" ? "dark" : "light"].default.base.bg,
|
|
42
41
|
children
|
|
43
42
|
});
|
|
44
43
|
};
|
|
@@ -47,26 +46,43 @@ const NextStudioComponent = _ref5 => {
|
|
|
47
46
|
let {
|
|
48
47
|
children,
|
|
49
48
|
config,
|
|
50
|
-
unstable__noScript,
|
|
49
|
+
unstable__noScript = true,
|
|
50
|
+
unstable__fastRender,
|
|
51
51
|
scheme,
|
|
52
52
|
...props
|
|
53
53
|
} = _ref5;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
unstable__noScript,
|
|
57
|
-
config,
|
|
58
|
-
scheme
|
|
59
|
-
}),
|
|
60
|
-
children: /* @__PURE__ */jsx(NextStudioLayout, {
|
|
61
|
-
config,
|
|
62
|
-
scheme,
|
|
63
|
-
children: children || /* @__PURE__ */jsx(Studio, {
|
|
54
|
+
if (unstable__fastRender) {
|
|
55
|
+
return /* @__PURE__ */jsxs(Fragment, {
|
|
56
|
+
children: [unstable__noScript && /* @__PURE__ */jsx(NextStudioNoScript, {}), /* @__PURE__ */jsx(NextStudioLayout, {
|
|
64
57
|
config,
|
|
65
58
|
scheme,
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
children: children || /* @__PURE__ */jsx(Studio, {
|
|
60
|
+
config,
|
|
61
|
+
scheme,
|
|
62
|
+
unstable_globalStyles: true,
|
|
63
|
+
...props
|
|
64
|
+
})
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */jsxs(Fragment, {
|
|
69
|
+
children: [unstable__noScript && /* @__PURE__ */jsx(NextStudioNoScript, {}), /* @__PURE__ */jsx(NextStudioClientOnly, {
|
|
70
|
+
fallback: /* @__PURE__ */jsx(NextStudioLoading, {
|
|
71
|
+
unstable__noScript,
|
|
72
|
+
config,
|
|
73
|
+
scheme
|
|
74
|
+
}),
|
|
75
|
+
children: /* @__PURE__ */jsx(NextStudioLayout, {
|
|
76
|
+
config,
|
|
77
|
+
scheme,
|
|
78
|
+
children: children || /* @__PURE__ */jsx(Studio, {
|
|
79
|
+
config,
|
|
80
|
+
scheme,
|
|
81
|
+
unstable_globalStyles: true,
|
|
82
|
+
...props
|
|
83
|
+
})
|
|
68
84
|
})
|
|
69
|
-
})
|
|
85
|
+
})]
|
|
70
86
|
});
|
|
71
87
|
};
|
|
72
88
|
const NextStudio = memo(NextStudioComponent);
|
|
@@ -92,5 +108,5 @@ const store = createStore();
|
|
|
92
108
|
function usePrefersColorScheme() {
|
|
93
109
|
return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
94
110
|
}
|
|
95
|
-
export { NextStudio, NextStudioClientOnly, NextStudioLayout, usePrefersColorScheme, useTheme };
|
|
111
|
+
export { NextStudio, NextStudioClientOnly, NextStudioLayout, NextStudioNoScript, usePrefersColorScheme, useTheme };
|
|
96
112
|
//# sourceMappingURL=index.js.map
|
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].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
|
|
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","_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","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;ACEA,MAA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AM;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/studio/loading.cjs
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var NextStudioLoading = require('../_chunks/NextStudioLoading-
|
|
6
|
+
var NextStudioLoading = require('../_chunks/NextStudioLoading-225bb240.cjs');
|
|
7
7
|
exports.NextStudioLoading = NextStudioLoading.NextStudioLoading;
|
|
8
8
|
//# sourceMappingURL=loading.cjs.map
|
package/dist/studio/loading.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
1
|
import type {Config} from 'sanity'
|
|
4
2
|
import type {SingleWorkspace} from 'sanity'
|
|
5
3
|
import type {StudioProps} from 'sanity'
|
|
6
4
|
|
|
7
5
|
export declare function NextStudioLoading(props: NextStudioLoadingProps): JSX.Element
|
|
8
6
|
|
|
9
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* @alpha
|
|
9
|
+
* @deprecated Will be removed in the next major release
|
|
10
|
+
*/
|
|
10
11
|
export declare interface NextStudioLoadingProps extends Pick<StudioProps, 'scheme'> {
|
|
11
12
|
/**
|
|
12
13
|
* If your Studio Config has a custom theme you can pass it here to ensure the loading screen matches your theme.
|
package/dist/studio/loading.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { NextStudioLoading } from '../_chunks/NextStudioLoading-
|
|
1
|
+
export { NextStudioLoading } from '../_chunks/NextStudioLoading-2003f32a.js';
|
|
2
2
|
//# sourceMappingURL=loading.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const metadata = {
|
|
7
|
+
// Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly
|
|
8
|
+
viewport: "width=device-width,initial-scale=1,viewport-fit=cover",
|
|
9
|
+
referrer: "same-origin",
|
|
10
|
+
robots: "noindex"
|
|
11
|
+
};
|
|
12
|
+
exports.metadata = metadata;
|
|
13
|
+
//# sourceMappingURL=metadata.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.cjs","sources":["../../src/studio/metadata.ts"],"sourcesContent":["import type {Metadata} from 'next'\n\n/**\n * In Next 13 appDir mode (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the metadata directly:\n * export {metadata} from 'next-sanity/studio'\n *\n * // To customize the metadata, spread it on the export:\n * import {metadata as studioMetadata} from 'next-sanity/studio'\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * ...studioMetadata,\n * // Overrides the viewport to resize behavior\n * viewport: `${studioMetadata.viewport}, interactive-widget=resizes-content`,\n * })\n * ```\n * If you're using Next 12 or the `pages` folder (`/pages/studio/[[...index]].tsx`):\n * ```tsx\n * import Head from 'next/head'\n * import {NextStudio, metadata} from 'next-sanity/studio'\n *\n * export default function StudioPage() {\n * return (\n * <>\n * <Head>\n * {Object.entries(metadata).map(([key, value]) => (\n * <meta key={key} name={key} content={value} />\n * ))}\n * </Head>\n * <NextStudio config={config} />\n * </>\n * )\n * }\n * ```\n * @public\n */\nexport const metadata = {\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewport: 'width=device-width,initial-scale=1,viewport-fit=cover' as const,\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n"],"names":["metadata","viewport","referrer","robots"],"mappings":";;;;;AAsCO,MAAMA,QAAW,GAAA;EAAA;EAEtBC,QAAU,EAAA,uDAAA;EACVC,QAAU,EAAA,aAAA;EACVC,MAAQ,EAAA;AACV,CAAA;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In Next 13 appDir mode (`/app/studio/[[...index]]/page.tsx`):
|
|
3
|
+
* ```tsx
|
|
4
|
+
* // If you don't want to change any defaults you can just re-export the metadata directly:
|
|
5
|
+
* export {metadata} from 'next-sanity/studio'
|
|
6
|
+
*
|
|
7
|
+
* // To customize the metadata, spread it on the export:
|
|
8
|
+
* import {metadata as studioMetadata} from 'next-sanity/studio'
|
|
9
|
+
* import type { Metadata } from 'next'
|
|
10
|
+
*
|
|
11
|
+
* export const metadata: Metadata = {
|
|
12
|
+
* ...studioMetadata,
|
|
13
|
+
* // Overrides the viewport to resize behavior
|
|
14
|
+
* viewport: `${studioMetadata.viewport}, interactive-widget=resizes-content`,
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
* If you're using Next 12 or the `pages` folder (`/pages/studio/[[...index]].tsx`):
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import Head from 'next/head'
|
|
20
|
+
* import {NextStudio, metadata} from 'next-sanity/studio'
|
|
21
|
+
*
|
|
22
|
+
* export default function StudioPage() {
|
|
23
|
+
* return (
|
|
24
|
+
* <>
|
|
25
|
+
* <Head>
|
|
26
|
+
* {Object.entries(metadata).map(([key, value]) => (
|
|
27
|
+
* <meta key={key} name={key} content={value} />
|
|
28
|
+
* ))}
|
|
29
|
+
* </Head>
|
|
30
|
+
* <NextStudio config={config} />
|
|
31
|
+
* </>
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare const metadata: {
|
|
38
|
+
viewport: 'width=device-width,initial-scale=1,viewport-fit=cover'
|
|
39
|
+
referrer: 'same-origin'
|
|
40
|
+
robots: 'noindex'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const metadata = {
|
|
2
|
+
// Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly
|
|
3
|
+
viewport: "width=device-width,initial-scale=1,viewport-fit=cover",
|
|
4
|
+
referrer: "same-origin",
|
|
5
|
+
robots: "noindex"
|
|
6
|
+
};
|
|
7
|
+
export { metadata };
|
|
8
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sources":["../../src/studio/metadata.ts"],"sourcesContent":["import type {Metadata} from 'next'\n\n/**\n * In Next 13 appDir mode (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the metadata directly:\n * export {metadata} from 'next-sanity/studio'\n *\n * // To customize the metadata, spread it on the export:\n * import {metadata as studioMetadata} from 'next-sanity/studio'\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * ...studioMetadata,\n * // Overrides the viewport to resize behavior\n * viewport: `${studioMetadata.viewport}, interactive-widget=resizes-content`,\n * })\n * ```\n * If you're using Next 12 or the `pages` folder (`/pages/studio/[[...index]].tsx`):\n * ```tsx\n * import Head from 'next/head'\n * import {NextStudio, metadata} from 'next-sanity/studio'\n *\n * export default function StudioPage() {\n * return (\n * <>\n * <Head>\n * {Object.entries(metadata).map(([key, value]) => (\n * <meta key={key} name={key} content={value} />\n * ))}\n * </Head>\n * <NextStudio config={config} />\n * </>\n * )\n * }\n * ```\n * @public\n */\nexport const metadata = {\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewport: 'width=device-width,initial-scale=1,viewport-fit=cover' as const,\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n"],"names":["metadata","viewport","referrer","robots"],"mappings":"AAsCO,MAAMA,QAAW,GAAA;EAAA;EAEtBC,QAAU,EAAA,uDAAA;EACVC,QAAU,EAAA,aAAA;EACVC,MAAQ,EAAA;AACV,CAAA;"}
|
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 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,
|
|
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,CAAA,CAAU,IAAAI,IAAA,CAAKC,MAAMR,IAAI,CAAA;IACpCd,gBAAkB,EAAAgB;EAAA,CACpB;AACF;;"}
|
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 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,
|
|
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;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": "4.2.1
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -79,6 +79,17 @@
|
|
|
79
79
|
"import": "./dist/studio/loading.js",
|
|
80
80
|
"default": "./dist/studio/loading.js"
|
|
81
81
|
},
|
|
82
|
+
"./studio/metadata": {
|
|
83
|
+
"types": "./dist/studio/metadata.d.ts",
|
|
84
|
+
"source": "./src/studio/metadata.ts",
|
|
85
|
+
"require": "./dist/studio/metadata.cjs",
|
|
86
|
+
"node": {
|
|
87
|
+
"import": "./dist/studio/metadata.cjs.js",
|
|
88
|
+
"require": "./dist/studio/metadata.cjs"
|
|
89
|
+
},
|
|
90
|
+
"import": "./dist/studio/metadata.js",
|
|
91
|
+
"default": "./dist/studio/metadata.js"
|
|
92
|
+
},
|
|
82
93
|
"./webhook": {
|
|
83
94
|
"types": "./dist/webhook.d.ts",
|
|
84
95
|
"source": "./src/webhook/index.ts",
|
|
@@ -110,6 +121,9 @@
|
|
|
110
121
|
"studio/loading": [
|
|
111
122
|
"./dist/studio/loading.d.ts"
|
|
112
123
|
],
|
|
124
|
+
"studio/metadata": [
|
|
125
|
+
"./dist/studio/metadata.d.ts"
|
|
126
|
+
],
|
|
113
127
|
"webhook": [
|
|
114
128
|
"./dist/webhook.d.ts"
|
|
115
129
|
]
|
|
@@ -146,10 +160,10 @@
|
|
|
146
160
|
"singleQuote": true
|
|
147
161
|
},
|
|
148
162
|
"dependencies": {
|
|
149
|
-
"@sanity/client": "5
|
|
150
|
-
"@sanity/preview-kit": "1.4.
|
|
151
|
-
"@sanity/webhook": "
|
|
152
|
-
"groq": "
|
|
163
|
+
"@sanity/client": "5",
|
|
164
|
+
"@sanity/preview-kit": "1.4.0",
|
|
165
|
+
"@sanity/webhook": "2",
|
|
166
|
+
"groq": "3"
|
|
153
167
|
},
|
|
154
168
|
"devDependencies": {
|
|
155
169
|
"@rollup/plugin-url": "^8.0.1",
|
|
@@ -167,17 +181,17 @@
|
|
|
167
181
|
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
168
182
|
"autoprefixer": "^10.4.14",
|
|
169
183
|
"eslint": "^8.36.0",
|
|
170
|
-
"eslint-config-next": "13.
|
|
184
|
+
"eslint-config-next": "13.3.5-canary.5",
|
|
171
185
|
"eslint-config-prettier": "^8.7.0",
|
|
172
186
|
"eslint-config-sanity": "^6.0.0",
|
|
173
187
|
"eslint-gitignore": "^0.1.0",
|
|
174
188
|
"eslint-plugin-prettier": "^4.2.1",
|
|
175
189
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
176
|
-
"groqd": "^0.
|
|
190
|
+
"groqd": "^0.15.0",
|
|
177
191
|
"jest": "^29.5.0",
|
|
178
192
|
"jest-environment-jsdom": "^29.5.0",
|
|
179
193
|
"ls-engines": "^0.9.0",
|
|
180
|
-
"next": "13.
|
|
194
|
+
"next": "13.3.5-canary.5",
|
|
181
195
|
"postcss": "^8.4.21",
|
|
182
196
|
"prettier": "^2.8.4",
|
|
183
197
|
"prettier-plugin-packagejson": "^2.4.3",
|
|
@@ -193,12 +207,13 @@
|
|
|
193
207
|
"url-loader": "^4.1.1"
|
|
194
208
|
},
|
|
195
209
|
"peerDependencies": {
|
|
196
|
-
"@sanity/icons": "
|
|
197
|
-
"@sanity/types": "
|
|
198
|
-
"@sanity/ui": "
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"
|
|
210
|
+
"@sanity/icons": "2",
|
|
211
|
+
"@sanity/types": "3",
|
|
212
|
+
"@sanity/ui": "1",
|
|
213
|
+
"@types/styled-components": "^5.1",
|
|
214
|
+
"next": "13",
|
|
215
|
+
"react": "18",
|
|
216
|
+
"sanity": "3",
|
|
202
217
|
"styled-components": "^5.2"
|
|
203
218
|
},
|
|
204
219
|
"engines": {
|
package/src/client.ts
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ClientConfig as _ClientConfig,
|
|
3
|
-
createClient as _createClient,
|
|
4
|
-
} from '@sanity/preview-kit/client'
|
|
5
|
-
|
|
6
1
|
/** @public */
|
|
7
|
-
export
|
|
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' : false) satisfies _ClientConfig['encodeSourceMap'],
|
|
32
|
-
} = config
|
|
33
|
-
if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
|
|
34
|
-
encodeSourceMap = true
|
|
35
|
-
}
|
|
36
|
-
return _createClient({...config, studioUrl, encodeSourceMap})
|
|
37
|
-
}
|
|
2
|
+
export {type ClientConfig, createClient} from '@sanity/client'
|