mobx-state-tree 7.0.0-pre.2 → 7.0.1

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.
@@ -59,7 +59,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
59
59
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
60
60
  PERFORMANCE OF THIS SOFTWARE.
61
61
  ***************************************************************************** */
62
- /* global Reflect, Promise, SuppressedError, Symbol */
62
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
63
63
 
64
64
  var extendStatics = function(d, b) {
65
65
  extendStatics = Object.setPrototypeOf ||
@@ -100,8 +100,8 @@ function __rest(s, e) {
100
100
  }
101
101
 
102
102
  function __generator(thisArg, body) {
103
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
104
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
103
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
104
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
105
105
  function verb(n) { return function (v) { return step([n, v]); }; }
106
106
  function step(op) {
107
107
  if (f) throw new TypeError("Generator is already executing.");
@@ -1797,7 +1797,9 @@ var ObjectNode = /** @class */ (function (_super) {
1797
1797
  if (!this.parent && newParent.root === this) {
1798
1798
  throw new MstError("A state tree is not allowed to contain itself. Cannot assign ".concat(this, " to path '").concat(newParent.path, "/").concat(subpath, "'"));
1799
1799
  }
1800
- if (!this.parent && !!this.environment && this.environment !== newParent.root.environment) {
1800
+ if (!this.parent &&
1801
+ !!this.environment &&
1802
+ this.environment !== newParent.root.environment) {
1801
1803
  throw new MstError("A state tree cannot be made part of another state tree as long as their environments are different.");
1802
1804
  }
1803
1805
  }
@@ -1821,7 +1823,9 @@ var ObjectNode = /** @class */ (function (_super) {
1821
1823
  value: function (name) {
1822
1824
  var _this = this;
1823
1825
  this.fireInternalHook(name);
1824
- var fn = this.storedValue && typeof this.storedValue === "object" && this.storedValue[name];
1826
+ var fn = this.storedValue &&
1827
+ typeof this.storedValue === "object" &&
1828
+ this.storedValue[name];
1825
1829
  if (typeof fn === "function") {
1826
1830
  // we check for it to allow old mobx peer dependencies that don't have the method to work (even when still bugged)
1827
1831
  if (_allowStateChangesInsideComputed) {
@@ -1926,7 +1930,8 @@ var ObjectNode = /** @class */ (function (_super) {
1926
1930
  var actionFullPath = "";
1927
1931
  if (actionContext && actionContext.name != null) {
1928
1932
  // try to use the context, and if it not available use the node one
1929
- var actionPath = (actionContext && actionContext.context && getPath(actionContext.context)) || escapedPath;
1933
+ var actionPath = (actionContext && actionContext.context && getPath(actionContext.context)) ||
1934
+ escapedPath;
1930
1935
  actionFullPath = "".concat(actionPath, ".").concat(actionContext.name, "()");
1931
1936
  }
1932
1937
  return "You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name, "', Path upon death: '").concat(escapedPath, "', Subpath: '").concat(subpath, "', Action: '").concat(actionFullPath, "'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.");
@@ -2561,7 +2566,8 @@ var ComplexType = /** @class */ (function (_super) {
2561
2566
  writable: true,
2562
2567
  value: function (current, snapshot) {
2563
2568
  return (!current.identifierAttribute ||
2564
- current.identifier === normalizeIdentifier(snapshot[current.identifierAttribute]));
2569
+ current.identifier ===
2570
+ normalizeIdentifier(snapshot[current.identifierAttribute]));
2565
2571
  }
2566
2572
  });
2567
2573
  Object.defineProperty(ComplexType.prototype, "tryToReconcileNode", {
@@ -2959,7 +2965,8 @@ function serializeArgument(node, actionName, index, arg) {
2959
2965
  if (typeof arg === "function")
2960
2966
  return serializeTheUnserializable("[function]");
2961
2967
  if (typeof arg === "object" && !isPlainObject(arg) && !isArray(arg))
2962
- return serializeTheUnserializable("[object ".concat((arg && arg.constructor && arg.constructor.name) || "Complex Object", "]"));
2968
+ return serializeTheUnserializable("[object ".concat((arg && arg.constructor && arg.constructor.name) ||
2969
+ "Complex Object", "]"));
2963
2970
  try {
2964
2971
  // Check if serializable, cycle free etc...
2965
2972
  // MWE: there must be a better way....
@@ -3215,7 +3222,8 @@ function createActionInvoker(target, name, fn) {
3215
3222
  tree: getRoot(target),
3216
3223
  rootId: parentContext ? parentContext.rootId : id,
3217
3224
  parentId: parentContext ? parentContext.id : 0,
3218
- allParentIds: parentContext ? __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false) : [],
3225
+ allParentIds: parentContext
3226
+ ? __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false) : [],
3219
3227
  parentEvent: parentContext,
3220
3228
  parentActionEvent: parentActionContext
3221
3229
  }, fn);
@@ -3809,7 +3817,7 @@ function getRelativePathBetweenNodes(base, target) {
3809
3817
  break;
3810
3818
  }
3811
3819
  // TODO: assert that no targetParts paths are "..", "." or ""!
3812
- return baseParts.slice(common).map(doubleDot).join("/") + joinJsonPath(targetParts.slice(common));
3820
+ return (baseParts.slice(common).map(doubleDot).join("/") + joinJsonPath(targetParts.slice(common)));
3813
3821
  }
3814
3822
  /**
3815
3823
  * @internal
@@ -4057,7 +4065,8 @@ function deepFreeze(value) {
4057
4065
  freeze(value);
4058
4066
  if (isPlainObject(value)) {
4059
4067
  Object.keys(value).forEach(function (propKey) {
4060
- if (!isPrimitive(value[propKey]) && !Object.isFrozen(value[propKey])) {
4068
+ if (!isPrimitive(value[propKey]) &&
4069
+ !Object.isFrozen(value[propKey])) {
4061
4070
  deepFreeze(value[propKey]);
4062
4071
  }
4063
4072
  });
@@ -6125,11 +6134,16 @@ var ModelType = /** @class */ (function (_super) {
6125
6134
  configurable: true,
6126
6135
  writable: true,
6127
6136
  value: function (self, actions) {
6137
+ var _this = this;
6128
6138
  // check if return is correct
6129
- if (!isPlainObject(actions))
6139
+ if (!isPlainObject(actions)) {
6130
6140
  throw new MstError("actions initializer should return a plain object containing actions");
6141
+ }
6131
6142
  // bind actions to the object created
6132
- Object.keys(actions).forEach(function (name) {
6143
+ Object.getOwnPropertyNames(actions).forEach(function (name) {
6144
+ if (name in _this.properties) {
6145
+ throw new MstError("'".concat(name, "' is a property and cannot be declared as an action"));
6146
+ }
6133
6147
  // warn if preprocessor was given
6134
6148
  if (name === PRE_PROCESS_SNAPSHOT)
6135
6149
  throw new MstError("Cannot define action '".concat(PRE_PROCESS_SNAPSHOT, "', it should be defined using 'type.preProcessSnapshot(fn)' instead"));
@@ -6179,10 +6193,17 @@ var ModelType = /** @class */ (function (_super) {
6179
6193
  configurable: true,
6180
6194
  writable: true,
6181
6195
  value: function (self, state) {
6196
+ var _this = this;
6182
6197
  // check views return
6183
- if (!isPlainObject(state))
6198
+ if (!isPlainObject(state)) {
6184
6199
  throw new MstError("volatile state initializer should return a plain object containing state");
6185
- set(self, state);
6200
+ }
6201
+ Object.getOwnPropertyNames(state).forEach(function (name) {
6202
+ if (name in _this.properties) {
6203
+ throw new MstError("'".concat(name, "' is a property and cannot be declared as volatile state"));
6204
+ }
6205
+ set(self, name, state[name]);
6206
+ });
6186
6207
  }
6187
6208
  });
6188
6209
  Object.defineProperty(ModelType.prototype, "extend", {
@@ -6224,19 +6245,24 @@ var ModelType = /** @class */ (function (_super) {
6224
6245
  configurable: true,
6225
6246
  writable: true,
6226
6247
  value: function (self, views) {
6248
+ var _this = this;
6227
6249
  // check views return
6228
- if (!isPlainObject(views))
6250
+ if (!isPlainObject(views)) {
6229
6251
  throw new MstError("views initializer should return a plain object containing views");
6230
- Object.getOwnPropertyNames(views).forEach(function (key) {
6252
+ }
6253
+ Object.getOwnPropertyNames(views).forEach(function (name) {
6231
6254
  var _a;
6255
+ if (name in _this.properties) {
6256
+ throw new MstError("'".concat(name, "' is a property and cannot be declared as a view"));
6257
+ }
6232
6258
  // is this a computed property?
6233
- var descriptor = Object.getOwnPropertyDescriptor(views, key);
6259
+ var descriptor = Object.getOwnPropertyDescriptor(views, name);
6234
6260
  if ("get" in descriptor) {
6235
- defineProperty$1(self, key, descriptor);
6236
- makeObservable(self, (_a = {}, _a[key] = computed, _a));
6261
+ defineProperty$1(self, name, descriptor);
6262
+ makeObservable(self, (_a = {}, _a[name] = computed, _a));
6237
6263
  }
6238
6264
  else if (typeof descriptor.value === "function") {
6239
- (!devMode() ? addHiddenFinalProp : addHiddenWritableProp)(self, key, descriptor.value);
6265
+ (!devMode() ? addHiddenFinalProp : addHiddenWritableProp)(self, name, descriptor.value);
6240
6266
  }
6241
6267
  else {
6242
6268
  throw new MstError("A view member should either be a function or getter based property");
@@ -6372,14 +6398,9 @@ var ModelType = /** @class */ (function (_super) {
6372
6398
  if (applyPostProcess === void 0) { applyPostProcess = true; }
6373
6399
  var res = {};
6374
6400
  this.forAllProps(function (name, type) {
6375
- try {
6376
- // TODO: FIXME, make sure the observable ref is used!
6377
- var atom = getAtom(node.storedValue, name);
6378
- atom.reportObserved();
6379
- }
6380
- catch (e) {
6381
- throw new MstError("".concat(name, " property is declared twice"));
6382
- }
6401
+ // TODO: FIXME, make sure the observable ref is used!
6402
+ var atom = getAtom(node.storedValue, name);
6403
+ atom.reportObserved();
6383
6404
  res[name] = _this.getChildNode(node, name).snapshot;
6384
6405
  });
6385
6406
  if (applyPostProcess) {
@@ -6972,7 +6993,9 @@ function refinement() {
6972
6993
  var name = typeof args[0] === "string" ? args.shift() : isType(args[0]) ? args[0].name : null;
6973
6994
  var type = args[0];
6974
6995
  var predicate = args[1];
6975
- var message = args[2] ? args[2] : function (v) { return "Value does not respect the refinement predicate"; };
6996
+ var message = args[2]
6997
+ ? args[2]
6998
+ : function (v) { return "Value does not respect the refinement predicate"; };
6976
6999
  // ensures all parameters are correct
6977
7000
  assertIsType(type, [1, 2]);
6978
7001
  assertIsString(name, 1);
@@ -7173,7 +7196,7 @@ function union(optionsOrType) {
7173
7196
  otherTypes[_i - 1] = arguments[_i];
7174
7197
  }
7175
7198
  var options = isType(optionsOrType) ? undefined : optionsOrType;
7176
- var types = isType(optionsOrType) ? __spreadArray([optionsOrType], __read(otherTypes), false) : otherTypes;
7199
+ var types = (isType(optionsOrType) ? __spreadArray([optionsOrType], __read(otherTypes), false) : otherTypes);
7177
7200
  var name = "(" + types.map(function (type) { return type.name; }).join(" | ") + ")";
7178
7201
  // check all options
7179
7202
  if (devMode()) {
@@ -7594,7 +7617,8 @@ var Lazy = /** @class */ (function (_super) {
7594
7617
  when(function () {
7595
7618
  return _this.pendingNodeList.length > 0 &&
7596
7619
  _this.pendingNodeList.some(function (node) {
7597
- return node.isAlive && _this.options.shouldLoadPredicate(node.parent ? node.parent.value : null);
7620
+ return node.isAlive &&
7621
+ _this.options.shouldLoadPredicate(node.parent ? node.parent.value : null);
7598
7622
  });
7599
7623
  }, function () {
7600
7624
  _this.options.loadType().then(action(function (type) {
@@ -8108,7 +8132,9 @@ var IdentifierReferenceType = /** @class */ (function (_super) {
8108
8132
  configurable: true,
8109
8133
  writable: true,
8110
8134
  value: function (parent, subpath, environment, initialValue) {
8111
- var identifier = isStateTreeNode(initialValue) ? getIdentifier(initialValue) : initialValue;
8135
+ var identifier = isStateTreeNode(initialValue)
8136
+ ? getIdentifier(initialValue)
8137
+ : initialValue;
8112
8138
  var storedRef = new StoredReference(initialValue, this.targetType);
8113
8139
  var storedRefNode = createScalarNode(this, parent, subpath, environment, storedRef);
8114
8140
  storedRef.node = storedRefNode;
@@ -8193,7 +8219,9 @@ var CustomReferenceType = /** @class */ (function (_super) {
8193
8219
  var newIdentifier = isStateTreeNode(newValue)
8194
8220
  ? this.options.set(newValue, current ? current.storedValue : null)
8195
8221
  : newValue;
8196
- if (!current.isDetaching && current.type === this && current.storedValue === newIdentifier) {
8222
+ if (!current.isDetaching &&
8223
+ current.type === this &&
8224
+ current.storedValue === newIdentifier) {
8197
8225
  current.setParent(parent, subpath);
8198
8226
  return current;
8199
8227
  }
@@ -63,7 +63,7 @@
63
63
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
64
64
  PERFORMANCE OF THIS SOFTWARE.
65
65
  ***************************************************************************** */
66
- /* global Reflect, Promise, SuppressedError, Symbol */
66
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
67
67
 
68
68
  var extendStatics = function(d, b) {
69
69
  extendStatics = Object.setPrototypeOf ||
@@ -104,8 +104,8 @@
104
104
  }
105
105
 
106
106
  function __generator(thisArg, body) {
107
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
108
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
107
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
108
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
109
109
  function verb(n) { return function (v) { return step([n, v]); }; }
110
110
  function step(op) {
111
111
  if (f) throw new TypeError("Generator is already executing.");
@@ -1801,7 +1801,9 @@
1801
1801
  if (!this.parent && newParent.root === this) {
1802
1802
  throw new MstError("A state tree is not allowed to contain itself. Cannot assign ".concat(this, " to path '").concat(newParent.path, "/").concat(subpath, "'"));
1803
1803
  }
1804
- if (!this.parent && !!this.environment && this.environment !== newParent.root.environment) {
1804
+ if (!this.parent &&
1805
+ !!this.environment &&
1806
+ this.environment !== newParent.root.environment) {
1805
1807
  throw new MstError("A state tree cannot be made part of another state tree as long as their environments are different.");
1806
1808
  }
1807
1809
  }
@@ -1825,7 +1827,9 @@
1825
1827
  value: function (name) {
1826
1828
  var _this = this;
1827
1829
  this.fireInternalHook(name);
1828
- var fn = this.storedValue && typeof this.storedValue === "object" && this.storedValue[name];
1830
+ var fn = this.storedValue &&
1831
+ typeof this.storedValue === "object" &&
1832
+ this.storedValue[name];
1829
1833
  if (typeof fn === "function") {
1830
1834
  // we check for it to allow old mobx peer dependencies that don't have the method to work (even when still bugged)
1831
1835
  if (mobx._allowStateChangesInsideComputed) {
@@ -1930,7 +1934,8 @@
1930
1934
  var actionFullPath = "";
1931
1935
  if (actionContext && actionContext.name != null) {
1932
1936
  // try to use the context, and if it not available use the node one
1933
- var actionPath = (actionContext && actionContext.context && getPath(actionContext.context)) || escapedPath;
1937
+ var actionPath = (actionContext && actionContext.context && getPath(actionContext.context)) ||
1938
+ escapedPath;
1934
1939
  actionFullPath = "".concat(actionPath, ".").concat(actionContext.name, "()");
1935
1940
  }
1936
1941
  return "You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name, "', Path upon death: '").concat(escapedPath, "', Subpath: '").concat(subpath, "', Action: '").concat(actionFullPath, "'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.");
@@ -2565,7 +2570,8 @@
2565
2570
  writable: true,
2566
2571
  value: function (current, snapshot) {
2567
2572
  return (!current.identifierAttribute ||
2568
- current.identifier === normalizeIdentifier(snapshot[current.identifierAttribute]));
2573
+ current.identifier ===
2574
+ normalizeIdentifier(snapshot[current.identifierAttribute]));
2569
2575
  }
2570
2576
  });
2571
2577
  Object.defineProperty(ComplexType.prototype, "tryToReconcileNode", {
@@ -2963,7 +2969,8 @@
2963
2969
  if (typeof arg === "function")
2964
2970
  return serializeTheUnserializable("[function]");
2965
2971
  if (typeof arg === "object" && !isPlainObject(arg) && !isArray(arg))
2966
- return serializeTheUnserializable("[object ".concat((arg && arg.constructor && arg.constructor.name) || "Complex Object", "]"));
2972
+ return serializeTheUnserializable("[object ".concat((arg && arg.constructor && arg.constructor.name) ||
2973
+ "Complex Object", "]"));
2967
2974
  try {
2968
2975
  // Check if serializable, cycle free etc...
2969
2976
  // MWE: there must be a better way....
@@ -3219,7 +3226,8 @@
3219
3226
  tree: getRoot(target),
3220
3227
  rootId: parentContext ? parentContext.rootId : id,
3221
3228
  parentId: parentContext ? parentContext.id : 0,
3222
- allParentIds: parentContext ? __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false) : [],
3229
+ allParentIds: parentContext
3230
+ ? __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false) : [],
3223
3231
  parentEvent: parentContext,
3224
3232
  parentActionEvent: parentActionContext
3225
3233
  }, fn);
@@ -3813,7 +3821,7 @@
3813
3821
  break;
3814
3822
  }
3815
3823
  // TODO: assert that no targetParts paths are "..", "." or ""!
3816
- return baseParts.slice(common).map(doubleDot).join("/") + joinJsonPath(targetParts.slice(common));
3824
+ return (baseParts.slice(common).map(doubleDot).join("/") + joinJsonPath(targetParts.slice(common)));
3817
3825
  }
3818
3826
  /**
3819
3827
  * @internal
@@ -4057,7 +4065,8 @@
4057
4065
  freeze(value);
4058
4066
  if (isPlainObject(value)) {
4059
4067
  Object.keys(value).forEach(function (propKey) {
4060
- if (!isPrimitive(value[propKey]) && !Object.isFrozen(value[propKey])) {
4068
+ if (!isPrimitive(value[propKey]) &&
4069
+ !Object.isFrozen(value[propKey])) {
4061
4070
  deepFreeze(value[propKey]);
4062
4071
  }
4063
4072
  });
@@ -6107,11 +6116,16 @@
6107
6116
  configurable: true,
6108
6117
  writable: true,
6109
6118
  value: function (self, actions) {
6119
+ var _this = this;
6110
6120
  // check if return is correct
6111
- if (!isPlainObject(actions))
6121
+ if (!isPlainObject(actions)) {
6112
6122
  throw new MstError("actions initializer should return a plain object containing actions");
6123
+ }
6113
6124
  // bind actions to the object created
6114
- Object.keys(actions).forEach(function (name) {
6125
+ Object.getOwnPropertyNames(actions).forEach(function (name) {
6126
+ if (name in _this.properties) {
6127
+ throw new MstError("'".concat(name, "' is a property and cannot be declared as an action"));
6128
+ }
6115
6129
  // warn if preprocessor was given
6116
6130
  if (name === PRE_PROCESS_SNAPSHOT)
6117
6131
  throw new MstError("Cannot define action '".concat(PRE_PROCESS_SNAPSHOT, "', it should be defined using 'type.preProcessSnapshot(fn)' instead"));
@@ -6161,10 +6175,17 @@
6161
6175
  configurable: true,
6162
6176
  writable: true,
6163
6177
  value: function (self, state) {
6178
+ var _this = this;
6164
6179
  // check views return
6165
- if (!isPlainObject(state))
6180
+ if (!isPlainObject(state)) {
6166
6181
  throw new MstError("volatile state initializer should return a plain object containing state");
6167
- mobx.set(self, state);
6182
+ }
6183
+ Object.getOwnPropertyNames(state).forEach(function (name) {
6184
+ if (name in _this.properties) {
6185
+ throw new MstError("'".concat(name, "' is a property and cannot be declared as volatile state"));
6186
+ }
6187
+ mobx.set(self, name, state[name]);
6188
+ });
6168
6189
  }
6169
6190
  });
6170
6191
  Object.defineProperty(ModelType.prototype, "extend", {
@@ -6206,19 +6227,24 @@
6206
6227
  configurable: true,
6207
6228
  writable: true,
6208
6229
  value: function (self, views) {
6230
+ var _this = this;
6209
6231
  // check views return
6210
- if (!isPlainObject(views))
6232
+ if (!isPlainObject(views)) {
6211
6233
  throw new MstError("views initializer should return a plain object containing views");
6212
- Object.getOwnPropertyNames(views).forEach(function (key) {
6234
+ }
6235
+ Object.getOwnPropertyNames(views).forEach(function (name) {
6213
6236
  var _a;
6237
+ if (name in _this.properties) {
6238
+ throw new MstError("'".concat(name, "' is a property and cannot be declared as a view"));
6239
+ }
6214
6240
  // is this a computed property?
6215
- var descriptor = Object.getOwnPropertyDescriptor(views, key);
6241
+ var descriptor = Object.getOwnPropertyDescriptor(views, name);
6216
6242
  if ("get" in descriptor) {
6217
- mobx.defineProperty(self, key, descriptor);
6218
- mobx.makeObservable(self, (_a = {}, _a[key] = mobx.computed, _a));
6243
+ mobx.defineProperty(self, name, descriptor);
6244
+ mobx.makeObservable(self, (_a = {}, _a[name] = mobx.computed, _a));
6219
6245
  }
6220
6246
  else if (typeof descriptor.value === "function") {
6221
- (addHiddenWritableProp)(self, key, descriptor.value);
6247
+ (addHiddenWritableProp)(self, name, descriptor.value);
6222
6248
  }
6223
6249
  else {
6224
6250
  throw new MstError("A view member should either be a function or getter based property");
@@ -6354,14 +6380,9 @@
6354
6380
  if (applyPostProcess === void 0) { applyPostProcess = true; }
6355
6381
  var res = {};
6356
6382
  this.forAllProps(function (name, type) {
6357
- try {
6358
- // TODO: FIXME, make sure the observable ref is used!
6359
- var atom = mobx.getAtom(node.storedValue, name);
6360
- atom.reportObserved();
6361
- }
6362
- catch (e) {
6363
- throw new MstError("".concat(name, " property is declared twice"));
6364
- }
6383
+ // TODO: FIXME, make sure the observable ref is used!
6384
+ var atom = mobx.getAtom(node.storedValue, name);
6385
+ atom.reportObserved();
6365
6386
  res[name] = _this.getChildNode(node, name).snapshot;
6366
6387
  });
6367
6388
  if (applyPostProcess) {
@@ -6954,7 +6975,9 @@
6954
6975
  var name = typeof args[0] === "string" ? args.shift() : isType(args[0]) ? args[0].name : null;
6955
6976
  var type = args[0];
6956
6977
  var predicate = args[1];
6957
- var message = args[2] ? args[2] : function (v) { return "Value does not respect the refinement predicate"; };
6978
+ var message = args[2]
6979
+ ? args[2]
6980
+ : function (v) { return "Value does not respect the refinement predicate"; };
6958
6981
  // ensures all parameters are correct
6959
6982
  assertIsType(type, [1, 2]);
6960
6983
  assertIsString(name, 1);
@@ -7155,7 +7178,7 @@
7155
7178
  otherTypes[_i - 1] = arguments[_i];
7156
7179
  }
7157
7180
  var options = isType(optionsOrType) ? undefined : optionsOrType;
7158
- var types = isType(optionsOrType) ? __spreadArray([optionsOrType], __read(otherTypes), false) : otherTypes;
7181
+ var types = (isType(optionsOrType) ? __spreadArray([optionsOrType], __read(otherTypes), false) : otherTypes);
7159
7182
  var name = "(" + types.map(function (type) { return type.name; }).join(" | ") + ")";
7160
7183
  // check all options
7161
7184
  {
@@ -7576,7 +7599,8 @@
7576
7599
  mobx.when(function () {
7577
7600
  return _this.pendingNodeList.length > 0 &&
7578
7601
  _this.pendingNodeList.some(function (node) {
7579
- return node.isAlive && _this.options.shouldLoadPredicate(node.parent ? node.parent.value : null);
7602
+ return node.isAlive &&
7603
+ _this.options.shouldLoadPredicate(node.parent ? node.parent.value : null);
7580
7604
  });
7581
7605
  }, function () {
7582
7606
  _this.options.loadType().then(mobx.action(function (type) {
@@ -8090,7 +8114,9 @@
8090
8114
  configurable: true,
8091
8115
  writable: true,
8092
8116
  value: function (parent, subpath, environment, initialValue) {
8093
- var identifier = isStateTreeNode(initialValue) ? getIdentifier(initialValue) : initialValue;
8117
+ var identifier = isStateTreeNode(initialValue)
8118
+ ? getIdentifier(initialValue)
8119
+ : initialValue;
8094
8120
  var storedRef = new StoredReference(initialValue, this.targetType);
8095
8121
  var storedRefNode = createScalarNode(this, parent, subpath, environment, storedRef);
8096
8122
  storedRef.node = storedRefNode;
@@ -8175,7 +8201,9 @@
8175
8201
  var newIdentifier = isStateTreeNode(newValue)
8176
8202
  ? this.options.set(newValue, current ? current.storedValue : null)
8177
8203
  : newValue;
8178
- if (!current.isDetaching && current.type === this && current.storedValue === newIdentifier) {
8204
+ if (!current.isDetaching &&
8205
+ current.type === this &&
8206
+ current.storedValue === newIdentifier) {
8179
8207
  current.setParent(parent, subpath);
8180
8208
  return current;
8181
8209
  }