tweenlabs 0.1.2 → 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 -61
- 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,11 +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
|
-
console.log(
|
|
105
|
+
console.log(version);
|
|
100
106
|
process.exit(0);
|
|
101
107
|
}
|
|
102
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
|
+
|
|
103
114
|
// Parse flags
|
|
104
115
|
const isYes = args.includes("-y") || args.includes("--yes");
|
|
105
116
|
const isOverwrite = args.includes("-o") || args.includes("--overwrite");
|
|
@@ -135,28 +146,31 @@ async function main() {
|
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
if (cleanArgs[0] === "list") {
|
|
138
|
-
console.log(
|
|
139
|
-
`\n${colors.cyan}🔍 Fetching available components list...${colors.reset}`,
|
|
140
|
-
);
|
|
149
|
+
console.log(`${colors.cyan}🔍 Fetching registry...${colors.reset}`);
|
|
141
150
|
const domain =
|
|
142
151
|
process.env.TWEENLABS_REGISTRY_URL || "https://tweenlabs.xyz";
|
|
143
152
|
const url = `${domain}/api/registry/list`;
|
|
144
153
|
try {
|
|
145
154
|
const data = await fetchJson(url);
|
|
146
155
|
console.log(
|
|
147
|
-
`\n${colors.bold}${colors.green}Available
|
|
156
|
+
`\n${colors.bold}${colors.green}Available Components:${colors.reset}\n`,
|
|
148
157
|
);
|
|
149
|
-
|
|
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, " ");
|
|
150
165
|
console.log(
|
|
151
|
-
` ${colors.
|
|
166
|
+
` ${colors.cyan}${paddedSlug}${colors.reset}${colors.gray}${row.desc}${colors.reset}`,
|
|
152
167
|
);
|
|
153
|
-
console.log(` Slug: ${comp.slug} (or ${comp.cleanSlug})`);
|
|
154
|
-
console.log(` Desc: ${comp.description}\n`);
|
|
155
168
|
}
|
|
169
|
+
console.log("");
|
|
156
170
|
process.exit(0);
|
|
157
171
|
} catch (err) {
|
|
158
172
|
console.error(
|
|
159
|
-
|
|
173
|
+
`${colors.red}❌ Failed to fetch components list.${colors.reset}`,
|
|
160
174
|
);
|
|
161
175
|
console.error(`${colors.gray}Details: ${err.message}${colors.reset}`);
|
|
162
176
|
process.exit(1);
|
|
@@ -171,41 +185,68 @@ async function main() {
|
|
|
171
185
|
process.exit(1);
|
|
172
186
|
}
|
|
173
187
|
|
|
174
|
-
|
|
188
|
+
let componentSlug = cleanArgs[1];
|
|
175
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
|
+
|
|
176
205
|
console.log(
|
|
177
|
-
`${colors.
|
|
206
|
+
`${colors.bold}${colors.green}Select a component to install:${colors.reset}\n`,
|
|
178
207
|
);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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,
|
|
183
213
|
);
|
|
184
|
-
process.exit(1);
|
|
185
|
-
}
|
|
186
214
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
);
|
|
190
221
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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("");
|
|
194
233
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
componentData = await fetchJson(url);
|
|
198
|
-
} catch (err) {
|
|
199
|
-
console.error(
|
|
200
|
-
`\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}): `,
|
|
201
236
|
);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
+
}
|
|
205
242
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
243
|
+
if (choice === 1) {
|
|
244
|
+
componentSlug = ".";
|
|
245
|
+
} else {
|
|
246
|
+
componentSlug =
|
|
247
|
+
components[choice - 2].cleanSlug || components[choice - 2].slug;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
209
250
|
|
|
210
251
|
// Resolve target directory
|
|
211
252
|
let targetDir = "";
|
|
@@ -253,26 +294,78 @@ async function main() {
|
|
|
253
294
|
`📁 Target directory: ${colors.bold}${path.relative(process.cwd(), targetDir)}${colors.reset}`,
|
|
254
295
|
);
|
|
255
296
|
|
|
256
|
-
|
|
257
|
-
let
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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);
|
|
263
313
|
}
|
|
314
|
+
} else {
|
|
315
|
+
slugsToInstall = [componentSlug];
|
|
264
316
|
}
|
|
265
317
|
|
|
266
|
-
|
|
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
|
+
}
|
|
267
360
|
const overwriteConfirm = await askQuestion(
|
|
268
|
-
|
|
361
|
+
`\nOverwrite these files? (y/n) ${colors.gray}[y]${colors.reset}: `,
|
|
269
362
|
);
|
|
270
363
|
if (
|
|
271
364
|
overwriteConfirm &&
|
|
272
365
|
overwriteConfirm.toLowerCase() !== "y" &&
|
|
273
366
|
overwriteConfirm.toLowerCase() !== "yes"
|
|
274
367
|
) {
|
|
275
|
-
console.log(`${colors.yellow}Installation cancelled.${colors.reset}`);
|
|
368
|
+
console.log(`${colors.yellow}⚠ Installation cancelled.${colors.reset}`);
|
|
276
369
|
process.exit(0);
|
|
277
370
|
}
|
|
278
371
|
}
|
|
@@ -283,19 +376,17 @@ async function main() {
|
|
|
283
376
|
}
|
|
284
377
|
|
|
285
378
|
// Write component files
|
|
286
|
-
console.log(`\n${colors.
|
|
287
|
-
for (const file of
|
|
288
|
-
|
|
289
|
-
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");
|
|
290
382
|
console.log(
|
|
291
|
-
|
|
383
|
+
` ${colors.green}✔${colors.reset} Created ${colors.bold}${path.relative(process.cwd(), file.path)}${colors.reset}`,
|
|
292
384
|
);
|
|
293
385
|
}
|
|
294
386
|
|
|
295
387
|
// Check and install dependencies
|
|
296
|
-
const dependencies =
|
|
388
|
+
const dependencies = Array.from(allRequiredDeps);
|
|
297
389
|
if (dependencies.length > 0) {
|
|
298
|
-
// Read package.json to see if dependencies are already installed
|
|
299
390
|
let pkgJson = {};
|
|
300
391
|
try {
|
|
301
392
|
pkgJson = JSON.parse(
|
|
@@ -311,8 +402,12 @@ async function main() {
|
|
|
311
402
|
if (missingDeps.length > 0) {
|
|
312
403
|
const pm = detectPackageManager();
|
|
313
404
|
console.log(
|
|
314
|
-
`\n${colors.
|
|
405
|
+
`\n${colors.bold}📦 Installing missing dependencies using ${pm}...${colors.reset}`,
|
|
315
406
|
);
|
|
407
|
+
for (const dep of missingDeps) {
|
|
408
|
+
console.log(` → ${dep}`);
|
|
409
|
+
}
|
|
410
|
+
console.log("");
|
|
316
411
|
|
|
317
412
|
let installCmd = "";
|
|
318
413
|
if (pm === "pnpm") installCmd = `pnpm add ${missingDeps.join(" ")}`;
|
|
@@ -323,26 +418,24 @@ async function main() {
|
|
|
323
418
|
try {
|
|
324
419
|
execSync(installCmd, { stdio: "inherit" });
|
|
325
420
|
console.log(
|
|
326
|
-
|
|
421
|
+
`\n${colors.green}✔ Dependencies installed successfully!${colors.reset}`,
|
|
327
422
|
);
|
|
328
423
|
} catch (_err) {
|
|
329
424
|
console.error(
|
|
330
|
-
|
|
425
|
+
`\n${colors.red}❌ Failed to install dependencies. Please run "${installCmd}" manually.${colors.reset}`,
|
|
331
426
|
);
|
|
332
427
|
}
|
|
333
428
|
} else {
|
|
334
429
|
console.log(
|
|
335
|
-
`\n${colors.green}
|
|
430
|
+
`\n${colors.green}✔ All dependencies (${dependencies.join(", ")}) already installed.${colors.reset}`,
|
|
336
431
|
);
|
|
337
432
|
}
|
|
338
433
|
}
|
|
339
434
|
|
|
340
435
|
console.log(
|
|
341
|
-
`\n${colors.
|
|
342
|
-
);
|
|
343
|
-
console.log(
|
|
344
|
-
`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}`,
|
|
345
437
|
);
|
|
438
|
+
console.log(`You can now import and use them in your project.\n`);
|
|
346
439
|
}
|
|
347
440
|
|
|
348
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
|
+
}
|