Skip to content

Commit

Permalink
refactor(core): remove barrel exports from preview
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 2, 2024
1 parent 5f6a353 commit 3a71e25
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/core/form/studio/FormBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
11 changes: 10 additions & 1 deletion packages/sanity/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/core/preview/components/Preview.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 0 additions & 10 deletions packages/sanity/src/core/preview/index.ts

This file was deleted.

5 changes: 4 additions & 1 deletion packages/sanity/src/core/store/_legacy/datastores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/core/store/_legacy/types.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3a71e25

Please sign in to comment.