From ef38fbc390ba153ffcbf8ced0d87e7d408f8c2f9 Mon Sep 17 00:00:00 2001 From: Adam Krebs Date: Sat, 16 Sep 2023 11:56:39 -0400 Subject: [PATCH] add __experimental_sequenceProp to studio.transaction() --- theatre/studio/src/TheatreStudio.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/theatre/studio/src/TheatreStudio.ts b/theatre/studio/src/TheatreStudio.ts index 20e983b7b..89731478c 100644 --- a/theatre/studio/src/TheatreStudio.ts +++ b/theatre/studio/src/TheatreStudio.ts @@ -1,6 +1,6 @@ import type {IProject, IRafDriver, ISheet, ISheetObject} from '@theatre/core' import type {Prism, Pointer} from '@theatre/dataverse' -import {prism} from '@theatre/dataverse' +import {getPointerParts, prism} from '@theatre/dataverse' import SimpleCache from '@theatre/utils/SimpleCache' import type {$IntentionalAny, VoidFn} from '@theatre/utils/types' import type {IScrub} from '@theatre/studio/Scrub' @@ -88,6 +88,13 @@ export interface ITransactionAPI { * Makes Theatre forget about this sheet. */ __experimental_forgetSheet(sheet: TheatreSheet): void + + /** + * EXPERIMENTAL API - this api may be removed without notice. + * + * Sequences a track for the + */ + __experimental_sequenceProp(pointer: Pointer): void } /** * @@ -571,11 +578,28 @@ export default class TheatreStudio implements IStudio { ) } + const __experimental_sequenceProp = (prop: Pointer) => { + const {path, root} = getPointerParts(prop) + + if (!isSheetObject(root)) { + throw new Error( + 'Argument prop must be a pointer to a SheetObject property', + ) + } + + const propAdress = {...root.address, pathToProp: path} + + stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced( + propAdress, + ) + } + return fn({ set, unset, __experimental_forgetObject, __experimental_forgetSheet, + __experimental_sequenceProp, }) }) }