@razorwind/zed 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +18 -32
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +18 -32
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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");
|
|
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.map(e=>`- ${e.label}`).join(`
|
|
2
2
|
`),n=e.repositoryUrl?`\n## Links\n\n- [GitHub](${e.repositoryUrl})\n`:``;return`# ${e.displayName}
|
|
3
3
|
|
|
4
4
|
${e.description}
|
|
@@ -10,7 +10,7 @@ See **INSTALL.md** for Zed extension store and manual theme install steps.
|
|
|
10
10
|
## Themes
|
|
11
11
|
|
|
12
12
|
${t||`- (generated themes)`}
|
|
13
|
-
${n}`}function
|
|
13
|
+
${n}`}function i(e){let t=e.themes.map(e=>`- \`${e.path}\` — ${e.label}`).join(`
|
|
14
14
|
`),n=e.themes.map(e=>`- **${e.label}**`).join(`
|
|
15
15
|
`),r=e.themes.map(e=>`- \`${e.fileName}\``).join(`
|
|
16
16
|
`);return`# Installing ${e.displayName}
|
|
@@ -49,5 +49,5 @@ Then open **Settings → Select Theme** and choose a variant listed above.
|
|
|
49
49
|
## Select theme
|
|
50
50
|
|
|
51
51
|
\`Settings → Select Theme\` → pick a variant label from this extension.
|
|
52
|
-
`}const
|
|
53
|
-
`)}\n`}function
|
|
52
|
+
`}const a={name:`razorwind-zed`},o=`https://zed.dev/schema/themes/v0.2.0.json`;function s(e,n,r){return(0,t.createDocument)(e,n,a,r)}function c(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&(e.appearance===`dark`||e.appearance===`light`)&&(0,t.isObject)(e.style)}function l(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&Array.isArray(e.themes)&&e.themes.length>0&&e.themes.every(c)}function u(e){if(Array.isArray(e))return e.map((e,t)=>{if(!l(e))throw TypeError(`@razorwind/zed mapTheme()[${t}] must be a ZedTheme with name + themes[]`);return e});if(l(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(!l(t))throw TypeError(`@razorwind/zed mapTheme()["${e}"] must be a ZedTheme with name + themes[]`);return{...t,name:t.name||e}})}function d(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 f(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function p(e,t=o){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 m(e){let n=e.name??(0,t.titleCase)(e.id),r=e.description??`${n} — Zed themes generated by Razorwind`,i=[`id = "${f(e.id)}"`,`name = "${f(n)}"`,`version = "${f(e.version??`0.0.1`)}"`,`schema_version = ${e.schemaVersion??1}`,`description = "${f(r)}"`];if(e.authors?.length){let t=e.authors.map(e=>`"${f(e)}"`).join(`, `);i.push(`authors = [${t}]`)}return e.repository&&i.push(`repository = "${f(e.repository)}"`),`${i.join(`
|
|
53
|
+
`)}\n`}function h(e,a){d(a);let c=a.outputPath??`zed-extension`,l=a.name??(0,t.titleCase)(a.id),f=a.description??`${l} — Zed themes generated by Razorwind`,h=a.themeSchema??o,g=u(a.mapTheme(e.tokens));if(g.length===0)throw Error(`@razorwind/zed mapTheme() returned no themes`);let _={},v=new Set,y=[];for(let e of g){let r=(0,t.slugifyThemeName)(e.name);if(v.has(r)){let n=2;for(;v.has(`${(0,t.slugifyThemeName)(e.name)}-${n}`);)n+=1;r=`${(0,t.slugifyThemeName)(e.name)}-${n}`}v.add(r);let i=`${r}.json`,a=(0,n.join)(c,`themes`,i);_[a]=s(a,p(e,h),`json`);for(let t of e.themes)y.push({label:t.name,path:`themes/${i}`,slug:r,fileName:i})}let b=(0,n.join)(c,`extension.toml`);_[b]=s(b,m(a),`toml`);let x=y.map(e=>({label:e.label})),S=a.readme??r({displayName:l,description:f,themes:x,repositoryUrl:a.repository}),C=(0,n.join)(c,`README.md`);_[C]=s(C,S,`markdown`);let w=a.installGuide??i({displayName:l,extensionId:a.id,themes:y}),T=(0,n.join)(c,`INSTALL.md`);return _[T]=s(T,w,`markdown`),_}var g=(0,e.definePlugin)(e=>({name:`zed`,generate:async t=>{if(!e)throw Error(`@razorwind/zed requires options: { id, mapTheme }`);return h(t,e)}}));exports.default=g,Object.defineProperty(exports,"flattenTokens",{enumerable:!0,get:function(){return t.flattenTokens}}),Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateZedExtension=h,exports.normalizeThemes=u,exports.renderExtensionToml=m,exports.renderInstallMd=i,exports.renderThemeJson=p,Object.defineProperty(exports,"resolveTokenSets",{enumerable:!0,get:function(){return t.resolveTokenSets}}),Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import { flattenTokens, formatTokenValue, resolveTokenSets, toCssVar } from "@razorwind/core/utils";
|
|
2
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
1
3
|
import { Schema, Tokens } from "@razorwind/core/schema";
|
|
2
4
|
import { TokenType } from "@power-plant/dtcg-schema";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
//#region src/scripts.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Zed-specific install guide (extensions store + manual copy).
|
|
8
|
+
*
|
|
9
|
+
* @see https://draculatheme.com/zed
|
|
10
|
+
*/
|
|
11
|
+
declare function renderInstallMd(options: {
|
|
12
|
+
displayName: string;
|
|
13
|
+
extensionId: string;
|
|
14
|
+
themes: Array<{
|
|
15
|
+
label: string;
|
|
16
|
+
path: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
}>;
|
|
19
|
+
}): string;
|
|
20
|
+
//#endregion
|
|
5
21
|
//#region src/types.d.ts
|
|
6
22
|
/**
|
|
7
23
|
* A flattened design token ready for Zed theme mapping.
|
|
@@ -150,36 +166,6 @@ interface ZedPluginOptions {
|
|
|
150
166
|
includeTypes?: TokenType[];
|
|
151
167
|
}
|
|
152
168
|
//#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
169
|
//#region src/generate.d.ts
|
|
184
170
|
/**
|
|
185
171
|
* Normalize {@link ZedPluginOptions.mapTheme} results into a theme list.
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/scripts.ts","../src/types.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;;;iBAwDgB,gBAAgB;EAC9B;EACA;EACA,QAAQ;IAAQ;IAAe;IAAc;;;;;;;;UCnC9B;;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;;;;;;;iBCzHD,gBACd,QAAQ,WAAW,aAAa,eAAe,YAC9C;;;;;;iBA4Da,gBACd,OAAO,UACP;;;;iBAkBc,oBAAoB,SAAS;;;;;;;;iBAuC7B,qBACd,MAAM,QACN,SAAS,mBACR,wBAAwB,QAAQ"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import { formatTokenValue, toCssVar } from "@razorwind/core/utils";
|
|
1
|
+
import { flattenTokens, formatTokenValue, resolveTokenSets, toCssVar } from "@razorwind/core/utils";
|
|
2
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
2
3
|
import { Schema, Tokens } from "@razorwind/core/schema";
|
|
3
4
|
import { TokenType } from "@power-plant/dtcg-schema";
|
|
4
|
-
|
|
5
|
+
//#region src/scripts.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Zed-specific install guide (extensions store + manual copy).
|
|
8
|
+
*
|
|
9
|
+
* @see https://draculatheme.com/zed
|
|
10
|
+
*/
|
|
11
|
+
declare function renderInstallMd(options: {
|
|
12
|
+
displayName: string;
|
|
13
|
+
extensionId: string;
|
|
14
|
+
themes: Array<{
|
|
15
|
+
label: string;
|
|
16
|
+
path: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
}>;
|
|
19
|
+
}): string;
|
|
20
|
+
//#endregion
|
|
5
21
|
//#region src/types.d.ts
|
|
6
22
|
/**
|
|
7
23
|
* A flattened design token ready for Zed theme mapping.
|
|
@@ -150,36 +166,6 @@ interface ZedPluginOptions {
|
|
|
150
166
|
includeTypes?: TokenType[];
|
|
151
167
|
}
|
|
152
168
|
//#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
169
|
//#region src/generate.d.ts
|
|
184
170
|
/**
|
|
185
171
|
* Normalize {@link ZedPluginOptions.mapTheme} results into a theme list.
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/scripts.ts","../src/types.ts","../src/generate.ts","../src/index.ts"],"mappings":""}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{definePlugin as e}from"@razorwind/core/plugin";import{createDocument as t,
|
|
1
|
+
import{definePlugin as e}from"@razorwind/core/plugin";import{createDocument as t,flattenTokens as n,formatTokenValue as r,isObject as i,resolveTokenSets as a,slugifyThemeName as o,titleCase as s,toCssVar as c}from"@razorwind/core/utils";import{join as l}from"node:path";function u(e){let t=e.themes.map(e=>`- ${e.label}`).join(`
|
|
2
2
|
`),n=e.repositoryUrl?`\n## Links\n\n- [GitHub](${e.repositoryUrl})\n`:``;return`# ${e.displayName}
|
|
3
3
|
|
|
4
4
|
${e.description}
|
|
@@ -10,7 +10,7 @@ See **INSTALL.md** for Zed extension store and manual theme install steps.
|
|
|
10
10
|
## Themes
|
|
11
11
|
|
|
12
12
|
${t||`- (generated themes)`}
|
|
13
|
-
${n}`}function
|
|
13
|
+
${n}`}function d(e){let t=e.themes.map(e=>`- \`${e.path}\` — ${e.label}`).join(`
|
|
14
14
|
`),n=e.themes.map(e=>`- **${e.label}**`).join(`
|
|
15
15
|
`),r=e.themes.map(e=>`- \`${e.fileName}\``).join(`
|
|
16
16
|
`);return`# Installing ${e.displayName}
|
|
@@ -49,6 +49,6 @@ Then open **Settings → Select Theme** and choose a variant listed above.
|
|
|
49
49
|
## Select theme
|
|
50
50
|
|
|
51
51
|
\`Settings → Select Theme\` → pick a variant label from this extension.
|
|
52
|
-
`}const
|
|
53
|
-
`)}\n`}function
|
|
52
|
+
`}const f={name:`razorwind-zed`},p=`https://zed.dev/schema/themes/v0.2.0.json`;function m(e,n,r){return t(e,n,f,r)}function h(e){return i(e)&&typeof e.name==`string`&&(e.appearance===`dark`||e.appearance===`light`)&&i(e.style)}function g(e){return i(e)&&typeof e.name==`string`&&Array.isArray(e.themes)&&e.themes.length>0&&e.themes.every(h)}function _(e){if(Array.isArray(e))return e.map((e,t)=>{if(!g(e))throw TypeError(`@razorwind/zed mapTheme()[${t}] must be a ZedTheme with name + themes[]`);return e});if(g(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(!g(t))throw TypeError(`@razorwind/zed mapTheme()["${e}"] must be a ZedTheme with name + themes[]`);return{...t,name:t.name||e}})}function v(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 y(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function b(e,t=p){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 x(e){let t=e.name??s(e.id),n=e.description??`${t} — Zed themes generated by Razorwind`,r=[`id = "${y(e.id)}"`,`name = "${y(t)}"`,`version = "${y(e.version??`0.0.1`)}"`,`schema_version = ${e.schemaVersion??1}`,`description = "${y(n)}"`];if(e.authors?.length){let t=e.authors.map(e=>`"${y(e)}"`).join(`, `);r.push(`authors = [${t}]`)}return e.repository&&r.push(`repository = "${y(e.repository)}"`),`${r.join(`
|
|
53
|
+
`)}\n`}function S(e,t){v(t);let n=t.outputPath??`zed-extension`,r=t.name??s(t.id),i=t.description??`${r} — Zed themes generated by Razorwind`,a=t.themeSchema??p,c=_(t.mapTheme(e.tokens));if(c.length===0)throw Error(`@razorwind/zed mapTheme() returned no themes`);let f={},h=new Set,g=[];for(let e of c){let t=o(e.name);if(h.has(t)){let n=2;for(;h.has(`${o(e.name)}-${n}`);)n+=1;t=`${o(e.name)}-${n}`}h.add(t);let r=`${t}.json`,i=l(n,`themes`,r);f[i]=m(i,b(e,a),`json`);for(let n of e.themes)g.push({label:n.name,path:`themes/${r}`,slug:t,fileName:r})}let y=l(n,`extension.toml`);f[y]=m(y,x(t),`toml`);let S=g.map(e=>({label:e.label})),C=t.readme??u({displayName:r,description:i,themes:S,repositoryUrl:t.repository}),w=l(n,`README.md`);f[w]=m(w,C,`markdown`);let T=t.installGuide??d({displayName:r,extensionId:t.id,themes:g}),E=l(n,`INSTALL.md`);return f[E]=m(E,T,`markdown`),f}var C=e(e=>({name:`zed`,generate:async t=>{if(!e)throw Error(`@razorwind/zed requires options: { id, mapTheme }`);return S(t,e)}}));export{C as default,n as flattenTokens,r as formatTokenValue,S as generateZedExtension,_ as normalizeThemes,x as renderExtensionToml,d as renderInstallMd,b as renderThemeJson,a as resolveTokenSets,c as toCssVar};
|
|
54
54
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/zed",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Razorwind Zed theme extension plugin that creates Zed theme extensions from design tokens.",
|
|
6
6
|
"repository": {
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
"types": "./dist/index.d.cts",
|
|
66
66
|
"typings": "dist/index.d.mts",
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@power-plant/core": "^0.0.
|
|
68
|
+
"@power-plant/core": "^0.0.81",
|
|
69
69
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
70
|
-
"@razorwind/core": "0.0.
|
|
70
|
+
"@razorwind/core": "^0.0.30"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@powerlines/plugin-tsdown": "^0.1.
|
|
73
|
+
"@powerlines/plugin-tsdown": "^0.1.590",
|
|
74
74
|
"@types/node": "^25.9.5",
|
|
75
75
|
"typescript": "^6.0.3"
|
|
76
76
|
},
|
|
77
77
|
"publishConfig": { "access": "public" },
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "11a6e827627acf51ef0044e366fd9493f2173ec2"
|
|
79
79
|
}
|