relay-runtime 11.0.0 → 13.0.0-rc.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/handlers/RelayDefaultHandlerProvider.js.flow +2 -2
- package/handlers/connection/ConnectionHandler.js.flow +8 -10
- package/handlers/connection/MutationHandlers.js.flow +31 -7
- package/index.js +1 -1
- package/index.js.flow +60 -36
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +8 -8
- package/lib/handlers/connection/MutationHandlers.js +61 -5
- package/lib/index.js +58 -43
- package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +152 -0
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +419 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +21 -0
- package/lib/mutations/RelayDeclarativeMutationConfig.js +4 -1
- package/lib/mutations/RelayRecordProxy.js +3 -2
- package/lib/mutations/RelayRecordSourceMutator.js +3 -2
- package/lib/mutations/RelayRecordSourceProxy.js +12 -4
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +18 -5
- package/lib/mutations/applyOptimisticMutation.js +6 -6
- package/lib/mutations/commitMutation.js +14 -10
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +238 -0
- package/lib/mutations/validateMutation.js +12 -5
- package/lib/network/ConvertToExecuteFunction.js +2 -1
- package/lib/network/RelayNetwork.js +3 -2
- package/lib/network/RelayQueryResponseCache.js +21 -4
- package/lib/network/wrapNetworkWithLogObserver.js +79 -0
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/fetchQuery.js +6 -5
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +2 -1
- package/lib/store/ClientID.js +7 -1
- package/lib/store/DataChecker.js +141 -60
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +532 -195
- package/lib/store/RelayConcreteVariables.js +24 -4
- package/lib/store/RelayModernEnvironment.js +175 -234
- package/lib/store/RelayModernFragmentSpecResolver.js +52 -26
- package/lib/store/RelayModernOperationDescriptor.js +2 -1
- package/lib/store/RelayModernRecord.js +47 -12
- package/lib/store/RelayModernSelector.js +14 -8
- package/lib/store/RelayModernStore.js +58 -29
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayPublishQueue.js +41 -13
- package/lib/store/RelayReader.js +287 -46
- package/lib/store/RelayRecordSource.js +87 -3
- package/lib/store/RelayReferenceMarker.js +55 -31
- package/lib/store/RelayResponseNormalizer.js +250 -108
- package/lib/store/RelayStoreReactFlightUtils.js +8 -12
- package/lib/store/RelayStoreSubscriptions.js +14 -9
- package/lib/store/RelayStoreUtils.js +11 -5
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +61 -0
- package/lib/store/cloneRelayHandleSourceField.js +5 -4
- package/lib/store/cloneRelayScalarHandleSourceField.js +5 -4
- package/lib/store/createRelayContext.js +4 -2
- package/lib/store/defaultGetDataID.js +3 -1
- package/lib/store/readInlineData.js +6 -2
- package/lib/subscription/requestSubscription.js +35 -9
- package/lib/util/RelayConcreteNode.js +4 -0
- package/lib/util/RelayFeatureFlags.js +11 -4
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/RelayRuntimeTypes.js +0 -6
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/deepFreeze.js +1 -0
- package/lib/util/getFragmentIdentifier.js +15 -7
- package/lib/util/getOperation.js +2 -1
- package/lib/util/getPaginationMetadata.js +41 -0
- package/lib/util/getPaginationVariables.js +66 -0
- package/lib/util/getPendingOperationsForFragment.js +55 -0
- package/lib/util/getRefetchMetadata.js +36 -0
- package/lib/util/getRelayHandleKey.js +2 -2
- package/lib/util/getRequestIdentifier.js +2 -2
- package/lib/util/getValueAtPath.js +51 -0
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +26 -0
- package/lib/util/withDuration.js +31 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +43 -0
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +225 -0
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +506 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +261 -0
- package/multi-actor-environment/index.js.flow +26 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +32 -26
- package/mutations/RelayRecordProxy.js.flow +4 -5
- package/mutations/RelayRecordSourceMutator.js.flow +4 -6
- package/mutations/RelayRecordSourceProxy.js.flow +19 -10
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +22 -7
- package/mutations/applyOptimisticMutation.js.flow +13 -14
- package/mutations/commitLocalUpdate.js.flow +1 -1
- package/mutations/commitMutation.js.flow +35 -46
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +309 -0
- package/mutations/validateMutation.js.flow +28 -16
- package/network/ConvertToExecuteFunction.js.flow +2 -2
- package/network/RelayNetwork.js.flow +4 -5
- package/network/RelayNetworkTypes.js.flow +17 -8
- package/network/RelayObservable.js.flow +1 -1
- package/network/RelayQueryResponseCache.js.flow +34 -20
- package/network/wrapNetworkWithLogObserver.js.flow +100 -0
- package/package.json +3 -2
- package/query/GraphQLTag.js.flow +9 -9
- package/query/PreloadableQueryRegistry.js.flow +2 -1
- package/query/fetchQuery.js.flow +11 -13
- package/query/fetchQueryInternal.js.flow +6 -9
- package/query/fetchQuery_DEPRECATED.js.flow +6 -6
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +14 -3
- package/store/DataChecker.js.flow +162 -67
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +616 -283
- package/store/RelayConcreteVariables.js.flow +27 -5
- package/store/RelayModernEnvironment.js.flow +176 -235
- package/store/RelayModernFragmentSpecResolver.js.flow +55 -31
- package/store/RelayModernOperationDescriptor.js.flow +12 -7
- package/store/RelayModernRecord.js.flow +67 -11
- package/store/RelayModernSelector.js.flow +24 -14
- package/store/RelayModernStore.js.flow +72 -36
- package/store/RelayOperationTracker.js.flow +59 -43
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +79 -34
- package/store/RelayReader.js.flow +351 -72
- package/store/RelayRecordSource.js.flow +72 -6
- package/store/RelayReferenceMarker.js.flow +60 -33
- package/store/RelayResponseNormalizer.js.flow +288 -102
- package/store/RelayStoreReactFlightUtils.js.flow +9 -13
- package/store/RelayStoreSubscriptions.js.flow +19 -11
- package/store/RelayStoreTypes.js.flow +210 -44
- package/store/RelayStoreUtils.js.flow +25 -11
- package/store/ResolverCache.js.flow +249 -0
- package/store/ResolverFragments.js.flow +121 -0
- package/store/StoreInspector.js.flow +2 -2
- package/store/TypeID.js.flow +1 -1
- package/store/ViewerPattern.js.flow +2 -2
- package/store/cloneRelayHandleSourceField.js.flow +5 -6
- package/store/cloneRelayScalarHandleSourceField.js.flow +5 -6
- package/store/createFragmentSpecResolver.js.flow +3 -4
- package/store/createRelayContext.js.flow +3 -3
- package/store/defaultGetDataID.js.flow +3 -1
- package/store/normalizeRelayPayload.js.flow +6 -7
- package/store/readInlineData.js.flow +7 -8
- package/subscription/requestSubscription.js.flow +54 -27
- package/util/NormalizationNode.js.flow +16 -3
- package/util/ReaderNode.js.flow +38 -2
- package/util/RelayConcreteNode.js.flow +4 -0
- package/util/RelayFeatureFlags.js.flow +24 -8
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayReplaySubject.js.flow +9 -9
- package/util/RelayRuntimeTypes.js.flow +73 -4
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +3 -3
- package/util/deepFreeze.js.flow +2 -1
- package/util/getFragmentIdentifier.js.flow +27 -15
- package/util/getOperation.js.flow +2 -2
- package/util/getPaginationMetadata.js.flow +72 -0
- package/util/getPaginationVariables.js.flow +108 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +79 -0
- package/util/getRelayHandleKey.js.flow +1 -2
- package/util/getRequestIdentifier.js.flow +3 -3
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +2 -1
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- package/util/resolveImmediate.js.flow +1 -1
- package/util/withDuration.js.flow +32 -0
- package/lib/store/RelayRecordSourceMapImpl.js +0 -107
- package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +0 -318
- package/store/RelayRecordSourceMapImpl.js.flow +0 -91
- package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +0 -283
package/lib/store/RelayReader.js
CHANGED
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
18
18
|
|
|
19
19
|
var _require = require('../util/RelayConcreteNode'),
|
|
20
|
+
ACTOR_CHANGE = _require.ACTOR_CHANGE,
|
|
21
|
+
CLIENT_EDGE = _require.CLIENT_EDGE,
|
|
20
22
|
CLIENT_EXTENSION = _require.CLIENT_EXTENSION,
|
|
21
23
|
CONDITION = _require.CONDITION,
|
|
22
24
|
DEFER = _require.DEFER,
|
|
@@ -26,30 +28,46 @@ var _require = require('../util/RelayConcreteNode'),
|
|
|
26
28
|
INLINE_FRAGMENT = _require.INLINE_FRAGMENT,
|
|
27
29
|
LINKED_FIELD = _require.LINKED_FIELD,
|
|
28
30
|
MODULE_IMPORT = _require.MODULE_IMPORT,
|
|
31
|
+
RELAY_RESOLVER = _require.RELAY_RESOLVER,
|
|
29
32
|
REQUIRED_FIELD = _require.REQUIRED_FIELD,
|
|
30
33
|
SCALAR_FIELD = _require.SCALAR_FIELD,
|
|
31
34
|
STREAM = _require.STREAM;
|
|
32
35
|
|
|
36
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
37
|
+
|
|
38
|
+
var ClientID = require('./ClientID');
|
|
39
|
+
|
|
40
|
+
var RelayModernRecord = require('./RelayModernRecord');
|
|
41
|
+
|
|
33
42
|
var _require2 = require('./RelayStoreReactFlightUtils'),
|
|
34
43
|
getReactFlightClientResponse = _require2.getReactFlightClientResponse;
|
|
35
44
|
|
|
36
45
|
var _require3 = require('./RelayStoreUtils'),
|
|
37
|
-
|
|
46
|
+
CLIENT_EDGE_TRAVERSAL_PATH = _require3.CLIENT_EDGE_TRAVERSAL_PATH,
|
|
38
47
|
FRAGMENT_OWNER_KEY = _require3.FRAGMENT_OWNER_KEY,
|
|
39
48
|
FRAGMENT_PROP_NAME_KEY = _require3.FRAGMENT_PROP_NAME_KEY,
|
|
49
|
+
FRAGMENTS_KEY = _require3.FRAGMENTS_KEY,
|
|
40
50
|
ID_KEY = _require3.ID_KEY,
|
|
41
51
|
IS_WITHIN_UNMATCHED_TYPE_REFINEMENT = _require3.IS_WITHIN_UNMATCHED_TYPE_REFINEMENT,
|
|
42
52
|
MODULE_COMPONENT_KEY = _require3.MODULE_COMPONENT_KEY,
|
|
43
53
|
ROOT_ID = _require3.ROOT_ID,
|
|
44
54
|
getArgumentValues = _require3.getArgumentValues,
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
getModuleComponentKey = _require3.getModuleComponentKey,
|
|
56
|
+
getStorageKey = _require3.getStorageKey;
|
|
57
|
+
|
|
58
|
+
var _require4 = require('./ResolverCache'),
|
|
59
|
+
NoopResolverCache = _require4.NoopResolverCache;
|
|
60
|
+
|
|
61
|
+
var _require5 = require('./ResolverFragments'),
|
|
62
|
+
withResolverContext = _require5.withResolverContext;
|
|
63
|
+
|
|
64
|
+
var _require6 = require('./TypeID'),
|
|
65
|
+
generateTypeID = _require6.generateTypeID;
|
|
47
66
|
|
|
48
|
-
var
|
|
49
|
-
generateTypeID = _require4.generateTypeID;
|
|
67
|
+
var invariant = require('invariant');
|
|
50
68
|
|
|
51
|
-
function read(recordSource, selector) {
|
|
52
|
-
var reader = new RelayReader(recordSource, selector);
|
|
69
|
+
function read(recordSource, selector, resolverCache) {
|
|
70
|
+
var reader = new RelayReader(recordSource, selector, resolverCache !== null && resolverCache !== void 0 ? resolverCache : new NoopResolverCache());
|
|
53
71
|
return reader.read();
|
|
54
72
|
}
|
|
55
73
|
/**
|
|
@@ -58,7 +76,11 @@ function read(recordSource, selector) {
|
|
|
58
76
|
|
|
59
77
|
|
|
60
78
|
var RelayReader = /*#__PURE__*/function () {
|
|
61
|
-
function RelayReader(recordSource, selector) {
|
|
79
|
+
function RelayReader(recordSource, selector, resolverCache) {
|
|
80
|
+
var _selector$clientEdgeT;
|
|
81
|
+
|
|
82
|
+
this._clientEdgeTraversalPath = RelayFeatureFlags.ENABLE_CLIENT_EDGES && ((_selector$clientEdgeT = selector.clientEdgeTraversalPath) === null || _selector$clientEdgeT === void 0 ? void 0 : _selector$clientEdgeT.length) ? (0, _toConsumableArray2["default"])(selector.clientEdgeTraversalPath) : [];
|
|
83
|
+
this._missingClientEdges = [];
|
|
62
84
|
this._isMissingData = false;
|
|
63
85
|
this._isWithinUnmatchedTypeRefinement = false;
|
|
64
86
|
this._missingRequiredFields = null;
|
|
@@ -67,6 +89,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
67
89
|
this._seenRecords = new Set();
|
|
68
90
|
this._selector = selector;
|
|
69
91
|
this._variables = selector.variables;
|
|
92
|
+
this._resolverCache = resolverCache;
|
|
70
93
|
}
|
|
71
94
|
|
|
72
95
|
var _proto = RelayReader.prototype;
|
|
@@ -95,7 +118,15 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
95
118
|
if (isDataExpectedToBePresent && abstractKey == null && record != null) {
|
|
96
119
|
var recordType = RelayModernRecord.getType(record);
|
|
97
120
|
|
|
98
|
-
if (recordType !== node.type &&
|
|
121
|
+
if (recordType !== node.type && // The root record type is a special `__Root` type and may not match the
|
|
122
|
+
// type on the ast, so ignore type mismatches at the root.
|
|
123
|
+
// We currently detect whether we're at the root by checking against ROOT_ID,
|
|
124
|
+
// but this does not work for mutations/subscriptions which generate unique
|
|
125
|
+
// root ids. This is acceptable in practice as we don't read data for mutations/
|
|
126
|
+
// subscriptions in a situation where we would use isMissingData to decide whether
|
|
127
|
+
// to suspend or not.
|
|
128
|
+
// TODO T96653810: Correctly detect reading from root of mutation/subscription
|
|
129
|
+
dataID !== ROOT_ID) {
|
|
99
130
|
isDataExpectedToBePresent = false;
|
|
100
131
|
}
|
|
101
132
|
} // If this is an abstract fragment (and the precise refinement GK is enabled)
|
|
@@ -104,7 +135,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
104
135
|
// the interface, that itself constitutes "expected" data being missing.
|
|
105
136
|
|
|
106
137
|
|
|
107
|
-
if (isDataExpectedToBePresent && abstractKey != null && record != null
|
|
138
|
+
if (isDataExpectedToBePresent && abstractKey != null && record != null) {
|
|
108
139
|
var _recordType = RelayModernRecord.getType(record);
|
|
109
140
|
|
|
110
141
|
var typeID = generateTypeID(_recordType);
|
|
@@ -129,12 +160,30 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
129
160
|
return {
|
|
130
161
|
data: data,
|
|
131
162
|
isMissingData: this._isMissingData && isDataExpectedToBePresent,
|
|
163
|
+
missingClientEdges: RelayFeatureFlags.ENABLE_CLIENT_EDGES && this._missingClientEdges.length ? this._missingClientEdges : null,
|
|
132
164
|
seenRecords: this._seenRecords,
|
|
133
165
|
selector: this._selector,
|
|
134
166
|
missingRequiredFields: this._missingRequiredFields
|
|
135
167
|
};
|
|
136
168
|
};
|
|
137
169
|
|
|
170
|
+
_proto._markDataAsMissing = function _markDataAsMissing() {
|
|
171
|
+
this._isMissingData = true;
|
|
172
|
+
|
|
173
|
+
if (RelayFeatureFlags.ENABLE_CLIENT_EDGES && this._clientEdgeTraversalPath.length) {
|
|
174
|
+
var top = this._clientEdgeTraversalPath[this._clientEdgeTraversalPath.length - 1]; // Top can be null if we've traversed past a client edge into an ordinary
|
|
175
|
+
// client extension field; we never want to fetch in response to missing
|
|
176
|
+
// data off of a client extension field.
|
|
177
|
+
|
|
178
|
+
if (top !== null) {
|
|
179
|
+
this._missingClientEdges.push({
|
|
180
|
+
request: top.readerClientEdge.operation,
|
|
181
|
+
clientEdgeDestinationID: top.clientEdgeDestinationID
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
138
187
|
_proto._traverse = function _traverse(node, dataID, prevData) {
|
|
139
188
|
var record = this._recordSource.get(dataID);
|
|
140
189
|
|
|
@@ -142,7 +191,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
142
191
|
|
|
143
192
|
if (record == null) {
|
|
144
193
|
if (record === undefined) {
|
|
145
|
-
this.
|
|
194
|
+
this._markDataAsMissing();
|
|
146
195
|
}
|
|
147
196
|
|
|
148
197
|
return record;
|
|
@@ -245,7 +294,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
245
294
|
break;
|
|
246
295
|
|
|
247
296
|
case CONDITION:
|
|
248
|
-
var conditionValue = this._getVariableValue(selection.condition);
|
|
297
|
+
var conditionValue = Boolean(this._getVariableValue(selection.condition));
|
|
249
298
|
|
|
250
299
|
if (conditionValue === selection.passingValue) {
|
|
251
300
|
var hasExpectedData = this._traverseSelections(selection.selections, record, data);
|
|
@@ -272,7 +321,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
272
321
|
return false;
|
|
273
322
|
}
|
|
274
323
|
}
|
|
275
|
-
} else
|
|
324
|
+
} else {
|
|
276
325
|
// Similar to the logic in read(): data is only expected to be present
|
|
277
326
|
// if the record is known to conform to the interface. If we don't know
|
|
278
327
|
// whether the type conforms or not, that constitutes missing data.
|
|
@@ -298,17 +347,24 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
298
347
|
this._isMissingData = parentIsMissingData;
|
|
299
348
|
} else if (implementsInterface == null) {
|
|
300
349
|
// Don't know if the type implements the interface or not
|
|
301
|
-
this.
|
|
350
|
+
this._markDataAsMissing();
|
|
302
351
|
}
|
|
303
|
-
} else {
|
|
304
|
-
// legacy behavior for abstract refinements: always read even
|
|
305
|
-
// if the type doesn't conform and don't reset isMissingData
|
|
306
|
-
this._traverseSelections(selection.selections, record, data);
|
|
307
352
|
}
|
|
308
353
|
|
|
309
354
|
break;
|
|
310
355
|
}
|
|
311
356
|
|
|
357
|
+
case RELAY_RESOLVER:
|
|
358
|
+
{
|
|
359
|
+
if (!RelayFeatureFlags.ENABLE_RELAY_RESOLVERS) {
|
|
360
|
+
throw new Error('Relay Resolver fields are not yet supported.');
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
this._readResolverField(selection, record, data);
|
|
364
|
+
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
|
|
312
368
|
case FRAGMENT_SPREAD:
|
|
313
369
|
this._createFragmentPointer(selection, record, data);
|
|
314
370
|
|
|
@@ -320,7 +376,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
320
376
|
break;
|
|
321
377
|
|
|
322
378
|
case INLINE_DATA_FRAGMENT_SPREAD:
|
|
323
|
-
this.
|
|
379
|
+
this._createInlineDataOrResolverFragmentPointer(selection, record, data);
|
|
324
380
|
|
|
325
381
|
break;
|
|
326
382
|
|
|
@@ -328,10 +384,22 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
328
384
|
case CLIENT_EXTENSION:
|
|
329
385
|
{
|
|
330
386
|
var isMissingData = this._isMissingData;
|
|
387
|
+
var alreadyMissingClientEdges = this._missingClientEdges.length;
|
|
331
388
|
|
|
332
|
-
|
|
389
|
+
if (RelayFeatureFlags.ENABLE_CLIENT_EDGES) {
|
|
390
|
+
this._clientEdgeTraversalPath.push(null);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var _hasExpectedData2 = this._traverseSelections(selection.selections, record, data); // The only case where we want to suspend due to missing data off of
|
|
394
|
+
// a client extension is if we reached a client edge that we might be
|
|
395
|
+
// able to fetch:
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
this._isMissingData = isMissingData || this._missingClientEdges.length > alreadyMissingClientEdges;
|
|
333
399
|
|
|
334
|
-
|
|
400
|
+
if (RelayFeatureFlags.ENABLE_CLIENT_EDGES) {
|
|
401
|
+
this._clientEdgeTraversalPath.pop();
|
|
402
|
+
}
|
|
335
403
|
|
|
336
404
|
if (!_hasExpectedData2) {
|
|
337
405
|
return false;
|
|
@@ -360,6 +428,20 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
360
428
|
|
|
361
429
|
break;
|
|
362
430
|
|
|
431
|
+
case ACTOR_CHANGE:
|
|
432
|
+
this._readActorChange(selection, record, data);
|
|
433
|
+
|
|
434
|
+
break;
|
|
435
|
+
|
|
436
|
+
case CLIENT_EDGE:
|
|
437
|
+
if (RelayFeatureFlags.ENABLE_CLIENT_EDGES) {
|
|
438
|
+
this._readClientEdge(selection, record, data);
|
|
439
|
+
} else {
|
|
440
|
+
throw new Error('Client edges are not yet supported.');
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
break;
|
|
444
|
+
|
|
363
445
|
default:
|
|
364
446
|
selection;
|
|
365
447
|
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Unexpected ast kind `%s`.', selection.kind) : invariant(false) : void 0;
|
|
@@ -381,16 +463,140 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
381
463
|
return this._readLink(selection.field, record, data);
|
|
382
464
|
}
|
|
383
465
|
|
|
466
|
+
case RELAY_RESOLVER:
|
|
467
|
+
if (!RelayFeatureFlags.ENABLE_RELAY_RESOLVERS) {
|
|
468
|
+
throw new Error('Relay Resolver fields are not yet supported.');
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
this._readResolverField(selection.field, record, data);
|
|
472
|
+
|
|
473
|
+
break;
|
|
474
|
+
|
|
384
475
|
default:
|
|
385
476
|
selection.field.kind;
|
|
386
477
|
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Unexpected ast kind `%s`.', selection.kind) : invariant(false) : void 0;
|
|
387
478
|
}
|
|
388
479
|
};
|
|
389
480
|
|
|
390
|
-
_proto.
|
|
481
|
+
_proto._readResolverField = function _readResolverField(field, record, data) {
|
|
482
|
+
var _this = this;
|
|
483
|
+
|
|
391
484
|
var _field$alias;
|
|
392
485
|
|
|
486
|
+
var resolverModule = field.resolverModule,
|
|
487
|
+
fragment = field.fragment;
|
|
488
|
+
var storageKey = getStorageKey(field, this._variables);
|
|
489
|
+
var resolverID = ClientID.generateClientID(RelayModernRecord.getDataID(record), storageKey); // Found when reading the resolver fragment, which can happen either when
|
|
490
|
+
// evaluating the resolver and it calls readFragment, or when checking if the
|
|
491
|
+
// inputs have changed since a previous evaluation:
|
|
492
|
+
|
|
493
|
+
var fragmentValue;
|
|
494
|
+
var fragmentReaderSelector;
|
|
495
|
+
var fragmentSeenRecordIDs = new Set();
|
|
496
|
+
|
|
497
|
+
var getDataForResolverFragment = function getDataForResolverFragment(singularReaderSelector) {
|
|
498
|
+
if (fragmentValue != null) {
|
|
499
|
+
// It was already read when checking for input staleness; no need to read it again.
|
|
500
|
+
// Note that the variables like fragmentSeenRecordIDs in the outer closure will have
|
|
501
|
+
// already been set and will still be used in this case.
|
|
502
|
+
return fragmentValue;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
fragmentReaderSelector = singularReaderSelector;
|
|
506
|
+
var existingSeenRecords = _this._seenRecords;
|
|
507
|
+
|
|
508
|
+
try {
|
|
509
|
+
var _resolverFragmentData;
|
|
510
|
+
|
|
511
|
+
_this._seenRecords = fragmentSeenRecordIDs;
|
|
512
|
+
var resolverFragmentData = {};
|
|
513
|
+
|
|
514
|
+
_this._createInlineDataOrResolverFragmentPointer(singularReaderSelector.node, record, resolverFragmentData);
|
|
515
|
+
|
|
516
|
+
fragmentValue = (_resolverFragmentData = resolverFragmentData[FRAGMENTS_KEY]) === null || _resolverFragmentData === void 0 ? void 0 : _resolverFragmentData[fragment.name];
|
|
517
|
+
!(typeof fragmentValue === 'object' && fragmentValue !== null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected reader data to contain a __fragments property with a property for the fragment named ".concat(fragment.name, ", but it is missing.")) : invariant(false) : void 0;
|
|
518
|
+
return fragmentValue;
|
|
519
|
+
} finally {
|
|
520
|
+
_this._seenRecords = existingSeenRecords;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
var resolverContext = {
|
|
525
|
+
getDataForResolverFragment: getDataForResolverFragment
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
var _this$_resolverCache$ = this._resolverCache.readFromCacheOrEvaluate(record, field, this._variables, function () {
|
|
529
|
+
var key = {
|
|
530
|
+
__id: RelayModernRecord.getDataID(record),
|
|
531
|
+
__fragmentOwner: _this._owner,
|
|
532
|
+
__fragments: (0, _defineProperty2["default"])({}, fragment.name, {})
|
|
533
|
+
};
|
|
534
|
+
return withResolverContext(resolverContext, function () {
|
|
535
|
+
// $FlowFixMe[prop-missing] - resolver module's type signature is a lie
|
|
536
|
+
var resolverResult = resolverModule(key);
|
|
537
|
+
return {
|
|
538
|
+
resolverResult: resolverResult,
|
|
539
|
+
fragmentValue: fragmentValue,
|
|
540
|
+
resolverID: resolverID,
|
|
541
|
+
seenRecordIDs: fragmentSeenRecordIDs,
|
|
542
|
+
readerSelector: fragmentReaderSelector
|
|
543
|
+
};
|
|
544
|
+
});
|
|
545
|
+
}, getDataForResolverFragment),
|
|
546
|
+
result = _this$_resolverCache$[0],
|
|
547
|
+
seenRecord = _this$_resolverCache$[1];
|
|
548
|
+
|
|
549
|
+
if (seenRecord != null) {
|
|
550
|
+
this._seenRecords.add(seenRecord);
|
|
551
|
+
}
|
|
552
|
+
|
|
393
553
|
var applicationName = (_field$alias = field.alias) !== null && _field$alias !== void 0 ? _field$alias : field.name;
|
|
554
|
+
data[applicationName] = result;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
_proto._readClientEdge = function _readClientEdge(field, record, data) {
|
|
558
|
+
var _backingField$alias;
|
|
559
|
+
|
|
560
|
+
var backingField = field.backingField; // Because ReaderClientExtension doesn't have `alias` or `name` and so I don't know
|
|
561
|
+
// how to get its applicationName or storageKey yet:
|
|
562
|
+
|
|
563
|
+
!(backingField.kind !== 'ClientExtension') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Client extension client edges are not yet implemented.') : invariant(false) : void 0;
|
|
564
|
+
var applicationName = (_backingField$alias = backingField.alias) !== null && _backingField$alias !== void 0 ? _backingField$alias : backingField.name;
|
|
565
|
+
var backingFieldData = {};
|
|
566
|
+
|
|
567
|
+
this._traverseSelections([backingField], record, backingFieldData);
|
|
568
|
+
|
|
569
|
+
var destinationDataID = backingFieldData[applicationName];
|
|
570
|
+
|
|
571
|
+
if (destinationDataID == null) {
|
|
572
|
+
data[applicationName] = destinationDataID;
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
!(typeof destinationDataID === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Plural client edges not are yet implemented') : invariant(false) : void 0; // FIXME support plural
|
|
577
|
+
// Not wrapping the push/pop in a try/finally because if we throw, the
|
|
578
|
+
// Reader object is not usable after that anyway.
|
|
579
|
+
|
|
580
|
+
this._clientEdgeTraversalPath.push({
|
|
581
|
+
readerClientEdge: field,
|
|
582
|
+
clientEdgeDestinationID: destinationDataID
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
var prevData = data[applicationName];
|
|
586
|
+
!(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;
|
|
587
|
+
|
|
588
|
+
var value = this._traverse(field.linkedField, destinationDataID, // $FlowFixMe[incompatible-variance]
|
|
589
|
+
prevData);
|
|
590
|
+
|
|
591
|
+
data[applicationName] = value;
|
|
592
|
+
|
|
593
|
+
this._clientEdgeTraversalPath.pop();
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
_proto._readFlightField = function _readFlightField(field, record, data) {
|
|
597
|
+
var _field$alias2;
|
|
598
|
+
|
|
599
|
+
var applicationName = (_field$alias2 = field.alias) !== null && _field$alias2 !== void 0 ? _field$alias2 : field.name;
|
|
394
600
|
var storageKey = getStorageKey(field, this._variables);
|
|
395
601
|
var reactFlightClientResponseRecordID = RelayModernRecord.getLinkedRecordID(record, storageKey);
|
|
396
602
|
|
|
@@ -398,7 +604,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
398
604
|
data[applicationName] = reactFlightClientResponseRecordID;
|
|
399
605
|
|
|
400
606
|
if (reactFlightClientResponseRecordID === undefined) {
|
|
401
|
-
this.
|
|
607
|
+
this._markDataAsMissing();
|
|
402
608
|
}
|
|
403
609
|
|
|
404
610
|
return reactFlightClientResponseRecordID;
|
|
@@ -412,7 +618,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
412
618
|
data[applicationName] = reactFlightClientResponseRecord;
|
|
413
619
|
|
|
414
620
|
if (reactFlightClientResponseRecord === undefined) {
|
|
415
|
-
this.
|
|
621
|
+
this._markDataAsMissing();
|
|
416
622
|
}
|
|
417
623
|
|
|
418
624
|
return reactFlightClientResponseRecord;
|
|
@@ -424,14 +630,14 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
424
630
|
};
|
|
425
631
|
|
|
426
632
|
_proto._readScalar = function _readScalar(field, record, data) {
|
|
427
|
-
var _field$
|
|
633
|
+
var _field$alias3;
|
|
428
634
|
|
|
429
|
-
var applicationName = (_field$
|
|
635
|
+
var applicationName = (_field$alias3 = field.alias) !== null && _field$alias3 !== void 0 ? _field$alias3 : field.name;
|
|
430
636
|
var storageKey = getStorageKey(field, this._variables);
|
|
431
637
|
var value = RelayModernRecord.getValue(record, storageKey);
|
|
432
638
|
|
|
433
639
|
if (value === undefined) {
|
|
434
|
-
this.
|
|
640
|
+
this._markDataAsMissing();
|
|
435
641
|
}
|
|
436
642
|
|
|
437
643
|
data[applicationName] = value;
|
|
@@ -439,9 +645,9 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
439
645
|
};
|
|
440
646
|
|
|
441
647
|
_proto._readLink = function _readLink(field, record, data) {
|
|
442
|
-
var _field$
|
|
648
|
+
var _field$alias4;
|
|
443
649
|
|
|
444
|
-
var applicationName = (_field$
|
|
650
|
+
var applicationName = (_field$alias4 = field.alias) !== null && _field$alias4 !== void 0 ? _field$alias4 : field.name;
|
|
445
651
|
var storageKey = getStorageKey(field, this._variables);
|
|
446
652
|
var linkedID = RelayModernRecord.getLinkedRecordID(record, storageKey);
|
|
447
653
|
|
|
@@ -449,7 +655,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
449
655
|
data[applicationName] = linkedID;
|
|
450
656
|
|
|
451
657
|
if (linkedID === undefined) {
|
|
452
|
-
this.
|
|
658
|
+
this._markDataAsMissing();
|
|
453
659
|
}
|
|
454
660
|
|
|
455
661
|
return linkedID;
|
|
@@ -464,12 +670,44 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
464
670
|
return value;
|
|
465
671
|
};
|
|
466
672
|
|
|
673
|
+
_proto._readActorChange = function _readActorChange(field, record, data) {
|
|
674
|
+
var _field$alias5;
|
|
675
|
+
|
|
676
|
+
var applicationName = (_field$alias5 = field.alias) !== null && _field$alias5 !== void 0 ? _field$alias5 : field.name;
|
|
677
|
+
var storageKey = getStorageKey(field, this._variables);
|
|
678
|
+
var externalRef = RelayModernRecord.getActorLinkedRecordID(record, storageKey);
|
|
679
|
+
|
|
680
|
+
if (externalRef == null) {
|
|
681
|
+
data[applicationName] = externalRef;
|
|
682
|
+
|
|
683
|
+
if (externalRef === undefined) {
|
|
684
|
+
this._markDataAsMissing();
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
return data[applicationName];
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
var actorIdentifier = externalRef[0],
|
|
691
|
+
dataID = externalRef[1];
|
|
692
|
+
var fragmentRef = {};
|
|
693
|
+
|
|
694
|
+
this._createFragmentPointer(field.fragmentSpread, {
|
|
695
|
+
__id: dataID
|
|
696
|
+
}, fragmentRef);
|
|
697
|
+
|
|
698
|
+
data[applicationName] = {
|
|
699
|
+
__fragmentRef: fragmentRef,
|
|
700
|
+
__viewer: actorIdentifier
|
|
701
|
+
};
|
|
702
|
+
return data[applicationName];
|
|
703
|
+
};
|
|
704
|
+
|
|
467
705
|
_proto._readPluralLink = function _readPluralLink(field, record, data) {
|
|
468
|
-
var
|
|
706
|
+
var _this2 = this;
|
|
469
707
|
|
|
470
|
-
var _field$
|
|
708
|
+
var _field$alias6;
|
|
471
709
|
|
|
472
|
-
var applicationName = (_field$
|
|
710
|
+
var applicationName = (_field$alias6 = field.alias) !== null && _field$alias6 !== void 0 ? _field$alias6 : field.name;
|
|
473
711
|
var storageKey = getStorageKey(field, this._variables);
|
|
474
712
|
var linkedIDs = RelayModernRecord.getLinkedRecordIDs(record, storageKey);
|
|
475
713
|
|
|
@@ -477,7 +715,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
477
715
|
data[applicationName] = linkedIDs;
|
|
478
716
|
|
|
479
717
|
if (linkedIDs === undefined) {
|
|
480
|
-
this.
|
|
718
|
+
this._markDataAsMissing();
|
|
481
719
|
}
|
|
482
720
|
|
|
483
721
|
return linkedIDs;
|
|
@@ -489,7 +727,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
489
727
|
linkedIDs.forEach(function (linkedID, nextIndex) {
|
|
490
728
|
if (linkedID == null) {
|
|
491
729
|
if (linkedID === undefined) {
|
|
492
|
-
|
|
730
|
+
_this2._markDataAsMissing();
|
|
493
731
|
} // $FlowFixMe[cannot-write]
|
|
494
732
|
|
|
495
733
|
|
|
@@ -501,7 +739,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
501
739
|
!(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]
|
|
502
740
|
// $FlowFixMe[incompatible-variance]
|
|
503
741
|
|
|
504
|
-
linkedArray[nextIndex] =
|
|
742
|
+
linkedArray[nextIndex] = _this2._traverse(field, linkedID, prevItem);
|
|
505
743
|
});
|
|
506
744
|
data[applicationName] = linkedArray;
|
|
507
745
|
return linkedArray;
|
|
@@ -520,7 +758,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
520
758
|
|
|
521
759
|
if (component == null) {
|
|
522
760
|
if (component === undefined) {
|
|
523
|
-
this.
|
|
761
|
+
this._markDataAsMissing();
|
|
524
762
|
}
|
|
525
763
|
|
|
526
764
|
return;
|
|
@@ -534,7 +772,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
534
772
|
this._createFragmentPointer({
|
|
535
773
|
kind: 'FragmentSpread',
|
|
536
774
|
name: moduleImport.fragmentName,
|
|
537
|
-
args:
|
|
775
|
+
args: moduleImport.args
|
|
538
776
|
}, record, data);
|
|
539
777
|
|
|
540
778
|
data[FRAGMENT_PROP_NAME_KEY] = moduleImport.fragmentPropName;
|
|
@@ -557,13 +795,16 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
557
795
|
|
|
558
796
|
fragmentPointers[fragmentSpread.name] = fragmentSpread.args ? getArgumentValues(fragmentSpread.args, this._variables) : {};
|
|
559
797
|
data[FRAGMENT_OWNER_KEY] = this._owner;
|
|
798
|
+
data[IS_WITHIN_UNMATCHED_TYPE_REFINEMENT] = this._isWithinUnmatchedTypeRefinement;
|
|
560
799
|
|
|
561
|
-
if (RelayFeatureFlags.
|
|
562
|
-
|
|
800
|
+
if (RelayFeatureFlags.ENABLE_CLIENT_EDGES) {
|
|
801
|
+
if (this._clientEdgeTraversalPath.length > 0 && this._clientEdgeTraversalPath[this._clientEdgeTraversalPath.length - 1] !== null) {
|
|
802
|
+
data[CLIENT_EDGE_TRAVERSAL_PATH] = (0, _toConsumableArray2["default"])(this._clientEdgeTraversalPath);
|
|
803
|
+
}
|
|
563
804
|
}
|
|
564
805
|
};
|
|
565
806
|
|
|
566
|
-
_proto.
|
|
807
|
+
_proto._createInlineDataOrResolverFragmentPointer = function _createInlineDataOrResolverFragmentPointer(fragmentSpreadOrFragment, record, data) {
|
|
567
808
|
var fragmentPointers = data[FRAGMENTS_KEY];
|
|
568
809
|
|
|
569
810
|
if (fragmentPointers == null) {
|
|
@@ -578,10 +819,10 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
578
819
|
|
|
579
820
|
var inlineData = {};
|
|
580
821
|
|
|
581
|
-
this._traverseSelections(
|
|
822
|
+
this._traverseSelections(fragmentSpreadOrFragment.selections, record, inlineData); // $FlowFixMe[cannot-write] - writing into read-only field
|
|
582
823
|
|
|
583
824
|
|
|
584
|
-
fragmentPointers[
|
|
825
|
+
fragmentPointers[fragmentSpreadOrFragment.name] = inlineData;
|
|
585
826
|
};
|
|
586
827
|
|
|
587
828
|
return RelayReader;
|
|
@@ -10,15 +10,99 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
|
+
|
|
15
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
16
|
+
|
|
17
|
+
var RelayRecordState = require('./RelayRecordState');
|
|
18
|
+
|
|
19
|
+
var EXISTENT = RelayRecordState.EXISTENT,
|
|
20
|
+
NONEXISTENT = RelayRecordState.NONEXISTENT,
|
|
21
|
+
UNKNOWN = RelayRecordState.UNKNOWN;
|
|
22
|
+
/**
|
|
23
|
+
* An implementation of the `MutableRecordSource` interface (defined in
|
|
24
|
+
* `RelayStoreTypes`) that holds all records in memory (JS Map).
|
|
25
|
+
*/
|
|
14
26
|
|
|
15
27
|
var RelayRecordSource = /*#__PURE__*/function () {
|
|
16
28
|
function RelayRecordSource(records) {
|
|
17
|
-
|
|
29
|
+
var _this = this;
|
|
30
|
+
|
|
31
|
+
this._records = new Map();
|
|
32
|
+
|
|
33
|
+
if (records != null) {
|
|
34
|
+
Object.keys(records).forEach(function (key) {
|
|
35
|
+
_this._records.set(key, records[key]);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
18
38
|
}
|
|
19
39
|
|
|
20
40
|
RelayRecordSource.create = function create(records) {
|
|
21
|
-
return new
|
|
41
|
+
return new RelayRecordSource(records);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var _proto = RelayRecordSource.prototype;
|
|
45
|
+
|
|
46
|
+
_proto.clear = function clear() {
|
|
47
|
+
this._records = new Map();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
_proto["delete"] = function _delete(dataID) {
|
|
51
|
+
this._records.set(dataID, null);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
_proto.get = function get(dataID) {
|
|
55
|
+
return this._records.get(dataID);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
_proto.getRecordIDs = function getRecordIDs() {
|
|
59
|
+
return Array.from(this._records.keys());
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
_proto.getStatus = function getStatus(dataID) {
|
|
63
|
+
if (!this._records.has(dataID)) {
|
|
64
|
+
return UNKNOWN;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this._records.get(dataID) == null ? NONEXISTENT : EXISTENT;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
_proto.has = function has(dataID) {
|
|
71
|
+
return this._records.has(dataID);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
_proto.remove = function remove(dataID) {
|
|
75
|
+
this._records["delete"](dataID);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
_proto.set = function set(dataID, record) {
|
|
79
|
+
this._records.set(dataID, record);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_proto.size = function size() {
|
|
83
|
+
return this._records.size;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
_proto.toJSON = function toJSON() {
|
|
87
|
+
var obj = {};
|
|
88
|
+
|
|
89
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(this._records),
|
|
90
|
+
_step;
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
94
|
+
var _step$value = _step.value,
|
|
95
|
+
key = _step$value[0],
|
|
96
|
+
value = _step$value[1];
|
|
97
|
+
obj[key] = value;
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_iterator.e(err);
|
|
101
|
+
} finally {
|
|
102
|
+
_iterator.f();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return obj;
|
|
22
106
|
};
|
|
23
107
|
|
|
24
108
|
return RelayRecordSource;
|