react-relay 13.1.0 → 14.0.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.
Files changed (69) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayFragmentContainer.js.flow +7 -4
  3. package/ReactRelayLocalQueryRenderer.js.flow +1 -1
  4. package/ReactRelayPaginationContainer.js.flow +13 -8
  5. package/ReactRelayQueryFetcher.js.flow +1 -0
  6. package/ReactRelayQueryRenderer.js.flow +7 -6
  7. package/ReactRelayRefetchContainer.js.flow +10 -3
  8. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +2 -2
  9. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +2 -2
  10. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +3 -3
  11. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -3
  12. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +3 -3
  13. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -3
  14. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +2 -2
  15. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +2 -2
  16. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +2 -2
  17. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +2 -2
  18. package/buildReactRelayContainer.js.flow +2 -2
  19. package/hooks.js +1 -1
  20. package/index.js +1 -1
  21. package/jest-react/internalAct.js.flow +25 -9
  22. package/legacy.js +1 -1
  23. package/lib/ReactRelayQueryFetcher.js +1 -0
  24. package/lib/ReactRelayQueryRenderer.js +1 -2
  25. package/lib/jest-react/internalAct.js +24 -4
  26. package/lib/readContext.js +2 -1
  27. package/lib/relay-hooks/FragmentResource.js +62 -23
  28. package/lib/relay-hooks/HooksImplementation.js +29 -0
  29. package/lib/relay-hooks/MatchContainer.js +1 -0
  30. package/lib/relay-hooks/QueryResource.js +4 -166
  31. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +7 -11
  32. package/lib/relay-hooks/react-cache/RelayReactCache.js +37 -0
  33. package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +344 -0
  34. package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +540 -0
  35. package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +51 -0
  36. package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +56 -0
  37. package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +125 -0
  38. package/lib/relay-hooks/useFragment.js +15 -1
  39. package/lib/relay-hooks/useLazyLoadQuery.js +18 -2
  40. package/lib/relay-hooks/useMutation.js +4 -5
  41. package/lib/relay-hooks/usePreloadedQuery.js +18 -2
  42. package/package.json +3 -3
  43. package/react-relay-hooks.js +2 -2
  44. package/react-relay-hooks.min.js +2 -2
  45. package/react-relay-legacy.js +2 -2
  46. package/react-relay-legacy.min.js +2 -2
  47. package/react-relay.js +2 -2
  48. package/react-relay.min.js +2 -2
  49. package/readContext.js.flow +1 -0
  50. package/relay-hooks/FragmentResource.js.flow +72 -27
  51. package/relay-hooks/HooksImplementation.js.flow +45 -0
  52. package/relay-hooks/MatchContainer.js.flow +8 -1
  53. package/relay-hooks/QueryResource.js.flow +8 -203
  54. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +2 -2
  55. package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +2 -2
  56. package/relay-hooks/loadQuery.js.flow +2 -1
  57. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +7 -14
  58. package/relay-hooks/react-cache/RelayReactCache.js.flow +42 -0
  59. package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +424 -0
  60. package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +559 -0
  61. package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +74 -0
  62. package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +72 -0
  63. package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +153 -0
  64. package/relay-hooks/useFragment.js.flow +17 -10
  65. package/relay-hooks/useLazyLoadQuery.js.flow +38 -3
  66. package/relay-hooks/useMutation.js.flow +3 -3
  67. package/relay-hooks/usePreloadedQuery.js.flow +30 -2
  68. package/relay-hooks/useRefetchableFragmentNode.js.flow +26 -11
  69. package/relay-hooks/useSubscription.js.flow +14 -8
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.1.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -11,11 +11,11 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
 
13
13
  'use strict';
14
-
15
14
  import type {GeneratedNodeMap, RelayProp, $RelayProps} from './ReactRelayTypes';
16
15
  import type {
17
16
  FragmentMap,
18
17
  FragmentSpecResolver,
18
+ IEnvironment,
19
19
  RelayContext,
20
20
  } from 'relay-runtime';
21
21
 
@@ -58,7 +58,7 @@ function createContainerWithFragments<
58
58
 
59
59
  return class extends React.Component<ContainerProps, ContainerState> {
60
60
  static displayName = containerName;
61
- constructor(props) {
61
+ constructor(props: $FlowFixMe) {
62
62
  super(props);
63
63
  const relayContext = assertRelayContext(props.__relayContext);
64
64
  const rootIsQueryRenderer = props.__rootIsQueryRenderer ?? false;
@@ -163,7 +163,10 @@ function createContainerWithFragments<
163
163
  this.state.resolver.dispose();
164
164
  }
165
165
 
166
- shouldComponentUpdate(nextProps, nextState): boolean {
166
+ shouldComponentUpdate(
167
+ nextProps: ContainerProps,
168
+ nextState: ContainerState,
169
+ ): boolean {
167
170
  // Short-circuit if any Relay-related data has changed
168
171
  if (nextState.data !== this.state.data) {
169
172
  return true;
@@ -247,7 +250,7 @@ function createContainerWithFragments<
247
250
  };
248
251
  }
249
252
 
250
- function getRelayProp(environment) {
253
+ function getRelayProp(environment: IEnvironment) {
251
254
  return {
252
255
  environment,
253
256
  };
@@ -40,7 +40,7 @@ const queryRendererContext: ReactRelayQueryRendererContextType = {
40
40
  rootIsQueryRenderer: true,
41
41
  };
42
42
 
43
- function useDeepCompare<T: interface {}>(value: T): T {
43
+ function useDeepCompare<T: {...}>(value: T): T {
44
44
  const latestValue = React.useRef(value);
45
45
  if (!areEqual(latestValue.current, value)) {
46
46
  if (__DEV__) {
@@ -235,7 +235,7 @@ function createGetConnectionFromProps(metadata: ReactConnectionMetadata) {
235
235
  'ReactRelayPaginationContainer: Unable to synthesize a ' +
236
236
  'getConnectionFromProps function.',
237
237
  );
238
- return props => {
238
+ return (props: any) => {
239
239
  let data = props[metadata.fragmentName];
240
240
  for (let i = 0; i < path.length; i++) {
241
241
  if (!data || typeof data !== 'object') {
@@ -264,7 +264,9 @@ function createGetFragmentVariables(
264
264
 
265
265
  type ReactConnectionMetadata = ConnectionMetadata & {fragmentName: string, ...};
266
266
 
267
- function findConnectionMetadata(fragments): ReactConnectionMetadata {
267
+ function findConnectionMetadata(
268
+ fragments: FragmentMap,
269
+ ): ReactConnectionMetadata {
268
270
  let foundConnectionMetadata = null;
269
271
  let isRelayModern = false;
270
272
  for (const fragmentName in fragments) {
@@ -308,7 +310,7 @@ function toObserver(observerOrCallback: ?ObserverOrCallback): Observer<void> {
308
310
  ? {
309
311
  error: observerOrCallback,
310
312
  complete: observerOrCallback,
311
- unsubscribe: subscription => {
313
+ unsubscribe: (subscription: Subscription) => {
312
314
  typeof observerOrCallback === 'function' && observerOrCallback();
313
315
  },
314
316
  }
@@ -356,7 +358,7 @@ function createContainerWithFragments<
356
358
  _isUnmounted: boolean;
357
359
  _hasFetched: boolean;
358
360
 
359
- constructor(props) {
361
+ constructor(props: any) {
360
362
  super(props);
361
363
  const relayContext = assertRelayContext(props.__relayContext);
362
364
  const rootIsQueryRenderer = props.__rootIsQueryRenderer ?? false;
@@ -415,7 +417,7 @@ function createContainerWithFragments<
415
417
  * for updates. Props may be the same in which case previous data and
416
418
  * subscriptions can be reused.
417
419
  */
418
- UNSAFE_componentWillReceiveProps(nextProps) {
420
+ UNSAFE_componentWillReceiveProps(nextProps: any) {
419
421
  const relayContext = assertRelayContext(nextProps.__relayContext);
420
422
  const rootIsQueryRenderer = nextProps.__rootIsQueryRenderer ?? false;
421
423
  const prevIDs = getDataIDsFromObject(fragments, this.props);
@@ -479,7 +481,10 @@ function createContainerWithFragments<
479
481
  this._cleanup();
480
482
  }
481
483
 
482
- shouldComponentUpdate(nextProps, nextState): boolean {
484
+ shouldComponentUpdate(
485
+ nextProps: Props,
486
+ nextState: ContainerState,
487
+ ): boolean {
483
488
  // Short-circuit if any Relay-related data has changed
484
489
  if (
485
490
  nextState.data !== this.state.data ||
@@ -722,7 +727,7 @@ function createContainerWithFragments<
722
727
  return this._queryFetcher;
723
728
  }
724
729
 
725
- _canFetchPage(method): boolean {
730
+ _canFetchPage(method: 'loadMore' | 'refetchConnection'): boolean {
726
731
  if (this._isUnmounted) {
727
732
  warning(
728
733
  false,
@@ -813,7 +818,7 @@ function createContainerWithFragments<
813
818
  }
814
819
  this._hasFetched = true;
815
820
 
816
- const onNext = (payload, complete) => {
821
+ const onNext = (payload: mixed, complete: () => void) => {
817
822
  const prevData = this._resolver.resolve();
818
823
  this._resolver.setVariables(
819
824
  getFragmentVariables(
@@ -194,6 +194,7 @@ class ReactRelayQueryFetcher {
194
194
  onDataChange &&
195
195
  this._fetchOptions.onDataChangeCallbacks.indexOf(onDataChange) === -1
196
196
  ) {
197
+ // $FlowFixMe[incompatible-use]
197
198
  this._fetchOptions.onDataChangeCallbacks.push(onDataChange);
198
199
  }
199
200
 
@@ -29,7 +29,6 @@ const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext
29
29
  const areEqual = require('areEqual');
30
30
  const React = require('react');
31
31
  const {
32
- RelayFeatureFlags,
33
32
  createOperationDescriptor,
34
33
  deepFreeze,
35
34
  getRequest,
@@ -56,7 +55,12 @@ export type RenderProps<T> = {|
56
55
  * constructor. If a request is already in flight from a previous call to the
57
56
  * constructor, just reuse the query fetcher and wait for the response.
58
57
  */
59
- const requestCache = {};
58
+ const requestCache: {
59
+ [string]: void | {|
60
+ queryFetcher: ReactRelayQueryFetcher,
61
+ snapshot: ?Snapshot,
62
+ |},
63
+ } = {};
60
64
 
61
65
  const queryRendererContext: ReactRelayQueryRendererContextType = {
62
66
  rootIsQueryRenderer: true,
@@ -157,10 +161,7 @@ class ReactRelayQueryRenderer extends React.Component<Props, State> {
157
161
  }
158
162
 
159
163
  componentDidMount() {
160
- if (
161
- RelayFeatureFlags.ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT === true &&
162
- this._maybeHiddenOrFastRefresh === true
163
- ) {
164
+ if (this._maybeHiddenOrFastRefresh === true) {
164
165
  // This block only runs if the component has previously "unmounted"
165
166
  // due to it being hidden by the Offscreen API, or during fast refresh.
166
167
  // At this point, the current cached resource will have been disposed
@@ -24,6 +24,7 @@ import type {
24
24
  Disposable,
25
25
  FragmentMap,
26
26
  GraphQLTaggedNode,
27
+ IEnvironment,
27
28
  RelayContext,
28
29
  Subscription,
29
30
  Variables,
@@ -86,7 +87,7 @@ function createContainerWithFragments<
86
87
  _queryFetcher: ?ReactRelayQueryFetcher;
87
88
  _isUnmounted: boolean;
88
89
 
89
- constructor(props) {
90
+ constructor(props: any) {
90
91
  super(props);
91
92
  const relayContext = assertRelayContext(props.__relayContext);
92
93
  const rootIsQueryRenderer = props.__rootIsQueryRenderer ?? false;
@@ -217,7 +218,10 @@ function createContainerWithFragments<
217
218
  this._refetchSubscription && this._refetchSubscription.unsubscribe();
218
219
  }
219
220
 
220
- shouldComponentUpdate(nextProps, nextState): boolean {
221
+ shouldComponentUpdate(
222
+ nextProps: ContainerProps,
223
+ nextState: ContainerState,
224
+ ): boolean {
221
225
  // Short-circuit if any Relay-related data has changed
222
226
  if (
223
227
  nextState.data !== this.state.data ||
@@ -465,7 +469,10 @@ function createContainerWithFragments<
465
469
  };
466
470
  }
467
471
 
468
- function getRelayProp(environment, refetch): RelayRefetchProp {
472
+ function getRelayProp(
473
+ environment: IEnvironment,
474
+ refetch: RelayRefetchProp['refetch'],
475
+ ): RelayRefetchProp {
469
476
  return {
470
477
  environment,
471
478
  refetch,
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<56e1daf6db87bf9886b3627a3e0d76f9>>
7
+ * @generated SignedSource<<23bcef30afc22a42d79dd52e0cfe899c>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<c4fb5411e941bc7c5102499b684cf810>>
7
+ * @generated SignedSource<<af6c4570779066ea564051c9c71c494f>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<059d6a6d94da6f9b3cf43a0418ecc7b8>>
7
+ * @generated SignedSource<<6d173a357c286b417fdc586a839384d4>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -27,8 +27,8 @@ export type ReactRelayPaginationContainerFlowtestQuery$data = {|
27
27
  |},
28
28
  |};
29
29
  export type ReactRelayPaginationContainerFlowtestQuery = {|
30
- variables: ReactRelayPaginationContainerFlowtestQuery$variables,
31
30
  response: ReactRelayPaginationContainerFlowtestQuery$data,
31
+ variables: ReactRelayPaginationContainerFlowtestQuery$variables,
32
32
  |};
33
33
  */
34
34
 
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<86f990ee88078c49934d0f28c6c31da4>>
7
+ * @generated SignedSource<<b3cddee250d0ff22e89a7f0331e85df6>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -23,7 +23,7 @@ export type ReactRelayPaginationContainerFlowtest_viewer$data = {|
23
23
  +friends: ?{|
24
24
  +edges: ?$ReadOnlyArray<?{|
25
25
  +node: ?{|
26
- +__typename: string,
26
+ +__typename: "User",
27
27
  |},
28
28
  |}>,
29
29
  |},
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<a07bf128347274d353ab379de5eaef1f>>
7
+ * @generated SignedSource<<3b1b16b5d5ec1c94783d6161ae61bc3d>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -27,8 +27,8 @@ export type ReactRelayRefetchContainerFlowtestQuery$data = {|
27
27
  |},
28
28
  |};
29
29
  export type ReactRelayRefetchContainerFlowtestQuery = {|
30
- variables: ReactRelayRefetchContainerFlowtestQuery$variables,
31
30
  response: ReactRelayRefetchContainerFlowtestQuery$data,
31
+ variables: ReactRelayRefetchContainerFlowtestQuery$variables,
32
32
  |};
33
33
  */
34
34
 
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<6d9922010e1474b1214c383c394daa24>>
7
+ * @generated SignedSource<<6d04d7f7bf097d5869a1fdf0dea1e659>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -23,7 +23,7 @@ export type ReactRelayRefetchContainerFlowtest_viewer$data = {|
23
23
  +friends: ?{|
24
24
  +edges: ?$ReadOnlyArray<?{|
25
25
  +node: ?{|
26
- +__typename: string,
26
+ +__typename: "User",
27
27
  |},
28
28
  |}>,
29
29
  |},
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<050146f21476e7ed6edd2243d4c6b65d>>
7
+ * @generated SignedSource<<d3c71cb965d8374d40fb30f3c5ae9fd4>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<d8eae7df6faa43d95f6140dc3c9ad3ba>>
7
+ * @generated SignedSource<<bd60df80c19d8248426865abbc23562e>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<a7ba31d9d2381b0c8b700175be271b75>>
7
+ * @generated SignedSource<<527809017626cb43378afb92fed67feb>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -1,10 +1,10 @@
1
1
  /**
2
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.
6
6
  *
7
- * @generated SignedSource<<d032f6e721c9c9cdd034cdd93dfcbad6>>
7
+ * @generated SignedSource<<8a94ce305c03af7280da9b95a665349f>>
8
8
  * @flow
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
@@ -11,7 +11,7 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
 
13
13
  'use strict';
14
-
14
+ import type {ReaderFragment} from '../relay-runtime/util/ReaderNode';
15
15
  import type {GeneratedNodeMap} from './ReactRelayTypes';
16
16
  import type {FragmentMap} from 'relay-runtime';
17
17
 
@@ -45,7 +45,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
45
45
  const containerName = getContainerName(ComponentClass);
46
46
  assertFragmentMap(getComponentName(ComponentClass), fragmentSpec);
47
47
 
48
- const fragments = {};
48
+ const fragments: {[string]: ReaderFragment} = {};
49
49
  for (const key in fragmentSpec) {
50
50
  fragments[key] = getFragment(fragmentSpec[key]);
51
51
  }
package/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.1.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.1.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -36,7 +36,7 @@ interface Thenable<+R> {
36
36
 
37
37
  let actingUpdatesScopeDepth = 0;
38
38
 
39
- function act(scope: () => Thenable<mixed> | void) {
39
+ function act<T>(scope: () => Thenable<T> | T): Thenable<T> {
40
40
  if (Scheduler.unstable_flushAllWithoutAsserting === undefined) {
41
41
  throw Error(
42
42
  'This version of `act` requires a special mock build of Scheduler.',
@@ -49,10 +49,19 @@ function act(scope: () => Thenable<mixed> | void) {
49
49
  );
50
50
  }
51
51
 
52
+ const previousIsActEnvironment = global.IS_REACT_ACT_ENVIRONMENT;
52
53
  const previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
53
54
  actingUpdatesScopeDepth++;
55
+ if (__DEV__ && actingUpdatesScopeDepth === 1) {
56
+ // Because this is not the "real" `act`, we set this to `false` so React
57
+ // knows not to fire `act` warnings.
58
+ global.IS_REACT_ACT_ENVIRONMENT = false;
59
+ }
54
60
 
55
61
  const unwind = () => {
62
+ if (__DEV__ && actingUpdatesScopeDepth === 1) {
63
+ global.IS_REACT_ACT_ENVIRONMENT = previousIsActEnvironment;
64
+ }
56
65
  actingUpdatesScopeDepth--;
57
66
 
58
67
  if (__DEV__) {
@@ -71,20 +80,21 @@ function act(scope: () => Thenable<mixed> | void) {
71
80
  // returned and 2) we could use async/await. Since it's only our used in
72
81
  // our test suite, we should be able to.
73
82
  try {
74
- const thenable = scope();
83
+ const result = scope();
75
84
  if (
76
- typeof thenable === 'object' &&
77
- thenable !== null &&
78
- typeof thenable.then === 'function'
85
+ typeof result === 'object' &&
86
+ result !== null &&
87
+ typeof result.then === 'function'
79
88
  ) {
89
+ const thenableResult: Thenable<T> = (result: any);
80
90
  return {
81
- then(resolve: () => void, reject: (error: mixed) => void) {
82
- thenable.then(
83
- () => {
91
+ then(resolve, reject) {
92
+ thenableResult.then(
93
+ returnValue => {
84
94
  flushActWork(
85
95
  () => {
86
96
  unwind();
87
- resolve();
97
+ resolve(returnValue);
88
98
  },
89
99
  error => {
90
100
  unwind();
@@ -100,6 +110,7 @@ function act(scope: () => Thenable<mixed> | void) {
100
110
  },
101
111
  };
102
112
  } else {
113
+ const returnValue: T = (result: any);
103
114
  try {
104
115
  // TODO: Let's not support non-async scopes at all in our tests. Need to
105
116
  // migrate existing tests.
@@ -107,6 +118,11 @@ function act(scope: () => Thenable<mixed> | void) {
107
118
  do {
108
119
  didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
109
120
  } while (didFlushWork);
121
+ return {
122
+ then(resolve, reject) {
123
+ resolve(returnValue);
124
+ },
125
+ };
110
126
  } finally {
111
127
  unwind();
112
128
  }
package/legacy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.1.0
2
+ * Relay v14.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -153,6 +153,7 @@ var ReactRelayQueryFetcher = /*#__PURE__*/function () {
153
153
  };
154
154
 
155
155
  if (onDataChange && this._fetchOptions.onDataChangeCallbacks.indexOf(onDataChange) === -1) {
156
+ // $FlowFixMe[incompatible-use]
156
157
  this._fetchOptions.onDataChangeCallbacks.push(onDataChange);
157
158
  }
158
159
 
@@ -31,7 +31,6 @@ var areEqual = require("fbjs/lib/areEqual");
31
31
  var React = require('react');
32
32
 
33
33
  var _require = require('relay-runtime'),
34
- RelayFeatureFlags = _require.RelayFeatureFlags,
35
34
  createOperationDescriptor = _require.createOperationDescriptor,
36
35
  deepFreeze = _require.deepFreeze,
37
36
  getRequest = _require.getRequest;
@@ -132,7 +131,7 @@ var ReactRelayQueryRenderer = /*#__PURE__*/function (_React$Component) {
132
131
  _proto.componentDidMount = function componentDidMount() {
133
132
  var _this2 = this;
134
133
 
135
- if (RelayFeatureFlags.ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT === true && this._maybeHiddenOrFastRefresh === true) {
134
+ if (this._maybeHiddenOrFastRefresh === true) {
136
135
  // This block only runs if the component has previously "unmounted"
137
136
  // due to it being hidden by the Offscreen API, or during fast refresh.
138
137
  // At this point, the current cached resource will have been disposed
@@ -36,10 +36,21 @@ function act(scope) {
36
36
  throw Error("This version of `act` requires Jest's timer mocks " + '(i.e. jest.useFakeTimers).');
37
37
  }
38
38
 
39
+ var previousIsActEnvironment = global.IS_REACT_ACT_ENVIRONMENT;
39
40
  var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
40
41
  actingUpdatesScopeDepth++;
41
42
 
43
+ if (process.env.NODE_ENV !== "production" && actingUpdatesScopeDepth === 1) {
44
+ // Because this is not the "real" `act`, we set this to `false` so React
45
+ // knows not to fire `act` warnings.
46
+ global.IS_REACT_ACT_ENVIRONMENT = false;
47
+ }
48
+
42
49
  var unwind = function unwind() {
50
+ if (process.env.NODE_ENV !== "production" && actingUpdatesScopeDepth === 1) {
51
+ global.IS_REACT_ACT_ENVIRONMENT = previousIsActEnvironment;
52
+ }
53
+
43
54
  actingUpdatesScopeDepth--;
44
55
 
45
56
  if (process.env.NODE_ENV !== "production") {
@@ -55,15 +66,16 @@ function act(scope) {
55
66
 
56
67
 
57
68
  try {
58
- var thenable = scope();
69
+ var result = scope();
59
70
 
60
- if (typeof thenable === 'object' && thenable !== null && typeof thenable.then === 'function') {
71
+ if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
72
+ var thenableResult = result;
61
73
  return {
62
74
  then: function then(resolve, reject) {
63
- thenable.then(function () {
75
+ thenableResult.then(function (returnValue) {
64
76
  flushActWork(function () {
65
77
  unwind();
66
- resolve();
78
+ resolve(returnValue);
67
79
  }, function (error) {
68
80
  unwind();
69
81
  reject(error);
@@ -75,6 +87,8 @@ function act(scope) {
75
87
  }
76
88
  };
77
89
  } else {
90
+ var returnValue = result;
91
+
78
92
  try {
79
93
  // TODO: Let's not support non-async scopes at all in our tests. Need to
80
94
  // migrate existing tests.
@@ -83,6 +97,12 @@ function act(scope) {
83
97
  do {
84
98
  didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
85
99
  } while (didFlushWork);
100
+
101
+ return {
102
+ then: function then(resolve, reject) {
103
+ resolve(returnValue);
104
+ }
105
+ };
86
106
  } finally {
87
107
  unwind();
88
108
  }
@@ -10,7 +10,8 @@
10
10
  // flowlint ambiguous-object-type:error
11
11
  'use strict';
12
12
 
13
- var React = require('react');
13
+ var React = require('react'); // $FlowFixMe[incompatible-use]
14
+
14
15
 
15
16
  var _React$__SECRET_INTER =
16
17
  /* $FlowFixMe[prop-missing] Flow doesn't know about React's internals for