next-sanity 13.0.0-cache-components.4 → 13.0.0-cache-components.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache-life.d.ts +32 -0
- package/dist/cache-life.d.ts.map +1 -0
- package/dist/cache-life.js +4 -0
- package/dist/cache-life.js.map +1 -0
- package/dist/debug.d.ts +7 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +14 -0
- package/dist/debug.js.map +1 -0
- package/dist/live/server-actions/index.js +1 -1
- package/dist/live.next-js.js +1 -1
- package/dist/visual-editing/server-actions/index.js +1 -1
- package/package.json +12 -10
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
readonly revalidate: 7_776_000;
|
|
30
|
+
};
|
|
31
|
+
export { sanity };
|
|
32
|
+
//# 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 @@
|
|
|
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 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,EACpB,YAAY,QACb"}
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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}\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,8 +1,8 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import { t as sanitizePerspective } from "../../sanitizePerspective.js";
|
|
3
|
+
import { revalidateTag } from "next/cache";
|
|
3
4
|
import { perspectiveCookieName } from "@sanity/preview-url-secret/constants";
|
|
4
5
|
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.next-js.js
CHANGED
|
@@ -1,12 +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";
|
|
4
5
|
import { cookies, draftMode } from "next/headers";
|
|
5
6
|
import { stegaEncodeSourceMap } from "@sanity/client/stega";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
import { createClient } from "next-sanity";
|
|
8
9
|
import SanityLiveClientComponent from "next-sanity/experimental/client-components/live";
|
|
9
|
-
import { cacheLife, cacheTag, updateTag } from "next/cache";
|
|
10
10
|
import { preconnect } from "react-dom";
|
|
11
11
|
async function sanityCachedFetch(config, { query, params = {}, perspective, stega, requestTag, draftToken, customCacheTags = [] }) {
|
|
12
12
|
"use cache: remote";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
import { draftMode } from "next/headers";
|
|
3
2
|
import { revalidatePath } from "next/cache";
|
|
3
|
+
import { draftMode } from "next/headers";
|
|
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.
|
|
3
|
+
"version": "13.0.0-cache-components.6",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"live",
|
|
@@ -15,22 +15,29 @@
|
|
|
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
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
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",
|
|
39
|
+
"./cache-life": "./dist/cache-life.js",
|
|
40
|
+
"./debug": "./dist/debug.js",
|
|
34
41
|
"./draft-mode": "./dist/draft-mode/index.js",
|
|
35
42
|
"./experimental/client-components/live": "./dist/experimental/client-components/live.js",
|
|
36
43
|
"./hooks": "./dist/hooks/index.js",
|
|
@@ -50,11 +57,6 @@
|
|
|
50
57
|
"./webhook": "./dist/webhook/index.js",
|
|
51
58
|
"./package.json": "./package.json"
|
|
52
59
|
},
|
|
53
|
-
"module": "./dist/index.js",
|
|
54
|
-
"types": "./dist/index.d.ts",
|
|
55
|
-
"files": [
|
|
56
|
-
"dist"
|
|
57
|
-
],
|
|
58
60
|
"dependencies": {
|
|
59
61
|
"@portabletext/react": "^6.0.0",
|
|
60
62
|
"@sanity/client": "^7.13.2",
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
"@types/react": "^19.2.7",
|
|
75
77
|
"@types/react-dom": "^19.2.3",
|
|
76
78
|
"@vitest/coverage-v8": "^4.0.16",
|
|
77
|
-
"next": "16.1.
|
|
79
|
+
"next": "16.1.1-canary.0",
|
|
78
80
|
"publint": "^0.3.16",
|
|
79
81
|
"react": "^19.2.3",
|
|
80
82
|
"react-dom": "^19.2.3",
|