relay-runtime 10.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/lib/store/RelayModernStore.js +6 -6
- package/lib/store/RelayReader.js +4 -16
- package/lib/store/RelayResponseNormalizer.js +9 -36
- package/lib/store/StoreInspector.js +1 -3
- package/lib/util/recycleNodesInto.js +2 -8
- package/package.json +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayModernStore.js.flow +7 -7
- package/store/RelayReader.js.flow +4 -12
- package/store/RelayResponseNormalizer.js.flow +10 -31
- package/store/StoreInspector.js.flow +1 -3
- package/util/recycleNodesInto.js.flow +2 -8
package/index.js
CHANGED
|
@@ -102,7 +102,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
102
102
|
this._globalInvalidationEpoch = null;
|
|
103
103
|
this._invalidationSubscriptions = new Set();
|
|
104
104
|
this._invalidatedRecordIDs = new Set();
|
|
105
|
-
this.
|
|
105
|
+
this.__log = (_options$log = options === null || options === void 0 ? void 0 : options.log) !== null && _options$log !== void 0 ? _options$log : null;
|
|
106
106
|
this._queryCacheExpirationTime = options === null || options === void 0 ? void 0 : options.queryCacheExpirationTime;
|
|
107
107
|
this._operationLoader = (_options$operationLoa = options === null || options === void 0 ? void 0 : options.operationLoader) !== null && _options$operationLoa !== void 0 ? _options$operationLoa : null;
|
|
108
108
|
this._optimisticSource = null;
|
|
@@ -248,7 +248,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
248
248
|
_proto.notify = function notify(sourceOperation, invalidateStore) {
|
|
249
249
|
var _this3 = this;
|
|
250
250
|
|
|
251
|
-
var log = this.
|
|
251
|
+
var log = this.__log;
|
|
252
252
|
|
|
253
253
|
if (log != null) {
|
|
254
254
|
log({
|
|
@@ -336,7 +336,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
336
336
|
this._currentWriteEpoch + 1, idsMarkedForInvalidation, this._updatedRecordIDs, this._invalidatedRecordIDs); // NOTE: log *after* processing the source so that even if a bad log function
|
|
337
337
|
// mutates the source, it doesn't affect Relay processing of it.
|
|
338
338
|
|
|
339
|
-
var log = this.
|
|
339
|
+
var log = this.__log;
|
|
340
340
|
|
|
341
341
|
if (log != null) {
|
|
342
342
|
log({
|
|
@@ -527,7 +527,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
527
527
|
var _this9 = this;
|
|
528
528
|
|
|
529
529
|
!(this._optimisticSource == null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernStore: Unexpected call to snapshot() while a previous ' + 'snapshot exists.') : invariant(false) : void 0;
|
|
530
|
-
var log = this.
|
|
530
|
+
var log = this.__log;
|
|
531
531
|
|
|
532
532
|
if (log != null) {
|
|
533
533
|
log({
|
|
@@ -571,7 +571,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
571
571
|
|
|
572
572
|
_proto.restore = function restore() {
|
|
573
573
|
!(this._optimisticSource != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernStore: Unexpected call to restore(), expected a snapshot ' + 'to exist (make sure to call snapshot()).') : invariant(false) : void 0;
|
|
574
|
-
var log = this.
|
|
574
|
+
var log = this.__log;
|
|
575
575
|
|
|
576
576
|
if (log != null) {
|
|
577
577
|
log({
|
|
@@ -663,7 +663,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
663
663
|
_iterator2.f();
|
|
664
664
|
}
|
|
665
665
|
|
|
666
|
-
var log = this.
|
|
666
|
+
var log = this.__log;
|
|
667
667
|
|
|
668
668
|
if (log != null) {
|
|
669
669
|
log({
|
package/lib/store/RelayReader.js
CHANGED
|
@@ -297,10 +297,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
var prevData = data[applicationName];
|
|
300
|
-
!(prevData == null || typeof prevData === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Expected data for field `%s` on record `%s` ' + 'to be an object, got `%s`.', applicationName, RelayModernRecord.getDataID(record), prevData) : invariant(false) : void 0;
|
|
301
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_native_
|
|
302
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
303
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
300
|
+
!(prevData == null || typeof prevData === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Expected data for field `%s` on record `%s` ' + 'to be an object, got `%s`.', applicationName, RelayModernRecord.getDataID(record), prevData) : invariant(false) : void 0; // $FlowFixMe[incompatible-variance]
|
|
304
301
|
|
|
305
302
|
data[applicationName] = this._traverse(field, linkedID, prevData);
|
|
306
303
|
};
|
|
@@ -331,10 +328,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
331
328
|
if (linkedID == null) {
|
|
332
329
|
if (linkedID === undefined) {
|
|
333
330
|
_this._isMissingData = true;
|
|
334
|
-
}
|
|
335
|
-
/* $FlowFixMe[cannot-write] (>=0.98.0 site=www,mobile,react_native_
|
|
336
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
337
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
331
|
+
} // $FlowFixMe[cannot-write]
|
|
338
332
|
|
|
339
333
|
|
|
340
334
|
linkedArray[nextIndex] = linkedID;
|
|
@@ -342,14 +336,8 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
342
336
|
}
|
|
343
337
|
|
|
344
338
|
var prevItem = linkedArray[nextIndex];
|
|
345
|
-
!(prevItem == null || typeof prevItem === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Expected data for field `%s` on record `%s` ' + 'to be an object, got `%s`.', applicationName, RelayModernRecord.getDataID(record), prevItem) : invariant(false) : void 0;
|
|
346
|
-
|
|
347
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
348
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
349
|
-
|
|
350
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_
|
|
351
|
-
* native_fb,oss) This comment suppresses an error found when Flow v0.98
|
|
352
|
-
* was deployed. To see the error delete this comment and run Flow. */
|
|
339
|
+
!(prevItem == null || typeof prevItem === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Expected data for field `%s` on record `%s` ' + 'to be an object, got `%s`.', applicationName, RelayModernRecord.getDataID(record), prevItem) : invariant(false) : void 0; // $FlowFixMe[cannot-write]
|
|
340
|
+
// $FlowFixMe[incompatible-variance]
|
|
353
341
|
|
|
354
342
|
linkedArray[nextIndex] = _this._traverse(field, linkedID, prevItem);
|
|
355
343
|
});
|
|
@@ -398,16 +398,8 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
398
398
|
var _field$concreteType;
|
|
399
399
|
|
|
400
400
|
!(typeof fieldValue === 'object' && fieldValue) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayResponseNormalizer: Expected data for field `%s` to be an object.', storageKey) : invariant(false) : void 0;
|
|
401
|
-
var nextID = this._getDataId(
|
|
402
|
-
|
|
403
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
404
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
405
|
-
* Flow. */
|
|
406
|
-
fieldValue,
|
|
407
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_
|
|
408
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
409
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
410
|
-
* Flow. */
|
|
401
|
+
var nextID = this._getDataId( // $FlowFixMe[incompatible-variance]
|
|
402
|
+
fieldValue, // $FlowFixMe[incompatible-variance]
|
|
411
403
|
(_field$concreteType = field.concreteType) !== null && _field$concreteType !== void 0 ? _field$concreteType : this._getRecordType(fieldValue)) || // Reuse previously generated client IDs
|
|
412
404
|
RelayModernRecord.getLinkedRecordID(record, storageKey) || generateClientID(RelayModernRecord.getDataID(record), storageKey);
|
|
413
405
|
!(typeof nextID === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayResponseNormalizer: Expected id on field `%s` to be a string.', storageKey) : invariant(false) : void 0;
|
|
@@ -421,9 +413,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
421
413
|
var nextRecord = this._recordSource.get(nextID);
|
|
422
414
|
|
|
423
415
|
if (!nextRecord) {
|
|
424
|
-
|
|
425
|
-
* native_fb,oss) This comment suppresses an error found when Flow v0.98
|
|
426
|
-
* was deployed. To see the error delete this comment and run Flow. */
|
|
416
|
+
// $FlowFixMe[incompatible-variance]
|
|
427
417
|
var _typeName4 = field.concreteType || this._getRecordType(fieldValue);
|
|
428
418
|
|
|
429
419
|
nextRecord = RelayModernRecord.create(nextID, _typeName4);
|
|
@@ -431,10 +421,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
431
421
|
this._recordSource.set(nextID, nextRecord);
|
|
432
422
|
} else if (process.env.NODE_ENV !== "production") {
|
|
433
423
|
this._validateRecordType(nextRecord, field, fieldValue);
|
|
434
|
-
}
|
|
435
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_native_
|
|
436
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98 was
|
|
437
|
-
* deployed. To see the error delete this comment and run Flow. */
|
|
424
|
+
} // $FlowFixMe[incompatible-variance]
|
|
438
425
|
|
|
439
426
|
|
|
440
427
|
this._traverseSelections(field, nextRecord, fieldValue);
|
|
@@ -458,16 +445,8 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
458
445
|
_this._path.push(String(nextIndex));
|
|
459
446
|
|
|
460
447
|
!(typeof item === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayResponseNormalizer: Expected elements for field `%s` to be ' + 'objects.', storageKey) : invariant(false) : void 0;
|
|
461
|
-
var nextID = _this._getDataId(
|
|
462
|
-
|
|
463
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
464
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
465
|
-
* Flow. */
|
|
466
|
-
item,
|
|
467
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_
|
|
468
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
469
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
470
|
-
* Flow. */
|
|
448
|
+
var nextID = _this._getDataId( // $FlowFixMe[incompatible-variance]
|
|
449
|
+
item, // $FlowFixMe[incompatible-variance]
|
|
471
450
|
(_field$concreteType2 = field.concreteType) !== null && _field$concreteType2 !== void 0 ? _field$concreteType2 : _this._getRecordType(item)) || prevIDs && prevIDs[nextIndex] || // Reuse previously generated client IDs:
|
|
472
451
|
generateClientID(RelayModernRecord.getDataID(record), storageKey, nextIndex);
|
|
473
452
|
!(typeof nextID === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayResponseNormalizer: Expected id of elements of field `%s` to ' + 'be strings.', storageKey) : invariant(false) : void 0;
|
|
@@ -476,10 +455,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
476
455
|
var nextRecord = _this._recordSource.get(nextID);
|
|
477
456
|
|
|
478
457
|
if (!nextRecord) {
|
|
479
|
-
|
|
480
|
-
* native_fb,oss) This comment suppresses an error found when Flow
|
|
481
|
-
* v0.98 was deployed. To see the error delete this comment and run
|
|
482
|
-
* Flow. */
|
|
458
|
+
// $FlowFixMe[incompatible-variance]
|
|
483
459
|
var _typeName5 = field.concreteType || _this._getRecordType(item);
|
|
484
460
|
|
|
485
461
|
nextRecord = RelayModernRecord.create(nextID, _typeName5);
|
|
@@ -491,10 +467,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
491
467
|
|
|
492
468
|
if (prevIDs && process.env.NODE_ENV !== "production") {
|
|
493
469
|
_this._validateConflictingLinkedFieldsWithIdenticalId(record, prevIDs[nextIndex], nextID, storageKey);
|
|
494
|
-
}
|
|
495
|
-
/* $FlowFixMe[incompatible-variance] (>=0.98.0 site=www,mobile,react_
|
|
496
|
-
* native_fb,oss) This comment suppresses an error found when Flow v0.98
|
|
497
|
-
* was deployed. To see the error delete this comment and run Flow. */
|
|
470
|
+
} // $FlowFixMe[incompatible-variance]
|
|
498
471
|
|
|
499
472
|
|
|
500
473
|
_this._traverseSelections(field, nextRecord, item);
|
|
@@ -524,7 +497,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
|
|
|
524
497
|
if (process.env.NODE_ENV !== "production") {
|
|
525
498
|
var dataID = RelayModernRecord.getDataID(record);
|
|
526
499
|
var previousValue = RelayModernRecord.getValue(record, storageKey);
|
|
527
|
-
process.env.NODE_ENV !== "production" ? warning(storageKey === TYPENAME_KEY || previousValue === undefined || previousValue === fieldValue, 'RelayResponseNormalizer: Invalid record. The record contains two ' + 'instances of the same id: `%s` with conflicting field, %s and its values: %s and %s.' + 'If two fields are different but share' + 'the same id, one field will overwrite the other.', dataID, storageKey, previousValue, fieldValue) : void 0;
|
|
500
|
+
process.env.NODE_ENV !== "production" ? warning(storageKey === TYPENAME_KEY || previousValue === undefined || previousValue === fieldValue, 'RelayResponseNormalizer: Invalid record. The record contains two ' + 'instances of the same id: `%s` with conflicting field, %s and its values: %s and %s. ' + 'If two fields are different but share ' + 'the same id, one field will overwrite the other.', dataID, storageKey, previousValue, fieldValue) : void 0;
|
|
528
501
|
}
|
|
529
502
|
}
|
|
530
503
|
/**
|
|
@@ -152,9 +152,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
if (Array.isArray(value.__refs)) {
|
|
155
|
-
|
|
156
|
-
* suppresses an error found when Flow v0.111.0 was deployed. To
|
|
157
|
-
* see the error, delete this comment and run Flow. */
|
|
155
|
+
// $FlowFixMe[incompatible-call]
|
|
158
156
|
return value.__refs.map(function (ref) {
|
|
159
157
|
return getWrappedRecord(source, ref);
|
|
160
158
|
});
|
|
@@ -53,17 +53,11 @@ function recycleNodesInto(prevData, nextData) {
|
|
|
53
53
|
if (nextValue !== nextObject[key]) {
|
|
54
54
|
if (process.env.NODE_ENV !== "production") {
|
|
55
55
|
if (!Object.isFrozen(nextObject)) {
|
|
56
|
-
|
|
57
|
-
* native_fb,oss) This comment suppresses an error found when
|
|
58
|
-
* Flow v0.98 was deployed. To see the error delete this comment
|
|
59
|
-
* and run Flow. */
|
|
56
|
+
// $FlowFixMe[cannot-write]
|
|
60
57
|
nextObject[key] = nextValue;
|
|
61
58
|
}
|
|
62
59
|
} else {
|
|
63
|
-
|
|
64
|
-
* fb,oss) This comment suppresses an error found when Flow v0.98
|
|
65
|
-
* was deployed. To see the error delete this comment and run Flow.
|
|
66
|
-
*/
|
|
60
|
+
// $FlowFixMe[cannot-write]
|
|
67
61
|
nextObject[key] = nextValue;
|
|
68
62
|
}
|
|
69
63
|
}
|