Implement the experimental createContentOfSaveFileTyped() (#391)

Co-authored-by: Aria Minaei <aria.minaei@gmail.com>
This commit is contained in:
Adam Krebs 2023-03-09 06:50:46 -05:00 committed by GitHub
parent 6c7da6f653
commit d7feb3ffdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -13,6 +13,18 @@ export type {UnknownShorthandCompoundProps} from './propTypes'
import * as globalVariableNames from '@theatre/shared/globalVariableNames' import * as globalVariableNames from '@theatre/shared/globalVariableNames'
import type StudioBundle from '@theatre/studio/StudioBundle' import type StudioBundle from '@theatre/studio/StudioBundle'
import CoreBundle from './CoreBundle' 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() registerCoreBundle()

View file

@ -21,6 +21,7 @@ import {
} from './UIRoot/useKeyboardShortcuts' } from './UIRoot/useKeyboardShortcuts'
import type TheatreSheetObject from '@theatre/core/sheetObjects/TheatreSheetObject' import type TheatreSheetObject from '@theatre/core/sheetObjects/TheatreSheetObject'
import type TheatreSheet from '@theatre/core/sheets/TheatreSheet' import type TheatreSheet from '@theatre/core/sheets/TheatreSheet'
import type {__UNSTABLE_Project_OnDiskState} from '@theatre/core'
export interface ITransactionAPI { export interface ITransactionAPI {
/** /**
@ -434,6 +435,18 @@ export interface IStudio {
* @param persistenceKey - same persistencyKey as in `studio.initialize(opts)`, if any * @param persistenceKey - same persistencyKey as in `studio.initialize(opts)`, if any
*/ */
__experimental_clearPersistentStorage(persistenceKey?: string): void __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 { __experimental_clearPersistentStorage(persistenceKey?: string): void {
return getStudio().clearPersistentStorage(persistenceKey) return getStudio().clearPersistentStorage(persistenceKey)
}, },
__experimental_createContentOfSaveFileTyped(
projectId: string,
): __UNSTABLE_Project_OnDiskState {
return getStudio().createContentOfSaveFile(projectId) as $IntentionalAny
},
} }
/** /**