@vpmedia/phaser 1.117.0 → 1.118.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.
Files changed (37) hide show
  1. package/dist/index.js +140 -134
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation_manager.d.ts +1 -1
  4. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  5. package/dist/phaser/core/cache.d.ts +70 -42
  6. package/dist/phaser/core/cache.d.ts.map +1 -1
  7. package/dist/phaser/core/input.d.ts +1 -1
  8. package/dist/phaser/core/input.d.ts.map +1 -1
  9. package/dist/phaser/core/input_mspointer.d.ts +8 -7
  10. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  11. package/dist/phaser/core/loader.d.ts +30 -1
  12. package/dist/phaser/core/loader.d.ts.map +1 -1
  13. package/dist/phaser/core/loader_parser.d.ts +24 -4
  14. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  15. package/dist/phaser/core/sound.d.ts +13 -3
  16. package/dist/phaser/core/sound.d.ts.map +1 -1
  17. package/dist/phaser/core/tween.d.ts +3 -3
  18. package/dist/phaser/core/tween.d.ts.map +1 -1
  19. package/dist/phaser/core/tween_manager.d.ts +8 -6
  20. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  21. package/dist/phaser/display/bitmap_text.d.ts +13 -8
  22. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  23. package/package.json +1 -1
  24. package/src/phaser/core/animation_manager.ts +1 -1
  25. package/src/phaser/core/cache.test.ts +201 -0
  26. package/src/phaser/core/cache.ts +126 -86
  27. package/src/phaser/core/input.ts +1 -1
  28. package/src/phaser/core/input_mspointer.ts +10 -13
  29. package/src/phaser/core/loader.ts +82 -42
  30. package/src/phaser/core/loader_parser.test.ts +115 -0
  31. package/src/phaser/core/loader_parser.ts +64 -36
  32. package/src/phaser/core/sound.ts +29 -17
  33. package/src/phaser/core/sound_manager.ts +1 -1
  34. package/src/phaser/core/tween.ts +6 -6
  35. package/src/phaser/core/tween_manager.ts +42 -35
  36. package/src/phaser/display/bitmap_text.test.ts +212 -0
  37. package/src/phaser/display/bitmap_text.ts +39 -24
@@ -1,3 +1,4 @@
1
+ import type { TextureSource } from '../display/webgl/base_texture.js';
1
2
  import { BaseTexture } from '../display/webgl/base_texture.js';
2
3
  import { Texture } from '../display/webgl/texture.js';
3
4
  import { JSONDataHash, spriteSheet } from './animation_parser.js';
@@ -5,6 +6,7 @@ import { Frame } from './frame.js';
5
6
  import { FrameData } from './frame_data.js';
6
7
  import { jsonBitmapFont, xmlBitmapFont } from './loader_parser.js';
7
8
  import { Signal } from './signal.js';
9
+ import type { BitmapFontData } from './loader_parser.js';
8
10
  import type { Game } from './game.js';
9
11
 
10
12
  export const CANVAS = 0;
@@ -18,28 +20,66 @@ export const JSONDATA = 7;
18
20
  export const XML = 8;
19
21
  export const RENDER_TEXTURE = 9;
20
22
 
23
+ /** An image, sprite sheet or texture atlas: the source bitmap and the frames cut from it. */
24
+ export type ImageCacheEntry = {
25
+ key: string;
26
+ url: string;
27
+ data: TextureSource;
28
+ base: BaseTexture;
29
+ frame?: Frame;
30
+ frameData: FrameData | null;
31
+ };
32
+
33
+ /** Audio as the cache holds it: the raw bytes on load, an AudioBuffer once decoded. */
34
+ export type SoundData = ArrayBuffer | AudioBuffer;
35
+
36
+ /** A sound and how far its decoding has got. */
37
+ export type SoundCacheEntry = {
38
+ url: string;
39
+ data: SoundData;
40
+ isDecoding: boolean;
41
+ decoded: boolean;
42
+ };
43
+
44
+ /** A bitmap font: the glyph atlas and the descriptor parsed from it. */
45
+ export type BitmapFontCacheEntry = {
46
+ url: string;
47
+ data: TextureSource;
48
+ font: BitmapFontData;
49
+ base: BaseTexture;
50
+ };
51
+
52
+ /** A text, JSON or XML payload under the URL it came from. */
53
+ export type DataCacheEntry<T> = {
54
+ url: string;
55
+ data: T;
56
+ };
57
+
58
+ /** Anything the cache can hold, whichever bucket it lives in. */
59
+ export type CacheEntry = ImageCacheEntry | SoundCacheEntry | BitmapFontCacheEntry | DataCacheEntry<unknown>;
60
+
21
61
  interface CacheBuckets {
22
- canvas: Record<string, any>;
23
- image: Record<string, any>;
24
- texture: Record<string, any>;
25
- sound: Record<string, any>;
26
- text: Record<string, any>;
27
- json: Record<string, any>;
28
- xml: Record<string, any>;
29
- bitmapData: Record<string, any>;
30
- bitmapFont: Record<string, any>;
31
- renderTexture: Record<string, any>;
62
+ canvas: Record<string, CacheEntry>;
63
+ image: Record<string, ImageCacheEntry>;
64
+ texture: Record<string, CacheEntry>;
65
+ sound: Record<string, SoundCacheEntry>;
66
+ text: Record<string, DataCacheEntry<string>>;
67
+ json: Record<string, DataCacheEntry<unknown>>;
68
+ xml: Record<string, DataCacheEntry<XMLDocument>>;
69
+ bitmapData: Record<string, CacheEntry>;
70
+ bitmapFont: Record<string, BitmapFontCacheEntry>;
71
+ renderTexture: Record<string, CacheEntry>;
32
72
  }
33
73
 
34
74
  export class Cache {
35
75
  public game!: Game;
36
76
  public autoResolveURL!: boolean;
37
77
  public _cache!: CacheBuckets;
38
- public _urlMap!: Record<string, unknown> | null;
78
+ public _urlMap!: Record<string, object> | null;
39
79
  public _urlResolver!: HTMLImageElement | null;
40
80
  public _urlTemp!: string | null;
41
81
  public onSoundUnlock!: Signal;
42
- public _cacheMap!: Record<string, any>[];
82
+ public _cacheMap!: Record<string, CacheEntry>[];
43
83
  /**
44
84
  * Creates a new Cache instance.
45
85
  * @param {Game} game - The game instance.
@@ -108,7 +148,7 @@ export class Cache {
108
148
  * @param {HTMLImageElement} data - The image data to cache.
109
149
  * @returns {object} The cached image object.
110
150
  */
111
- public addImage(key: string, url: string | null, data: HTMLImageElement) {
151
+ public addImage(key: string, url: string | null, data: HTMLImageElement): ImageCacheEntry {
112
152
  const resolvedUrl = url ?? '';
113
153
  if (this.checkImageKey(key)) {
114
154
  this.removeImage(key);
@@ -169,14 +209,14 @@ export class Cache {
169
209
  * @param {HTMLCanvasElement} data - The canvas data for the atlas.
170
210
  * @param {object} atlasData - The atlas data to cache.
171
211
  */
172
- public addTextureAtlas(key: string, url: string, data: HTMLCanvasElement, atlasData: any): void {
173
- const obj: any = {
212
+ public addTextureAtlas(key: string, url: string, data: TextureSource, atlasData: unknown): void {
213
+ const obj: ImageCacheEntry = {
174
214
  key,
175
215
  url,
176
216
  data,
177
217
  base: new BaseTexture(data),
218
+ frameData: JSONDataHash(this.game, atlasData, key),
178
219
  };
179
- obj.frameData = JSONDataHash(this.game, atlasData, key);
180
220
  this._cache.image[key] = obj;
181
221
  this._resolveURL(url, obj);
182
222
  }
@@ -187,14 +227,15 @@ export class Cache {
187
227
  * @param {string} url - The URL the sound was loaded from.
188
228
  * @param {object} data - The sound data to cache.
189
229
  */
190
- public addSound(key: string, url: string, data: any): void {
191
- this._cache.sound[key] = {
230
+ public addSound(key: string, url: string, data: SoundData): void {
231
+ const obj: SoundCacheEntry = {
192
232
  url,
193
233
  data,
194
234
  isDecoding: false,
195
235
  decoded: false,
196
236
  };
197
- this._resolveURL(url, this._cache.sound[key]);
237
+ this._cache.sound[key] = obj;
238
+ this._resolveURL(url, obj);
198
239
  }
199
240
 
200
241
  /**
@@ -204,8 +245,9 @@ export class Cache {
204
245
  * @param {string} data - The text data to cache.
205
246
  */
206
247
  public addText(key: string, url: string, data: string): void {
207
- this._cache.text[key] = { url, data };
208
- this._resolveURL(url, this._cache.text[key]);
248
+ const obj: DataCacheEntry<string> = { url, data };
249
+ this._cache.text[key] = obj;
250
+ this._resolveURL(url, obj);
209
251
  }
210
252
 
211
253
  /**
@@ -221,23 +263,18 @@ export class Cache {
221
263
  public addBitmapFont(
222
264
  key: string,
223
265
  url: string,
224
- data: HTMLCanvasElement,
225
- atlasData: any,
266
+ data: TextureSource,
267
+ atlasData: unknown,
226
268
  atlasType: string,
227
269
  xSpacing = 0,
228
270
  ySpacing = 0
229
271
  ): void {
230
- const obj: { url: string; data: unknown; font: object | null; base: BaseTexture } = {
231
- url,
232
- data,
233
- font: null,
234
- base: new BaseTexture(data),
235
- };
236
- if (atlasType === 'json') {
237
- obj.font = jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
238
- } else {
239
- obj.font = xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
240
- }
272
+ const base = new BaseTexture(data);
273
+ const font =
274
+ atlasType === 'json'
275
+ ? jsonBitmapFont(atlasData, base, xSpacing, ySpacing)
276
+ : xmlBitmapFont(atlasData as XMLDocument, base, xSpacing, ySpacing);
277
+ const obj: BitmapFontCacheEntry = { url, data, font, base };
241
278
  this._cache.bitmapFont[key] = obj;
242
279
  this._resolveURL(url, obj);
243
280
  }
@@ -248,9 +285,10 @@ export class Cache {
248
285
  * @param {string} url - The URL the JSON was loaded from.
249
286
  * @param {object} data - The JSON data to cache.
250
287
  */
251
- public addJSON(key: string, url: string, data: any): void {
252
- this._cache.json[key] = { url, data };
253
- this._resolveURL(url, this._cache.json[key]);
288
+ public addJSON(key: string, url: string, data: unknown): void {
289
+ const obj: DataCacheEntry<unknown> = { url, data };
290
+ this._cache.json[key] = obj;
291
+ this._resolveURL(url, obj);
254
292
  }
255
293
 
256
294
  /**
@@ -260,8 +298,9 @@ export class Cache {
260
298
  * @param {XMLDocument} data - The XML data to cache.
261
299
  */
262
300
  public addXML(key: string, url: string, data: XMLDocument): void {
263
- this._cache.xml[key] = { url, data };
264
- this._resolveURL(url, this._cache.xml[key]);
301
+ const obj: DataCacheEntry<XMLDocument> = { url, data };
302
+ this._cache.xml[key] = obj;
303
+ this._resolveURL(url, obj);
265
304
  }
266
305
 
267
306
  // SOUND
@@ -272,7 +311,7 @@ export class Cache {
272
311
  * @param {string} property - The property to update.
273
312
  * @param {any} value - The new value for the property.
274
313
  */
275
- public updateSound(key: string, property: string, value: any): void {
314
+ public updateSound<K extends keyof SoundCacheEntry>(key: string, property: K, value: SoundCacheEntry[K]): void {
276
315
  const sound = this.getSound(key);
277
316
  if (sound) {
278
317
  sound[property] = value;
@@ -286,6 +325,9 @@ export class Cache {
286
325
  */
287
326
  public decodedSound(key: string, data: AudioBuffer): void {
288
327
  const sound = this.getSound(key);
328
+ if (!sound) {
329
+ return;
330
+ }
289
331
  sound.data = data;
290
332
  sound.decoded = true;
291
333
  sound.isDecoding = false;
@@ -296,8 +338,8 @@ export class Cache {
296
338
  * @param {string} key - The unique key for the cached sound.
297
339
  * @returns {boolean} True if the sound is decoded, false otherwise.
298
340
  */
299
- public isSoundDecoded(key: string) {
300
- const sound = this.getItem(key, SOUND, 'isSoundDecoded');
341
+ public isSoundDecoded(key: string): boolean | null {
342
+ const sound = this.getSound(key);
301
343
  if (sound) {
302
344
  return sound.decoded;
303
345
  }
@@ -309,8 +351,8 @@ export class Cache {
309
351
  * @param {string} key - The unique key for the cached sound.
310
352
  * @returns {boolean} True if the sound is ready, false otherwise.
311
353
  */
312
- public isSoundReady(key: string) {
313
- const sound = this.getItem(key, SOUND, 'isSoundDecoded');
354
+ public isSoundReady(key: string): boolean {
355
+ const sound = this.getSound(key);
314
356
  if (sound) {
315
357
  return sound.decoded && !this.game.sound.isLocked;
316
358
  }
@@ -436,13 +478,13 @@ export class Cache {
436
478
  * @param {string} property - TBD.
437
479
  * @returns {*} TBD.
438
480
  */
439
- public getItem(key: string, cache: number, _method: string, property: string | null = null) {
481
+ public getItem(key: string, cache: number, _method: string, property: string | null = null): unknown {
440
482
  if (this.checkKey(cache, key)) {
441
- const entry = this._cacheMap[cache]![key];
483
+ const entry = this._cacheMap[cache]![key]!;
442
484
  if (!property) {
443
485
  return entry;
444
486
  }
445
- return entry[property];
487
+ return (entry as Record<string, unknown>)[property];
446
488
  }
447
489
  return null;
448
490
  }
@@ -452,8 +494,8 @@ export class Cache {
452
494
  * @param {string} key - TBD.
453
495
  * @returns {HTMLCanvasElement} TBD.
454
496
  */
455
- public getCanvas(key: string) {
456
- return this.getItem(key, CANVAS, 'getCanvas', 'canvas');
497
+ public getCanvas(key: string): HTMLCanvasElement | null {
498
+ return this.getItem(key, CANVAS, 'getCanvas', 'canvas') as HTMLCanvasElement | null;
457
499
  }
458
500
 
459
501
  /**
@@ -462,11 +504,11 @@ export class Cache {
462
504
  * @param {boolean} full - TBD.
463
505
  * @returns {HTMLImageElement} TBD.
464
506
  */
465
- public getImage(key: string | number = '__default', full = false) {
466
- let img = this.getItem(String(key), IMAGE, 'getImage');
467
- if (img === null) {
468
- img = this.getItem('__missing', IMAGE, 'getImage');
469
- }
507
+ public getImage(key?: string | number, full?: false): TextureSource;
508
+ public getImage(key: string | number | undefined, full: true): ImageCacheEntry;
509
+ public getImage(key: string | number = '__default', full = false): TextureSource | ImageCacheEntry {
510
+ const img = (this.getItem(String(key), IMAGE, 'getImage') ??
511
+ this.getItem('__missing', IMAGE, 'getImage')) as ImageCacheEntry;
470
512
  if (full) {
471
513
  return img;
472
514
  }
@@ -478,8 +520,8 @@ export class Cache {
478
520
  * @param {string} key - TBD.
479
521
  * @returns {object} TBD.
480
522
  */
481
- public getTextureFrame(key: string) {
482
- return this.getItem(key, TEXTURE, 'getTextureFrame', 'frame');
523
+ public getTextureFrame(key: string): Frame | null {
524
+ return this.getItem(key, TEXTURE, 'getTextureFrame', 'frame') as Frame | null;
483
525
  }
484
526
 
485
527
  /**
@@ -487,8 +529,8 @@ export class Cache {
487
529
  * @param {string} key - TBD.
488
530
  * @returns {object} TBD.
489
531
  */
490
- public getSound(key: string) {
491
- return this.getItem(key, SOUND, 'getSound');
532
+ public getSound(key: string): SoundCacheEntry | null {
533
+ return this.getItem(key, SOUND, 'getSound') as SoundCacheEntry | null;
492
534
  }
493
535
 
494
536
  /**
@@ -496,8 +538,8 @@ export class Cache {
496
538
  * @param {string} key - TBD.
497
539
  * @returns {object} TBD.
498
540
  */
499
- public getSoundData(key: string) {
500
- return this.getItem(key, SOUND, 'getSoundData', 'data');
541
+ public getSoundData(key: string): SoundData | null {
542
+ return this.getItem(key, SOUND, 'getSoundData', 'data') as SoundData | null;
501
543
  }
502
544
 
503
545
  /**
@@ -505,8 +547,8 @@ export class Cache {
505
547
  * @param {string} key - TBD.
506
548
  * @returns {object} TBD.
507
549
  */
508
- public getText(key: string) {
509
- return this.getItem(key, TEXT, 'getText', 'data');
550
+ public getText(key: string): string | null {
551
+ return this.getItem(key, TEXT, 'getText', 'data') as string | null;
510
552
  }
511
553
 
512
554
  /**
@@ -514,7 +556,7 @@ export class Cache {
514
556
  * @param {string} key - TBD.
515
557
  * @returns {object} TBD.
516
558
  */
517
- public getBitmapData(key: string) {
559
+ public getBitmapData(key: string): unknown {
518
560
  return this.getItem(key, BITMAPDATA, 'getBitmapData', 'data');
519
561
  }
520
562
 
@@ -523,8 +565,8 @@ export class Cache {
523
565
  * @param {string} key - TBD.
524
566
  * @returns {object} TBD.
525
567
  */
526
- public getBitmapFont(key: string) {
527
- return this.getItem(key, BITMAPFONT, 'getBitmapFont');
568
+ public getBitmapFont(key: string): BitmapFontCacheEntry | null {
569
+ return this.getItem(key, BITMAPFONT, 'getBitmapFont') as BitmapFontCacheEntry | null;
528
570
  }
529
571
 
530
572
  /**
@@ -535,7 +577,7 @@ export class Cache {
535
577
  * @returns {T} The cached JSON data.
536
578
  */
537
579
  public getJSON<T = unknown>(key: string, isClone = false): T {
538
- const data = this.getItem(key, JSONDATA, 'getJSON', 'data');
580
+ const data = this.getItem(key, JSONDATA, 'getJSON', 'data') as T;
539
581
  return isClone ? structuredClone(data) : data;
540
582
  }
541
583
 
@@ -544,8 +586,8 @@ export class Cache {
544
586
  * @param {string} key - TBD.
545
587
  * @returns {XMLDocument} TBD.
546
588
  */
547
- public getXML(key: string) {
548
- return this.getItem(key, XML, 'getXML', 'data');
589
+ public getXML(key: string): XMLDocument | null {
590
+ return this.getItem(key, XML, 'getXML', 'data') as XMLDocument | null;
549
591
  }
550
592
 
551
593
  /**
@@ -553,8 +595,8 @@ export class Cache {
553
595
  * @param {string} key - TBD.
554
596
  * @returns {RenderTexture} TBD.
555
597
  */
556
- public getRenderTexture(key: string) {
557
- return this.getItem(key, RENDER_TEXTURE, 'getRenderTexture');
598
+ public getRenderTexture(key: string): CacheEntry | null {
599
+ return this.getItem(key, RENDER_TEXTURE, 'getRenderTexture') as CacheEntry | null;
558
600
  }
559
601
 
560
602
  // FRAME
@@ -565,8 +607,8 @@ export class Cache {
565
607
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
566
608
  * @returns {BaseTexture} The base texture.
567
609
  */
568
- public getBaseTexture(key: string, cache: number = IMAGE) {
569
- return this.getItem(key, cache, 'getBaseTexture', 'base');
610
+ public getBaseTexture(key: string, cache: number = IMAGE): BaseTexture | null {
611
+ return this.getItem(key, cache, 'getBaseTexture', 'base') as BaseTexture | null;
570
612
  }
571
613
 
572
614
  /**
@@ -575,8 +617,8 @@ export class Cache {
575
617
  * @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
576
618
  * @returns {Frame} The frame.
577
619
  */
578
- public getFrame(key: string, cache: number = IMAGE) {
579
- return this.getItem(key, cache, 'getFrame', 'frame');
620
+ public getFrame(key: string, cache: number = IMAGE): Frame | null {
621
+ return this.getItem(key, cache, 'getFrame', 'frame') as Frame | null;
580
622
  }
581
623
 
582
624
  /**
@@ -600,7 +642,7 @@ export class Cache {
600
642
  * @returns {FrameData | null} The frame data, or null when the entry has none.
601
643
  */
602
644
  public getFrameData(key: string, cache: number = IMAGE): FrameData | null {
603
- return this.getItem(key, cache, 'getFrameData', 'frameData');
645
+ return this.getItem(key, cache, 'getFrameData', 'frameData') as FrameData | null;
604
646
  }
605
647
 
606
648
  /**
@@ -622,7 +664,7 @@ export class Cache {
622
664
  public updateFrameData(key: string, frameData: FrameData, cache: number = IMAGE): void {
623
665
  const entry = this._cacheMap[cache]?.[key];
624
666
  if (entry) {
625
- entry.frameData = frameData;
667
+ (entry as ImageCacheEntry).frameData = frameData;
626
668
  }
627
669
  }
628
670
 
@@ -677,8 +719,9 @@ export class Cache {
677
719
  */
678
720
  public getKeys(cache: number = IMAGE): string[] {
679
721
  const result = [];
680
- if (this._cacheMap[cache]) {
681
- const keys = Object.keys(this._cacheMap[cache]);
722
+ const bucket = this._cacheMap[cache];
723
+ if (bucket) {
724
+ const keys = Object.keys(bucket);
682
725
  for (const key of keys) {
683
726
  if (key !== '__default' && key !== '__missing') {
684
727
  result.push(key);
@@ -705,7 +748,7 @@ export class Cache {
705
748
  */
706
749
  public removeImage(key: string, destroyBaseTexture = true): void {
707
750
  const img = this.getImage(key, true);
708
- if (destroyBaseTexture && img.base) {
751
+ if (destroyBaseTexture) {
709
752
  img.base.destroy();
710
753
  }
711
754
  delete this._cache.image[key];
@@ -787,9 +830,8 @@ export class Cache {
787
830
  * Clears all GL textures from the cache.
788
831
  */
789
832
  public clearGLTextures(): void {
790
- const keys = Object.keys(this._cache.image);
791
- for (const key of keys) {
792
- this._cache.image[key].base._glTextures = [];
833
+ for (const entry of Object.values(this._cache.image)) {
834
+ entry.base._glTextures = [];
793
835
  }
794
836
  }
795
837
 
@@ -799,7 +841,7 @@ export class Cache {
799
841
  * @param {object} data - The data to associate with the resolved URL.
800
842
  * @returns {string} The resolved URL or null if not enabled.
801
843
  */
802
- public _resolveURL(url: string, data: any | null = null) {
844
+ public _resolveURL(url: string, data: object | null = null): string | null {
803
845
  if (!this.autoResolveURL) {
804
846
  return null;
805
847
  }
@@ -825,9 +867,7 @@ export class Cache {
825
867
  const keys = cache ? Object.keys(cache) : [];
826
868
  for (const key of keys) {
827
869
  if (key !== '__default' && key !== '__missing') {
828
- if (cache[key].destroy) {
829
- cache[key].destroy();
830
- }
870
+ (cache[key] as { destroy?: () => void }).destroy?.();
831
871
  delete cache[key];
832
872
  }
833
873
  }
@@ -383,7 +383,7 @@ export class Input {
383
383
  * @param {number} identifier - TBD.
384
384
  * @returns {Pointer} TBD.
385
385
  */
386
- public getPointerFromIdentifier(identifier: number): Pointer | null {
386
+ public getPointerFromIdentifier(identifier: number | undefined): Pointer | null {
387
387
  for (const pointer of this.pointers) {
388
388
  if (pointer.identifier === identifier) {
389
389
  return pointer;
@@ -1,16 +1,17 @@
1
1
  import type { Game } from './game.js';
2
2
  import type { InputEvent } from './input_event.js';
3
+ import type { Input } from './input.js';
3
4
  export class MSPointer {
4
5
  public game!: Game;
5
- public input!: any;
6
+ public input!: Input;
6
7
  public callbackContext!: unknown;
7
- public pointerDownCallback!: any;
8
- public pointerMoveCallback!: any;
9
- public pointerUpCallback!: any;
10
- public capture!: any;
11
- public button!: any;
8
+ public pointerDownCallback: EventListener | null;
9
+ public pointerMoveCallback: EventListener | null;
10
+ public pointerUpCallback: EventListener | null;
11
+ public capture!: boolean;
12
+ public button!: number;
12
13
  public event!: InputEvent | null;
13
- public enabled!: any;
14
+ public enabled!: boolean;
14
15
  public _onMSPointerDown: EventListener | null;
15
16
  public _onMSPointerMove: EventListener | null;
16
17
  public _onMSPointerUp: EventListener | null;
@@ -113,9 +114,7 @@ export class MSPointer {
113
114
  canvas.removeEventListener('pointerup', this._onMSPointerUp, false);
114
115
  }
115
116
  if (this._onMSPointerUpGlobal) {
116
- if (this._onMSPointerUpGlobal) {
117
- globalThis.removeEventListener('MSPointerUp', this._onMSPointerUpGlobal, true);
118
- }
117
+ globalThis.removeEventListener('MSPointerUp', this._onMSPointerUpGlobal, true);
119
118
  }
120
119
  if (this._onMSPointerOver) {
121
120
  canvas.removeEventListener('MSPointerOver', this._onMSPointerOver, true);
@@ -125,9 +124,7 @@ export class MSPointer {
125
124
  }
126
125
  // IE11+ uses non-prefix events
127
126
  if (this._onMSPointerUpGlobal) {
128
- if (this._onMSPointerUpGlobal) {
129
- globalThis.removeEventListener('pointerup', this._onMSPointerUpGlobal, true);
130
- }
127
+ globalThis.removeEventListener('pointerup', this._onMSPointerUpGlobal, true);
131
128
  }
132
129
  if (this._onMSPointerOver) {
133
130
  canvas.removeEventListener('pointerover', this._onMSPointerOver, true);