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