@razorwind/notepad-plus-plus 0.0.20 → 0.0.21

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 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];return`# Installing ${e.title??(e.themes.length===1?t.displayName:`Notepad++ 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("@razorwind/core/lib/fonts"),r=require("node:path");function i(e){let t=e.themes[0];return`# Installing ${e.title??(e.themes.length===1?t.displayName:`Notepad++ Themes`)}
2
2
 
3
3
  Generated by \`@razorwind/notepad-plus-plus\`.
4
4
 
@@ -45,7 +45,7 @@ If tab text or backgrounds look wrong, check:
45
45
  1. **Settings → Preferences → General → Tab Bar** — enable **Change inactive tab color**
46
46
  2. **Settings → Preferences → Dark Mode** — newer builds may override theme tab colors
47
47
  3. Advanced \`config.xml\` — set \`darkTabUseTheme\` / \`lightModeUseTheme\` so tabs follow the theme
48
- `}function i(e){return(0,t.themeDisplayName)(e)}const a={name:`razorwind-notepad-plus-plus`};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/notepad-plus-plus mapTheme()[${t}] must be a NotepadPlusPlusTheme with name`);return e});if(s(e))return[e];if(!(0,t.isObject)(e))throw TypeError(`@razorwind/notepad-plus-plus mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!s(t))throw TypeError(`@razorwind/notepad-plus-plus mapTheme()["${e}"] must be a NotepadPlusPlusTheme with name`);return{...t,name:t.name||e}})}function l(e){if(!e.mapTheme)throw Error(`@razorwind/notepad-plus-plus requires options.mapTheme`)}function u(e){let t=e.trim();if(t.startsWith(`#`)){let n=t.slice(1);if(!/^[0-9a-fA-F]{6}$/.test(n))throw TypeError(`Invalid Notepad++ color: ${e}`);return n.toUpperCase()}if(/^[0-9a-fA-F]{6}$/.test(t))return t.toUpperCase();throw TypeError(`Invalid Notepad++ color: ${e}`)}function d(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function f(e){if(e!==void 0&&e!==``)return u(e)}function p(e){return Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}="${d(String(t))}"`).join(``)}function m(e,t=``){return e.map(e=>`${t}<!-- ${e} -->`)}function h(e,t){return`${t}<WordsStyle${p({name:e.name,styleID:e.styleID,fgColor:f(e.fgColor),bgColor:f(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle??`0`,fontSize:e.fontSize??``,colorStyle:e.colorStyle,keywordClass:e.keywordClass})} />`}function g(e,t){let n=[`${t}<LexerType${p({name:e.name,desc:e.desc,ext:e.ext??``})}>`];for(let r of e.wordsStyles)n.push(h(r,`${t} `));return n.push(`${t}</LexerType>`),n}function _(e,t){return`${t}<WidgetStyle${p({name:e.name,styleID:e.styleID,fgColor:f(e.fgColor),bgColor:f(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle,fontSize:e.fontSize??``,colorStyle:e.colorStyle})}></WidgetStyle>`}function v(e){return!!(e.body||e.lexerStyles&&e.lexerStyles.length>0||e.globalStyles&&e.globalStyles.length>0)}function y(e){let t=[i(e),...e.description?[e.description]:[],...e.author?[`Author: ${e.author}`]:[],...e.date?[`Date: ${e.date}`]:[],...e.license?[`License: ${e.license}`]:[],`Generated by @razorwind/notepad-plus-plus`];return e.comments?.length&&t.push(...e.comments),m(t)}function b(e){if(e.body)return e.body.replace(/\n$/,``);let t=[];if(e.lexerStyles?.length){t.push(` <LexerStyles>`);for(let n of e.lexerStyles)t.push(...g(n,` `));t.push(` </LexerStyles>`)}if(e.globalStyles?.length){t.push(` <GlobalStyles>`);for(let n of e.globalStyles)t.push(_(n,` `));t.push(` </GlobalStyles>`)}return t.join(`
49
- `)}function x(e){if(e.xml)return e.xml.endsWith(`
50
- `)?e.xml:`${e.xml}\n`;if(!v(e))throw TypeError(`@razorwind/notepad-plus-plus theme "${e.name}" must include lexerStyles, globalStyles, body, or xml`);return[`<?xml version="1.0" encoding="UTF-8" ?>`,``,`<NotepadPlus>`,...y(e,` `),b(e),`</NotepadPlus>`,``].join(`
51
- `)}function S(e,a){l(a);let s=a.outputPath??`notepad-plus-plus-themes`,u=c(a.mapTheme(e.tokens));if(u.length===0)throw Error(`@razorwind/notepad-plus-plus mapTheme() returned no themes`);let d={},f=new Set,p=[];for(let e of u){let r=(0,t.slugifyThemeName)(e.name);if(!r)throw TypeError(`@razorwind/notepad-plus-plus 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=`${r}.xml`,c=(0,n.join)(s,a);d[c]=o(c,x({...e,name:r}),`xml`),p.push({name:r,displayName:i(e),fileName:a})}let m=a.installGuide??r({themes:p,title:(0,t.resolveSchemaIdentity)(e).title}),h=(0,n.join)(s,`INSTALL.md`);return d[h]=o(h,m,`markdown`),d}var C=(0,e.definePlugin)(e=>({name:`notepad-plus-plus`,generate:async t=>{if(!e)throw Error(`@razorwind/notepad-plus-plus requires options: { mapTheme }`);return S(t,e)}}));exports.default=C,Object.defineProperty(exports,"flattenTokens",{enumerable:!0,get:function(){return t.flattenTokens}}),Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateNotepadPlusPlusTheme=S,exports.normalizeThemes=c,exports.renderInstallMd=r,exports.renderNotepadPlusPlusTheme=x,Object.defineProperty(exports,"resolveTokenSets",{enumerable:!0,get:function(){return t.resolveTokenSets}}),Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}}),exports.toNppColor=u;
48
+ `}function a(e){return(0,t.themeDisplayName)(e)}const o={name:`razorwind-notepad-plus-plus`};function s(e,n,r){return(0,t.createDocument)(e,n,o,r)}function c(e){return(0,t.isObject)(e)&&typeof e.name==`string`&&e.name.length>0}function l(e){if(Array.isArray(e))return e.map((e,t)=>{if(!c(e))throw TypeError(`@razorwind/notepad-plus-plus mapTheme()[${t}] must be a NotepadPlusPlusTheme with name`);return e});if(c(e))return[e];if(!(0,t.isObject)(e))throw TypeError(`@razorwind/notepad-plus-plus mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!c(t))throw TypeError(`@razorwind/notepad-plus-plus mapTheme()["${e}"] must be a NotepadPlusPlusTheme with name`);return{...t,name:t.name||e}})}function u(e){if(!e.mapTheme)throw Error(`@razorwind/notepad-plus-plus requires options.mapTheme`)}function d(e,t){if(e.xml)return e;let r=(0,n.pickFontByRole)(t,n.SANS_ROLES),i=r?(0,n.fontFamilyName)(r):void 0;return i?{...e,lexerStyles:e.lexerStyles?.map(e=>({...e,wordsStyles:e.wordsStyles.map(e=>({...e,fontName:e.fontName||i}))})),globalStyles:e.globalStyles?.map(e=>({...e,fontName:e.fontName||i}))}:e}function f(e){let t=e.trim();if(t.startsWith(`#`)){let n=t.slice(1);if(!/^[0-9a-fA-F]{6}$/.test(n))throw TypeError(`Invalid Notepad++ color: ${e}`);return n.toUpperCase()}if(/^[0-9a-fA-F]{6}$/.test(t))return t.toUpperCase();throw TypeError(`Invalid Notepad++ color: ${e}`)}function p(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function m(e){if(e!==void 0&&e!==``)return f(e)}function h(e){return Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}="${p(String(t))}"`).join(``)}function g(e,t=``){return e.map(e=>`${t}<!-- ${e} -->`)}function _(e,t){return`${t}<WordsStyle${h({name:e.name,styleID:e.styleID,fgColor:m(e.fgColor),bgColor:m(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle??`0`,fontSize:e.fontSize??``,colorStyle:e.colorStyle,keywordClass:e.keywordClass})} />`}function v(e,t){let n=[`${t}<LexerType${h({name:e.name,desc:e.desc,ext:e.ext??``})}>`];for(let r of e.wordsStyles)n.push(_(r,`${t} `));return n.push(`${t}</LexerType>`),n}function y(e,t){return`${t}<WidgetStyle${h({name:e.name,styleID:e.styleID,fgColor:m(e.fgColor),bgColor:m(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle,fontSize:e.fontSize??``,colorStyle:e.colorStyle})}></WidgetStyle>`}function b(e){return!!(e.body||e.lexerStyles&&e.lexerStyles.length>0||e.globalStyles&&e.globalStyles.length>0)}function x(e){let t=[a(e),...e.description?[e.description]:[],...e.author?[`Author: ${e.author}`]:[],...e.date?[`Date: ${e.date}`]:[],...e.license?[`License: ${e.license}`]:[],`Generated by @razorwind/notepad-plus-plus`];return e.comments?.length&&t.push(...e.comments),g(t)}function S(e){if(e.body)return e.body.replace(/\n$/,``);let t=[];if(e.lexerStyles?.length){t.push(` <LexerStyles>`);for(let n of e.lexerStyles)t.push(...v(n,` `));t.push(` </LexerStyles>`)}if(e.globalStyles?.length){t.push(` <GlobalStyles>`);for(let n of e.globalStyles)t.push(y(n,` `));t.push(` </GlobalStyles>`)}return t.join(`
49
+ `)}function C(e){if(e.xml)return e.xml.endsWith(`
50
+ `)?e.xml:`${e.xml}\n`;if(!b(e))throw TypeError(`@razorwind/notepad-plus-plus theme "${e.name}" must include lexerStyles, globalStyles, body, or xml`);return[`<?xml version="1.0" encoding="UTF-8" ?>`,``,`<NotepadPlus>`,...x(e,` `),S(e),`</NotepadPlus>`,``].join(`
51
+ `)}function w(e,n){u(n);let o=n.outputPath??`notepad-plus-plus-themes`,c=l(n.mapTheme(e.tokens)).map(t=>d(t,e.fonts));if(c.length===0)throw Error(`@razorwind/notepad-plus-plus mapTheme() returned no themes`);let f={},p=new Set,m=[];for(let e of c){let n=(0,t.slugifyThemeName)(e.name);if(!n)throw TypeError(`@razorwind/notepad-plus-plus theme name "${e.name}" slugifies to an empty string`);if(p.has(n)){let r=2;for(;p.has(`${(0,t.slugifyThemeName)(e.name)}-${r}`);)r+=1;n=`${(0,t.slugifyThemeName)(e.name)}-${r}`}p.add(n);let i=`${n}.xml`,c=(0,r.join)(o,i);f[c]=s(c,C({...e,name:n}),`xml`),m.push({name:n,displayName:a(e),fileName:i})}let h=n.installGuide??i({themes:m,title:(0,t.resolveSchemaIdentity)(e).title}),g=(0,r.join)(o,`INSTALL.md`);return f[g]=s(g,h,`markdown`),f}var T=(0,e.definePlugin)(e=>({name:`notepad-plus-plus`,generate:async t=>{if(!e)throw Error(`@razorwind/notepad-plus-plus requires options: { mapTheme }`);return w(t,e)}}));exports.default=T,Object.defineProperty(exports,"flattenTokens",{enumerable:!0,get:function(){return t.flattenTokens}}),Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateNotepadPlusPlusTheme=w,exports.normalizeThemes=l,exports.renderInstallMd=i,exports.renderNotepadPlusPlusTheme=C,Object.defineProperty(exports,"resolveTokenSets",{enumerable:!0,get:function(){return t.resolveTokenSets}}),Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}}),exports.toNppColor=f;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/install.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAyBiB;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;;;;;UAMe;;EAEf;;EAEA;;EAEA;EACA,aAAa;;;;;UAME;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;UAYe;;;;EAIf;;EAEA;EACA;EACA;EACA;EACA;;EAEA;;EAEA,cAAc;;EAEd,eAAe;;;;;EAKf;;EAEA;;;;;KAMU,gCACV,QAAQ,SAAS,eAAe,YAE9B,uBACA,yBACA,eAAe;;;;;;UAOF;;;;;;EAMf;;;;;;EAOA,UAAU;;;;;;;EAQV;;;;;EAMA,eAAe;;;;;;;;;iBC3ID,gBAAgB;EAC9B,QAAQ;IAAQ;IAAc;IAAqB;;;EAEnD;;;;iBCwBc,gBACd,QACI,uBACA,yBACA,eAAe,wBAClB;;;;;;iBAkDa,WAAW;;;;;;;iBAgJX,2BAA2B,OAAO;iBA0BlC,6BACd,MAAM,QACN,SAAS,+BACR,wBAAwB,QAAQ"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/install.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAyBiB;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;;;;;UAMe;;EAEf;;EAEA;;EAEA;EACA,aAAa;;;;;UAME;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;UAYe;;;;EAIf;;EAEA;EACA;EACA;EACA;EACA;;EAEA;;EAEA,cAAc;;EAEd,eAAe;;;;;EAKf;;EAEA;;;;;KAMU,gCACV,QAAQ,SAAS,eAAe,YAE9B,uBACA,yBACA,eAAe;;;;;;UAOF;;;;;;EAMf;;;;;;EAOA,UAAU;;;;;;;EAQV;;;;;EAMA,eAAe;;;;;;;;;iBC3ID,gBAAgB;EAC9B,QAAQ;IAAQ;IAAc;IAAqB;;;EAEnD;;;;iBCkCc,gBACd,QACI,uBACA,yBACA,eAAe,wBAClB;;;;;;iBAgFa,WAAW;;;;;;;iBAgJX,2BAA2B,OAAO;iBA0BlC,6BACd,MAAM,QACN,SAAS,+BACR,wBAAwB,QAAQ"}
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,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];return`# Installing ${e.title??(e.themes.length===1?t.displayName:`Notepad++ Themes`)}
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{SANS_ROLES as u,fontFamilyName as d,pickFontByRole as f}from"@razorwind/core/lib/fonts";import{join as p}from"node:path";function m(e){let t=e.themes[0];return`# Installing ${e.title??(e.themes.length===1?t.displayName:`Notepad++ Themes`)}
2
2
 
3
3
  Generated by \`@razorwind/notepad-plus-plus\`.
4
4
 
@@ -45,8 +45,8 @@ If tab text or backgrounds look wrong, check:
45
45
  1. **Settings → Preferences → General → Tab Bar** — enable **Change inactive tab color**
46
46
  2. **Settings → Preferences → Dark Mode** — newer builds may override theme tab colors
47
47
  3. Advanced \`config.xml\` — set \`darkTabUseTheme\` / \`lightModeUseTheme\` so tabs follow the theme
48
- `}function f(e){return c(e)}const p={name:`razorwind-notepad-plus-plus`};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/notepad-plus-plus mapTheme()[${t}] must be a NotepadPlusPlusTheme with name`);return e});if(h(e))return[e];if(!i(e))throw TypeError(`@razorwind/notepad-plus-plus mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!h(t))throw TypeError(`@razorwind/notepad-plus-plus mapTheme()["${e}"] must be a NotepadPlusPlusTheme with name`);return{...t,name:t.name||e}})}function _(e){if(!e.mapTheme)throw Error(`@razorwind/notepad-plus-plus requires options.mapTheme`)}function v(e){let t=e.trim();if(t.startsWith(`#`)){let n=t.slice(1);if(!/^[0-9a-fA-F]{6}$/.test(n))throw TypeError(`Invalid Notepad++ color: ${e}`);return n.toUpperCase()}if(/^[0-9a-fA-F]{6}$/.test(t))return t.toUpperCase();throw TypeError(`Invalid Notepad++ color: ${e}`)}function y(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function b(e){if(e!==void 0&&e!==``)return v(e)}function x(e){return Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}="${y(String(t))}"`).join(``)}function S(e,t=``){return e.map(e=>`${t}<!-- ${e} -->`)}function C(e,t){return`${t}<WordsStyle${x({name:e.name,styleID:e.styleID,fgColor:b(e.fgColor),bgColor:b(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle??`0`,fontSize:e.fontSize??``,colorStyle:e.colorStyle,keywordClass:e.keywordClass})} />`}function w(e,t){let n=[`${t}<LexerType${x({name:e.name,desc:e.desc,ext:e.ext??``})}>`];for(let r of e.wordsStyles)n.push(C(r,`${t} `));return n.push(`${t}</LexerType>`),n}function T(e,t){return`${t}<WidgetStyle${x({name:e.name,styleID:e.styleID,fgColor:b(e.fgColor),bgColor:b(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle,fontSize:e.fontSize??``,colorStyle:e.colorStyle})}></WidgetStyle>`}function E(e){return!!(e.body||e.lexerStyles&&e.lexerStyles.length>0||e.globalStyles&&e.globalStyles.length>0)}function D(e){let t=[f(e),...e.description?[e.description]:[],...e.author?[`Author: ${e.author}`]:[],...e.date?[`Date: ${e.date}`]:[],...e.license?[`License: ${e.license}`]:[],`Generated by @razorwind/notepad-plus-plus`];return e.comments?.length&&t.push(...e.comments),S(t)}function O(e){if(e.body)return e.body.replace(/\n$/,``);let t=[];if(e.lexerStyles?.length){t.push(` <LexerStyles>`);for(let n of e.lexerStyles)t.push(...w(n,` `));t.push(` </LexerStyles>`)}if(e.globalStyles?.length){t.push(` <GlobalStyles>`);for(let n of e.globalStyles)t.push(T(n,` `));t.push(` </GlobalStyles>`)}return t.join(`
49
- `)}function k(e){if(e.xml)return e.xml.endsWith(`
50
- `)?e.xml:`${e.xml}\n`;if(!E(e))throw TypeError(`@razorwind/notepad-plus-plus theme "${e.name}" must include lexerStyles, globalStyles, body, or xml`);return[`<?xml version="1.0" encoding="UTF-8" ?>`,``,`<NotepadPlus>`,...D(e,` `),O(e),`</NotepadPlus>`,``].join(`
51
- `)}function A(e,t){_(t);let n=t.outputPath??`notepad-plus-plus-themes`,r=g(t.mapTheme(e.tokens));if(r.length===0)throw Error(`@razorwind/notepad-plus-plus mapTheme() returned no themes`);let i={},o=new Set,c=[];for(let e of r){let t=s(e.name);if(!t)throw TypeError(`@razorwind/notepad-plus-plus 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=`${t}.xml`,a=u(n,r);i[a]=m(a,k({...e,name:t}),`xml`),c.push({name:t,displayName:f(e),fileName:r})}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 j=e(e=>({name:`notepad-plus-plus`,generate:async t=>{if(!e)throw Error(`@razorwind/notepad-plus-plus requires options: { mapTheme }`);return A(t,e)}}));export{j as default,n as flattenTokens,r as formatTokenValue,A as generateNotepadPlusPlusTheme,g as normalizeThemes,d as renderInstallMd,k as renderNotepadPlusPlusTheme,o as resolveTokenSets,l as toCssVar,v as toNppColor};
48
+ `}function h(e){return c(e)}const g={name:`razorwind-notepad-plus-plus`};function _(e,n,r){return t(e,n,g,r)}function v(e){return i(e)&&typeof e.name==`string`&&e.name.length>0}function y(e){if(Array.isArray(e))return e.map((e,t)=>{if(!v(e))throw TypeError(`@razorwind/notepad-plus-plus mapTheme()[${t}] must be a NotepadPlusPlusTheme with name`);return e});if(v(e))return[e];if(!i(e))throw TypeError(`@razorwind/notepad-plus-plus mapTheme() must return a theme, theme array, or theme record`);return Object.entries(e).map(([e,t])=>{if(!v(t))throw TypeError(`@razorwind/notepad-plus-plus mapTheme()["${e}"] must be a NotepadPlusPlusTheme with name`);return{...t,name:t.name||e}})}function b(e){if(!e.mapTheme)throw Error(`@razorwind/notepad-plus-plus requires options.mapTheme`)}function x(e,t){if(e.xml)return e;let n=f(t,u),r=n?d(n):void 0;return r?{...e,lexerStyles:e.lexerStyles?.map(e=>({...e,wordsStyles:e.wordsStyles.map(e=>({...e,fontName:e.fontName||r}))})),globalStyles:e.globalStyles?.map(e=>({...e,fontName:e.fontName||r}))}:e}function S(e){let t=e.trim();if(t.startsWith(`#`)){let n=t.slice(1);if(!/^[0-9a-fA-F]{6}$/.test(n))throw TypeError(`Invalid Notepad++ color: ${e}`);return n.toUpperCase()}if(/^[0-9a-fA-F]{6}$/.test(t))return t.toUpperCase();throw TypeError(`Invalid Notepad++ color: ${e}`)}function C(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function w(e){if(e!==void 0&&e!==``)return S(e)}function T(e){return Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}="${C(String(t))}"`).join(``)}function E(e,t=``){return e.map(e=>`${t}<!-- ${e} -->`)}function D(e,t){return`${t}<WordsStyle${T({name:e.name,styleID:e.styleID,fgColor:w(e.fgColor),bgColor:w(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle??`0`,fontSize:e.fontSize??``,colorStyle:e.colorStyle,keywordClass:e.keywordClass})} />`}function O(e,t){let n=[`${t}<LexerType${T({name:e.name,desc:e.desc,ext:e.ext??``})}>`];for(let r of e.wordsStyles)n.push(D(r,`${t} `));return n.push(`${t}</LexerType>`),n}function k(e,t){return`${t}<WidgetStyle${T({name:e.name,styleID:e.styleID,fgColor:w(e.fgColor),bgColor:w(e.bgColor),fontName:e.fontName??``,fontStyle:e.fontStyle,fontSize:e.fontSize??``,colorStyle:e.colorStyle})}></WidgetStyle>`}function A(e){return!!(e.body||e.lexerStyles&&e.lexerStyles.length>0||e.globalStyles&&e.globalStyles.length>0)}function j(e){let t=[h(e),...e.description?[e.description]:[],...e.author?[`Author: ${e.author}`]:[],...e.date?[`Date: ${e.date}`]:[],...e.license?[`License: ${e.license}`]:[],`Generated by @razorwind/notepad-plus-plus`];return e.comments?.length&&t.push(...e.comments),E(t)}function M(e){if(e.body)return e.body.replace(/\n$/,``);let t=[];if(e.lexerStyles?.length){t.push(` <LexerStyles>`);for(let n of e.lexerStyles)t.push(...O(n,` `));t.push(` </LexerStyles>`)}if(e.globalStyles?.length){t.push(` <GlobalStyles>`);for(let n of e.globalStyles)t.push(k(n,` `));t.push(` </GlobalStyles>`)}return t.join(`
49
+ `)}function N(e){if(e.xml)return e.xml.endsWith(`
50
+ `)?e.xml:`${e.xml}\n`;if(!A(e))throw TypeError(`@razorwind/notepad-plus-plus theme "${e.name}" must include lexerStyles, globalStyles, body, or xml`);return[`<?xml version="1.0" encoding="UTF-8" ?>`,``,`<NotepadPlus>`,...j(e,` `),M(e),`</NotepadPlus>`,``].join(`
51
+ `)}function P(e,t){b(t);let n=t.outputPath??`notepad-plus-plus-themes`,r=y(t.mapTheme(e.tokens)).map(t=>x(t,e.fonts));if(r.length===0)throw Error(`@razorwind/notepad-plus-plus mapTheme() returned no themes`);let i={},o=new Set,c=[];for(let e of r){let t=s(e.name);if(!t)throw TypeError(`@razorwind/notepad-plus-plus 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=`${t}.xml`,a=p(n,r);i[a]=_(a,N({...e,name:t}),`xml`),c.push({name:t,displayName:h(e),fileName:r})}let l=t.installGuide??m({themes:c,title:a(e).title}),u=p(n,`INSTALL.md`);return i[u]=_(u,l,`markdown`),i}var F=e(e=>({name:`notepad-plus-plus`,generate:async t=>{if(!e)throw Error(`@razorwind/notepad-plus-plus requires options: { mapTheme }`);return P(t,e)}}));export{F as default,n as flattenTokens,r as formatTokenValue,P as generateNotepadPlusPlusTheme,y as normalizeThemes,m as renderInstallMd,N as renderNotepadPlusPlusTheme,o as resolveTokenSets,l as toCssVar,S as toNppColor};
52
52
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razorwind/notepad-plus-plus",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "description": "Razorwind plugin that generates Notepad++ themes from design tokens.",
6
6
  "repository": {
@@ -69,7 +69,7 @@
69
69
  "dependencies": {
70
70
  "@power-plant/core": "^0.0.90",
71
71
  "@power-plant/dtcg-schema": "^0.0.1",
72
- "@razorwind/core": "^0.0.46"
72
+ "@razorwind/core": "^0.0.47"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@powerlines/plugin-tsdown": "^0.1.612",
@@ -77,5 +77,5 @@
77
77
  "typescript": "^6.0.3"
78
78
  },
79
79
  "publishConfig": { "access": "public" },
80
- "gitHead": "0bfdb728cdb6c241eae5072dab7984fe48146c22"
80
+ "gitHead": "ca5955e41399f13b752e589a14338d6821b78f6c"
81
81
  }