Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/react-loader

Package Overview
Dependencies
Maintainers
41
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/react-loader - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

14

CHANGELOG.md

@@ -15,2 +15,16 @@ # Changelog

## [1.1.1](https://github.com/sanity-io/visual-editing/compare/react-loader-v1.1.0...react-loader-v1.1.1) (2023-11-27)
### Bug Fixes
* set `tag` in `fetch` and `listen` methods ([4867aee](https://github.com/sanity-io/visual-editing/commit/4867aee5bd0f2b33445852ee7fcb17bd29804564))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @sanity/core-loader bumped to 1.0.2
## [1.1.0](https://github.com/sanity-io/visual-editing/compare/react-loader-v1.0.2...react-loader-v1.1.0) (2023-11-20)

@@ -17,0 +31,0 @@

2

dist/index.js

@@ -1,1 +0,1 @@

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{loadQuery:async(e,t={},r={})=>{const{perspective:n="published"}=r;if("undefined"!=typeof document)throw new Error("Cannot use `loadQuery` 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
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:o,setServerClient:i,enableLiveMode:a,unstable__cache:u,unstable__serverClient:c}=e({tag:"react-loader",...s}),l={};return{loadQuery:async(e,t={},r={})=>{const{perspective:n="published"}=r;if("undefined"!=typeof document)throw new Error("Cannot use `loadQuery` 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:o}=await r.fetch(e,t,{filterResponse:!1,resultSourceMap:"withKeyArraySelector",perspective:n});return{data:s,sourceMap:o,perspective:n}}const{result:s,resultSourceMap:o}=await u.fetch(JSON.stringify({query:e,params:t}));return o?{data:s,sourceMap:o}:{data:s}},useQuery:(e,s=l,i={})=>{const[a]=t((()=>i.initial?{perspective:"published",...i.initial}:void 0)),u=r((()=>JSON.stringify(s)),[s]),[c,p]=t((()=>o(e,JSON.parse(u),a).value));return n((()=>{const t=o(e,JSON.parse(u),a).listen((e=>{p(e)}));return()=>t()}),[u,a,e]),c},setServerClient:i,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

@@ -1,1 +0,1 @@

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{loadQuery:()=>{throw new Error("The `loadQuery` 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
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({tag:"react-loader.rsc",...o}),c={};return{loadQuery:()=>{throw new Error("The `loadQuery` function is server only.")},useQuery:(e,o=c,s={})=>{const[a]=r((()=>s.initial?{perspective:"published",...s.initial}:void 0)),u=t((()=>JSON.stringify(o)),[o]),[l,d]=r((()=>i(e,JSON.parse(u),a).value));return n((()=>{const r=i(e,JSON.parse(u),a).listen((e=>{d(e)}));return()=>r()}),[u,a,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 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{loadQuery: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
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:r,unstable__serverClient:n}=e({tag:"react-loader.rsc",...t});return{loadQuery:async(e,t={},r={})=>{const{perspective:o="published"}=r;if("previewDrafts"===o&&!n.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||n.instance.config().useCdn||r.cache||r.next?n.instance.config().useCdn?n.instance.withConfig({useCdn:!1}):n.instance:n.instance.withConfig({useCdn:!0}),{result:a,resultSourceMap:c}=await s.fetch(e,t,{filterResponse:!1,cache:r.next?void 0:"no-store",...r,perspective:o});return{data:a,sourceMap:c,perspective:"previewDrafts"===o?o:void 0}},setServerClient:r,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.")}}},r=()=>{throw new Error("The `useEncodeDataAttribute` hook can only be called from a client component.")};export{t as createQueryStore,r as useEncodeDataAttribute};//# sourceMappingURL=index.react-server.js.map
{
"name": "@sanity/react-loader",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/react-loader#readme",

@@ -138,3 +138,3 @@ "bugs": {

"dependencies": {
"@sanity/core-loader": "1.0.1"
"@sanity/core-loader": "1.0.2"
},

@@ -144,3 +144,3 @@ "devDependencies": {

"@sanity/pkg-utils": "^3.2.4",
"@types/react": "^18.2.37",
"@types/react": "^18.2.38",
"@typescript-eslint/eslint-plugin": "^6.12.0",

@@ -153,6 +153,6 @@ "@typescript-eslint/parser": "^6.12.0",

"react": "^18.2.0",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"vitest": "^0.34.6",
"visual-editing-helpers": "0.0.0",
"channels": "0.0.0"
"channels": "0.0.0",
"visual-editing-helpers": "0.0.0"
},

@@ -159,0 +159,0 @@ "peerDependencies": {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc