@salty-css/core 0.3.0-refactor-vite-8.4 → 0.3.0-refactor-vite-8.5
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/dist/bin/index.cjs +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/bin/main.cjs +1 -1
- package/dist/bin/main.js +1 -1
- package/dist/compiler/salty-compiler.cjs +1 -1
- package/dist/compiler/salty-compiler.js +1 -1
- package/dist/{main-DGpSu6zK.js → main-CDCMeMx3.js} +1 -1
- package/dist/{main-LnoqOq21.cjs → main-DhcbJ5aR.cjs} +1 -1
- package/dist/{salty-compiler-CvQ-rsex.js → salty-compiler-Cj88Ep29.js} +0 -1
- package/dist/{salty-compiler-Bvd0OKHz.cjs → salty-compiler-DItIIZ12.cjs} +1 -1
- package/package.json +21 -3
package/dist/bin/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require("../main-
|
|
2
|
+
require("../main-DhcbJ5aR.cjs").t().catch(e=>console.error(e));
|
package/dist/bin/index.js
CHANGED
package/dist/bin/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-DhcbJ5aR.cjs");exports.main=e.t;
|
package/dist/bin/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../main-
|
|
1
|
+
import { t as e } from "../main-CDCMeMx3.js";
|
|
2
2
|
export { e as main };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-DItIIZ12.cjs");exports.SaltyCompiler=e.t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../salty-compiler-
|
|
1
|
+
import { t as e } from "../salty-compiler-Cj88Ep29.js";
|
|
2
2
|
export { e as SaltyCompiler };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./salty-compiler-
|
|
1
|
+
import { n as e, r as t, t as n } from "./salty-compiler-Cj88Ep29.js";
|
|
2
2
|
import { isSaltyFile as r } from "./compiler/helpers.js";
|
|
3
3
|
import { pascalCase as i } from "./util/index.js";
|
|
4
4
|
import { checkShouldRestart as a } from "./server/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./chunk-CMqjfN_6.cjs"),t=require("./salty-compiler-
|
|
1
|
+
const e=require("./chunk-CMqjfN_6.cjs"),t=require("./salty-compiler-DItIIZ12.cjs"),n=require("./compiler/helpers.cjs"),r=require("./util/index.cjs"),i=require("./server/index.cjs");let a=require("commander"),o=require("fs"),s=require("path"),c=require("fs/promises"),l=require("child_process"),u=require("ora");u=e.t(u,1);let d=require("ejs");d=e.t(d,1);let f=require("readline/promises");var p=(0,s.join)(process.cwd(),`package.json`),m=async(e=p)=>{let t=await(0,c.readFile)(e,`utf-8`).then(JSON.parse).catch(()=>void 0);if(!t)throw`Could not read package.json file!`;return t},h=async(e,t=p)=>{typeof e==`object`&&(e=JSON.stringify(e,null,2)),await(0,c.writeFile)(t,e)},g=async()=>m(new URL(`../package.json`,``+{}.url)),_={core:e=>`@salty-css/core@${e}`,eslintConfigCore:e=>`@salty-css/eslint-config-core@${e}`},v=e=>{e.scripts||={};let t=e.scripts.prepare;if(t){if(t.includes(`salty-css`))return{changed:!1,pkg:e};e.scripts.prepare=t+` && npx salty-css build`}else e.scripts.prepare=`npx salty-css build`;return{changed:!0,pkg:e}},y=e=>new Promise((t,n)=>{(0,l.exec)(e,e=>{if(e)return n(e);t()})}),b=async(...e)=>{let t=e.map(e=>e.replace(`-D`,``).split(`@`).slice(0,-1).join(`@`).trim()).join(`, `),n=(0,u.default)(`Installing packages: ${t}`).start();await y(`npm install ${e.join(` `)}`),n.succeed(`Installed packages: ${t}`)},x=()=>(0,o.existsSync)((0,s.join)(process.cwd(),`node_modules`,`.bin`,`prettier`));async function S(e){try{if(!x())return;await y(`./node_modules/.bin/prettier --write "${e}"`),t.r.info(`Formatted ${e} with Prettier`)}catch(n){t.r.error(`Error formatting ${e} with Prettier:`,n)}}var C=(e=process.cwd())=>(0,s.join)(e,`.saltyrc.json`),w=async(e=process.cwd())=>await(0,c.readFile)(C(e),`utf-8`).then(JSON.parse).catch(()=>({})),T=async(e=process.cwd())=>(0,c.readFile)(C(e),`utf-8`).catch(()=>void 0),E=async(e=process.cwd())=>(await w(e)).defaultProject,D=(e,t,n,r={})=>{let i=(0,s.join)(t,n.srcDirectory),a={dir:i,framework:n.name,...r};if(e===void 0)return{content: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:i,projects:[a]},null,2),changed:!0,created:!0};let o=JSON.parse(e),c=o.projects||[];if(c.some(e=>e.dir===i))return{content:e,changed:!1,created:!1};c.push(a),o.projects=[...c];let l=JSON.stringify(o,null,2);return{content:l,changed:l!==e,created:!1}},O=async(e,n,r,i={})=>{let a=C(e),{content:o,changed:s,created:l}=D(await T(e),n,r,i);return s?(l?t.r.info(`Creating file: `+a):t.r.info(`Edit file: `+a),await(0,c.writeFile)(a,o),await S(a),!0):!1},ee=(e,t)=>(e.projects||[]).find(e=>e.dir===t)?.framework,k=(e,t=process.cwd())=>(0,s.join)(t,e===`.`?``:e),A=async e=>{let t=process.cwd(),n=k(e.dir,t),r=(0,s.relative)(t,n)||`.`,i=await m().catch(()=>void 0);if(e.requirePackageJson!==!1&&!i)throw Error(`Salty CSS project must be initialized in a directory with a package.json file.`);return{cwd:t,projectDir:n,relativeProjectPath:r,packageJson:i,rcFile:await w(t),cliVersion:(await g()).version||`0.0.0`,skipInstall:!!e.skipInstall,yes:!!e.yes}},j=(e,r)=>{e.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.`).option(`--mode <mode>`,`Build mode: "production" or "development". Defaults to NODE_ENV-based detection.`).action(async function(e=r){t.r.info(`Building the Salty-CSS project...`);let{dir:a=e,watch:s,mode:c}=this.opts();if(c!==void 0&&c!==`production`&&c!==`development`)return t.n(`Invalid --mode "${c}". Expected "production" or "development".`);let l=a??await E();if(!l)return t.n(`Project directory must be provided. Add it as the first argument after build command or use the --dir option.`);let u=k(l),d=new t.t(u,{mode:c});await d.generateCss(),s&&(t.r.info(`Watching for changes in the project directory...`),(0,o.watch)(u,{recursive:!0},async(e,t)=>{if(!t)return console.warn(`File path not provided for change event`);await i.checkShouldRestart(t)?await d.generateCss(!1):n.isSaltyFile(t)&&await d.generateFile(t)}))})},M=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.cjs`],N=e=>{for(let t of M){let n=(0,s.join)(e,t);if((0,o.existsSync)(n))return n}return null},te=e=>{let t=e.packageJson;if(!t)return!1;let n={...t.dependencies,...t.devDependencies};return Object.prototype.hasOwnProperty.call(n,`astro`)},P={name:`astro`,srcDirectory:`src`,detect:e=>!!N(e.projectDir)||te(e),runtimePackage:e=>`@salty-css/astro@${e}`,templates:{styled:`astro/styled-file.ts`,component:{styled:`astro/styled-file.ts`,wrapper:`astro/component.astro`,wrapperExt:`.astro`}}},F={name:`react`,srcDirectory:``,detect:()=>!0,runtimePackage:e=>`@salty-css/react@${e}`,templates:{styled:`react/styled-file.ts`,component:{styled:`react/styled-file.ts`,wrapper:`react/vanilla-file.ts`,wrapperExt:`.tsx`}}},I=[P,F],L={astro:P,react:F},R=async e=>{for(let t of I)if(await t.detect(e))return t;return F},z=e=>{if(e)return L[e]},B={"salty.config.ts":()=>Promise.resolve().then(()=>require("./salty.config-B0ZiRpHR.cjs")),"saltygen/index.css":()=>Promise.resolve().then(()=>require("./templates-BGHLaAOm.cjs")),"react/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-BCbAEzBB.cjs")),"react/vanilla-file.ts":()=>Promise.resolve().then(()=>require("./vanilla-file-Z3VsOa_U.cjs")),"astro/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-DorArlCk.cjs")),"astro/component.astro":()=>Promise.resolve().then(()=>require("./astro-component-r0qEcF1p.cjs"))},V=async(e,t)=>{let{default:n}=await B[e]();return{fileName:e,content:d.default.render(n,t)}},H=(e,n)=>{e.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 wrapper component file alongside the styled definition.`).action(async function(e,i=n){let{file:a=e,dir:o=i,tag:l,name:u,className:d,reactComponent:f=!1}=this.opts();if(!a)return t.n(`File to generate must be provided. Add it as the first argument after generate command or use the --file option.`);if(!o)return t.n(`Project directory must be provided. Add it as the second argument after generate command or use the --dir option.`);let p;try{p=await A({dir:o,requirePackageJson:!1})}catch(e){return t.n(e instanceof Error?e.message:String(e))}let m=z(ee(p.rcFile,p.relativeProjectPath))??await R(p),h=a.split(`/`).slice(0,-1).join(`/`);h&&await(0,c.mkdir)((0,s.join)(p.projectDir,h),{recursive:!0});let g=(0,s.parse)((0,s.join)(p.projectDir,a));g.ext||=`.ts`,g.name.endsWith(`.css`)||(g.name+=`.css`),g.base=g.name+g.ext;let _=(0,s.format)(g);if(await(0,c.readFile)(_,`utf-8`).catch(()=>void 0)!==void 0){t.r.error(`File already exists: `+_);return}let v=r.pascalCase(u||g.base.replace(/\.css\.\w+$/,``));if(f){if(!m.templates.component)return t.n(`--reactComponent is not supported for the ${m.name} framework.`);let e=v+`Component`;v+=`Wrapper`;let n=g.base.replace(/\.css\.\w+$/,``),{content:r}=await V(m.templates.component.wrapper,{tag:l,componentName:e,styledComponentName:v,className:d,fileName:n});g.name=n.replace(/\.css$/,``),g.ext=m.templates.component.wrapperExt,g.base=g.name+g.ext;let i=(0,s.format)(g);t.r.info(`Generating a new file: `+i),await(0,c.writeFile)(i,r),await S(i)}let{content:y}=await V(f&&m.templates.component?m.templates.component.styled:m.templates.styled,{tag:l,name:v,className:d});t.r.info(`Generating a new file: `+_),await(0,c.writeFile)(_,y),await S(_)})},U=e=>{let t=e.trim();return t.startsWith(`-D `)?`${t.slice(3).trim()} (dev)`:t},W=e=>e.map(e=>` + ${U(e)}`).join(`
|
|
2
2
|
`),G=async(e,t,n={})=>{if(t||e.length===0)return;let r=n.input??process.stdin,i=n.output??process.stdout;if(!(n.isTTY??process.stdin.isTTY??!1))throw Error(`Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.`);i.write(`The following packages will be installed:\n${W(e)}\n`);let a=(0,f.createInterface)({input:r,output:i,terminal:!1});try{let e=(await a.question(`Proceed? (y/N) `)).trim().toLowerCase();if(e!==`y`&&e!==`yes`)throw Error(`Install cancelled by user.`)}finally{a.close()}},K=async(e,t={})=>{if(t.yes)return!0;let n=t.input??process.stdin,r=t.output??process.stdout;if(!(t.isTTY??process.stdin.isTTY??!1))return!1;let i=t.defaultYes?`(Y/n)`:`(y/N)`,a=(0,f.createInterface)({input:n,output:r,terminal:!1});try{let n=(await a.question(`${e} ${i} `)).trim().toLowerCase();return n===``?!!t.defaultYes:n===`y`||n===`yes`}finally{a.close()}},q=[`src`,`public`,`assets`,`styles`,`css`,`app`],J=[`styles`,`css`,`app`,`pages`],Y=[`index`,`styles`,`main`,`app`,`global`,`globals`],X=[`.css`,`.scss`,`.sass`],Z=async e=>{for(let t of q)for(let n of Y)for(let r of X){let i=(0,s.join)(e,t,n+r);if(await(0,c.readFile)(i,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,i);for(let i of J){let a=(0,s.join)(e,t,i,n+r);if(await(0,c.readFile)(a,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,a)}}},Q=e=>`@salty-css/astro@${e}`,ne=`import saltyIntegration from '@salty-css/astro/integration';
|
|
3
3
|
`,re=e=>{if(e.includes(`@salty-css/astro`))return{content:null};let t=e,n=!1;return/integrations\s*:\s*\[/.test(t)?(t=t.replace(/integrations\s*:\s*\[/,e=>`${e}saltyIntegration(),`),n=!0):/defineConfig\s*\(\s*\{/.test(t)&&(t=t.replace(/defineConfig\s*\(\s*\{/,e=>`${e}\n integrations: [saltyIntegration()],`),n=!0),n?{content:ne+t}:{content:null,warning:`Could not find a place to add saltyIntegration() in the Astro config. Please add it manually.`}},ie={name:`astro`,detect:e=>N(e.projectDir),plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let i=re(r);if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[`-D ${Q(e.cliVersion)}`],execute:async()=>(t.r.info(`Adding Salty-CSS integration to Astro config: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},ae=[[`projectJs`,`eslint.config.js`],[`rootJs`,`eslint.config.js`],[`projectMjs`,`eslint.config.mjs`],[`rootMjs`,`eslint.config.mjs`],[`projectJson`,`.eslintrc.json`],[`rootJson`,`.eslintrc.json`]],oe=(e,t)=>ae.map(([n,r])=>(0,s.join)(n.startsWith(`root`)?t:e,r)),se=(e,t)=>{if(e.includes(`salty-css`))return{content:null};if(t){let t=`import saltyCss from "@salty-css/eslint-config-core/flat";\n${e}`;if(e.includes(`typescript-eslint`))if(t.includes(`.config(`))t=t.replace(`.config(`,`.config(saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};else if(t.includes(`export default [`))t=t.replace(`export default [`,`export default [ saltyCss,`);else if(t.includes(`eslintConfig = [`))t=t.replace(`eslintConfig = [`,`eslintConfig = [ saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};return{content:t}}let n=JSON.parse(e);return n.extends||=[],n.extends.includes(`@salty-css/core`)||n.extends.push(`@salty-css/core`),{content:JSON.stringify(n,null,2)}},ce={name:`eslint`,detect:e=>oe(e.projectDir,e.cwd).find(e=>(0,o.existsSync)(e))??null,plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return t.r.error(`Could not read ESLint config file.`),null;let i=se(r,n.endsWith(`js`));if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[_.eslintConfigCore(e.cliVersion)],execute:async()=>(t.r.info(`Edit file: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},le=[`next.config.js`,`next.config.cjs`,`next.config.ts`,`next.config.mjs`],ue=e=>`@salty-css/next@${e}`,de=e=>{if(e.includes(`withSaltyCss`))return{content:null};let t=e,n=!1;/\splugins([^=]*)=[^[]\[/.test(t)&&(t=t.replace(/\splugins([^=]*)=[^[]\[/,(e,t)=>` plugins${t}= [withSaltyCss,`),n=!0);let r=t.includes(`module.exports`),i=r?`const { withSaltyCss } = require('@salty-css/next');
|
|
4
4
|
`:`import { withSaltyCss } from '@salty-css/next';
|
|
@@ -3,7 +3,6 @@ import { dashCase as r, isPathAllowed as i, normalizePath as a, toHash as o } fr
|
|
|
3
3
|
import { defineTemplates as s } from "./factories/index.js";
|
|
4
4
|
import { s as c, t as l } from "./parse-styles-Bz0otiZ-.js";
|
|
5
5
|
import { mergeFactories as u, mergeObjects as d } from "./css/merge.js";
|
|
6
|
-
import "./css/index.js";
|
|
7
6
|
import { getPackageJson as f } from "./compiler/get-files.js";
|
|
8
7
|
import { getTemplateTypes as p, getTemplateVariantMaps as m, parseTemplates as h } from "./parsers/index.js";
|
|
9
8
|
import { copyFileSync as g, existsSync as _, mkdirSync as v, readFileSync as y, readdirSync as b, statSync as x, writeFileSync as S } from "fs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./chunk-CMqjfN_6.cjs"),t=require("./compiler/helpers.cjs"),n=require("./util/index.cjs"),r=require("./factories/index.cjs"),i=require("./parse-styles-2rwbF9j_.cjs"),a=require("./css/merge.cjs")
|
|
1
|
+
const e=require("./chunk-CMqjfN_6.cjs"),t=require("./compiler/helpers.cjs"),n=require("./util/index.cjs"),r=require("./factories/index.cjs"),i=require("./parse-styles-2rwbF9j_.cjs"),a=require("./css/merge.cjs"),o=require("./compiler/get-files.cjs"),s=require("./parsers/index.cjs");let c=require("fs"),l=require("esbuild");l=e.t(l,1);let u=require("path"),d=require("winston"),f=require("fs/promises"),p=require("child_process"),m=require("module");var h=(0,d.createLogger)({level:`debug`,format:d.format.combine(d.format.colorize(),d.format.cli()),transports:[new d.transports.Console({})]}),g=e=>{h.error(e)},_=/^(?:[a-z][a-z0-9+.-]*:)?\/\//i,v=e=>typeof e==`string`?{url:e}:e,y=e=>e.startsWith(`.`)||e.startsWith(`/`)?e:`./${e}`,b=e=>e.split(`\\`).join(`/`),x=(e,t)=>(0,m.createRequire)(t).resolve(e),S=(e,t)=>{let n=(0,u.dirname)(t);(0,c.existsSync)(n)||(0,c.mkdirSync)(n,{recursive:!0}),(0,c.copyFileSync)(e,t)},C=(e,{media:t,supports:n})=>{let r=`@import url('${e}')`;return n&&(r+=` supports(${n})`),t&&(r+=` ${t}`),`${r};`},w=(e,t,r,i={})=>{let a=v(e),{url:o}=a,s=i.resolveModule??x,c=i.copyAsset??S;if(_.test(o)||o.startsWith(`/`))return{rule:C(o,a)};if(o.startsWith(`./`)||o.startsWith(`../`)){let e=(0,u.resolve)((0,u.dirname)(t),o);return{rule:C(y(b((0,u.relative)((0,u.join)(r,`css`),e))),a)}}let l=s(o.startsWith(`~`)?o.slice(1):o,t),d=`${n.toHash(l,6)}-${(0,u.basename)(l)}`;return c(l,(0,u.join)(r,`imports`,d)),{rule:C(`../imports/${d}`,a)}},T=async e=>{let t=await o.getPackageJson(e);if(t)return t.type},E,D=async e=>{if(E)return E;let t=await T(e);return t===`module`?E=`esm`:(t===`commonjs`||{}.url.endsWith(`.cjs`))&&(E=`cjs`),E||`esm`};function O(e){return e?typeof e==`string`?e.replace(/[^\d\w]/g,`.`):O(String(e)):``}var k={"*, *::before, *::after":{boxSizing:`border-box`},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:`100%`,WebkitFontSmoothing:`antialiased`},"img, picture, video, canvas, svg":{display:`block`,maxWidth:`100%`},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:`break-word`},p:{textWrap:`pretty`},"h1, h2, h3, h4, h5, h6":{textWrap:`balance`},a:{color:`currentColor`},button:{lineHeight:`1em`,color:`currentColor`},"input, optgroup, select, textarea":{fontFamily:`inherit`,fontSize:`100%`,lineHeight:`1.15em`}},A=class{projectRootDir;options;importFile=e=>import(`${e}?t=${Date.now()}`);cache={rcFile:null,destDir:null,externalModules:[]};constructor(e,t={}){if(this.projectRootDir=e,this.options=t,typeof process>`u`)throw Error(`SaltyServer can only be used in a Node.js environment.`)}get isProduction(){if(this.options.mode)return this.options.mode===`production`;try{return process.env.NODE_ENV!==`development`}catch{return!1}}readRCFile=async(e=this.projectRootDir)=>{if(this.cache.rcFile)return this.cache.rcFile;if(e===`/`)throw Error(`Could not find .saltyrc.json file`);let t=await(0,f.readFile)((0,u.join)(e,`.saltyrc.json`),`utf-8`).then(JSON.parse).catch(()=>void 0);return t?(this.cache.rcFile=t,t):this.readRCFile((0,u.join)(e,`..`))};getRCProjectConfig=async e=>{let t=await this.readRCFile(e);return t.projects?.find(t=>e.endsWith(t.dir||``))||t.projects?.find(e=>e.dir===t.defaultProject)};getPathFilter=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir);return{include:e?.include,exclude:e?.exclude}};isAllowedSaltyFile=(e,r)=>t.isSaltyFile(e)?n.isPathAllowed(n.normalizePath((0,u.relative)(this.projectRootDir,e)),r):!1;getExternalModules=e=>{if(this.cache.externalModules.length>0)return this.cache.externalModules;let t=(0,c.readFileSync)(e,`utf8`).match(/externalModules:\s?\[(.*)\]/);if(!t)return[];let n=t[1].split(`,`).map(e=>e.replace(/['"`]/g,``).trim());return this.cache.externalModules=n,n};getDestDir=async()=>{if(this.cache.destDir)return this.cache.destDir;let e=await this.getRCProjectConfig(this.projectRootDir),t=(0,u.join)(this.projectRootDir,e?.saltygenDir||`saltygen`);return this.cache.destDir=t,t};generateConfig=async()=>{let e=await this.getRCProjectConfig(this.projectRootDir),t=await this.getDestDir(),n=(0,u.join)(this.projectRootDir,e?.configDir||``,`salty.config.ts`),r=(0,u.join)(t,`salty.config.js`),i=await D(this.projectRootDir),a=this.getExternalModules(n);await l.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:i,external:a});let{config:o}=await this.importFile(r);return{config:o,path:r}};addConfigCache=e=>{try{let t=(0,c.readFileSync)((0,u.join)(this.projectRootDir,`saltygen/cache/config-cache.json`),`utf8`);return t?`globalThis.saltyConfig = ${t};\n\n${e}`:`globalThis.saltyConfig = {};\n\n${e}`}catch{return e}};getConfigCache=async()=>{let e=(0,c.readFileSync)((0,u.join)(await this.getDestDir(),`cache/config-cache.json`),`utf8`);if(!e)throw Error(`Could not find config cache file`);return JSON.parse(e)};getConfig=async()=>{let e=await this.getConfigCache(),t=(0,u.join)(await this.getDestDir(),`salty.config.js`),{config:n}=await this.importFile(t);return a.mergeObjects(n,e)};generateCss=async(e=!0)=>{try{let r=Date.now();this.isProduction?h.info(`Generating CSS in production mode! 🔥`):h.info(`Generating CSS in development mode! 🚀`);let i=[],a=[],o=await this.getDestDir(),s=(0,u.join)(o,`index.css`);e&&((0,c.existsSync)(o)&&(0,p.execSync)(`rm -rf `+o),(0,c.mkdirSync)(o,{recursive:!0}),(0,c.mkdirSync)((0,u.join)(o,`css`)),(0,c.mkdirSync)((0,u.join)(o,`types`)),(0,c.mkdirSync)((0,u.join)(o,`js`)),(0,c.mkdirSync)((0,u.join)(o,`cache`)),(0,c.mkdirSync)((0,u.join)(o,`imports`)));let l=new Set,d=new Set,f=await this.getPathFilter(),{exclude:m}=f,g=this.projectRootDir;async function _(e){let r=[`node_modules`,`saltygen`],i=(0,c.statSync)(e);if(i.isDirectory()){if(r.some(t=>e.includes(t)))return;if(m?.length){let t=n.normalizePath((0,u.relative)(g,e));if(t&&!n.isPathAllowed(t,{exclude:m}))return}let t=(0,c.readdirSync)(e);await Promise.all(t.map(t=>_((0,u.join)(e,t))))}else if(i.isFile()&&t.isSaltyFile(e)&&n.isPathAllowed(n.normalizePath((0,u.relative)(g,e)),f)){l.add(e);let t=(0,c.readFileSync)(e,`utf8`);/define[\w\d]+\(/.test(t)&&d.add(e)}}await _(this.projectRootDir),await this.generateConfigStyles(d);let v={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async e=>{let{contents:n}=await this.compileSaltyFile(e,o);for(let[r,i]of Object.entries(n)){let n=await t.resolveExportValue(i,1);n.isKeyframes?v.keyframes.push({value:n,src:e,name:r}):n.isClassName?v.classNames.push({...i,src:e,name:r}):n.generator&&v.components.push({...i,src:e,name:r})}}));let y=await this.getConfig();for(let e of v.keyframes){let{value:t}=e,n=`a_${t.animationName}.css`,r=(0,u.join)(o,`css/${n}`);i.push(n),(0,c.writeFileSync)(r,t.css)}let b={};for(let e of v.components){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y});a[r.priority]||(a[r.priority]=[]);let i=await r.css;i&&(a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}for(let e of v.classNames){let{src:t,name:n}=e;b[t]||(b[t]=[]);let r=e.generator._withBuildContext({callerName:n,isProduction:this.isProduction,config:y}),i=await r.css;i&&(a[r.priority]||(a[r.priority]=[]),a[r.priority].push(r.cssFileName),(0,c.writeFileSync)((0,u.join)(o,`css/${r.cssFileName}`),i),y.importStrategy===`component`&&b[t].push(r.cssFileName))}y.importStrategy===`component`&&Object.entries(b).forEach(([e,t])=>{let r=t.map(e=>`@import url('./${e}');`).join(`
|
|
2
2
|
`),i=n.toHash(e,6);(0,c.writeFileSync)((0,u.join)(o,`css/f_${n.dashCase((0,u.parse)(e).name)}-${i}.css`),r||`/* Empty file */`)});let x=i.map(e=>`@import url('./css/${e}');`).join(`
|
|
3
3
|
`),S=`/*!
|
|
4
4
|
* Generated with Salty CSS (https://salty-css.dev)
|
package/package.json
CHANGED
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
"homepage": "https://salty-css.dev/",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/margarita-form/salty-css.git"
|
|
12
|
+
"url": "git+https://github.com/margarita-form/salty-css.git",
|
|
13
|
+
"directory": "libs/core"
|
|
13
14
|
},
|
|
14
15
|
"bugs": {
|
|
15
16
|
"url": "https://github.com/margarita-form/salty-css/issues"
|
|
16
17
|
},
|
|
17
|
-
"version": "0.3.0-refactor-vite-8.
|
|
18
|
+
"version": "0.3.0-refactor-vite-8.5",
|
|
18
19
|
"type": "module",
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "vite build",
|
|
@@ -135,5 +136,22 @@
|
|
|
135
136
|
"salty-css": "./dist/bin/index.js",
|
|
136
137
|
"salty-css-cjs": "./dist/bin/index.cjs",
|
|
137
138
|
"@salty-css/core": "./dist/bin/index.js"
|
|
138
|
-
}
|
|
139
|
+
},
|
|
140
|
+
"author": {
|
|
141
|
+
"name": "Teemu Lahjalahti",
|
|
142
|
+
"url": "https://www.linkedin.com/in/teemulahjalahti/"
|
|
143
|
+
},
|
|
144
|
+
"keywords": [
|
|
145
|
+
"salty-css",
|
|
146
|
+
"css-in-js",
|
|
147
|
+
"css",
|
|
148
|
+
"styling",
|
|
149
|
+
"build-time",
|
|
150
|
+
"compiler",
|
|
151
|
+
"design-tokens"
|
|
152
|
+
],
|
|
153
|
+
"engines": {
|
|
154
|
+
"node": ">=22"
|
|
155
|
+
},
|
|
156
|
+
"sideEffects": false
|
|
139
157
|
}
|