@razorwind/chrome 0.0.2

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 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,326 @@
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-1280x427-dark.gif">
9
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/razorwind/media/banner-1280x427-light.gif">
10
+ <img src="https://public.storm-cdn.com/razorwind/media/banner-1280x427-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
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/razorwind/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
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 - Chrome Theme Generator
53
+
54
+ **Razorwind - Chrome Theme Generator** creates [Google Chrome](https://www.google.com/chrome/) extension theme folders from design tokens. Output matches community themes such as [Dracula for Chrome](https://github.com/dracula/google-chrome) (`manifest.json` plus optional images and icons).
55
+
56
+ ## Installing
57
+
58
+ Using [pnpm](http://pnpm.io):
59
+
60
+ ```bash
61
+ pnpm add -D @razorwind/chrome
62
+ ```
63
+
64
+ <details>
65
+ <summary>Using npm</summary>
66
+
67
+ ```bash
68
+ npm install -D @razorwind/chrome
69
+ ```
70
+
71
+ </details>
72
+
73
+ <details>
74
+ <summary>Using yarn</summary>
75
+
76
+ ```bash
77
+ yarn add -D @razorwind/chrome
78
+ ```
79
+
80
+ </details>
81
+
82
+ ## Usage
83
+
84
+ ```ts
85
+ import { defineConfig } from "@razorwind/core";
86
+ import chrome, { flattenTokens, toChromeRgb } from "@razorwind/chrome";
87
+
88
+ export default defineConfig({
89
+ plugins: [
90
+ chrome({
91
+ mapTheme: tokens => {
92
+ const flat = flattenTokens(tokens);
93
+ const rgb = (path: string) =>
94
+ toChromeRgb(
95
+ flat.find(t => t.path === path)?.cssValue ?? "#282a36"
96
+ );
97
+
98
+ return {
99
+ name: "My Chrome Theme",
100
+ colors: {
101
+ frame: rgb("color.bg"),
102
+ toolbar: rgb("color.accent"),
103
+ tab_text: rgb("color.fg"),
104
+ omnibox_background: rgb("color.bg"),
105
+ ntp_background: rgb("color.bg"),
106
+ ntp_link: rgb("color.link")
107
+ },
108
+ icons: {
109
+ "16": "images/icon16.png",
110
+ "48": "images/icon48.png",
111
+ "128": "images/icon128.png"
112
+ }
113
+ };
114
+ }
115
+ })
116
+ ]
117
+ });
118
+ ```
119
+
120
+ Generated files (under `chrome-themes/` by default):
121
+
122
+ - `{theme-slug}/manifest.json` — Chrome extension theme manifest from `mapTheme`
123
+ - `INSTALL.md` — load each folder as an unpacked extension at `chrome://extensions`
124
+
125
+ Install like [Dracula for Chrome](https://github.com/dracula/google-chrome):
126
+
127
+ 1. Open `chrome://extensions`
128
+ 2. Enable **Developer mode**
129
+ 3. Click **Load unpacked** and select `chrome-themes/my-chrome-theme/`
130
+
131
+ Add any `images/` or icon PNGs referenced in `manifest.json` before loading.
132
+
133
+ ### Options
134
+
135
+ | Option | Default | Description |
136
+ | -------------- | ----------------- | ------------------------------------------------- |
137
+ | `mapTheme` | _(required)_ | `(tokens) =>` theme, theme array, or theme record |
138
+ | `outputPath` | `"chrome-themes"` | Output directory for theme folders |
139
+ | `installGuide` | _(generated)_ | Override body for generated `INSTALL.md` |
140
+
141
+ `mapTheme` return shapes: a single `ChromeTheme`, an array, or a `Record<string, ChromeTheme>`. Each theme needs `name` and `colors`. Color values may be hex strings (`#rrggbb`) or `[r, g, b]` tuples (0–255). Optional fields mirror Chrome's [theme manifest](https://developer.chrome.com/docs/extensions/develop/ui/themes): `images`, `icons`, `tints`, and `properties`.
142
+
143
+ ## Development
144
+
145
+ ### Building
146
+
147
+ Run `nx build chrome` to build the library.
148
+
149
+ ### Running unit tests
150
+
151
+ Run `nx test chrome` to execute the unit tests via [Vitest](https://vitest.dev/).
152
+
153
+ <!-- START footer -->
154
+ <!-- prettier-ignore-start -->
155
+ <!-- markdownlint-disable -->
156
+
157
+
158
+ ## Storm Workspaces
159
+
160
+ Storm workspaces are built using
161
+ <a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools
162
+ for monorepos, which helps you develop like Google, Facebook, and Microsoft.
163
+ Building on top of Nx, the Open System provides a set of tools and patterns that
164
+ help you scale your monorepo to many teams while keeping the codebase
165
+ maintainable.
166
+
167
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
168
+ <br />
169
+
170
+ ## Roadmap
171
+
172
+ See the [open issues](https://github.com/storm-software/razorwind/issues) for
173
+ a list of proposed features (and known issues).
174
+
175
+ - [Top Feature Requests](https://github.com/storm-software/razorwind/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc)
176
+ (Add your votes using the 👍 reaction)
177
+ - [Top Bugs](https://github.com/storm-software/razorwind/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc)
178
+ (Add your votes using the 👍 reaction)
179
+ - [Newest Bugs](https://github.com/storm-software/razorwind/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
180
+
181
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
182
+ <br />
183
+
184
+ ## Support
185
+
186
+ Reach out to the maintainer at one of the following places:
187
+
188
+ - [Contact](https://stormsoftware.com/contact)
189
+ - [GitHub discussions](https://github.com/storm-software/razorwind/discussions)
190
+ - <support@stormsoftware.com>
191
+
192
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
193
+ <br />
194
+
195
+ ## License
196
+
197
+ This project is licensed under the **Apache License 2.0**. Feel free to edit and
198
+ distribute this template as you like.
199
+
200
+ See [LICENSE](LICENSE) for more information.
201
+
202
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
203
+ <br />
204
+
205
+ ## Changelog
206
+
207
+ This project adheres to
208
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along
209
+ with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md)
210
+ file
211
+
212
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
213
+ <br />
214
+
215
+ ## Contributing
216
+
217
+ First off, thanks for taking the time to contribute! Contributions are what
218
+ makes the open-source community such an amazing place to learn, inspire, and
219
+ create. Any contributions you make will benefit everybody else and are **greatly
220
+ appreciated**.
221
+
222
+ Please try to create bug reports that are:
223
+
224
+ - _Reproducible._ Include steps to reproduce the problem.
225
+ - _Specific._ Include as much detail as possible: which version, what
226
+ environment, etc.
227
+ - _Unique._ Do not duplicate existing opened issues.
228
+ - _Scoped to a Single Bug._ One bug per report.
229
+
230
+ Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).
231
+
232
+ You can use
233
+ [markdownlint-cli](https://github.com/storm-software/razorwind/markdownlint-cli)
234
+ to check for common markdown style inconsistency.
235
+
236
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
237
+ <br />
238
+
239
+ ## Contributors
240
+
241
+ Thanks goes to these wonderful people
242
+ ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
243
+
244
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
245
+
246
+ <table>
247
+ <tbody>
248
+ <tr>
249
+ <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>
250
+ <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>
251
+ <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>
252
+ </tr>
253
+ </tbody>
254
+ <tfoot>
255
+ <tr>
256
+ <td align="center" size="13px" colspan="7">
257
+ <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" alt="All Contributors">
258
+ <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
259
+ </img>
260
+ </td>
261
+ </tr>
262
+ </tfoot>
263
+ </table>
264
+
265
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
266
+
267
+ This project follows the
268
+ [all-contributors](https://allcontributors.org/docs/en/emoji-key)
269
+ specification. Contributions of any kind welcome!
270
+
271
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
272
+ <br />
273
+
274
+ <hr />
275
+ <br />
276
+
277
+ <div align="center">
278
+ <picture>
279
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp">
280
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-light.webp">
281
+ <img src="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp" width="100%" alt="Storm Software" />
282
+ </picture>
283
+ </div>
284
+ <br />
285
+
286
+ <div align="center">
287
+ <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>
288
+ </div>
289
+
290
+ <div align="center">
291
+ <b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D
292
+ </div>
293
+ <br />
294
+
295
+ Storm Software is an open source software development organization and creator
296
+ of Acidic, StormStack and StormCloud.
297
+
298
+ Our mission is to make software development more accessible. Our ideal future is
299
+ one where anyone can create software without years of prior development
300
+ experience serving as a barrier to entry. We hope to achieve this via LLMs,
301
+ Generative AI, and intuitive, high-level data modeling/programming languages.
302
+
303
+ Join us on [Discord](https://discord.gg/MQ6YVzakM5) to chat with the team,
304
+ receive release notifications, ask questions, and get involved.
305
+
306
+ If this sounds interesting, and you would like to help us in creating the next
307
+ generation of development tools, please reach out on our
308
+ [website](https://stormsoftware.com/contact) or join our
309
+ [Slack channel](https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA)!
310
+
311
+ <br />
312
+
313
+ <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>
314
+ <br />
315
+ <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>
316
+ <br />
317
+
318
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
319
+ <br />
320
+ <br />
321
+
322
+
323
+ <!-- markdownlint-restore -->
324
+ <!-- prettier-ignore-end -->
325
+
326
+ <!-- END footer -->
package/dist/index.cjs ADDED
@@ -0,0 +1,39 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin"),t=require("@razorwind/core/utils"),n=require("node:path");function r(e){let t=e.themes[0],n=e.title??(e.themes.length===1?t.displayName:`Chrome Themes`),r=e.themes.map(e=>{let t=[`\`${e.folderName}/manifest.json\``],n=[...e.imagePaths??[],...e.iconPaths??[]];return n.length>0&&t.push(n.map(t=>`\`${e.folderName}/${t}\``).join(`, `)),`- ${t.join(` + `)} — ${e.displayName}`}).join(`
2
+ `),i=e.themes.map(e=>`- **${e.displayName}** — folder \`${e.folderName}/\``).join(`
3
+ `);return`# Installing ${n}
4
+
5
+ Generated by \`@razorwind/chrome\`.
6
+
7
+ These themes target [Google Chrome](https://www.google.com/chrome/) and other
8
+ Chromium browsers. Install steps follow the same pattern as
9
+ [Dracula for Chrome](https://github.com/dracula/google-chrome).
10
+
11
+ ## Files
12
+
13
+ ${r}
14
+ ${e.themes.some(e=>(e.imagePaths?.length??0)>0||(e.iconPaths?.length??0)>0)?`
15
+ If a theme references images or icons, copy the PNG files into the theme folder
16
+ using the paths from \`manifest.json\` before loading the extension.
17
+ `:``}
18
+ ## Setup
19
+
20
+ 1. Open Chrome and go to \`chrome://extensions\`.
21
+
22
+ 2. Enable **Developer mode** (toggle in the toolbar).
23
+
24
+ 3. Click **Load unpacked** and select a generated theme folder (for example
25
+ \`${t.folderName}/\`). The folder must contain \`manifest.json\`.
26
+
27
+ 4. Repeat for each theme variant you want installed.
28
+
29
+ To publish publicly, zip each theme folder and upload it to the
30
+ [Chrome Web Store](https://chrome.google.com/webstore/devconsole).
31
+
32
+ ## Select / load theme
33
+
34
+ Chrome applies the theme immediately after loading the extension. To switch
35
+ between installed themes, disable one theme extension and enable another under
36
+ \`chrome://extensions\`, or remove themes you no longer need:
37
+
38
+ ${i}
39
+ `}function i(e){return(0,t.themeDisplayName)(e)}const a={name:`razorwind-chrome`};function o(e,n,r){return(0,t.createDocument)(e,n,a,void 0,r)}function s(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&e.name.length>0&&(0,t.isObject)(e.colors)&&Object.keys(e.colors).length>0}function c(e){if(Array.isArray(e))return e.map((e,t)=>{if(!s(e))throw TypeError(`@razorwind/chrome mapTheme()[${t}] must be a ChromeTheme with name and colors`);return e});if(s(e))return[e];if(!(0,t.isObject)(e))throw TypeError(`@razorwind/chrome mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!s(t))throw TypeError(`@razorwind/chrome mapTheme()["${e}"] must be a ChromeTheme with name and colors`);return{...t,name:t.name||e}})}function l(e){if(!e.mapTheme)throw Error(`@razorwind/chrome requires options.mapTheme`)}function u(e){return Math.max(0,Math.min(255,Math.round(e)))}function d(e){if(Array.isArray(e)){if(e.length!==3)throw TypeError(`@razorwind/chrome RGB tuples must have exactly three channels`);return[u(e[0]),u(e[1]),u(e[2])]}let t=e.trim(),n=t.startsWith(`#`)?t.slice(1):t;if(!/^[0-9a-f]{6}$/i.test(n))throw TypeError(`@razorwind/chrome cannot convert color "${e}" to RGB — use #rrggbb or [r, g, b]`);return[Number.parseInt(n.slice(0,2),16),Number.parseInt(n.slice(2,4),16),Number.parseInt(n.slice(4,6),16)]}function f(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,d(t)]))}function p(e){let t={manifest_version:e.manifestVersion??3,name:i(e),description:e.description??`A browser color theme generated for ${e.name}.`,version:e.version??`1.0.0`,theme:{colors:f(e.colors)}};e.icons&&Object.keys(e.icons).length>0&&(t.icons=e.icons);let n=t.theme;return e.images&&Object.keys(e.images).length>0&&(n.images=e.images),e.tints&&Object.keys(e.tints).length>0&&(n.tints=e.tints),e.properties&&Object.keys(e.properties).length>0&&(n.properties=e.properties),`${JSON.stringify(t,null,2)}\n`}function m(e,a){l(a);let s=a.outputPath??`chrome-themes`,u=c(a.mapTheme(e.tokens));if(u.length===0)throw Error(`@razorwind/chrome mapTheme() returned no themes`);let d={},f=/* @__PURE__ */ new Set,m=[];for(let e of u){let r=(0,t.slugifyThemeName)(e.name);if(!r)throw TypeError(`@razorwind/chrome theme name "${e.name}" slugifies to an empty string`);if(f.has(r)){let n=2;for(;f.has(`${(0,t.slugifyThemeName)(e.name)}-${n}`);)n+=1;r=`${(0,t.slugifyThemeName)(e.name)}-${n}`}f.add(r);let a=(0,n.join)(s,r,`manifest.json`);d[a]=o(a,p(e),`json`),m.push({name:e.name,displayName:i(e),folderName:r,imagePaths:e.images?Object.values(e.images):void 0,iconPaths:e.icons?Object.values(e.icons):void 0})}let h=a.installGuide??r({themes:m,title:(0,t.resolveSchemaIdentity)(e).title}),g=(0,n.join)(s,`INSTALL.md`);return d[g]=o(g,h,`markdown`),d}var h=(0,e.definePlugin)(e=>({name:`chrome`,generate:async t=>{if(!e)throw Error(`@razorwind/chrome requires options: { mapTheme }`);return m(t,e)}}));exports.default=h,Object.defineProperty(exports,"flattenTokens",{enumerable:!0,get:function(){return t.flattenTokens}}),Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateChromeTheme=m,exports.normalizeThemes=c,exports.renderInstallMd=r,exports.renderManifestJson=p,Object.defineProperty(exports,"resolveTokenSets",{enumerable:!0,get:function(){return t.resolveTokenSets}}),exports.themeDisplayName=i,exports.toChromeRgb=d,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}});
@@ -0,0 +1,212 @@
1
+ import { flattenTokens, formatTokenValue, resolveTokenSets, toCssVar } from "@razorwind/core/utils";
2
+ import { GeneratorFunctionResult } from "@power-plant/core";
3
+ import { Schema, Tokens } from "@razorwind/core/schema";
4
+ import { TokenType } from "@power-plant/dtcg-schema";
5
+ //#region src/types.d.ts
6
+ /**
7
+ * A flattened design token ready for Chrome theme mapping.
8
+ */
9
+ interface FlatToken {
10
+ /** Dot-separated token path (e.g. `color.primary`). */
11
+ path: string;
12
+ /** DTCG `$type`, when known. */
13
+ type?: TokenType | string;
14
+ /** Raw `$value` from the token document. */
15
+ value: unknown;
16
+ /** CSS-friendly string form of {@link value}. */
17
+ cssValue: string;
18
+ /** Optional DTCG `$description`. */
19
+ description?: string;
20
+ /** Theme / set id when tokens are a `Record<string, Tokens>`. */
21
+ theme?: string;
22
+ }
23
+ /** Chrome theme color as an RGB tuple (0–255 per channel). */
24
+ type ChromeRgb = [number, number, number];
25
+ /** HSL tint tuple used by Chrome theme manifests. */
26
+ type ChromeTint = [number, number, number];
27
+ /**
28
+ * Color input accepted in {@link ChromeTheme.colors}.
29
+ * Hex strings (`#rrggbb`) are converted to RGB when rendering.
30
+ */
31
+ type ChromeColorInput = ChromeRgb | string;
32
+ /**
33
+ * Well-known Chrome browser UI color keys.
34
+ *
35
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
36
+ */
37
+ type ChromeThemeColorKey = "frame" | "frame_inactive" | "frame_incognito" | "frame_incognito_inactive" | "toolbar" | "toolbar_button_icon" | "tab_text" | "tab_background_text" | "tab_background_text_inactive" | "tab_background_text_incognito" | "tab_background_text_incognito_inactive" | "bookmark_text" | "omnibox_text" | "omnibox_background" | "ntp_background" | "ntp_text" | "ntp_link" | "ntp_header" | "ntp_section" | "button_background" | (string & {});
38
+ /**
39
+ * Well-known Chrome theme image keys (paths relative to the extension root).
40
+ *
41
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
42
+ */
43
+ type ChromeThemeImageKey = "theme_frame" | "theme_frame_overlay" | "theme_frame_incognito" | "theme_toolbar" | "theme_tab_background" | "theme_ntp_background" | "theme_ntp_attribution" | (string & {});
44
+ /**
45
+ * Google Chrome extension theme manifest — rendered to `manifest.json`.
46
+ *
47
+ * Load as an unpacked extension or publish to the Chrome Web Store.
48
+ *
49
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
50
+ * @see https://github.com/dracula/google-chrome/blob/master/manifest.json
51
+ */
52
+ interface ChromeTheme {
53
+ /**
54
+ * Extension display name written to `manifest.json`.
55
+ * Also used to derive the output folder slug.
56
+ */
57
+ name: string;
58
+ /** Optional label for INSTALL.md when different from {@link name}. */
59
+ displayName?: string;
60
+ /** Extension description. @defaultValue derived from {@link name} */
61
+ description?: string;
62
+ /** Extension version string. @defaultValue `"1.0.0"` */
63
+ version?: string;
64
+ /** Manifest format version. @defaultValue `3` */
65
+ manifestVersion?: 2 | 3;
66
+ /**
67
+ * Browser UI colors. Values are RGB tuples or hex strings converted at render
68
+ * time.
69
+ */
70
+ colors: Record<ChromeThemeColorKey, ChromeColorInput>;
71
+ /** Optional theme image paths (add image files beside `manifest.json`). */
72
+ images?: Partial<Record<ChromeThemeImageKey, string>>;
73
+ /**
74
+ * Extension icons by size (e.g. `"16"`, `"48"`, `"128"`).
75
+ * Paths are relative to the extension root — add PNG files before loading.
76
+ */
77
+ icons?: Record<string, string>;
78
+ /** HSL tints for frame, buttons, and incognito UI. */
79
+ tints?: Partial<Record<string, ChromeTint>>;
80
+ /** Theme layout properties (e.g. `ntp_background_alignment`). */
81
+ properties?: Record<string, string | number>;
82
+ }
83
+ /**
84
+ * Map extracted design tokens to one or more Chrome theme manifests.
85
+ *
86
+ * Return a single theme, an array, or a record keyed by theme id.
87
+ */
88
+ type GenerateChromeTheme = (tokens: Tokens | Record<string, Tokens>) => ChromeTheme | ChromeTheme[] | Record<string, ChromeTheme>;
89
+ /**
90
+ * Options for the Razorwind Chrome theme generator.
91
+ *
92
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
93
+ */
94
+ interface ChromePluginOptions {
95
+ /**
96
+ * Directory (relative to the execution cwd) for generated theme folders.
97
+ *
98
+ * @defaultValue `"chrome-themes"`
99
+ */
100
+ outputPath?: string;
101
+ /**
102
+ * Map extracted tokens to Chrome `manifest.json` document(s).
103
+ *
104
+ * Required — without a mapping there is nothing to emit.
105
+ */
106
+ mapTheme: GenerateChromeTheme;
107
+ /**
108
+ * Restrict flattened helper tokens to these DTCG `$type` values.
109
+ * Does not filter what {@link mapTheme} receives.
110
+ */
111
+ includeTypes?: TokenType[];
112
+ /**
113
+ * Override body for generated `INSTALL.md`. When omitted, Chrome install
114
+ * steps are generated from contributed themes.
115
+ */
116
+ installGuide?: string;
117
+ }
118
+ //#endregion
119
+ //#region src/install.d.ts
120
+ /**
121
+ * Build Chrome INSTALL.md for generated extension theme folders.
122
+ *
123
+ * Steps follow loading an unpacked extension, as used by community themes such
124
+ * as [Dracula for Chrome](https://github.com/dracula/google-chrome).
125
+ */
126
+ declare function renderInstallMd(options: {
127
+ themes: Array<{
128
+ name: string;
129
+ displayName: string;
130
+ folderName: string;
131
+ imagePaths?: string[];
132
+ iconPaths?: string[];
133
+ }>;
134
+ /** Design-system / package title from Schema when multiple themes. */
135
+ title?: string;
136
+ }): string;
137
+ /**
138
+ * Title-case a theme name for display when \`displayName\` is omitted.
139
+ */
140
+ declare function themeDisplayName(theme: ChromeTheme): string;
141
+ //#endregion
142
+ //#region src/generate.d.ts
143
+ /**
144
+ * Normalize {@link ChromePluginOptions.mapTheme} results into a theme list.
145
+ */
146
+ declare function normalizeThemes(result: ChromeTheme | ChromeTheme[] | Record<string, ChromeTheme>): ChromeTheme[];
147
+ /**
148
+ * Convert a CSS hex color or RGB tuple to Chrome's `[r, g, b]` manifest form.
149
+ *
150
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
151
+ */
152
+ declare function toChromeRgb(color: ChromeColorInput): ChromeRgb;
153
+ /**
154
+ * Serialize a Chrome extension theme `manifest.json`.
155
+ *
156
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
157
+ * @see https://github.com/dracula/google-chrome/blob/master/manifest.json
158
+ */
159
+ declare function renderManifestJson(theme: ChromeTheme): string;
160
+ /**
161
+ * Generate Chrome extension theme folders (plus INSTALL.md) from a Razorwind schema.
162
+ *
163
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
164
+ */
165
+ declare function generateChromeTheme(spec: Schema, options: ChromePluginOptions): GeneratorFunctionResult<Schema, ChromePluginOptions>;
166
+ //#endregion
167
+ //#region src/index.d.ts
168
+ /**
169
+ * Razorwind plugin that turns design tokens into Google Chrome extension
170
+ * theme manifests.
171
+ *
172
+ * Provide {@link ChromePluginOptions.mapTheme} to map extracted tokens to one
173
+ * or more `manifest.json` documents. Load generated folders as unpacked
174
+ * extensions at `chrome://extensions`.
175
+ *
176
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
177
+ * @see https://github.com/dracula/google-chrome
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * import { defineConfig } from "@razorwind/core";
182
+ * import chrome, { flattenTokens, toChromeRgb } from "@razorwind/chrome";
183
+ *
184
+ * export default defineConfig({
185
+ * plugins: [
186
+ * chrome({
187
+ * mapTheme: tokens => {
188
+ * const flat = flattenTokens(tokens);
189
+ * const rgb = (path: string) =>
190
+ * toChromeRgb(
191
+ * flat.find(t => t.path === path)?.cssValue ?? "#000000"
192
+ * );
193
+ *
194
+ * return {
195
+ * name: "My Chrome Theme",
196
+ * colors: {
197
+ * frame: rgb("color.bg"),
198
+ * toolbar: rgb("color.accent"),
199
+ * tab_text: rgb("color.fg"),
200
+ * ntp_background: rgb("color.bg")
201
+ * }
202
+ * };
203
+ * }
204
+ * })
205
+ * ]
206
+ * });
207
+ * ```
208
+ */
209
+ declare const _default: (options?: ChromePluginOptions | undefined) => import("@razorwind/core/plugin").Plugin;
210
+ //#endregion
211
+ export { type ChromeColorInput, type ChromePluginOptions, type ChromeRgb, type ChromeTheme, type ChromeThemeColorKey, type ChromeThemeImageKey, type ChromeTint, type FlatToken, type GenerateChromeTheme, _default as default, flattenTokens, formatTokenValue, generateChromeTheme, normalizeThemes, renderInstallMd, renderManifestJson, resolveTokenSets, themeDisplayName, toChromeRgb, toCssVar };
212
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/install.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAwBiB;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;;KAIU;;KAGA;;;;;KAMA,mBAAmB;;;;;;KAOnB;;;;;;KA4BA;;;;;;;;;UAkBK;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA,QAAQ,OAAO,qBAAqB;;EAEpC,SAAS,QAAQ,OAAO;;;;;EAKxB,QAAQ;;EAER,QAAQ,QAAQ,eAAe;;EAE/B,aAAa;;;;;;;KAQH,uBACV,QAAQ,SAAS,eAAe,YAC7B,cAAc,gBAAgB,eAAe;;;;;;UAOjC;;;;;;EAMf;;;;;;EAOA,UAAU;;;;;EAMV,eAAe;;;;;EAMf;;;;;;;;;;iBClJc,gBAAgB;EAC9B,QAAQ;IACN;IACA;IACA;IACA;IACA;;;EAGF;;;;;iBA4Ec,iBAAiB,OAAO;;;;;;iBChDxB,gBACd,QAAQ,cAAc,gBAAgB,eAAe,eACpD;;;;;;iBAsDa,YAAY,OAAO,mBAAmB;;;;;;;iBA2CtC,mBAAmB,OAAO;;;;;;iBAsC1B,oBACd,MAAM,QACN,SAAS,sBACR,wBAAwB,QAAQ"}
@@ -0,0 +1,212 @@
1
+ import { flattenTokens, formatTokenValue, resolveTokenSets, toCssVar } from "@razorwind/core/utils";
2
+ import { GeneratorFunctionResult } from "@power-plant/core";
3
+ import { Schema, Tokens } from "@razorwind/core/schema";
4
+ import { TokenType } from "@power-plant/dtcg-schema";
5
+ //#region src/types.d.ts
6
+ /**
7
+ * A flattened design token ready for Chrome theme mapping.
8
+ */
9
+ interface FlatToken {
10
+ /** Dot-separated token path (e.g. `color.primary`). */
11
+ path: string;
12
+ /** DTCG `$type`, when known. */
13
+ type?: TokenType | string;
14
+ /** Raw `$value` from the token document. */
15
+ value: unknown;
16
+ /** CSS-friendly string form of {@link value}. */
17
+ cssValue: string;
18
+ /** Optional DTCG `$description`. */
19
+ description?: string;
20
+ /** Theme / set id when tokens are a `Record<string, Tokens>`. */
21
+ theme?: string;
22
+ }
23
+ /** Chrome theme color as an RGB tuple (0–255 per channel). */
24
+ type ChromeRgb = [number, number, number];
25
+ /** HSL tint tuple used by Chrome theme manifests. */
26
+ type ChromeTint = [number, number, number];
27
+ /**
28
+ * Color input accepted in {@link ChromeTheme.colors}.
29
+ * Hex strings (`#rrggbb`) are converted to RGB when rendering.
30
+ */
31
+ type ChromeColorInput = ChromeRgb | string;
32
+ /**
33
+ * Well-known Chrome browser UI color keys.
34
+ *
35
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
36
+ */
37
+ type ChromeThemeColorKey = "frame" | "frame_inactive" | "frame_incognito" | "frame_incognito_inactive" | "toolbar" | "toolbar_button_icon" | "tab_text" | "tab_background_text" | "tab_background_text_inactive" | "tab_background_text_incognito" | "tab_background_text_incognito_inactive" | "bookmark_text" | "omnibox_text" | "omnibox_background" | "ntp_background" | "ntp_text" | "ntp_link" | "ntp_header" | "ntp_section" | "button_background" | (string & {});
38
+ /**
39
+ * Well-known Chrome theme image keys (paths relative to the extension root).
40
+ *
41
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
42
+ */
43
+ type ChromeThemeImageKey = "theme_frame" | "theme_frame_overlay" | "theme_frame_incognito" | "theme_toolbar" | "theme_tab_background" | "theme_ntp_background" | "theme_ntp_attribution" | (string & {});
44
+ /**
45
+ * Google Chrome extension theme manifest — rendered to `manifest.json`.
46
+ *
47
+ * Load as an unpacked extension or publish to the Chrome Web Store.
48
+ *
49
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
50
+ * @see https://github.com/dracula/google-chrome/blob/master/manifest.json
51
+ */
52
+ interface ChromeTheme {
53
+ /**
54
+ * Extension display name written to `manifest.json`.
55
+ * Also used to derive the output folder slug.
56
+ */
57
+ name: string;
58
+ /** Optional label for INSTALL.md when different from {@link name}. */
59
+ displayName?: string;
60
+ /** Extension description. @defaultValue derived from {@link name} */
61
+ description?: string;
62
+ /** Extension version string. @defaultValue `"1.0.0"` */
63
+ version?: string;
64
+ /** Manifest format version. @defaultValue `3` */
65
+ manifestVersion?: 2 | 3;
66
+ /**
67
+ * Browser UI colors. Values are RGB tuples or hex strings converted at render
68
+ * time.
69
+ */
70
+ colors: Record<ChromeThemeColorKey, ChromeColorInput>;
71
+ /** Optional theme image paths (add image files beside `manifest.json`). */
72
+ images?: Partial<Record<ChromeThemeImageKey, string>>;
73
+ /**
74
+ * Extension icons by size (e.g. `"16"`, `"48"`, `"128"`).
75
+ * Paths are relative to the extension root — add PNG files before loading.
76
+ */
77
+ icons?: Record<string, string>;
78
+ /** HSL tints for frame, buttons, and incognito UI. */
79
+ tints?: Partial<Record<string, ChromeTint>>;
80
+ /** Theme layout properties (e.g. `ntp_background_alignment`). */
81
+ properties?: Record<string, string | number>;
82
+ }
83
+ /**
84
+ * Map extracted design tokens to one or more Chrome theme manifests.
85
+ *
86
+ * Return a single theme, an array, or a record keyed by theme id.
87
+ */
88
+ type GenerateChromeTheme = (tokens: Tokens | Record<string, Tokens>) => ChromeTheme | ChromeTheme[] | Record<string, ChromeTheme>;
89
+ /**
90
+ * Options for the Razorwind Chrome theme generator.
91
+ *
92
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
93
+ */
94
+ interface ChromePluginOptions {
95
+ /**
96
+ * Directory (relative to the execution cwd) for generated theme folders.
97
+ *
98
+ * @defaultValue `"chrome-themes"`
99
+ */
100
+ outputPath?: string;
101
+ /**
102
+ * Map extracted tokens to Chrome `manifest.json` document(s).
103
+ *
104
+ * Required — without a mapping there is nothing to emit.
105
+ */
106
+ mapTheme: GenerateChromeTheme;
107
+ /**
108
+ * Restrict flattened helper tokens to these DTCG `$type` values.
109
+ * Does not filter what {@link mapTheme} receives.
110
+ */
111
+ includeTypes?: TokenType[];
112
+ /**
113
+ * Override body for generated `INSTALL.md`. When omitted, Chrome install
114
+ * steps are generated from contributed themes.
115
+ */
116
+ installGuide?: string;
117
+ }
118
+ //#endregion
119
+ //#region src/install.d.ts
120
+ /**
121
+ * Build Chrome INSTALL.md for generated extension theme folders.
122
+ *
123
+ * Steps follow loading an unpacked extension, as used by community themes such
124
+ * as [Dracula for Chrome](https://github.com/dracula/google-chrome).
125
+ */
126
+ declare function renderInstallMd(options: {
127
+ themes: Array<{
128
+ name: string;
129
+ displayName: string;
130
+ folderName: string;
131
+ imagePaths?: string[];
132
+ iconPaths?: string[];
133
+ }>;
134
+ /** Design-system / package title from Schema when multiple themes. */
135
+ title?: string;
136
+ }): string;
137
+ /**
138
+ * Title-case a theme name for display when \`displayName\` is omitted.
139
+ */
140
+ declare function themeDisplayName(theme: ChromeTheme): string;
141
+ //#endregion
142
+ //#region src/generate.d.ts
143
+ /**
144
+ * Normalize {@link ChromePluginOptions.mapTheme} results into a theme list.
145
+ */
146
+ declare function normalizeThemes(result: ChromeTheme | ChromeTheme[] | Record<string, ChromeTheme>): ChromeTheme[];
147
+ /**
148
+ * Convert a CSS hex color or RGB tuple to Chrome's `[r, g, b]` manifest form.
149
+ *
150
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
151
+ */
152
+ declare function toChromeRgb(color: ChromeColorInput): ChromeRgb;
153
+ /**
154
+ * Serialize a Chrome extension theme `manifest.json`.
155
+ *
156
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
157
+ * @see https://github.com/dracula/google-chrome/blob/master/manifest.json
158
+ */
159
+ declare function renderManifestJson(theme: ChromeTheme): string;
160
+ /**
161
+ * Generate Chrome extension theme folders (plus INSTALL.md) from a Razorwind schema.
162
+ *
163
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
164
+ */
165
+ declare function generateChromeTheme(spec: Schema, options: ChromePluginOptions): GeneratorFunctionResult<Schema, ChromePluginOptions>;
166
+ //#endregion
167
+ //#region src/index.d.ts
168
+ /**
169
+ * Razorwind plugin that turns design tokens into Google Chrome extension
170
+ * theme manifests.
171
+ *
172
+ * Provide {@link ChromePluginOptions.mapTheme} to map extracted tokens to one
173
+ * or more `manifest.json` documents. Load generated folders as unpacked
174
+ * extensions at `chrome://extensions`.
175
+ *
176
+ * @see https://developer.chrome.com/docs/extensions/develop/ui/themes
177
+ * @see https://github.com/dracula/google-chrome
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * import { defineConfig } from "@razorwind/core";
182
+ * import chrome, { flattenTokens, toChromeRgb } from "@razorwind/chrome";
183
+ *
184
+ * export default defineConfig({
185
+ * plugins: [
186
+ * chrome({
187
+ * mapTheme: tokens => {
188
+ * const flat = flattenTokens(tokens);
189
+ * const rgb = (path: string) =>
190
+ * toChromeRgb(
191
+ * flat.find(t => t.path === path)?.cssValue ?? "#000000"
192
+ * );
193
+ *
194
+ * return {
195
+ * name: "My Chrome Theme",
196
+ * colors: {
197
+ * frame: rgb("color.bg"),
198
+ * toolbar: rgb("color.accent"),
199
+ * tab_text: rgb("color.fg"),
200
+ * ntp_background: rgb("color.bg")
201
+ * }
202
+ * };
203
+ * }
204
+ * })
205
+ * ]
206
+ * });
207
+ * ```
208
+ */
209
+ declare const _default: (options?: ChromePluginOptions | undefined) => import("@razorwind/core/plugin").Plugin;
210
+ //#endregion
211
+ export { type ChromeColorInput, type ChromePluginOptions, type ChromeRgb, type ChromeTheme, type ChromeThemeColorKey, type ChromeThemeImageKey, type ChromeTint, type FlatToken, type GenerateChromeTheme, _default as default, flattenTokens, formatTokenValue, generateChromeTheme, normalizeThemes, renderInstallMd, renderManifestJson, resolveTokenSets, themeDisplayName, toChromeRgb, toCssVar };
212
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/install.ts","../src/generate.ts","../src/index.ts"],"mappings":""}
package/dist/index.mjs ADDED
@@ -0,0 +1,40 @@
1
+ import{definePlugin as e}from"@razorwind/core/plugin";import{createDocument as t,flattenTokens as n,formatTokenValue as r,isObject as i,resolveSchemaIdentity as a,resolveTokenSets as o,slugifyThemeName as s,themeDisplayName as c,toCssVar as l}from"@razorwind/core/utils";import{join as u}from"node:path";function d(e){let t=e.themes[0],n=e.title??(e.themes.length===1?t.displayName:`Chrome Themes`),r=e.themes.map(e=>{let t=[`\`${e.folderName}/manifest.json\``],n=[...e.imagePaths??[],...e.iconPaths??[]];return n.length>0&&t.push(n.map(t=>`\`${e.folderName}/${t}\``).join(`, `)),`- ${t.join(` + `)} — ${e.displayName}`}).join(`
2
+ `),i=e.themes.map(e=>`- **${e.displayName}** — folder \`${e.folderName}/\``).join(`
3
+ `);return`# Installing ${n}
4
+
5
+ Generated by \`@razorwind/chrome\`.
6
+
7
+ These themes target [Google Chrome](https://www.google.com/chrome/) and other
8
+ Chromium browsers. Install steps follow the same pattern as
9
+ [Dracula for Chrome](https://github.com/dracula/google-chrome).
10
+
11
+ ## Files
12
+
13
+ ${r}
14
+ ${e.themes.some(e=>(e.imagePaths?.length??0)>0||(e.iconPaths?.length??0)>0)?`
15
+ If a theme references images or icons, copy the PNG files into the theme folder
16
+ using the paths from \`manifest.json\` before loading the extension.
17
+ `:``}
18
+ ## Setup
19
+
20
+ 1. Open Chrome and go to \`chrome://extensions\`.
21
+
22
+ 2. Enable **Developer mode** (toggle in the toolbar).
23
+
24
+ 3. Click **Load unpacked** and select a generated theme folder (for example
25
+ \`${t.folderName}/\`). The folder must contain \`manifest.json\`.
26
+
27
+ 4. Repeat for each theme variant you want installed.
28
+
29
+ To publish publicly, zip each theme folder and upload it to the
30
+ [Chrome Web Store](https://chrome.google.com/webstore/devconsole).
31
+
32
+ ## Select / load theme
33
+
34
+ Chrome applies the theme immediately after loading the extension. To switch
35
+ between installed themes, disable one theme extension and enable another under
36
+ \`chrome://extensions\`, or remove themes you no longer need:
37
+
38
+ ${i}
39
+ `}function f(e){return c(e)}const p={name:`razorwind-chrome`};function m(e,n,r){return t(e,n,p,void 0,r)}function h(e){return i(e)&&typeof e.name==`string`&&e.name.length>0&&i(e.colors)&&Object.keys(e.colors).length>0}function g(e){if(Array.isArray(e))return e.map((e,t)=>{if(!h(e))throw TypeError(`@razorwind/chrome mapTheme()[${t}] must be a ChromeTheme with name and colors`);return e});if(h(e))return[e];if(!i(e))throw TypeError(`@razorwind/chrome mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!h(t))throw TypeError(`@razorwind/chrome mapTheme()["${e}"] must be a ChromeTheme with name and colors`);return{...t,name:t.name||e}})}function _(e){if(!e.mapTheme)throw Error(`@razorwind/chrome requires options.mapTheme`)}function v(e){return Math.max(0,Math.min(255,Math.round(e)))}function y(e){if(Array.isArray(e)){if(e.length!==3)throw TypeError(`@razorwind/chrome RGB tuples must have exactly three channels`);return[v(e[0]),v(e[1]),v(e[2])]}let t=e.trim(),n=t.startsWith(`#`)?t.slice(1):t;if(!/^[0-9a-f]{6}$/i.test(n))throw TypeError(`@razorwind/chrome cannot convert color "${e}" to RGB — use #rrggbb or [r, g, b]`);return[Number.parseInt(n.slice(0,2),16),Number.parseInt(n.slice(2,4),16),Number.parseInt(n.slice(4,6),16)]}function b(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,y(t)]))}function x(e){let t={manifest_version:e.manifestVersion??3,name:f(e),description:e.description??`A browser color theme generated for ${e.name}.`,version:e.version??`1.0.0`,theme:{colors:b(e.colors)}};e.icons&&Object.keys(e.icons).length>0&&(t.icons=e.icons);let n=t.theme;return e.images&&Object.keys(e.images).length>0&&(n.images=e.images),e.tints&&Object.keys(e.tints).length>0&&(n.tints=e.tints),e.properties&&Object.keys(e.properties).length>0&&(n.properties=e.properties),`${JSON.stringify(t,null,2)}\n`}function S(e,t){_(t);let n=t.outputPath??`chrome-themes`,r=g(t.mapTheme(e.tokens));if(r.length===0)throw Error(`@razorwind/chrome mapTheme() returned no themes`);let i={},o=/* @__PURE__ */ new Set,c=[];for(let e of r){let t=s(e.name);if(!t)throw TypeError(`@razorwind/chrome theme name "${e.name}" slugifies to an empty string`);if(o.has(t)){let n=2;for(;o.has(`${s(e.name)}-${n}`);)n+=1;t=`${s(e.name)}-${n}`}o.add(t);let r=u(n,t,`manifest.json`);i[r]=m(r,x(e),`json`),c.push({name:e.name,displayName:f(e),folderName:t,imagePaths:e.images?Object.values(e.images):void 0,iconPaths:e.icons?Object.values(e.icons):void 0})}let l=t.installGuide??d({themes:c,title:a(e).title}),p=u(n,`INSTALL.md`);return i[p]=m(p,l,`markdown`),i}var C=e(e=>({name:`chrome`,generate:async t=>{if(!e)throw Error(`@razorwind/chrome requires options: { mapTheme }`);return S(t,e)}}));export{C as default,n as flattenTokens,r as formatTokenValue,S as generateChromeTheme,g as normalizeThemes,d as renderInstallMd,x as renderManifestJson,o as resolveTokenSets,f as themeDisplayName,y as toChromeRgb,l as toCssVar};
40
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@razorwind/chrome",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "description": "Razorwind plugin that generates Google Chrome extension themes from design tokens.",
6
+ "repository": {
7
+ "type": "github",
8
+ "url": "https://github.com/storm-software/razorwind.git",
9
+ "directory": "packages/chrome"
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
+ "chrome",
26
+ "chromium",
27
+ "browser",
28
+ "theme",
29
+ "extension",
30
+ "razorwind",
31
+ "design-tokens",
32
+ "dtcg",
33
+ "storm-software"
34
+ ],
35
+ "exports": {
36
+ ".": {
37
+ "require": {
38
+ "types": "./dist/index.d.cts",
39
+ "default": "./dist/index.cjs"
40
+ },
41
+ "import": {
42
+ "types": "./dist/index.d.mts",
43
+ "default": "./dist/index.mjs"
44
+ },
45
+ "default": {
46
+ "types": "./dist/index.d.mts",
47
+ "default": "./dist/index.mjs"
48
+ }
49
+ },
50
+ "./generate": {
51
+ "require": {
52
+ "types": "./dist/index.d.cts",
53
+ "default": "./dist/index.cjs"
54
+ },
55
+ "import": {
56
+ "types": "./dist/index.d.mts",
57
+ "default": "./dist/index.mjs"
58
+ },
59
+ "default": {
60
+ "types": "./dist/index.d.mts",
61
+ "default": "./dist/index.mjs"
62
+ }
63
+ },
64
+ "./package.json": "./package.json"
65
+ },
66
+ "main": "./dist/index.cjs",
67
+ "module": "./dist/index.mjs",
68
+ "types": "./dist/index.d.cts",
69
+ "typings": "dist/index.d.mts",
70
+ "dependencies": {
71
+ "@power-plant/core": "^0.0.93",
72
+ "@power-plant/dtcg-schema": "^0.0.1",
73
+ "@razorwind/core": "^0.0.68"
74
+ },
75
+ "devDependencies": {
76
+ "@powerlines/plugin-tsdown": "^0.1.614",
77
+ "@types/node": "^25.9.7",
78
+ "typescript": "^6.0.3"
79
+ },
80
+ "publishConfig": { "access": "public" },
81
+ "gitHead": "1498cb7254b4a24cdbe7b1143cc513438148b863"
82
+ }