@haluo/util 2.0.33-beta.9 → 2.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -19
- package/dist/modules/app-call/configs.js +15 -10
- package/dist/modules/app-call/core.d.ts +2 -2
- package/dist/modules/app-call/core.js +60 -51
- package/dist/modules/app-call/extensions.d.ts +4 -3
- package/dist/modules/app-call/extensions.js +357 -290
- package/dist/modules/app-call/index.js +9 -9
- package/dist/modules/app-call/offline.js +43 -35
- package/dist/modules/app-call/types.d.ts +18 -4
- package/dist/modules/cookie/index.js +22 -17
- package/dist/modules/date/index.js +54 -48
- package/dist/modules/dom/index.js +21 -15
- package/dist/modules/filter/index.js +14 -8
- package/dist/modules/format/index.js +9 -5
- package/dist/modules/match/index.js +8 -5
- package/dist/modules/monitor/lib/jsError.js +27 -38
- package/dist/modules/monitor/lib/timing.js +15 -17
- package/dist/modules/monitor/lib/xhr.js +26 -25
- package/dist/modules/monitor/utils/tracker.js +22 -10
- package/dist/modules/number/index.js +33 -30
- package/dist/modules/open-app/index.d.ts +2 -1
- package/dist/modules/open-app/index.js +52 -62
- package/dist/modules/sentry/index.js +16 -12
- package/dist/modules/tools/index.d.ts +3 -3
- package/dist/modules/tools/index.js +164 -154
- package/dist/modules/track/index.js +149 -96
- package/dist/modules/track/types.d.ts +1 -1
- package/dist/modules/upload/aliOss.d.ts +36 -4
- package/dist/modules/upload/aliOss.js +569 -396
- package/dist/modules/upload/index.js +32 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/modules/app-call/partner-bridge.d.ts +0 -5
- package/dist/modules/app-call/partner-bridge.js +0 -68
package/dist/index.js
CHANGED
|
@@ -12,21 +12,21 @@ import monitor from './modules/monitor';
|
|
|
12
12
|
export * from './modules/monitor';
|
|
13
13
|
export * from './modules/app-call';
|
|
14
14
|
export * from './modules/track';
|
|
15
|
-
|
|
16
|
-
cookie,
|
|
17
|
-
date,
|
|
18
|
-
dom,
|
|
19
|
-
filter,
|
|
20
|
-
format,
|
|
21
|
-
match,
|
|
22
|
-
number,
|
|
23
|
-
openApp,
|
|
24
|
-
tools,
|
|
25
|
-
upload,
|
|
26
|
-
monitor
|
|
15
|
+
var modules = {
|
|
16
|
+
cookie: cookie,
|
|
17
|
+
date: date,
|
|
18
|
+
dom: dom,
|
|
19
|
+
filter: filter,
|
|
20
|
+
format: format,
|
|
21
|
+
match: match,
|
|
22
|
+
number: number,
|
|
23
|
+
openApp: openApp,
|
|
24
|
+
tools: tools,
|
|
25
|
+
upload: upload,
|
|
26
|
+
monitor: monitor
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
var Utils = /** @class */ (function () {
|
|
29
|
+
function Utils() {
|
|
30
30
|
Object.assign(this, modules);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -34,13 +34,14 @@ class Utils {
|
|
|
34
34
|
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
35
35
|
* @param {Object} Vue 需要挂载的目标对象
|
|
36
36
|
*/
|
|
37
|
-
install(app) {
|
|
38
|
-
Object.keys(modules).forEach((key)
|
|
39
|
-
|
|
37
|
+
Utils.prototype.install = function (app) {
|
|
38
|
+
Object.keys(modules).forEach(function (key) {
|
|
39
|
+
var globalProperties = app.config.globalProperties;
|
|
40
40
|
globalProperties['$' + key] = modules[key];
|
|
41
41
|
});
|
|
42
|
-
}
|
|
43
|
-
|
|
42
|
+
};
|
|
43
|
+
return Utils;
|
|
44
|
+
}());
|
|
44
45
|
export default new Utils();
|
|
45
46
|
export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
|
|
46
47
|
export * from './modules/app-call';
|
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
export var projectConfigs = {
|
|
2
13
|
motorfans: {
|
|
3
14
|
projectName: '摩托范',
|
|
4
15
|
domain: '58moto.com',
|
|
5
16
|
defaultImage: 'https://wap.58moto.com/static/img/common/motuofan_small.png',
|
|
6
17
|
defaultDesc: '摩托范,摩托发烧友的交流的平台,摩托维修、保养、配件等知识与经验分享社区。',
|
|
7
|
-
supportHarmonyos: true
|
|
8
18
|
},
|
|
9
19
|
emotofine: {
|
|
10
20
|
projectName: '电摩范',
|
|
11
21
|
domain: 'emotofine.com',
|
|
12
22
|
defaultImage: 'https://wap.emotofine.com/static/img/common/motuofan_small.png',
|
|
13
23
|
defaultDesc: '电摩范,摩托发烧友的交流的平台,摩托维修、保养、配件等知识与经验分享社区。',
|
|
14
|
-
supportHarmonyos: true
|
|
15
24
|
},
|
|
16
25
|
iwc: {
|
|
17
26
|
projectName: '手表范',
|
|
18
27
|
domain: 'biaofine.com',
|
|
19
28
|
defaultImage: 'https://wap.biaofine.com/static/img/common/motuofan_small.png',
|
|
20
|
-
defaultDesc: '
|
|
29
|
+
defaultDesc: '手表范,表友发烧友的交流的平台,手表维修、保养等知识与经验分享社区。'
|
|
21
30
|
},
|
|
22
31
|
dronefine: {
|
|
23
32
|
projectName: '无人机之家',
|
|
24
33
|
domain: 'dronefine.com',
|
|
25
34
|
defaultImage: 'https://wap.dronefine.com/static/img/common/motuofan_small.png',
|
|
26
35
|
defaultDesc: '无人机之家,无人机发烧友的交流的平台,无人机维修、保养、配件等知识与经验分享社区。',
|
|
27
|
-
supportHarmonyos: true
|
|
28
36
|
}
|
|
29
37
|
};
|
|
30
38
|
/**
|
|
31
39
|
* 创建项目配置
|
|
32
40
|
*/
|
|
33
41
|
export function createProjectConfig(projectType, overrides) {
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...baseConfig,
|
|
37
|
-
...overrides
|
|
38
|
-
};
|
|
42
|
+
var baseConfig = projectConfigs[projectType] || projectConfigs.motorfans;
|
|
43
|
+
return __assign(__assign({}, baseConfig), overrides);
|
|
39
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AppCall 核心实现
|
|
3
3
|
*/
|
|
4
|
-
import type { AppCallConfig, AppCallCore } from './types';
|
|
4
|
+
import type { AppCallConfig, AppCallCore, AppCallInstance } from './types';
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window {
|
|
7
7
|
NativeCall?: any;
|
|
@@ -26,7 +26,7 @@ declare global {
|
|
|
26
26
|
isEmotofine?: boolean;
|
|
27
27
|
isBiaofine?: boolean;
|
|
28
28
|
isdronefine?: boolean;
|
|
29
|
-
AppCall?:
|
|
29
|
+
AppCall?: AppCallInstance;
|
|
30
30
|
__wxjs_environment?: string;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
var AppCallCoreClass = /** @class */ (function () {
|
|
11
|
+
function AppCallCoreClass(config) {
|
|
12
|
+
this.iOSInterface = '';
|
|
11
13
|
this.config = config;
|
|
12
14
|
this.ua = navigator.userAgent.toLowerCase();
|
|
13
15
|
this.isIOS = this.ua.indexOf('mac') > -1;
|
|
@@ -30,10 +32,10 @@ export class AppCallCoreClass {
|
|
|
30
32
|
}
|
|
31
33
|
this.initGlobalVars();
|
|
32
34
|
}
|
|
33
|
-
initGlobalVars() {
|
|
35
|
+
AppCallCoreClass.prototype.initGlobalVars = function () {
|
|
34
36
|
window.isEmotofine = location.host.includes('emotofine');
|
|
35
37
|
window.bridge = window.bridge || {};
|
|
36
|
-
window.Toast = window.Toast || (()
|
|
38
|
+
window.Toast = window.Toast || (function () { });
|
|
37
39
|
window.isClient = location.href.includes('isClient=false') ? false : this.isClient;
|
|
38
40
|
window.isFile = location.href.includes('file://');
|
|
39
41
|
window.isIOS = this.isIOS;
|
|
@@ -46,17 +48,18 @@ export class AppCallCoreClass {
|
|
|
46
48
|
(this.ua.indexOf('qbwebviewtype') > -1 || this.ua.indexOf('qq') > -1);
|
|
47
49
|
window.isShare = window.location.href.indexOf('share=true') > -1;
|
|
48
50
|
window.isMiniprogram = this.ua.indexOf('miniprogram') > -1;
|
|
49
|
-
[100, 200, 500].forEach((delay)
|
|
50
|
-
setTimeout(()
|
|
51
|
+
[100, 200, 500].forEach(function (delay) {
|
|
52
|
+
setTimeout(function () {
|
|
51
53
|
window.isMiniprogram = window.__wxjs_environment === 'miniprogram';
|
|
52
54
|
}, delay);
|
|
53
55
|
});
|
|
54
|
-
}
|
|
55
|
-
call() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
};
|
|
57
|
+
AppCallCoreClass.prototype.call = function () {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
var arr = __spreadArray([], arguments, true);
|
|
60
|
+
var name = arr.shift();
|
|
61
|
+
var callback;
|
|
62
|
+
var data;
|
|
60
63
|
if (!this.isClient) {
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
@@ -70,13 +73,15 @@ export class AppCallCoreClass {
|
|
|
70
73
|
if (this.showTip && window.Toast) {
|
|
71
74
|
window.Toast({
|
|
72
75
|
position: 'top',
|
|
73
|
-
message:
|
|
76
|
+
message: "\u8BF7\u6C42\u65B9\u6CD5\u540D\uFF1A".concat(name, "\uFF1A").concat(JSON.stringify(arr))
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
try {
|
|
80
|
+
console.log('this.isAndroid', this.isAndroid);
|
|
77
81
|
if (this.isAndroid || this.isHarmonyos) {
|
|
78
82
|
if (this.has(name)) {
|
|
79
|
-
|
|
83
|
+
console.log('has', name);
|
|
84
|
+
data = ((_b = (_a = window.NativeCall) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.apply(window.NativeCall, arr)) || null;
|
|
80
85
|
if (this.showTip && window.Toast) {
|
|
81
86
|
window.Toast({
|
|
82
87
|
position: 'middle',
|
|
@@ -97,17 +102,18 @@ export class AppCallCoreClass {
|
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
catch (error) {
|
|
105
|
+
console.log('error', error);
|
|
100
106
|
if (this.showTip && window.Toast) {
|
|
101
107
|
window.Toast({
|
|
102
108
|
position: 'middle',
|
|
103
|
-
message:
|
|
109
|
+
message: error + '',
|
|
104
110
|
duration: 5000
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
return false;
|
|
109
|
-
}
|
|
110
|
-
has(name) {
|
|
115
|
+
};
|
|
116
|
+
AppCallCoreClass.prototype.has = function (name) {
|
|
111
117
|
if (this.isAndroid || this.isHarmonyos) {
|
|
112
118
|
return !!(window.NativeCall && window.NativeCall[name]);
|
|
113
119
|
}
|
|
@@ -115,52 +121,55 @@ export class AppCallCoreClass {
|
|
|
115
121
|
return true;
|
|
116
122
|
}
|
|
117
123
|
return false;
|
|
118
|
-
}
|
|
119
|
-
extend(obj) {
|
|
120
|
-
for (
|
|
124
|
+
};
|
|
125
|
+
AppCallCoreClass.prototype.extend = function (obj) {
|
|
126
|
+
for (var key in obj) {
|
|
121
127
|
;
|
|
122
128
|
this[key] = obj[key];
|
|
123
129
|
}
|
|
124
130
|
return this;
|
|
125
|
-
}
|
|
126
|
-
callIOSHandler(name, params, callback1) {
|
|
127
|
-
|
|
128
|
-
for (
|
|
131
|
+
};
|
|
132
|
+
AppCallCoreClass.prototype.callIOSHandler = function (name, params, callback1) {
|
|
133
|
+
var obj = {};
|
|
134
|
+
for (var i = 0; i < params.length; i++) {
|
|
129
135
|
obj['arg' + (i + 1)] = params[i];
|
|
130
136
|
}
|
|
131
137
|
if (this.showTip && window.Toast) {
|
|
132
|
-
setTimeout(()
|
|
133
|
-
|
|
138
|
+
setTimeout(function () {
|
|
139
|
+
var _a;
|
|
140
|
+
(_a = window.Toast) === null || _a === void 0 ? void 0 : _a.call(window, {
|
|
134
141
|
position: 'top',
|
|
135
|
-
message:
|
|
142
|
+
message: "\u8BF7\u6C42\u65B9\u6CD5\u540D\u53CA\u53C2\u6570\uFF1A".concat(name, "\uFF1A").concat(JSON.stringify(obj))
|
|
136
143
|
});
|
|
137
144
|
}, 50);
|
|
138
145
|
}
|
|
139
146
|
if (this.isIOS && window.setupWebViewJavascriptBridge) {
|
|
140
|
-
window.setupWebViewJavascriptBridge((bridge)
|
|
147
|
+
window.setupWebViewJavascriptBridge(function (bridge) {
|
|
141
148
|
bridge.callHandler(name, obj, callback1);
|
|
142
149
|
});
|
|
143
150
|
return true;
|
|
144
151
|
}
|
|
145
152
|
return false;
|
|
146
|
-
}
|
|
147
|
-
allParamsToString(params) {
|
|
148
|
-
|
|
149
|
-
keys.forEach((key)
|
|
150
|
-
params[key] =
|
|
153
|
+
};
|
|
154
|
+
AppCallCoreClass.prototype.allParamsToString = function (params) {
|
|
155
|
+
var keys = Object.keys(params);
|
|
156
|
+
keys.forEach(function (key) {
|
|
157
|
+
params[key] = params[key] + '';
|
|
151
158
|
});
|
|
152
159
|
return params;
|
|
153
|
-
}
|
|
154
|
-
setIOSInterface(interfaces) {
|
|
160
|
+
};
|
|
161
|
+
AppCallCoreClass.prototype.setIOSInterface = function (interfaces) {
|
|
155
162
|
this.iOSInterface = interfaces;
|
|
156
|
-
}
|
|
157
|
-
getIOSInterface() {
|
|
163
|
+
};
|
|
164
|
+
AppCallCoreClass.prototype.getIOSInterface = function () {
|
|
158
165
|
return this.iOSInterface;
|
|
159
|
-
}
|
|
160
|
-
getConfig() {
|
|
166
|
+
};
|
|
167
|
+
AppCallCoreClass.prototype.getConfig = function () {
|
|
161
168
|
return this.config;
|
|
162
|
-
}
|
|
163
|
-
getIsClient() {
|
|
169
|
+
};
|
|
170
|
+
AppCallCoreClass.prototype.getIsClient = function () {
|
|
164
171
|
return this.isClient;
|
|
165
|
-
}
|
|
166
|
-
|
|
172
|
+
};
|
|
173
|
+
return AppCallCoreClass;
|
|
174
|
+
}());
|
|
175
|
+
export { AppCallCoreClass };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* AppCall 所有扩展方法
|
|
3
3
|
* 整合了所有项目的扩展方法,供所有项目共享使用
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { AppCallCore, AppCallConfig } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* 创建所有扩展方法
|
|
8
8
|
*/
|
|
9
|
-
export declare function createAllExtensions(appCall:
|
|
9
|
+
export declare function createAllExtensions<T extends AppCallCore>(appCall: T, config: AppCallConfig): {
|
|
10
10
|
selectDeliveryAddress(data: any): any;
|
|
11
11
|
paySuccess(on: boolean): any;
|
|
12
12
|
pay(params?: any): any;
|
|
@@ -24,6 +24,7 @@ export declare function createAllExtensions(appCall: AppCallInstance, config: Ap
|
|
|
24
24
|
appUrlRouter: string;
|
|
25
25
|
appBundleId?: string;
|
|
26
26
|
}): any;
|
|
27
|
+
openPageInBrowser(url: string): any;
|
|
27
28
|
setTitle(title?: string): void;
|
|
28
29
|
haloService(params?: any): any;
|
|
29
30
|
qiyuService(params?: any): any;
|
|
@@ -176,7 +177,7 @@ export declare function createAllExtensions(appCall: AppCallInstance, config: Ap
|
|
|
176
177
|
onBackAction(callback: (res: any) => void): any;
|
|
177
178
|
getStatusBarHeight(params: any, callback: (res: any) => void): any;
|
|
178
179
|
loadLocalWeb(params?: any): any;
|
|
179
|
-
getExamVipQuestions(params: any
|
|
180
|
+
getExamVipQuestions(params: any): any;
|
|
180
181
|
saveEmCoupon(params?: any): any;
|
|
181
182
|
getEmCoupon(params: any, callback?: ((res: any) => void) | undefined): any;
|
|
182
183
|
getUserWinInfo(params: any): any;
|