@greensight/gts 1.0.0-beta.8 → 1.0.0-beta.9
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/index.cjs +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ export { shadows, type ShadowsKeysType };
|
|
|
60
60
|
`,gt=async({tsContent:r,cssContent:e,dir:o})=>{await y.delete(o);const t=y.write(it,r,{directory:o}),s=y.write(at,e,{directory:o});await Promise.all([t,s])},ft=async({shadowTokens:r,dir:e})=>{const o=ut(r),t=dt(o),s=yt(r);await gt({tsContent:s,cssContent:t,dir:e})},se=(r,e)=>Object.keys(r).reduce((o,t)=>{const s=r[t],n=e?`${e}-${t}`:t;if(s&&typeof s=="object"&&"type"in s&&"value"in s){const i={[n]:s.value.map(ct).join(", ")};return{...o,...i}}const a=se(s,n);return{...o,...a}},{}),pt=({input:r={},output:{dir:e}})=>({name:"shadows/tokenManager",executor:async({tokenManagerClient:o})=>{try{console.log("[shadows/tokenManager] Generating shadows from TokenManager...");const{includeStyles:t=!0}=r;if(!t)throw new Error("includeStyles must be enabled for shadows generation");if(!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const s=[];if(t){const a=o.getStyles();console.log("[shadows/tokenManager] Processing styles for shadows..."),a.effect&&s.push(a.effect)}const n=s.flatMap(a=>Object.entries(se(a,"")).reduce((i,[l,c])=>[...i,{name:l,value:c}],[]));if(n.length===0){console.warn("[shadows/tokenManager] No shadow tokens generated");return}console.log(`[shadows/tokenManager] Generated ${n.length} shadow tokens`),console.log(`[shadows/tokenManager] Writing files to ${e}...`),await ft({shadowTokens:n,dir:e}),console.log("[shadows/tokenManager] ✅ Successfully generated shadow files")}catch(t){const s=t instanceof Error?t.message:String(t);throw console.error("[shadows/tokenManager] ❌ Failed to generate shadows:",s),t instanceof Error&&t.stack&&console.error("[shadows/tokenManager] Stack trace:",t.stack),t}}}),ht="styles.module.css",mt="index.ts",bt="typography.ts",z="sans-serif",G=(r,e)=>{if(!e.length)return"";const o=e.map(t=>` ${t}`).join(`
|
|
61
61
|
`);return`${r} {
|
|
62
62
|
${o}
|
|
63
|
-
}`},ne=(r,e)=>{if(typeof r!="string")return r;const o=e[r]??r;return o.trim().toLowerCase().endsWith(z)?o:`${o}, ${z}`},q=(r,e)=>typeof r.fontFamily!="string"?r:{...r,fontFamily:ne(r.fontFamily,e)},v=(r,e)=>{const o={};return Object.entries(r).forEach(([t,s])=>{const n=t==="fontFamily"?ne(s,e):s,a=t.replace(/([A-Z])/g,"-$1")
|
|
63
|
+
}`},ne=(r,e)=>{if(typeof r!="string")return r;const o=e[r]??r;return o.trim().toLowerCase().endsWith(z)?o:`${o}, ${z}`},q=(r,e)=>typeof r.fontFamily!="string"?r:{...r,fontFamily:ne(r.fontFamily,e)},v=(r,e)=>{const o={};return Object.entries(r).forEach(([t,s])=>{const n=t==="fontFamily"?ne(s,e):s,a=t.replace(/([A-Z])/g,"-$1");o[a]=n}),o},wt=(r,e,o)=>{const t=Object.keys(r.breakpoints),s=v(r.base,o);return t.reduce((n,a,i)=>{const l=v(r.breakpoints[a],o);return i?[...n,{breakpoint:Number(e[a]),css:l}]:[{breakpoint:null,css:{...s,...l}}]},[{breakpoint:null,css:s}])},ae=()=>({base:{},breakpoints:{}}),P=(r,e,o,t)=>{Object.keys(t).length&&(r.breakpoints[e]||(r.breakpoints[e]={}),r.breakpoints[e][o]={...r.breakpoints[e][o],...t})},j=(r,e,o,t)=>{wt(e.value,o,t).forEach(({breakpoint:n,css:a})=>{if(n===null){r.base[e.name]=a;return}P(r,n,e.name,a)})},ie=r=>{const e=J(r.base),o=Object.keys(r.breakpoints).map(Number).sort((t,s)=>s-t).reduce((t,s)=>{const n=r.breakpoints[s];return t+`@media (max-width: ${s}px) { ${J(n)} }`},"");return e+o},kt=(r,e,o)=>{const t=r.reduce((s,n)=>(j(s,n,e,o),s),ae());return ie(t)},J=r=>Object.keys(r).reduce((e,o)=>{const t=r[o],s=Object.keys(t).map(n=>`${n}: ${t[n]}`).join(";");return e+`.typo-${o} { ${s} }`},""),H=r=>{if(typeof r=="number")return Number.isFinite(r)?r:null;const e=Number.parseFloat(r);return Number.isFinite(e)?e:null},Z=r=>{if(typeof r=="number")return r/16;const e=r.trim().toLowerCase();if(e.endsWith("rem"))return H(e);if(e.endsWith("px")){const o=H(e);return o===null?null:o/16}return null},$t=r=>{const{minValueRem:e,maxValueRem:o,minVwRem:t,maxVwRem:s}=r,n=o-e;return`calc(${e}rem + ((100vw - ${t}rem) / (${s}rem - ${t}rem)) * ${n}rem)`},St=(r,e,o,t)=>{const s=["font-size","line-height"],n=Object.entries(e.value.breakpoints).map(([f,h])=>{const b=Number.parseInt(o[f],10);return{breakpointName:f,width:b,typography:h}}).filter(f=>Number.isFinite(f.width)).sort((f,h)=>h.width-f.width);if(n.length<2){j(r,e,o,t);return}const a=n[0],i=n[n.length-1];if(a.width<=i.width){j(r,e,o,t);return}const l=v(e.value.base,t),c=v(a.typography,t),u=v(i.typography,t),d=a.width/16,g=i.width/16;if(d===g){j(r,e,o,t);return}r.base[e.name]={...l,...c};const m=s.reduce((f,h)=>{const b=c[h],T=u[h];if(b===void 0||T===void 0||b===T)return f;const U=Z(b),A=Z(T);return U===null||A===null?f:{...f,[h]:$t({minValueRem:A,maxValueRem:U,minVwRem:g,maxVwRem:d})}},{});P(r,a.width,e.name,m),P(r,i.width,e.name,u)},Tt=(r,e,o,t)=>{if(!t)return kt(r,e,o);const s=r.reduce((n,a)=>(St(n,a,e,o),n),ae());return ie(s)},vt=r=>r.length?`import styles from './styles.module.css';
|
|
64
64
|
import { typography } from './typography';
|
|
65
65
|
|
|
66
66
|
type TypographyKeysType = keyof typeof typography;
|
package/index.mjs
CHANGED
|
@@ -850,7 +850,7 @@ ${o}
|
|
|
850
850
|
}, T = (r, e) => {
|
|
851
851
|
const o = {};
|
|
852
852
|
return Object.entries(r).forEach(([t, s]) => {
|
|
853
|
-
const n = t === "fontFamily" ? ee(s, e) : s, a = t.replace(/([A-Z])/g, "-$1")
|
|
853
|
+
const n = t === "fontFamily" ? ee(s, e) : s, a = t.replace(/([A-Z])/g, "-$1");
|
|
854
854
|
o[a] = n;
|
|
855
855
|
}), o;
|
|
856
856
|
}, nt = (r, e, o) => {
|