diff --git a/packages/sanity/src/core/comments/hooks/useNotificationTarget.ts b/packages/sanity/src/core/comments/hooks/useNotificationTarget.ts index 19a32e796e1..6111cb5e910 100644 --- a/packages/sanity/src/core/comments/hooks/useNotificationTarget.ts +++ b/packages/sanity/src/core/comments/hooks/useNotificationTarget.ts @@ -4,7 +4,7 @@ import {of} from 'rxjs' import {usePaneRouter} from 'sanity/structure' import {useSchema} from '../../hooks/useSchema' -import {getPreviewStateObservable} from '../../preview' +import {getPreviewStateObservable} from '../../preview/utils/getPreviewStateObservable' import {useDocumentPreviewStore} from '../../store/_legacy/datastores' import {useWorkspace} from '../../studio/workspace' import {COMMENTS_INSPECTOR_NAME} from '../constants' diff --git a/packages/sanity/src/core/form/__workshop__/_common/resolvePreviewComponent.tsx b/packages/sanity/src/core/form/__workshop__/_common/resolvePreviewComponent.tsx index 31a50b3fd08..0f5c84f317e 100644 --- a/packages/sanity/src/core/form/__workshop__/_common/resolvePreviewComponent.tsx +++ b/packages/sanity/src/core/form/__workshop__/_common/resolvePreviewComponent.tsx @@ -2,7 +2,7 @@ import {Card, Code, ErrorBoundary, Stack} from '@sanity/ui' import {type ErrorInfo, useCallback, useState} from 'react' import {Button} from '../../../../ui-components' -import {PreviewLoader} from '../../../preview' +import {PreviewLoader} from '../../../preview/components/PreviewLoader' export const resolvePreviewComponent = () => TestPreview diff --git a/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferencePreview.tsx b/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferencePreview.tsx index 1b048c8062b..b5c70a314ce 100644 --- a/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferencePreview.tsx +++ b/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferencePreview.tsx @@ -9,7 +9,7 @@ import {Tooltip} from '../../../../ui-components' import {DefaultPreview, type PreviewMediaDimensions, TextWithTone} from '../../../components' import {type FIXME} from '../../../FIXME' import {useTranslation} from '../../../i18n' -import {type DocumentAvailability} from '../../../preview' +import {type DocumentAvailability} from '../../../preview/types' import {StyledPreviewFlex} from './CrossDatasetReferencePreview.styled' /** diff --git a/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/types.ts b/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/types.ts index 142d59264f1..f93a7b70927 100644 --- a/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/types.ts +++ b/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/types.ts @@ -1,7 +1,7 @@ import {type PreviewValue} from '@sanity/types' import {type Observable} from 'rxjs' -import {type DocumentAvailability} from '../../../preview' +import {type DocumentAvailability} from '../../../preview/types' /** @internal */ export interface CrossDatasetReferenceInfo { diff --git a/packages/sanity/src/core/form/inputs/PortableText/__workshop__/_common/resolvePreviewComponent.tsx b/packages/sanity/src/core/form/inputs/PortableText/__workshop__/_common/resolvePreviewComponent.tsx index c064f2f4ead..aee2791e0f5 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/__workshop__/_common/resolvePreviewComponent.tsx +++ b/packages/sanity/src/core/form/inputs/PortableText/__workshop__/_common/resolvePreviewComponent.tsx @@ -2,7 +2,8 @@ import {Card, Code, ErrorBoundary, Stack} from '@sanity/ui' import {type ErrorInfo, useCallback, useState} from 'react' import {Button} from '../../../../../../ui-components' -import {PreviewLoader, SanityDefaultPreview} from '../../../../../preview' +import {PreviewLoader} from '../../../../../preview/components/PreviewLoader' +import {SanityDefaultPreview} from '../../../../../preview/components/SanityDefaultPreview' export const resolvePreviewComponent = () => TestPreview diff --git a/packages/sanity/src/core/form/inputs/ReferenceInput/PreviewReferenceValue.tsx b/packages/sanity/src/core/form/inputs/ReferenceInput/PreviewReferenceValue.tsx index 78d47fe202c..4774f587611 100644 --- a/packages/sanity/src/core/form/inputs/ReferenceInput/PreviewReferenceValue.tsx +++ b/packages/sanity/src/core/form/inputs/ReferenceInput/PreviewReferenceValue.tsx @@ -7,7 +7,7 @@ import {Tooltip} from '../../../../ui-components' import {type PreviewLayoutKey, TextWithTone} from '../../../components' import {useListFormat} from '../../../hooks/useListFormat' import {Translate, useTranslation} from '../../../i18n' -import {SanityDefaultPreview} from '../../../preview' +import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' import {type RenderPreviewCallback} from '../../types' import {ReferencePreview} from './ReferencePreview' import {type ReferenceInfo} from './types' diff --git a/packages/sanity/src/core/form/inputs/ReferenceInput/types.ts b/packages/sanity/src/core/form/inputs/ReferenceInput/types.ts index 933afbdb68d..55d335111bf 100644 --- a/packages/sanity/src/core/form/inputs/ReferenceInput/types.ts +++ b/packages/sanity/src/core/form/inputs/ReferenceInput/types.ts @@ -8,7 +8,7 @@ import { import {type ComponentType, type ReactNode} from 'react' import {type Observable} from 'rxjs' -import {type DocumentAvailability} from '../../../preview' +import {type DocumentAvailability} from '../../../preview/types' import {type ObjectInputProps} from '../../types' export interface ReferenceInfo { diff --git a/packages/sanity/src/core/form/studio/FormBuilder.tsx b/packages/sanity/src/core/form/studio/FormBuilder.tsx index 2c1b1a41e87..20b6f95c563 100644 --- a/packages/sanity/src/core/form/studio/FormBuilder.tsx +++ b/packages/sanity/src/core/form/studio/FormBuilder.tsx @@ -6,7 +6,7 @@ import {useCallback, useRef} from 'react' import {type DocumentFieldAction} from '../../config' import {type FormNodePresence} from '../../presence' -import {PreviewLoader} from '../../preview' +import {PreviewLoader} from '../../preview/components/PreviewLoader' import {EMPTY_ARRAY} from '../../util' import {FormValueProvider} from '../contexts/FormValue' import {GetFormValueProvider} from '../contexts/GetFormValue' diff --git a/packages/sanity/src/core/form/studio/inputResolver/inputResolver.tsx b/packages/sanity/src/core/form/studio/inputResolver/inputResolver.tsx index df0b96549ab..aadf4d4a56b 100644 --- a/packages/sanity/src/core/form/studio/inputResolver/inputResolver.tsx +++ b/packages/sanity/src/core/form/studio/inputResolver/inputResolver.tsx @@ -9,7 +9,7 @@ import {type ComponentType} from 'react' import {type PreviewProps} from '../../../components' import {type FIXME} from '../../../FIXME' -import {SanityDefaultPreview} from '../../../preview' +import {SanityDefaultPreview} from '../../../preview/components/SanityDefaultPreview' import {type InputProps} from '../../types' import * as is from '../../utils/is' import {StudioReferenceInput} from '../inputs/reference/StudioReferenceInput' diff --git a/packages/sanity/src/core/form/studio/inputs/client-adapters/assets.ts b/packages/sanity/src/core/form/studio/inputs/client-adapters/assets.ts index b094fa46e70..58b3371a4db 100644 --- a/packages/sanity/src/core/form/studio/inputs/client-adapters/assets.ts +++ b/packages/sanity/src/core/form/studio/inputs/client-adapters/assets.ts @@ -3,7 +3,7 @@ import {type FileAsset, type ImageAsset} from '@sanity/types' import {Observable, of as observableOf} from 'rxjs' import {catchError, map, mergeMap} from 'rxjs/operators' -import {type DocumentPreviewStore} from '../../../../preview' +import {type DocumentPreviewStore} from '../../../../preview/documentPreviewStore' import {type UploadOptions} from '../../uploads/types' import {withMaxConcurrency} from '../../utils' diff --git a/packages/sanity/src/core/form/studio/inputs/client-adapters/reference.ts b/packages/sanity/src/core/form/studio/inputs/client-adapters/reference.ts index 699120fc4a6..a80468da18c 100644 --- a/packages/sanity/src/core/form/studio/inputs/client-adapters/reference.ts +++ b/packages/sanity/src/core/form/studio/inputs/client-adapters/reference.ts @@ -4,7 +4,9 @@ import {type ReferenceFilterSearchOptions, type ReferenceSchemaType} from '@sani import {combineLatest, type Observable, of} from 'rxjs' import {map, mergeMap, startWith, switchMap} from 'rxjs/operators' -import {type DocumentPreviewStore, getPreviewPaths, prepareForPreview} from '../../../../preview' +import {type DocumentPreviewStore} from '../../../../preview/documentPreviewStore' +import {getPreviewPaths} from '../../../../preview/utils/getPreviewPaths' +import {prepareForPreview} from '../../../../preview/utils/prepareForPreview' import {createSearch} from '../../../../search' import {collate, type CollatedHit, getDraftId, getIdPair, isRecord} from '../../../../util' import {type ReferenceInfo, type ReferenceSearchHit} from '../../../inputs/ReferenceInput/types' diff --git a/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/datastores/getReferenceInfo.ts b/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/datastores/getReferenceInfo.ts index 37a2f44414f..58a4675d2df 100644 --- a/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/datastores/getReferenceInfo.ts +++ b/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/datastores/getReferenceInfo.ts @@ -5,13 +5,10 @@ import {combineLatest, type Observable, of} from 'rxjs' import {map, switchMap} from 'rxjs/operators' import {type FIXME} from '../../../../../FIXME' -import { - type DocumentAvailability, - type DocumentPreviewStore, - getPreviewPaths, - prepareForPreview, - type Previewable, -} from '../../../../../preview' +import {type DocumentPreviewStore} from '../../../../../preview/documentPreviewStore' +import {type DocumentAvailability, type Previewable} from '../../../../../preview/types' +import {getPreviewPaths} from '../../../../../preview/utils/getPreviewPaths' +import {prepareForPreview} from '../../../../../preview/utils/prepareForPreview' import {isRecord} from '../../../../../util' import {type CrossDatasetReferenceInfo} from '../../../../inputs/CrossDatasetReferenceInput/types' diff --git a/packages/sanity/src/core/index.ts b/packages/sanity/src/core/index.ts index 15e41716d41..55e8a1a8f86 100644 --- a/packages/sanity/src/core/index.ts +++ b/packages/sanity/src/core/index.ts @@ -40,7 +40,16 @@ export * from './hooks/useUserListWithPermissions' export * from './hooks/useValidationStatus' export * from './i18n' export * from './presence' -export * from './preview' +export * from './preview/components/Preview' +export * from './preview/components/PreviewLoader' +export * from './preview/components/SanityDefaultPreview' +export * from './preview/documentPreviewStore' +export * from './preview/types' +export * from './preview/useValuePreview' +export {getPreviewPaths} from './preview/utils/getPreviewPaths' +export {getPreviewStateObservable} from './preview/utils/getPreviewStateObservable' +export {getPreviewValueWithFallback} from './preview/utils/getPreviewValueWithFallback' +export {prepareForPreview} from './preview/utils/prepareForPreview' export * from './schema' export type {SearchFactoryOptions, SearchOptions, SearchSort, SearchTerms} from './search' export {createSearch, getSearchableTypes} from './search' diff --git a/packages/sanity/src/core/preview/components/Preview.tsx b/packages/sanity/src/core/preview/components/Preview.tsx index c1311363e10..6902984e27a 100644 --- a/packages/sanity/src/core/preview/components/Preview.tsx +++ b/packages/sanity/src/core/preview/components/Preview.tsx @@ -1,6 +1,6 @@ import {usePreviewComponent} from '../../form/form-components-hooks' import {type RenderPreviewCallbackProps} from '../../form/types' -import {PreviewLoader} from '../index' +import {PreviewLoader} from './PreviewLoader' /** * @internal diff --git a/packages/sanity/src/core/preview/index.ts b/packages/sanity/src/core/preview/index.ts deleted file mode 100644 index 5a283024f4d..00000000000 --- a/packages/sanity/src/core/preview/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './components/Preview' -export * from './components/PreviewLoader' -export * from './components/SanityDefaultPreview' -export * from './documentPreviewStore' -export * from './types' -export * from './useValuePreview' -export {getPreviewPaths} from './utils/getPreviewPaths' -export {getPreviewStateObservable} from './utils/getPreviewStateObservable' -export {getPreviewValueWithFallback} from './utils/getPreviewValueWithFallback' -export {prepareForPreview} from './utils/prepareForPreview' diff --git a/packages/sanity/src/core/store/_legacy/datastores.ts b/packages/sanity/src/core/store/_legacy/datastores.ts index 31b48595291..b0b092837a4 100644 --- a/packages/sanity/src/core/store/_legacy/datastores.ts +++ b/packages/sanity/src/core/store/_legacy/datastores.ts @@ -4,7 +4,10 @@ import {useMemo} from 'react' import {useClient} from '../../hooks/useClient' import {useSchema} from '../../hooks/useSchema' import {useTemplates} from '../../hooks/useTemplates' -import {createDocumentPreviewStore, type DocumentPreviewStore} from '../../preview' +import { + createDocumentPreviewStore, + type DocumentPreviewStore, +} from '../../preview/documentPreviewStore' import {useSource, useWorkspace} from '../../studio' import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../studioClient' import {createKeyValueStore} from '../key-value/KeyValueStore' diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts index 6d17e3c08bf..29b85b7b580 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts @@ -15,7 +15,10 @@ import {buffer, publish, takeWhile} from 'rxjs/operators' import {createMockSanityClient} from '../../../../../../test/mocks/mockSanityClient' import {getFallbackLocaleSource} from '../../../../i18n/fallback' -import {type DocumentAvailability, type DraftsModelDocumentAvailability} from '../../../../preview' +import { + type DocumentAvailability, + type DraftsModelDocumentAvailability, +} from '../../../../preview/types' import {createSchema} from '../../../../schema' import {editState, type EditStateFor} from './editState' import {validation} from './validation' diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/validation.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/validation.ts index 360ddc475ac..3d4d1457924 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/validation.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/validation.ts @@ -30,7 +30,7 @@ import shallowEquals from 'shallow-equals' import {type SourceClientOptions} from '../../../../config' import {type LocaleSource} from '../../../../i18n' -import {type DraftsModelDocumentAvailability} from '../../../../preview' +import {type DraftsModelDocumentAvailability} from '../../../../preview/types' import {validateDocumentObservable, type ValidationContext} from '../../../../validation' import {type IdPair} from '../types' import {memoize} from '../utils/createMemoizer' diff --git a/packages/sanity/src/core/store/_legacy/document/document-store.ts b/packages/sanity/src/core/store/_legacy/document/document-store.ts index d40dabcf9b7..96d3af8554c 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-store.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-store.ts @@ -5,7 +5,7 @@ import {filter, map} from 'rxjs/operators' import {type SourceClientOptions} from '../../../config' import {type LocaleSource} from '../../../i18n' -import {type DocumentPreviewStore} from '../../../preview' +import {type DocumentPreviewStore} from '../../../preview/documentPreviewStore' import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../studioClient' import {type Template} from '../../../templates' import {getDraftId, isDraftId} from '../../../util' diff --git a/packages/sanity/src/core/store/_legacy/document/initialValue/initialValue.ts b/packages/sanity/src/core/store/_legacy/document/initialValue/initialValue.ts index 912a246693d..c13f364222f 100644 --- a/packages/sanity/src/core/store/_legacy/document/initialValue/initialValue.ts +++ b/packages/sanity/src/core/store/_legacy/document/initialValue/initialValue.ts @@ -11,7 +11,7 @@ import { switchMap, } from 'rxjs/operators' -import {type DocumentPreviewStore} from '../../../../preview' +import {type DocumentPreviewStore} from '../../../../preview/documentPreviewStore' import {resolveInitialValue, type Template} from '../../../../templates' import {getDraftId, getPublishedId} from '../../../../util' import { diff --git a/packages/sanity/src/core/store/_legacy/types.ts b/packages/sanity/src/core/store/_legacy/types.ts index a9dbe67ecac..eb73efb4a6b 100644 --- a/packages/sanity/src/core/store/_legacy/types.ts +++ b/packages/sanity/src/core/store/_legacy/types.ts @@ -1,5 +1,5 @@ import {type Config, type Source as SanitySource} from '../../config' -import {type DocumentPreviewStore} from '../../preview' +import {type DocumentPreviewStore} from '../../preview/documentPreviewStore' import {type KeyValueStore} from '../key-value/types' import {type DocumentStore} from './document/document-store' import {type GrantsStore} from './grants/types' diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/ReferencePreviewTitle.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/ReferencePreviewTitle.tsx index 5a292316d9d..969d3bb6941 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/ReferencePreviewTitle.tsx +++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/ReferencePreviewTitle.tsx @@ -3,7 +3,8 @@ import {Skeleton} from '@sanity/ui' import {useMemo} from 'react' import {useMemoObservable} from 'react-rx' -import {getPreviewStateObservable, getPreviewValueWithFallback} from '../../../../../../../preview' +import {getPreviewStateObservable} from '../../../../../../../preview/utils/getPreviewStateObservable' +import {getPreviewValueWithFallback} from '../../../../../../../preview/utils/getPreviewValueWithFallback' import {useDocumentPreviewStore} from '../../../../../../../store/_legacy/datastores' export function ReferencePreviewTitle({ diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/searchResults/item/SearchResultItemPreview.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/searchResults/item/SearchResultItemPreview.tsx index 7ec6247d628..d948f9c8c2b 100644 --- a/packages/sanity/src/core/studio/components/navbar/search/components/searchResults/item/SearchResultItemPreview.tsx +++ b/packages/sanity/src/core/studio/components/navbar/search/components/searchResults/item/SearchResultItemPreview.tsx @@ -9,11 +9,9 @@ import {type GeneralPreviewLayoutKey} from '../../../../../../../components' import {DocumentStatus} from '../../../../../../../components/documentStatus' import {DocumentStatusIndicator} from '../../../../../../../components/documentStatusIndicator' import {DocumentPreviewPresence} from '../../../../../../../presence/DocumentPreviewPresence' -import { - getPreviewStateObservable, - getPreviewValueWithFallback, - SanityDefaultPreview, -} from '../../../../../../../preview' +import {SanityDefaultPreview} from '../../../../../../../preview/components/SanityDefaultPreview' +import {getPreviewStateObservable} from '../../../../../../../preview/utils/getPreviewStateObservable' +import {getPreviewValueWithFallback} from '../../../../../../../preview/utils/getPreviewValueWithFallback' import {useDocumentPreviewStore} from '../../../../../../../store/_legacy/datastores' import {type DocumentPresence} from '../../../../../../../store/_legacy/presence/types' diff --git a/packages/sanity/src/core/validation/util/createBatchedGetDocumentExists.ts b/packages/sanity/src/core/validation/util/createBatchedGetDocumentExists.ts index c86af305695..b2b196945e0 100644 --- a/packages/sanity/src/core/validation/util/createBatchedGetDocumentExists.ts +++ b/packages/sanity/src/core/validation/util/createBatchedGetDocumentExists.ts @@ -13,7 +13,7 @@ import { switchMap, } from 'rxjs' -import {type AvailabilityResponse} from '../../preview' +import {type AvailabilityResponse} from '../../preview/types' /** * The amount of time reserved for waiting for new IDs.