mobx 6.3.13 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/errors.d.ts +2 -2
- package/dist/mobx.cjs.development.js +940 -263
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +940 -263
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +958 -269
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +940 -263
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/dist/types/observablemap.d.ts +2 -2
- package/dist/utils/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/action.ts +8 -3
- package/src/api/annotation.ts +1 -2
- package/src/api/autorun.ts +22 -8
- package/src/api/computed.ts +5 -2
- package/src/api/configure.ts +6 -2
- package/src/api/extendobservable.ts +11 -5
- package/src/api/extras.ts +4 -2
- package/src/api/flow.ts +11 -4
- package/src/api/intercept-read.ts +4 -2
- package/src/api/intercept.ts +5 -2
- package/src/api/iscomputed.ts +10 -4
- package/src/api/isobservable.ts +10 -4
- package/src/api/makeObservable.ts +4 -2
- package/src/api/object-api.ts +30 -16
- package/src/api/observable.ts +23 -9
- package/src/api/observe.ts +4 -2
- package/src/api/tojs.ts +7 -3
- package/src/api/trace.ts +6 -2
- package/src/api/when.ts +12 -5
- package/src/core/action.ts +8 -3
- package/src/core/computedvalue.ts +29 -9
- package/src/core/derivation.ts +25 -9
- package/src/core/globalstate.ts +18 -7
- package/src/core/observable.ts +14 -5
- package/src/core/reaction.ts +15 -6
- package/src/core/spy.ts +20 -7
- package/src/errors.ts +2 -2
- package/src/types/actionannotation.ts +2 -2
- package/src/types/dynamicobject.ts +10 -4
- package/src/types/flowannotation.ts +3 -1
- package/src/types/intercept-utils.ts +9 -3
- package/src/types/legacyobservablearray.ts +5 -3
- package/src/types/listen-utils.ts +6 -2
- package/src/types/modifiers.ts +39 -14
- package/src/types/observablearray.ts +78 -30
- package/src/types/observablemap.ts +60 -24
- package/src/types/observableobject.ts +52 -18
- package/src/types/observableset.ts +29 -10
- package/src/types/observablevalue.ts +13 -5
- package/src/types/type-utils.ts +33 -11
- package/src/utils/comparer.ts +4 -4
- package/src/utils/eq.ts +45 -15
- package/src/utils/utils.ts +42 -20
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
10: "'has()' can only be used on observable objects, arrays and maps",
|
|
30
30
|
11: "'get()' can only be used on observable objects, arrays and maps",
|
|
31
31
|
12: "Invalid annotation",
|
|
32
|
-
13: "Dynamic observable objects cannot be frozen",
|
|
32
|
+
13: "Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",
|
|
33
33
|
14: "Intercept handlers should return nothing or a change object",
|
|
34
|
-
15: "Observable arrays cannot be frozen",
|
|
34
|
+
15: "Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",
|
|
35
35
|
16: "Modification exception: the internal structure of an observable array was changed.",
|
|
36
36
|
17: function _(index, length) {
|
|
37
37
|
return "[mobx.array] Index out of bounds, " + index + " is larger than " + length;
|
|
@@ -145,7 +145,10 @@
|
|
|
145
145
|
function once(func) {
|
|
146
146
|
var invoked = false;
|
|
147
147
|
return function () {
|
|
148
|
-
if (invoked)
|
|
148
|
+
if (invoked) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
149
152
|
invoked = true;
|
|
150
153
|
return func.apply(this, arguments);
|
|
151
154
|
};
|
|
@@ -170,17 +173,31 @@
|
|
|
170
173
|
return value !== null && typeof value === "object";
|
|
171
174
|
}
|
|
172
175
|
function isPlainObject(value) {
|
|
173
|
-
if (!isObject(value))
|
|
176
|
+
if (!isObject(value)) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
174
180
|
var proto = Object.getPrototypeOf(value);
|
|
175
|
-
|
|
181
|
+
|
|
182
|
+
if (proto == null) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
|
|
176
186
|
var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
177
187
|
return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
|
|
178
188
|
} // https://stackoverflow.com/a/37865170
|
|
179
189
|
|
|
180
190
|
function isGenerator(obj) {
|
|
181
191
|
var constructor = obj == null ? void 0 : obj.constructor;
|
|
182
|
-
|
|
183
|
-
if (
|
|
192
|
+
|
|
193
|
+
if (!constructor) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
|
|
184
201
|
return false;
|
|
185
202
|
}
|
|
186
203
|
function addHiddenProp(object, propName, value) {
|
|
@@ -220,9 +237,16 @@
|
|
|
220
237
|
function getPlainObjectKeys(object) {
|
|
221
238
|
var keys = Object.keys(object); // Not supported in IE, so there are not going to be symbol props anyway...
|
|
222
239
|
|
|
223
|
-
if (!hasGetOwnPropertySymbols)
|
|
240
|
+
if (!hasGetOwnPropertySymbols) {
|
|
241
|
+
return keys;
|
|
242
|
+
}
|
|
243
|
+
|
|
224
244
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
225
|
-
|
|
245
|
+
|
|
246
|
+
if (!symbols.length) {
|
|
247
|
+
return keys;
|
|
248
|
+
}
|
|
249
|
+
|
|
226
250
|
return [].concat(keys, symbols.filter(function (s) {
|
|
227
251
|
return objectPrototype.propertyIsEnumerable.call(object, s);
|
|
228
252
|
}));
|
|
@@ -235,8 +259,14 @@
|
|
|
235
259
|
/* istanbul ignore next */
|
|
236
260
|
Object.getOwnPropertyNames;
|
|
237
261
|
function stringifyKey(key) {
|
|
238
|
-
if (typeof key === "string")
|
|
239
|
-
|
|
262
|
+
if (typeof key === "string") {
|
|
263
|
+
return key;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (typeof key === "symbol") {
|
|
267
|
+
return key.toString();
|
|
268
|
+
}
|
|
269
|
+
|
|
240
270
|
return new String(key).toString();
|
|
241
271
|
}
|
|
242
272
|
function toPrimitive(value) {
|
|
@@ -524,7 +554,10 @@
|
|
|
524
554
|
}
|
|
525
555
|
|
|
526
556
|
function defaultComparer(a, b) {
|
|
527
|
-
if (Object.is)
|
|
557
|
+
if (Object.is) {
|
|
558
|
+
return Object.is(a, b);
|
|
559
|
+
}
|
|
560
|
+
|
|
528
561
|
return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
|
|
529
562
|
}
|
|
530
563
|
|
|
@@ -537,20 +570,34 @@
|
|
|
537
570
|
|
|
538
571
|
function deepEnhancer(v, _, name) {
|
|
539
572
|
// it is an observable already, done
|
|
540
|
-
if (isObservable(v))
|
|
573
|
+
if (isObservable(v)) {
|
|
574
|
+
return v;
|
|
575
|
+
} // something that can be converted and mutated?
|
|
541
576
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
577
|
+
|
|
578
|
+
if (Array.isArray(v)) {
|
|
579
|
+
return observable.array(v, {
|
|
580
|
+
name: name
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (isPlainObject(v)) {
|
|
585
|
+
return observable.object(v, undefined, {
|
|
586
|
+
name: name
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (isES6Map(v)) {
|
|
591
|
+
return observable.map(v, {
|
|
592
|
+
name: name
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (isES6Set(v)) {
|
|
597
|
+
return observable.set(v, {
|
|
598
|
+
name: name
|
|
599
|
+
});
|
|
600
|
+
}
|
|
554
601
|
|
|
555
602
|
if (typeof v === "function" && !isAction(v) && !isFlow(v)) {
|
|
556
603
|
if (isGenerator(v)) {
|
|
@@ -563,33 +610,59 @@
|
|
|
563
610
|
return v;
|
|
564
611
|
}
|
|
565
612
|
function shallowEnhancer(v, _, name) {
|
|
566
|
-
if (v === undefined || v === null)
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
613
|
+
if (v === undefined || v === null) {
|
|
614
|
+
return v;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {
|
|
618
|
+
return v;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (Array.isArray(v)) {
|
|
622
|
+
return observable.array(v, {
|
|
623
|
+
name: name,
|
|
624
|
+
deep: false
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (isPlainObject(v)) {
|
|
629
|
+
return observable.object(v, undefined, {
|
|
630
|
+
name: name,
|
|
631
|
+
deep: false
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
if (isES6Map(v)) {
|
|
636
|
+
return observable.map(v, {
|
|
637
|
+
name: name,
|
|
638
|
+
deep: false
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (isES6Set(v)) {
|
|
643
|
+
return observable.set(v, {
|
|
644
|
+
name: name,
|
|
645
|
+
deep: false
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
{
|
|
650
|
+
die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
|
|
651
|
+
}
|
|
585
652
|
}
|
|
586
653
|
function referenceEnhancer(newValue) {
|
|
587
654
|
// never turn into an observable
|
|
588
655
|
return newValue;
|
|
589
656
|
}
|
|
590
657
|
function refStructEnhancer(v, oldValue) {
|
|
591
|
-
if ( isObservable(v))
|
|
592
|
-
|
|
658
|
+
if ( isObservable(v)) {
|
|
659
|
+
die("observable.struct should not be used with observable values");
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (deepEqual(v, oldValue)) {
|
|
663
|
+
return oldValue;
|
|
664
|
+
}
|
|
665
|
+
|
|
593
666
|
return v;
|
|
594
667
|
}
|
|
595
668
|
|
|
@@ -738,9 +811,11 @@
|
|
|
738
811
|
|
|
739
812
|
|
|
740
813
|
if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
|
|
741
|
-
if (this.extend_(adm, key, descriptor, false) === null)
|
|
742
|
-
|
|
743
|
-
|
|
814
|
+
if (this.extend_(adm, key, descriptor, false) === null) {
|
|
815
|
+
return 0
|
|
816
|
+
/* Cancel */
|
|
817
|
+
;
|
|
818
|
+
}
|
|
744
819
|
}
|
|
745
820
|
|
|
746
821
|
if (isFlow(descriptor.value)) {
|
|
@@ -1031,17 +1106,35 @@
|
|
|
1031
1106
|
} // already observable - ignore
|
|
1032
1107
|
|
|
1033
1108
|
|
|
1034
|
-
if (isObservable(v))
|
|
1109
|
+
if (isObservable(v)) {
|
|
1110
|
+
return v;
|
|
1111
|
+
} // plain object
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
if (isPlainObject(v)) {
|
|
1115
|
+
return observable.object(v, arg2, arg3);
|
|
1116
|
+
} // Array
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
if (Array.isArray(v)) {
|
|
1120
|
+
return observable.array(v, arg2);
|
|
1121
|
+
} // Map
|
|
1122
|
+
|
|
1035
1123
|
|
|
1036
|
-
if (
|
|
1124
|
+
if (isES6Map(v)) {
|
|
1125
|
+
return observable.map(v, arg2);
|
|
1126
|
+
} // Set
|
|
1037
1127
|
|
|
1038
|
-
if (Array.isArray(v)) return observable.array(v, arg2); // Map
|
|
1039
1128
|
|
|
1040
|
-
if (
|
|
1129
|
+
if (isES6Set(v)) {
|
|
1130
|
+
return observable.set(v, arg2);
|
|
1131
|
+
} // other object - ignore
|
|
1041
1132
|
|
|
1042
|
-
if (isES6Set(v)) return observable.set(v, arg2); // other object - ignore
|
|
1043
1133
|
|
|
1044
|
-
if (typeof v === "object" && v !== null)
|
|
1134
|
+
if (typeof v === "object" && v !== null) {
|
|
1135
|
+
return v;
|
|
1136
|
+
} // anything else
|
|
1137
|
+
|
|
1045
1138
|
|
|
1046
1139
|
return observable.box(v, arg2);
|
|
1047
1140
|
}
|
|
@@ -1099,8 +1192,13 @@
|
|
|
1099
1192
|
|
|
1100
1193
|
|
|
1101
1194
|
{
|
|
1102
|
-
if (!isFunction(arg1))
|
|
1103
|
-
|
|
1195
|
+
if (!isFunction(arg1)) {
|
|
1196
|
+
die("First argument to `computed` should be an expression.");
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
if (isFunction(arg2)) {
|
|
1200
|
+
die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
|
|
1201
|
+
}
|
|
1104
1202
|
}
|
|
1105
1203
|
|
|
1106
1204
|
var opts = isPlainObject(arg2) ? arg2 : {};
|
|
@@ -1132,8 +1230,13 @@
|
|
|
1132
1230
|
}
|
|
1133
1231
|
|
|
1134
1232
|
{
|
|
1135
|
-
if (!isFunction(fn))
|
|
1136
|
-
|
|
1233
|
+
if (!isFunction(fn)) {
|
|
1234
|
+
die("`action` can only be invoked on functions");
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
if (typeof actionName !== "string" || !actionName) {
|
|
1238
|
+
die("actions should have valid names, got: '" + actionName + "'");
|
|
1239
|
+
}
|
|
1137
1240
|
}
|
|
1138
1241
|
|
|
1139
1242
|
function res() {
|
|
@@ -1215,7 +1318,10 @@
|
|
|
1215
1318
|
allowStateChangesEnd(runInfo.prevAllowStateChanges_);
|
|
1216
1319
|
allowStateReadsEnd(runInfo.prevAllowStateReads_);
|
|
1217
1320
|
endBatch();
|
|
1218
|
-
|
|
1321
|
+
|
|
1322
|
+
if (runInfo.runAsAction_) {
|
|
1323
|
+
untrackedEnd(runInfo.prevDerivation_);
|
|
1324
|
+
}
|
|
1219
1325
|
|
|
1220
1326
|
if ( runInfo.notifySpy_) {
|
|
1221
1327
|
spyReportEnd({
|
|
@@ -1295,7 +1401,10 @@
|
|
|
1295
1401
|
var _proto = ObservableValue.prototype;
|
|
1296
1402
|
|
|
1297
1403
|
_proto.dehanceValue = function dehanceValue(value) {
|
|
1298
|
-
if (this.dehancer !== undefined)
|
|
1404
|
+
if (this.dehancer !== undefined) {
|
|
1405
|
+
return this.dehancer(value);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1299
1408
|
return value;
|
|
1300
1409
|
};
|
|
1301
1410
|
|
|
@@ -1318,7 +1427,10 @@
|
|
|
1318
1427
|
}
|
|
1319
1428
|
|
|
1320
1429
|
this.setNewValue_(newValue);
|
|
1321
|
-
|
|
1430
|
+
|
|
1431
|
+
if ( notifySpy) {
|
|
1432
|
+
spyReportEnd();
|
|
1433
|
+
}
|
|
1322
1434
|
}
|
|
1323
1435
|
};
|
|
1324
1436
|
|
|
@@ -1331,7 +1443,11 @@
|
|
|
1331
1443
|
type: UPDATE,
|
|
1332
1444
|
newValue: newValue
|
|
1333
1445
|
});
|
|
1334
|
-
|
|
1446
|
+
|
|
1447
|
+
if (!change) {
|
|
1448
|
+
return globalState.UNCHANGED;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1335
1451
|
newValue = change.newValue;
|
|
1336
1452
|
} // apply modifier
|
|
1337
1453
|
|
|
@@ -1365,14 +1481,17 @@
|
|
|
1365
1481
|
};
|
|
1366
1482
|
|
|
1367
1483
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
1368
|
-
if (fireImmediately)
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1484
|
+
if (fireImmediately) {
|
|
1485
|
+
listener({
|
|
1486
|
+
observableKind: "value",
|
|
1487
|
+
debugObjectName: this.name_,
|
|
1488
|
+
object: this,
|
|
1489
|
+
type: UPDATE,
|
|
1490
|
+
newValue: this.value_,
|
|
1491
|
+
oldValue: undefined
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1376
1495
|
return registerListener(this, listener);
|
|
1377
1496
|
};
|
|
1378
1497
|
|
|
@@ -1467,7 +1586,11 @@
|
|
|
1467
1586
|
this.keepAlive_ = void 0;
|
|
1468
1587
|
this.onBOL = void 0;
|
|
1469
1588
|
this.onBUOL = void 0;
|
|
1470
|
-
|
|
1589
|
+
|
|
1590
|
+
if (!options.get) {
|
|
1591
|
+
die(31);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1471
1594
|
this.derivation = options.get;
|
|
1472
1595
|
this.name_ = options.name || ( "ComputedValue@" + getNextId() );
|
|
1473
1596
|
|
|
@@ -1509,7 +1632,9 @@
|
|
|
1509
1632
|
;
|
|
1510
1633
|
|
|
1511
1634
|
_proto.get = function get() {
|
|
1512
|
-
if (this.isComputing_)
|
|
1635
|
+
if (this.isComputing_) {
|
|
1636
|
+
die(32, this.name_, this.derivation);
|
|
1637
|
+
}
|
|
1513
1638
|
|
|
1514
1639
|
if (globalState.inBatch === 0 && // !globalState.trackingDerivatpion &&
|
|
1515
1640
|
this.observers_.size === 0 && !this.keepAlive_) {
|
|
@@ -1525,20 +1650,34 @@
|
|
|
1525
1650
|
|
|
1526
1651
|
if (shouldCompute(this)) {
|
|
1527
1652
|
var prevTrackingContext = globalState.trackingContext;
|
|
1528
|
-
|
|
1529
|
-
if (this.
|
|
1653
|
+
|
|
1654
|
+
if (this.keepAlive_ && !prevTrackingContext) {
|
|
1655
|
+
globalState.trackingContext = this;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
if (this.trackAndCompute()) {
|
|
1659
|
+
propagateChangeConfirmed(this);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1530
1662
|
globalState.trackingContext = prevTrackingContext;
|
|
1531
1663
|
}
|
|
1532
1664
|
}
|
|
1533
1665
|
|
|
1534
1666
|
var result = this.value_;
|
|
1535
|
-
|
|
1667
|
+
|
|
1668
|
+
if (isCaughtException(result)) {
|
|
1669
|
+
throw result.cause;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1536
1672
|
return result;
|
|
1537
1673
|
};
|
|
1538
1674
|
|
|
1539
1675
|
_proto.set = function set(value) {
|
|
1540
1676
|
if (this.setter_) {
|
|
1541
|
-
if (this.isRunningSetter_)
|
|
1677
|
+
if (this.isRunningSetter_) {
|
|
1678
|
+
die(33, this.name_);
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1542
1681
|
this.isRunningSetter_ = true;
|
|
1543
1682
|
|
|
1544
1683
|
try {
|
|
@@ -1546,7 +1685,9 @@
|
|
|
1546
1685
|
} finally {
|
|
1547
1686
|
this.isRunningSetter_ = false;
|
|
1548
1687
|
}
|
|
1549
|
-
} else
|
|
1688
|
+
} else {
|
|
1689
|
+
die(34, this.name_);
|
|
1690
|
+
}
|
|
1550
1691
|
};
|
|
1551
1692
|
|
|
1552
1693
|
_proto.trackAndCompute = function trackAndCompute() {
|
|
@@ -1775,7 +1916,9 @@
|
|
|
1775
1916
|
|
|
1776
1917
|
var hasObservers = atom.observers_.size > 0; // Should not be possible to change observed state outside strict mode, except during initialization, see #563
|
|
1777
1918
|
|
|
1778
|
-
if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always"))
|
|
1919
|
+
if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) {
|
|
1920
|
+
console.warn("[MobX] " + (globalState.enforceActions ? "Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: " : "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ") + atom.name_);
|
|
1921
|
+
}
|
|
1779
1922
|
}
|
|
1780
1923
|
function checkIfStateReadsAreAllowed(observable) {
|
|
1781
1924
|
if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
|
|
@@ -1820,7 +1963,10 @@
|
|
|
1820
1963
|
}
|
|
1821
1964
|
|
|
1822
1965
|
function warnAboutDerivationWithoutDependencies(derivation) {
|
|
1823
|
-
|
|
1966
|
+
|
|
1967
|
+
if (derivation.observing_.length !== 0) {
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1824
1970
|
|
|
1825
1971
|
if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
|
|
1826
1972
|
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
@@ -1849,7 +1995,11 @@
|
|
|
1849
1995
|
|
|
1850
1996
|
if (dep.diffValue_ === 0) {
|
|
1851
1997
|
dep.diffValue_ = 1;
|
|
1852
|
-
|
|
1998
|
+
|
|
1999
|
+
if (i0 !== i) {
|
|
2000
|
+
observing[i0] = dep;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
1853
2003
|
i0++;
|
|
1854
2004
|
} // Upcast is 'safe' here, because if dep is IObservable, `dependenciesState` will be undefined,
|
|
1855
2005
|
// not hitting the condition
|
|
@@ -1941,7 +2091,10 @@
|
|
|
1941
2091
|
*/
|
|
1942
2092
|
|
|
1943
2093
|
function changeDependenciesStateTo0(derivation) {
|
|
1944
|
-
if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_)
|
|
2094
|
+
if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
|
|
1945
2098
|
derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_;
|
|
1946
2099
|
var obs = derivation.observing_;
|
|
1947
2100
|
var i = obs.length;
|
|
@@ -1985,8 +2138,14 @@
|
|
|
1985
2138
|
var isolateCalled = false;
|
|
1986
2139
|
var globalState = /*#__PURE__*/function () {
|
|
1987
2140
|
var global = /*#__PURE__*/getGlobal();
|
|
1988
|
-
|
|
1989
|
-
if (global.
|
|
2141
|
+
|
|
2142
|
+
if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) {
|
|
2143
|
+
canMergeGlobalState = false;
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) {
|
|
2147
|
+
canMergeGlobalState = false;
|
|
2148
|
+
}
|
|
1990
2149
|
|
|
1991
2150
|
if (!canMergeGlobalState) {
|
|
1992
2151
|
// Because this is a IIFE we need to let isolateCalled a chance to change
|
|
@@ -1999,7 +2158,11 @@
|
|
|
1999
2158
|
return new MobXGlobals();
|
|
2000
2159
|
} else if (global.__mobxGlobals) {
|
|
2001
2160
|
global.__mobxInstanceCount += 1;
|
|
2002
|
-
|
|
2161
|
+
|
|
2162
|
+
if (!global.__mobxGlobals.UNCHANGED) {
|
|
2163
|
+
global.__mobxGlobals.UNCHANGED = {};
|
|
2164
|
+
} // make merge backward compatible
|
|
2165
|
+
|
|
2003
2166
|
|
|
2004
2167
|
return global.__mobxGlobals;
|
|
2005
2168
|
} else {
|
|
@@ -2008,12 +2171,19 @@
|
|
|
2008
2171
|
}
|
|
2009
2172
|
}();
|
|
2010
2173
|
function isolateGlobalState() {
|
|
2011
|
-
if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions)
|
|
2174
|
+
if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) {
|
|
2175
|
+
die(36);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2012
2178
|
isolateCalled = true;
|
|
2013
2179
|
|
|
2014
2180
|
if (canMergeGlobalState) {
|
|
2015
2181
|
var global = getGlobal();
|
|
2016
|
-
|
|
2182
|
+
|
|
2183
|
+
if (--global.__mobxInstanceCount === 0) {
|
|
2184
|
+
global.__mobxGlobals = undefined;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2017
2187
|
globalState = new MobXGlobals();
|
|
2018
2188
|
}
|
|
2019
2189
|
}
|
|
@@ -2029,7 +2199,9 @@
|
|
|
2029
2199
|
var defaultGlobals = new MobXGlobals();
|
|
2030
2200
|
|
|
2031
2201
|
for (var key in defaultGlobals) {
|
|
2032
|
-
if (persistentKeys.indexOf(key) === -1)
|
|
2202
|
+
if (persistentKeys.indexOf(key) === -1) {
|
|
2203
|
+
globalState[key] = defaultGlobals[key];
|
|
2204
|
+
}
|
|
2033
2205
|
}
|
|
2034
2206
|
|
|
2035
2207
|
globalState.allowStateChanges = !globalState.enforceActions;
|
|
@@ -2063,8 +2235,12 @@
|
|
|
2063
2235
|
// invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR add already added node");
|
|
2064
2236
|
// invariantObservers(observable);
|
|
2065
2237
|
observable.observers_.add(node);
|
|
2066
|
-
|
|
2238
|
+
|
|
2239
|
+
if (observable.lowestObserverState_ > node.dependenciesState_) {
|
|
2240
|
+
observable.lowestObserverState_ = node.dependenciesState_;
|
|
2241
|
+
} // invariantObservers(observable);
|
|
2067
2242
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
|
|
2243
|
+
|
|
2068
2244
|
}
|
|
2069
2245
|
function removeObserver(observable, node) {
|
|
2070
2246
|
// invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
|
|
@@ -2175,7 +2351,10 @@
|
|
|
2175
2351
|
|
|
2176
2352
|
function propagateChanged(observable) {
|
|
2177
2353
|
// invariantLOS(observable, "changed start");
|
|
2178
|
-
if (observable.lowestObserverState_ === IDerivationState_.STALE_)
|
|
2354
|
+
if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2179
2358
|
observable.lowestObserverState_ = IDerivationState_.STALE_; // Ideally we use for..of here, but the downcompiled version is really slow...
|
|
2180
2359
|
|
|
2181
2360
|
observable.observers_.forEach(function (d) {
|
|
@@ -2193,7 +2372,10 @@
|
|
|
2193
2372
|
|
|
2194
2373
|
function propagateChangeConfirmed(observable) {
|
|
2195
2374
|
// invariantLOS(observable, "confirmed start");
|
|
2196
|
-
if (observable.lowestObserverState_ === IDerivationState_.STALE_)
|
|
2375
|
+
if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2197
2379
|
observable.lowestObserverState_ = IDerivationState_.STALE_;
|
|
2198
2380
|
observable.observers_.forEach(function (d) {
|
|
2199
2381
|
if (d.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) {
|
|
@@ -2211,7 +2393,10 @@
|
|
|
2211
2393
|
|
|
2212
2394
|
function propagateMaybeChanged(observable) {
|
|
2213
2395
|
// invariantLOS(observable, "maybe start");
|
|
2214
|
-
if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_)
|
|
2396
|
+
if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) {
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2215
2400
|
observable.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_;
|
|
2216
2401
|
observable.observers_.forEach(function (d) {
|
|
2217
2402
|
if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
|
|
@@ -2239,9 +2424,12 @@
|
|
|
2239
2424
|
}
|
|
2240
2425
|
|
|
2241
2426
|
lines.push("" + "\t".repeat(depth - 1) + tree.name);
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2427
|
+
|
|
2428
|
+
if (tree.dependencies) {
|
|
2429
|
+
tree.dependencies.forEach(function (child) {
|
|
2430
|
+
return printDepTree(child, lines, depth + 1);
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2245
2433
|
}
|
|
2246
2434
|
|
|
2247
2435
|
var Reaction = /*#__PURE__*/function () {
|
|
@@ -2359,7 +2547,9 @@
|
|
|
2359
2547
|
clearObserving(this);
|
|
2360
2548
|
}
|
|
2361
2549
|
|
|
2362
|
-
if (isCaughtException(result))
|
|
2550
|
+
if (isCaughtException(result)) {
|
|
2551
|
+
this.reportExceptionInDerivation_(result.cause);
|
|
2552
|
+
}
|
|
2363
2553
|
|
|
2364
2554
|
if ( notify) {
|
|
2365
2555
|
spyReportEnd({
|
|
@@ -2378,13 +2568,18 @@
|
|
|
2378
2568
|
return;
|
|
2379
2569
|
}
|
|
2380
2570
|
|
|
2381
|
-
if (globalState.disableErrorBoundaries)
|
|
2571
|
+
if (globalState.disableErrorBoundaries) {
|
|
2572
|
+
throw error;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2382
2575
|
var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'" ;
|
|
2383
2576
|
|
|
2384
2577
|
if (!globalState.suppressReactionErrors) {
|
|
2385
2578
|
console.error(message, error);
|
|
2386
2579
|
/** If debugging brought you here, please, read the above message :-). Tnx! */
|
|
2387
|
-
} else
|
|
2580
|
+
} else {
|
|
2581
|
+
console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)");
|
|
2582
|
+
} // prettier-ignore
|
|
2388
2583
|
|
|
2389
2584
|
|
|
2390
2585
|
if ( isSpyEnabled()) {
|
|
@@ -2438,7 +2633,10 @@
|
|
|
2438
2633
|
globalState.globalReactionErrorHandlers.push(handler);
|
|
2439
2634
|
return function () {
|
|
2440
2635
|
var idx = globalState.globalReactionErrorHandlers.indexOf(handler);
|
|
2441
|
-
|
|
2636
|
+
|
|
2637
|
+
if (idx >= 0) {
|
|
2638
|
+
globalState.globalReactionErrorHandlers.splice(idx, 1);
|
|
2639
|
+
}
|
|
2442
2640
|
};
|
|
2443
2641
|
}
|
|
2444
2642
|
/**
|
|
@@ -2455,7 +2653,10 @@
|
|
|
2455
2653
|
|
|
2456
2654
|
function runReactions() {
|
|
2457
2655
|
// Trampolining, if runReactions are already running, new reactions will be picked up
|
|
2458
|
-
if (globalState.inBatch > 0 || globalState.isRunningReactions)
|
|
2656
|
+
if (globalState.inBatch > 0 || globalState.isRunningReactions) {
|
|
2657
|
+
return;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2459
2660
|
reactionScheduler(runReactionsHelper);
|
|
2460
2661
|
}
|
|
2461
2662
|
|
|
@@ -2498,7 +2699,11 @@
|
|
|
2498
2699
|
}
|
|
2499
2700
|
function spyReport(event) {
|
|
2500
2701
|
|
|
2501
|
-
|
|
2702
|
+
|
|
2703
|
+
if (!globalState.spyListeners.length) {
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2502
2707
|
var listeners = globalState.spyListeners;
|
|
2503
2708
|
|
|
2504
2709
|
for (var i = 0, l = listeners.length; i < l; i++) {
|
|
@@ -2518,10 +2723,15 @@
|
|
|
2518
2723
|
spyReportEnd: true
|
|
2519
2724
|
};
|
|
2520
2725
|
function spyReportEnd(change) {
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2726
|
+
|
|
2727
|
+
if (change) {
|
|
2728
|
+
spyReport(_extends({}, change, {
|
|
2729
|
+
type: "report-end",
|
|
2730
|
+
spyReportEnd: true
|
|
2731
|
+
}));
|
|
2732
|
+
} else {
|
|
2733
|
+
spyReport(END_EVENT);
|
|
2734
|
+
}
|
|
2525
2735
|
}
|
|
2526
2736
|
function spy(listener) {
|
|
2527
2737
|
{
|
|
@@ -2554,9 +2764,15 @@
|
|
|
2554
2764
|
function createActionFactory(autoAction) {
|
|
2555
2765
|
var res = function action(arg1, arg2) {
|
|
2556
2766
|
// action(fn() {})
|
|
2557
|
-
if (isFunction(arg1))
|
|
2767
|
+
if (isFunction(arg1)) {
|
|
2768
|
+
return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction);
|
|
2769
|
+
} // action("name", fn() {})
|
|
2770
|
+
|
|
2771
|
+
|
|
2772
|
+
if (isFunction(arg2)) {
|
|
2773
|
+
return createAction(arg1, arg2, autoAction);
|
|
2774
|
+
} // @action
|
|
2558
2775
|
|
|
2559
|
-
if (isFunction(arg2)) return createAction(arg1, arg2, autoAction); // @action
|
|
2560
2776
|
|
|
2561
2777
|
if (isStringish(arg2)) {
|
|
2562
2778
|
return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
|
|
@@ -2570,7 +2786,9 @@
|
|
|
2570
2786
|
}));
|
|
2571
2787
|
}
|
|
2572
2788
|
|
|
2573
|
-
|
|
2789
|
+
{
|
|
2790
|
+
die("Invalid arguments for `action`");
|
|
2791
|
+
}
|
|
2574
2792
|
};
|
|
2575
2793
|
|
|
2576
2794
|
return res;
|
|
@@ -2604,8 +2822,13 @@
|
|
|
2604
2822
|
}
|
|
2605
2823
|
|
|
2606
2824
|
{
|
|
2607
|
-
if (!isFunction(view))
|
|
2608
|
-
|
|
2825
|
+
if (!isFunction(view)) {
|
|
2826
|
+
die("Autorun expects a function as first argument");
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
if (isAction(view)) {
|
|
2830
|
+
die("Autorun does not accept actions since actions are untrackable");
|
|
2831
|
+
}
|
|
2609
2832
|
}
|
|
2610
2833
|
|
|
2611
2834
|
var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : view.name || "Autorun@" + getNextId() ;
|
|
@@ -2626,7 +2849,10 @@
|
|
|
2626
2849
|
isScheduled = true;
|
|
2627
2850
|
scheduler(function () {
|
|
2628
2851
|
isScheduled = false;
|
|
2629
|
-
|
|
2852
|
+
|
|
2853
|
+
if (!reaction.isDisposed_) {
|
|
2854
|
+
reaction.track(reactionRunner);
|
|
2855
|
+
}
|
|
2630
2856
|
});
|
|
2631
2857
|
}
|
|
2632
2858
|
}, opts.onError, opts.requiresObservable);
|
|
@@ -2658,8 +2884,13 @@
|
|
|
2658
2884
|
}
|
|
2659
2885
|
|
|
2660
2886
|
{
|
|
2661
|
-
if (!isFunction(expression) || !isFunction(effect))
|
|
2662
|
-
|
|
2887
|
+
if (!isFunction(expression) || !isFunction(effect)) {
|
|
2888
|
+
die("First and second argument to reaction should be functions");
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
if (!isPlainObject(opts)) {
|
|
2892
|
+
die("Third argument of reactions should be an object");
|
|
2893
|
+
}
|
|
2663
2894
|
}
|
|
2664
2895
|
|
|
2665
2896
|
var name = (_opts$name2 = opts.name) != null ? _opts$name2 : "Reaction@" + getNextId() ;
|
|
@@ -2682,7 +2913,11 @@
|
|
|
2682
2913
|
|
|
2683
2914
|
function reactionRunner() {
|
|
2684
2915
|
isScheduled = false;
|
|
2685
|
-
|
|
2916
|
+
|
|
2917
|
+
if (r.isDisposed_) {
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2686
2921
|
var changed = false;
|
|
2687
2922
|
r.track(function () {
|
|
2688
2923
|
var nextValue = allowStateChanges(false, function () {
|
|
@@ -2692,7 +2927,13 @@
|
|
|
2692
2927
|
oldValue = value;
|
|
2693
2928
|
value = nextValue;
|
|
2694
2929
|
});
|
|
2695
|
-
|
|
2930
|
+
|
|
2931
|
+
if (firstTime && opts.fireImmediately) {
|
|
2932
|
+
effectAction(value, oldValue, r);
|
|
2933
|
+
} else if (!firstTime && changed) {
|
|
2934
|
+
effectAction(value, oldValue, r);
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2696
2937
|
firstTime = false;
|
|
2697
2938
|
}
|
|
2698
2939
|
|
|
@@ -2759,7 +3000,9 @@
|
|
|
2759
3000
|
globalState.useProxies = useProxies === ALWAYS ? true : useProxies === NEVER ? false : typeof Proxy !== "undefined";
|
|
2760
3001
|
}
|
|
2761
3002
|
|
|
2762
|
-
if (useProxies === "ifavailable")
|
|
3003
|
+
if (useProxies === "ifavailable") {
|
|
3004
|
+
globalState.verifyProxies = true;
|
|
3005
|
+
}
|
|
2763
3006
|
|
|
2764
3007
|
if (enforceActions !== undefined) {
|
|
2765
3008
|
var ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED;
|
|
@@ -2767,7 +3010,9 @@
|
|
|
2767
3010
|
globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true;
|
|
2768
3011
|
}
|
|
2769
3012
|
["computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "disableErrorBoundaries", "safeDescriptors"].forEach(function (key) {
|
|
2770
|
-
if (key in options)
|
|
3013
|
+
if (key in options) {
|
|
3014
|
+
globalState[key] = !!options[key];
|
|
3015
|
+
}
|
|
2771
3016
|
});
|
|
2772
3017
|
globalState.allowStateReads = !globalState.observableRequiresReaction;
|
|
2773
3018
|
|
|
@@ -2782,11 +3027,25 @@
|
|
|
2782
3027
|
|
|
2783
3028
|
function extendObservable(target, properties, annotations, options) {
|
|
2784
3029
|
{
|
|
2785
|
-
if (arguments.length > 4)
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
if (
|
|
3030
|
+
if (arguments.length > 4) {
|
|
3031
|
+
die("'extendObservable' expected 2-4 arguments");
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
if (typeof target !== "object") {
|
|
3035
|
+
die("'extendObservable' expects an object as first argument");
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
if (isObservableMap(target)) {
|
|
3039
|
+
die("'extendObservable' should not be used on maps, use map.merge instead");
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
if (!isPlainObject(properties)) {
|
|
3043
|
+
die("'extendObservable' only accepts plain objects as second argument");
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
if (isObservable(properties) || isObservable(annotations)) {
|
|
3047
|
+
die("Extending an object with another observable (object) is not supported");
|
|
3048
|
+
}
|
|
2790
3049
|
} // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
|
|
2791
3050
|
|
|
2792
3051
|
|
|
@@ -2814,7 +3073,11 @@
|
|
|
2814
3073
|
var result = {
|
|
2815
3074
|
name: node.name_
|
|
2816
3075
|
};
|
|
2817
|
-
|
|
3076
|
+
|
|
3077
|
+
if (node.observing_ && node.observing_.length > 0) {
|
|
3078
|
+
result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
|
|
3079
|
+
}
|
|
3080
|
+
|
|
2818
3081
|
return result;
|
|
2819
3082
|
}
|
|
2820
3083
|
|
|
@@ -2826,7 +3089,11 @@
|
|
|
2826
3089
|
var result = {
|
|
2827
3090
|
name: node.name_
|
|
2828
3091
|
};
|
|
2829
|
-
|
|
3092
|
+
|
|
3093
|
+
if (hasObservers(node)) {
|
|
3094
|
+
result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
|
|
3095
|
+
}
|
|
3096
|
+
|
|
2830
3097
|
return result;
|
|
2831
3098
|
}
|
|
2832
3099
|
|
|
@@ -2853,7 +3120,10 @@
|
|
|
2853
3120
|
} // flow(fn)
|
|
2854
3121
|
|
|
2855
3122
|
|
|
2856
|
-
if ( arguments.length !== 1)
|
|
3123
|
+
if ( arguments.length !== 1) {
|
|
3124
|
+
die("Flow expects single argument with generator function");
|
|
3125
|
+
}
|
|
3126
|
+
|
|
2857
3127
|
var generator = arg1;
|
|
2858
3128
|
var name = generator.name || "<unnamed flow>"; // Implementation based on https://github.com/tj/co/blob/master/index.js
|
|
2859
3129
|
|
|
@@ -2901,7 +3171,10 @@
|
|
|
2901
3171
|
return;
|
|
2902
3172
|
}
|
|
2903
3173
|
|
|
2904
|
-
if (ret.done)
|
|
3174
|
+
if (ret.done) {
|
|
3175
|
+
return resolve(ret.value);
|
|
3176
|
+
}
|
|
3177
|
+
|
|
2905
3178
|
pendingPromise = Promise.resolve(ret.value);
|
|
2906
3179
|
return pendingPromise.then(onFulfilled, onRejected);
|
|
2907
3180
|
}
|
|
@@ -2910,7 +3183,10 @@
|
|
|
2910
3183
|
});
|
|
2911
3184
|
promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
|
|
2912
3185
|
try {
|
|
2913
|
-
if (pendingPromise)
|
|
3186
|
+
if (pendingPromise) {
|
|
3187
|
+
cancelPromise(pendingPromise);
|
|
3188
|
+
} // Finally block can return (or yield) stuff..
|
|
3189
|
+
|
|
2914
3190
|
|
|
2915
3191
|
var _res = gen["return"](undefined); // eat anything that promise would do, it's cancelled!
|
|
2916
3192
|
|
|
@@ -2934,7 +3210,9 @@
|
|
|
2934
3210
|
flow.bound = /*#__PURE__*/createDecoratorAnnotation(flowBoundAnnotation);
|
|
2935
3211
|
|
|
2936
3212
|
function cancelPromise(promise) {
|
|
2937
|
-
if (isFunction(promise.cancel))
|
|
3213
|
+
if (isFunction(promise.cancel)) {
|
|
3214
|
+
promise.cancel();
|
|
3215
|
+
}
|
|
2938
3216
|
}
|
|
2939
3217
|
|
|
2940
3218
|
function flowResult(result) {
|
|
@@ -2950,13 +3228,19 @@
|
|
|
2950
3228
|
if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {
|
|
2951
3229
|
target = getAdministration(thing);
|
|
2952
3230
|
} else if (isObservableObject(thing)) {
|
|
2953
|
-
if ( !isStringish(propOrHandler))
|
|
3231
|
+
if ( !isStringish(propOrHandler)) {
|
|
3232
|
+
return die("InterceptReads can only be used with a specific property, not with an object in general");
|
|
3233
|
+
}
|
|
3234
|
+
|
|
2954
3235
|
target = getAdministration(thing, propOrHandler);
|
|
2955
3236
|
} else {
|
|
2956
3237
|
return die("Expected observable map, object or array as first array");
|
|
2957
3238
|
}
|
|
2958
3239
|
|
|
2959
|
-
if ( target.dehancer !== undefined)
|
|
3240
|
+
if ( target.dehancer !== undefined) {
|
|
3241
|
+
return die("An intercept reader was already established");
|
|
3242
|
+
}
|
|
3243
|
+
|
|
2960
3244
|
target.dehancer = typeof propOrHandler === "function" ? propOrHandler : handler;
|
|
2961
3245
|
return function () {
|
|
2962
3246
|
target.dehancer = undefined;
|
|
@@ -2964,7 +3248,11 @@
|
|
|
2964
3248
|
}
|
|
2965
3249
|
|
|
2966
3250
|
function intercept(thing, propOrHandler, handler) {
|
|
2967
|
-
if (isFunction(handler))
|
|
3251
|
+
if (isFunction(handler)) {
|
|
3252
|
+
return interceptProperty(thing, propOrHandler, handler);
|
|
3253
|
+
} else {
|
|
3254
|
+
return interceptInterceptable(thing, propOrHandler);
|
|
3255
|
+
}
|
|
2968
3256
|
}
|
|
2969
3257
|
|
|
2970
3258
|
function interceptInterceptable(thing, handler) {
|
|
@@ -2980,25 +3268,41 @@
|
|
|
2980
3268
|
return isComputedValue(value);
|
|
2981
3269
|
}
|
|
2982
3270
|
|
|
2983
|
-
if (isObservableObject(value) === false)
|
|
2984
|
-
|
|
3271
|
+
if (isObservableObject(value) === false) {
|
|
3272
|
+
return false;
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
if (!value[$mobx].values_.has(property)) {
|
|
3276
|
+
return false;
|
|
3277
|
+
}
|
|
3278
|
+
|
|
2985
3279
|
var atom = getAtom(value, property);
|
|
2986
3280
|
return isComputedValue(atom);
|
|
2987
3281
|
}
|
|
2988
3282
|
function isComputed(value) {
|
|
2989
|
-
if ( arguments.length > 1)
|
|
3283
|
+
if ( arguments.length > 1) {
|
|
3284
|
+
return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
|
|
3285
|
+
}
|
|
3286
|
+
|
|
2990
3287
|
return _isComputed(value);
|
|
2991
3288
|
}
|
|
2992
3289
|
function isComputedProp(value, propName) {
|
|
2993
|
-
if ( !isStringish(propName))
|
|
3290
|
+
if ( !isStringish(propName)) {
|
|
3291
|
+
return die("isComputed expected a property name as second argument");
|
|
3292
|
+
}
|
|
3293
|
+
|
|
2994
3294
|
return _isComputed(value, propName);
|
|
2995
3295
|
}
|
|
2996
3296
|
|
|
2997
3297
|
function _isObservable(value, property) {
|
|
2998
|
-
if (!value)
|
|
3298
|
+
if (!value) {
|
|
3299
|
+
return false;
|
|
3300
|
+
}
|
|
2999
3301
|
|
|
3000
3302
|
if (property !== undefined) {
|
|
3001
|
-
if ( (isObservableMap(value) || isObservableArray(value)))
|
|
3303
|
+
if ( (isObservableMap(value) || isObservableArray(value))) {
|
|
3304
|
+
return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
|
|
3305
|
+
}
|
|
3002
3306
|
|
|
3003
3307
|
if (isObservableObject(value)) {
|
|
3004
3308
|
return value[$mobx].values_.has(property);
|
|
@@ -3012,11 +3316,17 @@
|
|
|
3012
3316
|
}
|
|
3013
3317
|
|
|
3014
3318
|
function isObservable(value) {
|
|
3015
|
-
if ( arguments.length !== 1)
|
|
3319
|
+
if ( arguments.length !== 1) {
|
|
3320
|
+
die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3016
3323
|
return _isObservable(value);
|
|
3017
3324
|
}
|
|
3018
3325
|
function isObservableProp(value, propName) {
|
|
3019
|
-
if ( !isStringish(propName))
|
|
3326
|
+
if ( !isStringish(propName)) {
|
|
3327
|
+
return die("expected a property name as second argument");
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3020
3330
|
return _isObservable(value, propName);
|
|
3021
3331
|
}
|
|
3022
3332
|
|
|
@@ -3108,13 +3418,25 @@
|
|
|
3108
3418
|
} else if (isObservableSet(obj)) {
|
|
3109
3419
|
obj.add(key);
|
|
3110
3420
|
} else if (isObservableArray(obj)) {
|
|
3111
|
-
if (typeof key !== "number")
|
|
3112
|
-
|
|
3421
|
+
if (typeof key !== "number") {
|
|
3422
|
+
key = parseInt(key, 10);
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
if (key < 0) {
|
|
3426
|
+
die("Invalid index: '" + key + "'");
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3113
3429
|
startBatch();
|
|
3114
|
-
|
|
3430
|
+
|
|
3431
|
+
if (key >= obj.length) {
|
|
3432
|
+
obj.length = key + 1;
|
|
3433
|
+
}
|
|
3434
|
+
|
|
3115
3435
|
obj[key] = value;
|
|
3116
3436
|
endBatch();
|
|
3117
|
-
} else
|
|
3437
|
+
} else {
|
|
3438
|
+
die(8);
|
|
3439
|
+
}
|
|
3118
3440
|
}
|
|
3119
3441
|
function remove(obj, key) {
|
|
3120
3442
|
if (isObservableObject(obj)) {
|
|
@@ -3124,7 +3446,10 @@
|
|
|
3124
3446
|
} else if (isObservableSet(obj)) {
|
|
3125
3447
|
obj["delete"](key);
|
|
3126
3448
|
} else if (isObservableArray(obj)) {
|
|
3127
|
-
if (typeof key !== "number")
|
|
3449
|
+
if (typeof key !== "number") {
|
|
3450
|
+
key = parseInt(key, 10);
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3128
3453
|
obj.splice(key, 1);
|
|
3129
3454
|
} else {
|
|
3130
3455
|
die(9);
|
|
@@ -3144,7 +3469,9 @@
|
|
|
3144
3469
|
die(10);
|
|
3145
3470
|
}
|
|
3146
3471
|
function get(obj, key) {
|
|
3147
|
-
if (!has(obj, key))
|
|
3472
|
+
if (!has(obj, key)) {
|
|
3473
|
+
return undefined;
|
|
3474
|
+
}
|
|
3148
3475
|
|
|
3149
3476
|
if (isObservableObject(obj)) {
|
|
3150
3477
|
return obj[$mobx].get_(key);
|
|
@@ -3172,7 +3499,11 @@
|
|
|
3172
3499
|
}
|
|
3173
3500
|
|
|
3174
3501
|
function observe(thing, propOrCb, cbOrFire, fireImmediately) {
|
|
3175
|
-
if (isFunction(cbOrFire))
|
|
3502
|
+
if (isFunction(cbOrFire)) {
|
|
3503
|
+
return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);
|
|
3504
|
+
} else {
|
|
3505
|
+
return observeObservable(thing, propOrCb, cbOrFire);
|
|
3506
|
+
}
|
|
3176
3507
|
}
|
|
3177
3508
|
|
|
3178
3509
|
function observeObservable(thing, listener, fireImmediately) {
|
|
@@ -3189,8 +3520,13 @@
|
|
|
3189
3520
|
}
|
|
3190
3521
|
|
|
3191
3522
|
function toJSHelper(source, __alreadySeen) {
|
|
3192
|
-
if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source))
|
|
3193
|
-
|
|
3523
|
+
if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) {
|
|
3524
|
+
return source;
|
|
3525
|
+
}
|
|
3526
|
+
|
|
3527
|
+
if (isObservableValue(source) || isComputedValue(source)) {
|
|
3528
|
+
return toJSHelper(source.get(), __alreadySeen);
|
|
3529
|
+
}
|
|
3194
3530
|
|
|
3195
3531
|
if (__alreadySeen.has(source)) {
|
|
3196
3532
|
return __alreadySeen.get(source);
|
|
@@ -3241,18 +3577,25 @@
|
|
|
3241
3577
|
|
|
3242
3578
|
|
|
3243
3579
|
function toJS(source, options) {
|
|
3244
|
-
if ( options)
|
|
3580
|
+
if ( options) {
|
|
3581
|
+
die("toJS no longer supports options");
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3245
3584
|
return toJSHelper(source, new Map());
|
|
3246
3585
|
}
|
|
3247
3586
|
|
|
3248
3587
|
function trace() {
|
|
3588
|
+
|
|
3249
3589
|
var enterBreakPoint = false;
|
|
3250
3590
|
|
|
3251
3591
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3252
3592
|
args[_key] = arguments[_key];
|
|
3253
3593
|
}
|
|
3254
3594
|
|
|
3255
|
-
if (typeof args[args.length - 1] === "boolean")
|
|
3595
|
+
if (typeof args[args.length - 1] === "boolean") {
|
|
3596
|
+
enterBreakPoint = args.pop();
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3256
3599
|
var derivation = getAtomFromArgs(args);
|
|
3257
3600
|
|
|
3258
3601
|
if (!derivation) {
|
|
@@ -3302,7 +3645,10 @@
|
|
|
3302
3645
|
}
|
|
3303
3646
|
|
|
3304
3647
|
function when(predicate, arg1, arg2) {
|
|
3305
|
-
if (arguments.length === 1 || arg1 && typeof arg1 === "object")
|
|
3648
|
+
if (arguments.length === 1 || arg1 && typeof arg1 === "object") {
|
|
3649
|
+
return whenPromise(predicate, arg1);
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3306
3652
|
return _when(predicate, arg1, arg2 || {});
|
|
3307
3653
|
}
|
|
3308
3654
|
|
|
@@ -3314,7 +3660,12 @@
|
|
|
3314
3660
|
timeoutHandle = setTimeout(function () {
|
|
3315
3661
|
if (!disposer[$mobx].isDisposed_) {
|
|
3316
3662
|
disposer();
|
|
3317
|
-
|
|
3663
|
+
|
|
3664
|
+
if (opts.onError) {
|
|
3665
|
+
opts.onError(error);
|
|
3666
|
+
} else {
|
|
3667
|
+
throw error;
|
|
3668
|
+
}
|
|
3318
3669
|
}
|
|
3319
3670
|
}, opts.timeout);
|
|
3320
3671
|
}
|
|
@@ -3328,7 +3679,11 @@
|
|
|
3328
3679
|
|
|
3329
3680
|
if (cond) {
|
|
3330
3681
|
r.dispose();
|
|
3331
|
-
|
|
3682
|
+
|
|
3683
|
+
if (timeoutHandle) {
|
|
3684
|
+
clearTimeout(timeoutHandle);
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3332
3687
|
effectAction();
|
|
3333
3688
|
}
|
|
3334
3689
|
}, opts);
|
|
@@ -3336,7 +3691,10 @@
|
|
|
3336
3691
|
}
|
|
3337
3692
|
|
|
3338
3693
|
function whenPromise(predicate, opts) {
|
|
3339
|
-
if ( opts && opts.onError)
|
|
3694
|
+
if ( opts && opts.onError) {
|
|
3695
|
+
return die("the options 'onError' and 'promise' cannot be combined");
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3340
3698
|
var cancel;
|
|
3341
3699
|
var res = new Promise(function (resolve, reject) {
|
|
3342
3700
|
var disposer = _when(predicate, resolve, _extends({}, opts, {
|
|
@@ -3360,7 +3718,10 @@
|
|
|
3360
3718
|
|
|
3361
3719
|
var objectProxyTraps = {
|
|
3362
3720
|
has: function has(target, name) {
|
|
3363
|
-
if ( globalState.trackingDerivation)
|
|
3721
|
+
if ( globalState.trackingDerivation) {
|
|
3722
|
+
warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3364
3725
|
return getAdm(target).has_(name);
|
|
3365
3726
|
},
|
|
3366
3727
|
get: function get(target, name) {
|
|
@@ -3369,7 +3730,9 @@
|
|
|
3369
3730
|
set: function set(target, name, value) {
|
|
3370
3731
|
var _getAdm$set_;
|
|
3371
3732
|
|
|
3372
|
-
if (!isStringish(name))
|
|
3733
|
+
if (!isStringish(name)) {
|
|
3734
|
+
return false;
|
|
3735
|
+
}
|
|
3373
3736
|
|
|
3374
3737
|
if ( !getAdm(target).values_.has(name)) {
|
|
3375
3738
|
warnAboutProxyRequirement("add a new observable property through direct assignment. Use 'set' from 'mobx' instead.");
|
|
@@ -3385,7 +3748,10 @@
|
|
|
3385
3748
|
warnAboutProxyRequirement("delete properties from an observable object. Use 'remove' from 'mobx' instead.");
|
|
3386
3749
|
}
|
|
3387
3750
|
|
|
3388
|
-
if (!isStringish(name))
|
|
3751
|
+
if (!isStringish(name)) {
|
|
3752
|
+
return false;
|
|
3753
|
+
} // null (intercepted) -> true (success)
|
|
3754
|
+
|
|
3389
3755
|
|
|
3390
3756
|
return (_getAdm$delete_ = getAdm(target).delete_(name, true)) != null ? _getAdm$delete_ : true;
|
|
3391
3757
|
},
|
|
@@ -3400,7 +3766,10 @@
|
|
|
3400
3766
|
return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true;
|
|
3401
3767
|
},
|
|
3402
3768
|
ownKeys: function ownKeys(target) {
|
|
3403
|
-
if ( globalState.trackingDerivation)
|
|
3769
|
+
if ( globalState.trackingDerivation) {
|
|
3770
|
+
warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3404
3773
|
return getAdm(target).ownKeys_();
|
|
3405
3774
|
},
|
|
3406
3775
|
preventExtensions: function preventExtensions(target) {
|
|
@@ -3423,7 +3792,10 @@
|
|
|
3423
3792
|
interceptors.push(handler);
|
|
3424
3793
|
return once(function () {
|
|
3425
3794
|
var idx = interceptors.indexOf(handler);
|
|
3426
|
-
|
|
3795
|
+
|
|
3796
|
+
if (idx !== -1) {
|
|
3797
|
+
interceptors.splice(idx, 1);
|
|
3798
|
+
}
|
|
3427
3799
|
});
|
|
3428
3800
|
}
|
|
3429
3801
|
function interceptChange(interceptable, change) {
|
|
@@ -3435,8 +3807,14 @@
|
|
|
3435
3807
|
|
|
3436
3808
|
for (var i = 0, l = interceptors.length; i < l; i++) {
|
|
3437
3809
|
change = interceptors[i](change);
|
|
3438
|
-
|
|
3439
|
-
if (!change)
|
|
3810
|
+
|
|
3811
|
+
if (change && !change.type) {
|
|
3812
|
+
die(14);
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
if (!change) {
|
|
3816
|
+
break;
|
|
3817
|
+
}
|
|
3440
3818
|
}
|
|
3441
3819
|
|
|
3442
3820
|
return change;
|
|
@@ -3453,13 +3831,20 @@
|
|
|
3453
3831
|
listeners.push(handler);
|
|
3454
3832
|
return once(function () {
|
|
3455
3833
|
var idx = listeners.indexOf(handler);
|
|
3456
|
-
|
|
3834
|
+
|
|
3835
|
+
if (idx !== -1) {
|
|
3836
|
+
listeners.splice(idx, 1);
|
|
3837
|
+
}
|
|
3457
3838
|
});
|
|
3458
3839
|
}
|
|
3459
3840
|
function notifyListeners(listenable, change) {
|
|
3460
3841
|
var prevU = untrackedStart();
|
|
3461
3842
|
var listeners = listenable.changeListeners_;
|
|
3462
|
-
|
|
3843
|
+
|
|
3844
|
+
if (!listeners) {
|
|
3845
|
+
return;
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3463
3848
|
listeners = listeners.slice();
|
|
3464
3849
|
|
|
3465
3850
|
for (var i = 0, l = listeners.length; i < l; i++) {
|
|
@@ -3496,8 +3881,13 @@
|
|
|
3496
3881
|
var keysSymbol = /*#__PURE__*/Symbol("mobx-keys");
|
|
3497
3882
|
function makeAutoObservable(target, overrides, options) {
|
|
3498
3883
|
{
|
|
3499
|
-
if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target)))
|
|
3500
|
-
|
|
3884
|
+
if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {
|
|
3885
|
+
die("'makeAutoObservable' can only be used for classes that don't have a superclass");
|
|
3886
|
+
}
|
|
3887
|
+
|
|
3888
|
+
if (isObservableObject(target)) {
|
|
3889
|
+
die("makeAutoObservable can only be used on objects not already made observable");
|
|
3890
|
+
}
|
|
3501
3891
|
} // Optimization: avoid visiting protos
|
|
3502
3892
|
// Assumes that annotation.make_/.extend_ works the same for plain objects
|
|
3503
3893
|
|
|
@@ -3538,8 +3928,14 @@
|
|
|
3538
3928
|
var arrayTraps = {
|
|
3539
3929
|
get: function get(target, name) {
|
|
3540
3930
|
var adm = target[$mobx];
|
|
3541
|
-
|
|
3542
|
-
if (name ===
|
|
3931
|
+
|
|
3932
|
+
if (name === $mobx) {
|
|
3933
|
+
return adm;
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
if (name === "length") {
|
|
3937
|
+
return adm.getArrayLength_();
|
|
3938
|
+
}
|
|
3543
3939
|
|
|
3544
3940
|
if (typeof name === "string" && !isNaN(name)) {
|
|
3545
3941
|
return adm.get_(parseInt(name));
|
|
@@ -3600,12 +3996,18 @@
|
|
|
3600
3996
|
var _proto = ObservableArrayAdministration.prototype;
|
|
3601
3997
|
|
|
3602
3998
|
_proto.dehanceValue_ = function dehanceValue_(value) {
|
|
3603
|
-
if (this.dehancer !== undefined)
|
|
3999
|
+
if (this.dehancer !== undefined) {
|
|
4000
|
+
return this.dehancer(value);
|
|
4001
|
+
}
|
|
4002
|
+
|
|
3604
4003
|
return value;
|
|
3605
4004
|
};
|
|
3606
4005
|
|
|
3607
4006
|
_proto.dehanceValues_ = function dehanceValues_(values) {
|
|
3608
|
-
if (this.dehancer !== undefined && values.length > 0)
|
|
4007
|
+
if (this.dehancer !== undefined && values.length > 0) {
|
|
4008
|
+
return values.map(this.dehancer);
|
|
4009
|
+
}
|
|
4010
|
+
|
|
3609
4011
|
return values;
|
|
3610
4012
|
};
|
|
3611
4013
|
|
|
@@ -3641,9 +4043,15 @@
|
|
|
3641
4043
|
};
|
|
3642
4044
|
|
|
3643
4045
|
_proto.setArrayLength_ = function setArrayLength_(newLength) {
|
|
3644
|
-
if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0)
|
|
4046
|
+
if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) {
|
|
4047
|
+
die("Out of range: " + newLength);
|
|
4048
|
+
}
|
|
4049
|
+
|
|
3645
4050
|
var currentLength = this.values_.length;
|
|
3646
|
-
|
|
4051
|
+
|
|
4052
|
+
if (newLength === currentLength) {
|
|
4053
|
+
return;
|
|
4054
|
+
} else if (newLength > currentLength) {
|
|
3647
4055
|
var newItems = new Array(newLength - currentLength);
|
|
3648
4056
|
|
|
3649
4057
|
for (var i = 0; i < newLength - currentLength; i++) {
|
|
@@ -3652,13 +4060,21 @@
|
|
|
3652
4060
|
|
|
3653
4061
|
|
|
3654
4062
|
this.spliceWithArray_(currentLength, 0, newItems);
|
|
3655
|
-
} else
|
|
4063
|
+
} else {
|
|
4064
|
+
this.spliceWithArray_(newLength, currentLength - newLength);
|
|
4065
|
+
}
|
|
3656
4066
|
};
|
|
3657
4067
|
|
|
3658
4068
|
_proto.updateArrayLength_ = function updateArrayLength_(oldLength, delta) {
|
|
3659
|
-
if (oldLength !== this.lastKnownLength_)
|
|
4069
|
+
if (oldLength !== this.lastKnownLength_) {
|
|
4070
|
+
die(16);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
3660
4073
|
this.lastKnownLength_ += delta;
|
|
3661
|
-
|
|
4074
|
+
|
|
4075
|
+
if (this.legacyMode_ && delta > 0) {
|
|
4076
|
+
reserveArrayBuffer(oldLength + delta + 1);
|
|
4077
|
+
}
|
|
3662
4078
|
};
|
|
3663
4079
|
|
|
3664
4080
|
_proto.spliceWithArray_ = function spliceWithArray_(index, deleteCount, newItems) {
|
|
@@ -3666,9 +4082,26 @@
|
|
|
3666
4082
|
|
|
3667
4083
|
checkIfStateModificationsAreAllowed(this.atom_);
|
|
3668
4084
|
var length = this.values_.length;
|
|
3669
|
-
|
|
3670
|
-
if (
|
|
3671
|
-
|
|
4085
|
+
|
|
4086
|
+
if (index === undefined) {
|
|
4087
|
+
index = 0;
|
|
4088
|
+
} else if (index > length) {
|
|
4089
|
+
index = length;
|
|
4090
|
+
} else if (index < 0) {
|
|
4091
|
+
index = Math.max(0, length + index);
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
if (arguments.length === 1) {
|
|
4095
|
+
deleteCount = length - index;
|
|
4096
|
+
} else if (deleteCount === undefined || deleteCount === null) {
|
|
4097
|
+
deleteCount = 0;
|
|
4098
|
+
} else {
|
|
4099
|
+
deleteCount = Math.max(0, Math.min(deleteCount, length - index));
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
if (newItems === undefined) {
|
|
4103
|
+
newItems = EMPTY_ARRAY;
|
|
4104
|
+
}
|
|
3672
4105
|
|
|
3673
4106
|
if (hasInterceptors(this)) {
|
|
3674
4107
|
var change = interceptChange(this, {
|
|
@@ -3678,7 +4111,11 @@
|
|
|
3678
4111
|
removedCount: deleteCount,
|
|
3679
4112
|
added: newItems
|
|
3680
4113
|
});
|
|
3681
|
-
|
|
4114
|
+
|
|
4115
|
+
if (!change) {
|
|
4116
|
+
return EMPTY_ARRAY;
|
|
4117
|
+
}
|
|
4118
|
+
|
|
3682
4119
|
deleteCount = change.removedCount;
|
|
3683
4120
|
newItems = change.added;
|
|
3684
4121
|
}
|
|
@@ -3693,7 +4130,11 @@
|
|
|
3693
4130
|
}
|
|
3694
4131
|
|
|
3695
4132
|
var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
|
|
3696
|
-
|
|
4133
|
+
|
|
4134
|
+
if (deleteCount !== 0 || newItems.length !== 0) {
|
|
4135
|
+
this.notifyArraySplice_(index, newItems, res);
|
|
4136
|
+
}
|
|
4137
|
+
|
|
3697
4138
|
return this.dehanceValues_(res);
|
|
3698
4139
|
};
|
|
3699
4140
|
|
|
@@ -3736,10 +4177,19 @@
|
|
|
3736
4177
|
} : null; // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't
|
|
3737
4178
|
// cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
|
|
3738
4179
|
|
|
3739
|
-
if ( notifySpy)
|
|
4180
|
+
if ( notifySpy) {
|
|
4181
|
+
spyReportStart(change);
|
|
4182
|
+
}
|
|
4183
|
+
|
|
3740
4184
|
this.atom_.reportChanged();
|
|
3741
|
-
|
|
3742
|
-
if (
|
|
4185
|
+
|
|
4186
|
+
if (notify) {
|
|
4187
|
+
notifyListeners(this, change);
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
if ( notifySpy) {
|
|
4191
|
+
spyReportEnd();
|
|
4192
|
+
}
|
|
3743
4193
|
};
|
|
3744
4194
|
|
|
3745
4195
|
_proto.notifyArraySplice_ = function notifyArraySplice_(index, added, removed) {
|
|
@@ -3756,11 +4206,20 @@
|
|
|
3756
4206
|
removedCount: removed.length,
|
|
3757
4207
|
addedCount: added.length
|
|
3758
4208
|
} : null;
|
|
3759
|
-
|
|
4209
|
+
|
|
4210
|
+
if ( notifySpy) {
|
|
4211
|
+
spyReportStart(change);
|
|
4212
|
+
}
|
|
4213
|
+
|
|
3760
4214
|
this.atom_.reportChanged(); // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
|
|
3761
4215
|
|
|
3762
|
-
if (notify)
|
|
3763
|
-
|
|
4216
|
+
if (notify) {
|
|
4217
|
+
notifyListeners(this, change);
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
if ( notifySpy) {
|
|
4221
|
+
spyReportEnd();
|
|
4222
|
+
}
|
|
3764
4223
|
};
|
|
3765
4224
|
|
|
3766
4225
|
_proto.get_ = function get_(index) {
|
|
@@ -3787,7 +4246,11 @@
|
|
|
3787
4246
|
index: index,
|
|
3788
4247
|
newValue: newValue
|
|
3789
4248
|
});
|
|
3790
|
-
|
|
4249
|
+
|
|
4250
|
+
if (!change) {
|
|
4251
|
+
return;
|
|
4252
|
+
}
|
|
4253
|
+
|
|
3791
4254
|
newValue = change.newValue;
|
|
3792
4255
|
}
|
|
3793
4256
|
|
|
@@ -4071,7 +4534,10 @@
|
|
|
4071
4534
|
_proto.has = function has(key) {
|
|
4072
4535
|
var _this2 = this;
|
|
4073
4536
|
|
|
4074
|
-
if (!globalState.trackingDerivation)
|
|
4537
|
+
if (!globalState.trackingDerivation) {
|
|
4538
|
+
return this.has_(key);
|
|
4539
|
+
}
|
|
4540
|
+
|
|
4075
4541
|
var entry = this.hasMap_.get(key);
|
|
4076
4542
|
|
|
4077
4543
|
if (!entry) {
|
|
@@ -4095,7 +4561,11 @@
|
|
|
4095
4561
|
newValue: value,
|
|
4096
4562
|
name: key
|
|
4097
4563
|
});
|
|
4098
|
-
|
|
4564
|
+
|
|
4565
|
+
if (!change) {
|
|
4566
|
+
return this;
|
|
4567
|
+
}
|
|
4568
|
+
|
|
4099
4569
|
value = change.newValue;
|
|
4100
4570
|
}
|
|
4101
4571
|
|
|
@@ -4119,7 +4589,10 @@
|
|
|
4119
4589
|
object: this,
|
|
4120
4590
|
name: key
|
|
4121
4591
|
});
|
|
4122
|
-
|
|
4592
|
+
|
|
4593
|
+
if (!change) {
|
|
4594
|
+
return false;
|
|
4595
|
+
}
|
|
4123
4596
|
}
|
|
4124
4597
|
|
|
4125
4598
|
if (this.has_(key)) {
|
|
@@ -4135,7 +4608,10 @@
|
|
|
4135
4608
|
name: key
|
|
4136
4609
|
} : null;
|
|
4137
4610
|
|
|
4138
|
-
if ( notifySpy)
|
|
4611
|
+
if ( notifySpy) {
|
|
4612
|
+
spyReportStart(_change);
|
|
4613
|
+
} // TODO fix type
|
|
4614
|
+
|
|
4139
4615
|
|
|
4140
4616
|
transaction(function () {
|
|
4141
4617
|
var _this3$hasMap_$get;
|
|
@@ -4150,8 +4626,15 @@
|
|
|
4150
4626
|
|
|
4151
4627
|
_this3.data_["delete"](key);
|
|
4152
4628
|
});
|
|
4153
|
-
|
|
4154
|
-
if (
|
|
4629
|
+
|
|
4630
|
+
if (notify) {
|
|
4631
|
+
notifyListeners(this, _change);
|
|
4632
|
+
}
|
|
4633
|
+
|
|
4634
|
+
if ( notifySpy) {
|
|
4635
|
+
spyReportEnd();
|
|
4636
|
+
}
|
|
4637
|
+
|
|
4155
4638
|
return true;
|
|
4156
4639
|
}
|
|
4157
4640
|
|
|
@@ -4174,11 +4657,21 @@
|
|
|
4174
4657
|
name: key,
|
|
4175
4658
|
newValue: newValue
|
|
4176
4659
|
} : null;
|
|
4177
|
-
|
|
4660
|
+
|
|
4661
|
+
if ( notifySpy) {
|
|
4662
|
+
spyReportStart(change);
|
|
4663
|
+
} // TODO fix type
|
|
4664
|
+
|
|
4178
4665
|
|
|
4179
4666
|
observable.setNewValue_(newValue);
|
|
4180
|
-
|
|
4181
|
-
if (
|
|
4667
|
+
|
|
4668
|
+
if (notify) {
|
|
4669
|
+
notifyListeners(this, change);
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
if ( notifySpy) {
|
|
4673
|
+
spyReportEnd();
|
|
4674
|
+
}
|
|
4182
4675
|
}
|
|
4183
4676
|
};
|
|
4184
4677
|
|
|
@@ -4209,14 +4702,26 @@
|
|
|
4209
4702
|
name: key,
|
|
4210
4703
|
newValue: newValue
|
|
4211
4704
|
} : null;
|
|
4212
|
-
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4213
4705
|
|
|
4214
|
-
if (
|
|
4215
|
-
|
|
4706
|
+
if ( notifySpy) {
|
|
4707
|
+
spyReportStart(change);
|
|
4708
|
+
} // TODO fix type
|
|
4709
|
+
|
|
4710
|
+
|
|
4711
|
+
if (notify) {
|
|
4712
|
+
notifyListeners(this, change);
|
|
4713
|
+
}
|
|
4714
|
+
|
|
4715
|
+
if ( notifySpy) {
|
|
4716
|
+
spyReportEnd();
|
|
4717
|
+
}
|
|
4216
4718
|
};
|
|
4217
4719
|
|
|
4218
4720
|
_proto.get = function get(key) {
|
|
4219
|
-
if (this.has(key))
|
|
4721
|
+
if (this.has(key)) {
|
|
4722
|
+
return this.dehanceValue_(this.data_.get(key).get());
|
|
4723
|
+
}
|
|
4724
|
+
|
|
4220
4725
|
return this.dehanceValue_(undefined);
|
|
4221
4726
|
};
|
|
4222
4727
|
|
|
@@ -4290,18 +4795,27 @@
|
|
|
4290
4795
|
}
|
|
4291
4796
|
|
|
4292
4797
|
transaction(function () {
|
|
4293
|
-
if (isPlainObject(other))
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4798
|
+
if (isPlainObject(other)) {
|
|
4799
|
+
getPlainObjectKeys(other).forEach(function (key) {
|
|
4800
|
+
return _this5.set(key, other[key]);
|
|
4801
|
+
});
|
|
4802
|
+
} else if (Array.isArray(other)) {
|
|
4803
|
+
other.forEach(function (_ref) {
|
|
4804
|
+
var key = _ref[0],
|
|
4805
|
+
value = _ref[1];
|
|
4806
|
+
return _this5.set(key, value);
|
|
4807
|
+
});
|
|
4808
|
+
} else if (isES6Map(other)) {
|
|
4809
|
+
if (other.constructor !== Map) {
|
|
4810
|
+
die(19, other);
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4301
4813
|
other.forEach(function (value, key) {
|
|
4302
4814
|
return _this5.set(key, value);
|
|
4303
4815
|
});
|
|
4304
|
-
} else if (other !== null && other !== undefined)
|
|
4816
|
+
} else if (other !== null && other !== undefined) {
|
|
4817
|
+
die(20, other);
|
|
4818
|
+
}
|
|
4305
4819
|
});
|
|
4306
4820
|
return this;
|
|
4307
4821
|
};
|
|
@@ -4432,7 +4946,10 @@
|
|
|
4432
4946
|
* for callback details
|
|
4433
4947
|
*/
|
|
4434
4948
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
4435
|
-
if ( fireImmediately === true)
|
|
4949
|
+
if ( fireImmediately === true) {
|
|
4950
|
+
die("`observe` doesn't support fireImmediately=true in combination with maps.");
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4436
4953
|
return registerListener(this, listener);
|
|
4437
4954
|
};
|
|
4438
4955
|
|
|
@@ -4557,8 +5074,12 @@
|
|
|
4557
5074
|
object: this,
|
|
4558
5075
|
newValue: value
|
|
4559
5076
|
});
|
|
4560
|
-
|
|
5077
|
+
|
|
5078
|
+
if (!change) {
|
|
5079
|
+
return this;
|
|
5080
|
+
} // ideally, value = change.value would be done here, so that values can be
|
|
4561
5081
|
// changed by interceptor. Same applies for other Set and Map api's.
|
|
5082
|
+
|
|
4562
5083
|
}
|
|
4563
5084
|
|
|
4564
5085
|
if (!this.has(value)) {
|
|
@@ -4578,9 +5099,17 @@
|
|
|
4578
5099
|
newValue: value
|
|
4579
5100
|
} : null;
|
|
4580
5101
|
|
|
4581
|
-
if (notifySpy && "development" !== "production")
|
|
4582
|
-
|
|
4583
|
-
|
|
5102
|
+
if (notifySpy && "development" !== "production") {
|
|
5103
|
+
spyReportStart(_change);
|
|
5104
|
+
}
|
|
5105
|
+
|
|
5106
|
+
if (notify) {
|
|
5107
|
+
notifyListeners(this, _change);
|
|
5108
|
+
}
|
|
5109
|
+
|
|
5110
|
+
if (notifySpy && "development" !== "production") {
|
|
5111
|
+
spyReportEnd();
|
|
5112
|
+
}
|
|
4584
5113
|
}
|
|
4585
5114
|
|
|
4586
5115
|
return this;
|
|
@@ -4595,7 +5124,10 @@
|
|
|
4595
5124
|
object: this,
|
|
4596
5125
|
oldValue: value
|
|
4597
5126
|
});
|
|
4598
|
-
|
|
5127
|
+
|
|
5128
|
+
if (!change) {
|
|
5129
|
+
return false;
|
|
5130
|
+
}
|
|
4599
5131
|
}
|
|
4600
5132
|
|
|
4601
5133
|
if (this.has(value)) {
|
|
@@ -4610,14 +5142,24 @@
|
|
|
4610
5142
|
oldValue: value
|
|
4611
5143
|
} : null;
|
|
4612
5144
|
|
|
4613
|
-
if (notifySpy && "development" !== "production")
|
|
5145
|
+
if (notifySpy && "development" !== "production") {
|
|
5146
|
+
spyReportStart(_change2);
|
|
5147
|
+
}
|
|
5148
|
+
|
|
4614
5149
|
transaction(function () {
|
|
4615
5150
|
_this3.atom_.reportChanged();
|
|
4616
5151
|
|
|
4617
5152
|
_this3.data_["delete"](value);
|
|
4618
5153
|
});
|
|
4619
|
-
|
|
4620
|
-
if (
|
|
5154
|
+
|
|
5155
|
+
if (notify) {
|
|
5156
|
+
notifyListeners(this, _change2);
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5159
|
+
if (notifySpy && "development" !== "production") {
|
|
5160
|
+
spyReportEnd();
|
|
5161
|
+
}
|
|
5162
|
+
|
|
4621
5163
|
return true;
|
|
4622
5164
|
}
|
|
4623
5165
|
|
|
@@ -4697,7 +5239,10 @@
|
|
|
4697
5239
|
|
|
4698
5240
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
4699
5241
|
// ... 'fireImmediately' could also be true?
|
|
4700
|
-
if ( fireImmediately === true)
|
|
5242
|
+
if ( fireImmediately === true) {
|
|
5243
|
+
die("`observe` doesn't support fireImmediately=true in combination with sets.");
|
|
5244
|
+
}
|
|
5245
|
+
|
|
4701
5246
|
return registerListener(this, listener);
|
|
4702
5247
|
};
|
|
4703
5248
|
|
|
@@ -4799,7 +5344,11 @@
|
|
|
4799
5344
|
name: key,
|
|
4800
5345
|
newValue: newValue
|
|
4801
5346
|
});
|
|
4802
|
-
|
|
5347
|
+
|
|
5348
|
+
if (!change) {
|
|
5349
|
+
return null;
|
|
5350
|
+
}
|
|
5351
|
+
|
|
4803
5352
|
newValue = change.newValue;
|
|
4804
5353
|
}
|
|
4805
5354
|
|
|
@@ -4819,10 +5368,18 @@
|
|
|
4819
5368
|
newValue: newValue
|
|
4820
5369
|
} : null;
|
|
4821
5370
|
|
|
4822
|
-
if ( notifySpy)
|
|
5371
|
+
if ( notifySpy) {
|
|
5372
|
+
spyReportStart(_change);
|
|
5373
|
+
}
|
|
4823
5374
|
observable.setNewValue_(newValue);
|
|
4824
|
-
|
|
4825
|
-
if (
|
|
5375
|
+
|
|
5376
|
+
if (notify) {
|
|
5377
|
+
notifyListeners(this, _change);
|
|
5378
|
+
}
|
|
5379
|
+
|
|
5380
|
+
if ( notifySpy) {
|
|
5381
|
+
spyReportEnd();
|
|
5382
|
+
}
|
|
4826
5383
|
}
|
|
4827
5384
|
|
|
4828
5385
|
return true;
|
|
@@ -4931,12 +5488,18 @@
|
|
|
4931
5488
|
|
|
4932
5489
|
if (descriptor) {
|
|
4933
5490
|
var outcome = annotation.make_(this, key, descriptor, source);
|
|
5491
|
+
|
|
4934
5492
|
if (outcome === 0
|
|
4935
5493
|
/* Cancel */
|
|
4936
|
-
)
|
|
5494
|
+
) {
|
|
5495
|
+
return;
|
|
5496
|
+
}
|
|
5497
|
+
|
|
4937
5498
|
if (outcome === 1
|
|
4938
5499
|
/* Break */
|
|
4939
|
-
)
|
|
5500
|
+
) {
|
|
5501
|
+
break;
|
|
5502
|
+
}
|
|
4940
5503
|
}
|
|
4941
5504
|
|
|
4942
5505
|
source = Object.getPrototypeOf(source);
|
|
@@ -5006,7 +5569,11 @@
|
|
|
5006
5569
|
type: ADD,
|
|
5007
5570
|
newValue: descriptor.value
|
|
5008
5571
|
});
|
|
5009
|
-
|
|
5572
|
+
|
|
5573
|
+
if (!change) {
|
|
5574
|
+
return null;
|
|
5575
|
+
}
|
|
5576
|
+
|
|
5010
5577
|
var newValue = change.newValue;
|
|
5011
5578
|
|
|
5012
5579
|
if (descriptor.value !== newValue) {
|
|
@@ -5058,7 +5625,11 @@
|
|
|
5058
5625
|
type: ADD,
|
|
5059
5626
|
newValue: value
|
|
5060
5627
|
});
|
|
5061
|
-
|
|
5628
|
+
|
|
5629
|
+
if (!change) {
|
|
5630
|
+
return null;
|
|
5631
|
+
}
|
|
5632
|
+
|
|
5062
5633
|
value = change.newValue;
|
|
5063
5634
|
}
|
|
5064
5635
|
|
|
@@ -5113,7 +5684,10 @@
|
|
|
5113
5684
|
type: ADD,
|
|
5114
5685
|
newValue: undefined
|
|
5115
5686
|
});
|
|
5116
|
-
|
|
5687
|
+
|
|
5688
|
+
if (!change) {
|
|
5689
|
+
return null;
|
|
5690
|
+
}
|
|
5117
5691
|
}
|
|
5118
5692
|
|
|
5119
5693
|
options.name || (options.name = "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
|
|
@@ -5169,7 +5743,9 @@
|
|
|
5169
5743
|
type: REMOVE
|
|
5170
5744
|
}); // Cancelled
|
|
5171
5745
|
|
|
5172
|
-
if (!change)
|
|
5746
|
+
if (!change) {
|
|
5747
|
+
return null;
|
|
5748
|
+
}
|
|
5173
5749
|
} // Delete
|
|
5174
5750
|
|
|
5175
5751
|
|
|
@@ -5230,9 +5806,18 @@
|
|
|
5230
5806
|
oldValue: value,
|
|
5231
5807
|
name: key
|
|
5232
5808
|
};
|
|
5233
|
-
|
|
5234
|
-
if (
|
|
5235
|
-
|
|
5809
|
+
|
|
5810
|
+
if ("development" !== "production" && notifySpy) {
|
|
5811
|
+
spyReportStart(_change2);
|
|
5812
|
+
}
|
|
5813
|
+
|
|
5814
|
+
if (notify) {
|
|
5815
|
+
notifyListeners(this, _change2);
|
|
5816
|
+
}
|
|
5817
|
+
|
|
5818
|
+
if ("development" !== "production" && notifySpy) {
|
|
5819
|
+
spyReportEnd();
|
|
5820
|
+
}
|
|
5236
5821
|
}
|
|
5237
5822
|
} finally {
|
|
5238
5823
|
endBatch();
|
|
@@ -5248,7 +5833,10 @@
|
|
|
5248
5833
|
;
|
|
5249
5834
|
|
|
5250
5835
|
_proto.observe_ = function observe_(callback, fireImmediately) {
|
|
5251
|
-
if ( fireImmediately === true)
|
|
5836
|
+
if ( fireImmediately === true) {
|
|
5837
|
+
die("`observe` doesn't support the fire immediately property for observable objects.");
|
|
5838
|
+
}
|
|
5839
|
+
|
|
5252
5840
|
return registerListener(this, callback);
|
|
5253
5841
|
};
|
|
5254
5842
|
|
|
@@ -5271,9 +5859,18 @@
|
|
|
5271
5859
|
name: key,
|
|
5272
5860
|
newValue: value
|
|
5273
5861
|
} : null;
|
|
5274
|
-
|
|
5275
|
-
if (
|
|
5276
|
-
|
|
5862
|
+
|
|
5863
|
+
if ( notifySpy) {
|
|
5864
|
+
spyReportStart(change);
|
|
5865
|
+
}
|
|
5866
|
+
|
|
5867
|
+
if (notify) {
|
|
5868
|
+
notifyListeners(this, change);
|
|
5869
|
+
}
|
|
5870
|
+
|
|
5871
|
+
if ( notifySpy) {
|
|
5872
|
+
spyReportEnd();
|
|
5873
|
+
}
|
|
5277
5874
|
}
|
|
5278
5875
|
|
|
5279
5876
|
(_this$pendingKeys_2 = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_2$g = _this$pendingKeys_2.get(key)) == null ? void 0 : _this$pendingKeys_2$g.set(true); // Notify "keys/entries/values" observers
|
|
@@ -5314,7 +5911,10 @@
|
|
|
5314
5911
|
return target;
|
|
5315
5912
|
}
|
|
5316
5913
|
|
|
5317
|
-
if ( !Object.isExtensible(target))
|
|
5914
|
+
if ( !Object.isExtensible(target)) {
|
|
5915
|
+
die("Cannot make the designated object observable; it is not extensible");
|
|
5916
|
+
}
|
|
5917
|
+
|
|
5318
5918
|
var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() ;
|
|
5319
5919
|
var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options));
|
|
5320
5920
|
addHiddenProp(target, $mobx, adm);
|
|
@@ -5471,7 +6071,6 @@
|
|
|
5471
6071
|
var nextIndex = 0;
|
|
5472
6072
|
return makeIterable({
|
|
5473
6073
|
next: function next() {
|
|
5474
|
-
// @ts-ignore
|
|
5475
6074
|
return nextIndex < self.length ? {
|
|
5476
6075
|
value: self[nextIndex++],
|
|
5477
6076
|
done: false
|
|
@@ -5504,7 +6103,10 @@
|
|
|
5504
6103
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5505
6104
|
var prop = _ref[0],
|
|
5506
6105
|
fn = _ref[1];
|
|
5507
|
-
|
|
6106
|
+
|
|
6107
|
+
if (prop !== "concat") {
|
|
6108
|
+
addHiddenProp(LegacyObservableArray.prototype, prop, fn);
|
|
6109
|
+
}
|
|
5508
6110
|
});
|
|
5509
6111
|
|
|
5510
6112
|
function createArrayEntryDescriptor(index) {
|
|
@@ -5541,7 +6143,10 @@
|
|
|
5541
6143
|
function getAtom(thing, property) {
|
|
5542
6144
|
if (typeof thing === "object" && thing !== null) {
|
|
5543
6145
|
if (isObservableArray(thing)) {
|
|
5544
|
-
if (property !== undefined)
|
|
6146
|
+
if (property !== undefined) {
|
|
6147
|
+
die(23);
|
|
6148
|
+
}
|
|
6149
|
+
|
|
5545
6150
|
return thing[$mobx].atom_;
|
|
5546
6151
|
}
|
|
5547
6152
|
|
|
@@ -5550,18 +6155,31 @@
|
|
|
5550
6155
|
}
|
|
5551
6156
|
|
|
5552
6157
|
if (isObservableMap(thing)) {
|
|
5553
|
-
if (property === undefined)
|
|
6158
|
+
if (property === undefined) {
|
|
6159
|
+
return thing.keysAtom_;
|
|
6160
|
+
}
|
|
6161
|
+
|
|
5554
6162
|
var observable = thing.data_.get(property) || thing.hasMap_.get(property);
|
|
5555
|
-
|
|
6163
|
+
|
|
6164
|
+
if (!observable) {
|
|
6165
|
+
die(25, property, getDebugName(thing));
|
|
6166
|
+
}
|
|
6167
|
+
|
|
5556
6168
|
return observable;
|
|
5557
6169
|
}
|
|
5558
6170
|
|
|
6171
|
+
|
|
5559
6172
|
if (isObservableObject(thing)) {
|
|
5560
|
-
if (!property)
|
|
6173
|
+
if (!property) {
|
|
6174
|
+
return die(26);
|
|
6175
|
+
}
|
|
5561
6176
|
|
|
5562
6177
|
var _observable = thing[$mobx].values_.get(property);
|
|
5563
6178
|
|
|
5564
|
-
if (!_observable)
|
|
6179
|
+
if (!_observable) {
|
|
6180
|
+
die(27, property, getDebugName(thing));
|
|
6181
|
+
}
|
|
6182
|
+
|
|
5565
6183
|
return _observable;
|
|
5566
6184
|
}
|
|
5567
6185
|
|
|
@@ -5578,11 +6196,26 @@
|
|
|
5578
6196
|
die(28);
|
|
5579
6197
|
}
|
|
5580
6198
|
function getAdministration(thing, property) {
|
|
5581
|
-
if (!thing)
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
if (
|
|
6199
|
+
if (!thing) {
|
|
6200
|
+
die(29);
|
|
6201
|
+
}
|
|
6202
|
+
|
|
6203
|
+
if (property !== undefined) {
|
|
6204
|
+
return getAdministration(getAtom(thing, property));
|
|
6205
|
+
}
|
|
6206
|
+
|
|
6207
|
+
if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {
|
|
6208
|
+
return thing;
|
|
6209
|
+
}
|
|
6210
|
+
|
|
6211
|
+
if (isObservableMap(thing) || isObservableSet(thing)) {
|
|
6212
|
+
return thing;
|
|
6213
|
+
}
|
|
6214
|
+
|
|
6215
|
+
if (thing[$mobx]) {
|
|
6216
|
+
return thing[$mobx];
|
|
6217
|
+
}
|
|
6218
|
+
|
|
5586
6219
|
die(24, thing);
|
|
5587
6220
|
}
|
|
5588
6221
|
function getDebugName(thing, property) {
|
|
@@ -5615,17 +6248,33 @@
|
|
|
5615
6248
|
function eq(a, b, depth, aStack, bStack) {
|
|
5616
6249
|
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
|
5617
6250
|
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
|
5618
|
-
if (a === b)
|
|
6251
|
+
if (a === b) {
|
|
6252
|
+
return a !== 0 || 1 / a === 1 / b;
|
|
6253
|
+
} // `null` or `undefined` only equal to itself (strict comparison).
|
|
6254
|
+
|
|
6255
|
+
|
|
6256
|
+
if (a == null || b == null) {
|
|
6257
|
+
return false;
|
|
6258
|
+
} // `NaN`s are equivalent, but non-reflexive.
|
|
5619
6259
|
|
|
5620
|
-
if (a == null || b == null) return false; // `NaN`s are equivalent, but non-reflexive.
|
|
5621
6260
|
|
|
5622
|
-
if (a !== a)
|
|
6261
|
+
if (a !== a) {
|
|
6262
|
+
return b !== b;
|
|
6263
|
+
} // Exhaust primitive checks
|
|
6264
|
+
|
|
5623
6265
|
|
|
5624
6266
|
var type = typeof a;
|
|
5625
|
-
|
|
6267
|
+
|
|
6268
|
+
if (type !== "function" && type !== "object" && typeof b != "object") {
|
|
6269
|
+
return false;
|
|
6270
|
+
} // Compare `[[Class]]` names.
|
|
6271
|
+
|
|
5626
6272
|
|
|
5627
6273
|
var className = toString.call(a);
|
|
5628
|
-
|
|
6274
|
+
|
|
6275
|
+
if (className !== toString.call(b)) {
|
|
6276
|
+
return false;
|
|
6277
|
+
}
|
|
5629
6278
|
|
|
5630
6279
|
switch (className) {
|
|
5631
6280
|
// Strings, numbers, regular expressions, dates, and booleans are compared by value.
|
|
@@ -5639,7 +6288,10 @@
|
|
|
5639
6288
|
case "[object Number]":
|
|
5640
6289
|
// `NaN`s are equivalent, but non-reflexive.
|
|
5641
6290
|
// Object(NaN) is equivalent to NaN.
|
|
5642
|
-
if (+a !== +a)
|
|
6291
|
+
if (+a !== +a) {
|
|
6292
|
+
return +b !== +b;
|
|
6293
|
+
} // An `egal` comparison is performed for other numeric values.
|
|
6294
|
+
|
|
5643
6295
|
|
|
5644
6296
|
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
|
|
5645
6297
|
|
|
@@ -5670,9 +6322,12 @@
|
|
|
5670
6322
|
var areArrays = className === "[object Array]";
|
|
5671
6323
|
|
|
5672
6324
|
if (!areArrays) {
|
|
5673
|
-
if (typeof a != "object" || typeof b != "object")
|
|
6325
|
+
if (typeof a != "object" || typeof b != "object") {
|
|
6326
|
+
return false;
|
|
6327
|
+
} // Objects with different constructors are not equivalent, but `Object`s or `Array`s
|
|
5674
6328
|
// from different frames are.
|
|
5675
6329
|
|
|
6330
|
+
|
|
5676
6331
|
var aCtor = a.constructor,
|
|
5677
6332
|
bCtor = b.constructor;
|
|
5678
6333
|
|
|
@@ -5698,7 +6353,9 @@
|
|
|
5698
6353
|
while (length--) {
|
|
5699
6354
|
// Linear search. Performance is inversely proportional to the number of
|
|
5700
6355
|
// unique nested structures.
|
|
5701
|
-
if (aStack[length] === a)
|
|
6356
|
+
if (aStack[length] === a) {
|
|
6357
|
+
return bStack[length] === b;
|
|
6358
|
+
}
|
|
5702
6359
|
} // Add the first object to the stack of traversed objects.
|
|
5703
6360
|
|
|
5704
6361
|
|
|
@@ -5708,10 +6365,16 @@
|
|
|
5708
6365
|
if (areArrays) {
|
|
5709
6366
|
// Compare array lengths to determine if a deep comparison is necessary.
|
|
5710
6367
|
length = a.length;
|
|
5711
|
-
|
|
6368
|
+
|
|
6369
|
+
if (length !== b.length) {
|
|
6370
|
+
return false;
|
|
6371
|
+
} // Deep compare the contents, ignoring non-numeric properties.
|
|
6372
|
+
|
|
5712
6373
|
|
|
5713
6374
|
while (length--) {
|
|
5714
|
-
if (!eq(a[length], b[length], depth - 1, aStack, bStack))
|
|
6375
|
+
if (!eq(a[length], b[length], depth - 1, aStack, bStack)) {
|
|
6376
|
+
return false;
|
|
6377
|
+
}
|
|
5715
6378
|
}
|
|
5716
6379
|
} else {
|
|
5717
6380
|
// Deep compare objects.
|
|
@@ -5719,12 +6382,17 @@
|
|
|
5719
6382
|
var key;
|
|
5720
6383
|
length = keys.length; // Ensure that both objects contain the same number of properties before comparing deep equality.
|
|
5721
6384
|
|
|
5722
|
-
if (Object.keys(b).length !== length)
|
|
6385
|
+
if (Object.keys(b).length !== length) {
|
|
6386
|
+
return false;
|
|
6387
|
+
}
|
|
5723
6388
|
|
|
5724
6389
|
while (length--) {
|
|
5725
6390
|
// Deep compare each member
|
|
5726
6391
|
key = keys[length];
|
|
5727
|
-
|
|
6392
|
+
|
|
6393
|
+
if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {
|
|
6394
|
+
return false;
|
|
6395
|
+
}
|
|
5728
6396
|
}
|
|
5729
6397
|
} // Remove the first object from the stack of traversed objects.
|
|
5730
6398
|
|
|
@@ -5735,9 +6403,18 @@
|
|
|
5735
6403
|
}
|
|
5736
6404
|
|
|
5737
6405
|
function unwrap(a) {
|
|
5738
|
-
if (isObservableArray(a))
|
|
5739
|
-
|
|
5740
|
-
|
|
6406
|
+
if (isObservableArray(a)) {
|
|
6407
|
+
return a.slice();
|
|
6408
|
+
}
|
|
6409
|
+
|
|
6410
|
+
if (isES6Map(a) || isObservableMap(a)) {
|
|
6411
|
+
return Array.from(a.entries());
|
|
6412
|
+
}
|
|
6413
|
+
|
|
6414
|
+
if (isES6Set(a) || isObservableSet(a)) {
|
|
6415
|
+
return Array.from(a.entries());
|
|
6416
|
+
}
|
|
6417
|
+
|
|
5741
6418
|
return a;
|
|
5742
6419
|
}
|
|
5743
6420
|
|