@docsearch/js 5.0.0-beta.0 → 5.0.0-beta.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.
@@ -1,4 +1,4 @@
1
- /*! @docsearch/js 5.0.0-beta.0 (UNRELEASED 1b6607c) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
1
+ /*! @docsearch/js 5.0.0-beta.1 (UNRELEASED cc75f9a) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
2
  import { DocSearchAIProps as DocSearchAIProps$1 } from "@docsearch/react/docsearchAi";
3
3
  import { InitialAskAiMessage } from "@docsearch/core";
4
4
  //#region ../../node_modules/.bun/preact@11.0.0-beta.0/node_modules/preact/src/index.d.ts
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @docsearch/js 5.0.0-beta.0 (UNRELEASED 1b6607c) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
1
+ /*! @docsearch/js 5.0.0-beta.1 (UNRELEASED cc75f9a) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
2
  //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp$1 = Object.defineProperty;
@@ -27376,7 +27376,7 @@ function useChat(_ref2 = {}) {
27376
27376
  }
27377
27377
 
27378
27378
  //#endregion
27379
- //#region ../docsearch-react/dist/esm/useSuggestedQuestions-D2TGVPsI.js
27379
+ //#region ../docsearch-react/dist/esm/useSuggestedQuestions-CG2H3qm4.js
27380
27380
  init_compat();
27381
27381
  function AlertIcon(props) {
27382
27382
  return /* @__PURE__ */ En.createElement("svg", _objectSpread2$2({
@@ -27910,9 +27910,6 @@ function isAIToolPart(part) {
27910
27910
  function isSearchToolPart(part) {
27911
27911
  return part.type === "tool-searchIndex" || part.type === "tool-algolia_search_index" || part.type.startsWith("tool-algolia_search_index_");
27912
27912
  }
27913
- function isSearchIndexOutputPart(part) {
27914
- return part.type === "tool-searchIndex" && part.state === "output-available";
27915
- }
27916
27913
  function isSearchOutputPart(part) {
27917
27914
  return isAIToolPart(part) && isSearchToolPart(part) && part.state === "output-available";
27918
27915
  }
@@ -27935,8 +27932,22 @@ function getAgentPromptSuggestions(parts) {
27935
27932
  if (!suggestionsPart) return [];
27936
27933
  return suggestionsPart.data.suggestions;
27937
27934
  }
27935
+ function getSearchToolQueries(part) {
27936
+ if (part.state !== "input-available" && part.state !== "output-available") return [];
27937
+ if (part.type === "tool-searchIndex") {
27938
+ var _ref, _part$output$query, _part$output, _part$input;
27939
+ const query = ((_ref = (_part$output$query = (_part$output = part.output) === null || _part$output === void 0 ? void 0 : _part$output.query) !== null && _part$output$query !== void 0 ? _part$output$query : (_part$input = part.input) === null || _part$input === void 0 ? void 0 : _part$input.query) !== null && _ref !== void 0 ? _ref : "").trim();
27940
+ return query ? [query] : [];
27941
+ }
27942
+ if ("queries" in part.input && Array.isArray(part.input.queries)) return part.input.queries.map(({ query }) => query.trim()).filter(Boolean);
27943
+ if ("query" in part.input && typeof part.input.query === "string") {
27944
+ const query = part.input.query.trim();
27945
+ return query ? [query] : [];
27946
+ }
27947
+ return [];
27948
+ }
27938
27949
  function ToolState({ icon, shimmer = false, children, variant }) {
27939
- const className = `DocSearch-AskAiScreen-MessageContent-Tool Tool--${variant}${shimmer ? " shimmer" : ""}`;
27950
+ const className = `DocSearch-AskAiScreen-MessageContent-Tool Tool--${variant}${shimmer ? " DocSearch-shimmer" : ""}`;
27940
27951
  return /* @__PURE__ */ En.createElement("div", { className }, icon, children);
27941
27952
  }
27942
27953
  function SearchTool({ part, translations, onSearchQueryClick }) {
@@ -27947,14 +27958,19 @@ function SearchTool({ part, translations, onSearchQueryClick }) {
27947
27958
  icon: /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }),
27948
27959
  variant: "PartialCall"
27949
27960
  }, /* @__PURE__ */ En.createElement("span", null, searchingText));
27950
- case "input-available": return /* @__PURE__ */ En.createElement(ToolState, {
27951
- shimmer: true,
27952
- icon: /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }),
27953
- variant: "Call"
27954
- }, /* @__PURE__ */ En.createElement("span", null, preToolCallText, " ", `"${part.input.query || ""}" ...`));
27961
+ case "input-available": {
27962
+ const queries = getSearchToolQueries(part);
27963
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, queries.map((q, index) => /* @__PURE__ */ En.createElement(ToolState, {
27964
+ key: `${part.toolCallId}-call-${index}`,
27965
+ shimmer: true,
27966
+ icon: /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }),
27967
+ variant: "Call"
27968
+ }, /* @__PURE__ */ En.createElement("span", null, preToolCallText, " ", `"${q}" ...`))));
27969
+ }
27955
27970
  case "output-available": {
27956
- const query = part.type === "tool-searchIndex" ? part.output.query : part.input.query;
27957
- return /* @__PURE__ */ En.createElement(ToolState, {
27971
+ const queries = getSearchToolQueries(part);
27972
+ return /* @__PURE__ */ En.createElement(En.Fragment, null, queries.map((q, index) => /* @__PURE__ */ En.createElement(ToolState, {
27973
+ key: `${part.toolCallId}-result-${index}`,
27958
27974
  icon: /* @__PURE__ */ En.createElement(SearchIcon, null),
27959
27975
  variant: "Result"
27960
27976
  }, /* @__PURE__ */ En.createElement("span", null, toolCallResultText, " ", onSearchQueryClick ? /* @__PURE__ */ En.createElement("span", {
@@ -27964,11 +27980,11 @@ function SearchTool({ part, translations, onSearchQueryClick }) {
27964
27980
  onKeyDown: (e) => {
27965
27981
  if (e.key === "Enter" || e.key === " ") {
27966
27982
  e.preventDefault();
27967
- onSearchQueryClick(query || "");
27983
+ onSearchQueryClick(q);
27968
27984
  }
27969
27985
  },
27970
- onClick: () => onSearchQueryClick(query || "")
27971
- }, " ", "\"", query || "", "\"") : /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-MessageContent-Tool-Query" }, " ", "\"", query || "", "\"")));
27986
+ onClick: () => onSearchQueryClick(q)
27987
+ }, " ", "\"", q, "\"") : /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAiScreen-MessageContent-Tool-Query" }, " ", "\"", q, "\"")))));
27972
27988
  }
27973
27989
  default: return null;
27974
27990
  }
@@ -28099,16 +28115,6 @@ const MemoizedMarkdown = D$1(({ content, copyButtonText, copyButtonCopiedText, i
28099
28115
  });
28100
28116
  MemoizedMarkdown.displayName = "MemoizedMarkdown";
28101
28117
  /**
28102
- * Extracts the search query from a search tool result part. `searchIndex`
28103
- * exposes the query on its output, while the Algolia MCP search tools expose it
28104
- * on their input.
28105
- */
28106
- function getSearchQuery(part) {
28107
- var _part$output, _part$input;
28108
- const query = isSearchIndexOutputPart(part) ? (_part$output = part.output) === null || _part$output === void 0 ? void 0 : _part$output.query : (_part$input = part.input) === null || _part$input === void 0 ? void 0 : _part$input.query;
28109
- return (query !== null && query !== void 0 ? query : "").trim();
28110
- }
28111
- /**
28112
28118
  * Groups consecutive search tool invocation result parts together. Both the
28113
28119
  * `searchIndex` tool and the Algolia MCP search tools (`algolia_search_index`
28114
28120
  * and `algolia_search_index_*`) are aggregated. Empty or falsy queries are
@@ -28125,11 +28131,9 @@ function groupConsecutiveToolResults(parts) {
28125
28131
  while (j < parts.length) {
28126
28132
  const candidate = parts[j];
28127
28133
  if (isSearchOutputPart(candidate)) {
28128
- const q = getSearchQuery(candidate);
28129
- if (q && q.length > 0) {
28130
- queries.push(q);
28131
- singleQueryPart = candidate;
28132
- }
28134
+ const queriesForPart = getSearchToolQueries(candidate);
28135
+ queries.push(...queriesForPart);
28136
+ if (queriesForPart.length > 0) singleQueryPart = candidate;
28133
28137
  j++;
28134
28138
  } else break;
28135
28139
  }
@@ -31222,7 +31226,7 @@ function createAutocomplete(options) {
31222
31226
  }
31223
31227
 
31224
31228
  //#endregion
31225
- //#region ../docsearch-react/dist/esm/DocSearchAskAiModal-CCrk6YLb.js
31229
+ //#region ../docsearch-react/dist/esm/DocSearchAskAiModal-KaA6fBV4.js
31226
31230
  init_compat();
31227
31231
  function MessageIcon() {
31228
31232
  return /* @__PURE__ */ En.createElement("svg", {
@@ -31252,7 +31256,7 @@ function AggregatedSearchBlock({ queries, translations, onSearchQueryClick }) {
31252
31256
  tabIndex: 0,
31253
31257
  className: "DocSearch-AskAiScreen-MessageContent-Tool-Query",
31254
31258
  onKeyDown: (e) => {
31255
- if (e.key === "enter" || e.key === " ") {
31259
+ if (e.key === "Enter" || e.key === " ") {
31256
31260
  e.preventDefault();
31257
31261
  onSearchQueryClick(q);
31258
31262
  }
@@ -31310,7 +31314,7 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31310
31314
  }))), isThinking && /* @__PURE__ */ En.createElement("div", {
31311
31315
  className: "DocSearch-AskAiScreen-MessageContent-Thinking",
31312
31316
  role: "status"
31313
- }, /* @__PURE__ */ En.createElement("span", { className: "shimmer" }, translations.thinkingText || "Thinking..."), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton shimmer" }), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton DocSearch-AskAi-Thinking-Skeleton--short shimmer" })), displayParts.map((part, idx) => {
31317
+ }, /* @__PURE__ */ En.createElement("span", { className: "DocSearch-shimmer" }, translations.thinkingText || "Thinking..."), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton DocSearch-shimmer" }), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-AskAi-Thinking-Skeleton DocSearch-AskAi-Thinking-Skeleton--short DocSearch-shimmer" })), displayParts.map((part, idx) => {
31314
31318
  const index = idx;
31315
31319
  if (typeof part === "string") return /* @__PURE__ */ En.createElement(MemoizedMarkdown, {
31316
31320
  key: index,
@@ -31335,8 +31339,8 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31335
31339
  });
31336
31340
  if (part.type === "reasoning" && part.state === "streaming") return /* @__PURE__ */ En.createElement("div", {
31337
31341
  key: index,
31338
- className: "DocSearch-AskAiScreen-MessageContent-Reasoning shimmer"
31339
- }, /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }), /* @__PURE__ */ En.createElement("span", { className: "shimmer" }, "Reasoning..."));
31342
+ className: "DocSearch-AskAiScreen-MessageContent-Reasoning DocSearch-shimmer"
31343
+ }, /* @__PURE__ */ En.createElement(LoadingIcon, { className: "DocSearch-AskAiScreen-SmallerLoadingIcon" }), /* @__PURE__ */ En.createElement("span", { className: "DocSearch-shimmer" }, "Reasoning..."));
31340
31344
  if (part.type === "text") return /* @__PURE__ */ En.createElement(MemoizedMarkdown, {
31341
31345
  key: index,
31342
31346
  content: part.text,
@@ -31345,7 +31349,7 @@ function AskAiExchangeCard({ exchange, askAiError, isLastExchange, loadingStatus
31345
31349
  isStreaming: part.state === "streaming"
31346
31350
  });
31347
31351
  return null;
31348
- })), wasStopped && /* @__PURE__ */ En.createElement("p", { className: "DocSearck-AskAiScreen-MessageContent-Stopped" }, stoppedStreamingText)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Answer-Footer" }, /* @__PURE__ */ En.createElement(SourcesPanel, {
31352
+ })), wasStopped && /* @__PURE__ */ En.createElement("p", { className: "DocSearch-AskAiScreen-MessageContent-Stopped" }, stoppedStreamingText)), /* @__PURE__ */ En.createElement("div", { className: "DocSearch-AskAiScreen-Answer-Footer" }, /* @__PURE__ */ En.createElement(SourcesPanel, {
31349
31353
  links: urlsToDisplay,
31350
31354
  titleText: relatedSourcesText
31351
31355
  }), /* @__PURE__ */ En.createElement(FeedbackActions, {
@@ -31508,7 +31512,7 @@ const AskAiScreenState = En.memo((_ref) => {
31508
31512
  return nextProps.state.status === "loading" || nextProps.state.status === "stalled";
31509
31513
  });
31510
31514
  function ModalHeading({ heading, shimmer = false }) {
31511
- return /* @__PURE__ */ En.createElement("span", { className: `DocSearch-Modal-heading${shimmer ? " shimmer" : ""}` }, heading);
31515
+ return /* @__PURE__ */ En.createElement("span", { className: `DocSearch-Modal-heading${shimmer ? " DocSearch-shimmer" : ""}` }, heading);
31512
31516
  }
31513
31517
  const _excluded$1$1 = [
31514
31518
  "translations",