@razorwind/core 0.0.5 → 0.0.7
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/README.md +218 -0
- package/dist/config-DQHHeicR.d.mts +85 -0
- package/dist/config-DQHHeicR.d.mts.map +1 -0
- package/dist/config-Dj6RrLde.d.cts +85 -0
- package/dist/config-Dj6RrLde.d.cts.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +13 -2
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +13 -2
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +1 -1
- package/dist/generator-BWQOEMGt.mjs +2 -0
- package/dist/generator-BWQOEMGt.mjs.map +1 -0
- package/dist/generator-DQ1WS7hN.mjs +2 -0
- package/dist/generator-DQ1WS7hN.mjs.map +1 -0
- package/dist/generator-DjAElWpu.cjs +1 -0
- package/dist/generator-nWEM7jKK.cjs +1 -0
- package/dist/generator.cjs +1 -7
- package/dist/generator.d.cts +6 -6
- package/dist/generator.d.mts +6 -6
- package/dist/generator.mjs +1 -8
- package/dist/index--y-fo2Lr.d.mts +3 -0
- package/dist/index-COAOe8bR.d.cts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.mjs +1 -1
- package/dist/lib/tokens/index.cjs +1 -0
- package/dist/lib/tokens/index.d.cts +150 -0
- package/dist/lib/tokens/index.d.cts.map +1 -0
- package/dist/lib/tokens/index.d.mts +150 -0
- package/dist/lib/tokens/index.d.mts.map +1 -0
- package/dist/lib/tokens/index.mjs +1 -0
- package/dist/plugin.cjs +1 -0
- package/dist/plugin.d.cts +43 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +43 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +2 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/resolve-config-CBowa3KM.mjs +2 -0
- package/dist/resolve-config-CBowa3KM.mjs.map +1 -0
- package/dist/resolve-config-D7XXy_Qk.cjs +1 -0
- package/dist/rolldown-runtime-CMqjfN_6.cjs +1 -0
- package/dist/schema/index.cjs +1 -0
- package/dist/schema/index.d.cts +3 -0
- package/dist/schema/index.d.mts +3 -0
- package/dist/schema/index.mjs +1 -0
- package/dist/schema-1EWJvc56.d.cts +115 -0
- package/dist/schema-1EWJvc56.d.cts.map +1 -0
- package/dist/schema-BNfl9Tsw.d.mts +115 -0
- package/dist/schema-BNfl9Tsw.d.mts.map +1 -0
- package/dist/schema-Bxzw_P4l.mjs +2 -0
- package/dist/schema-Bxzw_P4l.mjs.map +1 -0
- package/dist/schema-CLeH9GGy.cjs +1 -0
- package/dist/tokens-B8Dv91EB.mjs +2 -0
- package/dist/tokens-B8Dv91EB.mjs.map +1 -0
- package/dist/tokens-CoQWg4mX.cjs +1 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.cts +37 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +37 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +83 -26
- package/dist/config-CJi9Fu8b.d.cts +0 -40
- package/dist/config-CJi9Fu8b.d.cts.map +0 -1
- package/dist/config-CJi9Fu8b.d.mts +0 -40
- package/dist/config-CJi9Fu8b.d.mts.map +0 -1
- package/dist/generator.mjs.map +0 -1
- package/dist/index-DUwzPMW3.d.mts +0 -14
- package/dist/index-DUwzPMW3.d.mts.map +0 -1
- package/dist/index-UbhspNdK.d.cts +0 -14
- package/dist/index-UbhspNdK.d.cts.map +0 -1
package/dist/generator.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { t as Schema } from "./schema-BNfl9Tsw.mjs";
|
|
2
|
+
import { n as Options } from "./config-DQHHeicR.mjs";
|
|
3
|
+
import "./index--y-fo2Lr.mjs";
|
|
3
4
|
//#region src/generator.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* A Power Plant generator for Razorwind.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @returns Generated documents keyed by output filename.
|
|
8
|
+
* Orchestrates configured {@link Plugin}s: Style Dictionary parsers /
|
|
9
|
+
* preprocessors, then `extract` → `validate` on input, then `generate`.
|
|
10
10
|
*/
|
|
11
|
-
declare const _default: import("@power-plant/core").GeneratorConfigObject<Schema,
|
|
11
|
+
declare const _default: import("@power-plant/core").GeneratorConfigObject<Schema, Options, void>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { _default as default };
|
|
14
14
|
//# sourceMappingURL=generator.d.mts.map
|
package/dist/generator.mjs
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`;)i++;i<e.length&&(t+=e[i]);continue}if(a===`/`&&o===`*`){for(i+=2;i<e.length;){if(e[i]===`*`&&e[i+1]===`/`){i++;break}e[i]===`
|
|
3
|
-
`&&(t+=`
|
|
4
|
-
`),i++}continue}if(a===`,`){let t=i+1;for(;t<e.length;){for(;/\s/.test(e[t]??``);)t++;if(e[t]===`/`&&e[t+1]===`/`){for(t+=2;t<e.length&&e[t]!==`
|
|
5
|
-
`&&e[t]!==`\r`;)t++;continue}if(e[t]===`/`&&e[t+1]===`*`){for(t+=2;t<e.length&&(e[t]!==`*`||e[t+1]!==`/`);)t++;t+=2;continue}break}if(e[t]===`}`||e[t]===`]`)continue}t+=a}return t}function Ce(e){if(e.startsWith(`#`)||e.startsWith(`.`)||re(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const we=new Map,I=new Map;function Te(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
6
|
-
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function Ee(e){let t=[],n=u.resolve(e,`pnpm-workspace.yaml`);if(v(n)){let e=await _(n);t.push(...Te(e))}let r=o(e,`package.json`);if(v(r))try{let e=await g(r),n=Array.isArray(e.workspaces)?e.workspaces:e.workspaces?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function De(e){let t=await Ee(e),n=new Map;if(!t.length)return n;let r=await l(t.map(e=>u.posix.join(e.split(u.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=u.resolve(e,u.dirname(t)),i=(await M(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function Oe(e,t){let n=x(e);if(!n)return null;let r=we.get(n);if(r?.has(t))return r.get(t)??null;let i=await De(n);return we.set(n,i),i.get(t)??null}function ke(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function Ae(e){let t=`${e.packageRoot}:${e.packageName}`,n=I.get(t);if(n)return n;let r=(await M(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return I.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=ce(n);if(!r)continue;let a=ke(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:le(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return I.set(t,i),i}async function je(e,t){let n=Ce(e);if(!n?.packageName)return null;let r=await Oe(t,n.packageName);return r?O(e,await Ae(r)):null}async function Me(e,t){let n=t.cwd??t.baseUrl??x();if(e.startsWith(`#`)){let t=await fe(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await je(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:Pe(e,t)}function Ne(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function Pe(e,t){let n=ne(t.baseUrl||t.cwd||x(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=Fe(e,t.paths??{});return!r&&Ne(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function Fe(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=k(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const Ie=c(`components`,{searchPlaces:[`components.json`]});async function Le(e){let t=await Be(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,Re(e,t)):null}const L={"@shadcn":`${T}/styles/{style}/{name}.json`};async function Re(e,t){t.registries={...L,...t.registries??{}};let n=await a(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await R(`utils`,t.aliases.utils,e,n),i=await R(`components`,t.aliases.components,e,n),o=t.aliases.ui?await R(`ui`,t.aliases.ui,e,n):u.resolve(i??e,`ui`),s=t.aliases.lib?await R(`lib`,t.aliases.lib,e,n):u.resolve(r??e,`..`),c=t.aliases.hooks?await R(`hooks`,t.aliases.hooks,e,n):u.resolve(i??e,`..`,`hooks`);return ze(e,{components:i,utils:r,ui:o,lib:s,hooks:c}),h.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?u.resolve(e,t.tailwind.config):``,tailwindCss:u.resolve(e,t.tailwind.css),utils:r,components:i,ui:o,lib:s,hooks:c}})}async function R(e,t,n,r){let i=await Me(t,{...r,cwd:n});if(!i?.path||t.startsWith(`#`)&&i.path===o(n,t))return null;if(e!==`utils`&&(i.source===`package_imports`||i.source===`workspace_package_exports`)){if(!i.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(i.path))return u.dirname(i.path);if(i.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(i.path))return i.path.replace(/\.[^/]+$/,``)}return i.path}function ze(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${s.cyan(e)}: ${s.cyan(n.join(`, `))}.`,`Configure path aliases in ${s.cyan(`tsconfig.json`)} or imports in ${s.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
7
|
-
`))}async function Be(e){try{let t=await Ie.search(e);if(!t)return null;let n=ee.parse(t.config);if(n.registries){for(let e of Object.keys(n.registries))if(e in L)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return n}catch(t){let n=`${e}/components.json`;throw t instanceof Error&&t.message.includes(`reserved registry`)?t:Error(`Invalid configuration found in ${s.cyan(n)}.`)}}function Ve(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...L}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}const He=b.object({category:b.enum([`block`,`component`,`ui`,`page`]),name:b.string(),title:b.string(),description:b.string().optional(),tags:b.array(b.string()).optional(),related:b.array(b.string()).optional(),since:b.string().optional(),version:b.string().optional(),repository:b.string().optional(),homepage:b.string().optional(),dependencies:b.record(b.string(),b.string()).optional(),registryDependencies:b.record(b.string(),b.string()).optional(),files:b.array(b.string()).optional()});b.record(b.string(),He);function Ue(e){return y.unknown().transform((t,n)=>{let r=e.safeParse(t);if(!r.success){for(let e of r.error.issues)n.addIssue({code:`custom`,message:e.message,path:e.path});return y.NEVER}return r.data})}const We=y.union([S,y.record(y.string(),S)]),Ge=y.object({registry:Ue(h),tokens:We}),Ke=[`razorwind-json`,`razorwind-yaml`,`razorwind-toml`,`razorwind-css`],z=[`json`,`json5`,`jsonc`,`yaml`,`yml`,`toml`,`css`,`js`,`mjs`,`cjs`,`ts`,`mts`,`cts`],qe=z.join(`,`),Je=[`tokens.json`,`tokens.json5`,`tokens.jsonc`,`tokens.yaml`,`tokens.yml`,`tokens.toml`,`tokens.css`,`design-tokens.json`,`design-tokens.yaml`,`design-tokens.yml`,`tokens`,`design-tokens`,`src/tokens`,`src/design-tokens`,`packages/tokens`,`style-dictionary.config.js`,`style-dictionary.config.mjs`,`style-dictionary.config.ts`,`sd.config.js`,`sd.config.mjs`,`sd.config.ts`],Ye=`**/*.{${qe}}`,Xe=/^(light|dark|dim|high-contrast|hc|default|base|theme)([._-].+)?$/i,Ze={color:`color`,colours:`color`,colors:`color`,colour:`color`,palette:`color`,bg:`color`,background:`color`,foreground:`color`,fg:`color`,border:`color`,fill:`color`,stroke:`color`,spacing:`dimension`,space:`dimension`,size:`dimension`,sizes:`dimension`,sizing:`dimension`,gap:`dimension`,radius:`dimension`,radii:`dimension`,rounded:`dimension`,width:`dimension`,height:`dimension`,dimension:`dimension`,dimensions:`dimension`,duration:`duration`,durations:`duration`,time:`duration`,delay:`duration`,animation:`duration`,motion:`duration`,transition:`duration`,font:`fontFamily`,fonts:`fontFamily`,fontfamily:`fontFamily`,"font-family":`fontFamily`,typeface:`fontFamily`,fontweight:`fontWeight`,"font-weight":`fontWeight`,weight:`fontWeight`,opacity:`number`,opacities:`number`,zindex:`number`,"z-index":`number`,lineheight:`number`,"line-height":`number`,letterspacing:`dimension`,"letter-spacing":`dimension`,shadow:`shadow`,shadows:`shadow`,elevation:`shadow`,gradient:`gradient`,gradients:`gradient`,typography:`typography`,text:`typography`,cubicbezier:`cubicBezier`,easing:`cubicBezier`,ease:`cubicBezier`},Qe=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,$e=/^rgba?\(\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+%?)(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,et=/^hsla?\(\s*([+\d.]+)[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%[\x09-\x0D\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?: |(?: \s*)?,)\s*([+\d.]+)%(?:\s*[,/]\s*([+\d.]+%?))?\s*\)$/i,tt=/^oklch\(\s*([+\d.]+%?|none)\s+([+\d.]+|none)\s+([+\d.]+|none)(?:\s*\/\s*([+\d.]+%?))?\s*\)$/i,nt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(px|rem|em|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc)$/i,rt=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(ms|s)$/i,it=/^cubic-bezier\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*\)$/i,at=/^var\(\s*(--[\w-]+)\s*(?:,\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))?\)\s*$/i,ot=/^\{[^{}]+\}$/,st={thin:100,hairline:100,extralight:200,"extra-light":200,ultralight:200,light:300,normal:400,regular:400,book:400,medium:500,semibold:600,"semi-bold":600,demibold:600,bold:700,extrabold:800,"extra-bold":800,ultrabold:800,black:900,heavy:900},B=new Set([`px`,`rem`]);function V(e){return Math.min(1,Math.max(0,e))}function H(e,t=100){let n=e.trim();if(n.endsWith(`%`))return V(Number.parseFloat(n)/t);let r=Number.parseFloat(n);return V(r>1?r/255:r)}function ct(e){let t=e.slice(1);return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:(e.length===7||e.length,e)}function lt(e){let t=ct(e.toLowerCase()).slice(1),n=Number.parseInt(t.slice(0,2),16)/255,r=Number.parseInt(t.slice(2,4),16)/255,i=Number.parseInt(t.slice(4,6),16)/255,a=t.length===8?Number.parseInt(t.slice(6,8),16)/255:void 0;return{colorSpace:`srgb`,components:[n,r,i],...a===void 0||a===1?{}:{alpha:a},hex:`#${t.slice(0,6)}`}}function ut(e){return`{${e.replace(/^--/,``).split(`-`).filter(Boolean).join(`.`)}}`}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function G(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.toLowerCase();if(!n)continue;let r=Ze[n];if(r)return r}}function K(e,t=[]){let n=G(t);if(typeof e==`string`){let r=e.trim();if(ot.test(r))return{value:r,type:n};let i=r.match(at);if(i?.[1])return{value:ut(i[1]),type:n};if(Qe.test(r))return{value:lt(r),type:`color`};let a=r.match($e);if(a){let e=[H(a[1]),H(a[2]),H(a[3])],t=a[4]?a[4].endsWith(`%`)?V(Number.parseFloat(a[4])/100):V(Number.parseFloat(a[4])):void 0;return{value:{colorSpace:`srgb`,components:e,...t===void 0||Number.isNaN(t)?{}:{alpha:t}},type:`color`}}let o=r.match(et);if(o)return{value:{colorSpace:`hsl`,components:[Number.parseFloat(o[1]),Number.parseFloat(o[2]),Number.parseFloat(o[3])],...o[4]?{alpha:o[4].endsWith(`%`)?V(Number.parseFloat(o[4])/100):V(Number.parseFloat(o[4]))}:{}},type:`color`};let s=r.match(tt);if(s){let e=e=>e===`none`?`none`:e.endsWith(`%`)?Number.parseFloat(e)/100:Number.parseFloat(e);return{value:{colorSpace:`oklch`,components:[e(s[1]),e(s[2]),e(s[3])],...s[4]?{alpha:s[4].endsWith(`%`)?V(Number.parseFloat(s[4])/100):V(Number.parseFloat(s[4]))}:{}},type:`color`}}let c=r.match(nt);if(c){let e=c[2].toLowerCase(),t=Number.parseFloat(c[1]);return B.has(e)?{value:{value:t,unit:e},type:`dimension`}:{value:r,type:n===`dimension`?void 0:n}}let l=r.match(rt);if(l)return{value:{value:Number.parseFloat(l[1]),unit:l[2].toLowerCase()},type:`duration`};let u=r.match(it);if(u)return{value:[Number.parseFloat(u[1]),Number.parseFloat(u[2]),Number.parseFloat(u[3]),Number.parseFloat(u[4])],type:`cubicBezier`};let d=st[r.toLowerCase()];return d===void 0?n===`fontFamily`||/family|font|typeface/i.test(t.at(-1)??``)?r.includes(`,`)?{value:r.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``)),type:`fontFamily`}:{value:r.replace(/^["']|["']$/g,``),type:`fontFamily`}:n===`color`&&!r.startsWith(`{`)?{value:r,type:void 0}:{value:r,type:n}:{value:d,type:`fontWeight`}}if(typeof e==`number`)return n===`fontWeight`?{value:e,type:`fontWeight`}:n===`duration`?{value:{value:e,unit:`ms`},type:`duration`}:n===`dimension`?{value:{value:e,unit:`px`},type:`dimension`}:{value:e,type:n??`number`};if(Array.isArray(e))return e.length===4&&e.every(e=>typeof e==`number`)&&(n===`cubicBezier`||t.some(e=>/ease|bezier/i.test(e)))?{value:e,type:`cubicBezier`}:e.every(e=>typeof e==`string`)?{value:e,type:n??`fontFamily`}:{value:e,type:n};if(U(e)){if(`colorSpace`in e&&`components`in e)return{value:e,type:`color`};if(`value`in e&&`unit`in e){let t=String(e.unit).toLowerCase();return t===`ms`||t===`s`?{value:e,type:`duration`}:B.has(t)?{value:e,type:`dimension`}:{value:e,type:n}}}return{value:e,type:n}}function dt(e,t){let n={...e};if(`value`in n&&!(`$value`in n)&&(n.$value=n.value,delete n.value),`type`in n&&!(`$type`in n)&&(n.$type=n.type,delete n.type),`comment`in n&&!(`$description`in n)&&(n.$description=n.comment,delete n.comment),`description`in n&&!(`$description`in n)&&(n.$description=n.description,delete n.description),`ref`in n&&!(`$ref`in n)&&(n.$ref=n.ref,delete n.ref),`$value`in n){let e=K(n.$value,t);n.$value=e.value,!(`$type`in n)&&e.type&&(n.$type=e.type)}return n}function q(e,t=[]){if(Array.isArray(e))return e.map((e,n)=>q(e,[...t,String(n)]));if(!U(e))return e;if(W(e))return dt(e,t);let n={};for(let[r,i]of Object.entries(e)){if(r.startsWith(`$`)){n[r]=i;continue}n[r]=q(i,[...t,r])}if(!(`$type`in n)){let e=G(t);e&&t.length>0&&(n.$type=e)}return n}function J(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/^--/,``).split(/[-./]/).filter(Boolean);if(e.length===0)continue;let i=t;for(let t=0;t<e.length-1;t++){let n=e[t],r=i[n];U(r)?W(r)&&(i[n]={DEFAULT:r}):i[n]={},i=i[n]}let a=e.at(-1),o=K(r,e),s={$value:o.value,...o.type?{$type:o.type}:{}},c=i[a];U(c)&&!W(c)?c.DEFAULT=s:i[a]=s}return q(t)}const ft=/(--[A-Z_][\w-]*)\s*:\s*([^;}{]+?)(?=\s*(?:;|\}|$))/gi;function pt(e){let t={},n=e.replace(/\/\*[\s\S]*?\*\//g,``);for(let e of n.matchAll(ft)){let n=e[1],r=e[2]?.trim();!n||!r||(t[n]=r)}return J(t)}const Y=`razorwind-infer`;function X(e){if(e==null)return{};if(typeof e!=`object`||Array.isArray(e))throw TypeError(`Token file must parse to a plain object.`);return q(e)}function mt(e){try{return X(ae.parse(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse JSON token file: ${t}`)}}function ht(e){try{return X(se(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse YAML token file: ${t}`)}}function gt(e){try{return X(oe(e))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse TOML token file: ${t}`)}}const _t=[{name:`razorwind-json`,pattern:/\.json[c5]?$/i,parser:({contents:e})=>mt(e)},{name:`razorwind-yaml`,pattern:/\.ya?ml$/i,parser:({contents:e})=>ht(e)},{name:`razorwind-toml`,pattern:/\.toml$/i,parser:({contents:e})=>gt(e)},{name:`razorwind-css`,pattern:/\.css$/i,parser:({contents:e})=>q(pt(e))}];function vt(){return Object.fromEntries(_t.map(({name:e,pattern:t,parser:n})=>[e,{pattern:t,parser:n}]))}function yt(e){return q(e)}function bt(){return{[Y]:yt}}function xt(e=i){for(let t of _t)e.registerParser(t);e.registerPreprocessor({name:Y,preprocessor:yt})}function Z(e,t){return p(t)?t:m(e,t)}function St(e){return/\.([^.]+)$/.exec(e)?.[1]?.toLowerCase()??``}function Ct(e){return z.includes(St(e))}function Q(e){let t=e.split(/[/\\]/).pop()?.toLowerCase()??``;return t.startsWith(`style-dictionary.config.`)||t.startsWith(`sd.config.`)}function wt(e){return o(e,Ye)}function Tt(e){let{cwd:t,tokensPath:n,fallbackPaths:r=[]}=e;if(n){let e=Z(t,n);if(!C(e))throw Error(`tokensPath "${n}" does not exist (resolved: ${e}).`);return w(e)?{resolvedPath:e,source:[wt(e)],origin:`tokensPath`}:Q(e)?{resolvedPath:e,source:[],origin:`tokensPath`}:{resolvedPath:e,source:[e],origin:`tokensPath`}}for(let e of Je){let n=Z(t,e);if(C(n)){if(w(n))return{resolvedPath:n,source:[wt(n)],origin:`default`};if(Q(n))return{resolvedPath:n,source:[],origin:`default`};if(Ct(n))return{resolvedPath:n,source:[n],origin:`default`}}}for(let e of r){if(!e)continue;let n=Z(t,e);if(!(!C(n)||w(n))&&(Ct(n)||St(n)===`css`))return{resolvedPath:n,source:[n],origin:`fallback`}}return{source:[],origin:`none`}}function Et(e){return(e.split(/[/\\]/).pop()??``).replace(/\.[^.]+$/,``).match(Xe)?.[1]?.toLowerCase()}let Dt=!1;function Ot(){Dt||=(xt(i),!0)}function kt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}async function At(e){let t=await ie(e);return t&&typeof t==`object`&&`default`in t&&t.default?t.default:t}async function jt(e){Ot();let t=new i({...e,parsers:[...Ke,...e.parsers??[]],preprocessors:[Y,...e.preprocessors??[]],hooks:{...e.hooks,parsers:{...vt(),...e.hooks?.parsers},preprocessors:{...bt(),...e.hooks?.preprocessors}},usesDtcg:e.usesDtcg??!0,platforms:e.platforms??{}});return await t.hasInitialized,t}async function $(e){return e.length===0?{}:(await jt({source:e})).tokens}async function Mt(e){return(await l(e,{absolute:!0,onlyFiles:!0,unique:!0})).sort()}async function Nt(e){let t=await Mt(e);if(t.length===0)return{};let n=new Map,r=[];for(let e of t){let t=Et(e);if(t){let r=n.get(t)??[];r.push(e),n.set(t,r)}else r.push(e)}if(n.size<2)return $(e);let i={};if(r.length>0){let e=await $(r);kt(e)||(i.base=e)}for(let[e,t]of n)i[e]=await $(t);return i}async function Pt(e){let{splitThemes:t=!0,...n}=e,r=Tt(n);return r.resolvedPath&&C(r.resolvedPath)&&/(?:^|[/\\])(?:style-dictionary|sd)\.config\./i.test(d(r.resolvedPath))?(await jt(await At(r.resolvedPath))).tokens:r.source.length===0?{}:t?Nt(r.source):$(r.source)}async function Ft(){try{return await import(`@tailwindcss/node`)}catch(e){throw Error(`Cannot load '@tailwindcss/node'. Install tailwindcss v4 / @tailwindcss/node to extract workspace theme tokens.`,{cause:e})}}function It(e,t){return p(t)?t:m(e,t)}async function Lt(e,t){let n=await he(e,{configCssFile:t??void 0});if(n?.tailwindVersion)return{configured:!!n.tailwindCssFile,version:n.tailwindVersion,cssFile:n.tailwindCssFile,configFile:n.tailwindConfigFile};let[r,i]=await Promise.all([P(e),F(e,t??void 0)]);return{configured:!!(r&&i),version:r,cssFile:i,configFile:null}}function Rt(e,t){for(let n of t){if(!r(n))continue;let t=It(e,n);if(C(t))return t}return null}async function zt(e){let{cwd:t,cssPath:n,omitDefaults:r=!1}=e,i=await Lt(t,n);if(!i.configured||i.version!==`v4`)return null;let a=Rt(t,[n,i.cssFile]);if(!a)return null;let o=await _(a),s=await(await Ft()).__unstable__loadDesignSystem(o,{base:f(a)}),c={};for(let[e,t]of s.theme.entries())r&&(t.options&4)==4||!e.startsWith(`--`)||!t.value||(c[e]=t.value);return Object.keys(c).length===0?null:J(c)}function Bt(e){return!e||typeof e!=`object`||Object.keys(e).length===0}var Vt=e({meta:{name:`razorwind`,title:`Razorwind`,description:`A generator that uses Razorwind to generate design system code from design tokens and components.`,version:`1.0`,tags:[`razorwind`,`dtcg`]},schema:Ge,input:async e=>{let{registryPath:a,tokensPath:o}=e,{cwd:s}=t(),c=r(a)?n(a):s,l=await Le(c)??Ve({resolvedPaths:{cwd:c}});xt(i);let u=[l.resolvedPaths?.tailwindCss,l.tailwind?.css],d;if(r(o))d=await Pt({cwd:s,tokensPath:o});else{let e=await Lt(s,l.tailwind?.css);e.configured&&e.version===`v4`&&(d=await zt({cwd:s,cssPath:l.resolvedPaths?.tailwindCss??l.tailwind?.css??e.cssFile})),Bt(d)&&(d=await Pt({cwd:s,fallbackPaths:u}))}return{registry:l,tokens:d??{}}},generator:async(e,t)=>({})});export{Vt as default};
|
|
8
|
-
//# sourceMappingURL=generator.mjs.map
|
|
1
|
+
import{t as e}from"./generator-BWQOEMGt.mjs";export{e as default};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config.cjs");exports.defineConfig=e.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugin.cjs"),t=require("./resolve-config-D7XXy_Qk.cjs"),n=require("./config.cjs");require("./generator-DjAElWpu.cjs");const r=require("./schema-CLeH9GGy.cjs"),i=require("./utils/index.cjs");let a=require("@power-plant/dtcg-schema");exports.componentFileSchema=r.n,exports.componentSchema=r.r,exports.componentsSchema=r.i,exports.createDocument=i.createDocument,exports.defineConfig=n.defineConfig,exports.definePlugin=e.definePlugin,exports.formatColorValue=i.formatColorValue,exports.formatDimensionValue=i.formatDimensionValue,exports.formatTokenValue=i.formatTokenValue,exports.isPlainObject=i.isPlainObject,exports.resolveConfig=t.t,exports.schema=r.t,exports.toCssVar=i.toCssVar,Object.defineProperty(exports,"tokenSchema",{enumerable:!0,get:function(){return a.tokenSchema}}),Object.defineProperty(exports,"tokensSchema",{enumerable:!0,get:function(){return a.tokensSchema}});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as Components, c as componentsSchema, i as ComponentFile, n as schema, o as componentFileSchema, r as Component, s as componentSchema, t as Schema } from "./schema-1EWJvc56.cjs";
|
|
2
|
+
import { a as UserConfigFn, c as UserConfigParams, d as TokensPreprocessor, i as UserConfigExport, l as Plugin, n as Options, o as UserConfigFnObject, r as UserConfig, s as UserConfigFnPromise, t as Config, u as TokensParser } from "./config-Dj6RrLde.cjs";
|
|
3
|
+
import { definePlugin } from "./plugin.cjs";
|
|
4
|
+
import { defineConfig, resolveConfig } from "./config.cjs";
|
|
5
|
+
import { i as tokensSchema, n as Tokens, r as tokenSchema, t as Token } from "./index-COAOe8bR.cjs";
|
|
6
|
+
import "./generator.cjs";
|
|
7
|
+
import { createDocument, formatColorValue, formatDimensionValue, formatTokenValue, isPlainObject, toCssVar } from "./utils/index.cjs";
|
|
4
8
|
import { GeneratorConfig } from "@power-plant/core";
|
|
5
9
|
//#region src/types/base.d.ts
|
|
6
10
|
type Generator<TOptions extends object = object> = GeneratorConfig<Schema, TOptions> & {
|
|
@@ -14,5 +18,5 @@ type Generator<TOptions extends object = object> = GeneratorConfig<Schema, TOpti
|
|
|
14
18
|
tags: string[];
|
|
15
19
|
};
|
|
16
20
|
//#endregion
|
|
17
|
-
export { type Config, type Generator, type
|
|
21
|
+
export { type Component, type ComponentFile, type Components, type Config, type Generator, type Options, type Plugin, type Schema, type Token, type Tokens, type TokensParser, type TokensPreprocessor, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type UserConfigParams, componentFileSchema, componentSchema, componentsSchema, createDocument, defineConfig, definePlugin, formatColorValue, formatDimensionValue, formatTokenValue, isPlainObject, resolveConfig, schema, toCssVar, tokenSchema, tokensSchema };
|
|
18
22
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/base.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/base.ts"],"mappings":";;;;;;;;;KAqBY,UAAU,oCAAoC,gBACxD,QACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as Components, c as componentsSchema, i as ComponentFile, n as schema, o as componentFileSchema, r as Component, s as componentSchema, t as Schema } from "./schema-BNfl9Tsw.mjs";
|
|
2
|
+
import { a as UserConfigFn, c as UserConfigParams, d as TokensPreprocessor, i as UserConfigExport, l as Plugin, n as Options, o as UserConfigFnObject, r as UserConfig, s as UserConfigFnPromise, t as Config, u as TokensParser } from "./config-DQHHeicR.mjs";
|
|
3
|
+
import { definePlugin } from "./plugin.mjs";
|
|
4
|
+
import { defineConfig, resolveConfig } from "./config.mjs";
|
|
5
|
+
import { i as tokensSchema, n as Tokens, r as tokenSchema, t as Token } from "./index--y-fo2Lr.mjs";
|
|
6
|
+
import "./generator.mjs";
|
|
7
|
+
import { createDocument, formatColorValue, formatDimensionValue, formatTokenValue, isPlainObject, toCssVar } from "./utils/index.mjs";
|
|
4
8
|
import { GeneratorConfig } from "@power-plant/core";
|
|
5
9
|
//#region src/types/base.d.ts
|
|
6
10
|
type Generator<TOptions extends object = object> = GeneratorConfig<Schema, TOptions> & {
|
|
@@ -14,5 +18,5 @@ type Generator<TOptions extends object = object> = GeneratorConfig<Schema, TOpti
|
|
|
14
18
|
tags: string[];
|
|
15
19
|
};
|
|
16
20
|
//#endregion
|
|
17
|
-
export { type Config, type Generator, type
|
|
21
|
+
export { type Component, type ComponentFile, type Components, type Config, type Generator, type Options, type Plugin, type Schema, type Token, type Tokens, type TokensParser, type TokensPreprocessor, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type UserConfigParams, componentFileSchema, componentSchema, componentsSchema, createDocument, defineConfig, definePlugin, formatColorValue, formatDimensionValue, formatTokenValue, isPlainObject, resolveConfig, schema, toCssVar, tokenSchema, tokensSchema };
|
|
18
22
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{definePlugin as e}from"./plugin.mjs";import{t}from"./resolve-config-CBowa3KM.mjs";import{defineConfig as n}from"./config.mjs";import"./generator-BWQOEMGt.mjs";import{a as r,i,n as a,o,r as s,t as c}from"./schema-Bxzw_P4l.mjs";import{createDocument as l,formatColorValue as u,formatDimensionValue as d,formatTokenValue as f,isPlainObject as p,toCssVar as m}from"./utils/index.mjs";export{i as componentFileSchema,r as componentSchema,o as componentsSchema,l as createDocument,n as defineConfig,e as definePlugin,u as formatColorValue,d as formatDimensionValue,f as formatTokenValue,p as isPlainObject,t as resolveConfig,s as schema,m as toCssVar,c as tokenSchema,a as tokensSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../tokens-CoQWg4mX.cjs");exports.DEFAULT_TOKEN_PATH_CANDIDATES=e.h,exports.RAZORWIND_INFER_PREPROCESSOR=e.a,exports.THEME_BASENAME_PATTERN=e.g,exports.TOKEN_DIRECTORY_GLOB=e._,exports.TOKEN_FILE_EXTENSIONS=e.v,exports.TYPE_PATH_HINTS=e.b,exports.WINDIE_PARSERS=e.y,exports.razorwindParsers=e.y,exports.getRazorwindParserHooks=e.o,exports.getRazorwindPreprocessorHooks=e.s,exports.inferTypeFromPath=e.d,exports.inferValue=e.f,exports.loadTokens=e.t,exports.loadTokensOrThrow=e.n,exports.nestFlatTokens=e.p,exports.normalizeTokenTree=e.m,exports.parseCssCustomProperties=e.u,exports.razorwindInferPreprocessor=e.c,exports.registerRazorwindParsers=e.l,exports.resolveTokensSource=e.r,exports.themeKeyFromPath=e.i;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { l as Plugin, t as Config } from "../../config-Dj6RrLde.cjs";
|
|
2
|
+
import { Tokens } from "@power-plant/dtcg-schema";
|
|
3
|
+
import { Hooks, Parser, PreprocessedTokens } from "style-dictionary/types";
|
|
4
|
+
//#region src/lib/tokens/constants.d.ts
|
|
5
|
+
/** Style Dictionary parser hook names registered by Razorwind. */
|
|
6
|
+
declare const TOKEN_PARSER_NAMES: readonly ["razorwind-json", "razorwind-yaml", "razorwind-toml", "razorwind-css"];
|
|
7
|
+
type RazorwindParserName = (typeof TOKEN_PARSER_NAMES)[number];
|
|
8
|
+
/** File extensions treated as design-token sources. */
|
|
9
|
+
declare const TOKEN_FILE_EXTENSIONS: readonly ["json", "json5", "jsonc", "yaml", "yml", "toml", "css", "js", "mjs", "cjs", "ts", "mts", "cts"];
|
|
10
|
+
/**
|
|
11
|
+
* Candidate paths checked when `tokensPath` is omitted.
|
|
12
|
+
* First existing file or directory wins.
|
|
13
|
+
*/
|
|
14
|
+
declare const DEFAULT_TOKEN_PATH_CANDIDATES: readonly ["tokens.json", "tokens.json5", "tokens.jsonc", "tokens.yaml", "tokens.yml", "tokens.toml", "tokens.css", "design-tokens.json", "design-tokens.yaml", "design-tokens.yml", "tokens", "design-tokens", "src/tokens", "src/design-tokens", "packages/tokens", "style-dictionary.config.js", "style-dictionary.config.mjs", "style-dictionary.config.ts", "sd.config.js", "sd.config.mjs", "sd.config.ts"];
|
|
15
|
+
/** Glob appended when a tokens directory is resolved. */
|
|
16
|
+
declare const TOKEN_DIRECTORY_GLOB: string;
|
|
17
|
+
/** Theme-like basename patterns used to split multi-file sources into a record. */
|
|
18
|
+
declare const THEME_BASENAME_PATTERN: RegExp;
|
|
19
|
+
/** Path segment hints used when inferring `$type`. */
|
|
20
|
+
declare const TYPE_PATH_HINTS: Record<string, string>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/lib/tokens/css.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* Extract CSS custom properties from stylesheet text into a nested token tree.
|
|
25
|
+
* Handles `:root`, `[data-theme]`, and Tailwind v4 `@theme` blocks alike.
|
|
26
|
+
*/
|
|
27
|
+
declare function parseCssCustomProperties(contents: string): Record<string, unknown>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/lib/tokens/infer.d.ts
|
|
30
|
+
type InferredTokenType = "color" | "dimension" | "duration" | "fontFamily" | "fontWeight" | "number" | "cubicBezier" | "shadow" | "gradient" | "typography" | "strokeStyle" | "border" | "transition";
|
|
31
|
+
/**
|
|
32
|
+
* Infer DTCG `$type` from a path segment chain (e.g. `color.primary`).
|
|
33
|
+
*/
|
|
34
|
+
declare function inferTypeFromPath(path: string[]): InferredTokenType | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Normalize a raw token value into DTCG-friendly shape + optional `$type`.
|
|
37
|
+
*/
|
|
38
|
+
declare function inferValue(raw: unknown, path?: string[]): {
|
|
39
|
+
value: unknown;
|
|
40
|
+
type?: InferredTokenType;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Walk a token tree: promote legacy keys to DTCG and infer `$type` / `$value` shapes.
|
|
44
|
+
*/
|
|
45
|
+
declare function normalizeTokenTree(input: unknown, path?: string[]): unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Nest a flat map of dashed keys into a token tree.
|
|
48
|
+
* `--color-primary-500` / `color-primary-500` → `color.primary.500`.
|
|
49
|
+
*
|
|
50
|
+
* Scalar parents that also have children (e.g. `--radius` + `--radius-lg`) are
|
|
51
|
+
* preserved under `DEFAULT` so neither value is dropped.
|
|
52
|
+
*/
|
|
53
|
+
declare function nestFlatTokens(flat: Record<string, unknown>): Record<string, unknown>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/lib/tokens/resolve-path.d.ts
|
|
56
|
+
interface ResolveTokensPathOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Working directory used to resolve relative paths.
|
|
59
|
+
*/
|
|
60
|
+
cwd: string;
|
|
61
|
+
/**
|
|
62
|
+
* Explicit tokens file or directory from config.
|
|
63
|
+
*/
|
|
64
|
+
tokensPath?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Extra fallback paths (e.g. registry `tailwind.css`).
|
|
67
|
+
*/
|
|
68
|
+
fallbackPaths?: Array<string | null | undefined>;
|
|
69
|
+
}
|
|
70
|
+
interface ResolvedTokensSource {
|
|
71
|
+
/**
|
|
72
|
+
* Absolute path to the resolved file or directory (if any).
|
|
73
|
+
*/
|
|
74
|
+
resolvedPath?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Style Dictionary `source` globs.
|
|
77
|
+
*/
|
|
78
|
+
source: string[];
|
|
79
|
+
/**
|
|
80
|
+
* How the path was discovered.
|
|
81
|
+
*/
|
|
82
|
+
origin: "tokensPath" | "default" | "fallback" | "none";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolve Style Dictionary source globs from `tokensPath` or common defaults.
|
|
86
|
+
*/
|
|
87
|
+
declare function resolveTokensSource(options: ResolveTokensPathOptions): ResolvedTokensSource;
|
|
88
|
+
/**
|
|
89
|
+
* Detect theme-like basenames for splitting multi-file token sets.
|
|
90
|
+
*/
|
|
91
|
+
declare function themeKeyFromPath(filePath: string): string | undefined;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/lib/tokens/load.d.ts
|
|
94
|
+
interface LoadTokensOptions extends ResolveTokensPathOptions {
|
|
95
|
+
/**
|
|
96
|
+
* When true, split theme-named files into a record keyed by theme.
|
|
97
|
+
*
|
|
98
|
+
* @defaultValue true
|
|
99
|
+
*/
|
|
100
|
+
splitThemes?: boolean;
|
|
101
|
+
}
|
|
102
|
+
type LoadedTokens = Tokens | Record<string, Tokens>;
|
|
103
|
+
/**
|
|
104
|
+
* Load design tokens via Style Dictionary parser hooks.
|
|
105
|
+
*
|
|
106
|
+
* Resolution order:
|
|
107
|
+
* 1. Explicit `tokensPath` (file, directory, or SD config)
|
|
108
|
+
* 2. Common default paths (`tokens.json`, `tokens/`, …)
|
|
109
|
+
* 3. Fallback paths (e.g. registry Tailwind CSS)
|
|
110
|
+
*/
|
|
111
|
+
declare function loadTokens(config: Config, options: LoadTokensOptions): Promise<LoadedTokens>;
|
|
112
|
+
/**
|
|
113
|
+
* Convenience: load tokens or throw when nothing usable is found.
|
|
114
|
+
*
|
|
115
|
+
* @param config - The configuration object.
|
|
116
|
+
* @param options - The options for loading the tokens.
|
|
117
|
+
* @returns The loaded tokens.
|
|
118
|
+
* @throws An error if no design tokens are found.
|
|
119
|
+
* @throws An error if the tokens are not valid.
|
|
120
|
+
*/
|
|
121
|
+
declare function loadTokensOrThrow(config: Config, options: LoadTokensOptions): Promise<LoadedTokens>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/lib/tokens/parsers.d.ts
|
|
124
|
+
/** Preprocessor name applied after all sources merge. */
|
|
125
|
+
declare const RAZORWIND_INFER_PREPROCESSOR = "razorwind-infer";
|
|
126
|
+
/** Inline `hooks.parsers` map for Style Dictionary config. */
|
|
127
|
+
declare function getRazorwindParserHooks(): NonNullable<Hooks["parsers"]>;
|
|
128
|
+
/**
|
|
129
|
+
* Infer DTCG `$type` / normalize legacy keys after sources merge.
|
|
130
|
+
* Covers JS/TS modules that bypass custom file parsers.
|
|
131
|
+
*/
|
|
132
|
+
declare function razorwindInferPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
|
|
133
|
+
/** Inline `hooks.preprocessors` map for Style Dictionary config. */
|
|
134
|
+
declare function getRazorwindPreprocessorHooks(): NonNullable<Hooks["preprocessors"]>;
|
|
135
|
+
/**
|
|
136
|
+
* Register Razorwind parsers + infer preprocessor on Style Dictionary,
|
|
137
|
+
* then register any parsers / preprocessors contributed by plugins.
|
|
138
|
+
*
|
|
139
|
+
* @see https://styledictionary.com/reference/hooks/parsers/
|
|
140
|
+
*/
|
|
141
|
+
declare function registerRazorwindParsers(plugins?: Plugin[], target?: {
|
|
142
|
+
registerParser: (parser: Parser) => unknown;
|
|
143
|
+
registerPreprocessor: (preprocessor: {
|
|
144
|
+
name: string;
|
|
145
|
+
preprocessor: typeof razorwindInferPreprocessor;
|
|
146
|
+
}) => unknown;
|
|
147
|
+
}): void;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { DEFAULT_TOKEN_PATH_CANDIDATES, type InferredTokenType, type LoadTokensOptions, type LoadedTokens, RAZORWIND_INFER_PREPROCESSOR, type RazorwindParserName, type ResolveTokensPathOptions, type ResolvedTokensSource, THEME_BASENAME_PATTERN, TOKEN_DIRECTORY_GLOB, TOKEN_FILE_EXTENSIONS, TYPE_PATH_HINTS, TOKEN_PARSER_NAMES as WINDIE_PARSERS, TOKEN_PARSER_NAMES as razorwindParsers, getRazorwindParserHooks, getRazorwindPreprocessorHooks, inferTypeFromPath, inferValue, loadTokens, loadTokensOrThrow, nestFlatTokens, normalizeTokenTree, parseCssCustomProperties, razorwindInferPreprocessor, registerRazorwindParsers, resolveTokensSource, themeKeyFromPath };
|
|
150
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/lib/tokens/constants.ts","../../../src/lib/tokens/css.ts","../../../src/lib/tokens/infer.ts","../../../src/lib/tokens/resolve-path.ts","../../../src/lib/tokens/load.ts","../../../src/lib/tokens/parsers.ts"],"mappings":";;;;;cAmBa;KAOD,8BAA8B;;cAG7B;;;;;cAsBA;;cAyBA;;cAGA,wBAAsB;;cAItB,iBAAiB;;;;;;;iBCvDd,yBACd,mBACC;;;KC+BS;;;;iBAuEI,kBACd,iBACC;;;;iBAiBa,WACd,cACA;EACG;EAAgB,OAAO;;;;;iBAsPZ,mBACd,gBACA;;;;;;;;iBA2Cc,eACd,MAAM,0BACL;;;UClac;;;;EAIf;;;;EAKA;;;;EAKA,gBAAgB;;UAGD;;;;EAIf;;;;EAKA;;;;EAKA;;;;;iBAkCc,oBACd,SAAS,2BACR;;;;iBAyFa,iBAAiB;;;UCpJhB,0BAA0B;;;;;;EAMzC;;KAGU,eAAe,SAAS,eAAe;;;;;;;;;iBA2I7B,WACpB,QAAQ,QACR,SAAS,oBACR,QAAQ;;;;;;;;;;iBAuCW,kBACpB,QAAQ,QACR,SAAS,oBACR,QAAQ;;;;cCnME;;iBAuEG,2BAA2B,YAAY;;;;;iBAavC,2BACd,YAAY,qBACX;;iBAKa,iCAAiC,YAC/C;;;;;;;iBAac,yBACd,UAAS,UACT;EACE,iBAAiB,QAAQ;EACzB,uBAAuB;IACrB;IACA,qBAAqB"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { l as Plugin, t as Config } from "../../config-DQHHeicR.mjs";
|
|
2
|
+
import { Tokens } from "@power-plant/dtcg-schema";
|
|
3
|
+
import { Hooks, Parser, PreprocessedTokens } from "style-dictionary/types";
|
|
4
|
+
//#region src/lib/tokens/constants.d.ts
|
|
5
|
+
/** Style Dictionary parser hook names registered by Razorwind. */
|
|
6
|
+
declare const TOKEN_PARSER_NAMES: readonly ["razorwind-json", "razorwind-yaml", "razorwind-toml", "razorwind-css"];
|
|
7
|
+
type RazorwindParserName = (typeof TOKEN_PARSER_NAMES)[number];
|
|
8
|
+
/** File extensions treated as design-token sources. */
|
|
9
|
+
declare const TOKEN_FILE_EXTENSIONS: readonly ["json", "json5", "jsonc", "yaml", "yml", "toml", "css", "js", "mjs", "cjs", "ts", "mts", "cts"];
|
|
10
|
+
/**
|
|
11
|
+
* Candidate paths checked when `tokensPath` is omitted.
|
|
12
|
+
* First existing file or directory wins.
|
|
13
|
+
*/
|
|
14
|
+
declare const DEFAULT_TOKEN_PATH_CANDIDATES: readonly ["tokens.json", "tokens.json5", "tokens.jsonc", "tokens.yaml", "tokens.yml", "tokens.toml", "tokens.css", "design-tokens.json", "design-tokens.yaml", "design-tokens.yml", "tokens", "design-tokens", "src/tokens", "src/design-tokens", "packages/tokens", "style-dictionary.config.js", "style-dictionary.config.mjs", "style-dictionary.config.ts", "sd.config.js", "sd.config.mjs", "sd.config.ts"];
|
|
15
|
+
/** Glob appended when a tokens directory is resolved. */
|
|
16
|
+
declare const TOKEN_DIRECTORY_GLOB: string;
|
|
17
|
+
/** Theme-like basename patterns used to split multi-file sources into a record. */
|
|
18
|
+
declare const THEME_BASENAME_PATTERN: RegExp;
|
|
19
|
+
/** Path segment hints used when inferring `$type`. */
|
|
20
|
+
declare const TYPE_PATH_HINTS: Record<string, string>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/lib/tokens/css.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* Extract CSS custom properties from stylesheet text into a nested token tree.
|
|
25
|
+
* Handles `:root`, `[data-theme]`, and Tailwind v4 `@theme` blocks alike.
|
|
26
|
+
*/
|
|
27
|
+
declare function parseCssCustomProperties(contents: string): Record<string, unknown>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/lib/tokens/infer.d.ts
|
|
30
|
+
type InferredTokenType = "color" | "dimension" | "duration" | "fontFamily" | "fontWeight" | "number" | "cubicBezier" | "shadow" | "gradient" | "typography" | "strokeStyle" | "border" | "transition";
|
|
31
|
+
/**
|
|
32
|
+
* Infer DTCG `$type` from a path segment chain (e.g. `color.primary`).
|
|
33
|
+
*/
|
|
34
|
+
declare function inferTypeFromPath(path: string[]): InferredTokenType | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Normalize a raw token value into DTCG-friendly shape + optional `$type`.
|
|
37
|
+
*/
|
|
38
|
+
declare function inferValue(raw: unknown, path?: string[]): {
|
|
39
|
+
value: unknown;
|
|
40
|
+
type?: InferredTokenType;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Walk a token tree: promote legacy keys to DTCG and infer `$type` / `$value` shapes.
|
|
44
|
+
*/
|
|
45
|
+
declare function normalizeTokenTree(input: unknown, path?: string[]): unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Nest a flat map of dashed keys into a token tree.
|
|
48
|
+
* `--color-primary-500` / `color-primary-500` → `color.primary.500`.
|
|
49
|
+
*
|
|
50
|
+
* Scalar parents that also have children (e.g. `--radius` + `--radius-lg`) are
|
|
51
|
+
* preserved under `DEFAULT` so neither value is dropped.
|
|
52
|
+
*/
|
|
53
|
+
declare function nestFlatTokens(flat: Record<string, unknown>): Record<string, unknown>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/lib/tokens/resolve-path.d.ts
|
|
56
|
+
interface ResolveTokensPathOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Working directory used to resolve relative paths.
|
|
59
|
+
*/
|
|
60
|
+
cwd: string;
|
|
61
|
+
/**
|
|
62
|
+
* Explicit tokens file or directory from config.
|
|
63
|
+
*/
|
|
64
|
+
tokensPath?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Extra fallback paths (e.g. registry `tailwind.css`).
|
|
67
|
+
*/
|
|
68
|
+
fallbackPaths?: Array<string | null | undefined>;
|
|
69
|
+
}
|
|
70
|
+
interface ResolvedTokensSource {
|
|
71
|
+
/**
|
|
72
|
+
* Absolute path to the resolved file or directory (if any).
|
|
73
|
+
*/
|
|
74
|
+
resolvedPath?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Style Dictionary `source` globs.
|
|
77
|
+
*/
|
|
78
|
+
source: string[];
|
|
79
|
+
/**
|
|
80
|
+
* How the path was discovered.
|
|
81
|
+
*/
|
|
82
|
+
origin: "tokensPath" | "default" | "fallback" | "none";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolve Style Dictionary source globs from `tokensPath` or common defaults.
|
|
86
|
+
*/
|
|
87
|
+
declare function resolveTokensSource(options: ResolveTokensPathOptions): ResolvedTokensSource;
|
|
88
|
+
/**
|
|
89
|
+
* Detect theme-like basenames for splitting multi-file token sets.
|
|
90
|
+
*/
|
|
91
|
+
declare function themeKeyFromPath(filePath: string): string | undefined;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/lib/tokens/load.d.ts
|
|
94
|
+
interface LoadTokensOptions extends ResolveTokensPathOptions {
|
|
95
|
+
/**
|
|
96
|
+
* When true, split theme-named files into a record keyed by theme.
|
|
97
|
+
*
|
|
98
|
+
* @defaultValue true
|
|
99
|
+
*/
|
|
100
|
+
splitThemes?: boolean;
|
|
101
|
+
}
|
|
102
|
+
type LoadedTokens = Tokens | Record<string, Tokens>;
|
|
103
|
+
/**
|
|
104
|
+
* Load design tokens via Style Dictionary parser hooks.
|
|
105
|
+
*
|
|
106
|
+
* Resolution order:
|
|
107
|
+
* 1. Explicit `tokensPath` (file, directory, or SD config)
|
|
108
|
+
* 2. Common default paths (`tokens.json`, `tokens/`, …)
|
|
109
|
+
* 3. Fallback paths (e.g. registry Tailwind CSS)
|
|
110
|
+
*/
|
|
111
|
+
declare function loadTokens(config: Config, options: LoadTokensOptions): Promise<LoadedTokens>;
|
|
112
|
+
/**
|
|
113
|
+
* Convenience: load tokens or throw when nothing usable is found.
|
|
114
|
+
*
|
|
115
|
+
* @param config - The configuration object.
|
|
116
|
+
* @param options - The options for loading the tokens.
|
|
117
|
+
* @returns The loaded tokens.
|
|
118
|
+
* @throws An error if no design tokens are found.
|
|
119
|
+
* @throws An error if the tokens are not valid.
|
|
120
|
+
*/
|
|
121
|
+
declare function loadTokensOrThrow(config: Config, options: LoadTokensOptions): Promise<LoadedTokens>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/lib/tokens/parsers.d.ts
|
|
124
|
+
/** Preprocessor name applied after all sources merge. */
|
|
125
|
+
declare const RAZORWIND_INFER_PREPROCESSOR = "razorwind-infer";
|
|
126
|
+
/** Inline `hooks.parsers` map for Style Dictionary config. */
|
|
127
|
+
declare function getRazorwindParserHooks(): NonNullable<Hooks["parsers"]>;
|
|
128
|
+
/**
|
|
129
|
+
* Infer DTCG `$type` / normalize legacy keys after sources merge.
|
|
130
|
+
* Covers JS/TS modules that bypass custom file parsers.
|
|
131
|
+
*/
|
|
132
|
+
declare function razorwindInferPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
|
|
133
|
+
/** Inline `hooks.preprocessors` map for Style Dictionary config. */
|
|
134
|
+
declare function getRazorwindPreprocessorHooks(): NonNullable<Hooks["preprocessors"]>;
|
|
135
|
+
/**
|
|
136
|
+
* Register Razorwind parsers + infer preprocessor on Style Dictionary,
|
|
137
|
+
* then register any parsers / preprocessors contributed by plugins.
|
|
138
|
+
*
|
|
139
|
+
* @see https://styledictionary.com/reference/hooks/parsers/
|
|
140
|
+
*/
|
|
141
|
+
declare function registerRazorwindParsers(plugins?: Plugin[], target?: {
|
|
142
|
+
registerParser: (parser: Parser) => unknown;
|
|
143
|
+
registerPreprocessor: (preprocessor: {
|
|
144
|
+
name: string;
|
|
145
|
+
preprocessor: typeof razorwindInferPreprocessor;
|
|
146
|
+
}) => unknown;
|
|
147
|
+
}): void;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { DEFAULT_TOKEN_PATH_CANDIDATES, type InferredTokenType, type LoadTokensOptions, type LoadedTokens, RAZORWIND_INFER_PREPROCESSOR, type RazorwindParserName, type ResolveTokensPathOptions, type ResolvedTokensSource, THEME_BASENAME_PATTERN, TOKEN_DIRECTORY_GLOB, TOKEN_FILE_EXTENSIONS, TYPE_PATH_HINTS, TOKEN_PARSER_NAMES as WINDIE_PARSERS, TOKEN_PARSER_NAMES as razorwindParsers, getRazorwindParserHooks, getRazorwindPreprocessorHooks, inferTypeFromPath, inferValue, loadTokens, loadTokensOrThrow, nestFlatTokens, normalizeTokenTree, parseCssCustomProperties, razorwindInferPreprocessor, registerRazorwindParsers, resolveTokensSource, themeKeyFromPath };
|
|
150
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/tokens/constants.ts","../../../src/lib/tokens/css.ts","../../../src/lib/tokens/infer.ts","../../../src/lib/tokens/resolve-path.ts","../../../src/lib/tokens/load.ts","../../../src/lib/tokens/parsers.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"../../tokens-B8Dv91EB.mjs";export{s as DEFAULT_TOKEN_PATH_CANDIDATES,t as RAZORWIND_INFER_PREPROCESSOR,o as THEME_BASENAME_PATTERN,e as TOKEN_DIRECTORY_GLOB,v as TOKEN_FILE_EXTENSIONS,n as TYPE_PATH_HINTS,y as WINDIE_PARSERS,y as razorwindParsers,f as getRazorwindParserHooks,h as getRazorwindPreprocessorHooks,i as inferTypeFromPath,a as inferValue,g as loadTokens,d as loadTokensOrThrow,p as nestFlatTokens,u as normalizeTokenTree,_ as parseCssCustomProperties,r as razorwindInferPreprocessor,l as registerRazorwindParsers,m as resolveTokensSource,c as themeKeyFromPath};
|
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e}exports.definePlugin=e;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { d as TokensPreprocessor, l as Plugin, u as TokensParser } from "./config-Dj6RrLde.cjs";
|
|
2
|
+
//#region src/plugin.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Type helper for Razorwind plugins (`extract` / `validate` / `generate`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { definePlugin } from "@razorwind/core";
|
|
9
|
+
*
|
|
10
|
+
* // As a plugin
|
|
11
|
+
* export default definePlugin({
|
|
12
|
+
* name: "my-plugin",
|
|
13
|
+
* extract: async (spec) => {
|
|
14
|
+
* ...
|
|
15
|
+
* },
|
|
16
|
+
* validate: async () => {
|
|
17
|
+
* ...
|
|
18
|
+
* },
|
|
19
|
+
* generate: async () => {
|
|
20
|
+
* ...
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // As a plugin factory
|
|
25
|
+
* export default definePlugin((options) => ({
|
|
26
|
+
* name: "my-plugin",
|
|
27
|
+
* extract: async (spec) => {
|
|
28
|
+
* ...
|
|
29
|
+
* },
|
|
30
|
+
* validate: async () => {
|
|
31
|
+
* ...
|
|
32
|
+
* },
|
|
33
|
+
* generate: async () => {
|
|
34
|
+
* ...
|
|
35
|
+
* }
|
|
36
|
+
* }));
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function definePlugin(factory: (options: any) => Plugin): (options: any) => Plugin;
|
|
40
|
+
declare function definePlugin(plugin: Plugin): Plugin;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { type Plugin, type TokensParser, type TokensPreprocessor, definePlugin };
|
|
43
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0DgB,aACd,UAAU,iBAAiB,UACzB,iBAAiB;iBACL,aAAa,QAAQ,SAAS"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { d as TokensPreprocessor, l as Plugin, u as TokensParser } from "./config-DQHHeicR.mjs";
|
|
2
|
+
//#region src/plugin.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Type helper for Razorwind plugins (`extract` / `validate` / `generate`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { definePlugin } from "@razorwind/core";
|
|
9
|
+
*
|
|
10
|
+
* // As a plugin
|
|
11
|
+
* export default definePlugin({
|
|
12
|
+
* name: "my-plugin",
|
|
13
|
+
* extract: async (spec) => {
|
|
14
|
+
* ...
|
|
15
|
+
* },
|
|
16
|
+
* validate: async () => {
|
|
17
|
+
* ...
|
|
18
|
+
* },
|
|
19
|
+
* generate: async () => {
|
|
20
|
+
* ...
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // As a plugin factory
|
|
25
|
+
* export default definePlugin((options) => ({
|
|
26
|
+
* name: "my-plugin",
|
|
27
|
+
* extract: async (spec) => {
|
|
28
|
+
* ...
|
|
29
|
+
* },
|
|
30
|
+
* validate: async () => {
|
|
31
|
+
* ...
|
|
32
|
+
* },
|
|
33
|
+
* generate: async () => {
|
|
34
|
+
* ...
|
|
35
|
+
* }
|
|
36
|
+
* }));
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function definePlugin(factory: (options: any) => Plugin): (options: any) => Plugin;
|
|
40
|
+
declare function definePlugin(plugin: Plugin): Plugin;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { type Plugin, type TokensParser, type TokensPreprocessor, definePlugin };
|
|
43
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":""}
|
package/dist/plugin.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getEnvPaths as e}from"@stryke/env";import{findFilePath as t}from"@stryke/path/find";import{joinPaths as n}from"@stryke/path/join";import{replacePath as r}from"@stryke/path/replace";import{isFunction as i}from"@stryke/type-checks/is-function";import{isSetObject as a}from"@stryke/type-checks/is-set-object";import{isSetString as o}from"@stryke/type-checks/is-set-string";import{loadConfig as s}from"c12";import{defu as c}from"defu";import{createJiti as l}from"jiti";import{existsSync as u}from"node:fs";import d from"node:os";const f=d.homedir();async function p(d,p){let m=p.configFile&&u(r(p.configFile,d))?r(p.configFile,d):p.configFile&&u(p.configFile)?p.configFile:u(n(d,`razorwind.${p.mode}.config.ts`))?n(d,`razorwind.${p.mode}.config.ts`):u(n(d,`razorwind.${p.mode}.config.js`))?n(d,`razorwind.${p.mode}.config.js`):u(n(d,`razorwind.${p.mode}.config.mts`))?n(d,`razorwind.${p.mode}.config.mts`):u(n(d,`razorwind.${p.mode}.config.mjs`))?n(d,`razorwind.${p.mode}.config.mjs`):u(n(d,`razorwind.config.ts`))?n(d,`razorwind.config.ts`):u(n(d,`razorwind.config.js`))?n(d,`razorwind.config.js`):u(n(d,`razorwind.config.mts`))?n(d,`razorwind.config.mts`):u(n(d,`razorwind.config.mjs`))?n(d,`razorwind.config.mjs`):void 0,h=e({orgId:`storm-software`,appId:`razorwind`,workspaceRoot:d}),g={cacheDir:h.cache},_=l(d,g),v={};if(m){let e=await _.import(_.esmResolve(m));if(e?.default){let t={};i(e.default)?t=await Promise.resolve(e.default({cwd:d,mode:p.mode})):(a(e.default)||Array.isArray(e.default))&&(t=e.default),(a(t)||Array.isArray(t))&&(v={...t,configFile:m})}}let[y,b,x]=await Promise.all([s({cwd:d,name:`razorwind`,envName:p.mode,globalRc:!0,packageJson:`razorwind`,dotenv:!0,jitiOptions:g}),s({cwd:h.config,name:`razorwind`,envName:p.mode,dotenv:!0,jitiOptions:g}),s({cwd:f,name:`razorwind`,envName:p.mode,dotenv:!0,jitiOptions:g})]),S=c({cwd:d,envPaths:{...h,home:f}},p,v,a(y?.config)?{...y.config}:{},a(b?.config)?{...b.config}:{},a(x?.config)?{...x.config}:{},{registryPath:o(p.registryPath)?t(p.registryPath):d,plugins:[]});return Array.isArray(S.plugins)||(S.plugins=[]),S}export{p as t};
|
|
2
|
+
//# sourceMappingURL=resolve-config-CBowa3KM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-config-CBowa3KM.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-CMqjfN_6.cjs");let t=require("@stryke/env"),n=require("@stryke/path/find"),r=require("@stryke/path/join"),i=require("@stryke/path/replace"),a=require("@stryke/type-checks/is-function"),o=require("@stryke/type-checks/is-set-object"),s=require("@stryke/type-checks/is-set-string"),c=require("c12"),l=require("defu"),u=require("jiti"),d=require("node:fs"),f=require("node:os");f=e.t(f,1);const p=f.default.homedir();async function m(e,f){let m=f.configFile&&(0,d.existsSync)((0,i.replacePath)(f.configFile,e))?(0,i.replacePath)(f.configFile,e):f.configFile&&(0,d.existsSync)(f.configFile)?f.configFile:(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.${f.mode}.config.ts`))?(0,r.joinPaths)(e,`razorwind.${f.mode}.config.ts`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.${f.mode}.config.js`))?(0,r.joinPaths)(e,`razorwind.${f.mode}.config.js`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.${f.mode}.config.mts`))?(0,r.joinPaths)(e,`razorwind.${f.mode}.config.mts`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.${f.mode}.config.mjs`))?(0,r.joinPaths)(e,`razorwind.${f.mode}.config.mjs`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.config.ts`))?(0,r.joinPaths)(e,`razorwind.config.ts`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.config.js`))?(0,r.joinPaths)(e,`razorwind.config.js`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.config.mts`))?(0,r.joinPaths)(e,`razorwind.config.mts`):(0,d.existsSync)((0,r.joinPaths)(e,`razorwind.config.mjs`))?(0,r.joinPaths)(e,`razorwind.config.mjs`):void 0,h=(0,t.getEnvPaths)({orgId:`storm-software`,appId:`razorwind`,workspaceRoot:e}),g={cacheDir:h.cache},_=(0,u.createJiti)(e,g),v={};if(m){let t=await _.import(_.esmResolve(m));if(t?.default){let n={};(0,a.isFunction)(t.default)?n=await Promise.resolve(t.default({cwd:e,mode:f.mode})):((0,o.isSetObject)(t.default)||Array.isArray(t.default))&&(n=t.default),((0,o.isSetObject)(n)||Array.isArray(n))&&(v={...n,configFile:m})}}let[y,b,x]=await Promise.all([(0,c.loadConfig)({cwd:e,name:`razorwind`,envName:f.mode,globalRc:!0,packageJson:`razorwind`,dotenv:!0,jitiOptions:g}),(0,c.loadConfig)({cwd:h.config,name:`razorwind`,envName:f.mode,dotenv:!0,jitiOptions:g}),(0,c.loadConfig)({cwd:p,name:`razorwind`,envName:f.mode,dotenv:!0,jitiOptions:g})]),S=(0,l.defu)({cwd:e,envPaths:{...h,home:p}},f,v,(0,o.isSetObject)(y?.config)?{...y.config}:{},(0,o.isSetObject)(b?.config)?{...b.config}:{},(0,o.isSetObject)(x?.config)?{...x.config}:{},{registryPath:(0,s.isSetString)(f.registryPath)?(0,n.findFilePath)(f.registryPath):e,plugins:[]});return Array.isArray(S.plugins)||(S.plugins=[]),S}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../schema-CLeH9GGy.cjs");let t=require("@power-plant/dtcg-schema");exports.componentFileSchema=e.n,exports.componentSchema=e.r,exports.componentsSchema=e.i,exports.schema=e.t,Object.defineProperty(exports,"tokenSchema",{enumerable:!0,get:function(){return t.tokenSchema}}),Object.defineProperty(exports,"tokensSchema",{enumerable:!0,get:function(){return t.tokensSchema}});
|