@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/.turbo/turbo-build.log +5 -13
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4945 -4948
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/useAnimaCodegen.ts +7 -8
- package/src/utils.ts +4 -4
package/package.json
CHANGED
package/src/useAnimaCodegen.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
for (
|
|
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
|
|