1 | "use strict";exports.__esModule=true;exports.default=initializeBuildWatcher;var _eventsource=require("./error-overlay/eventsource");function initializeBuildWatcher(toggleCallback){const shadowHost=document.createElement('div');shadowHost.id='__next-build-watcher';
|
2 | shadowHost.style.position='fixed';shadowHost.style.bottom='10px';shadowHost.style.right='20px';shadowHost.style.width=0;shadowHost.style.height=0;shadowHost.style.zIndex=99999;document.body.appendChild(shadowHost);let shadowRoot;let prefix='';if(shadowHost.attachShadow){shadowRoot=shadowHost.attachShadow({mode:'open'});}else{
|
3 |
|
4 |
|
5 | shadowRoot=shadowHost;prefix='__next-build-watcher-';}
|
6 | const container=createContainer(prefix);shadowRoot.appendChild(container);
|
7 | const css=createCss(prefix);shadowRoot.appendChild(css);
|
8 | let isVisible=false;let isBuilding=false;let timeoutId=null;
|
9 | (0,_eventsource.addMessageListener)(event=>{
|
10 | if(event.data==='\uD83D\uDC93'){return;}try{handleMessage(event);}catch(_unused){}});function handleMessage(event){const obj=typeof event==='string'?{action:event}:JSON.parse(event.data);
|
11 | switch(obj.action){case'building':timeoutId&&clearTimeout(timeoutId);isVisible=true;isBuilding=true;updateContainer();break;case'built':case'sync':isBuilding=false;
|
12 | timeoutId=setTimeout(()=>{isVisible=false;updateContainer();},100);updateContainer();break;}}toggleCallback(handleMessage);function updateContainer(){if(isBuilding){container.classList.add(`${prefix}building`);}else{container.classList.remove(`${prefix}building`);}if(isVisible){container.classList.add(`${prefix}visible`);}else{container.classList.remove(`${prefix}visible`);}}}function createContainer(prefix){const container=document.createElement('div');container.id=`${prefix}container`;container.innerHTML=`
|
13 | <div id="${prefix}icon-wrapper">
|
14 | <svg viewBox="0 0 226 200">
|
15 | <defs>
|
16 | <linearGradient
|
17 | x1="114.720775%"
|
18 | y1="181.283245%"
|
19 | x2="39.5399306%"
|
20 | y2="100%"
|
21 | id="${prefix}linear-gradient"
|
22 | >
|
23 | <stop stop-color="#000000" offset="0%" />
|
24 | <stop stop-color="#FFFFFF" offset="100%" />
|
25 | </linearGradient>
|
26 | </defs>
|
27 | <g id="${prefix}icon-group" fill="none" stroke="url(#${prefix}linear-gradient)" stroke-width="18">
|
28 | <path d="M113,5.08219117 L4.28393801,197.5 L221.716062,197.5 L113,5.08219117 Z" />
|
29 | </g>
|
30 | </svg>
|
31 | </div>
|
32 | `;return container;}function createCss(prefix){const css=document.createElement('style');css.textContent=`
|
33 | #${prefix}container {
|
34 | position: absolute;
|
35 | bottom: 10px;
|
36 | right: 30px;
|
37 |
|
38 | border-radius: 3px;
|
39 | background: #000;
|
40 | color: #fff;
|
41 | font: initial;
|
42 | cursor: initial;
|
43 | letter-spacing: initial;
|
44 | text-shadow: initial;
|
45 | text-transform: initial;
|
46 | visibility: initial;
|
47 |
|
48 | padding: 7px 10px 8px 10px;
|
49 | align-items: center;
|
50 | box-shadow: 0 11px 40px 0 rgba(0, 0, 0, 0.25), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
|
51 |
|
52 | display: none;
|
53 | opacity: 0;
|
54 | transition: opacity 0.1s ease, bottom 0.1s ease;
|
55 | animation: ${prefix}fade-in 0.1s ease-in-out;
|
56 | }
|
57 |
|
58 | #${prefix}container.${prefix}visible {
|
59 | display: flex;
|
60 | }
|
61 |
|
62 | #${prefix}container.${prefix}building {
|
63 | bottom: 20px;
|
64 | opacity: 1;
|
65 | }
|
66 |
|
67 | #${prefix}icon-wrapper {
|
68 | width: 16px;
|
69 | height: 16px;
|
70 | }
|
71 |
|
72 | #${prefix}icon-wrapper > svg {
|
73 | width: 100%;
|
74 | height: 100%;
|
75 | }
|
76 |
|
77 | #${prefix}icon-group {
|
78 | animation: ${prefix}strokedash 1s ease-in-out both infinite;
|
79 | }
|
80 |
|
81 | @keyframes ${prefix}fade-in {
|
82 | from {
|
83 | bottom: 10px;
|
84 | opacity: 0;
|
85 | }
|
86 | to {
|
87 | bottom: 20px;
|
88 | opacity: 1;
|
89 | }
|
90 | }
|
91 |
|
92 | @keyframes ${prefix}strokedash {
|
93 | 0% {
|
94 | stroke-dasharray: 0 226;
|
95 | }
|
96 | 80%,
|
97 | 100% {
|
98 | stroke-dasharray: 659 226;
|
99 | }
|
100 | }
|
101 | `;return css;}
|
102 |
|
\ | No newline at end of file |