@salty-css/core 0.0.1-alpha.253 → 0.0.1-alpha.255
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/README.md +1 -1
- package/bin/main.cjs +4 -4
- package/bin/main.js +125 -125
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +13 -13
- package/{index-D_yT1YG2.js → index-aCAHSJBW.js} +96 -96
- package/{index-Bh0Rdc9S.cjs → index-oCwSpzG5.cjs} +11 -11
- package/package.json +1 -1
- package/parse-styles-BT4aa1vH.cjs +5 -0
- package/parse-styles-DkygSsSC.js +137 -0
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-tiWPsnY8.js → should-restart-D2s1tQrI.js} +1 -1
- package/{should-restart-Crlwi2VJ.cjs → should-restart-HvsS0CW1.cjs} +1 -1
- package/parse-styles-BBLk1gXe.js +0 -137
- package/parse-styles-bvJ5u1by.cjs +0 -5
package/README.md
CHANGED
@@ -242,7 +242,7 @@ Example usage:
|
|
242
242
|
styled('span', {
|
243
243
|
base: {
|
244
244
|
// Use of static font family variable
|
245
|
-
fontFamily: '{
|
245
|
+
fontFamily: '{fontFamily.heading}',
|
246
246
|
// Use of responsive font size variable
|
247
247
|
fontSize: '{fontSize.heading.regular}',
|
248
248
|
// Use of conditional theme text color variable
|
package/bin/main.cjs
CHANGED
@@ -1,11 +1,11 @@
|
|
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-oCwSpzG5.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-HvsS0CW1.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,v)=>{se.exec(y,x=>{if(x)return v(x);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),v=oe(`Installing packages: ${C}`).start(),x=y.join(" ");await X(`npm install ${x}`),v.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"))},v=async(i,a)=>{const{default:g}=await C[i],d=ne.render(g,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,g=process.cwd();return n.join(g,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:g=i,cssFile:d,skipInstall:p}=this.opts();if(!g)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(g),q=await Promise.all([v("salty.config.ts"),v("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"),f=await s.readFile(h,"utf-8").catch(()=>{});if(f===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(f),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!==f&&(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
|
5
5
|
`)));const F=["src","public","assets","styles","css","app"],W=["styles","css","app","pages"],M=["index","styles","main","app","global","globals"],U=[".css",".scss",".sass"],E=await(async()=>{if(d)return d;for(const t of F)for(const u of M)for(const l of U){const o=n.join(r,t,u+l);if(await s.readFile(o,"utf-8").catch(()=>{})!==void 0)return n.relative(r,o);for(const O of W){const R=n.join(r,t,O,u+l);if(await s.readFile(R,"utf-8").catch(()=>{})!==void 0)return n.relative(r,R)}}})();if(E){const t=n.join(r,E),u=await s.readFile(t,"utf-8").catch(()=>{});if(u!==void 0&&!u.includes("saltygen")){const o=n.join(t,".."),O=`@import '${n.relative(o,n.join(r,"saltygen/index.css"))}';`;e.logger.info("Adding global import statement to CSS file: "+t),await s.writeFile(t,O+`
|
6
|
-
`+u),await S(t)}}else e.logger.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const Z={projectJs:n.join(r,"eslint.config.js"),rootJs:n.join(c,"eslint.config.js"),projectMjs:n.join(r,"eslint.config.mjs"),rootMjs:n.join(c,"eslint.config.mjs"),projectJson:n.join(r,".eslintrc.json"),rootJson:n.join(c,".eslintrc.json")},
|
7
|
-
${t}`;t.includes("typescript-eslint")?o.includes(".config(")?o=o.replace(".config(",".config(saltyCss,"):e.logger.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."):o.includes("export default [")?o=o.replace("export default [","export default [ saltyCss,"):o.includes("eslintConfig = [")?o=o.replace("eslintConfig = [","eslintConfig = [ saltyCss,"):e.logger.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."),await s.writeFile(
|
6
|
+
`+u),await S(t)}}else e.logger.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const Z={projectJs:n.join(r,"eslint.config.js"),rootJs:n.join(c,"eslint.config.js"),projectMjs:n.join(r,"eslint.config.mjs"),rootMjs:n.join(c,"eslint.config.mjs"),projectJson:n.join(r,".eslintrc.json"),rootJson:n.join(c,".eslintrc.json")},P=Object.values(Z).find(t=>A.existsSync(t));if(P){p||await I(D.eslintConfigCore);const t=await s.readFile(P,"utf-8").catch(()=>{});if(!t)return e.logError("Could not read ESLint config file.");if(!t.includes("salty-css"))if(e.logger.info("Edit file: "+P),P.endsWith("js")){let o=`import saltyCss from "@salty-css/eslint-config-core/flat";
|
7
|
+
${t}`;t.includes("typescript-eslint")?o.includes(".config(")?o=o.replace(".config(",".config(saltyCss,"):e.logger.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."):o.includes("export default [")?o=o.replace("export default [","export default [ saltyCss,"):o.includes("eslintConfig = [")?o=o.replace("eslintConfig = [","eslintConfig = [ saltyCss,"):e.logger.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."),await s.writeFile(P,o),await S(P)}else{const l=JSON.parse(t);l.extends||(l.extends=[]),l.extends.push("@salty-css/core");const o=JSON.stringify(l,null,2);await s.writeFile(P,o),await S(P)}}const L=n.join(r,"vite.config.ts"),z=await s.readFile(L,"utf-8").catch(()=>{});if(z!==void 0&&!z.includes("saltyPlugin")){e.logger.info("Edit file: "+L);const u=`import { saltyPlugin } from '@salty-css/vite';
|
8
8
|
`,o=z.replace(/(plugins: \[)/,`$1
|
9
9
|
saltyPlugin(__dirname),`);p||await I(`-D ${D.vite}`),e.logger.info("Adding Salty-CSS plugin to Vite config..."),await s.writeFile(L,u+o),await S(L)}const _=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(t=>n.join(r,t)).find(t=>A.existsSync(t));if(_){let t=await s.readFile(_,"utf-8").catch(()=>{});if(t!==void 0&&!t.includes("withSaltyCss")){let l=!1;/\splugins([^=]*)=[^[]\[/.test(t)&&!l&&(t=t.replace(/\splugins([^=]*)=[^[]\[/,(R,J)=>` plugins${J}= [withSaltyCss,`),l=!0);const k=t.includes("module.exports"),O=k?`const { withSaltyCss } = require('@salty-css/next');
|
10
10
|
`:`import { withSaltyCss } from '@salty-css/next';
|
11
|
-
`;k&&!l?(t=t.replace(/module.exports = ([^;]+)/,(R,J)=>`module.exports = withSaltyCss(${J})`),l=!0):l||(t=t.replace(/export default ([^;]+)/,(R,J)=>`export default withSaltyCss(${J})`)),p||await I(`-D ${D.next}`),e.logger.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(_,O+t),await S(_)}}const ee=await N().catch(()=>e.logError("Could not read package.json file.")).then(t=>(t.scripts||(t.scripts={}),t.scripts.prepare?t.scripts.prepare.includes("salty-css")||(e.logger.info("Edit file: "+b),t.scripts.prepare=t.scripts.prepare+" && npx salty-css build"):(e.logger.info("Edit file: "+b),t.scripts.prepare="npx salty-css build"),t));await Y(ee),e.logger.info("Running the build to generate initial CSS..."),await e.generateCss(r),e.logger.info("🎉 Salty CSS project initialized successfully!"),e.logger.info("Next steps:"),e.logger.info("1. Configure variables and templates in `salty.config.ts`"),e.logger.info("2. Create a new component with `npx salty-css generate [component-name]`"),e.logger.info("3. Run `npx salty-css build` to generate the CSS"),e.logger.info("4. Read about the features in the documentation: https://salty-css.dev"),e.logger.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐")}),y.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").option("--watch","Watch for changes and rebuild the project.").action(async function(i=V){e.logger.info("Building the Salty-CSS project...");const{dir:a=i,watch:
|
11
|
+
`;k&&!l?(t=t.replace(/module.exports = ([^;]+)/,(R,J)=>`module.exports = withSaltyCss(${J})`),l=!0):l||(t=t.replace(/export default ([^;]+)/,(R,J)=>`export default withSaltyCss(${J})`)),p||await I(`-D ${D.next}`),e.logger.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(_,O+t),await S(_)}}const ee=await N().catch(()=>e.logError("Could not read package.json file.")).then(t=>(t.scripts||(t.scripts={}),t.scripts.prepare?t.scripts.prepare.includes("salty-css")||(e.logger.info("Edit file: "+b),t.scripts.prepare=t.scripts.prepare+" && npx salty-css build"):(e.logger.info("Edit file: "+b),t.scripts.prepare="npx salty-css build"),t));await Y(ee),e.logger.info("Running the build to generate initial CSS..."),await e.generateCss(r),e.logger.info("🎉 Salty CSS project initialized successfully!"),e.logger.info("Next steps:"),e.logger.info("1. Configure variables and templates in `salty.config.ts`"),e.logger.info("2. Create a new component with `npx salty-css generate [component-name]`"),e.logger.info("3. Run `npx salty-css build` to generate the CSS"),e.logger.info("4. Read about the features in the documentation: https://salty-css.dev"),e.logger.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐")}),y.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").option("--watch","Watch for changes and rebuild the project.").action(async function(i=V){e.logger.info("Building the Salty-CSS project...");const{dir:a=i,watch:g}=this.opts();if(!a)return e.logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const d=H(a);await e.generateCss(d),g&&(e.logger.info("Watching for changes in the project directory..."),A.watch(d,{recursive:!0},async(p,c)=>{await ae.checkShouldRestart(c)?await e.generateCss(d,!1,!1):e.isSaltyFile(c)&&await e.generateFile(d,c)}))}),y.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>","File to generate.").option("-d, --dir <dir>","Project directory to generate the file in.").option("-t, --tag <tag>","HTML tag of the component.","div").option("-n, --name <name>","Name of the component.").option("-c, --className <className>","CSS class of the component.").option("-r, --reactComponent","Generate a React component as well.").action(async function(i,a=V){const{file:g=i,dir:d=a,tag:p,name:c,className:r,reactComponent:q=!1}=this.opts();if(!g)return e.logError("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!d)return e.logError("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const m=H(d),w=g.split("/").slice(0,-1).join("/");w&&await s.mkdir(n.join(m,w),{recursive:!0});const h=n.join(m,g),f=n.parse(h);f.ext||(f.ext=".ts"),f.name.endsWith(".css")||(f.name=f.name+".css"),f.base=f.name+f.ext;const j=n.format(f);if(await s.readFile(j,"utf-8").catch(()=>{})!==void 0){e.logger.error("File already exists:",j);return}let F=ie.pascalCase(c||f.base.replace(/\.css\.\w+$/,""));if(q){const M=F+"Component";F=F+"Wrapper";const U=f.base.replace(/\.css\.\w+$/,""),{content:Q}=await v("react/react-vanilla-file.ts",{tag:p,componentName:M,styledComponentName:F,className:r,fileName:U});f.name=U.replace(/\.css$/,""),f.ext=".tsx",f.base=f.name+f.ext;const E=n.format(f);e.logger.info("Generating a new file: "+E),await s.writeFile(E,Q),await S(E)}const{content:W}=await v("react/react-styled-file.ts",{tag:p,name:F,className:r});e.logger.info("Generating a new file: "+j),await s.writeFile(j,W),await S(j)});const K=async()=>{const i=n.join(process.cwd(),"package.json"),a=await N(i).catch(p=>e.logError(p));if(!a)return e.logError("Could not read package.json file.");const g={...a.dependencies,...a.devDependencies},d=Object.entries(g).filter(([p])=>p==="salty-css"||p.startsWith("@salty-css/"));return d.length?d:e.logError("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+i)};y.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>","Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(i="latest"){const{legacyPeerDeps:a,version:g=i}=this.opts(),d=await K();if(!d)return e.logError("Could not update Salty-CSS packages as any were found in package.json.");const p=d.map(([m])=>g==="@"?`${m}@${$.version}`:`${m}@${g.replace(/^@/,"")}`);a?(e.logger.warn("Using legacy peer dependencies to update packages."),await I(...p,"--legacy-peer-deps")):await I(...p);const c=await K();if(!c)return e.logError("Something went wrong while reading the updated packages.");const r=c.reduce((m,[w,h])=>(m[h]||(m[h]=[]),m[h].push(w),m),{});if(Object.keys(r).length===1){const w=Object.keys(r)[0].replace(/^\^/,"");e.logger.info(`Updated to all Salty CSS packages successfully to ${w}`)}else for(const[m,w]of Object.entries(r)){const h=m.replace(/^\^/,"");e.logger.info(`Updated to ${h}: ${w.join(", ")}`)}}),y.option("-v, --version","Show the current version of Salty-CSS.").action(async function(){const i=await B();e.logger.info("CLI is running: "+i.version);const a=n.join(process.cwd(),"package.json"),g=await N(a).catch(c=>e.logError(c));if(!g)return;const d={...g.dependencies,...g.devDependencies},p=Object.keys(d).filter(c=>c==="salty-css"||c.startsWith("@salty-css/"));if(!p.length)return e.logError("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+a);for(const c of p)e.logger.info(`${c}: ${d[c]}`)}),y.parseAsync(process.argv)}exports.main=ce;
|
package/bin/main.js
CHANGED
@@ -1,91 +1,91 @@
|
|
1
|
-
import { Command as
|
2
|
-
import { existsSync as Q, watch as
|
1
|
+
import { Command as ot } from "commander";
|
2
|
+
import { existsSync as Q, watch as rt } from "fs";
|
3
3
|
import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
|
4
|
-
import { join as a, relative as z, parse as
|
5
|
-
import { render as
|
6
|
-
import { l as
|
7
|
-
import { p as
|
8
|
-
import { exec as
|
9
|
-
import
|
10
|
-
import { c as
|
11
|
-
const
|
12
|
-
|
13
|
-
if ($) return
|
14
|
-
|
4
|
+
import { join as a, relative as z, parse as ct, format as et } from "path";
|
5
|
+
import { render as lt } from "ejs";
|
6
|
+
import { l as e, a as h, g as K, i as dt, b as ft } from "../index-aCAHSJBW.js";
|
7
|
+
import { p as pt } from "../pascal-case-BQpR5PdN.js";
|
8
|
+
import { exec as gt } from "child_process";
|
9
|
+
import ut from "ora";
|
10
|
+
import { c as yt } from "../should-restart-D2s1tQrI.js";
|
11
|
+
const st = (u) => new Promise((v, k) => {
|
12
|
+
gt(u, ($) => {
|
13
|
+
if ($) return k($);
|
14
|
+
v();
|
15
15
|
});
|
16
|
-
}), E = async (...
|
17
|
-
const
|
18
|
-
await
|
19
|
-
},
|
20
|
-
async function j(
|
16
|
+
}), E = async (...u) => {
|
17
|
+
const v = u.map((J) => J.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), k = ut(`Installing packages: ${v}`).start(), $ = u.join(" ");
|
18
|
+
await st(`npm install ${$}`), k.succeed(`Installed packages: ${v}`);
|
19
|
+
}, mt = () => Q(a(process.cwd(), "node_modules", ".bin", "prettier"));
|
20
|
+
async function j(u) {
|
21
21
|
try {
|
22
|
-
if (!
|
23
|
-
await
|
24
|
-
} catch (
|
25
|
-
|
22
|
+
if (!mt()) return;
|
23
|
+
await st(`./node_modules/.bin/prettier --write "${u}"`), e.info(`Formatted ${u} with Prettier`);
|
24
|
+
} catch (v) {
|
25
|
+
e.error(`Error formatting ${u} with Prettier:`, v);
|
26
26
|
}
|
27
27
|
}
|
28
|
-
async function
|
29
|
-
const
|
30
|
-
|
31
|
-
const
|
28
|
+
async function Jt() {
|
29
|
+
const u = new ot();
|
30
|
+
u.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
|
31
|
+
const v = {
|
32
32
|
// Core files
|
33
33
|
"salty.config.ts": import("../salty.config-BhBY_oOk.js"),
|
34
34
|
"saltygen/index.css": import("../index-D_732b92.js"),
|
35
35
|
// React
|
36
36
|
"react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js"),
|
37
37
|
"react/react-vanilla-file.ts": import("../react-vanilla-file-CCXbsjIb.js")
|
38
|
-
},
|
39
|
-
const { default: d } = await
|
40
|
-
return { fileName:
|
38
|
+
}, k = async (s, i) => {
|
39
|
+
const { default: d } = await v[s], l = lt(d, i);
|
40
|
+
return { fileName: s, content: l };
|
41
41
|
}, $ = async () => {
|
42
|
-
const
|
43
|
-
return await S(
|
44
|
-
}, J = a(process.cwd(), "package.json"), O = async (
|
45
|
-
const i = await S(
|
42
|
+
const s = a(process.cwd(), ".saltyrc.json");
|
43
|
+
return await S(s, "utf-8").then(JSON.parse).catch(() => ({}));
|
44
|
+
}, J = a(process.cwd(), "package.json"), O = async (s = J) => {
|
45
|
+
const i = await S(s, "utf-8").then(JSON.parse).catch(() => {
|
46
46
|
});
|
47
47
|
if (!i) throw "Could not read package.json file!";
|
48
48
|
return i;
|
49
|
-
},
|
50
|
-
typeof
|
49
|
+
}, nt = async (s, i = J) => {
|
50
|
+
typeof s == "object" && (s = JSON.stringify(s, null, 2)), await C(i, s);
|
51
51
|
}, X = async () => {
|
52
|
-
const
|
53
|
-
return O(
|
52
|
+
const s = new URL("../package.json", import.meta.url);
|
53
|
+
return O(s);
|
54
54
|
}, Y = await (async () => (await $()).defaultProject)(), N = await X(), A = {
|
55
55
|
core: `@salty-css/core@${N.version}`,
|
56
56
|
react: `@salty-css/react@${N.version}`,
|
57
57
|
eslintConfigCore: `@salty-css/eslint-config-core@${N.version}`,
|
58
58
|
vite: `@salty-css/vite@${N.version}`,
|
59
59
|
next: `@salty-css/next@${N.version}`
|
60
|
-
}, G = (
|
61
|
-
const i =
|
60
|
+
}, G = (s) => {
|
61
|
+
const i = s === "." ? "" : s, d = process.cwd();
|
62
62
|
return a(d, i);
|
63
63
|
};
|
64
|
-
|
64
|
+
u.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(s = ".") {
|
65
65
|
if (!await O().catch(() => {
|
66
66
|
})) return h("Salty CSS project must be initialized in a directory with a package.json file.");
|
67
|
-
|
68
|
-
const { dir: d =
|
67
|
+
e.info("Initializing a new Salty-CSS project!");
|
68
|
+
const { dir: d = s, cssFile: l, skipInstall: p } = this.opts();
|
69
69
|
if (!d) return h("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
|
70
70
|
p || await E(A.core, A.react);
|
71
|
-
const r = process.cwd(), o = G(d), T = await Promise.all([
|
71
|
+
const r = process.cwd(), o = G(d), T = await Promise.all([k("salty.config.ts"), k("saltygen/index.css")]);
|
72
72
|
await q(o, { recursive: !0 });
|
73
|
-
const y = T.map(async ({ fileName:
|
74
|
-
const c = a(o,
|
73
|
+
const y = T.map(async ({ fileName: t, content: g }) => {
|
74
|
+
const c = a(o, t);
|
75
75
|
if (await S(c, "utf-8").catch(() => {
|
76
76
|
}) !== void 0) {
|
77
|
-
|
77
|
+
e.debug("File already exists: " + c);
|
78
78
|
return;
|
79
79
|
}
|
80
|
-
const b =
|
81
|
-
b && await q(a(o, b), { recursive: !0 }),
|
80
|
+
const b = t.split("/").slice(0, -1).join("/");
|
81
|
+
b && await q(a(o, b), { recursive: !0 }), e.info("Creating file: " + c), await C(c, g), await j(c);
|
82
82
|
});
|
83
83
|
await Promise.all(y);
|
84
84
|
const w = z(r, o) || ".", m = a(r, ".saltyrc.json"), f = await S(m, "utf-8").catch(() => {
|
85
85
|
});
|
86
86
|
if (f === void 0) {
|
87
|
-
|
88
|
-
const
|
87
|
+
e.info("Creating file: " + m);
|
88
|
+
const g = JSON.stringify({
|
89
89
|
$schema: "./node_modules/@salty-css/core/.saltyrc.schema.json",
|
90
90
|
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.",
|
91
91
|
defaultProject: w,
|
@@ -96,157 +96,157 @@ async function Je() {
|
|
96
96
|
}
|
97
97
|
]
|
98
98
|
}, null, 2);
|
99
|
-
await C(m,
|
99
|
+
await C(m, g), await j(m);
|
100
100
|
} else {
|
101
|
-
const
|
102
|
-
if (
|
103
|
-
|
104
|
-
const
|
105
|
-
|
101
|
+
const t = JSON.parse(f), g = (t == null ? void 0 : t.projects) || [];
|
102
|
+
if (g.findIndex((n) => n.dir === w) === -1) {
|
103
|
+
g.push({ dir: w, framework: "react" }), t.projects = [...g];
|
104
|
+
const n = JSON.stringify(t, null, 2);
|
105
|
+
n !== f && (e.info("Edit file: " + m), await C(m, n), await j(m));
|
106
106
|
}
|
107
107
|
}
|
108
|
-
const
|
108
|
+
const P = a(r, ".gitignore"), H = await S(P, "utf-8").catch(() => {
|
109
109
|
});
|
110
|
-
H !== void 0 && (H.includes("saltygen") || (
|
110
|
+
H !== void 0 && (H.includes("saltygen") || (e.info("Edit file: " + P), await C(P, H + `
|
111
111
|
|
112
112
|
# Salty-CSS
|
113
113
|
saltygen
|
114
114
|
`)));
|
115
115
|
const F = ["src", "public", "assets", "styles", "css", "app"], M = ["styles", "css", "app", "pages"], B = ["index", "styles", "main", "app", "global", "globals"], U = [".css", ".scss", ".sass"], D = await (async () => {
|
116
116
|
if (l) return l;
|
117
|
-
for (const
|
118
|
-
for (const
|
117
|
+
for (const t of F)
|
118
|
+
for (const g of B)
|
119
119
|
for (const c of U) {
|
120
|
-
const
|
121
|
-
if (await S(
|
122
|
-
}) !== void 0) return z(o,
|
120
|
+
const n = a(o, t, g + c);
|
121
|
+
if (await S(n, "utf-8").catch(() => {
|
122
|
+
}) !== void 0) return z(o, n);
|
123
123
|
for (const L of M) {
|
124
|
-
const R = a(o,
|
124
|
+
const R = a(o, t, L, g + c);
|
125
125
|
if (await S(R, "utf-8").catch(() => {
|
126
126
|
}) !== void 0) return z(o, R);
|
127
127
|
}
|
128
128
|
}
|
129
129
|
})();
|
130
130
|
if (D) {
|
131
|
-
const
|
131
|
+
const t = a(o, D), g = await S(t, "utf-8").catch(() => {
|
132
132
|
});
|
133
|
-
if (
|
134
|
-
const
|
135
|
-
|
136
|
-
` +
|
133
|
+
if (g !== void 0 && !g.includes("saltygen")) {
|
134
|
+
const n = a(t, ".."), L = `@import '${z(n, a(o, "saltygen/index.css"))}';`;
|
135
|
+
e.info("Adding global import statement to CSS file: " + t), await C(t, L + `
|
136
|
+
` + g), await j(t);
|
137
137
|
}
|
138
138
|
} else
|
139
|
-
|
140
|
-
const
|
139
|
+
e.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");
|
140
|
+
const at = {
|
141
141
|
projectJs: a(o, "eslint.config.js"),
|
142
142
|
rootJs: a(r, "eslint.config.js"),
|
143
143
|
projectMjs: a(o, "eslint.config.mjs"),
|
144
144
|
rootMjs: a(r, "eslint.config.mjs"),
|
145
145
|
projectJson: a(o, ".eslintrc.json"),
|
146
146
|
rootJson: a(r, ".eslintrc.json")
|
147
|
-
},
|
148
|
-
if (
|
147
|
+
}, x = Object.values(at).find((t) => Q(t));
|
148
|
+
if (x) {
|
149
149
|
p || await E(A.eslintConfigCore);
|
150
|
-
const
|
150
|
+
const t = await S(x, "utf-8").catch(() => {
|
151
151
|
});
|
152
|
-
if (!
|
153
|
-
if (!
|
154
|
-
if (
|
155
|
-
let
|
156
|
-
${
|
157
|
-
|
152
|
+
if (!t) return h("Could not read ESLint config file.");
|
153
|
+
if (!t.includes("salty-css"))
|
154
|
+
if (e.info("Edit file: " + x), x.endsWith("js")) {
|
155
|
+
let n = `import saltyCss from "@salty-css/eslint-config-core/flat";
|
156
|
+
${t}`;
|
157
|
+
t.includes("typescript-eslint") ? n.includes(".config(") ? n = n.replace(".config(", ".config(saltyCss,") : e.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.") : n.includes("export default [") ? n = n.replace("export default [", "export default [ saltyCss,") : n.includes("eslintConfig = [") ? n = n.replace("eslintConfig = [", "eslintConfig = [ saltyCss,") : e.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."), await C(x, n), await j(x);
|
158
158
|
} else {
|
159
|
-
const c = JSON.parse(
|
159
|
+
const c = JSON.parse(t);
|
160
160
|
c.extends || (c.extends = []), c.extends.push("@salty-css/core");
|
161
|
-
const
|
162
|
-
await C(
|
161
|
+
const n = JSON.stringify(c, null, 2);
|
162
|
+
await C(x, n), await j(x);
|
163
163
|
}
|
164
164
|
}
|
165
165
|
const W = a(o, "vite.config.ts"), V = await S(W, "utf-8").catch(() => {
|
166
166
|
});
|
167
167
|
if (V !== void 0 && !V.includes("saltyPlugin")) {
|
168
|
-
|
169
|
-
const
|
170
|
-
`,
|
168
|
+
e.info("Edit file: " + W);
|
169
|
+
const g = `import { saltyPlugin } from '@salty-css/vite';
|
170
|
+
`, n = V.replace(/(plugins: \[)/, `$1
|
171
171
|
saltyPlugin(__dirname),`);
|
172
|
-
p || await E(`-D ${A.vite}`),
|
172
|
+
p || await E(`-D ${A.vite}`), e.info("Adding Salty-CSS plugin to Vite config..."), await C(W, g + n), await j(W);
|
173
173
|
}
|
174
|
-
const _ = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((
|
174
|
+
const _ = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((t) => a(o, t)).find((t) => Q(t));
|
175
175
|
if (_) {
|
176
|
-
let
|
176
|
+
let t = await S(_, "utf-8").catch(() => {
|
177
177
|
});
|
178
|
-
if (
|
178
|
+
if (t !== void 0 && !t.includes("withSaltyCss")) {
|
179
179
|
let c = !1;
|
180
|
-
/\splugins([^=]*)=[^[]\[/.test(
|
181
|
-
const b =
|
180
|
+
/\splugins([^=]*)=[^[]\[/.test(t) && !c && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (R, I) => ` plugins${I}= [withSaltyCss,`), c = !0);
|
181
|
+
const b = t.includes("module.exports"), L = b ? `const { withSaltyCss } = require('@salty-css/next');
|
182
182
|
` : `import { withSaltyCss } from '@salty-css/next';
|
183
183
|
`;
|
184
|
-
b && !c ? (
|
184
|
+
b && !c ? (t = t.replace(/module.exports = ([^;]+)/, (R, I) => `module.exports = withSaltyCss(${I})`), c = !0) : c || (t = t.replace(/export default ([^;]+)/, (R, I) => `export default withSaltyCss(${I})`)), p || await E(`-D ${A.next}`), e.info("Adding Salty-CSS plugin to Next.js config..."), await C(_, L + t), await j(_);
|
185
185
|
}
|
186
186
|
}
|
187
|
-
const
|
188
|
-
await
|
189
|
-
}),
|
190
|
-
|
191
|
-
const { dir: i =
|
187
|
+
const it = await O().catch(() => h("Could not read package.json file.")).then((t) => (t.scripts || (t.scripts = {}), t.scripts.prepare ? t.scripts.prepare.includes("salty-css") || (e.info("Edit file: " + J), t.scripts.prepare = t.scripts.prepare + " && npx salty-css build") : (e.info("Edit file: " + J), t.scripts.prepare = "npx salty-css build"), t));
|
188
|
+
await nt(it), e.info("Running the build to generate initial CSS..."), await K(o), e.info("🎉 Salty CSS project initialized successfully!"), e.info("Next steps:"), e.info("1. Configure variables and templates in `salty.config.ts`"), e.info("2. Create a new component with `npx salty-css generate [component-name]`"), e.info("3. Run `npx salty-css build` to generate the CSS"), e.info("4. Read about the features in the documentation: https://salty-css.dev"), e.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐");
|
189
|
+
}), u.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").action(async function(s = Y) {
|
190
|
+
e.info("Building the Salty-CSS project...");
|
191
|
+
const { dir: i = s, watch: d } = this.opts();
|
192
192
|
if (!i) return h("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
193
193
|
const l = G(i);
|
194
|
-
await K(l), d && (
|
195
|
-
await
|
194
|
+
await K(l), d && (e.info("Watching for changes in the project directory..."), rt(l, { recursive: !0 }, async (p, r) => {
|
195
|
+
await yt(r) ? await K(l, !1, !1) : dt(r) && await ft(l, r);
|
196
196
|
}));
|
197
|
-
}),
|
198
|
-
const { file: d =
|
197
|
+
}), u.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>", "File to generate.").option("-d, --dir <dir>", "Project directory to generate the file in.").option("-t, --tag <tag>", "HTML tag of the component.", "div").option("-n, --name <name>", "Name of the component.").option("-c, --className <className>", "CSS class of the component.").option("-r, --reactComponent", "Generate a React component as well.").action(async function(s, i = Y) {
|
198
|
+
const { file: d = s, dir: l = i, tag: p, name: r, className: o, reactComponent: T = !1 } = this.opts();
|
199
199
|
if (!d) return h("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
|
200
200
|
if (!l) return h("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
|
201
201
|
const y = G(l), w = d.split("/").slice(0, -1).join("/");
|
202
202
|
w && await q(a(y, w), { recursive: !0 });
|
203
|
-
const m = a(y, d), f =
|
203
|
+
const m = a(y, d), f = ct(m);
|
204
204
|
f.ext || (f.ext = ".ts"), f.name.endsWith(".css") || (f.name = f.name + ".css"), f.base = f.name + f.ext;
|
205
|
-
const
|
206
|
-
if (await S(
|
205
|
+
const P = et(f);
|
206
|
+
if (await S(P, "utf-8").catch(() => {
|
207
207
|
}) !== void 0) {
|
208
|
-
|
208
|
+
e.error("File already exists:", P);
|
209
209
|
return;
|
210
210
|
}
|
211
|
-
let F =
|
211
|
+
let F = pt(r || f.base.replace(/\.css\.\w+$/, ""));
|
212
212
|
if (T) {
|
213
213
|
const B = F + "Component";
|
214
214
|
F = F + "Wrapper";
|
215
|
-
const U = f.base.replace(/\.css\.\w+$/, ""), { content:
|
215
|
+
const U = f.base.replace(/\.css\.\w+$/, ""), { content: tt } = await k("react/react-vanilla-file.ts", { tag: p, componentName: B, styledComponentName: F, className: o, fileName: U });
|
216
216
|
f.name = U.replace(/\.css$/, ""), f.ext = ".tsx", f.base = f.name + f.ext;
|
217
|
-
const D =
|
218
|
-
|
217
|
+
const D = et(f);
|
218
|
+
e.info("Generating a new file: " + D), await C(D, tt), await j(D);
|
219
219
|
}
|
220
|
-
const { content: M } = await
|
221
|
-
|
220
|
+
const { content: M } = await k("react/react-styled-file.ts", { tag: p, name: F, className: o });
|
221
|
+
e.info("Generating a new file: " + P), await C(P, M), await j(P);
|
222
222
|
});
|
223
223
|
const Z = async () => {
|
224
|
-
const
|
224
|
+
const s = a(process.cwd(), "package.json"), i = await O(s).catch((p) => h(p));
|
225
225
|
if (!i) return h("Could not read package.json file.");
|
226
226
|
const d = { ...i.dependencies, ...i.devDependencies }, l = Object.entries(d).filter(([p]) => p === "salty-css" || p.startsWith("@salty-css/"));
|
227
227
|
return l.length ? l : h(
|
228
|
-
"No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " +
|
228
|
+
"No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + s
|
229
229
|
);
|
230
230
|
};
|
231
|
-
|
232
|
-
const { legacyPeerDeps: i, version: d =
|
231
|
+
u.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(s = "latest") {
|
232
|
+
const { legacyPeerDeps: i, version: d = s } = this.opts(), l = await Z();
|
233
233
|
if (!l) return h("Could not update Salty-CSS packages as any were found in package.json.");
|
234
234
|
const p = l.map(([y]) => d === "@" ? `${y}@${N.version}` : `${y}@${d.replace(/^@/, "")}`);
|
235
|
-
i ? (
|
235
|
+
i ? (e.warn("Using legacy peer dependencies to update packages."), await E(...p, "--legacy-peer-deps")) : await E(...p);
|
236
236
|
const r = await Z();
|
237
237
|
if (!r) return h("Something went wrong while reading the updated packages.");
|
238
238
|
const o = r.reduce((y, [w, m]) => (y[m] || (y[m] = []), y[m].push(w), y), {});
|
239
239
|
if (Object.keys(o).length === 1) {
|
240
240
|
const w = Object.keys(o)[0].replace(/^\^/, "");
|
241
|
-
|
241
|
+
e.info(`Updated to all Salty CSS packages successfully to ${w}`);
|
242
242
|
} else
|
243
243
|
for (const [y, w] of Object.entries(o)) {
|
244
244
|
const m = y.replace(/^\^/, "");
|
245
|
-
|
245
|
+
e.info(`Updated to ${m}: ${w.join(", ")}`);
|
246
246
|
}
|
247
|
-
}),
|
248
|
-
const
|
249
|
-
|
247
|
+
}), u.option("-v, --version", "Show the current version of Salty-CSS.").action(async function() {
|
248
|
+
const s = await X();
|
249
|
+
e.info("CLI is running: " + s.version);
|
250
250
|
const i = a(process.cwd(), "package.json"), d = await O(i).catch((r) => h(r));
|
251
251
|
if (!d) return;
|
252
252
|
const l = { ...d.dependencies, ...d.devDependencies }, p = Object.keys(l).filter((r) => r === "salty-css" || r.startsWith("@salty-css/"));
|
@@ -255,9 +255,9 @@ ${e}`;
|
|
255
255
|
"No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + i
|
256
256
|
);
|
257
257
|
for (const r of p)
|
258
|
-
|
259
|
-
}),
|
258
|
+
e.info(`${r}: ${l[r]}`);
|
259
|
+
}), u.parseAsync(process.argv);
|
260
260
|
}
|
261
261
|
export {
|
262
|
-
|
262
|
+
Jt as main
|
263
263
|
};
|
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-
|
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-BT4aa1vH.cjs");const e=require("../index-oCwSpzG5.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.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
@@ -4,8 +4,8 @@ import "../dash-case-DBThphLm.js";
|
|
4
4
|
import "path";
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
|
-
import "../parse-styles-
|
8
|
-
import { e as g, d as F, g as y, b as x, i as S, m as c, s as f, c as C } from "../index-
|
7
|
+
import "../parse-styles-DkygSsSC.js";
|
8
|
+
import { e as g, d as F, g as y, b as x, i as S, m as c, s as f, c as C } from "../index-aCAHSJBW.js";
|
9
9
|
import "../css/merge.js";
|
10
10
|
import "../define-templates-4A2yHcMF.js";
|
11
11
|
export {
|
package/css/keyframes.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../parse-styles-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../parse-styles-BT4aa1vH.cjs"),w=require("../dash-case-BJEkFEGQ.cjs"),C=async({animationName:l,params:u,appendInitialStyles:y,...t})=>{const n=l||w.toHash(t),r=async(s={})=>{const{duration:e="500ms",easing:o="ease-in-out",delay:i="0s",iterationCount:S="1",direction:p="normal",fillMode:g="forwards",playState:b="running"}={...u,...s},a=`${n} ${e} ${o} ${i} ${S} ${p} ${g} ${b}`;if(!y)return a;const c=t.from||t["0%"];if(!c)return a;const j=await m.parseAndJoinStyles(c,"");return`${a};${j}`},$=Object.entries(t).map(async([s,e])=>{if(!e)return"";const o=await m.parseAndJoinStyles(e,"");return`${typeof s=="number"?`${s}%`:s}{${o}}`}),d=(await Promise.all($)).join(""),f=`@keyframes ${n} {${d}}`;return Object.assign(r,{toString:r,isKeyframes:!0,animationName:n,css:f,keyframes:t}),r};exports.keyframes=C;
|
package/css/keyframes.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { p as m } from "../parse-styles-
|
1
|
+
import { p as m } from "../parse-styles-DkygSsSC.js";
|
2
2
|
import { t as j } from "../dash-case-DBThphLm.js";
|
3
3
|
const v = async ({ animationName: $, params: f, appendInitialStyles: l, ...t }) => {
|
4
4
|
const r = $ || j(t), o = async (n = {}) => {
|
package/generators/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var C=Object.defineProperty;var N=(a,s,t)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var m=(a,s,t)=>N(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../parse-styles-
|
1
|
+
"use strict";var C=Object.defineProperty;var N=(a,s,t)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var m=(a,s,t)=>N(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../parse-styles-BT4aa1vH.cjs"),n=require("../dash-case-BJEkFEGQ.cjs");class y{constructor(s){m(this,"buildContext",{});this.params=s}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){const{base:s,variants:t,compoundVariants:e}=this.params;return n.toHash({base:s,variants:t,compoundVariants:e})}get cssClassName(){return this.hash}get classNames(){const s=new Set([this.cssClassName]),{className:t}=this.params;return typeof t=="string"&&s.add(t),typeof t=="object"&&t.forEach(e=>s.add(e)),this.getTemplateClasses().forEach(e=>s.add(e)),this.buildContext.classNames&&this.buildContext.classNames.forEach(e=>s.add(e)),[...s].join(" ")}get cssFileName(){const{callerName:s}=this.buildContext;return s?`cl_${n.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:e=[]}=this.params,{config:i}=this.buildContext,o={...s,variants:t,compoundVariants:e};return S.parseAndJoinStyles(o,`.${this.cssClassName}`,i,this.isRoot)}getTemplateClasses(s=this.buildContext.config){if(!(s!=null&&s.templates)||!this.params.base||this.priority>0)return[];const t=Object.keys(s.templates);return Object.entries(this.params.base).reduce((e,[i,o])=>(t.includes(i)&&e.push("t_"+n.toHash(n.dashCase(`${i}-${o}`),4)),e),[])}_withBuildContext(s){return this.buildContext=s,this}}class v extends y{constructor(s){super(s),this._params=s}}class x extends y{constructor(s,t){super(t),this.tagName=s,this._params=t}get priority(){var s;return this.params.priority?this.params.priority:typeof this.tagName=="function"||typeof this.tagName=="object"?(((s=this.tagName.generator)==null?void 0:s.priority)||0)+1:0}get clientProps(){const{element:s,variants:t={},compoundVariants:e=[],defaultVariants:i={},defaultProps:o={},passProps:d}=this.params,{callerName:f,isProduction:b}=this.buildContext,h=new Set([]),l=r=>{const c=i[r];c!==void 0?h.add(`${r}=${String(c)}`):h.add(r)};Object.keys(t).forEach(l),e.map(r=>Object.keys(r).forEach(l));const p=new Set([]);if(this.params.base){const r=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);r&&r.forEach(c=>{const u=c.replace(/\{(?:-)?props\.([^}]+)\}/gi,"$1"),g=n.dashCase(u);u&&p.add(g)})}return{element:s,variantKeys:[...h],propValueKeys:[...p],passProps:d,defaultProps:o,attr:{"data-component-name":b?void 0:f}}}}exports.ClassNameGenerator=v;exports.StyledGenerator=x;
|