ai 5.0.0-beta.4 → 5.0.0-beta.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 4f3e637: fix (ui): avoid caching globalThis.fetch in case it is patched by other libraries
8
+
3
9
  ## 5.0.0-beta.4
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1446,7 +1446,7 @@ declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implement
1446
1446
  protected credentials?: RequestCredentials;
1447
1447
  protected headers?: Record<string, string> | Headers;
1448
1448
  protected body?: object;
1449
- protected fetch: FetchFunction;
1449
+ protected fetch?: FetchFunction;
1450
1450
  protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
1451
1451
  protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
1452
1452
  constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
package/dist/index.d.ts CHANGED
@@ -1446,7 +1446,7 @@ declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implement
1446
1446
  protected credentials?: RequestCredentials;
1447
1447
  protected headers?: Record<string, string> | Headers;
1448
1448
  protected body?: object;
1449
- protected fetch: FetchFunction;
1449
+ protected fetch?: FetchFunction;
1450
1450
  protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
1451
1451
  protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
1452
1452
  constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
package/dist/index.js CHANGED
@@ -850,14 +850,13 @@ async function convertFileListToFileUIParts(files) {
850
850
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
851
851
 
852
852
  // src/ui/http-chat-transport.ts
853
- var getOriginalFetch2 = () => fetch;
854
853
  var HttpChatTransport = class {
855
854
  constructor({
856
855
  api = "/api/chat",
857
856
  credentials,
858
857
  headers,
859
858
  body,
860
- fetch: fetch2 = getOriginalFetch2(),
859
+ fetch: fetch2,
861
860
  prepareSendMessagesRequest,
862
861
  prepareReconnectToStreamRequest
863
862
  }) {
@@ -873,7 +872,7 @@ var HttpChatTransport = class {
873
872
  abortSignal,
874
873
  ...options
875
874
  }) {
876
- var _a16, _b, _c, _d;
875
+ var _a16, _b, _c, _d, _e;
877
876
  const preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
878
877
  api: this.api,
879
878
  id: options.chatId,
@@ -896,7 +895,8 @@ var HttpChatTransport = class {
896
895
  messageId: options.messageId
897
896
  };
898
897
  const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
899
- const response = await this.fetch.call(void 0, api, {
898
+ const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
899
+ const response = await fetch2(api, {
900
900
  method: "POST",
901
901
  headers: {
902
902
  "Content-Type": "application/json",
@@ -908,7 +908,7 @@ var HttpChatTransport = class {
908
908
  });
909
909
  if (!response.ok) {
910
910
  throw new Error(
911
- (_d = await response.text()) != null ? _d : "Failed to fetch the chat response."
911
+ (_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
912
912
  );
913
913
  }
914
914
  if (!response.body) {
@@ -917,7 +917,7 @@ var HttpChatTransport = class {
917
917
  return this.processResponseStream(response.body);
918
918
  }
919
919
  async reconnectToStream(options) {
920
- var _a16, _b, _c, _d;
920
+ var _a16, _b, _c, _d, _e;
921
921
  const preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
922
922
  api: this.api,
923
923
  id: options.chatId,
@@ -929,7 +929,8 @@ var HttpChatTransport = class {
929
929
  const api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : `${this.api}/${options.chatId}/stream`;
930
930
  const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...options.headers };
931
931
  const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
932
- const response = await this.fetch.call(void 0, api, {
932
+ const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
933
+ const response = await fetch2(api, {
933
934
  method: "GET",
934
935
  headers,
935
936
  credentials
@@ -939,7 +940,7 @@ var HttpChatTransport = class {
939
940
  }
940
941
  if (!response.ok) {
941
942
  throw new Error(
942
- (_d = await response.text()) != null ? _d : "Failed to fetch the chat response."
943
+ (_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
943
944
  );
944
945
  }
945
946
  if (!response.body) {