Merge branch 'main' of github.com:theatre-js/theatre

This commit is contained in:
jrkb 2023-04-15 18:39:21 +02:00
commit 7d235386e7
4 changed files with 37 additions and 2 deletions

View file

@ -50,6 +50,7 @@ The quickest way to start tweaking things is to run the `playground` package.
```sh
$ cd ./packages/playground
$ yarn serve
$ yarn build
# or, shortcut:
$ cd root
$ yarn playground

View file

@ -13,6 +13,18 @@ export type {UnknownShorthandCompoundProps} from './propTypes'
import * as globalVariableNames from '@theatre/shared/globalVariableNames'
import type StudioBundle from '@theatre/studio/StudioBundle'
import CoreBundle from './CoreBundle'
import type {OnDiskState} from './projects/store/storeTypes'
/**
* NOTE: **INTERNAL and UNSTABLE** - This _WILL_ break between minor versions.
*
* This type represents the object returned by `studio.createContnentOfSaveFile()`. It's
* meant for advanced users who want to interact with the state of projects. In the vast
* majority of cases, you __should not__ use this type. Either an API for your use-case
* already exists, or you should open an issue on GitHub: https://github.com/theatre-js/theatre/issues
*
*/
export type __UNSTABLE_Project_OnDiskState = OnDiskState
registerCoreBundle()

View file

@ -21,6 +21,7 @@ import {
} from './UIRoot/useKeyboardShortcuts'
import type TheatreSheetObject from '@theatre/core/sheetObjects/TheatreSheetObject'
import type TheatreSheet from '@theatre/core/sheets/TheatreSheet'
import type {__UNSTABLE_Project_OnDiskState} from '@theatre/core'
export interface ITransactionAPI {
/**
@ -434,6 +435,18 @@ export interface IStudio {
* @param persistenceKey - same persistencyKey as in `studio.initialize(opts)`, if any
*/
__experimental_clearPersistentStorage(persistenceKey?: string): void
/**
* Warning: This is an experimental API and will change in the future.
*
* This is functionally the same as `studio.createContentOfSaveFile()`, but
* returns a typed object instead of a JSON object.
*
* See {@link __UNSTABLE_Project_OnDiskState} for more information.
*/
__experimental_createContentOfSaveFileTyped(
projectId: string,
): __UNSTABLE_Project_OnDiskState
}
}
@ -474,6 +487,11 @@ export default class TheatreStudio implements IStudio {
__experimental_clearPersistentStorage(persistenceKey?: string): void {
return getStudio().clearPersistentStorage(persistenceKey)
},
__experimental_createContentOfSaveFileTyped(
projectId: string,
): __UNSTABLE_Project_OnDiskState {
return getStudio().createContentOfSaveFile(projectId) as $IntentionalAny
},
}
/**

View file

@ -33,7 +33,7 @@ const PlayheadPositionPopover: React.FC<{
* Called when user hits enter/escape
*/
onRequestClose: (reason: string) => void
}> = ({layoutP}) => {
}> = ({layoutP, onRequestClose}) => {
const sheet = val(layoutP.sheet)
const sequence = sheet.getSequence()
@ -53,6 +53,7 @@ const PlayheadPositionPopover: React.FC<{
if (tempPosition) {
tempPosition = undefined
sequence.position = originalPosition
onRequestClose('discardTemporaryValue')
}
},
permanentlySetValue(newPosition: number): void {
@ -60,6 +61,7 @@ const PlayheadPositionPopover: React.FC<{
tempPosition = undefined
}
sequence.position = clamp(newPosition, 0, sequence.length)
onRequestClose('permanentlySetValue')
},
}
}, [layoutP, sequence])
@ -72,11 +74,13 @@ const PlayheadPositionPopover: React.FC<{
return usePrism(() => {
const sequence = sheet.getSequence()
const value = Number(val(sequence.pointer.position).toFixed(3))
return (
<Container>
<Label>Sequence position</Label>
<BasicNumberInput
value={Number(sequence.position.toFixed(3))}
value={value}
{...fns}
isValid={greaterThanOrEqualToZero}
inputRef={inputRef}