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

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.
@@ -1,30 +1,2 @@
1
- import { useIsPresentationTool, useOptimistic, useVisualEditingEnvironment } from "@sanity/visual-editing/react";
2
- import { ClientPerspective, ClientReturn, ContentSourceMap, QueryParams } from "@sanity/client";
3
- /** @alpha */
4
- type UsePresentationQueryReturnsInactive = {
5
- data: null;
6
- sourceMap: null;
7
- perspective: null;
8
- };
9
- /** @alpha */
10
- type UsePresentationQueryReturnsActive<QueryString extends string> = {
11
- data: ClientReturn<QueryString>;
12
- sourceMap: ContentSourceMap | null;
13
- perspective: ClientPerspective;
14
- };
15
- type UsePresentationQueryReturns<QueryString extends string> = UsePresentationQueryReturnsInactive | UsePresentationQueryReturnsActive<QueryString>;
16
- /**
17
- * Experimental hook that can run queries in Presentation Tool.
18
- * Query results are sent back over postMessage whenever the query results change.
19
- * It also works with optimistic updates in the studio itself, offering low latency updates.
20
- * It's not as low latency as the `useOptimistic` hook, but it's a good compromise for some use cases.
21
- * Especially until `useOptimistic` propagates edits in the Studio parent window back into the iframe.
22
- * @alpha
23
- */
24
- declare function usePresentationQuery<const QueryString extends string>(_: {
25
- query: QueryString;
26
- params?: QueryParams | Promise<QueryParams>;
27
- stega?: boolean;
28
- }): UsePresentationQueryReturns<QueryString>;
29
- export { useIsPresentationTool, useOptimistic, usePresentationQuery, useVisualEditingEnvironment };
30
- //# sourceMappingURL=index.d.ts.map
1
+ import { useIsPresentationTool, useOptimistic, usePresentationQuery, useVisualEditingEnvironment } from "@sanity/visual-editing/react";
2
+ export { useIsPresentationTool, useOptimistic, usePresentationQuery, useVisualEditingEnvironment };
@@ -1,14 +1,3 @@
1
1
  "use client";
2
- import { useIsPresentationTool, useOptimistic, useVisualEditingEnvironment } from "@sanity/visual-editing/react";
3
- const initialState = {
4
- data: null,
5
- sourceMap: null,
6
- perspective: null
7
- };
8
- function usePresentationQuery(_) {
9
- console.log("TODO: Implement usePresentationQuery");
10
- return initialState;
11
- }
2
+ import { useIsPresentationTool, useOptimistic, usePresentationQuery, useVisualEditingEnvironment } from "@sanity/visual-editing/react";
12
3
  export { useIsPresentationTool, useOptimistic, usePresentationQuery, useVisualEditingEnvironment };
13
-
14
- //# sourceMappingURL=index.js.map
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.27",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "live",
@@ -66,7 +66,7 @@
66
66
  "@sanity/comlink": "^4.0.1",
67
67
  "@sanity/presentation-comlink": "^2.0.1",
68
68
  "@sanity/preview-url-secret": "^4.0.3",
69
- "@sanity/visual-editing": "^5.2.1",
69
+ "@sanity/visual-editing": "^5.3.0",
70
70
  "@sanity/webhook": "^4.0.4",
71
71
  "dequal": "^2.0.3",
72
72
  "groq": "^5.8.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/visual-editing/hooks/usePresentationQuery.ts"],"mappings":";;;KAGY,mCAAA;EACV,IAAA;EACA,SAAA;EACA,WAAA;AAAA;;KAIU,iCAAA;EACV,IAAA,EAAM,YAAA,CAAa,WAAA;EACnB,SAAA,EAAW,gBAAA;EACX,WAAA,EAAa,iBAAA;AAAA;AAAA,KAGH,2BAAA,+BACR,mCAAA,GACA,iCAAA,CAAkC,WAAA;;;;;;;;;iBAgBtB,oBAAA,kCAAA,CAAuD,CAAA;EACrE,KAAA,EAAO,WAAA;EACP,MAAA,GAAS,WAAA,GAAc,OAAA,CAAQ,WAAA;EAC/B,KAAA;AAAA,IACE,2BAAA,CAA4B,WAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/visual-editing/hooks/usePresentationQuery.ts"],"sourcesContent":["import type {ClientPerspective, ClientReturn, ContentSourceMap, QueryParams} from '@sanity/client'\n\n/** @alpha */\nexport type UsePresentationQueryReturnsInactive = {\n data: null\n sourceMap: null\n perspective: null\n}\n\n/** @alpha */\nexport type UsePresentationQueryReturnsActive<QueryString extends string> = {\n data: ClientReturn<QueryString>\n sourceMap: ContentSourceMap | null\n perspective: ClientPerspective\n}\n\nexport type UsePresentationQueryReturns<QueryString extends string> =\n | UsePresentationQueryReturnsInactive\n | UsePresentationQueryReturnsActive<QueryString>\n\nconst initialState: UsePresentationQueryReturnsInactive = {\n data: null,\n sourceMap: null,\n perspective: null,\n}\n\n/**\n * Experimental hook that can run queries in Presentation Tool.\n * Query results are sent back over postMessage whenever the query results change.\n * It also works with optimistic updates in the studio itself, offering low latency updates.\n * It's not as low latency as the `useOptimistic` hook, but it's a good compromise for some use cases.\n * Especially until `useOptimistic` propagates edits in the Studio parent window back into the iframe.\n * @alpha\n */\nexport function usePresentationQuery<const QueryString extends string>(_: {\n query: QueryString\n params?: QueryParams | Promise<QueryParams>\n stega?: boolean\n}): UsePresentationQueryReturns<QueryString> {\n // oxlint-disable-next-line no-console\n console.log('TODO: Implement usePresentationQuery')\n\n return initialState\n}\n"],"mappings":";;AAoBA,MAAM,eAAoD;CACxD,MAAM;CACN,WAAW;CACX,aAAa;CACd;AAUD,SAAgB,qBAAuD,GAI1B;AAE3C,SAAQ,IAAI,uCAAuC;AAEnD,QAAO"}