mobx-react 5.4.3 → 5.4.4

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/index.module.js CHANGED
@@ -1,3 +1,11 @@
1
+ /** @license mobx-react v5.4.4
2
+ * index.module.js
3
+ *
4
+ * Copyright (c) 2015 Michel Weststrate.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
1
9
  import { isObservableArray, isObservableObject, isObservableMap, untracked, createAtom, Reaction, _allowStateChanges, $mobx, spy, configure, getDebugName } from 'mobx';
2
10
  import React__default, { Component, createElement, PureComponent, forwardRef, Children } from 'react';
3
11
  import { findDOMNode, unstable_batchedUpdates } from 'react-dom';
@@ -442,7 +450,8 @@ function isStateless(component) {
442
450
  return !(component.prototype && component.prototype.render);
443
451
  }
444
452
  var symbolId = 0;
445
- function newSymbol(name) {
453
+
454
+ function createSymbol(name) {
446
455
  if (typeof Symbol === "function") {
447
456
  return Symbol(name);
448
457
  }
@@ -451,6 +460,15 @@ function newSymbol(name) {
451
460
  symbolId++;
452
461
  return symbol;
453
462
  }
463
+
464
+ var createdSymbols = {};
465
+ function newSymbol(name) {
466
+ if (!createdSymbols[name]) {
467
+ createdSymbols[name] = createSymbol(name);
468
+ }
469
+
470
+ return createdSymbols[name];
471
+ }
454
472
  var mobxMixins = newSymbol("patchMixins");
455
473
  var mobxPatchedDefinition = newSymbol("patchedDefinition");
456
474
 
@@ -571,8 +589,8 @@ var proxiedInjectorProps = {
571
589
  configurable: true,
572
590
  enumerable: true
573
591
  }
574
- /**
575
- * Store Injection
592
+ /**
593
+ * Store Injection
576
594
  */
577
595
 
578
596
  };
@@ -656,11 +674,11 @@ function grabStoresByName(storeNames) {
656
674
  return nextProps;
657
675
  };
658
676
  }
659
- /**
660
- * higher order component that injects stores to a child.
661
- * takes either a varargs list of strings, which are stores read from the context,
662
- * or a function that manually maps the available stores from the context to props:
663
- * storesToProps(mobxStores, props, context) => newProps
677
+ /**
678
+ * higher order component that injects stores to a child.
679
+ * takes either a varargs list of strings, which are stores read from the context,
680
+ * or a function that manually maps the available stores from the context to props:
681
+ * storesToProps(mobxStores, props, context) => newProps
664
682
  */
665
683
 
666
684
 
@@ -698,8 +716,8 @@ function inject()
698
716
 
699
717
  var mobxAdminProperty = $mobx || "$mobx";
700
718
  var mobxIsUnmounted = newSymbol("isUnmounted");
701
- /**
702
- * dev tool support
719
+ /**
720
+ * dev tool support
703
721
  */
704
722
 
705
723
  var isDevtoolsEnabled = false;
@@ -712,11 +730,11 @@ var skipRenderKey = newSymbol("skipRender");
712
730
  var isForcingUpdateKey = newSymbol("isForcingUpdate"); // Using react-is had some issues (and operates on elements, not on types), see #608 / #609
713
731
 
714
732
  var ReactForwardRefSymbol = typeof forwardRef === "function" && forwardRef(function (_props, _ref) {})["$$typeof"];
715
- /**
716
- * Helper to set `prop` to `this` as non-enumerable (hidden prop)
717
- * @param target
718
- * @param prop
719
- * @param value
733
+ /**
734
+ * Helper to set `prop` to `this` as non-enumerable (hidden prop)
735
+ * @param target
736
+ * @param prop
737
+ * @param value
720
738
  */
721
739
 
722
740
  function setHiddenProp(target, prop, value) {
@@ -766,13 +784,13 @@ function trackComponents() {
766
784
  function useStaticRendering(useStaticRendering) {
767
785
  isUsingStaticRendering = useStaticRendering;
768
786
  }
769
- /**
770
- * Errors reporter
787
+ /**
788
+ * Errors reporter
771
789
  */
772
790
 
773
791
  var errorsReporter = new EventEmitter();
774
- /**
775
- * Utilities
792
+ /**
793
+ * Utilities
776
794
  */
777
795
 
778
796
  function patch$1(target, funcName) {
@@ -847,15 +865,15 @@ function makeComponentReactive(render) {
847
865
 
848
866
  var initialName = this.displayName || this.name || this.constructor && (this.constructor.displayName || this.constructor.name) || "<component>";
849
867
  var rootNodeID = this._reactInternalInstance && this._reactInternalInstance._rootNodeID || this._reactInternalInstance && this._reactInternalInstance._debugID || this._reactInternalFiber && this._reactInternalFiber._debugID;
850
- /**
851
- * If props are shallowly modified, react will render anyway,
852
- * so atom.reportChanged() should not result in yet another re-render
868
+ /**
869
+ * If props are shallowly modified, react will render anyway,
870
+ * so atom.reportChanged() should not result in yet another re-render
853
871
  */
854
872
 
855
873
  setHiddenProp(this, skipRenderKey, false);
856
- /**
857
- * forceUpdate will re-assign this.props. We don't want that to cause a loop,
858
- * so detect these changes
874
+ /**
875
+ * forceUpdate will re-assign this.props. We don't want that to cause a loop,
876
+ * so detect these changes
859
877
  */
860
878
 
861
879
  setHiddenProp(this, isForcingUpdateKey, false); // wire up reactive render
@@ -892,8 +910,8 @@ function makeComponentReactive(render) {
892
910
  this.render = reactiveRender;
893
911
  return reactiveRender.call(this);
894
912
  }
895
- /**
896
- * ReactiveMixin
913
+ /**
914
+ * ReactiveMixin
897
915
  */
898
916
 
899
917
 
@@ -976,8 +994,8 @@ function makeObservableProp(target, propName) {
976
994
  }
977
995
  });
978
996
  }
979
- /**
980
- * Observer function / decorator
997
+ /**
998
+ * Observer function / decorator
981
999
  */
982
1000
 
983
1001
 
package/native.d.ts CHANGED
@@ -1,140 +1,140 @@
1
- /**
2
- * Turns a React component or stateless render function into a reactive component.
3
- */
4
- import * as React from "react"
5
-
6
- export type IReactComponent<P = any> =
7
- | React.StatelessComponent<P>
8
- | React.ComponentClass<P>
9
- | React.ClassicComponentClass<P>
10
-
11
- /**
12
- * Observer
13
- */
14
-
15
- // Deprecated: observer with with stores (as decorator)
16
- export function observer(stores: string[]): <T extends IReactComponent>(clazz: T) => void
17
- // Deprecated: observer with with stores
18
- export function observer<T extends IReactComponent>(stores: string[], clazz: T): T
19
- export function observer<T extends IReactComponent>(target: T): T
20
-
21
- /**
22
- * Inject
23
- */
24
- export type IValueMap = { [key: string]: any }
25
- export type IStoresToProps<
26
- S extends IValueMap = {},
27
- P extends IValueMap = {},
28
- I extends IValueMap = {},
29
- C extends IValueMap = {}
30
- > = (stores: S, nextProps: P, context: C) => I
31
-
32
- export type IWrappedComponent<P> = {
33
- wrappedComponent: IReactComponent<P>
34
- wrappedInstance: React.ReactInstance | undefined
35
- }
36
-
37
- // Ideally we would want to return React.ComponentClass<Partial<P>>,
38
- // but TS doesn't allow such things in decorators, like we do in the non-decorator version
39
- // See also #256
40
- export function inject(
41
- ...stores: string[]
42
- ): <T extends IReactComponent<any>>(
43
- target: T
44
- ) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never)
45
- export function inject<S, P, I, C>(
46
- fn: IStoresToProps<S, P, I, C>
47
- ): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>
48
-
49
- // Ideal implementation:
50
- // export function inject
51
- // (
52
- // fn: IStoresToProps
53
- // ):
54
- // <P>(target: IReactComponent<P>) => IReactComponent<Partial<P>> & IWrappedComponent<IReactComponent<Partial<P>>>
55
- //
56
- // Or even better: (but that would require type inference to work other way around)
57
- // export function inject<P, I>
58
- // (
59
- // fn: IStoresToProps<any, P, I>
60
- // ):
61
- // <T extends IReactComponent<P & S>(target: T) => IReactComponent<P> & IWrappedComponent<T>
62
-
63
- /**
64
- * disposeOnUnmount
65
- */
66
- type Disposer = () => void
67
- export function disposeOnUnmount(target: React.Component<any, any>, propertyKey: string): void
68
- export function disposeOnUnmount<TF extends Disposer | Disposer[]>(
69
- target: React.Component<any, any>,
70
- fn: TF
71
- ): TF
72
-
73
- /**
74
- * Utilities
75
- */
76
- export function onError(cb: (error: Error) => void): () => void
77
-
78
- export class Provider extends React.Component<any, {}> {}
79
-
80
- export class Observer extends React.Component<
81
- {
82
- children?: () => React.ReactNode
83
- render?: () => React.ReactNode
84
- },
85
- {}
86
- > {}
87
-
88
- export function useStaticRendering(value: boolean): void
89
-
90
- /**
91
- * Enable dev tool support, makes sure that renderReport emits events.
92
- */
93
- export function trackComponents(): void
94
-
95
- export const renderReporter: RenderReporter
96
-
97
- export interface RenderReporter {
98
- on(handler: (data: IRenderEvent) => void): void
99
- }
100
-
101
- export interface IRenderEvent {
102
- event: "render" | "destroy"
103
- renderTime?: number
104
- totalTime?: number
105
- component: React.ReactElement<any> // Component instance
106
- node: any // DOMNode
107
- }
108
-
109
- /**
110
- * WeakMap DOMNode -> Component instance
111
- * @deprecated
112
- */
113
- export const componentByNodeRegistery: any
114
- /**
115
- * WeakMap DOMNode -> Component instance
116
- */
117
- export const componentByNodeRegistry: any
118
-
119
- /**
120
- * @deprecated, use PropTypes instead
121
- */
122
- export const propTypes: {
123
- observableArray: React.Requireable<any>
124
- observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
125
- observableMap: React.Requireable<any>
126
- observableObject: React.Requireable<any>
127
- arrayOrObservableArray: React.Requireable<any>
128
- arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
129
- objectOrObservableObject: React.Requireable<any>
130
- }
131
-
132
- export const PropTypes: {
133
- observableArray: React.Requireable<any>
134
- observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
135
- observableMap: React.Requireable<any>
136
- observableObject: React.Requireable<any>
137
- arrayOrObservableArray: React.Requireable<any>
138
- arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
139
- objectOrObservableObject: React.Requireable<any>
140
- }
1
+ /**
2
+ * Turns a React component or stateless render function into a reactive component.
3
+ */
4
+ import * as React from "react"
5
+
6
+ export type IReactComponent<P = any> =
7
+ | React.StatelessComponent<P>
8
+ | React.ComponentClass<P>
9
+ | React.ClassicComponentClass<P>
10
+
11
+ /**
12
+ * Observer
13
+ */
14
+
15
+ // Deprecated: observer with with stores (as decorator)
16
+ export function observer(stores: string[]): <T extends IReactComponent>(clazz: T) => void
17
+ // Deprecated: observer with with stores
18
+ export function observer<T extends IReactComponent>(stores: string[], clazz: T): T
19
+ export function observer<T extends IReactComponent>(target: T): T
20
+
21
+ /**
22
+ * Inject
23
+ */
24
+ export type IValueMap = { [key: string]: any }
25
+ export type IStoresToProps<
26
+ S extends IValueMap = {},
27
+ P extends IValueMap = {},
28
+ I extends IValueMap = {},
29
+ C extends IValueMap = {}
30
+ > = (stores: S, nextProps: P, context: C) => I
31
+
32
+ export type IWrappedComponent<P> = {
33
+ wrappedComponent: IReactComponent<P>
34
+ wrappedInstance: React.ReactInstance | undefined
35
+ }
36
+
37
+ // Ideally we would want to return React.ComponentClass<Partial<P>>,
38
+ // but TS doesn't allow such things in decorators, like we do in the non-decorator version
39
+ // See also #256
40
+ export function inject(
41
+ ...stores: string[]
42
+ ): <T extends IReactComponent<any>>(
43
+ target: T
44
+ ) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never)
45
+ export function inject<S, P, I, C>(
46
+ fn: IStoresToProps<S, P, I, C>
47
+ ): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>
48
+
49
+ // Ideal implementation:
50
+ // export function inject
51
+ // (
52
+ // fn: IStoresToProps
53
+ // ):
54
+ // <P>(target: IReactComponent<P>) => IReactComponent<Partial<P>> & IWrappedComponent<IReactComponent<Partial<P>>>
55
+ //
56
+ // Or even better: (but that would require type inference to work other way around)
57
+ // export function inject<P, I>
58
+ // (
59
+ // fn: IStoresToProps<any, P, I>
60
+ // ):
61
+ // <T extends IReactComponent<P & S>(target: T) => IReactComponent<P> & IWrappedComponent<T>
62
+
63
+ /**
64
+ * disposeOnUnmount
65
+ */
66
+ type Disposer = () => void
67
+ export function disposeOnUnmount(target: React.Component<any, any>, propertyKey: string): void
68
+ export function disposeOnUnmount<TF extends Disposer | Disposer[]>(
69
+ target: React.Component<any, any>,
70
+ fn: TF
71
+ ): TF
72
+
73
+ /**
74
+ * Utilities
75
+ */
76
+ export function onError(cb: (error: Error) => void): () => void
77
+
78
+ export class Provider extends React.Component<any, {}> {}
79
+
80
+ export class Observer extends React.Component<
81
+ {
82
+ children?: () => React.ReactNode
83
+ render?: () => React.ReactNode
84
+ },
85
+ {}
86
+ > {}
87
+
88
+ export function useStaticRendering(value: boolean): void
89
+
90
+ /**
91
+ * Enable dev tool support, makes sure that renderReport emits events.
92
+ */
93
+ export function trackComponents(): void
94
+
95
+ export const renderReporter: RenderReporter
96
+
97
+ export interface RenderReporter {
98
+ on(handler: (data: IRenderEvent) => void): void
99
+ }
100
+
101
+ export interface IRenderEvent {
102
+ event: "render" | "destroy"
103
+ renderTime?: number
104
+ totalTime?: number
105
+ component: React.ReactElement<any> // Component instance
106
+ node: any // DOMNode
107
+ }
108
+
109
+ /**
110
+ * WeakMap DOMNode -> Component instance
111
+ * @deprecated
112
+ */
113
+ export const componentByNodeRegistery: any
114
+ /**
115
+ * WeakMap DOMNode -> Component instance
116
+ */
117
+ export const componentByNodeRegistry: any
118
+
119
+ /**
120
+ * @deprecated, use PropTypes instead
121
+ */
122
+ export const propTypes: {
123
+ observableArray: React.Requireable<any>
124
+ observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
125
+ observableMap: React.Requireable<any>
126
+ observableObject: React.Requireable<any>
127
+ arrayOrObservableArray: React.Requireable<any>
128
+ arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
129
+ objectOrObservableObject: React.Requireable<any>
130
+ }
131
+
132
+ export const PropTypes: {
133
+ observableArray: React.Requireable<any>
134
+ observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
135
+ observableMap: React.Requireable<any>
136
+ observableObject: React.Requireable<any>
137
+ arrayOrObservableArray: React.Requireable<any>
138
+ arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
139
+ objectOrObservableObject: React.Requireable<any>
140
+ }
package/native.js CHANGED
@@ -1,3 +1,11 @@
1
+ /** @license mobx-react v5.4.4
2
+ * native.js
3
+ *
4
+ * Copyright (c) 2015 Michel Weststrate.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
1
9
  'use strict';
2
10
 
3
11
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -449,7 +457,8 @@ function isStateless(component) {
449
457
  return !(component.prototype && component.prototype.render);
450
458
  }
451
459
  var symbolId = 0;
452
- function newSymbol(name) {
460
+
461
+ function createSymbol(name) {
453
462
  if (typeof Symbol === "function") {
454
463
  return Symbol(name);
455
464
  }
@@ -458,6 +467,15 @@ function newSymbol(name) {
458
467
  symbolId++;
459
468
  return symbol;
460
469
  }
470
+
471
+ var createdSymbols = {};
472
+ function newSymbol(name) {
473
+ if (!createdSymbols[name]) {
474
+ createdSymbols[name] = createSymbol(name);
475
+ }
476
+
477
+ return createdSymbols[name];
478
+ }
461
479
  var mobxMixins = newSymbol("patchMixins");
462
480
  var mobxPatchedDefinition = newSymbol("patchedDefinition");
463
481
 
@@ -578,8 +596,8 @@ var proxiedInjectorProps = {
578
596
  configurable: true,
579
597
  enumerable: true
580
598
  }
581
- /**
582
- * Store Injection
599
+ /**
600
+ * Store Injection
583
601
  */
584
602
 
585
603
  };
@@ -663,11 +681,11 @@ function grabStoresByName(storeNames) {
663
681
  return nextProps;
664
682
  };
665
683
  }
666
- /**
667
- * higher order component that injects stores to a child.
668
- * takes either a varargs list of strings, which are stores read from the context,
669
- * or a function that manually maps the available stores from the context to props:
670
- * storesToProps(mobxStores, props, context) => newProps
684
+ /**
685
+ * higher order component that injects stores to a child.
686
+ * takes either a varargs list of strings, which are stores read from the context,
687
+ * or a function that manually maps the available stores from the context to props:
688
+ * storesToProps(mobxStores, props, context) => newProps
671
689
  */
672
690
 
673
691
 
@@ -705,8 +723,8 @@ function inject()
705
723
 
706
724
  var mobxAdminProperty = mobx.$mobx || "$mobx";
707
725
  var mobxIsUnmounted = newSymbol("isUnmounted");
708
- /**
709
- * dev tool support
726
+ /**
727
+ * dev tool support
710
728
  */
711
729
 
712
730
  var isDevtoolsEnabled = false;
@@ -719,11 +737,11 @@ var skipRenderKey = newSymbol("skipRender");
719
737
  var isForcingUpdateKey = newSymbol("isForcingUpdate"); // Using react-is had some issues (and operates on elements, not on types), see #608 / #609
720
738
 
721
739
  var ReactForwardRefSymbol = typeof React.forwardRef === "function" && React.forwardRef(function (_props, _ref) {})["$$typeof"];
722
- /**
723
- * Helper to set `prop` to `this` as non-enumerable (hidden prop)
724
- * @param target
725
- * @param prop
726
- * @param value
740
+ /**
741
+ * Helper to set `prop` to `this` as non-enumerable (hidden prop)
742
+ * @param target
743
+ * @param prop
744
+ * @param value
727
745
  */
728
746
 
729
747
  function setHiddenProp(target, prop, value) {
@@ -763,13 +781,13 @@ function trackComponents() {
763
781
  function useStaticRendering(useStaticRendering) {
764
782
  isUsingStaticRendering = useStaticRendering;
765
783
  }
766
- /**
767
- * Errors reporter
784
+ /**
785
+ * Errors reporter
768
786
  */
769
787
 
770
788
  var errorsReporter = new EventEmitter();
771
- /**
772
- * Utilities
789
+ /**
790
+ * Utilities
773
791
  */
774
792
 
775
793
  function patch$1(target, funcName) {
@@ -844,15 +862,15 @@ function makeComponentReactive(render) {
844
862
 
845
863
  var initialName = this.displayName || this.name || this.constructor && (this.constructor.displayName || this.constructor.name) || "<component>";
846
864
  var rootNodeID = this._reactInternalInstance && this._reactInternalInstance._rootNodeID || this._reactInternalInstance && this._reactInternalInstance._debugID || this._reactInternalFiber && this._reactInternalFiber._debugID;
847
- /**
848
- * If props are shallowly modified, react will render anyway,
849
- * so atom.reportChanged() should not result in yet another re-render
865
+ /**
866
+ * If props are shallowly modified, react will render anyway,
867
+ * so atom.reportChanged() should not result in yet another re-render
850
868
  */
851
869
 
852
870
  setHiddenProp(this, skipRenderKey, false);
853
- /**
854
- * forceUpdate will re-assign this.props. We don't want that to cause a loop,
855
- * so detect these changes
871
+ /**
872
+ * forceUpdate will re-assign this.props. We don't want that to cause a loop,
873
+ * so detect these changes
856
874
  */
857
875
 
858
876
  setHiddenProp(this, isForcingUpdateKey, false); // wire up reactive render
@@ -889,8 +907,8 @@ function makeComponentReactive(render) {
889
907
  this.render = reactiveRender;
890
908
  return reactiveRender.call(this);
891
909
  }
892
- /**
893
- * ReactiveMixin
910
+ /**
911
+ * ReactiveMixin
894
912
  */
895
913
 
896
914
 
@@ -973,8 +991,8 @@ function makeObservableProp(target, propName) {
973
991
  }
974
992
  });
975
993
  }
976
- /**
977
- * Observer function / decorator
994
+ /**
995
+ * Observer function / decorator
978
996
  */
979
997
 
980
998
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-react",
3
- "version": "5.4.3",
3
+ "version": "5.4.4",
4
4
  "description": "React bindings for MobX. Create fully reactive components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "index.module.js",