@sanity/react-loader
Advanced tools
Comparing version 0.9.2-pink-lizard to 0.10.0-pink-lizard
@@ -15,2 +15,23 @@ # Changelog | ||
## [0.10.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.9.2-pink-lizard...react-loader-v0.10.0-pink-lizard) (2023-11-13) | ||
### Features | ||
* add `encodeDataAttribute` API ([d9179f3](https://github.com/sanity-io/visual-editing/commit/d9179f30ab0defb1539d589a24c230683cce9c4e)) | ||
### Bug Fixes | ||
* **deps:** Update dependency @sanity/client to ^6.8.2 ([#356](https://github.com/sanity-io/visual-editing/issues/356)) ([b80dfa5](https://github.com/sanity-io/visual-editing/commit/b80dfa519c9790efdfdc0590ad7eb3f56998ea01)) | ||
* **deps:** Update dependency @sanity/client to ^6.8.4 ([5dbbe06](https://github.com/sanity-io/visual-editing/commit/5dbbe062ac1dd71a251e70d15caa1c5d53a505f6)) | ||
* **deps:** Update dependency @sanity/client to ^6.8.5 ([#361](https://github.com/sanity-io/visual-editing/issues/361)) ([e8e61c1](https://github.com/sanity-io/visual-editing/commit/e8e61c1a377b2737db60a1c3e42160794b26ad9b)) | ||
### Dependencies | ||
* The following workspace dependencies were updated | ||
* dependencies | ||
* @sanity/core-loader bumped to 0.9.0-pink-lizard | ||
## [0.9.2-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.9.1-pink-lizard...react-loader-v0.9.2-pink-lizard) (2023-11-13) | ||
@@ -17,0 +38,0 @@ |
import cjs from './index.cjs'; | ||
export const useEncodeDataAttribute = cjs.useEncodeDataAttribute; | ||
export const createQueryStore = cjs.createQueryStore; | ||
@@ -8,3 +8,8 @@ import type { ClientPerspective } from '@sanity/client' | ||
import { QueryStoreState } from '@sanity/core-loader' | ||
import type { ResolveStudioUrl } from '@sanity/client/csm' | ||
import type { StudioPathLike } from '@sanity/client/csm' | ||
import type { StudioUrl } from '@sanity/client/csm' | ||
export { ContentSourceMap } | ||
export declare const createQueryStore: ( | ||
@@ -14,2 +19,7 @@ options: CreateQueryStoreOptions, | ||
/** @public */ | ||
export declare type EncodeDataAttributeCallback = ( | ||
path: StudioPathLike, | ||
) => string | undefined | ||
export declare interface QueryOptions<T = 'next'> { | ||
@@ -33,3 +43,3 @@ /** | ||
data: QueryResponseResult | ||
sourceMap: ContentSourceMap | undefined | ||
sourceMap?: ContentSourceMap | ||
perspective?: ClientPerspective | ||
@@ -42,2 +52,15 @@ }> | ||
export { ResolveStudioUrl } | ||
export { StudioPathLike } | ||
export { StudioUrl } | ||
/** @public */ | ||
export declare function useEncodeDataAttribute<QueryResponseResult = unknown>( | ||
result: QueryResponseResult, | ||
sourceMap: ContentSourceMap | undefined, | ||
studioUrl: StudioUrl | ResolveStudioUrl, | ||
): EncodeDataAttributeCallback | ||
export declare type UseLiveModeHook = (options: EnableLiveModeOptions) => void | ||
@@ -73,3 +96,3 @@ | ||
data: QueryResponseResult | ||
sourceMap: ContentSourceMap | undefined | ||
sourceMap?: ContentSourceMap | ||
/** | ||
@@ -76,0 +99,0 @@ * The perspective used to fetch the data, if not provided it'll assume 'published' |
@@ -1,1 +0,1 @@ | ||
import{createQueryStore as e}from"@sanity/core-loader";import{useState as t,useMemo as r,useEffect as n}from"react";const s=s=>{const{createFetcherStore:i,setServerClient:o,enableLiveMode:a,unstable__cache:c,unstable__serverClient:u}=e(s),l={};return{query:async(e,t={},r={})=>{const{perspective:n="published"}=r;if("undefined"!=typeof document)throw new Error("Cannot use `query` in a browser environment, you should use it inside a loader, getStaticProps, getServerSideProps, getInitialProps, or in a React Server Component.");if("published"!==n&&!u.instance)throw new Error('You cannot use other perspectives than "published" unless you set "ssr: true" and call "setServerClient" first.');if("previewDrafts"===n){if(!u.canPreviewDrafts)throw new Error('You cannot use "previewDrafts" unless you set a "token" in the "client" instance you\'re pasing to "setServerClient".');const r=u.instance.config().useCdn?u.instance.withConfig({useCdn:!1}):u.instance,{result:s,resultSourceMap:i}=await r.fetch(e,t,{filterResponse:!1,perspective:n});return{data:s,sourceMap:i,perspective:n}}const{result:s,resultSourceMap:i}=await c.fetch(JSON.stringify({query:e,params:t}));return{data:s,sourceMap:i}},useQuery:(e,s=l,o={})=>{const[a]=t((()=>o.initial?{perspective:"published",...o.initial}:void 0)),c=r((()=>JSON.stringify(s)),[s]),[u,p]=t((()=>i(e,JSON.parse(c),a).value));return n((()=>{const t=i(e,JSON.parse(c),a).listen((e=>{p(e)}));return()=>t()}),[c,a,e]),u},setServerClient:o,useLiveMode:({allowStudioOrigin:e,client:t,onConnect:r,onDisconnect:s})=>{n((()=>{const n=a({allowStudioOrigin:e,client:t,onConnect:r,onDisconnect:s});return()=>n()}),[e,t,r,s])}}};export{s as createQueryStore};//# sourceMappingURL=index.js.map | ||
import{createQueryStore as e}from"@sanity/core-loader";import{useState as t,useMemo as r,useEffect as n}from"react";export{u as useEncodeDataAttribute}from"./_chunks/useEncodeDataAttribute-mY2QBNF1.js";const s=s=>{const{createFetcherStore:i,setServerClient:o,enableLiveMode:a,unstable__cache:u,unstable__serverClient:c}=e(s),l={};return{query:async(e,t={},r={})=>{const{perspective:n="published"}=r;if("undefined"!=typeof document)throw new Error("Cannot use `query` in a browser environment, you should use it inside a loader, getStaticProps, getServerSideProps, getInitialProps, or in a React Server Component.");if("published"!==n&&!c.instance)throw new Error('You cannot use other perspectives than "published" unless you set "ssr: true" and call "setServerClient" first.');if("previewDrafts"===n){if(!c.canPreviewDrafts)throw new Error('You cannot use "previewDrafts" unless you set a "token" in the "client" instance you\'re pasing to "setServerClient".');const r=c.instance.config().useCdn?c.instance.withConfig({useCdn:!1}):c.instance,{result:s,resultSourceMap:i}=await r.fetch(e,t,{filterResponse:!1,resultSourceMap:"withKeyArraySelector",perspective:n});return{data:s,sourceMap:i,perspective:n}}const{result:s,resultSourceMap:i}=await u.fetch(JSON.stringify({query:e,params:t}));return i?{data:s,sourceMap:i}:{data:s}},useQuery:(e,s=l,o={})=>{const[a]=t((()=>o.initial?{perspective:"published",...o.initial}:void 0)),u=r((()=>JSON.stringify(s)),[s]),[c,p]=t((()=>i(e,JSON.parse(u),a).value));return n((()=>{const t=i(e,JSON.parse(u),a).listen((e=>{p(e)}));return()=>t()}),[u,a,e]),c},setServerClient:o,useLiveMode:({allowStudioOrigin:e,client:t,onConnect:r,onDisconnect:s})=>{n((()=>{const n=a({allowStudioOrigin:e,client:t,onConnect:r,onDisconnect:s});return()=>n()}),[e,t,r,s])}}};export{s as createQueryStore};//# sourceMappingURL=index.js.map |
@@ -230,3 +230,5 @@ import { Any } from '@sanity/client/csm' | ||
export declare type SanityNode = { | ||
/** @deprecated */ | ||
projectId?: string | ||
/** @deprecated */ | ||
dataset?: string | ||
@@ -244,4 +246,2 @@ id: string | ||
baseUrl: string | ||
dataset: string | ||
projectId: string | ||
tool?: string | ||
@@ -248,0 +248,0 @@ workspace?: string |
@@ -1,1 +0,1 @@ | ||
import{forwardRef as e,createElement as t}from"react";import{getPublishedId as r,studioPath as n,jsonPathToStudioPath as i,resolveMapping as o,resolvedKeyedSourcePath as a}from"@sanity/client/csm";const s=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","webview"];function u(e){return{issues:e}}function p(e){return{output:e}}function c(e,t){return{reason:e?.reason,validation:t.validation,origin:e?.origin||"value",message:t.message,input:t.input,path:t.path,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function f(e,t){return{reason:t,origin:e?.origin,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function l(e,t,r,n){if(!t||!t.length||r?.skipPipe)return p(e);let i,o,a=e;for(const e of t){const t=e(a);if(t.issues){i=i||f(r,n);for(const e of t.issues){const t=c(i,e);o?o.push(t):o=[t]}if(i.abortEarly||i.abortPipeEarly)break}else a=t.output}return o?u(o):p(a)}function d(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function y(e){return"function"==typeof e?e():e}function b(e,t,r,n,i,o){return{issues:[{reason:t,validation:r,origin:e?.origin||"value",message:y(n),input:i,issues:o,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}]}}function h(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function g(e){return null!==e&&Array.isArray(e)}function m(e){let t="";for(const r of e)"string"!=typeof r?"number"!=typeof r?g(r)?(t&&(t+=":"),t+=`${r.join(",")}}`):r._key&&(t&&(t+=":"),t+=`${r._key}`):(t&&(t+=":"),t+=`${r}`):(t&&(t+="."),t+=r);return t}function v(e,t,s,u){const{mapping:p,pathSuffix:c}=o(s,t)||{};if(!p)return;if("literal"===p.source.type)return;if("unknown"===p.source.type)return;const f=t.documents[p.source.document],l=t.paths[p.source.path];return f&&l?{baseUrl:e.baseUrl,dataset:e.dataset,id:r(f._id),path:n.toString(i(a({keyedResultPath:u,pathSuffix:c,sourceBasePath:l}))),projectId:e.projectId,tool:e.tool,type:f._type,workspace:e.workspace}:void 0}const k=function(e,t){const[r,n]=d(e,t);return{type:"string",async:!1,_parse:(e,t)=>"string"!=typeof e?b(t,"type","string",r||"Invalid type",e):l(e,n,t,"string")}}([(P=1,e=>e.length<P?function(e,t,r){return u([{validation:e,message:y(t),input:r}])}("min_length",$||"Invalid length",e):p(e))]),_={type:"optional",wrapped:w=k,getDefault:()=>"function"==typeof E?E():E,async:!1,_parse(e,t){if(void 0===e){const t=this.getDefault();if(void 0===t)return p(e);e=t}return w._parse(e,t)}},j=function(e,t,r,n){const[i,o,a]=function(e,t,r){if(!e||"object"==typeof e&&!Array.isArray(e)){const[n,i]=d(t,r);return[e,n,i]}const[n,i]=d(e,t);return[void 0,n,i]}(t,r,n);let s;return{type:"object",entries:e,rest:i,async:!1,_parse(t,r){if(!t||"object"!=typeof t)return b(r,"type","object",o||"Invalid type",t);let n;s=s||Object.entries(e);const p={};for(const[e,i]of s){const o=t[e],a=i._parse(o,r);if(a.issues){const i={type:"object",input:t,key:e,value:o};for(const e of a.issues)e.path?e.path.unshift(i):e.path=[i],n?.push(e);if(n||(n=a.issues),r?.abortEarly)break}else(void 0!==a.output||e in t)&&(p[e]=a.output)}if(i&&(!r?.abortEarly||!n))for(const o in t)if(!(o in e)){const e=t[o],a=i._parse(e,r);if(a.issues){const i={type:"object",input:t,key:o,value:e};for(const e of a.issues)e.path?e.path.unshift(i):e.path=[i],n?.push(e);if(n||(n=a.issues),r?.abortEarly)break}else p[o]=a.output}return n?u(n):l(p,a,r,"object")}}}({projectId:_,dataset:_,id:k,path:k,type:_,baseUrl:k,workspace:_,tool:_});var w,E,P,$;function A(e){const{projectId:t,dataset:i,id:o,path:a,baseUrl:s,tool:u,workspace:p,type:c}=e;if(function(e){return t=e,!j._parse(t,{abortEarly:!0}).issues;var t}(e))return[["project",t],["dataset",i],["id",r(o)],["type",c],["path",m(n.fromString(a))],["base",encodeURIComponent(s)],["workspace",p],["tool",u]].filter((([,e])=>!!e)).map((e=>e.join("="))).join(";")}const I=["_createdAt","_dataset","_id","_key","_originalId","_projectId","_ref","_rev","_strengthenOnPublish","_type","_updatedAt","_weak"];function x(e){if(void 0!==e){if(null===e)return null;if(h(t=e)&&"sanity"===t.$$type$$)return e.value;var t;if(g(e))return e.map((e=>x(e)));if(h(e))return Object.fromEntries(Object.entries(e).map((([e,t])=>I.includes(e)?[e,t]:[e,x(t)])));throw new Error("invalid wrapped value")}}function D(e,t,r,o=[],a=[]){if(void 0!==t)return null===t?null:g(t)?t.map(((t,n)=>D(e,t,r,o.concat(n),a.concat(h(t)&&"_key"in t&&"string"==typeof t._key?{_key:t._key,_index:n}:n)))):h(t)?Object.fromEntries(Object.entries(t).map((([t,n])=>I.includes(t)?[t,n]:[t,D(e,n,r,o.concat(t),a.concat(t))]))):{$$type$$:"sanity",path:n.toString(i(o))||void 0,source:r?v(e,r,o,a):void 0,value:t}}const S=e((function(e,r){const{as:n,children:i,...o}=e;return i?.source?t(n,{...o,"data-sanity":A(i.source),ref:r},i.value):t(n,o,i?.value)})),O=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"];const M=new Proxy({},{get(r,n){if(i=n,s.includes(i)){if(r[n])return r[n];const i=e((function(e,r){return t(S,{as:n,ref:r,...e})}));return i.displayName=`sanity.${n}`,r[n]=i,i}var i;if(function(e){return O.includes(e)}(n)){if(r[n])return r[n];const i=e((function(e,r){return t(S,{as:n,ref:r,...e})}));return i.displayName=`sanity.${n}`,r[n]=i,i}throw new Error(`No such element: ${n}`)}});export{A as encodeSanityNodeData,M as sanity,x as unwrapData,D as wrapData};//# sourceMappingURL=jsx.js.map | ||
import{forwardRef as e,createElement as t}from"react";import{getPublishedId as r,studioPath as n,jsonPathToStudioPath as i,resolveMapping as o,resolvedKeyedSourcePath as a}from"@sanity/client/csm";const s=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","webview"];function u(e){return{issues:e}}function p(e){return{output:e}}function c(e,t){return{reason:e?.reason,validation:t.validation,origin:e?.origin||"value",message:t.message,input:t.input,path:t.path,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function f(e,t){return{reason:t,origin:e?.origin,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function l(e,t,r,n){if(!t||!t.length||r?.skipPipe)return p(e);let i,o,a=e;for(const e of t){const t=e(a);if(t.issues){i=i||f(r,n);for(const e of t.issues){const t=c(i,e);o?o.push(t):o=[t]}if(i.abortEarly||i.abortPipeEarly)break}else a=t.output}return o?u(o):p(a)}function y(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function d(e){return"function"==typeof e?e():e}function b(e,t,r,n,i,o){return{issues:[{reason:t,validation:r,origin:e?.origin||"value",message:d(n),input:i,issues:o,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}]}}function h(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function g(e){return null!==e&&Array.isArray(e)}function m(e){let t="";for(const r of e)"string"!=typeof r?"number"!=typeof r?g(r)?(t&&(t+=":"),t+=`${r.join(",")}}`):r._key&&(t&&(t+=":"),t+=`${r._key}`):(t&&(t+=":"),t+=`${r}`):(t&&(t+="."),t+=r);return t}function v(e,t,s,u){const{mapping:p,pathSuffix:c}=o(s,t)||{};if(!p)return;if("literal"===p.source.type)return;if("unknown"===p.source.type)return;const f=t.documents[p.source.document],l=t.paths[p.source.path];return f&&l?{baseUrl:e.baseUrl,workspace:e.workspace,tool:e.tool,type:f._type,id:r(f._id),path:n.toString(i(a({keyedResultPath:u,pathSuffix:c,sourceBasePath:l})))}:void 0}const k=function(e,t){const[r,n]=y(e,t);return{type:"string",async:!1,_parse:(e,t)=>"string"!=typeof e?b(t,"type","string",r||"Invalid type",e):l(e,n,t,"string")}}([(j=1,e=>e.length<j?function(e,t,r){return u([{validation:e,message:d(t),input:r}])}("min_length",$||"Invalid length",e):p(e))]),_={type:"optional",wrapped:E=k,getDefault:()=>"function"==typeof P?P():P,async:!1,_parse(e,t){if(void 0===e){const t=this.getDefault();if(void 0===t)return p(e);e=t}return E._parse(e,t)}},w=function(e,t,r,n){const[i,o,a]=function(e,t,r){if(!e||"object"==typeof e&&!Array.isArray(e)){const[n,i]=y(t,r);return[e,n,i]}const[n,i]=y(e,t);return[void 0,n,i]}(t,r,n);let s;return{type:"object",entries:e,rest:i,async:!1,_parse(t,r){if(!t||"object"!=typeof t)return b(r,"type","object",o||"Invalid type",t);let n;s=s||Object.entries(e);const p={};for(const[e,i]of s){const o=t[e],a=i._parse(o,r);if(a.issues){const i={type:"object",input:t,key:e,value:o};for(const e of a.issues)e.path?e.path.unshift(i):e.path=[i],n?.push(e);if(n||(n=a.issues),r?.abortEarly)break}else(void 0!==a.output||e in t)&&(p[e]=a.output)}if(i&&(!r?.abortEarly||!n))for(const o in t)if(!(o in e)){const e=t[o],a=i._parse(e,r);if(a.issues){const i={type:"object",input:t,key:o,value:e};for(const e of a.issues)e.path?e.path.unshift(i):e.path=[i],n?.push(e);if(n||(n=a.issues),r?.abortEarly)break}else p[o]=a.output}return n?u(n):l(p,a,r,"object")}}}({id:k,path:k,type:_,baseUrl:k,workspace:_,tool:_});var E,P,j,$;function A(e){const{id:t,path:i,baseUrl:o,tool:a,workspace:s,type:u}=e;if(function(e){return t=e,!w._parse(t,{abortEarly:!0}).issues;var t}(e))return[["id",r(t)],["type",u],["path",m(n.fromString(i))],["base",encodeURIComponent(o)],["workspace",s],["tool",a]].filter((([,e])=>!!e)).map((e=>e.join("="))).join(";")}const x=["_createdAt","_dataset","_id","_key","_originalId","_projectId","_ref","_rev","_strengthenOnPublish","_type","_updatedAt","_weak"];function D(e){if(void 0!==e){if(null===e)return null;if(h(t=e)&&"sanity"===t.$$type$$)return e.value;var t;if(g(e))return e.map((e=>D(e)));if(h(e))return Object.fromEntries(Object.entries(e).map((([e,t])=>x.includes(e)?[e,t]:[e,D(t)])));throw new Error("invalid wrapped value")}}function S(e,t,r,o=[],a=[]){if(void 0!==t)return null===t?null:g(t)?t.map(((t,n)=>S(e,t,r,o.concat(n),a.concat(h(t)&&"_key"in t&&"string"==typeof t._key?{_key:t._key,_index:n}:n)))):h(t)?Object.fromEntries(Object.entries(t).map((([t,n])=>x.includes(t)?[t,n]:[t,S(e,n,r,o.concat(t),a.concat(t))]))):{$$type$$:"sanity",path:n.toString(i(o))||void 0,source:r?v(e,r,o,a):void 0,value:t}}const O=e((function(e,r){const{as:n,children:i,...o}=e;return i?.source?t(n,{...o,"data-sanity":A(i.source),ref:r},i.value):t(n,o,i?.value)})),I=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"];const M=new Proxy({},{get(r,n){if(i=n,s.includes(i)){if(r[n])return r[n];const i=e((function(e,r){return t(O,{as:n,ref:r,...e})}));return i.displayName=`sanity.${n}`,r[n]=i,i}var i;if(function(e){return I.includes(e)}(n)){if(r[n])return r[n];const i=e((function(e,r){return t(O,{as:n,ref:r,...e})}));return i.displayName=`sanity.${n}`,r[n]=i,i}throw new Error(`No such element: ${n}`)}});export{A as encodeSanityNodeData,M as sanity,D as unwrapData,S as wrapData};//# sourceMappingURL=jsx.js.map |
import cjs from './index.cjs'; | ||
export const useEncodeDataAttribute = cjs.useEncodeDataAttribute; | ||
export const createQueryStore = cjs.createQueryStore; | ||
@@ -8,3 +8,8 @@ import type { ClientPerspective } from '@sanity/client' | ||
import { QueryStoreState } from '@sanity/core-loader' | ||
import type { ResolveStudioUrl } from '@sanity/client/csm' | ||
import type { StudioPathLike } from '@sanity/client/csm' | ||
import type { StudioUrl } from '@sanity/client/csm' | ||
export { ContentSourceMap } | ||
export declare const createQueryStore: ( | ||
@@ -14,2 +19,7 @@ options: CreateQueryStoreOptions, | ||
/** @public */ | ||
export declare type EncodeDataAttributeCallback = ( | ||
path: StudioPathLike, | ||
) => string | undefined | ||
export declare interface QueryOptions<T = 'next'> { | ||
@@ -44,2 +54,15 @@ /** | ||
export { ResolveStudioUrl } | ||
export { StudioPathLike } | ||
export { StudioUrl } | ||
/** @public */ | ||
export declare function useEncodeDataAttribute<QueryResponseResult = unknown>( | ||
result: QueryResponseResult, | ||
sourceMap: ContentSourceMap | undefined, | ||
studioUrl: StudioUrl | ResolveStudioUrl, | ||
): EncodeDataAttributeCallback | ||
export declare type UseLiveModeHook = (options: EnableLiveModeOptions) => void | ||
@@ -46,0 +69,0 @@ |
@@ -1,1 +0,1 @@ | ||
import{createQueryStore as e}from"@sanity/core-loader";import{useState as r,useMemo as n,useEffect as t}from"react";const o=o=>{const{createFetcherStore:i,enableLiveMode:s}=e(o),c={};return{query:()=>{throw new Error("The `query` function is server only.")},useQuery:(e,o=c,s={})=>{const[l]=r((()=>s.initial?{perspective:"published",...s.initial}:void 0)),u=n((()=>JSON.stringify(o)),[o]),[a,v]=r((()=>i(e,JSON.parse(u),l).value));return t((()=>{const r=i(e,JSON.parse(u),l).listen((e=>{v(e)}));return()=>r()}),[u,l,e]),a},setServerClient:()=>{throw new Error("The `setServerClient` function is server only.")},useLiveMode:({allowStudioOrigin:e,client:r,onConnect:n,onDisconnect:o})=>{t((()=>{const t=s({allowStudioOrigin:e,client:r,onConnect:n,onDisconnect:o});return()=>t()}),[e,r,n,o])}}};export{o as createQueryStore};//# sourceMappingURL=index.js.map | ||
import{createQueryStore as e}from"@sanity/core-loader";import{useState as r,useMemo as t,useEffect as n}from"react";export{u as useEncodeDataAttribute}from"../_chunks/useEncodeDataAttribute-mY2QBNF1.js";const o=o=>{const{createFetcherStore:i,enableLiveMode:s}=e(o),c={};return{query:()=>{throw new Error("The `query` function is server only.")},useQuery:(e,o=c,s={})=>{const[u]=r((()=>s.initial?{perspective:"published",...s.initial}:void 0)),a=t((()=>JSON.stringify(o)),[o]),[l,d]=r((()=>i(e,JSON.parse(a),u).value));return n((()=>{const r=i(e,JSON.parse(a),u).listen((e=>{d(e)}));return()=>r()}),[a,u,e]),l},setServerClient:()=>{throw new Error("The `setServerClient` function is server only.")},useLiveMode:({allowStudioOrigin:e,client:r,onConnect:t,onDisconnect:o})=>{n((()=>{const n=s({allowStudioOrigin:e,client:r,onConnect:t,onDisconnect:o});return()=>n()}),[e,r,t,o])}}};export{o as createQueryStore};//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
import{createQueryStore as e}from"@sanity/core-loader";const n=n=>{if(!n.ssr)throw new Error("When using React Server Components the `ssr` option must be set to `true`.");const{setServerClient:t,unstable__serverClient:r}=e(n);return{query:async(e,n={},t={})=>{const{perspective:s="published"}=t;if("previewDrafts"===s&&!r.canPreviewDrafts)throw new Error('You cannot use "previewDrafts" unless you set a "token" in the "client" instance you\'re pasing to "setServerClient".');const o="published"!==s||r.instance.config().useCdn||t.cache||t.next?r.instance.config().useCdn?r.instance.withConfig({useCdn:!1}):r.instance:r.instance.withConfig({useCdn:!0}),{result:i,resultSourceMap:c}=await o.fetch(e,n,{filterResponse:!1,cache:t.next?void 0:"no-store",...t,perspective:s});return{data:i,sourceMap:c,perspective:"previewDrafts"===s?s:void 0}},setServerClient:t,useQuery:()=>{throw new Error("The `useQuery` function can only be called from a client component.")},useLiveMode:()=>{throw new Error("The `useLiveMode` function can only be called from a client component.")}}};export{n as createQueryStore};//# sourceMappingURL=index.react-server.js.map | ||
import{createQueryStore as e}from"@sanity/core-loader";const t=t=>{if(!t.ssr)throw new Error("When using React Server Components the `ssr` option must be set to `true`.");const{setServerClient:n,unstable__serverClient:r}=e(t);return{query:async(e,t={},n={})=>{const{perspective:o="published"}=n;if("previewDrafts"===o&&!r.canPreviewDrafts)throw new Error('You cannot use "previewDrafts" unless you set a "token" in the "client" instance you\'re pasing to "setServerClient".');const s="published"!==o||r.instance.config().useCdn||n.cache||n.next?r.instance.config().useCdn?r.instance.withConfig({useCdn:!1}):r.instance:r.instance.withConfig({useCdn:!0}),{result:i,resultSourceMap:c}=await s.fetch(e,t,{filterResponse:!1,cache:n.next?void 0:"no-store",...n,perspective:o});return{data:i,sourceMap:c,perspective:"previewDrafts"===o?o:void 0}},setServerClient:n,useQuery:()=>{throw new Error("The `useQuery` hook can only be called from a client component.")},useLiveMode:()=>{throw new Error("The `useLiveMode` hook can only be called from a client component.")}}},n=()=>{throw new Error("The `useEncodeDataAttribute` hook can only be called from a client component.")};export{t as createQueryStore,n as useEncodeDataAttribute};//# sourceMappingURL=index.react-server.js.map |
{ | ||
"name": "@sanity/react-loader", | ||
"version": "0.9.2-pink-lizard", | ||
"version": "0.10.0-pink-lizard", | ||
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/react-loader#readme", | ||
@@ -138,10 +138,10 @@ "bugs": { | ||
"dependencies": { | ||
"@sanity/core-loader": "0.8.1-pink-lizard" | ||
"@sanity/core-loader": "0.9.0-pink-lizard" | ||
}, | ||
"devDependencies": { | ||
"@sanity/client": "^6.8.1", | ||
"@sanity/client": "^6.8.5", | ||
"@sanity/pkg-utils": "^3.2.3", | ||
"@types/react": "^18.2.37", | ||
"@typescript-eslint/eslint-plugin": "^6.10.0", | ||
"@typescript-eslint/parser": "^6.10.0", | ||
"@typescript-eslint/eslint-plugin": "^6.11.0", | ||
"@typescript-eslint/parser": "^6.11.0", | ||
"eslint": "^8.53.0", | ||
@@ -157,3 +157,3 @@ "eslint-config-prettier": "^9.0.0", | ||
"peerDependencies": { | ||
"@sanity/client": "^6.8.1", | ||
"@sanity/client": "^6.8.5", | ||
"react": "^18.2.0" | ||
@@ -160,0 +160,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
370886
28
612
+ Added@sanity/core-loader@0.9.0-pink-lizard(transitive)
- Removed@sanity/core-loader@0.8.1-pink-lizard(transitive)