@canvas-commons/core 0.2.0

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/lib/index.d.ts ADDED
@@ -0,0 +1,4875 @@
1
+ import chroma from "chroma-js";
2
+
3
+ //#region src/events/EventDispatcherBase.d.ts
4
+ interface EventHandler<T> {
5
+ (value: T): any;
6
+ }
7
+ /**
8
+ * A base for dispatching {@link Subscribable}s.
9
+ *
10
+ * @typeParam TValue - The type of the argument passed to subscribers.
11
+ * @typeParam THandler - The type of the callback function.
12
+ */
13
+ declare abstract class EventDispatcherBase<TValue, THandler extends EventHandler<TValue> = EventHandler<TValue>> {
14
+ readonly subscribable: Subscribable<TValue, THandler>;
15
+ private subscribers;
16
+ /**
17
+ * {@inheritDoc Subscribable.subscribe}
18
+ */
19
+ subscribe(handler: THandler): () => void;
20
+ /**
21
+ * {@inheritDoc Subscribable.unsubscribe}
22
+ */
23
+ unsubscribe(handler: THandler): void;
24
+ /**
25
+ * Unsubscribe all subscribers from the event.
26
+ */
27
+ clear(): void;
28
+ protected notifySubscribers(value: TValue): ReturnType<THandler>[];
29
+ }
30
+ /**
31
+ * Provides safe access to the public interface of {@link EventDispatcherBase}.
32
+ *
33
+ * @remarks
34
+ * External classes can use it to subscribe to an event without being able to
35
+ * dispatch it.
36
+ *
37
+ * @typeParam TValue - The type of the argument passed to subscribers.
38
+ * @typeParam THandler - The type of the callback function.
39
+ */
40
+ declare class Subscribable<TValue, THandler extends EventHandler<TValue> = EventHandler<TValue>> {
41
+ protected dispatcher: EventDispatcherBase<TValue, THandler>;
42
+ constructor(dispatcher: EventDispatcherBase<TValue, THandler>);
43
+ /**
44
+ * Subscribe to the event.
45
+ *
46
+ * @param handler - The handler to invoke when the event occurs.
47
+ *
48
+ * @returns A callback function that cancels the subscription.
49
+ */
50
+ subscribe(handler: THandler): () => void;
51
+ /**
52
+ * Unsubscribe from the event.
53
+ *
54
+ * @param handler - The handler to unsubscribe.
55
+ */
56
+ unsubscribe(handler: THandler): void;
57
+ }
58
+ //#endregion
59
+ //#region src/events/AsyncEventDispatcher.d.ts
60
+ interface AsyncEventHandler<T> {
61
+ (value: T): Promise<void>;
62
+ }
63
+ /**
64
+ * Dispatches an asynchronous {@link SubscribableEvent}.
65
+ *
66
+ * @remarks
67
+ * The {@link dispatch} method returns a promise that resolves when all the
68
+ * handlers resolve.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * class Example {
73
+ * // expose the event to external classes
74
+ * public get onValueChanged {
75
+ * return this.value.subscribable;
76
+ * }
77
+ * // create a private dispatcher
78
+ * private value = new AsyncEventDispatcher<number>();
79
+ *
80
+ * private async dispatchExample() {
81
+ * // dispatching returns a Promise.
82
+ * await this.value.dispatch(0);
83
+ * }
84
+ * }
85
+ * ```
86
+ *
87
+ * @typeParam T - The type of the argument passed to subscribers.
88
+ */
89
+ declare class AsyncEventDispatcher<T> extends EventDispatcherBase<T, AsyncEventHandler<T>> {
90
+ dispatch(value: T): Promise<void>;
91
+ }
92
+ /**
93
+ * Provides safe access to the public interface of {@link AsyncEventDispatcher}.
94
+ *
95
+ * @remarks
96
+ * External classes can use it to subscribe to an event without being able to
97
+ * dispatch it.
98
+ *
99
+ * @typeParam T - The type of the argument passed to subscribers.
100
+ */
101
+ type SubscribableAsyncEvent<T> = Subscribable<T, AsyncEventHandler<T>>;
102
+ //#endregion
103
+ //#region src/events/EventDispatcher.d.ts
104
+ /**
105
+ * Dispatches a {@link SubscribableEvent}.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * class Example {
110
+ * // expose the event to external classes
111
+ * public get onValueChanged {
112
+ * return this.value.subscribable;
113
+ * }
114
+ * // create a private dispatcher
115
+ * private value = new EventDispatcher<number>();
116
+ *
117
+ * private dispatchExample() {
118
+ * // dispatching will notify all subscribers.
119
+ * this.value.dispatch(0);
120
+ * }
121
+ * }
122
+ * ```
123
+ *
124
+ * @typeParam T - The type of the value argument to subscribers.
125
+ */
126
+ declare class EventDispatcher<T> extends EventDispatcherBase<T> {
127
+ dispatch(value: T): void;
128
+ }
129
+ /**
130
+ * Provides safe access to the public interface of {@link EventDispatcher}.
131
+ *
132
+ * @remarks
133
+ * External classes can use it to subscribe to an event without being able to
134
+ * dispatch it.
135
+ *
136
+ * @typeParam T - The type of the argument passed to subscribers.
137
+ */
138
+ type SubscribableEvent<T> = Subscribable<T>;
139
+ //#endregion
140
+ //#region src/events/FlagDispatcher.d.ts
141
+ /**
142
+ * Dispatches a {@link SubscribableFlagEvent}.
143
+ *
144
+ * @remarks
145
+ * Subscribers are notified only when the flag is set.
146
+ * Subsequent calls to {@link raise} don't trigger anything.
147
+ * Any handlers added while the flag is raised are immediately invoked.
148
+ *
149
+ * Resetting the flag doesn't notify the subscribers, but raising it again does.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * class Example {
154
+ * // expose the event to external classes
155
+ * public get onChanged {
156
+ * return this.flag.subscribable;
157
+ * }
158
+ * // create a private dispatcher
159
+ * private flag = new FlagDispatcher();
160
+ *
161
+ * private dispatchExample() {
162
+ * // setting the flag will notify all subscribers
163
+ * this.flag.raise();
164
+ * }
165
+ * }
166
+ * ```
167
+ */
168
+ declare class FlagDispatcher extends EventDispatcherBase<void> {
169
+ private value;
170
+ /**
171
+ * Notify all current and future subscribers.
172
+ */
173
+ raise(): void;
174
+ /**
175
+ * Stop notifying future subscribers.
176
+ */
177
+ reset(): void;
178
+ /**
179
+ * Are subscribers being notified?
180
+ */
181
+ isRaised(): boolean;
182
+ subscribe(handler: EventHandler<void>): () => void;
183
+ }
184
+ /**
185
+ * Provides safe access to the public interface of {@link FlagDispatcher}.
186
+ *
187
+ * @remarks
188
+ * External classes can use it to subscribe to an event without being able to
189
+ * dispatch it.
190
+ */
191
+ type SubscribableFlagEvent = Subscribable<void>;
192
+ //#endregion
193
+ //#region src/events/ValueDispatcher.d.ts
194
+ /**
195
+ * Dispatches a {@link SubscribableValueEvent}
196
+ *
197
+ * @remarks
198
+ * Changing the value stored by a value dispatcher will immediately notify all
199
+ * its subscribers.
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * class Example {
204
+ * // expose the event to external classes
205
+ * public get onValueChanged {
206
+ * return this.value.subscribable;
207
+ * }
208
+ * // create a private dispatcher
209
+ * private value = new ValueDispatcher(0);
210
+ *
211
+ * private changingValueExample() {
212
+ * // changing the value will notify all subscribers.
213
+ * this.value.current = 7;
214
+ * }
215
+ * }
216
+ * ```
217
+ *
218
+ * @typeParam T - The type of the value passed to subscribers.
219
+ */
220
+ declare class ValueDispatcher<T> extends EventDispatcherBase<T> {
221
+ private value;
222
+ readonly subscribable: SubscribableValueEvent<T>;
223
+ /**
224
+ * {@inheritDoc SubscribableValueEvent.current}
225
+ */
226
+ get current(): T;
227
+ /**
228
+ * Set the current value of this dispatcher.
229
+ *
230
+ * @remarks
231
+ * Setting the value will immediately notify all subscribers.
232
+ *
233
+ * @param value - The new value.
234
+ */
235
+ set current(value: T);
236
+ /**
237
+ * @param value - The initial value.
238
+ */
239
+ constructor(value: T);
240
+ /**
241
+ * {@inheritDoc SubscribableValueEvent.subscribe}
242
+ */
243
+ subscribe(handler: EventHandler<T>, dispatchImmediately?: boolean): () => void;
244
+ }
245
+ /**
246
+ * Provides safe access to the public interface of {@link ValueDispatcher}.
247
+ *
248
+ * @remarks
249
+ * External classes can use it to subscribe to an event without being able to
250
+ * dispatch it.
251
+ *
252
+ * @typeParam T - The type of the value passed to subscribers.
253
+ */
254
+ declare class SubscribableValueEvent<T> extends Subscribable<T, EventHandler<T>> {
255
+ /**
256
+ * Get the most recent value of this dispatcher.
257
+ */
258
+ get current(): T;
259
+ /**
260
+ * Subscribe to the event.
261
+ *
262
+ * Subscribing will immediately invoke the handler with the most recent value.
263
+ *
264
+ * @param handler - The handler to invoke when the event occurs.
265
+ * @param dispatchImmediately - Whether the handler should be immediately
266
+ * invoked with the most recent value.
267
+ *
268
+ * @returns Callback function that cancels the subscription.
269
+ */
270
+ subscribe(handler: EventHandler<T>, dispatchImmediately?: boolean): () => void;
271
+ }
272
+ //#endregion
273
+ //#region src/meta/MetaField.d.ts
274
+ /**
275
+ * Represents an entry in the meta file.
276
+ *
277
+ * @typeParam TSerializedValue - The type used to store this field in the meta
278
+ * file.
279
+ * @typeParam TValue - The runtime type of this field.
280
+ */
281
+ declare class MetaField<TSerializedValue, TValue extends TSerializedValue = TSerializedValue> {
282
+ readonly name: string;
283
+ readonly initial: TValue;
284
+ /**
285
+ * The type of this field used by the editor to display the correct input.
286
+ */
287
+ readonly type: any;
288
+ spacing: boolean;
289
+ description: string;
290
+ /**
291
+ * Triggered when the data of this field changes.
292
+ *
293
+ * @eventProperty
294
+ */
295
+ get onChanged(): SubscribableValueEvent<TValue>;
296
+ protected readonly value: ValueDispatcher<TValue>;
297
+ /**
298
+ * Triggered when the field becomes disabled or enabled.
299
+ *
300
+ * @eventProperty
301
+ */
302
+ get onDisabled(): SubscribableValueEvent<boolean>;
303
+ protected readonly disabled: ValueDispatcher<boolean>;
304
+ /**
305
+ * @param name - The name of this field displayed in the editor.
306
+ * @param initial - The initial value of this field.
307
+ */
308
+ constructor(name: string, initial: TValue);
309
+ /**
310
+ * Get the current value.
311
+ */
312
+ get(): TValue;
313
+ /**
314
+ * Set the current value.
315
+ *
316
+ * @param value - The new value.
317
+ */
318
+ set(value: TSerializedValue): void;
319
+ /**
320
+ * Convert a serialized value into a runtime type.
321
+ *
322
+ * @param value - The serialized value.
323
+ */
324
+ parse(value: TSerializedValue): TValue;
325
+ /**
326
+ * Serialize the value of this field.
327
+ */
328
+ serialize(): TSerializedValue;
329
+ /**
330
+ * Create a clone of this field.
331
+ */
332
+ clone(): this;
333
+ /**
334
+ * Disable or enable the field in the editor.
335
+ *
336
+ * @param value - Whether the field should be disabled.
337
+ */
338
+ disable(value?: boolean): this;
339
+ /**
340
+ * Add or remove spacing at the beginning of this field.
341
+ *
342
+ * @param value - Whether to include the spacing.
343
+ */
344
+ space(value?: boolean): this;
345
+ /**
346
+ * Set the description of this field.
347
+ *
348
+ * @param description - The description.
349
+ */
350
+ describe(description: string): this;
351
+ }
352
+ //#endregion
353
+ //#region src/meta/ObjectMetaField.d.ts
354
+ type ValueOf<T extends Record<string, any>> = { [K in keyof T]: T[K] extends MetaField<any, infer P> ? P : never };
355
+ type TransformationOf<TObject extends Record<string, any>, TKey extends CallableKeys<MetaField<any>>> = { [K in keyof TObject]: TObject[K] extends MetaField<infer A, infer B> ? ReturnType<MetaField<A, B>[TKey]> : never };
356
+ type CallableKeys<T> = { [K in keyof T]: T[K] extends (() => void) ? K : never }[keyof T];
357
+ declare class ObjectMetaFieldInternal<T extends Record<string, MetaField<any>>> extends MetaField<ValueOf<T>> {
358
+ readonly type: ObjectConstructor;
359
+ /**
360
+ * Triggered when the nested fields change.
361
+ *
362
+ * @eventProperty
363
+ */
364
+ get onFieldsChanged(): SubscribableValueEvent<MetaField<unknown, unknown>[]>;
365
+ protected ignoreChange: boolean;
366
+ protected customFields: Record<string, unknown>;
367
+ protected readonly fields: Map<string, MetaField<unknown>>;
368
+ protected readonly event: ValueDispatcher<MetaField<unknown>[]>;
369
+ constructor(name: string, fields: T);
370
+ set(value: Partial<ValueOf<T>>): void;
371
+ serialize(): ValueOf<T>;
372
+ clone(): this;
373
+ protected handleChange: () => void;
374
+ protected transform<TKey extends CallableKeys<MetaField<any>>>(fn: TKey): TransformationOf<T, TKey>;
375
+ }
376
+ /**
377
+ * Represents an object with nested meta-fields.
378
+ */
379
+ type ObjectMetaField<T extends Record<string, MetaField<any>>> = ObjectMetaFieldInternal<T> & T;
380
+ /**
381
+ * Represents an object with nested meta-fields.
382
+ */
383
+ declare const ObjectMetaField: {
384
+ new <T extends Record<string, MetaField<any>>>(name: string, data: T): ObjectMetaField<T>;
385
+ };
386
+ //#endregion
387
+ //#region src/meta/BoolMetaField.d.ts
388
+ /**
389
+ * Represents a boolean value stored in a meta file.
390
+ */
391
+ declare class BoolMetaField extends MetaField<any, boolean> {
392
+ readonly type: BooleanConstructor;
393
+ parse(value: any): boolean;
394
+ }
395
+ //#endregion
396
+ //#region src/tweening/interpolationFunctions.d.ts
397
+ interface InterpolationFunction<T, TRest extends any[] = any[]> {
398
+ (from: T, to: T, value: number, ...args: TRest): T;
399
+ }
400
+ declare function textLerp(fromString: string, toString: string, value: number): string;
401
+ /**
402
+ * Interpolate between any two Records, including objects and Maps, even with
403
+ * mismatched keys.
404
+ *
405
+ * @remarks
406
+ * Any old key that is missing in `to` will be removed immediately once value is
407
+ * not 0. Any new key that is missing in `from` will be added once value reaches
408
+ * 1.
409
+ *
410
+ * @param from - The input to favor when value is 0.
411
+ * @param to - The input to favor when value is 1.
412
+ * @param value - On a scale between 0 and 1, how closely to favor from vs to.
413
+ *
414
+ * @returns A value matching the structure of from and to.
415
+ */
416
+ declare function deepLerp<TFrom extends Record<any, unknown>, TTo extends Record<any, unknown>>(from: TFrom, to: TTo, value: number): TFrom | TTo;
417
+ declare function deepLerp<TFrom extends Record<any, unknown>, TTo extends Record<any, unknown>>(from: TFrom, to: TTo, value: number, suppressWarnings: boolean): TFrom | TTo;
418
+ /**
419
+ * Interpolate between any two values, including objects, arrays, and Maps.
420
+ *
421
+ * @param from - The input to favor when value is 0.
422
+ * @param to - The input to favor when value is 1.
423
+ * @param value - On a scale between 0 and 1, how closely to favor from vs to.
424
+ *
425
+ * @returns A value matching the structure of from and to.
426
+ */
427
+ declare function deepLerp<T>(from: T, to: T, value: number): T;
428
+ declare function deepLerp<T>(from: T, to: T, value: number, suppressWarnings: boolean): T;
429
+ declare function boolLerp<T>(from: T, to: T, value: number): T;
430
+ declare function map(from: number, to: number, value: number): number;
431
+ declare function remap(fromIn: number, toIn: number, fromOut: number, toOut: number, value: number): number;
432
+ declare function clamp(min: number, max: number, value: number): number;
433
+ declare function clampRemap(fromIn: number, toIn: number, fromOut: number, toOut: number, value: number): number;
434
+ declare function arcLerp(value: number, reverse: boolean, ratio: number): Vector2;
435
+ //#endregion
436
+ //#region src/threading/Thread.d.ts
437
+ /**
438
+ * A class representing an individual thread.
439
+ *
440
+ * @remarks
441
+ * Thread is a wrapper for a generator that can be executed concurrently.
442
+ *
443
+ * Aside from the main thread, all threads need to have a parent.
444
+ * If a parent finishes execution, all of its child threads are terminated.
445
+ */
446
+ declare class Thread {
447
+ /**
448
+ * The generator wrapped by this thread.
449
+ */
450
+ readonly runner: ThreadGenerator & {
451
+ task?: Thread;
452
+ };
453
+ get onDeferred(): Subscribable<void, EventHandler<void>>;
454
+ private deferred;
455
+ children: Thread[];
456
+ /**
457
+ * The next value to be passed to the wrapped generator.
458
+ */
459
+ value: unknown;
460
+ /**
461
+ * The current time of this thread.
462
+ *
463
+ * @remarks
464
+ * Used by {@link flow.waitFor} and other time-based functions to properly
465
+ * support durations shorter than one frame.
466
+ */
467
+ readonly time: SimpleSignal<number, void>;
468
+ /**
469
+ * The fixed time of this thread.
470
+ *
471
+ * @remarks
472
+ * Fixed time is a multiple of the frame duration. It can be used to account
473
+ * for the difference between this thread's {@link time} and the time of the
474
+ * current animation frame.
475
+ */
476
+ get fixed(): number;
477
+ /**
478
+ * Check if this thread or any of its ancestors has been canceled.
479
+ */
480
+ get canceled(): boolean;
481
+ get paused(): boolean;
482
+ get root(): Thread;
483
+ parent: Thread | null;
484
+ private isCanceled;
485
+ private isPaused;
486
+ private fixedTime;
487
+ private queue;
488
+ constructor(
489
+ /**
490
+ * The generator wrapped by this thread.
491
+ */
492
+
493
+ runner: ThreadGenerator & {
494
+ task?: Thread;
495
+ });
496
+ /**
497
+ * Progress the wrapped generator once.
498
+ */
499
+ next(): IteratorYieldResult<void | ThreadGenerator | Promise<any> | Promisable<any>> | IteratorReturnResult<void> | {
500
+ value: null;
501
+ done: boolean;
502
+ };
503
+ /**
504
+ * Prepare the thread for the next update cycle.
505
+ *
506
+ * @param dt - The delta time of the next cycle.
507
+ */
508
+ update(dt: number): void;
509
+ spawn(child: ThreadGenerator | (() => ThreadGenerator)): ThreadGenerator;
510
+ add(child: Thread): void;
511
+ drain(callback: (task: ThreadGenerator) => void): void;
512
+ cancel(): void;
513
+ pause(value: boolean): void;
514
+ runDeferred(): void;
515
+ }
516
+ //#endregion
517
+ //#region src/threading/ThreadGenerator.d.ts
518
+ interface Promisable<T> {
519
+ toPromise(): Promise<T>;
520
+ }
521
+ declare function isPromisable(value: any): value is Promisable<any>;
522
+ /**
523
+ * The main generator type produced by all generator functions in Canvas Commons.
524
+ *
525
+ * @example
526
+ * Yielded values can be used to control the flow of animation:
527
+ *
528
+ * Progress to the next frame:
529
+ * ```ts
530
+ * yield;
531
+ * ```
532
+ *
533
+ * Run another generator synchronously:
534
+ * ```ts
535
+ * yield* generatorFunction();
536
+ * ```
537
+ *
538
+ * Run another generator concurrently:
539
+ * ```ts
540
+ * const task = yield generatorFunction();
541
+ * ```
542
+ *
543
+ * Await a Promise:
544
+ * ```ts
545
+ * const result = yield asyncFunction();
546
+ * ```
547
+ */
548
+ type ThreadGenerator = Generator<ThreadGenerator | Promise<any> | Promisable<any> | void, void, Thread | any>;
549
+ /**
550
+ * Check if the given value is a {@link ThreadGenerator}.
551
+ *
552
+ * @param value - A possible thread {@link ThreadGenerator}.
553
+ */
554
+ declare function isThreadGenerator(value: unknown): value is ThreadGenerator;
555
+ //#endregion
556
+ //#region src/threading/cancel.d.ts
557
+ /**
558
+ * Cancel all listed tasks.
559
+ *
560
+ * Example:
561
+ * ```ts
562
+ * const task = yield generatorFunction();
563
+ *
564
+ * // do something concurrently
565
+ *
566
+ * yield* cancel(task);
567
+ * ```
568
+ *
569
+ * @param tasks - A list of tasks to cancel.
570
+ */
571
+ declare function cancel(...tasks: ThreadGenerator[]): void;
572
+ //#endregion
573
+ //#region src/threading/join.d.ts
574
+ /**
575
+ * Pause the current generator until all listed tasks are finished.
576
+ *
577
+ * @example
578
+ * ```ts
579
+ * const task = yield generatorFunction();
580
+ *
581
+ * // do something concurrently
582
+ *
583
+ * yield* join(task);
584
+ * ```
585
+ *
586
+ * @param tasks - A list of tasks to join.
587
+ */
588
+ declare function join(...tasks: ThreadGenerator[]): ThreadGenerator;
589
+ /**
590
+ * Pause the current generator until listed tasks are finished.
591
+ *
592
+ * @example
593
+ * ```ts
594
+ * const taskA = yield generatorFunctionA();
595
+ * const taskB = yield generatorFunctionB();
596
+ *
597
+ * // do something concurrently
598
+ *
599
+ * // await any of the tasks
600
+ * yield* join(false, taskA, taskB);
601
+ * ```
602
+ *
603
+ * @param all - Whether we should wait for all tasks or for at least one.
604
+ * @param tasks - A list of tasks to join.
605
+ */
606
+ declare function join(all: boolean, ...tasks: ThreadGenerator[]): ThreadGenerator;
607
+ //#endregion
608
+ //#region src/threading/names.d.ts
609
+ declare function setTaskName(task: Generator, source: Generator | string): void;
610
+ declare function getTaskName(task: Generator): string;
611
+ //#endregion
612
+ //#region src/threading/spawn.d.ts
613
+ /**
614
+ * Run the given task concurrently.
615
+ *
616
+ * @example
617
+ * Using an existing task:
618
+ * ```ts
619
+ * spawn(rect().opacity(1, 1));
620
+ * ```
621
+ * Using a generator function:
622
+ * ```ts
623
+ * spawn(function* () {
624
+ * yield* rect().opacity(1, 1);
625
+ * yield* waitFor('click');
626
+ * yield* rect().opacity(0, 1);
627
+ * });
628
+ * ```
629
+ * Await the spawned task:
630
+ * ```ts
631
+ * const task = spawn(rect().opacity(1, 1));
632
+ * // do some other things
633
+ * yield* join(task); // await the task
634
+ * ```
635
+ *
636
+ * @param task - Either a generator function or a task to run.
637
+ */
638
+ declare function spawn(task: ThreadGenerator | (() => ThreadGenerator)): ThreadGenerator;
639
+ //#endregion
640
+ //#region src/threading/threads.d.ts
641
+ /**
642
+ * Check if the given value is a [Promise][promise].
643
+ *
644
+ * @param value - A possible [Promise][promise].
645
+ *
646
+ * [promise]: https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/promise
647
+ */
648
+ declare function isPromise(value: any): value is Promise<any>;
649
+ /**
650
+ * A generator function or a normal function that returns a generator.
651
+ */
652
+ interface ThreadsFactory {
653
+ (): ThreadGenerator;
654
+ }
655
+ interface ThreadsCallback {
656
+ (root: Thread): void;
657
+ }
658
+ /**
659
+ * Create a context in which generators can be run concurrently.
660
+ *
661
+ * @remarks
662
+ * From the perspective of the external generator, `threads` is executed
663
+ * synchronously. By default, each scene generator is wrapped in its own
664
+ * `threads` generator.
665
+ *
666
+ * @example
667
+ * ```ts
668
+ * // first
669
+ *
670
+ * yield* threads(function* () {
671
+ * const task = yield generatorFunction();
672
+ * // second
673
+ * }); // <- `task` will be terminated here because the scope
674
+ * // of this `threads` generator has ended
675
+ *
676
+ * // third
677
+ * ```
678
+ *
679
+ * @param factory - A function that returns the generator to run.
680
+ * @param callback - Called whenever threads are created, canceled or finished.
681
+ * Used for debugging purposes.
682
+ */
683
+ declare function threads(factory: ThreadsFactory, callback?: ThreadsCallback): ThreadGenerator;
684
+ //#endregion
685
+ //#region src/tweening/spring.d.ts
686
+ type ProgressFunction = (value: number, time: number) => void;
687
+ declare function spring(spring: Spring | null, from: number, to: number, settleTolerance: number, onProgress: ProgressFunction, onEnd?: ProgressFunction): ThreadGenerator;
688
+ declare function spring(spring: Spring | null, from: number, to: number, onProgress: ProgressFunction, onEnd?: ProgressFunction): ThreadGenerator;
689
+ interface Spring {
690
+ mass: number;
691
+ stiffness: number;
692
+ damping: number;
693
+ initialVelocity?: number;
694
+ }
695
+ declare function makeSpring(mass: number, stiffness: number, damping: number, initialVelocity?: number): Spring;
696
+ declare const BeatSpring: Spring;
697
+ declare const PlopSpring: Spring;
698
+ declare const BounceSpring: Spring;
699
+ declare const SwingSpring: Spring;
700
+ declare const JumpSpring: Spring;
701
+ declare const StrikeSpring: Spring;
702
+ declare const SmoothSpring: Spring;
703
+ //#endregion
704
+ //#region src/tweening/timingFunctions.d.ts
705
+ interface TimingFunction {
706
+ (value: number, from?: number, to?: number): number;
707
+ }
708
+ declare function sin(value: number, from?: number, to?: number): number;
709
+ declare function easeInSine(value: number, from?: number, to?: number): number;
710
+ declare function easeOutSine(value: number, from?: number, to?: number): number;
711
+ declare function easeInOutSine(value: number, from?: number, to?: number): number;
712
+ declare function easeInQuad(value: number, from?: number, to?: number): number;
713
+ declare function easeOutQuad(value: number, from?: number, to?: number): number;
714
+ declare function easeInOutQuad(value: number, from?: number, to?: number): number;
715
+ declare function easeInCubic(value: number, from?: number, to?: number): number;
716
+ declare function easeOutCubic(value: number, from?: number, to?: number): number;
717
+ declare function easeInOutCubic(value: number, from?: number, to?: number): number;
718
+ declare function easeInQuart(value: number, from?: number, to?: number): number;
719
+ declare function easeOutQuart(value: number, from?: number, to?: number): number;
720
+ declare function easeInOutQuart(value: number, from?: number, to?: number): number;
721
+ declare function easeInQuint(value: number, from?: number, to?: number): number;
722
+ declare function easeOutQuint(value: number, from?: number, to?: number): number;
723
+ declare function easeInOutQuint(value: number, from?: number, to?: number): number;
724
+ declare function easeInExpo(value: number, from?: number, to?: number): number;
725
+ declare function easeOutExpo(value: number, from?: number, to?: number): number;
726
+ declare function easeInOutExpo(value: number, from?: number, to?: number): number;
727
+ declare function easeInCirc(value: number, from?: number, to?: number): number;
728
+ declare function easeOutCirc(value: number, from?: number, to?: number): number;
729
+ declare function easeInOutCirc(value: number, from?: number, to?: number): number;
730
+ declare function createEaseInBack(s?: number): TimingFunction;
731
+ declare function createEaseOutBack(s?: number): TimingFunction;
732
+ declare function createEaseInOutBack(s?: number, v?: number): TimingFunction;
733
+ declare function createEaseInElastic(s?: number): TimingFunction;
734
+ declare function createEaseOutElastic(s?: number): TimingFunction;
735
+ declare function createEaseInOutElastic(s?: number): TimingFunction;
736
+ declare function createEaseInBounce(n?: number, d?: number): TimingFunction;
737
+ declare function createEaseOutBounce(n?: number, d?: number): TimingFunction;
738
+ declare function createEaseInOutBounce(n?: number, d?: number): TimingFunction;
739
+ declare function linear(value: number, from?: number, to?: number): number;
740
+ declare function cos(value: number, from?: number, to?: number): number;
741
+ declare const easeInBack: TimingFunction;
742
+ declare const easeOutBack: TimingFunction;
743
+ declare const easeInOutBack: TimingFunction;
744
+ declare const easeInBounce: TimingFunction;
745
+ declare const easeOutBounce: TimingFunction;
746
+ declare const easeInOutBounce: TimingFunction;
747
+ declare const easeInElastic: TimingFunction;
748
+ declare const easeOutElastic: TimingFunction;
749
+ declare const easeInOutElastic: TimingFunction;
750
+ //#endregion
751
+ //#region src/tweening/tween.d.ts
752
+ declare function tween(seconds: number, onProgress: (value: number, time: number) => void, onEnd?: (value: number, time: number) => void): ThreadGenerator;
753
+ //#endregion
754
+ //#region src/signals/DependencyContext.d.ts
755
+ interface PromiseHandle<T> {
756
+ promise: Promise<T>;
757
+ value: T;
758
+ stack?: string;
759
+ owner?: any;
760
+ }
761
+ declare class DependencyContext<TOwner = void> implements Promisable<DependencyContext<TOwner>> {
762
+ protected owner: TOwner;
763
+ protected static collectionSet: Set<DependencyContext<any>>;
764
+ protected static collectionStack: DependencyContext<any>[];
765
+ protected static promises: PromiseHandle<any>[];
766
+ static collectPromise<T>(promise: Promise<T>): PromiseHandle<T | null>;
767
+ static collectPromise<T>(promise: Promise<T>, initialValue: T): PromiseHandle<T>;
768
+ static hasPromises(): boolean;
769
+ static consumePromises(): Promise<PromiseHandle<any>[]>;
770
+ protected readonly invokable: any;
771
+ protected dependencies: Set<Subscribable<void, EventHandler<void>>>;
772
+ protected event: FlagDispatcher;
773
+ protected markDirty: () => void;
774
+ constructor(owner: TOwner);
775
+ protected invoke(): void;
776
+ protected startCollecting(): void;
777
+ protected finishCollecting(): void;
778
+ protected clearDependencies(): void;
779
+ protected collect(): void;
780
+ dispose(): void;
781
+ toPromise(): Promise<this>;
782
+ }
783
+ //#endregion
784
+ //#region src/signals/symbols.d.ts
785
+ declare const DEFAULT: unique symbol;
786
+ //#endregion
787
+ //#region src/signals/types.d.ts
788
+ type SignalValue<TValue> = TValue | (() => TValue);
789
+ type SignalGenerator<TSetterValue, TValue extends TSetterValue> = ThreadGenerator & {
790
+ /**
791
+ * Tween to the specified value.
792
+ */
793
+ to: SignalTween<TSetterValue, TValue>;
794
+ /**
795
+ * Tween back to the original value.
796
+ *
797
+ * @param time - The duration of the tween.
798
+ * @param timingFunction - The timing function of the tween.
799
+ * @param interpolationFunction - The interpolation function of the tween.
800
+ */
801
+ back: (time: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<TValue>) => SignalGenerator<TSetterValue, TValue>;
802
+ /**
803
+ * Wait for the specified duration.
804
+ *
805
+ * @param duration - The duration to wait.
806
+ */
807
+ wait: (duration: number) => SignalGenerator<TSetterValue, TValue>;
808
+ /**
809
+ * Run the given task.
810
+ *
811
+ * @param task - The generator to run.
812
+ */
813
+ run: (task: ThreadGenerator) => SignalGenerator<TSetterValue, TValue>;
814
+ /**
815
+ * Invoke the given callback.
816
+ *
817
+ * @param callback - The callback to invoke.
818
+ */
819
+ do: (callback: () => void) => SignalGenerator<TSetterValue, TValue>;
820
+ };
821
+ interface SignalSetter<TValue, TOwner = void> {
822
+ (value: SignalValue<TValue> | typeof DEFAULT): TOwner;
823
+ }
824
+ interface SignalGetter<TValue> {
825
+ (): TValue;
826
+ }
827
+ interface SignalTween<TSetterValue, TValue extends TSetterValue> {
828
+ (value: SignalValue<TSetterValue> | typeof DEFAULT, time: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<TValue>): SignalGenerator<TSetterValue, TValue>;
829
+ }
830
+ interface SignalExtensions<TSetterValue, TValue extends TSetterValue> {
831
+ getter: SignalGetter<TValue>;
832
+ setter: SignalSetter<TSetterValue>;
833
+ tweener(value: SignalValue<TSetterValue>, time: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<TValue>): ThreadGenerator;
834
+ }
835
+ //#endregion
836
+ //#region src/signals/SignalContext.d.ts
837
+ type SimpleSignal<TValue, TReturn = void> = Signal<TValue, TValue, TReturn>;
838
+ interface Signal<TSetterValue, TValue extends TSetterValue, TOwner = void, TContext = SignalContext<TSetterValue, TValue, TOwner>> extends SignalSetter<TSetterValue, TOwner>, SignalGetter<TValue>, SignalTween<TSetterValue, TValue> {
839
+ /**
840
+ * {@inheritDoc SignalContext.reset}
841
+ */
842
+ reset(): TOwner;
843
+ /**
844
+ * {@inheritDoc SignalContext.save}
845
+ */
846
+ save(): TOwner;
847
+ /**
848
+ * {@inheritDoc SignalContext.isInitial}
849
+ */
850
+ isInitial(): boolean;
851
+ context: TContext;
852
+ }
853
+ declare class SignalContext<TSetterValue, TValue extends TSetterValue = TSetterValue, TOwner = void> extends DependencyContext<TOwner> {
854
+ private initial;
855
+ private readonly interpolation;
856
+ protected parser: (value: TSetterValue) => TValue;
857
+ protected extensions: SignalExtensions<TSetterValue, TValue>;
858
+ protected current: SignalValue<TSetterValue> | undefined;
859
+ protected last: TValue | undefined;
860
+ protected tweening: boolean;
861
+ constructor(initial: SignalValue<TSetterValue> | undefined, interpolation: InterpolationFunction<TValue>, owner?: TOwner, parser?: (value: TSetterValue) => TValue, extensions?: Partial<SignalExtensions<TSetterValue, TValue>>);
862
+ toSignal(): Signal<TSetterValue, TValue, TOwner>;
863
+ parse(value: TSetterValue): TValue;
864
+ set(value: SignalValue<TSetterValue> | typeof DEFAULT): TOwner;
865
+ setter(value: SignalValue<TSetterValue> | typeof DEFAULT): TOwner;
866
+ get(): TValue;
867
+ getter(): TValue;
868
+ protected invoke(value?: SignalValue<TSetterValue> | typeof DEFAULT, duration?: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<TValue>): TValue | TOwner | SignalGenerator<TSetterValue, TValue>;
869
+ protected createQueue(defaultTimingFunction: TimingFunction, defaultInterpolationFunction: InterpolationFunction<TValue>): SignalGenerator<TSetterValue, TValue>;
870
+ protected tween(value: SignalValue<TSetterValue> | typeof DEFAULT, duration: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<TValue>): ThreadGenerator;
871
+ tweener(value: SignalValue<TSetterValue>, duration: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<TValue>): ThreadGenerator;
872
+ dispose(): void;
873
+ /**
874
+ * Reset the signal to its initial value (if one has been set).
875
+ *
876
+ * @example
877
+ * ```ts
878
+ * const signal = createSignal(7);
879
+ *
880
+ * signal.reset();
881
+ * // same as:
882
+ * signal(7);
883
+ * ```
884
+ */
885
+ reset(): TOwner;
886
+ /**
887
+ * Compute the current value of the signal and immediately set it.
888
+ *
889
+ * @remarks
890
+ * This method can be used to stop the signal from updating while keeping its
891
+ * current value.
892
+ *
893
+ * @example
894
+ * ```ts
895
+ * signal.save();
896
+ * // same as:
897
+ * signal(signal());
898
+ * ```
899
+ */
900
+ save(): TOwner;
901
+ /**
902
+ * Check if the signal is currently using its initial value.
903
+ *
904
+ * @example
905
+ * ```ts
906
+ *
907
+ * const signal = createSignal(0);
908
+ * signal.isInitial(); // true
909
+ *
910
+ * signal(5);
911
+ * signal.isInitial(); // false
912
+ *
913
+ * signal(DEFAULT);
914
+ * signal.isInitial(); // true
915
+ * ```
916
+ */
917
+ isInitial(): boolean;
918
+ /**
919
+ * Get the initial value of this signal.
920
+ */
921
+ getInitial(): SignalValue<TSetterValue> | undefined;
922
+ /**
923
+ * Get the raw value of this signal.
924
+ *
925
+ * @remarks
926
+ * If the signal was provided with a factory function, the function itself
927
+ * will be returned, without invoking it.
928
+ *
929
+ * This method can be used to create copies of signals.
930
+ *
931
+ * @example
932
+ * ```ts
933
+ * const a = createSignal(2);
934
+ * const b = createSignal(() => a);
935
+ * // b() == 2
936
+ *
937
+ * const bClone = createSignal(b.raw());
938
+ * // bClone() == 2
939
+ *
940
+ * a(4);
941
+ * // b() == 4
942
+ * // bClone() == 4
943
+ * ```
944
+ */
945
+ raw(): SignalValue<TSetterValue> | undefined;
946
+ /**
947
+ * Is the signal undergoing a tween?
948
+ */
949
+ isTweening(): boolean;
950
+ }
951
+ //#endregion
952
+ //#region src/signals/CompoundSignalContext.d.ts
953
+ type CompoundSignal<TSetterValue, TValue extends TSetterValue, TKeys extends keyof TValue = keyof TValue, TOwner = void, TContext = CompoundSignalContext<TSetterValue, TValue, TKeys, TOwner>> = Signal<TSetterValue, TValue, TOwner, TContext> & { [K in TKeys]: Signal<TValue[K], TValue[K], TOwner extends void ? CompoundSignal<TSetterValue, TValue, TKeys, TOwner, TContext> : TOwner> };
954
+ declare class CompoundSignalContext<TSetterValue, TValue extends TSetterValue, TKeys extends keyof TValue = keyof TValue, TOwner = void> extends SignalContext<TSetterValue, TValue, TOwner> {
955
+ private readonly entries;
956
+ readonly signals: [keyof TValue, Signal<any, any, TOwner>][];
957
+ constructor(entries: (TKeys | [keyof TValue, Signal<any, any, TOwner>])[], parser: (value: TSetterValue) => TValue, initial: SignalValue<TSetterValue>, interpolation: InterpolationFunction<TValue>, owner?: TOwner, extensions?: Partial<SignalExtensions<TSetterValue, TValue>>);
958
+ toSignal(): CompoundSignal<TSetterValue, TValue, TKeys, TOwner>;
959
+ parse(value: TSetterValue): TValue;
960
+ getter(): TValue;
961
+ setter(value: SignalValue<TValue>): TOwner;
962
+ reset(): TOwner;
963
+ save(): TOwner;
964
+ isInitial(): boolean;
965
+ raw(): TSetterValue;
966
+ }
967
+ //#endregion
968
+ //#region src/signals/ComputedContext.d.ts
969
+ interface Computed<TValue> {
970
+ (...args: any[]): TValue;
971
+ context: ComputedContext<TValue>;
972
+ }
973
+ declare class ComputedContext<TValue> extends DependencyContext<any> {
974
+ private readonly factory;
975
+ private last;
976
+ constructor(factory: (...args: any[]) => TValue, owner?: any);
977
+ toSignal(): Computed<TValue>;
978
+ dispose(): void;
979
+ protected invoke(...args: any[]): TValue;
980
+ }
981
+ //#endregion
982
+ //#region src/signals/createComputed.d.ts
983
+ declare function createComputed<TValue>(factory: (...args: any[]) => TValue, owner?: any): Computed<TValue>;
984
+ //#endregion
985
+ //#region src/signals/createComputedAsync.d.ts
986
+ declare function createComputedAsync<T>(factory: () => Promise<T>): Computed<T | null>;
987
+ declare function createComputedAsync<T>(factory: () => Promise<T>, initial: T): Computed<T>;
988
+ //#endregion
989
+ //#region src/signals/createDeferredEffect.d.ts
990
+ /**
991
+ * Invoke the callback at the end of each frame if any of its dependencies
992
+ * changed.
993
+ *
994
+ * @param callback - The callback to invoke.
995
+ */
996
+ declare function createDeferredEffect(callback: () => void): () => void;
997
+ //#endregion
998
+ //#region src/signals/createEffect.d.ts
999
+ /**
1000
+ * Invoke the callback immediately after any of its dependencies change.
1001
+ *
1002
+ * @param callback - The callback to invoke.
1003
+ */
1004
+ declare function createEffect(callback: () => void): () => void;
1005
+ //#endregion
1006
+ //#region src/signals/createSignal.d.ts
1007
+ declare function createSignal<TValue, TOwner = void>(initial?: SignalValue<TValue>, interpolation?: InterpolationFunction<TValue>, owner?: TOwner): SimpleSignal<TValue, TOwner>;
1008
+ //#endregion
1009
+ //#region src/signals/DeferredEffectContext.d.ts
1010
+ declare class DeferredEffectContext extends DependencyContext {
1011
+ private readonly callback;
1012
+ private readonly unsubscribe;
1013
+ constructor(callback: () => void);
1014
+ private update;
1015
+ dispose(): void;
1016
+ }
1017
+ //#endregion
1018
+ //#region src/signals/EffectContext.d.ts
1019
+ declare class EffectContext extends DependencyContext {
1020
+ private readonly callback;
1021
+ constructor(callback: () => void);
1022
+ private update;
1023
+ }
1024
+ //#endregion
1025
+ //#region src/signals/utils.d.ts
1026
+ declare function isReactive<T>(value: SignalValue<T>): value is () => T;
1027
+ declare function modify<TFrom, TTo>(value: SignalValue<TFrom>, modification: (value: TFrom) => TTo): SignalValue<TTo>;
1028
+ declare function unwrap<T>(value: SignalValue<T>): T;
1029
+ //#endregion
1030
+ //#region src/signals/Vector2SignalContext.d.ts
1031
+ interface Vector2Edit<TOwner> {
1032
+ (callback: (current: Vector2) => SignalValue<PossibleVector2>): TOwner;
1033
+ (callback: (current: Vector2) => SignalValue<PossibleVector2>, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1034
+ }
1035
+ interface Vector2Operation<TOwner> {
1036
+ (value: PossibleVector2): TOwner;
1037
+ (value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1038
+ }
1039
+ interface Vector2SignalHelpers<TOwner> {
1040
+ edit: Vector2Edit<TOwner>;
1041
+ mul: Vector2Operation<TOwner>;
1042
+ div: Vector2Operation<TOwner>;
1043
+ add: Vector2Operation<TOwner>;
1044
+ sub: Vector2Operation<TOwner>;
1045
+ dot: Vector2Operation<TOwner>;
1046
+ cross: Vector2Operation<TOwner>;
1047
+ mod: Vector2Operation<TOwner>;
1048
+ }
1049
+ type Vector2Signal<TOwner = void, TContext = Vector2SignalContext<TOwner>> = CompoundSignal<PossibleVector2, Vector2, 'x' | 'y', TOwner, TContext> & Vector2SignalHelpers<TOwner>;
1050
+ declare class Vector2SignalContext<TOwner = void> extends CompoundSignalContext<PossibleVector2, Vector2, 'x' | 'y', TOwner> implements Vector2SignalHelpers<TOwner> {
1051
+ constructor(entries: ('x' | 'y' | [keyof Vector2, Signal<any, any, TOwner>])[], parser: (value: PossibleVector2) => Vector2, initial: SignalValue<PossibleVector2>, interpolation: InterpolationFunction<Vector2>, owner?: TOwner, extensions?: Partial<SignalExtensions<PossibleVector2, Vector2>>);
1052
+ toSignal(): Vector2Signal<TOwner>;
1053
+ edit(callback: (current: Vector2) => SignalValue<PossibleVector2>): TOwner;
1054
+ edit(callback: (current: Vector2) => SignalValue<PossibleVector2>, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1055
+ mul(value: PossibleVector2): TOwner;
1056
+ mul(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1057
+ div(value: PossibleVector2): TOwner;
1058
+ div(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1059
+ add(value: PossibleVector2): TOwner;
1060
+ add(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1061
+ sub(value: PossibleVector2): TOwner;
1062
+ sub(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1063
+ dot(value: PossibleVector2): TOwner;
1064
+ dot(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1065
+ cross(value: PossibleVector2): TOwner;
1066
+ cross(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1067
+ mod(value: PossibleVector2): TOwner;
1068
+ mod(value: PossibleVector2, duration: number, timingFunction?: TimingFunction, interpolationFunction?: InterpolationFunction<Vector2>): SignalGenerator<PossibleVector2, Vector2>;
1069
+ }
1070
+ //#endregion
1071
+ //#region src/types/Type.d.ts
1072
+ declare const EPSILON = 0.000001;
1073
+ interface Type {
1074
+ toSymbol(): symbol;
1075
+ }
1076
+ interface WebGLConvertible {
1077
+ toUniform(gl: WebGL2RenderingContext, location: WebGLUniformLocation): void;
1078
+ }
1079
+ declare function isType(value: any): value is Type;
1080
+ //#endregion
1081
+ //#region src/types/Origin.d.ts
1082
+ declare enum Center {
1083
+ Vertical = 1,
1084
+ Horizontal = 2
1085
+ }
1086
+ declare enum Direction {
1087
+ Top = 4,
1088
+ Bottom = 8,
1089
+ Left = 16,
1090
+ Right = 32
1091
+ }
1092
+ declare enum Origin {
1093
+ Middle = 3,
1094
+ Top = 5,
1095
+ Bottom = 9,
1096
+ Left = 18,
1097
+ Right = 34,
1098
+ TopLeft = 20,
1099
+ TopRight = 36,
1100
+ BottomLeft = 24,
1101
+ BottomRight = 40
1102
+ }
1103
+ declare function flipOrigin(origin: Direction, axis?: Center): Direction;
1104
+ declare function flipOrigin(origin: Origin, axis?: Center): Origin;
1105
+ /**
1106
+ * Convert the given origin to a vector representing its offset.
1107
+ *
1108
+ * @example
1109
+ * ```ts
1110
+ * const bottomRight = originToOffset(Origin.TopRight);
1111
+ * // bottomRight = {x: 1, y: -1}
1112
+ * ```
1113
+ *
1114
+ * @param origin - The origin to convert.
1115
+ */
1116
+ declare function originToOffset(origin: Origin | Direction): Vector2;
1117
+ //#endregion
1118
+ //#region src/types/Vector.d.ts
1119
+ type SerializedVector2<T = number> = {
1120
+ x: T;
1121
+ y: T;
1122
+ };
1123
+ type PossibleVector2<T = number> = SerializedVector2<T> | {
1124
+ width: T;
1125
+ height: T;
1126
+ } | T | [T, T] | undefined;
1127
+ type SimpleVector2Signal<T> = Signal<PossibleVector2, Vector2, T>;
1128
+ /**
1129
+ * Represents a two-dimensional vector.
1130
+ */
1131
+ declare class Vector2 implements Type, WebGLConvertible {
1132
+ static readonly symbol: unique symbol;
1133
+ static readonly zero: Vector2;
1134
+ static readonly one: Vector2;
1135
+ static readonly right: Vector2;
1136
+ static readonly left: Vector2;
1137
+ static readonly up: Vector2;
1138
+ static readonly down: Vector2;
1139
+ /**
1140
+ * A constant equal to `Vector2(0, -1)`
1141
+ */
1142
+ static readonly top: Vector2;
1143
+ /**
1144
+ * A constant equal to `Vector2(0, 1)`
1145
+ */
1146
+ static readonly bottom: Vector2;
1147
+ /**
1148
+ * A constant equal to `Vector2(-1, -1)`
1149
+ */
1150
+ static readonly topLeft: Vector2;
1151
+ /**
1152
+ * A constant equal to `Vector2(1, -1)`
1153
+ */
1154
+ static readonly topRight: Vector2;
1155
+ /**
1156
+ * A constant equal to `Vector2(-1, 1)`
1157
+ */
1158
+ static readonly bottomLeft: Vector2;
1159
+ /**
1160
+ * A constant equal to `Vector2(1, 1)`
1161
+ */
1162
+ static readonly bottomRight: Vector2;
1163
+ x: number;
1164
+ y: number;
1165
+ static createSignal(initial?: SignalValue<PossibleVector2>, interpolation?: InterpolationFunction<Vector2>, owner?: any): Vector2Signal<void>;
1166
+ static lerp(from: Vector2, to: Vector2, value: number | Vector2): Vector2;
1167
+ static arcLerp(from: Vector2, to: Vector2, value: number, reverse?: boolean, ratio?: number): Vector2;
1168
+ static createArcLerp(reverse?: boolean, ratio?: number): (from: Vector2, to: Vector2, value: number) => Vector2;
1169
+ /**
1170
+ * Interpolates between two vectors on the polar plane by interpolating
1171
+ * the angles and magnitudes of the vectors individually.
1172
+ *
1173
+ * @param from - The starting vector.
1174
+ * @param to - The target vector.
1175
+ * @param value - The t-value of the interpolation.
1176
+ * @param counterclockwise - Whether the vector should get rotated
1177
+ * counterclockwise. Defaults to `false`.
1178
+ * @param origin - The center of rotation. Defaults to the origin.
1179
+ *
1180
+ * @remarks
1181
+ * This function is useful when used in conjunction with {@link rotate} to
1182
+ * animate an object's position on a circular arc (see examples).
1183
+ *
1184
+ * @example
1185
+ * Animating an object in a circle around the origin
1186
+ * ```tsx
1187
+ * circle().position(
1188
+ * circle().position().rotate(180),
1189
+ * 1,
1190
+ * easeInOutCubic,
1191
+ * Vector2.polarLerp
1192
+ * );
1193
+ * ```
1194
+ * @example
1195
+ * Rotating an object around the point `[-200, 100]`
1196
+ * ```ts
1197
+ * circle().position(
1198
+ * circle().position().rotate(180, [-200, 100]),
1199
+ * 1,
1200
+ * easeInOutCubic,
1201
+ * Vector2.createPolarLerp(false, [-200, 100]),
1202
+ * );
1203
+ * ```
1204
+ * @example
1205
+ * Rotating an object counterclockwise around the origin
1206
+ * ```ts
1207
+ * circle().position(
1208
+ * circle().position().rotate(180),
1209
+ * 1,
1210
+ * easeInOutCubic,
1211
+ * Vector2.createPolarLerp(true),
1212
+ * );
1213
+ * ```
1214
+ */
1215
+ static polarLerp(from: Vector2, to: Vector2, value: number, counterclockwise?: boolean, origin?: Vector2): Vector2;
1216
+ /**
1217
+ * Helper function to create a {@link Vector2.polarLerp} interpolation
1218
+ * function with additional parameters.
1219
+ *
1220
+ * @param counterclockwise - Whether the point should get rotated
1221
+ * counterclockwise.
1222
+ * @param center - The center of rotation. Defaults to the origin.
1223
+ */
1224
+ static createPolarLerp(counterclockwise?: boolean, center?: PossibleVector2): (from: Vector2, to: Vector2, value: number) => Vector2;
1225
+ static fromOrigin(origin: Origin | Direction): Vector2;
1226
+ static fromScalar(value: number): Vector2;
1227
+ static fromRadians(radians: number): Vector2;
1228
+ static fromDegrees(degrees: number): Vector2;
1229
+ /**
1230
+ * Return the angle in radians between the vector described by x and y and the
1231
+ * positive x-axis.
1232
+ *
1233
+ * @param x - The x component of the vector.
1234
+ * @param y - The y component of the vector.
1235
+ */
1236
+ static radians(x: number, y: number): number;
1237
+ /**
1238
+ * Return the angle in degrees between the vector described by x and y and the
1239
+ * positive x-axis.
1240
+ *
1241
+ * @param x - The x component of the vector.
1242
+ * @param y - The y component of the vector.
1243
+ *
1244
+ * @remarks
1245
+ * The returned angle will be between -180 and 180 degrees.
1246
+ */
1247
+ static degrees(x: number, y: number): number;
1248
+ static magnitude(x: number, y: number): number;
1249
+ static squaredMagnitude(x: number, y: number): number;
1250
+ static angleBetween(u: Vector2, v: Vector2): number;
1251
+ get width(): number;
1252
+ set width(value: number);
1253
+ get height(): number;
1254
+ set height(value: number);
1255
+ get magnitude(): number;
1256
+ get squaredMagnitude(): number;
1257
+ get normalized(): Vector2;
1258
+ get safe(): Vector2;
1259
+ get flipped(): Vector2;
1260
+ get floored(): Vector2;
1261
+ get rounded(): Vector2;
1262
+ get ceiled(): Vector2;
1263
+ get perpendicular(): Vector2;
1264
+ /**
1265
+ * Return the angle in radians between the vector and the positive x-axis.
1266
+ */
1267
+ get radians(): number;
1268
+ /**
1269
+ * Return the angle in degrees between the vector and the positive x-axis.
1270
+ *
1271
+ * @remarks
1272
+ * The returned angle will be between -180 and 180 degrees.
1273
+ */
1274
+ get degrees(): number;
1275
+ get ctg(): number;
1276
+ constructor();
1277
+ constructor(from: PossibleVector2);
1278
+ constructor(x: number, y: number);
1279
+ lerp(to: Vector2, value: Vector2 | number): Vector2;
1280
+ getOriginOffset(origin: Origin | Direction): Vector2;
1281
+ scale(value: number): Vector2;
1282
+ transformAsPoint(matrix: PossibleMatrix2D): Vector2;
1283
+ transform(matrix: PossibleMatrix2D): Vector2;
1284
+ mul(possibleVector: PossibleVector2): Vector2;
1285
+ div(possibleVector: PossibleVector2): Vector2;
1286
+ add(possibleVector: PossibleVector2): Vector2;
1287
+ sub(possibleVector: PossibleVector2): Vector2;
1288
+ dot(possibleVector: PossibleVector2): number;
1289
+ cross(possibleVector: PossibleVector2): number;
1290
+ mod(possibleVector: PossibleVector2): Vector2;
1291
+ /**
1292
+ * Rotate the vector around a point by the provided angle.
1293
+ *
1294
+ * @param angle - The angle by which to rotate in degrees.
1295
+ * @param center - The center of rotation. Defaults to the origin.
1296
+ */
1297
+ rotate(angle: number, center?: PossibleVector2): Vector2;
1298
+ addX(value: number): Vector2;
1299
+ addY(value: number): Vector2;
1300
+ /**
1301
+ * Transform the components of the vector.
1302
+ *
1303
+ * @example
1304
+ * Raise the components to the power of 2.
1305
+ * ```ts
1306
+ * const vector = new Vector2(2, 3);
1307
+ * const result = vector.transform(value => value ** 2);
1308
+ * ```
1309
+ *
1310
+ * @param callback - A callback to apply to each component.
1311
+ */
1312
+ map(callback: (value: number, index: number) => number): Vector2;
1313
+ toSymbol(): symbol;
1314
+ toString(): string;
1315
+ toArray(): [number, number];
1316
+ toUniform(gl: WebGL2RenderingContext, location: WebGLUniformLocation): void;
1317
+ serialize(): SerializedVector2;
1318
+ /**
1319
+ * Check if two vectors are exactly equal to each other.
1320
+ *
1321
+ * @remarks
1322
+ * If you need to compensate for floating point inaccuracies, use the
1323
+ * {@link equals} method, instead.
1324
+ *
1325
+ * @param other - The vector to compare.
1326
+ */
1327
+ exactlyEquals(other: Vector2): boolean;
1328
+ /**
1329
+ * Check if two vectors are equal to each other.
1330
+ *
1331
+ * @remarks
1332
+ * This method allows passing an allowed error margin when comparing vectors
1333
+ * to compensate for floating point inaccuracies. To check if two vectors are
1334
+ * exactly equal, use the {@link exactlyEquals} method, instead.
1335
+ *
1336
+ * @param other - The vector to compare.
1337
+ * @param threshold - The allowed error threshold when comparing the vectors.
1338
+ */
1339
+ equals(other: Vector2, threshold?: number): boolean;
1340
+ [Symbol.iterator](): Generator<number, void, unknown>;
1341
+ }
1342
+ //#endregion
1343
+ //#region src/types/Matrix2D.d.ts
1344
+ type PossibleMatrix2D = Matrix2D | DOMMatrix | [number, number, number, number, number, number] | [PossibleVector2, PossibleVector2, PossibleVector2] | undefined;
1345
+ /**
1346
+ * A specialized 2x3 Matrix representing a 2D transformation.
1347
+ *
1348
+ * A Matrix2D contains six elements defined as
1349
+ * [a, b,
1350
+ * c, d,
1351
+ * tx, ty]
1352
+ *
1353
+ * This is a shortcut for a 3x3 matrix of the form
1354
+ * [a, b, 0,
1355
+ * c, d, 0
1356
+ * tx, ty, 1]
1357
+ *
1358
+ * Note that because a Matrix2D ignores the z-values of each component vectors,
1359
+ * it does not satisfy all properties of a "real" 3x3 matrix.
1360
+ *
1361
+ * - A Matrix2D has no transpose
1362
+ * - A(B + C) = AB + AC does not hold for a Matrix2D
1363
+ * - (rA)^-1 = r^-1 A^-1, r != 0 does not hold for a Matrix2D
1364
+ * - r(AB) = (rA)B = A(rB) does not hold for a Matrix2D
1365
+ */
1366
+ declare class Matrix2D implements Type, WebGLConvertible {
1367
+ static readonly symbol: unique symbol;
1368
+ readonly values: Float32Array;
1369
+ static readonly identity: Matrix2D;
1370
+ static readonly zero: Matrix2D;
1371
+ static fromRotation(angle: number): Matrix2D;
1372
+ static fromTranslation(translation: PossibleVector2): Matrix2D;
1373
+ static fromScaling(scale: PossibleVector2): Matrix2D;
1374
+ get x(): Vector2;
1375
+ get y(): Vector2;
1376
+ get scaleX(): number;
1377
+ set scaleX(value: number);
1378
+ get skewX(): number;
1379
+ set skewX(value: number);
1380
+ get scaleY(): number;
1381
+ set scaleY(value: number);
1382
+ get skewY(): number;
1383
+ set skewY(value: number);
1384
+ get translateX(): number;
1385
+ set translateX(value: number);
1386
+ get translateY(): number;
1387
+ set translateY(value: number);
1388
+ get rotation(): number;
1389
+ set rotation(angle: number);
1390
+ get translation(): Vector2;
1391
+ set translation(translation: PossibleVector2);
1392
+ get scaling(): Vector2;
1393
+ set scaling(value: PossibleVector2);
1394
+ /**
1395
+ * Get the inverse of the matrix.
1396
+ *
1397
+ * @remarks
1398
+ * If the matrix is not invertible, i.e. its determinant is `0`, this will
1399
+ * return `null`, instead.
1400
+ *
1401
+ * @example
1402
+ * ```ts
1403
+ * const matrix = new Matrix2D(
1404
+ * [1, 2],
1405
+ * [3, 4],
1406
+ * [5, 6],
1407
+ * );
1408
+ *
1409
+ * const inverse = matrix.inverse;
1410
+ * // => Matrix2D(
1411
+ * // [-2, 1],
1412
+ * // [1.5, -0.5],
1413
+ * // [1, -2],
1414
+ * // )
1415
+ * ```
1416
+ */
1417
+ get inverse(): Matrix2D | null;
1418
+ /**
1419
+ * Get the determinant of the matrix.
1420
+ */
1421
+ get determinant(): number;
1422
+ get domMatrix(): DOMMatrix;
1423
+ constructor();
1424
+ constructor(matrix: PossibleMatrix2D);
1425
+ constructor(x: PossibleVector2, y: PossibleVector2, z: PossibleVector2);
1426
+ constructor(a: number, b: number, c: number, d: number, tx: number, ty: number);
1427
+ /**
1428
+ * Get the nth component vector of the matrix. Only defined for 0, 1, and 2.
1429
+ *
1430
+ * @example
1431
+ * ```ts
1432
+ * const matrix = new Matrix2D(
1433
+ * [1, 0],
1434
+ * [0, 0],
1435
+ * [1, 0],
1436
+ * );
1437
+ *
1438
+ * const x = matrix.column(0);
1439
+ * // Vector2(1, 0)
1440
+ *
1441
+ * const y = matrix.column(1);
1442
+ * // Vector2(0, 0)
1443
+ *
1444
+ * const z = matrix.column(1);
1445
+ * // Vector2(1, 0)
1446
+ * ```
1447
+ *
1448
+ * @param index - The index of the component vector to retrieve.
1449
+ */
1450
+ column(index: number): Vector2;
1451
+ /**
1452
+ * Returns the nth row of the matrix. Only defined for 0 and 1.
1453
+ *
1454
+ * @example
1455
+ * ```ts
1456
+ * const matrix = new Matrix2D(
1457
+ * [1, 0],
1458
+ * [0, 0],
1459
+ * [1, 0],
1460
+ * );
1461
+ *
1462
+ * const firstRow = matrix.column(0);
1463
+ * // [1, 0, 1]
1464
+ *
1465
+ * const secondRow = matrix.column(1);
1466
+ * // [0, 0, 0]
1467
+ * ```
1468
+ *
1469
+ * @param index - The index of the row to retrieve.
1470
+ */
1471
+ row(index: number): [number, number, number];
1472
+ /**
1473
+ * Returns the matrix product of this matrix with the provided matrix.
1474
+ *
1475
+ * @remarks
1476
+ * This method returns a new matrix representing the result of the
1477
+ * computation. It will not modify the source matrix.
1478
+ *
1479
+ * @example
1480
+ * ```ts
1481
+ * const a = new Matrix2D(
1482
+ * [1, 2],
1483
+ * [0, 1],
1484
+ * [1, 1],
1485
+ * );
1486
+ * const b = new Matrix2D(
1487
+ * [2, 1],
1488
+ * [1, 1],
1489
+ * [1, 1],
1490
+ * );
1491
+ *
1492
+ * const result = a.mul(b);
1493
+ * // => Matrix2D(
1494
+ * // [2, 5],
1495
+ * // [1, 3],
1496
+ * // [2, 4],
1497
+ * // )
1498
+ * ```
1499
+ *
1500
+ * @param other - The matrix to multiply with
1501
+ */
1502
+ mul(other: Matrix2D): Matrix2D;
1503
+ /**
1504
+ * Rotate the matrix by the provided angle. By default, the angle is
1505
+ * provided in degrees.
1506
+ *
1507
+ * @remarks
1508
+ * This method returns a new matrix representing the result of the
1509
+ * computation. It will not modify the source matrix.
1510
+ *
1511
+ * @example
1512
+ * ```ts
1513
+ * const a = new Matrix2D(
1514
+ * [1, 2],
1515
+ * [3, 4],
1516
+ * [5, 6],
1517
+ * );
1518
+ *
1519
+ * const result = a.rotate(90);
1520
+ * // => Matrix2D(
1521
+ * // [3, 4],
1522
+ * // [-1, -2],
1523
+ * // [5, 6],
1524
+ * // )
1525
+ *
1526
+ * // Provide the angle in radians
1527
+ * const result = a.rotate(Math.PI * 0.5, true);
1528
+ * // => Matrix2D(
1529
+ * // [3, 4],
1530
+ * // [-1, -2],
1531
+ * // [5, 6],
1532
+ * // )
1533
+ * ```
1534
+ *
1535
+ * @param angle - The angle by which to rotate the matrix.
1536
+ * @param degrees - Whether the angle is provided in degrees.
1537
+ */
1538
+ rotate(angle: number, degrees?: boolean): Matrix2D;
1539
+ /**
1540
+ * Scale the x and y component vectors of the matrix.
1541
+ *
1542
+ * @remarks
1543
+ * If `vec` is provided as a vector, the x and y component vectors of the
1544
+ * matrix will be scaled by the x and y parts of the vector, respectively.
1545
+ *
1546
+ * If `vec` is provided as a scalar, the x and y component vectors will be
1547
+ * scaled uniformly by this factor.
1548
+ *
1549
+ * This method returns a new matrix representing the result of the
1550
+ * computation. It will not modify the source matrix.
1551
+ *
1552
+ * @example
1553
+ * ```ts
1554
+ * const matrix = new Matrix2D(
1555
+ * [1, 2],
1556
+ * [3, 4],
1557
+ * [5, 6],
1558
+ * );
1559
+ *
1560
+ * const result1 = matrix.scale([2, 3]);
1561
+ * // => new Matrix2D(
1562
+ * // [2, 4],
1563
+ * // [9, 12],
1564
+ * // [5, 6],
1565
+ * // )
1566
+ *
1567
+ * const result2 = matrix.scale(2);
1568
+ * // => new Matrix2D(
1569
+ * // [2, 4],
1570
+ * // [6, 8],
1571
+ * // [5, 6],
1572
+ * // )
1573
+ * ```
1574
+ *
1575
+ * @param vec - The factor by which to scale the matrix
1576
+ */
1577
+ scale(vec: PossibleVector2): Matrix2D;
1578
+ /**
1579
+ * Multiply each value of the matrix by a scalar.
1580
+ *
1581
+ * * @example
1582
+ * ```ts
1583
+ * const matrix = new Matrix2D(
1584
+ * [1, 2],
1585
+ * [3, 4],
1586
+ * [5, 6],
1587
+ * );
1588
+ *
1589
+ * const result1 = matrix.mulScalar(2);
1590
+ * // => new Matrix2D(
1591
+ * // [2, 4],
1592
+ * // [6, 8],
1593
+ * // [10, 12],
1594
+ * // )
1595
+ * ```
1596
+ *
1597
+ * @param s - The value by which to scale each term
1598
+ */
1599
+ mulScalar(s: number): Matrix2D;
1600
+ /**
1601
+ * Translate the matrix by the dimensions of the provided vector.
1602
+ *
1603
+ * @remarks
1604
+ * If `vec` is provided as a scalar, matrix will be translated uniformly
1605
+ * by this factor.
1606
+ *
1607
+ * This method returns a new matrix representing the result of the
1608
+ * computation. It will not modify the source matrix.
1609
+ *
1610
+ * @example
1611
+ * ```ts
1612
+ * const matrix = new Matrix2D(
1613
+ * [1, 2],
1614
+ * [3, 4],
1615
+ * [5, 6],
1616
+ * );
1617
+ *
1618
+ * const result1 = matrix.translate([2, 3]);
1619
+ * // => new Matrix2D(
1620
+ * // [1, 2],
1621
+ * // [3, 4],
1622
+ * // [16, 22],
1623
+ * // )
1624
+ *
1625
+ * const result2 = matrix.translate(2);
1626
+ * // => new Matrix2D(
1627
+ * // [1, 2],
1628
+ * // [3, 4],
1629
+ * // [13, 18],
1630
+ * // )
1631
+ * ```
1632
+ *
1633
+ * @param vec - The vector by which to translate the matrix
1634
+ */
1635
+ translate(vec: PossibleVector2): Matrix2D;
1636
+ /**
1637
+ * Add the provided matrix to this matrix.
1638
+ *
1639
+ * @remarks
1640
+ * This method returns a new matrix representing the result of the
1641
+ * computation. It will not modify the source matrix.
1642
+ *
1643
+ * @example
1644
+ * ```ts
1645
+ * const a = new Matrix2D(
1646
+ * [1, 2],
1647
+ * [3, 4],
1648
+ * [5, 6],
1649
+ * );
1650
+ * const a = new Matrix2D(
1651
+ * [7, 8],
1652
+ * [9, 10],
1653
+ * [11, 12],
1654
+ * );
1655
+ *
1656
+ * const result = a.add(b);
1657
+ * // => Matrix2D(
1658
+ * // [8, 10],
1659
+ * // [12, 14],
1660
+ * // [16, 18],
1661
+ * // )
1662
+ * ```
1663
+ *
1664
+ * @param other - The matrix to add
1665
+ */
1666
+ add(other: Matrix2D): Matrix2D;
1667
+ /**
1668
+ * Subtract the provided matrix from this matrix.
1669
+ *
1670
+ * @remarks
1671
+ * This method returns a new matrix representing the result of the
1672
+ * computation. It will not modify the source matrix.
1673
+ *
1674
+ * @example
1675
+ * ```ts
1676
+ * const a = new Matrix2D(
1677
+ * [1, 2],
1678
+ * [3, 4],
1679
+ * [5, 6],
1680
+ * );
1681
+ * const a = new Matrix2D(
1682
+ * [7, 8],
1683
+ * [9, 10],
1684
+ * [11, 12],
1685
+ * );
1686
+ *
1687
+ * const result = a.sub(b);
1688
+ * // => Matrix2D(
1689
+ * // [-6, -6],
1690
+ * // [-6, -6],
1691
+ * // [-6, -6],
1692
+ * // )
1693
+ * ```
1694
+ *
1695
+ * @param other - The matrix to subract
1696
+ */
1697
+ sub(other: Matrix2D): Matrix2D;
1698
+ toSymbol(): symbol;
1699
+ toUniform(gl: WebGL2RenderingContext, location: WebGLUniformLocation): void;
1700
+ equals(other: Matrix2D, threshold?: number): boolean;
1701
+ exactlyEquals(other: Matrix2D): boolean;
1702
+ }
1703
+ //#endregion
1704
+ //#region src/types/Spacing.d.ts
1705
+ type SerializedSpacing = {
1706
+ top: number;
1707
+ right: number;
1708
+ bottom: number;
1709
+ left: number;
1710
+ };
1711
+ type PossibleSpacing = SerializedSpacing | number | [number, number] | [number, number, number] | [number, number, number, number] | undefined;
1712
+ type SpacingSignal<T> = CompoundSignal<PossibleSpacing, Spacing, 'top' | 'right' | 'bottom' | 'left', T>;
1713
+ declare class Spacing implements Type, WebGLConvertible {
1714
+ static readonly symbol: unique symbol;
1715
+ top: number;
1716
+ right: number;
1717
+ bottom: number;
1718
+ left: number;
1719
+ static createSignal(initial?: SignalValue<PossibleSpacing>, interpolation?: InterpolationFunction<Spacing>): SpacingSignal<void>;
1720
+ static lerp(from: Spacing, to: Spacing, value: number): Spacing;
1721
+ get x(): number;
1722
+ get y(): number;
1723
+ constructor();
1724
+ constructor(from: PossibleSpacing);
1725
+ constructor(all: number);
1726
+ constructor(vertical: number, horizontal: number);
1727
+ constructor(top: number, horizontal: number, bottom: number);
1728
+ constructor(top: number, right: number, bottom: number, left: number);
1729
+ lerp(to: Spacing, value: number): Spacing;
1730
+ scale(value: number): Spacing;
1731
+ addScalar(value: number): Spacing;
1732
+ toSymbol(): symbol;
1733
+ toString(): string;
1734
+ toUniform(gl: WebGL2RenderingContext, location: WebGLUniformLocation): void;
1735
+ serialize(): SerializedSpacing;
1736
+ }
1737
+ //#endregion
1738
+ //#region src/types/BBox.d.ts
1739
+ type SerializedBBox = {
1740
+ x: number;
1741
+ y: number;
1742
+ width: number;
1743
+ height: number;
1744
+ };
1745
+ type PossibleBBox = SerializedBBox | [number, number, number, number] | Vector2 | undefined;
1746
+ type RectSignal<T> = CompoundSignal<PossibleBBox, BBox, 'x' | 'y' | 'width' | 'height', T>;
1747
+ declare class BBox implements Type, WebGLConvertible {
1748
+ static readonly symbol: unique symbol;
1749
+ x: number;
1750
+ y: number;
1751
+ width: number;
1752
+ height: number;
1753
+ static createSignal(initial?: SignalValue<PossibleBBox>, interpolation?: InterpolationFunction<BBox>): RectSignal<void>;
1754
+ static lerp(from: BBox, to: BBox, value: number | Vector2 | BBox): BBox;
1755
+ static arcLerp(from: BBox, to: BBox, value: number, reverse?: boolean, ratio?: number): BBox;
1756
+ static fromSizeCentered(size: Vector2): BBox;
1757
+ static fromPoints(...points: Vector2[]): BBox;
1758
+ static fromBBoxes(...boxes: BBox[]): BBox;
1759
+ lerp(to: BBox, value: number | Vector2 | BBox): BBox;
1760
+ get position(): Vector2;
1761
+ set position(value: Vector2);
1762
+ get size(): Vector2;
1763
+ get center(): Vector2;
1764
+ get left(): number;
1765
+ set left(value: number);
1766
+ get right(): number;
1767
+ set right(value: number);
1768
+ get top(): number;
1769
+ set top(value: number);
1770
+ get bottom(): number;
1771
+ set bottom(value: number);
1772
+ get topLeft(): Vector2;
1773
+ get topRight(): Vector2;
1774
+ get bottomLeft(): Vector2;
1775
+ get bottomRight(): Vector2;
1776
+ get corners(): [Vector2, Vector2, Vector2, Vector2];
1777
+ get pixelPerfect(): BBox;
1778
+ constructor();
1779
+ constructor(from: PossibleBBox);
1780
+ constructor(position: Vector2, size: Vector2);
1781
+ constructor(x: number, y?: number, width?: number, height?: number);
1782
+ transform(matrix: PossibleMatrix2D): BBox;
1783
+ transformCorners(matrix: PossibleMatrix2D): Vector2[];
1784
+ /**
1785
+ * Translate the bounding box by the given vector.
1786
+ *
1787
+ * @param vector - The vector to translate the bounding box by.
1788
+ */
1789
+ translate(vector: PossibleVector2): BBox;
1790
+ /**
1791
+ * Expand the bounding box to accommodate the given spacing.
1792
+ *
1793
+ * @param value - The value to expand the bounding box by.
1794
+ */
1795
+ expand(value: PossibleSpacing): BBox;
1796
+ /**
1797
+ * {@inheritDoc expand}
1798
+ *
1799
+ * @deprecated Use {@link expand} instead.
1800
+ */
1801
+ addSpacing(value: PossibleSpacing): BBox;
1802
+ includes(point: Vector2): boolean;
1803
+ intersects(other: BBox): boolean;
1804
+ intersection(other: BBox): BBox;
1805
+ union(other: BBox): BBox;
1806
+ toSymbol(): symbol;
1807
+ toString(): string;
1808
+ toUniform(gl: WebGL2RenderingContext, location: WebGLUniformLocation): void;
1809
+ serialize(): SerializedBBox;
1810
+ }
1811
+ //#endregion
1812
+ //#region src/types/Canvas.d.ts
1813
+ type CanvasColorSpace = 'srgb' | 'display-p3';
1814
+ type CanvasOutputMimeType = 'image/png' | 'image/jpeg' | 'image/webp';
1815
+ //#endregion
1816
+ //#region src/types/Color.d.ts
1817
+ type SerializedColor = string;
1818
+ type PossibleColor = SerializedColor | number | Color | {
1819
+ r: number;
1820
+ g: number;
1821
+ b: number;
1822
+ a: number;
1823
+ };
1824
+ type ColorSignal<T> = Signal<PossibleColor, Color, T>;
1825
+ type ColorSpace = 'rgb' | 'hsl' | 'hsv' | 'hsi' | 'lab' | 'oklab' | 'lch' | 'oklch' | 'hcl' | 'lrgb';
1826
+ /**
1827
+ * Represents a color.
1828
+ *
1829
+ * @remarks
1830
+ * Wraps {@link https://gka.github.io/chroma.js/ | chroma.js} internally,
1831
+ * providing color creation, conversion, and interpolation.
1832
+ */
1833
+ declare class Color implements Type, WebGLConvertible {
1834
+ static readonly symbol: unique symbol;
1835
+ private inner;
1836
+ constructor(input: PossibleColor);
1837
+ private static fromChroma;
1838
+ static lerp(from: Color | string | null, to: Color | string | null, value: number, colorSpace?: ColorSpace): Color;
1839
+ static createLerp(colorSpace: ColorSpace): InterpolationFunction<Color>;
1840
+ static createSignal(initial?: SignalValue<PossibleColor>, interpolation?: InterpolationFunction<Color>): ColorSignal<void>;
1841
+ static fromHsv(h: number, s: number, v: number, a?: number): Color;
1842
+ static isValid(input: string): boolean;
1843
+ hex(mode?: 'auto' | 'rgb' | 'rgba'): string;
1844
+ css(mode?: 'hsl'): string;
1845
+ gl(): [number, number, number, number];
1846
+ alpha(): number;
1847
+ alpha(value: number): Color;
1848
+ name(): string;
1849
+ rgb(round?: boolean): [number, number, number];
1850
+ rgba(round?: boolean): [number, number, number, number];
1851
+ hsl(): [number, number, number];
1852
+ hsv(): [number, number, number];
1853
+ hsi(): [number, number, number];
1854
+ lab(): [number, number, number];
1855
+ lch(): [number, number, number];
1856
+ hcl(): [number, number, number];
1857
+ oklab(): [number, number, number];
1858
+ oklch(): [number, number, number];
1859
+ num(): number;
1860
+ temperature(): number;
1861
+ clipped(): boolean;
1862
+ darken(amount?: number): Color;
1863
+ brighten(amount?: number): Color;
1864
+ saturate(amount?: number): Color;
1865
+ desaturate(amount?: number): Color;
1866
+ mix(color: Color | string, ratio?: number, colorSpace?: chroma.ColorFormat): Color;
1867
+ shade(ratio?: number, mode?: chroma.InterpolationMode): Color;
1868
+ tint(ratio?: number, mode?: chroma.InterpolationMode): Color;
1869
+ luminance(): number;
1870
+ luminance(value: number, mode?: chroma.InterpolationMode): Color;
1871
+ set(channel: string, value: string | number): Color;
1872
+ get(modechan: string): number;
1873
+ serialize(): SerializedColor;
1874
+ toSymbol(): symbol;
1875
+ toUniform(gl: WebGL2RenderingContext, location: WebGLUniformLocation): void;
1876
+ lerp(to: Color, value: number, colorSpace?: ColorSpace): Color;
1877
+ toString(): string;
1878
+ }
1879
+ //#endregion
1880
+ //#region src/types/Matrix.d.ts
1881
+ declare function transformAngle(angle: number, matrix: DOMMatrix): number;
1882
+ declare function transformScalar(scalar: number, matrix: DOMMatrix): number;
1883
+ //#endregion
1884
+ //#region src/meta/ColorMetaField.d.ts
1885
+ /**
1886
+ * Represents a color stored in a meta file.
1887
+ */
1888
+ declare class ColorMetaField extends MetaField<PossibleColor | null, Color | null> {
1889
+ readonly type: symbol;
1890
+ parse(value: PossibleColor | null): Color | null;
1891
+ serialize(): PossibleColor | null;
1892
+ }
1893
+ //#endregion
1894
+ //#region src/meta/MetaOption.d.ts
1895
+ interface MetaOption<T> {
1896
+ text: string;
1897
+ value: T;
1898
+ }
1899
+ //#endregion
1900
+ //#region src/meta/EnumMetaField.d.ts
1901
+ /**
1902
+ * Represents an enum value stored in a meta file.
1903
+ */
1904
+ declare class EnumMetaField<T> extends MetaField<T> {
1905
+ readonly options: MetaOption<T>[];
1906
+ static readonly symbol: unique symbol;
1907
+ readonly type: symbol;
1908
+ constructor(name: string, options: MetaOption<T>[], initial?: T);
1909
+ set(value: T): void;
1910
+ parse(value: T): T;
1911
+ getOption(value: T): MetaOption<T>;
1912
+ }
1913
+ //#endregion
1914
+ //#region src/plugin/Plugin.d.ts
1915
+ /**
1916
+ * Represents a runtime Canvas Commons plugin.
1917
+ */
1918
+ interface Plugin {
1919
+ /**
1920
+ * A unique name of the plugin.
1921
+ *
1922
+ * @remarks
1923
+ * The name should be unique across the entire ecosystem of Canvas Commons.
1924
+ * If a plugin with the same name has already been registered, this plugin
1925
+ * will be ignored.
1926
+ *
1927
+ * If you intend to publish your plugin to npm, it is recommended to prefix
1928
+ * this name with the name of your npm package.
1929
+ *
1930
+ * Other identifiers defined by the plugin, such as a tab id, will be
1931
+ * automatically prefixed with this name and as such don't have to be unique.
1932
+ */
1933
+ name: string;
1934
+ /**
1935
+ * Modify the project settings before the project is initialized.
1936
+ *
1937
+ * @param settings - The project settings.
1938
+ */
1939
+ settings?(settings: ProjectSettings): ProjectSettings | void;
1940
+ /**
1941
+ * Receive the project instance right after it is initialized.
1942
+ *
1943
+ * @param project - The project instance.
1944
+ */
1945
+ project?(project: Project): void;
1946
+ /**
1947
+ * Receive the player instance right after it is initialized.
1948
+ *
1949
+ * @param player - The player instance.
1950
+ */
1951
+ player?(player: Player): void;
1952
+ /**
1953
+ * Receive the presenter instance right after it is initialized.
1954
+ *
1955
+ * @param presenter - The presenter instance.
1956
+ */
1957
+ presenter?(presenter: Presenter): void;
1958
+ /**
1959
+ * Receive the renderer instance right after it is initialized.
1960
+ *
1961
+ * @param renderer - The renderer instance.
1962
+ */
1963
+ renderer?(renderer: Renderer): void;
1964
+ /**
1965
+ * Provide custom exporters for the project.
1966
+ *
1967
+ * @param project - The project instance.
1968
+ */
1969
+ exporters?(project: Project): ExporterClass[];
1970
+ }
1971
+ //#endregion
1972
+ //#region src/plugin/makePlugin.d.ts
1973
+ /**
1974
+ * A helper function for exporting Canvas Commons plugins.
1975
+ *
1976
+ * @param plugin - The plugin configuration.
1977
+ *
1978
+ * @example
1979
+ * ```ts
1980
+ * export default makePlugin({
1981
+ * name: 'my-custom-plugin',
1982
+ * });
1983
+ * ```
1984
+ */
1985
+ declare function makePlugin(plugin: Plugin | (() => Plugin)): () => Plugin;
1986
+ //#endregion
1987
+ //#region src/app/Logger.d.ts
1988
+ declare enum LogLevel {
1989
+ Error = "error",
1990
+ Warn = "warn",
1991
+ Info = "info",
1992
+ Http = "http",
1993
+ Verbose = "verbose",
1994
+ Debug = "debug",
1995
+ Silly = "silly"
1996
+ }
1997
+ /**
1998
+ * Represents an individual log entry.
1999
+ *
2000
+ * @remarks
2001
+ * When displayed in the editor, the log entry will have the following format:
2002
+ * ```
2003
+ * inspect node ┐
2004
+ * ┌ expand more duration ┐ │
2005
+ * ▼ ▼ ▼
2006
+ * ┌────────────────────────────────────────────┐
2007
+ * │ ▶ message 300 ms (+) │
2008
+ * ├────────────────────────────────────────────┤
2009
+ * │ remarks │
2010
+ * │ object │
2011
+ * │ stacktrace │
2012
+ * └────────────────────────────────────────────┘
2013
+ * ```
2014
+ */
2015
+ interface LogPayload {
2016
+ /**
2017
+ * The log level.
2018
+ */
2019
+ level?: LogLevel;
2020
+ /**
2021
+ * The main message of the log.
2022
+ *
2023
+ * @remarks
2024
+ * Always visible.
2025
+ */
2026
+ message: string;
2027
+ /**
2028
+ * Additional information about the log.
2029
+ *
2030
+ * @remarks
2031
+ * Visible only when the log is expanded.
2032
+ */
2033
+ remarks?: string;
2034
+ /**
2035
+ * An object that will be serialized as JSON and displayed under the message.
2036
+ *
2037
+ * @remarks
2038
+ * Visible only when the log is expanded.
2039
+ */
2040
+ object?: any;
2041
+ /**
2042
+ * The stack trace of the log.
2043
+ *
2044
+ * @remarks
2045
+ * Visible only when the log is expanded.
2046
+ * The current stack trace can be obtained using `new Error().stack`.
2047
+ * Both Chromium and Firefox stack traces are supported.
2048
+ */
2049
+ stack?: string;
2050
+ /**
2051
+ * An optional duration in milliseconds.
2052
+ *
2053
+ * @remarks
2054
+ * Can be used to display any duration related to the log.
2055
+ * The value is always visible next to the message.
2056
+ */
2057
+ durationMs?: number;
2058
+ /**
2059
+ * An optional key used to inspect a related object.
2060
+ *
2061
+ * @remarks
2062
+ * This will be used together with the {@link scenes.Inspectable} interface to
2063
+ * display additional information about the inspected object.
2064
+ * When specified, the log will have an "inspect" button that will open the
2065
+ * "Properties" tab and select the inspected object.
2066
+ */
2067
+ inspect?: string;
2068
+ /**
2069
+ * Any additional information that the log may contain.
2070
+ */
2071
+ [K: string]: any;
2072
+ }
2073
+ declare class Logger {
2074
+ /**
2075
+ * Triggered when a new message is logged.
2076
+ */
2077
+ get onLogged(): Subscribable<LogPayload, EventHandler<LogPayload>>;
2078
+ private readonly logged;
2079
+ readonly history: LogPayload[];
2080
+ private profilers;
2081
+ log(payload: LogPayload): void;
2082
+ error(payload: string | LogPayload): void;
2083
+ warn(payload: string | LogPayload): void;
2084
+ info(payload: string | LogPayload): void;
2085
+ http(payload: string | LogPayload): void;
2086
+ verbose(payload: string | LogPayload): void;
2087
+ debug(payload: string | LogPayload): void;
2088
+ silly(payload: string | LogPayload): void;
2089
+ protected logLevel(level: LogLevel, payload: string | LogPayload): void;
2090
+ profile(id: string, payload?: LogPayload): void;
2091
+ }
2092
+ //#endregion
2093
+ //#region src/scenes/Random.d.ts
2094
+ /**
2095
+ * A random number generator based on
2096
+ * {@link https://gist.github.com/tommyettinger/46a874533244883189143505d203312c | Mulberry32}.
2097
+ */
2098
+ declare class Random {
2099
+ private state;
2100
+ /**
2101
+ * Previously generated Gaussian random number.
2102
+ *
2103
+ * @remarks
2104
+ * This is an optimization.
2105
+ * Since {@link gauss} generates a pair of independent Gaussian random
2106
+ * numbers, it returns one immediately and stores the other for the next call
2107
+ * to {@link gauss}.
2108
+ */
2109
+ private nextGauss;
2110
+ constructor(state: number);
2111
+ /**
2112
+ * @internal
2113
+ */
2114
+ static createSeed(): number;
2115
+ /**
2116
+ * Get the next random float in the given range.
2117
+ *
2118
+ * @param from - The start of the range.
2119
+ * @param to - The end of the range.
2120
+ */
2121
+ nextFloat(from?: number, to?: number): number;
2122
+ /**
2123
+ * Get the next random integer in the given range.
2124
+ *
2125
+ * @param from - The start of the range.
2126
+ * @param to - The end of the range. Exclusive.
2127
+ */
2128
+ nextInt(from?: number, to?: number): number;
2129
+ /**
2130
+ * Get a random float from a gaussian distribution.
2131
+ * @param mean - The mean of the distribution.
2132
+ * @param stdev - The standard deviation of the distribution.
2133
+ */
2134
+ gauss(mean?: number, stdev?: number): number;
2135
+ /**
2136
+ * Get an array filled with random floats in the given range.
2137
+ *
2138
+ * @param size - The size of the array.
2139
+ * @param from - The start of the range.
2140
+ * @param to - The end of the range.
2141
+ */
2142
+ floatArray(size: number, from?: number, to?: number): number[];
2143
+ /**
2144
+ Get an array filled with random integers in the given range.
2145
+ *
2146
+ * @param size - The size of the array.
2147
+ * @param from - The start of the range.
2148
+ * @param to - The end of the range. Exclusive.
2149
+ */
2150
+ intArray(size: number, from?: number, to?: number): number[];
2151
+ /**
2152
+ * Create a new independent generator.
2153
+ */
2154
+ spawn(): Random;
2155
+ private next;
2156
+ }
2157
+ //#endregion
2158
+ //#region src/scenes/timeEvents/TimeEvent.d.ts
2159
+ /**
2160
+ * Represents a time event at runtime.
2161
+ */
2162
+ interface TimeEvent {
2163
+ /**
2164
+ * Name of the event.
2165
+ */
2166
+ name: string;
2167
+ /**
2168
+ * Time in seconds, relative to the beginning of the scene, at which the event
2169
+ * was registered.
2170
+ *
2171
+ * @remarks
2172
+ * In other words, the moment at which {@link flow.waitUntil} for this event
2173
+ * was invoked.
2174
+ */
2175
+ initialTime: number;
2176
+ /**
2177
+ * Time in seconds, relative to the beginning of the scene, at which the event
2178
+ * should end.
2179
+ */
2180
+ targetTime: number;
2181
+ /**
2182
+ * Duration of the event in seconds.
2183
+ */
2184
+ offset: number;
2185
+ /**
2186
+ * Stack trace at the moment of registration.
2187
+ */
2188
+ stack?: string;
2189
+ }
2190
+ //#endregion
2191
+ //#region src/scenes/timeEvents/TimeEvents.d.ts
2192
+ /**
2193
+ * An interface for classes managing the time events.
2194
+ */
2195
+ interface TimeEvents {
2196
+ /**
2197
+ * Triggered when time events change.
2198
+ *
2199
+ * @eventProperty
2200
+ */
2201
+ get onChanged(): SubscribableValueEvent<TimeEvent[]>;
2202
+ /**
2203
+ * Change the time offset of the given event.
2204
+ *
2205
+ * @param name - The name of the event.
2206
+ * @param offset - The time offset in seconds.
2207
+ * @param preserve - Whether the timing of the consecutive events should be
2208
+ * preserved. When set to `true` their offsets will be
2209
+ * adjusted to keep them in place.
2210
+ */
2211
+ set(name: string, offset: number, preserve?: boolean): void;
2212
+ /**
2213
+ * Register a time event.
2214
+ *
2215
+ * @param name - The name of the event.
2216
+ * @param initialTime - Time in seconds, relative to the beginning of the
2217
+ * scene, at which the event was registered.
2218
+ *
2219
+ * @returns The duration of the event in seconds.
2220
+ *
2221
+ * @internal
2222
+ */
2223
+ register(name: string, initialTime: number): number;
2224
+ }
2225
+ //#endregion
2226
+ //#region src/scenes/timeEvents/EditableTimeEvents.d.ts
2227
+ /**
2228
+ * Manages time events during editing.
2229
+ */
2230
+ declare class EditableTimeEvents implements TimeEvents {
2231
+ private readonly scene;
2232
+ get onChanged(): SubscribableValueEvent<TimeEvent[]>;
2233
+ private readonly events;
2234
+ private registeredEvents;
2235
+ private lookup;
2236
+ private collisionLookup;
2237
+ private previousReference;
2238
+ private didEventsChange;
2239
+ private preserveTiming;
2240
+ constructor(scene: Scene);
2241
+ set(name: string, offset: number, preserve?: boolean): void;
2242
+ register(name: string, initialTime: number): number;
2243
+ /**
2244
+ * Called when the parent scene gets reloaded.
2245
+ */
2246
+ private handleReload;
2247
+ /**
2248
+ * Called when the parent scene gets recalculated.
2249
+ */
2250
+ private handleRecalculated;
2251
+ private handleReset;
2252
+ /**
2253
+ * Called when the meta of the parent scene changes.
2254
+ */
2255
+ private handleMetaChanged;
2256
+ private load;
2257
+ }
2258
+ //#endregion
2259
+ //#region src/scenes/timeEvents/ReadOnlyTimeEvents.d.ts
2260
+ /**
2261
+ * Manages time events during rendering and presentation.
2262
+ */
2263
+ declare class ReadOnlyTimeEvents implements TimeEvents {
2264
+ private readonly scene;
2265
+ get onChanged(): SubscribableValueEvent<TimeEvent[]>;
2266
+ private readonly events;
2267
+ private lookup;
2268
+ constructor(scene: Scene);
2269
+ set(): void;
2270
+ register(name: string, initialTime: number): number;
2271
+ /**
2272
+ * Called when the parent scene gets reloaded.
2273
+ */
2274
+ private handleReload;
2275
+ }
2276
+ //#endregion
2277
+ //#region src/scenes/timeEvents/SerializedTimeEvent.d.ts
2278
+ /**
2279
+ * Represents a time event stored in a meta file.
2280
+ */
2281
+ interface SerializedTimeEvent {
2282
+ /**
2283
+ * {@inheritDoc TimeEvent.name}
2284
+ */
2285
+ name: string;
2286
+ /**
2287
+ * {@inheritDoc TimeEvent.targetTime}
2288
+ */
2289
+ targetTime: number;
2290
+ }
2291
+ //#endregion
2292
+ //#region src/scenes/SceneMetadata.d.ts
2293
+ /**
2294
+ * Create a runtime representation of the scene metadata.
2295
+ */
2296
+ declare function createSceneMetadata(): ObjectMetaField<{
2297
+ version: MetaField<any, number>;
2298
+ timeEvents: MetaField<SerializedTimeEvent[], SerializedTimeEvent[]>;
2299
+ seed: MetaField<any, number>;
2300
+ }>;
2301
+ /**
2302
+ * A runtime representation of the scene metadata.
2303
+ */
2304
+ type SceneMetadata = ReturnType<typeof createSceneMetadata>;
2305
+ //#endregion
2306
+ //#region src/app/SharedWebGLContext.d.ts
2307
+ /**
2308
+ * @internal
2309
+ */
2310
+ interface WebGLContextOwner {
2311
+ setup(gl: WebGL2RenderingContext): void;
2312
+ teardown(gl: WebGL2RenderingContext): void;
2313
+ }
2314
+ declare class SharedWebGLContext {
2315
+ private readonly logger;
2316
+ private gl;
2317
+ private currentOwner;
2318
+ private readonly programLookup;
2319
+ constructor(logger: Logger);
2320
+ borrow(owner: WebGLContextOwner): WebGL2RenderingContext;
2321
+ /**
2322
+ * Dispose the WebGL context to free up resources.
2323
+ */
2324
+ dispose(): void;
2325
+ getProgram(fragment: string, vertex: string): WebGLProgram | null;
2326
+ private getShader;
2327
+ private getGL;
2328
+ }
2329
+ //#endregion
2330
+ //#region src/scenes/Shaders.d.ts
2331
+ /**
2332
+ * @internal
2333
+ */
2334
+ declare const UNIFORM_RESOLUTION = "resolution";
2335
+ /**
2336
+ * @internal
2337
+ */
2338
+ declare const UNIFORM_DESTINATION_TEXTURE = "destinationTexture";
2339
+ /**
2340
+ * @internal
2341
+ */
2342
+ declare const UNIFORM_SOURCE_TEXTURE = "sourceTexture";
2343
+ /**
2344
+ * @internal
2345
+ */
2346
+ declare const UNIFORM_TIME = "time";
2347
+ /**
2348
+ * @internal
2349
+ */
2350
+ declare const UNIFORM_DELTA_TIME = "deltaTime";
2351
+ /**
2352
+ * @internal
2353
+ */
2354
+ declare const UNIFORM_FRAMERATE = "framerate";
2355
+ /**
2356
+ * @internal
2357
+ */
2358
+ declare const UNIFORM_FRAME = "frame";
2359
+ /**
2360
+ * @internal
2361
+ */
2362
+ declare const UNIFORM_SOURCE_MATRIX = "sourceMatrix";
2363
+ /**
2364
+ * @internal
2365
+ */
2366
+ declare const UNIFORM_DESTINATION_MATRIX = "destinationMatrix";
2367
+ /**
2368
+ * @internal
2369
+ */
2370
+ declare class Shaders implements WebGLContextOwner {
2371
+ private readonly scene;
2372
+ private readonly sharedContext;
2373
+ private gl;
2374
+ private positionBuffer;
2375
+ private sourceTexture;
2376
+ private destinationTexture;
2377
+ private positionLocation;
2378
+ private readonly quadPositions;
2379
+ constructor(scene: Scene, sharedContext: SharedWebGLContext);
2380
+ setup(gl: WebGL2RenderingContext): void;
2381
+ teardown(gl: WebGL2RenderingContext): void;
2382
+ private handleReload;
2383
+ private updateViewport;
2384
+ getGL(): WebGL2RenderingContext;
2385
+ getProgram(fragment: string): WebGLProgram | null;
2386
+ copyTextures(destination: TexImageSource, source: TexImageSource): void;
2387
+ clear(): void;
2388
+ render(): void;
2389
+ private copyTexture;
2390
+ }
2391
+ //#endregion
2392
+ //#region src/scenes/Slides.d.ts
2393
+ interface Slide {
2394
+ id: string;
2395
+ name: string;
2396
+ time: number;
2397
+ scene: Scene;
2398
+ stack?: string;
2399
+ }
2400
+ declare class Slides {
2401
+ private readonly scene;
2402
+ get onChanged(): SubscribableValueEvent<Slide[]>;
2403
+ private readonly slides;
2404
+ private readonly lookup;
2405
+ private readonly collisionLookup;
2406
+ private current;
2407
+ private canResume;
2408
+ private waitsForId;
2409
+ private targetId;
2410
+ constructor(scene: Scene);
2411
+ setTarget(target: string | null): void;
2412
+ resume(): void;
2413
+ isWaitingFor(slide: string): boolean;
2414
+ isWaiting(): boolean;
2415
+ didHappen(slide: string): boolean;
2416
+ getCurrent(): Slide | null;
2417
+ register(name: string, initialTime: number): void;
2418
+ shouldWait(name: string): boolean;
2419
+ private handleReload;
2420
+ private handleReset;
2421
+ private handleRecalculated;
2422
+ private toId;
2423
+ }
2424
+ //#endregion
2425
+ //#region src/scenes/Sounds.d.ts
2426
+ interface SoundSettings {
2427
+ audio: string;
2428
+ start?: number;
2429
+ end?: number;
2430
+ gain?: number;
2431
+ detune?: number;
2432
+ playbackRate?: number;
2433
+ }
2434
+ interface Sound extends SoundSettings {
2435
+ offset: number;
2436
+ realPlaybackRate: number;
2437
+ }
2438
+ declare class SoundBuilder {
2439
+ private settings;
2440
+ /**
2441
+ * {@inheritDoc sound}
2442
+ */
2443
+ constructor(audio: string | SoundBuilder);
2444
+ /**
2445
+ * Trim the audio file to a specific portion of it.
2446
+ *
2447
+ * @param start - The offset in seconds to play from.
2448
+ * @param end - The offset in seconds to play to.
2449
+ */
2450
+ trim(start?: number, end?: number): this;
2451
+ /**
2452
+ * Set the amplification of the played sound.
2453
+ *
2454
+ * @param db - The gain in dB.
2455
+ */
2456
+ gain(db: number): this;
2457
+ /**
2458
+ * Pitch shift the played sound.
2459
+ *
2460
+ * @remarks
2461
+ * This also affects the duration of the sound.
2462
+ *
2463
+ * @param cents - The pitch shift in cents.
2464
+ */
2465
+ detune(cents: number): this;
2466
+ /**
2467
+ * Change the playback rate of the sound.
2468
+ *
2469
+ * @remarks
2470
+ * This also affects the perceived pitch of the sound.
2471
+ *
2472
+ * @param rate - The new playback rate. Must be greater than 0.
2473
+ */
2474
+ playbackRate(rate: number): this;
2475
+ /**
2476
+ * Play the configured sound at the current frame.
2477
+ *
2478
+ * @param offset - An offset in seconds from the current frame. Defaults to 0.
2479
+ */
2480
+ play(offset?: number): void;
2481
+ }
2482
+ /**
2483
+ * Begin configuring a sound to be played back.
2484
+ */
2485
+ declare function sound(audio: string | SoundBuilder): SoundBuilder;
2486
+ declare class Sounds {
2487
+ private readonly scene;
2488
+ get onChanged(): SubscribableValueEvent<Sound[]>;
2489
+ private readonly sounds;
2490
+ private registeredSounds;
2491
+ constructor(scene: Scene);
2492
+ add(settings: SoundSettings, offset?: number): void;
2493
+ getSounds(): readonly Sound[];
2494
+ private handleRecalculated;
2495
+ private reset;
2496
+ }
2497
+ //#endregion
2498
+ //#region src/scenes/Variables.d.ts
2499
+ declare class Variables {
2500
+ private readonly scene;
2501
+ private signals;
2502
+ private variables;
2503
+ constructor(scene: Scene);
2504
+ /**
2505
+ * Get variable signal if exists or create signal if not
2506
+ *
2507
+ * @param name - The name of the variable.
2508
+ * @param initial - The initial value of the variable. It will be used if the
2509
+ * variable was not configured from the outside.
2510
+ */
2511
+ get<T>(name: string, initial: T): () => T;
2512
+ /**
2513
+ * Update all signals with new project variable values.
2514
+ */
2515
+ updateSignals(variables: Record<string, unknown>): void;
2516
+ /**
2517
+ * Reset all stored signals.
2518
+ */
2519
+ handleReset: () => void;
2520
+ }
2521
+ //#endregion
2522
+ //#region src/scenes/Scene.d.ts
2523
+ /**
2524
+ * The constructor used when creating new scenes.
2525
+ *
2526
+ * @remarks
2527
+ * Each class implementing the {@link Scene} interface should have a matching
2528
+ * constructor.
2529
+ *
2530
+ * @typeParam T - The type of the configuration object. This object will be
2531
+ * passed to the constructor from
2532
+ * {@link SceneDescription.config}.
2533
+ */
2534
+ interface SceneConstructor<T> {
2535
+ new (description: FullSceneDescription<T>): Scene;
2536
+ }
2537
+ /**
2538
+ * Describes a scene exposed by scene files.
2539
+ *
2540
+ * @typeParam T - The type of the configuration object.
2541
+ */
2542
+ interface SceneDescription<T = unknown> {
2543
+ /**
2544
+ * The class used to instantiate the scene.
2545
+ */
2546
+ klass: SceneConstructor<T>;
2547
+ /**
2548
+ * Configuration object.
2549
+ */
2550
+ config: T;
2551
+ /**
2552
+ * The stack trace at the moment of creation.
2553
+ */
2554
+ stack?: string;
2555
+ /**
2556
+ * A list of plugins to include in the project.
2557
+ */
2558
+ plugins?: (Plugin | string)[];
2559
+ meta: SceneMetadata;
2560
+ }
2561
+ /**
2562
+ * Describes a complete scene together with the meta file.
2563
+ *
2564
+ * @typeParam T - The type of the configuration object.
2565
+ */
2566
+ interface FullSceneDescription<T = unknown> extends SceneDescription<T> {
2567
+ name: string;
2568
+ size: Vector2;
2569
+ resolutionScale: number;
2570
+ variables: Variables;
2571
+ playback: PlaybackStatus;
2572
+ logger: Logger;
2573
+ onReplaced: ValueDispatcher<FullSceneDescription<T>>;
2574
+ timeEventsClass: new (scene: Scene) => TimeEvents;
2575
+ sharedWebGLContext: SharedWebGLContext;
2576
+ experimentalFeatures?: boolean;
2577
+ }
2578
+ /**
2579
+ * A part of the {@link SceneDescription} that can be updated during reload.
2580
+ *
2581
+ * @typeParam T - The type of the configuration object.
2582
+ */
2583
+ interface SceneDescriptionReload<T = unknown> {
2584
+ size?: Vector2;
2585
+ resolutionScale?: number;
2586
+ config?: T;
2587
+ stack?: string;
2588
+ }
2589
+ type DescriptionOf<TScene> = TScene extends Scene<infer TConfig> ? SceneDescription<TConfig> : never;
2590
+ /**
2591
+ * Describes cached information about the timing of a scene.
2592
+ */
2593
+ interface CachedSceneData {
2594
+ firstFrame: number;
2595
+ lastFrame: number;
2596
+ transitionDuration: number;
2597
+ duration: number;
2598
+ }
2599
+ /**
2600
+ * Signifies the various stages of a {@link Scene}'s render lifecycle.
2601
+ */
2602
+ declare enum SceneRenderEvent {
2603
+ /**
2604
+ * Occurs before the render starts when the Scene transitions are applied.
2605
+ */
2606
+ BeforeRender = 0,
2607
+ /**
2608
+ * Occurs at the beginning of a render when the Scene's
2609
+ * {@link utils.useContext} handlers are applied.
2610
+ */
2611
+ BeginRender = 1,
2612
+ /**
2613
+ * Occurs at the end of a render when the Scene's
2614
+ * {@link utils.useContextAfter} handlers are applied.
2615
+ */
2616
+ FinishRender = 2,
2617
+ /**
2618
+ * Occurs after a render ends.
2619
+ */
2620
+ AfterRender = 3
2621
+ }
2622
+ /**
2623
+ * The main interface for scenes.
2624
+ *
2625
+ * @remarks
2626
+ * Any class implementing this interface should have a constructor matching
2627
+ * {@link SceneConstructor}.
2628
+ *
2629
+ * @typeParam T - The type of the configuration object.
2630
+ */
2631
+ interface Scene<T = unknown> {
2632
+ /**
2633
+ * Name of the scene.
2634
+ *
2635
+ * @remarks
2636
+ * Will be passed as the second argument to the constructor.
2637
+ */
2638
+ readonly name: string;
2639
+ /**
2640
+ * Reference to the project.
2641
+ */
2642
+ readonly playback: PlaybackStatus;
2643
+ readonly timeEvents: TimeEvents;
2644
+ /**
2645
+ * @experimental
2646
+ */
2647
+ readonly shaders: Shaders;
2648
+ readonly slides: Slides;
2649
+ readonly sounds: Sounds;
2650
+ readonly logger: Logger;
2651
+ readonly variables: Variables;
2652
+ readonly random: Random;
2653
+ readonly meta: SceneMetadata;
2654
+ creationStack?: string;
2655
+ /**
2656
+ * The frame at which this scene starts.
2657
+ */
2658
+ get firstFrame(): number;
2659
+ /**
2660
+ * Scene transition duration in frames.
2661
+ */
2662
+ get transitionDuration(): number;
2663
+ /**
2664
+ * The frame at which this scene ends.
2665
+ */
2666
+ get lastFrame(): number;
2667
+ /**
2668
+ * Triggered when the cached data changes.
2669
+ *
2670
+ * @eventProperty
2671
+ */
2672
+ get onCacheChanged(): SubscribableValueEvent<CachedSceneData>;
2673
+ /**
2674
+ * Triggered when the scene is reloaded.
2675
+ *
2676
+ * @eventProperty
2677
+ */
2678
+ get onReloaded(): SubscribableEvent<void>;
2679
+ /**
2680
+ * Triggered after scene is recalculated.
2681
+ *
2682
+ * @eventProperty
2683
+ */
2684
+ get onRecalculated(): SubscribableEvent<void>;
2685
+ /**
2686
+ * The {@link scenes.LifecycleEvents} of this scene.
2687
+ */
2688
+ get lifecycleEvents(): LifecycleEvents;
2689
+ /**
2690
+ * The {@link scenes.LifecycleEvents} of this scene.
2691
+ *
2692
+ * @deprecated Use {@link lifecycleEvents} instead.
2693
+ */
2694
+ get LifecycleEvents(): LifecycleEvents;
2695
+ /**
2696
+ * Triggered at various stages of the render lifecycle with an event title and a Context2D.
2697
+ *
2698
+ * @eventProperty
2699
+ */
2700
+ get onRenderLifecycle(): SubscribableEvent<[SceneRenderEvent, CanvasRenderingContext2D]>;
2701
+ /**
2702
+ * Triggered when the scene is reset.
2703
+ *
2704
+ * @eventProperty
2705
+ */
2706
+ get onReset(): SubscribableEvent<void>;
2707
+ /**
2708
+ * The scene directly before this scene, or null if omitted for performance.
2709
+ */
2710
+ get previous(): Scene | null;
2711
+ /**
2712
+ * Whether experimental features are enabled.
2713
+ */
2714
+ get experimentalFeatures(): boolean;
2715
+ /**
2716
+ * Render the scene onto a canvas.
2717
+ *
2718
+ * @param context - The context to used when rendering.
2719
+ */
2720
+ render(context: CanvasRenderingContext2D): Promise<void>;
2721
+ /**
2722
+ * Reload the scene.
2723
+ *
2724
+ * @remarks
2725
+ * This method is called whenever something related to this scene has changed:
2726
+ * time events, source code, metadata, etc.
2727
+ *
2728
+ * Should trigger {@link onReloaded}.
2729
+ *
2730
+ * @param description - If present, an updated version of the description.
2731
+ */
2732
+ reload(description?: SceneDescriptionReload<T>): void;
2733
+ /**
2734
+ * Recalculate the scene.
2735
+ *
2736
+ * @remarks
2737
+ * The task of this method is to calculate new timings stored in the cache.
2738
+ * When this method is invoked, `this.project.frame` is set to the frame at
2739
+ * which this scene should start ({@link firstFrame}).
2740
+ *
2741
+ * At the end of execution, this method should set `this.project.frame` to the
2742
+ * frame at which this scene ends ({@link lastFrame}).
2743
+ *
2744
+ * Should trigger {@link onRecalculated}.
2745
+ */
2746
+ recalculate(setFrame: (frame: number) => void): Promise<void>;
2747
+ /**
2748
+ * Progress this scene one frame forward.
2749
+ */
2750
+ next(): Promise<void>;
2751
+ /**
2752
+ * Reset this scene to its initial state.
2753
+ *
2754
+ * @param previous - If present, the previous scene.
2755
+ */
2756
+ reset(previous?: Scene): Promise<void>;
2757
+ /**
2758
+ * Get the size of this scene.
2759
+ *
2760
+ * @remarks
2761
+ * Usually returns `this.project.getSize()`.
2762
+ */
2763
+ getSize(): Vector2;
2764
+ /**
2765
+ * Get the real size of this scene.
2766
+ *
2767
+ * @remarks
2768
+ * Returns the size of the scene multiplied by the resolution scale.
2769
+ * This is the actual size of the canvas onto which the scene is rendered.
2770
+ */
2771
+ getRealSize(): Vector2;
2772
+ /**
2773
+ * Is this scene in the {@link SceneState.AfterTransitionIn} state?
2774
+ */
2775
+ isAfterTransitionIn(): boolean;
2776
+ /**
2777
+ * Is this scene in the {@link SceneState.CanTransitionOut} state?
2778
+ */
2779
+ canTransitionOut(): boolean;
2780
+ /**
2781
+ * Is this scene in the {@link SceneState.Finished} state?
2782
+ */
2783
+ isFinished(): boolean;
2784
+ /**
2785
+ * Enter the {@link SceneState.Initial} state.
2786
+ */
2787
+ enterInitial(): void;
2788
+ /**
2789
+ * Enter the {@link SceneState.AfterTransitionIn} state.
2790
+ */
2791
+ enterAfterTransitionIn(): void;
2792
+ /**
2793
+ * Enter the {@link SceneState.CanTransitionOut} state.
2794
+ */
2795
+ enterCanTransitionOut(): void;
2796
+ /**
2797
+ * Is this scene cached?
2798
+ *
2799
+ * @remarks
2800
+ * Used only by {@link GeneratorScene}. Seeking through a project that
2801
+ * contains at least one uncached scene will log a warning to the console.
2802
+ *
2803
+ * Should always return `true`.
2804
+ */
2805
+ isCached(): boolean;
2806
+ /**
2807
+ * Should this scene be rendered below the previous scene during a transition?
2808
+ */
2809
+ previousOnTop: SignalValue<boolean>;
2810
+ }
2811
+ //#endregion
2812
+ //#region src/scenes/LifecycleEvents.d.ts
2813
+ /**
2814
+ * Lifecycle events for {@link Scene} that are cleared on every reset.
2815
+ */
2816
+ declare class LifecycleEvents {
2817
+ private readonly scene;
2818
+ get onBeforeRender(): Subscribable<CanvasRenderingContext2D, EventHandler<CanvasRenderingContext2D>>;
2819
+ protected readonly beforeRender: EventDispatcher<CanvasRenderingContext2D>;
2820
+ get onBeginRender(): Subscribable<CanvasRenderingContext2D, EventHandler<CanvasRenderingContext2D>>;
2821
+ protected readonly beginRender: EventDispatcher<CanvasRenderingContext2D>;
2822
+ get onFinishRender(): Subscribable<CanvasRenderingContext2D, EventHandler<CanvasRenderingContext2D>>;
2823
+ protected readonly finishRender: EventDispatcher<CanvasRenderingContext2D>;
2824
+ get onAfterRender(): Subscribable<CanvasRenderingContext2D, EventHandler<CanvasRenderingContext2D>>;
2825
+ protected readonly afterRender: EventDispatcher<CanvasRenderingContext2D>;
2826
+ constructor(scene: Scene);
2827
+ }
2828
+ //#endregion
2829
+ //#region src/scenes/Threadable.d.ts
2830
+ /**
2831
+ * Scenes can implement this interface to display their thread hierarchy in the
2832
+ * UI.
2833
+ *
2834
+ * @remarks
2835
+ * This interface is only useful when a scene uses thread generators to run.
2836
+ */
2837
+ interface Threadable {
2838
+ /**
2839
+ * Triggered when the main thread changes.
2840
+ *
2841
+ * @eventProperty
2842
+ */
2843
+ get onThreadChanged(): SubscribableValueEvent<Thread | null>;
2844
+ }
2845
+ declare function isThreadable(value: any): value is Threadable;
2846
+ //#endregion
2847
+ //#region src/scenes/GeneratorScene.d.ts
2848
+ interface ThreadGeneratorFactory<T> {
2849
+ (view: T): ThreadGenerator;
2850
+ }
2851
+ /**
2852
+ * The default implementation of the {@link Scene} interface.
2853
+ *
2854
+ * Uses generators to control the animation.
2855
+ */
2856
+ declare abstract class GeneratorScene<T> implements Scene<ThreadGeneratorFactory<T>>, Threadable {
2857
+ readonly name: string;
2858
+ readonly playback: PlaybackStatus;
2859
+ readonly logger: Logger;
2860
+ readonly meta: SceneMetadata;
2861
+ readonly timeEvents: TimeEvents;
2862
+ readonly shaders: Shaders;
2863
+ readonly slides: Slides;
2864
+ readonly sounds: Sounds;
2865
+ readonly variables: Variables;
2866
+ random: Random;
2867
+ creationStack?: string;
2868
+ previousOnTop: SignalValue<boolean>;
2869
+ get firstFrame(): number;
2870
+ get transitionDuration(): number;
2871
+ get lastFrame(): number;
2872
+ get onCacheChanged(): SubscribableValueEvent<CachedSceneData>;
2873
+ private readonly cache;
2874
+ get onReloaded(): Subscribable<void, EventHandler<void>>;
2875
+ private readonly reloaded;
2876
+ get onRecalculated(): Subscribable<void, EventHandler<void>>;
2877
+ private readonly recalculated;
2878
+ get onThreadChanged(): SubscribableValueEvent<Thread | null>;
2879
+ private readonly thread;
2880
+ get onRenderLifecycle(): Subscribable<[SceneRenderEvent, CanvasRenderingContext2D], EventHandler<[SceneRenderEvent, CanvasRenderingContext2D]>>;
2881
+ protected readonly renderLifecycle: EventDispatcher<[SceneRenderEvent, CanvasRenderingContext2D]>;
2882
+ get onReset(): Subscribable<void, EventHandler<void>>;
2883
+ private readonly afterReset;
2884
+ readonly lifecycleEvents: LifecycleEvents;
2885
+ get LifecycleEvents(): LifecycleEvents;
2886
+ get previous(): Scene<unknown> | null;
2887
+ readonly experimentalFeatures: boolean;
2888
+ protected resolutionScale: number;
2889
+ private runnerFactory;
2890
+ private previousScene;
2891
+ private runner;
2892
+ private state;
2893
+ private cached;
2894
+ private counters;
2895
+ private size;
2896
+ constructor(description: FullSceneDescription<ThreadGeneratorFactory<T>>);
2897
+ abstract getView(): T;
2898
+ /**
2899
+ * Update the view.
2900
+ *
2901
+ * Invoked after each step of the main generator.
2902
+ * Can be used for calculating layout.
2903
+ *
2904
+ * Can modify the state of the view.
2905
+ */
2906
+ update(): void;
2907
+ render(context: CanvasRenderingContext2D): Promise<void>;
2908
+ protected abstract draw(context: CanvasRenderingContext2D): void;
2909
+ reload({
2910
+ config,
2911
+ size,
2912
+ stack,
2913
+ resolutionScale
2914
+ }?: SceneDescriptionReload<ThreadGeneratorFactory<T>>): void;
2915
+ recalculate(setFrame: (frame: number) => void): Promise<void>;
2916
+ next(): Promise<void>;
2917
+ reset(previousScene?: Scene | null): Promise<void>;
2918
+ getSize(): Vector2;
2919
+ getRealSize(): Vector2;
2920
+ isAfterTransitionIn(): boolean;
2921
+ canTransitionOut(): boolean;
2922
+ isFinished(): boolean;
2923
+ enterInitial(): void;
2924
+ enterAfterTransitionIn(): void;
2925
+ enterCanTransitionOut(): void;
2926
+ isCached(): boolean;
2927
+ /**
2928
+ * Invoke the given callback in the context of this scene.
2929
+ *
2930
+ * @remarks
2931
+ * This method makes sure that the context of this scene is globally available
2932
+ * during the execution of the callback.
2933
+ *
2934
+ * @param callback - The callback to invoke.
2935
+ */
2936
+ protected execute<T>(callback: () => T): T;
2937
+ }
2938
+ //#endregion
2939
+ //#region src/scenes/Inspectable.d.ts
2940
+ /**
2941
+ * Represents an element to inspect.
2942
+ *
2943
+ * @remarks
2944
+ * The type is not important because the UI does not interact with it.
2945
+ * It serves as a key that will be passed back to an Inspectable scene to
2946
+ * receive more information about said element.
2947
+ */
2948
+ type InspectedElement = unknown;
2949
+ /**
2950
+ * Represents attributes of an inspected element.
2951
+ */
2952
+ type InspectedAttributes = {
2953
+ stack?: string;
2954
+ [K: string]: any;
2955
+ };
2956
+ /**
2957
+ * Scenes can implement this interface to make their components
2958
+ * inspectable through the UI.
2959
+ */
2960
+ interface Inspectable {
2961
+ /**
2962
+ * Get a possible element to inspect at a given position.
2963
+ *
2964
+ * @param x - The x coordinate.
2965
+ * @param y - The y coordinate.
2966
+ */
2967
+ inspectPosition(x: number, y: number): InspectedElement | null;
2968
+ /**
2969
+ * Check if the inspected element is still valid.
2970
+ *
2971
+ * @remarks
2972
+ * If a scene destroys and recreates its components upon every reset, the
2973
+ * reference may no longer be valid. Even though the component is still
2974
+ * present. This method should check that and return a new reference.
2975
+ *
2976
+ * @param element - The element to validate.
2977
+ */
2978
+ validateInspection(element: InspectedElement | null): InspectedElement | null;
2979
+ /**
2980
+ * Return the attributes of the inspected element.
2981
+ *
2982
+ * @remarks
2983
+ * This information will be displayed in the "Properties" panel.
2984
+ *
2985
+ * @param element - The element to inspect.
2986
+ */
2987
+ inspectAttributes(element: InspectedElement): InspectedAttributes | null;
2988
+ /**
2989
+ * Draw an overlay for the inspected element.
2990
+ *
2991
+ * @remarks
2992
+ * This method can be used to overlay additional information about an
2993
+ * element on top of the animation.
2994
+ *
2995
+ * @param element - The element for which to draw an overlay.
2996
+ * @param matrix - A local-to-screen matrix.
2997
+ * @param context - The context to draw with.
2998
+ */
2999
+ drawOverlay(element: InspectedElement, matrix: DOMMatrix, context: CanvasRenderingContext2D): void;
3000
+ /**
3001
+ * Transform the absolute mouse coordinates into the scene's coordinate system.
3002
+ *
3003
+ * @param x - The x coordinate.
3004
+ * @param y - The y coordinate.
3005
+ */
3006
+ transformMousePosition(x: number, y: number): Vector2 | null;
3007
+ }
3008
+ declare function isInspectable(value: any): value is Inspectable;
3009
+ //#endregion
3010
+ //#region src/scenes/SceneState.d.ts
3011
+ /**
3012
+ * Describes the state of a scene.
3013
+ */
3014
+ declare enum SceneState {
3015
+ /**
3016
+ * The scene has just been created/reset.
3017
+ */
3018
+ Initial = 0,
3019
+ /**
3020
+ * The scene has finished transitioning in.
3021
+ *
3022
+ * @remarks
3023
+ * Informs the Project that the previous scene is no longer necessary and can
3024
+ * be disposed of.
3025
+ */
3026
+ AfterTransitionIn = 1,
3027
+ /**
3028
+ * The scene is ready to transition out.
3029
+ *
3030
+ * @remarks
3031
+ * Informs the project that the next scene can begin.
3032
+ * The {@link Scene.next} method will still be invoked until the next scene
3033
+ * enters {@link AfterTransitionIn}.
3034
+ */
3035
+ CanTransitionOut = 2,
3036
+ /**
3037
+ * The scene has finished.
3038
+ *
3039
+ * @remarks
3040
+ * Invoking {@link Scene.next} won't have any effect.
3041
+ */
3042
+ Finished = 3
3043
+ }
3044
+ //#endregion
3045
+ //#region src/app/ProjectMetadata.d.ts
3046
+ declare function createProjectMetadata(project: Project): {
3047
+ version: MetaField<unknown, number>;
3048
+ shared: ObjectMetaField<{
3049
+ background: ColorMetaField;
3050
+ range: RangeMetaField;
3051
+ size: Vector2MetaField;
3052
+ audioOffset: NumberMetaField;
3053
+ }>;
3054
+ preview: ObjectMetaField<{
3055
+ fps: NumberMetaField;
3056
+ resolutionScale: EnumMetaField<number>;
3057
+ }>;
3058
+ rendering: ObjectMetaField<{
3059
+ fps: NumberMetaField;
3060
+ resolutionScale: EnumMetaField<number>;
3061
+ colorSpace: EnumMetaField<CanvasColorSpace>;
3062
+ exporter: ExporterMetaField;
3063
+ }>;
3064
+ };
3065
+ declare class ProjectMetadata extends ObjectMetaField<ReturnType<typeof createProjectMetadata>> {
3066
+ constructor(project: Project);
3067
+ getFullPreviewSettings(): {
3068
+ fps: number;
3069
+ resolutionScale: number;
3070
+ background: Color | null;
3071
+ range: [number, number];
3072
+ size: Vector2;
3073
+ audioOffset: number;
3074
+ };
3075
+ getFullRenderingSettings(): {
3076
+ fps: number;
3077
+ resolutionScale: number;
3078
+ colorSpace: CanvasColorSpace;
3079
+ background: Color | null;
3080
+ range: [number, number];
3081
+ size: Vector2;
3082
+ audioOffset: number;
3083
+ exporter: {
3084
+ name: string;
3085
+ options: unknown;
3086
+ };
3087
+ };
3088
+ }
3089
+ //#endregion
3090
+ //#region src/app/SettingsMetadata.d.ts
3091
+ /**
3092
+ * Create a runtime representation of the settings metadata.
3093
+ */
3094
+ declare function createSettingsMetadata(): ObjectMetaField<{
3095
+ version: MetaField<any, number>;
3096
+ appearance: ObjectMetaField<{
3097
+ color: ColorMetaField;
3098
+ font: BoolMetaField;
3099
+ coordinates: BoolMetaField;
3100
+ }>;
3101
+ defaults: ObjectMetaField<{
3102
+ background: ColorMetaField;
3103
+ size: Vector2MetaField;
3104
+ }>;
3105
+ }>;
3106
+ /**
3107
+ * A runtime representation of the settings metadata.
3108
+ */
3109
+ type SettingsMetadata = ReturnType<typeof createSettingsMetadata>;
3110
+ //#endregion
3111
+ //#region src/app/Project.d.ts
3112
+ interface ProjectSettings {
3113
+ /**
3114
+ * The name of the project.
3115
+ */
3116
+ name?: string;
3117
+ /**
3118
+ * A list of scene descriptions that make up the project.
3119
+ *
3120
+ * @remarks
3121
+ * A full scene description can be obtained by loading a scene module with a
3122
+ * `?scene` query parameter.
3123
+ *
3124
+ * @example
3125
+ * ```ts
3126
+ * import exampleScene from './example?scene';
3127
+ *
3128
+ * export default makeProject({
3129
+ * scenes: [exampleScene],
3130
+ * });
3131
+ * ```
3132
+ */
3133
+ scenes: FullSceneDescription[];
3134
+ /**
3135
+ * A list of plugins to include in the project.
3136
+ *
3137
+ * @remarks
3138
+ * When a string is provided, the plugin will be imported dynamically using
3139
+ * the string as the module specifier. This is the preferred way to include
3140
+ * editor plugins because it makes sure that the plugin's source code gets
3141
+ * excluded from the production build.
3142
+ */
3143
+ plugins?: (Plugin | string)[];
3144
+ /**
3145
+ * A custom logger instance to use.
3146
+ */
3147
+ logger?: Logger;
3148
+ /**
3149
+ * An url for the audio track to play alongside the animation.
3150
+ *
3151
+ * @see https://canvascommons.io/docs/media#audio
3152
+ */
3153
+ audio?: string;
3154
+ /**
3155
+ * @deprecated Configure the offset in the Video Settings tab of th editor.
3156
+ */
3157
+ audioOffset?: number;
3158
+ /**
3159
+ * Default values for project variables.
3160
+ *
3161
+ * @see https://canvascommons.io/docs/project-variables
3162
+ */
3163
+ variables?: Record<string, unknown>;
3164
+ /**
3165
+ * Enable experimental features.
3166
+ *
3167
+ * @see https://canvascommons.io/docs/experimental
3168
+ *
3169
+ * @experimental
3170
+ */
3171
+ experimentalFeatures?: boolean;
3172
+ }
3173
+ interface Versions {
3174
+ core: string;
3175
+ two: string | null;
3176
+ ui: string | null;
3177
+ vitePlugin: string | null;
3178
+ }
3179
+ interface Project {
3180
+ name: string;
3181
+ scenes: FullSceneDescription[];
3182
+ plugins: Plugin[];
3183
+ logger: Logger;
3184
+ meta: ProjectMetadata;
3185
+ settings: SettingsMetadata;
3186
+ audio?: string;
3187
+ variables?: Record<string, unknown>;
3188
+ versions: Versions;
3189
+ experimentalFeatures: boolean;
3190
+ }
3191
+ declare function makeProject(settings: ProjectSettings): ProjectSettings;
3192
+ //#endregion
3193
+ //#region src/app/bootstrap.d.ts
3194
+ /**
3195
+ * Bootstrap a project.
3196
+ *
3197
+ * @param name - The name of the project.
3198
+ * @param versions - Package versions.
3199
+ * @param plugins - Loaded plugins.
3200
+ * @param config - Project settings.
3201
+ * @param metaFile - The project meta file.
3202
+ * @param settingsFile - The settings meta file.
3203
+ * @param logger - An optional logger instance.
3204
+ * @param pluginResolutions - Mapping from the plugin name to the plugin instance.
3205
+ *
3206
+ * @internal
3207
+ */
3208
+ declare function bootstrap(name: string, versions: Versions, plugins: PluginLike[], config: ProjectSettings, metaFile: MetaFile<any>, settingsFile: MetaFile<any>, logger?: Logger, pluginResolutions?: Map<string, Plugin>): Project;
3209
+ /**
3210
+ * Bootstrap a project together with all editor plugins.
3211
+ *
3212
+ * @param name - The name of the project.
3213
+ * @param versions - Package versions.
3214
+ * @param plugins - Loaded plugins.
3215
+ * @param config - Project settings.
3216
+ * @param metaFile - The project meta file.
3217
+ * @param settingsFile - The settings meta file.
3218
+ *
3219
+ * @internal
3220
+ */
3221
+ declare function editorBootstrap(name: string, versions: Versions, plugins: PluginLike[], config: ProjectSettings, metaFile: MetaFile<any>, settingsFile: MetaFile<any>): Promise<Project>;
3222
+ type PluginLike = Plugin | string;
3223
+ //#endregion
3224
+ //#region src/app/Stage.d.ts
3225
+ interface StageSettings {
3226
+ size: Vector2;
3227
+ resolutionScale: number;
3228
+ colorSpace: CanvasColorSpace;
3229
+ background: Color | string | null;
3230
+ }
3231
+ /**
3232
+ * Manages canvases on which an animation can be displayed.
3233
+ */
3234
+ declare class Stage {
3235
+ private background;
3236
+ private resolutionScale;
3237
+ private colorSpace;
3238
+ private size;
3239
+ readonly finalBuffer: HTMLCanvasElement;
3240
+ private readonly currentBuffer;
3241
+ private readonly previousBuffer;
3242
+ context: CanvasRenderingContext2D;
3243
+ private currentContext;
3244
+ private previousContext;
3245
+ private get canvasSize();
3246
+ constructor();
3247
+ configure({
3248
+ colorSpace,
3249
+ size,
3250
+ resolutionScale,
3251
+ background
3252
+ }: Partial<StageSettings>): void;
3253
+ render(currentScene: Scene, previousScene: Scene | null): Promise<void>;
3254
+ resizeCanvas(context: CanvasRenderingContext2D): void;
3255
+ }
3256
+ //#endregion
3257
+ //#region src/app/TimeEstimator.d.ts
3258
+ /**
3259
+ * An estimate of the time remaining until the process is finished.
3260
+ */
3261
+ interface TimeEstimate {
3262
+ /**
3263
+ * The completion percentage ranging from `0` to `1`.
3264
+ */
3265
+ completion: number;
3266
+ /**
3267
+ * The time passed since the beginning of the process in milliseconds.
3268
+ */
3269
+ elapsed: number;
3270
+ /**
3271
+ * The estimated time remaining until the process is finished in milliseconds.
3272
+ */
3273
+ eta: number;
3274
+ }
3275
+ /**
3276
+ * Calculates the estimated time remaining until a process is finished.
3277
+ */
3278
+ declare class TimeEstimator {
3279
+ get onCompletionChanged(): SubscribableValueEvent<number>;
3280
+ private readonly completion;
3281
+ private startTimestamp;
3282
+ private lastUpdateTimestamp;
3283
+ private nextCompletion;
3284
+ /**
3285
+ * Get the current time estimate.
3286
+ *
3287
+ * @param timestamp - The timestamp to calculate the estimate against.
3288
+ * Defaults to `performance.now()`.
3289
+ */
3290
+ estimate(timestamp?: number): TimeEstimate;
3291
+ /**
3292
+ * Update the completion percentage.
3293
+ *
3294
+ * @param completion - The completion percentage ranging from `0` to `1`.
3295
+ * @param timestamp - A timestamp at which the process was updated.
3296
+ * Defaults to `performance.now()`.
3297
+ */
3298
+ update(completion: number, timestamp?: number): void;
3299
+ /**
3300
+ * Reset the estimator.
3301
+ *
3302
+ * @param nextCompletion - If known, the completion percentage of the next
3303
+ * update.
3304
+ * @param timestamp - A timestamp at which the process started.
3305
+ * Defaults to `performance.now()`.
3306
+ */
3307
+ reset(nextCompletion?: number, timestamp?: number): void;
3308
+ }
3309
+ //#endregion
3310
+ //#region src/app/Renderer.d.ts
3311
+ interface RendererSettings extends StageSettings {
3312
+ name: string;
3313
+ range: [number, number];
3314
+ fps: number;
3315
+ exporter: {
3316
+ name: string;
3317
+ options: unknown;
3318
+ };
3319
+ }
3320
+ declare enum RendererState {
3321
+ Initial = 0,
3322
+ Working = 1,
3323
+ Aborting = 2
3324
+ }
3325
+ declare enum RendererResult {
3326
+ Success = 0,
3327
+ Error = 1,
3328
+ Aborted = 2
3329
+ }
3330
+ /**
3331
+ * The rendering logic used by the editor to export animations.
3332
+ *
3333
+ * @remarks
3334
+ * This class uses the `PlaybackManager` to render animations. In contrast to a
3335
+ * player, a renderer does not use an update loop. It plays through the
3336
+ * animation as fast as it can, occasionally pausing to keep the UI responsive.
3337
+ *
3338
+ * The actual exporting is outsourced to an {@link Exporter}.
3339
+ */
3340
+ declare class Renderer {
3341
+ private project;
3342
+ get onStateChanged(): SubscribableValueEvent<RendererState>;
3343
+ private readonly state;
3344
+ get onFinished(): Subscribable<RendererResult, EventHandler<RendererResult>>;
3345
+ private readonly finished;
3346
+ get onFrameChanged(): SubscribableValueEvent<number>;
3347
+ private readonly frame;
3348
+ readonly stage: Stage;
3349
+ readonly estimator: TimeEstimator;
3350
+ private readonly lock;
3351
+ private readonly playback;
3352
+ private readonly status;
3353
+ private readonly sharedWebGLContext;
3354
+ private exporter;
3355
+ private abortController;
3356
+ constructor(project: Project);
3357
+ /**
3358
+ * Render the animation using the provided settings.
3359
+ *
3360
+ * @param settings - The rendering settings.
3361
+ */
3362
+ render(settings: RendererSettings): Promise<void>;
3363
+ /**
3364
+ * Abort the ongoing render process.
3365
+ */
3366
+ abort(): void;
3367
+ /**
3368
+ * Export an individual frame.
3369
+ *
3370
+ * @remarks
3371
+ * This method always uses the default `ImageExporter`.
3372
+ *
3373
+ * @param settings - The rendering settings.
3374
+ * @param time - The timestamp to export.
3375
+ */
3376
+ renderFrame(settings: RendererSettings, time: number): Promise<void>;
3377
+ private run;
3378
+ private reloadScenes;
3379
+ private collectSounds;
3380
+ private exportFrame;
3381
+ }
3382
+ //#endregion
3383
+ //#region src/app/Exporter.d.ts
3384
+ /**
3385
+ * The static interface for exporters.
3386
+ */
3387
+ interface ExporterClass {
3388
+ /**
3389
+ * The unique identifier of this exporter.
3390
+ *
3391
+ * @remarks
3392
+ * This identifier will be used to store the settings of this exporter.
3393
+ * It's recommended to prepend it with the name of the package to avoid
3394
+ * collisions.
3395
+ */
3396
+ readonly id: string;
3397
+ /**
3398
+ * The name of this exporter.
3399
+ *
3400
+ * @remarks
3401
+ * This name will be displayed in the editor.
3402
+ */
3403
+ readonly displayName: string;
3404
+ /**
3405
+ * Create an instance of this exporter.
3406
+ *
3407
+ * @remarks
3408
+ * A new exporter is created whenever the user starts a new rendering process.
3409
+ *
3410
+ * @param project - The current project.
3411
+ * @param settings - The rendering settings.
3412
+ */
3413
+ create(project: Project, settings: RendererSettings): Promise<Exporter>;
3414
+ /**
3415
+ * Create a meta field representing the options of this exporter.
3416
+ */
3417
+ meta(project: Project): MetaField<any>;
3418
+ }
3419
+ /**
3420
+ * The main interface for implementing custom exporters.
3421
+ */
3422
+ interface Exporter {
3423
+ /**
3424
+ * Prepare the rendering configuration.
3425
+ *
3426
+ * @remarks
3427
+ * Called at the beginning of the rendering process, before anything else has
3428
+ * been set up. The returned value can be used to override the rendering
3429
+ * settings provided by the user.
3430
+ */
3431
+ configuration?(): Promise<RendererSettings | void>;
3432
+ /**
3433
+ * Begin the rendering process.
3434
+ *
3435
+ * @remarks
3436
+ * Called after the rendering has been set up, right before the first frame
3437
+ * is rendered. Once `start()` is called, it is guaranteed that the `stop()`
3438
+ * method will be called as well. Can be used to initialize any resources that
3439
+ * require a clean-up.
3440
+ *
3441
+ * @param sounds - The sounds to be played during the animation.
3442
+ * @param duration - The duration of the animation in frames.
3443
+ */
3444
+ start?(sounds: Sound[], duration: number): Promise<void>;
3445
+ /**
3446
+ * Export a frame.
3447
+ *
3448
+ * @remarks
3449
+ * Called each time after a frame is rendered.
3450
+ *
3451
+ * @param canvas - A canvas containing the rendered frame.
3452
+ * @param frame - The frame number.
3453
+ * @param sceneFrame - The frame number within the scene.
3454
+ * @param sceneName - The name of the scene with which the frame is associated.
3455
+ * @param signal - An abort signal triggered if the user aborts the rendering.
3456
+ * @param context - A 2D rendering context for the canvas.
3457
+ */
3458
+ handleFrame(canvas: HTMLCanvasElement, frame: number, sceneFrame: number, sceneName: string, signal: AbortSignal, context: CanvasRenderingContext2D): Promise<void>;
3459
+ /**
3460
+ * Finish the rendering process.
3461
+ *
3462
+ * @remarks
3463
+ * Guaranteed to be called after the rendering has finished - no matter the
3464
+ * result. Can be used to finalize the exporting and perform any necessary
3465
+ * clean-up.
3466
+ *
3467
+ * @param result - The result of the rendering.
3468
+ */
3469
+ stop?(result: RendererResult): Promise<void>;
3470
+ }
3471
+ //#endregion
3472
+ //#region src/app/ImageExporter.d.ts
3473
+ /**
3474
+ * Image sequence exporter.
3475
+ *
3476
+ * @internal
3477
+ */
3478
+ declare class ImageExporter implements Exporter {
3479
+ private readonly logger;
3480
+ private readonly settings;
3481
+ static readonly id = "@canvas-commons/core/image-sequence";
3482
+ static readonly displayName = "Image sequence";
3483
+ static meta(): ObjectMetaField<{
3484
+ fileType: EnumMetaField<CanvasOutputMimeType>;
3485
+ quality: NumberMetaField;
3486
+ groupByScene: BoolMetaField;
3487
+ }>;
3488
+ static create(project: Project, settings: RendererSettings): Promise<ImageExporter>;
3489
+ private static readonly response;
3490
+ private readonly frameLookup;
3491
+ private readonly projectName;
3492
+ private readonly quality;
3493
+ private readonly fileType;
3494
+ private readonly groupByScene;
3495
+ constructor(logger: Logger, settings: RendererSettings);
3496
+ start(): Promise<void>;
3497
+ handleFrame(canvas: HTMLCanvasElement, frame: number, sceneFrame: number, sceneName: string, signal: AbortSignal): Promise<void>;
3498
+ stop(): Promise<void>;
3499
+ private handleResponse;
3500
+ }
3501
+ //#endregion
3502
+ //#region src/app/PlaybackManager.d.ts
3503
+ declare enum PlaybackState {
3504
+ Playing = 0,
3505
+ Rendering = 1,
3506
+ Paused = 2,
3507
+ Presenting = 3
3508
+ }
3509
+ /**
3510
+ * A general class for managing a sequence of scenes.
3511
+ *
3512
+ * @remarks
3513
+ * This class provides primitive operations that can be executed on a scene
3514
+ * sequence, such as {@link progress} or {@link seek}.
3515
+ *
3516
+ * @internal
3517
+ */
3518
+ declare class PlaybackManager {
3519
+ /**
3520
+ * Triggered when the active scene changes.
3521
+ *
3522
+ * @eventProperty
3523
+ */
3524
+ get onSceneChanged(): SubscribableValueEvent<Scene<unknown>>;
3525
+ /**
3526
+ * Triggered when the scenes get recalculated.
3527
+ *
3528
+ * @remarks
3529
+ * This event indicates that the timing of at least one scene has changed.
3530
+ *
3531
+ * @eventProperty
3532
+ */
3533
+ get onScenesRecalculated(): SubscribableValueEvent<Scene<unknown>[]>;
3534
+ frame: number;
3535
+ speed: number;
3536
+ fps: number;
3537
+ duration: number;
3538
+ finished: boolean;
3539
+ slides: Slide[];
3540
+ previousScene: Scene | null;
3541
+ state: PlaybackState;
3542
+ get currentScene(): Scene;
3543
+ set currentScene(scene: Scene);
3544
+ private currentSceneReference;
3545
+ private scenes;
3546
+ setup(scenes: Scene[]): void;
3547
+ progress(): Promise<boolean>;
3548
+ seek(frame: number): Promise<boolean>;
3549
+ goBack(): Promise<void>;
3550
+ goForward(): Promise<void>;
3551
+ goTo(slideId: string): Promise<void>;
3552
+ private seekSlide;
3553
+ reset(): Promise<void>;
3554
+ reload(description?: SceneDescriptionReload<never>): void;
3555
+ recalculate(): Promise<void>;
3556
+ private next;
3557
+ private findBestScene;
3558
+ private getNextScene;
3559
+ }
3560
+ //#endregion
3561
+ //#region src/app/PlaybackStatus.d.ts
3562
+ /**
3563
+ * A read-only representation of the playback.
3564
+ */
3565
+ declare class PlaybackStatus {
3566
+ private readonly playback;
3567
+ constructor(playback: PlaybackManager);
3568
+ /**
3569
+ * Convert seconds to frames using the current framerate.
3570
+ *
3571
+ * @param seconds - The seconds to convert.
3572
+ */
3573
+ secondsToFrames(seconds: number): number;
3574
+ /**
3575
+ * Convert frames to seconds using the current framerate.
3576
+ *
3577
+ * @param frames - The frames to convert.
3578
+ */
3579
+ framesToSeconds(frames: number): number;
3580
+ get time(): number;
3581
+ get frame(): number;
3582
+ get speed(): number;
3583
+ get fps(): number;
3584
+ get state(): PlaybackState;
3585
+ /**
3586
+ * The time passed since the last frame in seconds.
3587
+ */
3588
+ get deltaTime(): number;
3589
+ }
3590
+ //#endregion
3591
+ //#region src/media/AudioData.d.ts
3592
+ interface AudioData {
3593
+ /**
3594
+ * An array of minimum and maximum waveform data points, interleaved.
3595
+ * Each value is in range of -1 to 1.
3596
+ */
3597
+ peaks: number[];
3598
+ /**
3599
+ * The amount of samples taken.
3600
+ */
3601
+ length: number;
3602
+ /**
3603
+ * The absolute biggest value from the peaks array.
3604
+ */
3605
+ absoluteMax: number;
3606
+ /**
3607
+ * Samples per seconds.
3608
+ */
3609
+ sampleRate: number;
3610
+ /**
3611
+ * The duration of the audio in seconds.
3612
+ */
3613
+ duration: number;
3614
+ }
3615
+ declare const EMPTY_AUDIO_DATA: AudioData;
3616
+ //#endregion
3617
+ //#region src/media/AudioManager.d.ts
3618
+ declare class AudioManager {
3619
+ private readonly logger;
3620
+ private readonly context;
3621
+ private readonly audioElement;
3622
+ private source;
3623
+ private error;
3624
+ private offset;
3625
+ private start?;
3626
+ private duration?;
3627
+ private gainNode?;
3628
+ private sourceNode?;
3629
+ constructor(logger: Logger, context: AudioContext);
3630
+ setSound(sound: Sound): void;
3631
+ getTime(): number;
3632
+ setTime(value: number): void;
3633
+ setTrim(start?: number, end?: number): void;
3634
+ setOffset(value: number): void;
3635
+ setPlaybackRate(value: number, pitchShift?: boolean): void;
3636
+ setMuted(isMuted: boolean): void;
3637
+ setVolume(volume: number): void;
3638
+ getSource(): string | null;
3639
+ setSource(src: string): void;
3640
+ isInRange(time: number): boolean;
3641
+ toRelativeTime(time: number): number;
3642
+ toAbsoluteTime(time: number): number;
3643
+ isReady(): boolean | "" | null;
3644
+ /**
3645
+ * Pause/resume the audio.
3646
+ *
3647
+ * @param isPaused - Whether the audio should be paused or resumed.
3648
+ *
3649
+ * @returns `true` if the audio successfully started playing.
3650
+ */
3651
+ setPaused(isPaused: boolean): Promise<boolean>;
3652
+ dispose(): void;
3653
+ }
3654
+ //#endregion
3655
+ //#region src/media/AudioResourceManager.d.ts
3656
+ declare class AudioResourceManager {
3657
+ private readonly logger;
3658
+ private readonly context;
3659
+ private readonly lookup;
3660
+ constructor(logger: Logger);
3661
+ peekDuration(source: string): number;
3662
+ get(source: string): AudioResource;
3663
+ }
3664
+ declare class AudioResource {
3665
+ private readonly logger;
3666
+ private readonly source;
3667
+ private readonly context;
3668
+ get onData(): SubscribableValueEvent<AudioData>;
3669
+ private readonly data;
3670
+ private abort;
3671
+ constructor(logger: Logger, source: string, context: AudioContext);
3672
+ reload(): Promise<void>;
3673
+ private loadData;
3674
+ private decodeAudioData;
3675
+ }
3676
+ //#endregion
3677
+ //#region src/media/AudioManagerPool.d.ts
3678
+ declare class AudioManagerPool {
3679
+ private readonly logger;
3680
+ private readonly audioResources;
3681
+ private readonly context;
3682
+ private pool;
3683
+ private managers;
3684
+ private sounds;
3685
+ private muted;
3686
+ private volume;
3687
+ private paused;
3688
+ constructor(logger: Logger, audioResources: AudioResourceManager);
3689
+ setupPool(sounds: Sound[]): Promise<void>;
3690
+ setMuted(muted: boolean): void;
3691
+ setVolume(volume: number): void;
3692
+ setTime(time: number): void;
3693
+ setPaused(paused: boolean): Promise<void>;
3694
+ private isInRange;
3695
+ prepare(time: number): void;
3696
+ spawn(): AudioManager;
3697
+ resume(): void;
3698
+ }
3699
+ //#endregion
3700
+ //#region src/media/loadImage.d.ts
3701
+ type ImageDataSource = CanvasImageSource & {
3702
+ width: number;
3703
+ height: number;
3704
+ };
3705
+ declare function loadImage(source: string): Promise<HTMLImageElement>;
3706
+ declare function loadAnimation(sources: string[]): Promise<HTMLImageElement[]>;
3707
+ declare function getImageData(image: ImageDataSource): ImageData;
3708
+ //#endregion
3709
+ //#region src/app/Player.d.ts
3710
+ interface PlayerState extends Record<string, unknown> {
3711
+ paused: boolean;
3712
+ loop: boolean;
3713
+ muted: boolean;
3714
+ volume: number;
3715
+ speed: number;
3716
+ }
3717
+ interface PlayerSettings {
3718
+ range: [number, number];
3719
+ fps: number;
3720
+ size: Vector2;
3721
+ audioOffset: number;
3722
+ resolutionScale: number;
3723
+ }
3724
+ /**
3725
+ * The player logic used by the editor and embeddable player.
3726
+ *
3727
+ * @remarks
3728
+ * This class builds on top of the `PlaybackManager` to provide a simple
3729
+ * interface similar to other media players. It plays through the animation
3730
+ * using a real-time update loop and optionally synchronises it with audio.
3731
+ */
3732
+ declare class Player {
3733
+ private project;
3734
+ private settings;
3735
+ private initialState;
3736
+ private initialFrame;
3737
+ /**
3738
+ * Triggered during each iteration of the update loop when the frame is ready
3739
+ * to be rendered.
3740
+ *
3741
+ * @remarks
3742
+ * Player does not perform any rendering on its own. For the animation to be
3743
+ * visible, another class must subscribe to this event and perform the
3744
+ * rendering itself. {@link Stage} can be used to display the animation.
3745
+ *
3746
+ * @eventProperty
3747
+ */
3748
+ get onRender(): Subscribable<void, AsyncEventHandler<void>>;
3749
+ private readonly render;
3750
+ get onStateChanged(): SubscribableValueEvent<PlayerState>;
3751
+ private readonly playerState;
3752
+ get onFrameChanged(): SubscribableValueEvent<number>;
3753
+ private readonly frame;
3754
+ get onDurationChanged(): SubscribableValueEvent<number>;
3755
+ private readonly duration;
3756
+ /**
3757
+ * Triggered right after recalculation finishes.
3758
+ *
3759
+ * @remarks
3760
+ * Can be used to provide visual feedback.
3761
+ *
3762
+ * @eventProperty
3763
+ */
3764
+ get onRecalculated(): Subscribable<void, EventHandler<void>>;
3765
+ private readonly recalculated;
3766
+ readonly playback: PlaybackManager;
3767
+ readonly status: PlaybackStatus;
3768
+ readonly audio: AudioManager;
3769
+ readonly audioPool: AudioManagerPool;
3770
+ readonly audioResources: AudioResourceManager;
3771
+ readonly logger: Logger;
3772
+ private readonly sharedWebGLContext;
3773
+ private readonly lock;
3774
+ private startTime;
3775
+ private endTime;
3776
+ private requestId;
3777
+ private renderTime;
3778
+ private requestedSeek;
3779
+ private requestedRender;
3780
+ private requestedRecalculation;
3781
+ private size;
3782
+ private resolutionScale;
3783
+ private active;
3784
+ private get startFrame();
3785
+ private get endFrame();
3786
+ private get finished();
3787
+ constructor(project: Project, settings?: Partial<PlayerSettings>, initialState?: Partial<PlayerState>, initialFrame?: number);
3788
+ configure(settings: PlayerSettings): Promise<void>;
3789
+ /**
3790
+ * Whether the given frame is inside the animation range.
3791
+ *
3792
+ * @param frame - The frame to check.
3793
+ */
3794
+ isInRange(frame: number): boolean;
3795
+ /**
3796
+ * Whether the given frame is inside the user-defined range.
3797
+ *
3798
+ * @param frame - The frame to check.
3799
+ */
3800
+ isInUserRange(frame: number): boolean;
3801
+ requestSeek(value: number): void;
3802
+ requestPreviousFrame(): void;
3803
+ requestNextFrame(): void;
3804
+ requestReset(): void;
3805
+ requestRender(): void;
3806
+ toggleLoop(value?: boolean): void;
3807
+ togglePlayback(value?: boolean): void;
3808
+ toggleAudio(value?: boolean): void;
3809
+ setAudioVolume(value: number): void;
3810
+ addAudioVolume(value: number): void;
3811
+ setSpeed(value: number): void;
3812
+ setVariables(variables: Record<string, unknown>): void;
3813
+ /**
3814
+ * Activate the player.
3815
+ *
3816
+ * @remarks
3817
+ * A player needs to be active in order for the update loop to run. Each
3818
+ * player is active by default.
3819
+ */
3820
+ activate(): void;
3821
+ /**
3822
+ * Deactivate the player.
3823
+ *
3824
+ * @remarks
3825
+ * Deactivating the player prevents its update loop from running. This should
3826
+ * be done before disposing the player, to prevent it from running in the
3827
+ * background.
3828
+ *
3829
+ * Just pausing the player does not stop the loop.
3830
+ */
3831
+ deactivate(): void;
3832
+ private requestRecalculation;
3833
+ private prepare;
3834
+ private run;
3835
+ private request;
3836
+ clampRange(frame: number): number;
3837
+ private syncAudio;
3838
+ }
3839
+ //#endregion
3840
+ //#region src/app/Presenter.d.ts
3841
+ interface PresenterSettings extends StageSettings {
3842
+ name: string;
3843
+ fps: number;
3844
+ slide: string | null;
3845
+ }
3846
+ interface PresenterInfo extends Record<string, unknown> {
3847
+ currentSlideId: string | null;
3848
+ nextSlideId: string | null;
3849
+ hasNext: boolean;
3850
+ hasPrevious: boolean;
3851
+ isWaiting: boolean;
3852
+ count: number;
3853
+ index: number | null;
3854
+ }
3855
+ declare enum PresenterState {
3856
+ Initial = 0,
3857
+ Working = 1,
3858
+ Aborting = 2
3859
+ }
3860
+ declare class Presenter {
3861
+ private project;
3862
+ get onStateChanged(): SubscribableValueEvent<PresenterState>;
3863
+ private readonly state;
3864
+ get onInfoChanged(): SubscribableValueEvent<PresenterInfo>;
3865
+ private readonly info;
3866
+ get onSlidesChanged(): SubscribableValueEvent<Slide[]>;
3867
+ private readonly slides;
3868
+ readonly stage: Stage;
3869
+ private readonly lock;
3870
+ readonly playback: PlaybackManager;
3871
+ private readonly status;
3872
+ private readonly logger;
3873
+ private readonly sharedWebGLContext;
3874
+ private abortController;
3875
+ private renderTime;
3876
+ private requestId;
3877
+ private requestedResume;
3878
+ private requestedSlide;
3879
+ constructor(project: Project);
3880
+ /**
3881
+ * Present the animation.
3882
+ *
3883
+ * @param settings - The presentation settings.
3884
+ */
3885
+ present(settings: PresenterSettings): Promise<void>;
3886
+ /**
3887
+ * Abort the ongoing presentation process.
3888
+ */
3889
+ abort(): void;
3890
+ /**
3891
+ * Resume the presentation if waiting for the next slide.
3892
+ */
3893
+ resume(): void;
3894
+ requestFirstSlide(): void;
3895
+ requestLastSlide(): void;
3896
+ requestPreviousSlide(): void;
3897
+ requestNextSlide(): void;
3898
+ requestSlide(id: string): void;
3899
+ private run;
3900
+ private reloadScenes;
3901
+ private loop;
3902
+ private request;
3903
+ private updateInfo;
3904
+ }
3905
+ //#endregion
3906
+ //#region src/meta/ExporterMetaFile.d.ts
3907
+ /**
3908
+ * Represents the exporter configuration.
3909
+ */
3910
+ declare class ExporterMetaField extends MetaField<{
3911
+ name: string;
3912
+ options: unknown;
3913
+ }> {
3914
+ private current;
3915
+ readonly type: ObjectConstructor;
3916
+ /**
3917
+ * Triggered when the nested fields change.
3918
+ *
3919
+ * @eventProperty
3920
+ */
3921
+ get onFieldsChanged(): SubscribableValueEvent<MetaField<any, any>[]>;
3922
+ private readonly fields;
3923
+ get options(): MetaField<any> | undefined;
3924
+ private readonly exporterField;
3925
+ private readonly optionFields;
3926
+ readonly exporters: ExporterClass[];
3927
+ constructor(name: string, project: Project, current?: number);
3928
+ set(value: {
3929
+ name: string;
3930
+ options: any;
3931
+ }): void;
3932
+ serialize(): {
3933
+ name: string;
3934
+ options: any;
3935
+ };
3936
+ clone(): this;
3937
+ private handleChange;
3938
+ }
3939
+ //#endregion
3940
+ //#region src/meta/MetaFile.d.ts
3941
+ /**
3942
+ * Represents the meta file of a given entity.
3943
+ *
3944
+ * @remarks
3945
+ * This class is used exclusively by our Vite plugin as a bridge between
3946
+ * physical files and their runtime representation.
3947
+ *
3948
+ * @typeParam T - The type of the data stored in the meta file.
3949
+ *
3950
+ * @internal
3951
+ */
3952
+ declare class MetaFile<T> {
3953
+ private readonly name;
3954
+ private source;
3955
+ private readonly lock;
3956
+ private ignoreChange;
3957
+ private cache;
3958
+ private metaField;
3959
+ constructor(name: string, source?: string | false);
3960
+ attach(field: MetaField<T>): void;
3961
+ protected handleChanged: () => Promise<void>;
3962
+ private saveData;
3963
+ /**
3964
+ * Load new metadata from a file.
3965
+ *
3966
+ * @remarks
3967
+ * This method is called during hot module replacement.
3968
+ *
3969
+ * @param data - New metadata.
3970
+ */
3971
+ loadData(data: T): void;
3972
+ private static sourceLookup;
3973
+ }
3974
+ //#endregion
3975
+ //#region src/meta/NumberMetaField.d.ts
3976
+ /**
3977
+ * Represents a number stored in a meta file.
3978
+ */
3979
+ declare class NumberMetaField extends MetaField<any, number> {
3980
+ readonly type: NumberConstructor;
3981
+ protected presets: MetaOption<number>[];
3982
+ protected min: number;
3983
+ protected max: number;
3984
+ protected precision: number;
3985
+ protected step: number;
3986
+ parse(value: any): number;
3987
+ getPresets(): MetaOption<number>[];
3988
+ setPresets(options: MetaOption<number>[]): this;
3989
+ setRange(min?: number, max?: number): this;
3990
+ getMin(): number;
3991
+ getMax(): number;
3992
+ setPrecision(precision: number): this;
3993
+ getPrecision(): number;
3994
+ setStep(step: number): this;
3995
+ getStep(): number;
3996
+ }
3997
+ //#endregion
3998
+ //#region src/meta/RangeMetaField.d.ts
3999
+ /**
4000
+ * Represents a range stored in a meta file.
4001
+ *
4002
+ * @remarks
4003
+ * Range is an array with two elements denoting the beginning and end of a
4004
+ * range, respectively.
4005
+ */
4006
+ declare class RangeMetaField extends MetaField<[number, number | null], [number, number]> {
4007
+ static readonly symbol: unique symbol;
4008
+ readonly type: symbol;
4009
+ parse(value: [number, number | null]): [number, number];
4010
+ /**
4011
+ * Convert the given range from frames to seconds and update this field.
4012
+ *
4013
+ * @remarks
4014
+ * This helper method applies additional validation to the range, preventing
4015
+ * it from overflowing the timeline.
4016
+ *
4017
+ * @param startFrame - The beginning of the range.
4018
+ * @param endFrame - The end of the range.
4019
+ * @param duration - The current duration in frames.
4020
+ * @param fps - The current framerate.
4021
+ */
4022
+ update(startFrame: number, endFrame: number, duration: number, fps: number): void;
4023
+ protected parseRange(duration: number, startFrame?: number, endFrame?: number): [number, number];
4024
+ }
4025
+ //#endregion
4026
+ //#region src/meta/StringMetaField.d.ts
4027
+ /**
4028
+ * Represents a string stored in a meta file.
4029
+ */
4030
+ declare class StringMetaField<T extends string = string> extends MetaField<T> {
4031
+ readonly type: StringConstructor;
4032
+ protected presets: MetaOption<T>[];
4033
+ getPresets(): MetaOption<T>[];
4034
+ setPresets(options: MetaOption<T>[]): this;
4035
+ }
4036
+ //#endregion
4037
+ //#region src/meta/Vector2MetaField.d.ts
4038
+ /**
4039
+ * Represents a two-dimensional vector stored in a meta file.
4040
+ */
4041
+ declare class Vector2MetaField extends MetaField<PossibleVector2, Vector2> {
4042
+ readonly type: symbol;
4043
+ parse(value: PossibleVector2): Vector2;
4044
+ serialize(): PossibleVector2;
4045
+ }
4046
+ //#endregion
4047
+ //#region src/decorators/decorate.d.ts
4048
+ declare function decorate(fn: Callback, ...decorators: MethodDecorator[]): void;
4049
+ //#endregion
4050
+ //#region src/decorators/lazy.d.ts
4051
+ /**
4052
+ * Create a lazy decorator.
4053
+ *
4054
+ * @remarks
4055
+ * A property marked as lazy will not be initialized until it's requested for
4056
+ * the first time. Lazy properties are read-only.
4057
+ *
4058
+ * Must be used for any static properties that require the DOM API to be
4059
+ * initialized.
4060
+ *
4061
+ * @param factory - A function that returns the value of this property.
4062
+ */
4063
+ declare function lazy(factory: () => unknown): PropertyDecorator;
4064
+ //#endregion
4065
+ //#region src/decorators/threadable.d.ts
4066
+ declare function threadable(customName?: string): MethodDecorator;
4067
+ //#endregion
4068
+ //#region src/flow/all.d.ts
4069
+ /**
4070
+ * Run all tasks concurrently and wait for all of them to finish.
4071
+ *
4072
+ * @example
4073
+ * ```ts
4074
+ * // current time: 0s
4075
+ * yield* all(
4076
+ * rect.fill('#ff0000', 2),
4077
+ * rect.opacity(1, 1),
4078
+ * );
4079
+ * // current time: 2s
4080
+ * ```
4081
+ *
4082
+ * @param tasks - A list of tasks to run.
4083
+ */
4084
+ declare function all(...tasks: ThreadGenerator[]): ThreadGenerator;
4085
+ //#endregion
4086
+ //#region src/flow/any.d.ts
4087
+ /**
4088
+ * Run all tasks concurrently and wait for any of them to finish.
4089
+ *
4090
+ * @example
4091
+ * ```ts
4092
+ * // current time: 0s
4093
+ * yield* any(
4094
+ * rect.fill('#ff0000', 2),
4095
+ * rect.opacity(1, 1),
4096
+ * );
4097
+ * // current time: 1s
4098
+ * ```
4099
+ *
4100
+ * @param tasks - A list of tasks to run.
4101
+ */
4102
+ declare function any(...tasks: ThreadGenerator[]): ThreadGenerator;
4103
+ //#endregion
4104
+ //#region src/flow/chain.d.ts
4105
+ /**
4106
+ * Run tasks one after another.
4107
+ *
4108
+ * @example
4109
+ * ```ts
4110
+ * // current time: 0s
4111
+ * yield* chain(
4112
+ * rect.fill('#ff0000', 2),
4113
+ * rect.opacity(1, 1),
4114
+ * );
4115
+ * // current time: 3s
4116
+ * ```
4117
+ *
4118
+ * Note that the same animation can be written as:
4119
+ * ```ts
4120
+ * yield* rect.fill('#ff0000', 2),
4121
+ * yield* rect.opacity(1, 1),
4122
+ * ```
4123
+ *
4124
+ * The reason `chain` exists is to make it easier to pass it to other flow
4125
+ * functions. For example:
4126
+ * ```ts
4127
+ * yield* all(
4128
+ * rect.radius(20, 3),
4129
+ * chain(
4130
+ * rect.fill('#ff0000', 2),
4131
+ * rect.opacity(1, 1),
4132
+ * ),
4133
+ * );
4134
+ * ```
4135
+ *
4136
+ * @param tasks - A list of tasks to run.
4137
+ */
4138
+ declare function chain(...tasks: (ThreadGenerator | Callback)[]): ThreadGenerator;
4139
+ //#endregion
4140
+ //#region src/flow/delay.d.ts
4141
+ /**
4142
+ * Run the given generator or callback after a specific amount of time.
4143
+ *
4144
+ * @example
4145
+ * ```ts
4146
+ * yield* delay(1, rect.fill('#ff0000', 2));
4147
+ * ```
4148
+ *
4149
+ * Note that the same animation can be written as:
4150
+ * ```ts
4151
+ * yield* waitFor(1),
4152
+ * yield* rect.fill('#ff0000', 2),
4153
+ * ```
4154
+ *
4155
+ * The reason `delay` exists is to make it easier to pass it to other flow
4156
+ * functions. For example:
4157
+ * ```ts
4158
+ * yield* all(
4159
+ * rect.opacity(1, 3),
4160
+ * delay(1, rect.fill('#ff0000', 2));
4161
+ * );
4162
+ * ```
4163
+ *
4164
+ * @param time - The delay in seconds
4165
+ * @param task - The task or callback to run after the delay.
4166
+ */
4167
+ declare function delay(time: number, task: ThreadGenerator | Callback): ThreadGenerator;
4168
+ //#endregion
4169
+ //#region src/flow/every.d.ts
4170
+ interface EveryCallback {
4171
+ /**
4172
+ * A callback called by {@link EveryTimer} every N seconds.
4173
+ *
4174
+ * @param tick - The amount of times the timer has ticked.
4175
+ */
4176
+ (tick: number): void;
4177
+ }
4178
+ interface EveryTimer {
4179
+ /**
4180
+ * The generator responsible for running this timer.
4181
+ */
4182
+ runner: ThreadGenerator;
4183
+ setInterval(value: number): void;
4184
+ setCallback(value: EveryCallback): void;
4185
+ /**
4186
+ * Wait until the timer ticks.
4187
+ */
4188
+ sync(): ThreadGenerator;
4189
+ }
4190
+ /**
4191
+ * Call the given callback every N seconds.
4192
+ *
4193
+ * @example
4194
+ * ```ts
4195
+ * const timer = every(2, time => console.log(time));
4196
+ * yield timer.runner;
4197
+ *
4198
+ * // current time: 0s
4199
+ * yield* waitFor(5);
4200
+ * // current time: 5s
4201
+ * yield* timer.sync();
4202
+ * // current time: 6s
4203
+ * ```
4204
+ *
4205
+ * @param interval - The interval between subsequent calls.
4206
+ * @param callback - The callback to be called.
4207
+ */
4208
+ declare function every(interval: number, callback: EveryCallback): EveryTimer;
4209
+ //#endregion
4210
+ //#region src/flow/loop.d.ts
4211
+ interface LoopCallback {
4212
+ /**
4213
+ * A callback called by {@link loop} during each iteration.
4214
+ *
4215
+ * @param i - The current iteration index.
4216
+ */
4217
+ (i: number): ThreadGenerator | void;
4218
+ }
4219
+ /**
4220
+ * Run the given generator in a loop.
4221
+ *
4222
+ * @remarks
4223
+ * Each iteration waits until the previous one is completed.
4224
+ * Because this loop never finishes it cannot be used in the main thread.
4225
+ * Instead, use `yield` or {@link threading.spawn} to run the loop concurrently.
4226
+ *
4227
+ * @example
4228
+ * Rotate the `rect` indefinitely:
4229
+ * ```ts
4230
+ * yield loop(
4231
+ * () => rect.rotation(0).rotation(360, 2, linear),
4232
+ * );
4233
+ * ```
4234
+ *
4235
+ * @param factory - A function creating the generator to run. Because generators
4236
+ * can't be reset, a new generator is created on each
4237
+ * iteration.
4238
+ */
4239
+ declare function loop(factory: LoopCallback): ThreadGenerator;
4240
+ /**
4241
+ * Run the given generator N times.
4242
+ *
4243
+ * @remarks
4244
+ * Each iteration waits until the previous one is completed.
4245
+ *
4246
+ * @example
4247
+ * ```ts
4248
+ * const colors = [
4249
+ * '#ff6470',
4250
+ * '#ffc66d',
4251
+ * '#68abdf',
4252
+ * '#99c47a',
4253
+ * ];
4254
+ *
4255
+ * yield* loop(
4256
+ * colors.length,
4257
+ * i => rect.fill(colors[i], 2),
4258
+ * );
4259
+ * ```
4260
+ *
4261
+ * @param iterations - The number of iterations.
4262
+ * @param factory - A function creating the generator to run. Because generators
4263
+ * can't be reset, a new generator is created on each
4264
+ * iteration.
4265
+ */
4266
+ declare function loop(iterations: number, factory: LoopCallback): ThreadGenerator;
4267
+ //#endregion
4268
+ //#region src/flow/loopFor.d.ts
4269
+ /**
4270
+ * Run a generator in a loop for the given amount of time.
4271
+ *
4272
+ * @remarks
4273
+ * Generators are executed completely before the next iteration starts.
4274
+ * An iteration is allowed to finish even when the time is up. This means that
4275
+ * the actual duration of the loop may be longer than the given duration.
4276
+ *
4277
+ * @example
4278
+ * ```ts
4279
+ * yield* loopFor(
4280
+ * 3,
4281
+ * () => circle().position.x(-10, 0.1).to(10, 0.1)
4282
+ * );
4283
+ * ```
4284
+ *
4285
+ * @param seconds - The duration in seconds.
4286
+ * @param factory - A function creating the generator to run. Because generators
4287
+ * can't be reset, a new generator is created on each
4288
+ * iteration.
4289
+ */
4290
+ declare function loopFor(seconds: number, factory: LoopCallback): ThreadGenerator;
4291
+ //#endregion
4292
+ //#region src/flow/loopUntil.d.ts
4293
+ /**
4294
+ * Run a generator in a loop until the given time event.
4295
+ *
4296
+ * @remarks
4297
+ * Generators are executed completely before the next iteration starts.
4298
+ * An iteration is allowed to finish even when the time is up. This means that
4299
+ * the actual duration of the loop may be longer than the given duration.
4300
+ *
4301
+ * @example
4302
+ * ```ts
4303
+ * yield* loopUntil(
4304
+ * 'Stop Looping',
4305
+ * () => circle().position.x(-10, 0.1).to(10, 0.1)
4306
+ * );
4307
+ * ```
4308
+ *
4309
+ * @param event - The event.
4310
+ * @param factory - A function creating the generator to run. Because generators
4311
+ * can't be reset, a new generator is created on each
4312
+ * iteration.
4313
+ */
4314
+ declare function loopUntil(event: string, factory: LoopCallback): ThreadGenerator;
4315
+ //#endregion
4316
+ //#region src/flow/noop.d.ts
4317
+ /**
4318
+ * Do nothing.
4319
+ */
4320
+ declare function noop(): ThreadGenerator;
4321
+ //#endregion
4322
+ //#region src/flow/run.d.ts
4323
+ /**
4324
+ * Turn the given generator function into a task.
4325
+ *
4326
+ * @remarks
4327
+ * If you want to immediately run the generator in its own thread, you can use
4328
+ * {@link threading.spawn} instead. This function is useful when you want to
4329
+ * pass the created task to other flow functions.
4330
+ *
4331
+ * @example
4332
+ * ```ts
4333
+ * yield* all(
4334
+ * run(function* () {
4335
+ * // do things
4336
+ * }),
4337
+ * rect.opacity(1, 1),
4338
+ * );
4339
+ * ```
4340
+ *
4341
+ * @param runner - A generator function or a factory that creates the generator.
4342
+ */
4343
+ declare function run(runner: () => ThreadGenerator): ThreadGenerator;
4344
+ /**
4345
+ * Turn the given generator function into a task.
4346
+ *
4347
+ * @remarks
4348
+ * If you want to immediately run the generator in its own thread, you can use
4349
+ * {@link threading.spawn} instead. This function is useful when you want to
4350
+ * pass the created task to other flow functions.
4351
+ *
4352
+ * @example
4353
+ * ```ts
4354
+ * yield* all(
4355
+ * run(function* () {
4356
+ * // do things
4357
+ * }),
4358
+ * rect.opacity(1, 1),
4359
+ * );
4360
+ * ```
4361
+ *
4362
+ * @param runner - A generator function or a factory that creates the generator.
4363
+ * @param name - An optional name used when displaying this generator in the UI.
4364
+ */
4365
+ declare function run(name: string, runner: () => ThreadGenerator): ThreadGenerator;
4366
+ //#endregion
4367
+ //#region src/flow/scheduling.d.ts
4368
+ /**
4369
+ * Wait until the given time event.
4370
+ *
4371
+ * @remarks
4372
+ * Time events are displayed on the timeline and can be edited to adjust the
4373
+ * delay. By default, an event happens immediately - without any delay.
4374
+ *
4375
+ * @example
4376
+ * ```ts
4377
+ * yield waitUntil('event');
4378
+ * ```
4379
+ *
4380
+ * @param event - The name of the time event.
4381
+ * @param after - An optional task to be run after the function completes.
4382
+ */
4383
+ declare function waitUntil(event: string, after?: ThreadGenerator): ThreadGenerator;
4384
+ /**
4385
+ * Wait for the given amount of time.
4386
+ *
4387
+ * @example
4388
+ * ```ts
4389
+ * // current time: 0s
4390
+ * yield waitFor(2);
4391
+ * // current time: 2s
4392
+ * yield waitFor(3);
4393
+ * // current time: 5s
4394
+ * ```
4395
+ *
4396
+ * @param seconds - The relative time in seconds.
4397
+ * @param after - An optional task to be run after the function completes.
4398
+ */
4399
+ declare function waitFor(seconds?: number, after?: ThreadGenerator): ThreadGenerator;
4400
+ //#endregion
4401
+ //#region src/flow/sequence.d.ts
4402
+ /**
4403
+ * Start all tasks one after another with a constant delay between.
4404
+ *
4405
+ * @remarks
4406
+ * The function doesn't wait until the previous task in the sequence has
4407
+ * finished. Once the delay has passed, the next task will start even if
4408
+ * the previous is still running.
4409
+ *
4410
+ * @example
4411
+ * ```ts
4412
+ * yield* sequence(
4413
+ * 0.1,
4414
+ * ...rects.map(rect => rect.x(100, 1))
4415
+ * );
4416
+ * ```
4417
+ *
4418
+ * @param delay - The delay between each of the tasks.
4419
+ * @param tasks - A list of tasks to be run in a sequence.
4420
+ */
4421
+ declare function sequence(delay: number, ...tasks: ThreadGenerator[]): ThreadGenerator;
4422
+ //#endregion
4423
+ //#region src/plugin/DefaultPlugin.d.ts
4424
+ /**
4425
+ * The default plugin included in every Canvas Commons project.
4426
+ *
4427
+ * @internal
4428
+ */
4429
+ declare const _default: () => Plugin;
4430
+ //#endregion
4431
+ //#region src/transitions/fadeTransition.d.ts
4432
+ /**
4433
+ * Perform a transition that fades between the scenes.
4434
+ *
4435
+ * @param duration - The duration of the transition.
4436
+ */
4437
+ declare function fadeTransition(duration?: number): ThreadGenerator;
4438
+ //#endregion
4439
+ //#region src/transitions/slideTransition.d.ts
4440
+ /**
4441
+ * Perform a transition that slides the scene in the given direction.
4442
+ *
4443
+ * @param direction - The direction in which to slide.
4444
+ * @param duration - The duration of the transition.
4445
+ */
4446
+ declare function slideTransition(direction: Direction, duration?: number): ThreadGenerator;
4447
+ /**
4448
+ * Perform a transition that slides the scene towards the given origin.
4449
+ *
4450
+ * @param origin - The origin towards which to slide.
4451
+ * @param duration - The duration of the transition.
4452
+ */
4453
+ declare function slideTransition(origin: Origin, duration?: number): ThreadGenerator;
4454
+ //#endregion
4455
+ //#region src/transitions/useTransition.d.ts
4456
+ /**
4457
+ * Transition to the current scene by altering the Context2D before scenes are rendered.
4458
+ *
4459
+ * @param current - The callback to use before the current scene is rendered.
4460
+ * @param previous - The callback to use before the previous scene is rendered.
4461
+ * @param previousOnTop - Whether the previous scene should be rendered on top.
4462
+ */
4463
+ declare function useTransition(current: (ctx: CanvasRenderingContext2D) => void, previous?: (ctx: CanvasRenderingContext2D) => void, previousOnTop?: SignalValue<boolean>): () => void;
4464
+ //#endregion
4465
+ //#region src/transitions/waitTransition.d.ts
4466
+ /**
4467
+ * Perform a transition that doesn't do anything.
4468
+ *
4469
+ * @remarks
4470
+ * This is useful when you want to achieve a transition effect by animating
4471
+ * objects in the scenes. It will overlay the scenes on top of each other for
4472
+ * the duration of the transition.
4473
+ *
4474
+ * @param duration - The duration of the transition.
4475
+ * @param previousOnTop - Whether the previous scene should be rendered on top.
4476
+ */
4477
+ declare function waitTransition(duration?: number, previousOnTop?: SignalValue<boolean>): ThreadGenerator;
4478
+ //#endregion
4479
+ //#region src/transitions/zoomInTransition.d.ts
4480
+ /**
4481
+ * Perform a transition that zooms in on a given area of the scene.
4482
+ *
4483
+ * @param area - The area on which to zoom in.
4484
+ * @param duration - The duration of the transition.
4485
+ */
4486
+ declare function zoomInTransition(area: BBox, duration?: number): ThreadGenerator;
4487
+ //#endregion
4488
+ //#region src/transitions/zoomOutTransition.d.ts
4489
+ /**
4490
+ * Perform a transition that zooms out from a given area of the scene.
4491
+ *
4492
+ * @param area - The area from which to zoom out.
4493
+ * @param duration - The duration of the transition.
4494
+ */
4495
+ declare function zoomOutTransition(area: BBox, duration?: number): ThreadGenerator;
4496
+ //#endregion
4497
+ //#region src/utils/beginSlide.d.ts
4498
+ declare function beginSlide(name: string): ThreadGenerator;
4499
+ //#endregion
4500
+ //#region src/utils/capitalize.d.ts
4501
+ declare function capitalize<T extends string>(value: T): Capitalize<T>;
4502
+ //#endregion
4503
+ //#region src/utils/createRef.d.ts
4504
+ interface ReferenceReceiver<T> {
4505
+ (reference: T): void;
4506
+ }
4507
+ interface Reference<T> extends ReferenceReceiver<T> {
4508
+ (): T;
4509
+ }
4510
+ declare function createRef<T>(): Reference<T>;
4511
+ declare function makeRef<TObject, TKey extends keyof TObject>(object: TObject, key: TKey): ReferenceReceiver<TObject[TKey]>;
4512
+ type RefsProperty<TValue> = TValue extends ((config: {
4513
+ refs?: infer TReference;
4514
+ }) => void) ? TReference : never;
4515
+ declare function makeRefs<T extends (config: {
4516
+ refs?: any;
4517
+ }) => void>(): RefsProperty<T>;
4518
+ //#endregion
4519
+ //#region src/utils/createRefArray.d.ts
4520
+ type ReferenceArray<T> = T[] & Reference<T>;
4521
+ /**
4522
+ * Create an array of references.
4523
+ *
4524
+ * @remarks
4525
+ * The returned object is both an array and a reference that can be passed
4526
+ * directly to the `ref` property of a node.
4527
+ *
4528
+ * @example
4529
+ * ```tsx
4530
+ * const labels = createRefArray<Txt>();
4531
+ *
4532
+ * view.add(['A', 'B'].map(text => <Txt ref={labels}>{text}</Txt>));
4533
+ * view.add(<Txt ref={labels}>C</Txt>);
4534
+ *
4535
+ * // accessing the references individually:
4536
+ * yield* labels[0].text('A changes', 0.3);
4537
+ * yield* labels[1].text('B changes', 0.3);
4538
+ * yield* labels[2].text('C changes', 0.3);
4539
+ *
4540
+ * // accessing all references at once:
4541
+ * yield* all(...labels.map(label => label.fill('white', 0.3)));
4542
+ * ```
4543
+ */
4544
+ declare function createRefArray<T>(): ReferenceArray<T>;
4545
+ //#endregion
4546
+ //#region src/utils/createRefMap.d.ts
4547
+ type ReferenceMap<T> = Map<string, Reference<T>> & Record<string, Reference<T>> & {
4548
+ /**
4549
+ * Maps the references in this group to a new array.
4550
+ *
4551
+ * @param callback - The function to transform each reference.
4552
+ *
4553
+ * @returns An array of the transformed references.
4554
+ */
4555
+ mapRefs<TValue>(callback: (value: T, index: number) => TValue): TValue[];
4556
+ };
4557
+ /**
4558
+ * Create a group of references.
4559
+ *
4560
+ * @remarks
4561
+ * The returned object lets you easily create multiple references to the same
4562
+ * type without initializing them individually.
4563
+ *
4564
+ * You can retrieve references by accessing the object's properties. If the
4565
+ * reference for a given property does not exist, it will be created
4566
+ * automatically.
4567
+ *
4568
+ * @example
4569
+ * ```tsx
4570
+ * const labels = createRefMap<Txt>();
4571
+ *
4572
+ * view.add(
4573
+ * <>
4574
+ * <Txt ref={labels.a}>A</Txt>
4575
+ * <Txt ref={labels.b}>B</Txt>
4576
+ * <Txt ref={labels.c}>C</Txt>
4577
+ * </>,
4578
+ * );
4579
+ *
4580
+ * // accessing the references individually:
4581
+ * yield* labels.a().text('A changes', 0.3);
4582
+ * yield* labels.b().text('B changes', 0.3);
4583
+ * yield* labels.c().text('C changes', 0.3);
4584
+ *
4585
+ * // checking if the given reference exists:
4586
+ * if ('d' in labels) {
4587
+ * yield* labels.d().text('D changes', 0.3);
4588
+ * }
4589
+ *
4590
+ * // accessing all references at once:
4591
+ * yield* all(...labels.mapRefs(label => label.fill('white', 0.3)));
4592
+ * ```
4593
+ */
4594
+ declare function createRefMap<T>(): ReferenceMap<T>;
4595
+ //#endregion
4596
+ //#region src/utils/debug.d.ts
4597
+ /**
4598
+ * Logs a debug message with an arbitrary payload.
4599
+ *
4600
+ * @remarks
4601
+ * This method is a shortcut for calling `useLogger().debug()` which allows
4602
+ * you to more easily log non-string values as well.
4603
+ *
4604
+ * @example
4605
+ * ```ts
4606
+ * export default makeScene2D(function* (view) {
4607
+ * const circle = createRef<Circle>();
4608
+ *
4609
+ * view.add(
4610
+ * <Circle ref={circle} width={320} height={320} fill={'lightseagreen'} />,
4611
+ * );
4612
+ *
4613
+ * debug(circle().position());
4614
+ * });
4615
+ * ```
4616
+ *
4617
+ * @param payload - The payload to log
4618
+ */
4619
+ declare function debug(payload: any): void;
4620
+ //#endregion
4621
+ //#region src/utils/deprecate.d.ts
4622
+ /**
4623
+ * Mark the given function as deprecated.
4624
+ *
4625
+ * @param fn - The function to deprecate.
4626
+ * @param message - The log message.
4627
+ * @param remarks - The optional log remarks.
4628
+ */
4629
+ declare function deprecate<TArgs extends any[], TReturn>(fn: (...args: TArgs) => TReturn, message: string, remarks?: string): (...args: TArgs) => TReturn;
4630
+ //#endregion
4631
+ //#region src/utils/DetailedError.d.ts
4632
+ type DetailedErrorProps = Pick<LogPayload, 'message' | 'remarks' | 'object' | 'durationMs' | 'inspect'>;
4633
+ declare class DetailedError extends Error {
4634
+ /**
4635
+ * {@inheritDoc app.LogPayload.message}
4636
+ */
4637
+ readonly remarks?: string;
4638
+ /**
4639
+ * {@inheritDoc app.LogPayload.object}
4640
+ */
4641
+ readonly object?: any;
4642
+ /**
4643
+ * {@inheritDoc app.LogPayload.durationMs}
4644
+ */
4645
+ readonly durationMs?: number;
4646
+ /**
4647
+ * {@inheritDoc app.LogPayload.inspect}
4648
+ */
4649
+ readonly inspect?: string;
4650
+ constructor(message: string, remarks?: string);
4651
+ constructor(props: DetailedErrorProps);
4652
+ }
4653
+ //#endregion
4654
+ //#region src/utils/errorToLog.d.ts
4655
+ declare function errorToLog(error: any): LogPayload;
4656
+ //#endregion
4657
+ //#region src/utils/ExperimentalError.d.ts
4658
+ type ExperimentalErrorProps = Pick<LogPayload, 'message' | 'remarks' | 'object' | 'durationMs' | 'inspect'>;
4659
+ declare class ExperimentalError extends DetailedError {
4660
+ constructor(message: string, remarks?: string);
4661
+ constructor(props: ExperimentalErrorProps);
4662
+ }
4663
+ //#endregion
4664
+ //#region src/utils/experimentalLog.d.ts
4665
+ declare function experimentalLog(message: string, remarks?: string): LogPayload;
4666
+ //#endregion
4667
+ //#region src/utils/getContext.d.ts
4668
+ declare function getContext(options?: CanvasRenderingContext2DSettings, canvas?: HTMLCanvasElement): CanvasRenderingContext2D;
4669
+ //#endregion
4670
+ //#region src/utils/math.d.ts
4671
+ /**
4672
+ * A constant for converting radians to degrees
4673
+ *
4674
+ * @example
4675
+ * const degrees = 0.6 * RAD2DEG;
4676
+ */
4677
+ declare const RAD2DEG: number;
4678
+ /**
4679
+ * A constant for converting degrees to radians
4680
+ *
4681
+ * @example
4682
+ * const radians = 30 * DEG2RAD;
4683
+ */
4684
+ declare const DEG2RAD: number;
4685
+ //#endregion
4686
+ //#region src/utils/proxyUtils.d.ts
4687
+ /**
4688
+ * Utility to redirect remote sources via Proxy
4689
+ *
4690
+ * This utility is used to rewrite a request to be routed through
4691
+ * the Proxy instead.
4692
+ */
4693
+ /**
4694
+ * Route the given url through a local proxy.
4695
+ *
4696
+ * @example
4697
+ * This rewrites a remote url like `https://via.placeholder.com/300.png/09f/fff`
4698
+ * into a URI-Component-Encoded string like
4699
+ * `/cors-proxy/https%3A%2F%2Fvia.placeholder.com%2F300.png%2F09f%2Ffff`
4700
+ */
4701
+ declare function viaProxy(url: string): string;
4702
+ /**
4703
+ * Check if the proxy is enabled via the plugin by checking
4704
+ * for `import.meta.env.VITE_MC_PROXY_ENABLED`
4705
+ *
4706
+ * @remarks The value can either be 'true' of 'false'
4707
+ * (as strings) if present, or be undefined if not run
4708
+ * from a vite context or run without the MC Plugin.
4709
+ */
4710
+ declare function isProxyEnabled(): boolean;
4711
+ //#endregion
4712
+ //#region src/utils/range.d.ts
4713
+ /**
4714
+ * Create an array containing a range of numbers.
4715
+ *
4716
+ * @example
4717
+ * ```ts
4718
+ * const array1 = range(3); // [0, 1, 2]
4719
+ * const array2 = range(-3); // [0, -1, -2]
4720
+ * ```
4721
+ *
4722
+ * @param length - The length of the array.
4723
+ */
4724
+ declare function range(length: number): number[];
4725
+ /**
4726
+ * Create an array containing a range of numbers.
4727
+ *
4728
+ * @example
4729
+ * ```ts
4730
+ * const array1 = range(3, 7); // [3, 4, 5, 6]
4731
+ * const array2 = range(7, 3); // [7, 6, 5, 4]
4732
+ * ```
4733
+ *
4734
+ * @param from - The start of the range.
4735
+ * @param to - The end of the range. `to` itself is not included in the result.
4736
+ */
4737
+ declare function range(from: number, to: number): number[];
4738
+ /**
4739
+ * Create an array containing a range of numbers.
4740
+ *
4741
+ * @example
4742
+ * ```ts
4743
+ * const array1 = range(1, 2, 0.25); // [1, 1.25, 1.5, 1.75]
4744
+ * const array2 = range(2, 1, -0.25); // [2, 1.75, 1.5, 1.25]
4745
+ * ```
4746
+ *
4747
+ * @param from - The start of the range.
4748
+ * @param to - The end of the range. `to` itself is not included in the result.
4749
+ * @param step - The value by which to increment or decrement.
4750
+ */
4751
+ declare function range(from: number, to: number, step: number): number[];
4752
+ //#endregion
4753
+ //#region src/utils/Semaphore.d.ts
4754
+ /**
4755
+ * A simple semaphore implementation with a capacity of 1.
4756
+ *
4757
+ * @internal
4758
+ */
4759
+ declare class Semaphore {
4760
+ private resolveCurrent;
4761
+ private current;
4762
+ acquire(): Promise<void>;
4763
+ release(): void;
4764
+ }
4765
+ //#endregion
4766
+ //#region src/utils/useContext.d.ts
4767
+ /**
4768
+ * Provide a function to access the Context2D before the scene is rendered.
4769
+ *
4770
+ * @param callback - The function that will be provided the context before render.
4771
+ */
4772
+ declare function useContext(callback: (ctx: CanvasRenderingContext2D) => void): () => void;
4773
+ /**
4774
+ * Provide a function to access the Context2D after the scene is rendered.
4775
+ *
4776
+ * @param callback - The function that will be provided the context after render.
4777
+ */
4778
+ declare function useContextAfter(callback: (ctx: CanvasRenderingContext2D) => void): () => void;
4779
+ //#endregion
4780
+ //#region src/utils/useDuration.d.ts
4781
+ /**
4782
+ * Register a time event and get its duration in seconds.
4783
+ *
4784
+ * @remarks
4785
+ * This can be used to better specify when an animation should start
4786
+ * as well as how long this animation should take
4787
+ *
4788
+ * @example
4789
+ * ```ts
4790
+ * export default makeScene2D(function* (view) {
4791
+ * const circle = createRef<Circle>();
4792
+ *
4793
+ * view.add(
4794
+ * <Circle ref={circle} width={320} height={320} fill={'lightseagreen'} />,
4795
+ * );
4796
+ *
4797
+ * yield* circle().scale(2, useDuration('circleGrow'));
4798
+ * });
4799
+ * ```
4800
+ *
4801
+ * @param name - The name of the event.
4802
+ *
4803
+ * @returns The duration of the event in seconds.
4804
+ */
4805
+ declare function useDuration(name: string): number;
4806
+ //#endregion
4807
+ //#region src/utils/usePlayback.d.ts
4808
+ /**
4809
+ * Get a reference to the playback status.
4810
+ */
4811
+ declare function usePlayback(): PlaybackStatus;
4812
+ declare function startPlayback(playback: PlaybackStatus): void;
4813
+ declare function endPlayback(playback: PlaybackStatus): void;
4814
+ //#endregion
4815
+ //#region src/utils/useRandom.d.ts
4816
+ /**
4817
+ * Get the random number generator for the current scene.
4818
+ **/
4819
+ declare function useRandom(): Random;
4820
+ /**
4821
+ * Get the random number generator for the given seed.
4822
+ *
4823
+ * @param seed - The seed for the generator.
4824
+ * @param fixed - Whether the seed should be fixed. Fixed seeds remain
4825
+ * the same even when the main scene seed changes.
4826
+ */
4827
+ declare function useRandom(seed: number, fixed?: boolean): Random;
4828
+ //#endregion
4829
+ //#region src/utils/useScene.d.ts
4830
+ /**
4831
+ * Get a reference to the current scene.
4832
+ */
4833
+ declare function useScene(): Scene;
4834
+ declare function startScene(scene: Scene): void;
4835
+ declare function endScene(scene: Scene): void;
4836
+ declare function useLogger(): Logger | Console;
4837
+ /**
4838
+ * Mark the current scene as ready to transition out.
4839
+ *
4840
+ * @remarks
4841
+ * Usually used together with transitions. When a scene is marked as finished,
4842
+ * the transition will start but the scene generator will continue running.
4843
+ */
4844
+ declare function finishScene(): void;
4845
+ //#endregion
4846
+ //#region src/utils/useThread.d.ts
4847
+ /**
4848
+ * Get a reference to the current thread.
4849
+ */
4850
+ declare function useThread(): Thread;
4851
+ declare function startThread(thread: Thread): void;
4852
+ declare function endThread(thread: Thread): void;
4853
+ //#endregion
4854
+ //#region src/utils/useTime.d.ts
4855
+ /**
4856
+ * Get the real time since the start of the animation.
4857
+ *
4858
+ * @remarks
4859
+ * The returned value accounts for offsets caused by functions such as
4860
+ * {@link flow.waitFor}.
4861
+ *
4862
+ * @example
4863
+ * ```ts
4864
+ * // current time: 0s
4865
+ * yield* waitFor(0.02);
4866
+ *
4867
+ * // current time: 0.016(6)s
4868
+ * // real time: 0.02s
4869
+ * const realTime = useTime();
4870
+ * ```
4871
+ */
4872
+ declare function useTime(): number;
4873
+ //#endregion
4874
+ export { AsyncEventDispatcher, AsyncEventHandler, AudioData, AudioManager, AudioManagerPool, AudioResource, AudioResourceManager, BBox, BeatSpring, BoolMetaField, BounceSpring, CachedSceneData, CanvasColorSpace, CanvasOutputMimeType, Center, Color, ColorMetaField, ColorSignal, ColorSpace, CompoundSignal, CompoundSignalContext, Computed, ComputedContext, DEFAULT, DEG2RAD, _default as DefaultPlugin, DeferredEffectContext, DependencyContext, DescriptionOf, DetailedError, Direction, EMPTY_AUDIO_DATA, EPSILON, EditableTimeEvents, EffectContext, EnumMetaField, EventDispatcher, EventDispatcherBase, EventHandler, EveryCallback, EveryTimer, ExperimentalError, Exporter, ExporterClass, ExporterMetaField, FlagDispatcher, FullSceneDescription, GeneratorScene, ImageDataSource, ImageExporter, Inspectable, InspectedAttributes, InspectedElement, InterpolationFunction, JumpSpring, LifecycleEvents, LogLevel, LogPayload, Logger, LoopCallback, Matrix2D, MetaField, MetaFile, MetaOption, NumberMetaField, ObjectMetaField, Origin, PlaybackManager, PlaybackState, PlaybackStatus, Player, PlayerSettings, PlayerState, PlopSpring, Plugin, PossibleBBox, PossibleColor, PossibleMatrix2D, PossibleSpacing, PossibleVector2, Presenter, PresenterInfo, PresenterSettings, PresenterState, Project, ProjectMetadata, ProjectSettings, Promisable, PromiseHandle, RAD2DEG, Random, RangeMetaField, ReadOnlyTimeEvents, RectSignal, Reference, ReferenceArray, ReferenceMap, ReferenceReceiver, RefsProperty, Renderer, RendererResult, RendererSettings, RendererState, Scene, SceneConstructor, SceneDescription, SceneDescriptionReload, SceneMetadata, SceneRenderEvent, SceneState, Semaphore, SerializedBBox, SerializedColor, SerializedSpacing, SerializedTimeEvent, SerializedVector2, SettingsMetadata, Shaders, SharedWebGLContext, Signal, SignalContext, SignalExtensions, SignalGenerator, SignalGetter, SignalSetter, SignalTween, SignalValue, SimpleSignal, SimpleVector2Signal, Slide, Slides, SmoothSpring, Sound, SoundBuilder, SoundSettings, Sounds, Spacing, SpacingSignal, Spring, Stage, StageSettings, StrikeSpring, StringMetaField, Subscribable, SubscribableAsyncEvent, SubscribableEvent, SubscribableFlagEvent, SubscribableValueEvent, SwingSpring, Thread, ThreadGenerator, ThreadGeneratorFactory, Threadable, ThreadsCallback, ThreadsFactory, TimeEvent, TimeEvents, TimingFunction, Type, UNIFORM_DELTA_TIME, UNIFORM_DESTINATION_MATRIX, UNIFORM_DESTINATION_TEXTURE, UNIFORM_FRAME, UNIFORM_FRAMERATE, UNIFORM_RESOLUTION, UNIFORM_SOURCE_MATRIX, UNIFORM_SOURCE_TEXTURE, UNIFORM_TIME, ValueDispatcher, ValueOf, Variables, Vector2, Vector2Edit, Vector2MetaField, Vector2Operation, Vector2Signal, Vector2SignalContext, Vector2SignalHelpers, Versions, WebGLContextOwner, WebGLConvertible, all, any, arcLerp, beginSlide, boolLerp, bootstrap, cancel, capitalize, chain, clamp, clampRemap, cos, createComputed, createComputedAsync, createDeferredEffect, createEaseInBack, createEaseInBounce, createEaseInElastic, createEaseInOutBack, createEaseInOutBounce, createEaseInOutElastic, createEaseOutBack, createEaseOutBounce, createEaseOutElastic, createEffect, createRef, createRefArray, createRefMap, createSceneMetadata, createSettingsMetadata, createSignal, debug, decorate, deepLerp, delay, deprecate, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editorBootstrap, endPlayback, endScene, endThread, errorToLog, every, experimentalLog, fadeTransition, finishScene, flipOrigin, getContext, getImageData, getTaskName, isInspectable, isPromisable, isPromise, isProxyEnabled, isReactive, isThreadGenerator, isThreadable, isType, join, lazy, linear, loadAnimation, loadImage, loop, loopFor, loopUntil, makePlugin, makeProject, makeRef, makeRefs, makeSpring, map, modify, noop, originToOffset, range, remap, run, sequence, setTaskName, sin, slideTransition, sound, spawn, spring, startPlayback, startScene, startThread, textLerp, threadable, threads, transformAngle, transformScalar, tween, unwrap, useContext, useContextAfter, useDuration, useLogger, usePlayback, useRandom, useScene, useThread, useTime, useTransition, viaProxy, waitFor, waitTransition, waitUntil, zoomInTransition, zoomOutTransition };
4875
+ //# sourceMappingURL=index.d.ts.map