relay-runtime 0.0.0-main-1decb243 → 0.0.0-main-556d696f
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/experimental.js +1 -1
- package/index.js +1 -1
- package/lib/experimental.js +3 -3
- package/lib/handlers/RelayDefaultHandlerProvider.js +12 -12
- package/lib/handlers/connection/ConnectionHandler.js +17 -17
- package/lib/handlers/connection/ConnectionInterface.js +10 -10
- package/lib/handlers/connection/MutationHandlers.js +16 -16
- package/lib/index.js +61 -61
- package/lib/multi-actor-environment/ActorIdentifier.js +5 -5
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +8 -8
- package/lib/multi-actor-environment/ActorUtils.js +4 -4
- package/lib/multi-actor-environment/MultiActorEnvironment.js +12 -12
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +3 -3
- package/lib/mutations/RelayDeclarativeMutationConfig.js +26 -26
- package/lib/mutations/RelayRecordProxy.js +9 -9
- package/lib/mutations/RelayRecordSourceMutator.js +7 -7
- package/lib/mutations/RelayRecordSourceProxy.js +12 -12
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +9 -9
- package/lib/mutations/applyOptimisticMutation.js +9 -9
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +15 -15
- package/lib/mutations/createUpdatableProxy.js +13 -13
- package/lib/mutations/readUpdatableFragment.js +6 -6
- package/lib/mutations/readUpdatableQuery.js +3 -3
- package/lib/mutations/validateMutation.js +9 -7
- package/lib/network/ConvertToExecuteFunction.js +2 -2
- package/lib/network/RelayNetwork.js +8 -8
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +23 -22
- package/lib/network/RelayQueryResponseCache.js +5 -5
- package/lib/network/wrapNetworkWithLogObserver.js +8 -8
- package/lib/query/GraphQLTag.js +16 -16
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +13 -13
- package/lib/query/fetchQueryInternal.js +8 -8
- package/lib/query/fetchQuery_DEPRECATED.js +5 -5
- package/lib/store/ClientID.js +7 -7
- package/lib/store/DataChecker.js +29 -25
- package/lib/store/OperationExecutor.js +87 -87
- package/lib/store/RelayConcreteVariables.js +6 -6
- package/lib/store/RelayExperimentalGraphResponseHandler.js +12 -12
- package/lib/store/RelayExperimentalGraphResponseTransform.js +16 -16
- package/lib/store/RelayModernEnvironment.js +21 -21
- package/lib/store/RelayModernFragmentSpecResolver.js +16 -16
- package/lib/store/RelayModernOperationDescriptor.js +6 -6
- package/lib/store/RelayModernRecord.js +23 -23
- package/lib/store/RelayModernSelector.js +23 -23
- package/lib/store/RelayModernStore.js +35 -35
- package/lib/store/RelayOperationTracker.js +3 -3
- package/lib/store/RelayOptimisticRecordSource.js +8 -8
- package/lib/store/RelayPublishQueue.js +22 -22
- package/lib/store/RelayReader.js +48 -50
- package/lib/store/RelayRecordSource.js +3 -3
- package/lib/store/RelayRecordState.js +4 -4
- package/lib/store/RelayReferenceMarker.js +18 -14
- package/lib/store/RelayResponseNormalizer.js +40 -36
- package/lib/store/RelayStoreSubscriptions.js +8 -8
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +40 -35
- package/lib/store/ResolverCache.js +16 -16
- package/lib/store/ResolverFragments.js +6 -6
- package/lib/store/StoreInspector.js +16 -16
- package/lib/store/TypeID.js +3 -3
- package/lib/store/ViewerPattern.js +5 -5
- package/lib/store/cloneRelayHandleSourceField.js +6 -6
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -6
- package/lib/store/createFragmentSpecResolver.js +3 -3
- package/lib/store/createRelayContext.js +4 -4
- package/lib/store/defaultGetDataID.js +2 -2
- package/lib/store/defaultRequiredFieldLogger.js +3 -3
- package/lib/store/experimental-live-resolvers/LiveResolverCache.js +33 -33
- package/lib/store/experimental-live-resolvers/LiveResolverStore.js +36 -36
- package/lib/store/experimental-live-resolvers/LiveResolverSuspenseSentinel.js +1 -1
- package/lib/store/experimental-live-resolvers/getOutputTypeRecordIDs.js +5 -5
- package/lib/store/experimental-live-resolvers/isLiveStateValue.js +2 -2
- package/lib/store/experimental-live-resolvers/resolverDataInjector.js +6 -6
- package/lib/store/experimental-live-resolvers/weakObjectWrapper.js +6 -6
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/hasSignificantOverlappingIDs.js +3 -3
- package/lib/store/isRelayModernEnvironment.js +2 -2
- package/lib/store/normalizeResponse.js +1 -1
- package/lib/store/readInlineData.js +6 -6
- package/lib/subscription/requestSubscription.js +9 -9
- package/lib/util/JSResourceTypes.flow.js +1 -1
- package/lib/util/NormalizationNode.js +1 -1
- package/lib/util/ReaderNode.js +1 -1
- package/lib/util/RelayConcreteNode.js +36 -36
- package/lib/util/RelayDefaultHandleKey.js +2 -2
- package/lib/util/RelayError.js +3 -3
- package/lib/util/RelayFeatureFlags.js +1 -1
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +10 -10
- package/lib/util/RelayRuntimeTypes.js +1 -1
- package/lib/util/StringInterner.js +3 -3
- package/lib/util/createPayloadFor3DField.js +2 -2
- package/lib/util/deepFreeze.js +3 -3
- package/lib/util/generateID.js +1 -1
- package/lib/util/getFragmentIdentifier.js +12 -12
- package/lib/util/getOperation.js +2 -2
- package/lib/util/getPaginationMetadata.js +6 -6
- package/lib/util/getPaginationVariables.js +9 -9
- package/lib/util/getPendingOperationsForFragment.js +5 -5
- package/lib/util/getRefetchMetadata.js +7 -7
- package/lib/util/getRelayHandleKey.js +4 -4
- package/lib/util/getRequestIdentifier.js +4 -4
- package/lib/util/getValueAtPath.js +5 -5
- package/lib/util/handlePotentialSnapshotErrors.js +6 -6
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/isPromise.js +2 -2
- package/lib/util/isScalarAndEqual.js +2 -2
- package/lib/util/recycleNodesInto.js +6 -20
- package/lib/util/registerEnvironmentWithDevTools.js +2 -2
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +2 -2
- package/lib/util/withDuration.js +2 -2
- package/lib/util/withProvidedVariables.js +3 -3
- package/mutations/validateMutation.js.flow +2 -0
- package/network/RelayObservable.js.flow +3 -2
- package/package.json +1 -1
- package/relay-runtime-experimental.js +2 -2
- package/relay-runtime-experimental.min.js +2 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/DataChecker.js.flow +9 -1
- package/store/RelayModernSelector.js.flow +6 -3
- package/store/RelayReader.js.flow +7 -7
- package/store/RelayReferenceMarker.js.flow +6 -1
- package/store/RelayResponseNormalizer.js.flow +6 -1
- package/store/RelayStoreTypes.js.flow +7 -1
- package/store/RelayStoreUtils.js.flow +22 -7
- package/store/experimental-live-resolvers/resolverDataInjector.js.flow +1 -0
- package/store/experimental-live-resolvers/weakObjectWrapper.js.flow +1 -0
- package/util/NormalizationNode.js.flow +15 -2
- package/util/ReaderNode.js.flow +1 -1
- package/util/createPayloadFor3DField.js.flow +1 -0
- package/util/recycleNodesInto.js.flow +8 -30
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
5
5
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
6
|
-
var _require = require(
|
|
6
|
+
var _require = require('../multi-actor-environment/ActorIdentifier'),
|
|
7
7
|
INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = _require.INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
8
8
|
assertInternalActorIdentifier = _require.assertInternalActorIdentifier;
|
|
9
|
-
var deepFreeze = require(
|
|
10
|
-
var RelayFeatureFlags = require(
|
|
11
|
-
var resolveImmediate = require(
|
|
12
|
-
var DataChecker = require(
|
|
13
|
-
var defaultGetDataID = require(
|
|
14
|
-
var RelayModernRecord = require(
|
|
15
|
-
var RelayOptimisticRecordSource = require(
|
|
16
|
-
var RelayReader = require(
|
|
17
|
-
var RelayReferenceMarker = require(
|
|
18
|
-
var RelayStoreSubscriptions = require(
|
|
19
|
-
var RelayStoreUtils = require(
|
|
20
|
-
var _require2 = require(
|
|
9
|
+
var deepFreeze = require('../util/deepFreeze');
|
|
10
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
11
|
+
var resolveImmediate = require('../util/resolveImmediate');
|
|
12
|
+
var DataChecker = require('./DataChecker');
|
|
13
|
+
var defaultGetDataID = require('./defaultGetDataID');
|
|
14
|
+
var RelayModernRecord = require('./RelayModernRecord');
|
|
15
|
+
var RelayOptimisticRecordSource = require('./RelayOptimisticRecordSource');
|
|
16
|
+
var RelayReader = require('./RelayReader');
|
|
17
|
+
var RelayReferenceMarker = require('./RelayReferenceMarker');
|
|
18
|
+
var RelayStoreSubscriptions = require('./RelayStoreSubscriptions');
|
|
19
|
+
var RelayStoreUtils = require('./RelayStoreUtils');
|
|
20
|
+
var _require2 = require('./RelayStoreUtils'),
|
|
21
21
|
ROOT_ID = _require2.ROOT_ID,
|
|
22
22
|
ROOT_TYPE = _require2.ROOT_TYPE;
|
|
23
|
-
var _require3 = require(
|
|
23
|
+
var _require3 = require('./ResolverCache'),
|
|
24
24
|
RecordResolverCache = _require3.RecordResolverCache;
|
|
25
|
-
var invariant = require(
|
|
25
|
+
var invariant = require('invariant');
|
|
26
26
|
var DEFAULT_RELEASE_BUFFER_SIZE = 10;
|
|
27
27
|
var RelayModernStore = /*#__PURE__*/function () {
|
|
28
28
|
function RelayModernStore(source, options) {
|
|
@@ -90,7 +90,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
90
90
|
if (globalInvalidationEpoch != null) {
|
|
91
91
|
if (operationLastWrittenAt == null || operationLastWrittenAt <= globalInvalidationEpoch) {
|
|
92
92
|
return {
|
|
93
|
-
status:
|
|
93
|
+
status: 'stale'
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -169,7 +169,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
169
169
|
var log = this.__log;
|
|
170
170
|
if (log != null) {
|
|
171
171
|
log({
|
|
172
|
-
name:
|
|
172
|
+
name: 'store.notify.start',
|
|
173
173
|
sourceOperation: sourceOperation
|
|
174
174
|
});
|
|
175
175
|
}
|
|
@@ -188,7 +188,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
188
188
|
});
|
|
189
189
|
if (log != null) {
|
|
190
190
|
log({
|
|
191
|
-
name:
|
|
191
|
+
name: 'store.notify.complete',
|
|
192
192
|
sourceOperation: sourceOperation,
|
|
193
193
|
updatedRecordIDs: this._updatedRecordIDs,
|
|
194
194
|
invalidatedRecordIDs: this._invalidatedRecordIDs
|
|
@@ -202,7 +202,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
202
202
|
if (rootEntry != null) {
|
|
203
203
|
rootEntry.epoch = this._currentWriteEpoch;
|
|
204
204
|
rootEntry.fetchTime = Date.now();
|
|
205
|
-
} else if (sourceOperation.request.node.params.operationKind ===
|
|
205
|
+
} else if (sourceOperation.request.node.params.operationKind === 'query' && this._gcReleaseBufferSize > 0 && this._releaseBuffer.length < this._gcReleaseBufferSize) {
|
|
206
206
|
var temporaryRootEntry = {
|
|
207
207
|
operation: sourceOperation,
|
|
208
208
|
refCount: 0,
|
|
@@ -221,7 +221,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
221
221
|
var log = this.__log;
|
|
222
222
|
if (log != null) {
|
|
223
223
|
log({
|
|
224
|
-
name:
|
|
224
|
+
name: 'store.publish',
|
|
225
225
|
source: source,
|
|
226
226
|
optimistic: target === this._optimisticSource
|
|
227
227
|
});
|
|
@@ -251,7 +251,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
251
251
|
};
|
|
252
252
|
};
|
|
253
253
|
_proto.toJSON = function toJSON() {
|
|
254
|
-
return
|
|
254
|
+
return 'RelayModernStore()';
|
|
255
255
|
};
|
|
256
256
|
_proto.getEpoch = function getEpoch() {
|
|
257
257
|
return this._currentWriteEpoch;
|
|
@@ -267,7 +267,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
267
267
|
var record = _this5.getSource().get(dataID);
|
|
268
268
|
invalidations.set(dataID, (_RelayModernRecord$ge = RelayModernRecord.getInvalidationEpoch(record)) !== null && _RelayModernRecord$ge !== void 0 ? _RelayModernRecord$ge : null);
|
|
269
269
|
});
|
|
270
|
-
invalidations.set(
|
|
270
|
+
invalidations.set('global', this._globalInvalidationEpoch);
|
|
271
271
|
return {
|
|
272
272
|
dataIDs: dataIDs,
|
|
273
273
|
invalidations: invalidations
|
|
@@ -277,7 +277,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
277
277
|
var latestInvalidationState = this.lookupInvalidationState(prevInvalidationState.dataIDs);
|
|
278
278
|
var currentInvalidations = latestInvalidationState.invalidations;
|
|
279
279
|
var prevInvalidations = prevInvalidationState.invalidations;
|
|
280
|
-
if (currentInvalidations.get(
|
|
280
|
+
if (currentInvalidations.get('global') !== prevInvalidations.get('global')) {
|
|
281
281
|
return true;
|
|
282
282
|
}
|
|
283
283
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(prevInvalidationState.dataIDs),
|
|
@@ -324,11 +324,11 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
324
324
|
callback();
|
|
325
325
|
};
|
|
326
326
|
_proto.snapshot = function snapshot() {
|
|
327
|
-
!(this._optimisticSource == null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
327
|
+
!(this._optimisticSource == null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernStore: Unexpected call to snapshot() while a previous ' + 'snapshot exists.') : invariant(false) : void 0;
|
|
328
328
|
var log = this.__log;
|
|
329
329
|
if (log != null) {
|
|
330
330
|
log({
|
|
331
|
-
name:
|
|
331
|
+
name: 'store.snapshot'
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
334
|
this._storeSubscriptions.snapshotSubscriptions(this.getSource());
|
|
@@ -339,11 +339,11 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
339
339
|
this._optimisticSource = RelayOptimisticRecordSource.create(this.getSource());
|
|
340
340
|
};
|
|
341
341
|
_proto.restore = function restore() {
|
|
342
|
-
!(this._optimisticSource != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
342
|
+
!(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;
|
|
343
343
|
var log = this.__log;
|
|
344
344
|
if (log != null) {
|
|
345
345
|
log({
|
|
346
|
-
name:
|
|
346
|
+
name: 'store.restore'
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
this._optimisticSource = null;
|
|
@@ -394,7 +394,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
394
394
|
var log = this.__log;
|
|
395
395
|
if (log != null) {
|
|
396
396
|
log({
|
|
397
|
-
name:
|
|
397
|
+
name: 'store.gc',
|
|
398
398
|
references: references
|
|
399
399
|
});
|
|
400
400
|
}
|
|
@@ -475,28 +475,28 @@ function updateTargetFromSource(target, source, currentWriteEpoch, idsMarkedForI
|
|
|
475
475
|
function getAvailabilityStatus(operationAvailability, operationLastWrittenAt, operationFetchTime, queryCacheExpirationTime) {
|
|
476
476
|
var mostRecentlyInvalidatedAt = operationAvailability.mostRecentlyInvalidatedAt,
|
|
477
477
|
status = operationAvailability.status;
|
|
478
|
-
if (typeof mostRecentlyInvalidatedAt ===
|
|
478
|
+
if (typeof mostRecentlyInvalidatedAt === 'number') {
|
|
479
479
|
if (operationLastWrittenAt == null || mostRecentlyInvalidatedAt > operationLastWrittenAt) {
|
|
480
480
|
return {
|
|
481
|
-
status:
|
|
481
|
+
status: 'stale'
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
if (status ===
|
|
485
|
+
if (status === 'missing') {
|
|
486
486
|
return {
|
|
487
|
-
status:
|
|
487
|
+
status: 'missing'
|
|
488
488
|
};
|
|
489
489
|
}
|
|
490
490
|
if (operationFetchTime != null && queryCacheExpirationTime != null) {
|
|
491
491
|
var isStale = operationFetchTime <= Date.now() - queryCacheExpirationTime;
|
|
492
492
|
if (isStale) {
|
|
493
493
|
return {
|
|
494
|
-
status:
|
|
494
|
+
status: 'stale'
|
|
495
495
|
};
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
return {
|
|
499
|
-
status:
|
|
499
|
+
status: 'available',
|
|
500
500
|
fetchTime: operationFetchTime !== null && operationFetchTime !== void 0 ? operationFetchTime : null
|
|
501
501
|
};
|
|
502
502
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
5
|
-
var invariant = require(
|
|
5
|
+
var invariant = require('invariant');
|
|
6
6
|
var RelayOperationTracker = /*#__PURE__*/function () {
|
|
7
7
|
function RelayOperationTracker() {
|
|
8
8
|
this._ownersToPendingOperations = new Map();
|
|
@@ -137,7 +137,7 @@ var RelayOperationTracker = /*#__PURE__*/function () {
|
|
|
137
137
|
var promise = new Promise(function (r) {
|
|
138
138
|
resolve = r;
|
|
139
139
|
});
|
|
140
|
-
!(resolve != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
140
|
+
!(resolve != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayOperationTracker: Expected resolver to be defined. If you' + 'are seeing this, it is likely a bug in Relay.') : invariant(false) : void 0;
|
|
141
141
|
var pendingOperations = Array.from(pendingOperationsForOwner.values());
|
|
142
142
|
this._ownersToPendingPromise.set(ownerIdentifier, {
|
|
143
143
|
promise: promise,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
5
|
-
var RelayModernRecord = require(
|
|
6
|
-
var RelayRecordSource = require(
|
|
7
|
-
var invariant = require(
|
|
5
|
+
var RelayModernRecord = require('./RelayModernRecord');
|
|
6
|
+
var RelayRecordSource = require('./RelayRecordSource');
|
|
7
|
+
var invariant = require('invariant');
|
|
8
8
|
var UNPUBLISH_RECORD_SENTINEL = RelayModernRecord.fromObject(Object.freeze({
|
|
9
9
|
__UNPUBLISH_RECORD_SENTINEL: true
|
|
10
10
|
}));
|
|
@@ -37,11 +37,11 @@ var RelayOptimisticRecordSource = /*#__PURE__*/function () {
|
|
|
37
37
|
_proto.getStatus = function getStatus(dataID) {
|
|
38
38
|
var record = this.get(dataID);
|
|
39
39
|
if (record === undefined) {
|
|
40
|
-
return
|
|
40
|
+
return 'UNKNOWN';
|
|
41
41
|
} else if (record === null) {
|
|
42
|
-
return
|
|
42
|
+
return 'NONEXISTENT';
|
|
43
43
|
} else {
|
|
44
|
-
return
|
|
44
|
+
return 'EXISTENT';
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
_proto.clear = function clear() {
|
|
@@ -85,7 +85,7 @@ function create(base) {
|
|
|
85
85
|
return new RelayOptimisticRecordSource(base);
|
|
86
86
|
}
|
|
87
87
|
function getOptimisticRecordIDs(source) {
|
|
88
|
-
!(source instanceof RelayOptimisticRecordSource) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
88
|
+
!(source instanceof RelayOptimisticRecordSource) ? process.env.NODE_ENV !== "production" ? invariant(false, 'getOptimisticRecordIDs: Instance of RelayOptimisticRecordSource is expected') : invariant(false) : void 0;
|
|
89
89
|
return source.getOptimisticRecordIDs();
|
|
90
90
|
}
|
|
91
91
|
module.exports = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var _global$ErrorUtils$ap, _global$ErrorUtils;
|
|
4
|
-
var RelayRecordSourceMutator = require(
|
|
5
|
-
var RelayRecordSourceProxy = require(
|
|
6
|
-
var RelayRecordSourceSelectorProxy = require(
|
|
7
|
-
var RelayReader = require(
|
|
8
|
-
var RelayRecordSource = require(
|
|
9
|
-
var invariant = require(
|
|
4
|
+
var RelayRecordSourceMutator = require('../mutations/RelayRecordSourceMutator');
|
|
5
|
+
var RelayRecordSourceProxy = require('../mutations/RelayRecordSourceProxy');
|
|
6
|
+
var RelayRecordSourceSelectorProxy = require('../mutations/RelayRecordSourceSelectorProxy');
|
|
7
|
+
var RelayReader = require('./RelayReader');
|
|
8
|
+
var RelayRecordSource = require('./RelayRecordSource');
|
|
9
|
+
var invariant = require('invariant');
|
|
10
10
|
var warning = require("fbjs/lib/warning");
|
|
11
|
-
var _global = typeof global !==
|
|
11
|
+
var _global = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : undefined;
|
|
12
12
|
var applyWithGuard = (_global$ErrorUtils$ap = _global === null || _global === void 0 ? void 0 : (_global$ErrorUtils = _global.ErrorUtils) === null || _global$ErrorUtils === void 0 ? void 0 : _global$ErrorUtils.applyWithGuard) !== null && _global$ErrorUtils$ap !== void 0 ? _global$ErrorUtils$ap : function (callback, context, args, onError, name) {
|
|
13
13
|
return callback.apply(context, args);
|
|
14
14
|
};
|
|
@@ -27,7 +27,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
27
27
|
}
|
|
28
28
|
var _proto = RelayPublishQueue.prototype;
|
|
29
29
|
_proto.applyUpdate = function applyUpdate(updater) {
|
|
30
|
-
!(!this._appliedOptimisticUpdates.has(updater) && !this._pendingOptimisticUpdates.has(updater)) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
30
|
+
!(!this._appliedOptimisticUpdates.has(updater) && !this._pendingOptimisticUpdates.has(updater)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayPublishQueue: Cannot apply the same update function more than ' + 'once concurrently.') : invariant(false) : void 0;
|
|
31
31
|
this._pendingOptimisticUpdates.add(updater);
|
|
32
32
|
};
|
|
33
33
|
_proto.revertUpdate = function revertUpdate(updater) {
|
|
@@ -46,7 +46,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
46
46
|
_proto.commitPayload = function commitPayload(operation, payload, updater) {
|
|
47
47
|
this._pendingBackupRebase = true;
|
|
48
48
|
this._pendingData.add({
|
|
49
|
-
kind:
|
|
49
|
+
kind: 'payload',
|
|
50
50
|
operation: operation,
|
|
51
51
|
payload: payload,
|
|
52
52
|
updater: updater
|
|
@@ -55,14 +55,14 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
55
55
|
_proto.commitUpdate = function commitUpdate(updater) {
|
|
56
56
|
this._pendingBackupRebase = true;
|
|
57
57
|
this._pendingData.add({
|
|
58
|
-
kind:
|
|
58
|
+
kind: 'updater',
|
|
59
59
|
updater: updater
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
_proto.commitSource = function commitSource(source) {
|
|
63
63
|
this._pendingBackupRebase = true;
|
|
64
64
|
this._pendingData.add({
|
|
65
|
-
kind:
|
|
65
|
+
kind: 'source',
|
|
66
66
|
source: source
|
|
67
67
|
});
|
|
68
68
|
};
|
|
@@ -70,8 +70,8 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
70
70
|
var runWillClearGcHold = this._appliedOptimisticUpdates === 0 && !!this._gcHold;
|
|
71
71
|
var runIsANoop = !this._pendingBackupRebase && this._pendingOptimisticUpdates.size === 0 && !runWillClearGcHold;
|
|
72
72
|
if (process.env.NODE_ENV !== "production") {
|
|
73
|
-
process.env.NODE_ENV !== "production" ? warning(!runIsANoop,
|
|
74
|
-
process.env.NODE_ENV !== "production" ? warning(this._isRunning !== true,
|
|
73
|
+
process.env.NODE_ENV !== "production" ? warning(!runIsANoop, 'RelayPublishQueue.run was called, but the call would have been a noop.') : void 0;
|
|
74
|
+
process.env.NODE_ENV !== "production" ? warning(this._isRunning !== true, 'A store update was detected within another store update. Please ' + "make sure new store updates aren't being executed within an " + 'updater function for a different update.') : void 0;
|
|
75
75
|
this._isRunning = true;
|
|
76
76
|
}
|
|
77
77
|
if (runIsANoop) {
|
|
@@ -122,13 +122,13 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
122
122
|
if (fieldPayloads && fieldPayloads.length) {
|
|
123
123
|
fieldPayloads.forEach(function (fieldPayload) {
|
|
124
124
|
var handler = _this._handlerProvider && _this._handlerProvider(fieldPayload.handle);
|
|
125
|
-
!handler ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
125
|
+
!handler ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected a handler to be provided for ' + 'handle `%s`.', fieldPayload.handle) : invariant(false) : void 0;
|
|
126
126
|
handler.update(recordSourceProxy, fieldPayload);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
if (updater) {
|
|
130
130
|
var selector = operation.fragment;
|
|
131
|
-
!(selector != null) ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
131
|
+
!(selector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: Expected a selector to be provided with updater function.') : invariant(false) : void 0;
|
|
132
132
|
var recordSourceSelectorProxy = new RelayRecordSourceSelectorProxy(mutator, recordSourceProxy, selector, this._missingFieldHandlers);
|
|
133
133
|
var selectorData = lookupSelector(source, selector);
|
|
134
134
|
updater(recordSourceSelectorProxy, selectorData);
|
|
@@ -144,10 +144,10 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
144
144
|
}
|
|
145
145
|
var invalidatedStore = false;
|
|
146
146
|
this._pendingData.forEach(function (data) {
|
|
147
|
-
if (data.kind ===
|
|
147
|
+
if (data.kind === 'payload') {
|
|
148
148
|
var payloadInvalidatedStore = _this2._publishSourceFromPayload(data);
|
|
149
149
|
invalidatedStore = invalidatedStore || payloadInvalidatedStore;
|
|
150
|
-
} else if (data.kind ===
|
|
150
|
+
} else if (data.kind === 'source') {
|
|
151
151
|
var source = data.source;
|
|
152
152
|
_this2._store.publish(source);
|
|
153
153
|
} else {
|
|
@@ -155,7 +155,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
155
155
|
var sink = RelayRecordSource.create();
|
|
156
156
|
var mutator = new RelayRecordSourceMutator(_this2._store.getSource(), sink);
|
|
157
157
|
var recordSourceProxy = new RelayRecordSourceProxy(mutator, _this2._getDataID, _this2._handlerProvider, _this2._missingFieldHandlers);
|
|
158
|
-
applyWithGuard(updater, null, [recordSourceProxy], null,
|
|
158
|
+
applyWithGuard(updater, null, [recordSourceProxy], null, 'RelayPublishQueue:commitData');
|
|
159
159
|
invalidatedStore = invalidatedStore || recordSourceProxy.isStoreMarkedForInvalidation();
|
|
160
160
|
var idsMarkedForInvalidation = recordSourceProxy.getIDsMarkedForInvalidation();
|
|
161
161
|
_this2._store.publish(sink, idsMarkedForInvalidation);
|
|
@@ -172,7 +172,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
172
172
|
var processUpdate = function processUpdate(optimisticUpdate) {
|
|
173
173
|
if (optimisticUpdate.storeUpdater) {
|
|
174
174
|
var storeUpdater = optimisticUpdate.storeUpdater;
|
|
175
|
-
applyWithGuard(storeUpdater, null, [recordSourceProxy], null,
|
|
175
|
+
applyWithGuard(storeUpdater, null, [recordSourceProxy], null, 'RelayPublishQueue:applyUpdates');
|
|
176
176
|
} else {
|
|
177
177
|
var operation = optimisticUpdate.operation,
|
|
178
178
|
payload = optimisticUpdate.payload,
|
|
@@ -188,7 +188,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
188
188
|
selectorData = lookupSelector(source, operation.fragment);
|
|
189
189
|
}
|
|
190
190
|
var recordSourceSelectorProxy = new RelayRecordSourceSelectorProxy(mutator, recordSourceProxy, operation.fragment, _this3._missingFieldHandlers);
|
|
191
|
-
applyWithGuard(updater, null, [recordSourceSelectorProxy, selectorData], null,
|
|
191
|
+
applyWithGuard(updater, null, [recordSourceSelectorProxy, selectorData], null, 'RelayPublishQueue:applyUpdates');
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
};
|
|
@@ -209,7 +209,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
209
209
|
function lookupSelector(source, selector) {
|
|
210
210
|
var selectorData = RelayReader.read(source, selector).data;
|
|
211
211
|
if (process.env.NODE_ENV !== "production") {
|
|
212
|
-
var deepFreeze = require(
|
|
212
|
+
var deepFreeze = require('../util/deepFreeze');
|
|
213
213
|
if (selectorData) {
|
|
214
214
|
deepFreeze(selectorData);
|
|
215
215
|
}
|