@salty-css/core 0.0.1-alpha.118 → 0.0.1-alpha.119
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/config/config-types.d.ts +6 -2
- package/index-BKHuU-Ho.cjs +21 -0
- package/index-DrkPrGSp.js +300 -0
- package/package.json +1 -1
- package/templates/salty-reset.d.ts +2 -0
- package/types/index.d.ts +1 -1
- package/index-V5AY9k9D.js +0 -257
- package/index-eyW1pjj1.cjs +0 -21
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-BKHuU-Ho.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-DrkPrGSp.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-8PdMJjFC.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-lpgqU05M.cjs");const e=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-8PdMJjFC.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-lpgqU05M.cjs");const e=require("../index-BKHuU-Ho.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-D1FebDfR.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-DrkPrGSp.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
package/config/config-types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { CssStyles } from '../types';
|
1
|
+
import { CssProperties, CssStyles } from '../types';
|
2
2
|
import { OrString } from '../types/util-types';
|
3
|
-
export type GlobalStyles = Record<string,
|
3
|
+
export type GlobalStyles = Record<string, CssProperties>;
|
4
4
|
export type CssVariables = Record<string, unknown>;
|
5
5
|
export interface CssResponsiveVariables {
|
6
6
|
[key: string]: CssVariables;
|
@@ -45,6 +45,10 @@ export interface SaltyConfig {
|
|
45
45
|
* Variables that are defined for different parent selectors (classes or data attributes).
|
46
46
|
*/
|
47
47
|
conditionalVariables?: CssConditionalVariables;
|
48
|
+
/**
|
49
|
+
* The global styles that are imported in the root of the project.
|
50
|
+
*/
|
51
|
+
reset?: 'default' | 'none' | GlobalStyles;
|
48
52
|
/**
|
49
53
|
* The global styles that are imported in the root of the project.
|
50
54
|
*/
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";const se=require("esbuild"),ne=require("child_process"),_=require("./dash-case-8PdMJjFC.cjs"),o=require("path"),c=require("fs"),Z=require("fs/promises"),V=require("./parse-templates-lpgqU05M.cjs"),R=require("winston");var I=typeof document<"u"?document.currentScript:null;function oe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const K=oe(se),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return c.existsSync(t)?t:L(o.join(e,".."))},re=async e=>{const t=L(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await re(e);if(t)return t.type};let E;const U=async e=>{if(E)return E;const t=await ie(e);return t==="module"?E="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-BKHuU-Ho.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},J=R.createLogger({level:"debug",format:R.format.combine(R.format.colorize(),R.format.cli()),transports:[new R.transports.Console({})]}),ce=e=>{J.error(e)};function G(e){return e?typeof e!="string"?G(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 ae={"*, *::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"},button:{lineHeight:"1em"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},X=e=>{if(A.externalModules.length>0)return A.externalModules;const t=o.join(e,"salty.config.ts"),n=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return A.externalModules=i,i},q=e=>o.join(e,"./saltygen"),Y=["salty","css","styles","styled"],Q=(e=[])=>new RegExp(`\\.(${[...Y,...e].join("|")})\\.`),z=(e,t=[])=>Q(t).test(e),le=async e=>{const t=q(e),s=o.join(e,"salty.config.ts"),n=o.join(t,"salty.config.js"),i=await U(e),p=X(e);await K.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:p});const h=Date.now(),{config:g}=await import(`${n}?t=${h}`);return g},ee=async e=>{const t=await le(e),s=new Set,n=(f,l=[])=>f?Object.entries(f).flatMap(([d,u])=>{if(!u)return;if(typeof u=="object")return n(u,[...l,d]);const x=G(d),N=_.dashCase(d),v=[...l,x].join(".");s.add(`"${v}"`);const O=[...l.map(_.dashCase),N].join("-"),{result:H}=V.parseValueTokens(u);return`--${O}: ${H};`}):[],i=f=>f?Object.entries(f).flatMap(([l,d])=>{const u=n(d);return l==="base"?u.join(""):`${l} { ${u.join("")} }`}):[],p=f=>f?Object.entries(f).flatMap(([l,d])=>Object.entries(d).flatMap(([u,x])=>{const N=n(x,[l]),v=`.${l}-${u}, [data-${l}="${u}"]`,O=N.join("");return`${v} { ${O} }`})):[],h=n(t.variables),g=i(t.responsiveVariables),b=p(t.conditionalVariables),r=q(e),k=o.join(r,"css/variables.css"),m=`:root { ${h.join("")} ${g.join("")} } ${b.join("")}`;c.writeFileSync(k,m);const j=o.join(r,"css/global.css"),w=V.parseStyles(t.global,"");c.writeFileSync(j,`@layer global { ${w} }`);const a=o.join(r,"css/reset.css"),C=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ae,F=V.parseStyles(C,"");c.writeFileSync(a,`@layer reset { ${F} }`);const $=o.join(r,"css/templates.css"),T=V.parseTemplates(t.templates),y=V.getTemplateTypes(t.templates);c.writeFileSync($,T);const P=o.join(r,"types/css-tokens.d.ts"),M=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...s].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(y).map(([f,l])=>`${f}?: ${l}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;c.writeFileSync(P,M)},W=async(e,t,s)=>{const n=_.toHash(t),i=o.join(s,"./temp");c.existsSync(i)||c.mkdirSync(i);const p=o.parse(t);let h=c.readFileSync(t,"utf8");h=h.replace(/styled\([^"'`{,]+,/g,"styled('div',");const g=o.join(s,"js",n+".js"),b=X(e),r=await U(e);await K.build({stdin:{contents:h,sourcefile:p.base,resolveDir:p.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:g,format:r,target:["node20"],keepNames:!0,external:b,packages:"external"});const k=Date.now();return await import(`${g}?t=${k}`)},B=async e=>{const t=q(e),s=o.join(t,"salty.config.js"),{config:n}=await import(s);return n},te=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},pe=async(e,t=te())=>{try{t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const s=[],n=[],i=q(e),p=o.join(i,"index.css");(()=>{c.existsSync(i)&&ne.execSync("rm -rf "+i),c.mkdirSync(i),c.mkdirSync(o.join(i,"css")),c.mkdirSync(o.join(i,"types"))})(),await ee(e);const g=await B(e);async function b(a,S){const C=["node_modules","saltygen"],F=c.statSync(a);if(F.isDirectory()){const $=c.readdirSync(a);if(C.some(y=>a.includes(y)))return;await Promise.all($.map(y=>b(o.join(a,y),o.join(S,y))))}else if(F.isFile()&&z(a)){const T=await W(e,a,i),y=[];Object.entries(T).forEach(([f,l])=>{if(l.isKeyframes&&l.css){const v=`${l.animationName}.css`,O=`css/${v}`,H=o.join(i,O);s.push(v),c.writeFileSync(H,l.css);return}if(!l.generator)return;const d=l.generator._withBuildContext({name:f,config:g,prod:t}),u=`${d.hash}-${d.priority}.css`;n[d.priority]||(n[d.priority]=[]),n[d.priority].push(u),y.push(u);const x=`css/${u}`,N=o.join(i,x);c.writeFileSync(N,d.css)});const P=y.map(f=>`@import url('./${f}');`).join(`
|
12
|
+
`),D=_.toHash(a,6),M=o.join(i,`css/${D}.css`);c.writeFileSync(M,P)}}await b(e,i);const r=s.map(a=>`@import url('./css/${a}');`).join(`
|
13
|
+
`);let w=`@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(o.join(i,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
|
16
|
+
`)}
|
17
|
+
${r}`;if(g.importStrategy!=="component"){const a=n.flat().map(S=>`@import url('./css/${S}');`).join(`
|
18
|
+
`);w+=a}c.writeFileSync(p,w)}catch(s){console.error(s)}},ue=async(e,t)=>{try{const s=[],n=o.join(e,"./saltygen"),i=o.join(n,"index.css");if(z(t)){const h=await B(e),g=await W(e,t,n);Object.entries(g).forEach(([j,w])=>{if(!w.generator)return;const a=w.generator._withBuildContext({name:j,config:h}),S=`${a.hash}-${a.priority}.css`,C=`css/${S}`,F=o.join(n,C);s.push(S),c.writeFileSync(F,a.css)});const b=c.readFileSync(i,"utf8").split(`
|
19
|
+
`),r=s.map(j=>`@import url('../saltygen/css/${j}');`),m=[...new Set([...b,...r])].join(`
|
20
|
+
`);c.writeFileSync(i,m)}}catch(s){console.error(s)}},fe=async(e,t,s=te())=>{try{const n=o.join(e,"./saltygen");if(z(t)){const p=c.readFileSync(t,"utf8");p.replace(/^(?!export\s)const\s.*/gm,m=>`export ${m}`)!==p&&await Z.writeFile(t,p);const g=await B(e),b=await W(e,t,n);let r=p;Object.entries(b).forEach(([m,j])=>{var u;if(j.isKeyframes||!j.generator)return;const w=j.generator._withBuildContext({name:m,config:g,prod:s}),a=new RegExp(`\\s${m}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(p);if(!a)return console.error("Could not find the original declaration");const S=(u=a.at(1))==null?void 0:u.trim(),C=new RegExp(`\\s${m}[=\\s]+styled\\(`,"g").exec(r);if(!C)return console.error("Could not find the original declaration");const{index:F}=C;let $=!1;const T=setTimeout(()=>$=!0,5e3);let y=0,P=!1,D=0;for(;!P&&!$;){const x=r[F+y];x==="("&&D++,x===")"&&D--,D===0&&x===")"&&(P=!0),y>r.length&&($=!0),y++}if(!$)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const M=F+y,f=r.slice(F,M),l=r,d=` ${m} = styled(${S}, "${w.classNames}", ${JSON.stringify(w.props)});`;r=r.replace(f,d),l===r&&console.error("Minimize file failed to change content",{name:m,tagName:S})});const k=_.toHash(t,6);return g.importStrategy==="component"&&(r=`import '../../saltygen/css/${k}.css';
|
21
|
+
${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=W;exports.generateConfigStyles=ee;exports.generateCss=pe;exports.generateFile=ue;exports.isSaltyFile=z;exports.logError=ce;exports.logger=J;exports.minimizeFile=fe;exports.saltyFileExtensions=Y;exports.saltyFileRegExp=Q;
|
@@ -0,0 +1,300 @@
|
|
1
|
+
import * as q from "esbuild";
|
2
|
+
import { execSync as et } from "child_process";
|
3
|
+
import { t as H, d as G } from "./dash-case-D_tXuO4I.js";
|
4
|
+
import { join as o, parse as st } from "path";
|
5
|
+
import { existsSync as I, writeFileSync as b, mkdirSync as O, readFileSync as J, statSync as nt, readdirSync as ot } from "fs";
|
6
|
+
import { readFile as rt, writeFile as at } from "fs/promises";
|
7
|
+
import { p as L, a as it, b as ct, c as lt } from "./parse-templates-D1FebDfR.js";
|
8
|
+
import { createLogger as pt, format as z, transports as ft } from "winston";
|
9
|
+
const U = (t) => {
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
+
const e = o(t, "package.json");
|
12
|
+
return I(e) ? e : U(o(t, ".."));
|
13
|
+
}, ut = async (t) => {
|
14
|
+
const e = U(t);
|
15
|
+
return await rt(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
+
});
|
17
|
+
}, gt = async (t) => {
|
18
|
+
const e = await ut(t);
|
19
|
+
if (e)
|
20
|
+
return e.type;
|
21
|
+
};
|
22
|
+
let v;
|
23
|
+
const X = async (t) => {
|
24
|
+
if (v) return v;
|
25
|
+
const e = await gt(t);
|
26
|
+
return e === "module" ? v = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (v = "cjs"), v || "esm";
|
27
|
+
}, B = pt({
|
28
|
+
level: "debug",
|
29
|
+
format: z.combine(z.colorize(), z.cli()),
|
30
|
+
transports: [new ft.Console({})]
|
31
|
+
}), Ft = (t) => {
|
32
|
+
B.error(t);
|
33
|
+
};
|
34
|
+
function Y(t) {
|
35
|
+
return t ? typeof t != "string" ? Y(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, a) => (a > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
+
}
|
37
|
+
const dt = {
|
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 button line height */
|
69
|
+
button: {
|
70
|
+
lineHeight: "1em"
|
71
|
+
},
|
72
|
+
/** Improve form elements */
|
73
|
+
"input, optgroup, select, textarea": {
|
74
|
+
fontFamily: "inherit",
|
75
|
+
fontSize: "100%",
|
76
|
+
lineHeight: "1.15em"
|
77
|
+
}
|
78
|
+
}, A = {
|
79
|
+
externalModules: []
|
80
|
+
}, Q = (t) => {
|
81
|
+
if (A.externalModules.length > 0) return A.externalModules;
|
82
|
+
const e = o(t, "salty.config.ts"), s = J(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
83
|
+
if (!s) return [];
|
84
|
+
const r = s[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
|
85
|
+
return A.externalModules = r, r;
|
86
|
+
}, R = (t) => o(t, "./saltygen"), yt = ["salty", "css", "styles", "styled"], mt = (t = []) => new RegExp(`\\.(${[...yt, ...t].join("|")})\\.`), Z = (t, e = []) => mt(e).test(t), ht = async (t) => {
|
87
|
+
const e = R(t), a = o(t, "salty.config.ts"), s = o(e, "salty.config.js"), r = await X(t), l = Q(t);
|
88
|
+
await q.build({
|
89
|
+
entryPoints: [a],
|
90
|
+
minify: !0,
|
91
|
+
treeShaking: !0,
|
92
|
+
bundle: !0,
|
93
|
+
outfile: s,
|
94
|
+
format: r,
|
95
|
+
external: l
|
96
|
+
});
|
97
|
+
const m = Date.now(), { config: g } = await import(`${s}?t=${m}`);
|
98
|
+
return g;
|
99
|
+
}, bt = async (t) => {
|
100
|
+
const e = await ht(t), a = /* @__PURE__ */ new Set(), s = (f, c = []) => f ? Object.entries(f).flatMap(([u, p]) => {
|
101
|
+
if (!p) return;
|
102
|
+
if (typeof p == "object") return s(p, [...c, u]);
|
103
|
+
const C = Y(u), V = G(u), M = [...c, C].join(".");
|
104
|
+
a.add(`"${M}"`);
|
105
|
+
const N = [...c.map(G), V].join("-"), { result: W } = lt(p);
|
106
|
+
return `--${N}: ${W};`;
|
107
|
+
}) : [], r = (f) => f ? Object.entries(f).flatMap(([c, u]) => {
|
108
|
+
const p = s(u);
|
109
|
+
return c === "base" ? p.join("") : `${c} { ${p.join("")} }`;
|
110
|
+
}) : [], l = (f) => f ? Object.entries(f).flatMap(([c, u]) => Object.entries(u).flatMap(([p, C]) => {
|
111
|
+
const V = s(C, [c]), M = `.${c}-${p}, [data-${c}="${p}"]`, N = V.join("");
|
112
|
+
return `${M} { ${N} }`;
|
113
|
+
})) : [], m = s(e.variables), g = r(e.responsiveVariables), $ = l(e.conditionalVariables), n = R(t), F = o(n, "css/variables.css"), y = `:root { ${m.join("")} ${g.join("")} } ${$.join("")}`;
|
114
|
+
b(F, y);
|
115
|
+
const S = o(n, "css/global.css"), w = L(e.global, "");
|
116
|
+
b(S, `@layer global { ${w} }`);
|
117
|
+
const i = o(n, "css/reset.css"), k = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : dt, x = L(k, "");
|
118
|
+
b(i, `@layer reset { ${x} }`);
|
119
|
+
const j = o(n, "css/templates.css"), T = it(e.templates), d = ct(e.templates);
|
120
|
+
b(j, T);
|
121
|
+
const P = o(n, "types/css-tokens.d.ts"), E = `
|
122
|
+
// Variable types
|
123
|
+
type VariableTokens = ${[...a].join("|")};
|
124
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
125
|
+
|
126
|
+
// Template types
|
127
|
+
type TemplateTokens = {
|
128
|
+
${Object.entries(d).map(([f, c]) => `${f}?: ${c}`).join(`
|
129
|
+
`)}
|
130
|
+
}
|
131
|
+
`;
|
132
|
+
b(P, E);
|
133
|
+
}, _ = async (t, e, a) => {
|
134
|
+
const s = H(e), r = o(a, "./temp");
|
135
|
+
I(r) || O(r);
|
136
|
+
const l = st(e);
|
137
|
+
let m = J(e, "utf8");
|
138
|
+
m = m.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
139
|
+
const g = o(a, "js", s + ".js"), $ = Q(t), n = await X(t);
|
140
|
+
await q.build({
|
141
|
+
stdin: {
|
142
|
+
contents: m,
|
143
|
+
sourcefile: l.base,
|
144
|
+
resolveDir: l.dir,
|
145
|
+
loader: "tsx"
|
146
|
+
},
|
147
|
+
minify: !1,
|
148
|
+
treeShaking: !0,
|
149
|
+
bundle: !0,
|
150
|
+
outfile: g,
|
151
|
+
format: n,
|
152
|
+
target: ["node20"],
|
153
|
+
keepNames: !0,
|
154
|
+
external: $,
|
155
|
+
packages: "external"
|
156
|
+
});
|
157
|
+
const F = Date.now();
|
158
|
+
return await import(`${g}?t=${F}`);
|
159
|
+
}, K = async (t) => {
|
160
|
+
const e = R(t), a = o(e, "salty.config.js"), { config: s } = await import(a);
|
161
|
+
return s;
|
162
|
+
}, tt = () => {
|
163
|
+
try {
|
164
|
+
return process.env.NODE_ENV === "production";
|
165
|
+
} catch {
|
166
|
+
return !1;
|
167
|
+
}
|
168
|
+
}, Tt = async (t, e = tt()) => {
|
169
|
+
try {
|
170
|
+
e ? B.info("Generating CSS in production mode! 🔥") : B.info("Generating CSS in development mode! 🚀");
|
171
|
+
const a = [], s = [], r = R(t), l = o(r, "index.css");
|
172
|
+
(() => {
|
173
|
+
I(r) && et("rm -rf " + r), O(r), O(o(r, "css")), O(o(r, "types"));
|
174
|
+
})(), await bt(t);
|
175
|
+
const g = await K(t);
|
176
|
+
async function $(i, h) {
|
177
|
+
const k = ["node_modules", "saltygen"], x = nt(i);
|
178
|
+
if (x.isDirectory()) {
|
179
|
+
const j = ot(i);
|
180
|
+
if (k.some((d) => i.includes(d))) return;
|
181
|
+
await Promise.all(j.map((d) => $(o(i, d), o(h, d))));
|
182
|
+
} else if (x.isFile() && Z(i)) {
|
183
|
+
const T = await _(t, i, r), d = [];
|
184
|
+
Object.entries(T).forEach(([f, c]) => {
|
185
|
+
if (c.isKeyframes && c.css) {
|
186
|
+
const M = `${c.animationName}.css`, N = `css/${M}`, W = o(r, N);
|
187
|
+
a.push(M), b(W, c.css);
|
188
|
+
return;
|
189
|
+
}
|
190
|
+
if (!c.generator) return;
|
191
|
+
const u = c.generator._withBuildContext({
|
192
|
+
name: f,
|
193
|
+
config: g,
|
194
|
+
prod: e
|
195
|
+
}), p = `${u.hash}-${u.priority}.css`;
|
196
|
+
s[u.priority] || (s[u.priority] = []), s[u.priority].push(p), d.push(p);
|
197
|
+
const C = `css/${p}`, V = o(r, C);
|
198
|
+
b(V, u.css);
|
199
|
+
});
|
200
|
+
const P = d.map((f) => `@import url('./${f}');`).join(`
|
201
|
+
`), D = H(i, 6), E = o(r, `css/${D}.css`);
|
202
|
+
b(E, P);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
await $(t, r);
|
206
|
+
const n = a.map((i) => `@import url('./css/${i}');`).join(`
|
207
|
+
`);
|
208
|
+
let w = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
209
|
+
|
210
|
+
${["variables.css", "reset.css", "global.css", "templates.css"].filter((i) => {
|
211
|
+
try {
|
212
|
+
return J(o(r, "css", i), "utf8").length > 0;
|
213
|
+
} catch {
|
214
|
+
return !1;
|
215
|
+
}
|
216
|
+
}).map((i) => `@import url('./css/${i}');`).join(`
|
217
|
+
`)}
|
218
|
+
${n}`;
|
219
|
+
if (g.importStrategy !== "component") {
|
220
|
+
const i = s.flat().map((h) => `@import url('./css/${h}');`).join(`
|
221
|
+
`);
|
222
|
+
w += i;
|
223
|
+
}
|
224
|
+
b(l, w);
|
225
|
+
} catch (a) {
|
226
|
+
console.error(a);
|
227
|
+
}
|
228
|
+
}, Pt = async (t, e) => {
|
229
|
+
try {
|
230
|
+
const a = [], s = o(t, "./saltygen"), r = o(s, "index.css");
|
231
|
+
if (Z(e)) {
|
232
|
+
const m = await K(t), g = await _(t, e, s);
|
233
|
+
Object.entries(g).forEach(([S, w]) => {
|
234
|
+
if (!w.generator) return;
|
235
|
+
const i = w.generator._withBuildContext({
|
236
|
+
name: S,
|
237
|
+
config: m
|
238
|
+
}), h = `${i.hash}-${i.priority}.css`, k = `css/${h}`, x = o(s, k);
|
239
|
+
a.push(h), b(x, i.css);
|
240
|
+
});
|
241
|
+
const $ = J(r, "utf8").split(`
|
242
|
+
`), n = a.map((S) => `@import url('../saltygen/css/${S}');`), y = [.../* @__PURE__ */ new Set([...$, ...n])].join(`
|
243
|
+
`);
|
244
|
+
b(r, y);
|
245
|
+
}
|
246
|
+
} catch (a) {
|
247
|
+
console.error(a);
|
248
|
+
}
|
249
|
+
}, Dt = async (t, e, a = tt()) => {
|
250
|
+
try {
|
251
|
+
const s = o(t, "./saltygen");
|
252
|
+
if (Z(e)) {
|
253
|
+
const l = J(e, "utf8");
|
254
|
+
l.replace(/^(?!export\s)const\s.*/gm, (y) => `export ${y}`) !== l && await at(e, l);
|
255
|
+
const g = await K(t), $ = await _(t, e, s);
|
256
|
+
let n = l;
|
257
|
+
Object.entries($).forEach(([y, S]) => {
|
258
|
+
var p;
|
259
|
+
if (S.isKeyframes || !S.generator) return;
|
260
|
+
const w = S.generator._withBuildContext({
|
261
|
+
name: y,
|
262
|
+
config: g,
|
263
|
+
prod: a
|
264
|
+
}), i = new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
|
265
|
+
if (!i) return console.error("Could not find the original declaration");
|
266
|
+
const h = (p = i.at(1)) == null ? void 0 : p.trim(), k = new RegExp(`\\s${y}[=\\s]+styled\\(`, "g").exec(n);
|
267
|
+
if (!k) return console.error("Could not find the original declaration");
|
268
|
+
const { index: x } = k;
|
269
|
+
let j = !1;
|
270
|
+
const T = setTimeout(() => j = !0, 5e3);
|
271
|
+
let d = 0, P = !1, D = 0;
|
272
|
+
for (; !P && !j; ) {
|
273
|
+
const C = n[x + d];
|
274
|
+
C === "(" && D++, C === ")" && D--, D === 0 && C === ")" && (P = !0), d > n.length && (j = !0), d++;
|
275
|
+
}
|
276
|
+
if (!j) clearTimeout(T);
|
277
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
278
|
+
const E = x + d, f = n.slice(x, E), c = n, u = ` ${y} = styled(${h}, "${w.classNames}", ${JSON.stringify(w.props)});`;
|
279
|
+
n = n.replace(f, u), c === n && console.error("Minimize file failed to change content", { name: y, tagName: h });
|
280
|
+
});
|
281
|
+
const F = H(e, 6);
|
282
|
+
return g.importStrategy === "component" && (n = `import '../../saltygen/css/${F}.css';
|
283
|
+
${n}`), n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
284
|
+
}
|
285
|
+
} catch (s) {
|
286
|
+
console.error("Error in minimizeFile:", s);
|
287
|
+
}
|
288
|
+
};
|
289
|
+
export {
|
290
|
+
Ft as a,
|
291
|
+
mt as b,
|
292
|
+
bt as c,
|
293
|
+
_ as d,
|
294
|
+
Pt as e,
|
295
|
+
Tt as g,
|
296
|
+
Z as i,
|
297
|
+
B as l,
|
298
|
+
Dt as m,
|
299
|
+
yt as s
|
300
|
+
};
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
@@ -21,7 +21,7 @@ type FnComponent<PROPS extends StyledComponentProps> = {
|
|
21
21
|
};
|
22
22
|
export type Tag<PROPS extends StyledComponentProps> = OrString | keyof HTMLElementTagNameMap | FnComponent<PROPS>;
|
23
23
|
type CSSPropertyValueFunction = (params?: any) => any;
|
24
|
-
type CssProperties = {
|
24
|
+
export type CssProperties = {
|
25
25
|
[key in keyof CSS.Properties]: CSS.Properties[key] | PropertyValueToken | CSSPropertyValueFunction | NeverObj;
|
26
26
|
};
|
27
27
|
type CssPropertyKeys = keyof CssProperties;
|
package/index-V5AY9k9D.js
DELETED
@@ -1,257 +0,0 @@
|
|
1
|
-
import * as G from "esbuild";
|
2
|
-
import { execSync as tt } from "child_process";
|
3
|
-
import { t as A, d as K } from "./dash-case-D_tXuO4I.js";
|
4
|
-
import { join as r, parse as et } from "path";
|
5
|
-
import { existsSync as B, writeFileSync as x, mkdirSync as N, readFileSync as V, statSync as st, readdirSync as nt } from "fs";
|
6
|
-
import { readFile as ot, writeFile as rt } from "fs/promises";
|
7
|
-
import { p as at, a as ct, b as it, c as lt } from "./parse-templates-D1FebDfR.js";
|
8
|
-
import { createLogger as pt, format as J, transports as ft } from "winston";
|
9
|
-
const W = (t) => {
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
-
const e = r(t, "package.json");
|
12
|
-
return B(e) ? e : W(r(t, ".."));
|
13
|
-
}, ut = async (t) => {
|
14
|
-
const e = W(t);
|
15
|
-
return await ot(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
-
});
|
17
|
-
}, dt = async (t) => {
|
18
|
-
const e = await ut(t);
|
19
|
-
if (e)
|
20
|
-
return e.type;
|
21
|
-
};
|
22
|
-
let E;
|
23
|
-
const H = async (t) => {
|
24
|
-
if (E) return E;
|
25
|
-
const e = await dt(t);
|
26
|
-
return e === "module" ? E = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (E = "cjs"), E || "esm";
|
27
|
-
}, R = pt({
|
28
|
-
level: "debug",
|
29
|
-
format: J.combine(J.colorize(), J.cli()),
|
30
|
-
transports: [new ft.Console({})]
|
31
|
-
}), Ft = (t) => {
|
32
|
-
R.error(t);
|
33
|
-
};
|
34
|
-
function L(t) {
|
35
|
-
return t ? typeof t != "string" ? L(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, a) => (a > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
-
}
|
37
|
-
const O = {
|
38
|
-
externalModules: []
|
39
|
-
}, q = (t) => {
|
40
|
-
if (O.externalModules.length > 0) return O.externalModules;
|
41
|
-
const e = r(t, "salty.config.ts"), s = V(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
42
|
-
if (!s) return [];
|
43
|
-
const n = s[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
|
44
|
-
return O.externalModules = n, n;
|
45
|
-
}, v = (t) => r(t, "./saltygen"), gt = ["salty", "css", "styles", "styled"], mt = (t = []) => new RegExp(`\\.(${[...gt, ...t].join("|")})\\.`), I = (t, e = []) => mt(e).test(t), yt = async (t) => {
|
46
|
-
const e = v(t), a = r(t, "salty.config.ts"), s = r(e, "salty.config.js"), n = await H(t), l = q(t);
|
47
|
-
await G.build({
|
48
|
-
entryPoints: [a],
|
49
|
-
minify: !0,
|
50
|
-
treeShaking: !0,
|
51
|
-
bundle: !0,
|
52
|
-
outfile: s,
|
53
|
-
format: n,
|
54
|
-
external: l
|
55
|
-
});
|
56
|
-
const b = Date.now(), { config: f } = await import(`${s}?t=${b}`);
|
57
|
-
return f;
|
58
|
-
}, ht = async (t) => {
|
59
|
-
const e = await yt(t), a = /* @__PURE__ */ new Set(), s = (i, p = []) => i ? Object.entries(i).flatMap(([g, u]) => {
|
60
|
-
if (!u) return;
|
61
|
-
if (typeof u == "object") return s(u, [...p, g]);
|
62
|
-
const F = L(g), y = K(g), h = [...p, F].join(".");
|
63
|
-
a.add(`"${h}"`);
|
64
|
-
const j = [...p.map(K), y].join("-"), { result: P } = lt(u);
|
65
|
-
return `--${j}: ${P};`;
|
66
|
-
}) : [], n = (i) => i ? Object.entries(i).flatMap(([p, g]) => {
|
67
|
-
const u = s(g);
|
68
|
-
return p === "base" ? u.join("") : `${p} { ${u.join("")} }`;
|
69
|
-
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, g]) => Object.entries(g).flatMap(([u, F]) => {
|
70
|
-
const y = s(F, [p]), h = `.${p}-${u}, [data-${p}="${u}"]`, j = y.join("");
|
71
|
-
return `${h} { ${j} }`;
|
72
|
-
})) : [], b = s(e.variables), f = n(e.responsiveVariables), $ = l(e.conditionalVariables), o = v(t), D = r(o, "css/variables.css"), d = `:root { ${b.join("")} ${f.join("")} } ${$.join("")}`;
|
73
|
-
x(D, d);
|
74
|
-
const w = r(o, "css/global.css"), S = at(e.global, "");
|
75
|
-
x(w, S);
|
76
|
-
const c = r(o, "css/templates.css"), m = ct(e.templates), k = it(e.templates);
|
77
|
-
x(c, m);
|
78
|
-
const C = r(o, "types/css-tokens.d.ts"), M = `
|
79
|
-
// Variable types
|
80
|
-
type VariableTokens = ${[...a].join("|")};
|
81
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
82
|
-
|
83
|
-
// Template types
|
84
|
-
type TemplateTokens = {
|
85
|
-
${Object.entries(k).map(([i, p]) => `${i}?: ${p}`).join(`
|
86
|
-
`)}
|
87
|
-
}
|
88
|
-
`;
|
89
|
-
x(C, M);
|
90
|
-
}, Z = async (t, e, a) => {
|
91
|
-
const s = A(e), n = r(a, "./temp");
|
92
|
-
B(n) || N(n);
|
93
|
-
const l = et(e);
|
94
|
-
let b = V(e, "utf8");
|
95
|
-
b = b.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
96
|
-
const f = r(a, "js", s + ".js"), $ = q(t), o = await H(t);
|
97
|
-
await G.build({
|
98
|
-
stdin: {
|
99
|
-
contents: b,
|
100
|
-
sourcefile: l.base,
|
101
|
-
resolveDir: l.dir,
|
102
|
-
loader: "tsx"
|
103
|
-
},
|
104
|
-
minify: !1,
|
105
|
-
treeShaking: !0,
|
106
|
-
bundle: !0,
|
107
|
-
outfile: f,
|
108
|
-
format: o,
|
109
|
-
target: ["node20"],
|
110
|
-
keepNames: !0,
|
111
|
-
external: $,
|
112
|
-
packages: "external"
|
113
|
-
});
|
114
|
-
const D = Date.now();
|
115
|
-
return await import(`${f}?t=${D}`);
|
116
|
-
}, _ = async (t) => {
|
117
|
-
const e = v(t), a = r(e, "salty.config.js"), { config: s } = await import(a);
|
118
|
-
return s;
|
119
|
-
}, U = () => {
|
120
|
-
try {
|
121
|
-
return process.env.NODE_ENV === "production";
|
122
|
-
} catch {
|
123
|
-
return !1;
|
124
|
-
}
|
125
|
-
}, kt = async (t, e = U()) => {
|
126
|
-
try {
|
127
|
-
e ? R.info("Generating CSS in production mode! 🔥") : R.info("Generating CSS in development mode! 🚀");
|
128
|
-
const a = [], s = [], n = v(t), l = r(n, "index.css");
|
129
|
-
(() => {
|
130
|
-
B(n) && tt("rm -rf " + n), N(n), N(r(n, "css")), N(r(n, "types"));
|
131
|
-
})(), await ht(t);
|
132
|
-
const f = await _(t);
|
133
|
-
async function $(c, m) {
|
134
|
-
const k = ["node_modules", "saltygen"], C = st(c);
|
135
|
-
if (C.isDirectory()) {
|
136
|
-
const T = nt(c);
|
137
|
-
if (k.some((i) => c.includes(i))) return;
|
138
|
-
await Promise.all(T.map((i) => $(r(c, i), r(m, i))));
|
139
|
-
} else if (C.isFile() && I(c)) {
|
140
|
-
const M = await Z(t, c, n), i = [];
|
141
|
-
Object.entries(M).forEach(([F, y]) => {
|
142
|
-
if (y.isKeyframes && y.css) {
|
143
|
-
const z = `${y.animationName}.css`, Y = `css/${z}`, Q = r(n, Y);
|
144
|
-
a.push(z), x(Q, y.css);
|
145
|
-
return;
|
146
|
-
}
|
147
|
-
if (!y.generator) return;
|
148
|
-
const h = y.generator._withBuildContext({
|
149
|
-
name: F,
|
150
|
-
config: f,
|
151
|
-
prod: e
|
152
|
-
}), j = `${h.hash}-${h.priority}.css`;
|
153
|
-
s[h.priority] || (s[h.priority] = []), s[h.priority].push(j), i.push(j);
|
154
|
-
const P = `css/${j}`, X = r(n, P);
|
155
|
-
x(X, h.css);
|
156
|
-
});
|
157
|
-
const p = i.map((F) => `@import url('./${F}');`).join(`
|
158
|
-
`), g = A(c, 6), u = r(n, `css/${g}.css`);
|
159
|
-
x(u, p);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
await $(t, n);
|
163
|
-
const o = a.map((c) => `@import url('./css/${c}');`).join(`
|
164
|
-
`);
|
165
|
-
let S = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
166
|
-
|
167
|
-
${["variables.css", "global.css", "templates.css"].filter((c) => {
|
168
|
-
try {
|
169
|
-
return V(r(n, "css", c), "utf8").length > 0;
|
170
|
-
} catch {
|
171
|
-
return !1;
|
172
|
-
}
|
173
|
-
}).map((c) => `@import url('./css/${c}');`).join(`
|
174
|
-
`)}
|
175
|
-
${o}`;
|
176
|
-
if (f.importStrategy !== "component") {
|
177
|
-
const c = s.flat().map((m) => `@import url('./css/${m}');`).join(`
|
178
|
-
`);
|
179
|
-
S += c;
|
180
|
-
}
|
181
|
-
x(l, S);
|
182
|
-
} catch (a) {
|
183
|
-
console.error(a);
|
184
|
-
}
|
185
|
-
}, Tt = async (t, e) => {
|
186
|
-
try {
|
187
|
-
const a = [], s = r(t, "./saltygen"), n = r(s, "index.css");
|
188
|
-
if (I(e)) {
|
189
|
-
const b = await _(t), f = await Z(t, e, s);
|
190
|
-
Object.entries(f).forEach(([w, S]) => {
|
191
|
-
if (!S.generator) return;
|
192
|
-
const c = S.generator._withBuildContext({
|
193
|
-
name: w,
|
194
|
-
config: b
|
195
|
-
}), m = `${c.hash}-${c.priority}.css`, k = `css/${m}`, C = r(s, k);
|
196
|
-
a.push(m), x(C, c.css);
|
197
|
-
});
|
198
|
-
const $ = V(n, "utf8").split(`
|
199
|
-
`), o = a.map((w) => `@import url('../saltygen/css/${w}');`), d = [.../* @__PURE__ */ new Set([...$, ...o])].join(`
|
200
|
-
`);
|
201
|
-
x(n, d);
|
202
|
-
}
|
203
|
-
} catch (a) {
|
204
|
-
console.error(a);
|
205
|
-
}
|
206
|
-
}, Dt = async (t, e, a = U()) => {
|
207
|
-
try {
|
208
|
-
const s = r(t, "./saltygen");
|
209
|
-
if (I(e)) {
|
210
|
-
const l = V(e, "utf8");
|
211
|
-
l.replace(/^(?!export\s)const\s.*/gm, (d) => `export ${d}`) !== l && await rt(e, l);
|
212
|
-
const f = await _(t), $ = await Z(t, e, s);
|
213
|
-
let o = l;
|
214
|
-
Object.entries($).forEach(([d, w]) => {
|
215
|
-
var j;
|
216
|
-
if (w.isKeyframes || !w.generator) return;
|
217
|
-
const S = w.generator._withBuildContext({
|
218
|
-
name: d,
|
219
|
-
config: f,
|
220
|
-
prod: a
|
221
|
-
}), c = new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
|
222
|
-
if (!c) return console.error("Could not find the original declaration");
|
223
|
-
const m = (j = c.at(1)) == null ? void 0 : j.trim(), k = new RegExp(`\\s${d}[=\\s]+styled\\(`, "g").exec(o);
|
224
|
-
if (!k) return console.error("Could not find the original declaration");
|
225
|
-
const { index: C } = k;
|
226
|
-
let T = !1;
|
227
|
-
const M = setTimeout(() => T = !0, 5e3);
|
228
|
-
let i = 0, p = !1, g = 0;
|
229
|
-
for (; !p && !T; ) {
|
230
|
-
const P = o[C + i];
|
231
|
-
P === "(" && g++, P === ")" && g--, g === 0 && P === ")" && (p = !0), i > o.length && (T = !0), i++;
|
232
|
-
}
|
233
|
-
if (!T) clearTimeout(M);
|
234
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
235
|
-
const u = C + i, F = o.slice(C, u), y = o, h = ` ${d} = styled(${m}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
236
|
-
o = o.replace(F, h), y === o && console.error("Minimize file failed to change content", { name: d, tagName: m });
|
237
|
-
});
|
238
|
-
const D = A(e, 6);
|
239
|
-
return f.importStrategy === "component" && (o = `import '../../saltygen/css/${D}.css';
|
240
|
-
${o}`), o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
241
|
-
}
|
242
|
-
} catch (s) {
|
243
|
-
console.error("Error in minimizeFile:", s);
|
244
|
-
}
|
245
|
-
};
|
246
|
-
export {
|
247
|
-
Ft as a,
|
248
|
-
mt as b,
|
249
|
-
ht as c,
|
250
|
-
Z as d,
|
251
|
-
Tt as e,
|
252
|
-
kt as g,
|
253
|
-
I as i,
|
254
|
-
R as l,
|
255
|
-
Dt as m,
|
256
|
-
gt as s
|
257
|
-
};
|
package/index-eyW1pjj1.cjs
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";const se=require("esbuild"),ne=require("child_process"),O=require("./dash-case-8PdMJjFC.cjs"),o=require("path"),a=require("fs"),B=require("fs/promises"),V=require("./parse-templates-lpgqU05M.cjs"),N=require("winston");var q=typeof document<"u"?document.currentScript:null;function oe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Z=oe(se),H=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return a.existsSync(t)?t:H(o.join(e,".."))},ie=async e=>{const t=H(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},re=async e=>{const t=await ie(e);if(t)return t.type};let M;const K=async e=>{if(M)return M;const t=await re(e);return t==="module"?M="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-eyW1pjj1.cjs",document.baseURI).href).endsWith(".cjs"))&&(M="cjs"),M||"esm"},v=N.createLogger({level:"debug",format:N.format.combine(N.format.colorize(),N.format.cli()),transports:[new N.transports.Console({})]}),ce=e=>{v.error(e)};function L(e){return e?typeof e!="string"?L(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 I={externalModules:[]},U=e=>{if(I.externalModules.length>0)return I.externalModules;const t=o.join(e,"salty.config.ts"),n=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(u=>u.replace(/['"`]/g,"").trim());return I.externalModules=i,i},R=e=>o.join(e,"./saltygen"),G=["salty","css","styles","styled"],W=(e=[])=>new RegExp(`\\.(${[...G,...e].join("|")})\\.`),_=(e,t=[])=>W(t).test(e),ae=async e=>{const t=R(e),s=o.join(e,"salty.config.ts"),n=o.join(t,"salty.config.js"),i=await K(e),u=U(e);await Z.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:u});const S=Date.now(),{config:f}=await import(`${n}?t=${S}`);return f},X=async e=>{const t=await ae(e),s=new Set,n=(l,p=[])=>l?Object.entries(l).flatMap(([y,d])=>{if(!d)return;if(typeof d=="object")return n(d,[...p,y]);const x=L(y),h=O.dashCase(y),j=[...p,x].join(".");s.add(`"${j}"`);const C=[...p.map(O.dashCase),h].join("-"),{result:D}=V.parseValueTokens(d);return`--${C}: ${D};`}):[],i=l=>l?Object.entries(l).flatMap(([p,y])=>{const d=n(y);return p==="base"?d.join(""):`${p} { ${d.join("")} }`}):[],u=l=>l?Object.entries(l).flatMap(([p,y])=>Object.entries(y).flatMap(([d,x])=>{const h=n(x,[p]),j=`.${p}-${d}, [data-${p}="${d}"]`,C=h.join("");return`${j} { ${C} }`})):[],S=n(t.variables),f=i(t.responsiveVariables),b=u(t.conditionalVariables),r=R(e),P=o.join(r,"css/variables.css"),g=`:root { ${S.join("")} ${f.join("")} } ${b.join("")}`;a.writeFileSync(P,g);const w=o.join(r,"css/global.css"),F=V.parseStyles(t.global,"");a.writeFileSync(w,F);const c=o.join(r,"css/templates.css"),m=V.parseTemplates(t.templates),k=V.getTemplateTypes(t.templates);a.writeFileSync(c,m);const $=o.join(r,"types/css-tokens.d.ts"),E=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...s].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
|
-
`;a.writeFileSync($,E)},J=async(e,t,s)=>{const n=O.toHash(t),i=o.join(s,"./temp");a.existsSync(i)||a.mkdirSync(i);const u=o.parse(t);let S=a.readFileSync(t,"utf8");S=S.replace(/styled\([^"'`{,]+,/g,"styled('div',");const f=o.join(s,"js",n+".js"),b=U(e),r=await K(e);await Z.build({stdin:{contents:S,sourcefile:u.base,resolveDir:u.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:f,format:r,target:["node20"],keepNames:!0,external:b,packages:"external"});const P=Date.now();return await import(`${f}?t=${P}`)},z=async e=>{const t=R(e),s=o.join(t,"salty.config.js"),{config:n}=await import(s);return n},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},le=async(e,t=Y())=>{try{t?v.info("Generating CSS in production mode! 🔥"):v.info("Generating CSS in development mode! 🚀");const s=[],n=[],i=R(e),u=o.join(i,"index.css");(()=>{a.existsSync(i)&&ne.execSync("rm -rf "+i),a.mkdirSync(i),a.mkdirSync(o.join(i,"css")),a.mkdirSync(o.join(i,"types"))})(),await X(e);const f=await z(e);async function b(c,m){const k=["node_modules","saltygen"],$=a.statSync(c);if($.isDirectory()){const T=a.readdirSync(c);if(k.some(l=>c.includes(l)))return;await Promise.all(T.map(l=>b(o.join(c,l),o.join(m,l))))}else if($.isFile()&&_(c)){const E=await J(e,c,i),l=[];Object.entries(E).forEach(([x,h])=>{if(h.isKeyframes&&h.css){const A=`${h.animationName}.css`,ee=`css/${A}`,te=o.join(i,ee);s.push(A),a.writeFileSync(te,h.css);return}if(!h.generator)return;const j=h.generator._withBuildContext({name:x,config:f,prod:t}),C=`${j.hash}-${j.priority}.css`;n[j.priority]||(n[j.priority]=[]),n[j.priority].push(C),l.push(C);const D=`css/${C}`,Q=o.join(i,D);a.writeFileSync(Q,j.css)});const p=l.map(x=>`@import url('./${x}');`).join(`
|
12
|
-
`),y=O.toHash(c,6),d=o.join(i,`css/${y}.css`);a.writeFileSync(d,p)}}await b(e,i);const r=s.map(c=>`@import url('./css/${c}');`).join(`
|
13
|
-
`);let F=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["variables.css","global.css","templates.css"].filter(c=>{try{return a.readFileSync(o.join(i,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
|
16
|
-
`)}
|
17
|
-
${r}`;if(f.importStrategy!=="component"){const c=n.flat().map(m=>`@import url('./css/${m}');`).join(`
|
18
|
-
`);F+=c}a.writeFileSync(u,F)}catch(s){console.error(s)}},ue=async(e,t)=>{try{const s=[],n=o.join(e,"./saltygen"),i=o.join(n,"index.css");if(_(t)){const S=await z(e),f=await J(e,t,n);Object.entries(f).forEach(([w,F])=>{if(!F.generator)return;const c=F.generator._withBuildContext({name:w,config:S}),m=`${c.hash}-${c.priority}.css`,k=`css/${m}`,$=o.join(n,k);s.push(m),a.writeFileSync($,c.css)});const b=a.readFileSync(i,"utf8").split(`
|
19
|
-
`),r=s.map(w=>`@import url('../saltygen/css/${w}');`),g=[...new Set([...b,...r])].join(`
|
20
|
-
`);a.writeFileSync(i,g)}}catch(s){console.error(s)}},pe=async(e,t,s=Y())=>{try{const n=o.join(e,"./saltygen");if(_(t)){const u=a.readFileSync(t,"utf8");u.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==u&&await B.writeFile(t,u);const f=await z(e),b=await J(e,t,n);let r=u;Object.entries(b).forEach(([g,w])=>{var C;if(w.isKeyframes||!w.generator)return;const F=w.generator._withBuildContext({name:g,config:f,prod:s}),c=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(u);if(!c)return console.error("Could not find the original declaration");const m=(C=c.at(1))==null?void 0:C.trim(),k=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(r);if(!k)return console.error("Could not find the original declaration");const{index:$}=k;let T=!1;const E=setTimeout(()=>T=!0,5e3);let l=0,p=!1,y=0;for(;!p&&!T;){const D=r[$+l];D==="("&&y++,D===")"&&y--,y===0&&D===")"&&(p=!0),l>r.length&&(T=!0),l++}if(!T)clearTimeout(E);else throw new Error("Failed to find the end of the styled call and timed out");const d=$+l,x=r.slice($,d),h=r,j=` ${g} = styled(${m}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(x,j),h===r&&console.error("Minimize file failed to change content",{name:g,tagName:m})});const P=O.toHash(t,6);return f.importStrategy==="component"&&(r=`import '../../saltygen/css/${P}.css';
|
21
|
-
${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=J;exports.generateConfigStyles=X;exports.generateCss=le;exports.generateFile=ue;exports.isSaltyFile=_;exports.logError=ce;exports.logger=v;exports.minimizeFile=pe;exports.saltyFileExtensions=G;exports.saltyFileRegExp=W;
|