vite-uni-dev-tool 0.0.11 → 0.0.13
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/README.md +55 -1
- package/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/dev/components/AppInfo/index.vue +0 -36
- package/dev/components/AutoSizer/index.vue +0 -193
- package/dev/components/AutoSizer/index1.vue +0 -186
- package/dev/components/AutoSizer/utils.ts +0 -49
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/CaptureScreen/index.vue +0 -62
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/CloseButton/index.vue +0 -26
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/Connection/index.vue +0 -88
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
- package/dev/components/ConsoleList/RunJSInput.vue +0 -235
- package/dev/components/ConsoleList/index.vue +0 -130
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -182
- package/dev/components/DevToolButton/index.vue +0 -213
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1037
- package/dev/components/DeviceInfo/index.vue +0 -32
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +0 -28
- package/dev/components/FilterInput/index.vue +0 -86
- package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
- package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
- package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
- package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
- package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
- package/dev/components/JsonPretty/hooks/useError.ts +0 -21
- package/dev/components/JsonPretty/index.vue +0 -474
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -197
- package/dev/components/NetworkList/NetworkItem.vue +0 -106
- package/dev/components/NetworkList/index.vue +0 -115
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -110
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -225
- package/dev/components/StorageList/index.vue +0 -170
- package/dev/components/SystemInfo/index.vue +0 -34
- package/dev/components/Tabs/index.vue +0 -123
- package/dev/components/Tag/index.vue +0 -89
- package/dev/components/UniEvent/UniEventItem.vue +0 -124
- package/dev/components/UniEvent/index.vue +0 -94
- package/dev/components/UploadList/UploadDetail.vue +0 -208
- package/dev/components/UploadList/UploadItem.vue +0 -111
- package/dev/components/UploadList/index.vue +0 -104
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -175
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -98
- package/dev/components/WebSocket/WebSocketList.vue +0 -176
- package/dev/components/WebSocket/index.vue +0 -111
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -166
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -806
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -718
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -264
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -46
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -72
- package/dev/utils/object.ts +0 -298
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
import { backup as m } from "../core.js";
|
|
2
|
+
import "../utils/index.js";
|
|
3
|
+
import { transformValueToView as k } from "../utils/language.js";
|
|
4
|
+
import { getCurrentPagePath as g } from "../utils/page.js";
|
|
5
|
+
import { getCurrentDate as o } from "../utils/date.js";
|
|
6
|
+
import { parseValue as L } from "../utils/object.js";
|
|
7
|
+
import { escapeHTML as w } from "../utils/string.js";
|
|
8
|
+
class W {
|
|
9
|
+
constructor(e) {
|
|
10
|
+
this.initPinia = !1, this.cache$on = /* @__PURE__ */ new Map(), this.cache$once = /* @__PURE__ */ new Map(), this.cache$emit = /* @__PURE__ */ new Map(), this.cache$off = /* @__PURE__ */ new Map(), this.event = e.event, this.init(e);
|
|
11
|
+
}
|
|
12
|
+
init(e) {
|
|
13
|
+
this.interceptAppError(), this.interceptAppConsole(), this.interceptSetStorage(), this.interceptRemoveStorage(), this.interceptClearStorage(), this.interceptUploadFile(), this.interceptRequest(), this.interceptSocket(), this.interceptSwitchTab(), this.interceptNavigateTo(), this.interceptUniEvent(), e.enableInterceptPromiseReject && this.interceptPromiseReject();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* app 中拦截 console
|
|
17
|
+
* app
|
|
18
|
+
* @memberof DevIntercept
|
|
19
|
+
*/
|
|
20
|
+
interceptAppConsole() {
|
|
21
|
+
if (!uni.__log__)
|
|
22
|
+
return;
|
|
23
|
+
const e = this;
|
|
24
|
+
uni.__log__ = function(s, t, ...i) {
|
|
25
|
+
const r = g();
|
|
26
|
+
m.__log__(s, t, ...i), e.event.updateConsoleList([
|
|
27
|
+
{
|
|
28
|
+
type: s,
|
|
29
|
+
position: r,
|
|
30
|
+
time: o(),
|
|
31
|
+
args: i.map((d) => ({
|
|
32
|
+
type: k(d),
|
|
33
|
+
value: L(d)
|
|
34
|
+
})),
|
|
35
|
+
stack: t
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 拦截 vue3 信息
|
|
42
|
+
*
|
|
43
|
+
* @memberof DevIntercept
|
|
44
|
+
*/
|
|
45
|
+
interceptVue3(e) {
|
|
46
|
+
e && (e.appContext.config.errorHandler = (s, t, i) => {
|
|
47
|
+
this.event.getDevToolDestroy() || this.interceptErrorVue3(s);
|
|
48
|
+
}, e.appContext.config.warnHandler = (s, t, i) => {
|
|
49
|
+
this.event.getDevToolDestroy() || this.interceptWarnVue3(s + `
|
|
50
|
+
` + i);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* app 中捕获全局错误
|
|
55
|
+
*
|
|
56
|
+
* @memberof DevIntercept
|
|
57
|
+
*/
|
|
58
|
+
interceptAppError() {
|
|
59
|
+
uni.onError((e) => {
|
|
60
|
+
var i, r;
|
|
61
|
+
if (this.event.getDevToolDestroy())
|
|
62
|
+
return;
|
|
63
|
+
const s = e.toString(), t = ((r = (i = e == null ? void 0 : e.stack) == null ? void 0 : i.split(`
|
|
64
|
+
`)) == null ? void 0 : r[1]) ?? "";
|
|
65
|
+
this.event.updateConsoleList([
|
|
66
|
+
{
|
|
67
|
+
type: "error",
|
|
68
|
+
args: [
|
|
69
|
+
{
|
|
70
|
+
type: "string",
|
|
71
|
+
value: s
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
position: g(),
|
|
75
|
+
time: o(),
|
|
76
|
+
stack: t
|
|
77
|
+
}
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 拦截 app 错误
|
|
83
|
+
*
|
|
84
|
+
* @param {*} error
|
|
85
|
+
* @memberof DevIntercept
|
|
86
|
+
*/
|
|
87
|
+
interceptErrorVue3(e) {
|
|
88
|
+
var i;
|
|
89
|
+
const s = (i = e == null ? void 0 : e.stack) == null ? void 0 : i.split(`
|
|
90
|
+
`), t = s == null ? void 0 : s[1];
|
|
91
|
+
console.error(e), this.event.updateConsoleList([
|
|
92
|
+
{
|
|
93
|
+
type: "error",
|
|
94
|
+
args: [
|
|
95
|
+
{
|
|
96
|
+
type: "string",
|
|
97
|
+
value: e.toString()
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
position: g(),
|
|
101
|
+
time: o(),
|
|
102
|
+
stack: t
|
|
103
|
+
}
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 拦截 app 警告
|
|
108
|
+
*
|
|
109
|
+
* @param {*} warn
|
|
110
|
+
* @return {*}
|
|
111
|
+
* @memberof DevIntercept
|
|
112
|
+
*/
|
|
113
|
+
interceptWarnVue3(e) {
|
|
114
|
+
var d, n, l, h;
|
|
115
|
+
if (this.preWarn === e)
|
|
116
|
+
return;
|
|
117
|
+
this.preWarn = e;
|
|
118
|
+
const s = g(), t = (n = (d = new Error()) == null ? void 0 : d.stack) == null ? void 0 : n.split(`
|
|
119
|
+
`), i = (l = t == null ? void 0 : t.slice(2)) == null ? void 0 : l[0];
|
|
120
|
+
console.warn(e);
|
|
121
|
+
const r = (h = e.split(`
|
|
122
|
+
`)) == null ? void 0 : h.map((v) => w(v)).join(`
|
|
123
|
+
`);
|
|
124
|
+
this.event.updateConsoleList([
|
|
125
|
+
{
|
|
126
|
+
type: "warn",
|
|
127
|
+
args: [
|
|
128
|
+
{
|
|
129
|
+
type: "string",
|
|
130
|
+
value: r
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
position: s,
|
|
134
|
+
time: o(),
|
|
135
|
+
stack: i
|
|
136
|
+
}
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 拦截 promise reject
|
|
141
|
+
*
|
|
142
|
+
* @memberof DevIntercept
|
|
143
|
+
*/
|
|
144
|
+
interceptPromiseReject() {
|
|
145
|
+
Object.defineProperty(Promise, "reject", {
|
|
146
|
+
value: function(e) {
|
|
147
|
+
return this.interceptErrorApp(e), m.reject.call(Promise, e);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 拦截 nav 跳转
|
|
153
|
+
*
|
|
154
|
+
* @memberof DevIntercept
|
|
155
|
+
*/
|
|
156
|
+
interceptSwitchTab() {
|
|
157
|
+
const e = this;
|
|
158
|
+
uni.addInterceptor("switchTab", {
|
|
159
|
+
invoke(s) {
|
|
160
|
+
const t = s.complete;
|
|
161
|
+
s.complete = function(i) {
|
|
162
|
+
var d, n, l;
|
|
163
|
+
t && t(i);
|
|
164
|
+
const r = ((l = (n = (d = s.url) == null ? void 0 : d.slice(1)) == null ? void 0 : n.split("?")) == null ? void 0 : l[0]) || "/";
|
|
165
|
+
e.event.updateCurrentPagePath(r);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 拦截页面跳转
|
|
172
|
+
*
|
|
173
|
+
* @memberof DevIntercept
|
|
174
|
+
*/
|
|
175
|
+
interceptNavigateTo() {
|
|
176
|
+
const e = this;
|
|
177
|
+
uni.addInterceptor("navigateTo", {
|
|
178
|
+
invoke(s) {
|
|
179
|
+
const t = s.complete;
|
|
180
|
+
s.complete = function(i) {
|
|
181
|
+
var d, n, l;
|
|
182
|
+
t && t(i);
|
|
183
|
+
const r = ((l = (n = (d = s.url) == null ? void 0 : d.slice(1)) == null ? void 0 : n.split("?")) == null ? void 0 : l[0]) || "/";
|
|
184
|
+
e.event.updateCurrentPagePath(r);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* 拦截网络请求
|
|
191
|
+
*
|
|
192
|
+
* @memberof DevIntercept
|
|
193
|
+
*/
|
|
194
|
+
interceptRequest() {
|
|
195
|
+
const e = this;
|
|
196
|
+
uni.addInterceptor("request", {
|
|
197
|
+
invoke(s) {
|
|
198
|
+
var a;
|
|
199
|
+
const t = e.event.getRequestIndex(), i = e.event.setRequestIndex(t + 1), r = s.url, d = (a = r == null ? void 0 : r.split("?")) == null ? void 0 : a[0], n = d == null ? void 0 : d.lastIndexOf("/"), l = (d == null ? void 0 : d.slice(n + 1)) ?? "", h = {
|
|
200
|
+
index: i,
|
|
201
|
+
url: s.url,
|
|
202
|
+
name: l,
|
|
203
|
+
startTime: Date.now(),
|
|
204
|
+
endTime: 0,
|
|
205
|
+
time: "-",
|
|
206
|
+
headers: {
|
|
207
|
+
requestHeader: Object.entries(s.header ?? {}).map(
|
|
208
|
+
([c, u]) => ({
|
|
209
|
+
key: c,
|
|
210
|
+
value: u
|
|
211
|
+
})
|
|
212
|
+
),
|
|
213
|
+
responseHeader: []
|
|
214
|
+
},
|
|
215
|
+
method: s.method || "GET",
|
|
216
|
+
status: "pending",
|
|
217
|
+
payload: s != null && s.data ? JSON.stringify(s.data) : "",
|
|
218
|
+
response: "",
|
|
219
|
+
size: ""
|
|
220
|
+
};
|
|
221
|
+
e.event.updateNetworkList([h]);
|
|
222
|
+
let v = s.complete;
|
|
223
|
+
s.complete = function(c) {
|
|
224
|
+
var p, f;
|
|
225
|
+
v && v(c), h.status = c.statusCode ?? "error", h.endTime = Date.now();
|
|
226
|
+
const u = Date.now() - h.startTime;
|
|
227
|
+
h.time = u < 1e3 ? u + "ms" : u / 1e3 + "s";
|
|
228
|
+
const S = ((p = c == null ? void 0 : c.header) == null ? void 0 : p["Content-Length"]) || ((f = c == null ? void 0 : c.header) == null ? void 0 : f["content-length"]) || 0;
|
|
229
|
+
h.size = S > 1024 ? (S / 1024).toFixed(2) + "k" : S + "b", h.response = c, h.headers.responseHeader = Object.entries(
|
|
230
|
+
c.header ?? {}
|
|
231
|
+
).map(([y, T]) => ({
|
|
232
|
+
key: y,
|
|
233
|
+
value: T
|
|
234
|
+
})), e.event.updateNetworkList([h], i);
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 拦截 websocket
|
|
241
|
+
*
|
|
242
|
+
* @memberof DevIntercept
|
|
243
|
+
*/
|
|
244
|
+
interceptSocket() {
|
|
245
|
+
const e = this, s = function(t) {
|
|
246
|
+
const i = t.url, r = Object.entries(t.header ?? {}).map(
|
|
247
|
+
([a, c]) => ({ key: a, value: c })
|
|
248
|
+
), d = (t.method ?? "GET").toLowerCase(), n = t.protocols ?? [];
|
|
249
|
+
e.event.updateWsList({
|
|
250
|
+
url: i,
|
|
251
|
+
headers: r,
|
|
252
|
+
method: d,
|
|
253
|
+
protocols: n,
|
|
254
|
+
readyState: "connection",
|
|
255
|
+
message: []
|
|
256
|
+
});
|
|
257
|
+
const l = m.connectSocket({
|
|
258
|
+
...t,
|
|
259
|
+
success: (a) => {
|
|
260
|
+
var c;
|
|
261
|
+
(c = t.success) == null || c.call(t, a), e.event.updateWsList({
|
|
262
|
+
url: i,
|
|
263
|
+
readyState: "open",
|
|
264
|
+
headers: r,
|
|
265
|
+
protocols: n,
|
|
266
|
+
message: [
|
|
267
|
+
{
|
|
268
|
+
data: "连接成功",
|
|
269
|
+
type: "success",
|
|
270
|
+
time: Date.now()
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
fail: (a) => {
|
|
276
|
+
var c;
|
|
277
|
+
(c = t.fail) == null || c.call(t, a), e.event.updateWsList({
|
|
278
|
+
url: i,
|
|
279
|
+
readyState: "error",
|
|
280
|
+
headers: r,
|
|
281
|
+
protocols: n,
|
|
282
|
+
message: [
|
|
283
|
+
{
|
|
284
|
+
data: "连接失败",
|
|
285
|
+
type: "error",
|
|
286
|
+
time: Date.now()
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
complete: (a) => {
|
|
292
|
+
var c;
|
|
293
|
+
(c = t == null ? void 0 : t.complete) == null || c.call(t, a);
|
|
294
|
+
}
|
|
295
|
+
}), h = l.send;
|
|
296
|
+
l.send = (a) => {
|
|
297
|
+
h.call(l, {
|
|
298
|
+
data: a.data,
|
|
299
|
+
fail: (c) => {
|
|
300
|
+
var u;
|
|
301
|
+
(u = a == null ? void 0 : a.fail) == null || u.call(a, c), e.event.updateWsList({
|
|
302
|
+
url: i,
|
|
303
|
+
readyState: "error",
|
|
304
|
+
headers: r,
|
|
305
|
+
protocols: n,
|
|
306
|
+
message: [
|
|
307
|
+
{
|
|
308
|
+
data: JSON.stringify(c),
|
|
309
|
+
type: "error",
|
|
310
|
+
time: Date.now()
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
});
|
|
314
|
+
},
|
|
315
|
+
success: (c) => {
|
|
316
|
+
var u, S;
|
|
317
|
+
(u = a == null ? void 0 : a.success) == null || u.call(a, c), e.event.updateWsList({
|
|
318
|
+
readyState: "open",
|
|
319
|
+
url: i,
|
|
320
|
+
headers: r,
|
|
321
|
+
protocols: n,
|
|
322
|
+
message: [
|
|
323
|
+
{
|
|
324
|
+
type: "success",
|
|
325
|
+
time: Date.now(),
|
|
326
|
+
data: (S = a.data) == null ? void 0 : S.toString()
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
complete: (c) => {
|
|
332
|
+
var u;
|
|
333
|
+
(u = a == null ? void 0 : a.complete) == null || u.call(a, c);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
const v = l.close;
|
|
338
|
+
return l.close = (a) => {
|
|
339
|
+
e.event.updateWsList({
|
|
340
|
+
url: i,
|
|
341
|
+
readyState: "closing",
|
|
342
|
+
headers: r,
|
|
343
|
+
protocols: n,
|
|
344
|
+
message: []
|
|
345
|
+
}), v.call(l, {
|
|
346
|
+
...a,
|
|
347
|
+
fail: (c) => {
|
|
348
|
+
var u;
|
|
349
|
+
(u = a == null ? void 0 : a.fail) == null || u.call(a, c), e.event.updateWsList({
|
|
350
|
+
url: i,
|
|
351
|
+
headers: r,
|
|
352
|
+
readyState: "open",
|
|
353
|
+
protocols: n,
|
|
354
|
+
message: []
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
success: (c) => {
|
|
358
|
+
var u;
|
|
359
|
+
(u = a == null ? void 0 : a.success) == null || u.call(a, c), e.event.updateWsList({
|
|
360
|
+
url: i,
|
|
361
|
+
headers: r,
|
|
362
|
+
readyState: "closed",
|
|
363
|
+
protocols: n,
|
|
364
|
+
message: []
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
complete: (c) => {
|
|
368
|
+
var u;
|
|
369
|
+
(u = a == null ? void 0 : a.complete) == null || u.call(a, c);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}, l.onMessage((a) => {
|
|
373
|
+
e.event.updateWsList({
|
|
374
|
+
url: i,
|
|
375
|
+
headers: r,
|
|
376
|
+
protocols: n,
|
|
377
|
+
message: [
|
|
378
|
+
{
|
|
379
|
+
type: "success",
|
|
380
|
+
time: Date.now(),
|
|
381
|
+
data: JSON.parse(a.data)
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
});
|
|
385
|
+
}), l;
|
|
386
|
+
};
|
|
387
|
+
uni.connectSocket = s;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* 拦截 uni.setStorageSync 和 uni.setStorage
|
|
391
|
+
*
|
|
392
|
+
* @memberof DevIntercept
|
|
393
|
+
*/
|
|
394
|
+
interceptSetStorage() {
|
|
395
|
+
uni.setStorageSync = (e, s) => {
|
|
396
|
+
m.setStorageSync(e.toString(), s), this.event.updateStoreList([
|
|
397
|
+
{
|
|
398
|
+
key: e.toString(),
|
|
399
|
+
_oldKey: e.toString(),
|
|
400
|
+
value: s
|
|
401
|
+
}
|
|
402
|
+
]);
|
|
403
|
+
}, uni.setStorage = (e) => {
|
|
404
|
+
var s;
|
|
405
|
+
m.setStorage({
|
|
406
|
+
...e,
|
|
407
|
+
key: (s = e.key) == null ? void 0 : s.toString()
|
|
408
|
+
}).then(() => {
|
|
409
|
+
var t, i;
|
|
410
|
+
this.event.updateStoreList([
|
|
411
|
+
{
|
|
412
|
+
key: (t = e.key) == null ? void 0 : t.toString(),
|
|
413
|
+
_oldKey: (i = e.key) == null ? void 0 : i.toString(),
|
|
414
|
+
value: e.data
|
|
415
|
+
}
|
|
416
|
+
]);
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* 拦截 uni.clearStorageSync 和 uni.clearStorage
|
|
422
|
+
*
|
|
423
|
+
* @memberof DevIntercept
|
|
424
|
+
*/
|
|
425
|
+
interceptClearStorage() {
|
|
426
|
+
uni.clearStorageSync = () => {
|
|
427
|
+
m.clearStorageSync(), this.event.clearStorage();
|
|
428
|
+
}, uni.clearStorage = () => {
|
|
429
|
+
m.clearStorage(), this.event.clearStorage();
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* 拦截 uni.removeStorageSync 和 uni.removeStorage
|
|
434
|
+
*
|
|
435
|
+
* @memberof DevIntercept
|
|
436
|
+
*/
|
|
437
|
+
interceptRemoveStorage() {
|
|
438
|
+
uni.removeStorageSync = (e) => {
|
|
439
|
+
m.removeStorageSync(e), this.event.removeStorage(e);
|
|
440
|
+
}, uni.removeStorage = (e) => {
|
|
441
|
+
m.removeStorage(e).then(() => {
|
|
442
|
+
this.event.removeStorage(e.key);
|
|
443
|
+
});
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/** 拦截vuex */
|
|
447
|
+
interceptVuexStorage(e) {
|
|
448
|
+
var s;
|
|
449
|
+
this.event.setVuexList(e.state), (s = e == null ? void 0 : e.subscribe) == null || s.call(e, (t, i) => {
|
|
450
|
+
this.event.setVuexList(i);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/** 拦截pinia */
|
|
454
|
+
interceptPiniaStore(e) {
|
|
455
|
+
var s;
|
|
456
|
+
return this.initPinia || (this.initPinia = !0, this.event.setPiniaStore(e.pinia)), this.event.setPiniaList(e.pinia.state.value), (s = e == null ? void 0 : e.store) == null || s.$subscribe(() => {
|
|
457
|
+
this.event.setPiniaList({
|
|
458
|
+
[e.store.$id]: e.store.$state
|
|
459
|
+
});
|
|
460
|
+
}), e.pinia;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* 拦截 uni.uploadFile
|
|
464
|
+
*
|
|
465
|
+
* @memberof DevIntercept
|
|
466
|
+
*/
|
|
467
|
+
interceptUploadFile() {
|
|
468
|
+
const e = this, s = (t) => {
|
|
469
|
+
const i = e.event.getUploadIndex(), r = e.event.setUploadIndex(i + 1);
|
|
470
|
+
e.event.updateUploadList(
|
|
471
|
+
[
|
|
472
|
+
{
|
|
473
|
+
index: r,
|
|
474
|
+
name: t.name,
|
|
475
|
+
url: t.url,
|
|
476
|
+
filePath: t.filePath,
|
|
477
|
+
fileType: t.fileType,
|
|
478
|
+
headers: {
|
|
479
|
+
requestHeader: Object.entries(t.header || {}).map(
|
|
480
|
+
([n, l]) => ({ key: n, value: l })
|
|
481
|
+
),
|
|
482
|
+
responseHeader: []
|
|
483
|
+
},
|
|
484
|
+
formData: t.formData,
|
|
485
|
+
status: "pending",
|
|
486
|
+
progress: 0,
|
|
487
|
+
totalBytesSent: 0,
|
|
488
|
+
totalBytesExpectedToSend: 0,
|
|
489
|
+
startTime: Date.now()
|
|
490
|
+
}
|
|
491
|
+
],
|
|
492
|
+
r
|
|
493
|
+
);
|
|
494
|
+
const d = m.uploadFile({
|
|
495
|
+
...t,
|
|
496
|
+
success: (n) => {
|
|
497
|
+
var l;
|
|
498
|
+
(l = t == null ? void 0 : t.success) == null || l.call(t, n), e.event.updateUploadList(
|
|
499
|
+
[
|
|
500
|
+
{
|
|
501
|
+
index: r,
|
|
502
|
+
status: "success",
|
|
503
|
+
endTime: Date.now(),
|
|
504
|
+
response: {
|
|
505
|
+
...n,
|
|
506
|
+
data: JSON.parse(n.data)
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
],
|
|
510
|
+
r
|
|
511
|
+
), e.event.removeUploadTask(r);
|
|
512
|
+
},
|
|
513
|
+
fail: (n) => {
|
|
514
|
+
var l;
|
|
515
|
+
(l = t == null ? void 0 : t.fail) == null || l.call(t, n), e.event.updateUploadList(
|
|
516
|
+
[
|
|
517
|
+
{
|
|
518
|
+
index: r,
|
|
519
|
+
status: "error",
|
|
520
|
+
response: n,
|
|
521
|
+
endTime: Date.now()
|
|
522
|
+
}
|
|
523
|
+
],
|
|
524
|
+
r
|
|
525
|
+
), e.event.removeUploadTask(r);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
return d.onProgressUpdate((n) => {
|
|
529
|
+
e.event.updateUploadList(
|
|
530
|
+
[
|
|
531
|
+
{
|
|
532
|
+
index: r,
|
|
533
|
+
progress: n.progress,
|
|
534
|
+
totalBytesSent: n.totalBytesSent,
|
|
535
|
+
totalBytesExpectedToSend: n.totalBytesExpectedToSend,
|
|
536
|
+
status: "uploading"
|
|
537
|
+
}
|
|
538
|
+
],
|
|
539
|
+
r
|
|
540
|
+
);
|
|
541
|
+
}), e.event.addUploadTask(r, d), d;
|
|
542
|
+
};
|
|
543
|
+
uni.uploadFile = s.bind(uni);
|
|
544
|
+
}
|
|
545
|
+
interceptUniEventFactory(e) {
|
|
546
|
+
const s = `$${e}`;
|
|
547
|
+
uni[`$${e}`] = (t, i) => {
|
|
548
|
+
var n, l, h, v;
|
|
549
|
+
const r = (l = (n = new Error()) == null ? void 0 : n.stack) == null ? void 0 : l.split(`
|
|
550
|
+
`), d = r == null ? void 0 : r[2];
|
|
551
|
+
(v = (h = m) == null ? void 0 : h[s]) == null || v.call(h, t, i), this.event.updateUniEventList([
|
|
552
|
+
{
|
|
553
|
+
eventName: t,
|
|
554
|
+
timer: o(),
|
|
555
|
+
stack: d,
|
|
556
|
+
type: e
|
|
557
|
+
}
|
|
558
|
+
]), this.event.updateUniEventCount(e);
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
interceptUniEvent() {
|
|
562
|
+
this.interceptUniEventFactory("on"), this.interceptUniEventFactory("once"), this.interceptUniEventFactory("emit"), this.interceptUniEventFactory("off");
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* 监听截屏
|
|
566
|
+
*
|
|
567
|
+
* @memberof DevIntercept
|
|
568
|
+
*/
|
|
569
|
+
interceptCaptureScreen() {
|
|
570
|
+
uni.onUserCaptureScreen(() => {
|
|
571
|
+
this.event.getDevToolDestroy() || this.event.updateCaptureScreenList([
|
|
572
|
+
{
|
|
573
|
+
position: g(),
|
|
574
|
+
timer: o()
|
|
575
|
+
}
|
|
576
|
+
]);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
export {
|
|
581
|
+
W as DevIntercept
|
|
582
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DevConsole } from '../devConsole';
|
|
2
|
+
|
|
3
|
+
type SandboxOptions = {
|
|
4
|
+
console: DevConsole;
|
|
5
|
+
};
|
|
6
|
+
export declare class DevRunJS {
|
|
7
|
+
private context;
|
|
8
|
+
private isDestroyed;
|
|
9
|
+
constructor(options: SandboxOptions);
|
|
10
|
+
/**
|
|
11
|
+
* 创建context
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
* @param {DevConsole} [console]
|
|
15
|
+
* @memberof DevRunJs
|
|
16
|
+
*/
|
|
17
|
+
createContext(console?: DevConsole): void;
|
|
18
|
+
estimateObjectSize(obj: any): number;
|
|
19
|
+
/**
|
|
20
|
+
* 注入外部变量,方法
|
|
21
|
+
*
|
|
22
|
+
* @param {string} name
|
|
23
|
+
* @param {*} value
|
|
24
|
+
* @return {*} {this}
|
|
25
|
+
* @memberof DevRunJs
|
|
26
|
+
*/
|
|
27
|
+
setVariable(name: string, value: any): this;
|
|
28
|
+
/**
|
|
29
|
+
* 批量注入
|
|
30
|
+
*
|
|
31
|
+
* @param {Record<string, any>} variables
|
|
32
|
+
* @return {*} {this}
|
|
33
|
+
* @memberof DevRunJs
|
|
34
|
+
*/
|
|
35
|
+
setVariables(variables: Record<string, any>): this;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* TODO
|
|
39
|
+
* code 中存在 var, let, const, function 等关键字定义的变量或方法时,应该存入 context 中,允许下一次运行 js 调用
|
|
40
|
+
* 局部定义的不加入 context
|
|
41
|
+
*
|
|
42
|
+
* @memberof DevRunJs
|
|
43
|
+
*/
|
|
44
|
+
matchingGlobalVarAndFunc(code: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* TODO
|
|
47
|
+
* 清空客户端注入的context
|
|
48
|
+
*/
|
|
49
|
+
clearGlobalVarAndFunc(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 执行 code
|
|
52
|
+
*
|
|
53
|
+
* @param {string} code
|
|
54
|
+
* @return {*} {Promise<any>}
|
|
55
|
+
* @memberof DevRunJs
|
|
56
|
+
*/
|
|
57
|
+
execute(code: string): Promise<any>;
|
|
58
|
+
/**
|
|
59
|
+
* 销毁
|
|
60
|
+
*
|
|
61
|
+
* @return {*} {void}
|
|
62
|
+
* @memberof DevRunJs
|
|
63
|
+
*/
|
|
64
|
+
destroy(): void;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../dev/devRunJS/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAA2B;IAE1C,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,EAAE,cAAc;IAInC;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAezC,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;IA6BpC;;;;;;;OAOG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAQ3C;;;;;;OAMG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IASlD;;;;;;;OAOG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM;IAErC;;;OAGG;IACH,qBAAqB;IAErB;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA8BnC;;;;;OAKG;IACH,OAAO,IAAI,IAAI;CAYhB"}
|