@animaapp/anima-sdk-react 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animaapp/anima-sdk-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "Anima's JavaScript utilities library",
6
6
  "author": "Anima App, Inc.",
@@ -4,7 +4,6 @@ import type {
4
4
  GetCodeParams,
5
5
  StreamCodgenMessage,
6
6
  } from "@animaapp/anima-sdk";
7
- import { convertCodegenFilesToAnimaFiles } from "@animaapp/anima-sdk";
8
7
  import { EventSource } from "eventsource";
9
8
  import { useImmer } from "use-immer";
10
9
 
@@ -160,12 +159,7 @@ export const useAnimaCodegen = ({
160
159
  event.data
161
160
  ) as StreamMessageByType<"generating_code">;
162
161
  if (message.payload.status === "success") {
163
- const codegenFiles = message.payload.files as Record<
164
- string,
165
- { code: string; type: "code" }
166
- >;
167
-
168
- result.files = convertCodegenFilesToAnimaFiles(codegenFiles);
162
+ result.files = message.payload.files;
169
163
  }
170
164
 
171
165
  updateStatus((draft) => {
@@ -225,7 +219,12 @@ export const useAnimaCodegen = ({
225
219
  }
226
220
  });
227
221
 
228
- es.addEventListener("done", () => {
222
+ es.addEventListener("done", (event) => {
223
+ const message = JSON.parse(
224
+ event.data
225
+ ) as StreamMessageByType<"done">;
226
+ result.tokenUsage = message.payload.tokenUsage;
227
+
229
228
  updateStatus((draft) => {
230
229
  draft.status = "success";
231
230
  draft.result = result as AnimaSDKResult;
package/src/utils.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export const arrayBufferToBase64 = (buffer: ArrayBuffer) => {
2
- var binary = "";
3
- var bytes = new Uint8Array(buffer);
4
- var len = bytes.byteLength;
5
- for (var i = 0; i < len; i++) {
2
+ let binary = "";
3
+ const bytes = new Uint8Array(buffer);
4
+ const len = bytes.byteLength;
5
+ for (let i = 0; i < len; i++) {
6
6
  binary += String.fromCharCode(bytes[i]);
7
7
  }
8
8