react-instantsearch-core
Advanced tools
Comparing version 7.9.0 to 7.10.0
@@ -30,2 +30,5 @@ "use strict"; | ||
// This is used to re-map the result index to the requesting widget | ||
var recommendIdx = _react.default.useRef(0); | ||
// When <DynamicWidgets> is mounted, a second provider is used above the user-land | ||
@@ -40,5 +43,6 @@ // <InstantSearchSSRProvider> in `getServerState()`. | ||
value: _objectSpread(_objectSpread({}, props), {}, { | ||
ssrSearchRef: ssrSearchRef | ||
ssrSearchRef: ssrSearchRef, | ||
recommendIdx: recommendIdx | ||
}) | ||
}, children); | ||
} |
@@ -14,2 +14,3 @@ "use strict"; | ||
var _useInstantSearchServerContext = require("../lib/useInstantSearchServerContext"); | ||
var _useInstantSearchSSRContext = require("../lib/useInstantSearchSSRContext"); | ||
var _useStableValue = require("../lib/useStableValue"); | ||
@@ -36,2 +37,3 @@ var _useWidget = require("../lib/useWidget"); | ||
var serverContext = (0, _useInstantSearchServerContext.useInstantSearchServerContext)(); | ||
var ssrContext = (0, _useInstantSearchSSRContext.useInstantSearchSSRContext)(); | ||
var search = (0, _useInstantSearchContext.useInstantSearchContext)(); | ||
@@ -101,3 +103,4 @@ var parentIndex = (0, _useIndexContext.useIndexContext)(); | ||
results = _getIndexSearchResult.results, | ||
scopedResults = _getIndexSearchResult.scopedResults; | ||
scopedResults = _getIndexSearchResult.scopedResults, | ||
recommendResults = _getIndexSearchResult.recommendResults; | ||
@@ -111,6 +114,3 @@ // We get the widget render state by providing the same parameters as | ||
instantSearchInstance: search, | ||
results: widget.dependsOn === 'recommend' ? | ||
// @TODO: this is to avoid using wrong hits in SSR, | ||
// will be replace with SSR support for recommend | ||
null : results, | ||
results: widget.dependsOn === 'recommend' && recommendResults && ssrContext ? recommendResults[ssrContext.recommendIdx.current++] : results, | ||
scopedResults: scopedResults, | ||
@@ -117,0 +117,0 @@ state: helper.state, |
@@ -30,4 +30,5 @@ "use strict"; | ||
results: results, | ||
scopedResults: scopedResults | ||
scopedResults: scopedResults, | ||
recommendResults: helper.lastRecommendResults | ||
}; | ||
} |
@@ -22,3 +22,8 @@ "use strict"; | ||
var _useState = (0, _react.useState)(function () { | ||
return (0, _getIndexSearchResults.getIndexSearchResults)(searchIndex); | ||
var indexSearchResults = (0, _getIndexSearchResults.getIndexSearchResults)(searchIndex); | ||
// We do this not to leak `recommendResults` in the API. | ||
return { | ||
results: indexSearchResults.results, | ||
scopedResults: indexSearchResults.scopedResults | ||
}; | ||
}), | ||
@@ -25,0 +30,0 @@ _useState2 = _slicedToArray(_useState, 2), |
@@ -20,2 +20,3 @@ "use strict"; | ||
}; | ||
(0, _utils.resetWidgetId)(); | ||
var createNotifyServer = function createNotifyServer() { | ||
@@ -49,2 +50,3 @@ var hasBeenNotified = false; | ||
if (shouldRefetch) { | ||
(0, _utils.resetWidgetId)(); | ||
return execute({ | ||
@@ -54,3 +56,4 @@ children: /*#__PURE__*/_react.default.createElement(_.InstantSearchSSRProvider, serverState, children), | ||
searchRef: searchRef, | ||
notifyServer: createNotifyServer() | ||
notifyServer: createNotifyServer(), | ||
skipRecommend: true | ||
}); | ||
@@ -65,3 +68,4 @@ } | ||
notifyServer = _ref3.notifyServer, | ||
searchRef = _ref3.searchRef; | ||
searchRef = _ref3.searchRef, | ||
skipRecommend = _ref3.skipRecommend; | ||
return Promise.resolve().then(function () { | ||
@@ -91,3 +95,3 @@ renderToString( /*#__PURE__*/_react.default.createElement(_.InstantSearchServerContext.Provider, { | ||
} | ||
return (0, _server.waitForResults)(searchRef.current); | ||
return (0, _server.waitForResults)(searchRef.current, skipRecommend); | ||
}).then(function (requestParamsList) { | ||
@@ -94,0 +98,0 @@ return { |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _default = '7.9.0'; | ||
var _default = '7.10.0'; | ||
exports.default = _default; |
@@ -23,2 +23,5 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
// This is used to re-map the result index to the requesting widget | ||
var recommendIdx = React.useRef(0); | ||
// When <DynamicWidgets> is mounted, a second provider is used above the user-land | ||
@@ -33,5 +36,6 @@ // <InstantSearchSSRProvider> in `getServerState()`. | ||
value: _objectSpread(_objectSpread({}, props), {}, { | ||
ssrSearchRef: ssrSearchRef | ||
ssrSearchRef: ssrSearchRef, | ||
recommendIdx: recommendIdx | ||
}) | ||
}, children); | ||
} |
@@ -23,2 +23,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
import { useInstantSearchServerContext } from "../lib/useInstantSearchServerContext.js"; | ||
import { useInstantSearchSSRContext } from "../lib/useInstantSearchSSRContext.js"; | ||
import { useStableValue } from "../lib/useStableValue.js"; | ||
@@ -30,2 +31,3 @@ import { useWidget } from "../lib/useWidget.js"; | ||
var serverContext = useInstantSearchServerContext(); | ||
var ssrContext = useInstantSearchSSRContext(); | ||
var search = useInstantSearchContext(); | ||
@@ -95,3 +97,4 @@ var parentIndex = useIndexContext(); | ||
results = _getIndexSearchResult.results, | ||
scopedResults = _getIndexSearchResult.scopedResults; | ||
scopedResults = _getIndexSearchResult.scopedResults, | ||
recommendResults = _getIndexSearchResult.recommendResults; | ||
@@ -105,6 +108,3 @@ // We get the widget render state by providing the same parameters as | ||
instantSearchInstance: search, | ||
results: widget.dependsOn === 'recommend' ? | ||
// @TODO: this is to avoid using wrong hits in SSR, | ||
// will be replace with SSR support for recommend | ||
null : results, | ||
results: widget.dependsOn === 'recommend' && recommendResults && ssrContext ? recommendResults[ssrContext.recommendIdx.current++] : results, | ||
scopedResults: scopedResults, | ||
@@ -111,0 +111,0 @@ state: helper.state, |
@@ -9,2 +9,3 @@ import type { IndexWidget } from 'instantsearch.js/es/widgets/index/index'; | ||
}[]; | ||
recommendResults: import("algoliasearch-helper").RecommendResults<any> | null; | ||
}; |
@@ -24,4 +24,5 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
results: results, | ||
scopedResults: scopedResults | ||
scopedResults: scopedResults, | ||
recommendResults: helper.lastRecommendResults | ||
}; | ||
} |
@@ -7,3 +7,4 @@ import type { InstantSearchServerState } from '../components/InstantSearchSSRProvider'; | ||
ssrSearchRef: MutableRefObject<InternalInstantSearch<TUiState, TRouteState> | null>; | ||
recommendIdx: MutableRefObject<number>; | ||
}; | ||
export declare const InstantSearchSSRContext: import("react").Context<Partial<InstantSearchSSRContextApi<UiState, UiState>> | null>; |
@@ -16,3 +16,8 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
var _useState = useState(function () { | ||
return getIndexSearchResults(searchIndex); | ||
var indexSearchResults = getIndexSearchResults(searchIndex); | ||
// We do this not to leak `recommendResults` in the API. | ||
return { | ||
results: indexSearchResults.results, | ||
scopedResults: indexSearchResults.scopedResults | ||
}; | ||
}), | ||
@@ -19,0 +24,0 @@ _useState2 = _slicedToArray(_useState, 2), |
import { getInitialResults, waitForResults } from "instantsearch.js/es/lib/server.js"; | ||
import { walkIndex } from "instantsearch.js/es/lib/utils/index.js"; | ||
import { walkIndex, resetWidgetId } from "instantsearch.js/es/lib/utils/index.js"; | ||
import React from 'react'; | ||
@@ -13,2 +13,3 @@ import { InstantSearchServerContext, InstantSearchSSRProvider } from "../index.js"; | ||
}; | ||
resetWidgetId(); | ||
var createNotifyServer = function createNotifyServer() { | ||
@@ -42,2 +43,3 @@ var hasBeenNotified = false; | ||
if (shouldRefetch) { | ||
resetWidgetId(); | ||
return execute({ | ||
@@ -47,3 +49,4 @@ children: /*#__PURE__*/React.createElement(InstantSearchSSRProvider, serverState, children), | ||
searchRef: searchRef, | ||
notifyServer: createNotifyServer() | ||
notifyServer: createNotifyServer(), | ||
skipRecommend: true | ||
}); | ||
@@ -58,3 +61,4 @@ } | ||
notifyServer = _ref3.notifyServer, | ||
searchRef = _ref3.searchRef; | ||
searchRef = _ref3.searchRef, | ||
skipRecommend = _ref3.skipRecommend; | ||
return Promise.resolve().then(function () { | ||
@@ -84,3 +88,3 @@ renderToString( /*#__PURE__*/React.createElement(InstantSearchServerContext.Provider, { | ||
} | ||
return waitForResults(searchRef.current); | ||
return waitForResults(searchRef.current, skipRecommend); | ||
}).then(function (requestParamsList) { | ||
@@ -87,0 +91,0 @@ return { |
@@ -1,2 +0,2 @@ | ||
declare const _default: "7.9.0"; | ||
declare const _default: "7.10.0"; | ||
export default _default; |
@@ -1,1 +0,1 @@ | ||
export default '7.9.0'; | ||
export default '7.10.0'; |
{ | ||
"name": "react-instantsearch-core", | ||
"version": "7.9.0", | ||
"version": "7.10.0", | ||
"description": "⚡ Lightning-fast search for React, by Algolia", | ||
@@ -52,4 +52,4 @@ "types": "dist/es/index.d.ts", | ||
"@babel/runtime": "^7.1.2", | ||
"algoliasearch-helper": "3.20.0", | ||
"instantsearch.js": "4.69.0", | ||
"algoliasearch-helper": "3.21.0", | ||
"instantsearch.js": "4.70.0", | ||
"use-sync-external-store": "^1.0.0" | ||
@@ -65,3 +65,3 @@ }, | ||
}, | ||
"gitHead": "95ec6c4ce746c77eeb92fab1e42b5f833f3f04bc" | ||
"gitHead": "5bf02d0f65e6e1fc70265319dbad660696d8ba81" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3756861
23132
+ Addedalgoliasearch-helper@3.21.0(transitive)
+ Addedinstantsearch.js@4.70.0(transitive)
- Removedalgoliasearch-helper@3.20.0(transitive)
- Removedinstantsearch.js@4.69.0(transitive)
Updatedalgoliasearch-helper@3.21.0
Updatedinstantsearch.js@4.70.0