@haluo/util 2.1.5 → 2.1.8
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 +14 -6
- package/dist/modules/app-call/core.d.ts +1 -1
- package/dist/modules/app-call/core.js +59 -49
- package/dist/modules/app-call/extensions.d.ts +1 -1
- package/dist/modules/app-call/extensions.js +324 -257
- package/dist/modules/app-call/index.js +9 -9
- package/dist/modules/app-call/offline.js +42 -34
- 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 +1 -0
- package/dist/modules/open-app/index.js +55 -64
- package/dist/modules/sentry/index.js +16 -12
- package/dist/modules/tools/index.d.ts +1 -1
- package/dist/modules/tools/index.js +164 -154
- package/dist/modules/track/index.js +149 -96
- 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,4 +1,15 @@
|
|
|
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',
|
|
@@ -28,9 +39,6 @@ export const projectConfigs = {
|
|
|
28
39
|
* 创建项目配置
|
|
29
40
|
*/
|
|
30
41
|
export function createProjectConfig(projectType, overrides) {
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
...baseConfig,
|
|
34
|
-
...overrides
|
|
35
|
-
};
|
|
42
|
+
var baseConfig = projectConfigs[projectType] || projectConfigs.motorfans;
|
|
43
|
+
return __assign(__assign({}, baseConfig), overrides);
|
|
36
44
|
}
|
|
@@ -41,7 +41,7 @@ export declare class AppCallCoreClass implements AppCallCore {
|
|
|
41
41
|
private showTip;
|
|
42
42
|
constructor(config: AppCallConfig);
|
|
43
43
|
private initGlobalVars;
|
|
44
|
-
call(): any;
|
|
44
|
+
call(...args: any[]): any;
|
|
45
45
|
has(name: string): boolean;
|
|
46
46
|
extend(obj: Record<string, any>): AppCallCore;
|
|
47
47
|
callIOSHandler(name: string, params: any[], callback1?: Function): boolean;
|
|
@@ -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,22 @@ 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 args = [];
|
|
60
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
61
|
+
args[_i] = arguments[_i];
|
|
62
|
+
}
|
|
63
|
+
var arr = __spreadArray([], args, true);
|
|
64
|
+
var name = arr.shift();
|
|
65
|
+
var callback;
|
|
66
|
+
var data;
|
|
60
67
|
if (!this.isClient) {
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
@@ -70,7 +77,7 @@ export class AppCallCoreClass {
|
|
|
70
77
|
if (this.showTip && window.Toast) {
|
|
71
78
|
window.Toast({
|
|
72
79
|
position: 'top',
|
|
73
|
-
message:
|
|
80
|
+
message: "\u8BF7\u6C42\u65B9\u6CD5\u540D\uFF1A".concat(name, "\uFF1A").concat(JSON.stringify(arr))
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
try {
|
|
@@ -78,7 +85,7 @@ export class AppCallCoreClass {
|
|
|
78
85
|
if (this.isAndroid || this.isHarmonyos) {
|
|
79
86
|
if (this.has(name)) {
|
|
80
87
|
console.log('has', name);
|
|
81
|
-
data = window.NativeCall
|
|
88
|
+
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;
|
|
82
89
|
if (this.showTip && window.Toast) {
|
|
83
90
|
window.Toast({
|
|
84
91
|
position: 'middle',
|
|
@@ -109,8 +116,8 @@ export class AppCallCoreClass {
|
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
return false;
|
|
112
|
-
}
|
|
113
|
-
has(name) {
|
|
119
|
+
};
|
|
120
|
+
AppCallCoreClass.prototype.has = function (name) {
|
|
114
121
|
if (this.isAndroid || this.isHarmonyos) {
|
|
115
122
|
return !!(window.NativeCall && window.NativeCall[name]);
|
|
116
123
|
}
|
|
@@ -118,52 +125,55 @@ export class AppCallCoreClass {
|
|
|
118
125
|
return true;
|
|
119
126
|
}
|
|
120
127
|
return false;
|
|
121
|
-
}
|
|
122
|
-
extend(obj) {
|
|
123
|
-
for (
|
|
128
|
+
};
|
|
129
|
+
AppCallCoreClass.prototype.extend = function (obj) {
|
|
130
|
+
for (var key in obj) {
|
|
124
131
|
;
|
|
125
132
|
this[key] = obj[key];
|
|
126
133
|
}
|
|
127
134
|
return this;
|
|
128
|
-
}
|
|
129
|
-
callIOSHandler(name, params, callback1) {
|
|
130
|
-
|
|
131
|
-
for (
|
|
135
|
+
};
|
|
136
|
+
AppCallCoreClass.prototype.callIOSHandler = function (name, params, callback1) {
|
|
137
|
+
var obj = {};
|
|
138
|
+
for (var i = 0; i < params.length; i++) {
|
|
132
139
|
obj['arg' + (i + 1)] = params[i];
|
|
133
140
|
}
|
|
134
141
|
if (this.showTip && window.Toast) {
|
|
135
|
-
setTimeout(()
|
|
136
|
-
|
|
142
|
+
setTimeout(function () {
|
|
143
|
+
var _a;
|
|
144
|
+
(_a = window.Toast) === null || _a === void 0 ? void 0 : _a.call(window, {
|
|
137
145
|
position: 'top',
|
|
138
|
-
message:
|
|
146
|
+
message: "\u8BF7\u6C42\u65B9\u6CD5\u540D\u53CA\u53C2\u6570\uFF1A".concat(name, "\uFF1A").concat(JSON.stringify(obj))
|
|
139
147
|
});
|
|
140
148
|
}, 50);
|
|
141
149
|
}
|
|
142
150
|
if (this.isIOS && window.setupWebViewJavascriptBridge) {
|
|
143
|
-
window.setupWebViewJavascriptBridge((bridge)
|
|
151
|
+
window.setupWebViewJavascriptBridge(function (bridge) {
|
|
144
152
|
bridge.callHandler(name, obj, callback1);
|
|
145
153
|
});
|
|
146
154
|
return true;
|
|
147
155
|
}
|
|
148
156
|
return false;
|
|
149
|
-
}
|
|
150
|
-
allParamsToString(params) {
|
|
151
|
-
|
|
152
|
-
keys.forEach((key)
|
|
157
|
+
};
|
|
158
|
+
AppCallCoreClass.prototype.allParamsToString = function (params) {
|
|
159
|
+
var keys = Object.keys(params);
|
|
160
|
+
keys.forEach(function (key) {
|
|
153
161
|
params[key] = params[key] + '';
|
|
154
162
|
});
|
|
155
163
|
return params;
|
|
156
|
-
}
|
|
157
|
-
setIOSInterface(interfaces) {
|
|
164
|
+
};
|
|
165
|
+
AppCallCoreClass.prototype.setIOSInterface = function (interfaces) {
|
|
158
166
|
this.iOSInterface = interfaces;
|
|
159
|
-
}
|
|
160
|
-
getIOSInterface() {
|
|
167
|
+
};
|
|
168
|
+
AppCallCoreClass.prototype.getIOSInterface = function () {
|
|
161
169
|
return this.iOSInterface;
|
|
162
|
-
}
|
|
163
|
-
getConfig() {
|
|
170
|
+
};
|
|
171
|
+
AppCallCoreClass.prototype.getConfig = function () {
|
|
164
172
|
return this.config;
|
|
165
|
-
}
|
|
166
|
-
getIsClient() {
|
|
173
|
+
};
|
|
174
|
+
AppCallCoreClass.prototype.getIsClient = function () {
|
|
167
175
|
return this.isClient;
|
|
168
|
-
}
|
|
169
|
-
|
|
176
|
+
};
|
|
177
|
+
return AppCallCoreClass;
|
|
178
|
+
}());
|
|
179
|
+
export { AppCallCoreClass };
|
|
@@ -6,7 +6,7 @@ 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;
|