exodeui 2.4.0
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/README.md +113 -0
- package/dist/ExodeUICanvas.d.ts +17 -0
- package/dist/engine.d.ts +42 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +30 -0
- package/dist/index.mjs +5783 -0
- package/dist/physics/PhysicsEngine.d.ts +40 -0
- package/dist/physics/RapierPhysics.d.ts +30 -0
- package/dist/physics/index.d.ts +2 -0
- package/dist/renderer.d.ts +5 -0
- package/dist/types.d.ts +236 -0
- package/dist/useExodeUI.d.ts +10 -0
- package/package.json +32 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface BodyOptions {
|
|
2
|
+
id: string;
|
|
3
|
+
type: 'Rectangle' | 'Ellipse' | 'Triangle' | 'Star' | 'Polygon';
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
rotation?: number;
|
|
9
|
+
isStatic: boolean;
|
|
10
|
+
mass?: number;
|
|
11
|
+
friction?: number;
|
|
12
|
+
restitution?: number;
|
|
13
|
+
frictionAir?: number;
|
|
14
|
+
density?: number;
|
|
15
|
+
isSensor?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PhysicsEngine {
|
|
18
|
+
init(gravity: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
createBody(options: BodyOptions): void;
|
|
24
|
+
removeBody(id: string): void;
|
|
25
|
+
step(dt: number): void;
|
|
26
|
+
getPosition(id: string): {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
} | null;
|
|
30
|
+
getRotation(id: string): number | null;
|
|
31
|
+
getVelocity(id: string): {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
} | null;
|
|
35
|
+
setPosition(id: string, x: number, y: number): void;
|
|
36
|
+
setRotation(id: string, angle: number): void;
|
|
37
|
+
setVelocity(id: string, vx: number, vy: number): void;
|
|
38
|
+
applyForce(id: string, fx: number, fy: number): void;
|
|
39
|
+
applyImpulse(id: string, ix: number, iy: number): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PhysicsEngine, BodyOptions } from './PhysicsEngine';
|
|
2
|
+
|
|
3
|
+
export declare class RapierPhysics implements PhysicsEngine {
|
|
4
|
+
private world;
|
|
5
|
+
private bodies;
|
|
6
|
+
private colliders;
|
|
7
|
+
private initialized;
|
|
8
|
+
init(gravity: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
createBody(options: BodyOptions): void;
|
|
14
|
+
removeBody(id: string): void;
|
|
15
|
+
step(dt: number): void;
|
|
16
|
+
getPosition(id: string): {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | null;
|
|
20
|
+
getRotation(id: string): number | null;
|
|
21
|
+
getVelocity(id: string): {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
} | null;
|
|
25
|
+
setPosition(id: string, x: number, y: number): void;
|
|
26
|
+
setRotation(id: string, angle: number): void;
|
|
27
|
+
setVelocity(id: string, vx: number, vy: number): void;
|
|
28
|
+
applyForce(id: string, fx: number, fy: number): void;
|
|
29
|
+
applyImpulse(id: string, ix: number, iy: number): void;
|
|
30
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
export interface Transform {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
rotation: number;
|
|
5
|
+
scale_x: number;
|
|
6
|
+
scale_y: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Shadow {
|
|
9
|
+
color: string;
|
|
10
|
+
blur: number;
|
|
11
|
+
offsetX: number;
|
|
12
|
+
offsetY: number;
|
|
13
|
+
opacity: number;
|
|
14
|
+
}
|
|
15
|
+
export interface Blur {
|
|
16
|
+
amount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Style {
|
|
19
|
+
fill?: {
|
|
20
|
+
type: 'Solid' | 'LinearGradient' | 'RadialGradient' | 'None';
|
|
21
|
+
color: string;
|
|
22
|
+
opacity: number;
|
|
23
|
+
};
|
|
24
|
+
stroke?: {
|
|
25
|
+
color: string;
|
|
26
|
+
width: number;
|
|
27
|
+
opacity: number;
|
|
28
|
+
};
|
|
29
|
+
shadow?: Shadow;
|
|
30
|
+
blur?: Blur;
|
|
31
|
+
palette?: string[];
|
|
32
|
+
}
|
|
33
|
+
export type Geometry = {
|
|
34
|
+
type: 'Rectangle';
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
corner_radius?: number;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'Ellipse';
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'Text';
|
|
44
|
+
text: string;
|
|
45
|
+
fontSize: number;
|
|
46
|
+
fontFamily: string;
|
|
47
|
+
textInputId?: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'SVG';
|
|
50
|
+
svgContent: string;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
preserveAspectRatio: boolean;
|
|
54
|
+
colors: string[];
|
|
55
|
+
} | {
|
|
56
|
+
type: 'Triangle';
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'Polygon';
|
|
61
|
+
radius: number;
|
|
62
|
+
sides: number;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'Star';
|
|
65
|
+
inner_radius: number;
|
|
66
|
+
outer_radius: number;
|
|
67
|
+
points: number;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'Line';
|
|
70
|
+
length: number;
|
|
71
|
+
} | {
|
|
72
|
+
type: 'SVG';
|
|
73
|
+
svgContent: string;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
preserveAspectRatio: boolean;
|
|
77
|
+
colors: string[];
|
|
78
|
+
} | {
|
|
79
|
+
type: 'Image';
|
|
80
|
+
src: string;
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
};
|
|
84
|
+
export interface Trigger {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
eventType: 'onClick' | 'onHold' | 'pointerDown' | 'pointerUp' | 'hover';
|
|
88
|
+
entryAnimationId?: string | null;
|
|
89
|
+
exitAnimationId?: string | null;
|
|
90
|
+
duration?: number;
|
|
91
|
+
loop?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface Interaction {
|
|
94
|
+
id: string;
|
|
95
|
+
event: 'onClick' | 'onHold' | 'pointerDown' | 'pointerUp' | 'hover';
|
|
96
|
+
action: 'setInput' | 'fireTrigger';
|
|
97
|
+
targetInputId: string;
|
|
98
|
+
value?: any;
|
|
99
|
+
}
|
|
100
|
+
export interface Physics {
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
bodyType: 'Dynamic' | 'Static';
|
|
103
|
+
mass: number;
|
|
104
|
+
density: number;
|
|
105
|
+
friction: number;
|
|
106
|
+
restitution: number;
|
|
107
|
+
frictionAir: number;
|
|
108
|
+
isSensor: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface ShapeObject {
|
|
111
|
+
type: 'Shape';
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
transform: Transform;
|
|
115
|
+
geometry: Geometry;
|
|
116
|
+
style: Style;
|
|
117
|
+
triggers?: Trigger[];
|
|
118
|
+
interactions?: Interaction[];
|
|
119
|
+
physics?: Physics;
|
|
120
|
+
}
|
|
121
|
+
export interface Keyframe {
|
|
122
|
+
time: number;
|
|
123
|
+
value: number | string;
|
|
124
|
+
easing: string;
|
|
125
|
+
}
|
|
126
|
+
export interface Track {
|
|
127
|
+
object_id: string;
|
|
128
|
+
property: string;
|
|
129
|
+
keyframes: Keyframe[];
|
|
130
|
+
}
|
|
131
|
+
export interface Animation {
|
|
132
|
+
id: string;
|
|
133
|
+
name: string;
|
|
134
|
+
duration: number;
|
|
135
|
+
tracks: Track[];
|
|
136
|
+
}
|
|
137
|
+
export declare enum ConditionOp {
|
|
138
|
+
Equal = "Equal",
|
|
139
|
+
NotEqual = "NotEqual",
|
|
140
|
+
GreaterThan = "GreaterThan",
|
|
141
|
+
LessThan = "LessThan",
|
|
142
|
+
GreaterEqual = "GreaterEqual",
|
|
143
|
+
LessEqual = "LessEqual",
|
|
144
|
+
IsTrue = "IsTrue",
|
|
145
|
+
IsFalse = "IsFalse"
|
|
146
|
+
}
|
|
147
|
+
export interface Condition {
|
|
148
|
+
inputId: string;
|
|
149
|
+
op: ConditionOp;
|
|
150
|
+
value?: number | boolean;
|
|
151
|
+
}
|
|
152
|
+
export interface StateAction {
|
|
153
|
+
type: 'SetInput' | 'FireTrigger';
|
|
154
|
+
inputId: string;
|
|
155
|
+
value?: boolean | number;
|
|
156
|
+
}
|
|
157
|
+
export interface Transition {
|
|
158
|
+
id: string;
|
|
159
|
+
targetStateId: string;
|
|
160
|
+
duration: number;
|
|
161
|
+
delay?: number;
|
|
162
|
+
conditions: Condition[];
|
|
163
|
+
}
|
|
164
|
+
export interface State {
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
x: number;
|
|
168
|
+
y: number;
|
|
169
|
+
transitions: Transition[];
|
|
170
|
+
animationId?: string | null;
|
|
171
|
+
loop?: boolean;
|
|
172
|
+
speed?: number;
|
|
173
|
+
onEntry?: StateAction[];
|
|
174
|
+
onExit?: StateAction[];
|
|
175
|
+
}
|
|
176
|
+
export type InputValue = {
|
|
177
|
+
type: 'Boolean';
|
|
178
|
+
value: boolean;
|
|
179
|
+
} | {
|
|
180
|
+
type: 'Number';
|
|
181
|
+
value: number;
|
|
182
|
+
} | {
|
|
183
|
+
type: 'Trigger';
|
|
184
|
+
value: boolean;
|
|
185
|
+
} | {
|
|
186
|
+
type: 'Text';
|
|
187
|
+
value: string;
|
|
188
|
+
};
|
|
189
|
+
export interface InputNodePosition {
|
|
190
|
+
id: string;
|
|
191
|
+
x: number;
|
|
192
|
+
y: number;
|
|
193
|
+
}
|
|
194
|
+
export interface Input {
|
|
195
|
+
id: string;
|
|
196
|
+
name: string;
|
|
197
|
+
value: InputValue;
|
|
198
|
+
x?: number;
|
|
199
|
+
y?: number;
|
|
200
|
+
nodes?: InputNodePosition[];
|
|
201
|
+
}
|
|
202
|
+
export interface Layer {
|
|
203
|
+
name: string;
|
|
204
|
+
entryStateId: string;
|
|
205
|
+
entryConditions?: Condition[];
|
|
206
|
+
states: State[];
|
|
207
|
+
}
|
|
208
|
+
export interface StateMachine {
|
|
209
|
+
inputs: Input[];
|
|
210
|
+
layers: Layer[];
|
|
211
|
+
}
|
|
212
|
+
export interface Artboard {
|
|
213
|
+
name: string;
|
|
214
|
+
width: number;
|
|
215
|
+
height: number;
|
|
216
|
+
backgroundColor: string;
|
|
217
|
+
objects: ShapeObject[];
|
|
218
|
+
animations: Animation[];
|
|
219
|
+
stateMachine?: StateMachine;
|
|
220
|
+
physics?: {
|
|
221
|
+
gravity: {
|
|
222
|
+
x: number;
|
|
223
|
+
y: number;
|
|
224
|
+
};
|
|
225
|
+
wind: {
|
|
226
|
+
x: number;
|
|
227
|
+
y: number;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export type Fit = 'Cover' | 'Contain' | 'Fill' | 'FitWidth' | 'FitHeight' | 'None' | 'ScaleDown';
|
|
232
|
+
export type Alignment = 'Center' | 'TopLeft' | 'TopCenter' | 'TopRight' | 'CenterLeft' | 'CenterRight' | 'BottomLeft' | 'BottomCenter' | 'BottomRight';
|
|
233
|
+
export interface Layout {
|
|
234
|
+
fit: Fit;
|
|
235
|
+
alignment: Alignment;
|
|
236
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExodeUIEngine } from './engine';
|
|
2
|
+
|
|
3
|
+
export declare function useExodeUI(): {
|
|
4
|
+
setEngine: import('react').Dispatch<import('react').SetStateAction<ExodeUIEngine | null>>;
|
|
5
|
+
engine: ExodeUIEngine | null;
|
|
6
|
+
setInputBool: (name: string, value: boolean) => void;
|
|
7
|
+
setInputNumber: (name: string, value: number) => void;
|
|
8
|
+
fireTrigger: (name: string) => void;
|
|
9
|
+
setInputText: (name: string, value: string) => void;
|
|
10
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "exodeui",
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "React Runtime for ExodeUI Animation Engine",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "vite build",
|
|
14
|
+
"dev": "vite build --watch"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": ">=16.8.0",
|
|
18
|
+
"react-dom": ">=16.8.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/react": "^18.2.0",
|
|
22
|
+
"@types/react-dom": "^18.2.0",
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-dom": "^18.2.0",
|
|
25
|
+
"typescript": "^5.0.0",
|
|
26
|
+
"vite": "^5.0.0",
|
|
27
|
+
"vite-plugin-dts": "^3.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@dimforge/rapier2d-compat": "^0.19.3"
|
|
31
|
+
}
|
|
32
|
+
}
|