From 6c7da6f653b452f1ce9d2995eae65606703598ab Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Thu, 9 Mar 2023 12:43:41 +0100 Subject: [PATCH 1/3] UX improvements for PlayheadPositionPopover --- .../RightOverlay/PlayheadPositionPopover.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/PlayheadPositionPopover.tsx b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/PlayheadPositionPopover.tsx index da776c9..046eb42 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/PlayheadPositionPopover.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/PlayheadPositionPopover.tsx @@ -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 ( Date: Thu, 9 Mar 2023 06:50:46 -0500 Subject: [PATCH 2/3] Implement the experimental `createContentOfSaveFileTyped()` (#391) Co-authored-by: Aria Minaei --- theatre/core/src/index.ts | 12 ++++++++++++ theatre/studio/src/TheatreStudio.ts | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/theatre/core/src/index.ts b/theatre/core/src/index.ts index 5998343..1ceda23 100644 --- a/theatre/core/src/index.ts +++ b/theatre/core/src/index.ts @@ -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() diff --git a/theatre/studio/src/TheatreStudio.ts b/theatre/studio/src/TheatreStudio.ts index 3637272..2801951 100644 --- a/theatre/studio/src/TheatreStudio.ts +++ b/theatre/studio/src/TheatreStudio.ts @@ -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 + }, } /** From 4c375672af7d8fb068f4c289d979a3638707bd90 Mon Sep 17 00:00:00 2001 From: Timo Hausmann Date: Thu, 9 Mar 2023 12:54:52 +0100 Subject: [PATCH 3/3] playground needs yarn build (#402) --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cabfc21..6377d87 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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