instantsearch.js 4.31.0 → 4.33.1

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 (45) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/cjs/connectors/powered-by/connectPoweredBy.js +13 -4
  3. package/cjs/lib/InstantSearch.js +4 -2
  4. package/cjs/lib/infiniteHitsCache/sessionStorage.js +16 -12
  5. package/cjs/lib/insights/client.js +6 -1
  6. package/cjs/lib/routers/history.js +89 -42
  7. package/cjs/lib/utils/detect-insights-client.js +10 -1
  8. package/cjs/lib/utils/getWidgetAttribute.js +18 -8
  9. package/cjs/lib/utils/index.js +10 -1
  10. package/cjs/lib/utils/safelyRunOnBrowser.js +30 -0
  11. package/cjs/lib/version.js +1 -1
  12. package/cjs/lib/voiceSearchHelper/index.js +5 -0
  13. package/cjs/middlewares/createMetadataMiddleware.js +13 -5
  14. package/cjs/widgets/index/index.js +1 -1
  15. package/dist/instantsearch.development.d.ts +32 -26
  16. package/dist/instantsearch.development.js +213 -84
  17. package/dist/instantsearch.development.js.map +1 -1
  18. package/dist/instantsearch.development.min.d.ts +32 -26
  19. package/dist/instantsearch.production.d.ts +32 -26
  20. package/dist/instantsearch.production.min.d.ts +32 -26
  21. package/dist/instantsearch.production.min.js +2 -2
  22. package/dist/instantsearch.production.min.js.map +1 -1
  23. package/es/connectors/powered-by/connectPoweredBy.js +14 -5
  24. package/es/lib/InstantSearch.js +4 -2
  25. package/es/lib/infiniteHitsCache/sessionStorage.js +17 -14
  26. package/es/lib/insights/client.js +6 -1
  27. package/es/lib/insights/listener.d.ts +2 -2
  28. package/es/lib/routers/history.d.ts +13 -2
  29. package/es/lib/routers/history.js +88 -42
  30. package/es/lib/utils/detect-insights-client.js +9 -1
  31. package/es/lib/utils/getWidgetAttribute.js +19 -9
  32. package/es/lib/utils/index.d.ts +1 -0
  33. package/es/lib/utils/index.js +2 -1
  34. package/es/lib/utils/safelyRunOnBrowser.d.ts +14 -0
  35. package/es/lib/utils/safelyRunOnBrowser.js +23 -0
  36. package/es/lib/version.d.ts +1 -1
  37. package/es/lib/version.js +1 -1
  38. package/es/lib/voiceSearchHelper/index.js +5 -0
  39. package/es/middlewares/createMetadataMiddleware.js +13 -5
  40. package/es/types/connector.d.ts +2 -2
  41. package/es/types/insights.d.ts +12 -15
  42. package/es/types/widget-factory.d.ts +2 -2
  43. package/es/types/widget.d.ts +2 -2
  44. package/es/widgets/index/index.js +1 -1
  45. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.31.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
1
+ /*! InstantSearch.js 4.33.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -318,7 +318,10 @@
318
318
  }
319
319
 
320
320
  for (var key in source) {
321
- if (!Object.prototype.hasOwnProperty.call(source, key)) {
321
+ if (
322
+ !Object.prototype.hasOwnProperty.call(source, key) ||
323
+ key === '__proto__'
324
+ ) {
322
325
  continue;
323
326
  }
324
327
 
@@ -329,7 +332,10 @@
329
332
  continue;
330
333
  }
331
334
 
332
- if (isObjectOrArrayOrFunction(targetVal) && isObjectOrArrayOrFunction(sourceVal)) {
335
+ if (
336
+ isObjectOrArrayOrFunction(targetVal) &&
337
+ isObjectOrArrayOrFunction(sourceVal)
338
+ ) {
333
339
  target[key] = _merge(targetVal, sourceVal);
334
340
  } else {
335
341
  target[key] = clone(sourceVal);
@@ -1906,9 +1912,17 @@
1906
1912
 
1907
1913
  managedParameters: [
1908
1914
  'index',
1909
- 'facets', 'disjunctiveFacets', 'facetsRefinements',
1910
- 'facetsExcludes', 'disjunctiveFacetsRefinements',
1911
- 'numericRefinements', 'tagRefinements', 'hierarchicalFacets', 'hierarchicalFacetsRefinements'
1915
+
1916
+ 'facets',
1917
+ 'disjunctiveFacets',
1918
+ 'facetsRefinements',
1919
+ 'hierarchicalFacets',
1920
+ 'facetsExcludes',
1921
+
1922
+ 'disjunctiveFacetsRefinements',
1923
+ 'numericRefinements',
1924
+ 'tagRefinements',
1925
+ 'hierarchicalFacetsRefinements'
1912
1926
  ],
1913
1927
  getQueryParams: function getQueryParams() {
1914
1928
  var managedParameters = this.managedParameters;
@@ -3146,6 +3160,10 @@
3146
3160
  }
3147
3161
  });
3148
3162
 
3163
+ orderedFacets = orderedFacets.filter(function(facet) {
3164
+ return facet;
3165
+ });
3166
+
3149
3167
  var sortRemainingBy = facetOrdering.sortRemainingBy;
3150
3168
  var ordering;
3151
3169
  if (sortRemainingBy === 'hidden') {
@@ -3837,7 +3855,7 @@
3837
3855
  var numericFilters = requestBuilder._getNumericFilters(state);
3838
3856
  var tagFilters = requestBuilder._getTagFilters(state);
3839
3857
  var additionalParams = {
3840
- facets: facets,
3858
+ facets: facets.indexOf('*') > -1 ? ['*'] : facets,
3841
3859
  tagFilters: tagFilters
3842
3860
  };
3843
3861
 
@@ -4097,7 +4115,7 @@
4097
4115
 
4098
4116
  var requestBuilder_1 = requestBuilder;
4099
4117
 
4100
- var version = '3.5.5';
4118
+ var version = '3.6.2';
4101
4119
 
4102
4120
  /**
4103
4121
  * Event triggered when a parameter is set or updated
@@ -7868,17 +7886,51 @@
7868
7886
  }
7869
7887
 
7870
7888
  function getWidgetAttribute(widget, initOptions) {
7871
- try {
7872
- // assume the type to be the correct one, but throw a nice error if it isn't the case
7873
- var _getWidgetRenderState = widget.getWidgetRenderState(initOptions),
7874
- widgetParams = _getWidgetRenderState.widgetParams;
7889
+ var _widget$getWidgetRend;
7875
7890
 
7876
- var attribute = 'attribute' in widgetParams ? widgetParams.attribute : widgetParams.attributes[0];
7877
- if (typeof attribute !== 'string') throw new Error();
7878
- return attribute;
7879
- } catch (e) {
7891
+ var renderState = (_widget$getWidgetRend = widget.getWidgetRenderState) === null || _widget$getWidgetRend === void 0 ? void 0 : _widget$getWidgetRend.call(widget, initOptions);
7892
+ var attribute = null;
7893
+
7894
+ if (renderState && renderState.widgetParams) {
7895
+ // casting as widgetParams is checked just before
7896
+ var widgetParams = renderState.widgetParams;
7897
+
7898
+ if (widgetParams.attribute) {
7899
+ attribute = widgetParams.attribute;
7900
+ } else if (Array.isArray(widgetParams.attributes)) {
7901
+ attribute = widgetParams.attributes[0];
7902
+ }
7903
+ }
7904
+
7905
+ if (typeof attribute !== 'string') {
7880
7906
  throw new Error("Could not find the attribute of the widget:\n\n".concat(JSON.stringify(widget), "\n\nPlease check whether the widget's getWidgetRenderState returns widgetParams.attribute correctly."));
7881
7907
  }
7908
+
7909
+ return attribute;
7910
+ }
7911
+
7912
+ // eslint-disable-next-line no-restricted-globals
7913
+
7914
+ /**
7915
+ * Runs code on browser enviromnents safely.
7916
+ */
7917
+ function safelyRunOnBrowser(callback) {
7918
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
7919
+ fallback: function fallback() {
7920
+ return undefined;
7921
+ }
7922
+ },
7923
+ fallback = _ref.fallback;
7924
+
7925
+ // eslint-disable-next-line no-restricted-globals
7926
+ if (typeof window === 'undefined') {
7927
+ return fallback();
7928
+ } // eslint-disable-next-line no-restricted-globals
7929
+
7930
+
7931
+ return callback({
7932
+ window: window
7933
+ });
7882
7934
  }
7883
7935
 
7884
7936
  var withUsage = createDocumentationMessageGenerator({
@@ -8400,7 +8452,7 @@
8400
8452
  localUiState = getLocalWidgetsUiState(localWidgets, {
8401
8453
  searchParameters: this.getHelper().state,
8402
8454
  helper: this.getHelper()
8403
- });
8455
+ }, localUiState);
8404
8456
  }
8405
8457
  };
8406
8458
  };
@@ -8413,7 +8465,7 @@
8413
8465
  instantSearchInstance.renderState = _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState), {}, _defineProperty({}, parentIndexName, _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
8414
8466
  }
8415
8467
 
8416
- var version$1 = '4.31.0';
8468
+ var version$1 = '4.33.1';
8417
8469
 
8418
8470
  var NAMESPACE = 'ais';
8419
8471
  var component = function component(componentName) {
@@ -9481,6 +9533,8 @@
9481
9533
 
9482
9534
  var setWindowTitle = function setWindowTitle(title) {
9483
9535
  if (title) {
9536
+ // This function is only executed on browsers so we can disable this check.
9537
+ // eslint-disable-next-line no-restricted-globals
9484
9538
  window.document.title = title;
9485
9539
  }
9486
9540
  };
@@ -9491,11 +9545,14 @@
9491
9545
  * using web APIs (`window.location.pushState` and `onpopstate` event).
9492
9546
  */
9493
9547
  function BrowserHistory(_ref) {
9548
+ var _this = this;
9549
+
9494
9550
  var windowTitle = _ref.windowTitle,
9495
9551
  _ref$writeDelay = _ref.writeDelay,
9496
9552
  writeDelay = _ref$writeDelay === void 0 ? 400 : _ref$writeDelay,
9497
9553
  createURL = _ref.createURL,
9498
- parseURL = _ref.parseURL;
9554
+ parseURL = _ref.parseURL,
9555
+ getLocation = _ref.getLocation;
9499
9556
 
9500
9557
  _classCallCheck(this, BrowserHistory);
9501
9558
 
@@ -9507,15 +9564,23 @@
9507
9564
 
9508
9565
  _defineProperty(this, "parseURL", void 0);
9509
9566
 
9567
+ _defineProperty(this, "getLocation", void 0);
9568
+
9510
9569
  _defineProperty(this, "writeTimer", void 0);
9511
9570
 
9571
+ _defineProperty(this, "shouldPushState", true);
9572
+
9512
9573
  this.windowTitle = windowTitle;
9513
9574
  this.writeTimer = undefined;
9514
9575
  this.writeDelay = writeDelay;
9515
9576
  this._createURL = createURL;
9516
9577
  this.parseURL = parseURL;
9517
- var title = this.windowTitle && this.windowTitle(this.read());
9518
- setWindowTitle(title);
9578
+ this.getLocation = getLocation;
9579
+ safelyRunOnBrowser(function () {
9580
+ var title = _this.windowTitle && _this.windowTitle(_this.read());
9581
+
9582
+ setWindowTitle(title);
9583
+ });
9519
9584
  }
9520
9585
  /**
9521
9586
  * Reads the URL and returns a syncable UI search state.
@@ -9527,7 +9592,7 @@
9527
9592
  value: function read() {
9528
9593
  return this.parseURL({
9529
9594
  qsModule: lib$1,
9530
- location: window.location
9595
+ location: this.getLocation()
9531
9596
  });
9532
9597
  }
9533
9598
  /**
@@ -9537,20 +9602,30 @@
9537
9602
  }, {
9538
9603
  key: "write",
9539
9604
  value: function write(routeState) {
9540
- var _this = this;
9605
+ var _this2 = this;
9541
9606
 
9542
- var url = this.createURL(routeState);
9543
- var title = this.windowTitle && this.windowTitle(routeState);
9607
+ safelyRunOnBrowser(function (_ref2) {
9608
+ var window = _ref2.window;
9544
9609
 
9545
- if (this.writeTimer) {
9546
- window.clearTimeout(this.writeTimer);
9547
- }
9610
+ var url = _this2.createURL(routeState);
9611
+
9612
+ var title = _this2.windowTitle && _this2.windowTitle(routeState);
9548
9613
 
9549
- this.writeTimer = window.setTimeout(function () {
9550
- setWindowTitle(title);
9551
- window.history.pushState(routeState, title || '', url);
9552
- _this.writeTimer = undefined;
9553
- }, this.writeDelay);
9614
+ if (_this2.writeTimer) {
9615
+ clearTimeout(_this2.writeTimer);
9616
+ }
9617
+
9618
+ _this2.writeTimer = setTimeout(function () {
9619
+ setWindowTitle(title);
9620
+
9621
+ if (_this2.shouldPushState) {
9622
+ window.history.pushState(routeState, title || '', url);
9623
+ }
9624
+
9625
+ _this2.shouldPushState = true;
9626
+ _this2.writeTimer = undefined;
9627
+ }, _this2.writeDelay);
9628
+ });
9554
9629
  }
9555
9630
  /**
9556
9631
  * Sets a callback on the `onpopstate` event of the history API of the current page.
@@ -9560,26 +9635,30 @@
9560
9635
  }, {
9561
9636
  key: "onUpdate",
9562
9637
  value: function onUpdate(callback) {
9563
- var _this2 = this;
9638
+ var _this3 = this;
9564
9639
 
9565
9640
  this._onPopState = function (event) {
9566
- if (_this2.writeTimer) {
9567
- window.clearTimeout(_this2.writeTimer);
9568
- _this2.writeTimer = undefined;
9641
+ if (_this3.writeTimer) {
9642
+ clearTimeout(_this3.writeTimer);
9643
+ _this3.writeTimer = undefined;
9569
9644
  }
9570
9645
 
9646
+ _this3.shouldPushState = false;
9571
9647
  var routeState = event.state; // At initial load, the state is read from the URL without update.
9572
9648
  // Therefore the state object is not available.
9573
9649
  // In this case, we fallback and read the URL.
9574
9650
 
9575
9651
  if (!routeState) {
9576
- callback(_this2.read());
9652
+ callback(_this3.read());
9577
9653
  } else {
9578
9654
  callback(routeState);
9579
9655
  }
9580
9656
  };
9581
9657
 
9582
- window.addEventListener('popstate', this._onPopState);
9658
+ safelyRunOnBrowser(function (_ref3) {
9659
+ var window = _ref3.window;
9660
+ window.addEventListener('popstate', _this3._onPopState);
9661
+ });
9583
9662
  }
9584
9663
  /**
9585
9664
  * Creates a complete URL from a given syncable UI state.
@@ -9595,7 +9674,7 @@
9595
9674
  return this._createURL({
9596
9675
  qsModule: lib$1,
9597
9676
  routeState: routeState,
9598
- location: window.location
9677
+ location: this.getLocation()
9599
9678
  });
9600
9679
  }
9601
9680
  /**
@@ -9605,12 +9684,18 @@
9605
9684
  }, {
9606
9685
  key: "dispose",
9607
9686
  value: function dispose() {
9608
- if (this._onPopState) {
9609
- window.removeEventListener('popstate', this._onPopState);
9610
- }
9687
+ var _this4 = this;
9688
+
9689
+ safelyRunOnBrowser(function (_ref4) {
9690
+ var window = _ref4.window;
9691
+
9692
+ if (_this4._onPopState) {
9693
+ window.removeEventListener('popstate', _this4._onPopState);
9694
+ }
9695
+ });
9611
9696
 
9612
9697
  if (this.writeTimer) {
9613
- window.clearTimeout(this.writeTimer);
9698
+ clearTimeout(this.writeTimer);
9614
9699
  }
9615
9700
 
9616
9701
  this.write({});
@@ -9621,12 +9706,12 @@
9621
9706
  }();
9622
9707
 
9623
9708
  function historyRouter() {
9624
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
9625
- _ref2$createURL = _ref2.createURL,
9626
- createURL = _ref2$createURL === void 0 ? function (_ref3) {
9627
- var qsModule = _ref3.qsModule,
9628
- routeState = _ref3.routeState,
9629
- location = _ref3.location;
9709
+ var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
9710
+ _ref5$createURL = _ref5.createURL,
9711
+ createURL = _ref5$createURL === void 0 ? function (_ref6) {
9712
+ var qsModule = _ref6.qsModule,
9713
+ routeState = _ref6.routeState,
9714
+ location = _ref6.location;
9630
9715
  var protocol = location.protocol,
9631
9716
  hostname = location.hostname,
9632
9717
  _location$port = location.port,
@@ -9642,11 +9727,11 @@
9642
9727
  }
9643
9728
 
9644
9729
  return "".concat(protocol, "//").concat(hostname).concat(portWithPrefix).concat(pathname, "?").concat(queryString).concat(hash);
9645
- } : _ref2$createURL,
9646
- _ref2$parseURL = _ref2.parseURL,
9647
- parseURL = _ref2$parseURL === void 0 ? function (_ref4) {
9648
- var qsModule = _ref4.qsModule,
9649
- location = _ref4.location;
9730
+ } : _ref5$createURL,
9731
+ _ref5$parseURL = _ref5.parseURL,
9732
+ parseURL = _ref5$parseURL === void 0 ? function (_ref7) {
9733
+ var qsModule = _ref7.qsModule,
9734
+ location = _ref7.location;
9650
9735
  // `qs` by default converts arrays with more than 20 items to an object.
9651
9736
  // We want to avoid this because the data structure manipulated can therefore vary.
9652
9737
  // Setting the limit to `100` seems a good number because the engine's default is 100
@@ -9660,16 +9745,28 @@
9660
9745
  return qsModule.parse(location.search.slice(1), {
9661
9746
  arrayLimit: 99
9662
9747
  });
9663
- } : _ref2$parseURL,
9664
- _ref2$writeDelay = _ref2.writeDelay,
9665
- writeDelay = _ref2$writeDelay === void 0 ? 400 : _ref2$writeDelay,
9666
- windowTitle = _ref2.windowTitle;
9748
+ } : _ref5$parseURL,
9749
+ _ref5$writeDelay = _ref5.writeDelay,
9750
+ writeDelay = _ref5$writeDelay === void 0 ? 400 : _ref5$writeDelay,
9751
+ windowTitle = _ref5.windowTitle,
9752
+ _ref5$getLocation = _ref5.getLocation,
9753
+ getLocation = _ref5$getLocation === void 0 ? function () {
9754
+ return safelyRunOnBrowser(function (_ref8) {
9755
+ var window = _ref8.window;
9756
+ return window.location;
9757
+ }, {
9758
+ fallback: function fallback() {
9759
+ throw new Error('You need to provide `getLocation` to the `history` router in environments where `window` does not exist.');
9760
+ }
9761
+ });
9762
+ } : _ref5$getLocation;
9667
9763
 
9668
9764
  return new BrowserHistory({
9669
9765
  createURL: createURL,
9670
9766
  parseURL: parseURL,
9671
9767
  writeDelay: writeDelay,
9672
- windowTitle: windowTitle
9768
+ windowTitle: windowTitle,
9769
+ getLocation: getLocation
9673
9770
  });
9674
9771
  }
9675
9772
 
@@ -9740,7 +9837,8 @@
9740
9837
  if (widget.getWidgetRenderState) {
9741
9838
  var renderState = widget.getWidgetRenderState(initOptions);
9742
9839
 
9743
- if (renderState && _typeof(renderState.widgetParams) === 'object') {
9840
+ if (renderState && renderState.widgetParams) {
9841
+ // casting, as we just earlier checked widgetParams exists, and thus an object
9744
9842
  widgetParams = renderState.widgetParams;
9745
9843
  }
9746
9844
  } // since we destructure in all widgets, the parameters with defaults are set to "undefined"
@@ -9762,7 +9860,14 @@
9762
9860
  }
9763
9861
 
9764
9862
  function isMetadataEnabled() {
9765
- return typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Algolia Crawler') > -1;
9863
+ return safelyRunOnBrowser(function (_ref) {
9864
+ var window = _ref.window;
9865
+ return window.navigator.userAgent.indexOf('Algolia Crawler') > -1;
9866
+ }, {
9867
+ fallback: function fallback() {
9868
+ return false;
9869
+ }
9870
+ });
9766
9871
  }
9767
9872
  /**
9768
9873
  * Exposes the metadata of mounted widgets in a custom
@@ -9773,8 +9878,8 @@
9773
9878
  */
9774
9879
 
9775
9880
  function createMetadataMiddleware() {
9776
- return function (_ref) {
9777
- var instantSearchInstance = _ref.instantSearchInstance;
9881
+ return function (_ref2) {
9882
+ var instantSearchInstance = _ref2.instantSearchInstance;
9778
9883
  var payload = {
9779
9884
  widgets: []
9780
9885
  };
@@ -10267,15 +10372,17 @@
10267
10372
  var nextUiState = typeof uiState === 'function' ? uiState(this.mainIndex.getWidgetUiState({})) : uiState;
10268
10373
 
10269
10374
  var setIndexHelperState = function setIndexHelperState(indexWidget) {
10375
+ var nextIndexUiState = nextUiState[indexWidget.getIndexId()] || {};
10376
+
10270
10377
  {
10271
10378
  checkIndexUiState({
10272
10379
  index: indexWidget,
10273
- indexUiState: nextUiState[indexWidget.getIndexId()]
10380
+ indexUiState: nextIndexUiState
10274
10381
  });
10275
10382
  }
10276
10383
 
10277
10384
  indexWidget.getHelper().setState(indexWidget.getWidgetSearchParameters(indexWidget.getHelper().state, {
10278
- uiState: nextUiState[indexWidget.getIndexId()]
10385
+ uiState: nextIndexUiState
10279
10386
  }));
10280
10387
  indexWidget.getWidgets().filter(isIndexWidget).forEach(setIndexHelperState);
10281
10388
  };
@@ -11051,7 +11158,12 @@
11051
11158
  };
11052
11159
 
11053
11160
  var wrapInsightsClient = function wrapInsightsClient(aa, results, hits) {
11054
- return function (method, payload) {
11161
+ return function (method) {
11162
+ for (var _len = arguments.length, payloads = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
11163
+ payloads[_key - 1] = arguments[_key];
11164
+ }
11165
+
11166
+ var payload = payloads[0];
11055
11167
  _warning(false, "`insights` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/") ;
11056
11168
 
11057
11169
  if (!aa) {
@@ -14088,11 +14200,20 @@
14088
14200
  var connectPoweredBy = function connectPoweredBy(renderFn) {
14089
14201
  var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
14090
14202
  checkRendering(renderFn, withUsage$k());
14091
- var defaultUrl = 'https://www.algolia.com/?' + 'utm_source=instantsearch.js&' + 'utm_medium=website&' + "utm_content=".concat(typeof window !== 'undefined' && window.location ? window.location.hostname : '', "&") + 'utm_campaign=poweredby';
14203
+ var defaultUrl = 'https://www.algolia.com/?' + 'utm_source=instantsearch.js&' + 'utm_medium=website&' + "utm_content=".concat(safelyRunOnBrowser(function (_ref) {
14204
+ var _window$location;
14205
+
14206
+ var window = _ref.window;
14207
+ return ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || '';
14208
+ }, {
14209
+ fallback: function fallback() {
14210
+ return '';
14211
+ }
14212
+ }), "&") + 'utm_campaign=poweredby';
14092
14213
  return function (widgetParams) {
14093
- var _ref = widgetParams || {},
14094
- _ref$url = _ref.url,
14095
- url = _ref$url === void 0 ? defaultUrl : _ref$url;
14214
+ var _ref2 = widgetParams || {},
14215
+ _ref2$url = _ref2.url,
14216
+ url = _ref2$url === void 0 ? defaultUrl : _ref2$url;
14096
14217
 
14097
14218
  return {
14098
14219
  $$type: 'ais.poweredBy',
@@ -14577,6 +14698,11 @@
14577
14698
  };
14578
14699
  };
14579
14700
 
14701
+ // `SpeechRecognition` is an API used on the browser so we can safely disable
14702
+ // the `window` check.
14703
+
14704
+ /* eslint-disable no-restricted-globals */
14705
+
14580
14706
  /* global SpeechRecognition SpeechRecognitionEvent */
14581
14707
  var createVoiceSearchHelper = function createVoiceSearchHelper(_ref) {
14582
14708
  var searchAsYouSpeak = _ref.searchAsYouSpeak,
@@ -21453,28 +21579,27 @@
21453
21579
  }
21454
21580
 
21455
21581
  var KEY = 'ais.infiniteHits';
21456
-
21457
- function hasSessionStorage() {
21458
- return typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined';
21459
- }
21460
-
21461
21582
  function createInfiniteHitsSessionStorageCache() {
21462
21583
  return {
21463
21584
  read: function read(_ref2) {
21464
21585
  var state = _ref2.state;
21586
+ var sessionStorage = safelyRunOnBrowser(function (_ref3) {
21587
+ var window = _ref3.window;
21588
+ return window.sessionStorage;
21589
+ });
21465
21590
 
21466
- if (!hasSessionStorage()) {
21591
+ if (!sessionStorage) {
21467
21592
  return null;
21468
21593
  }
21469
21594
 
21470
21595
  try {
21471
21596
  var cache = JSON.parse( // @ts-expect-error JSON.parse() requires a string, but it actually accepts null, too.
21472
- window.sessionStorage.getItem(KEY));
21597
+ sessionStorage.getItem(KEY));
21473
21598
  return cache && isEqual(cache.state, getStateWithoutPage$1(state)) ? cache.hits : null;
21474
21599
  } catch (error) {
21475
21600
  if (error instanceof SyntaxError) {
21476
21601
  try {
21477
- window.sessionStorage.removeItem(KEY);
21602
+ sessionStorage.removeItem(KEY);
21478
21603
  } catch (err) {// do nothing
21479
21604
  }
21480
21605
  }
@@ -21482,16 +21607,20 @@
21482
21607
  return null;
21483
21608
  }
21484
21609
  },
21485
- write: function write(_ref3) {
21486
- var state = _ref3.state,
21487
- hits = _ref3.hits;
21610
+ write: function write(_ref4) {
21611
+ var state = _ref4.state,
21612
+ hits = _ref4.hits;
21613
+ var sessionStorage = safelyRunOnBrowser(function (_ref5) {
21614
+ var window = _ref5.window;
21615
+ return window.sessionStorage;
21616
+ });
21488
21617
 
21489
- if (!hasSessionStorage()) {
21618
+ if (!sessionStorage) {
21490
21619
  return;
21491
21620
  }
21492
21621
 
21493
21622
  try {
21494
- window.sessionStorage.setItem(KEY, JSON.stringify({
21623
+ sessionStorage.setItem(KEY, JSON.stringify({
21495
21624
  state: getStateWithoutPage$1(state),
21496
21625
  hits: hits
21497
21626
  }));