mobx-state-tree 5.4.0 → 5.4.2-pre.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.
@@ -49,7 +49,7 @@ var Hook;
49
49
  Hook["beforeDestroy"] = "beforeDestroy";
50
50
  })(Hook || (Hook = {}));
51
51
 
52
- /*! *****************************************************************************
52
+ /******************************************************************************
53
53
  Copyright (c) Microsoft Corporation.
54
54
 
55
55
  Permission to use, copy, modify, and/or distribute this software for any
@@ -63,7 +63,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
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 */
66
+ /* global Reflect, Promise, SuppressedError, Symbol */
67
67
 
68
68
  var extendStatics = function(d, b) {
69
69
  extendStatics = Object.setPrototypeOf ||
@@ -109,7 +109,7 @@ function __generator(thisArg, body) {
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.");
112
- while (_) try {
112
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
113
113
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
114
114
  if (y = 0, t) op = [op[0] & 2, t.value];
115
115
  switch (op[0]) {
@@ -160,12 +160,20 @@ function __read(o, n) {
160
160
  return ar;
161
161
  }
162
162
 
163
- /** @deprecated */
164
- function __spread() {
165
- for (var ar = [], i = 0; i < arguments.length; i++)
166
- ar = ar.concat(__read(arguments[i]));
167
- return ar;
168
- }
163
+ function __spreadArray(to, from, pack) {
164
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
165
+ if (ar || !(i in from)) {
166
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
167
+ ar[i] = from[i];
168
+ }
169
+ }
170
+ return to.concat(ar || Array.prototype.slice.call(from));
171
+ }
172
+
173
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
174
+ var e = new Error(message);
175
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
176
+ };
169
177
 
170
178
  /**
171
179
  * Returns the _actual_ type of the given tree node. (Or throws)
@@ -348,7 +356,7 @@ function protect(target) {
348
356
  assertIsStateTreeNode(target, 1);
349
357
  var node = getStateTreeNode(target);
350
358
  if (!node.isRoot)
351
- throw fail$1("`protect` can only be invoked on root nodes");
359
+ throw fail("`protect` can only be invoked on root nodes");
352
360
  node.isProtectionEnabled = true;
353
361
  }
354
362
  /**
@@ -380,7 +388,7 @@ function unprotect(target) {
380
388
  assertIsStateTreeNode(target, 1);
381
389
  var node = getStateTreeNode(target);
382
390
  if (!node.isRoot)
383
- throw fail$1("`unprotect` can only be invoked on root nodes");
391
+ throw fail("`unprotect` can only be invoked on root nodes");
384
392
  node.isProtectionEnabled = false;
385
393
  }
386
394
  /**
@@ -463,7 +471,7 @@ function getParent(target, depth) {
463
471
  return parent.storedValue;
464
472
  parent = parent.parent;
465
473
  }
466
- throw fail$1("Failed to find the parent of " + getStateTreeNode(target) + " at depth " + depth);
474
+ throw fail("Failed to find the parent of ".concat(getStateTreeNode(target), " at depth ").concat(depth));
467
475
  }
468
476
  /**
469
477
  * Given a model instance, returns `true` if the object has a parent of given type, that is, is part of another object, map or array
@@ -501,7 +509,7 @@ function getParentOfType(target, type) {
501
509
  return parent.storedValue;
502
510
  parent = parent.parent;
503
511
  }
504
- throw fail$1("Failed to find the parent of " + getStateTreeNode(target) + " of a given type");
512
+ throw fail("Failed to find the parent of ".concat(getStateTreeNode(target), " of a given type"));
505
513
  }
506
514
  /**
507
515
  * Given an object in a model tree, returns the root object of that tree.
@@ -618,7 +626,7 @@ function tryReference(getter, checkIfAlive) {
618
626
  }
619
627
  }
620
628
  else {
621
- throw fail$1("The reference to be checked is not one of node, null or undefined");
629
+ throw fail("The reference to be checked is not one of node, null or undefined");
622
630
  }
623
631
  }
624
632
  catch (e) {
@@ -646,7 +654,7 @@ function isValidReference(getter, checkIfAlive) {
646
654
  return checkIfAlive ? isAlive(node) : true;
647
655
  }
648
656
  else {
649
- throw fail$1("The reference to be checked is not one of node, null or undefined");
657
+ throw fail("The reference to be checked is not one of node, null or undefined");
650
658
  }
651
659
  }
652
660
  catch (e) {
@@ -1301,7 +1309,7 @@ var ScalarNode = /** @class */ (function (_super) {
1301
1309
  get: function () {
1302
1310
  // future optimization: store root ref in the node and maintain it
1303
1311
  if (!this.parent)
1304
- throw fail$1("This scalar node is not part of a tree");
1312
+ throw fail("This scalar node is not part of a tree");
1305
1313
  return this.parent.root;
1306
1314
  },
1307
1315
  enumerable: false,
@@ -1320,15 +1328,15 @@ var ScalarNode = /** @class */ (function (_super) {
1320
1328
  if (devMode()) {
1321
1329
  if (!subpath) {
1322
1330
  // istanbul ignore next
1323
- throw fail$1("assertion failed: subpath expected");
1331
+ throw fail("assertion failed: subpath expected");
1324
1332
  }
1325
1333
  if (!newParent) {
1326
1334
  // istanbul ignore next
1327
- throw fail$1("assertion failed: parent expected");
1335
+ throw fail("assertion failed: parent expected");
1328
1336
  }
1329
1337
  if (parentChanged) {
1330
1338
  // istanbul ignore next
1331
- throw fail$1("assertion failed: scalar nodes cannot change their parent");
1339
+ throw fail("assertion failed: scalar nodes cannot change their parent");
1332
1340
  }
1333
1341
  }
1334
1342
  this.environment = undefined; // use parent's
@@ -1356,7 +1364,7 @@ var ScalarNode = /** @class */ (function (_super) {
1356
1364
  writable: true,
1357
1365
  value: function () {
1358
1366
  var path = (this.isAlive ? this.path : this.pathUponDeath) || "<root>";
1359
- return this.type.name + "@" + path + (this.isAlive ? "" : " [dead]");
1367
+ return "".concat(this.type.name, "@").concat(path).concat(this.isAlive ? "" : " [dead]");
1360
1368
  }
1361
1369
  });
1362
1370
  Object.defineProperty(ScalarNode.prototype, "die", {
@@ -1502,7 +1510,7 @@ var ObjectNode = /** @class */ (function (_super) {
1502
1510
  enumerable: true,
1503
1511
  configurable: true,
1504
1512
  writable: true,
1505
- value: 0 /* UNINITIALIZED */
1513
+ value: 0 /* ObservableInstanceLifecycle.UNINITIALIZED */
1506
1514
  });
1507
1515
  Object.defineProperty(_this, "_childNodes", {
1508
1516
  enumerable: true,
@@ -1569,7 +1577,7 @@ var ObjectNode = /** @class */ (function (_super) {
1569
1577
  }
1570
1578
  }
1571
1579
  if (typeof id !== "string" && typeof id !== "number") {
1572
- throw fail$1("Instance identifier '" + _this.identifierAttribute + "' for type '" + _this.type.name + "' must be a string or a number");
1580
+ throw fail("Instance identifier '".concat(_this.identifierAttribute, "' for type '").concat(_this.type.name, "' must be a string or a number"));
1573
1581
  }
1574
1582
  // normalize internal identifier to string
1575
1583
  _this.identifier = normalizeIdentifier(id);
@@ -1607,7 +1615,7 @@ var ObjectNode = /** @class */ (function (_super) {
1607
1615
  writable: true,
1608
1616
  value: function (fireHooks) {
1609
1617
  if (fireHooks === void 0) { fireHooks = true; }
1610
- if (this._observableInstanceState === 0 /* UNINITIALIZED */) {
1618
+ if (this._observableInstanceState === 0 /* ObservableInstanceLifecycle.UNINITIALIZED */) {
1611
1619
  this.createObservableInstance(fireHooks);
1612
1620
  }
1613
1621
  }
@@ -1622,10 +1630,10 @@ var ObjectNode = /** @class */ (function (_super) {
1622
1630
  if (devMode()) {
1623
1631
  if (this.state !== NodeLifeCycle.INITIALIZING) {
1624
1632
  // istanbul ignore next
1625
- throw fail$1("assertion failed: the creation of the observable instance must be done on the initializing phase");
1633
+ throw fail("assertion failed: the creation of the observable instance must be done on the initializing phase");
1626
1634
  }
1627
1635
  }
1628
- this._observableInstanceState = 1 /* CREATING */;
1636
+ this._observableInstanceState = 1 /* ObservableInstanceLifecycle.CREATING */;
1629
1637
  // make sure the parent chain is created as well
1630
1638
  // array with parent chain from parent to child
1631
1639
  var parentChain = [];
@@ -1635,7 +1643,7 @@ var ObjectNode = /** @class */ (function (_super) {
1635
1643
  // this is done to avoid traversing the whole tree to the root when using
1636
1644
  // the same reference again
1637
1645
  while (parent &&
1638
- parent._observableInstanceState === 0 /* UNINITIALIZED */) {
1646
+ parent._observableInstanceState === 0 /* ObservableInstanceLifecycle.UNINITIALIZED */) {
1639
1647
  parentChain.unshift(parent);
1640
1648
  parent = parent.parent;
1641
1649
  }
@@ -1669,7 +1677,7 @@ var ObjectNode = /** @class */ (function (_super) {
1669
1677
  finally {
1670
1678
  this._isRunningAction = false;
1671
1679
  }
1672
- this._observableInstanceState = 2 /* CREATED */;
1680
+ this._observableInstanceState = 2 /* ObservableInstanceLifecycle.CREATED */;
1673
1681
  this._snapshotComputed.trackAndCompute();
1674
1682
  if (this.isRoot)
1675
1683
  this._addSnapshotReaction();
@@ -1745,20 +1753,20 @@ var ObjectNode = /** @class */ (function (_super) {
1745
1753
  if (devMode()) {
1746
1754
  if (!subpath) {
1747
1755
  // istanbul ignore next
1748
- throw fail$1("assertion failed: subpath expected");
1756
+ throw fail("assertion failed: subpath expected");
1749
1757
  }
1750
1758
  if (!newParent) {
1751
1759
  // istanbul ignore next
1752
- throw fail$1("assertion failed: new parent expected");
1760
+ throw fail("assertion failed: new parent expected");
1753
1761
  }
1754
1762
  if (this.parent && parentChanged) {
1755
- throw fail$1("A node cannot exists twice in the state tree. Failed to add " + this + " to path '" + newParent.path + "/" + subpath + "'.");
1763
+ throw fail("A node cannot exists twice in the state tree. Failed to add ".concat(this, " to path '").concat(newParent.path, "/").concat(subpath, "'."));
1756
1764
  }
1757
1765
  if (!this.parent && newParent.root === this) {
1758
- throw fail$1("A state tree is not allowed to contain itself. Cannot assign " + this + " to path '" + newParent.path + "/" + subpath + "'");
1766
+ throw fail("A state tree is not allowed to contain itself. Cannot assign ".concat(this, " to path '").concat(newParent.path, "/").concat(subpath, "'"));
1759
1767
  }
1760
1768
  if (!this.parent && !!this.environment && this.environment !== newParent.root.environment) {
1761
- throw fail$1("A state tree cannot be made part of another state tree as long as their environments are different.");
1769
+ throw fail("A state tree cannot be made part of another state tree as long as their environments are different.");
1762
1770
  }
1763
1771
  }
1764
1772
  if (parentChanged) {
@@ -1814,7 +1822,7 @@ var ObjectNode = /** @class */ (function (_super) {
1814
1822
  value: function () {
1815
1823
  if (!this.isAlive)
1816
1824
  return this._snapshotUponDeath;
1817
- return this._observableInstanceState === 2 /* CREATED */
1825
+ return this._observableInstanceState === 2 /* ObservableInstanceLifecycle.CREATED */
1818
1826
  ? this._getActualSnapshot()
1819
1827
  : this._getCachedInitialSnapshot();
1820
1828
  }
@@ -1864,7 +1872,7 @@ var ObjectNode = /** @class */ (function (_super) {
1864
1872
  var error = this._getAssertAliveError(context);
1865
1873
  switch (livelinessChecking) {
1866
1874
  case "error":
1867
- throw fail$1(error);
1875
+ throw fail(error);
1868
1876
  case "warn":
1869
1877
  warnError(error);
1870
1878
  }
@@ -1887,9 +1895,9 @@ var ObjectNode = /** @class */ (function (_super) {
1887
1895
  if (actionContext && actionContext.name != null) {
1888
1896
  // try to use the context, and if it not available use the node one
1889
1897
  var actionPath = (actionContext && actionContext.context && getPath(actionContext.context)) || escapedPath;
1890
- actionFullPath = actionPath + "." + actionContext.name + "()";
1898
+ actionFullPath = "".concat(actionPath, ".").concat(actionContext.name, "()");
1891
1899
  }
1892
- return "You are trying to read or write to an object that is no longer part of a state tree. (Object type: '" + this.type.name + "', Path upon death: '" + escapedPath + "', Subpath: '" + subpath + "', Action: '" + actionFullPath + "'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";
1900
+ 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.");
1893
1901
  }
1894
1902
  });
1895
1903
  Object.defineProperty(ObjectNode.prototype, "getChildNode", {
@@ -1902,7 +1910,7 @@ var ObjectNode = /** @class */ (function (_super) {
1902
1910
  });
1903
1911
  this._autoUnbox = false;
1904
1912
  try {
1905
- return this._observableInstanceState === 2 /* CREATED */
1913
+ return this._observableInstanceState === 2 /* ObservableInstanceLifecycle.CREATED */
1906
1914
  ? this.type.getChildNode(this, subpath)
1907
1915
  : this._childNodes[subpath];
1908
1916
  }
@@ -1919,7 +1927,7 @@ var ObjectNode = /** @class */ (function (_super) {
1919
1927
  this.assertAlive(EMPTY_OBJECT);
1920
1928
  this._autoUnbox = false;
1921
1929
  try {
1922
- return this._observableInstanceState === 2 /* CREATED */
1930
+ return this._observableInstanceState === 2 /* ObservableInstanceLifecycle.CREATED */
1923
1931
  ? this.type.getChildren(this)
1924
1932
  : convertChildNodesToArray(this._childNodes);
1925
1933
  }
@@ -1950,7 +1958,7 @@ var ObjectNode = /** @class */ (function (_super) {
1950
1958
  value: function (context) {
1951
1959
  this.assertAlive(context);
1952
1960
  if (!this.isRunningAction() && this.isProtected) {
1953
- throw fail$1("Cannot modify '" + this + "', the object is protected and can only be modified by using an action.");
1961
+ throw fail("Cannot modify '".concat(this, "', the object is protected and can only be modified by using an action."));
1954
1962
  }
1955
1963
  }
1956
1964
  });
@@ -1982,8 +1990,8 @@ var ObjectNode = /** @class */ (function (_super) {
1982
1990
  writable: true,
1983
1991
  value: function () {
1984
1992
  var path = (this.isAlive ? this.path : this.pathUponDeath) || "<root>";
1985
- var identifier = this.identifier ? "(id: " + this.identifier + ")" : "";
1986
- return this.type.name + "@" + path + identifier + (this.isAlive ? "" : " [dead]");
1993
+ var identifier = this.identifier ? "(id: ".concat(this.identifier, ")") : "";
1994
+ return "".concat(this.type.name, "@").concat(path).concat(identifier).concat(this.isAlive ? "" : " [dead]");
1987
1995
  }
1988
1996
  });
1989
1997
  Object.defineProperty(ObjectNode.prototype, "finalizeCreation", {
@@ -2017,7 +2025,7 @@ var ObjectNode = /** @class */ (function (_super) {
2017
2025
  writable: true,
2018
2026
  value: function () {
2019
2027
  if (!this.isAlive)
2020
- throw fail$1("Error while detaching, node is not alive.");
2028
+ throw fail("Error while detaching, node is not alive.");
2021
2029
  this.clearParent();
2022
2030
  }
2023
2031
  });
@@ -2065,7 +2073,7 @@ var ObjectNode = /** @class */ (function (_super) {
2065
2073
  configurable: true,
2066
2074
  writable: true,
2067
2075
  value: function () {
2068
- if (this._observableInstanceState === 0 /* UNINITIALIZED */) {
2076
+ if (this._observableInstanceState === 0 /* ObservableInstanceLifecycle.UNINITIALIZED */) {
2069
2077
  return;
2070
2078
  }
2071
2079
  this.getChildren().forEach(function (node) {
@@ -2074,8 +2082,8 @@ var ObjectNode = /** @class */ (function (_super) {
2074
2082
  // beforeDestroy should run before the disposers since else we could end up in a situation where
2075
2083
  // a disposer added with addDisposer at this stage (beforeDestroy) is actually never released
2076
2084
  this.baseAboutToDie();
2077
- this._internalEventsEmit("dispose" /* Dispose */);
2078
- this._internalEventsClear("dispose" /* Dispose */);
2085
+ this._internalEventsEmit("dispose" /* InternalEvents.Dispose */);
2086
+ this._internalEventsClear("dispose" /* InternalEvents.Dispose */);
2079
2087
  }
2080
2088
  });
2081
2089
  Object.defineProperty(ObjectNode.prototype, "finalizeDeath", {
@@ -2101,7 +2109,7 @@ var ObjectNode = /** @class */ (function (_super) {
2101
2109
  writable: true,
2102
2110
  value: function (onChange) {
2103
2111
  this._addSnapshotReaction();
2104
- return this._internalEventsRegister("snapshot" /* Snapshot */, onChange);
2112
+ return this._internalEventsRegister("snapshot" /* InternalEvents.Snapshot */, onChange);
2105
2113
  }
2106
2114
  });
2107
2115
  Object.defineProperty(ObjectNode.prototype, "emitSnapshot", {
@@ -2109,7 +2117,7 @@ var ObjectNode = /** @class */ (function (_super) {
2109
2117
  configurable: true,
2110
2118
  writable: true,
2111
2119
  value: function (snapshot) {
2112
- this._internalEventsEmit("snapshot" /* Snapshot */, snapshot);
2120
+ this._internalEventsEmit("snapshot" /* InternalEvents.Snapshot */, snapshot);
2113
2121
  }
2114
2122
  });
2115
2123
  Object.defineProperty(ObjectNode.prototype, "onPatch", {
@@ -2117,7 +2125,7 @@ var ObjectNode = /** @class */ (function (_super) {
2117
2125
  configurable: true,
2118
2126
  writable: true,
2119
2127
  value: function (handler) {
2120
- return this._internalEventsRegister("patch" /* Patch */, handler);
2128
+ return this._internalEventsRegister("patch" /* InternalEvents.Patch */, handler);
2121
2129
  }
2122
2130
  });
2123
2131
  Object.defineProperty(ObjectNode.prototype, "emitPatch", {
@@ -2125,12 +2133,12 @@ var ObjectNode = /** @class */ (function (_super) {
2125
2133
  configurable: true,
2126
2134
  writable: true,
2127
2135
  value: function (basePatch, source) {
2128
- if (this._internalEventsHasSubscribers("patch" /* Patch */)) {
2136
+ if (this._internalEventsHasSubscribers("patch" /* InternalEvents.Patch */)) {
2129
2137
  var localizedPatch = extend({}, basePatch, {
2130
2138
  path: source.path.substr(this.path.length) + "/" + basePatch.path // calculate the relative path of the patch
2131
2139
  });
2132
2140
  var _a = __read(splitPatch(localizedPatch), 2), patch = _a[0], reversePatch = _a[1];
2133
- this._internalEventsEmit("patch" /* Patch */, patch, reversePatch);
2141
+ this._internalEventsEmit("patch" /* InternalEvents.Patch */, patch, reversePatch);
2134
2142
  }
2135
2143
  if (this.parent)
2136
2144
  this.parent.emitPatch(basePatch, source);
@@ -2141,7 +2149,7 @@ var ObjectNode = /** @class */ (function (_super) {
2141
2149
  configurable: true,
2142
2150
  writable: true,
2143
2151
  value: function (disposer) {
2144
- return this._internalEventsHas("dispose" /* Dispose */, disposer);
2152
+ return this._internalEventsHas("dispose" /* InternalEvents.Dispose */, disposer);
2145
2153
  }
2146
2154
  });
2147
2155
  Object.defineProperty(ObjectNode.prototype, "addDisposer", {
@@ -2150,10 +2158,10 @@ var ObjectNode = /** @class */ (function (_super) {
2150
2158
  writable: true,
2151
2159
  value: function (disposer) {
2152
2160
  if (!this.hasDisposer(disposer)) {
2153
- this._internalEventsRegister("dispose" /* Dispose */, disposer, true);
2161
+ this._internalEventsRegister("dispose" /* InternalEvents.Dispose */, disposer, true);
2154
2162
  return;
2155
2163
  }
2156
- throw fail$1("cannot add a disposer when it is already registered for execution");
2164
+ throw fail("cannot add a disposer when it is already registered for execution");
2157
2165
  }
2158
2166
  });
2159
2167
  Object.defineProperty(ObjectNode.prototype, "removeDisposer", {
@@ -2161,10 +2169,10 @@ var ObjectNode = /** @class */ (function (_super) {
2161
2169
  configurable: true,
2162
2170
  writable: true,
2163
2171
  value: function (disposer) {
2164
- if (!this._internalEventsHas("dispose" /* Dispose */, disposer)) {
2165
- throw fail$1("cannot remove a disposer which was never registered for execution");
2172
+ if (!this._internalEventsHas("dispose" /* InternalEvents.Dispose */, disposer)) {
2173
+ throw fail("cannot remove a disposer which was never registered for execution");
2166
2174
  }
2167
- this._internalEventsUnregister("dispose" /* Dispose */, disposer);
2175
+ this._internalEventsUnregister("dispose" /* InternalEvents.Dispose */, disposer);
2168
2176
  }
2169
2177
  });
2170
2178
  Object.defineProperty(ObjectNode.prototype, "removeMiddleware", {
@@ -2272,7 +2280,7 @@ var ObjectNode = /** @class */ (function (_super) {
2272
2280
  args[_i - 1] = arguments[_i];
2273
2281
  }
2274
2282
  if (this._internalEvents) {
2275
- (_a = this._internalEvents).emit.apply(_a, __spread([event], args));
2283
+ (_a = this._internalEvents).emit.apply(_a, __spreadArray([event], __read(args), false));
2276
2284
  }
2277
2285
  }
2278
2286
  });
@@ -2408,7 +2416,7 @@ var BaseType = /** @class */ (function () {
2408
2416
  writable: true,
2409
2417
  value: function (node, applyPostProcess) {
2410
2418
  // istanbul ignore next
2411
- throw fail$1("unimplemented method");
2419
+ throw fail("unimplemented method");
2412
2420
  }
2413
2421
  });
2414
2422
  Object.defineProperty(BaseType.prototype, "isAssignableFrom", {
@@ -2446,7 +2454,7 @@ var BaseType = /** @class */ (function () {
2446
2454
  Object.defineProperty(BaseType.prototype, "Type", {
2447
2455
  get: function () {
2448
2456
  // istanbul ignore next
2449
- throw fail$1("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`");
2457
+ throw fail("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`");
2450
2458
  },
2451
2459
  enumerable: false,
2452
2460
  configurable: true
@@ -2454,7 +2462,7 @@ var BaseType = /** @class */ (function () {
2454
2462
  Object.defineProperty(BaseType.prototype, "TypeWithoutSTN", {
2455
2463
  get: function () {
2456
2464
  // istanbul ignore next
2457
- throw fail$1("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`");
2465
+ throw fail("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`");
2458
2466
  },
2459
2467
  enumerable: false,
2460
2468
  configurable: true
@@ -2462,7 +2470,7 @@ var BaseType = /** @class */ (function () {
2462
2470
  Object.defineProperty(BaseType.prototype, "SnapshotType", {
2463
2471
  get: function () {
2464
2472
  // istanbul ignore next
2465
- throw fail$1("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`");
2473
+ throw fail("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`");
2466
2474
  },
2467
2475
  enumerable: false,
2468
2476
  configurable: true
@@ -2470,7 +2478,7 @@ var BaseType = /** @class */ (function () {
2470
2478
  Object.defineProperty(BaseType.prototype, "CreationType", {
2471
2479
  get: function () {
2472
2480
  // istanbul ignore next
2473
- throw fail$1("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`");
2481
+ throw fail("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`");
2474
2482
  },
2475
2483
  enumerable: false,
2476
2484
  configurable: true
@@ -2915,11 +2923,11 @@ function serializeArgument(node, actionName, index, arg) {
2915
2923
  // We should not serialize MST nodes, even if we can, because we don't know if the receiving party can handle a raw snapshot instead of an
2916
2924
  // MST type instance. So if one wants to serialize a MST node that was pass in, either explitly pass: 1: an id, 2: a (relative) path, 3: a snapshot
2917
2925
  if (isStateTreeNode(arg))
2918
- return serializeTheUnserializable("[MSTNode: " + getType(arg).name + "]");
2926
+ return serializeTheUnserializable("[MSTNode: ".concat(getType(arg).name, "]"));
2919
2927
  if (typeof arg === "function")
2920
2928
  return serializeTheUnserializable("[function]");
2921
2929
  if (typeof arg === "object" && !isPlainObject(arg) && !isArray(arg))
2922
- return serializeTheUnserializable("[object " + ((arg && arg.constructor && arg.constructor.name) || "Complex Object") + "]");
2930
+ return serializeTheUnserializable("[object ".concat((arg && arg.constructor && arg.constructor.name) || "Complex Object", "]"));
2923
2931
  try {
2924
2932
  // Check if serializable, cycle free etc...
2925
2933
  // MWE: there must be a better way....
@@ -2960,7 +2968,7 @@ function applyAction(target, actions) {
2960
2968
  function baseApplyAction(target, action) {
2961
2969
  var resolvedTarget = tryResolve(target, action.path || "");
2962
2970
  if (!resolvedTarget)
2963
- throw fail$1("Invalid action path: " + (action.path || ""));
2971
+ throw fail("Invalid action path: ".concat(action.path || ""));
2964
2972
  var node = getStateTreeNode(resolvedTarget);
2965
2973
  // Reserved functions
2966
2974
  if (action.name === "@APPLY_PATCHES") {
@@ -2970,7 +2978,7 @@ function baseApplyAction(target, action) {
2970
2978
  return applySnapshot.call(null, resolvedTarget, action.args[0]);
2971
2979
  }
2972
2980
  if (!(typeof resolvedTarget[action.name] === "function"))
2973
- throw fail$1("Action '" + action.name + "' does not exist in '" + node.path + "'");
2981
+ throw fail("Action '".concat(action.name, "' does not exist in '").concat(node.path, "'"));
2974
2982
  return resolvedTarget[action.name].apply(resolvedTarget, action.args ? action.args.map(function (v) { return deserializeArgument(node, v); }) : []);
2975
2983
  }
2976
2984
  /**
@@ -3175,7 +3183,7 @@ function createActionInvoker(target, name, fn) {
3175
3183
  tree: getRoot(target),
3176
3184
  rootId: parentContext ? parentContext.rootId : id,
3177
3185
  parentId: parentContext ? parentContext.id : 0,
3178
- allParentIds: parentContext ? __spread(parentContext.allParentIds, [parentContext.id]) : [],
3186
+ allParentIds: parentContext ? __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false) : [],
3179
3187
  parentEvent: parentContext,
3180
3188
  parentActionEvent: parentActionContext
3181
3189
  }, fn);
@@ -3331,11 +3339,11 @@ function runMiddleWares(node, baseCall, originalFn) {
3331
3339
  if (devMode()) {
3332
3340
  if (!nextInvoked && !abortInvoked) {
3333
3341
  var node2 = getStateTreeNode(call.tree);
3334
- throw fail$1("Neither the next() nor the abort() callback within the middleware " + handler.name + " for the action: \"" + call.name + "\" on the node: " + node2.type.name + " was invoked.");
3342
+ throw fail("Neither the next() nor the abort() callback within the middleware ".concat(handler.name, " for the action: \"").concat(call.name, "\" on the node: ").concat(node2.type.name, " was invoked."));
3335
3343
  }
3336
3344
  else if (nextInvoked && abortInvoked) {
3337
3345
  var node2 = getStateTreeNode(call.tree);
3338
- throw fail$1("The next() and abort() callback within the middleware " + handler.name + " for the action: \"" + call.name + "\" on the node: " + node2.type.name + " were invoked.");
3346
+ throw fail("The next() and abort() callback within the middleware ".concat(handler.name, " for the action: \"").concat(call.name, "\" on the node: ").concat(node2.type.name, " were invoked."));
3339
3347
  }
3340
3348
  }
3341
3349
  return result;
@@ -3385,7 +3393,7 @@ function safeStringify(value) {
3385
3393
  }
3386
3394
  catch (e) {
3387
3395
  // istanbul ignore next
3388
- return "<Unserializable: " + e + ">";
3396
+ return "<Unserializable: ".concat(e, ">");
3389
3397
  }
3390
3398
  }
3391
3399
  /**
@@ -3394,15 +3402,15 @@ function safeStringify(value) {
3394
3402
  */
3395
3403
  function prettyPrintValue(value) {
3396
3404
  return typeof value === "function"
3397
- ? "<function" + (value.name ? " " + value.name : "") + ">"
3405
+ ? "<function".concat(value.name ? " " + value.name : "", ">")
3398
3406
  : isStateTreeNode(value)
3399
- ? "<" + value + ">"
3400
- : "`" + safeStringify(value) + "`";
3407
+ ? "<".concat(value, ">")
3408
+ : "`".concat(safeStringify(value), "`");
3401
3409
  }
3402
3410
  function shortenPrintValue(valueInString) {
3403
3411
  return valueInString.length < 280
3404
3412
  ? valueInString
3405
- : valueInString.substring(0, 272) + "......" + valueInString.substring(valueInString.length - 8);
3413
+ : "".concat(valueInString.substring(0, 272), "......").concat(valueInString.substring(valueInString.length - 8));
3406
3414
  }
3407
3415
  function toErrorString(error) {
3408
3416
  var value = error.value;
@@ -3414,19 +3422,19 @@ function toErrorString(error) {
3414
3422
  })
3415
3423
  .filter(function (path) { return path.length > 0; })
3416
3424
  .join("/");
3417
- var pathPrefix = fullPath.length > 0 ? "at path \"/" + fullPath + "\" " : "";
3425
+ var pathPrefix = fullPath.length > 0 ? "at path \"/".concat(fullPath, "\" ") : "";
3418
3426
  var currentTypename = isStateTreeNode(value)
3419
- ? "value of type " + getStateTreeNode(value).type.name + ":"
3427
+ ? "value of type ".concat(getStateTreeNode(value).type.name, ":")
3420
3428
  : isPrimitive(value)
3421
3429
  ? "value"
3422
3430
  : "snapshot";
3423
3431
  var isSnapshotCompatible = type && isStateTreeNode(value) && type.is(getStateTreeNode(value).snapshot);
3424
- return ("" + pathPrefix + currentTypename + " " + prettyPrintValue(value) + " is not assignable " + (type ? "to type: `" + type.name + "`" : "") +
3425
- (error.message ? " (" + error.message + ")" : "") +
3432
+ return ("".concat(pathPrefix).concat(currentTypename, " ").concat(prettyPrintValue(value), " is not assignable ").concat(type ? "to type: `".concat(type.name, "`") : "") +
3433
+ (error.message ? " (".concat(error.message, ")") : "") +
3426
3434
  (type
3427
3435
  ? isPrimitiveType(type) || isPrimitive(value)
3428
3436
  ? "."
3429
- : ", expected an instance of `" + type.name + "` or a snapshot like `" + type.describe() + "` instead." +
3437
+ : ", expected an instance of `".concat(type.name, "` or a snapshot like `").concat(type.describe(), "` instead.") +
3430
3438
  (isSnapshotCompatible
3431
3439
  ? " (Note that a snapshot of the provided value is compatible with the targeted type)"
3432
3440
  : "")
@@ -3482,14 +3490,14 @@ function typecheckInternal(type, value) {
3482
3490
  function typecheck(type, value) {
3483
3491
  var errors = type.validate(value, [{ path: "", type: type }]);
3484
3492
  if (errors.length > 0) {
3485
- throw fail$1(validationErrorsToString(type, value, errors));
3493
+ throw fail(validationErrorsToString(type, value, errors));
3486
3494
  }
3487
3495
  }
3488
3496
  function validationErrorsToString(type, value, errors) {
3489
3497
  if (errors.length === 0) {
3490
3498
  return undefined;
3491
3499
  }
3492
- return ("Error while converting " + shortenPrintValue(prettyPrintValue(value)) + " to `" + type.name + "`:\n\n " + errors.map(toErrorString).join("\n "));
3500
+ return ("Error while converting ".concat(shortenPrintValue(prettyPrintValue(value)), " to `").concat(type.name, "`:\n\n ") + errors.map(toErrorString).join("\n "));
3493
3501
  }
3494
3502
 
3495
3503
  var identifierCacheId = 0;
@@ -3537,7 +3545,7 @@ var IdentifierCache = /** @class */ (function () {
3537
3545
  writable: true,
3538
3546
  value: function (identifier) {
3539
3547
  var modificationId = this.lastCacheModificationPerId.get(identifier) || 0;
3540
- return this.cacheId + "-" + modificationId;
3548
+ return "".concat(this.cacheId, "-").concat(modificationId);
3541
3549
  }
3542
3550
  });
3543
3551
  Object.defineProperty(IdentifierCache.prototype, "addNodeToCache", {
@@ -3553,7 +3561,7 @@ var IdentifierCache = /** @class */ (function () {
3553
3561
  }
3554
3562
  var set = this.cache.get(identifier);
3555
3563
  if (set.indexOf(node) !== -1)
3556
- throw fail$1("Already registered");
3564
+ throw fail("Already registered");
3557
3565
  set.push(node);
3558
3566
  if (lastCacheUpdate) {
3559
3567
  this.updateLastCacheModificationPerId(identifier);
@@ -3652,9 +3660,9 @@ var IdentifierCache = /** @class */ (function () {
3652
3660
  case 1:
3653
3661
  return matches[0];
3654
3662
  default:
3655
- throw fail$1("Cannot resolve a reference to type '" + type.name + "' with id: '" + identifier + "' unambigously, there are multiple candidates: " + matches
3663
+ throw fail("Cannot resolve a reference to type '".concat(type.name, "' with id: '").concat(identifier, "' unambigously, there are multiple candidates: ").concat(matches
3656
3664
  .map(function (n) { return n.path; })
3657
- .join(", "));
3665
+ .join(", ")));
3658
3666
  }
3659
3667
  }
3660
3668
  });
@@ -3670,7 +3678,7 @@ function createObjectNode(type, parent, subpath, environment, initialValue) {
3670
3678
  if (existingNode) {
3671
3679
  if (existingNode.parent) {
3672
3680
  // istanbul ignore next
3673
- throw fail$1("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '" + (parent ? parent.path : "") + "/" + subpath + "', but it lives already at '" + existingNode.path + "'");
3681
+ throw fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(parent ? parent.path : "", "/").concat(subpath, "', but it lives already at '").concat(existingNode.path, "'"));
3674
3682
  }
3675
3683
  if (parent) {
3676
3684
  existingNode.setParent(parent, subpath);
@@ -3733,7 +3741,7 @@ function assertIsStateTreeNode(value, argNumber) {
3733
3741
  function getStateTreeNode(value) {
3734
3742
  if (!isStateTreeNode(value)) {
3735
3743
  // istanbul ignore next
3736
- throw fail$1("Value " + value + " is no MST Node");
3744
+ throw fail("Value ".concat(value, " is no MST Node"));
3737
3745
  }
3738
3746
  return value.$treenode;
3739
3747
  }
@@ -3759,7 +3767,7 @@ var doubleDot = function (_) { return ".."; };
3759
3767
  function getRelativePathBetweenNodes(base, target) {
3760
3768
  // PRE condition target is (a child of) base!
3761
3769
  if (base.root !== target.root) {
3762
- throw fail$1("Cannot calculate relative path: objects '" + base + "' and '" + target + "' are not part of the same object tree");
3770
+ throw fail("Cannot calculate relative path: objects '".concat(base, "' and '").concat(target, "' are not part of the same object tree"));
3763
3771
  }
3764
3772
  var baseParts = splitJsonPath(base.path);
3765
3773
  var targetParts = splitJsonPath(target.path);
@@ -3816,7 +3824,7 @@ function resolveNodeByPathParts(base, pathParts, failIfResolveFails) {
3816
3824
  }
3817
3825
  }
3818
3826
  }
3819
- throw fail$1("Could not resolve '" + part + "' in path '" + (joinJsonPath(pathParts.slice(0, i)) || "/") + "' while resolving '" + joinJsonPath(pathParts) + "'");
3827
+ throw fail("Could not resolve '".concat(part, "' in path '").concat(joinJsonPath(pathParts.slice(0, i)) || "/", "' while resolving '").concat(joinJsonPath(pathParts), "'"));
3820
3828
  }
3821
3829
  }
3822
3830
  catch (e) {
@@ -3892,7 +3900,7 @@ Object.freeze(mobxShallow);
3892
3900
  * @internal
3893
3901
  * @hidden
3894
3902
  */
3895
- function fail$1(message) {
3903
+ function fail(message) {
3896
3904
  if (message === void 0) { message = "Illegal state"; }
3897
3905
  return new Error("[mobx-state-tree] " + message);
3898
3906
  }
@@ -4136,7 +4144,7 @@ var EventHandler = /** @class */ (function () {
4136
4144
  }
4137
4145
  // make a copy just in case it changes
4138
4146
  var handlers = this.handlers.slice();
4139
- handlers.forEach(function (f) { return f.apply(void 0, __spread(args)); });
4147
+ handlers.forEach(function (f) { return f.apply(void 0, __spreadArray([], __read(args), false)); });
4140
4148
  }
4141
4149
  });
4142
4150
  return EventHandler;
@@ -4229,7 +4237,7 @@ var EventHandlers = /** @class */ (function () {
4229
4237
  }
4230
4238
  var handler = this.eventHandlers && this.eventHandlers[event];
4231
4239
  if (handler) {
4232
- (_a = handler).emit.apply(_a, __spread(args));
4240
+ (_a = handler).emit.apply(_a, __spreadArray([], __read(args), false));
4233
4241
  }
4234
4242
  }
4235
4243
  });
@@ -4274,7 +4282,7 @@ deprecated.ids = {};
4274
4282
  * @hidden
4275
4283
  */
4276
4284
  function warnError(msg) {
4277
- console.warn(new Error("[mobx-state-tree] " + msg));
4285
+ console.warn(new Error("[mobx-state-tree] ".concat(msg)));
4278
4286
  }
4279
4287
  /**
4280
4288
  * @internal
@@ -4299,7 +4307,7 @@ function assertArg(value, fn, typeName, argNumber) {
4299
4307
  if (devMode()) {
4300
4308
  if (!fn(value)) {
4301
4309
  // istanbul ignore next
4302
- throw fail$1("expected " + typeName + " as argument " + asArray(argNumber).join(" or ") + ", got " + value + " instead");
4310
+ throw fail("expected ".concat(typeName, " as argument ").concat(asArray(argNumber).join(" or "), ", got ").concat(value, " instead"));
4303
4311
  }
4304
4312
  }
4305
4313
  }
@@ -4317,10 +4325,10 @@ function assertIsFunction(value, argNumber) {
4317
4325
  function assertIsNumber(value, argNumber, min, max) {
4318
4326
  assertArg(value, function (n) { return typeof n === "number"; }, "number", argNumber);
4319
4327
  if (min !== undefined) {
4320
- assertArg(value, function (n) { return n >= min; }, "number greater than " + min, argNumber);
4328
+ assertArg(value, function (n) { return n >= min; }, "number greater than ".concat(min), argNumber);
4321
4329
  }
4322
4330
  if (max !== undefined) {
4323
- assertArg(value, function (n) { return n <= max; }, "number lesser than " + max, argNumber);
4331
+ assertArg(value, function (n) { return n <= max; }, "number lesser than ".concat(max), argNumber);
4324
4332
  }
4325
4333
  }
4326
4334
  /**
@@ -4399,7 +4407,7 @@ function toGeneratorFunction(p) {
4399
4407
  }
4400
4408
  return __generator(this, function (_a) {
4401
4409
  switch (_a.label) {
4402
- case 0: return [4 /*yield*/, p.apply(void 0, __spread(args))];
4410
+ case 0: return [4 /*yield*/, p.apply(void 0, __spreadArray([], __read(args), false))];
4403
4411
  case 1: return [2 /*return*/, (_a.sent())];
4404
4412
  }
4405
4413
  });
@@ -4444,11 +4452,11 @@ function createFlowSpawner(name, generator) {
4444
4452
  var runId = getNextActionId();
4445
4453
  var parentContext = getCurrentActionContext();
4446
4454
  if (!parentContext) {
4447
- throw fail$1("a mst flow must always have a parent context");
4455
+ throw fail("a mst flow must always have a parent context");
4448
4456
  }
4449
4457
  var parentActionContext = getParentActionContext(parentContext);
4450
4458
  if (!parentActionContext) {
4451
- throw fail$1("a mst flow must always have a parent action context");
4459
+ throw fail("a mst flow must always have a parent action context");
4452
4460
  }
4453
4461
  var contextBase = {
4454
4462
  name: name,
@@ -4456,7 +4464,7 @@ function createFlowSpawner(name, generator) {
4456
4464
  tree: parentContext.tree,
4457
4465
  context: parentContext.context,
4458
4466
  parentId: parentContext.id,
4459
- allParentIds: __spread(parentContext.allParentIds, [parentContext.id]),
4467
+ allParentIds: __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false),
4460
4468
  rootId: parentContext.rootId,
4461
4469
  parentEvent: parentContext,
4462
4470
  parentActionEvent: parentActionContext
@@ -4519,7 +4527,7 @@ function createFlowSpawner(name, generator) {
4519
4527
  // TODO: support more type of values? See https://github.com/tj/co/blob/249bbdc72da24ae44076afd716349d2089b31c4c/index.js#L100
4520
4528
  if (!ret.value || typeof ret.value.then !== "function") {
4521
4529
  // istanbul ignore next
4522
- throw fail$1("Only promises can be yielded to `async`, got: " + ret);
4530
+ throw fail("Only promises can be yielded to `async`, got: " + ret);
4523
4531
  }
4524
4532
  return ret.value.then(onFulfilled, onRejected);
4525
4533
  }
@@ -4535,7 +4543,7 @@ function createFlowSpawner(name, generator) {
4535
4543
  */
4536
4544
  function splitPatch(patch) {
4537
4545
  if (!("oldValue" in patch))
4538
- throw fail$1("Patches without `oldValue` field cannot be inversed");
4546
+ throw fail("Patches without `oldValue` field cannot be inversed");
4539
4547
  return [stripPatch(patch), invertPatch(patch)];
4540
4548
  }
4541
4549
  /**
@@ -4636,7 +4644,7 @@ function splitJsonPath(path) {
4636
4644
  stringStartsWith(path, "./") ||
4637
4645
  stringStartsWith(path, "../");
4638
4646
  if (!valid) {
4639
- throw fail$1("a json path must be either rooted, empty or relative, but got '" + path + "'");
4647
+ throw fail("a json path must be either rooted, empty or relative, but got '".concat(path, "'"));
4640
4648
  }
4641
4649
  // '/a/b/c' -> ["a", "b", "c"]
4642
4650
  // '../../b/c' -> ["..", "..", "b", "c"]
@@ -4682,7 +4690,7 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4682
4690
  configurable: true,
4683
4691
  writable: true,
4684
4692
  value: function () {
4685
- return "snapshotProcessor(" + this._subtype.describe() + ")";
4693
+ return "snapshotProcessor(".concat(this._subtype.describe(), ")");
4686
4694
  }
4687
4695
  });
4688
4696
  Object.defineProperty(SnapshotProcessor.prototype, "preProcessSnapshot", {
@@ -4984,28 +4992,28 @@ var MSTMap = /** @class */ (function (_super) {
4984
4992
  writable: true,
4985
4993
  value: function (value) {
4986
4994
  if (!value)
4987
- throw fail$1("Map.put cannot be used to set empty values");
4995
+ throw fail("Map.put cannot be used to set empty values");
4988
4996
  if (isStateTreeNode(value)) {
4989
4997
  var node = getStateTreeNode(value);
4990
4998
  if (devMode()) {
4991
4999
  if (!node.identifierAttribute) {
4992
- throw fail$1(needsIdentifierError);
5000
+ throw fail(needsIdentifierError);
4993
5001
  }
4994
5002
  }
4995
5003
  if (node.identifier === null) {
4996
- throw fail$1(needsIdentifierError);
5004
+ throw fail(needsIdentifierError);
4997
5005
  }
4998
5006
  this.set(node.identifier, value);
4999
5007
  return value;
5000
5008
  }
5001
5009
  else if (!isMutable(value)) {
5002
- throw fail$1("Map.put can only be used to store complex values");
5010
+ throw fail("Map.put can only be used to store complex values");
5003
5011
  }
5004
5012
  else {
5005
5013
  var mapNode = getStateTreeNode(this);
5006
5014
  var mapType = mapNode.type;
5007
5015
  if (mapType.identifierMode !== MapIdentifierMode.YES) {
5008
- throw fail$1(needsIdentifierError);
5016
+ throw fail(needsIdentifierError);
5009
5017
  }
5010
5018
  var idAttr = mapType.mapIdentifierAttribute;
5011
5019
  var id = value[idAttr];
@@ -5098,7 +5106,7 @@ var MapType = /** @class */ (function (_super) {
5098
5106
  if (!type.identifierAttribute)
5099
5107
  return current;
5100
5108
  if (current && current !== type.identifierAttribute) {
5101
- throw fail$1("The objects in a map should all have the same identifier attribute, expected '" + current + "', but child of type '" + type.name + "' declared attribute '" + type.identifierAttribute + "' as identifier");
5109
+ throw fail("The objects in a map should all have the same identifier attribute, expected '".concat(current, "', but child of type '").concat(type.name, "' declared attribute '").concat(type.identifierAttribute, "' as identifier"));
5102
5110
  }
5103
5111
  return type.identifierAttribute;
5104
5112
  }, undefined);
@@ -5177,7 +5185,7 @@ var MapType = /** @class */ (function (_super) {
5177
5185
  value: function (node, key) {
5178
5186
  var childNode = node.storedValue.get("" + key);
5179
5187
  if (!childNode)
5180
- throw fail$1("Not a child " + key);
5188
+ throw fail("Not a child " + key);
5181
5189
  return childNode;
5182
5190
  }
5183
5191
  });
@@ -5222,7 +5230,7 @@ var MapType = /** @class */ (function (_super) {
5222
5230
  if (this.identifierMode === MapIdentifierMode.YES && node instanceof ObjectNode) {
5223
5231
  var identifier = node.identifier;
5224
5232
  if (identifier !== expected)
5225
- throw fail$1("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + identifier + "', but expected: '" + expected + "'");
5233
+ throw fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(identifier, "', but expected: '").concat(expected, "'"));
5226
5234
  }
5227
5235
  }
5228
5236
  });
@@ -5394,7 +5402,7 @@ MapType.prototype.applySnapshot = mobx.action(MapType.prototype.applySnapshot);
5394
5402
  * @returns
5395
5403
  */
5396
5404
  function map(subtype) {
5397
- return new MapType("Map<string, " + subtype.name + ">", subtype);
5405
+ return new MapType("Map<string, ".concat(subtype.name, ">"), subtype);
5398
5406
  }
5399
5407
  /**
5400
5408
  * Returns if a given value represents a map type.
@@ -5520,7 +5528,7 @@ var ArrayType = /** @class */ (function (_super) {
5520
5528
  var index = Number(key);
5521
5529
  if (index < node.storedValue.length)
5522
5530
  return node.storedValue[index];
5523
- throw fail$1("Not a child: " + key);
5531
+ throw fail("Not a child: " + key);
5524
5532
  }
5525
5533
  });
5526
5534
  Object.defineProperty(ArrayType.prototype, "willChange", {
@@ -5711,7 +5719,7 @@ ArrayType.prototype.applySnapshot = mobx.action(ArrayType.prototype.applySnapsho
5711
5719
  */
5712
5720
  function array(subtype) {
5713
5721
  assertIsType(subtype, 1);
5714
- return new ArrayType(subtype.name + "[]", subtype);
5722
+ return new ArrayType("".concat(subtype.name, "[]"), subtype);
5715
5723
  }
5716
5724
  function reconcileArrayChildren(parent, childType, oldNodes, newValues, newPaths) {
5717
5725
  var nothingChanged = true;
@@ -5745,7 +5753,7 @@ function reconcileArrayChildren(parent, childType, oldNodes, newValues, newPaths
5745
5753
  // check if already belongs to the same parent. if so, avoid pushing item in. only swapping can occur.
5746
5754
  if (isStateTreeNode(newValue) && getStateTreeNode(newValue).parent === parent) {
5747
5755
  // this node is owned by this parent, but not in the reconcilable set, so it must be double
5748
- throw fail$1("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '" + parent.path + "/" + newPath + "', but it lives already at '" + getStateTreeNode(newValue).path + "'");
5756
+ throw fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(parent.path, "/").concat(newPath, "', but it lives already at '").concat(getStateTreeNode(newValue).path, "'"));
5749
5757
  }
5750
5758
  nothingChanged = false;
5751
5759
  var newNode = valueAsNode(childType, parent, newPath, newValue);
@@ -5861,7 +5869,7 @@ function toPropertiesObject(declaredProps) {
5861
5869
  var alreadySeenKeys = new Set();
5862
5870
  keysList.forEach(function (key) {
5863
5871
  if (alreadySeenKeys.has(key)) {
5864
- throw fail$1(key + " is declared twice in the model. Model should not contain the same keys");
5872
+ throw fail("".concat(key, " is declared twice in the model. Model should not contain the same keys"));
5865
5873
  }
5866
5874
  alreadySeenKeys.add(key);
5867
5875
  });
@@ -5869,17 +5877,17 @@ function toPropertiesObject(declaredProps) {
5869
5877
  return keysList.reduce(function (props, key) {
5870
5878
  // warn if user intended a HOOK
5871
5879
  if (key in Hook) {
5872
- throw fail$1("Hook '" + key + "' was defined as property. Hooks should be defined as part of the actions");
5880
+ throw fail("Hook '".concat(key, "' was defined as property. Hooks should be defined as part of the actions"));
5873
5881
  }
5874
5882
  // the user intended to use a view
5875
5883
  var descriptor = Object.getOwnPropertyDescriptor(declaredProps, key);
5876
5884
  if ("get" in descriptor) {
5877
- throw fail$1("Getters are not supported as properties. Please use views instead");
5885
+ throw fail("Getters are not supported as properties. Please use views instead");
5878
5886
  }
5879
5887
  // undefined and null are not valid
5880
5888
  var value = descriptor.value;
5881
5889
  if (value === null || value === undefined) {
5882
- throw fail$1("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");
5890
+ throw fail("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");
5883
5891
  }
5884
5892
  // its a primitive, convert to its type
5885
5893
  else if (isPrimitive(value)) {
@@ -5896,14 +5904,14 @@ function toPropertiesObject(declaredProps) {
5896
5904
  else if (isType(value)) ;
5897
5905
  // its a function, maybe the user wanted a view?
5898
5906
  else if (devMode() && typeof value === "function") {
5899
- throw fail$1("Invalid type definition for property '" + key + "', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?");
5907
+ throw fail("Invalid type definition for property '".concat(key, "', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?"));
5900
5908
  }
5901
5909
  // no other complex values
5902
5910
  else if (devMode() && typeof value === "object") {
5903
- throw fail$1("Invalid type definition for property '" + key + "', it looks like you passed an object. Try passing another model type or a types.frozen.");
5911
+ throw fail("Invalid type definition for property '".concat(key, "', it looks like you passed an object. Try passing another model type or a types.frozen."));
5904
5912
  }
5905
5913
  else {
5906
- throw fail$1("Invalid type definition for property '" + key + "', cannot infer a type from a value like '" + value + "' (" + typeof value + ")");
5914
+ throw fail("Invalid type definition for property '".concat(key, "', cannot infer a type from a value like '").concat(value, "' (").concat(typeof value, ")"));
5907
5915
  }
5908
5916
  return props;
5909
5917
  }, declaredProps);
@@ -6016,7 +6024,7 @@ var ModelType = /** @class */ (function (_super) {
6016
6024
  this.forAllProps(function (propName, propType) {
6017
6025
  if (propType.flags & TypeFlags.Identifier) {
6018
6026
  if (identifierAttribute)
6019
- throw fail$1("Cannot define property '" + propName + "' as object identifier, property '" + identifierAttribute + "' is already defined as identifier property");
6027
+ throw fail("Cannot define property '".concat(propName, "' as object identifier, property '").concat(identifierAttribute, "' is already defined as identifier property"));
6020
6028
  identifierAttribute = propName;
6021
6029
  }
6022
6030
  });
@@ -6057,15 +6065,15 @@ var ModelType = /** @class */ (function (_super) {
6057
6065
  value: function (self, actions) {
6058
6066
  // check if return is correct
6059
6067
  if (!isPlainObject(actions))
6060
- throw fail$1("actions initializer should return a plain object containing actions");
6068
+ throw fail("actions initializer should return a plain object containing actions");
6061
6069
  // bind actions to the object created
6062
6070
  Object.keys(actions).forEach(function (name) {
6063
6071
  // warn if preprocessor was given
6064
6072
  if (name === PRE_PROCESS_SNAPSHOT)
6065
- throw fail$1("Cannot define action '" + PRE_PROCESS_SNAPSHOT + "', it should be defined using 'type.preProcessSnapshot(fn)' instead");
6073
+ throw fail("Cannot define action '".concat(PRE_PROCESS_SNAPSHOT, "', it should be defined using 'type.preProcessSnapshot(fn)' instead"));
6066
6074
  // warn if postprocessor was given
6067
6075
  if (name === POST_PROCESS_SNAPSHOT)
6068
- throw fail$1("Cannot define action '" + POST_PROCESS_SNAPSHOT + "', it should be defined using 'type.postProcessSnapshot(fn)' instead");
6076
+ throw fail("Cannot define action '".concat(POST_PROCESS_SNAPSHOT, "', it should be defined using 'type.postProcessSnapshot(fn)' instead"));
6069
6077
  var action2 = actions[name];
6070
6078
  // apply hook composition
6071
6079
  var baseAction = self[name];
@@ -6095,7 +6103,7 @@ var ModelType = /** @class */ (function (_super) {
6095
6103
  value: function (fn) {
6096
6104
  var _this = this;
6097
6105
  if (typeof fn !== "function") {
6098
- throw fail$1("You passed an " + typeof fn + " to volatile state as an argument, when function is expected");
6106
+ throw fail("You passed an ".concat(typeof fn, " to volatile state as an argument, when function is expected"));
6099
6107
  }
6100
6108
  var stateInitializer = function (self) {
6101
6109
  _this.instantiateVolatileState(self, fn(self));
@@ -6111,7 +6119,7 @@ var ModelType = /** @class */ (function (_super) {
6111
6119
  value: function (self, state) {
6112
6120
  // check views return
6113
6121
  if (!isPlainObject(state))
6114
- throw fail$1("volatile state initializer should return a plain object containing state");
6122
+ throw fail("volatile state initializer should return a plain object containing state");
6115
6123
  mobx.set(self, state);
6116
6124
  }
6117
6125
  });
@@ -6124,7 +6132,7 @@ var ModelType = /** @class */ (function (_super) {
6124
6132
  var initializer = function (self) {
6125
6133
  var _a = fn(self), actions = _a.actions, views = _a.views, state = _a.state, rest = __rest(_a, ["actions", "views", "state"]);
6126
6134
  for (var key in rest)
6127
- throw fail$1("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '" + key + "'");
6135
+ throw fail("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(key, "'"));
6128
6136
  if (state)
6129
6137
  _this.instantiateVolatileState(self, state);
6130
6138
  if (views)
@@ -6156,7 +6164,7 @@ var ModelType = /** @class */ (function (_super) {
6156
6164
  value: function (self, views) {
6157
6165
  // check views return
6158
6166
  if (!isPlainObject(views))
6159
- throw fail$1("views initializer should return a plain object containing views");
6167
+ throw fail("views initializer should return a plain object containing views");
6160
6168
  Object.getOwnPropertyNames(views).forEach(function (key) {
6161
6169
  var _a;
6162
6170
  // is this a computed property?
@@ -6169,7 +6177,7 @@ var ModelType = /** @class */ (function (_super) {
6169
6177
  (!devMode() ? addHiddenFinalProp : addHiddenWritableProp)(self, key, descriptor.value);
6170
6178
  }
6171
6179
  else {
6172
- throw fail$1("A view member should either be a function or getter based property");
6180
+ throw fail("A view member should either be a function or getter based property");
6173
6181
  }
6174
6182
  });
6175
6183
  }
@@ -6285,11 +6293,11 @@ var ModelType = /** @class */ (function (_super) {
6285
6293
  value: function (node, key) {
6286
6294
  var _a;
6287
6295
  if (!(key in this.properties))
6288
- throw fail$1("Not a value property: " + key);
6296
+ throw fail("Not a value property: " + key);
6289
6297
  var adm = mobx._getAdministration(node.storedValue, key);
6290
6298
  var childNode = (_a = adm.raw) === null || _a === void 0 ? void 0 : _a.call(adm);
6291
6299
  if (!childNode)
6292
- throw fail$1("Node not available for property " + key);
6300
+ throw fail("Node not available for property " + key);
6293
6301
  return childNode;
6294
6302
  }
6295
6303
  });
@@ -6308,7 +6316,7 @@ var ModelType = /** @class */ (function (_super) {
6308
6316
  atom.reportObserved();
6309
6317
  }
6310
6318
  catch (e) {
6311
- throw fail$1(name + " property is declared twice");
6319
+ throw fail("".concat(name, " property is declared twice"));
6312
6320
  }
6313
6321
  res[name] = _this.getChildNode(node, name).snapshot;
6314
6322
  });
@@ -6336,7 +6344,7 @@ var ModelType = /** @class */ (function (_super) {
6336
6344
  writable: true,
6337
6345
  value: function (node, subpath, patch) {
6338
6346
  if (!(patch.op === "replace" || patch.op === "add")) {
6339
- throw fail$1("object does not support operation " + patch.op);
6347
+ throw fail("object does not support operation ".concat(patch.op));
6340
6348
  }
6341
6349
  node.storedValue[subpath] = patch.value;
6342
6350
  }
@@ -6448,7 +6456,7 @@ function model() {
6448
6456
  args[_i] = arguments[_i];
6449
6457
  }
6450
6458
  if (devMode() && typeof args[0] !== "string" && args[1]) {
6451
- throw fail$1("Model creation failed. First argument must be a string when two arguments are provided");
6459
+ throw fail("Model creation failed. First argument must be a string when two arguments are provided");
6452
6460
  }
6453
6461
  var name = typeof args[0] === "string" ? args.shift() : "AnonymousModel";
6454
6462
  var properties = args.shift() || {};
@@ -6568,7 +6576,7 @@ var CoreType = /** @class */ (function (_super) {
6568
6576
  return typeCheckSuccess();
6569
6577
  }
6570
6578
  var typeName = this.name === "Date" ? "Date or a unix milliseconds timestamp" : this.name;
6571
- return typeCheckFailure(context, value, "Value is not a " + typeName);
6579
+ return typeCheckFailure(context, value, "Value is not a ".concat(typeName));
6572
6580
  }
6573
6581
  });
6574
6582
  return CoreType;
@@ -6695,7 +6703,7 @@ function getPrimitiveFactoryFromValue(value) {
6695
6703
  if (value instanceof Date)
6696
6704
  return DatePrimitive;
6697
6705
  }
6698
- throw fail$1("Cannot determine primitive type from value " + value);
6706
+ throw fail("Cannot determine primitive type from value " + value);
6699
6707
  }
6700
6708
  /**
6701
6709
  * Returns if a given value represents a primitive type.
@@ -6761,7 +6769,7 @@ var Literal = /** @class */ (function (_super) {
6761
6769
  if (isPrimitive(value) && value === this.value) {
6762
6770
  return typeCheckSuccess();
6763
6771
  }
6764
- return typeCheckFailure(context, value, "Value is not a literal " + JSON.stringify(this.value));
6772
+ return typeCheckFailure(context, value, "Value is not a literal ".concat(JSON.stringify(this.value)));
6765
6773
  }
6766
6774
  });
6767
6775
  return Literal;
@@ -6943,7 +6951,7 @@ function enumeration(name, options) {
6943
6951
  assertIsString(option, i + 1);
6944
6952
  });
6945
6953
  }
6946
- var type = union.apply(void 0, __spread(realOptions.map(function (option) { return literal("" + option); })));
6954
+ var type = union.apply(void 0, __spreadArray([], __read(realOptions.map(function (option) { return literal("" + option); })), false));
6947
6955
  if (typeof name === "string")
6948
6956
  type.name = name;
6949
6957
  return type;
@@ -7015,7 +7023,7 @@ var Union = /** @class */ (function (_super) {
7015
7023
  value: function (parent, subpath, environment, initialValue) {
7016
7024
  var type = this.determineType(initialValue, undefined);
7017
7025
  if (!type)
7018
- throw fail$1("No matching type for union " + this.describe()); // can happen in prod builds
7026
+ throw fail("No matching type for union " + this.describe()); // can happen in prod builds
7019
7027
  return type.instantiate(parent, subpath, environment, initialValue);
7020
7028
  }
7021
7029
  });
@@ -7026,7 +7034,7 @@ var Union = /** @class */ (function (_super) {
7026
7034
  value: function (current, newValue, parent, subpath) {
7027
7035
  var type = this.determineType(newValue, current.getReconciliationType());
7028
7036
  if (!type)
7029
- throw fail$1("No matching type for union " + this.describe()); // can happen in prod builds
7037
+ throw fail("No matching type for union " + this.describe()); // can happen in prod builds
7030
7038
  return type.reconcile(current, newValue, parent, subpath);
7031
7039
  }
7032
7040
  });
@@ -7039,7 +7047,7 @@ var Union = /** @class */ (function (_super) {
7039
7047
  if (this._dispatcher) {
7040
7048
  return this._dispatcher(value);
7041
7049
  }
7042
- // find the most accomodating type
7050
+ // find the most accommodating type
7043
7051
  // if we are using reconciliation try the current node type first (fix for #1045)
7044
7052
  if (reconcileCurrentType) {
7045
7053
  if (reconcileCurrentType.is(value)) {
@@ -7103,7 +7111,7 @@ function union(optionsOrType) {
7103
7111
  otherTypes[_i - 1] = arguments[_i];
7104
7112
  }
7105
7113
  var options = isType(optionsOrType) ? undefined : optionsOrType;
7106
- var types = isType(optionsOrType) ? __spread([optionsOrType], otherTypes) : otherTypes;
7114
+ var types = isType(optionsOrType) ? __spreadArray([optionsOrType], __read(otherTypes), false) : otherTypes;
7107
7115
  var name = "(" + types.map(function (type) { return type.name; }).join(" | ") + ")";
7108
7116
  // check all options
7109
7117
  if (devMode()) {
@@ -7241,7 +7249,7 @@ var OptionalValue = /** @class */ (function (_super) {
7241
7249
  function checkOptionalPreconditions(type, defaultValueOrFunction) {
7242
7250
  // make sure we never pass direct instances
7243
7251
  if (typeof defaultValueOrFunction !== "function" && isStateTreeNode(defaultValueOrFunction)) {
7244
- throw fail$1("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");
7252
+ throw fail("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");
7245
7253
  }
7246
7254
  assertIsType(type, 1);
7247
7255
  if (devMode()) {
@@ -7380,10 +7388,10 @@ var Late = /** @class */ (function (_super) {
7380
7388
  throw e;
7381
7389
  }
7382
7390
  if (mustSucceed && t === undefined)
7383
- throw fail$1("Late type seems to be used too early, the definition (still) returns undefined");
7391
+ throw fail("Late type seems to be used too early, the definition (still) returns undefined");
7384
7392
  if (t) {
7385
7393
  if (devMode() && !isType(t))
7386
- throw fail$1("Failed to determine subtype, make sure types.late returns a type definition.");
7394
+ throw fail("Failed to determine subtype, make sure types.late returns a type definition.");
7387
7395
  this._subType = t;
7388
7396
  }
7389
7397
  }
@@ -7465,12 +7473,12 @@ var Late = /** @class */ (function (_super) {
7465
7473
  * @returns
7466
7474
  */
7467
7475
  function late(nameOrType, maybeType) {
7468
- var name = typeof nameOrType === "string" ? nameOrType : "late(" + nameOrType.toString() + ")";
7476
+ var name = typeof nameOrType === "string" ? nameOrType : "late(".concat(nameOrType.toString(), ")");
7469
7477
  var type = typeof nameOrType === "string" ? maybeType : nameOrType;
7470
7478
  // checks that the type is actually a late type
7471
7479
  if (devMode()) {
7472
7480
  if (!(typeof type === "function" && type.length === 0))
7473
- throw fail$1("Invalid late type, expected a function with zero arguments that returns a type, got: " +
7481
+ throw fail("Invalid late type, expected a function with zero arguments that returns a type, got: " +
7474
7482
  type);
7475
7483
  }
7476
7484
  return new Late(name, type);
@@ -7537,7 +7545,7 @@ var Lazy = /** @class */ (function (_super) {
7537
7545
  node.parent.applyPatches([
7538
7546
  {
7539
7547
  op: "replace",
7540
- path: "/" + node.subpath,
7548
+ path: "/".concat(node.subpath),
7541
7549
  value: node.snapshot
7542
7550
  }
7543
7551
  ]);
@@ -7551,7 +7559,7 @@ var Lazy = /** @class */ (function (_super) {
7551
7559
  configurable: true,
7552
7560
  writable: true,
7553
7561
  value: function () {
7554
- return "<lazy " + this.name + ">";
7562
+ return "<lazy ".concat(this.name, ">");
7555
7563
  }
7556
7564
  });
7557
7565
  Object.defineProperty(Lazy.prototype, "instantiate", {
@@ -7605,7 +7613,7 @@ var Lazy = /** @class */ (function (_super) {
7605
7613
  var Frozen = /** @class */ (function (_super) {
7606
7614
  __extends(Frozen, _super);
7607
7615
  function Frozen(subType) {
7608
- var _this = _super.call(this, subType ? "frozen(" + subType.name + ")" : "frozen") || this;
7616
+ var _this = _super.call(this, subType ? "frozen(".concat(subType.name, ")") : "frozen") || this;
7609
7617
  Object.defineProperty(_this, "subType", {
7610
7618
  enumerable: true,
7611
7619
  configurable: true,
@@ -7753,15 +7761,15 @@ var StoredReference = /** @class */ (function () {
7753
7761
  else if (isStateTreeNode(value)) {
7754
7762
  var targetNode = getStateTreeNode(value);
7755
7763
  if (!targetNode.identifierAttribute)
7756
- throw fail$1("Can only store references with a defined identifier attribute.");
7764
+ throw fail("Can only store references with a defined identifier attribute.");
7757
7765
  var id = targetNode.unnormalizedIdentifier;
7758
7766
  if (id === null || id === undefined) {
7759
- throw fail$1("Can only store references to tree nodes with a defined identifier.");
7767
+ throw fail("Can only store references to tree nodes with a defined identifier.");
7760
7768
  }
7761
7769
  this.identifier = id;
7762
7770
  }
7763
7771
  else {
7764
- throw fail$1("Can only store references to tree nodes or identifiers, got: '" + value + "'");
7772
+ throw fail("Can only store references to tree nodes or identifiers, got: '".concat(value, "'"));
7765
7773
  }
7766
7774
  }
7767
7775
  Object.defineProperty(StoredReference.prototype, "updateResolvedReference", {
@@ -7778,7 +7786,7 @@ var StoredReference = /** @class */ (function () {
7778
7786
  // reference was initialized with the identifier of the target
7779
7787
  var target = root.identifierCache.resolve(targetType, normalizedId);
7780
7788
  if (!target) {
7781
- throw new InvalidReferenceError("[mobx-state-tree] Failed to resolve reference '" + this.identifier + "' to type '" + this.targetType.name + "' (from node: " + node.path + ")");
7789
+ throw new InvalidReferenceError("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier, "' to type '").concat(this.targetType.name, "' (from node: ").concat(node.path, ")"));
7782
7790
  }
7783
7791
  this.resolvedReference = {
7784
7792
  node: target,
@@ -7817,7 +7825,7 @@ var InvalidReferenceError = /** @class */ (function (_super) {
7817
7825
  var BaseReferenceType = /** @class */ (function (_super) {
7818
7826
  __extends(BaseReferenceType, _super);
7819
7827
  function BaseReferenceType(targetType, onInvalidated) {
7820
- var _this = _super.call(this, "reference(" + targetType.name + ")") || this;
7828
+ var _this = _super.call(this, "reference(".concat(targetType.name, ")")) || this;
7821
7829
  Object.defineProperty(_this, "targetType", {
7822
7830
  enumerable: true,
7823
7831
  configurable: true,
@@ -8143,7 +8151,7 @@ function reference(subType, options) {
8143
8151
  if (devMode()) {
8144
8152
  if (arguments.length === 2 && typeof arguments[1] === "string") {
8145
8153
  // istanbul ignore next
8146
- throw fail$1("References with base path are no longer supported. Please remove the base path.");
8154
+ throw fail("References with base path are no longer supported. Please remove the base path.");
8147
8155
  }
8148
8156
  }
8149
8157
  var getSetOptions = options ? options : undefined;
@@ -8153,7 +8161,7 @@ function reference(subType, options) {
8153
8161
  if (getSetOptions && (getSetOptions.get || getSetOptions.set)) {
8154
8162
  if (devMode()) {
8155
8163
  if (!getSetOptions.get || !getSetOptions.set) {
8156
- throw fail$1("reference options must either contain both a 'get' and a 'set' method or none of them");
8164
+ throw fail("reference options must either contain both a 'get' and a 'set' method or none of them");
8157
8165
  }
8158
8166
  }
8159
8167
  return new CustomReferenceType(subType, {
@@ -8231,7 +8239,7 @@ var BaseIdentifierType = /** @class */ (function (_super) {
8231
8239
  writable: true,
8232
8240
  value: function (parent, subpath, environment, initialValue) {
8233
8241
  if (!parent || !(parent.type instanceof ModelType))
8234
- throw fail$1("Identifier types can only be instantiated as direct child of a model type");
8242
+ throw fail("Identifier types can only be instantiated as direct child of a model type");
8235
8243
  return createScalarNode(this, parent, subpath, environment, initialValue);
8236
8244
  }
8237
8245
  });
@@ -8242,7 +8250,7 @@ var BaseIdentifierType = /** @class */ (function (_super) {
8242
8250
  value: function (current, newValue, parent, subpath) {
8243
8251
  // we don't consider detaching here since identifier are scalar nodes, and scalar nodes cannot be detached
8244
8252
  if (current.storedValue !== newValue)
8245
- throw fail$1("Tried to change identifier from '" + current.storedValue + "' to '" + newValue + "'. Changing identifiers is not allowed.");
8253
+ throw fail("Tried to change identifier from '".concat(current.storedValue, "' to '").concat(newValue, "'. Changing identifiers is not allowed."));
8246
8254
  current.setParent(parent, subpath);
8247
8255
  return current;
8248
8256
  }
@@ -8253,7 +8261,7 @@ var BaseIdentifierType = /** @class */ (function (_super) {
8253
8261
  writable: true,
8254
8262
  value: function (value, context) {
8255
8263
  if (typeof value !== this.validType) {
8256
- return typeCheckFailure(context, value, "Value is not a valid " + this.describe() + ", expected a " + this.validType);
8264
+ return typeCheckFailure(context, value, "Value is not a valid ".concat(this.describe(), ", expected a ").concat(this.validType));
8257
8265
  }
8258
8266
  return typeCheckSuccess();
8259
8267
  }
@@ -8464,7 +8472,7 @@ var CustomType = /** @class */ (function (_super) {
8464
8472
  return typeCheckSuccess();
8465
8473
  var typeError = this.options.getValidationMessage(value);
8466
8474
  if (typeError) {
8467
- return typeCheckFailure(context, value, "Invalid value for type '" + this.name + "': " + typeError);
8475
+ return typeCheckFailure(context, value, "Invalid value for type '".concat(this.name, "': ").concat(typeError));
8468
8476
  }
8469
8477
  return typeCheckSuccess();
8470
8478
  }