@sanity/visual-editing
Version:
[](https://npm-stat.com/charts.html?package=@sanity/visual-editing) [](https://
1 lines • 6.78 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":["../src/index.ts","../src/ui/shared-state/useSharedState.ts"],"sourcesContent":["import type {DatasetMutatorMachineInput as DatasetMutatorMachineInputDeprecated} from './optimistic/state/datasetMutator'\nimport type {\n DocumentsGet as DocumentsGetDeprecated,\n DocumentsMutate as DocumentsMutateDeprecated,\n OptimisticDocument as OptimisticDocumentDeprecated,\n OptimisticDocumentPatches as OptimisticDocumentPatchesDeprecated,\n OptimisticReducerAction as OptimisticReducerActionDeprecated,\n OptimisticReducer as OptimisticReducerDeprecated,\n Path as PathDeprecated,\n PathValue as PathValueDeprecated,\n} from './optimistic/types'\nimport {useDocuments as useDocumentsDeprecated} from './react/useDocuments'\nimport {useOptimistic as useOptimisticDeprecated} from './react/useOptimistic'\n\nexport {createOverlayController} from './controller'\nexport type {\n DisableVisualEditing,\n DragEndEvent,\n DragInsertPosition,\n DragSkeleton,\n ElementFocusedState,\n ElementNode,\n ElementState,\n HistoryAdapter,\n HistoryAdapterNavigate,\n HistoryRefresh,\n HistoryUpdate,\n Msg,\n OverlayComponent,\n OverlayComponentProps,\n OverlayComponentResolver,\n OverlayComponentResolverContext,\n OverlayController,\n OverlayElementField,\n OverlayElementParent,\n OverlayEventHandler,\n OverlayMsg,\n OverlayMsgActivate,\n OverlayMsgBlur,\n OverlayMsgDeactivate,\n OverlayMsgDragEnd,\n OverlayMsgDragEndMinimapTransition,\n OverlayMsgDragStart,\n OverlayMsgDragStartMinimapTransition,\n OverlayMsgDragToggleMinimap,\n OverlayMsgDragToggleMinimapPrompt,\n OverlayMsgDragUpdateCursorPosition,\n OverlayMsgDragUpdateGroupRect,\n OverlayMsgDragUpdateInsertPosition,\n OverlayMsgDragUpdateSkeleton,\n OverlayMsgElement,\n OverlayMsgElementActivate,\n OverlayMsgElementClick,\n OverlayMsgElementContextMenu,\n OverlayMsgElementDeactivate,\n OverlayMsgElementMouseEnter,\n OverlayMsgElementMouseLeave,\n OverlayMsgElementRegister,\n OverlayMsgElementUnregister,\n OverlayMsgElementUpdate,\n OverlayMsgElementUpdateRect,\n OverlayMsgSetCursor,\n OverlayOptions,\n OverlayRect,\n SanityNode,\n SanityStegaNode,\n VisualEditingOptions,\n} from './types'\nexport {enableVisualEditing} from './ui/enableVisualEditing'\nexport {useSharedState} from './ui/shared-state/useSharedState'\nexport {\n type CreateDataAttribute,\n type CreateDataAttributeProps,\n type DocumentSchema,\n type SchemaArrayItem,\n type SchemaArrayNode,\n type SchemaBooleanNode,\n type SchemaInlineNode,\n type SchemaNode,\n type SchemaNullNode,\n type SchemaNumberNode,\n type SchemaObjectField,\n type SchemaObjectNode,\n type SchemaStringNode,\n type SchemaUnionNode,\n type SchemaUnionNodeOptions,\n type SchemaUnionOption,\n type SchemaUnknownNode,\n type WithRequired,\n createDataAttribute,\n} from '@repo/visual-editing-helpers'\nexport {getArrayItemKeyAndParentPath} from './util/mutations'\n\n/**\n * @public\n * @deprecated Use `import {useDocuments} from '@sanity/visual-editing/react'` instead\n */\nexport const useDocuments = useDocumentsDeprecated\n/**\n * @public\n * @deprecated Use `import {useOptimistic} from '@sanity/visual-editing/react'` instead\n */\nexport const useOptimistic = useOptimisticDeprecated\n/**\n * @public\n * @deprecated Use `import type {DatasetMutatorMachineInput} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type DatasetMutatorMachineInput = DatasetMutatorMachineInputDeprecated\n/**\n * @public\n * @deprecated Use `import type {DocumentsGet} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type DocumentsGet = DocumentsGetDeprecated\n/**\n * @public\n * @deprecated Use `import type {DocumentsMutate} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type DocumentsMutate = DocumentsMutateDeprecated\n/**\n * @public\n * @deprecated Use `import type {OptimisticDocument} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type OptimisticDocument = OptimisticDocumentDeprecated\n/**\n * @public\n * @deprecated Use `import type {OptimisticDocumentPatches} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type OptimisticDocumentPatches = OptimisticDocumentPatchesDeprecated\n/**\n * @public\n * @deprecated Use `import type {OptimisticReducer} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type OptimisticReducer<T, U> = OptimisticReducerDeprecated<T, U>\n/**\n * @public\n * @deprecated Use `import type {OptimisticReducerAction} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type OptimisticReducerAction<T> = OptimisticReducerActionDeprecated<T>\n/**\n * @public\n * @deprecated Use `import type {Path} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type Path<T, K extends keyof T> = PathDeprecated<T, K>\n/**\n * @public\n * @deprecated Use `import type {PathValue} from '@sanity/visual-editing/optimistic'` instead\n */\nexport type PathValue<T, P extends string> = PathValueDeprecated<T, P>\n/**\n * @internal\n * @deprecated - do not use\n */\nexport type {\n useDocumentsDeprecated,\n useOptimisticDeprecated,\n DatasetMutatorMachineInputDeprecated,\n DocumentsGetDeprecated,\n DocumentsMutateDeprecated,\n OptimisticDocumentDeprecated,\n OptimisticDocumentPatchesDeprecated,\n OptimisticReducerDeprecated,\n OptimisticReducerActionDeprecated,\n PathDeprecated,\n PathValueDeprecated,\n}\n","import {useCallback, useContext, useSyncExternalStore} from 'react'\nimport {SharedStateContext} from './SharedStateContext'\n\nexport function useSharedState<\n T extends boolean | null | number | object | string | undefined | unknown = unknown,\n>(key: string): T {\n const context = useContext(SharedStateContext)\n if (!context) {\n throw new Error('useSharedState must be used within a SharedStateProvider')\n }\n\n const {store} = context\n\n const value = useSyncExternalStore(\n store.subscribe,\n useCallback(() => store.getState()[key] as T, [key, store]),\n )\n\n return value\n}\n"],"names":["useDocuments","useDocumentsDeprecated","useOptimistic","useOptimisticDeprecated","key","$","_c","context","useContext","SharedStateContext","Error","store","t0","getState","useSyncExternalStore","subscribe"],"mappings":"kUAiGaA,MAAAA,EAAeC,IAKfC,EAAgBC,EAAAA,EAAAA,QAAAA,6BAAAA,EAAAA,EAAAA,QAAAA,wBAAAA,EAAAA,EAAAA,QAAAA,oBAAAA,EAAAA,EAAAA,QAAAA,oBAAAA,EAAAA,EAAAA,QAAAA,aAAAA,EAAAA,QAAAA,cAAAA,EAAAA,QAAAA,eCnGtB,SAAAC,GAAAC,MAAAA,EAAAC,EAAAA,EAAA,GAGLC,EAAgBC,aAAAC,KAA8B,IACzCF,EAAOG,MAAAA,IAAAA,MACM,4DAGlB,MAAAC,MAAAA,GAAgBJ,EAAOK,IAAAA,EAAA,OAAAP,EAAAD,KAAAA,GAAAC,OAAAM,GAITC,EAAAA,IAAMD,EAAKE,WAAYT,GAASC,KAAAD,EAAAC,KAAAM,EAAAN,KAAAO,GAAAA,EAAAP,EAAA,GAFhCS,EACZH,qBAAAA,EAAKI,UACLH,EAGU"}