Progress on docs

This commit is contained in:
Aria Minaei 2021-09-04 17:08:51 +02:00
parent c189bb2662
commit 5d63ce4f3e
7 changed files with 63 additions and 49 deletions

View file

@ -42,7 +42,7 @@ export function getProject(id: string, config: IProjectConfig = {}): IProject {
throw new Error(
`You seem to have called Theatre.getProject("${id}", config) twice, with different config objects. ` +
`This is disallowed because changing the config of a project on the fly can lead to hard-to-debug issues.\n\n` +
`You can fix this by either calling Theatre.getProject() once per project-id,` +
`You can fix this by either calling Theatre.getProject() once per projectId,` +
` or calling it multiple times but with the exact same config.`,
)
}

View file

@ -1,3 +1,9 @@
/**
* Theatre comes in two packages: `@theatre/core` (the library) and
* `@theatre/studio` (the editor). This package is the core library.
*
* @module \@theatre/core
*/
export * from './coreExports'
export type {
IProject,

View file

@ -6,19 +6,37 @@ import {validateName} from '@theatre/shared/utils/sanitizers'
import {validateAndSanitiseSlashedPathOrThrow} from '@theatre/shared/utils/slashedPaths'
import type {$IntentionalAny} from '@theatre/shared/utils/types'
export type IProjectConfig = Partial<{
state: $IntentionalAny
}>
/**
* A project's config object (currently the only point of configuration is the project's state)
*/
export type IProjectConfig = {
/**
* The state of the project, as [exported](https://docs.theatrejs.com/export.html) by the studio.
*/
state?: $IntentionalAny
}
/**
* A Theatre project
*/
export interface IProject {
readonly type: 'Theatre_Project_PublicAPI'
/**
* If `@theatre/studio` is used, this promise would resolve when studio has loaded
* the state of the project into memory.
*
* If `@theatre/studio` is not used, this promise is already resolved.
*/
readonly ready: Promise<void>
/**
* Shows whether the project is ready to be used.
* Better to use IProject.ready, which is a promise that will
* Better to use {@link IProject.ready}, which is a promise that would
* resolve when the project is ready.
*/
readonly isReady: boolean
/**
* The project's address
*/
readonly address: ProjectAddress
sheet(sheetId: string, instanceId?: string): ISheet
}