ionblink-js 0.1.2 → 0.1.6
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 +81 -6
- package/README.md +40 -17
- package/dist/cjs/index.cjs +673 -144
- package/dist/cjs/protocol.cjs +6 -0
- package/dist/esm/{c-2BL72NP3.js → c-7SPQIMCH.js} +44 -23
- package/dist/esm/{c-VOZLB3UG.js → c-EMLSQ5BC.js} +1 -3
- package/dist/esm/c-ILAGKULG.js +431 -0
- package/dist/esm/{c-MLVABENR.js → c-LULHYRWR.js} +52 -5
- package/dist/esm/{c-YTOQLBPZ.js → c-MNMQMJ5I.js} +7 -1
- package/dist/esm/{c-FTUPFEXC.js → c-UMIKYUMF.js} +13 -5
- package/dist/esm/index.js +21 -12
- package/dist/esm/protocol.js +7 -1
- package/dist/i-729781ba45.js +1 -0
- package/dist/integrity.json +6 -5
- package/dist/ionblink.min.js +1 -1
- package/dist/{r-fa1898205a.js → r-a4f89dccd1.js} +1 -1
- package/dist/types/auto.d.ts +2 -1
- package/dist/types/consent.d.ts +9 -1
- package/dist/types/inspect-cdn.d.ts +1 -0
- package/dist/types/inspect.d.ts +29 -0
- package/dist/types/mask.d.ts +6 -5
- package/dist/types/phone-replay.d.ts +42 -0
- package/dist/types/protocol.d.ts +112 -10
- package/dist/types/replay-npm.d.ts +2 -0
- package/dist/types/replay.d.ts +4 -2
- package/dist/types/types.d.ts +40 -0
- package/dist/types/vitals.d.ts +1 -0
- package/dist/v1.js +1 -1
- package/dist/x-8b414fa290.js +1 -0
- package/package.json +2 -2
- package/dist/x-0e25e29517.js +0 -1
- /package/dist/{r-fa1898205a.js.LICENSE.txt → r-a4f89dccd1.js.LICENSE.txt} +0 -0
package/dist/cjs/protocol.cjs
CHANGED
|
@@ -20,7 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/protocol.ts
|
|
21
21
|
var protocol_exports = {};
|
|
22
22
|
__export(protocol_exports, {
|
|
23
|
+
CONSOLE_PLUGIN: () => CONSOLE_PLUGIN,
|
|
23
24
|
LIMITS: () => LIMITS,
|
|
25
|
+
MOBILE_REPLAY_TAG: () => MOBILE_REPLAY_TAG,
|
|
26
|
+
NETWORK_PLUGIN: () => NETWORK_PLUGIN,
|
|
24
27
|
PROTOCOL_VERSION: () => PROTOCOL_VERSION,
|
|
25
28
|
SYSTEM_EVENTS: () => SYSTEM_EVENTS
|
|
26
29
|
});
|
|
@@ -71,3 +74,6 @@ var SYSTEM_EVENTS = [
|
|
|
71
74
|
"$tap",
|
|
72
75
|
"$rage_tap"
|
|
73
76
|
];
|
|
77
|
+
var CONSOLE_PLUGIN = "rrweb/console@1";
|
|
78
|
+
var NETWORK_PLUGIN = "rrweb/network@1";
|
|
79
|
+
var MOBILE_REPLAY_TAG = "ib.mobile";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
now,
|
|
7
7
|
report,
|
|
8
8
|
setReporter
|
|
9
|
-
} from "./c-
|
|
9
|
+
} from "./c-EMLSQ5BC.js";
|
|
10
10
|
import {
|
|
11
11
|
NO_CAPTURE,
|
|
12
12
|
isSensitive,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
selector,
|
|
15
15
|
shortText,
|
|
16
16
|
textFor
|
|
17
|
-
} from "./c-
|
|
17
|
+
} from "./c-UMIKYUMF.js";
|
|
18
18
|
import {
|
|
19
19
|
actionable,
|
|
20
20
|
boxOf,
|
|
@@ -136,6 +136,19 @@ function createAuto(ctx) {
|
|
|
136
136
|
if (seen[k] > 1) p.n = seen[k];
|
|
137
137
|
ctx.capture("$error", p, now());
|
|
138
138
|
}
|
|
139
|
+
function field(target, action, t) {
|
|
140
|
+
const el = target;
|
|
141
|
+
if (!ctx.on("forms") || !el || !/^(INPUT|SELECT|TEXTAREA)$/.test(el.tagName) || closest(el, NO_CAPTURE)) return;
|
|
142
|
+
const type = el.tagName === "INPUT" ? (el.getAttribute("type") || "text").toLowerCase() : el.tagName.toLowerCase();
|
|
143
|
+
if (type === "hidden" || type === "submit" || type === "button") return;
|
|
144
|
+
const fd = { type };
|
|
145
|
+
const label = fieldLabel(el, ctx.level());
|
|
146
|
+
const name = el.getAttribute("name");
|
|
147
|
+
if (label) fd.label = label;
|
|
148
|
+
if (name) fd.name = scrub(name.slice(0, 40));
|
|
149
|
+
if (isSensitive(el)) fd.sensitive = true;
|
|
150
|
+
ctx.capture("$field", { action, field: fd }, t);
|
|
151
|
+
}
|
|
139
152
|
return {
|
|
140
153
|
click(e, t, box, late) {
|
|
141
154
|
const el = actionable(e.target);
|
|
@@ -170,21 +183,10 @@ function createAuto(ctx) {
|
|
|
170
183
|
selection(t) {
|
|
171
184
|
lastSel = t;
|
|
172
185
|
},
|
|
173
|
-
field
|
|
174
|
-
const el = e.target;
|
|
175
|
-
if (!ctx.on("forms") || !el || !/^(INPUT|SELECT|TEXTAREA)$/.test(el.tagName) || closest(el, NO_CAPTURE)) return;
|
|
176
|
-
const type = el.tagName === "INPUT" ? (el.getAttribute("type") || "text").toLowerCase() : el.tagName.toLowerCase();
|
|
177
|
-
if (type === "hidden" || type === "submit" || type === "button") return;
|
|
178
|
-
const field = { type };
|
|
179
|
-
const label = fieldLabel(el, ctx.level());
|
|
180
|
-
const name = el.getAttribute("name");
|
|
181
|
-
if (label) field.label = label;
|
|
182
|
-
if (name) field.name = scrub(name.slice(0, 40));
|
|
183
|
-
if (isSensitive(el)) field.sensitive = true;
|
|
184
|
-
ctx.capture("$field", { action: focus ? "focus" : "blur", field }, t);
|
|
185
|
-
},
|
|
186
|
+
field,
|
|
186
187
|
input(e, t) {
|
|
187
188
|
const el = e.target;
|
|
189
|
+
if (el && /^(select|checkbox|radio)/.test(el.type)) field(el, "change", t);
|
|
188
190
|
const f = el && el.form;
|
|
189
191
|
if (!ctx.on("forms") || !f || started.has(f) || closest(f, NO_CAPTURE)) return;
|
|
190
192
|
started.add(f);
|
|
@@ -219,12 +221,18 @@ var afterLoad = (fn) => {
|
|
|
219
221
|
function createReplay(api) {
|
|
220
222
|
let loading = false;
|
|
221
223
|
let budget = false;
|
|
224
|
+
const waits = () => {
|
|
225
|
+
const s = api.rs();
|
|
226
|
+
return !!s.cfg && s.mode !== "replay";
|
|
227
|
+
};
|
|
228
|
+
let waited = waits();
|
|
222
229
|
const blocked = (path) => {
|
|
223
230
|
const g = api.rs().opts.blockPaths;
|
|
224
231
|
return !!g && g.some((x) => typeof x === "string" && glob(x).test(path));
|
|
225
232
|
};
|
|
226
233
|
function gate() {
|
|
227
234
|
const s = api.rs();
|
|
235
|
+
if (waits()) waited = true;
|
|
228
236
|
if (s.mode !== "replay" || !s.sid) return "mode";
|
|
229
237
|
if (s.killed === "replay" || s.killed === "all") return "killed";
|
|
230
238
|
if (!s.cfg) return s.failed ? "no_config" : "wait";
|
|
@@ -267,7 +275,13 @@ function createReplay(api) {
|
|
|
267
275
|
if (r === "budget") budget = true;
|
|
268
276
|
stop(r);
|
|
269
277
|
},
|
|
270
|
-
report
|
|
278
|
+
report,
|
|
279
|
+
cfg: () => {
|
|
280
|
+
const c = api.rs().cfg;
|
|
281
|
+
return c ? c.replay : void 0;
|
|
282
|
+
},
|
|
283
|
+
opts: s.opts,
|
|
284
|
+
fresh: !waited
|
|
271
285
|
});
|
|
272
286
|
} catch (e) {
|
|
273
287
|
off("unsupported");
|
|
@@ -695,6 +709,7 @@ function createSignals(start2) {
|
|
|
695
709
|
// src/vitals.ts
|
|
696
710
|
function watchVitals() {
|
|
697
711
|
let lcp;
|
|
712
|
+
let lcpEl;
|
|
698
713
|
let cls = 0;
|
|
699
714
|
let win = 0;
|
|
700
715
|
let winStart = 0;
|
|
@@ -717,6 +732,7 @@ function watchVitals() {
|
|
|
717
732
|
}
|
|
718
733
|
observe("largest-contentful-paint", (e) => {
|
|
719
734
|
lcp = e.startTime;
|
|
735
|
+
lcpEl = e.element;
|
|
720
736
|
});
|
|
721
737
|
observe("layout-shift", (e) => {
|
|
722
738
|
const s = e;
|
|
@@ -740,6 +756,7 @@ function watchVitals() {
|
|
|
740
756
|
read() {
|
|
741
757
|
const out = {};
|
|
742
758
|
if (lcp !== void 0) out.lcp = Math.round(lcp);
|
|
759
|
+
if (lcpEl) out.lcp_el = selector(lcpEl);
|
|
743
760
|
if (types.indexOf("layout-shift") >= 0) out.cls = Math.round(cls * 1e3) / 1e3;
|
|
744
761
|
const d = Object.keys(inter).map((k) => inter[+k]).sort((a, b) => b - a);
|
|
745
762
|
if (d.length) out.inp = Math.round(d[Math.min(d.length - 1, Math.floor(d.length / 50))]);
|
|
@@ -784,6 +801,10 @@ function start(api, navStart) {
|
|
|
784
801
|
if (lastA) eng += Math.min(Math.max(0, t - lastA), 5e3);
|
|
785
802
|
lastA = t;
|
|
786
803
|
};
|
|
804
|
+
const page = () => ({
|
|
805
|
+
engaged_ms: Math.round(eng),
|
|
806
|
+
scroll_pct: Math.min(100, Math.round((maxY + window.innerHeight) / (document.documentElement.scrollHeight || 1) * 100))
|
|
807
|
+
});
|
|
787
808
|
const h = {
|
|
788
809
|
pointermove: (e, t) => {
|
|
789
810
|
act(t);
|
|
@@ -828,13 +849,14 @@ function start(api, navStart) {
|
|
|
828
849
|
},
|
|
829
850
|
copy: () => c() && sig.copy(),
|
|
830
851
|
paste: () => c() && sig.paste(),
|
|
831
|
-
focusin: (e, t) => auto.field(e,
|
|
832
|
-
focusout: (e, t) => auto.field(e,
|
|
852
|
+
focusin: (e, t) => auto.field(e.target, "focus", t),
|
|
853
|
+
focusout: (e, t) => auto.field(e.target, "blur", t),
|
|
833
854
|
submit: (e, t) => auto.submit(e, t),
|
|
834
855
|
selectionchange: (_e, t) => auto.selection(t),
|
|
835
856
|
error: (e) => e instanceof ErrorEvent && auto.error(e),
|
|
836
857
|
unhandledrejection: (e) => auto.rejection(e),
|
|
837
858
|
securitypolicyviolation: (e) => {
|
|
859
|
+
if (e.disposition === "report") return;
|
|
838
860
|
auto.csp(e);
|
|
839
861
|
cspHint(e);
|
|
840
862
|
},
|
|
@@ -856,11 +878,10 @@ function start(api, navStart) {
|
|
|
856
878
|
if (f) f(e, t, extra, late);
|
|
857
879
|
},
|
|
858
880
|
dirty: sig.dirty,
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}),
|
|
881
|
+
// a page hidden for good without a pagehide (in-app browsers, a killed tab) sends no $page_leave: its last
|
|
882
|
+
// $signals carries the depth and engaged time instead
|
|
883
|
+
summary: (t) => ({ ...sig.summary(t), ...page() }),
|
|
884
|
+
page,
|
|
864
885
|
vitals: () => vit ? vit.read() : {},
|
|
865
886
|
automation: readAutomation,
|
|
866
887
|
queue: (name) => openQueue(name),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/util.ts
|
|
2
|
-
var VERSION = true ? "0.1.
|
|
2
|
+
var VERSION = true ? "0.1.6" : "0.0.0-dev";
|
|
3
3
|
var now = () => Date.now();
|
|
4
4
|
function rnd(n) {
|
|
5
5
|
const a = new Uint8Array(n);
|
|
@@ -37,7 +37,6 @@ function fnv1a(s) {
|
|
|
37
37
|
for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619) >>> 0;
|
|
38
38
|
return h;
|
|
39
39
|
}
|
|
40
|
-
var clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
41
40
|
var perf = { total: 0, max: 0, over4: 0, over50: 0, errors: 0 };
|
|
42
41
|
var reporter = null;
|
|
43
42
|
function setReporter(r) {
|
|
@@ -89,7 +88,6 @@ export {
|
|
|
89
88
|
uuid4,
|
|
90
89
|
uuid7,
|
|
91
90
|
fnv1a,
|
|
92
|
-
clamp,
|
|
93
91
|
perf,
|
|
94
92
|
setReporter,
|
|
95
93
|
hasReporter,
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
// src/inspect.ts
|
|
2
|
+
var LINE = 2e3;
|
|
3
|
+
var MAX_LINES = 1e3;
|
|
4
|
+
var MAX_CHARS = 4e5;
|
|
5
|
+
var MAX_REQS = 1e3;
|
|
6
|
+
var RATE = 20;
|
|
7
|
+
var BURST = 100;
|
|
8
|
+
var WAIT_MS = 1500;
|
|
9
|
+
var LEVELS = ["log", "info", "warn", "error"];
|
|
10
|
+
var CONSOLE_PLUGIN = "rrweb/console@1";
|
|
11
|
+
var NETWORK_PLUGIN = "rrweb/network@1";
|
|
12
|
+
var SECRET = /pass|pwd|secret|token|auth(?!or(?!i))|bearer|cookie|session.?id|sessid|(?:^|[^a-z])sid(?:$|[^a-z])|csrf|xsrf|signature|credential|card|cc-?num|cvc|cvv|iban|ssn|otp|e-?mail|phone|api.?key|private.?key/i;
|
|
13
|
+
var AUTHZ = /\b(?:Bearer|Basic|Digest|Token)\s+[\w.~+/=-]{6,}/gi;
|
|
14
|
+
var URLS = /\bhttps?:\/\/[^\s"'<>()\\]+/gi;
|
|
15
|
+
var cur = null;
|
|
16
|
+
var stars = (s) => s.replace(/\S/g, "*");
|
|
17
|
+
var scrub = stars;
|
|
18
|
+
var seg = () => "/:redacted";
|
|
19
|
+
var wrapped = 0;
|
|
20
|
+
var swept = false;
|
|
21
|
+
var busy = false;
|
|
22
|
+
var bucket = () => ({ n: BURST, at: 0, used: 0, chars: 0, skipped: 0, done: false });
|
|
23
|
+
var con = bucket();
|
|
24
|
+
var net = bucket();
|
|
25
|
+
var plugin = (name, payload) => ({ type: 6, data: { plugin: name, payload }, timestamp: Date.now() });
|
|
26
|
+
function note(text2) {
|
|
27
|
+
if (cur) cur.push(plugin(CONSOLE_PLUGIN, { level: "warn", trace: [], payload: [JSON.stringify("[ionblink] " + text2)] }));
|
|
28
|
+
}
|
|
29
|
+
function take(b, max, what) {
|
|
30
|
+
if (b.done) return false;
|
|
31
|
+
if (b.used >= max || b.chars > MAX_CHARS) {
|
|
32
|
+
b.done = true;
|
|
33
|
+
note(what + " capture stopped for this page after " + b.used);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const t = Date.now();
|
|
37
|
+
b.n = Math.min(BURST, b.n + (t - b.at) * RATE / 1e3);
|
|
38
|
+
b.at = t;
|
|
39
|
+
if (b.n < 1) {
|
|
40
|
+
if (!b.skipped++)
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
if (b.skipped && !b.done) note(b.skipped + " " + what + " skipped: more than " + RATE + " a second");
|
|
43
|
+
b.skipped = 0;
|
|
44
|
+
}, 1e3);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
b.n--;
|
|
48
|
+
b.used++;
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
function str(s, max) {
|
|
52
|
+
let t = s.slice(0, max + 320);
|
|
53
|
+
t = cur && cur.star ? stars(t) : scrub(t.replace(AUTHZ, stars).replace(URLS, (u) => cleanUrl(u, []) || u.split(/[?#]/)[0]));
|
|
54
|
+
return t.length > max ? t.slice(0, max - 1) + "\u2026" : t;
|
|
55
|
+
}
|
|
56
|
+
var plain = (o) => {
|
|
57
|
+
const p = Object.getPrototypeOf(o);
|
|
58
|
+
return p === Object.prototype || p === null;
|
|
59
|
+
};
|
|
60
|
+
var kind = (o) => {
|
|
61
|
+
const p = Object.getPrototypeOf(o);
|
|
62
|
+
const c = p && p.constructor && p.constructor.name;
|
|
63
|
+
return typeof c === "string" && c ? c.slice(0, 60) : "Object";
|
|
64
|
+
};
|
|
65
|
+
function text(v, room) {
|
|
66
|
+
if (typeof v === "string") return JSON.stringify(str(v, room));
|
|
67
|
+
let n = 0;
|
|
68
|
+
const seen = [];
|
|
69
|
+
const walk = (x, d) => {
|
|
70
|
+
if (++n > 100) return "\u2026";
|
|
71
|
+
if (x === null || typeof x === "boolean") return x;
|
|
72
|
+
switch (typeof x) {
|
|
73
|
+
case "string":
|
|
74
|
+
return str(x, 300);
|
|
75
|
+
case "number":
|
|
76
|
+
return isFinite(x) ? x : String(x);
|
|
77
|
+
case "undefined":
|
|
78
|
+
return "undefined";
|
|
79
|
+
case "bigint":
|
|
80
|
+
return x + "n";
|
|
81
|
+
case "symbol":
|
|
82
|
+
return String(x);
|
|
83
|
+
case "function":
|
|
84
|
+
return "\u0192 " + (x.name ? str(x.name, 60) : "anonymous");
|
|
85
|
+
}
|
|
86
|
+
const o = x;
|
|
87
|
+
if (o instanceof Error) return str(o.name + ": " + o.message, 300);
|
|
88
|
+
if (o instanceof Date) return isNaN(o.getTime()) ? "Invalid Date" : o.toISOString();
|
|
89
|
+
if (o instanceof RegExp) return String(o);
|
|
90
|
+
if (typeof Node !== "undefined" && o instanceof Node) return "<" + o.nodeName.toLowerCase() + ">";
|
|
91
|
+
if (o === window) return "[Window]";
|
|
92
|
+
if (seen.indexOf(o) >= 0) return "[Circular]";
|
|
93
|
+
if (o instanceof Map || o instanceof Set) return (o instanceof Map ? "Map(" : "Set(") + o.size + ")";
|
|
94
|
+
if (ArrayBuffer.isView(o)) return kind(o) + "(" + (o.length ?? o.byteLength) + ")";
|
|
95
|
+
if (!Array.isArray(o) && !plain(o)) return "[" + kind(o) + "]";
|
|
96
|
+
if (d > 2) return Array.isArray(o) ? "[Array(" + o.length + ")]" : "[Object]";
|
|
97
|
+
seen.push(o);
|
|
98
|
+
let r;
|
|
99
|
+
if (Array.isArray(o)) {
|
|
100
|
+
const a = o.slice(0, 20).map((y) => walk(y, d + 1));
|
|
101
|
+
if (o.length > 20) a.push("\u2026 " + (o.length - 20) + " more");
|
|
102
|
+
r = a;
|
|
103
|
+
} else {
|
|
104
|
+
const out = {};
|
|
105
|
+
const ks = Object.keys(o);
|
|
106
|
+
for (const k of ks.slice(0, 20)) {
|
|
107
|
+
if (k === "__proto__") continue;
|
|
108
|
+
let y;
|
|
109
|
+
try {
|
|
110
|
+
y = o[k];
|
|
111
|
+
} catch (e) {
|
|
112
|
+
y = "[unreadable]";
|
|
113
|
+
}
|
|
114
|
+
out[str(k, 100)] = SECRET.test(k) && y !== null && y !== void 0 && y !== "" ? "********" : walk(y, d + 1);
|
|
115
|
+
}
|
|
116
|
+
if (ks.length > 20) out["\u2026"] = ks.length - 20 + " more keys";
|
|
117
|
+
r = out;
|
|
118
|
+
}
|
|
119
|
+
seen.pop();
|
|
120
|
+
return r;
|
|
121
|
+
};
|
|
122
|
+
try {
|
|
123
|
+
const j = JSON.stringify(walk(v, 0));
|
|
124
|
+
return j === void 0 ? String(v) : j;
|
|
125
|
+
} catch (e) {
|
|
126
|
+
return '"[unreadable]"';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function frames(stack) {
|
|
130
|
+
const out = [];
|
|
131
|
+
if (typeof stack !== "string") return out;
|
|
132
|
+
for (const l of stack.slice(0, 8e3).split("\n")) {
|
|
133
|
+
const f = l.trim();
|
|
134
|
+
if (f.indexOf("at ") !== 0 && !/@[^@]*:\d+(?::\d+)?$/.test(f)) continue;
|
|
135
|
+
const s = scrub(f.slice(0, 620).replace(/[?#][^\s:)]*/g, "").replace(URLS, (u) => cleanUrl(u, []) || u));
|
|
136
|
+
out.push(s.length > 300 ? s.slice(0, 299) + "\u2026" : s);
|
|
137
|
+
if (out.length >= 10) break;
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
function line(level, args, trace, lead) {
|
|
142
|
+
const a = cur;
|
|
143
|
+
if (!a || !a.console || busy) return;
|
|
144
|
+
const first = args[0];
|
|
145
|
+
if (typeof first === "string" && first.indexOf("[ionblink]") === 0) return;
|
|
146
|
+
busy = true;
|
|
147
|
+
try {
|
|
148
|
+
if (!take(con, MAX_LINES, "console lines")) return;
|
|
149
|
+
const out = lead ? [JSON.stringify(lead)] : [];
|
|
150
|
+
let room = LINE - (lead ? lead.length + 2 : 0);
|
|
151
|
+
let tr = trace ? trace() : [];
|
|
152
|
+
for (let i = 0; i < args.length && room > 0; i++) {
|
|
153
|
+
const v = args[i];
|
|
154
|
+
if (v instanceof Error && !tr.length) tr = frames(v.stack);
|
|
155
|
+
let s = text(v, room);
|
|
156
|
+
if (s.length > room) s = s.slice(0, Math.max(0, room - 1)) + "\u2026";
|
|
157
|
+
room -= s.length;
|
|
158
|
+
out.push(s);
|
|
159
|
+
}
|
|
160
|
+
con.chars += LINE - room;
|
|
161
|
+
a.push(plugin(CONSOLE_PLUGIN, { level, trace: tr, payload: out }));
|
|
162
|
+
} catch (e) {
|
|
163
|
+
a.report("inspect.console", e);
|
|
164
|
+
} finally {
|
|
165
|
+
busy = false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function wrapConsole() {
|
|
169
|
+
const c = console;
|
|
170
|
+
for (const l of LEVELS) {
|
|
171
|
+
const orig = c[l];
|
|
172
|
+
if (typeof orig !== "function") continue;
|
|
173
|
+
c[l] = function(...a) {
|
|
174
|
+
line(l, a);
|
|
175
|
+
return orig.apply(this, a);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
addEventListener("error", (e) => {
|
|
179
|
+
const err = e.error;
|
|
180
|
+
if (err instanceof Error) line("error", [err.name + ": " + err.message], () => frames(err.stack), "Uncaught");
|
|
181
|
+
else line("error", [e.message || "Script error"], () => e.filename ? frames("at " + e.filename + ":" + e.lineno + ":" + e.colno) : [], "Uncaught");
|
|
182
|
+
});
|
|
183
|
+
addEventListener("unhandledrejection", (e) => {
|
|
184
|
+
const r = e.reason;
|
|
185
|
+
if (r instanceof Error) line("error", [r.name + ": " + r.message], () => frames(r.stack), "Uncaught (in promise)");
|
|
186
|
+
else line("error", [r], void 0, "Uncaught (in promise)");
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
var open = [];
|
|
190
|
+
var abs = (u) => {
|
|
191
|
+
try {
|
|
192
|
+
return new URL(String(u), location.href);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var own = (u) => /^(api|cdn)\.ionblink\.com$/.test(u.hostname) || /\/v1\/batch$/.test(u.pathname) && u.searchParams.has("k") && u.searchParams.has("lane") || /\/v1\/config\/ib_pk_[^/]*$/.test(u.pathname);
|
|
198
|
+
var ms = (n) => Math.max(0, Math.round(n));
|
|
199
|
+
var origin = () => performance.timeOrigin || Date.now() - performance.now();
|
|
200
|
+
function cleanUrl(href, keep) {
|
|
201
|
+
let u;
|
|
202
|
+
try {
|
|
203
|
+
u = new URL(href);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
return "";
|
|
206
|
+
}
|
|
207
|
+
if (u.protocol !== "http:" && u.protocol !== "https:") return u.protocol;
|
|
208
|
+
let q = "";
|
|
209
|
+
if (keep.length)
|
|
210
|
+
u.searchParams.forEach((v, k) => {
|
|
211
|
+
if (keep.indexOf(k) >= 0) q += (q ? "&" : "?") + encodeURIComponent(k) + "=" + encodeURIComponent(scrub(v.slice(0, 520)).slice(0, 200));
|
|
212
|
+
});
|
|
213
|
+
return (u.origin + seg(u.pathname)).slice(0, 1e3) + q;
|
|
214
|
+
}
|
|
215
|
+
function fill(q, pe) {
|
|
216
|
+
if (typeof pe.transferSize === "number") q.transferSize = pe.transferSize;
|
|
217
|
+
if (typeof pe.encodedBodySize === "number") q.encodedBodySize = pe.encodedBodySize;
|
|
218
|
+
if (!(pe.responseStart > 0)) return;
|
|
219
|
+
const t = {};
|
|
220
|
+
let any = false;
|
|
221
|
+
const put = (k, v) => {
|
|
222
|
+
if (ms(v) > 0) any = !!(t[k] = ms(v));
|
|
223
|
+
};
|
|
224
|
+
put("dns", pe.domainLookupEnd - pe.domainLookupStart);
|
|
225
|
+
put("connect", pe.connectEnd - pe.connectStart);
|
|
226
|
+
if (pe.secureConnectionStart > 0) put("tls", pe.connectEnd - pe.secureConnectionStart);
|
|
227
|
+
put("wait", pe.responseStart - (pe.requestStart || pe.startTime));
|
|
228
|
+
put("download", pe.responseEnd - pe.responseStart);
|
|
229
|
+
if (any) q.timing = t;
|
|
230
|
+
}
|
|
231
|
+
function begin(u, m, type) {
|
|
232
|
+
if (!cur || !cur.network) return null;
|
|
233
|
+
const p = abs(u);
|
|
234
|
+
if (!p || own(p)) return null;
|
|
235
|
+
const r = { url: p.href, method: (typeof m === "string" && m ? m : "GET").toUpperCase().slice(0, 12), type, t0: performance.now() };
|
|
236
|
+
open.push(r);
|
|
237
|
+
if (open.length > 200) open.shift();
|
|
238
|
+
return r;
|
|
239
|
+
}
|
|
240
|
+
function end(r, status, error) {
|
|
241
|
+
r.t1 = performance.now();
|
|
242
|
+
r.status = status;
|
|
243
|
+
if (error) r.error = error;
|
|
244
|
+
if (r.pe) send(r);
|
|
245
|
+
else r.timer = setTimeout(() => send(r), WAIT_MS);
|
|
246
|
+
}
|
|
247
|
+
function entry(pe) {
|
|
248
|
+
if (pe.initiatorType !== "fetch" && pe.initiatorType !== "xmlhttprequest") return;
|
|
249
|
+
for (const r of open)
|
|
250
|
+
if (!r.pe && r.url === pe.name && r.t0 <= pe.startTime + 20) {
|
|
251
|
+
r.pe = pe;
|
|
252
|
+
if (r.t1 !== void 0) {
|
|
253
|
+
clearTimeout(r.timer);
|
|
254
|
+
send(r);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function send(r) {
|
|
260
|
+
const i = open.indexOf(r);
|
|
261
|
+
if (i < 0) return;
|
|
262
|
+
open.splice(i, 1);
|
|
263
|
+
const a = cur;
|
|
264
|
+
if (!a || !take(net, MAX_REQS, "requests")) return;
|
|
265
|
+
const pe = r.pe;
|
|
266
|
+
const o = origin();
|
|
267
|
+
const q = {
|
|
268
|
+
url: cleanUrl(r.url, a.keep),
|
|
269
|
+
method: r.method,
|
|
270
|
+
initiatorType: r.type,
|
|
271
|
+
status: r.status,
|
|
272
|
+
startTime: ms(o + (pe ? pe.startTime : r.t0)),
|
|
273
|
+
endTime: ms(o + (pe && pe.responseEnd > 0 ? pe.responseEnd : r.t1))
|
|
274
|
+
};
|
|
275
|
+
if (r.error) q.error = r.error;
|
|
276
|
+
if (pe) fill(q, pe);
|
|
277
|
+
a.push(plugin(NETWORK_PLUGIN, { requests: [q] }));
|
|
278
|
+
}
|
|
279
|
+
var safe = (where, f) => (...a) => {
|
|
280
|
+
try {
|
|
281
|
+
f(...a);
|
|
282
|
+
} catch (e) {
|
|
283
|
+
if (cur) cur.report(where, e);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
function wrapNetwork() {
|
|
287
|
+
const w = window;
|
|
288
|
+
const F = w.fetch;
|
|
289
|
+
if (typeof F === "function")
|
|
290
|
+
w.fetch = function(input, init) {
|
|
291
|
+
let r = null;
|
|
292
|
+
safe("inspect.fetch", () => {
|
|
293
|
+
const req = typeof Request !== "undefined" && input instanceof Request ? input : null;
|
|
294
|
+
r = begin(req ? req.url : input, init && init.method || req && req.method, "fetch");
|
|
295
|
+
})();
|
|
296
|
+
const p = F.apply(this, arguments);
|
|
297
|
+
const rr = r;
|
|
298
|
+
if (!rr || !p || typeof p.then !== "function") return p;
|
|
299
|
+
return p.then(
|
|
300
|
+
(res) => {
|
|
301
|
+
safe("inspect.fetch", end)(rr, res.status);
|
|
302
|
+
return res;
|
|
303
|
+
},
|
|
304
|
+
(e) => {
|
|
305
|
+
safe("inspect.fetch", end)(rr, 0, e instanceof Error && e.name === "AbortError" ? "aborted" : "failed");
|
|
306
|
+
throw e;
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
const X = typeof XMLHttpRequest !== "undefined" ? XMLHttpRequest.prototype : null;
|
|
311
|
+
if (X) {
|
|
312
|
+
const meta = /* @__PURE__ */ new WeakMap();
|
|
313
|
+
const live = /* @__PURE__ */ new WeakMap();
|
|
314
|
+
const O = X.open;
|
|
315
|
+
const S = X.send;
|
|
316
|
+
X.open = function(m, u) {
|
|
317
|
+
meta.set(this, [m, u]);
|
|
318
|
+
return O.apply(this, arguments);
|
|
319
|
+
};
|
|
320
|
+
X.send = function() {
|
|
321
|
+
safe("inspect.xhr", () => {
|
|
322
|
+
const m = meta.get(this);
|
|
323
|
+
const r = m && begin(m[1], m[0], "xmlhttprequest");
|
|
324
|
+
if (!r) return;
|
|
325
|
+
const x = this;
|
|
326
|
+
const had = live.get(x);
|
|
327
|
+
if (had) {
|
|
328
|
+
had.r = r;
|
|
329
|
+
had.err = void 0;
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const l = { r };
|
|
333
|
+
live.set(x, l);
|
|
334
|
+
const on = (t, v) => x.addEventListener(t, () => l.err = v);
|
|
335
|
+
on("abort", "aborted");
|
|
336
|
+
on("error", "failed");
|
|
337
|
+
on("timeout", "timeout");
|
|
338
|
+
x.addEventListener(
|
|
339
|
+
"loadend",
|
|
340
|
+
safe("inspect.xhr", () => {
|
|
341
|
+
const q = l.r;
|
|
342
|
+
if (!q) return;
|
|
343
|
+
l.r = null;
|
|
344
|
+
end(q, x.status, x.status ? void 0 : l.err || "failed");
|
|
345
|
+
})
|
|
346
|
+
);
|
|
347
|
+
})();
|
|
348
|
+
return S.apply(this, arguments);
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (typeof PerformanceObserver !== "undefined") {
|
|
352
|
+
try {
|
|
353
|
+
new PerformanceObserver(safe("inspect.timing", (l) => {
|
|
354
|
+
for (const e of l.getEntries()) entry(e);
|
|
355
|
+
})).observe({ type: "resource" });
|
|
356
|
+
} catch (e) {
|
|
357
|
+
if (cur) cur.report("inspect.timing", e);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
var here = (u) => u ? u.origin + u.pathname + u.hash : "";
|
|
362
|
+
function sweep(a) {
|
|
363
|
+
if (swept || !a.fresh || typeof performance === "undefined" || !performance.getEntriesByType) return;
|
|
364
|
+
swept = true;
|
|
365
|
+
const nav = performance.getEntriesByType("navigation")[0];
|
|
366
|
+
if (!nav || here(abs(nav.name)) !== here(abs(location.href))) return;
|
|
367
|
+
const o = origin();
|
|
368
|
+
const list = [];
|
|
369
|
+
for (const e of performance.getEntriesByType("resource")) {
|
|
370
|
+
const u = e.initiatorType === "fetch" || e.initiatorType === "xmlhttprequest" ? abs(e.name) : null;
|
|
371
|
+
if (!u || own(u)) continue;
|
|
372
|
+
const q = { url: cleanUrl(e.name, a.keep), initiatorType: e.initiatorType, startTime: ms(o + e.startTime), endTime: ms(o + e.responseEnd), isInitial: true };
|
|
373
|
+
const st = e.responseStatus;
|
|
374
|
+
if (typeof st === "number" && st > 0) q.status = st;
|
|
375
|
+
fill(q, e);
|
|
376
|
+
list.push(q);
|
|
377
|
+
}
|
|
378
|
+
const keep = list.slice(-50).filter(() => take(net, MAX_REQS, "requests"));
|
|
379
|
+
if (keep.length) a.push(plugin(NETWORK_PLUGIN, { requests: keep }));
|
|
380
|
+
}
|
|
381
|
+
function start(a) {
|
|
382
|
+
cur = a;
|
|
383
|
+
scrub = a.scrub;
|
|
384
|
+
seg = a.seg;
|
|
385
|
+
if (a.console && !(wrapped & 1)) {
|
|
386
|
+
wrapped |= 1;
|
|
387
|
+
wrapConsole();
|
|
388
|
+
}
|
|
389
|
+
if (a.network) {
|
|
390
|
+
if (!(wrapped & 2)) {
|
|
391
|
+
wrapped |= 2;
|
|
392
|
+
wrapNetwork();
|
|
393
|
+
}
|
|
394
|
+
safe("inspect.sweep", sweep)(a);
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
stop: safe("inspect.stop", () => {
|
|
398
|
+
if (cur !== a) return;
|
|
399
|
+
for (const r of open.slice())
|
|
400
|
+
if (r.t1 !== void 0) {
|
|
401
|
+
clearTimeout(r.timer);
|
|
402
|
+
send(r);
|
|
403
|
+
}
|
|
404
|
+
open = [];
|
|
405
|
+
cur = null;
|
|
406
|
+
})
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function resetForTests() {
|
|
410
|
+
cur = null;
|
|
411
|
+
open = [];
|
|
412
|
+
swept = false;
|
|
413
|
+
busy = false;
|
|
414
|
+
Object.assign(con, bucket());
|
|
415
|
+
Object.assign(net, bucket());
|
|
416
|
+
}
|
|
417
|
+
export {
|
|
418
|
+
BURST,
|
|
419
|
+
LINE,
|
|
420
|
+
MAX_CHARS,
|
|
421
|
+
MAX_LINES,
|
|
422
|
+
MAX_REQS,
|
|
423
|
+
RATE,
|
|
424
|
+
cleanUrl,
|
|
425
|
+
frames,
|
|
426
|
+
line,
|
|
427
|
+
resetForTests,
|
|
428
|
+
start,
|
|
429
|
+
str,
|
|
430
|
+
text
|
|
431
|
+
};
|