@skillbuilder/miniapp-simulator 0.2.4 → 0.2.8

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 (54) hide show
  1. package/README.md +18 -1
  2. package/docs/assets/road-king-controls.png +0 -0
  3. package/docs/audit-data-collection.codex.md +76 -393
  4. package/docs/audit-local-validation.codex.md +1 -1
  5. package/docs/audit-score-design.codex.md +23 -22
  6. package/docs/audit-score-design.md +39 -92
  7. package/docs/audit-score-tech-plan.md +6 -4
  8. package/docs/audit-tech-design.codex.md +36 -19
  9. package/docs/desktop-gesture-design.redoc.xml +96 -0
  10. package/docs/electron-review.md +1 -1
  11. package/docs/quality-evaluation-redoc.xml +4 -4
  12. package/docs/tracker.md +3 -2
  13. package/lib/client-C59iNO5u.mjs +1371 -0
  14. package/lib/{index-7MeYFlk_.mjs → index-BSj1bmle.mjs} +158 -140
  15. package/lib/index.js +4484 -3027
  16. package/lib/remote-client.js +2 -2
  17. package/lib/types/core/simulator.d.ts +2 -0
  18. package/lib/types/gesture/host-bus.d.ts +27 -2
  19. package/lib/types/gesture/input-scheduler.d.ts +29 -0
  20. package/lib/types/gesture/keyboard-panel-view.d.ts +16 -0
  21. package/lib/types/gesture/keyboard-panel.d.ts +54 -0
  22. package/lib/types/gesture/plugins/index.d.ts +11 -14
  23. package/lib/types/gesture/plugins/keyboard-touch.d.ts +4 -0
  24. package/lib/types/gesture/plugins/multi-touch-hint.d.ts +1 -9
  25. package/lib/types/gesture/plugins/multi-touch-switch.d.ts +1 -1
  26. package/lib/types/gesture/plugins/touch-emitter.d.ts +1 -9
  27. package/lib/types/gesture/plugins/wheel-pinch.d.ts +3 -0
  28. package/lib/types/gesture/plugins/wheel-scroll.d.ts +1 -1
  29. package/lib/types/gesture/touch-cursor.d.ts +4 -0
  30. package/lib/types/gesture/touch-sequence.d.ts +12 -0
  31. package/lib/types/gesture/types.d.ts +33 -9
  32. package/lib/types/host/shadow-host.d.ts +15 -5
  33. package/lib/types/inspector/host-inspector.d.ts +1 -1
  34. package/lib/types/remote/audit-controller.d.ts +7 -0
  35. package/lib/types/remote/audit-leave-monitor.d.ts +2 -0
  36. package/lib/types/remote/audit-package-sources.d.ts +9 -0
  37. package/lib/types/remote/audit-telemetry.d.ts +25 -12
  38. package/lib/types/remote/client.d.ts +2 -0
  39. package/lib/types/remote/keyboard-panel-host.d.ts +19 -0
  40. package/lib/types/remote/protocol.d.ts +38 -4
  41. package/lib/types/remote/runtime-entry.d.ts +2 -1
  42. package/lib/types/remote/runtime.d.ts +1 -1
  43. package/lib/types/runtime/jsapi-modules/interaction.d.ts +1 -1
  44. package/lib/types/runtime/jsapi-modules/local-media.d.ts +4 -0
  45. package/lib/types/runtime/jsapi-modules/media.d.ts +1 -1
  46. package/lib/types/runtime/jsapi-modules/note-publish-media.d.ts +9 -0
  47. package/lib/types/tracker/constants.d.ts +1 -1
  48. package/lib/types/tracker/default-tracker.d.ts +1 -1
  49. package/lib/types/types/options.d.ts +6 -2
  50. package/lib/types/types/renderer.d.ts +8 -0
  51. package/lib/types/utils/screen-coordinates.d.ts +31 -0
  52. package/lib/workbench.js +1 -1
  53. package/package.json +1 -1
  54. package/lib/client-BDt3WDu_.mjs +0 -1118
@@ -1,12 +1,12 @@
1
- const p = "0.2.4", y = /* @__PURE__ */ new Set();
2
- function X(e, n) {
1
+ const T = "0.2.8", v = /* @__PURE__ */ new Set();
2
+ function Z(e, n) {
3
3
  const t = () => {
4
4
  let r = !document.hidden && e.isConnected;
5
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);
6
+ const a = getComputedStyle(s);
7
+ r = a.display !== "none" && a.visibility !== "hidden" && a.visibility !== "collapse";
8
+ const c = s.getRootNode();
9
+ s = s.parentElement ?? (c instanceof ShadowRoot ? c.host : null);
10
10
  }
11
11
  n(r);
12
12
  }, o = new MutationObserver(t);
@@ -19,7 +19,7 @@ function X(e, n) {
19
19
  o.disconnect(), document.removeEventListener("visibilitychange", t), window.removeEventListener("resize", t), window.removeEventListener("pageshow", t);
20
20
  };
21
21
  }
22
- function Y(e, n) {
22
+ function J(e, n) {
23
23
  let t = "", o = 0;
24
24
  const r = () => {
25
25
  if (document.hidden || !e.isConnected) return !1;
@@ -27,8 +27,8 @@ function Y(e, n) {
27
27
  const u = getComputedStyle(i);
28
28
  if (u.display === "none" || u.visibility === "hidden" || u.visibility === "collapse")
29
29
  return !1;
30
- const d = i.getRootNode();
31
- i = i.parentElement ?? (d instanceof ShadowRoot ? d.host : null);
30
+ const l = i.getRootNode();
31
+ i = i.parentElement ?? (l instanceof ShadowRoot ? l.host : null);
32
32
  }
33
33
  return !0;
34
34
  }, s = () => {
@@ -46,7 +46,7 @@ function Y(e, n) {
46
46
  );
47
47
  } catch {
48
48
  }
49
- }, c = (i) => {
49
+ }, a = (i) => {
50
50
  if (!(!i.isTrusted || i.source !== e.contentWindow || i.data?.type !== "mini-app:worker-ready" || typeof i.data.sessionId != "string")) {
51
51
  try {
52
52
  if (i.origin !== new URL(n(), location.href).origin || e.contentWindow?.__MINITOOL_WORKER_CONTEXT__?.sessionId !== i.data.sessionId)
@@ -56,21 +56,21 @@ function Y(e, n) {
56
56
  }
57
57
  t = i.data.sessionId, s();
58
58
  }
59
- }, a = new MutationObserver(s);
59
+ }, c = new MutationObserver(s);
60
60
  for (let i = e; i; ) {
61
- a.observe(i, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
61
+ c.observe(i, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
62
62
  const u = i.getRootNode();
63
63
  i = i.parentElement ?? (u instanceof ShadowRoot ? u.host : null);
64
64
  }
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);
65
+ return window.addEventListener("message", a), window.addEventListener("resize", s), window.addEventListener("pageshow", s), document.addEventListener("visibilitychange", s), v.add(s), () => {
66
+ v.delete(s), c.disconnect(), window.removeEventListener("message", a), window.removeEventListener("resize", s), window.removeEventListener("pageshow", s), document.removeEventListener("visibilitychange", s);
67
67
  };
68
68
  }
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
- function f(e, n) {
69
+ var f = /* @__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))(f || {});
70
+ function m(e, n) {
71
71
  return Object.assign(new Error(n), { code: e });
72
72
  }
73
- class E {
73
+ class I {
74
74
  constructor() {
75
75
  this.buffer = "";
76
76
  }
@@ -86,42 +86,42 @@ class E {
86
86
  const t = [];
87
87
  let o = 0, r = 0, s = 0;
88
88
  for (; s < this.buffer.length; ) {
89
- const c = this.buffer[s];
90
- if (c !== "\r" && c !== `
89
+ const a = this.buffer[s];
90
+ if (a !== "\r" && a !== `
91
91
  `) {
92
92
  s += 1;
93
93
  continue;
94
94
  }
95
- let a = s + 1;
96
- if (c === "\r") {
97
- if (a === this.buffer.length && !n) break;
98
- this.buffer[a] === `
99
- ` && (a += 1);
95
+ let c = s + 1;
96
+ if (a === "\r") {
97
+ if (c === this.buffer.length && !n) break;
98
+ this.buffer[c] === `
99
+ ` && (c += 1);
100
100
  }
101
- s === r && (t.push(this.buffer.slice(o, a)), o = a), r = a, s = a;
101
+ s === r && (t.push(this.buffer.slice(o, c)), o = c), r = c, s = c;
102
102
  }
103
103
  return o > 0 && (this.buffer = this.buffer.slice(o)), t;
104
104
  }
105
105
  }
106
- function K() {
106
+ function ee() {
107
107
  let e = "";
108
108
  const n = (t) => {
109
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 !== `
110
+ let r = 0, s = 0, a = 0;
111
+ for (; a < e.length; ) {
112
+ const c = e[a];
113
+ if (c !== "\r" && c !== `
114
114
  `) {
115
- c += 1;
115
+ a += 1;
116
116
  continue;
117
117
  }
118
- let i = c + 1;
119
- if (a === "\r") {
118
+ let i = a + 1;
119
+ if (c === "\r") {
120
120
  if (i === e.length && !t) break;
121
121
  e[i] === `
122
122
  ` && (i += 1);
123
123
  }
124
- c === s && (o.push(e.slice(r, i)), r = i), s = i, c = i;
124
+ a === s && (o.push(e.slice(r, i)), r = i), s = i, a = i;
125
125
  }
126
126
  return r > 0 && (e = e.slice(r)), o;
127
127
  };
@@ -135,30 +135,30 @@ function K() {
135
135
  }
136
136
  };
137
137
  }
138
- function T(e) {
138
+ function S(e) {
139
139
  return e?.toLowerCase().includes("text/event-stream") ?? !1;
140
140
  }
141
- const I = /* @__PURE__ */ new WeakMap();
142
- async function Z(e, n, t) {
143
- D(n.data);
144
- const o = I.get(e);
141
+ const R = /* @__PURE__ */ new WeakMap();
142
+ async function te(e, n, t) {
143
+ N(n.data);
144
+ const o = R.get(e);
145
145
  if (o) return o(n, t);
146
- const r = await e(R(n, t.signal));
146
+ const r = await e(L(n, t.signal));
147
147
  if (t.signal.aborted)
148
- throw f(l.REQUEST_ABORTED, "request aborted");
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 }) : {
148
+ throw m(f.REQUEST_ABORTED, "request aborted");
149
+ U(r);
150
+ const s = A(r.header);
151
+ return t.onHeaders({ taskId: n.taskId, statusCode: r.statusCode, header: s }), n.enableChunked && S(s["content-type"]) && (typeof r.data == "string" || C(r.data)) ? (await P(r.data, n.taskId, t), { taskId: n.taskId, statusCode: r.statusCode, data: "", header: s }) : {
152
152
  taskId: n.taskId,
153
153
  statusCode: r.statusCode,
154
- data: await A(r.data, n),
154
+ data: await B(r.data, n),
155
155
  header: s
156
156
  };
157
157
  }
158
- function R(e, n) {
158
+ function L(e, n) {
159
159
  const t = e.data, o = { ...e.header }, r = e.method.toUpperCase();
160
160
  return r === "GET" || r === "HEAD" ? {
161
- url: S(e.url, v(t)),
161
+ url: O(e.url, k(t)),
162
162
  method: e.method,
163
163
  header: o,
164
164
  responseType: e.responseType,
@@ -168,48 +168,48 @@ function R(e, n) {
168
168
  url: e.url,
169
169
  method: e.method,
170
170
  header: o,
171
- data: L(t, o),
171
+ data: D(t, o),
172
172
  responseType: e.responseType,
173
173
  enableChunked: e.enableChunked,
174
174
  signal: n
175
175
  };
176
176
  }
177
- function S(e, n) {
177
+ function O(e, n) {
178
178
  if (!n) return e;
179
179
  const t = e.indexOf("#"), o = t >= 0 ? e.slice(t) : "", r = t >= 0 ? e.slice(0, t) : e;
180
180
  return `${r}${r.includes("?") ? "&" : "?"}${n}${o}`;
181
181
  }
182
- function v(e) {
182
+ function k(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
- function L(e, n) {
185
+ function D(e, n) {
186
186
  if (e == null || typeof e == "string") return 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);
187
+ let t = x(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") ? k(e) : String(e);
189
189
  }
190
- function O(e, n) {
190
+ function x(e, n) {
191
191
  const t = Object.keys(e).find((o) => o.toLowerCase() === n);
192
192
  return t ? String(e[t]) : void 0;
193
193
  }
194
- function D(e) {
194
+ function N(e) {
195
195
  if (!(!(e instanceof ArrayBuffer) && !ArrayBuffer.isView(e)))
196
- throw f(
197
- l.INVALID_PARAM,
196
+ throw m(
197
+ f.INVALID_PARAM,
198
198
  "request data does not support ArrayBuffer"
199
199
  );
200
200
  }
201
- function x(e) {
201
+ function U(e) {
202
202
  if (!e || typeof e != "object" || typeof e.statusCode != "number")
203
- throw f(
204
- l.REQUEST_FAILED,
203
+ throw m(
204
+ f.REQUEST_FAILED,
205
205
  "host request adapter returned an invalid response"
206
206
  );
207
207
  }
208
- function N(e) {
208
+ function C(e) {
209
209
  return !!(e && typeof e == "object" && "getReader" in e);
210
210
  }
211
- async function U(e, n, t) {
212
- const o = new E(), r = (i) => {
211
+ async function P(e, n, t) {
212
+ const o = new I(), r = (i) => {
213
213
  for (const u of o.push(i)) t.onChunk({ taskId: n, chunk: u });
214
214
  };
215
215
  if (typeof e == "string") {
@@ -217,34 +217,34 @@ async function U(e, n, t) {
217
217
  for (const i of o.finish()) t.onChunk({ taskId: n, chunk: i });
218
218
  return;
219
219
  }
220
- const s = e.getReader(), c = new TextDecoder(), a = () => void s.cancel().catch(() => {
220
+ const s = e.getReader(), a = new TextDecoder(), c = () => void s.cancel().catch(() => {
221
221
  });
222
- t.signal.addEventListener("abort", a, { once: !0 });
222
+ t.signal.addEventListener("abort", c, { once: !0 });
223
223
  try {
224
224
  for (; ; ) {
225
225
  if (t.signal.aborted) return;
226
226
  const u = await s.read();
227
227
  if (u.done) break;
228
- const d = typeof u.value == "string" ? u.value : c.decode(u.value, { stream: !0 });
229
- d && r(d);
228
+ const l = typeof u.value == "string" ? u.value : a.decode(u.value, { stream: !0 });
229
+ l && r(l);
230
230
  }
231
- const i = c.decode();
231
+ const i = a.decode();
232
232
  i && r(i);
233
233
  for (const u of o.finish()) t.onChunk({ taskId: n, chunk: u });
234
234
  } finally {
235
- t.signal.removeEventListener("abort", a), s.releaseLock();
235
+ t.signal.removeEventListener("abort", c), s.releaseLock();
236
236
  }
237
237
  }
238
- function P(e) {
238
+ function A(e) {
239
239
  const n = {};
240
240
  for (const [t, o] of Object.entries(e ?? {}))
241
241
  t.toLowerCase() !== "set-cookie" && (n[t.toLowerCase()] = String(o));
242
242
  return n;
243
243
  }
244
- async function A(e, n) {
244
+ async function B(e, n) {
245
245
  if (e instanceof ArrayBuffer || ArrayBuffer.isView(e))
246
- throw f(
247
- l.REQUEST_FAILED,
246
+ throw m(
247
+ f.REQUEST_FAILED,
248
248
  "request response does not support ArrayBuffer"
249
249
  );
250
250
  if (n.dataType === "json" && typeof e == "string")
@@ -255,7 +255,7 @@ async function A(e, n) {
255
255
  }
256
256
  return e;
257
257
  }
258
- const B = "miniapp_simulator_event", C = "skillbuilder-miniapp", F = {
258
+ const F = "miniapp_simulator_event", q = "skillbuilder-miniapp", j = {
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,11 @@ const B = "miniapp_simulator_event", C = "skillbuilder-miniapp", F = {
264
264
  production: "https://apm-fe.rnote.com/api/data",
265
265
  development: "https://apm-fe.rnote.com/api/data"
266
266
  }
267
- }, j = 10, H = 1e4;
268
- function g() {
267
+ }, b = 10, H = 1e4;
268
+ function w() {
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 V(e) {
272
272
  return Object.fromEntries(
273
273
  Object.entries(e).map(([n, t]) => [
274
274
  n,
@@ -276,7 +276,7 @@ function q(e) {
276
276
  ])
277
277
  );
278
278
  }
279
- function V(e, n) {
279
+ function Q(e, n) {
280
280
  const t = typeof window < "u";
281
281
  return {
282
282
  clientTime: Date.now(),
@@ -296,21 +296,37 @@ function V(e, n) {
296
296
  context_matchedPath: t ? window.location.pathname : "",
297
297
  context_route: t ? window.location.href : "",
298
298
  context_userAgent: typeof navigator < "u" ? navigator.userAgent : "",
299
- context_artifactName: C,
300
- context_artifactVersion: p,
299
+ context_artifactName: q,
300
+ context_artifactVersion: T,
301
301
  context_deviceLevel: "unknown",
302
302
  context_feSdkVersion: "1.3.13",
303
303
  context_userId: n.userId,
304
- measurement_name: B,
304
+ measurement_name: F,
305
305
  measurement_data: {
306
306
  event_name: e.name,
307
307
  timestamp: e.timestamp,
308
- ...q(e.payload)
308
+ ...V(e.payload)
309
309
  }
310
310
  };
311
311
  }
312
- const _ = [250, 1e3];
313
- async function Q(e, n) {
312
+ const y = [250, 1e3], M = 5e3;
313
+ let E = Promise.resolve();
314
+ function W(e, n) {
315
+ const t = async () => {
316
+ let o;
317
+ try {
318
+ o = await z(e.endpoint, n);
319
+ } catch {
320
+ o = { ok: !1, attempts: 0, eventCount: n.length };
321
+ }
322
+ try {
323
+ e.onDelivery?.(o);
324
+ } catch {
325
+ }
326
+ };
327
+ E = E.then(t, t);
328
+ }
329
+ async function z(e, n) {
314
330
  const t = n.length;
315
331
  if (typeof fetch != "function" || t === 0)
316
332
  return { ok: !1, attempts: 0, eventCount: t };
@@ -325,91 +341,93 @@ async function Q(e, n) {
325
341
  keepalive: !0
326
342
  };
327
343
  let r;
328
- for (let s = 0; s <= _.length; s += 1) {
344
+ for (let s = 0; s <= y.length; s += 1) {
345
+ const a = new AbortController(), c = setTimeout(() => a.abort(), M);
329
346
  try {
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 };
347
+ const u = await fetch(e, { ...o, signal: a.signal });
348
+ if (r = u.status, u.ok)
349
+ return { ok: !0, status: u.status, attempts: s + 1, eventCount: t };
350
+ if (u.status >= 400 && u.status < 500)
351
+ return { ok: !1, status: u.status, attempts: s + 1, eventCount: t };
335
352
  } catch {
353
+ } finally {
354
+ clearTimeout(c);
336
355
  }
337
- const c = _[s];
338
- if (c === void 0)
356
+ const i = y[s];
357
+ if (i === void 0)
339
358
  return { ok: !1, status: r, attempts: s + 1, eventCount: t };
340
- await new Promise((a) => setTimeout(a, c));
359
+ await new Promise((u) => setTimeout(u, i));
341
360
  }
342
- return { ok: !1, status: r, attempts: _.length + 1, eventCount: t };
361
+ return { ok: !1, status: r, attempts: y.length + 1, eventCount: t };
343
362
  }
344
- function W(e) {
363
+ function $(e) {
345
364
  if (typeof console > "u") return;
346
365
  const n = e.measurement_name ?? "apm";
347
366
  console.groupCollapsed(`[apm] ${n}`), console.log(e), console.groupEnd();
348
367
  }
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;
368
+ function G(e) {
369
+ const n = e.debug === !0, t = w(), o = w();
370
+ let r = 0, s = [], a = null, c = 0, i = !1;
352
371
  const u = () => {
353
- if (i = !1, c !== null && (clearTimeout(c), c = null), s.length === 0) return;
372
+ if (i = !1, a !== null && (clearTimeout(a), a = null), s.length === 0) return;
354
373
  const h = s;
355
- s = [], Q(e.endpoint, h).then((m) => {
356
- try {
357
- e.onDelivery?.(m);
358
- } catch {
359
- }
360
- });
361
- }, d = () => {
362
- if (c !== null && (clearTimeout(c), c = null), a > 0) {
374
+ s = [];
375
+ for (let d = 0; d < h.length; d += b) {
376
+ const _ = h.slice(d, d + b);
377
+ W(e, _);
378
+ }
379
+ }, l = () => {
380
+ if (a !== null && (clearTimeout(a), a = null), c > 0) {
363
381
  i = !0;
364
382
  return;
365
383
  }
366
384
  u();
367
- }, w = () => {
368
- c === null && (c = setTimeout(d, H));
385
+ }, p = () => {
386
+ a === null && (a = setTimeout(l, H));
369
387
  };
370
388
  return {
371
389
  sendCustomPoint(h) {
372
- const m = r++;
373
- a += 1, Promise.resolve().then(() => e.resolveUserId()).catch(() => "").then((k) => {
390
+ const d = r++;
391
+ c += 1, Promise.resolve().then(() => e.resolveUserId()).catch(() => "").then((_) => {
374
392
  try {
375
- const b = V(h, {
393
+ const g = Q(h, {
376
394
  sessionId: t,
377
395
  pageSessionId: o,
378
- seqId: m,
379
- userId: k,
396
+ seqId: d,
397
+ userId: _,
380
398
  region: e.region
381
399
  });
382
400
  if (n) {
383
- W(b);
401
+ $(g);
384
402
  return;
385
403
  }
386
- s.push(b), s.length >= j ? setTimeout(() => d()) : w();
404
+ s.push(g), s.length >= b ? setTimeout(() => l()) : p();
387
405
  } catch {
388
406
  }
389
407
  }).finally(() => {
390
- a -= 1, a === 0 && i && u();
408
+ c -= 1, c === 0 && i && u();
391
409
  });
392
410
  },
393
- flush: d
411
+ flush: l
394
412
  };
395
413
  }
396
- function M(e) {
414
+ function X(e) {
397
415
  const n = e.region ?? "cn";
398
416
  if (e.endpoint) return e.endpoint;
399
- const t = $();
400
- return F[n][t];
417
+ const t = Y();
418
+ return j[n][t];
401
419
  }
402
- function $() {
420
+ function Y() {
403
421
  if (typeof window > "u") return "production";
404
422
  const e = window.location.hostname.toLowerCase();
405
423
  return e === "localhost" || e === "127.0.0.1" || e === "0.0.0.0" || e.includes(".sit.") || // hostname.includes(".beta.") ||
406
424
  e.startsWith("local.") ? "development" : "production";
407
425
  }
408
- function G(e, n) {
426
+ function K(e, n) {
409
427
  if (e === !1) return null;
410
428
  try {
411
- const t = e.region ?? "cn", o = z({
412
- endpoint: M(e),
429
+ const t = e.region ?? "cn", o = G({
430
+ endpoint: X(e),
413
431
  region: t,
414
432
  resolveUserId: n ?? (() => Promise.resolve("")),
415
433
  debug: e.debug
@@ -419,7 +437,7 @@ function G(e, n) {
419
437
  return null;
420
438
  }
421
439
  }
422
- class J {
440
+ class ne {
423
441
  constructor(n, t, o, r) {
424
442
  this.resolveContext = r, this.unsubscribers = [], this.common = {
425
443
  business_line: "",
@@ -427,7 +445,7 @@ class J {
427
445
  content_mode: "",
428
446
  renderer: ""
429
447
  };
430
- const s = G(n, o);
448
+ const s = K(n, o);
431
449
  if (!s) {
432
450
  this.send = () => {
433
451
  }, this.flush = () => {
@@ -583,20 +601,20 @@ class J {
583
601
  this.unsubscribers.length = 0;
584
602
  }
585
603
  }
586
- function ee(e) {
604
+ function se(e) {
587
605
  return !(e === void 0 || e === !1);
588
606
  }
589
607
  export {
590
- l as M,
591
- Y as a,
592
- f as b,
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
608
+ f as M,
609
+ J as a,
610
+ m as b,
611
+ G as c,
612
+ ee as d,
613
+ te as e,
614
+ se as f,
615
+ ne as g,
616
+ S as i,
617
+ Z as o,
618
+ X as r,
619
+ T as v
602
620
  };