@animaapp/anima-sdk 0.2.3 → 0.2.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/.turbo/turbo-build.log +14 -12
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +437 -431
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anima.ts +7 -0
- package/src/settings.ts +2 -0
- package/src/types.ts +36 -34
package/package.json
CHANGED
package/src/anima.ts
CHANGED
|
@@ -87,6 +87,7 @@ export class Anima {
|
|
|
87
87
|
enableCompactStructure: settings.enableCompactStructure,
|
|
88
88
|
enableAutoSplit: settings.enableAutoSplit,
|
|
89
89
|
autoSplitThreshold: settings.autoSplitThreshold,
|
|
90
|
+
disableMarkedForExport: settings.disableMarkedForExport,
|
|
90
91
|
}),
|
|
91
92
|
});
|
|
92
93
|
|
|
@@ -145,6 +146,12 @@ export class Anima {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
switch (data.type) {
|
|
149
|
+
case "queueing": {
|
|
150
|
+
typeof handler === "function"
|
|
151
|
+
? handler(data)
|
|
152
|
+
: handler.onQueueing?.();
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
148
155
|
case "start": {
|
|
149
156
|
result.sessionId = data.sessionId;
|
|
150
157
|
typeof handler === "function"
|
package/src/settings.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
const CodegenSettingsSchema = z
|
|
4
4
|
.object({
|
|
5
5
|
language: z.enum(["typescript", "javascript"]).optional(),
|
|
6
|
+
disableMarkedForExport: z.boolean().optional(),
|
|
6
7
|
})
|
|
7
8
|
.and(
|
|
8
9
|
z.union([
|
|
@@ -51,6 +52,7 @@ export type CodegenSettings = {
|
|
|
51
52
|
enableCompactStructure?: boolean;
|
|
52
53
|
enableAutoSplit?: boolean;
|
|
53
54
|
autoSplitThreshold?: number;
|
|
55
|
+
disableMarkedForExport?: boolean;
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
export const validateSettings = (obj: unknown): CodegenSettings => {
|
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;
|