tweenlabs 0.1.3 → 0.1.5
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 +168 -168
- package/bin/cli.js +154 -66
- package/package.json +60 -60
package/README.md
CHANGED
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
<!-- SEO Meta Block — paste this in your Next.js layout.tsx or head -->
|
|
2
|
-
<!--
|
|
3
|
-
title: TweenLabs — Premium Open Source GSAP Component Library for Next.js
|
|
4
|
-
description: A free, open-source GSAP animation component library and UI template sandbox built with Next.js 16, React 19, and Lenis. Learn and build modern web animations with reusable, copy-paste ready components.
|
|
5
|
-
keywords: TweenLabs, GSAP component library, GSAP Next.js, GSAP animations React, open source animation library, web animation components, Lenis smooth scroll, GSAP ScrollTrigger components, Next.js animation library
|
|
6
|
-
-->
|
|
7
|
-
|
|
8
|
-
# <img src="https://raw.githubusercontent.com/TweenLabs/TweenLabs/master/public/logo.svg" alt="TweenLabs Logo" width="40" height="40" align="center" /> TweenLabs
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
> The open-source **GSAP animation component library** for Next.js developers — learn, copy, and contribute modern web animation patterns built with **GSAP 3.15**, **Next.js 16**, and **Lenis**.
|
|
12
|
-
|
|
13
|
-
**[Live Demo](https://tweenlabs.xyz)** • **[Contributing Guide](#contributing)** • **[Roadmap](#roadmap)**
|
|
14
|
-
|
|
15
|
-

|
|
16
|
-

|
|
17
|
-

|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
<!-- [Contributors](https://img.shields.io/github/contributors/TweenLabs/TweenLabs?style=flat-square) -->
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## What is TweenLabs?
|
|
25
|
-
|
|
26
|
-
**TweenLabs** is a community-driven, open-source collection of reusable GSAP animation components for Next.js and React. Every component is production-ready, well-documented, and built to help developers understand *how* advanced web animations work — not just copy code blindly.
|
|
27
|
-
|
|
28
|
-
No paid plugins. No locked content. Just clean, modern animation patterns anyone can learn from and build on.
|
|
29
|
-
|
|
30
|
-
> 🔍 **Looking for a GSAP component library for Next.js?** You found it.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## ✨ Animation Components
|
|
35
|
-
|
|
36
|
-
| Component | Description | GSAP Features Used |
|
|
37
|
-
|-----------|-------------|-------------------|
|
|
38
|
-
| **Gravity Drop** | Physics-based falling animations with realistic bounce | `gsap.to`, `ease`, stagger |
|
|
39
|
-
| **Scroll-Triggered Assemblies** | Content reveals synced with scroll position | ScrollTrigger |
|
|
40
|
-
| **Border Reveal Effects** | Inward/outward border animations | Timeline, `clipPath` |
|
|
41
|
-
| **Horizontal Card Showcase** | Smooth carousel and card transitions | ScrollTrigger, `x` transforms |
|
|
42
|
-
| **Page Transitions** | Seamless route change animations | Timeline, Next.js router |
|
|
43
|
-
| **Smooth Scrolling** | Native-feel smooth scroll | Lenis + GSAP ticker |
|
|
44
|
-
|
|
45
|
-
> More components added with every contribution. [See full list →](https://tweenlabs.xyz)
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## 🛠 Tech Stack
|
|
50
|
-
|
|
51
|
-
- **[Next.js 16](https://nextjs.org/)** – React framework with SSR and App Router
|
|
52
|
-
- **[GSAP 3.15](https://gsap.com/)** – Industry-standard JavaScript animation library
|
|
53
|
-
- **[React 19](https://react.dev/)** – Modern component-based UI
|
|
54
|
-
- **[Lenis 1.3](https://github.com/darkroom-digital/lenis)** – Buttery smooth scroll
|
|
55
|
-
- **[Tailwind CSS 4](https://tailwindcss.com/)** – Utility-first styling
|
|
56
|
-
- **[TypeScript](https://www.typescriptlang.org/)** – Full type safety
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## 🚀 Quick Start
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
# Install pnpm if you don't have it
|
|
64
|
-
npm install -g pnpm
|
|
65
|
-
|
|
66
|
-
# Clone and run
|
|
67
|
-
git clone https://github.com/TweenLabs/TweenLabs.git
|
|
68
|
-
cd TweenLabs
|
|
69
|
-
pnpm install
|
|
70
|
-
pnpm dev
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Open [http://localhost:3000](http://localhost:3000) — pick any animation card and start exploring.
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## 🤝 Contributing
|
|
78
|
-
|
|
79
|
-
TweenLabs grows with the community. We welcome new components, bug fixes, docs, performance improvements, and accessibility enhancements.
|
|
80
|
-
|
|
81
|
-
### Steps
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
# 1. Fork the repo, then clone your fork
|
|
85
|
-
git clone https://github.com/YOUR_USERNAME/TweenLabs.git
|
|
86
|
-
|
|
87
|
-
# 2. Create a branch
|
|
88
|
-
git checkout -b feat/your-animation-name
|
|
89
|
-
|
|
90
|
-
# 3. Install & run
|
|
91
|
-
pnpm install && pnpm dev
|
|
92
|
-
|
|
93
|
-
# 4. Make changes, then commit
|
|
94
|
-
git commit -m "feat: add [animation name]"
|
|
95
|
-
|
|
96
|
-
# 5. Push and open a PR
|
|
97
|
-
git push origin feat/your-animation-name
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Adding a New Component
|
|
101
|
-
|
|
102
|
-
- Follow the folder pattern: `src/app/XX-component-name/`
|
|
103
|
-
- Include a `page.tsx` with your animation
|
|
104
|
-
- Add inline comments explaining the GSAP logic
|
|
105
|
-
- Reference `gsapskills.md` for best practices
|
|
106
|
-
|
|
107
|
-
### Good First Contributions
|
|
108
|
-
|
|
109
|
-
- ✅ Add explanatory comments to existing animations
|
|
110
|
-
- ✅ Test on mobile/tablet and report issues
|
|
111
|
-
- ✅ Create animation variants with different easing curves
|
|
112
|
-
- ✅ Improve accessibility (`prefers-reduced-motion`, ARIA)
|
|
113
|
-
- ✅ Write or improve docs
|
|
114
|
-
|
|
115
|
-
### Code Guidelines
|
|
116
|
-
|
|
117
|
-
- Use CSS transforms (`x`, `y`, `scale`) — never layout properties
|
|
118
|
-
- Always respect `prefers-reduced-motion`
|
|
119
|
-
- TypeScript only — no `any` types
|
|
120
|
-
- Write descriptive commit messages
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## 🗺 Roadmap
|
|
125
|
-
|
|
126
|
-
- [ ] Export as npm package (`@tweenlabs/components`)
|
|
127
|
-
- [ ] Storybook integration for isolated component previews
|
|
128
|
-
- [ ] Unit tests for animation logic
|
|
129
|
-
- [ ] FLIP, Draggable, MorphSVG animation patterns
|
|
130
|
-
- [ ] Community showcase gallery
|
|
131
|
-
- [ ] Animation starter templates for common use cases
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## 📚 Learn More
|
|
136
|
-
|
|
137
|
-
New to GSAP? These resources pair perfectly with this repo:
|
|
138
|
-
|
|
139
|
-
- [GSAP Official Docs](https://gsap.com/docs/) — start here
|
|
140
|
-
- [GSAP + React Guide](https://gsap.com/resources/React/) — useGSAP hook
|
|
141
|
-
- [ScrollTrigger Docs](https://gsap.com/docs/v3/Plugins/ScrollTrigger/) — scroll animations
|
|
142
|
-
- [Next.js Docs](https://nextjs.org/docs) — framework reference
|
|
143
|
-
- [Lenis Docs](https://lenis.studiofreight.com/) — smooth scroll setup
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## 📜 License
|
|
148
|
-
|
|
149
|
-
[MIT](LICENSE) — free to use in personal and commercial projects.
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## 🌟 Contributors
|
|
154
|
-
|
|
155
|
-
Thanks to everyone building this together. ❤️
|
|
156
|
-
|
|
157
|
-
<!-- Add contributor grid here once you have 5+ contributors -->
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
**Built in public. Animated with love. Open to all. 🚀**
|
|
162
|
-
|
|
163
|
-
<!--
|
|
164
|
-
SEARCH TAGS (do not remove — improves GitHub discoverability):
|
|
165
|
-
tweenlabs, gsap animation library, gsap component library, gsap nextjs, gsap react components,
|
|
166
|
-
open source animation, web animation components, lenis smooth scroll, scrolltrigger examples,
|
|
167
|
-
next.js animation, gsap copy paste components, gsap learning, gsap playground
|
|
168
|
-
-->
|
|
1
|
+
<!-- SEO Meta Block — paste this in your Next.js layout.tsx or head -->
|
|
2
|
+
<!--
|
|
3
|
+
title: TweenLabs — Premium Open Source GSAP Component Library for Next.js
|
|
4
|
+
description: A free, open-source GSAP animation component library and UI template sandbox built with Next.js 16, React 19, and Lenis. Learn and build modern web animations with reusable, copy-paste ready components.
|
|
5
|
+
keywords: TweenLabs, GSAP component library, GSAP Next.js, GSAP animations React, open source animation library, web animation components, Lenis smooth scroll, GSAP ScrollTrigger components, Next.js animation library
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
# <img src="https://raw.githubusercontent.com/TweenLabs/TweenLabs/master/public/logo.svg" alt="TweenLabs Logo" width="40" height="40" align="center" /> TweenLabs
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
> The open-source **GSAP animation component library** for Next.js developers — learn, copy, and contribute modern web animation patterns built with **GSAP 3.15**, **Next.js 16**, and **Lenis**.
|
|
12
|
+
|
|
13
|
+
**[Live Demo](https://tweenlabs.xyz)** • **[Contributing Guide](#contributing)** • **[Roadmap](#roadmap)**
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
<!-- [Contributors](https://img.shields.io/github/contributors/TweenLabs/TweenLabs?style=flat-square) -->
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## What is TweenLabs?
|
|
25
|
+
|
|
26
|
+
**TweenLabs** is a community-driven, open-source collection of reusable GSAP animation components for Next.js and React. Every component is production-ready, well-documented, and built to help developers understand *how* advanced web animations work — not just copy code blindly.
|
|
27
|
+
|
|
28
|
+
No paid plugins. No locked content. Just clean, modern animation patterns anyone can learn from and build on.
|
|
29
|
+
|
|
30
|
+
> 🔍 **Looking for a GSAP component library for Next.js?** You found it.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## ✨ Animation Components
|
|
35
|
+
|
|
36
|
+
| Component | Description | GSAP Features Used |
|
|
37
|
+
|-----------|-------------|-------------------|
|
|
38
|
+
| **Gravity Drop** | Physics-based falling animations with realistic bounce | `gsap.to`, `ease`, stagger |
|
|
39
|
+
| **Scroll-Triggered Assemblies** | Content reveals synced with scroll position | ScrollTrigger |
|
|
40
|
+
| **Border Reveal Effects** | Inward/outward border animations | Timeline, `clipPath` |
|
|
41
|
+
| **Horizontal Card Showcase** | Smooth carousel and card transitions | ScrollTrigger, `x` transforms |
|
|
42
|
+
| **Page Transitions** | Seamless route change animations | Timeline, Next.js router |
|
|
43
|
+
| **Smooth Scrolling** | Native-feel smooth scroll | Lenis + GSAP ticker |
|
|
44
|
+
|
|
45
|
+
> More components added with every contribution. [See full list →](https://tweenlabs.xyz)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🛠 Tech Stack
|
|
50
|
+
|
|
51
|
+
- **[Next.js 16](https://nextjs.org/)** – React framework with SSR and App Router
|
|
52
|
+
- **[GSAP 3.15](https://gsap.com/)** – Industry-standard JavaScript animation library
|
|
53
|
+
- **[React 19](https://react.dev/)** – Modern component-based UI
|
|
54
|
+
- **[Lenis 1.3](https://github.com/darkroom-digital/lenis)** – Buttery smooth scroll
|
|
55
|
+
- **[Tailwind CSS 4](https://tailwindcss.com/)** – Utility-first styling
|
|
56
|
+
- **[TypeScript](https://www.typescriptlang.org/)** – Full type safety
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🚀 Quick Start
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Install pnpm if you don't have it
|
|
64
|
+
npm install -g pnpm
|
|
65
|
+
|
|
66
|
+
# Clone and run
|
|
67
|
+
git clone https://github.com/TweenLabs/TweenLabs.git
|
|
68
|
+
cd TweenLabs
|
|
69
|
+
pnpm install
|
|
70
|
+
pnpm dev
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Open [http://localhost:3000](http://localhost:3000) — pick any animation card and start exploring.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 🤝 Contributing
|
|
78
|
+
|
|
79
|
+
TweenLabs grows with the community. We welcome new components, bug fixes, docs, performance improvements, and accessibility enhancements.
|
|
80
|
+
|
|
81
|
+
### Steps
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# 1. Fork the repo, then clone your fork
|
|
85
|
+
git clone https://github.com/YOUR_USERNAME/TweenLabs.git
|
|
86
|
+
|
|
87
|
+
# 2. Create a branch
|
|
88
|
+
git checkout -b feat/your-animation-name
|
|
89
|
+
|
|
90
|
+
# 3. Install & run
|
|
91
|
+
pnpm install && pnpm dev
|
|
92
|
+
|
|
93
|
+
# 4. Make changes, then commit
|
|
94
|
+
git commit -m "feat: add [animation name]"
|
|
95
|
+
|
|
96
|
+
# 5. Push and open a PR
|
|
97
|
+
git push origin feat/your-animation-name
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Adding a New Component
|
|
101
|
+
|
|
102
|
+
- Follow the folder pattern: `src/app/XX-component-name/`
|
|
103
|
+
- Include a `page.tsx` with your animation
|
|
104
|
+
- Add inline comments explaining the GSAP logic
|
|
105
|
+
- Reference `gsapskills.md` for best practices
|
|
106
|
+
|
|
107
|
+
### Good First Contributions
|
|
108
|
+
|
|
109
|
+
- ✅ Add explanatory comments to existing animations
|
|
110
|
+
- ✅ Test on mobile/tablet and report issues
|
|
111
|
+
- ✅ Create animation variants with different easing curves
|
|
112
|
+
- ✅ Improve accessibility (`prefers-reduced-motion`, ARIA)
|
|
113
|
+
- ✅ Write or improve docs
|
|
114
|
+
|
|
115
|
+
### Code Guidelines
|
|
116
|
+
|
|
117
|
+
- Use CSS transforms (`x`, `y`, `scale`) — never layout properties
|
|
118
|
+
- Always respect `prefers-reduced-motion`
|
|
119
|
+
- TypeScript only — no `any` types
|
|
120
|
+
- Write descriptive commit messages
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🗺 Roadmap
|
|
125
|
+
|
|
126
|
+
- [ ] Export as npm package (`@tweenlabs/components`)
|
|
127
|
+
- [ ] Storybook integration for isolated component previews
|
|
128
|
+
- [ ] Unit tests for animation logic
|
|
129
|
+
- [ ] FLIP, Draggable, MorphSVG animation patterns
|
|
130
|
+
- [ ] Community showcase gallery
|
|
131
|
+
- [ ] Animation starter templates for common use cases
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 📚 Learn More
|
|
136
|
+
|
|
137
|
+
New to GSAP? These resources pair perfectly with this repo:
|
|
138
|
+
|
|
139
|
+
- [GSAP Official Docs](https://gsap.com/docs/) — start here
|
|
140
|
+
- [GSAP + React Guide](https://gsap.com/resources/React/) — useGSAP hook
|
|
141
|
+
- [ScrollTrigger Docs](https://gsap.com/docs/v3/Plugins/ScrollTrigger/) — scroll animations
|
|
142
|
+
- [Next.js Docs](https://nextjs.org/docs) — framework reference
|
|
143
|
+
- [Lenis Docs](https://lenis.studiofreight.com/) — smooth scroll setup
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 📜 License
|
|
148
|
+
|
|
149
|
+
[MIT](LICENSE) — free to use in personal and commercial projects.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 🌟 Contributors
|
|
154
|
+
|
|
155
|
+
Thanks to everyone building this together. ❤️
|
|
156
|
+
|
|
157
|
+
<!-- Add contributor grid here once you have 5+ contributors -->
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
**Built in public. Animated with love. Open to all. 🚀**
|
|
162
|
+
|
|
163
|
+
<!--
|
|
164
|
+
SEARCH TAGS (do not remove — improves GitHub discoverability):
|
|
165
|
+
tweenlabs, gsap animation library, gsap component library, gsap nextjs, gsap react components,
|
|
166
|
+
open source animation, web animation components, lenis smooth scroll, scrolltrigger examples,
|
|
167
|
+
next.js animation, gsap copy paste components, gsap learning, gsap playground
|
|
168
|
+
-->
|
package/bin/cli.js
CHANGED
|
@@ -95,16 +95,22 @@ async function main() {
|
|
|
95
95
|
process.exit(0);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
let version = "0.1.4";
|
|
99
|
+
try {
|
|
100
|
+
const pkg = require("../package.json");
|
|
101
|
+
version = pkg.version;
|
|
102
|
+
} catch (_e) {}
|
|
103
|
+
|
|
98
104
|
if (args.includes("--version") || args.includes("-v")) {
|
|
99
|
-
|
|
100
|
-
const pkg = require("../package.json");
|
|
101
|
-
console.log(pkg.version);
|
|
102
|
-
} catch (_err) {
|
|
103
|
-
console.log("0.1.1");
|
|
104
|
-
}
|
|
105
|
+
console.log(version);
|
|
105
106
|
process.exit(0);
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
// Print CLI Header Banner
|
|
110
|
+
console.log(
|
|
111
|
+
`\n${colors.bold}${colors.cyan}▲ tweenlabs${colors.reset} ${colors.gray}v${version}${colors.reset}\n`,
|
|
112
|
+
);
|
|
113
|
+
|
|
108
114
|
// Parse flags
|
|
109
115
|
const isYes = args.includes("-y") || args.includes("--yes");
|
|
110
116
|
const isOverwrite = args.includes("-o") || args.includes("--overwrite");
|
|
@@ -140,28 +146,31 @@ async function main() {
|
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
if (cleanArgs[0] === "list") {
|
|
143
|
-
console.log(
|
|
144
|
-
`\n${colors.cyan}🔍 Fetching available components list...${colors.reset}`,
|
|
145
|
-
);
|
|
149
|
+
console.log(`${colors.cyan}🔍 Fetching registry...${colors.reset}`);
|
|
146
150
|
const domain =
|
|
147
151
|
process.env.TWEENLABS_REGISTRY_URL || "https://tweenlabs.xyz";
|
|
148
152
|
const url = `${domain}/api/registry/list`;
|
|
149
153
|
try {
|
|
150
154
|
const data = await fetchJson(url);
|
|
151
155
|
console.log(
|
|
152
|
-
`\n${colors.bold}${colors.green}Available
|
|
156
|
+
`\n${colors.bold}${colors.green}Available Components:${colors.reset}\n`,
|
|
153
157
|
);
|
|
154
|
-
|
|
158
|
+
const rows = data.components.map((comp) => ({
|
|
159
|
+
slug: comp.cleanSlug || comp.slug,
|
|
160
|
+
desc: comp.description || "",
|
|
161
|
+
}));
|
|
162
|
+
const maxSlugLen = Math.max(...rows.map((r) => r.slug.length), 10);
|
|
163
|
+
for (const row of rows) {
|
|
164
|
+
const paddedSlug = row.slug.padEnd(maxSlugLen + 4, " ");
|
|
155
165
|
console.log(
|
|
156
|
-
` ${colors.
|
|
166
|
+
` ${colors.cyan}${paddedSlug}${colors.reset}${colors.gray}${row.desc}${colors.reset}`,
|
|
157
167
|
);
|
|
158
|
-
console.log(` Slug: ${comp.slug} (or ${comp.cleanSlug})`);
|
|
159
|
-
console.log(` Desc: ${comp.description}\n`);
|
|
160
168
|
}
|
|
169
|
+
console.log("");
|
|
161
170
|
process.exit(0);
|
|
162
171
|
} catch (err) {
|
|
163
172
|
console.error(
|
|
164
|
-
|
|
173
|
+
`${colors.red}❌ Failed to fetch components list.${colors.reset}`,
|
|
165
174
|
);
|
|
166
175
|
console.error(`${colors.gray}Details: ${err.message}${colors.reset}`);
|
|
167
176
|
process.exit(1);
|
|
@@ -176,41 +185,68 @@ async function main() {
|
|
|
176
185
|
process.exit(1);
|
|
177
186
|
}
|
|
178
187
|
|
|
179
|
-
|
|
188
|
+
let componentSlug = cleanArgs[1];
|
|
180
189
|
if (!componentSlug) {
|
|
190
|
+
console.log(`${colors.cyan}🔍 Fetching registry...${colors.reset}`);
|
|
191
|
+
const domain =
|
|
192
|
+
process.env.TWEENLABS_REGISTRY_URL || "https://tweenlabs.xyz";
|
|
193
|
+
const listUrl = `${domain}/api/registry/list`;
|
|
194
|
+
let listData;
|
|
195
|
+
try {
|
|
196
|
+
listData = await fetchJson(listUrl);
|
|
197
|
+
} catch (err) {
|
|
198
|
+
console.error(
|
|
199
|
+
`${colors.red}❌ Failed to fetch components list.${colors.reset}`,
|
|
200
|
+
);
|
|
201
|
+
console.error(`${colors.gray}Details: ${err.message}${colors.reset}`);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
181
205
|
console.log(
|
|
182
|
-
`${colors.
|
|
206
|
+
`${colors.bold}${colors.green}Select a component to install:${colors.reset}\n`,
|
|
183
207
|
);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
208
|
+
const components = listData.components;
|
|
209
|
+
const maxIndexLen = String(components.length + 1).length;
|
|
210
|
+
const maxSlugLen = Math.max(
|
|
211
|
+
...components.map((c) => (c.cleanSlug || c.slug).length),
|
|
212
|
+
10,
|
|
188
213
|
);
|
|
189
|
-
process.exit(1);
|
|
190
|
-
}
|
|
191
214
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
// Print "All Components" option first
|
|
216
|
+
const allIndexStr = "[1]".padStart(maxIndexLen + 2, " ");
|
|
217
|
+
const allSlugStr = ".".padEnd(maxSlugLen + 4, " ");
|
|
218
|
+
console.log(
|
|
219
|
+
` ${colors.bold}${colors.cyan}${allIndexStr}${colors.reset} ${colors.cyan}${allSlugStr}${colors.reset}${colors.gray}All Components${colors.reset}`,
|
|
220
|
+
);
|
|
195
221
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
for (let i = 0; i < components.length; i++) {
|
|
223
|
+
const indexStr = `[${i + 2}]`.padStart(maxIndexLen + 2, " ");
|
|
224
|
+
const slugStr = (components[i].cleanSlug || components[i].slug).padEnd(
|
|
225
|
+
maxSlugLen + 4,
|
|
226
|
+
" ",
|
|
227
|
+
);
|
|
228
|
+
console.log(
|
|
229
|
+
` ${colors.bold}${colors.cyan}${indexStr}${colors.reset} ${colors.cyan}${slugStr}${colors.reset}${colors.gray}${components[i].name}${colors.reset}`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
console.log("");
|
|
199
233
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
componentData = await fetchJson(url);
|
|
203
|
-
} catch (err) {
|
|
204
|
-
console.error(
|
|
205
|
-
`\n${colors.red}❌ Failed to fetch component. Make sure the slug is correct and the server is running.${colors.reset}`,
|
|
234
|
+
const choiceStr = await askQuestion(
|
|
235
|
+
`👉 Enter the number of the component to add (1-${components.length + 1}): `,
|
|
206
236
|
);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
237
|
+
const choice = parseInt(choiceStr, 10);
|
|
238
|
+
if (Number.isNaN(choice) || choice < 1 || choice > components.length + 1) {
|
|
239
|
+
console.log(`${colors.red}❌ Invalid choice. Exiting.${colors.reset}`);
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
210
242
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
243
|
+
if (choice === 1) {
|
|
244
|
+
componentSlug = ".";
|
|
245
|
+
} else {
|
|
246
|
+
componentSlug =
|
|
247
|
+
components[choice - 2].cleanSlug || components[choice - 2].slug;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
214
250
|
|
|
215
251
|
// Resolve target directory
|
|
216
252
|
let targetDir = "";
|
|
@@ -258,26 +294,78 @@ async function main() {
|
|
|
258
294
|
`📁 Target directory: ${colors.bold}${path.relative(process.cwd(), targetDir)}${colors.reset}`,
|
|
259
295
|
);
|
|
260
296
|
|
|
261
|
-
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
297
|
+
const domain = process.env.TWEENLABS_REGISTRY_URL || "https://tweenlabs.xyz";
|
|
298
|
+
let slugsToInstall = [];
|
|
299
|
+
if (componentSlug === "." || componentSlug === "all") {
|
|
300
|
+
console.log(
|
|
301
|
+
`${colors.cyan}🔍 Fetching all components list...${colors.reset}`,
|
|
302
|
+
);
|
|
303
|
+
const listUrl = `${domain}/api/registry/list`;
|
|
304
|
+
try {
|
|
305
|
+
const listData = await fetchJson(listUrl);
|
|
306
|
+
slugsToInstall = listData.components.map((c) => c.cleanSlug || c.slug);
|
|
307
|
+
} catch (err) {
|
|
308
|
+
console.error(
|
|
309
|
+
`${colors.red}❌ Failed to fetch components list.${colors.reset}`,
|
|
310
|
+
);
|
|
311
|
+
console.error(`${colors.gray}Details: ${err.message}${colors.reset}`);
|
|
312
|
+
process.exit(1);
|
|
268
313
|
}
|
|
314
|
+
} else {
|
|
315
|
+
slugsToInstall = [componentSlug];
|
|
269
316
|
}
|
|
270
317
|
|
|
271
|
-
|
|
318
|
+
// Gather files and check conflicts
|
|
319
|
+
const filesToWrite = [];
|
|
320
|
+
const conflicts = [];
|
|
321
|
+
const allRequiredDeps = new Set();
|
|
322
|
+
|
|
323
|
+
for (const slug of slugsToInstall) {
|
|
324
|
+
console.log(
|
|
325
|
+
`${colors.cyan}🔍 Fetching ${colors.bold}${slug}${colors.reset}${colors.cyan} registry data...${colors.reset}`,
|
|
326
|
+
);
|
|
327
|
+
const url = `${domain}/api/registry/${slug}`;
|
|
328
|
+
try {
|
|
329
|
+
const componentData = await fetchJson(url);
|
|
330
|
+
for (const file of componentData.files) {
|
|
331
|
+
const filePath = path.join(targetDir, file.name);
|
|
332
|
+
if (fs.existsSync(filePath)) {
|
|
333
|
+
conflicts.push(path.relative(process.cwd(), filePath));
|
|
334
|
+
}
|
|
335
|
+
filesToWrite.push({ path: filePath, content: file.content });
|
|
336
|
+
}
|
|
337
|
+
const dependencies = componentData.dependencies || [];
|
|
338
|
+
for (const dep of dependencies) {
|
|
339
|
+
allRequiredDeps.add(dep);
|
|
340
|
+
}
|
|
341
|
+
} catch (_err) {
|
|
342
|
+
console.error(
|
|
343
|
+
`${colors.red}❌ Failed to fetch component ${slug}. Skipping.${colors.reset}`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (filesToWrite.length === 0) {
|
|
349
|
+
console.log(`${colors.red}❌ No files to install. Exiting.${colors.reset}`);
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (conflicts.length > 0 && !isOverwrite && !isYes) {
|
|
354
|
+
console.log(
|
|
355
|
+
`\n${colors.yellow}⚠️ The following files already exist:${colors.reset}`,
|
|
356
|
+
);
|
|
357
|
+
for (const conflict of conflicts) {
|
|
358
|
+
console.log(` → ${conflict}`);
|
|
359
|
+
}
|
|
272
360
|
const overwriteConfirm = await askQuestion(
|
|
273
|
-
|
|
361
|
+
`\nOverwrite these files? (y/n) ${colors.gray}[y]${colors.reset}: `,
|
|
274
362
|
);
|
|
275
363
|
if (
|
|
276
364
|
overwriteConfirm &&
|
|
277
365
|
overwriteConfirm.toLowerCase() !== "y" &&
|
|
278
366
|
overwriteConfirm.toLowerCase() !== "yes"
|
|
279
367
|
) {
|
|
280
|
-
console.log(`${colors.yellow}Installation cancelled.${colors.reset}`);
|
|
368
|
+
console.log(`${colors.yellow}⚠ Installation cancelled.${colors.reset}`);
|
|
281
369
|
process.exit(0);
|
|
282
370
|
}
|
|
283
371
|
}
|
|
@@ -288,19 +376,17 @@ async function main() {
|
|
|
288
376
|
}
|
|
289
377
|
|
|
290
378
|
// Write component files
|
|
291
|
-
console.log(`\n${colors.
|
|
292
|
-
for (const file of
|
|
293
|
-
|
|
294
|
-
fs.writeFileSync(filePath, file.content, "utf-8");
|
|
379
|
+
console.log(`\n${colors.bold}💾 Writing component files...${colors.reset}`);
|
|
380
|
+
for (const file of filesToWrite) {
|
|
381
|
+
fs.writeFileSync(file.path, file.content, "utf-8");
|
|
295
382
|
console.log(
|
|
296
|
-
|
|
383
|
+
` ${colors.green}✔${colors.reset} Created ${colors.bold}${path.relative(process.cwd(), file.path)}${colors.reset}`,
|
|
297
384
|
);
|
|
298
385
|
}
|
|
299
386
|
|
|
300
387
|
// Check and install dependencies
|
|
301
|
-
const dependencies =
|
|
388
|
+
const dependencies = Array.from(allRequiredDeps);
|
|
302
389
|
if (dependencies.length > 0) {
|
|
303
|
-
// Read package.json to see if dependencies are already installed
|
|
304
390
|
let pkgJson = {};
|
|
305
391
|
try {
|
|
306
392
|
pkgJson = JSON.parse(
|
|
@@ -316,8 +402,12 @@ async function main() {
|
|
|
316
402
|
if (missingDeps.length > 0) {
|
|
317
403
|
const pm = detectPackageManager();
|
|
318
404
|
console.log(
|
|
319
|
-
`\n${colors.
|
|
405
|
+
`\n${colors.bold}📦 Installing missing dependencies using ${pm}...${colors.reset}`,
|
|
320
406
|
);
|
|
407
|
+
for (const dep of missingDeps) {
|
|
408
|
+
console.log(` → ${dep}`);
|
|
409
|
+
}
|
|
410
|
+
console.log("");
|
|
321
411
|
|
|
322
412
|
let installCmd = "";
|
|
323
413
|
if (pm === "pnpm") installCmd = `pnpm add ${missingDeps.join(" ")}`;
|
|
@@ -328,26 +418,24 @@ async function main() {
|
|
|
328
418
|
try {
|
|
329
419
|
execSync(installCmd, { stdio: "inherit" });
|
|
330
420
|
console.log(
|
|
331
|
-
|
|
421
|
+
`\n${colors.green}✔ Dependencies installed successfully!${colors.reset}`,
|
|
332
422
|
);
|
|
333
423
|
} catch (_err) {
|
|
334
424
|
console.error(
|
|
335
|
-
|
|
425
|
+
`\n${colors.red}❌ Failed to install dependencies. Please run "${installCmd}" manually.${colors.reset}`,
|
|
336
426
|
);
|
|
337
427
|
}
|
|
338
428
|
} else {
|
|
339
429
|
console.log(
|
|
340
|
-
`\n${colors.green}
|
|
430
|
+
`\n${colors.green}✔ All dependencies (${dependencies.join(", ")}) already installed.${colors.reset}`,
|
|
341
431
|
);
|
|
342
432
|
}
|
|
343
433
|
}
|
|
344
434
|
|
|
345
435
|
console.log(
|
|
346
|
-
`\n${colors.
|
|
347
|
-
);
|
|
348
|
-
console.log(
|
|
349
|
-
`You can now import and use the ${colors.bold}${componentData.className}${colors.reset} component in your project.\n`,
|
|
436
|
+
`\n${colors.bold}${colors.green}🎉 Done! All requested components installed successfully.${colors.reset}`,
|
|
350
437
|
);
|
|
438
|
+
console.log(`You can now import and use them in your project.\n`);
|
|
351
439
|
}
|
|
352
440
|
|
|
353
441
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tweenlabs",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/TweenLabs/TweenLabs.git"
|
|
8
|
-
},
|
|
9
|
-
"homepage": "https://tweenlabs.xyz",
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/TweenLabs/TweenLabs/issues"
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"tweenlabs": "bin/cli.js"
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"bin",
|
|
18
|
-
"README.md",
|
|
19
|
-
"LICENSE"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"dev": "next dev",
|
|
23
|
-
"build": "node scripts/generate-llms-full.js && next build",
|
|
24
|
-
"vercel-build": "convex deploy --cmd \"node scripts/generate-llms-full.js && next build\"",
|
|
25
|
-
"start": "next start",
|
|
26
|
-
"lint": "eslint"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@convex-dev/better-auth": "^0.12.4",
|
|
30
|
-
"@gsap/react": "^2.1.2",
|
|
31
|
-
"better-auth": "^1.6.19",
|
|
32
|
-
"convex": "^1.41.0",
|
|
33
|
-
"gsap": "^3.15.0",
|
|
34
|
-
"lenis": "^1.3.23",
|
|
35
|
-
"next": "16.2.7",
|
|
36
|
-
"react": "19.2.4",
|
|
37
|
-
"react-dom": "19.2.4"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@biomejs/biome": "^2.5.0",
|
|
41
|
-
"@tailwindcss/postcss": "^4",
|
|
42
|
-
"@types/node": "^20",
|
|
43
|
-
"@types/react": "^19",
|
|
44
|
-
"@types/react-dom": "^19",
|
|
45
|
-
"eslint": "^9",
|
|
46
|
-
"eslint-config-next": "16.2.7",
|
|
47
|
-
"sharp": "^0.35.1",
|
|
48
|
-
"tailwindcss": "^4",
|
|
49
|
-
"typescript": "^5"
|
|
50
|
-
},
|
|
51
|
-
"pnpm": {
|
|
52
|
-
"ignoredBuiltDependencies": [
|
|
53
|
-
"sharp",
|
|
54
|
-
"unrs-resolver"
|
|
55
|
-
],
|
|
56
|
-
"overrides": {
|
|
57
|
-
"postcss": "^8.5.10"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tweenlabs",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/TweenLabs/TweenLabs.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://tweenlabs.xyz",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/TweenLabs/TweenLabs/issues"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"tweenlabs": "bin/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "next dev",
|
|
23
|
+
"build": "node scripts/generate-llms-full.js && next build",
|
|
24
|
+
"vercel-build": "convex deploy --cmd \"node scripts/generate-llms-full.js && next build\"",
|
|
25
|
+
"start": "next start",
|
|
26
|
+
"lint": "eslint"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@convex-dev/better-auth": "^0.12.4",
|
|
30
|
+
"@gsap/react": "^2.1.2",
|
|
31
|
+
"better-auth": "^1.6.19",
|
|
32
|
+
"convex": "^1.41.0",
|
|
33
|
+
"gsap": "^3.15.0",
|
|
34
|
+
"lenis": "^1.3.23",
|
|
35
|
+
"next": "16.2.7",
|
|
36
|
+
"react": "19.2.4",
|
|
37
|
+
"react-dom": "19.2.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@biomejs/biome": "^2.5.0",
|
|
41
|
+
"@tailwindcss/postcss": "^4",
|
|
42
|
+
"@types/node": "^20",
|
|
43
|
+
"@types/react": "^19",
|
|
44
|
+
"@types/react-dom": "^19",
|
|
45
|
+
"eslint": "^9",
|
|
46
|
+
"eslint-config-next": "16.2.7",
|
|
47
|
+
"sharp": "^0.35.1",
|
|
48
|
+
"tailwindcss": "^4",
|
|
49
|
+
"typescript": "^5"
|
|
50
|
+
},
|
|
51
|
+
"pnpm": {
|
|
52
|
+
"ignoredBuiltDependencies": [
|
|
53
|
+
"sharp",
|
|
54
|
+
"unrs-resolver"
|
|
55
|
+
],
|
|
56
|
+
"overrides": {
|
|
57
|
+
"postcss": "^8.5.10"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|