dom-augmentor
Advanced tools
Comparing version 1.1.4 to 1.1.5
22
index.js
@@ -191,2 +191,5 @@ var augmentor = (function (exports) { | ||
} | ||
var isFunction = function isFunction(fn) { | ||
return typeof fn === 'function'; | ||
}; | ||
@@ -240,3 +243,3 @@ var compat = typeof cancelAnimationFrame === 'function'; | ||
if (stack.length <= index) { | ||
stack[index] = typeof value === 'function' ? value() : value; | ||
stack[index] = isFunction(value) ? value() : value; | ||
if (!updates.has(hook)) updates.set(hook, reraf()); | ||
@@ -246,3 +249,3 @@ } | ||
return [stack[index], function (value) { | ||
stack[index] = value; | ||
stack[index] = isFunction(value) ? value(stack[index]) : value; | ||
updates.get(hook)(hook, null, args); | ||
@@ -311,3 +314,2 @@ }]; | ||
var clean = info.clean, | ||
invoke = info.invoke, | ||
update = info.update, | ||
@@ -324,9 +326,9 @@ values = info.values; | ||
var invoke = function invoke() { | ||
info.clean = effect(); | ||
}; | ||
if (sync) after.push(invoke);else update(invoke); | ||
} | ||
} else { | ||
var _invoke = function _invoke() { | ||
_info.clean = effect(); | ||
}; | ||
if (!effects.has(hook)) effects.set(hook, { | ||
@@ -339,3 +341,2 @@ stack: [], | ||
clean: null, | ||
invoke: _invoke, | ||
stop: stop, | ||
@@ -347,2 +348,7 @@ update: details.update, | ||
details.stack.push(_info); | ||
var _invoke = function _invoke() { | ||
_info.clean = effect(); | ||
}; | ||
if (sync) after.push(_invoke);else _info.stop = details.update(_invoke); | ||
@@ -349,0 +355,0 @@ } |
/*! (c) Andrea Giammarchi - ISC */ | ||
var augmentor=function(e){"use strict";var n={};n.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(e){return n.prototype=new n("").constructor.prototype,n;function n(e,n){n||(n={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(e,!!n.bubbles,!!n.cancelable,n.detail),t}}();var t=n.CustomEvent,r={};try{r.WeakSet=WeakSet}catch(e){!function(e){var n=new e,t=u.prototype;function u(t){n.set(this,new e),t&&t.forEach(this.add,this)}t.add=function(e){return n.get(this).set(e,1),this},t.delete=function(e){return n.get(this).delete(e)},t.has=function(e){return n.get(this).has(e)},r.WeakSet=u}(WeakMap)}var u=r.WeakSet;var o=null,a=function(e){e()},c=function(){return o};function i(e,n){return e!==this[n]}var s="function"==typeof cancelAnimationFrame,f=s?cancelAnimationFrame:clearTimeout,l=s?requestAnimationFrame:setTimeout;function v(e){var n,t,r,u,o;return c(),function(e,c,s){return r=e,u=c,o=s,t||(t=l(a)),--n<0&&i(!0),i};function a(){c(),r.apply(u,o||[])}function c(){n=e||1/0,t=s?0:null}function i(e){var n=!!t;return n&&(f(t),e&&a()),n}}var d=new WeakMap,h=function(e){var n=c(),t=n.hook,r=n.args,u=n.stack,o=n.index;return u.length<=o&&(u[o]="function"==typeof e?e():e,d.has(t)||d.set(t,v())),[u[o],function(e){u[o]=e,d.get(t)(t,null,r)}]},p=new WeakMap,k=function(e){var n=e.hook,t=e.args;n.apply(null,t)};function m(e){this.value!==e&&(this.value=e,p.get(this).forEach(k))}function g(e){return e.hook===this.hook}var E=new WeakMap,y=function(){},w=function(e){return function(n,t){var r=c(),u=r.hook,o=r.stack,a=r.index,s=r.after;if(a<o.length){var f=o[a],l=f.clean,d=f.invoke,h=f.update,p=f.values;t&&!t.some(i,p)||(f.values=t,l&&(f.clean=null,l()),e?s.push(d):h(d))}else{var k=function(){g.clean=n()};E.has(u)||E.set(u,{stack:[],update:v()});var m=E.get(u),g={clean:null,invoke:k,stop:y,update:m.update,values:t};o[a]=g,m.stack.push(g),e?s.push(k):g.stop=m.update(k)}}},b=w(!1),W=w(!0),C=function(e,n){var t=c(),r=t.stack,u=t.index;return(!n||r.length<=u||n.some(i,r[u].values))&&(r[u]={current:e(),values:n}),r[u].current},N=function(e){var n=e.Event,t=e.WeakSet,r=!0,u=null;return function(e){return r&&(r=!r,u=new t,function(e){var r=new t,o=new t;try{new MutationObserver(s).observe(e,{subtree:!0,childList:!0})}catch(n){var a=0,c=[],i=function(e){c.push(e),clearTimeout(a),a=setTimeout(function(){s(c.splice(a=0,c.length))},0)};e.addEventListener("DOMNodeRemoved",function(e){i({addedNodes:[],removedNodes:[e.target]})},!0),e.addEventListener("DOMNodeInserted",function(e){i({addedNodes:[e.target],removedNodes:[]})},!0)}function s(e){for(var n,t=e.length,u=0;u<t;u++)f((n=e[u]).removedNodes,"disconnected",o,r),f(n.addedNodes,"connected",r,o)}function f(e,t,r,u){for(var o,a=new n(t),c=e.length,i=0;i<c;1===(o=e[i++]).nodeType&&l(o,a,t,r,u));}function l(e,n,t,r,o){u.has(e)&&!r.has(e)&&(o.delete(e),r.add(e),e.dispatchEvent(n));for(var a=e.children||[],c=a.length,i=0;i<c;l(a[i++],n,t,r,o));}}(e.ownerDocument)),u.add(e),e}}({Event:t,WeakSet:u});return e.augmentor=function(e){var n=function(e){var n=[];return function t(){var r=o,u=[],c=0;o={hook:t,args:arguments,stack:n,get index(){return c++},after:u};try{return e.apply(null,arguments)}finally{o=r,u.forEach(a)}}}(e),t=function(e){E.has(e)&&E.get(e).stack.forEach(function(e){var n=e.clean;(0,e.stop)(),n&&(e.clean=null,n())})}.bind(null,n);return function(){return function e(n,t){var r=n.nodeType;if(r){var u=1===r?n:function(e){for(var n=e.childNodes,t=n.length,r=0;r<t;){var u=n[r++];if(1===u.nodeType)return u}throw"unobservable"}(n);N(u),u.addEventListener("disconnected",t,!1)}else{var o=n.valueOf();o!==n&&e(o,t)}return n}(n.apply(this,arguments),t)}},e.createContext=function(e){var n={value:e,provide:m};return p.set(n,[]),n},e.useCallback=function(e,n){return C(function(){return e},n)},e.useContext=function(e){var n=c(),t=n.hook,r=n.args,u=p.get(e),o={hook:t,args:r};return u.some(g,o)||u.push(o),e.value},e.useEffect=b,e.useLayoutEffect=W,e.useMemo=C,e.useReducer=function(e,n,t){var r=h(t?t(n):n);return[r[0],function(n){r[1](e(r[0],n))}]},e.useRef=function(e){var n=c(),t=n.stack,r=n.index;return r<t.length?t[r]:t[r]={current:e}},e.useState=h,e}({}); | ||
var augmentor=function(e){"use strict";var n={};n.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(e){return n.prototype=new n("").constructor.prototype,n;function n(e,n){n||(n={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(e,!!n.bubbles,!!n.cancelable,n.detail),t}}();var t=n.CustomEvent,r={};try{r.WeakSet=WeakSet}catch(e){!function(e){var n=new e,t=u.prototype;function u(t){n.set(this,new e),t&&t.forEach(this.add,this)}t.add=function(e){return n.get(this).set(e,1),this},t.delete=function(e){return n.get(this).delete(e)},t.has=function(e){return n.get(this).has(e)},r.WeakSet=u}(WeakMap)}var u=r.WeakSet;var a=null,o=function(e){e()},c=function(){return a};function i(e,n){return e!==this[n]}var s=function(e){return"function"==typeof e},f="function"==typeof cancelAnimationFrame,l=f?cancelAnimationFrame:clearTimeout,v=f?requestAnimationFrame:setTimeout;function d(e){var n,t,r,u,a;return c(),function(e,c,s){return r=e,u=c,a=s,t||(t=v(o)),--n<0&&i(!0),i};function o(){c(),r.apply(u,a||[])}function c(){n=e||1/0,t=f?0:null}function i(e){var n=!!t;return n&&(l(t),e&&o()),n}}var h=new WeakMap,p=function(e){var n=c(),t=n.hook,r=n.args,u=n.stack,a=n.index;return u.length<=a&&(u[a]=s(e)?e():e,h.has(t)||h.set(t,d())),[u[a],function(e){u[a]=s(e)?e(u[a]):e,h.get(t)(t,null,r)}]},m=new WeakMap,g=function(e){var n=e.hook,t=e.args;n.apply(null,t)};function k(e){this.value!==e&&(this.value=e,m.get(this).forEach(g))}function E(e){return e.hook===this.hook}var y=new WeakMap,w=function(){},b=function(e){return function(n,t){var r=c(),u=r.hook,a=r.stack,o=r.index,s=r.after;if(o<a.length){var f=a[o],l=f.clean,v=f.update,h=f.values;if(!t||t.some(i,h)){f.values=t,l&&(f.clean=null,l());var p=function(){f.clean=n()};e?s.push(p):v(p)}}else{y.has(u)||y.set(u,{stack:[],update:d()});var m=y.get(u),g={clean:null,stop:w,update:m.update,values:t};a[o]=g,m.stack.push(g);var k=function(){g.clean=n()};e?s.push(k):g.stop=m.update(k)}}},W=b(!1),C=b(!0),N=function(e,n){var t=c(),r=t.stack,u=t.index;return(!n||r.length<=u||n.some(i,r[u].values))&&(r[u]={current:e(),values:n}),r[u].current},M=function(e){var n=e.Event,t=e.WeakSet,r=!0,u=null;return function(e){return r&&(r=!r,u=new t,function(e){var r=new t,a=new t;try{new MutationObserver(s).observe(e,{subtree:!0,childList:!0})}catch(n){var o=0,c=[],i=function(e){c.push(e),clearTimeout(o),o=setTimeout(function(){s(c.splice(o=0,c.length))},0)};e.addEventListener("DOMNodeRemoved",function(e){i({addedNodes:[],removedNodes:[e.target]})},!0),e.addEventListener("DOMNodeInserted",function(e){i({addedNodes:[e.target],removedNodes:[]})},!0)}function s(e){for(var n,t=e.length,u=0;u<t;u++)f((n=e[u]).removedNodes,"disconnected",a,r),f(n.addedNodes,"connected",r,a)}function f(e,t,r,u){for(var a,o=new n(t),c=e.length,i=0;i<c;1===(a=e[i++]).nodeType&&l(a,o,t,r,u));}function l(e,n,t,r,a){u.has(e)&&!r.has(e)&&(a.delete(e),r.add(e),e.dispatchEvent(n));for(var o=e.children||[],c=o.length,i=0;i<c;l(o[i++],n,t,r,a));}}(e.ownerDocument)),u.add(e),e}}({Event:t,WeakSet:u});return e.augmentor=function(e){var n=function(e){var n=[];return function t(){var r=a,u=[],c=0;a={hook:t,args:arguments,stack:n,get index(){return c++},after:u};try{return e.apply(null,arguments)}finally{a=r,u.forEach(o)}}}(e),t=function(e){y.has(e)&&y.get(e).stack.forEach(function(e){var n=e.clean;(0,e.stop)(),n&&(e.clean=null,n())})}.bind(null,n);return function(){return function e(n,t){var r=n.nodeType;if(r){var u=1===r?n:function(e){for(var n=e.childNodes,t=n.length,r=0;r<t;){var u=n[r++];if(1===u.nodeType)return u}throw"unobservable"}(n);M(u),u.addEventListener("disconnected",t,!1)}else{var a=n.valueOf();a!==n&&e(a,t)}return n}(n.apply(this,arguments),t)}},e.createContext=function(e){var n={value:e,provide:k};return m.set(n,[]),n},e.useCallback=function(e,n){return N(function(){return e},n)},e.useContext=function(e){var n=c(),t=n.hook,r=n.args,u=m.get(e),a={hook:t,args:r};return u.some(E,a)||u.push(a),e.value},e.useEffect=W,e.useLayoutEffect=C,e.useMemo=N,e.useReducer=function(e,n,t){var r=p(t?t(n):n);return[r[0],function(n){r[1](e(r[0],n))}]},e.useRef=function(e){var n=c(),t=n.stack,r=n.index;return r<t.length?t[r]:t[r]={current:e}},e.useState=p,e}({}); |
{ | ||
"name": "dom-augmentor", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "DOM oriented useEffect hooks for the augmentor", | ||
@@ -35,3 +35,3 @@ "main": "cjs/index.js", | ||
"@ungap/weakset": "^0.1.5", | ||
"augmentor": "^1.1.5", | ||
"augmentor": "^1.1.7", | ||
"disconnected": "^0.2.1" | ||
@@ -38,0 +38,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25398
548
Updatedaugmentor@^1.1.7