@razorwind/core 0.0.5 → 0.0.6
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 +218 -0
- package/dist/generator.cjs +2 -2
- package/dist/generator.d.cts +1 -1
- package/dist/generator.d.mts +1 -1
- package/dist/generator.mjs +4 -4
- package/dist/{index-DUwzPMW3.d.mts → index-8xt23rlo.d.mts} +3 -2
- package/dist/index-8xt23rlo.d.mts.map +1 -0
- package/dist/{index-UbhspNdK.d.cts → index-DCXWFAYS.d.cts} +3 -2
- package/dist/index-DCXWFAYS.d.cts.map +1 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/package.json +3 -1
- package/dist/index-DUwzPMW3.d.mts.map +0 -1
- package/dist/index-UbhspNdK.d.cts.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
<!-- START header -->
|
|
2
|
+
<!-- prettier-ignore-start -->
|
|
3
|
+
<!-- markdownlint-disable -->
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<div align="center">
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/razorwind/media/banner-1280x640-dark.gif">
|
|
9
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/razorwind/media/banner-1280x640-light.gif">
|
|
10
|
+
<img src="https://public.storm-cdn.com/razorwind/media/banner-1280x640-dark.gif" width="100%" alt="Razorwind" />
|
|
11
|
+
</picture>
|
|
12
|
+
</div>
|
|
13
|
+
<br />
|
|
14
|
+
|
|
15
|
+
<div align="center">
|
|
16
|
+
<b>
|
|
17
|
+
<a href="https://stormsoftware.com" target="_blank">Website</a> •
|
|
18
|
+
<a href="https://github.com/storm-software/razorwind" target="_blank">GitHub</a> •
|
|
19
|
+
<a href="https://discord.gg/MQ6YVzakM5">Discord</a> • <a href="https://stormstack.github.io/stormstack/" target="_blank">Docs</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> •
|
|
20
|
+
<a href="https://github.com/storm-software/stack/issues/new?assignees=&labels=bug&template=bug-report.yml&title=Bug Report%3A+">Report a Bug</a>
|
|
21
|
+
</b>
|
|
22
|
+
</div>
|
|
23
|
+
<br />
|
|
24
|
+
|
|
25
|
+
💨 Razorwind is a unified set of tools that make creating design systems a breeze.
|
|
26
|
+
|
|
27
|
+
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3>
|
|
28
|
+
<br />
|
|
29
|
+
|
|
30
|
+
[](http://commitizen.github.io/cz-cli/)  
|
|
31
|
+
|
|
32
|
+
<!-- prettier-ignore-start -->
|
|
33
|
+
<!-- markdownlint-disable -->
|
|
34
|
+
|
|
35
|
+
> [!IMPORTANT]
|
|
36
|
+
> This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
|
|
37
|
+
|
|
38
|
+
<!-- markdownlint-restore -->
|
|
39
|
+
<!-- prettier-ignore-end -->
|
|
40
|
+
|
|
41
|
+
<div align="center">
|
|
42
|
+
<b>Be sure to ⭐ this repository on <a href="https://github.com/storm-software/razorwind" target="_blank">GitHub</a> so you can keep up to date on any daily progress!</b>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<br />
|
|
46
|
+
|
|
47
|
+
<!-- markdownlint-restore -->
|
|
48
|
+
<!-- prettier-ignore-end -->
|
|
2
49
|
|
|
3
50
|
<!-- END header -->
|
|
4
51
|
|
|
@@ -43,5 +90,176 @@ Run `nx build core` to build the library.
|
|
|
43
90
|
Run `nx test core` to execute the unit tests via [Vitest](https://vitest.dev/).
|
|
44
91
|
|
|
45
92
|
<!-- START footer -->
|
|
93
|
+
<!-- prettier-ignore-start -->
|
|
94
|
+
<!-- markdownlint-disable -->
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## Storm Workspaces
|
|
98
|
+
|
|
99
|
+
Storm workspaces are built using
|
|
100
|
+
<a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools
|
|
101
|
+
for monorepos, which helps you develop like Google, Facebook, and Microsoft.
|
|
102
|
+
Building on top of Nx, the Open System provides a set of tools and patterns that
|
|
103
|
+
help you scale your monorepo to many teams while keeping the codebase
|
|
104
|
+
maintainable.
|
|
105
|
+
|
|
106
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
107
|
+
<br />
|
|
108
|
+
|
|
109
|
+
## Roadmap
|
|
110
|
+
|
|
111
|
+
See the [open issues](https://github.com/storm-software/razorwind/issues) for
|
|
112
|
+
a list of proposed features (and known issues).
|
|
113
|
+
|
|
114
|
+
- [Top Feature Requests](https://github.com/storm-software/razorwind/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc)
|
|
115
|
+
(Add your votes using the 👍 reaction)
|
|
116
|
+
- [Top Bugs](https://github.com/storm-software/razorwind/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc)
|
|
117
|
+
(Add your votes using the 👍 reaction)
|
|
118
|
+
- [Newest Bugs](https://github.com/storm-software/razorwind/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
|
|
119
|
+
|
|
120
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
121
|
+
<br />
|
|
122
|
+
|
|
123
|
+
## Support
|
|
124
|
+
|
|
125
|
+
Reach out to the maintainer at one of the following places:
|
|
126
|
+
|
|
127
|
+
- [Contact](https://stormsoftware.com/contact)
|
|
128
|
+
- [GitHub discussions](https://github.com/storm-software/razorwind/discussions)
|
|
129
|
+
- <support@stormsoftware.com>
|
|
130
|
+
|
|
131
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
132
|
+
<br />
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
This project is licensed under the **Apache License 2.0**. Feel free to edit and
|
|
137
|
+
distribute this template as you like.
|
|
138
|
+
|
|
139
|
+
See [LICENSE](LICENSE) for more information.
|
|
140
|
+
|
|
141
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
142
|
+
<br />
|
|
143
|
+
|
|
144
|
+
## Changelog
|
|
145
|
+
|
|
146
|
+
This project adheres to
|
|
147
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along
|
|
148
|
+
with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md)
|
|
149
|
+
file
|
|
150
|
+
|
|
151
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
152
|
+
<br />
|
|
153
|
+
|
|
154
|
+
## Contributing
|
|
155
|
+
|
|
156
|
+
First off, thanks for taking the time to contribute! Contributions are what
|
|
157
|
+
makes the open-source community such an amazing place to learn, inspire, and
|
|
158
|
+
create. Any contributions you make will benefit everybody else and are **greatly
|
|
159
|
+
appreciated**.
|
|
160
|
+
|
|
161
|
+
Please try to create bug reports that are:
|
|
162
|
+
|
|
163
|
+
- _Reproducible._ Include steps to reproduce the problem.
|
|
164
|
+
- _Specific._ Include as much detail as possible: which version, what
|
|
165
|
+
environment, etc.
|
|
166
|
+
- _Unique._ Do not duplicate existing opened issues.
|
|
167
|
+
- _Scoped to a Single Bug._ One bug per report.
|
|
168
|
+
|
|
169
|
+
Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).
|
|
170
|
+
|
|
171
|
+
You can use
|
|
172
|
+
[markdownlint-cli](https://github.com/storm-software/razorwind/markdownlint-cli)
|
|
173
|
+
to check for common markdown style inconsistency.
|
|
174
|
+
|
|
175
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
176
|
+
<br />
|
|
177
|
+
|
|
178
|
+
## Contributors
|
|
179
|
+
|
|
180
|
+
Thanks goes to these wonderful people
|
|
181
|
+
([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
182
|
+
|
|
183
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
184
|
+
|
|
185
|
+
<table>
|
|
186
|
+
<tbody>
|
|
187
|
+
<tr>
|
|
188
|
+
<td align="center" valign="top" width="14.28%"><a href="http://www.sullypat.com/"><img src="https://avatars.githubusercontent.com/u/99053093?v=4?s=100" width="100px;" alt="Patrick Sullivan"/><br /><sub><b>Patrick Sullivan</b></sub></a><br /><a href="#design-sullivanpj" title="Design">🎨</a> <a href="https://github.com/storm-software/razorwind/commits?author=sullivanpj" title="Code">💻</a> <a href="#tool-sullivanpj" title="Tools">🔧</a> <a href="https://github.com/storm-software/razorwind/commits?author=sullivanpj" title="Documentation">📖</a> <a href="https://github.com/storm-software/razorwind/commits?author=sullivanpj" title="Tests">⚠️</a></td>
|
|
189
|
+
<td align="center" valign="top" width="14.28%"><a href="https://tylerbenning.com/"><img src="https://avatars.githubusercontent.com/u/7265547?v=4?s=100" width="100px;" alt="Tyler Benning"/><br /><sub><b>Tyler Benning</b></sub></a><br /><a href="#design-tbenning" title="Design">🎨</a></td>
|
|
190
|
+
<td align="center" valign="top" width="14.28%"><a href="http://stormsoftware.com"><img src="https://avatars.githubusercontent.com/u/149802440?v=4?s=100" width="100px;" alt="Stormie"/><br /><sub><b>Stormie</b></sub></a><br /><a href="#maintenance-stormie-bot" title="Maintenance">🚧</a></td>
|
|
191
|
+
</tr>
|
|
192
|
+
</tbody>
|
|
193
|
+
<tfoot>
|
|
194
|
+
<tr>
|
|
195
|
+
<td align="center" size="13px" colspan="7">
|
|
196
|
+
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" alt="All Contributors">
|
|
197
|
+
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
|
|
198
|
+
</img>
|
|
199
|
+
</td>
|
|
200
|
+
</tr>
|
|
201
|
+
</tfoot>
|
|
202
|
+
</table>
|
|
203
|
+
|
|
204
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
205
|
+
|
|
206
|
+
This project follows the
|
|
207
|
+
[all-contributors](https://github.com/all-contributors/all-contributors)
|
|
208
|
+
specification. Contributions of any kind welcome!
|
|
209
|
+
|
|
210
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
211
|
+
<br />
|
|
212
|
+
|
|
213
|
+
<hr />
|
|
214
|
+
<br />
|
|
215
|
+
|
|
216
|
+
<div align="center">
|
|
217
|
+
<picture>
|
|
218
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp">
|
|
219
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-light.webp">
|
|
220
|
+
<img src="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp" width="100%" alt="Storm Software" />
|
|
221
|
+
</picture>
|
|
222
|
+
</div>
|
|
223
|
+
<br />
|
|
224
|
+
|
|
225
|
+
<div align="center">
|
|
226
|
+
<a href="https://stormsoftware.com" target="_blank">Website</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> • <a href="https://linkedin.com/in/patrick-sullivan-865526b0" target="_blank">LinkedIn</a> • <a href="https://medium.com/@pat.joseph.sullivan" target="_blank">Medium</a> • <a href="https://github.com/storm-software" target="_blank">GitHub</a> • <a href="https://keybase.io/sullivanp" target="_blank">OpenPGP Key</a>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<div align="center">
|
|
230
|
+
<b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D
|
|
231
|
+
</div>
|
|
232
|
+
<br />
|
|
233
|
+
|
|
234
|
+
Storm Software is an open source software development organization and creator
|
|
235
|
+
of Acidic, StormStack and StormCloud.
|
|
236
|
+
|
|
237
|
+
Our mission is to make software development more accessible. Our ideal future is
|
|
238
|
+
one where anyone can create software without years of prior development
|
|
239
|
+
experience serving as a barrier to entry. We hope to achieve this via LLMs,
|
|
240
|
+
Generative AI, and intuitive, high-level data modeling/programming languages.
|
|
241
|
+
|
|
242
|
+
Join us on [Discord](https://discord.gg/MQ6YVzakM5) to chat with the team,
|
|
243
|
+
receive release notifications, ask questions, and get involved.
|
|
244
|
+
|
|
245
|
+
If this sounds interesting, and you would like to help us in creating the next
|
|
246
|
+
generation of development tools, please reach out on our
|
|
247
|
+
[website](https://stormsoftware.com/contact) or join our
|
|
248
|
+
[Slack channel](https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA)!
|
|
249
|
+
|
|
250
|
+
<br />
|
|
251
|
+
|
|
252
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/icons/circle-dark.webp"><source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/icons/circle-light.webp"><img src="https://public.storm-cdn.com/storm-software/icons/circle-dark.webp" width="200px" alt="Storm Software" /></picture></a></div>
|
|
253
|
+
<br />
|
|
254
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/misc/text/visit-us-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/misc/text/visit-us-light.png"><img src="https://public.storm-cdn.com/misc/text/visit-us-dark.png" height="90px" alt="Visit us at stormsoftware.com" /></picture></a></div>
|
|
255
|
+
<br />
|
|
256
|
+
|
|
257
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
258
|
+
<br />
|
|
259
|
+
<br />
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
<!-- markdownlint-restore -->
|
|
263
|
+
<!-- prettier-ignore-end -->
|
|
46
264
|
|
|
47
265
|
<!-- END footer -->
|
package/dist/generator.cjs
CHANGED
|
@@ -3,5 +3,5 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
3
3
|
`&&(t+=`
|
|
4
4
|
`),i++}continue}if(a===`,`){let t=i+1;for(;t<e.length;){for(;/\s/.test(e[t]??``);)t++;if(e[t]===`/`&&e[t+1]===`/`){for(t+=2;t<e.length&&e[t]!==`
|
|
5
5
|
`&&e[t]!==`\r`;)t++;continue}if(e[t]===`/`&&e[t+1]===`*`){for(t+=2;t<e.length&&(e[t]!==`*`||e[t+1]!==`/`);)t++;t+=2;continue}break}if(e[t]===`}`||e[t]===`]`)continue}t+=a}return t}function we(e){if(e.startsWith(`#`)||e.startsWith(`.`)||(0,re.isAbsolute)(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const Te=new Map,I=new Map;function Ee(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
6
|
-
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function De(e){let t=[],n=g.default.resolve(e,`pnpm-workspace.yaml`);if((0,b.existsSync)(n)){let e=await(0,y.readFile)(n);t.push(...Ee(e))}let r=(0,p.joinPaths)(e,`package.json`);if((0,b.existsSync)(r))try{let e=await(0,v.readJsonFile)(r),n=Array.isArray(e
|
|
7
|
-
`))}async function Ve(e){try{let t=await Le.search(e);if(!t)return null;let n=_.rawConfigSchema.parse(t.config);if(n.registries){for(let e of Object.keys(n.registries))if(e in L)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return n}catch(t){let n=`${e}/components.json`;throw t instanceof Error&&t.message.includes(`reserved registry`)?t:Error(`Invalid configuration found in ${m.default.cyan(n)}.`)}}function He(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...L}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}const Ue=x.z.object({category:x.z.enum([`block`,`component`,`ui`,`page`]),name:x.z.string(),title:x.z.string(),description:x.z.string().optional(),tags:x.z.array(x.z.string()).optional(),related:x.z.array(x.z.string()).optional(),since:x.z.string().optional(),version:x.z.string().optional(),repository:x.z.string().optional(),homepage:x.z.string().optional(),dependencies:x.z.record(x.z.string(),x.z.string()).optional(),registryDependencies:x.z.record(x.z.string(),x.z.string()).optional(),files:x.z.array(x.z.string()).optional()});x.z.record(x.z.string(),Ue);function We(e){return x.default.unknown().transform((t,n)=>{let r=e.safeParse(t);if(!r.success){for(let e of r.error.issues)n.addIssue({code:`custom`,message:e.message,path:e.path});return x.default.NEVER}return r.data})}const Ge=x.default.union([C.tokensSchema,x.default.record(x.default.string(),C.tokensSchema)]),Ke=x.default.object({registry:We(_.configSchema),tokens:Ge}),qe=[`razorwind-json`,`razorwind-yaml`,`razorwind-toml`,`razorwind-css`],z=[`json`,`json5`,`jsonc`,`yaml`,`yml`,`toml`,`css`,`js`,`mjs`,`cjs`,`ts`,`mts`,`cts`],Je=z.join(`,`),Ye=[`tokens.json`,`tokens.json5`,`tokens.jsonc`,`tokens.yaml`,`tokens.yml`,`tokens.toml`,`tokens.css`,`design-tokens.json`,`design-tokens.yaml`,`design-tokens.yml`,`tokens`,`design-tokens`,`src/tokens`,`src/design-tokens`,`packages/tokens`,`style-dictionary.config.js`,`style-dictionary.config.mjs`,`style-dictionary.config.ts`,`sd.config.js`,`sd.config.mjs`,`sd.config.ts`],Xe=`**/*.{${Je}}`,Ze=/^(light|dark|dim|high-contrast|hc|default|base|theme)([._-].+)?$/i,Qe={color:`color`,colours:`color`,colors:`color`,colour:`color`,palette:`color`,bg:`color`,background:`color`,foreground:`color`,fg:`color`,border:`color`,fill:`color`,stroke:`color`,spacing:`dimension`,space:`dimension`,size:`dimension`,sizes:`dimension`,sizing:`dimension`,gap:`dimension`,radius:`dimension`,radii:`dimension`,rounded:`dimension`,width:`dimension`,height:`dimension`,dimension:`dimension`,dimensions:`dimension`,duration:`duration`,durations:`duration`,time:`duration`,delay:`duration`,animation:`duration`,motion:`duration`,transition:`duration`,font:`fontFamily`,fonts:`fontFamily`,fontfamily:`fontFamily`,"font-family":`fontFamily`,typeface:`fontFamily`,fontweight:`fontWeight`,"font-weight":`fontWeight`,weight:`fontWeight`,opacity:`number`,opacities:`number`,zindex:`number`,"z-index":`number`,lineheight:`number`,"line-height":`number`,letterspacing:`dimension`,"letter-spacing":`dimension`,shadow:`shadow`,shadows:`shadow`,elevation:`shadow`,gradient:`gradient`,gradients:`gradient`,typography:`typography`,text:`typography`,cubicbezier:`cubicBezier`,easing:`cubicBezier`,ease:`cubicBezier`},$e=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,et=/^rgba?\(\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,tt=/^hsla?\(\s*([+\d.]+)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,nt=/^oklch\(\s*([+\d.]+%?|none)\s+([+\d.]+|none)\s+([+\d.]+|none)(?:\s*\/\s*([+\d.]+%?))?\s*\)$/i,rt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(px|rem|em|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc)$/i,it=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(ms|s)$/i,at=/^cubic-bezier\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*\)$/i,ot=/^var\(\s*(--[\w-]+)\s*(?:,\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))?\)\s*$/i,st=/^\{[^{}]+\}$/,ct={thin:100,hairline:100,extralight:200,"extra-light":200,ultralight:200,light:300,normal:400,regular:400,book:400,medium:500,semibold:600,"semi-bold":600,demibold:600,bold:700,extrabold:800,"extra-bold":800,ultrabold:800,black:900,heavy:900},B=new Set([`px`,`rem`]);function V(e){return Math.min(1,Math.max(0,e))}function H(e,t=100){let n=e.trim();if(n.endsWith(`%`))return V(Number.parseFloat(n)/t);let r=Number.parseFloat(n);return V(r>1?r/255:r)}function lt(e){let t=e.slice(1);return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:(e.length===7||e.length,e)}function ut(e){let t=lt(e.toLowerCase()).slice(1),n=Number.parseInt(t.slice(0,2),16)/255,r=Number.parseInt(t.slice(2,4),16)/255,i=Number.parseInt(t.slice(4,6),16)/255,a=t.length===8?Number.parseInt(t.slice(6,8),16)/255:void 0;return{colorSpace:`srgb`,components:[n,r,i],...a===void 0||a===1?{}:{alpha:a},hex:`#${t.slice(0,6)}`}}function dt(e){return`{${e.replace(/^--/,``).split(`-`).filter(Boolean).join(`.`)}}`}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function G(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.toLowerCase();if(!n)continue;let r=Qe[n];if(r)return r}}function K(e,t=[]){let n=G(t);if(typeof e==`string`){let r=e.trim();if(st.test(r))return{value:r,type:n};let i=r.match(ot);if(i?.[1])return{value:dt(i[1]),type:n};if($e.test(r))return{value:ut(r),type:`color`};let a=r.match(et);if(a){let e=[H(a[1]),H(a[2]),H(a[3])],t=a[4]?a[4].endsWith(`%`)?V(Number.parseFloat(a[4])/100):V(Number.parseFloat(a[4])):void 0;return{value:{colorSpace:`srgb`,components:e,...t===void 0||Number.isNaN(t)?{}:{alpha:t}},type:`color`}}let o=r.match(tt);if(o)return{value:{colorSpace:`hsl`,components:[Number.parseFloat(o[1]),Number.parseFloat(o[2]),Number.parseFloat(o[3])],...o[4]?{alpha:o[4].endsWith(`%`)?V(Number.parseFloat(o[4])/100):V(Number.parseFloat(o[4]))}:{}},type:`color`};let s=r.match(nt);if(s){let e=e=>e===`none`?`none`:e.endsWith(`%`)?Number.parseFloat(e)/100:Number.parseFloat(e);return{value:{colorSpace:`oklch`,components:[e(s[1]),e(s[2]),e(s[3])],...s[4]?{alpha:s[4].endsWith(`%`)?V(Number.parseFloat(s[4])/100):V(Number.parseFloat(s[4]))}:{}},type:`color`}}let c=r.match(rt);if(c){let e=c[2].toLowerCase(),t=Number.parseFloat(c[1]);return B.has(e)?{value:{value:t,unit:e},type:`dimension`}:{value:r,type:n===`dimension`?void 0:n}}let l=r.match(it);if(l)return{value:{value:Number.parseFloat(l[1]),unit:l[2].toLowerCase()},type:`duration`};let u=r.match(at);if(u)return{value:[Number.parseFloat(u[1]),Number.parseFloat(u[2]),Number.parseFloat(u[3]),Number.parseFloat(u[4])],type:`cubicBezier`};let d=ct[r.toLowerCase()];return d===void 0?n===`fontFamily`||/family|font|typeface/i.test(t.at(-1)??``)?r.includes(`,`)?{value:r.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``)),type:`fontFamily`}:{value:r.replace(/^["']|["']$/g,``),type:`fontFamily`}:n===`color`&&!r.startsWith(`{`)?{value:r,type:void 0}:{value:r,type:n}:{value:d,type:`fontWeight`}}if(typeof e==`number`)return n===`fontWeight`?{value:e,type:`fontWeight`}:n===`duration`?{value:{value:e,unit:`ms`},type:`duration`}:n===`dimension`?{value:{value:e,unit:`px`},type:`dimension`}:{value:e,type:n??`number`};if(Array.isArray(e))return e.length===4&&e.every(e=>typeof e==`number`)&&(n===`cubicBezier`||t.some(e=>/ease|bezier/i.test(e)))?{value:e,type:`cubicBezier`}:e.every(e=>typeof e==`string`)?{value:e,type:n??`fontFamily`}:{value:e,type:n};if(U(e)){if(`colorSpace`in e&&`components`in e)return{value:e,type:`color`};if(`value`in e&&`unit`in e){let t=String(e.unit).toLowerCase();return t===`ms`||t===`s`?{value:e,type:`duration`}:B.has(t)?{value:e,type:`dimension`}:{value:e,type:n}}}return{value:e,type:n}}function ft(e,t){let n={...e};if(`value`in n&&!(`$value`in n)&&(n.$value=n.value,delete n.value),`type`in n&&!(`$type`in n)&&(n.$type=n.type,delete n.type),`comment`in n&&!(`$description`in n)&&(n.$description=n.comment,delete n.comment),`description`in n&&!(`$description`in n)&&(n.$description=n.description,delete n.description),`ref`in n&&!(`$ref`in n)&&(n.$ref=n.ref,delete n.ref),`$value`in n){let e=K(n.$value,t);n.$value=e.value,!(`$type`in n)&&e.type&&(n.$type=e.type)}return n}function q(e,t=[]){if(Array.isArray(e))return e.map((e,n)=>q(e,[...t,String(n)]));if(!U(e))return e;if(W(e))return ft(e,t);let n={};for(let[r,i]of Object.entries(e)){if(r.startsWith(`$`)){n[r]=i;continue}n[r]=q(i,[...t,r])}if(!(`$type`in n)){let e=G(t);e&&t.length>0&&(n.$type=e)}return n}function J(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/^--/,``).split(/[-./]/).filter(Boolean);if(e.length===0)continue;let i=t;for(let t=0;t<e.length-1;t++){let n=e[t],r=i[n];U(r)?W(r)&&(i[n]={DEFAULT:r}):i[n]={},i=i[n]}let a=e.at(-1),o=K(r,e),s={$value:o.value,...o.type?{$type:o.type}:{}},c=i[a];U(c)&&!W(c)?c.DEFAULT=s:i[a]=s}return q(t)}const pt=/(--[A-Z_][\w-]*)\s*:\s*([^;}{]+?)(?=\s*(?:;|\}|$))/gi;function mt(e){let t={},n=e.replace(/\/\*[\s\S]*?\*\//g,``);for(let e of n.matchAll(pt)){let n=e[1],r=e[2]?.trim();!n||!r||(t[n]=r)}return J(t)}const Y=`razorwind-infer`;function X(e){if(e==null)return{};if(typeof e!=`object`||Array.isArray(e))throw TypeError(`Token file must parse to a plain object.`);return q(e)}function ht(e){try{return X(T.default.parse(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse JSON token file: ${t}`)}}function gt(e){try{return X((0,oe.parse)(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse YAML token file: ${t}`)}}function _t(e){try{return X((0,ae.parse)(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse TOML token file: ${t}`)}}const vt=[{name:`razorwind-json`,pattern:/\.json[c5]?$/i,parser:({contents:e})=>ht(e)},{name:`razorwind-yaml`,pattern:/\.ya?ml$/i,parser:({contents:e})=>gt(e)},{name:`razorwind-toml`,pattern:/\.toml$/i,parser:({contents:e})=>_t(e)},{name:`razorwind-css`,pattern:/\.css$/i,parser:({contents:e})=>q(mt(e))}];function yt(){return Object.fromEntries(vt.map(({name:e,pattern:t,parser:n})=>[e,{pattern:t,parser:n}]))}function bt(e){return q(e)}function xt(){return{[Y]:bt}}function St(e=d.default){for(let t of vt)e.registerParser(t);e.registerPreprocessor({name:Y,preprocessor:bt})}function Z(e,t){return(0,g.isAbsolute)(t)?t:(0,g.resolve)(e,t)}function Q(e){return/\.([^.]+)$/.exec(e)?.[1]?.toLowerCase()??``}function Ct(e){return z.includes(Q(e))}function wt(e){let t=e.split(/[/\\]/).pop()?.toLowerCase()??``;return t.startsWith(`style-dictionary.config.`)||t.startsWith(`sd.config.`)}function Tt(e){return(0,p.joinPaths)(e,Xe)}function Et(e){let{cwd:t,tokensPath:n,fallbackPaths:r=[]}=e;if(n){let e=Z(t,n);if(!(0,w.existsSync)(e))throw Error(`tokensPath "${n}" does not exist (resolved: ${e}).`);return(0,E.isDirectory)(e)?{resolvedPath:e,source:[Tt(e)],origin:`tokensPath`}:wt(e)?{resolvedPath:e,source:[],origin:`tokensPath`}:{resolvedPath:e,source:[e],origin:`tokensPath`}}for(let e of Ye){let n=Z(t,e);if((0,w.existsSync)(n)){if((0,E.isDirectory)(n))return{resolvedPath:n,source:[Tt(n)],origin:`default`};if(wt(n))return{resolvedPath:n,source:[],origin:`default`};if(Ct(n))return{resolvedPath:n,source:[n],origin:`default`}}}for(let e of r){if(!e)continue;let n=Z(t,e);if(!(!(0,w.existsSync)(n)||(0,E.isDirectory)(n))&&(Ct(n)||Q(n)===`css`))return{resolvedPath:n,source:[n],origin:`fallback`}}return{source:[],origin:`none`}}function Dt(e){return(e.split(/[/\\]/).pop()??``).replace(/\.[^.]+$/,``).match(Ze)?.[1]?.toLowerCase()}let Ot=!1;function kt(){Ot||=(St(d.default),!0)}function At(e){return!e||typeof e!=`object`||Object.keys(e).length===0}async function jt(e){let t=await(0,ie.importModule)(e);return t&&typeof t==`object`&&`default`in t&&t.default?t.default:t}async function Mt(e){kt();let t=new d.default({...e,parsers:[...qe,...e.parsers??[]],preprocessors:[Y,...e.preprocessors??[]],hooks:{...e.hooks,parsers:{...yt(),...e.hooks?.parsers},preprocessors:{...xt(),...e.hooks?.preprocessors}},usesDtcg:e.usesDtcg??!0,platforms:e.platforms??{}});return await t.hasInitialized,t}async function $(e){return e.length===0?{}:(await Mt({source:e})).tokens}async function Nt(e){return(await(0,h.default)(e,{absolute:!0,onlyFiles:!0,unique:!0})).sort()}async function Pt(e){let t=await Nt(e);if(t.length===0)return{};let n=new Map,r=[];for(let e of t){let t=Dt(e);if(t){let r=n.get(t)??[];r.push(e),n.set(t,r)}else r.push(e)}if(n.size<2)return $(e);let i={};if(r.length>0){let e=await $(r);At(e)||(i.base=e)}for(let[e,t]of n)i[e]=await $(t);return i}async function Ft(e){let{splitThemes:t=!0,...n}=e,r=Et(n);return r.resolvedPath&&(0,w.existsSync)(r.resolvedPath)&&/(?:^|[/\\])(?:style-dictionary|sd)\.config\./i.test((0,g.basename)(r.resolvedPath))?(await Mt(await jt(r.resolvedPath))).tokens:r.source.length===0?{}:t?Pt(r.source):$(r.source)}async function It(){try{return await import(`@tailwindcss/node`)}catch(e){throw Error(`Cannot load '@tailwindcss/node'. Install tailwindcss v4 / @tailwindcss/node to extract workspace theme tokens.`,{cause:e})}}function Lt(e,t){return(0,g.isAbsolute)(t)?t:(0,g.resolve)(e,t)}async function Rt(e,t){let n=await he(e,{configCssFile:t??void 0});if(n?.tailwindVersion)return{configured:!!n.tailwindCssFile,version:n.tailwindVersion,cssFile:n.tailwindCssFile,configFile:n.tailwindConfigFile};let[r,i]=await Promise.all([F(e),_e(e,t??void 0)]);return{configured:!!(r&&i),version:r,cssFile:i,configFile:null}}function zt(e,t){for(let n of t){if(!(0,u.isSetString)(n))continue;let t=Lt(e,n);if((0,w.existsSync)(t))return t}return null}async function Bt(e){let{cwd:t,cssPath:n,omitDefaults:r=!1}=e,i=await Rt(t,n);if(!i.configured||i.version!==`v4`)return null;let a=zt(t,[n,i.cssFile]);if(!a)return null;let o=await(0,y.readFile)(a),s=await(await It()).__unstable__loadDesignSystem(o,{base:(0,g.dirname)(a)}),c={};for(let[e,t]of s.theme.entries())r&&(t.options&4)==4||!e.startsWith(`--`)||!t.value||(c[e]=t.value);return Object.keys(c).length===0?null:J(c)}function Vt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}var Ht=(0,c.defineGenerator)({meta:{name:`razorwind`,title:`Razorwind`,description:`A generator that uses Razorwind to generate design system code from design tokens and components.`,version:`1.0`,tags:[`razorwind`,`dtcg`]},schema:Ke,input:async e=>{let{registryPath:t,tokensPath:n}=e,{cwd:r}=(0,c.useExecution)(),i=(0,u.isSetString)(t)?(0,l.findFilePath)(t):r,a=await Re(i)??He({resolvedPaths:{cwd:i}});St(d.default);let o=[a.resolvedPaths?.tailwindCss,a.tailwind?.css],s;if((0,u.isSetString)(n))s=await Ft({cwd:r,tokensPath:n});else{let e=await Rt(r,a.tailwind?.css);e.configured&&e.version===`v4`&&(s=await Bt({cwd:r,cssPath:a.resolvedPaths?.tailwindCss??a.tailwind?.css??e.cssFile})),Vt(s)&&(s=await Ft({cwd:r,fallbackPaths:o}))}return{registry:a,tokens:s??{}}},generator:async(e,t)=>({})});module.exports=Ht;
|
|
6
|
+
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function De(e){let t=[],n=g.default.resolve(e,`pnpm-workspace.yaml`);if((0,b.existsSync)(n)){let e=await(0,y.readFile)(n);t.push(...Ee(e))}let r=(0,p.joinPaths)(e,`package.json`);if((0,b.existsSync)(r))try{let e=(await(0,v.readJsonFile)(r)).workspaces,n=Array.isArray(e)?e:e?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function Oe(e){let t=await De(e),n=new Map;if(!t.length)return n;let r=await(0,h.default)(t.map(e=>g.default.posix.join(e.split(g.default.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=g.default.resolve(e,g.default.dirname(t)),i=(await N(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function ke(e,t){let n=(0,S.getWorkspaceRoot)(e);if(!n)return null;let r=Te.get(n);if(r?.has(t))return r.get(t)??null;let i=await Oe(n);return Te.set(n,i),i.get(t)??null}function Ae(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function je(e){let t=`${e.packageRoot}:${e.packageName}`,n=I.get(t);if(n)return n;let r=(await N(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return I.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=A(n);if(!r)continue;let a=Ae(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:se(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return I.set(t,i),i}async function Me(e,t){let n=we(e);if(!n?.packageName)return null;let r=await ke(t,n.packageName);return r?ce(e,await je(r)):null}async function Ne(e,t){let n=t.cwd??t.baseUrl??(0,S.getWorkspaceRoot)();if(e.startsWith(`#`)){let t=await fe(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await Me(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:Fe(e,t)}function Pe(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function Fe(e,t){let n=(0,ne.createMatchPath)(t.baseUrl||t.cwd||(0,S.getWorkspaceRoot)(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=Ie(e,t.paths??{});return!r&&Pe(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function Ie(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=le(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const Le=(0,ee.cosmiconfig)(`components`,{searchPlaces:[`components.json`]});async function Re(e){let t=await Ve(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,ze(e,t)):null}const L={"@shadcn":`${D}/styles/{style}/{name}.json`};async function ze(e,t){t.registries={...L,...t.registries??{}};let n=await(0,f.loadTsConfig)(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await R(`utils`,t.aliases.utils,e,n),i=await R(`components`,t.aliases.components,e,n),a=t.aliases.ui?await R(`ui`,t.aliases.ui,e,n):g.default.resolve(i??e,`ui`),o=t.aliases.lib?await R(`lib`,t.aliases.lib,e,n):g.default.resolve(r??e,`..`),s=t.aliases.hooks?await R(`hooks`,t.aliases.hooks,e,n):g.default.resolve(i??e,`..`,`hooks`);return Be(e,{components:i,utils:r,ui:a,lib:o,hooks:s}),_.configSchema.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?g.default.resolve(e,t.tailwind.config):``,tailwindCss:g.default.resolve(e,t.tailwind.css),utils:r,components:i,ui:a,lib:o,hooks:s}})}async function R(e,t,n,r){let i=await Ne(t,{...r,cwd:n});if(!i?.path||t.startsWith(`#`)&&i.path===(0,p.joinPaths)(n,t))return null;if(e!==`utils`&&(i.source===`package_imports`||i.source===`workspace_package_exports`)){if(!i.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(i.path))return g.default.dirname(i.path);if(i.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(i.path))return i.path.replace(/\.[^/]+$/,``)}return i.path}function Be(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${m.default.cyan(e)}: ${m.default.cyan(n.join(`, `))}.`,`Configure path aliases in ${m.default.cyan(`tsconfig.json`)} or imports in ${m.default.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
7
|
+
`))}async function Ve(e){try{let t=await Le.search(e);if(!t)return null;let n=_.rawConfigSchema.parse(t.config);if(n.registries){for(let e of Object.keys(n.registries))if(e in L)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return n}catch(t){let n=`${e}/components.json`;throw t instanceof Error&&t.message.includes(`reserved registry`)?t:Error(`Invalid configuration found in ${m.default.cyan(n)}.`)}}function He(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...L}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}const Ue=x.z.object({category:x.z.enum([`block`,`component`,`ui`,`page`]),name:x.z.string(),title:x.z.string(),description:x.z.string().optional(),tags:x.z.array(x.z.string()).optional(),related:x.z.array(x.z.string()).optional(),since:x.z.string().optional(),version:x.z.string().optional(),repository:x.z.string().optional(),homepage:x.z.string().optional(),dependencies:x.z.record(x.z.string(),x.z.string()).optional(),registryDependencies:x.z.record(x.z.string(),x.z.string()).optional(),files:x.z.array(x.z.string()).optional()});x.z.record(x.z.string(),Ue);function We(e){return x.default.unknown().transform((t,n)=>{let r=e.safeParse(t);if(!r.success){for(let e of r.error.issues)n.addIssue({code:`custom`,message:e.message,path:e.path});return x.default.NEVER}return r.data})}const Ge=x.default.union([C.tokensSchema,x.default.record(x.default.string(),C.tokensSchema)]),Ke=x.default.object({registry:We(_.configSchema),tokens:Ge}),qe=[`razorwind-json`,`razorwind-yaml`,`razorwind-toml`,`razorwind-css`],z=[`json`,`json5`,`jsonc`,`yaml`,`yml`,`toml`,`css`,`js`,`mjs`,`cjs`,`ts`,`mts`,`cts`],Je=z.join(`,`),Ye=[`tokens.json`,`tokens.json5`,`tokens.jsonc`,`tokens.yaml`,`tokens.yml`,`tokens.toml`,`tokens.css`,`design-tokens.json`,`design-tokens.yaml`,`design-tokens.yml`,`tokens`,`design-tokens`,`src/tokens`,`src/design-tokens`,`packages/tokens`,`style-dictionary.config.js`,`style-dictionary.config.mjs`,`style-dictionary.config.ts`,`sd.config.js`,`sd.config.mjs`,`sd.config.ts`],Xe=`**/*.{${Je}}`,Ze=/^(light|dark|dim|high-contrast|hc|default|base|theme)([._-].+)?$/i,Qe={color:`color`,colours:`color`,colors:`color`,colour:`color`,palette:`color`,bg:`color`,background:`color`,foreground:`color`,fg:`color`,border:`color`,fill:`color`,stroke:`color`,spacing:`dimension`,space:`dimension`,size:`dimension`,sizes:`dimension`,sizing:`dimension`,gap:`dimension`,radius:`dimension`,radii:`dimension`,rounded:`dimension`,width:`dimension`,height:`dimension`,dimension:`dimension`,dimensions:`dimension`,duration:`duration`,durations:`duration`,time:`duration`,delay:`duration`,animation:`duration`,motion:`duration`,transition:`duration`,font:`fontFamily`,fonts:`fontFamily`,fontfamily:`fontFamily`,"font-family":`fontFamily`,typeface:`fontFamily`,fontweight:`fontWeight`,"font-weight":`fontWeight`,weight:`fontWeight`,opacity:`number`,opacities:`number`,zindex:`number`,"z-index":`number`,lineheight:`number`,"line-height":`number`,letterspacing:`dimension`,"letter-spacing":`dimension`,shadow:`shadow`,shadows:`shadow`,elevation:`shadow`,gradient:`gradient`,gradients:`gradient`,typography:`typography`,text:`typography`,cubicbezier:`cubicBezier`,easing:`cubicBezier`,ease:`cubicBezier`},$e=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,et=/^rgba?\(\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,tt=/^hsla?\(\s*([+\d.]+)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,nt=/^oklch\(\s*([+\d.]+%?|none)\s+([+\d.]+|none)\s+([+\d.]+|none)(?:\s*\/\s*([+\d.]+%?))?\s*\)$/i,rt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(px|rem|em|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc)$/i,it=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(ms|s)$/i,at=/^cubic-bezier\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*\)$/i,ot=/^var\(\s*(--[\w-]+)\s*(?:,\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))?\)\s*$/i,st=/^\{[^{}]+\}$/,ct={thin:100,hairline:100,extralight:200,"extra-light":200,ultralight:200,light:300,normal:400,regular:400,book:400,medium:500,semibold:600,"semi-bold":600,demibold:600,bold:700,extrabold:800,"extra-bold":800,ultrabold:800,black:900,heavy:900},B=new Set([`px`,`rem`]);function V(e){return Math.min(1,Math.max(0,e))}function H(e,t=100){let n=e.trim();if(n.endsWith(`%`))return V(Number.parseFloat(n)/t);let r=Number.parseFloat(n);return V(r>1?r/255:r)}function lt(e){let t=e.slice(1);return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:(e.length===7||e.length,e)}function ut(e){let t=lt(e.toLowerCase()).slice(1),n=Number.parseInt(t.slice(0,2),16)/255,r=Number.parseInt(t.slice(2,4),16)/255,i=Number.parseInt(t.slice(4,6),16)/255,a=t.length===8?Number.parseInt(t.slice(6,8),16)/255:void 0;return{colorSpace:`srgb`,components:[n,r,i],...a===void 0||a===1?{}:{alpha:a},hex:`#${t.slice(0,6)}`}}function dt(e){return`{${e.replace(/^--/,``).split(`-`).filter(Boolean).join(`.`)}}`}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function G(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.toLowerCase();if(!n)continue;let r=Qe[n];if(r)return r}}function K(e,t=[]){let n=G(t);if(typeof e==`string`){let r=e.trim();if(st.test(r))return{value:r,type:n};let i=r.match(ot);if(i?.[1])return{value:dt(i[1]),type:n};if($e.test(r))return{value:ut(r),type:`color`};let a=r.match(et);if(a){let e=[H(a[1]),H(a[2]),H(a[3])],t=a[4]?a[4].endsWith(`%`)?V(Number.parseFloat(a[4])/100):V(Number.parseFloat(a[4])):void 0;return{value:{colorSpace:`srgb`,components:e,...t===void 0||Number.isNaN(t)?{}:{alpha:t}},type:`color`}}let o=r.match(tt);if(o)return{value:{colorSpace:`hsl`,components:[Number.parseFloat(o[1]),Number.parseFloat(o[2]),Number.parseFloat(o[3])],...o[4]?{alpha:o[4].endsWith(`%`)?V(Number.parseFloat(o[4])/100):V(Number.parseFloat(o[4]))}:{}},type:`color`};let s=r.match(nt);if(s){let e=e=>e===`none`?`none`:e.endsWith(`%`)?Number.parseFloat(e)/100:Number.parseFloat(e);return{value:{colorSpace:`oklch`,components:[e(s[1]),e(s[2]),e(s[3])],...s[4]?{alpha:s[4].endsWith(`%`)?V(Number.parseFloat(s[4])/100):V(Number.parseFloat(s[4]))}:{}},type:`color`}}let c=r.match(rt);if(c){let e=c[2].toLowerCase(),t=Number.parseFloat(c[1]);return B.has(e)?{value:{value:t,unit:e},type:`dimension`}:{value:r,type:n===`dimension`?void 0:n}}let l=r.match(it);if(l)return{value:{value:Number.parseFloat(l[1]),unit:l[2].toLowerCase()},type:`duration`};let u=r.match(at);if(u)return{value:[Number.parseFloat(u[1]),Number.parseFloat(u[2]),Number.parseFloat(u[3]),Number.parseFloat(u[4])],type:`cubicBezier`};let d=ct[r.toLowerCase()];return d===void 0?n===`fontFamily`||/family|font|typeface/i.test(t.at(-1)??``)?r.includes(`,`)?{value:r.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``)),type:`fontFamily`}:{value:r.replace(/^["']|["']$/g,``),type:`fontFamily`}:n===`color`&&!r.startsWith(`{`)?{value:r,type:void 0}:{value:r,type:n}:{value:d,type:`fontWeight`}}if(typeof e==`number`)return n===`fontWeight`?{value:e,type:`fontWeight`}:n===`duration`?{value:{value:e,unit:`ms`},type:`duration`}:n===`dimension`?{value:{value:e,unit:`px`},type:`dimension`}:{value:e,type:n??`number`};if(Array.isArray(e))return e.length===4&&e.every(e=>typeof e==`number`)&&(n===`cubicBezier`||t.some(e=>/ease|bezier/i.test(e)))?{value:e,type:`cubicBezier`}:e.every(e=>typeof e==`string`)?{value:e,type:n??`fontFamily`}:{value:e,type:n};if(U(e)){if(`colorSpace`in e&&`components`in e)return{value:e,type:`color`};if(`value`in e&&`unit`in e){let t=String(e.unit).toLowerCase();return t===`ms`||t===`s`?{value:e,type:`duration`}:B.has(t)?{value:e,type:`dimension`}:{value:e,type:n}}}return{value:e,type:n}}function ft(e,t){let n={...e};if(`value`in n&&!(`$value`in n)&&(n.$value=n.value,delete n.value),`type`in n&&!(`$type`in n)&&(n.$type=n.type,delete n.type),`comment`in n&&!(`$description`in n)&&(n.$description=n.comment,delete n.comment),`description`in n&&!(`$description`in n)&&(n.$description=n.description,delete n.description),`ref`in n&&!(`$ref`in n)&&(n.$ref=n.ref,delete n.ref),`$value`in n){let e=K(n.$value,t);n.$value=e.value,!(`$type`in n)&&e.type&&(n.$type=e.type)}return n}function q(e,t=[]){if(Array.isArray(e))return e.map((e,n)=>q(e,[...t,String(n)]));if(!U(e))return e;if(W(e))return ft(e,t);let n={};for(let[r,i]of Object.entries(e)){if(r.startsWith(`$`)){n[r]=i;continue}n[r]=q(i,[...t,r])}if(!(`$type`in n)){let e=G(t);e&&t.length>0&&(n.$type=e)}return n}function J(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/^--/,``).split(/[-./]/).filter(Boolean);if(e.length===0)continue;let i=t;for(let t=0;t<e.length-1;t++){let n=e[t],r=i[n];U(r)?W(r)&&(i[n]={DEFAULT:r}):i[n]={},i=i[n]}let a=e.at(-1),o=K(r,e),s={$value:o.value,...o.type?{$type:o.type}:{}},c=i[a];U(c)&&!W(c)?c.DEFAULT=s:i[a]=s}return q(t)}const pt=/(--[A-Z_][\w-]*)\s*:\s*([^;}{]+?)(?=\s*(?:;|\}|$))/gi;function mt(e){let t={},n=e.replace(/\/\*[\s\S]*?\*\//g,``);for(let e of n.matchAll(pt)){let n=e[1],r=e[2]?.trim();!n||!r||(t[n]=r)}return J(t)}const Y=`razorwind-infer`;function X(e){if(e==null)return{};if(typeof e!=`object`||Array.isArray(e))throw TypeError(`Token file must parse to a plain object.`);return q(e)}function ht(e){try{return X(T.default.parse(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse JSON token file: ${t}`)}}function gt(e){try{return X((0,oe.parse)(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse YAML token file: ${t}`)}}function _t(e){try{return X((0,ae.parse)(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse TOML token file: ${t}`)}}const vt=[{name:`razorwind-json`,pattern:/\.json[c5]?$/i,parser:({contents:e})=>ht(e)},{name:`razorwind-yaml`,pattern:/\.ya?ml$/i,parser:({contents:e})=>gt(e)},{name:`razorwind-toml`,pattern:/\.toml$/i,parser:({contents:e})=>_t(e)},{name:`razorwind-css`,pattern:/\.css$/i,parser:({contents:e})=>q(mt(e))}];function yt(){return Object.fromEntries(vt.map(({name:e,pattern:t,parser:n})=>[e,{pattern:t,parser:n}]))}function bt(e){return q(e)}function xt(){return{[Y]:bt}}function St(e=d.default){for(let t of vt)e.registerParser(t);e.registerPreprocessor({name:Y,preprocessor:bt})}function Z(e,t){return(0,g.isAbsolute)(t)?t:(0,g.resolve)(e,t)}function Q(e){return/\.([^.]+)$/.exec(e)?.[1]?.toLowerCase()??``}function Ct(e){return z.includes(Q(e))}function wt(e){let t=e.split(/[/\\]/).pop()?.toLowerCase()??``;return t.startsWith(`style-dictionary.config.`)||t.startsWith(`sd.config.`)}function Tt(e){return(0,p.joinPaths)(e,Xe)}function Et(e){let{cwd:t,tokensPath:n,fallbackPaths:r=[]}=e;if(n){let e=Z(t,n);if(!(0,w.existsSync)(e))throw Error(`tokensPath "${n}" does not exist (resolved: ${e}).`);return(0,E.isDirectory)(e)?{resolvedPath:e,source:[Tt(e)],origin:`tokensPath`}:wt(e)?{resolvedPath:e,source:[],origin:`tokensPath`}:{resolvedPath:e,source:[e],origin:`tokensPath`}}for(let e of Ye){let n=Z(t,e);if((0,w.existsSync)(n)){if((0,E.isDirectory)(n))return{resolvedPath:n,source:[Tt(n)],origin:`default`};if(wt(n))return{resolvedPath:n,source:[],origin:`default`};if(Ct(n))return{resolvedPath:n,source:[n],origin:`default`}}}for(let e of r){if(!e)continue;let n=Z(t,e);if(!(!(0,w.existsSync)(n)||(0,E.isDirectory)(n))&&(Ct(n)||Q(n)===`css`))return{resolvedPath:n,source:[n],origin:`fallback`}}return{source:[],origin:`none`}}function Dt(e){return(e.split(/[/\\]/).pop()??``).replace(/\.[^.]+$/,``).match(Ze)?.[1]?.toLowerCase()}let Ot=!1;function kt(){Ot||=(St(d.default),!0)}function At(e){return!e||typeof e!=`object`||Object.keys(e).length===0}async function jt(e){let t=await(0,ie.importModule)(e);return t&&typeof t==`object`&&`default`in t&&t.default?t.default:t}async function Mt(e){kt();let t=new d.default({...e,parsers:[...qe,...e.parsers??[]],preprocessors:[Y,...e.preprocessors??[]],hooks:{...e.hooks,parsers:{...yt(),...e.hooks?.parsers},preprocessors:{...xt(),...e.hooks?.preprocessors}},usesDtcg:e.usesDtcg??!0,platforms:e.platforms??{}});return await t.hasInitialized,t}async function $(e){return e.length===0?{}:(await Mt({source:e})).tokens}async function Nt(e){return(await(0,h.default)(e,{absolute:!0,onlyFiles:!0,unique:!0})).sort()}async function Pt(e){let t=await Nt(e);if(t.length===0)return{};let n=new Map,r=[];for(let e of t){let t=Dt(e);if(t){let r=n.get(t)??[];r.push(e),n.set(t,r)}else r.push(e)}if(n.size<2)return $(e);let i={};if(r.length>0){let e=await $(r);At(e)||(i.base=e)}for(let[e,t]of n)i[e]=await $(t);return i}async function Ft(e){let{splitThemes:t=!0,...n}=e,r=Et(n);return r.resolvedPath&&(0,w.existsSync)(r.resolvedPath)&&/(?:^|[/\\])(?:style-dictionary|sd)\.config\./i.test((0,g.basename)(r.resolvedPath))?(await Mt(await jt(r.resolvedPath))).tokens:r.source.length===0?{}:t?Pt(r.source):$(r.source)}async function It(){try{return await import(`@tailwindcss/node`)}catch(e){throw Error(`Cannot load '@tailwindcss/node'. Install tailwindcss v4 / @tailwindcss/node to extract workspace theme tokens.`,{cause:e})}}function Lt(e,t){return(0,g.isAbsolute)(t)?t:(0,g.resolve)(e,t)}async function Rt(e,t){let n=await he(e,{configCssFile:t??void 0});if(n?.tailwindVersion)return{configured:!!n.tailwindCssFile,version:n.tailwindVersion,cssFile:n.tailwindCssFile,configFile:n.tailwindConfigFile};let[r,i]=await Promise.all([F(e),_e(e,t??void 0)]);return{configured:!!(r&&i),version:r,cssFile:i,configFile:null}}function zt(e,t){for(let n of t){if(!(0,u.isSetString)(n))continue;let t=Lt(e,n);if((0,w.existsSync)(t))return t}return null}async function Bt(e){let{cwd:t,cssPath:n,omitDefaults:r=!1}=e,i=await Rt(t,n);if(!i.configured||i.version!==`v4`)return null;let a=zt(t,[n,i.cssFile]);if(!a)return null;let o=await(0,y.readFile)(a),s=await(await It()).__unstable__loadDesignSystem(o,{base:(0,g.dirname)(a)}),c={};for(let[e,t]of s.theme.entries())r&&(t.options&4)==4||!e.startsWith(`--`)||!t.value||(c[e]=t.value);return Object.keys(c).length===0?null:J(c)}function Vt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}var Ht=(0,c.defineGenerator)({meta:{name:`razorwind`,title:`Razorwind`,description:`A generator that uses Razorwind to generate design system code from design tokens and components.`,version:`1.0`,tags:[`razorwind`,`dtcg`]},schema:(0,c.defineSchema)({schema:Ke}),input:async e=>{let{registryPath:t,tokensPath:n}=e,{cwd:r}=(0,c.useExecution)(),i=(0,u.isSetString)(t)?(0,l.findFilePath)(t):r,a=await Re(i)??He({resolvedPaths:{cwd:i}});St(d.default);let o=[a.resolvedPaths?.tailwindCss,a.tailwind?.css],s;if((0,u.isSetString)(n))s=await Ft({cwd:r,tokensPath:n});else{let e=await Rt(r,a.tailwind?.css);e.configured&&e.version===`v4`&&(s=await Bt({cwd:r,cssPath:a.resolvedPaths?.tailwindCss??a.tailwind?.css??e.cssFile})),Vt(s)&&(s=await Ft({cwd:r,fallbackPaths:o}))}return{registry:a,tokens:s??{}}},generator:async(e,t)=>({})});module.exports=Ht;
|
package/dist/generator.d.cts
CHANGED
package/dist/generator.d.mts
CHANGED
package/dist/generator.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{defineGenerator as e,useExecution as
|
|
1
|
+
import{defineGenerator as e,defineSchema as t,useExecution as n}from"@power-plant/core";import{findFilePath as r}from"@stryke/path/find";import{isSetString as i}from"@stryke/type-checks/is-set-string";import a from"style-dictionary";import{loadTsConfig as o}from"@stryke/fs/tsconfig";import{joinPaths as s}from"@stryke/path/join";import c from"chalk";import{cosmiconfig as l}from"cosmiconfig";import u from"fast-glob";import d,{basename as f,dirname as p,isAbsolute as m,resolve as h}from"node:path";import{configSchema as ee,rawConfigSchema as te}from"shadcn/schema";import"shadcn/preset";import{readJsonFile as ne}from"@stryke/fs/json";import{readFile as g}from"@stryke/fs/read-file";import{existsSync as _}from"node:fs";import{access as re}from"node:fs/promises";import v,{z as y}from"zod";import"@stryke/http/fetch";import"@stryke/url/helpers";import{getWorkspaceRoot as b}from"@stryke/fs/get-workspace-root";import{createMatchPath as ie}from"tsconfig-paths";import{isAbsolute as ae}from"@stryke/path/is-type";import{tokensSchema as x}from"@power-plant/dtcg-schema";import{existsSync as S}from"@stryke/fs/exists";import{importModule as oe}from"@stryke/fs/resolve";import se from"json5";import{parse as ce}from"smol-toml";import{parse as le}from"yaml";import{isDirectory as C}from"@stryke/fs/is-file";const w=process.env.REGISTRY_URL??`https://ui.shadcn.com/r`,T=w.replace(/\/r\/?$/,``),E={"next-app":{name:`next-app`,label:`Next.js`,links:{installation:`${T}/docs/installation/next`,tailwind:`https://tailwindcss.com/docs/guides/nextjs`}},"next-pages":{name:`next-pages`,label:`Next.js`,links:{installation:`${T}/docs/installation/next`,tailwind:`https://tailwindcss.com/docs/guides/nextjs`}},remix:{name:`remix`,label:`Remix`,links:{installation:`${T}/docs/installation/remix`,tailwind:`https://tailwindcss.com/docs/guides/remix`}},"react-router":{name:`react-router`,label:`React Router`,links:{installation:`${T}/docs/installation/react-router`,tailwind:`https://tailwindcss.com/docs/installation/framework-guides/react-router`}},vite:{name:`vite`,label:`Vite`,links:{installation:`${T}/docs/installation/vite`,tailwind:`https://tailwindcss.com/docs/guides/vite`}},astro:{name:`astro`,label:`Astro`,links:{installation:`${T}/docs/installation/astro`,tailwind:`https://tailwindcss.com/docs/guides/astro`}},laravel:{name:`laravel`,label:`Laravel`,links:{installation:`${T}/docs/installation/laravel`,tailwind:`https://tailwindcss.com/docs/guides/laravel`}},"tanstack-start":{name:`tanstack-start`,label:`TanStack Start`,links:{installation:`${T}/docs/installation/tanstack`,tailwind:`https://tailwindcss.com/docs/installation/using-postcss`}},gatsby:{name:`gatsby`,label:`Gatsby`,links:{installation:`${T}/docs/installation/gatsby`,tailwind:`https://tailwindcss.com/docs/guides/gatsby`}},expo:{name:`expo`,label:`Expo`,links:{installation:`${T}/docs/installation/expo`,tailwind:`https://www.nativewind.dev/docs/getting-started/installation`}},manual:{name:`manual`,label:`Manual`,links:{installation:`${T}/docs/installation/manual`,tailwind:`https://tailwindcss.com/docs/installation`}}};function ue(e){let t=[e];for(;t.length;){let e=t.shift();if(typeof e==`string`){if(e.startsWith(`./`))return e;continue}if(Array.isArray(e)){t.unshift(...e);continue}e&&typeof e==`object`&&t.unshift(...Object.values(e))}return null}function de(e){if(!e.includes(`*`))return`strip_extension`;let t=e.slice(e.indexOf(`*`)+1);return t&&/^\.[^/]+$/.test(t)?`strip_extension`:`preserve_extension`}function D(e,t){let n=t.find(t=>!t.hasWildcard&&t.key===e);if(n)return{path:d.resolve(n.rootDir,n.target),matchedAlias:n.key,matchedTarget:n.target,emitMode:n.emitMode};let r=t.filter(e=>e.hasWildcard).sort((e,t)=>t.key.length-e.key.length);for(let t of r){let n=O(e,t.key,{allowBareAliasBase:!0});if(n!==null)return{path:d.resolve(t.rootDir,fe(t.target,n)),matchedAlias:t.key,matchedTarget:t.target,emitMode:t.emitMode}}return null}function O(e,t,n={}){if(!t.includes(`*`))return e===t?``:null;let[r,i=``]=t.split(`*`);return r&&e.startsWith(r)&&e.endsWith(i)?i?e.slice(r.length,-i.length):e.slice(r.length):n.allowBareAliasBase&&i===``&&r&&r.endsWith(`/`)&&e===r.slice(0,-1)?``:null}function fe(e,t){if(!e.includes(`*`))return e;let[n,r=``]=e.split(`*`);return t?n?`${n}${t}${r}`:t:n?n.replace(/\/$/,``):``}const k=new Map;async function A(e){let t=d.resolve(e),n=k.get(t);if(n)return n;let r=(await j(e))?.imports;if(!r||typeof r!=`object`||Array.isArray(r))return k.set(t,[]),[];let i=[];for(let[e,n]of Object.entries(r)){if(!e.startsWith(`#`))continue;let r=ue(n);r&&i.push({key:e,aliasBase:e===`#*`?`#`:e.endsWith(`/*`)?e.slice(0,-2):e,target:r,emitMode:de(r),hasWildcard:e.includes(`*`),rootDir:t})}return k.set(t,i),i}async function pe(e){let t=(await A(e)).map(e=>e.aliasBase);return t.length?he(t):null}async function me(e,t){return D(e,await A(t))}function he(e){let t=e.map(e=>e.slice(1).split(`/`).filter(Boolean)).reduce((e,t,n)=>n?e.filter((e,n)=>t[n]===e):t,[]);return t.length?`#${t.join(`/`)}`:`#`}async function j(e=``){return ne(d.join(e,`package.json`))}const M=[`**/node_modules/**`,`.next`,`public`,`dist`,`build`],ge=y.object({compilerOptions:y.object({paths:y.record(y.string(),y.string().or(y.array(y.string())))})});async function _e(e,t){let[n,r,i,a,o,c,l,d]=await Promise.all([u.glob(`**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*`,{cwd:e,deep:3,ignore:M}),re(s(e,`src`)).then(()=>!0).catch(()=>!1),Se(e),ye(e),P(e,t?.configCssFile),N(e),xe(e),j(e)]),f=_(s(e,`${r?`src/`:``}app`)),p={framework:E.manual,isSrcDir:r,isRSC:!1,isTsx:i,tailwindConfigFile:a,tailwindCssFile:o,tailwindVersion:c,frameworkVersion:null,aliasPrefix:l.prefix};if(n.find(e=>e.startsWith(`next.config.`))?.length)return p.framework=f?E[`next-app`]:E[`next-pages`],p.isRSC=f,p.frameworkVersion=await ve(p.framework,d),p;if(n.find(e=>e.startsWith(`astro.config.`))?.length)return p.framework=E.astro,p;if(n.find(e=>e.startsWith(`gatsby-config.`))?.length)return p.framework=E.gatsby,p;if(n.find(e=>e.startsWith(`composer.json`))?.length)return p.framework=E.laravel,p;if(Object.keys(d?.dependencies??{}).find(e=>e.startsWith(`@remix-run/`)))return p.framework=E.remix,p;if([...Object.keys(d?.dependencies??{}),...Object.keys(d?.devDependencies??{})].find(e=>e.startsWith(`@tanstack/react-start`)))return p.framework=E[`tanstack-start`],p;if(n.find(e=>e.startsWith(`react-router.config.`))?.length)return p.framework=E[`react-router`],p;if(n.find(e=>e.startsWith(`vite.config.`))?.length)return p.framework=E.vite,p;let m=n.find(e=>e.startsWith(`app.config`));return m?.length&&(await g(s(e,m))).includes(`defineConfig`)?(p.framework=E.vite,p):(d?.dependencies?.expo&&(p.framework=E.expo),p)}async function ve(e,t){if(!t||![`next-app`,`next-pages`].includes(e.name))return null;let n=t.dependencies?.next||t.devDependencies?.next;if(!n)return null;let r=n.match(/^[\^~]?(\d+\.\d+\.\d+)/);if(r)return r[1]??null;let i=n.match(/(\d+\.\d+\.\d+)/);return i?i[1]??null:n}async function N(e){let[t,n]=await Promise.all([j(e),Re(e)]);return n?.tailwind?.config===``?`v4`:!t?.dependencies?.tailwindcss&&!t?.devDependencies?.tailwindcss?null:/^(?:\^|~)?3(?:\.\d+)*(?:-.*)?$/.test(t?.dependencies?.tailwindcss||t?.devDependencies?.tailwindcss||``)?`v3`:`v4`}async function P(e,t){if(t&&_(d.resolve(e,t)))return t;let[n]=await Promise.all([u.glob([`**/*.css`,`**/*.scss`],{cwd:e,deep:5,ignore:M}),N(e)]);if(!n.length)return null;for(let t of n){let n=await g(s(e,t));if(n.includes(`@import "tailwindcss"`)||n.includes(`@import 'tailwindcss'`)||n.includes(`@tailwind base`))return t}return null}async function ye(e){let t=await u.glob(`tailwind.config.*`,{cwd:e,deep:3,ignore:M});return t.length?t[0]??null:null}async function be(e){let t=await Ce(e),n=Object.entries(t?.compilerOptions.paths??{}).length?t?.compilerOptions.paths:null;if(!n||!Object.entries(n).length)return null;for(let[e,t]of Object.entries(n)){let n=Array.isArray(t)?t:[t];if(n.includes(`./*`)||n.includes(`./src/*`)||n.includes(`./app/*`)||n.includes(`./resources/js/*`))return e.replace(/\/\*$/,``)??null}return Object.keys(n)?.[0]?.replace(/\/\*$/,``)??null}async function xe(e){let t=await be(e),n=await pe(e);return n&&t?.startsWith(`#`)?{prefix:n,source:`package_imports`}:t?{prefix:t,source:`tsconfig_paths`}:n?{prefix:n,source:`package_imports`}:{prefix:null,source:null}}async function Se(e){return(await u.glob(`tsconfig.*`,{cwd:e,deep:1,ignore:M})).length>0}async function Ce(e){for(let t of[`tsconfig.json`,`tsconfig.web.json`,`tsconfig.app.json`]){let n=d.resolve(e,t);if(!_(n))continue;let r=await g(n),i;try{i=JSON.parse(we(r))}catch{continue}let a=ge.safeParse(i);if(!a.error)return a.data}return null}function we(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];if(n){if(t+=a,r){r=!1;continue}if(a===`\\`){r=!0;continue}a===`"`&&(n=!1);continue}if(a===`"`){n=!0,t+=a;continue}if(a===`/`&&o===`/`){for(;i<e.length&&e[i]!==`
|
|
2
2
|
`;)i++;i<e.length&&(t+=e[i]);continue}if(a===`/`&&o===`*`){for(i+=2;i<e.length;){if(e[i]===`*`&&e[i+1]===`/`){i++;break}e[i]===`
|
|
3
3
|
`&&(t+=`
|
|
4
4
|
`),i++}continue}if(a===`,`){let t=i+1;for(;t<e.length;){for(;/\s/.test(e[t]??``);)t++;if(e[t]===`/`&&e[t+1]===`/`){for(t+=2;t<e.length&&e[t]!==`
|
|
5
|
-
`&&e[t]!==`\r`;)t++;continue}if(e[t]===`/`&&e[t+1]===`*`){for(t+=2;t<e.length&&(e[t]!==`*`||e[t+1]!==`/`);)t++;t+=2;continue}break}if(e[t]===`}`||e[t]===`]`)continue}t+=a}return t}function
|
|
6
|
-
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function
|
|
7
|
-
`))}async function Be(e){try{let t=await Ie.search(e);if(!t)return null;let n=ee.parse(t.config);if(n.registries){for(let e of Object.keys(n.registries))if(e in L)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return n}catch(t){let n=`${e}/components.json`;throw t instanceof Error&&t.message.includes(`reserved registry`)?t:Error(`Invalid configuration found in ${s.cyan(n)}.`)}}function Ve(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...L}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}const He=b.object({category:b.enum([`block`,`component`,`ui`,`page`]),name:b.string(),title:b.string(),description:b.string().optional(),tags:b.array(b.string()).optional(),related:b.array(b.string()).optional(),since:b.string().optional(),version:b.string().optional(),repository:b.string().optional(),homepage:b.string().optional(),dependencies:b.record(b.string(),b.string()).optional(),registryDependencies:b.record(b.string(),b.string()).optional(),files:b.array(b.string()).optional()});b.record(b.string(),He);function Ue(e){return y.unknown().transform((t,n)=>{let r=e.safeParse(t);if(!r.success){for(let e of r.error.issues)n.addIssue({code:`custom`,message:e.message,path:e.path});return y.NEVER}return r.data})}const We=y.union([S,y.record(y.string(),S)]),Ge=y.object({registry:Ue(h),tokens:We}),Ke=[`razorwind-json`,`razorwind-yaml`,`razorwind-toml`,`razorwind-css`],z=[`json`,`json5`,`jsonc`,`yaml`,`yml`,`toml`,`css`,`js`,`mjs`,`cjs`,`ts`,`mts`,`cts`],qe=z.join(`,`),Je=[`tokens.json`,`tokens.json5`,`tokens.jsonc`,`tokens.yaml`,`tokens.yml`,`tokens.toml`,`tokens.css`,`design-tokens.json`,`design-tokens.yaml`,`design-tokens.yml`,`tokens`,`design-tokens`,`src/tokens`,`src/design-tokens`,`packages/tokens`,`style-dictionary.config.js`,`style-dictionary.config.mjs`,`style-dictionary.config.ts`,`sd.config.js`,`sd.config.mjs`,`sd.config.ts`],Ye=`**/*.{${qe}}`,Xe=/^(light|dark|dim|high-contrast|hc|default|base|theme)([._-].+)?$/i,Ze={color:`color`,colours:`color`,colors:`color`,colour:`color`,palette:`color`,bg:`color`,background:`color`,foreground:`color`,fg:`color`,border:`color`,fill:`color`,stroke:`color`,spacing:`dimension`,space:`dimension`,size:`dimension`,sizes:`dimension`,sizing:`dimension`,gap:`dimension`,radius:`dimension`,radii:`dimension`,rounded:`dimension`,width:`dimension`,height:`dimension`,dimension:`dimension`,dimensions:`dimension`,duration:`duration`,durations:`duration`,time:`duration`,delay:`duration`,animation:`duration`,motion:`duration`,transition:`duration`,font:`fontFamily`,fonts:`fontFamily`,fontfamily:`fontFamily`,"font-family":`fontFamily`,typeface:`fontFamily`,fontweight:`fontWeight`,"font-weight":`fontWeight`,weight:`fontWeight`,opacity:`number`,opacities:`number`,zindex:`number`,"z-index":`number`,lineheight:`number`,"line-height":`number`,letterspacing:`dimension`,"letter-spacing":`dimension`,shadow:`shadow`,shadows:`shadow`,elevation:`shadow`,gradient:`gradient`,gradients:`gradient`,typography:`typography`,text:`typography`,cubicbezier:`cubicBezier`,easing:`cubicBezier`,ease:`cubicBezier`},Qe=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,$e=/^rgba?\(\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,et=/^hsla?\(\s*([+\d.]+)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,tt=/^oklch\(\s*([+\d.]+%?|none)\s+([+\d.]+|none)\s+([+\d.]+|none)(?:\s*\/\s*([+\d.]+%?))?\s*\)$/i,nt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(px|rem|em|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc)$/i,rt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(ms|s)$/i,it=/^cubic-bezier\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*\)$/i,at=/^var\(\s*(--[\w-]+)\s*(?:,\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))?\)\s*$/i,ot=/^\{[^{}]+\}$/,st={thin:100,hairline:100,extralight:200,"extra-light":200,ultralight:200,light:300,normal:400,regular:400,book:400,medium:500,semibold:600,"semi-bold":600,demibold:600,bold:700,extrabold:800,"extra-bold":800,ultrabold:800,black:900,heavy:900},B=new Set([`px`,`rem`]);function V(e){return Math.min(1,Math.max(0,e))}function H(e,t=100){let n=e.trim();if(n.endsWith(`%`))return V(Number.parseFloat(n)/t);let r=Number.parseFloat(n);return V(r>1?r/255:r)}function ct(e){let t=e.slice(1);return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:(e.length===7||e.length,e)}function lt(e){let t=ct(e.toLowerCase()).slice(1),n=Number.parseInt(t.slice(0,2),16)/255,r=Number.parseInt(t.slice(2,4),16)/255,i=Number.parseInt(t.slice(4,6),16)/255,a=t.length===8?Number.parseInt(t.slice(6,8),16)/255:void 0;return{colorSpace:`srgb`,components:[n,r,i],...a===void 0||a===1?{}:{alpha:a},hex:`#${t.slice(0,6)}`}}function ut(e){return`{${e.replace(/^--/,``).split(`-`).filter(Boolean).join(`.`)}}`}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function G(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.toLowerCase();if(!n)continue;let r=Ze[n];if(r)return r}}function K(e,t=[]){let n=G(t);if(typeof e==`string`){let r=e.trim();if(ot.test(r))return{value:r,type:n};let i=r.match(at);if(i?.[1])return{value:ut(i[1]),type:n};if(Qe.test(r))return{value:lt(r),type:`color`};let a=r.match($e);if(a){let e=[H(a[1]),H(a[2]),H(a[3])],t=a[4]?a[4].endsWith(`%`)?V(Number.parseFloat(a[4])/100):V(Number.parseFloat(a[4])):void 0;return{value:{colorSpace:`srgb`,components:e,...t===void 0||Number.isNaN(t)?{}:{alpha:t}},type:`color`}}let o=r.match(et);if(o)return{value:{colorSpace:`hsl`,components:[Number.parseFloat(o[1]),Number.parseFloat(o[2]),Number.parseFloat(o[3])],...o[4]?{alpha:o[4].endsWith(`%`)?V(Number.parseFloat(o[4])/100):V(Number.parseFloat(o[4]))}:{}},type:`color`};let s=r.match(tt);if(s){let e=e=>e===`none`?`none`:e.endsWith(`%`)?Number.parseFloat(e)/100:Number.parseFloat(e);return{value:{colorSpace:`oklch`,components:[e(s[1]),e(s[2]),e(s[3])],...s[4]?{alpha:s[4].endsWith(`%`)?V(Number.parseFloat(s[4])/100):V(Number.parseFloat(s[4]))}:{}},type:`color`}}let c=r.match(nt);if(c){let e=c[2].toLowerCase(),t=Number.parseFloat(c[1]);return B.has(e)?{value:{value:t,unit:e},type:`dimension`}:{value:r,type:n===`dimension`?void 0:n}}let l=r.match(rt);if(l)return{value:{value:Number.parseFloat(l[1]),unit:l[2].toLowerCase()},type:`duration`};let u=r.match(it);if(u)return{value:[Number.parseFloat(u[1]),Number.parseFloat(u[2]),Number.parseFloat(u[3]),Number.parseFloat(u[4])],type:`cubicBezier`};let d=st[r.toLowerCase()];return d===void 0?n===`fontFamily`||/family|font|typeface/i.test(t.at(-1)??``)?r.includes(`,`)?{value:r.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``)),type:`fontFamily`}:{value:r.replace(/^["']|["']$/g,``),type:`fontFamily`}:n===`color`&&!r.startsWith(`{`)?{value:r,type:void 0}:{value:r,type:n}:{value:d,type:`fontWeight`}}if(typeof e==`number`)return n===`fontWeight`?{value:e,type:`fontWeight`}:n===`duration`?{value:{value:e,unit:`ms`},type:`duration`}:n===`dimension`?{value:{value:e,unit:`px`},type:`dimension`}:{value:e,type:n??`number`};if(Array.isArray(e))return e.length===4&&e.every(e=>typeof e==`number`)&&(n===`cubicBezier`||t.some(e=>/ease|bezier/i.test(e)))?{value:e,type:`cubicBezier`}:e.every(e=>typeof e==`string`)?{value:e,type:n??`fontFamily`}:{value:e,type:n};if(U(e)){if(`colorSpace`in e&&`components`in e)return{value:e,type:`color`};if(`value`in e&&`unit`in e){let t=String(e.unit).toLowerCase();return t===`ms`||t===`s`?{value:e,type:`duration`}:B.has(t)?{value:e,type:`dimension`}:{value:e,type:n}}}return{value:e,type:n}}function dt(e,t){let n={...e};if(`value`in n&&!(`$value`in n)&&(n.$value=n.value,delete n.value),`type`in n&&!(`$type`in n)&&(n.$type=n.type,delete n.type),`comment`in n&&!(`$description`in n)&&(n.$description=n.comment,delete n.comment),`description`in n&&!(`$description`in n)&&(n.$description=n.description,delete n.description),`ref`in n&&!(`$ref`in n)&&(n.$ref=n.ref,delete n.ref),`$value`in n){let e=K(n.$value,t);n.$value=e.value,!(`$type`in n)&&e.type&&(n.$type=e.type)}return n}function q(e,t=[]){if(Array.isArray(e))return e.map((e,n)=>q(e,[...t,String(n)]));if(!U(e))return e;if(W(e))return dt(e,t);let n={};for(let[r,i]of Object.entries(e)){if(r.startsWith(`$`)){n[r]=i;continue}n[r]=q(i,[...t,r])}if(!(`$type`in n)){let e=G(t);e&&t.length>0&&(n.$type=e)}return n}function J(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/^--/,``).split(/[-./]/).filter(Boolean);if(e.length===0)continue;let i=t;for(let t=0;t<e.length-1;t++){let n=e[t],r=i[n];U(r)?W(r)&&(i[n]={DEFAULT:r}):i[n]={},i=i[n]}let a=e.at(-1),o=K(r,e),s={$value:o.value,...o.type?{$type:o.type}:{}},c=i[a];U(c)&&!W(c)?c.DEFAULT=s:i[a]=s}return q(t)}const ft=/(--[A-Z_][\w-]*)\s*:\s*([^;}{]+?)(?=\s*(?:;|\}|$))/gi;function pt(e){let t={},n=e.replace(/\/\*[\s\S]*?\*\//g,``);for(let e of n.matchAll(ft)){let n=e[1],r=e[2]?.trim();!n||!r||(t[n]=r)}return J(t)}const Y=`razorwind-infer`;function X(e){if(e==null)return{};if(typeof e!=`object`||Array.isArray(e))throw TypeError(`Token file must parse to a plain object.`);return q(e)}function mt(e){try{return X(ae.parse(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse JSON token file: ${t}`)}}function ht(e){try{return X(se(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse YAML token file: ${t}`)}}function gt(e){try{return X(oe(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse TOML token file: ${t}`)}}const _t=[{name:`razorwind-json`,pattern:/\.json[c5]?$/i,parser:({contents:e})=>mt(e)},{name:`razorwind-yaml`,pattern:/\.ya?ml$/i,parser:({contents:e})=>ht(e)},{name:`razorwind-toml`,pattern:/\.toml$/i,parser:({contents:e})=>gt(e)},{name:`razorwind-css`,pattern:/\.css$/i,parser:({contents:e})=>q(pt(e))}];function vt(){return Object.fromEntries(_t.map(({name:e,pattern:t,parser:n})=>[e,{pattern:t,parser:n}]))}function yt(e){return q(e)}function bt(){return{[Y]:yt}}function xt(e=i){for(let t of _t)e.registerParser(t);e.registerPreprocessor({name:Y,preprocessor:yt})}function Z(e,t){return p(t)?t:m(e,t)}function St(e){return/\.([^.]+)$/.exec(e)?.[1]?.toLowerCase()??``}function Ct(e){return z.includes(St(e))}function Q(e){let t=e.split(/[/\\]/).pop()?.toLowerCase()??``;return t.startsWith(`style-dictionary.config.`)||t.startsWith(`sd.config.`)}function wt(e){return o(e,Ye)}function Tt(e){let{cwd:t,tokensPath:n,fallbackPaths:r=[]}=e;if(n){let e=Z(t,n);if(!C(e))throw Error(`tokensPath "${n}" does not exist (resolved: ${e}).`);return w(e)?{resolvedPath:e,source:[wt(e)],origin:`tokensPath`}:Q(e)?{resolvedPath:e,source:[],origin:`tokensPath`}:{resolvedPath:e,source:[e],origin:`tokensPath`}}for(let e of Je){let n=Z(t,e);if(C(n)){if(w(n))return{resolvedPath:n,source:[wt(n)],origin:`default`};if(Q(n))return{resolvedPath:n,source:[],origin:`default`};if(Ct(n))return{resolvedPath:n,source:[n],origin:`default`}}}for(let e of r){if(!e)continue;let n=Z(t,e);if(!(!C(n)||w(n))&&(Ct(n)||St(n)===`css`))return{resolvedPath:n,source:[n],origin:`fallback`}}return{source:[],origin:`none`}}function Et(e){return(e.split(/[/\\]/).pop()??``).replace(/\.[^.]+$/,``).match(Xe)?.[1]?.toLowerCase()}let Dt=!1;function Ot(){Dt||=(xt(i),!0)}function kt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}async function At(e){let t=await ie(e);return t&&typeof t==`object`&&`default`in t&&t.default?t.default:t}async function jt(e){Ot();let t=new i({...e,parsers:[...Ke,...e.parsers??[]],preprocessors:[Y,...e.preprocessors??[]],hooks:{...e.hooks,parsers:{...vt(),...e.hooks?.parsers},preprocessors:{...bt(),...e.hooks?.preprocessors}},usesDtcg:e.usesDtcg??!0,platforms:e.platforms??{}});return await t.hasInitialized,t}async function $(e){return e.length===0?{}:(await jt({source:e})).tokens}async function Mt(e){return(await l(e,{absolute:!0,onlyFiles:!0,unique:!0})).sort()}async function Nt(e){let t=await Mt(e);if(t.length===0)return{};let n=new Map,r=[];for(let e of t){let t=Et(e);if(t){let r=n.get(t)??[];r.push(e),n.set(t,r)}else r.push(e)}if(n.size<2)return $(e);let i={};if(r.length>0){let e=await $(r);kt(e)||(i.base=e)}for(let[e,t]of n)i[e]=await $(t);return i}async function Pt(e){let{splitThemes:t=!0,...n}=e,r=Tt(n);return r.resolvedPath&&C(r.resolvedPath)&&/(?:^|[/\\])(?:style-dictionary|sd)\.config\./i.test(d(r.resolvedPath))?(await jt(await At(r.resolvedPath))).tokens:r.source.length===0?{}:t?Nt(r.source):$(r.source)}async function Ft(){try{return await import(`@tailwindcss/node`)}catch(e){throw Error(`Cannot load '@tailwindcss/node'. Install tailwindcss v4 / @tailwindcss/node to extract workspace theme tokens.`,{cause:e})}}function It(e,t){return p(t)?t:m(e,t)}async function Lt(e,t){let n=await he(e,{configCssFile:t??void 0});if(n?.tailwindVersion)return{configured:!!n.tailwindCssFile,version:n.tailwindVersion,cssFile:n.tailwindCssFile,configFile:n.tailwindConfigFile};let[r,i]=await Promise.all([P(e),F(e,t??void 0)]);return{configured:!!(r&&i),version:r,cssFile:i,configFile:null}}function Rt(e,t){for(let n of t){if(!r(n))continue;let t=It(e,n);if(C(t))return t}return null}async function zt(e){let{cwd:t,cssPath:n,omitDefaults:r=!1}=e,i=await Lt(t,n);if(!i.configured||i.version!==`v4`)return null;let a=Rt(t,[n,i.cssFile]);if(!a)return null;let o=await _(a),s=await(await Ft()).__unstable__loadDesignSystem(o,{base:f(a)}),c={};for(let[e,t]of s.theme.entries())r&&(t.options&4)==4||!e.startsWith(`--`)||!t.value||(c[e]=t.value);return Object.keys(c).length===0?null:J(c)}function Bt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}var Vt=e({meta:{name:`razorwind`,title:`Razorwind`,description:`A generator that uses Razorwind to generate design system code from design tokens and components.`,version:`1.0`,tags:[`razorwind`,`dtcg`]},schema:Ge,input:async e=>{let{registryPath:a,tokensPath:o}=e,{cwd:s}=t(),c=r(a)?n(a):s,l=await Le(c)??Ve({resolvedPaths:{cwd:c}});xt(i);let u=[l.resolvedPaths?.tailwindCss,l.tailwind?.css],d;if(r(o))d=await Pt({cwd:s,tokensPath:o});else{let e=await Lt(s,l.tailwind?.css);e.configured&&e.version===`v4`&&(d=await zt({cwd:s,cssPath:l.resolvedPaths?.tailwindCss??l.tailwind?.css??e.cssFile})),Bt(d)&&(d=await Pt({cwd:s,fallbackPaths:u}))}return{registry:l,tokens:d??{}}},generator:async(e,t)=>({})});export{Vt as default};
|
|
5
|
+
`&&e[t]!==`\r`;)t++;continue}if(e[t]===`/`&&e[t+1]===`*`){for(t+=2;t<e.length&&(e[t]!==`*`||e[t+1]!==`/`);)t++;t+=2;continue}break}if(e[t]===`}`||e[t]===`]`)continue}t+=a}return t}function Te(e){if(e.startsWith(`#`)||e.startsWith(`.`)||ae(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const F=new Map,I=new Map;function Ee(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
6
|
+
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function De(e){let t=[],n=d.resolve(e,`pnpm-workspace.yaml`);if(_(n)){let e=await g(n);t.push(...Ee(e))}let r=s(e,`package.json`);if(_(r))try{let e=(await ne(r)).workspaces,n=Array.isArray(e)?e:e?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function Oe(e){let t=await De(e),n=new Map;if(!t.length)return n;let r=await u(t.map(e=>d.posix.join(e.split(d.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=d.resolve(e,d.dirname(t)),i=(await j(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function ke(e,t){let n=b(e);if(!n)return null;let r=F.get(n);if(r?.has(t))return r.get(t)??null;let i=await Oe(n);return F.set(n,i),i.get(t)??null}function Ae(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function je(e){let t=`${e.packageRoot}:${e.packageName}`,n=I.get(t);if(n)return n;let r=(await j(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return I.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=ue(n);if(!r)continue;let a=Ae(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:de(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return I.set(t,i),i}async function Me(e,t){let n=Te(e);if(!n?.packageName)return null;let r=await ke(t,n.packageName);return r?D(e,await je(r)):null}async function Ne(e,t){let n=t.cwd??t.baseUrl??b();if(e.startsWith(`#`)){let t=await me(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await Me(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:Fe(e,t)}function Pe(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function Fe(e,t){let n=ie(t.baseUrl||t.cwd||b(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=Ie(e,t.paths??{});return!r&&Pe(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function Ie(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=O(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const Le=l(`components`,{searchPlaces:[`components.json`]});async function Re(e){let t=await Ve(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,ze(e,t)):null}const L={"@shadcn":`${w}/styles/{style}/{name}.json`};async function ze(e,t){t.registries={...L,...t.registries??{}};let n=await o(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await R(`utils`,t.aliases.utils,e,n),i=await R(`components`,t.aliases.components,e,n),a=t.aliases.ui?await R(`ui`,t.aliases.ui,e,n):d.resolve(i??e,`ui`),s=t.aliases.lib?await R(`lib`,t.aliases.lib,e,n):d.resolve(r??e,`..`),c=t.aliases.hooks?await R(`hooks`,t.aliases.hooks,e,n):d.resolve(i??e,`..`,`hooks`);return Be(e,{components:i,utils:r,ui:a,lib:s,hooks:c}),ee.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?d.resolve(e,t.tailwind.config):``,tailwindCss:d.resolve(e,t.tailwind.css),utils:r,components:i,ui:a,lib:s,hooks:c}})}async function R(e,t,n,r){let i=await Ne(t,{...r,cwd:n});if(!i?.path||t.startsWith(`#`)&&i.path===s(n,t))return null;if(e!==`utils`&&(i.source===`package_imports`||i.source===`workspace_package_exports`)){if(!i.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(i.path))return d.dirname(i.path);if(i.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(i.path))return i.path.replace(/\.[^/]+$/,``)}return i.path}function Be(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${c.cyan(e)}: ${c.cyan(n.join(`, `))}.`,`Configure path aliases in ${c.cyan(`tsconfig.json`)} or imports in ${c.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
7
|
+
`))}async function Ve(e){try{let t=await Le.search(e);if(!t)return null;let n=te.parse(t.config);if(n.registries){for(let e of Object.keys(n.registries))if(e in L)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return n}catch(t){let n=`${e}/components.json`;throw t instanceof Error&&t.message.includes(`reserved registry`)?t:Error(`Invalid configuration found in ${c.cyan(n)}.`)}}function He(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...L}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}const Ue=y.object({category:y.enum([`block`,`component`,`ui`,`page`]),name:y.string(),title:y.string(),description:y.string().optional(),tags:y.array(y.string()).optional(),related:y.array(y.string()).optional(),since:y.string().optional(),version:y.string().optional(),repository:y.string().optional(),homepage:y.string().optional(),dependencies:y.record(y.string(),y.string()).optional(),registryDependencies:y.record(y.string(),y.string()).optional(),files:y.array(y.string()).optional()});y.record(y.string(),Ue);function We(e){return v.unknown().transform((t,n)=>{let r=e.safeParse(t);if(!r.success){for(let e of r.error.issues)n.addIssue({code:`custom`,message:e.message,path:e.path});return v.NEVER}return r.data})}const Ge=v.union([x,v.record(v.string(),x)]),Ke=v.object({registry:We(ee),tokens:Ge}),qe=[`razorwind-json`,`razorwind-yaml`,`razorwind-toml`,`razorwind-css`],z=[`json`,`json5`,`jsonc`,`yaml`,`yml`,`toml`,`css`,`js`,`mjs`,`cjs`,`ts`,`mts`,`cts`],Je=z.join(`,`),Ye=[`tokens.json`,`tokens.json5`,`tokens.jsonc`,`tokens.yaml`,`tokens.yml`,`tokens.toml`,`tokens.css`,`design-tokens.json`,`design-tokens.yaml`,`design-tokens.yml`,`tokens`,`design-tokens`,`src/tokens`,`src/design-tokens`,`packages/tokens`,`style-dictionary.config.js`,`style-dictionary.config.mjs`,`style-dictionary.config.ts`,`sd.config.js`,`sd.config.mjs`,`sd.config.ts`],Xe=`**/*.{${Je}}`,Ze=/^(light|dark|dim|high-contrast|hc|default|base|theme)([._-].+)?$/i,Qe={color:`color`,colours:`color`,colors:`color`,colour:`color`,palette:`color`,bg:`color`,background:`color`,foreground:`color`,fg:`color`,border:`color`,fill:`color`,stroke:`color`,spacing:`dimension`,space:`dimension`,size:`dimension`,sizes:`dimension`,sizing:`dimension`,gap:`dimension`,radius:`dimension`,radii:`dimension`,rounded:`dimension`,width:`dimension`,height:`dimension`,dimension:`dimension`,dimensions:`dimension`,duration:`duration`,durations:`duration`,time:`duration`,delay:`duration`,animation:`duration`,motion:`duration`,transition:`duration`,font:`fontFamily`,fonts:`fontFamily`,fontfamily:`fontFamily`,"font-family":`fontFamily`,typeface:`fontFamily`,fontweight:`fontWeight`,"font-weight":`fontWeight`,weight:`fontWeight`,opacity:`number`,opacities:`number`,zindex:`number`,"z-index":`number`,lineheight:`number`,"line-height":`number`,letterspacing:`dimension`,"letter-spacing":`dimension`,shadow:`shadow`,shadows:`shadow`,elevation:`shadow`,gradient:`gradient`,gradients:`gradient`,typography:`typography`,text:`typography`,cubicbezier:`cubicBezier`,easing:`cubicBezier`,ease:`cubicBezier`},$e=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,et=/^rgba?\(\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,tt=/^hsla?\(\s*([+\d.]+)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,nt=/^oklch\(\s*([+\d.]+%?|none)\s+([+\d.]+|none)\s+([+\d.]+|none)(?:\s*\/\s*([+\d.]+%?))?\s*\)$/i,rt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(px|rem|em|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc)$/i,it=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(ms|s)$/i,at=/^cubic-bezier\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*\)$/i,ot=/^var\(\s*(--[\w-]+)\s*(?:,\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))?\)\s*$/i,st=/^\{[^{}]+\}$/,ct={thin:100,hairline:100,extralight:200,"extra-light":200,ultralight:200,light:300,normal:400,regular:400,book:400,medium:500,semibold:600,"semi-bold":600,demibold:600,bold:700,extrabold:800,"extra-bold":800,ultrabold:800,black:900,heavy:900},B=new Set([`px`,`rem`]);function V(e){return Math.min(1,Math.max(0,e))}function H(e,t=100){let n=e.trim();if(n.endsWith(`%`))return V(Number.parseFloat(n)/t);let r=Number.parseFloat(n);return V(r>1?r/255:r)}function lt(e){let t=e.slice(1);return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:(e.length===7||e.length,e)}function ut(e){let t=lt(e.toLowerCase()).slice(1),n=Number.parseInt(t.slice(0,2),16)/255,r=Number.parseInt(t.slice(2,4),16)/255,i=Number.parseInt(t.slice(4,6),16)/255,a=t.length===8?Number.parseInt(t.slice(6,8),16)/255:void 0;return{colorSpace:`srgb`,components:[n,r,i],...a===void 0||a===1?{}:{alpha:a},hex:`#${t.slice(0,6)}`}}function dt(e){return`{${e.replace(/^--/,``).split(`-`).filter(Boolean).join(`.`)}}`}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function G(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.toLowerCase();if(!n)continue;let r=Qe[n];if(r)return r}}function K(e,t=[]){let n=G(t);if(typeof e==`string`){let r=e.trim();if(st.test(r))return{value:r,type:n};let i=r.match(ot);if(i?.[1])return{value:dt(i[1]),type:n};if($e.test(r))return{value:ut(r),type:`color`};let a=r.match(et);if(a){let e=[H(a[1]),H(a[2]),H(a[3])],t=a[4]?a[4].endsWith(`%`)?V(Number.parseFloat(a[4])/100):V(Number.parseFloat(a[4])):void 0;return{value:{colorSpace:`srgb`,components:e,...t===void 0||Number.isNaN(t)?{}:{alpha:t}},type:`color`}}let o=r.match(tt);if(o)return{value:{colorSpace:`hsl`,components:[Number.parseFloat(o[1]),Number.parseFloat(o[2]),Number.parseFloat(o[3])],...o[4]?{alpha:o[4].endsWith(`%`)?V(Number.parseFloat(o[4])/100):V(Number.parseFloat(o[4]))}:{}},type:`color`};let s=r.match(nt);if(s){let e=e=>e===`none`?`none`:e.endsWith(`%`)?Number.parseFloat(e)/100:Number.parseFloat(e);return{value:{colorSpace:`oklch`,components:[e(s[1]),e(s[2]),e(s[3])],...s[4]?{alpha:s[4].endsWith(`%`)?V(Number.parseFloat(s[4])/100):V(Number.parseFloat(s[4]))}:{}},type:`color`}}let c=r.match(rt);if(c){let e=c[2].toLowerCase(),t=Number.parseFloat(c[1]);return B.has(e)?{value:{value:t,unit:e},type:`dimension`}:{value:r,type:n===`dimension`?void 0:n}}let l=r.match(it);if(l)return{value:{value:Number.parseFloat(l[1]),unit:l[2].toLowerCase()},type:`duration`};let u=r.match(at);if(u)return{value:[Number.parseFloat(u[1]),Number.parseFloat(u[2]),Number.parseFloat(u[3]),Number.parseFloat(u[4])],type:`cubicBezier`};let d=ct[r.toLowerCase()];return d===void 0?n===`fontFamily`||/family|font|typeface/i.test(t.at(-1)??``)?r.includes(`,`)?{value:r.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``)),type:`fontFamily`}:{value:r.replace(/^["']|["']$/g,``),type:`fontFamily`}:n===`color`&&!r.startsWith(`{`)?{value:r,type:void 0}:{value:r,type:n}:{value:d,type:`fontWeight`}}if(typeof e==`number`)return n===`fontWeight`?{value:e,type:`fontWeight`}:n===`duration`?{value:{value:e,unit:`ms`},type:`duration`}:n===`dimension`?{value:{value:e,unit:`px`},type:`dimension`}:{value:e,type:n??`number`};if(Array.isArray(e))return e.length===4&&e.every(e=>typeof e==`number`)&&(n===`cubicBezier`||t.some(e=>/ease|bezier/i.test(e)))?{value:e,type:`cubicBezier`}:e.every(e=>typeof e==`string`)?{value:e,type:n??`fontFamily`}:{value:e,type:n};if(U(e)){if(`colorSpace`in e&&`components`in e)return{value:e,type:`color`};if(`value`in e&&`unit`in e){let t=String(e.unit).toLowerCase();return t===`ms`||t===`s`?{value:e,type:`duration`}:B.has(t)?{value:e,type:`dimension`}:{value:e,type:n}}}return{value:e,type:n}}function ft(e,t){let n={...e};if(`value`in n&&!(`$value`in n)&&(n.$value=n.value,delete n.value),`type`in n&&!(`$type`in n)&&(n.$type=n.type,delete n.type),`comment`in n&&!(`$description`in n)&&(n.$description=n.comment,delete n.comment),`description`in n&&!(`$description`in n)&&(n.$description=n.description,delete n.description),`ref`in n&&!(`$ref`in n)&&(n.$ref=n.ref,delete n.ref),`$value`in n){let e=K(n.$value,t);n.$value=e.value,!(`$type`in n)&&e.type&&(n.$type=e.type)}return n}function q(e,t=[]){if(Array.isArray(e))return e.map((e,n)=>q(e,[...t,String(n)]));if(!U(e))return e;if(W(e))return ft(e,t);let n={};for(let[r,i]of Object.entries(e)){if(r.startsWith(`$`)){n[r]=i;continue}n[r]=q(i,[...t,r])}if(!(`$type`in n)){let e=G(t);e&&t.length>0&&(n.$type=e)}return n}function J(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/^--/,``).split(/[-./]/).filter(Boolean);if(e.length===0)continue;let i=t;for(let t=0;t<e.length-1;t++){let n=e[t],r=i[n];U(r)?W(r)&&(i[n]={DEFAULT:r}):i[n]={},i=i[n]}let a=e.at(-1),o=K(r,e),s={$value:o.value,...o.type?{$type:o.type}:{}},c=i[a];U(c)&&!W(c)?c.DEFAULT=s:i[a]=s}return q(t)}const pt=/(--[A-Z_][\w-]*)\s*:\s*([^;}{]+?)(?=\s*(?:;|\}|$))/gi;function mt(e){let t={},n=e.replace(/\/\*[\s\S]*?\*\//g,``);for(let e of n.matchAll(pt)){let n=e[1],r=e[2]?.trim();!n||!r||(t[n]=r)}return J(t)}const Y=`razorwind-infer`;function X(e){if(e==null)return{};if(typeof e!=`object`||Array.isArray(e))throw TypeError(`Token file must parse to a plain object.`);return q(e)}function ht(e){try{return X(se.parse(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse JSON token file: ${t}`)}}function gt(e){try{return X(le(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse YAML token file: ${t}`)}}function _t(e){try{return X(ce(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse TOML token file: ${t}`)}}const vt=[{name:`razorwind-json`,pattern:/\.json[c5]?$/i,parser:({contents:e})=>ht(e)},{name:`razorwind-yaml`,pattern:/\.ya?ml$/i,parser:({contents:e})=>gt(e)},{name:`razorwind-toml`,pattern:/\.toml$/i,parser:({contents:e})=>_t(e)},{name:`razorwind-css`,pattern:/\.css$/i,parser:({contents:e})=>q(mt(e))}];function yt(){return Object.fromEntries(vt.map(({name:e,pattern:t,parser:n})=>[e,{pattern:t,parser:n}]))}function bt(e){return q(e)}function xt(){return{[Y]:bt}}function Z(e=a){for(let t of vt)e.registerParser(t);e.registerPreprocessor({name:Y,preprocessor:bt})}function Q(e,t){return m(t)?t:h(e,t)}function St(e){return/\.([^.]+)$/.exec(e)?.[1]?.toLowerCase()??``}function Ct(e){return z.includes(St(e))}function wt(e){let t=e.split(/[/\\]/).pop()?.toLowerCase()??``;return t.startsWith(`style-dictionary.config.`)||t.startsWith(`sd.config.`)}function Tt(e){return s(e,Xe)}function Et(e){let{cwd:t,tokensPath:n,fallbackPaths:r=[]}=e;if(n){let e=Q(t,n);if(!S(e))throw Error(`tokensPath "${n}" does not exist (resolved: ${e}).`);return C(e)?{resolvedPath:e,source:[Tt(e)],origin:`tokensPath`}:wt(e)?{resolvedPath:e,source:[],origin:`tokensPath`}:{resolvedPath:e,source:[e],origin:`tokensPath`}}for(let e of Ye){let n=Q(t,e);if(S(n)){if(C(n))return{resolvedPath:n,source:[Tt(n)],origin:`default`};if(wt(n))return{resolvedPath:n,source:[],origin:`default`};if(Ct(n))return{resolvedPath:n,source:[n],origin:`default`}}}for(let e of r){if(!e)continue;let n=Q(t,e);if(!(!S(n)||C(n))&&(Ct(n)||St(n)===`css`))return{resolvedPath:n,source:[n],origin:`fallback`}}return{source:[],origin:`none`}}function Dt(e){return(e.split(/[/\\]/).pop()??``).replace(/\.[^.]+$/,``).match(Ze)?.[1]?.toLowerCase()}let Ot=!1;function kt(){Ot||=(Z(a),!0)}function At(e){return!e||typeof e!=`object`||Object.keys(e).length===0}async function jt(e){let t=await oe(e);return t&&typeof t==`object`&&`default`in t&&t.default?t.default:t}async function Mt(e){kt();let t=new a({...e,parsers:[...qe,...e.parsers??[]],preprocessors:[Y,...e.preprocessors??[]],hooks:{...e.hooks,parsers:{...yt(),...e.hooks?.parsers},preprocessors:{...xt(),...e.hooks?.preprocessors}},usesDtcg:e.usesDtcg??!0,platforms:e.platforms??{}});return await t.hasInitialized,t}async function $(e){return e.length===0?{}:(await Mt({source:e})).tokens}async function Nt(e){return(await u(e,{absolute:!0,onlyFiles:!0,unique:!0})).sort()}async function Pt(e){let t=await Nt(e);if(t.length===0)return{};let n=new Map,r=[];for(let e of t){let t=Dt(e);if(t){let r=n.get(t)??[];r.push(e),n.set(t,r)}else r.push(e)}if(n.size<2)return $(e);let i={};if(r.length>0){let e=await $(r);At(e)||(i.base=e)}for(let[e,t]of n)i[e]=await $(t);return i}async function Ft(e){let{splitThemes:t=!0,...n}=e,r=Et(n);return r.resolvedPath&&S(r.resolvedPath)&&/(?:^|[/\\])(?:style-dictionary|sd)\.config\./i.test(f(r.resolvedPath))?(await Mt(await jt(r.resolvedPath))).tokens:r.source.length===0?{}:t?Pt(r.source):$(r.source)}async function It(){try{return await import(`@tailwindcss/node`)}catch(e){throw Error(`Cannot load '@tailwindcss/node'. Install tailwindcss v4 / @tailwindcss/node to extract workspace theme tokens.`,{cause:e})}}function Lt(e,t){return m(t)?t:h(e,t)}async function Rt(e,t){let n=await _e(e,{configCssFile:t??void 0});if(n?.tailwindVersion)return{configured:!!n.tailwindCssFile,version:n.tailwindVersion,cssFile:n.tailwindCssFile,configFile:n.tailwindConfigFile};let[r,i]=await Promise.all([N(e),P(e,t??void 0)]);return{configured:!!(r&&i),version:r,cssFile:i,configFile:null}}function zt(e,t){for(let n of t){if(!i(n))continue;let t=Lt(e,n);if(S(t))return t}return null}async function Bt(e){let{cwd:t,cssPath:n,omitDefaults:r=!1}=e,i=await Rt(t,n);if(!i.configured||i.version!==`v4`)return null;let a=zt(t,[n,i.cssFile]);if(!a)return null;let o=await g(a),s=await(await It()).__unstable__loadDesignSystem(o,{base:p(a)}),c={};for(let[e,t]of s.theme.entries())r&&(t.options&4)==4||!e.startsWith(`--`)||!t.value||(c[e]=t.value);return Object.keys(c).length===0?null:J(c)}function Vt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}var Ht=e({meta:{name:`razorwind`,title:`Razorwind`,description:`A generator that uses Razorwind to generate design system code from design tokens and components.`,version:`1.0`,tags:[`razorwind`,`dtcg`]},schema:t({schema:Ke}),input:async e=>{let{registryPath:t,tokensPath:o}=e,{cwd:s}=n(),c=i(t)?r(t):s,l=await Re(c)??He({resolvedPaths:{cwd:c}});Z(a);let u=[l.resolvedPaths?.tailwindCss,l.tailwind?.css],d;if(i(o))d=await Ft({cwd:s,tokensPath:o});else{let e=await Rt(s,l.tailwind?.css);e.configured&&e.version===`v4`&&(d=await Bt({cwd:s,cssPath:l.resolvedPaths?.tailwindCss??l.tailwind?.css??e.cssFile})),Vt(d)&&(d=await Ft({cwd:s,fallbackPaths:u}))}return{registry:l,tokens:d??{}}},generator:async(e,t)=>({})});export{Ht as default};
|
|
8
8
|
//# sourceMappingURL=generator.mjs.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { configSchema, rawConfigSchema } from "shadcn/schema";
|
|
2
2
|
import z, { z as z$1 } from "zod";
|
|
3
3
|
import { Tokens } from "@power-plant/dtcg-schema";
|
|
4
|
+
import { z as z$2 } from "zod/v3";
|
|
4
5
|
//#region src/registry/shadcn-types.d.ts
|
|
5
|
-
type ShadcnConfig =
|
|
6
|
+
type ShadcnConfig = z$2.infer<typeof configSchema>;
|
|
6
7
|
//#endregion
|
|
7
8
|
//#region src/schema/schema.d.ts
|
|
8
9
|
interface Schema {
|
|
@@ -11,4 +12,4 @@ interface Schema {
|
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
13
14
|
export { Schema as t };
|
|
14
|
-
//# sourceMappingURL=index-
|
|
15
|
+
//# sourceMappingURL=index-8xt23rlo.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-8xt23rlo.d.mts","names":[],"sources":["../src/registry/shadcn-types.ts","../src/schema/schema.ts"],"mappings":""}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "zod";
|
|
2
2
|
import { Tokens } from "@power-plant/dtcg-schema";
|
|
3
3
|
import { configSchema } from "shadcn/schema";
|
|
4
|
+
import { z } from "zod/v3";
|
|
4
5
|
//#region src/registry/shadcn-types.d.ts
|
|
5
|
-
type ShadcnConfig =
|
|
6
|
+
type ShadcnConfig = z.infer<typeof configSchema>;
|
|
6
7
|
//#endregion
|
|
7
8
|
//#region src/schema/schema.d.ts
|
|
8
9
|
interface Schema {
|
|
@@ -11,4 +12,4 @@ interface Schema {
|
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
13
14
|
export { Schema as t };
|
|
14
|
-
//# sourceMappingURL=index-
|
|
15
|
+
//# sourceMappingURL=index-DCXWFAYS.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DCXWFAYS.d.cts","names":[],"sources":["../src/registry/shadcn-types.ts","../src/schema/schema.ts"],"mappings":";;;;;KA2BY,eAAe,EAAG,aAAa;;;UCuB1B;EACf,UAAU;EACV,QAAQ,SAAS,eAAe"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as UserConfigFn, c as UserConfigParams, i as UserConfigExport, n as InputOptions, o as UserConfigFnObject, r as UserConfig, s as UserConfigFnPromise, t as Config } from "./config-CJi9Fu8b.cjs";
|
|
2
2
|
import { defineConfig } from "./config.cjs";
|
|
3
|
-
import { t as Schema } from "./index-
|
|
3
|
+
import { t as Schema } from "./index-DCXWFAYS.cjs";
|
|
4
4
|
import { GeneratorConfig } from "@power-plant/core";
|
|
5
5
|
//#region src/types/base.d.ts
|
|
6
6
|
type Generator<TOptions extends object = object> = GeneratorConfig<Schema, TOptions> & {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as UserConfigFn, c as UserConfigParams, i as UserConfigExport, n as InputOptions, o as UserConfigFnObject, r as UserConfig, s as UserConfigFnPromise, t as Config } from "./config-CJi9Fu8b.mjs";
|
|
2
2
|
import { defineConfig } from "./config.mjs";
|
|
3
|
-
import { t as Schema } from "./index-
|
|
3
|
+
import { t as Schema } from "./index-8xt23rlo.mjs";
|
|
4
4
|
import { GeneratorConfig } from "@power-plant/core";
|
|
5
5
|
//#region src/types/base.d.ts
|
|
6
6
|
type Generator<TOptions extends object = object> = GeneratorConfig<Schema, TOptions> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "💨 Razorwind is a unified set of tools that make creating design systems a breeze.",
|
|
6
6
|
"keywords": ["razorwind", "storm-software"],
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"@stryke/url": "catalog:",
|
|
103
103
|
"@tailwindcss/node": "catalog:",
|
|
104
104
|
"chalk": "catalog:",
|
|
105
|
+
"cosmiconfig": "^9.0.0",
|
|
105
106
|
"fast-glob": "catalog:",
|
|
106
107
|
"json5": "catalog:",
|
|
107
108
|
"lightningcss": "^1.33.0",
|
|
@@ -109,6 +110,7 @@
|
|
|
109
110
|
"smol-toml": "catalog:",
|
|
110
111
|
"style-dictionary": "catalog:",
|
|
111
112
|
"tailwindcss": "catalog:",
|
|
113
|
+
"tsconfig-paths": "^4.2.0",
|
|
112
114
|
"yaml": "catalog:",
|
|
113
115
|
"zod": "catalog:"
|
|
114
116
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-DUwzPMW3.d.mts","names":[],"sources":["../src/registry/shadcn-types.ts","../src/schema/schema.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-UbhspNdK.d.cts","names":[],"sources":["../src/registry/shadcn-types.ts","../src/schema/schema.ts"],"mappings":";;;;KA0BY,uBAAuB;;;UCwBlB;EACf,UAAU;EACV,QAAQ,SAAS,eAAe"}
|