初始化

This commit is contained in:
2025-04-09 18:55:14 +08:00
commit 6e1ae24845
2315 changed files with 256628 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
/**
* @param versionA
* @param versionB
* @returns
*/
export declare const semverCompare: (
versionA: string,
versionB: string,
) => -1 | 0 | 1;
export declare const getIOSVersion: () => number;
export declare const isAndroid: boolean;
export declare const isIOS: boolean;
export declare const isOriginalChrome: boolean;
export declare const isQQBrowser: boolean;
export declare const isFirefox: boolean;
export declare const isBaidu: boolean;
/**
* @returns boolean
*/
export declare const haveSchemeToLinkOrFallback: () => boolean;

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
var ua = window.navigator.userAgent || '';
/**
* @param versionA
* @param versionB
* @returns
*/
export var semverCompare = function semverCompare(versionA, versionB) {
var splitA = versionA.split('.');
var splitB = versionB.split('.');
for (var i = 0; i < 3; i++) {
var snippetA = Number(splitA[i]);
var snippetB = Number(splitB[i]);
if (snippetA > snippetB) return 1;
if (snippetB > snippetA) return -1;
// e.g. '1.0.0-rc' -- Number('0-rc') = NaN
if (!isNaN(snippetA) && isNaN(snippetB)) return 1;
if (isNaN(snippetA) && !isNaN(snippetB)) return -1;
}
return 0;
};
export var getIOSVersion = function getIOSVersion() {
var version = ua.match(/OS (\d+)_(\d+)_?(\d+)?/);
return Number.parseInt(version[1], 10);
};
export var isAndroid = /android/i.test(ua);
export var isIOS = /iphone|ipad|ipod/i.test(ua);
export var isOriginalChrome = /chrome\/[\d.]+ mobile safari\/[\d.]+/i.test(ua) && isAndroid && ua.indexOf('Version') < 0;
export var isQQBrowser = /qqbrowser/i.test(ua);
export var isFirefox = /firefox/i.test(ua);
export var isBaidu = /baidubrowser/i.test(ua);
/**
* @returns boolean
*/
export var haveSchemeToLinkOrFallback = function haveSchemeToLinkOrFallback() {
return isAndroid || getIOSVersion() < 9;
};

View File

@@ -0,0 +1,13 @@
/**
* @param url
*/
export declare function evokeByLocation(url: string): void;
/**
* @param url
*/
export declare function evokeByTagA(url: string): void;
export declare function buildIFrame(): void;
/**
* @param url
*/
export declare function evokeByIFrame(url: string): void;

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
/**
* @param url
*/
export function evokeByLocation(url) {
window.location.href = url;
}
/**
* @param url
*/
export function evokeByTagA(url) {
var a = document.createElement('a');
a.setAttribute('href', url);
a.style.display = 'none';
document.body.appendChild(a);
var e = document.createEvent('HTMLEvents');
e.initEvent('click', false, false);
a.dispatchEvent(e);
}
var iframe;
export function buildIFrame() {
if (!iframe) {
iframe = document.createElement('iframe');
iframe.id = 'callapp_iframe_'.concat(Date.now());
iframe.style.cssText = 'display:none;border:0;width:0;height:0;';
document.body.appendChild(iframe);
}
}
/**
* @param url
*/
export function evokeByIFrame(url) {
iframe.src = url;
}

View File

@@ -0,0 +1,29 @@
/**
* @param url
* @param params
* @returns
*/
export declare function generateQS(
url: string,
params?: Record<string, any>,
): string;
/**
* @param url
* @param params
* @returns
*/
export declare function generateLink(
url: string,
params?: Record<string, any>,
): string;
/**
* @param url
* @param packageName
* @param params
* @returns
*/
export declare function generateIntent(
url: string,
packageName?: string,
fallbackUrl?: string,
): string;

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
/**
* @param url
* @param params
* @returns
*/
export function generateQS(url, params) {
var newUrl = new URL(url);
for (var i in params) {
if (i) {
newUrl.searchParams.set(i, params[i]);
}
}
return newUrl.toString();
}
/**
* @param url
* @param params
* @returns
*/
export function generateLink(url, params) {
return generateQS(url, params);
}
/**
* @param url
* @param packageName
* @param params
* @returns
*/
export function generateIntent(url, packageName, fallbackUrl) {
var intentTail = '';
if (fallbackUrl) {
intentTail = 'S.browser_fallback_url='.concat(encodeURIComponent(fallbackUrl), ';');
}
var protocol = url.substring(0, url.indexOf('://'));
var hash = packageName ? '#Intent;scheme='.concat(protocol, ';package=').concat(packageName, ';') : '#Intent;scheme='.concat(protocol, ';');
var newUrl = url.replace(/.*?:\/\//, 'intent://');
return ''.concat(newUrl + hash + intentTail, 'end');
}

View File

@@ -0,0 +1,43 @@
/// <reference types="node" />
import type { CallappConfig, CallappOptions, EvokeAppBy } from './types';
declare class CallApp {
config: CallappConfig;
timer: NodeJS.Timeout | null;
options: CallappOptions;
evokeAppBy: EvokeAppBy;
constructor(config?: CallappConfig);
private init;
/**
* @param options
*/
open(options: CallappOptions): void;
private handleLink;
private handleIntent;
private handleScheme;
private handleIOSScheme;
private handleOriginalChrome;
/**
* @param evokeFn
* @param delay
* @param fallback
* @param degradationStrategy
*/
private evokeAppDelay;
private evokeByLocationDelay;
private evokeByTagADelay;
private evokeByIFrameDelay;
/**
* @param fallback
* @returns
*/
private checkIsOpen;
private clearTimer;
}
export default CallApp;

View File

@@ -0,0 +1,298 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
function _typeof(obj) {
'@babel/helpers - typeof';
return _typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;
}, _typeof(obj);
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, 'prototype', {
writable: false
});
return Constructor;
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, 'string');
return _typeof(key) === 'symbol' ? key : String(key);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== 'object' || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || 'default');
if (_typeof(res) !== 'object') return res;
throw new TypeError('@@toPrimitive must return a primitive value.');
}
return (hint === 'string' ? String : Number)(input);
}
import * as Browser from "./browser";
import { buildIFrame, evokeByIFrame, evokeByLocation, evokeByTagA } from "./evoke";
import { generateIntent, generateLink } from "./generate";
import { addEventListener, checkCallAppSuccess, checkIsHttpUrl } from "./utils/index";
var EvokeAppType;
(function (EvokeAppType) {
EvokeAppType['SCHEME'] = 'Scheme';
EvokeAppType['LINK'] = 'Link';
EvokeAppType['INTENT'] = 'Intent';
})(EvokeAppType || (EvokeAppType = {}));
var CallApp = /*#__PURE__*/function () {
function CallApp(config) {
_classCallCheck(this, CallApp);
this.config = void 0;
this.timer = void 0;
this.options = void 0;
this.evokeAppBy = void 0;
var defaultConfig = {
delay: 0
};
this.config = _objectSpread(_objectSpread({}, defaultConfig), config);
this.options = {};
this.timer = null;
this.evokeAppBy = {
url: '',
type: EvokeAppType.LINK
};
this.init();
}
_createClass(CallApp, [{
key: 'init',
value: function init() {
buildIFrame();
addEventListener({
evokeAppBy: this.evokeAppBy,
successCb: this.config.successCb,
timeout: this.config.resultJudgmentTime
});
}
/**
* @param options
*/
}, {
key: 'open',
value: function open(options) {
this.options = options;
var _this$options = this.options,
scheme = _this$options.scheme,
intent = _this$options.intent,
link = _this$options.link,
params = _this$options.params,
fallback = _this$options.fallback;
if (!scheme && !link && !intent) {
console.error('请至少填一个链接');
return;
}
if (link && checkIsHttpUrl(link)) {
this.options.link = generateLink(link, params);
this.handleLink();
} else if (scheme && !checkIsHttpUrl(scheme)) {
this.options.scheme = generateLink(scheme, params);
this.handleScheme();
} else if (intent && intent.scheme && intent.package) {
this.handleIntent();
} else if (fallback) {
fallback();
} else {
console.error('唤端失败');
}
}
}, {
key: 'handleLink',
value: function handleLink() {
this.evokeAppBy.type = EvokeAppType.LINK;
var _this$options2 = this.options,
link = _this$options2.link,
scheme = _this$options2.scheme,
delay = _this$options2.delay,
fallback = _this$options2.fallback;
if (Browser.isIOS) {
if (Browser.getIOSVersion() > 9) {
this.evokeByLocationDelay(link, delay, fallback, this.handleScheme);
} else if (scheme) {
this.handleScheme();
} else if (fallback) {
fallback();
} else {
console.error('唤端失败');
}
} else {
this.evokeByLocationDelay(link, delay, fallback, this.handleScheme);
}
}
}, {
key: 'handleIntent',
value: function handleIntent() {
this.evokeAppBy.type = EvokeAppType.INTENT;
var _this$options3 = this.options,
intent = _this$options3.intent,
delay = _this$options3.delay,
fallback = _this$options3.fallback;
if (intent && intent.scheme && intent.package) {
this.evokeByLocationDelay(generateIntent(intent.scheme, intent.package, intent.fallbackUrl), delay, fallback);
}
}
}, {
key: 'handleScheme',
value: function handleScheme() {
this.evokeAppBy.type = EvokeAppType.SCHEME;
var _this$options4 = this.options,
scheme = _this$options4.scheme,
delay = _this$options4.delay,
fallback = _this$options4.fallback;
if (scheme) {
if (Browser.isIOS) {
this.handleIOSScheme();
} else if (Browser.isOriginalChrome || Browser.isFirefox) {
this.handleOriginalChrome();
} else {
this.evokeByIFrameDelay(scheme, delay, fallback);
}
}
}
}, {
key: 'handleIOSScheme',
value: function handleIOSScheme() {
var _this$options5 = this.options,
scheme = _this$options5.scheme,
delay = _this$options5.delay,
fallback = _this$options5.fallback;
if (Browser.getIOSVersion() < 9) {
this.evokeByIFrameDelay(scheme, delay, fallback);
} else {
this.evokeByTagADelay(scheme, delay, fallback);
}
}
}, {
key: 'handleOriginalChrome',
value: function handleOriginalChrome() {
var _this = this;
var _this$options6 = this.options,
scheme = _this$options6.scheme,
intent = _this$options6.intent,
delay = _this$options6.delay,
fallback = _this$options6.fallback;
var degradationStrategyFn = function degradationStrategyFn() {
if (intent && intent.package) {
_this.evokeByLocationDelay(generateIntent(scheme, intent.package, intent.fallbackUrl), delay, fallback, _this.handleIntent.bind(_this));
}
};
this.evokeByLocationDelay(scheme, delay, fallback, degradationStrategyFn);
}
/**
* @param evokeFn
* @param delay
* @param fallback
* @param degradationStrategy
*/
}, {
key: 'evokeAppDelay',
value: function evokeAppDelay(evokeFn, evokeAppByUrl, delay, fallback, degradationStrategy) {
var _this2 = this;
var newDelay = delay || this.config.delay;
var newFallback = fallback || this.config.fallback;
this.timer = setTimeout(function () {
_this2.clearTimer();
evokeFn();
_this2.checkIsOpen(evokeAppByUrl, newFallback, degradationStrategy);
}, newDelay);
}
}, {
key: 'evokeByLocationDelay',
value: function evokeByLocationDelay(url, delay, fallback, degradationStrategy) {
this.evokeAppDelay(function () {
return evokeByLocation(url);
}, url, delay, fallback, degradationStrategy);
}
}, {
key: 'evokeByTagADelay',
value: function evokeByTagADelay(url, delay, fallback, degradationStrategy) {
this.evokeAppDelay(function () {
return evokeByTagA(url);
}, url, delay, fallback, degradationStrategy);
}
}, {
key: 'evokeByIFrameDelay',
value: function evokeByIFrameDelay(url, delay, fallback, degradationStrategy) {
this.evokeAppDelay(function () {
return evokeByIFrame(url);
}, url, delay, fallback, degradationStrategy);
}
/**
* @param fallback
* @returns
*/
}, {
key: 'checkIsOpen',
value: function checkIsOpen(evokeAppByUrl, fallback, degradationStrategy) {
this.evokeAppBy.url = evokeAppByUrl;
return checkCallAppSuccess(degradationStrategy || fallback, this.config.resultJudgmentTime);
}
}, {
key: 'clearTimer',
value: function clearTimer() {
if (this.timer) {
clearTimeout(this.timer);
}
}
}]);
return CallApp;
}();
export default CallApp;

View File

@@ -0,0 +1,41 @@
/// <reference types="node" />
import type { CallappConfig, CallappOptions, EvokeAppBy } from './types';
declare class CallApp {
config: CallappConfig;
timer: NodeJS.Timeout | null;
options: CallappOptions;
evokeAppBy: EvokeAppBy;
constructor(config?: CallappConfig);
private init;
/**
* @param options
*/
open(options: CallappOptions): void;
private handleDegradationStrategy;
private evokeLink;
private evokeScheme;
private handleIntent;
private handleOriginalChrome;
/**
* @param evokeFn
* @param delay
* @param fallback
* @param degradationStrategy
*/
private evokeAppDelay;
private evokeByLocationDelay;
private evokeByTagADelay;
private evokeByIFrameDelay;
/**
* @param fallback
* @returns
*/
private checkIsOpen;
private clearTimer;
}
export default CallApp;

View File

@@ -0,0 +1,305 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
function _typeof(obj) {
'@babel/helpers - typeof';
return _typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;
}, _typeof(obj);
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, 'prototype', {
writable: false
});
return Constructor;
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, 'string');
return _typeof(key) === 'symbol' ? key : String(key);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== 'object' || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || 'default');
if (_typeof(res) !== 'object') return res;
throw new TypeError('@@toPrimitive must return a primitive value.');
}
return (hint === 'string' ? String : Number)(input);
}
import * as Browser from "./browser";
import { buildIFrame, evokeByIFrame, evokeByLocation, evokeByTagA } from "./evoke";
import { generateIntent, generateLink } from "./generate";
import { addEventListener, checkCallAppSuccess, checkIsHttpUrl } from "./utils/index";
var EvokeAppType;
(function (EvokeAppType) {
EvokeAppType['SCHEME'] = 'Scheme';
EvokeAppType['LINK'] = 'Link';
EvokeAppType['INTENT'] = 'Intent';
})(EvokeAppType || (EvokeAppType = {}));
var CallApp = /*#__PURE__*/function () {
function CallApp(config) {
var _this = this;
_classCallCheck(this, CallApp);
this.config = void 0;
this.timer = void 0;
this.options = void 0;
this.evokeAppBy = void 0;
this.handleDegradationStrategy = function () {
var _this$options = _this.options,
scheme = _this$options.scheme,
link = _this$options.link,
intent = _this$options.intent,
params = _this$options.params;
if (link && scheme) {
_this.options.link = generateLink(link, params);
_this.options.scheme = generateLink(scheme, params);
if (Browser.isIOS && Browser.getIOSVersion() > 9) {
_this.evokeLink();
} else {
_this.evokeScheme(_this.evokeLink.bind(_this));
}
} else {
if (link) {
_this.options.link = generateLink(link, params);
_this.evokeLink();
} else if (scheme) {
_this.options.scheme = generateLink(scheme, params);
_this.evokeScheme();
} else if (intent && intent.scheme && intent.package) {
_this.handleIntent();
}
}
};
var defaultConfig = {
delay: 0
};
this.config = _objectSpread(_objectSpread({}, defaultConfig), config);
this.options = {};
this.timer = null;
this.evokeAppBy = {
url: '',
type: EvokeAppType.LINK
};
this.init();
}
_createClass(CallApp, [{
key: 'init',
value: function init() {
buildIFrame();
addEventListener({
evokeAppBy: this.evokeAppBy,
successCb: this.config.successCb,
timeout: this.config.resultJudgmentTime
});
}
/**
* @param options
*/
}, {
key: 'open',
value: function open(options) {
this.options = options;
var _this$options2 = this.options,
scheme = _this$options2.scheme,
intent = _this$options2.intent,
link = _this$options2.link;
if (!scheme && !link && !(intent === null || intent === void 0 ? void 0 : intent.scheme)) {
throw new Error('请至少填一个链接');
}
/**
* scheme不为(http|https|itms-apps|itms-appss|market)
*/
if (scheme && checkIsHttpUrl(scheme)) {
throw new Error('请填写正确格式的scheme');
}
/**
* link为(http|https|itms-apps|itms-appss|market)
*/
if (link && !checkIsHttpUrl(link)) {
throw new Error('请填写正确格式的link');
}
if (intent && intent.scheme && checkIsHttpUrl(intent.scheme)) {
throw new Error('请填写正确格式的intent');
}
this.handleDegradationStrategy();
}
}, {
key: 'evokeLink',
value: function evokeLink() {
this.evokeAppBy.type = EvokeAppType.LINK;
var _this$options3 = this.options,
link = _this$options3.link,
delay = _this$options3.delay;
this.evokeByLocationDelay(link, delay);
}
}, {
key: 'evokeScheme',
value: function evokeScheme(degradationStrategy) {
this.evokeAppBy.type = EvokeAppType.SCHEME;
var _this$options4 = this.options,
scheme = _this$options4.scheme,
delay = _this$options4.delay,
fallback = _this$options4.fallback;
if (Browser.isIOS) {
if (Browser.getIOSVersion() > 9) {
this.evokeByTagADelay(scheme, delay, fallback, degradationStrategy);
} else {
if (Browser.isQQBrowser) {
this.evokeByTagADelay(scheme, delay, fallback, degradationStrategy);
} else {
this.evokeByIFrameDelay(scheme, delay, fallback, degradationStrategy);
}
}
} else {
if (Browser.isOriginalChrome || Browser.isFirefox) {
this.handleOriginalChrome();
} else {
this.evokeByIFrameDelay(scheme, delay, fallback, degradationStrategy);
}
}
}
}, {
key: 'handleIntent',
value: function handleIntent() {
var _this2 = this;
var _this$options5 = this.options,
scheme = _this$options5.scheme,
intent = _this$options5.intent,
delay = _this$options5.delay,
link = _this$options5.link,
fallback = _this$options5.fallback;
var tempScheme = (intent === null || intent === void 0 ? void 0 : intent.scheme) || scheme;
if (tempScheme && !checkIsHttpUrl(tempScheme)) {
this.evokeAppBy.type = EvokeAppType.INTENT;
var degradationStrategyFn;
if (link) {
degradationStrategyFn = function degradationStrategyFn() {
return _this2.evokeLink();
};
}
this.evokeByLocationDelay(generateIntent(tempScheme, intent === null || intent === void 0 ? void 0 : intent.package, (intent === null || intent === void 0 ? void 0 : intent.fallbackUrl) || ''), delay, fallback, degradationStrategyFn);
}
}
}, {
key: 'handleOriginalChrome',
value: function handleOriginalChrome() {
this.handleIntent();
}
/**
* @param evokeFn
* @param delay
* @param fallback
* @param degradationStrategy
*/
}, {
key: 'evokeAppDelay',
value: function evokeAppDelay(evokeFn, evokeAppByUrl, delay, fallback, degradationStrategy) {
var _this3 = this;
var newDelay = delay || this.config.delay;
var newFallback = fallback || this.config.fallback;
this.timer = setTimeout(function () {
_this3.clearTimer();
evokeFn();
_this3.checkIsOpen(evokeAppByUrl, newFallback, degradationStrategy);
}, newDelay);
}
}, {
key: 'evokeByLocationDelay',
value: function evokeByLocationDelay(url, delay, fallback, degradationStrategy) {
this.evokeAppDelay(function () {
return evokeByLocation(url);
}, url, delay, fallback, degradationStrategy);
}
}, {
key: 'evokeByTagADelay',
value: function evokeByTagADelay(url, delay, fallback, degradationStrategy) {
this.evokeAppDelay(function () {
return evokeByTagA(url);
}, url, delay, fallback, degradationStrategy);
}
}, {
key: 'evokeByIFrameDelay',
value: function evokeByIFrameDelay(url, delay, fallback, degradationStrategy) {
this.evokeAppDelay(function () {
return evokeByIFrame(url);
}, url, delay, fallback, degradationStrategy);
}
/**
* @param fallback
* @returns
*/
}, {
key: 'checkIsOpen',
value: function checkIsOpen(evokeAppByUrl, fallback, degradationStrategy) {
this.evokeAppBy.url = evokeAppByUrl;
return checkCallAppSuccess(degradationStrategy || fallback, this.config.resultJudgmentTime);
}
}, {
key: 'clearTimer',
value: function clearTimer() {
if (this.timer) {
clearTimeout(this.timer);
}
}
}]);
return CallApp;
}();
export default CallApp;

View File

@@ -0,0 +1,15 @@
import CallApp from './main';
import type { OpenWalletConfig, OpenWalletOptions } from './types';
import type { WalletType } from './utils/config';
declare class OpenWallet extends CallApp {
constructor(config?: OpenWalletConfig);
/**
* @param options
*/
openWallet(options: OpenWalletOptions): void;
/**
* @param options
*/
openAppStore(walletName: WalletType): void;
}
export default OpenWallet;

View File

@@ -0,0 +1,197 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
function _typeof(obj) {
'@babel/helpers - typeof';
return _typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;
}, _typeof(obj);
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, 'prototype', {
writable: false
});
return Constructor;
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, 'string');
return _typeof(key) === 'symbol' ? key : String(key);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== 'object' || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || 'default');
if (_typeof(res) !== 'object') return res;
throw new TypeError('@@toPrimitive must return a primitive value.');
}
return (hint === 'string' ? String : Number)(input);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function');
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, 'prototype', {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === 'object' || typeof call === 'function')) {
return call;
} else if (call !== void 0) {
throw new TypeError('Derived constructors may only return object or undefined');
}
return _assertThisInitialized(self);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _isNativeReflectConstruct() {
if (typeof Reflect === 'undefined' || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === 'function') return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
import * as Browser from "./browser";
import { evokeByLocation } from "./evoke";
import CallApp from "./main";
import { AndroidWalletPackageName, IOSWalletAppId } from "./utils/config";
var OpenWallet = /*#__PURE__*/function (_CallApp) {
_inherits(OpenWallet, _CallApp);
var _super = _createSuper(OpenWallet);
function OpenWallet(config) {
var _this;
_classCallCheck(this, OpenWallet);
_this = _super.call(this);
_this.config = _objectSpread({}, config);
return _this;
}
/**
* @param options
*/
_createClass(OpenWallet, [{
key: 'openWallet',
value: function openWallet(options) {
var _options$intent;
this.open(_objectSpread(_objectSpread({}, options), {}, {
intent: {
package: AndroidWalletPackageName[options.walletName],
scheme: options.scheme || ((_options$intent = options.intent) === null || _options$intent === void 0 ? void 0 : _options$intent.scheme) || ''
}
}));
}
/**
* @param options
*/
}, {
key: 'openAppStore',
value: function openAppStore(walletName) {
var IOSAppStoreLink = 'itms-apps://itunes.apple.com/app/'.concat(IOSWalletAppId[walletName]);
var AndroidAppStoreLink = 'market://details?id='.concat(AndroidWalletPackageName[walletName]);
var link = Browser.isIOS ? IOSAppStoreLink : AndroidAppStoreLink;
evokeByLocation(link);
}
}]);
return OpenWallet;
}(CallApp);
export default OpenWallet;

View File

@@ -0,0 +1,46 @@
export interface EvokeAppBy {
url: string;
type: 'Scheme' | 'Link' | 'Intent';
}
export type SuccessCb = (evokeAppBy?: EvokeAppBy) => void;
export interface CallappConfig {
fallback?: () => void;
delay?: number;
fallbackUrl?: string;
successCb?: SuccessCb;
resultJudgmentTime?: number;
}
export interface CallappOptions
extends Omit<CallappConfig, 'successCb' | 'resultJudgmentTime'> {
scheme?: string;
intent?: {
package?: string;
scheme: string;
fallbackUrl?: string;
};
link?: string;
params?: Record<string, any>;
}
export type Hidden =
| 'hidden'
| 'webkitHidden'
| 'msHidden'
| 'mozHidden'
| undefined;
export type VisibilityChange =
| 'visibilitychange'
| 'webkitvisibilitychange'
| 'msvisibilitychange'
| 'mozvisibilitychange'
| undefined;
export interface EvokeAppResultOptions {
evokeAppBy: EvokeAppBy;
successCb?: SuccessCb;
timeout?: number;
}
export interface OpenWalletConfig extends CallappConfig {
walletName: string;
}
export interface OpenWalletOptions extends CallappOptions {
walletName: string;
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,24 @@
export declare enum WalletType {
TnGD = 'TNG',
KKP = 'KAKAOPAY',
TMN = 'TRUEMONEY',
DANA = 'DANA',
GCash = 'GCASH',
AlipayHK = 'ALIPAY_HK',
}
export declare const AndroidWalletPackageName: {
TNG: string;
KAKAOPAY: string;
TRUEMONEY: string;
DANA: string;
GCASH: string;
ALIPAY_HK: string;
};
export declare const IOSWalletAppId: {
TNG: string;
KAKAOPAY: string;
TRUEMONEY: string;
DANA: string;
GCASH: string;
ALIPAY_HK: string;
};

View File

@@ -0,0 +1,57 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
var _AndroidWalletPackage, _IOSWalletAppId;
function _typeof(obj) {
'@babel/helpers - typeof';
return _typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;
}, _typeof(obj);
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, 'string');
return _typeof(key) === 'symbol' ? key : String(key);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== 'object' || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || 'default');
if (_typeof(res) !== 'object') return res;
throw new TypeError('@@toPrimitive must return a primitive value.');
}
return (hint === 'string' ? String : Number)(input);
}
export var WalletType;
(function (WalletType) {
WalletType['TnGD'] = 'TNG';
WalletType['KKP'] = 'KAKAOPAY';
WalletType['TMN'] = 'TRUEMONEY';
WalletType['DANA'] = 'DANA';
WalletType['GCash'] = 'GCASH';
WalletType['AlipayHK'] = 'ALIPAY_HK';
})(WalletType || (WalletType = {}));
// Android
export var AndroidWalletPackageName = (_AndroidWalletPackage = {}, _defineProperty(_AndroidWalletPackage, WalletType.TnGD, 'my.com.tngdigital.ewallet'), _defineProperty(_AndroidWalletPackage, WalletType.KKP, 'com.kakaopay.app'), _defineProperty(_AndroidWalletPackage, WalletType.TMN, 'th.co.truemoney.wallet'), _defineProperty(_AndroidWalletPackage, WalletType.DANA, 'id.dana'), _defineProperty(_AndroidWalletPackage, WalletType.GCash, 'com.globe.gcash.android'), _defineProperty(_AndroidWalletPackage, WalletType.AlipayHK, 'hk.alipay.wallet'), _AndroidWalletPackage);
// IOS
export var IOSWalletAppId = (_IOSWalletAppId = {}, _defineProperty(_IOSWalletAppId, WalletType.TnGD, 'id1344696702'), _defineProperty(_IOSWalletAppId, WalletType.KKP, 'id1464496236'), _defineProperty(_IOSWalletAppId, WalletType.TMN, 'id1345776130'), _defineProperty(_IOSWalletAppId, WalletType.DANA, 'id1437123008'), _defineProperty(_IOSWalletAppId, WalletType.GCash, 'id520020791'), _defineProperty(_IOSWalletAppId, WalletType.AlipayHK, 'id1210638245'), _IOSWalletAppId);

View File

@@ -0,0 +1,15 @@
import type { EvokeAppResultOptions } from '../types';
export declare function checkCallAppSuccess(
fallback?: () => void,
timeout?: number,
): void;
/**
* Listening page
*/
export declare function addEventListener(options: EvokeAppResultOptions): void;
/**
* Determine whether the URL is an http or application market link
* @param {[type]} url
* @return {Boolean} [description]
*/
export declare function checkIsHttpUrl(url: string): boolean;

View File

@@ -0,0 +1,98 @@
/**
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
*/
var hidden;
var visibilityChange;
var DEFAULT_TIMEOUT = 5000;
var timeStamp;
/**
* @returns
*/
function getSupportedProperty(document) {
if (typeof document === 'undefined') return;
if (typeof document.hidden !== 'undefined') {
hidden = 'hidden';
visibilityChange = 'visibilitychange';
} else if (typeof document.mozHidden !== 'undefined') {
hidden = 'mozHidden';
visibilityChange = 'mozvisibilitychange';
} else if (typeof document.msHidden !== 'undefined') {
hidden = 'msHidden';
visibilityChange = 'msvisibilitychange';
} else if (typeof document.webkitHidden !== 'undefined') {
hidden = 'webkitHidden';
visibilityChange = 'webkitvisibilitychange';
}
}
getSupportedProperty(document);
/**
* @returns
*/
function isPageHidden() {
if (!hidden) return false;
return document[hidden];
}
/**
* @param fallback
* @param timeout
*/
var timer;
export function checkCallAppSuccess(fallback, timeout) {
timeStamp = +new Date();
timer = setTimeout(function () {
var pageHidden = isPageHidden();
if (!pageHidden && fallback) {
fallback();
}
}, timeout || DEFAULT_TIMEOUT);
}
export function addEventListener(options) {
if (typeof visibilityChange !== 'undefined') {
document.addEventListener(visibilityChange, function () {
return handlePageHidden(options);
});
} else {
window.addEventListener('pagehide', function () {
return handlePageHidden(options);
});
}
}
function handlePageHidden(options) {
var evokeAppBy = options.evokeAppBy;
if (evokeAppBy === null || evokeAppBy === void 0 ? void 0 : evokeAppBy.url) {
handleSuccessCb(options);
clearTimer();
}
}
/**
* @param successCb
*/
function handleSuccessCb(_ref) {
var evokeAppBy = _ref.evokeAppBy,
successCb = _ref.successCb,
timeout = _ref.timeout;
if (successCb) {
// hack
var newTimeStamp = +new Date();
var newTimeout = timeout || DEFAULT_TIMEOUT;
var preTimeStamp = timeStamp || +new Date();
if (newTimeStamp - preTimeStamp < newTimeout) {
successCb(evokeAppBy);
}
}
}
function clearTimer() {
if (timer) {
clearTimeout(timer);
}
}
/**
* @param {[type]} url
* @return {Boolean} [description]
*/
export function checkIsHttpUrl(url) {
return /^(http|https|itms-apps|itms-appss|market):\/\//.test(url);
}