@we-debug/plugin-error 0.30.0 → 0.31.11
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +110 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.js +17 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.31.11](https://github.com/dlhandsome/we-debug/compare/v0.31.10...v0.31.11) (2024-01-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @we-debug/plugin-error
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.31.0](https://github.com/dlhandsome/we-debug/compare/v0.30.1...v0.31.0) (2024-01-03)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @we-debug/plugin-error
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [0.30.0](https://github.com/dlhandsome/we-debug/compare/v0.29.7...v0.30.0) (2023-12-22)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @we-debug/plugin-error
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var ErrorPlugin = {
|
|
18
|
+
install: function () { }
|
|
19
|
+
};
|
|
20
|
+
var errManage = {
|
|
21
|
+
_errStack: [],
|
|
22
|
+
get: function () {
|
|
23
|
+
return this._errStack;
|
|
24
|
+
},
|
|
25
|
+
add: function (e) {
|
|
26
|
+
this._errStack.push(e);
|
|
27
|
+
},
|
|
28
|
+
clear: function () {
|
|
29
|
+
this._errStack = [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
ErrorPlugin.install = function (weDebug, options) {
|
|
33
|
+
if (options === void 0) { options = {}; }
|
|
34
|
+
if (ErrorPlugin.installed)
|
|
35
|
+
return;
|
|
36
|
+
ErrorPlugin.installed = true;
|
|
37
|
+
var badgeOption = options.badge || {};
|
|
38
|
+
var copyOption = options.copyRule || {};
|
|
39
|
+
var clearOption = options.clearRule || {};
|
|
40
|
+
var errorBadge = weDebug.createBadge(Object.assign({}, {
|
|
41
|
+
key: 'error',
|
|
42
|
+
value: 0,
|
|
43
|
+
color: 'red',
|
|
44
|
+
show: function () { return true; },
|
|
45
|
+
draggable: true,
|
|
46
|
+
position: {
|
|
47
|
+
right: 0,
|
|
48
|
+
top: 10
|
|
49
|
+
}
|
|
50
|
+
}, badgeOption));
|
|
51
|
+
var copyErrStackRule = weDebug.createFormRule(Object.assign({}, {
|
|
52
|
+
title: '获取错误信息',
|
|
53
|
+
desc: '复制错误信息到剪切板',
|
|
54
|
+
type: 'button',
|
|
55
|
+
state: {
|
|
56
|
+
disabled: false
|
|
57
|
+
},
|
|
58
|
+
handler: {
|
|
59
|
+
bindTap: function (state) {
|
|
60
|
+
if (!state.disabled) {
|
|
61
|
+
wx.setClipboardData({
|
|
62
|
+
data: JSON.stringify(errManage.get(), null, 2)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, copyOption));
|
|
68
|
+
var clearErrStackRule = weDebug.createFormRule(Object.assign({}, {
|
|
69
|
+
title: '清空错误信息',
|
|
70
|
+
desc: '',
|
|
71
|
+
type: 'button',
|
|
72
|
+
state: {
|
|
73
|
+
name: '清空',
|
|
74
|
+
disabled: false
|
|
75
|
+
},
|
|
76
|
+
handler: {
|
|
77
|
+
bindTap: function (state) {
|
|
78
|
+
if (!state.disabled) {
|
|
79
|
+
errManage.clear();
|
|
80
|
+
updateState();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, clearOption));
|
|
85
|
+
weDebug.addBadge([errorBadge]);
|
|
86
|
+
weDebug.addFormRule([copyErrStackRule, clearErrStackRule], {
|
|
87
|
+
group: '系统'
|
|
88
|
+
});
|
|
89
|
+
function updateState() {
|
|
90
|
+
var errStack = errManage.get();
|
|
91
|
+
var errLen = errStack.length;
|
|
92
|
+
errorBadge.emit({
|
|
93
|
+
value: errLen
|
|
94
|
+
});
|
|
95
|
+
copyErrStackRule.emit({
|
|
96
|
+
meta: errLen
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
wx.onError &&
|
|
100
|
+
wx.onError(function (err) {
|
|
101
|
+
errManage.add(err);
|
|
102
|
+
updateState();
|
|
103
|
+
});
|
|
104
|
+
wx.onAppRoute &&
|
|
105
|
+
wx.onAppRoute(function () {
|
|
106
|
+
updateState();
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
exports.default = ErrorPlugin;
|
|
110
|
+
__exportStar(require("./types"), exports);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IPluginInstance, IBadgeManageConstructorOption, IFormRuleManageConstructorOption } from '@we-debug/core';
|
|
2
|
+
export * from '@we-debug/core';
|
|
3
|
+
export interface IPlugin extends IPluginInstance {
|
|
4
|
+
installed?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IPluginInitOption {
|
|
7
|
+
badge: IBadgeManageConstructorOption;
|
|
8
|
+
copyRule: IFormRuleManageConstructorOption;
|
|
9
|
+
clearRule: IFormRuleManageConstructorOption;
|
|
10
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@we-debug/core"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@we-debug/plugin-error",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.11",
|
|
4
4
|
"description": "error plugin for we-debug",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,5 +16,8 @@
|
|
|
16
16
|
"readme": "ERROR: No README data found!",
|
|
17
17
|
"_id": "@we-debug/plugin-error@0.1.6",
|
|
18
18
|
"_commitid": "ea9904d",
|
|
19
|
-
"
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@we-debug/core": "^0.31.10"
|
|
21
|
+
},
|
|
22
|
+
"gitHead": "42043c705c466081c52fa1c8586efb8c610ba2b1"
|
|
20
23
|
}
|