@haluo/util 2.1.5 → 2.1.6
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.js +55 -49
- package/dist/modules/app-call/extensions.js +318 -252
- 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.js +52 -62
- 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 -395
- package/dist/modules/upload/index.js +32 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
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
|
}
|
|
@@ -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,7 +73,7 @@ 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 {
|
|
@@ -78,7 +81,7 @@ export class AppCallCoreClass {
|
|
|
78
81
|
if (this.isAndroid || this.isHarmonyos) {
|
|
79
82
|
if (this.has(name)) {
|
|
80
83
|
console.log('has', name);
|
|
81
|
-
data = window.NativeCall
|
|
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;
|
|
82
85
|
if (this.showTip && window.Toast) {
|
|
83
86
|
window.Toast({
|
|
84
87
|
position: 'middle',
|
|
@@ -109,8 +112,8 @@ export class AppCallCoreClass {
|
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
return false;
|
|
112
|
-
}
|
|
113
|
-
has(name) {
|
|
115
|
+
};
|
|
116
|
+
AppCallCoreClass.prototype.has = function (name) {
|
|
114
117
|
if (this.isAndroid || this.isHarmonyos) {
|
|
115
118
|
return !!(window.NativeCall && window.NativeCall[name]);
|
|
116
119
|
}
|
|
@@ -118,52 +121,55 @@ export class AppCallCoreClass {
|
|
|
118
121
|
return true;
|
|
119
122
|
}
|
|
120
123
|
return false;
|
|
121
|
-
}
|
|
122
|
-
extend(obj) {
|
|
123
|
-
for (
|
|
124
|
+
};
|
|
125
|
+
AppCallCoreClass.prototype.extend = function (obj) {
|
|
126
|
+
for (var key in obj) {
|
|
124
127
|
;
|
|
125
128
|
this[key] = obj[key];
|
|
126
129
|
}
|
|
127
130
|
return this;
|
|
128
|
-
}
|
|
129
|
-
callIOSHandler(name, params, callback1) {
|
|
130
|
-
|
|
131
|
-
for (
|
|
131
|
+
};
|
|
132
|
+
AppCallCoreClass.prototype.callIOSHandler = function (name, params, callback1) {
|
|
133
|
+
var obj = {};
|
|
134
|
+
for (var i = 0; i < params.length; i++) {
|
|
132
135
|
obj['arg' + (i + 1)] = params[i];
|
|
133
136
|
}
|
|
134
137
|
if (this.showTip && window.Toast) {
|
|
135
|
-
setTimeout(()
|
|
136
|
-
|
|
138
|
+
setTimeout(function () {
|
|
139
|
+
var _a;
|
|
140
|
+
(_a = window.Toast) === null || _a === void 0 ? void 0 : _a.call(window, {
|
|
137
141
|
position: 'top',
|
|
138
|
-
message:
|
|
142
|
+
message: "\u8BF7\u6C42\u65B9\u6CD5\u540D\u53CA\u53C2\u6570\uFF1A".concat(name, "\uFF1A").concat(JSON.stringify(obj))
|
|
139
143
|
});
|
|
140
144
|
}, 50);
|
|
141
145
|
}
|
|
142
146
|
if (this.isIOS && window.setupWebViewJavascriptBridge) {
|
|
143
|
-
window.setupWebViewJavascriptBridge((bridge)
|
|
147
|
+
window.setupWebViewJavascriptBridge(function (bridge) {
|
|
144
148
|
bridge.callHandler(name, obj, callback1);
|
|
145
149
|
});
|
|
146
150
|
return true;
|
|
147
151
|
}
|
|
148
152
|
return false;
|
|
149
|
-
}
|
|
150
|
-
allParamsToString(params) {
|
|
151
|
-
|
|
152
|
-
keys.forEach((key)
|
|
153
|
+
};
|
|
154
|
+
AppCallCoreClass.prototype.allParamsToString = function (params) {
|
|
155
|
+
var keys = Object.keys(params);
|
|
156
|
+
keys.forEach(function (key) {
|
|
153
157
|
params[key] = params[key] + '';
|
|
154
158
|
});
|
|
155
159
|
return params;
|
|
156
|
-
}
|
|
157
|
-
setIOSInterface(interfaces) {
|
|
160
|
+
};
|
|
161
|
+
AppCallCoreClass.prototype.setIOSInterface = function (interfaces) {
|
|
158
162
|
this.iOSInterface = interfaces;
|
|
159
|
-
}
|
|
160
|
-
getIOSInterface() {
|
|
163
|
+
};
|
|
164
|
+
AppCallCoreClass.prototype.getIOSInterface = function () {
|
|
161
165
|
return this.iOSInterface;
|
|
162
|
-
}
|
|
163
|
-
getConfig() {
|
|
166
|
+
};
|
|
167
|
+
AppCallCoreClass.prototype.getConfig = function () {
|
|
164
168
|
return this.config;
|
|
165
|
-
}
|
|
166
|
-
getIsClient() {
|
|
169
|
+
};
|
|
170
|
+
AppCallCoreClass.prototype.getIsClient = function () {
|
|
167
171
|
return this.isClient;
|
|
168
|
-
}
|
|
169
|
-
|
|
172
|
+
};
|
|
173
|
+
return AppCallCoreClass;
|
|
174
|
+
}());
|
|
175
|
+
export { AppCallCoreClass };
|