@ai-sdk/react
Advanced tools
Comparing version 1.0.3 to 1.0.4
# @ai-sdk/react | ||
## 1.0.4 | ||
### Patch Changes | ||
- 953469c: chore (ui): extract prepareAttachmentsForRequest | ||
- Updated dependencies [953469c] | ||
- Updated dependencies [a3dd2ed] | ||
- @ai-sdk/ui-utils@1.0.3 | ||
## 1.0.3 | ||
@@ -4,0 +13,0 @@ |
@@ -420,6 +420,3 @@ "use strict"; | ||
var _a, _b; | ||
if (!message.id) { | ||
message.id = generateId2(); | ||
} | ||
const attachmentsForRequest = await prepareAttachmentsForRequest( | ||
const attachmentsForRequest = await (0, import_ui_utils2.prepareAttachmentsForRequest)( | ||
experimental_attachments | ||
@@ -492,3 +489,3 @@ ); | ||
} | ||
const attachmentsForRequest = await prepareAttachmentsForRequest( | ||
const attachmentsForRequest = await (0, import_ui_utils2.prepareAttachmentsForRequest)( | ||
options.experimental_attachments | ||
@@ -573,32 +570,2 @@ ); | ||
} | ||
async function prepareAttachmentsForRequest(attachmentsFromOptions) { | ||
if (attachmentsFromOptions == null) { | ||
return []; | ||
} | ||
if (attachmentsFromOptions instanceof FileList) { | ||
return Promise.all( | ||
Array.from(attachmentsFromOptions).map(async (attachment) => { | ||
const { name, type } = attachment; | ||
const dataUrl = await new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.onload = (readerEvent) => { | ||
var _a; | ||
resolve((_a = readerEvent.target) == null ? void 0 : _a.result); | ||
}; | ||
reader.onerror = (error) => reject(error); | ||
reader.readAsDataURL(attachment); | ||
}); | ||
return { | ||
name, | ||
contentType: type, | ||
url: dataUrl | ||
}; | ||
}) | ||
); | ||
} | ||
if (Array.isArray(attachmentsFromOptions)) { | ||
return attachmentsFromOptions; | ||
} | ||
throw new Error("Invalid attachments type"); | ||
} | ||
@@ -605,0 +572,0 @@ // src/use-completion.ts |
{ | ||
"name": "@ai-sdk/react", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "Apache-2.0", | ||
@@ -23,3 +23,3 @@ "sideEffects": false, | ||
"@ai-sdk/provider-utils": "2.0.2", | ||
"@ai-sdk/ui-utils": "1.0.2", | ||
"@ai-sdk/ui-utils": "1.0.3", | ||
"swr": "^2.2.5", | ||
@@ -29,3 +29,3 @@ "throttleit": "2.1.0" | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^6.4.8", | ||
"@testing-library/jest-dom": "^6.6.3", | ||
"@testing-library/user-event": "^14.5.2", | ||
@@ -32,0 +32,0 @@ "@testing-library/react": "^16.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192140
1880
+ Added@ai-sdk/ui-utils@1.0.3(transitive)
- Removed@ai-sdk/ui-utils@1.0.2(transitive)
Updated@ai-sdk/ui-utils@1.0.3