@animaapp/anima-sdk-react 0.3.0 → 0.3.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/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2608 -2608
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/.storybook/main.ts +0 -25
- package/.storybook/preview.ts +0 -13
- package/.turbo/turbo-build.log +0 -13
- package/.turbo/turbo-dev.log +0 -0
- package/.turbo/turbo-test.log +0 -161
- package/src/index.ts +0 -2
- package/src/stories/useAnimaCodegen.stories.tsx +0 -201
- package/src/useAnimaCodegen.ts +0 -306
- package/src/useFigmaFile.ts +0 -44
- package/src/utils.ts +0 -10
- package/vite.config.ts +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animaapp/anima-sdk-react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Anima's JavaScript utilities library",
|
|
6
6
|
"author": "Anima App, Inc.",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"vite-plugin-dts": "^4.5.0",
|
|
54
54
|
"vite-tsconfig-paths": "^5.1.4"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|
package/.storybook/main.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { join, dirname } from "path";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This function is used to resolve the absolute path of a package.
|
|
5
|
-
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
|
6
|
-
*/
|
|
7
|
-
function getAbsolutePath(value) {
|
|
8
|
-
return dirname(require.resolve(join(value, "package.json")));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** @type { import('@storybook/react-vite').StorybookConfig } */
|
|
12
|
-
const config = {
|
|
13
|
-
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
14
|
-
addons: [
|
|
15
|
-
getAbsolutePath("@storybook/addon-essentials"),
|
|
16
|
-
getAbsolutePath("@storybook/addon-onboarding"),
|
|
17
|
-
getAbsolutePath("@chromatic-com/storybook"),
|
|
18
|
-
getAbsolutePath("@storybook/addon-interactions"),
|
|
19
|
-
],
|
|
20
|
-
framework: {
|
|
21
|
-
name: getAbsolutePath("@storybook/react-vite"),
|
|
22
|
-
options: {},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
export default config;
|
package/.storybook/preview.ts
DELETED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[36mvite v6.0.11 [32mbuilding for production...[36m[39m
|
|
3
|
-
[2K[1Gtransforming (1) [2msrc/index.ts[22m[2K[1Gtransforming (14) [2m../node_modules/swr/dist/_internal/events.mjs[22m[2K[1G../node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs (1:0): Module level directives cause errors when bundled, "use client" in "../node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs" was ignored.
|
|
4
|
-
[2K[1G[32m✓[39m 25 modules transformed.
|
|
5
|
-
[2K[1Grendering chunks (1)...[2K[1G[32m
|
|
6
|
-
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
7
|
-
[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.cjs [39m[1m[2m113.03 kB[22m[1m[22m[2m │ gzip: 32.99 kB[22m[2m │ map: 416.13 kB[22m
|
|
8
|
-
[32m[36m[vite:dts][32m Start rollup declaration files...[39m
|
|
9
|
-
Analysis will use the bundled TypeScript version 5.7.2
|
|
10
|
-
[32m[36m[vite:dts][32m Declaration files built in 2433ms.
|
|
11
|
-
[39m
|
|
12
|
-
[2K[1Grendering chunks (1)...[2K[1G[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.js [39m[1m[2m167.32 kB[22m[1m[22m[2m │ gzip: 41.60 kB[22m[2m │ map: 433.44 kB[22m
|
|
13
|
-
[32m✓ built in 2.84s[39m
|
package/.turbo/turbo-dev.log
DELETED
|
Binary file
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[1m[2mDetermining test suites to run...[22m[22m[999D[K
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
6
|
-
|
|
7
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
8
|
-
|
|
9
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
10
|
-
|
|
11
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
12
|
-
|
|
13
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
page.evaluate: StorybookTestRunnerError:
|
|
50
|
-
An error occurred in the following story. Access the link for full output:
|
|
51
|
-
http://127.0.0.1:6006/?path=/story/hooks-useanimacodegen--success&addonPanel=storybook/interactions/panel
|
|
52
|
-
|
|
53
|
-
Message:
|
|
54
|
-
expected null to match object { sessionId: Anything, …(4) }
|
|
55
|
-
[2m[22m
|
|
56
|
-
[2m [0m[0m[22m
|
|
57
|
-
[2m[22m
|
|
58
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:217:58[22m[2m[22m
|
|
59
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
60
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
61
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
62
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
63
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
64
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16[22m[2m[22m
|
|
65
|
-
[2m [2mat testFn ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:302:49)[22m[2m[22m
|
|
66
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:315:33)[22m[2m[22m
|
|
67
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
68
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
69
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
70
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
71
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
72
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16)[22m[2m[22m
|
|
73
|
-
|
|
74
|
-
[1m[31m [1m● [22m[1mHooks/useAnimaCodegen › InvalidBody › play-test[39m[22m
|
|
75
|
-
|
|
76
|
-
page.evaluate: StorybookTestRunnerError:
|
|
77
|
-
An error occurred in the following story. Access the link for full output:
|
|
78
|
-
http://127.0.0.1:6006/?path=/story/hooks-useanimacodegen--invalid-body&addonPanel=storybook/interactions/panel
|
|
79
|
-
|
|
80
|
-
Message:
|
|
81
|
-
expected { name: 'TypeError', …(1) } to match object { …(4) }
|
|
82
|
-
[2m[22m
|
|
83
|
-
[2m [0m[0m[22m
|
|
84
|
-
[2m[22m
|
|
85
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:404:58[22m[2m[22m
|
|
86
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
87
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
88
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
89
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
90
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
91
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16[22m[2m[22m
|
|
92
|
-
[2m [2mat testFn ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:489:49)[22m[2m[22m
|
|
93
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:502:33)[22m[2m[22m
|
|
94
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
95
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
96
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
97
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
98
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
99
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16)[22m[2m[22m
|
|
100
|
-
|
|
101
|
-
[1m[31m [1m● [22m[1mHooks/useAnimaCodegen › NotFoundFile › play-test[39m[22m
|
|
102
|
-
|
|
103
|
-
page.evaluate: StorybookTestRunnerError:
|
|
104
|
-
An error occurred in the following story. Access the link for full output:
|
|
105
|
-
http://127.0.0.1:6006/?path=/story/hooks-useanimacodegen--not-found-file&addonPanel=storybook/interactions/panel
|
|
106
|
-
|
|
107
|
-
Message:
|
|
108
|
-
expected { name: 'TypeError', …(1) } to match object { name: 'Task Crashed', …(1) }
|
|
109
|
-
[2m[22m
|
|
110
|
-
[2m [0m[0m[22m
|
|
111
|
-
[2m[22m
|
|
112
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:591:58[22m[2m[22m
|
|
113
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
114
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
115
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
116
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
117
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
118
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16[22m[2m[22m
|
|
119
|
-
[2m [2mat testFn ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:676:49)[22m[2m[22m
|
|
120
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:689:33)[22m[2m[22m
|
|
121
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
122
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
123
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
124
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
125
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
126
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16)[22m[2m[22m
|
|
127
|
-
|
|
128
|
-
[1m[31m [1m● [22m[1mHooks/useAnimaCodegen › InvalidSelectedNode › play-test[39m[22m
|
|
129
|
-
|
|
130
|
-
page.evaluate: StorybookTestRunnerError:
|
|
131
|
-
An error occurred in the following story. Access the link for full output:
|
|
132
|
-
http://127.0.0.1:6006/?path=/story/hooks-useanimacodegen--invalid-selected-node&addonPanel=storybook/interactions/panel
|
|
133
|
-
|
|
134
|
-
Message:
|
|
135
|
-
expected { name: 'TypeError', …(1) } to match object { name: 'Task Crashed', …(1) }
|
|
136
|
-
[2m[22m
|
|
137
|
-
[2m [0m[0m[22m
|
|
138
|
-
[2m[22m
|
|
139
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:778:58[22m[2m[22m
|
|
140
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
141
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
142
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
143
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
144
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
145
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16[22m[2m[22m
|
|
146
|
-
[2m [2mat testFn ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:863:49)[22m[2m[22m
|
|
147
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:876:33)[22m[2m[22m
|
|
148
|
-
[2m [2mat step ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:161:23)[22m[2m[22m
|
|
149
|
-
[2m [2mat Object.next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:102:20)[22m[2m[22m
|
|
150
|
-
[2m [2mat asyncGeneratorStep ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:4:28)[22m[2m[22m
|
|
151
|
-
[2m [2mat _next ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:22:17)[22m[2m[22m
|
|
152
|
-
[2m [2mat [22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:27:13[22m[2m[22m
|
|
153
|
-
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msdk-react/src/stories/useAnimaCodegen.stories.tsx[39m[0m[2m:19:16)[22m[2m[22m
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [0m[7m[33m browser: chromium [39m[27m[0m [2msrc/stories/[22m[1museAnimaCodegen.stories.tsx[22m
|
|
157
|
-
|
|
158
|
-
[1mTests: [22m[1m[31m4 failed[39m[22m, 4 total
|
|
159
|
-
[1mSnapshots: [22m0 total
|
|
160
|
-
[1mTime:[22m 1.07 s
|
|
161
|
-
[2mRan all test suites[22m[2m.[22m
|
package/src/index.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { expect, userEvent, waitFor, within } from "@storybook/test";
|
|
3
|
-
import { AnimaSDKResult, CodegenError } from "@animaapp/anima-sdk";
|
|
4
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
|
-
import { useAnimaCodegen, UseAnimaParams } from "..";
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
payload: UseAnimaParams;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const DummyComponent = ({ payload }: Props) => {
|
|
12
|
-
const [result, setResult] = useState<AnimaSDKResult | null>(null);
|
|
13
|
-
const [error, setError] = useState<CodegenError | null>(null);
|
|
14
|
-
|
|
15
|
-
const animaCodegen = useAnimaCodegen({
|
|
16
|
-
url: "http://localhost:3000",
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const handleClick = async () => {
|
|
20
|
-
const { result, error } = await animaCodegen.getCode(payload);
|
|
21
|
-
|
|
22
|
-
setResult(result);
|
|
23
|
-
setError(error);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div>
|
|
28
|
-
<button data-testid="run-button" onClick={handleClick}>
|
|
29
|
-
Run request
|
|
30
|
-
</button>
|
|
31
|
-
|
|
32
|
-
{result && (
|
|
33
|
-
<div>
|
|
34
|
-
<h3>Success result</h3>
|
|
35
|
-
|
|
36
|
-
<pre data-testid="request-result" data-status="success">
|
|
37
|
-
{JSON.stringify(result, null, 2)}
|
|
38
|
-
</pre>
|
|
39
|
-
</div>
|
|
40
|
-
)}
|
|
41
|
-
|
|
42
|
-
{error && (
|
|
43
|
-
<div>
|
|
44
|
-
<h3>Error result</h3>
|
|
45
|
-
|
|
46
|
-
<pre data-testid="request-result" data-status="error">
|
|
47
|
-
{JSON.stringify(
|
|
48
|
-
{
|
|
49
|
-
name: error.name,
|
|
50
|
-
message: error.message,
|
|
51
|
-
status: error.status,
|
|
52
|
-
detail: error.detail,
|
|
53
|
-
},
|
|
54
|
-
null,
|
|
55
|
-
2
|
|
56
|
-
)}
|
|
57
|
-
</pre>
|
|
58
|
-
</div>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const meta = {
|
|
65
|
-
title: "Hooks/useAnimaCodegen",
|
|
66
|
-
component: DummyComponent,
|
|
67
|
-
} satisfies Meta<typeof DummyComponent>;
|
|
68
|
-
export default meta;
|
|
69
|
-
|
|
70
|
-
type Story = StoryObj<typeof meta>;
|
|
71
|
-
|
|
72
|
-
const run = async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
73
|
-
const result: { result: AnimaSDKResult | null; error: CodegenError | null } =
|
|
74
|
-
{ result: null, error: null };
|
|
75
|
-
|
|
76
|
-
const canvas = within(canvasElement);
|
|
77
|
-
|
|
78
|
-
const runButton = canvas.getByTestId("run-button");
|
|
79
|
-
await userEvent.click(runButton);
|
|
80
|
-
|
|
81
|
-
const requestResult = await waitFor(
|
|
82
|
-
() => canvas.findByTestId("request-result"),
|
|
83
|
-
{ timeout: 10_000 }
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
if (!requestResult.textContent) {
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const resultStatus = requestResult.dataset.status;
|
|
91
|
-
|
|
92
|
-
if (resultStatus === "success") {
|
|
93
|
-
result.result = JSON.parse(requestResult.textContent);
|
|
94
|
-
} else {
|
|
95
|
-
result.error = JSON.parse(requestResult.textContent);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return result;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const Success: Story = {
|
|
102
|
-
play: async (context) => {
|
|
103
|
-
const { result } = await run(context);
|
|
104
|
-
|
|
105
|
-
expect(result).toMatchObject({
|
|
106
|
-
sessionId: expect.anything(),
|
|
107
|
-
figmaFileName: "Anima SDK - Test File",
|
|
108
|
-
figmaSelectedFrameName: "MyFrame",
|
|
109
|
-
files: expect.anything(),
|
|
110
|
-
tokenUsage: expect.anything(),
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
args: {
|
|
115
|
-
payload: {
|
|
116
|
-
fileKey: "5d0u9PmD4GtB5fdX57pTtK",
|
|
117
|
-
nodesId: ["1:2"],
|
|
118
|
-
settings: {
|
|
119
|
-
framework: "react",
|
|
120
|
-
styling: "plain_css",
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export const InvalidBody: Story = {
|
|
127
|
-
play: async (context) => {
|
|
128
|
-
const { error } = await run(context);
|
|
129
|
-
|
|
130
|
-
expect(error).toMatchObject({
|
|
131
|
-
name: "HTTP error from Anima API",
|
|
132
|
-
message: "Invalid body payload",
|
|
133
|
-
status: 400,
|
|
134
|
-
detail: [
|
|
135
|
-
{
|
|
136
|
-
code: "invalid_type",
|
|
137
|
-
expected: "string",
|
|
138
|
-
received: "null",
|
|
139
|
-
path: ["fileKey"],
|
|
140
|
-
message: "Expected string, received null",
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
});
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
args: {
|
|
147
|
-
payload: {
|
|
148
|
-
// @ts-expect-error: Testing invalid body payload
|
|
149
|
-
fileKey: null,
|
|
150
|
-
nodesId: ["1:2"],
|
|
151
|
-
settings: {
|
|
152
|
-
framework: "react",
|
|
153
|
-
styling: "plain_css",
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export const NotFoundFile: Story = {
|
|
160
|
-
play: async (context) => {
|
|
161
|
-
const { error } = await run(context);
|
|
162
|
-
|
|
163
|
-
expect(error).toMatchObject({
|
|
164
|
-
name: "Task Crashed",
|
|
165
|
-
message: "Figma file not found",
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
args: {
|
|
170
|
-
payload: {
|
|
171
|
-
fileKey: "invalid-file-key",
|
|
172
|
-
nodesId: ["1:2"],
|
|
173
|
-
settings: {
|
|
174
|
-
framework: "react",
|
|
175
|
-
styling: "plain_css",
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
export const InvalidSelectedNode: Story = {
|
|
182
|
-
play: async (context) => {
|
|
183
|
-
const { error } = await run(context);
|
|
184
|
-
|
|
185
|
-
expect(error).toMatchObject({
|
|
186
|
-
name: "Task Crashed",
|
|
187
|
-
message: "Selected node type is not supported",
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
args: {
|
|
192
|
-
payload: {
|
|
193
|
-
fileKey: "5d0u9PmD4GtB5fdX57pTtK",
|
|
194
|
-
nodesId: ["14:5"],
|
|
195
|
-
settings: {
|
|
196
|
-
framework: "react",
|
|
197
|
-
styling: "plain_css",
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
};
|