react-instantsearch-core 7.37.0 → 7.38.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.
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "default", {
9
9
  return _default;
10
10
  }
11
11
  });
12
- var _default = '7.37.0';
12
+ var _default = '7.38.0';
@@ -1,2 +1,2 @@
1
- declare const _default: "7.37.0";
1
+ declare const _default: "7.38.0";
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- var version = '7.37.0';
1
+ var version = '7.38.0';
2
2
 
3
3
  export { version as default };
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch Core 7.37.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch Core 7.38.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -24,7 +24,7 @@
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
26
 
27
- var version$2 = '7.37.0';
27
+ var version$2 = '7.38.0';
28
28
 
29
29
  function _define_property(obj, key, value) {
30
30
  if (key in obj) {
@@ -6903,10 +6903,11 @@
6903
6903
 
6904
6904
  var hasAlphanumeric = new RegExp(/\w/i);
6905
6905
  function getHighlightFromSiblings(parts, i) {
6906
+ var _ref, _ref1;
6906
6907
  var _parts_, _parts_1;
6907
6908
  var current = parts[i];
6908
- var isNextHighlighted = ((_parts_ = parts[i + 1]) === null || _parts_ === void 0 ? void 0 : _parts_.isHighlighted) || true;
6909
- var isPreviousHighlighted = ((_parts_1 = parts[i - 1]) === null || _parts_1 === void 0 ? void 0 : _parts_1.isHighlighted) || true;
6909
+ var isNextHighlighted = (_ref = (_parts_ = parts[i + 1]) === null || _parts_ === void 0 ? void 0 : _parts_.isHighlighted) !== null && _ref !== void 0 ? _ref : true;
6910
+ var isPreviousHighlighted = (_ref1 = (_parts_1 = parts[i - 1]) === null || _parts_1 === void 0 ? void 0 : _parts_1.isHighlighted) !== null && _ref1 !== void 0 ? _ref1 : true;
6910
6911
  if (!hasAlphanumeric.test(unescape$1(current.value)) && isPreviousHighlighted === isNextHighlighted) {
6911
6912
  return isPreviousHighlighted;
6912
6913
  }
@@ -10853,7 +10854,7 @@
10853
10854
  };
10854
10855
  }
10855
10856
 
10856
- var version = '4.103.0';
10857
+ var version = '4.104.0';
10857
10858
 
10858
10859
  var withUsage$r = createDocumentationMessageGenerator({
10859
10860
  name: 'instantsearch'
@@ -13930,12 +13931,10 @@
13930
13931
  var _chatInstance;
13931
13932
  var input = '';
13932
13933
  var open = false;
13933
- var isClearing = false;
13934
13934
  var sendEvent;
13935
13935
  var setInput;
13936
13936
  var setOpen;
13937
13937
  var focusInput;
13938
- var setIsClearing;
13939
13938
  var setFeedbackState;
13940
13939
  var hasValidatedEntryPoints = false;
13941
13940
  var agentId = 'agentId' in options ? options.agentId : undefined;
@@ -13965,21 +13964,17 @@
13965
13964
  _chatInstance.messages = messagesParam;
13966
13965
  };
13967
13966
  var clearMessages = function clearMessages() {
13968
- if (!_chatInstance.messages || _chatInstance.messages.length === 0) {
13969
- return;
13970
- }
13971
13967
  var status = _chatInstance.status;
13972
13968
  if (status === 'submitted' || status === 'streaming') {
13973
13969
  _chatInstance.stop();
13974
13970
  }
13975
- setIsClearing(true);
13976
- };
13977
- var onClearTransitionEnd = function onClearTransitionEnd() {
13971
+ // Reset the non-reactive state first: `setMessages` and `clearError` emit
13972
+ // ChatState callbacks that synchronously re-render, so they must run last
13973
+ // for that render to see the cleared feedback and rotated conversation id.
13974
+ feedbackState = {};
13975
+ _chatInstance.resetConversationId();
13978
13976
  setMessages([]);
13979
13977
  _chatInstance.clearError();
13980
- _chatInstance.resetConversationId();
13981
- feedbackState = {};
13982
- setIsClearing(false);
13983
13978
  };
13984
13979
  var validateEntryPoints = function validateEntryPoints(instantSearchInstance) {
13985
13980
  if (disableTriggerValidation || hasValidatedEntryPoints) {
@@ -14045,22 +14040,37 @@
14045
14040
  }));
14046
14041
  }
14047
14042
  if ('agentId' in options && options.agentId) {
14043
+ var _options_requestOptions, _options_requestOptions1;
14048
14044
  if (!appId || !apiKey) {
14049
14045
  throw new Error(withUsage$o('Could not extract Algolia credentials from the search client.'));
14050
14046
  }
14051
- var baseApi = "https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions?compatibilityMode=ai-sdk-5");
14047
+ var createApi = function createApi() {
14048
+ var bypassCache = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
14049
+ var _options_requestOptions;
14050
+ var api = new URL("https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions"));
14051
+ var queryParameters = _object_spread(_object_spread_props(_object_spread({}, (_options_requestOptions = options.requestOptions) === null || _options_requestOptions === void 0 ? void 0 : _options_requestOptions.queryParameters), {
14052
+ compatibilityMode: 'ai-sdk-5'
14053
+ }), bypassCache ? {
14054
+ cache: false
14055
+ } : {});
14056
+ api.search = new URLSearchParams(queryParameters).toString();
14057
+ return api.toString();
14058
+ };
14059
+ var baseApi = createApi();
14052
14060
  transport = new DefaultChatTransport({
14053
14061
  api: baseApi,
14054
- headers: {
14062
+ headers: _object_spread_props(_object_spread({}, _instanceof((_options_requestOptions = options.requestOptions) === null || _options_requestOptions === void 0 ? void 0 : _options_requestOptions.headers, Headers) ? Object.fromEntries(options.requestOptions.headers.entries()) : (_options_requestOptions1 = options.requestOptions) === null || _options_requestOptions1 === void 0 ? void 0 : _options_requestOptions1.headers), {
14063
+ // Preserve the required Algolia identity headers and chat agent
14064
+ // marker, even when requestOptions.headers contains the same keys.
14055
14065
  'x-algolia-application-id': appId,
14056
14066
  'x-algolia-api-key': apiKey,
14057
14067
  'x-algolia-agent': "".concat(getAlgoliaAgent(client), "; chat")
14058
- },
14068
+ }),
14059
14069
  prepareSendMessagesRequest: function prepareSendMessagesRequest(param) {
14060
14070
  var id = param.id, messages = param.messages, trigger = param.trigger, messageId = param.messageId;
14061
14071
  return {
14062
14072
  // Bypass cache when regenerating to ensure fresh responses
14063
- api: trigger === 'regenerate-message' ? "".concat(baseApi, "&cache=false") : baseApi,
14073
+ api: trigger === 'regenerate-message' ? createApi(true) : baseApi,
14064
14074
  body: {
14065
14075
  id: id,
14066
14076
  messageId: messageId,
@@ -14145,10 +14155,6 @@
14145
14155
  input = i;
14146
14156
  render();
14147
14157
  };
14148
- setIsClearing = function setIsClearing(value) {
14149
- isClearing = value;
14150
- render();
14151
- };
14152
14158
  setFeedbackState = function setFeedbackState(messageId, state) {
14153
14159
  feedbackState = _object_spread_props(_object_spread({}, feedbackState), _define_property({}, messageId, state));
14154
14160
  render();
@@ -14267,9 +14273,7 @@
14267
14273
  focusInput: focusInput,
14268
14274
  setMessages: setMessages,
14269
14275
  suggestions: getSuggestionsFromMessages(_chatInstance.messages),
14270
- isClearing: isClearing,
14271
14276
  clearMessages: clearMessages,
14272
- onClearTransitionEnd: onClearTransitionEnd,
14273
14277
  tools: toolsWithAddToolResult,
14274
14278
  sendChatMessageFeedback: _sendChatMessageFeedback,
14275
14279
  feedbackState: feedbackState,