Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

onek

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onek - npm Package Compare versions

Comparing version 0.1.2 to 0.1.4

types/core/classes/common.d.ts

2

dist/onek.js

@@ -1,2 +0,2 @@

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;
var t=require("react"),n=null;function i(t){var i=n;return n=t,i}var r=100,o=new Set,s=new Set,u=[],f=!1,e=function(t){Promise.resolve().then(t,h)},h=function(t){console.error("Reaction exception:",t)};function c(){try{for(var t=r;u.length||s.size;){for(s.forEach(function(t){t.t()}),s.clear();u.length&&--t;){var n=u;u=[],n.forEach(function(t){try{t.i()}catch(t){h(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{f=!1,u=[],o.forEach(function(t){t.o()}),o.clear()}}var a=0;function v(t,n){void 0===n&&(n=null);var r=i(n);a+=1;try{return t()}finally{a-=1,i(r),p()}}function l(t){return function(){var n=i(null);try{return t.apply(this,arguments)}finally{i(n)}}}function p(){a||!f&&(u.length||s.size||o.size)&&(f=!0,e(c))}var w=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),o=r.length;if(Object.keys(n).length!==o)return!1;for(;o-- >0;){var s=r[o];if(!w.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 x=l(d),Revision=function(){};function b(t){var n=!1;return t.forEach(function(t,i){n||(n=i.revision()!==t)}),n}function S(t,n){t.forEach(function(t,i){i.u(n)})}function j(t,n){t.forEach(function(t,i){i.h(n)})}function M(t,n,i){t.forEach(function(t){t.v(n,i)})}var Computed=/*#__PURE__*/function(){function Computed(t,n){this.l=void 0,this.p=new Revision,this.S=new Set,this.j=new Map,this.M=0,this.O=t,this.R=n?"function"==typeof n?l(n):x:void 0}var t=Computed.prototype;return t.addSubscription=function(t){2!==this.M&&t.h(this),this.j.set(t,t.revision())},t.h=function(t){this.S.add(t),6===this.M&&this._()},t.u=function(t){this.S.delete(t),this.g()},t.o=function(){this.S.size||6===this.M||this.m()},t.v=function(t,n){var i=this.M;i!==t&&(this.R?3===i&&this.A(4):this.A(t),this.M=t,5===t&&this.q())},t.t=function(t){if(void 0===t&&(t=!1),(6!==this.M||b(this.j))&&(4===this.M&&(this.j.forEach(function(n,i){i.t(t)}),4===this.M&&(this.M=3)),3!==this.M)){var n=this.M,r=0!==n,o=t||r&&6!==n;this.j.clear(),this.M=o?1:2;var s=i(this);try{var u=this.O();if(this.M=o?3:6,this.R&&r){if(this.R(this.l,u))return;this.A(5)}this.l=u,this.p=new Revision}catch(t){throw this.destroy(),t}finally{i(s)}}},t.revision=function(){return this.t(),this.p},t.destroy=function(){this.q(),this.j.clear(),this.M=0,this.l=void 0},t.get=function(t){if(void 0===t&&(t=n),1===this.M||2===this.M)throw new Error("Recursive computed call");var i=!!t;return this.t(i),i&&t.addSubscription(this),this.l},t.g=function(){this.S.size||6===this.M||function(t){o.add(t)}(this)},t.B=function(){j(this.j,this)},t.q=function(){S(this.j,this)},t.A=function(t){M(this.S,t,this)},t.m=function(){this.q(),this.M=6},t._=function(){this.B(),this.M=3},Computed}();function O(t,n){var i=new Computed(t,n),r=i.get.bind(i);return r.instance=i,r.destroy=i.destroy.bind(i),r.revision=i.revision.bind(i),r}O.box=function(t,n){return new Computed(t,n)},O.prop=function(t,n){return new Computed(t,n)};var Observable=/*#__PURE__*/function(){function Observable(t,n){this.p=new Revision,this.S=new Set,this.l=t,this.R=n?"function"==typeof n?l(n):x:void 0}var t=Observable.prototype;return t.h=function(t){this.S.add(t)},t.u=function(t){this.S.delete(t)},t.t=function(){},t.revision=function(){return this.p},t.get=function(t){return void 0===t&&(t=n),t&&t.addSubscription(this),this.l},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.l)),this.R&&this.R(this.l,t))return;this.l=t}this.notify()},t.notify=function(){this.p=new Revision,M(this.S,5,this),p()},Observable}();function R(t,n){var i=new Observable(t,n),r=i.get.bind(i),o=i.set.bind(i);return r.instance=i,r.revision=i.revision.bind(i),[r,o]}R.box=function(t,n){return new Observable(t,n)},R.prop=function(t,n){return new Observable(t,n)};var Reaction=/*#__PURE__*/function(){function Reaction(t,n){var i=this;this.O=void 0,this.C=void 0,this.shouldSubscribe=!0,this.j=new Map,this.I=null,this.M=2,this.P=function(){i.I=i.O()},this.O=t,this.C=n}var t=Reaction.prototype;return t.addSubscription=function(t){this.shouldSubscribe&&t.h(this),this.j.set(t,t.revision())},t.v=function(t,n){3===t?function(t){s.add(t)}(n):2===this.M&&(this.M=4,u.push(this))},t.i=function(){6!==this.M&&(this.C?this.C():this.run())},t.subscribe=function(){j(this.j,this)},t.unsubscribe=function(){S(this.j,this)},t.unsubscribeAndCleanup=function(){this.unsubscribe(),this.j.clear(),this.I&&this.I(),this.I=null,this.M=2},t.missedRun=function(){return b(this.j)},t.destroy=function(){this.unsubscribeAndCleanup(),this.M=6},t.run=function(){this.unsubscribeAndCleanup(),v(this.P,this)},Reaction}(),_="undefined"!=typeof window,g=[],m=function(){},E=function(t){return t()};E.addSubscription=m,exports.Computed=Computed,exports.Observable=Observable,exports.Reaction=Reaction,exports.Revision=Revision,exports.action=function(t){return function(){var n=i(null);a+=1;try{return t.apply(this,arguments)}finally{a-=1,i(n),p()}}},exports.computed=O,exports.configure=function(t){void 0!==t.reactionScheduler&&(e=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(h=t.reactionExceptionHandler)},exports.observable=R,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){a+=1;try{t()}finally{a-=1,p()}},exports.untracked=function(t){var n=i(null);try{return t()}finally{i(n)}},exports.useObserver=function(){if(!_)return E;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.shouldSubscribe=!1;var o=function(t){var n=i(r);try{return t()}finally{i(n)}};return o.addSubscription=r.addSubscription.bind(r),{B:function(t){return n.add(t),r.shouldSubscribe=!0,r.subscribe(),r.missedRun()&&t(),function(){n.delete(t),n.size||(r.unsubscribe(),r.shouldSubscribe=!1)}},k:function(){return t},D:function(){r.unsubscribeAndCleanup()},F:o}},g);return t.useSyncExternalStore(n.B,n.k),n.D(),n.F},exports.utx=v,exports.withUntracked=l;
//# sourceMappingURL=onek.js.map

@@ -1,2 +0,2 @@

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};
import{useMemo as t,useSyncExternalStore as n}from"react";var i=null;function r(t){var n=i;return i=t,n}var u=100,o=new Set,f=new Set,s=[],h=!1,e=function(t){Promise.resolve().then(t,c)},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;s.length||f.size;){for(f.forEach(function(t){t.t()}),f.clear();s.length&&--t;){var n=s;s=[],n.forEach(function(t){try{t.i()}catch(t){c(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{h=!1,s=[],o.forEach(function(t){t.u()}),o.clear()}}var l=0;function w(t){l+=1;try{t()}finally{l-=1,S()}}function y(t,n){void 0===n&&(n=null);var i=r(n);l+=1;try{return t()}finally{l-=1,r(i),S()}}function d(t){var n=r(null);try{return t()}finally{r(n)}}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);l+=1;try{return t.apply(this,arguments)}finally{l-=1,r(n),S()}}}function S(){l||!h&&(s.length||f.size||o.size)&&(h=!0,e(v))}var j=Object.prototype.hasOwnProperty;function m(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&&m(t)&&m(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(!j.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 f=!0;return t.forEach(function(t){n.has(t)||(f=!1)}),f}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var s=!0;return t.forEach(function(t,i){n.get(i)!==t&&(s=!1)}),s}return!1}var O=p(M),Revision=function(){};function R(t){var n=!1;return t.forEach(function(t,i){n||(n=i.revision()!==t)}),n}function _(t,n){t.forEach(function(t,i){i.o(n)})}function g(t,n){t.forEach(function(t,i){i.h(n)})}function E(t,n,i){t.forEach(function(t){t.v(n,i)})}var Computed=/*#__PURE__*/function(){function Computed(t,n){this.l=void 0,this.p=new Revision,this.S=new Set,this.j=new Map,this.m=0,this.M=t,this.O=n?"function"==typeof n?p(n):O:void 0}var t=Computed.prototype;return t.addSubscription=function(t){2!==this.m&&t.h(this),this.j.set(t,t.revision())},t.h=function(t){this.S.add(t),6===this.m&&this.R()},t.o=function(t){this.S.delete(t),this._()},t.u=function(){this.S.size||6===this.m||this.g()},t.v=function(t,n){var i=this.m;i!==t&&(this.O?3===i&&this.A(4):this.A(t),this.m=t,5===t&&this.B())},t.t=function(t){if(void 0===t&&(t=!1),(6!==this.m||R(this.j))&&(4===this.m&&(this.j.forEach(function(n,i){i.t(t)}),4===this.m&&(this.m=3)),3!==this.m)){var n=this.m,i=0!==n,u=t||i&&6!==n;this.j.clear(),this.m=u?1:2;var o=r(this);try{var f=this.M();if(this.m=u?3:6,this.O&&i){if(this.O(this.l,f))return;this.A(5)}this.l=f,this.p=new Revision}catch(t){throw this.destroy(),t}finally{r(o)}}},t.revision=function(){return this.t(),this.p},t.destroy=function(){this.B(),this.j.clear(),this.m=0,this.l=void 0},t.get=function(t){if(void 0===t&&(t=i),1===this.m||2===this.m)throw new Error("Recursive computed call");var n=!!t;return this.t(n),n&&t.addSubscription(this),this.l},t._=function(){this.S.size||6===this.m||function(t){o.add(t)}(this)},t.C=function(){g(this.j,this)},t.B=function(){_(this.j,this)},t.A=function(t){E(this.S,t,this)},t.g=function(){this.B(),this.m=6},t.R=function(){this.C(),this.m=3},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.revision=i.revision.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.p=new Revision,this.S=new Set,this.l=t,this.O=n?"function"==typeof n?p(n):O:void 0}var t=Observable.prototype;return t.h=function(t){this.S.add(t)},t.o=function(t){this.S.delete(t)},t.t=function(){},t.revision=function(){return this.p},t.get=function(t){return void 0===t&&(t=i),t&&t.addSubscription(this),this.l},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.l)),this.O&&this.O(this.l,t))return;this.l=t}this.notify()},t.notify=function(){this.p=new Revision,E(this.S,5,this),S()},Observable}();function A(t,n){var i=new Observable(t,n),r=i.get.bind(i),u=i.set.bind(i);return r.instance=i,r.revision=i.revision.bind(i),[r,u]}A.box=function(t,n){return new Observable(t,n)},A.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.I=void 0,this.shouldSubscribe=!0,this.j=new Map,this.P=null,this.m=3,this.k=function(){i.P=i.M()},this.M=t,this.I=n}var t=Reaction.prototype;return t.addSubscription=function(t){this.shouldSubscribe&&t.h(this),this.j.set(t,t.revision())},t.v=function(t,n){4===t?function(t){f.add(t)}(n):3===this.m&&(this.m=5,function(t){s.push(t)}(this))},t.i=function(){7!==this.m&&(this.I?this.I():this.run())},t.subscribe=function(){g(this.j,this)},t.unsubscribe=function(){_(this.j,this)},t.unsubscribeAndCleanup=function(){this.unsubscribe(),this.j.clear(),this.P&&this.P(),this.P=null,this.m=3},t.missedRun=function(){return R(this.j)},t.destroy=function(){this.unsubscribeAndCleanup(),this.m=7},t.run=function(){this.unsubscribeAndCleanup(),y(this.k,this)},Reaction}();function B(t,n){var i=new Reaction(t,n),r=i.destroy.bind(i);return r.run=i.run.bind(i),i.run(),r}var C="undefined"!=typeof window,I=[],P=function(){},k=function(t){return t()};function q(){if(!C)return k;var i=t(function(){var t=new Revision,n=new Set,i=new Reaction(P,function(){t=new Revision,n.forEach(function(t){t()})});i.shouldSubscribe=!1;var u=function(t){var n=r(i);try{return t()}finally{r(n)}};return u.addSubscription=i.addSubscription.bind(i),{C:function(t){return n.add(t),i.shouldSubscribe=!0,i.subscribe(),i.missedRun()&&t(),function(){n.delete(t),n.size||(i.unsubscribe(),i.shouldSubscribe=!1)}},q:function(){return t},D:function(){i.unsubscribeAndCleanup()},F:u}},I);return n(i.C,i.q),i.D(),i.F}k.addSubscription=P;export{Computed,Observable,Reaction,Revision,b as action,x as computed,a as configure,A as observable,B as reaction,r as setSubscriber,M as shallowEquals,w as tx,d as untracked,q as useObserver,y as utx,p as withUntracked};
//# sourceMappingURL=onek.module.js.map

@@ -1,2 +0,2 @@

!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});
!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 i=null;function r(t){var n=i;return i=t,n}var o=100,u=new Set,f=new Set,s=[],e=!1,h=function(t){Promise.resolve().then(t,c)},c=function(t){console.error("Reaction exception:",t)};function a(){try{for(var t=o;s.length||f.size;){for(f.forEach(function(t){t.t()}),f.clear();s.length&&--t;){var n=s;s=[],n.forEach(function(t){try{t.i()}catch(t){c(t)}})}if(!t)throw new Error("Infinite reactions loop")}}finally{e=!1,s=[],u.forEach(function(t){t.o()}),u.clear()}}var v=0;function l(t,n){void 0===n&&(n=null);var i=r(n);v+=1;try{return t()}finally{v-=1,r(i),y()}}function w(t){return function(){var n=r(null);try{return t.apply(this,arguments)}finally{r(n)}}}function y(){v||!e&&(s.length||f.size||u.size)&&(e=!0,h(a))}var d=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 u=r[o];if(!d.call(n,u)||t[u]!==n[u])return!1}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var f=!0;return t.forEach(function(t){n.has(t)||(f=!1)}),f}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var s=!0;return t.forEach(function(t,i){n.get(i)!==t&&(s=!1)}),s}return!1}var j=w(b),Revision=function(){};function S(t){var n=!1;return t.forEach(function(t,i){n||(n=i.revision()!==t)}),n}function g(t,n){t.forEach(function(t,i){i.u(n)})}function m(t,n){t.forEach(function(t,i){i.h(n)})}function x(t,n,i){t.forEach(function(t){t.v(n,i)})}var Computed=/*#__PURE__*/function(){function Computed(t,n){this.l=void 0,this.p=new Revision,this.j=new Set,this.S=new Map,this.g=0,this.m=t,this.M=n?"function"==typeof n?w(n):j:void 0}var t=Computed.prototype;return t.addSubscription=function(t){2!==this.g&&t.h(this),this.S.set(t,t.revision())},t.h=function(t){this.j.add(t),6===this.g&&this.O()},t.u=function(t){this.j.delete(t),this.R()},t.o=function(){this.j.size||6===this.g||this._()},t.v=function(t,n){var i=this.g;i!==t&&(this.M?3===i&&this.A(4):this.A(t),this.g=t,5===t&&this.T())},t.t=function(t){if(void 0===t&&(t=!1),(6!==this.g||S(this.S))&&(4===this.g&&(this.S.forEach(function(n,i){i.t(t)}),4===this.g&&(this.g=3)),3!==this.g)){var n=this.g,i=0!==n,o=t||i&&6!==n;this.S.clear(),this.g=o?1:2;var u=r(this);try{var f=this.m();if(this.g=o?3:6,this.M&&i){if(this.M(this.l,f))return;this.A(5)}this.l=f,this.p=new Revision}catch(t){throw this.destroy(),t}finally{r(u)}}},t.revision=function(){return this.t(),this.p},t.destroy=function(){this.T(),this.S.clear(),this.g=0,this.l=void 0},t.get=function(t){if(void 0===t&&(t=i),1===this.g||2===this.g)throw new Error("Recursive computed call");var n=!!t;return this.t(n),n&&t.addSubscription(this),this.l},t.R=function(){this.j.size||6===this.g||function(t){u.add(t)}(this)},t.q=function(){m(this.S,this)},t.T=function(){g(this.S,this)},t.A=function(t){x(this.j,t,this)},t._=function(){this.T(),this.g=6},t.O=function(){this.q(),this.g=3},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.revision=i.revision.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.p=new Revision,this.j=new Set,this.l=t,this.M=n?"function"==typeof n?w(n):j:void 0}var t=Observable.prototype;return t.h=function(t){this.j.add(t)},t.u=function(t){this.j.delete(t)},t.t=function(){},t.revision=function(){return this.p},t.get=function(t){return void 0===t&&(t=i),t&&t.addSubscription(this),this.l},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.l)),this.M&&this.M(this.l,t))return;this.l=t}this.notify()},t.notify=function(){this.p=new Revision,x(this.j,5,this),y()},Observable}();function O(t,n){var i=new Observable(t,n),r=i.get.bind(i),o=i.set.bind(i);return r.instance=i,r.revision=i.revision.bind(i),[r,o]}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.B=void 0,this.shouldSubscribe=!0,this.S=new Map,this.C=null,this.g=3,this.I=function(){i.C=i.m()},this.m=t,this.B=n}var t=Reaction.prototype;return t.addSubscription=function(t){this.shouldSubscribe&&t.h(this),this.S.set(t,t.revision())},t.v=function(t,n){4===t?function(t){f.add(t)}(n):3===this.g&&(this.g=5,s.push(this))},t.i=function(){7!==this.g&&(this.B?this.B():this.run())},t.subscribe=function(){m(this.S,this)},t.unsubscribe=function(){g(this.S,this)},t.unsubscribeAndCleanup=function(){this.unsubscribe(),this.S.clear(),this.C&&this.C(),this.C=null,this.g=3},t.missedRun=function(){return S(this.S)},t.destroy=function(){this.unsubscribeAndCleanup(),this.g=7},t.run=function(){this.unsubscribeAndCleanup(),l(this.I,this)},Reaction}(),R="undefined"!=typeof window,_=[],E=function(){},A=function(t){return t()};A.addSubscription=E,t.Computed=Computed,t.Observable=Observable,t.Reaction=Reaction,t.Revision=Revision,t.action=function(t){return function(){var n=r(null);v+=1;try{return t.apply(this,arguments)}finally{v-=1,r(n),y()}}},t.computed=M,t.configure=function(t){void 0!==t.reactionScheduler&&(h=t.reactionScheduler),void 0!==t.reactionExceptionHandler&&(c=t.reactionExceptionHandler)},t.observable=O,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){v+=1;try{t()}finally{v-=1,y()}},t.untracked=function(t){var n=r(null);try{return t()}finally{r(n)}},t.useObserver=function(){if(!R)return A;var t=n.useMemo(function(){var t=new Revision,n=new Set,i=new Reaction(E,function(){t=new Revision,n.forEach(function(t){t()})});i.shouldSubscribe=!1;var o=function(t){var n=r(i);try{return t()}finally{r(n)}};return o.addSubscription=i.addSubscription.bind(i),{q:function(t){return n.add(t),i.shouldSubscribe=!0,i.subscribe(),i.missedRun()&&t(),function(){n.delete(t),n.size||(i.unsubscribe(),i.shouldSubscribe=!1)}},P:function(){return t},k:function(){i.unsubscribeAndCleanup()},D:o}},_);return n.useSyncExternalStore(t.q,t.P),t.k(),t.D},t.utx=l,t.withUntracked=w});
//# sourceMappingURL=onek.umd.js.map
{
"name": "onek",
"version": "0.1.2",
"description": "⚡️1.7KB full-featured state management inspired by MobX and Solid, batteries included ⚡️",
"repository": {
"type": "git",
"url": "git+https://github.com/zheksoon/onek.git"
"name": "onek",
"version": "0.1.4",
"description": "⚡️1.8KB full-featured state management inspired by MobX and Solid, batteries included ⚡️",
"repository": {
"type": "git",
"url": "git+https://github.com/zheksoon/onek.git"
},
"main": "dist/onek.js",
"source": "src/index.ts",
"umd:main": "./dist/onek.umd.js",
"module": "dist/onek.module.js",
"unpkg": "./dist/onek.umd.js",
"types": "./types/index.d.ts",
"exports": {
".": {
"types": "./types/index.d.ts",
"browser": "./dist/onek.module.js",
"umd": "./dist/onek.umd.js",
"import": "./dist/onek.mjs",
"require": "./dist/onek.js"
},
"main": "dist/onek.js",
"source": "src/index.ts",
"umd:main": "./dist/onek.umd.js",
"module": "dist/onek.module.js",
"unpkg": "./dist/onek.umd.js",
"types": "./types/index.d.ts",
"exports": {
".": {
"types": "./types/index.d.ts",
"browser": "./dist/onek.module.js",
"umd": "./dist/onek.umd.js",
"import": "./dist/onek.mjs",
"require": "./dist/onek.js"
},
"./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"
}
"./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"
},
"packageManager": "yarn@3.5.0",
"scripts": {
"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",
"README.md",
"package.json"
],
"keywords": [
"state",
"state management",
"reactive",
"observable",
"computed",
"autorun",
"frp",
"functional reactive programming",
"zustand",
"jotai",
"react",
"mobx",
"solid",
"solid.js",
"recoil",
"preact signals",
"valtio",
"unstated",
"1kb",
"tiny",
"small",
"compact",
"lightweight",
"minimal",
"performance",
"typescript",
"hooks",
"shallow equality"
],
"author": "Eugene Daragan",
"license": "MIT",
"bugs": {
"url": "https://github.com/zheksoon/onek/issues"
},
"homepage": "https://github.com/zheksoon/onek#readme",
"minify": {
"mangle": {
"properties": {
"regex": "^_"
},
"keep_classnames": true,
"reserved": [
"Observable",
"Computed",
"Reaction",
"Revision"
]
}
"./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": {
"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": {
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.4.0",
"@types/node": "^20.1.0",
"@types/react": ">=18.0.0",
"@types/react-dom": ">=18.0.0",
"@types/react-test-renderer": "^18.0.0",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.5.0",
"microbundle": "^0.15.1",
"prettier": "^2.8.8",
"react": ">=18.0.0",
"react-dom": ">=18.0.0",
"react-test-renderer": "^18.2.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",
"README.md",
"package.json"
],
"keywords": [
"state",
"state management",
"reactive",
"observable",
"computed",
"autorun",
"frp",
"functional reactive programming",
"zustand",
"jotai",
"react",
"mobx",
"solid",
"solid.js",
"recoil",
"preact signals",
"valtio",
"unstated",
"1kb",
"tiny",
"small",
"compact",
"lightweight",
"minimal",
"performance",
"typescript",
"hooks",
"shallow equality"
],
"author": "Eugene Daragan",
"license": "MIT",
"bugs": {
"url": "https://github.com/zheksoon/onek/issues"
},
"homepage": "https://github.com/zheksoon/onek#readme",
"minify": {
"mangle": {
"properties": {
"regex": "^_"
},
"keep_classnames": true,
"reserved": [
"Observable",
"Computed",
"Reaction",
"Revision"
]
}
}
}

@@ -10,3 +10,3 @@ <p align="center">

<p align="center">
⚡️ <b>1.7KB</b> full-featured state management inspired by MobX and Solid, <b>batteries included</b> ⚡️
⚡️ <b>1.7KB</b> full-featured state management inspired by MobX and Solid.js, <b>batteries included</b> ⚡️
</p>

@@ -16,29 +16,33 @@

<a href="https://www.npmjs.com/package/onek" >
<img src="https://badgen.net/npm/v/onek?color=5fbfcd" alt="onek version"/>
<img src="https://badgen.net/npm/v/onek?color=5fbfcd" alt="Onek version"/>
</a>
<a href="https://bundlephobia.com/package/onek" >
<img src="https://badgen.net/badgesize/brotli/file-url/unpkg.com/onek/dist/onek.mjs?color=5fbfcd" alt="onek brotli size"/>
<img src="https://badgen.net/badgesize/brotli/file-url/unpkg.com/onek/dist/onek.mjs?color=5fbfcd" alt="Onek brotli size"/>
</a>
<a href="https://github.com/zheksoon/onek/blob/main/LICENSE" >
<img src="https://badgen.net/github/license/zheksoon/onek?color=5fbfcd" alt="onek license"/>
<img src="https://badgen.net/github/license/zheksoon/onek?color=5fbfcd" alt="Onek license"/>
</a>
<a href="https://codecov.io/github/zheksoon/onek" >
<img src="https://codecov.io/github/zheksoon/onek/branch/main/graph/badge.svg?token=5ZQAEJ0A9H"/>
</a>
</p>
**Onek** (reads as **_one-kay_** or **_one-key_**) is a simple but powerful state management library for **React** based on solid foundation of functional reactive
data structures from **MobX** and **Solid.js**, providing everything needed for managing state in complex React applications,
all in less than **2KB** package.
**Onek** (reads as **_one-kay_** or **_on-ek_**) is a simple but powerful state management library
for **React** based on a solid foundation of functional reactive data structures from **MobX** and
**Solid.js**, providing everything needed for managing state in complex React applications,
all in a less than **2KB package**.
## Features
- 🚀 **Reactive observable and computed values** - just like MobX, Solid.js or Preact Signals
- 🚀 **Reactive observable and computed values** - just like MobX, Solid.js and Preact Signals
- 🎭 **Both MobX and Solid.js** flavors - choose what you like
- 🤔 **Not opinionated** about the structure of your models
- 👁 **Transparency** - no data glitches guaranteed
- 🔄 **Transactional updates** - no unexpected side-effects
- 🙈 **Laziness** - nothing happens until you need a value
- 💧 **No memory leaks** - optimal computed caching without compromises
- 🧩 **Single hook** - effortless integration with React components
- 🤓 **Built-in shallow equality** - easily optimize re-renders
- 🤔 **Not opinionated** about structure of your models
- 🧩 **Single hook** - effortless integration with React components
- 💾 **Compatibility** - only ES6 `Set` and `Map` are required
- 💯 **100% test coverage** with complex cases
- ⭐️ Written in **100% TypeScript**
- 📦 ...and all in less than **2KB package**
- 📦 ...and all in a less than **2KB package**

@@ -54,2 +58,5 @@ ## Table of contents

- [Reactions](#reactions)
- [Making models](#making-models)
- [Solid.js flavor](#solidjs-flavor)
- [MobX flavor](#mobx-flavor)
- [Examples](#examples)

@@ -75,5 +82,9 @@ - [Counter](#simple-counter)

**Note:** in this section Solid.js flavor will be used. If you want examples for MobX flavor, check
out the [MobX flavor](#mobx-flavor) section.
### Observable values
`observable` is a simple function that accepts initial value and returns a tuple of getter and setter functions - the same convention as `useState` from React:
`observable` is a simple function that accepts an initial value and returns a tuple of getter and
setter functions - the same convention as `useState` from React:

@@ -83,12 +94,9 @@ ```js

// create observable value
const [greeting, setGreeting] = observable("hello!");
greeting() === "hello!";
// set value directly
setGreeting("hola!");
greeting() === "hola!";
// alternative option - updater function
// set value with updater function
setGreeting((oldGreeting) => oldGreeting + "!!!");

@@ -102,3 +110,4 @@

The second argument to `observable` might be equality check function (or `true` for built-in `shallowEquals` implementation):
The second argument to `observable` might be an equality check function (or `true` for the
built-in `shallowEquals` implementation):

@@ -120,3 +129,5 @@ ```js

In order to store a function in observable you need to pass `true` as a second argument to setter function. This argument means the setter should store the first argument as-is, without its interpretation as updater function:
In order to store a function in an observable you need to pass `true` as the second argument to the
setter function. This argument means the setter should store the first argument as-is, without its
interpretation as an updater function:

@@ -133,3 +144,7 @@ ```js

Computed value is like `useMemo` in React - it's cached and returns the cached value afterwards. All accessed `observable` or other `computed` values are automatically tracked, there is no need to specify dependency list. Changes to these tracked values automatically invalidate the cached value, which is recalculated on next access to the `computed`:
A computed value is like `useMemo` in React - it's cached and returns the cached value afterwards.
All accessed `observable` or other `computed` values are automatically tracked, there is no need to
specify a dependency list.
Changes to these tracked values automatically invalidate the cached value, which is recalculated on
next access to the `computed`:

@@ -150,5 +165,6 @@ ```js

<summary><b>Extra:</b> equality check argument</summary>
The second argument to `computed` is also equality check function (or `true` for built-in implementation):
The second argument to `computed` is also an equality check function (or `true` for the built-in
implementation):
```js

@@ -175,3 +191,3 @@ const [numbers, setNumbers] = observable([1, 2, 3, 4]);

```jsx
import { observable, computed, useObserver } from "onek";
import { computed, observable, useObserver } from "onek";

@@ -183,17 +199,17 @@ const [greeting, setGreeting] = observable("hello!");

const LoudGreeting = () => {
const obs = useObserver();
const observer = useObserver();
return <p>{loudGreeting(obs)}</p>;
return observer(() => <p>{loudGreeting()}</p>);
};
const GreetingInput = () => {
const obs = useObserver();
const observer = useObserver();
return (
return observer(() => (
<input
type="text"
onChange={(e) => setGreeting(e.target.value)}
value={greeting(obs)}
value={greeting()}
/>
);
));
};

@@ -209,3 +225,6 @@

`useObserver` hook has no arguments and returns subscriber instance that should be passed to `observable` and `computed` getters in order to get the component subscribed to them. While it's still correct to read observable values without passing the subscriber, changes to them won't rerender your component:
`useObserver` hook has no arguments and returns an observer function. You can wrap your component
code with it or pass it to `observable` and `computed` getters in order to get the component update
on their changes. Reading observable values outside of the observer fn or without passing it to
getters won't subscribe the component to changes:

@@ -216,5 +235,7 @@ ```js

const Component = () => {
const obs = useObserver();
const observer = useObserver();
value(obs); // correct, component will rerender on value change
observer(() => value()); // component will rerender on value change
observer(value); // correct, will rerender as well
value(observer); // also corrrect
value(); // no rerender on value change

@@ -226,5 +247,9 @@ };

**Actions** automatically batch updates to observable values, and also make access to observable getters untracked - so if your action is called inside component's render function or inside reaction, it won't make it re-render on accessed values change.
**Actions** automatically batch updates to observable values, and also make access to observable
getters untracked - so if your action is called inside a component's render function or inside a
reaction it won't make it re-render on accessed values change.
**Important note**: by default all changes to `observable` values are batched until the end of current microtask. In order to run reactions synchronously on transaction end, please read the [Changing reaction scheduler](#reaction-scheduler) section.
**Important note**: by default all changes to `observable` values are batched until the end of the
current microtask. In order to run reactions synchronously on transaction end, please read
the [Changing reaction scheduler](#reaction-scheduler) section.

@@ -245,3 +270,4 @@ ```js

**Transaction** is the same, except it's executed immediately and doesn't make values access untracked:
A **transaction** is the same, except it's executed immediately and doesn't make values access
untracked:

@@ -257,3 +283,3 @@ ```js

To get the same behaviour as `action` use `utx` (**U**ntracked transaction) instead:
To get the same behavior as `action` use `utx` (**U**ntracked transaction) instead:

@@ -293,3 +319,5 @@ ```js

By default, onek uses microtask scheduler for reactions, so updates to observables are batched until the current microtask end. This means both `data` and `fetching` values will be consistent when any side effects run.
By default, Onek uses a microtask scheduler for reactions, so updates to observables are batched
until the current microtask end. This means both `data` and `fetching` values will be consistent
when any side effects run.

@@ -299,3 +327,5 @@ <details>

[You can configure](#reaction-scheduler) onek to use synchronous reaction scheduler that will execute side effects synchronously after each transaction end. In this case you need to use `action` for promise handlers or `utx` for code blocks in async function, i.e.:
[You can configure](#reaction-scheduler) Onek to use synchronous reaction scheduler that will
execute side effects synchronously after each transaction end. In this case you need to use `action`
for promise handlers or `utx` for code blocks in async function, i.e.:

@@ -348,3 +378,4 @@ ```js

**Reaction** is a way to react to observable or computed changes without involving React. It's the same as `autorun` function from MobX:
A **reaction** is a way to react to observable or computed changes without involving React. It's the
same as the `autorun` function from MobX:

@@ -371,3 +402,4 @@ ```js

Return value of reaction body might be **reaction destructor** - a function that is called before each reaction run and on `disposer` call:
The return value of the reaction body might be a **reaction destructor** - a function that is called
before each reaction run and on `disposer` call:

@@ -394,2 +426,66 @@ ```js

### Making models
#### Solid.js flavor
To compose your observable and computed values into a single model, you can use the following
pattern:
```js
function makeModel(initialValue) {
const [value, setValue] = observable(initialValue);
const doubleValue = computed(() => value() * 2);
return {
value,
setValue,
doubleValue,
};
}
```
A downside of this approach is that it's required to explicitly return all model
getters/setters/actions, which can be cumbersome for large models. Also it requires defining a
convenient TypeScript type for the model:
```ts
type Model = ReturnType<typeof makeModel>;
```
#### MobX flavor
Another flavor for making Onek models is MobX flavor. It requires importing an additional tiny
(~300 bytes) package:
```js
import { makeObservable } from "onek/mobx";
class Model {
constructor(initialValue) {
this.value = observable.prop(initialValue);
this.double = computed.prop(() => this.value * 2);
makeObservable(this);
}
}
const model = new Model(10);
// read observable and computed values
model.value === 10;
model.double === 20;
// set observable value
model.value = 100;
```
It defines observable and computed values on class and then calls `makeObservable` to create
getters/setters on the class instance. The only difference in defining the values on the class is
that you need to use `.prop` modifier on observable/computed factories. Otherwise, the usage of MobX
models is equivalent to Solid.js ones - just read the values inside `observer` function to make a
component re-render on changes.
**Note:** it's safe to call `makeObservable` more than once on a class instance. This makes it work
for inheritance cases where both base and inherited classes have observable values.
## Examples?

@@ -403,3 +499,3 @@

```jsx
import { observable, action, useObserver } from "onek";
import { action, observable, useObserver } from "onek";

@@ -416,7 +512,7 @@ const makeCounter = (initial) => {

const Counter = ({ counter }) => {
const observer = useObserver();
const { count, inc, dec, reset } = counter;
const obs = useObserver();
return (
return observer(() => (
<>

@@ -426,5 +522,5 @@ <button onClick={inc}>+</button>

<button onClick={reset}>Reset</button>
Count: {count(obs)}
Count: {count()}
</>
);
));
};

@@ -482,16 +578,16 @@

const CounterStats = ({ count, sum }) => {
const obs = useObserver();
const observer = useObserver();
return (
return observer(() => (
<>
<p>Total count: {count(obs)}</p>
<p>Total sum: {sum(obs)}</p>
<p>Total count: {count()}</p>
<p>Total sum: {sum()}</p>
</>
);
));
};
const CountersList = ({ model }) => {
const obs = useObserver();
const observer = useObserver();
return (
return observer(() => (
<div>

@@ -501,3 +597,3 @@ <CounterStats count={model.countersCount} sum={model.countersSum} />

<button onClick={model.resetAll}>Reset all</button>
{model.counters(obs).map((counter) => (
{model.counters().map((counter) => (
<div>

@@ -509,3 +605,3 @@ <Counter counter={counter} />

</div>
);
));
};

@@ -526,3 +622,3 @@

```jsx
import { action, observable, computed, useObserver } from "onek";
import { action, computed, observable, useObserver } from "onek";

@@ -606,22 +702,22 @@ let id = 0;

const NewTodoInput = ({ model }) => {
const observer = useObserver();
const { text, setText, addTodo } = model;
const obs = useObserver();
return (
return observer(() => (
<div>
<input onChange={(e) => setText(e.target.value)} value={text(obs)} />
<button onClick={addTodo} disabled={text(obs).length === 0}>
<input onChange={(e) => setText(e.target.value)} value={text()} />
<button onClick={addTodo} disabled={text().length === 0}>
Add
</button>
</div>
);
));
};
const TodoListFilter = ({ model }) => {
const obs = useObserver();
const observer = useObserver();
return (
return observer(() => (
<select
value={model.filter(obs)}
value={model.filter()}
onChange={(e) => model.setFilter(e.target.value)}

@@ -635,9 +731,9 @@ >

</select>
);
));
};
const Todo = ({ model }) => {
const obs = useObserver();
const observer = useObserver();
return (
return observer(() => (
<div className="todo">

@@ -647,19 +743,19 @@ <label>

type="checkbox"
checked={model.done(obs)}
checked={model.done()}
onChange={model.toggleDone}
/>
<span
style={{ textDecoration: model.done(obs) ? "line-through" : "none" }}
style={{ textDecoration: model.done() ? "line-through" : "none" }}
>
{model.text(obs)}
{model.text()}
</span>
</label>
</div>
);
));
};
export const TodoList = ({ model }) => {
const obs = useObserver();
const observer = useObserver();
return (
return observer(() => (
<div className="todo-list">

@@ -669,7 +765,7 @@ <button onClick={model.clearDone}>Clear done</button>

<NewTodoInput model={model} />
{model.visibleTodos(obs).map((todo) => (
{model.visibleTodos().map((todo) => (
<Todo key={todo.id} model={todo} />
))}
</div>
);
));
};

@@ -686,3 +782,6 @@ ```

Reaction scheduler is a function that's called on the end of the first transaction executed after previous scheduler run. It has one argument - `runner` function that should somehow be "scheduled" to run. Default implementation of the scheduler is microtask Promise-based scheduler:
The reaction scheduler is a function that's called at the end of the first transaction executed
after the previous scheduler run. It has one argument - a `runner` function that should somehow be "
scheduled" to run. The default implementation of the scheduler is a microtask Promise-based
scheduler:

@@ -695,3 +794,5 @@ ```js

This is a good compromise between speed and developer experience, but sometimes you might want to run all reactions synchronously on transaction end (for example, this is done in onek test suite):
This is a good compromise between speed and developer experience, but sometimes you might want to
run all reactions synchronously at transaction end (for example, this is done in the Onek test
suite):

@@ -704,3 +805,3 @@ ```js

Another alternative to the default microtask scheduler is **macro**task scheduler:
Another alternative to the default microtask scheduler is a **macro**task scheduler:

@@ -715,3 +816,4 @@ ```js

Default exception handler for auto-run reactions is just `console.error`. It can be configured by `reactionExceptionHandler` option:
The default exception handler for auto-run reactions is just `console.error`. It can be configured
by the `reactionExceptionHandler` option:

@@ -728,5 +830,13 @@ ```js

Onek does not have memory leaks while maintaining optimal caching for computed values. There is no `keepAlive` option like `MobX` has, and here's why. When a computed value has lost its last subscriber or being read in untracked context without existing subscribers, it enters **passive** state. The state means the computed is no longer referenced by any observable or other computed, but still holds references to its dependencies, so it can check later if some of them changed.
Onek does not have memory leaks while maintaining optimal caching for computed values. There is
no `keepAlive` option like in `MobX`, and here's why. When a computed value has lost its last
subscriber or is being read in untracked context without existing subscribers, it enters a **passive
** state. This state means the computed is no longer referenced by any observable or other computed,
but still holds references to its dependencies, so it can check later if some of them changed.
How is the change detection possible without guarantees that values stored in observables and computeds are immutable? The answer is simple: along with the value, observables and computeds store **revision** - an immutable plain object that is new each time observable or computed updated. This allows to implement `reselect`-like logic of checking computed dependencies with very small overhead and preserve cached values without any memory leaks.
How is the change detection possible without guarantees that values stored in observables and
computeds are immutable? The answer is simple: along with the value, observable and computed store a
**revision** - an immutable plain object that is new each time an observable or computed is updated.
This allows the implementation of `reselect`-like logic of checking computed dependencies with very small
overhead and preserve cached values without any memory leaks.

@@ -737,3 +847,3 @@ ## API Documentation

Here's some general interfaces used in the following documentation:
Here are some general interfaces used in the following documentation:

@@ -750,7 +860,7 @@ ```ts

interface ObservableGetter<T> extends Getter<T> {
$$observable: ObservableImpl<T>;
instance: IObservable<T>;
}
interface ComputedGetter<T> extends Getter<T> {
$$computed: ComputedImpl<T>;
instance: IComputed<T>;

@@ -777,8 +887,19 @@ destroy(): void;

Creates getter and setter for reactive value. `value` argument as a value stored in the observable instance, `checkFn` is a function that's used for checking if new value from the setter is the same as the old one.
Getter is a function that can accept `Subscriber` - return value of `useObserver` hook or value of `$$computed` attribute of computed getter.
Setter function can accept `value` argument that can be of generic type or updater function that returns a value of the generic type.
The second argument to setter function is `asIs` boolean that indicates if the `value` should be stored as is without interpreting it as updater function.
Setter also can be called without arguments - this will mark the observable as changed without changing its value. This can be useful when you mutate observable value directly without changing reference to it.
Creates a getter and setter for reactive value. The `value` argument is the value stored in the
observable instance, and the `checkFn`
is a function that's used for checking if the new value from the setter is the same as the old one.
The getter is a function that can accept a `Subscriber` - return value of `useObserver` hook or the
value of `instance`attribute of a computed getter.
The setter function can accept a `value` argument that can be of a generic type or an updater
function that returns a value of the generic type.
The second argument to the setter function is an `asIs` boolean that indicates if the `value` should
be stored as is without interpreting it as an updater function.
The setter also can be called without arguments - this will mark the observable as changed without
changing its value. This can be useful when you mutate the observable value directly without
changing the reference to it.
### computed

@@ -785,0 +906,0 @@

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

import type { CheckFn, IComputed, IComputedGetter, IComputedImpl, IRevision, Subscriber, Subscription } from "../types";
import { State } from "../constants";
import type { CheckFn, IComputed, IComputedGetter, IComputedImpl, IRevision, NotifyState, Subscriber, Subscription } from "../types";
export declare class Computed<T = any> implements IComputedImpl<T> {

@@ -8,5 +7,3 @@ private _value;

private readonly _subscriptions;
private _subscriptionsToActualize;
private _state;
private _shouldSubscribe;
private readonly _fn;

@@ -19,3 +16,3 @@ private readonly _checkFn?;

_checkSubscribersAndPassivate(): void;
_notify(state: State, subscription: Subscription): void;
_notify(state: NotifyState, subscription: Subscription): void;
_actualizeAndRecompute(willHaveSubscriber?: boolean): void;

@@ -22,0 +19,0 @@ revision(): IRevision;

@@ -10,2 +10,3 @@ import type { CheckFn, IObservable, IObservableGetter, IObservableImpl, IRevision, ISetter, Subscriber, UpdaterFn } from "../types";

_removeSubscriber(subscriber: Subscriber): void;
_actualizeAndRecompute(): void;
revision(): IRevision;

@@ -12,0 +13,0 @@ get(_subscriber?: import("../types").MaybeSubscriber): T;

@@ -1,7 +0,6 @@

import type { Disposer, IReactionImpl, ReactionFn, Subscription } from "../types";
import { State } from "../constants";
import type { Disposer, IReactionImpl, NotifyState, ReactionFn, Subscription } from "../types";
export declare class Reaction implements IReactionImpl {
private _fn;
private _manager?;
_shouldSubscribe: boolean;
shouldSubscribe: boolean;
private _subscriptions;

@@ -12,8 +11,8 @@ private _destructor;

addSubscription(subscription: Subscription): void;
_notify(state: State, subscription: Subscription): void;
_subscribe(): void;
_unsubscribe(): void;
_unsubscribeAndRemove(): void;
_notify(state: NotifyState, subscription: Subscription): void;
_runManager(): void;
_missedRun(): boolean;
subscribe(): void;
unsubscribe(): void;
unsubscribeAndCleanup(): void;
missedRun(): boolean;
destroy(): void;

@@ -20,0 +19,0 @@ run(): void;

export declare const enum State {
NOT_INITIALIZED = 0,
CLEAN = 1,
MAYBE_DIRTY = 2,
DIRTY = 3,
COMPUTING = 4,
PASSIVE = 5,
DESTROYED = 6
COMPUTING = 1,
COMPUTING_PASSIVE = 2,
CLEAN = 3,
MAYBE_DIRTY = 4,
DIRTY = 5,
PASSIVE = 6,
DESTROYED = 7
}
export declare const MAX_REACTION_ITERATIONS = 100;

@@ -1,4 +0,4 @@

import { Computed } from "../classes";
export declare const stateActualizationQueue: Set<Computed>;
export declare function scheduleStateActualization(computed: Computed): void;
import { Subscription } from "../types";
export declare const stateActualizationQueue: Set<Subscription>;
export declare function scheduleStateActualization(computed: Subscription): void;
export declare function runStateActualization(): void;
import { IdentityFn, MaybeSubscriber } from "./types";
export declare let txDepth: number;
export declare function tx(fn: () => void): void;
export declare function utx<T>(fn: () => T, subscriber?: MaybeSubscriber): T;
export declare function untracked<T>(fn: () => T): T;
export declare function withUntracked<T extends Function>(fn: T): IdentityFn<T>;
export declare function action<T extends Function>(fn: T): IdentityFn<T>;
export declare function endTx(): void;
import { State } from "./constants";
export type NotifyState = State.MAYBE_DIRTY | State.DIRTY;
export type IdentityFn<T> = T extends (...args: infer Args) => infer R ? (...args: Args) => R : never;

@@ -12,3 +13,3 @@ export type Subscriber = IComputedImpl | IReactionImpl;

export interface IGettable<T> {
get(_subscriber?: Subscriber): T;
get(_subscriber?: SubscriberBase): T;
revision(): IRevision;

@@ -18,2 +19,3 @@ }

set(newValue?: T | UpdaterFn<T>, asIs?: boolean): void;
notify(): void;
}

@@ -23,2 +25,3 @@ export interface IObservableImpl<T = any> extends IObservable<T> {

_removeSubscriber(subscriber: Subscriber): void;
_actualizeAndRecompute(): void;
}

@@ -32,3 +35,3 @@ export interface IComputed<T> extends IGettable<T> {

_checkSubscribersAndPassivate(): void;
_notify(state: State, subscription: Subscription): void;
_notify(state: NotifyState, subscription: Subscription): void;
_actualizeAndRecompute(willHaveSubscriber?: boolean): void;

@@ -42,10 +45,10 @@ }

export interface IReaction {
new (fn: ReactionFn, manager?: () => void): IReaction;
destroy(): void;
run(): void;
subscribe(): void;
unsubscribe(): void;
unsubscribeAndCleanup(): void;
}
export interface IReactionImpl extends SubscriberBase {
_notify(state: State, subscription: Subscription): void;
_subscribe(): void;
_unsubscribe(): void;
export interface IReactionImpl extends IReaction, SubscriberBase {
_notify(state: NotifyState, subscription: Subscription): void;
_runManager(): void;

@@ -56,3 +59,4 @@ }

export interface IGetter<T> {
(subscriber?: Subscriber): T;
(subscriber?: SubscriberBase): T;
revision(): IRevision;
}

@@ -59,0 +63,0 @@ export interface ISetter<T> {

export declare function shallowEquals<T>(prev: T, next: T): boolean;
export declare const untrackedShallowEquals: (prev: unknown, next: unknown) => boolean;
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 { observable, Observable, computed, Computed, reaction, Reaction, Revision, tx, utx, untracked, 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc