next-sanity 13.0.0-cache-components.37 → 13.0.0-cache-components.38
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/live/conditions/next-js/index.js +1 -1
- package/dist/live/conditions/react-server/index.js +1 -1
- package/dist/parseTags.d.ts +25 -3
- package/dist/parseTags.d.ts.map +1 -1
- package/dist/resolvePerspectiveFromCookies.js +22 -3
- package/dist/resolvePerspectiveFromCookies.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as isCorsOriginError } from "../../../isCorsOriginError.js";
|
|
2
2
|
import { n as revalidate, t as cacheTagPrefixes } from "../../../constants.js";
|
|
3
|
-
import { t as parseTags } from "../../../parseTags.js";
|
|
4
3
|
import { n as validateStrictFetchOptions, r as validateStrictSanityLiveProps, t as resolvePerspectiveFromCookies } from "../../../resolvePerspectiveFromCookies.js";
|
|
4
|
+
import { t as parseTags } from "../../../parseTags.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { SanityLive } from "next-sanity/live/client-components";
|
|
7
7
|
import { actionRefresh, actionUpdateTags } from "next-sanity/live/server-actions";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as isCorsOriginError } from "../../../isCorsOriginError.js";
|
|
2
2
|
import { t as cacheTagPrefixes } from "../../../constants.js";
|
|
3
|
-
import { t as parseTags } from "../../../parseTags.js";
|
|
4
3
|
import { n as validateStrictFetchOptions, r as validateStrictSanityLiveProps, t as resolvePerspectiveFromCookies } from "../../../resolvePerspectiveFromCookies.js";
|
|
4
|
+
import { t as parseTags } from "../../../parseTags.js";
|
|
5
5
|
import { t as sanitizePerspective } from "../../../sanitizePerspective.js";
|
|
6
6
|
import { perspectiveCookieName } from "@sanity/preview-url-secret/constants";
|
|
7
7
|
import { cookies, draftMode } from "next/headers";
|
package/dist/parseTags.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { cookies } from "next/headers";
|
|
2
2
|
import { ClientPerspective, SyncTag } from "@sanity/client";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated - refactor to exporting the same function instead
|
|
5
|
+
*/
|
|
3
6
|
type ResolvePerspectiveFromCookies = (options: {
|
|
4
7
|
/**
|
|
5
8
|
* You must await the cookies() function from next/headers
|
|
@@ -14,14 +17,33 @@ type ResolvePerspectiveFromCookies = (options: {
|
|
|
14
17
|
cookies: Awaited<ReturnType<typeof cookies>>;
|
|
15
18
|
}) => Promise<Exclude<ClientPerspective, "raw">>;
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Reads the active draft-mode perspective from the cookie set by
|
|
21
|
+
* {@link "next-sanity/draft-mode".defineEnableDraftMode | `defineEnableDraftMode`}, falling back to `'drafts'`
|
|
22
|
+
* when the cookie is missing or contains an invalid value.
|
|
23
|
+
*
|
|
24
|
+
* This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),
|
|
25
|
+
* where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.
|
|
26
|
+
* Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.
|
|
27
|
+
*
|
|
28
|
+
* The caller is responsible for awaiting `cookies()` from `next/headers` and passing the
|
|
29
|
+
* resulting cookie store as the `cookies` option — this keeps the helper free of dynamic APIs
|
|
30
|
+
* so it can be invoked from anywhere a `ReadonlyRequestCookies` instance is available.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import {cookies} from 'next/headers'
|
|
35
|
+
* import {resolvePerspectiveFromCookies} from 'next-sanity/live'
|
|
36
|
+
*
|
|
37
|
+
* const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
18
40
|
* @public
|
|
19
41
|
*/
|
|
20
|
-
declare
|
|
42
|
+
declare function resolvePerspectiveFromCookies({
|
|
21
43
|
cookies: jar
|
|
22
44
|
}: {
|
|
23
45
|
cookies: Awaited<ReturnType<typeof cookies>>;
|
|
24
|
-
})
|
|
46
|
+
}): Promise<Exclude<ClientPerspective, "raw">>;
|
|
25
47
|
declare const cacheTagPrefixes: {
|
|
26
48
|
published: string;
|
|
27
49
|
drafts: string;
|
package/dist/parseTags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseTags.d.ts","names":[],"sources":["../src/live/shared/resolvePerspectiveFromCookies.ts","../src/live/shared/constants.ts","../src/live/shared/parseTags.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"parseTags.d.ts","names":[],"sources":["../src/live/shared/resolvePerspectiveFromCookies.ts","../src/live/shared/constants.ts","../src/live/shared/parseTags.ts"],"mappings":";;;AASA;;KAAY,6BAAA,IAAiC,OAAA;;;;;;;;;;;EAW3C,OAAA,EAAS,OAAA,CAAQ,UAAA,QAAkB,OAAA;AAAA,MAC/B,OAAA,CAAQ,OAAA,CAAQ,iBAAA;;;;;;;AAyBtB;;;;;;;;;;;;;;;;;iBAAsB,6BAAA,CAAA;EACpB,OAAA,EAAS;AAAA;EAET,OAAA,EAAS,OAAA,CAAQ,UAAA,QAAkB,OAAA;AAAA,IACjC,OAAA,CAAQ,OAAA,CAAQ,iBAAA;AAAA,cC3CP,gBAAA;EACX,SAAA;EACA,MAAA;AAAA;AAAA,UCLQ,mBAAA;EACR,IAAA,YAAgB,gBAAA,CAAiB,SAAA,GAAY,OAAA;EAC7C,MAAA,SAAe,gBAAA,CAAiB,SAAA;EAChC,UAAA;AAAA;AAAA,UAEQ,eAAA;EACR,IAAA,YAAgB,gBAAA,CAAiB,MAAA,GAAS,OAAA;EAC1C,MAAA,SAAe,gBAAA,CAAiB,MAAA;EAChC,UAAA;AAAA;AAAA,KAEG,UAAA,GAAa,mBAAA,GAAsB,eAAA;;;;;;;;;;;;AFgCxC;;;;;;;;;;iBETgB,SAAA,CAAU,UAAA,YAAsB,UAAA"}
|
|
@@ -9,12 +9,31 @@ function validateStrictFetchOptions(options) {
|
|
|
9
9
|
if (typeof options.stega !== "boolean") throw new Error(`sanityFetch() requires an explicit \`stega\` option (true or false) when \`strict: true\` is set on \`defineLive\`.\n\nMore information: ${generateHelpUrl("next-sanity-fetch-strict")}`, { cause: options });
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Reads the active draft-mode perspective from the cookie set by
|
|
13
|
+
* {@link "next-sanity/draft-mode".defineEnableDraftMode | `defineEnableDraftMode`}, falling back to `'drafts'`
|
|
14
|
+
* when the cookie is missing or contains an invalid value.
|
|
15
|
+
*
|
|
16
|
+
* This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),
|
|
17
|
+
* where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.
|
|
18
|
+
* Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.
|
|
19
|
+
*
|
|
20
|
+
* The caller is responsible for awaiting `cookies()` from `next/headers` and passing the
|
|
21
|
+
* resulting cookie store as the `cookies` option — this keeps the helper free of dynamic APIs
|
|
22
|
+
* so it can be invoked from anywhere a `ReadonlyRequestCookies` instance is available.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import {cookies} from 'next/headers'
|
|
27
|
+
* import {resolvePerspectiveFromCookies} from 'next-sanity/live'
|
|
28
|
+
*
|
|
29
|
+
* const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
13
32
|
* @public
|
|
14
33
|
*/
|
|
15
|
-
|
|
34
|
+
async function resolvePerspectiveFromCookies({ cookies: jar }) {
|
|
16
35
|
return jar.has(perspectiveCookieName) ? sanitizePerspective(jar.get(perspectiveCookieName)?.value, "drafts") : "drafts";
|
|
17
|
-
}
|
|
36
|
+
}
|
|
18
37
|
export { validateStrictFetchOptions as n, validateStrictSanityLiveProps as r, resolvePerspectiveFromCookies as t };
|
|
19
38
|
|
|
20
39
|
//# sourceMappingURL=resolvePerspectiveFromCookies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePerspectiveFromCookies.js","names":[],"sources":["../src/live/shared/strictValidation.ts","../src/live/shared/resolvePerspectiveFromCookies.ts"],"sourcesContent":["import {generateHelpUrl} from '@sanity/generate-help-url'\n\nexport function validateStrictSanityLiveProps(props: {includeDrafts?: unknown}): void {\n if (typeof props.includeDrafts !== 'boolean') {\n throw new Error(\n `<SanityLive> requires an explicit \\`includeDrafts\\` prop (true or false) when \\`strict: true\\` is set on \\`defineLive\\`.\\n\\nMore information: ${generateHelpUrl('next-sanity-live-strict')}`,\n {cause: props},\n )\n }\n}\n\nexport function validateStrictFetchOptions(options: {\n perspective?: unknown\n stega?: unknown\n}): void {\n if (typeof options.perspective === 'undefined' || options.perspective === null) {\n throw new Error(\n `sanityFetch() requires an explicit \\`perspective\\` option when \\`strict: true\\` is set on \\`defineLive\\`.\\n\\nMore information: ${generateHelpUrl('next-sanity-fetch-strict')}`,\n {cause: options},\n )\n }\n if (typeof options.stega !== 'boolean') {\n throw new Error(\n `sanityFetch() requires an explicit \\`stega\\` option (true or false) when \\`strict: true\\` is set on \\`defineLive\\`.\\n\\nMore information: ${generateHelpUrl('next-sanity-fetch-strict')}`,\n {cause: options},\n )\n }\n}\n","import type {ClientPerspective} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport type {cookies} from 'next/headers'\n\nimport {sanitizePerspective} from '
|
|
1
|
+
{"version":3,"file":"resolvePerspectiveFromCookies.js","names":[],"sources":["../src/live/shared/strictValidation.ts","../src/live/shared/resolvePerspectiveFromCookies.ts"],"sourcesContent":["import {generateHelpUrl} from '@sanity/generate-help-url'\n\nexport function validateStrictSanityLiveProps(props: {includeDrafts?: unknown}): void {\n if (typeof props.includeDrafts !== 'boolean') {\n throw new Error(\n `<SanityLive> requires an explicit \\`includeDrafts\\` prop (true or false) when \\`strict: true\\` is set on \\`defineLive\\`.\\n\\nMore information: ${generateHelpUrl('next-sanity-live-strict')}`,\n {cause: props},\n )\n }\n}\n\nexport function validateStrictFetchOptions(options: {\n perspective?: unknown\n stega?: unknown\n}): void {\n if (typeof options.perspective === 'undefined' || options.perspective === null) {\n throw new Error(\n `sanityFetch() requires an explicit \\`perspective\\` option when \\`strict: true\\` is set on \\`defineLive\\`.\\n\\nMore information: ${generateHelpUrl('next-sanity-fetch-strict')}`,\n {cause: options},\n )\n }\n if (typeof options.stega !== 'boolean') {\n throw new Error(\n `sanityFetch() requires an explicit \\`stega\\` option (true or false) when \\`strict: true\\` is set on \\`defineLive\\`.\\n\\nMore information: ${generateHelpUrl('next-sanity-fetch-strict')}`,\n {cause: options},\n )\n }\n}\n","import type {ClientPerspective} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport type {cookies} from 'next/headers'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\n\n/**\n * @deprecated - refactor to exporting the same function instead\n */\nexport type ResolvePerspectiveFromCookies = (options: {\n /**\n * You must await the cookies() function from next/headers\n * and pass it here.\n * Example:\n * ```ts\n * import { cookies } from 'next/headers'\n *\n * const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})\n * ```\n */\n cookies: Awaited<ReturnType<typeof cookies>>\n}) => Promise<Exclude<ClientPerspective, 'raw'>>\n\n/**\n * Reads the active draft-mode perspective from the cookie set by\n * {@link \"next-sanity/draft-mode\".defineEnableDraftMode | `defineEnableDraftMode`}, falling back to `'drafts'`\n * when the cookie is missing or contains an invalid value.\n *\n * This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),\n * where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.\n * Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.\n *\n * The caller is responsible for awaiting `cookies()` from `next/headers` and passing the\n * resulting cookie store as the `cookies` option — this keeps the helper free of dynamic APIs\n * so it can be invoked from anywhere a `ReadonlyRequestCookies` instance is available.\n *\n * @example\n * ```ts\n * import {cookies} from 'next/headers'\n * import {resolvePerspectiveFromCookies} from 'next-sanity/live'\n *\n * const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})\n * ```\n *\n * @public\n */\nexport async function resolvePerspectiveFromCookies({\n cookies: jar,\n}: {\n cookies: Awaited<ReturnType<typeof cookies>>\n}): Promise<Exclude<ClientPerspective, 'raw'>> {\n return jar.has(perspectiveCookieName)\n ? sanitizePerspective(jar.get(perspectiveCookieName)?.value, 'drafts')\n : 'drafts'\n}\n"],"mappings":";;;AAEA,SAAgB,8BAA8B,OAAwC;AACpF,KAAI,OAAO,MAAM,kBAAkB,UACjC,OAAM,IAAI,MACR,iJAAiJ,gBAAgB,0BAA0B,IAC3L,EAAC,OAAO,OAAM,CACf;;AAIL,SAAgB,2BAA2B,SAGlC;AACP,KAAI,OAAO,QAAQ,gBAAgB,eAAe,QAAQ,gBAAgB,KACxE,OAAM,IAAI,MACR,kIAAkI,gBAAgB,2BAA2B,IAC7K,EAAC,OAAO,SAAQ,CACjB;AAEH,KAAI,OAAO,QAAQ,UAAU,UAC3B,OAAM,IAAI,MACR,4IAA4I,gBAAgB,2BAA2B,IACvL,EAAC,OAAO,SAAQ,CACjB;;;;;;;;;;;;;;;;;;;;;;;;;ACqBL,eAAsB,8BAA8B,EAClD,SAAS,OAGoC;AAC7C,QAAO,IAAI,IAAI,sBAAsB,GACjC,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,OAAO,SAAS,GACpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-sanity",
|
|
3
|
-
"version": "13.0.0-cache-components.
|
|
3
|
+
"version": "13.0.0-cache-components.38",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"live",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@vitejs/plugin-react": "^6.0.1",
|
|
83
83
|
"@vitest/coverage-v8": "^4.1.5",
|
|
84
84
|
"js-yaml": "^4.1.1",
|
|
85
|
-
"next": "16.3.0-canary.
|
|
85
|
+
"next": "16.3.0-canary.9",
|
|
86
86
|
"publint": "^0.3.18",
|
|
87
87
|
"react": "^19.2.5",
|
|
88
88
|
"react-dom": "^19.2.5",
|