@razorwind/design-md 0.0.4
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/LICENSE +201 -0
- package/README.md +286 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +248 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +248 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
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 -->
|
|
49
|
+
|
|
50
|
+
<!-- END header -->
|
|
51
|
+
|
|
52
|
+
# Razorwind - DESIGN.md Plugin
|
|
53
|
+
|
|
54
|
+
**Razorwind - DESIGN.md** is a package that can create a [DESIGN.md](https://github.com/google-labs-code/design.md) design-system specification file from design tokens or read a DESIGN.md file and return the design-system specification.
|
|
55
|
+
|
|
56
|
+
## Installing
|
|
57
|
+
|
|
58
|
+
Using [pnpm](http://pnpm.io):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pnpm add -D @razorwind/design-md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>Using npm</summary>
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install -D @razorwind/design-md
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary>Using yarn</summary>
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
yarn add -D @razorwind/design-md
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { defineConfig } from "@razorwind/core";
|
|
86
|
+
import designMd from "@razorwind/design-md";
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
plugins: [designMd]
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Options
|
|
94
|
+
|
|
95
|
+
| Option | Default | Description |
|
|
96
|
+
| ------------- | --------------------------- | -------------------------------------------------------- |
|
|
97
|
+
| `outFile` | `"DESIGN.md"` | Output file path (relative to the execution cwd) |
|
|
98
|
+
| `name` | `"Razorwind Design System"` | Design system name written to the YAML front matter |
|
|
99
|
+
| `description` | — | Short description written to the YAML front matter |
|
|
100
|
+
| `version` | `"alpha"` | DESIGN.md spec version written to the YAML front matter |
|
|
101
|
+
| `overview` | Generated summary | Prose for the `## Overview` section |
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
### Building
|
|
106
|
+
|
|
107
|
+
Run `nx build design-md` to build the library.
|
|
108
|
+
|
|
109
|
+
### Running unit tests
|
|
110
|
+
|
|
111
|
+
Run `nx test design-md` to execute the unit tests via [Vitest](https://vitest.dev/).
|
|
112
|
+
|
|
113
|
+
<!-- START footer -->
|
|
114
|
+
<!-- prettier-ignore-start -->
|
|
115
|
+
<!-- markdownlint-disable -->
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## Storm Workspaces
|
|
119
|
+
|
|
120
|
+
Storm workspaces are built using
|
|
121
|
+
<a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools
|
|
122
|
+
for monorepos, which helps you develop like Google, Facebook, and Microsoft.
|
|
123
|
+
Building on top of Nx, the Open System provides a set of tools and patterns that
|
|
124
|
+
help you scale your monorepo to many teams while keeping the codebase
|
|
125
|
+
maintainable.
|
|
126
|
+
|
|
127
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
128
|
+
<br />
|
|
129
|
+
|
|
130
|
+
## Roadmap
|
|
131
|
+
|
|
132
|
+
See the [open issues](https://github.com/storm-software/razorwind/issues) for
|
|
133
|
+
a list of proposed features (and known issues).
|
|
134
|
+
|
|
135
|
+
- [Top Feature Requests](https://github.com/storm-software/razorwind/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc)
|
|
136
|
+
(Add your votes using the 👍 reaction)
|
|
137
|
+
- [Top Bugs](https://github.com/storm-software/razorwind/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc)
|
|
138
|
+
(Add your votes using the 👍 reaction)
|
|
139
|
+
- [Newest Bugs](https://github.com/storm-software/razorwind/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
|
|
140
|
+
|
|
141
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
142
|
+
<br />
|
|
143
|
+
|
|
144
|
+
## Support
|
|
145
|
+
|
|
146
|
+
Reach out to the maintainer at one of the following places:
|
|
147
|
+
|
|
148
|
+
- [Contact](https://stormsoftware.com/contact)
|
|
149
|
+
- [GitHub discussions](https://github.com/storm-software/razorwind/discussions)
|
|
150
|
+
- <support@stormsoftware.com>
|
|
151
|
+
|
|
152
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
153
|
+
<br />
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
This project is licensed under the **Apache License 2.0**. Feel free to edit and
|
|
158
|
+
distribute this template as you like.
|
|
159
|
+
|
|
160
|
+
See [LICENSE](LICENSE) for more information.
|
|
161
|
+
|
|
162
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
163
|
+
<br />
|
|
164
|
+
|
|
165
|
+
## Changelog
|
|
166
|
+
|
|
167
|
+
This project adheres to
|
|
168
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along
|
|
169
|
+
with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md)
|
|
170
|
+
file
|
|
171
|
+
|
|
172
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
173
|
+
<br />
|
|
174
|
+
|
|
175
|
+
## Contributing
|
|
176
|
+
|
|
177
|
+
First off, thanks for taking the time to contribute! Contributions are what
|
|
178
|
+
makes the open-source community such an amazing place to learn, inspire, and
|
|
179
|
+
create. Any contributions you make will benefit everybody else and are **greatly
|
|
180
|
+
appreciated**.
|
|
181
|
+
|
|
182
|
+
Please try to create bug reports that are:
|
|
183
|
+
|
|
184
|
+
- _Reproducible._ Include steps to reproduce the problem.
|
|
185
|
+
- _Specific._ Include as much detail as possible: which version, what
|
|
186
|
+
environment, etc.
|
|
187
|
+
- _Unique._ Do not duplicate existing opened issues.
|
|
188
|
+
- _Scoped to a Single Bug._ One bug per report.
|
|
189
|
+
|
|
190
|
+
Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).
|
|
191
|
+
|
|
192
|
+
You can use
|
|
193
|
+
[markdownlint-cli](https://github.com/storm-software/razorwind/markdownlint-cli)
|
|
194
|
+
to check for common markdown style inconsistency.
|
|
195
|
+
|
|
196
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
197
|
+
<br />
|
|
198
|
+
|
|
199
|
+
## Contributors
|
|
200
|
+
|
|
201
|
+
Thanks goes to these wonderful people
|
|
202
|
+
([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
203
|
+
|
|
204
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
205
|
+
|
|
206
|
+
<table>
|
|
207
|
+
<tbody>
|
|
208
|
+
<tr>
|
|
209
|
+
<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>
|
|
210
|
+
<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>
|
|
211
|
+
<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>
|
|
212
|
+
</tr>
|
|
213
|
+
</tbody>
|
|
214
|
+
<tfoot>
|
|
215
|
+
<tr>
|
|
216
|
+
<td align="center" size="13px" colspan="7">
|
|
217
|
+
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" alt="All Contributors">
|
|
218
|
+
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
|
|
219
|
+
</img>
|
|
220
|
+
</td>
|
|
221
|
+
</tr>
|
|
222
|
+
</tfoot>
|
|
223
|
+
</table>
|
|
224
|
+
|
|
225
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
226
|
+
|
|
227
|
+
This project follows the
|
|
228
|
+
[all-contributors](https://github.com/all-contributors/all-contributors)
|
|
229
|
+
specification. Contributions of any kind welcome!
|
|
230
|
+
|
|
231
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
232
|
+
<br />
|
|
233
|
+
|
|
234
|
+
<hr />
|
|
235
|
+
<br />
|
|
236
|
+
|
|
237
|
+
<div align="center">
|
|
238
|
+
<picture>
|
|
239
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp">
|
|
240
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-light.webp">
|
|
241
|
+
<img src="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp" width="100%" alt="Storm Software" />
|
|
242
|
+
</picture>
|
|
243
|
+
</div>
|
|
244
|
+
<br />
|
|
245
|
+
|
|
246
|
+
<div align="center">
|
|
247
|
+
<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>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div align="center">
|
|
251
|
+
<b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D
|
|
252
|
+
</div>
|
|
253
|
+
<br />
|
|
254
|
+
|
|
255
|
+
Storm Software is an open source software development organization and creator
|
|
256
|
+
of Acidic, StormStack and StormCloud.
|
|
257
|
+
|
|
258
|
+
Our mission is to make software development more accessible. Our ideal future is
|
|
259
|
+
one where anyone can create software without years of prior development
|
|
260
|
+
experience serving as a barrier to entry. We hope to achieve this via LLMs,
|
|
261
|
+
Generative AI, and intuitive, high-level data modeling/programming languages.
|
|
262
|
+
|
|
263
|
+
Join us on [Discord](https://discord.gg/MQ6YVzakM5) to chat with the team,
|
|
264
|
+
receive release notifications, ask questions, and get involved.
|
|
265
|
+
|
|
266
|
+
If this sounds interesting, and you would like to help us in creating the next
|
|
267
|
+
generation of development tools, please reach out on our
|
|
268
|
+
[website](https://stormsoftware.com/contact) or join our
|
|
269
|
+
[Slack channel](https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA)!
|
|
270
|
+
|
|
271
|
+
<br />
|
|
272
|
+
|
|
273
|
+
<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>
|
|
274
|
+
<br />
|
|
275
|
+
<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>
|
|
276
|
+
<br />
|
|
277
|
+
|
|
278
|
+
<div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
|
|
279
|
+
<br />
|
|
280
|
+
<br />
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
<!-- markdownlint-restore -->
|
|
284
|
+
<!-- prettier-ignore-end -->
|
|
285
|
+
|
|
286
|
+
<!-- END footer -->
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@power-plant/core"),t=require("@razorwind/core/plugin"),n=require("@stryke/fs/read-file"),r=require("@stryke/type-checks/is-empty-object"),i=require("@razorwind/core/utils"),a=require("@razorwind/core/tokens"),o=require("@stryke/fs/exists"),s=require("@stryke/path/join"),c=require("yaml");function l(e,t){let n=e.split(`.`).filter(Boolean);for(;n.length>1&&t.includes(n[0].toLowerCase());)n.shift();return n.join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase()}function u(e){if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=String(e);return/^[a-z][\w-]*$/i.test(t)?t:JSON.stringify(t)}function ee(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}const te=/^(?:light|dark|dim|high-contrast|hc|default|base|theme)(?:[._-].+)?$/i;function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function p(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function m(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function h(e){if(`$value`in e)return e.$value;if(`value`in e)return e.value;if(typeof e.$ref==`string`)return e.$ref;if(typeof e.ref==`string`)return e.ref}function g(e,t,n,r,a){if(!d(e))return;let o=m(e,n);if(f(e)){let n=h(e);a.push({path:t.join(`.`),type:o,value:n,cssValue:(0,i.formatTokenValue)(n,o),description:p(e),theme:r});return}for(let[n,i]of Object.entries(e))n.startsWith(`$`)||g(i,[...t,n],o,r,a)}function _(e){if(!d(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));return t.length>0&&t.every(e=>te.test(e))?t.map(t=>({id:t,tokens:e[t]})):[{id:`default`,tokens:e}]}function v(e,t){let n=t?new Set(t):void 0,r=[];for(let t of _(e)){let e=t.id==="default"?void 0:t.id;g(t.tokens,[],void 0,e,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}const y=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),ne={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},re=[`color`,`colors`,`palette`],b=[`typography`,`type`,`text`,`font`,`fonts`],x=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,S=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,C=/^components?$/i,w=/^\{([^}]+)\}$/,T=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e){let t=[...new Set(e.map(e=>e.theme))],n=t.find(e=>e===void 0)??t.find(e=>/^light/i.test(e??``))??t.find(e=>/^(?:default|base)/i.test(e??``))??t[0];return e.filter(e=>e.theme===n)}function O(e){if(typeof e==`string`)return w.exec(e.trim())?.[1]}function k(e,t){let n=e;for(let e=0;e<8;e++){let e=O(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function ie(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function ae(e){let t=ie(e);return y.has(t)?t:ne[t.toLowerCase()]}function oe(e,t){let n={};if(!E(e))return n;for(let r of T){let a=e[r];if(a==null)continue;let o=O(a),s=o?t.get(o):void 0,c=s?k(s,t).cssValue:void 0;if(typeof a==`number`){n[r]=a;continue}n[r]=c??(0,i.formatTokenValue)(a)}return n}function A(e,t={}){let n=D(v(e.tokens)),r=new Map(n.map(e=>[e.path,e])),i={name:t.name??`Razorwind Design System`,description:t.description,version:t.version??`alpha`,colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},a=new Map,o=[];for(let e of n){let t=e.path.split(`.`);if(t[0]&&C.test(t[0])){o.push(e);continue}if(e.type===`color`){let t=l(e.path,re),n=k(e,r);i.colors[t]=n.cssValue,e.description&&(i.colorDescriptions[t]=e.description),a.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=l(e.path,b);i.typography[t]=oe(e.value,r),a.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=l(e.path,b);i.typography[t]??={},i.typography[t].fontFamily=e.cssValue,a.set(e.path,`typography.${t}`);continue}let n=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(n&&x.test(e.path)){let n=t.at(-1);i.rounded[n]=k(e,r).cssValue,a.set(e.path,`rounded.${n}`);continue}if(n&&S.test(e.path)){let n=t.at(-1);i.spacing[n]=k(e,r).cssValue,a.set(e.path,`spacing.${n}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let n=ae(t.at(-1));if(!n)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=O(e.value),c=s?a.get(s):void 0,l=c?`{${c}}`:k(e,r).cssValue;i.components[o]??={},i.components[o][n]=l}return i}function j(e,t,n){let r=Object.entries(t);if(r.length!==0){n.push(`${e}:`);for(let[e,t]of r){if(typeof t==`object`&&t){n.push(` ${e}:`);for(let[e,r]of Object.entries(t))n.push(` ${e}: ${u(r)}`);continue}n.push(` ${e}: ${u(t)}`)}}}function M(e){let t=[`---`];return e.version&&t.push(`version: ${u(e.version)}`),t.push(`name: ${u(e.name)}`),e.description&&t.push(`description: ${u(e.description)}`),j(`colors`,e.colors,t),j(`typography`,e.typography,t),j(`rounded`,e.rounded,t),j(`spacing`,e.spacing,t),j(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
2
|
+
`)}\n`}function N(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
3
|
+
`)}\n`}function P(e){let t=[[Object.keys(e.colors).length,`color`],[Object.keys(e.typography).length,`typography`],[Object.keys(e.rounded).length,`shape`],[Object.keys(e.spacing).length,`spacing`],[Object.keys(e.components).length,`component`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t} token${e===1?``:`s`}`).join(`, `);return`${e.name} design tokens${t?` — ${t}`:``}. The YAML front matter above is the normative source; the prose below explains how to apply it.`}function F(e,t={}){let n=[N(`Overview`,t.overview??P(e))],r=Object.entries(e.colors);r.length>0&&n.push(N(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${ee(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
4
|
+
`)));let i=Object.entries(e.typography);i.length>0&&n.push(N(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
5
|
+
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(N(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
6
|
+
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(N(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
7
|
+
`)));let s=Object.entries(e.components);return s.length>0&&n.push(N(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
8
|
+
`))),n.join(`
|
|
9
|
+
`)}function I(e,t={}){return`${M(e)}\n${F(e,t)}`}function L(e,t={}){let n=t.outFile??`DESIGN.md`,r=A(e,t);return{[n]:{path:n,language:`markdown`,chunks:[{content:I(r,t),meta:{name:`razorwind-design-md`}}]}}}const R=/(?:^|[/\\])design\.md$/i,z=[`DESIGN.md`,`design.md`,`docs/DESIGN.md`],B=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,V=/^\{[^{}]+\}$/,H=new Set([`version`,`name`,`description`]),U=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`,`fontFeature`,`fontVariation`],W={backgroundColor:`color`,textColor:`color`,typography:`typography`,rounded:`dimension`,padding:`dimension`,size:`dimension`,height:`dimension`,width:`dimension`};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`string`&&V.test(e.trim())}function q(e){return typeof e==`number`?`${e}px`:e}function J(e){let t={};for(let n of U){let r=e[n];r!=null&&(t[n]=r)}for(let[n,r]of Object.entries(e))!(n in t)&&r!=null&&(typeof r==`string`||typeof r==`number`)&&(t[n]=r);return t}function Y(e,t,n=!1){let r={};for(let[i,a]of Object.entries(e))a!=null&&(r[i]={$type:t,$value:K(a)?a.trim():n?q(a):a});return r}function se(e){let t={};for(let[n,r]of Object.entries(e))K(r)?t[n]={$type:`typography`,$value:r.trim()}:G(r)&&(t[n]={$type:`typography`,$value:J(r)});return t}function ce(e){let t={};for(let[n,r]of Object.entries(e)){if(!G(r))continue;let e={};for(let[t,n]of Object.entries(r)){if(n==null)continue;let r=W[t];e[t]={...r?{$type:r}:{},$value:K(n)?n.trim():r===`typography`&&G(n)?J(n):q(n)}}Object.keys(e).length>0&&(t[n]=e)}return t}function X(e){let t=B.exec(e);if(!t?.[1])return;let n;try{n=(0,c.parse)(t[1])}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse DESIGN.md front matter as YAML: ${t}`)}return G(n)?n:void 0}function Z(e){let t={};for(let[n,r]of Object.entries(e))if(!(H.has(n)||!G(r)))switch(n){case`colors`:t[n]=Y(r,`color`);break;case`typography`:t[n]=se(r);break;case`rounded`:case`spacing`:t[n]=Y(r,`dimension`,!0);break;case`components`:t[n]=ce(r);break;default:t[n]=r;break}return(0,a.normalizeTokenTree)(t)}function Q(e){let t=X(e);return t?Z(t):{}}function le(e){return R.test(e)}function $(e){for(let t of z){let n=(0,s.joinPaths)(e,t);if((0,o.existsSync)(n))return n}}var ue=(0,t.definePlugin)((t={})=>({name:`razorwind-design-md`,parsers:[{name:`razorwind-design-md`,pattern:R,parser:e=>Q(e)}],extract:async(i,a)=>{if(i.tokens&&!(0,r.isEmptyObject)(i.tokens))return i;let o=t.path;if(!o){let{cwd:t}=(0,e.useExecution)();if(o=$(t),!o)return i}let s=Q(await(0,n.readFile)(o));return!s||(0,r.isEmptyObject)(s)?i:{...i,tokens:s}},generate:async(e,t)=>L(e,t)}));exports.DESIGN_MD_FILE_PATTERN=R,exports.DESIGN_MD_PATH_CANDIDATES=z,exports.default=ue,exports.designMdToTokens=Z,exports.extractDesignMd=A,exports.extractDesignMdFrontMatter=X,exports.flattenTokens=v,Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return i.formatTokenValue}}),exports.generateDesignMd=L,exports.isDesignMdFile=le,exports.parseDesignMdTokens=Q,exports.renderBody=F,exports.renderDesignMd=I,exports.renderFrontMatter=M,exports.resolveDesignMdPath=$,exports.resolveTokenSets=_,exports.selectPrimaryTheme=D,exports.toTokenName=l,exports.toYamlScalar=u;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Schema, Tokens } from "@razorwind/core/schema";
|
|
2
|
+
import { TokenType } from "@power-plant/dtcg-schema";
|
|
3
|
+
import { formatTokenValue } from "@razorwind/core/utils";
|
|
4
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
5
|
+
import { DesignTokens } from "style-dictionary/types";
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Options for the Razorwind DESIGN.md generator.
|
|
9
|
+
*/
|
|
10
|
+
interface Options {
|
|
11
|
+
/**
|
|
12
|
+
* Output file path (relative to the execution cwd).
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue `"DESIGN.md"`
|
|
15
|
+
*/
|
|
16
|
+
outFile?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Design system name written to the YAML front matter.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `"Razorwind Design System"`
|
|
21
|
+
*/
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Short design system description written to the YAML front matter.
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
/**
|
|
28
|
+
* DESIGN.md spec version written to the YAML front matter.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `"alpha"`
|
|
31
|
+
*/
|
|
32
|
+
version?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Prose used for the `## Overview` section. When omitted, a summary is
|
|
35
|
+
* generated from the extracted tokens.
|
|
36
|
+
*/
|
|
37
|
+
overview?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A flattened design token ready for DESIGN.md extraction.
|
|
41
|
+
*/
|
|
42
|
+
interface FlatToken {
|
|
43
|
+
/** Dot-separated token path (e.g. `color.primary`). */
|
|
44
|
+
path: string;
|
|
45
|
+
/** DTCG `$type`, when known. */
|
|
46
|
+
type?: TokenType | string;
|
|
47
|
+
/** Raw `$value` from the token document. */
|
|
48
|
+
value: unknown;
|
|
49
|
+
/** CSS-friendly string form of {@link value}. */
|
|
50
|
+
cssValue: string;
|
|
51
|
+
/** Optional DTCG `$description`. */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
54
|
+
theme?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A DESIGN.md typography token
|
|
58
|
+
* (https://github.com/google-labs-code/design.md — Token Types).
|
|
59
|
+
*/
|
|
60
|
+
interface TypographyToken {
|
|
61
|
+
fontFamily?: string;
|
|
62
|
+
fontSize?: string;
|
|
63
|
+
fontWeight?: string | number;
|
|
64
|
+
lineHeight?: string | number;
|
|
65
|
+
letterSpacing?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A DESIGN.md component token — a map of valid component properties
|
|
69
|
+
* (`backgroundColor`, `textColor`, `typography`, `rounded`, `padding`,
|
|
70
|
+
* `size`, `height`, `width`) to values or `{token.references}`.
|
|
71
|
+
*/
|
|
72
|
+
type ComponentToken = Record<string, string>;
|
|
73
|
+
/**
|
|
74
|
+
* Intermediate representation of a DESIGN.md document, extracted from the
|
|
75
|
+
* Razorwind schema before rendering.
|
|
76
|
+
*/
|
|
77
|
+
interface DesignMdDocument {
|
|
78
|
+
name: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
version?: string;
|
|
81
|
+
colors: Record<string, string>;
|
|
82
|
+
/** Prose descriptions keyed by color token name. */
|
|
83
|
+
colorDescriptions: Record<string, string>;
|
|
84
|
+
typography: Record<string, TypographyToken>;
|
|
85
|
+
rounded: Record<string, string>;
|
|
86
|
+
spacing: Record<string, string>;
|
|
87
|
+
components: Record<string, ComponentToken>;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/extract.d.ts
|
|
91
|
+
/**
|
|
92
|
+
* Select the token set used for the front matter when tokens are split into
|
|
93
|
+
* multiple themes: the un-themed set first, then `light`, then `default`,
|
|
94
|
+
* then whichever theme appears first.
|
|
95
|
+
*/
|
|
96
|
+
declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
97
|
+
/**
|
|
98
|
+
* Extract a DESIGN.md document from the Razorwind schema.
|
|
99
|
+
*
|
|
100
|
+
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
101
|
+
* derived from the DTCG token tree. DTCG aliases are re-emitted as DESIGN.md
|
|
102
|
+
* `{section.token}` references when the target token is part of the output,
|
|
103
|
+
* or resolved to their terminal CSS value otherwise.
|
|
104
|
+
*/
|
|
105
|
+
declare function extractDesignMd(spec: Schema, options?: Options): DesignMdDocument;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/flatten.d.ts
|
|
108
|
+
interface TokenSet {
|
|
109
|
+
id: string;
|
|
110
|
+
tokens: Tokens;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Split `Schema.tokens` into one or more named token sets.
|
|
114
|
+
*
|
|
115
|
+
* A record whose keys all look like themes (`light`, `dark`, …) is treated as
|
|
116
|
+
* multi-theme input; otherwise the whole document is a single set.
|
|
117
|
+
*/
|
|
118
|
+
declare function resolveTokenSets(tokens: Tokens | Record<string, Tokens>): TokenSet[];
|
|
119
|
+
/**
|
|
120
|
+
* Flatten DTCG token trees into extraction rows.
|
|
121
|
+
*/
|
|
122
|
+
declare function flattenTokens(tokens: Tokens | Record<string, Tokens>, includeTypes?: TokenType[]): FlatToken[];
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/format.d.ts
|
|
125
|
+
/**
|
|
126
|
+
* Convert a token path into a DESIGN.md token name.
|
|
127
|
+
*
|
|
128
|
+
* Strips a leading group segment (e.g. `color`, `colors`, `radius`) when it
|
|
129
|
+
* matches the section the token is emitted into, then joins the rest with
|
|
130
|
+
* `-` (DESIGN.md token names are flat kebab-case).
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* toTokenName("color.primary", ["color", "colors"]) // "primary"
|
|
134
|
+
*/
|
|
135
|
+
declare function toTokenName(path: string, stripPrefixes: string[]): string;
|
|
136
|
+
/**
|
|
137
|
+
* Serialize a value as a YAML scalar, quoting when required (values starting
|
|
138
|
+
* with `#`, `{`, containing YAML-significant characters, etc.).
|
|
139
|
+
*/
|
|
140
|
+
declare function toYamlScalar(value: unknown): string;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/generate.d.ts
|
|
143
|
+
/**
|
|
144
|
+
* Render the machine-readable YAML front matter layer of a DESIGN.md file.
|
|
145
|
+
*/
|
|
146
|
+
declare function renderFrontMatter(document: DesignMdDocument): string;
|
|
147
|
+
/**
|
|
148
|
+
* Render the human-readable markdown body of a DESIGN.md file. Sections
|
|
149
|
+
* follow the canonical order defined by the spec (Overview, Colors,
|
|
150
|
+
* Typography, Layout, Shapes, Components); empty sections are omitted.
|
|
151
|
+
*/
|
|
152
|
+
declare function renderBody(document: DesignMdDocument, options?: Options): string;
|
|
153
|
+
/**
|
|
154
|
+
* Render a complete DESIGN.md file — YAML front matter followed by the
|
|
155
|
+
* markdown body.
|
|
156
|
+
*
|
|
157
|
+
* @see https://github.com/google-labs-code/design.md
|
|
158
|
+
*/
|
|
159
|
+
declare function renderDesignMd(document: DesignMdDocument, options?: Options): string;
|
|
160
|
+
/**
|
|
161
|
+
* Generate a DESIGN.md design-system specification file from a Razorwind
|
|
162
|
+
* schema.
|
|
163
|
+
*
|
|
164
|
+
* @see https://github.com/google-labs-code/design.md
|
|
165
|
+
*/
|
|
166
|
+
declare function generateDesignMd(spec: Schema, options?: Options): GeneratorFunctionResult<Schema, Options>;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/load.d.ts
|
|
169
|
+
/**
|
|
170
|
+
* Basename pattern for DESIGN.md spec files
|
|
171
|
+
* (https://github.com/google-labs-code/design.md).
|
|
172
|
+
*/
|
|
173
|
+
declare const DESIGN_MD_FILE_PATTERN: RegExp;
|
|
174
|
+
/** Candidate workspace paths checked for a DESIGN.md spec file. */
|
|
175
|
+
declare const DESIGN_MD_PATH_CANDIDATES: readonly ["DESIGN.md", "design.md", "docs/DESIGN.md"];
|
|
176
|
+
/**
|
|
177
|
+
* Extract the YAML front matter object from DESIGN.md contents.
|
|
178
|
+
*
|
|
179
|
+
* @param contents - The raw DESIGN.md file contents.
|
|
180
|
+
* @returns The parsed front matter, or `undefined` when no front matter fence
|
|
181
|
+
* is present.
|
|
182
|
+
*/
|
|
183
|
+
declare function extractDesignMdFrontMatter(contents: string): Record<string, unknown> | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Convert DESIGN.md front-matter tokens (colors, typography, rounded,
|
|
186
|
+
* spacing, components) into a DTCG design-token tree.
|
|
187
|
+
*
|
|
188
|
+
* DESIGN.md `{path.to.token}` references are preserved verbatim — the group
|
|
189
|
+
* names in the emitted tree match the front-matter section names, so the
|
|
190
|
+
* references resolve as DTCG aliases without rewriting.
|
|
191
|
+
*
|
|
192
|
+
* @see https://github.com/google-labs-code/design.md#the-specification
|
|
193
|
+
*
|
|
194
|
+
* @param frontMatter - The parsed DESIGN.md YAML front matter.
|
|
195
|
+
* @returns The equivalent DTCG token tree.
|
|
196
|
+
*/
|
|
197
|
+
declare function designMdToTokens(frontMatter: Record<string, unknown>): DesignTokens;
|
|
198
|
+
/**
|
|
199
|
+
* Parse DESIGN.md file contents into a DTCG token tree.
|
|
200
|
+
*
|
|
201
|
+
* @param contents - The raw DESIGN.md file contents.
|
|
202
|
+
* @returns The extracted tokens; an empty object when the file has no YAML
|
|
203
|
+
* front matter.
|
|
204
|
+
*/
|
|
205
|
+
declare function parseDesignMdTokens(contents: string): DesignTokens;
|
|
206
|
+
/**
|
|
207
|
+
* Check whether a path points at a DESIGN.md spec file.
|
|
208
|
+
*
|
|
209
|
+
* @param filePath - The file path to test.
|
|
210
|
+
* @returns True when the basename is `DESIGN.md` (case-insensitive).
|
|
211
|
+
*/
|
|
212
|
+
declare function isDesignMdFile(filePath: string): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Resolve the DESIGN.md file for a workspace, if one exists.
|
|
215
|
+
*
|
|
216
|
+
* @param cwd - The workspace root to search from.
|
|
217
|
+
* @returns The absolute path to the first matching candidate, or `undefined`.
|
|
218
|
+
*/
|
|
219
|
+
declare function resolveDesignMdPath(cwd: string): string | undefined;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/index.d.ts
|
|
222
|
+
interface DesignMdPluginOptions {
|
|
223
|
+
/**
|
|
224
|
+
* The path to the DESIGN.md file.
|
|
225
|
+
*
|
|
226
|
+
* @default "DESIGN.md"
|
|
227
|
+
*/
|
|
228
|
+
path?: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Razorwind plugin: load DESIGN.md tokens on extract, emit DESIGN.md on generate.
|
|
232
|
+
*
|
|
233
|
+
* @see https://github.com/google-labs-code/design.md
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* import { defineConfig } from "@razorwind/core";
|
|
238
|
+
* import designMd from "@razorwind/design-md";
|
|
239
|
+
*
|
|
240
|
+
* export default defineConfig({
|
|
241
|
+
* plugins: [designMd()]
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare const _default: any;
|
|
246
|
+
//#endregion
|
|
247
|
+
export { type ComponentToken, DESIGN_MD_FILE_PATTERN, DESIGN_MD_PATH_CANDIDATES, type DesignMdDocument, DesignMdPluginOptions, type FlatToken, type Options, type TypographyToken, _default as default, designMdToTokens, extractDesignMd, extractDesignMdFrontMatter, flattenTokens, formatTokenValue, generateDesignMd, isDesignMdFile, parseDesignMdTokens, renderBody, renderDesignMd, renderFrontMatter, resolveDesignMdPath, resolveTokenSets, selectPrimaryTheme, toTokenName, toYamlScalar };
|
|
248
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/extract.ts","../src/flatten.ts","../src/format.ts","../src/generate.ts","../src/load.ts","../src/index.ts"],"mappings":";;;;;;;;;UAuBiB;;;;;;EAMf;;;;;;EAOA;;;;EAKA;;;;;;EAOA;;;;;EAMA;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;;;;;UAOe;EACf;EACA;EACA;EACA;EACA;;;;;;;KAQU,iBAAiB;;;;;UAMZ;EACf;EACA;EACA;EACA,QAAQ;;EAER,mBAAmB;EACnB,YAAY,eAAe;EAC3B,SAAS;EACT,SAAS;EACT,YAAY,eAAe;;;;;;;;;iBC5Bb,mBAAmB,MAAM,cAAc;;;;;;;;;iBA6GvC,gBACd,MAAM,QACN,UAAS,UACR;;;UCpFc;EACf;EACA,QAAQ;;;;;;;;iBASM,iBACd,QAAQ,SAAS,eAAe,UAC/B;;;;iBAsBa,cACd,QAAQ,SAAS,eAAe,SAChC,eAAe,cACd;;;;;;;;;;;;;iBCpHa,YAAY,cAAc;;;;;iBAoB1B,aAAa;;;;;;iBCIb,kBAAkB,UAAU;;;;;;iBAgD5B,WACd,UAAU,kBACV,UAAS;;;;;;;iBA6FK,eACd,UAAU,kBACV,UAAS;;;;;;;iBAWK,iBACd,MAAM,QACN,UAAS,UACR,wBAAwB,QAAQ;;;;;;;cCzLtB,wBAAsB;;cAGtB;;;;;;;;iBAiLG,2BACd,mBACC;;;;;;;;;;;;;;iBAgCa,iBACd,aAAa,0BACZ;;;;;;;;iBAwCa,oBAAoB,mBAAmB;;;;;;;iBAevC,eAAe;;;;;;;iBAUf,oBAAoB;;;UC7PnB;;;;;;EAMf"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
2
|
+
import { formatTokenValue } from "@razorwind/core/utils";
|
|
3
|
+
import { Schema, Tokens } from "@razorwind/core/schema";
|
|
4
|
+
import { TokenType } from "@power-plant/dtcg-schema";
|
|
5
|
+
import { DesignTokens } from "style-dictionary/types";
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Options for the Razorwind DESIGN.md generator.
|
|
9
|
+
*/
|
|
10
|
+
interface Options {
|
|
11
|
+
/**
|
|
12
|
+
* Output file path (relative to the execution cwd).
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue `"DESIGN.md"`
|
|
15
|
+
*/
|
|
16
|
+
outFile?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Design system name written to the YAML front matter.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `"Razorwind Design System"`
|
|
21
|
+
*/
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Short design system description written to the YAML front matter.
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
/**
|
|
28
|
+
* DESIGN.md spec version written to the YAML front matter.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `"alpha"`
|
|
31
|
+
*/
|
|
32
|
+
version?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Prose used for the `## Overview` section. When omitted, a summary is
|
|
35
|
+
* generated from the extracted tokens.
|
|
36
|
+
*/
|
|
37
|
+
overview?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A flattened design token ready for DESIGN.md extraction.
|
|
41
|
+
*/
|
|
42
|
+
interface FlatToken {
|
|
43
|
+
/** Dot-separated token path (e.g. `color.primary`). */
|
|
44
|
+
path: string;
|
|
45
|
+
/** DTCG `$type`, when known. */
|
|
46
|
+
type?: TokenType | string;
|
|
47
|
+
/** Raw `$value` from the token document. */
|
|
48
|
+
value: unknown;
|
|
49
|
+
/** CSS-friendly string form of {@link value}. */
|
|
50
|
+
cssValue: string;
|
|
51
|
+
/** Optional DTCG `$description`. */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
54
|
+
theme?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A DESIGN.md typography token
|
|
58
|
+
* (https://github.com/google-labs-code/design.md — Token Types).
|
|
59
|
+
*/
|
|
60
|
+
interface TypographyToken {
|
|
61
|
+
fontFamily?: string;
|
|
62
|
+
fontSize?: string;
|
|
63
|
+
fontWeight?: string | number;
|
|
64
|
+
lineHeight?: string | number;
|
|
65
|
+
letterSpacing?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A DESIGN.md component token — a map of valid component properties
|
|
69
|
+
* (`backgroundColor`, `textColor`, `typography`, `rounded`, `padding`,
|
|
70
|
+
* `size`, `height`, `width`) to values or `{token.references}`.
|
|
71
|
+
*/
|
|
72
|
+
type ComponentToken = Record<string, string>;
|
|
73
|
+
/**
|
|
74
|
+
* Intermediate representation of a DESIGN.md document, extracted from the
|
|
75
|
+
* Razorwind schema before rendering.
|
|
76
|
+
*/
|
|
77
|
+
interface DesignMdDocument {
|
|
78
|
+
name: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
version?: string;
|
|
81
|
+
colors: Record<string, string>;
|
|
82
|
+
/** Prose descriptions keyed by color token name. */
|
|
83
|
+
colorDescriptions: Record<string, string>;
|
|
84
|
+
typography: Record<string, TypographyToken>;
|
|
85
|
+
rounded: Record<string, string>;
|
|
86
|
+
spacing: Record<string, string>;
|
|
87
|
+
components: Record<string, ComponentToken>;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/extract.d.ts
|
|
91
|
+
/**
|
|
92
|
+
* Select the token set used for the front matter when tokens are split into
|
|
93
|
+
* multiple themes: the un-themed set first, then `light`, then `default`,
|
|
94
|
+
* then whichever theme appears first.
|
|
95
|
+
*/
|
|
96
|
+
declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
97
|
+
/**
|
|
98
|
+
* Extract a DESIGN.md document from the Razorwind schema.
|
|
99
|
+
*
|
|
100
|
+
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
101
|
+
* derived from the DTCG token tree. DTCG aliases are re-emitted as DESIGN.md
|
|
102
|
+
* `{section.token}` references when the target token is part of the output,
|
|
103
|
+
* or resolved to their terminal CSS value otherwise.
|
|
104
|
+
*/
|
|
105
|
+
declare function extractDesignMd(spec: Schema, options?: Options): DesignMdDocument;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/flatten.d.ts
|
|
108
|
+
interface TokenSet {
|
|
109
|
+
id: string;
|
|
110
|
+
tokens: Tokens;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Split `Schema.tokens` into one or more named token sets.
|
|
114
|
+
*
|
|
115
|
+
* A record whose keys all look like themes (`light`, `dark`, …) is treated as
|
|
116
|
+
* multi-theme input; otherwise the whole document is a single set.
|
|
117
|
+
*/
|
|
118
|
+
declare function resolveTokenSets(tokens: Tokens | Record<string, Tokens>): TokenSet[];
|
|
119
|
+
/**
|
|
120
|
+
* Flatten DTCG token trees into extraction rows.
|
|
121
|
+
*/
|
|
122
|
+
declare function flattenTokens(tokens: Tokens | Record<string, Tokens>, includeTypes?: TokenType[]): FlatToken[];
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/format.d.ts
|
|
125
|
+
/**
|
|
126
|
+
* Convert a token path into a DESIGN.md token name.
|
|
127
|
+
*
|
|
128
|
+
* Strips a leading group segment (e.g. `color`, `colors`, `radius`) when it
|
|
129
|
+
* matches the section the token is emitted into, then joins the rest with
|
|
130
|
+
* `-` (DESIGN.md token names are flat kebab-case).
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* toTokenName("color.primary", ["color", "colors"]) // "primary"
|
|
134
|
+
*/
|
|
135
|
+
declare function toTokenName(path: string, stripPrefixes: string[]): string;
|
|
136
|
+
/**
|
|
137
|
+
* Serialize a value as a YAML scalar, quoting when required (values starting
|
|
138
|
+
* with `#`, `{`, containing YAML-significant characters, etc.).
|
|
139
|
+
*/
|
|
140
|
+
declare function toYamlScalar(value: unknown): string;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/generate.d.ts
|
|
143
|
+
/**
|
|
144
|
+
* Render the machine-readable YAML front matter layer of a DESIGN.md file.
|
|
145
|
+
*/
|
|
146
|
+
declare function renderFrontMatter(document: DesignMdDocument): string;
|
|
147
|
+
/**
|
|
148
|
+
* Render the human-readable markdown body of a DESIGN.md file. Sections
|
|
149
|
+
* follow the canonical order defined by the spec (Overview, Colors,
|
|
150
|
+
* Typography, Layout, Shapes, Components); empty sections are omitted.
|
|
151
|
+
*/
|
|
152
|
+
declare function renderBody(document: DesignMdDocument, options?: Options): string;
|
|
153
|
+
/**
|
|
154
|
+
* Render a complete DESIGN.md file — YAML front matter followed by the
|
|
155
|
+
* markdown body.
|
|
156
|
+
*
|
|
157
|
+
* @see https://github.com/google-labs-code/design.md
|
|
158
|
+
*/
|
|
159
|
+
declare function renderDesignMd(document: DesignMdDocument, options?: Options): string;
|
|
160
|
+
/**
|
|
161
|
+
* Generate a DESIGN.md design-system specification file from a Razorwind
|
|
162
|
+
* schema.
|
|
163
|
+
*
|
|
164
|
+
* @see https://github.com/google-labs-code/design.md
|
|
165
|
+
*/
|
|
166
|
+
declare function generateDesignMd(spec: Schema, options?: Options): GeneratorFunctionResult<Schema, Options>;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/load.d.ts
|
|
169
|
+
/**
|
|
170
|
+
* Basename pattern for DESIGN.md spec files
|
|
171
|
+
* (https://github.com/google-labs-code/design.md).
|
|
172
|
+
*/
|
|
173
|
+
declare const DESIGN_MD_FILE_PATTERN: RegExp;
|
|
174
|
+
/** Candidate workspace paths checked for a DESIGN.md spec file. */
|
|
175
|
+
declare const DESIGN_MD_PATH_CANDIDATES: readonly ["DESIGN.md", "design.md", "docs/DESIGN.md"];
|
|
176
|
+
/**
|
|
177
|
+
* Extract the YAML front matter object from DESIGN.md contents.
|
|
178
|
+
*
|
|
179
|
+
* @param contents - The raw DESIGN.md file contents.
|
|
180
|
+
* @returns The parsed front matter, or `undefined` when no front matter fence
|
|
181
|
+
* is present.
|
|
182
|
+
*/
|
|
183
|
+
declare function extractDesignMdFrontMatter(contents: string): Record<string, unknown> | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Convert DESIGN.md front-matter tokens (colors, typography, rounded,
|
|
186
|
+
* spacing, components) into a DTCG design-token tree.
|
|
187
|
+
*
|
|
188
|
+
* DESIGN.md `{path.to.token}` references are preserved verbatim — the group
|
|
189
|
+
* names in the emitted tree match the front-matter section names, so the
|
|
190
|
+
* references resolve as DTCG aliases without rewriting.
|
|
191
|
+
*
|
|
192
|
+
* @see https://github.com/google-labs-code/design.md#the-specification
|
|
193
|
+
*
|
|
194
|
+
* @param frontMatter - The parsed DESIGN.md YAML front matter.
|
|
195
|
+
* @returns The equivalent DTCG token tree.
|
|
196
|
+
*/
|
|
197
|
+
declare function designMdToTokens(frontMatter: Record<string, unknown>): DesignTokens;
|
|
198
|
+
/**
|
|
199
|
+
* Parse DESIGN.md file contents into a DTCG token tree.
|
|
200
|
+
*
|
|
201
|
+
* @param contents - The raw DESIGN.md file contents.
|
|
202
|
+
* @returns The extracted tokens; an empty object when the file has no YAML
|
|
203
|
+
* front matter.
|
|
204
|
+
*/
|
|
205
|
+
declare function parseDesignMdTokens(contents: string): DesignTokens;
|
|
206
|
+
/**
|
|
207
|
+
* Check whether a path points at a DESIGN.md spec file.
|
|
208
|
+
*
|
|
209
|
+
* @param filePath - The file path to test.
|
|
210
|
+
* @returns True when the basename is `DESIGN.md` (case-insensitive).
|
|
211
|
+
*/
|
|
212
|
+
declare function isDesignMdFile(filePath: string): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Resolve the DESIGN.md file for a workspace, if one exists.
|
|
215
|
+
*
|
|
216
|
+
* @param cwd - The workspace root to search from.
|
|
217
|
+
* @returns The absolute path to the first matching candidate, or `undefined`.
|
|
218
|
+
*/
|
|
219
|
+
declare function resolveDesignMdPath(cwd: string): string | undefined;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/index.d.ts
|
|
222
|
+
interface DesignMdPluginOptions {
|
|
223
|
+
/**
|
|
224
|
+
* The path to the DESIGN.md file.
|
|
225
|
+
*
|
|
226
|
+
* @default "DESIGN.md"
|
|
227
|
+
*/
|
|
228
|
+
path?: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Razorwind plugin: load DESIGN.md tokens on extract, emit DESIGN.md on generate.
|
|
232
|
+
*
|
|
233
|
+
* @see https://github.com/google-labs-code/design.md
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* import { defineConfig } from "@razorwind/core";
|
|
238
|
+
* import designMd from "@razorwind/design-md";
|
|
239
|
+
*
|
|
240
|
+
* export default defineConfig({
|
|
241
|
+
* plugins: [designMd()]
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare const _default: any;
|
|
246
|
+
//#endregion
|
|
247
|
+
export { type ComponentToken, DESIGN_MD_FILE_PATTERN, DESIGN_MD_PATH_CANDIDATES, type DesignMdDocument, DesignMdPluginOptions, type FlatToken, type Options, type TypographyToken, _default as default, designMdToTokens, extractDesignMd, extractDesignMdFrontMatter, flattenTokens, formatTokenValue, generateDesignMd, isDesignMdFile, parseDesignMdTokens, renderBody, renderDesignMd, renderFrontMatter, resolveDesignMdPath, resolveTokenSets, selectPrimaryTheme, toTokenName, toYamlScalar };
|
|
248
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/extract.ts","../src/flatten.ts","../src/format.ts","../src/generate.ts","../src/load.ts","../src/index.ts"],"mappings":""}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{useExecution as e}from"@power-plant/core";import{definePlugin as t}from"@razorwind/core/plugin";import{readFile as n}from"@stryke/fs/read-file";import{isEmptyObject as r}from"@stryke/type-checks/is-empty-object";import{formatTokenValue as i}from"@razorwind/core/utils";import{normalizeTokenTree as a}from"@razorwind/core/tokens";import{existsSync as o}from"@stryke/fs/exists";import{joinPaths as s}from"@stryke/path/join";import{parse as c}from"yaml";function l(e,t){let n=e.split(`.`).filter(Boolean);for(;n.length>1&&t.includes(n[0].toLowerCase());)n.shift();return n.join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase()}function u(e){if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=String(e);return/^[a-z][\w-]*$/i.test(t)?t:JSON.stringify(t)}function ee(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}const te=/^(?:light|dark|dim|high-contrast|hc|default|base|theme)(?:[._-].+)?$/i;function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function p(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function m(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function h(e){if(`$value`in e)return e.$value;if(`value`in e)return e.value;if(typeof e.$ref==`string`)return e.$ref;if(typeof e.ref==`string`)return e.ref}function g(e,t,n,r,a){if(!d(e))return;let o=m(e,n);if(f(e)){let n=h(e);a.push({path:t.join(`.`),type:o,value:n,cssValue:i(n,o),description:p(e),theme:r});return}for(let[n,i]of Object.entries(e))n.startsWith(`$`)||g(i,[...t,n],o,r,a)}function _(e){if(!d(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));return t.length>0&&t.every(e=>te.test(e))?t.map(t=>({id:t,tokens:e[t]})):[{id:`default`,tokens:e}]}function v(e,t){let n=t?new Set(t):void 0,r=[];for(let t of _(e)){let e=t.id==="default"?void 0:t.id;g(t.tokens,[],void 0,e,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}const y=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),ne={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},re=[`color`,`colors`,`palette`],b=[`typography`,`type`,`text`,`font`,`fonts`],x=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,S=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,C=/^components?$/i,w=/^\{([^}]+)\}$/,T=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e){let t=[...new Set(e.map(e=>e.theme))],n=t.find(e=>e===void 0)??t.find(e=>/^light/i.test(e??``))??t.find(e=>/^(?:default|base)/i.test(e??``))??t[0];return e.filter(e=>e.theme===n)}function O(e){if(typeof e==`string`)return w.exec(e.trim())?.[1]}function k(e,t){let n=e;for(let e=0;e<8;e++){let e=O(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function ie(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function ae(e){let t=ie(e);return y.has(t)?t:ne[t.toLowerCase()]}function oe(e,t){let n={};if(!E(e))return n;for(let r of T){let a=e[r];if(a==null)continue;let o=O(a),s=o?t.get(o):void 0,c=s?k(s,t).cssValue:void 0;if(typeof a==`number`){n[r]=a;continue}n[r]=c??i(a)}return n}function A(e,t={}){let n=D(v(e.tokens)),r=new Map(n.map(e=>[e.path,e])),i={name:t.name??`Razorwind Design System`,description:t.description,version:t.version??`alpha`,colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},a=new Map,o=[];for(let e of n){let t=e.path.split(`.`);if(t[0]&&C.test(t[0])){o.push(e);continue}if(e.type===`color`){let t=l(e.path,re),n=k(e,r);i.colors[t]=n.cssValue,e.description&&(i.colorDescriptions[t]=e.description),a.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=l(e.path,b);i.typography[t]=oe(e.value,r),a.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=l(e.path,b);i.typography[t]??={},i.typography[t].fontFamily=e.cssValue,a.set(e.path,`typography.${t}`);continue}let n=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(n&&x.test(e.path)){let n=t.at(-1);i.rounded[n]=k(e,r).cssValue,a.set(e.path,`rounded.${n}`);continue}if(n&&S.test(e.path)){let n=t.at(-1);i.spacing[n]=k(e,r).cssValue,a.set(e.path,`spacing.${n}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let n=ae(t.at(-1));if(!n)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=O(e.value),c=s?a.get(s):void 0,l=c?`{${c}}`:k(e,r).cssValue;i.components[o]??={},i.components[o][n]=l}return i}function j(e,t,n){let r=Object.entries(t);if(r.length!==0){n.push(`${e}:`);for(let[e,t]of r){if(typeof t==`object`&&t){n.push(` ${e}:`);for(let[e,r]of Object.entries(t))n.push(` ${e}: ${u(r)}`);continue}n.push(` ${e}: ${u(t)}`)}}}function M(e){let t=[`---`];return e.version&&t.push(`version: ${u(e.version)}`),t.push(`name: ${u(e.name)}`),e.description&&t.push(`description: ${u(e.description)}`),j(`colors`,e.colors,t),j(`typography`,e.typography,t),j(`rounded`,e.rounded,t),j(`spacing`,e.spacing,t),j(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
2
|
+
`)}\n`}function N(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
3
|
+
`)}\n`}function P(e){let t=[[Object.keys(e.colors).length,`color`],[Object.keys(e.typography).length,`typography`],[Object.keys(e.rounded).length,`shape`],[Object.keys(e.spacing).length,`spacing`],[Object.keys(e.components).length,`component`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t} token${e===1?``:`s`}`).join(`, `);return`${e.name} design tokens${t?` — ${t}`:``}. The YAML front matter above is the normative source; the prose below explains how to apply it.`}function F(e,t={}){let n=[N(`Overview`,t.overview??P(e))],r=Object.entries(e.colors);r.length>0&&n.push(N(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${ee(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
4
|
+
`)));let i=Object.entries(e.typography);i.length>0&&n.push(N(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
5
|
+
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(N(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
6
|
+
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(N(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
7
|
+
`)));let s=Object.entries(e.components);return s.length>0&&n.push(N(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
8
|
+
`))),n.join(`
|
|
9
|
+
`)}function I(e,t={}){return`${M(e)}\n${F(e,t)}`}function L(e,t={}){let n=t.outFile??`DESIGN.md`,r=A(e,t);return{[n]:{path:n,language:`markdown`,chunks:[{content:I(r,t),meta:{name:`razorwind-design-md`}}]}}}const R=/(?:^|[/\\])design\.md$/i,z=[`DESIGN.md`,`design.md`,`docs/DESIGN.md`],B=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,V=/^\{[^{}]+\}$/,H=new Set([`version`,`name`,`description`]),U=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`,`fontFeature`,`fontVariation`],W={backgroundColor:`color`,textColor:`color`,typography:`typography`,rounded:`dimension`,padding:`dimension`,size:`dimension`,height:`dimension`,width:`dimension`};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`string`&&V.test(e.trim())}function q(e){return typeof e==`number`?`${e}px`:e}function J(e){let t={};for(let n of U){let r=e[n];r!=null&&(t[n]=r)}for(let[n,r]of Object.entries(e))!(n in t)&&r!=null&&(typeof r==`string`||typeof r==`number`)&&(t[n]=r);return t}function Y(e,t,n=!1){let r={};for(let[i,a]of Object.entries(e))a!=null&&(r[i]={$type:t,$value:K(a)?a.trim():n?q(a):a});return r}function se(e){let t={};for(let[n,r]of Object.entries(e))K(r)?t[n]={$type:`typography`,$value:r.trim()}:G(r)&&(t[n]={$type:`typography`,$value:J(r)});return t}function ce(e){let t={};for(let[n,r]of Object.entries(e)){if(!G(r))continue;let e={};for(let[t,n]of Object.entries(r)){if(n==null)continue;let r=W[t];e[t]={...r?{$type:r}:{},$value:K(n)?n.trim():r===`typography`&&G(n)?J(n):q(n)}}Object.keys(e).length>0&&(t[n]=e)}return t}function X(e){let t=B.exec(e);if(!t?.[1])return;let n;try{n=c(t[1])}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse DESIGN.md front matter as YAML: ${t}`)}return G(n)?n:void 0}function Z(e){let t={};for(let[n,r]of Object.entries(e))if(!(H.has(n)||!G(r)))switch(n){case`colors`:t[n]=Y(r,`color`);break;case`typography`:t[n]=se(r);break;case`rounded`:case`spacing`:t[n]=Y(r,`dimension`,!0);break;case`components`:t[n]=ce(r);break;default:t[n]=r;break}return a(t)}function Q(e){let t=X(e);return t?Z(t):{}}function le(e){return R.test(e)}function $(e){for(let t of z){let n=s(e,t);if(o(n))return n}}var ue=t((t={})=>({name:`razorwind-design-md`,parsers:[{name:`razorwind-design-md`,pattern:R,parser:e=>Q(e)}],extract:async(i,a)=>{if(i.tokens&&!r(i.tokens))return i;let o=t.path;if(!o){let{cwd:t}=e();if(o=$(t),!o)return i}let s=Q(await n(o));return!s||r(s)?i:{...i,tokens:s}},generate:async(e,t)=>L(e,t)}));export{R as DESIGN_MD_FILE_PATTERN,z as DESIGN_MD_PATH_CANDIDATES,ue as default,Z as designMdToTokens,A as extractDesignMd,X as extractDesignMdFrontMatter,v as flattenTokens,i as formatTokenValue,L as generateDesignMd,le as isDesignMdFile,Q as parseDesignMdTokens,F as renderBody,I as renderDesignMd,M as renderFrontMatter,$ as resolveDesignMdPath,_ as resolveTokenSets,D as selectPrimaryTheme,l as toTokenName,u as toYamlScalar};
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@razorwind/design-md",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Razorwind design-md package that can create a DESIGN.md design-system specification file from design tokens or read a DESIGN.md file and return the design-system specification.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "github",
|
|
8
|
+
"url": "https://github.com/storm-software/razorwind.git",
|
|
9
|
+
"directory": "packages/design-md"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://stormsoftware.com",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://stormsoftware.com/support",
|
|
14
|
+
"email": "support@stormsoftware.com"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Storm Software",
|
|
18
|
+
"email": "contact@stormsoftware.com",
|
|
19
|
+
"url": "https://stormsoftware.com"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"private": false,
|
|
23
|
+
"files": ["dist"],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"design-md",
|
|
26
|
+
"razorwind",
|
|
27
|
+
"design-tokens",
|
|
28
|
+
"dtcg",
|
|
29
|
+
"storm-software"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/index.d.cts",
|
|
35
|
+
"default": "./dist/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./dist/index.d.mts",
|
|
39
|
+
"default": "./dist/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"default": {
|
|
42
|
+
"types": "./dist/index.d.mts",
|
|
43
|
+
"default": "./dist/index.mjs"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
"main": "./dist/index.cjs",
|
|
49
|
+
"module": "./dist/index.mjs",
|
|
50
|
+
"types": "./dist/index.d.cts",
|
|
51
|
+
"typings": "dist/index.d.mts",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@power-plant/core": "^0.0.37",
|
|
54
|
+
"@power-plant/dtcg-schema": "^0.0.1",
|
|
55
|
+
"@razorwind/core": "^0.0.8",
|
|
56
|
+
"@stryke/fs": "^0.33.99",
|
|
57
|
+
"@stryke/path": "^0.29.25",
|
|
58
|
+
"@stryke/type-checks": "^0.6.31",
|
|
59
|
+
"style-dictionary": "^5.5.0",
|
|
60
|
+
"yaml": "^2.9.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@powerlines/plugin-tsdown": "^0.1.560",
|
|
64
|
+
"@types/node": "^25.9.5",
|
|
65
|
+
"typescript": "^6.0.3"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": { "access": "public" },
|
|
68
|
+
"gitHead": "1d74276595c13888022fafaa5f501092dc8e03a0"
|
|
69
|
+
}
|