@tomorrowevening/theatre-core 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +88 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { ISequence } from './sequences/TheatreSequence';
|
|
4
|
-
export { ISheetObject } from './sheetObjects/TheatreSheetObject';
|
|
5
|
-
export { ISheet } from './sheets/TheatreSheet';
|
|
6
|
-
export { UnknownShorthandCompoundProps } from './propTypes/index';
|
|
1
|
+
import type { PointerType, Prism } from '@tomorrowevening/theatre-dataverse';
|
|
2
|
+
import type { VoidFn } from '@tomorrowevening/theatre-shared/utils/types';
|
|
7
3
|
import { OnDiskState } from './projects/store/storeTypes';
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -12,6 +8,92 @@ import { OnDiskState } from './projects/store/storeTypes';
|
|
|
12
8
|
* @packageDocumentation
|
|
13
9
|
*/
|
|
14
10
|
|
|
11
|
+
// Re-exported from coreExports
|
|
12
|
+
export { notify } from '@tomorrowevening/theatre-shared/notify';
|
|
13
|
+
export * as types from './propTypes/index';
|
|
14
|
+
export { createRafDriver } from './rafDrivers';
|
|
15
|
+
export type { IRafDriver } from './rafDrivers';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns a project of the given id, or creates one if it doesn't already exist.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* If \@tomorrowevening/theatre-studio is also loaded, then the state of the project will be managed by the studio.
|
|
22
|
+
*
|
|
23
|
+
* [Learn more about exporting](https://www.theatrejs.com/docs/latest/manual/projects#state)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* Usage:
|
|
27
|
+
* ```ts
|
|
28
|
+
* import {getProject} from '@tomorrowevening/theatre-core'
|
|
29
|
+
* const config = {} // the config can be empty when starting a new project
|
|
30
|
+
* const project = getProject("a-unique-id", config)
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* Usage with an explicit state:
|
|
35
|
+
* ```ts
|
|
36
|
+
* import {getProject} from '@tomorrowevening/theatre-core'
|
|
37
|
+
* import state from './saved-state.json'
|
|
38
|
+
* const config = {state} // here the config contains our saved state
|
|
39
|
+
* const project = getProject("a-unique-id", config)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function getProject(id: string, config?: IProjectConfig): IProject;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Calls `callback` every time the pointed value of `pointer` changes.
|
|
46
|
+
*
|
|
47
|
+
* @param pointer - A Pointer (like `object.props.x`)
|
|
48
|
+
* @param callback - The callback is called every time the value of pointer changes
|
|
49
|
+
* @param rafDriver - (optional) The `rafDriver` to use. Learn how to use `rafDriver`s [from the docs](https://www.theatrejs.com/docs/latest/manual/advanced#rafdrivers).
|
|
50
|
+
* @returns An unsubscribe function
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* Usage:
|
|
54
|
+
* ```ts
|
|
55
|
+
* import {getProject, onChange} from '@tomorrowevening/theatre-core'
|
|
56
|
+
*
|
|
57
|
+
* const obj = getProject("A project").sheet("Scene").object("Box", {position: {x: 0}})
|
|
58
|
+
*
|
|
59
|
+
* const usubscribe = onChange(obj.props.position.x, (x) => {
|
|
60
|
+
* console.log('position.x changed to:', x)
|
|
61
|
+
* })
|
|
62
|
+
*
|
|
63
|
+
* setTimeout(usubscribe, 10000) // stop listening to changes after 10 seconds
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function onChange<P extends PointerType<any> | Prism<any>>(
|
|
67
|
+
pointer: P,
|
|
68
|
+
callback: (value: P extends PointerType<infer T> ? T : P extends Prism<infer T> ? T : unknown) => void,
|
|
69
|
+
rafDriver?: IRafDriver
|
|
70
|
+
): VoidFn;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Takes a Pointer and returns the value it points to.
|
|
74
|
+
*
|
|
75
|
+
* @param pointer - A pointer (like `object.props.x`)
|
|
76
|
+
* @returns The value the pointer points to
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
*
|
|
80
|
+
* Usage
|
|
81
|
+
* ```ts
|
|
82
|
+
* import {val, getProject} from '@tomorrowevening/theatre-core'
|
|
83
|
+
*
|
|
84
|
+
* const obj = getProject("A project").sheet("Scene").object("Box", {position: {x: 0}})
|
|
85
|
+
*
|
|
86
|
+
* console.log(val(obj.props.position.x)) // logs the value of obj.props.x
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function val<T>(pointer: PointerType<T>): T;
|
|
90
|
+
|
|
91
|
+
export { IProject, IProjectConfig } from './projects/TheatreProject';
|
|
92
|
+
export { ISequence } from './sequences/TheatreSequence';
|
|
93
|
+
export { ISheetObject } from './sheetObjects/TheatreSheetObject';
|
|
94
|
+
export { ISheet } from './sheets/TheatreSheet';
|
|
95
|
+
export { UnknownShorthandCompoundProps } from './propTypes/index';
|
|
96
|
+
|
|
15
97
|
/**
|
|
16
98
|
* NOTE: **INTERNAL and UNSTABLE** - This _WILL_ break between minor versions.
|
|
17
99
|
*
|