@bryce3310687963/android-toolkit 0.0.0-stage → 1.0.51
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 +100 -2
- package/browser.d.ts +158 -0
- package/dist/browser.js +818 -0
- package/dist/browser.js.map +7 -0
- package/dist/index.cjs +3300 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +3270 -0
- package/dist/index.js.map +7 -0
- package/index.d.ts +346 -0
- package/package.json +48 -4
package/dist/browser.js
ADDED
|
@@ -0,0 +1,818 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/constants.js
|
|
8
|
+
var constants_exports = {};
|
|
9
|
+
__export(constants_exports, {
|
|
10
|
+
ActorInfo: () => ActorInfo,
|
|
11
|
+
ActorKey: () => ActorKey,
|
|
12
|
+
AppiumSettings: () => AppiumSettings,
|
|
13
|
+
Code: () => Code,
|
|
14
|
+
Status: () => Status,
|
|
15
|
+
StoragePath: () => StoragePath,
|
|
16
|
+
UnicodeIme: () => UnicodeIme,
|
|
17
|
+
WebViewBridge: () => WebViewBridge
|
|
18
|
+
});
|
|
19
|
+
var Code = Object.freeze({
|
|
20
|
+
Success: 0,
|
|
21
|
+
EmptySuccess: 1,
|
|
22
|
+
UnknownError: -1,
|
|
23
|
+
NotLogin: 30000001,
|
|
24
|
+
Timeout: 30000003,
|
|
25
|
+
InitialTimeout: 30000004,
|
|
26
|
+
OverallTimeout: 30000005,
|
|
27
|
+
AccountFreeze: 30000006,
|
|
28
|
+
InvalidRequest: 30010001,
|
|
29
|
+
AdbUnavailable: 30010002,
|
|
30
|
+
ContentUnavailable: 30010003,
|
|
31
|
+
SourceExtractionFailed: 30010004,
|
|
32
|
+
AutomationFailed: 30010005,
|
|
33
|
+
AppRuntimeUnavailable: 30010008,
|
|
34
|
+
AppNotInstalled: 30010009
|
|
35
|
+
});
|
|
36
|
+
var Status = Object.freeze({
|
|
37
|
+
Success: "SUCCESS",
|
|
38
|
+
Failed: "FAILED"
|
|
39
|
+
});
|
|
40
|
+
var StoragePath = Object.freeze({
|
|
41
|
+
Input: "/apify_storage/input.json",
|
|
42
|
+
Output: "/apify_storage/output.json"
|
|
43
|
+
});
|
|
44
|
+
var UnicodeIme = Object.freeze({
|
|
45
|
+
packageName: "io.appium.settings",
|
|
46
|
+
component: "io.appium.settings/.UnicodeIME",
|
|
47
|
+
inputAction: "ADB_INPUT_TEXT"
|
|
48
|
+
});
|
|
49
|
+
var AppiumSettings = Object.freeze({
|
|
50
|
+
packageName: "io.appium.settings",
|
|
51
|
+
clipboardReceiver: "io.appium.settings/.receivers.ClipboardReceiver",
|
|
52
|
+
clipboardGetAction: "io.appium.settings.clipboard.get"
|
|
53
|
+
});
|
|
54
|
+
var WebViewBridge = Object.freeze({
|
|
55
|
+
packageName: "com.heartbit.apify.android.bridge",
|
|
56
|
+
actionCommand: "com.heartbit.apify.android.bridge.COMMAND",
|
|
57
|
+
cacheDir: "apify-webview-bridge",
|
|
58
|
+
hookConfigFile: "hook.json",
|
|
59
|
+
commandDir: "commands",
|
|
60
|
+
resultDir: "results"
|
|
61
|
+
});
|
|
62
|
+
var ActorKey = Object.freeze({
|
|
63
|
+
DoubaoAndroid: "doubao.android",
|
|
64
|
+
ErineAndroid: "erine.android",
|
|
65
|
+
WechatAndroid: "wechat.android",
|
|
66
|
+
QwenAndroid: "qwen.android",
|
|
67
|
+
YuanbaoAndroid: "yuanbao.android",
|
|
68
|
+
XhsAndroid: "xhs.android"
|
|
69
|
+
});
|
|
70
|
+
var normalizeShare = (share) => {
|
|
71
|
+
const source = share && typeof share === "object" ? share : {};
|
|
72
|
+
return {
|
|
73
|
+
mode: "clipboard",
|
|
74
|
+
prefix: String(source.prefix || "").trim(),
|
|
75
|
+
xurl: Array.isArray(source.xurl) ? source.xurl : []
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var createActorInfo = (info) => {
|
|
79
|
+
const key = String(info.key || "").trim();
|
|
80
|
+
return Object.freeze({
|
|
81
|
+
key,
|
|
82
|
+
name: String(info.name || key),
|
|
83
|
+
icon: String(info.icon || `https://static.heartbitai.com/general/actors/${key}.png`),
|
|
84
|
+
webviews: Object.freeze(Array.isArray(info.webviews) ? info.webviews : []),
|
|
85
|
+
share: Object.freeze(normalizeShare(info.share))
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
var ActorInfo = Object.freeze({
|
|
89
|
+
[ActorKey.DoubaoAndroid]: createActorInfo({
|
|
90
|
+
key: ActorKey.DoubaoAndroid,
|
|
91
|
+
name: "\u8C46\u5305 Android",
|
|
92
|
+
webviews: [{
|
|
93
|
+
name: [
|
|
94
|
+
"android.webkit.WebView",
|
|
95
|
+
"com.baidu.webkit.sdk.WebView",
|
|
96
|
+
"com.tencent.smtt.sdk.WebView",
|
|
97
|
+
"com.tencent.xweb.WebView",
|
|
98
|
+
"com.tencent.xweb.pinus.PSWebview"
|
|
99
|
+
],
|
|
100
|
+
value: ["www.doubao.com"]
|
|
101
|
+
}],
|
|
102
|
+
share: {
|
|
103
|
+
prefix: "https://www.doubao.com/thread/",
|
|
104
|
+
xurl: []
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
[ActorKey.ErineAndroid]: createActorInfo({
|
|
108
|
+
key: ActorKey.ErineAndroid,
|
|
109
|
+
name: "\u6587\u5C0F\u8A00 Android",
|
|
110
|
+
webviews: [{
|
|
111
|
+
name: [
|
|
112
|
+
"android.webkit.WebView",
|
|
113
|
+
"com.baidu.webkit.sdk.WebView",
|
|
114
|
+
"com.tencent.smtt.sdk.WebView",
|
|
115
|
+
"com.tencent.xweb.WebView",
|
|
116
|
+
"com.tencent.xweb.pinus.PSWebview"
|
|
117
|
+
],
|
|
118
|
+
value: ["yiyanapp.baidu.com"]
|
|
119
|
+
}],
|
|
120
|
+
share: {
|
|
121
|
+
prefix: "https://mr.baidu.com/r/",
|
|
122
|
+
xurl: []
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
[ActorKey.WechatAndroid]: createActorInfo({
|
|
126
|
+
key: ActorKey.WechatAndroid,
|
|
127
|
+
name: "\u5FAE\u4FE1 Android",
|
|
128
|
+
webviews: [{
|
|
129
|
+
name: [
|
|
130
|
+
"android.webkit.WebView",
|
|
131
|
+
"com.baidu.webkit.sdk.WebView",
|
|
132
|
+
"com.tencent.smtt.sdk.WebView",
|
|
133
|
+
"com.tencent.xweb.WebView",
|
|
134
|
+
"com.tencent.xweb.pinus.PSWebview"
|
|
135
|
+
],
|
|
136
|
+
value: ["websearch/template"]
|
|
137
|
+
}],
|
|
138
|
+
share: {
|
|
139
|
+
prefix: "",
|
|
140
|
+
xurl: []
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
[ActorKey.QwenAndroid]: createActorInfo({
|
|
144
|
+
key: ActorKey.QwenAndroid,
|
|
145
|
+
name: "\u5343\u95EE Android",
|
|
146
|
+
webviews: [{
|
|
147
|
+
name: [
|
|
148
|
+
"android.webkit.WebView",
|
|
149
|
+
"com.baidu.webkit.sdk.WebView",
|
|
150
|
+
"com.tencent.smtt.sdk.WebView",
|
|
151
|
+
"com.tencent.xweb.WebView",
|
|
152
|
+
"com.tencent.xweb.pinus.PSWebview"
|
|
153
|
+
],
|
|
154
|
+
value: ["www.qianwen.com", "chat2.qianwen.com"]
|
|
155
|
+
}],
|
|
156
|
+
share: {
|
|
157
|
+
prefix: "",
|
|
158
|
+
xurl: []
|
|
159
|
+
}
|
|
160
|
+
}),
|
|
161
|
+
[ActorKey.XhsAndroid]: createActorInfo({
|
|
162
|
+
key: ActorKey.XhsAndroid,
|
|
163
|
+
name: "\u5C0F\u7EA2\u4E66 Android",
|
|
164
|
+
webviews: [{
|
|
165
|
+
name: [
|
|
166
|
+
"android.webkit.WebView",
|
|
167
|
+
"com.baidu.webkit.sdk.WebView",
|
|
168
|
+
"com.tencent.smtt.sdk.WebView",
|
|
169
|
+
"com.tencent.xweb.WebView",
|
|
170
|
+
"com.tencent.xweb.pinus.PSWebview"
|
|
171
|
+
],
|
|
172
|
+
value: ["xiaohongshu.com", "xhslink.com"]
|
|
173
|
+
}],
|
|
174
|
+
share: {
|
|
175
|
+
prefix: "",
|
|
176
|
+
xurl: []
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
[ActorKey.YuanbaoAndroid]: createActorInfo({
|
|
180
|
+
key: ActorKey.YuanbaoAndroid,
|
|
181
|
+
name: "\u5143\u5B9D Android",
|
|
182
|
+
webviews: [{
|
|
183
|
+
name: [
|
|
184
|
+
"android.webkit.WebView",
|
|
185
|
+
"com.baidu.webkit.sdk.WebView",
|
|
186
|
+
"com.tencent.smtt.sdk.WebView",
|
|
187
|
+
"com.tencent.xweb.WebView",
|
|
188
|
+
"com.tencent.xweb.pinus.PSWebview"
|
|
189
|
+
],
|
|
190
|
+
value: ["yuanbao.tencent.com", "hunyuan.tencent.com", "yb.tencent.com"]
|
|
191
|
+
}],
|
|
192
|
+
share: {
|
|
193
|
+
prefix: "https://yb.tencent.com/s/",
|
|
194
|
+
xurl: []
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// src/errors.js
|
|
200
|
+
var errors_exports = {};
|
|
201
|
+
__export(errors_exports, {
|
|
202
|
+
CrawlerError: () => CrawlerError,
|
|
203
|
+
serializeError: () => serializeError
|
|
204
|
+
});
|
|
205
|
+
var CrawlerError = class _CrawlerError extends Error {
|
|
206
|
+
constructor(input = {}, options = {}) {
|
|
207
|
+
const payload = typeof input === "string" ? { message: input } : input;
|
|
208
|
+
super(payload.message || "Android crawler error", options);
|
|
209
|
+
this.name = "CrawlerError";
|
|
210
|
+
this.code = payload.code || Code.UnknownError;
|
|
211
|
+
this.context = payload.context || {};
|
|
212
|
+
}
|
|
213
|
+
static isCrawlerError(error) {
|
|
214
|
+
return error instanceof _CrawlerError || (error == null ? void 0 : error.name) === "CrawlerError";
|
|
215
|
+
}
|
|
216
|
+
static from(error, fallback = {}) {
|
|
217
|
+
if (_CrawlerError.isCrawlerError(error)) return error;
|
|
218
|
+
return new _CrawlerError({
|
|
219
|
+
message: (error == null ? void 0 : error.message) || String(error),
|
|
220
|
+
code: fallback.code || Code.UnknownError,
|
|
221
|
+
context: fallback.context || {}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
function serializeError(error) {
|
|
226
|
+
if (!error) return { message: "" };
|
|
227
|
+
return {
|
|
228
|
+
name: error.name || "Error",
|
|
229
|
+
message: error.message || String(error),
|
|
230
|
+
stack: error.stack || "",
|
|
231
|
+
code: error.code || "",
|
|
232
|
+
context: error.context || void 0
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/logger.js
|
|
237
|
+
var defaultLogger = {
|
|
238
|
+
info: (...args) => console.error(...args),
|
|
239
|
+
warning: (...args) => console.error(...args),
|
|
240
|
+
warn: (...args) => console.error(...args),
|
|
241
|
+
error: (...args) => console.error(...args),
|
|
242
|
+
debug: (...args) => console.error(...args)
|
|
243
|
+
};
|
|
244
|
+
var activeLogger = defaultLogger;
|
|
245
|
+
var ANSI = {
|
|
246
|
+
reset: "\x1B[0m",
|
|
247
|
+
gray: "\x1B[90m",
|
|
248
|
+
red: "\x1B[31m",
|
|
249
|
+
green: "\x1B[32m",
|
|
250
|
+
yellow: "\x1B[33m",
|
|
251
|
+
blue: "\x1B[34m",
|
|
252
|
+
cyan: "\x1B[36m"
|
|
253
|
+
};
|
|
254
|
+
var STEP_PREFIX = "\u6B65\u9AA4:";
|
|
255
|
+
var STEP_SEPARATOR = " | ";
|
|
256
|
+
var LOG_TAG_PREFIX = "[#log:";
|
|
257
|
+
var LOG_TAG_SUFFIX = "]";
|
|
258
|
+
var STEP_ICONS = [
|
|
259
|
+
{ match: "\u4EFB\u52A1", icon: "\u{1F9ED}" },
|
|
260
|
+
{ match: "Launch", icon: "\u{1F680}" },
|
|
261
|
+
{ match: "Step", icon: "\u{1F9F1}" },
|
|
262
|
+
{ match: "\u8F93\u5165\u6CD5", icon: "\u2328\uFE0F" },
|
|
263
|
+
{ match: "ADB", icon: "\u{1F50C}" },
|
|
264
|
+
{ match: "Mutation", icon: "\u{1F4E1}" },
|
|
265
|
+
{ match: "WebView", icon: "\u{1F310}" },
|
|
266
|
+
{ match: "\u622A\u56FE", icon: "\u{1F5BC}\uFE0F" },
|
|
267
|
+
{ match: "\u5206\u4EAB", icon: "\u{1F517}" },
|
|
268
|
+
{ match: "\u6570\u636E", icon: "\u{1F4E6}" }
|
|
269
|
+
];
|
|
270
|
+
var STATUS_ICONS = [
|
|
271
|
+
{ match: "\u5F00\u59CB", icon: "\u{1F680}" },
|
|
272
|
+
{ match: "\u5B8C\u6210", icon: "\u2705" },
|
|
273
|
+
{ match: "\u6210\u529F", icon: "\u2705" },
|
|
274
|
+
{ match: "\u5931\u8D25", icon: "\u274C" },
|
|
275
|
+
{ match: "\u8DF3\u8FC7", icon: "\u23ED\uFE0F" },
|
|
276
|
+
{ match: "\u91CD\u8BD5", icon: "\u{1F501}" },
|
|
277
|
+
{ match: "\u7A33\u5B9A", icon: "\u{1F7E2}" }
|
|
278
|
+
];
|
|
279
|
+
var ATTENTION_RANK = {
|
|
280
|
+
low: 1,
|
|
281
|
+
medium: 2,
|
|
282
|
+
high: 3,
|
|
283
|
+
critical: 4
|
|
284
|
+
};
|
|
285
|
+
var DEFAULT_ATTENTION_RANK = ATTENTION_RANK.high;
|
|
286
|
+
var toErrorMessage = (error) => {
|
|
287
|
+
if (!error) return "";
|
|
288
|
+
if (error instanceof Error) return error.message;
|
|
289
|
+
if (typeof error === "string") return error;
|
|
290
|
+
try {
|
|
291
|
+
return JSON.stringify(error);
|
|
292
|
+
} catch {
|
|
293
|
+
return String(error);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
var detailToParts = (detail) => {
|
|
297
|
+
if (detail == null || detail === "") return [];
|
|
298
|
+
if (detail instanceof Error) return [`err=${detail.message}`];
|
|
299
|
+
if (typeof detail === "string") return [detail];
|
|
300
|
+
if (Array.isArray(detail)) return detail.flatMap(detailToParts).filter(Boolean);
|
|
301
|
+
if (typeof detail === "object") {
|
|
302
|
+
return Object.entries(detail).filter(([, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key}=${typeof value === "object" ? safeJson(value) : String(value)}`);
|
|
303
|
+
}
|
|
304
|
+
return [String(detail)];
|
|
305
|
+
};
|
|
306
|
+
var LOG_DEFINITIONS = [
|
|
307
|
+
{
|
|
308
|
+
key: "task_start",
|
|
309
|
+
method: "taskStart",
|
|
310
|
+
label: "\u4EFB\u52A1\u5F00\u59CB",
|
|
311
|
+
group: "\u4EFB\u52A1",
|
|
312
|
+
step: "\u4EFB\u52A1",
|
|
313
|
+
status: "\u5F00\u59CB",
|
|
314
|
+
level: "start",
|
|
315
|
+
attention: "low",
|
|
316
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
key: "task_success",
|
|
320
|
+
method: "taskSuccess",
|
|
321
|
+
label: "\u4EFB\u52A1\u5B8C\u6210",
|
|
322
|
+
group: "\u4EFB\u52A1",
|
|
323
|
+
step: "\u4EFB\u52A1",
|
|
324
|
+
status: "\u5B8C\u6210",
|
|
325
|
+
level: "success",
|
|
326
|
+
attention: "high",
|
|
327
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
key: "task_fail",
|
|
331
|
+
method: "taskFail",
|
|
332
|
+
label: "\u4EFB\u52A1\u5931\u8D25",
|
|
333
|
+
group: "\u4EFB\u52A1",
|
|
334
|
+
step: "\u4EFB\u52A1",
|
|
335
|
+
status: "\u5931\u8D25",
|
|
336
|
+
level: "error",
|
|
337
|
+
attention: "critical",
|
|
338
|
+
buildDetails: (detail, error) => [...detailToParts(detail), error ? `err=${toErrorMessage(error)}` : ""]
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
key: "launch_start",
|
|
342
|
+
method: "launchStart",
|
|
343
|
+
label: "Launch \u5F00\u59CB",
|
|
344
|
+
group: "Launch",
|
|
345
|
+
step: "Launch.run",
|
|
346
|
+
status: "\u5F00\u59CB",
|
|
347
|
+
level: "start",
|
|
348
|
+
attention: "low",
|
|
349
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
key: "launch_success",
|
|
353
|
+
method: "launchSuccess",
|
|
354
|
+
label: "Launch \u5B8C\u6210",
|
|
355
|
+
group: "Launch",
|
|
356
|
+
step: "Launch.run",
|
|
357
|
+
status: "\u5B8C\u6210",
|
|
358
|
+
level: "success",
|
|
359
|
+
attention: "high",
|
|
360
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
key: "launch_fail",
|
|
364
|
+
method: "launchFail",
|
|
365
|
+
label: "Launch \u5931\u8D25",
|
|
366
|
+
group: "Launch",
|
|
367
|
+
step: "Launch.run",
|
|
368
|
+
status: "\u5931\u8D25",
|
|
369
|
+
level: "error",
|
|
370
|
+
attention: "critical",
|
|
371
|
+
buildDetails: (detail, error) => [...detailToParts(detail), error ? `err=${toErrorMessage(error)}` : ""]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
key: "input_method_snapshot_fail",
|
|
375
|
+
method: "inputMethodSnapshotFail",
|
|
376
|
+
label: "\u8F93\u5165\u6CD5\u5FEB\u7167\u5931\u8D25",
|
|
377
|
+
group: "\u8F93\u5165\u6CD5",
|
|
378
|
+
step: "\u8F93\u5165\u6CD5\u5FEB\u7167",
|
|
379
|
+
status: "\u5931\u8D25",
|
|
380
|
+
level: "warning",
|
|
381
|
+
attention: "medium",
|
|
382
|
+
buildDetails: (error) => [error ? `err=${toErrorMessage(error)}` : ""]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
key: "input_method_restore_fail",
|
|
386
|
+
method: "inputMethodRestoreFail",
|
|
387
|
+
label: "\u8F93\u5165\u6CD5\u6062\u590D\u5931\u8D25",
|
|
388
|
+
group: "\u8F93\u5165\u6CD5",
|
|
389
|
+
step: "\u8F93\u5165\u6CD5\u6062\u590D",
|
|
390
|
+
status: "\u5931\u8D25",
|
|
391
|
+
level: "warning",
|
|
392
|
+
attention: "medium",
|
|
393
|
+
buildDetails: (error) => [error ? `err=${toErrorMessage(error)}` : ""]
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
key: "step_start",
|
|
397
|
+
method: "stepStart",
|
|
398
|
+
label: "\u6B65\u9AA4\u5F00\u59CB",
|
|
399
|
+
group: "Step",
|
|
400
|
+
step: "Step",
|
|
401
|
+
status: "\u5F00\u59CB",
|
|
402
|
+
level: "start",
|
|
403
|
+
attention: "low",
|
|
404
|
+
buildDetails: (step, detail) => [step ? `name=${step}` : "", ...detailToParts(detail)]
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
key: "step_success",
|
|
408
|
+
method: "stepSuccess",
|
|
409
|
+
label: "\u6B65\u9AA4\u5B8C\u6210",
|
|
410
|
+
group: "Step",
|
|
411
|
+
step: "Step",
|
|
412
|
+
status: "\u5B8C\u6210",
|
|
413
|
+
level: "success",
|
|
414
|
+
attention: "high",
|
|
415
|
+
buildDetails: (step, detail) => [step ? `name=${step}` : "", ...detailToParts(detail)]
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
key: "step_fail",
|
|
419
|
+
method: "stepFail",
|
|
420
|
+
label: "\u6B65\u9AA4\u5931\u8D25",
|
|
421
|
+
group: "Step",
|
|
422
|
+
step: "Step",
|
|
423
|
+
status: "\u5931\u8D25",
|
|
424
|
+
level: "error",
|
|
425
|
+
attention: "critical",
|
|
426
|
+
buildDetails: (step, error) => [step ? `name=${step}` : "", error ? `err=${toErrorMessage(error)}` : ""]
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
key: "step_retry",
|
|
430
|
+
method: "stepRetry",
|
|
431
|
+
label: "\u6B65\u9AA4\u91CD\u8BD5",
|
|
432
|
+
group: "Step",
|
|
433
|
+
step: "Step",
|
|
434
|
+
status: "\u91CD\u8BD5",
|
|
435
|
+
level: "warning",
|
|
436
|
+
attention: "medium",
|
|
437
|
+
buildDetails: (step, attempt) => [step ? `name=${step}` : "", attempt !== void 0 ? `attempt=${attempt}` : ""]
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
key: "adb_exec",
|
|
441
|
+
method: "adbExec",
|
|
442
|
+
label: "ADB \u6267\u884C",
|
|
443
|
+
group: "ADB",
|
|
444
|
+
step: "ADB",
|
|
445
|
+
status: "\u5B8C\u6210",
|
|
446
|
+
level: "debug",
|
|
447
|
+
attention: "low",
|
|
448
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
key: "adb_retry",
|
|
452
|
+
method: "adbRetry",
|
|
453
|
+
label: "ADB \u91CD\u8BD5",
|
|
454
|
+
group: "ADB",
|
|
455
|
+
step: "ADB",
|
|
456
|
+
status: "\u91CD\u8BD5",
|
|
457
|
+
level: "warning",
|
|
458
|
+
attention: "medium",
|
|
459
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
key: "mutation_wait_start",
|
|
463
|
+
method: "mutationWaitStart",
|
|
464
|
+
label: "Mutation \u7B49\u5F85\u5F00\u59CB",
|
|
465
|
+
group: "Mutation",
|
|
466
|
+
step: "Mutation",
|
|
467
|
+
status: "\u5F00\u59CB",
|
|
468
|
+
level: "start",
|
|
469
|
+
attention: "low",
|
|
470
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
key: "mutation_wait_success",
|
|
474
|
+
method: "mutationWaitSuccess",
|
|
475
|
+
label: "Mutation \u7A33\u5B9A",
|
|
476
|
+
group: "Mutation",
|
|
477
|
+
step: "Mutation",
|
|
478
|
+
status: "\u7A33\u5B9A",
|
|
479
|
+
level: "success",
|
|
480
|
+
attention: "medium",
|
|
481
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
key: "mutation_wait_warn",
|
|
485
|
+
method: "mutationWaitWarn",
|
|
486
|
+
label: "Mutation \u7B49\u5F85\u544A\u8B66",
|
|
487
|
+
group: "Mutation",
|
|
488
|
+
step: "Mutation",
|
|
489
|
+
status: "\u8DF3\u8FC7",
|
|
490
|
+
level: "warning",
|
|
491
|
+
attention: "medium",
|
|
492
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
key: "webview_command",
|
|
496
|
+
method: "webViewCommand",
|
|
497
|
+
label: "WebView \u547D\u4EE4",
|
|
498
|
+
group: "WebView",
|
|
499
|
+
step: "WebView",
|
|
500
|
+
status: "\u5F00\u59CB",
|
|
501
|
+
level: "start",
|
|
502
|
+
attention: "low",
|
|
503
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
key: "webview_success",
|
|
507
|
+
method: "webViewSuccess",
|
|
508
|
+
label: "WebView \u5B8C\u6210",
|
|
509
|
+
group: "WebView",
|
|
510
|
+
step: "WebView",
|
|
511
|
+
status: "\u5B8C\u6210",
|
|
512
|
+
level: "success",
|
|
513
|
+
attention: "medium",
|
|
514
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
key: "webview_warn",
|
|
518
|
+
method: "webViewWarn",
|
|
519
|
+
label: "WebView \u544A\u8B66",
|
|
520
|
+
group: "WebView",
|
|
521
|
+
step: "WebView",
|
|
522
|
+
status: "\u8DF3\u8FC7",
|
|
523
|
+
level: "warning",
|
|
524
|
+
attention: "medium",
|
|
525
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
key: "webview_fail",
|
|
529
|
+
method: "webViewFail",
|
|
530
|
+
label: "WebView \u5931\u8D25",
|
|
531
|
+
group: "WebView",
|
|
532
|
+
step: "WebView",
|
|
533
|
+
status: "\u5931\u8D25",
|
|
534
|
+
level: "error",
|
|
535
|
+
attention: "high",
|
|
536
|
+
buildDetails: (error) => [error ? `err=${toErrorMessage(error)}` : ""]
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
key: "screenshot_start",
|
|
540
|
+
method: "screenshotStart",
|
|
541
|
+
label: "\u622A\u56FE\u5F00\u59CB",
|
|
542
|
+
group: "\u622A\u56FE",
|
|
543
|
+
step: "\u622A\u56FE",
|
|
544
|
+
status: "\u5F00\u59CB",
|
|
545
|
+
level: "start",
|
|
546
|
+
attention: "low",
|
|
547
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
key: "screenshot_success",
|
|
551
|
+
method: "screenshotDone",
|
|
552
|
+
label: "\u622A\u56FE\u6210\u529F",
|
|
553
|
+
group: "\u622A\u56FE",
|
|
554
|
+
step: "\u622A\u56FE",
|
|
555
|
+
status: "\u6210\u529F",
|
|
556
|
+
level: "success",
|
|
557
|
+
attention: "high",
|
|
558
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
key: "share_start",
|
|
562
|
+
method: "shareStart",
|
|
563
|
+
label: "\u5206\u4EAB\u5F00\u59CB",
|
|
564
|
+
group: "\u5206\u4EAB",
|
|
565
|
+
step: "\u5206\u4EAB",
|
|
566
|
+
status: "\u5F00\u59CB",
|
|
567
|
+
level: "start",
|
|
568
|
+
attention: "low",
|
|
569
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
key: "share_success",
|
|
573
|
+
method: "shareSuccess",
|
|
574
|
+
label: "\u5206\u4EAB\u6210\u529F",
|
|
575
|
+
group: "\u5206\u4EAB",
|
|
576
|
+
step: "\u5206\u4EAB",
|
|
577
|
+
status: "\u6210\u529F",
|
|
578
|
+
level: "success",
|
|
579
|
+
attention: "high",
|
|
580
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
key: "share_fail",
|
|
584
|
+
method: "shareFail",
|
|
585
|
+
label: "\u5206\u4EAB\u5931\u8D25",
|
|
586
|
+
group: "\u5206\u4EAB",
|
|
587
|
+
step: "\u5206\u4EAB",
|
|
588
|
+
status: "\u5931\u8D25",
|
|
589
|
+
level: "warning",
|
|
590
|
+
attention: "high",
|
|
591
|
+
buildDetails: (error) => [error ? `err=${toErrorMessage(error)}` : ""]
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
key: "data_push_success",
|
|
595
|
+
method: "dataPush",
|
|
596
|
+
label: "\u6570\u636E\u63A8\u9001\u6210\u529F",
|
|
597
|
+
group: "\u6570\u636E",
|
|
598
|
+
step: "\u6570\u636E\u63A8\u9001",
|
|
599
|
+
status: "\u6210\u529F",
|
|
600
|
+
level: "success",
|
|
601
|
+
attention: "high",
|
|
602
|
+
buildDetails: (detail) => detailToParts(detail)
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
key: "data_push_fail",
|
|
606
|
+
method: "dataPushFail",
|
|
607
|
+
label: "\u6570\u636E\u63A8\u9001\u5931\u8D25",
|
|
608
|
+
group: "\u6570\u636E",
|
|
609
|
+
step: "\u6570\u636E\u63A8\u9001",
|
|
610
|
+
status: "\u5931\u8D25",
|
|
611
|
+
level: "error",
|
|
612
|
+
attention: "high",
|
|
613
|
+
buildDetails: (error) => [error ? `err=${toErrorMessage(error)}` : ""]
|
|
614
|
+
}
|
|
615
|
+
];
|
|
616
|
+
var buildLogTag = (key) => `${LOG_TAG_PREFIX}${key}${LOG_TAG_SUFFIX}`;
|
|
617
|
+
var escapeRegExp = (value) => String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
618
|
+
var buildStepPattern = (step, status) => {
|
|
619
|
+
if (!step) return null;
|
|
620
|
+
let pattern = `${STEP_PREFIX} .*${escapeRegExp(step)}`;
|
|
621
|
+
if (status) pattern += `.*${escapeRegExp(status)}`;
|
|
622
|
+
return new RegExp(pattern);
|
|
623
|
+
};
|
|
624
|
+
var LOG_TEMPLATES = Object.freeze(LOG_DEFINITIONS.map((definition) => {
|
|
625
|
+
const attention = definition.attention || "medium";
|
|
626
|
+
const attentionRank = ATTENTION_RANK[attention] || ATTENTION_RANK.medium;
|
|
627
|
+
const patterns = [new RegExp(`\\[#log:${escapeRegExp(definition.key)}\\]`)];
|
|
628
|
+
const fallback = buildStepPattern(definition.step, definition.status);
|
|
629
|
+
if (fallback) patterns.push(fallback);
|
|
630
|
+
return {
|
|
631
|
+
key: definition.key,
|
|
632
|
+
label: definition.label,
|
|
633
|
+
group: definition.group,
|
|
634
|
+
attention,
|
|
635
|
+
patterns,
|
|
636
|
+
defaultSelected: attentionRank >= DEFAULT_ATTENTION_RANK
|
|
637
|
+
};
|
|
638
|
+
}));
|
|
639
|
+
var Logger = {
|
|
640
|
+
setLogger(logger) {
|
|
641
|
+
activeLogger = logger || defaultLogger;
|
|
642
|
+
},
|
|
643
|
+
createLogger(scope) {
|
|
644
|
+
const prefix = scope ? String(scope) : "";
|
|
645
|
+
return {
|
|
646
|
+
start: (message, detail) => createBaseLogger(prefix).start(formatMessage(message, detail)),
|
|
647
|
+
success: (message, detail) => createBaseLogger(prefix).success(formatMessage(message, detail)),
|
|
648
|
+
fail: (message, error) => createBaseLogger(prefix).error(formatMessage(message, (error == null ? void 0 : error.message) || error)),
|
|
649
|
+
warn: (message, detail) => createBaseLogger(prefix).warning(formatMessage(message, detail)),
|
|
650
|
+
warning: (message, detail) => createBaseLogger(prefix).warning(formatMessage(message, detail)),
|
|
651
|
+
info: (message, detail) => createBaseLogger(prefix).info(formatMessage(message, detail)),
|
|
652
|
+
debug: (message, detail) => createBaseLogger(prefix).debug(formatMessage(message, detail)),
|
|
653
|
+
useTemplate: () => createTemplateLogger(createBaseLogger(prefix))
|
|
654
|
+
};
|
|
655
|
+
},
|
|
656
|
+
useTemplate(logger) {
|
|
657
|
+
if (logger) return createTemplateLogger(createBaseLogger("", logger));
|
|
658
|
+
return createTemplateLogger(createBaseLogger(""));
|
|
659
|
+
},
|
|
660
|
+
start(message, detail = "") {
|
|
661
|
+
createBaseLogger("").start(formatMessage(message, detail));
|
|
662
|
+
},
|
|
663
|
+
success(message, detail = "") {
|
|
664
|
+
createBaseLogger("").success(formatMessage(message, detail));
|
|
665
|
+
},
|
|
666
|
+
fail(message, error = "") {
|
|
667
|
+
createBaseLogger("").error(formatMessage(message, (error == null ? void 0 : error.message) || error));
|
|
668
|
+
},
|
|
669
|
+
warn(message, detail = "") {
|
|
670
|
+
createBaseLogger("").warning(formatMessage(message, detail));
|
|
671
|
+
},
|
|
672
|
+
warning(message, detail = "") {
|
|
673
|
+
Logger.warn(message, detail);
|
|
674
|
+
},
|
|
675
|
+
error(message, detail = "") {
|
|
676
|
+
createBaseLogger("").error(formatMessage(message, detail));
|
|
677
|
+
},
|
|
678
|
+
info(message, detail = "") {
|
|
679
|
+
createBaseLogger("").info(formatMessage(message, detail));
|
|
680
|
+
},
|
|
681
|
+
debug(message, detail = "") {
|
|
682
|
+
createBaseLogger("").debug(formatMessage(message, detail));
|
|
683
|
+
},
|
|
684
|
+
duration(startedAt) {
|
|
685
|
+
return `${((Date.now() - startedAt) / 1e3).toFixed(2)}s`;
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
function stripAnsi(value) {
|
|
689
|
+
return String(value || "").replace(/\u001b\[[0-9;]*m/g, "");
|
|
690
|
+
}
|
|
691
|
+
function createBaseLogger(prefix = "", explicitLogger = null) {
|
|
692
|
+
const name = prefix ? String(prefix) : "";
|
|
693
|
+
const dispatch = (methodName, icon, message, color) => {
|
|
694
|
+
const timestamp = colorize(`[${formatTimestamp()}]`, ANSI.gray);
|
|
695
|
+
const line = formatLine(name, icon, message);
|
|
696
|
+
const coloredLine = colorize(line, color);
|
|
697
|
+
const writer = resolveLogMethod(resolveLogger(explicitLogger), methodName);
|
|
698
|
+
writer(`${timestamp} ${coloredLine}`.trim());
|
|
699
|
+
};
|
|
700
|
+
return {
|
|
701
|
+
info: (message) => dispatch("info", "\u{1F4D6}", message, ANSI.cyan),
|
|
702
|
+
success: (message) => dispatch("info", "\u2705", message, ANSI.green),
|
|
703
|
+
warning: (message) => dispatch("warning", "\u26A0\uFE0F", message, ANSI.yellow),
|
|
704
|
+
warn: (message) => dispatch("warning", "\u26A0\uFE0F", message, ANSI.yellow),
|
|
705
|
+
error: (message) => dispatch("error", "\u274C", message, ANSI.red),
|
|
706
|
+
debug: (message) => dispatch("debug", "\u{1F539}", message, ANSI.gray),
|
|
707
|
+
start: (message) => dispatch("info", "\u{1F537}", message, ANSI.blue)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function createTemplateLogger(baseLogger) {
|
|
711
|
+
const handlers = {
|
|
712
|
+
info: (line) => baseLogger.info(line),
|
|
713
|
+
success: (line) => baseLogger.success(line),
|
|
714
|
+
warning: (line) => baseLogger.warning(line),
|
|
715
|
+
warn: (line) => baseLogger.warning(line),
|
|
716
|
+
error: (line) => baseLogger.error(line),
|
|
717
|
+
debug: (line) => baseLogger.debug(line),
|
|
718
|
+
start: (line) => baseLogger.start(line)
|
|
719
|
+
};
|
|
720
|
+
const emitDefinition = (definition, details = []) => {
|
|
721
|
+
const handler = handlers[definition.level] || handlers.info;
|
|
722
|
+
handler(buildStepLine(definition.step, definition.status, [...details, buildLogTag(definition.key)]));
|
|
723
|
+
};
|
|
724
|
+
const definitionMethods = {};
|
|
725
|
+
for (const definition of LOG_DEFINITIONS) {
|
|
726
|
+
if (!definition.method) continue;
|
|
727
|
+
definitionMethods[definition.method] = (...args) => {
|
|
728
|
+
const details = definition.buildDetails ? definition.buildDetails(...args) : [];
|
|
729
|
+
emitDefinition(definition, details.filter(Boolean));
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
return {
|
|
733
|
+
step: (step, status, details, level = "info") => {
|
|
734
|
+
const handler = handlers[level] || handlers.info;
|
|
735
|
+
handler(buildStepLine(step, status, detailToParts(details)));
|
|
736
|
+
},
|
|
737
|
+
info: (message, detail) => baseLogger.info(formatMessage(message, detail)),
|
|
738
|
+
success: (message, detail) => baseLogger.success(formatMessage(message, detail)),
|
|
739
|
+
warning: (message, detail) => baseLogger.warning(formatMessage(message, detail)),
|
|
740
|
+
warn: (message, detail) => baseLogger.warning(formatMessage(message, detail)),
|
|
741
|
+
error: (message, detail) => baseLogger.error(formatMessage(message, detail)),
|
|
742
|
+
debug: (message, detail) => baseLogger.debug(formatMessage(message, detail)),
|
|
743
|
+
start: (message, detail) => baseLogger.start(formatMessage(message, detail)),
|
|
744
|
+
...definitionMethods
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function buildStepLine(step, status, details = []) {
|
|
748
|
+
const parts = [];
|
|
749
|
+
const decoratedStep = step ? decorateLabel(step, STEP_ICONS) : "";
|
|
750
|
+
parts.push(decoratedStep ? `${STEP_PREFIX} ${decoratedStep}` : STEP_PREFIX);
|
|
751
|
+
if (status) parts.push(decorateLabel(status, STATUS_ICONS));
|
|
752
|
+
const detailParts = details.flatMap(detailToParts).filter(Boolean);
|
|
753
|
+
parts.push(...detailParts);
|
|
754
|
+
return parts.join(STEP_SEPARATOR);
|
|
755
|
+
}
|
|
756
|
+
function decorateLabel(label, mappings) {
|
|
757
|
+
if (!label) return "";
|
|
758
|
+
const mapping = mappings.find((item) => String(label).includes(item.match));
|
|
759
|
+
if (!mapping) return label;
|
|
760
|
+
return `${mapping.icon} ${label}`;
|
|
761
|
+
}
|
|
762
|
+
function resolveLogger(explicitLogger) {
|
|
763
|
+
if (explicitLogger && typeof explicitLogger.info === "function") return explicitLogger;
|
|
764
|
+
return activeLogger || defaultLogger;
|
|
765
|
+
}
|
|
766
|
+
function resolveLogMethod(logger, name) {
|
|
767
|
+
if (logger && typeof logger[name] === "function") return logger[name].bind(logger);
|
|
768
|
+
if (name === "warning" && logger && typeof logger.warn === "function") return logger.warn.bind(logger);
|
|
769
|
+
return defaultLogger[name] || defaultLogger.info;
|
|
770
|
+
}
|
|
771
|
+
function formatLine(prefix, icon, message) {
|
|
772
|
+
const parts = [];
|
|
773
|
+
if (prefix) parts.push(`[${prefix}]`);
|
|
774
|
+
if (icon) parts.push(icon);
|
|
775
|
+
if (message) parts.push(message);
|
|
776
|
+
return parts.join(" ").trim();
|
|
777
|
+
}
|
|
778
|
+
function formatMessage(message, detail = "") {
|
|
779
|
+
const detailText = formatDetail(detail);
|
|
780
|
+
return detailText ? `${message} ${detailText}` : String(message || "");
|
|
781
|
+
}
|
|
782
|
+
function formatTimestamp(date = /* @__PURE__ */ new Date()) {
|
|
783
|
+
const pad = (value, size = 2) => String(value).padStart(size, "0");
|
|
784
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`;
|
|
785
|
+
}
|
|
786
|
+
function formatDetail(detail) {
|
|
787
|
+
return detailToParts(detail).join(" ");
|
|
788
|
+
}
|
|
789
|
+
function colorize(text, color) {
|
|
790
|
+
if (!text || !color) return text;
|
|
791
|
+
return `${color}${text}${ANSI.reset}`;
|
|
792
|
+
}
|
|
793
|
+
function safeJson(value) {
|
|
794
|
+
try {
|
|
795
|
+
return JSON.stringify(value);
|
|
796
|
+
} catch {
|
|
797
|
+
return String(value);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// entrys/browser.js
|
|
802
|
+
var ToolkitMode = Object.freeze({
|
|
803
|
+
default: "default"
|
|
804
|
+
});
|
|
805
|
+
var useAndroidToolKit = () => {
|
|
806
|
+
return {
|
|
807
|
+
Constants: constants_exports,
|
|
808
|
+
Errors: errors_exports,
|
|
809
|
+
Logger,
|
|
810
|
+
LOG_TEMPLATES,
|
|
811
|
+
$Internals: { LOG_TEMPLATES, stripAnsi }
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
useAndroidToolKit.Mode = ToolkitMode;
|
|
815
|
+
export {
|
|
816
|
+
useAndroidToolKit
|
|
817
|
+
};
|
|
818
|
+
//# sourceMappingURL=browser.js.map
|