@salty-css/core 0.0.1-alpha.134 → 0.0.1-alpha.136
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-BC_57RHS.cjs +22 -0
- package/index-CjY7a4U6.js +332 -0
- package/package.json +1 -1
- package/index-quuC8yrT.cjs +0 -21
- package/index-vfptqI3j.js +0 -318
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-BC_57RHS.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-CjY7a4U6.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-BC_57RHS.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-CjY7a4U6.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";const ce=require("esbuild"),ae=require("child_process"),R=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var H=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const G=le(ce),U=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:U(s.join(e,".."))},ue=async e=>{const t=U(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},pe=async e=>{const t=await ue(e);if(t)return t.type};let O;const X=async e=>{if(O)return O;const t=await pe(e);return t==="module"?O="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:H&&H.tagName.toUpperCase()==="SCRIPT"&&H.src||new URL("index-BC_57RHS.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},I=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{I.error(e)};function Y(e){return e?typeof e!="string"?Y(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,o)=>(o>0?".":"")+t.toLowerCase()):""}const fe={"*, *::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"}},A={externalModules:[]},Q=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),r=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!r)return[];const u=r[1].split(",").map(n=>n.replace(/['"`]/g,"").trim());return A.externalModules=u,u},J=e=>s.join(e,"./saltygen"),B=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...B,...e].join("|")})\\.`),q=(e,t=[])=>ee(t).test(e),ye=async e=>{const t=J(e),o=s.join(e,"salty.config.ts"),r=s.join(t,"salty.config.js"),u=await X(e),n=Q(e);await G.build({entryPoints:[o],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:u,external:n});const m=Date.now(),{config:b}=await import(`${r}?t=${m}`);return b},te=async e=>{const t=await ye(e),o=new Set,r=(l,p=[])=>l?Object.entries(l).flatMap(([j,d])=>{if(!d)return;if(typeof d=="object")return r(d,[...p,j]);const E=Y(j),V=R.dashCase(j),M=[...p,E].join(".");o.add(`"${M}"`);const P=[...p.map(R.dashCase),V].join("-"),{result:N}=v.parseValueTokens(d);return`--${P}: ${N};`}):[],u=l=>l?Object.entries(l).flatMap(([p,j])=>{const d=r(j);return p==="base"?d.join(""):`${p} { ${d.join("")} }`}):[],n=l=>l?Object.entries(l).flatMap(([p,j])=>Object.entries(j).flatMap(([d,E])=>{const V=r(E,[p]),M=`.${p}-${d}, [data-${p}="${d}"]`,P=V.join("");return`${M} { ${P} }`})):[],m=r(t.variables),b=u(t.responsiveVariables),x=n(t.conditionalVariables),i=J(e),f=s.join(i,"css/_variables.css"),$=`:root { ${m.join("")} ${b.join("")} } ${x.join("")}`;c.writeFileSync(f,$);const h=s.join(i,"css/_global.css"),y=v.parseStyles(t.global,"");c.writeFileSync(h,`@layer global { ${y} }`);const F=s.join(i,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,w=v.parseStyles(g,"");c.writeFileSync(F,`@layer reset { ${w} }`);const a=s.join(i,"css/_templates.css"),S=v.parseTemplates(t.templates),k=v.getTemplateTypes(t.templates);c.writeFileSync(a,S);const C=s.join(i,"types/css-tokens.d.ts"),D=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...o].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(k).map(([l,p])=>`${l}?: ${p}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;c.writeFileSync(C,D)},W=async(e,t,o)=>{const r=R.toHash(t),u=s.join(o,"./temp");c.existsSync(u)||c.mkdirSync(u);const n=s.parse(t);let m=c.readFileSync(t,"utf8");m=m.replace(/styled\(([^"'`{,]+),/g,(h,y)=>{if(/^['"`]/.test(y))return h;const T=new RegExp(`import\\s?\\{[^{}]*${y}[^{}]*\\}\\s?from\\s?([^{};]+);`);if(!T.test(m))return h;const w=T.exec(m);if(w){const a=w.at(1);if(B.some(k=>a==null?void 0:a.includes(k)))return h}return"styled('div',"});const b=s.join(o,"js",r+".js"),x=Q(e),i=await X(e);await G.build({stdin:{contents:m,sourcefile:n.base,resolveDir:n.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:b,format:i,target:["node20"],keepNames:!0,external:x,packages:"external"});const f=Date.now();return await import(`${b}?t=${f}`)},K=async e=>{const t=J(e),o=s.join(t,"salty.config.js"),r=Date.now(),{config:u}=await import(`${o}?t=${r}`);return u},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ge=async(e,t=se())=>{try{const o=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const r=[],u=[],n=J(e),m=s.join(n,"index.css");(()=>{c.existsSync(n)&&ae.execSync("rm -rf "+n),c.mkdirSync(n),c.mkdirSync(s.join(n,"css")),c.mkdirSync(s.join(n,"types"))})(),await te(e);const x=await K(e);async function i(a,S){const k=["node_modules","saltygen"],C=c.statSync(a);if(C.isDirectory()){const _=c.readdirSync(a);if(k.some(l=>a.includes(l)))return;await Promise.all(_.map(l=>i(s.join(a,l),s.join(S,l))))}else if(C.isFile()&&q(a)){const D=await W(e,a,n),l=[];Object.entries(D).forEach(([M,P])=>{if(P.isKeyframes&&P.css){const L=`a_${P.animationName}.css`,re=`css/${L}`,ie=s.join(n,re);r.push(L),c.writeFileSync(ie,P.css);return}if(!P.generator)return;const N=P.generator._withBuildContext({name:M,config:x,prod:t});u[N.priority]||(u[N.priority]=[]),u[N.priority].push(N.cssFileName),l.push(N.cssFileName);const ne=`css/${N.cssFileName}`,oe=s.join(n,ne);c.writeFileSync(oe,N.css)});const p=l.map(M=>`@import url('./${M}');`).join(`
|
12
|
+
`),j=R.toHash(a,6),d=s.parse(a),E=R.dashCase(d.name),V=s.join(n,`css/f_${E}-${j}.css`);c.writeFileSync(V,p)}}await i(e,n);const f=r.map(a=>`@import url('./css/${a}');`).join(`
|
13
|
+
`);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
+
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return c.readFileSync(s.join(n,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
|
16
|
+
`)}
|
17
|
+
${f}`;if(x.importStrategy!=="component"){const a=u.reduce((S,k,C)=>{const _=k.reduce((j,d)=>{const E=c.readFileSync(s.join(n,"css",d),"utf8");return`${j}
|
18
|
+
${E}`},""),D=`l_${C}.css`,l=s.join(n,"css",D),p=`@layer l${C} { ${_} }`;return c.writeFileSync(l,p),`${S}
|
19
|
+
@import url('./css/${D}');`},"");F+=a}c.writeFileSync(m,F);const g=Date.now()-o,w=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";I.info(`Generated CSS in ${g}ms! ${w}`)}catch(o){console.error(o)}},me=async(e,t)=>{try{const o=[],r=s.join(e,"./saltygen"),u=s.join(r,"index.css");if(q(t)){const m=await K(e),b=await W(e,t,r);Object.entries(b).forEach(([h,y])=>{if(y.isKeyframes&&y.css){const a=`css/${`a_${y.animationName}.css`}`,S=s.join(r,a);c.writeFileSync(S,y.css);return}if(!y.generator)return;const F=y.generator._withBuildContext({name:h,config:m}),T=`css/${F.cssFileName}`,g=s.join(r,T);o.push(F.cssFileName),c.writeFileSync(g,F.css)});const x=c.readFileSync(u,"utf8").split(`
|
20
|
+
`),i=o.map(h=>`@import url('../saltygen/css/${h}');`),$=[...new Set([...x,...i])].join(`
|
21
|
+
`);c.writeFileSync(u,$)}}catch(o){console.error(o)}},he=async(e,t,o=se())=>{try{const r=s.join(e,"./saltygen");if(q(t)){const n=c.readFileSync(t,"utf8");n.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==n&&await Z.writeFile(t,n);const b=await K(e),x=await W(e,t,r);let i=n;if(Object.entries(x).forEach(([f,$])=>{var j;if($.isKeyframes||!$.generator)return;const h=$.generator._withBuildContext({name:f,config:b,prod:o}),y=new RegExp(`\\s${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(n);if(!y)return console.error("Could not find the original declaration");const F=(j=y.at(1))==null?void 0:j.trim(),T=new RegExp(`\\s${f}[=\\s]+styled\\(`,"g").exec(i);if(!T)return console.error("Could not find the original declaration");const{index:g}=T;let w=!1;const a=setTimeout(()=>w=!0,5e3);let S=0,k=!1,C=0;for(;!k&&!w;){const d=i[g+S];d==="("&&C++,d===")"&&C--,C===0&&d===")"&&(k=!0),S>i.length&&(w=!0),S++}if(!w)clearTimeout(a);else throw new Error("Failed to find the end of the styled call and timed out");const _=g+S,D=i.slice(g,_),l=i,p=` ${f} = styled(${F}, "${h.classNames}", ${JSON.stringify(h.props)});`;i=i.replace(D,p),l===i&&console.error("Minimize file failed to change content",{name:f,tagName:F})}),b.importStrategy==="component"){const f=R.toHash(t,6),$=s.parse(t);i=`import '../../saltygen/css/${`f_${R.dashCase($.name)}-${f}.css`}';
|
22
|
+
${i}`}return i=i.replace("{ styled }","{ styledClient as styled }"),i=i.replace("@salty-css/react/styled","@salty-css/react/styled-client"),i}}catch(r){console.error("Error in minimizeFile:",r)}};exports.compileSaltyFile=W;exports.generateConfigStyles=te;exports.generateCss=ge;exports.generateFile=me;exports.isSaltyFile=q;exports.logError=de;exports.logger=I;exports.minimizeFile=he;exports.saltyFileExtensions=B;exports.saltyFileRegExp=ee;
|
@@ -0,0 +1,332 @@
|
|
1
|
+
import * as X from "esbuild";
|
2
|
+
import { execSync as it } from "child_process";
|
3
|
+
import { t as B, d as z } from "./dash-case-DBThphLm.js";
|
4
|
+
import { join as n, parse as H } from "path";
|
5
|
+
import { existsSync as K, writeFileSync as b, mkdirSync as J, readFileSync as v, statSync as lt, readdirSync as pt } from "fs";
|
6
|
+
import { readFile as ft, writeFile as ut } from "fs/promises";
|
7
|
+
import { p as U, a as dt, b as gt, c as mt } from "./parse-templates-CgZo0YA1.js";
|
8
|
+
import { createLogger as yt, format as W, transports as ht } from "winston";
|
9
|
+
const Y = (t) => {
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
+
const e = n(t, "package.json");
|
12
|
+
return K(e) ? e : Y(n(t, ".."));
|
13
|
+
}, $t = async (t) => {
|
14
|
+
const e = Y(t);
|
15
|
+
return await ft(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
+
});
|
17
|
+
}, bt = async (t) => {
|
18
|
+
const e = await $t(t);
|
19
|
+
if (e)
|
20
|
+
return e.type;
|
21
|
+
};
|
22
|
+
let V;
|
23
|
+
const Q = async (t) => {
|
24
|
+
if (V) return V;
|
25
|
+
const e = await bt(t);
|
26
|
+
return e === "module" ? V = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (V = "cjs"), V || "esm";
|
27
|
+
}, O = yt({
|
28
|
+
level: "debug",
|
29
|
+
format: W.combine(W.colorize(), W.cli()),
|
30
|
+
transports: [new ht.Console({})]
|
31
|
+
}), Et = (t) => {
|
32
|
+
O.error(t);
|
33
|
+
};
|
34
|
+
function tt(t) {
|
35
|
+
return t ? typeof t != "string" ? tt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, c) => (c > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
+
}
|
37
|
+
const St = {
|
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
|
+
}, et = (t) => {
|
86
|
+
if (A.externalModules.length > 0) return A.externalModules;
|
87
|
+
const e = n(t, "salty.config.ts"), r = v(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
88
|
+
if (!r) return [];
|
89
|
+
const l = r[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
90
|
+
return A.externalModules = l, l;
|
91
|
+
}, I = (t) => n(t, "./saltygen"), st = ["salty", "css", "styles", "styled"], wt = (t = []) => new RegExp(`\\.(${[...st, ...t].join("|")})\\.`), Z = (t, e = []) => wt(e).test(t), xt = async (t) => {
|
92
|
+
const e = I(t), c = n(t, "salty.config.ts"), r = n(e, "salty.config.js"), l = await Q(t), s = et(t);
|
93
|
+
await X.build({
|
94
|
+
entryPoints: [c],
|
95
|
+
minify: !0,
|
96
|
+
treeShaking: !0,
|
97
|
+
bundle: !0,
|
98
|
+
outfile: r,
|
99
|
+
format: l,
|
100
|
+
external: s
|
101
|
+
});
|
102
|
+
const m = Date.now(), { config: S } = await import(`${r}?t=${m}`);
|
103
|
+
return S;
|
104
|
+
}, Ft = async (t) => {
|
105
|
+
const e = await xt(t), c = /* @__PURE__ */ new Set(), r = (i, p = []) => i ? Object.entries(i).flatMap(([$, f]) => {
|
106
|
+
if (!f) return;
|
107
|
+
if (typeof f == "object") return r(f, [...p, $]);
|
108
|
+
const M = tt($), R = z($), _ = [...p, M].join(".");
|
109
|
+
c.add(`"${_}"`);
|
110
|
+
const P = [...p.map(z), R].join("-"), { result: T } = mt(f);
|
111
|
+
return `--${P}: ${T};`;
|
112
|
+
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, $]) => {
|
113
|
+
const f = r($);
|
114
|
+
return p === "base" ? f.join("") : `${p} { ${f.join("")} }`;
|
115
|
+
}) : [], s = (i) => i ? Object.entries(i).flatMap(([p, $]) => Object.entries($).flatMap(([f, M]) => {
|
116
|
+
const R = r(M, [p]), _ = `.${p}-${f}, [data-${p}="${f}"]`, P = R.join("");
|
117
|
+
return `${_} { ${P} }`;
|
118
|
+
})) : [], m = r(e.variables), S = l(e.responsiveVariables), j = s(e.conditionalVariables), o = I(t), u = n(o, "css/_variables.css"), F = `:root { ${m.join("")} ${S.join("")} } ${j.join("")}`;
|
119
|
+
b(u, F);
|
120
|
+
const y = n(o, "css/_global.css"), d = U(e.global, "");
|
121
|
+
b(y, `@layer global { ${d} }`);
|
122
|
+
const w = n(o, "css/_reset.css"), g = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : St, x = U(g, "");
|
123
|
+
b(w, `@layer reset { ${x} }`);
|
124
|
+
const a = n(o, "css/_templates.css"), h = dt(e.templates), k = gt(e.templates);
|
125
|
+
b(a, h);
|
126
|
+
const C = n(o, "types/css-tokens.d.ts"), N = `
|
127
|
+
// Variable types
|
128
|
+
type VariableTokens = ${[...c].join("|")};
|
129
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
130
|
+
|
131
|
+
// Template types
|
132
|
+
type TemplateTokens = {
|
133
|
+
${Object.entries(k).map(([i, p]) => `${i}?: ${p}`).join(`
|
134
|
+
`)}
|
135
|
+
}
|
136
|
+
`;
|
137
|
+
b(C, N);
|
138
|
+
}, G = async (t, e, c) => {
|
139
|
+
const r = B(e), l = n(c, "./temp");
|
140
|
+
K(l) || J(l);
|
141
|
+
const s = H(e);
|
142
|
+
let m = v(e, "utf8");
|
143
|
+
m = m.replace(/styled\(([^"'`{,]+),/g, (y, d) => {
|
144
|
+
if (/^['"`]/.test(d)) return y;
|
145
|
+
const D = new RegExp(`import\\s?\\{[^{}]*${d}[^{}]*\\}\\s?from\\s?([^{};]+);`);
|
146
|
+
if (!D.test(m)) return y;
|
147
|
+
const x = D.exec(m);
|
148
|
+
if (x) {
|
149
|
+
const a = x.at(1);
|
150
|
+
if (st.some((k) => a == null ? void 0 : a.includes(k))) return y;
|
151
|
+
}
|
152
|
+
return "styled('div',";
|
153
|
+
});
|
154
|
+
const S = n(c, "js", r + ".js"), j = et(t), o = await Q(t);
|
155
|
+
await X.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: S,
|
166
|
+
format: o,
|
167
|
+
target: ["node20"],
|
168
|
+
keepNames: !0,
|
169
|
+
external: j,
|
170
|
+
packages: "external"
|
171
|
+
});
|
172
|
+
const u = Date.now();
|
173
|
+
return await import(`${S}?t=${u}`);
|
174
|
+
}, L = async (t) => {
|
175
|
+
const e = I(t), c = n(e, "salty.config.js"), r = Date.now(), { config: l } = await import(`${c}?t=${r}`);
|
176
|
+
return l;
|
177
|
+
}, nt = () => {
|
178
|
+
try {
|
179
|
+
return process.env.NODE_ENV === "production";
|
180
|
+
} catch {
|
181
|
+
return !1;
|
182
|
+
}
|
183
|
+
}, Mt = async (t, e = nt()) => {
|
184
|
+
try {
|
185
|
+
const c = Date.now();
|
186
|
+
e ? O.info("Generating CSS in production mode! 🔥") : O.info("Generating CSS in development mode! 🚀");
|
187
|
+
const r = [], l = [], s = I(t), m = n(s, "index.css");
|
188
|
+
(() => {
|
189
|
+
K(s) && it("rm -rf " + s), J(s), J(n(s, "css")), J(n(s, "types"));
|
190
|
+
})(), await Ft(t);
|
191
|
+
const j = await L(t);
|
192
|
+
async function o(a, h) {
|
193
|
+
const k = ["node_modules", "saltygen"], C = lt(a);
|
194
|
+
if (C.isDirectory()) {
|
195
|
+
const E = pt(a);
|
196
|
+
if (k.some((i) => a.includes(i))) return;
|
197
|
+
await Promise.all(E.map((i) => o(n(a, i), n(h, i))));
|
198
|
+
} else if (C.isFile() && Z(a)) {
|
199
|
+
const N = await G(t, a, s), i = [];
|
200
|
+
Object.entries(N).forEach(([_, P]) => {
|
201
|
+
if (P.isKeyframes && P.css) {
|
202
|
+
const q = `a_${P.animationName}.css`, at = `css/${q}`, ct = n(s, at);
|
203
|
+
r.push(q), b(ct, P.css);
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
if (!P.generator) return;
|
207
|
+
const T = P.generator._withBuildContext({
|
208
|
+
name: _,
|
209
|
+
config: j,
|
210
|
+
prod: e
|
211
|
+
});
|
212
|
+
l[T.priority] || (l[T.priority] = []), l[T.priority].push(T.cssFileName), i.push(T.cssFileName);
|
213
|
+
const ot = `css/${T.cssFileName}`, rt = n(s, ot);
|
214
|
+
b(rt, T.css);
|
215
|
+
});
|
216
|
+
const p = i.map((_) => `@import url('./${_}');`).join(`
|
217
|
+
`), $ = B(a, 6), f = H(a), M = z(f.name), R = n(s, `css/f_${M}-${$}.css`);
|
218
|
+
b(R, p);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
await o(t, s);
|
222
|
+
const u = r.map((a) => `@import url('./css/${a}');`).join(`
|
223
|
+
`);
|
224
|
+
let w = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
225
|
+
|
226
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((a) => {
|
227
|
+
try {
|
228
|
+
return v(n(s, "css", a), "utf8").length > 0;
|
229
|
+
} catch {
|
230
|
+
return !1;
|
231
|
+
}
|
232
|
+
}).map((a) => `@import url('./css/${a}');`).join(`
|
233
|
+
`)}
|
234
|
+
${u}`;
|
235
|
+
if (j.importStrategy !== "component") {
|
236
|
+
const a = l.reduce((h, k, C) => {
|
237
|
+
const E = k.reduce(($, f) => {
|
238
|
+
const M = v(n(s, "css", f), "utf8");
|
239
|
+
return `${$}
|
240
|
+
${M}`;
|
241
|
+
}, ""), N = `l_${C}.css`, i = n(s, "css", N), p = `@layer l${C} { ${E} }`;
|
242
|
+
return b(i, p), `${h}
|
243
|
+
@import url('./css/${N}');`;
|
244
|
+
}, "");
|
245
|
+
w += a;
|
246
|
+
}
|
247
|
+
b(m, w);
|
248
|
+
const g = Date.now() - c, x = g < 200 ? "🔥" : g < 500 ? "🚀" : g < 1e3 ? "🎉" : g < 2e3 ? "🚗" : g < 5e3 ? "🤔" : "🥴";
|
249
|
+
O.info(`Generated CSS in ${g}ms! ${x}`);
|
250
|
+
} catch (c) {
|
251
|
+
console.error(c);
|
252
|
+
}
|
253
|
+
}, _t = async (t, e) => {
|
254
|
+
try {
|
255
|
+
const c = [], r = n(t, "./saltygen"), l = n(r, "index.css");
|
256
|
+
if (Z(e)) {
|
257
|
+
const m = await L(t), S = await G(t, e, r);
|
258
|
+
Object.entries(S).forEach(([y, d]) => {
|
259
|
+
if (d.isKeyframes && d.css) {
|
260
|
+
const a = `css/${`a_${d.animationName}.css`}`, h = n(r, a);
|
261
|
+
b(h, d.css);
|
262
|
+
return;
|
263
|
+
}
|
264
|
+
if (!d.generator) return;
|
265
|
+
const w = d.generator._withBuildContext({
|
266
|
+
name: y,
|
267
|
+
config: m
|
268
|
+
}), D = `css/${w.cssFileName}`, g = n(r, D);
|
269
|
+
c.push(w.cssFileName), b(g, w.css);
|
270
|
+
});
|
271
|
+
const j = v(l, "utf8").split(`
|
272
|
+
`), o = c.map((y) => `@import url('../saltygen/css/${y}');`), F = [.../* @__PURE__ */ new Set([...j, ...o])].join(`
|
273
|
+
`);
|
274
|
+
b(l, F);
|
275
|
+
}
|
276
|
+
} catch (c) {
|
277
|
+
console.error(c);
|
278
|
+
}
|
279
|
+
}, Vt = async (t, e, c = nt()) => {
|
280
|
+
try {
|
281
|
+
const r = n(t, "./saltygen");
|
282
|
+
if (Z(e)) {
|
283
|
+
const s = v(e, "utf8");
|
284
|
+
s.replace(/^(?!export\s)const\s.*/gm, (u) => `export ${u}`) !== s && await ut(e, s);
|
285
|
+
const S = await L(t), j = await G(t, e, r);
|
286
|
+
let o = s;
|
287
|
+
if (Object.entries(j).forEach(([u, F]) => {
|
288
|
+
var $;
|
289
|
+
if (F.isKeyframes || !F.generator) return;
|
290
|
+
const y = F.generator._withBuildContext({
|
291
|
+
name: u,
|
292
|
+
config: S,
|
293
|
+
prod: c
|
294
|
+
}), d = new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
295
|
+
if (!d) return console.error("Could not find the original declaration");
|
296
|
+
const w = ($ = d.at(1)) == null ? void 0 : $.trim(), D = new RegExp(`\\s${u}[=\\s]+styled\\(`, "g").exec(o);
|
297
|
+
if (!D) return console.error("Could not find the original declaration");
|
298
|
+
const { index: g } = D;
|
299
|
+
let x = !1;
|
300
|
+
const a = setTimeout(() => x = !0, 5e3);
|
301
|
+
let h = 0, k = !1, C = 0;
|
302
|
+
for (; !k && !x; ) {
|
303
|
+
const f = o[g + h];
|
304
|
+
f === "(" && C++, f === ")" && C--, C === 0 && f === ")" && (k = !0), h > o.length && (x = !0), h++;
|
305
|
+
}
|
306
|
+
if (!x) clearTimeout(a);
|
307
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
308
|
+
const E = g + h, N = o.slice(g, E), i = o, p = ` ${u} = styled(${w}, "${y.classNames}", ${JSON.stringify(y.props)});`;
|
309
|
+
o = o.replace(N, p), i === o && console.error("Minimize file failed to change content", { name: u, tagName: w });
|
310
|
+
}), S.importStrategy === "component") {
|
311
|
+
const u = B(e, 6), F = H(e);
|
312
|
+
o = `import '../../saltygen/css/${`f_${z(F.name)}-${u}.css`}';
|
313
|
+
${o}`;
|
314
|
+
}
|
315
|
+
return o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
316
|
+
}
|
317
|
+
} catch (r) {
|
318
|
+
console.error("Error in minimizeFile:", r);
|
319
|
+
}
|
320
|
+
};
|
321
|
+
export {
|
322
|
+
Et as a,
|
323
|
+
wt as b,
|
324
|
+
Ft as c,
|
325
|
+
G as d,
|
326
|
+
_t as e,
|
327
|
+
Mt as g,
|
328
|
+
Z as i,
|
329
|
+
O as l,
|
330
|
+
Vt as m,
|
331
|
+
st as s
|
332
|
+
};
|
package/package.json
CHANGED
package/index-quuC8yrT.cjs
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";const ce=require("esbuild"),ae=require("child_process"),E=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),R=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var I=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const G=le(ce),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:L(s.join(e,".."))},pe=async e=>{const t=L(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let O;const U=async e=>{if(O)return O;const t=await ue(e);return t==="module"?O="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-quuC8yrT.cjs",document.baseURI).href).endsWith(".cjs"))&&(O="cjs"),O||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{J.error(e)};function X(e){return e?typeof e!="string"?X(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 fe={"*, *::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"}},A={externalModules:[]},Y=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),o=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const p=o[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return A.externalModules=p,p},q=e=>s.join(e,"./saltygen"),Q=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...Q,...e].join("|")})\\.`),W=(e,t=[])=>ee(t).test(e),ye=async e=>{const t=q(e),n=s.join(e,"salty.config.ts"),o=s.join(t,"salty.config.js"),p=await U(e),r=Y(e);await G.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:p,external:r});const h=Date.now(),{config:S}=await import(`${o}?t=${h}`);return S},te=async e=>{const t=await ye(e),n=new Set,o=(l,d=[])=>l?Object.entries(l).flatMap(([b,f])=>{if(!f)return;if(typeof f=="object")return o(f,[...d,b]);const V=X(b),v=E.dashCase(b),_=[...d,V].join(".");n.add(`"${_}"`);const x=[...d.map(E.dashCase),v].join("-"),{result:P}=R.parseValueTokens(f);return`--${x}: ${P};`}):[],p=l=>l?Object.entries(l).flatMap(([d,b])=>{const f=o(b);return d==="base"?f.join(""):`${d} { ${f.join("")} }`}):[],r=l=>l?Object.entries(l).flatMap(([d,b])=>Object.entries(b).flatMap(([f,V])=>{const v=o(V,[d]),_=`.${d}-${f}, [data-${d}="${f}"]`,x=v.join("");return`${_} { ${x} }`})):[],h=o(t.variables),S=p(t.responsiveVariables),w=r(t.conditionalVariables),i=q(e),u=s.join(i,"css/_variables.css"),j=`:root { ${h.join("")} ${S.join("")} } ${w.join("")}`;c.writeFileSync(u,j);const $=s.join(i,"css/_global.css"),g=R.parseStyles(t.global,"");c.writeFileSync($,`@layer global { ${g} }`);const F=s.join(i,"css/_reset.css"),y=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,k=R.parseStyles(y,"");c.writeFileSync(F,`@layer reset { ${k} }`);const a=s.join(i,"css/_templates.css"),m=R.parseTemplates(t.templates),T=R.getTemplateTypes(t.templates);c.writeFileSync(a,m);const C=s.join(i,"types/css-tokens.d.ts"),D=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...n].join("|")};
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
-
|
6
|
-
// Template types
|
7
|
-
type TemplateTokens = {
|
8
|
-
${Object.entries(T).map(([l,d])=>`${l}?: ${d}`).join(`
|
9
|
-
`)}
|
10
|
-
}
|
11
|
-
`;c.writeFileSync(C,D)},H=async(e,t,n)=>{const o=E.toHash(t),p=s.join(n,"./temp");c.existsSync(p)||c.mkdirSync(p);const r=s.parse(t);let h=c.readFileSync(t,"utf8");h=h.replace(/styled\([^"'`{,]+,/g,"styled('div',");const S=s.join(n,"js",o+".js"),w=Y(e),i=await U(e);await G.build({stdin:{contents:h,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:i,target:["node20"],keepNames:!0,external:w,packages:"external"});const u=Date.now();return await import(`${S}?t=${u}`)},B=async e=>{const t=q(e),n=s.join(t,"salty.config.js"),o=Date.now(),{config:p}=await import(`${n}?t=${o}`);return p},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ge=async(e,t=se())=>{try{const n=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const o=[],p=[],r=q(e),h=s.join(r,"index.css");(()=>{c.existsSync(r)&&ae.execSync("rm -rf "+r),c.mkdirSync(r),c.mkdirSync(s.join(r,"css")),c.mkdirSync(s.join(r,"types"))})(),await te(e);const w=await B(e);async function i(a,m){const T=["node_modules","saltygen"],C=c.statSync(a);if(C.isDirectory()){const N=c.readdirSync(a);if(T.some(l=>a.includes(l)))return;await Promise.all(N.map(l=>i(s.join(a,l),s.join(m,l))))}else if(C.isFile()&&W(a)){const D=await H(e,a,r),l=[];Object.entries(D).forEach(([_,x])=>{if(x.isKeyframes&&x.css){const K=`a_${x.animationName}.css`,re=`css/${K}`,ie=s.join(r,re);o.push(K),c.writeFileSync(ie,x.css);return}if(!x.generator)return;const P=x.generator._withBuildContext({name:_,config:w,prod:t});p[P.priority]||(p[P.priority]=[]),p[P.priority].push(P.cssFileName),l.push(P.cssFileName);const ne=`css/${P.cssFileName}`,oe=s.join(r,ne);c.writeFileSync(oe,P.css)});const d=l.map(_=>`@import url('./${_}');`).join(`
|
12
|
-
`),b=E.toHash(a,6),f=s.parse(a),V=E.dashCase(f.name),v=s.join(r,`css/f_${V}-${b}.css`);c.writeFileSync(v,d)}}await i(e,r);const u=o.map(a=>`@import url('./css/${a}');`).join(`
|
13
|
-
`);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return c.readFileSync(s.join(r,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
|
16
|
-
`)}
|
17
|
-
${u}`;if(w.importStrategy!=="component"){const a=p.reduce((m,T,C)=>{const N=T.reduce((D,l)=>D+`@import url('./css/${l}') layer(l${C});`,"");return`${m}
|
18
|
-
${N}`},"");F+=a}c.writeFileSync(h,F);const y=Date.now()-n,k=y<200?"🔥":y<500?"🚀":y<1e3?"🎉":y<2e3?"🚗":y<5e3?"🤔":"🥴";J.info(`Generated CSS in ${y}ms! ${k}`)}catch(n){console.error(n)}},me=async(e,t)=>{try{const n=[],o=s.join(e,"./saltygen"),p=s.join(o,"index.css");if(W(t)){const h=await B(e),S=await H(e,t,o);Object.entries(S).forEach(([$,g])=>{if(g.isKeyframes&&g.css){const a=`css/${`a_${g.animationName}.css`}`,m=s.join(o,a);c.writeFileSync(m,g.css);return}if(!g.generator)return;const F=g.generator._withBuildContext({name:$,config:h}),M=`css/${F.cssFileName}`,y=s.join(o,M);n.push(F.cssFileName),c.writeFileSync(y,F.css)});const w=c.readFileSync(p,"utf8").split(`
|
19
|
-
`),i=n.map($=>`@import url('../saltygen/css/${$}');`),j=[...new Set([...w,...i])].join(`
|
20
|
-
`);c.writeFileSync(p,j)}}catch(n){console.error(n)}},he=async(e,t,n=se())=>{try{const o=s.join(e,"./saltygen");if(W(t)){const r=c.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==r&&await Z.writeFile(t,r);const S=await B(e),w=await H(e,t,o);let i=r;if(Object.entries(w).forEach(([u,j])=>{var b;if(j.isKeyframes||!j.generator)return;const $=j.generator._withBuildContext({name:u,config:S,prod:n}),g=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!g)return console.error("Could not find the original declaration");const F=(b=g.at(1))==null?void 0:b.trim(),M=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(i);if(!M)return console.error("Could not find the original declaration");const{index:y}=M;let k=!1;const a=setTimeout(()=>k=!0,5e3);let m=0,T=!1,C=0;for(;!T&&!k;){const f=i[y+m];f==="("&&C++,f===")"&&C--,C===0&&f===")"&&(T=!0),m>i.length&&(k=!0),m++}if(!k)clearTimeout(a);else throw new Error("Failed to find the end of the styled call and timed out");const N=y+m,D=i.slice(y,N),l=i,d=` ${u} = styled(${F}, "${$.classNames}", ${JSON.stringify($.props)});`;i=i.replace(D,d),l===i&&console.error("Minimize file failed to change content",{name:u,tagName:F})}),S.importStrategy==="component"){const u=E.toHash(t,6),j=s.parse(t);i=`import '../../saltygen/css/${`f_${E.dashCase(j.name)}-${u}.css`}';
|
21
|
-
${i}`}return i=i.replace("{ styled }","{ styledClient as styled }"),i=i.replace("@salty-css/react/styled","@salty-css/react/styled-client"),i}}catch(o){console.error("Error in minimizeFile:",o)}};exports.compileSaltyFile=H;exports.generateConfigStyles=te;exports.generateCss=ge;exports.generateFile=me;exports.isSaltyFile=W;exports.logError=de;exports.logger=J;exports.minimizeFile=he;exports.saltyFileExtensions=Q;exports.saltyFileRegExp=ee;
|
package/index-vfptqI3j.js
DELETED
@@ -1,318 +0,0 @@
|
|
1
|
-
import * as X from "esbuild";
|
2
|
-
import { execSync as ce } from "child_process";
|
3
|
-
import { t as H, d as R } from "./dash-case-DBThphLm.js";
|
4
|
-
import { join as o, parse as I } from "path";
|
5
|
-
import { existsSync as K, writeFileSync as $, mkdirSync as O, readFileSync as J, statSync as ie, readdirSync as le } from "fs";
|
6
|
-
import { readFile as pe, writeFile as fe } from "fs/promises";
|
7
|
-
import { p as U, a as de, b as ue, c as ge } from "./parse-templates-CgZo0YA1.js";
|
8
|
-
import { createLogger as me, format as A, transports as ye } from "winston";
|
9
|
-
const Y = (e) => {
|
10
|
-
if (!e || e === "/") throw new Error("Could not find package.json file");
|
11
|
-
const t = o(e, "package.json");
|
12
|
-
return K(t) ? t : Y(o(e, ".."));
|
13
|
-
}, he = async (e) => {
|
14
|
-
const t = Y(e);
|
15
|
-
return await pe(t, "utf-8").then(JSON.parse).catch(() => {
|
16
|
-
});
|
17
|
-
}, be = async (e) => {
|
18
|
-
const t = await he(e);
|
19
|
-
if (t)
|
20
|
-
return t.type;
|
21
|
-
};
|
22
|
-
let E;
|
23
|
-
const Q = async (e) => {
|
24
|
-
if (E) return E;
|
25
|
-
const t = await be(e);
|
26
|
-
return t === "module" ? E = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (E = "cjs"), E || "esm";
|
27
|
-
}, z = me({
|
28
|
-
level: "debug",
|
29
|
-
format: A.combine(A.colorize(), A.cli()),
|
30
|
-
transports: [new ye.Console({})]
|
31
|
-
}), Me = (e) => {
|
32
|
-
z.error(e);
|
33
|
-
};
|
34
|
-
function ee(e) {
|
35
|
-
return e ? typeof e != "string" ? ee(String(e)) : e.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, a) => (a > 0 ? "." : "") + t.toLowerCase()) : "";
|
36
|
-
}
|
37
|
-
const $e = {
|
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
|
-
}, te = (e) => {
|
86
|
-
if (B.externalModules.length > 0) return B.externalModules;
|
87
|
-
const t = o(e, "salty.config.ts"), r = J(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
88
|
-
if (!r) return [];
|
89
|
-
const l = r[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
90
|
-
return B.externalModules = l, l;
|
91
|
-
}, W = (e) => o(e, "./saltygen"), we = ["salty", "css", "styles", "styled"], Se = (e = []) => new RegExp(`\\.(${[...we, ...e].join("|")})\\.`), Z = (e, t = []) => Se(t).test(e), Fe = async (e) => {
|
92
|
-
const t = W(e), a = o(e, "salty.config.ts"), r = o(t, "salty.config.js"), l = await Q(e), s = te(e);
|
93
|
-
await X.build({
|
94
|
-
entryPoints: [a],
|
95
|
-
minify: !0,
|
96
|
-
treeShaking: !0,
|
97
|
-
bundle: !0,
|
98
|
-
outfile: r,
|
99
|
-
format: l,
|
100
|
-
external: s
|
101
|
-
});
|
102
|
-
const y = Date.now(), { config: h } = await import(`${r}?t=${y}`);
|
103
|
-
return h;
|
104
|
-
}, xe = async (e) => {
|
105
|
-
const t = await Fe(e), a = /* @__PURE__ */ new Set(), r = (i, f = []) => i ? Object.entries(i).flatMap(([b, d]) => {
|
106
|
-
if (!d) return;
|
107
|
-
if (typeof d == "object") return r(d, [...f, b]);
|
108
|
-
const V = ee(b), v = R(b), M = [...f, V].join(".");
|
109
|
-
a.add(`"${M}"`);
|
110
|
-
const j = [...f.map(R), v].join("-"), { result: P } = ge(d);
|
111
|
-
return `--${j}: ${P};`;
|
112
|
-
}) : [], l = (i) => i ? Object.entries(i).flatMap(([f, b]) => {
|
113
|
-
const d = r(b);
|
114
|
-
return f === "base" ? d.join("") : `${f} { ${d.join("")} }`;
|
115
|
-
}) : [], s = (i) => i ? Object.entries(i).flatMap(([f, b]) => Object.entries(b).flatMap(([d, V]) => {
|
116
|
-
const v = r(V, [f]), M = `.${f}-${d}, [data-${f}="${d}"]`, j = v.join("");
|
117
|
-
return `${M} { ${j} }`;
|
118
|
-
})) : [], y = r(t.variables), h = l(t.responsiveVariables), F = s(t.conditionalVariables), n = W(e), p = o(n, "css/_variables.css"), w = `:root { ${y.join("")} ${h.join("")} } ${F.join("")}`;
|
119
|
-
$(p, w);
|
120
|
-
const x = o(n, "css/_global.css"), g = U(t.global, "");
|
121
|
-
$(x, `@layer global { ${g} }`);
|
122
|
-
const S = o(n, "css/_reset.css"), u = t.reset === "none" ? {} : typeof t.reset == "object" ? t.reset : $e, k = U(u, "");
|
123
|
-
$(S, `@layer reset { ${k} }`);
|
124
|
-
const c = o(n, "css/_templates.css"), m = de(t.templates), D = ue(t.templates);
|
125
|
-
$(c, m);
|
126
|
-
const C = o(n, "types/css-tokens.d.ts"), T = `
|
127
|
-
// Variable types
|
128
|
-
type VariableTokens = ${[...a].join("|")};
|
129
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
130
|
-
|
131
|
-
// Template types
|
132
|
-
type TemplateTokens = {
|
133
|
-
${Object.entries(D).map(([i, f]) => `${i}?: ${f}`).join(`
|
134
|
-
`)}
|
135
|
-
}
|
136
|
-
`;
|
137
|
-
$(C, T);
|
138
|
-
}, G = async (e, t, a) => {
|
139
|
-
const r = H(t), l = o(a, "./temp");
|
140
|
-
K(l) || O(l);
|
141
|
-
const s = I(t);
|
142
|
-
let y = J(t, "utf8");
|
143
|
-
y = y.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
144
|
-
const h = o(a, "js", r + ".js"), F = te(e), n = await Q(e);
|
145
|
-
await X.build({
|
146
|
-
stdin: {
|
147
|
-
contents: y,
|
148
|
-
sourcefile: s.base,
|
149
|
-
resolveDir: s.dir,
|
150
|
-
loader: "tsx"
|
151
|
-
},
|
152
|
-
minify: !1,
|
153
|
-
treeShaking: !0,
|
154
|
-
bundle: !0,
|
155
|
-
outfile: h,
|
156
|
-
format: n,
|
157
|
-
target: ["node20"],
|
158
|
-
keepNames: !0,
|
159
|
-
external: F,
|
160
|
-
packages: "external"
|
161
|
-
});
|
162
|
-
const p = Date.now();
|
163
|
-
return await import(`${h}?t=${p}`);
|
164
|
-
}, L = async (e) => {
|
165
|
-
const t = W(e), a = o(t, "salty.config.js"), r = Date.now(), { config: l } = await import(`${a}?t=${r}`);
|
166
|
-
return l;
|
167
|
-
}, se = () => {
|
168
|
-
try {
|
169
|
-
return process.env.NODE_ENV === "production";
|
170
|
-
} catch {
|
171
|
-
return !1;
|
172
|
-
}
|
173
|
-
}, _e = async (e, t = se()) => {
|
174
|
-
try {
|
175
|
-
const a = Date.now();
|
176
|
-
t ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
|
177
|
-
const r = [], l = [], s = W(e), y = o(s, "index.css");
|
178
|
-
(() => {
|
179
|
-
K(s) && ce("rm -rf " + s), O(s), O(o(s, "css")), O(o(s, "types"));
|
180
|
-
})(), await xe(e);
|
181
|
-
const F = await L(e);
|
182
|
-
async function n(c, m) {
|
183
|
-
const D = ["node_modules", "saltygen"], C = ie(c);
|
184
|
-
if (C.isDirectory()) {
|
185
|
-
const N = le(c);
|
186
|
-
if (D.some((i) => c.includes(i))) return;
|
187
|
-
await Promise.all(N.map((i) => n(o(c, i), o(m, i))));
|
188
|
-
} else if (C.isFile() && Z(c)) {
|
189
|
-
const T = await G(e, c, s), i = [];
|
190
|
-
Object.entries(T).forEach(([M, j]) => {
|
191
|
-
if (j.isKeyframes && j.css) {
|
192
|
-
const q = `a_${j.animationName}.css`, re = `css/${q}`, ae = o(s, re);
|
193
|
-
r.push(q), $(ae, j.css);
|
194
|
-
return;
|
195
|
-
}
|
196
|
-
if (!j.generator) return;
|
197
|
-
const P = j.generator._withBuildContext({
|
198
|
-
name: M,
|
199
|
-
config: F,
|
200
|
-
prod: t
|
201
|
-
});
|
202
|
-
l[P.priority] || (l[P.priority] = []), l[P.priority].push(P.cssFileName), i.push(P.cssFileName);
|
203
|
-
const ne = `css/${P.cssFileName}`, oe = o(s, ne);
|
204
|
-
$(oe, P.css);
|
205
|
-
});
|
206
|
-
const f = i.map((M) => `@import url('./${M}');`).join(`
|
207
|
-
`), b = H(c, 6), d = I(c), V = R(d.name), v = o(s, `css/f_${V}-${b}.css`);
|
208
|
-
$(v, f);
|
209
|
-
}
|
210
|
-
}
|
211
|
-
await n(e, s);
|
212
|
-
const p = r.map((c) => `@import url('./css/${c}');`).join(`
|
213
|
-
`);
|
214
|
-
let S = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
215
|
-
|
216
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((c) => {
|
217
|
-
try {
|
218
|
-
return J(o(s, "css", c), "utf8").length > 0;
|
219
|
-
} catch {
|
220
|
-
return !1;
|
221
|
-
}
|
222
|
-
}).map((c) => `@import url('./css/${c}');`).join(`
|
223
|
-
`)}
|
224
|
-
${p}`;
|
225
|
-
if (F.importStrategy !== "component") {
|
226
|
-
const c = l.reduce((m, D, C) => {
|
227
|
-
const N = D.reduce((T, i) => T + `@import url('./css/${i}') layer(l${C});`, "");
|
228
|
-
return `${m}
|
229
|
-
${N}`;
|
230
|
-
}, "");
|
231
|
-
S += c;
|
232
|
-
}
|
233
|
-
$(y, S);
|
234
|
-
const u = Date.now() - a, k = u < 200 ? "🔥" : u < 500 ? "🚀" : u < 1e3 ? "🎉" : u < 2e3 ? "🚗" : u < 5e3 ? "🤔" : "🥴";
|
235
|
-
z.info(`Generated CSS in ${u}ms! ${k}`);
|
236
|
-
} catch (a) {
|
237
|
-
console.error(a);
|
238
|
-
}
|
239
|
-
}, Ee = async (e, t) => {
|
240
|
-
try {
|
241
|
-
const a = [], r = o(e, "./saltygen"), l = o(r, "index.css");
|
242
|
-
if (Z(t)) {
|
243
|
-
const y = await L(e), h = await G(e, t, r);
|
244
|
-
Object.entries(h).forEach(([x, g]) => {
|
245
|
-
if (g.isKeyframes && g.css) {
|
246
|
-
const c = `css/${`a_${g.animationName}.css`}`, m = o(r, c);
|
247
|
-
$(m, g.css);
|
248
|
-
return;
|
249
|
-
}
|
250
|
-
if (!g.generator) return;
|
251
|
-
const S = g.generator._withBuildContext({
|
252
|
-
name: x,
|
253
|
-
config: y
|
254
|
-
}), _ = `css/${S.cssFileName}`, u = o(r, _);
|
255
|
-
a.push(S.cssFileName), $(u, S.css);
|
256
|
-
});
|
257
|
-
const F = J(l, "utf8").split(`
|
258
|
-
`), n = a.map((x) => `@import url('../saltygen/css/${x}');`), w = [.../* @__PURE__ */ new Set([...F, ...n])].join(`
|
259
|
-
`);
|
260
|
-
$(l, w);
|
261
|
-
}
|
262
|
-
} catch (a) {
|
263
|
-
console.error(a);
|
264
|
-
}
|
265
|
-
}, Ve = async (e, t, a = se()) => {
|
266
|
-
try {
|
267
|
-
const r = o(e, "./saltygen");
|
268
|
-
if (Z(t)) {
|
269
|
-
const s = J(t, "utf8");
|
270
|
-
s.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== s && await fe(t, s);
|
271
|
-
const h = await L(e), F = await G(e, t, r);
|
272
|
-
let n = s;
|
273
|
-
if (Object.entries(F).forEach(([p, w]) => {
|
274
|
-
var b;
|
275
|
-
if (w.isKeyframes || !w.generator) return;
|
276
|
-
const x = w.generator._withBuildContext({
|
277
|
-
name: p,
|
278
|
-
config: h,
|
279
|
-
prod: a
|
280
|
-
}), g = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
281
|
-
if (!g) return console.error("Could not find the original declaration");
|
282
|
-
const S = (b = g.at(1)) == null ? void 0 : b.trim(), _ = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(n);
|
283
|
-
if (!_) return console.error("Could not find the original declaration");
|
284
|
-
const { index: u } = _;
|
285
|
-
let k = !1;
|
286
|
-
const c = setTimeout(() => k = !0, 5e3);
|
287
|
-
let m = 0, D = !1, C = 0;
|
288
|
-
for (; !D && !k; ) {
|
289
|
-
const d = n[u + m];
|
290
|
-
d === "(" && C++, d === ")" && C--, C === 0 && d === ")" && (D = !0), m > n.length && (k = !0), m++;
|
291
|
-
}
|
292
|
-
if (!k) clearTimeout(c);
|
293
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
294
|
-
const N = u + m, T = n.slice(u, N), i = n, f = ` ${p} = styled(${S}, "${x.classNames}", ${JSON.stringify(x.props)});`;
|
295
|
-
n = n.replace(T, f), i === n && console.error("Minimize file failed to change content", { name: p, tagName: S });
|
296
|
-
}), h.importStrategy === "component") {
|
297
|
-
const p = H(t, 6), w = I(t);
|
298
|
-
n = `import '../../saltygen/css/${`f_${R(w.name)}-${p}.css`}';
|
299
|
-
${n}`;
|
300
|
-
}
|
301
|
-
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
302
|
-
}
|
303
|
-
} catch (r) {
|
304
|
-
console.error("Error in minimizeFile:", r);
|
305
|
-
}
|
306
|
-
};
|
307
|
-
export {
|
308
|
-
Me as a,
|
309
|
-
Se as b,
|
310
|
-
xe as c,
|
311
|
-
G as d,
|
312
|
-
Ee as e,
|
313
|
-
_e as g,
|
314
|
-
Z as i,
|
315
|
-
z as l,
|
316
|
-
Ve as m,
|
317
|
-
we as s
|
318
|
-
};
|