next-sanity 0.0.0-dev.3 → 0.0.0-dev.5
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/index.cjs +16 -6
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +24 -2
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +36 -1
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var client = require('@sanity/client');
|
|
6
|
+
var client = require('@sanity/preview-kit/client');
|
|
7
7
|
var groq = require('groq');
|
|
8
8
|
function _interopDefaultCompat(e) {
|
|
9
9
|
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
@@ -11,16 +11,26 @@ function _interopDefaultCompat(e) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
var groq__default = /*#__PURE__*/_interopDefaultCompat(groq);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function createClient(config) {
|
|
15
|
+
let {
|
|
16
|
+
// eslint-disable-next-line prefer-const
|
|
17
|
+
studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL,
|
|
18
|
+
encodeSourceMap = studioUrl ? "auto" : "none"
|
|
19
|
+
} = config;
|
|
20
|
+
if (encodeSourceMap === "auto" && process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
|
|
21
|
+
encodeSourceMap = "stega";
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
return client.createClient({
|
|
24
|
+
...config,
|
|
25
|
+
studioUrl,
|
|
26
|
+
encodeSourceMap
|
|
27
|
+
});
|
|
28
|
+
}
|
|
20
29
|
Object.defineProperty(exports, 'groq', {
|
|
21
30
|
enumerable: true,
|
|
22
31
|
get: function () {
|
|
23
32
|
return groq__default.default;
|
|
24
33
|
}
|
|
25
34
|
});
|
|
35
|
+
exports.createClient = createClient;
|
|
26
36
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.js
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/client.ts"],"sourcesContent":["import {\n type ClientConfig as _ClientConfig,\n createClient as _createClient,\n} from '@sanity/preview-kit/client'\n\n/** @public */\nexport interface ClientConfig extends Omit<_ClientConfig, 'studioUrl'> {\n /**\n * Where the Studio is hosted.\n * If it's embedded in the app, use the base path for example `/studio`.\n * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.\n * @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL\n * @alpha\n */\n studioUrl?: _ClientConfig['studioUrl']\n /**\n * If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.\n * @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'\n * @alpha\n */\n encodeSourceMap: _ClientConfig['encodeSourceMap']\n}\n\n/**\n * @public\n */\nexport function createClient(config: ClientConfig): ReturnType<typeof _createClient> {\n let {\n // eslint-disable-next-line prefer-const\n studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL! as _ClientConfig['studioUrl'],\n encodeSourceMap = studioUrl ? 'auto' : 'none',\n } = config\n if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {\n encodeSourceMap = 'stega'\n }\n return _createClient({...config, studioUrl, encodeSourceMap})\n}\n"],"names":["createClient","config","studioUrl","process","env","NEXT_PUBLIC_SANITY_STUDIO_URL","encodeSourceMap","NEXT_PUBLIC_VERCEL_ENV","_createClient"],"mappings":";;;;;;;;;;;;;AA0BO,SAASA,aAAaC,MAAwD,EAAA;EAC/E,IAAA;IAAA;IAEFC,SAAA,GAAYC,QAAQC,GAAI,CAAAC,6BAAA;IACxBC,eAAA,GAAkBJ,YAAY,MAAS,GAAA;EACrC,CAAA,GAAAD,MAAA;EACJ,IAAIK,eAAoB,KAAA,MAAA,IAAUH,OAAQ,CAAAC,GAAA,CAAIG,2BAA2B,SAAW,EAAA;IAChED,eAAA,GAAA,OAAA;EACpB;EACA,OAAOE,MAAAA,CAAAA,aAAc;IAAC,GAAGP,MAAQ;IAAAC,SAAA;IAAWI;EAAgB,CAAA,CAAA;AAC9D;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import {ClientConfig} from '@sanity/client'
|
|
2
|
-
import {
|
|
2
|
+
import {ClientConfig as ClientConfig_3} from '@sanity/preview-kit/client'
|
|
3
|
+
import {createClient as createClient_2} from '@sanity/preview-kit/client'
|
|
3
4
|
import {default as groq} from 'groq'
|
|
4
5
|
import {SanityClient} from '@sanity/client'
|
|
5
6
|
|
|
6
7
|
export {ClientConfig}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/** @public */
|
|
10
|
+
declare interface ClientConfig_2 extends Omit<ClientConfig_3, 'studioUrl'> {
|
|
11
|
+
/**
|
|
12
|
+
* Where the Studio is hosted.
|
|
13
|
+
* If it's embedded in the app, use the base path for example `/studio`.
|
|
14
|
+
* Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
|
|
15
|
+
* @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
|
+
studioUrl?: ClientConfig_3['studioUrl']
|
|
19
|
+
/**
|
|
20
|
+
* If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.
|
|
21
|
+
* @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'
|
|
22
|
+
* @alpha
|
|
23
|
+
*/
|
|
24
|
+
encodeSourceMap: ClientConfig_3['encodeSourceMap']
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function createClient(config: ClientConfig_2): ReturnType<typeof createClient_2>
|
|
9
31
|
|
|
10
32
|
export {groq}
|
|
11
33
|
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { createClient as createClient$1 } from '@sanity/preview-kit/client';
|
|
2
2
|
export { default as groq } from 'groq';
|
|
3
|
+
function createClient(config) {
|
|
4
|
+
let {
|
|
5
|
+
// eslint-disable-next-line prefer-const
|
|
6
|
+
studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL,
|
|
7
|
+
encodeSourceMap = studioUrl ? "auto" : "none"
|
|
8
|
+
} = config;
|
|
9
|
+
if (encodeSourceMap === "auto" && process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
|
|
10
|
+
encodeSourceMap = "stega";
|
|
11
|
+
}
|
|
12
|
+
return createClient$1({
|
|
13
|
+
...config,
|
|
14
|
+
studioUrl,
|
|
15
|
+
encodeSourceMap
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { createClient };
|
|
3
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/client.ts"],"sourcesContent":["import {\n type ClientConfig as _ClientConfig,\n createClient as _createClient,\n} from '@sanity/preview-kit/client'\n\n/** @public */\nexport interface ClientConfig extends Omit<_ClientConfig, 'studioUrl'> {\n /**\n * Where the Studio is hosted.\n * If it's embedded in the app, use the base path for example `/studio`.\n * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.\n * @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL\n * @alpha\n */\n studioUrl?: _ClientConfig['studioUrl']\n /**\n * If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.\n * @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'\n * @alpha\n */\n encodeSourceMap: _ClientConfig['encodeSourceMap']\n}\n\n/**\n * @public\n */\nexport function createClient(config: ClientConfig): ReturnType<typeof _createClient> {\n let {\n // eslint-disable-next-line prefer-const\n studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL! as _ClientConfig['studioUrl'],\n encodeSourceMap = studioUrl ? 'auto' : 'none',\n } = config\n if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {\n encodeSourceMap = 'stega'\n }\n return _createClient({...config, studioUrl, encodeSourceMap})\n}\n"],"names":["createClient","config","studioUrl","process","env","NEXT_PUBLIC_SANITY_STUDIO_URL","encodeSourceMap","NEXT_PUBLIC_VERCEL_ENV","_createClient"],"mappings":";;AA0BO,SAASA,aAAaC,MAAwD,EAAA;EAC/E,IAAA;IAAA;IAEFC,SAAA,GAAYC,QAAQC,GAAI,CAAAC,6BAAA;IACxBC,eAAA,GAAkBJ,YAAY,MAAS,GAAA;EACrC,CAAA,GAAAD,MAAA;EACJ,IAAIK,eAAoB,KAAA,MAAA,IAAUH,OAAQ,CAAAC,GAAA,CAAIG,2BAA2B,SAAW,EAAA;IAChED,eAAA,GAAA,OAAA;EACpB;EACA,OAAOE,eAAc;IAAC,GAAGP,MAAQ;IAAAC,SAAA;IAAWI;EAAgB,CAAA,CAAA;AAC9D;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-sanity",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.5",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -146,8 +146,8 @@
|
|
|
146
146
|
"singleQuote": true
|
|
147
147
|
},
|
|
148
148
|
"dependencies": {
|
|
149
|
-
"@sanity/client": "0.0.0-dev.
|
|
150
|
-
"@sanity/preview-kit": "0.0.0-dev.
|
|
149
|
+
"@sanity/client": "0.0.0-dev.6",
|
|
150
|
+
"@sanity/preview-kit": "0.0.0-dev.7",
|
|
151
151
|
"@sanity/webhook": "2",
|
|
152
152
|
"groq": "3"
|
|
153
153
|
},
|
package/src/client.ts
CHANGED
|
@@ -1,2 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClientConfig as _ClientConfig,
|
|
3
|
+
createClient as _createClient,
|
|
4
|
+
} from '@sanity/preview-kit/client'
|
|
5
|
+
|
|
1
6
|
/** @public */
|
|
2
|
-
export
|
|
7
|
+
export interface ClientConfig extends Omit<_ClientConfig, 'studioUrl'> {
|
|
8
|
+
/**
|
|
9
|
+
* Where the Studio is hosted.
|
|
10
|
+
* If it's embedded in the app, use the base path for example `/studio`.
|
|
11
|
+
* Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
|
|
12
|
+
* @defaultValue process.env.NEXT_PUBLIC_SANITY_STUDIO_URL
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
studioUrl?: _ClientConfig['studioUrl']
|
|
16
|
+
/**
|
|
17
|
+
* If there's no `studioUrl` then the default value is `none` and the normal `@sanity/client` will be used. If `studioUrl` is set, then it's `auto` by default.
|
|
18
|
+
* @defaultValue process.env.MEXT_PUBLIC_SANITY_SOURCE_MAP || studioUrl ? 'auto' : 'none'
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
21
|
+
encodeSourceMap: _ClientConfig['encodeSourceMap']
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export function createClient(config: ClientConfig): ReturnType<typeof _createClient> {
|
|
28
|
+
let {
|
|
29
|
+
// eslint-disable-next-line prefer-const
|
|
30
|
+
studioUrl = process.env.NEXT_PUBLIC_SANITY_STUDIO_URL! as _ClientConfig['studioUrl'],
|
|
31
|
+
encodeSourceMap = studioUrl ? 'auto' : 'none',
|
|
32
|
+
} = config
|
|
33
|
+
if (encodeSourceMap === 'auto' && process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
|
|
34
|
+
encodeSourceMap = 'stega'
|
|
35
|
+
}
|
|
36
|
+
return _createClient({...config, studioUrl, encodeSourceMap})
|
|
37
|
+
}
|