mobx 5.14.1 → 5.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,7 +79,8 @@ _Tip: Consider using the faster and smaller ES6 build if targetting a modern env
79
79
  - LearnCode.academy MobX tutorial [Part I: MobX + React is AWESOME (7m)](https://www.youtube.com/watch?v=_q50BXqkAfI) [Part II: Computed Values and Nested/Referenced Observables (12m.)](https://www.youtube.com/watch?v=nYvNqKrl69s)
80
80
  - [Screencast: intro to MobX](https://www.youtube.com/watch?v=K8dr8BMU7-8) - 8m
81
81
  - [Talk: State Management Is Easy, React Amsterdam 2016 conf](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) ([slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx))
82
- - [Boilerplates and related projects](http://mobxjs.github.io/mobx/faq/boilerplates.html)
82
+ - Boilerplates [MobX awesome list](https://github.com/mobxjs/awesome-mobx#boilerplates)
83
+ - Related projects [MobX awesome list](https://github.com/mobxjs/awesome-mobx#related-projects-and-utilities)
83
84
  - More tutorials, blogs, videos, and other helpful resources can be found on the [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx)
84
85
 
85
86
  ## Introduction
@@ -312,11 +313,13 @@ And finally, kudos to all the people that believed in, tried, validated and even
312
313
  ## Further resources and documentation
313
314
 
314
315
  - <img src="docs/assets/book.jpg" height="80px"/> [The MobX book](https://books.google.nl/books?id=ALFmDwAAQBAJ&pg=PP1&lpg=PP1&dq=michel+weststrate+mobx+quick+start+guide:+supercharge+the+client+state+in+your+react+apps+with+mobx&source=bl&ots=D460fxti0F&sig=ivDGTxsPNwlOjLHrpKF1nweZFl8&hl=nl&sa=X&ved=2ahUKEwiwl8XO--ncAhWPmbQKHWOYBqIQ6AEwAnoECAkQAQ#v=onepage&q=michel%20weststrate%20mobx%20quick%20start%20guide%3A%20supercharge%20the%20client%20state%20in%20your%20react%20apps%20with%20mobx&f=false) by Pavan Podila and Michel Weststrate (which despite its name is in-depth!)
315
- - [MobX homepage](http://mobxjs.github.io/mobx/faq/blogs.html)
316
+ - [MobX homepage](http://mobxjs.github.io)
316
317
  - [API overview](http://mobxjs.github.io/mobx/refguide/api.html)
317
- - [Tutorials, Blogs & Videos](http://mobxjs.github.io/mobx/faq/blogs.html)
318
- - [Boilerplates](http://mobxjs.github.io/mobx/faq/boilerplates.html)
319
- - [Related projects](http://mobxjs.github.io/mobx/faq/related.html)
318
+ - [Tutorials](https://github.com/mobxjs/awesome-mobx#tutorials)
319
+ - [Blogs](https://github.com/mobxjs/awesome-mobx#blogs)
320
+ - [Videos](https://github.com/mobxjs/awesome-mobx#videos)
321
+ - [Boilerplates](https://github.com/mobxjs/awesome-mobx#boilerplates)
322
+ - [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx)
320
323
 
321
324
  ## What others are saying...
322
325
 
@@ -1,19 +1,7 @@
1
1
  import { IAction } from "../internal";
2
2
  export interface IActionFactory {
3
- <A1, R, T extends (a1: A1) => R>(fn: T): T & IAction;
4
- <A1, A2, R, T extends (a1: A1, a2: A2) => R>(fn: T): T & IAction;
5
- <A1, A2, A3, R, T extends (a1: A1, a2: A2, a3: A3) => R>(fn: T): T & IAction;
6
- <A1, A2, A3, A4, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4) => R>(fn: T): T & IAction;
7
- <A1, A2, A3, A4, A5, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => R>(fn: T): T & IAction;
8
- <A1, A2, A3, A4, A5, A6, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4, a6: A6) => R>(fn: T): T & IAction;
9
- <A1, R, T extends (a1: A1) => R>(name: string, fn: T): T & IAction;
10
- <A1, A2, R, T extends (a1: A1, a2: A2) => R>(name: string, fn: T): T & IAction;
11
- <A1, A2, A3, R, T extends (a1: A1, a2: A2, a3: A3) => R>(name: string, fn: T): T & IAction;
12
- <A1, A2, A3, A4, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4) => R>(name: string, fn: T): T & IAction;
13
- <A1, A2, A3, A4, A5, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => R>(name: string, fn: T): T & IAction;
14
- <A1, A2, A3, A4, A5, A6, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4, a6: A6) => R>(name: string, fn: T): T & IAction;
15
- <T extends Function>(fn: T): T & IAction;
16
- <T extends Function>(name: string, fn: T): T & IAction;
3
+ <T extends Function | null | undefined>(fn: T): T & IAction;
4
+ <T extends Function | null | undefined>(name: string, fn: T): T & IAction;
17
5
  (customName: string): (target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor) => void;
18
6
  (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void;
19
7
  bound(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void;
package/lib/api/flow.d.ts CHANGED
@@ -1,12 +1,9 @@
1
+ export declare function FlowCancellationError(): void;
2
+ export declare namespace FlowCancellationError {
3
+ var prototype: any;
4
+ }
5
+ export declare function isFlowCancellationError(error: Error): boolean;
1
6
  export declare type CancellablePromise<T> = Promise<T> & {
2
7
  cancel(): void;
3
8
  };
4
- export interface FlowYield {
5
- "!!flowYield": undefined;
6
- }
7
- export interface FlowReturn<T> {
8
- "!!flowReturn": T;
9
- }
10
- export declare type FlowReturnType<R> = IfAllAreFlowYieldThenVoid<R extends FlowReturn<infer FR> ? FR extends Promise<infer FRP> ? FRP : FR : R extends Promise<any> ? FlowYield : R>;
11
- export declare type IfAllAreFlowYieldThenVoid<R> = Exclude<R, FlowYield> extends never ? void : Exclude<R, FlowYield>;
12
- export declare function flow<R, Args extends any[]>(generator: (...args: Args) => IterableIterator<R>): (...args: Args) => CancellablePromise<FlowReturnType<R>>;
9
+ export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>): (...args: Args) => CancellablePromise<R>;
@@ -38,7 +38,7 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
38
38
  newObserving: null;
39
39
  isBeingObserved: boolean;
40
40
  isPendingUnobservation: boolean;
41
- observers: Set<any>;
41
+ observers: Set<IDerivation>;
42
42
  diffValue: number;
43
43
  runId: number;
44
44
  lastAccessedBy: number;
@@ -92,4 +92,4 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
92
92
  valueOf(): T;
93
93
  [Symbol.toPrimitive](): T;
94
94
  }
95
- export declare const isComputedValue: (x: any) => x is ComputedValue<{}>;
95
+ export declare const isComputedValue: (x: any) => x is ComputedValue<unknown>;
@@ -96,6 +96,7 @@ export declare class MobXGlobals {
96
96
  disableErrorBoundaries: boolean;
97
97
  suppressReactionErrors: boolean;
98
98
  }
99
+ export declare function getGlobal(): any;
99
100
  export declare let globalState: MobXGlobals;
100
101
  export declare function isolateGlobalState(): void;
101
102
  export declare function getGlobalState(): any;
@@ -104,4 +105,3 @@ export declare function getGlobalState(): any;
104
105
  * but can be used to get back at a stable state after throwing errors
105
106
  */
106
107
  export declare function resetGlobalState(): void;
107
- export declare function getGlobal(): any;
package/lib/mobx.d.ts CHANGED
@@ -15,4 +15,4 @@
15
15
  * - utils/ Utility stuff.
16
16
  *
17
17
  */
18
- export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, IDerivation, untracked, IDerivationState, IAtom, createAtom, IAction, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, IObservableObject, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, IObservableFactories, computed, IComputed, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, decorate, configure, onBecomeObserved, onBecomeUnobserved, flow, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, Lambda, isArrayLike, $mobx, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions, IActionRunInfo, _startAction, _endAction } from "./internal";
18
+ export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, IDerivation, untracked, IDerivationState, IAtom, createAtom, IAction, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, IObservableObject, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, IObservableFactories, computed, IComputed, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, decorate, configure, onBecomeObserved, onBecomeUnobserved, flow, FlowCancellationError, isFlowCancellationError, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, Lambda, isArrayLike, $mobx, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions, IActionRunInfo, _startAction, _endAction, allowStateReadsStart as _allowStateReadsStart, allowStateReadsEnd as _allowStateReadsEnd } from "./internal";
package/lib/mobx.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** MobX - (c) Michel Weststrate 2015 - 2019 - MIT Licensed */
2
- const OBFUSCATED_ERROR = "An invariant failed, however the error is obfuscated because this is an production build.";
2
+ const OBFUSCATED_ERROR = "An invariant failed, however the error is obfuscated because this is a production build.";
3
3
  const EMPTY_ARRAY = [];
4
4
  Object.freeze(EMPTY_ARRAY);
5
5
  const EMPTY_OBJECT = {};
@@ -241,7 +241,9 @@ function initializeInstance(target) {
241
241
  const decorators = target[mobxPendingDecorators];
242
242
  if (decorators) {
243
243
  addHiddenProp(target, mobxDidRunLazyInitializersSymbol, true);
244
- for (let key in decorators) {
244
+ // Build property key array from both strings and symbols
245
+ const keys = [...Object.getOwnPropertySymbols(decorators), ...Object.keys(decorators)];
246
+ for (const key of keys) {
245
247
  const d = decorators[key];
246
248
  d.propertyCreator(target, d.prop, d.descriptor, d.decoratorTarget, d.decoratorArguments);
247
249
  }
@@ -286,7 +288,8 @@ function createPropDecorator(propertyInitiallyEnumerable, propertyCreator) {
286
288
  };
287
289
  }
288
290
  function quacksLikeADecorator(args) {
289
- return (((args.length === 2 || args.length === 3) && typeof args[1] === "string") ||
291
+ return (((args.length === 2 || args.length === 3) &&
292
+ (typeof args[1] === "string" || typeof args[1] === "symbol")) ||
290
293
  (args.length === 4 && args[3] === true));
291
294
  }
292
295
 
@@ -403,7 +406,7 @@ function getEnhancerFromOptions(options) {
403
406
  */
404
407
  function createObservable(v, arg2, arg3) {
405
408
  // @observable someProp;
406
- if (typeof arguments[1] === "string") {
409
+ if (typeof arguments[1] === "string" || typeof arguments[1] === "symbol") {
407
410
  return deepDecorator.apply(null, arguments);
408
411
  }
409
412
  // it is an observable already, done
@@ -570,6 +573,8 @@ function shouldCompute(derivation) {
570
573
  case IDerivationState.STALE:
571
574
  return true;
572
575
  case IDerivationState.POSSIBLY_STALE: {
576
+ // state propagation can occur outside of action/reactive context #2195
577
+ const prevAllowStateReads = allowStateReadsStart(true);
573
578
  const prevUntracked = untrackedStart(); // no need for those computeds to be reported, they will be picked up in trackDerivedFunction.
574
579
  const obs = derivation.observing, l = obs.length;
575
580
  for (let i = 0; i < l; i++) {
@@ -585,6 +590,7 @@ function shouldCompute(derivation) {
585
590
  catch (e) {
586
591
  // we are not interested in the value *or* exception at this moment, but if there is one, notify all
587
592
  untrackedEnd(prevUntracked);
593
+ allowStateReadsEnd(prevAllowStateReads);
588
594
  return true;
589
595
  }
590
596
  }
@@ -593,12 +599,14 @@ function shouldCompute(derivation) {
593
599
  // invariantShouldCompute(derivation)
594
600
  if (derivation.dependenciesState === IDerivationState.STALE) {
595
601
  untrackedEnd(prevUntracked);
602
+ allowStateReadsEnd(prevAllowStateReads);
596
603
  return true;
597
604
  }
598
605
  }
599
606
  }
600
607
  changeDependenciesStateTo0(derivation);
601
608
  untrackedEnd(prevUntracked);
609
+ allowStateReadsEnd(prevAllowStateReads);
602
610
  return false;
603
611
  }
604
612
  }
@@ -1041,8 +1049,7 @@ class ComputedValue {
1041
1049
  this.isComputing = false; // to check for cycles
1042
1050
  this.isRunningSetter = false;
1043
1051
  this.isTracing = TraceMode.NONE;
1044
- if (process.env.NODE_ENV !== "production" && !options.get)
1045
- throw "[mobx] missing option for computed: get";
1052
+ invariant(options.get, "missing option for computed: get");
1046
1053
  this.derivation = options.get;
1047
1054
  this.name = options.name || "ComputedValue@" + getNextId();
1048
1055
  if (options.set)
@@ -1333,6 +1340,19 @@ class MobXGlobals {
1333
1340
  this.suppressReactionErrors = false;
1334
1341
  }
1335
1342
  }
1343
+ const mockGlobal = {};
1344
+ function getGlobal() {
1345
+ if (typeof window !== "undefined") {
1346
+ return window;
1347
+ }
1348
+ if (typeof global !== "undefined") {
1349
+ return global;
1350
+ }
1351
+ if (typeof self !== "undefined") {
1352
+ return self;
1353
+ }
1354
+ return mockGlobal;
1355
+ }
1336
1356
  let canMergeGlobalState = true;
1337
1357
  let isolateCalled = false;
1338
1358
  let globalState = (function () {
@@ -1386,16 +1406,6 @@ function resetGlobalState() {
1386
1406
  globalState[key] = defaultGlobals[key];
1387
1407
  globalState.allowStateChanges = !globalState.enforceActions;
1388
1408
  }
1389
- const mockGlobal = {};
1390
- function getGlobal() {
1391
- if (typeof window !== "undefined") {
1392
- return window;
1393
- }
1394
- if (typeof global !== "undefined") {
1395
- return global;
1396
- }
1397
- return mockGlobal;
1398
- }
1399
1409
 
1400
1410
  function hasObservers(observable) {
1401
1411
  return observable.observers && observable.observers.size > 0;
@@ -1810,7 +1820,7 @@ function spyReport(event) {
1810
1820
  function spyReportStart(event) {
1811
1821
  if (process.env.NODE_ENV === "production")
1812
1822
  return;
1813
- const change = Object.assign({}, event, { spyReportStart: true });
1823
+ const change = Object.assign(Object.assign({}, event), { spyReportStart: true });
1814
1824
  spyReport(change);
1815
1825
  }
1816
1826
  const END_EVENT = { spyReportEnd: true };
@@ -1818,7 +1828,7 @@ function spyReportEnd(change) {
1818
1828
  if (process.env.NODE_ENV === "production")
1819
1829
  return;
1820
1830
  if (change)
1821
- spyReport(Object.assign({}, change, { spyReportEnd: true }));
1831
+ spyReport(Object.assign(Object.assign({}, change), { spyReportEnd: true }));
1822
1832
  else
1823
1833
  spyReport(END_EVENT);
1824
1834
  }
@@ -2195,8 +2205,6 @@ function extendObservableObjectWithProperties(target, properties, decorators, de
2195
2205
  if (process.env.NODE_ENV !== "production") {
2196
2206
  if (!isPlainObject(properties))
2197
2207
  fail(`'extendObservabe' only accepts plain objects as second argument`);
2198
- if (Object.getOwnPropertyDescriptor(target, key))
2199
- fail(`'extendObservable' can only be used to introduce new properties. Use 'set' or 'decorate' instead. The property '${stringifyKey(key)}' already exists on '${target}'`);
2200
2208
  if (isComputed(descriptor.value))
2201
2209
  fail(`Passing a 'computed' as initial property value is no longer supported by extendObservable. Use a getter or decorator instead`);
2202
2210
  }
@@ -2242,9 +2250,16 @@ function nodeToObserverTree(node) {
2242
2250
  }
2243
2251
 
2244
2252
  let generatorId = 0;
2253
+ function FlowCancellationError() {
2254
+ this.message = "FLOW_CANCELLED";
2255
+ }
2256
+ FlowCancellationError.prototype = Object.create(Error.prototype);
2257
+ function isFlowCancellationError(error) {
2258
+ return error instanceof FlowCancellationError;
2259
+ }
2245
2260
  function flow(generator) {
2246
2261
  if (arguments.length !== 1)
2247
- fail(!!process.env.NODE_ENV && `Flow expects one 1 argument and cannot be used as decorator`);
2262
+ fail(!!process.env.NODE_ENV && `Flow expects 1 argument and cannot be used as decorator`);
2248
2263
  const name = generator.name || "<unnamed flow>";
2249
2264
  // Implementation based on https://github.com/tj/co/blob/master/index.js
2250
2265
  return function () {
@@ -2297,13 +2312,13 @@ function flow(generator) {
2297
2312
  if (pendingPromise)
2298
2313
  cancelPromise(pendingPromise);
2299
2314
  // Finally block can return (or yield) stuff..
2300
- const res = gen.return();
2315
+ const res = gen.return(undefined);
2301
2316
  // eat anything that promise would do, it's cancelled!
2302
2317
  const yieldedPromise = Promise.resolve(res.value);
2303
2318
  yieldedPromise.then(noop, noop);
2304
2319
  cancelPromise(yieldedPromise); // maybe it can be cancelled :)
2305
2320
  // reject our original promise
2306
- rejector(new Error("FLOW_CANCELLED"));
2321
+ rejector(new FlowCancellationError());
2307
2322
  }
2308
2323
  catch (e) {
2309
2324
  rejector(e); // there could be a throwing finally block
@@ -2745,7 +2760,7 @@ function whenPromise(predicate, opts) {
2745
2760
  return fail(`the options 'onError' and 'promise' cannot be combined`);
2746
2761
  let cancel;
2747
2762
  const res = new Promise((resolve, reject) => {
2748
- let disposer = _when(predicate, resolve, Object.assign({}, opts, { onError: reject }));
2763
+ let disposer = _when(predicate, resolve, Object.assign(Object.assign({}, opts), { onError: reject }));
2749
2764
  cancel = () => {
2750
2765
  disposer();
2751
2766
  reject("WHEN_CANCELLED");
@@ -3057,7 +3072,7 @@ class ObservableArrayAdministration {
3057
3072
  // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't
3058
3073
  // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
3059
3074
  if (notifySpy && process.env.NODE_ENV !== "production")
3060
- spyReportStart(Object.assign({}, change, { name: this.atom.name }));
3075
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.atom.name }));
3061
3076
  this.atom.reportChanged();
3062
3077
  if (notify)
3063
3078
  notifyListeners(this, change);
@@ -3079,7 +3094,7 @@ class ObservableArrayAdministration {
3079
3094
  }
3080
3095
  : null;
3081
3096
  if (notifySpy && process.env.NODE_ENV !== "production")
3082
- spyReportStart(Object.assign({}, change, { name: this.atom.name }));
3097
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.atom.name }));
3083
3098
  this.atom.reportChanged();
3084
3099
  // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
3085
3100
  if (notify)
@@ -3330,7 +3345,7 @@ class ObservableMap {
3330
3345
  }
3331
3346
  : null;
3332
3347
  if (notifySpy && process.env.NODE_ENV !== "production")
3333
- spyReportStart(Object.assign({}, change, { name: this.name, key }));
3348
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name, key }));
3334
3349
  transaction(() => {
3335
3350
  this._keysAtom.reportChanged();
3336
3351
  this._updateHasMapEntry(key, false);
@@ -3368,7 +3383,7 @@ class ObservableMap {
3368
3383
  }
3369
3384
  : null;
3370
3385
  if (notifySpy && process.env.NODE_ENV !== "production")
3371
- spyReportStart(Object.assign({}, change, { name: this.name, key }));
3386
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name, key }));
3372
3387
  observable.setNewValue(newValue);
3373
3388
  if (notify)
3374
3389
  notifyListeners(this, change);
@@ -3396,7 +3411,7 @@ class ObservableMap {
3396
3411
  }
3397
3412
  : null;
3398
3413
  if (notifySpy && process.env.NODE_ENV !== "production")
3399
- spyReportStart(Object.assign({}, change, { name: this.name, key }));
3414
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name, key }));
3400
3415
  if (notify)
3401
3416
  notifyListeners(this, change);
3402
3417
  if (notifySpy && process.env.NODE_ENV !== "production")
@@ -3644,7 +3659,7 @@ class ObservableSet {
3644
3659
  }
3645
3660
  : null;
3646
3661
  if (notifySpy && process.env.NODE_ENV !== "production")
3647
- spyReportStart(Object.assign({}, change, { name: this.name }));
3662
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name }));
3648
3663
  transaction(() => {
3649
3664
  this._atom.reportChanged();
3650
3665
  this._data.delete(value);
@@ -3776,7 +3791,7 @@ class ObservableObjectAdministration {
3776
3791
  }
3777
3792
  : null;
3778
3793
  if (notifySpy && process.env.NODE_ENV !== "production")
3779
- spyReportStart(Object.assign({}, change, { name: this.name, key }));
3794
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name, key }));
3780
3795
  observable.setNewValue(newValue);
3781
3796
  if (notify)
3782
3797
  notifyListeners(this, change);
@@ -3865,7 +3880,7 @@ class ObservableObjectAdministration {
3865
3880
  }
3866
3881
  : null;
3867
3882
  if (notifySpy && process.env.NODE_ENV !== "production")
3868
- spyReportStart(Object.assign({}, change, { name: this.name, key }));
3883
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name, key }));
3869
3884
  if (notify)
3870
3885
  notifyListeners(this, change);
3871
3886
  if (notifySpy && process.env.NODE_ENV !== "production")
@@ -3922,7 +3937,7 @@ class ObservableObjectAdministration {
3922
3937
  }
3923
3938
  : null;
3924
3939
  if (notifySpy && process.env.NODE_ENV !== "production")
3925
- spyReportStart(Object.assign({}, change, { name: this.name, key }));
3940
+ spyReportStart(Object.assign(Object.assign({}, change), { name: this.name, key }));
3926
3941
  if (notify)
3927
3942
  notifyListeners(this, change);
3928
3943
  if (notifySpy && process.env.NODE_ENV !== "production")
@@ -4098,9 +4113,6 @@ function eq(a, b, depth, aStack, bStack) {
4098
4113
  const type = typeof a;
4099
4114
  if (type !== "function" && type !== "object" && typeof b != "object")
4100
4115
  return false;
4101
- // Unwrap any wrapped objects.
4102
- a = unwrap(a);
4103
- b = unwrap(b);
4104
4116
  // Compare `[[Class]]` names.
4105
4117
  const className = toString.call(a);
4106
4118
  if (className !== toString.call(b))
@@ -4128,7 +4140,18 @@ function eq(a, b, depth, aStack, bStack) {
4128
4140
  return +a === +b;
4129
4141
  case "[object Symbol]":
4130
4142
  return (typeof Symbol !== "undefined" && Symbol.valueOf.call(a) === Symbol.valueOf.call(b));
4143
+ case "[object Map]":
4144
+ case "[object Set]":
4145
+ // Maps and Sets are unwrapped to arrays of entry-pairs, adding an incidental level.
4146
+ // Hide this extra level by increasing the depth.
4147
+ if (depth >= 0) {
4148
+ depth++;
4149
+ }
4150
+ break;
4131
4151
  }
4152
+ // Unwrap any wrapped objects.
4153
+ a = unwrap(a);
4154
+ b = unwrap(b);
4132
4155
  const areArrays = className === "[object Array]";
4133
4156
  if (!areArrays) {
4134
4157
  if (typeof a != "object" || typeof b != "object")
@@ -4281,4 +4304,4 @@ if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
4281
4304
  });
4282
4305
  }
4283
4306
 
4284
- export { $mobx, IDerivationState, ObservableMap, ObservableSet, Reaction, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, _endAction, getAdministration as _getAdministration, getGlobalState as _getGlobalState, interceptReads as _interceptReads, isComputingDerivation as _isComputingDerivation, resetGlobalState as _resetGlobalState, _startAction, action, autorun, comparer, computed, configure, createAtom, decorate, entries, extendObservable, flow, get, getAtom, getDebugName, getDependencyTree, getObserverTree, has, intercept, isAction, isArrayLike, isObservableValue as isBoxedObservable, isComputed, isComputedProp, isObservable, isObservableArray, isObservableMap, isObservableObject, isObservableProp, isObservableSet, keys, observable, observe, onBecomeObserved, onBecomeUnobserved, onReactionError, reaction, remove, runInAction, set, spy, toJS, trace, transaction, untracked, values, when };
4307
+ export { $mobx, FlowCancellationError, IDerivationState, ObservableMap, ObservableSet, Reaction, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, allowStateReadsEnd as _allowStateReadsEnd, allowStateReadsStart as _allowStateReadsStart, _endAction, getAdministration as _getAdministration, getGlobalState as _getGlobalState, interceptReads as _interceptReads, isComputingDerivation as _isComputingDerivation, resetGlobalState as _resetGlobalState, _startAction, action, autorun, comparer, computed, configure, createAtom, decorate, entries, extendObservable, flow, get, getAtom, getDebugName, getDependencyTree, getObserverTree, has, intercept, isAction, isArrayLike, isObservableValue as isBoxedObservable, isComputed, isComputedProp, isFlowCancellationError, isObservable, isObservableArray, isObservableMap, isObservableObject, isObservableProp, isObservableSet, keys, observable, observe, onBecomeObserved, onBecomeUnobserved, onReactionError, reaction, remove, runInAction, set, spy, toJS, trace, transaction, untracked, values, when };