Skip to content

Commit

Permalink
refactor: colocate duplicate type + value imports (#5515)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars authored Jan 19, 2024
1 parent 9b3eae9 commit 9795480
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 123 deletions.
3 changes: 1 addition & 2 deletions packages/@sanity/cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type ora from 'ora'
import ora, {type Ora} from 'ora'
import type chalk from 'chalk'
import type {Ora} from 'ora'
import type {SanityClient} from '@sanity/client'
import type {Separator, DistinctQuestion, Answers, ChoiceCollection} from 'inquirer'
import type {InlineConfig, ConfigEnv} from 'vite'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import React, {ForwardedRef, forwardRef, useCallback, useEffect} from 'react'
import {Schema} from '@sanity/schema'

import {defineArrayMember, defineField} from '@sanity/types'
import {PortableTextEditor, PortableTextEditable} from '../../index'
import type {PortableTextEditorProps, PortableTextEditableProps} from '../../index'
import {
PortableTextEditor,
PortableTextEditable,
type PortableTextEditorProps,
type PortableTextEditableProps,
} from '../../index'

const imageType = defineField({
type: 'image',
Expand Down
5 changes: 4 additions & 1 deletion packages/sanity/src/core/form/inputs/arrays/common/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import {
PointerSensor,
useSensor,
useSensors,
type SensorOptions,
type AutoScrollOptions,
type DragStartEvent,
type DragEndEvent,
} from '@dnd-kit/core'
import type {SensorOptions, AutoScrollOptions, DragStartEvent, DragEndEvent} from '@dnd-kit/core'
import {
horizontalListSortingStrategy,
SortableContext,
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 @@ -13,6 +13,7 @@ import {
ItemProps,
ObjectInputProps,
RenderPreviewCallbackProps,
type FormDocumentValue,
} from '../types'
import {StateTree} from '../store'
import {EMPTY_ARRAY} from '../../util'
Expand All @@ -29,7 +30,6 @@ import {
usePreviewComponent,
} from '../form-components-hooks'
import {PreviewLoader} from '../../preview'
import type {FormDocumentValue} from '../types'
import {FormValueProvider} from '../contexts/FormValue'
import {GetFormValueProvider} from '../contexts/GetFormValue'
import {FormProvider} from './FormProvider'
Expand Down
12 changes: 6 additions & 6 deletions packages/sanity/src/core/preview/availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import {distinctUntilChanged, map, mergeMap, reduce, switchMap} from 'rxjs/opera
import shallowEquals from 'shallow-equals'
import {flatten, keyBy} from 'lodash'
import {getDraftId, getPublishedId, isRecord} from '../util'
import type {
AvailabilityResponse,
DocumentAvailability,
DraftsModelDocumentAvailability,
} from './types'
import {debounceCollect} from './utils/debounceCollect'
import {
AVAILABILITY_NOT_FOUND,
AVAILABILITY_PERMISSION_DENIED,
AVAILABILITY_READABLE,
} from './constants'
import {ObservePathsFn} from './types'
import {
ObservePathsFn,
type AvailabilityResponse,
type DocumentAvailability,
type DraftsModelDocumentAvailability,
} from './types'

const MAX_DOCUMENT_ID_CHUNK_SIZE = 11164

Expand Down
9 changes: 7 additions & 2 deletions packages/sanity/src/core/preview/createPreviewObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import {
} from '@sanity/types'
import {isPlainObject} from 'lodash'
import {invokePrepare, prepareForPreview} from './utils/prepareForPreview'
import type {ApiConfig, PreviewPath, PreparedSnapshot} from './types'
import {getPreviewPaths} from './utils/getPreviewPaths'
import {Previewable, PreviewableType} from './types'
import {
Previewable,
PreviewableType,
type ApiConfig,
type PreviewPath,
type PreparedSnapshot,
} from './types'

function isRecord(value: unknown): value is Record<string, unknown> {
return isPlainObject(value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {SanityClient} from '@sanity/client'
import type {Observable} from 'rxjs'
import {of} from 'rxjs'
import {of, type Observable} from 'rxjs'
import {map} from 'rxjs/operators'
import {getDraftId, getPublishedId} from '../../../util'

Expand Down
3 changes: 1 addition & 2 deletions packages/sanity/src/core/util/useThrottledCallback.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {throttle} from 'lodash'
import type {ThrottleSettings} from 'lodash'
import {throttle, type ThrottleSettings} from 'lodash'
import {useMemo} from 'react'

/**
Expand Down
207 changes: 102 additions & 105 deletions packages/sanity/src/desk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,110 +4,6 @@
*
* @deprecated Use `sanity/structure` instead.
*/
import type {
BackLinkProps as _BackLinkProps,
BaseGenericList as _BaseGenericList,
BaseIntentParams as _BaseIntentParams,
BaseView as _BaseView,
BuildableComponent as _BuildableComponent,
BuildableGenericList as _BuildableGenericList,
BuildableList as _BuildableList,
Builder as _Builder,
Child as _Child,
ChildLinkProps as _ChildLinkProps,
ChildObservable as _ChildObservable,
ChildResolver as _ChildResolver,
ChildResolverOptions as _ChildResolverOptions,
Collection as _Collection,
CollectionBuilder as _CollectionBuilder,
Component as _Component,
ComponentInput as _ComponentInput,
ComponentView as _ComponentView,
ConfirmDeleteDialogProps as _ConfirmDeleteDialogProps,
CustomComponentPaneNode as _CustomComponentPaneNode,
DefaultDocumentNodeContext as _DefaultDocumentNodeContext,
DefaultDocumentNodeResolver as _DefaultDocumentNodeResolver,
Divider as _Divider,
DocumentFieldMenuActionNode as _DocumentFieldMenuActionNode,
DocumentList as _DocumentList,
DocumentListInput as _DocumentListInput,
DocumentListItem as _DocumentListItem,
DocumentListItemInput as _DocumentListItemInput,
DocumentListOptions as _DocumentListOptions,
DocumentListPaneNode as _DocumentListPaneNode,
DocumentListPaneProps as _DocumentListPaneProps,
DocumentNode as _DocumentNode,
DocumentOptions as _DocumentOptions,
DocumentPaneNode as _DocumentPaneNode,
DocumentPaneProviderProps as _DocumentPaneProviderProps,
DocumentTypeListInput as _DocumentTypeListInput,
EditReferenceOptions as _EditReferenceOptions,
EditorNode as _EditorNode,
FormView as _FormView,
GenericList as _GenericList,
GenericListInput as _GenericListInput,
Intent as _Intent,
IntentChecker as _IntentChecker,
IntentJsonParams as _IntentJsonParams,
IntentParams as _IntentParams,
ItemChild as _ItemChild,
List as _List,
ListDisplayOptions as _ListDisplayOptions,
ListInput as _ListInput,
ListItem as _ListItem,
ListItemChild as _ListItemChild,
ListItemDisplayOptions as _ListItemDisplayOptions,
ListItemInput as _ListItemInput,
ListItemSerializeOptions as _ListItemSerializeOptions,
ListPaneNode as _ListPaneNode,
MenuItem as _MenuItem,
MenuItemActionType as _MenuItemActionType,
MenuItemGroup as _MenuItemGroup,
MenuItemParamsType as _MenuItemParamsType,
PaneListItem as _PaneListItem,
PaneListItemDivider as _PaneListItemDivider,
PaneMenuItem as _PaneMenuItem,
PaneMenuItemGroup as _PaneMenuItemGroup,
PaneNode as _PaneNode,
PaneNodeResolver as _PaneNodeResolver,
PaneRouterContextValue as _PaneRouterContextValue,
ParameterizedLinkProps as _ParameterizedLinkProps,
PartialDocumentList as _PartialDocumentList,
PartialDocumentListItem as _PartialDocumentListItem,
PartialDocumentNode as _PartialDocumentNode,
PartialListItem as _PartialListItem,
PartialMenuItem as _PartialMenuItem,
ReferenceChildLinkProps as _ReferenceChildLinkProps,
RouterPaneGroup as _RouterPaneGroup,
RouterPaneSibling as _RouterPaneSibling,
RouterPaneSiblingContext as _RouterPaneSiblingContext,
RouterPanes as _RouterPanes,
SerializablePaneNode as _SerializablePaneNode,
SerializeOptions as _SerializeOptions,
SerializePath as _SerializePath,
SortMenuItem as _SortMenuItem,
StructureBuilder as _StructureBuilder,
StructureBuilderOptions as _StructureBuilderOptions,
StructureContext as _StructureContext,
StructureLocaleResourceKeys as _StructureLocaleResourceKeys,
StructureNode as _StructureNode,
StructureResolver as _StructureResolver,
StructureResolverContext as _StructureResolverContext,
StructureToolContextValue as _DeskToolContextValue,
StructureToolFeatures as _DeskToolFeatures,
StructureToolMenuItem as _DeskToolMenuItem,
StructureToolOptions as _DeskToolOptions,
StructureToolPaneActionHandler as _DeskToolPaneActionHandler,
StructureToolProviderProps as _DeskToolProviderProps,
UnresolvedPaneNode as _UnresolvedPaneNode,
UnserializedListItem as _UnserializedListItem,
UnserializedListItemChild as _UnserializedListItemChild,
UserComponent as _UserComponent,
UserViewComponent as _UserViewComponent,
View as _View,
ViewBuilder as _ViewBuilder,
} from '../structure'

import {
ComponentBuilder as _ComponentBuilder,
ComponentViewBuilder as _ComponentViewBuilder,
Expand Down Expand Up @@ -153,10 +49,111 @@ import {
shallowIntentChecker as _shallowIntentChecker,
structureLocaleNamespace as _structureLocaleNamespace,
structureTool as _structureTool,
useStructureTool as _useStructureTool,
useDocumentPane as _useDocumentPane,
useDocumentTitle as _useDocumentTitle,
usePaneRouter as _usePaneRouter,
useStructureTool as _useStructureTool,
type BackLinkProps as _BackLinkProps,
type BaseGenericList as _BaseGenericList,
type BaseIntentParams as _BaseIntentParams,
type BaseView as _BaseView,
type BuildableComponent as _BuildableComponent,
type BuildableGenericList as _BuildableGenericList,
type BuildableList as _BuildableList,
type Builder as _Builder,
type Child as _Child,
type ChildLinkProps as _ChildLinkProps,
type ChildObservable as _ChildObservable,
type ChildResolver as _ChildResolver,
type ChildResolverOptions as _ChildResolverOptions,
type Collection as _Collection,
type CollectionBuilder as _CollectionBuilder,
type Component as _Component,
type ComponentInput as _ComponentInput,
type ComponentView as _ComponentView,
type ConfirmDeleteDialogProps as _ConfirmDeleteDialogProps,
type CustomComponentPaneNode as _CustomComponentPaneNode,
type DefaultDocumentNodeContext as _DefaultDocumentNodeContext,
type DefaultDocumentNodeResolver as _DefaultDocumentNodeResolver,
type StructureToolContextValue as _DeskToolContextValue,
type StructureToolFeatures as _DeskToolFeatures,
type StructureToolMenuItem as _DeskToolMenuItem,
type StructureToolOptions as _DeskToolOptions,
type StructureToolPaneActionHandler as _DeskToolPaneActionHandler,
type StructureToolProviderProps as _DeskToolProviderProps,
type Divider as _Divider,
type DocumentFieldMenuActionNode as _DocumentFieldMenuActionNode,
type DocumentList as _DocumentList,
type DocumentListInput as _DocumentListInput,
type DocumentListItem as _DocumentListItem,
type DocumentListItemInput as _DocumentListItemInput,
type DocumentListOptions as _DocumentListOptions,
type DocumentListPaneNode as _DocumentListPaneNode,
type DocumentListPaneProps as _DocumentListPaneProps,
type DocumentNode as _DocumentNode,
type DocumentOptions as _DocumentOptions,
type DocumentPaneNode as _DocumentPaneNode,
type DocumentPaneProviderProps as _DocumentPaneProviderProps,
type DocumentTypeListInput as _DocumentTypeListInput,
type EditReferenceOptions as _EditReferenceOptions,
type EditorNode as _EditorNode,
type FormView as _FormView,
type GenericList as _GenericList,
type GenericListInput as _GenericListInput,
type Intent as _Intent,
type IntentChecker as _IntentChecker,
type IntentJsonParams as _IntentJsonParams,
type IntentParams as _IntentParams,
type ItemChild as _ItemChild,
type List as _List,
type ListDisplayOptions as _ListDisplayOptions,
type ListInput as _ListInput,
type ListItem as _ListItem,
type ListItemChild as _ListItemChild,
type ListItemDisplayOptions as _ListItemDisplayOptions,
type ListItemInput as _ListItemInput,
type ListItemSerializeOptions as _ListItemSerializeOptions,
type ListPaneNode as _ListPaneNode,
type MenuItem as _MenuItem,
type MenuItemActionType as _MenuItemActionType,
type MenuItemGroup as _MenuItemGroup,
type MenuItemParamsType as _MenuItemParamsType,
type PaneListItem as _PaneListItem,
type PaneListItemDivider as _PaneListItemDivider,
type PaneMenuItem as _PaneMenuItem,
type PaneMenuItemGroup as _PaneMenuItemGroup,
type PaneNode as _PaneNode,
type PaneNodeResolver as _PaneNodeResolver,
type PaneRouterContextValue as _PaneRouterContextValue,
type ParameterizedLinkProps as _ParameterizedLinkProps,
type PartialDocumentList as _PartialDocumentList,
type PartialDocumentListItem as _PartialDocumentListItem,
type PartialDocumentNode as _PartialDocumentNode,
type PartialListItem as _PartialListItem,
type PartialMenuItem as _PartialMenuItem,
type ReferenceChildLinkProps as _ReferenceChildLinkProps,
type RouterPaneGroup as _RouterPaneGroup,
type RouterPaneSibling as _RouterPaneSibling,
type RouterPaneSiblingContext as _RouterPaneSiblingContext,
type RouterPanes as _RouterPanes,
type SerializablePaneNode as _SerializablePaneNode,
type SerializeOptions as _SerializeOptions,
type SerializePath as _SerializePath,
type SortMenuItem as _SortMenuItem,
type StructureBuilder as _StructureBuilder,
type StructureBuilderOptions as _StructureBuilderOptions,
type StructureContext as _StructureContext,
type StructureLocaleResourceKeys as _StructureLocaleResourceKeys,
type StructureNode as _StructureNode,
type StructureResolver as _StructureResolver,
type StructureResolverContext as _StructureResolverContext,
type UnresolvedPaneNode as _UnresolvedPaneNode,
type UnserializedListItem as _UnserializedListItem,
type UnserializedListItemChild as _UnserializedListItemChild,
type UserComponent as _UserComponent,
type UserViewComponent as _UserViewComponent,
type View as _View,
type ViewBuilder as _ViewBuilder,
} from '../structure'

/**
Expand Down

2 comments on commit 9795480

@vercel
Copy link

@vercel vercel bot commented on 9795480 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio-git-next.sanity.build
performance-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 9795480 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

Please sign in to comment.