@salty-css/core 0.0.1-alpha.283 → 0.0.1-alpha.285
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 +2 -2
- package/cache/resolve-dynamic-config-cache.cjs +1 -1
- package/cache/resolve-dynamic-config-cache.js +6 -8
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +1 -1
- package/{index-BYrtB4JM.cjs → index-De9SH8ms.cjs} +4 -4
- package/{index-CR0k7PXM.js → index-nYFJiyUY.js} +80 -82
- package/package.json +1 -1
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-BFVRQc0_.cjs → should-restart-9v8CVeO9.cjs} +1 -1
- package/{should-restart-CR-ZEYLq.js → should-restart-BQEu8oUb.js} +1 -1
package/bin/main.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-De9SH8ms.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-9v8CVeO9.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,x=>{if(x)return P(x);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(),x=y.join(" ");await X(`npm install ${x}`),P.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){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:f}=await C[i],d=ne.render(f,a);return{fileName:i,content:d}},x=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:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).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}`},H=i=>{const a=i==="."?"":i,f=process.cwd();return n.join(f,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 e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:f=i,cssFile:d,skipInstall:p}=this.opts();if(!f)return e.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 c=process.cwd(),r=H(f),q=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),g=await s.readFile(h,"utf-8").catch(()=>{});if(g===void 0){e.logger.info("Creating file: "+h);const u=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,u),await S(h)}else{const t=JSON.parse(g),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==g&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
|
2
2
|
|
3
3
|
# Salty-CSS
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
@@ -3,11 +3,11 @@ import { existsSync as Q, watch as re } from "fs";
|
|
3
3
|
import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
|
4
4
|
import { join as a, relative as z, parse as ce, format as te } from "path";
|
5
5
|
import { render as le } from "ejs";
|
6
|
-
import { l as t, a as h, b as K, i as de, c as fe } from "../index-
|
6
|
+
import { l as t, a as h, b as K, i as de, c as fe } from "../index-nYFJiyUY.js";
|
7
7
|
import { p as pe } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as ue } from "child_process";
|
9
9
|
import ge from "ora";
|
10
|
-
import { c as ye } from "../should-restart-
|
10
|
+
import { c as ye } from "../should-restart-BQEu8oUb.js";
|
11
11
|
const ne = (g) => new Promise((P, x) => {
|
12
12
|
ue(g, ($) => {
|
13
13
|
if ($) return x($);
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("fs/promises"),r=require("path"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("fs/promises"),r=require("path"),t=require("../index-De9SH8ms.cjs"),i=async()=>{const o=t.getCorePackageRoot(),c=r.join(o,"cache/config-cache.json"),e=await n.readFile(c,"utf8");if(!e)throw new Error("Could not find config cache file");return JSON.parse(e)};exports.resolveDynamicConfigCache=i;
|
@@ -1,12 +1,10 @@
|
|
1
|
-
import { readFile as
|
2
|
-
import { join as
|
3
|
-
import { g as
|
1
|
+
import { readFile as r } from "fs/promises";
|
2
|
+
import { join as t } from "path";
|
3
|
+
import { g as n } from "../index-nYFJiyUY.js";
|
4
4
|
const s = async () => {
|
5
|
-
const e =
|
6
|
-
|
7
|
-
|
8
|
-
if (!c) throw new Error("Could not find config cache file");
|
9
|
-
return JSON.parse(c);
|
5
|
+
const e = n(), c = t(e, "cache/config-cache.json"), o = await r(c, "utf8");
|
6
|
+
if (!o) throw new Error("Could not find config cache file");
|
7
|
+
return JSON.parse(o);
|
10
8
|
};
|
11
9
|
export {
|
12
10
|
s as resolveDynamicConfigCache
|
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-styles-Bdgw_4ME.cjs");require("../parsers/index.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-styles-Bdgw_4ME.cjs");require("../parsers/index.cjs");const e=require("../index-De9SH8ms.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.getCorePackageRoot=e.getCorePackageRoot;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
@@ -6,7 +6,7 @@ import "fs";
|
|
6
6
|
import "fs/promises";
|
7
7
|
import "../parse-styles-C1E6ETeH.js";
|
8
8
|
import "../parsers/index.js";
|
9
|
-
import { f as F, e as y, b as c, c as f, g as x, i as C, m as S, s as E, d as R } from "../index-
|
9
|
+
import { f as F, e as y, b as c, c as f, g as x, i as C, m as S, s as E, d as R } from "../index-nYFJiyUY.js";
|
10
10
|
import "../css/merge.js";
|
11
11
|
import "../define-templates-4A2yHcMF.js";
|
12
12
|
export {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const Re=require("esbuild"),ve=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),
|
1
|
+
"use strict";const Re=require("esbuild"),ve=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),Se=require("fs/promises"),ce=require("./parse-styles-Bdgw_4ME.cjs"),he=require("./parsers/index.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),Ee=require("./define-templates-Cunsb_Tr.cjs"),re=require("typescript");var I=typeof document<"u"?document.currentScript:null;function Ve(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 je=Ve(Re),be=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:be(i.join(e,".."))},Me=async e=>{const t=be(e);return await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Je=async e=>{const t=await Me(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Je(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-De9SH8ms.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),qe=e=>{B.error(e)};function $e(e){return e?typeof e!="string"?$e(String(e)):e.replace(/[^\d\w]/g,"."):""}const ze={"*, *::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"}},He=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=re.createSourceFile("temp.ts",e,re.ScriptTarget.Latest,!0);function o(y){if(re.isVariableDeclaration(y)&&y.name.getText()===t){const S=y.getStart(),d=y.getEnd();clearTimeout(r),s([S,d])}y.forEachChild(o)}o(l)}),Ce=()=>{let{pathname:e}=new URL(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-De9SH8ms.cjs",document.baseURI).href);for(;/core\/?(src\/)?$/.test(e)===!1;)e=i.join(e,"../");return e},R={externalModules:[],rcFile:void 0,destDir:void 0},Pe=e=>{if(R.externalModules.length>0)return R.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return R.externalModules=n,n},q=async e=>{if(R.destDir)return R.destDir;const t=await fe(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},le=["salty","css","styles","styled"],Ne=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),ee=(e,t=[])=>Ne(t).test(e),xe=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):xe(i.join(e,".."))},fe=async e=>{var n,r;const t=await xe(e),s=(n=t.projects)==null?void 0:n.find(l=>e.endsWith(l.dir||""));return s||((r=t.projects)==null?void 0:r.find(l=>l.dir===t.defaultProject))},Ie=async e=>{const t=await fe(e),s=await q(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await Fe(e),o=Pe(n);await je.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const y=Date.now(),{config:S}=await import(`${r}?t=${y}`);return{config:S,path:r}},ke=async(e,t)=>{var me,ye;const s=await q(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:F,outputFilePath:G}=await A(e,w,s);Object.entries(F).forEach(([D,P])=>{P.isMedia?n.mediaQueries.push([D,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${D};;${G}`))})}));const{config:r,path:l}=await Ie(e),o={...r},{mediaQueries:y}=n;o.mediaQueries=Object.fromEntries(y.map(([w,F])=>[`@${w}`,F]));const S=y.map(([w])=>`'@${w}'`).join(" | "),d=new Set,a=async(w,F=[])=>{if(!w)return[];const G=Object.entries(w).map(async([P,M])=>{const K=async T=>{if(!T)return;if(T instanceof Promise)return await K(await T);if(typeof T=="function")return await K(await T());if(typeof T=="object")return await a(T,[...F,P]);const oe=$e(P),ie=_.dashCase(P),ae=[...F,oe].join(".");d.add(`"${ae}"`);const Z=[...F.map(_.dashCase),ie].join("-"),ge=ce.parseVariableTokens(T);return ge?`--${Z}: ${ge.transformed};`:`--${Z}: ${T};`};return await K(M)});return(await Promise.all(G)).flat()},g=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=await a(P);return D==="base"?M.join(""):o.mediaQueries[D]?`${o.mediaQueries[D]} { ${M.join("")} }`:`${D} { ${M.join("")} }`});return(await Promise.all(F)).flat()},m=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=Object.entries(P).map(async([T,oe])=>{const ie=await a(oe,[D]),ae=`.${D}-${T}, [data-${D}="${T}"]`,Z=ie.join("");return`${ae} { ${Z} }`});return(await Promise.all(M)).flat()});return(await Promise.all(F)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map(F=>w==="static"?h(F._current):F._current[w]),$=J.mergeObjects(h(r.variables),p("static")),x=await a($),k=J.mergeObjects((me=r.variables)==null?void 0:me.responsive,p("responsive")),v=await g(k),z=J.mergeObjects((ye=r.variables)==null?void 0:ye.conditional,p("conditional")),X=await m(z),de=i.join(s,"css/_variables.css"),E=`:root { ${x.join("")} ${v.join("")} } ${X.join("")}`;c.writeFileSync(de,E),o.staticVariables=$;const te=i.join(s,"css/_global.css"),u=J.mergeObjects(r.global,n.globalStyles),j=await ce.parseAndJoinStyles(u,"");c.writeFileSync(te,`@layer global { ${j} }`);const b=i.join(s,"css/_reset.css"),C=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:ze,N=await ce.parseAndJoinStyles(C,"");c.writeFileSync(b,`@layer reset { ${N} }`);const O=i.join(s,"css/_templates.css"),V=J.mergeObjects(r.templates,n.templates),L=await he.parseTemplates(V),W=he.getTemplateTypes(V);c.writeFileSync(O,`@layer templates { ${L} }`),o.templates=V;const Y=r.templates?[Ee.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],se=J.mergeFactories(n.templates,Y);o.templatePaths=Object.fromEntries(Object.entries(se).map(([w,F])=>[w,F._path]));const U=i.join(s,"types/css-tokens.d.ts"),De=`
|
2
2
|
// Variable types
|
3
3
|
type VariableTokens = ${[...d].join("|")};
|
4
4
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -11,11 +11,11 @@
|
|
11
11
|
|
12
12
|
// Media query types
|
13
13
|
type MediaQueryKeys = ${S||"''"};
|
14
|
-
`;c.writeFileSync(U,
|
14
|
+
`;c.writeFileSync(U,De);const Te=i.join(s,"cache/config-cache.json");c.writeFileSync(Te,JSON.stringify(o,null,2));const _e=Ce(),Oe=i.join(_e,"cache/config-cache.json");c.writeFileSync(Oe,JSON.stringify(o,null,2))},we=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const r=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!r.test(e))return t;const o=r.exec(e);if(o){const y=o.at(1);if(le.some(d=>y==null?void 0:y.includes(d)))return t}return"styled('div',"}),Le=(e,t)=>{try{const s=c.readFileSync(i.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
15
15
|
|
16
16
|
${e}`:`globalThis.saltyConfig = {};
|
17
17
|
|
18
|
-
${e}`}catch{return e}},A=async(e,t,s)=>{const n=_.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const l=i.parse(t);let o=c.readFileSync(t,"utf8");o=
|
18
|
+
${e}`}catch{return e}},A=async(e,t,s)=>{const n=_.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const l=i.parse(t);let o=c.readFileSync(t,"utf8");o=we(o),o=Le(o,e);const y=i.join(s,"js",n+".js"),S=await fe(e),d=i.join(e,(S==null?void 0:S.configDir)||"","salty.config.ts"),a=Pe(d),g=await Fe(e);await je.build({stdin:{contents:o,sourcefile:l.base,resolveDir:l.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:a,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},$=>{const x=c.readFileSync($.path,"utf8");return{contents:we(x),loader:"ts"}})}}]});const m=Date.now();return{contents:await import(`${y}?t=${m}`),outputFilePath:y}},We=async e=>{const t=await q(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ue=async e=>{const t=await We(e),s=await q(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:l}=await import(`${n}?t=${r}`);return J.mergeObjects(l,t)},pe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ue=async(e,t=pe(),s=!0)=>{try{const n=Date.now();t?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const r=[],l=[],o=await q(e),y=i.join(o,"index.css");s&&(()=>{c.existsSync(o)&&ve.execSync("rm -rf "+o),c.mkdirSync(o,{recursive:!0}),c.mkdirSync(i.join(o,"css")),c.mkdirSync(i.join(o,"types")),c.mkdirSync(i.join(o,"js")),c.mkdirSync(i.join(o,"cache"))})();const d=new Set,a=new Set;async function g(u){const j=["node_modules","saltygen"],b=c.statSync(u);if(b.isDirectory()){const f=c.readdirSync(u);if(j.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>g(i.join(u,N))))}else if(b.isFile()&&ee(u)){d.add(u);const C=c.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&a.add(u)}}await g(e),await ke(e,a);const m={keyframes:[],components:[],classNames:[]};await Promise.all([...d].map(async u=>{const{contents:j}=await A(e,u,o);for(let[b,f]of Object.entries(j))f instanceof Promise&&(f=await f),f.isKeyframes?m.keyframes.push({value:f,src:u,name:b}):f.isClassName?m.classNames.push({...f,src:u,name:b}):f.generator&&m.components.push({...f,src:u,name:b})}));const h=await ue(e);for(const u of m.keyframes){const{value:j}=u,b=`a_${j.animationName}.css`,f=`css/${b}`,C=i.join(o,f);r.push(b),c.writeFileSync(C,j.css)}const p={};for(const u of m.components){const{src:j,name:b}=u;p[j]||(p[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:h});l[f.priority]||(l[f.priority]=[]);const C=await f.css;if(!C)continue;l[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,O=i.join(o,N);c.writeFileSync(O,C),h.importStrategy==="component"&&p[j].push(f.cssFileName)}for(const u of m.classNames){const{src:j,name:b}=u;p[j]||(p[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:h}),C=await f.css;if(!C)continue;l[f.priority]||(l[f.priority]=[]),l[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,O=i.join(o,N);c.writeFileSync(O,C),h.importStrategy==="component"&&p[j].push(f.cssFileName)}h.importStrategy==="component"&&Object.entries(p).forEach(([u,j])=>{const b=j.map(V=>`@import url('./${V}');`).join(`
|
19
19
|
`),f=_.toHash(u,6),C=i.parse(u),N=_.dashCase(C.name),O=i.join(o,`css/f_${N}-${f}.css`);c.writeFileSync(O,b||"/* Empty file */")});const $=r.map(u=>`@import url('./css/${u}');`).join(`
|
20
20
|
`);let X=`/*!
|
21
21
|
* Generated with Salty CSS (https://salty-css.dev)
|
@@ -38,4 +38,4 @@ ${v}
|
|
38
38
|
${z}
|
39
39
|
}`}}),c.writeFileSync(g,m)});else{const S=l.flat().map(h=>`@import url('./${h}');`).join(`
|
40
40
|
`),d=_.toHash(t,6),a=i.parse(t),g=_.dashCase(a.name),m=i.join(n,`css/f_${g}-${d}.css`);c.writeFileSync(m,S||"/* Empty file */")}}}catch(n){console.error(n)}},Ke=async(e,t,s=pe())=>{var n,r;try{const l=await q(e);if(ee(t)){const y=c.readFileSync(t,"utf8"),S=await ue(e),{contents:d}=await A(e,t,l);let a=y;for(const[g,m]of Object.entries(d)){if(m.isKeyframes||!m.generator)continue;const h=m.generator._withBuildContext({callerName:g,isProduction:s,config:S}),[p,$]=await He(a,g),x=a.slice(p,$);if(m.isClassName){const k=a,v=` ${g} = className("${h.classNames}")`;a=a.replace(x,v),k===a&&console.error("Minimize file failed to change content",{name:g})}if(x.includes("styled")){const k=(r=(n=/styled\(([^,]+),/.exec(x))==null?void 0:n.at(1))==null?void 0:r.trim(),v=a,z=` ${g} = styled(${k}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;a=a.replace(x,z),v===a&&console.error("Minimize file failed to change content",{name:g,tagName:k})}}if(S.importStrategy==="component"){const g=_.toHash(t,6),m=i.parse(t);a=`import '../../saltygen/css/${`f_${_.dashCase(m.name)}-${g}.css`}';
|
41
|
-
${a}`}return a=a.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),a=a.replace("{ styled }","{ styledClient as styled }"),a=a.replace("@salty-css/react/styled","@salty-css/react/styled-client"),a}}catch(l){console.error("Error in minimizeFile:",l)}};exports.compileSaltyFile=A;exports.generateConfigStyles=
|
41
|
+
${a}`}return a=a.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),a=a.replace("{ styled }","{ styledClient as styled }"),a=a.replace("@salty-css/react/styled","@salty-css/react/styled-client"),a}}catch(l){console.error("Error in minimizeFile:",l)}};exports.compileSaltyFile=A;exports.generateConfigStyles=ke;exports.generateCss=Ue;exports.generateFile=Ge;exports.getCorePackageRoot=Ce;exports.isSaltyFile=ee;exports.logError=qe;exports.logger=B;exports.minimizeFile=Ke;exports.saltyFileExtensions=le;exports.saltyFileRegExp=Ne;
|
@@ -1,22 +1,22 @@
|
|
1
|
-
import * as
|
1
|
+
import * as St from "esbuild";
|
2
2
|
import { execSync as vt } from "child_process";
|
3
3
|
import { t as I, d as U } from "./dash-case-DBThphLm.js";
|
4
4
|
import { join as i, parse as tt } from "path";
|
5
5
|
import { existsSync as ft, writeFileSync as C, mkdirSync as G, readFileSync as _, statSync as Et, readdirSync as Ot } from "fs";
|
6
|
-
import { readFile as
|
7
|
-
import { p as
|
6
|
+
import { readFile as Ct } from "fs/promises";
|
7
|
+
import { p as $t, a as Rt } from "./parse-styles-C1E6ETeH.js";
|
8
8
|
import { parseTemplates as Mt, getTemplateTypes as Jt } from "./parsers/index.js";
|
9
9
|
import { createLogger as zt, format as rt, transports as Wt } from "winston";
|
10
10
|
import { mergeObjects as H, mergeFactories as Gt } from "./css/merge.js";
|
11
11
|
import { d as Ht } from "./define-templates-4A2yHcMF.js";
|
12
12
|
import lt from "typescript";
|
13
|
-
const
|
13
|
+
const Ft = (t) => {
|
14
14
|
if (!t || t === "/") throw new Error("Could not find package.json file");
|
15
15
|
const e = i(t, "package.json");
|
16
|
-
return ft(e) ? e :
|
16
|
+
return ft(e) ? e : Ft(i(t, ".."));
|
17
17
|
}, It = async (t) => {
|
18
|
-
const e =
|
19
|
-
return await
|
18
|
+
const e = Ft(t);
|
19
|
+
return await Ct(e, "utf-8").then(JSON.parse).catch(() => {
|
20
20
|
});
|
21
21
|
}, Kt = async (t) => {
|
22
22
|
const e = await It(t);
|
@@ -24,7 +24,7 @@ const jt = (t) => {
|
|
24
24
|
return e.type;
|
25
25
|
};
|
26
26
|
let W;
|
27
|
-
const
|
27
|
+
const Pt = async (t) => {
|
28
28
|
if (W) return W;
|
29
29
|
const e = await Kt(t);
|
30
30
|
return e === "module" ? W = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (W = "cjs"), W || "esm";
|
@@ -35,8 +35,8 @@ const Nt = async (t) => {
|
|
35
35
|
}), fe = (t) => {
|
36
36
|
Z.error(t);
|
37
37
|
};
|
38
|
-
function
|
39
|
-
return t ? typeof t != "string" ?
|
38
|
+
function jt(t) {
|
39
|
+
return t ? typeof t != "string" ? jt(String(t)) : t.replace(/[^\d\w]/g, ".") : "";
|
40
40
|
}
|
41
41
|
const Qt = {
|
42
42
|
/** Set box model to border-box */
|
@@ -105,7 +105,7 @@ const Qt = {
|
|
105
105
|
externalModules: [],
|
106
106
|
rcFile: void 0,
|
107
107
|
destDir: void 0
|
108
|
-
},
|
108
|
+
}, Nt = (t) => {
|
109
109
|
if (v.externalModules.length > 0) return v.externalModules;
|
110
110
|
const s = _(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
111
111
|
if (!s) return [];
|
@@ -115,19 +115,19 @@ const Qt = {
|
|
115
115
|
if (v.destDir) return v.destDir;
|
116
116
|
const e = await pt(t), s = i(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
117
117
|
return v.destDir = s, s;
|
118
|
-
},
|
118
|
+
}, xt = ["salty", "css", "styles", "styled"], qt = (t = []) => new RegExp(`\\.(${[...xt, ...t].join("|")})\\.`), mt = (t, e = []) => qt(e).test(t), Dt = async (t) => {
|
119
119
|
if (v.rcFile) return v.rcFile;
|
120
120
|
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
121
|
-
const e = i(t, ".saltyrc.json"), s = await
|
121
|
+
const e = i(t, ".saltyrc.json"), s = await Ct(e, "utf-8").then(JSON.parse).catch(() => {
|
122
122
|
});
|
123
|
-
return s ? (v.rcFile = s, s) :
|
123
|
+
return s ? (v.rcFile = s, s) : Dt(i(t, ".."));
|
124
124
|
}, pt = async (t) => {
|
125
125
|
var n, c;
|
126
|
-
const e = await
|
126
|
+
const e = await Dt(t), s = (n = e.projects) == null ? void 0 : n.find((r) => t.endsWith(r.dir || ""));
|
127
127
|
return s || ((c = e.projects) == null ? void 0 : c.find((r) => r.dir === e.defaultProject));
|
128
128
|
}, Ut = async (t) => {
|
129
|
-
const e = await pt(t), s = await J(t), n = i(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), c = i(s, "salty.config.js"), r = await
|
130
|
-
await
|
129
|
+
const e = await pt(t), s = await J(t), n = i(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), c = i(s, "salty.config.js"), r = await Pt(t), o = Nt(n);
|
130
|
+
await St.build({
|
131
131
|
entryPoints: [n],
|
132
132
|
minify: !0,
|
133
133
|
treeShaking: !0,
|
@@ -139,7 +139,7 @@ const Qt = {
|
|
139
139
|
const d = Date.now(), { config: w } = await import(`${c}?t=${d}`);
|
140
140
|
return { config: w, path: c };
|
141
141
|
}, At = async (t, e) => {
|
142
|
-
var
|
142
|
+
var gt, ht;
|
143
143
|
const s = await J(t), n = {
|
144
144
|
mediaQueries: [],
|
145
145
|
globalStyles: [],
|
@@ -149,8 +149,8 @@ const Qt = {
|
|
149
149
|
await Promise.all(
|
150
150
|
[...e].map(async (h) => {
|
151
151
|
const { contents: S, outputFilePath: B } = await et(t, h, s);
|
152
|
-
Object.entries(S).forEach(([
|
153
|
-
j.isMedia ? n.mediaQueries.push([
|
152
|
+
Object.entries(S).forEach(([k, j]) => {
|
153
|
+
j.isMedia ? n.mediaQueries.push([k, j]) : j.isGlobalDefine ? n.globalStyles.push(j) : j.isDefineVariables ? n.variables.push(j) : j.isDefineTemplates && n.templates.push(j._setPath(`${k};;${B}`));
|
154
154
|
});
|
155
155
|
})
|
156
156
|
);
|
@@ -164,42 +164,42 @@ const Qt = {
|
|
164
164
|
if (T instanceof Promise) return await q(await T);
|
165
165
|
if (typeof T == "function") return await q(await T());
|
166
166
|
if (typeof T == "object") return await a(T, [...S, j]);
|
167
|
-
const at =
|
167
|
+
const at = jt(j), it = U(j), ct = [...S, at].join(".");
|
168
168
|
p.add(`"${ct}"`);
|
169
|
-
const Y = [...S.map(U), it].join("-"),
|
170
|
-
return
|
169
|
+
const Y = [...S.map(U), it].join("-"), wt = Rt(T);
|
170
|
+
return wt ? `--${Y}: ${wt.transformed};` : `--${Y}: ${T};`;
|
171
171
|
};
|
172
172
|
return await q(M);
|
173
173
|
});
|
174
174
|
return (await Promise.all(B)).flat();
|
175
|
-
},
|
175
|
+
}, y = async (h) => {
|
176
176
|
if (!h) return [];
|
177
|
-
const S = Object.entries(h).map(async ([
|
177
|
+
const S = Object.entries(h).map(async ([k, j]) => {
|
178
178
|
const M = await a(j);
|
179
|
-
return
|
179
|
+
return k === "base" ? M.join("") : o.mediaQueries[k] ? `${o.mediaQueries[k]} { ${M.join("")} }` : `${k} { ${M.join("")} }`;
|
180
180
|
});
|
181
181
|
return (await Promise.all(S)).flat();
|
182
182
|
}, u = async (h) => {
|
183
183
|
if (!h) return [];
|
184
|
-
const S = Object.entries(h).map(async ([
|
184
|
+
const S = Object.entries(h).map(async ([k, j]) => {
|
185
185
|
const M = Object.entries(j).map(async ([T, at]) => {
|
186
|
-
const it = await a(at, [
|
186
|
+
const it = await a(at, [k]), ct = `.${k}-${T}, [data-${k}="${T}"]`, Y = it.join("");
|
187
187
|
return `${ct} { ${Y} }`;
|
188
188
|
});
|
189
189
|
return (await Promise.all(M)).flat();
|
190
190
|
});
|
191
191
|
return (await Promise.all(S)).flat();
|
192
|
-
},
|
193
|
-
C(
|
194
|
-
const st = i(s, "css/_global.css"), f = H(c.global, n.globalStyles), $ = await
|
192
|
+
}, g = (h) => ({ ...h, responsive: void 0, conditional: void 0 }), m = (h) => n.variables.map((S) => h === "static" ? g(S._current) : S._current[h]), F = H(g(c.variables), m("static")), x = await a(F), D = H((gt = c.variables) == null ? void 0 : gt.responsive, m("responsive")), E = await y(D), z = H((ht = c.variables) == null ? void 0 : ht.conditional, m("conditional")), A = await u(z), yt = i(s, "css/_variables.css"), O = `:root { ${x.join("")} ${E.join("")} } ${A.join("")}`;
|
193
|
+
C(yt, O), o.staticVariables = F;
|
194
|
+
const st = i(s, "css/_global.css"), f = H(c.global, n.globalStyles), $ = await $t(f, "");
|
195
195
|
C(st, `@layer global { ${$} }`);
|
196
|
-
const b = i(s, "css/_reset.css"), P = c.reset === "none" ? {} : typeof c.reset == "object" ? c.reset : Qt, N = await
|
196
|
+
const b = i(s, "css/_reset.css"), P = c.reset === "none" ? {} : typeof c.reset == "object" ? c.reset : Qt, N = await $t(P, "");
|
197
197
|
C(b, `@layer reset { ${N} }`);
|
198
198
|
const V = i(s, "css/_templates.css"), R = H(c.templates, n.templates), K = await Mt(R), Q = Jt(R);
|
199
199
|
C(V, `@layer templates { ${K} }`), o.templates = R;
|
200
200
|
const X = c.templates ? [Ht(c.templates)._setPath(`config;;${r}`)] : [], nt = Gt(n.templates, X);
|
201
201
|
o.templatePaths = Object.fromEntries(Object.entries(nt).map(([h, S]) => [h, S._path]));
|
202
|
-
const L = i(s, "types/css-tokens.d.ts"),
|
202
|
+
const L = i(s, "types/css-tokens.d.ts"), kt = `
|
203
203
|
// Variable types
|
204
204
|
type VariableTokens = ${[...p].join("|")};
|
205
205
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -213,21 +213,19 @@ const Qt = {
|
|
213
213
|
// Media query types
|
214
214
|
type MediaQueryKeys = ${w || "''"};
|
215
215
|
`;
|
216
|
-
C(L,
|
217
|
-
const
|
216
|
+
C(L, kt);
|
217
|
+
const Tt = i(s, "cache/config-cache.json");
|
218
|
+
C(Tt, JSON.stringify(o, null, 2));
|
219
|
+
const _t = Bt(), Vt = i(_t, "cache/config-cache.json");
|
218
220
|
C(Vt, JSON.stringify(o, null, 2));
|
219
|
-
|
220
|
-
console.log("corePackageRoot", yt);
|
221
|
-
const ht = i(yt, "cache/config-cache.json");
|
222
|
-
console.log("Config cache secondary path", ht), C(ht, JSON.stringify(o, null, 2));
|
223
|
-
}, Ct = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
221
|
+
}, bt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
224
222
|
if (/^['"`]/.test(s)) return e;
|
225
223
|
const c = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
226
224
|
if (!c.test(t)) return e;
|
227
225
|
const o = c.exec(t);
|
228
226
|
if (o) {
|
229
227
|
const d = o.at(1);
|
230
|
-
if (
|
228
|
+
if (xt.some((p) => d == null ? void 0 : d.includes(p))) return e;
|
231
229
|
}
|
232
230
|
return "styled('div',";
|
233
231
|
}), Xt = (t, e) => {
|
@@ -246,9 +244,9 @@ ${t}`;
|
|
246
244
|
ft(c) || G(c);
|
247
245
|
const r = tt(e);
|
248
246
|
let o = _(e, "utf8");
|
249
|
-
o =
|
250
|
-
const d = i(s, "js", n + ".js"), w = await pt(t), p = i(t, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), a =
|
251
|
-
await
|
247
|
+
o = bt(o), o = Xt(o, t);
|
248
|
+
const d = i(s, "js", n + ".js"), w = await pt(t), p = i(t, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), a = Nt(p), y = await Pt(t);
|
249
|
+
await St.build({
|
252
250
|
stdin: {
|
253
251
|
contents: o,
|
254
252
|
sourcefile: r.base,
|
@@ -259,7 +257,7 @@ ${t}`;
|
|
259
257
|
treeShaking: !0,
|
260
258
|
bundle: !0,
|
261
259
|
outfile: d,
|
262
|
-
format:
|
260
|
+
format: y,
|
263
261
|
target: ["node20"],
|
264
262
|
keepNames: !0,
|
265
263
|
external: a,
|
@@ -270,7 +268,7 @@ ${t}`;
|
|
270
268
|
setup: (m) => {
|
271
269
|
m.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (F) => {
|
272
270
|
const x = _(F.path, "utf8");
|
273
|
-
return { contents:
|
271
|
+
return { contents: bt(x), loader: "ts" };
|
274
272
|
});
|
275
273
|
}
|
276
274
|
}
|
@@ -300,19 +298,19 @@ ${t}`;
|
|
300
298
|
ft(o) && vt("rm -rf " + o), G(o, { recursive: !0 }), G(i(o, "css")), G(i(o, "types")), G(i(o, "js")), G(i(o, "cache"));
|
301
299
|
})();
|
302
300
|
const p = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
303
|
-
async function
|
301
|
+
async function y(f) {
|
304
302
|
const $ = ["node_modules", "saltygen"], b = Et(f);
|
305
303
|
if (b.isDirectory()) {
|
306
304
|
const l = Ot(f);
|
307
305
|
if ($.some((N) => f.includes(N))) return;
|
308
|
-
await Promise.all(l.map((N) =>
|
306
|
+
await Promise.all(l.map((N) => y(i(f, N))));
|
309
307
|
} else if (b.isFile() && mt(f)) {
|
310
308
|
p.add(f);
|
311
309
|
const P = _(f, "utf8");
|
312
310
|
/define[\w\d]+\(/.test(P) && a.add(f);
|
313
311
|
}
|
314
312
|
}
|
315
|
-
await
|
313
|
+
await y(t), await At(t, a);
|
316
314
|
const u = {
|
317
315
|
keyframes: [],
|
318
316
|
components: [],
|
@@ -337,7 +335,7 @@ ${t}`;
|
|
337
335
|
});
|
338
336
|
})
|
339
337
|
);
|
340
|
-
const
|
338
|
+
const g = await ut(t);
|
341
339
|
for (const f of u.keyframes) {
|
342
340
|
const { value: $ } = f, b = `a_${$.animationName}.css`, l = `css/${b}`, P = i(o, l);
|
343
341
|
c.push(b), C(P, $.css);
|
@@ -349,14 +347,14 @@ ${t}`;
|
|
349
347
|
const l = f.generator._withBuildContext({
|
350
348
|
callerName: b,
|
351
349
|
isProduction: e,
|
352
|
-
config:
|
350
|
+
config: g
|
353
351
|
});
|
354
352
|
r[l.priority] || (r[l.priority] = []);
|
355
353
|
const P = await l.css;
|
356
354
|
if (!P) continue;
|
357
355
|
r[l.priority].push(l.cssFileName);
|
358
356
|
const N = `css/${l.cssFileName}`, V = i(o, N);
|
359
|
-
C(V, P),
|
357
|
+
C(V, P), g.importStrategy === "component" && m[$].push(l.cssFileName);
|
360
358
|
}
|
361
359
|
for (const f of u.classNames) {
|
362
360
|
const { src: $, name: b } = f;
|
@@ -364,14 +362,14 @@ ${t}`;
|
|
364
362
|
const l = f.generator._withBuildContext({
|
365
363
|
callerName: b,
|
366
364
|
isProduction: e,
|
367
|
-
config:
|
365
|
+
config: g
|
368
366
|
}), P = await l.css;
|
369
367
|
if (!P) continue;
|
370
368
|
r[l.priority] || (r[l.priority] = []), r[l.priority].push(l.cssFileName);
|
371
369
|
const N = `css/${l.cssFileName}`, V = i(o, N);
|
372
|
-
C(V, P),
|
370
|
+
C(V, P), g.importStrategy === "component" && m[$].push(l.cssFileName);
|
373
371
|
}
|
374
|
-
|
372
|
+
g.importStrategy === "component" && Object.entries(m).forEach(([f, $]) => {
|
375
373
|
const b = $.map((R) => `@import url('./${R}');`).join(`
|
376
374
|
`), l = I(f, 6), P = tt(f), N = U(P.name), V = i(o, `css/f_${N}-${l}.css`);
|
377
375
|
C(V, b || "/* Empty file */");
|
@@ -395,7 +393,7 @@ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) =
|
|
395
393
|
`
|
396
394
|
)}
|
397
395
|
${F}`;
|
398
|
-
if (
|
396
|
+
if (g.importStrategy !== "component") {
|
399
397
|
const f = r.reduce(($, b, l) => {
|
400
398
|
const P = b.reduce((K, Q) => {
|
401
399
|
var ot;
|
@@ -437,8 +435,8 @@ ${nt}
|
|
437
435
|
}), F = await m.css;
|
438
436
|
if (!F) continue;
|
439
437
|
r[m.priority] || (r[m.priority] = []), r[m.priority].push(m.cssFileName);
|
440
|
-
const x = `css/${m.cssFileName}`,
|
441
|
-
C(
|
438
|
+
const x = `css/${m.cssFileName}`, D = i(n, x);
|
439
|
+
C(D, F);
|
442
440
|
continue;
|
443
441
|
}
|
444
442
|
if (!p.generator) continue;
|
@@ -446,20 +444,20 @@ ${nt}
|
|
446
444
|
callerName: w,
|
447
445
|
isProduction: s,
|
448
446
|
config: o
|
449
|
-
}),
|
450
|
-
if (!
|
451
|
-
const u = `css/${a.cssFileName}`,
|
452
|
-
C(
|
447
|
+
}), y = await a.css;
|
448
|
+
if (!y) continue;
|
449
|
+
const u = `css/${a.cssFileName}`, g = i(n, u);
|
450
|
+
C(g, y), r[a.priority] || (r[a.priority] = []), r[a.priority].push(a.cssFileName);
|
453
451
|
}
|
454
452
|
if (o.importStrategy !== "component")
|
455
453
|
r.forEach((w, p) => {
|
456
|
-
const a = `l_${p}.css`,
|
457
|
-
let u = _(
|
458
|
-
w.forEach((
|
459
|
-
var
|
460
|
-
const m = i(n, "css",
|
454
|
+
const a = `l_${p}.css`, y = i(n, "css", a);
|
455
|
+
let u = _(y, "utf8");
|
456
|
+
w.forEach((g) => {
|
457
|
+
var D;
|
458
|
+
const m = i(n, "css", g), F = ((D = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : D.at(1)) || I(m, 6);
|
461
459
|
if (!u.includes(F)) {
|
462
|
-
const E = _(m, "utf8"), z = `/*start:${F}-${
|
460
|
+
const E = _(m, "utf8"), z = `/*start:${F}-${g}*/
|
463
461
|
${E}
|
464
462
|
/*end:${F}*/
|
465
463
|
`;
|
@@ -467,11 +465,11 @@ ${E}
|
|
467
465
|
${z}
|
468
466
|
}`;
|
469
467
|
}
|
470
|
-
}), C(
|
468
|
+
}), C(y, u);
|
471
469
|
});
|
472
470
|
else {
|
473
|
-
const w = r.flat().map((
|
474
|
-
`), p = I(e, 6), a = tt(e),
|
471
|
+
const w = r.flat().map((g) => `@import url('./${g}');`).join(`
|
472
|
+
`), p = I(e, 6), a = tt(e), y = U(a.name), u = i(n, `css/f_${y}-${p}.css`);
|
475
473
|
C(u, w || "/* Empty file */");
|
476
474
|
}
|
477
475
|
}
|
@@ -485,25 +483,25 @@ ${z}
|
|
485
483
|
if (mt(e)) {
|
486
484
|
const d = _(e, "utf8"), w = await ut(t), { contents: p } = await et(t, e, r);
|
487
485
|
let a = d;
|
488
|
-
for (const [
|
486
|
+
for (const [y, u] of Object.entries(p)) {
|
489
487
|
if (u.isKeyframes || !u.generator) continue;
|
490
|
-
const
|
491
|
-
callerName:
|
488
|
+
const g = u.generator._withBuildContext({
|
489
|
+
callerName: y,
|
492
490
|
isProduction: s,
|
493
491
|
config: w
|
494
|
-
}), [m, F] = await Lt(a,
|
492
|
+
}), [m, F] = await Lt(a, y), x = a.slice(m, F);
|
495
493
|
if (u.isClassName) {
|
496
|
-
const
|
497
|
-
a = a.replace(x, E),
|
494
|
+
const D = a, E = ` ${y} = className("${g.classNames}")`;
|
495
|
+
a = a.replace(x, E), D === a && console.error("Minimize file failed to change content", { name: y });
|
498
496
|
}
|
499
497
|
if (x.includes("styled")) {
|
500
|
-
const
|
501
|
-
a = a.replace(x, z), E === a && console.error("Minimize file failed to change content", { name:
|
498
|
+
const D = (c = (n = /styled\(([^,]+),/.exec(x)) == null ? void 0 : n.at(1)) == null ? void 0 : c.trim(), E = a, z = ` ${y} = styled(${D}, "${g.classNames}", ${JSON.stringify(g.clientProps)})`;
|
499
|
+
a = a.replace(x, z), E === a && console.error("Minimize file failed to change content", { name: y, tagName: D });
|
502
500
|
}
|
503
501
|
}
|
504
502
|
if (w.importStrategy === "component") {
|
505
|
-
const
|
506
|
-
a = `import '../../saltygen/css/${`f_${U(u.name)}-${
|
503
|
+
const y = I(e, 6), u = tt(e);
|
504
|
+
a = `import '../../saltygen/css/${`f_${U(u.name)}-${y}.css`}';
|
507
505
|
${a}`;
|
508
506
|
}
|
509
507
|
return a = a.replace("@salty-css/react/class-name", "@salty-css/react/class-name-client"), a = a.replace("{ styled }", "{ styledClient as styled }"), a = a.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), a;
|
@@ -523,5 +521,5 @@ export {
|
|
523
521
|
mt as i,
|
524
522
|
Z as l,
|
525
523
|
ue as m,
|
526
|
-
|
524
|
+
xt as s
|
527
525
|
};
|
package/package.json
CHANGED
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-9v8CVeO9.cjs");exports.checkShouldRestart=e.checkShouldRestart;
|
package/server/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const s=require("fs/promises"),r=require("./index-
|
1
|
+
"use strict";const s=require("fs/promises"),r=require("./index-De9SH8ms.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!(/.+define[A-Z]\w+/.test(e)||/.+keyframes\(.+/.test(e))};exports.checkShouldRestart=i;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { readFile as r } from "fs/promises";
|
2
|
-
import { i as e } from "./index-
|
2
|
+
import { i as e } from "./index-nYFJiyUY.js";
|
3
3
|
const f = async (t) => {
|
4
4
|
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
5
|
if (t.includes("salty.config")) return !0;
|