relay-runtime 11.0.2 → 13.0.0-rc.2

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.
Files changed (219) hide show
  1. package/README.md +67 -0
  2. package/handlers/RelayDefaultHandlerProvider.js.flow +3 -3
  3. package/handlers/connection/ConnectionHandler.js.flow +9 -18
  4. package/handlers/connection/ConnectionInterface.js.flow +1 -1
  5. package/handlers/connection/MutationHandlers.js.flow +8 -12
  6. package/index.js +1 -1
  7. package/index.js.flow +57 -35
  8. package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
  9. package/lib/handlers/connection/ConnectionHandler.js +13 -19
  10. package/lib/handlers/connection/ConnectionInterface.js +1 -1
  11. package/lib/handlers/connection/MutationHandlers.js +4 -7
  12. package/lib/index.js +59 -44
  13. package/lib/multi-actor-environment/ActorIdentifier.js +12 -2
  14. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +64 -20
  15. package/lib/multi-actor-environment/ActorUtils.js +27 -0
  16. package/lib/multi-actor-environment/MultiActorEnvironment.js +324 -61
  17. package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
  18. package/lib/multi-actor-environment/index.js +6 -2
  19. package/lib/mutations/RelayDeclarativeMutationConfig.js +5 -2
  20. package/lib/mutations/RelayRecordProxy.js +4 -3
  21. package/lib/mutations/RelayRecordSourceMutator.js +4 -3
  22. package/lib/mutations/RelayRecordSourceProxy.js +13 -5
  23. package/lib/mutations/RelayRecordSourceSelectorProxy.js +19 -6
  24. package/lib/mutations/applyOptimisticMutation.js +7 -7
  25. package/lib/mutations/commitLocalUpdate.js +1 -1
  26. package/lib/mutations/commitMutation.js +15 -11
  27. package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +242 -0
  28. package/lib/mutations/validateMutation.js +11 -6
  29. package/lib/network/ConvertToExecuteFunction.js +3 -2
  30. package/lib/network/RelayNetwork.js +4 -3
  31. package/lib/network/RelayNetworkTypes.js +1 -1
  32. package/lib/network/RelayObservable.js +1 -1
  33. package/lib/network/RelayQueryResponseCache.js +22 -6
  34. package/lib/network/wrapNetworkWithLogObserver.js +79 -0
  35. package/lib/query/GraphQLTag.js +3 -2
  36. package/lib/query/PreloadableQueryRegistry.js +1 -1
  37. package/lib/query/fetchQuery.js +7 -6
  38. package/lib/query/fetchQueryInternal.js +1 -1
  39. package/lib/query/fetchQuery_DEPRECATED.js +3 -2
  40. package/lib/store/ClientID.js +8 -2
  41. package/lib/store/DataChecker.js +124 -55
  42. package/lib/store/OperationExecutor.js +489 -215
  43. package/lib/store/RelayConcreteVariables.js +27 -9
  44. package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
  45. package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
  46. package/lib/store/RelayModernEnvironment.js +100 -120
  47. package/lib/store/RelayModernFragmentSpecResolver.js +53 -27
  48. package/lib/store/RelayModernOperationDescriptor.js +3 -2
  49. package/lib/store/RelayModernRecord.js +48 -13
  50. package/lib/store/RelayModernSelector.js +15 -9
  51. package/lib/store/RelayModernStore.js +56 -23
  52. package/lib/store/RelayOperationTracker.js +34 -24
  53. package/lib/store/RelayOptimisticRecordSource.js +1 -1
  54. package/lib/store/RelayPublishQueue.js +35 -11
  55. package/lib/store/RelayReader.js +257 -72
  56. package/lib/store/RelayRecordSource.js +88 -4
  57. package/lib/store/RelayRecordState.js +1 -1
  58. package/lib/store/RelayReferenceMarker.js +34 -22
  59. package/lib/store/RelayResponseNormalizer.js +172 -96
  60. package/lib/store/RelayStoreReactFlightUtils.js +5 -11
  61. package/lib/store/RelayStoreSubscriptions.js +15 -10
  62. package/lib/store/RelayStoreTypes.js +1 -1
  63. package/lib/store/RelayStoreUtils.js +13 -8
  64. package/lib/store/ResolverCache.js +213 -0
  65. package/lib/store/ResolverFragments.js +10 -6
  66. package/lib/store/StoreInspector.js +1 -1
  67. package/lib/store/TypeID.js +1 -1
  68. package/lib/store/ViewerPattern.js +1 -1
  69. package/lib/store/cloneRelayHandleSourceField.js +6 -5
  70. package/lib/store/cloneRelayScalarHandleSourceField.js +6 -5
  71. package/lib/store/createFragmentSpecResolver.js +1 -1
  72. package/lib/store/createRelayContext.js +5 -3
  73. package/lib/store/defaultGetDataID.js +1 -1
  74. package/lib/store/defaultRequiredFieldLogger.js +1 -1
  75. package/lib/store/hasOverlappingIDs.js +1 -1
  76. package/lib/store/isRelayModernEnvironment.js +1 -1
  77. package/lib/store/normalizeRelayPayload.js +1 -1
  78. package/lib/store/readInlineData.js +7 -3
  79. package/lib/subscription/requestSubscription.js +32 -34
  80. package/lib/util/JSResourceTypes.flow.js +1 -1
  81. package/lib/util/NormalizationNode.js +1 -1
  82. package/lib/util/ReaderNode.js +1 -1
  83. package/lib/util/RelayConcreteNode.js +3 -1
  84. package/lib/util/RelayDefaultHandleKey.js +1 -1
  85. package/lib/util/RelayError.js +1 -1
  86. package/lib/util/RelayFeatureFlags.js +10 -7
  87. package/lib/util/RelayProfiler.js +1 -1
  88. package/lib/util/RelayReplaySubject.js +22 -7
  89. package/lib/util/RelayRuntimeTypes.js +1 -7
  90. package/lib/util/StringInterner.js +71 -0
  91. package/lib/util/createPayloadFor3DField.js +1 -1
  92. package/lib/util/deepFreeze.js +1 -1
  93. package/lib/util/generateID.js +1 -1
  94. package/lib/util/getAllRootVariables.js +29 -0
  95. package/lib/util/getFragmentIdentifier.js +16 -8
  96. package/lib/util/getOperation.js +3 -2
  97. package/lib/util/getPaginationMetadata.js +41 -0
  98. package/lib/util/getPaginationVariables.js +66 -0
  99. package/lib/util/getPendingOperationsForFragment.js +55 -0
  100. package/lib/util/getRefetchMetadata.js +36 -0
  101. package/lib/util/getRelayHandleKey.js +3 -3
  102. package/lib/util/getRequestIdentifier.js +3 -3
  103. package/lib/util/getValueAtPath.js +51 -0
  104. package/lib/util/isEmptyObject.js +2 -2
  105. package/lib/util/isPromise.js +1 -1
  106. package/lib/util/isScalarAndEqual.js +1 -1
  107. package/lib/util/recycleNodesInto.js +1 -1
  108. package/lib/util/registerEnvironmentWithDevTools.js +26 -0
  109. package/lib/util/reportMissingRequiredFields.js +1 -1
  110. package/lib/util/resolveImmediate.js +1 -1
  111. package/lib/util/stableCopy.js +1 -1
  112. package/lib/util/withDuration.js +31 -0
  113. package/multi-actor-environment/ActorIdentifier.js.flow +18 -2
  114. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +94 -58
  115. package/multi-actor-environment/ActorUtils.js.flow +33 -0
  116. package/multi-actor-environment/MultiActorEnvironment.js.flow +366 -93
  117. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +88 -23
  118. package/multi-actor-environment/index.js.flow +3 -1
  119. package/mutations/RelayDeclarativeMutationConfig.js.flow +33 -27
  120. package/mutations/RelayRecordProxy.js.flow +5 -6
  121. package/mutations/RelayRecordSourceMutator.js.flow +5 -7
  122. package/mutations/RelayRecordSourceProxy.js.flow +20 -11
  123. package/mutations/RelayRecordSourceSelectorProxy.js.flow +23 -8
  124. package/mutations/applyOptimisticMutation.js.flow +14 -15
  125. package/mutations/commitLocalUpdate.js.flow +2 -2
  126. package/mutations/commitMutation.js.flow +36 -47
  127. package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +318 -0
  128. package/mutations/validateMutation.js.flow +27 -17
  129. package/network/ConvertToExecuteFunction.js.flow +3 -3
  130. package/network/RelayNetwork.js.flow +5 -6
  131. package/network/RelayNetworkTypes.js.flow +1 -1
  132. package/network/RelayObservable.js.flow +2 -2
  133. package/network/RelayQueryResponseCache.js.flow +35 -22
  134. package/network/wrapNetworkWithLogObserver.js.flow +99 -0
  135. package/package.json +2 -2
  136. package/query/GraphQLTag.js.flow +11 -11
  137. package/query/PreloadableQueryRegistry.js.flow +5 -3
  138. package/query/fetchQuery.js.flow +19 -19
  139. package/query/fetchQueryInternal.js.flow +7 -10
  140. package/query/fetchQuery_DEPRECATED.js.flow +7 -7
  141. package/relay-runtime.js +2 -2
  142. package/relay-runtime.min.js +2 -2
  143. package/store/ClientID.js.flow +15 -4
  144. package/store/DataChecker.js.flow +142 -60
  145. package/store/OperationExecutor.js.flow +575 -320
  146. package/store/RelayConcreteVariables.js.flow +28 -9
  147. package/store/RelayExperimentalGraphResponseHandler.js.flow +121 -0
  148. package/store/RelayExperimentalGraphResponseTransform.js.flow +470 -0
  149. package/store/RelayModernEnvironment.js.flow +91 -115
  150. package/store/RelayModernFragmentSpecResolver.js.flow +56 -32
  151. package/store/RelayModernOperationDescriptor.js.flow +13 -8
  152. package/store/RelayModernRecord.js.flow +68 -12
  153. package/store/RelayModernSelector.js.flow +25 -15
  154. package/store/RelayModernStore.js.flow +67 -32
  155. package/store/RelayOperationTracker.js.flow +60 -44
  156. package/store/RelayOptimisticRecordSource.js.flow +3 -3
  157. package/store/RelayPublishQueue.js.flow +74 -32
  158. package/store/RelayReader.js.flow +319 -100
  159. package/store/RelayRecordSource.js.flow +73 -7
  160. package/store/RelayRecordState.js.flow +1 -1
  161. package/store/RelayReferenceMarker.js.flow +41 -27
  162. package/store/RelayResponseNormalizer.js.flow +204 -86
  163. package/store/RelayStoreReactFlightUtils.js.flow +5 -12
  164. package/store/RelayStoreSubscriptions.js.flow +20 -12
  165. package/store/RelayStoreTypes.js.flow +200 -41
  166. package/store/RelayStoreUtils.js.flow +25 -12
  167. package/store/ResolverCache.js.flow +249 -0
  168. package/store/ResolverFragments.js.flow +16 -20
  169. package/store/StoreInspector.js.flow +3 -3
  170. package/store/TypeID.js.flow +2 -2
  171. package/store/ViewerPattern.js.flow +3 -3
  172. package/store/cloneRelayHandleSourceField.js.flow +6 -7
  173. package/store/cloneRelayScalarHandleSourceField.js.flow +6 -7
  174. package/store/createFragmentSpecResolver.js.flow +4 -5
  175. package/store/createRelayContext.js.flow +4 -4
  176. package/store/defaultGetDataID.js.flow +1 -1
  177. package/store/defaultRequiredFieldLogger.js.flow +1 -1
  178. package/store/hasOverlappingIDs.js.flow +1 -1
  179. package/store/isRelayModernEnvironment.js.flow +1 -1
  180. package/store/normalizeRelayPayload.js.flow +7 -8
  181. package/store/readInlineData.js.flow +8 -9
  182. package/subscription/requestSubscription.js.flow +55 -51
  183. package/util/JSResourceTypes.flow.js.flow +1 -1
  184. package/util/NormalizationNode.js.flow +11 -4
  185. package/util/ReaderNode.js.flow +25 -2
  186. package/util/RelayConcreteNode.js.flow +5 -1
  187. package/util/RelayDefaultHandleKey.js.flow +1 -1
  188. package/util/RelayError.js.flow +1 -1
  189. package/util/RelayFeatureFlags.js.flow +23 -15
  190. package/util/RelayProfiler.js.flow +1 -1
  191. package/util/RelayReplaySubject.js.flow +10 -10
  192. package/util/RelayRuntimeTypes.js.flow +70 -3
  193. package/util/StringInterner.js.flow +69 -0
  194. package/util/createPayloadFor3DField.js.flow +4 -4
  195. package/util/deepFreeze.js.flow +1 -1
  196. package/util/generateID.js.flow +1 -1
  197. package/util/getAllRootVariables.js.flow +36 -0
  198. package/util/getFragmentIdentifier.js.flow +28 -16
  199. package/util/getOperation.js.flow +3 -3
  200. package/util/getPaginationMetadata.js.flow +69 -0
  201. package/util/getPaginationVariables.js.flow +108 -0
  202. package/util/getPendingOperationsForFragment.js.flow +62 -0
  203. package/util/getRefetchMetadata.js.flow +76 -0
  204. package/util/getRelayHandleKey.js.flow +2 -3
  205. package/util/getRequestIdentifier.js.flow +4 -4
  206. package/util/getValueAtPath.js.flow +46 -0
  207. package/util/isEmptyObject.js.flow +2 -1
  208. package/util/isPromise.js.flow +1 -1
  209. package/util/isScalarAndEqual.js.flow +1 -1
  210. package/util/recycleNodesInto.js.flow +1 -1
  211. package/util/registerEnvironmentWithDevTools.js.flow +33 -0
  212. package/util/reportMissingRequiredFields.js.flow +1 -1
  213. package/util/resolveImmediate.js.flow +2 -2
  214. package/util/stableCopy.js.flow +1 -1
  215. package/util/withDuration.js.flow +32 -0
  216. package/lib/store/RelayRecordSourceMapImpl.js +0 -107
  217. package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +0 -318
  218. package/store/RelayRecordSourceMapImpl.js.flow +0 -91
  219. package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +0 -283
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -12,21 +12,18 @@
12
12
 
13
13
  var RelayDeclarativeMutationConfig = require('../mutations/RelayDeclarativeMutationConfig');
14
14
 
15
- var RelayFeatureFlags = require('../util/RelayFeatureFlags');
16
-
17
- var warning = require("fbjs/lib/warning");
18
-
19
15
  var _require = require('../query/GraphQLTag'),
20
16
  getRequest = _require.getRequest;
21
17
 
22
- var _require2 = require('../store/ClientID'),
23
- generateUniqueClientID = _require2.generateUniqueClientID;
18
+ var _require2 = require('../store/RelayModernOperationDescriptor'),
19
+ createOperationDescriptor = _require2.createOperationDescriptor;
24
20
 
25
- var _require3 = require('../store/RelayModernOperationDescriptor'),
26
- createOperationDescriptor = _require3.createOperationDescriptor;
21
+ var _require3 = require('../store/RelayModernSelector'),
22
+ createReaderSelector = _require3.createReaderSelector;
27
23
 
28
- var _require4 = require('../store/RelayModernSelector'),
29
- createReaderSelector = _require4.createReaderSelector;
24
+ var RelayFeatureFlags = require('../util/RelayFeatureFlags');
25
+
26
+ var warning = require("fbjs/lib/warning");
30
27
 
31
28
  function requestSubscription(environment, config) {
32
29
  var subscription = getRequest(config.subscription);
@@ -41,43 +38,44 @@ function requestSubscription(environment, config) {
41
38
  onNext = config.onNext,
42
39
  variables = config.variables,
43
40
  cacheConfig = config.cacheConfig;
44
- var operation = createOperationDescriptor(subscription, variables, cacheConfig, RelayFeatureFlags.ENABLE_UNIQUE_SUBSCRIPTION_ROOT ? generateUniqueClientID() : undefined);
41
+ var operation = createOperationDescriptor(subscription, variables, cacheConfig);
45
42
  process.env.NODE_ENV !== "production" ? warning(!(config.updater && configs), 'requestSubscription: Expected only one of `updater` and `configs` to be provided') : void 0;
46
43
 
47
44
  var _ref = configs ? RelayDeclarativeMutationConfig.convert(configs, subscription, null
48
45
  /* optimisticUpdater */
49
- , config.updater) : config,
46
+ ,
47
+ /* optimisticUpdater */
48
+ config.updater) : config,
50
49
  updater = _ref.updater;
51
50
 
52
- var sub = environment.execute({
51
+ var sub = environment.executeSubscription({
53
52
  operation: operation,
54
53
  updater: updater
55
- }).map(function (responses) {
56
- var selector = operation.fragment;
54
+ }).subscribe({
55
+ next: function next(responses) {
56
+ if (onNext != null) {
57
+ var selector = operation.fragment;
58
+ var nextID;
57
59
 
58
- if (RelayFeatureFlags.ENABLE_UNIQUE_SUBSCRIPTION_ROOT) {
59
- var nextID;
60
+ if (Array.isArray(responses)) {
61
+ var _responses$, _responses$$extension;
60
62
 
61
- if (Array.isArray(responses)) {
62
- var _responses$, _responses$$extension;
63
+ nextID = (_responses$ = responses[0]) === null || _responses$ === void 0 ? void 0 : (_responses$$extension = _responses$.extensions) === null || _responses$$extension === void 0 ? void 0 : _responses$$extension.__relay_subscription_root_id;
64
+ } else {
65
+ var _responses$extensions;
63
66
 
64
- nextID = (_responses$ = responses[0]) === null || _responses$ === void 0 ? void 0 : (_responses$$extension = _responses$.extensions) === null || _responses$$extension === void 0 ? void 0 : _responses$$extension.__relay_subscription_root_id;
65
- } else {
66
- var _responses$extensions;
67
+ nextID = (_responses$extensions = responses.extensions) === null || _responses$extensions === void 0 ? void 0 : _responses$extensions.__relay_subscription_root_id;
68
+ }
67
69
 
68
- nextID = (_responses$extensions = responses.extensions) === null || _responses$extensions === void 0 ? void 0 : _responses$extensions.__relay_subscription_root_id;
69
- }
70
+ if (typeof nextID === 'string') {
71
+ selector = createReaderSelector(selector.node, nextID, selector.variables, selector.owner);
72
+ }
70
73
 
71
- if (typeof nextID === 'string') {
72
- selector = createReaderSelector(selector.node, nextID, selector.variables, selector.owner);
73
- }
74
- }
74
+ var data = environment.lookup(selector).data; // $FlowFixMe[incompatible-cast]
75
75
 
76
- var data = environment.lookup(selector).data; // $FlowFixMe[incompatible-cast]
77
-
78
- return data;
79
- }).subscribe({
80
- next: onNext,
76
+ onNext(data);
77
+ }
78
+ },
81
79
  error: onError,
82
80
  complete: onCompleted
83
81
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -24,8 +24,10 @@
24
24
  * for local caching.
25
25
  */
26
26
  var RelayConcreteNode = {
27
+ ACTOR_CHANGE: 'ActorChange',
27
28
  CONDITION: 'Condition',
28
29
  CLIENT_COMPONENT: 'ClientComponent',
30
+ CLIENT_EDGE: 'ClientEdge',
29
31
  CLIENT_EXTENSION: 'ClientExtension',
30
32
  DEFER: 'Defer',
31
33
  CONNECTION: 'Connection',
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,20 +11,23 @@
11
11
  'use strict';
12
12
 
13
13
  var RelayFeatureFlags = {
14
+ DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES: false,
15
+ ENABLE_CLIENT_EDGES: false,
14
16
  ENABLE_VARIABLE_CONNECTION_KEY: false,
15
17
  ENABLE_PARTIAL_RENDERING_DEFAULT: true,
16
- ENABLE_RELAY_CONTAINERS_SUSPENSE: true,
17
- ENABLE_PRECISE_TYPE_REFINEMENT: false,
18
18
  ENABLE_REACT_FLIGHT_COMPONENT_FIELD: false,
19
- ENABLE_REQUIRED_DIRECTIVES: false,
20
19
  ENABLE_RELAY_RESOLVERS: false,
21
20
  ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION: false,
22
21
  ENABLE_FRIENDLY_QUERY_NAME_GQL_URL: false,
23
- ENABLE_STORE_SUBSCRIPTIONS_REFACTOR: false,
24
22
  ENABLE_LOAD_QUERY_REQUEST_DEDUPING: true,
25
23
  ENABLE_DO_NOT_WRAP_LIVE_QUERY: false,
26
24
  ENABLE_NOTIFY_SUBSCRIPTION: false,
27
- ENABLE_UNIQUE_SUBSCRIPTION_ROOT: false,
28
- ENABLE_BATCHED_STORE_UPDATES: false
25
+ BATCH_ASYNC_MODULE_UPDATES_FN: null,
26
+ ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT: false,
27
+ ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT: false,
28
+ MAX_DATA_ID_LENGTH: null,
29
+ REFACTOR_SUSPENSE_RESOURCE: true,
30
+ STRING_INTERN_LEVEL: 0,
31
+ USE_REACT_CACHE: false
29
32
  };
30
33
  module.exports = RelayFeatureFlags;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -12,6 +12,8 @@
12
12
 
13
13
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
14
14
 
15
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
16
+
15
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
18
 
17
19
  var RelayObservable = require('../network/RelayObservable');
@@ -31,7 +33,7 @@ var RelayReplaySubject = /*#__PURE__*/function () {
31
33
  (0, _defineProperty2["default"])(this, "_complete", false);
32
34
  (0, _defineProperty2["default"])(this, "_events", []);
33
35
  (0, _defineProperty2["default"])(this, "_sinks", new Set());
34
- (0, _defineProperty2["default"])(this, "_subscription", null);
36
+ (0, _defineProperty2["default"])(this, "_subscription", []);
35
37
  this._observable = RelayObservable.create(function (sink) {
36
38
  _this._sinks.add(sink);
37
39
 
@@ -121,16 +123,29 @@ var RelayReplaySubject = /*#__PURE__*/function () {
121
123
  };
122
124
 
123
125
  _proto.subscribe = function subscribe(observer) {
124
- this._subscription = this._observable.subscribe(observer);
125
- return this._subscription;
126
+ var subscription = this._observable.subscribe(observer);
127
+
128
+ this._subscription.push(subscription);
129
+
130
+ return subscription;
126
131
  };
127
132
 
128
133
  _proto.unsubscribe = function unsubscribe() {
129
- if (this._subscription) {
130
- this._subscription.unsubscribe();
134
+ var _iterator = (0, _createForOfIteratorHelper2["default"])(this._subscription),
135
+ _step;
131
136
 
132
- this._subscription = null;
137
+ try {
138
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
139
+ var subscription = _step.value;
140
+ subscription.unsubscribe();
141
+ }
142
+ } catch (err) {
143
+ _iterator.e(err);
144
+ } finally {
145
+ _iterator.f();
133
146
  }
147
+
148
+ this._subscription = [];
134
149
  };
135
150
 
136
151
  _proto.getObserverCount = function getObserverCount() {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,10 +11,4 @@
11
11
  'use strict';
12
12
  /**
13
13
  * Basic types used throughout Relay.
14
- */
15
-
16
- /**
17
- * Represents any resource that must be explicitly disposed of. The most common
18
- * use-case is as a return value for subscriptions, where calling `dispose()`
19
- * would cancel the subscription.
20
14
  */
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+ // flowlint ambiguous-object-type:error
11
+ 'use strict';
12
+
13
+ var internTable = new Map();
14
+ var nextIndex = 1;
15
+ var digits = initDigitTable(); // Character used as the prefix for interned strings. The specific character is
16
+ // chosen to reduce the likelihood that non-interned input strings need to be
17
+ // escaped (choosing eg a-Z would increase the likelihood we need to escape)
18
+
19
+ var INTERN_PREFIX = '\t'; // Character used as the prefix of escaped strings. As above, this is also
20
+ // chosen to be unlikely in normal input strings.
21
+
22
+ var ESCAPE_PREFIX = '\v';
23
+
24
+ function initDigitTable() {
25
+ // disable lint because digits isn't defined when this function is called
26
+ // eslint-disable-next-line no-shadow
27
+ var digits = new Set();
28
+
29
+ for (var i = 0; i < 10; ++i) {
30
+ digits.add(i.toString());
31
+ }
32
+
33
+ return digits;
34
+ } // Escape a string so that it cannot conflict with an interned string
35
+
36
+
37
+ function escape(str) {
38
+ if ( // "\t<digit>..." -> "\v\t<digit>..."
39
+ str[0] === INTERN_PREFIX && digits.has(str[1]) || // "\v..." -> "\v\v..."
40
+ str[0] === ESCAPE_PREFIX) {
41
+ return ESCAPE_PREFIX + str;
42
+ }
43
+
44
+ return str;
45
+ } // Interns the input string if its length equals or exceeds the given `limit`,
46
+ // returning a shorter replacement string that is uniquely associated with the
47
+ // input: multiple calls to intern() for the equivalent input strings (and limit)
48
+ // will always return the exact same string.
49
+ // Strings shorter than the limit are not interned but are escaped if they
50
+ // could conflict with interned strings.
51
+
52
+
53
+ function intern(str, limit) {
54
+ if (limit == null || str.length < limit) {
55
+ return escape(str);
56
+ }
57
+
58
+ var internedString = internTable.get(str);
59
+
60
+ if (internedString != null) {
61
+ return internedString;
62
+ }
63
+
64
+ internedString = INTERN_PREFIX + nextIndex++;
65
+ internTable.set(str, internedString);
66
+ return internedString;
67
+ }
68
+
69
+ module.exports = {
70
+ intern: intern
71
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ * @emails oncall+relay
10
+ */
11
+ // flowlint ambiguous-object-type:error
12
+ 'use strict';
13
+
14
+ function getAllRootVariables(userSuppliedVariables, parameters) {
15
+ var providedVariables = parameters.providedVariables;
16
+
17
+ if (providedVariables != null) {
18
+ var allVariables = {};
19
+ Object.assign(allVariables, userSuppliedVariables);
20
+ Object.keys(providedVariables).forEach(function (varName) {
21
+ allVariables[varName] = providedVariables[varName].get();
22
+ });
23
+ return allVariables;
24
+ } else {
25
+ return userSuppliedVariables;
26
+ }
27
+ }
28
+
29
+ module.exports = getAllRootVariables;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,16 +11,19 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var RelayFeatureFlags = require('./RelayFeatureFlags');
14
+ var _require = require('../store/RelayModernSelector'),
15
+ getDataIDsFromFragment = _require.getDataIDsFromFragment,
16
+ getSelector = _require.getSelector,
17
+ getVariablesFromFragment = _require.getVariablesFromFragment;
15
18
 
16
19
  var isEmptyObject = require('./isEmptyObject');
17
20
 
21
+ var RelayFeatureFlags = require('./RelayFeatureFlags');
22
+
18
23
  var stableCopy = require('./stableCopy');
19
24
 
20
- var _require = require('../store/RelayModernSelector'),
21
- getDataIDsFromFragment = _require.getDataIDsFromFragment,
22
- getVariablesFromFragment = _require.getVariablesFromFragment,
23
- getSelector = _require.getSelector;
25
+ var _require2 = require('./StringInterner'),
26
+ intern = _require2.intern;
24
27
 
25
28
  function getFragmentIdentifier(fragmentNode, fragmentRef) {
26
29
  var selector = getSelector(fragmentNode, fragmentRef);
@@ -31,11 +34,16 @@ function getFragmentIdentifier(fragmentNode, fragmentRef) {
31
34
  var dataIDs = getDataIDsFromFragment(fragmentNode, fragmentRef);
32
35
 
33
36
  if (RelayFeatureFlags.ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION) {
34
- return fragmentOwnerIdentifier + '/' + fragmentNode.name + '/' + (fragmentVariables == null || isEmptyObject(fragmentVariables) ? '{}' : JSON.stringify(stableCopy(fragmentVariables))) + '/' + (typeof dataIDs === 'undefined' ? 'missing' : dataIDs == null ? 'null' : Array.isArray(dataIDs) ? '[' + dataIDs.join(',') + ']' : dataIDs);
37
+ var ids = typeof dataIDs === 'undefined' ? 'missing' : dataIDs == null ? 'null' : Array.isArray(dataIDs) ? '[' + dataIDs.join(',') + ']' : dataIDs;
38
+ ids = RelayFeatureFlags.STRING_INTERN_LEVEL <= 1 ? ids : intern(ids, RelayFeatureFlags.MAX_DATA_ID_LENGTH);
39
+ return fragmentOwnerIdentifier + '/' + fragmentNode.name + '/' + (fragmentVariables == null || isEmptyObject(fragmentVariables) ? '{}' : JSON.stringify(stableCopy(fragmentVariables))) + '/' + ids;
35
40
  } else {
36
41
  var _JSON$stringify;
37
42
 
38
- return fragmentOwnerIdentifier + '/' + fragmentNode.name + '/' + JSON.stringify(stableCopy(fragmentVariables)) + '/' + ((_JSON$stringify = JSON.stringify(dataIDs)) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : 'missing');
43
+ var _ids = (_JSON$stringify = JSON.stringify(dataIDs)) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : 'missing';
44
+
45
+ _ids = RelayFeatureFlags.STRING_INTERN_LEVEL <= 1 ? _ids : intern(_ids, RelayFeatureFlags.MAX_DATA_ID_LENGTH);
46
+ return fragmentOwnerIdentifier + '/' + fragmentNode.name + '/' + JSON.stringify(stableCopy(fragmentVariables)) + '/' + _ids;
39
47
  }
40
48
  }
41
49
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -14,11 +14,12 @@
14
14
  var _require = require('./RelayConcreteNode'),
15
15
  REQUEST = _require.REQUEST,
16
16
  SPLIT_OPERATION = _require.SPLIT_OPERATION;
17
-
18
17
  /**
19
18
  * OperationLoaders can return either a NormalizationSplitOperation or
20
19
  * ConcreteRequest.
21
20
  */
21
+
22
+
22
23
  function getOperation(node) {
23
24
  switch (node.kind) {
24
25
  case REQUEST:
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+relay
8
+ *
9
+ * @format
10
+ */
11
+ // flowlint ambiguous-object-type:error
12
+ 'use strict';
13
+
14
+ var getRefetchMetadata = require('./getRefetchMetadata');
15
+
16
+ var invariant = require('invariant');
17
+
18
+ function getPaginationMetadata(fragmentNode, componentDisplayName) {
19
+ var _fragmentNode$metadat, _fragmentNode$metadat2;
20
+
21
+ var _getRefetchMetadata = getRefetchMetadata(fragmentNode, componentDisplayName),
22
+ paginationRequest = _getRefetchMetadata.refetchableRequest,
23
+ refetchMetadata = _getRefetchMetadata.refetchMetadata;
24
+
25
+ var paginationMetadata = refetchMetadata.connection;
26
+ !(paginationMetadata != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: getPaginationMetadata(): Expected fragment `%s` to include a ' + 'connection when using `%s`. Did you forget to add a @connection ' + 'directive to the connection field in the fragment?', componentDisplayName, fragmentNode.name) : invariant(false) : void 0;
27
+ var connectionPathInFragmentData = paginationMetadata.path;
28
+ var connectionMetadata = ((_fragmentNode$metadat = (_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.connection) !== null && _fragmentNode$metadat !== void 0 ? _fragmentNode$metadat : [])[0];
29
+ !(connectionMetadata != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: getPaginationMetadata(): Expected fragment `%s` to include a ' + 'connection when using `%s`. Did you forget to add a @connection ' + 'directive to the connection field in the fragment?', componentDisplayName, fragmentNode.name) : invariant(false) : void 0;
30
+ var identifierField = refetchMetadata.identifierField;
31
+ !(identifierField == null || typeof identifierField === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: getRefetchMetadata(): Expected `identifierField` to be a string.') : invariant(false) : void 0;
32
+ return {
33
+ connectionPathInFragmentData: connectionPathInFragmentData,
34
+ identifierField: identifierField,
35
+ paginationRequest: paginationRequest,
36
+ paginationMetadata: paginationMetadata,
37
+ stream: connectionMetadata.stream === true
38
+ };
39
+ }
40
+
41
+ module.exports = getPaginationMetadata;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+relay
8
+ *
9
+ * @format
10
+ */
11
+ // flowlint ambiguous-object-type:error
12
+ 'use strict';
13
+
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
15
+
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
18
+ var _objectSpread4 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
19
+
20
+ var invariant = require('invariant');
21
+
22
+ var warning = require("fbjs/lib/warning");
23
+
24
+ function getPaginationVariables(direction, count, cursor, baseVariables, extraVariables, paginationMetadata) {
25
+ var _objectSpread3;
26
+
27
+ var backwardMetadata = paginationMetadata.backward,
28
+ forwardMetadata = paginationMetadata.forward;
29
+
30
+ if (direction === 'backward') {
31
+ var _objectSpread2;
32
+
33
+ !(backwardMetadata != null && backwardMetadata.count != null && backwardMetadata.cursor != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected backward pagination metadata to be available. ' + "If you're seeing this, this is likely a bug in Relay.") : invariant(false) : void 0;
34
+ process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(backwardMetadata.cursor), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain cursor variable `%s`. This variable is automatically ' + 'determined by Relay.', backwardMetadata.cursor) : void 0;
35
+ process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(backwardMetadata.count), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain count variable `%s`. This variable is automatically ' + 'determined by Relay.', backwardMetadata.count) : void 0;
36
+
37
+ var _paginationVariables = (0, _objectSpread4["default"])((0, _objectSpread4["default"])((0, _objectSpread4["default"])({}, baseVariables), extraVariables), {}, (_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, backwardMetadata.cursor, cursor), (0, _defineProperty2["default"])(_objectSpread2, backwardMetadata.count, count), _objectSpread2));
38
+
39
+ if (forwardMetadata && forwardMetadata.cursor) {
40
+ _paginationVariables[forwardMetadata.cursor] = null;
41
+ }
42
+
43
+ if (forwardMetadata && forwardMetadata.count) {
44
+ _paginationVariables[forwardMetadata.count] = null;
45
+ }
46
+
47
+ return _paginationVariables;
48
+ }
49
+
50
+ !(forwardMetadata != null && forwardMetadata.count != null && forwardMetadata.cursor != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected forward pagination metadata to be available. ' + "If you're seeing this, this is likely a bug in Relay.") : invariant(false) : void 0;
51
+ process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(forwardMetadata.cursor), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain cursor variable `%s`. This variable is automatically ' + 'determined by Relay.', forwardMetadata.cursor) : void 0;
52
+ process.env.NODE_ENV !== "production" ? warning(!extraVariables.hasOwnProperty(forwardMetadata.count), 'Relay: `UNSTABLE_extraVariables` provided by caller should not ' + 'contain count variable `%s`. This variable is automatically ' + 'determined by Relay.', forwardMetadata.count) : void 0;
53
+ var paginationVariables = (0, _objectSpread4["default"])((0, _objectSpread4["default"])((0, _objectSpread4["default"])({}, baseVariables), extraVariables), {}, (_objectSpread3 = {}, (0, _defineProperty2["default"])(_objectSpread3, forwardMetadata.cursor, cursor), (0, _defineProperty2["default"])(_objectSpread3, forwardMetadata.count, count), _objectSpread3));
54
+
55
+ if (backwardMetadata && backwardMetadata.cursor) {
56
+ paginationVariables[backwardMetadata.cursor] = null;
57
+ }
58
+
59
+ if (backwardMetadata && backwardMetadata.count) {
60
+ paginationVariables[backwardMetadata.count] = null;
61
+ }
62
+
63
+ return paginationVariables;
64
+ }
65
+
66
+ module.exports = getPaginationVariables;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+relay
8
+ *
9
+ * @format
10
+ */
11
+ // flowlint ambiguous-object-type:error
12
+ 'use strict';
13
+
14
+ var _require = require('../query/fetchQueryInternal'),
15
+ getPromiseForActiveRequest = _require.getPromiseForActiveRequest;
16
+
17
+ function getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner) {
18
+ var _pendingOperations$ma, _pendingOperations;
19
+
20
+ var pendingOperations = [];
21
+ var promise = getPromiseForActiveRequest(environment, fragmentOwner);
22
+
23
+ if (promise != null) {
24
+ pendingOperations = [fragmentOwner];
25
+ } else {
26
+ var _result$pendingOperat, _result$promise;
27
+
28
+ var result = environment.getOperationTracker().getPendingOperationsAffectingOwner(fragmentOwner);
29
+ pendingOperations = (_result$pendingOperat = result === null || result === void 0 ? void 0 : result.pendingOperations) !== null && _result$pendingOperat !== void 0 ? _result$pendingOperat : [];
30
+ promise = (_result$promise = result === null || result === void 0 ? void 0 : result.promise) !== null && _result$promise !== void 0 ? _result$promise : null;
31
+ }
32
+
33
+ if (!promise) {
34
+ return null;
35
+ }
36
+
37
+ var pendingOperationName = (_pendingOperations$ma = (_pendingOperations = pendingOperations) === null || _pendingOperations === void 0 ? void 0 : _pendingOperations.map(function (op) {
38
+ return op.node.params.name;
39
+ }).join(',')) !== null && _pendingOperations$ma !== void 0 ? _pendingOperations$ma : null;
40
+
41
+ if (pendingOperationName == null || pendingOperationName.length === 0) {
42
+ pendingOperationName = 'Unknown pending operation';
43
+ }
44
+
45
+ var fragmentName = fragmentNode.name;
46
+ var promiseDisplayName = pendingOperationName === fragmentName ? "Relay(".concat(pendingOperationName, ")") : "Relay(".concat(pendingOperationName, ":").concat(fragmentName, ")"); // $FlowExpectedError[prop-missing] Expando to annotate Promises.
47
+
48
+ promise.displayName = promiseDisplayName;
49
+ return {
50
+ promise: promise,
51
+ pendingOperations: pendingOperations
52
+ };
53
+ }
54
+
55
+ module.exports = getPendingOperationsForFragment;