@stripchatdev/ext-helper 0.1.17 → 0.1.18
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/dist/ext-helper.js +37 -32
- package/package.json +1 -1
package/dist/ext-helper.js
CHANGED
|
@@ -219,7 +219,7 @@ class X {
|
|
|
219
219
|
}
|
|
220
220
|
class W {
|
|
221
221
|
constructor(t) {
|
|
222
|
-
this.peers = /* @__PURE__ */ new Map(), this.onMessage = (n) => {
|
|
222
|
+
this.peers = /* @__PURE__ */ new Map(), this.handlers = /* @__PURE__ */ new Set(), this.onMessage = (n) => {
|
|
223
223
|
const s = (o) => {
|
|
224
224
|
const { data: i, origin: a, source: c } = o;
|
|
225
225
|
if (!c)
|
|
@@ -232,13 +232,18 @@ class W {
|
|
|
232
232
|
console.error("[PostMessageTransport] onMessage: failed to call cb on message", m);
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
|
-
return this.localWindow.addEventListener("message", s), () => {
|
|
236
|
-
this.localWindow.removeEventListener("message", s);
|
|
235
|
+
return this.localWindow.addEventListener("message", s), this.handlers.add(s), () => {
|
|
236
|
+
this.localWindow.removeEventListener("message", s), this.handlers.delete(s);
|
|
237
237
|
};
|
|
238
238
|
};
|
|
239
239
|
const { localWindow: r } = t;
|
|
240
240
|
this.localWindow = r || window;
|
|
241
241
|
}
|
|
242
|
+
destroy() {
|
|
243
|
+
this.handlers.forEach((t) => {
|
|
244
|
+
this.localWindow.removeEventListener("message", t);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
242
247
|
send(t, r) {
|
|
243
248
|
const n = this.peers.get(t);
|
|
244
249
|
n && n.source.postMessage(r, n.origin);
|
|
@@ -360,75 +365,75 @@ const p = {
|
|
|
360
365
|
try {
|
|
361
366
|
const o = new Error("synthetic error"), i = await t(n, s), a = i.clone(), c = Y(n, s, a);
|
|
362
367
|
if (i.status >= 500) {
|
|
363
|
-
const
|
|
364
|
-
|
|
368
|
+
const d = new Error("fetch response error");
|
|
369
|
+
d.stack = o.stack, e.report({
|
|
365
370
|
kind: "fetchResponseError",
|
|
366
371
|
type: "network",
|
|
367
372
|
data: c,
|
|
368
|
-
error:
|
|
373
|
+
error: d
|
|
369
374
|
});
|
|
370
375
|
}
|
|
371
376
|
const {
|
|
372
377
|
arrayBuffer: h,
|
|
373
378
|
blob: m,
|
|
374
|
-
json:
|
|
379
|
+
json: N,
|
|
375
380
|
text: k
|
|
376
381
|
} = i;
|
|
377
382
|
return i.json = async function() {
|
|
378
383
|
try {
|
|
379
|
-
return await
|
|
380
|
-
} catch (
|
|
384
|
+
return await N.call(this);
|
|
385
|
+
} catch (d) {
|
|
381
386
|
throw e.report({
|
|
382
387
|
type: "network",
|
|
383
388
|
kind: "fetchParseBodyError",
|
|
384
|
-
error:
|
|
389
|
+
error: d,
|
|
385
390
|
data: {
|
|
386
391
|
parseType: "json",
|
|
387
392
|
...c
|
|
388
393
|
}
|
|
389
|
-
}),
|
|
394
|
+
}), d;
|
|
390
395
|
}
|
|
391
396
|
}, i.text = async function() {
|
|
392
397
|
try {
|
|
393
398
|
return await k.call(this);
|
|
394
|
-
} catch (
|
|
399
|
+
} catch (d) {
|
|
395
400
|
throw e.report({
|
|
396
401
|
type: "network",
|
|
397
402
|
kind: "fetchParseBodyError",
|
|
398
|
-
error:
|
|
403
|
+
error: d,
|
|
399
404
|
data: {
|
|
400
405
|
parseType: "text",
|
|
401
406
|
...c
|
|
402
407
|
}
|
|
403
|
-
}),
|
|
408
|
+
}), d;
|
|
404
409
|
}
|
|
405
410
|
}, i.blob = async function() {
|
|
406
411
|
try {
|
|
407
412
|
return await m.call(this);
|
|
408
|
-
} catch (
|
|
413
|
+
} catch (d) {
|
|
409
414
|
throw e.report({
|
|
410
415
|
type: "network",
|
|
411
416
|
kind: "fetchParseBodyError",
|
|
412
|
-
error:
|
|
417
|
+
error: d,
|
|
413
418
|
data: {
|
|
414
419
|
parseType: "blob",
|
|
415
420
|
...c
|
|
416
421
|
}
|
|
417
|
-
}),
|
|
422
|
+
}), d;
|
|
418
423
|
}
|
|
419
424
|
}, i.arrayBuffer = async function() {
|
|
420
425
|
try {
|
|
421
426
|
return await h.call(this);
|
|
422
|
-
} catch (
|
|
427
|
+
} catch (d) {
|
|
423
428
|
throw e.report({
|
|
424
429
|
type: "network",
|
|
425
430
|
kind: "fetchParseBodyError",
|
|
426
|
-
error:
|
|
431
|
+
error: d,
|
|
427
432
|
data: {
|
|
428
433
|
parseType: "arrayBuffer",
|
|
429
434
|
...c
|
|
430
435
|
}
|
|
431
|
-
}),
|
|
436
|
+
}), d;
|
|
432
437
|
}
|
|
433
438
|
}, i;
|
|
434
439
|
} catch (o) {
|
|
@@ -458,15 +463,15 @@ const p = {
|
|
|
458
463
|
}
|
|
459
464
|
});
|
|
460
465
|
});
|
|
461
|
-
},
|
|
466
|
+
}, v = Symbol("patchedXHLHttpRequest"), u = Symbol("requestInfo"), re = (e) => ({
|
|
462
467
|
statusCode: e.status,
|
|
463
|
-
...e[
|
|
464
|
-
}), ne = (e) => (e[
|
|
465
|
-
e[
|
|
466
|
-
}, oe = (e) => e[
|
|
468
|
+
...e[u]
|
|
469
|
+
}), ne = (e) => (e[u] || (e[u] = {}), e[u]), se = (e) => {
|
|
470
|
+
e[v] = !0;
|
|
471
|
+
}, oe = (e) => e[v] === !0, ie = (e) => {
|
|
467
472
|
const t = XMLHttpRequest.prototype.send, r = XMLHttpRequest.prototype.open, n = function(...o) {
|
|
468
473
|
const [i, a] = o;
|
|
469
|
-
this[
|
|
474
|
+
this[u] = {
|
|
470
475
|
method: i,
|
|
471
476
|
url: typeof a == "string" ? a : a.toString()
|
|
472
477
|
}, oe(this) || (se(this), this.addEventListener("error", () => {
|
|
@@ -474,7 +479,7 @@ const p = {
|
|
|
474
479
|
e.report({
|
|
475
480
|
type: "network",
|
|
476
481
|
kind: "xmlHttpRequestError",
|
|
477
|
-
data: this[
|
|
482
|
+
data: this[u],
|
|
478
483
|
error: c
|
|
479
484
|
});
|
|
480
485
|
}), this.addEventListener("timeout", () => {
|
|
@@ -482,7 +487,7 @@ const p = {
|
|
|
482
487
|
e.report({
|
|
483
488
|
type: "network",
|
|
484
489
|
kind: "xmlHttpRequestTimeoutError",
|
|
485
|
-
data: this[
|
|
490
|
+
data: this[u],
|
|
486
491
|
error: c
|
|
487
492
|
});
|
|
488
493
|
}), this.addEventListener("load", () => {
|
|
@@ -503,7 +508,7 @@ const p = {
|
|
|
503
508
|
type: "network",
|
|
504
509
|
kind: "xmlHttpRequestOpenError",
|
|
505
510
|
error: c,
|
|
506
|
-
data: this[
|
|
511
|
+
data: this[u]
|
|
507
512
|
}), c;
|
|
508
513
|
}
|
|
509
514
|
}, s = function(o) {
|
|
@@ -515,7 +520,7 @@ const p = {
|
|
|
515
520
|
type: "network",
|
|
516
521
|
kind: "xmlHttpRequestSendError",
|
|
517
522
|
error: i,
|
|
518
|
-
data: this[
|
|
523
|
+
data: this[u]
|
|
519
524
|
}), i;
|
|
520
525
|
}
|
|
521
526
|
};
|
|
@@ -607,7 +612,7 @@ class ce {
|
|
|
607
612
|
}), this.crashReporter.init();
|
|
608
613
|
}
|
|
609
614
|
}
|
|
610
|
-
const
|
|
615
|
+
const de = () => {
|
|
611
616
|
const e = new URL(window.location.href), t = e.searchParams.get("origin") || "", r = e.searchParams.get("theme") || "dark", n = new ce({
|
|
612
617
|
serverId: "server",
|
|
613
618
|
serverOrigin: t || window.parent.origin,
|
|
@@ -617,5 +622,5 @@ const ue = () => {
|
|
|
617
622
|
return n.bootstrap(), n;
|
|
618
623
|
};
|
|
619
624
|
export {
|
|
620
|
-
|
|
625
|
+
de as createExtHelper
|
|
621
626
|
};
|