@salty-css/core 0.0.1-alpha.111 → 0.0.1-alpha.113
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
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-Cj4Em07G.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,v)=>{se.exec(y,F=>{if(F)return v(F);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(),F=y.join(" ");await X(`npm install ${F}`),v.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"))},v=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 g=process.cwd(),r=R(l),T=await Promise.all([v("salty.config.ts"),v("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:f})=>{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,f),await S(c)});await Promise.all(m);const w=n.relative(g,r)||".",h=n.join(g,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const f=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,f),await S(h)}else{const e=JSON.parse(d),f=(e==null?void 0:e.projects)||[];if(f.findIndex(o=>o.dir===w)===-1){f.push({dir:w,framework:"react"}),e.projects=[...f];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(g,".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
|
@@ -8,4 +8,4 @@ ${e}`;e.includes("typescript-eslint")?o.includes(".config(")?o=o.replace(".confi
|
|
8
8
|
`,o=W.replace(/(plugins: \[)/,`$1
|
9
9
|
saltyPlugin(__dirname),`);p||await I(`-D ${D.vite}`),t.logger.info("Adding Salty-CSS plugin to Vite config..."),await s.writeFile(_,f+o),await S(_)}const A=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(e=>n.join(r,e)).find(e=>G.existsSync(e));if(A){let e=await s.readFile(A,"utf-8").catch(()=>{});if(e!==void 0&&!e.includes("withSaltyCss")){let c=!1;/\splugins([^=]*)=[^[]\[/.test(e)&&!c&&(e=e.replace(/\splugins([^=]*)=[^[]\[/,(q,J)=>` plugins${J}= [withSaltyCss,`),c=!0);const k=e.includes("module.exports"),O=k?`const { withSaltyCss } = require('@salty-css/next');
|
10
10
|
`:`import { withSaltyCss } from '@salty-css/next';
|
11
|
-
`;k&&!c?(e=e.replace(/module.exports = ([^;]+)/,(q,J)=>`module.exports = withSaltyCss(${J})`),c=!0):c||(e=e.replace(/export default ([^;]+)/,(q,J)=>`export default withSaltyCss(${J})`)),p||await I(`-D ${D.next}`),t.logger.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(A,O+e),await S(A)}}const ee=await N().catch(()=>t.logError("Could not read package.json file.")).then(e=>(e.scripts||(e.scripts={}),e.scripts.prepare?e.scripts.prepare.includes("salty-css")||(t.logger.info("Edit file: "+b),e.scripts.prepare=e.scripts.prepare+" && npx salty-css build"):(t.logger.info("Edit file: "+b),e.scripts.prepare="npx salty-css build"),e));await Y(ee),t.logger.info("Running the build to generate initial CSS..."),await t.generateCss(r),t.logger.info("🎉 Salty CSS project initialized successfully!"),t.logger.info("Next steps:"),t.logger.info("1. Configure variables and templates in `salty.config.ts`"),t.logger.info("2. Create a new component with `npx salty-css generate [component-name]`"),t.logger.info("3. Run `npx salty-css build` to generate the CSS"),t.logger.info("4. Read about the features in the documentation: https://salty-css.dev"),t.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.").action(async function(i=V){t.logger.info("Building the Salty-CSS project...");const{dir:a=i}=this.opts();if(!a)return t.logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const l=R(a);await t.generateCss(l)}),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:l=i,dir:u=a,tag:p,name:g,className:r,reactComponent:T=!1}=this.opts();if(!l)return t.logError("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!u)return t.logError("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const m=R(u),w=l.split("/").slice(0,-1).join("/");w&&await s.mkdir(n.join(m,w),{recursive:!0});const h=n.join(m,l),d=n.parse(h);d.ext||(d.ext=".ts"),d.name.endsWith(".css")||(d.name=d.name+".css"),d.base=d.name+d.ext;const j=n.format(d);if(await s.readFile(j,"utf-8").catch(()=>{})!==void 0){t.logger.error("File already exists:",j);return}let x=ie.pascalCase(g||d.base.replace(/\.css\.\w+$/,""));if(T){const M=x+"Component";x=x+"Wrapper";const L=d.base.replace(/\.css\.\w+$/,""),{content:Q}=await v("react/react-vanilla-file.ts",{tag:p,componentName:M,styledComponentName:x,className:r,fileName:L});d.name=L.replace(/\.css$/,""),d.ext=".tsx",d.base=d.name+d.ext;const E=n.format(d);t.logger.info("Generating a new file: "+E),await s.writeFile(E,Q),await S(E)}const{content:H}=await v("react/react-styled-file.ts",{tag:p,name:x,className:r});t.logger.info("Generating a new file: "+j),await s.writeFile(j,H),await S(j)});const K=async()=>{const i=n.join(process.cwd(),"package.json"),a=await N(i).catch(p=>t.logError(p));if(!a)return t.logError("Could not read package.json file.");const l={...a.dependencies,...a.devDependencies},u=Object.entries(l).filter(([p])=>p==="salty-css"||p.startsWith("@salty-css/"));return u.length?u:t.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:l=i}=this.opts(),u=await K();if(!u)return t.logError("Could not update Salty-CSS packages as any were found in package.json.");const p=u.map(([m])=>l==="@"?`${m}@${$.version}`:`${m}@${l.replace(/^@/,"")}`);a?(t.logger.warn("Using legacy peer dependencies to update packages."),await I(...p,"--legacy-peer-deps")):await I(...p);const g=await K();if(!g)return t.logError("Something went wrong while reading the updated packages.");const r=g.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(/^\^/,"");t.logger.info(
|
11
|
+
`;k&&!c?(e=e.replace(/module.exports = ([^;]+)/,(q,J)=>`module.exports = withSaltyCss(${J})`),c=!0):c||(e=e.replace(/export default ([^;]+)/,(q,J)=>`export default withSaltyCss(${J})`)),p||await I(`-D ${D.next}`),t.logger.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(A,O+e),await S(A)}}const ee=await N().catch(()=>t.logError("Could not read package.json file.")).then(e=>(e.scripts||(e.scripts={}),e.scripts.prepare?e.scripts.prepare.includes("salty-css")||(t.logger.info("Edit file: "+b),e.scripts.prepare=e.scripts.prepare+" && npx salty-css build"):(t.logger.info("Edit file: "+b),e.scripts.prepare="npx salty-css build"),e));await Y(ee),t.logger.info("Running the build to generate initial CSS..."),await t.generateCss(r),t.logger.info("🎉 Salty CSS project initialized successfully!"),t.logger.info("Next steps:"),t.logger.info("1. Configure variables and templates in `salty.config.ts`"),t.logger.info("2. Create a new component with `npx salty-css generate [component-name]`"),t.logger.info("3. Run `npx salty-css build` to generate the CSS"),t.logger.info("4. Read about the features in the documentation: https://salty-css.dev"),t.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.").action(async function(i=V){t.logger.info("Building the Salty-CSS project...");const{dir:a=i}=this.opts();if(!a)return t.logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const l=R(a);await t.generateCss(l)}),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:l=i,dir:u=a,tag:p,name:g,className:r,reactComponent:T=!1}=this.opts();if(!l)return t.logError("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!u)return t.logError("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const m=R(u),w=l.split("/").slice(0,-1).join("/");w&&await s.mkdir(n.join(m,w),{recursive:!0});const h=n.join(m,l),d=n.parse(h);d.ext||(d.ext=".ts"),d.name.endsWith(".css")||(d.name=d.name+".css"),d.base=d.name+d.ext;const j=n.format(d);if(await s.readFile(j,"utf-8").catch(()=>{})!==void 0){t.logger.error("File already exists:",j);return}let x=ie.pascalCase(g||d.base.replace(/\.css\.\w+$/,""));if(T){const M=x+"Component";x=x+"Wrapper";const L=d.base.replace(/\.css\.\w+$/,""),{content:Q}=await v("react/react-vanilla-file.ts",{tag:p,componentName:M,styledComponentName:x,className:r,fileName:L});d.name=L.replace(/\.css$/,""),d.ext=".tsx",d.base=d.name+d.ext;const E=n.format(d);t.logger.info("Generating a new file: "+E),await s.writeFile(E,Q),await S(E)}const{content:H}=await v("react/react-styled-file.ts",{tag:p,name:x,className:r});t.logger.info("Generating a new file: "+j),await s.writeFile(j,H),await S(j)});const K=async()=>{const i=n.join(process.cwd(),"package.json"),a=await N(i).catch(p=>t.logError(p));if(!a)return t.logError("Could not read package.json file.");const l={...a.dependencies,...a.devDependencies},u=Object.entries(l).filter(([p])=>p==="salty-css"||p.startsWith("@salty-css/"));return u.length?u:t.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:l=i}=this.opts(),u=await K();if(!u)return t.logError("Could not update Salty-CSS packages as any were found in package.json.");const p=u.map(([m])=>l==="@"?`${m}@${$.version}`:`${m}@${l.replace(/^@/,"")}`);a?(t.logger.warn("Using legacy peer dependencies to update packages."),await I(...p,"--legacy-peer-deps")):await I(...p);const g=await K();if(!g)return t.logError("Something went wrong while reading the updated packages.");const r=g.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(/^\^/,"");t.logger.info(`Updated to all Salty CSS packages successfully to ${w}`)}else for(const[m,w]of Object.entries(r)){const h=m.replace(/^\^/,"");t.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();t.logger.info("CLI is running: "+i.version);const a=n.join(process.cwd(),"package.json"),l=await N(a).catch(g=>t.logError(g));if(!l)return;const u={...l.dependencies,...l.devDependencies},p=Object.keys(u).filter(g=>g==="salty-css"||g.startsWith("@salty-css/"));if(!p.length)return t.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 g of p)t.logger.info(`${g}: ${u[g]}`)}),y.parseAsync(process.argv)}exports.main=re;
|
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 rt, format as tt } from "path";
|
5
5
|
import { render as ct } from "ejs";
|
6
|
-
import { l as e, a as h, g as et } from "../index-
|
6
|
+
import { l as e, a as h, g as et } from "../index-BYjQglAA.js";
|
7
7
|
import { p as lt } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as dt } from "child_process";
|
9
9
|
import ft from "ora";
|
@@ -235,7 +235,7 @@ ${t}`;
|
|
235
235
|
const o = d.reduce((y, [S, m]) => (y[m] || (y[m] = []), y[m].push(S), y), {});
|
236
236
|
if (Object.keys(o).length === 1) {
|
237
237
|
const S = Object.keys(o)[0].replace(/^\^/, "");
|
238
|
-
e.info(
|
238
|
+
e.info(`Updated to all Salty CSS packages successfully to ${S}`);
|
239
239
|
} else
|
240
240
|
for (const [y, S] of Object.entries(o)) {
|
241
241
|
const m = y.replace(/^\^/, "");
|
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-DKzpenwY.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-C1-wQz7G.cjs");const e=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-DKzpenwY.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-C1-wQz7G.cjs");const e=require("../index-Cj4Em07G.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-BNINfXOG.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-BYjQglAA.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
@@ -2,7 +2,7 @@ import * as K from "esbuild";
|
|
2
2
|
import { execSync as Q } from "child_process";
|
3
3
|
import { t as B, d as H } from "./dash-case-DMQMcCO6.js";
|
4
4
|
import { join as a, parse as tt } from "path";
|
5
|
-
import { existsSync as I, writeFileSync as
|
5
|
+
import { existsSync as I, writeFileSync as x, mkdirSync as V, readFileSync as E, statSync as et, readdirSync as st } from "fs";
|
6
6
|
import { readFile as nt, writeFile as ot } from "fs/promises";
|
7
7
|
import { p as at, a as rt, b as ct, c as it } from "./parse-templates-BNINfXOG.js";
|
8
8
|
import { createLogger as lt, format as J, transports as pt } from "winston";
|
@@ -28,7 +28,7 @@ const q = async (t) => {
|
|
28
28
|
level: "debug",
|
29
29
|
format: J.combine(J.colorize(), J.cli()),
|
30
30
|
transports: [new pt.Console({})]
|
31
|
-
}),
|
31
|
+
}), Ct = (t) => {
|
32
32
|
R.error(t);
|
33
33
|
}, O = {
|
34
34
|
externalModules: []
|
@@ -55,22 +55,22 @@ const q = async (t) => {
|
|
55
55
|
const e = await mt(t), c = /* @__PURE__ */ new Set(), s = (i, p = []) => i ? Object.entries(i).flatMap(([d, u]) => {
|
56
56
|
if (!u) return;
|
57
57
|
if (typeof u == "object") return s(u, [...p, d]);
|
58
|
-
const
|
59
|
-
c.add(`"${
|
58
|
+
const C = [...p, d].join(".");
|
59
|
+
c.add(`"${C}"`);
|
60
60
|
const y = [...p.map(H), H(d)].join("-"), { result: h } = it(u);
|
61
61
|
return `--${y}: ${h};`;
|
62
62
|
}) : [], n = (i) => i ? Object.entries(i).flatMap(([p, d]) => {
|
63
63
|
const u = s(d);
|
64
64
|
return p === "base" ? u.join("") : `${p} { ${u.join("")} }`;
|
65
|
-
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, d]) => Object.entries(d).flatMap(([u,
|
66
|
-
const y = s(
|
65
|
+
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, d]) => Object.entries(d).flatMap(([u, C]) => {
|
66
|
+
const y = s(C, [p]), h = `.${p}-${u}, [data-${p}="${u}"]`, T = y.join("");
|
67
67
|
return `${h} { ${T} }`;
|
68
68
|
})) : [], b = s(e.variables), f = n(e.responsiveVariables), $ = l(e.conditionalVariables), o = N(t), D = a(o, "css/variables.css"), g = `:root { ${b.join("")} ${f.join("")} } ${$.join("")}`;
|
69
|
-
|
69
|
+
x(D, g);
|
70
70
|
const w = a(o, "css/global.css"), S = at(e.global, "");
|
71
|
-
|
71
|
+
x(w, S);
|
72
72
|
const r = a(o, "css/templates.css"), m = rt(e.templates), F = ct(e.templates);
|
73
|
-
|
73
|
+
x(r, m);
|
74
74
|
const j = a(o, "types/css-tokens.d.ts"), P = `
|
75
75
|
// Variable types
|
76
76
|
type VariableTokens = ${[...c].join("|")};
|
@@ -82,7 +82,7 @@ const q = async (t) => {
|
|
82
82
|
`)}
|
83
83
|
}
|
84
84
|
`;
|
85
|
-
|
85
|
+
x(j, P);
|
86
86
|
}, z = async (t, e, c) => {
|
87
87
|
const s = B(e), n = a(c, "./temp");
|
88
88
|
I(n) || V(n);
|
@@ -95,7 +95,7 @@ const q = async (t) => {
|
|
95
95
|
contents: b,
|
96
96
|
sourcefile: l.base,
|
97
97
|
resolveDir: l.dir,
|
98
|
-
loader: "
|
98
|
+
loader: "tsx"
|
99
99
|
},
|
100
100
|
minify: !1,
|
101
101
|
treeShaking: !0,
|
@@ -134,25 +134,25 @@ const q = async (t) => {
|
|
134
134
|
await Promise.all(k.map((i) => $(a(r, i), a(m, i))));
|
135
135
|
} else if (j.isFile() && _(r)) {
|
136
136
|
const P = await z(t, r, n), i = [];
|
137
|
-
Object.entries(P).forEach(([
|
137
|
+
Object.entries(P).forEach(([C, y]) => {
|
138
138
|
if (y.isKeyframes && y.css) {
|
139
139
|
const W = `${y.animationName}.css`, Y = `css/${W}`, Z = a(n, Y);
|
140
|
-
c.push(W),
|
140
|
+
c.push(W), x(Z, y.css);
|
141
141
|
return;
|
142
142
|
}
|
143
143
|
if (!y.generator) return;
|
144
144
|
const h = y.generator._withBuildContext({
|
145
|
-
name:
|
145
|
+
name: C,
|
146
146
|
config: f,
|
147
147
|
prod: e
|
148
148
|
}), T = `${h.hash}-${h.priority}.css`;
|
149
149
|
s[h.priority] || (s[h.priority] = []), s[h.priority].push(T), i.push(T);
|
150
150
|
const v = `css/${T}`, X = a(n, v);
|
151
|
-
|
151
|
+
x(X, h.css);
|
152
152
|
});
|
153
|
-
const p = i.map((
|
153
|
+
const p = i.map((C) => `@import url('./${C}');`).join(`
|
154
154
|
`), d = B(r, 6), u = a(n, `css/${d}.css`);
|
155
|
-
|
155
|
+
x(u, p);
|
156
156
|
}
|
157
157
|
}
|
158
158
|
await $(t, n);
|
@@ -174,7 +174,7 @@ ${o}`;
|
|
174
174
|
`);
|
175
175
|
S += r;
|
176
176
|
}
|
177
|
-
|
177
|
+
x(l, S);
|
178
178
|
} catch (c) {
|
179
179
|
console.error(c);
|
180
180
|
}
|
@@ -189,12 +189,12 @@ ${o}`;
|
|
189
189
|
name: w,
|
190
190
|
config: b
|
191
191
|
}), m = `${r.hash}-${r.priority}.css`, F = `css/${m}`, j = a(s, F);
|
192
|
-
c.push(m),
|
192
|
+
c.push(m), x(j, r.css);
|
193
193
|
});
|
194
194
|
const $ = E(n, "utf8").split(`
|
195
195
|
`), o = c.map((w) => `@import url('../saltygen/css/${w}');`), g = [.../* @__PURE__ */ new Set([...$, ...o])].join(`
|
196
196
|
`);
|
197
|
-
|
197
|
+
x(n, g);
|
198
198
|
}
|
199
199
|
} catch (c) {
|
200
200
|
console.error(c);
|
@@ -228,8 +228,8 @@ ${o}`;
|
|
228
228
|
}
|
229
229
|
if (!k) clearTimeout(P);
|
230
230
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
231
|
-
const u = j + i,
|
232
|
-
o = o.replace(
|
231
|
+
const u = j + i, C = o.slice(j, u), y = o, h = ` ${g} = styled(${m}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
232
|
+
o = o.replace(C, h), y === o && console.error("Minimize file failed to change content", { name: g, tagName: m });
|
233
233
|
});
|
234
234
|
const D = B(e, 6);
|
235
235
|
return f.importStrategy === "component" && (o = `import '../../saltygen/css/${D}.css';
|
@@ -240,7 +240,7 @@ ${o}`), o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace
|
|
240
240
|
}
|
241
241
|
};
|
242
242
|
export {
|
243
|
-
|
243
|
+
Ct as a,
|
244
244
|
dt as b,
|
245
245
|
yt as c,
|
246
246
|
z as d,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const te=require("esbuild"),se=require("child_process"),N=require("./dash-case-DKzpenwY.cjs"),o=require("path"),a=require("fs"),H=require("fs/promises"),O=require("./parse-templates-C1-wQz7G.cjs"),M=require("winston");var q=typeof document<"u"?document.currentScript:null;function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=ne(te),G=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:G(o.join(e,".."))},oe=async e=>{const t=G(e);return await H.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await oe(e);if(t)return t.type};let v;const L=async e=>{if(v)return v;const t=await ie(e);return t==="module"?v="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-
|
1
|
+
"use strict";const te=require("esbuild"),se=require("child_process"),N=require("./dash-case-DKzpenwY.cjs"),o=require("path"),a=require("fs"),H=require("fs/promises"),O=require("./parse-templates-C1-wQz7G.cjs"),M=require("winston");var q=typeof document<"u"?document.currentScript:null;function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=ne(te),G=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:G(o.join(e,".."))},oe=async e=>{const t=G(e);return await H.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await oe(e);if(t)return t.type};let v;const L=async e=>{if(v)return v;const t=await ie(e);return t==="module"?v="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-Cj4Em07G.cjs",document.baseURI).href).endsWith(".cjs"))&&(v="cjs"),v||"esm"},V=M.createLogger({level:"debug",format:M.format.combine(M.format.colorize(),M.format.cli()),transports:[new M.transports.Console({})]}),re=e=>{V.error(e)},I={externalModules:[]},W=e=>{if(I.externalModules.length>0)return I.externalModules;const t=o.join(e,"salty.config.ts"),s=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const i=s[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return I.externalModules=i,i},R=e=>o.join(e,"./saltygen"),K=["salty","css","styles","styled"],A=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),_=(e,t=[])=>A(t).test(e),ce=async e=>{const t=R(e),n=o.join(e,"salty.config.ts"),s=o.join(t,"salty.config.js"),i=await L(e),p=W(e);await U.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:i,external:p});const S=Date.now(),{config:f}=await import(`${s}?t=${S}`);return f},X=async e=>{const t=await ce(e),n=new Set,s=(l,u=[])=>l?Object.entries(l).flatMap(([g,d])=>{if(!d)return;if(typeof d=="object")return s(d,[...u,g]);const C=[...u,g].join(".");n.add(`"${C}"`);const h=[...u.map(N.dashCase),N.dashCase(g)].join("-"),{result:j}=O.parseValueTokens(d);return`--${h}: ${j};`}):[],i=l=>l?Object.entries(l).flatMap(([u,g])=>{const d=s(g);return u==="base"?d.join(""):`${u} { ${d.join("")} }`}):[],p=l=>l?Object.entries(l).flatMap(([u,g])=>Object.entries(g).flatMap(([d,C])=>{const h=s(C,[u]),j=`.${u}-${d}, [data-${u}="${d}"]`,T=h.join("");return`${j} { ${T} }`})):[],S=s(t.variables),f=i(t.responsiveVariables),b=p(t.conditionalVariables),r=R(e),P=o.join(r,"css/variables.css"),y=`:root { ${S.join("")} ${f.join("")} } ${b.join("")}`;a.writeFileSync(P,y);const w=o.join(r,"css/global.css"),F=O.parseStyles(t.global,"");a.writeFileSync(w,F);const c=o.join(r,"css/templates.css"),m=O.parseTemplates(t.templates),x=O.getTemplateTypes(t.templates);a.writeFileSync(c,m);const $=o.join(r,"types/css-tokens.d.ts"),D=`
|
2
2
|
// Variable types
|
3
3
|
type VariableTokens = ${[...n].join("|")};
|
4
4
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -8,7 +8,7 @@
|
|
8
8
|
${Object.entries(x).map(([l,u])=>`${l}?: ${u}`).join(`
|
9
9
|
`)}
|
10
10
|
}
|
11
|
-
`;a.writeFileSync($,D)},J=async(e,t,n)=>{const s=N.toHash(t),i=o.join(n,"./temp");a.existsSync(i)||a.mkdirSync(i);const p=o.parse(t);let S=a.readFileSync(t,"utf8");S=S.replace(/styled\([^"'`{,]+,/g,"styled('div',");const f=o.join(n,"js",s+".js"),b=W(e),r=await L(e);await U.build({stdin:{contents:S,sourcefile:p.base,resolveDir:p.dir,loader:"
|
11
|
+
`;a.writeFileSync($,D)},J=async(e,t,n)=>{const s=N.toHash(t),i=o.join(n,"./temp");a.existsSync(i)||a.mkdirSync(i);const p=o.parse(t);let S=a.readFileSync(t,"utf8");S=S.replace(/styled\([^"'`{,]+,/g,"styled('div',");const f=o.join(n,"js",s+".js"),b=W(e),r=await L(e);await U.build({stdin:{contents:S,sourcefile:p.base,resolveDir:p.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),n=o.join(t,"salty.config.js"),{config:s}=await import(n);return s},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(e,t=Y())=>{try{t?V.info("Generating CSS in production mode! 🔥"):V.info("Generating CSS in development mode! 🚀");const n=[],s=[],i=R(e),p=o.join(i,"index.css");(()=>{a.existsSync(i)&&se.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 x=["node_modules","saltygen"],$=a.statSync(c);if($.isDirectory()){const k=a.readdirSync(c);if(x.some(l=>c.includes(l)))return;await Promise.all(k.map(l=>b(o.join(c,l),o.join(m,l))))}else if($.isFile()&&_(c)){const D=await J(e,c,i),l=[];Object.entries(D).forEach(([C,h])=>{if(h.isKeyframes&&h.css){const B=`${h.animationName}.css`,Q=`css/${B}`,ee=o.join(i,Q);n.push(B),a.writeFileSync(ee,h.css);return}if(!h.generator)return;const j=h.generator._withBuildContext({name:C,config:f,prod:t}),T=`${j.hash}-${j.priority}.css`;s[j.priority]||(s[j.priority]=[]),s[j.priority].push(T),l.push(T);const E=`css/${T}`,Z=o.join(i,E);a.writeFileSync(Z,j.css)});const u=l.map(C=>`@import url('./${C}');`).join(`
|
12
12
|
`),g=N.toHash(c,6),d=o.join(i,`css/${g}.css`);a.writeFileSync(d,u)}}await b(e,i);const r=n.map(c=>`@import url('./css/${c}');`).join(`
|
13
13
|
`);let F=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
14
|
|