react-instantsearch 7.0.3 → 7.1.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.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var React__default = 'default' in React ? React['default'] : React;
|
|
9
9
|
|
|
10
|
-
var version = '7.0
|
|
10
|
+
var version = '7.1.0';
|
|
11
11
|
|
|
12
12
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
13
13
|
//
|
|
@@ -4327,7 +4327,7 @@
|
|
|
4327
4327
|
|
|
4328
4328
|
var SearchResults_1 = SearchResults;
|
|
4329
4329
|
|
|
4330
|
-
var version$1 = '3.14.
|
|
4330
|
+
var version$1 = '3.14.2';
|
|
4331
4331
|
|
|
4332
4332
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
4333
4333
|
|
|
@@ -8238,6 +8238,11 @@
|
|
|
8238
8238
|
return stableValue;
|
|
8239
8239
|
}
|
|
8240
8240
|
|
|
8241
|
+
var useKey = 'use';
|
|
8242
|
+
|
|
8243
|
+
// @TODO: Remove this file and import directly from React when available.
|
|
8244
|
+
var use = React[useKey];
|
|
8245
|
+
|
|
8241
8246
|
/**
|
|
8242
8247
|
* `useLayoutEffect` that doesn't show a warning when server-side rendering.
|
|
8243
8248
|
*
|
|
@@ -8245,11 +8250,19 @@
|
|
|
8245
8250
|
*/
|
|
8246
8251
|
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
8247
8252
|
|
|
8253
|
+
var InstantSearchRSCContext = /*#__PURE__*/React.createContext(null);
|
|
8254
|
+
|
|
8255
|
+
function useRSCContext() {
|
|
8256
|
+
return React.useContext(InstantSearchRSCContext);
|
|
8257
|
+
}
|
|
8258
|
+
|
|
8248
8259
|
function useWidget(_ref) {
|
|
8260
|
+
var _waitingForResultsRef;
|
|
8249
8261
|
var widget = _ref.widget,
|
|
8250
8262
|
parentIndex = _ref.parentIndex,
|
|
8251
8263
|
props = _ref.props,
|
|
8252
8264
|
shouldSsr = _ref.shouldSsr;
|
|
8265
|
+
var waitingForResultsRef = useRSCContext();
|
|
8253
8266
|
var prevPropsRef = React.useRef(props);
|
|
8254
8267
|
React.useEffect(function () {
|
|
8255
8268
|
prevPropsRef.current = props;
|
|
@@ -8309,9 +8322,20 @@
|
|
|
8309
8322
|
});
|
|
8310
8323
|
};
|
|
8311
8324
|
}, [parentIndex, widget, shouldAddWidgetEarly, search, props]);
|
|
8312
|
-
if (shouldAddWidgetEarly) {
|
|
8325
|
+
if (shouldAddWidgetEarly || (waitingForResultsRef === null || waitingForResultsRef === void 0 ? void 0 : (_waitingForResultsRef = waitingForResultsRef.current) === null || _waitingForResultsRef === void 0 ? void 0 : _waitingForResultsRef.status) === 'pending') {
|
|
8313
8326
|
parentIndex.addWidgets([widget]);
|
|
8314
8327
|
}
|
|
8328
|
+
if (typeof window === 'undefined' && waitingForResultsRef !== null && waitingForResultsRef !== void 0 && waitingForResultsRef.current &&
|
|
8329
|
+
// We need the widgets contained in the index to be added before we trigger the search request.
|
|
8330
|
+
widget.$$type !== 'ais.index') {
|
|
8331
|
+
var _search$helper;
|
|
8332
|
+
use(waitingForResultsRef.current);
|
|
8333
|
+
// If we made a second request because of DynamicWidgets, we need to wait for the second result,
|
|
8334
|
+
// except for DynamicWidgets itself which needs to render its children after the first result.
|
|
8335
|
+
if (widget.$$type !== 'ais.dynamicWidgets' && (_search$helper = search.helper) !== null && _search$helper !== void 0 && _search$helper.lastResults) {
|
|
8336
|
+
use(waitingForResultsRef.current);
|
|
8337
|
+
}
|
|
8338
|
+
}
|
|
8315
8339
|
}
|
|
8316
8340
|
|
|
8317
8341
|
function _typeof$b(obj) {
|
|
@@ -11760,7 +11784,7 @@
|
|
|
11760
11784
|
};
|
|
11761
11785
|
}
|
|
11762
11786
|
|
|
11763
|
-
var version$3 = '4.
|
|
11787
|
+
var version$3 = '4.57.0';
|
|
11764
11788
|
|
|
11765
11789
|
function _typeof$n(obj) {
|
|
11766
11790
|
"@babel/helpers - typeof";
|
|
@@ -12486,8 +12510,10 @@
|
|
|
12486
12510
|
var forceUpdate = useForceUpdate();
|
|
12487
12511
|
var serverContext = useInstantSearchServerContext();
|
|
12488
12512
|
var serverState = useInstantSearchSSRContext();
|
|
12513
|
+
var waitingForResultsRef = useRSCContext();
|
|
12489
12514
|
var initialResults = serverState === null || serverState === void 0 ? void 0 : serverState.initialResults;
|
|
12490
12515
|
var prevPropsRef = React.useRef(props);
|
|
12516
|
+
var shouldRenderAtOnce = serverContext || initialResults || waitingForResultsRef;
|
|
12491
12517
|
var searchRef = React.useRef(null);
|
|
12492
12518
|
// As we need to render on mount with SSR, using the local ref above in `StrictMode` will
|
|
12493
12519
|
// create and start two instances of InstantSearch. To avoid this, we instead discard it and use
|
|
@@ -12511,7 +12537,7 @@
|
|
|
12511
12537
|
}, 0);
|
|
12512
12538
|
};
|
|
12513
12539
|
search._schedule.queue = [];
|
|
12514
|
-
if (
|
|
12540
|
+
if (shouldRenderAtOnce) {
|
|
12515
12541
|
// InstantSearch.js has a private Initial Results API that lets us inject
|
|
12516
12542
|
// results on the search instance.
|
|
12517
12543
|
// On the server, we default the initial results to an empty object so that
|
|
@@ -12525,7 +12551,7 @@
|
|
|
12525
12551
|
// On the server, we start the search early to compute the search parameters.
|
|
12526
12552
|
// On SSR, we start the search early to directly catch up with the lifecycle
|
|
12527
12553
|
// and render.
|
|
12528
|
-
if (
|
|
12554
|
+
if (shouldRenderAtOnce) {
|
|
12529
12555
|
search.start();
|
|
12530
12556
|
}
|
|
12531
12557
|
if (serverContext) {
|
|
@@ -12639,8 +12665,8 @@
|
|
|
12639
12665
|
* which is either `nodejs` or `edge`.
|
|
12640
12666
|
*/
|
|
12641
12667
|
function getNextVersion() {
|
|
12642
|
-
var
|
|
12643
|
-
return typeof window !== 'undefined' && ((
|
|
12668
|
+
var _next2, _process$env;
|
|
12669
|
+
return typeof window !== 'undefined' && ((_next2 = window.next) === null || _next2 === void 0 ? void 0 : _next2.version) || (typeof process !== 'undefined' ? (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.NEXT_RUNTIME : undefined);
|
|
12644
12670
|
}
|
|
12645
12671
|
|
|
12646
12672
|
var _excluded$6 = ["children"];
|
|
@@ -18012,6 +18038,33 @@
|
|
|
18012
18038
|
};
|
|
18013
18039
|
}
|
|
18014
18040
|
|
|
18041
|
+
// This is needed in order to work with RSC Suspense, perhaps they will later provide a wrapper.
|
|
18042
|
+
|
|
18043
|
+
function isStatefulPromise(promise) {
|
|
18044
|
+
return 'status' in promise;
|
|
18045
|
+
}
|
|
18046
|
+
function wrapPromiseWithState(promise) {
|
|
18047
|
+
if (isStatefulPromise(promise)) {
|
|
18048
|
+
return promise;
|
|
18049
|
+
}
|
|
18050
|
+
var pendingPromise = promise;
|
|
18051
|
+
pendingPromise.status = 'pending';
|
|
18052
|
+
pendingPromise.then(function (value) {
|
|
18053
|
+
if (pendingPromise.status === 'pending') {
|
|
18054
|
+
var fulfilledPromise = pendingPromise;
|
|
18055
|
+
fulfilledPromise.status = 'fulfilled';
|
|
18056
|
+
fulfilledPromise.value = value;
|
|
18057
|
+
}
|
|
18058
|
+
}, function (reason) {
|
|
18059
|
+
if (pendingPromise.status === 'pending') {
|
|
18060
|
+
var rejectedPromise = pendingPromise;
|
|
18061
|
+
rejectedPromise.status = 'rejected';
|
|
18062
|
+
rejectedPromise.reason = reason;
|
|
18063
|
+
}
|
|
18064
|
+
});
|
|
18065
|
+
return promise;
|
|
18066
|
+
}
|
|
18067
|
+
|
|
18015
18068
|
function _typeof$I(obj) {
|
|
18016
18069
|
"@babel/helpers - typeof";
|
|
18017
18070
|
|
|
@@ -19956,6 +20009,7 @@
|
|
|
19956
20009
|
exports.Index = Index;
|
|
19957
20010
|
exports.InfiniteHits = InfiniteHits$1;
|
|
19958
20011
|
exports.InstantSearch = InstantSearch$1;
|
|
20012
|
+
exports.InstantSearchRSCContext = InstantSearchRSCContext;
|
|
19959
20013
|
exports.InstantSearchSSRProvider = InstantSearchSSRProvider;
|
|
19960
20014
|
exports.InstantSearchServerContext = InstantSearchServerContext;
|
|
19961
20015
|
exports.Menu = Menu$1;
|
|
@@ -19981,11 +20035,13 @@
|
|
|
19981
20035
|
exports.useHitsPerPage = useHitsPerPage;
|
|
19982
20036
|
exports.useInfiniteHits = useInfiniteHits;
|
|
19983
20037
|
exports.useInstantSearch = useInstantSearch;
|
|
20038
|
+
exports.useInstantSearchContext = useInstantSearchContext;
|
|
19984
20039
|
exports.useMenu = useMenu;
|
|
19985
20040
|
exports.useNumericMenu = useNumericMenu;
|
|
19986
20041
|
exports.usePagination = usePagination;
|
|
19987
20042
|
exports.usePoweredBy = usePoweredBy;
|
|
19988
20043
|
exports.useQueryRules = useQueryRules;
|
|
20044
|
+
exports.useRSCContext = useRSCContext;
|
|
19989
20045
|
exports.useRange = useRange;
|
|
19990
20046
|
exports.useRefinementList = useRefinementList;
|
|
19991
20047
|
exports.useSearchBox = useSearchBox;
|
|
@@ -19993,6 +20049,7 @@
|
|
|
19993
20049
|
exports.useStats = useStats;
|
|
19994
20050
|
exports.useToggleRefinement = useToggleRefinement;
|
|
19995
20051
|
exports.version = version;
|
|
20052
|
+
exports.wrapPromiseWithState = wrapPromiseWithState;
|
|
19996
20053
|
|
|
19997
20054
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
19998
20055
|
|