@vpmedia/phaser 1.0.34 → 1.0.36

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.36",
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"
@@ -59,40 +59,6 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
59
59
  return data;
60
60
  }
61
61
 
62
- /**
63
- *
64
- * @param {object} game TBD
65
- * @param {object} json TBD
66
- * @returns {object} TBD
67
- */
68
- export function JSONData(game, json) {
69
- // Malformed?
70
- if (!json.frames) {
71
- return null;
72
- }
73
- // Let's create some frames then
74
- const data = new FrameData();
75
- // By this stage frames is a fully parsed array
76
- const frames = json.frames;
77
- let newFrame;
78
- for (let i = 0; i < frames.length; i += 1) {
79
- newFrame = data.addFrame(new Frame(i, frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename));
80
- if (frames[i].trimmed) {
81
- newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h);
82
- }
83
- }
84
- return data;
85
-
86
- }
87
-
88
- /**
89
- *
90
- */
91
- export function JSONDataPyxel() {
92
- // TODO
93
- console.warn('animation_parser.JSONDataPyxel() is not implemented');
94
- }
95
-
96
62
  /**
97
63
  *
98
64
  * @param {object} game TBD
@@ -121,11 +87,3 @@ export function JSONDataHash(game, json) {
121
87
  }
122
88
  return data;
123
89
  }
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 { 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,23 +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)) {
125
- // Let's just work it out from the frames array
126
- obj.frameData = JSONData(this.game, atlasData, key);
127
- } else {
128
- obj.frameData = JSONDataHash(this.game, atlasData, key);
129
- }
116
+ obj.frameData = JSONDataHash(this.game, atlasData, key);
130
117
  this._cache.image[key] = obj;
131
118
  this._resolveURL(url, obj);
132
119
  }
@@ -287,8 +274,6 @@ export default class {
287
274
  return this.checkKey(XML, key);
288
275
  }
289
276
 
290
- // TODO video shader rendertexture physics
291
-
292
277
  // GET
293
278
 
294
279
  getItem(key, cache, method, property = null) {
@@ -357,10 +342,6 @@ export default class {
357
342
  return this.getItem(key, XML, 'getXML', 'data');
358
343
  }
359
344
 
360
- getVideo(key) {
361
- return this.getItem(key, VIDEO, 'getVideo');
362
- }
363
-
364
345
  getShader(key) {
365
346
  return this.getItem(key, SHADER, 'getShader', 'data');
366
347
  }
@@ -490,10 +471,6 @@ export default class {
490
471
  delete this._cache.xml[key];
491
472
  }
492
473
 
493
- removeVideo(key) {
494
- delete this._cache.video[key];
495
- }
496
-
497
474
  removeShader(key) {
498
475
  delete this._cache.shader[key];
499
476
  }
@@ -94,12 +94,6 @@ 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
- export const TEXTURE_ATLAS_JSON_ARRAY = 0;
101
99
  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_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');
@@ -317,55 +311,17 @@ export default class {
317
311
  return this;
318
312
  }
319
313
 
320
- atlasJSONArray(key, textureURL, atlasURL, atlasData) {
321
- return this.atlas(key, textureURL, atlasURL, atlasData, TEXTURE_ATLAS_JSON_ARRAY);
322
- }
323
-
324
- atlasJSONHash(key, textureURL, atlasURL, atlasData) {
325
- return this.atlas(key, textureURL, atlasURL, atlasData, TEXTURE_ATLAS_JSON_HASH);
326
- }
327
-
328
- atlasXML() {
329
- // TODO
330
- console.warn('loader.atlasXML() is not implemented');
331
- }
332
-
333
- atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_ARRAY) {
314
+ atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_HASH) {
334
315
  if (textureURL === undefined || textureURL === null) {
335
316
  textureURL = key + '.png';
336
317
  }
337
318
  if (!atlasURL && !atlasData) {
338
- if (format === TEXTURE_ATLAS_XML_STARLING) {
339
- atlasURL = key + '.xml';
340
- } else {
341
- atlasURL = key + '.json';
342
- }
319
+ atlasURL = key + '.json';
343
320
  }
344
321
  // A URL to a json/xml file has been given
345
322
  if (atlasURL) {
346
323
  this.addToFileList('textureatlas', key, textureURL, { atlasURL, format });
347
324
  } 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;
368
- }
369
325
  this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData, format });
370
326
  }
371
327
  return this;
@@ -562,9 +518,6 @@ export default class {
562
518
  case "spritesheet":
563
519
  this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
564
520
  break;
565
- case "video":
566
- this.video(file.key, file.urls ? file.urls : file.url);
567
- break;
568
521
  case "audio":
569
522
  this.audio(file.key, file.urls ? file.urls : file.url);
570
523
  break;
@@ -586,7 +539,7 @@ export default class {
586
539
  this.bitmapFont(file.key, file.textureURL, file.atlasURL, file.atlasData, file.xSpacing, file.ySpacing);
587
540
  break;
588
541
  case "atlas":
589
- this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, file.format === 'TEXTURE_ATLAS_JSON_HASH' ? TEXTURE_ATLAS_JSON_HASH : TEXTURE_ATLAS_JSON_ARRAY);
542
+ this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
590
543
  break;
591
544
  case "shader":
592
545
  this.shader(file.key, file.url, file.overwrite);
@@ -624,18 +577,6 @@ export default class {
624
577
  this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
625
578
  }
626
579
  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
580
  case 'json':
640
581
  this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.jsonLoadComplete);
641
582
  break;
@@ -690,11 +631,6 @@ export default class {
690
631
  file.data.src = this.transformUrl(file.url, file);
691
632
  }
692
633
 
693
- loadVideoTag() {
694
- // TODO
695
- console.warn('loader.loadVideoTag() is not implemented');
696
- }
697
-
698
634
  xhrLoad(file, url, type, onload, onerror) {
699
635
  const xhr = new XMLHttpRequest();
700
636
  xhr.open('GET', url, true);
@@ -810,10 +746,8 @@ export default class {
810
746
  } else {
811
747
  // Load the JSON or XML before carrying on with the next file
812
748
  loadNext = false;
813
- if (file.format === TEXTURE_ATLAS_JSON_ARRAY || file.format === TEXTURE_ATLAS_JSON_HASH || file.format === TEXTURE_ATLAS_JSON_PYXEL) {
749
+ if (file.format === TEXTURE_ATLAS_JSON_HASH) {
814
750
  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
751
  } else {
818
752
  throw new Error('Invalid Texture Atlas format: ' + file.format);
819
753
  }
@@ -843,16 +777,6 @@ export default class {
843
777
  });
844
778
  }
845
779
  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
780
  case 'audio':
857
781
  file.data = xhr.response;
858
782
  this.cache.addSound(file.key, file.url, file.data);