@xysfe/bug-tap 0.0.0-stage → 0.1.0
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 +69 -0
- package/LICENSE +21 -0
- package/README.md +461 -2
- package/THIRD_PARTY_NOTICES.md +39 -0
- package/dist/bug-tap-screenshot.min.js +10 -0
- package/dist/bug-tap-screenshot.min.js.map +1 -0
- package/dist/bug-tap-vue.cjs +2 -0
- package/dist/bug-tap-vue.cjs.map +1 -0
- package/dist/bug-tap-vue.js +106 -0
- package/dist/bug-tap-vue.js.map +1 -0
- package/dist/bug-tap-vue.min.js +2 -0
- package/dist/bug-tap-vue.min.js.map +1 -0
- package/dist/bug-tap.cjs +2 -0
- package/dist/bug-tap.cjs.map +1 -0
- package/dist/bug-tap.js +13 -0
- package/dist/bug-tap.js.map +1 -0
- package/dist/bug-tap.min.js +508 -0
- package/dist/bug-tap.min.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/core/body.d.ts +30 -0
- package/dist/core/breadcrumbs.d.ts +85 -0
- package/dist/core/browser-api-errors.d.ts +55 -0
- package/dist/core/byte-buffer.d.ts +43 -0
- package/dist/core/collector.d.ts +34 -0
- package/dist/core/console-collector.d.ts +23 -0
- package/dist/core/env-collector.d.ts +16 -0
- package/dist/core/error-collector.d.ts +48 -0
- package/dist/core/error-noise.d.ts +43 -0
- package/dist/core/network-collector.d.ts +97 -0
- package/dist/core/network-record.d.ts +19 -0
- package/dist/core/resource-timing.d.ts +28 -0
- package/dist/core/ring-buffer.d.ts +22 -0
- package/dist/core/selector.d.ts +3 -0
- package/dist/core/serialize.d.ts +5 -0
- package/dist/core/tongji.d.ts +14 -0
- package/dist/core/user.d.ts +9 -0
- package/dist/index-BBRuTNvo.js +4685 -0
- package/dist/index-BBRuTNvo.js.map +1 -0
- package/dist/index-DCLLRJxX.cjs +488 -0
- package/dist/index-DCLLRJxX.cjs.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/integrations.d.ts +26 -0
- package/dist/panel-mount-Dia21VuZ.cjs +2 -0
- package/dist/panel-mount-Dia21VuZ.cjs.map +1 -0
- package/dist/panel-mount-mAOg572s.js +499 -0
- package/dist/panel-mount-mAOg572s.js.map +1 -0
- package/dist/screenshot-global.d.ts +14 -0
- package/dist/sdk.d.ts +76 -0
- package/dist/transport/log-item.d.ts +2 -0
- package/dist/transport/offline-queue.d.ts +48 -0
- package/dist/transport/payload.d.ts +15 -0
- package/dist/transport/transport.d.ts +57 -0
- package/dist/transport/upload.d.ts +8 -0
- package/dist/types.d.ts +459 -0
- package/dist/ui/element-picker.d.ts +51 -0
- package/dist/ui/floating-button.d.ts +43 -0
- package/dist/ui/icons.d.ts +1 -0
- package/dist/ui/panel-mount.d.ts +20 -0
- package/dist/ui/panel.vue.d.ts +15 -0
- package/dist/ui/screenshot-loader-shared.d.ts +2 -0
- package/dist/ui/screenshot-loader.d.ts +14 -0
- package/dist/ui/screenshot-loader.iife.d.ts +16 -0
- package/dist/ui/screenshot.d.ts +20 -0
- package/dist/ui/shadow-host.d.ts +16 -0
- package/dist/ui/styles.css.d.ts +1 -0
- package/dist/ui/visibility.d.ts +25 -0
- package/dist/utils/match.d.ts +2 -0
- package/dist/utils/ua.d.ts +6 -0
- package/dist/utils/url.d.ts +2 -0
- package/dist/vue-global.d.ts +21 -0
- package/dist/vue.d.ts +49 -0
- package/docs/api.md +257 -0
- package/docs/backend-api.md +401 -0
- package/docs/bundler.md +122 -0
- package/docs/config.md +396 -0
- package/package.json +97 -4
|
@@ -0,0 +1,4685 @@
|
|
|
1
|
+
import { getCssSelector as kr } from "css-selector-generator";
|
|
2
|
+
/*! @xysfe/bug-tap v0.1.0 | MIT */
|
|
3
|
+
const Z = [
|
|
4
|
+
"x-request-id",
|
|
5
|
+
"x-trace-id",
|
|
6
|
+
"traceparent",
|
|
7
|
+
"tracestate",
|
|
8
|
+
"x-b3-traceid",
|
|
9
|
+
"x-b3-spanid",
|
|
10
|
+
"server-timing",
|
|
11
|
+
"content-length"
|
|
12
|
+
];
|
|
13
|
+
function _(e, t) {
|
|
14
|
+
try {
|
|
15
|
+
return e instanceof RegExp ? (e.lastIndex = 0, e.test(t)) : t.includes(e);
|
|
16
|
+
} catch (r) {
|
|
17
|
+
return !1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const Cr = [
|
|
21
|
+
// 跨域脚本的不可读错误,浏览器硬编码,大概率无 stack
|
|
22
|
+
/^Script error\.?$/,
|
|
23
|
+
/^Javascript error: Script error\.? on line 0$/,
|
|
24
|
+
// ResizeObserver 回调超时的浏览器噪音,不代表页面真的出错
|
|
25
|
+
/^ResizeObserver loop completed with undelivered notifications\.$/,
|
|
26
|
+
// GTM + 广告拦截器组合触发
|
|
27
|
+
/^Cannot redefine property: googletag$/,
|
|
28
|
+
/can't redefine non-configurable property "solana"/,
|
|
29
|
+
// Google Search App / Facebook Mobile 的 WebView 注入错误
|
|
30
|
+
/^Can't find variable: gmo$/,
|
|
31
|
+
/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,
|
|
32
|
+
/vv\(\)\.getRestrictions is not a function/,
|
|
33
|
+
/Can't find variable: _AutofillCallbackHandler/,
|
|
34
|
+
// CEFSharp(.NET 内嵌 Chromium) 的不可行动错误
|
|
35
|
+
/Object Not Found Matching Id:\d+, MethodName:simulateEvent/
|
|
36
|
+
], er = /^(?:<anonymous>|\[native code\]|data:|blob:|about:|chrome-extension:|moz-extension:)/i, Lr = /\bat\s+(?:.*?\s+\()?([^\s()]+):(\d+):(\d+)\)?\s*$/;
|
|
37
|
+
function Ct(e) {
|
|
38
|
+
if (e)
|
|
39
|
+
for (const t of e.split(`
|
|
40
|
+
`)) {
|
|
41
|
+
const r = Lr.exec(t);
|
|
42
|
+
if (!r) continue;
|
|
43
|
+
const i = r[1];
|
|
44
|
+
if (!i || er.test(i)) continue;
|
|
45
|
+
const n = Number(r[2]), s = Number(r[3]);
|
|
46
|
+
return {
|
|
47
|
+
url: i,
|
|
48
|
+
line: Number.isFinite(n) && n > 0 ? n : void 0,
|
|
49
|
+
column: Number.isFinite(s) && s >= 0 ? s : void 0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function Rr(e, t) {
|
|
54
|
+
const r = Ct(e);
|
|
55
|
+
if (r) return r.url;
|
|
56
|
+
if (t && !er.test(t)) return t;
|
|
57
|
+
}
|
|
58
|
+
const Tr = /^\[(?:setTimeout|setInterval|requestAnimationFrame)\] /, Mr = /^[A-Za-z]*Error: /;
|
|
59
|
+
function Ar(e) {
|
|
60
|
+
const t = /* @__PURE__ */ new Set([e]), r = e.replace(Tr, "");
|
|
61
|
+
t.add(r);
|
|
62
|
+
const i = r.replace(Mr, "");
|
|
63
|
+
return t.add(i), Array.from(t);
|
|
64
|
+
}
|
|
65
|
+
function Pr(e, t) {
|
|
66
|
+
return Ar(e).some(
|
|
67
|
+
(r) => t.some((i) => _(i, r))
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function Br(e) {
|
|
71
|
+
const t = (e.message || "").trim(), r = (e.stack || "").trim();
|
|
72
|
+
return t.length === 0 && r.length === 0;
|
|
73
|
+
}
|
|
74
|
+
function Ir(e, t, r) {
|
|
75
|
+
return !(t.length > 0 && (!e || !t.some((i) => _(i, e))) || e && r.some((i) => _(i, e)));
|
|
76
|
+
}
|
|
77
|
+
const $r = /\.(?:js|css|map|png|jpe?g|gif|svg|webp|ico|bmp|woff2?|ttf|eot|otf|mp4|webm|mp3|wav|ogg|avi|mov|zip|gz|pdf)(?:[?#]|$)/i, Or = [$r], ke = "/go/SupportTools/logreport", Ce = "/platform/file/uploadPicture", Le = "1008";
|
|
78
|
+
function _r(e) {
|
|
79
|
+
return (String(e != null ? e : "").trim() || ke).replace(/\/+$/, "") || ke;
|
|
80
|
+
}
|
|
81
|
+
function bt(e) {
|
|
82
|
+
return Object.prototype.toString.call(e) === "[object Object]";
|
|
83
|
+
}
|
|
84
|
+
function rr(e) {
|
|
85
|
+
if (typeof e == "function") return e;
|
|
86
|
+
if (!bt(e)) return;
|
|
87
|
+
const t = {};
|
|
88
|
+
for (const r of Object.keys(e)) {
|
|
89
|
+
const i = e[r], n = typeof i;
|
|
90
|
+
(n === "string" || n === "number" || n === "boolean") && (t[r] = i);
|
|
91
|
+
}
|
|
92
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
93
|
+
}
|
|
94
|
+
function y(e, t, r, i) {
|
|
95
|
+
return Math.round(nr(e, t, r, i));
|
|
96
|
+
}
|
|
97
|
+
function Hr(e) {
|
|
98
|
+
const t = String(e.release || "").trim();
|
|
99
|
+
if (t) return t;
|
|
100
|
+
const r = String(e.appVersion || "").trim(), i = String(e.buildId || "").trim();
|
|
101
|
+
return r && i ? `${r}+${i}` : r || i;
|
|
102
|
+
}
|
|
103
|
+
function ir(e) {
|
|
104
|
+
return e === !0 ? !0 : Array.isArray(e) ? Array.from(
|
|
105
|
+
new Set(
|
|
106
|
+
e.map((t) => String(t || "").trim().toLowerCase()).filter((t) => t.length > 0)
|
|
107
|
+
)
|
|
108
|
+
) : [];
|
|
109
|
+
}
|
|
110
|
+
function Ur(e) {
|
|
111
|
+
if (e === !0) return !0;
|
|
112
|
+
const t = ir(e);
|
|
113
|
+
return Array.from(
|
|
114
|
+
/* @__PURE__ */ new Set([...Z, "content-type", ...t])
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function nr(e, t, r, i) {
|
|
118
|
+
const n = typeof e == "number" ? e : Number(e);
|
|
119
|
+
return Number.isFinite(n) ? Math.min(r, Math.max(t, n)) : i;
|
|
120
|
+
}
|
|
121
|
+
function sr(e, t) {
|
|
122
|
+
if (!bt(e) || !bt(t))
|
|
123
|
+
return t === void 0 ? e : t;
|
|
124
|
+
const r = { ...e };
|
|
125
|
+
for (const i of Object.keys(t))
|
|
126
|
+
r[i] = sr(e[i], t[i]);
|
|
127
|
+
return r;
|
|
128
|
+
}
|
|
129
|
+
function jr(e, t) {
|
|
130
|
+
return sr(e, t || {});
|
|
131
|
+
}
|
|
132
|
+
function it(e) {
|
|
133
|
+
var o, a, c, l, h, u, d, p, g, b, m, I, q, Tt, Mt, At, Pt, Bt, It, $t, Ot, _t, Ht, Ut, jt, zt, Dt, Nt, qt, Ft, Wt, Xt, Vt, Yt, Kt, Gt, Jt, Qt, Zt, te, ee, re, ie, ne, se, oe, ae, ce, le, he, ue, de, fe, pe, ge, me, be, ye, we, ve, xe, Ee, Se;
|
|
134
|
+
const t = {
|
|
135
|
+
excludeUrls: Or.concat(((o = e.privacy) == null ? void 0 : o.excludeUrls) || []),
|
|
136
|
+
excludeConsolePatterns: (((a = e.privacy) == null ? void 0 : a.excludeConsolePatterns) || []).slice(),
|
|
137
|
+
excludeBreadcrumbUrls: (((c = e.privacy) == null ? void 0 : c.excludeBreadcrumbUrls) || []).slice()
|
|
138
|
+
}, r = e.filtering || {}, i = {
|
|
139
|
+
ignoreErrors: (r.ignoreErrors || []).slice().concat(
|
|
140
|
+
r.disableErrorDefaults ? [] : Cr
|
|
141
|
+
),
|
|
142
|
+
denyUrls: (r.denyUrls || []).slice(),
|
|
143
|
+
allowUrls: (r.allowUrls || []).slice()
|
|
144
|
+
}, n = e.hooks || {}, s = {
|
|
145
|
+
beforeSend: typeof n.beforeSend == "function" ? n.beforeSend : void 0,
|
|
146
|
+
beforeBreadcrumb: typeof n.beforeBreadcrumb == "function" ? n.beforeBreadcrumb : void 0
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
project: String(e.project || "").trim(),
|
|
150
|
+
endpoint: _r(e.endpoint),
|
|
151
|
+
environment: String(e.environment || "production").trim() || "production",
|
|
152
|
+
// 业务构建标识:生产包是压缩产物,没有它就映射不回源码行号
|
|
153
|
+
appVersion: String(e.appVersion || "").trim(),
|
|
154
|
+
buildId: String(e.buildId || "").trim(),
|
|
155
|
+
release: Hr(e),
|
|
156
|
+
debug: e.debug === !0,
|
|
157
|
+
user: rr(e.user),
|
|
158
|
+
reporter: {
|
|
159
|
+
enabled: ((l = e.reporter) == null ? void 0 : l.enabled) !== !1,
|
|
160
|
+
position: ((h = e.reporter) == null ? void 0 : h.position) === "bottom-left" ? "bottom-left" : "bottom-right",
|
|
161
|
+
theme: ((u = e.reporter) == null ? void 0 : u.theme) === "light" || ((d = e.reporter) == null ? void 0 : d.theme) === "dark" ? e.reporter.theme : "auto",
|
|
162
|
+
text: String(((p = e.reporter) == null ? void 0 : p.text) || "反馈").slice(0, 20),
|
|
163
|
+
zIndex: y((g = e.reporter) == null ? void 0 : g.zIndex, 1, 2147483647, 2147483e3),
|
|
164
|
+
visibility: {
|
|
165
|
+
mode: ((m = (b = e.reporter) == null ? void 0 : b.visibility) == null ? void 0 : m.mode) === "triggered" ? "triggered" : "always",
|
|
166
|
+
queryParam: String(((q = (I = e.reporter) == null ? void 0 : I.visibility) == null ? void 0 : q.queryParam) || "bugtap").trim(),
|
|
167
|
+
queryValue: ((Mt = (Tt = e.reporter) == null ? void 0 : Tt.visibility) == null ? void 0 : Mt.queryValue) === void 0 ? "1" : String(e.reporter.visibility.queryValue),
|
|
168
|
+
closable: ((Pt = (At = e.reporter) == null ? void 0 : At.visibility) == null ? void 0 : Pt.closable) !== !1
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
collect: {
|
|
172
|
+
console: ((Bt = e.collect) == null ? void 0 : Bt.console) !== !1,
|
|
173
|
+
error: ((It = e.collect) == null ? void 0 : It.error) !== !1,
|
|
174
|
+
network: (($t = e.collect) == null ? void 0 : $t.network) !== !1,
|
|
175
|
+
networkBody: ((Ot = e.collect) == null ? void 0 : Ot.networkBody) !== !1,
|
|
176
|
+
// 长连接与资源错误默认开启:这两类问题在没有网络记录时几乎无法定位
|
|
177
|
+
realtime: ((_t = e.collect) == null ? void 0 : _t.realtime) !== !1,
|
|
178
|
+
resourceErrors: ((Ht = e.collect) == null ? void 0 : Ht.resourceErrors) !== !1,
|
|
179
|
+
environment: ((Ut = e.collect) == null ? void 0 : Ut.environment) !== !1,
|
|
180
|
+
trackIds: ((jt = e.collect) == null ? void 0 : jt.trackIds) !== !1,
|
|
181
|
+
breadcrumbs: ((zt = e.collect) == null ? void 0 : zt.breadcrumbs) !== !1,
|
|
182
|
+
// 与 Sentry(默认 100)和 Rollbar(上限 100)对齐,Bugsnag 取 25 偏小
|
|
183
|
+
maxBreadcrumbs: y((Dt = e.collect) == null ? void 0 : Dt.maxBreadcrumbs, 1, 200, 100),
|
|
184
|
+
maxConsoleLogs: y((Nt = e.collect) == null ? void 0 : Nt.maxConsoleLogs, 1, 500, 100),
|
|
185
|
+
maxNetworkRecords: y((qt = e.collect) == null ? void 0 : qt.maxNetworkRecords, 1, 500, 200),
|
|
186
|
+
maxErrors: y((Ft = e.collect) == null ? void 0 : Ft.maxErrors, 1, 200, 50),
|
|
187
|
+
// 默认 512KB:够放下 200 条普通接口,或几十条带完整 body 的请求
|
|
188
|
+
maxNetworkBytes: y((Wt = e.collect) == null ? void 0 : Wt.maxNetworkBytes, 8192, 8e6, 524288),
|
|
189
|
+
maxCloneBytes: y((Xt = e.collect) == null ? void 0 : Xt.maxCloneBytes, 1024, 5e6, 262144),
|
|
190
|
+
// 默认不采请求头;显式配置 authorization / x-tenant-id 等才记录
|
|
191
|
+
requestHeaders: ir((Vt = e.collect) == null ? void 0 : Vt.requestHeaders),
|
|
192
|
+
// 响应头默认只保留 trace 白名单,可追加;true 表示全部可读头
|
|
193
|
+
responseHeaders: Ur((Yt = e.collect) == null ? void 0 : Yt.responseHeaders),
|
|
194
|
+
// 元素快照带 attributes / text / path,默认只留最近的 5 个,避免撑爆 ext
|
|
195
|
+
maxElements: y((Kt = e.collect) == null ? void 0 : Kt.maxElements, 1, 20, 5),
|
|
196
|
+
// 包装 EventTarget 对全页监听器都有开销,允许大型页面关掉
|
|
197
|
+
eventListenerErrors: ((Gt = e.collect) == null ? void 0 : Gt.eventListenerErrors) !== !1
|
|
198
|
+
},
|
|
199
|
+
privacy: t,
|
|
200
|
+
filtering: i,
|
|
201
|
+
hooks: s,
|
|
202
|
+
screenshot: {
|
|
203
|
+
enabled: ((Jt = e.screenshot) == null ? void 0 : Jt.enabled) !== !1,
|
|
204
|
+
auto: ((Qt = e.screenshot) == null ? void 0 : Qt.auto) !== !1,
|
|
205
|
+
quality: nr((Zt = e.screenshot) == null ? void 0 : Zt.quality, 0.1, 1, 0.8),
|
|
206
|
+
maxWidth: y((te = e.screenshot) == null ? void 0 : te.maxWidth, 320, 4096, 1600),
|
|
207
|
+
maxSizeKB: y((ee = e.screenshot) == null ? void 0 : ee.maxSizeKB, 50, 2048, 400),
|
|
208
|
+
// 空字符串表示「与主包同目录」,由 screenshot-loader.iife.ts 推断
|
|
209
|
+
scriptUrl: String(((re = e.screenshot) == null ? void 0 : re.scriptUrl) || "").trim()
|
|
210
|
+
},
|
|
211
|
+
transport: {
|
|
212
|
+
timeoutMs: y((ie = e.transport) == null ? void 0 : ie.timeoutMs, 1e3, 6e4, 15e3),
|
|
213
|
+
retries: y((ne = e.transport) == null ? void 0 : ne.retries, 0, 5, 2),
|
|
214
|
+
headers: { ...((se = e.transport) == null ? void 0 : se.headers) || {} },
|
|
215
|
+
maxItemBytes: y((oe = e.transport) == null ? void 0 : oe.maxItemBytes, 5e4, 5e6, 8e5),
|
|
216
|
+
// 用户点提交后最长等待时间(含重试与退避),避免「一直转圈」
|
|
217
|
+
totalTimeoutMs: y((ae = e.transport) == null ? void 0 : ae.totalTimeoutMs, 3e3, 6e4, 3e4),
|
|
218
|
+
maxConcurrent: y((ce = e.transport) == null ? void 0 : ce.maxConcurrent, 1, 50, 10),
|
|
219
|
+
// 只在显式配置为 1 / 2 / 3 时生效,其余按 severity 映射
|
|
220
|
+
logLevel: ((le = e.transport) == null ? void 0 : le.logLevel) === 1 || ((he = e.transport) == null ? void 0 : he.logLevel) === 2 || ((ue = e.transport) == null ? void 0 : ue.logLevel) === 3 ? e.transport.logLevel : void 0,
|
|
221
|
+
offline: {
|
|
222
|
+
enabled: ((fe = (de = e.transport) == null ? void 0 : de.offline) == null ? void 0 : fe.enabled) !== !1,
|
|
223
|
+
// 默认保留 24 小时:跨天再打开页面仍能补发
|
|
224
|
+
ttlMs: y((ge = (pe = e.transport) == null ? void 0 : pe.offline) == null ? void 0 : ge.ttlMs, 6e4, 168 * 36e5, 24 * 36e5),
|
|
225
|
+
maxItems: y((be = (me = e.transport) == null ? void 0 : me.offline) == null ? void 0 : be.maxItems, 1, 100, 20)
|
|
226
|
+
},
|
|
227
|
+
// 0 表示不限制
|
|
228
|
+
maxReportsPerSession: y((ye = e.transport) == null ? void 0 : ye.maxReportsPerSession, 0, 1e3, 0)
|
|
229
|
+
},
|
|
230
|
+
upload: {
|
|
231
|
+
enabled: ((we = e.upload) == null ? void 0 : we.enabled) !== !1,
|
|
232
|
+
url: String(((ve = e.upload) == null ? void 0 : ve.url) || Ce).trim() || Ce,
|
|
233
|
+
// 上传接口必须带业务类型,未显式配置时用默认值 1008
|
|
234
|
+
bizId: String((Ee = (xe = e.upload) == null ? void 0 : xe.bizId) != null ? Ee : Le).trim() || Le,
|
|
235
|
+
timeoutMs: y((Se = e.upload) == null ? void 0 : Se.timeoutMs, 1e3, 12e4, 3e4)
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function yt(e) {
|
|
240
|
+
const t = [];
|
|
241
|
+
if (!e || typeof e != "object")
|
|
242
|
+
return t.push("配置不是对象"), t;
|
|
243
|
+
if ((!e.project || typeof e.project != "string") && t.push("缺少 project"), e.endpoint !== void 0 && e.endpoint !== null && String(e.endpoint).trim() !== "")
|
|
244
|
+
try {
|
|
245
|
+
const r = new URL(e.endpoint, location.href);
|
|
246
|
+
r.protocol !== "http:" && r.protocol !== "https:" && t.push("endpoint 必须是 http/https 地址");
|
|
247
|
+
} catch (r) {
|
|
248
|
+
t.push("endpoint 不是合法 URL");
|
|
249
|
+
}
|
|
250
|
+
return t;
|
|
251
|
+
}
|
|
252
|
+
class Lt {
|
|
253
|
+
constructor(t) {
|
|
254
|
+
this.start = 0, this.length = 0, this.evicted = 0, this.capacity = Math.max(1, Math.floor(t)), this.items = new Array(this.capacity);
|
|
255
|
+
}
|
|
256
|
+
get size() {
|
|
257
|
+
return this.length;
|
|
258
|
+
}
|
|
259
|
+
// 缓冲区容量:调用方据此判断「是否可能还有更早的记录被丢掉」
|
|
260
|
+
get limit() {
|
|
261
|
+
return this.capacity;
|
|
262
|
+
}
|
|
263
|
+
// 因容量满被挤掉的条数
|
|
264
|
+
get droppedCount() {
|
|
265
|
+
return this.evicted;
|
|
266
|
+
}
|
|
267
|
+
push(t) {
|
|
268
|
+
if (this.length < this.capacity) {
|
|
269
|
+
this.items[(this.start + this.length) % this.capacity] = t, this.length += 1;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this.items[this.start] = t, this.start = (this.start + 1) % this.capacity, this.evicted += 1;
|
|
273
|
+
}
|
|
274
|
+
// 读最后一条而不物化整个数组:面包屑在每次请求 / 点击时都要看尾部
|
|
275
|
+
last() {
|
|
276
|
+
if (this.length !== 0)
|
|
277
|
+
return this.items[(this.start + this.length - 1) % this.capacity];
|
|
278
|
+
}
|
|
279
|
+
toArray() {
|
|
280
|
+
const t = [];
|
|
281
|
+
for (let r = 0; r < this.length; r += 1) {
|
|
282
|
+
const i = this.items[(this.start + r) % this.capacity];
|
|
283
|
+
i !== void 0 && t.push(i);
|
|
284
|
+
}
|
|
285
|
+
return t;
|
|
286
|
+
}
|
|
287
|
+
// 判断某条记录是否仍在缓冲区里(可能已被新记录挤出)
|
|
288
|
+
includes(t) {
|
|
289
|
+
for (let r = 0; r < this.length; r += 1)
|
|
290
|
+
if (this.items[(this.start + r) % this.capacity] === t) return !0;
|
|
291
|
+
return !1;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 原地更新第一条命中的记录,保持它在时间线上的位置。
|
|
295
|
+
* 用于把重复事件折叠成一条(如轮询请求),而不是让它挤掉用户操作。
|
|
296
|
+
*/
|
|
297
|
+
update(t, r) {
|
|
298
|
+
for (let i = 0; i < this.length; i += 1) {
|
|
299
|
+
const n = (this.start + i) % this.capacity, s = this.items[n];
|
|
300
|
+
if (s !== void 0 && t(s))
|
|
301
|
+
return this.items[n] = r(s), !0;
|
|
302
|
+
}
|
|
303
|
+
return !1;
|
|
304
|
+
}
|
|
305
|
+
// 原地更新最后一条:折叠轮询请求时目标永远在尾部,无需线性扫描
|
|
306
|
+
updateLast(t) {
|
|
307
|
+
if (this.length === 0) return !1;
|
|
308
|
+
const r = (this.start + this.length - 1) % this.capacity, i = this.items[r];
|
|
309
|
+
return i === void 0 ? !1 : (this.items[r] = t(i), !0);
|
|
310
|
+
}
|
|
311
|
+
clear() {
|
|
312
|
+
this.items = new Array(this.capacity), this.start = 0, this.length = 0, this.evicted = 0;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function or(e) {
|
|
316
|
+
return e.ok === !1 || !!e.error || (e.status || 0) >= 400;
|
|
317
|
+
}
|
|
318
|
+
function zr(e) {
|
|
319
|
+
return e.ok === !0;
|
|
320
|
+
}
|
|
321
|
+
function ar(e) {
|
|
322
|
+
return e ? e.droppedCount + e.evictedCount + (e.trimmedCount || 0) : 0;
|
|
323
|
+
}
|
|
324
|
+
const Dr = 60, Nr = 40;
|
|
325
|
+
function Re(e) {
|
|
326
|
+
var t, r, i, n;
|
|
327
|
+
try {
|
|
328
|
+
if (!e) return;
|
|
329
|
+
const s = e.tagName ? e.tagName.toLowerCase() : "";
|
|
330
|
+
if (!s) return;
|
|
331
|
+
const o = e.id ? `#${e.id}` : "", a = ((t = e.getAttribute) == null ? void 0 : t.call(e, "data-testid")) || ((r = e.getAttribute) == null ? void 0 : r.call(e, "data-test")) || ((i = e.getAttribute) == null ? void 0 : i.call(e, "data-qa")) || "", c = !o && a ? `[data-testid="${a}"]` : "", l = ((n = e.getAttribute) == null ? void 0 : n.call(e, "name")) || "", h = !o && !c && l ? `[name="${l}"]` : "", u = typeof e.className == "string" ? e.className.trim() : "", d = !o && !c && !h && u ? `.${u.split(/\s+/).slice(0, 2).join(".")}` : "";
|
|
332
|
+
return `${s}${o}${c}${h}${d}`.slice(0, Dr);
|
|
333
|
+
} catch (s) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function qr(e, t = Nr) {
|
|
338
|
+
try {
|
|
339
|
+
const r = ((e == null ? void 0 : e.textContent) || "").replace(/\s+/g, " ").trim();
|
|
340
|
+
return r ? r.slice(0, t) : void 0;
|
|
341
|
+
} catch (r) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function Fr(e) {
|
|
346
|
+
var t;
|
|
347
|
+
try {
|
|
348
|
+
const r = (((t = e == null ? void 0 : e.getAttribute) == null ? void 0 : t.call(e, "type")) || "").toLowerCase();
|
|
349
|
+
return r === "password" || r === "hidden";
|
|
350
|
+
} catch (r) {
|
|
351
|
+
return !0;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function Te(e) {
|
|
355
|
+
var r, i;
|
|
356
|
+
try {
|
|
357
|
+
if (document.documentElement.hasAttribute("data-bug-tap-picking")) return !0;
|
|
358
|
+
} catch (n) {
|
|
359
|
+
}
|
|
360
|
+
let t = e;
|
|
361
|
+
for (; t; )
|
|
362
|
+
try {
|
|
363
|
+
if ((r = t.hasAttribute) != null && r.call(t, "data-bug-tap") || (i = t.hasAttribute) != null && i.call(t, "data-bug-tap-picker"))
|
|
364
|
+
return !0;
|
|
365
|
+
const n = t.getRootNode ? t.getRootNode() : null;
|
|
366
|
+
if (n && n.host) {
|
|
367
|
+
t = n.host;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
t = t.parentElement;
|
|
371
|
+
} catch (n) {
|
|
372
|
+
return !1;
|
|
373
|
+
}
|
|
374
|
+
return !1;
|
|
375
|
+
}
|
|
376
|
+
function nt(e) {
|
|
377
|
+
try {
|
|
378
|
+
const t = new URL(e);
|
|
379
|
+
return `${t.pathname}${t.search}${t.hash}`.slice(0, 300);
|
|
380
|
+
} catch (t) {
|
|
381
|
+
return e.slice(0, 300);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function Wr(e, t) {
|
|
385
|
+
if (e === t) return !0;
|
|
386
|
+
if (!e || !t) return !1;
|
|
387
|
+
try {
|
|
388
|
+
return JSON.stringify(e) === JSON.stringify(t);
|
|
389
|
+
} catch (r) {
|
|
390
|
+
return !1;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
class Xr {
|
|
394
|
+
constructor(t) {
|
|
395
|
+
this.options = t, this.started = !1, this.lastRoute = "", this.lastVisibility = "", this.navigationDisabled = !1, this.tailSignature = "", this.onClick = (r) => {
|
|
396
|
+
if (!(!this.started || !this.options.dom))
|
|
397
|
+
try {
|
|
398
|
+
const i = r.target;
|
|
399
|
+
if (Te(i)) return;
|
|
400
|
+
const n = Re(i);
|
|
401
|
+
if (!n) return;
|
|
402
|
+
this.push({
|
|
403
|
+
t: Date.now(),
|
|
404
|
+
type: "click",
|
|
405
|
+
selector: n,
|
|
406
|
+
text: qr(i)
|
|
407
|
+
});
|
|
408
|
+
} catch (i) {
|
|
409
|
+
}
|
|
410
|
+
}, this.onChange = (r) => {
|
|
411
|
+
if (!(!this.started || !this.options.dom))
|
|
412
|
+
try {
|
|
413
|
+
const i = r.target;
|
|
414
|
+
if (!i || Te(i) || Fr(i)) return;
|
|
415
|
+
const n = Re(i);
|
|
416
|
+
if (!n) return;
|
|
417
|
+
this.push({ t: Date.now(), type: "input", selector: n });
|
|
418
|
+
} catch (i) {
|
|
419
|
+
}
|
|
420
|
+
}, this.onVisibility = () => {
|
|
421
|
+
if (this.started)
|
|
422
|
+
try {
|
|
423
|
+
const r = document.visibilityState;
|
|
424
|
+
if (r === this.lastVisibility) return;
|
|
425
|
+
this.lastVisibility = r, this.push({ t: Date.now(), type: "visibility", state: r });
|
|
426
|
+
} catch (r) {
|
|
427
|
+
}
|
|
428
|
+
}, this.checkRoute = () => {
|
|
429
|
+
if (!(!this.started || !this.options.navigation || this.navigationDisabled))
|
|
430
|
+
try {
|
|
431
|
+
const r = location.href;
|
|
432
|
+
if (r === this.lastRoute) return;
|
|
433
|
+
const i = this.lastRoute;
|
|
434
|
+
this.lastRoute = r, this.push({ t: Date.now(), type: "route", from: nt(i), to: nt(r) });
|
|
435
|
+
} catch (r) {
|
|
436
|
+
}
|
|
437
|
+
}, this.onHistory = () => {
|
|
438
|
+
this.navigationDisabled || setTimeout(this.checkRoute, 0);
|
|
439
|
+
}, this.originalPush = null, this.originalReplace = null, this.wrappedPush = null, this.wrappedReplace = null, this.routeHook = null, this.buffer = new Lt(t.max);
|
|
440
|
+
}
|
|
441
|
+
get limit() {
|
|
442
|
+
return this.buffer.limit;
|
|
443
|
+
}
|
|
444
|
+
// 条数不物化数组,getData 只需要计数时用它
|
|
445
|
+
get size() {
|
|
446
|
+
return this.buffer.size;
|
|
447
|
+
}
|
|
448
|
+
// 因容量满被挤掉的条数:调用方据此判断时间线是否完整
|
|
449
|
+
get evicted() {
|
|
450
|
+
return this.buffer.droppedCount;
|
|
451
|
+
}
|
|
452
|
+
start() {
|
|
453
|
+
if (!this.started) {
|
|
454
|
+
this.started = !0;
|
|
455
|
+
try {
|
|
456
|
+
this.lastRoute = location.href, this.lastVisibility = document.visibilityState;
|
|
457
|
+
} catch (t) {
|
|
458
|
+
}
|
|
459
|
+
this.options.dom && (window.addEventListener("click", this.onClick, !0), window.addEventListener("change", this.onChange, !0)), this.options.navigation && !this.navigationDisabled && (window.addEventListener("popstate", this.checkRoute), window.addEventListener("hashchange", this.checkRoute), window.addEventListener("visibilitychange", this.onVisibility), this.patchHistory());
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
stop() {
|
|
463
|
+
this.started && (this.started = !1, window.removeEventListener("click", this.onClick, !0), window.removeEventListener("change", this.onChange, !0), window.removeEventListener("popstate", this.checkRoute), window.removeEventListener("hashchange", this.checkRoute), window.removeEventListener("visibilitychange", this.onVisibility), this.unpatchHistory());
|
|
464
|
+
}
|
|
465
|
+
getBreadcrumbs() {
|
|
466
|
+
return this.buffer.toArray();
|
|
467
|
+
}
|
|
468
|
+
/** 业务主动写入一条轨迹(BugTap.addBreadcrumb) */
|
|
469
|
+
add(t) {
|
|
470
|
+
this.started && this.push(t);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* 交给框架路由接管导航记录(vue-router 集成)。
|
|
474
|
+
*
|
|
475
|
+
* 只摘补丁不够:框架通常在 SDK 之后才创建自己的 history,它会把
|
|
476
|
+
* **我们的包装器** 保存在闭包里,摘掉顶层包装后对方仍会调用到我们。
|
|
477
|
+
* 所以这里同时置一个开关,让 checkRoute / onHistory 直接短路。
|
|
478
|
+
*/
|
|
479
|
+
disableNavigationCapture() {
|
|
480
|
+
this.options.navigation && (this.navigationDisabled = !0, window.removeEventListener("popstate", this.checkRoute), window.removeEventListener("hashchange", this.checkRoute), this.unpatchHistory());
|
|
481
|
+
}
|
|
482
|
+
clear() {
|
|
483
|
+
this.buffer.clear(), this.tailSignature = "";
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* 网络请求留痕:与 Sentry 的 breadcrumbsIntegration 一致,记录**所有**请求,
|
|
487
|
+
* 完整数据在 network[],这里只放一行摘要并用 ref 关联。
|
|
488
|
+
*
|
|
489
|
+
* 风险是轮询请求会把 100 条容量吃光,导致「点按钮 → 报错」的因果链被挤出时间线。
|
|
490
|
+
* 因此连续的相同请求(method + url + status 相同)折叠成一条并累加 repeat,
|
|
491
|
+
* 轮询变成 `GET /api/heartbeat 200 ×120`,既保留完整视野又不挤占空间。
|
|
492
|
+
*/
|
|
493
|
+
addNetwork(t) {
|
|
494
|
+
var o;
|
|
495
|
+
if (!this.started || !this.options.network || this.options.excludeUrls && this.options.excludeUrls.some((a) => _(a, t.url)))
|
|
496
|
+
return;
|
|
497
|
+
const r = nt(t.url), i = or(t), n = `${t.method} ${r} ${(o = t.status) != null ? o : ""} ${i ? 1 : 0}`, s = this.buffer.last();
|
|
498
|
+
if (s && s.type === "http" && this.tailSignature === n) {
|
|
499
|
+
this.buffer.updateLast((a) => ({
|
|
500
|
+
...a,
|
|
501
|
+
repeat: (a.repeat || 1) + 1,
|
|
502
|
+
// 指向最近一次,便于去 network[] 找最新那条的完整 body
|
|
503
|
+
ref: t.id
|
|
504
|
+
}));
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
this.tailSignature = n, this.push({
|
|
508
|
+
t: Date.now(),
|
|
509
|
+
type: "http",
|
|
510
|
+
method: t.method,
|
|
511
|
+
url: r,
|
|
512
|
+
status: t.status,
|
|
513
|
+
durationMs: t.durationMs,
|
|
514
|
+
httpError: t.error,
|
|
515
|
+
ref: t.id
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
/** 异常留痕:与 errors[] 同源,时间线上按发生顺序排列 */
|
|
519
|
+
addError(t) {
|
|
520
|
+
!this.started || !this.options.error || this.push({
|
|
521
|
+
t: t.timestamp,
|
|
522
|
+
type: "error",
|
|
523
|
+
message: t.message.slice(0, 200),
|
|
524
|
+
count: t.count
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
push(t) {
|
|
528
|
+
if (!this.started) return;
|
|
529
|
+
const r = this.applyHook(t);
|
|
530
|
+
if (!r) return;
|
|
531
|
+
const i = r;
|
|
532
|
+
i.type !== "http" && (this.tailSignature = "");
|
|
533
|
+
const n = this.buffer.last();
|
|
534
|
+
n && n.type === i.type && n.selector === i.selector && n.to === i.to && n.state === i.state && n.ref === i.ref && n.message === i.message && Wr(n.data, i.data) || this.buffer.push(i);
|
|
535
|
+
}
|
|
536
|
+
// 钩子抛错时按「不修改」处理:业务 bug 不能导致时间线整体停摆
|
|
537
|
+
applyHook(t) {
|
|
538
|
+
const r = this.options.beforeBreadcrumb;
|
|
539
|
+
if (!r) return t;
|
|
540
|
+
try {
|
|
541
|
+
const i = r(t);
|
|
542
|
+
return i === null ? null : i && typeof i == "object" ? i : t;
|
|
543
|
+
} catch (i) {
|
|
544
|
+
return t;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
// pushState 与 replaceState 的包装逻辑完全相同,只差被包装的原函数
|
|
548
|
+
wrapHistory(t) {
|
|
549
|
+
const r = this, i = function(...n) {
|
|
550
|
+
var o;
|
|
551
|
+
const s = t.apply(this, n);
|
|
552
|
+
return (o = r.routeHook) == null || o.call(r), s;
|
|
553
|
+
};
|
|
554
|
+
return i.__bugTap = !0, i;
|
|
555
|
+
}
|
|
556
|
+
patchHistory() {
|
|
557
|
+
try {
|
|
558
|
+
if (typeof history == "undefined") return;
|
|
559
|
+
const t = history.pushState, r = history.replaceState;
|
|
560
|
+
this.originalPush = t, this.originalReplace = r, this.routeHook = () => this.onHistory(), this.wrappedPush = this.wrapHistory(t), this.wrappedReplace = this.wrapHistory(r), history.pushState = this.wrappedPush, history.replaceState = this.wrappedReplace;
|
|
561
|
+
} catch (t) {
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
unpatchHistory() {
|
|
565
|
+
try {
|
|
566
|
+
this.wrappedPush && history.pushState === this.wrappedPush && this.originalPush && (history.pushState = this.originalPush), this.wrappedReplace && history.replaceState === this.wrappedReplace && this.originalReplace && (history.replaceState = this.originalReplace);
|
|
567
|
+
} catch (t) {
|
|
568
|
+
}
|
|
569
|
+
this.routeHook = null, this.originalPush = null, this.originalReplace = null, this.wrappedPush = null, this.wrappedReplace = null;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const cr = "__bugTapCaptured";
|
|
573
|
+
let D = 0, F = 0;
|
|
574
|
+
function Vr(e) {
|
|
575
|
+
try {
|
|
576
|
+
e && (typeof e == "object" || typeof e == "function") && (e[cr] = !0);
|
|
577
|
+
} catch (t) {
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function Me(e) {
|
|
581
|
+
try {
|
|
582
|
+
return !!(e && typeof e == "object" && e[cr]);
|
|
583
|
+
} catch (t) {
|
|
584
|
+
return !1;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function Yr() {
|
|
588
|
+
return D <= 0 ? !1 : (D -= 1, !0);
|
|
589
|
+
}
|
|
590
|
+
function Kr() {
|
|
591
|
+
D += 1;
|
|
592
|
+
try {
|
|
593
|
+
F && clearTimeout(F), F = setTimeout(() => {
|
|
594
|
+
D = 0, F = 0;
|
|
595
|
+
}, 0);
|
|
596
|
+
} catch (e) {
|
|
597
|
+
D = 0;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const Gr = "__bugTapWrapped", Ae = "__bugTapHandleEvent";
|
|
601
|
+
class Jr {
|
|
602
|
+
constructor(t) {
|
|
603
|
+
this.options = t, this.patched = [], this.registry = /* @__PURE__ */ new WeakMap(), this.started = !1;
|
|
604
|
+
}
|
|
605
|
+
start() {
|
|
606
|
+
this.started || (this.started = !0, this.patchTimer("setTimeout", "setTimeout"), this.patchTimer("setInterval", "setInterval"), this.patchTimer("requestAnimationFrame", "requestAnimationFrame"), this.options.eventListeners !== !1 && this.patchEventTarget());
|
|
607
|
+
}
|
|
608
|
+
stop() {
|
|
609
|
+
if (this.started) {
|
|
610
|
+
this.started = !1;
|
|
611
|
+
for (const { target: t, key: r, original: i } of this.patched)
|
|
612
|
+
try {
|
|
613
|
+
const n = t[r];
|
|
614
|
+
typeof n == "function" && n.__bugTap && (t[r] = i);
|
|
615
|
+
} catch (n) {
|
|
616
|
+
}
|
|
617
|
+
this.patched.length = 0;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
patchTimer(t, r) {
|
|
621
|
+
try {
|
|
622
|
+
const i = window, n = i[t];
|
|
623
|
+
if (typeof n != "function" || n.__bugTap) return;
|
|
624
|
+
this.patched.push({ target: i, key: t, original: n });
|
|
625
|
+
const s = this, o = function(a, ...c) {
|
|
626
|
+
if (!s.started || typeof a != "function")
|
|
627
|
+
return n.apply(this, [a, ...c]);
|
|
628
|
+
const l = s.wrapCallback(a, r);
|
|
629
|
+
return n.apply(this, [l, ...c]);
|
|
630
|
+
};
|
|
631
|
+
o.__bugTap = !0, i[t] = o;
|
|
632
|
+
} catch (i) {
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
patchEventTarget() {
|
|
636
|
+
try {
|
|
637
|
+
if (typeof EventTarget == "undefined" || !EventTarget.prototype) return;
|
|
638
|
+
const t = EventTarget.prototype, r = t.addEventListener, i = t.removeEventListener;
|
|
639
|
+
if (typeof r != "function" || typeof i != "function" || r.__bugTap) return;
|
|
640
|
+
this.patched.push({ target: t, key: "addEventListener", original: r }), this.patched.push({ target: t, key: "removeEventListener", original: i });
|
|
641
|
+
const n = this, s = function(a, c, l) {
|
|
642
|
+
if (!n.started || !c)
|
|
643
|
+
return r.call(this, a, c, l);
|
|
644
|
+
if (typeof c == "object") {
|
|
645
|
+
const u = c;
|
|
646
|
+
if (typeof u.handleEvent == "function")
|
|
647
|
+
try {
|
|
648
|
+
u.handleEvent[Ae] || (u.handleEvent = n.wrapCallback(
|
|
649
|
+
u.handleEvent.bind(c),
|
|
650
|
+
a,
|
|
651
|
+
Ae
|
|
652
|
+
));
|
|
653
|
+
} catch (d) {
|
|
654
|
+
}
|
|
655
|
+
return r.call(this, a, c, l);
|
|
656
|
+
}
|
|
657
|
+
if (typeof c != "function")
|
|
658
|
+
return r.call(this, a, c, l);
|
|
659
|
+
const h = n.listenerFor(this, a, c, l);
|
|
660
|
+
return r.call(this, a, h, l);
|
|
661
|
+
}, o = function(a, c, l) {
|
|
662
|
+
var h, u, d, p;
|
|
663
|
+
try {
|
|
664
|
+
const b = c && (typeof c == "object" || typeof c == "function") ? (u = (h = n.registry.get(this)) == null ? void 0 : h.get(st(a, l))) == null ? void 0 : u.get(c) : void 0;
|
|
665
|
+
b && b !== c && (i.call(this, a, b, l), (p = (d = n.registry.get(this)) == null ? void 0 : d.get(st(a, l))) == null || p.delete(c));
|
|
666
|
+
} catch (g) {
|
|
667
|
+
}
|
|
668
|
+
return i.call(this, a, c, l);
|
|
669
|
+
};
|
|
670
|
+
s.__bugTap = !0, o.__bugTap = !0, t.addEventListener = s, t.removeEventListener = o;
|
|
671
|
+
} catch (t) {
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
/** 同一个 (target, event, capture, 原函数) 始终复用同一个包装器 */
|
|
675
|
+
listenerFor(t, r, i, n) {
|
|
676
|
+
let s = this.registry.get(t);
|
|
677
|
+
s || (s = /* @__PURE__ */ new Map(), this.registry.set(t, s));
|
|
678
|
+
const o = st(r, n);
|
|
679
|
+
let a = s.get(o);
|
|
680
|
+
a || (a = /* @__PURE__ */ new WeakMap(), s.set(o, a));
|
|
681
|
+
const c = a.get(i);
|
|
682
|
+
if (c) return c;
|
|
683
|
+
const l = this.wrapCallback(i, r);
|
|
684
|
+
return a.set(i, l), l;
|
|
685
|
+
}
|
|
686
|
+
/** 统一包装:失败时记一条带来源的异常,然后原样抛出 */
|
|
687
|
+
wrapCallback(t, r, i = Gr) {
|
|
688
|
+
const n = this, s = function(...o) {
|
|
689
|
+
try {
|
|
690
|
+
return t.apply(this, o);
|
|
691
|
+
} catch (a) {
|
|
692
|
+
try {
|
|
693
|
+
Vr(a), Kr(), n.options.capture(a, r);
|
|
694
|
+
} catch (c) {
|
|
695
|
+
}
|
|
696
|
+
throw a;
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
try {
|
|
700
|
+
s[i] = t;
|
|
701
|
+
} catch (o) {
|
|
702
|
+
}
|
|
703
|
+
return s;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
function st(e, t) {
|
|
707
|
+
const r = typeof t == "boolean" ? t : !!(t && typeof t == "object" && t.capture);
|
|
708
|
+
return `${e}|${r ? 1 : 0}`;
|
|
709
|
+
}
|
|
710
|
+
const Qr = 4, v = 50, Zr = 2e3, lr = 4e3;
|
|
711
|
+
function P(e, t = Zr) {
|
|
712
|
+
return e.length > t ? `${e.slice(0, t)}…[${e.length - t} chars truncated]` : e;
|
|
713
|
+
}
|
|
714
|
+
function ti(e) {
|
|
715
|
+
const t = typeof e;
|
|
716
|
+
if (e === null) return "null";
|
|
717
|
+
if (t === "undefined") return "undefined";
|
|
718
|
+
if (t === "string") return P(e);
|
|
719
|
+
if (t === "number") return Number.isFinite(e), String(e);
|
|
720
|
+
if (t === "boolean") return String(e);
|
|
721
|
+
if (t === "bigint") return `${String(e)}n`;
|
|
722
|
+
if (t === "symbol") return String(e);
|
|
723
|
+
if (t === "function") {
|
|
724
|
+
const r = e.name;
|
|
725
|
+
return `[Function${r ? ` ${r}` : ""}]`;
|
|
726
|
+
}
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
function O(e, t = 0, r) {
|
|
730
|
+
const i = ti(e);
|
|
731
|
+
if (i !== null) return i;
|
|
732
|
+
const n = r || /* @__PURE__ */ new WeakSet(), s = e;
|
|
733
|
+
if (typeof s != "object" || s === null) return String(s);
|
|
734
|
+
if (n.has(s)) return "[Circular]";
|
|
735
|
+
n.add(s);
|
|
736
|
+
try {
|
|
737
|
+
if (e instanceof Error) {
|
|
738
|
+
const c = typeof e.stack == "string" ? e.stack.split(`
|
|
739
|
+
`).slice(0, 6).join(`
|
|
740
|
+
`) : "";
|
|
741
|
+
return P(`${e.name || "Error"}: ${e.message}${c ? `
|
|
742
|
+
${c}` : ""}`, lr);
|
|
743
|
+
}
|
|
744
|
+
if (e instanceof Date)
|
|
745
|
+
try {
|
|
746
|
+
return e.toISOString();
|
|
747
|
+
} catch (c) {
|
|
748
|
+
return "[Invalid Date]";
|
|
749
|
+
}
|
|
750
|
+
if (e instanceof RegExp) return String(e);
|
|
751
|
+
if (typeof Element != "undefined" && e instanceof Element) {
|
|
752
|
+
const c = e.tagName.toLowerCase(), l = e.id ? `#${e.id}` : "", h = typeof e.className == "string" && e.className.trim() ? `.${e.className.trim().split(/\s+/).slice(0, 3).join(".")}` : "";
|
|
753
|
+
return `<${c}${l}${h}>`;
|
|
754
|
+
}
|
|
755
|
+
if (typeof Node != "undefined" && e instanceof Node)
|
|
756
|
+
return `[Node ${e.nodeName}]`;
|
|
757
|
+
if (t >= Qr) return "[MaxDepth]";
|
|
758
|
+
if (Array.isArray(e)) {
|
|
759
|
+
const c = e.slice(0, v).map((l) => O(l, t + 1, n));
|
|
760
|
+
return e.length > v && c.push(`…[${e.length - v} more]`), P(`[${c.join(", ")}]`);
|
|
761
|
+
}
|
|
762
|
+
if (e instanceof Map) {
|
|
763
|
+
const c = [];
|
|
764
|
+
let l = 0;
|
|
765
|
+
return e.forEach((h, u) => {
|
|
766
|
+
l < v && c.push(`${O(u, t + 1, n)} => ${O(h, t + 1, n)}`), l += 1;
|
|
767
|
+
}), l > v && c.push(`…[${l - v} more]`), P(`Map(${e.size}) {${c.join(", ")}}`);
|
|
768
|
+
}
|
|
769
|
+
if (e instanceof Set) {
|
|
770
|
+
const c = [];
|
|
771
|
+
let l = 0;
|
|
772
|
+
return e.forEach((h) => {
|
|
773
|
+
l < v && c.push(O(h, t + 1, n)), l += 1;
|
|
774
|
+
}), l > v && c.push(`…[${l - v} more]`), P(`Set(${e.size}) {${c.join(", ")}}`);
|
|
775
|
+
}
|
|
776
|
+
const o = Object.keys(e), a = [];
|
|
777
|
+
for (const c of o.slice(0, v))
|
|
778
|
+
try {
|
|
779
|
+
const l = e[c];
|
|
780
|
+
a.push(`${c}: ${O(l, t + 1, n)}`);
|
|
781
|
+
} catch (l) {
|
|
782
|
+
a.push(`${c}: [Thrown]`);
|
|
783
|
+
}
|
|
784
|
+
return o.length > v && a.push(`…[${o.length - v} more keys]`), P(`{${a.join(", ")}}`);
|
|
785
|
+
} catch (o) {
|
|
786
|
+
return "[Unserializable]";
|
|
787
|
+
} finally {
|
|
788
|
+
n.delete(s);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function ei(e) {
|
|
792
|
+
const t = e.map((i) => O(i)), r = P(t.join(" "), lr);
|
|
793
|
+
return { args: t, text: r };
|
|
794
|
+
}
|
|
795
|
+
const ot = ["log", "info", "warn", "error", "debug", "trace", "assert"];
|
|
796
|
+
class ri {
|
|
797
|
+
constructor(t) {
|
|
798
|
+
this.options = t, this.originals = /* @__PURE__ */ new Map(), this.wrapped = /* @__PURE__ */ new Map(), this.originalClear = null, this.wrappedClear = null, this.started = !1, this.capturing = !1, this.dispatching = !1, this.buffer = new Lt(t.max);
|
|
799
|
+
}
|
|
800
|
+
start() {
|
|
801
|
+
if (this.started) return;
|
|
802
|
+
this.started = !0;
|
|
803
|
+
const t = window.console;
|
|
804
|
+
for (const i of ot) {
|
|
805
|
+
const n = t[i];
|
|
806
|
+
if (typeof n != "function") continue;
|
|
807
|
+
const s = n;
|
|
808
|
+
this.originals.set(i, s);
|
|
809
|
+
const o = this, a = function(...c) {
|
|
810
|
+
o.capture(i, c), o.dispatching = !0;
|
|
811
|
+
try {
|
|
812
|
+
return s.apply(this, c);
|
|
813
|
+
} finally {
|
|
814
|
+
o.dispatching = !1;
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
a.__bugTap = !0, this.wrapped.set(i, a);
|
|
818
|
+
try {
|
|
819
|
+
t[i] = a;
|
|
820
|
+
} catch (c) {
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
const r = t.clear;
|
|
824
|
+
if (typeof r == "function") {
|
|
825
|
+
this.originalClear = r;
|
|
826
|
+
const i = this, n = function() {
|
|
827
|
+
return i.buffer.clear(), i.originalClear.apply(this);
|
|
828
|
+
};
|
|
829
|
+
n.__bugTap = !0, this.wrappedClear = n;
|
|
830
|
+
try {
|
|
831
|
+
t.clear = n;
|
|
832
|
+
} catch (s) {
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
stop() {
|
|
837
|
+
if (!this.started) return;
|
|
838
|
+
this.started = !1;
|
|
839
|
+
const t = window.console;
|
|
840
|
+
for (const r of ot) {
|
|
841
|
+
const i = this.wrapped.get(r), n = this.originals.get(r);
|
|
842
|
+
if (!(!i || !n) && t[r] === i)
|
|
843
|
+
try {
|
|
844
|
+
t[r] = n;
|
|
845
|
+
} catch (s) {
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (this.wrappedClear && this.originalClear && t.clear === this.wrappedClear)
|
|
849
|
+
try {
|
|
850
|
+
t.clear = this.originalClear;
|
|
851
|
+
} catch (r) {
|
|
852
|
+
}
|
|
853
|
+
this.wrapped.clear(), this.originals.clear(), this.wrappedClear = null, this.originalClear = null;
|
|
854
|
+
}
|
|
855
|
+
getLogs() {
|
|
856
|
+
return this.buffer.toArray();
|
|
857
|
+
}
|
|
858
|
+
// 打点是否仍然生效:页面后来又包了一层 console 时,顶层已不是我们的包装器
|
|
859
|
+
getPatchState() {
|
|
860
|
+
if (!this.started) return !1;
|
|
861
|
+
const t = window.console;
|
|
862
|
+
for (const r of ot) {
|
|
863
|
+
const i = this.wrapped.get(r);
|
|
864
|
+
if (i && t[r] === i) return !0;
|
|
865
|
+
}
|
|
866
|
+
return !1;
|
|
867
|
+
}
|
|
868
|
+
clear() {
|
|
869
|
+
this.buffer.clear();
|
|
870
|
+
}
|
|
871
|
+
capture(t, r) {
|
|
872
|
+
if (!(!this.started || this.capturing || this.dispatching)) {
|
|
873
|
+
this.capturing = !0;
|
|
874
|
+
try {
|
|
875
|
+
if (t === "assert" && r[0]) return;
|
|
876
|
+
const { args: i, text: n } = ei(t === "assert" ? r.slice(1) : r);
|
|
877
|
+
if (this.options.excludePatterns.some((o) => _(o, n))) return;
|
|
878
|
+
const s = this.buffer.last();
|
|
879
|
+
if (s && s.level === t && s.text === n) {
|
|
880
|
+
this.buffer.updateLast((o) => ({
|
|
881
|
+
...o,
|
|
882
|
+
count: (o.count || 1) + 1,
|
|
883
|
+
timestamp: Date.now()
|
|
884
|
+
}));
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
this.buffer.push({
|
|
888
|
+
level: t,
|
|
889
|
+
timestamp: Date.now(),
|
|
890
|
+
args: i,
|
|
891
|
+
text: n
|
|
892
|
+
});
|
|
893
|
+
} catch (i) {
|
|
894
|
+
} finally {
|
|
895
|
+
this.capturing = !1;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
const ii = 1e3, Pe = 200, ni = 6e4, si = 20, oi = 50, W = 2e3;
|
|
901
|
+
function Be(e) {
|
|
902
|
+
if (e != null)
|
|
903
|
+
try {
|
|
904
|
+
if (e instanceof Error) {
|
|
905
|
+
const t = `${e.name || "Error"}: ${e.message}`, r = typeof e.stack == "string" ? e.stack.split(`
|
|
906
|
+
`).slice(0, 6).join(`
|
|
907
|
+
`) : "";
|
|
908
|
+
return (r ? `${t}
|
|
909
|
+
${r}` : t).slice(0, W);
|
|
910
|
+
}
|
|
911
|
+
return typeof e == "string" ? e.slice(0, W) : JSON.stringify(e).slice(0, W);
|
|
912
|
+
} catch (t) {
|
|
913
|
+
return String(e).slice(0, W);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
const ai = /(?:[\\/]src[\\/](?:core|ui|transport)[\\/](?:browser-api-errors|error-collector|console-collector|network-collector|breadcrumbs|collector|resource-timing|body|serialize|selector|user|tongji|error-noise|network-record|ring-buffer|byte-buffer|panel(?:-mount)?|screenshot|element-picker|floating-button|shadow-host|visibility|transport|payload|log-item|upload|offline-queue)\.(?:ts|vue)|[\\/]src[\\/](?:index|sdk|config|integrations)\.ts|@xysfe[\\/]bug-tap|[\\/]bug-tap(?:\.min)?\.js|\bsafeCallback\b)/i;
|
|
917
|
+
function Ie(e) {
|
|
918
|
+
if (!e) return;
|
|
919
|
+
const t = e.split(`
|
|
920
|
+
`), r = t[0] || "", i = t.slice(1).filter((s) => !ai.test(s));
|
|
921
|
+
return [r, ...i].slice(0, si).join(`
|
|
922
|
+
`);
|
|
923
|
+
}
|
|
924
|
+
class ci {
|
|
925
|
+
constructor(t) {
|
|
926
|
+
this.options = t, this.signatures = /* @__PURE__ */ new Map(), this.started = !1, this.listener = null, this.onError = (r) => {
|
|
927
|
+
try {
|
|
928
|
+
if (r.target && r.target !== window) {
|
|
929
|
+
this.options.resourceErrors !== !1 && this.pushResourceError(r);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
if (Me(r.error) || r.error === void 0 && Yr())
|
|
933
|
+
return;
|
|
934
|
+
const i = (r.message || "Script error.").replace(/^Uncaught\s+/, ""), n = r.error, s = n && typeof n.stack == "string" ? n.stack : "";
|
|
935
|
+
this.push({
|
|
936
|
+
type: "error",
|
|
937
|
+
message: this.sanitize(i),
|
|
938
|
+
filename: r.filename ? this.sanitize(r.filename) : void 0,
|
|
939
|
+
lineno: r.lineno || void 0,
|
|
940
|
+
colno: r.colno || void 0,
|
|
941
|
+
stack: s ? this.sanitize(Ie(s) || "") : void 0,
|
|
942
|
+
cause: Be(n == null ? void 0 : n.cause),
|
|
943
|
+
timestamp: Date.now(),
|
|
944
|
+
count: 1
|
|
945
|
+
});
|
|
946
|
+
} catch (i) {
|
|
947
|
+
}
|
|
948
|
+
}, this.onRejection = (r) => {
|
|
949
|
+
try {
|
|
950
|
+
const i = r.reason;
|
|
951
|
+
if (Me(i)) return;
|
|
952
|
+
this.push({ ...this.fromUnknown(i), type: "unhandledrejection" });
|
|
953
|
+
} catch (i) {
|
|
954
|
+
}
|
|
955
|
+
}, this.buffer = new Lt(t.max);
|
|
956
|
+
}
|
|
957
|
+
setListener(t) {
|
|
958
|
+
this.listener = t;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* 资源加载错误的 target 是具体元素,不带 stack。
|
|
962
|
+
* 只保留标签与地址,足够定位「哪张图 / 哪个脚本没加载出来」。
|
|
963
|
+
*/
|
|
964
|
+
pushResourceError(t) {
|
|
965
|
+
const r = t.target;
|
|
966
|
+
if (!r || typeof r.tagName != "string") return;
|
|
967
|
+
const i = r.tagName.toLowerCase(), n = r.currentSrc || r.getAttribute("src") || r.getAttribute("href") || "";
|
|
968
|
+
this.push({
|
|
969
|
+
type: "resource",
|
|
970
|
+
message: this.sanitize(`Resource load failed: <${i}>${n ? ` ${n}` : ""}`),
|
|
971
|
+
filename: n ? this.sanitize(n) : void 0,
|
|
972
|
+
timestamp: Date.now(),
|
|
973
|
+
count: 1
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* 由 BrowserApiErrors 调用:定时器 / 事件监听回调里的异常。
|
|
978
|
+
* 来源写进 message,排查时不用再猜「这是哪类异步错误」。
|
|
979
|
+
*/
|
|
980
|
+
captureFromBrowserApi(t, r) {
|
|
981
|
+
try {
|
|
982
|
+
this.push(this.fromUnknown(t, `[${r}]`, r));
|
|
983
|
+
} catch (i) {
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* 业务主动上报异常。只进本地缓冲,随下一次用户反馈一起提交,
|
|
988
|
+
* 不会单独发请求,避免业务在循环里调用时打爆网关。
|
|
989
|
+
*/
|
|
990
|
+
captureException(t, r) {
|
|
991
|
+
try {
|
|
992
|
+
this.push(this.fromUnknown(t, "", void 0, r), !1);
|
|
993
|
+
} catch (i) {
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
/** 业务主动上报一条消息,语义同 captureException,但不要求是 Error 实例 */
|
|
997
|
+
captureMessage(t, r) {
|
|
998
|
+
try {
|
|
999
|
+
this.push(
|
|
1000
|
+
{
|
|
1001
|
+
type: "error",
|
|
1002
|
+
message: this.sanitize(String(t != null ? t : "")),
|
|
1003
|
+
context: r && Object.keys(r).length > 0 ? r : void 0,
|
|
1004
|
+
timestamp: Date.now(),
|
|
1005
|
+
count: 1
|
|
1006
|
+
},
|
|
1007
|
+
!1
|
|
1008
|
+
);
|
|
1009
|
+
} catch (i) {
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
/** 把任意抛出值归一成一条异常记录 */
|
|
1013
|
+
fromUnknown(t, r = "", i, n) {
|
|
1014
|
+
let s, o, a;
|
|
1015
|
+
if (t instanceof Error)
|
|
1016
|
+
s = `${t.name || "Error"}: ${t.message}`, o = t.stack, a = Be(t.cause);
|
|
1017
|
+
else if (typeof t == "string")
|
|
1018
|
+
s = t;
|
|
1019
|
+
else
|
|
1020
|
+
try {
|
|
1021
|
+
s = JSON.stringify(t);
|
|
1022
|
+
} catch (h) {
|
|
1023
|
+
s = String(t);
|
|
1024
|
+
}
|
|
1025
|
+
const c = o ? Ie(o) : void 0, l = Ct(c);
|
|
1026
|
+
return {
|
|
1027
|
+
type: "error",
|
|
1028
|
+
message: this.sanitize(i ? `${r} ${s}` : `${r}${s}`),
|
|
1029
|
+
// 定时器 / 事件回调异常没有 event.filename:从业务栈帧补结构化位置
|
|
1030
|
+
filename: l != null && l.url ? this.sanitize(l.url) : void 0,
|
|
1031
|
+
lineno: l == null ? void 0 : l.line,
|
|
1032
|
+
colno: l == null ? void 0 : l.column,
|
|
1033
|
+
stack: c ? this.sanitize(c) : void 0,
|
|
1034
|
+
cause: a,
|
|
1035
|
+
context: n && Object.keys(n).length > 0 ? n : void 0,
|
|
1036
|
+
timestamp: Date.now(),
|
|
1037
|
+
count: 1
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
start() {
|
|
1041
|
+
if (!this.started) {
|
|
1042
|
+
this.started = !0;
|
|
1043
|
+
try {
|
|
1044
|
+
this.previousStackTraceLimit = Error.stackTraceLimit, Error.stackTraceLimit = oi;
|
|
1045
|
+
} catch (t) {
|
|
1046
|
+
}
|
|
1047
|
+
window.addEventListener("error", this.onError, !0), window.addEventListener("unhandledrejection", this.onRejection);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
stop() {
|
|
1051
|
+
if (this.started && (this.started = !1, window.removeEventListener("error", this.onError, !0), window.removeEventListener("unhandledrejection", this.onRejection), this.previousStackTraceLimit !== void 0)) {
|
|
1052
|
+
try {
|
|
1053
|
+
Error.stackTraceLimit = this.previousStackTraceLimit;
|
|
1054
|
+
} catch (t) {
|
|
1055
|
+
}
|
|
1056
|
+
this.previousStackTraceLimit = void 0;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
getErrors() {
|
|
1060
|
+
return this.buffer.toArray();
|
|
1061
|
+
}
|
|
1062
|
+
getPatchState() {
|
|
1063
|
+
return this.started;
|
|
1064
|
+
}
|
|
1065
|
+
clear() {
|
|
1066
|
+
this.buffer.clear(), this.signatures.clear();
|
|
1067
|
+
}
|
|
1068
|
+
push(t, r = !0) {
|
|
1069
|
+
if (r && this.shouldDrop(t)) return;
|
|
1070
|
+
const i = `${t.type}|${t.message}|${t.filename || ""}|${t.lineno || ""}`, n = this.signatures.get(i), s = t.timestamp;
|
|
1071
|
+
if (r && n && s - n.lastTs < ii) {
|
|
1072
|
+
if (this.buffer.includes(n.record)) {
|
|
1073
|
+
n.record.count += 1, n.lastTs = s;
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
this.signatures.delete(i);
|
|
1077
|
+
}
|
|
1078
|
+
if (this.signatures.size >= Pe && (this.pruneSignatures(s), this.signatures.size >= Pe && this.signatures.clear()), this.signatures.set(i, { record: t, lastTs: s }), this.buffer.push(t), this.listener)
|
|
1079
|
+
try {
|
|
1080
|
+
this.listener(t);
|
|
1081
|
+
} catch (o) {
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
pruneSignatures(t) {
|
|
1085
|
+
for (const [r, i] of this.signatures)
|
|
1086
|
+
(t - i.lastTs >= ni || !this.buffer.includes(i.record)) && this.signatures.delete(r);
|
|
1087
|
+
}
|
|
1088
|
+
// 与 Sentry eventFilters 的三层过滤对齐:消息 → 无内容 → 脚本地址
|
|
1089
|
+
shouldDrop(t) {
|
|
1090
|
+
const r = this.options.ignoreErrors || [];
|
|
1091
|
+
if (r.length > 0 && Pr(t.message, r) || Br(t)) return !0;
|
|
1092
|
+
const i = Rr(t.stack, t.filename);
|
|
1093
|
+
return !Ir(i, this.options.allowUrls || [], this.options.denyUrls || []);
|
|
1094
|
+
}
|
|
1095
|
+
sanitize(t) {
|
|
1096
|
+
return String(t).slice(0, 4e3);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
class li {
|
|
1100
|
+
constructor(t, r, i) {
|
|
1101
|
+
this.maxItems = t, this.maxBytes = r, this.sizeOf = i, this.items = [], this.sizes = [], this.head = 0, this.total = 0, this.droppedItems = 0, this.droppedBytes = 0, this.evictedItems = 0, this.evictedBytes = 0;
|
|
1102
|
+
}
|
|
1103
|
+
get size() {
|
|
1104
|
+
return this.items.length - this.head;
|
|
1105
|
+
}
|
|
1106
|
+
get bytes() {
|
|
1107
|
+
return this.total;
|
|
1108
|
+
}
|
|
1109
|
+
// 因单条超预算而没写入的记录
|
|
1110
|
+
get dropped() {
|
|
1111
|
+
return { count: this.droppedItems, bytes: this.droppedBytes };
|
|
1112
|
+
}
|
|
1113
|
+
// 为腾空间被淘汰的旧记录
|
|
1114
|
+
get evicted() {
|
|
1115
|
+
return { count: this.evictedItems, bytes: this.evictedBytes };
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* 返回实际写入的条数变化:
|
|
1119
|
+
* - 'ok' 正常写入
|
|
1120
|
+
* - 'evicted' 为腾空间丢了旧记录
|
|
1121
|
+
* - 'dropped' 单条就超过总预算,没写入
|
|
1122
|
+
*/
|
|
1123
|
+
push(t) {
|
|
1124
|
+
const r = this.sizeOf(t);
|
|
1125
|
+
if (r > this.maxBytes)
|
|
1126
|
+
return this.droppedItems += 1, this.droppedBytes += r, "dropped";
|
|
1127
|
+
let i = !1;
|
|
1128
|
+
for (; this.size > 0 && (this.total + r > this.maxBytes || this.size >= this.maxItems); )
|
|
1129
|
+
this.shift(), i = !0;
|
|
1130
|
+
return this.items.push(t), this.sizes.push(r), this.total += r, i ? "evicted" : "ok";
|
|
1131
|
+
}
|
|
1132
|
+
toArray() {
|
|
1133
|
+
return this.items.slice(this.head);
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* 原地更新一条已写入的记录(例如流式响应稍后拿到 body)。
|
|
1137
|
+
* 更新后若超出总预算则保持原样,宁可丢 body 也不丢整条元数据。
|
|
1138
|
+
*/
|
|
1139
|
+
update(t, r) {
|
|
1140
|
+
for (let i = this.head; i < this.items.length; i += 1) {
|
|
1141
|
+
const n = this.items[i];
|
|
1142
|
+
if (!t(n)) continue;
|
|
1143
|
+
const s = r(n), o = this.sizeOf(s), a = o - (this.sizes[i] || 0);
|
|
1144
|
+
return this.total + a > this.maxBytes ? "dropped" : (this.items[i] = s, this.sizes[i] = o, this.total += a, "ok");
|
|
1145
|
+
}
|
|
1146
|
+
return "missed";
|
|
1147
|
+
}
|
|
1148
|
+
clear() {
|
|
1149
|
+
this.items = [], this.sizes = [], this.head = 0, this.total = 0, this.droppedItems = 0, this.droppedBytes = 0, this.evictedItems = 0, this.evictedBytes = 0;
|
|
1150
|
+
}
|
|
1151
|
+
shift() {
|
|
1152
|
+
const t = this.sizes[this.head] || 0;
|
|
1153
|
+
this.items[this.head] = void 0, this.head += 1, this.total -= t, this.evictedItems += 1, this.evictedBytes += t, this.head >= this.items.length ? (this.items = [], this.sizes = [], this.head = 0) : this.head > 64 && this.head * 2 > this.items.length && (this.items = this.items.slice(this.head), this.sizes = this.sizes.slice(this.head), this.head = 0);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
const hi = /text\/event-stream/i, ui = /^(?:image|video|audio|font)\/|^application\/(?:octet-stream|x-protobuf|protobuf|zip|gzip|x-zip-compressed|pdf|wasm|vnd\.ms-fontobject)/i;
|
|
1157
|
+
function wt(e, t) {
|
|
1158
|
+
if (t <= 0) return e;
|
|
1159
|
+
let r = 0, i = 0;
|
|
1160
|
+
for (; i < e.length; ) {
|
|
1161
|
+
const n = e.charCodeAt(i);
|
|
1162
|
+
let s, o = 1;
|
|
1163
|
+
if (n < 128 ? s = 1 : n < 2048 ? s = 2 : n < 55296 || n >= 57344 ? s = 3 : (s = 4, o = n >= 56320 ? 1 : 2), r + s > t) break;
|
|
1164
|
+
r += s, i += o;
|
|
1165
|
+
}
|
|
1166
|
+
return i >= e.length ? e : `${e.slice(0, i)}…[truncated]`;
|
|
1167
|
+
}
|
|
1168
|
+
function S(e) {
|
|
1169
|
+
let t = 0;
|
|
1170
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
1171
|
+
const i = e.charCodeAt(r);
|
|
1172
|
+
i < 128 ? t += 1 : i < 2048 ? t += 2 : i < 55296 || i >= 57344 ? t += 3 : (t += 4, r += 1);
|
|
1173
|
+
}
|
|
1174
|
+
return t;
|
|
1175
|
+
}
|
|
1176
|
+
function di(e) {
|
|
1177
|
+
if (e != null)
|
|
1178
|
+
try {
|
|
1179
|
+
if (typeof e == "string") return e;
|
|
1180
|
+
if (typeof URLSearchParams != "undefined" && e instanceof URLSearchParams)
|
|
1181
|
+
return e.toString();
|
|
1182
|
+
if (typeof FormData != "undefined" && e instanceof FormData) {
|
|
1183
|
+
const t = [];
|
|
1184
|
+
return e.forEach((r, i) => {
|
|
1185
|
+
if (typeof File != "undefined" && r instanceof File) {
|
|
1186
|
+
const n = r.name || "blob", s = r.type || "unknown";
|
|
1187
|
+
t.push(`${i}=[File ${n} ${r.size}B ${s}]`);
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
if (typeof Blob != "undefined" && r instanceof Blob) {
|
|
1191
|
+
t.push(`${i}=[Blob ${r.size}B ${r.type || "unknown"}]`);
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
t.push(`${i}=${String(r)}`);
|
|
1195
|
+
}), t.join("&");
|
|
1196
|
+
}
|
|
1197
|
+
return typeof Blob != "undefined" && e instanceof Blob ? `[Blob ${e.size}B ${e.type || "unknown"}]` : typeof ArrayBuffer != "undefined" && e instanceof ArrayBuffer ? `[Binary ${e.byteLength}B]` : typeof ArrayBuffer != "undefined" && ArrayBuffer.isView(e) ? `[Binary ${e.byteLength}B]` : typeof ReadableStream != "undefined" && e instanceof ReadableStream ? "[ReadableStream]" : `[${Object.prototype.toString.call(e).slice(8, -1)}]`;
|
|
1198
|
+
} catch (t) {
|
|
1199
|
+
return "[Unreadable]";
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
function B(e, t = Number.MAX_SAFE_INTEGER) {
|
|
1203
|
+
try {
|
|
1204
|
+
return S(JSON.stringify(e));
|
|
1205
|
+
} catch (r) {
|
|
1206
|
+
return t;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
function hr(e, t, r) {
|
|
1210
|
+
const i = (e || "").toLowerCase();
|
|
1211
|
+
return !(hi.test(i) || ui.test(i) || t > 0 && t > r);
|
|
1212
|
+
}
|
|
1213
|
+
function $e(e, t) {
|
|
1214
|
+
if (typeof e.getReader != "function" || typeof TextDecoder == "undefined")
|
|
1215
|
+
return new Response(e).text();
|
|
1216
|
+
const r = e.getReader(), i = new TextDecoder("utf-8", { fatal: !1 }), n = [];
|
|
1217
|
+
let s = 0, o = !1;
|
|
1218
|
+
const a = () => {
|
|
1219
|
+
try {
|
|
1220
|
+
Promise.resolve(r.cancel()).catch(() => {
|
|
1221
|
+
});
|
|
1222
|
+
} catch (h) {
|
|
1223
|
+
}
|
|
1224
|
+
}, c = () => r.read().then(
|
|
1225
|
+
({ done: h, value: u }) => h ? (n.push(i.decode()), l()) : u ? (s += u.byteLength, s > t ? (o = !0, a(), l()) : (n.push(i.decode(u, { stream: !0 })), c())) : c(),
|
|
1226
|
+
() => (o = !0, a(), l())
|
|
1227
|
+
), l = () => {
|
|
1228
|
+
const h = n.join("");
|
|
1229
|
+
return o ? `${h}…[truncated]` : h;
|
|
1230
|
+
};
|
|
1231
|
+
return c();
|
|
1232
|
+
}
|
|
1233
|
+
function fi(e, t) {
|
|
1234
|
+
try {
|
|
1235
|
+
const r = e.getResponseHeader("content-type"), i = Number(e.getResponseHeader("content-length") || 0);
|
|
1236
|
+
if (!hr(r, i, t)) return;
|
|
1237
|
+
const n = e.responseType;
|
|
1238
|
+
if (n === "" || n === "text") {
|
|
1239
|
+
const s = e.responseText;
|
|
1240
|
+
return s ? wt(s, t) : void 0;
|
|
1241
|
+
}
|
|
1242
|
+
if (n === "json") {
|
|
1243
|
+
const s = e.response;
|
|
1244
|
+
if (s == null) return;
|
|
1245
|
+
try {
|
|
1246
|
+
return wt(JSON.stringify(s), t);
|
|
1247
|
+
} catch (o) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return `[${n}]`;
|
|
1252
|
+
} catch (r) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
const pi = 2e3, gi = 500, mi = 1e3;
|
|
1257
|
+
function H(e) {
|
|
1258
|
+
return Number.isFinite(e) && e > 0 ? Math.round(e) : 0;
|
|
1259
|
+
}
|
|
1260
|
+
function bi(e) {
|
|
1261
|
+
return {
|
|
1262
|
+
dns: H(e.domainLookupEnd - e.domainLookupStart),
|
|
1263
|
+
connect: H(e.connectEnd - e.connectStart),
|
|
1264
|
+
ttfb: H(e.responseStart - e.startTime),
|
|
1265
|
+
download: H(e.responseEnd - e.responseStart),
|
|
1266
|
+
total: H(e.responseEnd - e.startTime)
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
class yi {
|
|
1270
|
+
constructor() {
|
|
1271
|
+
this.started = /* @__PURE__ */ new Map(), this.enabled = !0;
|
|
1272
|
+
}
|
|
1273
|
+
/** @param startAt 请求发起时刻,需与 performance.now() 同一时间基准 */
|
|
1274
|
+
remember(t, r, i) {
|
|
1275
|
+
if (!(!this.enabled || !Number.isFinite(i)) && (this.started.set(t, { url: r, start: i }), this.started.size > mi)) {
|
|
1276
|
+
const n = this.started.keys().next();
|
|
1277
|
+
n.done || this.started.delete(n.value);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
/** 回查并返回带 timing 的新记录;查不到时原样返回 */
|
|
1281
|
+
attach(t) {
|
|
1282
|
+
if (t.timing) return t;
|
|
1283
|
+
const r = this.started.get(t.id);
|
|
1284
|
+
if (!r) return t;
|
|
1285
|
+
const i = this.find(r.url, r.start);
|
|
1286
|
+
return i ? { ...t, timing: i } : t;
|
|
1287
|
+
}
|
|
1288
|
+
clear() {
|
|
1289
|
+
this.started.clear();
|
|
1290
|
+
}
|
|
1291
|
+
find(t, r) {
|
|
1292
|
+
if (this.enabled)
|
|
1293
|
+
try {
|
|
1294
|
+
if (typeof performance == "undefined" || typeof performance.getEntriesByName != "function")
|
|
1295
|
+
return;
|
|
1296
|
+
const i = performance.getEntriesByName(t);
|
|
1297
|
+
if (!i.length || i.length > gi) return;
|
|
1298
|
+
let n, s = 1 / 0;
|
|
1299
|
+
for (const o of i) {
|
|
1300
|
+
if (typeof o.responseEnd != "number" || o.responseEnd <= 0) continue;
|
|
1301
|
+
const a = Math.abs(o.startTime - r);
|
|
1302
|
+
a < s && (s = a, n = o);
|
|
1303
|
+
}
|
|
1304
|
+
return !n || s > pi ? void 0 : bi(n);
|
|
1305
|
+
} catch (i) {
|
|
1306
|
+
this.enabled = !1;
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function N(e) {
|
|
1312
|
+
try {
|
|
1313
|
+
return new URL(e, location.href).href;
|
|
1314
|
+
} catch (t) {
|
|
1315
|
+
return e;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
const wi = 4096, vi = 40;
|
|
1319
|
+
function xi(e, t) {
|
|
1320
|
+
return t === !0 || t.indexOf(e) >= 0;
|
|
1321
|
+
}
|
|
1322
|
+
function T(e, t, r, i) {
|
|
1323
|
+
const n = String(t || "").trim().toLowerCase();
|
|
1324
|
+
if (!n || !xi(n, i) || !(n in e) && Object.keys(e).length >= vi) return;
|
|
1325
|
+
const s = String(r != null ? r : "").slice(0, wi);
|
|
1326
|
+
s && (e[n] = s);
|
|
1327
|
+
}
|
|
1328
|
+
function at(e, t) {
|
|
1329
|
+
if (!e) return;
|
|
1330
|
+
const r = {};
|
|
1331
|
+
try {
|
|
1332
|
+
if (e && typeof e.forEach == "function" && (typeof Headers == "undefined" || e instanceof Headers || typeof e.get == "function"))
|
|
1333
|
+
e.forEach((i, n) => T(r, n, i, t));
|
|
1334
|
+
else if (e && typeof e.get == "function") {
|
|
1335
|
+
const i = t === !0 ? [...Z] : t;
|
|
1336
|
+
for (const n of i) {
|
|
1337
|
+
const s = e.get(n);
|
|
1338
|
+
s && T(r, n, s, !0);
|
|
1339
|
+
}
|
|
1340
|
+
} else if (Array.isArray(e))
|
|
1341
|
+
for (const i of e)
|
|
1342
|
+
Array.isArray(i) && i.length >= 2 && T(r, String(i[0]), i[1], t);
|
|
1343
|
+
else if (typeof e == "object")
|
|
1344
|
+
for (const [i, n] of Object.entries(e))
|
|
1345
|
+
Array.isArray(n) ? n.forEach((s) => T(r, i, s, t)) : T(r, i, n, t);
|
|
1346
|
+
} catch (i) {
|
|
1347
|
+
}
|
|
1348
|
+
return Object.keys(r).length > 0 ? r : void 0;
|
|
1349
|
+
}
|
|
1350
|
+
function Ei(e, t) {
|
|
1351
|
+
return e ? t ? { ...e, ...t } : e : t;
|
|
1352
|
+
}
|
|
1353
|
+
function Si(e, t) {
|
|
1354
|
+
const r = {};
|
|
1355
|
+
return e.trim().split(/[\r\n]+/).forEach((i) => {
|
|
1356
|
+
const n = i.indexOf(":");
|
|
1357
|
+
n <= 0 || T(r, i.slice(0, n), i.slice(n + 1).trim(), t);
|
|
1358
|
+
}), Object.keys(r).length > 0 ? r : void 0;
|
|
1359
|
+
}
|
|
1360
|
+
function R() {
|
|
1361
|
+
return typeof performance != "undefined" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1362
|
+
}
|
|
1363
|
+
function Oe(e) {
|
|
1364
|
+
try {
|
|
1365
|
+
const t = new URL(e, location.href);
|
|
1366
|
+
return `${t.origin}${t.pathname.replace(/\/+$/, "") || "/"}`;
|
|
1367
|
+
} catch (t) {
|
|
1368
|
+
return null;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
function ki(e) {
|
|
1372
|
+
return typeof e == "string" ? e : typeof URL != "undefined" && e instanceof URL ? e.href : typeof Request != "undefined" && e instanceof Request ? e.url : String(e);
|
|
1373
|
+
}
|
|
1374
|
+
class Ci {
|
|
1375
|
+
constructor(t) {
|
|
1376
|
+
this.options = t, this.timing = new yi(), this.pendingXhr = /* @__PURE__ */ new WeakMap(), this.originalFetch = null, this.wrappedFetch = null, this.originalOpen = null, this.wrappedOpen = null, this.originalSend = null, this.wrappedSend = null, this.originalSetRequestHeader = null, this.wrappedSetRequestHeader = null, this.originalWebSocket = null, this.wrappedWebSocket = null, this.originalEventSource = null, this.wrappedEventSource = null, this.started = !1, this.seq = 0, this.listener = null, this.buffer = new li(
|
|
1377
|
+
t.max,
|
|
1378
|
+
t.maxBytes,
|
|
1379
|
+
(r) => this.sizeOf(r)
|
|
1380
|
+
), this.selfUrls = (t.selfUrls || []).filter(Boolean).map((r) => Oe(r)).filter((r) => r !== null), this.matchers = (t.excludeUrls || []).slice(), this.requestHeaderAllow = t.requestHeaders === !0 ? !0 : (t.requestHeaders || []).map((r) => r.toLowerCase()), this.responseHeaderAllow = t.responseHeaders === !0 ? !0 : Array.from(
|
|
1381
|
+
/* @__PURE__ */ new Set([
|
|
1382
|
+
...Z,
|
|
1383
|
+
...(t.responseHeaders || []).map((r) => r.toLowerCase())
|
|
1384
|
+
])
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1387
|
+
setListener(t) {
|
|
1388
|
+
this.listener = t;
|
|
1389
|
+
}
|
|
1390
|
+
// 这条请求是否不该采集(自身接口 / 排除规则命中)
|
|
1391
|
+
skipped(t) {
|
|
1392
|
+
try {
|
|
1393
|
+
const r = Oe(t);
|
|
1394
|
+
if (r && this.selfUrls.indexOf(r) >= 0) return !0;
|
|
1395
|
+
for (const i of this.matchers)
|
|
1396
|
+
if (_(i, t)) return !0;
|
|
1397
|
+
return !1;
|
|
1398
|
+
} catch (r) {
|
|
1399
|
+
return !1;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
// 粗估一条记录占用的字节数,用于总预算判断
|
|
1403
|
+
sizeOf(t) {
|
|
1404
|
+
let r = 0;
|
|
1405
|
+
for (const i of [t.reqHeaders, t.resHeaders])
|
|
1406
|
+
if (i)
|
|
1407
|
+
for (const n of Object.keys(i))
|
|
1408
|
+
r += S(n) + S(i[n] || "") + 6;
|
|
1409
|
+
return S(t.url || "") + S(t.reqBody || "") + S(t.resBody || "") + S(t.error || "") + S(t.contentType || "") + r + // timing 是 5 个数字字段,最多几十字节
|
|
1410
|
+
(t.timing ? 80 : 0) + 96;
|
|
1411
|
+
}
|
|
1412
|
+
start() {
|
|
1413
|
+
if (!this.started && (this.started = !0, this.patchFetch(), this.patchXhr(), this.options.realtime !== !1))
|
|
1414
|
+
try {
|
|
1415
|
+
this.patchRealtime();
|
|
1416
|
+
} catch (t) {
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
stop() {
|
|
1420
|
+
if (this.started) {
|
|
1421
|
+
if (this.started = !1, this.wrappedFetch && typeof window.fetch == "function" && window.fetch === this.wrappedFetch)
|
|
1422
|
+
try {
|
|
1423
|
+
window.fetch = this.originalFetch;
|
|
1424
|
+
} catch (t) {
|
|
1425
|
+
}
|
|
1426
|
+
if (this.wrappedOpen && XMLHttpRequest.prototype.open === this.wrappedOpen)
|
|
1427
|
+
try {
|
|
1428
|
+
XMLHttpRequest.prototype.open = this.originalOpen;
|
|
1429
|
+
} catch (t) {
|
|
1430
|
+
}
|
|
1431
|
+
if (this.wrappedSend && XMLHttpRequest.prototype.send === this.wrappedSend)
|
|
1432
|
+
try {
|
|
1433
|
+
XMLHttpRequest.prototype.send = this.originalSend;
|
|
1434
|
+
} catch (t) {
|
|
1435
|
+
}
|
|
1436
|
+
if (this.wrappedSetRequestHeader && XMLHttpRequest.prototype.setRequestHeader === this.wrappedSetRequestHeader)
|
|
1437
|
+
try {
|
|
1438
|
+
XMLHttpRequest.prototype.setRequestHeader = this.originalSetRequestHeader;
|
|
1439
|
+
} catch (t) {
|
|
1440
|
+
}
|
|
1441
|
+
if (this.wrappedWebSocket && window.WebSocket === this.wrappedWebSocket)
|
|
1442
|
+
try {
|
|
1443
|
+
window.WebSocket = this.originalWebSocket;
|
|
1444
|
+
} catch (t) {
|
|
1445
|
+
}
|
|
1446
|
+
if (this.wrappedEventSource && window.EventSource === this.wrappedEventSource)
|
|
1447
|
+
try {
|
|
1448
|
+
window.EventSource = this.originalEventSource;
|
|
1449
|
+
} catch (t) {
|
|
1450
|
+
}
|
|
1451
|
+
this.originalFetch = null, this.wrappedFetch = null, this.originalOpen = null, this.wrappedOpen = null, this.originalSend = null, this.wrappedSend = null, this.originalSetRequestHeader = null, this.wrappedSetRequestHeader = null, this.originalWebSocket = null, this.wrappedWebSocket = null, this.originalEventSource = null, this.wrappedEventSource = null;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
getRecords() {
|
|
1455
|
+
return this.buffer.toArray().map((t) => this.timing.attach(t)).sort((t, r) => t.timestamp - r.timestamp);
|
|
1456
|
+
}
|
|
1457
|
+
// 打点是否真的生效:外部库之后再包一层时,顶层函数已不是我们的包装器
|
|
1458
|
+
getPatchState() {
|
|
1459
|
+
return {
|
|
1460
|
+
fetch: !!this.wrappedFetch && typeof window.fetch == "function" && window.fetch === this.wrappedFetch,
|
|
1461
|
+
xhr: typeof XMLHttpRequest != "undefined" && !!this.wrappedOpen && !!this.wrappedSend && XMLHttpRequest.prototype.open === this.wrappedOpen && XMLHttpRequest.prototype.send === this.wrappedSend,
|
|
1462
|
+
websocket: !!this.wrappedWebSocket && typeof window.WebSocket == "function" && window.WebSocket === this.wrappedWebSocket,
|
|
1463
|
+
eventsource: !!this.wrappedEventSource && typeof window.EventSource == "function" && window.EventSource === this.wrappedEventSource
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
// 采集过程中因预算被丢弃 / 淘汰的统计
|
|
1467
|
+
getDropped() {
|
|
1468
|
+
const t = this.buffer.dropped, r = this.buffer.evicted;
|
|
1469
|
+
return {
|
|
1470
|
+
droppedCount: t.count,
|
|
1471
|
+
droppedBytes: t.bytes,
|
|
1472
|
+
evictedCount: r.count,
|
|
1473
|
+
evictedBytes: r.bytes
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
clear() {
|
|
1477
|
+
this.buffer.clear(), this.timing.clear();
|
|
1478
|
+
}
|
|
1479
|
+
patchFetch() {
|
|
1480
|
+
if (typeof window.fetch != "function") return;
|
|
1481
|
+
const t = window.fetch;
|
|
1482
|
+
this.originalFetch = t;
|
|
1483
|
+
const r = this, i = function(n, s) {
|
|
1484
|
+
if (!r.started) return t.apply(this, arguments);
|
|
1485
|
+
const o = R(), a = r.nextId(), c = Date.now(), l = ki(n), h = N(l);
|
|
1486
|
+
if (r.skipped(h))
|
|
1487
|
+
return t.apply(this, arguments);
|
|
1488
|
+
r.timing.remember(a, h, o);
|
|
1489
|
+
const u = (s && s.method || (typeof Request != "undefined" && n instanceof Request ? n.method : "GET")).toUpperCase(), d = r.requestHeadersOf(s && s.headers, n), p = r.bodyOf(s && s.body), g = p === void 0 && r.options.captureBody && typeof Request != "undefined" && n instanceof Request ? r.requestBodyOf(n) : Promise.resolve(p);
|
|
1490
|
+
let b;
|
|
1491
|
+
try {
|
|
1492
|
+
b = t.apply(this, arguments);
|
|
1493
|
+
} catch (m) {
|
|
1494
|
+
throw r.record({
|
|
1495
|
+
id: a,
|
|
1496
|
+
type: "fetch",
|
|
1497
|
+
method: u,
|
|
1498
|
+
url: h,
|
|
1499
|
+
reqHeaders: d,
|
|
1500
|
+
reqBody: p,
|
|
1501
|
+
durationMs: Math.round(R() - o),
|
|
1502
|
+
error: m instanceof Error ? m.message : String(m),
|
|
1503
|
+
timestamp: c
|
|
1504
|
+
}), m;
|
|
1505
|
+
}
|
|
1506
|
+
return b.then(
|
|
1507
|
+
(m) => (r.started && r.observeResponse(m, {
|
|
1508
|
+
id: a,
|
|
1509
|
+
method: u,
|
|
1510
|
+
url: h,
|
|
1511
|
+
start: o,
|
|
1512
|
+
timestamp: c,
|
|
1513
|
+
reqHeaders: d,
|
|
1514
|
+
reqBody: p,
|
|
1515
|
+
reqBodyLater: g
|
|
1516
|
+
}), m),
|
|
1517
|
+
(m) => {
|
|
1518
|
+
throw r.started && r.recordWithBody(
|
|
1519
|
+
{
|
|
1520
|
+
id: a,
|
|
1521
|
+
type: "fetch",
|
|
1522
|
+
method: u,
|
|
1523
|
+
url: h,
|
|
1524
|
+
reqHeaders: d,
|
|
1525
|
+
durationMs: Math.round(R() - o),
|
|
1526
|
+
error: m instanceof Error ? m.message : String(m),
|
|
1527
|
+
timestamp: c
|
|
1528
|
+
},
|
|
1529
|
+
g
|
|
1530
|
+
), m;
|
|
1531
|
+
}
|
|
1532
|
+
);
|
|
1533
|
+
};
|
|
1534
|
+
i.__bugTap = !0, this.wrappedFetch = i;
|
|
1535
|
+
try {
|
|
1536
|
+
window.fetch = i;
|
|
1537
|
+
} catch (n) {
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
patchXhr() {
|
|
1541
|
+
if (typeof XMLHttpRequest == "undefined") return;
|
|
1542
|
+
const t = this, r = XMLHttpRequest.prototype, i = r.open, n = r.send, s = r.setRequestHeader;
|
|
1543
|
+
this.originalOpen = i, this.originalSend = n, this.originalSetRequestHeader = s;
|
|
1544
|
+
const o = function(l, h) {
|
|
1545
|
+
const u = t.requestHeaderAllow;
|
|
1546
|
+
if (t.started && (u === !0 || u.length > 0))
|
|
1547
|
+
try {
|
|
1548
|
+
const d = t.pendingXhr.get(this);
|
|
1549
|
+
if (d) {
|
|
1550
|
+
const p = d.reqHeaders || {};
|
|
1551
|
+
T(p, String(l), h, u), d.reqHeaders = Object.keys(p).length > 0 ? p : void 0;
|
|
1552
|
+
}
|
|
1553
|
+
} catch (d) {
|
|
1554
|
+
}
|
|
1555
|
+
return s.call(this, l, h);
|
|
1556
|
+
}, a = function(l, h, ...u) {
|
|
1557
|
+
if (!t.started)
|
|
1558
|
+
return i.apply(this, [l, h, ...u]);
|
|
1559
|
+
try {
|
|
1560
|
+
t.pendingXhr.set(this, {
|
|
1561
|
+
id: t.nextId(),
|
|
1562
|
+
method: String(l || "GET").toUpperCase(),
|
|
1563
|
+
url: N(String(h)),
|
|
1564
|
+
start: 0,
|
|
1565
|
+
timestamp: Date.now()
|
|
1566
|
+
});
|
|
1567
|
+
} catch (d) {
|
|
1568
|
+
}
|
|
1569
|
+
return i.apply(this, [l, h, ...u]);
|
|
1570
|
+
}, c = function(l) {
|
|
1571
|
+
if (!t.started)
|
|
1572
|
+
return n.apply(this, [l]);
|
|
1573
|
+
const h = t.pendingXhr.get(this);
|
|
1574
|
+
if (h && t.skipped(h.url))
|
|
1575
|
+
return t.pendingXhr.delete(this), n.apply(this, [l]);
|
|
1576
|
+
if (h) {
|
|
1577
|
+
h.start = R(), h.timestamp = Date.now(), h.reqBody = t.bodyOf(l), t.timing.remember(h.id, h.url, h.start);
|
|
1578
|
+
try {
|
|
1579
|
+
this.addEventListener(
|
|
1580
|
+
"abort",
|
|
1581
|
+
() => {
|
|
1582
|
+
h.aborted = !0;
|
|
1583
|
+
},
|
|
1584
|
+
{ once: !0 }
|
|
1585
|
+
);
|
|
1586
|
+
} catch (u) {
|
|
1587
|
+
}
|
|
1588
|
+
try {
|
|
1589
|
+
this.addEventListener(
|
|
1590
|
+
"loadend",
|
|
1591
|
+
() => {
|
|
1592
|
+
if (t.started)
|
|
1593
|
+
try {
|
|
1594
|
+
const u = this.status, d = h.aborted === !0;
|
|
1595
|
+
t.record({
|
|
1596
|
+
id: h.id,
|
|
1597
|
+
type: "xhr",
|
|
1598
|
+
method: h.method,
|
|
1599
|
+
url: h.url,
|
|
1600
|
+
reqHeaders: h.reqHeaders,
|
|
1601
|
+
reqBody: h.reqBody,
|
|
1602
|
+
resBody: t.options.captureBody ? fi(this, t.options.maxCloneBytes) : void 0,
|
|
1603
|
+
status: u || void 0,
|
|
1604
|
+
// 主动取消没有服务端响应,不判成功也不判失败
|
|
1605
|
+
ok: d ? void 0 : u >= 200 && u < 400,
|
|
1606
|
+
durationMs: Math.round(R() - h.start),
|
|
1607
|
+
// 主动取消不算故障,避免被归入「失败请求优先」分片
|
|
1608
|
+
error: u === 0 && !d ? "Network Error" : void 0,
|
|
1609
|
+
resHeaders: t.xhrResponseHeaders(this),
|
|
1610
|
+
timestamp: h.timestamp
|
|
1611
|
+
});
|
|
1612
|
+
} catch (u) {
|
|
1613
|
+
}
|
|
1614
|
+
},
|
|
1615
|
+
{ once: !0 }
|
|
1616
|
+
);
|
|
1617
|
+
} catch (u) {
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
return n.apply(this, [l]);
|
|
1621
|
+
};
|
|
1622
|
+
this.wrappedOpen = a, this.wrappedSend = c, this.wrappedSetRequestHeader = o, this.wrappedOpen.__bugTap = !0, this.wrappedSend.__bugTap = !0, this.wrappedSetRequestHeader.__bugTap = !0;
|
|
1623
|
+
try {
|
|
1624
|
+
r.open = this.wrappedOpen, r.send = this.wrappedSend, r.setRequestHeader = this.wrappedSetRequestHeader;
|
|
1625
|
+
} catch (l) {
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* 长连接(WebSocket / EventSource)没有 fetch/XHR 那样的请求-响应模型,
|
|
1630
|
+
* 但「连接建不上 / 一直断开 / 服务端踢人」同样需要证据。
|
|
1631
|
+
*
|
|
1632
|
+
* 用「返回原生实例的包装构造函数」而不是改原型:
|
|
1633
|
+
* - 业务拿到的仍是原生实例,instanceof、addEventListener、消息回调都不受影响
|
|
1634
|
+
* - 静态常量(WebSocket.OPEN 等)通过 setPrototypeOf 继承
|
|
1635
|
+
*/
|
|
1636
|
+
patchRealtime() {
|
|
1637
|
+
this.patchWebSocket(), this.patchEventSource();
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* WebSocket 与 EventSource 的包装逐字相同,只差「怎么 new」和记录类型,
|
|
1641
|
+
* 收在这里共用;`create` 由调用方给出,保住各自的原生构造签名。
|
|
1642
|
+
*/
|
|
1643
|
+
wrapRealtime(t, r, i) {
|
|
1644
|
+
if (t.__bugTap) return null;
|
|
1645
|
+
const n = this, s = function(o, a) {
|
|
1646
|
+
const c = i(o, a);
|
|
1647
|
+
try {
|
|
1648
|
+
n.observeRealtime(c, r, String(o));
|
|
1649
|
+
} catch (l) {
|
|
1650
|
+
}
|
|
1651
|
+
return c;
|
|
1652
|
+
};
|
|
1653
|
+
return Object.setPrototypeOf(s, t), s.prototype = t.prototype, s.__bugTap = !0, s;
|
|
1654
|
+
}
|
|
1655
|
+
patchWebSocket() {
|
|
1656
|
+
if (typeof window == "undefined" || typeof window.WebSocket != "function") return;
|
|
1657
|
+
const t = window.WebSocket, r = this.wrapRealtime(
|
|
1658
|
+
t,
|
|
1659
|
+
"websocket",
|
|
1660
|
+
(i, n) => n === void 0 ? new t(i) : new t(i, n)
|
|
1661
|
+
);
|
|
1662
|
+
if (r) {
|
|
1663
|
+
this.originalWebSocket = t, this.wrappedWebSocket = r;
|
|
1664
|
+
try {
|
|
1665
|
+
window.WebSocket = this.wrappedWebSocket;
|
|
1666
|
+
} catch (i) {
|
|
1667
|
+
this.originalWebSocket = null, this.wrappedWebSocket = null;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
patchEventSource() {
|
|
1672
|
+
if (typeof window == "undefined" || typeof window.EventSource != "function") return;
|
|
1673
|
+
const t = window.EventSource, r = this.wrapRealtime(
|
|
1674
|
+
t,
|
|
1675
|
+
"eventsource",
|
|
1676
|
+
(i, n) => n === void 0 ? new t(i) : new t(i, n)
|
|
1677
|
+
);
|
|
1678
|
+
if (r) {
|
|
1679
|
+
this.originalEventSource = t, this.wrappedEventSource = r;
|
|
1680
|
+
try {
|
|
1681
|
+
window.EventSource = this.wrappedEventSource;
|
|
1682
|
+
} catch (i) {
|
|
1683
|
+
this.originalEventSource = null, this.wrappedEventSource = null;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
observeRealtime(t, r, i) {
|
|
1688
|
+
if (this.started === !1) return;
|
|
1689
|
+
const n = N(i);
|
|
1690
|
+
if (this.skipped(n)) return;
|
|
1691
|
+
const s = this.nextId(), o = R(), a = Date.now();
|
|
1692
|
+
this.pushRecord({
|
|
1693
|
+
id: s,
|
|
1694
|
+
type: r,
|
|
1695
|
+
method: r === "websocket" ? "WS" : "SSE",
|
|
1696
|
+
url: n,
|
|
1697
|
+
durationMs: 0,
|
|
1698
|
+
timestamp: a
|
|
1699
|
+
});
|
|
1700
|
+
const c = (l) => {
|
|
1701
|
+
if (this.started)
|
|
1702
|
+
try {
|
|
1703
|
+
this.buffer.update(
|
|
1704
|
+
(h) => h.id === s,
|
|
1705
|
+
(h) => ({ ...h, ...l, durationMs: Math.round(R() - o) })
|
|
1706
|
+
);
|
|
1707
|
+
} catch (h) {
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
try {
|
|
1711
|
+
t.addEventListener("open", () => c({ ok: !0, error: void 0 })), t.addEventListener(
|
|
1712
|
+
"error",
|
|
1713
|
+
() => c({
|
|
1714
|
+
ok: !1,
|
|
1715
|
+
error: r === "websocket" ? "WebSocket error" : "EventSource error"
|
|
1716
|
+
})
|
|
1717
|
+
), t.addEventListener("close", (l) => {
|
|
1718
|
+
const h = l, u = typeof h.code == "number" ? h.code : void 0, d = typeof h.reason == "string" ? h.reason : "";
|
|
1719
|
+
c({
|
|
1720
|
+
status: u,
|
|
1721
|
+
ok: u === 1e3 || u === 1005,
|
|
1722
|
+
error: u !== void 0 && u !== 1e3 && u !== 1005 ? `closed (${u}${d ? `: ${d}` : ""})` : void 0
|
|
1723
|
+
});
|
|
1724
|
+
});
|
|
1725
|
+
} catch (l) {
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
bodyOf(t) {
|
|
1729
|
+
if (this.options.captureBody)
|
|
1730
|
+
return di(t);
|
|
1731
|
+
}
|
|
1732
|
+
requestHeadersOf(t, r) {
|
|
1733
|
+
if (this.requestHeaderAllow !== !0 && this.requestHeaderAllow.length === 0) return;
|
|
1734
|
+
const i = at(t, this.requestHeaderAllow), n = typeof Request != "undefined" && r instanceof Request ? at(r.headers, this.requestHeaderAllow) : void 0;
|
|
1735
|
+
return Ei(n, i);
|
|
1736
|
+
}
|
|
1737
|
+
// XHR 没有 Headers 对象:allow=true 时读 getAllResponseHeaders,否则逐个 getResponseHeader
|
|
1738
|
+
xhrResponseHeaders(t) {
|
|
1739
|
+
try {
|
|
1740
|
+
let r;
|
|
1741
|
+
if (this.responseHeaderAllow === !0) {
|
|
1742
|
+
const n = t.getAllResponseHeaders ? t.getAllResponseHeaders() : "";
|
|
1743
|
+
if (n) return Si(n, !0);
|
|
1744
|
+
r = [...Z];
|
|
1745
|
+
} else
|
|
1746
|
+
r = this.responseHeaderAllow;
|
|
1747
|
+
const i = {};
|
|
1748
|
+
for (const n of r) {
|
|
1749
|
+
const s = t.getResponseHeader(n);
|
|
1750
|
+
s && T(i, n, s, !0);
|
|
1751
|
+
}
|
|
1752
|
+
return Object.keys(i).length > 0 ? i : void 0;
|
|
1753
|
+
} catch (r) {
|
|
1754
|
+
return;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
textOf(t) {
|
|
1758
|
+
return t || void 0;
|
|
1759
|
+
}
|
|
1760
|
+
// fetch 成功后的旁路采集:clone 响应读 body,任何异常都不能影响业务
|
|
1761
|
+
observeResponse(t, r) {
|
|
1762
|
+
var n;
|
|
1763
|
+
const { reqBodyLater: i } = r;
|
|
1764
|
+
try {
|
|
1765
|
+
const s = {
|
|
1766
|
+
id: r.id,
|
|
1767
|
+
type: "fetch",
|
|
1768
|
+
method: r.method,
|
|
1769
|
+
url: r.url,
|
|
1770
|
+
status: t.status,
|
|
1771
|
+
ok: t.ok,
|
|
1772
|
+
durationMs: Math.round(R() - r.start),
|
|
1773
|
+
timestamp: r.timestamp,
|
|
1774
|
+
contentType: t.headers.get("content-type") || void 0,
|
|
1775
|
+
reqHeaders: r.reqHeaders,
|
|
1776
|
+
resHeaders: at(t.headers, this.responseHeaderAllow)
|
|
1777
|
+
};
|
|
1778
|
+
if (!this.options.captureBody) {
|
|
1779
|
+
this.recordWithBody(s, i);
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
const o = Number(t.headers.get("content-length") || 0);
|
|
1783
|
+
if (!hr((n = s.contentType) != null ? n : null, o, this.options.maxCloneBytes)) {
|
|
1784
|
+
this.recordWithBody(s, i);
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
let a;
|
|
1788
|
+
try {
|
|
1789
|
+
a = t.clone();
|
|
1790
|
+
} catch (l) {
|
|
1791
|
+
this.recordWithBody(s, i);
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
const c = a.body;
|
|
1795
|
+
if (!c || typeof TextDecoder == "undefined") {
|
|
1796
|
+
a.text().then(
|
|
1797
|
+
(l) => this.recordWithBody(
|
|
1798
|
+
{ ...s, resBody: this.textOf(wt(l, this.options.maxCloneBytes)) },
|
|
1799
|
+
i
|
|
1800
|
+
),
|
|
1801
|
+
() => this.recordWithBody(s, i)
|
|
1802
|
+
);
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
this.recordStreaming(s, i, $e(c, this.options.maxCloneBytes));
|
|
1806
|
+
} catch (s) {
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* 传 Request 对象时用 clone 异步读 body。
|
|
1811
|
+
* 这里必须沿用 maxCloneBytes 限读:clone().text() 会把整个 body 读成字符串,
|
|
1812
|
+
* 大请求体(大 Blob / 流式上传)会直接撑爆内存。
|
|
1813
|
+
* 读到上限就 cancel 掉这一支,另一支不受影响;失败则留空,不影响业务。
|
|
1814
|
+
*/
|
|
1815
|
+
requestBodyOf(t) {
|
|
1816
|
+
if (!t.body) return Promise.resolve(void 0);
|
|
1817
|
+
try {
|
|
1818
|
+
const r = t.clone().body;
|
|
1819
|
+
return !r || typeof TextDecoder == "undefined" ? Promise.resolve(void 0) : $e(r, this.options.maxCloneBytes).then(
|
|
1820
|
+
(i) => this.textOf(i),
|
|
1821
|
+
() => {
|
|
1822
|
+
}
|
|
1823
|
+
);
|
|
1824
|
+
} catch (r) {
|
|
1825
|
+
return Promise.resolve(void 0);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* 流式响应先写入元数据,等 body 读到(或超限)后再原地补上。
|
|
1830
|
+
* 长轮询这类永不结束的流不会阻塞记录提交;补写超预算时只丢 body 不丢记录。
|
|
1831
|
+
*/
|
|
1832
|
+
recordStreaming(t, r, i) {
|
|
1833
|
+
const n = this.recordWithBody(t, r);
|
|
1834
|
+
Promise.all([n, i.catch(() => "")]).then(([, s]) => {
|
|
1835
|
+
if (!this.started) return;
|
|
1836
|
+
const o = this.textOf(s);
|
|
1837
|
+
o && this.buffer.update(
|
|
1838
|
+
(a) => a.id === t.id,
|
|
1839
|
+
(a) => a.resBody ? a : { ...a, resBody: o }
|
|
1840
|
+
);
|
|
1841
|
+
}).catch(() => {
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
// 同步记录(无 reqBody 需异步补充)
|
|
1845
|
+
record(t) {
|
|
1846
|
+
this.recordWithBody(t, Promise.resolve(t.reqBody));
|
|
1847
|
+
}
|
|
1848
|
+
// 等异步请求体就绪后再写入,避免请求体丢失;返回写入完成的 Promise
|
|
1849
|
+
recordWithBody(t, r) {
|
|
1850
|
+
return r.catch(() => {
|
|
1851
|
+
}).then((i) => {
|
|
1852
|
+
this.started && this.pushRecord(i ? { ...t, reqBody: i } : t);
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
pushRecord(t) {
|
|
1856
|
+
try {
|
|
1857
|
+
if (!t.url || t.url.startsWith("data:") || t.url.startsWith("blob:") || this.skipped(t.url)) return;
|
|
1858
|
+
if (this.buffer.push({ ...t }), this.listener)
|
|
1859
|
+
try {
|
|
1860
|
+
this.listener(t);
|
|
1861
|
+
} catch (r) {
|
|
1862
|
+
}
|
|
1863
|
+
} catch (r) {
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
nextId() {
|
|
1867
|
+
return this.seq += 1, `n${Date.now().toString(36)}${this.seq}`;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
function Li() {
|
|
1871
|
+
try {
|
|
1872
|
+
if (typeof performance == "undefined") return 0;
|
|
1873
|
+
const e = typeof performance.timeOrigin == "number" ? performance.timeOrigin : 0, t = typeof performance.getEntriesByType == "function" ? performance.getEntriesByType("navigation")[0] : void 0;
|
|
1874
|
+
if (e > 0) {
|
|
1875
|
+
const r = t && Number.isFinite(t.startTime) && t.startTime > 0 ? t.startTime : 0;
|
|
1876
|
+
return e + r;
|
|
1877
|
+
}
|
|
1878
|
+
if (typeof performance.now == "function") {
|
|
1879
|
+
const r = performance.now();
|
|
1880
|
+
if (Number.isFinite(r) && r >= 0) return Date.now() - r;
|
|
1881
|
+
}
|
|
1882
|
+
} catch (e) {
|
|
1883
|
+
}
|
|
1884
|
+
return 0;
|
|
1885
|
+
}
|
|
1886
|
+
function Ri(e) {
|
|
1887
|
+
const t = Math.max(1024, Math.floor((e.transport.maxItemBytes - 32768) / 2));
|
|
1888
|
+
return Math.min(e.collect.maxCloneBytes, t);
|
|
1889
|
+
}
|
|
1890
|
+
class _e {
|
|
1891
|
+
constructor(t) {
|
|
1892
|
+
this.config = t, this.consoleCollector = null, this.errorCollector = null, this.networkCollector = null, this.breadcrumbCollector = null, this.browserApiErrors = null, this.startedAt = 0;
|
|
1893
|
+
}
|
|
1894
|
+
start() {
|
|
1895
|
+
var r, i;
|
|
1896
|
+
const t = this.config;
|
|
1897
|
+
this.startedAt = Date.now(), t.collect.console && (this.consoleCollector = new ri({
|
|
1898
|
+
max: t.collect.maxConsoleLogs,
|
|
1899
|
+
excludePatterns: t.privacy.excludeConsolePatterns
|
|
1900
|
+
}), this.consoleCollector.start()), this.errorCollector = new ci({
|
|
1901
|
+
max: t.collect.maxErrors,
|
|
1902
|
+
ignoreErrors: t.filtering.ignoreErrors,
|
|
1903
|
+
denyUrls: t.filtering.denyUrls,
|
|
1904
|
+
allowUrls: t.filtering.allowUrls,
|
|
1905
|
+
resourceErrors: t.collect.resourceErrors
|
|
1906
|
+
}), t.collect.error && (this.errorCollector.start(), this.browserApiErrors = new Jr({
|
|
1907
|
+
capture: (n, s) => {
|
|
1908
|
+
var o;
|
|
1909
|
+
return (o = this.errorCollector) == null ? void 0 : o.captureFromBrowserApi(n, s);
|
|
1910
|
+
},
|
|
1911
|
+
// 包装 EventTarget 会给全页监听器套一层 try/catch,大型页面可关闭
|
|
1912
|
+
eventListeners: t.collect.eventListenerErrors
|
|
1913
|
+
}), this.browserApiErrors.start()), t.collect.network && (this.networkCollector = new Ci({
|
|
1914
|
+
max: t.collect.maxNetworkRecords,
|
|
1915
|
+
excludeUrls: t.privacy.excludeUrls,
|
|
1916
|
+
selfUrls: [t.endpoint, t.upload.url],
|
|
1917
|
+
captureBody: t.collect.networkBody,
|
|
1918
|
+
realtime: t.collect.realtime,
|
|
1919
|
+
requestHeaders: t.collect.requestHeaders,
|
|
1920
|
+
responseHeaders: t.collect.responseHeaders,
|
|
1921
|
+
maxBytes: t.collect.maxNetworkBytes,
|
|
1922
|
+
maxCloneBytes: Ri(t)
|
|
1923
|
+
}), this.networkCollector.start()), t.collect.breadcrumbs && (this.breadcrumbCollector = new Xr({
|
|
1924
|
+
max: t.collect.maxBreadcrumbs,
|
|
1925
|
+
dom: !0,
|
|
1926
|
+
navigation: !0,
|
|
1927
|
+
network: t.collect.network,
|
|
1928
|
+
error: t.collect.error,
|
|
1929
|
+
excludeUrls: t.privacy.excludeBreadcrumbUrls,
|
|
1930
|
+
beforeBreadcrumb: t.hooks.beforeBreadcrumb
|
|
1931
|
+
}), this.breadcrumbCollector.start(), (r = this.networkCollector) == null || r.setListener((n) => {
|
|
1932
|
+
var s;
|
|
1933
|
+
return (s = this.breadcrumbCollector) == null ? void 0 : s.addNetwork(n);
|
|
1934
|
+
}), (i = this.errorCollector) == null || i.setListener(
|
|
1935
|
+
(n) => {
|
|
1936
|
+
var s;
|
|
1937
|
+
return (s = this.breadcrumbCollector) == null ? void 0 : s.addError({
|
|
1938
|
+
message: n.message,
|
|
1939
|
+
timestamp: n.timestamp,
|
|
1940
|
+
count: n.count
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
));
|
|
1944
|
+
}
|
|
1945
|
+
stop() {
|
|
1946
|
+
var t, r, i, n, s;
|
|
1947
|
+
(t = this.consoleCollector) == null || t.stop(), (r = this.browserApiErrors) == null || r.stop(), (i = this.errorCollector) == null || i.stop(), (n = this.networkCollector) == null || n.stop(), (s = this.breadcrumbCollector) == null || s.stop(), this.consoleCollector = null, this.errorCollector = null, this.browserApiErrors = null, this.networkCollector = null, this.breadcrumbCollector = null;
|
|
1948
|
+
}
|
|
1949
|
+
getData() {
|
|
1950
|
+
const t = this.networkCollector ? this.networkCollector.getRecords() : [], r = this.consoleCollector ? this.consoleCollector.getLogs() : [], i = this.errorCollector ? this.errorCollector.getErrors() : [], n = this.networkCollector ? this.networkCollector.getPatchState() : { fetch: !1, xhr: !1, websocket: !1, eventsource: !1 }, s = Li(), o = this.breadcrumbCollector ? this.breadcrumbCollector.getBreadcrumbs() : void 0;
|
|
1951
|
+
return {
|
|
1952
|
+
logs: r,
|
|
1953
|
+
errors: i,
|
|
1954
|
+
network: t,
|
|
1955
|
+
networkDropped: this.networkCollector ? this.networkCollector.getDropped() : void 0,
|
|
1956
|
+
collector: {
|
|
1957
|
+
startedAt: this.startedAt,
|
|
1958
|
+
// > 0 说明页面在采集启动前已经跑了一段时间,首屏日志与请求不可回溯。
|
|
1959
|
+
// navigationStart 由 timeOrigin + startTime 组成,后者可能是小数,对外统一取整
|
|
1960
|
+
earlyGapMs: s > 0 && this.startedAt > s ? Math.round(this.startedAt - s) : 0,
|
|
1961
|
+
patched: {
|
|
1962
|
+
console: this.consoleCollector ? this.consoleCollector.getPatchState() : !1,
|
|
1963
|
+
fetch: n.fetch,
|
|
1964
|
+
xhr: n.xhr,
|
|
1965
|
+
error: this.errorCollector ? this.errorCollector.getPatchState() : !1,
|
|
1966
|
+
websocket: n.websocket,
|
|
1967
|
+
eventsource: n.eventsource
|
|
1968
|
+
},
|
|
1969
|
+
counts: {
|
|
1970
|
+
logs: r.length,
|
|
1971
|
+
errors: i.length,
|
|
1972
|
+
network: t.length,
|
|
1973
|
+
breadcrumbs: o ? o.length : 0
|
|
1974
|
+
},
|
|
1975
|
+
breadcrumbLimit: this.breadcrumbCollector ? this.breadcrumbCollector.limit : void 0,
|
|
1976
|
+
// > 0 说明时间线开头被挤掉了,最早的上下文不可见
|
|
1977
|
+
breadcrumbEvicted: this.breadcrumbCollector ? this.breadcrumbCollector.evicted : void 0
|
|
1978
|
+
},
|
|
1979
|
+
breadcrumbs: o
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
clear() {
|
|
1983
|
+
var t, r, i, n;
|
|
1984
|
+
(t = this.consoleCollector) == null || t.clear(), (r = this.errorCollector) == null || r.clear(), (i = this.networkCollector) == null || i.clear(), (n = this.breadcrumbCollector) == null || n.clear();
|
|
1985
|
+
}
|
|
1986
|
+
/** 业务主动上报异常,进入下一次反馈的 errors[] */
|
|
1987
|
+
captureException(t, r) {
|
|
1988
|
+
var i;
|
|
1989
|
+
(i = this.errorCollector) == null || i.captureException(t, r);
|
|
1990
|
+
}
|
|
1991
|
+
/** 业务主动上报消息,进入下一次反馈的 errors[] */
|
|
1992
|
+
captureMessage(t, r) {
|
|
1993
|
+
var i;
|
|
1994
|
+
(i = this.errorCollector) == null || i.captureMessage(t, r);
|
|
1995
|
+
}
|
|
1996
|
+
/** 业务主动写入一条时间线 */
|
|
1997
|
+
addBreadcrumb(t) {
|
|
1998
|
+
var r;
|
|
1999
|
+
(r = this.breadcrumbCollector) == null || r.add(t);
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* 交给框架路由接管导航记录,避免与主包的 history 补丁重复。
|
|
2003
|
+
* 由 vue-router 插件调用。
|
|
2004
|
+
*/
|
|
2005
|
+
disableRouteCapture() {
|
|
2006
|
+
var t;
|
|
2007
|
+
(t = this.breadcrumbCollector) == null || t.disableNavigationCapture();
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
const He = "__mcl_session_track__", ct = "_xys_s_id", vt = 2628e4, Ue = "abcdefhijklmnopqrstuvwxyz1234567890", Ti = /^cps.*\.(xinhulu|cxmuc)\.com$|^.+\.(kachabao|kachabao100)\.com$/;
|
|
2011
|
+
function ur() {
|
|
2012
|
+
try {
|
|
2013
|
+
return typeof location != "undefined" ? location.host : "";
|
|
2014
|
+
} catch (e) {
|
|
2015
|
+
return "";
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
function dr(e) {
|
|
2019
|
+
return /^niubao.*\.(xinhulu|cxmuc)\.com$/.test(e) || /^.+\.(niubao100|baichuan100)\.com$/.test(e);
|
|
2020
|
+
}
|
|
2021
|
+
function Mi(e) {
|
|
2022
|
+
return Ti.test(e);
|
|
2023
|
+
}
|
|
2024
|
+
function rt(e) {
|
|
2025
|
+
try {
|
|
2026
|
+
const t = new RegExp("(?:^|;+|\\s+)" + e + "=([^;]*)"), r = document.cookie.match(t);
|
|
2027
|
+
return r && r[1] ? r[1] : "";
|
|
2028
|
+
} catch (t) {
|
|
2029
|
+
return "";
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
function xt(e, t, r) {
|
|
2033
|
+
try {
|
|
2034
|
+
const i = /* @__PURE__ */ new Date();
|
|
2035
|
+
i.setMinutes(i.getMinutes() + r), document.cookie = `${e}=${escape(t)};expires=${i.toUTCString()};path=/`;
|
|
2036
|
+
} catch (i) {
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function Ai(e) {
|
|
2040
|
+
try {
|
|
2041
|
+
if (typeof localStorage != "undefined") return localStorage.getItem(e);
|
|
2042
|
+
} catch (t) {
|
|
2043
|
+
}
|
|
2044
|
+
return rt(e);
|
|
2045
|
+
}
|
|
2046
|
+
function Pi(e, t) {
|
|
2047
|
+
try {
|
|
2048
|
+
if (typeof localStorage != "undefined") {
|
|
2049
|
+
localStorage.setItem(e, t);
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
} catch (r) {
|
|
2053
|
+
}
|
|
2054
|
+
xt(e, t, vt);
|
|
2055
|
+
}
|
|
2056
|
+
function je(e) {
|
|
2057
|
+
let t = "";
|
|
2058
|
+
for (let r = 0; r < e; r += 1)
|
|
2059
|
+
t += Ue.charAt(Math.floor(Math.random() * Ue.length));
|
|
2060
|
+
return t;
|
|
2061
|
+
}
|
|
2062
|
+
function Bi() {
|
|
2063
|
+
const e = ur();
|
|
2064
|
+
let t = "xxid";
|
|
2065
|
+
return Mi(e) ? t = "cps_xxid" : dr(e) && (t = "niubao_xxid"), rt(t);
|
|
2066
|
+
}
|
|
2067
|
+
function Ii() {
|
|
2068
|
+
return dr(ur()) ? rt("niubao_subid") : null;
|
|
2069
|
+
}
|
|
2070
|
+
function $i() {
|
|
2071
|
+
let e = Ai(He);
|
|
2072
|
+
const t = rt(ct);
|
|
2073
|
+
return e ? (e !== t && xt(ct, e, vt), e) : (t ? e = t : (e = je(24) + je(8), xt(ct, e, vt)), Pi(He, e), e);
|
|
2074
|
+
}
|
|
2075
|
+
function fr() {
|
|
2076
|
+
try {
|
|
2077
|
+
const e = window.tongji;
|
|
2078
|
+
return e && typeof e == "object" ? e : null;
|
|
2079
|
+
} catch (e) {
|
|
2080
|
+
return null;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
function lt(e, t) {
|
|
2084
|
+
let r;
|
|
2085
|
+
if (typeof e == "function")
|
|
2086
|
+
try {
|
|
2087
|
+
r = e.call(fr());
|
|
2088
|
+
} catch (i) {
|
|
2089
|
+
}
|
|
2090
|
+
if ((r == null || r === "") && (r = t()), !(r == null || r === ""))
|
|
2091
|
+
return String(r);
|
|
2092
|
+
}
|
|
2093
|
+
let Et, J = 0;
|
|
2094
|
+
const Oi = 3e4;
|
|
2095
|
+
function _i() {
|
|
2096
|
+
if (typeof document == "undefined") return;
|
|
2097
|
+
const e = Date.now();
|
|
2098
|
+
if (J > 0 && e - J < Oi) return Et;
|
|
2099
|
+
try {
|
|
2100
|
+
const t = fr(), r = lt(t == null ? void 0 : t.getXid, Bi), i = lt(t == null ? void 0 : t.getSubId, Ii), n = lt(t == null ? void 0 : t.getSessionId, $i), s = r || i || n ? { xid: r, subId: i, sessionId: n } : void 0;
|
|
2101
|
+
return Et = s, J = e, s;
|
|
2102
|
+
} catch (t) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
function Hi() {
|
|
2107
|
+
Et = void 0, J = 0;
|
|
2108
|
+
}
|
|
2109
|
+
function ze(e, t) {
|
|
2110
|
+
for (const [r, i] of t) {
|
|
2111
|
+
const n = e.match(r);
|
|
2112
|
+
if (n) return { name: i, version: n[1] };
|
|
2113
|
+
}
|
|
2114
|
+
return null;
|
|
2115
|
+
}
|
|
2116
|
+
function Ui(e) {
|
|
2117
|
+
const t = String(e || ""), r = ze(t, [
|
|
2118
|
+
[/MicroMessenger\/([\d.]+)/i, "WeChat"],
|
|
2119
|
+
[/AlipayClient\/([\d.]+)/i, "Alipay"],
|
|
2120
|
+
[/Edg\/([\d.]+)/i, "Edge"],
|
|
2121
|
+
[/OPR\/([\d.]+)/i, "Opera"],
|
|
2122
|
+
[/Firefox\/([\d.]+)/i, "Firefox"],
|
|
2123
|
+
[/Chrome\/([\d.]+)/i, "Chrome"],
|
|
2124
|
+
[/Version\/([\d.]+).*Safari/i, "Safari"],
|
|
2125
|
+
[/MSIE ([\d.]+)/i, "IE"],
|
|
2126
|
+
[/Trident\/.*rv:([\d.]+)/i, "IE"]
|
|
2127
|
+
]), i = ze(t, [
|
|
2128
|
+
[/HarmonyOS/i, "HarmonyOS"],
|
|
2129
|
+
[/Windows NT 10\.0/i, "Windows"],
|
|
2130
|
+
[/Windows NT/i, "Windows"],
|
|
2131
|
+
[/Android[ /]([\d.]+)/i, "Android"],
|
|
2132
|
+
[/(?:iPhone|iPad|iPod).*OS ([\d_]+)/i, "iOS"],
|
|
2133
|
+
[/Mac OS X/i, "macOS"],
|
|
2134
|
+
[/Linux/i, "Linux"]
|
|
2135
|
+
]);
|
|
2136
|
+
return {
|
|
2137
|
+
browser: r == null ? void 0 : r.name,
|
|
2138
|
+
browserVersion: r == null ? void 0 : r.version,
|
|
2139
|
+
os: i == null ? void 0 : i.name
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
function pr() {
|
|
2143
|
+
return {
|
|
2144
|
+
url: location.href,
|
|
2145
|
+
// 刷新页面时 referrer 与当前地址相同,没有额外信息,省掉这几十字节
|
|
2146
|
+
referrer: document.referrer && document.referrer !== location.href ? document.referrer : void 0,
|
|
2147
|
+
title: document.title || void 0
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
function gr(e) {
|
|
2151
|
+
const t = Number.isFinite(e) && e > 0 ? e : 1;
|
|
2152
|
+
return Math.round(t * 100) / 100;
|
|
2153
|
+
}
|
|
2154
|
+
function ji(e, t, r) {
|
|
2155
|
+
return `${e || 0}*${t || 0} @ ${gr(r)}x`;
|
|
2156
|
+
}
|
|
2157
|
+
function zi(e) {
|
|
2158
|
+
const t = navigator.userAgent, r = Ui(t);
|
|
2159
|
+
let i = "";
|
|
2160
|
+
try {
|
|
2161
|
+
i = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
|
|
2162
|
+
} catch (c) {
|
|
2163
|
+
i = "";
|
|
2164
|
+
}
|
|
2165
|
+
const n = typeof window.screen != "undefined" ? window.screen : void 0, s = n && (n.width || n.availWidth) || 0, o = n && (n.height || n.availHeight) || 0, a = gr(window.devicePixelRatio || 1);
|
|
2166
|
+
return {
|
|
2167
|
+
userAgent: t,
|
|
2168
|
+
platform: navigator.platform || void 0,
|
|
2169
|
+
browser: r.browser,
|
|
2170
|
+
browserVersion: r.browserVersion,
|
|
2171
|
+
os: r.os,
|
|
2172
|
+
screenWidth: s,
|
|
2173
|
+
screenHeight: o,
|
|
2174
|
+
viewportWidth: window.innerWidth,
|
|
2175
|
+
viewportHeight: window.innerHeight,
|
|
2176
|
+
dpr: a,
|
|
2177
|
+
device: ji(s, o, a),
|
|
2178
|
+
language: navigator.language || "",
|
|
2179
|
+
timezone: i
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
function Di(e) {
|
|
2183
|
+
return {
|
|
2184
|
+
page: pr(),
|
|
2185
|
+
browser: zi()
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
const Ni = 30, De = 200;
|
|
2189
|
+
function qi(e) {
|
|
2190
|
+
if (!e) return;
|
|
2191
|
+
let t = e;
|
|
2192
|
+
if (typeof e == "function")
|
|
2193
|
+
try {
|
|
2194
|
+
t = e();
|
|
2195
|
+
} catch (s) {
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
const r = rr(t);
|
|
2199
|
+
if (!r || typeof r == "function") return;
|
|
2200
|
+
const i = {};
|
|
2201
|
+
let n = 0;
|
|
2202
|
+
for (const s of Object.keys(r)) {
|
|
2203
|
+
if (n >= Ni) break;
|
|
2204
|
+
const o = String(r[s]).trim();
|
|
2205
|
+
o && (i[s] = o.length > De ? o.slice(0, De) : o, n += 1);
|
|
2206
|
+
}
|
|
2207
|
+
return n > 0 ? i : void 0;
|
|
2208
|
+
}
|
|
2209
|
+
const Fi = 200, Wi = 5e3, x = 15e5;
|
|
2210
|
+
function L(e, t) {
|
|
2211
|
+
return e.length > t ? e.slice(0, t) : e;
|
|
2212
|
+
}
|
|
2213
|
+
function Xi(e) {
|
|
2214
|
+
return ((String(e || "").split(`
|
|
2215
|
+
`)[0] || "").trim() || "页面反馈").slice(0, 60);
|
|
2216
|
+
}
|
|
2217
|
+
function Vi() {
|
|
2218
|
+
try {
|
|
2219
|
+
if (typeof crypto != "undefined" && typeof crypto.randomUUID == "function")
|
|
2220
|
+
return crypto.randomUUID();
|
|
2221
|
+
} catch (e) {
|
|
2222
|
+
}
|
|
2223
|
+
return `r${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
|
|
2224
|
+
}
|
|
2225
|
+
const Yi = {
|
|
2226
|
+
userAgent: "",
|
|
2227
|
+
screenWidth: 0,
|
|
2228
|
+
screenHeight: 0,
|
|
2229
|
+
viewportWidth: 0,
|
|
2230
|
+
viewportHeight: 0,
|
|
2231
|
+
dpr: 1,
|
|
2232
|
+
device: "0*0 @ 1x",
|
|
2233
|
+
language: "",
|
|
2234
|
+
timezone: ""
|
|
2235
|
+
};
|
|
2236
|
+
function ht(e) {
|
|
2237
|
+
return e && e.length > 0 ? e : void 0;
|
|
2238
|
+
}
|
|
2239
|
+
function Ki(e) {
|
|
2240
|
+
const { values: t, data: r, config: i } = e, n = i.collect.environment ? Di() : { page: pr(), browser: { ...Yi } }, s = L(String(t.description || "").trim(), Wi), o = L(String(t.title || "").trim() || Xi(s), Fi), a = Gi(e.elements, i.collect.maxElements), c = {
|
|
2241
|
+
project: i.project,
|
|
2242
|
+
environment: i.environment,
|
|
2243
|
+
title: o,
|
|
2244
|
+
description: s,
|
|
2245
|
+
category: t.category ? L(String(t.category), 40) : void 0,
|
|
2246
|
+
severity: t.severity ? L(String(t.severity), 20) : void 0,
|
|
2247
|
+
contact: t.contact ? L(String(t.contact), 200) : void 0,
|
|
2248
|
+
// 提交这一刻求值,使用最新的登录身份
|
|
2249
|
+
user: qi(i.user),
|
|
2250
|
+
// 与 tongji 打通:xid / subId / sessionId,取不到则为 undefined
|
|
2251
|
+
track: i.collect.trackIds ? _i() : void 0,
|
|
2252
|
+
page: n.page,
|
|
2253
|
+
browser: n.browser,
|
|
2254
|
+
logs: r.logs,
|
|
2255
|
+
errors: r.errors,
|
|
2256
|
+
network: r.network,
|
|
2257
|
+
networkDropped: Qi(r, i.collect.network),
|
|
2258
|
+
screenshots: ht(e.screenshots),
|
|
2259
|
+
elements: ht(a),
|
|
2260
|
+
breadcrumbs: ht(r.breadcrumbs),
|
|
2261
|
+
collector: r.collector,
|
|
2262
|
+
app: Ji(i),
|
|
2263
|
+
release: i.release || void 0,
|
|
2264
|
+
tags: ut(e.tags),
|
|
2265
|
+
extra: ut(e.extra),
|
|
2266
|
+
contexts: ut(e.contexts),
|
|
2267
|
+
timestamp: Date.now(),
|
|
2268
|
+
sdkVersion: "0.1.0",
|
|
2269
|
+
clientReportId: e.clientReportId || Vi()
|
|
2270
|
+
};
|
|
2271
|
+
return tn(c);
|
|
2272
|
+
}
|
|
2273
|
+
function Gi(e, t) {
|
|
2274
|
+
if (!(!e || e.length === 0))
|
|
2275
|
+
return e.slice(-Math.max(1, t)).map((r) => {
|
|
2276
|
+
const i = {};
|
|
2277
|
+
return Object.keys(r.attributes || {}).slice(0, 20).forEach((n) => {
|
|
2278
|
+
var s;
|
|
2279
|
+
i[n] = L(String((s = r.attributes[n]) != null ? s : ""), 200);
|
|
2280
|
+
}), {
|
|
2281
|
+
...r,
|
|
2282
|
+
selector: L(r.selector, 300),
|
|
2283
|
+
text: r.text ? L(r.text, 200) : void 0,
|
|
2284
|
+
attributes: i,
|
|
2285
|
+
path: L(r.path, 300)
|
|
2286
|
+
};
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
function ut(e) {
|
|
2290
|
+
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2291
|
+
}
|
|
2292
|
+
function Ji(e) {
|
|
2293
|
+
if (!(!e.appVersion && !e.buildId))
|
|
2294
|
+
return {
|
|
2295
|
+
version: e.appVersion || void 0,
|
|
2296
|
+
buildId: e.buildId || void 0
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
function Qi(e, t) {
|
|
2300
|
+
if (!t)
|
|
2301
|
+
return {
|
|
2302
|
+
droppedCount: 0,
|
|
2303
|
+
droppedBytes: 0,
|
|
2304
|
+
evictedCount: 0,
|
|
2305
|
+
evictedBytes: 0,
|
|
2306
|
+
totalCount: null,
|
|
2307
|
+
sentCount: 0
|
|
2308
|
+
};
|
|
2309
|
+
const r = e.networkDropped || {
|
|
2310
|
+
droppedCount: 0,
|
|
2311
|
+
droppedBytes: 0,
|
|
2312
|
+
evictedCount: 0,
|
|
2313
|
+
evictedBytes: 0
|
|
2314
|
+
}, i = ar(r);
|
|
2315
|
+
return {
|
|
2316
|
+
...r,
|
|
2317
|
+
totalCount: i + e.network.length,
|
|
2318
|
+
sentCount: e.network.length
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
function A(e) {
|
|
2322
|
+
return B(e, x + 1);
|
|
2323
|
+
}
|
|
2324
|
+
function Zi(e) {
|
|
2325
|
+
return e.map((t) => B(t, x + 1) + 1);
|
|
2326
|
+
}
|
|
2327
|
+
function U(e, t, r, i) {
|
|
2328
|
+
const n = e[t];
|
|
2329
|
+
if (!n || n.length <= r) return;
|
|
2330
|
+
const s = Zi(n), o = B({ ...e, [t]: [] }, x + 1), a = new Array(n.length + 1);
|
|
2331
|
+
a[0] = 0;
|
|
2332
|
+
for (let h = 0; h < s.length; h += 1) a[h + 1] = (a[h] || 0) + (s[h] || 0);
|
|
2333
|
+
const c = a[n.length] || 0;
|
|
2334
|
+
let l = 0;
|
|
2335
|
+
for (; n.length - l > r; ) {
|
|
2336
|
+
const h = n.length - l;
|
|
2337
|
+
if (o + (c - (a[l] || 0)) - 1 <= x) break;
|
|
2338
|
+
l += Math.max(1, Math.min(i(h), h - r));
|
|
2339
|
+
}
|
|
2340
|
+
l > 0 && (e[t] = n.slice(l));
|
|
2341
|
+
}
|
|
2342
|
+
function X(e) {
|
|
2343
|
+
return (t) => Math.ceil(t / e);
|
|
2344
|
+
}
|
|
2345
|
+
function Ne(e, t) {
|
|
2346
|
+
return e.map((r) => t && !t(r) ? r : { ...r, reqBody: void 0, resBody: void 0 });
|
|
2347
|
+
}
|
|
2348
|
+
function tn(e) {
|
|
2349
|
+
if (A(e) <= x) return e;
|
|
2350
|
+
const t = e.network.length;
|
|
2351
|
+
if (e.network = Ne(e.network, zr), A(e) <= x || (e.network = Ne(e.network), A(e) <= x)) return dt(e, t);
|
|
2352
|
+
if (U(e, "network", 0, X(8)), U(e, "logs", 0, X(4)), U(e, "errors", 0, X(2)), e.screenshots && A(e) > x) {
|
|
2353
|
+
const i = e.screenshots.filter((n) => n.source === "manual");
|
|
2354
|
+
i.length > 0 ? e.screenshots = i : delete e.screenshots;
|
|
2355
|
+
}
|
|
2356
|
+
return qe(e, "extra"), qe(e, "contexts"), U(e, "elements", 1, () => 1), e.elements && A(e) > x && delete e.elements, U(e, "breadcrumbs", 10, X(2)), e.screenshots && A(e) > x && delete e.screenshots, en(e), rn(e), dt(e, t);
|
|
2357
|
+
}
|
|
2358
|
+
function qe(e, t) {
|
|
2359
|
+
const r = e[t];
|
|
2360
|
+
if (!r) return;
|
|
2361
|
+
const i = Object.keys(r);
|
|
2362
|
+
for (; i.length > 0 && A(e) > x; ) {
|
|
2363
|
+
const n = i.shift();
|
|
2364
|
+
if (n === void 0) break;
|
|
2365
|
+
delete r[n];
|
|
2366
|
+
}
|
|
2367
|
+
Object.keys(r).length === 0 && delete e[t];
|
|
2368
|
+
}
|
|
2369
|
+
function en(e) {
|
|
2370
|
+
if (!e.breadcrumbs || e.breadcrumbs.length === 0) return;
|
|
2371
|
+
const t = new Set(e.network.map((r) => r.id));
|
|
2372
|
+
e.breadcrumbs = e.breadcrumbs.map((r) => r.type !== "http" || !r.ref || t.has(r.ref) ? r : { ...r, ref: void 0, httpError: r.httpError || "[record trimmed]" });
|
|
2373
|
+
}
|
|
2374
|
+
function rn(e) {
|
|
2375
|
+
e.collector && (e.collector = {
|
|
2376
|
+
...e.collector,
|
|
2377
|
+
counts: {
|
|
2378
|
+
logs: e.logs.length,
|
|
2379
|
+
errors: e.errors.length,
|
|
2380
|
+
network: e.network.length,
|
|
2381
|
+
breadcrumbs: e.breadcrumbs ? e.breadcrumbs.length : 0
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
function dt(e, t) {
|
|
2386
|
+
const r = t - e.network.length;
|
|
2387
|
+
return e.networkDropped && (e.networkDropped = {
|
|
2388
|
+
...e.networkDropped,
|
|
2389
|
+
trimmedCount: r,
|
|
2390
|
+
sentCount: e.network.length
|
|
2391
|
+
}), e;
|
|
2392
|
+
}
|
|
2393
|
+
const nn = 200, sn = 500, Fe = 32, M = 64, on = 512;
|
|
2394
|
+
function k(e, t) {
|
|
2395
|
+
const r = String(e != null ? e : "").replace(/\s+/g, " ").trim();
|
|
2396
|
+
return r.length > t ? `${r.slice(0, t)}…` : r;
|
|
2397
|
+
}
|
|
2398
|
+
function an(e) {
|
|
2399
|
+
return e.severity === "normal" ? 2 : 3;
|
|
2400
|
+
}
|
|
2401
|
+
function cn(e, t) {
|
|
2402
|
+
return t === 1 || t === 2 || t === 3 ? t : an(e);
|
|
2403
|
+
}
|
|
2404
|
+
function ln(e) {
|
|
2405
|
+
return (e.clientReportId.replace(/[^0-9a-zA-Z]/g, "") + "0".repeat(Fe)).slice(0, Fe);
|
|
2406
|
+
}
|
|
2407
|
+
function hn(e) {
|
|
2408
|
+
let t = e.browser.userAgent;
|
|
2409
|
+
return !t && typeof navigator != "undefined" && (t = navigator.userAgent), `H5, ${t || "unknown userAgent"}`;
|
|
2410
|
+
}
|
|
2411
|
+
function mr(e) {
|
|
2412
|
+
return e.page.url ? e.page.url : typeof location != "undefined" ? location.href : "";
|
|
2413
|
+
}
|
|
2414
|
+
function un(e) {
|
|
2415
|
+
var a;
|
|
2416
|
+
const t = e.errors;
|
|
2417
|
+
let r = t.findIndex((c) => c.type !== "resource" && !!c.stack);
|
|
2418
|
+
r < 0 && (r = t.findIndex((c) => c.type !== "resource")), r < 0 && (r = t.length > 0 ? 0 : -1);
|
|
2419
|
+
const i = r >= 0 ? t[r] : void 0, n = i && (((a = Ct(i.stack)) == null ? void 0 : a.url) || i.filename) || "", s = i ? `${i.type}|${i.message}|${n}` : `feedback|${e.project}|${e.title}`;
|
|
2420
|
+
let o = 2166136261;
|
|
2421
|
+
for (let c = 0; c < s.length; c += 1)
|
|
2422
|
+
o ^= s.charCodeAt(c), o = Math.imul(o, 16777619);
|
|
2423
|
+
return { primaryIndex: r, fingerprint: `bt-${(o >>> 0).toString(16).padStart(8, "0")}` };
|
|
2424
|
+
}
|
|
2425
|
+
function dn(e) {
|
|
2426
|
+
if (!e) return "";
|
|
2427
|
+
const t = Object.keys(e).slice(0, 5).map((r) => `${r}=${k(e[r], M)}`);
|
|
2428
|
+
return t.length > 0 ? ` ${t.join(" ")}` : "";
|
|
2429
|
+
}
|
|
2430
|
+
function fn(e, t, r) {
|
|
2431
|
+
var g, b;
|
|
2432
|
+
const i = k(e.title, nn), n = k(e.description, sn), s = n && n === i ? "" : n, o = ar(e.networkDropped), a = mn(e.user), c = pn(e.track), l = e.collector ? Math.round(e.collector.earlyGapMs) : 0, h = gn(e), u = ((g = e.collector) == null ? void 0 : g.breadcrumbEvicted) || 0, d = ((b = e.networkDropped) == null ? void 0 : b.totalCount) === null, p = [
|
|
2433
|
+
"【Bug反馈】",
|
|
2434
|
+
i || "(无标题)",
|
|
2435
|
+
s ? ` | ${s}` : "",
|
|
2436
|
+
e.elements && e.elements.length > 0 ? ` | element=${e.elements.map((m) => m.selector).join(",")}` : "",
|
|
2437
|
+
` | project=${e.project}`,
|
|
2438
|
+
` env=${e.environment}`,
|
|
2439
|
+
a ? ` user=${a}` : "",
|
|
2440
|
+
c,
|
|
2441
|
+
e.release ? ` release=${k(e.release, M)}` : "",
|
|
2442
|
+
` fp=${t.fingerprint}`,
|
|
2443
|
+
dn(e.tags),
|
|
2444
|
+
` reportId=${e.clientReportId}`,
|
|
2445
|
+
d ? " | networkDisabled" : "",
|
|
2446
|
+
o > 0 ? ` | networkDropped=${o}` : "",
|
|
2447
|
+
// 采集盲区必须显眼:否则「logs/network 为空」会被误读成「页面没发生任何事」
|
|
2448
|
+
l > 0 ? ` | earlyGap=${l}ms` : "",
|
|
2449
|
+
u > 0 ? ` | timelineEvicted=${u}` : "",
|
|
2450
|
+
h ? ` | ${h}` : ""
|
|
2451
|
+
].join("");
|
|
2452
|
+
return !r || r.total <= 1 ? p : `${p} | part=${r.index}/${r.total}`;
|
|
2453
|
+
}
|
|
2454
|
+
function pn(e) {
|
|
2455
|
+
if (!e) return "";
|
|
2456
|
+
const t = [];
|
|
2457
|
+
return e.xid && t.push(`xid=${k(e.xid, M)}`), e.subId && t.push(`subId=${k(e.subId, M)}`), e.sessionId && t.push(`si=${k(e.sessionId, M)}`), t.length > 0 ? ` ${t.join(" ")}` : "";
|
|
2458
|
+
}
|
|
2459
|
+
function gn(e) {
|
|
2460
|
+
if (!e.app) return "";
|
|
2461
|
+
const t = [];
|
|
2462
|
+
return e.app.version && t.push(`app=${k(e.app.version, M)}`), e.app.buildId && t.push(`build=${k(e.app.buildId, M)}`), t.join(" ");
|
|
2463
|
+
}
|
|
2464
|
+
function mn(e) {
|
|
2465
|
+
var r, i, n, s;
|
|
2466
|
+
if (!e) return "";
|
|
2467
|
+
const t = (s = (n = (i = (r = e.id) != null ? r : e.name) != null ? i : e.userId) != null ? n : e.account) != null ? s : Object.values(e)[0];
|
|
2468
|
+
return t === void 0 ? "" : k(t, M);
|
|
2469
|
+
}
|
|
2470
|
+
function bn(e) {
|
|
2471
|
+
const t = { ...e.page };
|
|
2472
|
+
return (!t.url || t.url === mr(e)) && delete t.url, t;
|
|
2473
|
+
}
|
|
2474
|
+
function yn(e, t) {
|
|
2475
|
+
return {
|
|
2476
|
+
project: e.project,
|
|
2477
|
+
environment: e.environment,
|
|
2478
|
+
sdkVersion: e.sdkVersion,
|
|
2479
|
+
clientReportId: e.clientReportId,
|
|
2480
|
+
release: e.release,
|
|
2481
|
+
fingerprint: t.fingerprint,
|
|
2482
|
+
// errors[] 按采集时间排列,第一个不一定是主错误;用这个下标直接取
|
|
2483
|
+
primaryErrorIndex: t.primaryIndex,
|
|
2484
|
+
title: e.title,
|
|
2485
|
+
description: e.description,
|
|
2486
|
+
category: e.category,
|
|
2487
|
+
severity: e.severity,
|
|
2488
|
+
contact: e.contact,
|
|
2489
|
+
user: e.user,
|
|
2490
|
+
track: e.track,
|
|
2491
|
+
page: bn(e),
|
|
2492
|
+
browser: e.browser,
|
|
2493
|
+
networkDropped: e.networkDropped,
|
|
2494
|
+
// 排障线索:采集器健康状态、业务构建号、操作轨迹
|
|
2495
|
+
collector: e.collector,
|
|
2496
|
+
app: e.app,
|
|
2497
|
+
breadcrumbs: e.breadcrumbs,
|
|
2498
|
+
tags: e.tags,
|
|
2499
|
+
extra: e.extra,
|
|
2500
|
+
contexts: e.contexts
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
function wn(e) {
|
|
2504
|
+
return B(e) + 1;
|
|
2505
|
+
}
|
|
2506
|
+
function tt() {
|
|
2507
|
+
return { network: [], errors: [], logs: [], bytes: 0 };
|
|
2508
|
+
}
|
|
2509
|
+
function vn(e, t) {
|
|
2510
|
+
const r = [tt()];
|
|
2511
|
+
let i = t;
|
|
2512
|
+
const n = (a, c) => {
|
|
2513
|
+
for (const l of a) {
|
|
2514
|
+
const h = wn(l), u = r[r.length - 1], d = u.network.length + u.errors.length + u.logs.length;
|
|
2515
|
+
h > i && d > 0 && (r.push(tt()), i = t);
|
|
2516
|
+
const p = r[r.length - 1];
|
|
2517
|
+
p[c].push(l), p.bytes += h, i -= h;
|
|
2518
|
+
}
|
|
2519
|
+
}, s = [], o = [];
|
|
2520
|
+
for (const a of e.network)
|
|
2521
|
+
(or(a) ? s : o).push(a);
|
|
2522
|
+
return n(s, "network"), n(e.errors, "errors"), n(o, "network"), n(e.logs, "logs"), r;
|
|
2523
|
+
}
|
|
2524
|
+
function xn(e, t, r) {
|
|
2525
|
+
const i = un(e), n = yn(e, i), s = e.screenshots && e.screenshots.length > 0 ? e.screenshots : void 0, o = e.elements && e.elements.length > 0 ? e.elements : void 0, a = o ? B(o) : 0, c = B(n) + on + (s ? B(s) : 0), l = Math.max(1024, t - c), h = vn(e, l), u = h.length > 0 ? h : [tt()];
|
|
2526
|
+
let d = -1;
|
|
2527
|
+
return o && (c + u[0].bytes + a + 1 <= t ? d = 0 : (u.push(tt()), d = u.length - 1)), u.map((p, g) => {
|
|
2528
|
+
const b = { ...n };
|
|
2529
|
+
return b.network = p.network.slice().sort((m, I) => m.timestamp - I.timestamp), b.errors = p.errors, b.logs = p.logs, u.length > 1 && (b.part = { index: g + 1, total: u.length }), g === 0 && s && (b.screenshots = s), g === d && o && (b.elements = o), {
|
|
2530
|
+
timestamp: e.timestamp,
|
|
2531
|
+
logLevel: cn(e, r),
|
|
2532
|
+
userAgent: hn(e),
|
|
2533
|
+
url: mr(e),
|
|
2534
|
+
content: fn(e, i, { index: g + 1, total: u.length }),
|
|
2535
|
+
traceId: ln(e),
|
|
2536
|
+
ext: JSON.stringify(b)
|
|
2537
|
+
};
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
const En = "bug-tap", E = "pending", Sn = 1;
|
|
2541
|
+
function kn() {
|
|
2542
|
+
return typeof indexedDB == "undefined" ? Promise.resolve(null) : new Promise((e) => {
|
|
2543
|
+
try {
|
|
2544
|
+
const t = indexedDB.open(En, Sn);
|
|
2545
|
+
t.onupgradeneeded = () => {
|
|
2546
|
+
const r = t.result;
|
|
2547
|
+
r.objectStoreNames.contains(E) || r.createObjectStore(E, { keyPath: "id" });
|
|
2548
|
+
}, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
|
|
2549
|
+
} catch (t) {
|
|
2550
|
+
e(null);
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
class Cn {
|
|
2555
|
+
constructor(t) {
|
|
2556
|
+
this.options = t, this.memory = [], this.db = null;
|
|
2557
|
+
}
|
|
2558
|
+
database() {
|
|
2559
|
+
return this.db || (this.db = kn()), this.db;
|
|
2560
|
+
}
|
|
2561
|
+
/** 写入一条待发记录;超出容量或过期的旧记录会被清掉 */
|
|
2562
|
+
enqueue(t) {
|
|
2563
|
+
return this.database().then((r) => {
|
|
2564
|
+
if (!r) {
|
|
2565
|
+
this.putMemory(t);
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
return this.put(r, t).then((i) => (i || this.putMemory(t), this.prune(r)));
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
/** 返回是否真正写入了 DB;失败时由调用方退回内存 */
|
|
2572
|
+
put(t, r) {
|
|
2573
|
+
return new Promise((i) => {
|
|
2574
|
+
try {
|
|
2575
|
+
const n = t.transaction(E, "readwrite");
|
|
2576
|
+
n.objectStore(E).put(r), n.oncomplete = () => i(!0), n.onerror = () => i(!1), n.onabort = () => i(!1);
|
|
2577
|
+
} catch (n) {
|
|
2578
|
+
i(!1);
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2582
|
+
/**
|
|
2583
|
+
* 清理过期与超出容量的记录。
|
|
2584
|
+
* 单独一个事务:在 getAll 的 onsuccess 里直接 delete,避免事务在微任务之间被提交。
|
|
2585
|
+
*/
|
|
2586
|
+
prune(t) {
|
|
2587
|
+
return new Promise((r) => {
|
|
2588
|
+
try {
|
|
2589
|
+
const i = t.transaction(E, "readwrite"), n = i.objectStore(E), s = n.getAll();
|
|
2590
|
+
s.onsuccess = () => {
|
|
2591
|
+
const o = (s.result || []).sort(
|
|
2592
|
+
(h, u) => h.createdAt - u.createdAt
|
|
2593
|
+
), a = [], c = [];
|
|
2594
|
+
for (const h of o)
|
|
2595
|
+
(this.isExpired(h) ? a : c).push(h);
|
|
2596
|
+
const l = Math.max(0, c.length - this.options.maxItems);
|
|
2597
|
+
a.concat(c.slice(0, l)).forEach((h) => {
|
|
2598
|
+
try {
|
|
2599
|
+
n.delete(h.id);
|
|
2600
|
+
} catch (u) {
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
}, s.onerror = () => r(), i.oncomplete = () => r(), i.onerror = () => r(), i.onabort = () => r();
|
|
2604
|
+
} catch (i) {
|
|
2605
|
+
r();
|
|
2606
|
+
}
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* 按入队顺序取出未过期的记录。
|
|
2611
|
+
* 内存兜底里的条目也要一起返回:DB 写入失败时它们只存在于内存,
|
|
2612
|
+
* 只看 DB 会让这些「已保存」的记录永远发不出去。
|
|
2613
|
+
*/
|
|
2614
|
+
peek() {
|
|
2615
|
+
return this.database().then((t) => t ? new Promise((r) => {
|
|
2616
|
+
try {
|
|
2617
|
+
const n = t.transaction(E, "readonly").objectStore(E).getAll();
|
|
2618
|
+
n.onsuccess = () => {
|
|
2619
|
+
const s = n.result || [], o = new Set(s.map((c) => c.id)), a = s.concat(this.memory.filter((c) => !o.has(c.id)));
|
|
2620
|
+
r(
|
|
2621
|
+
a.filter((c) => !this.isExpired(c)).sort((c, l) => c.createdAt - l.createdAt)
|
|
2622
|
+
);
|
|
2623
|
+
}, n.onerror = () => r(this.memoryItems());
|
|
2624
|
+
} catch (i) {
|
|
2625
|
+
r(this.memoryItems());
|
|
2626
|
+
}
|
|
2627
|
+
}) : this.memoryItems());
|
|
2628
|
+
}
|
|
2629
|
+
memoryItems() {
|
|
2630
|
+
return this.memory.filter((t) => !this.isExpired(t)).sort((t, r) => t.createdAt - r.createdAt);
|
|
2631
|
+
}
|
|
2632
|
+
remove(t) {
|
|
2633
|
+
const r = this.memory.findIndex((i) => i.id === t);
|
|
2634
|
+
return r >= 0 && this.memory.splice(r, 1), this.database().then((i) => {
|
|
2635
|
+
if (i)
|
|
2636
|
+
return new Promise((n) => {
|
|
2637
|
+
try {
|
|
2638
|
+
const s = i.transaction(E, "readwrite");
|
|
2639
|
+
s.objectStore(E).delete(t), s.oncomplete = () => n(), s.onerror = () => n(), s.onabort = () => n();
|
|
2640
|
+
} catch (s) {
|
|
2641
|
+
n();
|
|
2642
|
+
}
|
|
2643
|
+
});
|
|
2644
|
+
});
|
|
2645
|
+
}
|
|
2646
|
+
size() {
|
|
2647
|
+
return this.peek().then((t) => t.length);
|
|
2648
|
+
}
|
|
2649
|
+
isExpired(t) {
|
|
2650
|
+
return Date.now() - t.createdAt > this.options.ttlMs;
|
|
2651
|
+
}
|
|
2652
|
+
trimMemory() {
|
|
2653
|
+
const t = this.memory.filter((r) => !this.isExpired(r));
|
|
2654
|
+
this.memory.length = 0, this.memory.push(...t.slice(-this.options.maxItems));
|
|
2655
|
+
}
|
|
2656
|
+
putMemory(t) {
|
|
2657
|
+
const r = this.memory.findIndex((i) => i.id === t.id);
|
|
2658
|
+
r >= 0 && this.memory.splice(r, 1), this.memory.push(t), this.trimMemory();
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
class w extends Error {
|
|
2662
|
+
constructor(t, r) {
|
|
2663
|
+
super(t), this.name = "TransportError", this.failure = r.failure, this.status = r.status, this.retryable = r.retryable, this.details = r.details, this.retryAfterMs = r.retryAfterMs, this.queued = r.queued;
|
|
2664
|
+
}
|
|
2665
|
+
/** 失败已写入本地补偿队列:只多一个布尔,其余字段原样继承 */
|
|
2666
|
+
asQueued() {
|
|
2667
|
+
return new w(this.message, {
|
|
2668
|
+
failure: this.failure,
|
|
2669
|
+
status: this.status,
|
|
2670
|
+
retryable: this.retryable,
|
|
2671
|
+
details: this.details,
|
|
2672
|
+
retryAfterMs: this.retryAfterMs,
|
|
2673
|
+
queued: !0
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
const Ln = 6e4, Rn = 15, Tn = 6e4;
|
|
2678
|
+
function Mn(e) {
|
|
2679
|
+
return new Promise((t) => setTimeout(t, e));
|
|
2680
|
+
}
|
|
2681
|
+
function An(e) {
|
|
2682
|
+
return 1e3 * Math.pow(3, e) + Math.floor(Math.random() * 250);
|
|
2683
|
+
}
|
|
2684
|
+
function Pn(e, t = Date.now()) {
|
|
2685
|
+
if (!e) return;
|
|
2686
|
+
const r = parseInt(e, 10);
|
|
2687
|
+
if (!isNaN(r)) return r * 1e3;
|
|
2688
|
+
const i = Date.parse(e);
|
|
2689
|
+
return isNaN(i) ? 6e4 : Math.max(0, i - t);
|
|
2690
|
+
}
|
|
2691
|
+
class We {
|
|
2692
|
+
constructor(t) {
|
|
2693
|
+
this.config = t, this.pendingCount = 0, this.pendingBytes = 0, this.successCount = 0, this.flushing = null, this.started = !1, this.onOnline = () => {
|
|
2694
|
+
this.flush();
|
|
2695
|
+
}, this.onVisibility = () => {
|
|
2696
|
+
document.visibilityState === "hidden" && this.beacon();
|
|
2697
|
+
}, this.onPageHide = () => {
|
|
2698
|
+
this.beacon();
|
|
2699
|
+
};
|
|
2700
|
+
const r = t.transport.offline;
|
|
2701
|
+
this.queue = r.enabled ? new Cn({ ttlMs: r.ttlMs, maxItems: r.maxItems }) : null;
|
|
2702
|
+
}
|
|
2703
|
+
/** 注册网络恢复 / 页面隐藏时的补偿逻辑;可重复调用 */
|
|
2704
|
+
start() {
|
|
2705
|
+
this.started || typeof window == "undefined" || (this.started = !0, window.addEventListener("online", this.onOnline), window.addEventListener("pagehide", this.onPageHide), document.addEventListener("visibilitychange", this.onVisibility), this.flush());
|
|
2706
|
+
}
|
|
2707
|
+
stop() {
|
|
2708
|
+
this.started && (this.started = !1, window.removeEventListener("online", this.onOnline), window.removeEventListener("pagehide", this.onPageHide), document.removeEventListener("visibilitychange", this.onVisibility));
|
|
2709
|
+
}
|
|
2710
|
+
send(t) {
|
|
2711
|
+
const r = this.config.transport;
|
|
2712
|
+
if (r.maxReportsPerSession > 0 && this.successCount >= r.maxReportsPerSession)
|
|
2713
|
+
return Promise.reject(
|
|
2714
|
+
new w(`本次会话反馈次数已达上限(${r.maxReportsPerSession} 次)`, {
|
|
2715
|
+
failure: "limited",
|
|
2716
|
+
retryable: !1
|
|
2717
|
+
})
|
|
2718
|
+
);
|
|
2719
|
+
if (this.pendingCount >= r.maxConcurrent)
|
|
2720
|
+
return Promise.reject(
|
|
2721
|
+
new w("正在提交中,请稍后重试", { failure: "busy", retryable: !1 })
|
|
2722
|
+
);
|
|
2723
|
+
let i;
|
|
2724
|
+
try {
|
|
2725
|
+
i = JSON.stringify(xn(t, r.maxItemBytes, r.logLevel));
|
|
2726
|
+
} catch (o) {
|
|
2727
|
+
return Promise.reject(
|
|
2728
|
+
new w(
|
|
2729
|
+
`报告序列化失败:${o instanceof Error ? o.message : String(o)}`,
|
|
2730
|
+
{ failure: "protocol", retryable: !1, details: o }
|
|
2731
|
+
)
|
|
2732
|
+
);
|
|
2733
|
+
}
|
|
2734
|
+
const n = Date.now() + r.totalTimeoutMs, s = S(i);
|
|
2735
|
+
return this.attempt(i, s, t.clientReportId, 0, n, this.config.endpoint).then((o) => (this.successCount += 1, o)).catch((o) => {
|
|
2736
|
+
const a = o instanceof w ? o : this.toTransportError(o);
|
|
2737
|
+
if (!this.shouldQueue(a) || !this.queue) throw a;
|
|
2738
|
+
return this.enqueue(i, s, t.clientReportId).then(() => {
|
|
2739
|
+
throw a.asQueued();
|
|
2740
|
+
});
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
/**
|
|
2744
|
+
* 重放本地补偿队列,返回本次成功发出的条数。
|
|
2745
|
+
* 遇到网络仍不可用时立即停下,避免在弱网下反复打网关。
|
|
2746
|
+
*/
|
|
2747
|
+
flush() {
|
|
2748
|
+
return this.queue ? this.flushing ? this.flushing : (this.flushing = this.queue.peek().then((t) => this.flushItems(t, 0)).catch(() => 0).finally(() => {
|
|
2749
|
+
this.flushing = null;
|
|
2750
|
+
}), this.flushing) : Promise.resolve(0);
|
|
2751
|
+
}
|
|
2752
|
+
flushItems(t, r) {
|
|
2753
|
+
var o;
|
|
2754
|
+
const i = t[r];
|
|
2755
|
+
if (!i) return Promise.resolve(0);
|
|
2756
|
+
const n = Date.now() + this.config.transport.timeoutMs, s = (o = i.size) != null ? o : S(i.body);
|
|
2757
|
+
return this.once(i.body, s, i.id, n, i.endpoint).then(
|
|
2758
|
+
() => this.queue.remove(i.id).then(() => this.flushItems(t, r + 1).then((a) => a + 1))
|
|
2759
|
+
).catch((a) => {
|
|
2760
|
+
const c = a instanceof w ? a : this.toTransportError(a);
|
|
2761
|
+
return this.shouldQueue(c) ? 0 : this.queue.remove(i.id).then(() => this.flushItems(t, r + 1));
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
/** 页面隐藏时用 sendBeacon 兜底,不依赖 fetch 能否在卸载阶段完成 */
|
|
2765
|
+
beacon() {
|
|
2766
|
+
if (this.queue)
|
|
2767
|
+
try {
|
|
2768
|
+
if (typeof navigator == "undefined" || typeof navigator.sendBeacon != "function") return;
|
|
2769
|
+
this.queue.peek().then((t) => {
|
|
2770
|
+
t.forEach((r) => {
|
|
2771
|
+
var i;
|
|
2772
|
+
try {
|
|
2773
|
+
const n = new Blob([r.body], { type: "application/json" });
|
|
2774
|
+
if (n.size > Tn) return;
|
|
2775
|
+
navigator.sendBeacon(r.endpoint, n) && ((i = this.queue) == null || i.remove(r.id));
|
|
2776
|
+
} catch (n) {
|
|
2777
|
+
}
|
|
2778
|
+
});
|
|
2779
|
+
}).catch(() => {
|
|
2780
|
+
});
|
|
2781
|
+
} catch (t) {
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
enqueue(t, r, i) {
|
|
2785
|
+
return this.queue ? this.queue.enqueue({
|
|
2786
|
+
id: i,
|
|
2787
|
+
endpoint: N(this.config.endpoint),
|
|
2788
|
+
body: t,
|
|
2789
|
+
size: r,
|
|
2790
|
+
createdAt: Date.now()
|
|
2791
|
+
}) : Promise.resolve();
|
|
2792
|
+
}
|
|
2793
|
+
// 只入队「重发有机会成功」的失败。
|
|
2794
|
+
// 不能直接复用 retryable:deadlineError 是 failure=timeout、retryable=false
|
|
2795
|
+
// (本次提交的预算耗尽,不能再原地重试),但报告本身值得留到下次再发。
|
|
2796
|
+
shouldQueue(t) {
|
|
2797
|
+
return t.failure === "network" || t.failure === "timeout" ? !0 : t.failure === "http" && (t.status === 429 || (t.status || 0) >= 500);
|
|
2798
|
+
}
|
|
2799
|
+
attempt(t, r, i, n, s, o) {
|
|
2800
|
+
return this.once(t, r, i, s, o).catch((a) => {
|
|
2801
|
+
const c = a instanceof w ? a : this.toTransportError(a), l = this.config.transport.retries;
|
|
2802
|
+
if (n < l && c.retryable) {
|
|
2803
|
+
const h = c.retryAfterMs !== void 0 ? c.retryAfterMs : An(n);
|
|
2804
|
+
if (Date.now() + h >= s) throw this.deadlineError(s);
|
|
2805
|
+
return Mn(h).then(
|
|
2806
|
+
() => this.attempt(t, r, i, n + 1, s, o)
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
throw c;
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
deadlineError(t) {
|
|
2813
|
+
return new w(`提交超时(${Math.round(this.config.transport.totalTimeoutMs / 1e3)}s)`, {
|
|
2814
|
+
failure: "timeout",
|
|
2815
|
+
retryable: !1,
|
|
2816
|
+
details: { deadline: t }
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2819
|
+
once(t, r, i, n, s) {
|
|
2820
|
+
const o = n - Date.now();
|
|
2821
|
+
if (o <= 0) return Promise.reject(this.deadlineError(n));
|
|
2822
|
+
const a = new AbortController(), c = Math.min(this.config.transport.timeoutMs, o), l = setTimeout(() => a.abort(), c), h = {
|
|
2823
|
+
"Content-Type": "application/json",
|
|
2824
|
+
...this.config.transport.headers
|
|
2825
|
+
};
|
|
2826
|
+
this.pendingCount += 1, this.pendingBytes += r;
|
|
2827
|
+
const u = this.pendingBytes <= Ln && this.pendingCount < Rn;
|
|
2828
|
+
return fetch(s, {
|
|
2829
|
+
method: "POST",
|
|
2830
|
+
headers: h,
|
|
2831
|
+
body: t,
|
|
2832
|
+
signal: a.signal,
|
|
2833
|
+
mode: "cors",
|
|
2834
|
+
credentials: "omit",
|
|
2835
|
+
keepalive: u
|
|
2836
|
+
}).then(
|
|
2837
|
+
(d) => d.text().then((p) => ({ response: d, text: p }))
|
|
2838
|
+
).then(({ response: d, text: p }) => {
|
|
2839
|
+
let g = null;
|
|
2840
|
+
if (p)
|
|
2841
|
+
try {
|
|
2842
|
+
g = JSON.parse(p);
|
|
2843
|
+
} catch (m) {
|
|
2844
|
+
g = p;
|
|
2845
|
+
}
|
|
2846
|
+
if (!d.ok) {
|
|
2847
|
+
const m = d.status === 429 || d.status >= 500, I = d.status === 429 ? Pn(d.headers.get("retry-after")) : void 0, q = this.extractMessage(g) || `服务端返回 HTTP ${d.status}`;
|
|
2848
|
+
throw new w(q, {
|
|
2849
|
+
failure: "http",
|
|
2850
|
+
status: d.status,
|
|
2851
|
+
retryable: m,
|
|
2852
|
+
details: g,
|
|
2853
|
+
retryAfterMs: I
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
if (!g || typeof g != "object")
|
|
2857
|
+
throw new w("服务端响应不是合法 JSON", {
|
|
2858
|
+
failure: "protocol",
|
|
2859
|
+
retryable: !1,
|
|
2860
|
+
details: g
|
|
2861
|
+
});
|
|
2862
|
+
if (g.errCode !== 0)
|
|
2863
|
+
throw new w(
|
|
2864
|
+
this.extractMessage(g) || "上报接口返回失败",
|
|
2865
|
+
{
|
|
2866
|
+
failure: "protocol",
|
|
2867
|
+
retryable: !1,
|
|
2868
|
+
details: g
|
|
2869
|
+
}
|
|
2870
|
+
);
|
|
2871
|
+
return {
|
|
2872
|
+
success: !0,
|
|
2873
|
+
reportId: i
|
|
2874
|
+
};
|
|
2875
|
+
}).catch((d) => {
|
|
2876
|
+
throw d instanceof w ? d : d instanceof DOMException && d.name === "AbortError" ? new w(`请求超时(${Math.round(c / 1e3)}s)`, {
|
|
2877
|
+
failure: "timeout",
|
|
2878
|
+
retryable: !0
|
|
2879
|
+
}) : new w(d instanceof Error ? d.message : String(d), {
|
|
2880
|
+
failure: "network",
|
|
2881
|
+
retryable: !0
|
|
2882
|
+
});
|
|
2883
|
+
}).finally(() => {
|
|
2884
|
+
clearTimeout(l), this.pendingCount -= 1, this.pendingBytes -= r;
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
toTransportError(t) {
|
|
2888
|
+
return new w(t instanceof Error ? t.message : String(t), {
|
|
2889
|
+
failure: "network",
|
|
2890
|
+
retryable: !0
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
extractMessage(t) {
|
|
2894
|
+
if (!t || typeof t != "object") return "";
|
|
2895
|
+
const r = t;
|
|
2896
|
+
if (typeof r.errMsg == "string" && r.errMsg) return r.errMsg;
|
|
2897
|
+
if (typeof r.message == "string") return r.message;
|
|
2898
|
+
const i = r.error;
|
|
2899
|
+
if (i && typeof i == "object") {
|
|
2900
|
+
const n = i;
|
|
2901
|
+
if (typeof n.message == "string") return n.message;
|
|
2902
|
+
}
|
|
2903
|
+
return "";
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
function Bn(e) {
|
|
2907
|
+
return Object.keys(e).map((t) => {
|
|
2908
|
+
var r;
|
|
2909
|
+
return `${encodeURIComponent(t)}=${encodeURIComponent((r = e[t]) != null ? r : "")}`;
|
|
2910
|
+
}).join("&");
|
|
2911
|
+
}
|
|
2912
|
+
function j(e) {
|
|
2913
|
+
return e instanceof Error ? e.message : String(e);
|
|
2914
|
+
}
|
|
2915
|
+
function In(e) {
|
|
2916
|
+
if (typeof e == "string") return e;
|
|
2917
|
+
if (e && typeof e == "object") {
|
|
2918
|
+
const t = e;
|
|
2919
|
+
if (typeof t.url == "string") return t.url;
|
|
2920
|
+
if (typeof t.file_url == "string") return t.file_url;
|
|
2921
|
+
}
|
|
2922
|
+
return "";
|
|
2923
|
+
}
|
|
2924
|
+
function $n(e, t) {
|
|
2925
|
+
if (!e.dataBase64)
|
|
2926
|
+
return Promise.resolve(e.url || "");
|
|
2927
|
+
const r = new AbortController(), i = setTimeout(() => r.abort(), t.timeoutMs), n = `data:${e.mime};base64,${e.dataBase64}`, s = Bn({
|
|
2928
|
+
imgdata: n,
|
|
2929
|
+
bizid: t.bizId,
|
|
2930
|
+
name: `bug-report-${Date.now()}.jpg`
|
|
2931
|
+
});
|
|
2932
|
+
return fetch(t.url, {
|
|
2933
|
+
method: "POST",
|
|
2934
|
+
headers: {
|
|
2935
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
2936
|
+
},
|
|
2937
|
+
body: s,
|
|
2938
|
+
credentials: "include",
|
|
2939
|
+
signal: r.signal
|
|
2940
|
+
}).then((o) => o.text().then((a) => ({ response: o, text: a }))).then(({ response: o, text: a }) => {
|
|
2941
|
+
let c = null;
|
|
2942
|
+
try {
|
|
2943
|
+
c = JSON.parse(a);
|
|
2944
|
+
} catch (u) {
|
|
2945
|
+
c = null;
|
|
2946
|
+
}
|
|
2947
|
+
if (!o.ok)
|
|
2948
|
+
throw new Error(`图片上传失败:HTTP ${o.status}`);
|
|
2949
|
+
if (!c || typeof c != "object")
|
|
2950
|
+
throw new Error("图片上传接口响应不是合法 JSON");
|
|
2951
|
+
const l = c;
|
|
2952
|
+
if (l.ret !== 0) {
|
|
2953
|
+
const u = typeof l.errmsg == "string" ? l.errmsg : "";
|
|
2954
|
+
throw new Error(u || "图片上传失败");
|
|
2955
|
+
}
|
|
2956
|
+
const h = In(l.data);
|
|
2957
|
+
if (!h)
|
|
2958
|
+
throw new Error("图片上传接口未返回 url");
|
|
2959
|
+
return h;
|
|
2960
|
+
}).catch((o) => {
|
|
2961
|
+
throw o instanceof DOMException && o.name === "AbortError" ? new Error(`图片上传超时(${Math.round(t.timeoutMs / 1e3)}s)`) : new Error(j(o));
|
|
2962
|
+
}).finally(() => clearTimeout(i));
|
|
2963
|
+
}
|
|
2964
|
+
const Xe = `
|
|
2965
|
+
:host {
|
|
2966
|
+
all: initial;
|
|
2967
|
+
--br-bg: #ffffff;
|
|
2968
|
+
--br-bg-soft: #f6f8fa;
|
|
2969
|
+
--br-fg: #1f2328;
|
|
2970
|
+
--br-muted: #656d76;
|
|
2971
|
+
--br-border: #d0d7de;
|
|
2972
|
+
--br-primary: #1d64e0;
|
|
2973
|
+
--br-primary-fg: #ffffff;
|
|
2974
|
+
--br-danger: #d1242f;
|
|
2975
|
+
--br-ok: #1a7f37;
|
|
2976
|
+
--br-shadow: 0 8px 30px rgba(15, 23, 42, .18);
|
|
2977
|
+
--br-radius: 10px;
|
|
2978
|
+
--br-z: 2147483000;
|
|
2979
|
+
position: fixed;
|
|
2980
|
+
inset: 0;
|
|
2981
|
+
z-index: var(--br-z);
|
|
2982
|
+
pointer-events: none;
|
|
2983
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
2984
|
+
font-size: 14px;
|
|
2985
|
+
line-height: 1.6;
|
|
2986
|
+
color: var(--br-fg);
|
|
2987
|
+
-webkit-font-smoothing: antialiased;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
:host([data-theme="dark"]) {
|
|
2991
|
+
--br-bg: #1c2128;
|
|
2992
|
+
--br-bg-soft: #22272e;
|
|
2993
|
+
--br-fg: #e6edf3;
|
|
2994
|
+
--br-muted: #9198a1;
|
|
2995
|
+
--br-border: #3d444d;
|
|
2996
|
+
--br-primary: #4d8ff0;
|
|
2997
|
+
--br-primary-fg: #0d1117;
|
|
2998
|
+
--br-danger: #f85149;
|
|
2999
|
+
--br-ok: #3fb950;
|
|
3000
|
+
--br-shadow: 0 8px 30px rgba(0, 0, 0, .5);
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
3004
|
+
|
|
3005
|
+
.br-fab-wrap {
|
|
3006
|
+
position: fixed;
|
|
3007
|
+
right: calc(20px + env(safe-area-inset-right, 0px));
|
|
3008
|
+
bottom: calc(20px + env(safe-area-inset-bottom, 0px));
|
|
3009
|
+
z-index: calc(var(--br-z) + 1);
|
|
3010
|
+
display: inline-flex;
|
|
3011
|
+
align-items: center;
|
|
3012
|
+
gap: 4px;
|
|
3013
|
+
pointer-events: auto;
|
|
3014
|
+
touch-action: none;
|
|
3015
|
+
transition: opacity .2s ease;
|
|
3016
|
+
}
|
|
3017
|
+
.br-fab-wrap--left { right: auto; left: calc(20px + env(safe-area-inset-left, 0px)); }
|
|
3018
|
+
.br-fab-wrap--hidden { display: none; }
|
|
3019
|
+
.br-fab-wrap--free { right: auto; bottom: auto; }
|
|
3020
|
+
.br-fab-wrap--dragging { cursor: grabbing; transition: none; }
|
|
3021
|
+
/* 滚动时淡化,减少对内容的干扰 */
|
|
3022
|
+
.br-fab-wrap--scrolling { opacity: .42; }
|
|
3023
|
+
.br-fab-wrap--scrolling .br-fab { box-shadow: 0 2px 8px rgba(15, 23, 42, .16); }
|
|
3024
|
+
.br-fab-wrap--dragging .br-fab { transform: scale(1.04); box-shadow: 0 10px 26px rgba(15, 23, 42, .32); }
|
|
3025
|
+
|
|
3026
|
+
.br-fab-icon {
|
|
3027
|
+
display: inline-flex;
|
|
3028
|
+
align-items: center;
|
|
3029
|
+
justify-content: center;
|
|
3030
|
+
width: 20px;
|
|
3031
|
+
height: 20px;
|
|
3032
|
+
transition: opacity .15s ease;
|
|
3033
|
+
}
|
|
3034
|
+
.br-fab-icon svg { display: block; }
|
|
3035
|
+
|
|
3036
|
+
/* loading:图标淡出,环形指示器覆盖上来 */
|
|
3037
|
+
.br-fab--loading { cursor: progress; }
|
|
3038
|
+
.br-fab--loading .br-fab-icon { opacity: 0; }
|
|
3039
|
+
.br-fab--loading::after {
|
|
3040
|
+
content: '';
|
|
3041
|
+
position: absolute;
|
|
3042
|
+
width: 18px;
|
|
3043
|
+
height: 18px;
|
|
3044
|
+
border: 2px solid rgba(255, 255, 255, .35);
|
|
3045
|
+
border-top-color: var(--br-primary-fg);
|
|
3046
|
+
border-radius: 50%;
|
|
3047
|
+
animation: br-spin .7s linear infinite;
|
|
3048
|
+
}
|
|
3049
|
+
@keyframes br-spin { to { transform: rotate(360deg); } }
|
|
3050
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3051
|
+
.br-fab--loading::after { animation-duration: 2s; }
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
.br-fab {
|
|
3055
|
+
position: relative;
|
|
3056
|
+
display: inline-flex;
|
|
3057
|
+
align-items: center;
|
|
3058
|
+
justify-content: center;
|
|
3059
|
+
width: 46px;
|
|
3060
|
+
height: 46px;
|
|
3061
|
+
padding: 0;
|
|
3062
|
+
border: 1px solid rgba(255, 255, 255, .18);
|
|
3063
|
+
border-radius: 50%;
|
|
3064
|
+
background: var(--br-primary);
|
|
3065
|
+
color: var(--br-primary-fg);
|
|
3066
|
+
box-shadow: var(--br-shadow);
|
|
3067
|
+
cursor: grab;
|
|
3068
|
+
pointer-events: auto;
|
|
3069
|
+
user-select: none;
|
|
3070
|
+
touch-action: none;
|
|
3071
|
+
transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
|
|
3072
|
+
}
|
|
3073
|
+
.br-fab:hover { transform: translateY(-1px); }
|
|
3074
|
+
.br-fab:active { cursor: grabbing; }
|
|
3075
|
+
.br-fab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
|
|
3076
|
+
|
|
3077
|
+
.br-overlay {
|
|
3078
|
+
position: fixed;
|
|
3079
|
+
inset: 0;
|
|
3080
|
+
z-index: calc(var(--br-z) + 2);
|
|
3081
|
+
display: none;
|
|
3082
|
+
background: rgba(15, 23, 42, .38);
|
|
3083
|
+
pointer-events: auto;
|
|
3084
|
+
}
|
|
3085
|
+
.br-overlay--open { display: block; }
|
|
3086
|
+
.br-overlay--hidden { display: none; }
|
|
3087
|
+
.br-panel--hidden { display: none !important; }
|
|
3088
|
+
|
|
3089
|
+
.br-panel {
|
|
3090
|
+
position: fixed;
|
|
3091
|
+
top: 50%;
|
|
3092
|
+
left: 50%;
|
|
3093
|
+
transform: translate(-50%, -50%);
|
|
3094
|
+
width: 640px;
|
|
3095
|
+
max-width: calc(100vw - 40px);
|
|
3096
|
+
height: 80vh;
|
|
3097
|
+
max-height: 900px;
|
|
3098
|
+
display: none;
|
|
3099
|
+
flex-direction: column;
|
|
3100
|
+
background: var(--br-bg);
|
|
3101
|
+
color: var(--br-fg);
|
|
3102
|
+
border-radius: 16px;
|
|
3103
|
+
box-shadow: var(--br-shadow);
|
|
3104
|
+
pointer-events: auto;
|
|
3105
|
+
overflow: hidden;
|
|
3106
|
+
}
|
|
3107
|
+
.br-panel--open { display: flex; }
|
|
3108
|
+
|
|
3109
|
+
.br-header {
|
|
3110
|
+
display: flex;
|
|
3111
|
+
align-items: center;
|
|
3112
|
+
gap: 10px;
|
|
3113
|
+
padding: 14px 16px;
|
|
3114
|
+
border-bottom: 1px solid var(--br-border);
|
|
3115
|
+
background: var(--br-bg);
|
|
3116
|
+
}
|
|
3117
|
+
.br-heading { flex: 1; margin: 0; font-size: 15px; font-weight: 600; }
|
|
3118
|
+
.br-close {
|
|
3119
|
+
width: 30px;
|
|
3120
|
+
height: 30px;
|
|
3121
|
+
border: 1px solid var(--br-border);
|
|
3122
|
+
border-radius: 8px;
|
|
3123
|
+
background: transparent;
|
|
3124
|
+
color: var(--br-muted);
|
|
3125
|
+
font: inherit;
|
|
3126
|
+
font-size: 16px;
|
|
3127
|
+
line-height: 1;
|
|
3128
|
+
cursor: pointer;
|
|
3129
|
+
}
|
|
3130
|
+
.br-close:hover { background: var(--br-bg-soft); color: var(--br-fg); }
|
|
3131
|
+
|
|
3132
|
+
.br-body {
|
|
3133
|
+
flex: 1;
|
|
3134
|
+
overflow-y: auto;
|
|
3135
|
+
padding: 14px 16px 18px;
|
|
3136
|
+
display: flex;
|
|
3137
|
+
flex-direction: column;
|
|
3138
|
+
gap: 14px;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
.br-hidden { display: none !important; }
|
|
3142
|
+
.br-form { display: flex; flex-direction: column; gap: 14px; }
|
|
3143
|
+
.br-field { display: flex; flex-direction: column; gap: 6px; }
|
|
3144
|
+
.br-label { font-size: 13px; font-weight: 600; color: var(--br-fg); }
|
|
3145
|
+
.br-required { color: var(--br-danger); margin-left: 2px; }
|
|
3146
|
+
.br-hint { font-size: 12px; color: var(--br-muted); }
|
|
3147
|
+
|
|
3148
|
+
.br-input, .br-textarea, .br-select {
|
|
3149
|
+
width: 100%;
|
|
3150
|
+
border: 1px solid var(--br-border);
|
|
3151
|
+
border-radius: 8px;
|
|
3152
|
+
background: var(--br-bg);
|
|
3153
|
+
color: var(--br-fg);
|
|
3154
|
+
font: inherit;
|
|
3155
|
+
font-size: 13px;
|
|
3156
|
+
padding: 8px 10px;
|
|
3157
|
+
outline: none;
|
|
3158
|
+
}
|
|
3159
|
+
.br-input:focus, .br-textarea:focus, .br-select:focus {
|
|
3160
|
+
border-color: var(--br-primary);
|
|
3161
|
+
box-shadow: 0 0 0 3px rgba(29, 100, 224, .16);
|
|
3162
|
+
}
|
|
3163
|
+
.br-textarea { resize: vertical; min-height: 96px; }
|
|
3164
|
+
.br-row { display: flex; gap: 10px; }
|
|
3165
|
+
.br-row > .br-field { flex: 1; min-width: 0; }
|
|
3166
|
+
|
|
3167
|
+
.br-shot-preview {
|
|
3168
|
+
display: block;
|
|
3169
|
+
width: 100%;
|
|
3170
|
+
max-height: 220px;
|
|
3171
|
+
margin-top: 8px;
|
|
3172
|
+
object-fit: contain;
|
|
3173
|
+
object-position: top center;
|
|
3174
|
+
border: 1px dashed var(--br-border);
|
|
3175
|
+
border-radius: 8px;
|
|
3176
|
+
background: var(--br-bg-soft);
|
|
3177
|
+
}
|
|
3178
|
+
.br-shot-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
|
3179
|
+
.br-shot-status { font-size: 12px; color: var(--br-muted); }
|
|
3180
|
+
.br-btn--link-inline {
|
|
3181
|
+
padding: 0;
|
|
3182
|
+
border: 0;
|
|
3183
|
+
background: transparent;
|
|
3184
|
+
color: var(--br-primary);
|
|
3185
|
+
font: inherit;
|
|
3186
|
+
font-size: 12px;
|
|
3187
|
+
cursor: pointer;
|
|
3188
|
+
}
|
|
3189
|
+
.br-btn--link-inline:hover { text-decoration: underline; }
|
|
3190
|
+
.br-element-box { display: flex; flex-direction: column; gap: 8px; }
|
|
3191
|
+
.br-element-list { display: flex; flex-direction: column; gap: 4px; }
|
|
3192
|
+
.br-element-item {
|
|
3193
|
+
display: flex;
|
|
3194
|
+
align-items: center;
|
|
3195
|
+
gap: 8px;
|
|
3196
|
+
padding: 4px 6px 4px 8px;
|
|
3197
|
+
border: 1px solid var(--br-border);
|
|
3198
|
+
border-radius: 6px;
|
|
3199
|
+
background: var(--br-bg-soft);
|
|
3200
|
+
}
|
|
3201
|
+
.br-element-item-text {
|
|
3202
|
+
flex: 1;
|
|
3203
|
+
min-width: 0;
|
|
3204
|
+
overflow: hidden;
|
|
3205
|
+
text-overflow: ellipsis;
|
|
3206
|
+
white-space: nowrap;
|
|
3207
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
3208
|
+
font-size: 12px;
|
|
3209
|
+
color: var(--br-fg);
|
|
3210
|
+
}
|
|
3211
|
+
.br-element-item-del {
|
|
3212
|
+
flex: none;
|
|
3213
|
+
width: 18px;
|
|
3214
|
+
height: 18px;
|
|
3215
|
+
padding: 0;
|
|
3216
|
+
border: 0;
|
|
3217
|
+
border-radius: 4px;
|
|
3218
|
+
background: transparent;
|
|
3219
|
+
color: var(--br-muted);
|
|
3220
|
+
font: inherit;
|
|
3221
|
+
font-size: 14px;
|
|
3222
|
+
line-height: 1;
|
|
3223
|
+
cursor: pointer;
|
|
3224
|
+
}
|
|
3225
|
+
.br-element-item-del:hover { background: var(--br-border); color: var(--br-fg); }
|
|
3226
|
+
|
|
3227
|
+
.br-thumb-list { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
3228
|
+
.br-attach-row { display: flex; align-items: center; gap: 8px; }
|
|
3229
|
+
.br-thumb {
|
|
3230
|
+
position: relative;
|
|
3231
|
+
width: 72px;
|
|
3232
|
+
height: 72px;
|
|
3233
|
+
border: 1px solid var(--br-border);
|
|
3234
|
+
border-radius: 6px;
|
|
3235
|
+
overflow: hidden;
|
|
3236
|
+
background: var(--br-bg-soft);
|
|
3237
|
+
}
|
|
3238
|
+
.br-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
3239
|
+
/* 自动截图角标:与用户手动上传的图区分开,避免误以为是自己的图 */
|
|
3240
|
+
.br-thumb-tag {
|
|
3241
|
+
position: absolute;
|
|
3242
|
+
left: 2px;
|
|
3243
|
+
bottom: 2px;
|
|
3244
|
+
padding: 1px 5px;
|
|
3245
|
+
border-radius: 4px;
|
|
3246
|
+
background: rgba(15, 23, 42, .62);
|
|
3247
|
+
color: #fff;
|
|
3248
|
+
font: 11px/1.4 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
3249
|
+
pointer-events: none;
|
|
3250
|
+
}
|
|
3251
|
+
.br-thumb-del {
|
|
3252
|
+
position: absolute;
|
|
3253
|
+
top: 2px;
|
|
3254
|
+
right: 2px;
|
|
3255
|
+
width: 18px;
|
|
3256
|
+
height: 18px;
|
|
3257
|
+
padding: 0;
|
|
3258
|
+
border: 0;
|
|
3259
|
+
border-radius: 50%;
|
|
3260
|
+
background: rgba(15, 23, 42, .62);
|
|
3261
|
+
color: #fff;
|
|
3262
|
+
font: inherit;
|
|
3263
|
+
font-size: 13px;
|
|
3264
|
+
line-height: 1;
|
|
3265
|
+
cursor: pointer;
|
|
3266
|
+
opacity: 0;
|
|
3267
|
+
transition: opacity .15s ease;
|
|
3268
|
+
}
|
|
3269
|
+
.br-thumb:hover .br-thumb-del,
|
|
3270
|
+
.br-thumb-del:focus-visible { opacity: 1; }
|
|
3271
|
+
@media (max-width: 560px) {
|
|
3272
|
+
.br-thumb-del { opacity: 1; }
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
.br-footer {
|
|
3276
|
+
display: flex;
|
|
3277
|
+
align-items: center;
|
|
3278
|
+
gap: 10px;
|
|
3279
|
+
padding: 12px 16px;
|
|
3280
|
+
border-top: 1px solid var(--br-border);
|
|
3281
|
+
background: var(--br-bg);
|
|
3282
|
+
}
|
|
3283
|
+
.br-footer .br-spacer { flex: 1; }
|
|
3284
|
+
|
|
3285
|
+
.br-btn {
|
|
3286
|
+
border: 1px solid var(--br-border);
|
|
3287
|
+
border-radius: 8px;
|
|
3288
|
+
background: var(--br-bg);
|
|
3289
|
+
color: var(--br-fg);
|
|
3290
|
+
font: inherit;
|
|
3291
|
+
font-size: 13px;
|
|
3292
|
+
padding: 7px 14px;
|
|
3293
|
+
cursor: pointer;
|
|
3294
|
+
}
|
|
3295
|
+
.br-btn:hover { background: var(--br-bg-soft); }
|
|
3296
|
+
.br-btn:disabled { opacity: .55; cursor: not-allowed; }
|
|
3297
|
+
.br-btn--primary {
|
|
3298
|
+
border-color: var(--br-primary);
|
|
3299
|
+
background: var(--br-primary);
|
|
3300
|
+
color: var(--br-primary-fg);
|
|
3301
|
+
}
|
|
3302
|
+
.br-btn--primary:hover { filter: brightness(1.05); background: var(--br-primary); }
|
|
3303
|
+
.br-btn--ghost { background: transparent; }
|
|
3304
|
+
.br-btn--link {
|
|
3305
|
+
padding: 0;
|
|
3306
|
+
border: 0;
|
|
3307
|
+
background: transparent;
|
|
3308
|
+
color: var(--br-muted);
|
|
3309
|
+
font-size: 12px;
|
|
3310
|
+
text-decoration: underline;
|
|
3311
|
+
cursor: pointer;
|
|
3312
|
+
margin-right: auto;
|
|
3313
|
+
}
|
|
3314
|
+
.br-btn--link:hover { color: var(--br-fg); }
|
|
3315
|
+
.br-btn--sm { padding: 4px 10px; font-size: 12px; }
|
|
3316
|
+
|
|
3317
|
+
.br-status { font-size: 12px; color: var(--br-muted); min-height: 18px; }
|
|
3318
|
+
.br-status--error { color: var(--br-danger); }
|
|
3319
|
+
.br-status--ok { color: var(--br-ok); }
|
|
3320
|
+
|
|
3321
|
+
.br-success { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
|
|
3322
|
+
.br-success-title { font-size: 15px; font-weight: 600; color: var(--br-ok); }
|
|
3323
|
+
.br-link { color: var(--br-primary); text-decoration: underline; word-break: break-all; }
|
|
3324
|
+
.br-success-actions { display: flex; gap: 8px; margin-top: 4px; }
|
|
3325
|
+
|
|
3326
|
+
@media (max-width: 560px) {
|
|
3327
|
+
.br-panel {
|
|
3328
|
+
top: auto;
|
|
3329
|
+
left: 0;
|
|
3330
|
+
right: 0;
|
|
3331
|
+
bottom: 0;
|
|
3332
|
+
transform: none;
|
|
3333
|
+
width: auto;
|
|
3334
|
+
max-width: none;
|
|
3335
|
+
height: 75vh;
|
|
3336
|
+
max-height: 85vh;
|
|
3337
|
+
border-radius: 16px 16px 0 0;
|
|
3338
|
+
padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
3339
|
+
}
|
|
3340
|
+
.br-row { flex-direction: column; gap: 14px; }
|
|
3341
|
+
.br-fab-wrap { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
|
|
3342
|
+
.br-fab-wrap--left { right: auto; left: calc(14px + env(safe-area-inset-left, 0px)); }
|
|
3343
|
+
}
|
|
3344
|
+
`;
|
|
3345
|
+
class On {
|
|
3346
|
+
constructor(t, r) {
|
|
3347
|
+
this.theme = t, this.media = null, this.onThemeChange = () => this.applyTheme(), this.host = document.createElement("div"), this.host.setAttribute("data-bug-tap", ""), this.host.setAttribute("data-theme", this.resolveTheme()), this.host.style.setProperty("--br-z", String(r)), this.root = this.host.attachShadow({ mode: "open" }), this.injectStyles(), this.bindTheme();
|
|
3348
|
+
}
|
|
3349
|
+
mount() {
|
|
3350
|
+
this.host.isConnected || document.documentElement.appendChild(this.host);
|
|
3351
|
+
}
|
|
3352
|
+
unmount() {
|
|
3353
|
+
this.unbindTheme(), this.host.remove();
|
|
3354
|
+
}
|
|
3355
|
+
injectStyles() {
|
|
3356
|
+
try {
|
|
3357
|
+
if (typeof CSSStyleSheet != "undefined" && "adoptedStyleSheets" in this.root) {
|
|
3358
|
+
const r = new CSSStyleSheet();
|
|
3359
|
+
r.replaceSync(Xe), this.root.adoptedStyleSheets = [...this.root.adoptedStyleSheets, r];
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3362
|
+
} catch (r) {
|
|
3363
|
+
}
|
|
3364
|
+
const t = document.createElement("style");
|
|
3365
|
+
t.textContent = Xe, this.root.appendChild(t);
|
|
3366
|
+
}
|
|
3367
|
+
bindTheme() {
|
|
3368
|
+
if (!(this.theme !== "auto" || typeof window.matchMedia != "function"))
|
|
3369
|
+
try {
|
|
3370
|
+
this.media = window.matchMedia("(prefers-color-scheme: dark)"), typeof this.media.addEventListener == "function" ? this.media.addEventListener("change", this.onThemeChange) : typeof this.media.addListener == "function" && this.media.addListener(this.onThemeChange);
|
|
3371
|
+
} catch (t) {
|
|
3372
|
+
this.media = null;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
unbindTheme() {
|
|
3376
|
+
if (this.media) {
|
|
3377
|
+
try {
|
|
3378
|
+
typeof this.media.removeEventListener == "function" ? this.media.removeEventListener("change", this.onThemeChange) : typeof this.media.removeListener == "function" && this.media.removeListener(this.onThemeChange);
|
|
3379
|
+
} catch (t) {
|
|
3380
|
+
}
|
|
3381
|
+
this.media = null;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
applyTheme() {
|
|
3385
|
+
this.host.setAttribute("data-theme", this.resolveTheme());
|
|
3386
|
+
}
|
|
3387
|
+
resolveTheme() {
|
|
3388
|
+
if (this.theme === "light" || this.theme === "dark") return this.theme;
|
|
3389
|
+
try {
|
|
3390
|
+
return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
3391
|
+
} catch (t) {
|
|
3392
|
+
return "light";
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
const _n = `
|
|
3397
|
+
<svg viewBox="0 0 24 24" width="20" height="20" fill="none"
|
|
3398
|
+
stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"
|
|
3399
|
+
aria-hidden="true" focusable="false">
|
|
3400
|
+
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/>
|
|
3401
|
+
<path d="M12 7.6v4.6"/>
|
|
3402
|
+
<circle cx="12" cy="15.2" r="1" fill="currentColor" stroke="none"/>
|
|
3403
|
+
</svg>`, C = 20, Ve = 4, br = "bug-tap-fab-position", Hn = 46;
|
|
3404
|
+
function V(e, t, r) {
|
|
3405
|
+
return Math.min(r, Math.max(t, e));
|
|
3406
|
+
}
|
|
3407
|
+
function Un() {
|
|
3408
|
+
try {
|
|
3409
|
+
const e = localStorage.getItem(br);
|
|
3410
|
+
if (!e) return null;
|
|
3411
|
+
const t = JSON.parse(e);
|
|
3412
|
+
return t.side !== "left" && t.side !== "right" || typeof t.top != "number" || !Number.isFinite(t.top) ? null : { side: t.side, top: t.top };
|
|
3413
|
+
} catch (e) {
|
|
3414
|
+
return null;
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
function jn(e) {
|
|
3418
|
+
try {
|
|
3419
|
+
localStorage.setItem(br, JSON.stringify(e));
|
|
3420
|
+
} catch (t) {
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
class zn {
|
|
3424
|
+
constructor(t) {
|
|
3425
|
+
this.options = t, this.startX = 0, this.startY = 0, this.originLeft = 0, this.originTop = 0, this.dragging = !1, this.moved = !1, this.suppressClick = !1, this.scrollTimer = 0, this.scrolling = !1, this.listeningScroll = !1, this.onScroll = () => {
|
|
3426
|
+
this.dragging || (this.scrolling || (this.scrolling = !0, this.wrapper.classList.add("br-fab-wrap--scrolling")), this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
|
|
3427
|
+
this.scrollTimer = 0, this.scrolling = !1, this.wrapper.classList.remove("br-fab-wrap--scrolling");
|
|
3428
|
+
}, 300));
|
|
3429
|
+
}, this.onPointerDown = (r) => {
|
|
3430
|
+
if (r.button !== 0 && r.pointerType === "mouse") return;
|
|
3431
|
+
this.dragging = !0, this.moved = !1, this.startX = r.clientX, this.startY = r.clientY;
|
|
3432
|
+
const i = this.el.getBoundingClientRect();
|
|
3433
|
+
this.originLeft = i.left, this.originTop = i.top;
|
|
3434
|
+
try {
|
|
3435
|
+
this.el.setPointerCapture(r.pointerId);
|
|
3436
|
+
} catch (n) {
|
|
3437
|
+
}
|
|
3438
|
+
this.el.addEventListener("pointermove", this.onPointerMove), this.el.addEventListener("pointerup", this.onPointerUp), this.el.addEventListener("pointercancel", this.onPointerUp);
|
|
3439
|
+
}, this.onPointerMove = (r) => {
|
|
3440
|
+
if (!this.dragging) return;
|
|
3441
|
+
const i = r.clientX - this.startX, n = r.clientY - this.startY;
|
|
3442
|
+
if (!this.moved && Math.abs(i) < Ve && Math.abs(n) < Ve) return;
|
|
3443
|
+
this.moved = !0, this.wrapper.classList.add("br-fab-wrap--dragging");
|
|
3444
|
+
const s = this.el.offsetWidth, o = this.el.offsetHeight, a = V(
|
|
3445
|
+
this.originLeft + i,
|
|
3446
|
+
C,
|
|
3447
|
+
window.innerWidth - s - C
|
|
3448
|
+
), c = V(this.originTop + n, C, window.innerHeight - o - C);
|
|
3449
|
+
this.applyPosition({ left: a, top: c });
|
|
3450
|
+
}, this.onPointerUp = (r) => {
|
|
3451
|
+
var c, l;
|
|
3452
|
+
if (!this.dragging) return;
|
|
3453
|
+
this.dragging = !1, this.el.removeEventListener("pointermove", this.onPointerMove), this.el.removeEventListener("pointerup", this.onPointerUp), this.el.removeEventListener("pointercancel", this.onPointerUp), this.wrapper.classList.remove("br-fab-wrap--dragging");
|
|
3454
|
+
try {
|
|
3455
|
+
this.el.releasePointerCapture(r.pointerId);
|
|
3456
|
+
} catch (h) {
|
|
3457
|
+
}
|
|
3458
|
+
if (r.type === "pointercancel") {
|
|
3459
|
+
this.suppressClick = !1, this.moved = !1;
|
|
3460
|
+
return;
|
|
3461
|
+
}
|
|
3462
|
+
if (!this.moved) return;
|
|
3463
|
+
this.suppressClick = !0;
|
|
3464
|
+
const i = this.el.getBoundingClientRect(), s = i.left + i.width / 2 < window.innerWidth / 2 ? "left" : "right", o = V(i.top, C, window.innerHeight - i.height - C);
|
|
3465
|
+
this.snapTo(s, o);
|
|
3466
|
+
const a = { side: s, top: o };
|
|
3467
|
+
jn(a), (l = (c = this.options).onDragEnd) == null || l.call(c, a);
|
|
3468
|
+
}, this.wrapper = document.createElement("div"), this.wrapper.className = "br-fab-wrap", t.position === "bottom-left" && this.wrapper.classList.add("br-fab-wrap--left"), this.el = document.createElement("button"), this.el.type = "button", this.el.className = "br-fab", this.el.innerHTML = `<span class="br-fab-icon">${_n}</span>`, this.el.title = t.text || "反馈问题", this.el.setAttribute("aria-label", t.text || "打开问题反馈面板"), this.el.setAttribute("aria-haspopup", "dialog"), this.wrapper.append(this.el), this.bindEvents(), this.bindScroll();
|
|
3469
|
+
}
|
|
3470
|
+
get element() {
|
|
3471
|
+
return this.wrapper;
|
|
3472
|
+
}
|
|
3473
|
+
// 页面滚动时按钮淡化,停止滚动 300ms 后恢复;不拦截滚动本身
|
|
3474
|
+
bindScroll() {
|
|
3475
|
+
this.listeningScroll || (this.listeningScroll = !0, window.addEventListener("scroll", this.onScroll, { capture: !0, passive: !0 }));
|
|
3476
|
+
}
|
|
3477
|
+
unbindScroll() {
|
|
3478
|
+
this.listeningScroll && (this.listeningScroll = !1, window.removeEventListener("scroll", this.onScroll, { capture: !0 }), this.scrollTimer && (clearTimeout(this.scrollTimer), this.scrollTimer = 0), this.scrolling = !1, this.wrapper.classList.remove("br-fab-wrap--scrolling"));
|
|
3479
|
+
}
|
|
3480
|
+
bindEvents() {
|
|
3481
|
+
this.el.addEventListener("click", (t) => {
|
|
3482
|
+
if (this.suppressClick) {
|
|
3483
|
+
this.suppressClick = !1, t.preventDefault(), t.stopPropagation();
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3486
|
+
this.options.onClick();
|
|
3487
|
+
}), this.el.addEventListener("pointerdown", this.onPointerDown);
|
|
3488
|
+
}
|
|
3489
|
+
/** 首次打开面板时展示 loading,直到面板渲染完成 */
|
|
3490
|
+
setLoading(t) {
|
|
3491
|
+
t ? (this.el.classList.add("br-fab--loading"), this.el.setAttribute("aria-busy", "true"), this.el.setAttribute("aria-label", "正在打开反馈面板")) : (this.el.classList.remove("br-fab--loading"), this.el.removeAttribute("aria-busy"), this.el.setAttribute("aria-label", this.el.title));
|
|
3492
|
+
}
|
|
3493
|
+
// 拖拽中直接用 left/top 定位
|
|
3494
|
+
applyPosition(t) {
|
|
3495
|
+
const r = this.wrapper.style;
|
|
3496
|
+
r.left = `${t.left}px`, r.top = `${t.top}px`, r.right = "auto", r.bottom = "auto", this.wrapper.classList.add("br-fab-wrap--free");
|
|
3497
|
+
}
|
|
3498
|
+
// 贴边后改用 side + top 定位,窗口尺寸变化时仍贴边
|
|
3499
|
+
snapTo(t, r) {
|
|
3500
|
+
const i = this.wrapper.style;
|
|
3501
|
+
i.removeProperty("left"), i.removeProperty("right"), i.top = `${r}px`, i.bottom = "auto", t === "left" ? this.wrapper.classList.add("br-fab-wrap--left") : this.wrapper.classList.remove("br-fab-wrap--left"), this.wrapper.classList.remove("br-fab-wrap--free");
|
|
3502
|
+
}
|
|
3503
|
+
/** 首次挂载时恢复上次位置,没有则用默认位置 */
|
|
3504
|
+
restorePosition() {
|
|
3505
|
+
const t = this.el.offsetHeight || Hn, r = Un();
|
|
3506
|
+
if (r) {
|
|
3507
|
+
const i = Math.max(C, window.innerHeight - t - C);
|
|
3508
|
+
this.snapTo(r.side, V(r.top, C, i));
|
|
3509
|
+
return;
|
|
3510
|
+
}
|
|
3511
|
+
this.options.position === "bottom-left" && this.wrapper.classList.add("br-fab-wrap--left");
|
|
3512
|
+
}
|
|
3513
|
+
show() {
|
|
3514
|
+
this.wrapper.classList.remove("br-fab-wrap--hidden");
|
|
3515
|
+
}
|
|
3516
|
+
hide() {
|
|
3517
|
+
this.wrapper.classList.add("br-fab-wrap--hidden");
|
|
3518
|
+
}
|
|
3519
|
+
destroy() {
|
|
3520
|
+
this.unbindScroll(), this.el.removeEventListener("pointerdown", this.onPointerDown);
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
function Dn() {
|
|
3524
|
+
return window.__BugTapHtml2Canvas;
|
|
3525
|
+
}
|
|
3526
|
+
function Nn(e) {
|
|
3527
|
+
return new Promise((t, r) => {
|
|
3528
|
+
const i = `script[data-bug-tap-shot="${e}"]`, n = document.querySelector(i);
|
|
3529
|
+
if (n) {
|
|
3530
|
+
n.addEventListener("load", () => t(), { once: !0 }), n.addEventListener("error", () => r(new Error("截图库加载失败")), { once: !0 });
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
const s = document.createElement("script");
|
|
3534
|
+
s.src = e, s.async = !0, s.setAttribute("data-bug-tap-shot", e), s.onload = () => t(), s.onerror = () => {
|
|
3535
|
+
s.remove(), r(new Error(`截图库加载失败:${e}`));
|
|
3536
|
+
}, document.head.appendChild(s);
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
function qn(e) {
|
|
3540
|
+
return Nn(N(e)).then(() => {
|
|
3541
|
+
const t = Dn();
|
|
3542
|
+
if (!t) throw new Error("截图库加载完成但未暴露入口");
|
|
3543
|
+
return t;
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
let St = "";
|
|
3547
|
+
function Fn(e) {
|
|
3548
|
+
St = String(e || "").trim();
|
|
3549
|
+
}
|
|
3550
|
+
function Wn() {
|
|
3551
|
+
if (St) {
|
|
3552
|
+
const e = typeof window != "undefined" ? window.__BugTapHtml2Canvas : void 0;
|
|
3553
|
+
return e ? Promise.resolve(e) : qn(St).then((t) => t);
|
|
3554
|
+
}
|
|
3555
|
+
return import("html2canvas-pro").then((e) => e.default);
|
|
3556
|
+
}
|
|
3557
|
+
let Y = null;
|
|
3558
|
+
function Ye(e) {
|
|
3559
|
+
Fn(e);
|
|
3560
|
+
}
|
|
3561
|
+
function Ke() {
|
|
3562
|
+
return Y || (Y = Wn().catch((e) => {
|
|
3563
|
+
throw Y = null, e;
|
|
3564
|
+
})), Y;
|
|
3565
|
+
}
|
|
3566
|
+
function Ge() {
|
|
3567
|
+
return new Promise((e) => {
|
|
3568
|
+
typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => requestAnimationFrame(() => e())) : setTimeout(e, 16);
|
|
3569
|
+
});
|
|
3570
|
+
}
|
|
3571
|
+
function ft(e, t) {
|
|
3572
|
+
const r = e.length - (t >= 0 ? t + 1 : 0);
|
|
3573
|
+
return Math.floor(r * 3 / 4);
|
|
3574
|
+
}
|
|
3575
|
+
function Xn(e) {
|
|
3576
|
+
try {
|
|
3577
|
+
return e.hasAttribute("data-bug-tap") || e.hasAttribute("data-bug-tap-ignore") || e instanceof HTMLElement && e.style.display === "none" && e.dataset.bugTapHidden === "1";
|
|
3578
|
+
} catch (t) {
|
|
3579
|
+
return !1;
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
function kt(e, t) {
|
|
3583
|
+
let r = e.width, i = e.height, n = e;
|
|
3584
|
+
if (r > t.maxWidth) {
|
|
3585
|
+
const u = t.maxWidth / r;
|
|
3586
|
+
r = Math.round(r * u), i = Math.round(i * u);
|
|
3587
|
+
const d = document.createElement("canvas");
|
|
3588
|
+
d.width = r, d.height = i;
|
|
3589
|
+
const p = d.getContext("2d");
|
|
3590
|
+
p && (p.drawImage(e, 0, 0, r, i), n = d);
|
|
3591
|
+
}
|
|
3592
|
+
const s = t.maxSizeKB * 1024;
|
|
3593
|
+
let o = t.quality, a = n.toDataURL("image/jpeg", o), c = a.indexOf(","), l = ft(a, c);
|
|
3594
|
+
for (; l > s && o > 0.35; )
|
|
3595
|
+
o = Math.max(0.35, o - 0.1), a = n.toDataURL("image/jpeg", o), c = a.indexOf(","), l = ft(a, c);
|
|
3596
|
+
let h = 0;
|
|
3597
|
+
for (; l > s && h < 4; ) {
|
|
3598
|
+
h += 1;
|
|
3599
|
+
const u = document.createElement("canvas");
|
|
3600
|
+
u.width = Math.max(1, Math.round(n.width * 0.8)), u.height = Math.max(1, Math.round(n.height * 0.8));
|
|
3601
|
+
const d = u.getContext("2d");
|
|
3602
|
+
if (!d) break;
|
|
3603
|
+
d.drawImage(n, 0, 0, u.width, u.height), n = u, a = n.toDataURL("image/jpeg", o), c = a.indexOf(","), l = ft(a, c);
|
|
3604
|
+
}
|
|
3605
|
+
return {
|
|
3606
|
+
mime: "image/jpeg",
|
|
3607
|
+
dataBase64: a.slice(c + 1),
|
|
3608
|
+
width: n.width,
|
|
3609
|
+
height: n.height,
|
|
3610
|
+
size: l,
|
|
3611
|
+
source: t.source || "auto",
|
|
3612
|
+
// auto 截图拍的是「打开面板那一刻」而非错误现场,AI 需要据此判断时效性
|
|
3613
|
+
capturedAt: Date.now()
|
|
3614
|
+
};
|
|
3615
|
+
}
|
|
3616
|
+
function Vn() {
|
|
3617
|
+
return Math.min(2, Math.max(1, window.devicePixelRatio || 1));
|
|
3618
|
+
}
|
|
3619
|
+
function Je(e, t) {
|
|
3620
|
+
return e(document.documentElement, {
|
|
3621
|
+
x: window.scrollX,
|
|
3622
|
+
y: window.scrollY,
|
|
3623
|
+
width: window.innerWidth,
|
|
3624
|
+
height: window.innerHeight,
|
|
3625
|
+
scrollX: window.scrollX,
|
|
3626
|
+
scrollY: window.scrollY,
|
|
3627
|
+
windowWidth: window.innerWidth,
|
|
3628
|
+
windowHeight: window.innerHeight,
|
|
3629
|
+
scale: Vn(),
|
|
3630
|
+
useCORS: !0,
|
|
3631
|
+
logging: !1,
|
|
3632
|
+
backgroundColor: null,
|
|
3633
|
+
foreignObjectRendering: !1,
|
|
3634
|
+
...t ? { ignoreElements: t } : {}
|
|
3635
|
+
});
|
|
3636
|
+
}
|
|
3637
|
+
function Yn(e) {
|
|
3638
|
+
const t = e.ignoreElement || null;
|
|
3639
|
+
return Promise.all([Ge(), Ke()]).then(([, r]) => Je(r, Xn)).then((r) => kt(r, e)).catch((r) => {
|
|
3640
|
+
if (!t) throw r;
|
|
3641
|
+
const i = t.style.display;
|
|
3642
|
+
return t.style.display = "none", Promise.all([Ge(), Ke()]).then(([, n]) => Je(n)).then((n) => kt(n, e)).finally(() => {
|
|
3643
|
+
t.style.display = i;
|
|
3644
|
+
});
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
3647
|
+
function Kn(e, t) {
|
|
3648
|
+
return new Promise((r, i) => {
|
|
3649
|
+
if (!e || !/^image\//.test(e.type)) {
|
|
3650
|
+
i(new Error("请选择图片文件"));
|
|
3651
|
+
return;
|
|
3652
|
+
}
|
|
3653
|
+
const n = URL.createObjectURL(e), s = new Image();
|
|
3654
|
+
s.onload = () => {
|
|
3655
|
+
try {
|
|
3656
|
+
const o = s.naturalWidth || s.width, a = s.naturalHeight || s.height;
|
|
3657
|
+
if (!o || !a) throw new Error("图片尺寸无效");
|
|
3658
|
+
const c = Math.min(1, t.maxWidth / o), l = document.createElement("canvas");
|
|
3659
|
+
l.width = Math.max(1, Math.round(o * c)), l.height = Math.max(1, Math.round(a * c));
|
|
3660
|
+
const h = l.getContext("2d");
|
|
3661
|
+
if (!h) throw new Error("当前环境不支持 Canvas");
|
|
3662
|
+
h.drawImage(s, 0, 0, l.width, l.height);
|
|
3663
|
+
const u = kt(l, { ...t, source: "manual" });
|
|
3664
|
+
URL.revokeObjectURL(n), r(u);
|
|
3665
|
+
} catch (o) {
|
|
3666
|
+
URL.revokeObjectURL(n), i(o);
|
|
3667
|
+
}
|
|
3668
|
+
}, s.onerror = () => {
|
|
3669
|
+
URL.revokeObjectURL(n), i(new Error("图片读取失败"));
|
|
3670
|
+
}, s.src = n;
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
const Gn = 200, yr = 8, Jn = [
|
|
3674
|
+
"id",
|
|
3675
|
+
"name",
|
|
3676
|
+
"role",
|
|
3677
|
+
"type",
|
|
3678
|
+
"aria-label",
|
|
3679
|
+
"aria-labelledby",
|
|
3680
|
+
"data-testid",
|
|
3681
|
+
"data-test",
|
|
3682
|
+
"data-qa",
|
|
3683
|
+
"placeholder",
|
|
3684
|
+
"title",
|
|
3685
|
+
"href"
|
|
3686
|
+
], Qn = [
|
|
3687
|
+
/^css-/,
|
|
3688
|
+
/^sc-/,
|
|
3689
|
+
/^emotion-/,
|
|
3690
|
+
/^makeStyles-/,
|
|
3691
|
+
/^jsx-/,
|
|
3692
|
+
/^el-/,
|
|
3693
|
+
/^van-/,
|
|
3694
|
+
/^ant-/,
|
|
3695
|
+
/^svelte-/,
|
|
3696
|
+
/\d{4,}/
|
|
3697
|
+
];
|
|
3698
|
+
function Zn(e) {
|
|
3699
|
+
try {
|
|
3700
|
+
return kr(e, {
|
|
3701
|
+
selectors: ["id", "class", "attribute", "tag", "nthchild"],
|
|
3702
|
+
ignoreGeneratedClassNames: !0,
|
|
3703
|
+
blacklist: Qn,
|
|
3704
|
+
maxCandidates: 50,
|
|
3705
|
+
maxCombinations: 100
|
|
3706
|
+
});
|
|
3707
|
+
} catch (t) {
|
|
3708
|
+
return ts(e);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
function ts(e) {
|
|
3712
|
+
const t = [];
|
|
3713
|
+
let r = e, i = 0;
|
|
3714
|
+
for (; r && r !== document.documentElement && i < yr; ) {
|
|
3715
|
+
let n = r.tagName.toLowerCase();
|
|
3716
|
+
const s = r.parentElement;
|
|
3717
|
+
if (s) {
|
|
3718
|
+
const o = Array.prototype.filter.call(
|
|
3719
|
+
s.children,
|
|
3720
|
+
(a) => a.tagName === r.tagName
|
|
3721
|
+
);
|
|
3722
|
+
o.length > 1 && (n += `:nth-of-type(${o.indexOf(r) + 1})`);
|
|
3723
|
+
}
|
|
3724
|
+
t.unshift(n), r = s, i += 1;
|
|
3725
|
+
}
|
|
3726
|
+
return t.join(" > ") || "body";
|
|
3727
|
+
}
|
|
3728
|
+
function es(e) {
|
|
3729
|
+
const t = {};
|
|
3730
|
+
for (const r of Jn) {
|
|
3731
|
+
const i = e.getAttribute(r);
|
|
3732
|
+
i && (t[r] = i.slice(0, 200));
|
|
3733
|
+
}
|
|
3734
|
+
return t;
|
|
3735
|
+
}
|
|
3736
|
+
function rs(e) {
|
|
3737
|
+
const t = [];
|
|
3738
|
+
let r = e, i = 0;
|
|
3739
|
+
for (; r && r !== document.documentElement && i < yr; )
|
|
3740
|
+
t.unshift(r.tagName.toLowerCase()), r = r.parentElement, i += 1;
|
|
3741
|
+
return t.join(" > ");
|
|
3742
|
+
}
|
|
3743
|
+
function pt(e) {
|
|
3744
|
+
const t = e.getBoundingClientRect(), r = (e.textContent || "").replace(/\s+/g, " ").trim();
|
|
3745
|
+
return {
|
|
3746
|
+
selector: Zn(e),
|
|
3747
|
+
tag: e.tagName.toLowerCase(),
|
|
3748
|
+
text: r ? r.slice(0, Gn) : void 0,
|
|
3749
|
+
attributes: es(e),
|
|
3750
|
+
rect: {
|
|
3751
|
+
x: Math.round(t.left),
|
|
3752
|
+
y: Math.round(t.top),
|
|
3753
|
+
width: Math.round(t.width),
|
|
3754
|
+
height: Math.round(t.height)
|
|
3755
|
+
},
|
|
3756
|
+
path: rs(e)
|
|
3757
|
+
};
|
|
3758
|
+
}
|
|
3759
|
+
const K = 10, gt = `:host { all: initial; position: fixed; inset: 0; z-index: 2147483600; pointer-events: none; }
|
|
3760
|
+
.box {
|
|
3761
|
+
position: fixed;
|
|
3762
|
+
border: 2px solid #1d64e0;
|
|
3763
|
+
background: rgba(29, 100, 224, .12);
|
|
3764
|
+
border-radius: 3px;
|
|
3765
|
+
pointer-events: none;
|
|
3766
|
+
}
|
|
3767
|
+
.badge {
|
|
3768
|
+
position: fixed;
|
|
3769
|
+
max-width: 60vw;
|
|
3770
|
+
padding: 3px 8px;
|
|
3771
|
+
border-radius: 4px;
|
|
3772
|
+
background: #1d64e0;
|
|
3773
|
+
color: #fff;
|
|
3774
|
+
font: 12px/1.4 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
3775
|
+
white-space: nowrap;
|
|
3776
|
+
overflow: hidden;
|
|
3777
|
+
text-overflow: ellipsis;
|
|
3778
|
+
pointer-events: none;
|
|
3779
|
+
}
|
|
3780
|
+
.bar {
|
|
3781
|
+
position: fixed;
|
|
3782
|
+
top: 0; left: 0; right: 0;
|
|
3783
|
+
display: flex;
|
|
3784
|
+
align-items: center;
|
|
3785
|
+
gap: 12px;
|
|
3786
|
+
padding: 10px 16px;
|
|
3787
|
+
background: rgba(29, 100, 224, .96);
|
|
3788
|
+
color: #fff;
|
|
3789
|
+
font: 13px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
3790
|
+
pointer-events: auto;
|
|
3791
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
|
|
3792
|
+
}
|
|
3793
|
+
.bar span { flex: 1; }
|
|
3794
|
+
.bar kbd {
|
|
3795
|
+
padding: 1px 6px;
|
|
3796
|
+
border-radius: 4px;
|
|
3797
|
+
background: rgba(255, 255, 255, .2);
|
|
3798
|
+
font: inherit;
|
|
3799
|
+
font-size: 12px;
|
|
3800
|
+
}
|
|
3801
|
+
.bar button {
|
|
3802
|
+
padding: 5px 12px;
|
|
3803
|
+
border: 1px solid rgba(255, 255, 255, .5);
|
|
3804
|
+
border-radius: 6px;
|
|
3805
|
+
background: transparent;
|
|
3806
|
+
color: #fff;
|
|
3807
|
+
font: inherit;
|
|
3808
|
+
cursor: pointer;
|
|
3809
|
+
}
|
|
3810
|
+
.bar button:hover { background: rgba(255, 255, 255, .15); }
|
|
3811
|
+
|
|
3812
|
+
.confirm {
|
|
3813
|
+
position: fixed;
|
|
3814
|
+
left: 12px;
|
|
3815
|
+
right: 12px;
|
|
3816
|
+
bottom: calc(12px + env(safe-area-inset-bottom, 0px));
|
|
3817
|
+
display: none;
|
|
3818
|
+
align-items: center;
|
|
3819
|
+
gap: 10px;
|
|
3820
|
+
padding: 10px 12px;
|
|
3821
|
+
border-radius: 12px;
|
|
3822
|
+
background: #1d64e0;
|
|
3823
|
+
color: #fff;
|
|
3824
|
+
font: 13px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
|
|
3825
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
|
|
3826
|
+
pointer-events: auto;
|
|
3827
|
+
}
|
|
3828
|
+
.confirm--show { display: flex; }
|
|
3829
|
+
.confirm-text {
|
|
3830
|
+
flex: 1;
|
|
3831
|
+
min-width: 0;
|
|
3832
|
+
overflow: hidden;
|
|
3833
|
+
text-overflow: ellipsis;
|
|
3834
|
+
white-space: nowrap;
|
|
3835
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
3836
|
+
font-size: 12px;
|
|
3837
|
+
}
|
|
3838
|
+
.confirm button {
|
|
3839
|
+
flex: none;
|
|
3840
|
+
padding: 8px 14px;
|
|
3841
|
+
border: 0;
|
|
3842
|
+
border-radius: 8px;
|
|
3843
|
+
font: inherit;
|
|
3844
|
+
cursor: pointer;
|
|
3845
|
+
}
|
|
3846
|
+
.confirm .ok { background: #fff; color: #1d64e0; font-weight: 600; }
|
|
3847
|
+
.confirm .no { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .5); }
|
|
3848
|
+
`;
|
|
3849
|
+
class is {
|
|
3850
|
+
constructor() {
|
|
3851
|
+
this.host = null, this.root = null, this.box = null, this.badge = null, this.confirmBar = null, this.confirmText = null, this.hovered = null, this.pending = null, this.raf = 0, this.active = !1, this.lastX = 0, this.lastY = 0, this.pointerKnown = !1, this.resolve = null, this.previousCursor = "", this.altPressed = !1, this.coarsePointer = !1, this.touchStartX = 0, this.touchStartY = 0, this.touchMoved = !1, this.ignoreElements = [], this.onMouseMove = (t) => {
|
|
3852
|
+
this.active && (this.lastX = t.clientX, this.lastY = t.clientY, this.pointerKnown = !0, !(this.coarsePointer || this.pending) && this.scheduleUpdate());
|
|
3853
|
+
}, this.onScroll = () => {
|
|
3854
|
+
if (!this.active) return;
|
|
3855
|
+
const t = this.pending || this.hovered;
|
|
3856
|
+
if (t) {
|
|
3857
|
+
if (!t.isConnected) {
|
|
3858
|
+
this.pending ? this.clearPending() : this.updateHighlight(null);
|
|
3859
|
+
return;
|
|
3860
|
+
}
|
|
3861
|
+
this.scheduleUpdate(t);
|
|
3862
|
+
return;
|
|
3863
|
+
}
|
|
3864
|
+
this.pointerKnown && !this.coarsePointer && this.scheduleUpdate();
|
|
3865
|
+
}, this.onClick = (t) => {
|
|
3866
|
+
if (!this.active) return;
|
|
3867
|
+
const r = this.hitTest(t.clientX, t.clientY);
|
|
3868
|
+
if (r) {
|
|
3869
|
+
if (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), this.coarsePointer) {
|
|
3870
|
+
this.setPending(r);
|
|
3871
|
+
return;
|
|
3872
|
+
}
|
|
3873
|
+
this.finish(pt(r));
|
|
3874
|
+
}
|
|
3875
|
+
}, this.onMousePress = (t) => {
|
|
3876
|
+
this.active && (this.isOwnUi(t.target) || (t.preventDefault(), t.stopPropagation()));
|
|
3877
|
+
}, this.onPointerPress = (t) => {
|
|
3878
|
+
this.active && t.pointerType !== "touch" && (this.isOwnUi(t.target) || (t.preventDefault(), t.stopPropagation()));
|
|
3879
|
+
}, this.onSuppress = (t) => {
|
|
3880
|
+
this.active && (this.isOwnUi(t.target) || (t.preventDefault(), t.stopPropagation()));
|
|
3881
|
+
}, this.onTouchStart = (t) => {
|
|
3882
|
+
if (!this.active || this.isOwnUi(t.target)) return;
|
|
3883
|
+
t.stopPropagation();
|
|
3884
|
+
const r = t.touches && t.touches[0];
|
|
3885
|
+
r && (this.touchStartX = r.clientX, this.touchStartY = r.clientY, this.touchMoved = !1);
|
|
3886
|
+
}, this.onTouchEnd = (t) => {
|
|
3887
|
+
if (!this.active || this.isOwnUi(t.target)) return;
|
|
3888
|
+
const r = t.changedTouches && t.changedTouches[0];
|
|
3889
|
+
if (!r || this.touchMoved || Math.abs(r.clientX - this.touchStartX) > K || Math.abs(r.clientY - this.touchStartY) > K) return;
|
|
3890
|
+
t.preventDefault(), t.stopPropagation();
|
|
3891
|
+
const n = this.hitTest(r.clientX, r.clientY);
|
|
3892
|
+
n && this.setPending(n);
|
|
3893
|
+
}, this.onTouchMove = (t) => {
|
|
3894
|
+
if (!this.active) return;
|
|
3895
|
+
const r = t.touches && t.touches[0];
|
|
3896
|
+
r && (Math.abs(r.clientX - this.touchStartX) > K || Math.abs(r.clientY - this.touchStartY) > K) && (this.touchMoved = !0);
|
|
3897
|
+
}, this.onKeyDown = (t) => {
|
|
3898
|
+
if (this.active) {
|
|
3899
|
+
if (t.key === "Escape") {
|
|
3900
|
+
if (t.preventDefault(), t.stopPropagation(), this.pending) {
|
|
3901
|
+
this.clearPending();
|
|
3902
|
+
return;
|
|
3903
|
+
}
|
|
3904
|
+
this.finish(null);
|
|
3905
|
+
return;
|
|
3906
|
+
}
|
|
3907
|
+
t.key === "Alt" && (this.altPressed = !0);
|
|
3908
|
+
}
|
|
3909
|
+
}, this.onKeyUp = (t) => {
|
|
3910
|
+
t.key === "Alt" && (this.altPressed = !1);
|
|
3911
|
+
};
|
|
3912
|
+
}
|
|
3913
|
+
start(t = {}) {
|
|
3914
|
+
return this.active ? Promise.resolve(null) : (this.active = !0, this.coarsePointer = this.detectCoarsePointer(), this.mount(t), new Promise((r) => {
|
|
3915
|
+
this.resolve = r, window.addEventListener("mousemove", this.onMouseMove, !0), window.addEventListener("click", this.onClick, !0), window.addEventListener("dblclick", this.onSuppress, !0), window.addEventListener("contextmenu", this.onSuppress, !0), window.addEventListener("mousedown", this.onMousePress, !0), window.addEventListener("pointerdown", this.onPointerPress, !0), window.addEventListener("touchstart", this.onTouchStart, { capture: !0, passive: !0 }), window.addEventListener("touchmove", this.onTouchMove, { capture: !0, passive: !0 }), window.addEventListener("touchend", this.onTouchEnd, { capture: !0, passive: !1 }), window.addEventListener("keydown", this.onKeyDown, !0), window.addEventListener("keyup", this.onKeyUp, !0), window.addEventListener("scroll", this.onScroll, { capture: !0, passive: !0 }), window.addEventListener("resize", this.onScroll, { passive: !0 });
|
|
3916
|
+
}));
|
|
3917
|
+
}
|
|
3918
|
+
// 触摸/触控笔为主,或视口很窄时,按移动端交互处理
|
|
3919
|
+
detectCoarsePointer() {
|
|
3920
|
+
try {
|
|
3921
|
+
return typeof window.matchMedia == "function" && window.matchMedia("(pointer: coarse)").matches ? !0 : window.innerWidth <= 560;
|
|
3922
|
+
} catch (t) {
|
|
3923
|
+
return !1;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
stop() {
|
|
3927
|
+
this.finish(null);
|
|
3928
|
+
}
|
|
3929
|
+
mount(t) {
|
|
3930
|
+
const r = document.createElement("div");
|
|
3931
|
+
r.setAttribute("data-bug-tap-picker", ""), this.host = r;
|
|
3932
|
+
const i = r.attachShadow({ mode: "open" });
|
|
3933
|
+
this.root = i;
|
|
3934
|
+
let n = null;
|
|
3935
|
+
try {
|
|
3936
|
+
if (typeof CSSStyleSheet != "undefined" && "adoptedStyleSheets" in i) {
|
|
3937
|
+
const g = new CSSStyleSheet();
|
|
3938
|
+
g.replaceSync(gt), i.adoptedStyleSheets = [...i.adoptedStyleSheets, g];
|
|
3939
|
+
} else
|
|
3940
|
+
n = document.createElement("style"), n.textContent = gt;
|
|
3941
|
+
} catch (g) {
|
|
3942
|
+
n = document.createElement("style"), n.textContent = gt;
|
|
3943
|
+
}
|
|
3944
|
+
const s = document.createElement("div");
|
|
3945
|
+
s.className = "box", s.style.display = "none", this.box = s;
|
|
3946
|
+
const o = document.createElement("div");
|
|
3947
|
+
o.className = "badge", o.style.display = "none", this.badge = o;
|
|
3948
|
+
const a = document.createElement("div");
|
|
3949
|
+
a.className = "bar";
|
|
3950
|
+
const c = document.createElement("span");
|
|
3951
|
+
c.innerHTML = this.coarsePointer ? "轻点要反馈的页面元素" : `${t.hint || "点击要反馈的页面元素"} <kbd>Alt</kbd> 选中父级 <kbd>Esc</kbd> 取消`;
|
|
3952
|
+
const l = document.createElement("button");
|
|
3953
|
+
l.type = "button", l.textContent = "取消", l.addEventListener("click", () => this.finish(null)), a.append(c, l);
|
|
3954
|
+
const h = document.createElement("div");
|
|
3955
|
+
h.className = "confirm";
|
|
3956
|
+
const u = document.createElement("div");
|
|
3957
|
+
u.className = "confirm-text";
|
|
3958
|
+
const d = document.createElement("button");
|
|
3959
|
+
d.type = "button", d.className = "no", d.textContent = "重选", d.addEventListener("click", () => this.clearPending());
|
|
3960
|
+
const p = document.createElement("button");
|
|
3961
|
+
p.type = "button", p.className = "ok", p.textContent = "确认", p.addEventListener("click", () => {
|
|
3962
|
+
this.pending && this.finish(pt(this.pending));
|
|
3963
|
+
}), h.append(u, d, p), this.confirmBar = h, this.confirmText = u, i.append(a, s, o, h), n && i.append(n), document.documentElement.appendChild(r), this.previousCursor = document.documentElement.style.cursor, document.documentElement.style.cursor = this.coarsePointer ? "default" : "crosshair";
|
|
3964
|
+
try {
|
|
3965
|
+
document.documentElement.setAttribute("data-bug-tap-picking", "");
|
|
3966
|
+
} catch (g) {
|
|
3967
|
+
}
|
|
3968
|
+
this.ignoreElements = t.ignoreElements || [];
|
|
3969
|
+
}
|
|
3970
|
+
isIgnored(t) {
|
|
3971
|
+
if (!t) return !0;
|
|
3972
|
+
let r = t;
|
|
3973
|
+
for (; r; ) {
|
|
3974
|
+
if (this.ignoreElements.indexOf(r) >= 0 || r.hasAttribute && r.hasAttribute("data-bug-tap-picker")) return !0;
|
|
3975
|
+
const i = r.getRootNode ? r.getRootNode() : null;
|
|
3976
|
+
if (i && i.host) {
|
|
3977
|
+
r = i.host;
|
|
3978
|
+
continue;
|
|
3979
|
+
}
|
|
3980
|
+
r = r.parentElement;
|
|
3981
|
+
}
|
|
3982
|
+
return !1;
|
|
3983
|
+
}
|
|
3984
|
+
hitTest(t, r) {
|
|
3985
|
+
const i = document.elementFromPoint(t, r);
|
|
3986
|
+
if (!i || this.isIgnored(i)) return null;
|
|
3987
|
+
if (this.altPressed && i.parentElement) {
|
|
3988
|
+
const n = i.parentElement;
|
|
3989
|
+
if (!this.isIgnored(n)) return n;
|
|
3990
|
+
}
|
|
3991
|
+
return i;
|
|
3992
|
+
}
|
|
3993
|
+
scheduleUpdate(t) {
|
|
3994
|
+
this.raf || (this.raf = requestAnimationFrame(() => {
|
|
3995
|
+
if (this.raf = 0, t) {
|
|
3996
|
+
this.updateHighlight(t);
|
|
3997
|
+
return;
|
|
3998
|
+
}
|
|
3999
|
+
this.updateHighlight(this.hitTest(this.lastX, this.lastY));
|
|
4000
|
+
}));
|
|
4001
|
+
}
|
|
4002
|
+
updateHighlight(t) {
|
|
4003
|
+
if (!this.box || !this.badge) return;
|
|
4004
|
+
if (!t) {
|
|
4005
|
+
this.box.style.display = "none", this.badge.style.display = "none", this.hovered = null;
|
|
4006
|
+
return;
|
|
4007
|
+
}
|
|
4008
|
+
this.hovered = t;
|
|
4009
|
+
const r = t.getBoundingClientRect();
|
|
4010
|
+
this.box.style.display = "block", this.box.style.top = `${r.top}px`, this.box.style.left = `${r.left}px`, this.box.style.width = `${r.width}px`, this.box.style.height = `${r.height}px`;
|
|
4011
|
+
const i = `${t.tagName.toLowerCase()}${t.id ? `#${t.id}` : ""}`;
|
|
4012
|
+
this.badge.style.display = "block", this.badge.textContent = i, this.badge.style.left = `${Math.max(4, r.left)}px`, this.badge.style.top = `${r.top > 26 ? r.top - 24 : r.bottom + 4}px`;
|
|
4013
|
+
}
|
|
4014
|
+
// 拾取器自身的提示条 / 确认条:其上的点击要正常工作
|
|
4015
|
+
isOwnUi(t) {
|
|
4016
|
+
if (!t) return !0;
|
|
4017
|
+
let r = t;
|
|
4018
|
+
for (; r; ) {
|
|
4019
|
+
if (r.hasAttribute && r.hasAttribute("data-bug-tap-picker")) return !0;
|
|
4020
|
+
const i = r.getRootNode ? r.getRootNode() : null;
|
|
4021
|
+
if (i && i.host) {
|
|
4022
|
+
r = i.host;
|
|
4023
|
+
continue;
|
|
4024
|
+
}
|
|
4025
|
+
r = r.parentElement;
|
|
4026
|
+
}
|
|
4027
|
+
return !1;
|
|
4028
|
+
}
|
|
4029
|
+
setPending(t) {
|
|
4030
|
+
this.pending = t, this.updateHighlight(t), this.confirmBar && this.confirmText && (this.confirmText.textContent = pt(t).selector, this.confirmBar.classList.add("confirm--show"));
|
|
4031
|
+
}
|
|
4032
|
+
clearPending() {
|
|
4033
|
+
var t;
|
|
4034
|
+
this.pending = null, (t = this.confirmBar) == null || t.classList.remove("confirm--show"), this.updateHighlight(null);
|
|
4035
|
+
}
|
|
4036
|
+
finish(t) {
|
|
4037
|
+
var i;
|
|
4038
|
+
if (!this.active) return;
|
|
4039
|
+
this.active = !1, window.removeEventListener("mousemove", this.onMouseMove, !0), window.removeEventListener("click", this.onClick, !0), window.removeEventListener("dblclick", this.onSuppress, !0), window.removeEventListener("contextmenu", this.onSuppress, !0), window.removeEventListener("mousedown", this.onMousePress, !0), window.removeEventListener("pointerdown", this.onPointerPress, !0), window.removeEventListener("touchstart", this.onTouchStart, { capture: !0 }), window.removeEventListener("touchmove", this.onTouchMove, { capture: !0 }), window.removeEventListener("touchend", this.onTouchEnd, { capture: !0 }), window.removeEventListener("keydown", this.onKeyDown, !0), window.removeEventListener("keyup", this.onKeyUp, !0), window.removeEventListener("scroll", this.onScroll, { capture: !0 }), window.removeEventListener("resize", this.onScroll), this.raf && (cancelAnimationFrame(this.raf), this.raf = 0), document.documentElement.style.cursor = this.previousCursor;
|
|
4040
|
+
try {
|
|
4041
|
+
document.documentElement.removeAttribute("data-bug-tap-picking");
|
|
4042
|
+
} catch (n) {
|
|
4043
|
+
}
|
|
4044
|
+
(i = this.host) == null || i.remove(), this.host = null, this.root = null, this.box = null, this.badge = null, this.confirmBar = null, this.confirmText = null, this.hovered = null, this.pending = null, this.altPressed = !1, this.ignoreElements = [], this.pointerKnown = !1;
|
|
4045
|
+
const r = this.resolve;
|
|
4046
|
+
this.resolve = null, r && r(t);
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
const wr = "bug-tap-enabled";
|
|
4050
|
+
function ns() {
|
|
4051
|
+
try {
|
|
4052
|
+
const e = localStorage.getItem(wr);
|
|
4053
|
+
return e === "1" || e === "0" ? e : null;
|
|
4054
|
+
} catch (e) {
|
|
4055
|
+
return null;
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
function vr(e) {
|
|
4059
|
+
try {
|
|
4060
|
+
localStorage.setItem(wr, e ? "1" : "0");
|
|
4061
|
+
} catch (t) {
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
function ss(e) {
|
|
4065
|
+
if (typeof location == "undefined") return null;
|
|
4066
|
+
try {
|
|
4067
|
+
const t = new URLSearchParams(location.search);
|
|
4068
|
+
if (!t.has(e.queryParam)) {
|
|
4069
|
+
const r = location.hash.includes("?") ? location.hash.slice(location.hash.indexOf("?") + 1) : "";
|
|
4070
|
+
if (!r) return null;
|
|
4071
|
+
const i = new URLSearchParams(r);
|
|
4072
|
+
return i.has(e.queryParam) ? Qe(i.get(e.queryParam), e.queryValue) : null;
|
|
4073
|
+
}
|
|
4074
|
+
return Qe(t.get(e.queryParam), e.queryValue);
|
|
4075
|
+
} catch (t) {
|
|
4076
|
+
return null;
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
function Qe(e, t) {
|
|
4080
|
+
return t ? e === t || e === "1" || e === "true" : !0;
|
|
4081
|
+
}
|
|
4082
|
+
function os(e) {
|
|
4083
|
+
const t = ss(e);
|
|
4084
|
+
if (t === !0)
|
|
4085
|
+
return vr(!0), !0;
|
|
4086
|
+
if (t === !1) return !1;
|
|
4087
|
+
const r = ns();
|
|
4088
|
+
return r === "0" ? !1 : e.mode === "triggered" ? r === "1" : !0;
|
|
4089
|
+
}
|
|
4090
|
+
function as() {
|
|
4091
|
+
if (typeof window == "undefined") return null;
|
|
4092
|
+
const e = window.BugTap;
|
|
4093
|
+
return e && typeof e.captureException == "function" ? e : null;
|
|
4094
|
+
}
|
|
4095
|
+
function z(e) {
|
|
4096
|
+
if (!e || typeof e != "object") return;
|
|
4097
|
+
const t = e, r = typeof t.fullPath == "string" ? t.fullPath : t.path;
|
|
4098
|
+
return typeof r == "string" ? r.slice(0, 500) : void 0;
|
|
4099
|
+
}
|
|
4100
|
+
function cs(e) {
|
|
4101
|
+
if (!e || typeof e != "object") return;
|
|
4102
|
+
const t = e.name;
|
|
4103
|
+
return typeof t == "string" ? t.slice(0, 100) : void 0;
|
|
4104
|
+
}
|
|
4105
|
+
function ls() {
|
|
4106
|
+
try {
|
|
4107
|
+
return `${location.pathname}${location.search}${location.hash}`.slice(0, 500);
|
|
4108
|
+
} catch (e) {
|
|
4109
|
+
return;
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
function hs(e) {
|
|
4113
|
+
var s, o, a, c, l, h, u, d, p, g;
|
|
4114
|
+
if (!e || typeof e != "object") return;
|
|
4115
|
+
const t = e, r = (o = (s = t.$) == null ? void 0 : s.type) != null ? o : t.type, i = t.$options, n = (g = (p = (u = (l = (c = (a = i == null ? void 0 : i.name) != null ? a : i == null ? void 0 : i.__name) != null ? c : r == null ? void 0 : r.name) != null ? l : r == null ? void 0 : r.__name) != null ? u : (h = t.type) == null ? void 0 : h.name) != null ? p : (d = t.type) == null ? void 0 : d.__name) != null ? g : i == null ? void 0 : i._componentTag;
|
|
4116
|
+
return typeof n == "string" && n ? n : void 0;
|
|
4117
|
+
}
|
|
4118
|
+
function us(e) {
|
|
4119
|
+
if (!(!e || typeof e != "object"))
|
|
4120
|
+
return z(e.$route);
|
|
4121
|
+
}
|
|
4122
|
+
function ds(e) {
|
|
4123
|
+
var t;
|
|
4124
|
+
return (t = us(e)) != null ? t : ls();
|
|
4125
|
+
}
|
|
4126
|
+
function xr(e) {
|
|
4127
|
+
return {
|
|
4128
|
+
install(t, r = {}) {
|
|
4129
|
+
const i = r.client || e || as();
|
|
4130
|
+
if (!i)
|
|
4131
|
+
return () => {
|
|
4132
|
+
};
|
|
4133
|
+
const n = t.config, s = [];
|
|
4134
|
+
if (r.captureErrors !== !1 && n) {
|
|
4135
|
+
const o = n.errorHandler, a = (c, l, h) => {
|
|
4136
|
+
try {
|
|
4137
|
+
i.captureException(c, {
|
|
4138
|
+
source: "vue",
|
|
4139
|
+
info: h,
|
|
4140
|
+
component: hs(l),
|
|
4141
|
+
route: ds(l)
|
|
4142
|
+
});
|
|
4143
|
+
} catch (u) {
|
|
4144
|
+
}
|
|
4145
|
+
typeof o == "function" && o(c, l, h);
|
|
4146
|
+
};
|
|
4147
|
+
n.errorHandler = a, s.push(() => {
|
|
4148
|
+
n.errorHandler === a && (n.errorHandler = o || null);
|
|
4149
|
+
});
|
|
4150
|
+
}
|
|
4151
|
+
if (r.router && typeof r.router.afterEach == "function") {
|
|
4152
|
+
try {
|
|
4153
|
+
i.disableRouteCapture();
|
|
4154
|
+
} catch (a) {
|
|
4155
|
+
}
|
|
4156
|
+
const o = r.router.afterEach((a, c, l) => {
|
|
4157
|
+
try {
|
|
4158
|
+
if (l) {
|
|
4159
|
+
i.captureException(
|
|
4160
|
+
l instanceof Error ? l : new Error(String(l)),
|
|
4161
|
+
{ source: "vue-router", from: z(c), to: z(a) }
|
|
4162
|
+
);
|
|
4163
|
+
return;
|
|
4164
|
+
}
|
|
4165
|
+
i.addBreadcrumb({
|
|
4166
|
+
type: "route",
|
|
4167
|
+
from: z(c),
|
|
4168
|
+
to: z(a),
|
|
4169
|
+
data: { name: cs(a), source: "vue-router" }
|
|
4170
|
+
});
|
|
4171
|
+
} catch (h) {
|
|
4172
|
+
}
|
|
4173
|
+
});
|
|
4174
|
+
s.push(() => {
|
|
4175
|
+
typeof o == "function" && o();
|
|
4176
|
+
});
|
|
4177
|
+
}
|
|
4178
|
+
return () => {
|
|
4179
|
+
s.forEach((o) => {
|
|
4180
|
+
try {
|
|
4181
|
+
o();
|
|
4182
|
+
} catch (a) {
|
|
4183
|
+
}
|
|
4184
|
+
});
|
|
4185
|
+
};
|
|
4186
|
+
}
|
|
4187
|
+
};
|
|
4188
|
+
}
|
|
4189
|
+
const Es = xr();
|
|
4190
|
+
function fs(e, t) {
|
|
4191
|
+
return !e || !e.config ? () => {
|
|
4192
|
+
} : xr(t).install(e, { client: t, captureErrors: !0 });
|
|
4193
|
+
}
|
|
4194
|
+
function ps(e) {
|
|
4195
|
+
const t = (r, i) => {
|
|
4196
|
+
try {
|
|
4197
|
+
e.captureException(r, {
|
|
4198
|
+
source: "react",
|
|
4199
|
+
componentStack: i && i.componentStack ? i.componentStack.slice(0, 4e3) : void 0
|
|
4200
|
+
});
|
|
4201
|
+
} catch (n) {
|
|
4202
|
+
}
|
|
4203
|
+
};
|
|
4204
|
+
return {
|
|
4205
|
+
onUncaughtError: t,
|
|
4206
|
+
onCaughtError: t,
|
|
4207
|
+
onRecoverableError: t
|
|
4208
|
+
};
|
|
4209
|
+
}
|
|
4210
|
+
const gs = typeof window != "undefined" && window.console && typeof window.console.debug == "function" ? window.console.debug.bind(window.console) : () => {
|
|
4211
|
+
};
|
|
4212
|
+
class Er {
|
|
4213
|
+
constructor(t) {
|
|
4214
|
+
this.host = null, this.fab = null, this.panel = null, this.panelLoading = null, this.openCancelled = !1, this.picker = null, this.lastClientReportId = null, this.pendingMount = 0, this.configErrors = [], this.tags = /* @__PURE__ */ new Map(), this.extras = /* @__PURE__ */ new Map(), this.contexts = /* @__PURE__ */ new Map(), this.initialized = !1, this.routeCaptureOwned = !1, this.rawConfig = t, this.config = it(t), this.collector = new _e(this.config), this.transport = new We(this.config), Ye(this.config.screenshot.scriptUrl), this.configErrors = yt(t), this.configErrors.length > 0 && this.warn(`配置不完整:${this.configErrors.join(";")}。上报按钮不会显示。`);
|
|
4215
|
+
}
|
|
4216
|
+
init() {
|
|
4217
|
+
this.initialized || (this.initialized = !0, this.collector.start(), this.transport.start(), this.config.reporter.enabled && this.isConfigured() && (this.mountFab(), this.applyFabVisibility()));
|
|
4218
|
+
}
|
|
4219
|
+
open() {
|
|
4220
|
+
this.openReporter();
|
|
4221
|
+
}
|
|
4222
|
+
close() {
|
|
4223
|
+
this.closeReporter();
|
|
4224
|
+
}
|
|
4225
|
+
openReporter() {
|
|
4226
|
+
var t, r;
|
|
4227
|
+
if (!this.config.reporter.enabled) {
|
|
4228
|
+
this.warn("上报入口已被 reporter.enabled=false 关闭");
|
|
4229
|
+
return;
|
|
4230
|
+
}
|
|
4231
|
+
if (!this.isConfigured()) {
|
|
4232
|
+
this.warn("缺少 project,无法打开上报面板");
|
|
4233
|
+
return;
|
|
4234
|
+
}
|
|
4235
|
+
if (this.panel !== null) {
|
|
4236
|
+
this.panel.open(this.config.screenshot.enabled && this.config.screenshot.auto);
|
|
4237
|
+
return;
|
|
4238
|
+
}
|
|
4239
|
+
if (this.panelLoading) {
|
|
4240
|
+
this.openCancelled = !1;
|
|
4241
|
+
const i = this.panelLoading;
|
|
4242
|
+
(t = this.fab) == null || t.setLoading(!0), i.then((n) => {
|
|
4243
|
+
var s, o;
|
|
4244
|
+
!n || this.openCancelled || ((s = this.panel) == null || s.open(this.config.screenshot.enabled && this.config.screenshot.auto), (o = this.fab) == null || o.setLoading(!1));
|
|
4245
|
+
});
|
|
4246
|
+
return;
|
|
4247
|
+
}
|
|
4248
|
+
this.openCancelled = !1, (r = this.fab) == null || r.setLoading(!0), this.cancelPendingMount(), this.pendingMount = requestAnimationFrame(() => {
|
|
4249
|
+
this.pendingMount = 0;
|
|
4250
|
+
const i = this.mountPanel();
|
|
4251
|
+
this.panelLoading = i, i.then((n) => {
|
|
4252
|
+
var s;
|
|
4253
|
+
!n || this.openCancelled || (s = this.panel) == null || s.open(this.config.screenshot.enabled && this.config.screenshot.auto);
|
|
4254
|
+
}).catch((n) => {
|
|
4255
|
+
this.warn(`面板挂载失败:${j(n)}`);
|
|
4256
|
+
}).finally(() => {
|
|
4257
|
+
var n;
|
|
4258
|
+
this.panelLoading === i && (this.panelLoading = null), (n = this.fab) == null || n.setLoading(!1);
|
|
4259
|
+
});
|
|
4260
|
+
});
|
|
4261
|
+
}
|
|
4262
|
+
cancelPendingMount() {
|
|
4263
|
+
this.pendingMount && (cancelAnimationFrame(this.pendingMount), this.pendingMount = 0);
|
|
4264
|
+
}
|
|
4265
|
+
closeReporter() {
|
|
4266
|
+
var t, r;
|
|
4267
|
+
this.cancelPendingMount(), this.openCancelled = !0, (t = this.fab) == null || t.setLoading(!1), (r = this.panel) == null || r.close();
|
|
4268
|
+
}
|
|
4269
|
+
setConfig(t) {
|
|
4270
|
+
const r = jr(this.rawConfig, t), i = this.config;
|
|
4271
|
+
this.rawConfig = r, this.config = it(r), Ye(this.config.screenshot.scriptUrl), this.initialized && this.transport.stop(), this.transport = new We(this.config), this.initialized && this.transport.start(), this.configErrors = yt(r), this.configErrors.length > 0 && this.warn(`配置不完整:${this.configErrors.join(";")}。上报按钮不会显示。`), (JSON.stringify(i.collect) !== JSON.stringify(this.config.collect) || // RegExp 序列化恒为 {},这里要单独比较
|
|
4272
|
+
!$(i.privacy.excludeUrls, this.config.privacy.excludeUrls) || !$(i.privacy.excludeConsolePatterns, this.config.privacy.excludeConsolePatterns) || // 面包屑的排除规则在构造时固化进 BreadcrumbCollector,不重建就不生效
|
|
4273
|
+
!$(
|
|
4274
|
+
i.privacy.excludeBreadcrumbUrls,
|
|
4275
|
+
this.config.privacy.excludeBreadcrumbUrls
|
|
4276
|
+
) || // 噪声过滤规则与 beforeBreadcrumb 同样是构造时注入的,改了就重建
|
|
4277
|
+
!$(i.filtering.ignoreErrors, this.config.filtering.ignoreErrors) || !$(i.filtering.denyUrls, this.config.filtering.denyUrls) || !$(i.filtering.allowUrls, this.config.filtering.allowUrls) || i.hooks.beforeBreadcrumb !== this.config.hooks.beforeBreadcrumb || i.endpoint !== this.config.endpoint || i.upload.url !== this.config.upload.url || // 采集侧的 body 读取预算由 maxItemBytes 反推(effectiveCloneBytes),
|
|
4278
|
+
// 漏掉这一项会让单条记录超出 maxItemBytes,打破「一条记录不拆」的前提
|
|
4279
|
+
i.transport.maxItemBytes !== this.config.transport.maxItemBytes) && (this.collector.stop(), this.collector = new _e(this.config), this.routeCaptureOwned && this.collector.disableRouteCapture(), this.initialized && this.collector.start()), this.cancelPendingMount(), this.panelLoading = null;
|
|
4280
|
+
const s = this.panel !== null;
|
|
4281
|
+
this.unmountUi(), this.initialized && this.config.reporter.enabled && this.isConfigured() && (this.mountFab(), s && this.mountPanel(), this.applyFabVisibility());
|
|
4282
|
+
}
|
|
4283
|
+
/**
|
|
4284
|
+
* 运行时更新登录用户信息。
|
|
4285
|
+
* 不走 setConfig:deep merge 会把 undefined 当作「没传」而保留旧值,
|
|
4286
|
+
* 这里需要能把用户信息真正清空,所以直接改 rawConfig 再重新归一化。
|
|
4287
|
+
*/
|
|
4288
|
+
setUser(t) {
|
|
4289
|
+
this.rawConfig = { ...this.rawConfig, user: t || void 0 }, this.config = it(this.rawConfig), Hi();
|
|
4290
|
+
}
|
|
4291
|
+
setTag(t, r) {
|
|
4292
|
+
mt(this.tags, t, typeof r == "string" ? r.slice(0, 64) : r);
|
|
4293
|
+
}
|
|
4294
|
+
setExtra(t, r) {
|
|
4295
|
+
mt(this.extras, t, et(r));
|
|
4296
|
+
}
|
|
4297
|
+
setContext(t, r) {
|
|
4298
|
+
mt(this.contexts, t, et(r));
|
|
4299
|
+
}
|
|
4300
|
+
addBreadcrumb(t) {
|
|
4301
|
+
const r = {
|
|
4302
|
+
...t,
|
|
4303
|
+
t: Date.now(),
|
|
4304
|
+
type: t.type || "manual"
|
|
4305
|
+
};
|
|
4306
|
+
this.collector.addBreadcrumb(r);
|
|
4307
|
+
}
|
|
4308
|
+
captureException(t, r) {
|
|
4309
|
+
this.collector.captureException(t, r);
|
|
4310
|
+
}
|
|
4311
|
+
captureMessage(t, r) {
|
|
4312
|
+
this.collector.captureMessage(t, r);
|
|
4313
|
+
}
|
|
4314
|
+
/**
|
|
4315
|
+
* 交给框架路由接管导航记录(vue-router 插件调用)。
|
|
4316
|
+
* 摘掉主包的 history 补丁后,路由变化改由 router.afterEach 显式写入,
|
|
4317
|
+
* 避免同一次导航被记两遍。
|
|
4318
|
+
*/
|
|
4319
|
+
disableRouteCapture() {
|
|
4320
|
+
this.routeCaptureOwned = !0, this.collector.disableRouteCapture();
|
|
4321
|
+
}
|
|
4322
|
+
installVueErrorHandler(t) {
|
|
4323
|
+
return fs(t, this);
|
|
4324
|
+
}
|
|
4325
|
+
reactErrorHandlers() {
|
|
4326
|
+
return ps(this);
|
|
4327
|
+
}
|
|
4328
|
+
flush() {
|
|
4329
|
+
return this.transport.flush();
|
|
4330
|
+
}
|
|
4331
|
+
destroy() {
|
|
4332
|
+
var t, r;
|
|
4333
|
+
this.cancelPendingMount(), (t = this.panel) == null || t.close(), (r = this.picker) == null || r.stop(), this.picker = null, this.unmountUi(), this.collector.stop(), this.transport.stop(), this.initialized = !1, this.tags.clear(), this.extras.clear(), this.contexts.clear(), this.lastClientReportId = null;
|
|
4334
|
+
}
|
|
4335
|
+
getReport() {
|
|
4336
|
+
const t = this.buildWithHooks({
|
|
4337
|
+
values: { title: "", description: "" },
|
|
4338
|
+
data: this.collector.getData(),
|
|
4339
|
+
config: this.config,
|
|
4340
|
+
clientReportId: this.lastClientReportId || void 0,
|
|
4341
|
+
...this.runtimeContext()
|
|
4342
|
+
});
|
|
4343
|
+
if (Ze(t))
|
|
4344
|
+
throw new Error("hooks.beforeSend 返回了 Promise,getReport 只支持同步钩子");
|
|
4345
|
+
if (!t) throw new Error("报告已被 hooks.beforeSend 丢弃");
|
|
4346
|
+
return t;
|
|
4347
|
+
}
|
|
4348
|
+
/**
|
|
4349
|
+
* buildReport + beforeSend(对应 Sentry 的 beforeSend):
|
|
4350
|
+
* 返回 null 表示放弃这条报告(例如用户只是想看一眼,不希望上报),
|
|
4351
|
+
* 钩子抛错时按「不修改」放行,不能因为业务 bug 丢掉整条反馈。
|
|
4352
|
+
* beforeSend 允许返回 Promise:提交路径会等待,getReport 会明确报错。
|
|
4353
|
+
*/
|
|
4354
|
+
buildWithHooks(t) {
|
|
4355
|
+
const r = Ki(t), i = this.config.hooks.beforeSend;
|
|
4356
|
+
if (!i) return r;
|
|
4357
|
+
const n = (s) => s === null ? null : s && typeof s == "object" ? s : r;
|
|
4358
|
+
try {
|
|
4359
|
+
const s = i(r);
|
|
4360
|
+
return Ze(s) ? s.then(n, (o) => (this.warn(`beforeSend 执行失败:${j(o)}`), r)) : n(s);
|
|
4361
|
+
} catch (s) {
|
|
4362
|
+
return this.warn(`beforeSend 执行失败:${j(s)}`), r;
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4365
|
+
/** 业务通过 setTag / setExtra / setContext 写入的上下文,每次组装报告时快照 */
|
|
4366
|
+
runtimeContext() {
|
|
4367
|
+
const t = (r) => r.size > 0 ? Object.fromEntries(r) : void 0;
|
|
4368
|
+
return {
|
|
4369
|
+
tags: t(this.tags),
|
|
4370
|
+
extra: t(this.extras),
|
|
4371
|
+
contexts: t(this.contexts)
|
|
4372
|
+
};
|
|
4373
|
+
}
|
|
4374
|
+
// 只挂悬浮按钮(很轻),面板等首次点击时再挂
|
|
4375
|
+
mountFab() {
|
|
4376
|
+
this.fab || (this.host = new On(this.config.reporter.theme, this.config.reporter.zIndex), this.fab = new zn({
|
|
4377
|
+
text: this.config.reporter.text,
|
|
4378
|
+
position: this.config.reporter.position,
|
|
4379
|
+
onClick: () => this.openReporter()
|
|
4380
|
+
}), this.host.root.append(this.fab.element), this.host.mount(), this.fab.restorePosition());
|
|
4381
|
+
}
|
|
4382
|
+
mountPanel() {
|
|
4383
|
+
if (this.panel) return Promise.resolve(this.panel);
|
|
4384
|
+
this.host || this.mountFab();
|
|
4385
|
+
const t = this.host;
|
|
4386
|
+
return t ? import("./panel-mount-mAOg572s.js").then(
|
|
4387
|
+
(r) => new r.ReporterPanel({
|
|
4388
|
+
onSubmit: (i, n, s) => this.submit(i, n, s),
|
|
4389
|
+
onCapture: () => this.capture(),
|
|
4390
|
+
onUpload: (i) => this.upload(i),
|
|
4391
|
+
onPickElement: () => this.pickElement(),
|
|
4392
|
+
canUploadScreenshot: this.config.screenshot.enabled,
|
|
4393
|
+
maxElements: this.config.collect.maxElements,
|
|
4394
|
+
onDisable: this.config.reporter.visibility.closable ? () => {
|
|
4395
|
+
var i;
|
|
4396
|
+
vr(!1), (i = this.fab) == null || i.hide();
|
|
4397
|
+
} : void 0
|
|
4398
|
+
})
|
|
4399
|
+
).then((r) => this.host !== t ? (r.unmount(), null) : this.panel ? (r.unmount(), this.panel) : (this.panel = r, t.root.append(r.overlay), r)) : Promise.resolve(null);
|
|
4400
|
+
}
|
|
4401
|
+
applyFabVisibility() {
|
|
4402
|
+
if (!this.fab) return;
|
|
4403
|
+
os(this.config.reporter.visibility) ? this.fab.show() : this.fab.hide();
|
|
4404
|
+
}
|
|
4405
|
+
unmountUi() {
|
|
4406
|
+
var t, r, i, n, s;
|
|
4407
|
+
(t = this.picker) == null || t.stop(), this.picker = null, (r = this.panel) == null || r.close(), (i = this.panel) == null || i.unmount(), (n = this.fab) == null || n.destroy(), (s = this.host) == null || s.unmount(), this.host = null, this.fab = null, this.panel = null;
|
|
4408
|
+
}
|
|
4409
|
+
capture() {
|
|
4410
|
+
return this.config.screenshot.enabled ? this.host ? Yn({
|
|
4411
|
+
ignoreElement: this.host.host,
|
|
4412
|
+
quality: this.config.screenshot.quality,
|
|
4413
|
+
maxWidth: this.config.screenshot.maxWidth,
|
|
4414
|
+
maxSizeKB: this.config.screenshot.maxSizeKB,
|
|
4415
|
+
source: "auto"
|
|
4416
|
+
}) : Promise.reject(new Error("上报面板未初始化")) : Promise.reject(new Error("截图功能已关闭"));
|
|
4417
|
+
}
|
|
4418
|
+
upload(t) {
|
|
4419
|
+
return this.config.screenshot.enabled ? Kn(t, {
|
|
4420
|
+
quality: this.config.screenshot.quality,
|
|
4421
|
+
maxWidth: this.config.screenshot.maxWidth,
|
|
4422
|
+
maxSizeKB: this.config.screenshot.maxSizeKB,
|
|
4423
|
+
source: "manual"
|
|
4424
|
+
}) : Promise.reject(new Error("截图功能已关闭"));
|
|
4425
|
+
}
|
|
4426
|
+
submit(t, r, i) {
|
|
4427
|
+
return this.isConfigured() ? this.prepareScreenshots(r).then((n) => {
|
|
4428
|
+
const s = this.collector.getData(), o = this.buildWithHooks({
|
|
4429
|
+
values: t,
|
|
4430
|
+
data: s,
|
|
4431
|
+
config: this.config,
|
|
4432
|
+
clientReportId: this.lastClientReportId || void 0,
|
|
4433
|
+
screenshots: n.length > 0 ? n : void 0,
|
|
4434
|
+
elements: i.length > 0 ? i : void 0,
|
|
4435
|
+
...this.runtimeContext()
|
|
4436
|
+
});
|
|
4437
|
+
return Promise.resolve(o).then((a) => {
|
|
4438
|
+
if (!a) throw new Error("报告已被 hooks.beforeSend 丢弃");
|
|
4439
|
+
return this.lastClientReportId = a.clientReportId, this.transport.send(a).catch((c) => {
|
|
4440
|
+
if (c instanceof w && c.queued)
|
|
4441
|
+
return {
|
|
4442
|
+
success: !0,
|
|
4443
|
+
queued: !0,
|
|
4444
|
+
reportId: a.clientReportId,
|
|
4445
|
+
message: "网络异常,反馈已保存,恢复后会自动提交"
|
|
4446
|
+
};
|
|
4447
|
+
throw c;
|
|
4448
|
+
}).finally(() => {
|
|
4449
|
+
this.lastClientReportId = null;
|
|
4450
|
+
});
|
|
4451
|
+
});
|
|
4452
|
+
}) : Promise.reject(new Error("缺少 project,无法提交"));
|
|
4453
|
+
}
|
|
4454
|
+
// 先上传截图换成 url,失败时降级为内联 base64,不阻断提交
|
|
4455
|
+
pickElement() {
|
|
4456
|
+
return this.host ? (this.picker || (this.picker = new is()), this.picker.start({
|
|
4457
|
+
ignoreElements: [this.host.host]
|
|
4458
|
+
})) : Promise.reject(new Error("上报面板未初始化"));
|
|
4459
|
+
}
|
|
4460
|
+
// 逐张上传,单张失败只降级那一张为内联 base64,不影响其余
|
|
4461
|
+
prepareScreenshots(t) {
|
|
4462
|
+
return t.length === 0 ? Promise.resolve([]) : Promise.all(t.map((r) => this.prepareScreenshot(r)));
|
|
4463
|
+
}
|
|
4464
|
+
prepareScreenshot(t) {
|
|
4465
|
+
return this.config.upload.enabled ? $n(t, this.config.upload).then((r) => ({ ...t, url: r, dataBase64: void 0 })).catch((r) => (this.warn(`截图上传失败,改为内联提交:${j(r)}`), t)) : Promise.resolve(t);
|
|
4466
|
+
}
|
|
4467
|
+
isConfigured() {
|
|
4468
|
+
return this.configErrors.length === 0;
|
|
4469
|
+
}
|
|
4470
|
+
warn(t) {
|
|
4471
|
+
this.config.debug && gs(`[bug-tap] ${t}`);
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
function Ze(e) {
|
|
4475
|
+
return !!(e && typeof e.then == "function");
|
|
4476
|
+
}
|
|
4477
|
+
const ms = 6, G = 50, bs = 50;
|
|
4478
|
+
function mt(e, t, r) {
|
|
4479
|
+
const i = String(t || "").slice(0, 64);
|
|
4480
|
+
if (i) {
|
|
4481
|
+
if (e.delete(i), e.size >= bs) {
|
|
4482
|
+
const n = e.keys().next();
|
|
4483
|
+
n.done || e.delete(n.value);
|
|
4484
|
+
}
|
|
4485
|
+
e.set(i, r);
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
4488
|
+
function et(e, t = 0, r) {
|
|
4489
|
+
const i = typeof e;
|
|
4490
|
+
if (e === null || i === "string" || i === "number" || i === "boolean") return e;
|
|
4491
|
+
if (i === "undefined" || i === "function" || i === "symbol" || i === "bigint")
|
|
4492
|
+
return i === "bigint" ? String(e) : void 0;
|
|
4493
|
+
if (e instanceof Date)
|
|
4494
|
+
try {
|
|
4495
|
+
return e.toISOString();
|
|
4496
|
+
} catch (o) {
|
|
4497
|
+
return;
|
|
4498
|
+
}
|
|
4499
|
+
if (e instanceof Error) return `[Error] ${e.name}: ${e.message}`.slice(0, 500);
|
|
4500
|
+
if (e instanceof RegExp) return String(e);
|
|
4501
|
+
if (t >= ms) return "[MaxDepth]";
|
|
4502
|
+
const n = r || /* @__PURE__ */ new WeakSet(), s = e;
|
|
4503
|
+
if (n.has(s)) return "[Circular]";
|
|
4504
|
+
n.add(s);
|
|
4505
|
+
try {
|
|
4506
|
+
if (Array.isArray(e)) {
|
|
4507
|
+
const c = e.slice(0, G).map((l) => {
|
|
4508
|
+
const h = et(l, t + 1, n);
|
|
4509
|
+
return h === void 0 ? null : h;
|
|
4510
|
+
});
|
|
4511
|
+
return e.length > G && c.push(`…[${e.length - G} more]`), c;
|
|
4512
|
+
}
|
|
4513
|
+
const o = {}, a = Object.keys(s).slice(0, G);
|
|
4514
|
+
for (const c of a) {
|
|
4515
|
+
let l;
|
|
4516
|
+
try {
|
|
4517
|
+
l = s[c];
|
|
4518
|
+
} catch (u) {
|
|
4519
|
+
continue;
|
|
4520
|
+
}
|
|
4521
|
+
const h = et(l, t + 1, n);
|
|
4522
|
+
h !== void 0 && (o[c] = h);
|
|
4523
|
+
}
|
|
4524
|
+
return o;
|
|
4525
|
+
} catch (o) {
|
|
4526
|
+
return "[Unserializable]";
|
|
4527
|
+
} finally {
|
|
4528
|
+
n.delete(s);
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
function $(e, t) {
|
|
4532
|
+
if (e.length !== t.length) return !1;
|
|
4533
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
4534
|
+
const i = e[r], n = t[r];
|
|
4535
|
+
if (i instanceof RegExp || n instanceof RegExp) {
|
|
4536
|
+
if (!(i instanceof RegExp) || !(n instanceof RegExp) || i.source !== n.source || i.flags !== n.flags) return !1;
|
|
4537
|
+
} else if (i !== n)
|
|
4538
|
+
return !1;
|
|
4539
|
+
}
|
|
4540
|
+
return !0;
|
|
4541
|
+
}
|
|
4542
|
+
const ys = "0.1.0";
|
|
4543
|
+
let f = null;
|
|
4544
|
+
function ws(e) {
|
|
4545
|
+
if (typeof window == "undefined") return null;
|
|
4546
|
+
try {
|
|
4547
|
+
const t = new Er(e);
|
|
4548
|
+
return t.init(), t;
|
|
4549
|
+
} catch (t) {
|
|
4550
|
+
return Q(`初始化失败:${t instanceof Error ? t.message : String(t)}`), null;
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
function Sr(e) {
|
|
4554
|
+
if (typeof window == "undefined") return null;
|
|
4555
|
+
if (f) return f;
|
|
4556
|
+
const t = e || window.BugTapConfig || Rt();
|
|
4557
|
+
if (!t)
|
|
4558
|
+
return Q("缺少配置:请在引入脚本前设置 window.BugTapConfig,或调用 BugTap.init(config)"), null;
|
|
4559
|
+
const r = yt(t);
|
|
4560
|
+
if (r.length > 0)
|
|
4561
|
+
return Q(`配置不完整:${r.join(";")}。未初始化。`), null;
|
|
4562
|
+
try {
|
|
4563
|
+
const i = new Er(t);
|
|
4564
|
+
return f = i, i.init(), i;
|
|
4565
|
+
} catch (i) {
|
|
4566
|
+
try {
|
|
4567
|
+
f == null || f.destroy();
|
|
4568
|
+
} catch (n) {
|
|
4569
|
+
}
|
|
4570
|
+
return Q(`初始化失败:${i instanceof Error ? i.message : String(i)}`), f = null, null;
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
function Rt() {
|
|
4574
|
+
try {
|
|
4575
|
+
if (typeof document == "undefined") return null;
|
|
4576
|
+
const e = document.currentScript, t = e && e.dataset && e.dataset.project ? e : document.querySelector("script[data-project]");
|
|
4577
|
+
if (!t || !t.dataset) return null;
|
|
4578
|
+
const r = t.dataset;
|
|
4579
|
+
return r.project ? {
|
|
4580
|
+
project: r.project,
|
|
4581
|
+
endpoint: r.endpoint,
|
|
4582
|
+
environment: r.environment,
|
|
4583
|
+
appVersion: r.appVersion,
|
|
4584
|
+
buildId: r.buildId,
|
|
4585
|
+
release: r.release,
|
|
4586
|
+
debug: r.debug === "true"
|
|
4587
|
+
} : null;
|
|
4588
|
+
} catch (e) {
|
|
4589
|
+
return null;
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
const vs = {
|
|
4593
|
+
version: ys,
|
|
4594
|
+
init: Sr,
|
|
4595
|
+
createClient: ws,
|
|
4596
|
+
open() {
|
|
4597
|
+
f == null || f.open();
|
|
4598
|
+
},
|
|
4599
|
+
close() {
|
|
4600
|
+
f == null || f.close();
|
|
4601
|
+
},
|
|
4602
|
+
openReporter() {
|
|
4603
|
+
f == null || f.openReporter();
|
|
4604
|
+
},
|
|
4605
|
+
closeReporter() {
|
|
4606
|
+
f == null || f.closeReporter();
|
|
4607
|
+
},
|
|
4608
|
+
setConfig(e) {
|
|
4609
|
+
f == null || f.setConfig(e);
|
|
4610
|
+
},
|
|
4611
|
+
setUser(e) {
|
|
4612
|
+
f == null || f.setUser(e);
|
|
4613
|
+
},
|
|
4614
|
+
setTag(e, t) {
|
|
4615
|
+
f == null || f.setTag(e, t);
|
|
4616
|
+
},
|
|
4617
|
+
setExtra(e, t) {
|
|
4618
|
+
f == null || f.setExtra(e, t);
|
|
4619
|
+
},
|
|
4620
|
+
setContext(e, t) {
|
|
4621
|
+
f == null || f.setContext(e, t);
|
|
4622
|
+
},
|
|
4623
|
+
addBreadcrumb(e) {
|
|
4624
|
+
f == null || f.addBreadcrumb(e);
|
|
4625
|
+
},
|
|
4626
|
+
captureException(e, t) {
|
|
4627
|
+
f == null || f.captureException(e, t);
|
|
4628
|
+
},
|
|
4629
|
+
captureMessage(e, t) {
|
|
4630
|
+
f == null || f.captureMessage(e, t);
|
|
4631
|
+
},
|
|
4632
|
+
disableRouteCapture() {
|
|
4633
|
+
f == null || f.disableRouteCapture();
|
|
4634
|
+
},
|
|
4635
|
+
installVueErrorHandler(e) {
|
|
4636
|
+
return f ? f.installVueErrorHandler(e) : () => {
|
|
4637
|
+
};
|
|
4638
|
+
},
|
|
4639
|
+
reactErrorHandlers() {
|
|
4640
|
+
if (f) return f.reactErrorHandlers();
|
|
4641
|
+
const e = () => {
|
|
4642
|
+
};
|
|
4643
|
+
return {
|
|
4644
|
+
onUncaughtError: e,
|
|
4645
|
+
onCaughtError: e,
|
|
4646
|
+
onRecoverableError: e
|
|
4647
|
+
};
|
|
4648
|
+
},
|
|
4649
|
+
flush() {
|
|
4650
|
+
return f ? f.flush() : Promise.resolve(0);
|
|
4651
|
+
},
|
|
4652
|
+
destroy() {
|
|
4653
|
+
f == null || f.destroy(), f = null;
|
|
4654
|
+
},
|
|
4655
|
+
getReport() {
|
|
4656
|
+
if (!f)
|
|
4657
|
+
throw new Error("[bug-tap] 尚未初始化");
|
|
4658
|
+
return f.getReport();
|
|
4659
|
+
}
|
|
4660
|
+
};
|
|
4661
|
+
function Q(e) {
|
|
4662
|
+
try {
|
|
4663
|
+
window.console && typeof window.console.warn == "function" && window.console.warn(`[bug-tap] ${e}`);
|
|
4664
|
+
} catch (t) {
|
|
4665
|
+
}
|
|
4666
|
+
}
|
|
4667
|
+
function tr() {
|
|
4668
|
+
if (window.__BUG_TAP__) return;
|
|
4669
|
+
const e = window.BugTapConfig || Rt();
|
|
4670
|
+
e && Sr(e) && (window.__BUG_TAP__ = !0);
|
|
4671
|
+
}
|
|
4672
|
+
typeof window != "undefined" && (window.BugTap = vs, window.BugTapConfig || Rt() ? tr() : document.readyState === "loading" && document.addEventListener("DOMContentLoaded", tr, { once: !0 }));
|
|
4673
|
+
export {
|
|
4674
|
+
Er as B,
|
|
4675
|
+
xr as a,
|
|
4676
|
+
fs as b,
|
|
4677
|
+
ws as c,
|
|
4678
|
+
Xi as d,
|
|
4679
|
+
Sr as i,
|
|
4680
|
+
j as m,
|
|
4681
|
+
Es as p,
|
|
4682
|
+
ps as r,
|
|
4683
|
+
ys as v
|
|
4684
|
+
};
|
|
4685
|
+
//# sourceMappingURL=index-BBRuTNvo.js.map
|