Comparing version 0.0.13 to 0.1.0
@@ -1,2 +0,2 @@ | ||
var t=require("react"),i=null;function n(t){var n=i;return i=t,n}var r=100,s=new Set,h=new Set,o=[],u=!1,f=function(t){Promise.resolve().then(t)},e=function(t){console.error("Reaction exception:",t)};function c(){try{for(var t=r;o.length||h.size;){for(h.forEach(function(t){t.t()}),h.clear();o.length&&--t;){var i=o;o=[],i.forEach(function(t){try{t.i()}catch(t){e(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{s.forEach(function(t){t.h()}),s.clear(),u=!1,o=[]}}function a(){!u&&(o.length||h.size||s.size)&&(u=!0,f(c))}var v=0;function l(t,i){void 0===i&&(i=null);var r=n(i);++v;try{return t()}finally{n(r),--v||a()}}function p(t){return function(){var i=n(null);try{return t.apply(this,arguments)}finally{n(i)}}}var w=Object.prototype.hasOwnProperty;function y(t){return t.constructor===Object||null===t.constructor}function d(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){var n=t.length;if(n!==i.length)return!1;for(;n--;)if(t[n]!==i[n])return!1;return!0}if(t&&i&&"object"==typeof t&&"object"==typeof i&&y(t)&&y(i)){var r=Object.keys(t),s=r.length;if(Object.keys(i).length!==s)return!1;for(;s-- >0;){var h=r[s];if(!w.call(i,h)||t[h]!==i[h])return!1}return!0}if(t instanceof Set&&i instanceof Set){if(t.size!==i.size)return!1;var o=!0;return t.forEach(function(t){i.has(t)||(o=!1)}),o}if(t instanceof Map&&i instanceof Map){if(t.size!==i.size)return!1;var u=!0;return t.forEach(function(t,n){i.get(n)!==t&&(u=!1)}),u}return!1}var Computed=/*#__PURE__*/function(){function Computed(t,i){this.o=void 0,this.u={},this.v=new Set,this.l=[],this.p=[],this.S=[],this.j=0,this.m=!0,this.O=t,this.g=i?"function"==typeof i?p(i):d:void 0}var t=Computed.prototype;return t.R=function(t){this.m&&!t._(this)||(this.p.push(t),this.l.push(t.A()))},t._=function(t){return!this.v.has(t)&&(this.v.add(t),!0)},t.M=function(t){this.v.delete(t),this.q()},t.q=function(){this.v.size||5===this.j||s.add(this)},t.h=function(){this.v.size||5===this.j||this.C()},t.I=function(t,i){this.j>=t||(this.g?1===this.j&&this.P(2):this.P(t),this.j=t,2===t?this.S.push(i):this.T())},t.t=function(){var t=this;if((5!==this.j||this.p.some(function(i,n){return i.A()!==t.l[n]}))&&(2===this.j&&(this.S.forEach(function(t){t.t()}),this.S=[],2===this.j&&(this.j=1)),1!==this.j)){var i=this.j,r=5===i,s=n(this);this.p=[],this.l=[],this.m=!r,this.j=4;try{var h=this.O();if(this.j=r?5:1,this.g&&0!==i){if(this.g(this.o,h))return;this.P(3)}this.o=h,this.u={}}catch(t){throw this.k(),t}finally{n(s)}}},t.k=function(){this.T(),this.p=[],this.l=[],this.S=[],this.j=0,this.o=void 0},t.A=function(){return this.t(),this.u},t.B=function(t){if(void 0===t&&(t=i),4===this.j)throw new Error("Recursive computed call");return this.t(),t?(5===this.j&&this.D(),t.R(this)):this.q(),this.o},t.F=function(){var t=this;this.p.forEach(function(i){i._(t)})},t.T=function(){var t=this;this.p.forEach(function(i){i.M(t)})},t.P=function(t){var i=this;this.v.forEach(function(n){n.I(t,i)})},t.C=function(){this.T(),this.j=5},t.D=function(){this.F(),this.j=1},Computed}(),Observable=/*#__PURE__*/function(){function Observable(t,i){this.u={},this.v=new Set,this.o=t,this.g=i?"function"==typeof i?p(i):d:void 0}var t=Observable.prototype;return t._=function(t){return!this.v.has(t)&&(this.v.add(t),!0)},t.M=function(t){this.v.delete(t)},t.A=function(){return this.u},t.B=function(t){return void 0===t&&(t=i),t&&t.R(this),this.o},t.G=function(t,n){if(i&&i instanceof Computed)throw new Error("Changing observable inside of computed");if(arguments.length>0){if("function"!=typeof t||n||(t=t(this.o)),this.g&&this.g(this.o,t))return;this.o=t,this.u={}}this.H()},t.H=function(){var t=this;this.v.forEach(function(i){return i.I(3,t)}),!v&&a()},Observable}(),Reaction=/*#__PURE__*/function(){function Reaction(t,i){var n=this;this.O=void 0,this.J=void 0,this.p=[],this.K=null,this.j=1,this.L=function(){n.K=n.O()},this.O=t,this.J=i}var t=Reaction.prototype;return t.R=function(t){t._(this)&&this.p.push(t)},t.I=function(t,i){2===t?h.add(i):1===this.j&&(this.j=3,o.push(this))},t.F=function(){var t=this;this.p.forEach(function(i){i._(t)})},t.T=function(){var t=this;this.p.forEach(function(i){i.M(t)})},t.N=function(){this.T(),this.p=[],this.K&&this.K(),this.K=null,this.j=1},t.i=function(){6!==this.j&&(this.J?this.J():this.U())},t.k=function(){this.N(),this.j=6},t.U=function(){this.N(),l(this.L,this)},Reaction}(),x=new Set,b=new Set,S=null,j="undefined"!=typeof window,m=[],O=function(){};exports.action=function(t){return function(){var i=n(null);++v;try{return t.apply(this,arguments)}finally{n(i),--v||a()}}},exports.computed=function(t,i){var n=new Computed(t,i),r=n.B.bind(n);return r.$$computed=n,r.destroy=n.k.bind(n),r},exports.configure=function(t){void 0!==t.reactionScheduler&&(f=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(e=t.reactionExceptionHandler)},exports.observable=function(t,i){var n=new Observable(t,i),r=n.B.bind(n),s=n.G.bind(n);return r.$$observable=n,[r,s]},exports.reaction=function(t,i){var n=new Reaction(t,i),r=n.k.bind(n);return r.run=n.U.bind(n),n.U(),r},exports.shallowEquals=d,exports.tx=function(t){++v;try{t()}finally{--v||a()}},exports.untracked=p,exports.useObserver=function(){if(j){var i=t.useMemo(function(){var t={},i=new Set,n=!1,r=new Reaction(O,function(){t={},i.forEach(function(t){t()})});return function(t){x.add(t),S||(S=setTimeout(function(){S=null;var t=b;b=x,x=new Set,t.forEach(function(t){t.T()})},5e3))}(r),{F:function(t){return function(t){x.delete(t),b.delete(t)}(r),n&&!i.size&&(r.F(),n=!1),i.add(t),function(){i.delete(t),i.size||(n=!0,r.T())}},A:function(){return t},V:r}},m);t.useSyncExternalStore(i.F,i.A);var n=i.V;return n.N(),n}},exports.utx=l; | ||
var t=require("react"),Revision=function(){},n=null;function i(t){var i=n;return n=t,i}var r=100,s=new Set,o=new Set,u=[],h=!1,f=function(t){Promise.resolve().then(t)},e=function(t){console.error("Reaction exception:",t)};function c(){try{for(var t=r;u.length||o.size;){for(o.forEach(function(t){t.t()}),o.clear();u.length&&--t;){var n=u;u=[],n.forEach(function(t){try{t.i()}catch(t){e(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{h=!1,u=[],s.forEach(function(t){t.o()}),s.clear()}}function a(){!h&&(u.length||o.size||s.size)&&(h=!0,f(c))}var v=0;function l(t,n){void 0===n&&(n=null);var r=i(n);++v;try{return t()}finally{i(r),--v||a()}}function w(t){return function(){var n=i(null);try{return t.apply(this,arguments)}finally{i(n)}}}var p=Object.prototype.hasOwnProperty;function y(t){return t.constructor===Object||null===t.constructor}function d(t,n){if(t===n)return!0;if(Array.isArray(t)&&Array.isArray(n)){var i=t.length;if(i!==n.length)return!1;for(;i--;)if(t[i]!==n[i])return!1;return!0}if(t&&n&&"object"==typeof t&&"object"==typeof n&&y(t)&&y(n)){var r=Object.keys(t),s=r.length;if(Object.keys(n).length!==s)return!1;for(;s-- >0;){var o=r[s];if(!p.call(n,o)||t[o]!==n[o])return!1}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var u=!0;return t.forEach(function(t){n.has(t)||(u=!1)}),u}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var h=!0;return t.forEach(function(t,i){n.get(i)!==t&&(h=!1)}),h}return!1}var Computed=/*#__PURE__*/function(){function Computed(t,n){this.u=void 0,this.h=new Revision,this.v=new Set,this.l=new Map,this.p=[],this.S=0,this.j=!0,this.M=t,this.O=n?"function"==typeof n?w(n):d:void 0}var t=Computed.prototype;return t.addSubscription=function(t){this.j&&t.R(this),this.l.set(t,t.revision())},t.R=function(t){this.v.add(t),5===this.S&&this._()},t.g=function(t){this.v.delete(t),this.m()},t.o=function(){this.v.size||5===this.S||this.A()},t.q=function(t,n){this.S>=t||(this.O?1===this.S&&this.B(2):this.B(t),this.S=t,2===t?this.p.push(n):this.C())},t.t=function(t){if(void 0===t&&(t=!1),5===this.S){var n=!1;if(this.l.forEach(function(t,i){n||(n=i.revision()!==t)}),!n)return}if(2===this.S&&(this.p.forEach(function(n){n.t(t)}),this.p=[],2===this.S&&(this.S=1)),1!==this.S){var r=this.S,s=0!==r;this.j=t||s&&5!==r,this.l.clear(),this.S=4;var o=i(this);try{var u=this.M();if(this.S=this.j?1:5,this.O&&s){if(this.O(this.u,u))return;this.B(3)}this.u=u,this.h=new Revision}catch(t){throw this.destroy(),t}finally{i(o)}}},t.revision=function(){return this.t(),this.h},t.destroy=function(){this.C(),this.l.clear(),this.p=[],this.S=0,this.u=void 0},t.get=function(t){if(void 0===t&&(t=n),4===this.S)throw new Error("Recursive computed call");var i=!!t;return this.t(i),i&&t.addSubscription(this),this.u},t.m=function(){this.v.size||5===this.S||function(t){s.add(t)}(this)},t.I=function(){var t=this;this.l.forEach(function(n,i){i.R(t)})},t.C=function(){var t=this;this.l.forEach(function(n,i){i.g(t)})},t.B=function(t){var n=this;this.v.forEach(function(i){i.q(t,n)})},t.A=function(){this.C(),this.S=5},t._=function(){this.I(),this.S=1},Computed}();function x(t,n){var i=new Computed(t,n),r=i.get.bind(i);return r.instance=i,r.destroy=i.destroy.bind(i),r}x.box=function(t,n){return new Computed(t,n)},x.prop=function(t,n){return new Computed(t,n)};var Observable=/*#__PURE__*/function(){function Observable(t,n){this.h=new Revision,this.v=new Set,this.u=t,this.O=n?"function"==typeof n?w(n):d:void 0}var t=Observable.prototype;return t.R=function(t){this.v.add(t)},t.g=function(t){this.v.delete(t)},t.revision=function(){return this.h},t.get=function(t){return void 0===t&&(t=n),t&&t.addSubscription(this),this.u},t.set=function(t,i){if(n&&n instanceof Computed)throw new Error("Changing observable inside of computed");if(arguments.length>0){if("function"!=typeof t||i||(t=t(this.u)),this.O&&this.O(this.u,t))return;this.u=t,this.h=new Revision}this.notify()},t.notify=function(){var t=this;this.v.forEach(function(n){return n.q(3,t)}),!v&&a()},Observable}();function b(t,n){var i=new Observable(t,n),r=i.get.bind(i),s=i.set.bind(i);return r.instance=i,[r,s]}b.box=function(t,n){return new Observable(t,n)},b.prop=function(t,n){return new Observable(t,n)};var Reaction=/*#__PURE__*/function(){function Reaction(t,n){var i=this;this.M=void 0,this.P=void 0,this.j=!0,this.l=new Map,this.k=null,this.S=1,this.D=function(){i.k=i.M()},this.M=t,this.P=n}var t=Reaction.prototype;return t.addSubscription=function(t){this.j&&t.R(this),this.l.set(t,t.revision())},t.q=function(t,n){2===t?function(t){o.add(t)}(n):1===this.S&&(this.S=3,u.push(this))},t.I=function(){var t=this;this.l.forEach(function(n,i){i.R(t)})},t.C=function(){var t=this;this.l.forEach(function(n,i){i.g(t)})},t.F=function(){this.C(),this.l.clear(),this.k&&this.k(),this.k=null,this.S=1},t.i=function(){6!==this.S&&(this.P?this.P():this.run())},t.G=function(){var t=!1;return this.l.forEach(function(n,i){t||(t=i.revision()!==n)}),t},t.destroy=function(){this.F(),this.S=6},t.run=function(){this.F(),l(this.D,this)},Reaction}(),S="undefined"!=typeof window,j=[],M=function(){},O=function(t){return t()};O.addSubscription=M,exports.Computed=Computed,exports.Observable=Observable,exports.Reaction=Reaction,exports.Revision=Revision,exports.action=function(t){return function(){var n=i(null);++v;try{return t.apply(this,arguments)}finally{i(n),--v||a()}}},exports.computed=x,exports.configure=function(t){void 0!==t.reactionScheduler&&(f=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(e=t.reactionExceptionHandler)},exports.observable=b,exports.reaction=function(t,n){var i=new Reaction(t,n),r=i.destroy.bind(i);return r.run=i.run.bind(i),i.run(),r},exports.setSubscriber=i,exports.shallowEquals=d,exports.tx=function(t){++v;try{t()}finally{--v||a()}},exports.useObserver=function(){if(!S)return O;var n=t.useMemo(function(){var t=new Revision,n=new Set,r=new Reaction(M,function(){t=new Revision,n.forEach(function(t){t()})});r.j=!1;var s=function(t){var n=i(r);try{return t()}finally{i(n)}};return s.addSubscription=r.addSubscription.bind(r),{I:function(t){return n.add(t),r.j=!0,r.I(),r.G()&&t(),function(){n.delete(t),n.size||(r.C(),r.j=!1)}},H:function(){return t},J:function(){r.F()},K:s}},j);return t.useSyncExternalStore(n.I,n.H),n.J(),n.K},exports.utx=l,exports.withUntracked=w; | ||
//# sourceMappingURL=onek.js.map |
@@ -1,2 +0,2 @@ | ||
import{useMemo as t,useSyncExternalStore as i}from"react";var n=null;function r(t){var i=n;return n=t,i}var s=100,h=new Set,o=new Set,u=[],f=!1,c=function(t){Promise.resolve().then(t)},e=function(t){console.error("Reaction exception:",t)};function a(t){void 0!==t.reactionScheduler&&(c=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(e=t.reactionExceptionHandler)}function v(){try{for(var t=s;u.length||o.size;){for(o.forEach(function(t){t.t()}),o.clear();u.length&&--t;){var i=u;u=[],i.forEach(function(t){try{t.i()}catch(t){e(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{h.forEach(function(t){t.h()}),h.clear(),f=!1,u=[]}}function l(){!f&&(u.length||o.size||h.size)&&(f=!0,c(v))}var w=0;function y(t){++w;try{t()}finally{--w||l()}}function d(t,i){void 0===i&&(i=null);var n=r(i);++w;try{return t()}finally{r(n),--w||l()}}function p(t){return function(){var i=r(null);try{return t.apply(this,arguments)}finally{r(i)}}}function b(t){return function(){var i=r(null);++w;try{return t.apply(this,arguments)}finally{r(i),--w||l()}}}var S=Object.prototype.hasOwnProperty;function j(t){return t.constructor===Object||null===t.constructor}function m(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){var n=t.length;if(n!==i.length)return!1;for(;n--;)if(t[n]!==i[n])return!1;return!0}if(t&&i&&"object"==typeof t&&"object"==typeof i&&j(t)&&j(i)){var r=Object.keys(t),s=r.length;if(Object.keys(i).length!==s)return!1;for(;s-- >0;){var h=r[s];if(!S.call(i,h)||t[h]!==i[h])return!1}return!0}if(t instanceof Set&&i instanceof Set){if(t.size!==i.size)return!1;var o=!0;return t.forEach(function(t){i.has(t)||(o=!1)}),o}if(t instanceof Map&&i instanceof Map){if(t.size!==i.size)return!1;var u=!0;return t.forEach(function(t,n){i.get(n)!==t&&(u=!1)}),u}return!1}var Computed=/*#__PURE__*/function(){function Computed(t,i){this.o=void 0,this.u={},this.v=new Set,this.l=[],this.p=[],this.S=[],this.j=0,this.m=!0,this.O=t,this.g=i?"function"==typeof i?p(i):m:void 0}var t=Computed.prototype;return t.R=function(t){this.m&&!t._(this)||(this.p.push(t),this.l.push(t.A()))},t._=function(t){return!this.v.has(t)&&(this.v.add(t),!0)},t.M=function(t){this.v.delete(t),this.C()},t.C=function(){this.v.size||5===this.j||function(t){h.add(t)}(this)},t.h=function(){this.v.size||5===this.j||this.I()},t.P=function(t,i){this.j>=t||(this.g?1===this.j&&this.T(2):this.T(t),this.j=t,2===t?this.S.push(i):this.k())},t.t=function(){var t=this;if((5!==this.j||this.p.some(function(i,n){return i.A()!==t.l[n]}))&&(2===this.j&&(this.S.forEach(function(t){t.t()}),this.S=[],2===this.j&&(this.j=1)),1!==this.j)){var i=this.j,n=5===i,s=r(this);this.p=[],this.l=[],this.m=!n,this.j=4;try{var h=this.O();if(this.j=n?5:1,this.g&&0!==i){if(this.g(this.o,h))return;this.T(3)}this.o=h,this.u={}}catch(t){throw this.q(),t}finally{r(s)}}},t.q=function(){this.k(),this.p=[],this.l=[],this.S=[],this.j=0,this.o=void 0},t.A=function(){return this.t(),this.u},t.B=function(t){if(void 0===t&&(t=n),4===this.j)throw new Error("Recursive computed call");return this.t(),t?(5===this.j&&this.D(),t.R(this)):this.C(),this.o},t.F=function(){var t=this;this.p.forEach(function(i){i._(t)})},t.k=function(){var t=this;this.p.forEach(function(i){i.M(t)})},t.T=function(t){var i=this;this.v.forEach(function(n){n.P(t,i)})},t.I=function(){this.k(),this.j=5},t.D=function(){this.F(),this.j=1},Computed}();function O(t,i){var n=new Computed(t,i),r=n.B.bind(n);return r.$$computed=n,r.destroy=n.q.bind(n),r}var Observable=/*#__PURE__*/function(){function Observable(t,i){this.u={},this.v=new Set,this.o=t,this.g=i?"function"==typeof i?p(i):m:void 0}var t=Observable.prototype;return t._=function(t){return!this.v.has(t)&&(this.v.add(t),!0)},t.M=function(t){this.v.delete(t)},t.A=function(){return this.u},t.B=function(t){return void 0===t&&(t=n),t&&t.R(this),this.o},t.G=function(t,i){if(n&&n instanceof Computed)throw new Error("Changing observable inside of computed");if(arguments.length>0){if("function"!=typeof t||i||(t=t(this.o)),this.g&&this.g(this.o,t))return;this.o=t,this.u={}}this.H()},t.H=function(){var t=this;this.v.forEach(function(i){return i.P(3,t)}),!w&&l()},Observable}();function g(t,i){var n=new Observable(t,i),r=n.B.bind(n),s=n.G.bind(n);return r.$$observable=n,[r,s]}var Reaction=/*#__PURE__*/function(){function Reaction(t,i){var n=this;this.O=void 0,this.J=void 0,this.p=[],this.K=null,this.j=1,this.L=function(){n.K=n.O()},this.O=t,this.J=i}var t=Reaction.prototype;return t.R=function(t){t._(this)&&this.p.push(t)},t.P=function(t,i){2===t?function(t){o.add(t)}(i):1===this.j&&(this.j=3,function(t){u.push(t)}(this))},t.F=function(){var t=this;this.p.forEach(function(i){i._(t)})},t.k=function(){var t=this;this.p.forEach(function(i){i.M(t)})},t.N=function(){this.k(),this.p=[],this.K&&this.K(),this.K=null,this.j=1},t.i=function(){6!==this.j&&(this.J?this.J():this.U())},t.q=function(){this.N(),this.j=6},t.U=function(){this.N(),d(this.L,this)},Reaction}();function E(t,i){var n=new Reaction(t,i),r=n.q.bind(n);return r.run=n.U.bind(n),n.U(),r}var R=new Set,_=new Set,x=null,A="undefined"!=typeof window,M=[],C=function(){};function I(){if(A){var n=t(function(){var t={},i=new Set,n=!1,r=new Reaction(C,function(){t={},i.forEach(function(t){t()})});return function(t){R.add(t),x||(x=setTimeout(function(){x=null;var t=_;_=R,R=new Set,t.forEach(function(t){t.k()})},5e3))}(r),{F:function(t){return function(t){R.delete(t),_.delete(t)}(r),n&&!i.size&&(r.F(),n=!1),i.add(t),function(){i.delete(t),i.size||(n=!0,r.k())}},A:function(){return t},V:r}},M);i(n.F,n.A);var r=n.V;return r.N(),r}}export{b as action,O as computed,a as configure,g as observable,E as reaction,m as shallowEquals,y as tx,p as untracked,I as useObserver,d as utx}; | ||
import{useMemo as t,useSyncExternalStore as n}from"react";var Revision=function(){},i=null;function r(t){var n=i;return i=t,n}var u=100,o=new Set,s=new Set,f=[],h=!1,e=function(t){Promise.resolve().then(t)},c=function(t){console.error("Reaction exception:",t)};function a(t){void 0!==t.reactionScheduler&&(e=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(c=t.reactionExceptionHandler)}function v(){try{for(var t=u;f.length||s.size;){for(s.forEach(function(t){t.t()}),s.clear();f.length&&--t;){var n=f;f=[],n.forEach(function(t){try{t.i()}catch(t){c(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{h=!1,f=[],o.forEach(function(t){t.u()}),o.clear()}}function l(){!h&&(f.length||s.size||o.size)&&(h=!0,e(v))}var w=0;function y(t){++w;try{t()}finally{--w||l()}}function d(t,n){void 0===n&&(n=null);var i=r(n);++w;try{return t()}finally{r(i),--w||l()}}function p(t){return function(){var n=r(null);try{return t.apply(this,arguments)}finally{r(n)}}}function b(t){return function(){var n=r(null);++w;try{return t.apply(this,arguments)}finally{r(n),--w||l()}}}var S=Object.prototype.hasOwnProperty;function j(t){return t.constructor===Object||null===t.constructor}function m(t,n){if(t===n)return!0;if(Array.isArray(t)&&Array.isArray(n)){var i=t.length;if(i!==n.length)return!1;for(;i--;)if(t[i]!==n[i])return!1;return!0}if(t&&n&&"object"==typeof t&&"object"==typeof n&&j(t)&&j(n)){var r=Object.keys(t),u=r.length;if(Object.keys(n).length!==u)return!1;for(;u-- >0;){var o=r[u];if(!S.call(n,o)||t[o]!==n[o])return!1}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var s=!0;return t.forEach(function(t){n.has(t)||(s=!1)}),s}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var f=!0;return t.forEach(function(t,i){n.get(i)!==t&&(f=!1)}),f}return!1}var Computed=/*#__PURE__*/function(){function Computed(t,n){this.o=void 0,this.h=new Revision,this.v=new Set,this.l=new Map,this.p=[],this.S=0,this.j=!0,this.m=t,this.M=n?"function"==typeof n?p(n):m:void 0}var t=Computed.prototype;return t.addSubscription=function(t){this.j&&t.O(this),this.l.set(t,t.revision())},t.O=function(t){this.v.add(t),5===this.S&&this.R()},t._=function(t){this.v.delete(t),this.g()},t.u=function(){this.v.size||5===this.S||this.A()},t.B=function(t,n){this.S>=t||(this.M?1===this.S&&this.C(2):this.C(t),this.S=t,2===t?this.p.push(n):this.I())},t.t=function(t){if(void 0===t&&(t=!1),5===this.S){var n=!1;if(this.l.forEach(function(t,i){n||(n=i.revision()!==t)}),!n)return}if(2===this.S&&(this.p.forEach(function(n){n.t(t)}),this.p=[],2===this.S&&(this.S=1)),1!==this.S){var i=this.S,u=0!==i;this.j=t||u&&5!==i,this.l.clear(),this.S=4;var o=r(this);try{var s=this.m();if(this.S=this.j?1:5,this.M&&u){if(this.M(this.o,s))return;this.C(3)}this.o=s,this.h=new Revision}catch(t){throw this.destroy(),t}finally{r(o)}}},t.revision=function(){return this.t(),this.h},t.destroy=function(){this.I(),this.l.clear(),this.p=[],this.S=0,this.o=void 0},t.get=function(t){if(void 0===t&&(t=i),4===this.S)throw new Error("Recursive computed call");var n=!!t;return this.t(n),n&&t.addSubscription(this),this.o},t.g=function(){this.v.size||5===this.S||function(t){o.add(t)}(this)},t.P=function(){var t=this;this.l.forEach(function(n,i){i.O(t)})},t.I=function(){var t=this;this.l.forEach(function(n,i){i._(t)})},t.C=function(t){var n=this;this.v.forEach(function(i){i.B(t,n)})},t.A=function(){this.I(),this.S=5},t.R=function(){this.P(),this.S=1},Computed}();function M(t,n){var i=new Computed(t,n),r=i.get.bind(i);return r.instance=i,r.destroy=i.destroy.bind(i),r}M.box=function(t,n){return new Computed(t,n)},M.prop=function(t,n){return new Computed(t,n)};var Observable=/*#__PURE__*/function(){function Observable(t,n){this.h=new Revision,this.v=new Set,this.o=t,this.M=n?"function"==typeof n?p(n):m:void 0}var t=Observable.prototype;return t.O=function(t){this.v.add(t)},t._=function(t){this.v.delete(t)},t.revision=function(){return this.h},t.get=function(t){return void 0===t&&(t=i),t&&t.addSubscription(this),this.o},t.set=function(t,n){if(i&&i instanceof Computed)throw new Error("Changing observable inside of computed");if(arguments.length>0){if("function"!=typeof t||n||(t=t(this.o)),this.M&&this.M(this.o,t))return;this.o=t,this.h=new Revision}this.notify()},t.notify=function(){var t=this;this.v.forEach(function(n){return n.B(3,t)}),!w&&l()},Observable}();function O(t,n){var i=new Observable(t,n),r=i.get.bind(i),u=i.set.bind(i);return r.instance=i,[r,u]}O.box=function(t,n){return new Observable(t,n)},O.prop=function(t,n){return new Observable(t,n)};var Reaction=/*#__PURE__*/function(){function Reaction(t,n){var i=this;this.m=void 0,this.k=void 0,this.j=!0,this.l=new Map,this.q=null,this.S=1,this.D=function(){i.q=i.m()},this.m=t,this.k=n}var t=Reaction.prototype;return t.addSubscription=function(t){this.j&&t.O(this),this.l.set(t,t.revision())},t.B=function(t,n){2===t?function(t){s.add(t)}(n):1===this.S&&(this.S=3,function(t){f.push(t)}(this))},t.P=function(){var t=this;this.l.forEach(function(n,i){i.O(t)})},t.I=function(){var t=this;this.l.forEach(function(n,i){i._(t)})},t.F=function(){this.I(),this.l.clear(),this.q&&this.q(),this.q=null,this.S=1},t.i=function(){6!==this.S&&(this.k?this.k():this.run())},t.G=function(){var t=!1;return this.l.forEach(function(n,i){t||(t=i.revision()!==n)}),t},t.destroy=function(){this.F(),this.S=6},t.run=function(){this.F(),d(this.D,this)},Reaction}();function R(t,n){var i=new Reaction(t,n),r=i.destroy.bind(i);return r.run=i.run.bind(i),i.run(),r}var _="undefined"!=typeof window,g=[],E=function(){},x=function(t){return t()};function A(){if(!_)return x;var i=t(function(){var t=new Revision,n=new Set,i=new Reaction(E,function(){t=new Revision,n.forEach(function(t){t()})});i.j=!1;var u=function(t){var n=r(i);try{return t()}finally{r(n)}};return u.addSubscription=i.addSubscription.bind(i),{P:function(t){return n.add(t),i.j=!0,i.P(),i.G()&&t(),function(){n.delete(t),n.size||(i.I(),i.j=!1)}},H:function(){return t},J:function(){i.F()},K:u}},g);return n(i.P,i.H),i.J(),i.K}x.addSubscription=E;export{Computed,Observable,Reaction,Revision,b as action,M as computed,a as configure,O as observable,R as reaction,r as setSubscriber,m as shallowEquals,y as tx,A as useObserver,d as utx,p as withUntracked}; | ||
//# sourceMappingURL=onek.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],i):i((t||self).onek={},t.react)}(this,function(t,i){var n=null;function s(t){var i=n;return n=t,i}var r=100,o=new Set,h=new Set,u=[],f=!1,e=function(t){Promise.resolve().then(t)},c=function(t){console.error("Reaction exception:",t)};function a(){try{for(var t=r;u.length||h.size;){for(h.forEach(function(t){t.t()}),h.clear();u.length&&--t;){var i=u;u=[],i.forEach(function(t){try{t.i()}catch(t){c(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{o.forEach(function(t){t.o()}),o.clear(),f=!1,u=[]}}function v(){!f&&(u.length||h.size||o.size)&&(f=!0,e(a))}var l=0;function d(t,i){void 0===i&&(i=null);var n=s(i);++l;try{return t()}finally{s(n),--l||v()}}function y(t){return function(){var i=s(null);try{return t.apply(this,arguments)}finally{s(i)}}}var w=Object.prototype.hasOwnProperty;function p(t){return t.constructor===Object||null===t.constructor}function b(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){var n=t.length;if(n!==i.length)return!1;for(;n--;)if(t[n]!==i[n])return!1;return!0}if(t&&i&&"object"==typeof t&&"object"==typeof i&&p(t)&&p(i)){var s=Object.keys(t),r=s.length;if(Object.keys(i).length!==r)return!1;for(;r-- >0;){var o=s[r];if(!w.call(i,o)||t[o]!==i[o])return!1}return!0}if(t instanceof Set&&i instanceof Set){if(t.size!==i.size)return!1;var h=!0;return t.forEach(function(t){i.has(t)||(h=!1)}),h}if(t instanceof Map&&i instanceof Map){if(t.size!==i.size)return!1;var u=!0;return t.forEach(function(t,n){i.get(n)!==t&&(u=!1)}),u}return!1}var Computed=/*#__PURE__*/function(){function Computed(t,i){this.h=void 0,this.u={},this.v=new Set,this.l=[],this.p=[],this.S=[],this.j=0,this.g=!0,this.m=t,this.O=i?"function"==typeof i?y(i):b:void 0}var t=Computed.prototype;return t.R=function(t){this.g&&!t.T(this)||(this.p.push(t),this.l.push(t._()))},t.T=function(t){return!this.v.has(t)&&(this.v.add(t),!0)},t.A=function(t){this.v.delete(t),this.M()},t.M=function(){this.v.size||5===this.j||o.add(this)},t.o=function(){this.v.size||5===this.j||this.q()},t.C=function(t,i){this.j>=t||(this.O?1===this.j&&this.I(2):this.I(t),this.j=t,2===t?this.S.push(i):this.P())},t.t=function(){var t=this;if((5!==this.j||this.p.some(function(i,n){return i._()!==t.l[n]}))&&(2===this.j&&(this.S.forEach(function(t){t.t()}),this.S=[],2===this.j&&(this.j=1)),1!==this.j)){var i=this.j,n=5===i,r=s(this);this.p=[],this.l=[],this.g=!n,this.j=4;try{var o=this.m();if(this.j=n?5:1,this.O&&0!==i){if(this.O(this.h,o))return;this.I(3)}this.h=o,this.u={}}catch(t){throw this.k(),t}finally{s(r)}}},t.k=function(){this.P(),this.p=[],this.l=[],this.S=[],this.j=0,this.h=void 0},t._=function(){return this.t(),this.u},t.B=function(t){if(void 0===t&&(t=n),4===this.j)throw new Error("Recursive computed call");return this.t(),t?(5===this.j&&this.D(),t.R(this)):this.M(),this.h},t.F=function(){var t=this;this.p.forEach(function(i){i.T(t)})},t.P=function(){var t=this;this.p.forEach(function(i){i.A(t)})},t.I=function(t){var i=this;this.v.forEach(function(n){n.C(t,i)})},t.q=function(){this.P(),this.j=5},t.D=function(){this.F(),this.j=1},Computed}(),Observable=/*#__PURE__*/function(){function Observable(t,i){this.u={},this.v=new Set,this.h=t,this.O=i?"function"==typeof i?y(i):b:void 0}var t=Observable.prototype;return t.T=function(t){return!this.v.has(t)&&(this.v.add(t),!0)},t.A=function(t){this.v.delete(t)},t._=function(){return this.u},t.B=function(t){return void 0===t&&(t=n),t&&t.R(this),this.h},t.G=function(t,i){if(n&&n instanceof Computed)throw new Error("Changing observable inside of computed");if(arguments.length>0){if("function"!=typeof t||i||(t=t(this.h)),this.O&&this.O(this.h,t))return;this.h=t,this.u={}}this.H()},t.H=function(){var t=this;this.v.forEach(function(i){return i.C(3,t)}),!l&&v()},Observable}(),Reaction=/*#__PURE__*/function(){function Reaction(t,i){var n=this;this.m=void 0,this.J=void 0,this.p=[],this.K=null,this.j=1,this.L=function(){n.K=n.m()},this.m=t,this.J=i}var t=Reaction.prototype;return t.R=function(t){t.T(this)&&this.p.push(t)},t.C=function(t,i){2===t?h.add(i):1===this.j&&(this.j=3,u.push(this))},t.F=function(){var t=this;this.p.forEach(function(i){i.T(t)})},t.P=function(){var t=this;this.p.forEach(function(i){i.A(t)})},t.N=function(){this.P(),this.p=[],this.K&&this.K(),this.K=null,this.j=1},t.i=function(){6!==this.j&&(this.J?this.J():this.U())},t.k=function(){this.N(),this.j=6},t.U=function(){this.N(),d(this.L,this)},Reaction}(),S=new Set,j=new Set,g=null,m="undefined"!=typeof window,x=[],O=function(){};t.action=function(t){return function(){var i=s(null);++l;try{return t.apply(this,arguments)}finally{s(i),--l||v()}}},t.computed=function(t,i){var n=new Computed(t,i),s=n.B.bind(n);return s.$$computed=n,s.destroy=n.k.bind(n),s},t.configure=function(t){void 0!==t.reactionScheduler&&(e=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(c=t.reactionExceptionHandler)},t.observable=function(t,i){var n=new Observable(t,i),s=n.B.bind(n),r=n.G.bind(n);return s.$$observable=n,[s,r]},t.reaction=function(t,i){var n=new Reaction(t,i),s=n.k.bind(n);return s.run=n.U.bind(n),n.U(),s},t.shallowEquals=b,t.tx=function(t){++l;try{t()}finally{--l||v()}},t.untracked=y,t.useObserver=function(){if(m){var t=i.useMemo(function(){var t={},i=new Set,n=!1,s=new Reaction(O,function(){t={},i.forEach(function(t){t()})});return function(t){S.add(t),g||(g=setTimeout(function(){g=null;var t=j;j=S,S=new Set,t.forEach(function(t){t.P()})},5e3))}(s),{F:function(t){return function(t){S.delete(t),j.delete(t)}(s),n&&!i.size&&(s.F(),n=!1),i.add(t),function(){i.delete(t),i.size||(n=!0,s.P())}},_:function(){return t},V:s}},x);i.useSyncExternalStore(t.F,t._);var n=t.V;return n.N(),n}},t.utx=d}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((t||self).onek={},t.react)}(this,function(t,n){var Revision=function(){},i=null;function r(t){var n=i;return i=t,n}var o=100,s=new Set,u=new Set,f=[],e=!1,h=function(t){Promise.resolve().then(t)},c=function(t){console.error("Reaction exception:",t)};function a(){try{for(var t=o;f.length||u.size;){for(u.forEach(function(t){t.t()}),u.clear();f.length&&--t;){var n=f;f=[],n.forEach(function(t){try{t.i()}catch(t){c(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{e=!1,f=[],s.forEach(function(t){t.o()}),s.clear()}}function v(){!e&&(f.length||u.size||s.size)&&(e=!0,h(a))}var l=0;function w(t,n){void 0===n&&(n=null);var i=r(n);++l;try{return t()}finally{r(i),--l||v()}}function d(t){return function(){var n=r(null);try{return t.apply(this,arguments)}finally{r(n)}}}var y=Object.prototype.hasOwnProperty;function p(t){return t.constructor===Object||null===t.constructor}function b(t,n){if(t===n)return!0;if(Array.isArray(t)&&Array.isArray(n)){var i=t.length;if(i!==n.length)return!1;for(;i--;)if(t[i]!==n[i])return!1;return!0}if(t&&n&&"object"==typeof t&&"object"==typeof n&&p(t)&&p(n)){var r=Object.keys(t),o=r.length;if(Object.keys(n).length!==o)return!1;for(;o-- >0;){var s=r[o];if(!y.call(n,s)||t[s]!==n[s])return!1}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var u=!0;return t.forEach(function(t){n.has(t)||(u=!1)}),u}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var f=!0;return t.forEach(function(t,i){n.get(i)!==t&&(f=!1)}),f}return!1}var Computed=/*#__PURE__*/function(){function Computed(t,n){this.u=void 0,this.h=new Revision,this.v=new Set,this.l=new Map,this.p=[],this.j=0,this.S=!0,this.g=t,this.m=n?"function"==typeof n?d(n):b:void 0}var t=Computed.prototype;return t.addSubscription=function(t){this.S&&t.M(this),this.l.set(t,t.revision())},t.M=function(t){this.v.add(t),5===this.j&&this.O()},t.R=function(t){this.v.delete(t),this._()},t.o=function(){this.v.size||5===this.j||this.A()},t.T=function(t,n){this.j>=t||(this.m?1===this.j&&this.q(2):this.q(t),this.j=t,2===t?this.p.push(n):this.B())},t.t=function(t){if(void 0===t&&(t=!1),5===this.j){var n=!1;if(this.l.forEach(function(t,i){n||(n=i.revision()!==t)}),!n)return}if(2===this.j&&(this.p.forEach(function(n){n.t(t)}),this.p=[],2===this.j&&(this.j=1)),1!==this.j){var i=this.j,o=0!==i;this.S=t||o&&5!==i,this.l.clear(),this.j=4;var s=r(this);try{var u=this.g();if(this.j=this.S?1:5,this.m&&o){if(this.m(this.u,u))return;this.q(3)}this.u=u,this.h=new Revision}catch(t){throw this.destroy(),t}finally{r(s)}}},t.revision=function(){return this.t(),this.h},t.destroy=function(){this.B(),this.l.clear(),this.p=[],this.j=0,this.u=void 0},t.get=function(t){if(void 0===t&&(t=i),4===this.j)throw new Error("Recursive computed call");var n=!!t;return this.t(n),n&&t.addSubscription(this),this.u},t._=function(){this.v.size||5===this.j||function(t){s.add(t)}(this)},t.C=function(){var t=this;this.l.forEach(function(n,i){i.M(t)})},t.B=function(){var t=this;this.l.forEach(function(n,i){i.R(t)})},t.q=function(t){var n=this;this.v.forEach(function(i){i.T(t,n)})},t.A=function(){this.B(),this.j=5},t.O=function(){this.C(),this.j=1},Computed}();function j(t,n){var i=new Computed(t,n),r=i.get.bind(i);return r.instance=i,r.destroy=i.destroy.bind(i),r}j.box=function(t,n){return new Computed(t,n)},j.prop=function(t,n){return new Computed(t,n)};var Observable=/*#__PURE__*/function(){function Observable(t,n){this.h=new Revision,this.v=new Set,this.u=t,this.m=n?"function"==typeof n?d(n):b:void 0}var t=Observable.prototype;return t.M=function(t){this.v.add(t)},t.R=function(t){this.v.delete(t)},t.revision=function(){return this.h},t.get=function(t){return void 0===t&&(t=i),t&&t.addSubscription(this),this.u},t.set=function(t,n){if(i&&i instanceof Computed)throw new Error("Changing observable inside of computed");if(arguments.length>0){if("function"!=typeof t||n||(t=t(this.u)),this.m&&this.m(this.u,t))return;this.u=t,this.h=new Revision}this.notify()},t.notify=function(){var t=this;this.v.forEach(function(n){return n.T(3,t)}),!l&&v()},Observable}();function S(t,n){var i=new Observable(t,n),r=i.get.bind(i),o=i.set.bind(i);return r.instance=i,[r,o]}S.box=function(t,n){return new Observable(t,n)},S.prop=function(t,n){return new Observable(t,n)};var Reaction=/*#__PURE__*/function(){function Reaction(t,n){var i=this;this.g=void 0,this.I=void 0,this.S=!0,this.l=new Map,this.P=null,this.j=1,this.k=function(){i.P=i.g()},this.g=t,this.I=n}var t=Reaction.prototype;return t.addSubscription=function(t){this.S&&t.M(this),this.l.set(t,t.revision())},t.T=function(t,n){2===t?function(t){u.add(t)}(n):1===this.j&&(this.j=3,f.push(this))},t.C=function(){var t=this;this.l.forEach(function(n,i){i.M(t)})},t.B=function(){var t=this;this.l.forEach(function(n,i){i.R(t)})},t.D=function(){this.B(),this.l.clear(),this.P&&this.P(),this.P=null,this.j=1},t.i=function(){6!==this.j&&(this.I?this.I():this.run())},t.F=function(){var t=!1;return this.l.forEach(function(n,i){t||(t=i.revision()!==n)}),t},t.destroy=function(){this.D(),this.j=6},t.run=function(){this.D(),w(this.k,this)},Reaction}(),g="undefined"!=typeof window,m=[],x=function(){},M=function(t){return t()};M.addSubscription=x,t.Computed=Computed,t.Observable=Observable,t.Reaction=Reaction,t.Revision=Revision,t.action=function(t){return function(){var n=r(null);++l;try{return t.apply(this,arguments)}finally{r(n),--l||v()}}},t.computed=j,t.configure=function(t){void 0!==t.reactionScheduler&&(h=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(c=t.reactionExceptionHandler)},t.observable=S,t.reaction=function(t,n){var i=new Reaction(t,n),r=i.destroy.bind(i);return r.run=i.run.bind(i),i.run(),r},t.setSubscriber=r,t.shallowEquals=b,t.tx=function(t){++l;try{t()}finally{--l||v()}},t.useObserver=function(){if(!g)return M;var t=n.useMemo(function(){var t=new Revision,n=new Set,i=new Reaction(x,function(){t=new Revision,n.forEach(function(t){t()})});i.S=!1;var o=function(t){var n=r(i);try{return t()}finally{r(n)}};return o.addSubscription=i.addSubscription.bind(i),{C:function(t){return n.add(t),i.S=!0,i.C(),i.F()&&t(),function(){n.delete(t),n.size||(i.B(),i.S=!1)}},G:function(){return t},H:function(){i.D()},J:o}},m);return n.useSyncExternalStore(t.C,t.G),t.H(),t.J},t.utx=w,t.withUntracked=d}); | ||
//# sourceMappingURL=onek.umd.js.map |
{ | ||
"version": "0.0.13", | ||
"name": "onek", | ||
"version": "0.1.0", | ||
"description": "⚡️1.7KB full-featured state management inspired by MobX and Solid, batteries included ⚡️", | ||
@@ -8,6 +9,6 @@ "repository": { | ||
}, | ||
"main": "./dist/onek.js", | ||
"main": "dist/onek.js", | ||
"source": "src/index.ts", | ||
"umd:main": "./dist/onek.umd.js", | ||
"module": "./dist/onek.module.js", | ||
"module": "dist/onek.module.js", | ||
"unpkg": "./dist/onek.umd.js", | ||
@@ -23,18 +24,49 @@ "types": "./types/index.d.ts", | ||
}, | ||
"./src": "./src/index.ts", | ||
"./src/core": "./src/core/index.ts", | ||
"./src/core/classes": "./src/core/classes/index.ts", | ||
"./src/react/abandonedRendererCleanup": "./src/react/abandonedRendererCleanup.ts" | ||
"./compat": { | ||
"types": "./compat/types/index.d.ts", | ||
"browser": "./compat/dist/index.module.js", | ||
"umd": "./compat/dist/index.umd.js", | ||
"import": "./compat/dist/index.mjs", | ||
"require": "./compat/dist/index.js" | ||
}, | ||
"./mobx": { | ||
"types": "./mobx/types/index.d.ts", | ||
"browser": "./mobx/dist/index.module.js", | ||
"umd": "./mobx/dist/index.umd.js", | ||
"import": "./mobx/dist/index.mjs", | ||
"require": "./mobx/dist/index.js" | ||
} | ||
}, | ||
"packageManager": "yarn@3.5.0", | ||
"scripts": { | ||
"publish": "yarn run build && npm publish", | ||
"build": "yarn exec microbundle --generateTypes=false", | ||
"build:full": "yarn exec microbundle --generateTypes=false --no-compress", | ||
"build:types": "yarn exec tsc -p ./types.tsconfig.json", | ||
"test": "yarn exec jest" | ||
"build": "yarn run build:onek && yarn run build:compat && yarn run build:mobx", | ||
"build:full": "yarn run build:onek --no-compress && yarn run build:compat --no-compress && yarn run build:mobx --no-compress", | ||
"build:onek": "yarn exec microbundle", | ||
"build:compat": "cd ./compat && yarn exec microbundle --external='onek'", | ||
"build:mobx": "cd ./mobx && yarn exec microbundle --external='onek'", | ||
"test": "node --expose-gc $(yarn bin jest)" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.4.0", | ||
"@types/node": "^20.1.0", | ||
"@types/react": ">=18.0.0", | ||
"jest": "^29.0.3", | ||
"microbundle": "^0.15.1", | ||
"react": ">=18.0.0", | ||
"ts-jest": "^29.0.5", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.0" | ||
}, | ||
"files": [ | ||
"dist/", | ||
"types/", | ||
"compat/dist", | ||
"compat/types", | ||
"compat/package.json", | ||
"mobx/dist", | ||
"mobx/types", | ||
"mobx/package.json", | ||
"LICENSE", | ||
@@ -89,13 +121,7 @@ "README.md", | ||
"Computed", | ||
"Reaction" | ||
"Reaction", | ||
"Revision" | ||
] | ||
} | ||
}, | ||
"name": "onek", | ||
"peerDependencies": { | ||
"react": ">=18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": ">=18.0.0" | ||
} | ||
} | ||
} |
@@ -650,2 +650,4 @@ <p align="center"> | ||
### Optimizing React re-renders with check flag | ||
### Reaction scheduler | ||
@@ -652,0 +654,0 @@ |
@@ -1,198 +0,3 @@ | ||
declare module "core/constants" { | ||
export const enum State { | ||
NOT_INITIALIZED = 0, | ||
CLEAN = 1, | ||
MAYBE_DIRTY = 2, | ||
DIRTY = 3, | ||
COMPUTING = 4, | ||
PASSIVE = 5, | ||
DESTROYED = 6 | ||
} | ||
export const MAX_REACTION_ITERATIONS = 100; | ||
} | ||
declare module "core/types" { | ||
import { State } from "core/constants"; | ||
export type Subscriber = ComputedImpl | ReactionImpl; | ||
export type Subscription = ObservableImpl | ComputedImpl; | ||
export type Revision = {}; | ||
export class ObservableImpl<T = any> { | ||
constructor(value: T, checkFn?: boolean | CheckFn<T>); | ||
_addSubscriber(subscriber: Subscriber): boolean; | ||
_removeSubscriber(subscriber: Subscriber): void; | ||
_getRevision(): Revision; | ||
_getValue(_subscriber?: Subscriber): T; | ||
_setValue(newValue?: T | UpdaterFn<T>, asIs?: boolean): void; | ||
} | ||
export class ComputedImpl<T = any> { | ||
constructor(fn: () => T, checkFn?: boolean | CheckFn<T>); | ||
_addSubscription(subscription: Subscription): void; | ||
_addSubscriber(subscriber: Subscriber): boolean; | ||
_removeSubscriber(subscriber: Subscriber): void; | ||
_checkSubscribersAndPassivate(): void; | ||
_notify(state: State, subscription: Subscription): void; | ||
_actualizeAndRecompute(): void; | ||
_destroy(): void; | ||
_getRevision(): Revision; | ||
_getValue(_subscriber?: Subscriber): T; | ||
} | ||
export type Destructor = (() => void) | null | undefined | void; | ||
export type ReactionFn = () => Destructor; | ||
export type Disposer = (() => void) & { | ||
run: () => void; | ||
}; | ||
export class ReactionImpl { | ||
constructor(fn: ReactionFn, manager?: () => void); | ||
_addSubscription(subscription: Subscription): void; | ||
_notify(state: State, subscription: Subscription): void; | ||
_subscribe(): void; | ||
_unsubscribe(): void; | ||
_runManager(): void; | ||
_destroy(): void; | ||
_run(): void; | ||
} | ||
export type CheckFn<T> = (prev: T, next: T) => boolean; | ||
export type UpdaterFn<T> = (prevValue: T) => T; | ||
export interface Getter<T> { | ||
(subscriber?: Subscriber): T; | ||
} | ||
export interface Setter<T> { | ||
(value?: T | UpdaterFn<T>, asIs?: boolean): void; | ||
} | ||
export interface ObservableGetter<T> extends Getter<T> { | ||
$$observable: ObservableImpl<T>; | ||
} | ||
export interface ComputedGetter<T> extends Getter<T> { | ||
$$computed: ComputedImpl<T>; | ||
destroy(): void; | ||
} | ||
export type Options = { | ||
reactionScheduler?: (runner: () => void) => void; | ||
reactionExceptionHandler?: (exception: Error) => void; | ||
}; | ||
} | ||
declare module "core/subscriber" { | ||
import type { Subscriber } from "core/types"; | ||
export let subscriber: Subscriber | null; | ||
export function setSubscriber(newSubscriber: Subscriber | null): Subscriber | null; | ||
} | ||
declare module "core/schedulers/reaction" { | ||
import { Computed, Reaction } from "core/classes/index"; | ||
import { Options } from "core/types"; | ||
export function configure(options: Options): void; | ||
export function scheduleReaction(reaction: Reaction): void; | ||
export function scheduleStateActualization(computed: Computed): void; | ||
export function scheduleSubscribersCheck(computed: Computed): void; | ||
export function scheduleReactionRunner(): void; | ||
} | ||
declare module "core/transaction" { | ||
import { Subscriber } from "core/types"; | ||
export let txDepth: number; | ||
export function tx(fn: () => void): void; | ||
export function utx<T>(fn: () => T, subscriber?: Subscriber | null): T; | ||
export function untracked<Args extends any[], T>(fn: (...args: Args) => T): (...args: Args) => T; | ||
export function action<Args extends any[], T>(fn: (...args: Args) => T): (...args: Args) => T; | ||
} | ||
declare module "core/utils/shallowEquals" { | ||
export function shallowEquals<T>(prev: T, next: T): boolean; | ||
} | ||
declare module "core/classes/computed" { | ||
import { CheckFn, ComputedGetter, ComputedImpl, Revision, Subscriber, Subscription } from "core/types"; | ||
import { State } from "core/constants"; | ||
export type ComputedState = State.NOT_INITIALIZED | State.CLEAN | State.MAYBE_DIRTY | State.DIRTY | State.COMPUTING | State.PASSIVE; | ||
export class Computed<T = any> implements ComputedImpl<T> { | ||
private _value; | ||
private _revision; | ||
private _subscribers; | ||
private _revisions; | ||
private _subscriptions; | ||
private _subscriptionsToActualize; | ||
private _state; | ||
private _shouldSubscribe; | ||
private readonly _fn; | ||
private readonly _checkFn?; | ||
constructor(fn: () => T, checkFn?: boolean | CheckFn<T>); | ||
_addSubscription(subscription: Subscription): void; | ||
_addSubscriber(subscriber: Subscriber): boolean; | ||
_removeSubscriber(subscriber: Subscriber): void; | ||
_checkSubscribers(): void; | ||
_checkSubscribersAndPassivate(): void; | ||
_notify(state: State, subscription: Subscription): void; | ||
_actualizeAndRecompute(): void; | ||
_destroy(): void; | ||
_getRevision(): Revision; | ||
_getValue(_subscriber?: Subscriber | null): T; | ||
private _subscribe; | ||
private _unsubscribe; | ||
private _notifySubscribers; | ||
private _passivate; | ||
private _resurrect; | ||
} | ||
export function computed<T>(fn: () => T, checkFn?: boolean | CheckFn<T>): ComputedGetter<T>; | ||
} | ||
declare module "core/classes/observable" { | ||
import { CheckFn, ObservableGetter, ObservableImpl, Revision, Setter, Subscriber, UpdaterFn } from "core/types"; | ||
export class Observable<T = any> implements ObservableImpl<T> { | ||
private _revision; | ||
private _subscribers; | ||
private _value; | ||
private readonly _checkFn?; | ||
constructor(value: T, checkFn?: boolean | CheckFn<T>); | ||
_addSubscriber(subscriber: Subscriber): boolean; | ||
_removeSubscriber(subscriber: Subscriber): void; | ||
_getRevision(): Revision; | ||
_getValue(_subscriber?: Subscriber | null): T; | ||
_setValue(newValue?: T | UpdaterFn<T>, asIs?: boolean): void; | ||
private _notifyChanged; | ||
} | ||
export function observable<T>(value: T, checkFn?: boolean | CheckFn<T>): readonly [ObservableGetter<T>, Setter<T>]; | ||
} | ||
declare module "core/classes/reaction" { | ||
import { Disposer, ReactionFn, ReactionImpl, Subscription } from "core/types"; | ||
import { State } from "core/constants"; | ||
export type ReactionState = State.CLEAN | State.DIRTY | State.DESTROYED; | ||
export class Reaction implements ReactionImpl { | ||
private _fn; | ||
private _manager?; | ||
private _subscriptions; | ||
private _destructor; | ||
private _state; | ||
private _runnerFn; | ||
constructor(_fn: ReactionFn, _manager?: (() => void) | undefined); | ||
_addSubscription(subscription: Subscription): void; | ||
_notify(state: State, subscription: Subscription): void; | ||
_subscribe(): void; | ||
_unsubscribe(): void; | ||
_unsubscribeAndRemove(): void; | ||
_runManager(): void; | ||
_destroy(): void; | ||
_run(): void; | ||
} | ||
export function reaction(fn: ReactionFn, manager?: () => void): Disposer; | ||
} | ||
declare module "core/classes/index" { | ||
export { Observable, observable } from "core/classes/observable"; | ||
export { Computed, computed } from "core/classes/computed"; | ||
export { Reaction, reaction } from "core/classes/reaction"; | ||
} | ||
declare module "core/index" { | ||
export { observable, computed, reaction } from "core/classes/index"; | ||
export { configure } from "core/schedulers/reaction"; | ||
export { tx, utx, untracked, action } from "core/transaction"; | ||
export type { CheckFn, UpdaterFn, Getter, ObservableGetter, ComputedGetter, Setter, Disposer, } from "core/types"; | ||
export { Options } from "core/types"; | ||
export { shallowEquals } from "core/utils/shallowEquals"; | ||
} | ||
declare module "react/abandonedRendererCleanup" { | ||
import { Reaction } from "core/classes/index"; | ||
export function addAbandonedRenderCleanup(reaction: Reaction): void; | ||
export function removeAbandonedRenderCleanup(reaction: Reaction): void; | ||
} | ||
declare module "react/useObserver" { | ||
import { Reaction } from "core/classes/index"; | ||
export type Observer = Reaction | undefined; | ||
export function useObserver(): Observer; | ||
} | ||
declare module "index" { | ||
export * from "core/index"; | ||
export { useObserver, Observer } from "react/useObserver"; | ||
} | ||
export type { IGettable, IObservable, IComputed, IReaction, IRevision, CheckFn, UpdaterFn, IGetter, IObservableGetter, IComputedGetter, ISetter, IOptions, Disposer, SubscriberBase, } from "./core/types"; | ||
export { observable, Observable, computed, Computed, reaction, Reaction, Revision, tx, utx, withUntracked, action, configure, shallowEquals, setSubscriber, } from "./core"; | ||
export { useObserver, IObserver } from "./react"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
191537
32
299
810
9