platform-utils.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (function (factory) {
  2. if (typeof module === "object" && typeof module.exports === "object") {
  3. var v = factory(require, exports);
  4. if (v !== undefined) module.exports = v;
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. define(["require", "exports"], factory);
  8. }
  9. })(function (require, exports) {
  10. "use strict";
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. function isCordova(plt) {
  13. var win = plt.win();
  14. return !!(win['cordova'] || win['PhoneGap'] || win['phonegap']);
  15. }
  16. exports.isCordova = isCordova;
  17. function isElectron(plt) {
  18. return plt.testUserAgent('Electron');
  19. }
  20. exports.isElectron = isElectron;
  21. function isIos(plt) {
  22. // shortcut function to be reused internally
  23. // checks navigator.platform to see if it's an actual iOS device
  24. // this does not use the user-agent string because it is often spoofed
  25. // an actual iPad will return true, a chrome dev tools iPad will return false
  26. return plt.testNavigatorPlatform('iphone|ipad|ipod');
  27. }
  28. exports.isIos = isIos;
  29. function isSafari(plt) {
  30. return plt.testUserAgent('Safari');
  31. }
  32. exports.isSafari = isSafari;
  33. function isWKWebView(plt) {
  34. return isIos(plt) && !!plt.win()['webkit'];
  35. }
  36. exports.isWKWebView = isWKWebView;
  37. function isIosUIWebView(plt) {
  38. return isIos(plt) && !isWKWebView(plt) && !isSafari(plt);
  39. }
  40. exports.isIosUIWebView = isIosUIWebView;
  41. });
  42. //# sourceMappingURL=platform-utils.js.map