react-relay 14.1.0 → 15.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.
- package/ReactRelayContainerUtils.js.flow +1 -0
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +1 -0
- package/ReactRelayFragmentContainer.js.flow +6 -2
- package/ReactRelayFragmentMockRenderer.js.flow +1 -0
- package/ReactRelayLocalQueryRenderer.js.flow +5 -3
- package/ReactRelayPaginationContainer.js.flow +21 -12
- package/ReactRelayQueryFetcher.js.flow +19 -5
- package/ReactRelayQueryRenderer.js.flow +32 -1
- package/ReactRelayQueryRendererContext.js.flow +1 -0
- package/ReactRelayRefetchContainer.js.flow +9 -5
- package/ReactRelayTestMocker.js.flow +3 -1
- package/ReactRelayTypes.js.flow +1 -0
- package/RelayContext.js.flow +1 -0
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -1
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -0
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -0
- package/__flowtests__/RelayModern-flowtest.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -0
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +3 -1
- package/assertFragmentMap.js.flow +1 -0
- package/buildReactRelayContainer.js.flow +7 -5
- package/getRootVariablesForFragments.js.flow +1 -1
- package/hooks.js +1 -1
- package/hooks.js.flow +4 -0
- package/index.js +1 -1
- package/index.js.flow +4 -0
- package/isRelayEnvironment.js.flow +1 -0
- package/jest-react/enqueueTask.js.flow +1 -1
- package/jest-react/index.js.flow +1 -1
- package/jest-react/internalAct.js.flow +1 -1
- package/legacy.js +1 -1
- package/legacy.js.flow +1 -0
- package/lib/ReactRelayContainerUtils.js +2 -2
- package/lib/ReactRelayContext.js +3 -3
- package/lib/ReactRelayFragmentContainer.js +39 -66
- package/lib/ReactRelayFragmentMockRenderer.js +2 -3
- package/lib/ReactRelayLocalQueryRenderer.js +18 -30
- package/lib/ReactRelayPaginationContainer.js +66 -159
- package/lib/ReactRelayQueryFetcher.js +48 -74
- package/lib/ReactRelayQueryRenderer.js +62 -82
- package/lib/ReactRelayQueryRendererContext.js +2 -1
- package/lib/ReactRelayRefetchContainer.js +52 -99
- package/lib/ReactRelayTestMocker.js +32 -66
- package/lib/ReactRelayTypes.js +2 -0
- package/lib/RelayContext.js +4 -6
- package/lib/assertFragmentMap.js +3 -4
- package/lib/buildReactRelayContainer.js +10 -25
- package/lib/getRootVariablesForFragments.js +5 -8
- package/lib/hooks.js +5 -17
- package/lib/index.js +5 -24
- package/lib/isRelayEnvironment.js +5 -3
- package/lib/jest-react/enqueueTask.js +5 -9
- package/lib/jest-react/index.js +0 -1
- package/lib/jest-react/internalAct.js +9 -20
- package/lib/legacy.js +2 -7
- package/lib/multi-actor/ActorChange.js +2 -5
- package/lib/multi-actor/index.js +2 -1
- package/lib/multi-actor/useRelayActorEnvironment.js +4 -7
- package/lib/relay-hooks/EntryPointContainer.react.js +9 -14
- package/lib/relay-hooks/EntryPointTypes.flow.js +5 -2
- package/lib/relay-hooks/FragmentResource.js +102 -196
- package/lib/relay-hooks/HooksImplementation.js +2 -5
- package/lib/relay-hooks/InternalLogger.js +2 -2
- package/lib/relay-hooks/LRUCache.js +2 -19
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -53
- package/lib/relay-hooks/MatchContainer.js +14 -22
- package/lib/relay-hooks/ProfilerContext.js +3 -2
- package/lib/relay-hooks/QueryResource.js +30 -99
- package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -8
- package/lib/relay-hooks/SuspenseResource.js +8 -31
- package/lib/relay-hooks/loadEntryPoint.js +19 -31
- package/lib/relay-hooks/loadQuery.js +41 -77
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +10 -35
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -14
- package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -11
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +24 -78
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +23 -56
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +65 -143
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -14
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -23
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +73 -74
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -38
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +60 -102
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +7 -15
- package/lib/relay-hooks/useBlockingPaginationFragment.js +71 -92
- package/lib/relay-hooks/useClientQuery.js +3 -6
- package/lib/relay-hooks/useEntryPointLoader.js +17 -36
- package/lib/relay-hooks/useFetchTrackingRef.js +10 -11
- package/lib/relay-hooks/useFragment.js +8 -18
- package/lib/relay-hooks/useFragmentNode.js +20 -31
- package/lib/relay-hooks/useIsMountedRef.js +4 -5
- package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
- package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
- package/lib/relay-hooks/useLazyLoadQuery.js +6 -9
- package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -33
- package/lib/relay-hooks/useLoadMoreFunction.js +45 -76
- package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -14
- package/lib/relay-hooks/useMemoVariables.js +15 -33
- package/lib/relay-hooks/useMutation.js +8 -25
- package/lib/relay-hooks/usePaginationFragment.js +61 -76
- package/lib/relay-hooks/usePreloadedQuery.js +12 -29
- package/lib/relay-hooks/useQueryLoader.js +23 -47
- package/lib/relay-hooks/useRefetchableFragment.js +8 -18
- package/lib/relay-hooks/useRefetchableFragmentNode.js +64 -107
- package/lib/relay-hooks/useRelayEnvironment.js +4 -7
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -7
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -8
- package/lib/relay-hooks/useSubscription.js +5 -9
- package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +29 -0
- package/multi-actor/ActorChange.js.flow +1 -1
- package/multi-actor/index.js.flow +1 -1
- package/multi-actor/useRelayActorEnvironment.js.flow +2 -2
- package/package.json +2 -2
- package/react-relay-hooks.js +2 -2
- package/react-relay-hooks.min.js +2 -2
- package/react-relay-legacy.js +2 -2
- package/react-relay-legacy.min.js +2 -2
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +1 -1
- package/relay-hooks/EntryPointTypes.flow.js.flow +7 -5
- package/relay-hooks/FragmentResource.js.flow +34 -8
- package/relay-hooks/HooksImplementation.js.flow +1 -1
- package/relay-hooks/InternalLogger.js.flow +1 -1
- package/relay-hooks/LRUCache.js.flow +1 -1
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +15 -8
- package/relay-hooks/MatchContainer.js.flow +1 -1
- package/relay-hooks/ProfilerContext.js.flow +1 -1
- package/relay-hooks/QueryResource.js.flow +25 -5
- package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
- package/relay-hooks/SuspenseResource.js.flow +1 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +35 -33
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +33 -32
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -18
- package/relay-hooks/__flowtests__/utils.js.flow +13 -2
- package/relay-hooks/loadEntryPoint.js.flow +11 -6
- package/relay-hooks/loadQuery.js.flow +11 -7
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -8
- package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
- package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +3 -3
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +4 -4
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +41 -22
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +11 -5
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +2 -2
- package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -56
- package/relay-hooks/useClientQuery.js.flow +1 -1
- package/relay-hooks/useEntryPointLoader.js.flow +10 -6
- package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
- package/relay-hooks/useFragment.js.flow +2 -2
- package/relay-hooks/useFragmentNode.js.flow +5 -4
- package/relay-hooks/useIsMountedRef.js.flow +1 -1
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
- package/relay-hooks/useLazyLoadQuery.js.flow +2 -2
- package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
- package/relay-hooks/useLoadMoreFunction.js.flow +14 -9
- package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
- package/relay-hooks/useMemoVariables.js.flow +13 -29
- package/relay-hooks/useMutation.js.flow +4 -4
- package/relay-hooks/usePaginationFragment.js.flow +53 -46
- package/relay-hooks/usePreloadedQuery.js.flow +47 -22
- package/relay-hooks/useQueryLoader.js.flow +85 -22
- package/relay-hooks/useRefetchableFragment.js.flow +64 -33
- package/relay-hooks/useRefetchableFragmentNode.js.flow +10 -4
- package/relay-hooks/useRelayEnvironment.js.flow +2 -2
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
- package/relay-hooks/useSubscription.js.flow +1 -1
- package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
- package/lib/readContext.js +0 -27
- package/readContext.js.flow +0 -29
|
@@ -4,25 +4,22 @@
|
|
|
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
|
-
* @emails oncall+relay
|
|
8
7
|
*
|
|
9
8
|
* @format
|
|
9
|
+
* @oncall relay
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
'use strict';
|
|
12
13
|
|
|
13
14
|
var warning = require("fbjs/lib/warning");
|
|
14
|
-
|
|
15
15
|
var implementation = null;
|
|
16
|
-
|
|
17
16
|
function inject(impl) {
|
|
18
17
|
process.env.NODE_ENV !== "production" ? warning(implementation !== null, 'Relay HooksImplementation was injected twice.') : void 0;
|
|
19
18
|
implementation = impl;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
function get() {
|
|
23
21
|
return implementation;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
module.exports = {
|
|
27
24
|
inject: inject,
|
|
28
25
|
get: get
|
|
@@ -4,14 +4,14 @@
|
|
|
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
|
-
* @emails oncall+relay
|
|
8
7
|
*
|
|
9
8
|
* @format
|
|
9
|
+
* @oncall relay
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
'use strict';
|
|
12
13
|
|
|
13
14
|
var loggerImpl = function loggerImpl(eventData) {};
|
|
14
|
-
|
|
15
15
|
module.exports = {
|
|
16
16
|
setLoggerImplementation: function setLoggerImplementation(loggerFn) {
|
|
17
17
|
loggerImpl = loggerFn;
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
|
-
* @emails oncall+relay
|
|
9
8
|
* @format
|
|
9
|
+
* @oncall relay
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
'use strict';
|
|
12
13
|
|
|
13
14
|
var invariant = require('invariant');
|
|
14
|
-
|
|
15
15
|
/**
|
|
16
16
|
* JS maps (both plain objects and Map) maintain key insertion
|
|
17
17
|
* order, which means there is an easy way to simulate LRU behavior
|
|
@@ -29,62 +29,45 @@ var LRUCache = /*#__PURE__*/function () {
|
|
|
29
29
|
!(this._capacity > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'LRUCache: Unable to create instance of cache with zero or negative capacity.') : invariant(false) : void 0;
|
|
30
30
|
this._map = new Map();
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
var _proto = LRUCache.prototype;
|
|
34
|
-
|
|
35
33
|
_proto.set = function set(key, value) {
|
|
36
34
|
this._map["delete"](key);
|
|
37
|
-
|
|
38
35
|
this._map.set(key, value);
|
|
39
|
-
|
|
40
36
|
if (this._map.size > this._capacity) {
|
|
41
37
|
var firstKey = this._map.keys().next();
|
|
42
|
-
|
|
43
38
|
if (!firstKey.done) {
|
|
44
39
|
this._map["delete"](firstKey.value);
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
};
|
|
48
|
-
|
|
49
43
|
_proto.get = function get(key) {
|
|
50
44
|
var value = this._map.get(key);
|
|
51
|
-
|
|
52
45
|
if (value != null) {
|
|
53
46
|
this._map["delete"](key);
|
|
54
|
-
|
|
55
47
|
this._map.set(key, value);
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
return value;
|
|
59
50
|
};
|
|
60
|
-
|
|
61
51
|
_proto.has = function has(key) {
|
|
62
52
|
return this._map.has(key);
|
|
63
53
|
};
|
|
64
|
-
|
|
65
54
|
_proto["delete"] = function _delete(key) {
|
|
66
55
|
this._map["delete"](key);
|
|
67
56
|
};
|
|
68
|
-
|
|
69
57
|
_proto.size = function size() {
|
|
70
58
|
return this._map.size;
|
|
71
59
|
};
|
|
72
|
-
|
|
73
60
|
_proto.capacity = function capacity() {
|
|
74
61
|
return this._capacity - this._map.size;
|
|
75
62
|
};
|
|
76
|
-
|
|
77
63
|
_proto.clear = function clear() {
|
|
78
64
|
this._map.clear();
|
|
79
65
|
};
|
|
80
|
-
|
|
81
66
|
return LRUCache;
|
|
82
67
|
}();
|
|
83
|
-
|
|
84
68
|
function create(capacity) {
|
|
85
69
|
return new LRUCache(capacity);
|
|
86
70
|
}
|
|
87
|
-
|
|
88
71
|
module.exports = {
|
|
89
72
|
create: create
|
|
90
73
|
};
|
|
@@ -4,124 +4,105 @@
|
|
|
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
|
-
* @emails oncall+relay
|
|
8
7
|
*
|
|
9
8
|
* @format
|
|
9
|
+
* @oncall relay
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
'use strict';
|
|
12
13
|
|
|
13
14
|
var preloadQuery_DEPRECATED = require('./preloadQuery_DEPRECATED');
|
|
14
|
-
|
|
15
15
|
var ProfilerContext = require('./ProfilerContext');
|
|
16
|
-
|
|
17
16
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
|
18
|
-
|
|
19
17
|
var React = require('react');
|
|
20
|
-
|
|
21
18
|
var _require = require('react'),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
useContext = _require.useContext,
|
|
20
|
+
useEffect = _require.useEffect,
|
|
21
|
+
useMemo = _require.useMemo;
|
|
26
22
|
var _require2 = require('relay-runtime'),
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
stableCopy = _require2.stableCopy;
|
|
29
24
|
function stableStringify(value) {
|
|
30
25
|
var _JSON$stringify;
|
|
31
|
-
|
|
32
26
|
return (_JSON$stringify = JSON.stringify(stableCopy(value))) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : 'null';
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
function prepareEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
|
36
29
|
// Start loading the code for the entrypoint
|
|
37
30
|
var loadingPromise = null;
|
|
38
|
-
|
|
39
31
|
if (entryPoint.root.getModuleIfRequired() == null) {
|
|
40
32
|
loadingPromise = entryPoint.root.load();
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
var preloadProps = entryPoint.getPreloadProps(entryPointParams);
|
|
44
35
|
var queries = preloadProps.queries,
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
entryPoints = preloadProps.entryPoints,
|
|
37
|
+
extraProps = preloadProps.extraProps;
|
|
47
38
|
var preloadedQueries = {};
|
|
48
39
|
var preloadedEntryPoints = {};
|
|
49
|
-
|
|
50
40
|
if (queries != null) {
|
|
51
41
|
var queriesPropNames = Object.keys(queries);
|
|
52
42
|
queriesPropNames.forEach(function (queryPropName) {
|
|
53
43
|
var _queries$queryPropNam = queries[queryPropName],
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
environmentProviderOptions = _queries$queryPropNam.environmentProviderOptions,
|
|
45
|
+
options = _queries$queryPropNam.options,
|
|
46
|
+
parameters = _queries$queryPropNam.parameters,
|
|
47
|
+
variables = _queries$queryPropNam.variables;
|
|
58
48
|
var environment = environmentProvider.getEnvironment(environmentProviderOptions);
|
|
59
49
|
preloadedQueries[queryPropName] = preloadQuery_DEPRECATED(environment, parameters, variables, options, environmentProviderOptions);
|
|
60
50
|
});
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
if (entryPoints != null) {
|
|
64
53
|
var entryPointPropNames = Object.keys(entryPoints);
|
|
65
54
|
entryPointPropNames.forEach(function (entryPointPropName) {
|
|
66
55
|
var entryPointDescription = entryPoints[entryPointPropName];
|
|
67
|
-
|
|
68
56
|
if (entryPointDescription == null) {
|
|
69
57
|
return;
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
var nestedEntryPoint = entryPointDescription.entryPoint,
|
|
73
|
-
|
|
60
|
+
nestedParams = entryPointDescription.entryPointParams;
|
|
74
61
|
preloadedEntryPoints[entryPointPropName] = prepareEntryPoint(environmentProvider, nestedEntryPoint, nestedParams);
|
|
75
62
|
});
|
|
76
63
|
}
|
|
77
|
-
|
|
78
64
|
return {
|
|
79
65
|
entryPoints: preloadedEntryPoints,
|
|
80
66
|
extraProps: extraProps !== null && extraProps !== void 0 ? extraProps : null,
|
|
81
67
|
getComponent: function getComponent() {
|
|
82
68
|
var component = entryPoint.root.getModuleIfRequired();
|
|
83
|
-
|
|
84
69
|
if (component == null) {
|
|
85
70
|
var _loadingPromise;
|
|
86
|
-
|
|
87
71
|
loadingPromise = (_loadingPromise = loadingPromise) !== null && _loadingPromise !== void 0 ? _loadingPromise : entryPoint.root.load();
|
|
88
72
|
throw loadingPromise;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
}
|
|
74
|
+
// $FlowFixMe[incompatible-cast] - trust me Flow, its entryPoint component
|
|
92
75
|
return component;
|
|
93
76
|
},
|
|
94
77
|
queries: preloadedQueries,
|
|
95
78
|
rootModuleID: entryPoint.root.getModuleId()
|
|
96
79
|
};
|
|
97
80
|
}
|
|
98
|
-
|
|
99
81
|
function LazyLoadEntryPointContainer_DEPRECATED(_ref) {
|
|
100
82
|
var entryPoint = _ref.entryPoint,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
entryPointParams = _ref.entryPointParams,
|
|
84
|
+
props = _ref.props,
|
|
85
|
+
environmentProvider = _ref.environmentProvider;
|
|
104
86
|
var environment = useRelayEnvironment();
|
|
105
|
-
var getPreloadProps = entryPoint.getPreloadProps;
|
|
87
|
+
var getPreloadProps = entryPoint.getPreloadProps;
|
|
88
|
+
// IMPORTANT: Loading the component may suspend (throw), so the props
|
|
106
89
|
// *must* be computed first to fetch the component's data-dependencies in
|
|
107
90
|
// parallel with the component itself (the code).
|
|
108
|
-
|
|
109
91
|
var entryPointParamsHash = stableStringify(entryPointParams);
|
|
110
|
-
|
|
111
92
|
var _useMemo = useMemo(function () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
93
|
+
return prepareEntryPoint(environmentProvider !== null && environmentProvider !== void 0 ? environmentProvider : {
|
|
94
|
+
getEnvironment: function getEnvironment() {
|
|
95
|
+
return environment;
|
|
96
|
+
}
|
|
97
|
+
}, entryPoint, entryPointParams);
|
|
98
|
+
// NOTE: stableParams encodes the information from params
|
|
99
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
+
}, [environment, environmentProvider, getPreloadProps, entryPointParamsHash]),
|
|
101
|
+
getComponent = _useMemo.getComponent,
|
|
102
|
+
queries = _useMemo.queries,
|
|
103
|
+
entryPoints = _useMemo.entryPoints,
|
|
104
|
+
extraProps = _useMemo.extraProps,
|
|
105
|
+
rootModuleID = _useMemo.rootModuleID;
|
|
125
106
|
var Component = useMemo(function () {
|
|
126
107
|
return getComponent();
|
|
127
108
|
}, [getComponent]);
|
|
@@ -140,5 +121,4 @@ function LazyLoadEntryPointContainer_DEPRECATED(_ref) {
|
|
|
140
121
|
queries: queries
|
|
141
122
|
});
|
|
142
123
|
}
|
|
143
|
-
|
|
144
124
|
module.exports = LazyLoadEntryPointContainer_DEPRECATED;
|
|
@@ -4,19 +4,18 @@
|
|
|
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
|
-
* @emails oncall+relay
|
|
8
7
|
*
|
|
9
8
|
* @format
|
|
9
|
+
* @oncall relay
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
'use strict';
|
|
12
13
|
|
|
13
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
14
|
-
|
|
15
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
|
-
|
|
17
16
|
var React = require('react');
|
|
18
|
-
|
|
19
17
|
var useMemo = React.useMemo;
|
|
18
|
+
|
|
20
19
|
/**
|
|
21
20
|
* Renders the results of a data-driven dependency fetched with the `@match`
|
|
22
21
|
* directive. The `@match` directive can be used to specify a mapping of
|
|
@@ -84,39 +83,35 @@ var useMemo = React.useMemo;
|
|
|
84
83
|
* your server returns for the `js(moduleName: String)` field).
|
|
85
84
|
*
|
|
86
85
|
*/
|
|
86
|
+
|
|
87
87
|
// Note: this type is intentionally non-exact, it is expected that the
|
|
88
88
|
// object may contain sibling fields.
|
|
89
89
|
|
|
90
90
|
function MatchContainer(_ref2) {
|
|
91
91
|
var _ref;
|
|
92
|
-
|
|
93
92
|
var fallback = _ref2.fallback,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
loader = _ref2.loader,
|
|
94
|
+
match = _ref2.match,
|
|
95
|
+
props = _ref2.props;
|
|
98
96
|
if (match != null && typeof match !== 'object') {
|
|
99
97
|
throw new Error('MatchContainer: Expected `match` value to be an object or null/undefined.');
|
|
100
|
-
}
|
|
98
|
+
}
|
|
99
|
+
// NOTE: the MatchPointer type has a $fragmentSpreads field to ensure that only
|
|
101
100
|
// an object that contains a FragmentSpread can be passed. If the fragment
|
|
102
101
|
// spread matches, then the metadata fields below (__id, __fragments, etc.)
|
|
103
102
|
// will be present. But they can be missing if all the fragment spreads use
|
|
104
103
|
// @module and none of the types matched. The cast here is necessary because
|
|
105
104
|
// fragment Flow types don't describe metadata fields, only the actual schema
|
|
106
105
|
// fields the developer selected.
|
|
107
|
-
|
|
108
|
-
|
|
109
106
|
var _ref3 = (_ref = match) !== null && _ref !== void 0 ? _ref : {},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
__id = _ref3.__id,
|
|
108
|
+
__fragments = _ref3.__fragments,
|
|
109
|
+
__fragmentOwner = _ref3.__fragmentOwner,
|
|
110
|
+
__fragmentPropName = _ref3.__fragmentPropName,
|
|
111
|
+
__module_component = _ref3.__module_component;
|
|
116
112
|
if (__fragmentOwner != null && typeof __fragmentOwner !== 'object' || __fragmentPropName != null && typeof __fragmentPropName !== 'string' || __fragments != null && typeof __fragments !== 'object' || __id != null && typeof __id !== 'string') {
|
|
117
113
|
throw new Error("MatchContainer: Invalid 'match' value, expected an object that has a " + "'...SomeFragment' spread.");
|
|
118
114
|
}
|
|
119
|
-
|
|
120
115
|
var LoadedContainer = __module_component != null ? loader(__module_component) : null;
|
|
121
116
|
var fragmentProps = useMemo(function () {
|
|
122
117
|
// TODO: Perform this transformation in RelayReader so that unchanged
|
|
@@ -130,10 +125,8 @@ function MatchContainer(_ref2) {
|
|
|
130
125
|
};
|
|
131
126
|
return fragProps;
|
|
132
127
|
}
|
|
133
|
-
|
|
134
128
|
return null;
|
|
135
129
|
}, [__id, __fragments, __fragmentOwner, __fragmentPropName]);
|
|
136
|
-
|
|
137
130
|
if (LoadedContainer != null && fragmentProps != null) {
|
|
138
131
|
// $FlowFixMe[incompatible-type]
|
|
139
132
|
// $FlowFixMe[cannot-spread-indexer]
|
|
@@ -142,5 +135,4 @@ function MatchContainer(_ref2) {
|
|
|
142
135
|
return fallback !== null && fallback !== void 0 ? fallback : null;
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
|
-
|
|
146
138
|
module.exports = MatchContainer;
|
|
@@ -4,17 +4,18 @@
|
|
|
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
|
-
* @emails oncall+relay
|
|
8
7
|
*
|
|
9
8
|
* @format
|
|
9
|
+
* @oncall relay
|
|
10
10
|
*/
|
|
11
|
+
|
|
11
12
|
// This contextual profiler can be used to wrap a react sub-tree. It will bind
|
|
12
13
|
// the RelayProfiler during the render phase of these components. Allows
|
|
13
14
|
// collecting metrics for a specific part of your application.
|
|
15
|
+
|
|
14
16
|
'use strict';
|
|
15
17
|
|
|
16
18
|
var React = require('react');
|
|
17
|
-
|
|
18
19
|
var ProfilerContext = React.createContext({
|
|
19
20
|
wrapPrepareQueryResource: function wrapPrepareQueryResource(cb) {
|
|
20
21
|
return cb();
|