@bravophone/webphone 0.3.0 → 0.4.0
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/README.md +53 -5
- package/dist/bravophone.mjs +308 -275
- package/dist/bravophone.umd.js +39 -20
- package/host/js/bravophone-route-selector.js +1 -1
- package/host/popup.js +3 -3
- package/host/shim/guest-bridge.js +23 -7
- package/package.json +2 -2
- package/types/index.d.ts +23 -2
package/dist/bravophone.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
const Z = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"',
|
|
1
|
+
const Z = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"', xe = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
2
2
|
<path class="bp-i-body" d="M15.6 12.8a11 11 0 0 1-4.4-4.4l1-1a1.6 1.6 0 0 0 .3-1.7c-.2-.7-.4-1.4-.5-2.2A1.6 1.6 0 0 0 10.4 2H7.9a1.6 1.6 0 0 0-1.6 1.8 15.8 15.8 0 0 0 2.4 6.9 15.6 15.6 0 0 0 4.8 4.8 15.8 15.8 0 0 0 6.9 2.4 1.6 1.6 0 0 0 1.7-1.6v-2.5a1.6 1.6 0 0 0-1.4-1.6c-.8-.1-1.5-.3-2.2-.5a1.6 1.6 0 0 0-1.7.4z"/>
|
|
3
3
|
<path class="bp-i-wave bp-i-wave-1" d="M14.5 6.2a4 4 0 0 1 3.3 3.3"/>
|
|
4
4
|
<path class="bp-i-wave bp-i-wave-2" d="M14.1 2.6a7.6 7.6 0 0 1 7.3 7.3"/>
|
|
5
|
-
</svg>`,
|
|
5
|
+
</svg>`, we = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
6
6
|
<path class="bp-i-bar bp-i-bar-1" d="M4 10v4"/>
|
|
7
7
|
<path class="bp-i-bar bp-i-bar-2" d="M8.7 6.5v11"/>
|
|
8
8
|
<path class="bp-i-bar bp-i-bar-3" d="M12 3.5v17"/>
|
|
9
9
|
<path class="bp-i-bar bp-i-bar-4" d="M15.3 6.5v11"/>
|
|
10
10
|
<path class="bp-i-bar bp-i-bar-5" d="M20 10v4"/>
|
|
11
|
-
</svg>`,
|
|
11
|
+
</svg>`, ye = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
12
12
|
<path class="bp-i-body" d="M4 13v-1a8 8 0 0 1 16 0v1"/>
|
|
13
13
|
<path class="bp-i-body" d="M20 14.5v2a3.5 3.5 0 0 1-3.5 3.5H13"/>
|
|
14
14
|
<rect class="bp-i-cup" x="1.6" y="12.6" width="4.4" height="6.4" rx="1.8"/>
|
|
15
15
|
<rect class="bp-i-cup" x="18" y="12.6" width="4.4" height="6.4" rx="1.8"/>
|
|
16
|
-
</svg>`,
|
|
16
|
+
</svg>`, ve = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
17
17
|
<path class="bp-i-body" d="M21 11.5a8.4 8.4 0 0 1-9 8.4 9 9 0 0 1-2.9-.5L3 21.5l1.5-4.6A8.4 8.4 0 0 1 12 3.1a8.4 8.4 0 0 1 9 8.4z"/>
|
|
18
18
|
<path class="bp-i-hand" d="M14.6 14.4a6.5 6.5 0 0 1-3.2-3.2l.7-.7a1 1 0 0 0 .2-1.1 6 6 0 0 1-.3-1.2 1 1 0 0 0-1-.8H9.6a1 1 0 0 0-1 1.1 9.6 9.6 0 0 0 4.8 7.2 1 1 0 0 0 1.4-.9v-1.2a1 1 0 0 0-.8-1z"/>
|
|
19
|
-
</svg>`,
|
|
19
|
+
</svg>`, ke = `<svg viewBox="0 0 10 16" width="10" height="16" fill="currentColor" aria-hidden="true">
|
|
20
20
|
<circle cx="2.6" cy="2.6" r="1.35"/><circle cx="7.4" cy="2.6" r="1.35"/>
|
|
21
21
|
<circle cx="2.6" cy="8" r="1.35"/><circle cx="7.4" cy="8" r="1.35"/>
|
|
22
22
|
<circle cx="2.6" cy="13.4" r="1.35"/><circle cx="7.4" cy="13.4" r="1.35"/>
|
|
23
|
-
</svg>`,
|
|
24
|
-
"phone-waves":
|
|
25
|
-
waveform:
|
|
26
|
-
headset:
|
|
27
|
-
"chat-phone":
|
|
28
|
-
}, ae = "phone-waves",
|
|
23
|
+
</svg>`, V = {
|
|
24
|
+
"phone-waves": xe,
|
|
25
|
+
waveform: we,
|
|
26
|
+
headset: ye,
|
|
27
|
+
"chat-phone": ve
|
|
28
|
+
}, ae = "phone-waves", Me = `
|
|
29
29
|
.bp-launcher-icon svg { width: 100%; height: 100%; display: block; overflow: visible; }
|
|
30
30
|
|
|
31
31
|
/* Ponto de status no canto do ícone — verde registrado, cinza sem linha. */
|
|
@@ -95,7 +95,7 @@ const Z = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-
|
|
|
95
95
|
.bp-i-wave, .bp-i-body, .bp-i-hand, .bp-i-bar { animation: none !important; }
|
|
96
96
|
.bp-launcher-icon { transition: none; }
|
|
97
97
|
}
|
|
98
|
-
`,
|
|
98
|
+
`, Le = `
|
|
99
99
|
:host { all: initial; }
|
|
100
100
|
* { box-sizing: border-box; }
|
|
101
101
|
|
|
@@ -358,25 +358,25 @@ const Z = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-
|
|
|
358
358
|
.bp-launcher[data-badge]:not([data-badge=""]) { animation: none; }
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
${
|
|
362
|
-
`, ge = "bravophone:widget:geometry",
|
|
363
|
-
function
|
|
361
|
+
${Me}
|
|
362
|
+
`, ge = "bravophone:widget:geometry", J = 28, X = 32;
|
|
363
|
+
function ze(e) {
|
|
364
364
|
try {
|
|
365
|
-
const
|
|
366
|
-
if (!
|
|
367
|
-
const
|
|
368
|
-
return
|
|
369
|
-
} catch (
|
|
365
|
+
const t = localStorage.getItem(ge);
|
|
366
|
+
if (!t) return { ...e };
|
|
367
|
+
const n = JSON.parse(t);
|
|
368
|
+
return n.dock ? { ...e, ...n, ...P(n.dock, n) } : { ...e, ...n };
|
|
369
|
+
} catch (t) {
|
|
370
370
|
return { ...e };
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
function K(e) {
|
|
374
374
|
try {
|
|
375
375
|
localStorage.setItem(ge, JSON.stringify(e));
|
|
376
|
-
} catch (
|
|
376
|
+
} catch (t) {
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function he(e) {
|
|
380
380
|
return {
|
|
381
381
|
minWidth: e.minWidth,
|
|
382
382
|
minHeight: e.minHeight,
|
|
@@ -386,208 +386,208 @@ function le(e) {
|
|
|
386
386
|
maxHeight: Math.max(e.minHeight, Math.min(e.maxHeight, window.innerHeight))
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
|
-
function
|
|
390
|
-
const
|
|
389
|
+
function U(e) {
|
|
390
|
+
const t = Math.max(0, window.innerWidth - e.width), n = Math.max(0, window.innerHeight - 40);
|
|
391
391
|
return {
|
|
392
392
|
...e,
|
|
393
|
-
x: Math.min(Math.max(0, e.x),
|
|
394
|
-
y: Math.min(Math.max(0, e.y),
|
|
393
|
+
x: Math.min(Math.max(0, e.x), t),
|
|
394
|
+
y: Math.min(Math.max(0, e.y), n)
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
|
-
function P(e,
|
|
398
|
-
const
|
|
397
|
+
function P(e, t) {
|
|
398
|
+
const n = window.innerWidth, i = window.innerHeight, r = Math.round(n / 2), d = Math.round(i / 2), u = Math.min(t.width, n);
|
|
399
399
|
switch (e) {
|
|
400
400
|
case "left":
|
|
401
|
-
return { x: 0, y: 0, width: u, height:
|
|
401
|
+
return { x: 0, y: 0, width: u, height: i };
|
|
402
402
|
case "right":
|
|
403
|
-
return { x:
|
|
403
|
+
return { x: n - u, y: 0, width: u, height: i };
|
|
404
404
|
case "left-half":
|
|
405
|
-
return { x: 0, y: 0, width: r, height:
|
|
405
|
+
return { x: 0, y: 0, width: r, height: i };
|
|
406
406
|
case "right-half":
|
|
407
|
-
return { x:
|
|
407
|
+
return { x: n - r, y: 0, width: r, height: i };
|
|
408
408
|
case "top":
|
|
409
|
-
return { x:
|
|
409
|
+
return { x: t.x, y: 0, width: u, height: d };
|
|
410
410
|
case "bottom":
|
|
411
|
-
return { x:
|
|
411
|
+
return { x: t.x, y: i - d, width: u, height: d };
|
|
412
412
|
case "top-half":
|
|
413
|
-
return { x: 0, y: 0, width:
|
|
413
|
+
return { x: 0, y: 0, width: n, height: d };
|
|
414
414
|
case "bottom-half":
|
|
415
|
-
return { x: 0, y:
|
|
415
|
+
return { x: 0, y: i - d, width: n, height: d };
|
|
416
416
|
case "max":
|
|
417
|
-
return { x: 0, y: 0, width:
|
|
417
|
+
return { x: 0, y: 0, width: n, height: i };
|
|
418
418
|
default:
|
|
419
|
-
return { x:
|
|
419
|
+
return { x: t.x, y: t.y, width: t.width, height: t.height };
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
function
|
|
423
|
-
const
|
|
424
|
-
return (f ||
|
|
422
|
+
function Se(e, t, n) {
|
|
423
|
+
const i = window.innerWidth, r = window.innerHeight, d = e <= J, u = e >= i - J, f = t <= J, a = t >= r - J;
|
|
424
|
+
return (f || a) && d ? "left-half" : (f || a) && u ? "right-half" : f ? n || "max" : a ? "bottom-half" : d ? "left" : u ? "right" : null;
|
|
425
425
|
}
|
|
426
|
-
function
|
|
427
|
-
let
|
|
428
|
-
const
|
|
429
|
-
e.style.left = `${
|
|
430
|
-
}, C = (
|
|
431
|
-
if (
|
|
432
|
-
if (!
|
|
433
|
-
|
|
426
|
+
function Ee({ root: e, handle: t, handles: n, preview: i, geometry: r, limits: d, topDock: u, onChange: f }) {
|
|
427
|
+
let a = { ...r }, g = null, p = "", c = null, l = null, x = null, k = null;
|
|
428
|
+
const y = () => {
|
|
429
|
+
e.style.left = `${a.x}px`, e.style.top = `${a.y}px`, e.style.width = `${a.width}px`, e.style.height = `${a.height}px`, e.classList.toggle("bp-docked", !!a.dock), f == null || f(a);
|
|
430
|
+
}, C = (o) => {
|
|
431
|
+
if (i) {
|
|
432
|
+
if (!o) {
|
|
433
|
+
i.hidden = !0;
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
436
|
-
|
|
436
|
+
i.hidden = !1, i.style.left = `${o.x}px`, i.style.top = `${o.y}px`, i.style.width = `${o.width}px`, i.style.height = `${o.height}px`;
|
|
437
437
|
}
|
|
438
|
-
},
|
|
439
|
-
const h =
|
|
440
|
-
let { x:
|
|
441
|
-
p.includes("e") && (
|
|
442
|
-
},
|
|
443
|
-
if (
|
|
444
|
-
const
|
|
445
|
-
|
|
438
|
+
}, D = (o, b) => {
|
|
439
|
+
const h = he(d);
|
|
440
|
+
let { x: E, y: v, width: M, height: T } = c;
|
|
441
|
+
p.includes("e") && (M = c.width + o), p.includes("w") && (M = c.width - o), p.includes("s") && (T = c.height + b), p.includes("n") && (T = c.height - b), M = Math.min(h.maxWidth, Math.max(h.minWidth, M)), T = Math.min(h.maxHeight, Math.max(h.minHeight, T)), p.includes("w") && (E = c.x + (c.width - M)), p.includes("n") && (v = c.y + (c.height - T)), p.includes("e") && Math.abs(E + M - window.innerWidth) <= X && (M = window.innerWidth - E), p.includes("w") && Math.abs(E) <= X && (M += E, E = 0), p.includes("s") && Math.abs(v + T - window.innerHeight) <= X && (T = window.innerHeight - v), p.includes("n") && Math.abs(v) <= X && (T += v, v = 0), a = { ...a, x: E, y: v, width: M, height: T, dock: null }, y();
|
|
442
|
+
}, W = (o, b, h, E) => {
|
|
443
|
+
if (a.dock) {
|
|
444
|
+
const v = k || { width: d.width, height: d.height }, M = l.x / Math.max(1, a.width);
|
|
445
|
+
a = { ...a, ...v, dock: null }, l = { x: Math.round(v.width * M), y: Math.min(l.y, 32) }, c = {
|
|
446
446
|
...c,
|
|
447
447
|
x: h - l.x,
|
|
448
|
-
y:
|
|
449
|
-
px: c.px +
|
|
448
|
+
y: E - l.y,
|
|
449
|
+
px: c.px + o,
|
|
450
450
|
py: c.py + b
|
|
451
|
-
},
|
|
451
|
+
}, o = 0, b = 0;
|
|
452
452
|
}
|
|
453
|
-
|
|
454
|
-
},
|
|
455
|
-
x && (
|
|
456
|
-
},
|
|
457
|
-
h.button === 0 && (
|
|
458
|
-
},
|
|
453
|
+
a = U({ ...a, x: c.x + o, y: c.y + b }), y(), x = Se(h, E, u), C(x ? P(x, a) : null);
|
|
454
|
+
}, j = () => {
|
|
455
|
+
x && (k = k || { width: a.width, height: a.height }, a = { ...a, ...P(x, a), dock: x }, y());
|
|
456
|
+
}, _ = (o, b) => (h) => {
|
|
457
|
+
h.button === 0 && (o === "drag" && h.target.closest(".bp-btn") || (g = o, p = b || "", c = { px: h.clientX, py: h.clientY, ...a }, l = { x: h.clientX - a.x, y: h.clientY - a.y }, a.dock || (k = { width: a.width, height: a.height }), e.classList.add(o === "drag" ? "bp-dragging" : "bp-resizing"), h.currentTarget.setPointerCapture(h.pointerId), h.preventDefault()));
|
|
458
|
+
}, F = (o) => {
|
|
459
459
|
if (!g || !c) return;
|
|
460
|
-
const b =
|
|
461
|
-
g === "drag" ?
|
|
462
|
-
},
|
|
460
|
+
const b = o.clientX - c.px, h = o.clientY - c.py;
|
|
461
|
+
g === "drag" ? W(b, h, o.clientX, o.clientY) : D(b, h);
|
|
462
|
+
}, A = (o) => {
|
|
463
463
|
if (g) {
|
|
464
|
-
e.classList.remove("bp-dragging", "bp-resizing"), C(null), g === "drag" &&
|
|
464
|
+
e.classList.remove("bp-dragging", "bp-resizing"), C(null), g === "drag" && j(), g = null, p = "", c = null, x = null;
|
|
465
465
|
try {
|
|
466
|
-
|
|
466
|
+
o.currentTarget.releasePointerCapture(o.pointerId);
|
|
467
467
|
} catch (b) {
|
|
468
468
|
}
|
|
469
|
-
K(
|
|
469
|
+
K(a);
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
|
-
|
|
473
|
-
|
|
472
|
+
t.addEventListener("pointerdown", _("drag")), t.addEventListener("pointermove", F), t.addEventListener("pointerup", A), t.addEventListener("pointercancel", A), (n || []).forEach(({ el: o, dir: b }) => {
|
|
473
|
+
o.addEventListener("pointerdown", _("resize", b)), o.addEventListener("pointermove", F), o.addEventListener("pointerup", A), o.addEventListener("pointercancel", A);
|
|
474
474
|
});
|
|
475
|
-
const
|
|
476
|
-
|
|
475
|
+
const B = () => {
|
|
476
|
+
a = a.dock ? { ...a, ...P(a.dock, a) } : U(a), y();
|
|
477
477
|
};
|
|
478
|
-
window.addEventListener("resize",
|
|
478
|
+
window.addEventListener("resize", B);
|
|
479
479
|
const G = {
|
|
480
|
-
start(
|
|
480
|
+
start(o) {
|
|
481
481
|
var b, h;
|
|
482
|
-
g = "drag", c = { px:
|
|
482
|
+
g = "drag", c = { px: o.x, py: o.y, ...a }, l = { x: (b = o.cx) != null ? b : a.width / 2, y: (h = o.cy) != null ? h : 20 }, a.dock || (k = { width: a.width, height: a.height }), e.classList.add("bp-dragging");
|
|
483
483
|
},
|
|
484
|
-
move(
|
|
484
|
+
move(o) {
|
|
485
485
|
if (g !== "drag" || !c) return;
|
|
486
|
-
const b =
|
|
487
|
-
|
|
486
|
+
const b = o.x - c.px, h = o.y - c.py;
|
|
487
|
+
W(b, h, c.x + b + l.x, c.y + h + l.y);
|
|
488
488
|
},
|
|
489
489
|
end() {
|
|
490
|
-
g === "drag" && (e.classList.remove("bp-dragging"), C(null),
|
|
490
|
+
g === "drag" && (e.classList.remove("bp-dragging"), C(null), j(), g = null, c = null, x = null, K(a));
|
|
491
491
|
}
|
|
492
492
|
};
|
|
493
|
-
return
|
|
493
|
+
return y(), {
|
|
494
494
|
external: G,
|
|
495
495
|
get geometry() {
|
|
496
|
-
return { ...
|
|
496
|
+
return { ...a };
|
|
497
497
|
},
|
|
498
|
-
set(
|
|
499
|
-
const b =
|
|
500
|
-
h.width = Math.min(b.maxWidth, Math.max(b.minWidth, h.width)), h.height = Math.min(b.maxHeight, Math.max(b.minHeight, h.height)),
|
|
498
|
+
set(o) {
|
|
499
|
+
const b = he(d), h = { ...a, ...o, dock: null };
|
|
500
|
+
h.width = Math.min(b.maxWidth, Math.max(b.minWidth, h.width)), h.height = Math.min(b.maxHeight, Math.max(b.minHeight, h.height)), a = U(h), y(), K(a);
|
|
501
501
|
},
|
|
502
502
|
/** 'left' | 'right' | 'left-half' | 'right-half' | 'max' | 'float' */
|
|
503
|
-
dock(
|
|
504
|
-
if (!
|
|
505
|
-
const b =
|
|
506
|
-
|
|
503
|
+
dock(o) {
|
|
504
|
+
if (!o || o === "float") {
|
|
505
|
+
const b = k || { width: d.width, height: d.height };
|
|
506
|
+
a = U({ ...a, ...b, dock: null });
|
|
507
507
|
} else
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
a.dock || (k = { width: a.width, height: a.height }), a = { ...a, ...P(o, a), dock: o };
|
|
509
|
+
y(), K(a);
|
|
510
510
|
},
|
|
511
511
|
destroy() {
|
|
512
|
-
window.removeEventListener("resize",
|
|
512
|
+
window.removeEventListener("resize", B);
|
|
513
513
|
}
|
|
514
514
|
};
|
|
515
515
|
}
|
|
516
516
|
const be = "bravophone/v1";
|
|
517
|
-
function
|
|
518
|
-
const
|
|
517
|
+
function Te({ frame: e, origin: t, onEvent: n }) {
|
|
518
|
+
const i = /* @__PURE__ */ new Map();
|
|
519
519
|
let r = 0, d = !1;
|
|
520
520
|
const u = [], f = (g) => {
|
|
521
521
|
var c;
|
|
522
|
-
if (g.origin !==
|
|
522
|
+
if (g.origin !== t || g.source !== e.contentWindow) return;
|
|
523
523
|
const p = g.data;
|
|
524
524
|
if (!(!p || p.protocol !== be)) {
|
|
525
525
|
if (p.type === "ready") {
|
|
526
526
|
for (d = !0; u.length; ) u.shift()();
|
|
527
|
-
|
|
527
|
+
n == null || n("ready", (c = p.payload) != null ? c : {});
|
|
528
528
|
return;
|
|
529
529
|
}
|
|
530
530
|
if (p.type === "reply") {
|
|
531
|
-
const l =
|
|
531
|
+
const l = i.get(p.id);
|
|
532
532
|
if (!l) return;
|
|
533
|
-
|
|
533
|
+
i.delete(p.id), clearTimeout(l.timer), p.error ? l.reject(new Error(p.error)) : l.resolve(p.payload);
|
|
534
534
|
return;
|
|
535
535
|
}
|
|
536
|
-
p.type === "event" && (
|
|
536
|
+
p.type === "event" && (n == null || n(p.name, p.payload));
|
|
537
537
|
}
|
|
538
538
|
};
|
|
539
539
|
window.addEventListener("message", f);
|
|
540
|
-
function
|
|
540
|
+
function a(g, p, { timeout: c = 15e3 } = {}) {
|
|
541
541
|
return new Promise((l, x) => {
|
|
542
|
-
const
|
|
543
|
-
var
|
|
542
|
+
const k = `${Date.now()}-${++r}`, y = () => {
|
|
543
|
+
var D;
|
|
544
544
|
const C = setTimeout(() => {
|
|
545
|
-
|
|
545
|
+
i.delete(k), x(new Error(`Bravophone: timeout no comando "${g}"`));
|
|
546
546
|
}, c);
|
|
547
|
-
|
|
548
|
-
{ protocol: be, type: "command", id:
|
|
549
|
-
|
|
547
|
+
i.set(k, { resolve: l, reject: x, timer: C }), (D = e.contentWindow) == null || D.postMessage(
|
|
548
|
+
{ protocol: be, type: "command", id: k, command: g, payload: p },
|
|
549
|
+
t
|
|
550
550
|
);
|
|
551
551
|
};
|
|
552
|
-
d ?
|
|
552
|
+
d ? y() : u.push(y);
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
555
|
return {
|
|
556
|
-
call:
|
|
556
|
+
call: a,
|
|
557
557
|
get ready() {
|
|
558
558
|
return d;
|
|
559
559
|
},
|
|
560
560
|
destroy() {
|
|
561
|
-
window.removeEventListener("message", f),
|
|
561
|
+
window.removeEventListener("message", f), i.forEach(({ reject: g, timer: p }) => {
|
|
562
562
|
clearTimeout(p), g(new Error("Bravophone: widget destruído"));
|
|
563
|
-
}),
|
|
563
|
+
}), i.clear();
|
|
564
564
|
}
|
|
565
565
|
};
|
|
566
566
|
}
|
|
567
|
-
const me = "bravophone:launcher", He = 4,
|
|
568
|
-
function
|
|
567
|
+
const me = "bravophone:launcher", He = 4, ne = 8;
|
|
568
|
+
function Ie(e) {
|
|
569
569
|
try {
|
|
570
|
-
const
|
|
571
|
-
return
|
|
572
|
-
} catch (
|
|
570
|
+
const t = localStorage.getItem(me);
|
|
571
|
+
return t ? { ...e, ...JSON.parse(t) } : { ...e };
|
|
572
|
+
} catch (t) {
|
|
573
573
|
return { ...e };
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function re(e) {
|
|
577
577
|
try {
|
|
578
578
|
localStorage.setItem(me, JSON.stringify(e));
|
|
579
|
-
} catch (
|
|
579
|
+
} catch (t) {
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
function q(e,
|
|
583
|
-
const
|
|
584
|
-
return Math.min(Math.max(
|
|
582
|
+
function q(e, t) {
|
|
583
|
+
const n = Math.max(ne, window.innerHeight - t - ne);
|
|
584
|
+
return Math.min(Math.max(ne, e), n);
|
|
585
585
|
}
|
|
586
|
-
function $e({ el: e, side:
|
|
587
|
-
let r = { side:
|
|
586
|
+
function $e({ el: e, side: t, y: n, onOpen: i }) {
|
|
587
|
+
let r = { side: t, y: q(n, e.offsetHeight || 48) }, d = null, u = !1;
|
|
588
588
|
const f = () => {
|
|
589
589
|
e.dataset.side = r.side, e.style.top = `${r.y}px`, e.style.right = r.side === "right" ? "0px" : "auto", e.style.left = r.side === "left" ? "0px" : "auto";
|
|
590
|
-
},
|
|
590
|
+
}, a = (l) => {
|
|
591
591
|
l.button === 0 && (d = { py: l.clientY, y: r.y }, u = !1, e.setPointerCapture(l.pointerId));
|
|
592
592
|
}, g = (l) => {
|
|
593
593
|
if (!d) return;
|
|
@@ -599,12 +599,12 @@ function $e({ el: e, side: a, y: i, onOpen: o }) {
|
|
|
599
599
|
d = null, u = !1, e.classList.remove("bp-launcher-dragging");
|
|
600
600
|
try {
|
|
601
601
|
e.releasePointerCapture(l.pointerId);
|
|
602
|
-
} catch (
|
|
602
|
+
} catch (k) {
|
|
603
603
|
}
|
|
604
|
-
x ?
|
|
604
|
+
x ? re(r) : i == null || i();
|
|
605
605
|
};
|
|
606
|
-
e.addEventListener("pointerdown",
|
|
607
|
-
(l.key === "Enter" || l.key === " ") && (l.preventDefault(),
|
|
606
|
+
e.addEventListener("pointerdown", a), e.addEventListener("pointermove", g), e.addEventListener("pointerup", p), e.addEventListener("pointercancel", p), e.addEventListener("keydown", (l) => {
|
|
607
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), i == null || i());
|
|
608
608
|
});
|
|
609
609
|
const c = () => {
|
|
610
610
|
r.y = q(r.y, e.offsetHeight), f();
|
|
@@ -614,22 +614,22 @@ function $e({ el: e, side: a, y: i, onOpen: o }) {
|
|
|
614
614
|
return { ...r };
|
|
615
615
|
},
|
|
616
616
|
setSide(l) {
|
|
617
|
-
r.side = l, f(),
|
|
617
|
+
r.side = l, f(), re(r);
|
|
618
618
|
},
|
|
619
619
|
moveTo(l) {
|
|
620
|
-
r.y = q(l, e.offsetHeight), f(),
|
|
620
|
+
r.y = q(l, e.offsetHeight), f(), re(r);
|
|
621
621
|
},
|
|
622
622
|
destroy() {
|
|
623
623
|
window.removeEventListener("resize", c);
|
|
624
624
|
}
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
|
-
const
|
|
628
|
-
function
|
|
629
|
-
return `${
|
|
627
|
+
const Oe = "https://cdn.jsdelivr.net/npm";
|
|
628
|
+
function Ce(e, t = "@bravophone/webphone") {
|
|
629
|
+
return `${Oe}/${t}@${e}/host/`;
|
|
630
630
|
}
|
|
631
|
-
function We({ version: e, parentOrigin:
|
|
632
|
-
const r =
|
|
631
|
+
function We({ version: e, parentOrigin: t, session: n, base: i }) {
|
|
632
|
+
const r = i || Ce(e), d = JSON.stringify({ parentOrigin: t, session: n || null }).replace(/</g, "\\u003c");
|
|
633
633
|
return `<!doctype html>
|
|
634
634
|
<html lang="pt-BR">
|
|
635
635
|
<head>
|
|
@@ -654,10 +654,29 @@ function We({ version: e, parentOrigin: a, token: i, base: o }) {
|
|
|
654
654
|
// O guest-bridge lê daqui: em srcdoc não há query string para carregar a
|
|
655
655
|
// origem do pai.
|
|
656
656
|
window.__bpParentOrigin = cfg.parentOrigin;
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
657
|
+
// Grava a sessão onde o bundle procura, ANTES dele avaliar, para já subir
|
|
658
|
+
// autenticado em vez de piscar a tela de login.
|
|
659
|
+
//
|
|
660
|
+
// As chaves e o prefixo não são escolha nossa: 'bp.local.' é como o
|
|
661
|
+
// chrome-shim mapeia chrome.storage.local, e os nomes vêm do bpSaveSession
|
|
662
|
+
// do bundle. Um token sozinho NÃO basta — sem sip e ramal o webphone não
|
|
663
|
+
// tem o que registrar, e o RouteSelector avisa "faça login pelo webphone".
|
|
664
|
+
if (cfg.session) {
|
|
665
|
+
var s = cfg.session;
|
|
666
|
+
var mapa = {
|
|
667
|
+
bravophoneVxToken: s.vxToken || null,
|
|
668
|
+
bravophoneVxTokenExpiresAt: s.expiresIn ? Date.now() + 1000 * Number(s.expiresIn) : null,
|
|
669
|
+
bravophoneSip: s.sip || null,
|
|
670
|
+
bravophoneTenant: s.tenant || null,
|
|
671
|
+
bravophoneRamal: s.ramal || null,
|
|
672
|
+
bravophoneClienteId: s.clienteId || null,
|
|
673
|
+
bravophoneRamaisUrl: s.ramaisUrl || null
|
|
674
|
+
};
|
|
675
|
+
try {
|
|
676
|
+
for (var k in mapa) {
|
|
677
|
+
if (mapa[k] !== null) localStorage.setItem('bp.local.' + k, JSON.stringify(mapa[k]));
|
|
678
|
+
}
|
|
679
|
+
} catch (e) {}
|
|
661
680
|
}
|
|
662
681
|
})();
|
|
663
682
|
<\/script>
|
|
@@ -687,85 +706,93 @@ const ue = {
|
|
|
687
706
|
maxHeight: 1400,
|
|
688
707
|
margin: 24
|
|
689
708
|
};
|
|
690
|
-
function
|
|
691
|
-
const
|
|
692
|
-
for (const [r, d] of Object.entries(
|
|
693
|
-
r === "class" ?
|
|
694
|
-
return
|
|
709
|
+
function w(e, t = {}, n = []) {
|
|
710
|
+
const i = document.createElement(e);
|
|
711
|
+
for (const [r, d] of Object.entries(t))
|
|
712
|
+
r === "class" ? i.className = d : r === "text" ? i.textContent = d : d != null && i.setAttribute(r, d);
|
|
713
|
+
return n.forEach((r) => i.appendChild(r)), i;
|
|
695
714
|
}
|
|
696
|
-
function
|
|
715
|
+
function Ae(e) {
|
|
697
716
|
const {
|
|
698
|
-
hostUrl:
|
|
699
|
-
token:
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
717
|
+
hostUrl: t,
|
|
718
|
+
token: n,
|
|
719
|
+
session: i,
|
|
720
|
+
position: r = "bottom-right",
|
|
721
|
+
open: d = !1,
|
|
722
|
+
launcher: u = !0,
|
|
723
|
+
title: f = "BRAVOPHONE",
|
|
704
724
|
// 'bar' por padrão: título, indicador de estado e controles visíveis.
|
|
705
725
|
// 'none' preserva 100% da UI do webphone — sem barra, o arraste vem de
|
|
706
726
|
// dentro do iframe e só um botão de fechar aparece no hover.
|
|
707
|
-
frame:
|
|
727
|
+
frame: a = "bar",
|
|
708
728
|
// O que arrastar até a borda de cima faz. 'max' é o gesto universal;
|
|
709
729
|
// troque para 'top-half' se preferir as metades verticais no topo.
|
|
710
|
-
dockTop:
|
|
730
|
+
dockTop: g = "max",
|
|
711
731
|
// Lado da viewport em que a aba de abertura fica colada.
|
|
712
|
-
launcherSide:
|
|
732
|
+
launcherSide: p = "right",
|
|
713
733
|
// Desenho da aba: 'phone-waves' | 'waveform' | 'headset' | 'chat-phone'
|
|
714
|
-
launcherIcon:
|
|
734
|
+
launcherIcon: c = ae,
|
|
715
735
|
// 'srcdoc' é o padrão porque é o modo que funciona sem infraestrutura
|
|
716
736
|
// nossa: o webphone vem do CDN, travado nesta versão. 'hosted' navega
|
|
717
737
|
// para hostUrl e depende de um domínio publicado — se ele não existir,
|
|
718
738
|
// o iframe falha em DNS antes de qualquer outra coisa.
|
|
719
|
-
mode:
|
|
739
|
+
mode: l = "srcdoc",
|
|
720
740
|
// Base dos assets no modo srcdoc. Padrão: o CDN travado nesta versão.
|
|
721
741
|
// Serve para desenvolvimento (localhost) e para quem espelhar os assets.
|
|
722
|
-
hostBase:
|
|
723
|
-
version:
|
|
724
|
-
emit:
|
|
725
|
-
} = e,
|
|
726
|
-
|
|
727
|
-
const j =
|
|
728
|
-
j.appendChild(
|
|
742
|
+
hostBase: x,
|
|
743
|
+
version: k,
|
|
744
|
+
emit: y
|
|
745
|
+
} = e, C = l === "srcdoc", D = C ? window.location.origin : new URL(t).origin, W = w("div", { "data-bravophone": "root" });
|
|
746
|
+
W.style.cssText = "all:initial;position:static";
|
|
747
|
+
const j = W.attachShadow({ mode: "open" });
|
|
748
|
+
j.appendChild(w("style", { text: Le }));
|
|
729
749
|
const _ = (() => {
|
|
730
|
-
var
|
|
731
|
-
const { width: s, height:
|
|
750
|
+
var le;
|
|
751
|
+
const { width: s, height: z, margin: O } = ue, N = window.innerWidth - s - O, ce = window.innerHeight - z - O, pe = {
|
|
732
752
|
"bottom-right": { x: N, y: ce },
|
|
733
|
-
"bottom-left": { x:
|
|
734
|
-
"top-right": { x: N, y:
|
|
735
|
-
"top-left": { x:
|
|
753
|
+
"bottom-left": { x: O, y: ce },
|
|
754
|
+
"top-right": { x: N, y: O },
|
|
755
|
+
"top-left": { x: O, y: O }
|
|
736
756
|
};
|
|
737
|
-
return
|
|
738
|
-
})(), F =
|
|
757
|
+
return U({ ...(le = pe[r]) != null ? le : pe["bottom-right"], width: s, height: z });
|
|
758
|
+
})(), F = U(ze(_)), A = w("span", { class: "bp-status", "data-state": "connecting" }), B = w("button", { class: "bp-btn bp-btn-min", title: "Minimizar", text: "—" }), G = w("button", { class: "bp-btn bp-btn-close", title: "Fechar", text: "×" }), o = w("div", { class: "bp-header" }, [
|
|
739
759
|
A,
|
|
740
|
-
|
|
760
|
+
w("span", { class: "bp-title", text: f }),
|
|
741
761
|
B,
|
|
742
|
-
|
|
743
|
-
]),
|
|
762
|
+
G
|
|
763
|
+
]), b = w("iframe", {
|
|
744
764
|
class: "bp-frame",
|
|
745
765
|
// allow= é obrigatório no modo hospedado (cross-origin). Em srcdoc o
|
|
746
766
|
// microfone já é herdado do topo, mas declarar não custa e documenta.
|
|
747
767
|
allow: "microphone; autoplay; clipboard-write; speaker-selection",
|
|
748
768
|
title: "Webphone BRAVOPHONE"
|
|
749
769
|
});
|
|
750
|
-
|
|
770
|
+
C ? b.setAttribute(
|
|
751
771
|
"srcdoc",
|
|
752
|
-
We({
|
|
753
|
-
|
|
772
|
+
We({
|
|
773
|
+
version: k,
|
|
774
|
+
parentOrigin: D,
|
|
775
|
+
base: x,
|
|
776
|
+
// token sozinho vira uma sessão mínima; sem sip/ramal o webphone
|
|
777
|
+
// carrega mas não registra.
|
|
778
|
+
session: i || (n ? { vxToken: n } : null)
|
|
779
|
+
})
|
|
780
|
+
) : b.setAttribute(
|
|
754
781
|
"src",
|
|
755
|
-
|
|
782
|
+
De(new URL(t), { token: n, embed: "1", parent: location.origin })
|
|
756
783
|
);
|
|
757
|
-
const
|
|
758
|
-
el:
|
|
784
|
+
const E = ["n", "s", "w", "e", "nw", "ne", "sw", "se"].map((s) => ({
|
|
785
|
+
el: w("div", { class: `bp-h bp-h-${s}` }),
|
|
759
786
|
dir: s
|
|
760
|
-
})), v =
|
|
787
|
+
})), v = w("div", { class: "bp-preview" });
|
|
761
788
|
v.hidden = !0;
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
const Q =
|
|
765
|
-
Q.innerHTML =
|
|
766
|
-
const oe =
|
|
767
|
-
oe.innerHTML =
|
|
768
|
-
const
|
|
789
|
+
const M = w("button", { class: "bp-btn bp-btn-close", title: "Fechar", text: "×" }), T = w("div", { class: "bp-overlay" }, [M]), fe = w("div", { class: "bp-body" }, [b, T]), L = w("div", { class: "bp-root" }, [o, fe, ...E.map((s) => s.el)]);
|
|
790
|
+
a !== "bar" && L.classList.add("bp-chromeless"), L.hidden = !d;
|
|
791
|
+
const Q = w("span", { class: "bp-launcher-icon" });
|
|
792
|
+
Q.innerHTML = V[c] || V[ae];
|
|
793
|
+
const oe = w("span", { class: "bp-launcher-grip", "aria-hidden": "true" });
|
|
794
|
+
oe.innerHTML = ke;
|
|
795
|
+
const H = w("div", {
|
|
769
796
|
class: "bp-launcher",
|
|
770
797
|
role: "button",
|
|
771
798
|
tabindex: "0",
|
|
@@ -774,65 +801,65 @@ function Ce(e) {
|
|
|
774
801
|
}, [
|
|
775
802
|
oe,
|
|
776
803
|
Q,
|
|
777
|
-
|
|
804
|
+
w("span", { class: "bp-badge" })
|
|
778
805
|
]);
|
|
779
|
-
|
|
780
|
-
const se =
|
|
781
|
-
side:
|
|
806
|
+
H.dataset.state = "connecting", H.hidden = !u, j.append(v, L, H), document.body.appendChild(W);
|
|
807
|
+
const se = Ie({
|
|
808
|
+
side: p,
|
|
782
809
|
y: Math.round(window.innerHeight / 2 - 24)
|
|
783
810
|
}), de = $e({
|
|
784
|
-
el:
|
|
811
|
+
el: H,
|
|
785
812
|
side: se.side,
|
|
786
813
|
y: q(se.y, 48),
|
|
787
814
|
// A aba nunca some, então o clique tem dois papéis: abrir quando fechada,
|
|
788
815
|
// e localizar quando já aberta.
|
|
789
|
-
onOpen: () =>
|
|
790
|
-
}), I =
|
|
791
|
-
root:
|
|
792
|
-
handle:
|
|
793
|
-
handles:
|
|
816
|
+
onOpen: () => $.reveal()
|
|
817
|
+
}), I = Ee({
|
|
818
|
+
root: L,
|
|
819
|
+
handle: o,
|
|
820
|
+
handles: E,
|
|
794
821
|
preview: v,
|
|
795
822
|
geometry: F,
|
|
796
823
|
limits: ue,
|
|
797
|
-
topDock:
|
|
798
|
-
onChange: (s) =>
|
|
799
|
-
}), ee =
|
|
800
|
-
frame:
|
|
801
|
-
origin:
|
|
802
|
-
onEvent: (s,
|
|
803
|
-
var
|
|
804
|
-
if (s === "ready" && (A.dataset.state = "ready",
|
|
824
|
+
topDock: g,
|
|
825
|
+
onChange: (s) => y("resize", { width: s.width, height: s.height, dock: s.dock || null })
|
|
826
|
+
}), ee = Te({
|
|
827
|
+
frame: b,
|
|
828
|
+
origin: D,
|
|
829
|
+
onEvent: (s, z) => {
|
|
830
|
+
var O;
|
|
831
|
+
if (s === "ready" && (A.dataset.state = "ready", H.dataset.state = "ready", (i || n) && ee.call("auth", { session: i || { vxToken: n } }).catch(() => {
|
|
805
832
|
})), s === "state") {
|
|
806
|
-
const N = (
|
|
807
|
-
A.dataset.state = N,
|
|
833
|
+
const N = (O = z == null ? void 0 : z.state) != null ? O : "ready";
|
|
834
|
+
A.dataset.state = N, H.dataset.state = N;
|
|
808
835
|
}
|
|
809
|
-
if (s === "call:incoming" && (
|
|
810
|
-
I.external.start(
|
|
836
|
+
if (s === "call:incoming" && ($.show(), H.dataset.badge = "1", H.dataset.state = "ringing"), s === "call:answered" && (H.dataset.state = "incall"), s === "call:ended" && (delete H.dataset.badge, H.dataset.state = "ready"), s === "drag:start") {
|
|
837
|
+
I.external.start(z);
|
|
811
838
|
return;
|
|
812
839
|
}
|
|
813
840
|
if (s === "drag:move") {
|
|
814
|
-
I.external.move(
|
|
841
|
+
I.external.move(z);
|
|
815
842
|
return;
|
|
816
843
|
}
|
|
817
844
|
if (s === "drag:end") {
|
|
818
845
|
I.external.end();
|
|
819
846
|
return;
|
|
820
847
|
}
|
|
821
|
-
|
|
848
|
+
y(s, z);
|
|
822
849
|
}
|
|
823
850
|
});
|
|
824
851
|
let Y = !1, te = null;
|
|
825
|
-
const
|
|
826
|
-
el:
|
|
852
|
+
const $ = {
|
|
853
|
+
el: W,
|
|
827
854
|
bridge: ee,
|
|
828
855
|
show() {
|
|
829
|
-
|
|
856
|
+
L.hidden = !1, y("open");
|
|
830
857
|
},
|
|
831
858
|
hide() {
|
|
832
|
-
|
|
859
|
+
L.hidden = !0, y("close");
|
|
833
860
|
},
|
|
834
861
|
toggle() {
|
|
835
|
-
|
|
862
|
+
L.hidden ? $.show() : $.hide();
|
|
836
863
|
},
|
|
837
864
|
/**
|
|
838
865
|
* Traz a janela para a atenção do usuário.
|
|
@@ -840,31 +867,31 @@ function Ce(e) {
|
|
|
840
867
|
* visível: um halo curto, para o olho encontrá-la.
|
|
841
868
|
*/
|
|
842
869
|
reveal() {
|
|
843
|
-
if (
|
|
844
|
-
|
|
870
|
+
if (L.hidden) {
|
|
871
|
+
$.show();
|
|
845
872
|
return;
|
|
846
873
|
}
|
|
847
874
|
const s = I.geometry;
|
|
848
875
|
(s.x + s.width < 40 || s.x > window.innerWidth - 40 || s.y > window.innerHeight - 40) && I.set({
|
|
849
876
|
x: Math.round((window.innerWidth - s.width) / 2),
|
|
850
877
|
y: Math.round((window.innerHeight - s.height) / 2)
|
|
851
|
-
}),
|
|
878
|
+
}), L.classList.remove("bp-attention"), L.offsetWidth, L.classList.add("bp-attention"), clearTimeout(te), te = setTimeout(() => L.classList.remove("bp-attention"), 1800), y("reveal");
|
|
852
879
|
},
|
|
853
880
|
get isOpen() {
|
|
854
|
-
return !
|
|
881
|
+
return !L.hidden;
|
|
855
882
|
},
|
|
856
883
|
minimize(s) {
|
|
857
|
-
if (
|
|
858
|
-
|
|
884
|
+
if (a !== "bar") {
|
|
885
|
+
$.hide();
|
|
859
886
|
return;
|
|
860
887
|
}
|
|
861
|
-
Y = s != null ? s : !Y,
|
|
888
|
+
Y = s != null ? s : !Y, L.classList.toggle("bp-minimized", Y), B.textContent = Y ? "▢" : "—";
|
|
862
889
|
},
|
|
863
|
-
move(s,
|
|
864
|
-
I.set({ x: s, y:
|
|
890
|
+
move(s, z) {
|
|
891
|
+
I.set({ x: s, y: z });
|
|
865
892
|
},
|
|
866
|
-
resize(s,
|
|
867
|
-
I.set({ width: s, height:
|
|
893
|
+
resize(s, z) {
|
|
894
|
+
I.set({ width: s, height: z });
|
|
868
895
|
},
|
|
869
896
|
dock(s) {
|
|
870
897
|
I.dock(s);
|
|
@@ -873,52 +900,56 @@ function Ce(e) {
|
|
|
873
900
|
de.setSide(s);
|
|
874
901
|
},
|
|
875
902
|
setLauncherIcon(s) {
|
|
876
|
-
Q.innerHTML =
|
|
903
|
+
Q.innerHTML = V[s] || V[ae];
|
|
877
904
|
},
|
|
878
905
|
get geometry() {
|
|
879
906
|
return I.geometry;
|
|
880
907
|
},
|
|
881
908
|
destroy() {
|
|
882
|
-
clearTimeout(te), ee.destroy(), I.destroy(), de.destroy(), v.remove(),
|
|
909
|
+
clearTimeout(te), ee.destroy(), I.destroy(), de.destroy(), v.remove(), W.remove();
|
|
883
910
|
}
|
|
884
911
|
};
|
|
885
|
-
return
|
|
912
|
+
return G.addEventListener("click", () => $.hide()), B.addEventListener("click", () => $.minimize()), M.addEventListener("click", () => $.hide()), $;
|
|
886
913
|
}
|
|
887
|
-
function
|
|
888
|
-
const
|
|
889
|
-
for (const [
|
|
890
|
-
r != null && r !== "" &&
|
|
891
|
-
return
|
|
914
|
+
function De(e, t) {
|
|
915
|
+
const n = new URL(e.href);
|
|
916
|
+
for (const [i, r] of Object.entries(t))
|
|
917
|
+
r != null && r !== "" && n.searchParams.set(i, r);
|
|
918
|
+
return t.token && (n.searchParams.delete("token"), n.hash = `token=${encodeURIComponent(t.token)}`), n.href;
|
|
892
919
|
}
|
|
893
|
-
const
|
|
894
|
-
let
|
|
895
|
-
const
|
|
896
|
-
function
|
|
897
|
-
var
|
|
898
|
-
(
|
|
920
|
+
const Re = "";
|
|
921
|
+
let S = null;
|
|
922
|
+
const R = /* @__PURE__ */ new Map();
|
|
923
|
+
function Be(e, t) {
|
|
924
|
+
var n, i;
|
|
925
|
+
(n = R.get(e)) == null || n.forEach((r) => {
|
|
899
926
|
try {
|
|
900
|
-
r(
|
|
927
|
+
r(t);
|
|
901
928
|
} catch (d) {
|
|
902
929
|
console.error("[Bravophone] listener falhou:", d);
|
|
903
930
|
}
|
|
904
|
-
}), (
|
|
931
|
+
}), (i = R.get("*")) == null || i.forEach((r) => {
|
|
905
932
|
try {
|
|
906
|
-
r({ event: e, payload:
|
|
933
|
+
r({ event: e, payload: t });
|
|
907
934
|
} catch (d) {
|
|
908
935
|
console.error("[Bravophone] listener falhou:", d);
|
|
909
936
|
}
|
|
910
937
|
});
|
|
911
938
|
}
|
|
912
939
|
function m() {
|
|
913
|
-
if (!
|
|
914
|
-
return
|
|
940
|
+
if (!S) throw new Error("Bravophone: chame Bravophone.init() antes.");
|
|
941
|
+
return S;
|
|
915
942
|
}
|
|
916
|
-
const
|
|
943
|
+
const ie = {
|
|
917
944
|
/**
|
|
918
945
|
* Monta o webphone na página.
|
|
919
946
|
* @param {object} opts
|
|
920
947
|
* @param {string} [opts.hostUrl] Origem do webphone hospedado.
|
|
921
|
-
* @param {
|
|
948
|
+
* @param {object} [opts.session] Sessão do /api/voxfree/login — o objeto
|
|
949
|
+
* inteiro: { vxToken, expiresIn, sip, tenant, ramal, clienteId, ramaisUrl }.
|
|
950
|
+
* É o que o webphone precisa para registrar sem passar pela tela de login.
|
|
951
|
+
* @param {string} [opts.token] Atalho para `{ vxToken }`. Sozinho não
|
|
952
|
+
* basta: sem sip e ramal o webphone carrega mas não registra.
|
|
922
953
|
* @param {'bottom-right'|'bottom-left'|'top-right'|'top-left'} [opts.position]
|
|
923
954
|
* @param {boolean} [opts.open] Abrir já visível (padrão: false, só o launcher).
|
|
924
955
|
* @param {boolean} [opts.launcher] Exibir a aba de abertura (padrão: true).
|
|
@@ -930,19 +961,19 @@ const ne = {
|
|
|
930
961
|
* precisa estar na allowlist de CORS dos backends.
|
|
931
962
|
*/
|
|
932
963
|
init(e = {}) {
|
|
933
|
-
if (
|
|
964
|
+
if (S) return S;
|
|
934
965
|
if (typeof window == "undefined" || !document.body)
|
|
935
966
|
throw new Error("Bravophone: init() precisa rodar no browser, após o <body> existir.");
|
|
936
967
|
if (location.protocol !== "https:" && location.hostname !== "localhost" && console.warn("[Bravophone] Contexto inseguro: o microfone exige HTTPS ou localhost."), e.mode === "hosted" && !e.hostUrl)
|
|
937
968
|
throw new Error(
|
|
938
969
|
"Bravophone: mode 'hosted' exige hostUrl. Use mode 'srcdoc' (padrão) para carregar o webphone do CDN sem depender de um host próprio."
|
|
939
970
|
);
|
|
940
|
-
return
|
|
941
|
-
hostUrl:
|
|
942
|
-
version:
|
|
971
|
+
return S = Ae({
|
|
972
|
+
hostUrl: Re,
|
|
973
|
+
version: ie.version,
|
|
943
974
|
...e,
|
|
944
|
-
emit:
|
|
945
|
-
}),
|
|
975
|
+
emit: Be
|
|
976
|
+
}), S;
|
|
946
977
|
},
|
|
947
978
|
// ---- Controle da janela ----
|
|
948
979
|
show() {
|
|
@@ -961,11 +992,11 @@ const ne = {
|
|
|
961
992
|
minimize(e) {
|
|
962
993
|
m().minimize(e);
|
|
963
994
|
},
|
|
964
|
-
move(e,
|
|
965
|
-
m().move(e,
|
|
995
|
+
move(e, t) {
|
|
996
|
+
m().move(e, t);
|
|
966
997
|
},
|
|
967
|
-
resize(e,
|
|
968
|
-
m().resize(e,
|
|
998
|
+
resize(e, t) {
|
|
999
|
+
m().resize(e, t);
|
|
969
1000
|
},
|
|
970
1001
|
/** 'left' | 'right' | 'left-half' | 'right-half' | 'max' | 'float' */
|
|
971
1002
|
dock(e) {
|
|
@@ -980,15 +1011,15 @@ const ne = {
|
|
|
980
1011
|
m().setLauncherIcon(e);
|
|
981
1012
|
},
|
|
982
1013
|
get isOpen() {
|
|
983
|
-
return
|
|
1014
|
+
return S ? S.isOpen : !1;
|
|
984
1015
|
},
|
|
985
1016
|
get geometry() {
|
|
986
|
-
return
|
|
1017
|
+
return S ? S.geometry : null;
|
|
987
1018
|
},
|
|
988
1019
|
// ---- Telefonia ----
|
|
989
1020
|
/** Disca um número. Aceita formato livre; a normalização é a mesma da extensão. */
|
|
990
|
-
call(e,
|
|
991
|
-
return m().bridge.call("call", { number: e, meta:
|
|
1021
|
+
call(e, t) {
|
|
1022
|
+
return m().bridge.call("call", { number: e, meta: t });
|
|
992
1023
|
},
|
|
993
1024
|
hangup() {
|
|
994
1025
|
return m().bridge.call("hangup");
|
|
@@ -1013,8 +1044,10 @@ const ne = {
|
|
|
1013
1044
|
getStatus() {
|
|
1014
1045
|
return m().bridge.call("status");
|
|
1015
1046
|
},
|
|
1047
|
+
/** Aceita a sessão completa do login, ou só o vxToken (insuficiente sozinho). */
|
|
1016
1048
|
setAuth(e) {
|
|
1017
|
-
|
|
1049
|
+
const t = typeof e == "string" ? { vxToken: e } : e;
|
|
1050
|
+
return m().bridge.call("auth", { session: t });
|
|
1018
1051
|
},
|
|
1019
1052
|
logout() {
|
|
1020
1053
|
return m().bridge.call("logout");
|
|
@@ -1022,20 +1055,20 @@ const ne = {
|
|
|
1022
1055
|
// ---- Eventos ----
|
|
1023
1056
|
/** Eventos: ready, state, call:dialing, call:incoming, call:answered,
|
|
1024
1057
|
* call:ended, call:failed, resize, open, close, error. */
|
|
1025
|
-
on(e,
|
|
1026
|
-
return
|
|
1058
|
+
on(e, t) {
|
|
1059
|
+
return R.has(e) || R.set(e, /* @__PURE__ */ new Set()), R.get(e).add(t), () => ie.off(e, t);
|
|
1027
1060
|
},
|
|
1028
|
-
off(e,
|
|
1029
|
-
var
|
|
1030
|
-
(
|
|
1061
|
+
off(e, t) {
|
|
1062
|
+
var n;
|
|
1063
|
+
(n = R.get(e)) == null || n.delete(t);
|
|
1031
1064
|
},
|
|
1032
1065
|
destroy() {
|
|
1033
|
-
|
|
1066
|
+
S == null || S.destroy(), S = null, R.clear();
|
|
1034
1067
|
},
|
|
1035
1068
|
// Substituída em build time pelo valor do package.json (ver vite.config.js).
|
|
1036
|
-
version: "0.
|
|
1069
|
+
version: "0.4.0"
|
|
1037
1070
|
};
|
|
1038
|
-
typeof window != "undefined" && (window.Bravophone =
|
|
1071
|
+
typeof window != "undefined" && (window.Bravophone = ie);
|
|
1039
1072
|
export {
|
|
1040
|
-
|
|
1073
|
+
ie as default
|
|
1041
1074
|
};
|