@vpmedia/phaser 1.0.34 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "@babel/preset-env": "^7.20.2",
24
24
  "@babel/register": "^7.18.9",
25
25
  "babel-loader": "^8.3.0",
26
- "eslint": "^8.28.0",
26
+ "eslint": "^8.29.0",
27
27
  "eslint-config-prettier": "^8.5.0",
28
28
  "eslint-plugin-import": "^2.26.0",
29
29
  "eslint-plugin-jest": "^27.1.6",
@@ -31,7 +31,7 @@
31
31
  "eslint-plugin-prettier": "^4.2.1",
32
32
  "husky": "^8.0.2",
33
33
  "jest": "^29.3.1",
34
- "lint-staged": "^13.0.4",
34
+ "lint-staged": "^13.1.0",
35
35
  "prettier": "^2.8.0",
36
36
  "webpack": "^5.75.0",
37
37
  "webpack-cli": "^4.10.0"
@@ -85,14 +85,6 @@ export function JSONData(game, json) {
85
85
 
86
86
  }
87
87
 
88
- /**
89
- *
90
- */
91
- export function JSONDataPyxel() {
92
- // TODO
93
- console.warn('animation_parser.JSONDataPyxel() is not implemented');
94
- }
95
-
96
88
  /**
97
89
  *
98
90
  * @param {object} game TBD
@@ -121,11 +113,3 @@ export function JSONDataHash(game, json) {
121
113
  }
122
114
  return data;
123
115
  }
124
-
125
- /**
126
- *
127
- */
128
- export function XMLData() {
129
- // TODO
130
- console.warn('animation_parser.XMLData() is not implemented');
131
- }
@@ -8,8 +8,7 @@ import BaseTexture from '../display/webgl/base_texture';
8
8
  import Signal from './signal';
9
9
  import Frame from './frame';
10
10
  import FrameData from './frame_data';
11
- import { XMLData, JSONData, JSONDataHash, JSONDataPyxel } from './animation_parser';
12
- import { TEXTURE_ATLAS_XML_STARLING, TEXTURE_ATLAS_JSON_PYXEL } from './const';
11
+ import { JSONData, JSONDataHash } from './animation_parser';
13
12
  import { jsonBitmapFont, xmlBitmapFont } from './loader_parser';
14
13
 
15
14
  export const CANVAS = 1;
@@ -24,7 +23,6 @@ export const BITMAPDATA = 9;
24
23
  export const BITMAPFONT = 10;
25
24
  export const JSON = 11;
26
25
  export const XML = 12;
27
- export const VIDEO = 13;
28
26
  export const SHADER = 14;
29
27
  export const RENDER_TEXTURE = 15;
30
28
 
@@ -38,7 +36,6 @@ export default class {
38
36
  image: {},
39
37
  texture: {},
40
38
  sound: {},
41
- video: {},
42
39
  text: {},
43
40
  json: {},
44
41
  xml: {},
@@ -67,7 +64,6 @@ export default class {
67
64
  this._cacheMap[BITMAPFONT] = this._cache.bitmapFont;
68
65
  this._cacheMap[JSON] = this._cache.json;
69
66
  this._cacheMap[XML] = this._cache.xml;
70
- this._cacheMap[VIDEO] = this._cache.video;
71
67
  this._cacheMap[SHADER] = this._cache.shader;
72
68
  this._cacheMap[RENDER_TEXTURE] = this._cache.renderTexture;
73
69
  this.addDefaultImage();
@@ -110,18 +106,14 @@ export default class {
110
106
  return img;
111
107
  }
112
108
 
113
- addTextureAtlas(key, url, data, atlasData, format) {
109
+ addTextureAtlas(key, url, data, atlasData) {
114
110
  const obj = {
115
111
  key,
116
112
  url,
117
113
  data,
118
114
  base: new BaseTexture(data),
119
115
  };
120
- if (format === TEXTURE_ATLAS_XML_STARLING) {
121
- obj.frameData = XMLData(this.game, atlasData, key);
122
- } else if (format === TEXTURE_ATLAS_JSON_PYXEL) {
123
- obj.frameData = JSONDataPyxel(this.game, atlasData, key);
124
- } else if (Array.isArray(atlasData.frames)) {
116
+ if (Array.isArray(atlasData.frames)) {
125
117
  // Let's just work it out from the frames array
126
118
  obj.frameData = JSONData(this.game, atlasData, key);
127
119
  } else {
@@ -287,8 +279,6 @@ export default class {
287
279
  return this.checkKey(XML, key);
288
280
  }
289
281
 
290
- // TODO video shader rendertexture physics
291
-
292
282
  // GET
293
283
 
294
284
  getItem(key, cache, method, property = null) {
@@ -357,10 +347,6 @@ export default class {
357
347
  return this.getItem(key, XML, 'getXML', 'data');
358
348
  }
359
349
 
360
- getVideo(key) {
361
- return this.getItem(key, VIDEO, 'getVideo');
362
- }
363
-
364
350
  getShader(key) {
365
351
  return this.getItem(key, SHADER, 'getShader', 'data');
366
352
  }
@@ -490,10 +476,6 @@ export default class {
490
476
  delete this._cache.xml[key];
491
477
  }
492
478
 
493
- removeVideo(key) {
494
- delete this._cache.video[key];
495
- }
496
-
497
479
  removeShader(key) {
498
480
  delete this._cache.shader[key];
499
481
  }
@@ -94,12 +94,7 @@ export const EMITTER = 11; // deprecated
94
94
  export const RETROFONT = 18; // deprecated
95
95
  export const ROPE = 20; // deprecated
96
96
  export const CREATURE = 27; // deprecated
97
- export const VIDEO = 28; // deprecated
98
97
  export const PENDING_ATLAS = -1;
99
98
  // sprite sheet atlas
100
99
  export const TEXTURE_ATLAS_JSON_ARRAY = 0;
101
100
  export const TEXTURE_ATLAS_JSON_HASH = 1;
102
- export const TEXTURE_ATLAS_XML_STARLING = 2;
103
- export const PHYSICS_LIME_CORONA_JSON = 3; // deprecated
104
- export const PHYSICS_PHASER_JSON = 4; // deprecated
105
- export const TEXTURE_ATLAS_JSON_PYXEL = 5;
@@ -31,12 +31,6 @@ export default class {
31
31
  this.m4a = false;
32
32
  this.webm = false;
33
33
  this.dolby = false;
34
- this.oggVideo = false;
35
- this.h264Video = false;
36
- this.mp4Video = false;
37
- this.webmVideo = false;
38
- this.vp9Video = false;
39
- this.hlsVideo = false;
40
34
  this.iPhone = false;
41
35
  this.iPad = false;
42
36
  this.pixelRatio = 1;
@@ -29,25 +29,6 @@ export function canPlayAudio(device, type) {
29
29
  return false;
30
30
  }
31
31
 
32
- /**
33
- *
34
- * @param {object} device TBD
35
- * @param {string} type TBD
36
- * @returns {boolean} TBD
37
- */
38
- export function canPlayVideo(device, type) {
39
- if (type === 'webm' && (device.webmVideo || device.vp9Video)) {
40
- return true;
41
- } else if (type === 'mp4' && (device.mp4Video || device.h264Video)) {
42
- return true;
43
- } else if ((type === 'ogg' || type === 'ogv') && device.oggVideo) {
44
- return true;
45
- } else if (type === 'mpeg' && device.hlsVideo) {
46
- return true;
47
- }
48
- return false;
49
- }
50
-
51
32
  /**
52
33
  *
53
34
  * @param {object} device TBD
@@ -170,37 +151,6 @@ export function checkBrowser(device) {
170
151
  }
171
152
  }
172
153
 
173
- /**
174
- *
175
- * @param {object} device TBD
176
- */
177
- export function checkVideo(device) {
178
- const videoElement = document.createElement('video');
179
- try {
180
- if (videoElement.canPlayType) {
181
- if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) {
182
- device.oggVideo = true;
183
- }
184
- if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) {
185
- // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546
186
- device.h264Video = true;
187
- device.mp4Video = true;
188
- }
189
- if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) {
190
- device.webmVideo = true;
191
- }
192
- if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) {
193
- device.vp9Video = true;
194
- }
195
- if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) {
196
- device.hlsVideo = true;
197
- }
198
- }
199
- } catch (e) {
200
- // pass
201
- }
202
- }
203
-
204
154
  /**
205
155
  *
206
156
  * @param {object} device TBD
@@ -259,7 +209,6 @@ export function initialize(device) {
259
209
  checkOS(device);
260
210
  checkBrowser(device);
261
211
  checkAudio(device);
262
- checkVideo(device);
263
212
  checkDevice(device);
264
213
  checkFullScreenSupport(device);
265
214
  checkInput(device);
@@ -6,7 +6,7 @@
6
6
  import Signal from './signal';
7
7
  import Rectangle from '../geom/rectangle';
8
8
  import { canPlayAudio } from './device_util';
9
- import { TEXTURE_ATLAS_JSON_ARRAY, TEXTURE_ATLAS_JSON_HASH, TEXTURE_ATLAS_XML_STARLING, TEXTURE_ATLAS_JSON_PYXEL } from './const';
9
+ import { TEXTURE_ATLAS_JSON_ARRAY, TEXTURE_ATLAS_JSON_HASH } from './const';
10
10
 
11
11
  export const TILED_JSON = 6;
12
12
  export const TILEMAP_CSV = 7;
@@ -278,12 +278,6 @@ export default class {
278
278
  return this;
279
279
  }
280
280
 
281
- video() {
282
- // TODO
283
- console.warn('loader.video() is not implemented');
284
- return this;
285
- }
286
-
287
281
  tilemap() {
288
282
  // TODO
289
283
  console.warn('loader.tilemap() is not implemented');
@@ -335,36 +329,14 @@ export default class {
335
329
  textureURL = key + '.png';
336
330
  }
337
331
  if (!atlasURL && !atlasData) {
338
- if (format === TEXTURE_ATLAS_XML_STARLING) {
339
- atlasURL = key + '.xml';
340
- } else {
341
- atlasURL = key + '.json';
342
- }
332
+ atlasURL = key + '.json';
343
333
  }
344
334
  // A URL to a json/xml file has been given
345
335
  if (atlasURL) {
346
336
  this.addToFileList('textureatlas', key, textureURL, { atlasURL, format });
347
337
  } else {
348
- switch (format) {
349
- // A json string or object has been given
350
- case TEXTURE_ATLAS_JSON_ARRAY:
351
- if (typeof atlasData === 'string') {
352
- atlasData = JSON.parse(atlasData);
353
- }
354
- break;
355
- // An xml string or object has been given
356
- case TEXTURE_ATLAS_XML_STARLING:
357
- if (typeof atlasData === 'string') {
358
- const xml = this.parseXml(atlasData);
359
- if (!xml) {
360
- throw new Error('Invalid Texture Atlas XML given');
361
- }
362
- atlasData = xml;
363
- }
364
- break;
365
- default:
366
- // pass
367
- break;
338
+ if (format === TEXTURE_ATLAS_JSON_ARRAY && typeof atlasData === 'string') {
339
+ atlasData = JSON.parse(atlasData);
368
340
  }
369
341
  this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData, format });
370
342
  }
@@ -562,9 +534,6 @@ export default class {
562
534
  case "spritesheet":
563
535
  this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
564
536
  break;
565
- case "video":
566
- this.video(file.key, file.urls ? file.urls : file.url);
567
- break;
568
537
  case "audio":
569
538
  this.audio(file.key, file.urls ? file.urls : file.url);
570
539
  break;
@@ -624,18 +593,6 @@ export default class {
624
593
  this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
625
594
  }
626
595
  break;
627
- case 'video':
628
- file.url = this.getVideoURL(file.url);
629
- if (file.url) {
630
- if (file.asBlob) {
631
- this.xhrLoad(file, this.transformUrl(file.url, file), 'blob', this.fileComplete);
632
- } else {
633
- this.loadVideoTag(file);
634
- }
635
- } else {
636
- this.fileError(file, null, 'No supported video URL specified or device does not have video playback support');
637
- }
638
- break;
639
596
  case 'json':
640
597
  this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.jsonLoadComplete);
641
598
  break;
@@ -690,11 +647,6 @@ export default class {
690
647
  file.data.src = this.transformUrl(file.url, file);
691
648
  }
692
649
 
693
- loadVideoTag() {
694
- // TODO
695
- console.warn('loader.loadVideoTag() is not implemented');
696
- }
697
-
698
650
  xhrLoad(file, url, type, onload, onerror) {
699
651
  const xhr = new XMLHttpRequest();
700
652
  xhr.open('GET', url, true);
@@ -810,10 +762,8 @@ export default class {
810
762
  } else {
811
763
  // Load the JSON or XML before carrying on with the next file
812
764
  loadNext = false;
813
- if (file.format === TEXTURE_ATLAS_JSON_ARRAY || file.format === TEXTURE_ATLAS_JSON_HASH || file.format === TEXTURE_ATLAS_JSON_PYXEL) {
765
+ if (file.format === TEXTURE_ATLAS_JSON_ARRAY || file.format === TEXTURE_ATLAS_JSON_HASH) {
814
766
  this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
815
- } else if (file.format === TEXTURE_ATLAS_XML_STARLING) {
816
- this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.xmlLoadComplete);
817
767
  } else {
818
768
  throw new Error('Invalid Texture Atlas format: ' + file.format);
819
769
  }
@@ -843,16 +793,6 @@ export default class {
843
793
  });
844
794
  }
845
795
  break;
846
- case 'video':
847
- if (file.asBlob) {
848
- try {
849
- file.data = xhr.response;
850
- } catch (e) {
851
- throw new Error('Unable to parse video file as Blob: ' + file.key);
852
- }
853
- }
854
- this.cache.addVideo(file.key, file.url, file.data, file.asBlob);
855
- break;
856
796
  case 'audio':
857
797
  file.data = xhr.response;
858
798
  this.cache.addSound(file.key, file.url, file.data);