@kayelaa/canvas 0.1.1 → 0.1.2

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.
@@ -0,0 +1,1482 @@
1
+ /**
2
+ * @fileoverview High-level 2D Canvas Engine (DOM-like, named entities/scenes)
3
+ */
4
+ type Listener<T extends any[] = any[]> = (...args: T) => void;
5
+ /**
6
+ * Generic event emitter with typed events and methods similar to Node.js EventEmitter.
7
+ *
8
+ * @template Events - Record mapping event names to argument tuples
9
+ *
10
+ * @example
11
+ * const emitter = new LeaEventEmitter<{
12
+ * update: [number];
13
+ * error: [Error];
14
+ * }>();
15
+ *
16
+ * emitter.on('update', (delta) => console.log(delta));
17
+ * emitter.emit('update', 0.016);
18
+ */
19
+ declare class LeaEventEmitter<Events extends Record<string, any[]>> {
20
+ #private;
21
+ constructor();
22
+ /**
23
+ * Registers a listener for the specified event.
24
+ *
25
+ * @template K - Event name
26
+ * @param event - The name of the event
27
+ * @param listener - The callback to invoke when the event is emitted
28
+ * @returns This emitter for chaining
29
+ */
30
+ on<K extends keyof Events>(event: K, listener: (...args: Events[K]) => void): this;
31
+ /**
32
+ * Registers a one-time listener for the specified event.
33
+ *
34
+ * The listener is automatically removed after the first invocation.
35
+ *
36
+ * @template K - Event name
37
+ * @param event - The name of the event
38
+ * @param listener - The callback to invoke once
39
+ * @returns This emitter for chaining
40
+ */
41
+ once<K extends keyof Events>(event: K, listener: (...args: Events[K]) => void): this;
42
+ /**
43
+ * Removes a listener for the specified event.
44
+ *
45
+ * @template K - Event name
46
+ * @param event - The name of the event
47
+ * @param listener - The callback to remove
48
+ * @returns This emitter for chaining
49
+ */
50
+ off<K extends keyof Events>(event: K, listener: (...args: Events[K]) => void): this;
51
+ /**
52
+ * Emits an event, invoking all registered listeners with the provided arguments.
53
+ *
54
+ * If the event is `"error"` and no listeners are registered, the first argument (the error)
55
+ * will be thrown.
56
+ *
57
+ * @template K - Event name
58
+ * @param event - The name of the event to emit
59
+ * @param args - Arguments to pass to listeners
60
+ * @returns `true` if any listeners were invoked, `false` otherwise
61
+ */
62
+ emit<K extends keyof Events>(event: K, ...args: Events[K]): boolean;
63
+ /**
64
+ * Removes all listeners for the specified event, or all listeners if no event is provided.
65
+ *
66
+ * @template K - Event name
67
+ * @param event - Optional event name to clear listeners for
68
+ * @returns This emitter for chaining
69
+ */
70
+ removeAllListeners<K extends keyof Events>(event?: K): this;
71
+ /**
72
+ * Returns the number of listeners registered for the specified event.
73
+ *
74
+ * @template K - Event name
75
+ * @param event - The event to count listeners for
76
+ * @returns The number of registered listeners
77
+ */
78
+ listenerCount<K extends keyof Events>(event: K): number;
79
+ }
80
+ /**
81
+ * Canvas-based renderer that manages a 2D drawing context and emits a `"draw"` event each frame.
82
+ *
83
+ * Handles resolution scaling (viewport vs camera), automatic clearing, and RAF loop.
84
+ *
85
+ * @extends LeaEventEmitter<{ draw: [CanvasRenderingContext2D] }>
86
+ *
87
+ * @example
88
+ * const renderer = new LeaRendererII(canvas, { viewportWidth: 800, viewportHeight: 600 });
89
+ * renderer.on("draw", (ctx) => {
90
+ * ctx.fillStyle = "black";
91
+ * ctx.fillRect(0, 0, renderer.viewportWidth, renderer.viewportHeight);
92
+ * });
93
+ * renderer.start();
94
+ */
95
+ declare class LeaRendererII extends LeaEventEmitter<{
96
+ draw: [CanvasRenderingContext2D];
97
+ }> {
98
+ #private;
99
+ /**
100
+ * The target canvas element.
101
+ */
102
+ canvas: HTMLCanvasElement;
103
+ /**
104
+ * The 2D rendering context.
105
+ */
106
+ ctx: CanvasRenderingContext2D;
107
+ /**
108
+ * Whether the renderer is currently running (RAF loop active).
109
+ */
110
+ running: boolean;
111
+ private _rafId;
112
+ private _fps;
113
+ private _frameCount;
114
+ private _fpsTimer;
115
+ private _lastFrameTime;
116
+ constructor(canvas: HTMLCanvasElement, { viewportWidth, viewportHeight, cameraWidth, cameraHeight, }?: {
117
+ viewportWidth?: number;
118
+ viewportHeight?: number;
119
+ cameraWidth?: number;
120
+ cameraHeight?: number;
121
+ });
122
+ automatic: boolean;
123
+ retransform(): void;
124
+ /**
125
+ * The logical viewport width (game coordinate space).
126
+ */
127
+ get viewportWidth(): number;
128
+ set viewportWidth(v: number);
129
+ get width(): number;
130
+ get height(): number;
131
+ /**
132
+ * Center X of the viewport (viewportWidth / 2).
133
+ */
134
+ get centerX(): number;
135
+ /**
136
+ * Center Y of the viewport (viewportHeight / 2).
137
+ */
138
+ get centerY(): number;
139
+ get left(): number;
140
+ get top(): number;
141
+ get right(): number;
142
+ get bottom(): number;
143
+ /**
144
+ * The logical viewport height (game coordinate space).
145
+ */
146
+ get viewportHeight(): number;
147
+ set viewportHeight(v: number);
148
+ /**
149
+ * The camera/pixel resolution width (canvas backing resolution).
150
+ */
151
+ get cameraWidth(): number;
152
+ set cameraWidth(v: number);
153
+ /**
154
+ * The camera/pixel resolution height (canvas backing resolution).
155
+ */
156
+ get cameraHeight(): number;
157
+ set cameraHeight(v: number);
158
+ /**
159
+ * Update canvas resolution to match camera
160
+ * Units remain the same
161
+ */
162
+ updateCanvasResolution(): void;
163
+ /**
164
+ * Apply viewport → canvas transform
165
+ * Scale computed dynamically each frame
166
+ */
167
+ applyTransform(): void;
168
+ /**
169
+ * Current measured FPS (updated every second).
170
+ */
171
+ get FPS(): number;
172
+ private _loop;
173
+ update(): void;
174
+ /**
175
+ * Starts the RAF loop and begins emitting `"draw"` events.
176
+ *
177
+ * @throws If called in a non-browser environment or RAF is unavailable
178
+ */
179
+ start(): void;
180
+ /**
181
+ * Stops the RAF loop and halts drawing.
182
+ *
183
+ * @throws If called in a non-browser environment or RAF is unavailable
184
+ */
185
+ stop(): void;
186
+ }
187
+ /**
188
+ * Fixed or variable timestep ticker that emits a `"tick"` event with delta time (seconds).
189
+ *
190
+ * Supports RAF mode (`tickInterval = Infinity`) or fixed interval.
191
+ *
192
+ * @extends LeaEventEmitter<{ tick: [number]; error: [unknown] }>
193
+ *
194
+ * @example
195
+ * const ticker = new LeaTickerII(1000 / 60); // 60 Hz
196
+ * ticker.on("tick", (delta) => {
197
+ * // update game state
198
+ * });
199
+ * ticker.start();
200
+ */
201
+ declare class LeaTickerII extends LeaEventEmitter<{
202
+ tick: [number];
203
+ error: [unknown];
204
+ }> {
205
+ #private;
206
+ setNow(now: number): void;
207
+ /**
208
+ * @type {NodeJS.Timeout}
209
+ */
210
+ private __intervalId;
211
+ private __lastTime;
212
+ /**
213
+ * @param tickInterval Interval in ms
214
+ */
215
+ constructor(tickInterval?: number);
216
+ /**
217
+ * Speed multiplier for delta time (for slow-motion / fast-forward).
218
+ */
219
+ speedHackDT: number;
220
+ /**
221
+ * Whether the ticker is using requestAnimationFrame (RAF) mode.
222
+ */
223
+ get isRaf(): boolean;
224
+ /**
225
+ * Tick interval in milliseconds.
226
+ * - Finite number = fixed timestep
227
+ * - `Infinity` = RAF / variable timestep
228
+ */
229
+ get tickInterval(): number;
230
+ set tickInterval(s: number);
231
+ /**
232
+ * Current time in milliseconds (monotonic).
233
+ */
234
+ now(): number;
235
+ private __tick;
236
+ /**
237
+ *
238
+ * @param {number} ms
239
+ * @returns
240
+ */
241
+ createTimeout(ms: number): LeaTimeout;
242
+ createTween(config: ConstructorParameters<typeof DeltaTweenII>[0], callback?: (change: number) => void): DeltaTweenII;
243
+ /**
244
+ * Starts the ticker loop.
245
+ */
246
+ start(): void;
247
+ /**
248
+ * Stops the ticker loop.
249
+ */
250
+ stop(): void;
251
+ /**
252
+ *
253
+ * @param {number} ms
254
+ * @param {number} offset
255
+ * @returns {number}
256
+ */
257
+ getSineMod(ms: number, offset?: number): number;
258
+ }
259
+ type LeaEntitySerializerEach<T extends Record<string, any>, K extends keyof T = keyof T> = [
260
+ K,
261
+ {
262
+ mapExport?: (value: T[K]) => any;
263
+ mapImport?: (value: any) => T[K];
264
+ }
265
+ ];
266
+ type LeaEntitySerializer<T extends Record<string, any>> = {
267
+ [K in keyof T]: LeaEntitySerializerEach<T, K>;
268
+ }[keyof T][];
269
+ type LeaEntitySerializerArray<T extends Record<string, any>> = {
270
+ [K in keyof T]: LeaEntitySerializerEach<T, K>;
271
+ }[keyof T][];
272
+ type OrderedLeaEntitySerializer<T extends Record<string, any>, FirstKeys extends (keyof T)[]> = [
273
+ ...{
274
+ [I in keyof FirstKeys]: LeaEntitySerializerEach<T, FirstKeys[I]>;
275
+ },
276
+ ...LeaEntitySerializerArray<T>
277
+ ];
278
+ declare namespace LeaSerializers {
279
+ function booleanExport(a: boolean): 0 | 1;
280
+ function booleanImport(a: 0 | 1): boolean;
281
+ function vec2Export(vec: Vector2): string;
282
+ function vec2Import(str: string): Vector2;
283
+ const booleanMap: {
284
+ mapExport: typeof booleanExport;
285
+ mapImport: typeof booleanImport;
286
+ };
287
+ function createRounder(maxDecimals: number): (num: number) => number;
288
+ function createLowPrecision(base?: number): {
289
+ mapExport(num: number): number;
290
+ mapImport(num: number): number;
291
+ };
292
+ function lightWeightRounder(n: number): number;
293
+ function createPercent(exportedMax?: number): {
294
+ mapExport(n: number): number;
295
+ mapImport(n: number): number;
296
+ };
297
+ function createLookup<T extends Record<string, any>>(record: T): {
298
+ mapExport: (key: string) => any;
299
+ mapImport: (value: any) => any;
300
+ };
301
+ function radToDeg(rad: number): number;
302
+ function degToRad(deg: number): number;
303
+ const angleRadToDeg: {
304
+ mapExport: typeof radToDeg;
305
+ mapImport: typeof degToRad;
306
+ };
307
+ function createLowPrecisionRadToDeg(base?: number): {
308
+ mapExport(n: number): number;
309
+ mapImport(n: number): number;
310
+ };
311
+ }
312
+ /**
313
+ * Abstract base class for all entities in a LEA scene.
314
+ *
315
+ * Provides event emission (`update`, `draw`, `error`), position, name, and z-order.
316
+ *
317
+ * @extends LeaEventEmitter<{ update: [number]; draw: [CanvasRenderingContext2D]; error: [unknown] }>
318
+ */
319
+ declare abstract class LeaEntityII extends LeaEventEmitter<{
320
+ update: [number];
321
+ error: [unknown];
322
+ draw: [CanvasRenderingContext2D];
323
+ }> {
324
+ /**
325
+ * Unique name of the entity (used for lookup and serialization).
326
+ */
327
+ name: string;
328
+ /**
329
+ * @type {number}
330
+ */
331
+ scaleRotate: number;
332
+ /**
333
+ * @type {number}
334
+ */
335
+ scale: number;
336
+ /**
337
+ * @param {string} name
338
+ * @param {number} [x]
339
+ * @param {number} [y]
340
+ */
341
+ constructor(name: string, x?: number, y?: number);
342
+ arraySerializeMap?: LeaEntitySerializer<any>;
343
+ autoTranslate: boolean;
344
+ /**
345
+ * Z-order for draw sorting (higher = drawn later / on top).
346
+ */
347
+ z: number;
348
+ private ___pos;
349
+ /**
350
+ * @type {(keyof this)[]}
351
+ */
352
+ nonSerializableProperties: (keyof this)[];
353
+ /**
354
+ * @type {(keyof this)[]}
355
+ */
356
+ forceSerializableProperties: (keyof this)[];
357
+ /**
358
+ * Current position (center point).
359
+ */
360
+ get pos(): Vector2;
361
+ /**
362
+ * X coordinate (center).
363
+ */
364
+ get x(): number;
365
+ /**
366
+ * Y coordinate (center).
367
+ */
368
+ get y(): number;
369
+ set x(s: number);
370
+ set y(s: number);
371
+ /**
372
+ * Update entity.
373
+ */
374
+ handleUpdate(delta: number): void;
375
+ /**
376
+ * Called once per tick with delta time (seconds).
377
+ *
378
+ * @param delta - Time since last tick in seconds
379
+ */
380
+ abstract update(_delta: number): void;
381
+ /**
382
+ * Draw entity.
383
+ */
384
+ handleDraw(ctx: CanvasRenderingContext2D): void;
385
+ /**
386
+ * Called once per frame to draw the entity.
387
+ *
388
+ * The context is already translated to the entity's position if `autoTranslate` is true.
389
+ *
390
+ * @param ctx - The 2D rendering context
391
+ */
392
+ abstract draw?(ctx: CanvasRenderingContext2D): void;
393
+ /**
394
+ * Serializes the entity to a plain object (for save/load).
395
+ *
396
+ * Excludes internal properties and respects `nonSerializableProperties`.
397
+ *
398
+ * @returns Serializable data
399
+ */
400
+ serialize(): any;
401
+ /**
402
+ * Converts a world position to local space relative to this entity.
403
+ *
404
+ * @param worldVec - World position
405
+ * @returns Local position
406
+ */
407
+ toLocal(worldVec: Vector2): Vector2;
408
+ /**
409
+ * Converts a local position to world space.
410
+ *
411
+ * @param localVec - Local position
412
+ * @returns World position
413
+ */
414
+ toWorld(localVec: Vector2): Vector2;
415
+ deserializeArray(snapshot: any[]): any;
416
+ static deserializeArray(map: LeaEntityII["arraySerializeMap"], snapshot: any[]): any;
417
+ }
418
+ /**
419
+ * Container for a collection of entities, handling update/draw loops and z-order sorting.
420
+ *
421
+ * @extends LeaEventEmitter<{ update: [number]; draw: [CanvasRenderingContext2D] }>
422
+ */
423
+ declare class LeaSceneII extends LeaEventEmitter<{
424
+ update: [number];
425
+ draw: [CanvasRenderingContext2D];
426
+ }> {
427
+ /**
428
+ * Unique name of the scene.
429
+ */
430
+ name: string;
431
+ /**
432
+ * Map of entities by name.
433
+ */
434
+ entities: Map<string, LeaEntityII>;
435
+ /**
436
+ * Whether updates and drawing are paused.
437
+ */
438
+ paused: boolean;
439
+ constructor(name: string);
440
+ /**
441
+ * Updates all non-paused entities in the scene.
442
+ *
443
+ * @param delta - Time since last update in seconds
444
+ */
445
+ handleUpdate(delta: number): void;
446
+ /**
447
+ * Draws all entities in z-order (higher z = drawn later).
448
+ *
449
+ * @param ctx - The 2D rendering context
450
+ */
451
+ handleDraw(ctx: CanvasRenderingContext2D): void;
452
+ /**
453
+ * Adds an entity to the scene.
454
+ *
455
+ * @param entity - The entity to add
456
+ * @throws If the entity has no name
457
+ */
458
+ addEntity(entity: any): void;
459
+ /**
460
+ * Removes an entity from the scene by name.
461
+ *
462
+ * @param entity - The entity to remove
463
+ */
464
+ removeEntity(entity: any): void;
465
+ /**
466
+ * Retrieves an entity by name.
467
+ *
468
+ * @param name - The name of the entity
469
+ * @returns The entity, or undefined if not found
470
+ */
471
+ getEntity(name: string): LeaEntityII;
472
+ }
473
+ /**
474
+ * Top-level game manager that owns scenes and a shared ticker.
475
+ *
476
+ * Coordinates updates across all scenes and provides viewport utilities.
477
+ */
478
+ declare class LeaGameII {
479
+ /**
480
+ * Map of scenes by name.
481
+ */
482
+ scenes: Map<string, LeaSceneII>;
483
+ /**
484
+ * The shared ticker driving updates.
485
+ */
486
+ ticker: LeaTickerII;
487
+ /**
488
+ * Center X of the viewport (width / 2).
489
+ */
490
+ get centerX(): number;
491
+ /**
492
+ * Center Y of the viewport (height / 2).
493
+ */
494
+ get centerY(): number;
495
+ get left(): number;
496
+ get top(): number;
497
+ get right(): number;
498
+ get bottom(): number;
499
+ /**
500
+ * Logical viewport width.
501
+ */
502
+ width: number;
503
+ /**
504
+ * Logical viewport height.
505
+ */
506
+ height: number;
507
+ /**
508
+ * @param {number} width
509
+ * @param {number} height
510
+ * @param {number} tickInterval
511
+ */
512
+ constructor(width: number, height: number, tickInterval?: number);
513
+ /**
514
+ * Adds a scene to the game.
515
+ *
516
+ * @param scene - The scene to add
517
+ * @throws If the scene has no name
518
+ */
519
+ addScene(scene: LeaSceneII): void;
520
+ /**
521
+ * Removes a scene from the game.
522
+ *
523
+ * @param scene - The scene to remove
524
+ */
525
+ removeScene(scene: LeaSceneII): void;
526
+ /**
527
+ * Current time in milliseconds (from ticker).
528
+ */
529
+ now(): number;
530
+ /**
531
+ * Starts the ticker loop (begins emitting "tick" events).
532
+ */
533
+ start(): void;
534
+ /**
535
+ * Stops the ticker loop.
536
+ */
537
+ stop(): void;
538
+ }
539
+ /**
540
+ * @fileoverview Basic math & easing utilities
541
+ */
542
+ declare const LeaUtilsII: {
543
+ /**
544
+ * Linear interpolation
545
+ *
546
+ * @param {number} a Start value
547
+ * @param {number} b End value
548
+ * @param {number} t Progress (0–1)
549
+ * @returns {number}
550
+ */
551
+ lerp(a: number, b: number, t: number): number;
552
+ /**
553
+ * Clamp a value between min and max
554
+ *
555
+ * @param {number} v
556
+ * @param {number} min
557
+ * @param {number} max
558
+ * @returns {number}
559
+ */
560
+ clamp(v: number, min: number, max: number): number;
561
+ /**
562
+ * Clamp a value between 0 and 1
563
+ *
564
+ * @param {number} v
565
+ * @returns {number}
566
+ */
567
+ clamp01(v: number): number;
568
+ /**
569
+ * Linear easing
570
+ *
571
+ * @param {number} t
572
+ * @returns {number}
573
+ */
574
+ easeLinear(t: number): number;
575
+ /**
576
+ * Quadratic ease-in
577
+ *
578
+ * @param {number} t
579
+ * @returns {number}
580
+ */
581
+ easeInQuad(t: number): number;
582
+ /**
583
+ * Quadratic ease-out
584
+ *
585
+ * @param {number} t
586
+ * @returns {number}
587
+ */
588
+ easeOutQuad(t: number): number;
589
+ /**
590
+ * Quadratic ease-in-out
591
+ *
592
+ * @param {number} t
593
+ * @returns {number}
594
+ */
595
+ easeInOutQuad(t: number): number;
596
+ /**
597
+ * Sine ease-in
598
+ *
599
+ * @param {number} t
600
+ * @returns {number}
601
+ */
602
+ easeInSine(t: number): number;
603
+ /**
604
+ * Sine ease-out
605
+ *
606
+ * @param {number} t
607
+ * @returns {number}
608
+ */
609
+ easeOutSine(t: number): number;
610
+ /**
611
+ * Sine ease-in-out
612
+ *
613
+ * @param {number} t
614
+ * @returns {number}
615
+ */
616
+ easeInOutSine(t: number): number;
617
+ /**
618
+ * Expo ease-in
619
+ *
620
+ * @param {number} t
621
+ * @returns {number}
622
+ */
623
+ easeInExpo(t: number): number;
624
+ /**
625
+ * Expo ease-out
626
+ *
627
+ * @param {number} t
628
+ * @returns {number}
629
+ */
630
+ easeOutExpo(t: number): number;
631
+ /**
632
+ * Expo ease-in-out
633
+ *
634
+ * @param {number} t
635
+ * @returns {number}
636
+ */
637
+ easeInOutExpo(t: number): number;
638
+ /**
639
+ * Smoothstep easing
640
+ *
641
+ * @param {number} t
642
+ * @returns {number}
643
+ */
644
+ smoothstep(t: number): number;
645
+ /**
646
+ *
647
+ * @param {number} a
648
+ * @param {number} b
649
+ */
650
+ randomLerp(a: number, b: number): number;
651
+ /**
652
+ *
653
+ * @param {number} a
654
+ * @param {number} b
655
+ * @returns
656
+ */
657
+ randomInt(a: number, b: number): number;
658
+ /**
659
+ * @template T
660
+ * @param {T[]} arr
661
+ * @returns {T}
662
+ */
663
+ randomArrayValue<T>(arr: T[]): T;
664
+ /**
665
+ * Create a real cubic-bezier easing function
666
+ * (same behavior as CSS cubic-bezier)
667
+ *
668
+ * @param {number} x1
669
+ * @param {number} y1
670
+ * @param {number} x2
671
+ * @param {number} y2
672
+ * @returns {(t:number)=>number}
673
+ */
674
+ createBezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number;
675
+ /**
676
+ *
677
+ * @param {...number} values
678
+ * @returns
679
+ */
680
+ lengthSquared(...values: number[]): number;
681
+ /**
682
+ * Normalize an angle in radians to [0, 2π)
683
+ * @param {number} rad
684
+ * @returns {number}
685
+ */
686
+ normalizeRad(rad: number): number;
687
+ /**
688
+ * Convert a Y-down canvas angle to standard mathematical radian coordinates (Y-up)
689
+ * @param {number} rad
690
+ * @returns {number}
691
+ */
692
+ angleInvertY(rad: number): number;
693
+ /**
694
+ * Convert degrees to radians, flipping Y-axis for canvas (top-left origin)
695
+ * @param {number} deg
696
+ * @returns {number}
697
+ */
698
+ degToRadFlipY(deg: number): number;
699
+ /**
700
+ * Determines the **minimal angular rotation direction** along a unit circle
701
+ * Returns 1 if clockwise is the shorter path, -1 if counter-clockwise is shorter
702
+ * @param {number} fromRad - starting angle in radians
703
+ * @param {number} toRad - target angle in radians
704
+ * @returns {1 | -1}
705
+ */
706
+ minimalAngularDirection(fromRad: number, toRad: number): 1 | -1;
707
+ };
708
+ /**
709
+ * @fileoverview Delta-based tween for a single numeric change
710
+ */
711
+ declare class DeltaTweenII extends LeaEventEmitter<{
712
+ delta: number[];
713
+ finish: void[];
714
+ }> {
715
+ constructor({ delta, ms, easing, }: {
716
+ delta: number;
717
+ ms: number;
718
+ easing?: (t: number) => number;
719
+ });
720
+ delta: number;
721
+ duration: number;
722
+ elapsed: number;
723
+ lastValue: number;
724
+ finished: boolean;
725
+ easing: (t: number) => number;
726
+ /**
727
+ * Advance tween by delta time
728
+ */
729
+ update(delta: number): void;
730
+ }
731
+ /**
732
+ * Rectangular entity with centered position, width, height, and basic AABB collision.
733
+ *
734
+ * Automatically handles translation and rotation for drawing if needed.
735
+ *
736
+ * @extends LeaEntityII
737
+ */
738
+ declare abstract class RectLeaEntity extends LeaEntityII {
739
+ /**
740
+ * @param {string} name
741
+ * @param {number} x Center X
742
+ * @param {number} y Center Y
743
+ * @param {number} width
744
+ * @param {number} height
745
+ */
746
+ constructor(name: string, x?: number, y?: number, width?: number, height?: number);
747
+ /**
748
+ * Width of the rectangle (centered on x).
749
+ */
750
+ width: number;
751
+ /**
752
+ * Height of the rectangle (centered on y).
753
+ */
754
+ height: number;
755
+ /**
756
+ * Left edge of the bounding box.
757
+ */
758
+ get left(): number;
759
+ set left(val: number);
760
+ /**
761
+ * Right edge of the bounding box.
762
+ */
763
+ get right(): number;
764
+ set right(val: number);
765
+ /**
766
+ * Top edge of the bounding box.
767
+ */
768
+ get top(): number;
769
+ set top(val: number);
770
+ /**
771
+ * Bottom edge of the bounding box.
772
+ */
773
+ get bottom(): number;
774
+ set bottom(val: number);
775
+ get lx(): number;
776
+ get ly(): number;
777
+ get lleft(): number;
778
+ get lright(): number;
779
+ get ltop(): number;
780
+ get lbottom(): number;
781
+ /**
782
+ * Checks for axis-aligned bounding box collision with another rectangular entity.
783
+ *
784
+ * @param other - The other entity to check against
785
+ * @returns `true` if the bounding boxes overlap
786
+ */
787
+ isCollidingWith(other: RectLeaEntity): boolean;
788
+ /**
789
+ * Default fill color for the rectangle (used in base draw implementation).
790
+ */
791
+ color: string;
792
+ abstract update(_delta: number): void;
793
+ /**
794
+ * Draws a filled rectangle centered on the entity's position.
795
+ *
796
+ * Subclasses should override or call `super.draw(ctx)` if extending.
797
+ *
798
+ * @param ctx - The 2D rendering context
799
+ */
800
+ draw(ctx: CanvasRenderingContext2D): void;
801
+ }
802
+ declare class LeaTimeout extends LeaEventEmitter<{
803
+ finish: [void];
804
+ }> {
805
+ duration: number;
806
+ ticker: LeaTickerII;
807
+ elapsed: number;
808
+ finished: boolean;
809
+ _resolve: (value?: unknown) => void;
810
+ promise: Promise<unknown>;
811
+ _timeoutId: NodeJS.Timeout;
812
+ /**
813
+ * @param {number} duration Duration in milliseconds
814
+ * @param {LeaTickerII} ticker Optional ticker to drive the timeout
815
+ */
816
+ constructor(duration: number, ticker?: LeaTickerII);
817
+ update(delta?: number): void;
818
+ finish(): void;
819
+ /**
820
+ * Start the timeout manually if no ticker is provided
821
+ */
822
+ start(): this;
823
+ /**
824
+ * Cancel the timeout
825
+ */
826
+ cancel(): void;
827
+ then<TResult1 = unknown, TResult2 = never>(onfulfilled?: ((value: unknown) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
828
+ /**
829
+ * @type {Promise<void>['then']}
830
+ */
831
+ after<TResult1 = unknown, TResult2 = never>(onfulfilled?: ((value: unknown) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
832
+ }
833
+ /**
834
+ * 2D Vector class similar to Godot's Vector2
835
+ */
836
+ declare class Vector2 {
837
+ /**
838
+ * Creates a new Vector2
839
+ * @param {number} x
840
+ * @param {number} y
841
+ */
842
+ constructor(x?: number, y?: number);
843
+ x: number;
844
+ y: number;
845
+ toJSON(): {
846
+ x: number;
847
+ y: number;
848
+ vec2: boolean;
849
+ };
850
+ /**
851
+ *
852
+ * @param {any} data
853
+ */
854
+ static isVec2(data: any): boolean;
855
+ /**
856
+ *
857
+ * @param {any} data
858
+ */
859
+ static fromSerialized(data: any): Vector2;
860
+ /**
861
+ * Rotate vector by angle (radians) around origin
862
+ * @param {number} angle
863
+ */
864
+ rotate(angle: number): Vector2;
865
+ /**
866
+ * Returns a new Vector2 representing a unit vector pointing in the given angle (radians)
867
+ * @param {number} rad
868
+ * @returns {Vector2}
869
+ */
870
+ static from(rad: number): Vector2;
871
+ /**
872
+ * Returns the angle of the vector relative to the positive X-axis in radians
873
+ * @returns {number}
874
+ */
875
+ get angle(): number;
876
+ /**
877
+ * Returns the length (magnitude) of the vector
878
+ * @returns {number}
879
+ */
880
+ get length(): number;
881
+ /**
882
+ * Returns the squared length (more efficient)
883
+ * @returns {number}
884
+ */
885
+ get lengthSquared(): number;
886
+ /**
887
+ * Returns a normalized vector (length = 1)
888
+ * @returns {Vector2}
889
+ */
890
+ normalized(): Vector2;
891
+ project(other: Vector2): Vector2;
892
+ /**
893
+ * Reflects a normalized vector (length = 1)
894
+ * @returns {Vector2}
895
+ */
896
+ reflect(normal: Vector2): Vector2;
897
+ /**
898
+ * Alignment
899
+ * Dot product with another vector (normalized)
900
+ * @param {Vector2} other
901
+ * @returns {number} -1 .. 1 if vectors are normalized
902
+ */
903
+ dotNormalized(other: Vector2): number;
904
+ /**
905
+ *
906
+ * @param {Vector2} other
907
+ * @returns
908
+ */
909
+ lengthSquaredTo(other: Vector2): number;
910
+ /**
911
+ * Projection
912
+ * True dot product including magnitude
913
+ * @param {Vector2} other
914
+ * @returns {number}
915
+ */
916
+ dot(other: Vector2): number;
917
+ /**
918
+ * Distance to another vector
919
+ * @param {Vector2} other
920
+ * @returns {number}
921
+ */
922
+ distanceTo(other: Vector2): number;
923
+ /**
924
+ * Distance to another vector
925
+ * @param {Vector2} other
926
+ * @returns {number}
927
+ */
928
+ distanceToCheap(other: Vector2): number;
929
+ /**
930
+ * Returns a vector pointing from this vector to another
931
+ * @param {Vector2} other
932
+ * @returns {Vector2}
933
+ */
934
+ directionTo(other: Vector2): Vector2;
935
+ /**
936
+ * Adds another vector
937
+ * @param {Vector2} other
938
+ * @returns {Vector2}
939
+ */
940
+ add(other: Vector2): Vector2;
941
+ /**
942
+ * Adds another vector
943
+ * @param {number} raw
944
+ * @returns {Vector2}
945
+ */
946
+ addRaw(raw: number): Vector2;
947
+ /**
948
+ * Overwrite instance
949
+ * @param {Vector2} newVec
950
+ */
951
+ overwite(newVec: Vector2): void;
952
+ /**
953
+ * Subtracts another vector
954
+ * @param {Vector2} other
955
+ * @returns {Vector2}
956
+ */
957
+ subtract(other: Vector2): Vector2;
958
+ /**
959
+ * Scales the vector by a scalar
960
+ * @param {number} scalar
961
+ * @returns {Vector2}
962
+ */
963
+ scale(scalar: number): Vector2;
964
+ /**
965
+ * Returns a string representation
966
+ * @returns {string}
967
+ */
968
+ toString(): string;
969
+ /**
970
+ * Clones a vector.
971
+ * @returns {Vector2}
972
+ */
973
+ clone(): Vector2;
974
+ }
975
+ /**
976
+ *
977
+ * @param {string} col
978
+ */
979
+ declare function getNormalizedColor(col: string): {
980
+ r: number;
981
+ g: number;
982
+ b: number;
983
+ a: number;
984
+ };
985
+ /**
986
+ *
987
+ * @param {{ r: number; g: number; b: number; a:number }} col
988
+ */
989
+ declare function colToRGBA(col: {
990
+ r: number;
991
+ g: number;
992
+ b: number;
993
+ a: number;
994
+ }): string;
995
+ /**
996
+ * Extract numeric RGBA from ctx.fillStyle
997
+ * Supports hex (#rgb, #rrggbb) and rgb(a)
998
+ * @param {string} fillStyle
999
+ * @returns {{r:number, g:number, b:number, a:number}}
1000
+ */
1001
+ declare function parseFillStyle(fillStyle: string): {
1002
+ r: number;
1003
+ g: number;
1004
+ b: number;
1005
+ a: number;
1006
+ };
1007
+ /**
1008
+ *
1009
+ * @param {string} str
1010
+ * @param {{ r?: number; g?: number; b?: number; a?: number }} param1
1011
+ * @returns {string}
1012
+ */
1013
+ declare function editRGBA(str: string, { r, g, b, a }?: {
1014
+ r?: number;
1015
+ g?: number;
1016
+ b?: number;
1017
+ a?: number;
1018
+ }): string;
1019
+ /**
1020
+ * Scales a 2D coordinate relative to an origin.
1021
+ *
1022
+ * @param {number} absoluteCoord - The original coordinate.
1023
+ * @param {number} scale - The scale factor.
1024
+ * @param {number} origin - The origin point for scaling.
1025
+ * @returns {number} - The new scaled coordinate.
1026
+ */
1027
+ declare function scaleCoord(absoluteCoord: number, scale: number, origin: number): number;
1028
+ declare function getEnvironment(): "web" | "node" | "unknown";
1029
+ declare const ENVIRONMENT: "web" | "node" | "unknown";
1030
+ declare const isNode: boolean;
1031
+ declare const isWeb: boolean;
1032
+ declare class LiaAudio {
1033
+ static unlock(): void;
1034
+ /**
1035
+ * @type {AudioContext}
1036
+ */
1037
+ static audioCtx: AudioContext;
1038
+ static masterGain: GainNode;
1039
+ static musicGain: GainNode;
1040
+ static sfxGain: GainNode;
1041
+ static get SFX_VOLUME(): number;
1042
+ static get MUSIC_VOLUME(): number;
1043
+ static get VOLUME(): number;
1044
+ static set SFX_VOLUME(n: number);
1045
+ static set MUSIC_VOLUME(n: number);
1046
+ static set VOLUME(n: number);
1047
+ /**
1048
+ *
1049
+ * @param {number} note
1050
+ * @returns
1051
+ */
1052
+ static noteToHz(note: number): number;
1053
+ static tuningFreq: number;
1054
+ /**
1055
+ * @type {Map<string, AudioBuffer>}
1056
+ */
1057
+ static audioBufferCache: Map<string, AudioBuffer>;
1058
+ /**
1059
+ * @type {Map<number, { source: LiaAudioSrc, gain: GainNode }>}
1060
+ */
1061
+ static loops: Map<number, {
1062
+ source: LiaAudioSrc;
1063
+ gain: GainNode;
1064
+ }>;
1065
+ /**
1066
+ * @type {Map<string, { source: LiaAudioSrc, gain: GainNode }>}
1067
+ */
1068
+ static sfsx: Map<string, {
1069
+ source: LiaAudioSrc;
1070
+ gain: GainNode;
1071
+ }>;
1072
+ static loopIdCounter: number;
1073
+ static CACHE_NAME: string;
1074
+ /**
1075
+ * Preload and decode audio buffer
1076
+ * @param {string} path
1077
+ * @returns {Promise<AudioBuffer>}
1078
+ */
1079
+ static preLoad(path: string): Promise<AudioBuffer>;
1080
+ /**
1081
+ * @param {string} path
1082
+ * @returns {Promise<Response>}
1083
+ */
1084
+ static getOnlyDownloadedCache(path: string): Promise<Response>;
1085
+ /**
1086
+ * Get AudioBuffer (returns null if not yet loaded)
1087
+ * @param {string} path
1088
+ * @returns {AudioBuffer|null}
1089
+ */
1090
+ static getCached(path: string): AudioBuffer | null;
1091
+ /**
1092
+ * Play SFX once with optional volume
1093
+ * @param {string} path
1094
+ * @param {number} volume
1095
+ * @param {number | null} speed default to random
1096
+ */
1097
+ static playSound(path: string, volume?: number, speed?: number | null, override?: boolean): Promise<void>;
1098
+ /**
1099
+ * Play looping SFX and return loop id
1100
+ * @param {string} path
1101
+ * @param {number} volume
1102
+ * @param {Object} [param2={}]
1103
+ * @param {number} [param2.loopStart=0]
1104
+ * @param {null | number} [param2.loopEnd=null]
1105
+ * @param {boolean} [param2.exclusive=true]
1106
+ * @param {number} [param2.skipMS=0]
1107
+ * @returns {Promise<number | undefined>}
1108
+ */
1109
+ static playLoop(path: string, volume?: number, { loopStart, loopEnd, exclusive, skipMS, }?: {
1110
+ loopStart?: number;
1111
+ loopEnd?: null | number;
1112
+ exclusive?: boolean;
1113
+ skipMS?: number;
1114
+ }): Promise<number | undefined>;
1115
+ /**
1116
+ * Stop a loop by id
1117
+ * @param {number} id
1118
+ */
1119
+ static stopLoop(id: number): void;
1120
+ /**
1121
+ * Create a LiaAudioSrc from a file path without playing it.
1122
+ * @param {string} path - audio file path
1123
+ * @param {Object} [options={}]
1124
+ * @param {number} [options.volume=1]
1125
+ * @param {number} [options.speed=1]
1126
+ * @param {boolean} [options.loop=false]
1127
+ * @param {number} [options.loopStart=0]
1128
+ * @param {number|null} [options.loopEnd=null]
1129
+ * @param {boolean} [options.isMusic]
1130
+ * @returns {Promise<LiaAudioSrc|null>}
1131
+ */
1132
+ static createLiaSource(path: string, { volume, speed, loop, loopStart, loopEnd, isMusic, gain: parentGain, }?: {
1133
+ volume?: number;
1134
+ speed?: number;
1135
+ loop?: boolean;
1136
+ loopStart?: number;
1137
+ loopEnd?: number | null;
1138
+ isMusic?: boolean;
1139
+ gain?: GainNode;
1140
+ }): Promise<LiaAudioSrc | null>;
1141
+ }
1142
+ declare const NOTE_NAMES: readonly ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
1143
+ type NOTE_NAME = (typeof NOTE_NAMES)[number];
1144
+ declare function isNote(note: string): note is NOTE_NAME;
1145
+ /**
1146
+ * High-level AudioBufferSourceNode replacement with play/pause, fades, speed, and strict AudioNode interface.
1147
+ * @implements {AudioNode}
1148
+ */
1149
+ declare class LiaAudioSrc {
1150
+ numberOfInputs: number;
1151
+ numberOfOutputs: number;
1152
+ /**
1153
+ * @param {AudioBuffer} buffer
1154
+ * @param {AudioContext} [context=LiaSfx.audioCtx]
1155
+ */
1156
+ constructor(buffer: AudioBuffer, context?: AudioContext);
1157
+ channelCount: number;
1158
+ channelCountMode: string;
1159
+ channelInterpretation: string;
1160
+ onended: () => any;
1161
+ /**
1162
+ * @type {AudioBufferSourceNode|null}
1163
+ */
1164
+ source: AudioBufferSourceNode | null;
1165
+ /**
1166
+ * @type {AudioBuffer}
1167
+ */
1168
+ buffer: AudioBuffer;
1169
+ /**
1170
+ * @type {AudioContext}
1171
+ */
1172
+ context: AudioContext;
1173
+ _createSource(): AudioBufferSourceNode;
1174
+ /**
1175
+ * Start playback
1176
+ * @param {Object} [options]
1177
+ * @param {number} [options.fadeIn=0] - seconds to fade in
1178
+ * @param {number} [options.offset=null] - start offset in seconds
1179
+ */
1180
+ play({ fadeIn, offset, }?: {
1181
+ fadeIn?: number;
1182
+ offset?: number;
1183
+ }): void;
1184
+ /**
1185
+ * Start playback identical to AudioBufferSourceNode.start()
1186
+ * @param {number} [when=0] - seconds from context.currentTime to start
1187
+ * @param {number} [offset=0] - offset in seconds into the buffer
1188
+ * @param {number} [duration] - how long to play in seconds
1189
+ */
1190
+ start(when: number, offset: number, duration: number): void;
1191
+ /**
1192
+ * Pause playback
1193
+ * @param {Object} [options]
1194
+ * @param {number} [options.fadeOut=0] - seconds to fade out
1195
+ */
1196
+ pause({ fadeOut }?: {
1197
+ fadeOut?: number;
1198
+ }): void;
1199
+ /**
1200
+ * Get playback elapsed time in milliseconds
1201
+ * @returns {number}
1202
+ */
1203
+ getElapsed(): number;
1204
+ /**
1205
+ * Set playback speed
1206
+ * @param {number} rate
1207
+ */
1208
+ setSpeed(rate: number): void;
1209
+ /**
1210
+ * Set loop mode
1211
+ * @param {boolean} loop
1212
+ */
1213
+ setLoop(loop?: boolean): void;
1214
+ loop: boolean;
1215
+ playbackRate: number;
1216
+ startTime: number;
1217
+ /**
1218
+ * @type {GainNode}
1219
+ */
1220
+ tempGain: GainNode;
1221
+ /**
1222
+ * Connect node to AudioNode or AudioParam
1223
+ * @param {AudioNode|AudioParam} destination
1224
+ * @param {number} [output=0]
1225
+ * @param {number} [input=0]
1226
+ * @returns {AudioNode|undefined}
1227
+ */
1228
+ connect(destination: AudioNode | AudioParam, output?: number, input?: number): AudioNode | undefined;
1229
+ /**
1230
+ * Disconnect node from AudioNode or AudioParam
1231
+ * @param {AudioNode} [destinationOrOutput]
1232
+ * @param {number} [output]
1233
+ * @param {number} [input]
1234
+ */
1235
+ disconnect(destinationOrOutput: AudioNode, output: number, input: number): void;
1236
+ output: GainNode;
1237
+ /**
1238
+ * Stop playback immediately or at optional future time
1239
+ * @param {number} [when=0] - seconds from now to stop
1240
+ */
1241
+ stop(when?: number): void;
1242
+ pauseTime: number;
1243
+ isPlaying: boolean;
1244
+ notIndependent: boolean;
1245
+ /** @type {number} */
1246
+ loopStart: number;
1247
+ /** @type {number} */
1248
+ loopEnd: number;
1249
+ }
1250
+ interface SFXConfig {
1251
+ osc: {
1252
+ enabled: boolean;
1253
+ type: "sine" | "square" | "sawtooth" | "triangle";
1254
+ freq: number;
1255
+ detune: number;
1256
+ };
1257
+ noise: {
1258
+ enabled: boolean;
1259
+ level: number;
1260
+ };
1261
+ ampEnv: {
1262
+ attack: number;
1263
+ decay: number;
1264
+ sustain: number;
1265
+ release: number;
1266
+ volume: number;
1267
+ };
1268
+ pitchEnv: {
1269
+ amount: number;
1270
+ decay: number;
1271
+ };
1272
+ filter: {
1273
+ enabled: boolean;
1274
+ type: "lowpass" | "highpass" | "bandpass" | "notch";
1275
+ freq: number;
1276
+ Q: number;
1277
+ envAmount: number;
1278
+ decay: number;
1279
+ };
1280
+ lfo: {
1281
+ enabled: boolean;
1282
+ target: "freq" | "gain" | "filter";
1283
+ rate: number;
1284
+ depth: number;
1285
+ };
1286
+ duration: number;
1287
+ }
1288
+ /**
1289
+ * @type {SFXConfig}
1290
+ */
1291
+ declare const defaultSFXConfig: SFXConfig;
1292
+ declare class LiaOscSFX {
1293
+ /**
1294
+ *
1295
+ * @param {Partial<SFXConfig>} config
1296
+ */
1297
+ constructor(config?: Partial<SFXConfig>);
1298
+ ctx: typeof LiaAudio.audioCtx;
1299
+ /**
1300
+ * @type {SFXConfig}
1301
+ */
1302
+ cfg: SFXConfig;
1303
+ play(outputGain?: GainNode): void;
1304
+ /** @returns {SFXConfig} */
1305
+ getConfig(): SFXConfig;
1306
+ /** @param {Partial<SFXConfig>} patch */
1307
+ setConfig(patch: Partial<SFXConfig>): this;
1308
+ getKey<K extends keyof SFXConfig>(key: K): SFXConfig[K];
1309
+ setKey<K extends keyof SFXConfig>(key: K, value: Partial<SFXConfig[K]>): this;
1310
+ /** @param {SFXConfig['osc']['freq']} freq */
1311
+ setFreq(freq: SFXConfig["osc"]["freq"]): this;
1312
+ /** @param {SFXConfig['osc']['type']} type */
1313
+ setWave(type: SFXConfig["osc"]["type"]): this;
1314
+ /** @param {SFXConfig['ampEnv']['volume']} volume */
1315
+ setVolume(volume: SFXConfig["ampEnv"]["volume"]): this;
1316
+ /** @param {SFXConfig['ampEnv']['attack']} attack @param {SFXConfig['ampEnv']['decay']} decay @param {SFXConfig['ampEnv']['sustain']} sustain @param {SFXConfig['ampEnv']['release']} release */
1317
+ setAmpEnv(attack: SFXConfig["ampEnv"]["attack"], decay: SFXConfig["ampEnv"]["decay"], sustain: SFXConfig["ampEnv"]["sustain"], release: SFXConfig["ampEnv"]["release"]): this;
1318
+ /** @param {SFXConfig['pitchEnv']['amount']} amount @param {SFXConfig['pitchEnv']['decay']} decay */
1319
+ setPitchEnv(amount: SFXConfig["pitchEnv"]["amount"], decay: SFXConfig["pitchEnv"]["decay"]): this;
1320
+ /** @param {SFXConfig['noise']['enabled']} enabled */
1321
+ setNoiseEnabled(enabled: SFXConfig["noise"]["enabled"]): this;
1322
+ /** @param {SFXConfig['noise']['level']} level */
1323
+ setNoiseLevel(level: SFXConfig["noise"]["level"]): this;
1324
+ /** @param {SFXConfig['filter']['enabled']} enabled */
1325
+ setFilterEnabled(enabled: SFXConfig["filter"]["enabled"]): this;
1326
+ setFilter(type: SFXConfig["filter"]["type"], freq: SFXConfig["filter"]["freq"], Q: SFXConfig["filter"]["Q"]): this;
1327
+ setLFOEnabled(enabled: SFXConfig["lfo"]["enabled"]): this;
1328
+ /** @param {SFXConfig['lfo']['target']} target @param {SFXConfig['lfo']['rate']} rate @param {SFXConfig['lfo']['depth']} depth */
1329
+ setLFO(target: SFXConfig["lfo"]["target"], rate: SFXConfig["lfo"]["rate"], depth: SFXConfig["lfo"]["depth"]): this;
1330
+ /** @param {SFXConfig['duration']} duration */
1331
+ setDuration(duration: SFXConfig["duration"]): this;
1332
+ clone(): LiaOscSFX;
1333
+ }
1334
+ declare const sfxUIClick: LiaOscSFX;
1335
+ declare const sfxUIHover: LiaOscSFX;
1336
+ declare const sfxJump: LiaOscSFX;
1337
+ declare const sfxLaser: LiaOscSFX;
1338
+ declare const sfxHit: LiaOscSFX;
1339
+ declare const LiaSFXMap: Map<string, LiaOscSFX>;
1340
+ declare function shortUID(length?: number): string;
1341
+ declare function tinyUID(length?: number): string;
1342
+ /**
1343
+ * @template EventMap
1344
+ * Default event structure
1345
+ */
1346
+ type DefaultWSE<EventMap> = {
1347
+ open: void;
1348
+ close: void;
1349
+ error: Error;
1350
+ message: EventMap[keyof EventMap];
1351
+ key: {
1352
+ key: string;
1353
+ mode: 1 | 2;
1354
+ };
1355
+ };
1356
+ /**
1357
+ * Memory-based client for in-process IPC
1358
+ */
1359
+ declare class GEmitterMemory<Events extends DefaultWSE<Events>> {
1360
+ private peer;
1361
+ private key;
1362
+ private events;
1363
+ mbAcc: number;
1364
+ private connected;
1365
+ constructor();
1366
+ /** Connect to a peer client */
1367
+ connect(peer?: GEmitterMemory<Events>): void;
1368
+ /** Is connected */
1369
+ isConnected(): boolean;
1370
+ /** Add event listener */
1371
+ on<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): void;
1372
+ /** Remove event listener */
1373
+ off<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): void;
1374
+ /** Emit event internally */
1375
+ private _emit;
1376
+ /** Send message to peer */
1377
+ send<K extends keyof Events>(event: K, payload: Events[K]): void;
1378
+ /** Receive message from peer */
1379
+ private _receive;
1380
+ /** Disconnect */
1381
+ close(): void;
1382
+ /** Get the client's key */
1383
+ getKey(): string;
1384
+ }
1385
+ /** Cross-browser UUIDv4 generator */
1386
+ declare function generateUUID(): string;
1387
+ declare function setAnimInterval(callback: () => void): {
1388
+ clear: () => boolean;
1389
+ };
1390
+ type Side = "left" | "right" | "top" | "bottom";
1391
+ interface RayHit {
1392
+ side: Side;
1393
+ t: number;
1394
+ }
1395
+ interface RaycastResult extends RayHit {
1396
+ avoidAngle: number;
1397
+ }
1398
+ /**
1399
+ * Core: Raycast to single rectangle
1400
+ */
1401
+ declare function getRayHit(x0: number, y0: number, w: number, h: number, angle: number): RayHit | null;
1402
+ declare function getAvoidAngle(angle: number, side: Side): number;
1403
+ /**
1404
+ Full reusable raycast with avoidance
1405
+ */
1406
+ declare function raycastAvoid(x0: number, y0: number, w: number, h: number, angle: number): RaycastResult | null;
1407
+ declare function isMobile(): boolean;
1408
+ declare const isInitiallyMobile: boolean;
1409
+
1410
+ type LEA_DefaultWSE<EventMap> = DefaultWSE<EventMap>;
1411
+ type LEA_DeltaTweenII = DeltaTweenII;
1412
+ declare const LEA_DeltaTweenII: typeof DeltaTweenII;
1413
+ declare const LEA_ENVIRONMENT: typeof ENVIRONMENT;
1414
+ type LEA_GEmitterMemory<Events extends DefaultWSE<Events>> = GEmitterMemory<Events>;
1415
+ declare const LEA_GEmitterMemory: typeof GEmitterMemory;
1416
+ type LEA_LeaEntityII = LeaEntityII;
1417
+ declare const LEA_LeaEntityII: typeof LeaEntityII;
1418
+ type LEA_LeaEntitySerializer<T extends Record<string, any>> = LeaEntitySerializer<T>;
1419
+ type LEA_LeaEntitySerializerArray<T extends Record<string, any>> = LeaEntitySerializerArray<T>;
1420
+ type LEA_LeaEntitySerializerEach<T extends Record<string, any>, K extends keyof T = keyof T> = LeaEntitySerializerEach<T, K>;
1421
+ type LEA_LeaEventEmitter<Events extends Record<string, any[]>> = LeaEventEmitter<Events>;
1422
+ declare const LEA_LeaEventEmitter: typeof LeaEventEmitter;
1423
+ type LEA_LeaGameII = LeaGameII;
1424
+ declare const LEA_LeaGameII: typeof LeaGameII;
1425
+ type LEA_LeaRendererII = LeaRendererII;
1426
+ declare const LEA_LeaRendererII: typeof LeaRendererII;
1427
+ type LEA_LeaSceneII = LeaSceneII;
1428
+ declare const LEA_LeaSceneII: typeof LeaSceneII;
1429
+ declare const LEA_LeaSerializers: typeof LeaSerializers;
1430
+ type LEA_LeaTickerII = LeaTickerII;
1431
+ declare const LEA_LeaTickerII: typeof LeaTickerII;
1432
+ type LEA_LeaTimeout = LeaTimeout;
1433
+ declare const LEA_LeaTimeout: typeof LeaTimeout;
1434
+ declare const LEA_LeaUtilsII: typeof LeaUtilsII;
1435
+ type LEA_LiaAudio = LiaAudio;
1436
+ declare const LEA_LiaAudio: typeof LiaAudio;
1437
+ type LEA_LiaAudioSrc = LiaAudioSrc;
1438
+ declare const LEA_LiaAudioSrc: typeof LiaAudioSrc;
1439
+ type LEA_LiaOscSFX = LiaOscSFX;
1440
+ declare const LEA_LiaOscSFX: typeof LiaOscSFX;
1441
+ declare const LEA_LiaSFXMap: typeof LiaSFXMap;
1442
+ type LEA_Listener<T extends any[] = any[]> = Listener<T>;
1443
+ type LEA_NOTE_NAME = NOTE_NAME;
1444
+ declare const LEA_NOTE_NAMES: typeof NOTE_NAMES;
1445
+ type LEA_OrderedLeaEntitySerializer<T extends Record<string, any>, FirstKeys extends (keyof T)[]> = OrderedLeaEntitySerializer<T, FirstKeys>;
1446
+ type LEA_RayHit = RayHit;
1447
+ type LEA_RaycastResult = RaycastResult;
1448
+ type LEA_RectLeaEntity = RectLeaEntity;
1449
+ declare const LEA_RectLeaEntity: typeof RectLeaEntity;
1450
+ type LEA_SFXConfig = SFXConfig;
1451
+ type LEA_Side = Side;
1452
+ type LEA_Vector2 = Vector2;
1453
+ declare const LEA_Vector2: typeof Vector2;
1454
+ declare const LEA_colToRGBA: typeof colToRGBA;
1455
+ declare const LEA_defaultSFXConfig: typeof defaultSFXConfig;
1456
+ declare const LEA_editRGBA: typeof editRGBA;
1457
+ declare const LEA_generateUUID: typeof generateUUID;
1458
+ declare const LEA_getAvoidAngle: typeof getAvoidAngle;
1459
+ declare const LEA_getEnvironment: typeof getEnvironment;
1460
+ declare const LEA_getNormalizedColor: typeof getNormalizedColor;
1461
+ declare const LEA_getRayHit: typeof getRayHit;
1462
+ declare const LEA_isInitiallyMobile: typeof isInitiallyMobile;
1463
+ declare const LEA_isMobile: typeof isMobile;
1464
+ declare const LEA_isNode: typeof isNode;
1465
+ declare const LEA_isNote: typeof isNote;
1466
+ declare const LEA_isWeb: typeof isWeb;
1467
+ declare const LEA_parseFillStyle: typeof parseFillStyle;
1468
+ declare const LEA_raycastAvoid: typeof raycastAvoid;
1469
+ declare const LEA_scaleCoord: typeof scaleCoord;
1470
+ declare const LEA_setAnimInterval: typeof setAnimInterval;
1471
+ declare const LEA_sfxHit: typeof sfxHit;
1472
+ declare const LEA_sfxJump: typeof sfxJump;
1473
+ declare const LEA_sfxLaser: typeof sfxLaser;
1474
+ declare const LEA_sfxUIClick: typeof sfxUIClick;
1475
+ declare const LEA_sfxUIHover: typeof sfxUIHover;
1476
+ declare const LEA_shortUID: typeof shortUID;
1477
+ declare const LEA_tinyUID: typeof tinyUID;
1478
+ declare namespace LEA {
1479
+ export { type LEA_DefaultWSE as DefaultWSE, LEA_DeltaTweenII as DeltaTweenII, LEA_ENVIRONMENT as ENVIRONMENT, LEA_GEmitterMemory as GEmitterMemory, LEA_LeaEntityII as LeaEntityII, type LEA_LeaEntitySerializer as LeaEntitySerializer, type LEA_LeaEntitySerializerArray as LeaEntitySerializerArray, type LEA_LeaEntitySerializerEach as LeaEntitySerializerEach, LEA_LeaEventEmitter as LeaEventEmitter, LEA_LeaGameII as LeaGameII, LEA_LeaRendererII as LeaRendererII, LEA_LeaSceneII as LeaSceneII, LEA_LeaSerializers as LeaSerializers, LEA_LeaTickerII as LeaTickerII, LEA_LeaTimeout as LeaTimeout, LEA_LeaUtilsII as LeaUtilsII, LEA_LiaAudio as LiaAudio, LEA_LiaAudioSrc as LiaAudioSrc, LEA_LiaOscSFX as LiaOscSFX, LEA_LiaSFXMap as LiaSFXMap, type LEA_Listener as Listener, type LEA_NOTE_NAME as NOTE_NAME, LEA_NOTE_NAMES as NOTE_NAMES, type LEA_OrderedLeaEntitySerializer as OrderedLeaEntitySerializer, type LEA_RayHit as RayHit, type LEA_RaycastResult as RaycastResult, LEA_RectLeaEntity as RectLeaEntity, type LEA_SFXConfig as SFXConfig, type LEA_Side as Side, LEA_Vector2 as Vector2, LEA_colToRGBA as colToRGBA, LEA_defaultSFXConfig as defaultSFXConfig, LEA_editRGBA as editRGBA, LEA_generateUUID as generateUUID, LEA_getAvoidAngle as getAvoidAngle, LEA_getEnvironment as getEnvironment, LEA_getNormalizedColor as getNormalizedColor, LEA_getRayHit as getRayHit, LEA_isInitiallyMobile as isInitiallyMobile, LEA_isMobile as isMobile, LEA_isNode as isNode, LEA_isNote as isNote, LEA_isWeb as isWeb, LEA_parseFillStyle as parseFillStyle, LEA_raycastAvoid as raycastAvoid, LEA_scaleCoord as scaleCoord, LEA_setAnimInterval as setAnimInterval, LEA_sfxHit as sfxHit, LEA_sfxJump as sfxJump, LEA_sfxLaser as sfxLaser, LEA_sfxUIClick as sfxUIClick, LEA_sfxUIHover as sfxUIHover, LEA_shortUID as shortUID, LEA_tinyUID as tinyUID };
1480
+ }
1481
+
1482
+ export { shortUID as $, getAvoidAngle as A, getEnvironment as B, getNormalizedColor as C, type DefaultWSE as D, ENVIRONMENT as E, getRayHit as F, GEmitterMemory as G, isInitiallyMobile as H, isMobile as I, isNode as J, isNote as K, LEA as L, isWeb as M, type NOTE_NAME as N, type OrderedLeaEntitySerializer as O, parseFillStyle as P, raycastAvoid as Q, RectLeaEntity as R, type SFXConfig as S, scaleCoord as T, setAnimInterval as U, Vector2 as V, sfxHit as W, sfxJump as X, sfxLaser as Y, sfxUIClick as Z, sfxUIHover as _, LeaGameII as a, tinyUID as a0, LeaRendererII as b, LeaSceneII as c, DeltaTweenII as d, LeaEntityII as e, type LeaEntitySerializer as f, type LeaEntitySerializerArray as g, type LeaEntitySerializerEach as h, LeaEventEmitter as i, LeaSerializers as j, LeaTickerII as k, LeaTimeout as l, LeaUtilsII as m, LiaAudio as n, LiaAudioSrc as o, LiaOscSFX as p, LiaSFXMap as q, type Listener as r, NOTE_NAMES as s, type RayHit as t, type RaycastResult as u, type Side as v, colToRGBA as w, defaultSFXConfig as x, editRGBA as y, generateUUID as z };