@salty-css/core 0.0.1-alpha.21 → 0.0.1-alpha.210

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.
Files changed (91) hide show
  1. package/.saltyrc.schema.json +48 -0
  2. package/README.md +143 -26
  3. package/bin/index.cjs +1 -21
  4. package/bin/index.js +2 -5799
  5. package/bin/logger.d.ts +1 -0
  6. package/bin/main.cjs +11 -0
  7. package/bin/main.d.ts +1 -0
  8. package/bin/main.js +260 -0
  9. package/compiler/get-files.d.ts +3 -0
  10. package/compiler/index.cjs +1 -11
  11. package/compiler/index.d.ts +19 -11
  12. package/compiler/index.js +17 -172
  13. package/config/define-config.d.ts +1 -1
  14. package/config/index.cjs +1 -1
  15. package/config/index.d.ts +2 -1
  16. package/config/index.js +11 -2
  17. package/css/index.cjs +1 -1
  18. package/css/index.d.ts +4 -1
  19. package/css/index.js +10 -2
  20. package/css/keyframes.cjs +1 -0
  21. package/css/keyframes.d.ts +22 -0
  22. package/css/keyframes.js +34 -0
  23. package/css/media.cjs +1 -0
  24. package/css/media.d.ts +87 -0
  25. package/css/media.js +88 -0
  26. package/css/merge.cjs +1 -0
  27. package/css/merge.d.ts +7 -0
  28. package/css/merge.js +5 -0
  29. package/css/token.cjs +1 -0
  30. package/css/token.d.ts +1 -0
  31. package/css/token.js +4 -0
  32. package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
  33. package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
  34. package/factories/define-global-styles.d.ts +7 -0
  35. package/factories/define-media-query.d.ts +8 -0
  36. package/factories/define-templates.d.ts +27 -0
  37. package/factories/define-variables.d.ts +12 -0
  38. package/factories/index.d.ts +4 -0
  39. package/generators/class-name-generator.d.ts +6 -0
  40. package/generators/index.cjs +1 -0
  41. package/generators/index.d.ts +2 -0
  42. package/generators/index.js +86 -0
  43. package/generators/styled-generator.d.ts +19 -0
  44. package/generators/styles-generator.d.ts +22 -0
  45. package/helpers/color.d.ts +18 -0
  46. package/helpers/index.cjs +1 -0
  47. package/helpers/index.d.ts +1 -0
  48. package/helpers/index.js +1152 -0
  49. package/index-B9PS8nEw.cjs +38 -0
  50. package/index-BzhU5E_2.js +502 -0
  51. package/package.json +34 -2
  52. package/parse-styles-B4adoYza.cjs +5 -0
  53. package/parse-styles-Bi-5cRYF.js +128 -0
  54. package/parsers/index.cjs +1 -0
  55. package/parsers/index.d.ts +5 -0
  56. package/parsers/index.js +76 -0
  57. package/parsers/parse-modifiers.d.ts +3 -0
  58. package/parsers/parse-styles.d.ts +13 -0
  59. package/parsers/parse-templates.d.ts +4 -0
  60. package/parsers/parse-tokens.d.ts +3 -0
  61. package/parsers/parser-types.d.ts +8 -0
  62. package/parsers/property-name-check.d.ts +1 -0
  63. package/parsers/unit-check.d.ts +7 -0
  64. package/react-vanilla-file-CCXbsjIb.js +18 -0
  65. package/react-vanilla-file-CG_WJLam.cjs +15 -0
  66. package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
  67. package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
  68. package/server/index.cjs +1 -0
  69. package/server/index.d.ts +1 -0
  70. package/server/index.js +12 -0
  71. package/server/should-restart.d.ts +1 -0
  72. package/templates/salty-reset.d.ts +2 -0
  73. package/types/cli-types.d.ts +10 -0
  74. package/types/config-types.d.ts +84 -0
  75. package/types/index.d.ts +52 -22
  76. package/util/dot-case.d.ts +1 -0
  77. package/util/index.cjs +1 -1
  78. package/util/index.js +1 -1
  79. package/util/module-type.d.ts +1 -0
  80. package/config/config-types.d.ts +0 -59
  81. package/generator/index.cjs +0 -1
  82. package/generator/index.d.ts +0 -1
  83. package/generator/index.js +0 -61
  84. package/generator/parse-modifiers.d.ts +0 -3
  85. package/generator/parse-styles.d.ts +0 -2
  86. package/generator/parse-templates.d.ts +0 -2
  87. package/generator/parse-tokens.d.ts +0 -2
  88. package/generator/parser-types.d.ts +0 -4
  89. package/generator/style-generator.d.ts +0 -28
  90. package/parse-templates-D4p3pgQR.js +0 -92
  91. package/parse-templates-W0YfTmOT.cjs +0 -8
@@ -0,0 +1,38 @@
1
+ "use strict";const Ce=require("esbuild"),xe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),oe=require("fs/promises"),X=require("./parse-styles-B4adoYza.cjs"),B=require("winston"),M=require("./css/merge.cjs");var ne=typeof document<"u"?document.currentScript:null;function Ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pe=Ne(Ce),ye=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[r,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const a=r.trim(),y=await ye(o,[...t,a]);s.push(y)}else n[r]=o;if(Object.keys(n).length){const r=t.map(D.dashCase).join("-"),o="t_"+D.toHash(r,4),a=await X.parseAndJoinStyles(n,`.${r}, .${o}`);s.push(a)}return s.join(`
2
+ `)},Pe=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=me(n).map(r=>`"${r}"`).join(" | ")),t),{}):{},me=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,r])=>{const o=t?`${t}.${n}`:n;return typeof r=="object"?me(r,o,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:ge(i.join(e,".."))},ke=async e=>{const t=ge(e);return await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},De=async e=>{const t=await ke(e);if(t)return t.type};let H;const he=async e=>{if(H)return H;const t=await De(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-B9PS8nEw.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},G=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]}),_e=e=>{G.error(e)};function Se(e){return e?typeof e!="string"?Se(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Oe={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},V={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(V.externalModules.length>0)return V.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return V.externalModules=n,n},v=async e=>{if(V.destDir)return V.destDir;const t=await re(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return V.destDir=s,s},ie=["salty","css","styles","styled"],we=(e=[])=>new RegExp(`\\.(${[...ie,...e].join("|")})\\.`),Y=(e,t=[])=>we(t).test(e),be=async e=>{if(V.rcFile)return V.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await oe.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):be(i.join(e,".."))},re=async e=>{var n,r;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(o=>e.endsWith(o.dir||""));return s||((r=t.projects)==null?void 0:r.find(o=>o.dir===t.defaultProject))},Ee=async e=>{const t=await re(e),s=await v(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),o=await he(e),a=je(n);await pe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:o,external:a});const y=Date.now(),{config:F}=await import(`${r}?t=${y}`);return F},$e=async(e,t)=>{var le,fe;const s=await v(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async m=>{const{contents:b,outputFilePath:R}=await K(e,m,s);Object.entries(b).forEach(([N,O])=>{O.isMedia?n.mediaQueries.push([N,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${N};;${R}`))})}));const r=await Ee(e),o={...r},a=new Set,y=(m,b=[])=>m?Object.entries(m).flatMap(([R,N])=>{if(!N)return;if(typeof N=="object")return y(N,[...b,R]);const O=Se(R),te=D.dashCase(R),se=[...b,O].join(".");a.add(`"${se}"`);const U=[...b.map(D.dashCase),te].join("-"),ue=X.parseVariableTokens(N);return ue?`--${U}: ${ue.transformed};`:`--${U}: ${N};`}):[],F=m=>m?Object.entries(m).flatMap(([b,R])=>{const N=y(R);return b==="base"?N.join(""):`${b} { ${N.join("")} }`}):[],l=m=>m?Object.entries(m).flatMap(([b,R])=>Object.entries(R).flatMap(([N,O])=>{const te=y(O,[b]),se=`.${b}-${N}, [data-${b}="${N}"]`,U=te.join("");return`${se} { ${U} }`})):[],d=m=>({...m,responsive:void 0,conditional:void 0}),g=m=>n.variables.map(b=>m==="static"?d(b._current):b._current[m]),p=M.mergeObjects(d(r.variables),g("static")),j=y(p),h=M.mergeObjects((le=r.variables)==null?void 0:le.responsive,g("responsive")),C=F(h),P=M.mergeObjects((fe=r.variables)==null?void 0:fe.conditional,g("conditional")),k=l(P),J=i.join(s,"css/_variables.css"),E=`:root { ${j.join("")} ${C.join("")} } ${k.join("")}`;c.writeFileSync(J,E),o.staticVariables=p;const q=i.join(s,"css/_global.css"),_=M.mergeObjects(r.global,n.globalStyles),I=await X.parseAndJoinStyles(_,"");c.writeFileSync(q,`@layer global { ${I} }`);const f=i.join(s,"css/_reset.css"),w=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Oe,u=await X.parseAndJoinStyles(w,"");c.writeFileSync(f,`@layer reset { ${u} }`);const $=i.join(s,"css/_templates.css"),x=M.mergeObjects(r.templates,n.templates),T=await ye(x),W=Pe(x);c.writeFileSync($,`@layer templates { ${T} }`),o.templates=x;const A=M.mergeFactories(n.templates);o.templatePaths=Object.fromEntries(Object.entries(A).map(([m,b])=>[m,b._path]));const{mediaQueries:z}=n;o.mediaQueries=Object.fromEntries(z.map(([m,b])=>[`@${m}`,b]));const L=z.map(([m])=>`'@${m}'`).join(" | "),ee=i.join(s,"types/css-tokens.d.ts"),Z=`
3
+ // Variable types
4
+ type VariableTokens = ${[...a].join("|")};
5
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
6
+
7
+ // Template types
8
+ type TemplateTokens = {
9
+ ${Object.entries(W).map(([m,b])=>`${m}?: ${b}`).join(`
10
+ `)}
11
+ }
12
+
13
+ // Media query types
14
+ type MediaQueryKeys = ${L||"''"};
15
+ `;c.writeFileSync(ee,Z);const Fe=i.join(s,"cache/config-cache.json");c.writeFileSync(Fe,JSON.stringify(o,null,2))},de=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const r=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!r.test(e))return t;const a=r.exec(e);if(a){const y=a.at(1);if(ie.some(l=>y==null?void 0:y.includes(l)))return t}return"styled('div',"}),Te=(e,t)=>{try{const s=c.readFileSync(i.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
16
+
17
+ ${e}`:`globalThis.saltyConfig = {};
18
+
19
+ ${e}`}catch{return e}},K=async(e,t,s)=>{const n=D.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const o=i.parse(t);let a=c.readFileSync(t,"utf8");a=de(a),a=Te(a,e);const y=i.join(s,"js",n+".js"),F=await re(e),l=i.join(e,(F==null?void 0:F.configDir)||"","salty.config.ts"),d=je(l),g=await he(e);await pe.build({stdin:{contents:a,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:d,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},C=>{const P=c.readFileSync(C.path,"utf8");return{contents:de(P),loader:"ts"}})}}]});const p=Date.now();return{contents:await import(`${y}?t=${p}`),outputFilePath:y}},Re=async e=>{const t=await v(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Re(e),s=await v(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:o}=await import(`${n}?t=${r}`);return M.mergeObjects(o,t)},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ve=async(e,t=ce(),s=!0)=>{try{const n=Date.now();t?G.info("Generating CSS in production mode! 🔥"):G.info("Generating CSS in development mode! 🚀");const r=[],o=[],a=await v(e),y=i.join(a,"index.css");s&&(()=>{c.existsSync(a)&&xe.execSync("rm -rf "+a),c.mkdirSync(a,{recursive:!0}),c.mkdirSync(i.join(a,"css")),c.mkdirSync(i.join(a,"types")),c.mkdirSync(i.join(a,"js")),c.mkdirSync(i.join(a,"cache"))})();const l=new Set,d=new Set;async function g(f){const S=["node_modules","saltygen"],w=c.statSync(f);if(w.isDirectory()){const u=c.readdirSync(f);if(S.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>g(i.join(f,x))))}else if(w.isFile()&&Y(f)){l.add(f);const $=c.readFileSync(f,"utf8");/define[\w\d]+\(/.test($)&&d.add(f)}}await g(e),await $e(e,d);const p={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:S}=await K(e,f,a);Object.entries(S).forEach(([w,u])=>{u.isKeyframes?p.keyframes.push({value:u,src:f,name:w}):u.isClassName?p.classNames.push({...u,src:f,name:w}):u.generator&&p.components.push({...u,src:f,name:w})})}));const j=await ae(e);for(const f of p.keyframes){const{value:S}=f,w=`a_${S.animationName}.css`,u=`css/${w}`,$=i.join(a,u);r.push(w),c.writeFileSync($,S.css)}const h={};for(const f of p.components){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j});o[u.priority]||(o[u.priority]=[]);const $=await u.css;if(!$)continue;o[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}for(const f of p.classNames){const{src:S,name:w}=f;h[S]||(h[S]=[]);const u=f.generator._withBuildContext({callerName:w,isProduction:t,config:j}),$=await u.css;if(!$)continue;o[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,T=i.join(a,x);c.writeFileSync(T,$),j.importStrategy==="component"&&h[S].push(u.cssFileName)}j.importStrategy==="component"&&Object.entries(h).forEach(([f,S])=>{const w=S.map(W=>`@import url('./${W}');`).join(`
20
+ `),u=D.toHash(f,6),$=i.parse(f),x=D.dashCase($.name),T=i.join(a,`css/f_${x}-${u}.css`);c.writeFileSync(T,w||"/* Empty file */")});const C=r.map(f=>`@import url('./css/${f}');`).join(`
21
+ `);let E=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
22
+
23
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return c.readFileSync(i.join(a,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
24
+ `)}
25
+ ${C}`;if(j.importStrategy!=="component"){const f=o.reduce((S,w,u)=>{const $=w.reduce((A,z)=>{var Z;const L=i.join(a,"css",z),ee=c.readFileSync(L,"utf8"),Q=((Z=/.*-([^-]+)-\d+.css/.exec(z))==null?void 0:Z.at(1))||D.toHash(L,6);return A.includes(Q)?A:`${A}
26
+ /*start:${Q}-${z}*/
27
+ ${ee}
28
+ /*end:${Q}*/
29
+ `},""),x=`l_${u}.css`,T=i.join(a,"css",x),W=`@layer l${u} { ${$}
30
+ }`;return c.writeFileSync(T,W),`${S}
31
+ @import url('./css/${x}');`},"");E+=f}c.writeFileSync(y,E);const _=Date.now()-n,I=_<200?"🔥":_<500?"🚀":_<1e3?"🎉":_<2e3?"🚗":_<5e3?"🤔":"🥴";G.info(`Generated CSS in ${_}ms! ${I}`)}catch(n){console.error(n)}},Me=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=[],a=await ae(e),{contents:y}=await K(e,t,n);for(const[F,l]of Object.entries(y)){if(l.isKeyframes&&l.css){const C=`css/${`a_${l.animationName}.css`}`,P=i.join(n,C);c.writeFileSync(P,await l.css);return}if(l.isClassName){const h=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),C=await h.css;if(!C)continue;o[0].push(h.cssFileName);const P=`css/${h.cssFileName}`,k=i.join(n,P);c.writeFileSync(k,C)}if(!l.generator)return;const d=l.generator._withBuildContext({callerName:F,isProduction:s,config:a}),g=await d.css;if(!g)continue;const p=`css/${d.cssFileName}`,j=i.join(n,p);c.writeFileSync(j,g),o[d.priority]||(o[d.priority]=[]),o[d.priority].push(d.cssFileName)}if(a.importStrategy!=="component")o.forEach((F,l)=>{const d=`l_${l}.css`,g=i.join(n,"css",d);let p=c.readFileSync(g,"utf8");F.forEach(j=>{var k;const h=i.join(n,"css",j),C=((k=/.*-([^-]+)-\d+.css/.exec(j))==null?void 0:k.at(1))||D.toHash(h,6);if(!p.includes(C)){const J=c.readFileSync(h,"utf8"),E=`/*start:${C}-${j}*/
32
+ ${J}
33
+ /*end:${C}*/
34
+ `;p=`${p.replace(/\}$/,"")}
35
+ ${E}
36
+ }`}}),c.writeFileSync(g,p)});else{const F=o.flat().map(j=>`@import url('./${j}');`).join(`
37
+ `),l=D.toHash(t,6),d=i.parse(t),g=D.dashCase(d.name),p=i.join(n,`css/f_${g}-${l}.css`);c.writeFileSync(p,F||"/* Empty file */")}}}catch(n){console.error(n)}},ve=async(e,t,s=ce())=>{try{const n=await v(e);if(Y(t)){const o=c.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,d=>`export ${d}`)!==o&&await oe.writeFile(t,o);const y=await ae(e),{contents:F}=await K(e,t,n);let l=o;if(Object.entries(F).forEach(([d,g])=>{var u;if(g.isKeyframes||!g.generator)return;const p=g.generator._withBuildContext({callerName:d,isProduction:s,config:y}),j=new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!j)return console.error("Could not find the original declaration");const h=(u=j.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${d}[=\\s]+styled\\(`,"g").exec(l);if(!C)return console.error("Could not find the original declaration");const{index:P}=C;let k=!1;const J=setTimeout(()=>k=!0,5e3);let E=0,q=!1,_=0;for(;!q&&!k;){const $=l[P+E];$==="("&&_++,$===")"&&_--,_===0&&$===")"&&(q=!0),E>l.length&&(k=!0),E++}if(!k)clearTimeout(J);else throw new Error("Failed to find the end of the styled call and timed out");const I=P+E,f=l.slice(P,I),S=l,w=` ${d} = styled(${h}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;l=l.replace(f,w),S===l&&console.error("Minimize file failed to change content",{name:d,tagName:h})}),y.importStrategy==="component"){const d=D.toHash(t,6),g=i.parse(t);l=`import '../../saltygen/css/${`f_${D.dashCase(g.name)}-${d}.css`}';
38
+ ${l}`}return l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=K;exports.generateConfigStyles=$e;exports.generateCss=Ve;exports.generateFile=Me;exports.isSaltyFile=Y;exports.logError=_e;exports.logger=G;exports.minimizeFile=ve;exports.saltyFileExtensions=ie;exports.saltyFileRegExp=we;
@@ -0,0 +1,502 @@
1
+ import * as gt from "esbuild";
2
+ import { execSync as Nt } from "child_process";
3
+ import { d as G, t as v } from "./dash-case-DBThphLm.js";
4
+ import { join as r, parse as Y } from "path";
5
+ import { existsSync as it, writeFileSync as x, mkdirSync as I, readFileSync as T, statSync as Pt, readdirSync as kt } from "fs";
6
+ import { readFile as yt, writeFile as Dt } from "fs/promises";
7
+ import { p as at, a as _t } from "./parse-styles-Bi-5cRYF.js";
8
+ import { createLogger as Et, format as ot, transports as Tt } from "winston";
9
+ import { mergeObjects as B, mergeFactories as Ot } from "./css/merge.js";
10
+ const ht = async (t, e = []) => {
11
+ if (!t) return "";
12
+ const s = [], n = {};
13
+ for (const [a, o] of Object.entries(t))
14
+ if (typeof o != "function") if (o && typeof o == "object") {
15
+ const i = a.trim(), d = await ht(o, [...e, i]);
16
+ s.push(d);
17
+ } else
18
+ n[a] = o;
19
+ if (Object.keys(n).length) {
20
+ const a = e.map(G).join("-"), o = "t_" + v(a, 4), i = await at(n, `.${a}, .${o}`);
21
+ s.push(i);
22
+ }
23
+ return s.join(`
24
+ `);
25
+ }, Vt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = $t(n).map((a) => `"${a}"`).join(" | ")), e), {}) : {}, $t = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, a]) => {
26
+ const o = e ? `${e}.${n}` : n;
27
+ return typeof a == "object" ? $t(a, o, s) : s.add(e);
28
+ }), [...s]) : [], bt = (t) => {
29
+ if (!t || t === "/") throw new Error("Could not find package.json file");
30
+ const e = r(t, "package.json");
31
+ return it(e) ? e : bt(r(t, ".."));
32
+ }, Mt = async (t) => {
33
+ const e = bt(t);
34
+ return await yt(e, "utf-8").then(JSON.parse).catch(() => {
35
+ });
36
+ }, vt = async (t) => {
37
+ const e = await Mt(t);
38
+ if (e)
39
+ return e.type;
40
+ };
41
+ let W;
42
+ const wt = async (t) => {
43
+ if (W) return W;
44
+ const e = await vt(t);
45
+ return e === "module" ? W = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (W = "cjs"), W || "esm";
46
+ }, X = Et({
47
+ level: "debug",
48
+ format: ot.combine(ot.colorize(), ot.cli()),
49
+ transports: [new Tt.Console({})]
50
+ }), Ut = (t) => {
51
+ X.error(t);
52
+ };
53
+ function St(t) {
54
+ return t ? typeof t != "string" ? St(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
55
+ }
56
+ const Rt = {
57
+ /** Set box model to border-box */
58
+ "*, *::before, *::after": {
59
+ boxSizing: "border-box"
60
+ },
61
+ /** Remove default margin and padding */
62
+ "*": {
63
+ margin: 0
64
+ },
65
+ /** Remove adjust font properties */
66
+ html: {
67
+ lineHeight: 1.15,
68
+ textSizeAdjust: "100%",
69
+ WebkitFontSmoothing: "antialiased"
70
+ },
71
+ /** Make media elements responsive */
72
+ "img, picture, video, canvas, svg": {
73
+ display: "block",
74
+ maxWidth: "100%"
75
+ },
76
+ /** Avoid overflow of text */
77
+ "p, h1, h2, h3, h4, h5, h6": {
78
+ overflowWrap: "break-word"
79
+ },
80
+ /** Improve text wrapping */
81
+ p: {
82
+ textWrap: "pretty"
83
+ },
84
+ "h1, h2, h3, h4, h5, h6": {
85
+ textWrap: "balance"
86
+ },
87
+ /** Improve link color */
88
+ a: {
89
+ color: "currentColor"
90
+ },
91
+ /** Improve button line height */
92
+ button: {
93
+ lineHeight: "1em",
94
+ color: "currentColor"
95
+ },
96
+ /** Improve form elements */
97
+ "input, optgroup, select, textarea": {
98
+ fontFamily: "inherit",
99
+ fontSize: "100%",
100
+ lineHeight: "1.15em"
101
+ }
102
+ }, M = {
103
+ externalModules: [],
104
+ rcFile: void 0,
105
+ destDir: void 0
106
+ }, Ct = (t) => {
107
+ if (M.externalModules.length > 0) return M.externalModules;
108
+ const s = T(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
109
+ if (!s) return [];
110
+ const n = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
111
+ return M.externalModules = n, n;
112
+ }, R = async (t) => {
113
+ if (M.destDir) return M.destDir;
114
+ const e = await ct(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
115
+ return M.destDir = s, s;
116
+ }, jt = ["salty", "css", "styles", "styled"], Jt = (t = []) => new RegExp(`\\.(${[...jt, ...t].join("|")})\\.`), rt = (t, e = []) => Jt(e).test(t), Ft = async (t) => {
117
+ if (M.rcFile) return M.rcFile;
118
+ if (t === "/") throw new Error("Could not find .saltyrc.json file");
119
+ const e = r(t, ".saltyrc.json"), s = await yt(e, "utf-8").then(JSON.parse).catch(() => {
120
+ });
121
+ return s ? (M.rcFile = s, s) : Ft(r(t, ".."));
122
+ }, ct = async (t) => {
123
+ var n, a;
124
+ const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((o) => t.endsWith(o.dir || ""));
125
+ return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
126
+ }, zt = async (t) => {
127
+ const e = await ct(t), s = await R(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = r(s, "salty.config.js"), o = await wt(t), i = Ct(n);
128
+ await gt.build({
129
+ entryPoints: [n],
130
+ minify: !0,
131
+ treeShaking: !0,
132
+ bundle: !0,
133
+ outfile: a,
134
+ format: o,
135
+ external: i
136
+ });
137
+ const d = Date.now(), { config: C } = await import(`${a}?t=${d}`);
138
+ return C;
139
+ }, Wt = async (t, e) => {
140
+ var ut, pt;
141
+ const s = await R(t), n = {
142
+ mediaQueries: [],
143
+ globalStyles: [],
144
+ variables: [],
145
+ templates: []
146
+ };
147
+ await Promise.all(
148
+ [...e].map(async (m) => {
149
+ const { contents: w, outputFilePath: V } = await tt(t, m, s);
150
+ Object.entries(w).forEach(([N, _]) => {
151
+ _.isMedia ? n.mediaQueries.push([N, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(`${N};;${V}`));
152
+ });
153
+ })
154
+ );
155
+ const a = await zt(t), o = { ...a }, i = /* @__PURE__ */ new Set(), d = (m, w = []) => m ? Object.entries(m).flatMap(([V, N]) => {
156
+ if (!N) return;
157
+ if (typeof N == "object") return d(N, [...w, V]);
158
+ const _ = St(V), st = G(V), nt = [...w, _].join(".");
159
+ i.add(`"${nt}"`);
160
+ const U = [...w.map(G), st].join("-"), dt = _t(N);
161
+ return dt ? `--${U}: ${dt.transformed};` : `--${U}: ${N};`;
162
+ }) : [], C = (m) => m ? Object.entries(m).flatMap(([w, V]) => {
163
+ const N = d(V);
164
+ return w === "base" ? N.join("") : `${w} { ${N.join("")} }`;
165
+ }) : [], c = (m) => m ? Object.entries(m).flatMap(([w, V]) => Object.entries(V).flatMap(([N, _]) => {
166
+ const st = d(_, [w]), nt = `.${w}-${N}, [data-${w}="${N}"]`, U = st.join("");
167
+ return `${nt} { ${U} }`;
168
+ })) : [], u = (m) => ({ ...m, responsive: void 0, conditional: void 0 }), g = (m) => n.variables.map((w) => m === "static" ? u(w._current) : w._current[m]), p = B(u(a.variables), g("static")), $ = d(p), y = B((ut = a.variables) == null ? void 0 : ut.responsive, g("responsive")), j = C(y), P = B((pt = a.variables) == null ? void 0 : pt.conditional, g("conditional")), k = c(P), J = r(s, "css/_variables.css"), E = `:root { ${$.join("")} ${j.join("")} } ${k.join("")}`;
169
+ x(J, E), o.staticVariables = p;
170
+ const H = r(s, "css/_global.css"), D = B(a.global, n.globalStyles), K = await at(D, "");
171
+ x(H, `@layer global { ${K} }`);
172
+ const l = r(s, "css/_reset.css"), b = a.reset === "none" ? {} : typeof a.reset == "object" ? a.reset : Rt, f = await at(b, "");
173
+ x(l, `@layer reset { ${f} }`);
174
+ const S = r(s, "css/_templates.css"), F = B(a.templates, n.templates), O = await ht(F), A = Vt(F);
175
+ x(S, `@layer templates { ${O} }`), o.templates = F;
176
+ const L = Ot(n.templates);
177
+ o.templatePaths = Object.fromEntries(Object.entries(L).map(([m, w]) => [m, w._path]));
178
+ const { mediaQueries: z } = n;
179
+ o.mediaQueries = Object.fromEntries(z.map(([m, w]) => [`@${m}`, w]));
180
+ const Q = z.map(([m]) => `'@${m}'`).join(" | "), et = r(s, "types/css-tokens.d.ts"), q = `
181
+ // Variable types
182
+ type VariableTokens = ${[...i].join("|")};
183
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
184
+
185
+ // Template types
186
+ type TemplateTokens = {
187
+ ${Object.entries(A).map(([m, w]) => `${m}?: ${w}`).join(`
188
+ `)}
189
+ }
190
+
191
+ // Media query types
192
+ type MediaQueryKeys = ${Q || "''"};
193
+ `;
194
+ x(et, q);
195
+ const xt = r(s, "cache/config-cache.json");
196
+ x(xt, JSON.stringify(o, null, 2));
197
+ }, mt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
198
+ if (/^['"`]/.test(s)) return e;
199
+ const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
200
+ if (!a.test(t)) return e;
201
+ const i = a.exec(t);
202
+ if (i) {
203
+ const d = i.at(1);
204
+ if (jt.some((c) => d == null ? void 0 : d.includes(c))) return e;
205
+ }
206
+ return "styled('div',";
207
+ }), It = (t, e) => {
208
+ try {
209
+ const s = T(r(e, "saltygen/cache/config-cache.json"), "utf8");
210
+ return s ? `globalThis.saltyConfig = ${s};
211
+
212
+ ${t}` : `globalThis.saltyConfig = {};
213
+
214
+ ${t}`;
215
+ } catch {
216
+ return t;
217
+ }
218
+ }, tt = async (t, e, s) => {
219
+ const n = v(e), a = r(s, "./temp");
220
+ it(a) || I(a);
221
+ const o = Y(e);
222
+ let i = T(e, "utf8");
223
+ i = mt(i), i = It(i, t);
224
+ const d = r(s, "js", n + ".js"), C = await ct(t), c = r(t, (C == null ? void 0 : C.configDir) || "", "salty.config.ts"), u = Ct(c), g = await wt(t);
225
+ await gt.build({
226
+ stdin: {
227
+ contents: i,
228
+ sourcefile: o.base,
229
+ resolveDir: o.dir,
230
+ loader: "tsx"
231
+ },
232
+ minify: !1,
233
+ treeShaking: !0,
234
+ bundle: !0,
235
+ outfile: d,
236
+ format: g,
237
+ target: ["node20"],
238
+ keepNames: !0,
239
+ external: u,
240
+ packages: "external",
241
+ plugins: [
242
+ {
243
+ name: "test",
244
+ setup: (y) => {
245
+ y.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
246
+ const P = T(j.path, "utf8");
247
+ return { contents: mt(P), loader: "ts" };
248
+ });
249
+ }
250
+ }
251
+ ]
252
+ });
253
+ const p = Date.now();
254
+ return { contents: await import(`${d}?t=${p}`), outputFilePath: d };
255
+ }, Bt = async (t) => {
256
+ const e = await R(t), s = r(e, "cache/config-cache.json"), n = T(s, "utf8");
257
+ if (!n) throw new Error("Could not find config cache file");
258
+ return JSON.parse(n);
259
+ }, lt = async (t) => {
260
+ const e = await Bt(t), s = await R(t), n = r(s, "salty.config.js"), a = Date.now(), { config: o } = await import(`${n}?t=${a}`);
261
+ return B(o, e);
262
+ }, ft = () => {
263
+ try {
264
+ return process.env.NODE_ENV === "production";
265
+ } catch {
266
+ return !1;
267
+ }
268
+ }, Xt = async (t, e = ft(), s = !0) => {
269
+ try {
270
+ const n = Date.now();
271
+ e ? X.info("Generating CSS in production mode! 🔥") : X.info("Generating CSS in development mode! 🚀");
272
+ const a = [], o = [], i = await R(t), d = r(i, "index.css");
273
+ s && (() => {
274
+ it(i) && Nt("rm -rf " + i), I(i, { recursive: !0 }), I(r(i, "css")), I(r(i, "types")), I(r(i, "js")), I(r(i, "cache"));
275
+ })();
276
+ const c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
277
+ async function g(l) {
278
+ const h = ["node_modules", "saltygen"], b = Pt(l);
279
+ if (b.isDirectory()) {
280
+ const f = kt(l);
281
+ if (h.some((F) => l.includes(F))) return;
282
+ await Promise.all(f.map((F) => g(r(l, F))));
283
+ } else if (b.isFile() && rt(l)) {
284
+ c.add(l);
285
+ const S = T(l, "utf8");
286
+ /define[\w\d]+\(/.test(S) && u.add(l);
287
+ }
288
+ }
289
+ await g(t), await Wt(t, u);
290
+ const p = {
291
+ keyframes: [],
292
+ components: [],
293
+ classNames: []
294
+ };
295
+ await Promise.all(
296
+ [...c].map(async (l) => {
297
+ const { contents: h } = await tt(t, l, i);
298
+ Object.entries(h).forEach(([b, f]) => {
299
+ f.isKeyframes ? p.keyframes.push({
300
+ value: f,
301
+ src: l,
302
+ name: b
303
+ }) : f.isClassName ? p.classNames.push({
304
+ ...f,
305
+ src: l,
306
+ name: b
307
+ }) : f.generator && p.components.push({
308
+ ...f,
309
+ src: l,
310
+ name: b
311
+ });
312
+ });
313
+ })
314
+ );
315
+ const $ = await lt(t);
316
+ for (const l of p.keyframes) {
317
+ const { value: h } = l, b = `a_${h.animationName}.css`, f = `css/${b}`, S = r(i, f);
318
+ a.push(b), x(S, h.css);
319
+ }
320
+ const y = {};
321
+ for (const l of p.components) {
322
+ const { src: h, name: b } = l;
323
+ y[h] || (y[h] = []);
324
+ const f = l.generator._withBuildContext({
325
+ callerName: b,
326
+ isProduction: e,
327
+ config: $
328
+ });
329
+ o[f.priority] || (o[f.priority] = []);
330
+ const S = await f.css;
331
+ if (!S) continue;
332
+ o[f.priority].push(f.cssFileName);
333
+ const F = `css/${f.cssFileName}`, O = r(i, F);
334
+ x(O, S), $.importStrategy === "component" && y[h].push(f.cssFileName);
335
+ }
336
+ for (const l of p.classNames) {
337
+ const { src: h, name: b } = l;
338
+ y[h] || (y[h] = []);
339
+ const f = l.generator._withBuildContext({
340
+ callerName: b,
341
+ isProduction: e,
342
+ config: $
343
+ }), S = await f.css;
344
+ if (!S) continue;
345
+ o[0].push(f.cssFileName);
346
+ const F = `css/${f.cssFileName}`, O = r(i, F);
347
+ x(O, S), $.importStrategy === "component" && y[h].push(f.cssFileName);
348
+ }
349
+ $.importStrategy === "component" && Object.entries(y).forEach(([l, h]) => {
350
+ const b = h.map((A) => `@import url('./${A}');`).join(`
351
+ `), f = v(l, 6), S = Y(l), F = G(S.name), O = r(i, `css/f_${F}-${f}.css`);
352
+ x(O, b || "/* Empty file */");
353
+ });
354
+ const j = a.map((l) => `@import url('./css/${l}');`).join(`
355
+ `);
356
+ let E = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
357
+
358
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
359
+ try {
360
+ return T(r(i, "css", l), "utf8").length > 0;
361
+ } catch {
362
+ return !1;
363
+ }
364
+ }).map((l) => `@import url('./css/${l}');`).join(`
365
+ `)}
366
+ ${j}`;
367
+ if ($.importStrategy !== "component") {
368
+ const l = o.reduce((h, b, f) => {
369
+ const S = b.reduce((L, z) => {
370
+ var q;
371
+ const Q = r(i, "css", z), et = T(Q, "utf8"), Z = ((q = /.*-([^-]+)-\d+.css/.exec(z)) == null ? void 0 : q.at(1)) || v(Q, 6);
372
+ return L.includes(Z) ? L : `${L}
373
+ /*start:${Z}-${z}*/
374
+ ${et}
375
+ /*end:${Z}*/
376
+ `;
377
+ }, ""), F = `l_${f}.css`, O = r(i, "css", F), A = `@layer l${f} { ${S}
378
+ }`;
379
+ return x(O, A), `${h}
380
+ @import url('./css/${F}');`;
381
+ }, "");
382
+ E += l;
383
+ }
384
+ x(d, E);
385
+ const D = Date.now() - n, K = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
386
+ X.info(`Generated CSS in ${D}ms! ${K}`);
387
+ } catch (n) {
388
+ console.error(n);
389
+ }
390
+ }, Yt = async (t, e, s = ft()) => {
391
+ try {
392
+ const n = await R(t);
393
+ if (rt(e)) {
394
+ const o = [], i = await lt(t), { contents: d } = await tt(t, e, n);
395
+ for (const [C, c] of Object.entries(d)) {
396
+ if (c.isKeyframes && c.css) {
397
+ const j = `css/${`a_${c.animationName}.css`}`, P = r(n, j);
398
+ x(P, await c.css);
399
+ return;
400
+ }
401
+ if (c.isClassName) {
402
+ const y = c.generator._withBuildContext({
403
+ callerName: C,
404
+ isProduction: s,
405
+ config: i
406
+ }), j = await y.css;
407
+ if (!j) continue;
408
+ o[0].push(y.cssFileName);
409
+ const P = `css/${y.cssFileName}`, k = r(n, P);
410
+ x(k, j);
411
+ }
412
+ if (!c.generator) return;
413
+ const u = c.generator._withBuildContext({
414
+ callerName: C,
415
+ isProduction: s,
416
+ config: i
417
+ }), g = await u.css;
418
+ if (!g) continue;
419
+ const p = `css/${u.cssFileName}`, $ = r(n, p);
420
+ x($, g), o[u.priority] || (o[u.priority] = []), o[u.priority].push(u.cssFileName);
421
+ }
422
+ if (i.importStrategy !== "component")
423
+ o.forEach((C, c) => {
424
+ const u = `l_${c}.css`, g = r(n, "css", u);
425
+ let p = T(g, "utf8");
426
+ C.forEach(($) => {
427
+ var k;
428
+ const y = r(n, "css", $), j = ((k = /.*-([^-]+)-\d+.css/.exec($)) == null ? void 0 : k.at(1)) || v(y, 6);
429
+ if (!p.includes(j)) {
430
+ const J = T(y, "utf8"), E = `/*start:${j}-${$}*/
431
+ ${J}
432
+ /*end:${j}*/
433
+ `;
434
+ p = `${p.replace(/\}$/, "")}
435
+ ${E}
436
+ }`;
437
+ }
438
+ }), x(g, p);
439
+ });
440
+ else {
441
+ const C = o.flat().map(($) => `@import url('./${$}');`).join(`
442
+ `), c = v(e, 6), u = Y(e), g = G(u.name), p = r(n, `css/f_${g}-${c}.css`);
443
+ x(p, C || "/* Empty file */");
444
+ }
445
+ }
446
+ } catch (n) {
447
+ console.error(n);
448
+ }
449
+ }, te = async (t, e, s = ft()) => {
450
+ try {
451
+ const n = await R(t);
452
+ if (rt(e)) {
453
+ const o = T(e, "utf8");
454
+ o.replace(/^(?!export\s)const\s.*/gm, (u) => `export ${u}`) !== o && await Dt(e, o);
455
+ const d = await lt(t), { contents: C } = await tt(t, e, n);
456
+ let c = o;
457
+ if (Object.entries(C).forEach(([u, g]) => {
458
+ var f;
459
+ if (g.isKeyframes || !g.generator) return;
460
+ const p = g.generator._withBuildContext({
461
+ callerName: u,
462
+ isProduction: s,
463
+ config: d
464
+ }), $ = new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
465
+ if (!$) return console.error("Could not find the original declaration");
466
+ const y = (f = $.at(1)) == null ? void 0 : f.trim(), j = new RegExp(`\\s${u}[=\\s]+styled\\(`, "g").exec(c);
467
+ if (!j) return console.error("Could not find the original declaration");
468
+ const { index: P } = j;
469
+ let k = !1;
470
+ const J = setTimeout(() => k = !0, 5e3);
471
+ let E = 0, H = !1, D = 0;
472
+ for (; !H && !k; ) {
473
+ const S = c[P + E];
474
+ S === "(" && D++, S === ")" && D--, D === 0 && S === ")" && (H = !0), E > c.length && (k = !0), E++;
475
+ }
476
+ if (!k) clearTimeout(J);
477
+ else throw new Error("Failed to find the end of the styled call and timed out");
478
+ const K = P + E, l = c.slice(P, K), h = c, b = ` ${u} = styled(${y}, "${p.classNames}", ${JSON.stringify(p.clientProps)});`;
479
+ c = c.replace(l, b), h === c && console.error("Minimize file failed to change content", { name: u, tagName: y });
480
+ }), d.importStrategy === "component") {
481
+ const u = v(e, 6), g = Y(e);
482
+ c = `import '../../saltygen/css/${`f_${G(g.name)}-${u}.css`}';
483
+ ${c}`;
484
+ }
485
+ return c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
486
+ }
487
+ } catch (n) {
488
+ console.error("Error in minimizeFile:", n);
489
+ }
490
+ };
491
+ export {
492
+ Ut as a,
493
+ Jt as b,
494
+ Wt as c,
495
+ tt as d,
496
+ Yt as e,
497
+ Xt as g,
498
+ rt as i,
499
+ X as l,
500
+ te as m,
501
+ jt as s
502
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.21",
3
+ "version": "0.0.1-alpha.210",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -10,7 +10,12 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "homepage": "https://github.com/margarita-form/salty-css",
13
+ "description": "Core library for Salty CSS. Will be used by other Salty CSS libraries and plugins.",
14
+ "homepage": "https://salty-css.dev/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/margarita-form/salty-css.git"
18
+ },
14
19
  "bugs": {
15
20
  "url": "https://github.com/margarita-form/salty-css/issues"
16
21
  },
@@ -23,13 +28,20 @@
23
28
  "name": "core"
24
29
  },
25
30
  "peerDependencies": {
31
+ "color": ">=5.x",
26
32
  "commander": ">=12.x",
33
+ "csstype": "^3.1.x",
27
34
  "ejs": ">=3.x",
28
35
  "esbuild": ">=0.21.x",
36
+ "ora": ">=8.x",
29
37
  "react": ">=18.x || >=19.x",
30
38
  "winston": ">=3.x"
31
39
  },
32
40
  "exports": {
41
+ "./bin/main": {
42
+ "import": "./bin/main.js",
43
+ "require": "./bin/main.cjs"
44
+ },
33
45
  "./compiler": {
34
46
  "import": "./compiler/index.js",
35
47
  "require": "./compiler/index.cjs"
@@ -38,6 +50,22 @@
38
50
  "import": "./css/index.js",
39
51
  "require": "./css/index.cjs"
40
52
  },
53
+ "./css/keyframes": {
54
+ "import": "./css/keyframes.js",
55
+ "require": "./css/keyframes.cjs"
56
+ },
57
+ "./css/media": {
58
+ "import": "./css/media.js",
59
+ "require": "./css/media.cjs"
60
+ },
61
+ "./css/token": {
62
+ "import": "./css/token.js",
63
+ "require": "./css/token.cjs"
64
+ },
65
+ "./css/merge": {
66
+ "import": "./css/merge.js",
67
+ "require": "./css/merge.cjs"
68
+ },
41
69
  "./generator": {
42
70
  "import": "./generator/index.js",
43
71
  "require": "./generator/index.cjs"
@@ -53,6 +81,10 @@
53
81
  "./util": {
54
82
  "import": "./util/index.js",
55
83
  "require": "./util/index.cjs"
84
+ },
85
+ "./helpers": {
86
+ "import": "./helpers/index.js",
87
+ "require": "./helpers/index.cjs"
56
88
  }
57
89
  },
58
90
  "bin": {
@@ -0,0 +1,5 @@
1
+ "use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),U=i=>e=>{if(typeof e!="string"||!i)return;let t=e;const f=[];return Object.values(i).forEach(n=>{const{pattern:b,transform:P}=n;t=t.replace(b,E=>{const{value:j,css:C}=P(E);return C&&f.push(C),j})}),{transformed:t,additionalCss:f}},S=i=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V.dashCase(n[1].replaceAll(".","-"))})`)},q=S(),J=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],M=(i,e,t)=>{if(J.some(n=>typeof n=="string"?n===i:n.test(i))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${e}${n}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=i=>i.startsWith("-")?i:Q.some(e=>i.startsWith(e))?`-${V.dashCase(i)}`:V.dashCase(i),h=async(i,e="",t,f=!1)=>{if(!i)throw new Error("No styles provided to parseStyles function!");const n=new Set,P=Object.entries(i).map(async([l,s])=>{var y;const r=l.trim(),$=_(r),u=(o,c=";")=>`${$}:${o}${c}`;if(typeof s=="function"&&(s=s({scope:e,config:t})),s instanceof Promise&&(s=await s),t!=null&&t.templates&&t.templatePaths[r]){const[o,c]=t.templatePaths[r].split(";;"),d=(await import(c))[o];if(d&&typeof d.params[r]=="function"){const p=await d.params[r](s),[w]=await h(p,"");return w}}if(t!=null&&t.templates&&t.templates[r]){if(f)return;const c=s.split(".").reduce((a,d)=>a[d],t.templates[r]);if(c){const[a]=await h(c,"");return a}console.warn(`Template "${r}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return u(s.toString());if(r==="defaultVariants")return;if(r==="variants"){const a=Object.entries(s);for(const[d,p]of a){if(!p)return;const w=Object.entries(p);for(const[k,m]of w){if(!m)return;const T=`${e}.${d}-${k}`;(await h(m,T,t)).forEach(z=>n.add(z))}}return}if(r==="compoundVariants"){for(const a of s){const{css:d,...p}=a,w=Object.entries(p).reduce((m,[T,N])=>`${m}.${T}-${N}`,e);(await h(d,w,t)).forEach(m=>n.add(m))}return}if(r.startsWith("@")){const a=((y=t==null?void 0:t.mediaQueries)==null?void 0:y[r])||r,d=await A(s,e,t),p=`${a} { ${d} }`;n.add(p);return}const o=l.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await h(s,o,t)).forEach(a=>n.add(a));return}if(typeof s=="number"){const o=M($,s,t);return u(o)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${$}`);return u(s)}),{modifiers:E}=t||{},j=[S(),U(E)],x=(await Promise.all(P).then(l=>Promise.all(l.map(s=>j.reduce(async(r,$)=>{const u=await r;if(!u)return u;const O=await $(u);if(!O)return u;const{transformed:y,additionalCss:o}=O;let c="";if(o)for(const a of o)c+=await A(a,"");return`${c}${y}`},Promise.resolve(s)))))).filter(l=>l!==void 0).join(`
2
+ `);if(!x.trim())return Array.from(n);const W=e?`${e} {
3
+ ${x}
4
+ }`:x;return n.has(W)?Array.from(n):[W,...n]},A=async(i,e,t,f=!1)=>(await h(i,e,t,f)).join(`
5
+ `);exports.parseAndJoinStyles=A;exports.parseVariableTokens=q;