next-sanity 13.0.0-cache-components.35 → 13.0.0-cache-components.37

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.
Files changed (54) hide show
  1. package/dist/NextStudio.js +17 -0
  2. package/dist/NextStudio.js.map +1 -1
  3. package/dist/NextStudioNoScript.js +2 -0
  4. package/dist/NextStudioNoScript.js.map +1 -1
  5. package/dist/RefreshOnFocus.js +2 -2
  6. package/dist/RefreshOnFocus.js.map +1 -1
  7. package/dist/RefreshOnInterval.js +2 -2
  8. package/dist/RefreshOnInterval.js.map +1 -1
  9. package/dist/RefreshOnMount.js +9 -3
  10. package/dist/RefreshOnMount.js.map +1 -1
  11. package/dist/RefreshOnReconnect.js +2 -2
  12. package/dist/RefreshOnReconnect.js.map +1 -1
  13. package/dist/SanityLive.js +13 -9
  14. package/dist/SanityLive.js.map +1 -1
  15. package/dist/VisualEditing.js +41 -0
  16. package/dist/VisualEditing.js.map +1 -1
  17. package/dist/constants.js +3 -0
  18. package/dist/constants.js.map +1 -1
  19. package/dist/draft-mode/index.js +17 -0
  20. package/dist/draft-mode/index.js.map +1 -1
  21. package/dist/image/index.js +6 -0
  22. package/dist/image/index.js.map +1 -1
  23. package/dist/isCorsOriginError.js +1 -0
  24. package/dist/isCorsOriginError.js.map +1 -1
  25. package/dist/live/cache-life.js +32 -1
  26. package/dist/live/cache-life.js.map +1 -1
  27. package/dist/live/client-components/index.d.ts.map +1 -1
  28. package/dist/live/client-components/index.js +3 -0
  29. package/dist/live/client-components/index.js.map +1 -1
  30. package/dist/live/conditions/default/index.js +4 -0
  31. package/dist/live/conditions/default/index.js.map +1 -1
  32. package/dist/live/conditions/next-js/index.js +7 -0
  33. package/dist/live/conditions/next-js/index.js.map +1 -1
  34. package/dist/live/conditions/react-server/index.js.map +1 -1
  35. package/dist/live/server-actions/index.default.js +6 -0
  36. package/dist/live/server-actions/index.default.js.map +1 -1
  37. package/dist/live/server-actions/index.next-js.js +6 -0
  38. package/dist/live/server-actions/index.next-js.js.map +1 -1
  39. package/dist/parseTags.js +21 -0
  40. package/dist/parseTags.js.map +1 -1
  41. package/dist/resolvePerspectiveFromCookies.js +4 -0
  42. package/dist/resolvePerspectiveFromCookies.js.map +1 -1
  43. package/dist/studio/client-component/index.js +7 -0
  44. package/dist/studio/client-component/index.js.map +1 -1
  45. package/dist/studio/index.js +40 -0
  46. package/dist/studio/index.js.map +1 -1
  47. package/dist/types.d.ts +1 -1
  48. package/dist/visual-editing/index.js +3 -0
  49. package/dist/visual-editing/index.js.map +1 -1
  50. package/dist/visual-editing/server-actions/index.js +6 -0
  51. package/dist/visual-editing/server-actions/index.js.map +1 -1
  52. package/dist/webhook/index.js +5 -0
  53. package/dist/webhook/index.js.map +1 -1
  54. package/package.json +18 -17
@@ -1,5 +1,8 @@
1
1
  "use client";
2
2
  import dynamic from "next/dynamic";
3
+ /**
4
+ * @alpha CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.
5
+ */
3
6
  const SanityLive = dynamic(() => import("../../SanityLive.js"), { ssr: false });
4
7
  export { SanityLive };
5
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/live/client-components/index.ts"],"sourcesContent":["'use client'\n\nimport dynamic from 'next/dynamic'\n\nimport type {SanityLiveProps} from './SanityLive'\n/**\n * @alpha CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.\n */\nexport const SanityLive: React.ComponentType<SanityLiveProps> = dynamic(\n () => import('./SanityLive'),\n {ssr: false},\n)\n"],"mappings":";;AAQA,MAAa,aAAmD,cACxD,OAAO,wBACb,EAAC,KAAK,OAAM,CACb"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/live/client-components/index.ts"],"sourcesContent":["'use client'\n\nimport dynamic from 'next/dynamic'\n\nimport type {SanityLiveProps} from './SanityLive'\n/**\n * @alpha CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.\n */\nexport const SanityLive: React.ComponentType<SanityLiveProps> = dynamic(\n () => import('./SanityLive'),\n {ssr: false},\n)\n"],"mappings":";;;;;AAQA,MAAa,aAAmD,cACxD,OAAO,wBACb,EAAC,KAAK,OAAM,CACb"}
@@ -3,6 +3,10 @@ import { t as parseTags } from "../../../parseTags.js";
3
3
  function defineLive(_config) {
4
4
  throw new Error(`defineLive can't be imported by a client component`);
5
5
  }
6
+ /**
7
+ * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from "next-sanity/draft-mode"`
8
+ * @public
9
+ */
6
10
  const resolvePerspectiveFromCookies = () => {
7
11
  throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`);
8
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 * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(_config: DefineLiveOptions): never {\n throw new Error(`defineLive can't be imported by a client component`)\n}\n\n/**\n * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from \"next-sanity/draft-mode\"`\n * @public\n */\nexport const resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies = () => {\n throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`)\n}\n\nexport type {PerspectiveType as LivePerspective} from '#live/types'\n"],"mappings":";;AA6BA,SAAgB,WAAW,SAAmC;AAC5D,OAAM,IAAI,MAAM,qDAAqD;;AAOvE,MAAa,sCAAqE;AAChF,OAAM,IAAI,MAAM,wEAAwE"}
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 * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(_config: DefineLiveOptions): never {\n throw new Error(`defineLive can't be imported by a client component`)\n}\n\n/**\n * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from \"next-sanity/draft-mode\"`\n * @public\n */\nexport const resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies = () => {\n throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`)\n}\n\nexport type {PerspectiveType as LivePerspective} from '#live/types'\n"],"mappings":";;AA6BA,SAAgB,WAAW,SAAmC;AAC5D,OAAM,IAAI,MAAM,qDAAqD;;;;;;AAOvE,MAAa,sCAAqE;AAChF,OAAM,IAAI,MAAM,wEAAwE"}
@@ -40,7 +40,14 @@ function defineLive(config) {
40
40
  token: perspective === "published" ? originalToken : serverToken || originalToken
41
41
  });
42
42
  const tags = [...customCacheTags, ...(syncTags || []).map((tag) => `${cacheTagPrefix}${tag}`)];
43
+ /**
44
+ * The tags used here, are expired later on in the `expireTags` Server Action with the `expireTag` function from `next/cache`
45
+ */
43
46
  cacheTag(...tags);
47
+ /**
48
+ * Sanity Live handles on-demand revalidation, so the default 15min time based revalidation is too short,
49
+ * userland can still set a shorter revalidate time by calling `cacheLife` themselves.
50
+ */
44
51
  cacheLife({ revalidate });
45
52
  return {
46
53
  data: result,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["SanityLive","SanityLiveClientComponent"],"sources":["../../../../src/live/conditions/next-js/defineLive.tsx"],"sourcesContent":["import {SanityLive as SanityLiveClientComponent} from 'next-sanity/live/client-components'\nimport {actionRefresh, actionUpdateTags} from 'next-sanity/live/server-actions'\nimport {cacheLife, cacheTag} from 'next/cache'\nimport {PHASE_PRODUCTION_BUILD} from 'next/constants'\nimport {preconnect} from 'react-dom'\n\nimport {cacheTagPrefixes, revalidate} from '#live/constants'\nimport {validateStrictFetchOptions, validateStrictSanityLiveProps} from '#live/strictValidation'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions) {\n const {client: _client, serverToken, browserToken, strict = false} = config\n\n if (!_client) {\n throw new Error('`client` is required for `defineLive` to function')\n }\n\n if (process.env.NODE_ENV !== 'production' && !serverToken && serverToken !== false) {\n console.warn(\n 'No `serverToken` provided to `defineLive`. This means that only published content will be fetched and respond to live events. You can silence this warning by setting `serverToken: false`.',\n )\n }\n\n if (process.env.NODE_ENV !== 'production' && !browserToken && browserToken !== false) {\n console.warn(\n 'No `browserToken` provided to `defineLive`. This means that live previewing drafts will only work when using the Presentation Tool in your Sanity Studio. To support live previewing drafts stand-alone, provide a `browserToken`. It is shared with the browser so it should only have Viewer rights or lower. You can silence this warning by setting `browserToken: false`.',\n )\n }\n\n const client = _client.withConfig({allowReconfigure: false, useCdn: true})\n const {token: originalToken, perspective: originalPerspective = 'published'} = client.config()\n\n const sanityFetch: DefinedFetchType = async function sanityFetch({\n query,\n params = {},\n perspective: _perspective,\n stega: _stega,\n tags: customCacheTags = [],\n requestTag = 'next-loader.fetch.cache-components',\n }) {\n if (strict) {\n validateStrictFetchOptions({perspective: _perspective, stega: _stega})\n }\n const perspective = _perspective ?? originalPerspective\n const stega = _stega ?? false\n const useCdn = perspective === 'published'\n const isBuildPhase = process.env['NEXT_PHASE'] === PHASE_PRODUCTION_BUILD\n const cacheMode = useCdn && !isBuildPhase ? 'noStale' : undefined\n\n const cacheTagPrefix =\n perspective === 'published' ? cacheTagPrefixes.published : cacheTagPrefixes.drafts\n const {result, resultSourceMap, syncTags} = await client.fetch(query, await params, {\n filterResponse: false,\n returnQuery: false,\n perspective,\n useCdn,\n stega,\n cacheMode,\n tag: requestTag,\n token: perspective === 'published' ? originalToken : serverToken || originalToken, // @TODO can pass undefined instead of config.token here?\n })\n const tags = [...customCacheTags, ...(syncTags || []).map((tag) => `${cacheTagPrefix}${tag}`)]\n /**\n * The tags used here, are expired later on in the `expireTags` Server Action with the `expireTag` function from `next/cache`\n */\n cacheTag(...tags)\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time based revalidation is too short,\n * userland can still set a shorter revalidate time by calling `cacheLife` themselves.\n */\n cacheLife({revalidate})\n\n return {data: result, sourceMap: resultSourceMap || null, tags}\n }\n\n const SanityLive: React.ComponentType<DefinedLiveProps> = function SanityLive(props) {\n if (strict) {\n validateStrictSanityLiveProps(props)\n }\n const {\n includeDrafts = false,\n action = actionUpdateTags,\n onReconnect = actionRefresh,\n onRestart = actionRefresh,\n\n onWelcome,\n onError,\n onGoAway,\n\n refreshOnMount = false,\n refreshOnFocus = false,\n refreshOnReconnect = false,\n requestTag = 'next-loader.live.cache-components',\n } = props\n\n const shouldIncludeDrafts = typeof browserToken === 'string' && includeDrafts\n\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n\n // Preconnect to the Live Event API origin early, as the Sanity API is almost always on a different origin than the app\n const {origin} = new URL(client.getUrl('', false))\n preconnect(origin)\n\n return (\n <SanityLiveClientComponent\n config={{\n projectId,\n dataset,\n apiHost,\n apiVersion,\n useProjectHostname,\n requestTagPrefix,\n token: shouldIncludeDrafts ? browserToken : undefined,\n }}\n includeDrafts={shouldIncludeDrafts}\n action={action}\n onReconnect={onReconnect}\n onRestart={onRestart}\n onWelcome={onWelcome}\n onError={onError}\n onGoAway={onGoAway}\n requestTag={requestTag}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n />\n )\n }\n SanityLive.displayName = 'SanityLiveServerComponent'\n\n return {\n sanityFetch: sanityFetch,\n SanityLive: SanityLive,\n }\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,WAAW,QAA2B;CACpD,MAAM,EAAC,QAAQ,SAAS,aAAa,cAAc,SAAS,UAAS;AAErE,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,oDAAoD;AAGtE,KAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,eAAe,gBAAgB,MAC3E,SAAQ,KACN,8LACD;AAGH,KAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,gBAAgB,iBAAiB,MAC7E,SAAQ,KACN,iXACD;CAGH,MAAM,SAAS,QAAQ,WAAW;EAAC,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AAQ;EAGjB,MAAM,EAAC,WAAU,IAAI,IAAI,OAAO,OAAO,IAAI,MAAM,CAAC;AAClD,aAAW,OAAO;AAElB,SACE,oBAACC,YAAAA;GACC,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA,OAAO,sBAAsB,eAAe,KAAA;IAC7C;GACD,eAAe;GACP;GACK;GACF;GACA;GACF;GACC;GACE;GACI;GACA;GACI;IACpB;;AAGN,cAAW,cAAc;AAEzB,QAAO;EACQ;EACb,YAAYD;EACb"}
1
+ {"version":3,"file":"index.js","names":["SanityLive","SanityLiveClientComponent"],"sources":["../../../../src/live/conditions/next-js/defineLive.tsx"],"sourcesContent":["import {SanityLive as SanityLiveClientComponent} from 'next-sanity/live/client-components'\nimport {actionRefresh, actionUpdateTags} from 'next-sanity/live/server-actions'\nimport {cacheLife, cacheTag} from 'next/cache'\nimport {PHASE_PRODUCTION_BUILD} from 'next/constants'\nimport {preconnect} from 'react-dom'\n\nimport {cacheTagPrefixes, revalidate} from '#live/constants'\nimport {validateStrictFetchOptions, validateStrictSanityLiveProps} from '#live/strictValidation'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions) {\n const {client: _client, serverToken, browserToken, strict = false} = config\n\n if (!_client) {\n throw new Error('`client` is required for `defineLive` to function')\n }\n\n if (process.env.NODE_ENV !== 'production' && !serverToken && serverToken !== false) {\n console.warn(\n 'No `serverToken` provided to `defineLive`. This means that only published content will be fetched and respond to live events. You can silence this warning by setting `serverToken: false`.',\n )\n }\n\n if (process.env.NODE_ENV !== 'production' && !browserToken && browserToken !== false) {\n console.warn(\n 'No `browserToken` provided to `defineLive`. This means that live previewing drafts will only work when using the Presentation Tool in your Sanity Studio. To support live previewing drafts stand-alone, provide a `browserToken`. It is shared with the browser so it should only have Viewer rights or lower. You can silence this warning by setting `browserToken: false`.',\n )\n }\n\n const client = _client.withConfig({allowReconfigure: false, useCdn: true})\n const {token: originalToken, perspective: originalPerspective = 'published'} = client.config()\n\n const sanityFetch: DefinedFetchType = async function sanityFetch({\n query,\n params = {},\n perspective: _perspective,\n stega: _stega,\n tags: customCacheTags = [],\n requestTag = 'next-loader.fetch.cache-components',\n }) {\n if (strict) {\n validateStrictFetchOptions({perspective: _perspective, stega: _stega})\n }\n const perspective = _perspective ?? originalPerspective\n const stega = _stega ?? false\n const useCdn = perspective === 'published'\n const isBuildPhase = process.env['NEXT_PHASE'] === PHASE_PRODUCTION_BUILD\n const cacheMode = useCdn && !isBuildPhase ? 'noStale' : undefined\n\n const cacheTagPrefix =\n perspective === 'published' ? cacheTagPrefixes.published : cacheTagPrefixes.drafts\n const {result, resultSourceMap, syncTags} = await client.fetch(query, await params, {\n filterResponse: false,\n returnQuery: false,\n perspective,\n useCdn,\n stega,\n cacheMode,\n tag: requestTag,\n token: perspective === 'published' ? originalToken : serverToken || originalToken, // @TODO can pass undefined instead of config.token here?\n })\n const tags = [...customCacheTags, ...(syncTags || []).map((tag) => `${cacheTagPrefix}${tag}`)]\n /**\n * The tags used here, are expired later on in the `expireTags` Server Action with the `expireTag` function from `next/cache`\n */\n cacheTag(...tags)\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time based revalidation is too short,\n * userland can still set a shorter revalidate time by calling `cacheLife` themselves.\n */\n cacheLife({revalidate})\n\n return {data: result, sourceMap: resultSourceMap || null, tags}\n }\n\n const SanityLive: React.ComponentType<DefinedLiveProps> = function SanityLive(props) {\n if (strict) {\n validateStrictSanityLiveProps(props)\n }\n const {\n includeDrafts = false,\n action = actionUpdateTags,\n onReconnect = actionRefresh,\n onRestart = actionRefresh,\n\n onWelcome,\n onError,\n onGoAway,\n\n refreshOnMount = false,\n refreshOnFocus = false,\n refreshOnReconnect = false,\n requestTag = 'next-loader.live.cache-components',\n } = props\n\n const shouldIncludeDrafts = typeof browserToken === 'string' && includeDrafts\n\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n\n // Preconnect to the Live Event API origin early, as the Sanity API is almost always on a different origin than the app\n const {origin} = new URL(client.getUrl('', false))\n preconnect(origin)\n\n return (\n <SanityLiveClientComponent\n config={{\n projectId,\n dataset,\n apiHost,\n apiVersion,\n useProjectHostname,\n requestTagPrefix,\n token: shouldIncludeDrafts ? browserToken : undefined,\n }}\n includeDrafts={shouldIncludeDrafts}\n action={action}\n onReconnect={onReconnect}\n onRestart={onRestart}\n onWelcome={onWelcome}\n onError={onError}\n onGoAway={onGoAway}\n requestTag={requestTag}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n />\n )\n }\n SanityLive.displayName = 'SanityLiveServerComponent'\n\n return {\n sanityFetch: sanityFetch,\n SanityLive: SanityLive,\n }\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,WAAW,QAA2B;CACpD,MAAM,EAAC,QAAQ,SAAS,aAAa,cAAc,SAAS,UAAS;AAErE,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,oDAAoD;AAGtE,KAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,eAAe,gBAAgB,MAC3E,SAAQ,KACN,8LACD;AAGH,KAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,gBAAgB,iBAAiB,MAC7E,SAAQ,KACN,iXACD;CAGH,MAAM,SAAS,QAAQ,WAAW;EAAC,kBAAkB;EAAO,QAAQ;EAAK,CAAC;CAC1E,MAAM,EAAC,OAAO,eAAe,aAAa,sBAAsB,gBAAe,OAAO,QAAQ;CAE9F,MAAM,cAAgC,eAAe,YAAY,EAC/D,OACA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A;IACA;IACA;IACA;IACA;IACA,OAAO,sBAAsB,eAAe,KAAA;IAC7C;GACD,eAAe;GACP;GACK;GACF;GACA;GACF;GACC;GACE;GACI;GACA;GACI;GACpB,CAAA;;AAGN,cAAW,cAAc;AAEzB,QAAO;EACQ;EACb,YAAYD;EACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["SanityLive","SanityLiveClientComponent"],"sources":["../../../../src/live/conditions/react-server/defineLive.tsx"],"sourcesContent":["import {type ClientPerspective, type QueryParams} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {SanityLive as SanityLiveClientComponent} from 'next-sanity/live/client-components'\nimport {actionRefresh, actionUpdateTags} from 'next-sanity/live/server-actions'\nimport {PHASE_PRODUCTION_BUILD} from 'next/constants'\nimport {cookies, draftMode} from 'next/headers'\nimport {preconnect} from 'react-dom'\n\nimport {cacheTagPrefixes} from '#live/constants'\nimport {sanitizePerspective} from '#live/sanitizePerspective'\nimport {validateStrictFetchOptions, validateStrictSanityLiveProps} from '#live/strictValidation'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions) {\n const {\n client: _client,\n serverToken,\n browserToken,\n stega: stegaEnabled = true,\n strict = false,\n } = config\n\n if (!_client) {\n throw new Error('`client` is required for `defineLive` to function')\n }\n\n if (process.env.NODE_ENV !== 'production' && !serverToken && serverToken !== false) {\n console.warn(\n 'No `serverToken` provided to `defineLive`. This means that only published content will be fetched and respond to live events. You can silence this warning by setting `serverToken: false`.',\n )\n }\n\n if (process.env.NODE_ENV !== 'production' && !browserToken && browserToken !== false) {\n console.warn(\n 'No `browserToken` provided to `defineLive`. This means that live previewing drafts will only work when using the Presentation Tool in your Sanity Studio. To support live previewing drafts stand-alone, provide a `browserToken`. It is shared with the browser so it should only have Viewer rights or lower. You can silence this warning by setting `browserToken: false`.',\n )\n }\n\n const client = _client.withConfig({allowReconfigure: false, useCdn: false})\n const {token: originalToken, perspective: originalPerspective = 'published'} = client.config()\n const studioUrlDefined = typeof client.config().stega.studioUrl !== 'undefined'\n\n const sanityFetch: DefinedFetchType = async function sanityFetch<\n const QueryString extends string,\n >({\n query,\n params = {},\n stega: _stega,\n tags = [],\n perspective: _perspective,\n tag,\n requestTag = tag ?? 'next-loader.fetch',\n }: {\n query: QueryString\n params?: QueryParams | Promise<QueryParams>\n stega?: boolean\n tags?: string[]\n perspective?: Exclude<ClientPerspective, 'raw'>\n tag?: string\n requestTag?: string\n }) {\n if (strict) {\n validateStrictFetchOptions({perspective: _perspective, stega: _stega})\n }\n const stega = strict\n ? _stega!\n : (_stega ?? (stegaEnabled && studioUrlDefined && (await draftMode()).isEnabled))\n const perspective = strict\n ? _perspective!\n : (_perspective ??\n (await resolveCookiePerspective(\n originalPerspective === 'raw' ? 'published' : originalPerspective,\n )))\n const useCdn = perspective === 'published'\n const isBuildPhase = process.env['NEXT_PHASE'] === PHASE_PRODUCTION_BUILD\n const cacheMode = useCdn && !isBuildPhase ? 'noStale' : undefined\n const revalidate = false\n const cacheTagPrefix =\n perspective === 'published' ? cacheTagPrefixes.published : cacheTagPrefixes.drafts\n\n // fetch the tags first, with revalidate to 1s to ensure we get the latest tags, eventually\n const {syncTags} = await client.fetch(query, await params, {\n filterResponse: false,\n perspective: perspective as ClientPerspective,\n stega: false,\n returnQuery: false,\n next: {\n revalidate,\n tags: [...tags, 'fetch-sync-tags'].map((tag) => `${cacheTagPrefix}${tag}`),\n },\n useCdn,\n cacheMode,\n tag: [requestTag, 'fetch-sync-tags'].filter(Boolean).join('.'),\n })\n\n const cacheTags = [...tags, ...(syncTags?.map((tag) => `${cacheTagPrefix}${tag}`) || [])]\n\n const {result, resultSourceMap} = await client.fetch(query, await params, {\n filterResponse: false,\n perspective: perspective as ClientPerspective,\n stega,\n token: perspective !== 'published' && serverToken ? serverToken : originalToken,\n next: {revalidate, tags: cacheTags},\n useCdn,\n cacheMode,\n tag: requestTag,\n })\n return {data: result, sourceMap: resultSourceMap || null, tags: cacheTags}\n }\n\n const SanityLive: React.ComponentType<DefinedLiveProps> = async function SanityLive(props) {\n if (strict) {\n validateStrictSanityLiveProps(props)\n }\n const {\n includeDrafts = (await draftMode()).isEnabled,\n action = actionUpdateTags,\n onReconnect = actionRefresh,\n onRestart = actionRefresh,\n\n onWelcome = false,\n onError = false,\n onGoAway = false,\n\n refreshOnMount,\n refreshOnFocus,\n refreshOnReconnect,\n requestTag = 'next-loader.live',\n } = props\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n const shouldIncludeDrafts = typeof browserToken === 'string' && includeDrafts\n\n // Preconnect to the Live Event API origin early, as the Sanity API is almost always on a different origin than the app\n const {origin} = new URL(client.getUrl('', false))\n preconnect(origin)\n\n return (\n <SanityLiveClientComponent\n config={{\n projectId,\n dataset,\n apiHost,\n apiVersion,\n useProjectHostname,\n requestTagPrefix,\n token: shouldIncludeDrafts ? browserToken : undefined,\n }}\n includeDrafts={shouldIncludeDrafts}\n action={action}\n onReconnect={onReconnect}\n onRestart={onRestart}\n onWelcome={onWelcome}\n onError={onError}\n onGoAway={onGoAway}\n requestTag={requestTag}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n />\n )\n }\n SanityLive.displayName = 'SanityLiveServerComponent'\n\n return {\n sanityFetch,\n SanityLive,\n }\n}\n\nasync function resolveCookiePerspective(\n fallback: Exclude<ClientPerspective, 'raw'>,\n): Promise<Exclude<ClientPerspective, 'raw'>> {\n return (await draftMode()).isEnabled\n ? (await cookies()).has(perspectiveCookieName)\n ? sanitizePerspective((await cookies()).get(perspectiveCookieName)?.value, 'drafts')\n : 'drafts'\n : fallback\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,WAAW,QAA2B;CACpD,MAAM,EACJ,QAAQ,SACR,aACA,cACA,OAAO,eAAe,MACtB,SAAS,UACP;AAEJ,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,oDAAoD;AAGtE,KAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,eAAe,gBAAgB,MAC3E,SAAQ,KACN,8LACD;AAGH,KAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,gBAAgB,iBAAiB,MAC7E,SAAQ,KACN,iXACD;CAGH,MAAM,SAAS,QAAQ,WAAW;EAAC,kBAAkB;EAAO,QAAQ;EAAM,CAAC;CAC3E,MAAM,EAAC,OAAO,eAAe,aAAa,sBAAsB,gBAAe,OAAO,QAAQ;CAC9F,MAAM,mBAAmB,OAAO,OAAO,QAAQ,CAAC,MAAM,cAAc;CAEpE,MAAM,cAAgC,eAAe,YAEnD,EACA,OACA,SAAS,EAAE,EACX,OAAO,QACP,OAAO,EAAE,EACT,aAAa,cACb,KACA,aAAa,OAAO,uBASnB;AACD,MAAI,OACF,4BAA2B;GAAC,aAAa;GAAc,OAAO;GAAO,CAAC;EAExE,MAAM,QAAQ,SACV,SACC,WAAW,gBAAgB,qBAAqB,MAAM,WAAW,EAAE;EACxE,MAAM,cAAc,SAChB,eACC,gBACA,MAAM,yBACL,wBAAwB,QAAQ,cAAc,oBAC/C;EACL,MAAM,SAAS,gBAAgB;EAC/B,MAAM,eAAe,QAAQ,IAAI,kBAAkB;EACnD,MAAM,YAAY,UAAU,CAAC,eAAe,YAAY,KAAA;EACxD,MAAM,aAAa;EACnB,MAAM,iBACJ,gBAAgB,cAAc,iBAAiB,YAAY,iBAAiB;EAG9E,MAAM,EAAC,aAAY,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ;GACzD,gBAAg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;AAGH,eAAe,yBACb,UAC4C;AAC5C,SAAQ,MAAM,WAAW,EAAE,aACtB,MAAM,SAAS,EAAE,IAAI,sBAAsB,GAC1C,qBAAqB,MAAM,SAAS,EAAE,IAAI,sBAAsB,EAAE,OAAO,SAAS,GAClF,WACF"}
1
+ {"version":3,"file":"index.js","names":["SanityLive","SanityLiveClientComponent"],"sources":["../../../../src/live/conditions/react-server/defineLive.tsx"],"sourcesContent":["import {type ClientPerspective, type QueryParams} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {SanityLive as SanityLiveClientComponent} from 'next-sanity/live/client-components'\nimport {actionRefresh, actionUpdateTags} from 'next-sanity/live/server-actions'\nimport {PHASE_PRODUCTION_BUILD} from 'next/constants'\nimport {cookies, draftMode} from 'next/headers'\nimport {preconnect} from 'react-dom'\n\nimport {cacheTagPrefixes} from '#live/constants'\nimport {sanitizePerspective} from '#live/sanitizePerspective'\nimport {validateStrictFetchOptions, validateStrictSanityLiveProps} from '#live/strictValidation'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(config: DefineLiveOptions) {\n const {\n client: _client,\n serverToken,\n browserToken,\n stega: stegaEnabled = true,\n strict = false,\n } = config\n\n if (!_client) {\n throw new Error('`client` is required for `defineLive` to function')\n }\n\n if (process.env.NODE_ENV !== 'production' && !serverToken && serverToken !== false) {\n console.warn(\n 'No `serverToken` provided to `defineLive`. This means that only published content will be fetched and respond to live events. You can silence this warning by setting `serverToken: false`.',\n )\n }\n\n if (process.env.NODE_ENV !== 'production' && !browserToken && browserToken !== false) {\n console.warn(\n 'No `browserToken` provided to `defineLive`. This means that live previewing drafts will only work when using the Presentation Tool in your Sanity Studio. To support live previewing drafts stand-alone, provide a `browserToken`. It is shared with the browser so it should only have Viewer rights or lower. You can silence this warning by setting `browserToken: false`.',\n )\n }\n\n const client = _client.withConfig({allowReconfigure: false, useCdn: false})\n const {token: originalToken, perspective: originalPerspective = 'published'} = client.config()\n const studioUrlDefined = typeof client.config().stega.studioUrl !== 'undefined'\n\n const sanityFetch: DefinedFetchType = async function sanityFetch<\n const QueryString extends string,\n >({\n query,\n params = {},\n stega: _stega,\n tags = [],\n perspective: _perspective,\n tag,\n requestTag = tag ?? 'next-loader.fetch',\n }: {\n query: QueryString\n params?: QueryParams | Promise<QueryParams>\n stega?: boolean\n tags?: string[]\n perspective?: Exclude<ClientPerspective, 'raw'>\n tag?: string\n requestTag?: string\n }) {\n if (strict) {\n validateStrictFetchOptions({perspective: _perspective, stega: _stega})\n }\n const stega = strict\n ? _stega!\n : (_stega ?? (stegaEnabled && studioUrlDefined && (await draftMode()).isEnabled))\n const perspective = strict\n ? _perspective!\n : (_perspective ??\n (await resolveCookiePerspective(\n originalPerspective === 'raw' ? 'published' : originalPerspective,\n )))\n const useCdn = perspective === 'published'\n const isBuildPhase = process.env['NEXT_PHASE'] === PHASE_PRODUCTION_BUILD\n const cacheMode = useCdn && !isBuildPhase ? 'noStale' : undefined\n const revalidate = false\n const cacheTagPrefix =\n perspective === 'published' ? cacheTagPrefixes.published : cacheTagPrefixes.drafts\n\n // fetch the tags first, with revalidate to 1s to ensure we get the latest tags, eventually\n const {syncTags} = await client.fetch(query, await params, {\n filterResponse: false,\n perspective: perspective as ClientPerspective,\n stega: false,\n returnQuery: false,\n next: {\n revalidate,\n tags: [...tags, 'fetch-sync-tags'].map((tag) => `${cacheTagPrefix}${tag}`),\n },\n useCdn,\n cacheMode,\n tag: [requestTag, 'fetch-sync-tags'].filter(Boolean).join('.'),\n })\n\n const cacheTags = [...tags, ...(syncTags?.map((tag) => `${cacheTagPrefix}${tag}`) || [])]\n\n const {result, resultSourceMap} = await client.fetch(query, await params, {\n filterResponse: false,\n perspective: perspective as ClientPerspective,\n stega,\n token: perspective !== 'published' && serverToken ? serverToken : originalToken,\n next: {revalidate, tags: cacheTags},\n useCdn,\n cacheMode,\n tag: requestTag,\n })\n return {data: result, sourceMap: resultSourceMap || null, tags: cacheTags}\n }\n\n const SanityLive: React.ComponentType<DefinedLiveProps> = async function SanityLive(props) {\n if (strict) {\n validateStrictSanityLiveProps(props)\n }\n const {\n includeDrafts = (await draftMode()).isEnabled,\n action = actionUpdateTags,\n onReconnect = actionRefresh,\n onRestart = actionRefresh,\n\n onWelcome = false,\n onError = false,\n onGoAway = false,\n\n refreshOnMount,\n refreshOnFocus,\n refreshOnReconnect,\n requestTag = 'next-loader.live',\n } = props\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n const shouldIncludeDrafts = typeof browserToken === 'string' && includeDrafts\n\n // Preconnect to the Live Event API origin early, as the Sanity API is almost always on a different origin than the app\n const {origin} = new URL(client.getUrl('', false))\n preconnect(origin)\n\n return (\n <SanityLiveClientComponent\n config={{\n projectId,\n dataset,\n apiHost,\n apiVersion,\n useProjectHostname,\n requestTagPrefix,\n token: shouldIncludeDrafts ? browserToken : undefined,\n }}\n includeDrafts={shouldIncludeDrafts}\n action={action}\n onReconnect={onReconnect}\n onRestart={onRestart}\n onWelcome={onWelcome}\n onError={onError}\n onGoAway={onGoAway}\n requestTag={requestTag}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n />\n )\n }\n SanityLive.displayName = 'SanityLiveServerComponent'\n\n return {\n sanityFetch,\n SanityLive,\n }\n}\n\nasync function resolveCookiePerspective(\n fallback: Exclude<ClientPerspective, 'raw'>,\n): Promise<Exclude<ClientPerspective, 'raw'>> {\n return (await draftMode()).isEnabled\n ? (await cookies()).has(perspectiveCookieName)\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AC4C;AAC5C,SAAQ,MAAM,WAAW,EAAE,aACtB,MAAM,SAAS,EAAE,IAAI,sBAAsB,GAC1C,qBAAqB,MAAM,SAAS,EAAE,IAAI,sBAAsB,EAAE,OAAO,SAAS,GAClF,WACF"}
@@ -2,6 +2,9 @@
2
2
  import { t as parseTags } from "../../parseTags.js";
3
3
  import { draftMode } from "next/headers";
4
4
  import { refresh, revalidateTag, updateTag } from "next/cache";
5
+ /**
6
+ * Used by `<SanityLive action={actionRevalidateTags} />`
7
+ */
5
8
  async function actionUpdateTags(unsafeTags) {
6
9
  const { tags, prefixType } = parseTags(unsafeTags);
7
10
  if ((await draftMode()).isEnabled) {
@@ -13,6 +16,9 @@ async function actionUpdateTags(unsafeTags) {
13
16
  revalidateTag("sanity:fetch-sync-tags", "max");
14
17
  console.log(`<SanityLive ${prefixType === "drafts" ? "includeDrafts " : ""}/> updated tags: ${tags.join(", ")} and revalidated tag: "sanity:fetch-sync-tags" with cache profile "max"`);
15
18
  }
19
+ /**
20
+ * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`
21
+ */
16
22
  async function actionRefresh() {
17
23
  refresh();
18
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.default.js","names":[],"sources":["../../../src/live/server-actions/index.default.ts"],"sourcesContent":["'use server'\n\nimport {refresh, revalidateTag, updateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * Used by `<SanityLive action={actionRevalidateTags} />`\n */\nexport async function actionUpdateTags(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n for (const tag of tags) {\n updateTag(tag)\n }\n revalidateTag('sanity:fetch-sync-tags', 'max')\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> updated tags: ${tags.join(', ')} and revalidated tag: \"sanity:fetch-sync-tags\" with cache profile \"max\"`,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`\n */\nexport async function actionRefresh(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;AAUA,eAAsB,iBAAiB,YAAoC;CACzE,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAEhB,eAAc,0BAA0B,MAAM;AAE9C,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,mBAAmB,KAAK,KAAK,KAAK,CAAC,yEACnG;;AAMH,eAAsB,gBAA+B;AACnD,UAAS"}
1
+ {"version":3,"file":"index.default.js","names":[],"sources":["../../../src/live/server-actions/index.default.ts"],"sourcesContent":["'use server'\n\nimport {refresh, revalidateTag, updateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * Used by `<SanityLive action={actionRevalidateTags} />`\n */\nexport async function actionUpdateTags(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n for (const tag of tags) {\n updateTag(tag)\n }\n revalidateTag('sanity:fetch-sync-tags', 'max')\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> updated tags: ${tags.join(', ')} and revalidated tag: \"sanity:fetch-sync-tags\" with cache profile \"max\"`,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`\n */\nexport async function actionRefresh(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,iBAAiB,YAAoC;CACzE,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAEhB,eAAc,0BAA0B,MAAM;AAE9C,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,mBAAmB,KAAK,KAAK,KAAK,CAAC,yEACnG;;;;;AAMH,eAAsB,gBAA+B;AACnD,UAAS"}
@@ -2,6 +2,9 @@
2
2
  import { t as parseTags } from "../../parseTags.js";
3
3
  import { draftMode } from "next/headers";
4
4
  import { refresh, updateTag } from "next/cache";
5
+ /**
6
+ * Used by `<SanityLive action={actionRevalidateTags} />`
7
+ */
5
8
  async function actionUpdateTags(unsafeTags) {
6
9
  const { tags, prefixType } = parseTags(unsafeTags);
7
10
  if ((await draftMode()).isEnabled) {
@@ -12,6 +15,9 @@ async function actionUpdateTags(unsafeTags) {
12
15
  for (const tag of tags) updateTag(tag);
13
16
  console.log(`<SanityLive ${prefixType === "drafts" ? "includeDrafts " : ""}/> updated tags: ${tags.join(", ")}`);
14
17
  }
18
+ /**
19
+ * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`
20
+ */
15
21
  async function actionRefresh() {
16
22
  refresh();
17
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.next-js.js","names":[],"sources":["../../../src/live/server-actions/index.next-js.ts"],"sourcesContent":["'use server'\n\nimport {refresh, updateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * Used by `<SanityLive action={actionRevalidateTags} />`\n */\nexport async function actionUpdateTags(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n for (const tag of tags) {\n updateTag(tag)\n }\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> updated tags: ${tags.join(', ')}`,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`\n */\nexport async function actionRefresh(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;AAUA,eAAsB,iBAAiB,YAAoC;CACzE,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAGhB,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,mBAAmB,KAAK,KAAK,KAAK,GAClG;;AAMH,eAAsB,gBAA+B;AACnD,UAAS"}
1
+ {"version":3,"file":"index.next-js.js","names":[],"sources":["../../../src/live/server-actions/index.next-js.ts"],"sourcesContent":["'use server'\n\nimport {refresh, updateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * Used by `<SanityLive action={actionRevalidateTags} />`\n */\nexport async function actionUpdateTags(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n for (const tag of tags) {\n updateTag(tag)\n }\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> updated tags: ${tags.join(', ')}`,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`\n */\nexport async function actionRefresh(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,iBAAiB,YAAoC;CACzE,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAGhB,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,mBAAmB,KAAK,KAAK,KAAK,GAClG;;;;;AAMH,eAAsB,gBAA+B;AACnD,UAAS"}
package/dist/parseTags.js CHANGED
@@ -1,4 +1,25 @@
1
1
  import { t as cacheTagPrefixes } from "./constants.js";
2
+ /**
3
+ * Prefixes live event tags according to the conventions used by `defineLive().sanityFetch()`
4
+ * so that they can be used with `import {updateTag} from 'next/cache'`.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import {updateTag} from 'next/cache'
9
+ * import {parseTags} from 'next-sanity/live'
10
+ * import {SanityLive} from '#sanity/live
11
+ *
12
+ * <SanityLive
13
+ * action={async (event, context) => {
14
+ * 'use server'
15
+ *
16
+ * for (const tag of parseTags(event.tags, context)) {
17
+ * updateTag(tag)
18
+ * }
19
+ * }}
20
+ * />
21
+ * ```
22
+ */
2
23
  function parseTags(unsafeTags) {
3
24
  if (!Array.isArray(unsafeTags)) throw new TypeError("tags must be an array", { cause: { unsafeTags } });
4
25
  if (unsafeTags.length === 0) throw new TypeError("tags must be an non-empty array", { cause: { unsafeTags } });
@@ -1 +1 @@
1
- {"version":3,"file":"parseTags.js","names":[],"sources":["../src/live/shared/parseTags.ts"],"sourcesContent":["import type {SyncTag} from '@sanity/client'\n\nimport {cacheTagPrefixes} from './constants'\n\ninterface ParsedPublishedTags {\n tags: `${typeof cacheTagPrefixes.published}${SyncTag}`[]\n prefix: typeof cacheTagPrefixes.published\n prefixType: 'published'\n}\ninterface ParsedDraftTags {\n tags: `${typeof cacheTagPrefixes.drafts}${SyncTag}`[]\n prefix: typeof cacheTagPrefixes.drafts\n prefixType: 'drafts'\n}\ntype ParsedTags = ParsedPublishedTags | ParsedDraftTags\n\n/**\n * Prefixes live event tags according to the conventions used by `defineLive().sanityFetch()`\n * so that they can be used with `import {updateTag} from 'next/cache'`.\n *\n * @example\n * ```tsx\n * import {updateTag} from 'next/cache'\n * import {parseTags} from 'next-sanity/live'\n * import {SanityLive} from '#sanity/live\n *\n * <SanityLive\n * action={async (event, context) => {\n * 'use server'\n *\n * for (const tag of parseTags(event.tags, context)) {\n * updateTag(tag)\n * }\n * }}\n * />\n * ```\n */\nexport function parseTags(unsafeTags: unknown): ParsedTags {\n if (!Array.isArray(unsafeTags)) {\n throw new TypeError('tags must be an array', {cause: {unsafeTags}})\n }\n if (unsafeTags.length === 0) {\n throw new TypeError('tags must be an non-empty array', {cause: {unsafeTags}})\n }\n if (unsafeTags.some((tag) => typeof tag !== 'string')) {\n throw new TypeError('tags must be an array of strings', {cause: {unsafeTags}})\n }\n if (unsafeTags.some((tag) => tag.startsWith(cacheTagPrefixes.published))) {\n const prefixType = 'published'\n const tags: ParsedPublishedTags['tags'] = []\n // oxlint-disable-next-line no-unsafe-type-assertion\n for (const tag of unsafeTags as string[]) {\n if (tag.startsWith(cacheTagPrefixes.drafts)) {\n throw new TypeError('cannot mix published and drafts tags', {cause: {tag, unsafeTags}})\n }\n if (!tag.startsWith(cacheTagPrefixes.published)) {\n throw new TypeError('tag must start with a valid prefix', {cause: {tag}})\n }\n // oxlint-disable-next-line no-unsafe-type-assertion\n tags.push(tag as `${typeof cacheTagPrefixes.published}${SyncTag}`)\n }\n return {tags, prefix: cacheTagPrefixes.published, prefixType}\n } else if (unsafeTags.some((tag) => tag.startsWith(cacheTagPrefixes.drafts))) {\n const prefixType = 'drafts'\n const tags: ParsedDraftTags['tags'] = []\n // oxlint-disable-next-line no-unsafe-type-assertion\n for (const tag of unsafeTags as string[]) {\n if (tag.startsWith(cacheTagPrefixes.published)) {\n throw new TypeError('cannot mix published and drafts tags', {cause: {tag, unsafeTags}})\n }\n if (!tag.startsWith(cacheTagPrefixes.drafts)) {\n throw new TypeError('tag must start with a valid prefix', {cause: {tag}})\n }\n // oxlint-disable-next-line no-unsafe-type-assertion\n tags.push(tag as `${typeof cacheTagPrefixes.drafts}${SyncTag}`)\n }\n return {tags, prefix: cacheTagPrefixes.drafts, prefixType}\n }\n\n throw new Error('Failed to parse tags, no valid prefix found', {cause: {unsafeTags}})\n}\n"],"mappings":";AAqCA,SAAgB,UAAU,YAAiC;AACzD,KAAI,CAAC,MAAM,QAAQ,WAAW,CAC5B,OAAM,IAAI,UAAU,yBAAyB,EAAC,OAAO,EAAC,YAAW,EAAC,CAAC;AAErE,KAAI,WAAW,WAAW,EACxB,OAAM,IAAI,UAAU,mCAAmC,EAAC,OAAO,EAAC,YAAW,EAAC,CAAC;AAE/E,KAAI,WAAW,MAAM,QAAQ,OAAO,QAAQ,SAAS,CACnD,OAAM,IAAI,UAAU,oCAAoC,EAAC,OAAO,EAAC,YAAW,EAAC,CAAC;AAEhF,KAAI,WAAW,MAAM,QAAQ,IAAI,WAAW,iBAAiB,UAAU,CAAC,EAAE;EACxE,MAAM,aAAa;EACnB,MAAM,OAAoC,EAAE;AAE5C,OAAK,MAAM,OAAO,YAAwB;AACxC,OAAI,IAAI,WAAW,iBAAiB,OAAO,CACzC,OAAM,IAAI,UAAU,wCAAwC,EAAC,OAAO;IAAC;IAAK;IAAW,EAAC,CAAC;AAEzF,OAAI,CAAC,IAAI,WAAW,iBAAiB,UAAU,CAC7C,OAAM,IAAI,UAAU,sCAAsC,EAAC,OAAO,EAAC,KAAI,EAAC,CAAC;AAG3E,QAAK,KAAK,IAAwD;;AAEpE,SAAO;GAAC;GAAM,QAAQ,iBAAiB;GAAW;GAAW;YACpD,WAAW,MAAM,QAAQ,IAAI,WAAW,iBAAiB,OAAO,CAAC,EAAE;EAC5E,MAAM,aAAa;EACnB,MAAM,OAAgC,EAAE;AAExC,OAAK,MAAM,OAAO,YAAwB;AACxC,OAAI,IAAI,WAAW,iBAAiB,UAAU,CAC5C,OAAM,IAAI,UAAU,wCAAwC,EAAC,OAAO;IAAC;IAAK;IAAW,EAAC,CAAC;AAEzF,OAAI,CAAC,IAAI,WAAW,iBAAiB,OAAO,CAC1C,OAAM,IAAI,UAAU,sCAAsC,EAAC,OAAO,EAAC,KAAI,EAAC,CAAC;AAG3E,QAAK,KAAK,IAAqD;;AAEjE,SAAO;GAAC;GAAM,QAAQ,iBAAiB;GAAQ;GAAW;;AAG5D,OAAM,IAAI,MAAM,+CAA+C,EAAC,OAAO,EAAC,YAAW,EAAC,CAAC"}
1
+ {"version":3,"file":"parseTags.js","names":[],"sources":["../src/live/shared/parseTags.ts"],"sourcesContent":["import type {SyncTag} from '@sanity/client'\n\nimport {cacheTagPrefixes} from './constants'\n\ninterface ParsedPublishedTags {\n tags: `${typeof cacheTagPrefixes.published}${SyncTag}`[]\n prefix: typeof cacheTagPrefixes.published\n prefixType: 'published'\n}\ninterface ParsedDraftTags {\n tags: `${typeof cacheTagPrefixes.drafts}${SyncTag}`[]\n prefix: typeof cacheTagPrefixes.drafts\n prefixType: 'drafts'\n}\ntype ParsedTags = ParsedPublishedTags | ParsedDraftTags\n\n/**\n * Prefixes live event tags according to the conventions used by `defineLive().sanityFetch()`\n * so that they can be used with `import {updateTag} from 'next/cache'`.\n *\n * @example\n * ```tsx\n * import {updateTag} from 'next/cache'\n * import {parseTags} from 'next-sanity/live'\n * import {SanityLive} from '#sanity/live\n *\n * <SanityLive\n * action={async (event, context) => {\n * 'use server'\n *\n * for (const tag of parseTags(event.tags, context)) {\n * updateTag(tag)\n * }\n * }}\n * />\n * ```\n */\nexport function parseTags(unsafeTags: unknown): ParsedTags {\n if (!Array.isArray(unsafeTags)) {\n throw new TypeError('tags must be an array', {cause: {unsafeTags}})\n }\n if (unsafeTags.length === 0) {\n throw new TypeError('tags must be an non-empty array', {cause: {unsafeTags}})\n }\n if (unsafeTags.some((tag) => typeof tag !== 'string')) {\n throw new TypeError('tags must be an array of strings', {cause: {unsafeTags}})\n }\n if (unsafeTags.some((tag) => tag.startsWith(cacheTagPrefixes.published))) {\n const prefixType = 'published'\n const tags: ParsedPublishedTags['tags'] = []\n // oxlint-disable-next-line no-unsafe-type-assertion\n for (const tag of unsafeTags as string[]) {\n if (tag.startsWith(cacheTagPrefixes.drafts)) {\n throw new TypeError('cannot mix published and drafts tags', {cause: {tag, unsafeTags}})\n }\n if (!tag.startsWith(cacheTagPrefixes.published)) {\n throw new TypeError('tag must start with a valid prefix', {cause: {tag}})\n }\n // oxlint-disable-next-line no-unsafe-type-assertion\n tags.push(tag as `${typeof cacheTagPrefixes.published}${SyncTag}`)\n }\n return {tags, prefix: cacheTagPrefixes.published, prefixType}\n } else if (unsafeTags.some((tag) => tag.startsWith(cacheTagPrefixes.drafts))) {\n const prefixType = 'drafts'\n const tags: ParsedDraftTags['tags'] = []\n // oxlint-disable-next-line no-unsafe-type-assertion\n for (const tag of unsafeTags as string[]) {\n if (tag.startsWith(cacheTagPrefixes.published)) {\n throw new TypeError('cannot mix published and drafts tags', {cause: {tag, unsafeTags}})\n }\n if (!tag.startsWith(cacheTagPrefixes.drafts)) {\n throw new TypeError('tag must start with a valid prefix', {cause: {tag}})\n }\n // oxlint-disable-next-line no-unsafe-type-assertion\n tags.push(tag as `${typeof cacheTagPrefixes.drafts}${SyncTag}`)\n }\n return {tags, prefix: cacheTagPrefixes.drafts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AsC,EAAC,OAAO,EAAC,KAAI,EAAC,CAAC;AAG3E,QAAK,KAAK,IAAqD;;AAEjE,SAAO;GAAC;GAAM,QAAQ,iBAAiB;GAAQ;GAAW;;AAG5D,OAAM,IAAI,MAAM,+CAA+C,EAAC,OAAO,EAAC,YAAW,EAAC,CAAC"}
@@ -8,6 +8,10 @@ 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
+ /**
12
+ * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from "next-sanity/draft-mode"`
13
+ * @public
14
+ */
11
15
  const resolvePerspectiveFromCookies = async function resolvePerspectiveFromCookies({ cookies: jar }) {
12
16
  return jar.has(perspectiveCookieName) ? sanitizePerspective(jar.get(perspectiveCookieName)?.value, "drafts") : "drafts";
13
17
  };
@@ -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 './sanitizePerspective'\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 * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from \"next-sanity/draft-mode\"`\n * @public\n */\nexport const resolvePerspectiveFromCookies = 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;;ACDL,MAAa,gCAAgC,eAAe,8BAA8B,EACxF,SAAS,OAGoC;AAC7C,QAAO,IAAI,IAAI,sBAAsB,GACjC,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,OAAO,SAAS,GACpE"}
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 './sanitizePerspective'\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 * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from \"next-sanity/draft-mode\"`\n * @public\n */\nexport const resolvePerspectiveFromCookies = 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;;;;;;ACDL,MAAa,gCAAgC,eAAe,8BAA8B,EACxF,SAAS,OAGoC;AAC7C,QAAO,IAAI,IAAI,sBAAsB,GACjC,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,OAAO,SAAS,GACpE"}
@@ -1,6 +1,13 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { Suspense, lazy } from "react";
4
+ /**
5
+ *
6
+ * If pages router supported `next/dynamic` imports (it wants `next/dynamic.js`),
7
+ * or if turbopack in app router allowed `next/dynamic.js` (it doesn't yet)
8
+ * we could use `dynamic(() => import('...), {ssr: false})` here.
9
+ * Since we can't, we need to use a lazy import and Suspense ourself.
10
+ */
4
11
  const NextStudioClientComponent = lazy(() => import("../../NextStudio.js"));
5
12
  function NextStudioLazyClientComponent(props) {
6
13
  return /* @__PURE__ */ jsx(Suspense, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/studio/client-component/NextStudioLazy.tsx"],"sourcesContent":["/**\n *\n * If pages router supported `next/dynamic` imports (it wants `next/dynamic.js`),\n * or if turbopack in app router allowed `next/dynamic.js` (it doesn't yet)\n * we could use `dynamic(() => import('...), {ssr: false})` here.\n * Since we can't, we need to use a lazy import and Suspense ourself.\n */\n\nimport {lazy, Suspense} from 'react'\n\nimport type {NextStudioProps} from './NextStudio'\n\nconst NextStudioClientComponent = lazy(() => import('./NextStudio'))\n\nexport function NextStudioLazyClientComponent(props: NextStudioProps): React.ReactNode {\n return (\n <Suspense fallback={null}>\n <NextStudioClientComponent {...props} />\n </Suspense>\n )\n}\n"],"mappings":";;;AAYA,MAAM,4BAA4B,WAAW,OAAO,uBAAgB;AAEpE,SAAgB,8BAA8B,OAAyC;AACrF,QACE,oBAAC,UAAA;EAAS,UAAU;YAClB,oBAAC,2BAAA,EAA0B,GAAI,OAAA,CAAS;GAC/B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/studio/client-component/NextStudioLazy.tsx"],"sourcesContent":["/**\n *\n * If pages router supported `next/dynamic` imports (it wants `next/dynamic.js`),\n * or if turbopack in app router allowed `next/dynamic.js` (it doesn't yet)\n * we could use `dynamic(() => import('...), {ssr: false})` here.\n * Since we can't, we need to use a lazy import and Suspense ourself.\n */\n\nimport {lazy, Suspense} from 'react'\n\nimport type {NextStudioProps} from './NextStudio'\n\nconst NextStudioClientComponent = lazy(() => import('./NextStudio'))\n\nexport function NextStudioLazyClientComponent(props: NextStudioProps): React.ReactNode {\n return (\n <Suspense fallback={null}>\n <NextStudioClientComponent {...props} />\n </Suspense>\n )\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAM,4BAA4B,WAAW,OAAO,uBAAgB;AAEpE,SAAgB,8BAA8B,OAAyC;AACrF,QACE,oBAAC,UAAD;EAAU,UAAU;YAClB,oBAAC,2BAAD,EAA2B,GAAI,OAAS,CAAA;EAC/B,CAAA"}
@@ -2,15 +2,55 @@ import { n as NextStudioLayout, t as NextStudioNoScript } from "../NextStudioNoS
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { preloadModule } from "react-dom";
4
4
  import { NextStudio } from "next-sanity/studio/client-component";
5
+ /**
6
+ * In router segments (`/app/studio/[[...index]]/page.tsx`):
7
+ * ```tsx
8
+ * // If you don't want to change any defaults you can just re-export the viewport config directly:
9
+ * export {viewport} from 'next-sanity/studio'
10
+ *
11
+ * // To customize the viewport config, spread it on the export:
12
+ * import {viewport as studioViewport} from 'next-sanity/studio'
13
+ * import type { Viewport } from 'next'
14
+ *
15
+ * export const viewport: Viewport = {
16
+ * ...studioViewport,
17
+ * // Overrides the viewport to resize behavior
18
+ * interactiveWidget: 'resizes-content'
19
+ * })
20
+ * ```
21
+ * @public
22
+ */
5
23
  const viewport = {
6
24
  width: "device-width",
7
25
  initialScale: 1,
8
26
  viewportFit: "cover"
9
27
  };
28
+ /**
29
+ * In router segments (`/app/studio/[[...index]]/page.tsx`):
30
+ * ```tsx
31
+ * // If you don't want to change any defaults you can just re-export the metadata directly:
32
+ * export {metadata} from 'next-sanity/studio'
33
+ *
34
+ * // To customize the metadata, spread it on the export:
35
+ * import {metadata as studioMetadata} from 'next-sanity/studio'
36
+ * import type { Metadata } from 'next'
37
+ *
38
+ * export const metadata: Metadata = {
39
+ * ...studioMetadata,
40
+ * // Set another title
41
+ * title: 'My Studio',
42
+ * })
43
+ * ```
44
+ * @public
45
+ */
10
46
  const metadata = {
11
47
  referrer: "same-origin",
12
48
  robots: "noindex"
13
49
  };
50
+ /**
51
+ * Loads the bridge script the same way Sanity Studio does:
52
+ * https://github.com/sanity-io/sanity/blob/bd5b1acb5015baaddd8d96c2abd1eaf579b3c904/packages/sanity/src/_internal/cli/server/renderDocument.tsx#L124-L139
53
+ */
14
54
  const bridgeScript = "https://core.sanity-cdn.com/bridge.js";
15
55
  function NextStudioWithBridge(props) {
16
56
  preloadModule(bridgeScript, { as: "script" });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/studio/head.tsx","../../src/studio/NextStudioWithBridge.tsx"],"sourcesContent":["import type {Metadata, Viewport} from 'next'\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the viewport config directly:\n * export {viewport} from 'next-sanity/studio'\n *\n * // To customize the viewport config, spread it on the export:\n * import {viewport as studioViewport} from 'next-sanity/studio'\n * import type { Viewport } from 'next'\n *\n * export const viewport: Viewport = {\n * ...studioViewport,\n * // Overrides the viewport to resize behavior\n * interactiveWidget: 'resizes-content'\n * })\n * ```\n * @public\n */\nexport const viewport = {\n width: 'device-width' as const,\n initialScale: 1 as const,\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewportFit: 'cover',\n} satisfies Viewport\n\n/**\n * In router segments (`/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 * // Set another title\n * title: 'My Studio',\n * })\n * ```\n * @public\n */\nexport const metadata = {\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n","import {NextStudio, type NextStudioProps} from 'next-sanity/studio/client-component'\nimport {preloadModule} from 'react-dom'\n\n/**\n * Loads the bridge script the same way Sanity Studio does:\n * https://github.com/sanity-io/sanity/blob/bd5b1acb5015baaddd8d96c2abd1eaf579b3c904/packages/sanity/src/_internal/cli/server/renderDocument.tsx#L124-L139\n */\n\nconst bridgeScript = 'https://core.sanity-cdn.com/bridge.js'\n\nexport function NextStudioWithBridge(props: NextStudioProps): React.JSX.Element {\n preloadModule(bridgeScript, {as: 'script'})\n\n return (\n <>\n <script src={bridgeScript} async type=\"module\" data-sanity-core />\n <NextStudio {...props} />\n </>\n )\n}\n"],"mappings":";;;;AAoBA,MAAa,WAAW;CACtB,OAAO;CACP,cAAc;CAEd,aAAa;CACd;AAoBD,MAAa,WAAW;CACtB,UAAU;CACV,QAAQ;CACT;ACxCD,MAAM,eAAe;AAErB,SAAgB,qBAAqB,OAA2C;AAC9E,eAAc,cAAc,EAAC,IAAI,UAAS,CAAC;AAE3C,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,UAAA;EAAO,KAAK;EAAc,OAAA;EAAM,MAAK;EAAS,oBAAA;GAAmB,EAClE,oBAAC,YAAA,EAAW,GAAI,OAAA,CAAS,CAAA,EAAA,CACxB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/studio/head.tsx","../../src/studio/NextStudioWithBridge.tsx"],"sourcesContent":["import type {Metadata, Viewport} from 'next'\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the viewport config directly:\n * export {viewport} from 'next-sanity/studio'\n *\n * // To customize the viewport config, spread it on the export:\n * import {viewport as studioViewport} from 'next-sanity/studio'\n * import type { Viewport } from 'next'\n *\n * export const viewport: Viewport = {\n * ...studioViewport,\n * // Overrides the viewport to resize behavior\n * interactiveWidget: 'resizes-content'\n * })\n * ```\n * @public\n */\nexport const viewport = {\n width: 'device-width' as const,\n initialScale: 1 as const,\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewportFit: 'cover',\n} satisfies Viewport\n\n/**\n * In router segments (`/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 * // Set another title\n * title: 'My Studio',\n * })\n * ```\n * @public\n */\nexport const metadata = {\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n","import {NextStudio, type NextStudioProps} from 'next-sanity/studio/client-component'\nimport {preloadModule} from 'react-dom'\n\n/**\n * Loads the bridge script the same way Sanity Studio does:\n * https://github.com/sanity-io/sanity/blob/bd5b1acb5015baaddd8d96c2abd1eaf579b3c904/packages/sanity/src/_internal/cli/server/renderDocument.tsx#L124-L139\n */\n\nconst bridgeScript = 'https://core.sanity-cdn.com/bridge.js'\n\nexport function NextStudioWithBridge(props: NextStudioProps): React.JSX.Element {\n preloadModule(bridgeScript, {as: 'script'})\n\n return (\n <>\n <script src={bridgeScript} async type=\"module\" data-sanity-core />\n <NextStudio {...props} />\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,WAAW;CACtB,OAAO;CACP,cAAc;CAEd,aAAa;CACd;;;;;;;;;;;;;;;;;;;AAoBD,MAAa,WAAW;CACtB,UAAU;CACV,QAAQ;CACT;;;;;ACxCD,MAAM,eAAe;AAErB,SAAgB,qBAAqB,OAA2C;AAC9E,eAAc,cAAc,EAAC,IAAI,UAAS,CAAC;AAE3C,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,UAAD;EAAQ,KAAK;EAAc,OAAA;EAAM,MAAK;EAAS,oBAAA;EAAmB,CAAA,EAClE,oBAAC,YAAD,EAAY,GAAI,OAAS,CAAA,CACxB,EAAA,CAAA"}
package/dist/types.d.ts CHANGED
@@ -45,7 +45,7 @@ interface SanityLiveActionContext {
45
45
  * TODO: docs
46
46
  * Has a default implementation tailed the nextjs env and config
47
47
  */
48
- type SanityLiveAction = (unsafeTags: unknown) => Promise<void>;
48
+ type SanityLiveAction = (unsafeTags: unknown) => Promise<void | "refresh">;
49
49
  /**
50
50
  * TODO: docs
51
51
  * If not defined it'll throw the error during render instead, which will crash the react app
@@ -1,6 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { VisualEditing as VisualEditing$1 } from "next-sanity/visual-editing/client-component";
3
3
  import { actionPerspectiveChange } from "next-sanity/visual-editing/server-actions";
4
+ /**
5
+ * @public
6
+ */
4
7
  function VisualEditing(props) {
5
8
  let autoBasePath;
6
9
  if (typeof props.basePath !== "string") try {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["VisualEditingComponent"],"sources":["../../src/visual-editing/VisualEditing.tsx"],"sourcesContent":["import type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\nimport {VisualEditing as VisualEditingComponent} from 'next-sanity/visual-editing/client-component'\nimport {actionPerspectiveChange} from 'next-sanity/visual-editing/server-actions'\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // oxlint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // oxlint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n onPerspectiveChange={actionPerspectiveChange}\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"mappings":";;;AAOA,SAAgB,cAAc,OAA+C;CAC3E,IAAI;AACJ,KAAI,OAAO,MAAM,aAAa,SAC5B,KAAI;AACF,iBAAe,QAAQ,IAAI;AAC3B,MAAI,aAEF,SAAQ,IACN,6BAA6B,KAAK,UAAU,aAAa,CAAC,gKAC3D;UAEI,KAAK;AACZ,UAAQ,MAAM,6BAA6B,IAAI;;CAGnD,IAAI;AACJ,KAAI,OAAO,MAAM,kBAAkB,UACjC,KAAI;AACF,sBAAoB,QAAQ,QAAQ,IAAI,yBAAyB;AACjE,MAAI,kBAEF,SAAQ,IACN,kCAAkC,KAAK,UAAU,kBAAkB,CAAC,oKACrE;UAEI,KAAK;AACZ,UAAQ,MAAM,kCAAkC,IAAI;;AAGxD,QACE,oBAACA,iBAAAA;EACC,qBAAqB;EACrB,GAAI;EACJ,UAAU,MAAM,YAAY;EAC5B,eAAe,MAAM,iBAAiB;GACtC"}
1
+ {"version":3,"file":"index.js","names":["VisualEditingComponent"],"sources":["../../src/visual-editing/VisualEditing.tsx"],"sourcesContent":["import type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\nimport {VisualEditing as VisualEditingComponent} from 'next-sanity/visual-editing/client-component'\nimport {actionPerspectiveChange} from 'next-sanity/visual-editing/server-actions'\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // oxlint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // oxlint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n onPerspectiveChange={actionPerspectiveChange}\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"mappings":";;;;;;AAOA,SAAgB,cAAc,OAA+C;CAC3E,IAAI;AACJ,KAAI,OAAO,MAAM,aAAa,SAC5B,KAAI;AACF,iBAAe,QAAQ,IAAI;AAC3B,MAAI,aAEF,SAAQ,IACN,6BAA6B,KAAK,UAAU,aAAa,CAAC,gKAC3D;UAEI,KAAK;AACZ,UAAQ,MAAM,6BAA6B,IAAI;;CAGnD,IAAI;AACJ,KAAI,OAAO,MAAM,kBAAkB,UACjC,KAAI;AACF,sBAAoB,QAAQ,QAAQ,IAAI,yBAAyB;AACjE,MAAI,kBAEF,SAAQ,IACN,kCAAkC,KAAK,UAAU,kBAAkB,CAAC,oKACrE;UAEI,KAAK;AACZ,UAAQ,MAAM,kCAAkC,IAAI;;AAGxD,QACE,oBAACA,iBAAD;EACE,qBAAqB;EACrB,GAAI;EACJ,UAAU,MAAM,YAAY;EAC5B,eAAe,MAAM,iBAAiB;EACtC,CAAA"}
@@ -3,9 +3,15 @@ import { t as sanitizePerspective } from "../../sanitizePerspective.js";
3
3
  import { perspectiveCookieName } from "@sanity/preview-url-secret/constants";
4
4
  import { cookies } from "next/headers";
5
5
  import { refresh } from "next/cache";
6
+ /**
7
+ * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.
8
+ */
6
9
  async function actionRefresh(_payload) {
7
10
  refresh();
8
11
  }
12
+ /**
13
+ * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.
14
+ */
9
15
  async function actionPerspectiveChange(perspective) {
10
16
  const sanitizedPerspective = sanitizePerspective(perspective, "drafts");
11
17
  if (!sanitizedPerspective || Array.isArray(sanitizedPerspective) && sanitizedPerspective.length === 0) throw new Error(`Invalid perspective`, { cause: perspective });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/visual-editing/server-actions/index.ts"],"sourcesContent":["'use server'\n\nimport type {ClientPerspective} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport type {HistoryRefresh} from '@sanity/visual-editing/react'\nimport {refresh} from 'next/cache'\nimport {cookies} from 'next/headers'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\n\n/**\n * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function actionRefresh(_payload: HistoryRefresh): Promise<void> {\n refresh()\n}\n\n/**\n * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function actionPerspectiveChange(perspective: ClientPerspective): Promise<void> {\n const sanitizedPerspective = sanitizePerspective(perspective, 'drafts')\n if (\n !sanitizedPerspective ||\n (Array.isArray(sanitizedPerspective) && sanitizedPerspective.length === 0)\n ) {\n throw new Error(`Invalid perspective`, {cause: perspective})\n }\n\n const nextPerspective = Array.isArray(sanitizedPerspective)\n ? sanitizedPerspective.join(',')\n : sanitizedPerspective\n const jar = await cookies()\n if (\n nextPerspective === jar.get(perspectiveCookieName)?.value &&\n process.env.NODE_ENV !== 'production'\n ) {\n // oxlint-disable-next-line no-console\n console.debug('actionPerspectiveChange', 'Perspective is the same, skipping', nextPerspective)\n return\n }\n jar.set(perspectiveCookieName, nextPerspective, {\n httpOnly: true,\n path: '/',\n secure: true,\n sameSite: 'none',\n })\n\n refresh()\n}\n"],"mappings":";;;;;AAaA,eAAsB,cAAc,UAAyC;AAC3E,UAAS;;AAMX,eAAsB,wBAAwB,aAA+C;CAC3F,MAAM,uBAAuB,oBAAoB,aAAa,SAAS;AACvE,KACE,CAAC,wBACA,MAAM,QAAQ,qBAAqB,IAAI,qBAAqB,WAAW,EAExE,OAAM,IAAI,MAAM,uBAAuB,EAAC,OAAO,aAAY,CAAC;CAG9D,MAAM,kBAAkB,MAAM,QAAQ,qBAAqB,GACvD,qBAAqB,KAAK,IAAI,GAC9B;CACJ,MAAM,MAAM,MAAM,SAAS;AAC3B,KACE,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,SACpD,QAAQ,IAAI,aAAa,cACzB;AAEA,UAAQ,MAAM,2BAA2B,qCAAqC,gBAAgB;AAC9F;;AAEF,KAAI,IAAI,uBAAuB,iBAAiB;EAC9C,UAAU;EACV,MAAM;EACN,QAAQ;EACR,UAAU;EACX,CAAC;AAEF,UAAS"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/visual-editing/server-actions/index.ts"],"sourcesContent":["'use server'\n\nimport type {ClientPerspective} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport type {HistoryRefresh} from '@sanity/visual-editing/react'\nimport {refresh} from 'next/cache'\nimport {cookies} from 'next/headers'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\n\n/**\n * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function actionRefresh(_payload: HistoryRefresh): Promise<void> {\n refresh()\n}\n\n/**\n * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function actionPerspectiveChange(perspective: ClientPerspective): Promise<void> {\n const sanitizedPerspective = sanitizePerspective(perspective, 'drafts')\n if (\n !sanitizedPerspective ||\n (Array.isArray(sanitizedPerspective) && sanitizedPerspective.length === 0)\n ) {\n throw new Error(`Invalid perspective`, {cause: perspective})\n }\n\n const nextPerspective = Array.isArray(sanitizedPerspective)\n ? sanitizedPerspective.join(',')\n : sanitizedPerspective\n const jar = await cookies()\n if (\n nextPerspective === jar.get(perspectiveCookieName)?.value &&\n process.env.NODE_ENV !== 'production'\n ) {\n // oxlint-disable-next-line no-console\n console.debug('actionPerspectiveChange', 'Perspective is the same, skipping', nextPerspective)\n return\n }\n jar.set(perspectiveCookieName, nextPerspective, {\n httpOnly: true,\n path: '/',\n secure: true,\n sameSite: 'none',\n })\n\n refresh()\n}\n"],"mappings":";;;;;;;;AAaA,eAAsB,cAAc,UAAyC;AAC3E,UAAS;;;;;AAMX,eAAsB,wBAAwB,aAA+C;CAC3F,MAAM,uBAAuB,oBAAoB,aAAa,SAAS;AACvE,KACE,CAAC,wBACA,MAAM,QAAQ,qBAAqB,IAAI,qBAAqB,WAAW,EAExE,OAAM,IAAI,MAAM,uBAAuB,EAAC,OAAO,aAAY,CAAC;CAG9D,MAAM,kBAAkB,MAAM,QAAQ,qBAAqB,GACvD,qBAAqB,KAAK,IAAI,GAC9B;CACJ,MAAM,MAAM,MAAM,SAAS;AAC3B,KACE,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,SACpD,QAAQ,IAAI,aAAa,cACzB;AAEA,UAAQ,MAAM,2BAA2B,qCAAqC,gBAAgB;AAC9F;;AAEF,KAAI,IAAI,uBAAuB,iBAAiB;EAC9C,UAAU;EACV,MAAM;EACN,QAAQ;EACR,UAAU;EACX,CAAC;AAEF,UAAS"}
@@ -1,4 +1,9 @@
1
1
  import { SIGNATURE_HEADER_NAME, isValidSignature } from "@sanity/webhook";
2
+ /**
3
+ * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
4
+ * without worrying about getting stale data.
5
+ * @public
6
+ */
2
7
  async function parseBody(req, secret, waitForContentLakeEventualConsistency = true) {
3
8
  const signature = req.headers.get(SIGNATURE_HEADER_NAME);
4
9
  if (!signature) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/webhook/index.ts"],"sourcesContent":["import {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextRequest} from 'next/server'\n\n/** @public */\nexport type ParsedBody<T> = {\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: T | null\n}\n\n/** @public */\ninterface SanityDocument {\n _id: string\n _type: string\n _createdAt: string\n _updatedAt: string\n _rev: string\n [key: string]: unknown\n}\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<Body = SanityDocument>(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency = true,\n): Promise<ParsedBody<Body>> {\n const signature = req.headers.get(SIGNATURE_HEADER_NAME)\n if (!signature) {\n console.error('Missing signature header')\n return {body: null, isValidSignature: null}\n }\n\n const body = await req.text()\n const validSignature = secret ? await isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 3000))\n }\n\n return {\n body: body.trim() ? JSON.parse(body) : null,\n isValidSignature: validSignature,\n }\n}\n"],"mappings":";AA2BA,eAAsB,UACpB,KACA,QACA,wCAAwC,MACb;CAC3B,MAAM,YAAY,IAAI,QAAQ,IAAI,sBAAsB;AACxD,KAAI,CAAC,WAAW;AACd,UAAQ,MAAM,2BAA2B;AACzC,SAAO;GAAC,MAAM;GAAM,kBAAkB;GAAK;;CAG7C,MAAM,OAAO,MAAM,IAAI,MAAM;CAC7B,MAAM,iBAAiB,SAAS,MAAM,iBAAiB,MAAM,WAAW,OAAO,MAAM,CAAC,GAAG;AAEzF,KAAI,mBAAmB,SAAS,sCAC9B,OAAM,IAAI,SAAS,YAAY,WAAW,SAAS,IAAK,CAAC;AAG3D,QAAO;EACL,MAAM,KAAK,MAAM,GAAG,KAAK,MAAM,KAAK,GAAG;EACvC,kBAAkB;EACnB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/webhook/index.ts"],"sourcesContent":["import {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextRequest} from 'next/server'\n\n/** @public */\nexport type ParsedBody<T> = {\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: T | null\n}\n\n/** @public */\ninterface SanityDocument {\n _id: string\n _type: string\n _createdAt: string\n _updatedAt: string\n _rev: string\n [key: string]: unknown\n}\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<Body = SanityDocument>(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency = true,\n): Promise<ParsedBody<Body>> {\n const signature = req.headers.get(SIGNATURE_HEADER_NAME)\n if (!signature) {\n console.error('Missing signature header')\n return {body: null, isValidSignature: null}\n }\n\n const body = await req.text()\n const validSignature = secret ? await isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 3000))\n }\n\n return {\n body: body.trim() ? JSON.parse(body) : null,\n isValidSignature: validSignature,\n }\n}\n"],"mappings":";;;;;;AA2BA,eAAsB,UACpB,KACA,QACA,wCAAwC,MACb;CAC3B,MAAM,YAAY,IAAI,QAAQ,IAAI,sBAAsB;AACxD,KAAI,CAAC,WAAW;AACd,UAAQ,MAAM,2BAA2B;AACzC,SAAO;GAAC,MAAM;GAAM,kBAAkB;GAAK;;CAG7C,MAAM,OAAO,MAAM,IAAI,MAAM;CAC7B,MAAM,iBAAiB,SAAS,MAAM,iBAAiB,MAAM,WAAW,OAAO,MAAM,CAAC,GAAG;AAEzF,KAAI,mBAAmB,SAAS,sCAC9B,OAAM,IAAI,SAAS,YAAY,WAAW,SAAS,IAAK,CAAC;AAG3D,QAAO;EACL,MAAM,KAAK,MAAM,GAAG,KAAK,MAAM,KAAK,GAAG;EACvC,kBAAkB;EACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "13.0.0-cache-components.35",
3
+ "version": "13.0.0-cache-components.37",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "live",
@@ -62,43 +62,44 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@portabletext/react": "^6.0.3",
65
- "@sanity/client": "^7.20.0",
65
+ "@sanity/client": "^7.22.0",
66
66
  "@sanity/comlink": "^4.0.1",
67
67
  "@sanity/generate-help-url": "^4.0.0",
68
68
  "@sanity/presentation-comlink": "^2.0.1",
69
- "@sanity/preview-url-secret": "^4.0.4",
70
- "@sanity/visual-editing": "^5.3.3",
69
+ "@sanity/preview-url-secret": "^4.0.5",
70
+ "@sanity/visual-editing": "^5.3.4",
71
71
  "@sanity/webhook": "^4.0.4",
72
72
  "dequal": "^2.0.3",
73
- "groq": "^5.18.0",
73
+ "groq": "^5.23.0",
74
74
  "history": "^5.3.0"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@sanity/tsconfig": "^2.1.0",
78
78
  "@types/js-yaml": "^4.0.9",
79
- "@types/node": "^24.12.0",
79
+ "@types/node": "^24.12.2",
80
80
  "@types/react": "^19.2.14",
81
81
  "@types/react-dom": "^19.2.3",
82
- "@vitejs/plugin-react": "^5.2.0",
83
- "@vitest/coverage-v8": "^4.1.0",
82
+ "@vitejs/plugin-react": "^6.0.1",
83
+ "@vitest/coverage-v8": "^4.1.5",
84
84
  "js-yaml": "^4.1.1",
85
- "next": "16.2.1-canary.10",
85
+ "next": "16.3.0-canary.5",
86
86
  "publint": "^0.3.18",
87
- "react": "^19.2.4",
88
- "react-dom": "^19.2.4",
89
- "styled-components": "^6.3.12",
90
- "tsdown": "0.20.3",
91
- "typedoc": "^0.28.17",
87
+ "react": "^19.2.5",
88
+ "react-dom": "^19.2.5",
89
+ "styled-components": "^6.4.1",
90
+ "tsdown": "^0.21.10",
91
+ "typedoc": "^0.28.19",
92
92
  "typescript": "5.9.3",
93
- "vitest": "^4.1.0",
93
+ "vite": "^8.0.10",
94
+ "vitest": "^4.1.5",
94
95
  "vitest-package-exports": "^1.2.0"
95
96
  },
96
97
  "peerDependencies": {
97
- "@sanity/client": "^7.20.0",
98
+ "@sanity/client": "^7.22.0",
98
99
  "next": "^16.0.0-0",
99
100
  "react": "^19.2.3",
100
101
  "react-dom": "^19.2.3",
101
- "sanity": "^5.18.0",
102
+ "sanity": "^5.23.0",
102
103
  "styled-components": "^6.1"
103
104
  },
104
105
  "engines": {