next-sanity 13.1.1 → 13.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VisualEditing.js +3 -1
- package/dist/VisualEditing.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/draft-mode/index.d.ts +25 -25
- package/dist/draft-mode/index.d.ts.map +1 -1
- package/dist/draft-mode/index.js.map +1 -1
- package/dist/image/index.d.ts +10 -10
- package/dist/image/index.d.ts.map +1 -1
- package/dist/isCorsOriginError.d.ts.map +1 -1
- package/dist/live/cache-life.d.ts +17 -20
- package/dist/live/cache-life.d.ts.map +1 -1
- package/dist/live/cache-life.js.map +1 -1
- package/dist/live/client-components/index.d.ts +2 -2
- package/dist/live/client-components/index.d.ts.map +1 -1
- package/dist/live/conditions/default/index.d.ts +286 -286
- package/dist/live/conditions/default/index.d.ts.map +1 -1
- package/dist/live/conditions/next-js/index.d.ts +228 -228
- package/dist/live/conditions/next-js/index.d.ts.map +1 -1
- package/dist/live/conditions/react-server/index.d.ts +228 -228
- package/dist/live/conditions/react-server/index.d.ts.map +1 -1
- package/dist/live/server-actions/index.d.ts +2 -2
- package/dist/live/server-actions/index.d.ts.map +1 -1
- package/dist/parseTags.d.ts +80 -82
- package/dist/parseTags.d.ts.map +1 -1
- package/dist/studio/client-component/index.d.ts +9 -9
- package/dist/studio/client-component/index.d.ts.map +1 -1
- package/dist/studio/index.d.ts +36 -38
- package/dist/studio/index.d.ts.map +1 -1
- package/dist/studio/index.js.map +1 -1
- package/dist/types.d.ts +189 -189
- package/dist/types.d.ts.map +1 -1
- package/dist/visual-editing/client-component/index.d.ts +16 -16
- package/dist/visual-editing/client-component/index.d.ts.map +1 -1
- package/dist/visual-editing/index.d.ts +2 -2
- package/dist/visual-editing/index.d.ts.map +1 -1
- package/dist/visual-editing/server-actions/index.d.ts +2 -2
- package/dist/visual-editing/server-actions/index.d.ts.map +1 -1
- package/dist/webhook/index.d.ts +6 -6
- package/dist/webhook/index.d.ts.map +1 -1
- package/package.json +22 -22
package/dist/VisualEditing.js
CHANGED
|
@@ -87,7 +87,7 @@ function removeTrailingSlash(route) {
|
|
|
87
87
|
return route.replace(/\/$/, "") || "/";
|
|
88
88
|
}
|
|
89
89
|
function VisualEditing(props) {
|
|
90
|
-
const { basePath = "", plugins, components, refresh, trailingSlash = false, zIndex, onPerspectiveChange } = props;
|
|
90
|
+
const { basePath = "", plugins, components, refresh, trailingSlash = false, zIndex, onPerspectiveChange, keepStegaOnCopy, onSuspiciousStega } = props;
|
|
91
91
|
const router = useRouter();
|
|
92
92
|
const [navigate, setNavigate] = useState();
|
|
93
93
|
const history = useMemo(() => ({
|
|
@@ -137,6 +137,8 @@ function VisualEditing(props) {
|
|
|
137
137
|
portal: true,
|
|
138
138
|
refresh: refresh ?? handleRefresh,
|
|
139
139
|
onPerspectiveChange,
|
|
140
|
+
keepStegaOnCopy,
|
|
141
|
+
onSuspiciousStega,
|
|
140
142
|
zIndex
|
|
141
143
|
});
|
|
142
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisualEditing.js","names":["VisualEditingComponent"],"sources":["../src/visual-editing/client-component/utils.ts","../src/visual-editing/client-component/VisualEditing.tsx"],"sourcesContent":["/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/path-has-prefix.ts#L10-L17\n * Checks if a given path starts with a given prefix. It ensures it matches\n * exactly without containing extra chars. e.g. prefix /docs should replace\n * for /docs, /docs/, /docs/a but not /docsss\n * @param path The path to check.\n * @param prefix The prefix to check against.\n */\nfunction pathHasPrefix(path: string, prefix: string): boolean {\n if (typeof path !== 'string') {\n return false\n }\n\n const {pathname} = parsePath(path)\n return pathname === prefix || pathname.startsWith(`${prefix}/`)\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/parse-path.ts#L6-L22\n * Given a path this function will find the pathname, query and hash and return\n * them. This is useful to parse full paths on the client side.\n * @param path A path to parse e.g. /foo/bar?id=1#hash\n */\nfunction parsePath(path: string): {\n pathname: string\n query: string\n hash: string\n} {\n const hashIndex = path.indexOf('#')\n const queryIndex = path.indexOf('?')\n const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex)\n\n if (hasQuery || hashIndex > -1) {\n return {\n pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),\n query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : '',\n hash: hashIndex > -1 ? path.slice(hashIndex) : '',\n }\n }\n\n return {pathname: path, query: '', hash: ''}\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/add-path-prefix.ts#L3C1-L14C2\n * Adds the provided prefix to the given path. It first ensures that the path\n * is indeed starting with a slash.\n */\nexport function addPathPrefix(path: string, prefix?: string): string {\n if (!path.startsWith('/') || !prefix) {\n return path\n }\n // If the path is exactly '/' then return just the prefix\n if (path === '/' && prefix) {\n return prefix\n }\n\n const {pathname, query, hash} = parsePath(path)\n return `${prefix}${pathname}${query}${hash}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/remove-path-prefix.ts#L3-L39\n * Given a path and a prefix it will remove the prefix when it exists in the\n * given path. It ensures it matches exactly without containing extra chars\n * and if the prefix is not there it will be noop.\n *\n * @param path The path to remove the prefix from.\n * @param prefix The prefix to be removed.\n */\nexport function removePathPrefix(path: string, prefix: string): string {\n // If the path doesn't start with the prefix we can return it as is. This\n // protects us from situations where the prefix is a substring of the path\n // prefix such as:\n //\n // For prefix: /blog\n //\n // /blog -> true\n // /blog/ -> true\n // /blog/1 -> true\n // /blogging -> false\n // /blogging/ -> false\n // /blogging/1 -> false\n if (!pathHasPrefix(path, prefix)) {\n return path\n }\n\n // Remove the prefix from the path via slicing.\n const withoutPrefix = path.slice(prefix.length)\n\n // If the path without the prefix starts with a `/` we can return it as is.\n if (withoutPrefix.startsWith('/')) {\n return withoutPrefix\n }\n\n // If the path without the prefix doesn't start with a `/` we need to add it\n // back to the path to make sure it's a valid path.\n return `/${withoutPrefix}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/dfe7fc03e2268e7cb765dce6a89e02c831c922d5/packages/next/src/client/normalize-trailing-slash.ts#L16\n * Normalizes the trailing slash of a path according to the `trailingSlash` option\n * in `next.config.js`.\n */\nexport const normalizePathTrailingSlash = (path: string, trailingSlash: boolean): string => {\n const {pathname, query, hash} = parsePath(path)\n if (trailingSlash) {\n if (pathname.endsWith('/')) {\n return `${pathname}${query}${hash}`\n }\n return `${pathname}/${query}${hash}`\n }\n\n return `${removeTrailingSlash(pathname)}${query}${hash}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/dfe7fc03e2268e7cb765dce6a89e02c831c922d5/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts#L8\n * Removes the trailing slash for a given route or page path. Preserves the\n * root page. Examples:\n * - `/foo/bar/` -> `/foo/bar`\n * - `/foo/bar` -> `/foo/bar`\n * - `/` -> `/`\n */\nfunction removeTrailingSlash(route: string) {\n return route.replace(/\\/$/, '') || '/'\n}\n","import {\n type HistoryAdapter,\n type HistoryAdapterNavigate,\n type HistoryRefresh,\n VisualEditing as VisualEditingComponent,\n type VisualEditingOptions,\n} from '@sanity/visual-editing/react'\nimport {usePathname, useRouter, useSearchParams} from 'next/navigation'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {addPathPrefix, normalizePathTrailingSlash, removePathPrefix} from './utils'\n\n/**\n * @public\n */\nexport interface VisualEditingProps extends Omit<VisualEditingOptions, 'history'> {\n /**\n * @deprecated The histoy adapter is already implemented\n */\n history?: never\n /**\n * If next.config.ts is configured with a basePath we try to configure it automatically,\n * you can disable this by setting basePath to ''.\n * @example basePath=\"/my-custom-base-path\"\n * @alpha experimental and may change without notice\n * @defaultValue process.env.__NEXT_ROUTER_BASEPATH || ''\n */\n basePath?: string\n /**\n * If next.config.ts is configured with a `trailingSlash` we try to detect it automatically,\n * it can be controlled manually by passing a boolean.\n * @example trailingSlash={true}\n * @alpha experimental and may change without notice\n * @defaultValue Boolean(process.env.__NEXT_TRAILING_SLASH)\n */\n trailingSlash?: boolean\n}\n\nexport default function VisualEditing(props: VisualEditingProps): React.JSX.Element | null {\n const {\n basePath = '',\n plugins,\n components,\n refresh,\n trailingSlash = false,\n zIndex,\n onPerspectiveChange,\n } = props\n\n const router = useRouter()\n const [navigate, setNavigate] = useState<HistoryAdapterNavigate | undefined>()\n\n const history = useMemo<HistoryAdapter>(\n () => ({\n subscribe: (_navigate) => {\n setNavigate(() => _navigate)\n return () => setNavigate(undefined)\n },\n update: (update) => {\n switch (update.type) {\n case 'push':\n return router.push(removePathPrefix(update.url, basePath))\n case 'pop':\n return router.back()\n case 'replace':\n return router.replace(removePathPrefix(update.url, basePath))\n default:\n throw new Error(`Unknown update type`, {cause: update})\n }\n },\n }),\n [basePath, router],\n )\n\n const pathname = usePathname()\n const searchParams = useSearchParams()\n useEffect(() => {\n if (navigate) {\n navigate({\n type: 'push',\n url: normalizePathTrailingSlash(\n addPathPrefix(\n `${pathname}${searchParams?.size ? `?${searchParams.toString()}` : ''}`,\n basePath,\n ),\n trailingSlash,\n ),\n })\n }\n }, [basePath, navigate, pathname, searchParams, trailingSlash])\n\n const handleRefresh = useCallback(\n (payload: HistoryRefresh): false | Promise<void> => {\n switch (payload.source) {\n case 'manual':\n router.refresh()\n break\n case 'mutation': {\n // oxlint-disable-next-line no-console\n console.debug(\n '<VisualEditing /> refresh called with source \"mutation\", if you want automatic refresh when this happens, or silence this message, provide your own handler to the refresh prop',\n )\n return false\n }\n default:\n throw new Error('Unknown refresh source', {cause: payload})\n }\n return new Promise((resolve) => setTimeout(resolve, 1_000))\n },\n [router],\n )\n\n return (\n <VisualEditingComponent\n plugins={plugins}\n components={components}\n history={history}\n portal\n refresh={refresh ?? handleRefresh}\n onPerspectiveChange={onPerspectiveChange}\n zIndex={zIndex}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAS,cAAc,MAAc,QAAyB;CAC5D,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,MAAM,EAAC,aAAY,UAAU,IAAI;CACjC,OAAO,aAAa,UAAU,SAAS,WAAW,GAAG,OAAO,EAAE;AAChE;;;;;;;AAQA,SAAS,UAAU,MAIjB;CACA,MAAM,YAAY,KAAK,QAAQ,GAAG;CAClC,MAAM,aAAa,KAAK,QAAQ,GAAG;CACnC,MAAM,WAAW,aAAa,OAAO,YAAY,KAAK,aAAa;CAEnE,IAAI,YAAY,YAAY,IAC1B,OAAO;EACL,UAAU,KAAK,UAAU,GAAG,WAAW,aAAa,SAAS;EAC7D,OAAO,WAAW,KAAK,UAAU,YAAY,YAAY,KAAK,YAAY,KAAA,CAAS,IAAI;EACvF,MAAM,YAAY,KAAK,KAAK,MAAM,SAAS,IAAI;CACjD;CAGF,OAAO;EAAC,UAAU;EAAM,OAAO;EAAI,MAAM;CAAE;AAC7C;;;;;;AAOA,SAAgB,cAAc,MAAc,QAAyB;CACnE,IAAI,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,QAC5B,OAAO;CAGT,IAAI,SAAS,OAAO,QAClB,OAAO;CAGT,MAAM,EAAC,UAAU,OAAO,SAAQ,UAAU,IAAI;CAC9C,OAAO,GAAG,SAAS,WAAW,QAAQ;AACxC;;;;;;;;;;AAWA,SAAgB,iBAAiB,MAAc,QAAwB;CAarE,IAAI,CAAC,cAAc,MAAM,MAAM,GAC7B,OAAO;CAIT,MAAM,gBAAgB,KAAK,MAAM,OAAO,MAAM;CAG9C,IAAI,cAAc,WAAW,GAAG,GAC9B,OAAO;CAKT,OAAO,IAAI;AACb;;;;;;AAOA,MAAa,8BAA8B,MAAc,kBAAmC;C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,QAAQ;IACf;GACF,KAAK;IAEH,QAAQ,MACN,mLACF;IACA,OAAO;GAET,SACE,MAAM,IAAI,MAAM,0BAA0B,EAAC,OAAO,QAAO,CAAC;EAC9D;EACA,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAK,CAAC;CAC5D,GACA,CAAC,MAAM,CACT;CAEA,OACE,oBAACA,iBAAD;EACW;EACG;EACH;EACT,QAAA;EACA,SAAS,WAAW;EACC;EACb;CACT,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"VisualEditing.js","names":["VisualEditingComponent"],"sources":["../src/visual-editing/client-component/utils.ts","../src/visual-editing/client-component/VisualEditing.tsx"],"sourcesContent":["/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/path-has-prefix.ts#L10-L17\n * Checks if a given path starts with a given prefix. It ensures it matches\n * exactly without containing extra chars. e.g. prefix /docs should replace\n * for /docs, /docs/, /docs/a but not /docsss\n * @param path The path to check.\n * @param prefix The prefix to check against.\n */\nfunction pathHasPrefix(path: string, prefix: string): boolean {\n if (typeof path !== 'string') {\n return false\n }\n\n const {pathname} = parsePath(path)\n return pathname === prefix || pathname.startsWith(`${prefix}/`)\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/parse-path.ts#L6-L22\n * Given a path this function will find the pathname, query and hash and return\n * them. This is useful to parse full paths on the client side.\n * @param path A path to parse e.g. /foo/bar?id=1#hash\n */\nfunction parsePath(path: string): {\n pathname: string\n query: string\n hash: string\n} {\n const hashIndex = path.indexOf('#')\n const queryIndex = path.indexOf('?')\n const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex)\n\n if (hasQuery || hashIndex > -1) {\n return {\n pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),\n query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : '',\n hash: hashIndex > -1 ? path.slice(hashIndex) : '',\n }\n }\n\n return {pathname: path, query: '', hash: ''}\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/add-path-prefix.ts#L3C1-L14C2\n * Adds the provided prefix to the given path. It first ensures that the path\n * is indeed starting with a slash.\n */\nexport function addPathPrefix(path: string, prefix?: string): string {\n if (!path.startsWith('/') || !prefix) {\n return path\n }\n // If the path is exactly '/' then return just the prefix\n if (path === '/' && prefix) {\n return prefix\n }\n\n const {pathname, query, hash} = parsePath(path)\n return `${prefix}${pathname}${query}${hash}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/remove-path-prefix.ts#L3-L39\n * Given a path and a prefix it will remove the prefix when it exists in the\n * given path. It ensures it matches exactly without containing extra chars\n * and if the prefix is not there it will be noop.\n *\n * @param path The path to remove the prefix from.\n * @param prefix The prefix to be removed.\n */\nexport function removePathPrefix(path: string, prefix: string): string {\n // If the path doesn't start with the prefix we can return it as is. This\n // protects us from situations where the prefix is a substring of the path\n // prefix such as:\n //\n // For prefix: /blog\n //\n // /blog -> true\n // /blog/ -> true\n // /blog/1 -> true\n // /blogging -> false\n // /blogging/ -> false\n // /blogging/1 -> false\n if (!pathHasPrefix(path, prefix)) {\n return path\n }\n\n // Remove the prefix from the path via slicing.\n const withoutPrefix = path.slice(prefix.length)\n\n // If the path without the prefix starts with a `/` we can return it as is.\n if (withoutPrefix.startsWith('/')) {\n return withoutPrefix\n }\n\n // If the path without the prefix doesn't start with a `/` we need to add it\n // back to the path to make sure it's a valid path.\n return `/${withoutPrefix}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/dfe7fc03e2268e7cb765dce6a89e02c831c922d5/packages/next/src/client/normalize-trailing-slash.ts#L16\n * Normalizes the trailing slash of a path according to the `trailingSlash` option\n * in `next.config.js`.\n */\nexport const normalizePathTrailingSlash = (path: string, trailingSlash: boolean): string => {\n const {pathname, query, hash} = parsePath(path)\n if (trailingSlash) {\n if (pathname.endsWith('/')) {\n return `${pathname}${query}${hash}`\n }\n return `${pathname}/${query}${hash}`\n }\n\n return `${removeTrailingSlash(pathname)}${query}${hash}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/dfe7fc03e2268e7cb765dce6a89e02c831c922d5/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts#L8\n * Removes the trailing slash for a given route or page path. Preserves the\n * root page. Examples:\n * - `/foo/bar/` -> `/foo/bar`\n * - `/foo/bar` -> `/foo/bar`\n * - `/` -> `/`\n */\nfunction removeTrailingSlash(route: string) {\n return route.replace(/\\/$/, '') || '/'\n}\n","import {\n type HistoryAdapter,\n type HistoryAdapterNavigate,\n type HistoryRefresh,\n VisualEditing as VisualEditingComponent,\n type VisualEditingOptions,\n} from '@sanity/visual-editing/react'\nimport {usePathname, useRouter, useSearchParams} from 'next/navigation'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {addPathPrefix, normalizePathTrailingSlash, removePathPrefix} from './utils'\n\n/**\n * @public\n */\nexport interface VisualEditingProps extends Omit<VisualEditingOptions, 'history'> {\n /**\n * @deprecated The histoy adapter is already implemented\n */\n history?: never\n /**\n * If next.config.ts is configured with a basePath we try to configure it automatically,\n * you can disable this by setting basePath to ''.\n * @example basePath=\"/my-custom-base-path\"\n * @alpha experimental and may change without notice\n * @defaultValue process.env.__NEXT_ROUTER_BASEPATH || ''\n */\n basePath?: string\n /**\n * If next.config.ts is configured with a `trailingSlash` we try to detect it automatically,\n * it can be controlled manually by passing a boolean.\n * @example trailingSlash={true}\n * @alpha experimental and may change without notice\n * @defaultValue Boolean(process.env.__NEXT_TRAILING_SLASH)\n */\n trailingSlash?: boolean\n}\n\nexport default function VisualEditing(props: VisualEditingProps): React.JSX.Element | null {\n const {\n basePath = '',\n plugins,\n components,\n refresh,\n trailingSlash = false,\n zIndex,\n onPerspectiveChange,\n keepStegaOnCopy,\n onSuspiciousStega,\n } = props\n\n const router = useRouter()\n const [navigate, setNavigate] = useState<HistoryAdapterNavigate | undefined>()\n\n const history = useMemo<HistoryAdapter>(\n () => ({\n subscribe: (_navigate) => {\n setNavigate(() => _navigate)\n return () => setNavigate(undefined)\n },\n update: (update) => {\n switch (update.type) {\n case 'push':\n return router.push(removePathPrefix(update.url, basePath))\n case 'pop':\n return router.back()\n case 'replace':\n return router.replace(removePathPrefix(update.url, basePath))\n default:\n throw new Error(`Unknown update type`, {cause: update})\n }\n },\n }),\n [basePath, router],\n )\n\n const pathname = usePathname()\n const searchParams = useSearchParams()\n useEffect(() => {\n if (navigate) {\n navigate({\n type: 'push',\n url: normalizePathTrailingSlash(\n addPathPrefix(\n `${pathname}${searchParams?.size ? `?${searchParams.toString()}` : ''}`,\n basePath,\n ),\n trailingSlash,\n ),\n })\n }\n }, [basePath, navigate, pathname, searchParams, trailingSlash])\n\n const handleRefresh = useCallback(\n (payload: HistoryRefresh): false | Promise<void> => {\n switch (payload.source) {\n case 'manual':\n router.refresh()\n break\n case 'mutation': {\n // oxlint-disable-next-line no-console\n console.debug(\n '<VisualEditing /> refresh called with source \"mutation\", if you want automatic refresh when this happens, or silence this message, provide your own handler to the refresh prop',\n )\n return false\n }\n default:\n throw new Error('Unknown refresh source', {cause: payload})\n }\n return new Promise((resolve) => setTimeout(resolve, 1_000))\n },\n [router],\n )\n\n return (\n <VisualEditingComponent\n plugins={plugins}\n components={components}\n history={history}\n portal\n refresh={refresh ?? handleRefresh}\n onPerspectiveChange={onPerspectiveChange}\n keepStegaOnCopy={keepStegaOnCopy}\n onSuspiciousStega={onSuspiciousStega}\n zIndex={zIndex}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAS,cAAc,MAAc,QAAyB;CAC5D,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,MAAM,EAAC,aAAY,UAAU,IAAI;CACjC,OAA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,SAAS,WAAW;EACC;EACJ;EACE;EACX;CACT,CAAA;AAEL"}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/live/shared/constants.ts"],"sourcesContent":["import type {CacheTagPrefix} from '#live/types'\n\n// @TODO make this configurable\nexport const cacheTagPrefix = 'sanity:' satisfies CacheTagPrefix\n\n/** The default API host used by @sanity/client when none is specified. */\nexport const defaultApiHost = 'https://api.sanity.io'\n"],"mappings":"AAGA,MAAa,
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/live/shared/constants.ts"],"sourcesContent":["import type {CacheTagPrefix} from '#live/types'\n\n// @TODO make this configurable\nexport const cacheTagPrefix: 'sanity:' = 'sanity:' satisfies CacheTagPrefix\n\n/** The default API host used by @sanity/client when none is specified. */\nexport const defaultApiHost = 'https://api.sanity.io'\n"],"mappings":"AAGA,MAAa,iBAA4B;;AAGzC,MAAa,iBAAiB"}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { SanityClient } from "@sanity/client";
|
|
2
2
|
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
5
|
interface DefineEnableDraftModeOptions {
|
|
6
6
|
client: SanityClient;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
* Force secure cookies in development mode.
|
|
9
|
+
* Enable this when using Next.js --experimental-https flag.
|
|
10
|
+
* This option has no effect in production (cookies are always secure).
|
|
11
|
+
* @defaultValue false
|
|
12
|
+
*/
|
|
13
13
|
secureDevMode?: boolean;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
18
|
interface EnableDraftMode {
|
|
19
19
|
GET: (request: Request) => Promise<Response>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.
|
|
23
|
-
* Can also be used with `sanity-plugin-iframe-pane`.
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* // src/app/api/draft-mode/enable/route.ts
|
|
27
|
-
*
|
|
28
|
-
* import { defineEnableDraftMode } from "next-sanity/draft-mode";
|
|
29
|
-
* import { client } from "@/sanity/lib/client";
|
|
30
|
-
*
|
|
31
|
-
* export const { GET } = defineEnableDraftMode({
|
|
32
|
-
* client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
22
|
+
* Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.
|
|
23
|
+
* Can also be used with `sanity-plugin-iframe-pane`.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // src/app/api/draft-mode/enable/route.ts
|
|
27
|
+
*
|
|
28
|
+
* import { defineEnableDraftMode } from "next-sanity/draft-mode";
|
|
29
|
+
* import { client } from "@/sanity/lib/client";
|
|
30
|
+
*
|
|
31
|
+
* export const { GET } = defineEnableDraftMode({
|
|
32
|
+
* client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
38
|
declare function defineEnableDraftMode(options: DefineEnableDraftModeOptions): EnableDraftMode;
|
|
39
39
|
export { DefineEnableDraftModeOptions, EnableDraftMode, defineEnableDraftMode };
|
|
40
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"mappings":";;;;UASiB;EACf,QAAQ;;;;;;;EAOR;;;;;UAMe;EACf,MAAM,SAAS,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;iBAoBrB,sBAAsB,SAAS,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"sourcesContent":["import type {SanityClient} from '@sanity/client'\nimport {validatePreviewUrl} from '@sanity/preview-url-secret'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {cookies, draftMode} from 'next/headers'\nimport {redirect} from 'next/navigation'\n\n/**\n * @public\n */\nexport interface DefineEnableDraftModeOptions {\n client: SanityClient\n /**\n * Force secure cookies in development mode.\n * Enable this when using Next.js --experimental-https flag.\n * This option has no effect in production (cookies are always secure).\n * @defaultValue false\n */\n secureDevMode?: boolean\n}\n\n/**\n * @public\n */\nexport interface EnableDraftMode {\n GET: (request: Request) => Promise<Response>\n}\n\n/**\n * Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.\n * Can also be used with `sanity-plugin-iframe-pane`.\n * @example\n * ```ts\n * // src/app/api/draft-mode/enable/route.ts\n *\n * import { defineEnableDraftMode } from \"next-sanity/draft-mode\";\n * import { client } from \"@/sanity/lib/client\";\n *\n * export const { GET } = defineEnableDraftMode({\n * client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),\n * });\n * ```\n *\n * @public\n */\nexport function defineEnableDraftMode(options: DefineEnableDraftModeOptions): EnableDraftMode {\n const {client} = options\n return {\n GET: async (request: Request) => {\n // @TODO check if already in draft mode at a much earlier stage, and skip validation\n\n const {\n isValid,\n redirectTo = '/',\n studioPreviewPerspective,\n } = await validatePreviewUrl(client, request.url)\n if (!isValid) {\n return new Response('Invalid secret', {status: 401})\n }\n\n const draftModeStore = await draftMode()\n\n // Let's enable draft mode if it's not already enabled\n if (!draftModeStore.isEnabled) {\n draftModeStore.enable()\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n // We can't auto-detect HTTPS in dev due to Next.js limitations,\n // so we need an explicit option\n const isSecure = isProduction || (options.secureDevMode ?? false)\n\n // Override cookie header for draft mode for usage in live-preview\n // https://github.com/vercel/next.js/issues/49927\n const cookieStore = await cookies()\n const cookie = cookieStore.get('__prerender_bypass')!\n cookieStore.set({\n name: '__prerender_bypass',\n value: cookie?.value,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n\n if (studioPreviewPerspective) {\n cookieStore.set({\n name: perspectiveCookieName,\n value: studioPreviewPerspective,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"sourcesContent":["import type {SanityClient} from '@sanity/client'\nimport {validatePreviewUrl} from '@sanity/preview-url-secret'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {cookies, draftMode} from 'next/headers'\nimport {redirect} from 'next/navigation'\n\n/**\n * @public\n */\nexport interface DefineEnableDraftModeOptions {\n client: SanityClient\n /**\n * Force secure cookies in development mode.\n * Enable this when using Next.js --experimental-https flag.\n * This option has no effect in production (cookies are always secure).\n * @defaultValue false\n */\n secureDevMode?: boolean\n}\n\n/**\n * @public\n */\nexport interface EnableDraftMode {\n GET: (request: Request) => Promise<Response>\n}\n\n/**\n * Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.\n * Can also be used with `sanity-plugin-iframe-pane`.\n * @example\n * ```ts\n * // src/app/api/draft-mode/enable/route.ts\n *\n * import { defineEnableDraftMode } from \"next-sanity/draft-mode\";\n * import { client } from \"@/sanity/lib/client\";\n *\n * export const { GET } = defineEnableDraftMode({\n * client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),\n * });\n * ```\n *\n * @public\n */\nexport function defineEnableDraftMode(options: DefineEnableDraftModeOptions): EnableDraftMode {\n const {client} = options\n return {\n GET: async (request: Request) => {\n // @TODO check if already in draft mode at a much earlier stage, and skip validation\n\n const {\n isValid,\n redirectTo = '/',\n studioPreviewPerspective,\n } = await validatePreviewUrl(client, request.url)\n if (!isValid) {\n return new Response('Invalid secret', {status: 401})\n }\n\n const draftModeStore = await draftMode()\n\n // Let's enable draft mode if it's not already enabled\n if (!draftModeStore.isEnabled) {\n draftModeStore.enable()\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n // We can't auto-detect HTTPS in dev due to Next.js limitations,\n // so we need an explicit option\n const isSecure = isProduction || (options.secureDevMode ?? false)\n\n // Override cookie header for draft mode for usage in live-preview\n // https://github.com/vercel/next.js/issues/49927\n const cookieStore = await cookies()\n const cookie = cookieStore.get('__prerender_bypass')!\n cookieStore.set({\n name: '__prerender_bypass',\n value: cookie?.value,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n\n if (studioPreviewPerspective) {\n cookieStore.set({\n name: perspectiveCookieName,\n value: studioPreviewPerspective,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n }\n\n return redirect(redirectTo)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,sBAAsB,SAAwD;CAC5F,MAAM,EAAC,WAAU;CACjB,OAAO,EACL,KAAK,OAAO,YAAqB;EAG/B,MAAM,EACJ,SACA,aAAa,KACb,6BACE,MAAM,mBAAmB,QAAQ,QAAQ,GAAG;EAChD,IAAI,CAAC,SACH,OAAO,IAAI,SAAS,kBAAkB,EAAC,QAAQ,IAAG,CAAC;EAGrD,MAAM,iBAAiB,MAAM,UAAU;EAGvC,IAAI,CAAC,eAAe,WAClB,eAAe,OAAO;EAOxB,MAAM,WAJe,QAAQ,IAAI,aAAa,iBAIZ,QAAQ,iBAAiB;EAI3D,MAAM,cAAc,MAAM,QAAQ;EAClC,MAAM,SAAS,YAAY,IAAI,oBAAoB;EACnD,YAAY,IAAI;GACd,MAAM;GACN,OAAO,QAAQ;GACf,UAAU;GACV,MAAM;GACN,QAAQ;GACR,UAAU,WAAW,SAAS;EAChC,CAAC;EAED,IAAI,0BACF,YAAY,IAAI;GACd,MAAM;GACN,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,UAAU,WAAW,SAAS;EAChC,CAAC;EAGH,OAAO,SAAS,UAAU;CAC5B,EACF;AACF"}
|
package/dist/image/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { ImageLoader, ImageProps as ImageProps$1 } from "next/image";
|
|
2
2
|
/**
|
|
3
|
-
* @alpha
|
|
4
|
-
*/
|
|
3
|
+
* @alpha
|
|
4
|
+
*/
|
|
5
5
|
interface ImageProps extends Omit<ImageProps$1, "loader" | "src"> {
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.
|
|
8
|
+
*/
|
|
9
9
|
loader?: never;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Must be a string that is a valid URL to an image on the Sanity Image CDN.
|
|
12
|
+
*/
|
|
13
13
|
src: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @alpha
|
|
17
|
-
*/
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
18
|
declare function Image(props: ImageProps): React.JSX.Element;
|
|
19
19
|
/**
|
|
20
|
-
* @alpha
|
|
21
|
-
*/
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
22
|
declare const imageLoader: ImageLoader;
|
|
23
23
|
export { Image, type ImageProps, imageLoader };
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/image/Image.tsx","../../src/image/imageLoader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/image/Image.tsx","../../src/image/imageLoader.ts"],"mappings":";;;;UAOiB,mBAAmB,KAAK;;;;EAIvC;;;;EAIA;;;;;iBAMc,MAAM,OAAO,aAAa,MAAM,IAAI;;;;cChBvC,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCorsOriginError.d.ts","names":[],"sources":["../src/live/shared/isCorsOriginError.ts"],"mappings":";;iBAGgB,
|
|
1
|
+
{"version":3,"file":"isCorsOriginError.d.ts","names":[],"sources":["../src/live/shared/isCorsOriginError.ts"],"mappings":";;iBAGgB,kBAAkB,iBAAiB,SAAS"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* For usage with `cacheComponents: true`, and `defineLive`:
|
|
3
|
-
* ```ts
|
|
4
|
-
* // next.config.ts
|
|
5
|
-
*
|
|
6
|
-
* import type {NextConfig} from 'next'
|
|
7
|
-
* import {sanity} from 'next-sanity/live/cache-life'
|
|
8
|
-
*
|
|
9
|
-
* const nextConfig: NextConfig = {
|
|
10
|
-
* cacheComponents: true,
|
|
11
|
-
* cacheLife: {
|
|
12
|
-
* default: sanity,
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* export default nextConfig
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
2
|
+
* For usage with `cacheComponents: true`, and `defineLive`:
|
|
3
|
+
* ```ts
|
|
4
|
+
* // next.config.ts
|
|
5
|
+
*
|
|
6
|
+
* import type {NextConfig} from 'next'
|
|
7
|
+
* import {sanity} from 'next-sanity/live/cache-life'
|
|
8
|
+
*
|
|
9
|
+
* const nextConfig: NextConfig = {
|
|
10
|
+
* cacheComponents: true,
|
|
11
|
+
* cacheLife: {
|
|
12
|
+
* default: sanity,
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* export default nextConfig
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
19
|
declare const sanity: {
|
|
20
|
-
/**
|
|
21
|
-
* Sanity Live handles on-demand revalidation, so the default 15min time-based revalidation is too short
|
|
22
|
-
*/
|
|
23
20
|
readonly revalidate: 31_536_000;
|
|
24
21
|
};
|
|
25
22
|
export { sanity };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-life.d.ts","names":[],"sources":["../../src/live/cache-life.ts"],"mappings":"AAkBA
|
|
1
|
+
{"version":3,"file":"cache-life.d.ts","names":[],"sources":["../../src/live/cache-life.ts"],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;cAAa;WACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-life.js","names":[],"sources":["../../src/live/cache-life.ts"],"sourcesContent":["/**\n * For usage with `cacheComponents: true`, and `defineLive`:\n * ```ts\n * // next.config.ts\n *\n * import type {NextConfig} from 'next'\n * import {sanity} from 'next-sanity/live/cache-life'\n *\n * const nextConfig: NextConfig = {\n * cacheComponents: true,\n * cacheLife: {\n * default: sanity,\n * }\n * }\n *\n * export default nextConfig\n * ```\n */\nexport const sanity = {\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time-based revalidation is too short\n */\n revalidate: 31_536_000, // 365 days\n} as const satisfies {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,
|
|
1
|
+
{"version":3,"file":"cache-life.js","names":[],"sources":["../../src/live/cache-life.ts"],"sourcesContent":["/**\n * For usage with `cacheComponents: true`, and `defineLive`:\n * ```ts\n * // next.config.ts\n *\n * import type {NextConfig} from 'next'\n * import {sanity} from 'next-sanity/live/cache-life'\n *\n * const nextConfig: NextConfig = {\n * cacheComponents: true,\n * cacheLife: {\n * default: sanity,\n * }\n * }\n *\n * export default nextConfig\n * ```\n */\nexport const sanity: {\n readonly revalidate: 31_536_000\n} = {\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time-based revalidation is too short\n */\n revalidate: 31_536_000, // 365 days\n} as const satisfies {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAET;;;;AAIF,YAAY,QACd"}
|
|
@@ -12,8 +12,8 @@ interface SanityLiveProps {
|
|
|
12
12
|
onGoAway: SanityLiveOnGoaway | false | undefined;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* @internal CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.
|
|
16
|
-
*/
|
|
15
|
+
* @internal CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.
|
|
16
|
+
*/
|
|
17
17
|
declare const SanityLive: React.ComponentType<SanityLiveProps>;
|
|
18
18
|
export { SanityLive };
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/live/client-components/SanityLive.tsx","../../../src/live/client-components/index.ts"],"mappings":";UAmBiB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/live/client-components/SanityLive.tsx","../../../src/live/client-components/index.ts"],"mappings":";UAmBiB;EACf,QAAQ;EACR;EACA;EACA;EAEA,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,WAAW;EACX,UAAU;;;;;cCtBC,YAAY,MAAM,cAAc"}
|