next-sanity 13.0.0-cache-components.25 → 13.0.0-cache-components.26

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/parseTags.js CHANGED
@@ -4,7 +4,7 @@ function parseTags(tags, context) {
4
4
  tags,
5
5
  context
6
6
  } });
7
- return tags.map((tag) => `${context.includeAllDocuments ? PUBLISHED_SYNC_TAG_PREFIX : DRAFT_SYNC_TAG_PREFIX}${tag}`);
7
+ return tags.map((tag) => `${context.includeAllDocuments ? DRAFT_SYNC_TAG_PREFIX : PUBLISHED_SYNC_TAG_PREFIX}${tag}`);
8
8
  }
9
9
  export { parseTags as t };
10
10
 
@@ -1 +1 @@
1
- {"version":3,"file":"parseTags.js","names":[],"sources":["../src/live/shared/parseTags.ts"],"sourcesContent":["import type {LiveEvent, SyncTag} from '@sanity/client'\n\nimport type {SanityLiveActionContext} from './types'\n\nimport {DRAFT_SYNC_TAG_PREFIX, PUBLISHED_SYNC_TAG_PREFIX} from './constants'\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<const Tags extends Extract<LiveEvent, {type: 'message'}>['tags']>(\n tags: Tags,\n context: SanityLiveActionContext,\n): `${typeof PUBLISHED_SYNC_TAG_PREFIX | typeof DRAFT_SYNC_TAG_PREFIX}${SyncTag}`[] {\n if (!Array.isArray(tags)) {\n throw new TypeError('tags must be an array', {cause: {tags, context}})\n }\n return tags.map(\n (tag) =>\n `${context.includeAllDocuments ? PUBLISHED_SYNC_TAG_PREFIX : DRAFT_SYNC_TAG_PREFIX}${tag}` as const,\n )\n}\n"],"mappings":";AA2BA,SAAgB,UACd,MACA,SACkF;AAClF,KAAI,CAAC,MAAM,QAAQ,KAAK,CACtB,OAAM,IAAI,UAAU,yBAAyB,EAAC,OAAO;EAAC;EAAM;EAAQ,EAAC,CAAC;AAExE,QAAO,KAAK,KACT,QACC,GAAG,QAAQ,sBAAsB,4BAA4B,wBAAwB,MACxF"}
1
+ {"version":3,"file":"parseTags.js","names":[],"sources":["../src/live/shared/parseTags.ts"],"sourcesContent":["import type {LiveEvent, SyncTag} from '@sanity/client'\n\nimport type {SanityLiveActionContext} from './types'\n\nimport {DRAFT_SYNC_TAG_PREFIX, PUBLISHED_SYNC_TAG_PREFIX} from './constants'\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<const Tags extends Extract<LiveEvent, {type: 'message'}>['tags']>(\n tags: Tags,\n context: SanityLiveActionContext,\n): `${typeof PUBLISHED_SYNC_TAG_PREFIX | typeof DRAFT_SYNC_TAG_PREFIX}${SyncTag}`[] {\n if (!Array.isArray(tags)) {\n throw new TypeError('tags must be an array', {cause: {tags, context}})\n }\n return tags.map(\n (tag) =>\n `${context.includeAllDocuments ? DRAFT_SYNC_TAG_PREFIX : PUBLISHED_SYNC_TAG_PREFIX}${tag}` as const,\n )\n}\n"],"mappings":";AA2BA,SAAgB,UACd,MACA,SACkF;AAClF,KAAI,CAAC,MAAM,QAAQ,KAAK,CACtB,OAAM,IAAI,UAAU,yBAAyB,EAAC,OAAO;EAAC;EAAM;EAAQ,EAAC,CAAC;AAExE,QAAO,KAAK,KACT,QACC,GAAG,QAAQ,sBAAsB,wBAAwB,4BAA4B,MACxF"}
@@ -11,7 +11,7 @@ async function actionPerspectiveChange(perspective) {
11
11
  if (!sanitizedPerspective || Array.isArray(sanitizedPerspective) && sanitizedPerspective.length === 0) throw new Error(`Invalid perspective`, { cause: perspective });
12
12
  const nextPerspective = Array.isArray(sanitizedPerspective) ? sanitizedPerspective.join(",") : sanitizedPerspective;
13
13
  const jar = await cookies();
14
- if (nextPerspective === jar.get(perspectiveCookieName)?.value) {
14
+ if (nextPerspective === jar.get(perspectiveCookieName)?.value && process.env.NODE_ENV !== "production") {
15
15
  console.debug("actionPerspectiveChange", "Perspective is the same, skipping", nextPerspective);
16
16
  return;
17
17
  }
@@ -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 type {HistoryRefresh} from '@sanity/visual-editing/react'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {refresh} from 'next/cache'\nimport {cookies} from 'next/headers'\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 (nextPerspective === jar.get(perspectiveCookieName)?.value) {\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,KAAI,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,OAAO;AAE7D,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 type {HistoryRefresh} from '@sanity/visual-editing/react'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {refresh} from 'next/cache'\nimport {cookies} from 'next/headers'\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 (nextPerspective === jar.get(perspectiveCookieName)?.value && process.env.NODE_ENV !== 'production') {\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,KAAI,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,SAAS,QAAQ,IAAI,aAAa,cAAc;AAEtG,UAAQ,MAAM,2BAA2B,qCAAqC,gBAAgB;AAC9F;;AAEF,KAAI,IAAI,uBAAuB,iBAAiB;EAC9C,UAAU;EACV,MAAM;EACN,QAAQ;EACR,UAAU;EACX,CAAC;AAEF,UAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "13.0.0-cache-components.25",
3
+ "version": "13.0.0-cache-components.26",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "live",