Socket
Socket
Sign inDemoInstall

uhooks-dom

Package Overview
Dependencies
4
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

18

cjs/index.js

@@ -11,10 +11,20 @@ 'use strict';

const find = ({firstChild}) => {
if (
firstChild &&
firstChild.nodeType !== 1 &&
!(firstChild = firstChild.nextElementSibling)
)
throw 'unobservable';
return firstChild;
};
const get = node => {
const {firstChild, nodeType} = node;
const {nodeType} = node;
if (nodeType)
return nodeType < 11 ? node : firstChild;
return nodeType === 1 ? node : find(node);
else {
// give a chance to facades to return a reasonable value
const value = node.valueOf();
return value !== node ? get(value) : firstChild;
return value !== node ? get(value) : find(value);
}

@@ -32,3 +42,3 @@ };

if (!observer)
observer = observe(document, 'childNodes', CustomEvent);
observer = observe(document, 'children', CustomEvent);
if (!observer.has(disconnectable))

@@ -35,0 +45,0 @@ observer.connect(disconnectable, {

@@ -1,3 +0,3 @@

self.uhooksDOM=function(e){"use strict";var t=CustomEvent;const n="connected",s="disconnected",o="EventListener",c=(e,t,c)=>{e[t+o](n,c),e[t+o](s,c)},r=(e=document,t="childNodes",o=CustomEvent,r=MutationObserver)=>{const a=new WeakMap,l=new WeakMap,i=new WeakMap,h=e=>a.has(e),d=e=>{h(e)&&(c(e,"remove",a.get(e)),a.delete(e))},f=(e,t,n,s)=>{for(let{length:o}=e,c=0;c<o;c++)p(e[c],t,n,s)},p=(e,n,s,c)=>{h(e)&&!s.has(e)&&(c.delete(e),s.set(e,0),e.dispatchEvent(new o(n))),f(e[t]||[],n,s,c)},v=new r((e=>{for(let{length:t}=e,o=0;o<t;o++){const{removedNodes:t,addedNodes:c}=e[o];f(t,s,i,l),f(c,n,l,i)}}));return v.observe(e,{subtree:!0,childList:!0}),{has:h,connect:(e,t={})=>{d(e),t.handleEvent||(t.handleEvent=u),c(e,"add",t),a.set(e,t)},disconnect:d,kill(){v.disconnect()}}};function u(e){e.type in this&&this[e.type](e)}var a=Promise;let l=null,i=null,h=null,d=new Set;const f=new WeakMap,p=new a((e=>e())),v=e=>{const{$:t,r:n,h:s}=e;$(n)&&(g.get(s).delete(e),n()),$(e.r=t())&&g.get(s).add(e)},w=()=>{const e=d;d=new Set,e.forEach(C)},g=new WeakMap,E=[],y=[];function _(e,t){return e!==this[t]}const m=e=>{const t=g.get(e);t&&p.then((()=>{t.forEach((e=>{e.r(),e.r=null})),t.clear()}))},k=()=>{const e=f.get(h);return e.a=l,e.c=i,e},M=e=>g.has(e),$=e=>"function"==typeof e,b=e=>{return f.set(t,{a:l,c:i,h:t,i:0,s:[]}),t;function t(){const n=l,s=i,o=h;l=arguments,i=this,h=t;try{return e.apply(i,l)}finally{l=n,i=s,h=o,E.length&&p.then(E.forEach.bind(E.splice(0),v)),y.length&&y.splice(0).forEach(v)}}},C=e=>{e.i=0,e.h.apply(e.c,e.a)};function S(e){const{_:t,value:n}=this;n!==e&&(this._=new Set,this.value=e,t.forEach(C))}const W=(e,t)=>{const n=k(),{i:s,s:o}=n;return s===o.length?o.push({$:e(),_:t}):t&&!t.some(_,o[s]._)||(o[s]={$:e(),_:t}),o[n.i++].$},N=e=>(t,n)=>{const s=k(),{i:o,s:c,h:r}=s,u=o===c.length;u&&(g.has(r)||g.set(r,new Set),c.push({$:t,_:n,r:null,h:r}));const a=c[s.i++];(u||!n||n.some(_,a._))&&e.push(a)},O=N(E),L=N(y),x=(e,t)=>$(t)?t(e):t,P=(e,t,n)=>{const s=k(),{i:o,s:c}=s;o===c.length&&c.push({$:$(n)?n(t):x(void 0,t),set:t=>{c[o].$=e(c[o].$,t),(e=>{d.has(e)||(d.add(e),p.then(w))})(s)}});const{$:r,set:u}=c[s.i++];return[r,u]};
self.uhooksDOM=function(e){"use strict";var t=CustomEvent;const n="connected",s="disconnected",o="EventListener",c=(e,t,c)=>{e[t+o](n,c),e[t+o](s,c)},r=(e=document,t="children",o=CustomEvent,r=MutationObserver)=>{const l=new WeakMap,a=new WeakMap,i=new WeakMap,h=e=>l.has(e),d=e=>{h(e)&&(c(e,"remove",l.get(e)),l.delete(e))},f=(e,t,n,s)=>{for(let{length:o}=e,c=0;c<o;c++)p(e[c],t,n,s)},p=(e,n,s,c)=>{h(e)&&!s.has(e)&&(c.delete(e),s.set(e,0),e.dispatchEvent(new o(n))),f(e[t]||[],n,s,c)},v=new r((e=>{for(let{length:t}=e,o=0;o<t;o++){const{removedNodes:t,addedNodes:c}=e[o];f(t,s,i,a),f(c,n,a,i)}}));return v.observe(e,{subtree:!0,childList:!0}),{has:h,connect:(e,t={})=>{d(e),t.handleEvent||(t.handleEvent=u),c(e,"add",t),l.set(e,t)},disconnect:d,kill(){v.disconnect()}}};function u(e){e.type in this&&this[e.type](e)}var l=Promise;let a=null,i=null,h=null,d=new Set;const f=new WeakMap,p=new l((e=>e())),v=e=>{const{$:t,r:n,h:s}=e;M(n)&&(g.get(s).delete(e),n()),M(e.r=t())&&g.get(s).add(e)},w=()=>{const e=d;d=new Set,e.forEach(S)},g=new WeakMap,E=[],y=[];function b(e,t){return e!==this[t]}const m=e=>{const t=g.get(e);t&&p.then((()=>{t.forEach((e=>{e.r(),e.r=null})),t.clear()}))},_=()=>{const e=f.get(h);return e.a=a,e.c=i,e},k=e=>g.has(e),M=e=>"function"==typeof e,$=e=>{return f.set(t,{a:a,c:i,h:t,i:0,s:[]}),t;function t(){const n=a,s=i,o=h;a=arguments,i=this,h=t;try{return e.apply(i,a)}finally{a=n,i=s,h=o,E.length&&p.then(E.forEach.bind(E.splice(0),v)),y.length&&y.splice(0).forEach(v)}}},S=e=>{e.i=0,e.h.apply(e.c,e.a)};function C(e){const{_:t,value:n}=this;n!==e&&(this._=new Set,this.value=e,t.forEach(S))}const W=(e,t)=>{const n=_(),{i:s,s:o}=n;return s===o.length?o.push({$:e(),_:t}):t&&!t.some(b,o[s]._)||(o[s]={$:e(),_:t}),o[n.i++].$},O=e=>(t,n)=>{const s=_(),{i:o,s:c,h:r}=s,u=o===c.length;u&&(g.has(r)||g.set(r,new Set),c.push({$:t,_:n,r:null,h:r}));const l=c[s.i++];(u||!n||n.some(b,l._))&&e.push(l)},x=O(E),L=O(y),N=(e,t)=>M(t)?t(e):t,P=(e,t,n)=>{const s=_(),{i:o,s:c}=s;o===c.length&&c.push({$:M(n)?n(t):N(void 0,t),set:t=>{c[o].$=e(c[o].$,t),(e=>{d.has(e)||(d.add(e),p.then(w))})(s)}});const{$:r,set:u}=c[s.i++];return[r,u]};
/*! (c) Andrea Giammarchi - ISC */
let R=null;const j=e=>{const{firstChild:t,nodeType:n}=e;if(n)return n<11?e:t;{const n=e.valueOf();return n!==e?j(n):t}};return e.createContext=e=>({_:new Set,provide:S,value:e}),e.hooked=e=>{const n=b(e);return function(){const e=n.apply(this,arguments);if(M(n)){const s=j(e);if(!s)throw"unobservable";R||(R=r(document,"childNodes",t)),R.has(s)||R.connect(s,{disconnected(){m(n)}})}return e}},e.useCallback=(e,t)=>W((()=>e),t),e.useContext=({_:e,value:t})=>(e.add(k()),t),e.useEffect=O,e.useLayoutEffect=L,e.useMemo=W,e.useReducer=P,e.useRef=e=>{const t=k(),{i:n,s:s}=t;return n===s.length&&s.push({current:e}),s[t.i++]},e.useState=e=>P(x,e),Object.defineProperty(e,"__esModule",{value:!0}),e}({});
let R=null;const T=({firstChild:e})=>{if(e&&1!==e.nodeType&&!(e=e.nextElementSibling))throw"unobservable";return e},j=e=>{const{nodeType:t}=e;if(t)return 1===t?e:T(e);{const t=e.valueOf();return t!==e?j(t):T(t)}};return e.createContext=e=>({_:new Set,provide:C,value:e}),e.hooked=e=>{const n=$(e);return function(){const e=n.apply(this,arguments);if(k(n)){const s=j(e);if(!s)throw"unobservable";R||(R=r(document,"children",t)),R.has(s)||R.connect(s,{disconnected(){m(n)}})}return e}},e.useCallback=(e,t)=>W((()=>e),t),e.useContext=({_:e,value:t})=>(e.add(_()),t),e.useEffect=x,e.useLayoutEffect=L,e.useMemo=W,e.useReducer=P,e.useRef=e=>{const t=_(),{i:n,s:s}=t;return n===s.length&&s.push({current:e}),s[t.i++]},e.useState=e=>P(N,e),Object.defineProperty(e,"__esModule",{value:!0}),e}({});

@@ -10,10 +10,20 @@ /*! (c) Andrea Giammarchi - ISC */

const find = ({firstChild}) => {
if (
firstChild &&
firstChild.nodeType !== 1 &&
!(firstChild = firstChild.nextElementSibling)
)
throw 'unobservable';
return firstChild;
};
const get = node => {
const {firstChild, nodeType} = node;
const {nodeType} = node;
if (nodeType)
return nodeType < 11 ? node : firstChild;
return nodeType === 1 ? node : find(node);
else {
// give a chance to facades to return a reasonable value
const value = node.valueOf();
return value !== node ? get(value) : firstChild;
return value !== node ? get(value) : find(value);
}

@@ -31,3 +41,3 @@ };

if (!observer)
observer = observe(document, 'childNodes', CustomEvent);
observer = observe(document, 'children', CustomEvent);
if (!observer.has(disconnectable))

@@ -34,0 +44,0 @@ observer.connect(disconnectable, {

@@ -42,3 +42,3 @@ self.uhooksDOM = (function (exports) {

* @param {Node} root a DOM node to observe for mutations.
* @param {string} parse the kind of nodes to parse: childNodes, by default, or children.
* @param {string} parse the kind of nodes to parse: children, by default, or childNodes.
* @param {Event} CE an Event/CustomEvent constructor (polyfilled in SSR).

@@ -52,3 +52,3 @@ * @param {MutationObserver} MO a MutationObserver constructor (polyfilled in SSR).

var root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
var parse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'childNodes';
var parse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
var CE = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CustomEvent;

@@ -347,9 +347,14 @@ var MO = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MutationObserver;

var find = function find(_ref) {
var firstChild = _ref.firstChild;
if (firstChild && firstChild.nodeType !== 1 && !(firstChild = firstChild.nextElementSibling)) throw 'unobservable';
return firstChild;
};
var get = function get(node) {
var firstChild = node.firstChild,
nodeType = node.nodeType;
if (nodeType) return nodeType < 11 ? node : firstChild;else {
var nodeType = node.nodeType;
if (nodeType) return nodeType === 1 ? node : find(node);else {
// give a chance to facades to return a reasonable value
var value = node.valueOf();
return value !== node ? get(value) : firstChild;
return value !== node ? get(value) : find(value);
}

@@ -366,3 +371,3 @@ };

if (!disconnectable) throw 'unobservable';
if (!observer) observer = observe(document, 'childNodes', CustomEvent$1);
if (!observer) observer = observe(document, 'children', CustomEvent$1);
if (!observer.has(disconnectable)) observer.connect(disconnectable, {

@@ -369,0 +374,0 @@ disconnected: function disconnected() {

self.uhooksDOM=function(n){"use strict";
/*! (c) Andrea Giammarchi - ISC */var e={};e.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(n){return e[n]=new e("").constructor[n],e;function e(n,e){e||(e={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(n,!!e.bubbles,!!e.cancelable,e.detail),t}}("prototype");var t=e.CustomEvent,u="connected",r="disconnected",o="EventListener",i=function(n,e,t){n[e+o](u,t),n[e+o](r,t)},c=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"childNodes",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:CustomEvent,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:MutationObserver,c=new WeakMap,s=new WeakMap,f=new WeakMap,h=function(n){return c.has(n)},l=function(n){h(n)&&(i(n,"remove",c.get(n)),c.delete(n))},v=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(n),e.handleEvent||(e.handleEvent=a),i(n,"add",e),c.set(n,e)},d=function(n,e,t,u){for(var r=n.length,o=0;o<r;o++)p(n[o],e,t,u)},p=function(n,u,r,o){h(n)&&!r.has(n)&&(o.delete(n),r.set(n,0),n.dispatchEvent(new t(u))),d(n[e]||[],u,r,o)},E=new o((function(n){for(var e=n.length,t=0;t<e;t++){var o=n[t],i=o.removedNodes,c=o.addedNodes;d(i,r,f,s),d(c,u,s,f)}}));return E.observe(n,{subtree:!0,childList:!0}),{has:h,connect:v,disconnect:l,kill:function(){E.disconnect()}}};function a(n){n.type in this&&this[n.type](n)}var s="function"==typeof Promise?Promise:function(n){var e,t=[],u=0;return n((function(n){e=n,u=1,t.splice(0).forEach(r)})),{then:r};function r(n){return u?setTimeout(n,0,e):t.push(n),this}},f=null,h=null,l=null,v=new Set,d=new WeakMap,p=new s((function(n){return n()})),E=function(n){var e=n.$,t=n.r,u=n.h;M(t)&&(m.get(u).delete(n),t()),M(n.r=e())&&m.get(u).add(n)},g=function(){var n=v;v=new Set,n.forEach($)},m=new WeakMap,w=[],y=[];function b(n,e){return n!==this[e]}var C=function(n){var e=m.get(n);e&&p.then((function(){e.forEach((function(n){n.r(),n.r=null})),e.clear()}))},_=function(){var n=d.get(l);return n.a=f,n.c=h,n},k=function(n){return m.has(n)},M=function(n){return"function"==typeof n},$=function(n){n.i=0,n.h.apply(n.c,n.a)};function S(n){var e=this._;this.value!==n&&(this._=new Set,this.value=n,e.forEach($))}var W=function(n,e){var t=_(),u=t.i,r=t.s;return u===r.length?r.push({$:n(),_:e}):e&&!e.some(b,r[u]._)||(r[u]={$:n(),_:e}),r[t.i++].$},N=function(n){return function(e,t){var u=_(),r=u.i,o=u.s,i=u.h,c=r===o.length;c&&(m.has(i)||m.set(i,new Set),o.push({$:e,_:t,r:null,h:i}));var a=o[u.i++];(c||!t||t.some(b,a._))&&n.push(a)}},O=N(w),L=N(y),P=function(n,e){return M(e)?e(n):e},x=function(n,e,t){var u=_(),r=u.i,o=u.s;r===o.length&&o.push({$:M(t)?t(e):P(void 0,e),set:function(e){o[r].$=n(o[r].$,e),function(n){v.has(n)||(v.add(n),p.then(g))}(u)}});var i=o[u.i++];return[i.$,i.set]},R=null,T=function n(e){var t=e.firstChild,u=e.nodeType;if(u)return u<11?e:t;var r=e.valueOf();return r!==e?n(r):t};return n.createContext=function(n){return{_:new Set,provide:S,value:n}},n.hooked=function(n){var e=function(n){return d.set(e,{a:f,c:h,h:e,i:0,s:[]}),e;function e(){var t=f,u=h,r=l;f=arguments,h=this,l=e;try{return n.apply(h,f)}finally{f=t,h=u,l=r,w.length&&p.then(w.forEach.bind(w.splice(0),E)),y.length&&y.splice(0).forEach(E)}}}(n);return function(){var n=e.apply(this,arguments);if(k(e)){var u=T(n);if(!u)throw"unobservable";R||(R=c(document,"childNodes",t)),R.has(u)||R.connect(u,{disconnected:function(){C(e)}})}return n}},n.useCallback=function(n,e){return W((function(){return n}),e)},n.useContext=function(n){var e=n._,t=n.value;return e.add(_()),t},n.useEffect=O,n.useLayoutEffect=L,n.useMemo=W,n.useReducer=x,n.useRef=function(n){var e=_(),t=e.i,u=e.s;return t===u.length&&u.push({current:n}),u[e.i++]},n.useState=function(n){return x(P,n)},Object.defineProperty(n,"__esModule",{value:!0}),n}({});
/*! (c) Andrea Giammarchi - ISC */var e={};e.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(n){return e[n]=new e("").constructor[n],e;function e(n,e){e||(e={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(n,!!e.bubbles,!!e.cancelable,e.detail),t}}("prototype");var t=e.CustomEvent,r="connected",u="disconnected",o="EventListener",i=function(n,e,t){n[e+o](r,t),n[e+o](u,t)},c=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"children",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:CustomEvent,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:MutationObserver,c=new WeakMap,s=new WeakMap,f=new WeakMap,l=function(n){return c.has(n)},h=function(n){l(n)&&(i(n,"remove",c.get(n)),c.delete(n))},v=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h(n),e.handleEvent||(e.handleEvent=a),i(n,"add",e),c.set(n,e)},d=function(n,e,t,r){for(var u=n.length,o=0;o<u;o++)p(n[o],e,t,r)},p=function(n,r,u,o){l(n)&&!u.has(n)&&(o.delete(n),u.set(n,0),n.dispatchEvent(new t(r))),d(n[e]||[],r,u,o)},E=new o((function(n){for(var e=n.length,t=0;t<e;t++){var o=n[t],i=o.removedNodes,c=o.addedNodes;d(i,u,f,s),d(c,r,s,f)}}));return E.observe(n,{subtree:!0,childList:!0}),{has:l,connect:v,disconnect:h,kill:function(){E.disconnect()}}};function a(n){n.type in this&&this[n.type](n)}var s="function"==typeof Promise?Promise:function(n){var e,t=[],r=0;return n((function(n){e=n,r=1,t.splice(0).forEach(u)})),{then:u};function u(n){return r?setTimeout(n,0,e):t.push(n),this}},f=null,l=null,h=null,v=new Set,d=new WeakMap,p=new s((function(n){return n()})),E=function(n){var e=n.$,t=n.r,r=n.h;M(t)&&(m.get(r).delete(n),t()),M(n.r=e())&&m.get(r).add(n)},g=function(){var n=v;v=new Set,n.forEach($)},m=new WeakMap,w=[],b=[];function y(n,e){return n!==this[e]}var C=function(n){var e=m.get(n);e&&p.then((function(){e.forEach((function(n){n.r(),n.r=null})),e.clear()}))},_=function(){var n=d.get(h);return n.a=f,n.c=l,n},k=function(n){return m.has(n)},M=function(n){return"function"==typeof n},$=function(n){n.i=0,n.h.apply(n.c,n.a)};function S(n){var e=this._;this.value!==n&&(this._=new Set,this.value=n,e.forEach($))}var W=function(n,e){var t=_(),r=t.i,u=t.s;return r===u.length?u.push({$:n(),_:e}):e&&!e.some(y,u[r]._)||(u[r]={$:n(),_:e}),u[t.i++].$},O=function(n){return function(e,t){var r=_(),u=r.i,o=r.s,i=r.h,c=u===o.length;c&&(m.has(i)||m.set(i,new Set),o.push({$:e,_:t,r:null,h:i}));var a=o[r.i++];(c||!t||t.some(y,a._))&&n.push(a)}},x=O(w),L=O(b),P=function(n,e){return M(e)?e(n):e},T=function(n,e,t){var r=_(),u=r.i,o=r.s;u===o.length&&o.push({$:M(t)?t(e):P(void 0,e),set:function(e){o[u].$=n(o[u].$,e),function(n){v.has(n)||(v.add(n),p.then(g))}(r)}});var i=o[r.i++];return[i.$,i.set]},N=null,R=function(n){var e=n.firstChild;if(e&&1!==e.nodeType&&!(e=e.nextElementSibling))throw"unobservable";return e},j=function n(e){var t=e.nodeType;if(t)return 1===t?e:R(e);var r=e.valueOf();return r!==e?n(r):R(r)};return n.createContext=function(n){return{_:new Set,provide:S,value:n}},n.hooked=function(n){var e=function(n){return d.set(e,{a:f,c:l,h:e,i:0,s:[]}),e;function e(){var t=f,r=l,u=h;f=arguments,l=this,h=e;try{return n.apply(l,f)}finally{f=t,l=r,h=u,w.length&&p.then(w.forEach.bind(w.splice(0),E)),b.length&&b.splice(0).forEach(E)}}}(n);return function(){var n=e.apply(this,arguments);if(k(e)){var r=j(n);if(!r)throw"unobservable";N||(N=c(document,"children",t)),N.has(r)||N.connect(r,{disconnected:function(){C(e)}})}return n}},n.useCallback=function(n,e){return W((function(){return n}),e)},n.useContext=function(n){var e=n._,t=n.value;return e.add(_()),t},n.useEffect=x,n.useLayoutEffect=L,n.useMemo=W,n.useReducer=T,n.useRef=function(n){var e=_(),t=e.i,r=e.s;return t===r.length&&r.push({current:n}),r[e.i++]},n.useState=function(n){return T(P,n)},Object.defineProperty(n,"__esModule",{value:!0}),n}({});
{
"name": "uhooks-dom",
"version": "0.0.2",
"version": "0.0.3",
"description": "A dom-augmentor alternative based on uhooks",

@@ -44,5 +44,5 @@ "main": "./cjs/index.js",

"@ungap/custom-event": "^0.3.1",
"uconnect": "^0.2.2",
"uconnect": "^0.2.3",
"uhooks": "^0.1.12"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc