next-sanity 13.0.0-cache-components.5 → 13.0.0-cache-components.7

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * For usage with `cacheComponents: true`, and `defineLive`:
3
+ * ```ts
4
+ * // next.config.ts
5
+ *
6
+ * import type {NextConfig} from 'next'
7
+ * import {sanity} from 'next-sanity/cache-life'
8
+ *
9
+ * const nextConfig: NextConfig = {
10
+ * cacheComponents: true,
11
+ * cacheLife: {
12
+ * sanity
13
+ * }
14
+ * }
15
+ *
16
+ * export default nextConfig
17
+ * ```
18
+ *
19
+ * ```ts
20
+ *
21
+ * async function sanityFetch() {
22
+ * 'use cache'
23
+ * cacheLife('sanity')
24
+ * const {data} = await fetch({query, params})
25
+ * return data
26
+ * }
27
+ */
28
+ declare const sanity: {
29
+ /**
30
+ * Sanity Live handles on-demand revalidation, so the default 15min time based revalidation is too short
31
+ */
32
+ readonly revalidate: 7_776_000;
33
+ };
34
+ export { sanity };
35
+ //# sourceMappingURL=cache-life.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-life.d.ts","names":[],"sources":["../src/cache-life.ts"],"sourcesContent":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa"}
@@ -0,0 +1,4 @@
1
+ const sanity = { revalidate: 7776e3 };
2
+ export { sanity };
3
+
4
+ //# sourceMappingURL=cache-life.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-life.js","names":[],"sources":["../src/cache-life.ts"],"sourcesContent":["/**\n * For usage with `cacheComponents: true`, and `defineLive`:\n * ```ts\n * // next.config.ts\n *\n * import type {NextConfig} from 'next'\n * import {sanity} from 'next-sanity/cache-life'\n *\n * const nextConfig: NextConfig = {\n * cacheComponents: true,\n * cacheLife: {\n * sanity\n * }\n * }\n *\n * export default nextConfig\n * ```\n *\n * ```ts\n *\n * async function sanityFetch() {\n * 'use cache'\n * cacheLife('sanity')\n * const {data} = await fetch({query, params})\n * return data\n * }\n */\nexport const sanity = {\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time based revalidation is too short\n */\n revalidate: 7_776_000, // 90 days,\n} as const satisfies {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n}\n"],"mappings":"AA2BA,MAAa,SAAS,EAIpB,YAAY,QACb"}
@@ -1,4 +1,145 @@
1
+ import { cookies } from "next/headers";
1
2
  import { ClientPerspective, ClientReturn, ContentSourceMap, LiveEventGoAway, QueryParams, SanityClient, SyncTag } from "@sanity/client";
3
+ import { ClientPerspective as ClientPerspective$1, ClientReturn as ClientReturn$1, ContentSourceMap as ContentSourceMap$1, LiveEventGoAway as LiveEventGoAway$1, QueryParams as QueryParams$1, SanityClient as SanityClient$1 } from "next-sanity";
4
+ type ResolvePerspectiveFromCookies = (options: {
5
+ /**
6
+ * You must await the cookies() function from next/headers
7
+ * and pass it here.
8
+ * Example:
9
+ * ```ts
10
+ * import { cookies } from 'next/headers'
11
+ *
12
+ * const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
13
+ * ```
14
+ */
15
+ cookies: Awaited<ReturnType<typeof cookies>>;
16
+ }) => Promise<Exclude<ClientPerspective, "raw">>;
17
+ /**
18
+ * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from "next-sanity/draft-mode"`
19
+ * @public
20
+ */
21
+ declare const resolvePerspectiveFromCookies: ({
22
+ cookies: jar
23
+ }: {
24
+ cookies: Awaited<ReturnType<typeof cookies>>;
25
+ }) => Promise<Exclude<ClientPerspective, "raw">>;
26
+ /**
27
+ * Perspectives supported by Sanity Live.
28
+ * Using the legacy `'raw'` perspective is not supported and leads to undefined behavior.
29
+ */
30
+ type PerspectiveType = Exclude<ClientPerspective$1, "raw">;
31
+ /**
32
+ * TODO: docs
33
+ */
34
+ type DefinedFetchType = <const QueryString extends string>(options: {
35
+ query: QueryString;
36
+ params?: QueryParams$1;
37
+ /**
38
+ * @defaultValue 'published'
39
+ */
40
+ perspective?: PerspectiveType;
41
+ /**
42
+ * Enables stega encoding of the data, this is typically only used in draft mode in conjunction with `perspective: 'drafts'` and with `@sanity/visual-editing` setup.
43
+ * @defaultValue `false`
44
+ */
45
+ stega?: boolean;
46
+ /**
47
+ * Custom cache tags that can be used with next's `updateTag` functions for custom `read-your-write` server actions,
48
+ * for example a like button that uses client.mutate to update a document and then immediately shows the result.
49
+ */
50
+ tags?: string[];
51
+ /**
52
+ * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
53
+ * @see https://www.sanity.io/docs/reference-api-request-tags
54
+ * @defaultValue 'next-loader.fetch'
55
+ */
56
+ requestTag?: string;
57
+ }) => Promise<{
58
+ data: ClientReturn$1<QueryString, unknown>;
59
+ sourceMap: ContentSourceMap$1 | null;
60
+ tags: string[];
61
+ }>;
62
+ interface DefinedLiveProps {
63
+ /**
64
+ * TODO: should match the `perspective` you give `defineLive().fetch()`, setting it to a value other than `"published"`
65
+ * and with `browserToken` set will cause it to subscribe to draft content changes as well as published content.
66
+ */
67
+ perspective?: PerspectiveType;
68
+ /**
69
+ * TODO: If Presentation Tool is present this event will fire with the current `perspective` stack used in the
70
+ * Sanity Studio global perspective menu. The default event handler will store this state in a cookie,
71
+ * which can be read with `resolvePerspectiveFromCookies` and used to ensure data fetching in the preview
72
+ * matches the perspective and content viewed in the Studio, allowing you to quickly switch and preview different perspectives.
73
+ */
74
+ onStudioPerspective?: (perspective: PerspectiveType) => void;
75
+ /**
76
+ * Automatic refresh of RSC when the component <SanityLive /> is mounted.
77
+ * @defaultValue `false`
78
+ */
79
+ refreshOnMount?: boolean;
80
+ /**
81
+ * Automatically refresh when window gets focused
82
+ * @defaultValue `false`
83
+ */
84
+ refreshOnFocus?: boolean;
85
+ /**
86
+ * Automatically refresh when the browser regains a network connection (via navigator.onLine)
87
+ * @defaultValue `false`
88
+ */
89
+ refreshOnReconnect?: boolean;
90
+ /**
91
+ * Automatically refresh on an interval when the Live Event API emits a `goaway` event, which indicates that the connection is rejected or closed.
92
+ * This typically happens if the connection limit is reached, or if the connection is idle for too long.
93
+ * To disable this long polling fallback behavior set `intervalOnGoAway` to `false` or `0`.
94
+ * You can also use `onGoAway` to handle the `goaway` event in your own way, and read the reason why the event was emitted.
95
+ * @defaultValue `30_000` 30 seconds interval
96
+ */
97
+ intervalOnGoAway?: number | false;
98
+ /**
99
+ * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
100
+ * @see https://www.sanity.io/docs/reference-api-request-tags
101
+ * @defaultValue 'next-loader.live'
102
+ */
103
+ requestTag?: string;
104
+ /**
105
+ * Handle errors from the Live Events subscription.
106
+ * By default it's reported using `console.error`, you can override this prop to handle it in your own way.
107
+ */
108
+ onError?: (error: unknown) => void;
109
+ /**
110
+ * Handle the `goaway` event if the connection is rejected/closed.
111
+ * `event.reason` will be a string of why the event was emitted, for example `'connection limit reached'`.
112
+ * When this happens the `<SanityLive />` will fallback to long polling with a default interval of 30 seconds, providing your own `onGoAway` handler does not change this behavior.
113
+ * If you want to disable long polling set `intervalOnGoAway` to `false` or `0`.
114
+ */
115
+ onGoAway?: (event: LiveEventGoAway$1, intervalOnGoAway: number | false) => void;
116
+ /**
117
+ * TODO: docs, this handles events for published content only, and can be used to revalidate content for all your users when in presentation tool
118
+ */
119
+ onChange?: (tags: string[]) => Promise<void | "refresh">;
120
+ /**
121
+ * TODO: docs, this handles events for all changes, published, drafts and even version documents in content releases.
122
+ * It's only used when `browserToken` is provided, and the `perspective` prop is other than `"published"`.
123
+ * Wether you should just `refresh()` or use `updateTag` to expire tags depends on how you fetch draft content and wether it's cached or not.
124
+ */
125
+ onChangeIncludingDrafts?: (tags: string[]) => Promise<void | "refresh">;
126
+ }
127
+ interface LiveOptions {
128
+ /**
129
+ * Required for `fetch()` and `<Live>` to work
130
+ */
131
+ client: SanityClient$1;
132
+ /**
133
+ * Optional. If provided then the token needs to have permissions to query documents with `drafts.` prefixes in order for `perspective: 'drafts'` to work.
134
+ * This token is never shared with the browser, unless you reuse it in `browserToken`..
135
+ */
136
+ serverToken?: string | false;
137
+ /**
138
+ * Optional. This token is shared with the browser when `<Live>` is given a `perspective` prop other than `"published"`, and should only have access to query published documents.
139
+ * It is used to setup a `Live Draft Content` EventSource connection, and enables live previewing drafts stand-alone, outside of Presentation Tool.
140
+ */
141
+ browserToken?: string | false;
142
+ }
2
143
  /**
3
144
  * @public
4
145
  */
@@ -15,10 +156,6 @@ type DefinedSanityFetchType = <const QueryString extends string>(options: {
15
156
  perspective?: Exclude<ClientPerspective, "raw">;
16
157
  stega?: boolean;
17
158
  /**
18
- * @deprecated use `requestTag` instead
19
- */
20
- tag?: never;
21
- /**
22
159
  * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
23
160
  * @see https://www.sanity.io/docs/reference-api-request-tags
24
161
  * @defaultValue 'next-loader.fetch'
@@ -60,10 +197,6 @@ interface DefinedSanityLiveProps {
60
197
  */
61
198
  intervalOnGoAway?: number | false;
62
199
  /**
63
- * @deprecated use `requestTag` instead
64
- */
65
- tag?: never;
66
- /**
67
200
  * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
68
201
  * @see https://www.sanity.io/docs/reference-api-request-tags
69
202
  * @defaultValue 'next-loader.live'
@@ -121,20 +254,15 @@ interface DefineSanityLiveOptions {
121
254
  */
122
255
  stega?: boolean;
123
256
  }
124
- /**
125
- * @public
126
- */
127
257
  declare function defineLive(config: DefineSanityLiveOptions): {
128
258
  /**
129
- * Use this function to fetch data from Sanity in your React Server Components.
130
- * @public
259
+ * @deprecated use `fetch` instead, and define your own `sanityFetch` function with logic for when to toggle `stega` and `perspective`
131
260
  */
132
261
  sanityFetch: DefinedSanityFetchType;
133
262
  /**
134
- * Render this in your root layout.tsx to make your page revalidate on new content live, automatically.
135
- * @public
263
+ * @deprecated use `Live` instead, and define your own `SanityLive` component with logic for when to toggle `perspective`
136
264
  */
137
265
  SanityLive: React.ComponentType<DefinedSanityLiveProps>;
138
266
  };
139
- export { defineLive as i, DefinedSanityFetchType as n, DefinedSanityLiveProps as r, DefineSanityLiveOptions as t };
267
+ export { DefinedFetchType as a, PerspectiveType as c, defineLive as i, ResolvePerspectiveFromCookies as l, DefinedSanityFetchType as n, DefinedLiveProps as o, DefinedSanityLiveProps as r, LiveOptions as s, DefineSanityLiveOptions as t, resolvePerspectiveFromCookies as u };
140
268
  //# sourceMappingURL=defineLive.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineLive.d.ts","names":[],"sources":["../src/live/defineLive.tsx"],"sourcesContent":[],"mappings":";;AAkBA;;AAEW,KAFC,sBAAA,GAED,CAAA,0BAAA,MAAA,CAAA,CAAA,OAAA,EAAA;EAAsB,KAAA,EADxB,WACwB;EAAR,MAAA,CAAA,EAAd,WAAc,GAAA,OAAA,CAAQ,WAAR,CAAA;EAQD;;;;;;EAYlB,IAAA,CAAA,EAAA,MAAA,EAAA;EASN,WAAiB,CAAA,EArBD,OAqBC,CArBO,iBAqBP,EAAA,KAAA,CAAA;EAoDI,KAAA,CAAA,EAAA,OAAA;EAMS;;;EAM9B,GAAiB,CAAA,EAAA,KAAA;EAuCjB;;;;;EAUoB,UAAA,CAAA,EAAA,MAAA;MA1Hd;QACE,aAAa;aACR;;;;;;UAOI,sBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoDI;;;;;8BAMS,cAAc;;;;;UAM3B,uBAAA;;;;UAIP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmCM,UAAA,SAAmB;;;;;eAKpB;;;;;cAKD,KAAA,CAAM,cAAc"}
1
+ {"version":3,"file":"defineLive.d.ts","names":[],"sources":["../src/shared/live/resolvePerspectiveFromCookies.ts","../src/shared/live/types.ts","../src/live/defineLive.tsx"],"sourcesContent":[],"mappings":";;;KAMY,6BAAA;;AAAZ;;;;;;;;AAkBA;EACW,OAAA,EARA,OAQA,CARQ,UAQR,CAAA,OAR0B,OAQ1B,CAAA,CAAA;CAE0B,EAAA,GAT/B,OAS+B,CATvB,OASuB,CATf,iBASe,EAAA,KAAA,CAAA,CAAA;;;;;AACjC,cAJS,6BAIT,EAAA,CAAA;EAAA,OAAA,EAHO;CAGP,EAAA;EAAA,OAAA,EADO,OACP,CADe,UACf,CAAA,OADiC,OACjC,CAAA,CAAA;MAAA,QAAQ,QAAQ;;;;AAtBpB;AAWqC,KCJzB,eAAA,GAAkB,ODIO,CCJC,mBDID,EAAA,KAAA,CAAA;;;;AACvB,KCAF,gBAAA,GDAE,CAAA,0BAAA,MAAA,CAAA,CAAA,OAAA,EAAA;EAAR,KAAA,ECCG,WDDH;EAAA,MAAA,CAAA,ECEK,aDFL;EAMN;;;EAGmB,WAAA,CAAA,ECHH,eDGG;EAAR;;;;EACP,KAAA,CAAA,EAAA,OAAA;;ACfJ;AAKA;;EAEW,IAAA,CAAA,EAAA,MAAA,EAAA;EAIK;;;;;EAiBV,UAAA,CAAA,EAAA,MAAA;AAMN,CAAA,EAAA,GANM,OAMW,CAAA;EAKD,IAAA,EAVR,cAUQ,CAVK,WAUL,EAAA,OAAA,CAAA;EAQsB,SAAA,EAjBzB,kBAiByB,GAAA,IAAA;EA6CjB,IAAA,EAAA,MAAA,EAAA;CAKY,CAAA;AAOe,UAtE/B,gBAAA,CAsE+B;EAAA;AAGhD;;ACpGA;EACS,WAAA,CAAA,ED+BO,eC/BP;EACE;;;;;;EAiBH,mBAAA,CAAA,EAAA,CAAA,WAAA,EDqB8B,eCrB9B,EAAA,GAAA,IAAA;EACK;;;AAOb;EA+CqB,cAAA,CAAA,EAAA,OAAA;EAMS;;;AAM9B;EAgCA,cAAgB,CAAA,EAAA,OAAA;EAAmB;;;;EAQf,kBAAA,CAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBDzCC;;;;iCAKY;;;;;;gDAOe;;UAG/B,WAAA;;;;UAIP;;;;;;;;;;;;;;;ADtHE,KEcA,sBAAA,GFdA,CAAA,0BAAA,MAAA,CAAA,CAAA,OAAA,EAAA;EAWyB,KAAA,EEI5B,WFJ4B;EAAlB,MAAA,CAAA,EEKR,WFLQ,GEKM,OFLN,CEKc,WFLd,CAAA;EAAR;;;;;AAOX;EACW,IAAA,CAAA,EAAA,MAAA,EAAA;EAE0B,WAAA,CAAA,EEGrB,OFHqB,CEGb,iBFHa,EAAA,KAAA,CAAA;EAAlB,KAAA,CAAA,EAAA,OAAA;EAAR;;;;;;ACdX,CAAA,EAAA,GCyBM,ODzBM,CAAA;EAKZ,IAAY,ECqBJ,YDrBI,CCqBS,WDrBT,CAAA;EACH,SAAA,ECqBI,gBDrBJ,GAAA,IAAA;EACE,IAAA,EAAA,MAAA,EAAA;CAIK,CAAA;;;;AAiBV,UCMW,sBAAA,CDNX;EAAA;AAMN;;;;EA+DiC,cAAA,CAAA,EAAA,OAAA;EAOe;;AAGhD;;ACpGA;EACS,cAAA,CAAA,EAAA,OAAA;EACE;;;;;EAiBU,kBAAA,CAAA,EAAA,OAAA;EAAb;;;;AAQR;;;EAqD4C,gBAAA,CAAA,EAAA,MAAA,GAAA,KAAA;EAAA;AAM5C;AAgCA;;;EAQkC,UAAA,CAAA,EAAA,MAAA;EAApB;;;;;;;;;;;qBApDO;;;;;8BAMS,cAAc;;;;;UAM3B,uBAAA;;;;UAIP;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BM,UAAA,SAAmB;;;;eAIpB;;;;cAID,KAAA,CAAM,cAAc"}
@@ -1,6 +1,7 @@
1
- import { n as PUBLISHED_SYNC_TAG_PREFIX, t as DRAFT_SYNC_TAG_PREFIX } from "../../constants.js";
2
1
  import { ClientPerspective, InitializedClientConfig, LiveEventGoAway, SyncTag } from "@sanity/client";
3
2
  interface SanityClientConfig extends Pick<InitializedClientConfig, "projectId" | "dataset" | "apiHost" | "apiVersion" | "useProjectHostname" | "token" | "requestTagPrefix"> {}
3
+ declare const PUBLISHED_SYNC_TAG_PREFIX = "sp:";
4
+ declare const DRAFT_SYNC_TAG_PREFIX = "sd:";
4
5
  /**
5
6
  * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.
6
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"live.d.ts","names":[],"sources":["../../../src/experimental/types.ts","../../../src/experimental/client-components/live.tsx"],"sourcesContent":[],"mappings":";;UAEiB,kBAAA,SAA2B,KAC1C;AADF;;ACkCA;AACU,UADO,eAAA,CACP;EAYW,MAAA,EAZX,kBAYW;EAED,gBAAA,EAAA,OAAA;EAAmC,cAAA,CAAA,EAAA,OAAA;EAAwB,cAAA,CAAA,EAAA,OAAA;EACxE,kBAAA,CAAA,EAAA,OAAA;EACsC,UAAA,EAAA,MAAA,GAAA,SAAA;EAAR;;;;;;qBAJhB;uCAED,mCAAmC,wBAAwB,gBACxE;qCAC8B,QAAQ;;;;;iBAkCrB,UAAA,QAAkB,kBAAkB,KAAA,CAAM,GAAA,CAAI"}
1
+ {"version":3,"file":"live.d.ts","names":[],"sources":["../../../src/experimental/types.ts","../../../src/experimental/constants.ts","../../../src/experimental/client-components/live.tsx"],"sourcesContent":[],"mappings":";UAEiB,kBAAA,SAA2B,KAC1C;cCHW,yBAAA;cACA,qBAAA;;AADb;AACA;UCmCiB,eAAA;EAAjB,MAAiB,EACP,kBADO;EACP,gBAAA,EAAA,OAAA;EAYW,cAAA,CAAA,EAAA,OAAA;EAED,cAAA,CAAA,EAAA,OAAA;EAAmC,kBAAA,CAAA,EAAA,OAAA;EAAwB,UAAA,EAAA,MAAA,GAAA,SAAA;EACxE;;;;SAmCiB,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAkB,GAAA,IAAA;;qBAtCrB;uCAED,mCAAmC,wBAAwB,gBACxE;qCAC8B,QAAQ;;;;;iBAkCrB,UAAA,QAAkB,kBAAkB,KAAA,CAAM,GAAA,CAAI"}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
2
  import { t as sanitizePerspective } from "../../sanitizePerspective.js";
3
- import { revalidateTag } from "next/cache";
4
3
  import { perspectiveCookieName } from "@sanity/preview-url-secret/constants";
5
4
  import { cookies, draftMode } from "next/headers";
5
+ import { revalidateTag } from "next/cache";
6
6
  async function revalidateSyncTags(tags) {
7
7
  revalidateTag("sanity:fetch-sync-tags", "max");
8
8
  for (const _tag of tags) {
package/dist/live.d.ts CHANGED
@@ -1,11 +1,18 @@
1
1
  import { t as isCorsOriginError } from "./isCorsOriginError.js";
2
- import { n as DefinedSanityFetchType, r as DefinedSanityLiveProps, t as DefineSanityLiveOptions } from "./defineLive.js";
3
- import { t as ResolvePerspectiveFromCookies } from "./resolvePerspectiveFromCookies.js";
2
+ import { a as DefinedFetchType, c as PerspectiveType, l as ResolvePerspectiveFromCookies, n as DefinedSanityFetchType, o as DefinedLiveProps, r as DefinedSanityLiveProps, t as DefineSanityLiveOptions } from "./defineLive.js";
4
3
  /**
5
4
  * @public
6
5
  */
7
6
  declare function defineLive(_config: DefineSanityLiveOptions): {
7
+ fetch: DefinedFetchType;
8
+ Live: React.ComponentType<DefinedLiveProps>;
9
+ /**
10
+ * @deprecated use `fetch` instead, and define your own `sanityFetch` function with logic for when to toggle `stega` and `perspective`
11
+ */
8
12
  sanityFetch: DefinedSanityFetchType;
13
+ /**
14
+ * @deprecated use `Live` instead, and define your own `SanityLive` component with logic for when to toggle `perspective`
15
+ */
9
16
  SanityLive: React.ComponentType<DefinedSanityLiveProps>;
10
17
  };
11
18
  /**
@@ -13,5 +20,5 @@ declare function defineLive(_config: DefineSanityLiveOptions): {
13
20
  * @public
14
21
  */
15
22
  declare const resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies;
16
- export { type DefineSanityLiveOptions, type DefinedSanityFetchType, type DefinedSanityLiveProps, defineLive, isCorsOriginError, resolvePerspectiveFromCookies };
23
+ export { type PerspectiveType as LivePerspective, defineLive, isCorsOriginError, resolvePerspectiveFromCookies };
17
24
  //# sourceMappingURL=live.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"live.d.ts","names":["resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies"],"sources":["../src/live.tsx"],"sourcesContent":[],"mappings":";;;;;AAiBA;AAAoC,iBAApB,UAAA,CAAoB,OAAA,EAAA,uBAAA,CAAA,EAAA;EACrB,WAAA,EAAA,sBAAA;EACmB,UAAA,EAApB,KAAA,CAAM,aAAc,CAAA,sBAAA,CAAA;CAApB;;;;;cAgBDA,+BAA+B"}
1
+ {"version":3,"file":"live.d.ts","names":["resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies"],"sources":["../src/live.tsx"],"sourcesContent":[],"mappings":";;;;;AAsBc,iBAFE,UAAA,CAEF,OAAA,EAFsB,uBAEtB,CAAA,EAAA;EAIC,KAAA,EALN,gBAKM;EAImB,IAAA,EAR1B,KAAA,CAAM,aAQoB,CARN,gBAQM,CAAA;EAApB;;AASd;eAbe;;;;cAID,KAAA,CAAM,cAAc;;;;;;cASrBA,+BAA+B"}
package/dist/live.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"live.js","names":["resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies"],"sources":["../src/live.tsx"],"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\nexport {isCorsOriginError} from '#live/isCorsOriginError'\n\nimport type {\n DefineSanityLiveOptions,\n DefinedSanityFetchType,\n DefinedSanityLiveProps,\n} from './live/defineLive'\n\n/**\n * @public\n */\nexport function defineLive(_config: DefineSanityLiveOptions): {\n sanityFetch: DefinedSanityFetchType\n SanityLive: React.ComponentType<DefinedSanityLiveProps>\n} {\n throw new Error(`defineLive can't be imported by a client component`)\n}\n\n/**\n * @public\n */\nexport type {DefineSanityLiveOptions, DefinedSanityFetchType, DefinedSanityLiveProps}\n\nimport type {ResolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\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"],"mappings":";AAiBA,SAAgB,WAAW,SAGzB;AACA,OAAM,IAAI,MAAM,qDAAqD;;AAcvE,MAAaA,sCAAqE;AAChF,OAAM,IAAI,MAAM,wEAAwE"}
1
+ {"version":3,"file":"live.js","names":["resolvePerspectiveFromCookies: ResolvePerspectiveFromCookies"],"sources":["../src/live.tsx"],"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 {DefinedFetchType, DefinedLiveProps} from '#live/types'\n\nimport type {\n DefineSanityLiveOptions,\n DefinedSanityFetchType,\n DefinedSanityLiveProps,\n} from './live/defineLive'\n\nexport {isCorsOriginError} from '#live/isCorsOriginError'\n\n/**\n * @public\n */\nexport function defineLive(_config: DefineSanityLiveOptions): {\n fetch: DefinedFetchType\n Live: React.ComponentType<DefinedLiveProps>\n /**\n * @deprecated use `fetch` instead, and define your own `sanityFetch` function with logic for when to toggle `stega` and `perspective`\n */\n sanityFetch: DefinedSanityFetchType\n /**\n * @deprecated use `Live` instead, and define your own `SanityLive` component with logic for when to toggle `perspective`\n */\n SanityLive: React.ComponentType<DefinedSanityLiveProps>\n} {\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":";AAoBA,SAAgB,WAAW,SAWzB;AACA,OAAM,IAAI,MAAM,qDAAqD;;AAOvE,MAAaA,sCAAqE;AAChF,OAAM,IAAI,MAAM,wEAAwE"}
@@ -1,134 +1,16 @@
1
- import { n as PUBLISHED_SYNC_TAG_PREFIX, t as DRAFT_SYNC_TAG_PREFIX } from "./constants.js";
2
1
  import { t as isCorsOriginError } from "./isCorsOriginError.js";
3
- import { n as resolvePerspectiveFromCookies } from "./resolvePerspectiveFromCookies.js";
4
- import { ClientPerspective, ClientReturn, ContentSourceMap, LiveEventGoAway, QueryParams, SanityClient, SyncTag } from "next-sanity";
5
- /**
6
- * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.
7
- */
8
- interface SanityFetchOptions<QueryString extends string> {
9
- query: QueryString;
10
- params?: QueryParams;
2
+ import { a as DefinedFetchType, c as PerspectiveType, n as DefinedSanityFetchType, o as DefinedLiveProps, r as DefinedSanityLiveProps, s as LiveOptions, u as resolvePerspectiveFromCookies } from "./defineLive.js";
3
+ declare function defineLive(config: LiveOptions): {
4
+ fetch: DefinedFetchType;
5
+ Live: React.ComponentType<DefinedLiveProps>;
11
6
  /**
12
- * @defaultValue 'published'
13
- */
14
- perspective?: Exclude<ClientPerspective, "raw">;
15
- /**
16
- * Enables stega encoding of the data, this is typically only used in draft mode in conjunction with `perspective: 'drafts'` and with `@sanity/visual-editing` setup.
17
- * @defaultValue `false`
18
- */
19
- stega?: boolean;
20
- /**
21
- * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
22
- * @see https://www.sanity.io/docs/reference-api-request-tags
23
- * @defaultValue 'next-loader.fetch'
24
- */
25
- requestTag?: string;
26
- /**
27
- * Custom cache tags that can be used with next's `revalidateTag` and `updateTag` functions for custom webhook on-demand revalidation.
28
- */
29
- tags?: string[];
30
- }
31
- /**
32
- * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.
33
- */
34
- type DefinedSanityFetchType = <const QueryString extends string>(options: SanityFetchOptions<QueryString>) => Promise<{
35
- data: ClientReturn<QueryString, unknown>;
36
- /**
37
- * The Content Source Map can be used for custom setups like `encodeSourceMap` for `data-sanity` attributes, or `stegaEncodeSourceMap` for stega encoding in your own way.
38
- * The Content Source Map is only fetched by default in draft mode, if `stega` is `true`. Otherwise your client configuration will need to have `resultSourceMap: 'withKeyArraySelector' | true`
39
- */
40
- sourceMap: ContentSourceMap | null;
41
- /**
42
- * The cache tags used with `next/cache`, useful for debugging.
43
- */
44
- tags: string[];
45
- }>;
46
- /**
47
- * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.
48
- */
49
- interface DefinedSanityLiveProps {
50
- /**
51
- * Automatic refresh of RSC when the component <SanityLive /> is mounted.
52
- * @defaultValue `false`
53
- */
54
- refreshOnMount?: boolean;
55
- /**
56
- * Automatically refresh when window gets focused
57
- * @defaultValue `false`
58
- */
59
- refreshOnFocus?: boolean;
60
- /**
61
- * Automatically refresh when the browser regains a network connection (via navigator.onLine)
62
- * @defaultValue `false`
63
- */
64
- refreshOnReconnect?: boolean;
65
- /**
66
- * Automatically refresh on an interval when the Live Event API emits a `goaway` event, which indicates that the connection is rejected or closed.
67
- * This typically happens if the connection limit is reached, or if the connection is idle for too long.
68
- * To disable this long polling fallback behavior set `intervalOnGoAway` to `false` or `0`.
69
- * You can also use `onGoAway` to handle the `goaway` event in your own way, and read the reason why the event was emitted.
70
- * @defaultValue `30_000` 30 seconds interval
71
- */
72
- intervalOnGoAway?: number | false;
73
- /**
74
- * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
75
- * @see https://www.sanity.io/docs/reference-api-request-tags
76
- * @defaultValue 'next-loader.live'
77
- */
78
- requestTag?: string;
79
- /**
80
- * Handle errors from the Live Events subscription.
81
- * By default it's reported using `console.error`, you can override this prop to handle it in your own way.
82
- */
83
- onError?: (error: unknown) => void;
84
- /**
85
- * Handle the `goaway` event if the connection is rejected/closed.
86
- * `event.reason` will be a string of why the event was emitted, for example `'connection limit reached'`.
87
- * When this happens the `<SanityLive />` will fallback to long polling with a default interval of 30 seconds, providing your own `onGoAway` handler does not change this behavior.
88
- * If you want to disable long polling set `intervalOnGoAway` to `false` or `0`.
89
- */
90
- onGoAway?: (event: LiveEventGoAway, intervalOnGoAway: number | false) => void;
91
- /**
92
- * Override how cache tags are invalidated, you need to pass a server action here.
93
- * You can also pass a `use client` function here, and have `router.refresh()` be called if the promise resolves to `'refresh'`.
94
- */
95
- revalidateSyncTags?: (tags: `${typeof PUBLISHED_SYNC_TAG_PREFIX | typeof DRAFT_SYNC_TAG_PREFIX}${SyncTag}`[]) => Promise<void | "refresh">;
96
- /**
97
- * Control how the draft mode perspective is resolved, by default it resolves from the `sanity-preview-perspective` cookie.
98
- */
99
- resolveDraftModePerspective?: () => Promise<ClientPerspective>;
100
- }
101
- /**
102
- * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.
103
- */
104
- interface DefineSanityLiveOptions {
105
- /**
106
- * Required for `sanityFetch` and `SanityLive` to work
107
- */
108
- client: SanityClient;
109
- /**
110
- * Optional. If provided then the token needs to have permissions to query documents with `drafts.` prefixes in order for `perspective: 'drafts'` to work.
111
- * This token is not shared with the browser.
112
- */
113
- serverToken?: string | false;
114
- /**
115
- * Optional. This token is shared with the browser, and should only have access to query published documents.
116
- * It is used to setup a `Live Draft Content` EventSource connection, and enables live previewing drafts stand-alone, outside of Presentation Tool.
117
- */
118
- browserToken?: string | false;
119
- }
120
- /**
121
- * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.
122
- */
123
- declare function defineLive(config: DefineSanityLiveOptions): {
124
- /**
125
- * Use this function to fetch data from Sanity in your React Server Components.
7
+ * @deprecated use `fetch` instead, and define your own `sanityFetch` function with logic for when to toggle `stega` and `perspective`
126
8
  */
127
9
  sanityFetch: DefinedSanityFetchType;
128
10
  /**
129
- * Render this in your root layout.tsx to make your page revalidate on new content live, automatically.
11
+ * @deprecated use `Live` instead, and define your own `SanityLive` component with logic for when to toggle `perspective`
130
12
  */
131
13
  SanityLive: React.ComponentType<DefinedSanityLiveProps>;
132
14
  };
133
- export { type DefineSanityLiveOptions, type DefinedSanityFetchType, type DefinedSanityLiveProps, type SanityFetchOptions, defineLive, isCorsOriginError, resolvePerspectiveFromCookies };
15
+ export { type PerspectiveType as LivePerspective, defineLive, isCorsOriginError, resolvePerspectiveFromCookies };
134
16
  //# sourceMappingURL=live.next-js.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"live.next-js.d.ts","names":[],"sources":["../src/experimental/live.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqFiB,UAAA,kBAAA,CAAA,oBAAA,MAAA,CAAA,CAAA;EACR,KAAA,EAAA,WAAA;EACE,MAAA,CAAA,EAAA,WAAA;EAIa;;;EAqBxB,WAAY,CAAA,EArBI,OAqBJ,CArBY,iBAqBZ,EAAA,KAAA,CAAA;EACkB;;;;EAOjB,KAAA,CAAA,EAAA,OAAA;EANR;;AAgBL;;;EAoDuD,UAAA,CAAA,EAAA,MAAA;EAAwB;;;EAUzC,IAAA,CAAA,EAAA,MAAA,EAAA;;AAMtC;AAoBA;;AAIe,KA9GH,sBAAA,GA8GG,CAAA,0BAAA,MAAA,CAAA,CAAA,OAAA,EA7GJ,kBA6GI,CA7Ge,WA6Gf,CAAA,EAAA,GA5GV,OA4GU,CAAA;EAImB,IAAA,EA/G1B,YA+G0B,CA/Gb,WA+Ga,EAAA,OAAA,CAAA;EAApB;;;;aA1GD;;;;;;;;;UAUI,sBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4CI;;;;;wCAQD,mCAAmC,wBAAwB,gBACxE;;;;sCAS+B,QAAQ;;;;;UAM7B,uBAAA;;;;UAIP;;;;;;;;;;;;;;;iBAgBM,UAAA,SAAmB;;;;eAIpB;;;;cAID,KAAA,CAAM,cAAc"}
1
+ {"version":3,"file":"live.next-js.d.ts","names":[],"sources":["../src/experimental/live.tsx"],"sourcesContent":[],"mappings":";;iBAagB,UAAA,SAAmB;EAAnC,KAAgB,EACP,gBADO;EAAmB,IAAA,EAE3B,KAAA,CAAM,aAFqB,CAEP,gBAFO,CAAA;EAC1B;;;EAKM,WAAA,EAAA,sBAAA;EAImB;;;cAApB,KAAA,CAAM,cAAc"}
@@ -1,40 +1,12 @@
1
1
  import { t as isCorsOriginError } from "./isCorsOriginError.js";
2
2
  import { n as PUBLISHED_SYNC_TAG_PREFIX, t as DRAFT_SYNC_TAG_PREFIX } from "./constants.js";
3
3
  import { t as resolvePerspectiveFromCookies } from "./resolvePerspectiveFromCookies.js";
4
- import { cacheLife, cacheTag, updateTag } from "next/cache";
5
4
  import { cookies, draftMode } from "next/headers";
6
- import { stegaEncodeSourceMap } from "@sanity/client/stega";
5
+ import { Suspense } from "react";
7
6
  import { jsx } from "react/jsx-runtime";
8
- import { createClient } from "next-sanity";
9
7
  import SanityLiveClientComponent from "next-sanity/experimental/client-components/live";
8
+ import { cacheTag, updateTag } from "next/cache";
10
9
  import { preconnect } from "react-dom";
11
- async function sanityCachedFetch(config, { query, params = {}, perspective, stega, requestTag, draftToken, customCacheTags = [] }) {
12
- "use cache: remote";
13
- const client = createClient({
14
- ...config,
15
- useCdn: true
16
- });
17
- const useCdn = perspective === "published";
18
- const { result, resultSourceMap, syncTags } = await client.fetch(query, params, {
19
- filterResponse: false,
20
- returnQuery: false,
21
- perspective,
22
- useCdn,
23
- resultSourceMap: stega ? "withKeyArraySelector" : void 0,
24
- stega: false,
25
- cacheMode: useCdn ? "noStale" : void 0,
26
- tag: requestTag,
27
- token: perspective === "published" ? config.token : draftToken || config.token
28
- });
29
- const tags = [...customCacheTags, ...(syncTags || []).map((tag) => `${perspective === "published" ? PUBLISHED_SYNC_TAG_PREFIX : DRAFT_SYNC_TAG_PREFIX}${tag}`)];
30
- cacheTag(...tags);
31
- cacheLife({ revalidate: 3600 * 24 * 90 });
32
- return {
33
- data: result,
34
- sourceMap: resultSourceMap || null,
35
- tags
36
- };
37
- }
38
10
  function defineLive(config) {
39
11
  const { client: _client, serverToken, browserToken } = config;
40
12
  if (!_client) throw new Error("`client` is required for `defineLive` to function");
@@ -42,84 +14,69 @@ function defineLive(config) {
42
14
  if (process.env.NODE_ENV !== "production" && !browserToken && browserToken !== false) console.warn("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`.");
43
15
  const client = _client.withConfig({
44
16
  allowReconfigure: false,
45
- useCdn: false
17
+ useCdn: true
46
18
  });
47
- const { token: originalToken, apiHost, apiVersion, useProjectHostname, dataset, projectId, requestTagPrefix, stega: stegaConfig } = client.config();
19
+ const { token: originalToken } = client.config();
48
20
  return {
49
- sanityFetch: function sanityFetch({ query, params = {}, stega = false, perspective = "published", tags: customCacheTags = [], requestTag = "next-loader.fetch" }) {
50
- return sanityCachedFetch({
51
- apiHost,
52
- apiVersion,
53
- useProjectHostname,
54
- dataset,
55
- projectId,
56
- requestTagPrefix,
57
- token: originalToken
58
- }, {
59
- query,
60
- params,
21
+ fetch: async function fetch({ query, params = {}, perspective = "published", stega = false, tags: customCacheTags = [], requestTag = "next-loader.fetch.cache-components" }) {
22
+ const useCdn = perspective === "published";
23
+ const { result, resultSourceMap, syncTags } = await client.fetch(query, params, {
24
+ filterResponse: false,
25
+ returnQuery: false,
61
26
  perspective,
27
+ useCdn,
62
28
  stega,
63
- requestTag,
64
- draftToken: serverToken,
65
- customCacheTags
66
- }).then(({ data, sourceMap, tags }) => ({
67
- data: stega && sourceMap ? stegaEncodeSourceMap(data, sourceMap, {
68
- ...stegaConfig,
69
- enabled: true
70
- }) : data,
71
- sourceMap,
29
+ cacheMode: useCdn ? "noStale" : void 0,
30
+ tag: requestTag,
31
+ token: perspective === "published" ? originalToken : serverToken || originalToken
32
+ });
33
+ const tags = [...customCacheTags, ...(syncTags || []).map((tag) => `${perspective === "published" ? PUBLISHED_SYNC_TAG_PREFIX : DRAFT_SYNC_TAG_PREFIX}${tag}`)];
34
+ cacheTag(...tags);
35
+ return {
36
+ data: result,
37
+ sourceMap: resultSourceMap || null,
72
38
  tags
73
- }));
39
+ };
74
40
  },
75
- SanityLive: function SanityLive(props) {
76
- const { refreshOnMount = false, refreshOnFocus = false, refreshOnReconnect = false, requestTag, onError, onGoAway, intervalOnGoAway, revalidateSyncTags = expireTags } = props;
77
- const { projectId: projectId$1, dataset: dataset$1, apiHost: apiHost$1, apiVersion: apiVersion$1, useProjectHostname: useProjectHostname$1, requestTagPrefix: requestTagPrefix$1 } = client.config();
41
+ Live: function Live(props) {
42
+ const { perspective = "published", onChange, onChangeIncludingDrafts, onStudioPerspective, refreshOnMount = false, refreshOnFocus = false, refreshOnReconnect = false, requestTag = "next-loader.live.cache-components", onError, onGoAway, intervalOnGoAway } = props;
43
+ if (onChange) console.warn("`onChange` is not implemented yet");
44
+ if (onChangeIncludingDrafts) console.warn("`onChangeIncludingDrafts` is not implemented yet");
45
+ if (onStudioPerspective) console.warn("`onStudioPerspective` is not implemented yet");
46
+ const includeDrafts = typeof browserToken === "string" && perspective !== "published";
47
+ const { projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix } = client.config();
78
48
  const { origin } = new URL(client.getUrl("", false));
79
49
  preconnect(origin);
80
- return /* @__PURE__ */ jsx(SanityLiveServerComponent, {
50
+ return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(SanityLiveClientComponent, {
81
51
  config: {
82
- projectId: projectId$1,
83
- dataset: dataset$1,
84
- apiHost: apiHost$1,
85
- apiVersion: apiVersion$1,
86
- useProjectHostname: useProjectHostname$1,
87
- requestTagPrefix: requestTagPrefix$1
52
+ projectId,
53
+ dataset,
54
+ apiHost,
55
+ apiVersion,
56
+ useProjectHostname,
57
+ requestTagPrefix,
58
+ token: includeDrafts ? browserToken : void 0
88
59
  },
89
60
  requestTag,
90
- browserToken,
61
+ draftModeEnabled: includeDrafts,
91
62
  refreshOnMount,
92
63
  refreshOnFocus,
93
64
  refreshOnReconnect,
94
65
  onError,
95
66
  onGoAway,
96
67
  intervalOnGoAway,
97
- revalidateSyncTags,
98
- resolveDraftModePerspective: props.resolveDraftModePerspective ?? resolveDraftModePerspective
99
- });
68
+ revalidateSyncTags: expireTags,
69
+ resolveDraftModePerspective
70
+ }) });
71
+ },
72
+ sanityFetch: () => {
73
+ throw new Error("`defineLive().sanityFetch` is not available when `cacheComponents: true`, use `defineLive().fetch` instead");
74
+ },
75
+ SanityLive: () => {
76
+ throw new Error("`defineLive().SanityLive` is not available when `cacheComponents: true`, use `defineLive().Live` instead");
100
77
  }
101
78
  };
102
79
  }
103
- const SanityLiveServerComponent = async function SanityLiveServerComponent$1(props) {
104
- const { config, requestTag, intervalOnGoAway, onError, onGoAway, refreshOnFocus, refreshOnMount, refreshOnReconnect, revalidateSyncTags, browserToken, resolveDraftModePerspective: resolveDraftModePerspective$1 } = props;
105
- const { isEnabled: isDraftModeEnabled } = await draftMode();
106
- return /* @__PURE__ */ jsx(SanityLiveClientComponent, {
107
- config: {
108
- ...config,
109
- token: typeof browserToken === "string" && isDraftModeEnabled ? browserToken : void 0
110
- },
111
- requestTag,
112
- draftModeEnabled: isDraftModeEnabled,
113
- refreshOnMount,
114
- refreshOnFocus,
115
- refreshOnReconnect,
116
- onError,
117
- onGoAway,
118
- intervalOnGoAway,
119
- revalidateSyncTags,
120
- resolveDraftModePerspective: resolveDraftModePerspective$1
121
- });
122
- };
123
80
  async function expireTags(_tags) {
124
81
  "use server";
125
82
  if (!Array.isArray(_tags)) {
@@ -1 +1 @@
1
- {"version":3,"file":"live.next-js.js","names":["SanityLiveServerComponent: React.ComponentType<SanityLiveServerComponentProps>","SanityLiveServerComponent","resolveDraftModePerspective"],"sources":["../src/experimental/live.tsx"],"sourcesContent":["import {resolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\nimport {stegaEncodeSourceMap} from '@sanity/client/stega'\nimport {\n createClient,\n type ClientPerspective,\n type ClientReturn,\n type ContentSourceMap,\n type LiveEventGoAway,\n type QueryParams,\n type SanityClient,\n type SyncTag,\n} from 'next-sanity'\nimport SanityLiveClientComponent, {\n type SanityLiveProps,\n} from 'next-sanity/experimental/client-components/live'\nimport {cacheTag, cacheLife, updateTag} from 'next/cache'\nimport {draftMode, cookies} from 'next/headers'\nimport {preconnect} from 'react-dom'\n\nimport type {SanityClientConfig} from './types'\n\nimport {DRAFT_SYNC_TAG_PREFIX, PUBLISHED_SYNC_TAG_PREFIX} from './constants'\n\nasync function sanityCachedFetch<const QueryString extends string>(\n config: SanityClientConfig,\n {\n query,\n params = {},\n perspective,\n stega,\n requestTag,\n draftToken,\n customCacheTags = [],\n }: {\n query: QueryString\n params?: QueryParams\n perspective: Exclude<ClientPerspective, 'raw'>\n stega: boolean\n requestTag: string\n draftToken?: string | false | undefined\n customCacheTags?: string[]\n },\n): Promise<{\n data: ClientReturn<QueryString, unknown>\n sourceMap: ContentSourceMap | null\n tags: string[]\n}> {\n 'use cache: remote'\n\n const client = createClient({...config, useCdn: true})\n const useCdn = perspective === 'published'\n\n const {result, resultSourceMap, syncTags} = await client.fetch(query, params, {\n filterResponse: false,\n returnQuery: false,\n perspective,\n useCdn,\n resultSourceMap: stega ? 'withKeyArraySelector' : undefined, // @TODO allow passing csm for non-stega use\n stega: false,\n cacheMode: useCdn ? 'noStale' : undefined,\n tag: requestTag,\n token: perspective === 'published' ? config.token : draftToken || config.token, // @TODO can pass undefined instead of config.token here?\n })\n const tags = [\n ...customCacheTags,\n ...(syncTags || []).map(\n (tag) =>\n `${perspective === 'published' ? PUBLISHED_SYNC_TAG_PREFIX : DRAFT_SYNC_TAG_PREFIX}${tag}`,\n ),\n ]\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 */\n cacheLife({revalidate: 60 * 60 * 24 * 90})\n\n return {data: result, sourceMap: resultSourceMap || null, tags}\n}\n\n/**\n * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.\n */\nexport interface SanityFetchOptions<QueryString extends string> {\n query: QueryString\n params?: QueryParams\n /**\n * @defaultValue 'published'\n */\n perspective?: Exclude<ClientPerspective, 'raw'>\n /**\n * Enables stega encoding of the data, this is typically only used in draft mode in conjunction with `perspective: 'drafts'` and with `@sanity/visual-editing` setup.\n * @defaultValue `false`\n */\n stega?: boolean\n /**\n * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.\n * @see https://www.sanity.io/docs/reference-api-request-tags\n * @defaultValue 'next-loader.fetch'\n */\n requestTag?: string\n /**\n * Custom cache tags that can be used with next's `revalidateTag` and `updateTag` functions for custom webhook on-demand revalidation.\n */\n tags?: string[]\n}\n\n/**\n * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.\n */\nexport type DefinedSanityFetchType = <const QueryString extends string>(\n options: SanityFetchOptions<QueryString>,\n) => Promise<{\n data: ClientReturn<QueryString, unknown>\n /**\n * The Content Source Map can be used for custom setups like `encodeSourceMap` for `data-sanity` attributes, or `stegaEncodeSourceMap` for stega encoding in your own way.\n * The Content Source Map is only fetched by default in draft mode, if `stega` is `true`. Otherwise your client configuration will need to have `resultSourceMap: 'withKeyArraySelector' | true`\n */\n sourceMap: ContentSourceMap | null\n /**\n * The cache tags used with `next/cache`, useful for debugging.\n */\n tags: string[]\n}>\n\n/**\n * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.\n */\nexport interface DefinedSanityLiveProps {\n /**\n * Automatic refresh of RSC when the component <SanityLive /> is mounted.\n * @defaultValue `false`\n */\n refreshOnMount?: boolean\n /**\n * Automatically refresh when window gets focused\n * @defaultValue `false`\n */\n refreshOnFocus?: boolean\n /**\n * Automatically refresh when the browser regains a network connection (via navigator.onLine)\n * @defaultValue `false`\n */\n refreshOnReconnect?: boolean\n /**\n * Automatically refresh on an interval when the Live Event API emits a `goaway` event, which indicates that the connection is rejected or closed.\n * This typically happens if the connection limit is reached, or if the connection is idle for too long.\n * To disable this long polling fallback behavior set `intervalOnGoAway` to `false` or `0`.\n * You can also use `onGoAway` to handle the `goaway` event in your own way, and read the reason why the event was emitted.\n * @defaultValue `30_000` 30 seconds interval\n */\n intervalOnGoAway?: number | false\n\n /**\n * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.\n * @see https://www.sanity.io/docs/reference-api-request-tags\n * @defaultValue 'next-loader.live'\n */\n requestTag?: string\n\n /**\n * Handle errors from the Live Events subscription.\n * By default it's reported using `console.error`, you can override this prop to handle it in your own way.\n */\n onError?: (error: unknown) => void\n\n /**\n * Handle the `goaway` event if the connection is rejected/closed.\n * `event.reason` will be a string of why the event was emitted, for example `'connection limit reached'`.\n * When this happens the `<SanityLive />` will fallback to long polling with a default interval of 30 seconds, providing your own `onGoAway` handler does not change this behavior.\n * If you want to disable long polling set `intervalOnGoAway` to `false` or `0`.\n */\n onGoAway?: (event: LiveEventGoAway, intervalOnGoAway: number | false) => void\n\n /**\n * Override how cache tags are invalidated, you need to pass a server action here.\n * You can also pass a `use client` function here, and have `router.refresh()` be called if the promise resolves to `'refresh'`.\n */\n // @TODO remove, replace with onLiveEvent\n revalidateSyncTags?: (\n tags: `${typeof PUBLISHED_SYNC_TAG_PREFIX | typeof DRAFT_SYNC_TAG_PREFIX}${SyncTag}`[],\n ) => Promise<void | 'refresh'>\n\n // @TODO add\n // decide how to handle a live event coming in\n // onLiveEvent?: (event: LiveEvent, mode: 'production' | 'preview) => void\n\n /**\n * Control how the draft mode perspective is resolved, by default it resolves from the `sanity-preview-perspective` cookie.\n */\n resolveDraftModePerspective?: () => Promise<ClientPerspective>\n}\n\n/**\n * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.\n */\nexport interface DefineSanityLiveOptions {\n /**\n * Required for `sanityFetch` and `SanityLive` to work\n */\n client: SanityClient\n /**\n * Optional. If provided then the token needs to have permissions to query documents with `drafts.` prefixes in order for `perspective: 'drafts'` to work.\n * This token is not shared with the browser.\n */\n serverToken?: string | false\n /**\n * Optional. This token is shared with the browser, and should only have access to query published documents.\n * It is used to setup a `Live Draft Content` EventSource connection, and enables live previewing drafts stand-alone, outside of Presentation Tool.\n */\n browserToken?: string | false\n}\n\n/**\n * @alpha CAUTION: This API does not follow semver and could have breaking changes in future minor releases.\n */\nexport function defineLive(config: DefineSanityLiveOptions): {\n /**\n * Use this function to fetch data from Sanity in your React Server Components.\n */\n sanityFetch: DefinedSanityFetchType\n /**\n * Render this in your root layout.tsx to make your page revalidate on new content live, automatically.\n */\n SanityLive: React.ComponentType<DefinedSanityLiveProps>\n} {\n const {client: _client, serverToken, browserToken} = 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 {\n token: originalToken,\n apiHost,\n apiVersion,\n useProjectHostname,\n dataset,\n projectId,\n requestTagPrefix,\n stega: stegaConfig,\n } = client.config()\n\n const sanityFetch: DefinedSanityFetchType = function sanityFetch<\n const QueryString extends string,\n >({\n query,\n params = {},\n stega = false,\n perspective = 'published',\n tags: customCacheTags = [],\n requestTag = 'next-loader.fetch',\n }: {\n query: QueryString\n params?: QueryParams\n stega?: boolean\n tags?: string[]\n perspective?: Exclude<ClientPerspective, 'raw'>\n requestTag?: string\n }) {\n return sanityCachedFetch(\n {\n apiHost,\n apiVersion,\n useProjectHostname,\n dataset,\n projectId,\n requestTagPrefix,\n token: originalToken,\n },\n {\n query,\n params,\n perspective,\n stega,\n requestTag,\n draftToken: serverToken,\n customCacheTags,\n },\n ).then(({data, sourceMap, tags}) => ({\n data:\n stega && sourceMap\n ? stegaEncodeSourceMap(data, sourceMap, {...stegaConfig, enabled: true})\n : data,\n sourceMap,\n tags,\n }))\n }\n\n const SanityLive: React.ComponentType<DefinedSanityLiveProps> = function SanityLive(props) {\n const {\n // perspective,\n refreshOnMount = false,\n refreshOnFocus = false,\n refreshOnReconnect = false,\n requestTag,\n onError,\n onGoAway,\n intervalOnGoAway,\n revalidateSyncTags = expireTags,\n } = props\n\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n const {origin} = new URL(client.getUrl('', false))\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 preconnect(origin)\n\n return (\n <SanityLiveServerComponent\n config={{projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix}}\n requestTag={requestTag}\n browserToken={browserToken}\n // origin={origin}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n onError={onError}\n onGoAway={onGoAway}\n intervalOnGoAway={intervalOnGoAway}\n revalidateSyncTags={revalidateSyncTags}\n resolveDraftModePerspective={\n props.resolveDraftModePerspective ?? resolveDraftModePerspective\n }\n />\n )\n }\n\n return {sanityFetch, SanityLive}\n}\n\ninterface SanityLiveServerComponentProps extends Omit<\n SanityLiveProps,\n 'draftModeEnabled' | 'token' | 'draftModePerspective'\n> {\n browserToken: string | false | undefined\n // origin: string\n // perspective?: Exclude<ClientPerspective, 'raw'>\n}\n\nconst SanityLiveServerComponent: React.ComponentType<SanityLiveServerComponentProps> =\n async function SanityLiveServerComponent(props) {\n // 'use cache'\n // @TODO should this be 'max' instead?, or configured by changing the default cache profile?\n // cacheLife({\n // stale: Infinity,\n // revalidate: Infinity,\n // expire: Infinity,\n // })\n const {\n config,\n requestTag,\n intervalOnGoAway,\n onError,\n onGoAway,\n refreshOnFocus,\n refreshOnMount,\n refreshOnReconnect,\n revalidateSyncTags,\n browserToken,\n // origin,\n // perspective,\n resolveDraftModePerspective,\n } = props\n\n const {isEnabled: isDraftModeEnabled} = await draftMode()\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 // preconnect(origin)\n\n return (\n <SanityLiveClientComponent\n config={{\n ...config,\n token: typeof browserToken === 'string' && isDraftModeEnabled ? browserToken : undefined,\n }}\n requestTag={requestTag}\n draftModeEnabled={isDraftModeEnabled}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n onError={onError}\n onGoAway={onGoAway}\n intervalOnGoAway={intervalOnGoAway}\n revalidateSyncTags={revalidateSyncTags}\n resolveDraftModePerspective={resolveDraftModePerspective}\n />\n )\n }\n\n// @TODO expose parseTags function that returns the correct array of tags\n// we already have s1: prefixes, but they could change\n// use sp: for prod, sd: for draft, keep em short\nasync function expireTags(_tags: unknown): Promise<void> {\n 'use server'\n // @TODO Draft Mode bypasses cache anyway so we don't bother with expiring tags for draft content\n // const isDraftMode = (await draftMode()).isEnabled\n // const tags = _tags.map((tag) => `${isDraftMode ? 'drafts' : 'sanity'}:${tag}`)\n if (!Array.isArray(_tags)) {\n console.warn('<SanityLive /> `expireTags` called with non-array tags', _tags)\n return undefined\n }\n const tags = _tags.filter(\n (tag) => typeof tag === 'string' && tag.startsWith(PUBLISHED_SYNC_TAG_PREFIX),\n )\n if (!tags.length) {\n console.warn('<SanityLive /> `expireTags` called with no valid tags', _tags)\n return undefined\n }\n for (const tag of tags) {\n updateTag(tag)\n }\n // oxlint-disable-next-line no-console\n console.log(`<SanityLive /> updated tags: ${tags.join(', ')}`)\n}\n\nasync function resolveDraftModePerspective(): Promise<ClientPerspective> {\n 'use server'\n if ((await draftMode()).isEnabled) {\n const jar = await cookies()\n return resolvePerspectiveFromCookies({cookies: jar})\n }\n return 'published'\n}\n\n// revalidateSyncTags => actionUpdateTags\n// router.refresh() => actionRefresh\n"],"mappings":";;;;;;;;;;AAuBA,eAAe,kBACb,QACA,EACE,OACA,SAAS,EAAE,EACX,aACA,OACA,YACA,YACA,kBAAkB,EAAE,IAcrB;AACD;CAEA,MAAM,SAAS,aAAa;EAAC,GAAG;EAAQ,QAAQ;EAAK,CAAC;CACtD,MAAM,SAAS,gBAAgB;CAE/B,MAAM,EAAC,QAAQ,iBAAiB,aAAY,MAAM,OAAO,MAAM,OAAO,QAAQ;EAC5E,gBAAgB;EAChB,aAAa;EACb;EACA;EACA,iBAAiB,QAAQ,yBAAyB,KAAA;EAClD,OAAO;EACP,WAAW,SAAS,YAAY,KAAA;EAChC,KAAK;EACL,OAAO,gBAAgB,cAAc,OAAO,QAAQ,cAAc,OAAO;EAC1E,CAAC;CACF,MAAM,OAAO,CACX,GAAG,iBACH,IAAI,YAAY,EAAE,EAAE,KACjB,QACC,GAAG,gBAAgB,cAAc,4BAA4B,wBAAwB,MACxF,CACF;AAID,UAAS,GAAG,KAAK;AAIjB,WAAU,EAAC,YAAY,OAAU,KAAK,IAAG,CAAC;AAE1C,QAAO;EAAC,MAAM;EAAQ,WAAW,mBAAmB;EAAM;EAAK;;AA2IjE,SAAgB,WAAW,QASzB;CACA,MAAM,EAAC,QAAQ,SAAS,aAAa,iBAAgB;AAErD,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,EACJ,OAAO,eACP,SACA,YACA,oBACA,SACA,WACA,kBACA,OAAO,gBACL,OAAO,QAAQ;AAwFnB,QAAO;EAAC,aAtFoC,SAAS,YAEnD,EACA,OACA,SAAS,EAAE,EACX,QAAQ,OACR,cAAc,aACd,MAAM,kBAAkB,EAAE,EAC1B,aAAa,uBAQZ;AACD,UAAO,kBACL;IACE;IACA;IACA;IACA;IACA;IACA;IACA,OAAO;IACR,EACD;IACE;IACA;IACA;IACA;IACA;IACA,YAAY;IACZ;IACD,CACF,CAAC,MAAM,EAAC,MAAM,WAAW,YAAW;IACnC,MACE,SAAS,YACL,qBAAqB,MAAM,WAAW;KAAC,GAAG;KAAa,SAAS;KAAK,CAAC,GACtE;IACN;IACA;IACD,EAAE;;EA2CgB,YAxC2C,SAAS,WAAW,OAAO;GACzF,MAAM,EAEJ,iBAAiB,OACjB,iBAAiB,OACjB,qBAAqB,OACrB,YACA,SACA,UACA,kBACA,qBAAqB,eACnB;GAEJ,MAAM,EAAC,WAAA,aAAW,SAAA,WAAS,SAAA,WAAS,YAAA,cAAY,oBAAA,sBAAoB,kBAAA,uBAClE,OAAO,QAAQ;GACjB,MAAM,EAAC,WAAU,IAAI,IAAI,OAAO,OAAO,IAAI,MAAM,CAAC;AAGlD,cAAW,OAAO;AAElB,UACE,oBAAC,2BAAA;IACC,QAAQ;KAAC,WAAA;KAAW,SAAA;KAAS,SAAA;KAAS,YAAA;KAAY,oBAAA;KAAoB,kBAAA;KAAiB;IAC3E;IACE;IAEE;IACA;IACI;IACX;IACC;IACQ;IACE;IACpB,6BACE,MAAM,+BAA+B;KAEvC;;EAI0B;;AAYlC,MAAMA,4BACJ,eAAeC,4BAA0B,OAAO;CAQ9C,MAAM,EACJ,QACA,YACA,kBACA,SACA,UACA,gBACA,gBACA,oBACA,oBACA,cAGA,6BAAA,kCACE;CAEJ,MAAM,EAAC,WAAW,uBAAsB,MAAM,WAAW;AAKzD,QACE,oBAAC,2BAAA;EACC,QAAQ;GACN,GAAG;GACH,OAAO,OAAO,iBAAiB,YAAY,qBAAqB,eAAe,KAAA;GAChF;EACW;EACZ,kBAAkB;EACF;EACA;EACI;EACX;EACC;EACQ;EACE;EACpB,6BAA6BC;GAC7B;;AAOR,eAAe,WAAW,OAA+B;AACvD;AAIA,KAAI,CAAC,MAAM,QAAQ,MAAM,EAAE;AACzB,UAAQ,KAAK,0DAA0D,MAAM;AAC7E;;CAEF,MAAM,OAAO,MAAM,QAChB,QAAQ,OAAO,QAAQ,YAAY,IAAI,WAAW,0BAA0B,CAC9E;AACD,KAAI,CAAC,KAAK,QAAQ;AAChB,UAAQ,KAAK,yDAAyD,MAAM;AAC5E;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAGhB,SAAQ,IAAI,gCAAgC,KAAK,KAAK,KAAK,GAAG;;AAGhE,eAAe,8BAA0D;AACvE;AACA,MAAK,MAAM,WAAW,EAAE,UAEtB,QAAO,8BAA8B,EAAC,SAD1B,MAAM,SAAS,EACwB,CAAC;AAEtD,QAAO"}
1
+ {"version":3,"file":"live.next-js.js","names":[],"sources":["../src/experimental/live.tsx"],"sourcesContent":["import type {DefinedFetchType, DefinedLiveProps, LiveOptions, PerspectiveType} from '#live/types'\n\nimport {resolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\nimport SanityLiveClientComponent from 'next-sanity/experimental/client-components/live'\nimport {cacheTag, updateTag} from 'next/cache'\nimport {draftMode, cookies} from 'next/headers'\nimport {Suspense} from 'react'\nimport {preconnect} from 'react-dom'\n\nimport type {DefinedSanityFetchType, DefinedSanityLiveProps} from '../live/defineLive'\n\nimport {DRAFT_SYNC_TAG_PREFIX, PUBLISHED_SYNC_TAG_PREFIX} from './constants'\n\nexport function defineLive(config: LiveOptions): {\n fetch: DefinedFetchType\n Live: React.ComponentType<DefinedLiveProps>\n /**\n * @deprecated use `fetch` instead, and define your own `sanityFetch` function with logic for when to toggle `stega` and `perspective`\n */\n sanityFetch: DefinedSanityFetchType\n /**\n * @deprecated use `Live` instead, and define your own `SanityLive` component with logic for when to toggle `perspective`\n */\n SanityLive: React.ComponentType<DefinedSanityLiveProps>\n} {\n const {client: _client, serverToken, browserToken} = 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} = client.config()\n\n const fetch: DefinedFetchType = async function fetch({\n query,\n params = {},\n perspective = 'published',\n stega = false,\n tags: customCacheTags = [],\n requestTag = 'next-loader.fetch.cache-components',\n }) {\n const useCdn = perspective === 'published'\n\n const {result, resultSourceMap, syncTags} = await client.fetch(query, params, {\n filterResponse: false,\n returnQuery: false,\n perspective,\n useCdn,\n stega,\n cacheMode: useCdn ? 'noStale' : undefined,\n tag: requestTag,\n token: perspective === 'published' ? originalToken : serverToken || originalToken, // @TODO can pass undefined instead of config.token here?\n })\n const tags = [\n ...customCacheTags,\n ...(syncTags || []).map(\n (tag) =>\n `${perspective === 'published' ? PUBLISHED_SYNC_TAG_PREFIX : DRAFT_SYNC_TAG_PREFIX}${tag}`,\n ),\n ]\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 */\n // cacheLife({revalidate: 60 * 60 * 24 * 90})\n\n return {data: result, sourceMap: resultSourceMap || null, tags}\n\n // return sanityCachedFetch(\n // {\n // apiHost,\n // apiVersion,\n // useProjectHostname,\n // dataset,\n // projectId,\n // requestTagPrefix,\n // token: originalToken,\n // },\n // {\n // query,\n // params,\n // perspective,\n // stega,\n // requestTag,\n // draftToken: serverToken,\n // customCacheTags,\n // },\n // ).then(({data, sourceMap, tags}) => ({\n // data:\n // stega && sourceMap\n // ? stegaEncodeSourceMap(data, sourceMap, {...stegaConfig, enabled: true})\n // : data,\n // sourceMap,\n // tags,\n // }))\n }\n\n const Live: React.ComponentType<DefinedLiveProps> = function Live(props) {\n const {\n perspective = 'published',\n onChange,\n onChangeIncludingDrafts,\n onStudioPerspective,\n refreshOnMount = false,\n refreshOnFocus = false,\n refreshOnReconnect = false,\n requestTag = 'next-loader.live.cache-components',\n onError,\n onGoAway,\n intervalOnGoAway,\n } = props\n\n if (onChange) {\n console.warn('`onChange` is not implemented yet')\n }\n if (onChangeIncludingDrafts) {\n console.warn('`onChangeIncludingDrafts` is not implemented yet')\n }\n if (onStudioPerspective) {\n console.warn('`onStudioPerspective` is not implemented yet')\n }\n\n const includeDrafts = typeof browserToken === 'string' && perspective !== 'published'\n\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n const {origin} = new URL(client.getUrl('', false))\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 preconnect(origin)\n\n return (\n <Suspense>\n <SanityLiveClientComponent\n config={{\n projectId,\n dataset,\n apiHost,\n apiVersion,\n useProjectHostname,\n requestTagPrefix,\n token: includeDrafts ? browserToken : undefined,\n }}\n requestTag={requestTag}\n // origin={origin}\n draftModeEnabled={includeDrafts}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n onError={onError}\n onGoAway={onGoAway}\n intervalOnGoAway={intervalOnGoAway}\n revalidateSyncTags={expireTags}\n resolveDraftModePerspective={resolveDraftModePerspective}\n />\n </Suspense>\n )\n }\n\n return {\n fetch,\n Live,\n sanityFetch: () => {\n throw new Error(\n '`defineLive().sanityFetch` is not available when `cacheComponents: true`, use `defineLive().fetch` instead',\n )\n },\n SanityLive: () => {\n throw new Error(\n '`defineLive().SanityLive` is not available when `cacheComponents: true`, use `defineLive().Live` instead',\n )\n },\n }\n}\n\n// @TODO expose parseTags function that returns the correct array of tags\n// we already have s1: prefixes, but they could change\n// use sp: for prod, sd: for draft, keep em short\nasync function expireTags(_tags: unknown): Promise<void> {\n 'use server'\n // @TODO Draft Mode bypasses cache anyway so we don't bother with expiring tags for draft content\n // const isDraftMode = (await draftMode()).isEnabled\n // const tags = _tags.map((tag) => `${isDraftMode ? 'drafts' : 'sanity'}:${tag}`)\n if (!Array.isArray(_tags)) {\n console.warn('<SanityLive /> `expireTags` called with non-array tags', _tags)\n return undefined\n }\n const tags = _tags.filter(\n (tag) => typeof tag === 'string' && tag.startsWith(PUBLISHED_SYNC_TAG_PREFIX),\n )\n if (!tags.length) {\n console.warn('<SanityLive /> `expireTags` called with no valid tags', _tags)\n return undefined\n }\n for (const tag of tags) {\n updateTag(tag)\n }\n // oxlint-disable-next-line no-console\n console.log(`<SanityLive /> updated tags: ${tags.join(', ')}`)\n}\n\nasync function resolveDraftModePerspective(): Promise<PerspectiveType> {\n 'use server'\n if ((await draftMode()).isEnabled) {\n const jar = await cookies()\n return resolvePerspectiveFromCookies({cookies: jar})\n }\n return 'published'\n}\n\n// revalidateSyncTags => actionUpdateTags\n// router.refresh() => actionRefresh\n"],"mappings":";;;;;;;;;AAaA,SAAgB,WAAW,QAWzB;CACA,MAAM,EAAC,QAAQ,SAAS,aAAa,iBAAgB;AAErD,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,kBAAiB,OAAO,QAAQ;AAmI9C,QAAO;EACL,OAlI8B,eAAe,MAAM,EACnD,OACA,SAAS,EAAE,EACX,cAAc,aACd,QAAQ,OACR,MAAM,kBAAkB,EAAE,EAC1B,aAAa,wCACZ;GACD,MAAM,SAAS,gBAAgB;GAE/B,MAAM,EAAC,QAAQ,iBAAiB,aAAY,MAAM,OAAO,MAAM,OAAO,QAAQ;IAC5E,gBAAgB;IAChB,aAAa;IACb;IACA;IACA;IACA,WAAW,SAAS,YAAY,KAAA;IAChC,KAAK;IACL,OAAO,gBAAgB,cAAc,gBAAgB,eAAe;IACrE,CAAC;GACF,MAAM,OAAO,CACX,GAAG,iBACH,IAAI,YAAY,EAAE,EAAE,KACjB,QACC,GAAG,gBAAgB,cAAc,4BAA4B,wBAAwB,MACxF,CACF;AAID,YAAS,GAAG,KAAK;AAMjB,UAAO;IAAC,MAAM;IAAQ,WAAW,mBAAmB;IAAM;IAAK;;EA+F/D,MAhEkD,SAAS,KAAK,OAAO;GACvE,MAAM,EACJ,cAAc,aACd,UACA,yBACA,qBACA,iBAAiB,OACjB,iBAAiB,OACjB,qBAAqB,OACrB,aAAa,qCACb,SACA,UACA,qBACE;AAEJ,OAAI,SACF,SAAQ,KAAK,oCAAoC;AAEnD,OAAI,wBACF,SAAQ,KAAK,mDAAmD;AAElE,OAAI,oBACF,SAAQ,KAAK,+CAA+C;GAG9D,MAAM,gBAAgB,OAAO,iBAAiB,YAAY,gBAAgB;GAE1E,MAAM,EAAC,WAAW,SAAS,SAAS,YAAY,oBAAoB,qBAClE,OAAO,QAAQ;GACjB,MAAM,EAAC,WAAU,IAAI,IAAI,OAAO,OAAO,IAAI,MAAM,CAAC;AAGlD,cAAW,OAAO;AAElB,UACE,oBAAC,UAAA,EAAA,UACC,oBAAC,2BAAA;IACC,QAAQ;KACN;KACA;KACA;KACA;KACA;KACA;KACA,OAAO,gBAAgB,eAAe,KAAA;KACvC;IACW;IAEZ,kBAAkB;IACF;IACA;IACI;IACX;IACC;IACQ;IAClB,oBAAoB;IACS;KAC7B,EAAA,CACO;;EAOb,mBAAmB;AACjB,SAAM,IAAI,MACR,6GACD;;EAEH,kBAAkB;AAChB,SAAM,IAAI,MACR,2GACD;;EAEJ;;AAMH,eAAe,WAAW,OAA+B;AACvD;AAIA,KAAI,CAAC,MAAM,QAAQ,MAAM,EAAE;AACzB,UAAQ,KAAK,0DAA0D,MAAM;AAC7E;;CAEF,MAAM,OAAO,MAAM,QAChB,QAAQ,OAAO,QAAQ,YAAY,IAAI,WAAW,0BAA0B,CAC9E;AACD,KAAI,CAAC,KAAK,QAAQ;AAChB,UAAQ,KAAK,yDAAyD,MAAM;AAC5E;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAGhB,SAAQ,IAAI,gCAAgC,KAAK,KAAK,KAAK,GAAG;;AAGhE,eAAe,8BAAwD;AACrE;AACA,MAAK,MAAM,WAAW,EAAE,UAEtB,QAAO,8BAA8B,EAAC,SAD1B,MAAM,SAAS,EACwB,CAAC;AAEtD,QAAO"}
@@ -1,4 +1,3 @@
1
1
  import { t as isCorsOriginError } from "./isCorsOriginError.js";
2
- import { i as defineLive, n as DefinedSanityFetchType, r as DefinedSanityLiveProps, t as DefineSanityLiveOptions } from "./defineLive.js";
3
- import { n as resolvePerspectiveFromCookies } from "./resolvePerspectiveFromCookies.js";
4
- export { type DefineSanityLiveOptions, type DefinedSanityFetchType, type DefinedSanityLiveProps, defineLive, isCorsOriginError, resolvePerspectiveFromCookies };
2
+ import { c as PerspectiveType, i as defineLive, u as resolvePerspectiveFromCookies } from "./defineLive.js";
3
+ export { type PerspectiveType as LivePerspective, defineLive, isCorsOriginError, resolvePerspectiveFromCookies };
@@ -61,7 +61,7 @@ function defineLive(config) {
61
61
  };
62
62
  },
63
63
  SanityLive: async function SanityLive(props) {
64
- const { refreshOnMount, refreshOnFocus, refreshOnReconnect, tag, requestTag = tag, onError, onGoAway, intervalOnGoAway, revalidateSyncTags } = props;
64
+ const { refreshOnMount, refreshOnFocus, refreshOnReconnect, requestTag, onError, onGoAway, intervalOnGoAway, revalidateSyncTags } = props;
65
65
  const { projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix } = client.config();
66
66
  const { isEnabled: isDraftModeEnabled } = await draftMode();
67
67
  const { origin } = new URL(client.getUrl("", false));
@@ -1 +1 @@
1
- {"version":3,"file":"live.react-server.js","names":["tag"],"sources":["../src/live/resolveCookiePerspective.ts","../src/live/defineLive.tsx"],"sourcesContent":["import type {ClientPerspective} from '@sanity/client'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {cookies, draftMode} from 'next/headers'\n\n/**\n * @internal\n */\nexport async function resolveCookiePerspective(): 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 : 'published'\n}\n","import {\n type ClientPerspective,\n type ClientReturn,\n type ContentSourceMap,\n type LiveEventGoAway,\n type QueryParams,\n type SanityClient,\n type SyncTag,\n} from '@sanity/client'\nimport SanityLiveClientComponent from 'next-sanity/live/client-components/live'\nimport {draftMode} from 'next/headers'\nimport {prefetchDNS, preconnect} from 'react-dom'\n\nimport {resolveCookiePerspective} from './resolveCookiePerspective'\n\n/**\n * @public\n */\nexport type DefinedSanityFetchType = <const QueryString extends string>(options: {\n query: QueryString\n params?: QueryParams | Promise<QueryParams>\n /**\n * Add custom `next.tags` to the underlying fetch request.\n * @see https://nextjs.org/docs/app/api-reference/functions/fetch#optionsnexttags\n * This can be used in conjunction with custom fallback revalidation strategies, as well as with custom Server Actions that mutate data and want to render with fresh data right away (faster than the Live Event latency).\n * @defaultValue `['sanity']`\n */\n tags?: string[]\n perspective?: Exclude<ClientPerspective, 'raw'>\n stega?: boolean\n /**\n * @deprecated use `requestTag` instead\n */\n tag?: never\n /**\n * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.\n * @see https://www.sanity.io/docs/reference-api-request-tags\n * @defaultValue 'next-loader.fetch'\n */\n requestTag?: string\n}) => Promise<{\n data: ClientReturn<QueryString>\n sourceMap: ContentSourceMap | null\n tags: string[]\n}>\n\n/**\n * @public\n */\nexport interface DefinedSanityLiveProps {\n /**\n * Automatic refresh of RSC when the component <SanityLive /> is mounted.\n * Note that this is different from revalidation, which is based on tags and causes `sanityFetch` calls to be re-fetched.\n * @defaultValue `true`\n */\n refreshOnMount?: boolean\n /**\n * Automatically refresh when window gets focused\n * Note that this is different from revalidation, which is based on tags and causes `sanityFetch` calls to be re-fetched.\n * @defaultValue `false` if draftMode().isEnabled, otherwise `true` if not inside an iframe\n */\n refreshOnFocus?: boolean\n /**\n * Automatically refresh when the browser regains a network connection (via navigator.onLine)\n * Note that this is different from revalidation, which is based on tags and causes `sanityFetch` calls to be re-fetched.\n * @defaultValue `true`\n */\n refreshOnReconnect?: boolean\n /**\n * Automatically refresh on an interval when the Live Event API emits a `goaway` event, which indicates that the connection is rejected or closed.\n * This typically happens if the connection limit is reached, or if the connection is idle for too long.\n * To disable this long polling fallback behavior set `intervalOnGoAway` to `false` or `0`.\n * You can also use `onGoAway` to handle the `goaway` event in your own way, and read the reason why the event was emitted.\n * @defaultValue `30_000` 30 seconds interval\n */\n intervalOnGoAway?: number | false\n\n /**\n * @deprecated use `requestTag` instead\n */\n tag?: never\n\n /**\n * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.\n * @see https://www.sanity.io/docs/reference-api-request-tags\n * @defaultValue 'next-loader.live'\n */\n requestTag?: string\n\n /**\n * Handle errors from the Live Events subscription.\n * By default it's reported using `console.error`, you can override this prop to handle it in your own way.\n */\n onError?: (error: unknown) => void\n\n /**\n * Handle the `goaway` event if the connection is rejected/closed.\n * `event.reason` will be a string of why the event was emitted, for example `'connection limit reached'`.\n * When this happens the `<SanityLive />` will fallback to long polling with a default interval of 30 seconds, providing your own `onGoAway` handler does not change this behavior.\n * If you want to disable long polling set `intervalOnGoAway` to `false` or `0`.\n */\n onGoAway?: (event: LiveEventGoAway, intervalOnGoAway: number | false) => void\n\n /**\n * Override how cache tags are invalidated, you need to pass a server action here.\n * You can also pass a `use client` function here, and have `router.refresh()` be called if the promise resolves to `'refresh'`.\n */\n revalidateSyncTags?: (tags: SyncTag[]) => Promise<void | 'refresh'>\n}\n\n/**\n * @public\n */\nexport interface DefineSanityLiveOptions {\n /**\n * Required for `sanityFetch` and `SanityLive` to work\n */\n client: SanityClient\n /**\n * Optional. If provided then the token needs to have permissions to query documents with `drafts.` prefixes in order for `perspective: 'drafts'` to work.\n * This token is not shared with the browser.\n */\n serverToken?: string | false\n /**\n * Optional. This token is shared with the browser, and should only have access to query published documents.\n * It is used to setup a `Live Draft Content` EventSource connection, and enables live previewing drafts stand-alone, outside of Presentation Tool.\n */\n browserToken?: string | false\n /**\n * Fetch options used by `sanityFetch`\n */\n fetchOptions?: {\n /**\n * Optional, enables time based revalidation in addition to the EventSource connection.\n * @defaultValue `false`\n */\n revalidate?: number | false\n }\n /**\n * Optional. Include stega encoding when draft mode is enabled.\n * @defaultValue `true`\n */\n stega?: boolean\n}\n\n// export type VerifyPreviewSecretType = (\n// secret: string,\n// ) => Promise<{isValid: boolean; studioUrl: string | null}>\n\n/**\n * @public\n */\nexport function defineLive(config: DefineSanityLiveOptions): {\n /**\n * Use this function to fetch data from Sanity in your React Server Components.\n * @public\n */\n sanityFetch: DefinedSanityFetchType\n /**\n * Render this in your root layout.tsx to make your page revalidate on new content live, automatically.\n * @public\n */\n SanityLive: React.ComponentType<DefinedSanityLiveProps>\n} {\n const {\n client: _client,\n serverToken,\n browserToken,\n fetchOptions,\n stega: stegaEnabled = true,\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} = client.config()\n const studioUrlDefined = typeof client.config().stega.studioUrl !== 'undefined'\n\n const sanityFetch: DefinedSanityFetchType = async function sanityFetch<\n const QueryString extends string,\n >({\n query,\n params = {},\n stega: _stega,\n tags = ['sanity'],\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 const stega = _stega ?? (stegaEnabled && studioUrlDefined && (await draftMode()).isEnabled)\n const perspective = _perspective ?? (await resolveCookiePerspective())\n const useCdn = perspective === 'published'\n const revalidate =\n fetchOptions?.revalidate !== undefined\n ? fetchOptions.revalidate\n : process.env.NODE_ENV === 'production'\n ? false\n : undefined\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: {revalidate, tags: [...tags, 'sanity:fetch-sync-tags']},\n useCdn,\n cacheMode: useCdn ? 'noStale' : undefined,\n tag: [requestTag, 'fetch-sync-tags'].filter(Boolean).join('.'),\n })\n\n const cacheTags = [...tags, ...(syncTags?.map((tag) => `sanity:${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: useCdn ? 'noStale' : undefined,\n tag: requestTag,\n })\n return {data: result, sourceMap: resultSourceMap || null, tags: cacheTags}\n }\n\n const SanityLive: React.ComponentType<DefinedSanityLiveProps> = async function SanityLive(props) {\n const {\n // handleDraftModeAction = handleDraftModeActionMissing\n refreshOnMount,\n refreshOnFocus,\n refreshOnReconnect,\n tag,\n requestTag = tag,\n onError,\n onGoAway,\n intervalOnGoAway,\n revalidateSyncTags,\n } = props\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n const {isEnabled: isDraftModeEnabled} = await draftMode()\n\n // Preconnect to the Live Event API origin, or at least prefetch the DNS if preconenct is not supported\n const {origin} = new URL(client.getUrl('', false))\n preconnect(origin)\n prefetchDNS(origin)\n\n return (\n <SanityLiveClientComponent\n projectId={projectId}\n dataset={dataset}\n apiHost={apiHost}\n apiVersion={apiVersion}\n useProjectHostname={useProjectHostname}\n requestTagPrefix={requestTagPrefix}\n requestTag={requestTag}\n token={typeof browserToken === 'string' && isDraftModeEnabled ? browserToken : undefined}\n draftModeEnabled={isDraftModeEnabled}\n // handleDraftModeAction={handleDraftModeAction}\n draftModePerspective={await resolveCookiePerspective()}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n onError={onError}\n onGoAway={onGoAway}\n intervalOnGoAway={intervalOnGoAway}\n revalidateSyncTags={revalidateSyncTags}\n />\n )\n }\n\n return {\n sanityFetch,\n SanityLive,\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,2BAAuE;AAC3F,SAAQ,MAAM,WAAW,EAAE,aACtB,MAAM,SAAS,EAAE,IAAI,sBAAsB,GAC1C,qBAAqB,MAAM,SAAS,EAAE,IAAI,sBAAsB,EAAE,OAAO,SAAS,GAClF,WACF;;AC0IN,SAAgB,WAAW,QAWzB;CACA,MAAM,EACJ,QAAQ,SACR,aACA,cACA,cACA,OAAO,eAAe,SACpB;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,kBAAiB,OAAO,QAAQ;CAC9C,MAAM,mBAAmB,OAAO,OAAO,QAAQ,CAAC,MAAM,cAAc;AAwGpE,QAAO;EACL,aAvG0C,eAAe,YAEzD,EACA,OACA,SAAS,EAAE,EACX,OAAO,QACP,OAAO,CAAC,SAAS,EACjB,aAAa,cACb,KACA,aAAa,OAAO,uBASnB;GACD,MAAM,QAAQ,WAAW,gBAAgB,qBAAqB,MAAM,WAAW,EAAE;GACjF,MAAM,cAAc,gBAAiB,MAAM,0BAA0B;GACrE,MAAM,SAAS,gBAAgB;GAC/B,MAAM,aACJ,cAAc,eAAe,KAAA,IACzB,aAAa,aACb,QAAQ,IAAI,aAAa,eACvB,QACA,KAAA;GAGR,MAAM,EAAC,aAAY,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ;IACzD,gBAAgB;IACH;IACb,OAAO;IACP,aAAa;IACb,MAAM;KAAC;KAAY,MAAM,CAAC,GAAG,MAAM,yBAAyB;KAAC;IAC7D;IACA,WAAW,SAAS,YAAY,KAAA;IAChC,KAAK,CAAC,YAAY,kBAAkB,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;IAC/D,CAAC;GAEF,MAAM,YAAY,CAAC,GAAG,MAAM,GAAI,UAAU,KAAK,UAAQ,UAAUA,QAAM,IAAI,EAAE,CAAE;GAE/E,MAAM,EAAC,QAAQ,oBAAmB,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ;IACxE,gBAAgB;IACH;IACb;IACA,OAAO,gBAAgB,eAAe,cAAc,cAAc;IAClE,MAAM;KAAC;KAAY,MAAM;KAAU;IACnC;IACA,WAAW,SAAS,YAAY,KAAA;IAChC,KAAK;IACN,CAAC;AACF,UAAO;IAAC,MAAM;IAAQ,WAAW,mBAAmB;IAAM,MAAM;IAAU;;EAmD1E,YAhD8D,eAAe,WAAW,OAAO;GAC/F,MAAM,EAEJ,gBACA,gBACA,oBACA,KACA,aAAa,KACb,SACA,UACA,kBACA,uBACE;GACJ,MAAM,EAAC,WAAW,SAAS,SAAS,YAAY,oBAAoB,qBAClE,OAAO,QAAQ;GACjB,MAAM,EAAC,WAAW,uBAAsB,MAAM,WAAW;GAGzD,MAAM,EAAC,WAAU,IAAI,IAAI,OAAO,OAAO,IAAI,MAAM,CAAC;AAClD,cAAW,OAAO;AAClB,eAAY,OAAO;AAEnB,UACE,oBAAC,2BAAA;IACY;IACF;IACA;IACG;IACQ;IACF;IACN;IACZ,OAAO,OAAO,iBAAiB,YAAY,qBAAqB,eAAe,KAAA;IAC/E,kBAAkB;IAElB,sBAAsB,MAAM,0BAA0B;IACtC;IACA;IACI;IACX;IACC;IACQ;IACE;KACpB;;EAOL"}
1
+ {"version":3,"file":"live.react-server.js","names":["tag"],"sources":["../src/live/resolveCookiePerspective.ts","../src/live/defineLive.tsx"],"sourcesContent":["import type {ClientPerspective} from '@sanity/client'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {cookies, draftMode} from 'next/headers'\n\n/**\n * @internal\n */\nexport async function resolveCookiePerspective(): 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 : 'published'\n}\n","// import type {DefinedFetchType, DefinedLiveProps} from '#live/types'\n\nimport {\n type ClientPerspective,\n type ClientReturn,\n type ContentSourceMap,\n type LiveEventGoAway,\n type QueryParams,\n type SanityClient,\n type SyncTag,\n} from '@sanity/client'\nimport SanityLiveClientComponent from 'next-sanity/live/client-components/live'\nimport {draftMode} from 'next/headers'\nimport {prefetchDNS, preconnect} from 'react-dom'\n\nimport {resolveCookiePerspective} from './resolveCookiePerspective'\n\n/**\n * @public\n */\nexport type DefinedSanityFetchType = <const QueryString extends string>(options: {\n query: QueryString\n params?: QueryParams | Promise<QueryParams>\n /**\n * Add custom `next.tags` to the underlying fetch request.\n * @see https://nextjs.org/docs/app/api-reference/functions/fetch#optionsnexttags\n * This can be used in conjunction with custom fallback revalidation strategies, as well as with custom Server Actions that mutate data and want to render with fresh data right away (faster than the Live Event latency).\n * @defaultValue `['sanity']`\n */\n tags?: string[]\n perspective?: Exclude<ClientPerspective, 'raw'>\n stega?: boolean\n /**\n * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.\n * @see https://www.sanity.io/docs/reference-api-request-tags\n * @defaultValue 'next-loader.fetch'\n */\n requestTag?: string\n}) => Promise<{\n data: ClientReturn<QueryString>\n sourceMap: ContentSourceMap | null\n tags: string[]\n}>\n\n/**\n * @public\n */\nexport interface DefinedSanityLiveProps {\n /**\n * Automatic refresh of RSC when the component <SanityLive /> is mounted.\n * Note that this is different from revalidation, which is based on tags and causes `sanityFetch` calls to be re-fetched.\n * @defaultValue `true`\n */\n refreshOnMount?: boolean\n /**\n * Automatically refresh when window gets focused\n * Note that this is different from revalidation, which is based on tags and causes `sanityFetch` calls to be re-fetched.\n * @defaultValue `false` if draftMode().isEnabled, otherwise `true` if not inside an iframe\n */\n refreshOnFocus?: boolean\n /**\n * Automatically refresh when the browser regains a network connection (via navigator.onLine)\n * Note that this is different from revalidation, which is based on tags and causes `sanityFetch` calls to be re-fetched.\n * @defaultValue `true`\n */\n refreshOnReconnect?: boolean\n /**\n * Automatically refresh on an interval when the Live Event API emits a `goaway` event, which indicates that the connection is rejected or closed.\n * This typically happens if the connection limit is reached, or if the connection is idle for too long.\n * To disable this long polling fallback behavior set `intervalOnGoAway` to `false` or `0`.\n * You can also use `onGoAway` to handle the `goaway` event in your own way, and read the reason why the event was emitted.\n * @defaultValue `30_000` 30 seconds interval\n */\n intervalOnGoAway?: number | false\n\n /**\n * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.\n * @see https://www.sanity.io/docs/reference-api-request-tags\n * @defaultValue 'next-loader.live'\n */\n requestTag?: string\n\n /**\n * Handle errors from the Live Events subscription.\n * By default it's reported using `console.error`, you can override this prop to handle it in your own way.\n */\n onError?: (error: unknown) => void\n\n /**\n * Handle the `goaway` event if the connection is rejected/closed.\n * `event.reason` will be a string of why the event was emitted, for example `'connection limit reached'`.\n * When this happens the `<SanityLive />` will fallback to long polling with a default interval of 30 seconds, providing your own `onGoAway` handler does not change this behavior.\n * If you want to disable long polling set `intervalOnGoAway` to `false` or `0`.\n */\n onGoAway?: (event: LiveEventGoAway, intervalOnGoAway: number | false) => void\n\n /**\n * Override how cache tags are invalidated, you need to pass a server action here.\n * You can also pass a `use client` function here, and have `router.refresh()` be called if the promise resolves to `'refresh'`.\n */\n revalidateSyncTags?: (tags: SyncTag[]) => Promise<void | 'refresh'>\n}\n\n/**\n * @public\n */\nexport interface DefineSanityLiveOptions {\n /**\n * Required for `sanityFetch` and `SanityLive` to work\n */\n client: SanityClient\n /**\n * Optional. If provided then the token needs to have permissions to query documents with `drafts.` prefixes in order for `perspective: 'drafts'` to work.\n * This token is not shared with the browser.\n */\n serverToken?: string | false\n /**\n * Optional. This token is shared with the browser, and should only have access to query published documents.\n * It is used to setup a `Live Draft Content` EventSource connection, and enables live previewing drafts stand-alone, outside of Presentation Tool.\n */\n browserToken?: string | false\n /**\n * Fetch options used by `sanityFetch`\n */\n fetchOptions?: {\n /**\n * Optional, enables time based revalidation in addition to the EventSource connection.\n * @defaultValue `false`\n */\n revalidate?: number | false\n }\n /**\n * Optional. Include stega encoding when draft mode is enabled.\n * @defaultValue `true`\n */\n stega?: boolean\n}\n\nexport function defineLive(config: DefineSanityLiveOptions): {\n /**\n * @deprecated use `fetch` instead, and define your own `sanityFetch` function with logic for when to toggle `stega` and `perspective`\n */\n sanityFetch: DefinedSanityFetchType\n /**\n * @deprecated use `Live` instead, and define your own `SanityLive` component with logic for when to toggle `perspective`\n */\n SanityLive: React.ComponentType<DefinedSanityLiveProps>\n // fetch: DefinedFetchType\n // Live: React.ComponentType<DefinedLiveProps>\n} {\n const {\n client: _client,\n serverToken,\n browserToken,\n fetchOptions,\n stega: stegaEnabled = true,\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} = client.config()\n const studioUrlDefined = typeof client.config().stega.studioUrl !== 'undefined'\n\n const sanityFetch: DefinedSanityFetchType = async function sanityFetch<\n const QueryString extends string,\n >({\n query,\n params = {},\n stega: _stega,\n tags = ['sanity'],\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 const stega = _stega ?? (stegaEnabled && studioUrlDefined && (await draftMode()).isEnabled)\n const perspective = _perspective ?? (await resolveCookiePerspective())\n const useCdn = perspective === 'published'\n const revalidate =\n fetchOptions?.revalidate !== undefined\n ? fetchOptions.revalidate\n : process.env.NODE_ENV === 'production'\n ? false\n : undefined\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: {revalidate, tags: [...tags, 'sanity:fetch-sync-tags']},\n useCdn,\n cacheMode: useCdn ? 'noStale' : undefined,\n tag: [requestTag, 'fetch-sync-tags'].filter(Boolean).join('.'),\n })\n\n const cacheTags = [...tags, ...(syncTags?.map((tag) => `sanity:${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: useCdn ? 'noStale' : undefined,\n tag: requestTag,\n })\n return {data: result, sourceMap: resultSourceMap || null, tags: cacheTags}\n }\n\n const SanityLive: React.ComponentType<DefinedSanityLiveProps> = async function SanityLive(props) {\n const {\n // handleDraftModeAction = handleDraftModeActionMissing\n refreshOnMount,\n refreshOnFocus,\n refreshOnReconnect,\n requestTag,\n onError,\n onGoAway,\n intervalOnGoAway,\n revalidateSyncTags,\n } = props\n const {projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix} =\n client.config()\n const {isEnabled: isDraftModeEnabled} = await draftMode()\n\n // Preconnect to the Live Event API origin, or at least prefetch the DNS if preconenct is not supported\n const {origin} = new URL(client.getUrl('', false))\n preconnect(origin)\n prefetchDNS(origin)\n\n return (\n <SanityLiveClientComponent\n projectId={projectId}\n dataset={dataset}\n apiHost={apiHost}\n apiVersion={apiVersion}\n useProjectHostname={useProjectHostname}\n requestTagPrefix={requestTagPrefix}\n requestTag={requestTag}\n token={typeof browserToken === 'string' && isDraftModeEnabled ? browserToken : undefined}\n draftModeEnabled={isDraftModeEnabled}\n // handleDraftModeAction={handleDraftModeAction}\n draftModePerspective={await resolveCookiePerspective()}\n refreshOnMount={refreshOnMount}\n refreshOnFocus={refreshOnFocus}\n refreshOnReconnect={refreshOnReconnect}\n onError={onError}\n onGoAway={onGoAway}\n intervalOnGoAway={intervalOnGoAway}\n revalidateSyncTags={revalidateSyncTags}\n />\n )\n }\n\n return {\n sanityFetch,\n SanityLive,\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,2BAAuE;AAC3F,SAAQ,MAAM,WAAW,EAAE,aACtB,MAAM,SAAS,EAAE,IAAI,sBAAsB,GAC1C,qBAAqB,MAAM,SAAS,EAAE,IAAI,sBAAsB,EAAE,OAAO,SAAS,GAClF,WACF;;AC4HN,SAAgB,WAAW,QAWzB;CACA,MAAM,EACJ,QAAQ,SACR,aACA,cACA,cACA,OAAO,eAAe,SACpB;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,kBAAiB,OAAO,QAAQ;CAC9C,MAAM,mBAAmB,OAAO,OAAO,QAAQ,CAAC,MAAM,cAAc;AAuGpE,QAAO;EACL,aAtG0C,eAAe,YAEzD,EACA,OACA,SAAS,EAAE,EACX,OAAO,QACP,OAAO,CAAC,SAAS,EACjB,aAAa,cACb,KACA,aAAa,OAAO,uBASnB;GACD,MAAM,QAAQ,WAAW,gBAAgB,qBAAqB,MAAM,WAAW,EAAE;GACjF,MAAM,cAAc,gBAAiB,MAAM,0BAA0B;GACrE,MAAM,SAAS,gBAAgB;GAC/B,MAAM,aACJ,cAAc,eAAe,KAAA,IACzB,aAAa,aACb,QAAQ,IAAI,aAAa,eACvB,QACA,KAAA;GAGR,MAAM,EAAC,aAAY,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ;IACzD,gBAAgB;IACH;IACb,OAAO;IACP,aAAa;IACb,MAAM;KAAC;KAAY,MAAM,CAAC,GAAG,MAAM,yBAAyB;KAAC;IAC7D;IACA,WAAW,SAAS,YAAY,KAAA;IAChC,KAAK,CAAC,YAAY,kBAAkB,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;IAC/D,CAAC;GAEF,MAAM,YAAY,CAAC,GAAG,MAAM,GAAI,UAAU,KAAK,UAAQ,UAAUA,QAAM,IAAI,EAAE,CAAE;GAE/E,MAAM,EAAC,QAAQ,oBAAmB,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ;IACxE,gBAAgB;IACH;IACb;IACA,OAAO,gBAAgB,eAAe,cAAc,cAAc;IAClE,MAAM;KAAC;KAAY,MAAM;KAAU;IACnC;IACA,WAAW,SAAS,YAAY,KAAA;IAChC,KAAK;IACN,CAAC;AACF,UAAO;IAAC,MAAM;IAAQ,WAAW,mBAAmB;IAAM,MAAM;IAAU;;EAkD1E,YA/C8D,eAAe,WAAW,OAAO;GAC/F,MAAM,EAEJ,gBACA,gBACA,oBACA,YACA,SACA,UACA,kBACA,uBACE;GACJ,MAAM,EAAC,WAAW,SAAS,SAAS,YAAY,oBAAoB,qBAClE,OAAO,QAAQ;GACjB,MAAM,EAAC,WAAW,uBAAsB,MAAM,WAAW;GAGzD,MAAM,EAAC,WAAU,IAAI,IAAI,OAAO,OAAO,IAAI,MAAM,CAAC;AAClD,cAAW,OAAO;AAClB,eAAY,OAAO;AAEnB,UACE,oBAAC,2BAAA;IACY;IACF;IACA;IACG;IACQ;IACF;IACN;IACZ,OAAO,OAAO,iBAAiB,YAAY,qBAAqB,eAAe,KAAA;IAC/E,kBAAkB;IAElB,sBAAsB,MAAM,0BAA0B;IACtC;IACA;IACI;IACX;IACC;IACQ;IACE;KACpB;;EAOL"}
@@ -1,6 +1,6 @@
1
1
  "use server";
2
- import { revalidatePath } from "next/cache";
3
2
  import { draftMode } from "next/headers";
3
+ import { revalidatePath } from "next/cache";
4
4
  async function revalidateRootLayout() {
5
5
  if (!(await draftMode()).isEnabled) {
6
6
  console.warn("Skipped revalidatePath request because draft mode is not enabled");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "13.0.0-cache-components.5",
3
+ "version": "13.0.0-cache-components.7",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "live",
@@ -15,23 +15,28 @@
15
15
  "bugs": {
16
16
  "url": "https://github.com/sanity-io/next-sanity/issues"
17
17
  },
18
+ "license": "MIT",
19
+ "author": "Sanity.io <hello@sanity.io>",
18
20
  "repository": {
19
21
  "type": "git",
20
22
  "url": "git+ssh://git@github.com/sanity-io/next-sanity.git",
21
23
  "directory": "packages/next-sanity"
22
24
  },
23
- "author": "Sanity.io <hello@sanity.io>",
24
- "license": "MIT",
25
- "sideEffects": false,
25
+ "files": [
26
+ "dist"
27
+ ],
26
28
  "type": "module",
29
+ "sideEffects": false,
27
30
  "main": "./dist/index.js",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
28
33
  "imports": {
29
34
  "#client-components/*": "./src/shared/client-components/*.tsx",
30
35
  "#live/*": "./src/shared/live/*.ts"
31
36
  },
32
37
  "exports": {
33
38
  ".": "./dist/index.js",
34
- "./debug": "./dist/debug.js",
39
+ "./cache-life": "./dist/cache-life.js",
35
40
  "./draft-mode": "./dist/draft-mode/index.js",
36
41
  "./experimental/client-components/live": "./dist/experimental/client-components/live.js",
37
42
  "./hooks": "./dist/hooks/index.js",
@@ -51,11 +56,6 @@
51
56
  "./webhook": "./dist/webhook/index.js",
52
57
  "./package.json": "./package.json"
53
58
  },
54
- "module": "./dist/index.js",
55
- "types": "./dist/index.d.ts",
56
- "files": [
57
- "dist"
58
- ],
59
59
  "dependencies": {
60
60
  "@portabletext/react": "^6.0.0",
61
61
  "@sanity/client": "^7.13.2",
@@ -75,7 +75,7 @@
75
75
  "@types/react": "^19.2.7",
76
76
  "@types/react-dom": "^19.2.3",
77
77
  "@vitest/coverage-v8": "^4.0.16",
78
- "next": "16.1.0-canary.34",
78
+ "next": "16.1.1-canary.0",
79
79
  "publint": "^0.3.16",
80
80
  "react": "^19.2.3",
81
81
  "react-dom": "^19.2.3",
@@ -1,4 +0,0 @@
1
- declare const PUBLISHED_SYNC_TAG_PREFIX = "sp:";
2
- declare const DRAFT_SYNC_TAG_PREFIX = "sd:";
3
- export { PUBLISHED_SYNC_TAG_PREFIX as n, DRAFT_SYNC_TAG_PREFIX as t };
4
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","names":[],"sources":["../src/experimental/constants.ts"],"sourcesContent":[],"mappings":"AAAa,cAAA,yBAAA,GAAA,KAAA;AACA,cAAA,qBAAA,GAAA,KAAA"}
package/dist/debug.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare const tag = "sanity:debug";
2
- declare function debug(): Promise<{
3
- data: number;
4
- cacheTags: [typeof tag];
5
- }>;
6
- export { debug };
7
- //# sourceMappingURL=debug.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.d.ts","names":[],"sources":["../src/debug.ts"],"sourcesContent":[],"mappings":"cAEM,GAAA,GAAA,cAAA;AAEgB,iBAAA,KAAA,CAAA,CAAS,EAAA,OAAA,CAAA;;qBAA0C"}
package/dist/debug.js DELETED
@@ -1,14 +0,0 @@
1
- import { cacheTag } from "next/cache";
2
- const tag = "sanity:debug";
3
- async function debug() {
4
- const { resolve, promise } = Promise.withResolvers();
5
- cacheTag(tag);
6
- setTimeout(() => resolve(Math.random()), 1e3);
7
- return {
8
- data: await promise,
9
- cacheTags: [tag]
10
- };
11
- }
12
- export { debug };
13
-
14
- //# sourceMappingURL=debug.js.map
package/dist/debug.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.js","names":[],"sources":["../src/debug.ts"],"sourcesContent":["import {cacheTag} from 'next/cache'\n\nconst tag = 'sanity:debug'\n\nexport async function debug(): Promise<{data: number; cacheTags: [typeof tag]}> {\n const {resolve, promise} = Promise.withResolvers<number>()\n \n cacheTag(tag)\n\n setTimeout(() => resolve(Math.random()), 1_000)\n\n return {\n data: await promise,\n cacheTags: [tag],\n }\n}"],"mappings":";AAEA,MAAM,MAAM;AAEZ,eAAsB,QAA0D;CAC9E,MAAM,EAAC,SAAS,YAAW,QAAQ,eAAuB;AAE1D,UAAS,IAAI;AAEb,kBAAiB,QAAQ,KAAK,QAAQ,CAAC,EAAE,IAAM;AAE/C,QAAO;EACL,MAAM,MAAM;EACZ,WAAW,CAAC,IAAI;EACjB"}
@@ -1,26 +0,0 @@
1
- import { cookies } from "next/headers";
2
- import { ClientPerspective } from "@sanity/client";
3
- type ResolvePerspectiveFromCookies = (options: {
4
- /**
5
- * You must await the cookies() function from next/headers
6
- * and pass it here.
7
- * Example:
8
- * ```ts
9
- * import { cookies } from 'next/headers'
10
- *
11
- * const perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
12
- * ```
13
- */
14
- cookies: Awaited<ReturnType<typeof cookies>>;
15
- }) => Promise<Exclude<ClientPerspective, "raw">>;
16
- /**
17
- * Resolves the perspective from the cookie that is set by `import { defineEnableDraftMode } from "next-sanity/draft-mode"`
18
- * @public
19
- */
20
- declare const resolvePerspectiveFromCookies: ({
21
- cookies: jar
22
- }: {
23
- cookies: Awaited<ReturnType<typeof cookies>>;
24
- }) => Promise<Exclude<ClientPerspective, "raw">>;
25
- export { resolvePerspectiveFromCookies as n, ResolvePerspectiveFromCookies as t };
26
- //# sourceMappingURL=resolvePerspectiveFromCookies.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolvePerspectiveFromCookies.d.ts","names":[],"sources":["../src/shared/live/resolvePerspectiveFromCookies.ts"],"sourcesContent":[],"mappings":";;KAMY,6BAAA;EAAZ;;;;;;;;AAkBA;;EAGqC,OAAA,EAV1B,OAU0B,CAVlB,UAUkB,CAAA,OAVA,OAUA,CAAA,CAAA;CAAlB,EAAA,GATb,OASa,CATL,OASK,CATG,iBASH,EAAA,KAAA,CAAA,CAAA;;;;;AACf,cAJS,6BAIT,EAAA,CAAA;EAAA,OAAA,EAHO;CAGP,EAAA;WADO,QAAQ,kBAAkB;MACjC,QAAQ,QAAQ"}