@salty-css/core 0.0.1-alpha.143 → 0.0.1-alpha.145
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/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +1 -1
- package/index-Ba9ztgjd.cjs +29 -0
- package/index-BrnUnqGp.js +360 -0
- package/package.json +1 -1
- package/index-Btco4x8K.cjs +0 -30
- package/index-ZxtEz_YW.js +0 -361
package/bin/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-Ba9ztgjd.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
|
|
2
2
|
|
|
3
3
|
# Salty-CSS
|
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync as K } from "fs";
|
|
|
3
3
|
import { mkdir as q, readFile as C, writeFile as w } from "fs/promises";
|
|
4
4
|
import { join as i, relative as z, parse as re, format as ee } from "path";
|
|
5
5
|
import { render as ce } from "ejs";
|
|
6
|
-
import { l as t, a as h, g as te } from "../index-
|
|
6
|
+
import { l as t, a as h, g as te } from "../index-BrnUnqGp.js";
|
|
7
7
|
import { p as le } from "../pascal-case-BQpR5PdN.js";
|
|
8
8
|
import { exec as de } from "child_process";
|
|
9
9
|
import fe from "ora";
|
package/compiler/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DD4hQEpv.cjs");const e=require("../index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DD4hQEpv.cjs");const e=require("../index-Ba9ztgjd.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import "path";
|
|
|
5
5
|
import "fs";
|
|
6
6
|
import "fs/promises";
|
|
7
7
|
import "../parse-templates-CgZo0YA1.js";
|
|
8
|
-
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-
|
|
8
|
+
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-BrnUnqGp.js";
|
|
9
9
|
export {
|
|
10
10
|
p as compileSaltyFile,
|
|
11
11
|
n as generateConfigStyles,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";const ae=require("esbuild"),le=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var W=typeof document<"u"?document.currentScript:null;function de(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const c=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,c.get?c:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=de(ae),X=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:X(o.join(e,".."))},pe=async e=>{const t=X(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let V;const Y=async e=>{if(V)return V;const t=await ue(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-Ba9ztgjd.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},H=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),fe=e=>{H.error(e)};function Q(e){return e?typeof e!="string"?Q(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,n)=>(n>0?".":"")+t.toLowerCase()):""}const ye={"*, *::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"}},L={externalModules:[]},ee=e=>{if(L.externalModules.length>0)return L.externalModules;const t=o.join(e,"salty.config.ts"),c=i.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!c)return[];const a=c[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return L.externalModules=a,a},J=e=>o.join(e,"./saltygen"),B=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...B,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),ge=async e=>{const t=J(e),n=o.join(e,"salty.config.ts"),c=o.join(t,"salty.config.js"),a=await Y(e),r=ee(e);await U.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:c,format:a,external:r});const S=Date.now(),{config:f}=await import(`${c}?t=${S}`);return f},se=async e=>{const t=await ge(e),n=new Set,c=(d,g=[])=>d?Object.entries(d).flatMap(([h,u])=>{if(!u)return;if(typeof u=="object")return c(u,[...g,h]);const E=Q(h),R=D.dashCase(h),k=[...g,E].join(".");n.add(`"${k}"`);const F=[...g.map(D.dashCase),R].join("-"),{result:N}=v.parseValueTokens(u);return`--${F}: ${N};`}):[],a=d=>d?Object.entries(d).flatMap(([g,h])=>{const u=c(h);return g==="base"?u.join(""):`${g} { ${u.join("")} }`}):[],r=d=>d?Object.entries(d).flatMap(([g,h])=>Object.entries(h).flatMap(([u,E])=>{const R=c(E,[g]),k=`.${g}-${u}, [data-${g}="${u}"]`,F=R.join("");return`${k} { ${F} }`})):[],S=c(t.variables),f=a(t.responsiveVariables),y=r(t.conditionalVariables),s=J(e),p=o.join(s,"css/_variables.css"),m=`:root { ${S.join("")} ${f.join("")} } ${y.join("")}`;i.writeFileSync(p,m);const w=o.join(s,"css/_global.css"),b=v.parseStyles(t.global,"");i.writeFileSync(w,`@layer global { ${b} }`);const $=o.join(s,"css/_reset.css"),j=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ye,P=v.parseStyles(j,"");i.writeFileSync($,`@layer reset { ${P} }`);const l=o.join(s,"css/_templates.css"),C=v.parseTemplates(t.templates),_=v.getTemplateTypes(t.templates);i.writeFileSync(l,C);const x=o.join(s,"types/css-tokens.d.ts"),T=`
|
|
2
|
+
// Variable types
|
|
3
|
+
type VariableTokens = ${[...n].join("|")};
|
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
5
|
+
|
|
6
|
+
// Template types
|
|
7
|
+
type TemplateTokens = {
|
|
8
|
+
${Object.entries(_).map(([d,g])=>`${d}?: ${g}`).join(`
|
|
9
|
+
`)}
|
|
10
|
+
}
|
|
11
|
+
`;i.writeFileSync(x,T)},A=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,n)=>{if(/^['"`]/.test(n))return t;const a=new RegExp(`import[^;]*${n}[,\\s{][^;]*from\\s?([^{};]+);`);if(!a.test(e))return t;const S=a.exec(e);if(S){const f=S.at(1);if(B.some(s=>f==null?void 0:f.includes(s)))return t}return"styled('div',"}),q=async(e,t,n)=>{const c=D.toHash(t),a=o.join(n,"./temp");i.existsSync(a)||i.mkdirSync(a);const r=o.parse(t);let S=i.readFileSync(t,"utf8");S=A(S);const f=o.join(n,"js",c+".js"),y=ee(e),s=await Y(e);await U.build({stdin:{contents:S,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:f,format:s,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:w=>{w.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},b=>{const $=i.readFileSync(b.path,"utf8");return{contents:A($),loader:"ts"}})}}]});const p=Date.now();return await import(`${f}?t=${p}`)},K=async e=>{const t=J(e),n=o.join(t,"salty.config.js"),c=Date.now(),{config:a}=await import(`${n}?t=${c}`);return a},ne=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},me=async(e,t=ne())=>{try{const n=Date.now();t?H.info("Generating CSS in production mode! 🔥"):H.info("Generating CSS in development mode! 🚀");const c=[],a=[],r=J(e),S=o.join(r,"index.css");(()=>{i.existsSync(r)&&le.execSync("rm -rf "+r),i.mkdirSync(r),i.mkdirSync(o.join(r,"css")),i.mkdirSync(o.join(r,"types"))})(),await se(e);const y=await K(e);async function s(l,C){const _=["node_modules","saltygen"],x=i.statSync(l);if(x.isDirectory()){const M=i.readdirSync(l);if(_.some(d=>l.includes(d)))return;await Promise.all(M.map(d=>s(o.join(l,d),o.join(C,d))))}else if(x.isFile()&&I(l)){const T=await q(e,l,r),d=[];Object.entries(T).forEach(([k,F])=>{if(F.isKeyframes&&F.css){const Z=`a_${F.animationName}.css`,ie=`css/${Z}`,ce=o.join(r,ie);c.push(Z),i.writeFileSync(ce,F.css);return}if(!F.generator)return;const N=F.generator._withBuildContext({name:k,config:y,prod:t});a[N.priority]||(a[N.priority]=[]),a[N.priority].push(N.cssFileName),d.push(N.cssFileName);const oe=`css/${N.cssFileName}`,re=o.join(r,oe);i.writeFileSync(re,N.css)});const g=d.map(k=>`@import url('./${k}');`).join(`
|
|
12
|
+
`),h=D.toHash(l,6),u=o.parse(l),E=D.dashCase(u.name),R=o.join(r,`css/f_${E}-${h}.css`);i.writeFileSync(R,g)}}await s(e,r);const p=c.map(l=>`@import url('./css/${l}');`).join(`
|
|
13
|
+
`);let $=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
14
|
+
|
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(l=>{try{return i.readFileSync(o.join(r,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
|
16
|
+
`)}
|
|
17
|
+
${p}`;if(y.importStrategy!=="component"){const l=a.reduce((C,_,x)=>{const M=_.reduce((h,u)=>{var F;const E=o.join(r,"css",u),R=i.readFileSync(E,"utf8"),k=((F=/.*-([^-]+)-\d+.css/.exec(u))==null?void 0:F.at(1))||D.toHash(E,6);return h.includes(k)?h:`${h}
|
|
18
|
+
/*start:${k}*/
|
|
19
|
+
${R}
|
|
20
|
+
/*end:${k}*/
|
|
21
|
+
`},""),T=`l_${x}.css`,d=o.join(r,"css",T),g=`@layer l${x} { ${M}
|
|
22
|
+
}`;return i.writeFileSync(d,g),`${C}
|
|
23
|
+
@import url('./css/${T}');`},"");$+=l}i.writeFileSync(S,$);const j=Date.now()-n,P=j<200?"🔥":j<500?"🚀":j<1e3?"🎉":j<2e3?"🚗":j<5e3?"🤔":"🥴";H.info(`Generated CSS in ${j}ms! ${P}`)}catch(n){console.error(n)}},he=async(e,t)=>{try{const n=o.join(e,"./saltygen");if(I(t)){const a=[],r=await K(e),S=await q(e,t,n);Object.entries(S).forEach(([f,y])=>{if(y.isKeyframes&&y.css){const b=`css/${`a_${y.animationName}.css`}`,$=o.join(n,b);i.writeFileSync($,y.css);return}if(!y.generator)return;const s=y.generator._withBuildContext({name:f,config:r}),p=`css/${s.cssFileName}`,m=o.join(n,p);i.writeFileSync(m,s.css),a[s.priority]||(a[s.priority]=[]),a[s.priority].push(s.cssFileName)}),r.importStrategy!=="component"&&a.forEach((f,y)=>{const s=`l_${y}.css`,p=o.join(n,"css",s);let m=i.readFileSync(p,"utf8");f.forEach(w=>{var j;const b=o.join(n,"css",w),$=((j=/.*-([^-]+)-\d+.css/.exec(w))==null?void 0:j.at(1))||D.toHash(b,6);if(!m.includes($)){const P=i.readFileSync(b,"utf8"),l=`/*start:${$}*/
|
|
24
|
+
${P}
|
|
25
|
+
/*end:${$}*/
|
|
26
|
+
`;m=`${m.replace(/\}$/,"")}
|
|
27
|
+
${l}
|
|
28
|
+
}`}}),i.writeFileSync(p,m)})}}catch(n){console.error(n)}},Se=async(e,t,n=ne())=>{try{const c=o.join(e,"./saltygen");if(I(t)){const r=i.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,p=>`export ${p}`)!==r&&await G.writeFile(t,r);const f=await K(e),y=await q(e,t,c);let s=r;if(Object.entries(y).forEach(([p,m])=>{var h;if(m.isKeyframes||!m.generator)return;const w=m.generator._withBuildContext({name:p,config:f,prod:n}),b=new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!b)return console.error("Could not find the original declaration");const $=(h=b.at(1))==null?void 0:h.trim(),O=new RegExp(`\\s${p}[=\\s]+styled\\(`,"g").exec(s);if(!O)return console.error("Could not find the original declaration");const{index:j}=O;let P=!1;const l=setTimeout(()=>P=!0,5e3);let C=0,_=!1,x=0;for(;!_&&!P;){const u=s[j+C];u==="("&&x++,u===")"&&x--,x===0&&u===")"&&(_=!0),C>s.length&&(P=!0),C++}if(!P)clearTimeout(l);else throw new Error("Failed to find the end of the styled call and timed out");const M=j+C,T=s.slice(j,M),d=s,g=` ${p} = styled(${$}, "${w.classNames}", ${JSON.stringify(w.props)});`;s=s.replace(T,g),d===s&&console.error("Minimize file failed to change content",{name:p,tagName:$})}),f.importStrategy==="component"){const p=D.toHash(t,6),m=o.parse(t);s=`import '../../saltygen/css/${`f_${D.dashCase(m.name)}-${p}.css`}';
|
|
29
|
+
${s}`}return s=s.replace("{ styled }","{ styledClient as styled }"),s=s.replace("@salty-css/react/styled","@salty-css/react/styled-client"),s}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=q;exports.generateConfigStyles=se;exports.generateCss=me;exports.generateFile=he;exports.isSaltyFile=I;exports.logError=fe;exports.logger=H;exports.minimizeFile=Se;exports.saltyFileExtensions=B;exports.saltyFileRegExp=te;
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import * as Y from "esbuild";
|
|
2
|
+
import { execSync as lt } from "child_process";
|
|
3
|
+
import { t as J, d as W } from "./dash-case-DBThphLm.js";
|
|
4
|
+
import { join as o, parse as K } from "path";
|
|
5
|
+
import { existsSync as L, writeFileSync as x, mkdirSync as O, readFileSync as _, statSync as pt, readdirSync as ft } from "fs";
|
|
6
|
+
import { readFile as dt, writeFile as ut } from "fs/promises";
|
|
7
|
+
import { p as U, a as gt, b as mt, c as yt } from "./parse-templates-CgZo0YA1.js";
|
|
8
|
+
import { createLogger as ht, format as H, transports as $t } from "winston";
|
|
9
|
+
const Q = (t) => {
|
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
|
11
|
+
const e = o(t, "package.json");
|
|
12
|
+
return L(e) ? e : Q(o(t, ".."));
|
|
13
|
+
}, bt = async (t) => {
|
|
14
|
+
const e = Q(t);
|
|
15
|
+
return await dt(e, "utf-8").then(JSON.parse).catch(() => {
|
|
16
|
+
});
|
|
17
|
+
}, St = async (t) => {
|
|
18
|
+
const e = await bt(t);
|
|
19
|
+
if (e)
|
|
20
|
+
return e.type;
|
|
21
|
+
};
|
|
22
|
+
let R;
|
|
23
|
+
const tt = async (t) => {
|
|
24
|
+
if (R) return R;
|
|
25
|
+
const e = await St(t);
|
|
26
|
+
return e === "module" ? R = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (R = "cjs"), R || "esm";
|
|
27
|
+
}, z = ht({
|
|
28
|
+
level: "debug",
|
|
29
|
+
format: H.combine(H.colorize(), H.cli()),
|
|
30
|
+
transports: [new $t.Console({})]
|
|
31
|
+
}), _t = (t) => {
|
|
32
|
+
z.error(t);
|
|
33
|
+
};
|
|
34
|
+
function et(t) {
|
|
35
|
+
return t ? typeof t != "string" ? et(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, r) => (r > 0 ? "." : "") + e.toLowerCase()) : "";
|
|
36
|
+
}
|
|
37
|
+
const wt = {
|
|
38
|
+
/** Set box model to border-box */
|
|
39
|
+
"*, *::before, *::after": {
|
|
40
|
+
boxSizing: "border-box"
|
|
41
|
+
},
|
|
42
|
+
/** Remove default margin and padding */
|
|
43
|
+
"*": {
|
|
44
|
+
margin: 0
|
|
45
|
+
},
|
|
46
|
+
/** Remove adjust font properties */
|
|
47
|
+
html: {
|
|
48
|
+
lineHeight: 1.15,
|
|
49
|
+
textSizeAdjust: "100%",
|
|
50
|
+
WebkitFontSmoothing: "antialiased"
|
|
51
|
+
},
|
|
52
|
+
/** Make media elements responsive */
|
|
53
|
+
"img, picture, video, canvas, svg": {
|
|
54
|
+
display: "block",
|
|
55
|
+
maxWidth: "100%"
|
|
56
|
+
},
|
|
57
|
+
/** Avoid overflow of text */
|
|
58
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
|
59
|
+
overflowWrap: "break-word"
|
|
60
|
+
},
|
|
61
|
+
/** Improve text wrapping */
|
|
62
|
+
p: {
|
|
63
|
+
textWrap: "pretty"
|
|
64
|
+
},
|
|
65
|
+
"h1, h2, h3, h4, h5, h6": {
|
|
66
|
+
textWrap: "balance"
|
|
67
|
+
},
|
|
68
|
+
/** Improve link color */
|
|
69
|
+
a: {
|
|
70
|
+
color: "currentColor"
|
|
71
|
+
},
|
|
72
|
+
/** Improve button line height */
|
|
73
|
+
button: {
|
|
74
|
+
lineHeight: "1em",
|
|
75
|
+
color: "currentColor"
|
|
76
|
+
},
|
|
77
|
+
/** Improve form elements */
|
|
78
|
+
"input, optgroup, select, textarea": {
|
|
79
|
+
fontFamily: "inherit",
|
|
80
|
+
fontSize: "100%",
|
|
81
|
+
lineHeight: "1.15em"
|
|
82
|
+
}
|
|
83
|
+
}, B = {
|
|
84
|
+
externalModules: []
|
|
85
|
+
}, st = (t) => {
|
|
86
|
+
if (B.externalModules.length > 0) return B.externalModules;
|
|
87
|
+
const e = o(t, "salty.config.ts"), c = _(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
|
88
|
+
if (!c) return [];
|
|
89
|
+
const a = c[1].split(",").map((n) => n.replace(/['"`]/g, "").trim());
|
|
90
|
+
return B.externalModules = a, a;
|
|
91
|
+
}, I = (t) => o(t, "./saltygen"), nt = ["salty", "css", "styles", "styled"], xt = (t = []) => new RegExp(`\\.(${[...nt, ...t].join("|")})\\.`), Z = (t, e = []) => xt(e).test(t), Ct = async (t) => {
|
|
92
|
+
const e = I(t), r = o(t, "salty.config.ts"), c = o(e, "salty.config.js"), a = await tt(t), n = st(t);
|
|
93
|
+
await Y.build({
|
|
94
|
+
entryPoints: [r],
|
|
95
|
+
minify: !0,
|
|
96
|
+
treeShaking: !0,
|
|
97
|
+
bundle: !0,
|
|
98
|
+
outfile: c,
|
|
99
|
+
format: a,
|
|
100
|
+
external: n
|
|
101
|
+
});
|
|
102
|
+
const h = Date.now(), { config: d } = await import(`${c}?t=${h}`);
|
|
103
|
+
return d;
|
|
104
|
+
}, Ft = async (t) => {
|
|
105
|
+
const e = await Ct(t), r = /* @__PURE__ */ new Set(), c = (l, g = []) => l ? Object.entries(l).flatMap(([y, f]) => {
|
|
106
|
+
if (!f) return;
|
|
107
|
+
if (typeof f == "object") return c(f, [...g, y]);
|
|
108
|
+
const E = et(y), V = W(y), k = [...g, E].join(".");
|
|
109
|
+
r.add(`"${k}"`);
|
|
110
|
+
const w = [...g.map(W), V].join("-"), { result: T } = yt(f);
|
|
111
|
+
return `--${w}: ${T};`;
|
|
112
|
+
}) : [], a = (l) => l ? Object.entries(l).flatMap(([g, y]) => {
|
|
113
|
+
const f = c(y);
|
|
114
|
+
return g === "base" ? f.join("") : `${g} { ${f.join("")} }`;
|
|
115
|
+
}) : [], n = (l) => l ? Object.entries(l).flatMap(([g, y]) => Object.entries(y).flatMap(([f, E]) => {
|
|
116
|
+
const V = c(E, [g]), k = `.${g}-${f}, [data-${g}="${f}"]`, w = V.join("");
|
|
117
|
+
return `${k} { ${w} }`;
|
|
118
|
+
})) : [], h = c(e.variables), d = a(e.responsiveVariables), u = n(e.conditionalVariables), s = I(t), p = o(s, "css/_variables.css"), m = `:root { ${h.join("")} ${d.join("")} } ${u.join("")}`;
|
|
119
|
+
x(p, m);
|
|
120
|
+
const C = o(s, "css/_global.css"), S = U(e.global, "");
|
|
121
|
+
x(C, `@layer global { ${S} }`);
|
|
122
|
+
const $ = o(s, "css/_reset.css"), b = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : wt, P = U(b, "");
|
|
123
|
+
x($, `@layer reset { ${P} }`);
|
|
124
|
+
const i = o(s, "css/_templates.css"), F = gt(e.templates), D = mt(e.templates);
|
|
125
|
+
x(i, F);
|
|
126
|
+
const j = o(s, "types/css-tokens.d.ts"), N = `
|
|
127
|
+
// Variable types
|
|
128
|
+
type VariableTokens = ${[...r].join("|")};
|
|
129
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
130
|
+
|
|
131
|
+
// Template types
|
|
132
|
+
type TemplateTokens = {
|
|
133
|
+
${Object.entries(D).map(([l, g]) => `${l}?: ${g}`).join(`
|
|
134
|
+
`)}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
x(j, N);
|
|
138
|
+
}, X = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, r) => {
|
|
139
|
+
if (/^['"`]/.test(r)) return e;
|
|
140
|
+
const a = new RegExp(`import[^;]*${r}[,\\s{][^;]*from\\s?([^{};]+);`);
|
|
141
|
+
if (!a.test(t)) return e;
|
|
142
|
+
const h = a.exec(t);
|
|
143
|
+
if (h) {
|
|
144
|
+
const d = h.at(1);
|
|
145
|
+
if (nt.some((s) => d == null ? void 0 : d.includes(s))) return e;
|
|
146
|
+
}
|
|
147
|
+
return "styled('div',";
|
|
148
|
+
}), A = async (t, e, r) => {
|
|
149
|
+
const c = J(e), a = o(r, "./temp");
|
|
150
|
+
L(a) || O(a);
|
|
151
|
+
const n = K(e);
|
|
152
|
+
let h = _(e, "utf8");
|
|
153
|
+
h = X(h);
|
|
154
|
+
const d = o(r, "js", c + ".js"), u = st(t), s = await tt(t);
|
|
155
|
+
await Y.build({
|
|
156
|
+
stdin: {
|
|
157
|
+
contents: h,
|
|
158
|
+
sourcefile: n.base,
|
|
159
|
+
resolveDir: n.dir,
|
|
160
|
+
loader: "tsx"
|
|
161
|
+
},
|
|
162
|
+
minify: !1,
|
|
163
|
+
treeShaking: !0,
|
|
164
|
+
bundle: !0,
|
|
165
|
+
outfile: d,
|
|
166
|
+
format: s,
|
|
167
|
+
target: ["node20"],
|
|
168
|
+
keepNames: !0,
|
|
169
|
+
external: u,
|
|
170
|
+
packages: "external",
|
|
171
|
+
plugins: [
|
|
172
|
+
{
|
|
173
|
+
name: "test",
|
|
174
|
+
setup: (C) => {
|
|
175
|
+
C.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (S) => {
|
|
176
|
+
const $ = _(S.path, "utf8");
|
|
177
|
+
return { contents: X($), loader: "ts" };
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
});
|
|
183
|
+
const p = Date.now();
|
|
184
|
+
return await import(`${d}?t=${p}`);
|
|
185
|
+
}, G = async (t) => {
|
|
186
|
+
const e = I(t), r = o(e, "salty.config.js"), c = Date.now(), { config: a } = await import(`${r}?t=${c}`);
|
|
187
|
+
return a;
|
|
188
|
+
}, ot = () => {
|
|
189
|
+
try {
|
|
190
|
+
return process.env.NODE_ENV === "production";
|
|
191
|
+
} catch {
|
|
192
|
+
return !1;
|
|
193
|
+
}
|
|
194
|
+
}, Mt = async (t, e = ot()) => {
|
|
195
|
+
try {
|
|
196
|
+
const r = Date.now();
|
|
197
|
+
e ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
|
|
198
|
+
const c = [], a = [], n = I(t), h = o(n, "index.css");
|
|
199
|
+
(() => {
|
|
200
|
+
L(n) && lt("rm -rf " + n), O(n), O(o(n, "css")), O(o(n, "types"));
|
|
201
|
+
})(), await Ft(t);
|
|
202
|
+
const u = await G(t);
|
|
203
|
+
async function s(i, F) {
|
|
204
|
+
const D = ["node_modules", "saltygen"], j = pt(i);
|
|
205
|
+
if (j.isDirectory()) {
|
|
206
|
+
const M = ft(i);
|
|
207
|
+
if (D.some((l) => i.includes(l))) return;
|
|
208
|
+
await Promise.all(M.map((l) => s(o(i, l), o(F, l))));
|
|
209
|
+
} else if (j.isFile() && Z(i)) {
|
|
210
|
+
const N = await A(t, i, n), l = [];
|
|
211
|
+
Object.entries(N).forEach(([k, w]) => {
|
|
212
|
+
if (w.isKeyframes && w.css) {
|
|
213
|
+
const q = `a_${w.animationName}.css`, ct = `css/${q}`, it = o(n, ct);
|
|
214
|
+
c.push(q), x(it, w.css);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (!w.generator) return;
|
|
218
|
+
const T = w.generator._withBuildContext({
|
|
219
|
+
name: k,
|
|
220
|
+
config: u,
|
|
221
|
+
prod: e
|
|
222
|
+
});
|
|
223
|
+
a[T.priority] || (a[T.priority] = []), a[T.priority].push(T.cssFileName), l.push(T.cssFileName);
|
|
224
|
+
const rt = `css/${T.cssFileName}`, at = o(n, rt);
|
|
225
|
+
x(at, T.css);
|
|
226
|
+
});
|
|
227
|
+
const g = l.map((k) => `@import url('./${k}');`).join(`
|
|
228
|
+
`), y = J(i, 6), f = K(i), E = W(f.name), V = o(n, `css/f_${E}-${y}.css`);
|
|
229
|
+
x(V, g);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
await s(t, n);
|
|
233
|
+
const p = c.map((i) => `@import url('./css/${i}');`).join(`
|
|
234
|
+
`);
|
|
235
|
+
let $ = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
236
|
+
|
|
237
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((i) => {
|
|
238
|
+
try {
|
|
239
|
+
return _(o(n, "css", i), "utf8").length > 0;
|
|
240
|
+
} catch {
|
|
241
|
+
return !1;
|
|
242
|
+
}
|
|
243
|
+
}).map((i) => `@import url('./css/${i}');`).join(`
|
|
244
|
+
`)}
|
|
245
|
+
${p}`;
|
|
246
|
+
if (u.importStrategy !== "component") {
|
|
247
|
+
const i = a.reduce((F, D, j) => {
|
|
248
|
+
const M = D.reduce((y, f) => {
|
|
249
|
+
var w;
|
|
250
|
+
const E = o(n, "css", f), V = _(E, "utf8"), k = ((w = /.*-([^-]+)-\d+.css/.exec(f)) == null ? void 0 : w.at(1)) || J(E, 6);
|
|
251
|
+
return y.includes(k) ? y : `${y}
|
|
252
|
+
/*start:${k}*/
|
|
253
|
+
${V}
|
|
254
|
+
/*end:${k}*/
|
|
255
|
+
`;
|
|
256
|
+
}, ""), N = `l_${j}.css`, l = o(n, "css", N), g = `@layer l${j} { ${M}
|
|
257
|
+
}`;
|
|
258
|
+
return x(l, g), `${F}
|
|
259
|
+
@import url('./css/${N}');`;
|
|
260
|
+
}, "");
|
|
261
|
+
$ += i;
|
|
262
|
+
}
|
|
263
|
+
x(h, $);
|
|
264
|
+
const b = Date.now() - r, P = b < 200 ? "🔥" : b < 500 ? "🚀" : b < 1e3 ? "🎉" : b < 2e3 ? "🚗" : b < 5e3 ? "🤔" : "🥴";
|
|
265
|
+
z.info(`Generated CSS in ${b}ms! ${P}`);
|
|
266
|
+
} catch (r) {
|
|
267
|
+
console.error(r);
|
|
268
|
+
}
|
|
269
|
+
}, Vt = async (t, e) => {
|
|
270
|
+
try {
|
|
271
|
+
const r = o(t, "./saltygen");
|
|
272
|
+
if (Z(e)) {
|
|
273
|
+
const a = [], n = await G(t), h = await A(t, e, r);
|
|
274
|
+
Object.entries(h).forEach(([d, u]) => {
|
|
275
|
+
if (u.isKeyframes && u.css) {
|
|
276
|
+
const S = `css/${`a_${u.animationName}.css`}`, $ = o(r, S);
|
|
277
|
+
x($, u.css);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!u.generator) return;
|
|
281
|
+
const s = u.generator._withBuildContext({
|
|
282
|
+
name: d,
|
|
283
|
+
config: n
|
|
284
|
+
}), p = `css/${s.cssFileName}`, m = o(r, p);
|
|
285
|
+
x(m, s.css), a[s.priority] || (a[s.priority] = []), a[s.priority].push(s.cssFileName);
|
|
286
|
+
}), n.importStrategy !== "component" && a.forEach((d, u) => {
|
|
287
|
+
const s = `l_${u}.css`, p = o(r, "css", s);
|
|
288
|
+
let m = _(p, "utf8");
|
|
289
|
+
d.forEach((C) => {
|
|
290
|
+
var b;
|
|
291
|
+
const S = o(r, "css", C), $ = ((b = /.*-([^-]+)-\d+.css/.exec(C)) == null ? void 0 : b.at(1)) || J(S, 6);
|
|
292
|
+
if (!m.includes($)) {
|
|
293
|
+
const P = _(S, "utf8"), i = `/*start:${$}*/
|
|
294
|
+
${P}
|
|
295
|
+
/*end:${$}*/
|
|
296
|
+
`;
|
|
297
|
+
m = `${m.replace(/\}$/, "")}
|
|
298
|
+
${i}
|
|
299
|
+
}`;
|
|
300
|
+
}
|
|
301
|
+
}), x(p, m);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
} catch (r) {
|
|
305
|
+
console.error(r);
|
|
306
|
+
}
|
|
307
|
+
}, vt = async (t, e, r = ot()) => {
|
|
308
|
+
try {
|
|
309
|
+
const c = o(t, "./saltygen");
|
|
310
|
+
if (Z(e)) {
|
|
311
|
+
const n = _(e, "utf8");
|
|
312
|
+
n.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== n && await ut(e, n);
|
|
313
|
+
const d = await G(t), u = await A(t, e, c);
|
|
314
|
+
let s = n;
|
|
315
|
+
if (Object.entries(u).forEach(([p, m]) => {
|
|
316
|
+
var y;
|
|
317
|
+
if (m.isKeyframes || !m.generator) return;
|
|
318
|
+
const C = m.generator._withBuildContext({
|
|
319
|
+
name: p,
|
|
320
|
+
config: d,
|
|
321
|
+
prod: r
|
|
322
|
+
}), S = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(n);
|
|
323
|
+
if (!S) return console.error("Could not find the original declaration");
|
|
324
|
+
const $ = (y = S.at(1)) == null ? void 0 : y.trim(), v = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(s);
|
|
325
|
+
if (!v) return console.error("Could not find the original declaration");
|
|
326
|
+
const { index: b } = v;
|
|
327
|
+
let P = !1;
|
|
328
|
+
const i = setTimeout(() => P = !0, 5e3);
|
|
329
|
+
let F = 0, D = !1, j = 0;
|
|
330
|
+
for (; !D && !P; ) {
|
|
331
|
+
const f = s[b + F];
|
|
332
|
+
f === "(" && j++, f === ")" && j--, j === 0 && f === ")" && (D = !0), F > s.length && (P = !0), F++;
|
|
333
|
+
}
|
|
334
|
+
if (!P) clearTimeout(i);
|
|
335
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
|
336
|
+
const M = b + F, N = s.slice(b, M), l = s, g = ` ${p} = styled(${$}, "${C.classNames}", ${JSON.stringify(C.props)});`;
|
|
337
|
+
s = s.replace(N, g), l === s && console.error("Minimize file failed to change content", { name: p, tagName: $ });
|
|
338
|
+
}), d.importStrategy === "component") {
|
|
339
|
+
const p = J(e, 6), m = K(e);
|
|
340
|
+
s = `import '../../saltygen/css/${`f_${W(m.name)}-${p}.css`}';
|
|
341
|
+
${s}`;
|
|
342
|
+
}
|
|
343
|
+
return s = s.replace("{ styled }", "{ styledClient as styled }"), s = s.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), s;
|
|
344
|
+
}
|
|
345
|
+
} catch (c) {
|
|
346
|
+
console.error("Error in minimizeFile:", c);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
export {
|
|
350
|
+
_t as a,
|
|
351
|
+
xt as b,
|
|
352
|
+
Ft as c,
|
|
353
|
+
A as d,
|
|
354
|
+
Vt as e,
|
|
355
|
+
Mt as g,
|
|
356
|
+
Z as i,
|
|
357
|
+
z as l,
|
|
358
|
+
vt as m,
|
|
359
|
+
nt as s
|
|
360
|
+
};
|
package/package.json
CHANGED
package/index-Btco4x8K.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";const ae=require("esbuild"),le=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),H=require("winston");var W=typeof document<"u"?document.currentScript:null;function pe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const U=pe(ae),X=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:X(o.join(e,".."))},de=async e=>{const t=X(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},fe=async e=>{const t=await de(e);if(t)return t.type};let V;const Y=async e=>{if(V)return V;const t=await fe(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-Btco4x8K.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},z=H.createLogger({level:"debug",format:H.format.combine(H.format.colorize(),H.format.cli()),transports:[new H.transports.Console({})]}),ue=e=>{z.error(e)};function Q(e){return e?typeof e!="string"?Q(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 ye={"*, *::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"}},L={externalModules:[]},ee=e=>{if(L.externalModules.length>0)return L.externalModules;const t=o.join(e,"salty.config.ts"),c=i.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!c)return[];const d=c[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return L.externalModules=d,d},J=e=>o.join(e,"./saltygen"),A=["salty","css","styles","styled"],te=(e=[])=>new RegExp(`\\.(${[...A,...e].join("|")})\\.`),I=(e,t=[])=>te(t).test(e),ge=async e=>{const t=J(e),s=o.join(e,"salty.config.ts"),c=o.join(t,"salty.config.js"),d=await Y(e),n=ee(e);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:c,format:d,external:n});const m=Date.now(),{config:h}=await import(`${c}?t=${m}`);return h},se=async e=>{const t=await ge(e),s=new Set,c=(p,u=[])=>p?Object.entries(p).flatMap(([j,y])=>{if(!y)return;if(typeof y=="object")return c(y,[...u,j]);const M=Q(j),O=D.dashCase(j),T=[...u,M].join(".");s.add(`"${T}"`);const N=[...u.map(D.dashCase),O].join("-"),{result:E}=v.parseValueTokens(y);return`--${N}: ${E};`}):[],d=p=>p?Object.entries(p).flatMap(([u,j])=>{const y=c(j);return u==="base"?y.join(""):`${u} { ${y.join("")} }`}):[],n=p=>p?Object.entries(p).flatMap(([u,j])=>Object.entries(j).flatMap(([y,M])=>{const O=c(M,[u]),T=`.${u}-${y}, [data-${u}="${y}"]`,N=O.join("");return`${T} { ${N} }`})):[],m=c(t.variables),h=d(t.responsiveVariables),k=n(t.conditionalVariables),r=J(e),a=o.join(r,"css/_variables.css"),f=`:root { ${m.join("")} ${h.join("")} } ${k.join("")}`;i.writeFileSync(a,f);const F=o.join(r,"css/_global.css"),S=v.parseStyles(t.global,"");i.writeFileSync(F,`@layer global { ${S} }`);const b=o.join(r,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ye,C=v.parseStyles(g,"");i.writeFileSync(b,`@layer reset { ${C} }`);const l=o.join(r,"css/_templates.css"),$=v.parseTemplates(t.templates),P=v.getTemplateTypes(t.templates);i.writeFileSync(l,$);const x=o.join(r,"types/css-tokens.d.ts"),_=`
|
|
2
|
-
// Variable types
|
|
3
|
-
type VariableTokens = ${[...s].join("|")};
|
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
5
|
-
|
|
6
|
-
// Template types
|
|
7
|
-
type TemplateTokens = {
|
|
8
|
-
${Object.entries(P).map(([p,u])=>`${p}?: ${u}`).join(`
|
|
9
|
-
`)}
|
|
10
|
-
}
|
|
11
|
-
`;i.writeFileSync(x,_)},Z=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const d=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!d.test(e))return t;const m=d.exec(e);if(m){const h=m.at(1);if(A.some(r=>h==null?void 0:h.includes(r)))return t}return"styled('div',"}),q=async(e,t,s)=>{const c=D.toHash(t),d=o.join(s,"./temp");i.existsSync(d)||i.mkdirSync(d);const n=o.parse(t);let m=i.readFileSync(t,"utf8");m=Z(m);const h=o.join(s,"js",c+".js"),k=ee(e),r=await Y(e);await U.build({stdin:{contents:m,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:r,target:["node20"],keepNames:!0,external:k,packages:"external",plugins:[{name:"test",setup:F=>{F.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},S=>{const b=i.readFileSync(S.path,"utf8");return{contents:Z(b),loader:"ts"}})}}]});const a=Date.now();return await import(`${h}?t=${a}`)},B=async e=>{const t=J(e),s=o.join(t,"salty.config.js"),c=Date.now(),{config:d}=await import(`${s}?t=${c}`);return d},ne=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},me=async(e,t=ne())=>{try{const s=Date.now();t?z.info("Generating CSS in production mode! 🔥"):z.info("Generating CSS in development mode! 🚀");const c=[],d=[],n=J(e),m=o.join(n,"index.css");(()=>{i.existsSync(n)&&le.execSync("rm -rf "+n),i.mkdirSync(n),i.mkdirSync(o.join(n,"css")),i.mkdirSync(o.join(n,"types"))})(),await se(e);const k=await B(e);async function r(l,$){const P=["node_modules","saltygen"],x=i.statSync(l);if(x.isDirectory()){const R=i.readdirSync(l);if(P.some(p=>l.includes(p)))return;await Promise.all(R.map(p=>r(o.join(l,p),o.join($,p))))}else if(x.isFile()&&I(l)){const _=await q(e,l,n),p=[];Object.entries(_).forEach(([T,N])=>{if(N.isKeyframes&&N.css){const K=`a_${N.animationName}.css`,ie=`css/${K}`,ce=o.join(n,ie);c.push(K),i.writeFileSync(ce,N.css);return}if(!N.generator)return;const E=N.generator._withBuildContext({name:T,config:k,prod:t});d[E.priority]||(d[E.priority]=[]),d[E.priority].push(E.cssFileName),p.push(E.cssFileName);const oe=`css/${E.cssFileName}`,re=o.join(n,oe);i.writeFileSync(re,E.css)});const u=p.map(T=>`@import url('./${T}');`).join(`
|
|
12
|
-
`),j=D.toHash(l,6),y=o.parse(l),M=D.dashCase(y.name),O=o.join(n,`css/f_${M}-${j}.css`);i.writeFileSync(O,u)}}await r(e,n);const a=c.map(l=>`@import url('./css/${l}');`).join(`
|
|
13
|
-
`);let b=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
14
|
-
|
|
15
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(l=>{try{return i.readFileSync(o.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
|
16
|
-
`)}
|
|
17
|
-
${a}`;if(k.importStrategy!=="component"){const l=d.reduce(($,P,x)=>{const R=P.reduce((j,y)=>{const M=o.join(n,"css",y),O=i.readFileSync(M,"utf8"),T=D.toHash(M,6);return`${j}
|
|
18
|
-
/*start:${T}*/
|
|
19
|
-
${O}
|
|
20
|
-
/*end:${T}*/
|
|
21
|
-
`},""),_=`l_${x}.css`,p=o.join(n,"css",_),u=`@layer l${x} { ${R}
|
|
22
|
-
}`;return i.writeFileSync(p,u),`${$}
|
|
23
|
-
@import url('./css/${_}');`},"");b+=l}i.writeFileSync(m,b);const g=Date.now()-s,C=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";z.info(`Generated CSS in ${g}ms! ${C}`)}catch(s){console.error(s)}},he=async(e,t)=>{try{const s=o.join(e,"./saltygen"),c=o.join(s,"index.css");if(I(t)){const n=[],m=await B(e),h=await q(e,t,s);Object.entries(h).forEach(([r,a])=>{if(a.isKeyframes&&a.css){const w=`css/${`a_${a.animationName}.css`}`,g=o.join(s,w);i.writeFileSync(g,a.css);return}if(!a.generator)return;const f=a.generator._withBuildContext({name:r,config:m}),F=`css/${f.cssFileName}`,S=o.join(s,F);i.writeFileSync(S,f.css),n[f.priority]||(n[f.priority]=[]),n[f.priority].push(f.cssFileName)});const k=i.readFileSync(c,"utf8").split(`
|
|
24
|
-
`);m.importStrategy!=="component"&&n.forEach((r,a)=>{const f=`l_${a}.css`,F=o.join(s,"css",f);let S=i.readFileSync(F,"utf8");r.forEach(b=>{const w=o.join(s,"css",b),g=D.toHash(w,6),C=S.includes(g);if(console.log({layer:a,filepath:w,filepathHash:g,found:C}),!C){const l=i.readFileSync(w,"utf8"),$=D.toHash(w,6),P=`/*start:${$}*/
|
|
25
|
-
${l}
|
|
26
|
-
/*end:${$}*/
|
|
27
|
-
`;S=`${S.replace(/\}$/,"")}
|
|
28
|
-
${P}
|
|
29
|
-
}`}}),i.writeFileSync(F,S)})}}catch(s){console.error(s)}},Se=async(e,t,s=ne())=>{try{const c=o.join(e,"./saltygen");if(I(t)){const n=i.readFileSync(t,"utf8");n.replace(/^(?!export\s)const\s.*/gm,a=>`export ${a}`)!==n&&await G.writeFile(t,n);const h=await B(e),k=await q(e,t,c);let r=n;if(Object.entries(k).forEach(([a,f])=>{var j;if(f.isKeyframes||!f.generator)return;const F=f.generator._withBuildContext({name:a,config:h,prod:s}),S=new RegExp(`\\s${a}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(n);if(!S)return console.error("Could not find the original declaration");const b=(j=S.at(1))==null?void 0:j.trim(),w=new RegExp(`\\s${a}[=\\s]+styled\\(`,"g").exec(r);if(!w)return console.error("Could not find the original declaration");const{index:g}=w;let C=!1;const l=setTimeout(()=>C=!0,5e3);let $=0,P=!1,x=0;for(;!P&&!C;){const y=r[g+$];y==="("&&x++,y===")"&&x--,x===0&&y===")"&&(P=!0),$>r.length&&(C=!0),$++}if(!C)clearTimeout(l);else throw new Error("Failed to find the end of the styled call and timed out");const R=g+$,_=r.slice(g,R),p=r,u=` ${a} = styled(${b}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(_,u),p===r&&console.error("Minimize file failed to change content",{name:a,tagName:b})}),h.importStrategy==="component"){const a=D.toHash(t,6),f=o.parse(t);r=`import '../../saltygen/css/${`f_${D.dashCase(f.name)}-${a}.css`}';
|
|
30
|
-
${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=q;exports.generateConfigStyles=se;exports.generateCss=me;exports.generateFile=he;exports.isSaltyFile=I;exports.logError=ue;exports.logger=z;exports.minimizeFile=Se;exports.saltyFileExtensions=A;exports.saltyFileRegExp=te;
|
package/index-ZxtEz_YW.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import * as Y from "esbuild";
|
|
2
|
-
import { execSync as lt } from "child_process";
|
|
3
|
-
import { t as J, d as W } from "./dash-case-DBThphLm.js";
|
|
4
|
-
import { join as o, parse as B } from "path";
|
|
5
|
-
import { existsSync as K, writeFileSync as w, mkdirSync as O, readFileSync as _, statSync as pt, readdirSync as ft } from "fs";
|
|
6
|
-
import { readFile as dt, writeFile as ut } from "fs/promises";
|
|
7
|
-
import { p as U, a as gt, b as mt, c as yt } from "./parse-templates-CgZo0YA1.js";
|
|
8
|
-
import { createLogger as ht, format as I, transports as $t } from "winston";
|
|
9
|
-
const Q = (t) => {
|
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
|
11
|
-
const e = o(t, "package.json");
|
|
12
|
-
return K(e) ? e : Q(o(t, ".."));
|
|
13
|
-
}, bt = async (t) => {
|
|
14
|
-
const e = Q(t);
|
|
15
|
-
return await dt(e, "utf-8").then(JSON.parse).catch(() => {
|
|
16
|
-
});
|
|
17
|
-
}, St = async (t) => {
|
|
18
|
-
const e = await bt(t);
|
|
19
|
-
if (e)
|
|
20
|
-
return e.type;
|
|
21
|
-
};
|
|
22
|
-
let R;
|
|
23
|
-
const tt = async (t) => {
|
|
24
|
-
if (R) return R;
|
|
25
|
-
const e = await St(t);
|
|
26
|
-
return e === "module" ? R = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (R = "cjs"), R || "esm";
|
|
27
|
-
}, z = ht({
|
|
28
|
-
level: "debug",
|
|
29
|
-
format: I.combine(I.colorize(), I.cli()),
|
|
30
|
-
transports: [new $t.Console({})]
|
|
31
|
-
}), _t = (t) => {
|
|
32
|
-
z.error(t);
|
|
33
|
-
};
|
|
34
|
-
function et(t) {
|
|
35
|
-
return t ? typeof t != "string" ? et(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, r) => (r > 0 ? "." : "") + e.toLowerCase()) : "";
|
|
36
|
-
}
|
|
37
|
-
const wt = {
|
|
38
|
-
/** Set box model to border-box */
|
|
39
|
-
"*, *::before, *::after": {
|
|
40
|
-
boxSizing: "border-box"
|
|
41
|
-
},
|
|
42
|
-
/** Remove default margin and padding */
|
|
43
|
-
"*": {
|
|
44
|
-
margin: 0
|
|
45
|
-
},
|
|
46
|
-
/** Remove adjust font properties */
|
|
47
|
-
html: {
|
|
48
|
-
lineHeight: 1.15,
|
|
49
|
-
textSizeAdjust: "100%",
|
|
50
|
-
WebkitFontSmoothing: "antialiased"
|
|
51
|
-
},
|
|
52
|
-
/** Make media elements responsive */
|
|
53
|
-
"img, picture, video, canvas, svg": {
|
|
54
|
-
display: "block",
|
|
55
|
-
maxWidth: "100%"
|
|
56
|
-
},
|
|
57
|
-
/** Avoid overflow of text */
|
|
58
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
|
59
|
-
overflowWrap: "break-word"
|
|
60
|
-
},
|
|
61
|
-
/** Improve text wrapping */
|
|
62
|
-
p: {
|
|
63
|
-
textWrap: "pretty"
|
|
64
|
-
},
|
|
65
|
-
"h1, h2, h3, h4, h5, h6": {
|
|
66
|
-
textWrap: "balance"
|
|
67
|
-
},
|
|
68
|
-
/** Improve link color */
|
|
69
|
-
a: {
|
|
70
|
-
color: "currentColor"
|
|
71
|
-
},
|
|
72
|
-
/** Improve button line height */
|
|
73
|
-
button: {
|
|
74
|
-
lineHeight: "1em",
|
|
75
|
-
color: "currentColor"
|
|
76
|
-
},
|
|
77
|
-
/** Improve form elements */
|
|
78
|
-
"input, optgroup, select, textarea": {
|
|
79
|
-
fontFamily: "inherit",
|
|
80
|
-
fontSize: "100%",
|
|
81
|
-
lineHeight: "1.15em"
|
|
82
|
-
}
|
|
83
|
-
}, A = {
|
|
84
|
-
externalModules: []
|
|
85
|
-
}, st = (t) => {
|
|
86
|
-
if (A.externalModules.length > 0) return A.externalModules;
|
|
87
|
-
const e = o(t, "salty.config.ts"), c = _(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
|
88
|
-
if (!c) return [];
|
|
89
|
-
const p = c[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
|
90
|
-
return A.externalModules = p, p;
|
|
91
|
-
}, H = (t) => o(t, "./saltygen"), nt = ["salty", "css", "styles", "styled"], xt = (t = []) => new RegExp(`\\.(${[...nt, ...t].join("|")})\\.`), L = (t, e = []) => xt(e).test(t), Ct = async (t) => {
|
|
92
|
-
const e = H(t), r = o(t, "salty.config.ts"), c = o(e, "salty.config.js"), p = await tt(t), s = st(t);
|
|
93
|
-
await Y.build({
|
|
94
|
-
entryPoints: [r],
|
|
95
|
-
minify: !0,
|
|
96
|
-
treeShaking: !0,
|
|
97
|
-
bundle: !0,
|
|
98
|
-
outfile: c,
|
|
99
|
-
format: p,
|
|
100
|
-
external: s
|
|
101
|
-
});
|
|
102
|
-
const m = Date.now(), { config: y } = await import(`${c}?t=${m}`);
|
|
103
|
-
return y;
|
|
104
|
-
}, Ft = async (t) => {
|
|
105
|
-
const e = await Ct(t), r = /* @__PURE__ */ new Set(), c = (l, d = []) => l ? Object.entries(l).flatMap(([b, u]) => {
|
|
106
|
-
if (!u) return;
|
|
107
|
-
if (typeof u == "object") return c(u, [...d, b]);
|
|
108
|
-
const M = et(b), v = W(b), N = [...d, M].join(".");
|
|
109
|
-
r.add(`"${N}"`);
|
|
110
|
-
const T = [...d.map(W), v].join("-"), { result: E } = yt(u);
|
|
111
|
-
return `--${T}: ${E};`;
|
|
112
|
-
}) : [], p = (l) => l ? Object.entries(l).flatMap(([d, b]) => {
|
|
113
|
-
const u = c(b);
|
|
114
|
-
return d === "base" ? u.join("") : `${d} { ${u.join("")} }`;
|
|
115
|
-
}) : [], s = (l) => l ? Object.entries(l).flatMap(([d, b]) => Object.entries(b).flatMap(([u, M]) => {
|
|
116
|
-
const v = c(M, [d]), N = `.${d}-${u}, [data-${d}="${u}"]`, T = v.join("");
|
|
117
|
-
return `${N} { ${T} }`;
|
|
118
|
-
})) : [], m = c(e.variables), y = p(e.responsiveVariables), k = s(e.conditionalVariables), n = H(t), a = o(n, "css/_variables.css"), f = `:root { ${m.join("")} ${y.join("")} } ${k.join("")}`;
|
|
119
|
-
w(a, f);
|
|
120
|
-
const S = o(n, "css/_global.css"), h = U(e.global, "");
|
|
121
|
-
w(S, `@layer global { ${h} }`);
|
|
122
|
-
const x = o(n, "css/_reset.css"), g = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : wt, F = U(g, "");
|
|
123
|
-
w(x, `@layer reset { ${F} }`);
|
|
124
|
-
const i = o(n, "css/_templates.css"), $ = gt(e.templates), P = mt(e.templates);
|
|
125
|
-
w(i, $);
|
|
126
|
-
const j = o(n, "types/css-tokens.d.ts"), D = `
|
|
127
|
-
// Variable types
|
|
128
|
-
type VariableTokens = ${[...r].join("|")};
|
|
129
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
130
|
-
|
|
131
|
-
// Template types
|
|
132
|
-
type TemplateTokens = {
|
|
133
|
-
${Object.entries(P).map(([l, d]) => `${l}?: ${d}`).join(`
|
|
134
|
-
`)}
|
|
135
|
-
}
|
|
136
|
-
`;
|
|
137
|
-
w(j, D);
|
|
138
|
-
}, X = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, r) => {
|
|
139
|
-
if (/^['"`]/.test(r)) return e;
|
|
140
|
-
const p = new RegExp(`import[^;]*${r}[,\\s{][^;]*from\\s?([^{};]+);`);
|
|
141
|
-
if (!p.test(t)) return e;
|
|
142
|
-
const m = p.exec(t);
|
|
143
|
-
if (m) {
|
|
144
|
-
const y = m.at(1);
|
|
145
|
-
if (nt.some((n) => y == null ? void 0 : y.includes(n))) return e;
|
|
146
|
-
}
|
|
147
|
-
return "styled('div',";
|
|
148
|
-
}), Z = async (t, e, r) => {
|
|
149
|
-
const c = J(e), p = o(r, "./temp");
|
|
150
|
-
K(p) || O(p);
|
|
151
|
-
const s = B(e);
|
|
152
|
-
let m = _(e, "utf8");
|
|
153
|
-
m = X(m);
|
|
154
|
-
const y = o(r, "js", c + ".js"), k = st(t), n = await tt(t);
|
|
155
|
-
await Y.build({
|
|
156
|
-
stdin: {
|
|
157
|
-
contents: m,
|
|
158
|
-
sourcefile: s.base,
|
|
159
|
-
resolveDir: s.dir,
|
|
160
|
-
loader: "tsx"
|
|
161
|
-
},
|
|
162
|
-
minify: !1,
|
|
163
|
-
treeShaking: !0,
|
|
164
|
-
bundle: !0,
|
|
165
|
-
outfile: y,
|
|
166
|
-
format: n,
|
|
167
|
-
target: ["node20"],
|
|
168
|
-
keepNames: !0,
|
|
169
|
-
external: k,
|
|
170
|
-
packages: "external",
|
|
171
|
-
plugins: [
|
|
172
|
-
{
|
|
173
|
-
name: "test",
|
|
174
|
-
setup: (S) => {
|
|
175
|
-
S.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (h) => {
|
|
176
|
-
const x = _(h.path, "utf8");
|
|
177
|
-
return { contents: X(x), loader: "ts" };
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
});
|
|
183
|
-
const a = Date.now();
|
|
184
|
-
return await import(`${y}?t=${a}`);
|
|
185
|
-
}, G = async (t) => {
|
|
186
|
-
const e = H(t), r = o(e, "salty.config.js"), c = Date.now(), { config: p } = await import(`${r}?t=${c}`);
|
|
187
|
-
return p;
|
|
188
|
-
}, ot = () => {
|
|
189
|
-
try {
|
|
190
|
-
return process.env.NODE_ENV === "production";
|
|
191
|
-
} catch {
|
|
192
|
-
return !1;
|
|
193
|
-
}
|
|
194
|
-
}, Mt = async (t, e = ot()) => {
|
|
195
|
-
try {
|
|
196
|
-
const r = Date.now();
|
|
197
|
-
e ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
|
|
198
|
-
const c = [], p = [], s = H(t), m = o(s, "index.css");
|
|
199
|
-
(() => {
|
|
200
|
-
K(s) && lt("rm -rf " + s), O(s), O(o(s, "css")), O(o(s, "types"));
|
|
201
|
-
})(), await Ft(t);
|
|
202
|
-
const k = await G(t);
|
|
203
|
-
async function n(i, $) {
|
|
204
|
-
const P = ["node_modules", "saltygen"], j = pt(i);
|
|
205
|
-
if (j.isDirectory()) {
|
|
206
|
-
const V = ft(i);
|
|
207
|
-
if (P.some((l) => i.includes(l))) return;
|
|
208
|
-
await Promise.all(V.map((l) => n(o(i, l), o($, l))));
|
|
209
|
-
} else if (j.isFile() && L(i)) {
|
|
210
|
-
const D = await Z(t, i, s), l = [];
|
|
211
|
-
Object.entries(D).forEach(([N, T]) => {
|
|
212
|
-
if (T.isKeyframes && T.css) {
|
|
213
|
-
const q = `a_${T.animationName}.css`, ct = `css/${q}`, it = o(s, ct);
|
|
214
|
-
c.push(q), w(it, T.css);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
if (!T.generator) return;
|
|
218
|
-
const E = T.generator._withBuildContext({
|
|
219
|
-
name: N,
|
|
220
|
-
config: k,
|
|
221
|
-
prod: e
|
|
222
|
-
});
|
|
223
|
-
p[E.priority] || (p[E.priority] = []), p[E.priority].push(E.cssFileName), l.push(E.cssFileName);
|
|
224
|
-
const rt = `css/${E.cssFileName}`, at = o(s, rt);
|
|
225
|
-
w(at, E.css);
|
|
226
|
-
});
|
|
227
|
-
const d = l.map((N) => `@import url('./${N}');`).join(`
|
|
228
|
-
`), b = J(i, 6), u = B(i), M = W(u.name), v = o(s, `css/f_${M}-${b}.css`);
|
|
229
|
-
w(v, d);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
await n(t, s);
|
|
233
|
-
const a = c.map((i) => `@import url('./css/${i}');`).join(`
|
|
234
|
-
`);
|
|
235
|
-
let x = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
236
|
-
|
|
237
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((i) => {
|
|
238
|
-
try {
|
|
239
|
-
return _(o(s, "css", i), "utf8").length > 0;
|
|
240
|
-
} catch {
|
|
241
|
-
return !1;
|
|
242
|
-
}
|
|
243
|
-
}).map((i) => `@import url('./css/${i}');`).join(`
|
|
244
|
-
`)}
|
|
245
|
-
${a}`;
|
|
246
|
-
if (k.importStrategy !== "component") {
|
|
247
|
-
const i = p.reduce(($, P, j) => {
|
|
248
|
-
const V = P.reduce((b, u) => {
|
|
249
|
-
const M = o(s, "css", u), v = _(M, "utf8"), N = J(M, 6);
|
|
250
|
-
return `${b}
|
|
251
|
-
/*start:${N}*/
|
|
252
|
-
${v}
|
|
253
|
-
/*end:${N}*/
|
|
254
|
-
`;
|
|
255
|
-
}, ""), D = `l_${j}.css`, l = o(s, "css", D), d = `@layer l${j} { ${V}
|
|
256
|
-
}`;
|
|
257
|
-
return w(l, d), `${$}
|
|
258
|
-
@import url('./css/${D}');`;
|
|
259
|
-
}, "");
|
|
260
|
-
x += i;
|
|
261
|
-
}
|
|
262
|
-
w(m, x);
|
|
263
|
-
const g = Date.now() - r, F = g < 200 ? "🔥" : g < 500 ? "🚀" : g < 1e3 ? "🎉" : g < 2e3 ? "🚗" : g < 5e3 ? "🤔" : "🥴";
|
|
264
|
-
z.info(`Generated CSS in ${g}ms! ${F}`);
|
|
265
|
-
} catch (r) {
|
|
266
|
-
console.error(r);
|
|
267
|
-
}
|
|
268
|
-
}, Vt = async (t, e) => {
|
|
269
|
-
try {
|
|
270
|
-
const r = o(t, "./saltygen"), c = o(r, "index.css");
|
|
271
|
-
if (L(e)) {
|
|
272
|
-
const s = [], m = await G(t), y = await Z(t, e, r);
|
|
273
|
-
Object.entries(y).forEach(([n, a]) => {
|
|
274
|
-
if (a.isKeyframes && a.css) {
|
|
275
|
-
const C = `css/${`a_${a.animationName}.css`}`, g = o(r, C);
|
|
276
|
-
w(g, a.css);
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
if (!a.generator) return;
|
|
280
|
-
const f = a.generator._withBuildContext({
|
|
281
|
-
name: n,
|
|
282
|
-
config: m
|
|
283
|
-
}), S = `css/${f.cssFileName}`, h = o(r, S);
|
|
284
|
-
w(h, f.css), s[f.priority] || (s[f.priority] = []), s[f.priority].push(f.cssFileName);
|
|
285
|
-
});
|
|
286
|
-
const k = _(c, "utf8").split(`
|
|
287
|
-
`);
|
|
288
|
-
m.importStrategy !== "component" && s.forEach((n, a) => {
|
|
289
|
-
const f = `l_${a}.css`, S = o(r, "css", f);
|
|
290
|
-
let h = _(S, "utf8");
|
|
291
|
-
n.forEach((x) => {
|
|
292
|
-
const C = o(r, "css", x), g = J(C, 6), F = h.includes(g);
|
|
293
|
-
if (console.log({ layer: a, filepath: C, filepathHash: g, found: F }), !F) {
|
|
294
|
-
const i = _(C, "utf8"), $ = J(C, 6), P = `/*start:${$}*/
|
|
295
|
-
${i}
|
|
296
|
-
/*end:${$}*/
|
|
297
|
-
`;
|
|
298
|
-
h = `${h.replace(/\}$/, "")}
|
|
299
|
-
${P}
|
|
300
|
-
}`;
|
|
301
|
-
}
|
|
302
|
-
}), w(S, h);
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
} catch (r) {
|
|
306
|
-
console.error(r);
|
|
307
|
-
}
|
|
308
|
-
}, vt = async (t, e, r = ot()) => {
|
|
309
|
-
try {
|
|
310
|
-
const c = o(t, "./saltygen");
|
|
311
|
-
if (L(e)) {
|
|
312
|
-
const s = _(e, "utf8");
|
|
313
|
-
s.replace(/^(?!export\s)const\s.*/gm, (a) => `export ${a}`) !== s && await ut(e, s);
|
|
314
|
-
const y = await G(t), k = await Z(t, e, c);
|
|
315
|
-
let n = s;
|
|
316
|
-
if (Object.entries(k).forEach(([a, f]) => {
|
|
317
|
-
var b;
|
|
318
|
-
if (f.isKeyframes || !f.generator) return;
|
|
319
|
-
const S = f.generator._withBuildContext({
|
|
320
|
-
name: a,
|
|
321
|
-
config: y,
|
|
322
|
-
prod: r
|
|
323
|
-
}), h = new RegExp(`\\s${a}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
|
324
|
-
if (!h) return console.error("Could not find the original declaration");
|
|
325
|
-
const x = (b = h.at(1)) == null ? void 0 : b.trim(), C = new RegExp(`\\s${a}[=\\s]+styled\\(`, "g").exec(n);
|
|
326
|
-
if (!C) return console.error("Could not find the original declaration");
|
|
327
|
-
const { index: g } = C;
|
|
328
|
-
let F = !1;
|
|
329
|
-
const i = setTimeout(() => F = !0, 5e3);
|
|
330
|
-
let $ = 0, P = !1, j = 0;
|
|
331
|
-
for (; !P && !F; ) {
|
|
332
|
-
const u = n[g + $];
|
|
333
|
-
u === "(" && j++, u === ")" && j--, j === 0 && u === ")" && (P = !0), $ > n.length && (F = !0), $++;
|
|
334
|
-
}
|
|
335
|
-
if (!F) clearTimeout(i);
|
|
336
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
|
337
|
-
const V = g + $, D = n.slice(g, V), l = n, d = ` ${a} = styled(${x}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
|
338
|
-
n = n.replace(D, d), l === n && console.error("Minimize file failed to change content", { name: a, tagName: x });
|
|
339
|
-
}), y.importStrategy === "component") {
|
|
340
|
-
const a = J(e, 6), f = B(e);
|
|
341
|
-
n = `import '../../saltygen/css/${`f_${W(f.name)}-${a}.css`}';
|
|
342
|
-
${n}`;
|
|
343
|
-
}
|
|
344
|
-
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
|
345
|
-
}
|
|
346
|
-
} catch (c) {
|
|
347
|
-
console.error("Error in minimizeFile:", c);
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
export {
|
|
351
|
-
_t as a,
|
|
352
|
-
xt as b,
|
|
353
|
-
Ft as c,
|
|
354
|
-
Z as d,
|
|
355
|
-
Vt as e,
|
|
356
|
-
Mt as g,
|
|
357
|
-
L as i,
|
|
358
|
-
z as l,
|
|
359
|
-
vt as m,
|
|
360
|
-
nt as s
|
|
361
|
-
};
|