next-sanity 13.0.0-cache-components.39 → 13.0.0-cache-components.40
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/default/index.d.ts +0 -3
- package/dist/live/conditions/default/index.d.ts.map +1 -1
- package/dist/live/conditions/default/index.js +0 -3
- package/dist/live/conditions/default/index.js.map +1 -1
- package/dist/parseTags.d.ts +24 -3
- package/dist/parseTags.d.ts.map +1 -1
- package/dist/resolvePerspectiveFromCookies.js +21 -2
- package/dist/resolvePerspectiveFromCookies.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,9 +21,6 @@ declare function defineLive(config: DefineLiveOptions & {
|
|
|
21
21
|
sanityFetch: DefinedFetchType;
|
|
22
22
|
SanityLive: React.ComponentType<DefinedLiveProps>;
|
|
23
23
|
};
|
|
24
|
-
/**
|
|
25
|
-
* @alias {@link resolvePerspectiveFromCookies}
|
|
26
|
-
*/
|
|
27
24
|
declare const resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies;
|
|
28
25
|
export { type LivePerspective, defineLive, isCorsOriginError, parseTags, resolvePerspectiveFromCookies };
|
|
29
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"mappings":";;;AAsBA;;;;AAAA,iBAAgB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,sBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,sBAAA;AAAA;;;;;iBAMlB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,gBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,gBAAA;AAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"mappings":";;;AAsBA;;;;AAAA,iBAAgB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,sBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,sBAAA;AAAA;;;;;iBAMlB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,gBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,gBAAA;AAAA;AAAA,cAWrB,6BAAA,EAA+B,6BAAA"}
|
|
@@ -7,9 +7,6 @@ import { t as parseTags } from "../../../parseTags.js";
|
|
|
7
7
|
function defineLive(_config) {
|
|
8
8
|
throw new Error(`defineLive can't be imported by a client component`);
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* @alias {@link resolvePerspectiveFromCookies}
|
|
12
|
-
*/
|
|
13
10
|
const resolvePerspectiveFromCookies = () => {
|
|
14
11
|
throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`);
|
|
15
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"sourcesContent":["// This is the fallback export condition for `import 'next-sanity/live'`,\n// it should have the same type definitions as the other conditions so that userland don't have to worry about setting the right\n// `customCondition` in their `tsconfig.json` in order to get accurate typings.\n// The implementation here though should all throw errors, as importing this file means userland made a mistake and somehow a client component is\n// trying to pull in something it shouldn't.\n\nimport type {ResolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport {isCorsOriginError} from '#live/isCorsOriginError'\nexport {parseTags} from '#live/parseTags'\n\n/**\n * One\n * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\n/**\n * Two\n * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\n/**\n * Three\n * @public\n */\nexport function defineLive(_config: DefineLiveOptions): never {\n throw new Error(`defineLive can't be imported by a client component`)\n}\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"sourcesContent":["// This is the fallback export condition for `import 'next-sanity/live'`,\n// it should have the same type definitions as the other conditions so that userland don't have to worry about setting the right\n// `customCondition` in their `tsconfig.json` in order to get accurate typings.\n// The implementation here though should all throw errors, as importing this file means userland made a mistake and somehow a client component is\n// trying to pull in something it shouldn't.\n\nimport type {ResolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport {isCorsOriginError} from '#live/isCorsOriginError'\nexport {parseTags} from '#live/parseTags'\n\n/**\n * One\n * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\n/**\n * Two\n * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\n/**\n * Three\n * @public\n */\nexport function defineLive(_config: DefineLiveOptions): never {\n throw new Error(`defineLive can't be imported by a client component`)\n}\n\n\nexport const resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies = () => {\n throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`)\n}\n\nexport type {LivePerspective} from '#live/types'\n"],"mappings":";;;;;;AAsCA,SAAgB,WAAW,SAAmC;AAC5D,OAAM,IAAI,MAAM,qDAAqD;;AAIvE,MAAa,sCAAqE;AAChF,OAAM,IAAI,MAAM,wEAAwE"}
|
package/dist/parseTags.d.ts
CHANGED
|
@@ -19,10 +19,31 @@ import { ClientPerspective, SyncTag } from "@sanity/client";
|
|
|
19
19
|
*
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
declare function resolvePerspectiveFromCookies({
|
|
23
|
+
cookies: jar
|
|
24
|
+
}: {
|
|
23
25
|
cookies: Awaited<ReturnType<typeof cookies>>;
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
+
}): Promise<Exclude<ClientPerspective, "raw">>;
|
|
27
|
+
/**
|
|
28
|
+
* This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),
|
|
29
|
+
* where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.
|
|
30
|
+
* Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.
|
|
31
|
+
*
|
|
32
|
+
* The caller is responsible for awaiting `cookies()` from `next/headers` and passing the
|
|
33
|
+
* resulting cookie store as the `cookies` option — this keeps the helper free of dynamic APIs
|
|
34
|
+
* so it can be invoked from anywhere a `ReadonlyRequestCookies` instance is available.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import {cookies} from 'next/headers'
|
|
39
|
+
* import {resolvePerspectiveFromCookies} from 'next-sanity/live'
|
|
40
|
+
*
|
|
41
|
+
* const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
type ResolvePerspectiveFromCookies = typeof resolvePerspectiveFromCookies;
|
|
26
47
|
declare const cacheTagPrefixes: {
|
|
27
48
|
published: string;
|
|
28
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":";;;AAyBA;;;;;;;;;;;;;;;;;;
|
|
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":";;;AAyBA;;;;;;;;;;;;;;;;;;iBAAsB,6BAAA,CAAA;EACpB,OAAA,EAAS;AAAA;EAET,OAAA,EAAS,OAAA,CAAQ,UAAA,QAAkB,OAAA;AAAA,IACjC,OAAA,CAAQ,OAAA,CAAQ,iBAAA;;;AAyBpB;;;;;;AC/CA;;;;;;ACL+B;;;;;KFoDnB,6BAAA,UAAuC,6BAAA;AAAA,cC/CtC,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;;;;;;;;;;;;;;AFwCxC;;;;;;AC/CA;;iBC8BgB,SAAA,CAAU,UAAA,YAAsB,UAAA"}
|
|
@@ -8,9 +8,28 @@ function validateStrictFetchOptions(options) {
|
|
|
8
8
|
if (typeof options.perspective === "undefined" || options.perspective === null) throw new Error(`sanityFetch() requires an explicit \`perspective\` option when \`strict: true\` is set on \`defineLive\`.\n\nMore information: ${generateHelpUrl("next-sanity-fetch-strict")}`, { cause: 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
|
+
* This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),
|
|
13
|
+
* where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.
|
|
14
|
+
* Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.
|
|
15
|
+
*
|
|
16
|
+
* The caller is responsible for awaiting `cookies()` from `next/headers` and passing the
|
|
17
|
+
* resulting cookie store as the `cookies` option — this keeps the helper free of dynamic APIs
|
|
18
|
+
* so it can be invoked from anywhere a `ReadonlyRequestCookies` instance is available.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import {cookies} from 'next/headers'
|
|
23
|
+
* import {resolvePerspectiveFromCookies} from 'next-sanity/live'
|
|
24
|
+
*
|
|
25
|
+
* const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
async function resolvePerspectiveFromCookies({ cookies: jar }) {
|
|
12
31
|
return jar.has(perspectiveCookieName) ? sanitizePerspective(jar.get(perspectiveCookieName)?.value, "drafts") : "drafts";
|
|
13
|
-
}
|
|
32
|
+
}
|
|
14
33
|
export { validateStrictFetchOptions as n, validateStrictSanityLiveProps as r, resolvePerspectiveFromCookies as t };
|
|
15
34
|
|
|
16
35
|
//# 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 '#live/sanitizePerspective'\n\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
|
|
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 * 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\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 type ResolvePerspectiveFromCookies = typeof resolvePerspectiveFromCookies\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;;;;;;;;;;;;;;;;;;;;;ACAL,eAAsB,8BAA8B,EAClD,SAAS,OAGoC;AAC7C,QAAO,IAAI,IAAI,sBAAsB,GACjC,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,OAAO,SAAS,GACpE"}
|