home-assistant-query-selector 2.1.0 → 2.1.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/dist/esm/index.d.ts +40 -7
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +40 -7
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/esm/index.d.ts
CHANGED
|
@@ -46,13 +46,46 @@ declare enum HAQuerySelectorEvent {
|
|
|
46
46
|
ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN = "onLovelaceHistoryAndLogBookDialogOpen",
|
|
47
47
|
ON_LOVELACE_SETTINGS_DIALOG_OPEN = "onLovelaceSettingsDialogOpen"
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
type OnLovelacePanelLoadDetail = Record<keyof typeof HA_ROOT_ELEMENT | keyof typeof HA_RESOLVER_ELEMENT, HAElement>;
|
|
50
|
+
type OnLovelaceMoreInfoDialogOpenDetail = Record<Exclude<keyof typeof HA_DIALOG_ELEMENT, 'HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK' | 'HA_DIALOG_MORE_INFO_SETTINGS'>, HAElement>;
|
|
51
|
+
type OnLovelaceHistoryAndLogBookDialogOpenDetail = Record<Exclude<keyof typeof HA_DIALOG_ELEMENT, 'HA_MORE_INFO_DIALOG_INFO' | 'HA_DIALOG_MORE_INFO_SETTINGS'>, HAElement>;
|
|
52
|
+
type OnLovelaceSettingsDialogOpenDetail = Record<Exclude<keyof typeof HA_DIALOG_ELEMENT, 'HA_MORE_INFO_DIALOG_INFO' | 'HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK'>, HAElement>;
|
|
53
|
+
declare class DelegatedEventTarget implements EventTarget {
|
|
54
|
+
private delegate;
|
|
55
|
+
addEventListener(...args: Parameters<EventTarget['addEventListener']>): void;
|
|
56
|
+
dispatchEvent(...args: Parameters<EventTarget['dispatchEvent']>): boolean;
|
|
57
|
+
removeEventListener(...args: Parameters<EventTarget['removeEventListener']>): void;
|
|
58
|
+
}
|
|
59
|
+
declare class HAQuerySelector extends DelegatedEventTarget {
|
|
51
60
|
constructor(config?: HAQuerySelectorConfig);
|
|
61
|
+
private _config;
|
|
62
|
+
private _dialogTree;
|
|
63
|
+
private _homeAssistantRootTree;
|
|
64
|
+
private _homeAssistantResolverTree;
|
|
65
|
+
private _haDialogElements;
|
|
66
|
+
private _haRootElements;
|
|
67
|
+
private _haResolverElements;
|
|
68
|
+
private _dialogsObserver;
|
|
69
|
+
private _dialogsContentObserver;
|
|
70
|
+
private _panelResolverObserver;
|
|
71
|
+
private _lovelaceObserver;
|
|
72
|
+
private _watchDialogsBinded;
|
|
73
|
+
private _watchDialogsContentBinded;
|
|
74
|
+
private _watchDashboardsBinded;
|
|
75
|
+
private _watchLovelaceBinded;
|
|
76
|
+
private _timestap;
|
|
77
|
+
private _dispatchEvent;
|
|
78
|
+
private _updateDialogElements;
|
|
79
|
+
private _updateRootElements;
|
|
80
|
+
private _updateResolverElements;
|
|
81
|
+
private _watchDialogs;
|
|
82
|
+
private _watchDialogsContent;
|
|
83
|
+
private _watchDashboards;
|
|
84
|
+
private _watchLovelace;
|
|
52
85
|
listen(): void;
|
|
53
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD}`, callback: HAQuerySelectorEventListener<
|
|
54
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_MORE_INFO_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<
|
|
55
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<
|
|
56
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_SETTINGS_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<
|
|
86
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD}`, callback: HAQuerySelectorEventListener<OnLovelacePanelLoadDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
87
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_MORE_INFO_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<OnLovelaceMoreInfoDialogOpenDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
88
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<OnLovelaceHistoryAndLogBookDialogOpenDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
89
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_SETTINGS_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<OnLovelaceSettingsDialogOpenDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
57
90
|
}
|
|
58
|
-
export { HAQuerySelector, HAQuerySelectorEvent, ElementProps };
|
|
91
|
+
export { HAQuerySelector, HAQuerySelectorEvent, ElementProps, OnLovelacePanelLoadDetail, OnLovelaceMoreInfoDialogOpenDetail, OnLovelaceHistoryAndLogBookDialogOpenDetail, OnLovelaceSettingsDialogOpenDetail };
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{asyncQuerySelector as e,AsyncSelector as t}from"shadow-dom-selector";function
|
|
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,L,d,N,R,u,H="$",D={retries:100,delay:50};!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR"}(n||(n={})),function(e){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"}(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_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",e.ON_LOVELACE_MORE_INFO_DIALOG_OPEN="onLovelaceMoreInfoDialogOpen",e.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onLovelaceHistoryAndLogBookDialogOpen",e.ON_LOVELACE_SETTINGS_DIALOG_OPEN="onLovelaceSettingsDialogOpen"}(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"}(u||(u={}));var v=((s={})[n.HOME_ASSISTANT]={selector:u.HOME_ASSISTANT,children:{shadowRoot:{selector:H,children:(a={},a[n.HOME_ASSISTANT_MAIN]={selector:u.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:H,children:(A={},A[n.HA_DRAWER]={selector:u.HA_DRAWER,children:(l={},l[n.HA_SIDEBAR]={selector:u.HA_SIDEBAR,children:{shadowRoot:{selector:H}}},l)},A)}}},a)}}},s),p=((c={})[r.PARTIAL_PANEL_RESOLVER]={selector:u.PARTIAL_PANEL_RESOLVER,children:(E={},E[r.HA_PANEL_LOVELACE]={selector:u.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:H,children:(h={},h[r.HUI_ROOT]={selector:u.HUI_ROOT,children:{shadowRoot:{selector:H,children:(I={},I[r.HEADER]={selector:u.HEADER},I[r.HUI_VIEW]={selector:u.HUI_VIEW},I)}}},h)}}},E)},c),f={shadowRoot:{selector:H,children:(L={},L[O.HA_MORE_INFO_DIALOG]={selector:u.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:H,children:(d={},d[O.HA_DIALOG]={selector:u.HA_DIALOG,children:(N={},N[O.HA_DIALOG_CONTENT]={selector:u.HA_DIALOG_CONTENT,children:(R={},R[O.HA_MORE_INFO_DIALOG_INFO]={selector:u.HA_MORE_INFO_DIALOG_INFO},R[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:u.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},R[O.HA_DIALOG_MORE_INFO_SETTINGS]={selector:u.HA_DIALOG_MORE_INFO_SETTINGS},R)},N)},d)}}},L)}},T=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===H&&r)return a.children?_(_({},n),T(o,a.children,r,!0)):n;var A=r?r.then((function(t){return e(t,(_=a.selector,O?"$ "+_:_),o);var _})):e(a.selector,o);return n[s]={element:A,children:T(o,a.children,A),selector:new t(A,o)},n}),{})},S=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=S(e,n[1].children);if(r)return r}},G=function(e,t){return Object.keys(e).reduce((function(e,o){var n=S(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}),{})},m=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}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){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=T(this._config,f,this._haRootElements.HOME_ASSISTANT.element);var _=G(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_LOVELACE_MORE_INFO_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=i.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[O.HA_DIALOG_MORE_INFO_SETTINGS]=i.ON_LOVELACE_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(n[e],this._haDialogElements)},t.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=T(this._config,v),this._haRootElements=G(n,this._homeAssistantRootTree),this._haRootElements[n.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})}))},t.prototype._updateResolverElements=function(){var e=this,t=Date.now();t-this._timestap<500||(this._timestap=t,this._homeAssistantResolverTree=T(this._config,p,this._haRootElements[n.HA_DRAWER].element),this._haResolverElements=G(r,this._homeAssistantResolverTree),this._haResolverElements[r.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),e._panelResolverObserver.observe(t,{childList:!0})})),this._haResolverElements[r.HA_PANEL_LOVELACE].selector.$.element.then((function(t){e._lovelaceObserver.disconnect(),e._lovelaceObserver.observe(t,{childList:!0})})),this._dispatchEvent(i.ON_LOVELACE_PANEL_LOAD,_(_({},this._haRootElements),this._haResolverElements)))},t.prototype._watchDialogs=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===u.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={})[u.HA_MORE_INFO_DIALOG_INFO]=O.HA_MORE_INFO_DIALOG_INFO,o[u.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=O.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[u.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){e.localName===u.HA_PANEL_LOVELACE&&t._updateResolverElements()}))}))},t.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===u.HUI_ROOT&&t._updateResolverElements()}))}))},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._updateResolverElements()},t.prototype.addEventListener=function(t,o,_){e.prototype.addEventListener.call(this,t,o,_)},t}(m);export{M as HAQuerySelector,i as HAQuerySelectorEvent};
|
package/dist/index.d.ts
CHANGED
|
@@ -46,13 +46,46 @@ declare enum HAQuerySelectorEvent {
|
|
|
46
46
|
ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN = "onLovelaceHistoryAndLogBookDialogOpen",
|
|
47
47
|
ON_LOVELACE_SETTINGS_DIALOG_OPEN = "onLovelaceSettingsDialogOpen"
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
type OnLovelacePanelLoadDetail = Record<keyof typeof HA_ROOT_ELEMENT | keyof typeof HA_RESOLVER_ELEMENT, HAElement>;
|
|
50
|
+
type OnLovelaceMoreInfoDialogOpenDetail = Record<Exclude<keyof typeof HA_DIALOG_ELEMENT, 'HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK' | 'HA_DIALOG_MORE_INFO_SETTINGS'>, HAElement>;
|
|
51
|
+
type OnLovelaceHistoryAndLogBookDialogOpenDetail = Record<Exclude<keyof typeof HA_DIALOG_ELEMENT, 'HA_MORE_INFO_DIALOG_INFO' | 'HA_DIALOG_MORE_INFO_SETTINGS'>, HAElement>;
|
|
52
|
+
type OnLovelaceSettingsDialogOpenDetail = Record<Exclude<keyof typeof HA_DIALOG_ELEMENT, 'HA_MORE_INFO_DIALOG_INFO' | 'HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK'>, HAElement>;
|
|
53
|
+
declare class DelegatedEventTarget implements EventTarget {
|
|
54
|
+
private delegate;
|
|
55
|
+
addEventListener(...args: Parameters<EventTarget['addEventListener']>): void;
|
|
56
|
+
dispatchEvent(...args: Parameters<EventTarget['dispatchEvent']>): boolean;
|
|
57
|
+
removeEventListener(...args: Parameters<EventTarget['removeEventListener']>): void;
|
|
58
|
+
}
|
|
59
|
+
declare class HAQuerySelector extends DelegatedEventTarget {
|
|
51
60
|
constructor(config?: HAQuerySelectorConfig);
|
|
61
|
+
private _config;
|
|
62
|
+
private _dialogTree;
|
|
63
|
+
private _homeAssistantRootTree;
|
|
64
|
+
private _homeAssistantResolverTree;
|
|
65
|
+
private _haDialogElements;
|
|
66
|
+
private _haRootElements;
|
|
67
|
+
private _haResolverElements;
|
|
68
|
+
private _dialogsObserver;
|
|
69
|
+
private _dialogsContentObserver;
|
|
70
|
+
private _panelResolverObserver;
|
|
71
|
+
private _lovelaceObserver;
|
|
72
|
+
private _watchDialogsBinded;
|
|
73
|
+
private _watchDialogsContentBinded;
|
|
74
|
+
private _watchDashboardsBinded;
|
|
75
|
+
private _watchLovelaceBinded;
|
|
76
|
+
private _timestap;
|
|
77
|
+
private _dispatchEvent;
|
|
78
|
+
private _updateDialogElements;
|
|
79
|
+
private _updateRootElements;
|
|
80
|
+
private _updateResolverElements;
|
|
81
|
+
private _watchDialogs;
|
|
82
|
+
private _watchDialogsContent;
|
|
83
|
+
private _watchDashboards;
|
|
84
|
+
private _watchLovelace;
|
|
52
85
|
listen(): void;
|
|
53
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD}`, callback: HAQuerySelectorEventListener<
|
|
54
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_MORE_INFO_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<
|
|
55
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<
|
|
56
|
-
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_SETTINGS_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<
|
|
86
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD}`, callback: HAQuerySelectorEventListener<OnLovelacePanelLoadDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
87
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_MORE_INFO_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<OnLovelaceMoreInfoDialogOpenDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
88
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<OnLovelaceHistoryAndLogBookDialogOpenDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
89
|
+
addEventListener(type: `${HAQuerySelectorEvent.ON_LOVELACE_SETTINGS_DIALOG_OPEN}`, callback: HAQuerySelectorEventListener<OnLovelaceSettingsDialogOpenDetail>, options?: boolean | AddEventListenerOptions): void;
|
|
57
90
|
}
|
|
58
|
-
export { HAQuerySelector, HAQuerySelectorEvent, ElementProps };
|
|
91
|
+
export { HAQuerySelector, HAQuerySelectorEvent, ElementProps, OnLovelacePanelLoadDetail, OnLovelaceMoreInfoDialogOpenDetail, OnLovelaceHistoryAndLogBookDialogOpenDetail, OnLovelaceSettingsDialogOpenDetail };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("shadow-dom-selector")
|
|
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,_=arguments.length;o<_;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var _,n,r,O,s,i,A,a,c,l,E,h,I,L,d,N,R,u="$",H={retries:100,delay:50};!function(e){e.HOME_ASSISTANT="HOME_ASSISTANT",e.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",e.HA_DRAWER="HA_DRAWER",e.HA_SIDEBAR="HA_SIDEBAR"}(_||(_={})),function(e){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"}(n||(n={})),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,(O=exports.HAQuerySelectorEvent||(exports.HAQuerySelectorEvent={})).ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",O.ON_LOVELACE_MORE_INFO_DIALOG_OPEN="onLovelaceMoreInfoDialogOpen",O.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onLovelaceHistoryAndLogBookDialogOpen",O.ON_LOVELACE_SETTINGS_DIALOG_OPEN="onLovelaceSettingsDialogOpen",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={})[_.HOME_ASSISTANT]={selector:R.HOME_ASSISTANT,children:{shadowRoot:{selector:u,children:(i={},i[_.HOME_ASSISTANT_MAIN]={selector:R.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:u,children:(A={},A[_.HA_DRAWER]={selector:R.HA_DRAWER,children:(a={},a[_.HA_SIDEBAR]={selector:R.HA_SIDEBAR,children:{shadowRoot:{selector:u}}},a)},A)}}},i)}}},s),p=((c={})[n.PARTIAL_PANEL_RESOLVER]={selector:R.PARTIAL_PANEL_RESOLVER,children:(l={},l[n.HA_PANEL_LOVELACE]={selector:R.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:u,children:(E={},E[n.HUI_ROOT]={selector:R.HUI_ROOT,children:{shadowRoot:{selector:u,children:(h={},h[n.HEADER]={selector:R.HEADER},h[n.HUI_VIEW]={selector:R.HUI_VIEW},h)}}},E)}}},l)},c),D={shadowRoot:{selector:u,children:(I={},I[r.HA_MORE_INFO_DIALOG]={selector:R.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:u,children:(L={},L[r.HA_DIALOG]={selector:R.HA_DIALOG,children:(d={},d[r.HA_DIALOG_CONTENT]={selector:R.HA_DIALOG_CONTENT,children:(N={},N[r.HA_MORE_INFO_DIALOG_INFO]={selector:R.HA_MORE_INFO_DIALOG_INFO},N[r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]={selector:R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},N[r.HA_DIALOG_MORE_INFO_SETTINGS]={selector:R.HA_DIALOG_MORE_INFO_SETTINGS},N)},d)},L)}}},I)}},S=function(t,_,n,r){return void 0===n&&(n=null),void 0===r&&(r=!1),Object.entries(_||{}).reduce((function(_,O){var s=O[0],i=O[1];if(i.selector===u&&n)return i.children?o(o({},_),S(t,i.children,n,!0)):_;var A=n?n.then((function(o){return e.asyncQuerySelector(o,(_=i.selector,r?"$ "+_:_),t);var _})):e.asyncQuerySelector(i.selector,t);return _[s]={element:A,children:S(t,i.children,A),selector:new e.AsyncSelector(A,t)},_}),{})},f=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=f(e,n[1].children);if(r)return r}},T=function(e,t){return Object.keys(e).reduce((function(e,_){var n=f(_,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 O(t){void 0===t&&(t={});var _=e.call(this)||this;return _._config=o(o({},H),t),_}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 _(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(_.prototype=o.prototype,new _)}(O,e),O.prototype._dispatchEvent=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},O.prototype._updateDialogElements=function(e){var t,o=this;void 0===e&&(e=r.HA_MORE_INFO_DIALOG_INFO),this._dialogTree=S(this._config,D,this._haRootElements.HOME_ASSISTANT.element);var _=T(r,this._dialogTree);_.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}),{})}(_,e);var n=((t={})[r.HA_MORE_INFO_DIALOG_INFO]=exports.HAQuerySelectorEvent.ON_LOVELACE_MORE_INFO_DIALOG_OPEN,t[r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=exports.HAQuerySelectorEvent.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN,t[r.HA_DIALOG_MORE_INFO_SETTINGS]=exports.HAQuerySelectorEvent.ON_LOVELACE_SETTINGS_DIALOG_OPEN,t);this._dispatchEvent(n[e],this._haDialogElements)},O.prototype._updateRootElements=function(){var e=this;this._homeAssistantRootTree=S(this._config,v),this._haRootElements=T(_,this._homeAssistantRootTree),this._haRootElements[_.HOME_ASSISTANT].selector.$.element.then((function(t){e._dialogsObserver.disconnect(),e._dialogsObserver.observe(t,{childList:!0})}))},O.prototype._updateResolverElements=function(){var e=this,t=Date.now();t-this._timestap<500||(this._timestap=t,this._homeAssistantResolverTree=S(this._config,p,this._haRootElements[_.HA_DRAWER].element),this._haResolverElements=T(n,this._homeAssistantResolverTree),this._haResolverElements[n.PARTIAL_PANEL_RESOLVER].element.then((function(t){e._panelResolverObserver.disconnect(),e._panelResolverObserver.observe(t,{childList:!0})})),this._haResolverElements[n.HA_PANEL_LOVELACE].selector.$.element.then((function(t){e._lovelaceObserver.disconnect(),e._lovelaceObserver.observe(t,{childList:!0})})),this._dispatchEvent(exports.HAQuerySelectorEvent.ON_LOVELACE_PANEL_LOAD,o(o({},this._haRootElements),this._haResolverElements)))},O.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()}))}))},O.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]=r.HA_MORE_INFO_DIALOG_INFO,o[R.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]=r.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,o[R.HA_DIALOG_MORE_INFO_SETTINGS]=r.HA_DIALOG_MORE_INFO_SETTINGS,o);if(e.localName&&e.localName in _){var n=e.localName;t._updateDialogElements(_[n])}}))}))},O.prototype._watchDashboards=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HA_PANEL_LOVELACE&&t._updateResolverElements()}))}))},O.prototype._watchLovelace=function(e){var t=this;e.forEach((function(e){e.addedNodes.forEach((function(e){e.localName===R.HUI_ROOT&&t._updateResolverElements()}))}))},O.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._updateResolverElements()},O.prototype.addEventListener=function(t,o,_){e.prototype.addEventListener.call(this,t,o,_)},O}(G);exports.HAQuerySelector=m;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "home-assistant-query-selector",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Easily query home-assistant DOM elements in an async way",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query-selector",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"postversion": "git push && git push --tags"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"shadow-dom-selector": "^3.0.
|
|
53
|
+
"shadow-dom-selector": "^3.0.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@cypress/code-coverage": "^3.12.10",
|