react-instantsearch-core 7.39.0 → 7.40.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.
@@ -126,7 +126,10 @@ function useConnector(connector) {
126
126
  (0, _useWidget.useWidget)({
127
127
  widget: widget,
128
128
  parentIndex: parentIndex,
129
- props: stableProps,
129
+ props: [
130
+ stableProps,
131
+ stableAdditionalWidgetProperties
132
+ ],
130
133
  shouldSsr: Boolean(serverContext),
131
134
  skipSuspense: skipSuspense
132
135
  });
@@ -15,5 +15,8 @@ var InstantSearchRSCContext = (0, _react.createContext)({
15
15
  current: 0
16
16
  },
17
17
  waitForResultsRef: null,
18
+ resolveWaitForResultsRef: {
19
+ current: null
20
+ },
18
21
  ignoreMultipleHooksWarning: false
19
22
  });
@@ -42,6 +42,13 @@ function getServerState(children, param) {
42
42
  var shouldRefetch = false;
43
43
  // Two-pass widgets require another query to discover and mount child widgets.
44
44
  (0, _utils.walkIndex)(searchRef.current.mainIndex, function(index) {
45
+ var current = index;
46
+ while(current){
47
+ if (current._isolated) {
48
+ return;
49
+ }
50
+ current = current.getParent();
51
+ }
45
52
  shouldRefetch = shouldRefetch || index.getWidgets().some(_utils.isTwoPassWidget);
46
53
  });
47
54
  if (shouldRefetch) {
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "default", {
9
9
  return _default;
10
10
  }
11
11
  });
12
- var _default = '7.39.0';
12
+ var _default = '7.40.0';
@@ -116,7 +116,10 @@ function useConnector(connector) {
116
116
  useWidget({
117
117
  widget: widget,
118
118
  parentIndex: parentIndex,
119
- props: stableProps,
119
+ props: [
120
+ stableProps,
121
+ stableAdditionalWidgetProperties
122
+ ],
120
123
  shouldSsr: Boolean(serverContext),
121
124
  skipSuspense: skipSuspense
122
125
  });
@@ -2,6 +2,7 @@ import type { PromiseWithState } from './wrapPromiseWithState';
2
2
  import type { RefObject } from 'react';
3
3
  export type InstantSearchRSCContextApi = {
4
4
  waitForResultsRef: RefObject<PromiseWithState<void> | null> | null;
5
+ resolveWaitForResultsRef?: RefObject<(() => void) | null>;
5
6
  countRef: RefObject<number>;
6
7
  ignoreMultipleHooksWarning: boolean;
7
8
  };
@@ -5,6 +5,9 @@ var InstantSearchRSCContext = createContext({
5
5
  current: 0
6
6
  },
7
7
  waitForResultsRef: null,
8
+ resolveWaitForResultsRef: {
9
+ current: null
10
+ },
8
11
  ignoreMultipleHooksWarning: false
9
12
  });
10
13
 
@@ -33,6 +33,13 @@ import { InstantSearchSSRProvider } from '../components/InstantSearchSSRProvider
33
33
  var shouldRefetch = false;
34
34
  // Two-pass widgets require another query to discover and mount child widgets.
35
35
  walkIndex(searchRef.current.mainIndex, function(index) {
36
+ var current = index;
37
+ while(current){
38
+ if (current._isolated) {
39
+ return;
40
+ }
41
+ current = current.getParent();
42
+ }
36
43
  shouldRefetch = shouldRefetch || index.getWidgets().some(isTwoPassWidget);
37
44
  });
38
45
  if (shouldRefetch) {
@@ -1,2 +1,2 @@
1
- declare const _default: "7.39.0";
1
+ declare const _default: "7.40.0";
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- var version = '7.39.0';
1
+ var version = '7.40.0';
2
2
 
3
3
  export { version as default };
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch Core 7.39.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch Core 7.40.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.39.0';
27
+ var version$2 = '7.40.0';
28
28
 
29
29
  function _define_property(obj, key, value) {
30
30
  if (key in obj) {
@@ -7528,6 +7528,9 @@
7528
7528
  current: 0
7529
7529
  },
7530
7530
  waitForResultsRef: null,
7531
+ resolveWaitForResultsRef: {
7532
+ current: null
7533
+ },
7531
7534
  ignoreMultipleHooksWarning: false
7532
7535
  });
7533
7536
 
@@ -7762,7 +7765,10 @@
7762
7765
  useWidget({
7763
7766
  widget: widget,
7764
7767
  parentIndex: parentIndex,
7765
- props: stableProps,
7768
+ props: [
7769
+ stableProps,
7770
+ stableAdditionalWidgetProperties
7771
+ ],
7766
7772
  shouldSsr: Boolean(serverContext),
7767
7773
  skipSuspense: skipSuspense
7768
7774
  });
@@ -8499,6 +8505,39 @@
8499
8505
  ].concat(_to_consumable_array(resolveScopedResultsFromWidgets(current.getWidgets()))));
8500
8506
  }, []);
8501
8507
  }
8508
+ function getWidgetsRequestDependencies(widgets) {
8509
+ return widgets.reduce(function(dependencies, widget) {
8510
+ if (isIndexWidget(widget)) {
8511
+ if (widget._isolated) {
8512
+ return dependencies;
8513
+ }
8514
+ var childDependencies = getWidgetsRequestDependencies(widget.getWidgets());
8515
+ return {
8516
+ hasSearchWidget: dependencies.hasSearchWidget || childDependencies.hasSearchWidget,
8517
+ hasRecommendWidget: dependencies.hasRecommendWidget || childDependencies.hasRecommendWidget
8518
+ };
8519
+ }
8520
+ if (widget.dependsOn === 'recommend') {
8521
+ return _object_spread_props(_object_spread({}, dependencies), {
8522
+ hasRecommendWidget: true
8523
+ });
8524
+ }
8525
+ if (widget.dependsOn === 'none') {
8526
+ return dependencies;
8527
+ }
8528
+ return _object_spread_props(_object_spread({}, dependencies), {
8529
+ hasSearchWidget: true
8530
+ });
8531
+ }, {
8532
+ hasSearchWidget: false,
8533
+ hasRecommendWidget: false
8534
+ });
8535
+ }
8536
+ function recomputeInstantSearchRequestDependencies(instantSearchInstance) {
8537
+ var _getWidgetsRequestDependencies = getWidgetsRequestDependencies(instantSearchInstance.mainIndex.getWidgets()), hasSearchWidget = _getWidgetsRequestDependencies.hasSearchWidget, hasRecommendWidget = _getWidgetsRequestDependencies.hasRecommendWidget;
8538
+ instantSearchInstance._hasSearchWidget = hasSearchWidget;
8539
+ instantSearchInstance._hasRecommendWidget = hasRecommendWidget;
8540
+ }
8502
8541
  var index = function index(widgetParams) {
8503
8542
  if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {
8504
8543
  throw new Error(withUsage$s('The `indexName` option is required.'));
@@ -8513,8 +8552,11 @@
8513
8552
  var helper = null;
8514
8553
  var derivedHelper = null;
8515
8554
  var lastValidSearchParameters = null;
8516
- var hasRecommendWidget = false;
8517
- var hasSearchWidget = false;
8555
+ var recomputeLocalRequestDependencies = function recomputeLocalRequestDependencies() {
8556
+ if (localInstantSearchInstance) {
8557
+ recomputeInstantSearchRequestDependencies(localInstantSearchInstance);
8558
+ }
8559
+ };
8518
8560
  return {
8519
8561
  $$type: 'ais.index',
8520
8562
  $$widgetType: 'ais.index',
@@ -8605,21 +8647,12 @@
8605
8647
  }
8606
8648
  flatWidgets.forEach(function(widget) {
8607
8649
  widget.parent = _this;
8608
- if (isIndexWidget(widget)) {
8609
- return;
8610
- }
8611
- if (localInstantSearchInstance && widget.dependsOn === 'recommend') {
8612
- localInstantSearchInstance._hasRecommendWidget = true;
8613
- } else if (localInstantSearchInstance) {
8614
- localInstantSearchInstance._hasSearchWidget = true;
8615
- } else if (widget.dependsOn === 'recommend') {
8616
- hasRecommendWidget = true;
8617
- } else {
8618
- hasSearchWidget = true;
8650
+ if (!isIndexWidget(widget)) {
8651
+ addWidgetId(widget);
8619
8652
  }
8620
- addWidgetId(widget);
8621
8653
  });
8622
8654
  localWidgets = localWidgets.concat(flatWidgets);
8655
+ recomputeLocalRequestDependencies();
8623
8656
  if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
8624
8657
  privateHelperSetState(helper, {
8625
8658
  state: getLocalWidgetsSearchParameters(localWidgets, {
@@ -8676,21 +8709,10 @@
8676
8709
  localWidgets = localWidgets.filter(function(widget) {
8677
8710
  return flatWidgets.indexOf(widget) === -1;
8678
8711
  });
8679
- localWidgets.forEach(function(widget) {
8712
+ flatWidgets.forEach(function(widget) {
8680
8713
  widget.parent = undefined;
8681
- if (isIndexWidget(widget)) {
8682
- return;
8683
- }
8684
- if (localInstantSearchInstance && widget.dependsOn === 'recommend') {
8685
- localInstantSearchInstance._hasRecommendWidget = true;
8686
- } else if (localInstantSearchInstance) {
8687
- localInstantSearchInstance._hasSearchWidget = true;
8688
- } else if (widget.dependsOn === 'recommend') {
8689
- hasRecommendWidget = true;
8690
- } else {
8691
- hasSearchWidget = true;
8692
- }
8693
8714
  });
8715
+ recomputeLocalRequestDependencies();
8694
8716
  if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
8695
8717
  var _flatWidgets_reduce = flatWidgets.reduce(function(states, widget) {
8696
8718
  // the `dispose` method exists at this point we already assert it
@@ -8913,12 +8935,7 @@
8913
8935
  // schedule a render that will render the results injected on the helper.
8914
8936
  instantSearchInstance.scheduleRender();
8915
8937
  }
8916
- if (hasRecommendWidget) {
8917
- instantSearchInstance._hasRecommendWidget = true;
8918
- }
8919
- if (hasSearchWidget) {
8920
- instantSearchInstance._hasSearchWidget = true;
8921
- }
8938
+ recomputeLocalRequestDependencies();
8922
8939
  },
8923
8940
  render: function render(param) {
8924
8941
  var _this = this;
@@ -9192,7 +9209,7 @@
9192
9209
  });
9193
9210
  }
9194
9211
 
9195
- var version = '4.105.0';
9212
+ var version = '4.107.0';
9196
9213
 
9197
9214
  var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
9198
9215
  function getCookie(name) {
@@ -11333,8 +11350,11 @@
11333
11350
  mainHelper.searchForFacetValues = mainHelper.searchForCompositionFacetValues.bind(mainHelper);
11334
11351
  }
11335
11352
  mainHelper.search = function() {
11336
- _this.status = 'loading';
11337
- _this.scheduleRender(false);
11353
+ var hasSearchOrRecommendWidget = _this._hasSearchWidget || _this._hasRecommendWidget;
11354
+ if (hasSearchOrRecommendWidget) {
11355
+ _this.status = 'loading';
11356
+ }
11357
+ _this.scheduleRender(!hasSearchOrRecommendWidget);
11338
11358
  // This solution allows us to keep the exact same API for the users but
11339
11359
  // under the hood, we have a different implementation. It should be
11340
11360
  // completely transparent for the rest of the codebase. Only this module
@@ -11398,7 +11418,7 @@
11398
11418
  error.error = error;
11399
11419
  _this.error = error;
11400
11420
  _this.status = 'error';
11401
- _this.scheduleRender(false);
11421
+ _this.scheduleRender(!_this._hasSearchWidget && !_this._hasRecommendWidget);
11402
11422
  // This needs to execute last because it throws the error.
11403
11423
  _this.emit('error', error);
11404
11424
  });
@@ -12106,10 +12126,14 @@
12106
12126
  return function(widgetParams) {
12107
12127
  var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(indices) {
12108
12128
  return indices;
12109
- } : _ref_transformItems, tmp = _ref.future, _ref1 = tmp === void 0 ? {} : tmp, _ref_undefinedEmptyQuery = _ref1.undefinedEmptyQuery, undefinedEmptyQuery = _ref_undefinedEmptyQuery === void 0 ? false : _ref_undefinedEmptyQuery;
12129
+ } : _ref_transformItems, _ref_requiresSearch = _ref.requiresSearch, requiresSearch = _ref_requiresSearch === void 0 ? true : _ref_requiresSearch, tmp = _ref.future, _ref1 = tmp === void 0 ? {} : tmp, _ref_undefinedEmptyQuery = _ref1.undefinedEmptyQuery, undefinedEmptyQuery = _ref_undefinedEmptyQuery === void 0 ? false : _ref_undefinedEmptyQuery;
12110
12130
  var connectorState = {};
12111
12131
  return {
12112
12132
  $$type: 'ais.autocomplete',
12133
+ dependsOn: requiresSearch ? 'search' : 'none',
12134
+ shouldRender: requiresSearch ? undefined : function() {
12135
+ return true;
12136
+ },
12113
12137
  init: function init(initOptions) {
12114
12138
  var instantSearchInstance = initOptions.instantSearchInstance;
12115
12139
  renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
@@ -12608,15 +12632,14 @@
12608
12632
  return Promise.resolve(value);
12609
12633
  }
12610
12634
  /**
12611
- * Error raised when the upstream stream emits a `data-guardrail-violation`
12612
- * chunk. The `message` carries the service-provided `fallbackResponse`, which
12613
- * is intentionally surfaced verbatim through the chat error UI (unlike
12614
- * generic cost-control / 4xx errors, where the raw API message is hidden
12615
- * behind a friendly default).
12635
+ * Error shape for custom chat implementations that still surface a
12636
+ * `data-guardrail-violation` chunk through the error UI. The `message` carries
12637
+ * the service-provided `fallbackResponse`, which is authored for end-user
12638
+ * display.
12616
12639
  *
12617
12640
  * Detection across package boundaries should rely on `error.name` rather than
12618
12641
  * `instanceof` to avoid issues with mixed module copies in bundled apps.
12619
- */ var GuardrailViolationError = /*#__PURE__*/ function(Error1) {
12642
+ */ /*#__PURE__*/ (function(Error1) {
12620
12643
  _inherits(GuardrailViolationError, Error1);
12621
12644
  function GuardrailViolationError(message) {
12622
12645
  _class_call_check(this, GuardrailViolationError);
@@ -12628,7 +12651,7 @@
12628
12651
  return _this;
12629
12652
  }
12630
12653
  return GuardrailViolationError;
12631
- }(_wrap_native_super(Error));
12654
+ })(_wrap_native_super(Error));
12632
12655
  /**
12633
12656
  * Reads a non-empty `message` field off a JSON-serialized error envelope.
12634
12657
  *
@@ -12720,6 +12743,7 @@
12720
12743
  }
12721
12744
  return fallbackInput;
12722
12745
  };
12746
+ var defaultGuardrailFallbackResponse = 'Sorry, we are not able to generate a response at the moment.';
12723
12747
  /**
12724
12748
  * Abstract base class for chat implementations.
12725
12749
  */ var AbstractChat = /*#__PURE__*/ function() {
@@ -13546,28 +13570,37 @@
13546
13570
  }
13547
13571
  break;
13548
13572
  }
13549
- // Surface guardrail violations through the error state, but
13550
- // distinct from generic cost-control / 4xx errors: throw a
13551
- // `GuardrailViolationError` so the UI can render the
13552
- // service-provided `fallbackResponse` verbatim (it's authored for
13553
- // end-user display) instead of the friendly default used for
13554
- // opaque transport errors. Also discard any in-progress assistant
13555
- // message so no partial text lingers above the fallback, and
13556
- // clear the local cursor so the `onFinish` callback doesn't
13557
- // receive a `currentMessage` that no longer exists in state.
13558
13573
  case 'data-guardrail-violation':
13559
13574
  {
13560
- isError = true;
13561
- if (currentMessageIndex >= 0) {
13562
- _this.state.messages = _this.state.messages.slice(0, currentMessageIndex);
13563
- currentMessage = undefined;
13564
- currentMessageIndex = -1;
13565
- }
13566
13575
  // `chunk.data` widens to `unknown` here: the chunk union also
13567
13576
  // carries a generic `data-${string}` member, and the literal
13568
13577
  // matches both, so narrowing can't pick the specific shape.
13569
13578
  var fallbackResponse = chunk.data.fallbackResponse;
13570
- throw new GuardrailViolationError(fallbackResponse || 'Sorry, we are not able to generate a response at the moment.');
13579
+ var fallbackText = fallbackResponse || defaultGuardrailFallbackResponse;
13580
+ // The stream closes after a guardrail violation; keep the
13581
+ // fallback as the current message so the normal finish path runs.
13582
+ currentMessage = {
13583
+ id: (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.id) || currentMessageId || _this.generateId(),
13584
+ role: 'assistant',
13585
+ metadata: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.metadata,
13586
+ parts: [
13587
+ {
13588
+ type: 'text',
13589
+ text: fallbackText,
13590
+ state: 'done'
13591
+ }
13592
+ ]
13593
+ };
13594
+ if (currentMessageIndex >= 0) {
13595
+ _this.state.replaceMessage(currentMessageIndex, currentMessage);
13596
+ } else {
13597
+ _this.state.pushMessage(currentMessage);
13598
+ currentMessageIndex = _this.state.messages.length - 1;
13599
+ }
13600
+ currentMessageId = currentMessage.id;
13601
+ currentTextPartId = undefined;
13602
+ currentReasoningPartId = undefined;
13603
+ break;
13571
13604
  }
13572
13605
  default:
13573
13606
  {
@@ -13702,7 +13735,7 @@
13702
13735
  var ChatState = /*#__PURE__*/ function() {
13703
13736
  function ChatState() {
13704
13737
  var _this = this;
13705
- var id = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : undefined, initialMessages = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : getDefaultInitialMessages(id);
13738
+ var id = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : undefined, initialMessages = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : undefined, persistence = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
13706
13739
  _class_call_check(this, ChatState);
13707
13740
  _define_property(this, "_messages", void 0);
13708
13741
  _define_property(this, "_status", 'ready');
@@ -13762,7 +13795,16 @@
13762
13795
  return callback();
13763
13796
  });
13764
13797
  });
13765
- this._messages = initialMessages;
13798
+ if (initialMessages !== undefined) {
13799
+ this._messages = initialMessages;
13800
+ } else if (persistence) {
13801
+ this._messages = getDefaultInitialMessages(id);
13802
+ } else {
13803
+ this._messages = [];
13804
+ }
13805
+ if (!persistence) {
13806
+ return;
13807
+ }
13766
13808
  var saveMessagesInLocalStorage = function saveMessagesInLocalStorage() {
13767
13809
  if (_this.status === 'ready') {
13768
13810
  try {
@@ -13816,11 +13858,12 @@
13816
13858
  function Chat(_0) {
13817
13859
  _class_call_check(this, Chat);
13818
13860
  var _this;
13819
- var messages = _0.messages, agentId = _0.agentId, init = _object_without_properties(_0, [
13861
+ var messages = _0.messages, agentId = _0.agentId, _0_persistence = _0.persistence, persistence = _0_persistence === void 0 ? true : _0_persistence, init = _object_without_properties(_0, [
13820
13862
  "messages",
13821
- "agentId"
13863
+ "agentId",
13864
+ "persistence"
13822
13865
  ]);
13823
- var state = new ChatState(agentId, messages);
13866
+ var state = new ChatState(agentId, messages, persistence);
13824
13867
  _this = _call_super(this, Chat, [
13825
13868
  _object_spread_props(_object_spread({}, init), {
13826
13869
  state: state
@@ -14124,14 +14167,16 @@
14124
14167
  var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
14125
14168
  checkRendering(renderFn, withUsage$o());
14126
14169
  return function(widgetParams) {
14127
- var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, _ref_tools = _ref.tools, tools = _ref_tools === void 0 ? {} : _ref_tools, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, context = _ref.context, initialUserMessage = _ref.initialUserMessage, initialMessages = _ref.initialMessages, _ref_disableTriggerValidation = _ref.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, options = _object_without_properties(_ref, [
14170
+ var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, _ref_tools = _ref.tools, tools = _ref_tools === void 0 ? {} : _ref_tools, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, context = _ref.context, initialUserMessage = _ref.initialUserMessage, initialMessages = _ref.initialMessages, _ref_disableTriggerValidation = _ref.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, _ref_sendAutomaticallyWhen = _ref.sendAutomaticallyWhen, sendAutomaticallyWhen = _ref_sendAutomaticallyWhen === void 0 ? lastAssistantMessageIsCompleteWithToolCalls : _ref_sendAutomaticallyWhen, _ref_requiresSearch = _ref.requiresSearch, requiresSearch = _ref_requiresSearch === void 0 ? true : _ref_requiresSearch, options = _object_without_properties(_ref, [
14128
14171
  "resume",
14129
14172
  "tools",
14130
14173
  "type",
14131
14174
  "context",
14132
14175
  "initialUserMessage",
14133
14176
  "initialMessages",
14134
- "disableTriggerValidation"
14177
+ "disableTriggerValidation",
14178
+ "sendAutomaticallyWhen",
14179
+ "requiresSearch"
14135
14180
  ]);
14136
14181
  var _chatInstance;
14137
14182
  var input = '';
@@ -14292,8 +14337,8 @@
14292
14337
  return options.chat;
14293
14338
  }
14294
14339
  return new Chat(_object_spread_props(_object_spread({}, options), {
14340
+ sendAutomaticallyWhen: sendAutomaticallyWhen,
14295
14341
  transport: transport,
14296
- sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
14297
14342
  shouldRepairToolInput: function shouldRepairToolInput(toolName) {
14298
14343
  var tool = tools[toolName];
14299
14344
  if (!tool && toolName.startsWith("".concat(SearchIndexToolType, "_"))) {
@@ -14335,6 +14380,7 @@
14335
14380
  };
14336
14381
  return {
14337
14382
  $$type: 'ais.chat',
14383
+ dependsOn: requiresSearch ? 'search' : 'none',
14338
14384
  init: function init(initOptions) {
14339
14385
  var _this = this;
14340
14386
  var instantSearchInstance = initOptions.instantSearchInstance;
@@ -14547,6 +14593,7 @@
14547
14593
  return {
14548
14594
  $$type: 'ais.chatTrigger',
14549
14595
  opensChat: true,
14596
+ dependsOn: 'none',
14550
14597
  init: function init(initOptions) {
14551
14598
  lastOptions = initOptions;
14552
14599
  renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
@@ -14575,6 +14622,9 @@
14575
14622
  return _object_spread_props(_object_spread({}, renderState), {
14576
14623
  chatTrigger: this.getWidgetRenderState(renderOptions)
14577
14624
  });
14625
+ },
14626
+ shouldRender: function shouldRender() {
14627
+ return true;
14578
14628
  }
14579
14629
  };
14580
14630
  };
@@ -18515,6 +18565,8 @@
18515
18565
  // later during hydration.
18516
18566
  var requestParamsList;
18517
18567
  var client = helper.getClient();
18568
+ var waitsForSearch = search._hasSearchWidget;
18569
+ var waitsForRecommend = !skipRecommend && search._hasRecommendWidget;
18518
18570
  if (search.compositionID) {
18519
18571
  helper.setClient(_object_spread_props(_object_spread({}, client), {
18520
18572
  search: function search(query) {
@@ -18535,17 +18587,22 @@
18535
18587
  }
18536
18588
  }));
18537
18589
  }
18538
- if (search._hasSearchWidget) {
18590
+ if (waitsForSearch) {
18539
18591
  if (search.compositionID) {
18540
18592
  helper.searchWithComposition();
18541
18593
  } else {
18542
18594
  helper.searchOnlyWithDerivedHelpers();
18543
18595
  }
18544
18596
  }
18545
- !skipRecommend && search._hasRecommendWidget && helper.recommend();
18597
+ if (waitsForRecommend) {
18598
+ helper.recommend();
18599
+ }
18600
+ if (!waitsForSearch && !waitsForRecommend) {
18601
+ return Promise.resolve([]);
18602
+ }
18546
18603
  return new Promise(function(resolve, reject) {
18547
- var searchResultsReceived = !search._hasSearchWidget;
18548
- var recommendResultsReceived = !search._hasRecommendWidget || skipRecommend;
18604
+ var searchResultsReceived = !waitsForSearch;
18605
+ var recommendResultsReceived = !waitsForRecommend;
18549
18606
  // All derived helpers resolve in the same tick so we're safe only relying
18550
18607
  // on the first one.
18551
18608
  helper.derivedHelpers[0].on('result', function() {
@@ -18585,6 +18642,13 @@
18585
18642
  var requestParamsIndex = 0;
18586
18643
  walkIndex(rootIndex, function(widget) {
18587
18644
  var _widget_getHelper;
18645
+ var currentIndex = widget;
18646
+ while(currentIndex){
18647
+ if (currentIndex._isolated) {
18648
+ return;
18649
+ }
18650
+ currentIndex = currentIndex.getParent();
18651
+ }
18588
18652
  var searchResults = widget.getResults();
18589
18653
  var recommendResults = (_widget_getHelper = widget.getHelper()) === null || _widget_getHelper === void 0 ? void 0 : _widget_getHelper.lastRecommendResults;
18590
18654
  if (searchResults || recommendResults) {
@@ -18615,7 +18679,7 @@
18615
18679
  });
18616
18680
  }
18617
18681
  });
18618
- if (Object.keys(initialResults).length === 0) {
18682
+ if (Object.keys(initialResults).length === 0 && (requestParamsList === null || requestParamsList === void 0 ? void 0 : requestParamsList.length) !== 0) {
18619
18683
  throw new Error('The root index does not have any results. Make sure you have at least one widget that provides results.');
18620
18684
  }
18621
18685
  return initialResults;
@@ -18650,6 +18714,13 @@
18650
18714
  var shouldRefetch = false;
18651
18715
  // Two-pass widgets require another query to discover and mount child widgets.
18652
18716
  walkIndex(searchRef.current.mainIndex, function(index) {
18717
+ var current = index;
18718
+ while(current){
18719
+ if (current._isolated) {
18720
+ return;
18721
+ }
18722
+ current = current.getParent();
18723
+ }
18653
18724
  shouldRefetch = shouldRefetch || index.getWidgets().some(isTwoPassWidget);
18654
18725
  });
18655
18726
  if (shouldRefetch) {