shadow-dom-selector 4.1.2 → 5.0.0

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
@@ -2,7 +2,11 @@
2
2
 
3
3
  A very small JavaScript utility to query DOM elements through the [Shadow DOM] subtrees in a sync or an async way.
4
4
 
5
- [![Deployment Status](https://github.com/elchininet/shadow-dom-selector/actions/workflows/deploy.yaml/badge.svg)](https://github.com/elchininet/shadow-dom-selector/actions/workflows/deploy.yaml)   [![Coverage Status](https://coveralls.io/repos/github/elchininet/shadow-dom-selector/badge.svg?branch=master)](https://coveralls.io/github/elchininet/shadow-dom-selector?branch=master)   [![npm version](https://badge.fury.io/js/shadow-dom-selector.svg)](https://badge.fury.io/js/shadow-dom-selector)
5
+ [![Deployment Status](https://github.com/elchininet/shadow-dom-selector/actions/workflows/deploy.yaml/badge.svg)](https://github.com/elchininet/shadow-dom-selector/actions/workflows/deploy.yaml)
6
+ [![Tests](https://github.com/elchininet/shadow-dom-selector/actions/workflows/tests.yaml/badge.svg)](https://github.com/elchininet/shadow-dom-selector/actions/workflows/tests.yaml)
7
+ [![Coverage Status](https://coveralls.io/repos/github/elchininet/shadow-dom-selector/badge.svg?branch=master)](https://coveralls.io/github/elchininet/shadow-dom-selector?branch=master)
8
+ [![npm version](https://badge.fury.io/js/shadow-dom-selector.svg)](https://badge.fury.io/js/shadow-dom-selector)
9
+ [![downloads](https://img.shields.io/npm/dw/shadow-dom-selector)](https://www.npmjs.com/package/shadow-dom-selector)
6
10
 
7
11
  ## Introduction
8
12
 
@@ -193,34 +197,36 @@ Either the async methods or the async dot notation allow you to to specify the a
193
197
 
194
198
  ## Install
195
199
 
200
+ The package needs the [get-promisable-result](https://github.com/elchininet/get-promisable-result) package as a peer dependency.
201
+
196
202
  #### npm
197
203
 
198
204
  ```bash
199
- npm install shadow-dom-selector
205
+ npm install get-promisable-result shadow-dom-selector
200
206
  ```
201
207
 
202
208
  #### yarn
203
209
 
204
210
  ```bash
205
- yarn add shadow-dom-selector
211
+ yarn add get-promisable-result shadow-dom-selector
206
212
  ```
207
213
 
208
214
  #### PNPM
209
215
 
210
216
  ```bash
211
- pnpm add shadow-dom-selector
217
+ pnpm add get-promisable-result shadow-dom-selector
212
218
  ```
213
219
 
214
220
  #### In the browser
215
221
 
216
222
  It is possible to include a compiled version of the package directly in an HTML file. It will create a global `ShadowDomSelector` object containing all the exported functions that can be accessed from anywhere in your JavaScript code.
217
223
 
218
- 1. Copy the JavaScript file `index.js`, located in the root of the `dist/` folder
224
+ 1. Copy the JavaScript file `shadow-dom-selector-web.js`, located in the root of the `dist/` folder
219
225
  2. Put it in the folder that you prefer in your web server
220
226
  3. Include it in your HTML file
221
227
 
222
228
  ```html
223
- <script src="wherever/you/want/to/place/index.js"></script>
229
+ <script src="wherever/you/want/to/place/shadow-dom-selector-web.js"></script>
224
230
  ```
225
231
 
226
232
  ```javascript
@@ -2,7 +2,6 @@ interface AsyncParams {
2
2
  retries?: number;
3
3
  delay?: number;
4
4
  }
5
- declare const SHADOW_ROOT_SELECTOR = "$";
6
5
  declare function querySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): E | null;
7
6
  declare function querySelector<E extends Element = Element>(selectors: string): E | null;
8
7
  declare function deepQuerySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): E | null;
@@ -29,7 +28,7 @@ declare class AsyncSelector<T extends Document | Element | ShadowRoot> {
29
28
  private _element;
30
29
  private _asyncParams;
31
30
  get element(): Promise<T | null>;
32
- get [SHADOW_ROOT_SELECTOR](): AsyncSelector<ShadowRoot>;
31
+ get $(): AsyncSelector<ShadowRoot>;
33
32
  get all(): Promise<NodeListOf<Element>>;
34
33
  get asyncParams(): AsyncParams;
35
34
  eq(index: number): Promise<Element | null>;
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- var n=function(){return n=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},n.apply(this,arguments)};function t(n,t,e,r){return new(e||(e=Promise))((function(o,u){function i(n){try{c(r.next(n))}catch(n){u(n)}}function a(n){try{c(r.throw(n))}catch(n){u(n)}}function c(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(i,a)}c((r=r.apply(n,t||[])).next())}))}function e(n,t){var e,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(n,i)}catch(n){a=[6,n],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r="$",o=":host",u="invalid selector",i=10,a=10,c=function(n){var t,e=n[0],r=n[1];return(t=e)&&(t instanceof Document||t instanceof Element||t instanceof ShadowRoot)&&"string"==typeof r};function l(n,t){return function(n){return n.split(",").map((function(n){return n.trim()}))}(n).map((function(n){var e=function(n){return n.split(r).map((function(n){return n.trim()}))}(n);return t(e)}))}var s=function(n,t,e,r){return new Promise((function(o){var u=0,i=function(){var a=n();t(a)?o(a):++u<e?setTimeout(i,r):o(a)};i()}))};function f(n,t){var e=t?" If you want to select a shadowRoot, use ".concat(t," instead."):"";return"".concat(n," cannot be used with a selector ending in a shadowRoot (").concat(r,").").concat(e)}function d(n){return n instanceof Promise?n:Promise.resolve(n)}function h(){return"You can not select a shadowRoot (".concat(r,") of the document.")}function v(){return"You can not select a shadowRoot (".concat(r,") of a shadowRoot.")}function y(n,t){for(var e,r,u=null,i=n.length,a=0;a<i;a++){if(0===a)if(n[a].length)u=t.querySelector(n[a]);else{if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(v());u=(null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(n[++a]))||null}else u=(null===(r=u.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(o," ").concat(n[a])))||null;if(null===u)return null}return u}function m(n,t){var e,r=function(n,t,e){if(e||2===arguments.length)for(var r,o=0,u=t.length;o<u;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return n.concat(r||Array.prototype.slice.call(t))}([],n,!0),u=r.pop();if(!r.length)return t.querySelectorAll(u);var i=y(r,t);return(null===(e=null==i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelectorAll("".concat(o," ").concat(u)))||null}function p(n,t){if(1===n.length&&!n[0].length){if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(v());return t.shadowRoot}var e=y(n,t);return(null==e?void 0:e.shadowRoot)||null}function w(n,t,e,r){void 0===e&&(e="querySelector"),void 0===r&&(r="shadowRootQuerySelector");for(var o=l(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f(e,r));return n})),u=o.length,i=0;i<u;i++){var a=y(o[i],t);if(a)return a}return null}function g(n,t,e){void 0===e&&(e="querySelectorAll");for(var r=l(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f(e));return n})),o=r.length,i=0;i<o;i++){var a=m(r[i],t);if(null==a?void 0:a.length)return a}return document.querySelectorAll(u)}function S(n,t,e,o){void 0===e&&(e="shadowRootQuerySelector"),void 0===o&&(o="querySelector");for(var u=l(n,(function(n){if(n.pop().length)throw new SyntaxError(function(n,t){return"".concat(n," must be used with a selector ending in a shadowRoot (").concat(r,"). If you don't want to select a shadowRoot, use ").concat(t," instead.")}(e,o));return n})),i=u.length,a=0;a<i;a++){var c=p(u[a],t);if(c)return c}return null}function b(n,r,o,u){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,s((function(){return w(n,r,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(n){return!!n}),o,u)]}))}))}function P(n,r,o,u){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,s((function(){return g(n,r,"asyncQuerySelectorAll")}),(function(n){return!!n.length}),o,u)]}))}))}function R(n,r,o,u){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,s((function(){return S(n,r,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(n){return!!n}),o,u)]}))}))}var _=function(n,t){var e=n.querySelectorAll(t);if(e.length)return e;if(n instanceof Element&&n.shadowRoot){var r=_(n.shadowRoot,t);if(r.length)return r}for(var o=0,i=Array.from(n.querySelectorAll("*"));o<i.length;o++){var a=i[o],c=_(a,t);if(c.length)return c}return document.querySelectorAll(u)},q=function(n,t,e,r){return s((function(){return _(n,t)}),(function(n){return!!n.length}),e,r)};function x(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?w(e,document):w(r,e)}function A(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?_(document,e)[0]||null:_(e,r)[0]||null}function E(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?g(e,document):g(r,e)}function N(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?_(document,e):_(e,r)}function L(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?S(e,document):S(r,e)}function Q(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c(n)?(t=n[0],r=n[1],o=n[2],[4,b(r,t,(null==o?void 0:o.retries)||i,(null==o?void 0:o.delay)||a)]):[3,2];case 1:case 3:return[2,e.sent()];case 2:return u=n[0],l=n[1],[4,b(u,document,(null==l?void 0:l.retries)||i,(null==l?void 0:l.delay)||a)]}}))}))}function O(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c(n)?(t=n[0],r=n[1],o=n[2],[4,q(t,r,(null==o?void 0:o.retries)||i,(null==o?void 0:o.delay)||a)]):[3,2];case 1:case 3:return[2,e.sent()[0]||null];case 2:return u=n[0],l=n[1],[4,q(document,u,(null==l?void 0:l.retries)||i,(null==l?void 0:l.delay)||a)]}}))}))}function j(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c(n)?(t=n[0],r=n[1],o=n[2],[4,P(r,t,(null==o?void 0:o.retries)||i,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,e.sent()];case 2:return u=n[0],l=n[1],[2,P(u,document,(null==l?void 0:l.retries)||i,(null==l?void 0:l.delay)||a)]}}))}))}function k(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];if(c(n)){var e=n[0],r=n[1],o=n[2];return q(e,r,(null==o?void 0:o.retries)||i,(null==o?void 0:o.delay)||a)}var u=n[0],l=n[1];return q(document,u,(null==l?void 0:l.retries)||i,(null==l?void 0:l.delay)||a)}function D(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t(this,void 0,void 0,(function(){var t,r,o,u,l;return e(this,(function(e){switch(e.label){case 0:return c(n)?(t=n[0],r=n[1],o=n[2],[4,R(r,t,(null==o?void 0:o.retries)||i,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,e.sent()];case 2:return u=n[0],l=n[1],[2,R(u,document,(null==l?void 0:l.retries)||i,(null==l?void 0:l.delay)||a)]}}))}))}var I=function(){function o(t,e){t instanceof Node||t instanceof Promise?(this._element=t,this._asyncParams=n({retries:i,delay:a},e||{})):(this._element=document,this._asyncParams=n({retries:i,delay:a},t||{}))}return Object.defineProperty(o.prototype,"element",{get:function(){return d(this._element).then((function(n){return n instanceof NodeList?n[0]||null:n}))},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,r,{get:function(){var n=this;return new o(d(this._element).then((function(t){return t instanceof Document||t instanceof ShadowRoot||null===t||t instanceof NodeList&&0===t.length?null:t instanceof NodeList?D(t[0],r,n._asyncParams):D(t,r,n._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"all",{get:function(){return d(this._element).then((function(n){return n instanceof NodeList?n:document.querySelectorAll(u)}))},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),o.prototype.eq=function(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,d(this._element).then((function(t){return t instanceof NodeList&&t[n]||null}))]}))}))},o.prototype.query=function(n){var t=this;return new o(d(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?j(e[0],n,t._asyncParams):j(e,n,t._asyncParams)})),this._asyncParams)},o.prototype.deepQuery=function(n){var t=this;return new o(d(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?Promise.race(Array.from(e).map((function(e){return q(e,n,t._asyncParams.retries,t._asyncParams.delay)}))):q(e,n,t._asyncParams.retries,t._asyncParams.delay)})),this._asyncParams)},o}();export{I as AsyncSelector,O as asyncDeepQuerySelector,k as asyncDeepQuerySelectorAll,Q as asyncQuerySelector,j as asyncQuerySelectorAll,D as asyncShadowRootQuerySelector,A as deepQuerySelector,N as deepQuerySelectorAll,x as querySelector,E as querySelectorAll,L as shadowRootQuerySelector};
1
+ import{getPromisableResult as n}from"get-promisable-result";var t=function(){return t=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},t.apply(this,arguments)};function e(n,t,e,r){return new(e||(e=Promise))((function(o,u){function i(n){try{l(r.next(n))}catch(n){u(n)}}function a(n){try{l(r.throw(n))}catch(n){u(n)}}function l(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(i,a)}l((r=r.apply(n,t||[])).next())}))}function r(n,t){var e,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(n,u)}catch(n){a=[6,n],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}"function"==typeof SuppressedError&&SuppressedError;var o="$",u=":host",i="invalid selector",a=10,l=10,c=function(n){var t,e=n[0],r=n[1];return(t=e)&&(t instanceof Document||t instanceof Element||t instanceof ShadowRoot)&&"string"==typeof r};function s(n,t){return function(n){return n.split(",").map((function(n){return n.trim()}))}(n).map((function(n){var e=function(n){return n.split(o).map((function(n){return n.trim()}))}(n);return t(e)}))}function f(n,t){var e=t?" If you want to select a shadowRoot, use ".concat(t," instead."):"";return"".concat(n," cannot be used with a selector ending in a shadowRoot (").concat(o,").").concat(e)}function d(n){return n instanceof Promise?n:Promise.resolve(n)}function h(){return"You can not select a shadowRoot (".concat(o,") of the document.")}function y(){return"You can not select a shadowRoot (".concat(o,") of a shadowRoot.")}function v(n,t){for(var e,r,o=null,i=n.length,a=0;a<i;a++){if(0===a)if(n[a].length)o=t.querySelector(n[a]);else{if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(y());o=(null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(n[++a]))||null}else o=(null===(r=o.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(u," ").concat(n[a])))||null;if(null===o)return null}return o}function p(n,t){var e,r=function(n,t,e){if(e||2===arguments.length)for(var r,o=0,u=t.length;o<u;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return n.concat(r||Array.prototype.slice.call(t))}([],n,!0),o=r.pop();if(!r.length)return t.querySelectorAll(o);var i=v(r,t);return(null===(e=null==i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelectorAll("".concat(u," ").concat(o)))||null}function m(n,t){if(1===n.length&&!n[0].length){if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(y());return t.shadowRoot}var e=v(n,t);return(null==e?void 0:e.shadowRoot)||null}function w(n,t,e,r){void 0===e&&(e="querySelector"),void 0===r&&(r="shadowRootQuerySelector");for(var o=s(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f(e,r));return n})),u=o.length,i=0;i<u;i++){var a=v(o[i],t);if(a)return a}return null}function g(n,t,e){void 0===e&&(e="querySelectorAll");for(var r=s(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(f(e));return n})),o=r.length,u=0;u<o;u++){var a=p(r[u],t);if(null==a?void 0:a.length)return a}return document.querySelectorAll(i)}function b(n,t,e,r){void 0===e&&(e="shadowRootQuerySelector"),void 0===r&&(r="querySelector");for(var u=s(n,(function(n){if(n.pop().length)throw new SyntaxError(function(n,t){return"".concat(n," must be used with a selector ending in a shadowRoot (").concat(o,"). If you don't want to select a shadowRoot, use ").concat(t," instead.")}(e,r));return n})),i=u.length,a=0;a<i;a++){var l=m(u[a],t);if(l)return l}return null}function S(t,o,u,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,n((function(){return w(t,o,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(n){return!!n}),{retries:u,delay:i,shouldReject:!1})]}))}))}function R(t,o,u,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,n((function(){return g(t,o,"asyncQuerySelectorAll")}),(function(n){return!!n.length}),{retries:u,delay:i,shouldReject:!1})]}))}))}function P(t,o,u,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,n((function(){return b(t,o,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(n){return!!n}),{retries:u,delay:i,shouldReject:!1})]}))}))}var _=function(n,t){var e=n.querySelectorAll(t);if(e.length)return e;if(n instanceof Element&&n.shadowRoot){var r=_(n.shadowRoot,t);if(r.length)return r}for(var o=0,u=Array.from(n.querySelectorAll("*"));o<u.length;o++){var a=u[o],l=_(a,t);if(l.length)return l}return document.querySelectorAll(i)},q=function(t,e,r,o){return n((function(){return _(t,e)}),(function(n){return!!n.length}),{retries:r,delay:o,shouldReject:!1})};function x(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?w(e,document):w(r,e)}function A(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?_(document,e)[0]||null:_(e,r)[0]||null}function j(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?g(e,document):g(r,e)}function E(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?_(document,e):_(e,r)}function N(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=n[0],r=n[1];return"string"==typeof e?b(e,document):b(r,e)}function L(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e(this,void 0,void 0,(function(){var t,e,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(n)?(t=n[0],e=n[1],o=n[2],[4,S(e,t,(null==o?void 0:o.retries)||a,(null==o?void 0:o.delay)||l)]):[3,2];case 1:case 3:return[2,r.sent()];case 2:return u=n[0],i=n[1],[4,S(u,document,(null==i?void 0:i.retries)||a,(null==i?void 0:i.delay)||l)]}}))}))}function O(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e(this,void 0,void 0,(function(){var t,e,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(n)?(t=n[0],e=n[1],o=n[2],[4,q(t,e,(null==o?void 0:o.retries)||a,(null==o?void 0:o.delay)||l)]):[3,2];case 1:case 3:return[2,r.sent()[0]||null];case 2:return u=n[0],i=n[1],[4,q(document,u,(null==i?void 0:i.retries)||a,(null==i?void 0:i.delay)||l)]}}))}))}function Q(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e(this,void 0,void 0,(function(){var t,e,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(n)?(t=n[0],e=n[1],o=n[2],[4,R(e,t,(null==o?void 0:o.retries)||a,(null==o?void 0:o.delay)||l)]):[3,2];case 1:return[2,r.sent()];case 2:return u=n[0],i=n[1],[2,R(u,document,(null==i?void 0:i.retries)||a,(null==i?void 0:i.delay)||l)]}}))}))}function k(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];if(c(n)){var e=n[0],r=n[1],o=n[2];return q(e,r,(null==o?void 0:o.retries)||a,(null==o?void 0:o.delay)||l)}var u=n[0],i=n[1];return q(document,u,(null==i?void 0:i.retries)||a,(null==i?void 0:i.delay)||l)}function D(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e(this,void 0,void 0,(function(){var t,e,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(n)?(t=n[0],e=n[1],o=n[2],[4,P(e,t,(null==o?void 0:o.retries)||a,(null==o?void 0:o.delay)||l)]):[3,2];case 1:return[2,r.sent()];case 2:return u=n[0],i=n[1],[2,P(u,document,(null==i?void 0:i.retries)||a,(null==i?void 0:i.delay)||l)]}}))}))}var I=function(){function n(n,e){n instanceof Node||n instanceof Promise?(this._element=n,this._asyncParams=t({retries:a,delay:l},e||{})):(this._element=document,this._asyncParams=t({retries:a,delay:l},n||{}))}return Object.defineProperty(n.prototype,"element",{get:function(){return d(this._element).then((function(n){return n instanceof NodeList?n[0]||null:n}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"$",{get:function(){var t=this;return new n(d(this._element).then((function(n){return n instanceof Document||n instanceof ShadowRoot||null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?D(n[0],o,t._asyncParams):D(n,o,t._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"all",{get:function(){return d(this._element).then((function(n){return n instanceof NodeList?n:document.querySelectorAll(i)}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),n.prototype.eq=function(n){return e(this,void 0,void 0,(function(){return r(this,(function(t){return[2,d(this._element).then((function(t){return t instanceof NodeList&&t[n]||null}))]}))}))},n.prototype.query=function(t){var e=this;return new n(d(this._element).then((function(n){return null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?Q(n[0],t,e._asyncParams):Q(n,t,e._asyncParams)})),this._asyncParams)},n.prototype.deepQuery=function(t){var e=this;return new n(d(this._element).then((function(n){return null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?Promise.race(Array.from(n).map((function(n){return q(n,t,e._asyncParams.retries,e._asyncParams.delay)}))):q(n,t,e._asyncParams.retries,e._asyncParams.delay)})),this._asyncParams)},n}();export{I as AsyncSelector,O as asyncDeepQuerySelector,k as asyncDeepQuerySelectorAll,L as asyncQuerySelector,Q as asyncQuerySelectorAll,D as asyncShadowRootQuerySelector,A as deepQuerySelector,E as deepQuerySelectorAll,x as querySelector,j as querySelectorAll,N as shadowRootQuerySelector};
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ interface AsyncParams {
2
2
  retries?: number;
3
3
  delay?: number;
4
4
  }
5
- declare const SHADOW_ROOT_SELECTOR = "$";
6
5
  declare function querySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): E | null;
7
6
  declare function querySelector<E extends Element = Element>(selectors: string): E | null;
8
7
  declare function deepQuerySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): E | null;
@@ -29,7 +28,7 @@ declare class AsyncSelector<T extends Document | Element | ShadowRoot> {
29
28
  private _element;
30
29
  private _asyncParams;
31
30
  get element(): Promise<T | null>;
32
- get [SHADOW_ROOT_SELECTOR](): AsyncSelector<ShadowRoot>;
31
+ get $(): AsyncSelector<ShadowRoot>;
33
32
  get all(): Promise<NodeListOf<Element>>;
34
33
  get asyncParams(): AsyncParams;
35
34
  eq(index: number): Promise<Element | null>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).ShadowDomSelector={})}(this,(function(n){"use strict";var e=function(){return e=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n},e.apply(this,arguments)};function t(n,e,t,r){return new(t||(t=Promise))((function(o,u){function i(n){try{l(r.next(n))}catch(n){u(n)}}function c(n){try{l(r.throw(n))}catch(n){u(n)}}function l(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(i,c)}l((r=r.apply(n,e||[])).next())}))}function r(n,e){var t,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(l){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(n,i)}catch(n){c=[6,n],r=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,l])}}}"function"==typeof SuppressedError&&SuppressedError;var o="$",u=":host",i="invalid selector",c=10,l=10,a=function(n){var e,t=n[0],r=n[1];return(e=t)&&(e instanceof Document||e instanceof Element||e instanceof ShadowRoot)&&"string"==typeof r};function s(n,e){return function(n){return n.split(",").map((function(n){return n.trim()}))}(n).map((function(n){var t=function(n){return n.split(o).map((function(n){return n.trim()}))}(n);return e(t)}))}var f=function(n,e,t,r){return new Promise((function(o){var u=0,i=function(){var c=n();e(c)?o(c):++u<t?setTimeout(i,r):o(c)};i()}))};function d(n,e){var t=e?" If you want to select a shadowRoot, use ".concat(e," instead."):"";return"".concat(n," cannot be used with a selector ending in a shadowRoot (").concat(o,").").concat(t)}function h(n){return n instanceof Promise?n:Promise.resolve(n)}function y(){return"You can not select a shadowRoot (".concat(o,") of the document.")}function v(){return"You can not select a shadowRoot (".concat(o,") of a shadowRoot.")}function p(n,e){for(var t,r,o=null,i=n.length,c=0;c<i;c++){if(0===c)if(n[c].length)o=e.querySelector(n[c]);else{if(e instanceof Document)throw new SyntaxError(y());if(e instanceof ShadowRoot)throw new SyntaxError(v());o=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector(n[++c]))||null}else o=(null===(r=o.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(u," ").concat(n[c])))||null;if(null===o)return null}return o}function m(n,e){var t,r=function(n,e,t){if(t||2===arguments.length)for(var r,o=0,u=e.length;o<u;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return n.concat(r||Array.prototype.slice.call(e))}([],n,!0),o=r.pop();if(!r.length)return e.querySelectorAll(o);var i=p(r,e);return(null===(t=null==i?void 0:i.shadowRoot)||void 0===t?void 0:t.querySelectorAll("".concat(u," ").concat(o)))||null}function w(n,e){if(1===n.length&&!n[0].length){if(e instanceof Document)throw new SyntaxError(y());if(e instanceof ShadowRoot)throw new SyntaxError(v());return e.shadowRoot}var t=p(n,e);return(null==t?void 0:t.shadowRoot)||null}function g(n,e,t,r){void 0===t&&(t="querySelector"),void 0===r&&(r="shadowRootQuerySelector");for(var o=s(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(d(t,r));return n})),u=o.length,i=0;i<u;i++){var c=p(o[i],e);if(c)return c}return null}function S(n,e,t){void 0===t&&(t="querySelectorAll");for(var r=s(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(d(t));return n})),o=r.length,u=0;u<o;u++){var c=m(r[u],e);if(null==c?void 0:c.length)return c}return document.querySelectorAll(i)}function b(n,e,t,r){void 0===t&&(t="shadowRootQuerySelector"),void 0===r&&(r="querySelector");for(var u=s(n,(function(n){if(n.pop().length)throw new SyntaxError(function(n,e){return"".concat(n," must be used with a selector ending in a shadowRoot (").concat(o,"). If you don't want to select a shadowRoot, use ").concat(e," instead.")}(t,r));return n})),i=u.length,c=0;c<i;c++){var l=w(u[c],e);if(l)return l}return null}function P(n,e,o,u){return t(this,void 0,void 0,(function(){return r(this,(function(t){return[2,f((function(){return g(n,e,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(n){return!!n}),o,u)]}))}))}function R(n,e,o,u){return t(this,void 0,void 0,(function(){return r(this,(function(t){return[2,f((function(){return S(n,e,"asyncQuerySelectorAll")}),(function(n){return!!n.length}),o,u)]}))}))}function _(n,e,o,u){return t(this,void 0,void 0,(function(){return r(this,(function(t){return[2,f((function(){return b(n,e,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(n){return!!n}),o,u)]}))}))}var A=function(n,e){var t=n.querySelectorAll(e);if(t.length)return t;if(n instanceof Element&&n.shadowRoot){var r=A(n.shadowRoot,e);if(r.length)return r}for(var o=0,u=Array.from(n.querySelectorAll("*"));o<u.length;o++){var c=u[o],l=A(c,e);if(l.length)return l}return document.querySelectorAll(i)},q=function(n,e,t,r){return f((function(){return A(n,e)}),(function(n){return!!n.length}),t,r)};function Q(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(this,void 0,void 0,(function(){var e,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return a(n)?(e=n[0],t=n[1],o=n[2],[4,R(t,e,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:return[2,r.sent()];case 2:return u=n[0],i=n[1],[2,R(u,document,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))}function x(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(this,void 0,void 0,(function(){var e,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return a(n)?(e=n[0],t=n[1],o=n[2],[4,_(t,e,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:return[2,r.sent()];case 2:return u=n[0],i=n[1],[2,_(u,document,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))}var E=function(){function n(n,t){n instanceof Node||n instanceof Promise?(this._element=n,this._asyncParams=e({retries:c,delay:l},t||{})):(this._element=document,this._asyncParams=e({retries:c,delay:l},n||{}))}return Object.defineProperty(n.prototype,"element",{get:function(){return h(this._element).then((function(n){return n instanceof NodeList?n[0]||null:n}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,o,{get:function(){var e=this;return new n(h(this._element).then((function(n){return n instanceof Document||n instanceof ShadowRoot||null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?x(n[0],o,e._asyncParams):x(n,o,e._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"all",{get:function(){return h(this._element).then((function(n){return n instanceof NodeList?n:document.querySelectorAll(i)}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),n.prototype.eq=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(e){return[2,h(this._element).then((function(e){return e instanceof NodeList&&e[n]||null}))]}))}))},n.prototype.query=function(e){var t=this;return new n(h(this._element).then((function(n){return null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?Q(n[0],e,t._asyncParams):Q(n,e,t._asyncParams)})),this._asyncParams)},n.prototype.deepQuery=function(e){var t=this;return new n(h(this._element).then((function(n){return null===n||n instanceof NodeList&&0===n.length?null:n instanceof NodeList?Promise.race(Array.from(n).map((function(n){return q(n,e,t._asyncParams.retries,t._asyncParams.delay)}))):q(n,e,t._asyncParams.retries,t._asyncParams.delay)})),this._asyncParams)},n}();n.AsyncSelector=E,n.asyncDeepQuerySelector=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(this,void 0,void 0,(function(){var e,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return a(n)?(e=n[0],t=n[1],o=n[2],[4,q(e,t,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:case 3:return[2,r.sent()[0]||null];case 2:return u=n[0],i=n[1],[4,q(document,u,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))},n.asyncDeepQuerySelectorAll=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(a(n)){var t=n[0],r=n[1],o=n[2];return q(t,r,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)}var u=n[0],i=n[1];return q(document,u,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)},n.asyncQuerySelector=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(this,void 0,void 0,(function(){var e,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return a(n)?(e=n[0],t=n[1],o=n[2],[4,P(t,e,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:case 3:return[2,r.sent()];case 2:return u=n[0],i=n[1],[4,P(u,document,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))},n.asyncQuerySelectorAll=Q,n.asyncShadowRootQuerySelector=x,n.deepQuerySelector=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?A(document,t)[0]||null:A(t,r)[0]||null},n.deepQuerySelectorAll=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?A(document,t):A(t,r)},n.querySelector=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?g(t,document):g(r,t)},n.querySelectorAll=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?S(t,document):S(r,t)},n.shadowRootQuerySelector=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?b(t,document):b(r,t)}}));
1
+ "use strict";var e=require("get-promisable-result"),t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(o,u){function i(e){try{a(r.next(e))}catch(e){u(e)}}function l(e){try{a(r.throw(e))}catch(e){u(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}a((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,r=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){u=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){u.label=l[1];break}if(6===l[0]&&u.label<o[1]){u.label=o[1],o=l;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(l);break}o[2]&&u.ops.pop(),u.trys.pop();continue}l=t.call(e,u)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}"function"==typeof SuppressedError&&SuppressedError;var o="$",u=":host",i="invalid selector",l=10,a=10,c=function(e){var t,n=e[0],r=e[1];return(t=n)&&(t instanceof Document||t instanceof Element||t instanceof ShadowRoot)&&"string"==typeof r};function s(e,t){return function(e){return e.split(",").map((function(e){return e.trim()}))}(e).map((function(e){var n=function(e){return e.split(o).map((function(e){return e.trim()}))}(e);return t(n)}))}function f(e,t){var n=t?" If you want to select a shadowRoot, use ".concat(t," instead."):"";return"".concat(e," cannot be used with a selector ending in a shadowRoot (").concat(o,").").concat(n)}function d(e){return e instanceof Promise?e:Promise.resolve(e)}function h(){return"You can not select a shadowRoot (".concat(o,") of the document.")}function y(){return"You can not select a shadowRoot (".concat(o,") of a shadowRoot.")}function v(e,t){for(var n,r,o=null,i=e.length,l=0;l<i;l++){if(0===l)if(e[l].length)o=t.querySelector(e[l]);else{if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(y());o=(null===(n=t.shadowRoot)||void 0===n?void 0:n.querySelector(e[++l]))||null}else o=(null===(r=o.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(u," ").concat(e[l])))||null;if(null===o)return null}return o}function p(e,t){var n,r=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,u=t.length;o<u;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0),o=r.pop();if(!r.length)return t.querySelectorAll(o);var i=v(r,t);return(null===(n=null==i?void 0:i.shadowRoot)||void 0===n?void 0:n.querySelectorAll("".concat(u," ").concat(o)))||null}function m(e,t){if(1===e.length&&!e[0].length){if(t instanceof Document)throw new SyntaxError(h());if(t instanceof ShadowRoot)throw new SyntaxError(y());return t.shadowRoot}var n=v(e,t);return(null==n?void 0:n.shadowRoot)||null}function g(e,t,n,r){void 0===n&&(n="querySelector"),void 0===r&&(r="shadowRootQuerySelector");for(var o=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(f(n,r));return e})),u=o.length,i=0;i<u;i++){var l=v(o[i],t);if(l)return l}return null}function w(e,t,n){void 0===n&&(n="querySelectorAll");for(var r=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(f(n));return e})),o=r.length,u=0;u<o;u++){var l=p(r[u],t);if(null==l?void 0:l.length)return l}return document.querySelectorAll(i)}function S(e,t,n,r){void 0===n&&(n="shadowRootQuerySelector"),void 0===r&&(r="querySelector");for(var u=s(e,(function(e){if(e.pop().length)throw new SyntaxError(function(e,t){return"".concat(e," must be used with a selector ending in a shadowRoot (").concat(o,"). If you don't want to select a shadowRoot, use ").concat(t," instead.")}(n,r));return e})),i=u.length,l=0;l<i;l++){var a=m(u[l],t);if(a)return a}return null}function b(t,o,u,i){return n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,e.getPromisableResult((function(){return g(t,o,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(e){return!!e}),{retries:u,delay:i,shouldReject:!1})]}))}))}function R(t,o,u,i){return n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,e.getPromisableResult((function(){return w(t,o,"asyncQuerySelectorAll")}),(function(e){return!!e.length}),{retries:u,delay:i,shouldReject:!1})]}))}))}function P(t,o,u,i){return n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,e.getPromisableResult((function(){return S(t,o,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(e){return!!e}),{retries:u,delay:i,shouldReject:!1})]}))}))}var x=function(e,t){var n=e.querySelectorAll(t);if(n.length)return n;if(e instanceof Element&&e.shadowRoot){var r=x(e.shadowRoot,t);if(r.length)return r}for(var o=0,u=Array.from(e.querySelectorAll("*"));o<u.length;o++){var l=u[o],a=x(l,t);if(a.length)return a}return document.querySelectorAll(i)},_=function(t,n,r,o){return e.getPromisableResult((function(){return x(t,n)}),(function(e){return!!e.length}),{retries:r,delay:o,shouldReject:!1})};function q(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,n,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(e)?(t=e[0],n=e[1],o=e[2],[4,R(n,t,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,r.sent()];case 2:return u=e[0],i=e[1],[2,R(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||a)]}}))}))}function A(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,n,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(e)?(t=e[0],n=e[1],o=e[2],[4,P(n,t,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,r.sent()];case 2:return u=e[0],i=e[1],[2,P(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||a)]}}))}))}var Q=function(){function e(e,n){e instanceof Node||e instanceof Promise?(this._element=e,this._asyncParams=t({retries:l,delay:a},n||{})):(this._element=document,this._asyncParams=t({retries:l,delay:a},e||{}))}return Object.defineProperty(e.prototype,"element",{get:function(){return d(this._element).then((function(e){return e instanceof NodeList?e[0]||null:e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$",{get:function(){var t=this;return new e(d(this._element).then((function(e){return e instanceof Document||e instanceof ShadowRoot||null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?A(e[0],o,t._asyncParams):A(e,o,t._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"all",{get:function(){return d(this._element).then((function(e){return e instanceof NodeList?e:document.querySelectorAll(i)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),e.prototype.eq=function(e){return n(this,void 0,void 0,(function(){return r(this,(function(t){return[2,d(this._element).then((function(t){return t instanceof NodeList&&t[e]||null}))]}))}))},e.prototype.query=function(t){var n=this;return new e(d(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?q(e[0],t,n._asyncParams):q(e,t,n._asyncParams)})),this._asyncParams)},e.prototype.deepQuery=function(t){var n=this;return new e(d(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?Promise.race(Array.from(e).map((function(e){return _(e,t,n._asyncParams.retries,n._asyncParams.delay)}))):_(e,t,n._asyncParams.retries,n._asyncParams.delay)})),this._asyncParams)},e}();exports.AsyncSelector=Q,exports.asyncDeepQuerySelector=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,n,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(e)?(t=e[0],n=e[1],o=e[2],[4,_(t,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||a)]):[3,2];case 1:case 3:return[2,r.sent()[0]||null];case 2:return u=e[0],i=e[1],[4,_(document,u,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||a)]}}))}))},exports.asyncDeepQuerySelectorAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(c(e)){var n=e[0],r=e[1],o=e[2];return _(n,r,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||a)}var u=e[0],i=e[1];return _(document,u,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||a)},exports.asyncQuerySelector=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,n,o,u,i;return r(this,(function(r){switch(r.label){case 0:return c(e)?(t=e[0],n=e[1],o=e[2],[4,b(n,t,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||a)]):[3,2];case 1:case 3:return[2,r.sent()];case 2:return u=e[0],i=e[1],[4,b(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||a)]}}))}))},exports.asyncQuerySelectorAll=q,exports.asyncShadowRootQuerySelector=A,exports.deepQuerySelector=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0],r=e[1];return"string"==typeof n?x(document,n)[0]||null:x(n,r)[0]||null},exports.deepQuerySelectorAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0],r=e[1];return"string"==typeof n?x(document,n):x(n,r)},exports.querySelector=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0],r=e[1];return"string"==typeof n?g(n,document):g(r,n)},exports.querySelectorAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0],r=e[1];return"string"==typeof n?w(n,document):w(r,n)},exports.shadowRootQuerySelector=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0],r=e[1];return"string"==typeof n?S(n,document):S(r,n)};
@@ -0,0 +1,39 @@
1
+ interface AsyncParams {
2
+ retries?: number;
3
+ delay?: number;
4
+ }
5
+ declare function querySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): E | null;
6
+ declare function querySelector<E extends Element = Element>(selectors: string): E | null;
7
+ declare function deepQuerySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): E | null;
8
+ declare function deepQuerySelector<E extends Element = Element>(selectors: string): E | null;
9
+ declare function querySelectorAll<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): NodeListOf<E>;
10
+ declare function querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
11
+ declare function deepQuerySelectorAll<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string): NodeListOf<E>;
12
+ declare function deepQuerySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
13
+ declare function shadowRootQuerySelector(root: Document | Element | ShadowRoot, selectors: string): ShadowRoot | null;
14
+ declare function shadowRootQuerySelector(selectors: string): ShadowRoot | null;
15
+ declare function asyncQuerySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string, asyncParams?: AsyncParams): Promise<E | null>;
16
+ declare function asyncQuerySelector<E extends Element = Element>(selectors: string, asyncParams?: AsyncParams): Promise<E | null>;
17
+ declare function asyncDeepQuerySelector<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string, asyncParams?: AsyncParams): Promise<E | null>;
18
+ declare function asyncDeepQuerySelector<E extends Element = Element>(selectors: string, asyncParams?: AsyncParams): Promise<E | null>;
19
+ declare function asyncQuerySelectorAll<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string, asyncParams?: AsyncParams): Promise<NodeListOf<E>>;
20
+ declare function asyncQuerySelectorAll<E extends Element = Element>(selectors: string, asyncParams?: AsyncParams): Promise<NodeListOf<E>>;
21
+ declare function asyncDeepQuerySelectorAll<E extends Element = Element>(root: Document | Element | ShadowRoot, selectors: string, asyncParams?: AsyncParams): Promise<NodeListOf<E>>;
22
+ declare function asyncDeepQuerySelectorAll<E extends Element = Element>(selectors: string, asyncParams?: AsyncParams): Promise<NodeListOf<E>>;
23
+ declare function asyncShadowRootQuerySelector(root: Document | Element | ShadowRoot, selectors: string, asyncParams?: AsyncParams): Promise<ShadowRoot | null>;
24
+ declare function asyncShadowRootQuerySelector(selectors: string, asyncParams?: AsyncParams): Promise<ShadowRoot | null>;
25
+ declare class AsyncSelector<T extends Document | Element | ShadowRoot> {
26
+ constructor(asyncParams?: AsyncParams);
27
+ constructor(root?: T | Promise<T | NodeListOf<Element>>, asyncParams?: AsyncParams);
28
+ private _element;
29
+ private _asyncParams;
30
+ get element(): Promise<T | null>;
31
+ get $(): AsyncSelector<ShadowRoot>;
32
+ get all(): Promise<NodeListOf<Element>>;
33
+ get asyncParams(): AsyncParams;
34
+ eq(index: number): Promise<Element | null>;
35
+ query(selector: string): AsyncSelector<Element>;
36
+ deepQuery(selector: string): AsyncSelector<Element>;
37
+ }
38
+ export { querySelector, deepQuerySelector, querySelectorAll, deepQuerySelectorAll, shadowRootQuerySelector, asyncQuerySelector, asyncDeepQuerySelector, asyncQuerySelectorAll, asyncDeepQuerySelectorAll, asyncShadowRootQuerySelector, AsyncSelector };
39
+ export type { AsyncParams };
@@ -0,0 +1 @@
1
+ var ShadowDomSelector=function(e){"use strict";var n=function(){return n=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},n.apply(this,arguments)};function t(e,n,t,r){return new(t||(t=Promise))((function(o,u){function i(e){try{l(r.next(e))}catch(e){u(e)}}function c(e){try{l(r.throw(e))}catch(e){u(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,c)}l((r=r.apply(e,n||[])).next())}))}function r(e,n){var t,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(l){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(t=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(e,u)}catch(e){c=[6,e],r=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,l])}}}"function"==typeof SuppressedError&&SuppressedError;var o="$",u=":host",i="invalid selector",c=10,l=10,a=function(e,n,t){var r;void 0===t&&(t={});var o=t.retries,u=void 0===o?10:o,i=t.delay,c=void 0===i?10:i,l=t.shouldReject,a=void 0===l||l,s=null!==(r=t.rejectMessage)&&void 0!==r?r:"Could not get the result after {{ retries }} retries";return new Promise((function(t,r){var o=0,i=function(){var l=e();n(l)?t(l):++o<u?setTimeout(i,c):a?r(new Error(s.replace(/\{\{\s*retries\s*\}\}/g,"".concat(u)))):t(l)};i()}))},s=function(e){var n,t=e[0],r=e[1];return(n=t)&&(n instanceof Document||n instanceof Element||n instanceof ShadowRoot)&&"string"==typeof r};function f(e,n){return function(e){return e.split(",").map((function(e){return e.trim()}))}(e).map((function(e){var t=function(e){return e.split(o).map((function(e){return e.trim()}))}(e);return n(t)}))}function d(e,n){var t=n?" If you want to select a shadowRoot, use ".concat(n," instead."):"";return"".concat(e," cannot be used with a selector ending in a shadowRoot (").concat(o,").").concat(t)}function h(e){return e instanceof Promise?e:Promise.resolve(e)}function y(){return"You can not select a shadowRoot (".concat(o,") of the document.")}function v(){return"You can not select a shadowRoot (".concat(o,") of a shadowRoot.")}function p(e,n){for(var t,r,o=null,i=e.length,c=0;c<i;c++){if(0===c)if(e[c].length)o=n.querySelector(e[c]);else{if(n instanceof Document)throw new SyntaxError(y());if(n instanceof ShadowRoot)throw new SyntaxError(v());o=(null===(t=n.shadowRoot)||void 0===t?void 0:t.querySelector(e[++c]))||null}else o=(null===(r=o.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(u," ").concat(e[c])))||null;if(null===o)return null}return o}function m(e,n){var t,r=function(e,n,t){if(t||2===arguments.length)for(var r,o=0,u=n.length;o<u;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0),o=r.pop();if(!r.length)return n.querySelectorAll(o);var i=p(r,n);return(null===(t=null==i?void 0:i.shadowRoot)||void 0===t?void 0:t.querySelectorAll("".concat(u," ").concat(o)))||null}function w(e,n){if(1===e.length&&!e[0].length){if(n instanceof Document)throw new SyntaxError(y());if(n instanceof ShadowRoot)throw new SyntaxError(v());return n.shadowRoot}var t=p(e,n);return(null==t?void 0:t.shadowRoot)||null}function g(e,n,t,r){void 0===t&&(t="querySelector"),void 0===r&&(r="shadowRootQuerySelector");for(var o=f(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d(t,r));return e})),u=o.length,i=0;i<u;i++){var c=p(o[i],n);if(c)return c}return null}function S(e,n,t){void 0===t&&(t="querySelectorAll");for(var r=f(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d(t));return e})),o=r.length,u=0;u<o;u++){var c=m(r[u],n);if(null==c?void 0:c.length)return c}return document.querySelectorAll(i)}function b(e,n,t,r){void 0===t&&(t="shadowRootQuerySelector"),void 0===r&&(r="querySelector");for(var u=f(e,(function(e){if(e.pop().length)throw new SyntaxError(function(e,n){return"".concat(e," must be used with a selector ending in a shadowRoot (").concat(o,"). If you don't want to select a shadowRoot, use ").concat(n," instead.")}(t,r));return e})),i=u.length,c=0;c<i;c++){var l=w(u[c],n);if(l)return l}return null}function R(e,n,o,u){return t(this,void 0,void 0,(function(){return r(this,(function(t){return[2,a((function(){return g(e,n,"asyncQuerySelector","asyncShadowRootQuerySelector")}),(function(e){return!!e}),{retries:o,delay:u,shouldReject:!1})]}))}))}function P(e,n,o,u){return t(this,void 0,void 0,(function(){return r(this,(function(t){return[2,a((function(){return S(e,n,"asyncQuerySelectorAll")}),(function(e){return!!e.length}),{retries:o,delay:u,shouldReject:!1})]}))}))}function _(e,n,o,u){return t(this,void 0,void 0,(function(){return r(this,(function(t){return[2,a((function(){return b(e,n,"asyncShadowRootQuerySelector","asyncQuerySelector")}),(function(e){return!!e}),{retries:o,delay:u,shouldReject:!1})]}))}))}var A=function(e,n){var t=e.querySelectorAll(n);if(t.length)return t;if(e instanceof Element&&e.shadowRoot){var r=A(e.shadowRoot,n);if(r.length)return r}for(var o=0,u=Array.from(e.querySelectorAll("*"));o<u.length;o++){var c=u[o],l=A(c,n);if(l.length)return l}return document.querySelectorAll(i)},q=function(e,n,t,r){return a((function(){return A(e,n)}),(function(e){return!!e.length}),{retries:t,delay:r,shouldReject:!1})};function Q(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t(this,void 0,void 0,(function(){var n,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return s(e)?(n=e[0],t=e[1],o=e[2],[4,P(t,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:return[2,r.sent()];case 2:return u=e[0],i=e[1],[2,P(u,document,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))}function j(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t(this,void 0,void 0,(function(){var n,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return s(e)?(n=e[0],t=e[1],o=e[2],[4,_(t,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:return[2,r.sent()];case 2:return u=e[0],i=e[1],[2,_(u,document,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))}var E=function(){function e(e,t){e instanceof Node||e instanceof Promise?(this._element=e,this._asyncParams=n({retries:c,delay:l},t||{})):(this._element=document,this._asyncParams=n({retries:c,delay:l},e||{}))}return Object.defineProperty(e.prototype,"element",{get:function(){return h(this._element).then((function(e){return e instanceof NodeList?e[0]||null:e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$",{get:function(){var n=this;return new e(h(this._element).then((function(e){return e instanceof Document||e instanceof ShadowRoot||null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?j(e[0],o,n._asyncParams):j(e,o,n._asyncParams)})),this._asyncParams)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"all",{get:function(){return h(this._element).then((function(e){return e instanceof NodeList?e:document.querySelectorAll(i)}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"asyncParams",{get:function(){return this._asyncParams},enumerable:!1,configurable:!0}),e.prototype.eq=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(n){return[2,h(this._element).then((function(n){return n instanceof NodeList&&n[e]||null}))]}))}))},e.prototype.query=function(n){var t=this;return new e(h(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?Q(e[0],n,t._asyncParams):Q(e,n,t._asyncParams)})),this._asyncParams)},e.prototype.deepQuery=function(n){var t=this;return new e(h(this._element).then((function(e){return null===e||e instanceof NodeList&&0===e.length?null:e instanceof NodeList?Promise.race(Array.from(e).map((function(e){return q(e,n,t._asyncParams.retries,t._asyncParams.delay)}))):q(e,n,t._asyncParams.retries,t._asyncParams.delay)})),this._asyncParams)},e}();return e.AsyncSelector=E,e.asyncDeepQuerySelector=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t(this,void 0,void 0,(function(){var n,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return s(e)?(n=e[0],t=e[1],o=e[2],[4,q(n,t,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:case 3:return[2,r.sent()[0]||null];case 2:return u=e[0],i=e[1],[4,q(document,u,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))},e.asyncDeepQuerySelectorAll=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(s(e)){var t=e[0],r=e[1],o=e[2];return q(t,r,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)}var u=e[0],i=e[1];return q(document,u,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)},e.asyncQuerySelector=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t(this,void 0,void 0,(function(){var n,t,o,u,i;return r(this,(function(r){switch(r.label){case 0:return s(e)?(n=e[0],t=e[1],o=e[2],[4,R(t,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||l)]):[3,2];case 1:case 3:return[2,r.sent()];case 2:return u=e[0],i=e[1],[4,R(u,document,(null==i?void 0:i.retries)||c,(null==i?void 0:i.delay)||l)]}}))}))},e.asyncQuerySelectorAll=Q,e.asyncShadowRootQuerySelector=j,e.deepQuerySelector=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=e[0],r=e[1];return"string"==typeof t?A(document,t)[0]||null:A(t,r)[0]||null},e.deepQuerySelectorAll=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=e[0],r=e[1];return"string"==typeof t?A(document,t):A(t,r)},e.querySelector=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=e[0],r=e[1];return"string"==typeof t?g(t,document):g(r,t)},e.querySelectorAll=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=e[0],r=e[1];return"string"==typeof t?S(t,document):S(r,t)},e.shadowRootQuerySelector=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=e[0],r=e[1];return"string"==typeof t?b(t,document):b(r,t)},e}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadow-dom-selector",
3
- "version": "4.1.2",
3
+ "version": "5.0.0",
4
4
  "description": "A very small JavaScript utility to query DOM elements through the Shadow Dom subtrees in a sync or an async way",
5
5
  "keywords": [
6
6
  "query-selector",
@@ -44,30 +44,37 @@
44
44
  "clean": "rm -rf dist .nyc_output coverage || true",
45
45
  "demo": "rollup --config rollup.test.config.js --bundleConfigAsCjs -w",
46
46
  "coverage:report": "nyc report --reporter=lcov --reporter=text-summary",
47
- "lint": "eslint \"src/**/*.ts\" \"demo/**/*.ts\" \"cypress/**/*.ts\"",
48
- "lint:fix": "yarn lint --fix",
49
- "test": "cypress run",
47
+ "lint": "eslint \"src/**/*.ts\" \"demo/**/*.ts\" \"tests/**/*.ts\"",
48
+ "lint:fix": "pnpm lint --fix",
50
49
  "test:ts": "tsc --noEmit",
51
- "test:open": "yarn clean && cypress open",
52
- "test:ci": "yarn clean && start-server-and-test demo http://localhost:3000 test && yarn coverage:report",
53
- "prepare": "yarn build",
54
- "prepublishOnly": "yarn lint && yarn test:ts && yarn test:ci",
50
+ "test:run": "playwright test",
51
+ "test:open": "playwright test --ui",
52
+ "test:ci": "pnpm clean && pnpm test:run",
53
+ "prepare": "pnpm build",
54
+ "prepublishOnly": "pnpm lint && pnpm test:ts && pnpm test:ci",
55
55
  "version": "git add .",
56
56
  "postversion": "git push && git push --tags"
57
57
  },
58
58
  "devDependencies": {
59
- "@cypress/code-coverage": "^3.12.15",
60
- "@types/eslint": "^8.44.9",
61
- "@typescript-eslint/eslint-plugin": "^6.15.0",
62
- "@typescript-eslint/parser": "^6.15.0",
63
- "cypress": "^13.6.1",
64
- "eslint": "^8.56.0",
65
- "rollup": "^4.9.1",
59
+ "@playwright/test": "^1.48.2",
60
+ "@rollup/plugin-node-resolve": "^15.3.0",
61
+ "@rollup/plugin-terser": "^0.4.4",
62
+ "@types/eslint": "^9.6.1",
63
+ "@types/node": "^22.8.7",
64
+ "eslint": "^9.14.0",
65
+ "get-promisable-result": "^1.0.1",
66
+ "globals": "^15.11.0",
67
+ "nyc": "^17.1.0",
68
+ "playwright-test-coverage": "^1.2.12",
69
+ "rollup": "4.24.3",
66
70
  "rollup-plugin-istanbul": "^5.0.0",
67
71
  "rollup-plugin-serve": "^2.0.3",
68
- "rollup-plugin-terser": "^7.0.2",
69
72
  "rollup-plugin-ts": "^3.4.5",
70
- "start-server-and-test": "^2.0.3",
71
- "typescript": "^5.3.3"
73
+ "tslib": "^2.8.1",
74
+ "typescript": "^5.6.3",
75
+ "typescript-eslint": "^8.12.2"
76
+ },
77
+ "peerDependencies": {
78
+ "get-promisable-result": "^1.0.0"
72
79
  }
73
80
  }