@animaapp/anima-sdk 0.1.3 → 0.2.1
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 +29 -10
- package/dist/index.js +451 -450
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anima.ts +2 -10
- package/src/dataStream.ts +1 -1
- package/src/figma/figmaError.ts +7 -2
- package/src/figma/utils.ts +4 -4
- package/src/index.ts +0 -1
- package/src/types.ts +8 -2
- package/src/utils.ts +1 -1
- package/tsconfig.json +5 -0
- package/src/codegenToAnimaFiles.ts +0 -13
package/dist/index.d.ts
CHANGED
|
@@ -80,11 +80,6 @@ export declare type CodegenSettings = {
|
|
|
80
80
|
enableUILibraryTheming?: boolean;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
export declare const convertCodegenFilesToAnimaFiles: (codegenFiles: Record<string, {
|
|
84
|
-
code: string;
|
|
85
|
-
type: "code";
|
|
86
|
-
}>) => AnimaFiles;
|
|
87
|
-
|
|
88
83
|
/**
|
|
89
84
|
* Creates a Server-Sent Events (SSE) `Response` that forwards all messages from the code generation stream.
|
|
90
85
|
*
|
|
@@ -107,6 +102,19 @@ export declare const createCodegenResponseEventStream: (anima: Anima, params: Ge
|
|
|
107
102
|
*/
|
|
108
103
|
export declare const createCodegenStream: (anima: Anima, params: GetCodeParams) => ReadableStream<StreamCodgenMessage>;
|
|
109
104
|
|
|
105
|
+
export declare type FigmaApiError = {
|
|
106
|
+
cause?: {
|
|
107
|
+
body?: {
|
|
108
|
+
status?: number;
|
|
109
|
+
reason?: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
body?: {
|
|
113
|
+
status?: number;
|
|
114
|
+
reason?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
110
118
|
export declare type FigmaApiErrorType = "FigmaTokenIssue" | "RateLimitExceeded" | "NotFound" | "UnknownFigmaApiException";
|
|
111
119
|
|
|
112
120
|
export declare type FigmaNode = Node_2;
|
|
@@ -130,6 +138,12 @@ export declare const formatToFigmaLink: ({ fileKey, nodeId, }: {
|
|
|
130
138
|
nodeId: string;
|
|
131
139
|
}) => URL;
|
|
132
140
|
|
|
141
|
+
export declare type GeneratingCodePayload = {
|
|
142
|
+
status: "success" | "running" | "failure";
|
|
143
|
+
progress: number;
|
|
144
|
+
files: AnimaFiles;
|
|
145
|
+
};
|
|
146
|
+
|
|
133
147
|
export declare type GetCodeHandler = ((message: SSECodgenMessage) => void) | {
|
|
134
148
|
onStart?: ({ sessionId }: {
|
|
135
149
|
sessionId: string;
|
|
@@ -158,7 +172,7 @@ export declare type GetCodeHandler = ((message: SSECodgenMessage) => void) | {
|
|
|
158
172
|
|
|
159
173
|
export declare type GetCodeParams = {
|
|
160
174
|
fileKey: string;
|
|
161
|
-
figmaToken
|
|
175
|
+
figmaToken?: string;
|
|
162
176
|
nodesId: string[];
|
|
163
177
|
assetsStorage?: AssetsStorage;
|
|
164
178
|
settings: CodegenSettings;
|
|
@@ -191,14 +205,14 @@ export declare type GetFileNodesParams = {
|
|
|
191
205
|
authToken?: string;
|
|
192
206
|
nodeIds: string[];
|
|
193
207
|
figmaRestApi?: FigmaRestApi;
|
|
194
|
-
params?: Record<string,
|
|
208
|
+
params?: Record<string, string | number>;
|
|
195
209
|
};
|
|
196
210
|
|
|
197
211
|
export declare type GetFilePagesParams = {
|
|
198
212
|
fileKey: string;
|
|
199
213
|
authToken?: string;
|
|
200
214
|
figmaRestApi?: FigmaRestApi;
|
|
201
|
-
params?: Record<string,
|
|
215
|
+
params?: Record<string, string | number | undefined>;
|
|
202
216
|
};
|
|
203
217
|
|
|
204
218
|
export declare type GetFilePagesResult = FigmaPage[] | undefined;
|
|
@@ -209,7 +223,7 @@ export declare type GetFileParams = {
|
|
|
209
223
|
figmaRestApi?: FigmaRestApi;
|
|
210
224
|
};
|
|
211
225
|
|
|
212
|
-
export declare const handleFigmaApiError: (error:
|
|
226
|
+
export declare const handleFigmaApiError: (error: FigmaApiError, fileKey: string) => never;
|
|
213
227
|
|
|
214
228
|
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
215
229
|
|
|
@@ -235,6 +249,11 @@ export declare class RateLimitExceeded extends Error {
|
|
|
235
249
|
});
|
|
236
250
|
}
|
|
237
251
|
|
|
252
|
+
export declare class ResponseError extends Error {
|
|
253
|
+
response: Response;
|
|
254
|
+
constructor(message: string, res: Response);
|
|
255
|
+
}
|
|
256
|
+
|
|
238
257
|
export declare type SSECodgenMessage = {
|
|
239
258
|
type: "start";
|
|
240
259
|
sessionId: string;
|
|
@@ -247,7 +266,7 @@ export declare type SSECodgenMessage = {
|
|
|
247
266
|
figmaSelectedFrameName: string;
|
|
248
267
|
} | {
|
|
249
268
|
type: "generating_code";
|
|
250
|
-
payload:
|
|
269
|
+
payload: GeneratingCodePayload;
|
|
251
270
|
} | {
|
|
252
271
|
type: "codegen_completed";
|
|
253
272
|
} | {
|