Skip to content

Commit cb2891d

Browse files
committed
Added jsdocs to the Device inspector, removed out-dated properties and changed case of Device access
1 parent 1304eab commit cb2891d

14 files changed

Lines changed: 216 additions & 230 deletions

File tree

src/boot/DebugHeader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var DebugHeader = function (game)
2323
var renderType = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
2424

2525
var audioConfig = config.audio;
26-
var deviceAudio = game.device.Audio;
26+
var deviceAudio = game.device.audio;
2727

2828
var audioType;
2929

@@ -40,7 +40,7 @@ var DebugHeader = function (game)
4040
audioType = 'HTML5 Audio';
4141
}
4242

43-
if (!game.device.Browser.ie)
43+
if (!game.device.browser.ie)
4444
{
4545
var c = '';
4646
var args = [ c ];

src/boot/Game.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ var Game = new Class({
159159
this.scene = new SceneManager(this, this.config.sceneConfig);
160160

161161
/**
162-
* An instance of the Device inspector.
162+
* A reference to the Device inspector.
163163
*
164164
* Contains information about the device running this game, such as OS, browser vendor and feature support.
165165
* Used by various systems to determine capabilities and code paths.

src/device/Audio.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
var Browser = require('./Browser');
22

3+
/**
4+
* Determines the audio playback capabilities of the device running this Phaser Game instance.
5+
* These values are read-only and populated during the boot sequence of the game.
6+
* They are then referenced by internal game systems and are available for you to access
7+
* via `this.sys.game.device.audio` from within any Scene.
8+
*
9+
* @namespace Phaser.Device.Audio
10+
* @typedef {object} DeviceAudio
11+
* @since 3.0.0
12+
*
13+
* @property {boolean} audioData - Can this device play HTML Audio tags?
14+
* @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files?
15+
* @property {boolean} m4a - Can this device can play m4a files.
16+
* @property {boolean} mp3 - Can this device play mp3 files?
17+
* @property {boolean} ogg - Can this device play ogg files?
18+
* @property {boolean} opus - Can this device play opus files?
19+
* @property {boolean} wav - Can this device play wav files?
20+
* @property {boolean} webAudio - Does this device have the Web Audio API?
21+
* @property {boolean} webm - Can this device play webm files?
22+
*/
323
var Audio = {
424

5-
// @property {boolean} audioData - Are Audio tags available?
625
audioData: false,
7-
8-
// @property {boolean} webAudio - Is the WebAudio API available?
9-
webAudio: false,
10-
11-
// @property {boolean} ogg - Can this device play ogg files?
26+
dolby: false,
27+
m4a: false,
28+
mp3: false,
1229
ogg: false,
13-
14-
// @property {boolean} opus - Can this device play opus files?
1530
opus: false,
16-
17-
// @property {boolean} mp3 - Can this device play mp3 files?
18-
mp3: false,
19-
20-
// @property {boolean} wav - Can this device play wav files?
2131
wav: false,
22-
23-
// Can this device play m4a files?
24-
// @property {boolean} m4a - True if this device can play m4a files.
25-
m4a: false,
26-
27-
// @property {boolean} webm - Can this device play webm files?
28-
webm: false,
29-
30-
// @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files?
31-
dolby: false
32+
webAudio: false,
33+
webm: false
3234

3335
};
3436

src/device/Browser.js

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,54 @@
11
var OS = require('./OS');
22

3+
/**
4+
* Determines the browser type and version running this Phaser Game instance.
5+
* These values are read-only and populated during the boot sequence of the game.
6+
* They are then referenced by internal game systems and are available for you to access
7+
* via `this.sys.game.device.browser` from within any Scene.
8+
*
9+
* @namespace Phaser.Device.Browser
10+
* @typedef {object} DeviceBrowser
11+
* @since 3.0.0
12+
*
13+
* @property {boolean} chrome - Set to true if running in Chrome.
14+
* @property {boolean} edge - Set to true if running in Microsoft Edge browser.
15+
* @property {boolean} firefox - Set to true if running in Firefox.
16+
* @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge).
17+
* @property {boolean} mobileSafari - Set to true if running in Mobile Safari.
18+
* @property {boolean} opera - Set to true if running in Opera.
19+
* @property {boolean} safari - Set to true if running in Safari.
20+
* @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle)
21+
* @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+)
22+
* @property {number} chromeVersion - If running in Chrome this will contain the major version number.
23+
* @property {number} firefoxVersion - If running in Firefox this will contain the major version number.
24+
* @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion.
25+
* @property {number} safariVersion - If running in Safari this will contain the major version number.
26+
* @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx}
27+
*/
328
var Browser = {
429

5-
// @property {boolean} arora - Set to true if running in Arora.
6-
arora: false,
7-
8-
// @property {boolean} chrome - Set to true if running in Chrome.
930
chrome: false,
10-
11-
// @property {number} chromeVersion - If running in Chrome this will contain the major version number.
1231
chromeVersion: 0,
13-
14-
// @property {boolean} epiphany - Set to true if running in Epiphany.
15-
epiphany: false,
16-
17-
// @property {boolean} firefox - Set to true if running in Firefox.
32+
edge: false,
1833
firefox: false,
19-
20-
// @property {number} firefoxVersion - If running in Firefox this will contain the major version number.
2134
firefoxVersion: 0,
22-
23-
// @property {boolean} mobileSafari - Set to true if running in Mobile Safari.
24-
mobileSafari: false,
25-
26-
// @property {boolean} ie - Set to true if running in Internet Explorer.
2735
ie: false,
28-
29-
// @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Device.trident and Device.tridentVersion.
3036
ieVersion: 0,
31-
32-
// @property {boolean} midori - Set to true if running in Midori.
33-
midori: false,
34-
35-
// @property {boolean} opera - Set to true if running in Opera.
37+
mobileSafari: false,
3638
opera: false,
37-
38-
// @property {boolean} safari - Set to true if running in Safari.
3939
safari: false,
40-
41-
// @property {number} safariVersion - If running in Safari this will contain the major version number.
4240
safariVersion: 0,
43-
44-
// @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+)
41+
silk: false,
4542
trident: false,
46-
47-
// @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx}
48-
tridentVersion: 0,
49-
50-
// @property {boolean} edge - Set to true if running in Microsoft Edge browser.
51-
edge: false,
52-
53-
// @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle)
54-
silk: false
43+
tridentVersion: 0
5544

5645
};
5746

5847
function init ()
5948
{
6049
var ua = navigator.userAgent;
6150

62-
if ((/Arora/).test(ua))
63-
{
64-
Browser.arora = true;
65-
}
66-
else if (/Edge\/\d+/.test(ua))
51+
if (/Edge\/\d+/.test(ua))
6752
{
6853
Browser.edge = true;
6954
}
@@ -72,10 +57,6 @@ function init ()
7257
Browser.chrome = true;
7358
Browser.chromeVersion = parseInt(RegExp.$1, 10);
7459
}
75-
else if ((/Epiphany/).test(ua))
76-
{
77-
Browser.epiphany = true;
78-
}
7960
else if ((/Firefox\D+(\d+)/).test(ua))
8061
{
8162
Browser.firefox = true;
@@ -90,10 +71,6 @@ function init ()
9071
Browser.ie = true;
9172
Browser.ieVersion = parseInt(RegExp.$1, 10);
9273
}
93-
else if ((/Midori/).test(ua))
94-
{
95-
Browser.midori = true;
96-
}
9774
else if ((/Opera/).test(ua))
9875
{
9976
Browser.opera = true;

src/device/CanvasFeatures.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
var CanvasPool = require('../display/canvas/CanvasPool');
22

3+
/**
4+
* Determines the canvas features of the browser running this Phaser Game instance.
5+
* These values are read-only and populated during the boot sequence of the game.
6+
* They are then referenced by internal game systems and are available for you to access
7+
* via `this.sys.game.device.canvasFeatures` from within any Scene.
8+
*
9+
* @namespace Phaser.Device.CanvasFeatures
10+
* @typedef {object} DeviceCanvasFeatures
11+
* @since 3.0.0
12+
*
13+
* @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha.
14+
* @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes.
15+
*/
316
var CanvasFeatures = {
417

5-
supportNewBlendModes: false,
6-
7-
supportInverseAlpha: false
18+
supportInverseAlpha: false,
19+
supportNewBlendModes: false
820

921
};
1022

src/device/Features.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@ var OS = require('./OS');
22
var Browser = require('./Browser');
33
var CanvasPool = require('../display/canvas/CanvasPool');
44

5+
/**
6+
* Determines the features of the browser running this Phaser Game instance.
7+
* These values are read-only and populated during the boot sequence of the game.
8+
* They are then referenced by internal game systems and are available for you to access
9+
* via `this.sys.game.device.features` from within any Scene.
10+
*
11+
* @namespace Phaser.Device.Features
12+
* @typedef {object} DeviceFeatures
13+
* @since 3.0.0
14+
*
15+
* @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap.
16+
* @property {boolean} canvas - Is canvas available?
17+
* @property {boolean} file - Is file available?
18+
* @property {boolean} fileSystem - Is fileSystem available?
19+
* @property {boolean} getUserMedia - Does the device support the getUserMedia API?
20+
* @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays)
21+
* @property {boolean} localStorage - Is localStorage available?
22+
* @property {boolean} pointerLock - Is Pointer Lock available?
23+
* @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views?
24+
* @property {boolean} vibration - Does the device support the Vibration API?
25+
* @property {boolean} webGL - Is webGL available?
26+
* @property {boolean} worker - Is worker available?
27+
*/
528
var Features = {
629

7-
// @property {boolean} canvas - Is canvas available?
830
canvas: false,
9-
10-
// @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap.
1131
canvasBitBltShift: null,
12-
13-
// @property {boolean} webGL - Is webGL available?
14-
webGL: false,
15-
16-
// @property {boolean} file - Is file available?
1732
file: false,
18-
19-
// @property {boolean} fileSystem - Is fileSystem available?
2033
fileSystem: false,
21-
22-
// @property {boolean} localStorage - Is localStorage available?
34+
getUserMedia: true,
35+
littleEndian: false,
2336
localStorage: false,
24-
25-
// @property {boolean} worker - Is worker available?
26-
worker: false,
27-
28-
// @property {boolean} pointerLock - Is Pointer Lock available?
2937
pointerLock: false,
30-
31-
// @property {boolean} vibration - Does the device support the Vibration API?
38+
support32bit: false,
3239
vibration: false,
33-
34-
// @property {boolean} getUserMedia - Does the device support the getUserMedia API?
35-
getUserMedia: true,
36-
37-
// @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays)
38-
littleEndian: false,
39-
40-
// @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views?
41-
support32bit: false
40+
webGL: false,
41+
worker: false
4242

4343
};
4444

src/device/Fullscreen.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
/**
2+
* Determines the full screen support of the browser running this Phaser Game instance.
3+
* These values are read-only and populated during the boot sequence of the game.
4+
* They are then referenced by internal game systems and are available for you to access
5+
* via `this.sys.game.device.fullscreen` from within any Scene.
6+
*
7+
* @namespace Phaser.Device.Fullscreen
8+
* @typedef {object} DeviceFullscreen
9+
* @since 3.0.0
10+
*
11+
* @property {boolean} available - Does the browser support the Full Screen API?
12+
* @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode?
13+
* @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it.
14+
* @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it.
15+
*/
116
var Fullscreen = {
217

3-
// @property {boolean} available - Does the browser support the Full Screen API?
418
available: false,
5-
6-
// @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it.
7-
request: '',
8-
9-
// @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it.
1019
cancel: '',
11-
12-
// @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode?
13-
keyboard: false
20+
keyboard: false,
21+
request: ''
1422

1523
};
1624

src/device/Input.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
var OS = require('./OS');
22
var Browser = require('./Browser');
33

4+
/**
5+
* Determines the input support of the browser running this Phaser Game instance.
6+
* These values are read-only and populated during the boot sequence of the game.
7+
* They are then referenced by internal game systems and are available for you to access
8+
* via `this.sys.game.device.input` from within any Scene.
9+
*
10+
* @namespace Phaser.Device.Input
11+
* @typedef {object} DeviceInput
12+
* @since 3.0.0
13+
*
14+
* @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
15+
* @property {boolean} gamepads - Is navigator.getGamepads available?
16+
* @property {boolean} mspointer - Is mspointer available?
17+
* @property {boolean} touch - Is touch available?
18+
*/
419
var Input = {
520

6-
// @property {boolean} touch - Is touch available?
7-
touch: false,
8-
9-
// @property {boolean} mspointer - Is mspointer available?
21+
gamepads: false,
1022
mspointer: false,
11-
12-
// @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
13-
wheelEvent: null,
14-
15-
// @property {boolean} gamepads - Is navigator.getGamepads available?
16-
gamepads: false
23+
touch: false,
24+
wheelEvent: null
1725

1826
};
1927

0 commit comments

Comments
 (0)