@cyclone-ui/theme-builder 0.0.0-stage → 0.0.4
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/CHANGELOG.md +15 -0
- package/LICENSE +187 -0
- package/README.md +305 -2
- package/dist/generate.cjs +1 -0
- package/dist/generate.d.cts +5 -0
- package/dist/generate.d.cts.map +1 -0
- package/dist/generate.d.mts +6 -0
- package/dist/generate.d.mts.map +1 -0
- package/dist/generate.mjs +2 -0
- package/dist/generate.mjs.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/preprocessor.cjs +1 -0
- package/dist/preprocessor.d.cts +4 -0
- package/dist/preprocessor.d.cts.map +1 -0
- package/dist/preprocessor.d.mts +5 -0
- package/dist/preprocessor.d.mts.map +1 -0
- package/dist/preprocessor.mjs +2 -0
- package/dist/preprocessor.mjs.map +1 -0
- package/package.json +70 -3
- package/powerlines.config.ts +28 -0
- package/project.json +8 -0
- package/src/generate.ts +66 -0
- package/src/index.ts +22 -0
- package/src/preprocessor.ts +1524 -0
- package/test/preprocessor.spec.ts +518 -0
- package/test/shiki-theme-mapping.spec.ts +160 -0
- package/test/storybook-theme-mapping.spec.ts +118 -0
- package/tsconfig.json +13 -0
- package/tsconfig.spec.json +16 -0
- package/vitest.config.mts +24 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function b(e){if(Array.isArray(e))return e.map(e=>b(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function ne(e,t){if(t===`shadow`)return b(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function x(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function re(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=x(e,t);return`$value`in e?{...e,$value:ne(e.$value,n)}:{...e}}function S(e,t){if(Array.isArray(e))return e.map(e=>S(e,t));if(!i(e))return e;if(a(e))return re(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:S(i,n);return o}const ie={dark:`#ffffff`,light:`#0c0c0d`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function ae(e){if(i(e)&&i(e.color))return C(e.color.$description)}const oe={name:`active`,brightness:1.45,useContrastPrimitive:!0},se={name:`active`,brightness:1.25},ce={name:`active`,brightness:1.075},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},w={name:`inactive`,brightness:.8},T={name:`inactive`,brightness:.6,useContrastPrimitive:!0},E={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},D={lowSaturation:[oe,T,E],saturated:[se,w,E]},fe={lowSaturation:[le,T,E],saturated:D.saturated},pe={lowSaturation:[ce,w,E],saturated:D.saturated},me=[`danger`,`warning`,`info`,`discovery`,`success`],he={primary:`base`,tertiary:`base-subtle`},O=[`base`,...me],ge={border:{lowSaturation:[de,T,E],saturated:[ue,w,E]},...Object.fromEntries(O.flatMap(e=>[[e,D],[`${e}-subtle`,fe]]))},k=7.25,A=.01;function _e(e){return e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ve(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function j(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ve(t,i[1]);if(a&&`$value`in a)return j(a.$value,t,n)}function M(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function ye(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function N(e,t,n=!1){if(Array.isArray(e))return e.map(e=>N(e,t,n));if(!i(e))return e;if(n&&a(e)&&x(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=j(e.color,t);return n?{...e,color:M(n,F(n)?.2:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=N(a,t,n||i.toLowerCase()===`ring`);return r}function P(e,t){let n={value:0,unit:`px`};return{color:e,offsetX:n,offsetY:n,blur:n,spread:{value:t,unit:`px`}}}function be(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let e of O){if(!a(t[e]))continue;let i=`{color.${e}}`,o=P(`{color.surface-elevated}`,3),s={[e]:[`${e} 3px focus ring with no gap`,[P(i,3)]],[`${e}-subtle`]:[`${e} 1px hairline focus ring with no gap`,[P(i,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[o,P(i,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 3px gap`,[o,P(i,4)]]};for(let[t,[i,a]]of Object.entries(s))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:a,theme:Z(e)},r=!0)}return r?{...e,ring:n}:e}function F(e){return L(e).chroma<.02}function I(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function L(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function R({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function z(e,t,n,r){if(R(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;R(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function B(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=L(e);return g(s(n*t),r,i,a)}function xe(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=L(e);return g(s(n+t),r,i,a)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=L(e);return g(n,r*s(t),i,a)}function V(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function H(e,t){let n=V(e),r=V(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function U(e){let t=H(e,`#FAFAFA`);return t>=2?`#FAFAFA`:H(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=L(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*A),d=z(l,r,i,a),H(d,f)>=k)return f===e?{subtle:d}:{subtle:d,onMuted:f};if(u=s(u+c*A),f=z(u,r,i,a),H(d,f)>=k)return{subtle:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible subtle pair for ${e}`)}function we(e,t){return t===`dark`?W(e):t===`light`?!G(e):L(e).lightness>=.5}function Te(e,t){return!we(e,t)}function W(e){return L(e).lightness>=.75}function G(e){return L(e).lightness<=.25}function Ee(e,t,n){return Te(e,n)?t:2-t}function K(e,t){return e.useContrastPrimitive&&t?ie[t]:void 0}function q(e,t,n){if(t.name===`active`&&K(t,n)){if(n===`dark`&&W(e))return-.1;if(n===`light`&&G(e))return .1}}function J(e,t,n){return t.brightness===void 0?1:K(t,n)?t.name===`active`?1:t.brightness:Ee(e,t.brightness,n)}function De(e,t,n){let r=q(e,t,n),i=r===void 0?K(t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&t.name===`active`)&&(a=B(a,J(a,t,n))):a=xe(e,r),t.saturation!==void 0&&!I(e)&&(a=Se(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:M(a,t.opacity):ye(a,t.fadeOver,t.opacity??1)}function Oe(e,t,n){let r=[],i=q(t,e,n),a=K(e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&e.name===`active`)r.push(`${n} contrast primitive`);else if(e.brightness!==void 0){let i=J(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!I(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||I(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function ke(e,t,n,r){let i=Oe(n,t,r),a=De(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Y(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||_e(r))continue;let s=e[r];if(!a(s))continue;let c=x(s);if(c&&c!==`color`)continue;let l=j(s.$value,t);if(!l)continue;let u=F(l)?n.lowSaturation:n.saturated,d=C(s.$description)??i;for(let e of u){let t=`${r}-${e.name}`;t in o||(o[t]=ke(s,l,e,d))}}return o}function Ae(e,t,n){let r={...e};for(let i of O){let o=e[i];if(!a(o))continue;let s=x(o),c=j(o.$value,t);if(s&&s!==`color`||!c)continue;let l=e[`on-${i}`];delete r[`on-${i}`],r[`on-${i}-accent`]??=a(l)?{...l,theme:i,group:i}:{...o,$type:`color`,$value:U(c),$description:`Generated text and icon color on ${i} backgrounds`,theme:i,group:i},r[`${i}-accent`]??={$type:`color`,$value:`{color.${i}}`,$description:`Alias of ${i} for the ${i} theme`,theme:i,group:i};let u;if(n&&!(`${i}-subtle`in e)){let e=Ce(c,n);r[`${i}-subtle`]={...o,$type:`color`,$value:e.subtle,$description:`Generated low-emphasis ${i} background for the ${n} theme`},u=e.onMuted??c}else if(a(e[`${i}-subtle`])){let n=j(e[`${i}-subtle`].$value,t);u=n&&U(n)}u&&!(`on-${i}-subtle`in e)&&(r[`on-${i}-subtle`]={...o,$type:`color`,$value:u,$description:`Generated text and icon color on ${i}-subtle backgrounds`})}return r}function X(e){return e.replace(/^on-/,``).replace(/-(?:active|inactive|disabled)$/i,``).replace(/-subtle$/,``)}function Z(e){let t=X(e);return O.includes(t)?t:void 0}function je(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=X(n),i=he[e];i&&a(r)&&(t[n.replace(e,i)]??={...r,theme:`base`,group:`base`})}return t}function Me(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=Z(n);e&&a(r)&&!(`theme`in r)&&(t[n]={...r,theme:e})}return t}function Q(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=X(n);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);if(n?.startsWith(`surface-`))return Q(Y(s,t,pe,void 0,o));let c=n===`color`?Ae(je(s),t,o):s;for(let[e,n]of Object.entries(ge))a(c[e])&&(c=Y(c,t,n,e,o));return n===`color`?Q(Me(c)):c}function Ne(e){let t=S(e),n=be($(t,t,void 0,ae(t)));return N(n,n)}var Pe=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:Ne}]}));export{Pe as default};
|
|
2
|
+
//# sourceMappingURL=preprocessor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SURFACE_LOW_SATURATION_COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","BORDER_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","SURFACE_COLOR_STATE_VARIANTS","STATUS_COLOR_KEYS","BASE_THEME_COLOR_NAMES","THEME_COLOR_KEYS","COLOR_STATE_VARIANTS","MINIMUM_SUBTLE_CONTRAST_RATIO","SUBTLE_COLOR_LIGHTNESS_STEP","isStateVariantKey","getTokenAtPath","tree","part","path","resolveColorHex","direct","ref","seen","applyOpacity","rgb","opacity","applyFadeOver","foreground","base","background","offset","applyRingOpacity","inRingGroup","applyToLayer","isLowSaturation","index","ringLayer","zero","spread","addMissingRingTokens","ring","changed","name","ringColor","gap","variants","colorTokenTheme","hexToOklch","isGreyscale","l","m","s","isInSrgbGamut","oklchToGamutMappedHex","minimumChroma","maximumChroma","candidateChroma","applyBrightness","factor","applyLightnessShift","shift","applySaturation","relativeLuminance","contrastRatio","firstLuminance","first","secondLuminance","second","lighter","darker","createOnColor","whiteContrast","createMutedColor","subtleDirection","parentTheme","onMutedDirection","subtleLightness","onMutedLightness","subtle","onMuted","isLightColor","isWhiteColor","isBlackColor","isDarkColor","directedBrightnessFactor","contrastPrimitive","variant","contrastSideLightnessShift","stateBrightnessFactor","applyStateTransform","primitive","transformed","variantDetail","details","percent","createStateToken","detail","source","addColorStateTokens","group","names","onlyKey","tokenVariants","tokenParentTheme","variantKey","addMissingStatusCompanionTokens","onToken","pair","subtleHex","colorTokenRoot","root","addBaseThemeAliases","baseName","addColorTokenThemes","addColorTokenGroups","injectColorStateVariants","childKey","withStates","tokenKey","tamaguiPreprocessor","converted","withRings","preprocessor_default","definePlugin"],"sources":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclone-ui/theme-builder",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "A package for building themes within the Cyclone UI project",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "github",
|
|
11
|
+
"url": "https://github.com/storm-software/cyclone-ui.git",
|
|
12
|
+
"directory": "packages/theme-builder"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"default": "./dist/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"default": {
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"default": "./dist/index.mjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./generate": {
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/generate.d.cts",
|
|
32
|
+
"default": "./dist/generate.cjs"
|
|
33
|
+
},
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/generate.d.mts",
|
|
36
|
+
"default": "./dist/generate.mjs"
|
|
37
|
+
},
|
|
38
|
+
"default": {
|
|
39
|
+
"types": "./dist/generate.d.mts",
|
|
40
|
+
"default": "./dist/generate.mjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json",
|
|
44
|
+
"./preprocessor": {
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/preprocessor.d.cts",
|
|
47
|
+
"default": "./dist/preprocessor.cjs"
|
|
48
|
+
},
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/preprocessor.d.mts",
|
|
51
|
+
"default": "./dist/preprocessor.mjs"
|
|
52
|
+
},
|
|
53
|
+
"default": {
|
|
54
|
+
"types": "./dist/preprocessor.d.mts",
|
|
55
|
+
"default": "./dist/preprocessor.mjs"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"main": "./dist/index.cjs",
|
|
60
|
+
"module": "./dist/index.mjs",
|
|
61
|
+
"types": "./dist/index.d.cts",
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@razorwind/core": "^0.0.91",
|
|
64
|
+
"@razorwind/style-dictionary": "^0.0.77",
|
|
65
|
+
"@razorwind/tamagui": "^0.0.94",
|
|
66
|
+
"style-dictionary": "^5.6.1"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@powerlines/plugin-tsdown": "^0.1.615",
|
|
70
|
+
"@types/node": "^25.9.9",
|
|
71
|
+
"powerlines": "^0.47.214"
|
|
72
|
+
}
|
|
6
73
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* -------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
🗲 Storm Software - Cyclone UI
|
|
4
|
+
|
|
5
|
+
This code was released as part of the Cyclone UI project. Cyclone UI
|
|
6
|
+
is maintained by Storm Software under the Apache-2.0 license, and is
|
|
7
|
+
free for commercial and private use. For more information, please visit
|
|
8
|
+
our licensing page at https://stormsoftware.com/licenses/projects/cyclone-ui.
|
|
9
|
+
|
|
10
|
+
Website: https://stormsoftware.com
|
|
11
|
+
Repository: https://github.com/storm-software/cyclone-ui
|
|
12
|
+
Documentation: https://docs.stormsoftware.com/projects/cyclone-ui
|
|
13
|
+
Contact: https://stormsoftware.com/contact
|
|
14
|
+
|
|
15
|
+
SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
------------------------------------------------------------------- */
|
|
18
|
+
|
|
19
|
+
import { plugin as tsdown } from "@powerlines/plugin-tsdown";
|
|
20
|
+
import type { UserConfig } from "powerlines";
|
|
21
|
+
import { defineConfig } from "powerlines/config";
|
|
22
|
+
|
|
23
|
+
const config: UserConfig = defineConfig({
|
|
24
|
+
input: ["src/**/*.ts"],
|
|
25
|
+
plugins: [tsdown()]
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default config;
|
package/project.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "theme-builder",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"projectType": "library",
|
|
5
|
+
"sourceRoot": "packages/theme-builder/src",
|
|
6
|
+
"// targets": "to see all targets run: nx show project theme-builder --web",
|
|
7
|
+
"targets": {}
|
|
8
|
+
}
|
package/src/generate.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* -------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
🗲 Storm Software - Cyclone UI
|
|
4
|
+
|
|
5
|
+
This code was released as part of the Cyclone UI project. Cyclone UI
|
|
6
|
+
is maintained by Storm Software under the Apache-2.0 license, and is
|
|
7
|
+
free for commercial and private use. For more information, please visit
|
|
8
|
+
our licensing page at https://stormsoftware.com/licenses/projects/cyclone-ui.
|
|
9
|
+
|
|
10
|
+
Website: https://stormsoftware.com
|
|
11
|
+
Repository: https://github.com/storm-software/cyclone-ui
|
|
12
|
+
Documentation: https://docs.stormsoftware.com/projects/cyclone-ui
|
|
13
|
+
Contact: https://stormsoftware.com/contact
|
|
14
|
+
|
|
15
|
+
SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
------------------------------------------------------------------- */
|
|
18
|
+
|
|
19
|
+
import { definePlugin } from "@razorwind/core/plugin";
|
|
20
|
+
import type { TamaguiPluginOptions } from "@razorwind/tamagui";
|
|
21
|
+
import tamagui from "@razorwind/tamagui/generate";
|
|
22
|
+
|
|
23
|
+
export default definePlugin((options: TamaguiPluginOptions = {}) => {
|
|
24
|
+
const tamaguiPlugin = tamagui({
|
|
25
|
+
animations: "motion",
|
|
26
|
+
defaultFont: "body-md",
|
|
27
|
+
target: "v3",
|
|
28
|
+
...options
|
|
29
|
+
});
|
|
30
|
+
const generateTamagui = tamaguiPlugin.generate;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...tamaguiPlugin,
|
|
34
|
+
name: "cyclone-ui:tamagui-generate",
|
|
35
|
+
|
|
36
|
+
generate: async (
|
|
37
|
+
...[spec, config]: Parameters<NonNullable<typeof generateTamagui>>
|
|
38
|
+
) => {
|
|
39
|
+
if (!generateTamagui || !spec.fonts) {
|
|
40
|
+
return generateTamagui?.(spec, config) ?? {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const fonts = Object.fromEntries(
|
|
44
|
+
Object.entries(spec.fonts).map(([name, font]) => {
|
|
45
|
+
if (font.source !== "local" || !font.files) {
|
|
46
|
+
return [name, font];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [
|
|
50
|
+
name,
|
|
51
|
+
{
|
|
52
|
+
...font,
|
|
53
|
+
files: font.files.filter(
|
|
54
|
+
file =>
|
|
55
|
+
typeof file.weight !== "string" ||
|
|
56
|
+
/^\d+(?:\.\d+)?$/u.test(file.weight.trim())
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
})
|
|
61
|
+
) as typeof spec.fonts;
|
|
62
|
+
|
|
63
|
+
return generateTamagui({ ...spec, fonts }, config);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* -------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
🗲 Storm Software - Cyclone UI
|
|
4
|
+
|
|
5
|
+
This code was released as part of the Cyclone UI project. Cyclone UI
|
|
6
|
+
is maintained by Storm Software under the Apache-2.0 license, and is
|
|
7
|
+
free for commercial and private use. For more information, please visit
|
|
8
|
+
our licensing page at https://stormsoftware.com/licenses/projects/cyclone-ui.
|
|
9
|
+
|
|
10
|
+
Website: https://stormsoftware.com
|
|
11
|
+
Repository: https://github.com/storm-software/cyclone-ui
|
|
12
|
+
Documentation: https://docs.stormsoftware.com/projects/cyclone-ui
|
|
13
|
+
Contact: https://stormsoftware.com/contact
|
|
14
|
+
|
|
15
|
+
SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
------------------------------------------------------------------- */
|
|
18
|
+
|
|
19
|
+
import generate from "./generate";
|
|
20
|
+
import preprocessor from "./preprocessor";
|
|
21
|
+
|
|
22
|
+
export { generate, preprocessor };
|