shadow-dom-selector 1.0.1 → 1.0.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.js CHANGED
@@ -1 +1 @@
1
- function n(n,e,t,r){return new(t||(t=Promise))((function(o,u){function l(n){try{a(r.next(n))}catch(n){u(n)}}function c(n){try{a(r.throw(n))}catch(n){u(n)}}function a(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(l,c)}a((r=r.apply(n,e||[])).next())}))}function e(n,e){var t,r,o,u,l={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(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(l=0)),l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=e.call(n,l)}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,a])}}}function t(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))}"function"==typeof SuppressedError&&SuppressedError;var r="$",o=":host",u="invalid selector",l=10,c=10,a=function(n){var e,t=n[0],r=n[1];return(e=t)&&(e instanceof Document||e instanceof Element)&&"string"==typeof r};function i(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(r).map((function(n){return n.trim()}))}(n);return e(t)}))}function s(n,e,t,r,o){return void 0===o&&(o=!1),new Promise((function(l){var c=0,a=function(){var i=o?n.querySelectorAll(e):n.querySelector(e);o&&i.length||!o&&null!==i?l(i):++c<t?setTimeout(a,r):l(o?document.querySelectorAll(u):null)};a()}))}function f(n,e,t){return new Promise((function(r){var o=0,u=function(){var l=n.shadowRoot;l?r(l):++o<e?setTimeout(u,t):r(null)};u()}))}function h(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(r,").").concat(t)}function d(n,e){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(e," instead.")}function v(){return"You can not select a shadowRoot (".concat(r,") of the document.")}function y(n,e){for(var t,r,u=null,l=n.length,c=0;c<l;c++){if(0===c)if(n[c].length)u=e.querySelector(n[c]);else{if(e instanceof Document)throw new SyntaxError(v());u=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector(n[++c]))||null}else u=(null===(r=u.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(o," ").concat(n[c])))||null;if(null===u)return null}return u}function w(n,e){var r,u=t([],n,!0),l=u.pop();return u.length?(null===(r=y(u,e).shadowRoot)||void 0===r?void 0:r.querySelectorAll("".concat(o," ").concat(l)))||null:e.querySelectorAll(l)}function p(n,e){var t=y(n,e);return(null==t?void 0:t.shadowRoot)||null}function g(t,r,u,l){return n(this,void 0,void 0,(function(){var n,c,a,i,h,d;return e(this,(function(e){switch(e.label){case 0:n=null,c=t.length,a=0,e.label=1;case 1:if(!(a<c))return[3,15];if(0!==a)return[3,8];if(t[a].length)return[3,5];if(r instanceof Document)throw new SyntaxError(v());return r.shadowRoot?[4,s(r.shadowRoot,t[++a],u,l)]:[3,3];case 2:return i=e.sent(),[3,4];case 3:i=null,e.label=4;case 4:return n=i,[3,7];case 5:return[4,s(r,t[a],u,l)];case 6:n=e.sent(),e.label=7;case 7:return[3,13];case 8:return[4,f(n,u,l)];case 9:return(h=e.sent())?[4,s(h,"".concat(o," ").concat(t[a]),u,l)]:[3,11];case 10:return d=e.sent(),[3,12];case 11:d=null,e.label=12;case 12:n=d,e.label=13;case 13:if(null===n)return[2,null];e.label=14;case 14:return a++,[3,1];case 15:return[2,n]}}))}))}function b(r,u,l,c){return n(this,void 0,void 0,(function(){var n,a,i,h,d,v;return e(this,(function(e){switch(e.label){case 0:return n=t([],r,!0),a=n.pop(),n.length?[3,2]:[4,s(u,a,l,c,!0)];case 1:return[2,e.sent()];case 2:return[4,g(n,u,l,c)];case 3:return(i=e.sent())?[4,f(i,l,c)]:[3,5];case 4:return d=e.sent(),[3,6];case 5:d=null,e.label=6;case 6:return(h=d)?[4,s(h,"".concat(o," ").concat(a),l,c,!0)]:[3,8];case 7:return v=e.sent(),[3,9];case 8:v=null,e.label=9;case 9:return[2,v]}}))}))}function S(t,r,o,u){return n(this,void 0,void 0,(function(){var n,l;return e(this,(function(e){switch(e.label){case 0:return[4,g(t,r,o,u)];case 1:return(n=e.sent())?[4,f(n,o,u)]:[3,3];case 2:return l=e.sent(),[3,4];case 3:l=null,e.label=4;case 4:return[2,l]}}))}))}function m(n,e){for(var t=i(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("querySelector","shadowRootQuerySelector"));return n})),r=t.length,o=0;o<r;o++){var u=y(t[o],e);if(u)return u}return null}function R(n,e){for(var t=i(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("querySelectorAll"));return n})),r=t.length,o=0;o<r;o++){var l=w(t[o],e);if(null==l?void 0:l.length)return l}return document.querySelectorAll(u)}function x(n,e){for(var t=i(n,(function(n){if(n.pop().length)throw new SyntaxError(d("shadowRootQuerySelector","querySelector"));return n})),r=t.length,o=0;o<r;o++){var u=p(t[o],e);if(u)return u}return null}function q(t,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return e(this,(function(e){switch(e.label){case 0:n=i(t,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("asyncQuerySelector","asyncShadowRootQuerySelector"));return n})),l=n.length,c=0,e.label=1;case 1:return c<l?[4,g(n[c],r,o,u)]:[3,4];case 2:if(a=e.sent())return[2,a];e.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}function E(t,r,o,l){return n(this,void 0,void 0,(function(){var n,c,a,s;return e(this,(function(e){switch(e.label){case 0:n=i(t,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("asyncQuerySelectorAll"));return n})),c=n.length,a=0,e.label=1;case 1:return a<c?[4,b(n[a],r,o,l)]:[3,4];case 2:if(null==(s=e.sent())?void 0:s.length)return[2,s];e.label=3;case 3:return a++,[3,1];case 4:return[2,document.querySelectorAll(u)]}}))}))}function A(t,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return e(this,(function(e){switch(e.label){case 0:n=i(t,(function(n){if(n.pop().length)throw new SyntaxError(d("asyncShadowRootQuerySelector","asyncQuerySelector"));return n})),l=n.length,c=0,e.label=1;case 1:return c<l?[4,S(n[c],r,o,u)]:[3,4];case 2:if(a=e.sent())return[2,a];e.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}function Q(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?m(t,document):m(r,t)}function k(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?R(t,document):R(r,t)}function D(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?x(t,document):x(r,t)}function P(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,i;return e(this,(function(e){switch(e.label){case 0:return a(t)?(n=t[0],r=t[1],o=t[2],[4,q(r,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||c)]):[3,2];case 1:case 3:return[2,e.sent()];case 2:return u=t[0],i=t[1],[4,q(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||c)]}}))}))}function T(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,i;return e(this,(function(e){switch(e.label){case 0:return a(t)?(n=t[0],r=t[1],o=t[2],[4,E(r,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||c)]):[3,2];case 1:return[2,e.sent()];case 2:return u=t[0],i=t[1],[2,E(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||c)]}}))}))}function I(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,i;return e(this,(function(e){switch(e.label){case 0:return a(t)?(n=t[0],r=t[1],o=t[2],[4,A(r,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||c)]):[3,2];case 1:return[2,e.sent()];case 2:return u=t[0],i=t[1],[2,A(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||c)]}}))}))}export{P as asyncQuerySelector,T as asyncQuerySelectorAll,I as asyncShadowRootQuerySelector,Q as querySelector,k as querySelectorAll,D as shadowRootQuerySelector};
1
+ function n(n,e,t,r){return new(t||(t=Promise))((function(o,u){function l(n){try{a(r.next(n))}catch(n){u(n)}}function c(n){try{a(r.throw(n))}catch(n){u(n)}}function a(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(l,c)}a((r=r.apply(n,e||[])).next())}))}function e(n,e){var t,r,o,u,l={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(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(l=0)),l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=e.call(n,l)}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,a])}}}function t(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))}"function"==typeof SuppressedError&&SuppressedError;var r="$",o=":host",u="invalid selector",l=10,c=10,a=function(n){var e,t=n[0],r=n[1];return(e=t)&&(e instanceof Document||e instanceof Element)&&"string"==typeof r};function i(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(r).map((function(n){return n.trim()}))}(n);return e(t)}))}function s(n,e,t,r,o){return void 0===o&&(o=!1),new Promise((function(l){var c=0,a=function(){var i=o?n.querySelectorAll(e):n.querySelector(e);o&&i.length||!o&&null!==i?l(i):++c<t?setTimeout(a,r):l(o?document.querySelectorAll(u):null)};a()}))}function f(n,e,t){return new Promise((function(r){var o=0,u=function(){var l=n.shadowRoot;l?r(l):++o<e?setTimeout(u,t):r(null)};u()}))}function h(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(r,").").concat(t)}function d(n,e){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(e," instead.")}function v(){return"You can not select a shadowRoot (".concat(r,") of the document.")}function y(n,e){for(var t,r,u=null,l=n.length,c=0;c<l;c++){if(0===c)if(n[c].length)u=e.querySelector(n[c]);else{if(e instanceof Document)throw new SyntaxError(v());u=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector(n[++c]))||null}else u=(null===(r=u.shadowRoot)||void 0===r?void 0:r.querySelector("".concat(o," ").concat(n[c])))||null;if(null===u)return null}return u}function w(n,e){var r,u=t([],n,!0),l=u.pop();return u.length?(null===(r=y(u,e).shadowRoot)||void 0===r?void 0:r.querySelectorAll("".concat(o," ").concat(l)))||null:e.querySelectorAll(l)}function g(n,e){if(1===n.length&&!n[0].length){if(e instanceof Document)throw new SyntaxError(v());return e.shadowRoot}var t=y(n,e);return(null==t?void 0:t.shadowRoot)||null}function p(t,r,u,l){return n(this,void 0,void 0,(function(){var n,c,a,i,h,d;return e(this,(function(e){switch(e.label){case 0:n=null,c=t.length,a=0,e.label=1;case 1:if(!(a<c))return[3,15];if(0!==a)return[3,8];if(t[a].length)return[3,5];if(r instanceof Document)throw new SyntaxError(v());return r.shadowRoot?[4,s(r.shadowRoot,t[++a],u,l)]:[3,3];case 2:return i=e.sent(),[3,4];case 3:i=null,e.label=4;case 4:return n=i,[3,7];case 5:return[4,s(r,t[a],u,l)];case 6:n=e.sent(),e.label=7;case 7:return[3,13];case 8:return[4,f(n,u,l)];case 9:return(h=e.sent())?[4,s(h,"".concat(o," ").concat(t[a]),u,l)]:[3,11];case 10:return d=e.sent(),[3,12];case 11:d=null,e.label=12;case 12:n=d,e.label=13;case 13:if(null===n)return[2,null];e.label=14;case 14:return a++,[3,1];case 15:return[2,n]}}))}))}function b(r,u,l,c){return n(this,void 0,void 0,(function(){var n,a,i,h,d,v;return e(this,(function(e){switch(e.label){case 0:return n=t([],r,!0),a=n.pop(),n.length?[3,2]:[4,s(u,a,l,c,!0)];case 1:return[2,e.sent()];case 2:return[4,p(n,u,l,c)];case 3:return(i=e.sent())?[4,f(i,l,c)]:[3,5];case 4:return d=e.sent(),[3,6];case 5:d=null,e.label=6;case 6:return(h=d)?[4,s(h,"".concat(o," ").concat(a),l,c,!0)]:[3,8];case 7:return v=e.sent(),[3,9];case 8:v=null,e.label=9;case 9:return[2,v]}}))}))}function S(t,r,o,u){return n(this,void 0,void 0,(function(){var n,l;return e(this,(function(e){switch(e.label){case 0:if(1===t.length&&!t[0].length){if(r instanceof Document)throw new SyntaxError(v());return[2,f(r,o,u)]}return[4,p(t,r,o,u)];case 1:return(n=e.sent())?[4,f(n,o,u)]:[3,3];case 2:return l=e.sent(),[3,4];case 3:l=null,e.label=4;case 4:return[2,l]}}))}))}function m(n,e){for(var t=i(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("querySelector","shadowRootQuerySelector"));return n})),r=t.length,o=0;o<r;o++){var u=y(t[o],e);if(u)return u}return null}function R(n,e){for(var t=i(n,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("querySelectorAll"));return n})),r=t.length,o=0;o<r;o++){var l=w(t[o],e);if(null==l?void 0:l.length)return l}return document.querySelectorAll(u)}function x(n,e){for(var t=i(n,(function(n){if(n.pop().length)throw new SyntaxError(d("shadowRootQuerySelector","querySelector"));return n})),r=t.length,o=0;o<r;o++){var u=g(t[o],e);if(u)return u}return null}function E(t,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return e(this,(function(e){switch(e.label){case 0:n=i(t,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("asyncQuerySelector","asyncShadowRootQuerySelector"));return n})),l=n.length,c=0,e.label=1;case 1:return c<l?[4,p(n[c],r,o,u)]:[3,4];case 2:if(a=e.sent())return[2,a];e.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}function q(t,r,o,l){return n(this,void 0,void 0,(function(){var n,c,a,s;return e(this,(function(e){switch(e.label){case 0:n=i(t,(function(n){if(!n[n.length-1].length)throw new SyntaxError(h("asyncQuerySelectorAll"));return n})),c=n.length,a=0,e.label=1;case 1:return a<c?[4,b(n[a],r,o,l)]:[3,4];case 2:if(null==(s=e.sent())?void 0:s.length)return[2,s];e.label=3;case 3:return a++,[3,1];case 4:return[2,document.querySelectorAll(u)]}}))}))}function A(t,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return e(this,(function(e){switch(e.label){case 0:n=i(t,(function(n){if(n.pop().length)throw new SyntaxError(d("asyncShadowRootQuerySelector","asyncQuerySelector"));return n})),l=n.length,c=0,e.label=1;case 1:return c<l?[4,S(n[c],r,o,u)]:[3,4];case 2:if(a=e.sent())return[2,a];e.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}function Q(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?m(t,document):m(r,t)}function D(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?R(t,document):R(r,t)}function k(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n[0],r=n[1];return"string"==typeof t?x(t,document):x(r,t)}function P(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,i;return e(this,(function(e){switch(e.label){case 0:return a(t)?(n=t[0],r=t[1],o=t[2],[4,E(r,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||c)]):[3,2];case 1:case 3:return[2,e.sent()];case 2:return u=t[0],i=t[1],[4,E(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||c)]}}))}))}function T(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,i;return e(this,(function(e){switch(e.label){case 0:return a(t)?(n=t[0],r=t[1],o=t[2],[4,q(r,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||c)]):[3,2];case 1:return[2,e.sent()];case 2:return u=t[0],i=t[1],[2,q(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||c)]}}))}))}function I(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,i;return e(this,(function(e){switch(e.label){case 0:return a(t)?(n=t[0],r=t[1],o=t[2],[4,A(r,n,(null==o?void 0:o.retries)||l,(null==o?void 0:o.delay)||c)]):[3,2];case 1:return[2,e.sent()];case 2:return u=t[0],i=t[1],[2,A(u,document,(null==i?void 0:i.retries)||l,(null==i?void 0:i.delay)||c)]}}))}))}export{P as asyncQuerySelector,T as asyncQuerySelectorAll,I as asyncShadowRootQuerySelector,Q as querySelector,D as querySelectorAll,k as shadowRootQuerySelector};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ShadowDomSelector={})}(this,(function(e){"use strict";function n(e,n,t,r){return new(t||(t=Promise))((function(o,u){function l(e){try{a(r.next(e))}catch(e){u(e)}}function c(e){try{a(r.throw(e))}catch(e){u(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(l,c)}a((r=r.apply(e,n||[])).next())}))}function t(e,n){var t,r,o,u,l={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(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(l=0)),l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=n.call(e,l)}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,a])}}}function r(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))}"function"==typeof SuppressedError&&SuppressedError;var o="$",u=":host",l="invalid selector",c=10,a=10,i=function(e){var n,t=e[0],r=e[1];return(n=t)&&(n instanceof Document||n instanceof Element)&&"string"==typeof r};function s(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 f(e,n,t,r,o){return void 0===o&&(o=!1),new Promise((function(u){var c=0,a=function(){var i=o?e.querySelectorAll(n):e.querySelector(n);o&&i.length||!o&&null!==i?u(i):++c<t?setTimeout(a,r):u(o?document.querySelectorAll(l):null)};a()}))}function h(e,n,t){return new Promise((function(r){var o=0,u=function(){var l=e.shadowRoot;l?r(l):++o<n?setTimeout(u,t):r(null)};u()}))}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 v(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.")}function y(){return"You can not select a shadowRoot (".concat(o,") of the document.")}function w(e,n){for(var t,r,o=null,l=e.length,c=0;c<l;c++){if(0===c)if(e[c].length)o=n.querySelector(e[c]);else{if(n instanceof Document)throw new SyntaxError(y());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 p(e,n){var t,o=r([],e,!0),l=o.pop();return o.length?(null===(t=w(o,n).shadowRoot)||void 0===t?void 0:t.querySelectorAll("".concat(u," ").concat(l)))||null:n.querySelectorAll(l)}function g(e,n){var t=w(e,n);return(null==t?void 0:t.shadowRoot)||null}function b(e,r,o,l){return n(this,void 0,void 0,(function(){var n,c,a,i,s,d;return t(this,(function(t){switch(t.label){case 0:n=null,c=e.length,a=0,t.label=1;case 1:if(!(a<c))return[3,15];if(0!==a)return[3,8];if(e[a].length)return[3,5];if(r instanceof Document)throw new SyntaxError(y());return r.shadowRoot?[4,f(r.shadowRoot,e[++a],o,l)]:[3,3];case 2:return i=t.sent(),[3,4];case 3:i=null,t.label=4;case 4:return n=i,[3,7];case 5:return[4,f(r,e[a],o,l)];case 6:n=t.sent(),t.label=7;case 7:return[3,13];case 8:return[4,h(n,o,l)];case 9:return(s=t.sent())?[4,f(s,"".concat(u," ").concat(e[a]),o,l)]:[3,11];case 10:return d=t.sent(),[3,12];case 11:d=null,t.label=12;case 12:n=d,t.label=13;case 13:if(null===n)return[2,null];t.label=14;case 14:return a++,[3,1];case 15:return[2,n]}}))}))}function S(e,o,l,c){return n(this,void 0,void 0,(function(){var n,a,i,s,d,v;return t(this,(function(t){switch(t.label){case 0:return n=r([],e,!0),a=n.pop(),n.length?[3,2]:[4,f(o,a,l,c,!0)];case 1:return[2,t.sent()];case 2:return[4,b(n,o,l,c)];case 3:return(i=t.sent())?[4,h(i,l,c)]:[3,5];case 4:return d=t.sent(),[3,6];case 5:d=null,t.label=6;case 6:return(s=d)?[4,f(s,"".concat(u," ").concat(a),l,c,!0)]:[3,8];case 7:return v=t.sent(),[3,9];case 8:v=null,t.label=9;case 9:return[2,v]}}))}))}function m(e,r,o,u){return n(this,void 0,void 0,(function(){var n,l;return t(this,(function(t){switch(t.label){case 0:return[4,b(e,r,o,u)];case 1:return(n=t.sent())?[4,h(n,o,u)]:[3,3];case 2:return l=t.sent(),[3,4];case 3:l=null,t.label=4;case 4:return[2,l]}}))}))}function R(e,n){for(var t=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("querySelector","shadowRootQuerySelector"));return e})),r=t.length,o=0;o<r;o++){var u=w(t[o],n);if(u)return u}return null}function x(e,n){for(var t=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("querySelectorAll"));return e})),r=t.length,o=0;o<r;o++){var u=p(t[o],n);if(null==u?void 0:u.length)return u}return document.querySelectorAll(l)}function q(e,n){for(var t=s(e,(function(e){if(e.pop().length)throw new SyntaxError(v("shadowRootQuerySelector","querySelector"));return e})),r=t.length,o=0;o<r;o++){var u=g(t[o],n);if(u)return u}return null}function A(e,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return t(this,(function(t){switch(t.label){case 0:n=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("asyncQuerySelector","asyncShadowRootQuerySelector"));return e})),l=n.length,c=0,t.label=1;case 1:return c<l?[4,b(n[c],r,o,u)]:[3,4];case 2:if(a=t.sent())return[2,a];t.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}function E(e,r,o,u){return n(this,void 0,void 0,(function(){var n,c,a,i;return t(this,(function(t){switch(t.label){case 0:n=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("asyncQuerySelectorAll"));return e})),c=n.length,a=0,t.label=1;case 1:return a<c?[4,S(n[a],r,o,u)]:[3,4];case 2:if(null==(i=t.sent())?void 0:i.length)return[2,i];t.label=3;case 3:return a++,[3,1];case 4:return[2,document.querySelectorAll(l)]}}))}))}function Q(e,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return t(this,(function(t){switch(t.label){case 0:n=s(e,(function(e){if(e.pop().length)throw new SyntaxError(v("asyncShadowRootQuerySelector","asyncQuerySelector"));return e})),l=n.length,c=0,t.label=1;case 1:return c<l?[4,m(n[c],r,o,u)]:[3,4];case 2:if(a=t.sent())return[2,a];t.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}e.asyncQuerySelector=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return i(e)?(n=e[0],r=e[1],o=e[2],[4,A(r,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||a)]):[3,2];case 1:case 3:return[2,t.sent()];case 2:return u=e[0],l=e[1],[4,A(u,document,(null==l?void 0:l.retries)||c,(null==l?void 0:l.delay)||a)]}}))}))},e.asyncQuerySelectorAll=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return i(e)?(n=e[0],r=e[1],o=e[2],[4,E(r,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,t.sent()];case 2:return u=e[0],l=e[1],[2,E(u,document,(null==l?void 0:l.retries)||c,(null==l?void 0:l.delay)||a)]}}))}))},e.asyncShadowRootQuerySelector=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return i(e)?(n=e[0],r=e[1],o=e[2],[4,Q(r,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,t.sent()];case 2:return u=e[0],l=e[1],[2,Q(u,document,(null==l?void 0:l.retries)||c,(null==l?void 0:l.delay)||a)]}}))}))},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?R(t,document):R(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?x(t,document):x(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?q(t,document):q(r,t)}}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ShadowDomSelector={})}(this,(function(e){"use strict";function n(e,n,t,r){return new(t||(t=Promise))((function(o,u){function l(e){try{a(r.next(e))}catch(e){u(e)}}function c(e){try{a(r.throw(e))}catch(e){u(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(l,c)}a((r=r.apply(e,n||[])).next())}))}function t(e,n){var t,r,o,u,l={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(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(l=0)),l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=n.call(e,l)}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,a])}}}function r(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))}"function"==typeof SuppressedError&&SuppressedError;var o="$",u=":host",l="invalid selector",c=10,a=10,i=function(e){var n,t=e[0],r=e[1];return(n=t)&&(n instanceof Document||n instanceof Element)&&"string"==typeof r};function s(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 f(e,n,t,r,o){return void 0===o&&(o=!1),new Promise((function(u){var c=0,a=function(){var i=o?e.querySelectorAll(n):e.querySelector(n);o&&i.length||!o&&null!==i?u(i):++c<t?setTimeout(a,r):u(o?document.querySelectorAll(l):null)};a()}))}function h(e,n,t){return new Promise((function(r){var o=0,u=function(){var l=e.shadowRoot;l?r(l):++o<n?setTimeout(u,t):r(null)};u()}))}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 v(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.")}function y(){return"You can not select a shadowRoot (".concat(o,") of the document.")}function w(e,n){for(var t,r,o=null,l=e.length,c=0;c<l;c++){if(0===c)if(e[c].length)o=n.querySelector(e[c]);else{if(n instanceof Document)throw new SyntaxError(y());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 p(e,n){var t,o=r([],e,!0),l=o.pop();return o.length?(null===(t=w(o,n).shadowRoot)||void 0===t?void 0:t.querySelectorAll("".concat(u," ").concat(l)))||null:n.querySelectorAll(l)}function g(e,n){if(1===e.length&&!e[0].length){if(n instanceof Document)throw new SyntaxError(y());return n.shadowRoot}var t=w(e,n);return(null==t?void 0:t.shadowRoot)||null}function S(e,r,o,l){return n(this,void 0,void 0,(function(){var n,c,a,i,s,d;return t(this,(function(t){switch(t.label){case 0:n=null,c=e.length,a=0,t.label=1;case 1:if(!(a<c))return[3,15];if(0!==a)return[3,8];if(e[a].length)return[3,5];if(r instanceof Document)throw new SyntaxError(y());return r.shadowRoot?[4,f(r.shadowRoot,e[++a],o,l)]:[3,3];case 2:return i=t.sent(),[3,4];case 3:i=null,t.label=4;case 4:return n=i,[3,7];case 5:return[4,f(r,e[a],o,l)];case 6:n=t.sent(),t.label=7;case 7:return[3,13];case 8:return[4,h(n,o,l)];case 9:return(s=t.sent())?[4,f(s,"".concat(u," ").concat(e[a]),o,l)]:[3,11];case 10:return d=t.sent(),[3,12];case 11:d=null,t.label=12;case 12:n=d,t.label=13;case 13:if(null===n)return[2,null];t.label=14;case 14:return a++,[3,1];case 15:return[2,n]}}))}))}function b(e,o,l,c){return n(this,void 0,void 0,(function(){var n,a,i,s,d,v;return t(this,(function(t){switch(t.label){case 0:return n=r([],e,!0),a=n.pop(),n.length?[3,2]:[4,f(o,a,l,c,!0)];case 1:return[2,t.sent()];case 2:return[4,S(n,o,l,c)];case 3:return(i=t.sent())?[4,h(i,l,c)]:[3,5];case 4:return d=t.sent(),[3,6];case 5:d=null,t.label=6;case 6:return(s=d)?[4,f(s,"".concat(u," ").concat(a),l,c,!0)]:[3,8];case 7:return v=t.sent(),[3,9];case 8:v=null,t.label=9;case 9:return[2,v]}}))}))}function m(e,r,o,u){return n(this,void 0,void 0,(function(){var n,l;return t(this,(function(t){switch(t.label){case 0:if(1===e.length&&!e[0].length){if(r instanceof Document)throw new SyntaxError(y());return[2,h(r,o,u)]}return[4,S(e,r,o,u)];case 1:return(n=t.sent())?[4,h(n,o,u)]:[3,3];case 2:return l=t.sent(),[3,4];case 3:l=null,t.label=4;case 4:return[2,l]}}))}))}function R(e,n){for(var t=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("querySelector","shadowRootQuerySelector"));return e})),r=t.length,o=0;o<r;o++){var u=w(t[o],n);if(u)return u}return null}function x(e,n){for(var t=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("querySelectorAll"));return e})),r=t.length,o=0;o<r;o++){var u=p(t[o],n);if(null==u?void 0:u.length)return u}return document.querySelectorAll(l)}function q(e,n){for(var t=s(e,(function(e){if(e.pop().length)throw new SyntaxError(v("shadowRootQuerySelector","querySelector"));return e})),r=t.length,o=0;o<r;o++){var u=g(t[o],n);if(u)return u}return null}function E(e,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return t(this,(function(t){switch(t.label){case 0:n=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("asyncQuerySelector","asyncShadowRootQuerySelector"));return e})),l=n.length,c=0,t.label=1;case 1:return c<l?[4,S(n[c],r,o,u)]:[3,4];case 2:if(a=t.sent())return[2,a];t.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}function A(e,r,o,u){return n(this,void 0,void 0,(function(){var n,c,a,i;return t(this,(function(t){switch(t.label){case 0:n=s(e,(function(e){if(!e[e.length-1].length)throw new SyntaxError(d("asyncQuerySelectorAll"));return e})),c=n.length,a=0,t.label=1;case 1:return a<c?[4,b(n[a],r,o,u)]:[3,4];case 2:if(null==(i=t.sent())?void 0:i.length)return[2,i];t.label=3;case 3:return a++,[3,1];case 4:return[2,document.querySelectorAll(l)]}}))}))}function Q(e,r,o,u){return n(this,void 0,void 0,(function(){var n,l,c,a;return t(this,(function(t){switch(t.label){case 0:n=s(e,(function(e){if(e.pop().length)throw new SyntaxError(v("asyncShadowRootQuerySelector","asyncQuerySelector"));return e})),l=n.length,c=0,t.label=1;case 1:return c<l?[4,m(n[c],r,o,u)]:[3,4];case 2:if(a=t.sent())return[2,a];t.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))}e.asyncQuerySelector=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return i(e)?(n=e[0],r=e[1],o=e[2],[4,E(r,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||a)]):[3,2];case 1:case 3:return[2,t.sent()];case 2:return u=e[0],l=e[1],[4,E(u,document,(null==l?void 0:l.retries)||c,(null==l?void 0:l.delay)||a)]}}))}))},e.asyncQuerySelectorAll=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return i(e)?(n=e[0],r=e[1],o=e[2],[4,A(r,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,t.sent()];case 2:return u=e[0],l=e[1],[2,A(u,document,(null==l?void 0:l.retries)||c,(null==l?void 0:l.delay)||a)]}}))}))},e.asyncShadowRootQuerySelector=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return i(e)?(n=e[0],r=e[1],o=e[2],[4,Q(r,n,(null==o?void 0:o.retries)||c,(null==o?void 0:o.delay)||a)]):[3,2];case 1:return[2,t.sent()];case 2:return u=e[0],l=e[1],[2,Q(u,document,(null==l?void 0:l.retries)||c,(null==l?void 0:l.delay)||a)]}}))}))},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?R(t,document):R(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?x(t,document):x(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?q(t,document):q(r,t)}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadow-dom-selector",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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",