@animaapp/anima-sdk 0.2.3 → 0.2.4
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 -5
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +388 -384
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anima.ts +6 -0
- package/src/types.ts +36 -34
package/package.json
CHANGED
package/src/anima.ts
CHANGED
|
@@ -145,6 +145,12 @@ export class Anima {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
switch (data.type) {
|
|
148
|
+
case "queueing": {
|
|
149
|
+
typeof handler === "function"
|
|
150
|
+
? handler(data)
|
|
151
|
+
: handler.onQueueing?.();
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
148
154
|
case "start": {
|
|
149
155
|
result.sessionId = data.sessionId;
|
|
150
156
|
typeof handler === "function"
|
package/src/types.ts
CHANGED
|
@@ -40,32 +40,33 @@ export type GetCodeParams = {
|
|
|
40
40
|
export type GetCodeHandler =
|
|
41
41
|
| ((message: SSECodgenMessage) => void)
|
|
42
42
|
| {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
onQueueing?: () => void;
|
|
44
|
+
onStart?: ({ sessionId }: { sessionId: string }) => void;
|
|
45
|
+
onPreCodegen?: ({ message }: { message: string }) => void;
|
|
46
|
+
onAssetsUploaded?: () => void;
|
|
47
|
+
onAssetsList?: ({
|
|
48
|
+
assets,
|
|
49
|
+
}: {
|
|
50
|
+
assets: Array<{ name: string; url: string }>;
|
|
51
|
+
}) => void;
|
|
52
|
+
onFigmaMetadata?: ({
|
|
53
|
+
figmaFileName,
|
|
54
|
+
figmaSelectedFrameName,
|
|
55
|
+
}: {
|
|
56
|
+
figmaFileName: string;
|
|
57
|
+
figmaSelectedFrameName: string;
|
|
58
|
+
}) => void;
|
|
59
|
+
onGeneratingCode?: ({
|
|
60
|
+
status,
|
|
61
|
+
progress,
|
|
62
|
+
files,
|
|
63
|
+
}: {
|
|
64
|
+
status: "success" | "running" | "failure";
|
|
65
|
+
progress: number;
|
|
66
|
+
files: AnimaFiles;
|
|
67
|
+
}) => void;
|
|
68
|
+
onCodegenCompleted?: () => void;
|
|
69
|
+
};
|
|
69
70
|
|
|
70
71
|
export type GeneratingCodePayload = {
|
|
71
72
|
status: "success" | "running" | "failure";
|
|
@@ -75,23 +76,24 @@ export type GeneratingCodePayload = {
|
|
|
75
76
|
|
|
76
77
|
// TODO: `SSECodgenMessage` and `SSECodgenMessageErrorPayload` should be imported from `anima-public-api`
|
|
77
78
|
export type SSECodgenMessage =
|
|
79
|
+
| { type: "queueing" }
|
|
78
80
|
| { type: "start"; sessionId: string }
|
|
79
81
|
| { type: "pre_codegen"; message: string }
|
|
80
82
|
| {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
type: "figma_metadata";
|
|
84
|
+
figmaFileName: string;
|
|
85
|
+
figmaSelectedFrameName: string;
|
|
86
|
+
}
|
|
85
87
|
| { type: "generating_code"; payload: GeneratingCodePayload }
|
|
86
88
|
| { type: "codegen_completed" }
|
|
87
89
|
| { type: "assets_uploaded" }
|
|
88
90
|
| {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
type: "assets_list";
|
|
92
|
+
payload: { assets: Array<{ name: string; url: string }> };
|
|
93
|
+
}
|
|
92
94
|
| { type: "aborted" }
|
|
93
95
|
| { type: "error"; payload: SSECodgenMessageErrorPayload }
|
|
94
|
-
| { type: "done"
|
|
96
|
+
| { type: "done"; payload: { sessionId: string; tokenUsage: number } };
|
|
95
97
|
export type SSECodgenMessageErrorPayload = {
|
|
96
98
|
errorName: string;
|
|
97
99
|
task?: string;
|