Unify Derivation and Prism 12/n

This commit is contained in:
Aria Minaei 2022-12-01 15:01:53 +01:00
parent b2116e9a5d
commit d9644f2370
8 changed files with 18 additions and 20 deletions

View file

@ -118,7 +118,7 @@ export default class Sequence {
return this._lengthD.getValue()
}
get positionDerivation() {
get positionPrism() {
return this._positionD
}

View file

@ -253,7 +253,7 @@ export default class SheetObject implements IdentityPrismProvider {
const interpolate =
propConfig.interpolate! as Interpolator<$IntentionalAny>
const updateSequenceValueFromItsDerivation = () => {
const updateSequenceValueFromItsPrism = () => {
const triple = pr.getValue()
if (!triple) return valsAtom.setIn(pathToProp, undefined)
@ -279,9 +279,9 @@ export default class SheetObject implements IdentityPrismProvider {
interpolate(left, right, triple.progression),
)
}
const untap = pr.onStale(updateSequenceValueFromItsDerivation)
const untap = pr.onStale(updateSequenceValueFromItsPrism)
updateSequenceValueFromItsDerivation()
updateSequenceValueFromItsPrism()
untaps.push(untap)
}
return () => {
@ -304,7 +304,7 @@ export default class SheetObject implements IdentityPrismProvider {
this.template.project.pointers.historic.sheetsById[this.address.sheetId]
.sequence.tracksByObject[this.address.objectKey].trackData[trackId]
const timeD = this.sheet.getSequence().positionDerivation
const timeD = this.sheet.getSequence().positionPrism
return interpolationTripleAtPosition(this._internalUtilCtx, trackP, timeD)
}

View file

@ -128,7 +128,7 @@ export default class SheetObjectTemplate {
* Returns values that are set statically (ie, not sequenced, and not defaults)
*/
getStaticValues(): Prism<SerializableMap> {
return this._cache.get('getDerivationOfStatics', () =>
return this._cache.get('getStaticValues', () =>
prism(() => {
const pointerToSheetState =
this.sheetTemplate.project.pointers.historic.sheetsById[

View file

@ -148,7 +148,7 @@ export default class TheatreSheetObject<
}
private _valuesPrism(): Prism<this['value']> {
return this._cache.get('onValuesChangeDerivation', () => {
return this._cache.get('_valuesPrism', () => {
const sheetObject = privateAPI(this)
const d: Prism<PropsValue<Props>> = prism(() => {
return val(sheetObject.getValues().getValue()) as $FixMe

View file

@ -410,8 +410,8 @@ export default class TheatreStudio implements IStudio {
})
}
private _getSelectionDerivation(): Prism<(ISheetObject | ISheet)[]> {
return this._cache.get('_getStateDerivation()', () =>
private _getSelectionPrism(): Prism<(ISheetObject | ISheet)[]> {
return this._cache.get('_getSelectionPrism()', () =>
prism((): (ISheetObject | ISheet)[] => {
return getOutlineSelection()
.filter(
@ -424,7 +424,7 @@ export default class TheatreStudio implements IStudio {
}
private _getSelection(): (ISheetObject | ISheet)[] {
return this._getSelectionDerivation().getValue()
return this._getSelectionPrism().getValue()
}
setSelection(selection: Array<ISheetObject | ISheet>): void {
@ -440,7 +440,7 @@ export default class TheatreStudio implements IStudio {
}
onSelectionChange(fn: (s: (ISheetObject | ISheet)[]) => void): VoidFn {
return this._getSelectionDerivation().onChange(studioTicker, fn, true)
return this._getSelectionPrism().onChange(studioTicker, fn, true)
}
get selection(): Array<ISheetObject | ISheet> {

View file

@ -265,7 +265,7 @@ const Playhead: React.FC<{layoutP: Pointer<SequenceEditorPanelLayout>}> = ({
getIsPlayheadAttachedToFocusRange(sequence),
)
const posInUnitSpace = sequence.positionDerivation.getValue()
const posInUnitSpace = sequence.positionPrism.getValue()
const posInClippedSpace = val(layoutP.clippedSpace.fromUnitSpace)(
posInUnitSpace,

View file

@ -235,7 +235,7 @@ function ControlIndicators({
return usePrism(() => {
const pathToProp = getPointerParts(pointerToProp).path
const sequencePosition = val(obj.sheet.getSequence().positionDerivation)
const sequencePosition = val(obj.sheet.getSequence().positionPrism)
/*
2/10 perf concern:

View file

@ -65,7 +65,7 @@ const cache = new WeakMap<{}, Prism<EditingTools<$IntentionalAny>>>()
* Note: we're able to get `obj` and `propConfig` from `pointerToProp`,
* so the only reason they're still in the arguments list is that
*/
function createDerivation<T extends SerializablePrimitive>(
function createPrism<T extends SerializablePrimitive>(
pointerToProp: Pointer<T>,
obj: SheetObject,
propConfig: PropTypeConfig_AllSimples,
@ -181,9 +181,7 @@ function createDerivation<T extends SerializablePrimitive>(
sequenceTrackId
],
)
const sequencePosition = val(
obj.sheet.getSequence().positionDerivation,
)
const sequencePosition = val(obj.sheet.getSequence().positionPrism)
return getNearbyKeyframesOfTrack(
obj,
track && {
@ -325,7 +323,7 @@ function createDerivation<T extends SerializablePrimitive>(
})
}
function getDerivation<T extends SerializablePrimitive>(
function getPrism<T extends SerializablePrimitive>(
pointerToProp: Pointer<T>,
obj: SheetObject,
propConfig: PropTypeConfig_AllSimples,
@ -333,7 +331,7 @@ function getDerivation<T extends SerializablePrimitive>(
if (cache.has(pointerToProp)) {
return cache.get(pointerToProp)!
} else {
const d = createDerivation(pointerToProp, obj, propConfig)
const d = createPrism(pointerToProp, obj, propConfig)
cache.set(pointerToProp, d)
return d
}
@ -354,7 +352,7 @@ export function useEditingToolsForSimplePropInDetailsPanel<
obj: SheetObject,
propConfig: PropTypeConfig_AllSimples,
): EditingTools<T> {
const der = getDerivation(pointerToProp, obj, propConfig)
const der = getPrism(pointerToProp, obj, propConfig)
return usePrismInstance(der)
}