home-assistant-query-selector 6.2.0 → 7.0.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -15
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{asyncQuerySelector as e,AsyncSelector as t}from"shadow-dom-selector";const _="$",s={retries:100,delay:50,shouldReject:!1,eventThreshold:450};var o,O,n,
|
|
1
|
+
import{asyncQuerySelector as e,AsyncSelector as t}from"shadow-dom-selector";const _="$",s={retries:100,delay:50,shouldReject:!1,eventThreshold:450};var o,O,i,n,a;!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR",e.PARTIAL_PANEL_RESOLVER="PARTIAL_PANEL_RESOLVER"}(o||(o={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(O||(O={})),function(e){e.HA_MORE_INFO_DIALOG="HA_MORE_INFO_DIALOG",e.HA_DIALOG="HA_DIALOG",e.HA_DIALOG_CONTENT="HA_DIALOG_CONTENT",e.HA_MORE_INFO_DIALOG_INFO="HA_MORE_INFO_DIALOG_INFO",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK",e.HA_DIALOG_MORE_INFO_SETTINGS="HA_DIALOG_MORE_INFO_SETTINGS"}(i||(i={})),function(e){e.ON_LISTEN="onListen",e.ON_PANEL_LOAD="onPanelLoad",e.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",e.ON_MORE_INFO_DIALOG_OPEN="onMoreInfoDialogOpen",e.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onHistoryAndLogBookDialogOpen",e.ON_SETTINGS_DIALOG_OPEN="onSettingsDialogOpen"}(n||(n={})),function(e){e.HOME_ASSISTANT="home-assistant",e.HOME_ASSISTANT_MAIN="home-assistant-main",e.HA_DRAWER="ha-drawer",e.HA_SIDEBAR="ha-sidebar",e.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HUI_ROOT="hui-root",e.HEADER=".header",e.HUI_VIEW="hui-view",e.HA_MORE_INFO_DIALOG="ha-more-info-dialog",e.HA_DIALOG="ha-dialog",e.HA_ADAPTATIVE_DIALOG="ha-adaptive-dialog",e.HA_DIALOG_CONTENT=".content",e.HA_MORE_INFO_DIALOG_INFO="ha-more-info-info",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",e.HA_DIALOG_MORE_INFO_SETTINGS="ha-more-info-settings",e.DIV="div",e.FIRST_CHILD=":scope > *"}(a||(a={}));const A={[o.HOME_ASSISTANT]:{selector:a.HOME_ASSISTANT,children:{shadowRoot:{selector:_,children:{[o.HOME_ASSISTANT_MAIN]:{selector:a.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:_,children:{[o.HA_DRAWER]:{selector:a.HA_DRAWER,children:{[o.HA_SIDEBAR]:{selector:a.HA_SIDEBAR,children:{shadowRoot:{selector:_}}},[o.PARTIAL_PANEL_RESOLVER]:{selector:a.PARTIAL_PANEL_RESOLVER}}}}}}}}}}}},r={[O.HA_PANEL_LOVELACE]:{selector:a.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:_,children:{[O.HUI_ROOT]:{selector:a.HUI_ROOT,children:{shadowRoot:{selector:_,children:{[O.HEADER]:{selector:a.HEADER},[O.HUI_VIEW]:{selector:a.HUI_VIEW}}}}}}}}}},l={shadowRoot:{selector:_,children:{[i.HA_MORE_INFO_DIALOG]:{selector:a.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:_,children:{[i.HA_DIALOG]:{selector:`${a.HA_ADAPTATIVE_DIALOG}, ${a.HA_DIALOG}`,children:{[i.HA_DIALOG_CONTENT]:{selector:a.HA_DIALOG_CONTENT,children:{[i.HA_MORE_INFO_DIALOG_INFO]:{selector:a.HA_MORE_INFO_DIALOG_INFO},[i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:{selector:a.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},[i.HA_DIALOG_MORE_INFO_SETTINGS]:{selector:a.HA_DIALOG_MORE_INFO_SETTINGS}}}}}}}}}}}};"function"==typeof SuppressedError&&SuppressedError;const h=(s,o,O,i=!1)=>Object.entries(o||{}).reduce((o,n)=>{const[a,A]=n;if(A.selector===_&&O)return A.children?Object.assign(Object.assign({},o),h(s,A.children,O,!0)):o;const r=O?O.then(t=>{return t?e(t,(_=A.selector,i?"$ "+_:_),s):null;var _}):e(A.selector,s);return o[a]={element:r,children:h(s,A.children,r),selector:new t(r,s)},o},{}),E=(e,t)=>{const _=Object.entries(t);for(const t of _){if(t[0]===e)return t[1];{const _=E(e,t[1].children);if(_)return _}}},c=(e,t)=>Object.keys(e).reduce((e,_)=>{const s=E(_,t);if(s){const{children:t}=s,o=function(e,t){var _={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(_[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(_[s[o]]=e[s[o]])}return _}(s,["children"]);e[_]=Object.assign({},o)}return e},{});class I{constructor(){this.delegate=document.createDocumentFragment()}addEventListener(...e){this.delegate.addEventListener(...e)}dispatchEvent(...e){return this.delegate.dispatchEvent(...e)}removeEventListener(...e){return this.delegate.removeEventListener(...e)}}class d extends I{constructor(e={}){super(),this._config=Object.assign(Object.assign({},s),e),this._timestaps={}}_dispatchEvent(e,t){const _=Date.now();this._timestaps[e]&&_-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=_,this.dispatchEvent(new CustomEvent(e,{detail:t})))}_updateDialogElements(e=i.HA_MORE_INFO_DIALOG_INFO){this._dialogTree=h(this._config,l,this._haRootElements.HOME_ASSISTANT.element);const t=c(i,this._dialogTree);t.HA_DIALOG_CONTENT.element.then(e=>{this._dialogsContentObserver.disconnect(),this._dialogsContentObserver.observe(e,{childList:!0})}),this._haDialogElements=((e,t)=>[i.HA_MORE_INFO_DIALOG,i.HA_DIALOG,i.HA_DIALOG_CONTENT,t].reduce((t,_)=>(t[_]=e[_],t),{}))(t,e);const _={[i.HA_MORE_INFO_DIALOG_INFO]:n.ON_MORE_INFO_DIALOG_OPEN,[i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:n.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,[i.HA_DIALOG_MORE_INFO_SETTINGS]:n.ON_SETTINGS_DIALOG_OPEN};this._dispatchEvent(_[e],this._haDialogElements)}_updateRootElements(){this._homeAssistantRootTree=h(this._config,A),this._haRootElements=c(o,this._homeAssistantRootTree),this._haRootElements[o.HOME_ASSISTANT].selector.$.element.then(e=>{this._dialogsObserver.disconnect(),this._dialogsObserver.observe(e,{childList:!0})}),this._haRootElements[o.PARTIAL_PANEL_RESOLVER].element.then(e=>{this._panelResolverObserver.disconnect(),e&&this._panelResolverObserver.observe(e,{subtree:!0,childList:!0})}),this._dispatchEvent(n.ON_LISTEN,this._haRootElements),this._dispatchEvent(n.ON_PANEL_LOAD,this._haRootElements)}_updateLovelaceElements(){this._homeAssistantResolverTree=h(this._config,r,this._haRootElements[o.HA_DRAWER].element),this._haResolverElements=c(O,this._homeAssistantResolverTree),this._haResolverElements[O.HA_PANEL_LOVELACE].element.then(e=>{this._lovelaceObserver.disconnect(),e&&(this._lovelaceObserver.observe(e.shadowRoot,{childList:!0}),this._dispatchEvent(n.ON_LOVELACE_PANEL_LOAD,Object.assign(Object.assign({},this._haRootElements),this._haResolverElements)))})}_watchDialogs(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{e instanceof Element&&e.localName===a.HA_MORE_INFO_DIALOG&&(this._dialogsChildrenObserver.disconnect(),this._dialogsChildrenObserver.observe(e.shadowRoot,{childList:!0}),this._updateDialogElements())})})}_watchDialogsChildren(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{const t=[`${a.HA_DIALOG}`,`${a.HA_ADAPTATIVE_DIALOG}`];e instanceof Element&&t.includes(e.localName)&&this._updateDialogElements()})})}_watchDialogsContent(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{const t={[a.HA_MORE_INFO_DIALOG_INFO]:i.HA_MORE_INFO_DIALOG_INFO,[a.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,[a.HA_DIALOG_MORE_INFO_SETTINGS]:i.HA_DIALOG_MORE_INFO_SETTINGS};if(e instanceof Element&&e.localName)if(e.localName===a.DIV){const _=e.querySelector(a.FIRST_CHILD);if(_&&_.localName in t){const e=_.localName;this._updateDialogElements(t[e])}}else if(e.localName in t){const _=e.localName;this._updateDialogElements(t[_])}})})}_watchDashboards(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{this._dispatchEvent(n.ON_PANEL_LOAD,this._haRootElements),e instanceof Element&&e.localName===a.HA_PANEL_LOVELACE&&this._updateLovelaceElements()})})}_watchLovelace(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{e instanceof Element&&e.localName===a.HUI_ROOT&&this._updateLovelaceElements()})})}listen(){this._watchDialogsBinded=this._watchDialogs.bind(this),this._watchDialogsChildrenBinded=this._watchDialogsChildren.bind(this),this._watchDialogsContentBinded=this._watchDialogsContent.bind(this),this._watchDashboardsBinded=this._watchDashboards.bind(this),this._watchLovelaceBinded=this._watchLovelace.bind(this),this._dialogsObserver=new MutationObserver(this._watchDialogsBinded),this._dialogsChildrenObserver=new MutationObserver(this._watchDialogsChildrenBinded),this._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()}addEventListener(e,t,_){super.addEventListener(e,t,_)}}export{d as HAQuerySelector,n as HAQuerySelectorEvent};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("shadow-dom-selector");const t="$",s={retries:100,delay:50,shouldReject:!1,eventThreshold:450};var _,o,O,n,i;!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR",e.PARTIAL_PANEL_RESOLVER="PARTIAL_PANEL_RESOLVER"}(_||(_={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(o||(o={})),function(e){e.HA_MORE_INFO_DIALOG="HA_MORE_INFO_DIALOG",e.HA_DIALOG="HA_DIALOG",e.HA_DIALOG_CONTENT="HA_DIALOG_CONTENT",e.HA_MORE_INFO_DIALOG_INFO="HA_MORE_INFO_DIALOG_INFO",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK",e.HA_DIALOG_MORE_INFO_SETTINGS="HA_DIALOG_MORE_INFO_SETTINGS"}(O||(O={})),exports.HAQuerySelectorEvent=void 0,(n=exports.HAQuerySelectorEvent||(exports.HAQuerySelectorEvent={})).ON_LISTEN="onListen",n.ON_PANEL_LOAD="onPanelLoad",n.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",n.ON_MORE_INFO_DIALOG_OPEN="onMoreInfoDialogOpen",n.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onHistoryAndLogBookDialogOpen",n.ON_SETTINGS_DIALOG_OPEN="onSettingsDialogOpen",function(e){e.HOME_ASSISTANT="home-assistant",e.HOME_ASSISTANT_MAIN="home-assistant-main",e.HA_DRAWER="ha-drawer",e.HA_SIDEBAR="ha-sidebar",e.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HUI_ROOT="hui-root",e.HEADER=".header",e.HUI_VIEW="hui-view",e.HA_MORE_INFO_DIALOG="ha-more-info-dialog",e.HA_DIALOG="ha-dialog",e.HA_ADAPTATIVE_DIALOG="ha-adaptive-dialog",e.HA_DIALOG_CONTENT=".content",e.HA_MORE_INFO_DIALOG_INFO="ha-more-info-info",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",e.HA_DIALOG_MORE_INFO_SETTINGS="ha-more-info-settings"}(i||(i={}));const r={[_.HOME_ASSISTANT]:{selector:i.HOME_ASSISTANT,children:{shadowRoot:{selector:t,children:{[_.HOME_ASSISTANT_MAIN]:{selector:i.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:t,children:{[_.HA_DRAWER]:{selector:i.HA_DRAWER,children:{[_.HA_SIDEBAR]:{selector:i.HA_SIDEBAR,children:{shadowRoot:{selector:t}}},[_.PARTIAL_PANEL_RESOLVER]:{selector:i.PARTIAL_PANEL_RESOLVER}}}}}}}}}}}},A={[o.HA_PANEL_LOVELACE]:{selector:i.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:t,children:{[o.HUI_ROOT]:{selector:i.HUI_ROOT,children:{shadowRoot:{selector:t,children:{[o.HEADER]:{selector:i.HEADER},[o.HUI_VIEW]:{selector:i.HUI_VIEW}}}}}}}}}},a={shadowRoot:{selector:t,children:{[O.HA_MORE_INFO_DIALOG]:{selector:i.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:t,children:{[O.HA_DIALOG]:{selector:`${i.HA_ADAPTATIVE_DIALOG}, ${i.HA_DIALOG}`,children:{[O.HA_DIALOG_CONTENT]:{selector:i.HA_DIALOG_CONTENT,children:{[O.HA_MORE_INFO_DIALOG_INFO]:{selector:i.HA_MORE_INFO_DIALOG_INFO},[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:{selector:i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},[O.HA_DIALOG_MORE_INFO_SETTINGS]:{selector:i.HA_DIALOG_MORE_INFO_SETTINGS}}}}}}}}}}}};"function"==typeof SuppressedError&&SuppressedError;const l=(s,_,o,O=!1)=>Object.entries(_||{}).reduce((_,n)=>{const[i,r]=n;if(r.selector===t&&o)return r.children?Object.assign(Object.assign({},_),l(s,r.children,o,!0)):_;const A=o?o.then(t=>{return t?e.asyncQuerySelector(t,(_=r.selector,O?"$ "+_:_),s):null;var _}):e.asyncQuerySelector(r.selector,s);return _[i]={element:A,children:l(s,r.children,A),selector:new e.AsyncSelector(A,s)},_},{}),E=(e,t)=>{const s=Object.entries(t);for(const t of s){if(t[0]===e)return t[1];{const s=E(e,t[1].children);if(s)return s}}},h=(e,t)=>Object.keys(e).reduce((e,s)=>{const _=E(s,t);if(_){const{children:t}=_,o=function(e,t){var s={};for(var _ in e)Object.prototype.hasOwnProperty.call(e,_)&&t.indexOf(_)<0&&(s[_]=e[_]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(_=Object.getOwnPropertySymbols(e);o<_.length;o++)t.indexOf(_[o])<0&&Object.prototype.propertyIsEnumerable.call(e,_[o])&&(s[_[o]]=e[_[o]])}return s}(_,["children"]);e[s]=Object.assign({},o)}return e},{});class c{constructor(){this.delegate=document.createDocumentFragment()}addEventListener(...e){this.delegate.addEventListener(...e)}dispatchEvent(...e){return this.delegate.dispatchEvent(...e)}removeEventListener(...e){return this.delegate.removeEventListener(...e)}}exports.HAQuerySelector=class extends c{constructor(e={}){super(),this._config=Object.assign(Object.assign({},s),e),this._timestaps={}}_dispatchEvent(e,t){const s=Date.now();this._timestaps[e]&&s-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=s,this.dispatchEvent(new CustomEvent(e,{detail:t})))}_updateDialogElements(e=O.HA_MORE_INFO_DIALOG_INFO){this._dialogTree=l(this._config,a,this._haRootElements.HOME_ASSISTANT.element);const t=h(O,this._dialogTree);t.HA_DIALOG_CONTENT.element.then(e=>{this._dialogsContentObserver.disconnect(),this._dialogsContentObserver.observe(e,{childList:!0})}),this._haDialogElements=((e,t)=>[O.HA_MORE_INFO_DIALOG,O.HA_DIALOG,O.HA_DIALOG_CONTENT,t].reduce((t,s)=>(t[s]=e[s],t),{}))(t,e);const s={[O.HA_MORE_INFO_DIALOG_INFO]:exports.HAQuerySelectorEvent.ON_MORE_INFO_DIALOG_OPEN,[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:exports.HAQuerySelectorEvent.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,[O.HA_DIALOG_MORE_INFO_SETTINGS]:exports.HAQuerySelectorEvent.ON_SETTINGS_DIALOG_OPEN};this._dispatchEvent(s[e],this._haDialogElements)}_updateRootElements(){this._homeAssistantRootTree=l(this._config,r),this._haRootElements=h(_,this._homeAssistantRootTree),this._haRootElements[_.HOME_ASSISTANT].selector.$.element.then(e=>{this._dialogsObserver.disconnect(),this._dialogsObserver.observe(e,{childList:!0})}),this._haRootElements[_.PARTIAL_PANEL_RESOLVER].element.then(e=>{this._panelResolverObserver.disconnect(),e&&this._panelResolverObserver.observe(e,{subtree:!0,childList:!0})}),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LISTEN,this._haRootElements),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,this._haRootElements)}_updateLovelaceElements(){this._homeAssistantResolverTree=l(this._config,A,this._haRootElements[_.HA_DRAWER].element),this._haResolverElements=h(o,this._homeAssistantResolverTree),this._haResolverElements[o.HA_PANEL_LOVELACE].element.then(e=>{this._lovelaceObserver.disconnect(),e&&(this._lovelaceObserver.observe(e.shadowRoot,{childList:!0}),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD,Object.assign(Object.assign({},this._haRootElements),this._haResolverElements)))})}_watchDialogs(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{e instanceof Element&&e.localName===i.HA_MORE_INFO_DIALOG&&(this._dialogsChildrenObserver.disconnect(),this._dialogsChildrenObserver.observe(e.shadowRoot,{childList:!0}),this._updateDialogElements())})})}_watchDialogsChildren(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{const t=[`${i.HA_DIALOG}`,`${i.HA_ADAPTATIVE_DIALOG}`];e instanceof Element&&t.includes(e.localName)&&this._updateDialogElements()})})}_watchDialogsContent(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{const t={[i.HA_MORE_INFO_DIALOG_INFO]:O.HA_MORE_INFO_DIALOG_INFO,[i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,[i.HA_DIALOG_MORE_INFO_SETTINGS]:O.HA_DIALOG_MORE_INFO_SETTINGS};if(e instanceof Element&&e.localName&&e.localName in t){const s=e.localName;this._updateDialogElements(t[s])}})})}_watchDashboards(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{this._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,this._haRootElements),e instanceof Element&&e.localName===i.HA_PANEL_LOVELACE&&this._updateLovelaceElements()})})}_watchLovelace(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{e instanceof Element&&e.localName===i.HUI_ROOT&&this._updateLovelaceElements()})})}listen(){this._watchDialogsBinded=this._watchDialogs.bind(this),this._watchDialogsChildrenBinded=this._watchDialogsChildren.bind(this),this._watchDialogsContentBinded=this._watchDialogsContent.bind(this),this._watchDashboardsBinded=this._watchDashboards.bind(this),this._watchLovelaceBinded=this._watchLovelace.bind(this),this._dialogsObserver=new MutationObserver(this._watchDialogsBinded),this._dialogsChildrenObserver=new MutationObserver(this._watchDialogsChildrenBinded),this._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()}addEventListener(e,t,s){super.addEventListener(e,t,s)}};
|
|
1
|
+
"use strict";var e=require("shadow-dom-selector");const t="$",s={retries:100,delay:50,shouldReject:!1,eventThreshold:450};var _,o,O,n,i;!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR",e.PARTIAL_PANEL_RESOLVER="PARTIAL_PANEL_RESOLVER"}(_||(_={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(o||(o={})),function(e){e.HA_MORE_INFO_DIALOG="HA_MORE_INFO_DIALOG",e.HA_DIALOG="HA_DIALOG",e.HA_DIALOG_CONTENT="HA_DIALOG_CONTENT",e.HA_MORE_INFO_DIALOG_INFO="HA_MORE_INFO_DIALOG_INFO",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK",e.HA_DIALOG_MORE_INFO_SETTINGS="HA_DIALOG_MORE_INFO_SETTINGS"}(O||(O={})),exports.HAQuerySelectorEvent=void 0,(n=exports.HAQuerySelectorEvent||(exports.HAQuerySelectorEvent={})).ON_LISTEN="onListen",n.ON_PANEL_LOAD="onPanelLoad",n.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",n.ON_MORE_INFO_DIALOG_OPEN="onMoreInfoDialogOpen",n.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onHistoryAndLogBookDialogOpen",n.ON_SETTINGS_DIALOG_OPEN="onSettingsDialogOpen",function(e){e.HOME_ASSISTANT="home-assistant",e.HOME_ASSISTANT_MAIN="home-assistant-main",e.HA_DRAWER="ha-drawer",e.HA_SIDEBAR="ha-sidebar",e.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",e.HA_PANEL_LOVELACE="ha-panel-lovelace",e.HUI_ROOT="hui-root",e.HEADER=".header",e.HUI_VIEW="hui-view",e.HA_MORE_INFO_DIALOG="ha-more-info-dialog",e.HA_DIALOG="ha-dialog",e.HA_ADAPTATIVE_DIALOG="ha-adaptive-dialog",e.HA_DIALOG_CONTENT=".content",e.HA_MORE_INFO_DIALOG_INFO="ha-more-info-info",e.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",e.HA_DIALOG_MORE_INFO_SETTINGS="ha-more-info-settings",e.DIV="div",e.FIRST_CHILD=":scope > *"}(i||(i={}));const r={[_.HOME_ASSISTANT]:{selector:i.HOME_ASSISTANT,children:{shadowRoot:{selector:t,children:{[_.HOME_ASSISTANT_MAIN]:{selector:i.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:t,children:{[_.HA_DRAWER]:{selector:i.HA_DRAWER,children:{[_.HA_SIDEBAR]:{selector:i.HA_SIDEBAR,children:{shadowRoot:{selector:t}}},[_.PARTIAL_PANEL_RESOLVER]:{selector:i.PARTIAL_PANEL_RESOLVER}}}}}}}}}}}},A={[o.HA_PANEL_LOVELACE]:{selector:i.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:t,children:{[o.HUI_ROOT]:{selector:i.HUI_ROOT,children:{shadowRoot:{selector:t,children:{[o.HEADER]:{selector:i.HEADER},[o.HUI_VIEW]:{selector:i.HUI_VIEW}}}}}}}}}},a={shadowRoot:{selector:t,children:{[O.HA_MORE_INFO_DIALOG]:{selector:i.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:t,children:{[O.HA_DIALOG]:{selector:`${i.HA_ADAPTATIVE_DIALOG}, ${i.HA_DIALOG}`,children:{[O.HA_DIALOG_CONTENT]:{selector:i.HA_DIALOG_CONTENT,children:{[O.HA_MORE_INFO_DIALOG_INFO]:{selector:i.HA_MORE_INFO_DIALOG_INFO},[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:{selector:i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},[O.HA_DIALOG_MORE_INFO_SETTINGS]:{selector:i.HA_DIALOG_MORE_INFO_SETTINGS}}}}}}}}}}}};"function"==typeof SuppressedError&&SuppressedError;const l=(s,_,o,O=!1)=>Object.entries(_||{}).reduce((_,n)=>{const[i,r]=n;if(r.selector===t&&o)return r.children?Object.assign(Object.assign({},_),l(s,r.children,o,!0)):_;const A=o?o.then(t=>{return t?e.asyncQuerySelector(t,(_=r.selector,O?"$ "+_:_),s):null;var _}):e.asyncQuerySelector(r.selector,s);return _[i]={element:A,children:l(s,r.children,A),selector:new e.AsyncSelector(A,s)},_},{}),E=(e,t)=>{const s=Object.entries(t);for(const t of s){if(t[0]===e)return t[1];{const s=E(e,t[1].children);if(s)return s}}},h=(e,t)=>Object.keys(e).reduce((e,s)=>{const _=E(s,t);if(_){const{children:t}=_,o=function(e,t){var s={};for(var _ in e)Object.prototype.hasOwnProperty.call(e,_)&&t.indexOf(_)<0&&(s[_]=e[_]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(_=Object.getOwnPropertySymbols(e);o<_.length;o++)t.indexOf(_[o])<0&&Object.prototype.propertyIsEnumerable.call(e,_[o])&&(s[_[o]]=e[_[o]])}return s}(_,["children"]);e[s]=Object.assign({},o)}return e},{});class c{constructor(){this.delegate=document.createDocumentFragment()}addEventListener(...e){this.delegate.addEventListener(...e)}dispatchEvent(...e){return this.delegate.dispatchEvent(...e)}removeEventListener(...e){return this.delegate.removeEventListener(...e)}}exports.HAQuerySelector=class extends c{constructor(e={}){super(),this._config=Object.assign(Object.assign({},s),e),this._timestaps={}}_dispatchEvent(e,t){const s=Date.now();this._timestaps[e]&&s-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=s,this.dispatchEvent(new CustomEvent(e,{detail:t})))}_updateDialogElements(e=O.HA_MORE_INFO_DIALOG_INFO){this._dialogTree=l(this._config,a,this._haRootElements.HOME_ASSISTANT.element);const t=h(O,this._dialogTree);t.HA_DIALOG_CONTENT.element.then(e=>{this._dialogsContentObserver.disconnect(),this._dialogsContentObserver.observe(e,{childList:!0})}),this._haDialogElements=((e,t)=>[O.HA_MORE_INFO_DIALOG,O.HA_DIALOG,O.HA_DIALOG_CONTENT,t].reduce((t,s)=>(t[s]=e[s],t),{}))(t,e);const s={[O.HA_MORE_INFO_DIALOG_INFO]:exports.HAQuerySelectorEvent.ON_MORE_INFO_DIALOG_OPEN,[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:exports.HAQuerySelectorEvent.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,[O.HA_DIALOG_MORE_INFO_SETTINGS]:exports.HAQuerySelectorEvent.ON_SETTINGS_DIALOG_OPEN};this._dispatchEvent(s[e],this._haDialogElements)}_updateRootElements(){this._homeAssistantRootTree=l(this._config,r),this._haRootElements=h(_,this._homeAssistantRootTree),this._haRootElements[_.HOME_ASSISTANT].selector.$.element.then(e=>{this._dialogsObserver.disconnect(),this._dialogsObserver.observe(e,{childList:!0})}),this._haRootElements[_.PARTIAL_PANEL_RESOLVER].element.then(e=>{this._panelResolverObserver.disconnect(),e&&this._panelResolverObserver.observe(e,{subtree:!0,childList:!0})}),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LISTEN,this._haRootElements),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,this._haRootElements)}_updateLovelaceElements(){this._homeAssistantResolverTree=l(this._config,A,this._haRootElements[_.HA_DRAWER].element),this._haResolverElements=h(o,this._homeAssistantResolverTree),this._haResolverElements[o.HA_PANEL_LOVELACE].element.then(e=>{this._lovelaceObserver.disconnect(),e&&(this._lovelaceObserver.observe(e.shadowRoot,{childList:!0}),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD,Object.assign(Object.assign({},this._haRootElements),this._haResolverElements)))})}_watchDialogs(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{e instanceof Element&&e.localName===i.HA_MORE_INFO_DIALOG&&(this._dialogsChildrenObserver.disconnect(),this._dialogsChildrenObserver.observe(e.shadowRoot,{childList:!0}),this._updateDialogElements())})})}_watchDialogsChildren(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{const t=[`${i.HA_DIALOG}`,`${i.HA_ADAPTATIVE_DIALOG}`];e instanceof Element&&t.includes(e.localName)&&this._updateDialogElements()})})}_watchDialogsContent(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{const t={[i.HA_MORE_INFO_DIALOG_INFO]:O.HA_MORE_INFO_DIALOG_INFO,[i.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,[i.HA_DIALOG_MORE_INFO_SETTINGS]:O.HA_DIALOG_MORE_INFO_SETTINGS};if(e instanceof Element&&e.localName)if(e.localName===i.DIV){const s=e.querySelector(i.FIRST_CHILD);if(s&&s.localName in t){const e=s.localName;this._updateDialogElements(t[e])}}else if(e.localName in t){const s=e.localName;this._updateDialogElements(t[s])}})})}_watchDashboards(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{this._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,this._haRootElements),e instanceof Element&&e.localName===i.HA_PANEL_LOVELACE&&this._updateLovelaceElements()})})}_watchLovelace(e){e.forEach(({addedNodes:e})=>{e.forEach(e=>{e instanceof Element&&e.localName===i.HUI_ROOT&&this._updateLovelaceElements()})})}listen(){this._watchDialogsBinded=this._watchDialogs.bind(this),this._watchDialogsChildrenBinded=this._watchDialogsChildren.bind(this),this._watchDialogsContentBinded=this._watchDialogsContent.bind(this),this._watchDashboardsBinded=this._watchDashboards.bind(this),this._watchLovelaceBinded=this._watchLovelace.bind(this),this._dialogsObserver=new MutationObserver(this._watchDialogsBinded),this._dialogsChildrenObserver=new MutationObserver(this._watchDialogsChildrenBinded),this._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()}addEventListener(e,t,s){super.addEventListener(e,t,s)}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "home-assistant-query-selector",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta",
|
|
4
4
|
"description": "Easily query home-assistant DOM elements in an async way",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query-selector",
|
|
@@ -60,39 +60,31 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@eslint/js": "^10.0.1",
|
|
63
|
-
"@playwright/test": "1.
|
|
63
|
+
"@playwright/test": "1.61.0",
|
|
64
64
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
65
65
|
"@rollup/plugin-terser": "^1.0.0",
|
|
66
66
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
67
67
|
"@types/eslint": "^9.6.1",
|
|
68
|
-
"@types/node": "^
|
|
68
|
+
"@types/node": "^26.0.0",
|
|
69
69
|
"@types/sinon": "^21.0.1",
|
|
70
|
-
"eslint": "^10.
|
|
70
|
+
"eslint": "^10.5.0",
|
|
71
71
|
"globals": "^17.6.0",
|
|
72
72
|
"nyc": "^18.0.0",
|
|
73
73
|
"playwright-test-coverage": "^1.2.12",
|
|
74
|
-
"rollup": "^4.
|
|
74
|
+
"rollup": "^4.62.2",
|
|
75
75
|
"rollup-plugin-dts": "^6.4.1",
|
|
76
76
|
"rollup-plugin-istanbul": "^5.0.0",
|
|
77
77
|
"rollup-plugin-serve": "^3.0.0",
|
|
78
78
|
"rollup-plugin-tsconfig-paths": "^1.5.2",
|
|
79
|
-
"sinon": "^
|
|
79
|
+
"sinon": "^22.0.0",
|
|
80
80
|
"tslib": "^2.8.1",
|
|
81
81
|
"typescript": "^6.0.3",
|
|
82
|
-
"typescript-eslint": "^8.
|
|
82
|
+
"typescript-eslint": "^8.61.1"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"shadow-dom-selector": "^6.2.2"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"shadow-dom-selector": "^6.2.2"
|
|
89
|
-
},
|
|
90
|
-
"pnpm": {
|
|
91
|
-
"overrides": {
|
|
92
|
-
"brace-expansion@>=4.0.0 <5.0.5": ">=5.0.5",
|
|
93
|
-
"picomatch@<2.3.2": ">=2.3.2",
|
|
94
|
-
"picomatch@>=4.0.0 <4.0.4": ">=4.0.4",
|
|
95
|
-
"serialize-javascript@<7.0.5": ">=7.0.5"
|
|
96
|
-
}
|
|
97
89
|
}
|
|
98
90
|
}
|