Skip to content

Commit 8c3df92

Browse files
committed
refactor: move platform to typescript
1 parent 46279c0 commit 8c3df92

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

packages/melonjs/src/input/keyboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { preventDefault as preventDefaultAction } from "./input.js";
2-
import { isMobile } from "./../system/platform.js";
2+
import { isMobile } from "./../system/platform.ts";
33
import { eventEmitter, KEYDOWN, KEYUP } from "../system/event.ts";
44

55
// corresponding actions

packages/melonjs/src/system/device.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getParent } from "./../video/video.js";
22
import save from "./save.ts";
33
import { prefixed } from "./../utils/agent.ts";
44
import { DOMContentLoaded } from "./dom.js";
5-
import * as device_platform from "./platform.js";
5+
import * as device_platform from "./platform.ts";
66
import { BLUR, eventEmitter, FOCUS } from "./event.ts";
77

88
/**

packages/melonjs/src/system/dom.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DOM_READY, eventEmitter } from "./event.ts";
2-
import { nodeJS } from "./platform.js";
2+
import { nodeJS } from "./platform.ts";
33

44
// track if DOMContentLoaded was called already
55
let readyBound = false;

packages/melonjs/src/system/platform.js packages/melonjs/src/system/platform.ts

+16-15
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
* The device platform type
33
* @namespace platform
44
* @memberof device
5-
* @property {string} ua the user agent string for the current device
6-
* @property {boolean} iOS `true` if the device is an iOS platform
7-
* @property {boolean} android `true` if the device is an Android platform
8-
* @property {boolean} android2 `true` if the device is an Android 2.x platform
9-
* @property {boolean} linux `true` if the device is a Linux platform
10-
* @property {boolean} chromeOS `true` if the device is running on ChromeOS.
11-
* @property {boolean} wp `true` if the device is a Windows Phone platform
12-
* @property {boolean} BlackBerry`true` if the device is a BlackBerry platform
13-
* @property {boolean} Kindle`true` if the device is a Kindle platform
14-
* @property {boolean} ejecta `true` if running under Ejecta
15-
* @property {boolean} isWeixin `true` if running under Wechat
16-
* @property {boolean} nodeJS `true` if running under node.js
17-
* @property {boolean} isMobile `true` if a mobile device
18-
* @property {boolean} webApp `true` if running as a standalone web app
5+
* ua the user agent string for the current device
6+
* iOS `true` if the device is an iOS platform
7+
* android `true` if the device is an Android platform
8+
* android2 `true` if the device is an Android 2.x platform
9+
* linux `true` if the device is a Linux platform
10+
* chromeOS `true` if the device is running on ChromeOS.
11+
* wp `true` if the device is a Windows Phone platform
12+
* BlackBerry`true` if the device is a BlackBerry platform
13+
* Kindle`true` if the device is a Kindle platform
14+
* ejecta `true` if running under Ejecta
15+
* isWeixin `true` if running under Wechat
16+
* nodeJS `true` if running under node.js
17+
* isMobile `true` if a mobile device
18+
* webApp `true` if running as a standalone web app
1919
*/
2020

2121
export const ua =
@@ -30,7 +30,7 @@ export const chromeOS = /CrOS/.test(ua);
3030
export const wp = /Windows Phone/i.test(ua);
3131
export const BlackBerry = /BlackBerry/i.test(ua);
3232
export const Kindle = /Kindle|Silk.*Mobile Safari/i.test(ua);
33-
export const ejecta = typeof globalThis.ejecta !== "undefined";
33+
export const ejecta = "ejecta" in globalThis;
3434
export const isWeixin = /MicroMessenger/i.test(ua);
3535
export const nodeJS =
3636
typeof globalThis.process !== "undefined" &&
@@ -40,6 +40,7 @@ export const isMobile =
4040
/Mobi/i.test(ua) || iOS || android || wp || BlackBerry || Kindle || false;
4141
export const webApp =
4242
(typeof globalThis.navigator !== "undefined" &&
43+
"standalone" in globalThis.navigator &&
4344
globalThis.navigator.standalone === true) ||
4445
(typeof globalThis.matchMedia !== "undefined" &&
4546
globalThis.matchMedia("(display-mode: standalone)").matches);

0 commit comments

Comments
 (0)