@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.
Files changed (39) hide show
  1. package/docs/assets/audit-auto-stop-config-2026-10-21.jpg +0 -0
  2. package/docs/assets/audit-balanced-panel-2026-10-16.jpg +0 -0
  3. package/docs/assets/audit-lcp-input-2026-10-20.jpg +0 -0
  4. package/docs/assets/audit-paint-game3d-2026-10-16.jpg +0 -0
  5. package/docs/assets/audit-paint-webgl-2026-10-16.jpg +0 -0
  6. package/docs/assets/audit-paint-webgl-apm-excerpt-2026-10-16.json +397 -0
  7. package/docs/assets/audit-poetry-2026-10-16.jpg +0 -0
  8. package/docs/assets/audit-remaining-results-2026-10-16.json +2749 -0
  9. package/docs/assets/miniapp-audit-risk-review-2026-10-13.png +0 -0
  10. package/docs/assets/miniapp-audit-runtime-hung-2026-10-13.png +0 -0
  11. package/docs/audit-data-collection.codex.md +422 -0
  12. package/docs/audit-local-validation.codex.md +165 -0
  13. package/docs/audit-score-design.codex.md +221 -0
  14. package/docs/audit-score-design.md +885 -0
  15. package/docs/audit-score-tech-plan.md +448 -0
  16. package/docs/audit-tech-design.codex.md +468 -0
  17. package/docs/electron-review.md +223 -12
  18. package/docs/quality-evaluation-redoc.xml +163 -0
  19. package/lib/client-BDt3WDu_.mjs +1118 -0
  20. package/lib/{index-D5AYVv8s.mjs → index-7MeYFlk_.mjs} +210 -182
  21. package/lib/index.js +1254 -1115
  22. package/lib/remote-client.js +2 -2
  23. package/lib/types/host/shadow-host.d.ts +10 -0
  24. package/lib/types/injection/registry.d.ts +5 -0
  25. package/lib/types/remote/audit-controller.d.ts +56 -0
  26. package/lib/types/remote/audit-leave-monitor.d.ts +12 -0
  27. package/lib/types/remote/audit-telemetry.d.ts +23 -0
  28. package/lib/types/remote/audit-watchdog.d.ts +14 -0
  29. package/lib/types/remote/client.d.ts +25 -1
  30. package/lib/types/remote/load-timing.d.ts +5 -0
  31. package/lib/types/remote/protocol.d.ts +151 -1
  32. package/lib/types/remote/runtime.d.ts +2 -0
  33. package/lib/types/remote-client.d.ts +2 -2
  34. package/lib/types/sw/service-worker-host.d.ts +15 -0
  35. package/lib/types/tracker/default-tracker.d.ts +8 -0
  36. package/lib/types/types/options.d.ts +24 -0
  37. package/lib/workbench.js +1 -1
  38. package/package.json +1 -1
  39. package/lib/client-_vNHVHSm.mjs +0 -775
@@ -1,76 +1,76 @@
1
- const E = "0.2.2", _ = /* @__PURE__ */ new Set();
2
- function M(e, n) {
1
+ const p = "0.2.4", y = /* @__PURE__ */ new Set();
2
+ function X(e, n) {
3
3
  const t = () => {
4
- let s = !document.hidden && e.isConnected;
5
- for (let r = e; s && r; ) {
6
- const a = getComputedStyle(r);
7
- s = a.display !== "none" && a.visibility !== "hidden" && a.visibility !== "collapse";
8
- const c = r.getRootNode();
9
- r = r.parentElement ?? (c instanceof ShadowRoot ? c.host : null);
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(s);
12
- }, i = new MutationObserver(t);
13
- for (let s = e; s; ) {
14
- i.observe(s, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
15
- const r = s.getRootNode();
16
- s = s.parentElement ?? (r instanceof ShadowRoot ? r.host : null);
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
- i.disconnect(), document.removeEventListener("visibilitychange", t), window.removeEventListener("resize", t), window.removeEventListener("pageshow", t);
19
+ o.disconnect(), document.removeEventListener("visibilitychange", t), window.removeEventListener("resize", t), window.removeEventListener("pageshow", t);
20
20
  };
21
21
  }
22
- function G(e, n) {
23
- let t = "", i = 0;
24
- const s = () => {
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 o = e; o; ) {
27
- const u = getComputedStyle(o);
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 = o.getRootNode();
31
- o = o.parentElement ?? (d instanceof ShadowRoot ? d.host : null);
30
+ const d = i.getRootNode();
31
+ i = i.parentElement ?? (d instanceof ShadowRoot ? d.host : null);
32
32
  }
33
33
  return !0;
34
- }, r = () => {
34
+ }, s = () => {
35
35
  if (t)
36
36
  try {
37
- const o = new URL(n(), location.href).origin;
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: ++i,
43
- state: s() ? "visible" : "hidden"
42
+ sequence: ++o,
43
+ state: r() ? "visible" : "hidden"
44
44
  },
45
- o
45
+ i
46
46
  );
47
47
  } catch {
48
48
  }
49
- }, a = (o) => {
50
- if (!(!o.isTrusted || o.source !== e.contentWindow || o.data?.type !== "mini-app:worker-ready" || typeof o.data.sessionId != "string")) {
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 (o.origin !== new URL(n(), location.href).origin || e.contentWindow?.__MINITOOL_WORKER_CONTEXT__?.sessionId !== o.data.sessionId)
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 = o.data.sessionId, r();
57
+ t = i.data.sessionId, s();
58
58
  }
59
- }, c = new MutationObserver(r);
60
- for (let o = e; o; ) {
61
- c.observe(o, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
62
- const u = o.getRootNode();
63
- o = o.parentElement ?? (u instanceof ShadowRoot ? u.host : null);
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", a), window.addEventListener("resize", r), window.addEventListener("pageshow", r), document.addEventListener("visibilitychange", r), _.add(r), () => {
66
- _.delete(r), c.disconnect(), window.removeEventListener("message", a), window.removeEventListener("resize", r), window.removeEventListener("pageshow", r), document.removeEventListener("visibilitychange", r);
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 k {
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 i = 0, s = 0, r = 0;
88
- for (; r < this.buffer.length; ) {
89
- const a = this.buffer[r];
90
- if (a !== "\r" && a !== `
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
- r += 1;
92
+ s += 1;
93
93
  continue;
94
94
  }
95
- let c = r + 1;
96
- if (a === "\r") {
97
- if (c === this.buffer.length && !n) break;
98
- this.buffer[c] === `
99
- ` && (c += 1);
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
- r === s && (t.push(this.buffer.slice(i, c)), i = c), s = c, r = c;
101
+ s === r && (t.push(this.buffer.slice(o, a)), o = a), r = a, s = a;
102
102
  }
103
- return i > 0 && (this.buffer = this.buffer.slice(i)), t;
103
+ return o > 0 && (this.buffer = this.buffer.slice(o)), t;
104
104
  }
105
105
  }
106
- function X() {
106
+ function K() {
107
107
  let e = "";
108
108
  const n = (t) => {
109
- const i = [];
110
- let s = 0, r = 0, a = 0;
111
- for (; a < e.length; ) {
112
- const c = e[a];
113
- if (c !== "\r" && c !== `
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
- a += 1;
115
+ c += 1;
116
116
  continue;
117
117
  }
118
- let o = a + 1;
119
- if (c === "\r") {
120
- if (o === e.length && !t) break;
121
- e[o] === `
122
- ` && (o += 1);
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
- a === r && (i.push(e.slice(s, o)), s = o), r = o, a = o;
124
+ c === s && (o.push(e.slice(r, i)), r = i), s = i, c = i;
125
125
  }
126
- return s > 0 && (e = e.slice(s)), i;
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 p(e) {
138
+ function T(e) {
139
139
  return e?.toLowerCase().includes("text/event-stream") ?? !1;
140
140
  }
141
- const T = /* @__PURE__ */ new WeakMap();
142
- async function Y(e, n, t) {
143
- O(n.data);
144
- const i = T.get(e);
145
- if (i) return i(n, t);
146
- const s = await e(I(n, t.signal));
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(s);
150
- const r = U(s.header);
151
- return t.onHeaders({ taskId: n.taskId, statusCode: s.statusCode, header: r }), n.enableChunked && p(r["content-type"]) && (typeof s.data == "string" || D(s.data)) ? (await N(s.data, n.taskId, t), { taskId: n.taskId, statusCode: s.statusCode, data: "", header: r }) : {
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: s.statusCode,
154
- data: await B(s.data, n),
155
- header: r
153
+ statusCode: r.statusCode,
154
+ data: await A(r.data, n),
155
+ header: s
156
156
  };
157
157
  }
158
- function I(e, n) {
159
- const t = e.data, i = { ...e.header }, s = e.method.toUpperCase();
160
- return s === "GET" || s === "HEAD" ? {
161
- url: R(e.url, g(t)),
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: i,
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: i,
171
- data: L(t, i),
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 R(e, n) {
177
+ function S(e, n) {
178
178
  if (!n) return e;
179
- const t = e.indexOf("#"), i = t >= 0 ? e.slice(t) : "", s = t >= 0 ? e.slice(0, t) : e;
180
- return `${s}${s.includes("?") ? "&" : "?"}${n}${i}`;
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 g(e) {
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 = S(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") ? g(e) : String(e);
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 S(e, n) {
191
- const t = Object.keys(e).find((i) => i.toLowerCase() === n);
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 O(e) {
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 D(e) {
208
+ function N(e) {
209
209
  return !!(e && typeof e == "object" && "getReader" in e);
210
210
  }
211
- async function N(e, n, t) {
212
- const i = new k(), s = (o) => {
213
- for (const u of i.push(o)) t.onChunk({ taskId: n, chunk: u });
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
- s(e);
217
- for (const o of i.finish()) t.onChunk({ taskId: n, chunk: o });
216
+ r(e);
217
+ for (const i of o.finish()) t.onChunk({ taskId: n, chunk: i });
218
218
  return;
219
219
  }
220
- const r = e.getReader(), a = new TextDecoder(), c = () => void r.cancel().catch(() => {
220
+ const s = e.getReader(), c = new TextDecoder(), a = () => void s.cancel().catch(() => {
221
221
  });
222
- t.signal.addEventListener("abort", c, { once: !0 });
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 r.read();
226
+ const u = await s.read();
227
227
  if (u.done) break;
228
- const d = typeof u.value == "string" ? u.value : a.decode(u.value, { stream: !0 });
229
- d && s(d);
228
+ const d = typeof u.value == "string" ? u.value : c.decode(u.value, { stream: !0 });
229
+ d && r(d);
230
230
  }
231
- const o = a.decode();
232
- o && s(o);
233
- for (const u of i.finish()) t.onChunk({ taskId: n, chunk: u });
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", c), r.releaseLock();
235
+ t.signal.removeEventListener("abort", a), s.releaseLock();
236
236
  }
237
237
  }
238
- function U(e) {
238
+ function P(e) {
239
239
  const n = {};
240
- for (const [t, i] of Object.entries(e ?? {}))
241
- t.toLowerCase() !== "set-cookie" && (n[t.toLowerCase()] = String(i));
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 B(e, n) {
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 P = "miniapp_simulator_event", A = "skillbuilder-miniapp", C = {
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
- }, F = 10, H = 1e4;
268
- function b() {
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, n) {
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: A,
292
- context_artifactVersion: E,
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: P,
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
- function V(e, n) {
305
- if (!(typeof fetch != "function" || n.length === 0))
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 t = {
308
- method: "POST",
309
- headers: {
310
- "content-type": "application/json",
311
- "Biz-Type": "apm_fe",
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 j(e) {
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 Q(e) {
327
- const n = e.debug === !0, t = b(), i = b();
328
- let s = 0, r = [], a = null, c = 0, o = !1;
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 (o = !1, a !== null && (clearTimeout(a), a = null), r.length === 0) return;
331
- const h = r;
332
- r = [], V(e.endpoint, h);
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 (a !== null && (clearTimeout(a), a = null), c > 0) {
335
- o = !0;
362
+ if (c !== null && (clearTimeout(c), c = null), a > 0) {
363
+ i = !0;
336
364
  return;
337
365
  }
338
366
  u();
339
- }, y = () => {
340
- a === null && (a = setTimeout(d, H));
367
+ }, w = () => {
368
+ c === null && (c = setTimeout(d, H));
341
369
  };
342
370
  return {
343
371
  sendCustomPoint(h) {
344
- const v = s++;
345
- c += 1, Promise.resolve().then(() => e.resolveUserId()).catch(() => "").then((w) => {
372
+ const m = r++;
373
+ a += 1, Promise.resolve().then(() => e.resolveUserId()).catch(() => "").then((k) => {
346
374
  try {
347
- const m = q(h, {
375
+ const b = V(h, {
348
376
  sessionId: t,
349
- pageSessionId: i,
350
- seqId: v,
351
- userId: w,
377
+ pageSessionId: o,
378
+ seqId: m,
379
+ userId: k,
352
380
  region: e.region
353
381
  });
354
382
  if (n) {
355
- j(m);
383
+ W(b);
356
384
  return;
357
385
  }
358
- r.push(m), r.length >= F ? setTimeout(() => d()) : y();
386
+ s.push(b), s.length >= j ? setTimeout(() => d()) : w();
359
387
  } catch {
360
388
  }
361
389
  }).finally(() => {
362
- c -= 1, c === 0 && o && u();
390
+ a -= 1, a === 0 && i && u();
363
391
  });
364
392
  },
365
393
  flush: d
366
394
  };
367
395
  }
368
- function W(e) {
396
+ function M(e) {
369
397
  const n = e.region ?? "cn";
370
398
  if (e.endpoint) return e.endpoint;
371
- const t = z();
372
- return C[n][t];
399
+ const t = $();
400
+ return F[n][t];
373
401
  }
374
- function z() {
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 $(e, n) {
408
+ function G(e, n) {
381
409
  if (e === !1) return null;
382
410
  try {
383
- const t = e.region ?? "cn", i = Q({
384
- endpoint: W(e),
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: (s) => i.sendCustomPoint(s), flush: () => i.flush() };
417
+ return { send: (r) => o.sendCustomPoint(r), flush: () => o.flush() };
390
418
  } catch {
391
419
  return null;
392
420
  }
393
421
  }
394
- class K {
395
- constructor(n, t, i, s) {
396
- this.resolveContext = s, this.unsubscribers = [], this.common = {
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 r = $(n, i);
403
- if (!r) {
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 = r.send, this.flush = r.flush, this.common = {
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 i = {};
566
+ let o = {};
539
567
  try {
540
- i = this.resolveContext?.() ?? {};
568
+ o = this.resolveContext?.() ?? {};
541
569
  } catch {
542
570
  }
543
571
  this.send({
544
572
  name: n,
545
- payload: { ...this.common, ...t, ...i },
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 Z(e) {
586
+ function ee(e) {
559
587
  return !(e === void 0 || e === !1);
560
588
  }
561
589
  export {
562
590
  l as M,
563
- G as a,
591
+ Y as a,
564
592
  f as b,
565
- Q as c,
566
- X as d,
567
- Y as e,
568
- Z as f,
569
- K as g,
570
- p as i,
571
- M as o,
572
- W as r,
573
- E as v
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
  };