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 ADDED
@@ -0,0 +1,113 @@
1
+ # exodeui
2
+
3
+ The React Runtime for the ExodeUI Animation Engine. Easily render and interact with ExodeUI animations in your React applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install exodeui
9
+ # or
10
+ yarn add exodeui
11
+ ```
12
+
13
+ ## Basic Usage
14
+
15
+ ```tsx
16
+ import { ExodeUICanvas } from 'exodeui';
17
+
18
+ function App() {
19
+ return (
20
+ <div style={{ width: 500, height: 500 }}>
21
+ {/* Option 1: Load from a URL or file path (e.g. in public folder) */}
22
+ <ExodeUICanvas
23
+ src="/my-animation.json"
24
+ autoPlay={true}
25
+ fit="Contain"
26
+ alignment="Center"
27
+ />
28
+ </div>
29
+ );
30
+ }
31
+ ```
32
+
33
+ ### Loading via Import
34
+
35
+ Alternatively, you can import the JSON directly if your bundler supports it:
36
+
37
+ ```tsx
38
+ import { ExodeUICanvas } from 'exodeui';
39
+ import animationData from './my-animation.json';
40
+
41
+ function App() {
42
+ return (
43
+ <ExodeUICanvas artboard={animationData} />
44
+ )
45
+ }
46
+ ```
47
+
48
+ ## API
49
+
50
+ ### `<ExodeUICanvas />`
51
+
52
+ The main component for rendering ExodeUI animations.
53
+
54
+ | Prop | Type | Default | Description |
55
+ |------|------|---------|-------------|
56
+ | `artboard` | `object` | `undefined` | The JSON animation data object. |
57
+ | `src` | `string` | `undefined` | URL to fetch the animation JSON from. |
58
+ | `autoPlay` | `boolean` | `true` | Whether the animation should start playing automatically. |
59
+ | `fit` | `'Contain' \| 'Cover' \| 'Fill' \| 'FitWidth' \| 'FitHeight' \| 'None' \| 'ScaleDown'` | `'Contain'` | How the artboard fits within the canvas. |
60
+ | `alignment` | `'Center' \| 'TopLeft' \| ...` | `'Center'` | How the content aligns if there is extra space. |
61
+ | `onReady` | `(engine: ExodeUIEngine) => void` | `undefined` | Callback fired when the engine is loaded and ready. |
62
+ | `style` | `CSSProperties` | `{ width: '100%', height: '100%' }` | CSS styles for the canvas element. |
63
+ | `className` | `string` | `undefined` | CSS class name for the canvas element. |
64
+
65
+ ### `useExodeUI` Hook
66
+
67
+ (Coming Soon)
68
+
69
+ ## State Machine Inputs
70
+
71
+ You can control the animation state machine using the engine instance provided via `onReady`.
72
+
73
+ ```tsx
74
+ const [engine, setEngine] = useState<ExodeUIEngine | null>(null);
75
+
76
+ // ...
77
+
78
+ <ExodeUICanvas
79
+ artboard={data}
80
+ onReady={(e) => {
81
+ setEngine(e);
82
+
83
+ // Listen to triggers
84
+ e.setTriggerCallback((triggerName, animationName) => {
85
+ console.log(`Trigger "${triggerName}" fired! Playing "${animationName}"`);
86
+ });
87
+ }}
88
+ />
89
+
90
+ <button onClick={() => engine?.setInputBool('IsWalking', true)}>
91
+ Walk
92
+ </button>
93
+ ```
94
+
95
+ ## Listening to Triggers
96
+
97
+ You can listen for interactive triggers (e.g. clicks on shapes) using `setTriggerCallback`:
98
+
99
+ ```tsx
100
+ <ExodeUICanvas
101
+ artboard={data}
102
+ onReady={(engine) => {
103
+ engine.setTriggerCallback((triggerName, animationName) => {
104
+ // Handle side effects here (e.g. navigation, sound, analytics)
105
+ console.log(triggerName, animationName);
106
+ });
107
+ }}
108
+ />
109
+ ```
110
+
111
+ ## License
112
+
113
+ MIT
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ import { ExodeUIEngine } from './engine';
3
+ import { Artboard, Fit, Alignment } from './types';
4
+
5
+ export interface ExodeUICanvasProps {
6
+ artboard?: Artboard;
7
+ src?: string;
8
+ className?: string;
9
+ style?: React.CSSProperties;
10
+ autoPlay?: boolean;
11
+ fit?: Fit;
12
+ alignment?: Alignment;
13
+ onReady?: (engine: ExodeUIEngine) => void;
14
+ onTrigger?: (triggerName: string, animationName: string) => void;
15
+ onInputUpdate?: (nameOrId: string, value: any) => void;
16
+ }
17
+ export declare const ExodeUICanvas: React.ForwardRefExoticComponent<ExodeUICanvasProps & React.RefAttributes<HTMLCanvasElement>>;
@@ -0,0 +1,42 @@
1
+ import { Artboard, Fit, Alignment } from './types';
2
+
3
+ export declare class ExodeUIEngine {
4
+ private artboard;
5
+ private objectStates;
6
+ private physicsEngine;
7
+ private activeStateMachine;
8
+ private inputs;
9
+ private inputNameMap;
10
+ private layerStates;
11
+ private imageCache;
12
+ private layout;
13
+ private onTrigger?;
14
+ private onInputUpdate?;
15
+ setTriggerCallback(cb: (triggerName: string, animationName: string) => void): void;
16
+ setInputUpdateCallback(cb: (nameOrId: string, value: any) => void): void;
17
+ constructor();
18
+ private setInternalInput;
19
+ setLayout(fit: Fit, alignment: Alignment): void;
20
+ getActiveStateIds(layerName?: string): string[];
21
+ load(data: Artboard): void;
22
+ reset(): void;
23
+ private enterStates;
24
+ setInputBool(nameOrId: string, value: boolean): void;
25
+ setInputNumber(nameOrId: string, value: number): void;
26
+ fireTrigger(nameOrId: string): void;
27
+ setInputText(nameOrId: string, value: string): void;
28
+ private updateInput;
29
+ private evaluateTransitions;
30
+ private checkConditions;
31
+ private activeTriggers;
32
+ advance(dt: number): void;
33
+ handlePointerInput(type: string, canvasX: number, canvasY: number, canvasWidth: number, canvasHeight: number): void;
34
+ private handlePointerEvent;
35
+ private hitTest;
36
+ private applyAnimation;
37
+ private interpolate;
38
+ private interpolateColor;
39
+ render(ctx: CanvasRenderingContext2D, width: number, height: number): void;
40
+ private calculateTransform;
41
+ private renderObject;
42
+ }
@@ -0,0 +1,4 @@
1
+ export * from './ExodeUICanvas';
2
+ export * from './types';
3
+ export * from './engine';
4
+ export * from './useExodeUI';