@razorwind/tamagui 0.0.53 → 0.0.54
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/index.cjs +49 -19
- package/dist/index.d.cts +4 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +51 -21
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin"),t=require("@razorwind/core/utils"),n=require("node:path"),r=require("@razorwind/core/lib/fonts");function i(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`).replaceAll(`
|
|
2
|
-
`,`\\n`).replaceAll(`\r`,`\\r`)}function a(e){return typeof e==`string`?`"${i(e)}"`:typeof e==`number`||typeof e==`boolean`?String(e):e==null?`undefined`:JSON.stringify(e)}function o(e,n){if(typeof e==`number`)return e;if(typeof e==`boolean`)return Number(e);if((0,t.isObject)(e)&&typeof e.value==`number`&&typeof e.unit==`string`){let t=e.unit.toLowerCase();return t===`px`||t===``?e.value:t===`rem`?e.value*16:`${e.value}${e.unit}`}if(typeof e==`string`){let t=/^(-?\d+(?:\.\d+)?)px$/i.exec(e.trim());if(t)return Number(t[1]);let n=/^(-?\d+(?:\.\d+)?)rem$/i.exec(e.trim());if(n)return Number(n[1])*16;let r=Number(e);return!Number.isNaN(r)&&e.trim()!==``?r:e}return(0,t.formatTokenValue)(e,n)}const s=/^(?:font-size|fontSize)(?:\.|$)/i,c=/^(?:font-weight|fontWeight)(?:\.|$)/i,l=/^shadow(?:\.|$)/i,u=/^inset-shadow(?:\.|$)/i,d=/^drop-shadow(?:\.|$)/i,f=/^text-shadow(?:\.|$)/i,p=/^(?:blur|blur-?radius)(?:\.|$)/i,m=new Set([`color`,`shadow`,`insetShadow`,`dropShadow`,`textShadow`]),h=[{prefix:/^(?:color|colours?|palette)(?:\.|$)/i,category:`color`},{prefix:s,category:`fontSize`},{prefix:c,category:`fontWeight`},{prefix:d,category:`dropShadow`},{prefix:u,category:`insetShadow`},{prefix:f,category:`textShadow`},{prefix:l,category:`shadow`},{prefix:p,category:`blur`},{prefix:/^(?:space|spacing|gap)(?:\.|$)/i,category:`space`},{prefix:/^inset(?:\.|$)/i,category:`space`},{prefix:/^(?:size|sizing)(?:\.|$)/i,category:`size`},{prefix:/^(?:radius|rounded|radii)(?:\.|$)/i,category:`radius`},{prefix:/^(?:z-?index|zindex|elevation)(?:\.|$)/i,category:`zIndex`}];function g(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function _(e){return e===!0||e===`true`||e===1}function ee(e){return _(e.palette)||_(e.$palette)?!0:
|
|
3
|
-
`)}\n }`}function
|
|
4
|
-
`)}\n${r}}`}function
|
|
5
|
-
`)}\n});`}function
|
|
2
|
+
`,`\\n`).replaceAll(`\r`,`\\r`)}function a(e){return typeof e==`string`?`"${i(e)}"`:typeof e==`number`||typeof e==`boolean`?String(e):e==null?`undefined`:JSON.stringify(e)}function o(e,n){if(typeof e==`number`)return e;if(typeof e==`boolean`)return Number(e);if((0,t.isObject)(e)&&typeof e.value==`number`&&typeof e.unit==`string`){let t=e.unit.toLowerCase();return t===`px`||t===``?e.value:t===`rem`?e.value*16:`${e.value}${e.unit}`}if(typeof e==`string`){let t=/^(-?\d+(?:\.\d+)?)px$/i.exec(e.trim());if(t)return Number(t[1]);let n=/^(-?\d+(?:\.\d+)?)rem$/i.exec(e.trim());if(n)return Number(n[1])*16;let r=Number(e);return!Number.isNaN(r)&&e.trim()!==``?r:e}return(0,t.formatTokenValue)(e,n)}const s=/^(?:font-size|fontSize)(?:\.|$)/i,c=/^(?:font-weight|fontWeight)(?:\.|$)/i,l=/^shadow(?:\.|$)/i,u=/^inset-shadow(?:\.|$)/i,d=/^drop-shadow(?:\.|$)/i,f=/^text-shadow(?:\.|$)/i,p=/^(?:blur|blur-?radius)(?:\.|$)/i,m=new Set([`color`,`shadow`,`insetShadow`,`dropShadow`,`textShadow`]),h=[{prefix:/^(?:color|colours?|palette)(?:\.|$)/i,category:`color`},{prefix:s,category:`fontSize`},{prefix:c,category:`fontWeight`},{prefix:d,category:`dropShadow`},{prefix:u,category:`insetShadow`},{prefix:f,category:`textShadow`},{prefix:l,category:`shadow`},{prefix:p,category:`blur`},{prefix:/^(?:space|spacing|gap)(?:\.|$)/i,category:`space`},{prefix:/^inset(?:\.|$)/i,category:`space`},{prefix:/^(?:size|sizing)(?:\.|$)/i,category:`size`},{prefix:/^(?:radius|rounded|radii)(?:\.|$)/i,category:`radius`},{prefix:/^(?:z-?index|zindex|elevation)(?:\.|$)/i,category:`zIndex`}];function g(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function _(e){return e===!0||e===`true`||e===1}function ee(e){return _(e.palette)||_(e.$palette)?!0:S(e)===`palette`}function te(e,t){return(e===`palette`||e===`$palette`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function ne(e){return e===!0||e===`true`||e===1}function v(e){return ne(e.primitive)||ne(e.$primitive)?!0:S(e)===`primitive`}function y(e,t){return(e===`primitive`||e===`$primitive`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function b(e,t){return(e===`theme`||e===`$theme`)&&typeof t==`string`}function x(e){if(typeof e.theme==`string`&&e.theme.length>0)return e.theme;if(typeof e.$theme==`string`&&e.$theme.length>0)return e.$theme}function re(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function S(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(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 C(e,t){for(let{prefix:t,category:n}of h)if(t.test(e))return n;if(t===`color`||t===`palette`)return`color`;if(t===`shadow`)return u.test(e)?`insetShadow`:d.test(e)?`dropShadow`:f.test(e)?`textShadow`:`shadow`;if(t===`dimension`){if(s.test(e))return`fontSize`;if(p.test(e))return`blur`;if(/(?:^|\.)(?:space|spacing|gap)(?:\.|$)/i.test(e)||/(?:^|\.)inset(?:\.|$)/i.test(e))return`space`;if(/radius|rounded/i.test(e))return`radius`;if(/z-?index|elevation/i.test(e))return`zIndex`;if(/(?:^|\.)(?:size|sizing)(?:\.|$)/i.test(e)||/(?:^|\.)(?:width|height)(?:\.|$)/i.test(e))return`size`}if(t===`number`&&/z-?index|elevation/i.test(e))return`zIndex`;if(t===`fontWeight`||c.test(e))return`fontWeight`}function w(e){return e.flatMap(e=>e.split(/[-_\s]+/)).filter(Boolean).map((e,t)=>{if(/^\d/.test(e))return e;let n=e.toLowerCase();return t===0?n:`${n.charAt(0).toUpperCase()}${n.slice(1)}`}).join(``)}function ae(e){let t=e.split(`.`).filter(Boolean),n=t[0];n&&/^(?:color|colours?|palette|primitive|space|spacing|gap|inset|shadow|inset-shadow|drop-shadow|text-shadow|font-size|fontSize|font-weight|fontWeight|size|sizing|radius|rounded|radii|z-?index|zindex|elevation|blur)$/i.test(n)&&t.shift();let r=t.length>0?t:e.split(`.`).slice(-1);return r.length===1&&/^(?:DEFAULT|default)$/i.test(r[0]??``)?`true`:w(r)}function T(e,n,r,i,a,s,c){if(!(0,t.isObject)(e))return;let l=a||v(e)||ee(e),u=S(e,r),d=x(e)??s;if(g(e)){let r=ie(e),a=n.join(`.`),s=C(a,u)??(l||u===`primitive`||u===`palette`?`color`:void 0),f=(0,t.formatTokenValue)(r,u),p=s&&m.has(s)||u===`color`||u===`palette`||u===`primitive`||u===`shadow`?f:o(r,u);c.push({path:a,type:u===`palette`||u===`primitive`?`color`:u,value:r,cssValue:f,tamaguiValue:p,category:s,tokenKey:s?ae(a):void 0,description:re(e),theme:i,...d?{childTheme:d}:{},...l?{primitive:!0}:{}});return}for(let[t,r]of Object.entries(e))t.startsWith(`$`)&&t!==`$palette`&&t!==`$primitive`||te(t,r)||y(t,r)||b(t,r)||T(r,[...n,t],u,i,l,d,c)}function E(e,n={}){let r=n.includeTypes?new Set(n.includeTypes):void 0,i=[];for(let n of(0,t.resolveTokenSets)(e)){let e=n.id==="default"?void 0:n.id;T(n.tokens,[],void 0,e,!1,void 0,i)}return r?i.filter(e=>!e.type||r.has(e.type)):i}const D=/^\{([^{}]+)\}$/,oe=/^(?:typography|type|text)$/i,se=/^(?:font|fonts|font-family|fontFamily)$/i,O=/^(?:font-size|fontSize)$/i,k=/^(?:font-weight|fontWeight)$/i,A=/^(?:line-height|lineHeight|leading)$/i,ce=/^(?:letter-spacing|letterSpacing|tracking)$/i,le=/^(?:[a-z]{2}(?:-[A-Z]{2})?|cn|zh|jp|ja|kr|ko|ar|he|th|hi|ru|french|mandarin|chinese|japanese|korean|arabic|hebrew)$/i,j=[`fontFamily`,`font-family`,`family`],ue=[`fontSize`,`font-size`,`size`],de=[`fontWeight`,`font-weight`,`weight`],M=[`lineHeight`,`line-height`,`leading`],fe=[`letterSpacing`,`letter-spacing`,`tracking`],pe={1:12,2:14,3:16,4:18,5:20,6:24,7:28,8:32,9:40,10:48};function N(e){if(typeof e==`string`)return D.exec(e.trim())?.[1]?.trim()}function P(e,t){let n=N(e);if(!n)return e;let r=t.get(n),i=new Set([n]);for(let e=0;e<8&&r;e++){let e=N(r.value);if(!e||i.has(e))return r.value;i.add(e),r=t.get(e)}return r?.value??e}function F(e,t){for(let n of t)if(e[n]!==void 0&&e[n]!==null)return e[n]}function me(e){return(e.split(`,`)[0]?.trim()??e).replaceAll(/^["']|["']$/g,``)}function he(e){if(typeof e==`string`){let t=e.trim();return t.length===0||N(t)?void 0:t}if(Array.isArray(e)&&e.every(e=>typeof e==`string`)){let t=e.map(e=>e.trim()).filter(Boolean);return t.length>0?t.join(`, `):void 0}}function ge(e){return Number.isInteger(e)?e:Math.round(e*1e3)/1e3}function _e(e){if(e==null)return;let t=o(e);if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`){let e=/^(-?\d+(?:\.\d+)?)%$/.exec(t.trim());if(e)return Number.parseFloat(e[1])/100}}function ve(e){if(typeof e==`number`&&Number.isFinite(e))return String(e);if(typeof e==`string`){let t=e.trim();if(t.length===0||N(t))return;let n=Number(t);return Number.isNaN(n)?t:String(n)}let t=o(e);if(typeof t==`number`&&Number.isFinite(t))return String(t);if(typeof t==`string`&&t.length>0)return t}function ye(e,t){let n=_e(e);if(n!=null)return ge(t!=null&&n>0&&n<=4?n*t:n)}function I(e,t){return t.test(e.split(`.`)[0]??``)}function be(e){return e.split(`.`).filter(Boolean).at(-1)??e}function xe(e,t){let n=e.split(`.`).filter(Boolean);return n[0]&&t.test(n[0])&&n.shift(),n}function Se(e){let t=e.flatMap(e=>e.split(`-`)).filter(Boolean);return t.length===0?`body`:t.map((e,t)=>t===0?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(``)}function L(e){switch(e.toLowerCase()){case`sans`:case`body`:case`serif`:return`body`;case`monospace`:case`mono`:return`mono`;default:return Se([e])}}function Ce(e){return e.role?L(e.role):L(e.name)}function we(e){let t=xe(e,oe);if(t.length===0)return`body`;let n=t.at(-1);return n&&t.length>=2&&le.test(n)&&!n.includes(`_`)?`${t.slice(0,-1).join(`-`)}_${n}`:t.join(`-`)}function Te(e){return L(xe(e,se)[0]??be(e))}function Ee(e,t){let n=xe(e,t);return n.length===0||n.length===1&&/^(?:DEFAULT|default)$/i.test(n[0])?`true`:Se(n)}function De(e){return e.type===`typography`&&(0,t.isObject)(e.value)}function Oe(e){return e.category===`fontSize`||e.category===`fontWeight`||ke(e)||Ae(e)||je(e)||Me(e)?!1:e.type===`fontFamily`||I(e.path,se)}function ke(e){return e.category===`fontSize`||I(e.path,O)}function Ae(e){return e.category===`fontWeight`||e.type===`fontWeight`||I(e.path,k)}function je(e){return I(e.path,A)}function Me(e){return I(e.path,ce)}function Ne(e,t){if(!e.has(t))return t;let n=2,r=`${t}${n}`;for(;e.has(r);)n++,r=`${t}${n}`;return r}function Pe(e){let t=new Map;for(let n of Object.values(e)){let e=Ce(n);t.has(e)&&(e=Ne(t,Se([n.name]))),t.set(e,n)}return t}function Fe(e,t,n){if(!e)return;let i=Object.values(e);if(i.length===0)return;if(n){let e=n.split(`.`).filter(Boolean).at(-1);if(e){let t=i.find(t=>t.role===e||t.name.toLowerCase()===e.toLowerCase());if(t)return t}}if(!t)return;let a=me(t).toLowerCase();return i.find(e=>(0,r.fontFamilyName)(e).toLowerCase()===a||e.title.toLowerCase()===a||e.name.toLowerCase()===a)}function Ie(e){let t=new Map;for(let r of e.files){let e=String(r.weight??400),i=(0,n.basename)(r.path).replace(/\.[^.]+$/,``),a=t.get(e)??{};r.style===`italic`||r.style===`oblique`?a.italic=i:a.normal=i,t.set(e,a)}if(t.size!==0)return`{\n${[...t.entries()].toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0})).map(([e,t])=>{let n=[];return t.normal&&n.push(`normal: ${a(t.normal)}`),t.italic&&n.push(`italic: ${a(t.italic)}`),` ${e}: { ${n.join(`, `)} }`}).join(`,
|
|
3
|
+
`)}\n }`}function Le(e,t){return{...e,webFamily:(0,r.cssFontFamily)(t),nativeFamily:(0,r.fontFamilyName)(t),face:t.source===`local`?Ie(t):e.face}}function R(e){return{key:e,webFamily:`system-ui, sans-serif`,nativeFamily:`system-ui`,size:{},lineHeight:{},weight:{},letterSpacing:{}}}function Re(e,t){return{...e,webFamily:t,nativeFamily:me(t)}}const ze=/^(?:font-size|fontSize|font-weight|fontWeight|line-height|lineHeight|leading|letter-spacing|letterSpacing|tracking)$/i;function z(e,t){let n={true:e},r=N(t);if(!r)return n;let i=Ee(r,ze);return i&&i!==`true`&&(n[i]=e),n}function Be(e){return Object.keys(e.size).length>0?e:{...e,size:{...pe}}}function Ve(e,n,r,i){if(!(0,t.isObject)(n.value))return e;let a=F(n.value,j),o=N(a),s=he(P(a,r)),c=Fe(i,s,o),l=e;c?l=Le(l,c):s&&(l=Re(l,s));let u=F(n.value,ue),d=_e(P(u,r));d!=null&&(l={...l,size:z(d,u)});let f=F(n.value,de),p=ve(P(f,r));p&&(l={...l,weight:z(p,f)});let m=F(n.value,fe),h=_e(P(m,r));h!=null&&(l={...l,letterSpacing:z(h,m)});let g=F(n.value,M),_=ye(P(g,r),l.size.true??d);return _!=null&&(l={...l,lineHeight:z(_,g)}),He(l)}function He(e){let t=Object.keys(e.size);if(t.length===0)return e;let n=e=>{let n=e.true??Object.values(e)[0];if(n==null)return e;let r={...e};for(let e of t)r[e]??=n;return r};return{...e,lineHeight:Object.keys(e.lineHeight).length>0?n(e.lineHeight):e.lineHeight,weight:Object.keys(e.weight).length>0?n(e.weight):e.weight,letterSpacing:Object.keys(e.letterSpacing).length>0?n(e.letterSpacing):e.letterSpacing}}function Ue(e,t){let n=new Map(e.map(e=>[e.path,e])),r=new Map,i=e=>{r.set(e.key,e)};if(t)for(let[e,n]of Pe(t))i(Le(R(e),n));for(let a of e){if(!Oe(a)||De(a))continue;let e=Te(a.path),o=he(P(a.value,n)),s=r.get(e)??R(e),c=Fe(t,o,a.path),l=s;c?l=Le(l,c):(o&&s.webFamily===R(e).webFamily||o&&!r.has(e))&&(l=Re(l,o)),i(l)}for(let a of e){if(!De(a))continue;let e=we(a.path);i(Ve(r.get(e)??R(e),a,n,t))}return[...r.values()].map(Be).toSorted((e,t)=>e.key.localeCompare(t.key))}function We(e){return/^\d+$/.test(e)||/^[A-Z_$][\w$]*$/i.test(e)?e:a(e)}function B(e,t=4){let n=` `.repeat(t),r=` `.repeat(Math.max(t-2,0)),i=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return i.length===0?`{}`:`{\n${i.map(([e,t])=>`${n}${We(e)}: ${a(t)}`).join(`,
|
|
4
|
+
`)}\n${r}}`}function Ge(e,t){let n=`${e.split(`-`).filter(Boolean).map((e,t)=>t===0?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(``).replaceAll(/[^\w$]/g,``)||`font${t}`}Font`;return/^[A-Z_$]/i.test(n)?n:`font${t}`}function Ke(e,t){let n=a(e.webFamily),r=a(e.nativeFamily),i=[n===r?` family: ${n}`:` family: isWeb ? ${n} : ${r}`,` size: ${B(e.size)}`];return Object.keys(e.lineHeight).length>0&&i.push(` lineHeight: ${B(e.lineHeight)}`),Object.keys(e.weight).length>0&&i.push(` weight: ${B(e.weight)}`),Object.keys(e.letterSpacing).length>0&&i.push(` letterSpacing: ${B(e.letterSpacing)}`),e.face&&i.push(` face: ${e.face}`),`const ${t} = createFont({\n${i.join(`,
|
|
5
|
+
`)}\n});`}function qe(e){return`# Installing Tamagui Config
|
|
6
6
|
|
|
7
7
|
Generated by \`@razorwind/tamagui\`.
|
|
8
8
|
|
|
@@ -48,20 +48,50 @@ export function App() {
|
|
|
48
48
|
## Regenerate
|
|
49
49
|
|
|
50
50
|
Re-run Razorwind generate when tokens change so \`${e.outputPath}\` stays aligned with your design system.
|
|
51
|
-
`}const
|
|
52
|
-
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function
|
|
53
|
-
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function
|
|
54
|
-
`)}\n${r}}`}const gt=/^\{([^{}]+)\}$/,_t=/\{([^{}]+)\}/g,vt=/^var\((--[^),\s]+)(?:\s*,[^)]*)?\)$/,yt=/var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g;function W(e){return{byPath:new Map(e.map(e=>[e.path,e])),byCssVar:new Map(e.map(e=>[(0,t.toThemeCssVar)(e.path),e]))}}function bt(e){if(typeof e==`string`)return gt.exec(e.trim())?.[1]?.trim()}function G(e){if(typeof e==`string`)return vt.exec(e.trim())?.[1]}function xt(e){return bt(e)!=null||G(e)!=null}function St(e){return/var\(|\{[^{}]+\}/.test(e)}function K(e,t){let n=q(e,t.byPath,t.byCssVar);if(n.category!=null&&n.category!==`color`)return;let r=[n.cssValue,n.tamaguiValue];for(let e of r)if(typeof e==`string`&&e.length>0&&!xt(e))return e}function Ct(e,t){return e.replace(_t,(e,n)=>{let r=t.byPath.get(n.trim());return r?K(r,t)??e:e}).replace(yt,(e,n)=>{let r=t.byCssVar.get(n);return r?K(r,t)??e:e})}function q(e,t,n){let r=e,i=new Set;for(let e=0;e<8;e++){if(i.has(r.path))return r;i.add(r.path);let e=bt(r.value);if(e){let n=t.get(e);if(!n||n.path===r.path)return r;r=n;continue}let a=G(r.value)??G(r.cssValue)??G(r.tamaguiValue);if(a){let e=n.get(a);if(!e||e.path===r.path)return r;r=e;continue}return r}return r}function wt(e){return/^[A-Z_$][\w$]*$/i.test(e)?`theme.${e}`:`theme[${a(e)}]`}function Tt(e,t){return t<1?e:t+1-e}function Et(e,t){return e.length<2?!1:X(e,t).some((t,n)=>t!==e[n])}function Dt(e,t,n,r){let i=n[t];if(!i||r!==`dark`)return e;let a=$(i,t);return a.length<2||!Et(a.map(([,e])=>e),r)?e:Tt(e,a[a.length-1][0])}function Ot(e,t,n,r){let i=J(e);if(!i)return;let a=Dt(i.step,i.name,n,r);if(t&&i.name.toLowerCase()===t.toLowerCase()||n[i.name])return`${i.name}${a}`}function kt(e){if(e>=1&&e<=12)return e;if(e>=100&&e<=900&&e%100==0)return e/100}function J(e){let t=e.path.split(`.`).filter(Boolean),n=t.at(-1);if(n&&/^\d+$/.test(n)){let e=kt(Number(n)),r=t.at(-2);if(e!=null&&r&&!/^(?:color|colours?|palette)$/i.test(r))return{name:C([r]),step:e}}if(!e.tokenKey)return;let r=/^([A-Z]+)(\d{1,3})$/i.exec(e.tokenKey);if(!r)return;let[,i=``,a=``]=r,o=kt(Number(a));if(o!=null)return{name:i,step:o}}function At(e,t,n,r){let i=e[t]??{};i[`${t}${n}`]=r,e[t]=i}function jt(e){let t={};for(let n of e){if(typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&At(t,e.name,e.step,n.tamaguiValue)}return Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=3))}function Y(e){let t={};for(let n of e){if(!n.primitive||typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&At(t,e.name,e.step,n.tamaguiValue)}let n=Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=2));return Object.keys(n).length>0?n:jt(e)}function X(e,t){if(e.length<2)return[...e];let n=Ft(e[0]),r=Ft(e[e.length-1]);if(n==null||r==null||n===r)return[...e];let i=n>r;return t===`light`?i?[...e]:e.toReversed():i?e.toReversed():[...e]}function Z(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Mt(e){let t=e.startsWith(`#`)?e.slice(1):``;if((t.length===3||t.length===4)&&(t=[...t].map(e=>e+e).join(``)),t.length===8&&(t=t.slice(0,6)),t.length!==6||/[^0-9a-f]/i.test(t))return;let 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;return .2126*Z(n)+.7152*Z(r)+.0722*Z(i)}function Q(e){let t=e.trim();if(t.endsWith(`%`)){let e=Number.parseFloat(t);return Number.isFinite(e)?e/100:void 0}let n=Number.parseFloat(t);return Number.isFinite(n)?n:void 0}function Nt(e){return e>1?e/100:e}function Pt(e,t){let n=RegExp(`^${t}\\((.+)\\)$`,`i`).exec(e.trim());if(n?.[1])return n[1].split(/[\s,/]+/).filter(Boolean)}function Ft(e){let t=e.trim();if(!t||t.startsWith(`var(`)||t.includes(`{`))return;let n=Mt(t);if(n!=null)return n;let r=Pt(t,`oklch`);if(r?.[0]){let e=Q(r[0]);return e==null?void 0:Nt(e)}let i=Pt(t,`hsla?`);if(i?.[2]){let e=Q(i[2]);return e==null?void 0:Nt(e)}let a=Pt(t,`rgba?`);if(a?.[0]&&a[1]&&a[2]){let e=Q(a[0]),t=Q(a[1]),n=Q(a[2]);if(e==null||t==null||n==null)return;let r=(e,t)=>t.trim().endsWith(`%`)||e<=1?e:e/255;return .2126*Z(r(e,a[0]))+.7152*Z(r(t,a[1]))+.0722*Z(r(n,a[2]))}}function $(e,t){let n=[],r=t.toLowerCase();for(let[i,a]of Object.entries(e)){if(!i.toLowerCase().startsWith(r))continue;let e=i.slice(t.length);/^\d+$/.test(e)&&n.push([Number(e),a])}return n.sort(([e],[t])=>e-t),n}function It(e,t,n){let r=$(e,t);if(r.length===0)return e;let i=X(r.map(([,e])=>e),n),a={};for(let[e,[n]]of r.entries())a[`${t}${n}`]=i[e]??r[e][1];return a}function Lt(e,t,n){let r=t[n];return e.find(([,e])=>e===r)?.[0]??e[n]?.[0]??n+1}function Rt(e,t,n,r){let i=$(e,n);if(i.length===0)return{};let a=X(i.map(([,e])=>e),r),o={};for(let[e,[r]]of i.entries()){let s=t[`${n}${Lt(i,a,e)}`];s&&(o[`${n}${r}`]=H(s))}return o}function zt(e,t,n,r){let i=$(e,n);if(i.length<2)return;let a=X(i.map(([,e])=>e),r),o=[];for(let[e]of i.entries()){let r=t[`${n}${Lt(i,a,e)}`];if(!r)return;o.push(H(r))}let s=[...o],c=s.at(-1);if(c!=null){for(;s.length<12;)s.push(c);return`[${s.join(`,`)}]`}}function Bt(e,t){return $(e,t).length>=2}function Vt(e){if(e.length>=12)return e.slice(0,12);let t=[...e],n=t.at(-1);if(n==null)return t;for(;t.length<12;)t.push(n);return t}function Ht(e,t,n){let r=$(e,t);if(!(r.length<2))return Vt(X(r.map(([,e])=>e),n))}function Ut(e){let t=new Map;for(let n of e){let e=n.childTheme?.trim();if(!e)continue;let r=e.toLowerCase();et(r)||tt(r)||t.has(r)||t.set(r,C([e]))}return[...t.values()].toSorted((e,t)=>e.localeCompare(t))}function Wt(e,t){let n=t.toLowerCase(),r=e.split(/(?=[A-Z])/).filter(Boolean).filter(e=>e.toLowerCase()!==n);if(r.length!==0)return C(r)}function Gt(e){return e.toLowerCase()===`base`}function Kt(e){let t=e.split(/(?=[A-Z])/).filter(Boolean),n=t.at(-1)?.toLowerCase();if((n===`primary`||n===`secondary`||n===`tertiary`)&&!(t.length<2))return{role:C(t.slice(0,-1)),rank:n}}function qt(e){return e.category===`color`&&!e.primitive&&!!e.tokenKey}function Jt(e,t,n){let r=new Map,i={};for(let a of e){if(!qt(a)||!a.tokenKey)continue;let e=a.childTheme?.toLowerCase();if(e&&e!==`base`)continue;let o=ft(a,t,n);if(!o)continue;let s=Kt(a.tokenKey);if(s){let e=r.get(s.role)??{};e[s.rank]=o,r.set(s.role,e);continue}if(e===`base`){let e=Wt(a.tokenKey,`base`);e&&(i[e]=o)}}let a={...i};for(let[e,t]of r){t.primary&&(a[e]=t.primary);let n=t.secondary??t.tertiary;n&&(a[`${e}Subtle`]=n)}return a}function Yt(e,t){let n=W(e),r={};for(let i of Ut(e)){if(Gt(i)){let a=Jt(e,n,t);Object.keys(a).length>0&&(r[i]=a);continue}let a={},o=i.toLowerCase();for(let r of e){if(!qt(r)||r.childTheme?.toLowerCase()!==o)continue;let e=Wt(r.tokenKey,i);if(!e)continue;let s=ft(r,n,t);s&&(a[e]=s)}Object.keys(a).length>0&&(r[i]=a)}return r}function Xt(e,t){let n=new Map(Object.entries(e).map(([e,t])=>[e.toLowerCase(),{name:e,scale:t}]));for(let e of Qe){let r=n.get(e);if(!r)continue;let i=Ht(r.scale,r.name,t);if(i)return{name:r.name,palette:i}}}function Zt(e){let t=e.filter(e=>e.category===`color`||e.primitive),n=Y(B(t,`light`)),r=Y(B(t,`dark`)),i=Xt(n,`light`),a=Xt(r,`dark`);return{lightPalette:i?.palette,darkPalette:a?.palette,lightBaseName:i?.name,darkBaseName:a?.name}}function Qt(e,t,n){let r=Y(e),{byPath:i,byCssVar:o}=W(e),s={};for(let c of e){if(c.category!==`color`||!c.tokenKey||c.primitive||/^[A-Z]+\d{1,3}$/i.test(c.tokenKey)&&r[c.tokenKey.replace(/\d{1,3}$/,``)])continue;let e=q(c,i,o),l=Ot(e,t,r,n);if(l){s[c.tokenKey]=wt(l);continue}let u=e.tamaguiValue;xt(u)||xt(e.cssValue)||(typeof u==`string`||typeof u==`number`)&&(s[c.tokenKey]=a(u))}return s}function $t(e){return e.replaceAll(`\\`,`\\\\`).replaceAll("`","\\`").replaceAll("${","\\${")}function en(e,t,n,r,i){let a=q(e,t.byPath,t.byCssVar),o=Ot(a,n,r,i);if(o)return{kind:`theme`,property:o};let s=K(a,t);if(s)return{kind:`text`,value:s}}function tn(e,t,n,r,i){let a=[],o=/\{([^{}]+)\}|var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g,s=0;for(let c of e.matchAll(o)){let o=c.index??0;o>s&&a.push({kind:`text`,value:e.slice(s,o)});let l=c[1]?t.byPath.get(c[1].trim()):c[2]?t.byCssVar.get(c[2]):void 0;if(!l)return;let u=en(l,t,n,r,i);if(!u)return;a.push(u),s=o+c[0].length}return s<e.length&&a.push({kind:`text`,value:e.slice(s)}),a}function nn(e){return e.some(e=>e.kind===`theme`)?`\`${e.map(e=>e.kind===`theme`?`\${${wt(e.property)}}`:$t(e.value)).join(``)}\``:a(e.map(e=>e.kind===`text`?e.value:``).join(``))}function rn(e,t,n){let r=W(e),i=Y(e.filter(e=>e.category===`color`)),a={};for(let o of e){if(!nt(o)||!o.tokenKey)continue;let e=typeof o.tamaguiValue==`string`?o.tamaguiValue:o.cssValue;if(typeof e!=`string`||e.length===0)continue;let s=tn(e,r,t,i,n);s&&(a[o.tokenKey]=nn(s))}return a}function an(e,t,n,r,i){let a=new Set([...Object.keys(e),...Object.keys(t)]);if(a.size===0)return;let o=[];for(let s of[...a].toSorted((e,t)=>e.localeCompare(t))){let a=e[s]??t[s]??{},c=t[s]??e[s]??{};if(Object.keys(a).length===0||Object.keys(c).length===0)continue;let l=Bt(a,s)||Bt(c,s),u,d;if(i&&l?(u=Rt(a,n[s]??r[s]??{},s,`light`),d=Rt(c,r[s]??n[s]??{},s,`dark`)):l?(u=It(a,s,`light`),d=It(c,s,`dark`)):(u=a,d=c),Object.keys(u).length===0||Object.keys(d).length===0)continue;let f=l&&!i?(e,t)=>pt(e,t):mt;o.push(` ${s}: {
|
|
51
|
+
`}const Je=new Set([`default`,`light`,`theme`]),Ye=/^base(?:[A-Z]\w*|[._-].+)?$/i,Xe=/^ring(?:\.|$)/i,Ze=[`base`,`gray`,`grey`,`neutral`],Qe={css:`@tamagui/config/v5-css`,rn:`@tamagui/config/v5-rn`,reanimated:`@tamagui/config/v5-reanimated`,motion:`@tamagui/config/v5-motion`};function $e(e){return Je.has(e)}function et(e){return e===`dark`}function V(e,t){let n=new Map,r=t===`dark`?et:$e;for(let t of e){let e=t.theme?.toLowerCase();(!e||Ye.test(e))&&n.set(t.path,t)}for(let t of e){let e=t.theme?.toLowerCase();e&&r(e)&&n.set(t.path,t)}return[...n.values()]}function tt(e){return Xe.test(e.path)&&e.category===`shadow`}const nt=new Set([`fontSize`,`blur`]),rt=[`space`,`size`,`radius`,`zIndex`,`blur`,`fontSize`,`shadow`,`insetShadow`,`dropShadow`,`textShadow`,`boxShadow`,`fontWeight`];function it(e){return/^px\(-?\d/.test(e)}function at(e){if(e.category===`radius`&&e.tokenKey?.startsWith(`borderRadius`)){let t=e.tokenKey.replace(/^borderRadius/,``);return t?w([t]):e.tokenKey}return e.tokenKey??``}function ot(e,t){let n=q(e,t.byPath,t.byCssVar).tamaguiValue;if(e.category&&nt.has(e.category)&&typeof n==`number`)return`px(${n})`;if(typeof n==`string`){let r=Ct(n,t);return e.category===`dropShadow`?st(r):r}return n}function st(e){return e.includes(`drop-shadow(`)?e:e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.replace(/^inset\s+/i,``).split(/\s+/);if(t.length>=5){let[e,n,r]=t;return`drop-shadow(${e} ${n} ${r} ${t.slice(4).join(` `)})`}return`drop-shadow(${e.replace(/^inset\s+/i,``)})`}).join(` `)}function ct(e){let t={},n=G(e);for(let r of e){if(!r.category||r.category===`color`||!r.tokenKey||tt(r))continue;let e=at(r);if(!e)continue;let i=ot(r,n);if(typeof i==`string`&&St(i))continue;let a=t[r.category]??{};a[e]=i,t[r.category]=a}return t}function H(e){let t=e.tokenKey??e.path.replace(/^color\./i,``).replaceAll(`.`,``);return e.theme?`${e.theme}${t[0]?.toUpperCase()??``}${t.slice(1)}`:t}function U(e){return`tokens.color.${e}.val`}function lt(e,t){let n={},r=G(e),i=G(t),a=(e,t)=>{if(!e.tokenKey)return;let r=K(e,t);typeof r==`string`&&r.length!==0&&r!==`[object Object]`&&(n[H(e)]=r)};for(let t of e)a(t,r);for(let e of t)a(e,i);return n}function ut(e){let t={};for(let n of e){if(!n.primitive)continue;let e=J(n);if(!e)continue;let r=H(n);if(!r)continue;let i=t[e.name]??{};i[`${e.name}${e.step}`]=r,t[e.name]=i}let n=Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=2));if(Object.keys(n).length>0)return n;let r={};for(let t of e){let e=J(t);if(!e)continue;let n=t.tokenKey??H(t);if(!n)continue;let i=r[e.name]??{};i[`${e.name}${e.step}`]=n,r[e.name]=i}return Object.fromEntries(Object.entries(r).filter(([,e])=>Object.keys(e).length>=3))}function W(e,t,n,r){let i=n[r];if(typeof i!=`string`)return!1;let a=K(e,t);return a!=null&&a===i}function dt(e,t,n){let r=H(e);if(W(e,t,n,r))return U(r);if(e.tokenKey&&e.tokenKey!==r&&W(e,t,n,e.tokenKey))return U(e.tokenKey);let i=q(e,t.byPath,t.byCssVar),o=H(i);if(o!==r&&W(e,t,n,o))return U(o);if(i.tokenKey&&i.tokenKey!==o&&W(e,t,n,i.tokenKey))return U(i.tokenKey);if(i.primitive){let r=H(i);if(W(e,t,n,r))return U(r)}let s=K(e,t);if(s)return a(s)}function ft(e,t=2){let n=` `.repeat(t),r=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return r.length===0?`{}`:`{\n${r.map(([e,t])=>{let r=typeof t==`string`&&it(t)?t:a(t);return`${n}${/^[A-Z_$][\w$]*$/i.test(e)?e:a(e)}: ${r}`}).join(`,
|
|
52
|
+
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function pt(e,t=2){let n=` `.repeat(t),r=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${/^[A-Z_$][\w$]*$/i.test(e)?e:a(e)}: ${t}`).join(`,
|
|
53
|
+
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function mt(e,t=2){let n=` `.repeat(t),r=` `.repeat(Math.max(t-2,0)),i=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return i.length===0?`{\n${n}...theme\n${r}}`:`{\n${n}...theme,\n${i.map(([e,t])=>`${n}${/^[A-Z_$][\w$]*$/i.test(e)?e:a(e)}: ${t}`).join(`,
|
|
54
|
+
`)}\n${r}}`}const ht=/^\{([^{}]+)\}$/,gt=/\{([^{}]+)\}/g,_t=/^var\((--[^),\s]+)(?:\s*,[^)]*)?\)$/,vt=/var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g;function G(e){return{byPath:new Map(e.map(e=>[e.path,e])),byCssVar:new Map(e.map(e=>[(0,t.toThemeCssVar)(e.path),e]))}}function yt(e){if(typeof e==`string`)return ht.exec(e.trim())?.[1]?.trim()}function bt(e){if(typeof e==`string`)return _t.exec(e.trim())?.[1]}function xt(e){return yt(e)!=null||bt(e)!=null}function St(e){return/var\(|\{[^{}]+\}/.test(e)}function K(e,t){let n=q(e,t.byPath,t.byCssVar);if(n.category!=null&&n.category!==`color`)return;let r=[n.cssValue,n.tamaguiValue];for(let e of r)if(typeof e==`string`&&e.length>0&&!xt(e))return e}function Ct(e,t){return e.replace(gt,(e,n)=>{let r=t.byPath.get(n.trim());return r?K(r,t)??e:e}).replace(vt,(e,n)=>{let r=t.byCssVar.get(n);return r?K(r,t)??e:e})}function q(e,t,n){let r=e,i=new Set;for(let e=0;e<8;e++){if(i.has(r.path))return r;i.add(r.path);let e=yt(r.value);if(e){let n=t.get(e);if(!n||n.path===r.path)return r;r=n;continue}let a=bt(r.value)??bt(r.cssValue)??bt(r.tamaguiValue);if(a){let e=n.get(a);if(!e||e.path===r.path)return r;r=e;continue}return r}return r}function wt(e){return/^[A-Z_$][\w$]*$/i.test(e)?`theme.${e}`:`theme[${a(e)}]`}function Tt(e,t){return t<1?e:t+1-e}function Et(e,t){return e.length<2?!1:X(e,t).some((t,n)=>t!==e[n])}function Dt(e,t,n,r){let i=n[t];if(!i||r!==`dark`)return e;let a=$(i,t);return a.length<2||!Et(a.map(([,e])=>e),r)?e:Tt(e,a[a.length-1][0])}function Ot(e,t,n,r){let i=J(e);if(!i)return;let a=Dt(i.step,i.name,n,r);if(t&&i.name.toLowerCase()===t.toLowerCase()||n[i.name])return`${i.name}${a}`}function kt(e){if(e>=1&&e<=12)return e;if(e>=100&&e<=900&&e%100==0)return e/100}function J(e){let t=e.path.split(`.`).filter(Boolean),n=t.at(-1);if(n&&/^\d+$/.test(n)){let e=kt(Number(n)),r=t.at(-2);if(e!=null&&r&&!/^(?:color|colours?|palette)$/i.test(r))return{name:w([r]),step:e}}if(!e.tokenKey)return;let r=/^([A-Z]+)(\d{1,3})$/i.exec(e.tokenKey);if(!r)return;let[,i=``,a=``]=r,o=kt(Number(a));if(o!=null)return{name:i,step:o}}function At(e,t,n,r){let i=e[t]??{};i[`${t}${n}`]=r,e[t]=i}function jt(e){let t={};for(let n of e){if(typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&At(t,e.name,e.step,n.tamaguiValue)}return Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=3))}function Y(e){let t={};for(let n of e){if(!n.primitive||typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&At(t,e.name,e.step,n.tamaguiValue)}let n=Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=2));return Object.keys(n).length>0?n:jt(e)}function X(e,t){if(e.length<2)return[...e];let n=Ft(e[0]),r=Ft(e[e.length-1]);if(n==null||r==null||n===r)return[...e];let i=n>r;return t===`light`?i?[...e]:e.toReversed():i?e.toReversed():[...e]}function Z(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Mt(e){let t=e.startsWith(`#`)?e.slice(1):``;if((t.length===3||t.length===4)&&(t=[...t].map(e=>e+e).join(``)),t.length===8&&(t=t.slice(0,6)),t.length!==6||/[^0-9a-f]/i.test(t))return;let 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;return .2126*Z(n)+.7152*Z(r)+.0722*Z(i)}function Q(e){let t=e.trim();if(t.endsWith(`%`)){let e=Number.parseFloat(t);return Number.isFinite(e)?e/100:void 0}let n=Number.parseFloat(t);return Number.isFinite(n)?n:void 0}function Nt(e){return e>1?e/100:e}function Pt(e,t){let n=RegExp(`^${t}\\((.+)\\)$`,`i`).exec(e.trim());if(n?.[1])return n[1].split(/[\s,/]+/).filter(Boolean)}function Ft(e){let t=e.trim();if(!t||t.startsWith(`var(`)||t.includes(`{`))return;let n=Mt(t);if(n!=null)return n;let r=Pt(t,`oklch`);if(r?.[0]){let e=Q(r[0]);return e==null?void 0:Nt(e)}let i=Pt(t,`hsla?`);if(i?.[2]){let e=Q(i[2]);return e==null?void 0:Nt(e)}let a=Pt(t,`rgba?`);if(a?.[0]&&a[1]&&a[2]){let e=Q(a[0]),t=Q(a[1]),n=Q(a[2]);if(e==null||t==null||n==null)return;let r=(e,t)=>t.trim().endsWith(`%`)||e<=1?e:e/255;return .2126*Z(r(e,a[0]))+.7152*Z(r(t,a[1]))+.0722*Z(r(n,a[2]))}}function $(e,t){let n=[],r=t.toLowerCase();for(let[i,a]of Object.entries(e)){if(!i.toLowerCase().startsWith(r))continue;let e=i.slice(t.length);/^\d+$/.test(e)&&n.push([Number(e),a])}return n.sort(([e],[t])=>e-t),n}function It(e,t,n){let r=$(e,t);if(r.length===0)return e;let i=X(r.map(([,e])=>e),n),a={};for(let[e,[n]]of r.entries())a[`${t}${n}`]=i[e]??r[e][1];return a}function Lt(e,t,n){let r=t[n];return e.find(([,e])=>e===r)?.[0]??e[n]?.[0]??n+1}function Rt(e,t,n,r){let i=$(e,n);if(i.length===0)return{};let a=X(i.map(([,e])=>e),r),o={};for(let[e,[r]]of i.entries()){let s=t[`${n}${Lt(i,a,e)}`];s&&(o[`${n}${r}`]=U(s))}return o}function zt(e,t,n,r){let i=$(e,n);if(i.length<2)return;let a=X(i.map(([,e])=>e),r),o=[];for(let[e]of i.entries()){let r=t[`${n}${Lt(i,a,e)}`];if(!r)return;o.push(U(r))}let s=[...o],c=s.at(-1);if(c!=null){for(;s.length<12;)s.push(c);return`[${s.join(`,`)}]`}}function Bt(e,t){return $(e,t).length>=2}function Vt(e){if(e.length>=12)return e.slice(0,12);let t=[...e],n=t.at(-1);if(n==null)return t;for(;t.length<12;)t.push(n);return t}function Ht(e,t,n){let r=$(e,t);if(!(r.length<2))return Vt(X(r.map(([,e])=>e),n))}function Ut(e){let t=new Map;for(let n of e){let e=n.childTheme?.trim();if(!e)continue;let r=e.toLowerCase();$e(r)||et(r)||t.has(r)||t.set(r,w([e]))}return[...t.values()].toSorted((e,t)=>e.localeCompare(t))}function Wt(e,t){let n=t.toLowerCase(),r=e.split(/(?=[A-Z])/).filter(Boolean).filter(e=>e.toLowerCase()!==n);if(r.length!==0)return w(r)}function Gt(e){return e.toLowerCase()===`base`}function Kt(e){return Ut(e).filter(e=>!Gt(e))}function qt(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}const Jt=[{alias:`background`,source:e=>`background${e}`},{alias:`backgroundDisabled`,source:e=>`background${e}Disabled`},{alias:`backgroundHover`,source:e=>`background${e}Hover`},{alias:`backgroundSubtle`,source:e=>e===`Primary`?`backgroundSecondary`:`background${e}Subtle`},{alias:`border`,source:e=>`border${e}`},{alias:`borderDisabled`,source:e=>`border${e}Disabled`},{alias:`borderHover`,source:e=>`border${e}Hover`},{alias:`borderSubtle`,source:e=>e===`Primary`?`borderSecondary`:`border${e}Subtle`},{alias:`foreground`,source:e=>`foreground${e}`},{alias:`foregroundDisabled`,source:e=>`foreground${e}Disabled`},{alias:`foregroundHover`,source:e=>`foreground${e}Hover`},{alias:`foregroundOn`,source:e=>`foregroundOn${e}`},{alias:`foregroundOnDisabled`,source:e=>`foregroundOn${e}Disabled`},{alias:`foregroundOnHover`,source:e=>`foregroundOn${e}Hover`}];function Yt(e,t,n){let r=new Set([...Object.keys(e),...Object.keys(t)]),i=[`Primary`,...n.map(qt)],a=[];for(let{alias:e,source:t}of Jt)i.some(e=>r.has(t(e)))&&a.push(e);return a}function Xt(e){let t={};for(let[n,r]of Object.entries(e)){if(Gt(n))continue;let e=Object.values(r);if(e.length===0)continue;let i={};for(let[t,r]of e.entries())i[`${n}${t+1}`]=r;Object.keys(i).length===1&&(i[`${n}2`]=e[0]),t[n]=i}return t}function Zt(e){let t=e.split(/(?=[A-Z])/).filter(Boolean),n=t.at(-1)?.toLowerCase();if((n===`primary`||n===`secondary`||n===`tertiary`)&&!(t.length<2))return{role:w(t.slice(0,-1)),rank:n}}function Qt(e){return e.category===`color`&&!e.primitive&&!!e.tokenKey}function $t(e,t,n){let r=new Map,i={};for(let a of e){if(!Qt(a)||!a.tokenKey)continue;let e=a.childTheme?.toLowerCase();if(e&&e!==`base`)continue;let o=dt(a,t,n);if(!o)continue;let s=Zt(a.tokenKey);if(s){let e=r.get(s.role)??{};e[s.rank]=o,r.set(s.role,e);continue}if(e===`base`){let e=Wt(a.tokenKey,`base`);e&&(i[e]=o)}}let a={...i};for(let[e,t]of r){t.primary&&(a[e]=t.primary);let n=t.secondary??t.tertiary;n&&(a[`${e}Subtle`]=n)}return a}function en(e,t){let n=G(e),r={};for(let i of Ut(e)){if(Gt(i)){let a=$t(e,n,t);Object.keys(a).length>0&&(r[i]=a);continue}let a={},o=i.toLowerCase();for(let r of e){if(!Qt(r)||r.childTheme?.toLowerCase()!==o)continue;let e=Wt(r.tokenKey,i);if(!e)continue;let s=dt(r,n,t);s&&(a[e]=s)}Object.keys(a).length>0&&(r[i]=a)}return r}function tn(e,t){let n=new Map(Object.entries(e).map(([e,t])=>[e.toLowerCase(),{name:e,scale:t}]));for(let e of Ze){let r=n.get(e);if(!r)continue;let i=Ht(r.scale,r.name,t);if(i)return{name:r.name,palette:i}}}function nn(e){let t=e.filter(e=>e.category===`color`||e.primitive),n=Y(V(t,`light`)),r=Y(V(t,`dark`)),i=tn(n,`light`),a=tn(r,`dark`);return{lightPalette:i?.palette,darkPalette:a?.palette,lightBaseName:i?.name,darkBaseName:a?.name}}function rn(e,t,n){let r=Y(e),{byPath:i,byCssVar:o}=G(e),s={};for(let c of e){if(c.category!==`color`||!c.tokenKey||c.primitive||/^[A-Z]+\d{1,3}$/i.test(c.tokenKey)&&r[c.tokenKey.replace(/\d{1,3}$/,``)])continue;let e=q(c,i,o),l=Ot(e,t,r,n);if(l){s[c.tokenKey]=wt(l);continue}let u=e.tamaguiValue;xt(u)||xt(e.cssValue)||(typeof u==`string`||typeof u==`number`)&&(s[c.tokenKey]=a(u))}return s}function an(e){return e.replaceAll(`\\`,`\\\\`).replaceAll("`","\\`").replaceAll("${","\\${")}function on(e,t,n,r,i){let a=q(e,t.byPath,t.byCssVar),o=Ot(a,n,r,i);if(o)return{kind:`theme`,property:o};let s=K(a,t);if(s)return{kind:`text`,value:s}}function sn(e,t,n,r,i){let a=[],o=/\{([^{}]+)\}|var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g,s=0;for(let c of e.matchAll(o)){let o=c.index??0;o>s&&a.push({kind:`text`,value:e.slice(s,o)});let l=c[1]?t.byPath.get(c[1].trim()):c[2]?t.byCssVar.get(c[2]):void 0;if(!l)return;let u=on(l,t,n,r,i);if(!u)return;a.push(u),s=o+c[0].length}return s<e.length&&a.push({kind:`text`,value:e.slice(s)}),a}function cn(e){return e.some(e=>e.kind===`theme`)?`\`${e.map(e=>e.kind===`theme`?`\${${wt(e.property)}}`:an(e.value)).join(``)}\``:a(e.map(e=>e.kind===`text`?e.value:``).join(``))}function ln(e,t,n){let r=G(e),i=Y(e.filter(e=>e.category===`color`)),a={};for(let o of e){if(!tt(o)||!o.tokenKey)continue;let e=typeof o.tamaguiValue==`string`?o.tamaguiValue:o.cssValue;if(typeof e!=`string`||e.length===0)continue;let s=sn(e,r,t,i,n);s&&(a[o.tokenKey]=cn(s))}return a}function un(e,t,n,r,i){let a=new Set([...Object.keys(e),...Object.keys(t)]);if(a.size===0)return;let o=[];for(let s of[...a].toSorted((e,t)=>e.localeCompare(t))){let a=e[s]??t[s]??{},c=t[s]??e[s]??{};if(Object.keys(a).length===0||Object.keys(c).length===0)continue;let l=Bt(a,s)||Bt(c,s),u,d;if(i&&l?(u=Rt(a,n[s]??r[s]??{},s,`light`),d=Rt(c,r[s]??n[s]??{},s,`dark`),Object.keys(u).length===0&&(u=a),Object.keys(d).length===0&&(d=c)):l?(u=It(a,s,`light`),d=It(c,s,`dark`)):(u=a,d=c),Object.keys(u).length===0||Object.keys(d).length===0)continue;let f=l&&!i?(e,t)=>ft(e,t):pt;o.push(` ${s}: {
|
|
55
55
|
light: ${f(u,8)},
|
|
56
56
|
dark: ${f(d,8)}
|
|
57
57
|
}`)}if(o.length!==0)return`{\n${o.join(`,
|
|
58
|
-
`)}\n }`}function
|
|
59
|
-
|
|
60
|
-
? ${
|
|
61
|
-
: ${
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
`)}\n }`}function dn(e){let t=new Set;for(let n of e)for(let e of Object.values(n)){for(let n of e.matchAll(/theme\.([A-Z_$][\w$]*)/gi))n[1]&&t.add(n[1]);for(let n of e.matchAll(/theme\[(['"])(.+?)\1\]/g))t.add(n[2])}return[...t]}function fn(e,t){let n=new Set;for(let r of[e,t])for(let e of Object.values(r))for(let t of Object.keys(e))n.add(t);return[...n]}function pn(e,t){let n=Math.max(e?.length??0,t?.length??0);if(n===0)return[];let r=[];for(let e=1;e<=Math.min(n,12);e++)r.push(`base${e}`);return r}function mn(e){let t=new Set;for(let n of Object.keys(e.lightSemantic))t.add(n);for(let n of Object.keys(e.darkSemantic))t.add(n);for(let n of dn([e.lightSemantic,e.darkSemantic]))t.add(n);for(let n of fn(e.lightScales,e.darkScales))t.add(n);for(let n of pn(e.lightPalette,e.darkPalette))t.add(n);for(let n of Yt(e.lightSemantic,e.darkSemantic,e.semanticRoles??[]))t.add(n);return[...t].toSorted((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))}function hn(e){return`const SEMANTIC_ROLES = new Set([${e.map(e=>a(e)).join(`, `)}]);`}function gn(e,t){return` getTheme: ({ theme, scheme, name }: { theme: AppTheme; scheme: "light" | "dark"; name?: string }) => {
|
|
59
|
+
const values: Record<string, string> = scheme === "dark"
|
|
60
|
+
? ${mt(t,8)}
|
|
61
|
+
: ${mt(e,8)};
|
|
62
|
+
const child = name?.split("_")[1];
|
|
63
|
+
const role =
|
|
64
|
+
child && SEMANTIC_ROLES.has(child)
|
|
65
|
+
? child.charAt(0).toUpperCase() + child.slice(1)
|
|
66
|
+
: "Primary";
|
|
67
|
+
const overlay: Record<string, string> = {};
|
|
68
|
+
const assign = (alias: string, source: string) => {
|
|
69
|
+
const value = values[source];
|
|
70
|
+
if (value !== undefined) {
|
|
71
|
+
overlay[alias] = value;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
assign("background", \`background\${role}\`);
|
|
75
|
+
assign("backgroundDisabled", \`background\${role}Disabled\`);
|
|
76
|
+
assign("backgroundHover", \`background\${role}Hover\`);
|
|
77
|
+
assign("backgroundSubtle", role === "Primary" ? "backgroundSecondary" : \`background\${role}Subtle\`);
|
|
78
|
+
assign("border", \`border\${role}\`);
|
|
79
|
+
assign("borderDisabled", \`border\${role}Disabled\`);
|
|
80
|
+
assign("borderHover", \`border\${role}Hover\`);
|
|
81
|
+
assign("borderSubtle", role === "Primary" ? "borderSecondary" : \`border\${role}Subtle\`);
|
|
82
|
+
assign("foreground", \`foreground\${role}\`);
|
|
83
|
+
assign("foregroundDisabled", \`foreground\${role}Disabled\`);
|
|
84
|
+
assign("foregroundHover", \`foreground\${role}Hover\`);
|
|
85
|
+
assign("foregroundOn", \`foregroundOn\${role}\`);
|
|
86
|
+
assign("foregroundOnDisabled", \`foregroundOn\${role}Disabled\`);
|
|
87
|
+
assign("foregroundOnHover", \`foregroundOn\${role}Hover\`);
|
|
88
|
+
return {
|
|
89
|
+
...values,
|
|
90
|
+
...overlay
|
|
91
|
+
};
|
|
92
|
+
}`}function _n(e){return` ${/^[A-Z_$][\w$]*$/i.test(e)?e:a(e)}: string;`}function vn(e,t){if(e.length!==0)return[`/**`,` * Theme values available on \`useTheme()\` and \`$\` style props for the ${t.specName||`design system`}.`,` *`," * Derived from design tokens mapped by `createV5Theme` and `getTheme`.",` *`,` * @see https://tamagui.dev/docs/guides/theme-builder#gettheme`,` */`,`export interface AppTheme {`,...e.map(_n),`}`,``]}function yn(e,t,n={}){let r=e.fonts??{},i=n.useDefaultConfig===!0,o=n.animations??`css`,s=n.includeTypeAugmentation!==!1,c=t.filter(e=>e.category===`color`),l=V(c,`light`),u=V(c,`dark`),d=u.length>0?u:l,f=lt(l,u),p=Object.keys(f).length>0,m=ut(l),h=ut(d),g=Y(l),_=Y(d),ee=Kt([...l,...d]),te={...Xt(en(l,f)),...g},ne={...Xt(en(d,f)),..._},{lightPalette:v,darkPalette:y,lightBaseName:b,darkBaseName:x}=nn(t),re=un(te,ne,m,h,p),S=p&&b?zt(g[b]??{},m[b]??{},b,`light`):void 0,ie=p&&x?zt(_[x]??{},h[x]??{},x,`dark`):void 0,C=V(t,`light`),w=V(t,`dark`),ae=u.length>0?w:C,T=u.length>0?x:b,E={...rn(l,b,`light`),...ln(C,b,`light`)},D={...rn(u.length>0?u:l,T,`dark`),...ln(ae,T,`dark`)},oe=vn(mn({lightSemantic:E,darkSemantic:D,lightScales:te,darkScales:ne,lightPalette:v,darkPalette:y,semanticRoles:ee}),{specName:e.name}),se=ct(C),O=[];Object.keys(f).length>0&&O.push(` color: ${ft(f,4)}`);for(let e of rt){let t=se[e];t&&Object.keys(t).length>0&&O.push(` ${e}: ${ft(t,4)}`)}let k=[];S?k.push(` lightPalette: ${S}`):v&&k.push(` lightPalette: ${a(v)}`),ie?k.push(` darkPalette: ${ie}`):y&&k.push(` darkPalette: ${a(y)}`),re&&k.push(` childrenThemes: ${re}`),(Object.keys(E).length>0||Object.keys(D).length>0)&&k.push(gn(E,D));let A=[`import { isWeb } from '@tamagui/constants';`];i?A.push(`import { createV5Theme, defaultConfig, type CreateV5ThemeOptions } from "@tamagui/config/v5";`):A.push(`import { createV5Theme, type CreateV5ThemeOptions } from "@tamagui/config/v5";`),o!==!1&&A.push(`import { animations } from "${Qe[o]}";`),n.importConfig&&A.push(`import userConfig from "${n.importConfig}";`);let ce=[`createTamagui`,`px`];O.length>0&&ce.push(`createTokens`);let le=Ue(t,r);le.length>0&&ce.push(`createFont`),A.push(`import { ${ce.join(`, `)} } from "@tamagui/core";`);let j=[`/* eslint-disable */`,``,`/*`,` * Generated by @razorwind/tamagui — Do not edit by hand.`,` * `,` * @see https://tamagui.dev/docs/core/config-v5`,` */`,``,...A,``];O.length>0&&j.push(`const tokens = createTokens({`,O.join(`,
|
|
93
|
+
`),`});`,``);let ue=k.length>0?`createV5Theme({\n${k.join(`,
|
|
94
|
+
`)}\n})`:`createV5Theme()`;(Object.keys(E).length>0||Object.keys(D).length>0)&&j.push(hn(ee),``),j.push(`const themes = ${ue};`,``);let de=new Map;if(le.length>0)for(let[e,t]of le.entries()){let n=Ge(t.key,e);de.set(t.key,n),j.push(Ke(t,n),``)}let M=[];if(i&&M.push(` ...defaultConfig`),o!==!1&&M.push(` animations`),O.length>0&&(i?M.push(` tokens: {
|
|
65
95
|
...defaultConfig.tokens,
|
|
66
96
|
...tokens,
|
|
67
97
|
space: {
|
|
@@ -80,18 +110,18 @@ Re-run Razorwind generate when tokens change so \`${e.outputPath}\` stays aligne
|
|
|
80
110
|
...defaultConfig.tokens.zIndex,
|
|
81
111
|
...tokens.zIndex
|
|
82
112
|
}
|
|
83
|
-
}`):M.push(` tokens`)),M.push(` themes`),
|
|
113
|
+
}`):M.push(` tokens`)),M.push(` themes`),de.size>0){let e=[...de.entries()].map(([e,t])=>` ${/^[A-Z_$][\w$]*$/i.test(e)?e:a(e)}: ${t}`);i?M.push(` fonts: {
|
|
84
114
|
...defaultConfig.fonts,
|
|
85
115
|
${e.join(`,
|
|
86
116
|
`)}
|
|
87
117
|
}`):M.push(` fonts: {
|
|
88
118
|
${e.join(`,
|
|
89
119
|
`)}
|
|
90
|
-
}`)}return n.shorthands&&M.push(` shorthands: ${
|
|
120
|
+
}`)}return n.shorthands&&M.push(` shorthands: ${ft(n.shorthands,4)}`),n.media&&M.push(` media: ${a(n.media)}`),n.defaultFont&&M.push(` defaultFont: ${a(n.defaultFont)}`),j.push(``,...oe??[],`/**
|
|
91
121
|
* The Tamagui v5 config for the ${e.name||`design system`}.
|
|
92
122
|
*
|
|
93
123
|
* @see https://tamagui.dev/docs/core/config-v5
|
|
94
124
|
*/
|
|
95
125
|
export const config = createTamagui({`,M.join(`,
|
|
96
|
-
`),n.importConfig?`, ...userConfig `:``,`});`,``,`export type AppConfig = typeof config;`,``),s&&
|
|
97
|
-
`)}function
|
|
126
|
+
`),n.importConfig?`, ...userConfig `:``,`});`,``,`export type AppConfig = typeof config;`,``),s&&j.push(`declare module "@tamagui/core" {`,` // eslint-disable-next-line @typescript-eslint/no-empty-object-type`,` interface TamaguiCustomConfig extends AppConfig {}`,`}`,``),j.push(`export default config;`,``),j.join(`
|
|
127
|
+
`)}function bn(e,r={}){let i=e.tokens&&Object.keys(e.tokens).length>0,a=e.fonts&&Object.keys(e.fonts).length>0;if(!i&&!a)return{};let o=i?E(e.tokens,r):[];if(o.length===0&&!a)return{};let s=r.outputPath??`tamagui.config.ts`,c=yn(e,o,r),l=r.installGuide??qe({outputPath:s}),u=(0,n.join)((0,n.dirname)(s),`INSTALL.md`);return{[s]:(0,t.createDocument)(s,c,{name:`razorwind-tamagui`},!1,`typescript`),[u]:(0,t.createDocument)(u,l,{name:`razorwind-tamagui`},!1,`markdown`)}}var xn=(0,e.definePlugin)(e=>({name:`tamagui`,themeGeneration:`combined`,generate:async t=>bn(t,e??{})}));exports.collectColorScales=Y,exports.collectTamaguiFonts=Ue,exports.colorLightness=Ft,exports.default=xn,exports.flattenTokens=E,exports.flipPaletteStep=Tt,exports.fontVarName=Ge,Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateTamaguiConfig=bn,exports.isPaletteGroup=ee,exports.orderPaletteForScheme=X,exports.renderInstallMd=qe,exports.renderTamaguiConfig=yn,exports.resolveTokenCategory=C,exports.resolveTokenSets=t.resolveTokenSets,exports.tamaguiFontKeyFromRole=L,exports.toCamelCaseKey=w,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}}),exports.toTamaguiValue=o,exports.toTokenKey=ae,exports.typographyFontKey=we;
|
package/dist/index.d.cts
CHANGED
|
@@ -269,11 +269,10 @@ declare function generateTamaguiConfig(spec: Schema, options?: TamaguiPluginOpti
|
|
|
269
269
|
* receives both `lightPalette` / `darkPalette` and `childrenThemes` with
|
|
270
270
|
* `{ light, dark }` palettes. Groups marked `palette: true` become
|
|
271
271
|
* `childrenThemes`; palettes named `base`, `grey`, `gray`, or `neutral` also
|
|
272
|
-
* set `lightPalette` / `darkPalette` (`color1`–`color12`). Semantic
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* `xSubtle`. Light palettes are ordered lightest-first; dark palettes
|
|
272
|
+
* set `lightPalette` / `darkPalette` (`color1`–`color12`). Semantic `theme`
|
|
273
|
+
* tags select `getTheme` aliases keyed by the generated theme `name`
|
|
274
|
+
* (`dark` / `dark_base` → Primary, `dark_warning` → Warning) rather than
|
|
275
|
+
* childrenThemes maps. Light palettes are ordered lightest-first; dark palettes
|
|
277
276
|
* darkest-first.
|
|
278
277
|
*
|
|
279
278
|
* Typography tokens (`$type: "typography"`) each emit their own Tamagui
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/fonts.ts","../src/format.ts","../src/install.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;;;;KA0BY;;;;KAMA;;;;UAkBK;;;;;;;;;EASf;;;;;;;EAQA,aAAa;;;;;;EAOb,aAAa;;;;;;EAOb,QAAQ;;;;EAKR;;;;EAKA;;;;;;;;EASA;;;;;EAMA,eAAe;;;;;;;EAQf;;;;;EAMA;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA,WAAW;;EAEX;;EAEA;;EAEA;;;;;EAKA;;;;EAIA;;;;;;;;;iBChEc,eAAe,MAAM;;;;iBAyGrB,qBACd,cACA,gBACC;;;;;;;iBAoEa,eAAe;;;;;;;;iBA0Bf,WAAW;;;;iBA2GX,cACd,QAAQ,SAAS,eAAe,SAChC,UAAS,KAAK,wCACb;;;;;;;;;UCrUc;;EAEf;;EAEA;;EAEA;EACA,MAAM;EACN,YAAY;EACZ,QAAQ;EACR,eAAe;;EAEf;;;;;;;;;iBA4Lc,uBAAuB;;;;;;;;;iBAiCvB,kBAAkB;;;;;;;iBA2WlB,oBACd,QAAQ,aACR,QAAQ,QACP;;;;;;iBAsFa,YAAY,aAAa;;;;;;;;;iBC/rBzB,eAAe,gBAAgB;;;;;;;;iBCnC/B,gBAAgB;EAAW;;;;KCmCtC;;;;;;;;iBAwmBW,gBAAgB,cAAc;;;;;;;iBA6K9B,mBACd,aAAa,cACZ,eAAe;;;;;;;iBAmCF,sBACd,2BACA,QAAQ;;;;;iBA+EM,eAAe;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/fonts.ts","../src/format.ts","../src/install.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;;;;KA0BY;;;;KAMA;;;;UAkBK;;;;;;;;;EASf;;;;;;;EAQA,aAAa;;;;;;EAOb,aAAa;;;;;;EAOb,QAAQ;;;;EAKR;;;;EAKA;;;;;;;;EASA;;;;;EAMA,eAAe;;;;;;;EAQf;;;;;EAMA;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA,WAAW;;EAEX;;EAEA;;EAEA;;;;;EAKA;;;;EAIA;;;;;;;;;iBChEc,eAAe,MAAM;;;;iBAyGrB,qBACd,cACA,gBACC;;;;;;;iBAoEa,eAAe;;;;;;;;iBA0Bf,WAAW;;;;iBA2GX,cACd,QAAQ,SAAS,eAAe,SAChC,UAAS,KAAK,wCACb;;;;;;;;;UCrUc;;EAEf;;EAEA;;EAEA;EACA,MAAM;EACN,YAAY;EACZ,QAAQ;EACR,eAAe;;EAEf;;;;;;;;;iBA4Lc,uBAAuB;;;;;;;;;iBAiCvB,kBAAkB;;;;;;;iBA2WlB,oBACd,QAAQ,aACR,QAAQ,QACP;;;;;;iBAsFa,YAAY,aAAa;;;;;;;;;iBC/rBzB,eAAe,gBAAgB;;;;;;;;iBCnC/B,gBAAgB;EAAW;;;;KCmCtC;;;;;;;;iBAwmBW,gBAAgB,cAAc;;;;;;;iBA6K9B,mBACd,aAAa,cACZ,eAAe;;;;;;;iBAmCF,sBACd,2BACA,QAAQ;;;;;iBA+EM,eAAe;;;;;;;;;;;iBA+kCf,oBACd,MAAM,QACN,QAAQ,aACR,UAAS;;;;iBAmUK,sBACd,MAAM,QACN,UAAS,uBACR,wBAAwB,QAAQ"}
|
package/dist/index.d.mts
CHANGED
|
@@ -269,11 +269,10 @@ declare function generateTamaguiConfig(spec: Schema, options?: TamaguiPluginOpti
|
|
|
269
269
|
* receives both `lightPalette` / `darkPalette` and `childrenThemes` with
|
|
270
270
|
* `{ light, dark }` palettes. Groups marked `palette: true` become
|
|
271
271
|
* `childrenThemes`; palettes named `base`, `grey`, `gray`, or `neutral` also
|
|
272
|
-
* set `lightPalette` / `darkPalette` (`color1`–`color12`). Semantic
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* `xSubtle`. Light palettes are ordered lightest-first; dark palettes
|
|
272
|
+
* set `lightPalette` / `darkPalette` (`color1`–`color12`). Semantic `theme`
|
|
273
|
+
* tags select `getTheme` aliases keyed by the generated theme `name`
|
|
274
|
+
* (`dark` / `dark_base` → Primary, `dark_warning` → Warning) rather than
|
|
275
|
+
* childrenThemes maps. Light palettes are ordered lightest-first; dark palettes
|
|
277
276
|
* darkest-first.
|
|
278
277
|
*
|
|
279
278
|
* Typography tokens (`$type: "typography"`) each emit their own Tamagui
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import{definePlugin as e}from"@razorwind/core/plugin";import{createDocument as t,formatTokenValue as n,formatTokenValue as r,isObject as i,resolveTokenSets as a,toCssVar as o,toThemeCssVar as s}from"@razorwind/core/utils";import{basename as c,dirname as l,join as u}from"node:path";import{cssFontFamily as d,fontFamilyName as f}from"@razorwind/core/lib/fonts";function p(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`).replaceAll(`
|
|
2
|
-
`,`\\n`).replaceAll(`\r`,`\\r`)}function m(e){return typeof e==`string`?`"${p(e)}"`:typeof e==`number`||typeof e==`boolean`?String(e):e==null?`undefined`:JSON.stringify(e)}function h(e,t){if(typeof e==`number`)return e;if(typeof e==`boolean`)return Number(e);if(i(e)&&typeof e.value==`number`&&typeof e.unit==`string`){let t=e.unit.toLowerCase();return t===`px`||t===``?e.value:t===`rem`?e.value*16:`${e.value}${e.unit}`}if(typeof e==`string`){let t=/^(-?\d+(?:\.\d+)?)px$/i.exec(e.trim());if(t)return Number(t[1]);let n=/^(-?\d+(?:\.\d+)?)rem$/i.exec(e.trim());if(n)return Number(n[1])*16;let r=Number(e);return!Number.isNaN(r)&&e.trim()!==``?r:e}return r(e,t)}const g=/^(?:font-size|fontSize)(?:\.|$)/i,_=/^(?:font-weight|fontWeight)(?:\.|$)/i,ee=/^shadow(?:\.|$)/i,te=/^inset-shadow(?:\.|$)/i,v=/^drop-shadow(?:\.|$)/i,y=/^text-shadow(?:\.|$)/i,b=/^(?:blur|blur-?radius)(?:\.|$)/i,x=new Set([`color`,`shadow`,`insetShadow`,`dropShadow`,`textShadow`]),
|
|
3
|
-
`)}\n }`}function
|
|
4
|
-
`)}\n${r}}`}function
|
|
5
|
-
`)}\n});`}function
|
|
2
|
+
`,`\\n`).replaceAll(`\r`,`\\r`)}function m(e){return typeof e==`string`?`"${p(e)}"`:typeof e==`number`||typeof e==`boolean`?String(e):e==null?`undefined`:JSON.stringify(e)}function h(e,t){if(typeof e==`number`)return e;if(typeof e==`boolean`)return Number(e);if(i(e)&&typeof e.value==`number`&&typeof e.unit==`string`){let t=e.unit.toLowerCase();return t===`px`||t===``?e.value:t===`rem`?e.value*16:`${e.value}${e.unit}`}if(typeof e==`string`){let t=/^(-?\d+(?:\.\d+)?)px$/i.exec(e.trim());if(t)return Number(t[1]);let n=/^(-?\d+(?:\.\d+)?)rem$/i.exec(e.trim());if(n)return Number(n[1])*16;let r=Number(e);return!Number.isNaN(r)&&e.trim()!==``?r:e}return r(e,t)}const g=/^(?:font-size|fontSize)(?:\.|$)/i,_=/^(?:font-weight|fontWeight)(?:\.|$)/i,ee=/^shadow(?:\.|$)/i,te=/^inset-shadow(?:\.|$)/i,v=/^drop-shadow(?:\.|$)/i,y=/^text-shadow(?:\.|$)/i,b=/^(?:blur|blur-?radius)(?:\.|$)/i,x=new Set([`color`,`shadow`,`insetShadow`,`dropShadow`,`textShadow`]),S=[{prefix:/^(?:color|colours?|palette)(?:\.|$)/i,category:`color`},{prefix:g,category:`fontSize`},{prefix:_,category:`fontWeight`},{prefix:v,category:`dropShadow`},{prefix:te,category:`insetShadow`},{prefix:y,category:`textShadow`},{prefix:ee,category:`shadow`},{prefix:b,category:`blur`},{prefix:/^(?:space|spacing|gap)(?:\.|$)/i,category:`space`},{prefix:/^inset(?:\.|$)/i,category:`space`},{prefix:/^(?:size|sizing)(?:\.|$)/i,category:`size`},{prefix:/^(?:radius|rounded|radii)(?:\.|$)/i,category:`radius`},{prefix:/^(?:z-?index|zindex|elevation)(?:\.|$)/i,category:`zIndex`}];function ne(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function re(e){return e===!0||e===`true`||e===1}function ie(e){return re(e.palette)||re(e.$palette)?!0:ue(e)===`palette`}function ae(e,t){return(e===`palette`||e===`$palette`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function oe(e){return e===!0||e===`true`||e===1}function se(e){return oe(e.primitive)||oe(e.$primitive)?!0:ue(e)===`primitive`}function ce(e,t){return(e===`primitive`||e===`$primitive`)&&(typeof t==`boolean`||typeof t==`number`||typeof t==`string`)}function C(e,t){return(e===`theme`||e===`$theme`)&&typeof t==`string`}function w(e){if(typeof e.theme==`string`&&e.theme.length>0)return e.theme;if(typeof e.$theme==`string`&&e.$theme.length>0)return e.$theme}function le(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function ue(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function T(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 E(e,t){for(let{prefix:t,category:n}of S)if(t.test(e))return n;if(t===`color`||t===`palette`)return`color`;if(t===`shadow`)return te.test(e)?`insetShadow`:v.test(e)?`dropShadow`:y.test(e)?`textShadow`:`shadow`;if(t===`dimension`){if(g.test(e))return`fontSize`;if(b.test(e))return`blur`;if(/(?:^|\.)(?:space|spacing|gap)(?:\.|$)/i.test(e)||/(?:^|\.)inset(?:\.|$)/i.test(e))return`space`;if(/radius|rounded/i.test(e))return`radius`;if(/z-?index|elevation/i.test(e))return`zIndex`;if(/(?:^|\.)(?:size|sizing)(?:\.|$)/i.test(e)||/(?:^|\.)(?:width|height)(?:\.|$)/i.test(e))return`size`}if(t===`number`&&/z-?index|elevation/i.test(e))return`zIndex`;if(t===`fontWeight`||_.test(e))return`fontWeight`}function D(e){return e.flatMap(e=>e.split(/[-_\s]+/)).filter(Boolean).map((e,t)=>{if(/^\d/.test(e))return e;let n=e.toLowerCase();return t===0?n:`${n.charAt(0).toUpperCase()}${n.slice(1)}`}).join(``)}function O(e){let t=e.split(`.`).filter(Boolean),n=t[0];n&&/^(?:color|colours?|palette|primitive|space|spacing|gap|inset|shadow|inset-shadow|drop-shadow|text-shadow|font-size|fontSize|font-weight|fontWeight|size|sizing|radius|rounded|radii|z-?index|zindex|elevation|blur)$/i.test(n)&&t.shift();let r=t.length>0?t:e.split(`.`).slice(-1);return r.length===1&&/^(?:DEFAULT|default)$/i.test(r[0]??``)?`true`:D(r)}function k(e,t,r,a,o,s,c){if(!i(e))return;let l=o||se(e)||ie(e),u=ue(e,r),d=w(e)??s;if(ne(e)){let r=T(e),i=t.join(`.`),o=E(i,u)??(l||u===`primitive`||u===`palette`?`color`:void 0),s=n(r,u),f=o&&x.has(o)||u===`color`||u===`palette`||u===`primitive`||u===`shadow`?s:h(r,u);c.push({path:i,type:u===`palette`||u===`primitive`?`color`:u,value:r,cssValue:s,tamaguiValue:f,category:o,tokenKey:o?O(i):void 0,description:le(e),theme:a,...d?{childTheme:d}:{},...l?{primitive:!0}:{}});return}for(let[n,r]of Object.entries(e))n.startsWith(`$`)&&n!==`$palette`&&n!==`$primitive`||ae(n,r)||ce(n,r)||C(n,r)||k(r,[...t,n],u,a,l,d,c)}function A(e,t={}){let n=t.includeTypes?new Set(t.includeTypes):void 0,r=[];for(let t of a(e)){let e=t.id==="default"?void 0:t.id;k(t.tokens,[],void 0,e,!1,void 0,r)}return n?r.filter(e=>!e.type||n.has(e.type)):r}const de=/^\{([^{}]+)\}$/,j=/^(?:typography|type|text)$/i,M=/^(?:font|fonts|font-family|fontFamily)$/i,fe=/^(?:font-size|fontSize)$/i,pe=/^(?:font-weight|fontWeight)$/i,me=/^(?:line-height|lineHeight|leading)$/i,he=/^(?:letter-spacing|letterSpacing|tracking)$/i,ge=/^(?:[a-z]{2}(?:-[A-Z]{2})?|cn|zh|jp|ja|kr|ko|ar|he|th|hi|ru|french|mandarin|chinese|japanese|korean|arabic|hebrew)$/i,_e=[`fontFamily`,`font-family`,`family`],ve=[`fontSize`,`font-size`,`size`],ye=[`fontWeight`,`font-weight`,`weight`],be=[`lineHeight`,`line-height`,`leading`],xe=[`letterSpacing`,`letter-spacing`,`tracking`],Se={1:12,2:14,3:16,4:18,5:20,6:24,7:28,8:32,9:40,10:48};function N(e){if(typeof e==`string`)return de.exec(e.trim())?.[1]?.trim()}function P(e,t){let n=N(e);if(!n)return e;let r=t.get(n),i=new Set([n]);for(let e=0;e<8&&r;e++){let e=N(r.value);if(!e||i.has(e))return r.value;i.add(e),r=t.get(e)}return r?.value??e}function F(e,t){for(let n of t)if(e[n]!==void 0&&e[n]!==null)return e[n]}function Ce(e){return(e.split(`,`)[0]?.trim()??e).replaceAll(/^["']|["']$/g,``)}function we(e){if(typeof e==`string`){let t=e.trim();return t.length===0||N(t)?void 0:t}if(Array.isArray(e)&&e.every(e=>typeof e==`string`)){let t=e.map(e=>e.trim()).filter(Boolean);return t.length>0?t.join(`, `):void 0}}function Te(e){return Number.isInteger(e)?e:Math.round(e*1e3)/1e3}function Ee(e){if(e==null)return;let t=h(e);if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`){let e=/^(-?\d+(?:\.\d+)?)%$/.exec(t.trim());if(e)return Number.parseFloat(e[1])/100}}function De(e){if(typeof e==`number`&&Number.isFinite(e))return String(e);if(typeof e==`string`){let t=e.trim();if(t.length===0||N(t))return;let n=Number(t);return Number.isNaN(n)?t:String(n)}let t=h(e);if(typeof t==`number`&&Number.isFinite(t))return String(t);if(typeof t==`string`&&t.length>0)return t}function Oe(e,t){let n=Ee(e);if(n!=null)return Te(t!=null&&n>0&&n<=4?n*t:n)}function I(e,t){return t.test(e.split(`.`)[0]??``)}function ke(e){return e.split(`.`).filter(Boolean).at(-1)??e}function Ae(e,t){let n=e.split(`.`).filter(Boolean);return n[0]&&t.test(n[0])&&n.shift(),n}function je(e){let t=e.flatMap(e=>e.split(`-`)).filter(Boolean);return t.length===0?`body`:t.map((e,t)=>t===0?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(``)}function Me(e){switch(e.toLowerCase()){case`sans`:case`body`:case`serif`:return`body`;case`monospace`:case`mono`:return`mono`;default:return je([e])}}function Ne(e){return e.role?Me(e.role):Me(e.name)}function Pe(e){let t=Ae(e,j);if(t.length===0)return`body`;let n=t.at(-1);return n&&t.length>=2&&ge.test(n)&&!n.includes(`_`)?`${t.slice(0,-1).join(`-`)}_${n}`:t.join(`-`)}function Fe(e){return Me(Ae(e,M)[0]??ke(e))}function Ie(e,t){let n=Ae(e,t);return n.length===0||n.length===1&&/^(?:DEFAULT|default)$/i.test(n[0])?`true`:je(n)}function Le(e){return e.type===`typography`&&i(e.value)}function Re(e){return e.category===`fontSize`||e.category===`fontWeight`||ze(e)||Be(e)||Ve(e)||He(e)?!1:e.type===`fontFamily`||I(e.path,M)}function ze(e){return e.category===`fontSize`||I(e.path,fe)}function Be(e){return e.category===`fontWeight`||e.type===`fontWeight`||I(e.path,pe)}function Ve(e){return I(e.path,me)}function He(e){return I(e.path,he)}function Ue(e,t){if(!e.has(t))return t;let n=2,r=`${t}${n}`;for(;e.has(r);)n++,r=`${t}${n}`;return r}function We(e){let t=new Map;for(let n of Object.values(e)){let e=Ne(n);t.has(e)&&(e=Ue(t,je([n.name]))),t.set(e,n)}return t}function Ge(e,t,n){if(!e)return;let r=Object.values(e);if(r.length===0)return;if(n){let e=n.split(`.`).filter(Boolean).at(-1);if(e){let t=r.find(t=>t.role===e||t.name.toLowerCase()===e.toLowerCase());if(t)return t}}if(!t)return;let i=Ce(t).toLowerCase();return r.find(e=>f(e).toLowerCase()===i||e.title.toLowerCase()===i||e.name.toLowerCase()===i)}function Ke(e){let t=new Map;for(let n of e.files){let e=String(n.weight??400),r=c(n.path).replace(/\.[^.]+$/,``),i=t.get(e)??{};n.style===`italic`||n.style===`oblique`?i.italic=r:i.normal=r,t.set(e,i)}if(t.size!==0)return`{\n${[...t.entries()].toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0})).map(([e,t])=>{let n=[];return t.normal&&n.push(`normal: ${m(t.normal)}`),t.italic&&n.push(`italic: ${m(t.italic)}`),` ${e}: { ${n.join(`, `)} }`}).join(`,
|
|
3
|
+
`)}\n }`}function qe(e,t){return{...e,webFamily:d(t),nativeFamily:f(t),face:t.source===`local`?Ke(t):e.face}}function L(e){return{key:e,webFamily:`system-ui, sans-serif`,nativeFamily:`system-ui`,size:{},lineHeight:{},weight:{},letterSpacing:{}}}function Je(e,t){return{...e,webFamily:t,nativeFamily:Ce(t)}}const Ye=/^(?:font-size|fontSize|font-weight|fontWeight|line-height|lineHeight|leading|letter-spacing|letterSpacing|tracking)$/i;function R(e,t){let n={true:e},r=N(t);if(!r)return n;let i=Ie(r,Ye);return i&&i!==`true`&&(n[i]=e),n}function Xe(e){return Object.keys(e.size).length>0?e:{...e,size:{...Se}}}function Ze(e,t,n,r){if(!i(t.value))return e;let a=F(t.value,_e),o=N(a),s=we(P(a,n)),c=Ge(r,s,o),l=e;c?l=qe(l,c):s&&(l=Je(l,s));let u=F(t.value,ve),d=Ee(P(u,n));d!=null&&(l={...l,size:R(d,u)});let f=F(t.value,ye),p=De(P(f,n));p&&(l={...l,weight:R(p,f)});let m=F(t.value,xe),h=Ee(P(m,n));h!=null&&(l={...l,letterSpacing:R(h,m)});let g=F(t.value,be),_=Oe(P(g,n),l.size.true??d);return _!=null&&(l={...l,lineHeight:R(_,g)}),Qe(l)}function Qe(e){let t=Object.keys(e.size);if(t.length===0)return e;let n=e=>{let n=e.true??Object.values(e)[0];if(n==null)return e;let r={...e};for(let e of t)r[e]??=n;return r};return{...e,lineHeight:Object.keys(e.lineHeight).length>0?n(e.lineHeight):e.lineHeight,weight:Object.keys(e.weight).length>0?n(e.weight):e.weight,letterSpacing:Object.keys(e.letterSpacing).length>0?n(e.letterSpacing):e.letterSpacing}}function $e(e,t){let n=new Map(e.map(e=>[e.path,e])),r=new Map,i=e=>{r.set(e.key,e)};if(t)for(let[e,n]of We(t))i(qe(L(e),n));for(let a of e){if(!Re(a)||Le(a))continue;let e=Fe(a.path),o=we(P(a.value,n)),s=r.get(e)??L(e),c=Ge(t,o,a.path),l=s;c?l=qe(l,c):(o&&s.webFamily===L(e).webFamily||o&&!r.has(e))&&(l=Je(l,o)),i(l)}for(let a of e){if(!Le(a))continue;let e=Pe(a.path);i(Ze(r.get(e)??L(e),a,n,t))}return[...r.values()].map(Xe).toSorted((e,t)=>e.key.localeCompare(t.key))}function et(e){return/^\d+$/.test(e)||/^[A-Z_$][\w$]*$/i.test(e)?e:m(e)}function z(e,t=4){let n=` `.repeat(t),r=` `.repeat(Math.max(t-2,0)),i=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return i.length===0?`{}`:`{\n${i.map(([e,t])=>`${n}${et(e)}: ${m(t)}`).join(`,
|
|
4
|
+
`)}\n${r}}`}function tt(e,t){let n=`${e.split(`-`).filter(Boolean).map((e,t)=>t===0?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(``).replaceAll(/[^\w$]/g,``)||`font${t}`}Font`;return/^[A-Z_$]/i.test(n)?n:`font${t}`}function nt(e,t){let n=m(e.webFamily),r=m(e.nativeFamily),i=[n===r?` family: ${n}`:` family: isWeb ? ${n} : ${r}`,` size: ${z(e.size)}`];return Object.keys(e.lineHeight).length>0&&i.push(` lineHeight: ${z(e.lineHeight)}`),Object.keys(e.weight).length>0&&i.push(` weight: ${z(e.weight)}`),Object.keys(e.letterSpacing).length>0&&i.push(` letterSpacing: ${z(e.letterSpacing)}`),e.face&&i.push(` face: ${e.face}`),`const ${t} = createFont({\n${i.join(`,
|
|
5
|
+
`)}\n});`}function rt(e){return`# Installing Tamagui Config
|
|
6
6
|
|
|
7
7
|
Generated by \`@razorwind/tamagui\`.
|
|
8
8
|
|
|
@@ -48,20 +48,50 @@ export function App() {
|
|
|
48
48
|
## Regenerate
|
|
49
49
|
|
|
50
50
|
Re-run Razorwind generate when tokens change so \`${e.outputPath}\` stays aligned with your design system.
|
|
51
|
-
`}const
|
|
52
|
-
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function
|
|
53
|
-
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function
|
|
54
|
-
`)}\n${r}}`}const Tt=/^\{([^{}]+)\}$/,Et=/\{([^{}]+)\}/g,Dt=/^var\((--[^),\s]+)(?:\s*,[^)]*)?\)$/,Ot=/var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g;function W(e){return{byPath:new Map(e.map(e=>[e.path,e])),byCssVar:new Map(e.map(e=>[s(e.path),e]))}}function kt(e){if(typeof e==`string`)return Tt.exec(e.trim())?.[1]?.trim()}function G(e){if(typeof e==`string`)return Dt.exec(e.trim())?.[1]}function At(e){return kt(e)!=null||G(e)!=null}function jt(e){return/var\(|\{[^{}]+\}/.test(e)}function K(e,t){let n=q(e,t.byPath,t.byCssVar);if(n.category!=null&&n.category!==`color`)return;let r=[n.cssValue,n.tamaguiValue];for(let e of r)if(typeof e==`string`&&e.length>0&&!At(e))return e}function Mt(e,t){return e.replace(Et,(e,n)=>{let r=t.byPath.get(n.trim());return r?K(r,t)??e:e}).replace(Ot,(e,n)=>{let r=t.byCssVar.get(n);return r?K(r,t)??e:e})}function q(e,t,n){let r=e,i=new Set;for(let e=0;e<8;e++){if(i.has(r.path))return r;i.add(r.path);let e=kt(r.value);if(e){let n=t.get(e);if(!n||n.path===r.path)return r;r=n;continue}let a=G(r.value)??G(r.cssValue)??G(r.tamaguiValue);if(a){let e=n.get(a);if(!e||e.path===r.path)return r;r=e;continue}return r}return r}function Nt(e){return/^[A-Z_$][\w$]*$/i.test(e)?`theme.${e}`:`theme[${m(e)}]`}function Pt(e,t){return t<1?e:t+1-e}function Ft(e,t){return e.length<2?!1:X(e,t).some((t,n)=>t!==e[n])}function It(e,t,n,r){let i=n[t];if(!i||r!==`dark`)return e;let a=$(i,t);return a.length<2||!Ft(a.map(([,e])=>e),r)?e:Pt(e,a[a.length-1][0])}function Lt(e,t,n,r){let i=J(e);if(!i)return;let a=It(i.step,i.name,n,r);if(t&&i.name.toLowerCase()===t.toLowerCase()||n[i.name])return`${i.name}${a}`}function Rt(e){if(e>=1&&e<=12)return e;if(e>=100&&e<=900&&e%100==0)return e/100}function J(e){let t=e.path.split(`.`).filter(Boolean),n=t.at(-1);if(n&&/^\d+$/.test(n)){let e=Rt(Number(n)),r=t.at(-2);if(e!=null&&r&&!/^(?:color|colours?|palette)$/i.test(r))return{name:D([r]),step:e}}if(!e.tokenKey)return;let r=/^([A-Z]+)(\d{1,3})$/i.exec(e.tokenKey);if(!r)return;let[,i=``,a=``]=r,o=Rt(Number(a));if(o!=null)return{name:i,step:o}}function zt(e,t,n,r){let i=e[t]??{};i[`${t}${n}`]=r,e[t]=i}function Bt(e){let t={};for(let n of e){if(typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&zt(t,e.name,e.step,n.tamaguiValue)}return Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=3))}function Y(e){let t={};for(let n of e){if(!n.primitive||typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&zt(t,e.name,e.step,n.tamaguiValue)}let n=Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=2));return Object.keys(n).length>0?n:Bt(e)}function X(e,t){if(e.length<2)return[...e];let n=Wt(e[0]),r=Wt(e[e.length-1]);if(n==null||r==null||n===r)return[...e];let i=n>r;return t===`light`?i?[...e]:e.toReversed():i?e.toReversed():[...e]}function Z(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Vt(e){let t=e.startsWith(`#`)?e.slice(1):``;if((t.length===3||t.length===4)&&(t=[...t].map(e=>e+e).join(``)),t.length===8&&(t=t.slice(0,6)),t.length!==6||/[^0-9a-f]/i.test(t))return;let 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;return .2126*Z(n)+.7152*Z(r)+.0722*Z(i)}function Q(e){let t=e.trim();if(t.endsWith(`%`)){let e=Number.parseFloat(t);return Number.isFinite(e)?e/100:void 0}let n=Number.parseFloat(t);return Number.isFinite(n)?n:void 0}function Ht(e){return e>1?e/100:e}function Ut(e,t){let n=RegExp(`^${t}\\((.+)\\)$`,`i`).exec(e.trim());if(n?.[1])return n[1].split(/[\s,/]+/).filter(Boolean)}function Wt(e){let t=e.trim();if(!t||t.startsWith(`var(`)||t.includes(`{`))return;let n=Vt(t);if(n!=null)return n;let r=Ut(t,`oklch`);if(r?.[0]){let e=Q(r[0]);return e==null?void 0:Ht(e)}let i=Ut(t,`hsla?`);if(i?.[2]){let e=Q(i[2]);return e==null?void 0:Ht(e)}let a=Ut(t,`rgba?`);if(a?.[0]&&a[1]&&a[2]){let e=Q(a[0]),t=Q(a[1]),n=Q(a[2]);if(e==null||t==null||n==null)return;let r=(e,t)=>t.trim().endsWith(`%`)||e<=1?e:e/255;return .2126*Z(r(e,a[0]))+.7152*Z(r(t,a[1]))+.0722*Z(r(n,a[2]))}}function $(e,t){let n=[],r=t.toLowerCase();for(let[i,a]of Object.entries(e)){if(!i.toLowerCase().startsWith(r))continue;let e=i.slice(t.length);/^\d+$/.test(e)&&n.push([Number(e),a])}return n.sort(([e],[t])=>e-t),n}function Gt(e,t,n){let r=$(e,t);if(r.length===0)return e;let i=X(r.map(([,e])=>e),n),a={};for(let[e,[n]]of r.entries())a[`${t}${n}`]=i[e]??r[e][1];return a}function Kt(e,t,n){let r=t[n];return e.find(([,e])=>e===r)?.[0]??e[n]?.[0]??n+1}function qt(e,t,n,r){let i=$(e,n);if(i.length===0)return{};let a=X(i.map(([,e])=>e),r),o={};for(let[e,[r]]of i.entries()){let s=t[`${n}${Kt(i,a,e)}`];s&&(o[`${n}${r}`]=V(s))}return o}function Jt(e,t,n,r){let i=$(e,n);if(i.length<2)return;let a=X(i.map(([,e])=>e),r),o=[];for(let[e]of i.entries()){let r=t[`${n}${Kt(i,a,e)}`];if(!r)return;o.push(V(r))}let s=[...o],c=s.at(-1);if(c!=null){for(;s.length<12;)s.push(c);return`[${s.join(`,`)}]`}}function Yt(e,t){return $(e,t).length>=2}function Xt(e){if(e.length>=12)return e.slice(0,12);let t=[...e],n=t.at(-1);if(n==null)return t;for(;t.length<12;)t.push(n);return t}function Zt(e,t,n){let r=$(e,t);if(!(r.length<2))return Xt(X(r.map(([,e])=>e),n))}function Qt(e){let t=new Map;for(let n of e){let e=n.childTheme?.trim();if(!e)continue;let r=e.toLowerCase();ut(r)||dt(r)||t.has(r)||t.set(r,D([e]))}return[...t.values()].toSorted((e,t)=>e.localeCompare(t))}function $t(e,t){let n=t.toLowerCase(),r=e.split(/(?=[A-Z])/).filter(Boolean).filter(e=>e.toLowerCase()!==n);if(r.length!==0)return D(r)}function en(e){return e.toLowerCase()===`base`}function tn(e){let t=e.split(/(?=[A-Z])/).filter(Boolean),n=t.at(-1)?.toLowerCase();if((n===`primary`||n===`secondary`||n===`tertiary`)&&!(t.length<2))return{role:D(t.slice(0,-1)),rank:n}}function nn(e){return e.category===`color`&&!e.primitive&&!!e.tokenKey}function rn(e,t,n){let r=new Map,i={};for(let a of e){if(!nn(a)||!a.tokenKey)continue;let e=a.childTheme?.toLowerCase();if(e&&e!==`base`)continue;let o=St(a,t,n);if(!o)continue;let s=tn(a.tokenKey);if(s){let e=r.get(s.role)??{};e[s.rank]=o,r.set(s.role,e);continue}if(e===`base`){let e=$t(a.tokenKey,`base`);e&&(i[e]=o)}}let a={...i};for(let[e,t]of r){t.primary&&(a[e]=t.primary);let n=t.secondary??t.tertiary;n&&(a[`${e}Subtle`]=n)}return a}function an(e,t){let n=W(e),r={};for(let i of Qt(e)){if(en(i)){let a=rn(e,n,t);Object.keys(a).length>0&&(r[i]=a);continue}let a={},o=i.toLowerCase();for(let r of e){if(!nn(r)||r.childTheme?.toLowerCase()!==o)continue;let e=$t(r.tokenKey,i);if(!e)continue;let s=St(r,n,t);s&&(a[e]=s)}Object.keys(a).length>0&&(r[i]=a)}return r}function on(e,t){let n=new Map(Object.entries(e).map(([e,t])=>[e.toLowerCase(),{name:e,scale:t}]));for(let e of ct){let r=n.get(e);if(!r)continue;let i=Zt(r.scale,r.name,t);if(i)return{name:r.name,palette:i}}}function sn(e){let t=e.filter(e=>e.category===`color`||e.primitive),n=Y(z(t,`light`)),r=Y(z(t,`dark`)),i=on(n,`light`),a=on(r,`dark`);return{lightPalette:i?.palette,darkPalette:a?.palette,lightBaseName:i?.name,darkBaseName:a?.name}}function cn(e,t,n){let r=Y(e),{byPath:i,byCssVar:a}=W(e),o={};for(let s of e){if(s.category!==`color`||!s.tokenKey||s.primitive||/^[A-Z]+\d{1,3}$/i.test(s.tokenKey)&&r[s.tokenKey.replace(/\d{1,3}$/,``)])continue;let e=q(s,i,a),c=Lt(e,t,r,n);if(c){o[s.tokenKey]=Nt(c);continue}let l=e.tamaguiValue;At(l)||At(e.cssValue)||(typeof l==`string`||typeof l==`number`)&&(o[s.tokenKey]=m(l))}return o}function ln(e){return e.replaceAll(`\\`,`\\\\`).replaceAll("`","\\`").replaceAll("${","\\${")}function un(e,t,n,r,i){let a=q(e,t.byPath,t.byCssVar),o=Lt(a,n,r,i);if(o)return{kind:`theme`,property:o};let s=K(a,t);if(s)return{kind:`text`,value:s}}function dn(e,t,n,r,i){let a=[],o=/\{([^{}]+)\}|var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g,s=0;for(let c of e.matchAll(o)){let o=c.index??0;o>s&&a.push({kind:`text`,value:e.slice(s,o)});let l=c[1]?t.byPath.get(c[1].trim()):c[2]?t.byCssVar.get(c[2]):void 0;if(!l)return;let u=un(l,t,n,r,i);if(!u)return;a.push(u),s=o+c[0].length}return s<e.length&&a.push({kind:`text`,value:e.slice(s)}),a}function fn(e){return e.some(e=>e.kind===`theme`)?`\`${e.map(e=>e.kind===`theme`?`\${${Nt(e.property)}}`:ln(e.value)).join(``)}\``:m(e.map(e=>e.kind===`text`?e.value:``).join(``))}function pn(e,t,n){let r=W(e),i=Y(e.filter(e=>e.category===`color`)),a={};for(let o of e){if(!ft(o)||!o.tokenKey)continue;let e=typeof o.tamaguiValue==`string`?o.tamaguiValue:o.cssValue;if(typeof e!=`string`||e.length===0)continue;let s=dn(e,r,t,i,n);s&&(a[o.tokenKey]=fn(s))}return a}function mn(e,t,n,r,i){let a=new Set([...Object.keys(e),...Object.keys(t)]);if(a.size===0)return;let o=[];for(let s of[...a].toSorted((e,t)=>e.localeCompare(t))){let a=e[s]??t[s]??{},c=t[s]??e[s]??{};if(Object.keys(a).length===0||Object.keys(c).length===0)continue;let l=Yt(a,s)||Yt(c,s),u,d;if(i&&l?(u=qt(a,n[s]??r[s]??{},s,`light`),d=qt(c,r[s]??n[s]??{},s,`dark`)):l?(u=Gt(a,s,`light`),d=Gt(c,s,`dark`)):(u=a,d=c),Object.keys(u).length===0||Object.keys(d).length===0)continue;let f=l&&!i?(e,t)=>U(e,t):Ct;o.push(` ${s}: {
|
|
51
|
+
`}const it=new Set([`default`,`light`,`theme`]),at=/^base(?:[A-Z]\w*|[._-].+)?$/i,ot=/^ring(?:\.|$)/i,st=[`base`,`gray`,`grey`,`neutral`],ct={css:`@tamagui/config/v5-css`,rn:`@tamagui/config/v5-rn`,reanimated:`@tamagui/config/v5-reanimated`,motion:`@tamagui/config/v5-motion`};function lt(e){return it.has(e)}function ut(e){return e===`dark`}function B(e,t){let n=new Map,r=t===`dark`?ut:lt;for(let t of e){let e=t.theme?.toLowerCase();(!e||at.test(e))&&n.set(t.path,t)}for(let t of e){let e=t.theme?.toLowerCase();e&&r(e)&&n.set(t.path,t)}return[...n.values()]}function dt(e){return ot.test(e.path)&&e.category===`shadow`}const ft=new Set([`fontSize`,`blur`]),pt=[`space`,`size`,`radius`,`zIndex`,`blur`,`fontSize`,`shadow`,`insetShadow`,`dropShadow`,`textShadow`,`boxShadow`,`fontWeight`];function mt(e){return/^px\(-?\d/.test(e)}function ht(e){if(e.category===`radius`&&e.tokenKey?.startsWith(`borderRadius`)){let t=e.tokenKey.replace(/^borderRadius/,``);return t?D([t]):e.tokenKey}return e.tokenKey??``}function gt(e,t){let n=q(e,t.byPath,t.byCssVar).tamaguiValue;if(e.category&&ft.has(e.category)&&typeof n==`number`)return`px(${n})`;if(typeof n==`string`){let r=Mt(n,t);return e.category===`dropShadow`?_t(r):r}return n}function _t(e){return e.includes(`drop-shadow(`)?e:e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.replace(/^inset\s+/i,``).split(/\s+/);if(t.length>=5){let[e,n,r]=t;return`drop-shadow(${e} ${n} ${r} ${t.slice(4).join(` `)})`}return`drop-shadow(${e.replace(/^inset\s+/i,``)})`}).join(` `)}function vt(e){let t={},n=G(e);for(let r of e){if(!r.category||r.category===`color`||!r.tokenKey||dt(r))continue;let e=ht(r);if(!e)continue;let i=gt(r,n);if(typeof i==`string`&&jt(i))continue;let a=t[r.category]??{};a[e]=i,t[r.category]=a}return t}function V(e){let t=e.tokenKey??e.path.replace(/^color\./i,``).replaceAll(`.`,``);return e.theme?`${e.theme}${t[0]?.toUpperCase()??``}${t.slice(1)}`:t}function H(e){return`tokens.color.${e}.val`}function yt(e,t){let n={},r=G(e),i=G(t),a=(e,t)=>{if(!e.tokenKey)return;let r=K(e,t);typeof r==`string`&&r.length!==0&&r!==`[object Object]`&&(n[V(e)]=r)};for(let t of e)a(t,r);for(let e of t)a(e,i);return n}function bt(e){let t={};for(let n of e){if(!n.primitive)continue;let e=J(n);if(!e)continue;let r=V(n);if(!r)continue;let i=t[e.name]??{};i[`${e.name}${e.step}`]=r,t[e.name]=i}let n=Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=2));if(Object.keys(n).length>0)return n;let r={};for(let t of e){let e=J(t);if(!e)continue;let n=t.tokenKey??V(t);if(!n)continue;let i=r[e.name]??{};i[`${e.name}${e.step}`]=n,r[e.name]=i}return Object.fromEntries(Object.entries(r).filter(([,e])=>Object.keys(e).length>=3))}function U(e,t,n,r){let i=n[r];if(typeof i!=`string`)return!1;let a=K(e,t);return a!=null&&a===i}function xt(e,t,n){let r=V(e);if(U(e,t,n,r))return H(r);if(e.tokenKey&&e.tokenKey!==r&&U(e,t,n,e.tokenKey))return H(e.tokenKey);let i=q(e,t.byPath,t.byCssVar),a=V(i);if(a!==r&&U(e,t,n,a))return H(a);if(i.tokenKey&&i.tokenKey!==a&&U(e,t,n,i.tokenKey))return H(i.tokenKey);if(i.primitive){let r=V(i);if(U(e,t,n,r))return H(r)}let o=K(e,t);if(o)return m(o)}function W(e,t=2){let n=` `.repeat(t),r=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return r.length===0?`{}`:`{\n${r.map(([e,t])=>{let r=typeof t==`string`&&mt(t)?t:m(t);return`${n}${/^[A-Z_$][\w$]*$/i.test(e)?e:m(e)}: ${r}`}).join(`,
|
|
52
|
+
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function St(e,t=2){let n=` `.repeat(t),r=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${/^[A-Z_$][\w$]*$/i.test(e)?e:m(e)}: ${t}`).join(`,
|
|
53
|
+
`)}\n${` `.repeat(Math.max(t-2,0))}}`}function Ct(e,t=2){let n=` `.repeat(t),r=` `.repeat(Math.max(t-2,0)),i=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0}));return i.length===0?`{\n${n}...theme\n${r}}`:`{\n${n}...theme,\n${i.map(([e,t])=>`${n}${/^[A-Z_$][\w$]*$/i.test(e)?e:m(e)}: ${t}`).join(`,
|
|
54
|
+
`)}\n${r}}`}const wt=/^\{([^{}]+)\}$/,Tt=/\{([^{}]+)\}/g,Et=/^var\((--[^),\s]+)(?:\s*,[^)]*)?\)$/,Dt=/var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g;function G(e){return{byPath:new Map(e.map(e=>[e.path,e])),byCssVar:new Map(e.map(e=>[s(e.path),e]))}}function Ot(e){if(typeof e==`string`)return wt.exec(e.trim())?.[1]?.trim()}function kt(e){if(typeof e==`string`)return Et.exec(e.trim())?.[1]}function At(e){return Ot(e)!=null||kt(e)!=null}function jt(e){return/var\(|\{[^{}]+\}/.test(e)}function K(e,t){let n=q(e,t.byPath,t.byCssVar);if(n.category!=null&&n.category!==`color`)return;let r=[n.cssValue,n.tamaguiValue];for(let e of r)if(typeof e==`string`&&e.length>0&&!At(e))return e}function Mt(e,t){return e.replace(Tt,(e,n)=>{let r=t.byPath.get(n.trim());return r?K(r,t)??e:e}).replace(Dt,(e,n)=>{let r=t.byCssVar.get(n);return r?K(r,t)??e:e})}function q(e,t,n){let r=e,i=new Set;for(let e=0;e<8;e++){if(i.has(r.path))return r;i.add(r.path);let e=Ot(r.value);if(e){let n=t.get(e);if(!n||n.path===r.path)return r;r=n;continue}let a=kt(r.value)??kt(r.cssValue)??kt(r.tamaguiValue);if(a){let e=n.get(a);if(!e||e.path===r.path)return r;r=e;continue}return r}return r}function Nt(e){return/^[A-Z_$][\w$]*$/i.test(e)?`theme.${e}`:`theme[${m(e)}]`}function Pt(e,t){return t<1?e:t+1-e}function Ft(e,t){return e.length<2?!1:X(e,t).some((t,n)=>t!==e[n])}function It(e,t,n,r){let i=n[t];if(!i||r!==`dark`)return e;let a=$(i,t);return a.length<2||!Ft(a.map(([,e])=>e),r)?e:Pt(e,a[a.length-1][0])}function Lt(e,t,n,r){let i=J(e);if(!i)return;let a=It(i.step,i.name,n,r);if(t&&i.name.toLowerCase()===t.toLowerCase()||n[i.name])return`${i.name}${a}`}function Rt(e){if(e>=1&&e<=12)return e;if(e>=100&&e<=900&&e%100==0)return e/100}function J(e){let t=e.path.split(`.`).filter(Boolean),n=t.at(-1);if(n&&/^\d+$/.test(n)){let e=Rt(Number(n)),r=t.at(-2);if(e!=null&&r&&!/^(?:color|colours?|palette)$/i.test(r))return{name:D([r]),step:e}}if(!e.tokenKey)return;let r=/^([A-Z]+)(\d{1,3})$/i.exec(e.tokenKey);if(!r)return;let[,i=``,a=``]=r,o=Rt(Number(a));if(o!=null)return{name:i,step:o}}function zt(e,t,n,r){let i=e[t]??{};i[`${t}${n}`]=r,e[t]=i}function Bt(e){let t={};for(let n of e){if(typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&zt(t,e.name,e.step,n.tamaguiValue)}return Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=3))}function Y(e){let t={};for(let n of e){if(!n.primitive||typeof n.tamaguiValue!=`string`)continue;let e=J(n);e&&zt(t,e.name,e.step,n.tamaguiValue)}let n=Object.fromEntries(Object.entries(t).filter(([,e])=>Object.keys(e).length>=2));return Object.keys(n).length>0?n:Bt(e)}function X(e,t){if(e.length<2)return[...e];let n=Wt(e[0]),r=Wt(e[e.length-1]);if(n==null||r==null||n===r)return[...e];let i=n>r;return t===`light`?i?[...e]:e.toReversed():i?e.toReversed():[...e]}function Z(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Vt(e){let t=e.startsWith(`#`)?e.slice(1):``;if((t.length===3||t.length===4)&&(t=[...t].map(e=>e+e).join(``)),t.length===8&&(t=t.slice(0,6)),t.length!==6||/[^0-9a-f]/i.test(t))return;let 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;return .2126*Z(n)+.7152*Z(r)+.0722*Z(i)}function Q(e){let t=e.trim();if(t.endsWith(`%`)){let e=Number.parseFloat(t);return Number.isFinite(e)?e/100:void 0}let n=Number.parseFloat(t);return Number.isFinite(n)?n:void 0}function Ht(e){return e>1?e/100:e}function Ut(e,t){let n=RegExp(`^${t}\\((.+)\\)$`,`i`).exec(e.trim());if(n?.[1])return n[1].split(/[\s,/]+/).filter(Boolean)}function Wt(e){let t=e.trim();if(!t||t.startsWith(`var(`)||t.includes(`{`))return;let n=Vt(t);if(n!=null)return n;let r=Ut(t,`oklch`);if(r?.[0]){let e=Q(r[0]);return e==null?void 0:Ht(e)}let i=Ut(t,`hsla?`);if(i?.[2]){let e=Q(i[2]);return e==null?void 0:Ht(e)}let a=Ut(t,`rgba?`);if(a?.[0]&&a[1]&&a[2]){let e=Q(a[0]),t=Q(a[1]),n=Q(a[2]);if(e==null||t==null||n==null)return;let r=(e,t)=>t.trim().endsWith(`%`)||e<=1?e:e/255;return .2126*Z(r(e,a[0]))+.7152*Z(r(t,a[1]))+.0722*Z(r(n,a[2]))}}function $(e,t){let n=[],r=t.toLowerCase();for(let[i,a]of Object.entries(e)){if(!i.toLowerCase().startsWith(r))continue;let e=i.slice(t.length);/^\d+$/.test(e)&&n.push([Number(e),a])}return n.sort(([e],[t])=>e-t),n}function Gt(e,t,n){let r=$(e,t);if(r.length===0)return e;let i=X(r.map(([,e])=>e),n),a={};for(let[e,[n]]of r.entries())a[`${t}${n}`]=i[e]??r[e][1];return a}function Kt(e,t,n){let r=t[n];return e.find(([,e])=>e===r)?.[0]??e[n]?.[0]??n+1}function qt(e,t,n,r){let i=$(e,n);if(i.length===0)return{};let a=X(i.map(([,e])=>e),r),o={};for(let[e,[r]]of i.entries()){let s=t[`${n}${Kt(i,a,e)}`];s&&(o[`${n}${r}`]=H(s))}return o}function Jt(e,t,n,r){let i=$(e,n);if(i.length<2)return;let a=X(i.map(([,e])=>e),r),o=[];for(let[e]of i.entries()){let r=t[`${n}${Kt(i,a,e)}`];if(!r)return;o.push(H(r))}let s=[...o],c=s.at(-1);if(c!=null){for(;s.length<12;)s.push(c);return`[${s.join(`,`)}]`}}function Yt(e,t){return $(e,t).length>=2}function Xt(e){if(e.length>=12)return e.slice(0,12);let t=[...e],n=t.at(-1);if(n==null)return t;for(;t.length<12;)t.push(n);return t}function Zt(e,t,n){let r=$(e,t);if(!(r.length<2))return Xt(X(r.map(([,e])=>e),n))}function Qt(e){let t=new Map;for(let n of e){let e=n.childTheme?.trim();if(!e)continue;let r=e.toLowerCase();lt(r)||ut(r)||t.has(r)||t.set(r,D([e]))}return[...t.values()].toSorted((e,t)=>e.localeCompare(t))}function $t(e,t){let n=t.toLowerCase(),r=e.split(/(?=[A-Z])/).filter(Boolean).filter(e=>e.toLowerCase()!==n);if(r.length!==0)return D(r)}function en(e){return e.toLowerCase()===`base`}function tn(e){return Qt(e).filter(e=>!en(e))}function nn(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}const rn=[{alias:`background`,source:e=>`background${e}`},{alias:`backgroundDisabled`,source:e=>`background${e}Disabled`},{alias:`backgroundHover`,source:e=>`background${e}Hover`},{alias:`backgroundSubtle`,source:e=>e===`Primary`?`backgroundSecondary`:`background${e}Subtle`},{alias:`border`,source:e=>`border${e}`},{alias:`borderDisabled`,source:e=>`border${e}Disabled`},{alias:`borderHover`,source:e=>`border${e}Hover`},{alias:`borderSubtle`,source:e=>e===`Primary`?`borderSecondary`:`border${e}Subtle`},{alias:`foreground`,source:e=>`foreground${e}`},{alias:`foregroundDisabled`,source:e=>`foreground${e}Disabled`},{alias:`foregroundHover`,source:e=>`foreground${e}Hover`},{alias:`foregroundOn`,source:e=>`foregroundOn${e}`},{alias:`foregroundOnDisabled`,source:e=>`foregroundOn${e}Disabled`},{alias:`foregroundOnHover`,source:e=>`foregroundOn${e}Hover`}];function an(e,t,n){let r=new Set([...Object.keys(e),...Object.keys(t)]),i=[`Primary`,...n.map(nn)],a=[];for(let{alias:e,source:t}of rn)i.some(e=>r.has(t(e)))&&a.push(e);return a}function on(e){let t={};for(let[n,r]of Object.entries(e)){if(en(n))continue;let e=Object.values(r);if(e.length===0)continue;let i={};for(let[t,r]of e.entries())i[`${n}${t+1}`]=r;Object.keys(i).length===1&&(i[`${n}2`]=e[0]),t[n]=i}return t}function sn(e){let t=e.split(/(?=[A-Z])/).filter(Boolean),n=t.at(-1)?.toLowerCase();if((n===`primary`||n===`secondary`||n===`tertiary`)&&!(t.length<2))return{role:D(t.slice(0,-1)),rank:n}}function cn(e){return e.category===`color`&&!e.primitive&&!!e.tokenKey}function ln(e,t,n){let r=new Map,i={};for(let a of e){if(!cn(a)||!a.tokenKey)continue;let e=a.childTheme?.toLowerCase();if(e&&e!==`base`)continue;let o=xt(a,t,n);if(!o)continue;let s=sn(a.tokenKey);if(s){let e=r.get(s.role)??{};e[s.rank]=o,r.set(s.role,e);continue}if(e===`base`){let e=$t(a.tokenKey,`base`);e&&(i[e]=o)}}let a={...i};for(let[e,t]of r){t.primary&&(a[e]=t.primary);let n=t.secondary??t.tertiary;n&&(a[`${e}Subtle`]=n)}return a}function un(e,t){let n=G(e),r={};for(let i of Qt(e)){if(en(i)){let a=ln(e,n,t);Object.keys(a).length>0&&(r[i]=a);continue}let a={},o=i.toLowerCase();for(let r of e){if(!cn(r)||r.childTheme?.toLowerCase()!==o)continue;let e=$t(r.tokenKey,i);if(!e)continue;let s=xt(r,n,t);s&&(a[e]=s)}Object.keys(a).length>0&&(r[i]=a)}return r}function dn(e,t){let n=new Map(Object.entries(e).map(([e,t])=>[e.toLowerCase(),{name:e,scale:t}]));for(let e of st){let r=n.get(e);if(!r)continue;let i=Zt(r.scale,r.name,t);if(i)return{name:r.name,palette:i}}}function fn(e){let t=e.filter(e=>e.category===`color`||e.primitive),n=Y(B(t,`light`)),r=Y(B(t,`dark`)),i=dn(n,`light`),a=dn(r,`dark`);return{lightPalette:i?.palette,darkPalette:a?.palette,lightBaseName:i?.name,darkBaseName:a?.name}}function pn(e,t,n){let r=Y(e),{byPath:i,byCssVar:a}=G(e),o={};for(let s of e){if(s.category!==`color`||!s.tokenKey||s.primitive||/^[A-Z]+\d{1,3}$/i.test(s.tokenKey)&&r[s.tokenKey.replace(/\d{1,3}$/,``)])continue;let e=q(s,i,a),c=Lt(e,t,r,n);if(c){o[s.tokenKey]=Nt(c);continue}let l=e.tamaguiValue;At(l)||At(e.cssValue)||(typeof l==`string`||typeof l==`number`)&&(o[s.tokenKey]=m(l))}return o}function mn(e){return e.replaceAll(`\\`,`\\\\`).replaceAll("`","\\`").replaceAll("${","\\${")}function hn(e,t,n,r,i){let a=q(e,t.byPath,t.byCssVar),o=Lt(a,n,r,i);if(o)return{kind:`theme`,property:o};let s=K(a,t);if(s)return{kind:`text`,value:s}}function gn(e,t,n,r,i){let a=[],o=/\{([^{}]+)\}|var\((--[^),\s]+)(?:\s*,[^)]*)?\)/g,s=0;for(let c of e.matchAll(o)){let o=c.index??0;o>s&&a.push({kind:`text`,value:e.slice(s,o)});let l=c[1]?t.byPath.get(c[1].trim()):c[2]?t.byCssVar.get(c[2]):void 0;if(!l)return;let u=hn(l,t,n,r,i);if(!u)return;a.push(u),s=o+c[0].length}return s<e.length&&a.push({kind:`text`,value:e.slice(s)}),a}function _n(e){return e.some(e=>e.kind===`theme`)?`\`${e.map(e=>e.kind===`theme`?`\${${Nt(e.property)}}`:mn(e.value)).join(``)}\``:m(e.map(e=>e.kind===`text`?e.value:``).join(``))}function vn(e,t,n){let r=G(e),i=Y(e.filter(e=>e.category===`color`)),a={};for(let o of e){if(!dt(o)||!o.tokenKey)continue;let e=typeof o.tamaguiValue==`string`?o.tamaguiValue:o.cssValue;if(typeof e!=`string`||e.length===0)continue;let s=gn(e,r,t,i,n);s&&(a[o.tokenKey]=_n(s))}return a}function yn(e,t,n,r,i){let a=new Set([...Object.keys(e),...Object.keys(t)]);if(a.size===0)return;let o=[];for(let s of[...a].toSorted((e,t)=>e.localeCompare(t))){let a=e[s]??t[s]??{},c=t[s]??e[s]??{};if(Object.keys(a).length===0||Object.keys(c).length===0)continue;let l=Yt(a,s)||Yt(c,s),u,d;if(i&&l?(u=qt(a,n[s]??r[s]??{},s,`light`),d=qt(c,r[s]??n[s]??{},s,`dark`),Object.keys(u).length===0&&(u=a),Object.keys(d).length===0&&(d=c)):l?(u=Gt(a,s,`light`),d=Gt(c,s,`dark`)):(u=a,d=c),Object.keys(u).length===0||Object.keys(d).length===0)continue;let f=l&&!i?(e,t)=>W(e,t):St;o.push(` ${s}: {
|
|
55
55
|
light: ${f(u,8)},
|
|
56
56
|
dark: ${f(d,8)}
|
|
57
57
|
}`)}if(o.length!==0)return`{\n${o.join(`,
|
|
58
|
-
`)}\n }`}function
|
|
59
|
-
|
|
60
|
-
? ${
|
|
61
|
-
: ${
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
`)}\n }`}function bn(e){let t=new Set;for(let n of e)for(let e of Object.values(n)){for(let n of e.matchAll(/theme\.([A-Z_$][\w$]*)/gi))n[1]&&t.add(n[1]);for(let n of e.matchAll(/theme\[(['"])(.+?)\1\]/g))t.add(n[2])}return[...t]}function xn(e,t){let n=new Set;for(let r of[e,t])for(let e of Object.values(r))for(let t of Object.keys(e))n.add(t);return[...n]}function Sn(e,t){let n=Math.max(e?.length??0,t?.length??0);if(n===0)return[];let r=[];for(let e=1;e<=Math.min(n,12);e++)r.push(`base${e}`);return r}function Cn(e){let t=new Set;for(let n of Object.keys(e.lightSemantic))t.add(n);for(let n of Object.keys(e.darkSemantic))t.add(n);for(let n of bn([e.lightSemantic,e.darkSemantic]))t.add(n);for(let n of xn(e.lightScales,e.darkScales))t.add(n);for(let n of Sn(e.lightPalette,e.darkPalette))t.add(n);for(let n of an(e.lightSemantic,e.darkSemantic,e.semanticRoles??[]))t.add(n);return[...t].toSorted((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))}function wn(e){return`const SEMANTIC_ROLES = new Set([${e.map(e=>m(e)).join(`, `)}]);`}function Tn(e,t){return` getTheme: ({ theme, scheme, name }: { theme: AppTheme; scheme: "light" | "dark"; name?: string }) => {
|
|
59
|
+
const values: Record<string, string> = scheme === "dark"
|
|
60
|
+
? ${Ct(t,8)}
|
|
61
|
+
: ${Ct(e,8)};
|
|
62
|
+
const child = name?.split("_")[1];
|
|
63
|
+
const role =
|
|
64
|
+
child && SEMANTIC_ROLES.has(child)
|
|
65
|
+
? child.charAt(0).toUpperCase() + child.slice(1)
|
|
66
|
+
: "Primary";
|
|
67
|
+
const overlay: Record<string, string> = {};
|
|
68
|
+
const assign = (alias: string, source: string) => {
|
|
69
|
+
const value = values[source];
|
|
70
|
+
if (value !== undefined) {
|
|
71
|
+
overlay[alias] = value;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
assign("background", \`background\${role}\`);
|
|
75
|
+
assign("backgroundDisabled", \`background\${role}Disabled\`);
|
|
76
|
+
assign("backgroundHover", \`background\${role}Hover\`);
|
|
77
|
+
assign("backgroundSubtle", role === "Primary" ? "backgroundSecondary" : \`background\${role}Subtle\`);
|
|
78
|
+
assign("border", \`border\${role}\`);
|
|
79
|
+
assign("borderDisabled", \`border\${role}Disabled\`);
|
|
80
|
+
assign("borderHover", \`border\${role}Hover\`);
|
|
81
|
+
assign("borderSubtle", role === "Primary" ? "borderSecondary" : \`border\${role}Subtle\`);
|
|
82
|
+
assign("foreground", \`foreground\${role}\`);
|
|
83
|
+
assign("foregroundDisabled", \`foreground\${role}Disabled\`);
|
|
84
|
+
assign("foregroundHover", \`foreground\${role}Hover\`);
|
|
85
|
+
assign("foregroundOn", \`foregroundOn\${role}\`);
|
|
86
|
+
assign("foregroundOnDisabled", \`foregroundOn\${role}Disabled\`);
|
|
87
|
+
assign("foregroundOnHover", \`foregroundOn\${role}Hover\`);
|
|
88
|
+
return {
|
|
89
|
+
...values,
|
|
90
|
+
...overlay
|
|
91
|
+
};
|
|
92
|
+
}`}function En(e){return` ${/^[A-Z_$][\w$]*$/i.test(e)?e:m(e)}: string;`}function Dn(e,t){if(e.length!==0)return[`/**`,` * Theme values available on \`useTheme()\` and \`$\` style props for the ${t.specName||`design system`}.`,` *`," * Derived from design tokens mapped by `createV5Theme` and `getTheme`.",` *`,` * @see https://tamagui.dev/docs/guides/theme-builder#gettheme`,` */`,`export interface AppTheme {`,...e.map(En),`}`,``]}function On(e,t,n={}){let r=e.fonts??{},i=n.useDefaultConfig===!0,a=n.animations??`css`,o=n.includeTypeAugmentation!==!1,s=t.filter(e=>e.category===`color`),c=B(s,`light`),l=B(s,`dark`),u=l.length>0?l:c,d=yt(c,l),f=Object.keys(d).length>0,p=bt(c),h=bt(u),g=Y(c),_=Y(u),ee=tn([...c,...u]),te={...on(un(c,d)),...g},v={...on(un(u,d)),..._},{lightPalette:y,darkPalette:b,lightBaseName:x,darkBaseName:S}=fn(t),ne=yn(te,v,p,h,f),re=f&&x?Jt(g[x]??{},p[x]??{},x,`light`):void 0,ie=f&&S?Jt(_[S]??{},h[S]??{},S,`dark`):void 0,ae=B(t,`light`),oe=B(t,`dark`),se=l.length>0?oe:ae,ce=l.length>0?S:x,C={...pn(c,x,`light`),...vn(ae,x,`light`)},w={...pn(l.length>0?l:c,ce,`dark`),...vn(se,ce,`dark`)},le=Dn(Cn({lightSemantic:C,darkSemantic:w,lightScales:te,darkScales:v,lightPalette:y,darkPalette:b,semanticRoles:ee}),{specName:e.name}),ue=vt(ae),T=[];Object.keys(d).length>0&&T.push(` color: ${W(d,4)}`);for(let e of pt){let t=ue[e];t&&Object.keys(t).length>0&&T.push(` ${e}: ${W(t,4)}`)}let E=[];re?E.push(` lightPalette: ${re}`):y&&E.push(` lightPalette: ${m(y)}`),ie?E.push(` darkPalette: ${ie}`):b&&E.push(` darkPalette: ${m(b)}`),ne&&E.push(` childrenThemes: ${ne}`),(Object.keys(C).length>0||Object.keys(w).length>0)&&E.push(Tn(C,w));let D=[`import { isWeb } from '@tamagui/constants';`];i?D.push(`import { createV5Theme, defaultConfig, type CreateV5ThemeOptions } from "@tamagui/config/v5";`):D.push(`import { createV5Theme, type CreateV5ThemeOptions } from "@tamagui/config/v5";`),a!==!1&&D.push(`import { animations } from "${ct[a]}";`),n.importConfig&&D.push(`import userConfig from "${n.importConfig}";`);let O=[`createTamagui`,`px`];T.length>0&&O.push(`createTokens`);let k=$e(t,r);k.length>0&&O.push(`createFont`),D.push(`import { ${O.join(`, `)} } from "@tamagui/core";`);let A=[`/* eslint-disable */`,``,`/*`,` * Generated by @razorwind/tamagui — Do not edit by hand.`,` * `,` * @see https://tamagui.dev/docs/core/config-v5`,` */`,``,...D,``];T.length>0&&A.push(`const tokens = createTokens({`,T.join(`,
|
|
93
|
+
`),`});`,``);let de=E.length>0?`createV5Theme({\n${E.join(`,
|
|
94
|
+
`)}\n})`:`createV5Theme()`;(Object.keys(C).length>0||Object.keys(w).length>0)&&A.push(wn(ee),``),A.push(`const themes = ${de};`,``);let j=new Map;if(k.length>0)for(let[e,t]of k.entries()){let n=tt(t.key,e);j.set(t.key,n),A.push(nt(t,n),``)}let M=[];if(i&&M.push(` ...defaultConfig`),a!==!1&&M.push(` animations`),T.length>0&&(i?M.push(` tokens: {
|
|
65
95
|
...defaultConfig.tokens,
|
|
66
96
|
...tokens,
|
|
67
97
|
space: {
|
|
@@ -80,19 +110,19 @@ Re-run Razorwind generate when tokens change so \`${e.outputPath}\` stays aligne
|
|
|
80
110
|
...defaultConfig.tokens.zIndex,
|
|
81
111
|
...tokens.zIndex
|
|
82
112
|
}
|
|
83
|
-
}`):
|
|
113
|
+
}`):M.push(` tokens`)),M.push(` themes`),j.size>0){let e=[...j.entries()].map(([e,t])=>` ${/^[A-Z_$][\w$]*$/i.test(e)?e:m(e)}: ${t}`);i?M.push(` fonts: {
|
|
84
114
|
...defaultConfig.fonts,
|
|
85
115
|
${e.join(`,
|
|
86
116
|
`)}
|
|
87
|
-
}`):
|
|
117
|
+
}`):M.push(` fonts: {
|
|
88
118
|
${e.join(`,
|
|
89
119
|
`)}
|
|
90
|
-
}`)}return n.shorthands&&
|
|
120
|
+
}`)}return n.shorthands&&M.push(` shorthands: ${W(n.shorthands,4)}`),n.media&&M.push(` media: ${m(n.media)}`),n.defaultFont&&M.push(` defaultFont: ${m(n.defaultFont)}`),A.push(``,...le??[],`/**
|
|
91
121
|
* The Tamagui v5 config for the ${e.name||`design system`}.
|
|
92
122
|
*
|
|
93
123
|
* @see https://tamagui.dev/docs/core/config-v5
|
|
94
124
|
*/
|
|
95
|
-
export const config = createTamagui({`,
|
|
96
|
-
`),n.importConfig?`, ...userConfig `:``,`});`,``,`export type AppConfig = typeof config;`,``),o&&
|
|
97
|
-
`)}function
|
|
125
|
+
export const config = createTamagui({`,M.join(`,
|
|
126
|
+
`),n.importConfig?`, ...userConfig `:``,`});`,``,`export type AppConfig = typeof config;`,``),o&&A.push(`declare module "@tamagui/core" {`,` // eslint-disable-next-line @typescript-eslint/no-empty-object-type`,` interface TamaguiCustomConfig extends AppConfig {}`,`}`,``),A.push(`export default config;`,``),A.join(`
|
|
127
|
+
`)}function kn(e,n={}){let r=e.tokens&&Object.keys(e.tokens).length>0,i=e.fonts&&Object.keys(e.fonts).length>0;if(!r&&!i)return{};let a=r?A(e.tokens,n):[];if(a.length===0&&!i)return{};let o=n.outputPath??`tamagui.config.ts`,s=On(e,a,n),c=n.installGuide??rt({outputPath:o}),d=u(l(o),`INSTALL.md`);return{[o]:t(o,s,{name:`razorwind-tamagui`},!1,`typescript`),[d]:t(d,c,{name:`razorwind-tamagui`},!1,`markdown`)}}var An=e(e=>({name:`tamagui`,themeGeneration:`combined`,generate:async t=>kn(t,e??{})}));export{Y as collectColorScales,$e as collectTamaguiFonts,Wt as colorLightness,An as default,A as flattenTokens,Pt as flipPaletteStep,tt as fontVarName,n as formatTokenValue,kn as generateTamaguiConfig,ie as isPaletteGroup,X as orderPaletteForScheme,rt as renderInstallMd,On as renderTamaguiConfig,E as resolveTokenCategory,a as resolveTokenSets,Me as tamaguiFontKeyFromRole,D as toCamelCaseKey,o as toCssVar,h as toTamaguiValue,O as toTokenKey,Pe as typographyFontKey};
|
|
98
128
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/tamagui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Razorwind plugin that creates Tamagui theme tokens from Razorwind design tokens.",
|
|
6
6
|
"repository": {
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"typescript": "^6.0.3"
|
|
107
107
|
},
|
|
108
108
|
"publishConfig": { "access": "public" },
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "68f899ea992d9abd50d826ae278ef61084c56ec2"
|
|
110
110
|
}
|