@cyclone-ui/theme-builder 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/generate.cjs +2 -1
- package/dist/generate.d.cts +4 -2
- package/dist/generate.d.cts.map +1 -1
- package/dist/generate.d.mts +4 -3
- package/dist/generate.mjs +2 -1
- package/dist/generate.mjs.map +1 -1
- package/dist/preprocessor.cjs +1 -1
- package/dist/preprocessor.d.cts +2 -3
- package/dist/preprocessor.d.cts.map +1 -1
- package/dist/preprocessor.d.mts +2 -3
- package/dist/preprocessor.mjs +1 -1
- package/dist/preprocessor.mjs.map +1 -1
- package/package.json +5 -5
- package/src/generate.ts +87 -7
- package/src/preprocessor.ts +39 -21
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Cyclone UI - Theme Builder
|
|
4
4
|
|
|
5
|
+
## [0.0.15](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.15) (10/22/2026)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **tokens:** Update token structure to better allow customizations ([7f23eb61](https://github.com/storm-software/cyclone-ui/commit/7f23eb61))
|
|
10
|
+
|
|
5
11
|
## [0.0.12](https://github.com/storm-software/cyclone-ui/releases/tag/theme-builder%400.0.12) (10/18/2026)
|
|
6
12
|
|
|
7
13
|
### Miscellaneous
|
package/dist/generate.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@razorwind/core/plugin"),l=require("@razorwind/tamagui/generate");l=s(l);
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@razorwind/core/plugin"),l=require("@razorwind/tamagui/generate");l=s(l);const u=e=>Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0})).map(([e,t])=>` ${/^\d/.test(e)?`"${e}"`:e}: ${t}`).join(`,
|
|
2
|
+
`),d=e=>Object.fromEntries([...e.matchAll(/^\s*"?([\w-]+)"?: ([\d.]+),?$/gmu)].map(([,e,t])=>[e,Number(t)])),f=e=>e.replaceAll(/(\n {2}size: \{\n)([^}]*)(\n {2}\},\n {2}lineHeight: \{\n)([^}]*)(\n {2}\})/gu,(e,t,n,r,i,a)=>{let o=d(n),s=d(i),c=s.true??Object.values(s)[0];if(c==null||c<=0||c>4)return e;let l=e=>Math.round(e*1e3)/1e3,f=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,l(c*t)])),p=f.sm??Object.values(f)[0]??c;return`${t}${n}${r}${u({...Object.fromEntries(Object.keys(s).map(e=>[e,p])),...f})}${a}`}),p=(e,t)=>e.replaceAll(`from "tamagui";`,`from "${t}";`).replaceAll(`declare module "tamagui"`,`declare module "${t}"`);var m=(0,c.definePlugin)((e={})=>{let t={animations:`motion`,defaultFont:`body`,target:`v3`,tamaguiModule:`@tamagui/core`,...e},n=(0,l.default)(t),r=n.generate,i=t.tamaguiModule??`tamagui`,a=e=>{for(let t of Object.values(e??{}))for(let e of t?.chunks??[])typeof e.content==`string`&&e.content.includes(`createTamagui(`)&&(e.content=p(f(e.content),i));return e};return{...n,name:`cyclone-ui:tamagui-generate`,generate:async(...[e,t])=>{if(!r||!e.fonts)return a(await r?.(e,t)??{});let n=Object.fromEntries(Object.entries(e.fonts).map(([e,t])=>t.source!==`local`||!t.files?[e,t]:[e,{...t,files:t.files.filter(e=>typeof e.weight!=`string`||/^\d+(?:\.\d+)?$/u.test(e.weight.trim()))}]));return a(await r({...e,fonts:n},t))}}});module.exports=m;
|
package/dist/generate.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TamaguiPluginOptions } from "@razorwind/tamagui";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type GenerateOptions = TamaguiPluginOptions & {
|
|
3
|
+
tamaguiModule?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: (options?: GenerateOptions | undefined) => import("@razorwind/core/plugin").Plugin;
|
|
4
6
|
export = _default;
|
|
5
7
|
//# sourceMappingURL=generate.d.cts.map
|
package/dist/generate.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.cts","names":[],"sources":["../src/generate.ts"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"generate.d.cts","names":[],"sources":["../src/generate.ts"],"mappings":";KA6EK,kBAAkB;EAAyB"}
|
package/dist/generate.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TamaguiPluginOptions } from "@razorwind/tamagui";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type GenerateOptions = TamaguiPluginOptions & {
|
|
3
|
+
tamaguiModule?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: (options?: GenerateOptions | undefined) => import("@razorwind/core/plugin").Plugin;
|
|
5
6
|
export { _default as default };
|
|
6
7
|
//# sourceMappingURL=generate.d.mts.map
|
package/dist/generate.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import{definePlugin as e}from"@razorwind/core/plugin";import t from"@razorwind/tamagui/generate";
|
|
1
|
+
import{definePlugin as e}from"@razorwind/core/plugin";import t from"@razorwind/tamagui/generate";const n=e=>Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0})).map(([e,t])=>` ${/^\d/.test(e)?`"${e}"`:e}: ${t}`).join(`,
|
|
2
|
+
`),r=e=>Object.fromEntries([...e.matchAll(/^\s*"?([\w-]+)"?: ([\d.]+),?$/gmu)].map(([,e,t])=>[e,Number(t)])),i=e=>e.replaceAll(/(\n {2}size: \{\n)([^}]*)(\n {2}\},\n {2}lineHeight: \{\n)([^}]*)(\n {2}\})/gu,(e,t,i,a,o,s)=>{let c=r(i),l=r(o),u=l.true??Object.values(l)[0];if(u==null||u<=0||u>4)return e;let d=e=>Math.round(e*1e3)/1e3,f=Object.fromEntries(Object.entries(c).map(([e,t])=>[e,d(u*t)])),p=f.sm??Object.values(f)[0]??u;return`${t}${i}${a}${n({...Object.fromEntries(Object.keys(l).map(e=>[e,p])),...f})}${s}`}),a=(e,t)=>e.replaceAll(`from "tamagui";`,`from "${t}";`).replaceAll(`declare module "tamagui"`,`declare module "${t}"`);var o=e((e={})=>{let n={animations:`motion`,defaultFont:`body`,target:`v3`,tamaguiModule:`@tamagui/core`,...e},r=t(n),o=r.generate,s=n.tamaguiModule??`tamagui`,c=e=>{for(let t of Object.values(e??{}))for(let e of t?.chunks??[])typeof e.content==`string`&&e.content.includes(`createTamagui(`)&&(e.content=a(i(e.content),s));return e};return{...r,name:`cyclone-ui:tamagui-generate`,generate:async(...[e,t])=>{if(!o||!e.fonts)return c(await o?.(e,t)??{});let n=Object.fromEntries(Object.entries(e.fonts).map(([e,t])=>t.source!==`local`||!t.files?[e,t]:[e,{...t,files:t.files.filter(e=>typeof e.weight!=`string`||/^\d+(?:\.\d+)?$/u.test(e.weight.trim()))}]));return c(await o({...e,fonts:n},t))}}});export{o as default};
|
|
2
3
|
//# sourceMappingURL=generate.mjs.map
|
package/dist/generate.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.mjs","names":["tamagui","generate_default","definePlugin","
|
|
1
|
+
{"version":3,"file":"generate.mjs","names":["tamagui","renderScale","scale","a","b","key","value","parseScale","body","scaleRatioLineHeights","content","sizes","sizeBody","lineHeights","lineHeightBody","ratio","match","round","size","base","open","middle","close","replaceTamaguiModule","tamaguiModule","generate_default","definePlugin","resolvedOptions","options","tamaguiPlugin","generateTamagui","shimConfig","document","documents","chunk","spec","config","fonts","name","font","file"],"sources":[],"mappings":""}
|
package/dist/preprocessor.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin");const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},me=[`shadows`];function A(e){return Object.entries(e).filter(e=>!me.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const he={primary:E,secondary:pe,link:E},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.45},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},_e={outline:{lowSaturation:[de,w,T],saturated:[ue,fe,T]}},j=7.5,M=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function be(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function xe(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),W(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),W(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Ee(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function De(e,t){return!Ee(e,t)}const Oe=B(`#dddddd`).lightness,ke=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?Oe:.75)}function q(e){return B(e).lightness<=(R(e)?ke:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function Ae(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function je(e,t,n){return De(e,n)?t:2-t}function Y(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function Me(e,t,n){if(t.name===`hovered`&&Y(t,n)&&Ae(e,n))return n===`dark`?-.25:.25}function Ne(e,t,n){let r=Y(t,n);return r&&n&&t.name===`active`&&Ae(e,n)?ae[n]:r}function X(e,t,n){return t.brightness===void 0?1:Y(t,n)?J(t)?1:t.brightness:je(e,t.brightness,n)}function Pe(e,t,n){let r=Me(e,t,n),i=r===void 0?Ne(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=Se(a,X(a,t,n))):a=Ce(e,r),t.saturation!==void 0&&!z(e)&&(a=we(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):be(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=Me(t,e,n),a=Ne(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=X(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Z(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=Te(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(he))c=Z(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function Q(e,t,n,o){if(Array.isArray(e))return e.map(e=>Q(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:Q(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of A(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Z(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Z(c,t,n,e,o));return n===`color`?Re(c):c}function $(e){let t=x(e),n=xe(Q(t,t,void 0,oe(t)));return F(n,n)}var Be=(0,e.definePlugin)(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:$}]}));exports.default=Be,exports.tamaguiPreprocessor=$;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@razorwind/core/plugin");const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`group`,`semantic`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},me=[`shadows`];function A(e){return Object.entries(e).filter(e=>!me.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const j={lowSaturation:[de,w,T],saturated:[ue,fe,T]},he={primary:E,secondary:pe,link:E,outline:j},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.25},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},_e={outline:j},M=7.5,N=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function P(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return P(a.$value,t,n)}function be(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function xe(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=P(e.color,t);return n?{...e,color:be(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function Se(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,7)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Ee(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*N),d=H(l,r,i,a),W(d,f)>=M)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*N),f=H(u,r,i,a),W(d,f)>=M)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function De(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function Oe(e,t){return!De(e,t)}const ke=B(`#fefefe`).lightness,Ae=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?ke:.75)}function q(e){return B(e).lightness<=(R(e)?Ae:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function Y(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function je(e,t,n){return Oe(e,n)?t:2-t}function X(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function Z(e,t,n){if(t.name===`hovered`&&X(t,n)&&Y(e,n))return n===`dark`?-.25:.25}function Me(e,t,n){let r=X(t,n);return r&&n&&t.name===`active`&&Y(e,n)?ae[n]:r}function Ne(e,t,n){return t.brightness===void 0?1:X(t,n)?J(t)?1:t.brightness:je(e,t.brightness,n)}function Pe(e,t,n){let r=Z(e,t,n),i=r===void 0?Me(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=Ce(a,Ne(a,t,n))):a=we(e,r),t.saturation!==void 0&&!z(e)&&(a=Te(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:be(a,t.opacity):xe(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=Z(t,e,n),a=Me(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Ne(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Q(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=P(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&P(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},t.group===`status`&&(c.outline??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} border and divider color (matches primary)`}),c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=Ee(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=P(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(he))c=Q(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of A(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Q(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Q(c,t,n,e,o));return n===`color`?Re(c):c}function Be(e){let t=x(e),n=Se($(t,t,void 0,oe(t)));return F(n,n)}var Ve=(0,e.definePlugin)(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:Be}]}));exports.default=Ve,exports.tamaguiPreprocessor=Be;
|
package/dist/preprocessor.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PreprocessedTokens } from "style-dictionary/types";
|
|
2
|
-
//#region src/preprocessor.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
|
|
5
4
|
* colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
|
|
@@ -9,7 +8,8 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
9
8
|
* `on-secondary` text colors are generated, then hovered, active, inactive,
|
|
10
9
|
* and disabled variants are added to the outline, `foreground` and
|
|
11
10
|
* `background` group colors, and each theme color group's `primary`, `secondary`
|
|
12
|
-
* and `
|
|
11
|
+
* `link` and `outline` (`link`, and `outline` in `status` groups, default to
|
|
12
|
+
* `primary` when missing).
|
|
13
13
|
* Low-saturation colors derive their states from the parent theme's contrast
|
|
14
14
|
* primitive (backgrounds use a half-strength shift of their own lightness; hovered
|
|
15
15
|
* colors already near that primitive shift toward the middle, while active
|
|
@@ -23,6 +23,5 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
23
23
|
*/
|
|
24
24
|
declare function tamaguiPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
|
|
25
25
|
declare const _default: (options?: unknown) => import("@razorwind/core/plugin").Plugin;
|
|
26
|
-
//#endregion
|
|
27
26
|
export { _default as default, tamaguiPreprocessor };
|
|
28
27
|
//# sourceMappingURL=preprocessor.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.d.cts","names":[],"sources":["../src/preprocessor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"preprocessor.d.cts","names":[],"sources":["../src/preprocessor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBAqiDgB,oBACd,YAAY,qBACX"}
|
package/dist/preprocessor.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PreprocessedTokens } from "style-dictionary/types";
|
|
2
|
-
//#region src/preprocessor.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Style Dictionary preprocessor: rewrite color `$value`s (and nested shadow
|
|
5
4
|
* colors) to hex so generators emit `#rrggbb` / `#rrggbbaa` instead of
|
|
@@ -9,7 +8,8 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
9
8
|
* `on-secondary` text colors are generated, then hovered, active, inactive,
|
|
10
9
|
* and disabled variants are added to the outline, `foreground` and
|
|
11
10
|
* `background` group colors, and each theme color group's `primary`, `secondary`
|
|
12
|
-
* and `
|
|
11
|
+
* `link` and `outline` (`link`, and `outline` in `status` groups, default to
|
|
12
|
+
* `primary` when missing).
|
|
13
13
|
* Low-saturation colors derive their states from the parent theme's contrast
|
|
14
14
|
* primitive (backgrounds use a half-strength shift of their own lightness; hovered
|
|
15
15
|
* colors already near that primitive shift toward the middle, while active
|
|
@@ -23,6 +23,5 @@ import { PreprocessedTokens } from "style-dictionary/types";
|
|
|
23
23
|
*/
|
|
24
24
|
declare function tamaguiPreprocessor(dictionary: PreprocessedTokens): PreprocessedTokens;
|
|
25
25
|
declare const _default: (options?: unknown) => import("@razorwind/core/plugin").Plugin;
|
|
26
|
-
//#endregion
|
|
27
26
|
export { _default as default, tamaguiPreprocessor };
|
|
28
27
|
//# sourceMappingURL=preprocessor.d.mts.map
|
package/dist/preprocessor.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},me=[`shadows`];function A(e){return Object.entries(e).filter(e=>!me.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const he={primary:E,secondary:pe,link:E},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.45},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},_e={outline:{lowSaturation:[de,w,T],saturated:[ue,fe,T]}},j=7.5,M=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function N(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return N(a.$value,t,n)}function P(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function be(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=N(e.color,t);return n?{...e,color:P(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function xe(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,6)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Se(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*M),d=H(l,r,i,a),W(d,f)>=j)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*M),f=H(u,r,i,a),W(d,f)>=j)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function Ee(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function De(e,t){return!Ee(e,t)}const Oe=B(`#dddddd`).lightness,ke=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?Oe:.75)}function q(e){return B(e).lightness<=(R(e)?ke:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function Ae(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function je(e,t,n){return De(e,n)?t:2-t}function Y(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function Me(e,t,n){if(t.name===`hovered`&&Y(t,n)&&Ae(e,n))return n===`dark`?-.25:.25}function Ne(e,t,n){let r=Y(t,n);return r&&n&&t.name===`active`&&Ae(e,n)?ae[n]:r}function X(e,t,n){return t.brightness===void 0?1:Y(t,n)?J(t)?1:t.brightness:je(e,t.brightness,n)}function Pe(e,t,n){let r=Me(e,t,n),i=r===void 0?Ne(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=Se(a,X(a,t,n))):a=Ce(e,r),t.saturation!==void 0&&!z(e)&&(a=we(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:P(a,t.opacity):be(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=Me(t,e,n),a=Ne(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=X(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Z(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=N(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&N(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=Te(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=N(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(he))c=Z(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function Q(e,t,n,o){if(Array.isArray(e))return e.map(e=>Q(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:Q(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of A(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Z(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Z(c,t,n,e,o));return n===`color`?Re(c):c}function $(e){let t=x(e),n=xe(Q(t,t,void 0,oe(t)));return F(n,n)}var Be=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:$}]}));export{Be as default,$ as tamaguiPreprocessor};
|
|
1
|
+
import{definePlugin as e}from"@razorwind/core/plugin";const t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^oklch\(\s*([0-9.]+%?|none)\s+([0-9.]+|none)\s+([0-9.]+|none)(?:\s*\/\s*([0-9.%]+))?\s*\)$/i,r=/* @__PURE__ */ new Set([`$schema`,`$type`,`$description`,`$extensions`,`$extends`,`$deprecated`,`$root`,`$value`,`$ref`,`theme`,`group`,`semantic`,`palette`,`primitive`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return i(e)&&(`$value`in e||`$ref`in e)}function o(e){let t=e.trim();return t.startsWith(`{`)||t.startsWith(`var(`)}function s(e){return Math.min(1,Math.max(0,e))}function c(e){let t=s(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function l(e){let t=s(e);return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function u(e){return Math.round(c(e)*255).toString(16).padStart(2,`0`)}function d(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function f(e){return Math.round(s(e)*255).toString(16).padStart(2,`0`)}function p(e){let t=e.startsWith(`#`)?e.slice(1):e;return t.length===3||t.length===4?`#${[...t].map(e=>e+e).join(``)}`:`#${t}`}function m(e){if(typeof e==`string`){let n=e.trim();if(!t.test(n))return;let r=p(n).toLowerCase();return r.length===9&&r.endsWith(`ff`)?r.slice(0,7):r}if(i(e)){if(typeof e.hex==`string`&&t.test(e.hex)){let t=p(e.hex).toLowerCase().slice(0,7),n=v(e.alpha);return n!==void 0&&n<1?`${t}${f(n)}`:t}if(e.colorSpace===`srgb`&&Array.isArray(e.components)&&e.components.length>=3){let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t===void 0||n===void 0||r===void 0)return;let i=`#${d(t)}${d(n)}${d(r)}`,a=v(e.alpha);return a!==void 0&&a<1?`${i}${f(a)}`:i}}}function h(e,t,n){let r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o**3,u=s**3,d=c**3;return{red:4.0767416621*l-3.3077115913*u+.2309699292*d,green:-1.2684380046*l+2.6097574011*u-.3413193965*d,blue:-.0041960863*l-.7034186147*u+1.707614701*d}}function g(e,t,n,r){let{red:i,green:a,blue:o}=h(e,t,n),s=`#${u(i)}${u(a)}${u(o)}`;return r===void 0||r>=1?s:`${s}${f(r)}`}function _(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`||e===`none`)return;let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return e>1?e/100:e;if(typeof e!=`string`)return;let t=Number.parseFloat(e);if(Number.isFinite(t))return e.includes(`%`)||t>1?t/100:t}function ee(e){let t=n.exec(e.trim());if(!t)return;let r=_(t[1]),i=_(t[2]),a=_(t[3]);if(r!==void 0&&i!==void 0&&a!==void 0)return t[1]?.includes(`%`)&&(r/=100),g(r,i,a,v(t[4]))}function te(e){if(!Array.isArray(e.components)||e.components.length<3)return;let t=_(e.components[0]),n=_(e.components[1]),r=_(e.components[2]);if(t!==void 0&&n!==void 0&&r!==void 0)return t>1&&(t/=100),g(t,n,r,v(e.alpha))}function y(e){if(typeof e==`string`)return o(e)?void 0:ee(e)??m(e)??void 0;if(i(e))return typeof e.colorSpace==`string`&&e.colorSpace.toLowerCase()===`oklch`?te(e):m(e)??void 0}function ne(e){if(Array.isArray(e))return e.map(e=>ne(e));if(!i(e)||!(`color`in e))return e;let t=y(e.color);return t?{...e,color:t}:e}function re(e,t){if(t===`shadow`)return ne(e);if(t===`border`&&i(e)&&`color`in e){let t=y(e.color);return t?{...e,color:t}:e}return t===`color`||t===void 0?y(e)??e:e}function b(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function ie(e,t){if(`$ref`in e&&!(`$value`in e))return{...e};let n=b(e,t);return`$value`in e?{...e,$value:re(e.$value,n)}:{...e}}function x(e,t){if(Array.isArray(e))return e.map(e=>x(e,t));if(!i(e))return e;if(a(e))return ie(e,t);let n=typeof e.$type==`string`?e.$type:t,o={};for(let[t,i]of Object.entries(e))o[t]=r.has(t)||t.startsWith(`$`)?i:x(i,n);return o}const S={dark:`#ffffff`,light:`#0c0c0d`},ae={dark:`#ffffff`,light:`#000000`};function C(e){if(typeof e!=`string`)return;let t=/\b(dark|light)[\s-]+theme\b/i.exec(e)?.[1];return t?.toLowerCase()===`dark`?`dark`:t?.toLowerCase()===`light`?`light`:void 0}function oe(e){if(i(e)&&i(e.color))return C(e.color.$description)}const se={name:`active`,brightness:1.45,useContrastPrimitive:!0},ce={name:`active`,brightness:1.25},le={name:`active`,brightness:1.125},ue={name:`active`,brightness:1.4},de={name:`active`,brightness:1.8,useContrastPrimitive:!0},fe={name:`inactive`,brightness:.8},w={name:`inactive`,brightness:.5,useContrastPrimitive:!0},T={name:`disabled`,opacity:.35,saturation:.85,fadeOver:`oklch(0.3839 0.0045 286.26)`},E={lowSaturation:[se,w,T],saturated:[ce,fe,T]},pe={lowSaturation:[le,w,T],saturated:E.saturated},D={name:`inactive`,brightness:.9},O={...T,opacity:.675,saturation:.925},k={lowSaturation:[{name:`active`,brightness:1.15},D,O],saturated:[{name:`active`,brightness:1.25},D,O]},me=[`shadows`];function A(e){return Object.entries(e).filter(e=>!me.includes(e[0])&&i(e[1])&&!a(e[1])&&a(e[1].primary))}const j={lowSaturation:[de,w,T],saturated:[ue,fe,T]},he={primary:E,secondary:pe,link:E,outline:j},ge={foreground:{lowSaturation:[{name:`hovered`,brightness:1.25},...E.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...E.saturated]},background:{lowSaturation:[{name:`hovered`,brightness:1.1},...k.lowSaturation],saturated:[{name:`hovered`,brightness:1.15},...k.saturated]}},_e={outline:j},M=7.5,N=.01;function ve(e){return e.toLowerCase().endsWith(`-hovered`)||e.toLowerCase().endsWith(`-active`)||e.toLowerCase().endsWith(`-inactive`)||e.toLowerCase().endsWith(`-disabled`)}function ye(e,t){let n=e;for(let e of t.split(`.`).filter(Boolean)){if(!i(n)||!(e in n))return;n=n[e]}return a(n)?n:void 0}function P(e,t,n=/* @__PURE__ */ new Set){let r=y(e);if(r)return r;if(typeof e!=`string`)return;let i=/^\{([^{}]+)\}$/.exec(e.trim());if(!i?.[1]||n.has(i[1]))return;n.add(i[1]);let a=ye(t,i[1]);if(a&&`$value`in a)return P(a.$value,t,n)}function be(e,t){let n=p(e).toLowerCase(),r=n.slice(0,7),i=s((n.length===9?Number.parseInt(n.slice(7,9),16)/255:1)*t);return i>=1?r:`${r}${f(i)}`}function xe(e,t,n){let r=p(e).toLowerCase(),i=p(y(t)??t).toLowerCase(),a=s((r.length===9?Number.parseInt(r.slice(7,9),16)/255:1)*n),o=e=>d((Number.parseInt(r.slice(e,e+2),16)*a+Number.parseInt(i.slice(e,e+2),16)*(1-a))/255);return`#${o(1)}${o(3)}${o(5)}`}function F(e,t,n=!1){if(Array.isArray(e))return e.map(e=>F(e,t,n));if(!i(e))return e;if(n&&a(e)&&b(e)===`shadow`){let n=e.$value,r=e=>{if(!i(e)||!(`color`in e))return e;let n=P(e.color,t);return n?{...e,color:be(n,R(n)?.1:.15)}:e};return{...e,$value:Array.isArray(n)?n.map((e,t)=>t===n.length-1?r(e):e):r(n)}}let r={};for(let[i,a]of Object.entries(e))r[i]=F(a,t,n||i.toLowerCase()===`ring`);return r}const I={value:0,unit:`px`};function L(e,t){return{color:e,offsetX:I,offsetY:I,blur:I,spread:{value:t,unit:`px`}}}function Se(e){if(!i(e)||!i(e.color))return e;let t=e.color,n=i(e.ring)?{...e.ring}:{},r=!1;for(let[e]of A(t)){let t=`{color.${e}.primary}`,i=e=>L(`{color.elevated}`,e),a={[e]:[`${e} 3px focus ring with no gap`,[L(t,3)]],[`${e}-subtle`]:[`${e} 1px outline focus ring with no gap`,[L(t,1)]],[`${e}-offset`]:[`${e} 3px focus ring with a 3px gap`,[i(3),L(t,7)]],[`${e}-subtle-offset`]:[`${e} 1px focus ring with a 2px gap`,[i(2),L(t,3)]]};for(let[t,[i,o]]of Object.entries(a))t in n||(n[t]={$description:`Generated ${i}`,$type:`shadow`,$value:o,theme:e},r=!0)}return r?{...e,ring:n}:e}function R(e){return B(e).chroma<.02}function z(e){let t=p(e).toLowerCase();return t.slice(1,3)===t.slice(3,5)&&t.slice(3,5)===t.slice(5,7)}function B(e){let t=p(e).toLowerCase(),n=l(Number.parseInt(t.slice(1,3),16)/255),r=l(Number.parseInt(t.slice(3,5),16)/255),i=l(Number.parseInt(t.slice(5,7),16)/255),a=t.length===9?Number.parseInt(t.slice(7,9),16)/255:void 0,o=.4122214708*n+.5363325363*r+.0514459929*i,s=.2119034982*n+.6806995451*r+.1073969566*i,c=.0883024619*n+.2817188376*r+.6299787005*i,u=Math.cbrt(o),d=Math.cbrt(s),f=Math.cbrt(c),m=.2104542553*u+.793617785*d-.0040720468*f,h=1.9779984951*u-2.428592205*d+.4505937099*f,g=.0259040371*u+.7827717662*d-.808675766*f,_=Math.hypot(h,g),v=Math.atan2(g,h)*180/Math.PI;return v<0&&(v+=360),{lightness:m,chroma:_,hue:v,alpha:a}}function V({red:e,green:t,blue:n}){return e>=0&&e<=1&&t>=0&&t<=1&&n>=0&&n<=1}function H(e,t,n,r){if(V(h(e,t,n)))return g(e,t,n,r);let i=0,a=t;for(let t=0;t<32;t+=1){let t=(i+a)/2;V(h(e,t,n))?i=t:a=t}return g(e,i,n,r)}function Ce(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n*t),r,i,a)}function we(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(s(n+t),r,i,a)}function Te(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e);return g(n,r*s(t),i,a)}function U(e){let t=p(e).toLowerCase(),n=e=>{let n=Number.parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(1)+.7152*n(3)+.0722*n(5)}function W(e,t){let n=U(e),r=U(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function G(e){let t=W(e,`#FAFAFA`);return t>=2?`#FAFAFA`:W(e,`#151518`)*.5>t?`#151518`:`#FAFAFA`}function Ee(e,t){let{lightness:n,chroma:r,hue:i,alpha:a}=B(e),o=t===`light`?1:-1,c=-o,l=n,u=n,d=e,f=e;for(let t=0;t<100;t+=1){if(l=s(l+o*N),d=H(l,r,i,a),W(d,f)>=M)return f===e?{secondary:d}:{secondary:d,onMuted:f};if(u=s(u+c*N),f=H(u,r,i,a),W(d,f)>=M)return{secondary:d,onMuted:f};if((l===0||l===1)&&(u===0||u===1))break}throw Error(`Unable to generate an accessible secondary pair for ${e}`)}function De(e,t){return t===`dark`?K(e):t===`light`?!q(e):B(e).lightness>=.5}function Oe(e,t){return!De(e,t)}const ke=B(`#fefefe`).lightness,Ae=B(`#262626`).lightness;function K(e){return B(e).lightness>=(R(e)?ke:.75)}function q(e){return B(e).lightness<=(R(e)?Ae:.25)}function J(e){return e.name===`hovered`||e.name===`active`}function Y(e,t){return t===`dark`?K(e):t===`light`&&q(e)}function je(e,t,n){return Oe(e,n)?t:2-t}function X(e,t){return e.useContrastPrimitive&&t?S[t]:void 0}function Z(e,t,n){if(t.name===`hovered`&&X(t,n)&&Y(e,n))return n===`dark`?-.25:.25}function Me(e,t,n){let r=X(t,n);return r&&n&&t.name===`active`&&Y(e,n)?ae[n]:r}function Ne(e,t,n){return t.brightness===void 0?1:X(t,n)?J(t)?1:t.brightness:je(e,t.brightness,n)}function Pe(e,t,n){let r=Z(e,t,n),i=r===void 0?Me(e,t,n):void 0,a=i??e;return r===void 0?t.brightness!==void 0&&!(i&&J(t))&&(a=Ce(a,Ne(a,t,n))):a=we(e,r),t.saturation!==void 0&&!z(e)&&(a=Te(a,t.saturation),t.fadeOver===void 0)?a:t.fadeOver===void 0?t.opacity===void 0?a:be(a,t.opacity):xe(a,t.fadeOver,t.opacity??1)}function Fe(e,t,n){let r=[],i=Z(t,e,n),a=Me(t,e,n);if(i!==void 0)r.push(`${Math.round(Math.abs(i)*100)}% ${i<0?`darker`:`lighter`}`);else if(a&&J(e))r.push(n&&a!==S[n]?`pure ${n===`dark`?`white`:`black`}`:`${n} contrast primitive`);else if(e.brightness!==void 0){let i=Ne(t,e,n),a=Math.round((i-1)*100);r.push(a>=0?`${a}% brighter`:`${Math.abs(a)}% darker`)}return e.saturation!==void 0&&!z(t)&&r.push(`${Math.round(e.saturation*100)}% saturation`),e.fadeOver===void 0?e.opacity!==void 0&&(e.saturation===void 0||z(t))&&r.push(`${Math.round(e.opacity*100)}% opacity`):r.push(`${Math.round((e.opacity??1)*100)}% over ${e.fadeOver}`),r.join(`, `)||e.name}function Ie(e,t,n,r){let i=Fe(n,t,r),a=Pe(t,n,r);return{...e,$type:`color`,$value:a,$description:typeof e.$description==`string`?`${e.$description} (${n.name}, ${i})`:`${n.name} state at ${i}`}}function Q(e,t,n,r,i){let o={...e},s=r?[r]:Object.keys(e);for(let r of s){if(r.startsWith(`$`)||ve(r))continue;let s=e[r];if(!a(s))continue;let c=b(s);if(c&&c!==`color`)continue;let l=P(s.$value,t);if(!l)continue;let u=R(l)?n.lowSaturation:n.saturated,d=u.some(e=>e.name===`hovered`),f=u.flatMap(e=>e.name===`active`&&!d?[{...e,name:`hovered`},e]:[e]),p=C(s.$description)??i;for(let e of f){let t=`${r}-${e.name}`;t in o||(o[t]=Ie(s,l,e,p))}}return o}function Le(e,t,n,r){let i=t.primary,o=a(i)&&P(i.$value,n),s=a(i)&&b(i);if(!a(i)||!o||s&&s!==`color`)return t;let c={...t};c.link??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} hyperlink text color (matches primary)`},t.group===`status`&&(c.outline??={...i,$type:`color`,$value:`{color.${e}.primary}`,$description:`Generated ${e} border and divider color (matches primary)`}),c[`on-primary`]??={...i,$type:`color`,$value:G(o),$description:`Generated text and icon color on ${e} primary backgrounds`};let l;if(r&&!(`secondary`in t)){let t=Ee(o,r);c.secondary={...i,$type:`color`,$value:t.secondary,$description:`Generated low-emphasis ${e} background for the ${r} theme`},l=t.onMuted??o}else if(a(t.secondary)){let e=P(t.secondary.$value,n);l=e&&G(e)}l&&!(`on-secondary`in t)&&(c[`on-secondary`]={...i,$type:`color`,$value:l,$description:`Generated text and icon color on ${e} secondary backgrounds`});for(let[e,t]of Object.entries(he))c=Q(c,n,t,e,r);for(let[t,n]of Object.entries(c))a(n)&&(c[t]={theme:e,group:e,...n});return c}function Re(e){let t={...e};for(let[n,r]of Object.entries(e)){let e=n.replace(/^on-/,``).replace(/-(?:hovered|active|inactive|disabled)$/i,``);e!==n&&a(r)&&!(`group`in r)&&(t[n]={...r,group:e})}return t}function ze(e){let t=e.base,n=e.brand;return!i(t)||a(t)||!i(n)||a(n)||Object.entries(n).some(([e,t])=>!r.has(e)&&!e.startsWith(`$`)&&a(t))?e:{...e,brand:{...t,...n}}}function $(e,t,n,o){if(Array.isArray(e))return e.map(e=>$(e,t,void 0,o));if(!i(e)||a(e))return e;let s={};for(let[n,i]of Object.entries(e))s[n]=r.has(n)||n.startsWith(`$`)?i:$(i,t,n,n===`dark`||n===`light`?n:o);let c=s;if(n===`color`){c=ze(c);for(let[e,n]of A(c))c[e]=Le(e,n,t,o);for(let[e,n]of Object.entries(c)){let r=a(n)&&typeof n.group==`string`?ge[n.group]:void 0;r&&(c=Q(c,t,r,e,o))}}for(let[e,n]of Object.entries(_e))a(c[e])&&(c=Q(c,t,n,e,o));return n===`color`?Re(c):c}function Be(e){let t=x(e),n=Se($(t,t,void 0,oe(t)));return F(n,n)}var Ve=e(()=>({name:`cyclone-ui:tamagui-preprocessor`,preprocessors:[{name:`tamagui-preprocessor`,preprocessor:Be}]}));export{Ve as default,Be as tamaguiPreprocessor};
|
|
2
2
|
//# sourceMappingURL=preprocessor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","PURE_CONTRAST_COLORS","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","HAIRLINE_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","BACKGROUND_COLOR_STATE_INACTIVE","BACKGROUND_COLOR_STATE_DISABLED","BACKGROUND_COLOR_STATE_VARIANTS","NONE_THEME_COLOR_KEYS","themeColorGroups","entry","THEME_COLOR_STATE_VARIANTS","COLOR_STATE_TOKEN_GROUPS","COLOR_STATE_VARIANTS","MINIMUM_SUBTLE_CONTRAST_RATIO","SUBTLE_COLOR_LIGHTNESS_STEP","isStateVariantKey","getTokenAtPath","tree","part","path","resolveColorHex","direct","ref","seen","applyOpacity","rgb","opacity","applyFadeOver","foreground","base","background","offset","applyRingOpacity","inRingGroup","applyToLayer","isLowSaturation","index","ZERO","ringLayer","spread","addMissingRingTokens","ring","changed","name","ringColor","gap","variants","hexToOklch","isGreyscale","l","m","s","isInSrgbGamut","oklchToGamutMappedHex","minimumChroma","maximumChroma","candidateChroma","applyBrightness","factor","applyLightnessShift","shift","applySaturation","relativeLuminance","contrastRatio","firstLuminance","first","secondLuminance","second","lighter","darker","createOnColor","whiteContrast","createMutedColor","secondaryDirection","parentTheme","onMutedDirection","secondaryLightness","onMutedLightness","secondary","onMuted","isLightColor","isWhiteColor","isBlackColor","isDarkColor","LOW_SATURATION_WHITE_LIGHTNESS","LOW_SATURATION_BLACK_LIGHTNESS","isInteractionState","variant","isNearContrastPrimitive","directedBrightnessFactor","contrastPrimitive","contrastSideLightnessShift","stateContrastColor","primitive","stateBrightnessFactor","applyStateTransform","transformed","variantDetail","details","percent","createStateToken","detail","source","addColorStateTokens","group","names","onlyKey","baseVariants","hasHovered","tokenVariants","tokenParentTheme","variantKey","addThemeColorGroupTokens","onSecondary","pair","secondaryHex","addColorTokenGroups","root","populateEmptyBrandTheme","brand","injectColorStateVariants","childKey","withStates","tokenKey","tamaguiPreprocessor","converted","withRings","preprocessor_default","definePlugin"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"preprocessor.mjs","names":["HEX_RE","OKLCH_RE","RESERVED_KEYS","isPlainObject","value","isTokenNode","isAlias","trimmed","clamp01","toSrgb","clipped","channel","fromSrgb","hexChannel","srgbHexChannel","alphaHex","alpha","expandHex","hex","digit","colorValueToHex","expanded","parseAlpha","red","parseComponent","green","blue","oklchToLinearSrgb","hueRad","hue","a","chroma","b","l_","lightness","m_","s_","l3","m3","s3","oklchToHex","parsed","oklchStringToHex","match","oklchObjectToHex","convertColor","convertShadow","layer","color","convertValue","type","resolveType","token","inheritedType","mapTokenNode","walk","node","item","groupType","result","key","CONTRAST_PRIMITIVES","PURE_CONTRAST_COLORS","parentThemeFromDescription","description","theme","parentThemeFromDictionary","dictionary","LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_ACTIVE","SUBTLE_LOW_SATURATION_COLOR_STATE_ACTIVE","HAIRLINE_COLOR_STATE_ACTIVE","INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE","COLOR_STATE_INACTIVE","LOW_SATURATION_COLOR_STATE_INACTIVE","COLOR_STATE_DISABLED","DEFAULT_COLOR_STATE_VARIANTS","SUBTLE_COLOR_STATE_VARIANTS","BACKGROUND_COLOR_STATE_INACTIVE","BACKGROUND_COLOR_STATE_DISABLED","BACKGROUND_COLOR_STATE_VARIANTS","NONE_THEME_COLOR_KEYS","themeColorGroups","entry","OUTLINE_COLOR_STATE_VARIANTS","THEME_COLOR_STATE_VARIANTS","COLOR_STATE_TOKEN_GROUPS","COLOR_STATE_VARIANTS","MINIMUM_SUBTLE_CONTRAST_RATIO","SUBTLE_COLOR_LIGHTNESS_STEP","isStateVariantKey","getTokenAtPath","tree","part","path","resolveColorHex","direct","ref","seen","applyOpacity","rgb","opacity","applyFadeOver","foreground","base","background","offset","applyRingOpacity","inRingGroup","applyToLayer","isLowSaturation","index","ZERO","ringLayer","spread","addMissingRingTokens","ring","changed","name","ringColor","gap","variants","hexToOklch","isGreyscale","l","m","s","isInSrgbGamut","oklchToGamutMappedHex","minimumChroma","maximumChroma","candidateChroma","applyBrightness","factor","applyLightnessShift","shift","applySaturation","relativeLuminance","contrastRatio","firstLuminance","first","secondLuminance","second","lighter","darker","createOnColor","whiteContrast","createMutedColor","secondaryDirection","parentTheme","onMutedDirection","secondaryLightness","onMutedLightness","secondary","onMuted","isLightColor","isWhiteColor","isBlackColor","isDarkColor","LOW_SATURATION_WHITE_LIGHTNESS","LOW_SATURATION_BLACK_LIGHTNESS","isInteractionState","variant","isNearContrastPrimitive","directedBrightnessFactor","contrastPrimitive","contrastSideLightnessShift","stateContrastColor","primitive","stateBrightnessFactor","applyStateTransform","transformed","variantDetail","details","percent","createStateToken","detail","source","addColorStateTokens","group","names","onlyKey","baseVariants","hasHovered","tokenVariants","tokenParentTheme","variantKey","addThemeColorGroupTokens","onSecondary","pair","secondaryHex","addColorTokenGroups","root","populateEmptyBrandTheme","brand","injectColorStateVariants","childKey","withStates","tokenKey","tamaguiPreprocessor","converted","withRings","preprocessor_default","definePlugin"],"sources":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclone-ui/theme-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"module": "./dist/index.mjs",
|
|
61
61
|
"types": "./dist/index.d.cts",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@razorwind/core": "^0.0.
|
|
64
|
-
"@razorwind/style-dictionary": "^0.0.
|
|
65
|
-
"@razorwind/tamagui": "^0.0.
|
|
66
|
-
"style-dictionary": "^5.
|
|
63
|
+
"@razorwind/core": "^0.0.105",
|
|
64
|
+
"@razorwind/style-dictionary": "^0.0.91",
|
|
65
|
+
"@razorwind/tamagui": "^0.0.111",
|
|
66
|
+
"style-dictionary": "^5.7.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@powerlines/plugin-tsdown": "^0.1.615",
|
package/src/generate.ts
CHANGED
|
@@ -20,24 +20,104 @@ import { definePlugin } from "@razorwind/core/plugin";
|
|
|
20
20
|
import type { TamaguiPluginOptions } from "@razorwind/tamagui";
|
|
21
21
|
import tamagui from "@razorwind/tamagui/generate";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// ponytail: shims for @razorwind/tamagui <= 0.0.101, which ignores
|
|
24
|
+
// `tamaguiModule` and emits a typography token's unitless line height as-is
|
|
25
|
+
// (Tamagui renders it in px, collapsing the text). Both are fixed upstream;
|
|
26
|
+
// delete these once a release with the fixes is installed. Each is a no-op on
|
|
27
|
+
// the fixed output.
|
|
28
|
+
|
|
29
|
+
const renderScale = (scale: Record<string, number>) =>
|
|
30
|
+
Object.entries(scale)
|
|
31
|
+
.toSorted(([a], [b]) => a.localeCompare(b, undefined, { numeric: true }))
|
|
32
|
+
.map(
|
|
33
|
+
([key, value]) => ` ${/^\d/.test(key) ? `"${key}"` : key}: ${value}`
|
|
34
|
+
)
|
|
35
|
+
.join(",\n");
|
|
36
|
+
|
|
37
|
+
const parseScale = (body: string): Record<string, number> =>
|
|
38
|
+
Object.fromEntries(
|
|
39
|
+
[...body.matchAll(/^\s*"?([\w-]+)"?: ([\d.]+),?$/gmu)].map(
|
|
40
|
+
([, key, value]) => [key, Number(value)]
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/** Scales a ratio line height (e.g. `1.125`) to px for every font size step. */
|
|
45
|
+
const scaleRatioLineHeights = (content: string) =>
|
|
46
|
+
content.replaceAll(
|
|
47
|
+
/(\n {2}size: \{\n)([^}]*)(\n {2}\},\n {2}lineHeight: \{\n)([^}]*)(\n {2}\})/gu,
|
|
48
|
+
(match, open, sizeBody, middle, lineHeightBody, close) => {
|
|
49
|
+
const sizes = parseScale(sizeBody);
|
|
50
|
+
const lineHeights = parseScale(lineHeightBody);
|
|
51
|
+
const ratio = lineHeights.true ?? Object.values(lineHeights)[0];
|
|
52
|
+
if (ratio == null || ratio <= 0 || ratio > 4) {
|
|
53
|
+
return match;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const round = (value: number) => Math.round(value * 1000) / 1000;
|
|
57
|
+
const scale = Object.fromEntries(
|
|
58
|
+
Object.entries(sizes).map(([key, size]) => [key, round(ratio * size)])
|
|
59
|
+
);
|
|
60
|
+
const base = scale.sm ?? Object.values(scale)[0] ?? ratio;
|
|
61
|
+
|
|
62
|
+
return `${open}${sizeBody}${middle}${renderScale({
|
|
63
|
+
...Object.fromEntries(Object.keys(lineHeights).map(key => [key, base])),
|
|
64
|
+
...scale
|
|
65
|
+
})}${close}`;
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const replaceTamaguiModule = (content: string, tamaguiModule: string) =>
|
|
70
|
+
content
|
|
71
|
+
.replaceAll('from "tamagui";', `from "${tamaguiModule}";`)
|
|
72
|
+
.replaceAll(
|
|
73
|
+
'declare module "tamagui"',
|
|
74
|
+
`declare module "${tamaguiModule}"`
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// `tamaguiModule` is newer than the installed @razorwind/tamagui types.
|
|
78
|
+
type GenerateOptions = TamaguiPluginOptions & { tamaguiModule?: string };
|
|
79
|
+
|
|
80
|
+
export default definePlugin((options: GenerateOptions = {}) => {
|
|
81
|
+
const resolvedOptions: GenerateOptions = {
|
|
25
82
|
animations: "motion",
|
|
26
|
-
defaultFont: "body
|
|
83
|
+
defaultFont: "body",
|
|
27
84
|
target: "v3",
|
|
85
|
+
// This repo depends on `@tamagui/core`, not the `tamagui` meta-package.
|
|
86
|
+
tamaguiModule: "@tamagui/core",
|
|
28
87
|
...options
|
|
29
|
-
}
|
|
88
|
+
};
|
|
89
|
+
const tamaguiPlugin = tamagui(resolvedOptions);
|
|
30
90
|
const generateTamagui = tamaguiPlugin.generate;
|
|
91
|
+
const tamaguiModule = resolvedOptions.tamaguiModule ?? "tamagui";
|
|
92
|
+
|
|
93
|
+
const shimConfig = (
|
|
94
|
+
documents: Awaited<ReturnType<NonNullable<typeof generateTamagui>>>
|
|
95
|
+
) => {
|
|
96
|
+
for (const document of Object.values(documents ?? {})) {
|
|
97
|
+
for (const chunk of document?.chunks ?? []) {
|
|
98
|
+
if (
|
|
99
|
+
typeof chunk.content === "string" &&
|
|
100
|
+
chunk.content.includes("createTamagui(")
|
|
101
|
+
) {
|
|
102
|
+
chunk.content = replaceTamaguiModule(
|
|
103
|
+
scaleRatioLineHeights(chunk.content),
|
|
104
|
+
tamaguiModule
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return documents;
|
|
111
|
+
};
|
|
31
112
|
|
|
32
113
|
return {
|
|
33
114
|
...tamaguiPlugin,
|
|
34
115
|
name: "cyclone-ui:tamagui-generate",
|
|
35
|
-
|
|
36
116
|
generate: async (
|
|
37
117
|
...[spec, config]: Parameters<NonNullable<typeof generateTamagui>>
|
|
38
118
|
) => {
|
|
39
119
|
if (!generateTamagui || !spec.fonts) {
|
|
40
|
-
return generateTamagui?.(spec, config) ?? {};
|
|
120
|
+
return shimConfig((await generateTamagui?.(spec, config)) ?? {});
|
|
41
121
|
}
|
|
42
122
|
|
|
43
123
|
const fonts = Object.fromEntries(
|
|
@@ -60,7 +140,7 @@ export default definePlugin((options: TamaguiPluginOptions = {}) => {
|
|
|
60
140
|
})
|
|
61
141
|
) as typeof spec.fonts;
|
|
62
142
|
|
|
63
|
-
return generateTamagui({ ...spec, fonts }, config);
|
|
143
|
+
return shimConfig(await generateTamagui({ ...spec, fonts }, config));
|
|
64
144
|
}
|
|
65
145
|
};
|
|
66
146
|
});
|
package/src/preprocessor.ts
CHANGED
|
@@ -34,6 +34,8 @@ const RESERVED_KEYS = new Set([
|
|
|
34
34
|
"$value",
|
|
35
35
|
"$ref",
|
|
36
36
|
"theme",
|
|
37
|
+
"group",
|
|
38
|
+
"semantic",
|
|
37
39
|
"palette",
|
|
38
40
|
"primitive"
|
|
39
41
|
]);
|
|
@@ -553,18 +555,34 @@ function themeColorGroups(
|
|
|
553
555
|
): [string, Record<string, unknown>][] {
|
|
554
556
|
return Object.entries(color).filter(
|
|
555
557
|
(entry): entry is [string, Record<string, unknown>] =>
|
|
556
|
-
!NONE_THEME_COLOR_KEYS.includes(
|
|
558
|
+
!NONE_THEME_COLOR_KEYS.includes(
|
|
559
|
+
entry[0] as (typeof NONE_THEME_COLOR_KEYS)[number]
|
|
560
|
+
) &&
|
|
557
561
|
isPlainObject(entry[1]) &&
|
|
558
562
|
!isTokenNode(entry[1]) &&
|
|
559
|
-
isTokenNode(entry[1].primary)
|
|
563
|
+
isTokenNode((entry[1] as { primary?: unknown }).primary)
|
|
560
564
|
);
|
|
561
565
|
}
|
|
562
566
|
|
|
567
|
+
const OUTLINE_COLOR_STATE_VARIANTS: ColorStateVariants = {
|
|
568
|
+
lowSaturation: [
|
|
569
|
+
INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE,
|
|
570
|
+
LOW_SATURATION_COLOR_STATE_INACTIVE,
|
|
571
|
+
COLOR_STATE_DISABLED
|
|
572
|
+
],
|
|
573
|
+
saturated: [
|
|
574
|
+
HAIRLINE_COLOR_STATE_ACTIVE,
|
|
575
|
+
COLOR_STATE_INACTIVE,
|
|
576
|
+
COLOR_STATE_DISABLED
|
|
577
|
+
]
|
|
578
|
+
};
|
|
579
|
+
|
|
563
580
|
/** State variants for the tokens inside each theme color group. */
|
|
564
581
|
const THEME_COLOR_STATE_VARIANTS: Record<string, ColorStateVariants> = {
|
|
565
582
|
primary: DEFAULT_COLOR_STATE_VARIANTS,
|
|
566
583
|
secondary: SUBTLE_COLOR_STATE_VARIANTS,
|
|
567
|
-
link: DEFAULT_COLOR_STATE_VARIANTS
|
|
584
|
+
link: DEFAULT_COLOR_STATE_VARIANTS,
|
|
585
|
+
outline: OUTLINE_COLOR_STATE_VARIANTS
|
|
568
586
|
};
|
|
569
587
|
|
|
570
588
|
/**
|
|
@@ -573,7 +591,7 @@ const THEME_COLOR_STATE_VARIANTS: Record<string, ColorStateVariants> = {
|
|
|
573
591
|
*/
|
|
574
592
|
const FOREGROUND_COLOR_STATE_VARIANTS: ColorStateVariants = {
|
|
575
593
|
lowSaturation: [
|
|
576
|
-
{ name: "hovered", brightness: 1.
|
|
594
|
+
{ name: "hovered", brightness: 1.25 },
|
|
577
595
|
...DEFAULT_COLOR_STATE_VARIANTS.lowSaturation
|
|
578
596
|
],
|
|
579
597
|
saturated: [
|
|
@@ -601,18 +619,7 @@ const COLOR_STATE_TOKEN_GROUPS: Record<string, ColorStateVariants> = {
|
|
|
601
619
|
|
|
602
620
|
/** Standalone color tokens that receive state variants. */
|
|
603
621
|
const COLOR_STATE_VARIANTS: Record<string, ColorStateVariants> = {
|
|
604
|
-
outline:
|
|
605
|
-
lowSaturation: [
|
|
606
|
-
INCREASED_LOW_SATURATION_COLOR_STATE_ACTIVE,
|
|
607
|
-
LOW_SATURATION_COLOR_STATE_INACTIVE,
|
|
608
|
-
COLOR_STATE_DISABLED
|
|
609
|
-
],
|
|
610
|
-
saturated: [
|
|
611
|
-
HAIRLINE_COLOR_STATE_ACTIVE,
|
|
612
|
-
COLOR_STATE_INACTIVE,
|
|
613
|
-
COLOR_STATE_DISABLED
|
|
614
|
-
]
|
|
615
|
-
}
|
|
622
|
+
outline: OUTLINE_COLOR_STATE_VARIANTS
|
|
616
623
|
};
|
|
617
624
|
|
|
618
625
|
/** OKLCH chroma below which a color uses the low-saturation state variants. */
|
|
@@ -816,7 +823,7 @@ function addMissingRingTokens(dictionary: unknown): unknown {
|
|
|
816
823
|
],
|
|
817
824
|
[`${name}-offset`]: [
|
|
818
825
|
`${name} 3px focus ring with a 3px gap`,
|
|
819
|
-
[gap(3), ringLayer(ringColor,
|
|
826
|
+
[gap(3), ringLayer(ringColor, 7)]
|
|
820
827
|
],
|
|
821
828
|
[`${name}-subtle-offset`]: [
|
|
822
829
|
`${name} 1px focus ring with a 2px gap`,
|
|
@@ -1053,7 +1060,7 @@ function isDarkColor(hex: string, parentTheme?: ParentTheme): boolean {
|
|
|
1053
1060
|
}
|
|
1054
1061
|
|
|
1055
1062
|
/** Low-saturation colors only count as white / black past ≈ #dddddd / #262626. */
|
|
1056
|
-
const LOW_SATURATION_WHITE_LIGHTNESS = hexToOklch("#
|
|
1063
|
+
const LOW_SATURATION_WHITE_LIGHTNESS = hexToOklch("#fefefe").lightness;
|
|
1057
1064
|
const LOW_SATURATION_BLACK_LIGHTNESS = hexToOklch("#262626").lightness;
|
|
1058
1065
|
|
|
1059
1066
|
function isWhiteColor(hex: string): boolean {
|
|
@@ -1333,8 +1340,10 @@ function addColorStateTokens(
|
|
|
1333
1340
|
/**
|
|
1334
1341
|
* Fill in a theme color group (`color.danger`, …): generate a missing
|
|
1335
1342
|
* `secondary` low-emphasis background from `primary` and the parent theme,
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
1343
|
+
* missing `link` color and, for `status` groups, `outline` color (both
|
|
1344
|
+
* aliasing `primary`), `on-primary` /
|
|
1345
|
+
* `on-secondary` text colors, and state variants for `primary`, `secondary`,
|
|
1346
|
+
* `link` and `outline`. Every token in the group gets the group name as
|
|
1338
1347
|
* its `theme` and `group`, so Tamagui places it in that child theme (e.g.
|
|
1339
1348
|
* `danger.on-primary` → `onPrimary` in the `danger` theme).
|
|
1340
1349
|
*/
|
|
@@ -1358,6 +1367,14 @@ function addThemeColorGroupTokens(
|
|
|
1358
1367
|
$value: `{color.${name}.primary}`,
|
|
1359
1368
|
$description: `Generated ${name} hyperlink text color (matches primary)`
|
|
1360
1369
|
};
|
|
1370
|
+
if (group.group === "status") {
|
|
1371
|
+
result.outline ??= {
|
|
1372
|
+
...token,
|
|
1373
|
+
$type: "color",
|
|
1374
|
+
$value: `{color.${name}.primary}`,
|
|
1375
|
+
$description: `Generated ${name} border and divider color (matches primary)`
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1361
1378
|
result["on-primary"] ??= {
|
|
1362
1379
|
...token,
|
|
1363
1380
|
$type: "color",
|
|
@@ -1541,7 +1558,8 @@ function injectColorStateVariants(
|
|
|
1541
1558
|
* `on-secondary` text colors are generated, then hovered, active, inactive,
|
|
1542
1559
|
* and disabled variants are added to the outline, `foreground` and
|
|
1543
1560
|
* `background` group colors, and each theme color group's `primary`, `secondary`
|
|
1544
|
-
* and `
|
|
1561
|
+
* `link` and `outline` (`link`, and `outline` in `status` groups, default to
|
|
1562
|
+
* `primary` when missing).
|
|
1545
1563
|
* Low-saturation colors derive their states from the parent theme's contrast
|
|
1546
1564
|
* primitive (backgrounds use a half-strength shift of their own lightness; hovered
|
|
1547
1565
|
* colors already near that primitive shift toward the middle, while active
|