@razorwind/shiki 0.0.7 → 0.0.8
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 +2 -2
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
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");function r(e){let t=e.themes[0],n=e.themes.length===1?t.displayName:`Shiki Themes
|
|
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:`Shiki Themes`),r=e.themes.map(e=>`- \`${e.fileName}\` — ${e.displayName} (theme id: \`${e.name}\`)`).join(`
|
|
2
2
|
`),i=e.themes.map(e=>`- \`${e.name}\` — ${e.displayName}`).join(`
|
|
3
3
|
`);return`# Installing ${n}
|
|
4
4
|
|
|
@@ -45,4 +45,4 @@ await highlighter.loadTheme(theme);
|
|
|
45
45
|
Pass the theme id to \`codeToHtml\`, \`codeToTokens\`, or \`getTokenStyle\`:
|
|
46
46
|
|
|
47
47
|
${i}
|
|
48
|
-
`}function i(e){return(0,t.themeDisplayName)(e)}const a={name:`razorwind-shiki`};function o(e,n,r){return(0,t.createDocument)(e,n,a,r)}function s(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&e.name.length>0}function c(e){if(Array.isArray(e))return e.map((e,t)=>{if(!s(e))throw TypeError(`@razorwind/shiki mapTheme()[${t}] must be a ShikiTheme with name`);return e});if(s(e))return[e];if(!(0,t.isObject)(e))throw TypeError(`@razorwind/shiki mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!s(t))throw TypeError(`@razorwind/shiki mapTheme()["${e}"] must be a ShikiTheme with name`);return{...t,name:t.name||e}})}function l(e){if(!e.mapTheme)throw Error(`@razorwind/shiki requires options.mapTheme`)}function u(e){let t=e.settings??e.tokenColors??[],n={name:e.name,settings:t};return e.displayName&&(n.displayName=e.displayName),e.type&&(n.type=e.type),e.fg!==void 0&&(n.fg=e.fg),e.bg!==void 0&&(n.bg=e.bg),e.colors&&(n.colors=e.colors),e.tokenColors&&e.settings&&(n.tokenColors=e.tokenColors),e.colorReplacements&&(n.colorReplacements=e.colorReplacements),e.semanticHighlighting!==void 0&&(n.semanticHighlighting=e.semanticHighlighting),e.semanticTokenColors&&(n.semanticTokenColors=e.semanticTokenColors),`${JSON.stringify(n,null,2)}\n`}function d(e,a){l(a);let s=a.outputPath??`shiki-themes`,d=c(a.mapTheme(e.tokens));if(d.length===0)throw Error(`@razorwind/shiki mapTheme() returned no themes`);let f={},p=new Set,m=[];for(let e of d){let r=`${(0,t.slugifyThemeName)(e.name)}.json`;if(p.has(r)){let n=2;for(;p.has(`${(0,t.slugifyThemeName)(e.name)}-${n}.json`);)n+=1;r=`${(0,t.slugifyThemeName)(e.name)}-${n}.json`}p.add(r);let a=(0,n.join)(s,r);f[a]=o(a,u(e),`json`),m.push({name:e.name,displayName:i(e),fileName:r})}let h=a.installGuide??r({themes:m}),g=(0,n.join)(s,`INSTALL.md`);return f[g]=o(g,h,`markdown`),f}var f=(0,e.definePlugin)(e=>({name:`shiki`,generate:async t=>{if(!e)throw Error(`@razorwind/shiki requires options: { mapTheme }`);return d(t,e)}}));exports.default=f,Object.defineProperty(exports,"flattenTokens",{enumerable:!0,get:function(){return t.flattenTokens}}),Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateShikiTheme=d,exports.normalizeThemes=c,exports.renderInstallMd=r,exports.renderThemeJson=u,Object.defineProperty(exports,"resolveTokenSets",{enumerable:!0,get:function(){return t.resolveTokenSets}}),exports.themeDisplayName=i,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}});
|
|
48
|
+
`}function i(e){return(0,t.themeDisplayName)(e)}const a={name:`razorwind-shiki`};function o(e,n,r){return(0,t.createDocument)(e,n,a,r)}function s(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&e.name.length>0}function c(e){if(Array.isArray(e))return e.map((e,t)=>{if(!s(e))throw TypeError(`@razorwind/shiki mapTheme()[${t}] must be a ShikiTheme with name`);return e});if(s(e))return[e];if(!(0,t.isObject)(e))throw TypeError(`@razorwind/shiki mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!s(t))throw TypeError(`@razorwind/shiki mapTheme()["${e}"] must be a ShikiTheme with name`);return{...t,name:t.name||e}})}function l(e){if(!e.mapTheme)throw Error(`@razorwind/shiki requires options.mapTheme`)}function u(e){let t=e.settings??e.tokenColors??[],n={name:e.name,settings:t};return e.displayName&&(n.displayName=e.displayName),e.type&&(n.type=e.type),e.fg!==void 0&&(n.fg=e.fg),e.bg!==void 0&&(n.bg=e.bg),e.colors&&(n.colors=e.colors),e.tokenColors&&e.settings&&(n.tokenColors=e.tokenColors),e.colorReplacements&&(n.colorReplacements=e.colorReplacements),e.semanticHighlighting!==void 0&&(n.semanticHighlighting=e.semanticHighlighting),e.semanticTokenColors&&(n.semanticTokenColors=e.semanticTokenColors),`${JSON.stringify(n,null,2)}\n`}function d(e,a){l(a);let s=a.outputPath??`shiki-themes`,d=c(a.mapTheme(e.tokens));if(d.length===0)throw Error(`@razorwind/shiki mapTheme() returned no themes`);let f={},p=new Set,m=[];for(let e of d){let r=`${(0,t.slugifyThemeName)(e.name)}.json`;if(p.has(r)){let n=2;for(;p.has(`${(0,t.slugifyThemeName)(e.name)}-${n}.json`);)n+=1;r=`${(0,t.slugifyThemeName)(e.name)}-${n}.json`}p.add(r);let a=(0,n.join)(s,r);f[a]=o(a,u(e),`json`),m.push({name:e.name,displayName:i(e),fileName:r})}let h=a.installGuide??r({themes:m,title:(0,t.resolveSchemaIdentity)(e).title}),g=(0,n.join)(s,`INSTALL.md`);return f[g]=o(g,h,`markdown`),f}var f=(0,e.definePlugin)(e=>({name:`shiki`,generate:async t=>{if(!e)throw Error(`@razorwind/shiki requires options: { mapTheme }`);return d(t,e)}}));exports.default=f,Object.defineProperty(exports,"flattenTokens",{enumerable:!0,get:function(){return t.flattenTokens}}),Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateShikiTheme=d,exports.normalizeThemes=c,exports.renderInstallMd=r,exports.renderThemeJson=u,Object.defineProperty(exports,"resolveTokenSets",{enumerable:!0,get:function(){return t.resolveTokenSets}}),exports.themeDisplayName=i,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}});
|
package/dist/index.d.cts
CHANGED
|
@@ -119,6 +119,8 @@ declare function renderInstallMd(options: {
|
|
|
119
119
|
displayName: string;
|
|
120
120
|
fileName: string;
|
|
121
121
|
}>;
|
|
122
|
+
/** Design-system / package title from Schema when multiple themes. */
|
|
123
|
+
title?: string;
|
|
122
124
|
}): string;
|
|
123
125
|
/**
|
|
124
126
|
* Title-case a theme name for display when \`displayName\` is omitted.
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +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;;;;;;;UAQe;EACf;EACA;EACA;IACE;IACA;IACA;;;;;;;;;;;;UAaa;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA,SAAS;;EAET,WAAW;;;;;EAKX,cAAc;;EAEd,oBAAoB;EACpB;EACA,sBAAsB;;;;;;;KAQZ,sBACV,QAAQ,SAAS,eAAe,YAC7B,aAAa,eAAe,eAAe;;;;;;UAO/B;;;;;;EAMf;;;;;;EAOA,UAAU;;;;;EAMV,eAAe;;;;;EAMf;;;;;;;;;iBCzGc,gBAAgB;EAC9B,QAAQ;IAAQ;IAAc;IAAqB
|
|
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;;;;;;;UAQe;EACf;EACA;EACA;IACE;IACA;IACA;;;;;;;;;;;;UAaa;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA,SAAS;;EAET,WAAW;;;;;EAKX,cAAc;;EAEd,oBAAoB;EACpB;EACA,sBAAsB;;;;;;;KAQZ,sBACV,QAAQ,SAAS,eAAe,YAC7B,aAAa,eAAe,eAAe;;;;;;UAO/B;;;;;;EAMf;;;;;;EAOA,UAAU;;;;;EAMV,eAAe;;;;;EAMf;;;;;;;;;iBCzGc,gBAAgB;EAC9B,QAAQ;IAAQ;IAAc;IAAqB;;;EAEnD;;;;;iBAqEc,iBAAiB,OAAO;;;;;;iBCjDxB,gBACd,QAAQ,aAAa,eAAe,eAAe,cAClD;;;;;;iBAkDa,gBAAgB,OAAO;;;;;;;;;iBAkDvB,mBACd,MAAM,QACN,SAAS,qBACR,wBAAwB,QAAQ"}
|
package/dist/index.d.mts
CHANGED
|
@@ -119,6 +119,8 @@ declare function renderInstallMd(options: {
|
|
|
119
119
|
displayName: string;
|
|
120
120
|
fileName: string;
|
|
121
121
|
}>;
|
|
122
|
+
/** Design-system / package title from Schema when multiple themes. */
|
|
123
|
+
title?: string;
|
|
122
124
|
}): string;
|
|
123
125
|
/**
|
|
124
126
|
* Title-case a theme name for display when \`displayName\` is omitted.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{definePlugin as e}from"@razorwind/core/plugin";import{createDocument as t,flattenTokens as n,formatTokenValue as r,isObject as i,
|
|
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:`Shiki Themes`),r=e.themes.map(e=>`- \`${e.fileName}\` — ${e.displayName} (theme id: \`${e.name}\`)`).join(`
|
|
2
2
|
`),i=e.themes.map(e=>`- \`${e.name}\` — ${e.displayName}`).join(`
|
|
3
3
|
`);return`# Installing ${n}
|
|
4
4
|
|
|
@@ -45,5 +45,5 @@ await highlighter.loadTheme(theme);
|
|
|
45
45
|
Pass the theme id to \`codeToHtml\`, \`codeToTokens\`, or \`getTokenStyle\`:
|
|
46
46
|
|
|
47
47
|
${i}
|
|
48
|
-
`}function
|
|
48
|
+
`}function f(e){return c(e)}const p={name:`razorwind-shiki`};function m(e,n,r){return t(e,n,p,r)}function h(e){return i(e)&&typeof e.name==`string`&&e.name.length>0}function g(e){if(Array.isArray(e))return e.map((e,t)=>{if(!h(e))throw TypeError(`@razorwind/shiki mapTheme()[${t}] must be a ShikiTheme with name`);return e});if(h(e))return[e];if(!i(e))throw TypeError(`@razorwind/shiki mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!h(t))throw TypeError(`@razorwind/shiki mapTheme()["${e}"] must be a ShikiTheme with name`);return{...t,name:t.name||e}})}function _(e){if(!e.mapTheme)throw Error(`@razorwind/shiki requires options.mapTheme`)}function v(e){let t=e.settings??e.tokenColors??[],n={name:e.name,settings:t};return e.displayName&&(n.displayName=e.displayName),e.type&&(n.type=e.type),e.fg!==void 0&&(n.fg=e.fg),e.bg!==void 0&&(n.bg=e.bg),e.colors&&(n.colors=e.colors),e.tokenColors&&e.settings&&(n.tokenColors=e.tokenColors),e.colorReplacements&&(n.colorReplacements=e.colorReplacements),e.semanticHighlighting!==void 0&&(n.semanticHighlighting=e.semanticHighlighting),e.semanticTokenColors&&(n.semanticTokenColors=e.semanticTokenColors),`${JSON.stringify(n,null,2)}\n`}function y(e,t){_(t);let n=t.outputPath??`shiki-themes`,r=g(t.mapTheme(e.tokens));if(r.length===0)throw Error(`@razorwind/shiki mapTheme() returned no themes`);let i={},o=new Set,c=[];for(let e of r){let t=`${s(e.name)}.json`;if(o.has(t)){let n=2;for(;o.has(`${s(e.name)}-${n}.json`);)n+=1;t=`${s(e.name)}-${n}.json`}o.add(t);let r=u(n,t);i[r]=m(r,v(e),`json`),c.push({name:e.name,displayName:f(e),fileName:t})}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 b=e(e=>({name:`shiki`,generate:async t=>{if(!e)throw Error(`@razorwind/shiki requires options: { mapTheme }`);return y(t,e)}}));export{b as default,n as flattenTokens,r as formatTokenValue,y as generateShikiTheme,g as normalizeThemes,d as renderInstallMd,v as renderThemeJson,o as resolveTokenSets,f as themeDisplayName,l as toCssVar};
|
|
49
49
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/shiki",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Razorwind plugin that generates Shiki / TextMate themes from design tokens.",
|
|
6
6
|
"repository": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@power-plant/core": "^0.0.81",
|
|
71
71
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
72
|
-
"@razorwind/core": "0.0.
|
|
72
|
+
"@razorwind/core": "0.0.34"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@powerlines/plugin-tsdown": "^0.1.591",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"typescript": "^6.0.3"
|
|
78
78
|
},
|
|
79
79
|
"publishConfig": { "access": "public" },
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "2e9d53ceff13e46fdd225eff5f9ac32bc661814a"
|
|
81
81
|
}
|