@lxgicstudios/ai-animation 1.0.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,32 @@
1
+ # ai-animation
2
+
3
+ Generate CSS and Framer Motion animations from plain English.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g ai-animation
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ npx ai-animation "fade in from left with bounce"
15
+ npx ai-animation "pulse glow effect" -f css
16
+ npx ai-animation "staggered list entrance" -f framer -o animations.ts
17
+ ```
18
+
19
+ ## Options
20
+
21
+ - `-f, --format <format>` - css, framer, or both (default: both)
22
+ - `-o, --output <file>` - Write to file
23
+
24
+ ## Setup
25
+
26
+ ```bash
27
+ export OPENAI_API_KEY=sk-...
28
+ ```
29
+
30
+ ## License
31
+
32
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const commander_1 = require("commander");
41
+ const ora_1 = __importDefault(require("ora"));
42
+ const fs = __importStar(require("fs"));
43
+ const index_1 = require("./index");
44
+ const program = new commander_1.Command();
45
+ program
46
+ .name("ai-animation")
47
+ .description("Generate CSS and Framer Motion animations from descriptions")
48
+ .version("1.0.0")
49
+ .argument("<description>", "Describe the animation you want")
50
+ .option("-f, --format <format>", "Output format: css, framer, or both", "both")
51
+ .option("-o, --output <file>", "Write to file")
52
+ .action(async (description, opts) => {
53
+ const spinner = (0, ora_1.default)("Generating animation...").start();
54
+ try {
55
+ const code = await (0, index_1.generateAnimation)(description, opts);
56
+ spinner.stop();
57
+ if (opts.output) {
58
+ fs.writeFileSync(opts.output, code);
59
+ console.log(`Animation written to ${opts.output}`);
60
+ }
61
+ else {
62
+ console.log("\n" + code + "\n");
63
+ }
64
+ }
65
+ catch (err) {
66
+ spinner.fail(err.message);
67
+ process.exit(1);
68
+ }
69
+ });
70
+ program.parse();
@@ -0,0 +1,3 @@
1
+ export declare function generateAnimation(description: string, options: {
2
+ format?: string;
3
+ }): Promise<string>;
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateAnimation = generateAnimation;
7
+ const openai_1 = __importDefault(require("openai"));
8
+ const openai = new openai_1.default({ apiKey: process.env.OPENAI_API_KEY });
9
+ async function generateAnimation(description, options) {
10
+ const format = options.format || "both";
11
+ let outputInstructions = "";
12
+ if (format === "css")
13
+ outputInstructions = "Generate CSS @keyframes animation only.";
14
+ else if (format === "framer")
15
+ outputInstructions = "Generate Framer Motion animation config only (motion component props).";
16
+ else
17
+ outputInstructions = "Generate both CSS @keyframes and Framer Motion equivalent.";
18
+ const res = await openai.chat.completions.create({
19
+ model: "gpt-4o-mini",
20
+ messages: [
21
+ {
22
+ role: "system",
23
+ content: `You are a frontend animation expert. ${outputInstructions} Include proper easing, timing, and clean code. Return ONLY the code, no explanation.`,
24
+ },
25
+ {
26
+ role: "user",
27
+ content: `Create animation: ${description}`,
28
+ },
29
+ ],
30
+ temperature: 0.4,
31
+ });
32
+ return res.choices[0].message.content || "";
33
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@lxgicstudios/ai-animation",
3
+ "version": "1.0.0",
4
+ "description": "Generate CSS and Framer Motion animations from descriptions",
5
+ "main": "dist/index.js",
6
+ "bin": { "ai-animation": "dist/cli.js" },
7
+ "scripts": { "build": "tsc" },
8
+ "keywords": ["css", "animation", "framer-motion", "ai", "generator"],
9
+ "license": "MIT",
10
+ "dependencies": { "commander": "^12.1.0", "openai": "^4.73.0", "ora": "^5.4.1" },
11
+ "devDependencies": { "typescript": "^5.6.0", "@types/node": "^22.0.0" },
12
+ "author": "LXGIC Studios",
13
+ "repository": { "type": "git", "url": "https://github.com/lxgicstudios/ai-animation" }
14
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from "commander";
4
+ import ora from "ora";
5
+ import * as fs from "fs";
6
+ import { generateAnimation } from "./index";
7
+
8
+ const program = new Command();
9
+
10
+ program
11
+ .name("ai-animation")
12
+ .description("Generate CSS and Framer Motion animations from descriptions")
13
+ .version("1.0.0")
14
+ .argument("<description>", "Describe the animation you want")
15
+ .option("-f, --format <format>", "Output format: css, framer, or both", "both")
16
+ .option("-o, --output <file>", "Write to file")
17
+ .action(async (description, opts) => {
18
+ const spinner = ora("Generating animation...").start();
19
+ try {
20
+ const code = await generateAnimation(description, opts);
21
+ spinner.stop();
22
+ if (opts.output) {
23
+ fs.writeFileSync(opts.output, code);
24
+ console.log(`Animation written to ${opts.output}`);
25
+ } else {
26
+ console.log("\n" + code + "\n");
27
+ }
28
+ } catch (err: any) {
29
+ spinner.fail(err.message);
30
+ process.exit(1);
31
+ }
32
+ });
33
+
34
+ program.parse();
package/src/index.ts ADDED
@@ -0,0 +1,27 @@
1
+ import OpenAI from "openai";
2
+
3
+ const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
4
+
5
+ export async function generateAnimation(description: string, options: { format?: string }): Promise<string> {
6
+ const format = options.format || "both";
7
+ let outputInstructions = "";
8
+ if (format === "css") outputInstructions = "Generate CSS @keyframes animation only.";
9
+ else if (format === "framer") outputInstructions = "Generate Framer Motion animation config only (motion component props).";
10
+ else outputInstructions = "Generate both CSS @keyframes and Framer Motion equivalent.";
11
+
12
+ const res = await openai.chat.completions.create({
13
+ model: "gpt-4o-mini",
14
+ messages: [
15
+ {
16
+ role: "system",
17
+ content: `You are a frontend animation expert. ${outputInstructions} Include proper easing, timing, and clean code. Return ONLY the code, no explanation.`,
18
+ },
19
+ {
20
+ role: "user",
21
+ content: `Create animation: ${description}`,
22
+ },
23
+ ],
24
+ temperature: 0.4,
25
+ });
26
+ return res.choices[0].message.content || "";
27
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "outDir": "dist",
6
+ "rootDir": "src",
7
+ "esModuleInterop": true,
8
+ "strict": true,
9
+ "resolveJsonModule": true,
10
+ "declaration": true
11
+ },
12
+ "include": ["src"]
13
+ }