instantsearch.js 4.75.5 → 4.75.7

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 (46) hide show
  1. package/cjs/components/Slider/Rheostat.js +4 -4
  2. package/cjs/connectors/autocomplete/connectAutocomplete.js +9 -5
  3. package/cjs/connectors/current-refinements/connectCurrentRefinements.js +1 -1
  4. package/cjs/connectors/hits/connectHitsWithInsights.js +3 -1
  5. package/cjs/connectors/infinite-hits/connectInfiniteHits.js +1 -1
  6. package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +3 -1
  7. package/cjs/lib/InstantSearch.js +2 -0
  8. package/cjs/lib/server.js +5 -2
  9. package/cjs/lib/utils/getAppIdAndApiKey.js +4 -1
  10. package/cjs/lib/utils/getRefinements.js +2 -1
  11. package/cjs/lib/version.js +1 -1
  12. package/cjs/middlewares/createInsightsMiddleware.js +37 -78
  13. package/cjs/widgets/analytics/analytics.js +3 -0
  14. package/cjs/widgets/hits/defaultTemplates.js +1 -0
  15. package/cjs/widgets/index/index.js +0 -1
  16. package/cjs/widgets/places/places.js +2 -0
  17. package/dist/instantsearch.development.d.ts +4 -4
  18. package/dist/instantsearch.development.js +87 -110
  19. package/dist/instantsearch.development.js.map +1 -1
  20. package/dist/instantsearch.production.d.ts +4 -4
  21. package/dist/instantsearch.production.min.d.ts +4 -4
  22. package/dist/instantsearch.production.min.js +2 -2
  23. package/dist/instantsearch.production.min.js.map +1 -1
  24. package/es/connectors/autocomplete/connectAutocomplete.js +9 -5
  25. package/es/connectors/current-refinements/connectCurrentRefinements.js +1 -1
  26. package/es/connectors/hits/connectHitsWithInsights.js +3 -1
  27. package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +1 -1
  28. package/es/connectors/infinite-hits/connectInfiniteHits.js +1 -1
  29. package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +3 -1
  30. package/es/lib/InstantSearch.js +2 -0
  31. package/es/lib/server.js +5 -2
  32. package/es/lib/utils/getAppIdAndApiKey.d.ts +1 -1
  33. package/es/lib/utils/getAppIdAndApiKey.js +4 -1
  34. package/es/lib/utils/getRefinements.d.ts +1 -1
  35. package/es/lib/utils/getRefinements.js +2 -1
  36. package/es/lib/utils/render-args.d.ts +1 -1
  37. package/es/lib/version.d.ts +1 -1
  38. package/es/lib/version.js +1 -1
  39. package/es/middlewares/createInsightsMiddleware.js +37 -78
  40. package/es/types/widget.d.ts +3 -3
  41. package/es/widgets/analytics/analytics.js +3 -0
  42. package/es/widgets/hits/defaultTemplates.js +1 -0
  43. package/es/widgets/index/index.js +0 -1
  44. package/es/widgets/places/places.js +2 -0
  45. package/es/widgets/search-box/defaultTemplates.js +0 -1
  46. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.75.5 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.75.7 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
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) :
@@ -1172,7 +1172,10 @@
1172
1172
 
1173
1173
  // typed as any, since it accepts the _real_ js clients, not the interface we otherwise expect
1174
1174
  function getAppIdAndApiKey(searchClient) {
1175
- if (searchClient.transporter) {
1175
+ if (searchClient.appId && searchClient.apiKey) {
1176
+ // searchClient v5
1177
+ return [searchClient.appId, searchClient.apiKey];
1178
+ } else if (searchClient.transporter) {
1176
1179
  // searchClient v4 or v5
1177
1180
  var transporter = searchClient.transporter;
1178
1181
  var headers = transporter.headers || transporter.baseHeaders;
@@ -1299,8 +1302,9 @@
1299
1302
  }
1300
1303
  return res;
1301
1304
  }
1302
- function getRefinements(results, state) {
1305
+ function getRefinements(_results, state) {
1303
1306
  var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1307
+ var results = _results || {};
1304
1308
  var refinements = [];
1305
1309
  var _state$facetsRefineme = state.facetsRefinements,
1306
1310
  facetsRefinements = _state$facetsRefineme === void 0 ? {} : _state$facetsRefineme,
@@ -3129,7 +3133,7 @@
3129
3133
 
3130
3134
  mod[attribute] = facetRefinement;
3131
3135
 
3132
- return defaultsPure({}, mod, refinementList);
3136
+ return defaultsPure(mod, refinementList);
3133
3137
  },
3134
3138
  /**
3135
3139
  * Removes refinement(s) for an attribute:
@@ -4463,7 +4467,6 @@
4463
4467
 
4464
4468
  return this.setQueryParameters({
4465
4469
  hierarchicalFacetsRefinements: defaultsPure(
4466
- {},
4467
4470
  mod,
4468
4471
  this.hierarchicalFacetsRefinements
4469
4472
  ),
@@ -4491,7 +4494,6 @@
4491
4494
  mod[facet] = [path];
4492
4495
  return this.setQueryParameters({
4493
4496
  hierarchicalFacetsRefinements: defaultsPure(
4494
- {},
4495
4497
  mod,
4496
4498
  this.hierarchicalFacetsRefinements
4497
4499
  ),
@@ -4512,7 +4514,6 @@
4512
4514
  mod[facet] = [];
4513
4515
  return this.setQueryParameters({
4514
4516
  hierarchicalFacetsRefinements: defaultsPure(
4515
- {},
4516
4517
  mod,
4517
4518
  this.hierarchicalFacetsRefinements
4518
4519
  ),
@@ -5510,12 +5511,9 @@
5510
5511
  });
5511
5512
 
5512
5513
  // Make every key of the result options reachable from the instance
5513
- var opts = merge_1(
5514
- {
5515
- persistHierarchicalRootCount: false,
5516
- },
5517
- options
5518
- );
5514
+ var opts = defaultsPure(options, {
5515
+ persistHierarchicalRootCount: false,
5516
+ });
5519
5517
  Object.keys(opts).forEach(function (key) {
5520
5518
  self[key] = opts[key];
5521
5519
  });
@@ -5782,11 +5780,16 @@
5782
5780
  return;
5783
5781
  }
5784
5782
 
5785
- self.hierarchicalFacets[position][attributeIndex].data = merge_1(
5786
- {},
5787
- self.hierarchicalFacets[position][attributeIndex].data,
5788
- facetResults
5789
- );
5783
+ self.hierarchicalFacets[position][attributeIndex].data =
5784
+ self.persistHierarchicalRootCount
5785
+ ? defaultsPure(
5786
+ self.hierarchicalFacets[position][attributeIndex].data,
5787
+ facetResults
5788
+ )
5789
+ : defaultsPure(
5790
+ facetResults,
5791
+ self.hierarchicalFacets[position][attributeIndex].data
5792
+ );
5790
5793
  } else {
5791
5794
  position = disjunctiveFacetsIndices[dfacet];
5792
5795
 
@@ -5795,7 +5798,7 @@
5795
5798
 
5796
5799
  self.disjunctiveFacets[position] = {
5797
5800
  name: dfacet,
5798
- data: defaultsPure({}, facetResults, dataFromMainRequest),
5801
+ data: defaultsPure(dataFromMainRequest, facetResults),
5799
5802
  exhaustive: result.exhaustiveFacetsCount,
5800
5803
  };
5801
5804
  assignFacetStats(
@@ -6193,7 +6196,7 @@
6193
6196
  return undefined;
6194
6197
  }
6195
6198
 
6196
- var options = defaultsPure({}, opts, {
6199
+ var options = defaultsPure(opts, {
6197
6200
  sortBy: SearchResults.DEFAULT_SORT,
6198
6201
  // if no sortBy is given, attempt to sort based on facetOrdering
6199
6202
  // if it is given, we still allow to sort via facet ordering first
@@ -6484,7 +6487,7 @@
6484
6487
 
6485
6488
  var sortAndMergeRecommendations_1 = sortAndMergeRecommendations;
6486
6489
 
6487
- var version = '3.22.5';
6490
+ var version = '3.22.6';
6488
6491
 
6489
6492
  var escapeFacetValue$4 = escapeFacetValue_1.escapeFacetValue;
6490
6493
 
@@ -9048,7 +9051,7 @@
9048
9051
  function getItems() {
9049
9052
  if (!results) {
9050
9053
  return transformItems(getRefinementsItems({
9051
- results: {},
9054
+ results: null,
9052
9055
  helper: helper,
9053
9056
  indexId: helper.state.index,
9054
9057
  includedAttributes: includedAttributes,
@@ -9736,7 +9739,9 @@
9736
9739
  * Due to https://github.com/microsoft/web-build-tools/issues/1050, we need
9737
9740
  * Connector<...> imported in this file, even though it is only used implicitly.
9738
9741
  * This _uses_ Connector<...> so it is not accidentally removed by someone.
9739
- */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9742
+ */
9743
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9744
+
9740
9745
  var connectHitsWithInsights = withInsights(connectHits);
9741
9746
 
9742
9747
  var withUsage$8 = createDocumentationMessageGenerator({
@@ -10079,7 +10084,7 @@
10079
10084
  sendEvent: sendEvent,
10080
10085
  bindEvent: bindEvent,
10081
10086
  banner: banner,
10082
- results: results,
10087
+ results: results || undefined,
10083
10088
  showPrevious: showPrevious,
10084
10089
  showMore: showMore,
10085
10090
  isFirstPage: isFirstPage,
@@ -10133,7 +10138,9 @@
10133
10138
  * Due to https://github.com/microsoft/web-build-tools/issues/1050, we need
10134
10139
  * Connector<...> imported in this file, even though it is only used implicitly.
10135
10140
  * This _uses_ Connector<...> so it is not accidentally removed by someone.
10136
- */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
10141
+ */
10142
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
10143
+
10137
10144
  var connectInfiniteHitsWithInsights = withInsights(connectInfiniteHits);
10138
10145
 
10139
10146
  var _excluded$3 = ["name", "escapedValue", "path"];
@@ -12789,21 +12796,25 @@
12789
12796
  };
12790
12797
  }
12791
12798
  var indices = scopedResults.map(function (scopedResult) {
12799
+ var _scopedResult$results2, _scopedResult$results3;
12792
12800
  // We need to escape the hits because highlighting
12793
12801
  // exposes HTML tags to the end-user.
12794
- scopedResult.results.hits = escapeHTML ? escapeHits(scopedResult.results.hits) : scopedResult.results.hits;
12802
+ if (scopedResult.results) {
12803
+ scopedResult.results.hits = escapeHTML ? escapeHits(scopedResult.results.hits) : scopedResult.results.hits;
12804
+ }
12795
12805
  var sendEvent = createSendEventForHits({
12796
12806
  instantSearchInstance: instantSearchInstance,
12797
12807
  getIndex: function getIndex() {
12798
- return scopedResult.results.index;
12808
+ var _scopedResult$results;
12809
+ return ((_scopedResult$results = scopedResult.results) === null || _scopedResult$results === void 0 ? void 0 : _scopedResult$results.index) || '';
12799
12810
  },
12800
12811
  widgetType: _this.$$type
12801
12812
  });
12802
12813
  return {
12803
12814
  indexId: scopedResult.indexId,
12804
- indexName: scopedResult.results.index,
12805
- hits: scopedResult.results.hits,
12806
- results: scopedResult.results,
12815
+ indexName: ((_scopedResult$results2 = scopedResult.results) === null || _scopedResult$results2 === void 0 ? void 0 : _scopedResult$results2.index) || '',
12816
+ hits: ((_scopedResult$results3 = scopedResult.results) === null || _scopedResult$results3 === void 0 ? void 0 : _scopedResult$results3.hits) || [],
12817
+ results: scopedResult.results || {},
12807
12818
  sendEvent: sendEvent
12808
12819
  };
12809
12820
  });
@@ -13754,7 +13765,6 @@
13754
13765
  $$internal = _props$$$internal === void 0 ? false : _props$$$internal,
13755
13766
  _props$$$automatic = props.$$automatic,
13756
13767
  $$automatic = _props$$$automatic === void 0 ? false : _props$$$automatic;
13757
- var currentTokenType;
13758
13768
  var potentialInsightsClient = _insightsClient;
13759
13769
  if (!_insightsClient && _insightsClient !== null) {
13760
13770
  safelyRunOnBrowser(function (_ref) {
@@ -13803,9 +13813,7 @@
13803
13813
  _warning(Boolean(appId && apiKey), 'could not extract Algolia credentials from searchClient in insights middleware.') ;
13804
13814
  var queuedInitParams = undefined;
13805
13815
  var queuedUserToken = undefined;
13806
- var queuedAuthenticatedUserToken = undefined;
13807
13816
  var userTokenBeforeInit = undefined;
13808
- var authenticatedUserTokenBeforeInit = undefined;
13809
13817
  var queue = insightsClient.queue;
13810
13818
  if (Array.isArray(queue)) {
13811
13819
  // Context: The umd build of search-insights is asynchronously loaded by the snippet.
@@ -13818,7 +13826,7 @@
13818
13826
  // At this point, even though `search-insights` is not loaded yet,
13819
13827
  // we still want to read the token from the queue.
13820
13828
  // Otherwise, the first search call will be fired without the token.
13821
- var _map = ['setUserToken', 'setAuthenticatedUserToken', 'init'].map(function (key) {
13829
+ var _map = ['setUserToken', 'init'].map(function (key) {
13822
13830
  var _ref3 = find(queue.slice().reverse(), function (_ref5) {
13823
13831
  var _ref6 = _slicedToArray(_ref5, 1),
13824
13832
  method = _ref6[0];
@@ -13828,23 +13836,18 @@
13828
13836
  value = _ref4[1];
13829
13837
  return value;
13830
13838
  });
13831
- var _map2 = _slicedToArray(_map, 3);
13839
+ var _map2 = _slicedToArray(_map, 2);
13832
13840
  queuedUserToken = _map2[0];
13833
- queuedAuthenticatedUserToken = _map2[1];
13834
- queuedInitParams = _map2[2];
13841
+ queuedInitParams = _map2[1];
13835
13842
  }
13836
13843
 
13837
- // If user called `aa('setUserToken')` or `aa('setAuthenticatedUserToken')`
13838
- // before creating the Insights middleware, we temporarily store the token
13839
- // and set it later on.
13844
+ // If user called `aa('setUserToken')` before creating the Insights middleware,
13845
+ // we temporarily store the token and set it later on.
13840
13846
  //
13841
13847
  // Otherwise, the `init` call might override them with anonymous user token.
13842
13848
  insightsClient('getUserToken', null, function (_error, userToken) {
13843
13849
  userTokenBeforeInit = normalizeUserToken(userToken);
13844
13850
  });
13845
- insightsClient('getAuthenticatedUserToken', null, function (_error, userToken) {
13846
- authenticatedUserTokenBeforeInit = normalizeUserToken(userToken);
13847
- });
13848
13851
 
13849
13852
  // Only `init` if the `insightsInitParams` option is passed or
13850
13853
  // if the `insightsClient` version doesn't supports optional `init` calling.
@@ -13884,7 +13887,7 @@
13884
13887
  helper = instantSearchInstance.mainHelper;
13885
13888
  var queueAtStart = insightsClient.queue;
13886
13889
  if (Array.isArray(queueAtStart)) {
13887
- var _map3 = ['setUserToken', 'setAuthenticatedUserToken', 'init'].map(function (key) {
13890
+ var _map3 = ['setUserToken', 'init'].map(function (key) {
13888
13891
  var _ref7 = find(queueAtStart.slice().reverse(), function (_ref9) {
13889
13892
  var _ref10 = _slicedToArray(_ref9, 1),
13890
13893
  method = _ref10[0];
@@ -13894,15 +13897,11 @@
13894
13897
  value = _ref8[1];
13895
13898
  return value;
13896
13899
  });
13897
- var _map4 = _slicedToArray(_map3, 3);
13900
+ var _map4 = _slicedToArray(_map3, 2);
13898
13901
  queuedUserToken = _map4[0];
13899
- queuedAuthenticatedUserToken = _map4[1];
13900
- queuedInitParams = _map4[2];
13902
+ queuedInitParams = _map4[1];
13901
13903
  }
13902
- initialParameters = {
13903
- userToken: helper.state.userToken,
13904
- clickAnalytics: helper.state.clickAnalytics
13905
- };
13904
+ initialParameters = getInitialParameters(instantSearchInstance);
13906
13905
 
13907
13906
  // We don't want to force clickAnalytics when the insights is enabled from the search response.
13908
13907
  // This means we don't enable insights for indices that don't opt in
@@ -13914,9 +13913,8 @@
13914
13913
  if (!$$internal) {
13915
13914
  instantSearchInstance.scheduleSearch();
13916
13915
  }
13917
- var setUserTokenToSearch = function setUserTokenToSearch(userToken, tokenType) {
13918
- var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
13919
- var unsetAuthenticatedUserToken = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
13916
+ var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
13917
+ var immediate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
13920
13918
  var normalizedUserToken = normalizeUserToken(userToken);
13921
13919
  if (!normalizedUserToken) {
13922
13920
  return;
@@ -13929,13 +13927,6 @@
13929
13927
  if (existingToken && existingToken !== userToken) {
13930
13928
  instantSearchInstance.scheduleSearch();
13931
13929
  }
13932
- currentTokenType = tokenType;
13933
- }
13934
-
13935
- // the authenticated user token cannot be overridden by a user or anonymous token
13936
- // for instant search query requests
13937
- if (currentTokenType && currentTokenType === 'authenticated' && tokenType === 'default' && !unsetAuthenticatedUserToken) {
13938
- return;
13939
13930
  }
13940
13931
 
13941
13932
  // Delay the token application to the next render cycle
@@ -13945,14 +13936,9 @@
13945
13936
  applyToken();
13946
13937
  }
13947
13938
  };
13948
- function setUserToken(token, userToken, authenticatedUserToken) {
13949
- setUserTokenToSearch(token, authenticatedUserToken ? 'authenticated' : 'default', true);
13950
- if (userToken) {
13951
- insightsClient('setUserToken', userToken);
13952
- }
13953
- if (authenticatedUserToken) {
13954
- insightsClient('setAuthenticatedUserToken', authenticatedUserToken);
13955
- }
13939
+ function setUserToken(token) {
13940
+ setUserTokenToSearch(token, true);
13941
+ insightsClient('setUserToken', token);
13956
13942
  }
13957
13943
  var anonymousUserToken = undefined;
13958
13944
  var anonymousTokenFromInsights = getInsightsAnonymousUserTokenInternal();
@@ -13966,7 +13952,6 @@
13966
13952
  var token = "anonymous-".concat(createUUID());
13967
13953
  anonymousUserToken = token;
13968
13954
  }
13969
- var authenticatedUserTokenFromInit;
13970
13955
  var userTokenFromInit;
13971
13956
 
13972
13957
  // With SSR, the token could be be set on the state. We make sure
@@ -13974,36 +13959,25 @@
13974
13959
  // insights lib on the server.
13975
13960
  var tokenFromSearchParameters = initialParameters.userToken;
13976
13961
 
13977
- // When the first query is sent, the token is possibly not yet be set by
13962
+ // When the first query is sent, the token is possibly not yet set by
13978
13963
  // the insights onChange callbacks (if insights isn't yet loaded).
13979
13964
  // It is explicitly being set here so that the first query has the
13980
13965
  // initial tokens set and ensure a second query isn't automatically
13981
13966
  // made when the onChange callback actually changes the state.
13982
- if (insightsInitParams) {
13983
- if (insightsInitParams.authenticatedUserToken) {
13984
- authenticatedUserTokenFromInit = insightsInitParams.authenticatedUserToken;
13985
- } else if (insightsInitParams.userToken) {
13986
- userTokenFromInit = insightsInitParams.userToken;
13987
- }
13967
+ if (insightsInitParams !== null && insightsInitParams !== void 0 && insightsInitParams.userToken) {
13968
+ userTokenFromInit = insightsInitParams.userToken;
13988
13969
  }
13989
-
13990
- // We consider the `userToken` or `authenticatedUserToken` before an
13991
- // `init` call of higher importance than one from the queue and ones set
13992
- // from the init props to be higher than that.
13993
- var tokenFromInit = authenticatedUserTokenFromInit || userTokenFromInit;
13994
- var tokenBeforeInit = authenticatedUserTokenBeforeInit || userTokenBeforeInit;
13995
- var tokenFromQueue = queuedAuthenticatedUserToken || queuedUserToken;
13996
- if (tokenFromInit) {
13997
- setUserToken(tokenFromInit, userTokenFromInit, authenticatedUserTokenFromInit);
13970
+ if (userTokenFromInit) {
13971
+ setUserToken(userTokenFromInit);
13998
13972
  } else if (tokenFromSearchParameters) {
13999
- setUserToken(tokenFromSearchParameters, tokenFromSearchParameters, undefined);
14000
- } else if (tokenBeforeInit) {
14001
- setUserToken(tokenBeforeInit, userTokenBeforeInit, authenticatedUserTokenBeforeInit);
14002
- } else if (tokenFromQueue) {
14003
- setUserToken(tokenFromQueue, queuedUserToken, queuedAuthenticatedUserToken);
13973
+ setUserToken(tokenFromSearchParameters);
13974
+ } else if (userTokenBeforeInit) {
13975
+ setUserToken(userTokenBeforeInit);
13976
+ } else if (queuedUserToken) {
13977
+ setUserToken(queuedUserToken);
14004
13978
  } else if (anonymousUserToken) {
14005
13979
  var _queuedInitParams;
14006
- setUserToken(anonymousUserToken, anonymousUserToken, undefined);
13980
+ setUserToken(anonymousUserToken);
14007
13981
  if (insightsInitParams !== null && insightsInitParams !== void 0 && insightsInitParams.useCookie || (_queuedInitParams = queuedInitParams) !== null && _queuedInitParams !== void 0 && _queuedInitParams.useCookie) {
14008
13982
  var _queuedInitParams2;
14009
13983
  saveTokenAsCookie(anonymousUserToken, (insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.cookieDuration) || ((_queuedInitParams2 = queuedInitParams) === null || _queuedInitParams2 === void 0 ? void 0 : _queuedInitParams2.cookieDuration));
@@ -14012,20 +13986,7 @@
14012
13986
 
14013
13987
  // This updates userToken which is set explicitly by `aa('setUserToken', userToken)`
14014
13988
  insightsClient('onUserTokenChange', function (token) {
14015
- return setUserTokenToSearch(token, 'default', true);
14016
- }, {
14017
- immediate: true
14018
- });
14019
-
14020
- // This updates userToken which is set explicitly by `aa('setAuthenticatedtUserToken', authenticatedUserToken)`
14021
- insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) {
14022
- // If we're unsetting the `authenticatedUserToken`, we revert to the `userToken`
14023
- if (!authenticatedUserToken) {
14024
- insightsClient('getUserToken', null, function (_, userToken) {
14025
- setUserTokenToSearch(userToken, 'default', true, true);
14026
- });
14027
- }
14028
- setUserTokenToSearch(authenticatedUserToken, 'authenticated', true);
13989
+ return setUserTokenToSearch(token, true);
14029
13990
  }, {
14030
13991
  immediate: true
14031
13992
  });
@@ -14047,7 +14008,7 @@
14047
14008
  var lastQueryId;
14048
14009
  instantSearchInstance.mainHelper.derivedHelpers[0].on('result', function (_ref11) {
14049
14010
  var results = _ref11.results;
14050
- if (!results.queryID || results.queryID !== lastQueryId) {
14011
+ if (results && (!results.queryID || results.queryID !== lastQueryId)) {
14051
14012
  lastQueryId = results.queryID;
14052
14013
  viewedObjectIDs.clear();
14053
14014
  }
@@ -14087,7 +14048,6 @@
14087
14048
  },
14088
14049
  unsubscribe: function unsubscribe() {
14089
14050
  insightsClient('onUserTokenChange', undefined);
14090
- insightsClient('onAuthenticatedUserTokenChange', undefined);
14091
14051
  instantSearchInstance.sendEventToInsights = noop;
14092
14052
  if (helper && initialParameters) {
14093
14053
  helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), initialParameters));
@@ -14097,6 +14057,16 @@
14097
14057
  };
14098
14058
  };
14099
14059
  }
14060
+ function getInitialParameters(instantSearchInstance) {
14061
+ var _instantSearchInstanc, _instantSearchInstanc2;
14062
+ // in SSR, the initial state we use in this domain is set on the main index
14063
+ var stateFromInitialResults = ((_instantSearchInstanc = instantSearchInstance._initialResults) === null || _instantSearchInstanc === void 0 ? void 0 : (_instantSearchInstanc2 = _instantSearchInstanc[instantSearchInstance.indexName]) === null || _instantSearchInstanc2 === void 0 ? void 0 : _instantSearchInstanc2.state) || {};
14064
+ var stateFromHelper = instantSearchInstance.mainHelper.state;
14065
+ return {
14066
+ userToken: stateFromInitialResults.userToken || stateFromHelper.userToken,
14067
+ clickAnalytics: stateFromInitialResults.clickAnalytics || stateFromHelper.clickAnalytics
14068
+ };
14069
+ }
14100
14070
  function saveTokenAsCookie(token, cookieDuration) {
14101
14071
  var MONTH = 30 * 24 * 60 * 60 * 1000;
14102
14072
  var d = new Date();
@@ -15484,7 +15454,6 @@
15484
15454
  // TODO: emit "change" event when events for Recommend are implemented
15485
15455
  }
15486
15456
  }
15487
-
15488
15457
  function getLocalWidgetsUiState(widgets, widgetStateOptions) {
15489
15458
  var initialUiState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15490
15459
  return widgets.reduce(function (uiState, widget) {
@@ -16132,7 +16101,7 @@
16132
16101
  };
16133
16102
  }
16134
16103
 
16135
- var version$1 = '4.75.5';
16104
+ var version$1 = '4.75.7';
16136
16105
 
16137
16106
  var withUsage$v = createDocumentationMessageGenerator({
16138
16107
  name: 'instantsearch'
@@ -16144,9 +16113,11 @@
16144
16113
  // this purposely breaks typescript's type inference to ensure it's not used
16145
16114
  // as it's used for a default parameter for example
16146
16115
  // source: https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-504042546
16116
+
16147
16117
  /**
16148
16118
  * Global options for an InstantSearch instance.
16149
16119
  */
16120
+
16150
16121
  var INSTANTSEARCH_FUTURE_DEFAULTS = {
16151
16122
  preserveSharedStateOnUnmount: false,
16152
16123
  persistHierarchicalRootCount: false
@@ -19153,6 +19124,9 @@
19153
19124
  render: function render(_ref2) {
19154
19125
  var results = _ref2.results,
19155
19126
  state = _ref2.state;
19127
+ if (!results) {
19128
+ return;
19129
+ }
19156
19130
  if (isInitialSearch === true) {
19157
19131
  isInitialSearch = false;
19158
19132
  return;
@@ -20765,6 +20739,7 @@
20765
20739
 
20766
20740
  // false positive lint error
20767
20741
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
20742
+
20768
20743
  var defaultTemplates$5 = {
20769
20744
  empty: function empty() {
20770
20745
  return 'No results';
@@ -22088,7 +22063,9 @@
22088
22063
 
22089
22064
  /* Places.js is an optional dependency, no error should be reported if the package is missing */
22090
22065
  /** @ts-ignore */
22066
+
22091
22067
  // using the type like this requires only one ts-ignore
22068
+
22092
22069
  /**
22093
22070
  * This widget sets the geolocation value for the search based on the selected
22094
22071
  * result in the Algolia Places autocomplete.