@animaapp/anima-sdk 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 +6 -14
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +40 -10
- package/dist/index.js +625 -566
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anima.ts +5 -11
- package/src/dataStream.ts +7 -2
- package/src/figma/figmaError.ts +7 -2
- package/src/figma/utils.ts +4 -4
- package/src/index.ts +0 -1
- package/src/settings.ts +4 -2
- package/src/types.ts +43 -36
- package/src/{utils.ts → utils/figma.ts} +1 -1
- package/src/utils/files.ts +95 -0
- package/src/utils/index.ts +2 -0
- package/src/codegenToAnimaFiles.ts +0 -13
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare type BaseResult = {
|
|
|
50
50
|
sessionId: string;
|
|
51
51
|
figmaFileName: string;
|
|
52
52
|
figmaSelectedFrameName: string;
|
|
53
|
+
tokenUsage: number;
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
export declare class CodegenError extends Error {
|
|
@@ -78,13 +79,9 @@ export declare type CodegenSettings = {
|
|
|
78
79
|
uiLibrary?: "mui" | "antd" | "radix" | "shadcn";
|
|
79
80
|
enableTranslation?: boolean;
|
|
80
81
|
enableUILibraryTheming?: boolean;
|
|
82
|
+
enableCompactStructure?: boolean;
|
|
81
83
|
};
|
|
82
84
|
|
|
83
|
-
export declare const convertCodegenFilesToAnimaFiles: (codegenFiles: Record<string, {
|
|
84
|
-
code: string;
|
|
85
|
-
type: "code";
|
|
86
|
-
}>) => AnimaFiles;
|
|
87
|
-
|
|
88
85
|
/**
|
|
89
86
|
* Creates a Server-Sent Events (SSE) `Response` that forwards all messages from the code generation stream.
|
|
90
87
|
*
|
|
@@ -107,6 +104,19 @@ export declare const createCodegenResponseEventStream: (anima: Anima, params: Ge
|
|
|
107
104
|
*/
|
|
108
105
|
export declare const createCodegenStream: (anima: Anima, params: GetCodeParams) => ReadableStream<StreamCodgenMessage>;
|
|
109
106
|
|
|
107
|
+
export declare type FigmaApiError = {
|
|
108
|
+
cause?: {
|
|
109
|
+
body?: {
|
|
110
|
+
status?: number;
|
|
111
|
+
reason?: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
body?: {
|
|
115
|
+
status?: number;
|
|
116
|
+
reason?: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
110
120
|
export declare type FigmaApiErrorType = "FigmaTokenIssue" | "RateLimitExceeded" | "NotFound" | "UnknownFigmaApiException";
|
|
111
121
|
|
|
112
122
|
export declare type FigmaNode = Node_2;
|
|
@@ -130,6 +140,12 @@ export declare const formatToFigmaLink: ({ fileKey, nodeId, }: {
|
|
|
130
140
|
nodeId: string;
|
|
131
141
|
}) => URL;
|
|
132
142
|
|
|
143
|
+
export declare type GeneratingCodePayload = {
|
|
144
|
+
status: "success" | "running" | "failure";
|
|
145
|
+
progress: number;
|
|
146
|
+
files: AnimaFiles;
|
|
147
|
+
};
|
|
148
|
+
|
|
133
149
|
export declare type GetCodeHandler = ((message: SSECodgenMessage) => void) | {
|
|
134
150
|
onStart?: ({ sessionId }: {
|
|
135
151
|
sessionId: string;
|
|
@@ -158,7 +174,7 @@ export declare type GetCodeHandler = ((message: SSECodgenMessage) => void) | {
|
|
|
158
174
|
|
|
159
175
|
export declare type GetCodeParams = {
|
|
160
176
|
fileKey: string;
|
|
161
|
-
figmaToken
|
|
177
|
+
figmaToken?: string;
|
|
162
178
|
nodesId: string[];
|
|
163
179
|
assetsStorage?: AssetsStorage;
|
|
164
180
|
settings: CodegenSettings;
|
|
@@ -191,14 +207,14 @@ export declare type GetFileNodesParams = {
|
|
|
191
207
|
authToken?: string;
|
|
192
208
|
nodeIds: string[];
|
|
193
209
|
figmaRestApi?: FigmaRestApi;
|
|
194
|
-
params?: Record<string,
|
|
210
|
+
params?: Record<string, string | number>;
|
|
195
211
|
};
|
|
196
212
|
|
|
197
213
|
export declare type GetFilePagesParams = {
|
|
198
214
|
fileKey: string;
|
|
199
215
|
authToken?: string;
|
|
200
216
|
figmaRestApi?: FigmaRestApi;
|
|
201
|
-
params?: Record<string,
|
|
217
|
+
params?: Record<string, string | number | undefined>;
|
|
202
218
|
};
|
|
203
219
|
|
|
204
220
|
export declare type GetFilePagesResult = FigmaPage[] | undefined;
|
|
@@ -209,7 +225,12 @@ export declare type GetFileParams = {
|
|
|
209
225
|
figmaRestApi?: FigmaRestApi;
|
|
210
226
|
};
|
|
211
227
|
|
|
212
|
-
export declare const
|
|
228
|
+
export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
229
|
+
files: AnimaFiles;
|
|
230
|
+
screenPath?: string;
|
|
231
|
+
}) => AnimaFiles;
|
|
232
|
+
|
|
233
|
+
export declare const handleFigmaApiError: (error: FigmaApiError, fileKey: string) => never;
|
|
213
234
|
|
|
214
235
|
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
215
236
|
|
|
@@ -235,6 +256,11 @@ export declare class RateLimitExceeded extends Error {
|
|
|
235
256
|
});
|
|
236
257
|
}
|
|
237
258
|
|
|
259
|
+
export declare class ResponseError extends Error {
|
|
260
|
+
response: Response;
|
|
261
|
+
constructor(message: string, res: Response);
|
|
262
|
+
}
|
|
263
|
+
|
|
238
264
|
export declare type SSECodgenMessage = {
|
|
239
265
|
type: "start";
|
|
240
266
|
sessionId: string;
|
|
@@ -247,7 +273,7 @@ export declare type SSECodgenMessage = {
|
|
|
247
273
|
figmaSelectedFrameName: string;
|
|
248
274
|
} | {
|
|
249
275
|
type: "generating_code";
|
|
250
|
-
payload:
|
|
276
|
+
payload: GeneratingCodePayload;
|
|
251
277
|
} | {
|
|
252
278
|
type: "codegen_completed";
|
|
253
279
|
} | {
|
|
@@ -267,6 +293,10 @@ export declare type SSECodgenMessage = {
|
|
|
267
293
|
payload: SSECodgenMessageErrorPayload;
|
|
268
294
|
} | {
|
|
269
295
|
type: "done";
|
|
296
|
+
payload: {
|
|
297
|
+
sessionId: string;
|
|
298
|
+
tokenUsage: number;
|
|
299
|
+
};
|
|
270
300
|
};
|
|
271
301
|
|
|
272
302
|
export declare type SSECodgenMessageErrorPayload = {
|