@skillbuilder/miniapp-simulator 0.2.2 → 0.2.4
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/docs/assets/audit-auto-stop-config-2026-10-21.jpg +0 -0
- package/docs/assets/audit-balanced-panel-2026-10-16.jpg +0 -0
- package/docs/assets/audit-lcp-input-2026-10-20.jpg +0 -0
- package/docs/assets/audit-paint-game3d-2026-10-16.jpg +0 -0
- package/docs/assets/audit-paint-webgl-2026-10-16.jpg +0 -0
- package/docs/assets/audit-paint-webgl-apm-excerpt-2026-10-16.json +397 -0
- package/docs/assets/audit-poetry-2026-10-16.jpg +0 -0
- package/docs/assets/audit-remaining-results-2026-10-16.json +2749 -0
- package/docs/assets/miniapp-audit-risk-review-2026-10-13.png +0 -0
- package/docs/assets/miniapp-audit-runtime-hung-2026-10-13.png +0 -0
- package/docs/audit-data-collection.codex.md +422 -0
- package/docs/audit-local-validation.codex.md +165 -0
- package/docs/audit-score-design.codex.md +221 -0
- package/docs/audit-score-design.md +885 -0
- package/docs/audit-score-tech-plan.md +448 -0
- package/docs/audit-tech-design.codex.md +468 -0
- package/docs/electron-review.md +223 -12
- package/docs/quality-evaluation-redoc.xml +163 -0
- package/lib/client-BDt3WDu_.mjs +1118 -0
- package/lib/{index-D5AYVv8s.mjs → index-7MeYFlk_.mjs} +210 -182
- package/lib/index.js +1254 -1115
- package/lib/remote-client.js +2 -2
- package/lib/types/host/shadow-host.d.ts +10 -0
- package/lib/types/injection/registry.d.ts +5 -0
- package/lib/types/remote/audit-controller.d.ts +56 -0
- package/lib/types/remote/audit-leave-monitor.d.ts +12 -0
- package/lib/types/remote/audit-telemetry.d.ts +23 -0
- package/lib/types/remote/audit-watchdog.d.ts +14 -0
- package/lib/types/remote/client.d.ts +25 -1
- package/lib/types/remote/load-timing.d.ts +5 -0
- package/lib/types/remote/protocol.d.ts +151 -1
- package/lib/types/remote/runtime.d.ts +2 -0
- package/lib/types/remote-client.d.ts +2 -2
- package/lib/types/sw/service-worker-host.d.ts +15 -0
- package/lib/types/tracker/default-tracker.d.ts +8 -0
- package/lib/types/types/options.d.ts +24 -0
- package/lib/workbench.js +1 -1
- package/package.json +1 -1
- package/lib/client-_vNHVHSm.mjs +0 -775
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const p = "0.2.4", y = /* @__PURE__ */ new Set();
|
|
2
|
+
function X(e, n) {
|
|
3
3
|
const t = () => {
|
|
4
|
-
let
|
|
5
|
-
for (let
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
4
|
+
let r = !document.hidden && e.isConnected;
|
|
5
|
+
for (let s = e; r && s; ) {
|
|
6
|
+
const c = getComputedStyle(s);
|
|
7
|
+
r = c.display !== "none" && c.visibility !== "hidden" && c.visibility !== "collapse";
|
|
8
|
+
const a = s.getRootNode();
|
|
9
|
+
s = s.parentElement ?? (a instanceof ShadowRoot ? a.host : null);
|
|
10
10
|
}
|
|
11
|
-
n(
|
|
12
|
-
},
|
|
13
|
-
for (let
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
11
|
+
n(r);
|
|
12
|
+
}, o = new MutationObserver(t);
|
|
13
|
+
for (let r = e; r; ) {
|
|
14
|
+
o.observe(r, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
|
|
15
|
+
const s = r.getRootNode();
|
|
16
|
+
r = r.parentElement ?? (s instanceof ShadowRoot ? s.host : null);
|
|
17
17
|
}
|
|
18
18
|
return document.addEventListener("visibilitychange", t), window.addEventListener("resize", t), window.addEventListener("pageshow", t), t(), () => {
|
|
19
|
-
|
|
19
|
+
o.disconnect(), document.removeEventListener("visibilitychange", t), window.removeEventListener("resize", t), window.removeEventListener("pageshow", t);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
let t = "",
|
|
24
|
-
const
|
|
22
|
+
function Y(e, n) {
|
|
23
|
+
let t = "", o = 0;
|
|
24
|
+
const r = () => {
|
|
25
25
|
if (document.hidden || !e.isConnected) return !1;
|
|
26
|
-
for (let
|
|
27
|
-
const u = getComputedStyle(
|
|
26
|
+
for (let i = e; i; ) {
|
|
27
|
+
const u = getComputedStyle(i);
|
|
28
28
|
if (u.display === "none" || u.visibility === "hidden" || u.visibility === "collapse")
|
|
29
29
|
return !1;
|
|
30
|
-
const d =
|
|
31
|
-
|
|
30
|
+
const d = i.getRootNode();
|
|
31
|
+
i = i.parentElement ?? (d instanceof ShadowRoot ? d.host : null);
|
|
32
32
|
}
|
|
33
33
|
return !0;
|
|
34
|
-
},
|
|
34
|
+
}, s = () => {
|
|
35
35
|
if (t)
|
|
36
36
|
try {
|
|
37
|
-
const
|
|
37
|
+
const i = new URL(n(), location.href).origin;
|
|
38
38
|
e.contentWindow?.postMessage(
|
|
39
39
|
{
|
|
40
40
|
type: "mini-app:worker-state",
|
|
41
41
|
sessionId: t,
|
|
42
|
-
sequence: ++
|
|
43
|
-
state:
|
|
42
|
+
sequence: ++o,
|
|
43
|
+
state: r() ? "visible" : "hidden"
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
i
|
|
46
46
|
);
|
|
47
47
|
} catch {
|
|
48
48
|
}
|
|
49
|
-
},
|
|
50
|
-
if (!(!
|
|
49
|
+
}, c = (i) => {
|
|
50
|
+
if (!(!i.isTrusted || i.source !== e.contentWindow || i.data?.type !== "mini-app:worker-ready" || typeof i.data.sessionId != "string")) {
|
|
51
51
|
try {
|
|
52
|
-
if (
|
|
52
|
+
if (i.origin !== new URL(n(), location.href).origin || e.contentWindow?.__MINITOOL_WORKER_CONTEXT__?.sessionId !== i.data.sessionId)
|
|
53
53
|
return;
|
|
54
54
|
} catch {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
t =
|
|
57
|
+
t = i.data.sessionId, s();
|
|
58
58
|
}
|
|
59
|
-
},
|
|
60
|
-
for (let
|
|
61
|
-
|
|
62
|
-
const u =
|
|
63
|
-
|
|
59
|
+
}, a = new MutationObserver(s);
|
|
60
|
+
for (let i = e; i; ) {
|
|
61
|
+
a.observe(i, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
|
|
62
|
+
const u = i.getRootNode();
|
|
63
|
+
i = i.parentElement ?? (u instanceof ShadowRoot ? u.host : null);
|
|
64
64
|
}
|
|
65
|
-
return window.addEventListener("message",
|
|
66
|
-
|
|
65
|
+
return window.addEventListener("message", c), window.addEventListener("resize", s), window.addEventListener("pageshow", s), document.addEventListener("visibilitychange", s), y.add(s), () => {
|
|
66
|
+
y.delete(s), a.disconnect(), window.removeEventListener("message", c), window.removeEventListener("resize", s), window.removeEventListener("pageshow", s), document.removeEventListener("visibilitychange", s);
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
var l = /* @__PURE__ */ ((e) => (e[e.INVALID_PARAM = 10001] = "INVALID_PARAM", e[e.API_UNAVAILABLE = 10002] = "API_UNAVAILABLE", e[e.URL_SCHEME_NOT_ALLOWED = 10003] = "URL_SCHEME_NOT_ALLOWED", e[e.REQUEST_TIMEOUT = 10101] = "REQUEST_TIMEOUT", e[e.REQUEST_ABORTED = 10102] = "REQUEST_ABORTED", e[e.REQUEST_FAILED = 15201] = "REQUEST_FAILED", e[e.STORAGE_IO_ERROR = 50101] = "STORAGE_IO_ERROR", e[e.STORAGE_QUOTA_EXCEEDED = 50201] = "STORAGE_QUOTA_EXCEEDED", e[e.FILE_NOT_FOUND = 50202] = "FILE_NOT_FOUND", e[e.PATH_INVALID = 50203] = "PATH_INVALID", e[e.FILE_ALREADY_EXISTS = 50204] = "FILE_ALREADY_EXISTS", e[e.NOT_A_FILE = 50205] = "NOT_A_FILE", e[e.NOT_A_DIRECTORY = 50206] = "NOT_A_DIRECTORY", e))(l || {});
|
|
70
70
|
function f(e, n) {
|
|
71
71
|
return Object.assign(new Error(n), { code: e });
|
|
72
72
|
}
|
|
73
|
-
class
|
|
73
|
+
class E {
|
|
74
74
|
constructor() {
|
|
75
75
|
this.buffer = "";
|
|
76
76
|
}
|
|
@@ -84,46 +84,46 @@ class k {
|
|
|
84
84
|
}
|
|
85
85
|
drain(n) {
|
|
86
86
|
const t = [];
|
|
87
|
-
let
|
|
88
|
-
for (;
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
87
|
+
let o = 0, r = 0, s = 0;
|
|
88
|
+
for (; s < this.buffer.length; ) {
|
|
89
|
+
const c = this.buffer[s];
|
|
90
|
+
if (c !== "\r" && c !== `
|
|
91
91
|
`) {
|
|
92
|
-
|
|
92
|
+
s += 1;
|
|
93
93
|
continue;
|
|
94
94
|
}
|
|
95
|
-
let
|
|
96
|
-
if (
|
|
97
|
-
if (
|
|
98
|
-
this.buffer[
|
|
99
|
-
` && (
|
|
95
|
+
let a = s + 1;
|
|
96
|
+
if (c === "\r") {
|
|
97
|
+
if (a === this.buffer.length && !n) break;
|
|
98
|
+
this.buffer[a] === `
|
|
99
|
+
` && (a += 1);
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
s === r && (t.push(this.buffer.slice(o, a)), o = a), r = a, s = a;
|
|
102
102
|
}
|
|
103
|
-
return
|
|
103
|
+
return o > 0 && (this.buffer = this.buffer.slice(o)), t;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function K() {
|
|
107
107
|
let e = "";
|
|
108
108
|
const n = (t) => {
|
|
109
|
-
const
|
|
110
|
-
let
|
|
111
|
-
for (;
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
109
|
+
const o = [];
|
|
110
|
+
let r = 0, s = 0, c = 0;
|
|
111
|
+
for (; c < e.length; ) {
|
|
112
|
+
const a = e[c];
|
|
113
|
+
if (a !== "\r" && a !== `
|
|
114
114
|
`) {
|
|
115
|
-
|
|
115
|
+
c += 1;
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
118
|
-
let
|
|
119
|
-
if (
|
|
120
|
-
if (
|
|
121
|
-
e[
|
|
122
|
-
` && (
|
|
118
|
+
let i = c + 1;
|
|
119
|
+
if (a === "\r") {
|
|
120
|
+
if (i === e.length && !t) break;
|
|
121
|
+
e[i] === `
|
|
122
|
+
` && (i += 1);
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
c === s && (o.push(e.slice(r, i)), r = i), s = i, c = i;
|
|
125
125
|
}
|
|
126
|
-
return
|
|
126
|
+
return r > 0 && (e = e.slice(r)), o;
|
|
127
127
|
};
|
|
128
128
|
return {
|
|
129
129
|
push(t) {
|
|
@@ -135,63 +135,63 @@ function X() {
|
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function T(e) {
|
|
139
139
|
return e?.toLowerCase().includes("text/event-stream") ?? !1;
|
|
140
140
|
}
|
|
141
|
-
const
|
|
142
|
-
async function
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
const
|
|
141
|
+
const I = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
async function Z(e, n, t) {
|
|
143
|
+
D(n.data);
|
|
144
|
+
const o = I.get(e);
|
|
145
|
+
if (o) return o(n, t);
|
|
146
|
+
const r = await e(R(n, t.signal));
|
|
147
147
|
if (t.signal.aborted)
|
|
148
148
|
throw f(l.REQUEST_ABORTED, "request aborted");
|
|
149
|
-
x(
|
|
150
|
-
const
|
|
151
|
-
return t.onHeaders({ taskId: n.taskId, statusCode:
|
|
149
|
+
x(r);
|
|
150
|
+
const s = P(r.header);
|
|
151
|
+
return t.onHeaders({ taskId: n.taskId, statusCode: r.statusCode, header: s }), n.enableChunked && T(s["content-type"]) && (typeof r.data == "string" || N(r.data)) ? (await U(r.data, n.taskId, t), { taskId: n.taskId, statusCode: r.statusCode, data: "", header: s }) : {
|
|
152
152
|
taskId: n.taskId,
|
|
153
|
-
statusCode:
|
|
154
|
-
data: await
|
|
155
|
-
header:
|
|
153
|
+
statusCode: r.statusCode,
|
|
154
|
+
data: await A(r.data, n),
|
|
155
|
+
header: s
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
const t = e.data,
|
|
160
|
-
return
|
|
161
|
-
url:
|
|
158
|
+
function R(e, n) {
|
|
159
|
+
const t = e.data, o = { ...e.header }, r = e.method.toUpperCase();
|
|
160
|
+
return r === "GET" || r === "HEAD" ? {
|
|
161
|
+
url: S(e.url, v(t)),
|
|
162
162
|
method: e.method,
|
|
163
|
-
header:
|
|
163
|
+
header: o,
|
|
164
164
|
responseType: e.responseType,
|
|
165
165
|
enableChunked: e.enableChunked,
|
|
166
166
|
signal: n
|
|
167
167
|
} : {
|
|
168
168
|
url: e.url,
|
|
169
169
|
method: e.method,
|
|
170
|
-
header:
|
|
171
|
-
data: L(t,
|
|
170
|
+
header: o,
|
|
171
|
+
data: L(t, o),
|
|
172
172
|
responseType: e.responseType,
|
|
173
173
|
enableChunked: e.enableChunked,
|
|
174
174
|
signal: n
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function S(e, n) {
|
|
178
178
|
if (!n) return e;
|
|
179
|
-
const t = e.indexOf("#"),
|
|
180
|
-
return `${
|
|
179
|
+
const t = e.indexOf("#"), o = t >= 0 ? e.slice(t) : "", r = t >= 0 ? e.slice(0, t) : e;
|
|
180
|
+
return `${r}${r.includes("?") ? "&" : "?"}${n}${o}`;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function v(e) {
|
|
183
183
|
return e == null ? "" : typeof e == "string" ? e : typeof e != "object" || Array.isArray(e) ? String(e) : Object.entries(e).map(([n, t]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`).join("&");
|
|
184
184
|
}
|
|
185
185
|
function L(e, n) {
|
|
186
186
|
if (e == null || typeof e == "string") return e;
|
|
187
|
-
let t =
|
|
188
|
-
return t || (t = "application/json", n["content-type"] = t), t.toLowerCase().includes("application/json") ? JSON.stringify(e) : t.toLowerCase().includes("application/x-www-form-urlencoded") ?
|
|
187
|
+
let t = O(n, "content-type");
|
|
188
|
+
return t || (t = "application/json", n["content-type"] = t), t.toLowerCase().includes("application/json") ? JSON.stringify(e) : t.toLowerCase().includes("application/x-www-form-urlencoded") ? v(e) : String(e);
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
const t = Object.keys(e).find((
|
|
190
|
+
function O(e, n) {
|
|
191
|
+
const t = Object.keys(e).find((o) => o.toLowerCase() === n);
|
|
192
192
|
return t ? String(e[t]) : void 0;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function D(e) {
|
|
195
195
|
if (!(!(e instanceof ArrayBuffer) && !ArrayBuffer.isView(e)))
|
|
196
196
|
throw f(
|
|
197
197
|
l.INVALID_PARAM,
|
|
@@ -205,43 +205,43 @@ function x(e) {
|
|
|
205
205
|
"host request adapter returned an invalid response"
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function N(e) {
|
|
209
209
|
return !!(e && typeof e == "object" && "getReader" in e);
|
|
210
210
|
}
|
|
211
|
-
async function
|
|
212
|
-
const
|
|
213
|
-
for (const u of
|
|
211
|
+
async function U(e, n, t) {
|
|
212
|
+
const o = new E(), r = (i) => {
|
|
213
|
+
for (const u of o.push(i)) t.onChunk({ taskId: n, chunk: u });
|
|
214
214
|
};
|
|
215
215
|
if (typeof e == "string") {
|
|
216
|
-
|
|
217
|
-
for (const
|
|
216
|
+
r(e);
|
|
217
|
+
for (const i of o.finish()) t.onChunk({ taskId: n, chunk: i });
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
|
-
const
|
|
220
|
+
const s = e.getReader(), c = new TextDecoder(), a = () => void s.cancel().catch(() => {
|
|
221
221
|
});
|
|
222
|
-
t.signal.addEventListener("abort",
|
|
222
|
+
t.signal.addEventListener("abort", a, { once: !0 });
|
|
223
223
|
try {
|
|
224
224
|
for (; ; ) {
|
|
225
225
|
if (t.signal.aborted) return;
|
|
226
|
-
const u = await
|
|
226
|
+
const u = await s.read();
|
|
227
227
|
if (u.done) break;
|
|
228
|
-
const d = typeof u.value == "string" ? u.value :
|
|
229
|
-
d &&
|
|
228
|
+
const d = typeof u.value == "string" ? u.value : c.decode(u.value, { stream: !0 });
|
|
229
|
+
d && r(d);
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
for (const u of
|
|
231
|
+
const i = c.decode();
|
|
232
|
+
i && r(i);
|
|
233
|
+
for (const u of o.finish()) t.onChunk({ taskId: n, chunk: u });
|
|
234
234
|
} finally {
|
|
235
|
-
t.signal.removeEventListener("abort",
|
|
235
|
+
t.signal.removeEventListener("abort", a), s.releaseLock();
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function P(e) {
|
|
239
239
|
const n = {};
|
|
240
|
-
for (const [t,
|
|
241
|
-
t.toLowerCase() !== "set-cookie" && (n[t.toLowerCase()] = String(
|
|
240
|
+
for (const [t, o] of Object.entries(e ?? {}))
|
|
241
|
+
t.toLowerCase() !== "set-cookie" && (n[t.toLowerCase()] = String(o));
|
|
242
242
|
return n;
|
|
243
243
|
}
|
|
244
|
-
async function
|
|
244
|
+
async function A(e, n) {
|
|
245
245
|
if (e instanceof ArrayBuffer || ArrayBuffer.isView(e))
|
|
246
246
|
throw f(
|
|
247
247
|
l.REQUEST_FAILED,
|
|
@@ -255,7 +255,7 @@ async function B(e, n) {
|
|
|
255
255
|
}
|
|
256
256
|
return e;
|
|
257
257
|
}
|
|
258
|
-
const
|
|
258
|
+
const B = "miniapp_simulator_event", C = "skillbuilder-miniapp", F = {
|
|
259
259
|
cn: {
|
|
260
260
|
production: "https://apm-fe.xiaohongshu.com/api/data",
|
|
261
261
|
development: "https://apm-fe-test.xiaohongshu.com/api/data"
|
|
@@ -264,11 +264,19 @@ const P = "miniapp_simulator_event", A = "skillbuilder-miniapp", C = {
|
|
|
264
264
|
production: "https://apm-fe.rnote.com/api/data",
|
|
265
265
|
development: "https://apm-fe.rnote.com/api/data"
|
|
266
266
|
}
|
|
267
|
-
},
|
|
268
|
-
function
|
|
267
|
+
}, j = 10, H = 1e4;
|
|
268
|
+
function g() {
|
|
269
269
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`;
|
|
270
270
|
}
|
|
271
|
-
function q(e
|
|
271
|
+
function q(e) {
|
|
272
|
+
return Object.fromEntries(
|
|
273
|
+
Object.entries(e).map(([n, t]) => [
|
|
274
|
+
n,
|
|
275
|
+
typeof t == "boolean" ? Number(t) : t
|
|
276
|
+
])
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
function V(e, n) {
|
|
272
280
|
const t = typeof window < "u";
|
|
273
281
|
return {
|
|
274
282
|
clientTime: Date.now(),
|
|
@@ -288,125 +296,145 @@ function q(e, n) {
|
|
|
288
296
|
context_matchedPath: t ? window.location.pathname : "",
|
|
289
297
|
context_route: t ? window.location.href : "",
|
|
290
298
|
context_userAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
291
|
-
context_artifactName:
|
|
292
|
-
context_artifactVersion:
|
|
299
|
+
context_artifactName: C,
|
|
300
|
+
context_artifactVersion: p,
|
|
293
301
|
context_deviceLevel: "unknown",
|
|
294
302
|
context_feSdkVersion: "1.3.13",
|
|
295
303
|
context_userId: n.userId,
|
|
296
|
-
measurement_name:
|
|
304
|
+
measurement_name: B,
|
|
297
305
|
measurement_data: {
|
|
298
306
|
event_name: e.name,
|
|
299
307
|
timestamp: e.timestamp,
|
|
300
|
-
...e.payload
|
|
308
|
+
...q(e.payload)
|
|
301
309
|
}
|
|
302
310
|
};
|
|
303
311
|
}
|
|
304
|
-
|
|
305
|
-
|
|
312
|
+
const _ = [250, 1e3];
|
|
313
|
+
async function Q(e, n) {
|
|
314
|
+
const t = n.length;
|
|
315
|
+
if (typeof fetch != "function" || t === 0)
|
|
316
|
+
return { ok: !1, attempts: 0, eventCount: t };
|
|
317
|
+
const o = {
|
|
318
|
+
method: "POST",
|
|
319
|
+
headers: {
|
|
320
|
+
"content-type": "application/json",
|
|
321
|
+
"Biz-Type": "apm_fe",
|
|
322
|
+
Batch: "true"
|
|
323
|
+
},
|
|
324
|
+
body: JSON.stringify(n),
|
|
325
|
+
keepalive: !0
|
|
326
|
+
};
|
|
327
|
+
let r;
|
|
328
|
+
for (let s = 0; s <= _.length; s += 1) {
|
|
306
329
|
try {
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
Batch: "true"
|
|
313
|
-
},
|
|
314
|
-
body: JSON.stringify(n)
|
|
315
|
-
};
|
|
316
|
-
typeof navigator < "u" && "sendBeacon" in navigator && (t.keepalive = !0), Promise.resolve(fetch(e, t)).catch(() => {
|
|
317
|
-
});
|
|
330
|
+
const a = await fetch(e, o);
|
|
331
|
+
if (r = a.status, a.ok)
|
|
332
|
+
return { ok: !0, status: a.status, attempts: s + 1, eventCount: t };
|
|
333
|
+
if (a.status >= 400 && a.status < 500)
|
|
334
|
+
return { ok: !1, status: a.status, attempts: s + 1, eventCount: t };
|
|
318
335
|
} catch {
|
|
319
336
|
}
|
|
337
|
+
const c = _[s];
|
|
338
|
+
if (c === void 0)
|
|
339
|
+
return { ok: !1, status: r, attempts: s + 1, eventCount: t };
|
|
340
|
+
await new Promise((a) => setTimeout(a, c));
|
|
341
|
+
}
|
|
342
|
+
return { ok: !1, status: r, attempts: _.length + 1, eventCount: t };
|
|
320
343
|
}
|
|
321
|
-
function
|
|
344
|
+
function W(e) {
|
|
322
345
|
if (typeof console > "u") return;
|
|
323
346
|
const n = e.measurement_name ?? "apm";
|
|
324
347
|
console.groupCollapsed(`[apm] ${n}`), console.log(e), console.groupEnd();
|
|
325
348
|
}
|
|
326
|
-
function
|
|
327
|
-
const n = e.debug === !0, t =
|
|
328
|
-
let
|
|
349
|
+
function z(e) {
|
|
350
|
+
const n = e.debug === !0, t = g(), o = g();
|
|
351
|
+
let r = 0, s = [], c = null, a = 0, i = !1;
|
|
329
352
|
const u = () => {
|
|
330
|
-
if (
|
|
331
|
-
const h =
|
|
332
|
-
|
|
353
|
+
if (i = !1, c !== null && (clearTimeout(c), c = null), s.length === 0) return;
|
|
354
|
+
const h = s;
|
|
355
|
+
s = [], Q(e.endpoint, h).then((m) => {
|
|
356
|
+
try {
|
|
357
|
+
e.onDelivery?.(m);
|
|
358
|
+
} catch {
|
|
359
|
+
}
|
|
360
|
+
});
|
|
333
361
|
}, d = () => {
|
|
334
|
-
if (
|
|
335
|
-
|
|
362
|
+
if (c !== null && (clearTimeout(c), c = null), a > 0) {
|
|
363
|
+
i = !0;
|
|
336
364
|
return;
|
|
337
365
|
}
|
|
338
366
|
u();
|
|
339
|
-
},
|
|
340
|
-
|
|
367
|
+
}, w = () => {
|
|
368
|
+
c === null && (c = setTimeout(d, H));
|
|
341
369
|
};
|
|
342
370
|
return {
|
|
343
371
|
sendCustomPoint(h) {
|
|
344
|
-
const
|
|
345
|
-
|
|
372
|
+
const m = r++;
|
|
373
|
+
a += 1, Promise.resolve().then(() => e.resolveUserId()).catch(() => "").then((k) => {
|
|
346
374
|
try {
|
|
347
|
-
const
|
|
375
|
+
const b = V(h, {
|
|
348
376
|
sessionId: t,
|
|
349
|
-
pageSessionId:
|
|
350
|
-
seqId:
|
|
351
|
-
userId:
|
|
377
|
+
pageSessionId: o,
|
|
378
|
+
seqId: m,
|
|
379
|
+
userId: k,
|
|
352
380
|
region: e.region
|
|
353
381
|
});
|
|
354
382
|
if (n) {
|
|
355
|
-
|
|
383
|
+
W(b);
|
|
356
384
|
return;
|
|
357
385
|
}
|
|
358
|
-
|
|
386
|
+
s.push(b), s.length >= j ? setTimeout(() => d()) : w();
|
|
359
387
|
} catch {
|
|
360
388
|
}
|
|
361
389
|
}).finally(() => {
|
|
362
|
-
|
|
390
|
+
a -= 1, a === 0 && i && u();
|
|
363
391
|
});
|
|
364
392
|
},
|
|
365
393
|
flush: d
|
|
366
394
|
};
|
|
367
395
|
}
|
|
368
|
-
function
|
|
396
|
+
function M(e) {
|
|
369
397
|
const n = e.region ?? "cn";
|
|
370
398
|
if (e.endpoint) return e.endpoint;
|
|
371
|
-
const t =
|
|
372
|
-
return
|
|
399
|
+
const t = $();
|
|
400
|
+
return F[n][t];
|
|
373
401
|
}
|
|
374
|
-
function
|
|
402
|
+
function $() {
|
|
375
403
|
if (typeof window > "u") return "production";
|
|
376
404
|
const e = window.location.hostname.toLowerCase();
|
|
377
405
|
return e === "localhost" || e === "127.0.0.1" || e === "0.0.0.0" || e.includes(".sit.") || // hostname.includes(".beta.") ||
|
|
378
406
|
e.startsWith("local.") ? "development" : "production";
|
|
379
407
|
}
|
|
380
|
-
function
|
|
408
|
+
function G(e, n) {
|
|
381
409
|
if (e === !1) return null;
|
|
382
410
|
try {
|
|
383
|
-
const t = e.region ?? "cn",
|
|
384
|
-
endpoint:
|
|
411
|
+
const t = e.region ?? "cn", o = z({
|
|
412
|
+
endpoint: M(e),
|
|
385
413
|
region: t,
|
|
386
414
|
resolveUserId: n ?? (() => Promise.resolve("")),
|
|
387
415
|
debug: e.debug
|
|
388
416
|
});
|
|
389
|
-
return { send: (
|
|
417
|
+
return { send: (r) => o.sendCustomPoint(r), flush: () => o.flush() };
|
|
390
418
|
} catch {
|
|
391
419
|
return null;
|
|
392
420
|
}
|
|
393
421
|
}
|
|
394
|
-
class
|
|
395
|
-
constructor(n, t,
|
|
396
|
-
this.resolveContext =
|
|
422
|
+
class J {
|
|
423
|
+
constructor(n, t, o, r) {
|
|
424
|
+
this.resolveContext = r, this.unsubscribers = [], this.common = {
|
|
397
425
|
business_line: "",
|
|
398
426
|
sdk_version: "",
|
|
399
427
|
content_mode: "",
|
|
400
428
|
renderer: ""
|
|
401
429
|
};
|
|
402
|
-
const
|
|
403
|
-
if (!
|
|
430
|
+
const s = G(n, o);
|
|
431
|
+
if (!s) {
|
|
404
432
|
this.send = () => {
|
|
405
433
|
}, this.flush = () => {
|
|
406
434
|
};
|
|
407
435
|
return;
|
|
408
436
|
}
|
|
409
|
-
this.send =
|
|
437
|
+
this.send = s.send, this.flush = s.flush, this.common = {
|
|
410
438
|
...this.common,
|
|
411
439
|
...n === !1 ? {} : n.context,
|
|
412
440
|
business_line: n === !1 ? "" : n.business_line ?? "unknown"
|
|
@@ -535,14 +563,14 @@ class K {
|
|
|
535
563
|
/** 发送打点:自动合入公共字段 */
|
|
536
564
|
track(n, t) {
|
|
537
565
|
try {
|
|
538
|
-
let
|
|
566
|
+
let o = {};
|
|
539
567
|
try {
|
|
540
|
-
|
|
568
|
+
o = this.resolveContext?.() ?? {};
|
|
541
569
|
} catch {
|
|
542
570
|
}
|
|
543
571
|
this.send({
|
|
544
572
|
name: n,
|
|
545
|
-
payload: { ...this.common, ...t, ...
|
|
573
|
+
payload: { ...this.common, ...t, ...o },
|
|
546
574
|
timestamp: Date.now()
|
|
547
575
|
});
|
|
548
576
|
} catch {
|
|
@@ -555,20 +583,20 @@ class K {
|
|
|
555
583
|
this.unsubscribers.length = 0;
|
|
556
584
|
}
|
|
557
585
|
}
|
|
558
|
-
function
|
|
586
|
+
function ee(e) {
|
|
559
587
|
return !(e === void 0 || e === !1);
|
|
560
588
|
}
|
|
561
589
|
export {
|
|
562
590
|
l as M,
|
|
563
|
-
|
|
591
|
+
Y as a,
|
|
564
592
|
f as b,
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
593
|
+
z as c,
|
|
594
|
+
K as d,
|
|
595
|
+
Z as e,
|
|
596
|
+
ee as f,
|
|
597
|
+
J as g,
|
|
598
|
+
T as i,
|
|
599
|
+
X as o,
|
|
600
|
+
M as r,
|
|
601
|
+
p as v
|
|
574
602
|
};
|