@razorwind/design-md 0.0.25 → 0.0.27
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-4IceWWHl.d.mts +64 -0
- package/dist/generate-4IceWWHl.d.mts.map +1 -0
- package/dist/generate-C4R8IMTf.mjs +29 -0
- package/dist/generate-C4R8IMTf.mjs.map +1 -0
- package/dist/generate-CsdsF9HN.cjs +28 -0
- package/dist/generate-D-aW7d_O.d.cts +64 -0
- package/dist/generate-D-aW7d_O.d.cts.map +1 -0
- package/dist/generate.cjs +1 -1
- package/dist/generate.d.cts +2 -54
- package/dist/generate.d.mts +2 -54
- 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-9TCb0Dqf.d.mts → types-Bh1zZG6z.d.mts} +6 -1
- package/dist/types-Bh1zZG6z.d.mts.map +1 -0
- package/dist/{types-BNWqSKB5.d.cts → types-CYDjNc8P.d.cts} +6 -1
- package/dist/types-CYDjNc8P.d.cts.map +1 -0
- package/package.json +5 -5
- package/dist/generate-Cf-38Ogn.cjs +0 -9
- package/dist/generate-D6jEbSHL.mjs +0 -10
- package/dist/generate-D6jEbSHL.mjs.map +0 -1
- package/dist/generate.d.cts.map +0 -1
- package/dist/generate.d.mts.map +0 -1
- package/dist/types-9TCb0Dqf.d.mts.map +0 -1
- package/dist/types-BNWqSKB5.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-CYDjNc8P.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-Bh1zZG6z.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 };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { i as FlatToken, r as DesignMdGeneratePluginOptions, t as DesignMdDocument } from "./types-Bh1zZG6z.mjs";
|
|
2
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
|
+
import { Schema } from "@razorwind/core/schema";
|
|
4
|
+
//#region src/install.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build DESIGN.md INSTALL.md for generated design spec file.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/google-labs-code/design.md
|
|
9
|
+
*/
|
|
10
|
+
declare function renderInstallMd(options: {
|
|
11
|
+
outputPath: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
}): string;
|
|
14
|
+
declare namespace generate_d_exports {
|
|
15
|
+
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, renderInstallMd, selectPrimaryTheme };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Select the token set used for the front matter when tokens are split into
|
|
19
|
+
* multiple themes: the un-themed set first, then `light`, then `default`,
|
|
20
|
+
* then whichever theme appears first.
|
|
21
|
+
*/
|
|
22
|
+
declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
23
|
+
/**
|
|
24
|
+
* Extract a DESIGN.md document from the Razorwind schema.
|
|
25
|
+
*
|
|
26
|
+
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
27
|
+
* derived from the DTCG token tree. DTCG aliases are re-emitted as DESIGN.md
|
|
28
|
+
* `{section.token}` references when the target token is part of the output,
|
|
29
|
+
* or resolved to their terminal CSS value otherwise.
|
|
30
|
+
*/
|
|
31
|
+
declare function extractDesignMd(spec: Schema): DesignMdDocument;
|
|
32
|
+
/**
|
|
33
|
+
* Render a complete DESIGN.md file — YAML front matter followed by the
|
|
34
|
+
* markdown body.
|
|
35
|
+
*
|
|
36
|
+
* @see https://github.com/google-labs-code/design.md
|
|
37
|
+
*/
|
|
38
|
+
declare function renderDesignMd(document: DesignMdDocument, options?: DesignMdGeneratePluginOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Generate a DESIGN.md design-system specification file from a Razorwind
|
|
41
|
+
* schema.
|
|
42
|
+
*
|
|
43
|
+
* @see https://github.com/google-labs-code/design.md
|
|
44
|
+
*/
|
|
45
|
+
declare function generateDesignMd(spec: Schema, options?: DesignMdGeneratePluginOptions): GeneratorFunctionResult<Schema, DesignMdGeneratePluginOptions>;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a DESIGN.md design-system specification file from a Razorwind schema.
|
|
48
|
+
*
|
|
49
|
+
* @see https://github.com/google-labs-code/design.md
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { defineConfig } from "@razorwind/core";
|
|
54
|
+
* import designMd from "@razorwind/design-md/generate";
|
|
55
|
+
*
|
|
56
|
+
* export default defineConfig({
|
|
57
|
+
* plugins: [designMd()]
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const _default: (options?: DesignMdGeneratePluginOptions | undefined) => import("@razorwind/core").Plugin;
|
|
62
|
+
//#endregion
|
|
63
|
+
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-4IceWWHl.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-4IceWWHl.d.mts","names":[],"sources":["../src/install.ts","../src/generate.ts"],"mappings":""}
|
|
@@ -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{dirname as r,join as i}from"node:path";import{flattenTokens as a,formatTokenValue as o}from"@razorwind/core/utils";function s(e,t){return a(e,{includeTypes:t})}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){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 u(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 d(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var f=e({default:()=>L,extractDesignMd:()=>k,generateDesignMd:()=>I,renderDesignMd:()=>F,renderInstallMd:()=>c,selectPrimaryTheme:()=>S});const p=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),m={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},h=[`color`,`colors`,`palette`],g=[`typography`,`type`,`text`,`font`,`fonts`],_=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,v=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,y=/^components?$/i,b=/^\{([^}]+)\}$/,x=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function S(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 C(e){if(typeof e==`string`)return b.exec(e.trim())?.[1]}function w(e,t){let n=e;for(let e=0;e<8;e++){let e=C(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function T(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function E(e){let t=T(e);return p.has(t)?t:m[t.toLowerCase()]}function D(e,t){let r={};if(!n(e))return r;for(let n of x){let i=e[n];if(i==null)continue;let a=C(i),s=a?t.get(a):void 0,c=s?w(s,t).cssValue:void 0;if(typeof i==`number`){r[n]=n===`fontWeight`||n===`lineHeight`?i:o(i);continue}r[n]=c??o(i)}return r}function O(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 k(e){let t=S(s(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r={colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},i=new Map,a=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&y.test(t[0])){a.push(e);continue}if(e.type===`color`){let t=l(e.path,h),a=w(e,n);r.colors[t]=a.cssValue,e.description&&(r.colorDescriptions[t]=e.description),i.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=l(e.path,g);r.typography[t]=D(e.value,n),i.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=l(e.path,g);r.typography[t]??={},r.typography[t].fontFamily=e.cssValue,i.set(e.path,`typography.${t}`);continue}let o=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(o&&_.test(e.path)){let a=t.at(-1);r.rounded[a]=w(e,n).cssValue,i.set(e.path,`rounded.${a}`);continue}if(o&&v.test(e.path)){let a=t.at(-1);r.spacing[a]=w(e,n).cssValue,i.set(e.path,`spacing.${a}`)}}for(let e of a){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let a=E(t.at(-1));if(!a)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=C(e.value),c=s?i.get(s):void 0,l=c?`{${c}}`:w(e,n).cssValue;r.components[o]??={},r.components[o][a]=l}return r}function A(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}: ${u(r)}`);continue}n.push(` ${e}: ${u(t)}`)}}}function j(e){let t=[`---`];return e.version&&t.push(`version: ${u(e.version)}`),t.push(`name: ${u(e.name)}`),e.description&&t.push(`description: ${u(e.description)}`),A(`colors`,e.colors,t),A(`typography`,e.typography,t),A(`rounded`,e.rounded,t),A(`spacing`,e.spacing,t),A(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
21
|
+
`)}\n`}function M(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
22
|
+
`)}\n`}function N(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 P(e,t={}){let n=[M(`Overview`,t.overview??N(e))],r=Object.entries(e.colors);r.length>0&&n.push(M(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${d(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
23
|
+
`)));let i=Object.entries(e.typography);i.length>0&&n.push(M(`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(M(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
25
|
+
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(M(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
26
|
+
`)));let s=Object.entries(e.components);return s.length>0&&n.push(M(`Components`,s.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
27
|
+
`))),n.join(`
|
|
28
|
+
`)}function F(e,t={}){return`${j(e)}\n${P(e,t)}`}function I(e,t={}){let n=O(k(e),t),a=t.outputPath??`DESIGN.md`,o=F(n,t),s=t.installGuide??c({outputPath:a,name:t.name??n.name}),l=i(r(a),`INSTALL.md`);return{[a]:{path:a,language:`markdown`,chunks:[{content:o,meta:{name:`razorwind-design-md`}}]},[l]:{path:l,language:`markdown`,chunks:[{content:s,meta:{name:`razorwind-design-md`}}]}}}var L=t(e=>({name:`design-md:generate`,generate:async t=>I(t,e??{})}));export{F as a,f as i,I as n,S as o,L as r,c as s,k as t};
|
|
29
|
+
//# sourceMappingURL=generate-C4R8IMTf.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-C4R8IMTf.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("node:path"),i=require("@razorwind/core/utils");function a(e,t){return(0,i.flattenTokens)(e,{includeTypes:t})}function o(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 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:()=>o,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 r={};if(!(0,n.isObject)(e))return r;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`){r[n]=n===`fontWeight`||n===`lineHeight`?a:(0,i.formatTokenValue)(a);continue}r[n]=c??(0,i.formatTokenValue)(a)}return r}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(a(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r={colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},i=new Map,o=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&_.test(t[0])){o.push(e);continue}if(e.type===`color`){let t=s(e.path,p),a=S(e,n);r.colors[t]=a.cssValue,e.description&&(r.colorDescriptions[t]=e.description),i.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=s(e.path,m);r.typography[t]=T(e.value,n),i.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=s(e.path,m);r.typography[t]??={},r.typography[t].fontFamily=e.cssValue,i.set(e.path,`typography.${t}`);continue}let a=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(a&&h.test(e.path)){let a=t.at(-1);r.rounded[a]=S(e,n).cssValue,i.set(e.path,`rounded.${a}`);continue}if(a&&g.test(e.path)){let a=t.at(-1);r.spacing[a]=S(e,n).cssValue,i.set(e.path,`spacing.${a}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let a=w(t.at(-1));if(!a)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=x(e.value),c=s?i.get(s):void 0,l=c?`{${c}}`:S(e,n).cssValue;r.components[o]??={},r.components[o][a]=l}return r}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(`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),i=t.outputPath??`DESIGN.md`,a=N(n,t),s=t.installGuide??o({outputPath:i,name:t.name??n.name}),c=(0,r.join)((0,r.dirname)(i),`INSTALL.md`);return{[i]:{path:i,language:`markdown`,chunks:[{content:a,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`,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 o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { a as __exportAll, i as FlatToken, r as DesignMdGeneratePluginOptions, t as DesignMdDocument } from "./types-CYDjNc8P.cjs";
|
|
2
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
|
+
import { Schema } from "@razorwind/core/schema";
|
|
4
|
+
//#region src/install.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build DESIGN.md INSTALL.md for generated design spec file.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/google-labs-code/design.md
|
|
9
|
+
*/
|
|
10
|
+
declare function renderInstallMd(options: {
|
|
11
|
+
outputPath: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
}): string;
|
|
14
|
+
declare namespace generate_d_exports {
|
|
15
|
+
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, renderInstallMd, selectPrimaryTheme };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Select the token set used for the front matter when tokens are split into
|
|
19
|
+
* multiple themes: the un-themed set first, then `light`, then `default`,
|
|
20
|
+
* then whichever theme appears first.
|
|
21
|
+
*/
|
|
22
|
+
declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
23
|
+
/**
|
|
24
|
+
* Extract a DESIGN.md document from the Razorwind schema.
|
|
25
|
+
*
|
|
26
|
+
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
27
|
+
* derived from the DTCG token tree. DTCG aliases are re-emitted as DESIGN.md
|
|
28
|
+
* `{section.token}` references when the target token is part of the output,
|
|
29
|
+
* or resolved to their terminal CSS value otherwise.
|
|
30
|
+
*/
|
|
31
|
+
declare function extractDesignMd(spec: Schema): DesignMdDocument;
|
|
32
|
+
/**
|
|
33
|
+
* Render a complete DESIGN.md file — YAML front matter followed by the
|
|
34
|
+
* markdown body.
|
|
35
|
+
*
|
|
36
|
+
* @see https://github.com/google-labs-code/design.md
|
|
37
|
+
*/
|
|
38
|
+
declare function renderDesignMd(document: DesignMdDocument, options?: DesignMdGeneratePluginOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Generate a DESIGN.md design-system specification file from a Razorwind
|
|
41
|
+
* schema.
|
|
42
|
+
*
|
|
43
|
+
* @see https://github.com/google-labs-code/design.md
|
|
44
|
+
*/
|
|
45
|
+
declare function generateDesignMd(spec: Schema, options?: DesignMdGeneratePluginOptions): GeneratorFunctionResult<Schema, DesignMdGeneratePluginOptions>;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a DESIGN.md design-system specification file from a Razorwind schema.
|
|
48
|
+
*
|
|
49
|
+
* @see https://github.com/google-labs-code/design.md
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { defineConfig } from "@razorwind/core";
|
|
54
|
+
* import designMd from "@razorwind/design-md/generate";
|
|
55
|
+
*
|
|
56
|
+
* export default defineConfig({
|
|
57
|
+
* plugins: [designMd()]
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const _default: (options?: DesignMdGeneratePluginOptions | undefined) => import("@razorwind/core").Plugin;
|
|
62
|
+
//#endregion
|
|
63
|
+
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-D-aW7d_O.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-D-aW7d_O.d.cts","names":[],"sources":["../src/install.ts","../src/generate.ts"],"mappings":";;;;;;;;;iBAuBgB,gBAAgB;EAC9B;EACA;;;;;;;;;;iBC6Dc,mBAAmB,MAAM,cAAc;;;;;;;;;iBA+HvC,gBAAgB,MAAM,SAAS;;;;;;;iBAkR/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-CsdsF9HN.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,54 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
3
|
-
import { Schema } from "@razorwind/core/schema";
|
|
4
|
-
declare namespace generate_d_exports {
|
|
5
|
-
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, selectPrimaryTheme };
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Select the token set used for the front matter when tokens are split into
|
|
9
|
-
* multiple themes: the un-themed set first, then `light`, then `default`,
|
|
10
|
-
* then whichever theme appears first.
|
|
11
|
-
*/
|
|
12
|
-
declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
13
|
-
/**
|
|
14
|
-
* Extract a DESIGN.md document from the Razorwind schema.
|
|
15
|
-
*
|
|
16
|
-
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
17
|
-
* derived from the DTCG token tree. DTCG aliases are re-emitted as DESIGN.md
|
|
18
|
-
* `{section.token}` references when the target token is part of the output,
|
|
19
|
-
* or resolved to their terminal CSS value otherwise.
|
|
20
|
-
*/
|
|
21
|
-
declare function extractDesignMd(spec: Schema): DesignMdDocument;
|
|
22
|
-
/**
|
|
23
|
-
* Render a complete DESIGN.md file — YAML front matter followed by the
|
|
24
|
-
* markdown body.
|
|
25
|
-
*
|
|
26
|
-
* @see https://github.com/google-labs-code/design.md
|
|
27
|
-
*/
|
|
28
|
-
declare function renderDesignMd(document: DesignMdDocument, options?: DesignMdGeneratePluginOptions): string;
|
|
29
|
-
/**
|
|
30
|
-
* Generate a DESIGN.md design-system specification file from a Razorwind
|
|
31
|
-
* schema.
|
|
32
|
-
*
|
|
33
|
-
* @see https://github.com/google-labs-code/design.md
|
|
34
|
-
*/
|
|
35
|
-
declare function generateDesignMd(spec: Schema, options?: DesignMdGeneratePluginOptions): GeneratorFunctionResult<Schema, DesignMdGeneratePluginOptions>;
|
|
36
|
-
/**
|
|
37
|
-
* Generate a DESIGN.md design-system specification file from a Razorwind schema.
|
|
38
|
-
*
|
|
39
|
-
* @see https://github.com/google-labs-code/design.md
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { defineConfig } from "@razorwind/core";
|
|
44
|
-
* import designMd from "@razorwind/design-md/generate";
|
|
45
|
-
*
|
|
46
|
-
* export default defineConfig({
|
|
47
|
-
* plugins: [designMd()]
|
|
48
|
-
* });
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
declare const _default: (options?: DesignMdGeneratePluginOptions | undefined) => import("@razorwind/core").Plugin;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, selectPrimaryTheme, generate_d_exports as t };
|
|
54
|
-
//# sourceMappingURL=generate.d.cts.map
|
|
1
|
+
import { a as renderDesignMd, n as extractDesignMd, o as selectPrimaryTheme, r as generateDesignMd, s as renderInstallMd, t as _default } from "./generate-D-aW7d_O.cjs";
|
|
2
|
+
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, renderInstallMd, selectPrimaryTheme };
|
package/dist/generate.d.mts
CHANGED
|
@@ -1,54 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Schema } from "@razorwind/core/schema";
|
|
4
|
-
declare namespace generate_d_exports {
|
|
5
|
-
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, selectPrimaryTheme };
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Select the token set used for the front matter when tokens are split into
|
|
9
|
-
* multiple themes: the un-themed set first, then `light`, then `default`,
|
|
10
|
-
* then whichever theme appears first.
|
|
11
|
-
*/
|
|
12
|
-
declare function selectPrimaryTheme(flat: FlatToken[]): FlatToken[];
|
|
13
|
-
/**
|
|
14
|
-
* Extract a DESIGN.md document from the Razorwind schema.
|
|
15
|
-
*
|
|
16
|
-
* Colors, typography, rounded / spacing scales, and component tokens are
|
|
17
|
-
* derived from the DTCG token tree. DTCG aliases are re-emitted as DESIGN.md
|
|
18
|
-
* `{section.token}` references when the target token is part of the output,
|
|
19
|
-
* or resolved to their terminal CSS value otherwise.
|
|
20
|
-
*/
|
|
21
|
-
declare function extractDesignMd(spec: Schema): DesignMdDocument;
|
|
22
|
-
/**
|
|
23
|
-
* Render a complete DESIGN.md file — YAML front matter followed by the
|
|
24
|
-
* markdown body.
|
|
25
|
-
*
|
|
26
|
-
* @see https://github.com/google-labs-code/design.md
|
|
27
|
-
*/
|
|
28
|
-
declare function renderDesignMd(document: DesignMdDocument, options?: DesignMdGeneratePluginOptions): string;
|
|
29
|
-
/**
|
|
30
|
-
* Generate a DESIGN.md design-system specification file from a Razorwind
|
|
31
|
-
* schema.
|
|
32
|
-
*
|
|
33
|
-
* @see https://github.com/google-labs-code/design.md
|
|
34
|
-
*/
|
|
35
|
-
declare function generateDesignMd(spec: Schema, options?: DesignMdGeneratePluginOptions): GeneratorFunctionResult<Schema, DesignMdGeneratePluginOptions>;
|
|
36
|
-
/**
|
|
37
|
-
* Generate a DESIGN.md design-system specification file from a Razorwind schema.
|
|
38
|
-
*
|
|
39
|
-
* @see https://github.com/google-labs-code/design.md
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { defineConfig } from "@razorwind/core";
|
|
44
|
-
* import designMd from "@razorwind/design-md/generate";
|
|
45
|
-
*
|
|
46
|
-
* export default defineConfig({
|
|
47
|
-
* plugins: [designMd()]
|
|
48
|
-
* });
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
declare const _default: (options?: DesignMdGeneratePluginOptions | undefined) => import("@razorwind/core").Plugin;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { _default as default, extractDesignMd, generateDesignMd, renderDesignMd, selectPrimaryTheme, generate_d_exports as t };
|
|
54
|
-
//# sourceMappingURL=generate.d.mts.map
|
|
1
|
+
import { a as renderDesignMd, n as extractDesignMd, o as selectPrimaryTheme, r as generateDesignMd, s as renderInstallMd, t as _default } from "./generate-4IceWWHl.mjs";
|
|
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,t as
|
|
1
|
+
import{a as e,n as t,o as n,r,s as i,t as a}from"./generate-C4R8IMTf.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-CsdsF9HN.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-C4R8IMTf.mjs";export{e as extract,t as generate};
|
|
@@ -36,6 +36,11 @@ interface DesignMdGeneratePluginOptions {
|
|
|
36
36
|
* generated from the extracted tokens.
|
|
37
37
|
*/
|
|
38
38
|
overview?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Override body for generated `INSTALL.md`. When omitted, DESIGN.md wiring
|
|
41
|
+
* steps are generated for the output file.
|
|
42
|
+
*/
|
|
43
|
+
installGuide?: string;
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
46
|
* A flattened design token ready for DESIGN.md extraction.
|
|
@@ -89,4 +94,4 @@ interface DesignMdDocument {
|
|
|
89
94
|
}
|
|
90
95
|
//#endregion
|
|
91
96
|
export { FlatToken as i, DesignMdExtractPluginOptions as n, DesignMdGeneratePluginOptions as r, DesignMdDocument as t };
|
|
92
|
-
//# sourceMappingURL=types-
|
|
97
|
+
//# sourceMappingURL=types-Bh1zZG6z.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Bh1zZG6z.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
|
@@ -37,6 +37,11 @@ interface DesignMdGeneratePluginOptions {
|
|
|
37
37
|
* generated from the extracted tokens.
|
|
38
38
|
*/
|
|
39
39
|
overview?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Override body for generated `INSTALL.md`. When omitted, DESIGN.md wiring
|
|
42
|
+
* steps are generated for the output file.
|
|
43
|
+
*/
|
|
44
|
+
installGuide?: string;
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* A flattened design token ready for DESIGN.md extraction.
|
|
@@ -90,4 +95,4 @@ interface DesignMdDocument {
|
|
|
90
95
|
}
|
|
91
96
|
//#endregion
|
|
92
97
|
export { __exportAll as a, FlatToken as i, DesignMdExtractPluginOptions as n, DesignMdGeneratePluginOptions as r, DesignMdDocument as t };
|
|
93
|
-
//# sourceMappingURL=types-
|
|
98
|
+
//# sourceMappingURL=types-CYDjNc8P.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CYDjNc8P.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;;;;;;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/design-md",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
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,9 +78,9 @@
|
|
|
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.81",
|
|
82
82
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
83
|
-
"@razorwind/core": "0.0.
|
|
83
|
+
"@razorwind/core": "0.0.31",
|
|
84
84
|
"@stryke/fs": "^0.33.103",
|
|
85
85
|
"@stryke/path": "^0.29.29",
|
|
86
86
|
"@stryke/type-checks": "^0.6.35",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"yaml": "^2.9.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@powerlines/plugin-tsdown": "^0.1.
|
|
91
|
+
"@powerlines/plugin-tsdown": "^0.1.591",
|
|
92
92
|
"@types/node": "^25.9.5",
|
|
93
93
|
"typescript": "^6.0.3"
|
|
94
94
|
},
|
|
95
95
|
"publishConfig": { "access": "public" },
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "e5f1a6ed40a0cd566735910851df15a8a1647116"
|
|
97
97
|
}
|
|
@@ -1,9 +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");function i(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 a(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 o(e){return e.split(/[-_.]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}const s=/^(?:light|dark|dim|high-contrast|hc|default|base|theme)(?:[._-].+)?$/i;function c(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function l(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function u(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function d(e){if(`$value`in e)return e.$value;if(`value`in e)return e.value;if(typeof e.$ref==`string`)return e.$ref;if(typeof e.ref==`string`)return e.ref}function f(e,t,n,i,a){if(!(0,r.isObject)(e))return;let o=u(e,n);if(c(e)){let n=d(e);a.push({path:t.join(`.`),type:o,value:n,cssValue:(0,r.formatTokenValue)(n,o),description:l(e),theme:i});return}for(let[n,r]of Object.entries(e))n.startsWith(`$`)||f(r,[...t,n],o,i,a)}function p(e){if(!(0,r.isObject)(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));if(t.length>0&&t.every(e=>s.test(e))){let n=e;return t.map(e=>({id:e,tokens:n[e]}))}return[{id:`default`,tokens:e}]}function m(e,t){let n=t?new Set(t):void 0,r=[];for(let t of p(e)){let e=t.id==="default"?void 0:t.id;f(t.tokens,[],void 0,e,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}var h=e.t({default:()=>B,extractDesignMd:()=>M,generateDesignMd:()=>z,renderDesignMd:()=>R,selectPrimaryTheme:()=>T});const g=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),_={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},v=[`color`,`colors`,`palette`],y=[`typography`,`type`,`text`,`font`,`fonts`],b=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,x=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,S=/^components?$/i,C=/^\{([^}]+)\}$/,w=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function T(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 E(e){if(typeof e==`string`)return C.exec(e.trim())?.[1]}function D(e,t){let n=e;for(let e=0;e<8;e++){let e=E(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function O(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function k(e){let t=O(e);return g.has(t)?t:_[t.toLowerCase()]}function A(e,t){let i={};if(!(0,n.isObject)(e))return i;for(let n of w){let a=e[n];if(a==null)continue;let o=E(a),s=o?t.get(o):void 0,c=s?D(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 j(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 M(e){let t=T(m(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r={colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},a=new Map,o=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&S.test(t[0])){o.push(e);continue}if(e.type===`color`){let t=i(e.path,v),o=D(e,n);r.colors[t]=o.cssValue,e.description&&(r.colorDescriptions[t]=e.description),a.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=i(e.path,y);r.typography[t]=A(e.value,n),a.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=i(e.path,y);r.typography[t]??={},r.typography[t].fontFamily=e.cssValue,a.set(e.path,`typography.${t}`);continue}let s=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(s&&b.test(e.path)){let i=t.at(-1);r.rounded[i]=D(e,n).cssValue,a.set(e.path,`rounded.${i}`);continue}if(s&&x.test(e.path)){let i=t.at(-1);r.spacing[i]=D(e,n).cssValue,a.set(e.path,`spacing.${i}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let i=k(t.at(-1));if(!i)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=E(e.value),c=s?a.get(s):void 0,l=c?`{${c}}`:D(e,n).cssValue;r.components[o]??={},r.components[o][i]=l}return r}function N(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}: ${a(r)}`);continue}n.push(` ${e}: ${a(t)}`)}}}function P(e){let t=[`---`];return e.version&&t.push(`version: ${a(e.version)}`),t.push(`name: ${a(e.name)}`),e.description&&t.push(`description: ${a(e.description)}`),N(`colors`,e.colors,t),N(`typography`,e.typography,t),N(`rounded`,e.rounded,t),N(`spacing`,e.spacing,t),N(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
2
|
-
`)}\n`}function F(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
3
|
-
`)}\n`}function I(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 L(e,t={}){let n=[F(`Overview`,t.overview??I(e))],r=Object.entries(e.colors);r.length>0&&n.push(F(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${o(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
4
|
-
`)));let i=Object.entries(e.typography);i.length>0&&n.push(F(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
5
|
-
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(F(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
6
|
-
`)));let s=Object.entries(e.rounded);s.length>0&&n.push(F(`Shapes`,`Corner radius scale:`,``,s.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
7
|
-
`)));let c=Object.entries(e.components);return c.length>0&&n.push(F(`Components`,c.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
8
|
-
`))),n.join(`
|
|
9
|
-
`)}function R(e,t={}){return`${P(e)}\n${L(e,t)}`}function z(e,t={}){let n=j(M(e),t);return{[t.outputPath??`DESIGN.md`]:{path:t.outputPath??`DESIGN.md`,language:`markdown`,chunks:[{content:R(n,t),meta:{name:`razorwind-design-md`}}]}}}var B=(0,t.definePlugin)(e=>({name:`design-md:generate`,generate:async t=>z(t,e??{})}));Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return M}});
|
|
@@ -1,10 +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{formatTokenValue as r,isObject as i}from"@razorwind/core/utils";function a(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 o(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(` `)}const c=/^(?:light|dark|dim|high-contrast|hc|default|base|theme)(?:[._-].+)?$/i;function l(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function u(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function d(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function f(e){if(`$value`in e)return e.$value;if(`value`in e)return e.value;if(typeof e.$ref==`string`)return e.$ref;if(typeof e.ref==`string`)return e.ref}function p(e,t,n,a,o){if(!i(e))return;let s=d(e,n);if(l(e)){let n=f(e);o.push({path:t.join(`.`),type:s,value:n,cssValue:r(n,s),description:u(e),theme:a});return}for(let[n,r]of Object.entries(e))n.startsWith(`$`)||p(r,[...t,n],s,a,o)}function m(e){if(!i(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));if(t.length>0&&t.every(e=>c.test(e))){let n=e;return t.map(e=>({id:e,tokens:n[e]}))}return[{id:`default`,tokens:e}]}function h(e,t){let n=t?new Set(t):void 0,r=[];for(let t of m(e)){let e=t.id==="default"?void 0:t.id;p(t.tokens,[],void 0,e,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}var g=e({default:()=>V,extractDesignMd:()=>N,generateDesignMd:()=>B,renderDesignMd:()=>z,selectPrimaryTheme:()=>E});const _=new Set([`backgroundColor`,`textColor`,`typography`,`rounded`,`padding`,`size`,`height`,`width`]),v={background:`backgroundColor`,backgroundcolor:`backgroundColor`,bg:`backgroundColor`,fill:`backgroundColor`,color:`textColor`,foreground:`textColor`,text:`textColor`,textcolor:`textColor`,font:`typography`,radius:`rounded`,borderradius:`rounded`,corner:`rounded`},y=[`color`,`colors`,`palette`],b=[`typography`,`type`,`text`,`font`,`fonts`],x=/(?:^|\.)(?:radius|radii|rounded|corner)(?:\.|$)/i,S=/(?:^|\.)(?:spacing|space|gap)(?:\.|$)/i,C=/^components?$/i,w=/^\{([^}]+)\}$/,T=[`fontFamily`,`fontSize`,`fontWeight`,`lineHeight`,`letterSpacing`];function E(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 D(e){if(typeof e==`string`)return w.exec(e.trim())?.[1]}function O(e,t){let n=e;for(let e=0;e<8;e++){let e=D(n.value);if(!e)return n;let r=t.get(e);if(!r)return n;n=r}return n}function k(e){return e.split(/[-_.\s]+/).filter(Boolean).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function A(e){let t=k(e);return _.has(t)?t:v[t.toLowerCase()]}function j(e,t){let i={};if(!n(e))return i;for(let n of T){let a=e[n];if(a==null)continue;let o=D(a),s=o?t.get(o):void 0,c=s?O(s,t).cssValue:void 0;if(typeof a==`number`){i[n]=n===`fontWeight`||n===`lineHeight`?a:r(a);continue}i[n]=c??r(a)}return i}function M(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 N(e){let t=E(h(e.tokens)),n=new Map(t.map(e=>[e.path,e])),r={colors:{},colorDescriptions:{},typography:{},rounded:{},spacing:{},components:{}},i=new Map,o=[];for(let e of t){let t=e.path.split(`.`);if(t[0]&&C.test(t[0])){o.push(e);continue}if(e.type===`color`){let t=a(e.path,y),o=O(e,n);r.colors[t]=o.cssValue,e.description&&(r.colorDescriptions[t]=e.description),i.set(e.path,`colors.${t}`);continue}if(e.type===`typography`){let t=a(e.path,b);r.typography[t]=j(e.value,n),i.set(e.path,`typography.${t}`);continue}if(e.type===`fontFamily`){let t=a(e.path,b);r.typography[t]??={},r.typography[t].fontFamily=e.cssValue,i.set(e.path,`typography.${t}`);continue}let s=e.type===`dimension`||e.type===`number`||typeof e.value==`number`;if(s&&x.test(e.path)){let a=t.at(-1);r.rounded[a]=O(e,n).cssValue,i.set(e.path,`rounded.${a}`);continue}if(s&&S.test(e.path)){let a=t.at(-1);r.spacing[a]=O(e,n).cssValue,i.set(e.path,`spacing.${a}`)}}for(let e of o){let t=e.path.split(`.`).slice(1);if(t.length<2)continue;let a=A(t.at(-1));if(!a)continue;let o=t.slice(0,-1).join(`-`).replaceAll(/[^\w-]+/g,`-`).toLowerCase(),s=D(e.value),c=s?i.get(s):void 0,l=c?`{${c}}`:O(e,n).cssValue;r.components[o]??={},r.components[o][a]=l}return r}function P(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}: ${o(r)}`);continue}n.push(` ${e}: ${o(t)}`)}}}function F(e){let t=[`---`];return e.version&&t.push(`version: ${o(e.version)}`),t.push(`name: ${o(e.name)}`),e.description&&t.push(`description: ${o(e.description)}`),P(`colors`,e.colors,t),P(`typography`,e.typography,t),P(`rounded`,e.rounded,t),P(`spacing`,e.spacing,t),P(`components`,e.components,t),t.push(`---`),`${t.join(`
|
|
2
|
-
`)}\n`}function I(e,...t){return`## ${e}\n\n${t.filter(Boolean).join(`
|
|
3
|
-
`)}\n`}function L(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 R(e,t={}){let n=[I(`Overview`,t.overview??L(e))],r=Object.entries(e.colors);r.length>0&&n.push(I(`Colors`,r.map(([t,n])=>{let r=e.colorDescriptions[t];return`- **${s(t)} (${n}):**${r?` ${r}`:``}`}).join(`
|
|
4
|
-
`)));let i=Object.entries(e.typography);i.length>0&&n.push(I(`Typography`,i.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}`).join(`
|
|
5
|
-
`)));let a=Object.entries(e.spacing);a.length>0&&n.push(I(`Layout`,`Spacing scale:`,``,a.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
6
|
-
`)));let o=Object.entries(e.rounded);o.length>0&&n.push(I(`Shapes`,`Corner radius scale:`,``,o.map(([e,t])=>`- **${e}:** ${t}`).join(`
|
|
7
|
-
`)));let c=Object.entries(e.components);return c.length>0&&n.push(I(`Components`,c.map(([e,t])=>`- **${e}:** ${Object.entries(t).map(([e,t])=>`${e}: \`${t}\``).join(`, `)}`).join(`
|
|
8
|
-
`))),n.join(`
|
|
9
|
-
`)}function z(e,t={}){return`${F(e)}\n${R(e,t)}`}function B(e,t={}){let n=M(N(e),t);return{[t.outputPath??`DESIGN.md`]:{path:t.outputPath??`DESIGN.md`,language:`markdown`,chunks:[{content:z(n,t),meta:{name:`razorwind-design-md`}}]}}}var V=t(e=>({name:`design-md:generate`,generate:async t=>B(t,e??{})}));export{z as a,g as i,B as n,E as o,V as r,N as t};
|
|
10
|
-
//# sourceMappingURL=generate-D6jEbSHL.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-D6jEbSHL.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/generate.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.cts","names":[],"sources":["../src/generate.ts"],"mappings":";;;;;;;;;;;iBAoFgB,mBAAmB,MAAM,cAAc;;;;;;;;;iBA+HvC,gBAAgB,MAAM,SAAS;;;;;;;iBAkR/B,eACd,UAAU,kBACV,UAAS;;;;;;;iBAWK,iBACd,MAAM,QACN,UAAS,gCACR,wBAAwB,QAAQ"}
|
package/dist/generate.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.mts","names":[],"sources":["../src/generate.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-9TCb0Dqf.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-BNWqSKB5.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;UAoBiB;;;;;;EAMf;;UAGe;;;;;;EAMf;;;;;;EAOA;;;;EAKA;;;;;;EAOA;;;;;EAMA;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;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"}
|