UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

5 lines 13.4 kB
export const __webpack_ids__=["55964"];export const __webpack_modules__={73729:function(e,t,i){i.d(t,{i:()=>h});var o=i(44249),a=i(72621),r=i(74966),s=i(51408),l=i(57243),d=i(15093),n=i(76525);i(23334);const c=["button","ha-list-item"],h=(e,t)=>l.dy` <div class="header_title"> <ha-icon-button .label="${e?.localize("ui.common.close")??"Close"}" .path="${"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"}" dialogAction="close" class="header_button"></ha-icon-button> <span>${t}</span> </div> `;(0,o.Z)([(0,d.Mo)("ha-dialog")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:n.gA,value:void 0},{kind:"method",key:"scrollToPos",value:function(e,t){this.contentElement?.scrollTo(e,t)}},{kind:"method",key:"renderHeading",value:function(){return l.dy`<slot name="heading"> ${(0,a.Z)(i,"renderHeading",this,3)([])} </slot>`}},{kind:"method",key:"firstUpdated",value:function(){(0,a.Z)(i,"firstUpdated",this,3)([]),this.suppressDefaultPressSelector=[this.suppressDefaultPressSelector,c].join(", "),this._updateScrolledAttribute(),this.contentElement?.addEventListener("scroll",this._onScroll,{passive:!0})}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(i,"disconnectedCallback",this,3)([]),this.contentElement.removeEventListener("scroll",this._onScroll)}},{kind:"field",key:"_onScroll",value(){return()=>{this._updateScrolledAttribute()}}},{kind:"method",key:"_updateScrolledAttribute",value:function(){this.contentElement&&this.toggleAttribute("scrolled",0!==this.contentElement.scrollTop)}},{kind:"field",static:!0,key:"styles",value:()=>[s.W,l.iv`:host([scrolled]) ::slotted(ha-dialog-header){border-bottom:1px solid var(--mdc-dialog-scroll-divider-color,rgba(0,0,0,.12))}.mdc-dialog{--mdc-dialog-scroll-divider-color:var( --dialog-scroll-divider-color, var(--divider-color) );z-index:var(--dialog-z-index,8);-webkit-backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));--mdc-dialog-box-shadow:var(--dialog-box-shadow, none);--mdc-typography-headline6-font-weight:400;--mdc-typography-headline6-font-size:1.574rem}.mdc-dialog__actions{justify-content:var(--justify-action-buttons,flex-end);padding-bottom:max(env(safe-area-inset-bottom),24px)}.mdc-dialog__actions span:first-child{flex:var(--secondary-action-button-flex,unset)}.mdc-dialog__actions span:nth-child(2){flex:var(--primary-action-button-flex,unset)}.mdc-dialog__container{align-items:var(--vertical-align-dialog,center)}.mdc-dialog__title{padding:24px 24px 0 24px}.mdc-dialog__title:has(span){padding:12px 12px 0}.mdc-dialog__actions{padding:12px 24px 12px 24px}.mdc-dialog__title::before{content:unset}.mdc-dialog .mdc-dialog__content{position:var(--dialog-content-position,relative);padding:var(--dialog-content-padding,24px)}:host([hideactions]) .mdc-dialog .mdc-dialog__content{padding-bottom:max(var(--dialog-content-padding,24px),env(safe-area-inset-bottom))}.mdc-dialog .mdc-dialog__surface{position:var(--dialog-surface-position,relative);top:var(--dialog-surface-top);margin-top:var(--dialog-surface-margin-top);min-height:var(--mdc-dialog-min-height,auto);border-radius:var(--ha-dialog-border-radius,28px);-webkit-backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);background:var(--ha-dialog-surface-background,var(--mdc-theme-surface,#fff))}:host([flexContent]) .mdc-dialog .mdc-dialog__content{display:flex;flex-direction:column}.header_title{display:flex;align-items:center;direction:var(--direction)}.header_title span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;padding-left:4px}.header_button{text-decoration:none;color:inherit;inset-inline-start:initial;inset-inline-end:-12px;direction:var(--direction)}.dialog-actions{inset-inline-start:initial!important;inset-inline-end:0px!important;direction:var(--direction)}`]}]}}),r.M)},96e3:function(e,t,i){var o=i(44249),a=i(72621),r=(i(75656),i(50100),i(18084),i(57243)),s=i(15093),l=i(36522),d=i(76320),n=(i(99426),i(99650)),c=i(72344);(0,o.Z)([(0,s.Mo)("ha-hls-player")],(function(e,t){class o extends t{constructor(...t){super(...t),e(this)}}return{F:o,d:[{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"entityid",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"url",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:"poster-url"})],key:"posterUrl",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"controls"})],key:"controls",value:()=>!1},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"muted"})],key:"muted",value:()=>!1},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"autoplay"})],key:"autoPlay",value:()=>!1},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"playsinline"})],key:"playsInline",value:()=>!1},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"allow-exoplayer"})],key:"allowExoPlayer",value:()=>!1},{kind:"field",decorators:[(0,s.IO)("video")],key:"_videoEl",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_errorIsFatal",value:()=>!1},{kind:"field",decorators:[(0,s.SB)()],key:"_url",value:void 0},{kind:"field",key:"_hlsPolyfillInstance",value:void 0},{kind:"field",key:"_exoPlayer",value:()=>!1},{kind:"field",static:!0,key:"streamCount",value:()=>0},{kind:"method",key:"connectedCallback",value:function(){(0,a.Z)(o,"connectedCallback",this,3)([]),o.streamCount+=1,this.hasUpdated&&(this._resetError(),this._startHls())}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(o,"disconnectedCallback",this,3)([]),o.streamCount-=1,this._cleanUp()}},{kind:"method",key:"render",value:function(){return r.dy` ${this._error?r.dy`<ha-alert alert-type="error" class="${this._errorIsFatal?"fatal":"retry"}"> ${this._error} </ha-alert>`:""} ${this._errorIsFatal?"":r.dy`<video .poster="${this.posterUrl}" ?autoplay="${this.autoPlay}" .muted="${this.muted}" ?playsinline="${this.playsInline}" ?controls="${this.controls}" @loadeddata="${this._loadedData}"></video>`} `}},{kind:"method",key:"updated",value:function(e){(0,a.Z)(o,"updated",this,3)([e]);const t=e.has("entityid"),i=e.has("url");t?this._getStreamUrlFromEntityId():i&&this.url&&(this._cleanUp(),this._resetError(),this._url=this.url,this._startHls())}},{kind:"method",key:"_getStreamUrlFromEntityId",value:async function(){if(this._cleanUp(),this._resetError(),(0,c.p)(this.hass,"stream")){if(this.entityid)try{const{url:e}=await(0,n.Lr)(this.hass,this.entityid);this._url=this.hass.hassUrl(e),this._cleanUp(),this._resetError(),this._startHls()}catch(e){console.error(e),(0,l.B)(this,"streams",{hasAudio:!1,hasVideo:!1})}}else this._setFatalError("Streaming component is not loaded.")}},{kind:"method",key:"_startHls",value:async function(){const e=fetch(this._url),t=(await Promise.all([i.e("83895"),i.e("66095")]).then(i.bind(i,17231))).default;if(!this.isConnected)return;let o=t.isSupported();if(o||(o=""!==this._videoEl.canPlayType("application/vnd.apple.mpegurl")),!o)return void this._setFatalError(this.hass.localize("ui.components.media-browser.video_not_supported"));const a=this.allowExoPlayer&&this.hass.auth.external?.config.hasExoPlayer,r=await(await e).text();if(!this.isConnected)return;const s=/#EXT-X-STREAM-INF:.*?(?:CODECS=".*?([^.]*)?\..*?,([^.]*)?\..*?".*?)?(?:\n|\r\n)(.+)/g,l=s.exec(r),d=s.exec(r);let n;n=null!==l&&null===d?new URL(l[3],this._url).href:this._url;const c=l?`${l[1]},${l[2]}`:void 0;this._reportStreams(c),a&&(c?.includes("hevc")||c?.includes("hev1"))?this._renderHLSExoPlayer(n):t.isSupported()?this._renderHLSPolyfill(this._videoEl,t,n):this._renderHLSNative(this._videoEl,n)}},{kind:"method",key:"_renderHLSExoPlayer",value:async function(e){this._exoPlayer=!0,window.addEventListener("resize",this._resizeExoPlayer),this.updateComplete.then((()=>(0,d.y)())).then(this._resizeExoPlayer),this._videoEl.style.visibility="hidden",await this.hass.auth.external.fireMessage({type:"exoplayer/play_hls",payload:{url:e,muted:this.muted}})}},{kind:"field",key:"_resizeExoPlayer",value(){return()=>{if(!this._videoEl)return;const e=this._videoEl.getBoundingClientRect();this.hass.auth.external.fireMessage({type:"exoplayer/resize",payload:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})}}},{kind:"method",key:"_isLLHLSSupported",value:function(){if(o.streamCount<=2)return!0;if(!("performance"in window)||0===performance.getEntriesByType("resource").length)return!1;const e=performance.getEntriesByType("resource")[0];return"nextHopProtocol"in e&&"h2"===e.nextHopProtocol}},{kind:"method",key:"_renderHLSPolyfill",value:async function(e,t,i){const o=new t({backBufferLength:60,fragLoadingTimeOut:3e4,manifestLoadingTimeOut:3e4,levelLoadingTimeOut:3e4,maxLiveSyncPlaybackRate:2,lowLatencyMode:this._isLLHLSSupported()});this._hlsPolyfillInstance=o,o.attachMedia(e),o.on(t.Events.MEDIA_ATTACHED,(()=>{this._resetError(),o.loadSource(i)})),o.on(t.Events.FRAG_LOADED,((e,t)=>{this._resetError()})),o.on(t.Events.ERROR,((e,i)=>{if(i.fatal)if(i.type===t.ErrorTypes.NETWORK_ERROR){switch(i.details){case t.ErrorDetails.MANIFEST_LOAD_ERROR:{let e="Error starting stream, see logs for details";void 0!==i.response&&void 0!==i.response.code&&(i.response.code>=500?e+=" (Server failure)":i.response.code>=400?e+=" (Stream never started)":e+=" ("+i.response.code+")"),this._setRetryableError(e);break}case t.ErrorDetails.MANIFEST_LOAD_TIMEOUT:this._setRetryableError("Timeout while starting stream");break;default:this._setRetryableError("Stream network error")}o.startLoad()}else i.type===t.ErrorTypes.MEDIA_ERROR?(this._setRetryableError("Error with media stream contents"),o.recoverMediaError()):this._setFatalError("Error playing stream")}))}},{kind:"method",key:"_renderHLSNative",value:async function(e,t){e.src=t,e.addEventListener("loadedmetadata",(()=>{e.play()}))}},{kind:"method",key:"_cleanUp",value:function(){this._hlsPolyfillInstance&&(this._hlsPolyfillInstance.destroy(),this._hlsPolyfillInstance=void 0),this._exoPlayer&&(window.removeEventListener("resize",this._resizeExoPlayer),this.hass.auth.external.fireMessage({type:"exoplayer/stop"}),this._exoPlayer=!1),this._videoEl&&(this._videoEl.removeAttribute("src"),this._videoEl.load())}},{kind:"method",key:"_resetError",value:function(){this._error=void 0,this._errorIsFatal=!1}},{kind:"method",key:"_setFatalError",value:function(e){this._error=e,this._errorIsFatal=!0,(0,l.B)(this,"streams",{hasAudio:!1,hasVideo:!1})}},{kind:"method",key:"_setRetryableError",value:function(e){this._error=e,this._errorIsFatal=!1,(0,l.B)(this,"streams",{hasAudio:!1,hasVideo:!1})}},{kind:"method",key:"_reportStreams",value:function(e){const t=e?.split(",");(0,l.B)(this,"streams",{hasAudio:t?.includes("mp4a")??!1,hasVideo:t?.includes("mp4a")?t?.length>1:Boolean(t?.length)})}},{kind:"method",key:"_loadedData",value:function(){(0,l.B)(this,"load")}},{kind:"field",static:!0,key:"styles",value:()=>r.iv`:host,video{display:block}video{width:100%;max-height:var(--video-max-height,calc(100vh - 97px))}.fatal{display:block;padding:100px 16px}.retry{display:block}`}]}}),r.oi)},5486:function(e,t,i){i.r(t),i.d(t,{HuiDialogWebBrowserPlayMedia:()=>n});var o=i(44249),a=i(57243),r=i(15093),s=i(36522),l=i(73729),d=(i(96e3),i(28008));let n=(0,o.Z)([(0,r.Mo)("hui-dialog-web-browser-play-media")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_params",value:void 0},{kind:"method",key:"showDialog",value:function(e){this._params=e}},{kind:"method",key:"closeDialog",value:function(){this._params=void 0,(0,s.B)(this,"dialog-closed",{dialog:this.localName})}},{kind:"method",key:"render",value:function(){if(!this._params||!this._params.sourceType||!this._params.sourceUrl)return a.Ld;const e=this._params.sourceType.split("/",1)[0];return a.dy` <ha-dialog open hideActions .heading="${(0,l.i)(this.hass,this._params.title||this.hass.localize("ui.components.media-browser.media_player"))}" @closed="${this.closeDialog}"> ${"audio"===e?a.dy` <audio controls autoplay> <source src="${this._params.sourceUrl}" type="${this._params.sourceType}"> ${this.hass.localize("ui.components.media-browser.audio_not_supported")} </audio> `:"video"===e?a.dy` <video controls autoplay playsinline> <source src="${this._params.sourceUrl}" type="${this._params.sourceType}"> ${this.hass.localize("ui.components.media-browser.video_not_supported")} </video> `:"application/x-mpegURL"===this._params.sourceType?a.dy` <ha-hls-player controls autoplay playsinline .hass="${this.hass}" .url="${this._params.sourceUrl}"></ha-hls-player> `:"image"===e?a.dy`<img alt="${this._params.title||a.Ld}" src="${this._params.sourceUrl}">`:a.dy`${this.hass.localize("ui.components.media-browser.media_not_supported")}`} </ha-dialog> `}},{kind:"get",static:!0,key:"styles",value:function(){return[d.yu,a.iv`@media (min-width:800px){ha-dialog{--mdc-dialog-max-width:800px;--mdc-dialog-min-width:400px}}audio,img,video{outline:0;width:100%}`]}}]}}),a.oi)}}; //# sourceMappingURL=55964.731ac83081d9b3fc.js.map