@unseenco/theatre-studio 0.1.15 → 0.1.16
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 +604 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,606 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { IRafDriver, ISheetObject, ISheet, IProject, __UNSTABLE_Project_OnDiskState } from '@unseenco/theatre-core';
|
|
2
|
+
import { Pointer } from '@unseenco/theatre-dataverse';
|
|
3
|
+
import TheatreSheetObject from '@unseenco/theatre-core/sheetObjects/TheatreSheetObject';
|
|
4
|
+
import TheatreSheet from '@unseenco/theatre-core/sheets/TheatreSheet';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
type VoidFn = () => void;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Using a symbol, we can sort of add unique properties to arbitrary other types.
|
|
11
|
+
* So, we use this to our advantage to add a "marker" of information to strings using
|
|
12
|
+
* the {@link Nominal} type.
|
|
13
|
+
*
|
|
14
|
+
* Can be used with keys in pointers.
|
|
15
|
+
* This identifier shows in the expanded {@link Nominal} as `string & {[nominal]:"SequenceTrackId"}`,
|
|
16
|
+
* So, we're opting to keeping the identifier short.
|
|
17
|
+
*/
|
|
18
|
+
declare const nominal$1: unique symbol;
|
|
19
|
+
/**
|
|
20
|
+
* This creates an "opaque"/"nominal" type.
|
|
21
|
+
*
|
|
22
|
+
* Our primary use case is to be able to use with keys in pointers.
|
|
23
|
+
*
|
|
24
|
+
* Numbers cannot be added together if they are "nominal"
|
|
25
|
+
*
|
|
26
|
+
* See {@link nominal} for more details.
|
|
27
|
+
*/
|
|
28
|
+
type Nominal$1<N extends string> = string & {
|
|
29
|
+
[nominal$1]: N;
|
|
30
|
+
};
|
|
31
|
+
declare global {
|
|
32
|
+
interface ObjectConstructor {
|
|
33
|
+
/** Nominal: Extension to the Object prototype definition to properly manage {@link Nominal} keyed records */
|
|
34
|
+
keys<T extends Record<Nominal$1<string>, any>>(obj: T): any extends T ? never[] : Extract<keyof T, string>[];
|
|
35
|
+
/** Nominal: Extension to the Object prototype definition to properly manage {@link Nominal} keyed records */
|
|
36
|
+
entries<T extends Record<Nominal$1<string>, any>>(obj: T): any extends T ? [never, never][] : Array<{
|
|
37
|
+
[P in keyof T]: [P, T[P]];
|
|
38
|
+
}[Extract<keyof T, string>]>;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type PaneInstanceId = Nominal$1<'PaneInstanceId'>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Using a symbol, we can sort of add unique properties to arbitrary other types.
|
|
46
|
+
* So, we use this to our advantage to add a "marker" of information to strings using
|
|
47
|
+
* the {@link Nominal} type.
|
|
48
|
+
*
|
|
49
|
+
* Can be used with keys in pointers.
|
|
50
|
+
* This identifier shows in the expanded {@link Nominal} as `string & {[nominal]:"SequenceTrackId"}`,
|
|
51
|
+
* So, we're opting to keeping the identifier short.
|
|
52
|
+
*/
|
|
53
|
+
declare const nominal = Symbol()
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This creates an "opaque"/"nominal" type.
|
|
57
|
+
*
|
|
58
|
+
* Our primary use case is to be able to use with keys in pointers.
|
|
59
|
+
*
|
|
60
|
+
* Numbers cannot be added together if they are "nominal"
|
|
61
|
+
*
|
|
62
|
+
* See {@link nominal} for more details.
|
|
63
|
+
*/
|
|
64
|
+
type Nominal<N extends string> = string & {[nominal]: N}
|
|
65
|
+
|
|
66
|
+
declare global {
|
|
67
|
+
// Fix Object.entries and Object.keys definitions for Nominal strict records
|
|
68
|
+
interface ObjectConstructor {
|
|
69
|
+
/** Nominal: Extension to the Object prototype definition to properly manage {@link Nominal} keyed records */
|
|
70
|
+
keys<T extends Record<Nominal<string>, any>>(
|
|
71
|
+
obj: T,
|
|
72
|
+
): any extends T ? never[] : Extract<keyof T, string>[]
|
|
73
|
+
/** Nominal: Extension to the Object prototype definition to properly manage {@link Nominal} keyed records */
|
|
74
|
+
entries<T extends Record<Nominal<string>, any>>(
|
|
75
|
+
obj: T,
|
|
76
|
+
): any extends T
|
|
77
|
+
? [never, never][]
|
|
78
|
+
: Array<{[P in keyof T]: [P, T[P]]}[Extract<keyof T, string>]>
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The scrub API is a simple construct for changing values in Theatre.js in a history-compatible way.
|
|
84
|
+
* Primarily, it can be used to create a series of value changes using a temp transaction without
|
|
85
|
+
* creating multiple transactions.
|
|
86
|
+
*
|
|
87
|
+
* The name is inspired by the activity of "scrubbing" the value of an input through clicking and
|
|
88
|
+
* dragging left and right. But, the API is not limited to chaning a single prop's value.
|
|
89
|
+
*
|
|
90
|
+
* For now, using the {@link IScrubApi.set} will result in changing the values where the
|
|
91
|
+
* playhead is (the `sequence.position`).
|
|
92
|
+
*/
|
|
93
|
+
interface IScrubApi {
|
|
94
|
+
/**
|
|
95
|
+
* Set the value of a prop by its pointer. If the prop is sequenced, the value
|
|
96
|
+
* will be a keyframe at the current playhead position (`sequence.position`).
|
|
97
|
+
*
|
|
98
|
+
* @param pointer - A Pointer, like object.props
|
|
99
|
+
* @param value - The value to override the existing value. This is treated as a deep partial value.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* Usage:
|
|
103
|
+
* ```ts
|
|
104
|
+
* const obj = sheet.object("box", {x: 0, y: 0})
|
|
105
|
+
* const scrub = studio.scrub()
|
|
106
|
+
* scrub.capture(({set}) => {
|
|
107
|
+
* // set a specific prop's value
|
|
108
|
+
* set(obj.props.x, 10) // New value is {x: 10, y: 0}
|
|
109
|
+
* // values are set partially
|
|
110
|
+
* set(obj.props, {y: 11}) // New value is {x: 10, y: 11}
|
|
111
|
+
*
|
|
112
|
+
* // this will error, as there is no such prop as 'z'
|
|
113
|
+
* set(obj.props.z, 10)
|
|
114
|
+
* })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
set<T>(pointer: Pointer<T>, value: T): void;
|
|
118
|
+
}
|
|
119
|
+
interface IScrub {
|
|
120
|
+
/**
|
|
121
|
+
* Clears all the ops in the scrub, but keeps the scrub open so you can call
|
|
122
|
+
* `scrub.capture()` again.
|
|
123
|
+
*/
|
|
124
|
+
reset(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Commits the scrub and creates a single undo level.
|
|
127
|
+
*/
|
|
128
|
+
commit(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Captures operations for the scrub.
|
|
131
|
+
*
|
|
132
|
+
* Note that running `scrub.capture()` multiple times means all the older
|
|
133
|
+
* calls of `scrub.capture()` will be reset.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* Usage:
|
|
137
|
+
* ```ts
|
|
138
|
+
* scrub.capture(({set}) => {
|
|
139
|
+
* set(obj.props.x, 10) // set the value of obj.props.x to 10
|
|
140
|
+
* })
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
capture(fn: (api: IScrubApi) => void): void;
|
|
144
|
+
/**
|
|
145
|
+
* Clears the ops of the scrub and destroys it. After calling this,
|
|
146
|
+
* you won't be able to call `scrub.capture()` anymore.
|
|
147
|
+
*/
|
|
148
|
+
discard(): void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface ITransactionAPI {
|
|
152
|
+
/**
|
|
153
|
+
* Set the value of a prop by its pointer. If the prop is sequenced, the value
|
|
154
|
+
* will be a keyframe at the current sequence position.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* Usage:
|
|
158
|
+
* ```ts
|
|
159
|
+
* const obj = sheet.object("box", {x: 0, y: 0})
|
|
160
|
+
* studio.transaction(({set}) => {
|
|
161
|
+
* // set a specific prop's value
|
|
162
|
+
* set(obj.props.x, 10) // New value is {x: 10, y: 0}
|
|
163
|
+
* // values are set partially
|
|
164
|
+
* set(obj.props, {y: 11}) // New value is {x: 10, y: 11}
|
|
165
|
+
*
|
|
166
|
+
* // this will error, as there is no such prop as 'z'
|
|
167
|
+
* set(obj.props.z, 10)
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
* @param pointer - A Pointer, like object.props
|
|
171
|
+
* @param value - The value to override the existing value. This is treated as a deep partial value.
|
|
172
|
+
*/
|
|
173
|
+
set<V>(pointer: Pointer<V>, value: V): void;
|
|
174
|
+
/**
|
|
175
|
+
* Unsets the value of a prop by its pointer.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* Usage:
|
|
179
|
+
* ```ts
|
|
180
|
+
* const obj = sheet.object("box", {x: 0, y: 0})
|
|
181
|
+
* studio.transaction(({set}) => {
|
|
182
|
+
* // set props.x to its default value
|
|
183
|
+
* unset(obj.props.x)
|
|
184
|
+
* // set all props to their default value
|
|
185
|
+
* set(obj.props)
|
|
186
|
+
* })
|
|
187
|
+
* ```
|
|
188
|
+
* @param pointer - A pointer, like object.props
|
|
189
|
+
*/
|
|
190
|
+
unset<V>(pointer: Pointer<V>): void;
|
|
191
|
+
/**
|
|
192
|
+
* EXPERIMENTAL API - this api may be removed without notice.
|
|
193
|
+
*
|
|
194
|
+
* Makes Theatre forget about this object. This means all the prop overrides and sequenced props
|
|
195
|
+
* will be reset, and the object won't show up in the exported state.
|
|
196
|
+
*/
|
|
197
|
+
__experimental_forgetObject(object: TheatreSheetObject): void;
|
|
198
|
+
/**
|
|
199
|
+
* EXPERIMENTAL API - this api may be removed without notice.
|
|
200
|
+
*
|
|
201
|
+
* Makes Theatre forget about this sheet.
|
|
202
|
+
*/
|
|
203
|
+
__experimental_forgetSheet(sheet: TheatreSheet): void;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
*
|
|
207
|
+
*/
|
|
208
|
+
interface PaneClassDefinition {
|
|
209
|
+
/**
|
|
210
|
+
* Each pane has a `class`, which is a string.
|
|
211
|
+
*/
|
|
212
|
+
class: string;
|
|
213
|
+
mount: (opts: {
|
|
214
|
+
paneId: string;
|
|
215
|
+
node: HTMLElement;
|
|
216
|
+
}) => () => void;
|
|
217
|
+
}
|
|
218
|
+
type ToolConfigIcon = {
|
|
219
|
+
type: 'Icon';
|
|
220
|
+
svgSource: string;
|
|
221
|
+
title: string;
|
|
222
|
+
onClick: () => void;
|
|
223
|
+
/**
|
|
224
|
+
* When true, the button is rendered in its selected/active style.
|
|
225
|
+
*/
|
|
226
|
+
selected?: boolean;
|
|
227
|
+
};
|
|
228
|
+
type ToolConfigOption = {
|
|
229
|
+
value: string;
|
|
230
|
+
label: string;
|
|
231
|
+
svgSource: string;
|
|
232
|
+
};
|
|
233
|
+
type ToolConfigSwitch = {
|
|
234
|
+
type: 'Switch';
|
|
235
|
+
value: string;
|
|
236
|
+
onChange: (value: string) => void;
|
|
237
|
+
options: ToolConfigOption[];
|
|
238
|
+
};
|
|
239
|
+
type ToolconfigFlyoutMenuItem = {
|
|
240
|
+
label: string;
|
|
241
|
+
onClick?: () => void;
|
|
242
|
+
};
|
|
243
|
+
type ToolConfigFlyoutMenu = {
|
|
244
|
+
/**
|
|
245
|
+
* A flyout menu
|
|
246
|
+
*/
|
|
247
|
+
type: 'Flyout';
|
|
248
|
+
/**
|
|
249
|
+
* The label of the trigger button
|
|
250
|
+
*/
|
|
251
|
+
label: string;
|
|
252
|
+
items: ToolconfigFlyoutMenuItem[];
|
|
253
|
+
};
|
|
254
|
+
type ToolConfig = ToolConfigIcon | ToolConfigSwitch | ToolConfigFlyoutMenu;
|
|
255
|
+
type ToolsetConfig = Array<ToolConfig>;
|
|
256
|
+
/**
|
|
257
|
+
* A Theatre.js Studio extension. You can define one either
|
|
258
|
+
* in a separate package, or within your project.
|
|
259
|
+
*/
|
|
260
|
+
interface IExtension {
|
|
261
|
+
/**
|
|
262
|
+
* Pick a unique ID for your extension. Ideally the name would be unique if
|
|
263
|
+
* the extension was to be published to the npm repository.
|
|
264
|
+
*/
|
|
265
|
+
id: string;
|
|
266
|
+
/**
|
|
267
|
+
* Set this if you'd like to add a component to the global toolbar (on the top)
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* TODO
|
|
271
|
+
*/
|
|
272
|
+
toolbars?: {
|
|
273
|
+
[key in 'global' | string]: (set: (config: ToolsetConfig) => void, studio: IStudio) => () => void;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Introduces new pane types.
|
|
277
|
+
* @example
|
|
278
|
+
* TODO
|
|
279
|
+
*/
|
|
280
|
+
panes?: Array<PaneClassDefinition>;
|
|
281
|
+
}
|
|
282
|
+
type PaneInstance<ClassName extends string> = {
|
|
283
|
+
extensionId: string;
|
|
284
|
+
instanceId: PaneInstanceId;
|
|
285
|
+
definition: PaneClassDefinition;
|
|
286
|
+
};
|
|
287
|
+
type IDockedViewport = {
|
|
288
|
+
top: number;
|
|
289
|
+
left: number;
|
|
290
|
+
width: number;
|
|
291
|
+
height: number;
|
|
292
|
+
};
|
|
293
|
+
interface IStudioUI {
|
|
294
|
+
/**
|
|
295
|
+
* Temporarily hides the studio
|
|
296
|
+
*/
|
|
297
|
+
hide(): void;
|
|
298
|
+
/**
|
|
299
|
+
* Whether the studio is currently visible or hidden
|
|
300
|
+
*/
|
|
301
|
+
readonly isHidden: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Makes the studio visible again.
|
|
304
|
+
*/
|
|
305
|
+
restore(): void;
|
|
306
|
+
/**
|
|
307
|
+
* Whether the studio UI is in docked layout mode.
|
|
308
|
+
*/
|
|
309
|
+
readonly isDocked: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* The inner viewport rectangle when docked and visible.
|
|
312
|
+
* `null` when floating or when the studio is hidden.
|
|
313
|
+
*/
|
|
314
|
+
readonly dockedViewport: IDockedViewport | null;
|
|
315
|
+
/**
|
|
316
|
+
* Listen for docked layout mode changes. Called immediately with the
|
|
317
|
+
* current value.
|
|
318
|
+
*/
|
|
319
|
+
onDockedToggle(listener: (docked: boolean) => void): VoidFn;
|
|
320
|
+
/**
|
|
321
|
+
* Listen for inner viewport size/position changes while docked. Called
|
|
322
|
+
* immediately with the current viewport if docked. Called with `null` when
|
|
323
|
+
* the viewport is released (e.g. studio hidden while docked).
|
|
324
|
+
*/
|
|
325
|
+
onDockedResize(listener: (viewport: IDockedViewport | null) => void): VoidFn;
|
|
326
|
+
renderToolset(toolsetId: string, htmlNode: HTMLElement): () => void;
|
|
327
|
+
}
|
|
328
|
+
interface _StudioInitializeOpts {
|
|
329
|
+
/**
|
|
330
|
+
* The local storage key to use to persist the state.
|
|
331
|
+
*
|
|
332
|
+
* Default: "theatrejs:0.4"
|
|
333
|
+
*/
|
|
334
|
+
persistenceKey?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Whether to persist the changes in the browser's temporary storage.
|
|
337
|
+
* It is useful to set this to false in the test environment or when debugging things.
|
|
338
|
+
*
|
|
339
|
+
* Default: true
|
|
340
|
+
*/
|
|
341
|
+
usePersistentStorage?: boolean;
|
|
342
|
+
__experimental_rafDriver?: IRafDriver | undefined;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* This is the public api of Theatre's studio. It is exposed through:
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* Basic usage:
|
|
349
|
+
* ```ts
|
|
350
|
+
* import studio from '@unseenco/theatre-studio'
|
|
351
|
+
*
|
|
352
|
+
* studio.initialize()
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* Usage with **tree-shaking**:
|
|
357
|
+
* ```ts
|
|
358
|
+
* import studio from '@unseenco/theatre-studio'
|
|
359
|
+
*
|
|
360
|
+
* if (process.env.NODE_ENV !== 'production') {
|
|
361
|
+
* studio.initialize()
|
|
362
|
+
* }
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
interface IStudio {
|
|
366
|
+
readonly ui: IStudioUI;
|
|
367
|
+
/**
|
|
368
|
+
* Initializes the studio. Call it once in your index.js/index.ts module.
|
|
369
|
+
* It silently ignores subsequent calls.
|
|
370
|
+
*/
|
|
371
|
+
initialize(opts?: _StudioInitializeOpts): void;
|
|
372
|
+
/**
|
|
373
|
+
* Runs an undo-able transaction. Creates a single undo level for all
|
|
374
|
+
* the operations inside the transaction.
|
|
375
|
+
*
|
|
376
|
+
* Will roll back if an error is thrown.
|
|
377
|
+
*
|
|
378
|
+
* Pass `{undoable: false}` to persist the changes without recording an undo
|
|
379
|
+
* level — useful for frequently-updated values such as a camera position that
|
|
380
|
+
* should survive a page refresh but should not pollute the undo/redo stack.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* Usage:
|
|
384
|
+
* ```ts
|
|
385
|
+
* studio.transaction(({set, unset}) => {
|
|
386
|
+
* set(obj.props.x, 10) // set the value of obj.props.x to 10
|
|
387
|
+
* unset(obj.props.y) // unset the override at obj.props.y
|
|
388
|
+
* })
|
|
389
|
+
*
|
|
390
|
+
* // Non-undoable: persisted but not recorded in undo history
|
|
391
|
+
* studio.transaction(({set}) => {
|
|
392
|
+
* set(obj.props.cameraPosition, newPos)
|
|
393
|
+
* }, {undoable: false})
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
transaction(fn: (api: ITransactionAPI) => void, opts?: {
|
|
397
|
+
undoable?: boolean;
|
|
398
|
+
}): void;
|
|
399
|
+
/**
|
|
400
|
+
* Creates a scrub, which is just like a transaction, except you
|
|
401
|
+
* can run it multiple times without creating extra undo levels.
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* Usage:
|
|
405
|
+
* ```ts
|
|
406
|
+
* const scrub = studio.scrub()
|
|
407
|
+
* scrub.capture(({set}) => {
|
|
408
|
+
* set(obj.props.x, 10) // set the value of obj.props.x to 10
|
|
409
|
+
* })
|
|
410
|
+
*
|
|
411
|
+
* // half a second later...
|
|
412
|
+
* scrub.capture(({set}) => {
|
|
413
|
+
* set(obj.props.y, 11) // set the value of obj.props.y to 11
|
|
414
|
+
* // note that since we're not setting obj.props.x, its value reverts back to its old value (ie. not 10)
|
|
415
|
+
* })
|
|
416
|
+
*
|
|
417
|
+
* // then either:
|
|
418
|
+
* scrub.commit() // commits the scrub and creates a single undo level
|
|
419
|
+
* // or:
|
|
420
|
+
* scrub.reset() // clear all the ops in the scrub so we can run scrub.capture() again
|
|
421
|
+
* // or:
|
|
422
|
+
* scrub.discard() // clears the ops and destroys it (ie. can't call scrub.capture() anymore)
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
scrub(): IScrub;
|
|
426
|
+
/**
|
|
427
|
+
* Creates a debounced scrub, which is just like a normal scrub, but
|
|
428
|
+
* automatically runs scrub.commit() after `threshhold` milliseconds have
|
|
429
|
+
* passed after the last `scrub.capture`.
|
|
430
|
+
*
|
|
431
|
+
* @param threshhold - How long to wait before committing the scrub
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* Usage:
|
|
435
|
+
* ```ts
|
|
436
|
+
* // Will create a new undo-level after 2 seconds have passed
|
|
437
|
+
* // since the last scrub.capture()
|
|
438
|
+
* const scrub = studio.debouncedScrub(2000)
|
|
439
|
+
*
|
|
440
|
+
* // capture some ops
|
|
441
|
+
* scrub.capture(...)
|
|
442
|
+
* // wait one second
|
|
443
|
+
* await delay(1000)
|
|
444
|
+
* // capture more ops but no new undo level is made,
|
|
445
|
+
* // because the last scrub.capture() was called less than 2 seconds ago
|
|
446
|
+
* scrub.capture(...)
|
|
447
|
+
*
|
|
448
|
+
* // wait another seonc and half
|
|
449
|
+
* await delay(1500)
|
|
450
|
+
* // still no new undo level, because less than 2 seconds have passed
|
|
451
|
+
* // since the last capture
|
|
452
|
+
* scrub.capture(...)
|
|
453
|
+
*
|
|
454
|
+
* // wait 3 seconds
|
|
455
|
+
* await delay(3000) // at this point, one undo level is created.
|
|
456
|
+
*
|
|
457
|
+
* // this call to capture will start a new undo level
|
|
458
|
+
* scrub.capture(...)
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
debouncedScrub(threshhold: number): Pick<IScrub, 'capture'>;
|
|
462
|
+
/**
|
|
463
|
+
* Sets the current selection.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* Usage:
|
|
467
|
+
* ```ts
|
|
468
|
+
* const sheet1: ISheet = ...
|
|
469
|
+
* const obj1: ISheetObject<any> = ...
|
|
470
|
+
*
|
|
471
|
+
* studio.setSelection([sheet1, obj1])
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* You can read the current selection from studio.selection
|
|
475
|
+
*/
|
|
476
|
+
setSelection(selection: Array<ISheetObject<any> | ISheet>): void;
|
|
477
|
+
/**
|
|
478
|
+
* Calls fn every time the current selection changes.
|
|
479
|
+
*/
|
|
480
|
+
onSelectionChange(fn: (s: Array<ISheetObject<{}> | ISheet>) => void): VoidFunction;
|
|
481
|
+
/**
|
|
482
|
+
* The current selection, consisting of Sheets and Sheet Objects
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* Usage:
|
|
486
|
+
* ```ts
|
|
487
|
+
* console.log(studio.selection) // => [ISheetObject, ISheet]
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
readonly selection: Array<ISheetObject<{}> | ISheet>;
|
|
491
|
+
/**
|
|
492
|
+
* Registers an extension
|
|
493
|
+
*/
|
|
494
|
+
extend(
|
|
495
|
+
/**
|
|
496
|
+
* The extension's definition
|
|
497
|
+
*/
|
|
498
|
+
extension: IExtension, opts?: {
|
|
499
|
+
/**
|
|
500
|
+
* Whether to reconfigure the extension. This is useful if you're
|
|
501
|
+
* hot-reloading the extension.
|
|
502
|
+
*
|
|
503
|
+
* Mind you, that if the old version of the extension defines a pane,
|
|
504
|
+
* and the new version doesn't, all instances of that pane will disappear, as expected.
|
|
505
|
+
* _However_, if you again reconfigure the extension with the old version, the instances
|
|
506
|
+
* of the pane that pane will re-appear.
|
|
507
|
+
*
|
|
508
|
+
* We're not sure about whether this behavior makes sense or not. If not, let us know
|
|
509
|
+
* in the discord server or open an issue on github.
|
|
510
|
+
*/
|
|
511
|
+
__experimental_reconfigure?: boolean;
|
|
512
|
+
}): void;
|
|
513
|
+
/**
|
|
514
|
+
* Creates a new pane
|
|
515
|
+
*
|
|
516
|
+
* @param paneClass - The class name of the pane (provided by an extension)
|
|
517
|
+
*/
|
|
518
|
+
createPane<PaneClass extends string>(paneClass: PaneClass): PaneInstance<PaneClass>;
|
|
519
|
+
/**
|
|
520
|
+
* Returns the Theatre.js project that contains the studio's sheets and objects.
|
|
521
|
+
*
|
|
522
|
+
* It is useful if you'd like to have sheets/objects that are present only when
|
|
523
|
+
* studio is present.
|
|
524
|
+
*/
|
|
525
|
+
getStudioProject(): IProject;
|
|
526
|
+
/**
|
|
527
|
+
* Creates a JSON object that contains the state of the project. You can use this
|
|
528
|
+
* to programmatically save the state of your projects to the storage system of your
|
|
529
|
+
* choice, rather than manually clicking on the "Export" button in the UI.
|
|
530
|
+
*
|
|
531
|
+
* @param projectId - same projectId as in `core.getProject(projectId)`
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* Usage:
|
|
535
|
+
* ```ts
|
|
536
|
+
* const projectId = "project"
|
|
537
|
+
* const json = studio.createContentOfSaveFile(projectId)
|
|
538
|
+
* const string = JSON.stringify(json)
|
|
539
|
+
* fetch(`/projects/${projectId}/state`, {method: 'POST', body: string}).then(() => {
|
|
540
|
+
* console.log("Saved")
|
|
541
|
+
* })
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
createContentOfSaveFile(projectId: string): Record<string, unknown>;
|
|
545
|
+
__experimental: {
|
|
546
|
+
/**
|
|
547
|
+
* Warning: This is an experimental API and will change in the future.
|
|
548
|
+
*
|
|
549
|
+
* Disables the play/pause keyboard shortcut (spacebar)
|
|
550
|
+
* Also see `__experimental_enablePlayPauseKeyboardShortcut()` to re-enable it.
|
|
551
|
+
*/
|
|
552
|
+
__experimental_disblePlayPauseKeyboardShortcut(): void;
|
|
553
|
+
/**
|
|
554
|
+
* Warning: This is an experimental API and will change in the future.
|
|
555
|
+
*
|
|
556
|
+
* Disables the play/pause keyboard shortcut (spacebar)
|
|
557
|
+
*/
|
|
558
|
+
__experimental_enablePlayPauseKeyboardShortcut(): void;
|
|
559
|
+
/**
|
|
560
|
+
* Clears persistent storage and ensures that the current state will not be
|
|
561
|
+
* saved on window unload. Further changes to state will continue writing to
|
|
562
|
+
* persistent storage, if enabled during initialization.
|
|
563
|
+
*
|
|
564
|
+
* @param persistenceKey - same persistencyKey as in `studio.initialize(opts)`, if any
|
|
565
|
+
*/
|
|
566
|
+
__experimental_clearPersistentStorage(persistenceKey?: string): void;
|
|
567
|
+
/**
|
|
568
|
+
* Warning: This is an experimental API and will change in the future.
|
|
569
|
+
*
|
|
570
|
+
* This is functionally the same as `studio.createContentOfSaveFile()`, but
|
|
571
|
+
* returns a typed object instead of a JSON object.
|
|
572
|
+
*
|
|
573
|
+
* See {@link __UNSTABLE_Project_OnDiskState} for more information.
|
|
574
|
+
*/
|
|
575
|
+
__experimental_createContentOfSaveFileTyped(projectId: string): __UNSTABLE_Project_OnDiskState;
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare const ToolbarDropdownSelect: React.FC<{
|
|
580
|
+
value: string;
|
|
581
|
+
options: Array<{
|
|
582
|
+
label: string;
|
|
583
|
+
value: string;
|
|
584
|
+
icon: React.ReactElement;
|
|
585
|
+
}>;
|
|
586
|
+
onChange: (value: string) => void;
|
|
587
|
+
label: (cur: {
|
|
588
|
+
label: string;
|
|
589
|
+
value: string;
|
|
590
|
+
}) => string;
|
|
591
|
+
}>;
|
|
592
|
+
//# sourceMappingURL=ToolbarDropdownSelect.d.ts.map
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Returns `true` when this browser window has opened a remote editor popup that
|
|
596
|
+
* is still open. Always `false` inside the remote editor window itself.
|
|
597
|
+
*/
|
|
598
|
+
declare function isRemoteEditorOpen(): boolean;
|
|
599
|
+
/**
|
|
600
|
+
* Subscribe to changes in {@link isRemoteEditorOpen}. The listener is called
|
|
601
|
+
* immediately with the current value.
|
|
602
|
+
*/
|
|
603
|
+
declare function onRemoteEditorOpenChange(listener: (isOpen: boolean) => void): () => void;
|
|
6
604
|
|
|
7
605
|
/**
|
|
8
606
|
* The library providing the editor components of Theatre.js.
|
|
@@ -16,4 +614,4 @@ export { IScrub } from './Scrub';
|
|
|
16
614
|
declare const studio: IStudio;
|
|
17
615
|
//# sourceMappingURL=index.d.ts.map
|
|
18
616
|
|
|
19
|
-
export { studio as default };
|
|
617
|
+
export { IDockedViewport, IExtension, IScrub, IStudio, IStudioUI, PaneClassDefinition, PaneInstance, ToolConfig, ToolConfigIcon, ToolConfigSwitch, ToolbarDropdownSelect, ToolsetConfig, _StudioInitializeOpts, studio as default, isRemoteEditorOpen, onRemoteEditorOpenChange };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unseenco/theatre-studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"description": "Motion design editor for the web",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@unseenco/theatre-core": "*"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@unseenco/theatre-dataverse": "0.1.
|
|
37
|
+
"@unseenco/theatre-dataverse": "0.1.16"
|
|
38
38
|
},
|
|
39
39
|
"//": "Add packages here to make them externals of studio. Add them to theatre/package.json if you want to bundle them with studio."
|
|
40
40
|
}
|