loopwind 0.9.1

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.
Files changed (245) hide show
  1. package/FONTS.md +156 -0
  2. package/HELPERS_DEMO.md +134 -0
  3. package/PROJECT_STRUCTURE.md +286 -0
  4. package/PUBLISHING.md +171 -0
  5. package/README.md +1020 -0
  6. package/REGISTRY_SETUP.md +427 -0
  7. package/SHADCN_INTEGRATION.md +269 -0
  8. package/TAILWIND.md +228 -0
  9. package/TEMPLATE_SOURCES.md +363 -0
  10. package/_dsgn/templates/banner-hero/banner-hero.tsx +57 -0
  11. package/_dsgn/templates/banner-hero/meta.json +14 -0
  12. package/_dsgn/templates/composite-card/meta.json +16 -0
  13. package/_dsgn/templates/composite-card/template.tsx +44 -0
  14. package/_dsgn/templates/image/meta.json +13 -0
  15. package/_dsgn/templates/image/template.tsx +28 -0
  16. package/_dsgn/templates/kitchen-sink/meta.json +13 -0
  17. package/_dsgn/templates/kitchen-sink/template.tsx +72 -0
  18. package/_dsgn/templates/qr-card/meta.json +14 -0
  19. package/_dsgn/templates/qr-card/template.tsx +39 -0
  20. package/_dsgn/templates/test-parent/child/meta.json +11 -0
  21. package/_dsgn/templates/test-parent/child/template.tsx +27 -0
  22. package/_dsgn/templates/test-parent/meta.json +12 -0
  23. package/_dsgn/templates/test-parent/template.tsx +30 -0
  24. package/_dsgn/templates/test-sibling/meta.json +11 -0
  25. package/_dsgn/templates/test-sibling/template.tsx +20 -0
  26. package/_dsgn/templates/video/.tmp/template-1763421345296.mjs +43 -0
  27. package/_dsgn/templates/video/.tmp/template-1763421362228.mjs +43 -0
  28. package/_dsgn/templates/video/.tmp/template-1763421377706.mjs +43 -0
  29. package/_dsgn/templates/video/meta.json +17 -0
  30. package/_dsgn/templates/video/template.tsx +48 -0
  31. package/dist/cli.d.ts +3 -0
  32. package/dist/cli.d.ts.map +1 -0
  33. package/dist/cli.js +70 -0
  34. package/dist/cli.js.map +1 -0
  35. package/dist/commands/add.d.ts +6 -0
  36. package/dist/commands/add.d.ts.map +1 -0
  37. package/dist/commands/add.js +86 -0
  38. package/dist/commands/add.js.map +1 -0
  39. package/dist/commands/default.d.ts +2 -0
  40. package/dist/commands/default.d.ts.map +1 -0
  41. package/dist/commands/default.js +69 -0
  42. package/dist/commands/default.js.map +1 -0
  43. package/dist/commands/init.d.ts +2 -0
  44. package/dist/commands/init.d.ts.map +1 -0
  45. package/dist/commands/init.js +75 -0
  46. package/dist/commands/init.js.map +1 -0
  47. package/dist/commands/list.d.ts +2 -0
  48. package/dist/commands/list.d.ts.map +1 -0
  49. package/dist/commands/list.js +83 -0
  50. package/dist/commands/list.js.map +1 -0
  51. package/dist/commands/preview.d.ts +3 -0
  52. package/dist/commands/preview.d.ts.map +1 -0
  53. package/dist/commands/preview.js +296 -0
  54. package/dist/commands/preview.js.map +1 -0
  55. package/dist/commands/render.d.ts +10 -0
  56. package/dist/commands/render.d.ts.map +1 -0
  57. package/dist/commands/render.js +204 -0
  58. package/dist/commands/render.js.map +1 -0
  59. package/dist/commands/validate.d.ts +2 -0
  60. package/dist/commands/validate.d.ts.map +1 -0
  61. package/dist/commands/validate.js +107 -0
  62. package/dist/commands/validate.js.map +1 -0
  63. package/dist/default-templates/AGENTS.md +229 -0
  64. package/dist/default-templates/image/meta.json +13 -0
  65. package/dist/default-templates/image/template.d.ts +20 -0
  66. package/dist/default-templates/image/template.d.ts.map +1 -0
  67. package/dist/default-templates/image/template.js +18 -0
  68. package/dist/default-templates/image/template.js.map +1 -0
  69. package/dist/default-templates/image/template.tsx +20 -0
  70. package/dist/default-templates/image-template/meta.json +13 -0
  71. package/dist/default-templates/image-template/template.tsx +19 -0
  72. package/dist/default-templates/kitchen-sink/meta.json +13 -0
  73. package/dist/default-templates/kitchen-sink/template.tsx +64 -0
  74. package/dist/default-templates/page/meta.json +17 -0
  75. package/dist/default-templates/page/template.tsx +37 -0
  76. package/dist/default-templates/video/meta.json +17 -0
  77. package/dist/default-templates/video/template.d.ts +26 -0
  78. package/dist/default-templates/video/template.d.ts.map +1 -0
  79. package/dist/default-templates/video/template.js +33 -0
  80. package/dist/default-templates/video/template.js.map +1 -0
  81. package/dist/default-templates/video/template.tsx +37 -0
  82. package/dist/default-templates/video-template/meta.json +17 -0
  83. package/dist/default-templates/video-template/template.tsx +36 -0
  84. package/dist/default-templates/website/meta.json +16 -0
  85. package/dist/default-templates/website/pages/home.tsx +17 -0
  86. package/dist/default-templates/website/parts/footer.tsx +17 -0
  87. package/dist/default-templates/website/parts/header.tsx +17 -0
  88. package/dist/default-templates/website/template.tsx +17 -0
  89. package/dist/default-templates/website-template/meta.json +16 -0
  90. package/dist/default-templates/website-template/pages/home.tsx +16 -0
  91. package/dist/default-templates/website-template/parts/footer.tsx +16 -0
  92. package/dist/default-templates/website-template/parts/header.tsx +16 -0
  93. package/dist/default-templates/website-template/template.tsx +16 -0
  94. package/dist/lib/config.d.ts +34 -0
  95. package/dist/lib/config.d.ts.map +1 -0
  96. package/dist/lib/config.js +248 -0
  97. package/dist/lib/config.js.map +1 -0
  98. package/dist/lib/constants.d.ts +7 -0
  99. package/dist/lib/constants.d.ts.map +1 -0
  100. package/dist/lib/constants.js +12 -0
  101. package/dist/lib/constants.js.map +1 -0
  102. package/dist/lib/helpers.d.ts +29 -0
  103. package/dist/lib/helpers.d.ts.map +1 -0
  104. package/dist/lib/helpers.js +159 -0
  105. package/dist/lib/helpers.js.map +1 -0
  106. package/dist/lib/installer.d.ts +51 -0
  107. package/dist/lib/installer.d.ts.map +1 -0
  108. package/dist/lib/installer.js +215 -0
  109. package/dist/lib/installer.js.map +1 -0
  110. package/dist/lib/renderer.d.ts +51 -0
  111. package/dist/lib/renderer.d.ts.map +1 -0
  112. package/dist/lib/renderer.js +524 -0
  113. package/dist/lib/renderer.js.map +1 -0
  114. package/dist/lib/tailwind-config-loader.d.ts +47 -0
  115. package/dist/lib/tailwind-config-loader.d.ts.map +1 -0
  116. package/dist/lib/tailwind-config-loader.js +432 -0
  117. package/dist/lib/tailwind-config-loader.js.map +1 -0
  118. package/dist/lib/tailwind-detector.d.ts +36 -0
  119. package/dist/lib/tailwind-detector.d.ts.map +1 -0
  120. package/dist/lib/tailwind-detector.js +156 -0
  121. package/dist/lib/tailwind-detector.js.map +1 -0
  122. package/dist/lib/tailwind.d.ts +8 -0
  123. package/dist/lib/tailwind.d.ts.map +1 -0
  124. package/dist/lib/tailwind.js +994 -0
  125. package/dist/lib/tailwind.js.map +1 -0
  126. package/dist/lib/template-validator.d.ts +22 -0
  127. package/dist/lib/template-validator.d.ts.map +1 -0
  128. package/dist/lib/template-validator.js +174 -0
  129. package/dist/lib/template-validator.js.map +1 -0
  130. package/dist/lib/utils.d.ts +44 -0
  131. package/dist/lib/utils.d.ts.map +1 -0
  132. package/dist/lib/utils.js +207 -0
  133. package/dist/lib/utils.js.map +1 -0
  134. package/dist/lib/version-check.d.ts +16 -0
  135. package/dist/lib/version-check.d.ts.map +1 -0
  136. package/dist/lib/version-check.js +88 -0
  137. package/dist/lib/version-check.js.map +1 -0
  138. package/dist/lib/video-renderer.d.ts +32 -0
  139. package/dist/lib/video-renderer.d.ts.map +1 -0
  140. package/dist/lib/video-renderer.js +226 -0
  141. package/dist/lib/video-renderer.js.map +1 -0
  142. package/dist/sdk/index.d.ts +58 -0
  143. package/dist/sdk/index.d.ts.map +1 -0
  144. package/dist/sdk/index.js +119 -0
  145. package/dist/sdk/index.js.map +1 -0
  146. package/dist/sdk/template.d.ts +40 -0
  147. package/dist/sdk/template.d.ts.map +1 -0
  148. package/dist/sdk/template.js +60 -0
  149. package/dist/sdk/template.js.map +1 -0
  150. package/dist/types/config.d.ts +62 -0
  151. package/dist/types/config.d.ts.map +1 -0
  152. package/dist/types/config.js +47 -0
  153. package/dist/types/config.js.map +1 -0
  154. package/dist/types/template.d.ts +79 -0
  155. package/dist/types/template.d.ts.map +1 -0
  156. package/dist/types/template.js +2 -0
  157. package/dist/types/template.js.map +1 -0
  158. package/examples/nextjs-api/README.md +180 -0
  159. package/examples/nextjs-api/package.json +21 -0
  160. package/examples/nextjs-api/pages/api/intro-video.ts +53 -0
  161. package/examples/nextjs-api/pages/api/og-image.ts +50 -0
  162. package/netlify.toml +13 -0
  163. package/package.json +84 -0
  164. package/patches/satori+0.18.3.patch +13 -0
  165. package/test-templates/TESTS.md +63 -0
  166. package/test-templates/_dsgn/templates/absolute-spin/meta.json +7 -0
  167. package/test-templates/_dsgn/templates/absolute-spin/template.tsx +16 -0
  168. package/test-templates/_dsgn/templates/animated-intro/.tmp/template-1763468771640.mjs +7 -0
  169. package/test-templates/_dsgn/templates/animated-intro/meta.json +10 -0
  170. package/test-templates/_dsgn/templates/animated-intro/template.tsx +23 -0
  171. package/test-templates/_dsgn/templates/centered-spin/.tmp/template-1763468525386.mjs +7 -0
  172. package/test-templates/_dsgn/templates/centered-spin/meta.json +7 -0
  173. package/test-templates/_dsgn/templates/centered-spin/template.tsx +11 -0
  174. package/test-templates/_dsgn/templates/composite/.tmp/template-1763468815645.mjs +7 -0
  175. package/test-templates/_dsgn/templates/composite/meta.json +9 -0
  176. package/test-templates/_dsgn/templates/composite/template.tsx +23 -0
  177. package/test-templates/_dsgn/templates/easing-test/.tmp/template-1763468824501.mjs +7 -0
  178. package/test-templates/_dsgn/templates/easing-test/meta.json +7 -0
  179. package/test-templates/_dsgn/templates/easing-test/template.tsx +47 -0
  180. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763466364336.mjs +10 -0
  181. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763466584319.mjs +10 -0
  182. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763466667797.mjs +10 -0
  183. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763466746504.mjs +10 -0
  184. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763466930225.mjs +10 -0
  185. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467004552.mjs +10 -0
  186. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467060334.mjs +10 -0
  187. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467124493.mjs +10 -0
  188. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467174690.mjs +10 -0
  189. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467359134.mjs +10 -0
  190. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467451928.mjs +10 -0
  191. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467758275.mjs +10 -0
  192. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763467985201.mjs +10 -0
  193. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763468020563.mjs +10 -0
  194. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763468090428.mjs +10 -0
  195. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763468211036.mjs +10 -0
  196. package/test-templates/_dsgn/templates/minimal-spin/.tmp/template-1763468394057.mjs +10 -0
  197. package/test-templates/_dsgn/templates/minimal-spin/meta.json +7 -0
  198. package/test-templates/_dsgn/templates/minimal-spin/template.tsx +13 -0
  199. package/test-templates/_dsgn/templates/no-origin-spin/meta.json +7 -0
  200. package/test-templates/_dsgn/templates/no-origin-spin/template.tsx +10 -0
  201. package/test-templates/_dsgn/templates/opacity-test/meta.json +7 -0
  202. package/test-templates/_dsgn/templates/opacity-test/template.tsx +9 -0
  203. package/test-templates/_dsgn/templates/qr-code/.tmp/template-1763468758954.mjs +17 -0
  204. package/test-templates/_dsgn/templates/qr-code/.tmp/template-1763468815672.mjs +17 -0
  205. package/test-templates/_dsgn/templates/qr-code/meta.json +9 -0
  206. package/test-templates/_dsgn/templates/qr-code/template.tsx +20 -0
  207. package/test-templates/_dsgn/templates/rotation-abs-test/meta.json +7 -0
  208. package/test-templates/_dsgn/templates/rotation-abs-test/template.tsx +15 -0
  209. package/test-templates/_dsgn/templates/rotation-corner/meta.json +7 -0
  210. package/test-templates/_dsgn/templates/rotation-corner/template.tsx +12 -0
  211. package/test-templates/_dsgn/templates/rotation-test/meta.json +7 -0
  212. package/test-templates/_dsgn/templates/rotation-test/template.tsx +12 -0
  213. package/test-templates/_dsgn/templates/shake-test/meta.json +7 -0
  214. package/test-templates/_dsgn/templates/shake-test/template.tsx +12 -0
  215. package/test-templates/_dsgn/templates/static-image/.tmp/template-1763468746271.mjs +7 -0
  216. package/test-templates/_dsgn/templates/static-image/meta.json +9 -0
  217. package/test-templates/_dsgn/templates/static-image/template.tsx +19 -0
  218. package/test-templates/_dsgn/templates/translate-test/meta.json +7 -0
  219. package/test-templates/_dsgn/templates/translate-test/template.tsx +9 -0
  220. package/test-templates/_dsgn/templates/video-loops/.tmp/template-1763468793192.mjs +15 -0
  221. package/test-templates/_dsgn/templates/video-loops/meta.json +9 -0
  222. package/test-templates/_dsgn/templates/video-loops/template.tsx +39 -0
  223. package/test-templates/_dsgn/templates/wrapped-spin/meta.json +7 -0
  224. package/test-templates/_dsgn/templates/wrapped-spin/template.tsx +17 -0
  225. package/test-templates/compare-svgs.mjs +30 -0
  226. package/test-templates/convert-frames.mjs +15 -0
  227. package/test-templates/debug-rotation.mjs +25 -0
  228. package/test-templates/run-tests.sh +39 -0
  229. package/test-templates/test-sdk.mjs +115 -0
  230. package/website/.astro/settings.json +5 -0
  231. package/website/.astro/types.d.ts +1 -0
  232. package/website/README.md +112 -0
  233. package/website/astro.config.mjs +18 -0
  234. package/website/dist/_astro/fonts.DHdiHGBO.css +1 -0
  235. package/website/dist/fonts/index.html +193 -0
  236. package/website/dist/helpers/index.html +166 -0
  237. package/website/dist/images/index.html +314 -0
  238. package/website/dist/index.html +219 -0
  239. package/website/dist/llm.txt +2448 -0
  240. package/website/dist/styling/index.html +365 -0
  241. package/website/dist/templates/index.html +124 -0
  242. package/website/dist/video/index.html +636 -0
  243. package/website/package-lock.json +7606 -0
  244. package/website/package.json +23 -0
  245. package/website/public/robots.txt +5 -0
@@ -0,0 +1,427 @@
1
+ # Setting Up the Template Registry
2
+
3
+ ## Overview
4
+
5
+ The registry is a simple HTTP endpoint that serves template JSON files. Users run `dsgn add template-name` and it fetches from `https://dsgncli.com/r/template-name`.
6
+
7
+ ## Quick Solutions
8
+
9
+ ### Option 1: Static JSON Files (Simplest)
10
+
11
+ Host static JSON files on any static hosting:
12
+
13
+ **1. Create template JSON files:**
14
+
15
+ ```
16
+ dsgncli.com/
17
+ └── r/
18
+ ├── banner-hero.json
19
+ ├── product-card.json
20
+ └── social-og.json
21
+ ```
22
+
23
+ **2. Each JSON file contains:**
24
+
25
+ ```json
26
+ {
27
+ "name": "banner-hero",
28
+ "version": "1.0.0",
29
+ "description": "Hero banner with gradient background",
30
+ "files": [
31
+ {
32
+ "path": "banner-hero.tsx",
33
+ "content": "import React from 'react';\n\nexport const meta = {...};\n\nexport default function BannerHero({...}) {...}"
34
+ },
35
+ {
36
+ "path": "meta.json",
37
+ "content": "{\"name\":\"banner-hero\",\"size\":{\"width\":1600,\"height\":900},...}"
38
+ }
39
+ ]
40
+ }
41
+ ```
42
+
43
+ **3. Configure your web server:**
44
+
45
+ ```nginx
46
+ # nginx
47
+ location /r/ {
48
+ # Rewrite /r/banner-hero to /r/banner-hero.json
49
+ rewrite ^/r/(.+)$ /r/$1.json break;
50
+ }
51
+ ```
52
+
53
+ **4. Host on:**
54
+ - Vercel/Netlify (free)
55
+ - Cloudflare Pages (free)
56
+ - GitHub Pages (free)
57
+ - Any static host
58
+
59
+ ### Option 2: Serverless API (Recommended)
60
+
61
+ Create a simple API with Vercel/Netlify functions:
62
+
63
+ **File: `api/templates/[name].js`**
64
+
65
+ ```javascript
66
+ // Vercel/Next.js API route
67
+ export default function handler(req, res) {
68
+ const { name } = req.query;
69
+
70
+ // Load template from database or files
71
+ const template = getTemplate(name);
72
+
73
+ if (!template) {
74
+ return res.status(404).json({ error: 'Template not found' });
75
+ }
76
+
77
+ res.json(template);
78
+ }
79
+
80
+ function getTemplate(name) {
81
+ // Option A: From database
82
+ // return db.templates.findOne({ name });
83
+
84
+ // Option B: From static files
85
+ const templates = {
86
+ 'banner-hero': {
87
+ name: 'banner-hero',
88
+ version: '1.0.0',
89
+ description: 'Hero banner',
90
+ files: [
91
+ {
92
+ path: 'banner-hero.tsx',
93
+ content: require('./templates/banner-hero.tsx.txt')
94
+ },
95
+ {
96
+ path: 'meta.json',
97
+ content: require('./templates/banner-hero-meta.json')
98
+ }
99
+ ]
100
+ }
101
+ };
102
+
103
+ return templates[name];
104
+ }
105
+ ```
106
+
107
+ **Deploy:**
108
+
109
+ ```bash
110
+ vercel deploy
111
+ # or
112
+ netlify deploy
113
+ ```
114
+
115
+ ### Option 3: Use GitHub as Registry (Temporary)
116
+
117
+ Until you set up a real registry, use GitHub:
118
+
119
+ **1. Create a templates repo:**
120
+
121
+ ```
122
+ github.com/yourusername/dsgn-templates/
123
+ ├── banner-hero/
124
+ │ ├── template.json
125
+ │ ├── banner-hero.tsx
126
+ │ └── meta.json
127
+ ├── product-card/
128
+ │ └── ...
129
+ └── README.md
130
+ ```
131
+
132
+ **2. Users install with:**
133
+
134
+ ```bash
135
+ dsgn add github:yourusername/dsgn-templates/banner-hero
136
+ ```
137
+
138
+ **3. Update CLI default:**
139
+
140
+ ```typescript
141
+ // src/lib/constants.ts
142
+ export const DEFAULT_REGISTRY = 'github:yourusername/dsgn-templates';
143
+ ```
144
+
145
+ Then users can:
146
+
147
+ ```bash
148
+ dsgn add banner-hero # Uses GitHub as registry
149
+ ```
150
+
151
+ ## Creating Template JSON Files
152
+
153
+ ### Script to Convert Local Templates
154
+
155
+ ```javascript
156
+ // scripts/create-registry-json.js
157
+ const fs = require('fs');
158
+ const path = require('path');
159
+
160
+ const templatesDir = './design-templates';
161
+ const outputDir = './registry';
162
+
163
+ // Read all templates
164
+ const templates = fs.readdirSync(templatesDir);
165
+
166
+ templates.forEach(name => {
167
+ const templatePath = path.join(templatesDir, name);
168
+ const files = [];
169
+
170
+ // Read all files in template
171
+ const entries = fs.readdirSync(templatePath);
172
+ entries.forEach(file => {
173
+ const filePath = path.join(templatePath, file);
174
+ const content = fs.readFileSync(filePath, 'utf-8');
175
+ files.push({
176
+ path: file,
177
+ content: content
178
+ });
179
+ });
180
+
181
+ // Create registry JSON
182
+ const registryJson = {
183
+ name: name,
184
+ version: '1.0.0',
185
+ description: `Template: ${name}`,
186
+ files: files
187
+ };
188
+
189
+ // Write to output
190
+ const outputPath = path.join(outputDir, `${name}.json`);
191
+ fs.writeFileSync(outputPath, JSON.stringify(registryJson, null, 2));
192
+
193
+ console.log(`Created: ${outputPath}`);
194
+ });
195
+ ```
196
+
197
+ **Run:**
198
+
199
+ ```bash
200
+ node scripts/create-registry-json.js
201
+ ```
202
+
203
+ This creates:
204
+
205
+ ```
206
+ registry/
207
+ ├── banner-hero.json
208
+ ├── product-card.json
209
+ └── social-og.json
210
+ ```
211
+
212
+ Upload these to `dsgncli.com/r/`
213
+
214
+ ## Example Hosting Setups
215
+
216
+ ### Vercel (Recommended)
217
+
218
+ **1. Create Next.js project:**
219
+
220
+ ```bash
221
+ npx create-next-app@latest dsgn-registry
222
+ cd dsgn-registry
223
+ ```
224
+
225
+ **2. Create API route:**
226
+
227
+ ```typescript
228
+ // pages/api/r/[template].ts
229
+ import { NextApiRequest, NextApiResponse } from 'next';
230
+ import templates from '../../../data/templates.json';
231
+
232
+ export default function handler(req: NextApiRequest, res: NextApiResponse) {
233
+ const { template } = req.query;
234
+
235
+ const templateData = templates[template as string];
236
+
237
+ if (!templateData) {
238
+ return res.status(404).json({ error: 'Template not found' });
239
+ }
240
+
241
+ res.json(templateData);
242
+ }
243
+ ```
244
+
245
+ **3. Deploy:**
246
+
247
+ ```bash
248
+ vercel
249
+ ```
250
+
251
+ **4. Configure domain:**
252
+
253
+ Set `dsgncli.com` to point to your Vercel project.
254
+
255
+ ### Cloudflare Workers
256
+
257
+ ```javascript
258
+ // worker.js
259
+ const templates = {
260
+ 'banner-hero': {
261
+ name: 'banner-hero',
262
+ version: '1.0.0',
263
+ files: [...]
264
+ }
265
+ };
266
+
267
+ export default {
268
+ async fetch(request) {
269
+ const url = new URL(request.url);
270
+ const templateName = url.pathname.replace('/r/', '');
271
+
272
+ const template = templates[templateName];
273
+
274
+ if (!template) {
275
+ return new Response('Not found', { status: 404 });
276
+ }
277
+
278
+ return new Response(JSON.stringify(template), {
279
+ headers: { 'Content-Type': 'application/json' }
280
+ });
281
+ }
282
+ }
283
+ ```
284
+
285
+ ### Static Files on Vercel
286
+
287
+ **1. Create JSON files:**
288
+
289
+ ```
290
+ public/
291
+ └── r/
292
+ ├── banner-hero.json
293
+ ├── product-card.json
294
+ └── index.json (list of all templates)
295
+ ```
296
+
297
+ **2. Add to `vercel.json`:**
298
+
299
+ ```json
300
+ {
301
+ "rewrites": [
302
+ { "source": "/r/:template", "destination": "/r/:template.json" }
303
+ ]
304
+ }
305
+ ```
306
+
307
+ **3. Deploy:**
308
+
309
+ ```bash
310
+ vercel deploy
311
+ ```
312
+
313
+ ## Database-Backed Registry (Advanced)
314
+
315
+ For a production registry with versioning, search, etc.:
316
+
317
+ ```typescript
318
+ // API endpoint
319
+ app.get('/r/:name', async (req, res) => {
320
+ const { name } = req.params;
321
+ const { version } = req.query;
322
+
323
+ const template = await db.templates.findOne({
324
+ name,
325
+ version: version || 'latest'
326
+ });
327
+
328
+ if (!template) {
329
+ return res.status(404).json({ error: 'Template not found' });
330
+ }
331
+
332
+ res.json(template);
333
+ });
334
+
335
+ // Users can install specific versions
336
+ // dsgn add banner-hero@1.2.0
337
+ ```
338
+
339
+ ## Testing Your Registry
340
+
341
+ Once deployed, test it:
342
+
343
+ ```bash
344
+ # Test the endpoint
345
+ curl https://dsgncli.com/r/banner-hero
346
+
347
+ # Should return JSON like:
348
+ {
349
+ "name": "banner-hero",
350
+ "version": "1.0.0",
351
+ "files": [...]
352
+ }
353
+
354
+ # Test with CLI
355
+ dsgn add banner-hero
356
+ ```
357
+
358
+ ## Until Registry is Ready
359
+
360
+ **Option 1:** Tell users to use GitHub:
361
+
362
+ ```bash
363
+ dsgn add github:yourusername/dsgn-templates/banner-hero
364
+ ```
365
+
366
+ **Option 2:** Update README with temporary instructions:
367
+
368
+ ```markdown
369
+ ## Installation
370
+
371
+ Templates are currently hosted on GitHub. Install with:
372
+
373
+ \`\`\`bash
374
+ dsgn add github:dsgncli/templates/banner-hero
375
+ \`\`\`
376
+
377
+ Official registry coming soon!
378
+ ```
379
+
380
+ **Option 3:** Ship with bundled templates in the CLI package itself (see below).
381
+
382
+ ## Bundled Templates (Alternative)
383
+
384
+ Include templates directly in the npm package:
385
+
386
+ **1. Create templates folder:**
387
+
388
+ ```
389
+ dsgn/
390
+ ├── dist/
391
+ └── bundled-templates/
392
+ ├── banner-hero.json
393
+ ├── product-card.json
394
+ └── social-og.json
395
+ ```
396
+
397
+ **2. Update installer to check bundled first:**
398
+
399
+ ```typescript
400
+ export async function fetchTemplate(name: string) {
401
+ // Try bundled templates first
402
+ const bundledPath = path.join(__dirname, '../bundled-templates', `${name}.json`);
403
+
404
+ try {
405
+ const content = await fs.readFile(bundledPath, 'utf-8');
406
+ return JSON.parse(content);
407
+ } catch {
408
+ // Fall back to registry
409
+ return fetchFromRegistry(name);
410
+ }
411
+ }
412
+ ```
413
+
414
+ **3. Users get core templates immediately:**
415
+
416
+ ```bash
417
+ npm install -g dsgn
418
+ dsgn add banner-hero # Works offline!
419
+ ```
420
+
421
+ ## Recommended Approach
422
+
423
+ 1. **Short term:** Bundle 3-5 core templates with the CLI
424
+ 2. **Medium term:** Set up static JSON hosting on Vercel/Cloudflare
425
+ 3. **Long term:** Build proper registry with database, versioning, search
426
+
427
+ This way users can use it immediately while you build out the full registry!
@@ -0,0 +1,269 @@
1
+ # shadcn/ui Design System Integration
2
+
3
+ dsgn uses **shadcn/ui's design system** by default, providing beautiful and consistent colors, typography, and components.
4
+
5
+ ## Default Color Palette
6
+
7
+ All templates automatically have access to shadcn's semantic color tokens:
8
+
9
+ ```typescript
10
+ colors: {
11
+ // Primary colors
12
+ primary: '#18181b', // Main brand color
13
+ 'primary-foreground': '#fafafa',
14
+
15
+ // Secondary colors
16
+ secondary: '#f4f4f5', // Subtle accents
17
+ 'secondary-foreground': '#18181b',
18
+
19
+ // Background
20
+ background: '#ffffff', // Page background
21
+ foreground: '#09090b', // Main text color
22
+
23
+ // Muted
24
+ muted: '#f4f4f5', // Subtle backgrounds
25
+ 'muted-foreground': '#71717a', // Muted text
26
+
27
+ // Accent
28
+ accent: '#f4f4f5', // Highlight color
29
+ 'accent-foreground': '#18181b',
30
+
31
+ // Destructive
32
+ destructive: '#ef4444', // Error/danger states
33
+ 'destructive-foreground': '#fafafa',
34
+
35
+ // UI Elements
36
+ border: '#e4e4e7', // Border color
37
+ input: '#e4e4e7', // Input borders
38
+ ring: '#18181b', // Focus rings
39
+ card: '#ffffff', // Card background
40
+ 'card-foreground': '#09090b',
41
+ popover: '#ffffff', // Popover background
42
+ 'popover-foreground': '#09090b',
43
+ }
44
+ ```
45
+
46
+ ## Using shadcn Colors in Templates
47
+
48
+ ### Basic Usage
49
+
50
+ ```tsx
51
+ export default function Template({ title, tw }) {
52
+ return (
53
+ <div style={tw('bg-background text-foreground')}>
54
+ <h1 style={tw('text-primary font-bold')}>
55
+ {title}
56
+ </h1>
57
+ <p style={tw('text-muted-foreground')}>
58
+ Subtle secondary text
59
+ </p>
60
+ </div>
61
+ );
62
+ }
63
+ ```
64
+
65
+ ### Opacity Modifiers (shadcn Style)
66
+
67
+ Use Tailwind's slash syntax for opacity:
68
+
69
+ ```tsx
70
+ <div style={tw('bg-primary/50')}> {/* 50% opacity */}
71
+ <p style={tw('text-muted-foreground/75')}> {/* 75% opacity */}
72
+ <div style={tw('border/30')}> {/* Border with 30% opacity */}
73
+ ```
74
+
75
+ **Supported syntax:**
76
+ - `bg-{color}/{opacity}` - Background with opacity
77
+ - `text-{color}/{opacity}` - Text with opacity
78
+ - `border-{color}/{opacity}` - Border with opacity
79
+
80
+ ### Cards and Containers
81
+
82
+ ```tsx
83
+ <div style={tw('bg-card border rounded-xl p-16')}>
84
+ <h2 style={tw('text-card-foreground font-bold')}>Card Title</h2>
85
+ <p style={tw('text-muted-foreground')}>Card content</p>
86
+ </div>
87
+ ```
88
+
89
+ ### Destructive/Error States
90
+
91
+ ```tsx
92
+ <div style={tw('bg-destructive/10 border-destructive/50 rounded-lg p-4')}>
93
+ <p style={tw('text-destructive font-medium')}>
94
+ Error: Something went wrong
95
+ </p>
96
+ </div>
97
+ ```
98
+
99
+ ## Complete Example
100
+
101
+ Here's a template using shadcn design system:
102
+
103
+ ```tsx
104
+ import React from 'react';
105
+
106
+ export const meta = {
107
+ name: "shadcn-card",
108
+ description: "Card using shadcn design system",
109
+ type: "image",
110
+ size: { width: 1200, height: 630 }
111
+ };
112
+
113
+ export default function ShadcnCard({ title, description, status, tw }) {
114
+ return (
115
+ <div style={tw('w-full h-full flex items-center justify-center bg-background p-20')}>
116
+ <div style={tw('bg-card border rounded-xl p-16 flex flex-col')}>
117
+ {/* Header */}
118
+ <div style={tw('flex items-center mb-6')}>
119
+ <div style={tw('bg-primary rounded-lg p-3')}>
120
+ <span style={tw('text-primary-foreground text-2xl')}>✓</span>
121
+ </div>
122
+ <h1 style={tw('text-4xl font-bold text-foreground ml-4')}>
123
+ {title}
124
+ </h1>
125
+ </div>
126
+
127
+ {/* Description */}
128
+ <p style={tw('text-2xl text-muted-foreground mb-6')}>
129
+ {description}
130
+ </p>
131
+
132
+ {/* Status badge */}
133
+ <div style={tw('bg-secondary rounded-md p-2')}>
134
+ <span style={tw('text-secondary-foreground font-medium')}>
135
+ Status: {status}
136
+ </span>
137
+ </div>
138
+
139
+ {/* Subtle border */}
140
+ <div style={tw('border-t/50 mt-6 pt-6')}>
141
+ <p style={tw('text-muted-foreground/75 text-sm')}>
142
+ Powered by dsgn + shadcn
143
+ </p>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ );
148
+ }
149
+ ```
150
+
151
+ ## Customizing Colors
152
+
153
+ Users can override the default shadcn colors in their `dsgn.json`:
154
+
155
+ ```json
156
+ {
157
+ "colors": {
158
+ "primary": "#3b82f6",
159
+ "primary-foreground": "#ffffff",
160
+ "secondary": "#f1f5f9",
161
+ "secondary-foreground": "#0f172a"
162
+ // ... other colors
163
+ }
164
+ }
165
+ ```
166
+
167
+ Or use their existing `tailwind.config.js` colors - dsgn automatically detects and uses them!
168
+
169
+ ## shadcn Themes
170
+
171
+ dsgn uses the **Zinc theme** by default. Users can easily switch to other shadcn themes:
172
+
173
+ ### Slate Theme
174
+ ```json
175
+ {
176
+ "colors": {
177
+ "primary": "#020617",
178
+ "secondary": "#f1f5f9",
179
+ "muted": "#f1f5f9",
180
+ "accent": "#f1f5f9",
181
+ "border": "#e2e8f0"
182
+ }
183
+ }
184
+ ```
185
+
186
+ ### Stone Theme
187
+ ```json
188
+ {
189
+ "colors": {
190
+ "primary": "#0c0a09",
191
+ "secondary": "#f5f5f4",
192
+ "muted": "#f5f5f4",
193
+ "accent": "#f5f5f4",
194
+ "border": "#e7e5e4"
195
+ }
196
+ }
197
+ ```
198
+
199
+ ### Dark Mode
200
+ ```json
201
+ {
202
+ "colors": {
203
+ "primary": "#fafafa",
204
+ "primary-foreground": "#18181b",
205
+ "background": "#09090b",
206
+ "foreground": "#fafafa",
207
+ "card": "#18181b",
208
+ "card-foreground": "#fafafa",
209
+ "muted": "#27272a",
210
+ "muted-foreground": "#a1a1aa",
211
+ "border": "#27272a"
212
+ }
213
+ }
214
+ ```
215
+
216
+ ## Supported shadcn Classes
217
+
218
+ ### Colors
219
+ - `text-primary`, `text-secondary`, `text-muted`, `text-accent`, `text-destructive`
220
+ - `bg-primary`, `bg-secondary`, `bg-muted`, `bg-accent`, `bg-destructive`, `bg-card`
221
+ - `border`, `border-primary`, `border-destructive`, etc.
222
+
223
+ ### Foreground Variants
224
+ - `text-primary-foreground`
225
+ - `text-secondary-foreground`
226
+ - `text-muted-foreground`
227
+ - `text-card-foreground`
228
+
229
+ ### With Opacity
230
+ - `bg-primary/50`, `text-muted-foreground/75`, `border/30`
231
+ - Any color can have `/10`, `/20`, `/30`, ... `/90`, `/100`
232
+
233
+ ## Best Practices
234
+
235
+ 1. **Use semantic colors** - `text-foreground` instead of `text-black`
236
+ 2. **Leverage opacity modifiers** - `bg-primary/10` for subtle highlights
237
+ 3. **Card patterns** - `bg-card border rounded-xl` for containers
238
+ 4. **Consistent foregrounds** - Pair colors with their foreground variants
239
+ 5. **Muted for secondary** - Use `text-muted-foreground` for less important text
240
+
241
+ ## Migration from Custom Colors
242
+
243
+ Before (custom gradient):
244
+ ```tsx
245
+ <div style={{
246
+ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
247
+ color: 'white'
248
+ }}>
249
+ ```
250
+
251
+ After (shadcn):
252
+ ```tsx
253
+ <div style={tw('bg-primary text-primary-foreground')}>
254
+ ```
255
+
256
+ Much cleaner and themeable!
257
+
258
+ ## Summary
259
+
260
+ | Feature | Supported | Example |
261
+ |---------|-----------|---------|
262
+ | **Semantic colors** | ✅ | `text-primary`, `bg-card` |
263
+ | **Foreground variants** | ✅ | `text-muted-foreground` |
264
+ | **Opacity modifiers** | ✅ | `bg-primary/50`, `text-muted/75` |
265
+ | **Border colors** | ✅ | `border`, `border-destructive/50` |
266
+ | **Dark mode** | ✅ | Override in dsgn.json |
267
+ | **Custom themes** | ✅ | Full shadcn palette customizable |
268
+
269
+ **dsgn templates automatically work with shadcn's design system!** 🎨