@jetpack-desktop/client 0.1.2-beta.2 → 0.1.2-rc.2
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 +5 -1
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +102 -8
- package/dist/client.js.map +1 -1
- package/dist/control-bar.d.ts +41 -4
- package/dist/control-bar.d.ts.map +1 -1
- package/dist/control-bar.js +718 -3
- package/dist/control-bar.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/log-terminal.d.ts.map +1 -1
- package/dist/log-terminal.js +35 -0
- package/dist/log-terminal.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/wasm/jetpack_wasm.d.ts +6 -6
- package/wasm/jetpack_wasm.js +18 -18
- package/wasm/jetpack_wasm_bg.wasm +0 -0
- package/wasm/jetpack_wasm_bg.wasm.d.ts +6 -6
package/dist/control-bar.js
CHANGED
|
@@ -303,11 +303,247 @@ const CONTROL_BAR_STYLES = `
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
`;
|
|
306
|
+
const INSTALL_BANNER_STYLES = `
|
|
307
|
+
:host {
|
|
308
|
+
all: initial;
|
|
309
|
+
position: fixed;
|
|
310
|
+
inset: 0;
|
|
311
|
+
z-index: 2147483645;
|
|
312
|
+
pointer-events: none;
|
|
313
|
+
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
314
|
+
color: #f0f6fc;
|
|
315
|
+
-webkit-font-smoothing: antialiased;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
:host([hidden]) {
|
|
319
|
+
display: none !important;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
*, *::before, *::after {
|
|
323
|
+
box-sizing: border-box;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.jp-install-backdrop {
|
|
327
|
+
position: fixed;
|
|
328
|
+
left: 0;
|
|
329
|
+
right: 0;
|
|
330
|
+
top: var(--jp-control-bar-bottom, 48px);
|
|
331
|
+
bottom: var(--jetpack-log-terminal-offset, 0px);
|
|
332
|
+
pointer-events: auto;
|
|
333
|
+
display: flex;
|
|
334
|
+
align-items: center;
|
|
335
|
+
justify-content: center;
|
|
336
|
+
padding: 24px 20px;
|
|
337
|
+
background: rgba(8, 12, 19, 0.72);
|
|
338
|
+
backdrop-filter: blur(14px);
|
|
339
|
+
-webkit-backdrop-filter: blur(14px);
|
|
340
|
+
overflow-y: auto;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.jp-install-card {
|
|
344
|
+
position: relative;
|
|
345
|
+
z-index: 2;
|
|
346
|
+
width: 100%;
|
|
347
|
+
max-width: 440px;
|
|
348
|
+
display: flex;
|
|
349
|
+
flex-direction: column;
|
|
350
|
+
align-items: center;
|
|
351
|
+
text-align: center;
|
|
352
|
+
gap: 16px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.jp-poster-frame {
|
|
356
|
+
width: 100%;
|
|
357
|
+
max-width: 380px;
|
|
358
|
+
aspect-ratio: 16 / 9;
|
|
359
|
+
border-radius: 14px;
|
|
360
|
+
overflow: hidden;
|
|
361
|
+
border: 1px solid rgba(121, 192, 255, 0.28);
|
|
362
|
+
background: linear-gradient(145deg, #141d2e 0%, #0b111b 100%);
|
|
363
|
+
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
|
|
364
|
+
position: relative;
|
|
365
|
+
display: flex;
|
|
366
|
+
align-items: center;
|
|
367
|
+
justify-content: center;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.jp-poster-img {
|
|
371
|
+
width: 100%;
|
|
372
|
+
height: 100%;
|
|
373
|
+
object-fit: cover;
|
|
374
|
+
display: block;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.jp-poster-img[hidden] {
|
|
378
|
+
display: none;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.jp-poster-fallback {
|
|
382
|
+
position: relative;
|
|
383
|
+
width: 100%;
|
|
384
|
+
height: 100%;
|
|
385
|
+
padding: 20px;
|
|
386
|
+
display: flex;
|
|
387
|
+
flex-direction: column;
|
|
388
|
+
align-items: center;
|
|
389
|
+
justify-content: center;
|
|
390
|
+
gap: 10px;
|
|
391
|
+
overflow: hidden;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.jp-poster-fallback[hidden] {
|
|
395
|
+
display: none;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.jp-poster-grid {
|
|
399
|
+
position: absolute;
|
|
400
|
+
inset: 0;
|
|
401
|
+
background-image:
|
|
402
|
+
linear-gradient(rgba(88, 166, 255, 0.08) 1px, transparent 1px),
|
|
403
|
+
linear-gradient(90deg, rgba(88, 166, 255, 0.08) 1px, transparent 1px);
|
|
404
|
+
background-size: 22px 22px;
|
|
405
|
+
mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.9) 25%, transparent 85%);
|
|
406
|
+
pointer-events: none;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.jp-poster-emblem {
|
|
410
|
+
position: relative;
|
|
411
|
+
z-index: 1;
|
|
412
|
+
width: 52px;
|
|
413
|
+
height: 52px;
|
|
414
|
+
border-radius: 14px;
|
|
415
|
+
display: flex;
|
|
416
|
+
align-items: center;
|
|
417
|
+
justify-content: center;
|
|
418
|
+
background: rgba(31, 111, 235, 0.16);
|
|
419
|
+
border: 1px solid rgba(88, 166, 255, 0.35);
|
|
420
|
+
box-shadow: 0 10px 26px rgba(31, 111, 235, 0.25);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.jp-poster-emblem svg {
|
|
424
|
+
width: 30px;
|
|
425
|
+
height: 30px;
|
|
426
|
+
display: block;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.jp-poster-app-name {
|
|
430
|
+
position: relative;
|
|
431
|
+
z-index: 1;
|
|
432
|
+
font-size: 16px;
|
|
433
|
+
font-weight: 700;
|
|
434
|
+
color: #f0f6fc;
|
|
435
|
+
letter-spacing: -0.01em;
|
|
436
|
+
max-width: 100%;
|
|
437
|
+
overflow: hidden;
|
|
438
|
+
text-overflow: ellipsis;
|
|
439
|
+
white-space: nowrap;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.jp-poster-powered {
|
|
443
|
+
position: relative;
|
|
444
|
+
z-index: 1;
|
|
445
|
+
font-size: 11px;
|
|
446
|
+
font-weight: 600;
|
|
447
|
+
letter-spacing: 0.06em;
|
|
448
|
+
text-transform: uppercase;
|
|
449
|
+
color: #79c0ff;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.jp-install-message-box {
|
|
453
|
+
width: 100%;
|
|
454
|
+
background: rgba(19, 25, 36, 0.92);
|
|
455
|
+
border: 1px solid #2e3b52;
|
|
456
|
+
border-radius: 12px;
|
|
457
|
+
padding: 14px 18px;
|
|
458
|
+
box-shadow: 0 14px 38px rgba(0, 0, 0, 0.45);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.jp-install-message {
|
|
462
|
+
margin: 0;
|
|
463
|
+
font-size: 15px;
|
|
464
|
+
font-weight: 600;
|
|
465
|
+
line-height: 1.45;
|
|
466
|
+
color: #f0f6fc;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.jp-install-wait {
|
|
470
|
+
margin-top: 8px;
|
|
471
|
+
display: inline-flex;
|
|
472
|
+
align-items: center;
|
|
473
|
+
justify-content: center;
|
|
474
|
+
gap: 8px;
|
|
475
|
+
font-size: 12px;
|
|
476
|
+
font-weight: 500;
|
|
477
|
+
color: #9fb0c7;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.jp-install-wait-dot {
|
|
481
|
+
width: 8px;
|
|
482
|
+
height: 8px;
|
|
483
|
+
border-radius: 50%;
|
|
484
|
+
background: #58a6ff;
|
|
485
|
+
box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
|
|
486
|
+
animation: jp-pulse 1.6s ease-in-out infinite;
|
|
487
|
+
flex-shrink: 0;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
@keyframes jp-pulse {
|
|
491
|
+
0%, 100% {
|
|
492
|
+
opacity: 1;
|
|
493
|
+
transform: scale(1);
|
|
494
|
+
}
|
|
495
|
+
50% {
|
|
496
|
+
opacity: 0.55;
|
|
497
|
+
transform: scale(0.86);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.jp-install-arrow-svg {
|
|
502
|
+
position: fixed;
|
|
503
|
+
inset: 0;
|
|
504
|
+
width: 100%;
|
|
505
|
+
height: 100%;
|
|
506
|
+
pointer-events: none;
|
|
507
|
+
z-index: 3;
|
|
508
|
+
overflow: visible;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.jp-install-arrow-svg[hidden] {
|
|
512
|
+
display: none;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.jp-install-arrow-path {
|
|
516
|
+
fill: none;
|
|
517
|
+
stroke: #58a6ff;
|
|
518
|
+
stroke-width: 2.75;
|
|
519
|
+
stroke-linecap: round;
|
|
520
|
+
stroke-dasharray: 8 6;
|
|
521
|
+
filter: drop-shadow(0 2px 8px rgba(56, 139, 253, 0.55));
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.jp-install-arrow-head {
|
|
525
|
+
fill: #58a6ff;
|
|
526
|
+
}
|
|
527
|
+
`;
|
|
306
528
|
const JETPACK_LOGO_SVG = '<svg class="jp-logo-svg" viewBox="0 0 24 24" fill="none" aria-hidden="true">' +
|
|
307
529
|
'<rect width="24" height="24" rx="6" fill="#1F6FEB"/>' +
|
|
308
530
|
'<path d="M12 4.5L16.5 11H13.5V16.5L9.5 12H11.5V4.5H12Z" fill="#FFFFFF"/>' +
|
|
309
531
|
'<path d="M8.5 16.5L12 20L15.5 16.5H8.5Z" fill="#79C0FF"/>' +
|
|
310
532
|
'</svg>';
|
|
533
|
+
const ACTIVE_CONTROL_BARS_REGISTRY_KEY = Symbol.for('jetpack.controlBar.activeByDocument');
|
|
534
|
+
function getActiveControlBarRegistry() {
|
|
535
|
+
const g = globalThis;
|
|
536
|
+
let registry = g[ACTIVE_CONTROL_BARS_REGISTRY_KEY];
|
|
537
|
+
if (!registry) {
|
|
538
|
+
registry = new WeakMap();
|
|
539
|
+
g[ACTIVE_CONTROL_BARS_REGISTRY_KEY] = registry;
|
|
540
|
+
}
|
|
541
|
+
return registry;
|
|
542
|
+
}
|
|
543
|
+
function isLoopbackHost(hostname) {
|
|
544
|
+
const lower = hostname.toLowerCase();
|
|
545
|
+
return lower === '127.0.0.1' || lower === 'localhost' || lower === '[::1]' || lower === '::1';
|
|
546
|
+
}
|
|
311
547
|
function sanitizeHttpsDownloadUrl(rawUrl) {
|
|
312
548
|
if (typeof rawUrl !== 'string')
|
|
313
549
|
return null;
|
|
@@ -326,12 +562,92 @@ function sanitizeHttpsDownloadUrl(rawUrl) {
|
|
|
326
562
|
return null;
|
|
327
563
|
}
|
|
328
564
|
}
|
|
565
|
+
export function sanitizePosterUrl(rawUrl) {
|
|
566
|
+
if (typeof rawUrl !== 'string')
|
|
567
|
+
return null;
|
|
568
|
+
const trimmed = rawUrl.trim();
|
|
569
|
+
if (!trimmed || /[\s\u0000-\u001f\u007f]/.test(trimmed) || trimmed.includes('\\')) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
if (trimmed.startsWith('/')) {
|
|
573
|
+
if (trimmed.startsWith('//')) {
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
const pathOnly = trimmed.split(/[?#]/, 1)[0] || '';
|
|
577
|
+
const segments = pathOnly.split('/');
|
|
578
|
+
if (segments.some((seg) => seg === '..' || seg.toLowerCase() === '%2e%2e')) {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
return trimmed;
|
|
582
|
+
}
|
|
583
|
+
let parsed;
|
|
584
|
+
try {
|
|
585
|
+
parsed = new URL(trimmed);
|
|
586
|
+
}
|
|
587
|
+
catch {
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
if (parsed.username || parsed.password || !parsed.hostname) {
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
if (parsed.protocol === 'https:') {
|
|
594
|
+
// Allowed
|
|
595
|
+
}
|
|
596
|
+
else if (parsed.protocol === 'http:' && isLoopbackHost(parsed.hostname)) {
|
|
597
|
+
// Allowed loopback HTTP for local development/tests
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
const pathSegments = parsed.pathname.split('/');
|
|
603
|
+
if (pathSegments.some((seg) => seg === '..' || seg.toLowerCase() === '%2e%2e')) {
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
return parsed.toString();
|
|
607
|
+
}
|
|
608
|
+
function resolveMetaPosterCandidate() {
|
|
609
|
+
if (typeof document === 'undefined' || typeof document.querySelector !== 'function') {
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
const selectors = [
|
|
613
|
+
'meta[property="og:image"]',
|
|
614
|
+
'meta[name="og:image"]',
|
|
615
|
+
'meta[name="twitter:image"]',
|
|
616
|
+
'meta[property="twitter:image"]',
|
|
617
|
+
];
|
|
618
|
+
for (const selector of selectors) {
|
|
619
|
+
try {
|
|
620
|
+
const el = document.querySelector(selector);
|
|
621
|
+
const content = el?.getAttribute?.('content');
|
|
622
|
+
const safe = sanitizePosterUrl(content);
|
|
623
|
+
if (safe) {
|
|
624
|
+
return safe;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
catch {
|
|
628
|
+
// Ignore query errors in partial mock DOMs
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
function createSvgNode(tag) {
|
|
634
|
+
if (typeof document.createElementNS === 'function') {
|
|
635
|
+
return document.createElementNS('http://www.w3.org/2000/svg', tag);
|
|
636
|
+
}
|
|
637
|
+
return document.createElement(tag);
|
|
638
|
+
}
|
|
639
|
+
function clamp(val, min, max) {
|
|
640
|
+
if (max < min)
|
|
641
|
+
return min;
|
|
642
|
+
return Math.min(max, Math.max(min, val));
|
|
643
|
+
}
|
|
329
644
|
/**
|
|
330
645
|
* Shadow-DOM isolated top control bar for standalone and third-party JetPack web applications.
|
|
331
646
|
*
|
|
332
647
|
* Displays the JetPack logo, current app name, live worker status (`Connecting`, `Running`,
|
|
333
|
-
* `Stopped`, `Error`), `"Control Center"` link, `"Stop"` button,
|
|
334
|
-
* modal when stopping could lose unsaved work
|
|
648
|
+
* `Stopped`, `Error`), `"Control Center"` link, `"Stop"` button, an encapsulated confirmation
|
|
649
|
+
* modal when stopping could lose unsaved work, and a blocking install-gate overlay when
|
|
650
|
+
* JetPack Desktop is unreachable (`DAEMON_NOT_RUNNING`).
|
|
335
651
|
*/
|
|
336
652
|
export class JetPackControlBar {
|
|
337
653
|
options;
|
|
@@ -340,8 +656,11 @@ export class JetPackControlBar {
|
|
|
340
656
|
stopping = false;
|
|
341
657
|
relaunching = false;
|
|
342
658
|
modalOpen = false;
|
|
659
|
+
posterLoadFailed = false;
|
|
660
|
+
lastResolvedPosterUrl = null;
|
|
343
661
|
host = null;
|
|
344
662
|
shadow = null;
|
|
663
|
+
headerEl = null;
|
|
345
664
|
appNameEl = null;
|
|
346
665
|
statusPillEl = null;
|
|
347
666
|
statusTextEl = null;
|
|
@@ -356,7 +675,22 @@ export class JetPackControlBar {
|
|
|
356
675
|
modalMessageEl = null;
|
|
357
676
|
modalCancelBtnEl = null;
|
|
358
677
|
modalConfirmBtnEl = null;
|
|
678
|
+
installBannerHost = null;
|
|
679
|
+
installBannerShadow = null;
|
|
680
|
+
installBackdropEl = null;
|
|
681
|
+
installCardEl = null;
|
|
682
|
+
installPosterImgEl = null;
|
|
683
|
+
installPosterFallbackEl = null;
|
|
684
|
+
installPosterAppNameEl = null;
|
|
685
|
+
installMessageBoxEl = null;
|
|
686
|
+
installMessageEl = null;
|
|
687
|
+
installArrowSvgEl = null;
|
|
688
|
+
installArrowPathEl = null;
|
|
359
689
|
keydownHandler = null;
|
|
690
|
+
layoutListenersAttached = false;
|
|
691
|
+
resizeObserver = null;
|
|
692
|
+
windowLayoutHandler = null;
|
|
693
|
+
arrowRafId = null;
|
|
360
694
|
constructor(options = {}) {
|
|
361
695
|
this.options = { ...options };
|
|
362
696
|
this.status = options.initialStatus ?? 'Connecting';
|
|
@@ -375,12 +709,33 @@ export class JetPackControlBar {
|
|
|
375
709
|
if (!container) {
|
|
376
710
|
return false;
|
|
377
711
|
}
|
|
712
|
+
const registry = getActiveControlBarRegistry();
|
|
713
|
+
const prevActive = registry.get(document);
|
|
714
|
+
if (prevActive && prevActive !== this) {
|
|
715
|
+
prevActive.markSupersededAndUnmount();
|
|
716
|
+
}
|
|
378
717
|
if (!this.host) {
|
|
379
718
|
this.buildDom();
|
|
380
719
|
}
|
|
720
|
+
if (!this.installBannerHost) {
|
|
721
|
+
this.buildInstallBannerDom();
|
|
722
|
+
}
|
|
381
723
|
if (!this.host) {
|
|
382
724
|
return false;
|
|
383
725
|
}
|
|
726
|
+
if (typeof document.querySelectorAll === 'function') {
|
|
727
|
+
try {
|
|
728
|
+
const staleNodes = document.querySelectorAll('[data-jetpack-control-bar="true"], #jetpack-control-bar-host, [data-jetpack-install-banner="true"], #jetpack-install-banner-host');
|
|
729
|
+
for (const node of Array.from(staleNodes)) {
|
|
730
|
+
if (node !== this.host && node !== this.installBannerHost && node.parentNode) {
|
|
731
|
+
node.parentNode.removeChild(node);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
catch {
|
|
736
|
+
// Ignore query failures in restricted/mock DOM environments
|
|
737
|
+
}
|
|
738
|
+
}
|
|
384
739
|
if (this.host.parentNode !== container) {
|
|
385
740
|
if (container.firstChild) {
|
|
386
741
|
container.insertBefore(this.host, container.firstChild);
|
|
@@ -389,30 +744,66 @@ export class JetPackControlBar {
|
|
|
389
744
|
container.appendChild(this.host);
|
|
390
745
|
}
|
|
391
746
|
}
|
|
747
|
+
registry.set(document, this);
|
|
392
748
|
this.syncUi();
|
|
393
749
|
return true;
|
|
394
750
|
}
|
|
395
|
-
/** Unmounts and cleans up the control bar host and event listeners. */
|
|
751
|
+
/** Unmounts and cleans up the control bar host, install-gate overlay, and event listeners. */
|
|
396
752
|
unmount() {
|
|
397
753
|
this.closeModal();
|
|
754
|
+
this.detachInstallLayoutTracking();
|
|
398
755
|
if (this.keydownHandler && typeof document !== 'undefined') {
|
|
399
756
|
document.removeEventListener('keydown', this.keydownHandler);
|
|
400
757
|
this.keydownHandler = null;
|
|
401
758
|
}
|
|
759
|
+
if (typeof document !== 'undefined') {
|
|
760
|
+
const registry = getActiveControlBarRegistry();
|
|
761
|
+
if (registry.get(document) === this) {
|
|
762
|
+
registry.delete(document);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
402
765
|
if (this.host && this.host.parentNode) {
|
|
403
766
|
this.host.parentNode.removeChild(this.host);
|
|
404
767
|
}
|
|
768
|
+
if (this.installBannerHost && this.installBannerHost.parentNode) {
|
|
769
|
+
this.installBannerHost.parentNode.removeChild(this.installBannerHost);
|
|
770
|
+
}
|
|
405
771
|
this.host = null;
|
|
406
772
|
this.shadow = null;
|
|
773
|
+
this.headerEl = null;
|
|
774
|
+
this.installBannerHost = null;
|
|
775
|
+
this.installBannerShadow = null;
|
|
776
|
+
this.installBackdropEl = null;
|
|
777
|
+
this.installCardEl = null;
|
|
778
|
+
this.installPosterImgEl = null;
|
|
779
|
+
this.installPosterFallbackEl = null;
|
|
780
|
+
this.installPosterAppNameEl = null;
|
|
781
|
+
this.installMessageBoxEl = null;
|
|
782
|
+
this.installMessageEl = null;
|
|
783
|
+
this.installArrowSvgEl = null;
|
|
784
|
+
this.installArrowPathEl = null;
|
|
785
|
+
}
|
|
786
|
+
markSupersededAndUnmount() {
|
|
787
|
+
const cb = this.options.onSuperseded;
|
|
788
|
+
this.unmount();
|
|
789
|
+
cb?.();
|
|
407
790
|
}
|
|
408
791
|
/** Updates mutable configuration options on the mounted bar. */
|
|
409
792
|
updateOptions(partial) {
|
|
793
|
+
const posterChanged = 'posterUrl' in partial || 'installBanner' in partial;
|
|
410
794
|
this.options = { ...this.options, ...partial };
|
|
795
|
+
if (posterChanged) {
|
|
796
|
+
this.posterLoadFailed = false;
|
|
797
|
+
}
|
|
411
798
|
if (this.status === 'Error' && 'downloadUrl' in partial) {
|
|
412
799
|
this.currentDownloadUrl = sanitizeHttpsDownloadUrl(partial.downloadUrl);
|
|
413
800
|
}
|
|
414
801
|
this.syncUi();
|
|
415
802
|
}
|
|
803
|
+
/** Updates install-gate overlay options (`false` disables, or object updates `posterUrl`/`message`). */
|
|
804
|
+
setInstallBannerOptions(installBanner) {
|
|
805
|
+
this.updateOptions({ installBanner });
|
|
806
|
+
}
|
|
416
807
|
/** Updates the live worker status pill, optional detail text, and optional HTTPS download link. */
|
|
417
808
|
setStatus(status, detail, statusOptions) {
|
|
418
809
|
this.status = status;
|
|
@@ -439,6 +830,10 @@ export class JetPackControlBar {
|
|
|
439
830
|
getStatus() {
|
|
440
831
|
return this.status;
|
|
441
832
|
}
|
|
833
|
+
/** Returns `true` when the blocking install-gate overlay is currently visible. */
|
|
834
|
+
isInstallBannerVisible() {
|
|
835
|
+
return Boolean(this.installBannerHost && !this.installBannerHost.hidden);
|
|
836
|
+
}
|
|
442
837
|
/** Updates the displayed application name in the control bar. */
|
|
443
838
|
setAppName(appName) {
|
|
444
839
|
this.options.appName = appName;
|
|
@@ -457,6 +852,14 @@ export class JetPackControlBar {
|
|
|
457
852
|
getShadowRoot() {
|
|
458
853
|
return this.shadow;
|
|
459
854
|
}
|
|
855
|
+
/** Returns the install-gate overlay host element, or `null` if unmounted. */
|
|
856
|
+
getInstallBannerHostElement() {
|
|
857
|
+
return this.installBannerHost;
|
|
858
|
+
}
|
|
859
|
+
/** Returns the open ShadowRoot isolating the install-gate overlay styles and DOM. */
|
|
860
|
+
getInstallBannerShadowRoot() {
|
|
861
|
+
return this.installBannerShadow;
|
|
862
|
+
}
|
|
460
863
|
/** Returns `true` when the Shadow-DOM stop confirmation modal is open. */
|
|
461
864
|
isModalOpen() {
|
|
462
865
|
return this.modalOpen;
|
|
@@ -525,6 +928,27 @@ export class JetPackControlBar {
|
|
|
525
928
|
}
|
|
526
929
|
return typeof this.options.onBeforeStop === 'function';
|
|
527
930
|
}
|
|
931
|
+
shouldShowInstallBanner() {
|
|
932
|
+
return (this.options.installBanner !== false &&
|
|
933
|
+
this.status === 'Error' &&
|
|
934
|
+
this.currentDownloadUrl !== null &&
|
|
935
|
+
this.host !== null &&
|
|
936
|
+
this.host.parentNode !== null);
|
|
937
|
+
}
|
|
938
|
+
resolveSafePosterCandidate() {
|
|
939
|
+
const bannerOpts = typeof this.options.installBanner === 'object' && this.options.installBanner !== null
|
|
940
|
+
? this.options.installBanner
|
|
941
|
+
: null;
|
|
942
|
+
const explicit = typeof bannerOpts?.posterUrl === 'string' && bannerOpts.posterUrl.trim().length > 0
|
|
943
|
+
? bannerOpts.posterUrl
|
|
944
|
+
: typeof this.options.posterUrl === 'string' && this.options.posterUrl.trim().length > 0
|
|
945
|
+
? this.options.posterUrl
|
|
946
|
+
: null;
|
|
947
|
+
if (explicit !== null) {
|
|
948
|
+
return sanitizePosterUrl(explicit);
|
|
949
|
+
}
|
|
950
|
+
return resolveMetaPosterCandidate();
|
|
951
|
+
}
|
|
528
952
|
openModal() {
|
|
529
953
|
this.modalOpen = true;
|
|
530
954
|
if (this.modalTitleEl) {
|
|
@@ -733,6 +1157,7 @@ export class JetPackControlBar {
|
|
|
733
1157
|
}
|
|
734
1158
|
this.host = host;
|
|
735
1159
|
this.shadow = shadow;
|
|
1160
|
+
this.headerEl = header;
|
|
736
1161
|
this.appNameEl = appNameEl;
|
|
737
1162
|
this.statusPillEl = statusPillEl;
|
|
738
1163
|
this.statusTextEl = statusTextEl;
|
|
@@ -748,6 +1173,117 @@ export class JetPackControlBar {
|
|
|
748
1173
|
this.modalCancelBtnEl = cancelBtn;
|
|
749
1174
|
this.modalConfirmBtnEl = confirmBtn;
|
|
750
1175
|
}
|
|
1176
|
+
buildInstallBannerDom() {
|
|
1177
|
+
const bannerHost = document.createElement('div');
|
|
1178
|
+
bannerHost.id = 'jetpack-install-banner-host';
|
|
1179
|
+
bannerHost.setAttribute('data-jetpack-install-banner', 'true');
|
|
1180
|
+
bannerHost.hidden = true;
|
|
1181
|
+
bannerHost.style.display = 'none';
|
|
1182
|
+
const shadow = bannerHost.attachShadow({ mode: 'open' });
|
|
1183
|
+
const style = document.createElement('style');
|
|
1184
|
+
style.textContent = INSTALL_BANNER_STYLES;
|
|
1185
|
+
shadow.appendChild(style);
|
|
1186
|
+
const backdrop = document.createElement('div');
|
|
1187
|
+
backdrop.className = 'jp-install-backdrop';
|
|
1188
|
+
backdrop.setAttribute('data-jp-field', 'install-backdrop');
|
|
1189
|
+
backdrop.setAttribute('role', 'dialog');
|
|
1190
|
+
backdrop.setAttribute('aria-modal', 'true');
|
|
1191
|
+
const card = document.createElement('div');
|
|
1192
|
+
card.className = 'jp-install-card';
|
|
1193
|
+
card.setAttribute('data-jp-field', 'install-card');
|
|
1194
|
+
const posterFrame = document.createElement('div');
|
|
1195
|
+
posterFrame.className = 'jp-poster-frame';
|
|
1196
|
+
posterFrame.setAttribute('data-jp-field', 'install-poster');
|
|
1197
|
+
const posterImg = document.createElement('img');
|
|
1198
|
+
posterImg.className = 'jp-poster-img';
|
|
1199
|
+
posterImg.setAttribute('data-jp-field', 'install-poster-img');
|
|
1200
|
+
posterImg.hidden = true;
|
|
1201
|
+
posterImg.addEventListener('error', () => {
|
|
1202
|
+
this.posterLoadFailed = true;
|
|
1203
|
+
this.syncInstallBannerUi();
|
|
1204
|
+
});
|
|
1205
|
+
const posterFallback = document.createElement('div');
|
|
1206
|
+
posterFallback.className = 'jp-poster-fallback';
|
|
1207
|
+
posterFallback.setAttribute('data-jp-field', 'install-poster-fallback');
|
|
1208
|
+
const grid = document.createElement('div');
|
|
1209
|
+
grid.className = 'jp-poster-grid';
|
|
1210
|
+
grid.setAttribute('aria-hidden', 'true');
|
|
1211
|
+
const emblem = document.createElement('div');
|
|
1212
|
+
emblem.className = 'jp-poster-emblem';
|
|
1213
|
+
emblem.innerHTML = JETPACK_LOGO_SVG;
|
|
1214
|
+
const fallbackAppName = document.createElement('div');
|
|
1215
|
+
fallbackAppName.className = 'jp-poster-app-name';
|
|
1216
|
+
fallbackAppName.setAttribute('data-jp-field', 'install-poster-app-name');
|
|
1217
|
+
const poweredLabel = document.createElement('div');
|
|
1218
|
+
poweredLabel.className = 'jp-poster-powered';
|
|
1219
|
+
poweredLabel.textContent = 'Powered by JetPack';
|
|
1220
|
+
posterFallback.appendChild(grid);
|
|
1221
|
+
posterFallback.appendChild(emblem);
|
|
1222
|
+
posterFallback.appendChild(fallbackAppName);
|
|
1223
|
+
posterFallback.appendChild(poweredLabel);
|
|
1224
|
+
posterFrame.appendChild(posterImg);
|
|
1225
|
+
posterFrame.appendChild(posterFallback);
|
|
1226
|
+
const messageBox = document.createElement('div');
|
|
1227
|
+
messageBox.className = 'jp-install-message-box';
|
|
1228
|
+
messageBox.setAttribute('data-jp-field', 'install-message-box');
|
|
1229
|
+
const messageEl = document.createElement('p');
|
|
1230
|
+
messageEl.className = 'jp-install-message';
|
|
1231
|
+
messageEl.setAttribute('data-jp-field', 'install-message');
|
|
1232
|
+
const waitEl = document.createElement('div');
|
|
1233
|
+
waitEl.className = 'jp-install-wait';
|
|
1234
|
+
waitEl.setAttribute('data-jp-field', 'install-wait');
|
|
1235
|
+
const waitDot = document.createElement('span');
|
|
1236
|
+
waitDot.className = 'jp-install-wait-dot';
|
|
1237
|
+
waitDot.setAttribute('aria-hidden', 'true');
|
|
1238
|
+
const waitText = document.createElement('span');
|
|
1239
|
+
waitText.textContent = 'Click "Download JetPack" above — waiting for JetPack to start...';
|
|
1240
|
+
waitEl.appendChild(waitDot);
|
|
1241
|
+
waitEl.appendChild(waitText);
|
|
1242
|
+
messageBox.appendChild(messageEl);
|
|
1243
|
+
messageBox.appendChild(waitEl);
|
|
1244
|
+
card.appendChild(posterFrame);
|
|
1245
|
+
card.appendChild(messageBox);
|
|
1246
|
+
backdrop.appendChild(card);
|
|
1247
|
+
// Inline SVG arrow pointing from install message to the "Download JetPack" button
|
|
1248
|
+
const arrowSvg = createSvgNode('svg');
|
|
1249
|
+
arrowSvg.setAttribute('class', 'jp-install-arrow-svg');
|
|
1250
|
+
arrowSvg.setAttribute('data-jp-field', 'install-arrow-svg');
|
|
1251
|
+
arrowSvg.setAttribute('aria-hidden', 'true');
|
|
1252
|
+
arrowSvg.hidden = true;
|
|
1253
|
+
const defs = createSvgNode('defs');
|
|
1254
|
+
const marker = createSvgNode('marker');
|
|
1255
|
+
marker.setAttribute('id', 'jp-install-arrowhead');
|
|
1256
|
+
marker.setAttribute('markerWidth', '12');
|
|
1257
|
+
marker.setAttribute('markerHeight', '12');
|
|
1258
|
+
marker.setAttribute('refX', '9');
|
|
1259
|
+
marker.setAttribute('refY', '6');
|
|
1260
|
+
marker.setAttribute('orient', 'auto');
|
|
1261
|
+
marker.setAttribute('markerUnits', 'userSpaceOnUse');
|
|
1262
|
+
const markerPoly = createSvgNode('polygon');
|
|
1263
|
+
markerPoly.setAttribute('points', '0,1.5 11,6 0,10.5 2.5,6');
|
|
1264
|
+
markerPoly.setAttribute('class', 'jp-install-arrow-head');
|
|
1265
|
+
marker.appendChild(markerPoly);
|
|
1266
|
+
defs.appendChild(marker);
|
|
1267
|
+
const arrowPath = createSvgNode('path');
|
|
1268
|
+
arrowPath.setAttribute('class', 'jp-install-arrow-path');
|
|
1269
|
+
arrowPath.setAttribute('data-jp-field', 'install-arrow-path');
|
|
1270
|
+
arrowPath.setAttribute('marker-end', 'url(#jp-install-arrowhead)');
|
|
1271
|
+
arrowSvg.appendChild(defs);
|
|
1272
|
+
arrowSvg.appendChild(arrowPath);
|
|
1273
|
+
shadow.appendChild(backdrop);
|
|
1274
|
+
shadow.appendChild(arrowSvg);
|
|
1275
|
+
this.installBannerHost = bannerHost;
|
|
1276
|
+
this.installBannerShadow = shadow;
|
|
1277
|
+
this.installBackdropEl = backdrop;
|
|
1278
|
+
this.installCardEl = card;
|
|
1279
|
+
this.installPosterImgEl = posterImg;
|
|
1280
|
+
this.installPosterFallbackEl = posterFallback;
|
|
1281
|
+
this.installPosterAppNameEl = fallbackAppName;
|
|
1282
|
+
this.installMessageBoxEl = messageBox;
|
|
1283
|
+
this.installMessageEl = messageEl;
|
|
1284
|
+
this.installArrowSvgEl = arrowSvg;
|
|
1285
|
+
this.installArrowPathEl = arrowPath;
|
|
1286
|
+
}
|
|
751
1287
|
syncUi() {
|
|
752
1288
|
const resolvedName = this.options.appName?.trim() || this.options.appId?.trim() || 'JetPack App';
|
|
753
1289
|
if (this.appNameEl) {
|
|
@@ -783,6 +1319,185 @@ export class JetPackControlBar {
|
|
|
783
1319
|
if (this.modalConfirmBtnEl) {
|
|
784
1320
|
this.modalConfirmBtnEl.disabled = this.stopping;
|
|
785
1321
|
}
|
|
1322
|
+
this.syncInstallBannerUi(resolvedName);
|
|
1323
|
+
}
|
|
1324
|
+
syncInstallBannerUi(resolvedName) {
|
|
1325
|
+
if (!this.installBannerHost)
|
|
1326
|
+
return;
|
|
1327
|
+
const appDisplayName = resolvedName ?? (this.options.appName?.trim() || this.options.appId?.trim() || 'JetPack App');
|
|
1328
|
+
const visible = this.shouldShowInstallBanner();
|
|
1329
|
+
this.installBannerHost.hidden = !visible;
|
|
1330
|
+
this.installBannerHost.style.display = visible ? 'block' : 'none';
|
|
1331
|
+
this.installBannerHost.setAttribute('data-visible', visible ? 'true' : 'false');
|
|
1332
|
+
if (!visible) {
|
|
1333
|
+
this.detachInstallLayoutTracking();
|
|
1334
|
+
if (this.installArrowSvgEl) {
|
|
1335
|
+
this.installArrowSvgEl.hidden = true;
|
|
1336
|
+
}
|
|
1337
|
+
if (this.installBannerHost.parentNode) {
|
|
1338
|
+
this.installBannerHost.parentNode.removeChild(this.installBannerHost);
|
|
1339
|
+
}
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
const container = this.host?.parentNode;
|
|
1343
|
+
if (container && this.installBannerHost.parentNode !== container) {
|
|
1344
|
+
container.appendChild(this.installBannerHost);
|
|
1345
|
+
}
|
|
1346
|
+
const candidateUrl = this.resolveSafePosterCandidate();
|
|
1347
|
+
if (candidateUrl !== this.lastResolvedPosterUrl) {
|
|
1348
|
+
this.lastResolvedPosterUrl = candidateUrl;
|
|
1349
|
+
this.posterLoadFailed = false;
|
|
1350
|
+
}
|
|
1351
|
+
const usePosterImg = Boolean(candidateUrl && !this.posterLoadFailed);
|
|
1352
|
+
if (this.installPosterImgEl) {
|
|
1353
|
+
if (usePosterImg && candidateUrl) {
|
|
1354
|
+
if (this.installPosterImgEl.src !== candidateUrl) {
|
|
1355
|
+
this.installPosterImgEl.src = candidateUrl;
|
|
1356
|
+
}
|
|
1357
|
+
this.installPosterImgEl.alt = `${appDisplayName} poster`;
|
|
1358
|
+
this.installPosterImgEl.hidden = false;
|
|
1359
|
+
}
|
|
1360
|
+
else {
|
|
1361
|
+
this.installPosterImgEl.hidden = true;
|
|
1362
|
+
this.installPosterImgEl.removeAttribute('src');
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
if (this.installPosterFallbackEl) {
|
|
1366
|
+
this.installPosterFallbackEl.hidden = usePosterImg;
|
|
1367
|
+
}
|
|
1368
|
+
if (this.installPosterAppNameEl) {
|
|
1369
|
+
this.installPosterAppNameEl.textContent = appDisplayName;
|
|
1370
|
+
}
|
|
1371
|
+
const customMsg = typeof this.options.installBanner === 'object' && this.options.installBanner !== null
|
|
1372
|
+
? this.options.installBanner.message?.trim()
|
|
1373
|
+
: undefined;
|
|
1374
|
+
if (this.installMessageEl) {
|
|
1375
|
+
this.installMessageEl.textContent =
|
|
1376
|
+
customMsg && customMsg.length > 0
|
|
1377
|
+
? customMsg
|
|
1378
|
+
: `To use ${appDisplayName}, install and run the free JetPack app.`;
|
|
1379
|
+
}
|
|
1380
|
+
this.attachInstallLayoutTracking();
|
|
1381
|
+
this.scheduleInstallArrowUpdate();
|
|
1382
|
+
}
|
|
1383
|
+
attachInstallLayoutTracking() {
|
|
1384
|
+
if (this.layoutListenersAttached)
|
|
1385
|
+
return;
|
|
1386
|
+
this.layoutListenersAttached = true;
|
|
1387
|
+
if (typeof ResizeObserver === 'function' && !this.resizeObserver) {
|
|
1388
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
1389
|
+
this.scheduleInstallArrowUpdate();
|
|
1390
|
+
});
|
|
1391
|
+
if (this.headerEl)
|
|
1392
|
+
this.resizeObserver.observe(this.headerEl);
|
|
1393
|
+
if (this.installCardEl)
|
|
1394
|
+
this.resizeObserver.observe(this.installCardEl);
|
|
1395
|
+
if (this.downloadLinkEl)
|
|
1396
|
+
this.resizeObserver.observe(this.downloadLinkEl);
|
|
1397
|
+
}
|
|
1398
|
+
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
|
1399
|
+
this.windowLayoutHandler = () => {
|
|
1400
|
+
this.scheduleInstallArrowUpdate();
|
|
1401
|
+
};
|
|
1402
|
+
window.addEventListener('resize', this.windowLayoutHandler);
|
|
1403
|
+
window.addEventListener('scroll', this.windowLayoutHandler, true);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
detachInstallLayoutTracking() {
|
|
1407
|
+
this.layoutListenersAttached = false;
|
|
1408
|
+
if (this.arrowRafId !== null && typeof cancelAnimationFrame === 'function') {
|
|
1409
|
+
cancelAnimationFrame(this.arrowRafId);
|
|
1410
|
+
this.arrowRafId = null;
|
|
1411
|
+
}
|
|
1412
|
+
if (this.resizeObserver) {
|
|
1413
|
+
this.resizeObserver.disconnect();
|
|
1414
|
+
this.resizeObserver = null;
|
|
1415
|
+
}
|
|
1416
|
+
if (this.windowLayoutHandler &&
|
|
1417
|
+
typeof window !== 'undefined' &&
|
|
1418
|
+
typeof window.removeEventListener === 'function') {
|
|
1419
|
+
window.removeEventListener('resize', this.windowLayoutHandler);
|
|
1420
|
+
window.removeEventListener('scroll', this.windowLayoutHandler, true);
|
|
1421
|
+
}
|
|
1422
|
+
this.windowLayoutHandler = null;
|
|
1423
|
+
}
|
|
1424
|
+
scheduleInstallArrowUpdate() {
|
|
1425
|
+
this.updateInstallArrowGeometry();
|
|
1426
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
1427
|
+
if (this.arrowRafId !== null && typeof cancelAnimationFrame === 'function') {
|
|
1428
|
+
cancelAnimationFrame(this.arrowRafId);
|
|
1429
|
+
}
|
|
1430
|
+
this.arrowRafId = requestAnimationFrame(() => {
|
|
1431
|
+
this.arrowRafId = null;
|
|
1432
|
+
this.updateInstallArrowGeometry();
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
updateInstallArrowGeometry() {
|
|
1437
|
+
if (!this.shouldShowInstallBanner())
|
|
1438
|
+
return;
|
|
1439
|
+
const headerRect = this.headerEl && typeof this.headerEl.getBoundingClientRect === 'function'
|
|
1440
|
+
? this.headerEl.getBoundingClientRect()
|
|
1441
|
+
: null;
|
|
1442
|
+
const barBottom = headerRect && headerRect.bottom > 0 ? Math.ceil(headerRect.bottom) : 48;
|
|
1443
|
+
if (this.installBackdropEl) {
|
|
1444
|
+
this.installBackdropEl.style.setProperty?.('--jp-control-bar-bottom', `${barBottom}px`);
|
|
1445
|
+
}
|
|
1446
|
+
if (!this.installArrowSvgEl || !this.installArrowPathEl) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
const btnRect = this.downloadLinkEl &&
|
|
1450
|
+
!this.downloadLinkEl.hidden &&
|
|
1451
|
+
typeof this.downloadLinkEl.getBoundingClientRect === 'function'
|
|
1452
|
+
? this.downloadLinkEl.getBoundingClientRect()
|
|
1453
|
+
: null;
|
|
1454
|
+
const msgRect = this.installMessageBoxEl && typeof this.installMessageBoxEl.getBoundingClientRect === 'function'
|
|
1455
|
+
? this.installMessageBoxEl.getBoundingClientRect()
|
|
1456
|
+
: null;
|
|
1457
|
+
if (!btnRect ||
|
|
1458
|
+
!msgRect ||
|
|
1459
|
+
btnRect.width <= 0 ||
|
|
1460
|
+
btnRect.height <= 0 ||
|
|
1461
|
+
msgRect.width <= 0 ||
|
|
1462
|
+
msgRect.height <= 0) {
|
|
1463
|
+
this.installArrowSvgEl.hidden = true;
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
const vw = (typeof window !== 'undefined' && window.innerWidth) ||
|
|
1467
|
+
(typeof document !== 'undefined' && document.documentElement?.clientWidth) ||
|
|
1468
|
+
1024;
|
|
1469
|
+
const vh = (typeof window !== 'undefined' && window.innerHeight) ||
|
|
1470
|
+
(typeof document !== 'undefined' && document.documentElement?.clientHeight) ||
|
|
1471
|
+
768;
|
|
1472
|
+
const tx = clamp(btnRect.left + btnRect.width / 2, 16, vw - 16);
|
|
1473
|
+
const ty = Math.max(barBottom + 6, btnRect.bottom + 8);
|
|
1474
|
+
const hasRightRoom = vw - msgRect.right >= 56;
|
|
1475
|
+
const sx = hasRightRoom
|
|
1476
|
+
? msgRect.right + 12
|
|
1477
|
+
: clamp(msgRect.right - 24, 24, vw - 24);
|
|
1478
|
+
const sy = hasRightRoom
|
|
1479
|
+
? msgRect.top + msgRect.height * 0.45
|
|
1480
|
+
: msgRect.top - 8;
|
|
1481
|
+
if (sy <= ty + 20) {
|
|
1482
|
+
this.installArrowSvgEl.hidden = true;
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
const mx = clamp((sx + tx) / 2 + (hasRightRoom ? 44 : 28), 24, vw - 24);
|
|
1486
|
+
const my = (sy + ty) / 2;
|
|
1487
|
+
const c1x = clamp(sx + (hasRightRoom ? 68 : 36), 16, vw - 16);
|
|
1488
|
+
const c1y = sy - 10;
|
|
1489
|
+
const c2x = clamp(mx + 42, 16, vw - 16);
|
|
1490
|
+
const c2y = my + 34;
|
|
1491
|
+
const c3x = clamp(mx - 42, 16, vw - 16);
|
|
1492
|
+
const c3y = my - 34;
|
|
1493
|
+
const c4x = tx;
|
|
1494
|
+
const c4y = ty + 42;
|
|
1495
|
+
const pathData = `M ${sx.toFixed(1)} ${sy.toFixed(1)} ` +
|
|
1496
|
+
`C ${c1x.toFixed(1)} ${c1y.toFixed(1)}, ${c2x.toFixed(1)} ${c2y.toFixed(1)}, ${mx.toFixed(1)} ${my.toFixed(1)} ` +
|
|
1497
|
+
`C ${c3x.toFixed(1)} ${c3y.toFixed(1)}, ${c4x.toFixed(1)} ${c4y.toFixed(1)}, ${tx.toFixed(1)} ${ty.toFixed(1)}`;
|
|
1498
|
+
this.installArrowSvgEl.setAttribute('viewBox', `0 0 ${vw} ${vh}`);
|
|
1499
|
+
this.installArrowPathEl.setAttribute('d', pathData);
|
|
1500
|
+
this.installArrowSvgEl.hidden = false;
|
|
786
1501
|
}
|
|
787
1502
|
}
|
|
788
1503
|
//# sourceMappingURL=control-bar.js.map
|