@animaapp/anima-sdk 0.4.3 → 0.4.6
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/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -8
- package/dist/index.js +844 -824
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,13 +15,13 @@ export declare class Anima {
|
|
|
15
15
|
protected hasAuth(): boolean;
|
|
16
16
|
set auth(auth: Auth);
|
|
17
17
|
protected get headers(): Record<string, string>;
|
|
18
|
-
generateCode(params: GetCodeParams, handler?: GetCodeHandler): Promise<AnimaSDKResult>;
|
|
18
|
+
generateCode(params: GetCodeParams, handler?: GetCodeHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
19
19
|
/**
|
|
20
20
|
* @experimental
|
|
21
21
|
* This API is experimental and may change or be removed in future releases.
|
|
22
22
|
* Link2Code (l2c) flow.
|
|
23
23
|
*/
|
|
24
|
-
generateLink2Code(params: GetLink2CodeParams, handler?: GetLink2CodeHandler): Promise<AnimaSDKResult>;
|
|
24
|
+
generateLink2Code(params: GetLink2CodeParams, handler?: GetLink2CodeHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export declare type AnimaFiles = Record<string, {
|
|
@@ -73,7 +73,7 @@ export declare class CodegenError extends Error {
|
|
|
73
73
|
/**
|
|
74
74
|
* Codegen errors from the worker
|
|
75
75
|
*/
|
|
76
|
-
export declare type CodegenErrorReason = "Selected node type is not supported" | "Invisible group nodes are unsupported" | "Selected node is a page with multiple children" | "There is no node with the given id" | "Invalid Figma token" | "Anima API connection error" | "Figma token expired" | "Invalid user token" | "Figma file not found" | "Figma rate limit exceeded" | "Figma selection too large" | "Invalid responsive page node type" | "Unknown";
|
|
76
|
+
export declare type CodegenErrorReason = "Selected node type is not supported" | "Invisible group nodes are unsupported" | "Selected node is a page with multiple children" | "Selected node is a page with no valid children" | "There is no node with the given id" | "Invalid Figma token" | "Anima API connection error" | "Figma token expired" | "Invalid user token" | "Figma file not found" | "Figma rate limit exceeded" | "Figma selection too large" | "Invalid responsive page node type" | "Unknown";
|
|
77
77
|
|
|
78
78
|
export declare type CodegenResult = BaseResult & {
|
|
79
79
|
files: Record<string, {
|
|
@@ -103,6 +103,7 @@ export declare type CodegenSettings = {
|
|
|
103
103
|
enableAutoSplit?: boolean;
|
|
104
104
|
autoSplitThreshold?: number;
|
|
105
105
|
disableMarkedForExport?: boolean;
|
|
106
|
+
allowAutoSelectFirstNode?: boolean;
|
|
106
107
|
enableDisplayScreenModelId?: boolean;
|
|
107
108
|
enableGeneratePackageLock?: boolean;
|
|
108
109
|
};
|
|
@@ -236,9 +237,9 @@ export declare type GetCodeParams = {
|
|
|
236
237
|
|
|
237
238
|
export declare const getFigmaApiErrorType: (error: Error) => FigmaApiErrorType;
|
|
238
239
|
|
|
239
|
-
export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, }: GetFilePagesParams) => Promise<GetFileResponse>;
|
|
240
|
+
export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, signal, }: GetFilePagesParams) => Promise<GetFileResponse>;
|
|
240
241
|
|
|
241
|
-
export declare const getFileNodes: ({ fileKey, authToken, nodeIds, figmaRestApi, params, }: GetFileNodesParams) => Promise<{
|
|
242
|
+
export declare const getFileNodes: ({ fileKey, authToken, nodeIds, figmaRestApi, params, signal, }: GetFileNodesParams) => Promise<{
|
|
242
243
|
[key: string]: {
|
|
243
244
|
document: Node_2;
|
|
244
245
|
components: {
|
|
@@ -260,6 +261,7 @@ export declare type GetFileNodesParams = {
|
|
|
260
261
|
nodeIds: string[];
|
|
261
262
|
figmaRestApi?: FigmaRestApi;
|
|
262
263
|
params?: Record<string, string | number>;
|
|
264
|
+
signal?: AbortSignal;
|
|
263
265
|
};
|
|
264
266
|
|
|
265
267
|
export declare type GetFilePagesParams = {
|
|
@@ -267,6 +269,7 @@ export declare type GetFilePagesParams = {
|
|
|
267
269
|
authToken?: string;
|
|
268
270
|
figmaRestApi?: FigmaRestApi;
|
|
269
271
|
params?: Record<string, string | number | undefined>;
|
|
272
|
+
signal?: AbortSignal;
|
|
270
273
|
};
|
|
271
274
|
|
|
272
275
|
export declare type GetFilePagesResult = FigmaPage[] | undefined;
|
|
@@ -308,14 +311,17 @@ export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
|
308
311
|
screenPath?: string;
|
|
309
312
|
}) => AnimaFiles;
|
|
310
313
|
|
|
311
|
-
declare type InvalidNodeForCodegenReason = "Selected node is a page with multiple children" | "There is no node with the given id" | "Selected node type is not supported";
|
|
314
|
+
declare type InvalidNodeForCodegenReason = "Selected node is a page with multiple children" | "Selected node is a page with no valid children" | "There is no node with the given id" | "Selected node type is not supported";
|
|
312
315
|
|
|
313
316
|
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
314
317
|
|
|
315
318
|
/**
|
|
316
|
-
* Check if the pair "design" + "node id"
|
|
319
|
+
* Check if the pair "design" + "node id" is valid for code generation.
|
|
320
|
+
* May recommend a node that is not the one passed as argument.
|
|
317
321
|
*/
|
|
318
|
-
export declare const isNodeCodegenCompatible: (design: GetFileResponse, nodeId: string
|
|
322
|
+
export declare const isNodeCodegenCompatible: (design: GetFileResponse, nodeId: string, options?: {
|
|
323
|
+
allowAutoSelectFirstNode: boolean;
|
|
324
|
+
}) => ValidateNodeForCodegenResult;
|
|
319
325
|
|
|
320
326
|
export declare const isNotFound: (error: Error) => boolean;
|
|
321
327
|
|
|
@@ -357,6 +363,7 @@ export declare type L2CParamsReactConvention = {
|
|
|
357
363
|
framework: 'react';
|
|
358
364
|
language: L2CParamsLanguage;
|
|
359
365
|
styling: L2CParamsStyling;
|
|
366
|
+
enableGeneratePackageLock?: boolean;
|
|
360
367
|
};
|
|
361
368
|
|
|
362
369
|
export declare type L2CParamsStyling = 'tailwind' | 'inline-styles';
|
|
@@ -521,6 +528,10 @@ declare type ValidateNodeForCodegenResult = {
|
|
|
521
528
|
isValid: true;
|
|
522
529
|
node: FigmaNode;
|
|
523
530
|
note?: "Selected node is a page with a single valid children - returning it instead";
|
|
531
|
+
} | {
|
|
532
|
+
isValid: true;
|
|
533
|
+
node: FigmaNode;
|
|
534
|
+
note?: "Selected node is a page with multiple valid children - returning the first one instead";
|
|
524
535
|
} | {
|
|
525
536
|
isValid: false;
|
|
526
537
|
reason: InvalidNodeForCodegenReason;
|