Notes/static/js/lib/signals/signals.min.js
2023-06-15 07:24:23 +02:00

3 lines
3.3 KiB
JavaScript

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],r):r((n||self).preactSignals={},n.preact,n.hooks,n.signalsCore)}(this,function(n,r,i,e){var t,f,o=4;function u(n,i){r.options[n]=i.bind(null,r.options[n]||function(){})}function c(n){if(f)f();f=n&&n.S()}function a(n){var r=this,t=n.data,f=useSignal(t);f.value=t;var u=i.useMemo(function(){var n=r.__v;while(n=n.__)if(n.__c){n.__c.__$f|=o;break}r.__$u.c=function(){r.base.data=u.peek()};return e.computed(function(){var n=f.value.value;return 0===n?0:!0===n?"":n||""})},[]);return u.value}a.displayName="_st";Object.defineProperties(e.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:a},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});u("__b",function(n,r){if("string"==typeof r.type){var i,t=r.props;for(var f in t)if("children"!==f){var o=t[f];if(o instanceof e.Signal){if(!i)r.__np=i={};i[f]=o;t[f]=o.peek()}}}n(r)});u("__r",function(n,r){c();var i,f=r.__c;if(f){f.__$f&=-2;if(void 0===(i=f.__$u))f.__$u=i=function(n){var r;e.effect(function(){r=this});r.c=function(){f.__$f|=1;f.setState({})};return r}()}t=f;c(i);n(r)});u("__e",function(n,r,i,e){c();t=void 0;n(r,i,e)});u("diffed",function(n,r){c();t=void 0;var i;if("string"==typeof r.type&&(i=r.__e)){var e=r.__np,f=r.props;if(e){var o=i.U;if(o)for(var u in o){var a=o[u];if(void 0!==a&&!(u in e)){a.d();o[u]=void 0}}else i.U=o={};for(var s in e){var l=o[s],d=e[s];if(void 0===l){l=v(i,s,d,f);o[s]=l}else l.o(d,f)}}}n(r)});function v(n,r,i,t){var f=r in n&&void 0===n.ownerSVGElement,o=e.signal(i);return{o:function(n,r){o.value=n;t=r},d:e.effect(function(){var i=o.value.value;if(t[r]!==i){t[r]=i;if(f)n[r]=i;else if(i)n.setAttribute(r,i);else n.removeAttribute(r)}})}}u("unmount",function(n,r){if("string"==typeof r.type){var i=r.__e;if(i){var e=i.U;if(e){i.U=void 0;for(var t in e){var f=e[t];if(f)f.d()}}}}else{var o=r.__c;if(o){var u=o.__$u;if(u){o.__$u=void 0;u.d()}}}n(r)});u("__h",function(n,r,i,e){if(e<3)r.__$f|=2;n(r,i,e)});r.Component.prototype.shouldComponentUpdate=function(n,r){var i=this.__$u;if(!(i&&void 0!==i.s||this.__$f&o))return!0;if(3&this.__$f)return!0;for(var e in r)return!0;for(var t in n)if("__source"!==t&&n[t]!==this.props[t])return!0;for(var f in this.props)if(!(f in n))return!0;return!1};function useSignal(n){return i.useMemo(function(){return e.signal(n)},[])}Object.defineProperty(n,"Signal",{enumerable:!0,get:function(){return e.Signal}});Object.defineProperty(n,"batch",{enumerable:!0,get:function(){return e.batch}});Object.defineProperty(n,"computed",{enumerable:!0,get:function(){return e.computed}});Object.defineProperty(n,"effect",{enumerable:!0,get:function(){return e.effect}});Object.defineProperty(n,"signal",{enumerable:!0,get:function(){return e.signal}});n.useComputed=function(n){var r=i.useRef(n);r.current=n;t.__$f|=o;return i.useMemo(function(){return e.computed(function(){return r.current()})},[])};n.useSignal=useSignal;n.useSignalEffect=function(n){var r=i.useRef(n);r.current=n;i.useEffect(function(){return e.effect(function(){r.current()})},[])}});
//# sourceMappingURL=signals.min.js.map