diff --git a/packages/dataverse/src/Atom.ts b/packages/dataverse/src/Atom.ts index c796ff4..22270ce 100644 --- a/packages/dataverse/src/Atom.ts +++ b/packages/dataverse/src/Atom.ts @@ -266,7 +266,7 @@ const identityDerivationWeakMap = new WeakMap<{}, Prism>() * * @param pointer - The pointer to return the derivation at. */ -export const valueDerivation =

>( +export const pointerToPrism =

>( pointer: P, ): Prism

? T : void> => { const meta = getPointerMeta(pointer) @@ -276,7 +276,7 @@ export const valueDerivation =

>( const root = meta.root if (!isIdentityDerivationProvider(root)) { throw new Error( - `Cannot run valueDerivation() on a pointer whose root is not an IdentityChangeProvider`, + `Cannot run pointerToPrism() on a pointer whose root is not an IdentityChangeProvider`, ) } const {path} = meta @@ -322,7 +322,7 @@ export const val = < ? P : unknown => { if (isPointer(input)) { - return valueDerivation(input).getValue() as $IntentionalAny + return pointerToPrism(input).getValue() as $IntentionalAny } else if (isPrism(input)) { return input.getValue() as $IntentionalAny } else { diff --git a/packages/dataverse/src/PointerProxy.ts b/packages/dataverse/src/PointerProxy.ts index efca7b4..fefda1a 100644 --- a/packages/dataverse/src/PointerProxy.ts +++ b/packages/dataverse/src/PointerProxy.ts @@ -26,7 +26,7 @@ export default class PointerProxy * Convenience pointer pointing to the root of this PointerProxy. * * @remarks - * Allows convenient use of {@link valueDerivation} and {@link val}. + * Allows convenient use of {@link pointerToPrism} and {@link val}. */ readonly pointer: Pointer diff --git a/packages/dataverse/src/derivations/iterateAndCountTicks.ts b/packages/dataverse/src/derivations/iterateAndCountTicks.ts index 10ee83d..a41e168 100644 --- a/packages/dataverse/src/derivations/iterateAndCountTicks.ts +++ b/packages/dataverse/src/derivations/iterateAndCountTicks.ts @@ -1,4 +1,4 @@ -import {valueDerivation} from '../Atom' +import {pointerToPrism} from '../Atom' import type {Pointer} from '../pointer' import {isPointer} from '../pointer' import type {Prism} from './Interface' @@ -9,7 +9,7 @@ export default function* iterateAndCountTicks( ): Generator<{value: V; ticks: number}, void, void> { let d if (isPointer(pointerOrDerivation)) { - d = valueDerivation(pointerOrDerivation) as Prism + d = pointerToPrism(pointerOrDerivation) as Prism } else if (isPrism(pointerOrDerivation)) { d = pointerOrDerivation } else { diff --git a/packages/dataverse/src/derivations/iterateOver.ts b/packages/dataverse/src/derivations/iterateOver.ts index 37db47d..59d4861 100644 --- a/packages/dataverse/src/derivations/iterateOver.ts +++ b/packages/dataverse/src/derivations/iterateOver.ts @@ -1,4 +1,4 @@ -import {valueDerivation} from '../Atom' +import {pointerToPrism} from '../Atom' import type {Pointer} from '../pointer' import {isPointer} from '../pointer' import Ticker from '../Ticker' @@ -10,7 +10,7 @@ export default function* iterateOver( ): Generator { let d if (isPointer(pointerOrDerivation)) { - d = valueDerivation(pointerOrDerivation) as Prism + d = pointerToPrism(pointerOrDerivation) as Prism } else if (isPrism(pointerOrDerivation)) { d = pointerOrDerivation } else { diff --git a/packages/dataverse/src/index.ts b/packages/dataverse/src/index.ts index a31b8c1..e2db52b 100644 --- a/packages/dataverse/src/index.ts +++ b/packages/dataverse/src/index.ts @@ -5,7 +5,7 @@ */ export type {IdentityDerivationProvider} from './Atom' -export {default as Atom, val, valueDerivation} from './Atom' +export {default as Atom, val, pointerToPrism} from './Atom' export {default as Box} from './Box' export type {IBox} from './Box' export {isPrism} from './derivations/Interface' diff --git a/theatre/core/src/coreExports.ts b/theatre/core/src/coreExports.ts index 722c8f4..d2e05f0 100644 --- a/theatre/core/src/coreExports.ts +++ b/theatre/core/src/coreExports.ts @@ -10,7 +10,7 @@ import userReadableTypeOfValue from '@theatre/shared/utils/userReadableTypeOfVal import deepEqual from 'fast-deep-equal' import type {PointerType} from '@theatre/dataverse' import {isPointer} from '@theatre/dataverse' -import {isPrism, valueDerivation} from '@theatre/dataverse' +import {isPrism, pointerToPrism} from '@theatre/dataverse' import type {$IntentionalAny, VoidFn} from '@theatre/shared/utils/types' import type {ProjectId} from '@theatre/shared/utils/ids' import {_coreLogger} from './_coreLogger' @@ -155,7 +155,7 @@ export function onChange

>( callback: (value: P extends PointerType ? T : unknown) => void, ): VoidFn { if (isPointer(pointer)) { - const derivation = valueDerivation(pointer) + const derivation = pointerToPrism(pointer) return derivation.onChange( getCoreTicker(), callback as $IntentionalAny, @@ -189,7 +189,7 @@ export function onChange

>( */ export function val(pointer: PointerType): T { if (isPointer(pointer)) { - return valueDerivation(pointer).getValue() as $IntentionalAny + return pointerToPrism(pointer).getValue() as $IntentionalAny } else { throw new Error(`Called val(p) where p is not a pointer.`) } diff --git a/theatre/studio/src/Studio.ts b/theatre/studio/src/Studio.ts index 6a4d3b5..e2cd5a7 100644 --- a/theatre/studio/src/Studio.ts +++ b/theatre/studio/src/Studio.ts @@ -2,7 +2,7 @@ import Scrub from '@theatre/studio/Scrub' import type {StudioHistoricState} from '@theatre/studio/store/types/historic' import type UI from '@theatre/studio/UI' import type {Pointer} from '@theatre/dataverse' -import {Atom, PointerProxy, valueDerivation} from '@theatre/dataverse' +import {Atom, PointerProxy, pointerToPrism} from '@theatre/dataverse' import type { CommitOrDiscard, ITransactionPrivateApi, @@ -171,7 +171,7 @@ export class Studio { } _attachToIncomingProjects() { - const projectsD = valueDerivation(this.projectsP) + const projectsD = pointerToPrism(this.projectsP) const attachToProjects = (projects: Record) => { for (const project of Object.values(projects)) { diff --git a/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregatedKeyframeTrack.tsx b/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregatedKeyframeTrack.tsx index a083265..68b0715 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregatedKeyframeTrack.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/AggregatedKeyframeTrack/AggregatedKeyframeTrack.tsx @@ -9,7 +9,7 @@ import type { } from '@theatre/studio/panels/SequenceEditorPanel/layout/tree' import {usePrism, useVal} from '@theatre/react' import type {Prism, Pointer} from '@theatre/dataverse' -import {prism, val, valueDerivation} from '@theatre/dataverse' +import {prism, val, pointerToPrism} from '@theatre/dataverse' import React, {useMemo, Fragment} from 'react' import styled from 'styled-components' import type {IContextMenuItem} from '@theatre/studio/uiComponents/simpleContextMenu/useContextMenu' @@ -302,7 +302,7 @@ function useAggregatedKeyframeTrackContextMenu( displayName: 'Aggregate Keyframe Track', menuItems: () => { const selectionKeyframes = - valueDerivation( + pointerToPrism( getStudio()!.atomP.ahistoric.clipboard.keyframesWithRelativePaths, ).getValue() ?? [] @@ -355,7 +355,7 @@ function pasteKeyframesSheet( if (areKeyframesAllOnSingleTrack) { for (const object of viewModel.children.map((child) => child.sheetObject)) { - const tracksByObject = valueDerivation( + const tracksByObject = pointerToPrism( getStudio().atomP.historic.coreByProject[projectId].sheetsById[sheetId] .sequence.tracksByObject[object.address.objectKey], ).getValue() @@ -370,7 +370,7 @@ function pasteKeyframesSheet( ) } } else { - const tracksByObject = valueDerivation( + const tracksByObject = pointerToPrism( getStudio().atomP.historic.coreByProject[projectId].sheetsById[sheetId] .sequence.tracksByObject, ).getValue() @@ -418,7 +418,7 @@ function pasteKeyframesObjectOrCompound( ) { const {projectId, sheetId, objectKey} = viewModel.sheetObject.address - const trackRecords = valueDerivation( + const trackRecords = pointerToPrism( getStudio().atomP.historic.coreByProject[projectId].sheetsById[sheetId] .sequence.tracksByObject[objectKey], ).getValue() diff --git a/theatre/studio/src/panels/SequenceEditorPanel/layout/tree.ts b/theatre/studio/src/panels/SequenceEditorPanel/layout/tree.ts index 6e48eaa..b471987 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/layout/tree.ts +++ b/theatre/studio/src/panels/SequenceEditorPanel/layout/tree.ts @@ -13,7 +13,7 @@ import type { } from '@theatre/shared/utils/ids' import {createStudioSheetItemKey} from '@theatre/shared/utils/ids' import type {$FixMe, $IntentionalAny} from '@theatre/shared/utils/types' -import {prism, val, valueDerivation} from '@theatre/dataverse' +import {prism, val, pointerToPrism} from '@theatre/dataverse' import logger from '@theatre/shared/logger' import {titleBarHeight} from '@theatre/studio/panels/BasePanel/common' import type {Studio} from '@theatre/studio/Studio' @@ -116,7 +116,7 @@ export const calculateSequenceEditorTree = ( const isCollapsedP = collapsableItemSetP.byId[createStudioSheetItemKey.forSheet()].isCollapsed - const isCollapsed = valueDerivation(isCollapsedP).getValue() ?? false + const isCollapsed = pointerToPrism(isCollapsedP).getValue() ?? false const tree: SequenceEditorTree = { type: 'sheet', @@ -165,7 +165,7 @@ export const calculateSequenceEditorTree = ( collapsableItemSetP.byId[ createStudioSheetItemKey.forSheetObject(sheetObject) ].isCollapsed - const isCollapsed = valueDerivation(isCollapsedP).getValue() ?? false + const isCollapsed = pointerToPrism(isCollapsedP).getValue() ?? false const row: SequenceEditorTree_SheetObject = { type: 'sheetObject', @@ -284,7 +284,7 @@ export const calculateSequenceEditorTree = ( collapsableItemSetP.byId[ createStudioSheetItemKey.forSheetObjectProp(sheetObject, pathToProp) ].isCollapsed - const isCollapsed = valueDerivation(isCollapsedP).getValue() ?? false + const isCollapsed = pointerToPrism(isCollapsedP).getValue() ?? false const row: SequenceEditorTree_PropWithChildren = { type: 'propWithChildren', diff --git a/theatre/studio/src/uiComponents/usePresence.tsx b/theatre/studio/src/uiComponents/usePresence.tsx index 4750223..c1e0dac 100644 --- a/theatre/studio/src/uiComponents/usePresence.tsx +++ b/theatre/studio/src/uiComponents/usePresence.tsx @@ -3,7 +3,7 @@ import type {StrictRecord} from '@theatre/shared/utils/types' import React, {useMemo} from 'react' import {useEffect} from 'react' import {useLogger} from './useLogger' -import {Box, prism, valueDerivation} from '@theatre/dataverse' +import {Box, prism, pointerToPrism} from '@theatre/dataverse' import {Atom} from '@theatre/dataverse' import {useDerivation} from '@theatre/react' import {selectClosestHTMLAncestor} from '@theatre/studio/utils/selectClosestHTMLAncestor' @@ -69,10 +69,10 @@ function createPresenceContext(options: { if (!itemKey) return undefinedD // this is the thing being hovered const currentD = currentUserHoverItemB.derivation - const primaryFocusDer = valueDerivation( + const primaryFocusDer = pointerToPrism( currentUserHoverFlagItemsAtom.pointer[itemKey], ) - const relationsDer = valueDerivation(relationsAtom.pointer[itemKey]) + const relationsDer = pointerToPrism(relationsAtom.pointer[itemKey]) return prism(() => { const primary = primaryFocusDer.getValue() if (primary) {