Skip to content

Commit

Permalink
add __experimental_sequenceProp to studio.transaction()
Browse files Browse the repository at this point in the history
  • Loading branch information
akre54 committed Sep 16, 2023
1 parent 19ae109 commit ff1452a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
22 changes: 21 additions & 1 deletion theatre/studio/src/TheatreStudio.ts
Original file line number Diff line number Diff line change
@@ -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 {isPointer, prism} from '@theatre/dataverse'
import SimpleCache from '@theatre/shared/utils/SimpleCache'
import type {$IntentionalAny, VoidFn} from '@theatre/shared/utils/types'
import type {IScrub} from '@theatre/studio/Scrub'
Expand Down Expand Up @@ -78,6 +78,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<V>(pointer: Pointer<V>): void
}
/**
*
Expand Down Expand Up @@ -552,11 +559,24 @@ export default class TheatreStudio implements IStudio {
)
}

const __experimental_sequenceProp = <V>(pointer: Pointer<V>) => {
if (!isPointer(pointer)) {
throw new Error(
`sheet in transactionApi.__experimental_sequenceProp(pointer) must be the return type of pointer`,
)
}

stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
pointer.address,
)
}

return fn({
set,
unset,
__experimental_forgetObject,
__experimental_forgetSheet,
__experimental_sequenceProp,
})
})
}
Expand Down
1 change: 0 additions & 1 deletion theatre/studio/src/propEditors/DefaultValueIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const DefaultOrStaticValueIndicator: React.FC<{

stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(

stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ function createPrism<T extends SerializablePrimitive>(

stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
})
},
Expand Down
2 changes: 0 additions & 2 deletions theatre/studio/src/store/stateEditors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import {
} from '@theatre/shared/instanceTypes'
import type SheetTemplate from '@theatre/core/sheets/SheetTemplate'
import type SheetObjectTemplate from '@theatre/core/sheetObjects/SheetObjectTemplate'
import type {PropTypeConfig} from '@theatre/core/propTypes'
import {pointableSetUtil} from '@theatre/shared/utils/PointableSet'

export const setDrafts__onlyMeantToBeCalledByTransaction = (
Expand Down Expand Up @@ -686,7 +685,6 @@ namespace stateEditors {

export function setPrimitivePropAsSequenced(
p: WithoutSheetInstance<PropAddress>,
config: PropTypeConfig,
) {
const tracks = _ensureTracksOfObject(p)
const pathEncoded = encodePathToProp(p.pathToProp)
Expand Down

0 comments on commit ff1452a

Please sign in to comment.