@razorwind/design-md 0.0.59 → 0.0.61
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/extract.cjs +1 -1
- package/dist/extract.mjs +1 -1
- package/dist/generate-Br3E6XNy.mjs +29 -0
- package/dist/generate-Br3E6XNy.mjs.map +1 -0
- package/dist/generate-DRDnuRqo.cjs +28 -0
- package/dist/generate.cjs +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +9 -9
- package/dist/generate-CzUKj9-i.cjs +0 -28
- package/dist/generate-DZ-OYEsh.mjs +0 -29
- package/dist/generate-DZ-OYEsh.mjs.map +0 -1
package/dist/extract.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("@power-plant/core"),n=require("@razorwind/core"),r=require("@razorwind/core/plugin"),i=require("@stryke/fs/exists"),a=require("@stryke/fs/read-file"),o=require("@stryke/path/join"),s=require("@stryke/type-checks/is-empty-object"),c=require("@stryke/type-checks/is-object"),l=require("yaml");var u=e.t({DESIGN_MD_FILE_PATTERN:()=>d,DESIGN_MD_PATH_CANDIDATES:()=>f,default:()=>A,designMdToTokens:()=>T,extractDesignMdFrontMatter:()=>w,isDesignMdFile:()=>D,loadDesignMdTokens:()=>k,parseDesignMdTokens:()=>E,resolveDesignMdPath:()=>O});const d=/(?:^|[/\\])design\.md$/i,f=[`DESIGN.md`,`design.md`,`docs/DESIGN.md`],p=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,m=/^\{[^{}]+\}$/,h=new Set([`version`,`name`,`description`]),g=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`,`fontFeature`,`fontVariation`],_={backgroundColor:`color`,textColor:`color`,typography:`typography`,rounded:`dimension`,padding:`dimension`,size:`dimension`,height:`dimension`,width:`dimension`};function v(e){return typeof e==`string`&&m.test(e.trim())}function y(e){return typeof e==`number`?`${e}px`:e}function b(e){let t={};for(let n of g){let r=e[n];r!=null&&(t[n]=r)}for(let[n,r]of Object.entries(e))!(n in t)&&r!=null&&(typeof r==`string`||typeof r==`number`)&&(t[n]=r);return t}function x(e,t,n=!1){let r={};for(let[i,a]of Object.entries(e))a!=null&&(r[i]={$type:t,$value:v(a)?a.trim():n?y(a):a});return r}function S(e){let t={};for(let[n,r]of Object.entries(e))v(r)?t[n]={$type:`typography`,$value:r.trim()}:(0,c.isObject)(r)&&(t[n]={$type:`typography`,$value:b(r)});return t}function C(e){let t={};for(let[n,r]of Object.entries(e)){if(!(0,c.isObject)(r))continue;let e={};for(let[t,n]of Object.entries(r)){if(n==null)continue;let r=_[t];e[t]={...r?{$type:r}:{},$value:v(n)?n.trim():r===`typography`&&(0,c.isObject)(n)?b(n):y(n)}}Object.keys(e).length>0&&(t[n]=e)}return t}function w(e){let t=p.exec(e);if(!t?.[1])return;let n;try{n=(0,l.parse)(t[1])}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse DESIGN.md front matter as YAML: ${t}`)}return(0,c.isObject)(n)?n:void 0}function T(e){let t={};for(let[n,r]of Object.entries(e))if(!
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("@power-plant/core"),n=require("@razorwind/core"),r=require("@razorwind/core/plugin"),i=require("@stryke/fs/exists"),a=require("@stryke/fs/read-file"),o=require("@stryke/path/join"),s=require("@stryke/type-checks/is-empty-object"),c=require("@stryke/type-checks/is-object"),l=require("yaml");var u=e.t({DESIGN_MD_FILE_PATTERN:()=>d,DESIGN_MD_PATH_CANDIDATES:()=>f,default:()=>A,designMdToTokens:()=>T,extractDesignMdFrontMatter:()=>w,isDesignMdFile:()=>D,loadDesignMdTokens:()=>k,parseDesignMdTokens:()=>E,resolveDesignMdPath:()=>O});const d=/(?:^|[/\\])design\.md$/i,f=[`DESIGN.md`,`design.md`,`docs/DESIGN.md`],p=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,m=/^\{[^{}]+\}$/,h=new Set([`version`,`name`,`description`]),g=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`,`fontFeature`,`fontVariation`],_={backgroundColor:`color`,textColor:`color`,typography:`typography`,rounded:`dimension`,padding:`dimension`,size:`dimension`,height:`dimension`,width:`dimension`};function v(e){return typeof e==`string`&&m.test(e.trim())}function y(e){return typeof e==`number`?`${e}px`:e}function b(e){let t={};for(let n of g){let r=e[n];r!=null&&(t[n]=r)}for(let[n,r]of Object.entries(e))!(n in t)&&r!=null&&(typeof r==`string`||typeof r==`number`)&&(t[n]=r);return t}function x(e,t,n=!1){let r={};for(let[i,a]of Object.entries(e))a!=null&&(r[i]={$type:t,$value:v(a)?a.trim():n?y(a):a});return r}function S(e){let t={};for(let[n,r]of Object.entries(e))v(r)?t[n]={$type:`typography`,$value:r.trim()}:(0,c.isObject)(r)&&(t[n]={$type:`typography`,$value:b(r)});return t}function C(e){let t={};for(let[n,r]of Object.entries(e)){if(!(0,c.isObject)(r))continue;let e={};for(let[t,n]of Object.entries(r)){if(n==null)continue;let r=_[t];e[t]={...r?{$type:r}:{},$value:v(n)?n.trim():r===`typography`&&(0,c.isObject)(n)?b(n):y(n)}}Object.keys(e).length>0&&(t[n]=e)}return t}function w(e){let t=p.exec(e);if(!t?.[1])return;let n;try{n=(0,l.parse)(t[1])}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse DESIGN.md front matter as YAML: ${t}`)}return(0,c.isObject)(n)?n:void 0}function T(e){let t={};for(let[n,r]of Object.entries(e))if(!h.has(n)&&(0,c.isObject)(r))switch(n){case`colors`:t[n]=x(r,`color`);break;case`typography`:t[n]=S(r);break;case`rounded`:case`spacing`:t[n]=x(r,`dimension`,!0);break;case`components`:t[n]=C(r);break;default:t[n]=r}return(0,n.normalizeTokenTree)(t)}function E(e){let t=w(e);return t?T(t):{}}function D(e){return d.test(e)}function O(e){for(let t of f){let n=(0,o.joinPaths)(e,t);if((0,i.existsSync)(n))return n}}async function k(e){let t=O(e);if(t)return E(await(0,a.readFile)(t))}var A=(0,r.definePlugin)(e=>({name:`design-md:extract`,parsers:[{name:`design-md`,pattern:d,parser:e=>E(e)}],extract:async n=>{if(n.tokens&&!(0,s.isEmptyObject)(n.tokens))return n;let r=e?.path;if(!r){let{cwd:e}=(0,t.useExecution)();if(r=O(e),!r)return n}let i=E(await(0,a.readFile)(r));return!i||(0,s.isEmptyObject)(i)?n:{...n,tokens:i}}}));exports.DESIGN_MD_FILE_PATTERN=d,exports.DESIGN_MD_PATH_CANDIDATES=f,exports.default=A,exports.designMdToTokens=T,exports.extractDesignMdFrontMatter=w,exports.isDesignMdFile=D,exports.loadDesignMdTokens=k,exports.parseDesignMdTokens=E,exports.resolveDesignMdPath=O,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
|
package/dist/extract.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{useExecution as t}from"@power-plant/core";import{normalizeTokenTree as n}from"@razorwind/core";import{definePlugin as r}from"@razorwind/core/plugin";import{existsSync as i}from"@stryke/fs/exists";import{readFile as a}from"@stryke/fs/read-file";import{joinPaths as o}from"@stryke/path/join";import{isEmptyObject as s}from"@stryke/type-checks/is-empty-object";import{isObject as c}from"@stryke/type-checks/is-object";import{parse as l}from"yaml";var u=e({DESIGN_MD_FILE_PATTERN:()=>d,DESIGN_MD_PATH_CANDIDATES:()=>f,default:()=>A,designMdToTokens:()=>T,extractDesignMdFrontMatter:()=>w,isDesignMdFile:()=>D,loadDesignMdTokens:()=>k,parseDesignMdTokens:()=>E,resolveDesignMdPath:()=>O});const d=/(?:^|[/\\])design\.md$/i,f=[`DESIGN.md`,`design.md`,`docs/DESIGN.md`],p=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,m=/^\{[^{}]+\}$/,h=new Set([`version`,`name`,`description`]),g=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`,`fontFeature`,`fontVariation`],_={backgroundColor:`color`,textColor:`color`,typography:`typography`,rounded:`dimension`,padding:`dimension`,size:`dimension`,height:`dimension`,width:`dimension`};function v(e){return typeof e==`string`&&m.test(e.trim())}function y(e){return typeof e==`number`?`${e}px`:e}function b(e){let t={};for(let n of g){let r=e[n];r!=null&&(t[n]=r)}for(let[n,r]of Object.entries(e))!(n in t)&&r!=null&&(typeof r==`string`||typeof r==`number`)&&(t[n]=r);return t}function x(e,t,n=!1){let r={};for(let[i,a]of Object.entries(e))a!=null&&(r[i]={$type:t,$value:v(a)?a.trim():n?y(a):a});return r}function S(e){let t={};for(let[n,r]of Object.entries(e))v(r)?t[n]={$type:`typography`,$value:r.trim()}:c(r)&&(t[n]={$type:`typography`,$value:b(r)});return t}function C(e){let t={};for(let[n,r]of Object.entries(e)){if(!c(r))continue;let e={};for(let[t,n]of Object.entries(r)){if(n==null)continue;let r=_[t];e[t]={...r?{$type:r}:{},$value:v(n)?n.trim():r===`typography`&&c(n)?b(n):y(n)}}Object.keys(e).length>0&&(t[n]=e)}return t}function w(e){let t=p.exec(e);if(!t?.[1])return;let n;try{n=l(t[1])}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse DESIGN.md front matter as YAML: ${t}`)}return c(n)?n:void 0}function T(e){let t={};for(let[n,r]of Object.entries(e))if(!
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{useExecution as t}from"@power-plant/core";import{normalizeTokenTree as n}from"@razorwind/core";import{definePlugin as r}from"@razorwind/core/plugin";import{existsSync as i}from"@stryke/fs/exists";import{readFile as a}from"@stryke/fs/read-file";import{joinPaths as o}from"@stryke/path/join";import{isEmptyObject as s}from"@stryke/type-checks/is-empty-object";import{isObject as c}from"@stryke/type-checks/is-object";import{parse as l}from"yaml";var u=e({DESIGN_MD_FILE_PATTERN:()=>d,DESIGN_MD_PATH_CANDIDATES:()=>f,default:()=>A,designMdToTokens:()=>T,extractDesignMdFrontMatter:()=>w,isDesignMdFile:()=>D,loadDesignMdTokens:()=>k,parseDesignMdTokens:()=>E,resolveDesignMdPath:()=>O});const d=/(?:^|[/\\])design\.md$/i,f=[`DESIGN.md`,`design.md`,`docs/DESIGN.md`],p=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,m=/^\{[^{}]+\}$/,h=new Set([`version`,`name`,`description`]),g=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`,`fontFeature`,`fontVariation`],_={backgroundColor:`color`,textColor:`color`,typography:`typography`,rounded:`dimension`,padding:`dimension`,size:`dimension`,height:`dimension`,width:`dimension`};function v(e){return typeof e==`string`&&m.test(e.trim())}function y(e){return typeof e==`number`?`${e}px`:e}function b(e){let t={};for(let n of g){let r=e[n];r!=null&&(t[n]=r)}for(let[n,r]of Object.entries(e))!(n in t)&&r!=null&&(typeof r==`string`||typeof r==`number`)&&(t[n]=r);return t}function x(e,t,n=!1){let r={};for(let[i,a]of Object.entries(e))a!=null&&(r[i]={$type:t,$value:v(a)?a.trim():n?y(a):a});return r}function S(e){let t={};for(let[n,r]of Object.entries(e))v(r)?t[n]={$type:`typography`,$value:r.trim()}:c(r)&&(t[n]={$type:`typography`,$value:b(r)});return t}function C(e){let t={};for(let[n,r]of Object.entries(e)){if(!c(r))continue;let e={};for(let[t,n]of Object.entries(r)){if(n==null)continue;let r=_[t];e[t]={...r?{$type:r}:{},$value:v(n)?n.trim():r===`typography`&&c(n)?b(n):y(n)}}Object.keys(e).length>0&&(t[n]=e)}return t}function w(e){let t=p.exec(e);if(!t?.[1])return;let n;try{n=l(t[1])}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse DESIGN.md front matter as YAML: ${t}`)}return c(n)?n:void 0}function T(e){let t={};for(let[n,r]of Object.entries(e))if(!h.has(n)&&c(r))switch(n){case`colors`:t[n]=x(r,`color`);break;case`typography`:t[n]=S(r);break;case`rounded`:case`spacing`:t[n]=x(r,`dimension`,!0);break;case`components`:t[n]=C(r);break;default:t[n]=r}return n(t)}function E(e){let t=w(e);return t?T(t):{}}function D(e){return d.test(e)}function O(e){for(let t of f){let n=o(e,t);if(i(n))return n}}async function k(e){let t=O(e);if(t)return E(await a(t))}var A=r(e=>({name:`design-md:extract`,parsers:[{name:`design-md`,pattern:d,parser:e=>E(e)}],extract:async n=>{if(n.tokens&&!s(n.tokens))return n;let r=e?.path;if(!r){let{cwd:e}=t();if(r=O(e),!r)return n}let i=E(await a(r));return!i||s(i)?n:{...n,tokens:i}}}));export{d as DESIGN_MD_FILE_PATTERN,f as DESIGN_MD_PATH_CANDIDATES,A as default,T as designMdToTokens,w as extractDesignMdFrontMatter,D as isDesignMdFile,k as loadDesignMdTokens,E as parseDesignMdTokens,O as resolveDesignMdPath,u as t};
|
|
2
2
|
//# sourceMappingURL=extract.mjs.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{definePlugin as t}from"@razorwind/core/plugin";import{isObject as n}from"@stryke/type-checks/is-object";import{flattenTokens as r,formatTokenValue as i,isObject as a,isTokenLeaf as o,resolveSchemaIdentity as s,resolveTokenSets as c}from"@razorwind/core/utils";import{dirname as l,join as u}from"node:path";function d(e){return`# Installing ${e.name??`Razorwind Design System`} (DESIGN.md)
|
|
2
|
+
|
|
3
|
+
Generated by \`@razorwind/design-md\`.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- \`${e.outputPath}\` — DESIGN.md design-system specification
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
1. Place \`${e.outputPath}\` at your repo root (or the path your tooling expects).
|
|
12
|
+
|
|
13
|
+
2. Point DESIGN.md-aware tools (agents, linters, generators) at this file as the canonical design spec.
|
|
14
|
+
|
|
15
|
+
3. Keep \`${e.outputPath}\` in sync by re-running Razorwind generate when tokens or components change.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Reference token names, component rules, and layout guidance from \`${e.outputPath}\` when implementing UI. Regenerate rather than hand-editing generated sections.
|
|
20
|
+
`}function f(e){return e===!0||e===`true`||e===1}function p(e){if(typeof e.$type==`string`)return e.$type;if(typeof e.type==`string`)return e.type}function m(e){return f(e.palette)||f(e.$palette)?!0:p(e)===`palette`}function h(e){return f(e.primitive)||f(e.$primitive)?!0:p(e)===`primitive`}function g(e,t){return(e===`palette`||e===`$palette`||e===`primitive`||e===`$primitive`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function _(e,t){return e?`${e}:${t}`:t}function v(e){let t=new Map;function n(e,r,i,s,c){if(!a(e))return;let l=s||m(e),u=c||h(e);if(o(e)){(l||u)&&t.set(_(i,r.join(`.`)),{...l&&{palette:!0},...u&&{primitive:!0}});return}for(let[t,a]of Object.entries(e))t.startsWith(`$`)&&t!==`$palette`&&t!==`$primitive`||g(t,a)||n(a,[...r,t],i,l,u)}for(let t of c(e)){let e=t.id==="default"?void 0:t.id;n(t.tokens,[],e,!1,!1)}return t}function y(e,t){let n=r(e,{includeTypes:t,shouldIncludeToken:e=>e.skipDocs!==!0}),i=v(e);for(let e of n){let t=i.get(_(e.theme,e.path));t?.palette&&(e.palette=!0),t?.primitive&&(e.primitive=!0)}return n}function b(e,t){let n=e.split(`.`).filter(Boolean);for(;n.length>1&&t.includes(n[0].toLowerCase());)n.shift();return n.join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase()}function x(e){if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=String(e);return/^[a-z][\w-]*$/i.test(t)?t:JSON.stringify(t)}function S(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var C=e({default:()=>Y,extractDesignMd:()=>V,generateDesignMd:()=>J,renderDesignMd:()=>q,renderInstallMd:()=>d,selectPrimaryTheme:()=>N});const w=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),T={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},E=[`color`,`colors`,`palette`],D=[`typography`,`type`,`text`,`font`,`fonts`],O=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,k=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,A=/^components?$/i,j=/^\{([^}]+)\}$/,M=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function N(e){let t=[...new Set(e.map(e=>e.theme))],n=t.find(e=>e===void 0)??t.find(e=>/^light/i.test(e??``))??t.find(e=>/^(?:default|base)/i.test(e??``))??t[0];return e.filter(e=>e.theme===n)}function P(e){if(typeof e==`string`)return j.exec(e.trim())?.[1]}function F(e,t){let n=e;for(let e=0;e<8;e++){let e=P(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function I(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function L(e){let t=I(e);return w.has(t)?t:T[t.toLowerCase()]}function R(e,t){let r={};if(!n(e))return r;for(let n of M){let a=e[n];if(a==null)continue;let o=P(a),s=o?t.get(o):void 0,c=s?F(s,t).cssValue:void 0;if(typeof a==`number`){r[n]=n===`fontWeight`||n===`lineHeight`?a:i(a);continue}r[n]=c??i(a)}return r}function z(e,t){return{...e,...t.name!==void 0&&{name:t.name},...t.description!==void 0&&{description:t.description},...t.version!==void 0&&{version:t.version}}}function B(e){return e.palette===!0||e.primitive===!0}function V(e){let t=N(y(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r=s(e),i={...r.title||r.name?{name:r.title??r.name}:{},...r.description?{description:r.description}:{},colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},a=new Map,o=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&A.test(t[0])){o.push(e);continue}if(e.type===`color`){if(B(e))continue;let t=b(e.path,E),r=F(e,n);i.colors[t]=r.cssValue,e.description&&(i.colorDescriptions[t]=e.description),a.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=b(e.path,D);i.typography[t]=R(e.value,n),a.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=b(e.path,D);i.typography[t]??={},i.typography[t].fontFamily=e.cssValue,a.set(e.path,`typography.${t}`);continue}let r=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(r&&O.test(e.path)){let r=t.at(-1);i.rounded[r]=F(e,n).cssValue,a.set(e.path,`rounded.${r}`);continue}if(r&&k.test(e.path)){let r=t.at(-1);i.spacing[r]=F(e,n).cssValue,a.set(e.path,`spacing.${r}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let r=L(t.at(-1));if(!r)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=P(e.value),c=s?a.get(s):void 0,l=c?`{${c}}`:F(e,n).cssValue;i.components[o]??={},i.components[o][r]=l}return i}function H(e,t,n){let r=Object.entries(t);if(r.length!==0){n.push(`${e}:`);for(let[e,t]of r){if(typeof t==`object`&&t){n.push(` ${e}:`);for(let[e,r]of Object.entries(t))n.push(` ${e}: ${x(r)}`);continue}n.push(` ${e}: ${x(t)}`)}}}function U(e){let t=[`---`];return e.version?t.push(`version: ${x(e.version)}`):t.push(`version: alpha`),t.push(`name: ${x(e.name)}`),e.description&&t.push(`description: ${x(e.description)}`),H(`colors`,e.colors,t),H(`typography`,e.typography,t),H(`rounded`,e.rounded,t),H(`spacing`,e.spacing,t),H(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
+
`)}\n`}function W(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
+
`)}\n`}function G(e){let t=[[Object.keys(e.colors).length,`color`],[Object.keys(e.typography).length,`typography`],[Object.keys(e.rounded).length,`shape`],[Object.keys(e.spacing).length,`spacing`],[Object.keys(e.components).length,`component`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t} token${e===1?``:`s`}`).join(`, `);return`${e.name} design tokens${t?` — ${t}`:``}. The YAML front matter above is the normative source; the prose below explains how to apply it.`}function K(e,t={}){let n=[W(`Overview`,t.overview??G(e))],r=Object.entries(e.colors);r.length>0&&n.push(W(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${S(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
+
`)));let i=Object.entries(e.typography);i.length>0&&n.push(W(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
24
|
+
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(W(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
+
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(W(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
+
`)));let s=Object.entries(e.components);return s.length>0&&n.push(W(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
+
`))),n.join(`
|
|
28
|
+
`)}function q(e,t={}){return`${U(e)}\n${K(e,t)}`}function J(e,t={}){let n=z(V(e),t),r=t.outputPath??`DESIGN.md`,i=q(n,t),a=t.installGuide??d({outputPath:r,name:t.name??n.name}),o=u(l(r),`INSTALL.md`);return{[r]:{path:r,language:`markdown`,chunks:[{content:i,meta:{name:`razorwind-design-md`}}]},[o]:{path:o,language:`markdown`,chunks:[{content:a,meta:{name:`razorwind-design-md`}}]}}}var Y=t(e=>({name:`design-md:generate`,themeGeneration:`combined`,generate:async t=>J(t,e??{})}));export{q as a,C as i,J as n,N as o,Y as r,d as s,V as t};
|
|
29
|
+
//# sourceMappingURL=generate-Br3E6XNy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-Br3E6XNy.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("@razorwind/core/plugin"),n=require("@stryke/type-checks/is-object"),r=require("@razorwind/core/utils"),i=require("node:path");function a(e){return`# Installing ${e.name??`Razorwind Design System`} (DESIGN.md)
|
|
2
|
+
|
|
3
|
+
Generated by \`@razorwind/design-md\`.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- \`${e.outputPath}\` — DESIGN.md design-system specification
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
1. Place \`${e.outputPath}\` at your repo root (or the path your tooling expects).
|
|
12
|
+
|
|
13
|
+
2. Point DESIGN.md-aware tools (agents, linters, generators) at this file as the canonical design spec.
|
|
14
|
+
|
|
15
|
+
3. Keep \`${e.outputPath}\` in sync by re-running Razorwind generate when tokens or components change.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Reference token names, component rules, and layout guidance from \`${e.outputPath}\` when implementing UI. Regenerate rather than hand-editing generated sections.
|
|
20
|
+
`}function o(e){return e===!0||e===`true`||e===1}function s(e){if(typeof e.$type==`string`)return e.$type;if(typeof e.type==`string`)return e.type}function c(e){return o(e.palette)||o(e.$palette)?!0:s(e)===`palette`}function l(e){return o(e.primitive)||o(e.$primitive)?!0:s(e)===`primitive`}function u(e,t){return(e===`palette`||e===`$palette`||e===`primitive`||e===`$primitive`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function d(e,t){return e?`${e}:${t}`:t}function f(e){let t=new Map;function n(e,i,a,o,s){if(!(0,r.isObject)(e))return;let f=o||c(e),p=s||l(e);if((0,r.isTokenLeaf)(e)){(f||p)&&t.set(d(a,i.join(`.`)),{...f&&{palette:!0},...p&&{primitive:!0}});return}for(let[t,r]of Object.entries(e))t.startsWith(`$`)&&t!==`$palette`&&t!==`$primitive`||u(t,r)||n(r,[...i,t],a,f,p)}for(let t of(0,r.resolveTokenSets)(e)){let e=t.id==="default"?void 0:t.id;n(t.tokens,[],e,!1,!1)}return t}function p(e,t){let n=(0,r.flattenTokens)(e,{includeTypes:t,shouldIncludeToken:e=>e.skipDocs!==!0}),i=f(e);for(let e of n){let t=i.get(d(e.theme,e.path));t?.palette&&(e.palette=!0),t?.primitive&&(e.primitive=!0)}return n}function m(e,t){let n=e.split(`.`).filter(Boolean);for(;n.length>1&&t.includes(n[0].toLowerCase());)n.shift();return n.join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase()}function h(e){if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=String(e);return/^[a-z][\w-]*$/i.test(t)?t:JSON.stringify(t)}function g(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var _=e.t({default:()=>U,extractDesignMd:()=>F,generateDesignMd:()=>H,renderDesignMd:()=>V,renderInstallMd:()=>a,selectPrimaryTheme:()=>D});const v=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),y={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},b=[`color`,`colors`,`palette`],x=[`typography`,`type`,`text`,`font`,`fonts`],S=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,C=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,w=/^components?$/i,T=/^\{([^}]+)\}$/,E=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function D(e){let t=[...new Set(e.map(e=>e.theme))],n=t.find(e=>e===void 0)??t.find(e=>/^light/i.test(e??``))??t.find(e=>/^(?:default|base)/i.test(e??``))??t[0];return e.filter(e=>e.theme===n)}function O(e){if(typeof e==`string`)return T.exec(e.trim())?.[1]}function k(e,t){let n=e;for(let e=0;e<8;e++){let e=O(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function A(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function j(e){let t=A(e);return v.has(t)?t:y[t.toLowerCase()]}function M(e,t){let i={};if(!(0,n.isObject)(e))return i;for(let n of E){let a=e[n];if(a==null)continue;let o=O(a),s=o?t.get(o):void 0,c=s?k(s,t).cssValue:void 0;if(typeof a==`number`){i[n]=n===`fontWeight`||n===`lineHeight`?a:(0,r.formatTokenValue)(a);continue}i[n]=c??(0,r.formatTokenValue)(a)}return i}function N(e,t){return{...e,...t.name!==void 0&&{name:t.name},...t.description!==void 0&&{description:t.description},...t.version!==void 0&&{version:t.version}}}function P(e){return e.palette===!0||e.primitive===!0}function F(e){let t=D(p(e.tokens)),n=new Map(t.map(e=>[e.path,e])),i=(0,r.resolveSchemaIdentity)(e),a={...i.title||i.name?{name:i.title??i.name}:{},...i.description?{description:i.description}:{},colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},o=new Map,s=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&w.test(t[0])){s.push(e);continue}if(e.type===`color`){if(P(e))continue;let t=m(e.path,b),r=k(e,n);a.colors[t]=r.cssValue,e.description&&(a.colorDescriptions[t]=e.description),o.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=m(e.path,x);a.typography[t]=M(e.value,n),o.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=m(e.path,x);a.typography[t]??={},a.typography[t].fontFamily=e.cssValue,o.set(e.path,`typography.${t}`);continue}let r=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(r&&S.test(e.path)){let r=t.at(-1);a.rounded[r]=k(e,n).cssValue,o.set(e.path,`rounded.${r}`);continue}if(r&&C.test(e.path)){let r=t.at(-1);a.spacing[r]=k(e,n).cssValue,o.set(e.path,`spacing.${r}`)}}for(let e of s){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let r=j(t.at(-1));if(!r)continue;let i=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=O(e.value),c=s?o.get(s):void 0,l=c?`{${c}}`:k(e,n).cssValue;a.components[i]??={},a.components[i][r]=l}return a}function I(e,t,n){let r=Object.entries(t);if(r.length!==0){n.push(`${e}:`);for(let[e,t]of r){if(typeof t==`object`&&t){n.push(` ${e}:`);for(let[e,r]of Object.entries(t))n.push(` ${e}: ${h(r)}`);continue}n.push(` ${e}: ${h(t)}`)}}}function L(e){let t=[`---`];return e.version?t.push(`version: ${h(e.version)}`):t.push(`version: alpha`),t.push(`name: ${h(e.name)}`),e.description&&t.push(`description: ${h(e.description)}`),I(`colors`,e.colors,t),I(`typography`,e.typography,t),I(`rounded`,e.rounded,t),I(`spacing`,e.spacing,t),I(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
+
`)}\n`}function R(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
+
`)}\n`}function z(e){let t=[[Object.keys(e.colors).length,`color`],[Object.keys(e.typography).length,`typography`],[Object.keys(e.rounded).length,`shape`],[Object.keys(e.spacing).length,`spacing`],[Object.keys(e.components).length,`component`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t} token${e===1?``:`s`}`).join(`, `);return`${e.name} design tokens${t?` — ${t}`:``}. The YAML front matter above is the normative source; the prose below explains how to apply it.`}function B(e,t={}){let n=[R(`Overview`,t.overview??z(e))],r=Object.entries(e.colors);r.length>0&&n.push(R(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${g(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
+
`)));let i=Object.entries(e.typography);i.length>0&&n.push(R(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
24
|
+
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(R(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
+
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(R(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
+
`)));let s=Object.entries(e.components);return s.length>0&&n.push(R(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
+
`))),n.join(`
|
|
28
|
+
`)}function V(e,t={}){return`${L(e)}\n${B(e,t)}`}function H(e,t={}){let n=N(F(e),t),r=t.outputPath??`DESIGN.md`,o=V(n,t),s=t.installGuide??a({outputPath:r,name:t.name??n.name}),c=(0,i.join)((0,i.dirname)(r),`INSTALL.md`);return{[r]:{path:r,language:`markdown`,chunks:[{content:o,meta:{name:`razorwind-design-md`}}]},[c]:{path:c,language:`markdown`,chunks:[{content:s,meta:{name:`razorwind-design-md`}}]}}}var U=(0,t.definePlugin)(e=>({name:`design-md:generate`,themeGeneration:`combined`,generate:async t=>H(t,e??{})}));Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return F}});
|
package/dist/generate.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./generate-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./generate-DRDnuRqo.cjs");exports.default=e.r,exports.extractDesignMd=e.t,exports.generateDesignMd=e.n,exports.renderDesignMd=e.a,exports.renderInstallMd=e.s,exports.selectPrimaryTheme=e.o;
|
package/dist/generate.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t,o as n,r,s as i,t as a}from"./generate-
|
|
1
|
+
import{a as e,n as t,o as n,r,s as i,t as a}from"./generate-Br3E6XNy.mjs";export{r as default,a as extractDesignMd,t as generateDesignMd,e as renderDesignMd,i as renderInstallMd,n as selectPrimaryTheme};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./extract.cjs"),t=require("./generate-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./extract.cjs"),t=require("./generate-DRDnuRqo.cjs");Object.defineProperty(exports,"extract",{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,"generate",{enumerable:!0,get:function(){return t.i}});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./extract.mjs";import{i as t}from"./generate-
|
|
1
|
+
import{t as e}from"./extract.mjs";import{i as t}from"./generate-Br3E6XNy.mjs";export{e as extract,t as generate};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/design-md",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Razorwind DESIGN.md plugin that can create a DESIGN.md design-system specification file from design tokens or read a DESIGN.md file and return the design-system specification.",
|
|
6
6
|
"repository": {
|
|
@@ -78,20 +78,20 @@
|
|
|
78
78
|
"types": "./dist/index.d.cts",
|
|
79
79
|
"typings": "dist/index.d.mts",
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@power-plant/core": "^0.0.
|
|
81
|
+
"@power-plant/core": "^0.0.92",
|
|
82
82
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
83
|
-
"@razorwind/core": "^0.0.
|
|
84
|
-
"@stryke/fs": "^0.33.
|
|
85
|
-
"@stryke/path": "^0.29.
|
|
86
|
-
"@stryke/type-checks": "^0.6.
|
|
87
|
-
"style-dictionary": "^5.5.
|
|
83
|
+
"@razorwind/core": "^0.0.64",
|
|
84
|
+
"@stryke/fs": "^0.33.116",
|
|
85
|
+
"@stryke/path": "^0.29.41",
|
|
86
|
+
"@stryke/type-checks": "^0.6.47",
|
|
87
|
+
"style-dictionary": "^5.5.3",
|
|
88
88
|
"yaml": "^2.9.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@powerlines/plugin-tsdown": "^0.1.
|
|
91
|
+
"@powerlines/plugin-tsdown": "^0.1.613",
|
|
92
92
|
"@types/node": "^25.9.5",
|
|
93
93
|
"typescript": "^6.0.3"
|
|
94
94
|
},
|
|
95
95
|
"publishConfig": { "access": "public" },
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "49873beaca1bec96f7d6869f9dcd8c20efd2be41"
|
|
97
97
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("@razorwind/core/plugin"),n=require("@stryke/type-checks/is-object"),r=require("@razorwind/core/utils"),i=require("node:path");function a(e){return`# Installing ${e.name??`Razorwind Design System`} (DESIGN.md)
|
|
2
|
-
|
|
3
|
-
Generated by \`@razorwind/design-md\`.
|
|
4
|
-
|
|
5
|
-
## Files
|
|
6
|
-
|
|
7
|
-
- \`${e.outputPath}\` — DESIGN.md design-system specification
|
|
8
|
-
|
|
9
|
-
## Setup
|
|
10
|
-
|
|
11
|
-
1. Place \`${e.outputPath}\` at your repo root (or the path your tooling expects).
|
|
12
|
-
|
|
13
|
-
2. Point DESIGN.md-aware tools (agents, linters, generators) at this file as the canonical design spec.
|
|
14
|
-
|
|
15
|
-
3. Keep \`${e.outputPath}\` in sync by re-running Razorwind generate when tokens or components change.
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
Reference token names, component rules, and layout guidance from \`${e.outputPath}\` when implementing UI. Regenerate rather than hand-editing generated sections.
|
|
20
|
-
`}function o(e){return e===!0||e===`true`||e===1}function s(e){if(typeof e.$type==`string`)return e.$type;if(typeof e.type==`string`)return e.type}function c(e){return o(e.palette)||o(e.$palette)?!0:s(e)===`palette`}function l(e){return o(e.primitive)||o(e.$primitive)?!0:s(e)===`primitive`}function u(e,t){return(e===`palette`||e===`$palette`||e===`primitive`||e===`$primitive`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function d(e,t){return e?`${e}:${t}`:t}function f(e){let t=new Map;function n(e,i,a,o,s){if(!(0,r.isObject)(e))return;let f=o||c(e),p=s||l(e);if((0,r.isTokenLeaf)(e)){(f||p)&&t.set(d(a,i.join(`.`)),{...f&&{palette:!0},...p&&{primitive:!0}});return}for(let[t,r]of Object.entries(e))t.startsWith(`$`)&&t!==`$palette`&&t!==`$primitive`||u(t,r)||n(r,[...i,t],a,f,p)}for(let t of(0,r.resolveTokenSets)(e)){let e=t.id==="default"?void 0:t.id;n(t.tokens,[],e,!1,!1)}return t}function p(e,t){let n=(0,r.flattenTokens)(e,{includeTypes:t}),i=f(e);for(let e of n){let t=i.get(d(e.theme,e.path));t?.palette&&(e.palette=!0),t?.primitive&&(e.primitive=!0)}return n}function m(e,t){let n=e.split(`.`).filter(Boolean);for(;n.length>1&&t.includes(n[0].toLowerCase());)n.shift();return n.join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase()}function h(e){if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=String(e);return/^[a-z][\w-]*$/i.test(t)?t:JSON.stringify(t)}function g(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var _=e.t({default:()=>U,extractDesignMd:()=>F,generateDesignMd:()=>H,renderDesignMd:()=>V,renderInstallMd:()=>a,selectPrimaryTheme:()=>D});const v=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),y={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},b=[`color`,`colors`,`palette`],x=[`typography`,`type`,`text`,`font`,`fonts`],S=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,C=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,w=/^components?$/i,T=/^\{([^}]+)\}$/,E=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function D(e){let t=[...new Set(e.map(e=>e.theme))],n=t.find(e=>e===void 0)??t.find(e=>/^light/i.test(e??``))??t.find(e=>/^(?:default|base)/i.test(e??``))??t[0];return e.filter(e=>e.theme===n)}function O(e){if(typeof e==`string`)return T.exec(e.trim())?.[1]}function k(e,t){let n=e;for(let e=0;e<8;e++){let e=O(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function A(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function j(e){let t=A(e);return v.has(t)?t:y[t.toLowerCase()]}function M(e,t){let i={};if(!(0,n.isObject)(e))return i;for(let n of E){let a=e[n];if(a==null)continue;let o=O(a),s=o?t.get(o):void 0,c=s?k(s,t).cssValue:void 0;if(typeof a==`number`){i[n]=n===`fontWeight`||n===`lineHeight`?a:(0,r.formatTokenValue)(a);continue}i[n]=c??(0,r.formatTokenValue)(a)}return i}function N(e,t){return{...e,...t.name!==void 0&&{name:t.name},...t.description!==void 0&&{description:t.description},...t.version!==void 0&&{version:t.version}}}function P(e){return e.palette===!0||e.primitive===!0}function F(e){let t=D(p(e.tokens)),n=new Map(t.map(e=>[e.path,e])),i=(0,r.resolveSchemaIdentity)(e),a={...i.title||i.name?{name:i.title??i.name}:{},...i.description?{description:i.description}:{},colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},o=new Map,s=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&w.test(t[0])){s.push(e);continue}if(e.type===`color`){if(P(e))continue;let t=m(e.path,b),r=k(e,n);a.colors[t]=r.cssValue,e.description&&(a.colorDescriptions[t]=e.description),o.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=m(e.path,x);a.typography[t]=M(e.value,n),o.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=m(e.path,x);a.typography[t]??={},a.typography[t].fontFamily=e.cssValue,o.set(e.path,`typography.${t}`);continue}let r=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(r&&S.test(e.path)){let r=t.at(-1);a.rounded[r]=k(e,n).cssValue,o.set(e.path,`rounded.${r}`);continue}if(r&&C.test(e.path)){let r=t.at(-1);a.spacing[r]=k(e,n).cssValue,o.set(e.path,`spacing.${r}`)}}for(let e of s){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let r=j(t.at(-1));if(!r)continue;let i=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=O(e.value),c=s?o.get(s):void 0,l=c?`{${c}}`:k(e,n).cssValue;a.components[i]??={},a.components[i][r]=l}return a}function I(e,t,n){let r=Object.entries(t);if(r.length!==0){n.push(`${e}:`);for(let[e,t]of r){if(typeof t==`object`&&t){n.push(` ${e}:`);for(let[e,r]of Object.entries(t))n.push(` ${e}: ${h(r)}`);continue}n.push(` ${e}: ${h(t)}`)}}}function L(e){let t=[`---`];return e.version?t.push(`version: ${h(e.version)}`):t.push(`version: alpha`),t.push(`name: ${h(e.name)}`),e.description&&t.push(`description: ${h(e.description)}`),I(`colors`,e.colors,t),I(`typography`,e.typography,t),I(`rounded`,e.rounded,t),I(`spacing`,e.spacing,t),I(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
-
`)}\n`}function R(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
-
`)}\n`}function z(e){let t=[[Object.keys(e.colors).length,`color`],[Object.keys(e.typography).length,`typography`],[Object.keys(e.rounded).length,`shape`],[Object.keys(e.spacing).length,`spacing`],[Object.keys(e.components).length,`component`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t} token${e===1?``:`s`}`).join(`, `);return`${e.name} design tokens${t?` — ${t}`:``}. The YAML front matter above is the normative source; the prose below explains how to apply it.`}function B(e,t={}){let n=[R(`Overview`,t.overview??z(e))],r=Object.entries(e.colors);r.length>0&&n.push(R(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${g(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
-
`)));let i=Object.entries(e.typography);i.length>0&&n.push(R(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
24
|
-
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(R(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
-
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(R(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
-
`)));let s=Object.entries(e.components);return s.length>0&&n.push(R(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
-
`))),n.join(`
|
|
28
|
-
`)}function V(e,t={}){return`${L(e)}\n${B(e,t)}`}function H(e,t={}){let n=N(F(e),t),r=t.outputPath??`DESIGN.md`,o=V(n,t),s=t.installGuide??a({outputPath:r,name:t.name??n.name}),c=(0,i.join)((0,i.dirname)(r),`INSTALL.md`);return{[r]:{path:r,language:`markdown`,chunks:[{content:o,meta:{name:`razorwind-design-md`}}]},[c]:{path:c,language:`markdown`,chunks:[{content:s,meta:{name:`razorwind-design-md`}}]}}}var U=(0,t.definePlugin)(e=>({name:`design-md:generate`,themeGeneration:`combined`,generate:async t=>H(t,e??{})}));Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return F}});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{definePlugin as t}from"@razorwind/core/plugin";import{isObject as n}from"@stryke/type-checks/is-object";import{flattenTokens as r,formatTokenValue as i,isObject as a,isTokenLeaf as o,resolveSchemaIdentity as s,resolveTokenSets as c}from"@razorwind/core/utils";import{dirname as l,join as u}from"node:path";function d(e){return`# Installing ${e.name??`Razorwind Design System`} (DESIGN.md)
|
|
2
|
-
|
|
3
|
-
Generated by \`@razorwind/design-md\`.
|
|
4
|
-
|
|
5
|
-
## Files
|
|
6
|
-
|
|
7
|
-
- \`${e.outputPath}\` — DESIGN.md design-system specification
|
|
8
|
-
|
|
9
|
-
## Setup
|
|
10
|
-
|
|
11
|
-
1. Place \`${e.outputPath}\` at your repo root (or the path your tooling expects).
|
|
12
|
-
|
|
13
|
-
2. Point DESIGN.md-aware tools (agents, linters, generators) at this file as the canonical design spec.
|
|
14
|
-
|
|
15
|
-
3. Keep \`${e.outputPath}\` in sync by re-running Razorwind generate when tokens or components change.
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
Reference token names, component rules, and layout guidance from \`${e.outputPath}\` when implementing UI. Regenerate rather than hand-editing generated sections.
|
|
20
|
-
`}function f(e){return e===!0||e===`true`||e===1}function p(e){if(typeof e.$type==`string`)return e.$type;if(typeof e.type==`string`)return e.type}function m(e){return f(e.palette)||f(e.$palette)?!0:p(e)===`palette`}function h(e){return f(e.primitive)||f(e.$primitive)?!0:p(e)===`primitive`}function g(e,t){return(e===`palette`||e===`$palette`||e===`primitive`||e===`$primitive`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function _(e,t){return e?`${e}:${t}`:t}function v(e){let t=new Map;function n(e,r,i,s,c){if(!a(e))return;let l=s||m(e),u=c||h(e);if(o(e)){(l||u)&&t.set(_(i,r.join(`.`)),{...l&&{palette:!0},...u&&{primitive:!0}});return}for(let[t,a]of Object.entries(e))t.startsWith(`$`)&&t!==`$palette`&&t!==`$primitive`||g(t,a)||n(a,[...r,t],i,l,u)}for(let t of c(e)){let e=t.id==="default"?void 0:t.id;n(t.tokens,[],e,!1,!1)}return t}function y(e,t){let n=r(e,{includeTypes:t}),i=v(e);for(let e of n){let t=i.get(_(e.theme,e.path));t?.palette&&(e.palette=!0),t?.primitive&&(e.primitive=!0)}return n}function b(e,t){let n=e.split(`.`).filter(Boolean);for(;n.length>1&&t.includes(n[0].toLowerCase());)n.shift();return n.join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase()}function x(e){if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=String(e);return/^[a-z][\w-]*$/i.test(t)?t:JSON.stringify(t)}function S(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var C=e({default:()=>Y,extractDesignMd:()=>V,generateDesignMd:()=>J,renderDesignMd:()=>q,renderInstallMd:()=>d,selectPrimaryTheme:()=>N});const w=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),T={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},E=[`color`,`colors`,`palette`],D=[`typography`,`type`,`text`,`font`,`fonts`],O=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,k=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,A=/^components?$/i,j=/^\{([^}]+)\}$/,M=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function N(e){let t=[...new Set(e.map(e=>e.theme))],n=t.find(e=>e===void 0)??t.find(e=>/^light/i.test(e??``))??t.find(e=>/^(?:default|base)/i.test(e??``))??t[0];return e.filter(e=>e.theme===n)}function P(e){if(typeof e==`string`)return j.exec(e.trim())?.[1]}function F(e,t){let n=e;for(let e=0;e<8;e++){let e=P(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function I(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function L(e){let t=I(e);return w.has(t)?t:T[t.toLowerCase()]}function R(e,t){let r={};if(!n(e))return r;for(let n of M){let a=e[n];if(a==null)continue;let o=P(a),s=o?t.get(o):void 0,c=s?F(s,t).cssValue:void 0;if(typeof a==`number`){r[n]=n===`fontWeight`||n===`lineHeight`?a:i(a);continue}r[n]=c??i(a)}return r}function z(e,t){return{...e,...t.name!==void 0&&{name:t.name},...t.description!==void 0&&{description:t.description},...t.version!==void 0&&{version:t.version}}}function B(e){return e.palette===!0||e.primitive===!0}function V(e){let t=N(y(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r=s(e),i={...r.title||r.name?{name:r.title??r.name}:{},...r.description?{description:r.description}:{},colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},a=new Map,o=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&A.test(t[0])){o.push(e);continue}if(e.type===`color`){if(B(e))continue;let t=b(e.path,E),r=F(e,n);i.colors[t]=r.cssValue,e.description&&(i.colorDescriptions[t]=e.description),a.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=b(e.path,D);i.typography[t]=R(e.value,n),a.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=b(e.path,D);i.typography[t]??={},i.typography[t].fontFamily=e.cssValue,a.set(e.path,`typography.${t}`);continue}let r=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(r&&O.test(e.path)){let r=t.at(-1);i.rounded[r]=F(e,n).cssValue,a.set(e.path,`rounded.${r}`);continue}if(r&&k.test(e.path)){let r=t.at(-1);i.spacing[r]=F(e,n).cssValue,a.set(e.path,`spacing.${r}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let r=L(t.at(-1));if(!r)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=P(e.value),c=s?a.get(s):void 0,l=c?`{${c}}`:F(e,n).cssValue;i.components[o]??={},i.components[o][r]=l}return i}function H(e,t,n){let r=Object.entries(t);if(r.length!==0){n.push(`${e}:`);for(let[e,t]of r){if(typeof t==`object`&&t){n.push(` ${e}:`);for(let[e,r]of Object.entries(t))n.push(` ${e}: ${x(r)}`);continue}n.push(` ${e}: ${x(t)}`)}}}function U(e){let t=[`---`];return e.version?t.push(`version: ${x(e.version)}`):t.push(`version: alpha`),t.push(`name: ${x(e.name)}`),e.description&&t.push(`description: ${x(e.description)}`),H(`colors`,e.colors,t),H(`typography`,e.typography,t),H(`rounded`,e.rounded,t),H(`spacing`,e.spacing,t),H(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
-
`)}\n`}function W(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
-
`)}\n`}function G(e){let t=[[Object.keys(e.colors).length,`color`],[Object.keys(e.typography).length,`typography`],[Object.keys(e.rounded).length,`shape`],[Object.keys(e.spacing).length,`spacing`],[Object.keys(e.components).length,`component`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t} token${e===1?``:`s`}`).join(`, `);return`${e.name} design tokens${t?` — ${t}`:``}. The YAML front matter above is the normative source; the prose below explains how to apply it.`}function K(e,t={}){let n=[W(`Overview`,t.overview??G(e))],r=Object.entries(e.colors);r.length>0&&n.push(W(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${S(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
-
`)));let i=Object.entries(e.typography);i.length>0&&n.push(W(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
24
|
-
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(W(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
-
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(W(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
-
`)));let s=Object.entries(e.components);return s.length>0&&n.push(W(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
-
`))),n.join(`
|
|
28
|
-
`)}function q(e,t={}){return`${U(e)}\n${K(e,t)}`}function J(e,t={}){let n=z(V(e),t),r=t.outputPath??`DESIGN.md`,i=q(n,t),a=t.installGuide??d({outputPath:r,name:t.name??n.name}),o=u(l(r),`INSTALL.md`);return{[r]:{path:r,language:`markdown`,chunks:[{content:i,meta:{name:`razorwind-design-md`}}]},[o]:{path:o,language:`markdown`,chunks:[{content:a,meta:{name:`razorwind-design-md`}}]}}}var Y=t(e=>({name:`design-md:generate`,themeGeneration:`combined`,generate:async t=>J(t,e??{})}));export{q as a,C as i,J as n,N as o,Y as r,d as s,V as t};
|
|
29
|
-
//# sourceMappingURL=generate-DZ-OYEsh.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-DZ-OYEsh.mjs","names":[],"sources":[],"mappings":""}
|