@vpmedia/phaser 1.18.0 → 1.19.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 (80) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/phaser/core/cache.js +37 -16
  4. package/src/phaser/core/dom.js +3 -3
  5. package/src/phaser/core/input.js +13 -12
  6. package/src/phaser/core/input_handler.js +2 -1
  7. package/src/phaser/core/input_mouse.js +3 -2
  8. package/src/phaser/core/input_pointer.js +2 -1
  9. package/src/phaser/core/loader.js +70 -69
  10. package/src/phaser/core/scene_manager.js +1 -1
  11. package/src/phaser/core/signal_binding.js +16 -7
  12. package/src/phaser/core/tween.js +5 -4
  13. package/src/phaser/core/tween_data.js +2 -1
  14. package/src/phaser/display/canvas/renderer.js +8 -5
  15. package/src/phaser/display/display_object.js +2 -0
  16. package/src/phaser/display/graphics.js +4 -4
  17. package/src/phaser/display/image.js +6 -4
  18. package/src/phaser/display/text.js +41 -30
  19. package/src/phaser/display/webgl/abstract_filter.js +1 -1
  20. package/src/phaser/display/webgl/fast_sprite_batch.js +3 -1
  21. package/src/phaser/display/webgl/graphics.js +6 -6
  22. package/src/phaser/display/webgl/render_texture.js +3 -1
  23. package/src/phaser/display/webgl/renderer.js +9 -5
  24. package/src/phaser/display/webgl/shader/normal.js +1 -1
  25. package/src/phaser/display/webgl/shader_manager.js +3 -2
  26. package/src/phaser/display/webgl/sprite_batch.js +2 -1
  27. package/src/phaser/display/webgl/stencil_manager.js +8 -6
  28. package/typedefs/global.d.ts +1 -1
  29. package/types/phaser/core/cache.d.ts +68 -44
  30. package/types/phaser/core/cache.d.ts.map +1 -1
  31. package/types/phaser/core/dom.d.ts +6 -6
  32. package/types/phaser/core/dom.d.ts.map +1 -1
  33. package/types/phaser/core/input.d.ts +20 -19
  34. package/types/phaser/core/input.d.ts.map +1 -1
  35. package/types/phaser/core/input_handler.d.ts +5 -4
  36. package/types/phaser/core/input_handler.d.ts.map +1 -1
  37. package/types/phaser/core/input_mouse.d.ts +1 -1
  38. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  39. package/types/phaser/core/input_pointer.d.ts +3 -2
  40. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  41. package/types/phaser/core/loader.d.ts +104 -103
  42. package/types/phaser/core/loader.d.ts.map +1 -1
  43. package/types/phaser/core/scene_manager.d.ts +2 -2
  44. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  45. package/types/phaser/core/signal_binding.d.ts +23 -15
  46. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  47. package/types/phaser/core/tween.d.ts +8 -8
  48. package/types/phaser/core/tween.d.ts.map +1 -1
  49. package/types/phaser/core/tween_data.d.ts +6 -5
  50. package/types/phaser/core/tween_data.d.ts.map +1 -1
  51. package/types/phaser/display/button.d.ts +3 -2
  52. package/types/phaser/display/button.d.ts.map +1 -1
  53. package/types/phaser/display/canvas/renderer.d.ts +10 -7
  54. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  55. package/types/phaser/display/display_object.d.ts +5 -3
  56. package/types/phaser/display/display_object.d.ts.map +1 -1
  57. package/types/phaser/display/graphics.d.ts +6 -6
  58. package/types/phaser/display/graphics.d.ts.map +1 -1
  59. package/types/phaser/display/image.d.ts +14 -11
  60. package/types/phaser/display/image.d.ts.map +1 -1
  61. package/types/phaser/display/text.d.ts +61 -50
  62. package/types/phaser/display/text.d.ts.map +1 -1
  63. package/types/phaser/display/webgl/abstract_filter.d.ts +3 -3
  64. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  65. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +3 -2
  66. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  67. package/types/phaser/display/webgl/graphics.d.ts +13 -12
  68. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  69. package/types/phaser/display/webgl/render_texture.d.ts +5 -3
  70. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  71. package/types/phaser/display/webgl/renderer.d.ts +12 -8
  72. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  73. package/types/phaser/display/webgl/shader/normal.d.ts +2 -2
  74. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  75. package/types/phaser/display/webgl/shader_manager.d.ts +6 -5
  76. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  77. package/types/phaser/display/webgl/sprite_batch.d.ts +3 -2
  78. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  79. package/types/phaser/display/webgl/stencil_manager.d.ts +11 -9
  80. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
@@ -71,10 +71,11 @@ export class Text extends Image {
71
71
  * TBD.
72
72
  * @param {number} x - TBD.
73
73
  * @param {number} y - TBD.
74
- * @param color - TBD.
75
- * @param blur - TBD.
76
- * @param shadowStroke - TBD.
77
- * @param shadowFill - TBD.
74
+ * @param {string} color - TBD.
75
+ * @param {number} blur - TBD.
76
+ * @param {boolean} shadowStroke - TBD.
77
+ * @param {boolean} shadowFill - TBD.
78
+ * @returns {Text} TBD.
78
79
  */
79
80
  setShadow(x = 0, y = 0, color = 'rgba(0, 0, 0, 1)', blur = 0, shadowStroke = true, shadowFill = true) {
80
81
  this.style.shadowOffsetX = x;
@@ -89,8 +90,9 @@ export class Text extends Image {
89
90
 
90
91
  /**
91
92
  * TBD.
92
- * @param style
93
- * @param update
93
+ * @param {object} style - TBD.
94
+ * @param {boolean} update - TBD.
95
+ * @returns {Text} TBD.
94
96
  */
95
97
  setStyle(style = null, update = false) {
96
98
  style = JSON.parse(JSON.stringify(style)) || {};
@@ -298,10 +300,10 @@ export class Text extends Image {
298
300
 
299
301
  /**
300
302
  * TBD.
301
- * @param line - TBD.
303
+ * @param {string} line - TBD.
302
304
  * @param {number} x - TBD.
303
305
  * @param {number} y - TBD.
304
- * @param fill - TBD.
306
+ * @param {boolean} fill - TBD.
305
307
  */
306
308
  renderTabLine(line, x, y, fill) {
307
309
  const text = line.split(/(?:\t)/);
@@ -337,7 +339,7 @@ export class Text extends Image {
337
339
 
338
340
  /**
339
341
  * TBD.
340
- * @param state
342
+ * @param {string} state - TBD.
341
343
  */
342
344
  updateShadow(state) {
343
345
  if (state) {
@@ -355,7 +357,8 @@ export class Text extends Image {
355
357
 
356
358
  /**
357
359
  * TBD.
358
- * @param line - TBD.
360
+ * @param {string} line - TBD.
361
+ * @returns {number} TBD.
359
362
  */
360
363
  measureLine(line) {
361
364
  let lineLength = 0;
@@ -391,7 +394,7 @@ export class Text extends Image {
391
394
 
392
395
  /**
393
396
  * TBD.
394
- * @param line - TBD.
397
+ * @param {string} line - TBD.
395
398
  * @param {number} x - TBD.
396
399
  * @param {number} y - TBD.
397
400
  */
@@ -451,8 +454,8 @@ export class Text extends Image {
451
454
 
452
455
  /**
453
456
  * TBD.
454
- * @param color - TBD.
455
- * @param position - TBD.
457
+ * @param {number} color - TBD.
458
+ * @param {number} position - TBD.
456
459
  * @returns {Text} TBD.
457
460
  */
458
461
  addColor(color, position) {
@@ -463,8 +466,8 @@ export class Text extends Image {
463
466
 
464
467
  /**
465
468
  * TBD.
466
- * @param color - TBD.
467
- * @param position - TBD.
469
+ * @param {number} color - TBD.
470
+ * @param {number} position - TBD.
468
471
  * @returns {Text} TBD.
469
472
  */
470
473
  addStrokeColor(color, position) {
@@ -475,8 +478,8 @@ export class Text extends Image {
475
478
 
476
479
  /**
477
480
  * TBD.
478
- * @param style - TBD.
479
- * @param position - TBD.
481
+ * @param {object} style - TBD.
482
+ * @param {number} position - TBD.
480
483
  * @returns {Text} TBD.
481
484
  */
482
485
  addFontStyle(style, position) {
@@ -487,8 +490,8 @@ export class Text extends Image {
487
490
 
488
491
  /**
489
492
  * TBD.
490
- * @param weight - TBD.
491
- * @param position - TBD.
493
+ * @param {number} weight - TBD.
494
+ * @param {number} position - TBD.
492
495
  * @returns {Text} TBD.
493
496
  */
494
497
  addFontWeight(weight, position) {
@@ -499,7 +502,8 @@ export class Text extends Image {
499
502
 
500
503
  /**
501
504
  * TBD.
502
- * @param text - TBD.
505
+ * @param {string} text - TBD.
506
+ * @returns {string[]} TBD.
503
507
  */
504
508
  precalculateWordWrap(text) {
505
509
  this.texture.baseTexture.resolution = this._res;
@@ -510,7 +514,8 @@ export class Text extends Image {
510
514
 
511
515
  /**
512
516
  * TBD.
513
- * @param text - TBD.
517
+ * @param {string} text - TBD.
518
+ * @returns {string} TBD.
514
519
  */
515
520
  runWordWrap(text) {
516
521
  if (this.useAdvancedWrap) {
@@ -521,7 +526,9 @@ export class Text extends Image {
521
526
 
522
527
  /**
523
528
  * TBD.
524
- * @param text - TBD.
529
+ * @param {string} text - TBD.
530
+ * @returns {string} TBD.
531
+ * @throws Error.
525
532
  */
526
533
  advancedWordWrap(text) {
527
534
  const context = this.context;
@@ -602,7 +609,8 @@ export class Text extends Image {
602
609
 
603
610
  /**
604
611
  * TBD.
605
- * @param text - TBD.
612
+ * @param {string} text - TBD.
613
+ * @returns {string} TBD.
606
614
  */
607
615
  basicWordWrap(text) {
608
616
  let result = '';
@@ -634,7 +642,7 @@ export class Text extends Image {
634
642
 
635
643
  /**
636
644
  * TBD.
637
- * @param components
645
+ * @param {object} components - TBD.
638
646
  */
639
647
  updateFont(components) {
640
648
  const font = this.componentsToFont(components);
@@ -649,7 +657,7 @@ export class Text extends Image {
649
657
 
650
658
  /**
651
659
  * TBD.
652
- * @param font - TBD.
660
+ * @param {string} font - TBD.
653
661
  * @returns {object} TBD.
654
662
  */
655
663
  fontToComponents(font) {
@@ -685,7 +693,8 @@ export class Text extends Image {
685
693
 
686
694
  /**
687
695
  * TBD.
688
- * @param components - TBD.
696
+ * @param {object} components - TBD.
697
+ * @returns {string} TBD.
689
698
  */
690
699
  componentsToFont(components) {
691
700
  const parts = [];
@@ -719,8 +728,8 @@ export class Text extends Image {
719
728
 
720
729
  /**
721
730
  * TBD.
722
- * @param text - TBD.
723
- * @param immediate - TBD.
731
+ * @param {string} text - TBD.
732
+ * @param {boolean} immediate - TBD.
724
733
  * @returns {Text} TBD.
725
734
  */
726
735
  setText(text, immediate = false) {
@@ -735,7 +744,7 @@ export class Text extends Image {
735
744
 
736
745
  /**
737
746
  * TBD.
738
- * @param list
747
+ * @param {string[]|string[][]} list - TBD.
739
748
  * @returns {Text} TBD.
740
749
  */
741
750
  parseList(list) {
@@ -876,6 +885,7 @@ export class Text extends Image {
876
885
 
877
886
  /**
878
887
  * TBD.
888
+ * @returns {CanvasRenderingContext2D} TBD.
879
889
  */
880
890
  getFontPropertiesContext() {
881
891
  if (!window.PhaserRegistry.fontPropertiesContext) {
@@ -888,7 +898,8 @@ export class Text extends Image {
888
898
 
889
899
  /**
890
900
  * TBD.
891
- * @param fontStyle
901
+ * @param {string} fontStyle - TBD.
902
+ * @returns {object} TBD.
892
903
  */
893
904
  determineFontProperties(fontStyle) {
894
905
  const fontPropertiesCache = this.getFontPropertiesCache();
@@ -1,7 +1,7 @@
1
1
  export class AbstractFilter {
2
2
  /**
3
3
  * TBD.
4
- * @param fragmentSrc - TBD.
4
+ * @param {string[]} fragmentSrc - TBD.
5
5
  * @param {object} uniforms - TBD.
6
6
  */
7
7
  constructor(fragmentSrc, uniforms) {
@@ -1,3 +1,5 @@
1
+ import { Image } from '../image';
2
+
1
3
  export class FastSpriteBatch {
2
4
  /**
3
5
  * TBD.
@@ -96,7 +98,7 @@ export class FastSpriteBatch {
96
98
 
97
99
  /**
98
100
  * TBD.
99
- * @param sprite - TBD.
101
+ * @param {Image} sprite - TBD.
100
102
  */
101
103
  renderSprite(sprite) {
102
104
  if (!sprite.visible) {
@@ -53,7 +53,7 @@ export function switchMode(webGL, type) {
53
53
  /**
54
54
  * TBD.
55
55
  * @param {object} graphicsData - TBD.
56
- * @param {object} webGLData - TBD.
56
+ * @param {GraphicsData} webGLData - TBD.
57
57
  */
58
58
  export function buildLine(graphicsData, webGLData) {
59
59
  // TODO OPTIMISE!
@@ -218,7 +218,7 @@ export function buildLine(graphicsData, webGLData) {
218
218
  /**
219
219
  * TBD.
220
220
  * @param {object} graphicsData - TBD.
221
- * @param {object} webGLData - TBD.
221
+ * @param {GraphicsData} webGLData - TBD.
222
222
  */
223
223
  export function buildRectangle(graphicsData, webGLData) {
224
224
  //
@@ -301,7 +301,7 @@ export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
301
301
  /**
302
302
  * TBD.
303
303
  * @param {object} graphicsData - TBD.
304
- * @param {object} webGLData - TBD.
304
+ * @param {GraphicsData} webGLData - TBD.
305
305
  */
306
306
  export function buildRoundedRectangle(graphicsData, webGLData) {
307
307
  const rrectData = graphicsData.shape;
@@ -351,7 +351,7 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
351
351
  /**
352
352
  * TBD.
353
353
  * @param {object} graphicsData - TBD.
354
- * @param {object} webGLData - TBD.
354
+ * @param {GraphicsData} webGLData - TBD.
355
355
  */
356
356
  export function buildCircle(graphicsData, webGLData) {
357
357
  // need to convert points to a nice regular data
@@ -402,7 +402,7 @@ export function buildCircle(graphicsData, webGLData) {
402
402
  /**
403
403
  * TBD.
404
404
  * @param {object} graphicsData - TBD.
405
- * @param {object} webGLData - TBD.
405
+ * @param {GraphicsData} webGLData - TBD.
406
406
  */
407
407
  export function buildComplexPoly(graphicsData, webGLData) {
408
408
  // TODO - no need to copy this as it gets turned into a Float32Array anyways..
@@ -446,7 +446,7 @@ export function buildComplexPoly(graphicsData, webGLData) {
446
446
  /**
447
447
  * TBD.
448
448
  * @param {object} graphicsData - TBD.
449
- * @param {object} webGLData - TBD.
449
+ * @param {GraphicsData} webGLData - TBD.
450
450
  * @returns {boolean} TBD.
451
451
  */
452
452
  export function buildPoly(graphicsData, webGLData) {
@@ -4,6 +4,8 @@ import { Texture } from './texture';
4
4
  import { BaseTexture } from './base_texture';
5
5
  import { FilterTexture } from './filter_texture';
6
6
  import { CanvasBuffer } from '../canvas/buffer';
7
+ import { CanvasRenderer } from '../canvas/renderer';
8
+ import { WebGLRenderer } from './renderer';
7
9
  import { RENDER_WEBGL } from '../../core/const';
8
10
 
9
11
  export class RenderTexture extends Texture {
@@ -11,7 +13,7 @@ export class RenderTexture extends Texture {
11
13
  * TBD.
12
14
  * @param {number} width - TBD.
13
15
  * @param {number} height - TBD.
14
- * @param renderer - TBD.
16
+ * @param {WebGLRenderer|CanvasRenderer} renderer - TBD.
15
17
  * @param {number} scaleMode - TBD.
16
18
  * @param {number} resolution - TBD.
17
19
  */
@@ -29,6 +29,9 @@ import * as WebGLMaskManager from './mask_manager';
29
29
  import { WebGLFilterManager } from './filter_manager';
30
30
  import { WebGLStencilManager } from './stencil_manager';
31
31
  import { WebGLBlendModeManager } from './blend_manager';
32
+ import { BaseTexture } from './base_texture';
33
+ import { DisplayObject } from '../../display/display_object';
34
+ import { Stage } from '../../core/stage';
32
35
  import { Game } from '../../core/game';
33
36
 
34
37
  export class WebGLRenderer {
@@ -121,6 +124,7 @@ export class WebGLRenderer {
121
124
 
122
125
  /**
123
126
  * TBD.
127
+ * @throws Error.
124
128
  */
125
129
  initContext() {
126
130
  const gl =
@@ -154,7 +158,7 @@ export class WebGLRenderer {
154
158
 
155
159
  /**
156
160
  * TBD.
157
- * @param stage - TBD.
161
+ * @param {Stage} stage - TBD.
158
162
  */
159
163
  render(stage) {
160
164
  if (this.contextLost) {
@@ -176,9 +180,9 @@ export class WebGLRenderer {
176
180
 
177
181
  /**
178
182
  * TBD.
179
- * @param displayObject - TBD.
180
- * @param projection - TBD.
181
- * @param buffer - TBD.
183
+ * @param {DisplayObject} displayObject - TBD.
184
+ * @param {Point} projection - TBD.
185
+ * @param {object} buffer - TBD.
182
186
  * @param {Matrix} matrix - TBD.
183
187
  */
184
188
  renderDisplayObject(displayObject, projection, buffer, matrix) {
@@ -222,7 +226,7 @@ export class WebGLRenderer {
222
226
 
223
227
  /**
224
228
  * TBD.
225
- * @param texture - TBD.
229
+ * @param {BaseTexture} texture - TBD.
226
230
  * @returns {boolean} TBD.
227
231
  */
228
232
  updateTexture(texture) {
@@ -131,7 +131,7 @@ export class NormalShader {
131
131
 
132
132
  /**
133
133
  * TBD.
134
- * @param uniform - TBD.
134
+ * @param {object} uniform - TBD.
135
135
  */
136
136
  initSampler2D(uniform) {
137
137
  if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) {
@@ -40,7 +40,7 @@ export class WebGLShaderManager {
40
40
 
41
41
  /**
42
42
  * TBD.
43
- * @param attribs - TBD.
43
+ * @param {number[]} attribs - TBD.
44
44
  */
45
45
  setAttribs(attribs) {
46
46
  // reset temp state
@@ -68,7 +68,8 @@ export class WebGLShaderManager {
68
68
 
69
69
  /**
70
70
  * TBD.
71
- * @param shader - TBD.
71
+ * @param {NormalShader} shader - TBD.
72
+ * @returns {boolean} TBD.
72
73
  */
73
74
  setShader(shader) {
74
75
  if (this._currentId === shader._UID) {
@@ -2,6 +2,7 @@ import { AbstractFilter } from './abstract_filter';
2
2
  import { NormalShader } from './shader/normal';
3
3
  import { BaseTexture } from './base_texture';
4
4
  import { Matrix } from '../../geom/matrix';
5
+ import { Image } from '../../display/image';
5
6
 
6
7
  export class WebGLSpriteBatch {
7
8
  /**
@@ -88,7 +89,7 @@ export class WebGLSpriteBatch {
88
89
 
89
90
  /**
90
91
  * TBD.
91
- * @param sprite - TBD.
92
+ * @param {Image} sprite - TBD.
92
93
  * @param {Matrix} matrix - TBD.
93
94
  */
94
95
  render(sprite, matrix) {
@@ -1,4 +1,6 @@
1
1
  import { hex2rgb } from '../../util/math';
2
+ import { GraphicsData } from './graphics_data';
3
+ import { Graphics } from '../../display/graphics';
2
4
 
3
5
  export class WebGLStencilManager {
4
6
  /**
@@ -28,8 +30,8 @@ export class WebGLStencilManager {
28
30
 
29
31
  /**
30
32
  * TBD.
31
- * @param graphics - TBD.
32
- * @param webGLData - TBD.
33
+ * @param {Graphics} graphics - TBD.
34
+ * @param {GraphicsData} webGLData - TBD.
33
35
  * @param {object} renderSession - TBD.
34
36
  */
35
37
  pushStencil(graphics, webGLData, renderSession) {
@@ -86,8 +88,8 @@ export class WebGLStencilManager {
86
88
 
87
89
  /**
88
90
  * TBD.
89
- * @param graphics - TBD.
90
- * @param webGLData - TBD.
91
+ * @param {Graphics} graphics - TBD.
92
+ * @param {GraphicsData} webGLData - TBD.
91
93
  * @param {object} renderSession - TBD.
92
94
  */
93
95
  bindGraphics(graphics, webGLData, renderSession) {
@@ -133,8 +135,8 @@ export class WebGLStencilManager {
133
135
 
134
136
  /**
135
137
  * TBD.
136
- * @param graphics - TBD.
137
- * @param webGLData - TBD.
138
+ * @param {Graphics} graphics - TBD.
139
+ * @param {GraphicsData} webGLData - TBD.
138
140
  * @param {object} renderSession - TBD.
139
141
  */
140
142
  popStencil(graphics, webGLData, renderSession) {
@@ -1,6 +1,6 @@
1
1
  declare global {
2
2
  interface Window {
3
- PhaserRegistry: object;
3
+ PhaserRegistry: any;
4
4
  }
5
5
  }
6
6