react-relay 14.1.0 → 16.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 +20 -10
- package/ReactRelayQueryRenderer.js.flow +15 -11
- package/ReactRelayQueryRendererContext.js.flow +1 -0
- package/ReactRelayRefetchContainer.js.flow +9 -5
- package/ReactRelayTestMocker.js.flow +3 -1
- package/ReactRelayTypes.js.flow +2 -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 +10 -6
- 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 +0 -11
- package/lib/ReactRelayContext.js +1 -12
- package/lib/ReactRelayFragmentContainer.js +23 -122
- package/lib/ReactRelayFragmentMockRenderer.js +0 -12
- package/lib/ReactRelayLocalQueryRenderer.js +12 -41
- package/lib/ReactRelayPaginationContainer.js +45 -341
- package/lib/ReactRelayQueryFetcher.js +36 -111
- package/lib/ReactRelayQueryRenderer.js +29 -137
- package/lib/ReactRelayQueryRendererContext.js +0 -10
- package/lib/ReactRelayRefetchContainer.js +33 -166
- package/lib/ReactRelayTestMocker.js +18 -128
- package/lib/ReactRelayTypes.js +0 -9
- package/lib/RelayContext.js +0 -23
- package/lib/assertFragmentMap.js +0 -16
- package/lib/buildReactRelayContainer.js +7 -41
- package/lib/getRootVariablesForFragments.js +2 -19
- package/lib/hooks.js +3 -30
- package/lib/index.js +3 -39
- package/lib/isRelayEnvironment.js +1 -16
- package/lib/jest-react/enqueueTask.js +1 -25
- package/lib/jest-react/index.js +0 -1
- package/lib/jest-react/internalAct.js +2 -51
- package/lib/legacy.js +0 -20
- package/lib/multi-actor/ActorChange.js +0 -14
- package/lib/multi-actor/index.js +0 -10
- package/lib/multi-actor/useRelayActorEnvironment.js +2 -16
- package/lib/relay-hooks/EntryPointContainer.react.js +7 -23
- package/lib/relay-hooks/EntryPointTypes.flow.js +0 -10
- package/lib/relay-hooks/FragmentResource.js +130 -280
- package/lib/relay-hooks/HooksImplementation.js +0 -14
- package/lib/relay-hooks/InternalLogger.js +0 -11
- package/lib/relay-hooks/LRUCache.js +0 -39
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +27 -65
- package/lib/relay-hooks/MatchContainer.js +9 -111
- package/lib/relay-hooks/NestedRelayEntryPointBuilderUtils.js +9 -0
- package/lib/relay-hooks/ProfilerContext.js +0 -14
- package/lib/relay-hooks/QueryResource.js +14 -149
- package/lib/relay-hooks/RelayEnvironmentProvider.js +3 -17
- package/lib/relay-hooks/SuspenseResource.js +2 -59
- package/lib/relay-hooks/loadEntryPoint.js +10 -45
- package/lib/relay-hooks/loadQuery.js +29 -169
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +8 -58
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +6 -24
- package/lib/relay-hooks/react-cache/RelayReactCache.js +4 -20
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +13 -102
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +18 -75
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +79 -222
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +3 -27
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +11 -33
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +62 -85
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +20 -63
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +53 -179
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +5 -27
- package/lib/relay-hooks/useBlockingPaginationFragment.js +58 -121
- package/lib/relay-hooks/useClientQuery.js +0 -21
- package/lib/relay-hooks/useEntryPointLoader.js +12 -100
- package/lib/relay-hooks/useFetchTrackingRef.js +6 -33
- package/lib/relay-hooks/useFragment.js +5 -32
- package/lib/relay-hooks/useFragmentNode.js +14 -55
- package/lib/relay-hooks/useIsMountedRef.js +2 -14
- package/lib/relay-hooks/useIsOperationNodeActive.js +6 -29
- package/lib/relay-hooks/useIsParentQueryActive.js +1 -15
- package/lib/relay-hooks/useLazyLoadQuery.js +2 -23
- package/lib/relay-hooks/useLazyLoadQueryNode.js +18 -63
- package/lib/relay-hooks/useLoadMoreFunction.js +44 -100
- package/lib/relay-hooks/useMemoOperationDescriptor.js +4 -23
- package/lib/relay-hooks/useMemoVariables.js +8 -43
- package/lib/relay-hooks/useMutation.js +6 -34
- package/lib/relay-hooks/usePaginationFragment.js +49 -89
- package/lib/relay-hooks/usePreloadedQuery.js +10 -54
- package/lib/relay-hooks/useQueryLoader.js +18 -116
- package/lib/relay-hooks/useRefetchableFragment.js +4 -30
- package/lib/relay-hooks/useRefetchableFragmentNode.js +58 -184
- package/lib/relay-hooks/useRelayEnvironment.js +2 -16
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -20
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -28
- package/lib/relay-hooks/useSubscription.js +3 -22
- package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +12 -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 +6 -1
- package/relay-hooks/EntryPointTypes.flow.js.flow +23 -20
- package/relay-hooks/FragmentResource.js.flow +148 -34
- 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 +19 -10
- package/relay-hooks/MatchContainer.js.flow +1 -1
- package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +51 -0
- 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 +9 -7
- 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 +40 -33
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +38 -32
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +20 -18
- package/relay-hooks/__flowtests__/utils.js.flow +13 -2
- package/relay-hooks/loadEntryPoint.js.flow +15 -8
- package/relay-hooks/loadQuery.js.flow +32 -8
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +17 -10
- 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 +5 -4
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +32 -14
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +4 -10
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +39 -49
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +29 -16
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +17 -33
- package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -58
- package/relay-hooks/useClientQuery.js.flow +3 -3
- 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 +7 -6
- 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 +27 -16
- package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
- package/relay-hooks/useMemoVariables.js.flow +13 -29
- package/relay-hooks/useMutation.js.flow +30 -13
- package/relay-hooks/usePaginationFragment.js.flow +55 -54
- package/relay-hooks/usePreloadedQuery.js.flow +47 -22
- package/relay-hooks/useQueryLoader.js.flow +78 -21
- package/relay-hooks/useRefetchableFragment.js.flow +65 -33
- package/relay-hooks/useRefetchableFragmentNode.js.flow +38 -17
- 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
|
@@ -1,28 +1,14 @@
|
|
|
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
1
|
'use strict';
|
|
12
2
|
|
|
13
3
|
var warning = require("fbjs/lib/warning");
|
|
14
|
-
|
|
15
4
|
var implementation = null;
|
|
16
|
-
|
|
17
5
|
function inject(impl) {
|
|
18
6
|
process.env.NODE_ENV !== "production" ? warning(implementation !== null, 'Relay HooksImplementation was injected twice.') : void 0;
|
|
19
7
|
implementation = impl;
|
|
20
8
|
}
|
|
21
|
-
|
|
22
9
|
function get() {
|
|
23
10
|
return implementation;
|
|
24
11
|
}
|
|
25
|
-
|
|
26
12
|
module.exports = {
|
|
27
13
|
inject: inject,
|
|
28
14
|
get: get
|
|
@@ -1,17 +1,6 @@
|
|
|
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
1
|
'use strict';
|
|
12
2
|
|
|
13
3
|
var loggerImpl = function loggerImpl(eventData) {};
|
|
14
|
-
|
|
15
4
|
module.exports = {
|
|
16
5
|
setLoggerImplementation: function setLoggerImplementation(loggerFn) {
|
|
17
6
|
loggerImpl = loggerFn;
|
|
@@ -1,90 +1,51 @@
|
|
|
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
|
-
* @emails oncall+relay
|
|
9
|
-
* @format
|
|
10
|
-
*/
|
|
11
1
|
'use strict';
|
|
12
2
|
|
|
13
3
|
var invariant = require('invariant');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* JS maps (both plain objects and Map) maintain key insertion
|
|
17
|
-
* order, which means there is an easy way to simulate LRU behavior
|
|
18
|
-
* that should also perform quite well:
|
|
19
|
-
*
|
|
20
|
-
* To insert a new value, first delete the key from the inner _map,
|
|
21
|
-
* then _map.set(k, v). By deleting and reinserting, you ensure that the
|
|
22
|
-
* map sees the key as the last inserted key.
|
|
23
|
-
*
|
|
24
|
-
* Get does the same: if the key is present, delete and reinsert it.
|
|
25
|
-
*/
|
|
26
4
|
var LRUCache = /*#__PURE__*/function () {
|
|
27
5
|
function LRUCache(capacity) {
|
|
28
6
|
this._capacity = capacity;
|
|
29
7
|
!(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
8
|
this._map = new Map();
|
|
31
9
|
}
|
|
32
|
-
|
|
33
10
|
var _proto = LRUCache.prototype;
|
|
34
|
-
|
|
35
11
|
_proto.set = function set(key, value) {
|
|
36
12
|
this._map["delete"](key);
|
|
37
|
-
|
|
38
13
|
this._map.set(key, value);
|
|
39
|
-
|
|
40
14
|
if (this._map.size > this._capacity) {
|
|
41
15
|
var firstKey = this._map.keys().next();
|
|
42
|
-
|
|
43
16
|
if (!firstKey.done) {
|
|
44
17
|
this._map["delete"](firstKey.value);
|
|
45
18
|
}
|
|
46
19
|
}
|
|
47
20
|
};
|
|
48
|
-
|
|
49
21
|
_proto.get = function get(key) {
|
|
50
22
|
var value = this._map.get(key);
|
|
51
|
-
|
|
52
23
|
if (value != null) {
|
|
53
24
|
this._map["delete"](key);
|
|
54
|
-
|
|
55
25
|
this._map.set(key, value);
|
|
56
26
|
}
|
|
57
|
-
|
|
58
27
|
return value;
|
|
59
28
|
};
|
|
60
|
-
|
|
61
29
|
_proto.has = function has(key) {
|
|
62
30
|
return this._map.has(key);
|
|
63
31
|
};
|
|
64
|
-
|
|
65
32
|
_proto["delete"] = function _delete(key) {
|
|
66
33
|
this._map["delete"](key);
|
|
67
34
|
};
|
|
68
|
-
|
|
69
35
|
_proto.size = function size() {
|
|
70
36
|
return this._map.size;
|
|
71
37
|
};
|
|
72
|
-
|
|
73
38
|
_proto.capacity = function capacity() {
|
|
74
39
|
return this._capacity - this._map.size;
|
|
75
40
|
};
|
|
76
|
-
|
|
77
41
|
_proto.clear = function clear() {
|
|
78
42
|
this._map.clear();
|
|
79
43
|
};
|
|
80
|
-
|
|
81
44
|
return LRUCache;
|
|
82
45
|
}();
|
|
83
|
-
|
|
84
46
|
function create(capacity) {
|
|
85
47
|
return new LRUCache(capacity);
|
|
86
48
|
}
|
|
87
|
-
|
|
88
49
|
module.exports = {
|
|
89
50
|
create: create
|
|
90
51
|
};
|
|
@@ -1,127 +1,90 @@
|
|
|
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
1
|
'use strict';
|
|
12
2
|
|
|
13
3
|
var preloadQuery_DEPRECATED = require('./preloadQuery_DEPRECATED');
|
|
14
|
-
|
|
15
4
|
var ProfilerContext = require('./ProfilerContext');
|
|
16
|
-
|
|
17
5
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
|
18
|
-
|
|
19
6
|
var React = require('react');
|
|
20
|
-
|
|
21
7
|
var _require = require('react'),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
useContext = _require.useContext,
|
|
9
|
+
useEffect = _require.useEffect,
|
|
10
|
+
useMemo = _require.useMemo;
|
|
26
11
|
var _require2 = require('relay-runtime'),
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
stableCopy = _require2.stableCopy;
|
|
29
13
|
function stableStringify(value) {
|
|
30
14
|
var _JSON$stringify;
|
|
31
|
-
|
|
32
15
|
return (_JSON$stringify = JSON.stringify(stableCopy(value))) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : 'null';
|
|
33
16
|
}
|
|
34
|
-
|
|
35
17
|
function prepareEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
|
36
|
-
// Start loading the code for the entrypoint
|
|
37
18
|
var loadingPromise = null;
|
|
38
|
-
|
|
39
19
|
if (entryPoint.root.getModuleIfRequired() == null) {
|
|
40
20
|
loadingPromise = entryPoint.root.load();
|
|
41
21
|
}
|
|
42
|
-
|
|
43
22
|
var preloadProps = entryPoint.getPreloadProps(entryPointParams);
|
|
44
23
|
var queries = preloadProps.queries,
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
entryPoints = preloadProps.entryPoints,
|
|
25
|
+
extraProps = preloadProps.extraProps;
|
|
47
26
|
var preloadedQueries = {};
|
|
48
27
|
var preloadedEntryPoints = {};
|
|
49
|
-
|
|
50
28
|
if (queries != null) {
|
|
51
29
|
var queriesPropNames = Object.keys(queries);
|
|
52
30
|
queriesPropNames.forEach(function (queryPropName) {
|
|
53
31
|
var _queries$queryPropNam = queries[queryPropName],
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
32
|
+
environmentProviderOptions = _queries$queryPropNam.environmentProviderOptions,
|
|
33
|
+
options = _queries$queryPropNam.options,
|
|
34
|
+
parameters = _queries$queryPropNam.parameters,
|
|
35
|
+
variables = _queries$queryPropNam.variables;
|
|
58
36
|
var environment = environmentProvider.getEnvironment(environmentProviderOptions);
|
|
59
37
|
preloadedQueries[queryPropName] = preloadQuery_DEPRECATED(environment, parameters, variables, options, environmentProviderOptions);
|
|
60
38
|
});
|
|
61
39
|
}
|
|
62
|
-
|
|
63
40
|
if (entryPoints != null) {
|
|
64
41
|
var entryPointPropNames = Object.keys(entryPoints);
|
|
65
42
|
entryPointPropNames.forEach(function (entryPointPropName) {
|
|
66
43
|
var entryPointDescription = entryPoints[entryPointPropName];
|
|
67
|
-
|
|
68
44
|
if (entryPointDescription == null) {
|
|
69
45
|
return;
|
|
70
46
|
}
|
|
71
|
-
|
|
72
47
|
var nestedEntryPoint = entryPointDescription.entryPoint,
|
|
73
|
-
|
|
48
|
+
nestedParams = entryPointDescription.entryPointParams;
|
|
74
49
|
preloadedEntryPoints[entryPointPropName] = prepareEntryPoint(environmentProvider, nestedEntryPoint, nestedParams);
|
|
75
50
|
});
|
|
76
51
|
}
|
|
77
|
-
|
|
78
52
|
return {
|
|
79
53
|
entryPoints: preloadedEntryPoints,
|
|
80
54
|
extraProps: extraProps !== null && extraProps !== void 0 ? extraProps : null,
|
|
81
55
|
getComponent: function getComponent() {
|
|
82
56
|
var component = entryPoint.root.getModuleIfRequired();
|
|
83
|
-
|
|
84
57
|
if (component == null) {
|
|
85
58
|
var _loadingPromise;
|
|
86
|
-
|
|
87
59
|
loadingPromise = (_loadingPromise = loadingPromise) !== null && _loadingPromise !== void 0 ? _loadingPromise : entryPoint.root.load();
|
|
88
60
|
throw loadingPromise;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
61
|
+
}
|
|
92
62
|
return component;
|
|
93
63
|
},
|
|
94
64
|
queries: preloadedQueries,
|
|
95
65
|
rootModuleID: entryPoint.root.getModuleId()
|
|
96
66
|
};
|
|
97
67
|
}
|
|
98
|
-
|
|
99
68
|
function LazyLoadEntryPointContainer_DEPRECATED(_ref) {
|
|
100
69
|
var entryPoint = _ref.entryPoint,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
70
|
+
entryPointParams = _ref.entryPointParams,
|
|
71
|
+
props = _ref.props,
|
|
72
|
+
environmentProvider = _ref.environmentProvider;
|
|
104
73
|
var environment = useRelayEnvironment();
|
|
105
|
-
var getPreloadProps = entryPoint.getPreloadProps;
|
|
106
|
-
// *must* be computed first to fetch the component's data-dependencies in
|
|
107
|
-
// parallel with the component itself (the code).
|
|
108
|
-
|
|
74
|
+
var getPreloadProps = entryPoint.getPreloadProps;
|
|
109
75
|
var entryPointParamsHash = stableStringify(entryPointParams);
|
|
110
|
-
|
|
111
76
|
var _useMemo = useMemo(function () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
rootModuleID = _useMemo.rootModuleID;
|
|
124
|
-
|
|
77
|
+
return prepareEntryPoint(environmentProvider !== null && environmentProvider !== void 0 ? environmentProvider : {
|
|
78
|
+
getEnvironment: function getEnvironment() {
|
|
79
|
+
return environment;
|
|
80
|
+
}
|
|
81
|
+
}, entryPoint, entryPointParams);
|
|
82
|
+
}, [environment, environmentProvider, getPreloadProps, entryPointParamsHash]),
|
|
83
|
+
getComponent = _useMemo.getComponent,
|
|
84
|
+
queries = _useMemo.queries,
|
|
85
|
+
entryPoints = _useMemo.entryPoints,
|
|
86
|
+
extraProps = _useMemo.extraProps,
|
|
87
|
+
rootModuleID = _useMemo.rootModuleID;
|
|
125
88
|
var Component = useMemo(function () {
|
|
126
89
|
return getComponent();
|
|
127
90
|
}, [getComponent]);
|
|
@@ -140,5 +103,4 @@ function LazyLoadEntryPointContainer_DEPRECATED(_ref) {
|
|
|
140
103
|
queries: queries
|
|
141
104
|
});
|
|
142
105
|
}
|
|
143
|
-
|
|
144
106
|
module.exports = LazyLoadEntryPointContainer_DEPRECATED;
|
|
@@ -1,126 +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
|
-
* @emails oncall+relay
|
|
8
|
-
*
|
|
9
|
-
* @format
|
|
10
|
-
*/
|
|
11
1
|
'use strict';
|
|
12
2
|
|
|
13
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
14
|
-
|
|
15
4
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
|
-
|
|
17
5
|
var React = require('react');
|
|
18
|
-
|
|
19
6
|
var useMemo = React.useMemo;
|
|
20
|
-
/**
|
|
21
|
-
* Renders the results of a data-driven dependency fetched with the `@match`
|
|
22
|
-
* directive. The `@match` directive can be used to specify a mapping of
|
|
23
|
-
* result types to the containers used to render those types. The result
|
|
24
|
-
* value is an opaque object that described which component was selected
|
|
25
|
-
* and a reference to its data. Use <MatchContainer/> to render these
|
|
26
|
-
* values.
|
|
27
|
-
*
|
|
28
|
-
* ## Example
|
|
29
|
-
*
|
|
30
|
-
* For example, consider a piece of media content that might be text or
|
|
31
|
-
* an image, where for clients that don't support images the application
|
|
32
|
-
* should fall back to rendering the image caption as text. @match can be
|
|
33
|
-
* used to dynamically select whether to render a given media item as
|
|
34
|
-
* an image or text (on the server) and then fetch the corresponding
|
|
35
|
-
* React component and its data dependencies (information about the
|
|
36
|
-
* image or about the text).
|
|
37
|
-
*
|
|
38
|
-
* ```
|
|
39
|
-
* // Media.react.js
|
|
40
|
-
*
|
|
41
|
-
* // Define a React component that uses <MatchContainer /> to render the
|
|
42
|
-
* // results of a @module selection
|
|
43
|
-
* function Media(props) {
|
|
44
|
-
* const {media, ...restProps} = props;
|
|
45
|
-
*
|
|
46
|
-
* const loader = moduleReference => {
|
|
47
|
-
* // given the data returned by your server for the @module directive,
|
|
48
|
-
* // return the React component (or throw a Suspense promise if
|
|
49
|
-
* // it is loading asynchronously).
|
|
50
|
-
* todo_returnModuleOrThrowPromise(moduleReference);
|
|
51
|
-
* };
|
|
52
|
-
* return <MatchContainer
|
|
53
|
-
* loader={loader}
|
|
54
|
-
* match={media.mediaAttachment}
|
|
55
|
-
* props={restProps}
|
|
56
|
-
* />;
|
|
57
|
-
* }
|
|
58
|
-
*
|
|
59
|
-
* module.exports = createSuspenseFragmentContainer(
|
|
60
|
-
* Media,
|
|
61
|
-
* {
|
|
62
|
-
* media: graphql`
|
|
63
|
-
* fragment Media_media on Media {
|
|
64
|
-
* # ...
|
|
65
|
-
* mediaAttachment @match {
|
|
66
|
-
* ...ImageContainer_image @module(name: "ImageContainer.react")
|
|
67
|
-
* ...TextContainer_text @module(name: "TextContainer.react")
|
|
68
|
-
* }
|
|
69
|
-
* }
|
|
70
|
-
* `
|
|
71
|
-
* },
|
|
72
|
-
* );
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ## API
|
|
76
|
-
*
|
|
77
|
-
* MatchContainer accepts the following props:
|
|
78
|
-
* - `match`: The results (an opaque object) of a `@match` field.
|
|
79
|
-
* - `props`: Props that should be passed through to the dynamically
|
|
80
|
-
* selected component. Note that any of the components listed in
|
|
81
|
-
* `@module()` could be selected, so all components should accept
|
|
82
|
-
* the value passed here.
|
|
83
|
-
* - `loader`: A function to load a module given a reference (whatever
|
|
84
|
-
* your server returns for the `js(moduleName: String)` field).
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
// Note: this type is intentionally non-exact, it is expected that the
|
|
88
|
-
// object may contain sibling fields.
|
|
89
|
-
|
|
90
7
|
function MatchContainer(_ref2) {
|
|
91
8
|
var _ref;
|
|
92
|
-
|
|
93
9
|
var fallback = _ref2.fallback,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
10
|
+
loader = _ref2.loader,
|
|
11
|
+
match = _ref2.match,
|
|
12
|
+
props = _ref2.props;
|
|
98
13
|
if (match != null && typeof match !== 'object') {
|
|
99
14
|
throw new Error('MatchContainer: Expected `match` value to be an object or null/undefined.');
|
|
100
|
-
}
|
|
101
|
-
// an object that contains a FragmentSpread can be passed. If the fragment
|
|
102
|
-
// spread matches, then the metadata fields below (__id, __fragments, etc.)
|
|
103
|
-
// will be present. But they can be missing if all the fragment spreads use
|
|
104
|
-
// @module and none of the types matched. The cast here is necessary because
|
|
105
|
-
// fragment Flow types don't describe metadata fields, only the actual schema
|
|
106
|
-
// fields the developer selected.
|
|
107
|
-
|
|
108
|
-
|
|
15
|
+
}
|
|
109
16
|
var _ref3 = (_ref = match) !== null && _ref !== void 0 ? _ref : {},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
17
|
+
__id = _ref3.__id,
|
|
18
|
+
__fragments = _ref3.__fragments,
|
|
19
|
+
__fragmentOwner = _ref3.__fragmentOwner,
|
|
20
|
+
__fragmentPropName = _ref3.__fragmentPropName,
|
|
21
|
+
__module_component = _ref3.__module_component;
|
|
116
22
|
if (__fragmentOwner != null && typeof __fragmentOwner !== 'object' || __fragmentPropName != null && typeof __fragmentPropName !== 'string' || __fragments != null && typeof __fragments !== 'object' || __id != null && typeof __id !== 'string') {
|
|
117
23
|
throw new Error("MatchContainer: Invalid 'match' value, expected an object that has a " + "'...SomeFragment' spread.");
|
|
118
24
|
}
|
|
119
|
-
|
|
120
25
|
var LoadedContainer = __module_component != null ? loader(__module_component) : null;
|
|
121
26
|
var fragmentProps = useMemo(function () {
|
|
122
|
-
// TODO: Perform this transformation in RelayReader so that unchanged
|
|
123
|
-
// output of subscriptions already has a stable identity.
|
|
124
27
|
if (__fragmentPropName != null && __id != null && __fragments != null) {
|
|
125
28
|
var fragProps = {};
|
|
126
29
|
fragProps[__fragmentPropName] = {
|
|
@@ -130,17 +33,12 @@ function MatchContainer(_ref2) {
|
|
|
130
33
|
};
|
|
131
34
|
return fragProps;
|
|
132
35
|
}
|
|
133
|
-
|
|
134
36
|
return null;
|
|
135
37
|
}, [__id, __fragments, __fragmentOwner, __fragmentPropName]);
|
|
136
|
-
|
|
137
38
|
if (LoadedContainer != null && fragmentProps != null) {
|
|
138
|
-
// $FlowFixMe[incompatible-type]
|
|
139
|
-
// $FlowFixMe[cannot-spread-indexer]
|
|
140
39
|
return /*#__PURE__*/React.createElement(LoadedContainer, (0, _extends2["default"])({}, props, fragmentProps));
|
|
141
40
|
} else {
|
|
142
41
|
return fallback !== null && fallback !== void 0 ? fallback : null;
|
|
143
42
|
}
|
|
144
43
|
}
|
|
145
|
-
|
|
146
44
|
module.exports = MatchContainer;
|
|
@@ -1,20 +1,6 @@
|
|
|
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
|
-
// This contextual profiler can be used to wrap a react sub-tree. It will bind
|
|
12
|
-
// the RelayProfiler during the render phase of these components. Allows
|
|
13
|
-
// collecting metrics for a specific part of your application.
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
var React = require('react');
|
|
17
|
-
|
|
18
4
|
var ProfilerContext = React.createContext({
|
|
19
5
|
wrapPrepareQueryResource: function wrapPrepareQueryResource(cb) {
|
|
20
6
|
return cb();
|