react-instantsearch-core 7.24.0 → 7.26.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/dist/cjs/components/Configure.js +11 -17
- package/dist/cjs/components/DynamicWidgets.js +46 -53
- package/dist/cjs/components/Index.js +19 -22
- package/dist/cjs/components/InstantSearch.js +34 -36
- package/dist/cjs/components/InstantSearchSSRProvider.js +31 -41
- package/dist/cjs/components/InstantSearchServerContext.js +6 -10
- package/dist/cjs/connectors/useAutocomplete.js +8 -10
- package/dist/cjs/connectors/useBreadcrumb.js +8 -10
- package/dist/cjs/connectors/useChat.js +8 -10
- package/dist/cjs/connectors/useClearRefinements.js +8 -10
- package/dist/cjs/connectors/useConfigure.js +10 -12
- package/dist/cjs/connectors/useCurrentRefinements.js +8 -10
- package/dist/cjs/connectors/useDynamicWidgets.js +14 -20
- package/dist/cjs/connectors/useFilterSuggestions.js +8 -10
- package/dist/cjs/connectors/useFrequentlyBoughtTogether.js +8 -10
- package/dist/cjs/connectors/useGeoSearch.js +8 -10
- package/dist/cjs/connectors/useHierarchicalMenu.js +8 -10
- package/dist/cjs/connectors/useHits.js +8 -10
- package/dist/cjs/connectors/useHitsPerPage.js +8 -10
- package/dist/cjs/connectors/useInfiniteHits.js +8 -10
- package/dist/cjs/connectors/useLookingSimilar.js +8 -10
- package/dist/cjs/connectors/useMenu.js +8 -10
- package/dist/cjs/connectors/useNumericMenu.js +8 -10
- package/dist/cjs/connectors/usePagination.js +8 -10
- package/dist/cjs/connectors/usePoweredBy.js +18 -19
- package/dist/cjs/connectors/useQueryRules.js +8 -10
- package/dist/cjs/connectors/useRange.js +8 -10
- package/dist/cjs/connectors/useRefinementList.js +8 -10
- package/dist/cjs/connectors/useRelatedProducts.js +8 -10
- package/dist/cjs/connectors/useSearchBox.js +8 -10
- package/dist/cjs/connectors/useSortBy.js +8 -10
- package/dist/cjs/connectors/useStats.js +8 -10
- package/dist/cjs/connectors/useToggleRefinement.js +8 -10
- package/dist/cjs/connectors/useTrendingItems.js +8 -10
- package/dist/cjs/hooks/useConnector.js +123 -139
- package/dist/cjs/hooks/useInstantSearch.js +59 -59
- package/dist/cjs/index.js +90 -519
- package/dist/cjs/lib/IndexContext.js +6 -10
- package/dist/cjs/lib/InstantSearchContext.js +6 -10
- package/dist/cjs/lib/InstantSearchRSCContext.js +11 -12
- package/dist/cjs/lib/InstantSearchSSRContext.js +6 -10
- package/dist/cjs/lib/createSearchResults.js +24 -25
- package/dist/cjs/lib/dequal.js +33 -40
- package/dist/cjs/lib/getIndexSearchResults.js +23 -30
- package/dist/cjs/lib/invariant.js +11 -17
- package/dist/cjs/lib/noop.js +8 -6
- package/dist/cjs/lib/use.js +26 -11
- package/dist/cjs/lib/useAppIdAndApiKey.js +10 -12
- package/dist/cjs/lib/useForceUpdate.js +12 -21
- package/dist/cjs/lib/useIndex.js +40 -37
- package/dist/cjs/lib/useIndexContext.js +11 -12
- package/dist/cjs/lib/useInstantSearchApi.js +174 -197
- package/dist/cjs/lib/useInstantSearchContext.js +11 -12
- package/dist/cjs/lib/useInstantSearchSSRContext.js +8 -9
- package/dist/cjs/lib/useInstantSearchServerContext.js +8 -9
- package/dist/cjs/lib/useIsomorphicLayoutEffect.js +6 -8
- package/dist/cjs/lib/useRSCContext.js +8 -9
- package/dist/cjs/lib/useSearchResults.js +54 -62
- package/dist/cjs/lib/useSearchState.js +53 -60
- package/dist/cjs/lib/useStableValue.js +15 -24
- package/dist/cjs/lib/useWidget.js +99 -95
- package/dist/cjs/lib/warn.js +11 -35
- package/dist/cjs/lib/wrapPromiseWithState.js +23 -26
- package/dist/cjs/package.json +4 -1
- package/dist/cjs/server/getServerState.js +81 -91
- package/dist/cjs/server/index.js +6 -15
- package/dist/cjs/version.js +6 -6
- package/dist/es/components/Configure.js +11 -13
- package/dist/es/components/DynamicWidgets.js +45 -47
- package/dist/es/components/Index.js +19 -17
- package/dist/es/components/InstantSearch.js +33 -29
- package/dist/es/components/InstantSearchSSRProvider.js +30 -35
- package/dist/es/components/InstantSearchServerContext.js +4 -4
- package/dist/es/connectors/useAutocomplete.js +8 -5
- package/dist/es/connectors/useBreadcrumb.js +8 -5
- package/dist/es/connectors/useChat.js +8 -5
- package/dist/es/connectors/useClearRefinements.js +8 -5
- package/dist/es/connectors/useConfigure.js +10 -7
- package/dist/es/connectors/useCurrentRefinements.js +8 -5
- package/dist/es/connectors/useDynamicWidgets.js +14 -15
- package/dist/es/connectors/useFilterSuggestions.js +8 -5
- package/dist/es/connectors/useFrequentlyBoughtTogether.js +8 -5
- package/dist/es/connectors/useGeoSearch.js +8 -5
- package/dist/es/connectors/useHierarchicalMenu.js +8 -5
- package/dist/es/connectors/useHits.js +8 -5
- package/dist/es/connectors/useHitsPerPage.js +8 -5
- package/dist/es/connectors/useInfiniteHits.js +8 -5
- package/dist/es/connectors/useLookingSimilar.js +8 -5
- package/dist/es/connectors/useMenu.js +8 -5
- package/dist/es/connectors/useNumericMenu.js +8 -5
- package/dist/es/connectors/usePagination.js +8 -5
- package/dist/es/connectors/usePoweredBy.js +18 -15
- package/dist/es/connectors/useQueryRules.js +8 -5
- package/dist/es/connectors/useRange.js +8 -5
- package/dist/es/connectors/useRefinementList.js +8 -5
- package/dist/es/connectors/useRelatedProducts.js +8 -5
- package/dist/es/connectors/useSearchBox.js +8 -5
- package/dist/es/connectors/useSortBy.js +8 -5
- package/dist/es/connectors/useStats.js +8 -5
- package/dist/es/connectors/useToggleRefinement.js +8 -5
- package/dist/es/connectors/useTrendingItems.js +8 -5
- package/dist/es/hooks/useConnector.js +122 -134
- package/dist/es/hooks/useInstantSearch.js +58 -54
- package/dist/es/index.js +43 -43
- package/dist/es/lib/IndexContext.js +4 -4
- package/dist/es/lib/InstantSearchContext.js +4 -4
- package/dist/es/lib/InstantSearchRSCContext.js +10 -7
- package/dist/es/lib/InstantSearchSSRContext.js +4 -4
- package/dist/es/lib/createSearchResults.js +23 -19
- package/dist/es/lib/dequal.js +33 -36
- package/dist/es/lib/getIndexSearchResults.js +23 -26
- package/dist/es/lib/invariant.js +10 -12
- package/dist/es/lib/noop.js +7 -1
- package/dist/es/lib/use.js +4 -2
- package/dist/es/lib/useAppIdAndApiKey.js +9 -7
- package/dist/es/lib/useForceUpdate.js +9 -15
- package/dist/es/lib/useIndex.js +39 -31
- package/dist/es/lib/useIndexContext.js +10 -7
- package/dist/es/lib/useInstantSearchApi.js +174 -191
- package/dist/es/lib/useInstantSearchContext.js +10 -7
- package/dist/es/lib/useInstantSearchSSRContext.js +7 -4
- package/dist/es/lib/useInstantSearchServerContext.js +7 -4
- package/dist/es/lib/useIsomorphicLayoutEffect.js +4 -3
- package/dist/es/lib/useRSCContext.js +7 -4
- package/dist/es/lib/useSearchResults.js +53 -57
- package/dist/es/lib/useSearchState.js +52 -55
- package/dist/es/lib/useStableValue.js +14 -19
- package/dist/es/lib/useWidget.js +98 -90
- package/dist/es/lib/warn.js +9 -29
- package/dist/es/lib/wrapPromiseWithState.js +23 -22
- package/dist/es/package.json +4 -0
- package/dist/es/server/getServerState.js +80 -85
- package/dist/es/server/index.js +1 -1
- package/dist/es/version.d.ts +1 -1
- package/dist/es/version.js +3 -1
- package/dist/umd/ReactInstantSearchCore.js +17488 -22329
- package/dist/umd/ReactInstantSearchCore.min.js +3 -3
- package/package.json +7 -11
- package/dist/umd/ReactInstantSearchCore.js.map +0 -1
- package/dist/umd/ReactInstantSearchCore.min.js.map +0 -1
package/dist/es/lib/dequal.js
CHANGED
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable complexity */
|
|
1
|
+
import { _ } from '@swc/helpers/cjs/_type_of.cjs';
|
|
3
2
|
|
|
4
|
-
/*
|
|
3
|
+
/* eslint-disable complexity */ /*
|
|
5
4
|
* Code taken from dequal/lite v2.0.0
|
|
6
5
|
* https://github.com/lukeed/dequal/blob/9aa73181ac7e081cd330cac67d313632ac04bb02/src/lite.js
|
|
7
6
|
*
|
|
8
7
|
* It adds a 3rd argument `compare(a, b)` that lets execute custom logic to
|
|
9
8
|
* compare values.
|
|
10
9
|
* We use it to skip comparing function references.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
10
|
+
*/ // eslint-disable-next-line @typescript-eslint/unbound-method
|
|
14
11
|
var has = Object.prototype.hasOwnProperty;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
// end of custom implementation
|
|
21
|
-
|
|
22
|
-
var ctor;
|
|
23
|
-
var len;
|
|
24
|
-
if (foo === bar) return true;
|
|
25
|
-
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
26
|
-
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
27
|
-
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
28
|
-
if (ctor === Array) {
|
|
29
|
-
if ((len = foo.length) === bar.length) {
|
|
30
|
-
while (len-- && dequal(foo[len], bar[len], compare));
|
|
31
|
-
}
|
|
32
|
-
return len === -1;
|
|
12
|
+
function dequal(foo, bar, compare) {
|
|
13
|
+
// start of custom implementation
|
|
14
|
+
if (compare === null || compare === void 0 ? void 0 : compare(foo, bar)) {
|
|
15
|
+
return true;
|
|
33
16
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
// end of custom implementation
|
|
18
|
+
var ctor;
|
|
19
|
+
var len;
|
|
20
|
+
if (foo === bar) return true;
|
|
21
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
22
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
23
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
24
|
+
if (ctor === Array) {
|
|
25
|
+
if ((len = foo.length) === bar.length) {
|
|
26
|
+
while(len-- && dequal(foo[len], bar[len], compare));
|
|
27
|
+
}
|
|
28
|
+
return len === -1;
|
|
29
|
+
}
|
|
30
|
+
if (!ctor || (typeof foo === "undefined" ? "undefined" : _(foo)) === 'object') {
|
|
31
|
+
len = 0;
|
|
32
|
+
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
33
|
+
for(ctor in foo){
|
|
34
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
35
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor], compare)) return false;
|
|
36
|
+
}
|
|
37
|
+
return Object.keys(bar).length === len;
|
|
38
|
+
}
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
// eslint-disable-next-line no-self-compare
|
|
41
|
+
return foo !== foo && bar !== bar;
|
|
42
|
+
}
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
return foo !== foo && bar !== bar;
|
|
47
|
-
}
|
|
44
|
+
export { dequal };
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var fallbackResults = scopedResult.indexId === indexWidget.getIndexId() ? results : createSearchResults(scopedResult.helper.state);
|
|
17
|
-
return _objectSpread(_objectSpread({}, scopedResult), {}, {
|
|
18
|
-
// We keep `results` from being `null`.
|
|
19
|
-
results: scopedResult.results || fallbackResults
|
|
1
|
+
import { _ as _$1 } from '@swc/helpers/cjs/_object_spread.cjs';
|
|
2
|
+
import { _ } from '@swc/helpers/cjs/_object_spread_props.cjs';
|
|
3
|
+
import { createSearchResults } from './createSearchResults.js';
|
|
4
|
+
|
|
5
|
+
function getIndexSearchResults(indexWidget) {
|
|
6
|
+
var helper = indexWidget.getHelper();
|
|
7
|
+
var results = // On SSR, we get the results injected on the Index.
|
|
8
|
+
indexWidget.getResults() || // On the browser, we create fallback results based on the helper state.
|
|
9
|
+
createSearchResults(helper.state);
|
|
10
|
+
var scopedResults = indexWidget.getScopedResults().map(function(scopedResult) {
|
|
11
|
+
var fallbackResults = scopedResult.indexId === indexWidget.getIndexId() ? results : createSearchResults(scopedResult.helper.state);
|
|
12
|
+
return _(_$1({}, scopedResult), {
|
|
13
|
+
// We keep `results` from being `null`.
|
|
14
|
+
results: scopedResult.results || fallbackResults
|
|
15
|
+
});
|
|
20
16
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
return {
|
|
18
|
+
results: results,
|
|
19
|
+
scopedResults: scopedResults,
|
|
20
|
+
recommendResults: helper.lastRecommendResults
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { getIndexSearchResults };
|
package/dist/es/lib/invariant.js
CHANGED
|
@@ -5,15 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This is used to make development a better experience to provide guidance as
|
|
7
7
|
* to where the error comes from.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
8
|
+
*/ function invariant(condition, message) {
|
|
9
|
+
if (condition) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
{
|
|
13
|
+
throw new Error('Invariant failed');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { invariant };
|
package/dist/es/lib/noop.js
CHANGED
package/dist/es/lib/use.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { getAppIdAndApiKey } from
|
|
2
|
-
import { useInstantSearchContext } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
client =
|
|
6
|
-
|
|
7
|
-
};
|
|
1
|
+
import { getAppIdAndApiKey } from 'instantsearch.js/es/lib/utils/index.js';
|
|
2
|
+
import { useInstantSearchContext } from './useInstantSearchContext.js';
|
|
3
|
+
|
|
4
|
+
var useAppIdAndApiKey = function useAppIdAndApiKey() {
|
|
5
|
+
var client = useInstantSearchContext().client;
|
|
6
|
+
return getAppIdAndApiKey(client);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { useAppIdAndApiKey };
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1
|
+
import { _ } from '@swc/helpers/cjs/_sliced_to_array.cjs';
|
|
7
2
|
import { useReducer } from 'react';
|
|
8
3
|
|
|
9
4
|
/**
|
|
10
5
|
* Forces a React update that triggers a rerender.
|
|
11
6
|
* @link https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
7
|
+
*/ function useForceUpdate() {
|
|
8
|
+
var _useReducer = _(useReducer(function(x) {
|
|
9
|
+
return x + 1;
|
|
10
|
+
}, 0), 2), forceUpdate = _useReducer[1];
|
|
11
|
+
return forceUpdate;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useForceUpdate };
|
package/dist/es/lib/useIndex.js
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
import index from
|
|
1
|
+
import index from 'instantsearch.js/es/widgets/index/index.js';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { useForceUpdate } from
|
|
4
|
-
import { useIndexContext } from
|
|
5
|
-
import { useInstantSearchServerContext } from
|
|
6
|
-
import { useInstantSearchSSRContext } from
|
|
7
|
-
import { useIsomorphicLayoutEffect } from
|
|
8
|
-
import { useStableValue } from
|
|
9
|
-
import { useWidget } from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
3
|
+
import { useForceUpdate } from './useForceUpdate.js';
|
|
4
|
+
import { useIndexContext } from './useIndexContext.js';
|
|
5
|
+
import { useInstantSearchServerContext } from './useInstantSearchServerContext.js';
|
|
6
|
+
import { useInstantSearchSSRContext } from './useInstantSearchSSRContext.js';
|
|
7
|
+
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
|
|
8
|
+
import { useStableValue } from './useStableValue.js';
|
|
9
|
+
import { useWidget } from './useWidget.js';
|
|
10
|
+
|
|
11
|
+
function useIndex(props) {
|
|
12
|
+
var serverContext = useInstantSearchServerContext();
|
|
13
|
+
var ssrContext = useInstantSearchSSRContext();
|
|
14
|
+
var initialResults = ssrContext === null || ssrContext === void 0 ? void 0 : ssrContext.initialResults;
|
|
15
|
+
var parentIndex = useIndexContext();
|
|
16
|
+
var stableProps = useStableValue(props);
|
|
17
|
+
var indexWidget = useMemo(function() {
|
|
18
|
+
return index(stableProps);
|
|
19
|
+
}, [
|
|
20
|
+
stableProps
|
|
21
|
+
]);
|
|
22
|
+
var helper = indexWidget.getHelper();
|
|
23
|
+
var forceUpdate = useForceUpdate();
|
|
24
|
+
useIsomorphicLayoutEffect(function() {
|
|
25
|
+
forceUpdate();
|
|
26
|
+
}, [
|
|
27
|
+
helper,
|
|
28
|
+
forceUpdate
|
|
29
|
+
]);
|
|
30
|
+
useWidget({
|
|
31
|
+
widget: indexWidget,
|
|
32
|
+
parentIndex: parentIndex,
|
|
33
|
+
props: stableProps,
|
|
34
|
+
shouldSsr: Boolean(serverContext || initialResults),
|
|
35
|
+
skipSuspense: true
|
|
36
|
+
});
|
|
37
|
+
return indexWidget;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { useIndex };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import { IndexContext } from
|
|
3
|
-
import { invariant } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { IndexContext } from './IndexContext.js';
|
|
3
|
+
import { invariant } from './invariant.js';
|
|
4
|
+
|
|
5
|
+
function useIndexContext() {
|
|
6
|
+
var context = useContext(IndexContext);
|
|
7
|
+
invariant(context !== null);
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { useIndexContext };
|