@razorwind/design-md 0.0.52 → 0.0.53
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.d.cts +1 -1
- package/dist/extract.d.mts +1 -1
- package/dist/{generate-DXmXS53P.d.mts → generate-BEqyhG3P.d.mts} +7 -5
- package/dist/generate-BEqyhG3P.d.mts.map +1 -0
- package/dist/generate-CzUKj9-i.cjs +28 -0
- package/dist/generate-DZ-OYEsh.mjs +29 -0
- package/dist/generate-DZ-OYEsh.mjs.map +1 -0
- package/dist/{generate-Cc5TpO46.d.cts → generate-ZM_8ibPd.d.cts} +7 -5
- package/dist/generate-ZM_8ibPd.d.cts.map +1 -0
- package/dist/generate.cjs +1 -1
- package/dist/generate.d.cts +1 -1
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{types-I1sC5VJa.d.cts → types-CVzqIrbl.d.cts} +10 -2
- package/dist/types-CVzqIrbl.d.cts.map +1 -0
- package/dist/{types-Dytdpn6d.d.mts → types-txdk4MJU.d.mts} +10 -2
- package/dist/types-txdk4MJU.d.mts.map +1 -0
- package/package.json +2 -2
- package/dist/generate-Cc5TpO46.d.cts.map +0 -1
- package/dist/generate-DXmXS53P.d.mts.map +0 -1
- package/dist/generate-P_Pz4ABf.cjs +0 -28
- package/dist/generate-XnAk-wWP.mjs +0 -29
- package/dist/generate-XnAk-wWP.mjs.map +0 -1
- package/dist/types-Dytdpn6d.d.mts.map +0 -1
- package/dist/types-I1sC5VJa.d.cts.map +0 -1
package/dist/extract.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __exportAll, n as DesignMdExtractPluginOptions } from "./types-
|
|
1
|
+
import { a as __exportAll, n as DesignMdExtractPluginOptions } from "./types-CVzqIrbl.cjs";
|
|
2
2
|
import { DesignTokens } from "style-dictionary/types";
|
|
3
3
|
declare namespace extract_d_exports {
|
|
4
4
|
export { DESIGN_MD_FILE_PATTERN, DESIGN_MD_PATH_CANDIDATES, _default as default, designMdToTokens, extractDesignMdFrontMatter, isDesignMdFile, loadDesignMdTokens, parseDesignMdTokens, resolveDesignMdPath };
|
package/dist/extract.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DesignMdExtractPluginOptions } from "./types-
|
|
1
|
+
import { n as DesignMdExtractPluginOptions } from "./types-txdk4MJU.mjs";
|
|
2
2
|
import { DesignTokens } from "style-dictionary/types";
|
|
3
3
|
declare namespace extract_d_exports {
|
|
4
4
|
export { DESIGN_MD_FILE_PATTERN, DESIGN_MD_PATH_CANDIDATES, _default as default, designMdToTokens, extractDesignMdFrontMatter, isDesignMdFile, loadDesignMdTokens, parseDesignMdTokens, resolveDesignMdPath };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as FlatToken, r as DesignMdGeneratePluginOptions, t as DesignMdDocument } from "./types-
|
|
1
|
+
import { i as FlatToken, r as DesignMdGeneratePluginOptions, t as DesignMdDocument } from "./types-txdk4MJU.mjs";
|
|
2
2
|
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
3
|
import { Schema } from "@razorwind/core/schema";
|
|
4
4
|
//#region src/install.d.ts
|
|
@@ -24,9 +24,11 @@ declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
|
24
24
|
* Extract a DESIGN.md document from the Razorwind schema.
|
|
25
25
|
*
|
|
26
26
|
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
27
|
-
* derived from the DTCG token tree.
|
|
28
|
-
* `
|
|
29
|
-
*
|
|
27
|
+
* derived from the DTCG token tree. Color groups marked `palette` or
|
|
28
|
+
* `primitive` are omitted from the colors section. DTCG aliases are
|
|
29
|
+
* re-emitted as DESIGN.md `{section.token}` references when the target
|
|
30
|
+
* token is part of the output, or resolved to their terminal CSS value
|
|
31
|
+
* otherwise.
|
|
30
32
|
*/
|
|
31
33
|
declare function extractDesignMd(spec: Schema): DesignMdDocument;
|
|
32
34
|
/**
|
|
@@ -61,4 +63,4 @@ declare function generateDesignMd(spec: Schema, options?: DesignMdGeneratePlugin
|
|
|
61
63
|
declare const _default: (options?: DesignMdGeneratePluginOptions | undefined) => import("@razorwind/core").Plugin;
|
|
62
64
|
//#endregion
|
|
63
65
|
export { renderDesignMd as a, generate_d_exports as i, extractDesignMd as n, selectPrimaryTheme as o, generateDesignMd as r, renderInstallMd as s, _default as t };
|
|
64
|
-
//# sourceMappingURL=generate-
|
|
66
|
+
//# sourceMappingURL=generate-BEqyhG3P.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-BEqyhG3P.d.mts","names":[],"sources":["../src/install.ts","../src/generate.ts"],"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}),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}});
|
|
@@ -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}),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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-DZ-OYEsh.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __exportAll, i as FlatToken, r as DesignMdGeneratePluginOptions, t as DesignMdDocument } from "./types-
|
|
1
|
+
import { a as __exportAll, i as FlatToken, r as DesignMdGeneratePluginOptions, t as DesignMdDocument } from "./types-CVzqIrbl.cjs";
|
|
2
2
|
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
3
|
import { Schema } from "@razorwind/core/schema";
|
|
4
4
|
//#region src/install.d.ts
|
|
@@ -24,9 +24,11 @@ declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
|
24
24
|
* Extract a DESIGN.md document from the Razorwind schema.
|
|
25
25
|
*
|
|
26
26
|
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
27
|
-
* derived from the DTCG token tree.
|
|
28
|
-
* `
|
|
29
|
-
*
|
|
27
|
+
* derived from the DTCG token tree. Color groups marked `palette` or
|
|
28
|
+
* `primitive` are omitted from the colors section. DTCG aliases are
|
|
29
|
+
* re-emitted as DESIGN.md `{section.token}` references when the target
|
|
30
|
+
* token is part of the output, or resolved to their terminal CSS value
|
|
31
|
+
* otherwise.
|
|
30
32
|
*/
|
|
31
33
|
declare function extractDesignMd(spec: Schema): DesignMdDocument;
|
|
32
34
|
/**
|
|
@@ -61,4 +63,4 @@ declare function generateDesignMd(spec: Schema, options?: DesignMdGeneratePlugin
|
|
|
61
63
|
declare const _default: (options?: DesignMdGeneratePluginOptions | undefined) => import("@razorwind/core").Plugin;
|
|
62
64
|
//#endregion
|
|
63
65
|
export { renderDesignMd as a, generate_d_exports as i, extractDesignMd as n, selectPrimaryTheme as o, generateDesignMd as r, renderInstallMd as s, _default as t };
|
|
64
|
-
//# sourceMappingURL=generate-
|
|
66
|
+
//# sourceMappingURL=generate-ZM_8ibPd.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-ZM_8ibPd.d.cts","names":[],"sources":["../src/install.ts","../src/generate.ts"],"mappings":";;;;;;;;;iBAuBgB,gBAAgB;EAC9B;EACA;;;;;;;;;;iBC8Dc,mBAAmB,MAAM,cAAc;;;;;;;;;;;iBAyIvC,gBAAgB,MAAM,SAAS;;;;;;;iBA4R/B,eACd,UAAU,kBACV,UAAS;;;;;;;iBAaK,iBACd,MAAM,QACN,UAAS,gCACR,wBAAwB,QAAQ"}
|
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-CzUKj9-i.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.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as renderDesignMd, n as extractDesignMd, o as selectPrimaryTheme, r as generateDesignMd, s as renderInstallMd, t as _default } from "./generate-
|
|
1
|
+
import { a as renderDesignMd, n as extractDesignMd, o as selectPrimaryTheme, r as generateDesignMd, s as renderInstallMd, t as _default } from "./generate-ZM_8ibPd.cjs";
|
|
2
2
|
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, renderInstallMd, selectPrimaryTheme };
|
package/dist/generate.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as renderDesignMd, n as extractDesignMd, o as selectPrimaryTheme, r as generateDesignMd, s as renderInstallMd, t as _default } from "./generate-
|
|
1
|
+
import { a as renderDesignMd, n as extractDesignMd, o as selectPrimaryTheme, r as generateDesignMd, s as renderInstallMd, t as _default } from "./generate-BEqyhG3P.mjs";
|
|
2
2
|
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, renderInstallMd, selectPrimaryTheme };
|
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-DZ-OYEsh.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-CzUKj9-i.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.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
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-DZ-OYEsh.mjs";export{e as extract,t as generate};
|
|
@@ -59,7 +59,15 @@ interface FlatToken {
|
|
|
59
59
|
description?: string;
|
|
60
60
|
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
61
61
|
theme?: string;
|
|
62
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* True when an ancestor group is marked `palette: true` (or `$palette` /
|
|
64
|
+
* `$type: "palette"`).
|
|
65
|
+
*/
|
|
66
|
+
palette?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* True when an ancestor group is marked `primitive: true` (or `$primitive` /
|
|
69
|
+
* `$type: "primitive"`).
|
|
70
|
+
*/
|
|
63
71
|
primitive?: boolean;
|
|
64
72
|
}
|
|
65
73
|
/**
|
|
@@ -97,4 +105,4 @@ interface DesignMdDocument {
|
|
|
97
105
|
}
|
|
98
106
|
//#endregion
|
|
99
107
|
export { __exportAll as a, FlatToken as i, DesignMdExtractPluginOptions as n, DesignMdGeneratePluginOptions as r, DesignMdDocument as t };
|
|
100
|
-
//# sourceMappingURL=types-
|
|
108
|
+
//# sourceMappingURL=types-CVzqIrbl.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CVzqIrbl.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;UAoBiB;;;;;;EAMf;;UAGe;;;;;;EAMf;;;;;;EAOA;;;;EAKA;;;;;;EAOA;;;;;EAMA;;;;;EAMA;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;;;EAKA;;;;;;UAOe;EACf;EACA;EACA;EACA;EACA;;;;;;;KAQU,iBAAiB;;;;;UAMZ;EACf;EACA;EACA;EACA,QAAQ;;EAER,mBAAmB;EACnB,YAAY,eAAe;EAC3B,SAAS;EACT,SAAS;EACT,YAAY,eAAe"}
|
|
@@ -58,7 +58,15 @@ interface FlatToken {
|
|
|
58
58
|
description?: string;
|
|
59
59
|
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
60
60
|
theme?: string;
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* True when an ancestor group is marked `palette: true` (or `$palette` /
|
|
63
|
+
* `$type: "palette"`).
|
|
64
|
+
*/
|
|
65
|
+
palette?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* True when an ancestor group is marked `primitive: true` (or `$primitive` /
|
|
68
|
+
* `$type: "primitive"`).
|
|
69
|
+
*/
|
|
62
70
|
primitive?: boolean;
|
|
63
71
|
}
|
|
64
72
|
/**
|
|
@@ -96,4 +104,4 @@ interface DesignMdDocument {
|
|
|
96
104
|
}
|
|
97
105
|
//#endregion
|
|
98
106
|
export { FlatToken as i, DesignMdExtractPluginOptions as n, DesignMdGeneratePluginOptions as r, DesignMdDocument as t };
|
|
99
|
-
//# sourceMappingURL=types-
|
|
107
|
+
//# sourceMappingURL=types-txdk4MJU.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-txdk4MJU.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/design-md",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
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": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"typescript": "^6.0.3"
|
|
94
94
|
},
|
|
95
95
|
"publishConfig": { "access": "public" },
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "e360b927faf08cb025ae429055c52ce504d3596b"
|
|
97
97
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-Cc5TpO46.d.cts","names":[],"sources":["../src/install.ts","../src/generate.ts"],"mappings":";;;;;;;;;iBAuBgB,gBAAgB;EAC9B;EACA;;;;;;;;;;iBC8Dc,mBAAmB,MAAM,cAAc;;;;;;;;;iBA+HvC,gBAAgB,MAAM,SAAS;;;;;;;iBA0R/B,eACd,UAAU,kBACV,UAAS;;;;;;;iBAaK,iBACd,MAAM,QACN,UAAS,gCACR,wBAAwB,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-DXmXS53P.d.mts","names":[],"sources":["../src/install.ts","../src/generate.ts"],"mappings":""}
|
|
@@ -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,t){return(0,r.flattenTokens)(e,{includeTypes:t})}function s(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 c(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 l(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var u=e.t({default:()=>F,extractDesignMd:()=>D,generateDesignMd:()=>P,renderDesignMd:()=>N,renderInstallMd:()=>a,selectPrimaryTheme:()=>b});const d=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),f={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},p=[`color`,`colors`,`palette`],m=[`typography`,`type`,`text`,`font`,`fonts`],h=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,g=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,_=/^components?$/i,v=/^\{([^}]+)\}$/,y=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function b(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 x(e){if(typeof e==`string`)return v.exec(e.trim())?.[1]}function S(e,t){let n=e;for(let e=0;e<8;e++){let e=x(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function C(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function w(e){let t=C(e);return d.has(t)?t:f[t.toLowerCase()]}function T(e,t){let i={};if(!(0,n.isObject)(e))return i;for(let n of y){let a=e[n];if(a==null)continue;let o=x(a),s=o?t.get(o):void 0,c=s?S(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 E(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 D(e){let t=b(o(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:{}},c=new Map,l=[];for(let e of t.filter(e=>!e.primitive)){let t=e.path.split(`.`);if(t[0]&&_.test(t[0])){l.push(e);continue}if(e.type===`color`&&!e.primitive){let t=s(e.path,p),r=S(e,n);r.primitive||(a.colors[t]=r.cssValue,e.description&&(a.colorDescriptions[t]=e.description),c.set(e.path,`colors.${t}`));continue}if(e.type===`typography`){let t=s(e.path,m);a.typography[t]=T(e.value,n),c.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=s(e.path,m);a.typography[t]??={},a.typography[t].fontFamily=e.cssValue,c.set(e.path,`typography.${t}`);continue}let r=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(r&&h.test(e.path)){let r=t.at(-1);a.rounded[r]=S(e,n).cssValue,c.set(e.path,`rounded.${r}`);continue}if(r&&g.test(e.path)){let r=t.at(-1);a.spacing[r]=S(e,n).cssValue,c.set(e.path,`spacing.${r}`)}}for(let e of l){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let r=w(t.at(-1));if(!r)continue;let i=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),o=x(e.value),s=o?c.get(o):void 0,l=s?`{${s}}`:S(e,n).cssValue;a.components[i]??={},a.components[i][r]=l}return a}function O(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}: ${c(r)}`);continue}n.push(` ${e}: ${c(t)}`)}}}function k(e){let t=[`---`];return e.version?t.push(`version: ${c(e.version)}`):t.push(`version: alpha`),t.push(`name: ${c(e.name)}`),e.description&&t.push(`description: ${c(e.description)}`),O(`colors`,e.colors,t),O(`typography`,e.typography,t),O(`rounded`,e.rounded,t),O(`spacing`,e.spacing,t),O(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
-
`)}\n`}function A(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
-
`)}\n`}function j(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 M(e,t={}){let n=[A(`Overview`,t.overview??j(e))],r=Object.entries(e.colors);r.length>0&&n.push(A(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${l(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
-
`)));let i=Object.entries(e.typography);i.length>0&&n.push(A(`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(A(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
-
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(A(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
-
`)));let s=Object.entries(e.components);return s.length>0&&n.push(A(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
-
`))),n.join(`
|
|
28
|
-
`)}function N(e,t={}){return`${k(e)}\n${M(e,t)}`}function P(e,t={}){let n=E(D(e),t),r=t.outputPath??`DESIGN.md`,o=N(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 F=(0,t.definePlugin)(e=>({name:`design-md:generate`,themeGeneration:`combined`,generate:async t=>P(t,e??{})}));Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}});
|
|
@@ -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,resolveSchemaIdentity as a}from"@razorwind/core/utils";import{dirname as o,join as s}from"node:path";function c(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 l(e,t){return r(e,{includeTypes:t})}function u(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 d(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 f(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var p=e({default:()=>R,extractDesignMd:()=>A,generateDesignMd:()=>L,renderDesignMd:()=>I,renderInstallMd:()=>c,selectPrimaryTheme:()=>C});const m=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),h={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},g=[`color`,`colors`,`palette`],_=[`typography`,`type`,`text`,`font`,`fonts`],v=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,y=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,b=/^components?$/i,x=/^\{([^}]+)\}$/,S=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function C(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 w(e){if(typeof e==`string`)return x.exec(e.trim())?.[1]}function T(e,t){let n=e;for(let e=0;e<8;e++){let e=w(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function E(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function D(e){let t=E(e);return m.has(t)?t:h[t.toLowerCase()]}function O(e,t){let r={};if(!n(e))return r;for(let n of S){let a=e[n];if(a==null)continue;let o=w(a),s=o?t.get(o):void 0,c=s?T(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 k(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 A(e){let t=C(l(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r=a(e),i={...r.title||r.name?{name:r.title??r.name}:{},...r.description?{description:r.description}:{},colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},o=new Map,s=[];for(let e of t.filter(e=>!e.primitive)){let t=e.path.split(`.`);if(t[0]&&b.test(t[0])){s.push(e);continue}if(e.type===`color`&&!e.primitive){let t=u(e.path,g),r=T(e,n);r.primitive||(i.colors[t]=r.cssValue,e.description&&(i.colorDescriptions[t]=e.description),o.set(e.path,`colors.${t}`));continue}if(e.type===`typography`){let t=u(e.path,_);i.typography[t]=O(e.value,n),o.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=u(e.path,_);i.typography[t]??={},i.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&&v.test(e.path)){let r=t.at(-1);i.rounded[r]=T(e,n).cssValue,o.set(e.path,`rounded.${r}`);continue}if(r&&y.test(e.path)){let r=t.at(-1);i.spacing[r]=T(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=D(t.at(-1));if(!r)continue;let a=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=w(e.value),c=s?o.get(s):void 0,l=c?`{${c}}`:T(e,n).cssValue;i.components[a]??={},i.components[a][r]=l}return i}function j(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}: ${d(r)}`);continue}n.push(` ${e}: ${d(t)}`)}}}function M(e){let t=[`---`];return e.version?t.push(`version: ${d(e.version)}`):t.push(`version: alpha`),t.push(`name: ${d(e.name)}`),e.description&&t.push(`description: ${d(e.description)}`),j(`colors`,e.colors,t),j(`typography`,e.typography,t),j(`rounded`,e.rounded,t),j(`spacing`,e.spacing,t),j(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
-
`)}\n`}function N(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
-
`)}\n`}function P(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 F(e,t={}){let n=[N(`Overview`,t.overview??P(e))],r=Object.entries(e.colors);r.length>0&&n.push(N(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${f(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
-
`)));let i=Object.entries(e.typography);i.length>0&&n.push(N(`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(N(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
-
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(N(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
-
`)));let s=Object.entries(e.components);return s.length>0&&n.push(N(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
-
`))),n.join(`
|
|
28
|
-
`)}function I(e,t={}){return`${M(e)}\n${F(e,t)}`}function L(e,t={}){let n=k(A(e),t),r=t.outputPath??`DESIGN.md`,i=I(n,t),a=t.installGuide??c({outputPath:r,name:t.name??n.name}),l=s(o(r),`INSTALL.md`);return{[r]:{path:r,language:`markdown`,chunks:[{content:i,meta:{name:`razorwind-design-md`}}]},[l]:{path:l,language:`markdown`,chunks:[{content:a,meta:{name:`razorwind-design-md`}}]}}}var R=t(e=>({name:`design-md:generate`,themeGeneration:`combined`,generate:async t=>L(t,e??{})}));export{I as a,p as i,L as n,C as o,R as r,c as s,A as t};
|
|
29
|
-
//# sourceMappingURL=generate-XnAk-wWP.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-XnAk-wWP.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-Dytdpn6d.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-I1sC5VJa.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;UAoBiB;;;;;;EAMf;;UAGe;;;;;;EAMf;;;;;;EAOA;;;;EAKA;;;;;;EAOA;;;;;EAMA;;;;;EAMA;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;UAOe;EACf;EACA;EACA;EACA;EACA;;;;;;;KAQU,iBAAiB;;;;;UAMZ;EACf;EACA;EACA;EACA,QAAQ;;EAER,mBAAmB;EACnB,YAAY,eAAe;EAC3B,SAAS;EACT,SAAS;EACT,YAAY,eAAe"}
|