instantsearch.js 4.37.3 → 4.39.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/cjs/connectors/breadcrumb/connectBreadcrumb.js +3 -1
  3. package/cjs/connectors/clear-refinements/connectClearRefinements.js +11 -6
  4. package/cjs/connectors/current-refinements/connectCurrentRefinements.js +6 -2
  5. package/cjs/connectors/geo-search/connectGeoSearch.js +3 -1
  6. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +3 -1
  7. package/cjs/connectors/hits/connectHits.js +3 -1
  8. package/cjs/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  9. package/cjs/connectors/infinite-hits/connectInfiniteHits.js +5 -2
  10. package/cjs/connectors/menu/connectMenu.js +3 -1
  11. package/cjs/connectors/numeric-menu/connectNumericMenu.js +5 -3
  12. package/cjs/connectors/query-rules/connectQueryRules.js +3 -1
  13. package/cjs/connectors/refinement-list/connectRefinementList.js +8 -3
  14. package/cjs/connectors/sort-by/connectSortBy.js +3 -1
  15. package/cjs/lib/routers/history.js +44 -29
  16. package/cjs/lib/version.js +1 -1
  17. package/cjs/middlewares/createMetadataMiddleware.js +3 -1
  18. package/dist/instantsearch.development.d.ts +60 -43
  19. package/dist/instantsearch.development.js +108 -56
  20. package/dist/instantsearch.development.js.map +1 -1
  21. package/dist/instantsearch.production.d.ts +60 -43
  22. package/dist/instantsearch.production.min.d.ts +60 -43
  23. package/dist/instantsearch.production.min.js +2 -2
  24. package/dist/instantsearch.production.min.js.map +1 -1
  25. package/es/components/ToggleRefinement/ToggleRefinement.d.ts +3 -0
  26. package/es/components/ToggleRefinement/ToggleRefinement.js +4 -0
  27. package/es/connectors/breadcrumb/connectBreadcrumb.js +3 -1
  28. package/es/connectors/clear-refinements/connectClearRefinements.js +11 -6
  29. package/es/connectors/current-refinements/connectCurrentRefinements.js +6 -2
  30. package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +4 -5
  31. package/es/connectors/geo-search/connectGeoSearch.js +3 -1
  32. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +3 -1
  33. package/es/connectors/hits/connectHits.d.ts +10 -10
  34. package/es/connectors/hits/connectHits.js +3 -1
  35. package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -1
  36. package/es/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  37. package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +21 -21
  38. package/es/connectors/infinite-hits/connectInfiniteHits.js +5 -2
  39. package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -1
  40. package/es/connectors/menu/connectMenu.js +3 -1
  41. package/es/connectors/numeric-menu/connectNumericMenu.js +5 -3
  42. package/es/connectors/query-rules/connectQueryRules.d.ts +1 -2
  43. package/es/connectors/query-rules/connectQueryRules.js +3 -1
  44. package/es/connectors/refinement-list/connectRefinementList.js +8 -3
  45. package/es/connectors/sort-by/connectSortBy.js +3 -1
  46. package/es/lib/routers/history.d.ts +11 -0
  47. package/es/lib/routers/history.js +44 -29
  48. package/es/lib/utils/createSendEventForHits.d.ts +3 -0
  49. package/es/lib/utils/createSendEventForHits.js +3 -0
  50. package/es/lib/version.d.ts +1 -1
  51. package/es/lib/version.js +1 -1
  52. package/es/middlewares/createMetadataMiddleware.js +3 -1
  53. package/es/types/results.d.ts +8 -5
  54. package/es/types/widget.d.ts +4 -1
  55. package/package.json +4 -4
  56. package/dist/instantsearch.development.min.d.ts +0 -5246
package/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ # [4.39.0](https://github.com/algolia/instantsearch.js/compare/v4.38.1...v4.39.0) (2022-02-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * **ts:** allow Hits related connectors to be generic ([#5019](https://github.com/algolia/instantsearch.js/issues/5019)) ([e986f7e](https://github.com/algolia/instantsearch.js/commit/e986f7e46d57173da4d3d6c3c23fbdf3f9c0f78c))
7
+
8
+
9
+
10
+ ## [4.38.1](https://github.com/algolia/instantsearch.js/compare/v4.38.0...v4.38.1) (2022-02-08)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **routing:** fix history router based on history length ([#5004](https://github.com/algolia/instantsearch.js/issues/5004)) ([40541af](https://github.com/algolia/instantsearch.js/commit/40541af5c8face0e32a1ec3a4665a8387d89c626))
16
+ * **metadata:** ensure safe user agent detection ([#5009](https://github.com/algolia/instantsearch.js/pull/5009) [15a6a9d](https://github.com/algolia/instantsearch.js/commit/15a6a9d10ee512fab6884696bc59bedea13bd1b3))
17
+
18
+
19
+ # [4.38.0](https://github.com/algolia/instantsearch.js/compare/v4.37.3...v4.38.0) (2022-01-28)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **typescript:** remove non-existing UMD type definition ([#5001](https://github.com/algolia/instantsearch.js/issues/5001)) ([c234374](https://github.com/algolia/instantsearch.js/commit/c234374a1f5333f6625980c45fa0833a8c130257))
25
+
26
+
27
+ ### Features
28
+
29
+ * **connectors:** expose search results to `transformItems` when available ([#5000](https://github.com/algolia/instantsearch.js/issues/5000)) ([58c2651](https://github.com/algolia/instantsearch.js/commit/58c26517aad916ce49b474458e3411ff7ef5497a))
30
+
31
+
32
+
1
33
  ## [4.37.3](https://github.com/algolia/instantsearch.js/compare/v4.37.2...v4.37.3) (2022-01-25)
2
34
 
3
35
 
@@ -106,7 +106,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
106
106
 
107
107
  var facetValues = results.getFacetValues(facetName, {});
108
108
  var data = Array.isArray(facetValues.data) ? facetValues.data : [];
109
- var items = transformItems(shiftItemsValues(prepareItems(data)));
109
+ var items = transformItems(shiftItemsValues(prepareItems(data)), {
110
+ results: results
111
+ });
110
112
  return items;
111
113
  }
112
114
 
@@ -88,13 +88,15 @@ var connectClearRefinements = function connectClearRefinements(renderFn) {
88
88
  },
89
89
  getWidgetRenderState: function getWidgetRenderState(_ref2) {
90
90
  var createURL = _ref2.createURL,
91
- scopedResults = _ref2.scopedResults;
92
- connectorState.attributesToClear = scopedResults.reduce(function (results, scopedResult) {
93
- return results.concat(getAttributesToClear({
91
+ scopedResults = _ref2.scopedResults,
92
+ results = _ref2.results;
93
+ connectorState.attributesToClear = scopedResults.reduce(function (attributesToClear, scopedResult) {
94
+ return attributesToClear.concat(getAttributesToClear({
94
95
  scopedResult: scopedResult,
95
96
  includedAttributes: includedAttributes,
96
97
  excludedAttributes: excludedAttributes,
97
- transformItems: transformItems
98
+ transformItems: transformItems,
99
+ results: results
98
100
  }));
99
101
  }, []);
100
102
 
@@ -139,7 +141,8 @@ function getAttributesToClear(_ref5) {
139
141
  var scopedResult = _ref5.scopedResult,
140
142
  includedAttributes = _ref5.includedAttributes,
141
143
  excludedAttributes = _ref5.excludedAttributes,
142
- transformItems = _ref5.transformItems;
144
+ transformItems = _ref5.transformItems,
145
+ results = _ref5.results;
143
146
  var includesQuery = includedAttributes.indexOf('query') !== -1 || excludedAttributes.indexOf('query') === -1;
144
147
  return {
145
148
  helper: scopedResult.helper,
@@ -155,7 +158,9 @@ function getAttributesToClear(_ref5) {
155
158
  attribute === 'query' && includesQuery || // Otherwise, ignore the excluded attributes
156
159
  excludedAttributes.indexOf(attribute) === -1
157
160
  );
158
- })))
161
+ })), {
162
+ results: results
163
+ })
159
164
  };
160
165
  }
161
166
 
@@ -82,7 +82,9 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
82
82
  helper: helper,
83
83
  includedAttributes: includedAttributes,
84
84
  excludedAttributes: excludedAttributes
85
- }));
85
+ }), {
86
+ results: results
87
+ });
86
88
  }
87
89
 
88
90
  return scopedResults.reduce(function (accResults, scopedResult) {
@@ -91,7 +93,9 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
91
93
  helper: scopedResult.helper,
92
94
  includedAttributes: includedAttributes,
93
95
  excludedAttributes: excludedAttributes
94
- })));
96
+ }), {
97
+ results: results
98
+ }));
95
99
  }, []);
96
100
  }
97
101
 
@@ -169,7 +169,9 @@ var connectGeoSearch = function connectGeoSearch(renderFn) {
169
169
  var state = helper.state;
170
170
  var items = results ? transformItems(results.hits.filter(function (hit) {
171
171
  return hit._geoloc;
172
- })) : [];
172
+ }), {
173
+ results: results
174
+ }) : [];
173
175
 
174
176
  if (!sendEvent) {
175
177
  sendEvent = (0, _index.createSendEventForHits)({
@@ -200,7 +200,9 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
200
200
 
201
201
  var hasExhaustiveItems = (state.maxValuesPerFacet || 0) > getLimit() ? facetItems.length <= getLimit() : facetItems.length < getLimit();
202
202
  canToggleShowMore = showMore && (isShowingMore || !hasExhaustiveItems);
203
- items = transformItems(_prepareFacetValues(facetItems));
203
+ items = transformItems(_prepareFacetValues(facetItems), {
204
+ results: results
205
+ });
204
206
  }
205
207
 
206
208
  return {
@@ -87,7 +87,9 @@ var connectHits = function connectHits(renderFn) {
87
87
 
88
88
  var hitsWithAbsolutePosition = (0, _index.addAbsolutePosition)(results.hits, results.page, results.hitsPerPage);
89
89
  var hitsWithAbsolutePositionAndQueryID = (0, _index.addQueryID)(hitsWithAbsolutePosition, results.queryID);
90
- var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID);
90
+ var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
91
+ results: results
92
+ });
91
93
  return {
92
94
  hits: transformedHits,
93
95
  results: results,
@@ -128,7 +128,9 @@ var connectHitsPerPage = function connectHitsPerPage(renderFn) {
128
128
  createURL = _ref5.createURL,
129
129
  helper = _ref5.helper;
130
130
  return {
131
- items: transformItems(normalizeItems(state)),
131
+ items: transformItems(normalizeItems(state), {
132
+ results: results
133
+ }),
132
134
  refine: connectorState.getRefine(helper),
133
135
  createURL: connectorState.createURLFactory({
134
136
  state: state,
@@ -69,7 +69,8 @@ function extractHitsFromCachedHits(cachedHits) {
69
69
 
70
70
  var connectInfiniteHits = function connectInfiniteHits(renderFn) {
71
71
  var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _index.noop;
72
- (0, _index.checkRendering)(renderFn, withUsage());
72
+ (0, _index.checkRendering)(renderFn, withUsage()); // @TODO: this should be a generic, but a Connector can not yet be generic itself
73
+
73
74
  return function (widgetParams) {
74
75
  var _ref4 = widgetParams || {},
75
76
  _ref4$escapeHTML = _ref4.escapeHTML,
@@ -184,7 +185,9 @@ var connectInfiniteHits = function connectInfiniteHits(renderFn) {
184
185
 
185
186
  var hitsWithAbsolutePosition = (0, _index.addAbsolutePosition)(results.hits, results.page, results.hitsPerPage);
186
187
  var hitsWithAbsolutePositionAndQueryID = (0, _index.addQueryID)(hitsWithAbsolutePosition, results.queryID);
187
- var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID);
188
+ var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
189
+ results: results
190
+ });
188
191
 
189
192
  if (cachedHits[_page] === undefined) {
190
193
  cachedHits[_page] = transformedHits;
@@ -176,7 +176,9 @@ var connectMenu = function connectMenu(renderFn) {
176
176
  label: label,
177
177
  value: value
178
178
  });
179
- }));
179
+ }), {
180
+ results: results
181
+ });
180
182
  }
181
183
 
182
184
  return {
@@ -86,8 +86,8 @@ var connectNumericMenu = function connectNumericMenu(renderFn) {
86
86
  _ref2$items = _ref2.items,
87
87
  items = _ref2$items === void 0 ? [] : _ref2$items,
88
88
  _ref2$transformItems = _ref2.transformItems,
89
- transformItems = _ref2$transformItems === void 0 ? function (x) {
90
- return x;
89
+ transformItems = _ref2$transformItems === void 0 ? function (item) {
90
+ return item;
91
91
  } : _ref2$transformItems;
92
92
 
93
93
  if (attribute === '') {
@@ -224,7 +224,9 @@ var connectNumericMenu = function connectNumericMenu(renderFn) {
224
224
 
225
225
  return {
226
226
  createURL: connectorState.createURL(state),
227
- items: transformItems(prepareItems(state)),
227
+ items: transformItems(prepareItems(state), {
228
+ results: results
229
+ }),
228
230
  hasNoResults: results ? results.nbHits === 0 : true,
229
231
  refine: connectorState.refine,
230
232
  sendEvent: connectorState.sendEvent,
@@ -160,7 +160,9 @@ var connectQueryRules = function connectQueryRules(_render) {
160
160
  _ref4$userData = _ref4.userData,
161
161
  userData = _ref4$userData === void 0 ? [] : _ref4$userData;
162
162
 
163
- var items = transformItems(userData);
163
+ var items = transformItems(userData, {
164
+ results: results
165
+ });
164
166
  return {
165
167
  items: items,
166
168
  widgetParams: widgetParams
@@ -113,7 +113,8 @@ var connectRefinementList = function connectRefinementList(renderFn) {
113
113
  var createSearchForFacetValues = function createSearchForFacetValues(helper, widget) {
114
114
  return function (renderOptions) {
115
115
  return function (query) {
116
- var instantSearchInstance = renderOptions.instantSearchInstance;
116
+ var instantSearchInstance = renderOptions.instantSearchInstance,
117
+ searchResults = renderOptions.results;
117
118
 
118
119
  if (query === '' && lastItemsFromMainSearch) {
119
120
  // render with previous data from the helper.
@@ -140,7 +141,9 @@ var connectRefinementList = function connectRefinementList(renderFn) {
140
141
  value: value,
141
142
  label: value
142
143
  });
143
- }));
144
+ }), {
145
+ results: searchResults
146
+ });
144
147
  renderFn(_objectSpread(_objectSpread({}, widget.getWidgetRenderState(_objectSpread(_objectSpread({}, renderOptions), {}, {
145
148
  results: lastResultsFromMainSearch
146
149
  }))), {}, {
@@ -204,7 +207,9 @@ var connectRefinementList = function connectRefinementList(renderFn) {
204
207
  facetOrdering: sortBy === DEFAULT_SORT
205
208
  });
206
209
  facetValues = values && Array.isArray(values) ? values : [];
207
- items = transformItems(facetValues.slice(0, getLimit()).map(formatItems));
210
+ items = transformItems(facetValues.slice(0, getLimit()).map(formatItems), {
211
+ results: results
212
+ });
208
213
  var maxValuesPerFacetConfig = state.maxValuesPerFacet;
209
214
  var currentLimit = getLimit(); // If the limit is the max number of facet retrieved it is impossible to know
210
215
  // if the facets are exhaustive. The only moment we are sure it is exhaustive
@@ -87,7 +87,9 @@ var connectSortBy = function connectSortBy(renderFn) {
87
87
 
88
88
  return {
89
89
  currentRefinement: state.index,
90
- options: transformItems(items),
90
+ options: transformItems(items, {
91
+ results: results
92
+ }),
91
93
  refine: connectorState.setIndex,
92
94
  hasNoResults: results ? results.nbHits === 0 : true,
93
95
  widgetParams: widgetParams
@@ -58,16 +58,23 @@ var BrowserHistory = /*#__PURE__*/function () {
58
58
 
59
59
  _defineProperty(this, "shouldPushState", true);
60
60
 
61
+ _defineProperty(this, "isDisposed", false);
62
+
63
+ _defineProperty(this, "latestAcknowledgedHistory", 0);
64
+
61
65
  this.windowTitle = windowTitle;
62
66
  this.writeTimer = undefined;
63
67
  this.writeDelay = writeDelay;
64
68
  this._createURL = createURL;
65
69
  this.parseURL = parseURL;
66
70
  this.getLocation = getLocation;
67
- (0, _index.safelyRunOnBrowser)(function () {
71
+ (0, _index.safelyRunOnBrowser)(function (_ref2) {
72
+ var window = _ref2.window;
73
+
68
74
  var title = _this.windowTitle && _this.windowTitle(_this.read());
69
75
 
70
76
  setWindowTitle(title);
77
+ _this.latestAcknowledgedHistory = window.history.length;
71
78
  });
72
79
  }
73
80
  /**
@@ -92,8 +99,8 @@ var BrowserHistory = /*#__PURE__*/function () {
92
99
  value: function write(routeState) {
93
100
  var _this2 = this;
94
101
 
95
- (0, _index.safelyRunOnBrowser)(function (_ref2) {
96
- var window = _ref2.window;
102
+ (0, _index.safelyRunOnBrowser)(function (_ref3) {
103
+ var window = _ref3.window;
97
104
 
98
105
  var url = _this2.createURL(routeState);
99
106
 
@@ -104,10 +111,17 @@ var BrowserHistory = /*#__PURE__*/function () {
104
111
  }
105
112
 
106
113
  _this2.writeTimer = setTimeout(function () {
107
- setWindowTitle(title);
114
+ setWindowTitle(title); // We do want to `pushState` if:
115
+ // - the router is not disposed, IS.js needs to update the URL
116
+ // OR
117
+ // - the last write was from InstantSearch.js
118
+ // (unlike a SPA, where it would have last written)
119
+
120
+ var lastPushWasByISAfterDispose = !_this2.isDisposed || _this2.latestAcknowledgedHistory === window.history.length;
108
121
 
109
- if (_this2.shouldPushState) {
122
+ if (_this2.shouldPushState && lastPushWasByISAfterDispose) {
110
123
  window.history.pushState(routeState, title || '', url);
124
+ _this2.latestAcknowledgedHistory = window.history.length;
111
125
  }
112
126
 
113
127
  _this2.shouldPushState = true;
@@ -143,8 +157,8 @@ var BrowserHistory = /*#__PURE__*/function () {
143
157
  }
144
158
  };
145
159
 
146
- (0, _index.safelyRunOnBrowser)(function (_ref3) {
147
- var window = _ref3.window;
160
+ (0, _index.safelyRunOnBrowser)(function (_ref4) {
161
+ var window = _ref4.window;
148
162
  window.addEventListener('popstate', _this3._onPopState);
149
163
  });
150
164
  }
@@ -174,8 +188,9 @@ var BrowserHistory = /*#__PURE__*/function () {
174
188
  value: function dispose() {
175
189
  var _this4 = this;
176
190
 
177
- (0, _index.safelyRunOnBrowser)(function (_ref4) {
178
- var window = _ref4.window;
191
+ this.isDisposed = true;
192
+ (0, _index.safelyRunOnBrowser)(function (_ref5) {
193
+ var window = _ref5.window;
179
194
 
180
195
  if (_this4._onPopState) {
181
196
  window.removeEventListener('popstate', _this4._onPopState);
@@ -194,12 +209,12 @@ var BrowserHistory = /*#__PURE__*/function () {
194
209
  }();
195
210
 
196
211
  function historyRouter() {
197
- var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
198
- _ref5$createURL = _ref5.createURL,
199
- createURL = _ref5$createURL === void 0 ? function (_ref6) {
200
- var qsModule = _ref6.qsModule,
201
- routeState = _ref6.routeState,
202
- location = _ref6.location;
212
+ var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
213
+ _ref6$createURL = _ref6.createURL,
214
+ createURL = _ref6$createURL === void 0 ? function (_ref7) {
215
+ var qsModule = _ref7.qsModule,
216
+ routeState = _ref7.routeState,
217
+ location = _ref7.location;
203
218
  var protocol = location.protocol,
204
219
  hostname = location.hostname,
205
220
  _location$port = location.port,
@@ -215,11 +230,11 @@ function historyRouter() {
215
230
  }
216
231
 
217
232
  return "".concat(protocol, "//").concat(hostname).concat(portWithPrefix).concat(pathname, "?").concat(queryString).concat(hash);
218
- } : _ref5$createURL,
219
- _ref5$parseURL = _ref5.parseURL,
220
- parseURL = _ref5$parseURL === void 0 ? function (_ref7) {
221
- var qsModule = _ref7.qsModule,
222
- location = _ref7.location;
233
+ } : _ref6$createURL,
234
+ _ref6$parseURL = _ref6.parseURL,
235
+ parseURL = _ref6$parseURL === void 0 ? function (_ref8) {
236
+ var qsModule = _ref8.qsModule,
237
+ location = _ref8.location;
223
238
  // `qs` by default converts arrays with more than 20 items to an object.
224
239
  // We want to avoid this because the data structure manipulated can therefore vary.
225
240
  // Setting the limit to `100` seems a good number because the engine's default is 100
@@ -233,21 +248,21 @@ function historyRouter() {
233
248
  return qsModule.parse(location.search.slice(1), {
234
249
  arrayLimit: 99
235
250
  });
236
- } : _ref5$parseURL,
237
- _ref5$writeDelay = _ref5.writeDelay,
238
- writeDelay = _ref5$writeDelay === void 0 ? 400 : _ref5$writeDelay,
239
- windowTitle = _ref5.windowTitle,
240
- _ref5$getLocation = _ref5.getLocation,
241
- getLocation = _ref5$getLocation === void 0 ? function () {
242
- return (0, _index.safelyRunOnBrowser)(function (_ref8) {
243
- var window = _ref8.window;
251
+ } : _ref6$parseURL,
252
+ _ref6$writeDelay = _ref6.writeDelay,
253
+ writeDelay = _ref6$writeDelay === void 0 ? 400 : _ref6$writeDelay,
254
+ windowTitle = _ref6.windowTitle,
255
+ _ref6$getLocation = _ref6.getLocation,
256
+ getLocation = _ref6$getLocation === void 0 ? function () {
257
+ return (0, _index.safelyRunOnBrowser)(function (_ref9) {
258
+ var window = _ref9.window;
244
259
  return window.location;
245
260
  }, {
246
261
  fallback: function fallback() {
247
262
  throw new Error('You need to provide `getLocation` to the `history` router in environments where `window` does not exist.');
248
263
  }
249
264
  });
250
- } : _ref5$getLocation;
265
+ } : _ref6$getLocation;
251
266
 
252
267
  return new BrowserHistory({
253
268
  createURL: createURL,
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '4.37.3';
7
+ var _default = '4.39.0';
8
8
  exports.default = _default;
@@ -54,8 +54,10 @@ function extractPayload(widgets, instantSearchInstance, payload) {
54
54
 
55
55
  function isMetadataEnabled() {
56
56
  return (0, _index.safelyRunOnBrowser)(function (_ref) {
57
+ var _window$navigator, _window$navigator$use;
58
+
57
59
  var window = _ref.window;
58
- return window.navigator.userAgent.indexOf('Algolia Crawler') > -1;
60
+ return ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : (_window$navigator$use = _window$navigator.userAgent) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.indexOf('Algolia Crawler')) > -1;
59
61
  }, {
60
62
  fallback: function fallback() {
61
63
  return false;