PageSourceSearch

https://gamerummyk.com/src/js/index.umd.js?t=1232

js gamerummyk.com collected 2026-10-05 04:34:43 UTC 14,827 bytes, 437 lines download raw bytes

1(function (global, factory) {
2  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3  typeof define === 'function' && define.amd ? define(factory) :
4  (global = global || self, global.CallApp = factory());
5}(this, (function () { 'use strict';
6
7  function _classCallCheck(instance, Constructor) {
8    if (!(instance instanceof Constructor)) {
9      throw new TypeError("Cannot call a class as a function");
10    }
11  }
12
13  function _defineProperties(target, props) {
14    for (var i = 0; i < props.length; i++) {
15      var descriptor = props[i];
16      descriptor.enumerable = descriptor.enumerable || false;
17      descriptor.configurable = true;
18      if ("value" in descriptor) descriptor.writable = true;
19      Object.defineProperty(target, descriptor.key, descriptor);
20    }
21  }
22
23  function _createClass(Constructor, protoProps, staticProps) {
24    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25    if (staticProps) _defineProperties(Constructor, staticProps);
26    return Constructor;
27  }
28
29  function _defineProperty(obj, key, value) {
30    if (key in obj) {
31      Object.defineProperty(obj, key, {
32        value: value,
33        enumerable: true,
34        configurable: true,
35        writable: true
36      });
37    } else {
38      obj[key] = value;
39    }
40
41    return obj;
42  }
43
44  function _extends() {
45    _extends = Object.assign || function (target) {
46      for (var i = 1; i < arguments.length; i++) {
47        var source = arguments[i];
48
49        for (var key in source) {
50          if (Object.prototype.hasOwnProperty.call(source, key)) {
51            target[key] = source[key];
52          }
53        }
54      }
55
56      return target;
57    };
58
59    return _extends.apply(this, arguments);
60  }
61
62  var ua = navigator.userAgent || ''; // 版本号比较
63
64  var semverCompare = function semverCompare(verionA, versionB) {
65    var isNaN = Number.isNaN;
66    var splitA = verionA.split('.');
67    var splitB = versionB.split('.');
68
69    for (var i = 0; i < 3; i++) {
70      var snippetA = Number(splitA[i]);
71      var snippetB = Number(splitB[i]);
72      if (snippetA >
72 snippetB) return 1;
73      if (snippetB > snippetA) return -1; // e.g. '1.0.0-rc' -- Number('0-rc') = NaN
74
75      if (!isNaN(snippetA) && isNaN(snippetB)) return 1;
76      if (isNaN(snippetA) && !isNaN(snippetB)) return -1;
77    }
78
79    return 0;
80  };
81  /**
82   * 获取 ios 大版本号
83   */
84
85  var getIOSVersion = function getIOSVersion() {
86    var version = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
87    return Number.parseInt(version[1], 10);
88  };
89  /**
90   * 获取 微信 版本号
91   */
92
93  var getWeChatVersion = function getWeChatVersion() {
94    var version = navigator.appVersion.match(/micromessenger\/(\d+\.\d+\.\d+)/i);
95    return version[1];
96  };
97  var isAndroid = /android/i.test(ua);
98  var isIos = /iphone|ipad|ipod/i.test(ua);
99  var isWechat = /micromessenger\/([\d.]+)/i.test(ua);
100  var isWeibo = /(weibo).*weibo__([\d.]+)/i.test(ua);
101  var isBaidu = /(baiduboxapp)\/([\d.]+)/i.test(ua);
102  var isQQ = /qq\/([\d.]+)/i.test(ua);
103  var isQQBrowser = /(qqbrowser)\/([\d.]+)/i.test(ua);
104  var isQzone = /qzone\/.*_qz_([\d.]+)/i.test(ua); // 安卓 chrome 浏览器,包含 原生chrome浏览器、三星自带浏览器、360浏览器以及早期国内厂商自带浏览器
105  var isUC = /UCBrowser/i.test(ua);
106  var isFF = /Firefox/i.test(ua);
107  var isChrome = /Chrome/i.test(ua);
108  //var isOpera = /AppleWeb/i.test(ua);
109
110  var isOriginalChrome = /chrome\/[\d.]+ mobile safari\/[\d.]+/i.test(ua) && isA
110ndroid && ua.indexOf('Version') < 0; // chrome for ios 和 safari 的区别仅仅是将 Version/<VersionNum> 替换成了 CriOS/<ChromeRevision>
111  // ios 上很多 app 都包含 safari 标识,但它们都是以自己的 app 标识开头,而不是 Mozilla
112
113  var isSafari = /safari\/([\d.]+)$/i.test(ua) && isIos && ua.indexOf('Crios') < 0 && ua.indexOf('Mozilla') === 0;
114
115  // 生成基本的 url scheme
116  function buildScheme(config, options) {
117    var path = config.path,
118        param = config.param;
119    var customBuildScheme = options.buildScheme;
120
121    if (typeof customBuildScheme !== 'undefined') {
122      return customBuildScheme(config, options);
123    }
124
125    var _options$scheme = options.scheme,
126        host = _options$scheme.host,
127        port = _options$scheme.port,
128        protocol = _options$scheme.protocol;
129    var portPart = port ? ":".concat(port) : '';
130    var hostPort = host ? "".concat(host).concat(portPart, "/") : '';
131    var query = typeof param !== 'undefined' ? Object.keys(param).map(function (key) {
132      return "".concat(key, "=").concat(param[key]);
133    }).join('&') : '';
134    var urlQuery = query ? "?".concat(query) : '';
135    return "".concat(protocol, "://").concat(hostPort).concat(path).concat(urlQuery);
136  } // 生成业务需要的 url scheme(区分是否是外链)
137
138  function generateScheme(config, options) {
139    var outChain = options.outChain;
140    var uri = buildScheme(config, options);
141
142    if (typeof outChain !== 'undefined' && outChain) {
143      var protocol = outChain.protocol,
144          path = outChain.path,
145          key = outChain.key;
146      uri = "".concat(protocol, "://").concat(path, "?").concat(key, "=").concat(encodeURIComponent(uri));
147    }
148
149    return uri;
150  } // 生成 android intent
151
152  function generateIntent(config, options) {
153    var outChain = options.outChain;
154    var intent = options.intent,
155        fallback = options.fallback;
156    if (typeof intent === 'undefined') return '';
157    var keys = Object.keys(intent);
158    var encode = options.encode;
159    var intentParam = keys.map(function (key) {
160      return "".concat(key, "=").concat(intent[key], ";");
161    }).join('');
162    var intentTail = "#Intent;".concat(intentParam, "S.browser_fallback_url=").concat(encodeURIComponent(fallback), ";end;");
163    if(fallback=='####' && !isChrome){
164       intentTail = "#Intent;".concat(intentParam, "S.browser_fallback_url=").concat(fallback, ";end;");
165    }
166    if(isChrome){
167      if(encode) {
168        intentTail = "#Intent;".concat(intentParam, "S.browser_fallback_url=").concat(encodeURIComponent(fallback), ";end;");
169      } else {
170        intentTail = "#Intent;".concat(intentParam, "S.browser_fallback_url=").concat(fallback, ";end;");
171      }
172    }
173    var urlPath = buildScheme(config, options);
174
175    if (typeof outChain !== 'undefined' && outChain) {
176      var path = outChain.path,
177          key = outChain.key;
178      return "intent://".concat(path, "?").concat(key, "=").concat(encodeURIComponent(urlPath)).concat(intentTail);
179    }
180
181    urlPath = urlPath.slice(urlPath.indexOf('//') + 2);
182    // alert("intent://".concat(urlPath).concat(intentTail));
183    return "intent://".concat(urlPath).concat(intentTail);
184  } // 生成 universalLink
185
186  function generateUniversalLink(config, options) {
187    var universal = options.universal;
188    if (typeof universal === 'undefined') return '';
189    var host = universal.host,
190        pathKey = universal.pathKey;
191    var path = config.path,
192        param = config.param;
193    var query = typeof param !== 'undefined' ? Object.keys(param).map(function (key) {
194      return "".concat(key, "=").concat(param[key]);
195    }).join('&') : '';
196    var urlQuery = query ? "&".concat(query) : '';
197    return "https://".concat(host, "?").concat(pathKey, "=").concat(path).concat(urlQuery);
198  } // 生成 应用宝链接
199
200  function generateYingYongBao(config, options) {
201    var url = generateScheme(config, options); // 支持 AppLink
202
203    return "".concat(options.yingyongbao, "&android_schema=").concat(encodeURIComponent(url));
204  }
205
206  var hidden;
207  var visibilityChange;
208  var iframe;
209
210  function getSupportedProperty() {
211    if (typeof document.hidden !== 'undefined') {
212      // Opera 12.10 and Firefox 18 and later support
213      hidden = 'hidden';
214      visibilityChange = 'visibilitychange';
215    } else if (typeof document.msHidden !== 'undefined') {
216      hidden = 'msHidden';
217      visibilityChange = 'msvisibilitychange';
218    } else if (typeof document.webkitHidden !== 'undefined') {
219      hidden = 'webkitHidden';
220      visibilityChange = 'webkitvisibilitychange';
221    }
222  }
223
224  getSupportedProperty();
225  /**
226   * 判断页面是否隐藏(进入后台)
227   */
228
229  function isPageHidden() {
230    if (typeof hidden === 'undefined') return false;
231    return document[hidden];
232  }
233  /**
234   * 通过 top.location.href 跳转
235   * 使用 top 是因为在 qq 中打开的页面不属于顶级页面(iframe级别)
236   * 自身 url 变更无法触动唤端操作
237   * @param {string}} [uri] - 需要打开的地址
238   */
239
240
241  function evokeByLocation(uri) {
242    window.top.location.href = uri;
243  }
244  /**
245   * 通过 iframe 唤起
246   * @param {string}} [uri] - 需要打开的地址
247   */
248
249  function evokeByIFrame(uri) {
250    if (!iframe) {
251      iframe = document.createElement('iframe');
252      iframe.frameBorder = '0';
253      iframe.style.cssText = 'display:none;border:0;width:0;height:0;';
254      document.body.append(iframe);
255    }
256
257    iframe.src = uri;
258  }
259  /**
260   * 检测是否唤端成功
261   * @param cb - 唤端失败回调函数
262   * @param timeout
263   */
264
265  function checkOpen(cb, timeout) {
266    var timer = setTimeout(function () {
267      var pageHidden = isPageHidden();
268
269      if (!pageHidden) {
270        cb();
271      }
272    }, timeout);
273
274    if (typeof visibilityChange !== 'undefined') {
275      document.addEventListener(visibilityChange, function () {
276        clearTimeout(timer);
277      });
278    } else {
279      window.addEventListener('pagehide', function () {
280        clearTimeout(timer);
281      });
282    }
283  }
284
285  var CallApp = /*#__PURE__*/function () {
286    // Create an instance of CallApp
287    function CallApp(options) {
288      _classCallCheck(this, CallApp);
289
290      _defineProperty(this, "options", void 0);
291
292      var defaultOptions = {
293        timeout: 5000
294      };
295      this.options = _extends(defaultOptions, options);
296    }
297    /**
298     * 注册为方法
299     * generateScheme | generateIntent | generateUniversalLink | generateYingYongBao | checkOpen
300     */
301
302
303    _createClass(CallApp, [{
304      key: "generateScheme",
305      value: function generateScheme$1(config) {
306        return generateScheme(config, this.options);
307      }
308    }, {
309      key: "generateIntent",
310      value: function generateIntent$1(config) {
311        return generateIntent(config, this.options);
312      }
313    }, {
314      key: "generateUniversalLink",
315      value: function generateUniversalLink$1(config) {
316        return generateUniversalLink(config, this.options);
317      }
318    }, {
319      key: "generateYingYongBao",
320      value: function generateYingYongBao$1(config) {
321        return generateYingYongBao(config, this.options);
322      }
323    }, {
324      key: "checkOpen",
325      value: function checkOpen$1(cb) {
326        return checkOpen(cb, this.options.timeout);
327      } // 唤端失败跳转 app store
328
329    }, {
330      key: "fallToAppStore",
331      value: function fallToAppStore() {
332        var _this = this;
333
334        this.checkOpen(function () {
335          evokeByLocation(_this.options.appstore);
336        });
337      } // 唤端失败跳转通用(下载)页
338
339    }, {
340      key: "fallToFbUrl",
341      value: function fallToFbUrl() {
342        var _this2 = this;
343
344        this.checkOpen(function () {
345          evokeByLocation(_this2.options.fallback);
346        });
347      } // 唤端失败调用自定义回调函数
348
349    }, {
350      key: "fallToCustomCb",
351      value: function fallToCustomCb(callback) {
352        this.checkOpen(function () {
353          callback();
354        });
355      }
356      /**
357       * 唤起客户端
358       * 根据不同 browser 执行不同唤端策略
359       */
360
361    }, {
362      key: "open",
363      value: function open(config) {
364        var _this$options = this.options,
365            universal = _this$options.universal,
366            appstore = _this$options.appstore,
367            logFunc = _this$options.logFunc,
368            intent = _this$options.intent;
369        var callback = config.callback;
370        var supportUniversal = typeof universal !== 'undefined';
371        var schemeURL = this.generateScheme(config, this.options);
372        var checkOpenFall;
373
374        if (typeof logFunc !== 'undefined') {
375          logFunc();
376        }
377
378        if (isIos) {
379          // ios qq 禁止了 scheme 和 universalLink 唤起app,安卓不受影响 - 18年12月23日
380          // ios qq 浏览器禁止了 universalLink - 2019年5月1日
381          // ios 微信自 7.0.5 版本放开了 Universal Link 的限制
382          // ios 微博禁止了 universalLink
383          if (isWechat && semverCompare(getWeChatVersion(), '7.0.5') === -1 || isQQ || isWeibo) {
384            evokeByLocation(appstore);
385          } else if (getIOSVersion() < 9) {
386            evokeByIFrame(schemeURL);
387            checkOpenFall = this.fallToAppStore;
388          } else if (!supportUniversal || isQQBrowser || isQzone) {
389            evokeByLocation(schemeURL);
390            checkOpenFall = this.fallToAppStore;
391          } else {
392            evokeByLocation(this.generateUniversalLink(config));
393          } // Android
394          // 在微信中且配置了应用宝链接
395
396        } else if (isWechat && typeof this.options.yingyongbao !== 'undefined') {
397          evokeByLocation(this.generateYingYongBao(config));
398        } else if (isOriginalChrome) {
399          if (typeof intent !== 'undefined') {
400            evokeByLocation(this.generateIntent(config));
401          } else {
402            // scheme 在 andriod chrome 25+ 版本上iframe无法正常拉起
403            evokeByLocation(schemeURL);
404            checkOpenFall = this.fallToFbUrl;
405          }
406        } else if (isWechat || isBaidu || isWeibo || isQzone) {
407          evokeByLocation(this.options.fallback);
408        } else if (isUC) {
409          //evokeByIFrame(schemeURL);
410          window.location.href=schemeURL;
411          //window.open(schemeURL);
412          checkOpenFall = this.fallToFbUrl;
413        } else if (isFF) {
414          window.location.href=schemeURL;
415          checkOpenFall = this.fallToFbUrl;
416        } else {
417          //window.location.href=schemeURL;
418          evokeByIFrame(schemeURL);
419          checkOpenFall = this.fallToFbUrl;
420        }
421
422        if (typeof callback !== 'undefined') {
423          this.fallToCustomCb(callback);
424          return;
425        }
426
427        if (!checkOpenFall) return;
428        checkOpenFall.call(this);
429      }
430    }]);
431
432    return CallApp;
433  }();
434
435  return CallApp;
436
437})));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.