New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mobx-react-lite

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-react-lite - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

2

dist/index.d.ts

@@ -10,2 +10,2 @@ import "./assertEnvironment";

export { useQueuedForceUpdate, useQueuedForceUpdateBlock } from "./useQueuedForceUpdate";
export { observerBatching } from "./observerBatching";
export { isObserverBatched, observerBatching } from "./observerBatching";

@@ -17,3 +17,49 @@ (function (global, factory) {

function defaulNoopBatch(callback) {
function useForceUpdate() {
var _useState = React.useState(0),
setTick = _useState[1];
var update = React.useCallback(function () {
setTick(function (tick) {
return tick + 1;
});
}, []);
return update;
}
function isPlainObject(value) {
if (!value || typeof value !== "object") {
return false;
}
var proto = Object.getPrototypeOf(value);
return !proto || proto === Object.prototype;
}
function getSymbol(name) {
if (typeof Symbol === "function") {
return Symbol.for(name);
}
return "__$mobx-react " + name + "__";
}
var mockGlobal = {};
function getGlobal() {
if (typeof window !== "undefined") {
return window;
}
if (typeof global !== "undefined") {
return global;
}
if (typeof self !== "undefined") {
return self;
}
return mockGlobal;
}
var observerBatchingConfiguredSymbol =
/*#__PURE__*/
getSymbol("observerBatching");
function defaultNoopBatch(callback) {
callback();

@@ -23,3 +69,3 @@ }

if (!reactionScheduler) {
reactionScheduler = defaulNoopBatch;
reactionScheduler = defaultNoopBatch;

@@ -34,3 +80,7 @@ {

});
getGlobal()[observerBatchingConfiguredSymbol] = true;
}
var isObserverBatched = function isObserverBatched() {
return !!getGlobal()[observerBatchingConfiguredSymbol];
};

@@ -142,22 +192,2 @@ var globalIsUsingStaticRendering = false;

function useForceUpdate() {
var _useState = React.useState(0),
setTick = _useState[1];
var update = React.useCallback(function () {
setTick(function (tick) {
return tick + 1;
});
}, []);
return update;
}
function isPlainObject(value) {
if (!value || typeof value !== "object") {
return false;
}
var proto = Object.getPrototypeOf(value);
return !proto || proto === Object.prototype;
}
var insideRender = false;

@@ -472,2 +502,3 @@ var forceUpdateQueue = [];

exports.Observer = ObserverComponent;
exports.isObserverBatched = isObserverBatched;
exports.isUsingStaticRendering = isUsingStaticRendering;

@@ -474,0 +505,0 @@ exports.observer = observer;

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("mobx"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","mobx","react","react-dom"],r):r((e=e||self).mobxReactLite={},e.mobx,e.React,e.ReactDOM)}(this,(function(e,r,n,t){"use strict";var o="default"in n?n.default:n;if(!n.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.spy)throw new Error("mobx-react-lite requires mobx at least version 4 to be available");function u(e){e()}function c(e){e||(e=u),r.configure({reactionScheduler:e})}var i=!1;function a(){return i}function f(){return(f=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function s(e){return r.getDependencyTree(e)}var d,l=new Set;function p(){void 0===d&&(d=setTimeout(v,1e4))}function v(){d=void 0;var e=Date.now();l.forEach((function(r){var n=r.current;n&&e>=n.cleanAt&&(n.reaction.dispose(),r.current=null,l.delete(r))})),l.size>0&&p()}function b(){var e=n.useState(0)[1];return n.useCallback((function(){e((function(e){return e+1}))}),[])}var y=!1,h=[];function m(e){return function(){y?h.push(e):e()}}function w(e){y=!0,h=[];try{var r=e();y=!1;var n=h.length>0?h:void 0;return o.useLayoutEffect((function(){n&&n.forEach((function(e){return e()}))}),[n]),r}finally{y=!1}}var O={};function g(e){return"observer"+e}function j(e,n,t){if(void 0===n&&(n="observed"),void 0===t&&(t=O),a())return e();var u=m((t.useForceUpdate||b)()),c=o.useRef(null);if(!c.current){var i=new r.Reaction(g(n),(function(){f.mounted?u():(i.dispose(),c.current=null)})),f=function(e){return{cleanAt:Date.now()+1e4,reaction:e}}(i);c.current=f,l.add(c),p()}var d=c.current.reaction;return o.useDebugValue(d,s),o.useEffect((function(){return l.delete(c),c.current?c.current.mounted=!0:(c.current={reaction:new r.Reaction(g(n),(function(){u()})),cleanAt:Infinity},u()),function(){c.current.reaction.dispose(),c.current=null}}),[]),w((function(){var r,n;if(d.track((function(){try{r=e()}catch(e){n=e}})),n)throw n;return r}))}var R={$$typeof:!0,render:!0,compare:!0,type:!0};function x(e){var r=e.children||e.render;return"function"!=typeof r?null:j(r)}function E(e,r,n,t,o){var u="function"==typeof e[r],c="function"==typeof e["children"===r?"render":"children"];return u&&c?new Error("MobX Observer: Do not use children and render in the same time in`"+n):u||c?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[r]+"` supplied to `"+n+"`, expected `function`.")}function S(e,n){if(!n||void 0!==e){var t=o.useState((function(){return r.observable(e,{},{deep:!1})}))[0];return r.runInAction((function(){Object.assign(t,e)})),t}}x.propTypes={children:E,render:E},x.displayName="Observer",c(t.unstable_batchedUpdates),e.Observer=x,e.isUsingStaticRendering=a,e.observer=function(e,r){if(a())return e;var t,o,u,c=f({forwardRef:!1},r),i=e.displayName||e.name,s=function(r,n){return j((function(){return e(r,n)}),i)};return s.displayName=i,t=n.memo(c.forwardRef?n.forwardRef(s):s),o=e,u=t,Object.keys(o).forEach((function(e){R[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),t.displayName=i,t},e.observerBatching=c,e.useAsObservableSource=function(e){return S(e,!1)},e.useForceUpdate=b,e.useLocalStore=function(e,n){var t=S(n,!0);return o.useState((function(){var n=r.observable(e(t));return function(e){if(!e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return!r||r===Object.prototype}(n)&&r.runInAction((function(){Object.keys(n).forEach((function(e){var t,o,u=n[e];"function"==typeof u&&(n[e]=(t=u,o=n,function(){for(var e=arguments.length,n=new Array(e),u=0;u<e;u++)n[u]=arguments[u];return r.transaction((function(){return t.apply(o,n)}))}))}))})),n}))[0]},e.useObserver=j,e.useQueuedForceUpdate=m,e.useQueuedForceUpdateBlock=w,e.useStaticRendering=function(e){i=e},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("mobx"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","mobx","react","react-dom"],n):n((e=e||self).mobxReactLite={},e.mobx,e.React,e.ReactDOM)}(this,(function(e,n,r,t){"use strict";var o="default"in r?r.default:r;if(!r.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!n.spy)throw new Error("mobx-react-lite requires mobx at least version 4 to be available");function u(){var e=r.useState(0)[1];return r.useCallback((function(){e((function(e){return e+1}))}),[])}function i(e){return"function"==typeof Symbol?Symbol.for(e):"__$mobx-react "+e+"__"}var c={};function a(){return"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:c}var f=i("observerBatching");function s(e){e()}function d(e){e||(e=s),n.configure({reactionScheduler:e}),a()[f]=!0}var l=!1;function p(){return l}function v(){return(v=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function b(e){return n.getDependencyTree(e)}var y,h=new Set;function m(){void 0===y&&(y=setTimeout(w,1e4))}function w(){y=void 0;var e=Date.now();h.forEach((function(n){var r=n.current;r&&e>=r.cleanAt&&(r.reaction.dispose(),n.current=null,h.delete(n))})),h.size>0&&m()}var O=!1,g=[];function j(e){return function(){O?g.push(e):e()}}function x(e){O=!0,g=[];try{var n=e();O=!1;var r=g.length>0?g:void 0;return o.useLayoutEffect((function(){r&&r.forEach((function(e){return e()}))}),[r]),n}finally{O=!1}}var R={};function S(e){return"observer"+e}function E(e,r,t){if(void 0===r&&(r="observed"),void 0===t&&(t=R),p())return e();var i=j((t.useForceUpdate||u)()),c=o.useRef(null);if(!c.current){var a=new n.Reaction(S(r),(function(){f.mounted?i():(a.dispose(),c.current=null)})),f=function(e){return{cleanAt:Date.now()+1e4,reaction:e}}(a);c.current=f,h.add(c),m()}var s=c.current.reaction;return o.useDebugValue(s,b),o.useEffect((function(){return h.delete(c),c.current?c.current.mounted=!0:(c.current={reaction:new n.Reaction(S(r),(function(){i()})),cleanAt:Infinity},i()),function(){c.current.reaction.dispose(),c.current=null}}),[]),x((function(){var n,r;if(s.track((function(){try{n=e()}catch(e){r=e}})),r)throw r;return n}))}var A={$$typeof:!0,render:!0,compare:!0,type:!0};function D(e){var n=e.children||e.render;return"function"!=typeof n?null:E(n)}function _(e,n,r,t,o){var u="function"==typeof e[n],i="function"==typeof e["children"===n?"render":"children"];return u&&i?new Error("MobX Observer: Do not use children and render in the same time in`"+r):u||i?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[n]+"` supplied to `"+r+"`, expected `function`.")}function k(e,r){if(!r||void 0!==e){var t=o.useState((function(){return n.observable(e,{},{deep:!1})}))[0];return n.runInAction((function(){Object.assign(t,e)})),t}}D.propTypes={children:_,render:_},D.displayName="Observer",d(t.unstable_batchedUpdates),e.Observer=D,e.isObserverBatched=function(){return!!a()[f]},e.isUsingStaticRendering=p,e.observer=function(e,n){if(p())return e;var t,o,u,i=v({forwardRef:!1},n),c=e.displayName||e.name,a=function(n,r){return E((function(){return e(n,r)}),c)};return a.displayName=c,t=r.memo(i.forwardRef?r.forwardRef(a):a),o=e,u=t,Object.keys(o).forEach((function(e){A[e]||Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(o,e))})),t.displayName=c,t},e.observerBatching=d,e.useAsObservableSource=function(e){return k(e,!1)},e.useForceUpdate=u,e.useLocalStore=function(e,r){var t=k(r,!0);return o.useState((function(){var r=n.observable(e(t));return function(e){if(!e||"object"!=typeof e)return!1;var n=Object.getPrototypeOf(e);return!n||n===Object.prototype}(r)&&n.runInAction((function(){Object.keys(r).forEach((function(e){var t,o,u=r[e];"function"==typeof u&&(r[e]=(t=u,o=r,function(){for(var e=arguments.length,r=new Array(e),u=0;u<e;u++)r[u]=arguments[u];return n.transaction((function(){return t.apply(o,r)}))}))}))})),r}))[0]},e.useObserver=E,e.useQueuedForceUpdate=j,e.useQueuedForceUpdateBlock=x,e.useStaticRendering=function(e){l=e},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=mobxreactlite.umd.production.min.js.map

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

export declare function defaulNoopBatch(callback: () => void): void;
export declare function defaultNoopBatch(callback: () => void): void;
export declare function observerBatching(reactionScheduler: any): void;
export declare const isObserverBatched: () => boolean;

@@ -13,2 +13,2 @@ import "./assertEnvironment";

export { useQueuedForceUpdate, useQueuedForceUpdateBlock } from "./useQueuedForceUpdate";
export { observerBatching } from "./observerBatching";
export { isObserverBatched, observerBatching } from "./observerBatching";
import { configure } from "mobx";
export function defaulNoopBatch(callback) {
import { getGlobal, getSymbol } from "./utils";
var observerBatchingConfiguredSymbol = getSymbol("observerBatching");
export function defaultNoopBatch(callback) {
callback();

@@ -7,3 +9,3 @@ }

if (!reactionScheduler) {
reactionScheduler = defaulNoopBatch;
reactionScheduler = defaultNoopBatch;
if ("production" !== process.env.NODE_ENV) {

@@ -14,2 +16,4 @@ console.warn("[MobX] Failed to get unstable_batched updates from react-dom / react-native");

configure({ reactionScheduler: reactionScheduler });
getGlobal()[observerBatchingConfiguredSymbol] = true;
}
export var isObserverBatched = function () { return !!getGlobal()[observerBatchingConfiguredSymbol]; };

@@ -26,2 +26,3 @@ "use strict";

var observerBatching_2 = require("./observerBatching");
exports.isObserverBatched = observerBatching_2.isObserverBatched;
exports.observerBatching = observerBatching_2.observerBatching;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
function defaulNoopBatch(callback) {
var utils_1 = require("./utils");
var observerBatchingConfiguredSymbol = utils_1.getSymbol("observerBatching");
function defaultNoopBatch(callback) {
callback();
}
exports.defaulNoopBatch = defaulNoopBatch;
exports.defaultNoopBatch = defaultNoopBatch;
function observerBatching(reactionScheduler) {
if (!reactionScheduler) {
reactionScheduler = defaulNoopBatch;
reactionScheduler = defaultNoopBatch;
if ("production" !== process.env.NODE_ENV) {

@@ -16,3 +18,5 @@ console.warn("[MobX] Failed to get unstable_batched updates from react-dom / react-native");

mobx_1.configure({ reactionScheduler: reactionScheduler });
utils_1.getGlobal()[observerBatchingConfiguredSymbol] = true;
}
exports.observerBatching = observerBatching;
exports.isObserverBatched = function () { return !!utils_1.getGlobal()[observerBatchingConfiguredSymbol]; };
{
"name": "mobx-react-lite",
"version": "2.2.0",
"version": "2.2.1",
"description": "Lightweight React bindings for MobX based on React 16.8+ and Hooks",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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