From 1fb69126fd8326f74a6f156c2facb5c7df458185 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Mon, 23 Jan 2023 22:24:54 +0100 Subject: [PATCH] Fix the bug where the sequence was not play-able because it did not implement the `PointerToPrismProvider` interface correctly --- theatre/core/src/sequences/Sequence.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/theatre/core/src/sequences/Sequence.ts b/theatre/core/src/sequences/Sequence.ts index 017e969..13421d9 100644 --- a/theatre/core/src/sequences/Sequence.ts +++ b/theatre/core/src/sequences/Sequence.ts @@ -3,7 +3,13 @@ import type Sheet from '@theatre/core/sheets/Sheet' import type {SequenceAddress} from '@theatre/shared/utils/addresses' import didYouMean from '@theatre/shared/utils/didYouMean' import {InvalidArgumentError} from '@theatre/shared/utils/errors' -import type {Prism, Pointer, Ticker} from '@theatre/dataverse' +import type { + Prism, + Pointer, + Ticker, + PointerToPrismProvider, +} from '@theatre/dataverse' +import {getPointerParts} from '@theatre/dataverse' import {Atom} from '@theatre/dataverse' import {pointer} from '@theatre/dataverse' import {prism, val} from '@theatre/dataverse' @@ -17,6 +23,7 @@ import TheatreSequence from './TheatreSequence' import type {ILogger} from '@theatre/shared/logger' import type {ISequence} from '..' import {notify} from '@theatre/shared/notify' +import type {$IntentionalAny} from '@theatre/dataverse/src/types' export type IPlaybackRange = [from: number, to: number] @@ -33,7 +40,7 @@ const possibleDirections = [ 'alternateReverse', ] -export default class Sequence { +export default class Sequence implements PointerToPrismProvider { public readonly address: SequenceAddress publicApi: TheatreSequence @@ -81,28 +88,29 @@ export default class Sequence { }) } - pointerToPrism(path: Array): Prism { + pointerToPrism(pointer: Pointer): Prism { + const {path} = getPointerParts(pointer) if (path.length === 0) { return prism((): ISequence['pointer']['$$__pointer_type'] => ({ length: val(this.pointer.length), playing: val(this.pointer.playing), position: val(this.pointer.position), - })) + })) as $IntentionalAny as Prism } if (path.length > 1) { - return prism(() => undefined) + return prism(() => undefined) as $IntentionalAny as Prism } const [prop] = path if (prop === 'length') { - return this._lengthD + return this._lengthD as $IntentionalAny as Prism } else if (prop === 'position') { - return this._positionD + return this._positionD as $IntentionalAny as Prism } else if (prop === 'playing') { return prism(() => { return val(this._prismOfStatePointer.getValue().playing) - }) + }) as $IntentionalAny as Prism } else { - return prism(() => undefined) + return prism(() => undefined) as $IntentionalAny as Prism } }