@animaapp/anima-sdk 0.2.2 → 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 +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +654 -646
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anima.ts +8 -0
- package/src/settings.ts +4 -0
- package/src/types.ts +36 -34
package/package.json
CHANGED
package/src/anima.ts
CHANGED
|
@@ -85,6 +85,8 @@ export class Anima {
|
|
|
85
85
|
enableTranslation: settings.enableTranslation,
|
|
86
86
|
enableUILibraryTheming: settings.enableUILibraryTheming,
|
|
87
87
|
enableCompactStructure: settings.enableCompactStructure,
|
|
88
|
+
enableAutoSplit: settings.enableAutoSplit,
|
|
89
|
+
autoSplitThreshold: settings.autoSplitThreshold,
|
|
88
90
|
}),
|
|
89
91
|
});
|
|
90
92
|
|
|
@@ -143,6 +145,12 @@ export class Anima {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
switch (data.type) {
|
|
148
|
+
case "queueing": {
|
|
149
|
+
typeof handler === "function"
|
|
150
|
+
? handler(data)
|
|
151
|
+
: handler.onQueueing?.();
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
146
154
|
case "start": {
|
|
147
155
|
result.sessionId = data.sessionId;
|
|
148
156
|
typeof handler === "function"
|
package/src/settings.ts
CHANGED
|
@@ -21,6 +21,8 @@ const CodegenSettingsSchema = z
|
|
|
21
21
|
uiLibrary: z.enum(["mui", "antd", "radix", "shadcn"]).optional(),
|
|
22
22
|
enableUILibraryTheming: z.boolean().optional(),
|
|
23
23
|
enableCompactStructure: z.boolean().optional(),
|
|
24
|
+
enableAutoSplit: z.boolean().optional(),
|
|
25
|
+
autoSplitThreshold: z.number().optional(),
|
|
24
26
|
}),
|
|
25
27
|
z.object({
|
|
26
28
|
framework: z.literal("html"),
|
|
@@ -47,6 +49,8 @@ export type CodegenSettings = {
|
|
|
47
49
|
enableTranslation?: boolean;
|
|
48
50
|
enableUILibraryTheming?: boolean;
|
|
49
51
|
enableCompactStructure?: boolean;
|
|
52
|
+
enableAutoSplit?: boolean;
|
|
53
|
+
autoSplitThreshold?: number;
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
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;
|