home-assistant-query-selector 4.2.0 → 5.0.0-alpha

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 CHANGED
@@ -38,7 +38,7 @@ import { HAQuerySelector } from 'home-assistant-query-selector';
38
38
 
39
39
  const instance = new HAQuerySelector();
40
40
 
41
- // This even will be triggered when the listen method is called
41
+ // This event will be triggered when the listen method is called
42
42
  // You can also use the enum value HAQuerySelectorEvent.ON_LISTEN
43
43
  instance.addEventListener('onListen', ({ detail }) => {
44
44
 
@@ -328,7 +328,7 @@ This is the list of the elements available inside the `detail` property of the `
328
328
  | Detail element | DOM element |
329
329
  | -------------------------- | ------------------------ |
330
330
  | `HA_MORE_INFO_DIALOG` | `ha-more-info-dialog` |
331
- | `HA_DIALOG` | `ha-dialog` |
331
+ | `HA_DIALOG` | `ha-adaptive-dialog` |
332
332
  | `HA_DIALOG_CONTENT` | `.content` |
333
333
  | `HA_MORE_INFO_DIALOG_INFO` | `ha-more-info-info` |
334
334
 
@@ -367,7 +367,7 @@ This is the list of the elements available inside the `detail` property of the `
367
367
  | Detail element | DOM element |
368
368
  | ----------------------------------------- | ---------------------------------- |
369
369
  | `HA_MORE_INFO_DIALOG` | `ha-more-info-dialog` |
370
- | `HA_DIALOG` | `ha-dialog` |
370
+ | `HA_DIALOG` | `ha-adaptive-dialog` |
371
371
  | `HA_DIALOG_CONTENT` | `.content` |
372
372
  | `HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK` | `ha-more-info-history-and-logbook` |
373
373
 
@@ -406,7 +406,7 @@ This is the list of the elements available inside the `detail` property of the `
406
406
  | Detail element | DOM element |
407
407
  | ------------------------------ | ----------------------- |
408
408
  | `HA_MORE_INFO_DIALOG` | `ha-more-info-dialog` |
409
- | `HA_DIALOG` | `ha-dialog` |
409
+ | `HA_DIALOG` | `ha-adaptive-dialog` |
410
410
  | `HA_DIALOG_CONTENT` | `.content` |
411
411
  | `HA_DIALOG_MORE_INFO_SETTINGS` | `ha-more-info-settings` |
412
412
 
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{asyncQuerySelector as e,AsyncSelector as t}from"shadow-dom-selector";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},o(e,t)};var _=function(){return _=Object.assign||function(e){for(var t,o=1,_=arguments.length;o<_;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},_.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var n,r,O,i,s,a,A,l,c,E,h,I,d,N,L,R,u="$",D={retries:100,delay:50,eventThreshold:450};!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"}(n||(n={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(r||(r={})),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={})),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"}(i||(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",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_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"}(R||(R={}));var v=((s={})[n.HOME_ASSISTANT]={selector:R.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(a={},a[n.HOME_ASSISTANT_MAIN]={selector:R.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(A={},A[n.HA_DRAWER]={selector:R.HA_DRAWER,children:(l={},l[n.HA_SIDEBAR]={selector:R.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},l[n.PARTIAL_PANEL_RESOLVER]={selector:R.PARTIAL_PANEL_RESOLVER},l)},A)}}},a)}}},s),H=((c={})[r.HA_PANEL_LOVELACE]={selector:R.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(E={},E[r.HUI_ROOT]={selector:R.HUI_ROOT,children:{shadowRoot:{selector:u,children:(h={},h[r.HEADER]={selector:R.HEADER},h[r.HUI_VIEW]={selector:R.HUI_VIEW},h)}}},E)}}},c),p={shadowRoot:{selector:u,children:(I={},I[O.HA_MORE_INFO_DIALOG]={selector:R.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u,children:(d={},d[O.HA_DIALOG]={selector:R.HA_DIALOG,children:(N={},N[O.HA_DIALOG_CONTENT]={selector:R.HA_DIALOG_CONTENT,children:(L={},L[O.HA_MORE_INFO_DIALOG_INFO]={selector:R.HA_MORE_INFO_DIALOG_INFO},L[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},L[O.HA_DIALOG_MORE_INFO_SETTINGS]={selector:R.HA_DIALOG_MORE_INFO_SETTINGS},L)},N)},d)}}},I)}},f=function(o,n,r,O){return void 0===r&&(r=null),void 0===O&&(O=!1),Object.entries(n||{}).reduce((function(n,i){var s=i[0],a=i[1];if(a.selector===u&&r)return a.children?_(_({},n),f(o,a.children,r,!0)):n;var A=r?r.then((function(t){return t?e(t,(_=a.selector,O?"$ "+_:_),o):null;var _})):e(a.selector,o);return n[s]={element:A,children:f(o,a.children,A),selector:new t(A,o)},n}),{})},T=function(e,t){for(var o=0,_=Object.entries(t);o<_.length;o++){var n=_[o];if(n[0]===e)return n[1];var r=T(e,n[1].children);if(r)return r}},S=function(e,t){return Object.keys(e).reduce((function(e,o){var n=T(o,t);n.children;var r=function(e,t){var o={};for(var _ in e)Object.prototype.hasOwnProperty.call(e,_)&&t.indexOf(_)<0&&(o[_]=e[_]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(_=Object.getOwnPropertySymbols(e);n<_.length;n++)t.indexOf(_[n])<0&&Object.prototype.propertyIsEnumerable.call(e,_[n])&&(o[_[n]]=e[_[n]])}return o}(n,["children"]);return e[o]=_({},r),e}),{})},G=function(){function e(){this.delegate=document.createDocumentFragment()}return e.prototype.addEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=this.delegate).addEventListener.apply(e,t)},e.prototype.dispatchEvent=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).dispatchEvent.apply(e,t)},e.prototype.removeEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).removeEventListener.apply(e,t)},e}(),m=function(e){function t(t){void 0===t&&(t={});var o=e.call(this)||this;return o._config=_(_({},D),t),o._timestaps={},o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function _(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(_.prototype=t.prototype,new _)}(t,e),t.prototype._dispatchEvent=function(e,t){var o=Date.now();o-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=o,this.dispatchEvent(new CustomEvent(e,{detail:t})))},t.prototype._updateDialogElements=function(e){var t,o=this;void 0===e&&(e=O.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=f(this._config,p,this._haRootElements.HOME_ASSISTANT.element);var _=S(O,this._dialogTree);_.HA_DIALOG_CONTENT.element.then((function(e){o._dialogsContentObserver.disconnect(),o._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=function(e,t){return[O.HA_MORE_INFO_DIALOG,O.HA_DIALOG,O.HA_DIALOG_CONTENT,t].reduce((function(t,o){return t[o]=e[o],t}),{})}(_,e);var n=((t={})[O.HA_MORE_INFO_DIALOG_INFO]=i.ON_MORE_INFO_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=i.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_SETTINGS]=i.ON_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(n[e],this._haDialogElements)},t.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=f(this._config,v),this._haRootElements=S(n,this._homeAssistantRootTree),this._haRootElements[n.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})})),this._haRootElements[n.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0})})),this._dispatchEvent(i.ON_LISTEN,this._haRootElements),this._dispatchEvent(i.ON_PANEL_LOAD,this._haRootElements)},t.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=f(this._config,H,this._haRootElements[n.HA_DRAWER].element),this._haResolverElements=S(r,this._homeAssistantResolverTree),this._haResolverElements[r.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),e._dispatchEvent(i.ON_LOVELACE_PANEL_LOAD,_(_({},e._haRootElements),e._haResolverElements)))}))},t.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HA_MORE_INFO_DIALOG&&t._updateDialogElements()}))}))},t.prototype._watchDialogsContent=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){var o,_=((o={})[R.HA_MORE_INFO_DIALOG_INFO]=O.HA_MORE_INFO_DIALOG_INFO,o[R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[R.HA_DIALOG_MORE_INFO_SETTINGS]=O.HA_DIALOG_MORE_INFO_SETTINGS,o);if(e.localName&&e.localName in _){var n=e.localName;t._updateDialogElements(_[n])}}))}))},t.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){t._dispatchEvent(i.ON_PANEL_LOAD,t._haRootElements),e.localName===R.HA_PANEL_LOVELACE&&t._updateLovelaceElements()}))}))},t.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HUI_ROOT&&t._updateLovelaceElements()}))}))},t.prototype.listen=function(){this._watchDialogsBinded=this._watchDialogs.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._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()},t.prototype.addEventListener=function(t,o,_){e.prototype.addEventListener.call(this,t,o,_)},t}(G);export{m as HAQuerySelector,i as HAQuerySelectorEvent};
1
+ import{asyncQuerySelector as e,AsyncSelector as t}from"shadow-dom-selector";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},o(e,t)};var _=function(){return _=Object.assign||function(e){for(var t,o=1,_=arguments.length;o<_;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},_.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var n,r,O,i,s,a,A,l,c,E,h,I,d,N,L,R,u="$",D={retries:100,delay:50,eventThreshold:450};!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"}(n||(n={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(r||(r={})),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={})),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"}(i||(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",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-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"}(R||(R={}));var v=((s={})[n.HOME_ASSISTANT]={selector:R.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(a={},a[n.HOME_ASSISTANT_MAIN]={selector:R.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(A={},A[n.HA_DRAWER]={selector:R.HA_DRAWER,children:(l={},l[n.HA_SIDEBAR]={selector:R.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},l[n.PARTIAL_PANEL_RESOLVER]={selector:R.PARTIAL_PANEL_RESOLVER},l)},A)}}},a)}}},s),H=((c={})[r.HA_PANEL_LOVELACE]={selector:R.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(E={},E[r.HUI_ROOT]={selector:R.HUI_ROOT,children:{shadowRoot:{selector:u,children:(h={},h[r.HEADER]={selector:R.HEADER},h[r.HUI_VIEW]={selector:R.HUI_VIEW},h)}}},E)}}},c),p={shadowRoot:{selector:u,children:(I={},I[O.HA_MORE_INFO_DIALOG]={selector:R.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u,children:(d={},d[O.HA_DIALOG]={selector:R.HA_DIALOG,children:(N={},N[O.HA_DIALOG_CONTENT]={selector:R.HA_DIALOG_CONTENT,children:(L={},L[O.HA_MORE_INFO_DIALOG_INFO]={selector:R.HA_MORE_INFO_DIALOG_INFO},L[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},L[O.HA_DIALOG_MORE_INFO_SETTINGS]={selector:R.HA_DIALOG_MORE_INFO_SETTINGS},L)},N)},d)}}},I)}},f=function(o,n,r,O){return void 0===r&&(r=null),void 0===O&&(O=!1),Object.entries(n||{}).reduce((function(n,i){var s=i[0],a=i[1];if(a.selector===u&&r)return a.children?_(_({},n),f(o,a.children,r,!0)):n;var A=r?r.then((function(t){return t?e(t,(_=a.selector,O?"$ "+_:_),o):null;var _})):e(a.selector,o);return n[s]={element:A,children:f(o,a.children,A),selector:new t(A,o)},n}),{})},T=function(e,t){for(var o=0,_=Object.entries(t);o<_.length;o++){var n=_[o];if(n[0]===e)return n[1];var r=T(e,n[1].children);if(r)return r}},S=function(e,t){return Object.keys(e).reduce((function(e,o){var n=T(o,t);n.children;var r=function(e,t){var o={};for(var _ in e)Object.prototype.hasOwnProperty.call(e,_)&&t.indexOf(_)<0&&(o[_]=e[_]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(_=Object.getOwnPropertySymbols(e);n<_.length;n++)t.indexOf(_[n])<0&&Object.prototype.propertyIsEnumerable.call(e,_[n])&&(o[_[n]]=e[_[n]])}return o}(n,["children"]);return e[o]=_({},r),e}),{})},G=function(){function e(){this.delegate=document.createDocumentFragment()}return e.prototype.addEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=this.delegate).addEventListener.apply(e,t)},e.prototype.dispatchEvent=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).dispatchEvent.apply(e,t)},e.prototype.removeEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).removeEventListener.apply(e,t)},e}(),m=function(e){function t(t){void 0===t&&(t={});var o=e.call(this)||this;return o._config=_(_({},D),t),o._timestaps={},o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function _(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(_.prototype=t.prototype,new _)}(t,e),t.prototype._dispatchEvent=function(e,t){var o=Date.now();o-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=o,this.dispatchEvent(new CustomEvent(e,{detail:t})))},t.prototype._updateDialogElements=function(e){var t,o=this;void 0===e&&(e=O.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=f(this._config,p,this._haRootElements.HOME_ASSISTANT.element);var _=S(O,this._dialogTree);_.HA_DIALOG_CONTENT.element.then((function(e){o._dialogsContentObserver.disconnect(),o._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=function(e,t){return[O.HA_MORE_INFO_DIALOG,O.HA_DIALOG,O.HA_DIALOG_CONTENT,t].reduce((function(t,o){return t[o]=e[o],t}),{})}(_,e);var n=((t={})[O.HA_MORE_INFO_DIALOG_INFO]=i.ON_MORE_INFO_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=i.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_SETTINGS]=i.ON_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(n[e],this._haDialogElements)},t.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=f(this._config,v),this._haRootElements=S(n,this._homeAssistantRootTree),this._haRootElements[n.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})})),this._haRootElements[n.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0})})),this._dispatchEvent(i.ON_LISTEN,this._haRootElements),this._dispatchEvent(i.ON_PANEL_LOAD,this._haRootElements)},t.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=f(this._config,H,this._haRootElements[n.HA_DRAWER].element),this._haResolverElements=S(r,this._homeAssistantResolverTree),this._haResolverElements[r.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),e._dispatchEvent(i.ON_LOVELACE_PANEL_LOAD,_(_({},e._haRootElements),e._haResolverElements)))}))},t.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HA_MORE_INFO_DIALOG&&t._updateDialogElements()}))}))},t.prototype._watchDialogsContent=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){var o,_=((o={})[R.HA_MORE_INFO_DIALOG_INFO]=O.HA_MORE_INFO_DIALOG_INFO,o[R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[R.HA_DIALOG_MORE_INFO_SETTINGS]=O.HA_DIALOG_MORE_INFO_SETTINGS,o);if(e.localName&&e.localName in _){var n=e.localName;t._updateDialogElements(_[n])}}))}))},t.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){t._dispatchEvent(i.ON_PANEL_LOAD,t._haRootElements),e.localName===R.HA_PANEL_LOVELACE&&t._updateLovelaceElements()}))}))},t.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HUI_ROOT&&t._updateLovelaceElements()}))}))},t.prototype.listen=function(){this._watchDialogsBinded=this._watchDialogs.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._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()},t.prototype.addEventListener=function(t,o,_){e.prototype.addEventListener.call(this,t,o,_)},t}(G);export{m as HAQuerySelector,i as HAQuerySelectorEvent};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("shadow-dom-selector"),t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},t(e,o)};var o=function(){return o=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var _ in t=arguments[o])Object.prototype.hasOwnProperty.call(t,_)&&(e[_]=t[_]);return e},o.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var n,_,r,s,O,i,a,A,c,l,E,h,I,d,N,L,u="$",R={retries:100,delay:50,eventThreshold:450};!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"}(n||(n={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(_||(_={})),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"}(r||(r={})),exports.HAQuerySelectorEvent=void 0,(s=exports.HAQuerySelectorEvent||(exports.HAQuerySelectorEvent={})).ON_LISTEN="onListen",s.ON_PANEL_LOAD="onPanelLoad",s.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",s.ON_MORE_INFO_DIALOG_OPEN="onMoreInfoDialogOpen",s.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onHistoryAndLogBookDialogOpen",s.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_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"}(L||(L={}));var v=((O={})[n.HOME_ASSISTANT]={selector:L.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(i={},i[n.HOME_ASSISTANT_MAIN]={selector:L.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(a={},a[n.HA_DRAWER]={selector:L.HA_DRAWER,children:(A={},A[n.HA_SIDEBAR]={selector:L.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},A[n.PARTIAL_PANEL_RESOLVER]={selector:L.PARTIAL_PANEL_RESOLVER},A)},a)}}},i)}}},O),H=((c={})[_.HA_PANEL_LOVELACE]={selector:L.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(l={},l[_.HUI_ROOT]={selector:L.HUI_ROOT,children:{shadowRoot:{selector:u,children:(E={},E[_.HEADER]={selector:L.HEADER},E[_.HUI_VIEW]={selector:L.HUI_VIEW},E)}}},l)}}},c),p={shadowRoot:{selector:u,children:(h={},h[r.HA_MORE_INFO_DIALOG]={selector:L.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u,children:(I={},I[r.HA_DIALOG]={selector:L.HA_DIALOG,children:(d={},d[r.HA_DIALOG_CONTENT]={selector:L.HA_DIALOG_CONTENT,children:(N={},N[r.HA_MORE_INFO_DIALOG_INFO]={selector:L.HA_MORE_INFO_DIALOG_INFO},N[r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:L.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},N[r.HA_DIALOG_MORE_INFO_SETTINGS]={selector:L.HA_DIALOG_MORE_INFO_SETTINGS},N)},d)},I)}}},h)}},D=function(t,n,_,r){return void 0===_&&(_=null),void 0===r&&(r=!1),Object.entries(n||{}).reduce((function(n,s){var O=s[0],i=s[1];if(i.selector===u&&_)return i.children?o(o({},n),D(t,i.children,_,!0)):n;var a=_?_.then((function(o){return o?e.asyncQuerySelector(o,(n=i.selector,r?"$ "+n:n),t):null;var n})):e.asyncQuerySelector(i.selector,t);return n[O]={element:a,children:D(t,i.children,a),selector:new e.AsyncSelector(a,t)},n}),{})},S=function(e,t){for(var o=0,n=Object.entries(t);o<n.length;o++){var _=n[o];if(_[0]===e)return _[1];var r=S(e,_[1].children);if(r)return r}},f=function(e,t){return Object.keys(e).reduce((function(e,n){var _=S(n,t);_.children;var r=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var _=0;for(n=Object.getOwnPropertySymbols(e);_<n.length;_++)t.indexOf(n[_])<0&&Object.prototype.propertyIsEnumerable.call(e,n[_])&&(o[n[_]]=e[n[_]])}return o}(_,["children"]);return e[n]=o({},r),e}),{})},T=function(){function e(){this.delegate=document.createDocumentFragment()}return e.prototype.addEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=this.delegate).addEventListener.apply(e,t)},e.prototype.dispatchEvent=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).dispatchEvent.apply(e,t)},e.prototype.removeEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).removeEventListener.apply(e,t)},e}(),G=function(e){function s(t){void 0===t&&(t={});var n=e.call(this)||this;return n._config=o(o({},R),t),n._timestaps={},n}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}(s,e),s.prototype._dispatchEvent=function(e,t){var o=Date.now();o-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=o,this.dispatchEvent(new CustomEvent(e,{detail:t})))},s.prototype._updateDialogElements=function(e){var t,o=this;void 0===e&&(e=r.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=D(this._config,p,this._haRootElements.HOME_ASSISTANT.element);var n=f(r,this._dialogTree);n.HA_DIALOG_CONTENT.element.then((function(e){o._dialogsContentObserver.disconnect(),o._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=function(e,t){return[r.HA_MORE_INFO_DIALOG,r.HA_DIALOG,r.HA_DIALOG_CONTENT,t].reduce((function(t,o){return t[o]=e[o],t}),{})}(n,e);var _=((t={})[r.HA_MORE_INFO_DIALOG_INFO]=exports.HAQuerySelectorEvent.ON_MORE_INFO_DIALOG_OPEN,t[r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=exports.HAQuerySelectorEvent.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[r.HA_DIALOG_MORE_INFO_SETTINGS]=exports.HAQuerySelectorEvent.ON_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(_[e],this._haDialogElements)},s.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=D(this._config,v),this._haRootElements=f(n,this._homeAssistantRootTree),this._haRootElements[n.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})})),this._haRootElements[n.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0})})),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LISTEN,this._haRootElements),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,this._haRootElements)},s.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=D(this._config,H,this._haRootElements[n.HA_DRAWER].element),this._haResolverElements=f(_,this._homeAssistantResolverTree),this._haResolverElements[_.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),e._dispatchEvent(exports.HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD,o(o({},e._haRootElements),e._haResolverElements)))}))},s.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===L.HA_MORE_INFO_DIALOG&&t._updateDialogElements()}))}))},s.prototype._watchDialogsContent=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){var o,n=((o={})[L.HA_MORE_INFO_DIALOG_INFO]=r.HA_MORE_INFO_DIALOG_INFO,o[L.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[L.HA_DIALOG_MORE_INFO_SETTINGS]=r.HA_DIALOG_MORE_INFO_SETTINGS,o);if(e.localName&&e.localName in n){var _=e.localName;t._updateDialogElements(n[_])}}))}))},s.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){t._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,t._haRootElements),e.localName===L.HA_PANEL_LOVELACE&&t._updateLovelaceElements()}))}))},s.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===L.HUI_ROOT&&t._updateLovelaceElements()}))}))},s.prototype.listen=function(){this._watchDialogsBinded=this._watchDialogs.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._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()},s.prototype.addEventListener=function(t,o,n){e.prototype.addEventListener.call(this,t,o,n)},s}(T);exports.HAQuerySelector=G;
1
+ "use strict";var e=require("shadow-dom-selector"),t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},t(e,o)};var o=function(){return o=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var _ in t=arguments[o])Object.prototype.hasOwnProperty.call(t,_)&&(e[_]=t[_]);return e},o.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var n,_,r,s,O,i,a,A,c,l,E,h,I,d,N,L,u="$",R={retries:100,delay:50,eventThreshold:450};!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"}(n||(n={})),function(e){e.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",e.HUI_ROOT="HUI_ROOT",e.HEADER="HEADER",e.HUI_VIEW="HUI_VIEW"}(_||(_={})),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"}(r||(r={})),exports.HAQuerySelectorEvent=void 0,(s=exports.HAQuerySelectorEvent||(exports.HAQuerySelectorEvent={})).ON_LISTEN="onListen",s.ON_PANEL_LOAD="onPanelLoad",s.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",s.ON_MORE_INFO_DIALOG_OPEN="onMoreInfoDialogOpen",s.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onHistoryAndLogBookDialogOpen",s.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-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"}(L||(L={}));var v=((O={})[n.HOME_ASSISTANT]={selector:L.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(i={},i[n.HOME_ASSISTANT_MAIN]={selector:L.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(a={},a[n.HA_DRAWER]={selector:L.HA_DRAWER,children:(A={},A[n.HA_SIDEBAR]={selector:L.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},A[n.PARTIAL_PANEL_RESOLVER]={selector:L.PARTIAL_PANEL_RESOLVER},A)},a)}}},i)}}},O),H=((c={})[_.HA_PANEL_LOVELACE]={selector:L.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(l={},l[_.HUI_ROOT]={selector:L.HUI_ROOT,children:{shadowRoot:{selector:u,children:(E={},E[_.HEADER]={selector:L.HEADER},E[_.HUI_VIEW]={selector:L.HUI_VIEW},E)}}},l)}}},c),p={shadowRoot:{selector:u,children:(h={},h[r.HA_MORE_INFO_DIALOG]={selector:L.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u,children:(I={},I[r.HA_DIALOG]={selector:L.HA_DIALOG,children:(d={},d[r.HA_DIALOG_CONTENT]={selector:L.HA_DIALOG_CONTENT,children:(N={},N[r.HA_MORE_INFO_DIALOG_INFO]={selector:L.HA_MORE_INFO_DIALOG_INFO},N[r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:L.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},N[r.HA_DIALOG_MORE_INFO_SETTINGS]={selector:L.HA_DIALOG_MORE_INFO_SETTINGS},N)},d)},I)}}},h)}},D=function(t,n,_,r){return void 0===_&&(_=null),void 0===r&&(r=!1),Object.entries(n||{}).reduce((function(n,s){var O=s[0],i=s[1];if(i.selector===u&&_)return i.children?o(o({},n),D(t,i.children,_,!0)):n;var a=_?_.then((function(o){return o?e.asyncQuerySelector(o,(n=i.selector,r?"$ "+n:n),t):null;var n})):e.asyncQuerySelector(i.selector,t);return n[O]={element:a,children:D(t,i.children,a),selector:new e.AsyncSelector(a,t)},n}),{})},S=function(e,t){for(var o=0,n=Object.entries(t);o<n.length;o++){var _=n[o];if(_[0]===e)return _[1];var r=S(e,_[1].children);if(r)return r}},f=function(e,t){return Object.keys(e).reduce((function(e,n){var _=S(n,t);_.children;var r=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var _=0;for(n=Object.getOwnPropertySymbols(e);_<n.length;_++)t.indexOf(n[_])<0&&Object.prototype.propertyIsEnumerable.call(e,n[_])&&(o[n[_]]=e[n[_]])}return o}(_,["children"]);return e[n]=o({},r),e}),{})},T=function(){function e(){this.delegate=document.createDocumentFragment()}return e.prototype.addEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=this.delegate).addEventListener.apply(e,t)},e.prototype.dispatchEvent=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).dispatchEvent.apply(e,t)},e.prototype.removeEventListener=function(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return(e=this.delegate).removeEventListener.apply(e,t)},e}(),G=function(e){function s(t){void 0===t&&(t={});var n=e.call(this)||this;return n._config=o(o({},R),t),n._timestaps={},n}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}(s,e),s.prototype._dispatchEvent=function(e,t){var o=Date.now();o-this._timestaps[e]<this._config.eventThreshold||(this._timestaps[e]=o,this.dispatchEvent(new CustomEvent(e,{detail:t})))},s.prototype._updateDialogElements=function(e){var t,o=this;void 0===e&&(e=r.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=D(this._config,p,this._haRootElements.HOME_ASSISTANT.element);var n=f(r,this._dialogTree);n.HA_DIALOG_CONTENT.element.then((function(e){o._dialogsContentObserver.disconnect(),o._dialogsContentObserver.observe(e,{childList:!0})})),this._haDialogElements=function(e,t){return[r.HA_MORE_INFO_DIALOG,r.HA_DIALOG,r.HA_DIALOG_CONTENT,t].reduce((function(t,o){return t[o]=e[o],t}),{})}(n,e);var _=((t={})[r.HA_MORE_INFO_DIALOG_INFO]=exports.HAQuerySelectorEvent.ON_MORE_INFO_DIALOG_OPEN,t[r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=exports.HAQuerySelectorEvent.ON_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[r.HA_DIALOG_MORE_INFO_SETTINGS]=exports.HAQuerySelectorEvent.ON_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(_[e],this._haDialogElements)},s.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=D(this._config,v),this._haRootElements=f(n,this._homeAssistantRootTree),this._haRootElements[n.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})})),this._haRootElements[n.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),t&&e._panelResolverObserver.observe(t,{subtree:!0,childList:!0})})),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LISTEN,this._haRootElements),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,this._haRootElements)},s.prototype._updateLovelaceElements=function(){var e=this;this._homeAssistantResolverTree=D(this._config,H,this._haRootElements[n.HA_DRAWER].element),this._haResolverElements=f(_,this._homeAssistantResolverTree),this._haResolverElements[_.HA_PANEL_LOVELACE].element.then((function(t){e._lovelaceObserver.disconnect(),t&&(e._lovelaceObserver.observe(t.shadowRoot,{childList:!0}),e._dispatchEvent(exports.HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD,o(o({},e._haRootElements),e._haResolverElements)))}))},s.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===L.HA_MORE_INFO_DIALOG&&t._updateDialogElements()}))}))},s.prototype._watchDialogsContent=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){var o,n=((o={})[L.HA_MORE_INFO_DIALOG_INFO]=r.HA_MORE_INFO_DIALOG_INFO,o[L.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[L.HA_DIALOG_MORE_INFO_SETTINGS]=r.HA_DIALOG_MORE_INFO_SETTINGS,o);if(e.localName&&e.localName in n){var _=e.localName;t._updateDialogElements(n[_])}}))}))},s.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){t._dispatchEvent(exports.HAQuerySelectorEvent.ON_PANEL_LOAD,t._haRootElements),e.localName===L.HA_PANEL_LOVELACE&&t._updateLovelaceElements()}))}))},s.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===L.HUI_ROOT&&t._updateLovelaceElements()}))}))},s.prototype.listen=function(){this._watchDialogsBinded=this._watchDialogs.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._dialogsContentObserver=new MutationObserver(this._watchDialogsContentBinded),this._panelResolverObserver=new MutationObserver(this._watchDashboardsBinded),this._lovelaceObserver=new MutationObserver(this._watchLovelaceBinded),this._updateRootElements(),this._updateLovelaceElements()},s.prototype.addEventListener=function(t,o,n){e.prototype.addEventListener.call(this,t,o,n)},s}(T);exports.HAQuerySelector=G;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "home-assistant-query-selector",
3
- "version": "4.2.0",
3
+ "version": "5.0.0-alpha",
4
4
  "description": "Easily query home-assistant DOM elements in an async way",
5
5
  "keywords": [
6
6
  "query-selector",
@@ -33,48 +33,57 @@
33
33
  "license": "Apache-2.0",
34
34
  "repository": {
35
35
  "type": "git",
36
- "url": "git+https://github.com/elchininet/home-assistant-query-selector"
36
+ "url": "git+https://github.com/elchininet/home-assistant-query-selector.git"
37
37
  },
38
38
  "scripts": {
39
39
  "clean": "rm -rf dist || true",
40
40
  "test:clean": "rm -rf .nyc_output coverage || true",
41
- "build": "yarn clean && rollup --config rollup.config.js --bundleConfigAsCjs",
42
- "lint": "eslint \"src/**/*.ts\"",
41
+ "build": "pnpm clean && rollup --config rollup.config.js --bundleConfigAsCjs",
42
+ "lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
43
43
  "coverage:report": "nyc report --reporter=lcov --reporter=text-summary",
44
44
  "test:ts": "tsc --noEmit",
45
45
  "test:run": "playwright test",
46
46
  "test:open": "playwright test --ui",
47
- "test:ci": "yarn demo:ha && yarn start:playwright && yarn stop:ha",
47
+ "test:ci": "pnpm demo:ha && pnpm start:playwright && pnpm stop:ha",
48
+ "test:tag": "pnpm reset:ha && pnpm test:clean && pnpm demo:ha && pnpm tag:playwright && pnpm stop:ha",
48
49
  "start:ha": "docker run --rm -d -p8123:8123 -v ${PWD}/.hass/config:/config homeassistant/home-assistant:${TAG:-$(cat .hass/config/.HA_VERSION)}",
49
50
  "stop:ha": "docker stop $(docker ps -a -q --filter ancestor=homeassistant/home-assistant:${TAG:-$(cat .hass/config/.HA_VERSION)}) || true",
50
51
  "reset:ha": "git add .hass/config/.HA_VERSION && git checkout .hass/config",
51
- "demo:ha": "yarn test:clean && yarn build && yarn start:ha",
52
- "start:playwright": "docker run --rm --network host --add-host host.docker.internal:host-gateway -v $(pwd):/$(pwd)/ -w $(pwd) -i mcr.microsoft.com/playwright:$(cat .playwright_docker_version) sh -c \"yarn test:run && exit\"",
53
- "prepare": "yarn build",
54
- "prepublishOnly": "yarn lint && yarn test:ts && yarn test:ci",
52
+ "demo:ha": "pnpm test:clean && pnpm build && pnpm start:ha",
53
+ "start:playwright": "docker run -e CI=true --rm --network host --add-host host.docker.internal:host-gateway -v $(pwd):/$(pwd)/ -w $(pwd) -i mcr.microsoft.com/playwright:v$(jq -r '.devDependencies[\"@playwright/test\"]' package.json)-jammy sh -c \"npx playwright test\"",
54
+ "tag:playwright": "docker run --rm --network host --add-host host.docker.internal:host-gateway -v $(pwd):/$(pwd)/ -w $(pwd) -i mcr.microsoft.com/playwright:v$(jq -r '.devDependencies[\"@playwright/test\"]' package.json)-jammy sh -c \"npx playwright test --grep @testing --trace on\"",
55
+ "prepare": "pnpm build",
56
+ "prepublishOnly": "pnpm lint && pnpm test:ts && pnpm test:ci",
55
57
  "version": "git add .",
56
58
  "postversion": "git push && git push --tags"
57
59
  },
58
- "dependencies": {
59
- "shadow-dom-selector": "^4.1.2"
60
- },
61
60
  "devDependencies": {
62
- "@playwright/test": "^1.40.1",
63
- "@rollup/plugin-node-resolve": "^15.2.3",
64
- "@types/eslint": "^8.56.1",
65
- "@types/node": "^20.10.7",
66
- "@types/sinon": "^17.0.2",
67
- "@typescript-eslint/eslint-plugin": "^6.18.0",
68
- "@typescript-eslint/parser": "^6.18.0",
69
- "eslint": "^8.56.0",
70
- "nyc": "^15.1.0",
61
+ "@eslint/js": "^10.0.1",
62
+ "@playwright/test": "1.58.2",
63
+ "@rollup/plugin-node-resolve": "^16.0.3",
64
+ "@rollup/plugin-terser": "^0.4.4",
65
+ "@types/eslint": "^9.6.1",
66
+ "@types/node": "^25.2.3",
67
+ "@types/sinon": "^21.0.0",
68
+ "eslint": "^10.0.0",
69
+ "globals": "^17.3.0",
70
+ "nyc": "^17.1.0",
71
71
  "playwright-test-coverage": "^1.2.12",
72
- "rollup": "^4.9.4",
72
+ "rollup": "^4.57.1",
73
73
  "rollup-plugin-istanbul": "^5.0.0",
74
74
  "rollup-plugin-serve": "^2.0.3",
75
- "rollup-plugin-terser": "^7.0.2",
76
75
  "rollup-plugin-ts": "^3.4.5",
77
- "sinon": "^17.0.1",
78
- "typescript": "^5.3.3"
76
+ "sinon": "^21.0.1",
77
+ "tslib": "^2.8.1",
78
+ "typescript": "^5.9.3",
79
+ "typescript-eslint": "^8.55.0"
80
+ },
81
+ "dependencies": {
82
+ "shadow-dom-selector": "^5.0.1"
83
+ },
84
+ "pnpm": {
85
+ "overrides": {
86
+ "diff@>=6.0.0 <8.0.3": ">=8.0.3"
87
+ }
79
88
  }
80
89
  }