@razorwind/zed 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,165 @@
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
+ [![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
+
53
+ # Razorwind - Zed Theme Extension Plugin
54
+
55
+ **Razorwind - Zed Theme Extension** creates Zed-installable theme extensions from design tokens. Output matches official Zed extension layout ([Dracula for Zed](https://draculatheme.com/zed) is a good reference).
56
+
57
+ ## Installing
58
+
59
+ Using [pnpm](http://pnpm.io):
60
+
61
+ ```bash
62
+ pnpm add -D @razorwind/zed
63
+ ```
64
+
65
+ <details>
66
+ <summary>Using npm</summary>
67
+
68
+ ```bash
69
+ npm install -D @razorwind/zed
70
+ ```
71
+
72
+ </details>
73
+
74
+ <details>
75
+ <summary>Using yarn</summary>
76
+
77
+ ```bash
78
+ yarn add -D @razorwind/zed
79
+ ```
80
+
81
+ </details>
82
+
83
+ ## Usage
84
+
85
+ ```ts
86
+ import { defineConfig } from "@razorwind/core";
87
+ import zed, { flattenTokens } from "@razorwind/zed";
88
+
89
+ export default defineConfig({
90
+ plugins: [
91
+ zed({
92
+ id: "my-theme",
93
+ name: "My Theme",
94
+ authors: ["Acme <themes@acme.com>"],
95
+ mapTheme: tokens => {
96
+ const flat = flattenTokens(tokens);
97
+ const color = (path: string) =>
98
+ flat.find(t => t.path === path)?.cssValue ?? "#000000";
99
+
100
+ return {
101
+ name: "My Theme",
102
+ themes: [
103
+ {
104
+ name: "My Theme Dark",
105
+ appearance: "dark",
106
+ style: {
107
+ "editor.background": color("color.bg"),
108
+ "editor.foreground": color("color.fg"),
109
+ syntax: {
110
+ comment: { color: color("color.muted") }
111
+ }
112
+ }
113
+ },
114
+ {
115
+ name: "My Theme Light",
116
+ appearance: "light",
117
+ style: {
118
+ "editor.background": color("color.bg"),
119
+ "editor.foreground": color("color.fg")
120
+ }
121
+ }
122
+ ]
123
+ };
124
+ }
125
+ })
126
+ ]
127
+ });
128
+ ```
129
+
130
+ Generated package (under `zed-extension/` by default):
131
+
132
+ - `themes/*.json` — Zed theme collection documents from `mapTheme`
133
+ - `extension.toml` — Zed extension manifest
134
+ - `README.md`
135
+ - `INSTALL.md` — Zed extensions store + manual install steps
136
+
137
+ ### Options
138
+
139
+ | Option | Default | Description |
140
+ | --------------- | -------------------------------------------- | -------------------------------------------------------- |
141
+ | `id` | _(required)_ | Extension id slug for `extension.toml` |
142
+ | `mapTheme` | _(required)_ | `(tokens) =>` collection, array, or record |
143
+ | `outputPath` | `"zed-extension"` | Output directory for the extension package |
144
+ | `name` | title-cased `id` | Human-readable extension name |
145
+ | `version` | `"0.0.1"` | Extension version |
146
+ | `schemaVersion` | `1` | `extension.toml` schema version |
147
+ | `authors` | — | `extension.toml` authors array |
148
+ | `themeSchema` | `https://zed.dev/schema/themes/v0.2.0.json` | Default `$schema` for theme JSON |
149
+ | `installGuide` | _(generated)_ | Override body for generated `INSTALL.md` |
150
+
151
+ `mapTheme` return shapes: a single `ZedTheme` collection, an array, or a `Record<string, ZedTheme>`. Each collection contains `themes[]` variants with `appearance: "dark" | "light"` and a `style` object (UI keys, optional `syntax`, optional `players`).
152
+
153
+ ### Install in Zed
154
+
155
+ Publish or install via the Zed extensions store, or copy `themes/*.json` to `~/.config/zed/themes` and pick the theme under **Settings → Select Theme**. See generated `INSTALL.md` for full steps.
156
+
157
+ ## Development
158
+
159
+ ### Building
160
+
161
+ Run `nx build zed` to build the library.
162
+
163
+ ### Running unit tests
164
+
165
+ Run `nx test zed` to execute the unit tests via [Vitest](https://vitest.dev/).
package/dist/index.cjs ADDED
@@ -0,0 +1,53 @@
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");const r=/^(?:light|dark|dim|dimmed|high-contrast|hc|protanopia|deuteranopia|tritanopia|achromatopsia|achromatomaly|monochrome|monochromatic|grayscale|greyscale|bw|black-and-white|black-white|blackWhite|default|base|theme)(?:[A-Z]\w*|[._-].+)?$/i;function i(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function a(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function o(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function s(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 c(e,n,r,l,u){if(!(0,t.isObject)(e))return;let d=o(e,r);if(i(e)){let r=s(e);u.push({path:n.join(`.`),type:d,value:r,cssValue:(0,t.formatTokenValue)(r,d),description:a(e),theme:l});return}for(let[t,r]of Object.entries(e))t.startsWith(`$`)||c(r,[...n,t],d,l,u)}function l(e){if(!(0,t.isObject)(e))return[];let n=Object.keys(e).filter(e=>!e.startsWith(`$`));if(n.length>0&&n.every(e=>r.test(e))){let t=e;return n.map(e=>({id:e,tokens:t[e]}))}return[{id:`default`,tokens:e}]}function u(e,t={}){let n=t.includeTypes?new Set(t.includeTypes):void 0,r=[];for(let t of l(e)){let e=t.id==="default"?void 0:t.id;c(t.tokens,[],void 0,e,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}function d(e){let t=e.themes.map(e=>`- ${e.label}`).join(`
2
+ `),n=e.repositoryUrl?`\n## Links\n\n- [GitHub](${e.repositoryUrl})\n`:``;return`# ${e.displayName}
3
+
4
+ ${e.description}
5
+
6
+ ## Installation
7
+
8
+ See **INSTALL.md** for Zed extension store and manual theme install steps.
9
+
10
+ ## Themes
11
+
12
+ ${t||`- (generated themes)`}
13
+ ${n}`}function f(e){let t=e.themes.map(e=>`- \`${e.path}\` — ${e.label}`).join(`
14
+ `),n=e.themes.map(e=>`- **${e.label}**`).join(`
15
+ `),r=e.themes.map(e=>`- \`${e.fileName}\``).join(`
16
+ `);return`# Installing ${e.displayName}
17
+
18
+ Generated by \`@razorwind/zed\`.
19
+
20
+ ## Files
21
+
22
+ - \`extension.toml\` — Zed extension manifest
23
+ - \`themes/*.json\` — Zed theme collection documents
24
+ ${t}
25
+
26
+ ## Install in Zed (extensions store)
27
+
28
+ 1. Open Zed and open the extensions panel.
29
+ 2. Search for **${e.displayName}** (extension id: \`${e.extensionId}\`) or publish this folder as a Zed extension.
30
+ 3. After installing, open **Settings → Select Theme** and pick a variant:
31
+
32
+ ${n}
33
+
34
+ ## Install manually
35
+
36
+ Copy theme JSON into Zed's themes directory:
37
+
38
+ \`\`\`bash
39
+ mkdir -p ~/.config/zed/themes
40
+ cp themes/*.json ~/.config/zed/themes/
41
+ \`\`\`
42
+
43
+ Files:
44
+
45
+ ${r}
46
+
47
+ Then open **Settings → Select Theme** and choose a variant listed above.
48
+
49
+ ## Select theme
50
+
51
+ \`Settings → Select Theme\` → pick a variant label from this extension.
52
+ `}const p={name:`razorwind-zed`},m=`https://zed.dev/schema/themes/v0.2.0.json`;function h(e,n,r){return(0,t.createDocument)(e,n,p,r)}function g(e){return e.split(/[-_.\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function _(e){return e.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g,`-`).replaceAll(/^-+|-+$/g,``)}function v(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&(e.appearance===`dark`||e.appearance===`light`)&&(0,t.isObject)(e.style)}function y(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&Array.isArray(e.themes)&&e.themes.length>0&&e.themes.every(v)}function b(e){if(Array.isArray(e))return e.map((e,t)=>{if(!y(e))throw TypeError(`@razorwind/zed mapTheme()[${t}] must be a ZedTheme with name + themes[]`);return e});if(y(e))return[e];if(!(0,t.isObject)(e))throw TypeError(`@razorwind/zed mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!y(t))throw TypeError(`@razorwind/zed mapTheme()["${e}"] must be a ZedTheme with name + themes[]`);return{...t,name:t.name||e}})}function x(e){if(!e.mapTheme)throw Error(`@razorwind/zed requires options.mapTheme`);if(!e.id||e.id.includes(`/`))throw Error(`@razorwind/zed requires options.id (unscoped extension id slug)`)}function S(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function C(e,t=m){let n={$schema:e.$schema??t,name:e.name,themes:e.themes};return e.author&&(n.author=e.author),`${JSON.stringify(n,null,2)}\n`}function w(e){let t=e.name??g(e.id),n=e.description??`${t} — Zed themes generated by Razorwind`,r=[`id = "${S(e.id)}"`,`name = "${S(t)}"`,`version = "${S(e.version??`0.0.1`)}"`,`schema_version = ${e.schemaVersion??1}`,`description = "${S(n)}"`];if(e.authors?.length){let t=e.authors.map(e=>`"${S(e)}"`).join(`, `);r.push(`authors = [${t}]`)}return e.repository&&r.push(`repository = "${S(e.repository)}"`),`${r.join(`
53
+ `)}\n`}function T(e,t){x(t);let r=t.outputPath??`zed-extension`,i=t.name??g(t.id),a=t.description??`${i} — Zed themes generated by Razorwind`,o=t.themeSchema??m,s=b(t.mapTheme(e.tokens));if(s.length===0)throw Error(`@razorwind/zed mapTheme() returned no themes`);let c={},l=new Set,u=[];for(let e of s){let t=_(e.name);if(l.has(t)){let n=2;for(;l.has(`${_(e.name)}-${n}`);)n+=1;t=`${_(e.name)}-${n}`}l.add(t);let i=`${t}.json`,a=(0,n.join)(r,`themes`,i);c[a]=h(a,C(e,o),`json`);for(let n of e.themes)u.push({label:n.name,path:`themes/${i}`,slug:t,fileName:i})}let p=(0,n.join)(r,`extension.toml`);c[p]=h(p,w(t),`toml`);let v=u.map(e=>({label:e.label})),y=t.readme??d({displayName:i,description:a,themes:v,repositoryUrl:t.repository}),S=(0,n.join)(r,`README.md`);c[S]=h(S,y,`markdown`);let T=t.installGuide??f({displayName:i,extensionId:t.id,themes:u}),E=(0,n.join)(r,`INSTALL.md`);return c[E]=h(E,T,`markdown`),c}var E=(0,e.definePlugin)(e=>({name:`zed`,generate:async t=>{if(!e)throw Error(`@razorwind/zed requires options: { id, mapTheme }`);return T(t,e)}}));exports.default=E,exports.flattenTokens=u,Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateZedExtension=T,exports.normalizeThemes=b,exports.renderExtensionToml=w,exports.renderInstallMd=f,exports.renderThemeJson=C,exports.resolveTokenSets=l,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}});
@@ -0,0 +1,261 @@
1
+ import { Schema, Tokens } from "@razorwind/core/schema";
2
+ import { TokenType } from "@power-plant/dtcg-schema";
3
+ import { formatTokenValue, toCssVar } from "@razorwind/core/utils";
4
+ import { GeneratorFunctionResult } from "@power-plant/core";
5
+ //#region src/types.d.ts
6
+ /**
7
+ * A flattened design token ready for Zed 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
+ /**
24
+ * Zed syntax highlight style entry.
25
+ *
26
+ * @see https://zed.dev/schema/themes/v0.2.0.json
27
+ */
28
+ interface ZedSyntaxStyle {
29
+ color?: string | null;
30
+ font_style?: string | null;
31
+ font_weight?: number | null;
32
+ }
33
+ /**
34
+ * Collaborative player cursor colors in a Zed theme variant.
35
+ */
36
+ interface ZedPlayerColors {
37
+ cursor?: string;
38
+ background?: string;
39
+ selection?: string;
40
+ }
41
+ /**
42
+ * One appearance variant inside a Zed theme collection document.
43
+ *
44
+ * `style` holds UI color keys, optional `syntax` map, and optional `players`.
45
+ *
46
+ * @see https://zed.dev/schema/themes/v0.2.0.json
47
+ */
48
+ interface ZedThemeVariant {
49
+ /** Theme label shown in Zed's theme picker. */
50
+ name: string;
51
+ appearance: "dark" | "light";
52
+ style: Record<string, unknown>;
53
+ }
54
+ /**
55
+ * Zed theme collection document (`themes/*.json`).
56
+ *
57
+ * Matches the format used by official Zed extensions such as
58
+ * [Dracula for Zed](https://draculatheme.com/zed).
59
+ *
60
+ * @see https://zed.dev/schema/themes/v0.2.0.json
61
+ */
62
+ interface ZedTheme {
63
+ /** Collection name — also used for the theme file slug when omitted. */
64
+ name: string;
65
+ /** JSON schema URL written to `$schema`. */
66
+ $schema?: string;
67
+ author?: string;
68
+ themes: ZedThemeVariant[];
69
+ }
70
+ /**
71
+ * Map extracted design tokens to one or more Zed theme collection documents.
72
+ *
73
+ * Return a single collection, an array, or a record keyed by collection id.
74
+ */
75
+ type GenerateZedTheme = (tokens: Tokens | Record<string, Tokens>) => ZedTheme | ZedTheme[] | Record<string, ZedTheme>;
76
+ /**
77
+ * Options for the Razorwind Zed theme extension generator.
78
+ *
79
+ * @see https://draculatheme.com/zed
80
+ */
81
+ interface ZedPluginOptions {
82
+ /**
83
+ * Directory (relative to the execution cwd) for the generated extension
84
+ * package.
85
+ *
86
+ * @defaultValue `"zed-extension"`
87
+ */
88
+ outputPath?: string;
89
+ /**
90
+ * Map extracted tokens to Zed theme collection JSON document(s).
91
+ *
92
+ * Required — without a mapping there is nothing to emit.
93
+ */
94
+ mapTheme: GenerateZedTheme;
95
+ /**
96
+ * Extension id written to `extension.toml`.
97
+ *
98
+ * Must be a lowercase slug (no scopes).
99
+ */
100
+ id: string;
101
+ /**
102
+ * Human-readable extension name. Defaults to a title-cased {@link id}.
103
+ */
104
+ name?: string;
105
+ /**
106
+ * Extension version (semver).
107
+ *
108
+ * @defaultValue `"0.0.1"`
109
+ */
110
+ version?: string;
111
+ /**
112
+ * `extension.toml` schema version.
113
+ *
114
+ * @defaultValue `1`
115
+ */
116
+ schemaVersion?: number;
117
+ /**
118
+ * Extension authors for `extension.toml`.
119
+ *
120
+ * @example `["Jane Doe <jane@example.com>"]`
121
+ */
122
+ authors?: string[];
123
+ /** Extension short description. */
124
+ description?: string;
125
+ /** Source repository URL for `extension.toml`. */
126
+ repository?: string;
127
+ /**
128
+ * Default `$schema` for emitted theme JSON when {@link ZedTheme.$schema} is
129
+ * omitted.
130
+ *
131
+ * @defaultValue `"https://zed.dev/schema/themes/v0.2.0.json"`
132
+ */
133
+ themeSchema?: string;
134
+ /**
135
+ * Extension README body. When omitted, a minimal overview is generated from
136
+ * contributed themes.
137
+ */
138
+ readme?: string;
139
+ /**
140
+ * Override body for generated `INSTALL.md`. When omitted, Zed install steps
141
+ * are written (extensions store + manual copy to `~/.config/zed/themes`).
142
+ *
143
+ * @see https://draculatheme.com/zed
144
+ */
145
+ installGuide?: string;
146
+ /**
147
+ * Restrict flattened helper tokens to these DTCG `$type` values.
148
+ * Does not filter what {@link mapTheme} receives.
149
+ */
150
+ includeTypes?: TokenType[];
151
+ }
152
+ //#endregion
153
+ //#region src/flatten.d.ts
154
+ interface TokenSet {
155
+ id: string;
156
+ tokens: Tokens;
157
+ }
158
+ /**
159
+ * Split `Schema.tokens` into one or more named token sets.
160
+ */
161
+ declare function resolveTokenSets(tokens: Tokens | Record<string, Tokens>): TokenSet[];
162
+ /**
163
+ * Flatten DTCG token trees into rows helpful for {@link ZedPluginOptions.mapTheme}.
164
+ */
165
+ declare function flattenTokens(tokens: Tokens | Record<string, Tokens>, options?: Pick<ZedPluginOptions, "includeTypes">): FlatToken[];
166
+ //#endregion
167
+ //#region src/scripts.d.ts
168
+ /**
169
+ * Zed-specific install guide (extensions store + manual copy).
170
+ *
171
+ * @see https://draculatheme.com/zed
172
+ */
173
+ declare function renderInstallMd(options: {
174
+ displayName: string;
175
+ extensionId: string;
176
+ themes: Array<{
177
+ label: string;
178
+ path: string;
179
+ fileName: string;
180
+ }>;
181
+ }): string;
182
+ //#endregion
183
+ //#region src/generate.d.ts
184
+ /**
185
+ * Normalize {@link ZedPluginOptions.mapTheme} results into a theme list.
186
+ */
187
+ declare function normalizeThemes(result: ZedTheme | ZedTheme[] | Record<string, ZedTheme>): ZedTheme[];
188
+ /**
189
+ * Serialize a Zed theme collection document for `themes/*.json`.
190
+ *
191
+ * @see https://zed.dev/schema/themes/v0.2.0.json
192
+ */
193
+ declare function renderThemeJson(theme: ZedTheme, defaultSchema?: string): string;
194
+ /**
195
+ * Build the Zed extension `extension.toml` manifest.
196
+ */
197
+ declare function renderExtensionToml(options: ZedPluginOptions): string;
198
+ /**
199
+ * Generate a Zed-installable theme extension package from a Razorwind schema.
200
+ *
201
+ * Emits theme collection JSON, `extension.toml`, `README.md`, and `INSTALL.md`.
202
+ *
203
+ * @see https://draculatheme.com/zed
204
+ */
205
+ declare function generateZedExtension(spec: Schema, options: ZedPluginOptions): GeneratorFunctionResult<Schema, ZedPluginOptions>;
206
+ //#endregion
207
+ //#region src/index.d.ts
208
+ /**
209
+ * Razorwind plugin that turns design tokens into a Zed-installable theme
210
+ * extension (`extension.toml`, theme collection JSON, INSTALL.md).
211
+ *
212
+ * Provide {@link ZedPluginOptions.mapTheme} to map extracted tokens to one or
213
+ * more Zed theme collection documents. Install in Zed via the extensions store
214
+ * or by copying theme JSON to `~/.config/zed/themes` (same flow as
215
+ * [Dracula for Zed](https://draculatheme.com/zed)).
216
+ *
217
+ * @see https://zed.dev/schema/themes/v0.2.0.json
218
+ * @see https://draculatheme.com/zed
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * import { defineConfig } from "@razorwind/core";
223
+ * import zed, { flattenTokens } from "@razorwind/zed";
224
+ *
225
+ * export default defineConfig({
226
+ * plugins: [
227
+ * zed({
228
+ * id: "my-theme",
229
+ * name: "My Theme",
230
+ * authors: ["Acme <themes@acme.com>"],
231
+ * mapTheme: tokens => {
232
+ * const flat = flattenTokens(tokens);
233
+ * const color = (path: string) =>
234
+ * flat.find(t => t.path === path)?.cssValue ?? "#000000";
235
+ *
236
+ * return {
237
+ * name: "My Theme",
238
+ * themes: [
239
+ * {
240
+ * name: "My Theme Dark",
241
+ * appearance: "dark",
242
+ * style: {
243
+ * "editor.background": color("color.bg"),
244
+ * "editor.foreground": color("color.fg"),
245
+ * syntax: {
246
+ * comment: { color: color("color.muted") }
247
+ * }
248
+ * }
249
+ * }
250
+ * ]
251
+ * };
252
+ * }
253
+ * })
254
+ * ]
255
+ * });
256
+ * ```
257
+ */
258
+ declare const _default: (options?: ZedPluginOptions | undefined) => import("@razorwind/core/plugin").Plugin;
259
+ //#endregion
260
+ export { type FlatToken, type GenerateZedTheme, type ZedPlayerColors, type ZedPluginOptions, type ZedSyntaxStyle, type ZedTheme, type ZedThemeVariant, _default as default, flattenTokens, formatTokenValue, generateZedExtension, normalizeThemes, renderExtensionToml, renderInstallMd, renderThemeJson, resolveTokenSets, toCssVar };
261
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/scripts.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAwBiB;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;EACf;EACA;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;;;;;UAUe;;EAEf;EACA;EACA,OAAO;;;;;;;;;;UAWQ;;EAEf;;EAEA;EACA;EACA,QAAQ;;;;;;;KAQE,oBACV,QAAQ,SAAS,eAAe,YAC7B,WAAW,aAAa,eAAe;;;;;;UAO3B;;;;;;;EAOf;;;;;;EAOA,UAAU;;;;;;EAOV;;;;EAKA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;EAGA;;EAGA;;;;;;;EAQA;;;;;EAMA;;;;;;;EAQA;;;;;EAMA,eAAe;;;;UC7EA;EACf;EACA,QAAQ;;;;;iBAMM,iBACd,QAAQ,SAAS,eAAe,UAC/B;;;;iBAwBa,cACd,QAAQ,SAAS,eAAe,SAChC,UAAS,KAAK,oCACb;;;;;;;;iBCzFa,gBAAgB;EAC9B;EACA;EACA,QAAQ;IAAQ;IAAe;IAAc;;;;;;;;iBCqB/B,gBACd,QAAQ,WAAW,aAAa,eAAe,YAC9C;;;;;;iBA4Da,gBACd,OAAO,UACP;;;;iBAkBc,oBAAoB,SAAS;;;;;;;;iBAuC7B,qBACd,MAAM,QACN,SAAS,mBACR,wBAAwB,QAAQ"}
@@ -0,0 +1,261 @@
1
+ import { formatTokenValue, toCssVar } from "@razorwind/core/utils";
2
+ import { Schema, Tokens } from "@razorwind/core/schema";
3
+ import { TokenType } from "@power-plant/dtcg-schema";
4
+ import { GeneratorFunctionResult } from "@power-plant/core";
5
+ //#region src/types.d.ts
6
+ /**
7
+ * A flattened design token ready for Zed 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
+ /**
24
+ * Zed syntax highlight style entry.
25
+ *
26
+ * @see https://zed.dev/schema/themes/v0.2.0.json
27
+ */
28
+ interface ZedSyntaxStyle {
29
+ color?: string | null;
30
+ font_style?: string | null;
31
+ font_weight?: number | null;
32
+ }
33
+ /**
34
+ * Collaborative player cursor colors in a Zed theme variant.
35
+ */
36
+ interface ZedPlayerColors {
37
+ cursor?: string;
38
+ background?: string;
39
+ selection?: string;
40
+ }
41
+ /**
42
+ * One appearance variant inside a Zed theme collection document.
43
+ *
44
+ * `style` holds UI color keys, optional `syntax` map, and optional `players`.
45
+ *
46
+ * @see https://zed.dev/schema/themes/v0.2.0.json
47
+ */
48
+ interface ZedThemeVariant {
49
+ /** Theme label shown in Zed's theme picker. */
50
+ name: string;
51
+ appearance: "dark" | "light";
52
+ style: Record<string, unknown>;
53
+ }
54
+ /**
55
+ * Zed theme collection document (`themes/*.json`).
56
+ *
57
+ * Matches the format used by official Zed extensions such as
58
+ * [Dracula for Zed](https://draculatheme.com/zed).
59
+ *
60
+ * @see https://zed.dev/schema/themes/v0.2.0.json
61
+ */
62
+ interface ZedTheme {
63
+ /** Collection name — also used for the theme file slug when omitted. */
64
+ name: string;
65
+ /** JSON schema URL written to `$schema`. */
66
+ $schema?: string;
67
+ author?: string;
68
+ themes: ZedThemeVariant[];
69
+ }
70
+ /**
71
+ * Map extracted design tokens to one or more Zed theme collection documents.
72
+ *
73
+ * Return a single collection, an array, or a record keyed by collection id.
74
+ */
75
+ type GenerateZedTheme = (tokens: Tokens | Record<string, Tokens>) => ZedTheme | ZedTheme[] | Record<string, ZedTheme>;
76
+ /**
77
+ * Options for the Razorwind Zed theme extension generator.
78
+ *
79
+ * @see https://draculatheme.com/zed
80
+ */
81
+ interface ZedPluginOptions {
82
+ /**
83
+ * Directory (relative to the execution cwd) for the generated extension
84
+ * package.
85
+ *
86
+ * @defaultValue `"zed-extension"`
87
+ */
88
+ outputPath?: string;
89
+ /**
90
+ * Map extracted tokens to Zed theme collection JSON document(s).
91
+ *
92
+ * Required — without a mapping there is nothing to emit.
93
+ */
94
+ mapTheme: GenerateZedTheme;
95
+ /**
96
+ * Extension id written to `extension.toml`.
97
+ *
98
+ * Must be a lowercase slug (no scopes).
99
+ */
100
+ id: string;
101
+ /**
102
+ * Human-readable extension name. Defaults to a title-cased {@link id}.
103
+ */
104
+ name?: string;
105
+ /**
106
+ * Extension version (semver).
107
+ *
108
+ * @defaultValue `"0.0.1"`
109
+ */
110
+ version?: string;
111
+ /**
112
+ * `extension.toml` schema version.
113
+ *
114
+ * @defaultValue `1`
115
+ */
116
+ schemaVersion?: number;
117
+ /**
118
+ * Extension authors for `extension.toml`.
119
+ *
120
+ * @example `["Jane Doe <jane@example.com>"]`
121
+ */
122
+ authors?: string[];
123
+ /** Extension short description. */
124
+ description?: string;
125
+ /** Source repository URL for `extension.toml`. */
126
+ repository?: string;
127
+ /**
128
+ * Default `$schema` for emitted theme JSON when {@link ZedTheme.$schema} is
129
+ * omitted.
130
+ *
131
+ * @defaultValue `"https://zed.dev/schema/themes/v0.2.0.json"`
132
+ */
133
+ themeSchema?: string;
134
+ /**
135
+ * Extension README body. When omitted, a minimal overview is generated from
136
+ * contributed themes.
137
+ */
138
+ readme?: string;
139
+ /**
140
+ * Override body for generated `INSTALL.md`. When omitted, Zed install steps
141
+ * are written (extensions store + manual copy to `~/.config/zed/themes`).
142
+ *
143
+ * @see https://draculatheme.com/zed
144
+ */
145
+ installGuide?: string;
146
+ /**
147
+ * Restrict flattened helper tokens to these DTCG `$type` values.
148
+ * Does not filter what {@link mapTheme} receives.
149
+ */
150
+ includeTypes?: TokenType[];
151
+ }
152
+ //#endregion
153
+ //#region src/flatten.d.ts
154
+ interface TokenSet {
155
+ id: string;
156
+ tokens: Tokens;
157
+ }
158
+ /**
159
+ * Split `Schema.tokens` into one or more named token sets.
160
+ */
161
+ declare function resolveTokenSets(tokens: Tokens | Record<string, Tokens>): TokenSet[];
162
+ /**
163
+ * Flatten DTCG token trees into rows helpful for {@link ZedPluginOptions.mapTheme}.
164
+ */
165
+ declare function flattenTokens(tokens: Tokens | Record<string, Tokens>, options?: Pick<ZedPluginOptions, "includeTypes">): FlatToken[];
166
+ //#endregion
167
+ //#region src/scripts.d.ts
168
+ /**
169
+ * Zed-specific install guide (extensions store + manual copy).
170
+ *
171
+ * @see https://draculatheme.com/zed
172
+ */
173
+ declare function renderInstallMd(options: {
174
+ displayName: string;
175
+ extensionId: string;
176
+ themes: Array<{
177
+ label: string;
178
+ path: string;
179
+ fileName: string;
180
+ }>;
181
+ }): string;
182
+ //#endregion
183
+ //#region src/generate.d.ts
184
+ /**
185
+ * Normalize {@link ZedPluginOptions.mapTheme} results into a theme list.
186
+ */
187
+ declare function normalizeThemes(result: ZedTheme | ZedTheme[] | Record<string, ZedTheme>): ZedTheme[];
188
+ /**
189
+ * Serialize a Zed theme collection document for `themes/*.json`.
190
+ *
191
+ * @see https://zed.dev/schema/themes/v0.2.0.json
192
+ */
193
+ declare function renderThemeJson(theme: ZedTheme, defaultSchema?: string): string;
194
+ /**
195
+ * Build the Zed extension `extension.toml` manifest.
196
+ */
197
+ declare function renderExtensionToml(options: ZedPluginOptions): string;
198
+ /**
199
+ * Generate a Zed-installable theme extension package from a Razorwind schema.
200
+ *
201
+ * Emits theme collection JSON, `extension.toml`, `README.md`, and `INSTALL.md`.
202
+ *
203
+ * @see https://draculatheme.com/zed
204
+ */
205
+ declare function generateZedExtension(spec: Schema, options: ZedPluginOptions): GeneratorFunctionResult<Schema, ZedPluginOptions>;
206
+ //#endregion
207
+ //#region src/index.d.ts
208
+ /**
209
+ * Razorwind plugin that turns design tokens into a Zed-installable theme
210
+ * extension (`extension.toml`, theme collection JSON, INSTALL.md).
211
+ *
212
+ * Provide {@link ZedPluginOptions.mapTheme} to map extracted tokens to one or
213
+ * more Zed theme collection documents. Install in Zed via the extensions store
214
+ * or by copying theme JSON to `~/.config/zed/themes` (same flow as
215
+ * [Dracula for Zed](https://draculatheme.com/zed)).
216
+ *
217
+ * @see https://zed.dev/schema/themes/v0.2.0.json
218
+ * @see https://draculatheme.com/zed
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * import { defineConfig } from "@razorwind/core";
223
+ * import zed, { flattenTokens } from "@razorwind/zed";
224
+ *
225
+ * export default defineConfig({
226
+ * plugins: [
227
+ * zed({
228
+ * id: "my-theme",
229
+ * name: "My Theme",
230
+ * authors: ["Acme <themes@acme.com>"],
231
+ * mapTheme: tokens => {
232
+ * const flat = flattenTokens(tokens);
233
+ * const color = (path: string) =>
234
+ * flat.find(t => t.path === path)?.cssValue ?? "#000000";
235
+ *
236
+ * return {
237
+ * name: "My Theme",
238
+ * themes: [
239
+ * {
240
+ * name: "My Theme Dark",
241
+ * appearance: "dark",
242
+ * style: {
243
+ * "editor.background": color("color.bg"),
244
+ * "editor.foreground": color("color.fg"),
245
+ * syntax: {
246
+ * comment: { color: color("color.muted") }
247
+ * }
248
+ * }
249
+ * }
250
+ * ]
251
+ * };
252
+ * }
253
+ * })
254
+ * ]
255
+ * });
256
+ * ```
257
+ */
258
+ declare const _default: (options?: ZedPluginOptions | undefined) => import("@razorwind/core/plugin").Plugin;
259
+ //#endregion
260
+ export { type FlatToken, type GenerateZedTheme, type ZedPlayerColors, type ZedPluginOptions, type ZedSyntaxStyle, type ZedTheme, type ZedThemeVariant, _default as default, flattenTokens, formatTokenValue, generateZedExtension, normalizeThemes, renderExtensionToml, renderInstallMd, renderThemeJson, resolveTokenSets, toCssVar };
261
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/scripts.ts","../src/generate.ts","../src/index.ts"],"mappings":""}
package/dist/index.mjs ADDED
@@ -0,0 +1,54 @@
1
+ import{definePlugin as e}from"@razorwind/core/plugin";import{createDocument as t,formatTokenValue as n,formatTokenValue as r,isObject as i,toCssVar as a}from"@razorwind/core/utils";import{join as o}from"node:path";const s=/^(?:light|dark|dim|dimmed|high-contrast|hc|protanopia|deuteranopia|tritanopia|achromatopsia|achromatomaly|monochrome|monochromatic|grayscale|greyscale|bw|black-and-white|black-white|blackWhite|default|base|theme)(?:[A-Z]\w*|[._-].+)?$/i;function c(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function l(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function u(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function d(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 f(e,t,n,a,o){if(!i(e))return;let s=u(e,n);if(c(e)){let n=d(e);o.push({path:t.join(`.`),type:s,value:n,cssValue:r(n,s),description:l(e),theme:a});return}for(let[n,r]of Object.entries(e))n.startsWith(`$`)||f(r,[...t,n],s,a,o)}function p(e){if(!i(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));if(t.length>0&&t.every(e=>s.test(e))){let n=e;return t.map(e=>({id:e,tokens:n[e]}))}return[{id:`default`,tokens:e}]}function m(e,t={}){let n=t.includeTypes?new Set(t.includeTypes):void 0,r=[];for(let t of p(e)){let e=t.id==="default"?void 0:t.id;f(t.tokens,[],void 0,e,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}function h(e){let t=e.themes.map(e=>`- ${e.label}`).join(`
2
+ `),n=e.repositoryUrl?`\n## Links\n\n- [GitHub](${e.repositoryUrl})\n`:``;return`# ${e.displayName}
3
+
4
+ ${e.description}
5
+
6
+ ## Installation
7
+
8
+ See **INSTALL.md** for Zed extension store and manual theme install steps.
9
+
10
+ ## Themes
11
+
12
+ ${t||`- (generated themes)`}
13
+ ${n}`}function g(e){let t=e.themes.map(e=>`- \`${e.path}\` — ${e.label}`).join(`
14
+ `),n=e.themes.map(e=>`- **${e.label}**`).join(`
15
+ `),r=e.themes.map(e=>`- \`${e.fileName}\``).join(`
16
+ `);return`# Installing ${e.displayName}
17
+
18
+ Generated by \`@razorwind/zed\`.
19
+
20
+ ## Files
21
+
22
+ - \`extension.toml\` — Zed extension manifest
23
+ - \`themes/*.json\` — Zed theme collection documents
24
+ ${t}
25
+
26
+ ## Install in Zed (extensions store)
27
+
28
+ 1. Open Zed and open the extensions panel.
29
+ 2. Search for **${e.displayName}** (extension id: \`${e.extensionId}\`) or publish this folder as a Zed extension.
30
+ 3. After installing, open **Settings → Select Theme** and pick a variant:
31
+
32
+ ${n}
33
+
34
+ ## Install manually
35
+
36
+ Copy theme JSON into Zed's themes directory:
37
+
38
+ \`\`\`bash
39
+ mkdir -p ~/.config/zed/themes
40
+ cp themes/*.json ~/.config/zed/themes/
41
+ \`\`\`
42
+
43
+ Files:
44
+
45
+ ${r}
46
+
47
+ Then open **Settings → Select Theme** and choose a variant listed above.
48
+
49
+ ## Select theme
50
+
51
+ \`Settings → Select Theme\` → pick a variant label from this extension.
52
+ `}const _={name:`razorwind-zed`},v=`https://zed.dev/schema/themes/v0.2.0.json`;function y(e,n,r){return t(e,n,_,r)}function b(e){return e.split(/[-_.\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function x(e){return e.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g,`-`).replaceAll(/^-+|-+$/g,``)}function S(e){return i(e)&&typeof e.name==`string`&&(e.appearance===`dark`||e.appearance===`light`)&&i(e.style)}function C(e){return i(e)&&typeof e.name==`string`&&Array.isArray(e.themes)&&e.themes.length>0&&e.themes.every(S)}function w(e){if(Array.isArray(e))return e.map((e,t)=>{if(!C(e))throw TypeError(`@razorwind/zed mapTheme()[${t}] must be a ZedTheme with name + themes[]`);return e});if(C(e))return[e];if(!i(e))throw TypeError(`@razorwind/zed mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!C(t))throw TypeError(`@razorwind/zed mapTheme()["${e}"] must be a ZedTheme with name + themes[]`);return{...t,name:t.name||e}})}function T(e){if(!e.mapTheme)throw Error(`@razorwind/zed requires options.mapTheme`);if(!e.id||e.id.includes(`/`))throw Error(`@razorwind/zed requires options.id (unscoped extension id slug)`)}function E(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function D(e,t=v){let n={$schema:e.$schema??t,name:e.name,themes:e.themes};return e.author&&(n.author=e.author),`${JSON.stringify(n,null,2)}\n`}function O(e){let t=e.name??b(e.id),n=e.description??`${t} — Zed themes generated by Razorwind`,r=[`id = "${E(e.id)}"`,`name = "${E(t)}"`,`version = "${E(e.version??`0.0.1`)}"`,`schema_version = ${e.schemaVersion??1}`,`description = "${E(n)}"`];if(e.authors?.length){let t=e.authors.map(e=>`"${E(e)}"`).join(`, `);r.push(`authors = [${t}]`)}return e.repository&&r.push(`repository = "${E(e.repository)}"`),`${r.join(`
53
+ `)}\n`}function k(e,t){T(t);let n=t.outputPath??`zed-extension`,r=t.name??b(t.id),i=t.description??`${r} — Zed themes generated by Razorwind`,a=t.themeSchema??v,s=w(t.mapTheme(e.tokens));if(s.length===0)throw Error(`@razorwind/zed mapTheme() returned no themes`);let c={},l=new Set,u=[];for(let e of s){let t=x(e.name);if(l.has(t)){let n=2;for(;l.has(`${x(e.name)}-${n}`);)n+=1;t=`${x(e.name)}-${n}`}l.add(t);let r=`${t}.json`,i=o(n,`themes`,r);c[i]=y(i,D(e,a),`json`);for(let n of e.themes)u.push({label:n.name,path:`themes/${r}`,slug:t,fileName:r})}let d=o(n,`extension.toml`);c[d]=y(d,O(t),`toml`);let f=u.map(e=>({label:e.label})),p=t.readme??h({displayName:r,description:i,themes:f,repositoryUrl:t.repository}),m=o(n,`README.md`);c[m]=y(m,p,`markdown`);let _=t.installGuide??g({displayName:r,extensionId:t.id,themes:u}),S=o(n,`INSTALL.md`);return c[S]=y(S,_,`markdown`),c}var A=e(e=>({name:`zed`,generate:async t=>{if(!e)throw Error(`@razorwind/zed requires options: { id, mapTheme }`);return k(t,e)}}));export{A as default,m as flattenTokens,n as formatTokenValue,k as generateZedExtension,w as normalizeThemes,O as renderExtensionToml,g as renderInstallMd,D as renderThemeJson,p as resolveTokenSets,a as toCssVar};
54
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@razorwind/zed",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "description": "Razorwind Zed theme extension plugin that creates Zed theme extensions from design tokens.",
6
+ "repository": {
7
+ "type": "github",
8
+ "url": "https://github.com/storm-software/razorwind.git",
9
+ "directory": "packages/zed"
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
+ "zed",
26
+ "theme",
27
+ "razorwind",
28
+ "design-tokens",
29
+ "dtcg",
30
+ "storm-software"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "require": {
35
+ "types": "./dist/index.d.cts",
36
+ "default": "./dist/index.cjs"
37
+ },
38
+ "import": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "default": {
43
+ "types": "./dist/index.d.mts",
44
+ "default": "./dist/index.mjs"
45
+ }
46
+ },
47
+ "./generate": {
48
+ "require": {
49
+ "types": "./dist/index.d.cts",
50
+ "default": "./dist/index.cjs"
51
+ },
52
+ "import": {
53
+ "types": "./dist/index.d.mts",
54
+ "default": "./dist/index.mjs"
55
+ },
56
+ "default": {
57
+ "types": "./dist/index.d.mts",
58
+ "default": "./dist/index.mjs"
59
+ }
60
+ },
61
+ "./package.json": "./package.json"
62
+ },
63
+ "main": "./dist/index.cjs",
64
+ "module": "./dist/index.mjs",
65
+ "types": "./dist/index.d.cts",
66
+ "typings": "dist/index.d.mts",
67
+ "dependencies": {
68
+ "@power-plant/core": "^0.0.75",
69
+ "@power-plant/dtcg-schema": "^0.0.1",
70
+ "@razorwind/core": "0.0.28"
71
+ },
72
+ "devDependencies": {
73
+ "@powerlines/plugin-tsdown": "^0.1.589",
74
+ "@types/node": "^25.9.5",
75
+ "typescript": "^6.0.3"
76
+ },
77
+ "publishConfig": { "access": "public" },
78
+ "gitHead": "1035cb442a4b46f2373951c74b1c89821749be2b"
79
+ }