diff --git a/apps/next-app-router/app/Variant.tsx b/apps/next-app-router/app/Variant.tsx
index 2637fad13..847d39c85 100644
--- a/apps/next-app-router/app/Variant.tsx
+++ b/apps/next-app-router/app/Variant.tsx
@@ -1,13 +1,12 @@
-import dynamic from 'next/dynamic'
+import { lazy } from 'react'
-const DefaultVariant = dynamic(() => import('./variants/default'))
-const GroqStoreVariant = dynamic(() => import('./variants/groq-store'))
-const LiveStoreVariant = dynamic(() => import('./variants/live-store'))
+const GroqStoreVariant = lazy(() => import('./variants/groq-store'))
+const LiveStoreVariant = lazy(() => import('./variants/live-store'))
export default function Variant(props: React.PropsWithChildren) {
switch (process.env.VARIANT || 'default') {
case 'default':
- return
+ return <>{props.children}>
case 'groq-store':
return
case 'live-store':
diff --git a/apps/next-app-router/app/layout.tsx b/apps/next-app-router/app/layout.tsx
index f46d8e6dd..5aa61589e 100644
--- a/apps/next-app-router/app/layout.tsx
+++ b/apps/next-app-router/app/layout.tsx
@@ -4,6 +4,8 @@ import { unstable__adapter, unstable__environment } from '@sanity/client'
import DraftModeButton from './DraftModeButton'
import type { Metadata } from 'next'
+export const runtime = 'edge'
+
export const metadata: Metadata = {
title: `next-app-router-${process.env.VARIANT || 'default'}`,
}
diff --git a/apps/next-app-router/app/page.tsx b/apps/next-app-router/app/page.tsx
index 48128cfcc..667d294d9 100644
--- a/apps/next-app-router/app/page.tsx
+++ b/apps/next-app-router/app/page.tsx
@@ -16,6 +16,8 @@ import Variant from './Variant'
import { PreviewTable, PreviewFooter } from './previews'
import { Suspense } from 'react'
+export const runtime = 'edge'
+
export default async function Page() {
const footer = await sanityFetch({
query: footerQuery,
@@ -46,7 +48,7 @@ async function ServerTable() {
query: tableQuery,
tags: ['pages'],
})
-
+
return (
{children}>
}
diff --git a/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx b/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx
index 357ca2a6c..ec2a934a2 100644
--- a/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx
+++ b/apps/next-app-router/app/variants/groq-store/PreviewProvider.tsx
@@ -20,7 +20,6 @@ export default function PreviewProvider({
client={client}
token={token}
logger={console}
- cache={{ includeTypes: ['page'] }}
>
{children}
diff --git a/apps/next-app-router/next.config.mjs b/apps/next-app-router/next.config.mjs
index 8079aeb87..6b9332044 100644
--- a/apps/next-app-router/next.config.mjs
+++ b/apps/next-app-router/next.config.mjs
@@ -7,6 +7,7 @@ const nextConfig = {
fullUrl: true,
},
},
+ reactStrictMode: true,
serverActions: true,
productionBrowserSourceMaps: true,
// Support Vercel Authentication protection
@@ -21,7 +22,7 @@ const nextConfig = {
},
{
key: 'Content-Security-Policy',
- value: `frame-ancestors 'self' https://*.sanity.build`,
+ value: `frame-ancestors 'self' https://*.sanity.build http://localhost:3333`,
},
],
},
diff --git a/apps/next-pages-router/next.config.mjs b/apps/next-pages-router/next.config.mjs
index 1d08ba0b4..123dd3e54 100644
--- a/apps/next-pages-router/next.config.mjs
+++ b/apps/next-pages-router/next.config.mjs
@@ -7,6 +7,7 @@ const nextConfig = {
fullUrl: true,
},
},
+ reactStrictMode: true,
productionBrowserSourceMaps: true,
// Support Vercel Authentication protection
async headers() {
@@ -20,7 +21,7 @@ const nextConfig = {
},
{
key: 'Content-Security-Policy',
- value: `frame-ancestors 'self' https://*.sanity.build`,
+ value: `frame-ancestors 'self' https://*.sanity.build http://localhost:3333`,
},
],
},
diff --git a/apps/remix/app/variants/live-store/index.tsx b/apps/remix/app/variants/live-store/index.tsx
index 26bb2fd3e..83e9217df 100644
--- a/apps/remix/app/variants/live-store/index.tsx
+++ b/apps/remix/app/variants/live-store/index.tsx
@@ -1,5 +1,5 @@
import type { SerializeFrom } from '@vercel/remix'
-import { lazy } from 'react'
+import { StrictMode, lazy } from 'react'
import type { loader } from '~/routes'
@@ -12,9 +12,9 @@ export default function LiveStoreVariant({
studioUrl,
}: SerializeFrom & React.PropsWithChildren) {
return previewDrafts ? (
-
+
{children}
-
+
) : (
children
)
diff --git a/packages/preview-kit/package.json b/packages/preview-kit/package.json
index 1c56c9bdd..f48776e45 100644
--- a/packages/preview-kit/package.json
+++ b/packages/preview-kit/package.json
@@ -106,8 +106,6 @@
"singleQuote": true
},
"dependencies": {
- "@sanity/eventsource": "5.0.1",
- "@sanity/groq-store": "4.1.3",
"@sanity/preview-kit-compat": "1.0.1",
"@vercel/stega": "0.1.0",
"lru-cache": "10.1.0",
diff --git a/packages/preview-kit/src/GroqStoreProvider/GroqStoreProvider.tsx b/packages/preview-kit/src/GroqStoreProvider/GroqStoreProvider.tsx
deleted file mode 100644
index 96fe9c87e..000000000
--- a/packages/preview-kit/src/GroqStoreProvider/GroqStoreProvider.tsx
+++ /dev/null
@@ -1,200 +0,0 @@
-import type { QueryParams } from '@sanity/client'
-import DefaultEventSource from '@sanity/eventsource'
-import { type Config, groqStore } from '@sanity/groq-store'
-import { memo, useEffect, useMemo, useState } from 'react'
-
-import {
- defineListenerContext as ListenerContext,
- IsEnabledContext,
- LoadedListenersContext,
-} from '../context'
-import type {
- DefineListenerContext,
- ListenerGetSnapshot,
- ListenerSubscribe,
- LiveQueryProviderProps,
- Logger,
-} from '../types'
-import {
- DEFAULT_MAX_DOCUMENTS,
- getQueryCacheKey,
- type QueryCacheKey,
- useLoadingListenersContext,
-} from '../utils'
-
-export type { LiveQueryProviderProps, Logger }
-export type { CacheOptions } from '../types'
-
-/**
- * @public
- */
-export interface GroqStoreProviderInternalProps extends Config {
- children: React.ReactNode
- /**
- * @defaultValue true
- */
- listen?: boolean
- /**
- * @defaultValue true
- */
- overlayDrafts?: boolean
- /**
- * @defaultValue 3000
- */
- documentLimit?: number
- logger?: Logger
-}
-/**
- * Caches the store instance, if the config changes you need to pass a new `key` prop to apply it and trigger a re-render
- * @public
- */
-const GroqStoreProviderInternal = memo(function GroqStoreProvider(
- props: GroqStoreProviderInternalProps,
-) {
- const {
- children,
- logger,
- // The rest is the store config
- ...config
- } = props
-
- const [ready] = useState(() => new Set())
- const [loadedListenersContext, updateLoadedListeners] =
- useLoadingListenersContext(ready)
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const [snapshots] = useState(() => new Map())
- const [store] = useState(() =>
- groqStore({
- // Override some of the store defaults
- EventSource: props.token ? DefaultEventSource : undefined,
- listen: true,
- overlayDrafts: true,
- documentLimit: DEFAULT_MAX_DOCUMENTS,
- subscriptionThrottleMs: 1,
- // Spread in the rest
- ...config,
- }),
- )
-
- const report = useMemo(() => {
- if (config.listen) {
- return `Updates are applied in real-time. The cache is set to max ${
- config.documentLimit || DEFAULT_MAX_DOCUMENTS
- } documents.`
- }
- return `Updates require a manual refresh. The cache is set to max ${
- config.documentLimit || DEFAULT_MAX_DOCUMENTS
- } documents.`
- }, [config.documentLimit, config.listen])
- useEffect(() => {
- if (logger) {
- logger.log(
- `[@sanity/preview-kit]: With the current configuration you can expect that: ${report}`,
- )
- }
- }, [logger, report])
-
- // Make sure any async errors bubble up to the nearest error boundary
- const [error, setError] = useState(null)
- // eslint-disable-next-line no-warning-comments
- // @TODO can we just re throw inside the subscription itself?
- if (error) throw error
-
- const [listenerContext] = useState(() => {
- return function defineListener(
- initialSnapshot: QueryResult,
- query: string,
- params: QueryParams,
- ) {
- const key = getQueryCacheKey(query, params)
-
- // groq-store returns on subscriptions when the dataset haven't finished loading yet.
- // We workaround this by setting the initial value as the one provided by the hook
- if (!snapshots.has(key)) {
- snapshots.set(key, initialSnapshot)
- }
-
- const subscribe: ListenerSubscribe = (onStoreChange) => {
- if (!ready.has(key)) {
- store.query(query, params).then((result) => {
- if (!ready.has(key)) {
- snapshots.set(key, result)
-
- ready.add(key)
- updateLoadedListeners()
-
- onStoreChange()
- }
- }, setError)
- }
-
- if (!config.listen) {
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- return () => {}
- }
-
- const subscription = store.subscribe(query, params, (err, result) => {
- if (err) {
- setError(err)
- // Hold off on calling `onStoreChange` until we have a snapshot
- } else if (ready.has(key)) {
- snapshots.set(key, result)
- onStoreChange()
- }
- })
- return () => subscription.unsubscribe()
- }
- const getSnapshot: ListenerGetSnapshot = () =>
- snapshots.get(key)
-
- return { subscribe, getSnapshot }
- } satisfies DefineListenerContext
- })
-
- return (
-
-
- {children}
-
-
- )
-})
-
-/**
- * Handles live query updates using `@sanity/groq-store`
- * @internal
- */
-const GroqStoreProvider = memo(function GroqStoreProvider(
- props: LiveQueryProviderProps,
-) {
- const { children, client, cache, logger } = props
- const {
- projectId,
- dataset,
- token,
- // eslint-disable-next-line no-warning-comments
- // @TODO @sanity/groq-store should handle `perspective` directly
- perspective = 'previewDrafts',
- requestTagPrefix,
- } = useMemo(() => client.config(), [client])
-
- return (
-
- {children}
-
- )
-})
-GroqStoreProvider.displayName = 'GroqStoreProvider'
-
-export default GroqStoreProvider
diff --git a/packages/preview-kit/src/GroqStoreProvider/index.ts b/packages/preview-kit/src/GroqStoreProvider/index.ts
deleted file mode 100644
index 898595d6a..000000000
--- a/packages/preview-kit/src/GroqStoreProvider/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './GroqStoreProvider'
-export { default } from './GroqStoreProvider'
diff --git a/packages/preview-kit/src/LiveQueryProvider/createLiveQueryProvider.tsx b/packages/preview-kit/src/LiveQueryProvider/createLiveQueryProvider.tsx
index 7c07a7cf3..cd407887d 100644
--- a/packages/preview-kit/src/LiveQueryProvider/createLiveQueryProvider.tsx
+++ b/packages/preview-kit/src/LiveQueryProvider/createLiveQueryProvider.tsx
@@ -1,94 +1,21 @@
-/* eslint-disable @typescript-eslint/no-non-null-assertion */
-import { memo, Suspense, useEffect, useMemo, useState } from 'react'
+import { memo, useState } from 'react'
import type { LiveQueryProviderProps, Logger } from '../types'
-import { DEFAULT_MAX_DOCUMENTS, DEFAULT_TAG } from '../utils'
+import { DEFAULT_TAG } from '../utils'
export type { LiveQueryProviderProps, Logger }
export type { CacheOptions } from '../types'
/**
+ * @deprecated Use `LiveQueryProvider` instead
* @internal
*/
export function createLiveQueryProvider(options: {
- GroqStoreProvider: React.ComponentType
+ /** @deprecated this property is unused */
+ GroqStoreProvider?: React.ComponentType
LiveStoreProvider: React.ComponentType
}): React.ComponentType {
- const { GroqStoreProvider, LiveStoreProvider } = options
-
- const SelectStoreProvider = memo((props: LiveQueryProviderProps) => {
- const { children, refreshInterval, client, cache, logger } = props
- const maxDocuments = cache?.maxDocuments ?? DEFAULT_MAX_DOCUMENTS
- const [documentsCount, setDocumentsCount] = useState(null)
- const [error, setError] = useState(null)
- const [includeTypes] = useState(() => cache?.includeTypes ?? [])
-
- // Rethrow errors to the nearest error boundary
- if (error) {
- throw error
- }
-
- useEffect(() => {
- if (documentsCount !== null) {
- return
- }
-
- logger?.log('[@sanity/preview-kit]: fetch documents count')
- const controller = new AbortController()
- client
- .fetch(
- includeTypes.length > 0
- ? 'count(*[_type in $includeTypes])'
- : 'count(*)',
- { includeTypes },
- { filterResponse: true, signal: controller.signal },
- )
- .then((result) => {
- logger?.log('[@sanity/preview-kit]: documents count', result)
- setDocumentsCount(result)
- })
- .catch((error) => {
- if (error.name !== 'AbortError') {
- setError(error)
- }
- })
- return () => {
- controller.abort()
- }
- }, [client, documentsCount, includeTypes, logger])
-
- if (documentsCount === null) {
- return children
- }
-
- if (refreshInterval && documentsCount >= maxDocuments) {
- return (
-
-
- {children}
-
-
- )
- }
-
- if (documentsCount >= maxDocuments) {
- throw new Error(
- `[@sanity/preview-kit]: You have ${documentsCount} documents in your dataset, which is more than the maximum of ${maxDocuments} documents. Please reduce the number of documents in your dataset or increase the limit.`,
- )
- }
-
- return (
-
- {children}
-
- )
- })
- SelectStoreProvider.displayName = 'SelectStoreProvider'
+ const { LiveStoreProvider } = options
const LiveQueryProvider = memo((props: LiveQueryProviderProps) => {
const { children, refreshInterval = 10000, token } = props
@@ -104,7 +31,10 @@ export function createLiveQueryProvider(options: {
const { requestTagPrefix, resultSourceMap } = props.client.config()
return props.client.withConfig({
requestTagPrefix: requestTagPrefix || DEFAULT_TAG,
- resultSourceMap: resultSourceMap || 'withKeyArraySelector',
+ resultSourceMap:
+ resultSourceMap === 'withKeyArraySelector'
+ ? 'withKeyArraySelector'
+ : true,
// Set the recommended defaults, this is a convenience to make it easier to share a client config from a server component to the client component
...(token && {
token,
@@ -114,43 +44,16 @@ export function createLiveQueryProvider(options: {
}),
})
})
-
- const [cache] = useState(() => props.cache)
const [logger] = useState(() => props.logger)
- const turboSourceMap = useMemo(() => {
- const { resultSourceMap } = client.config()
- return (
- props.turboSourceMap ??
- (resultSourceMap === 'withKeyArraySelector' || resultSourceMap)
- )
- }, [client, props.turboSourceMap])
-
- if (turboSourceMap) {
- return (
-
-
- {children}
-
-
- )
- }
return (
-
-
- {children}
-
-
+
+ {children}
+
)
})
LiveQueryProvider.displayName = 'LiveQueryProvider'
diff --git a/packages/preview-kit/src/LiveQueryProvider/index.tsx b/packages/preview-kit/src/LiveQueryProvider/index.tsx
index 570f7beb4..7ca9132ec 100644
--- a/packages/preview-kit/src/LiveQueryProvider/index.tsx
+++ b/packages/preview-kit/src/LiveQueryProvider/index.tsx
@@ -4,11 +4,9 @@ import { createLiveQueryProvider } from './createLiveQueryProvider'
export * from './createLiveQueryProvider'
-const GroqStoreProvider = lazy(() => import('../GroqStoreProvider'))
const LiveStoreProvider = lazy(() => import('../LiveStoreProvider'))
/** @public */
export const LiveQueryProvider = createLiveQueryProvider({
- GroqStoreProvider,
LiveStoreProvider,
})
diff --git a/packages/preview-kit/src/LiveStoreProvider/LiveStoreProvider.tsx b/packages/preview-kit/src/LiveStoreProvider/LiveStoreProvider.tsx
index 2fa80d310..73630c681 100644
--- a/packages/preview-kit/src/LiveStoreProvider/LiveStoreProvider.tsx
+++ b/packages/preview-kit/src/LiveStoreProvider/LiveStoreProvider.tsx
@@ -57,12 +57,6 @@ export interface LiveStoreProviderProps {
* @defaultValue 10000
*/
refreshInterval?: number
- /**
- * Listen to mutations on the documents used by your queries, and apply patches directly to the result.
- * Requires Content Source Maps to work.
- * @defaultValue true
- */
- turboSourceMap?: boolean
logger?: Logger
}
/**
@@ -71,37 +65,15 @@ export interface LiveStoreProviderProps {
const LiveStoreProvider = memo(function LiveStoreProvider(
props: LiveStoreProviderProps,
) {
- const {
- children,
- client,
- refreshInterval = 10000,
- turboSourceMap = true,
- logger,
- } = props
+ const { children, client, refreshInterval = 10000, logger } = props
- // Check if the client is configured to use Content Source Maps if turbo is enabled
- // It's wrapped inside `useMemo` so it doesn't call `client.config` more than it needs to, but unlike `useEffect` sooner rather than later
- useMemo(() => {
- if (turboSourceMap && !client.config().resultSourceMap) {
- logger?.error(
- 'The client needs to be configured with `resultSourceMap: true` to enable turbo mode.`',
- )
- }
- }, [client, turboSourceMap, logger])
-
- const report = useMemo(() => {
- if (turboSourceMap && client.config().resultSourceMap) {
- return `Updates that can be traced using Content Source Maps will be applied in real-time. Other updates will be applied every ${refreshInterval}ms.`
- }
- return `Updates will be applied every ${refreshInterval}ms.`
- }, [client, refreshInterval, turboSourceMap])
useEffect(() => {
if (logger) {
logger.log(
- `[@sanity/preview-kit]: With the current configuration you can expect that: ${report}`,
+ `[@sanity/preview-kit]: With the current configuration you can expect that: Updates that can be traced using Content Source Maps will be applied in real-time. Other updates will be applied every ${refreshInterval}ms.`,
)
}
- }, [logger, report])
+ }, [logger, refreshInterval])
const [subscriptions, setSubscriptions] = useState([])
const [snapshots] = useState(() => new Map())
@@ -139,7 +111,6 @@ const LiveStoreProvider = memo(function LiveStoreProvider(
)
const turboIdsFromSourceMap = useCallback(
(contentSourceMap: ContentSourceMap) => {
- if (!turboSourceMap) return
// This handler only adds ids, on each query fetch. But that's ok since purges ids that are unused
const nextTurboIds = new Set()
docsInUse.clear()
@@ -164,22 +135,20 @@ const LiveStoreProvider = memo(function LiveStoreProvider(
}),
)
},
- [turboSourceMap, docsInUse],
+ [docsInUse],
)
return (
{children}
- {turboSourceMap && (
-
- )}
+
{subscriptions.map((key) => {
if (!hooks.cache.has(key)) return null
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
diff --git a/packages/preview-kit/src/context.ts b/packages/preview-kit/src/context.ts
index e55a6e49b..5201d7f67 100644
--- a/packages/preview-kit/src/context.ts
+++ b/packages/preview-kit/src/context.ts
@@ -2,7 +2,6 @@ import { createContext } from 'react'
import { NoStoreContext } from './no-store'
import { DefineListenerContext } from './types'
-import { QueryCacheKey } from './utils'
/**
* @internal
@@ -10,17 +9,11 @@ import { QueryCacheKey } from './utils'
export const defineListenerContext =
createContext(NoStoreContext)
-/**
- * If it's `null` then the listener should be treated as `success`, otherwise if a listener isn't in the array it should be considered as `loading`
- * @internal
- */
-export const LoadedListenersContext = createContext(
- null,
-)
-
/**
* Aids in debugging, notifying if the parent has a GroqStoreProvider, or a LiveStoreProvider, and is thus `live`.
* This is helpful as the `useLiveQuery` hook itself works even if no provider is present, but it will not be `live`.
* @internal
*/
export const IsEnabledContext = createContext(false)
+
+console.log('once or twice?')
diff --git a/packages/preview-kit/src/hooks.ts b/packages/preview-kit/src/hooks.ts
index 28ca7586f..1432b990e 100644
--- a/packages/preview-kit/src/hooks.ts
+++ b/packages/preview-kit/src/hooks.ts
@@ -3,12 +3,8 @@ import { useCallback, useContext, useMemo, useState } from 'react'
import isFastEqual from 'react-fast-compare'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'
-import {
- defineListenerContext,
- IsEnabledContext,
- LoadedListenersContext,
-} from './context'
-import { getQueryCacheKey, useParams } from './utils'
+import { defineListenerContext, IsEnabledContext } from './context'
+import { useParams } from './utils'
// Re-export types we use that are needed externally
export type { ClientQueryParams }
@@ -76,30 +72,12 @@ export function useLiveQuery<
selector,
isEqual,
)
- const loading = useLiveQueryIsLoading(query, params)
+ const enabled = useIsEnabled()
+ const loading = enabled && serverSnapshot === snapshot
return [snapshot, loading]
}
-/**
- * Wether a particular query is loading or not.
- * @public
- */
-function useLiveQueryIsLoading(
- query: string,
- params: ClientQueryParams,
-): QueryLoading {
- const loadedListeners = useContext(LoadedListenersContext)
- const key = useMemo(() => getQueryCacheKey(query, params), [params, query])
-
- return useMemo(() => {
- if (Array.isArray(loadedListeners)) {
- return loadedListeners.includes(key) ? false : true
- }
- return false
- }, [key, loadedListeners])
-}
-
/**
* The `useLiveQuery` hook is designed to work in environments where the parent `LiveQueryProvider` may be lazy loaded.
* Thus if it can't "know" if it's "live" or not, or of it will be later. When everything is setup correctly this is fine.
diff --git a/packages/preview-kit/src/types.ts b/packages/preview-kit/src/types.ts
index 84cdc9a17..410e2a403 100644
--- a/packages/preview-kit/src/types.ts
+++ b/packages/preview-kit/src/types.ts
@@ -31,7 +31,10 @@ export type Logger =
| typeof console
| Pick
-/** @public */
+/**
+ * @public
+ * @deprecated these options are no longer used
+ */
export interface CacheOptions {
/**
* Uses a `Listen` API call with EventSource to stream updates in real-time to the documents cache
@@ -61,10 +64,10 @@ export interface LiveQueryProviderProps {
* for example by: `client={client.withConfig({token})}`
*/
token?: string
+ /** @deprecated these options are no longer used */
cache?: CacheOptions
/**
- * Uses a `Listen` API call with EventSource to stream updates in real-time to the documents cache, powered by `Content Source Map` metadata
- * @defaultValue true
+ * @deprecated this option is now always enabled
*/
turboSourceMap?: boolean
/**
diff --git a/packages/preview-kit/src/utils.ts b/packages/preview-kit/src/utils.ts
index c900114cc..586e18d17 100644
--- a/packages/preview-kit/src/utils.ts
+++ b/packages/preview-kit/src/utils.ts
@@ -1,12 +1,5 @@
import type { QueryParams } from '@sanity/client'
-import {
- startTransition,
- useCallback,
- useEffect,
- useMemo,
- useReducer,
- useRef,
-} from 'react'
+import { useMemo } from 'react'
/**
* @internal
@@ -36,33 +29,4 @@ export function useParams(
return useMemo(() => JSON.parse(stringifiedParams), [stringifiedParams])
}
-/**
- * @internal
- */
-export function useLoadingListenersContext(
- ready: Set,
-): [QueryCacheKey[], () => void] {
- const [tick, forceUpdate] = useReducer((x) => x + 1, 0)
- const mountedRef = useRef(true)
- const scheduleUpdate = useCallback(() => {
- if (mountedRef.current) {
- startTransition(() => forceUpdate())
- }
- }, [])
- useEffect(() => {
- mountedRef.current = true
- scheduleUpdate()
- return () => {
- mountedRef.current = false
- }
- }, [scheduleUpdate])
- const loadedListenersContext = useMemo(
- () => (tick ? [...ready] : []),
- [ready, tick],
- )
-
- return [loadedListenersContext, scheduleUpdate]
-}
-
-export const DEFAULT_MAX_DOCUMENTS = 3000
export const DEFAULT_TAG = 'sanity.preview-kit'
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 91ac486e4..41c0ef765 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -254,12 +254,6 @@ importers:
packages/preview-kit:
dependencies:
- '@sanity/eventsource':
- specifier: 5.0.1
- version: 5.0.1
- '@sanity/groq-store':
- specifier: 4.1.3
- version: 4.1.3
'@sanity/preview-kit-compat':
specifier: 1.0.1
version: 1.0.1(@sanity/client@6.9.1)(react@18.2.0)
@@ -3591,23 +3585,6 @@ packages:
resolution: {integrity: sha512-wtMYcV5GIDIhVyF/jjmdwq1GdlK07dRL40XMns73VbrFI7FteRltxv48bhYVZPcLkRXb0SHjpDS/icj9/yzbVA==}
dev: false
- /@sanity/groq-store@4.1.3:
- resolution: {integrity: sha512-Yh3zbCkpnrowIG8+tMoZHGxV9HFMWVlZ4zhNfF1Y2rygi14SJteV+ildrlq3/OFq9/Y/cc6iXSD/+U6dErIpNw==}
- engines: {node: '>= 18'}
- dependencies:
- '@sanity/eventsource': 5.0.1
- '@sanity/types': 3.20.2
- fast-deep-equal: 3.1.3
- groq: 3.20.2
- groq-js: 1.3.0
- mendoza: 3.0.3
- simple-get: 4.0.1
- split2: 4.2.0
- throttle-debounce: 5.0.0
- transitivePeerDependencies:
- - supports-color
- dev: false
-
/@sanity/groq-store@5.0.1-experimental(@sanity/client@6.9.1):
resolution: {integrity: sha512-3qKQVxQW7j0n4DbmiFzEhC9jLK51u2F0d1xGYUWn0dUU5wrot2BfdlINGdCFze9FjvoPrOkihD6rc51Gfnk2xg==}
engines: {node: '>=18'}
@@ -6175,6 +6152,7 @@ packages:
engines: {node: '>=10'}
dependencies:
mimic-response: 3.1.0
+ dev: true
/decompress-response@7.0.0:
resolution: {integrity: sha512-6IvPrADQyyPGLpMnUh6kfKiqy7SrbXbjoUuZ90WMBJKErzv2pCiwlGEXjRX9/54OnTq+XFVnkOnOMzclLI5aEA==}
@@ -12249,18 +12227,6 @@ packages:
pkg-conf: 2.1.0
dev: true
- /simple-concat@1.0.1:
- resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
- dev: false
-
- /simple-get@4.0.1:
- resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
- dependencies:
- decompress-response: 6.0.0
- once: 1.4.0
- simple-concat: 1.0.1
- dev: false
-
/simple-wcswidth@1.0.1:
resolution: {integrity: sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg==}
dev: false
@@ -12456,6 +12422,7 @@ packages:
/split2@4.2.0:
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
engines: {node: '>= 10.x'}
+ dev: true
/sprintf-js@1.0.3:
resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==}
@@ -12814,11 +12781,6 @@ packages:
/text-table@0.2.0:
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
- /throttle-debounce@5.0.0:
- resolution: {integrity: sha512-2iQTSgkkc1Zyk0MeVrt/3BvuOXYPl/R8Z0U2xxo9rjwNciaHDG3R+Lm6dh4EeUci49DanvBnuqI6jshoQQRGEg==}
- engines: {node: '>=12.22'}
- dev: false
-
/through2@2.0.5:
resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==}
dependencies: