@salty-css/webpack 0.0.1-alpha.18 → 0.0.1-alpha.181

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 CHANGED
@@ -1,15 +1,132 @@
1
- # Salty Css
1
+ ![Salty CSS Banner](https://salty-css.dev/assets/banners/dvd.svg)
2
2
 
3
- ## Basic usage example with Button
3
+ # Salty CSS - CSS-in-JS library that is kinda sweet
4
4
 
5
- ### Initial requirements
5
+ Is there anything saltier than CSS in frontend web development? Salty CSS is built to provide better developer experience for developers looking for performant and feature rich CSS-in-JS solutions.
6
6
 
7
- 1. Add `saltyPlugin` to vite or webpack config from `@salty-css/vite` or `@salty-css/webpack`
8
- 2. Create `salty.config.ts` to the root of your project
9
- 3. Import global styles to any regular .css file from `saltygen/index.css` (does not exist during first run, cli command coming later)
10
- 4. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
7
+ ## Features
11
8
 
12
- ### Code examples
9
+ - Build time compilation to achieve awesome runtime performance and minimal size
10
+ - Next.js, React Server Components, Vite and Webpack support
11
+ - Type safety with out of the box TypeScript and ESLint plugin
12
+ - Advanced CSS variables configuration to allow smooth token usage
13
+ - Style templates to create reusable styles easily
14
+
15
+ ## Get started
16
+
17
+ Fastest way to get started with any framework is `npx salty-css init [directory]` command
18
+
19
+ - Next.js → [Next.js guide](#nextjs) + [Next.js example app](https://github.com/margarita-form/salty-css-website)
20
+ - React + Vite → [React + Vite guide](#react--vite) + [React example code](#code-examples)
21
+ - React + Webpack → Guide coming soon
22
+
23
+ ## Useful commands
24
+
25
+ - Create component: `npx salty-css generate [filePath]`
26
+ - Build: `npx salty-css build [directory]`
27
+ - Update Salty CSS packages: `npx salty-css up`
28
+
29
+ ## Salty CSS styled function
30
+
31
+ ```ts
32
+ // components/wrapper.css.ts
33
+ import { styled } from '@salty-css/react/styled';
34
+
35
+ // Define a component with styled function. First argument is the component name or existing component to extend and second argument is the object containing the styles and other options
36
+ export const Component = styled('div', {
37
+ className: 'wrapper', // Define custom class name that will be included for this component
38
+ element: 'section', // Define the html element that will be rendered for this component, overrides the first 'div' argument
39
+ base: {
40
+ // 👉 Add your CSS-in-JS base styles here! 👈
41
+ },
42
+ variants: {
43
+ // Define conditional styles that will be applied to the component based on the variant prop values
44
+ },
45
+ compoundVariants: [
46
+ // Define conditional styles that will be applied to the component based on the combination of variant prop values
47
+ ],
48
+ defaultVariants: {
49
+ // Set default variant prop values
50
+ },
51
+ defaultProps: {
52
+ // Add additional default props for the component (eg, id and other html element attributes)
53
+ },
54
+ passProps: true, // Pass variant props to the rendered element / parent component (default: false)
55
+ });
56
+ ```
57
+
58
+ ## Salty CSS CLI
59
+
60
+ In your existing repository you can use `npx salty-css [command]` to initialize a project, generate components, update related packages and build required files.
61
+
62
+ - Initialize project → `npx salty-css init [directory]` - Installs required packages, detects framework in use and creates project files to the provided directory. Directory can be left blank if you want files to be created to the current directory.
63
+ - Generate component → `npx salty-css update [version]` - Update @salty-css packages in your repository. Default version is "latest". Additional options like `--dir`, `--tag`, `--name` and `--className` are also supported.
64
+ - Build files → `npx salty-css build [directory]` - Compile Salty CSS related files in your project. This should not be needed if you are using tools like Next.js or Vite
65
+
66
+ ## Usage
67
+
68
+ ### Next.js
69
+
70
+ ![salty-next](https://github.com/user-attachments/assets/2cf6a93f-cdd5-4f5f-ab2e-3bc8bcfb83e8)
71
+
72
+ Salty CSS provides Next.js App & Pages router support with full React Server Components support.
73
+
74
+ ### Add Salty CSS to Next.js
75
+
76
+ 1. In your existing Next.js repository you can run `npx salty-css init` to automatically configure Salty CSS.
77
+ 2. Create your first Salty CSS component with `npx salty-css generate [filePath]` (e.g. src/custom-wrapper)
78
+ 3. Import your component for example to `page.tsx` and see it working!
79
+
80
+ And note: steps 2 & 3 are just to show how get new components up and running, step 1 does all of the important stuff 🤯
81
+
82
+ #### Manual configuration
83
+
84
+ 1. For Next.js support install `npm i @salty-css/next @salty-css/core @salty-css/react`
85
+ 2. Create `salty.config.ts` to your app directory
86
+ 3. Add Salty CSS plugin to next.js config
87
+
88
+ - **Next.js 15:** In `next.config.ts` add import for salty plugin `import { withSaltyCss } from '@salty-css/next';` and then add `withSaltyCss` to wrap your nextConfig export like so `export default withSaltyCss(nextConfig);`
89
+ - **Next.js 14 and older:** In `next.config.js` add import for salty plugin `const { withSaltyCss } = require('@salty-css/next');` and then add `withSaltyCss` to wrap your nextConfig export like so `module.exports = withSaltyCss(nextConfig);`
90
+
91
+ 4. Make sure that `salty.config.ts` and `next.config.ts` are in the same folder!
92
+ 5. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
93
+ 6. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
94
+
95
+ [Check out Next.js demo project](https://github.com/margarita-form/salty-css-website) or [react example code](#code-examples)
96
+
97
+ ---
98
+
99
+ ### React + Vite
100
+
101
+ ![salty-vite-react](https://github.com/user-attachments/assets/12ec5b6a-0dcc-48fa-afc1-d337fc8f800c)
102
+
103
+ ### Add Salty CSS to your React + Vite app
104
+
105
+ 1. In your existing Vite repository you can run `npx salty-css init` to automatically configure Salty CSS.
106
+ 2. Create your first Salty CSS component with `npx salty-css generate [filePath]` (e.g. src/custom-wrapper)
107
+ 3. Import your component for example to `main.tsx` and see it working!
108
+
109
+ And note: steps 2 & 3 are just to show how get new components up and running, step 1 does all of the important stuff 🤯
110
+
111
+ #### Manual configuration
112
+
113
+ 1. For Vite support install `npm i @salty-css/vite @salty-css/core`
114
+ 2. In `vite.config` add import for salty plugin `import { saltyPlugin } from '@salty-css/vite';` and then add `saltyPlugin(__dirname)` to your vite configuration plugins
115
+ 3. Make sure that `salty.config.ts` and `vite.config.ts` are in the same folder!
116
+ 4. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
117
+ 5. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
118
+
119
+ [Check out react example code](#code-examples)
120
+
121
+ ---
122
+
123
+ ### Create components
124
+
125
+ 1. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
126
+
127
+ ## Code examples
128
+
129
+ ### Basic usage example with Button
13
130
 
14
131
  **Salty config**
15
132
 
@@ -31,23 +148,6 @@ export const config = defineConfig({
31
148
  });
32
149
  ```
33
150
 
34
- **Your React component file**
35
-
36
- ```tsx
37
- import { Wrapper } from '../components/wrapper/wrapper.css';
38
- import { Button } from '../components/button/button.css';
39
-
40
- export const IndexPage = () => {
41
- return (
42
- <Wrapper>
43
- <Button variant="solid" onClick={() => alert('It is a button.')}>
44
- Outlined
45
- </Button>
46
- </Wrapper>
47
- );
48
- };
49
- ```
50
-
51
151
  **Wrapper** (`components/wrapper/wrapper.css.ts`)
52
152
 
53
153
  ```tsx
@@ -72,7 +172,7 @@ export const Button = styled('button', {
72
172
  padding: `0.6em 1.2em`,
73
173
  border: '1px solid currentColor',
74
174
  background: 'transparent',
75
- color: 'currentColor/40',
175
+ color: 'currentColor',
76
176
  cursor: 'pointer',
77
177
  transition: '200ms',
78
178
  textDecoration: 'none',
@@ -108,4 +208,21 @@ export const Button = styled('button', {
108
208
  });
109
209
  ```
110
210
 
211
+ **Your React component file**
212
+
213
+ ```tsx
214
+ import { Wrapper } from '../components/wrapper/wrapper.css';
215
+ import { Button } from '../components/button/button.css';
216
+
217
+ export const IndexPage = () => {
218
+ return (
219
+ <Wrapper>
220
+ <Button variant="solid" onClick={() => alert('It is a button.')}>
221
+ Outlined
222
+ </Button>
223
+ </Wrapper>
224
+ );
225
+ };
226
+ ```
227
+
111
228
  More examples coming soon
@@ -0,0 +1,36 @@
1
+ "use strict";const me=require("esbuild"),he=require("child_process"),l=require("path"),u=require("fs"),X=require("fs/promises"),q=require("winston");var U=typeof document<"u"?document.currentScript:null;function Se(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ne=Se(me),te=e=>String.fromCharCode(e+(e>25?39:97)),be=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=te(n%52)+s;return s=te(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},je=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},H=(e,t=5)=>{const s=je(5381,JSON.stringify(e))>>>0;return be(s,t)};function R(e){return e?typeof e!="string"?R(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const $e=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:a}=n;e=e.replace(i,c=>{const{value:p,css:r}=a(c);return r&&s.push(r),p})}),{result:e,additionalCss:s}},oe=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${R(n[1].replaceAll(".","-"))})`)}:{result:e},M=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((c,[p,r])=>{const o=p.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return c;if(o==="variants")return Object.entries(r).forEach(([P,S])=>{S&&Object.entries(S).forEach(([E,f])=>{if(!f)return;const $=`${t}.${P}-${E}`,b=M(f,$);n.push(b)})}),c;if(o==="defaultVariants")return c;if(o==="compoundVariants")return r.forEach(P=>{const{css:S,...E}=P,f=Object.entries(E).reduce((b,[w,m])=>`${b}.${w}-${m}`,t),$=M(S,f);n.push($)}),c;if(o.startsWith("@")){const P=M(r,t),S=`${o} {
2
+ ${P.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return n.push(S),c}const j=p.includes("&")?o.replace("&",t):o.startsWith(":")?`${t}${o}`:`${t} ${o}`,F=M(r,j);return n.push(F),c}const g=o.startsWith("-")?o:R(o),d=(j,F=";")=>c=`${c}${j}${F}`,y=j=>d(`${g}:${j}`);if(typeof r=="number")return y(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return c;const{modifiers:k}={},_=function*(){yield oe(r),yield $e(r,k)}();for(const{result:j,additionalCss:F=[]}of _)r=j,F.forEach(P=>{const S=M(P,"");d(S,"")});return y(r)},"");return i?t?[`${t} { ${i} }`,...n].join(`
6
+ `):i:n.join(`
7
+ `)},re=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,a])=>{if(typeof a=="object"){if(!a)return;const c=i.trim(),p=re(a,[...t,c]);s.push(p)}else n[i]=a}),Object.keys(n).length){const i=t.map(R).join("-"),a=M(n,`.${i}`);s.push(a)}return s.join(`
8
+ `)},we=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ie(n).map(i=>`"${i}"`).join(" | ")),t),{}):{},ie=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const a=t?`${t}.${n}`:n;return typeof i=="object"?ie(i,a,s):s.add(t)}),[...s]):[],ce=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ce(l.join(e,".."))},Fe=async e=>{const t=ce(e);return await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ce=async e=>{const t=await Fe(e);if(t)return t.type};let W;const ae=async e=>{if(W)return W;const t=await Ce(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("index-CgxcvuUt.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},Q=q.createLogger({level:"debug",format:q.format.combine(q.format.colorize(),q.format.cli()),transports:[new q.transports.Console({})]});function le(e){return e?typeof e!="string"?le(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const xe={"*, *::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"}},z=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),V={externalModules:[],rcFile:void 0,destDir:void 0},fe=e=>{if(V.externalModules.length>0)return V.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return V.externalModules=n,n},J=async e=>{if(V.destDir)return V.destDir;const t=await Y(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return V.destDir=s,s},ue=["salty","css","styles","styled"],pe=(e=[])=>new RegExp(`\\.(${[...ue,...e].join("|")})\\.`),L=(e,t=[])=>pe(t).test(e),de=async e=>{if(V.rcFile)return V.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(V.rcFile=s,s):de(l.join(e,".."))},Y=async e=>{var n,i;const t=await de(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((i=t.projects)==null?void 0:i.find(a=>a.dir===t.defaultProject))},ke=async e=>{const t=await Y(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),i=l.join(s,"salty.config.js"),a=await ae(e),c=fe(n);await ne.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:i,format:a,external:c});const p=Date.now(),{config:r}=await import(`${i}?t=${p}`);return r},De=async(e,t)=>{const s=await ke(e),n={...s},i=new Set,a=(D,x=[])=>D?Object.entries(D).flatMap(([O,T])=>{if(!T)return;if(typeof T=="object")return a(T,[...x,O]);const A=le(O),G=R(O),B=[...x,A].join(".");i.add(`"${B}"`);const K=[...x.map(R),G].join("-"),{result:ge}=oe(T);return`--${K}: ${ge};`}):[],c=D=>D?Object.entries(D).flatMap(([x,O])=>{const T=a(O);return x==="base"?T.join(""):`${x} { ${T.join("")} }`}):[],p=D=>D?Object.entries(D).flatMap(([x,O])=>Object.entries(O).flatMap(([T,A])=>{const G=a(A,[x]),B=`.${x}-${T}, [data-${x}="${T}"]`,K=G.join("");return`${B} { ${K} }`})):[],r=D=>t.variables.map(x=>x._current[D]),o=a(z(s.variables,r("variables"))),g=c(z(s.responsiveVariables,r("responsiveVariables"))),d=p(z(s.conditionalVariables,r("conditionalVariables"))),y=await J(e),k=l.join(y,"css/_variables.css"),N=`:root { ${o.join("")} ${g.join("")} } ${d.join("")}`;u.writeFileSync(k,N);const _=l.join(y,"css/_global.css"),j=z(s.global,t.globalStyles),F=M(j,"");u.writeFileSync(_,`@layer global { ${F} }`);const P=l.join(y,"css/_reset.css"),E=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:xe,f=M(E,"");u.writeFileSync(P,`@layer reset { ${f} }`);const $=l.join(y,"css/_templates.css"),b=z(s.templates,t.templates),w=re(b),m=we(b);u.writeFileSync($,w),n.templates=b;const C=l.join(y,"types/css-tokens.d.ts"),I=`
9
+ // Variable types
10
+ type VariableTokens = ${[...i].join("|")};
11
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
12
+
13
+ // Template types
14
+ type TemplateTokens = {
15
+ ${Object.entries(m).map(([D,x])=>`${D}?: ${x}`).join(`
16
+ `)}
17
+ }
18
+ `;u.writeFileSync(C,I);const Z=l.join(y,"cache/config-cache.json");u.writeFileSync(Z,JSON.stringify(n,null,2))},se=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(e))return t;const c=i.exec(e);if(c){const p=c.at(1);if(ue.some(o=>p==null?void 0:p.includes(o)))return t}return"styled('div',"}),v=async(e,t,s)=>{const n=H(t),i=l.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const a=l.parse(t);let c=u.readFileSync(t,"utf8");c=se(c);const p=l.join(s,"js",n+".js"),r=await Y(e),o=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),g=fe(o),d=await ae(e);await ne.build({stdin:{contents:c,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:d,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:N=>{N.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},_=>{const j=u.readFileSync(_.path,"utf8");return{contents:se(j),loader:"ts"}})}}]});const y=Date.now();return await import(`${p}?t=${y}`)},Ne=async e=>{const t=await J(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ee=async e=>{const t=await Ne(e),s=await J(e),n=l.join(s,"salty.config.js"),i=Date.now(),{config:a}=await import(`${n}?t=${i}`);return z(a,t)},ye=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Pe=async(e,t=ye(),s=!0)=>{try{const n=Date.now();t?Q.info("Generating CSS in production mode! 🔥"):Q.info("Generating CSS in development mode! 🚀");const i=[],a=[],c=await J(e),p=l.join(c,"index.css");s&&(()=>{u.existsSync(c)&&he.execSync("rm -rf "+c),u.mkdirSync(c,{recursive:!0}),u.mkdirSync(l.join(c,"css")),u.mkdirSync(l.join(c,"types")),u.mkdirSync(l.join(c,"js")),u.mkdirSync(l.join(c,"cache"))})();const o={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],components:[],templates:[]};async function g(f){const $=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const w=u.readdirSync(f);if($.some(C=>f.includes(C)))return;await Promise.all(w.map(C=>g(l.join(f,C))))}else if(b.isFile()&&L(f)){const m=await v(e,f,c);Object.entries(m).forEach(([C,h])=>{h.isKeyframes?o.keyframes.push({value:h,src:f,name:C}):h.isMedia?o.mediaQueries.push(h):h.isGlobalDefine?o.globalStyles.push(h):h.isDefineVariables?o.variables.push(h):h.isDefineTemplates?o.templates.push(h):h.generator&&o.components.push({value:h.generator,src:f,name:C})})}}await g(e),await De(e,o);const d=await ee(e);for(const f of o.keyframes){const{value:$}=f,b=`a_${$.animationName}.css`,w=`css/${b}`,m=l.join(c,w);i.push(b),u.writeFileSync(m,$.css)}const y={};for(const f of o.components){const{value:$,name:b,src:w}=f,m=$._withBuildContext({name:b,config:d,prod:t});a[m.priority]||(a[m.priority]=[]),a[m.priority].push(m.cssFileName),d.importStrategy==="component"&&(y[w]?y[w].push(m.cssFileName):y[w]=[m.cssFileName]);const C=`css/${m.cssFileName}`,h=l.join(c,C);u.writeFileSync(h,m.css)}d.importStrategy==="component"&&Object.entries(y).forEach(([f,$])=>{const b=$.map(I=>`@import url('./${I}');`).join(`
19
+ `),w=H(f,6),m=l.parse(f),C=R(m.name),h=l.join(c,`css/f_${C}-${w}.css`);u.writeFileSync(h,b)});const k=i.map(f=>`@import url('./css/${f}');`).join(`
20
+ `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
+
22
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(l.join(c,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
23
+ `)}
24
+ ${k}`;if(d.importStrategy!=="component"){const f=a.reduce(($,b,w)=>{const m=b.reduce((Z,D)=>{var A;const x=l.join(c,"css",D),O=u.readFileSync(x,"utf8"),T=((A=/.*-([^-]+)-\d+.css/.exec(D))==null?void 0:A.at(1))||H(x,6);return Z.includes(T)?Z:`${Z}
25
+ /*start:${T}*/
26
+ ${O}
27
+ /*end:${T}*/
28
+ `},""),C=`l_${w}.css`,h=l.join(c,"css",C),I=`@layer l${w} { ${m}
29
+ }`;return u.writeFileSync(h,I),`${$}
30
+ @import url('./css/${C}');`},"");F+=f}u.writeFileSync(p,F);const S=Date.now()-n,E=S<200?"🔥":S<500?"🚀":S<1e3?"🎉":S<2e3?"🚗":S<5e3?"🤔":"🥴";Q.info(`Generated CSS in ${S}ms! ${E}`)}catch(n){console.error(n)}},Te=async(e,t)=>{try{const s=await J(e);if(L(t)){const i=[],a=await ee(e),c=await v(e,t,s);Object.entries(c).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const k=`css/${`a_${r.animationName}.css`}`,N=l.join(s,k);u.writeFileSync(N,r.css);return}if(!r.generator)return;const o=r.generator._withBuildContext({name:p,config:a}),g=`css/${o.cssFileName}`,d=l.join(s,g);u.writeFileSync(d,o.css),i[o.priority]||(i[o.priority]=[]),i[o.priority].push(o.cssFileName)}),a.importStrategy!=="component"&&i.forEach((p,r)=>{const o=`l_${r}.css`,g=l.join(s,"css",o);let d=u.readFileSync(g,"utf8");p.forEach(y=>{var j;const k=l.join(s,"css",y),N=((j=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:j.at(1))||H(k,6);if(!d.includes(N)){const F=u.readFileSync(k,"utf8"),P=`/*start:${N}*/
31
+ ${F}
32
+ /*end:${N}*/
33
+ `;d=`${d.replace(/\}$/,"")}
34
+ ${P}
35
+ }`}}),u.writeFileSync(g,d)})}}catch(s){console.error(s)}},_e=async(e,t,s=ye())=>{try{const n=await J(e);if(L(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==a&&await X.writeFile(t,a);const p=await ee(e),r=await v(e,t,n);let o=a;if(Object.entries(r).forEach(([g,d])=>{var C;if(d.isKeyframes||!d.generator)return;const y=d.generator._withBuildContext({name:g,config:p,prod:s}),k=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!k)return console.error("Could not find the original declaration");const N=(C=k.at(1))==null?void 0:C.trim(),_=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(o);if(!_)return console.error("Could not find the original declaration");const{index:j}=_;let F=!1;const P=setTimeout(()=>F=!0,5e3);let S=0,E=!1,f=0;for(;!E&&!F;){const h=o[j+S];h==="("&&f++,h===")"&&f--,f===0&&h===")"&&(E=!0),S>o.length&&(F=!0),S++}if(!F)clearTimeout(P);else throw new Error("Failed to find the end of the styled call and timed out");const $=j+S,b=o.slice(j,$),w=o,m=` ${g} = styled(${N}, "${y.classNames}", ${JSON.stringify(y.props)});`;o=o.replace(b,m),w===o&&console.error("Minimize file failed to change content",{name:g,tagName:N})}),p.importStrategy==="component"){const g=H(t,6),d=l.parse(t);o=`import '../../saltygen/css/${`f_${R(d.name)}-${g}.css`}';
36
+ ${o}`}return o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Pe;exports.generateFile=Te;exports.isSaltyFile=L;exports.minimizeFile=_e;exports.saltyFileRegExp=pe;
@@ -0,0 +1,488 @@
1
+ import * as rt from "esbuild";
2
+ import { execSync as $t } from "child_process";
3
+ import { join as f, parse as X } from "path";
4
+ import { existsSync as Y, writeFileSync as E, readFileSync as M, mkdirSync as Z, statSync as bt, readdirSync as St } from "fs";
5
+ import { readFile as it, writeFile as wt } from "fs/promises";
6
+ import { createLogger as jt, format as Q, transports as Ct } from "winston";
7
+ const nt = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Ft = (t, e) => {
8
+ let s = "", n;
9
+ for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = nt(n % 52) + s;
10
+ return s = nt(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
11
+ }, xt = (t, e) => {
12
+ let s = e.length;
13
+ for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
14
+ return t;
15
+ }, L = (t, e = 5) => {
16
+ const s = xt(5381, JSON.stringify(t)) >>> 0;
17
+ return Ft(s, e);
18
+ };
19
+ function A(t) {
20
+ return t ? typeof t != "string" ? A(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
21
+ }
22
+ const kt = (t, e) => {
23
+ if (typeof t != "string") return { result: t };
24
+ if (!e) return { result: t };
25
+ const s = [];
26
+ return Object.values(e).forEach((n) => {
27
+ const { pattern: i, transform: a } = n;
28
+ t = t.replace(i, (c) => {
29
+ const { value: p, css: r } = a(c);
30
+ return r && s.push(r), p;
31
+ });
32
+ }), { result: t, additionalCss: s };
33
+ }, ct = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${A(n[1].replaceAll(".", "-"))})`) } : { result: t }, J = (t, e, s) => {
34
+ if (!t) return "";
35
+ const n = [], i = Object.entries(t).reduce((c, [p, r]) => {
36
+ const o = p.trim();
37
+ if (typeof r == "function" && (r = r()), typeof r == "object") {
38
+ if (!r) return c;
39
+ if (o === "variants")
40
+ return Object.entries(r).forEach(([N, y]) => {
41
+ y && Object.entries(y).forEach(([O, l]) => {
42
+ if (!l) return;
43
+ const S = `${e}.${N}-${O}`, $ = J(l, S);
44
+ n.push($);
45
+ });
46
+ }), c;
47
+ if (o === "defaultVariants")
48
+ return c;
49
+ if (o === "compoundVariants")
50
+ return r.forEach((N) => {
51
+ const { css: y, ...O } = N, l = Object.entries(O).reduce(($, [w, m]) => `${$}.${w}-${m}`, e), S = J(y, l);
52
+ n.push(S);
53
+ }), c;
54
+ if (o.startsWith("@")) {
55
+ const N = J(r, e), y = `${o} {
56
+ ${N.replace(`
57
+ `, `
58
+ `)}
59
+ }`;
60
+ return n.push(y), c;
61
+ }
62
+ const b = p.includes("&") ? o.replace("&", e) : o.startsWith(":") ? `${e}${o}` : `${e} ${o}`, j = J(r, b);
63
+ return n.push(j), c;
64
+ }
65
+ const g = o.startsWith("-") ? o : A(o), u = (b, j = ";") => c = `${c}${b}${j}`, d = (b) => u(`${g}:${b}`);
66
+ if (typeof r == "number") return d(r);
67
+ if (typeof r != "string")
68
+ if ("toString" in r) r = r.toString();
69
+ else return c;
70
+ const { modifiers: x } = {}, T = function* () {
71
+ yield ct(r), yield kt(r, x);
72
+ }();
73
+ for (const { result: b, additionalCss: j = [] } of T)
74
+ r = b, j.forEach((N) => {
75
+ const y = J(N, "");
76
+ u(y, "");
77
+ });
78
+ return d(r);
79
+ }, "");
80
+ return i ? e ? [`${e} { ${i} }`, ...n].join(`
81
+ `) : i : n.join(`
82
+ `);
83
+ }, at = (t, e = []) => {
84
+ if (!t) return "";
85
+ const s = [], n = {};
86
+ if (Object.entries(t).forEach(([i, a]) => {
87
+ if (typeof a == "object") {
88
+ if (!a) return;
89
+ const c = i.trim(), p = at(a, [...e, c]);
90
+ s.push(p);
91
+ } else
92
+ n[i] = a;
93
+ }), Object.keys(n).length) {
94
+ const i = e.map(A).join("-"), a = J(n, `.${i}`);
95
+ s.push(a);
96
+ }
97
+ return s.join(`
98
+ `);
99
+ }, Dt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = lt(n).map((i) => `"${i}"`).join(" | ")), e), {}) : {}, lt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, i]) => {
100
+ const a = e ? `${e}.${n}` : n;
101
+ return typeof i == "object" ? lt(i, a, s) : s.add(e);
102
+ }), [...s]) : [], ft = (t) => {
103
+ if (!t || t === "/") throw new Error("Could not find package.json file");
104
+ const e = f(t, "package.json");
105
+ return Y(e) ? e : ft(f(t, ".."));
106
+ }, Nt = async (t) => {
107
+ const e = ft(t);
108
+ return await it(e, "utf-8").then(JSON.parse).catch(() => {
109
+ });
110
+ }, Pt = async (t) => {
111
+ const e = await Nt(t);
112
+ if (e)
113
+ return e.type;
114
+ };
115
+ let z;
116
+ const pt = async (t) => {
117
+ if (z) return z;
118
+ const e = await Pt(t);
119
+ return e === "module" ? z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (z = "cjs"), z || "esm";
120
+ }, U = jt({
121
+ level: "debug",
122
+ format: Q.combine(Q.colorize(), Q.cli()),
123
+ transports: [new Ct.Console({})]
124
+ });
125
+ function ut(t) {
126
+ return t ? typeof t != "string" ? ut(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
127
+ }
128
+ const Et = {
129
+ /** Set box model to border-box */
130
+ "*, *::before, *::after": {
131
+ boxSizing: "border-box"
132
+ },
133
+ /** Remove default margin and padding */
134
+ "*": {
135
+ margin: 0
136
+ },
137
+ /** Remove adjust font properties */
138
+ html: {
139
+ lineHeight: 1.15,
140
+ textSizeAdjust: "100%",
141
+ WebkitFontSmoothing: "antialiased"
142
+ },
143
+ /** Make media elements responsive */
144
+ "img, picture, video, canvas, svg": {
145
+ display: "block",
146
+ maxWidth: "100%"
147
+ },
148
+ /** Avoid overflow of text */
149
+ "p, h1, h2, h3, h4, h5, h6": {
150
+ overflowWrap: "break-word"
151
+ },
152
+ /** Improve text wrapping */
153
+ p: {
154
+ textWrap: "pretty"
155
+ },
156
+ "h1, h2, h3, h4, h5, h6": {
157
+ textWrap: "balance"
158
+ },
159
+ /** Improve link color */
160
+ a: {
161
+ color: "currentColor"
162
+ },
163
+ /** Improve button line height */
164
+ button: {
165
+ lineHeight: "1em",
166
+ color: "currentColor"
167
+ },
168
+ /** Improve form elements */
169
+ "input, optgroup, select, textarea": {
170
+ fontFamily: "inherit",
171
+ fontSize: "100%",
172
+ lineHeight: "1.15em"
173
+ }
174
+ }, H = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), _ = {
175
+ externalModules: [],
176
+ rcFile: void 0,
177
+ destDir: void 0
178
+ }, dt = (t) => {
179
+ if (_.externalModules.length > 0) return _.externalModules;
180
+ const s = M(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
181
+ if (!s) return [];
182
+ const n = s[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
183
+ return _.externalModules = n, n;
184
+ }, R = async (t) => {
185
+ if (_.destDir) return _.destDir;
186
+ const e = await tt(t), s = f(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
187
+ return _.destDir = s, s;
188
+ }, gt = ["salty", "css", "styles", "styled"], Tt = (t = []) => new RegExp(`\\.(${[...gt, ...t].join("|")})\\.`), v = (t, e = []) => Tt(e).test(t), mt = async (t) => {
189
+ if (_.rcFile) return _.rcFile;
190
+ if (t === "/") throw new Error("Could not find .saltyrc.json file");
191
+ const e = f(t, ".saltyrc.json"), s = await it(e, "utf-8").then(JSON.parse).catch(() => {
192
+ });
193
+ return s ? (_.rcFile = s, s) : mt(f(t, ".."));
194
+ }, tt = async (t) => {
195
+ var n, i;
196
+ const e = await mt(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
197
+ return s || ((i = e.projects) == null ? void 0 : i.find((a) => a.dir === e.defaultProject));
198
+ }, Ot = async (t) => {
199
+ const e = await tt(t), s = await R(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), i = f(s, "salty.config.js"), a = await pt(t), c = dt(n);
200
+ await rt.build({
201
+ entryPoints: [n],
202
+ minify: !0,
203
+ treeShaking: !0,
204
+ bundle: !0,
205
+ outfile: i,
206
+ format: a,
207
+ external: c
208
+ });
209
+ const p = Date.now(), { config: r } = await import(`${i}?t=${p}`);
210
+ return r;
211
+ }, Vt = async (t, e) => {
212
+ const s = await Ot(t), n = { ...s }, i = /* @__PURE__ */ new Set(), a = (k, F = []) => k ? Object.entries(k).flatMap(([V, P]) => {
213
+ if (!P) return;
214
+ if (typeof P == "object") return a(P, [...F, V]);
215
+ const W = ut(V), B = A(V), K = [...F, W].join(".");
216
+ i.add(`"${K}"`);
217
+ const q = [...F.map(A), B].join("-"), { result: yt } = ct(P);
218
+ return `--${q}: ${yt};`;
219
+ }) : [], c = (k) => k ? Object.entries(k).flatMap(([F, V]) => {
220
+ const P = a(V);
221
+ return F === "base" ? P.join("") : `${F} { ${P.join("")} }`;
222
+ }) : [], p = (k) => k ? Object.entries(k).flatMap(([F, V]) => Object.entries(V).flatMap(([P, W]) => {
223
+ const B = a(W, [F]), K = `.${F}-${P}, [data-${F}="${P}"]`, q = B.join("");
224
+ return `${K} { ${q} }`;
225
+ })) : [], r = (k) => e.variables.map((F) => F._current[k]), o = a(H(s.variables, r("variables"))), g = c(H(s.responsiveVariables, r("responsiveVariables"))), u = p(H(s.conditionalVariables, r("conditionalVariables"))), d = await R(t), x = f(d, "css/_variables.css"), D = `:root { ${o.join("")} ${g.join("")} } ${u.join("")}`;
226
+ E(x, D);
227
+ const T = f(d, "css/_global.css"), b = H(s.global, e.globalStyles), j = J(b, "");
228
+ E(T, `@layer global { ${j} }`);
229
+ const N = f(d, "css/_reset.css"), O = s.reset === "none" ? {} : typeof s.reset == "object" ? s.reset : Et, l = J(O, "");
230
+ E(N, `@layer reset { ${l} }`);
231
+ const S = f(d, "css/_templates.css"), $ = H(s.templates, e.templates), w = at($), m = Dt($);
232
+ E(S, w), n.templates = $;
233
+ const C = f(d, "types/css-tokens.d.ts"), I = `
234
+ // Variable types
235
+ type VariableTokens = ${[...i].join("|")};
236
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
237
+
238
+ // Template types
239
+ type TemplateTokens = {
240
+ ${Object.entries(m).map(([k, F]) => `${k}?: ${F}`).join(`
241
+ `)}
242
+ }
243
+ `;
244
+ E(C, I);
245
+ const G = f(d, "cache/config-cache.json");
246
+ E(G, JSON.stringify(n, null, 2));
247
+ }, ot = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
248
+ if (/^['"`]/.test(s)) return e;
249
+ const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
250
+ if (!i.test(t)) return e;
251
+ const c = i.exec(t);
252
+ if (c) {
253
+ const p = c.at(1);
254
+ if (gt.some((o) => p == null ? void 0 : p.includes(o))) return e;
255
+ }
256
+ return "styled('div',";
257
+ }), et = async (t, e, s) => {
258
+ const n = L(e), i = f(s, "./temp");
259
+ Y(i) || Z(i);
260
+ const a = X(e);
261
+ let c = M(e, "utf8");
262
+ c = ot(c);
263
+ const p = f(s, "js", n + ".js"), r = await tt(t), o = f(t, (r == null ? void 0 : r.configDir) || "", "salty.config.ts"), g = dt(o), u = await pt(t);
264
+ await rt.build({
265
+ stdin: {
266
+ contents: c,
267
+ sourcefile: a.base,
268
+ resolveDir: a.dir,
269
+ loader: "tsx"
270
+ },
271
+ minify: !1,
272
+ treeShaking: !0,
273
+ bundle: !0,
274
+ outfile: p,
275
+ format: u,
276
+ target: ["node20"],
277
+ keepNames: !0,
278
+ external: g,
279
+ packages: "external",
280
+ plugins: [
281
+ {
282
+ name: "test",
283
+ setup: (D) => {
284
+ D.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (T) => {
285
+ const b = M(T.path, "utf8");
286
+ return { contents: ot(b), loader: "ts" };
287
+ });
288
+ }
289
+ }
290
+ ]
291
+ });
292
+ const d = Date.now();
293
+ return await import(`${p}?t=${d}`);
294
+ }, _t = async (t) => {
295
+ const e = await R(t), s = f(e, "cache/config-cache.json"), n = M(s, "utf8");
296
+ if (!n) throw new Error("Could not find config cache file");
297
+ return JSON.parse(n);
298
+ }, st = async (t) => {
299
+ const e = await _t(t), s = await R(t), n = f(s, "salty.config.js"), i = Date.now(), { config: a } = await import(`${n}?t=${i}`);
300
+ return H(a, e);
301
+ }, ht = () => {
302
+ try {
303
+ return process.env.NODE_ENV === "production";
304
+ } catch {
305
+ return !1;
306
+ }
307
+ }, zt = async (t, e = ht(), s = !0) => {
308
+ try {
309
+ const n = Date.now();
310
+ e ? U.info("Generating CSS in production mode! 🔥") : U.info("Generating CSS in development mode! 🚀");
311
+ const i = [], a = [], c = await R(t), p = f(c, "index.css");
312
+ s && (() => {
313
+ Y(c) && $t("rm -rf " + c), Z(c, { recursive: !0 }), Z(f(c, "css")), Z(f(c, "types")), Z(f(c, "js")), Z(f(c, "cache"));
314
+ })();
315
+ const o = {
316
+ keyframes: [],
317
+ mediaQueries: [],
318
+ globalStyles: [],
319
+ variables: [],
320
+ components: [],
321
+ templates: []
322
+ };
323
+ async function g(l) {
324
+ const S = ["node_modules", "saltygen"], $ = bt(l);
325
+ if ($.isDirectory()) {
326
+ const w = St(l);
327
+ if (S.some((C) => l.includes(C))) return;
328
+ await Promise.all(w.map((C) => g(f(l, C))));
329
+ } else if ($.isFile() && v(l)) {
330
+ const m = await et(t, l, c);
331
+ Object.entries(m).forEach(([C, h]) => {
332
+ h.isKeyframes ? o.keyframes.push({
333
+ value: h,
334
+ src: l,
335
+ name: C
336
+ }) : h.isMedia ? o.mediaQueries.push(h) : h.isGlobalDefine ? o.globalStyles.push(h) : h.isDefineVariables ? o.variables.push(h) : h.isDefineTemplates ? o.templates.push(h) : h.generator && o.components.push({
337
+ value: h.generator,
338
+ src: l,
339
+ name: C
340
+ });
341
+ });
342
+ }
343
+ }
344
+ await g(t), await Vt(t, o);
345
+ const u = await st(t);
346
+ for (const l of o.keyframes) {
347
+ const { value: S } = l, $ = `a_${S.animationName}.css`, w = `css/${$}`, m = f(c, w);
348
+ i.push($), E(m, S.css);
349
+ }
350
+ const d = {};
351
+ for (const l of o.components) {
352
+ const { value: S, name: $, src: w } = l, m = S._withBuildContext({
353
+ name: $,
354
+ config: u,
355
+ prod: e
356
+ });
357
+ a[m.priority] || (a[m.priority] = []), a[m.priority].push(m.cssFileName), u.importStrategy === "component" && (d[w] ? d[w].push(m.cssFileName) : d[w] = [m.cssFileName]);
358
+ const C = `css/${m.cssFileName}`, h = f(c, C);
359
+ E(h, m.css);
360
+ }
361
+ u.importStrategy === "component" && Object.entries(d).forEach(([l, S]) => {
362
+ const $ = S.map((I) => `@import url('./${I}');`).join(`
363
+ `), w = L(l, 6), m = X(l), C = A(m.name), h = f(c, `css/f_${C}-${w}.css`);
364
+ E(h, $);
365
+ });
366
+ const x = i.map((l) => `@import url('./css/${l}');`).join(`
367
+ `);
368
+ let j = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
369
+
370
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
371
+ try {
372
+ return M(f(c, "css", l), "utf8").length > 0;
373
+ } catch {
374
+ return !1;
375
+ }
376
+ }).map((l) => `@import url('./css/${l}');`).join(`
377
+ `)}
378
+ ${x}`;
379
+ if (u.importStrategy !== "component") {
380
+ const l = a.reduce((S, $, w) => {
381
+ const m = $.reduce((G, k) => {
382
+ var W;
383
+ const F = f(c, "css", k), V = M(F, "utf8"), P = ((W = /.*-([^-]+)-\d+.css/.exec(k)) == null ? void 0 : W.at(1)) || L(F, 6);
384
+ return G.includes(P) ? G : `${G}
385
+ /*start:${P}*/
386
+ ${V}
387
+ /*end:${P}*/
388
+ `;
389
+ }, ""), C = `l_${w}.css`, h = f(c, "css", C), I = `@layer l${w} { ${m}
390
+ }`;
391
+ return E(h, I), `${S}
392
+ @import url('./css/${C}');`;
393
+ }, "");
394
+ j += l;
395
+ }
396
+ E(p, j);
397
+ const y = Date.now() - n, O = y < 200 ? "🔥" : y < 500 ? "🚀" : y < 1e3 ? "🎉" : y < 2e3 ? "🚗" : y < 5e3 ? "🤔" : "🥴";
398
+ U.info(`Generated CSS in ${y}ms! ${O}`);
399
+ } catch (n) {
400
+ console.error(n);
401
+ }
402
+ }, Zt = async (t, e) => {
403
+ try {
404
+ const s = await R(t);
405
+ if (v(e)) {
406
+ const i = [], a = await st(t), c = await et(t, e, s);
407
+ Object.entries(c).forEach(([p, r]) => {
408
+ if (r.isKeyframes && r.css) {
409
+ const x = `css/${`a_${r.animationName}.css`}`, D = f(s, x);
410
+ E(D, r.css);
411
+ return;
412
+ }
413
+ if (!r.generator) return;
414
+ const o = r.generator._withBuildContext({
415
+ name: p,
416
+ config: a
417
+ }), g = `css/${o.cssFileName}`, u = f(s, g);
418
+ E(u, o.css), i[o.priority] || (i[o.priority] = []), i[o.priority].push(o.cssFileName);
419
+ }), a.importStrategy !== "component" && i.forEach((p, r) => {
420
+ const o = `l_${r}.css`, g = f(s, "css", o);
421
+ let u = M(g, "utf8");
422
+ p.forEach((d) => {
423
+ var b;
424
+ const x = f(s, "css", d), D = ((b = /.*-([^-]+)-\d+.css/.exec(d)) == null ? void 0 : b.at(1)) || L(x, 6);
425
+ if (!u.includes(D)) {
426
+ const j = M(x, "utf8"), N = `/*start:${D}*/
427
+ ${j}
428
+ /*end:${D}*/
429
+ `;
430
+ u = `${u.replace(/\}$/, "")}
431
+ ${N}
432
+ }`;
433
+ }
434
+ }), E(g, u);
435
+ });
436
+ }
437
+ } catch (s) {
438
+ console.error(s);
439
+ }
440
+ }, Ht = async (t, e, s = ht()) => {
441
+ try {
442
+ const n = await R(t);
443
+ if (v(e)) {
444
+ const a = M(e, "utf8");
445
+ a.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== a && await wt(e, a);
446
+ const p = await st(t), r = await et(t, e, n);
447
+ let o = a;
448
+ if (Object.entries(r).forEach(([g, u]) => {
449
+ var C;
450
+ if (u.isKeyframes || !u.generator) return;
451
+ const d = u.generator._withBuildContext({
452
+ name: g,
453
+ config: p,
454
+ prod: s
455
+ }), x = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
456
+ if (!x) return console.error("Could not find the original declaration");
457
+ const D = (C = x.at(1)) == null ? void 0 : C.trim(), T = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(o);
458
+ if (!T) return console.error("Could not find the original declaration");
459
+ const { index: b } = T;
460
+ let j = !1;
461
+ const N = setTimeout(() => j = !0, 5e3);
462
+ let y = 0, O = !1, l = 0;
463
+ for (; !O && !j; ) {
464
+ const h = o[b + y];
465
+ h === "(" && l++, h === ")" && l--, l === 0 && h === ")" && (O = !0), y > o.length && (j = !0), y++;
466
+ }
467
+ if (!j) clearTimeout(N);
468
+ else throw new Error("Failed to find the end of the styled call and timed out");
469
+ const S = b + y, $ = o.slice(b, S), w = o, m = ` ${g} = styled(${D}, "${d.classNames}", ${JSON.stringify(d.props)});`;
470
+ o = o.replace($, m), w === o && console.error("Minimize file failed to change content", { name: g, tagName: D });
471
+ }), p.importStrategy === "component") {
472
+ const g = L(e, 6), u = X(e);
473
+ o = `import '../../saltygen/css/${`f_${A(u.name)}-${g}.css`}';
474
+ ${o}`;
475
+ }
476
+ return o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
477
+ }
478
+ } catch (n) {
479
+ console.error("Error in minimizeFile:", n);
480
+ }
481
+ };
482
+ export {
483
+ Zt as a,
484
+ zt as g,
485
+ v as i,
486
+ Ht as m,
487
+ Tt as s
488
+ };
package/index.cjs CHANGED
@@ -1,15 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("path"),I=require("esbuild"),W=require("child_process"),m=require("fs");require("fs/promises");function H(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const x=H(I),E=t=>String.fromCharCode(t+(t>25?39:97)),z=(t,s)=>{let e="",n;for(n=Math.abs(t);n>52;n=n/52|0)e=E(n%52)+e;return e=E(n%52)+e,e.length<s?e=e.padStart(s,"a"):e.length>s&&(e=e.slice(-s)),e},B=(t,s)=>{let e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return t},A=(t,s=3)=>{const e=B(5381,JSON.stringify(t))>>>0;return z(e,s)};function V(t){return t?typeof t!="string"?V(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(s,e)=>(e>0?"-":"")+s.toLowerCase()):""}const G=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const e=[];return Object.values(s).forEach(n=>{const{pattern:r,transform:a}=n;t=t.replace(r,b=>{const{value:l,css:$}=a(b);return $&&e.push($),l})}),{result:t,additionalCss:e}},M=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V(n[1].replaceAll(".","-"))})`)}:{result:t},k=(t,s,e,n)=>{if(!t)return"";const r=[],a=Object.entries(t).reduce((l,[$,o])=>{const y=$.trim();if(typeof o=="function"&&(o=o()),typeof o=="object"){if(!o)return l;if(y==="variants")return Object.entries(o).forEach(([f,i])=>{i&&Object.entries(i).forEach(([p,c])=>{if(!c)return;const h=`${s}.${f}-${p}`,S=k(c,h);r.push(S)})}),l;if(y==="defaultVariants")return l;if(y==="compoundVariants")return o.forEach(f=>{const{css:i,...p}=f,c=Object.entries(p).reduce((S,[P,T])=>`${S}.${P}-${T}`,s),h=k(i,c);r.push(h)}),l;if(y.startsWith("@")){const f=k(o,s),i=`${y} {
2
- ${f.replace(`
3
- `,`
4
- `)}
5
- }`;return r.push(i),l}const j=$.includes("&")?y.replace("&",s):y.startsWith(":")?`${s}${y}`:`${s} ${y}`,d=k(o,j);return r.push(d),l}const g=y.startsWith("-")?y:V(y),w=(j,d=";")=>l=`${l}${j}${d}`,O=j=>w(`${g}:${j}`);if(typeof o=="number")return O(o);if(typeof o!="string")if("toString"in o)o=o.toString();else return l;const{modifiers:C}={},D=function*(){yield M(o),yield G(o,C)}();for(const{result:j,additionalCss:d=[]}of D)o=j,d.forEach(f=>{const i=k(f,"");w(i,"")});return O(o)},"");if(!a)return r.join(`
6
- `);if(!s)return a;let b="";return b=`${s} { ${a} }`,[b,...r].join(`
7
- `)},_=(t,s=[])=>{if(!t)return"";const e=[],n={};if(Object.entries(t).forEach(([r,a])=>{if(typeof a=="object"){if(!a)return;const b=r.trim(),l=_(a,[...s,b]);e.push(l)}else n[r]=a}),Object.keys(n).length){const r=s.map(V).join("-"),a=k(n,`.${r}`);e.push(a)}return e.join(`
8
- `)},N=t=>u.join(t,"./saltygen"),J=["salty","css","styles","styled"],q=(t=[])=>new RegExp(`\\.(${[...J,...t].join("|")})\\.`),K=(t,s=[])=>q(s).test(t),L=async t=>{const s=N(t),e=u.join(t,"salty.config.ts"),n=u.join(s,"salty.config.js");await x.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:"esm",external:["react"]});const r=Date.now(),{config:a}=await import(`${n}?t=${r}`);return a},U=async t=>{const s=await L(t),e=new Set,n=(f,i=[])=>f?Object.entries(f).flatMap(([p,c])=>{if(!c)return;if(typeof c=="object")return n(c,[...i,p]);const h=[...i,p].join(".");e.add(`"${h}"`);const S=[...i.map(V),V(p)].join("-"),{result:P}=M(c);return`--${S}: ${P};`}):[],r=f=>f?Object.entries(f).flatMap(([i,p])=>{const c=n(p);return i==="base"?c.join(""):`${i} { ${c.join("")} }`}):[],a=f=>f?Object.entries(f).flatMap(([i,p])=>Object.entries(p).flatMap(([c,h])=>{const S=n(h,[i]),P=`.${i}-${c}, [data-${i}="${c}"]`,T=S.join("");return`${P} { ${T} }`})):[],b=n(s.variables),l=r(s.responsiveVariables),$=a(s.conditionalVariables),o=N(t),y=u.join(o,"css/variables.css"),g=`:root { ${b.join("")} ${l.join("")} } ${$.join("")}`;m.writeFileSync(y,g);const w=u.join(o,"types/css-tokens.d.ts"),C=`type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;m.writeFileSync(w,C);const F=u.join(o,"css/global.css"),D=k(s.global,"");m.writeFileSync(F,D);const j=u.join(o,"css/templates.css"),d=_(s.templates);m.writeFileSync(j,d)},X=async(t,s)=>{const e=A(t),n=u.join(s,"js",e+".js");await x.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const r=Date.now();return await import(`${n}?t=${r}`)},Y=async t=>{const s=N(t),e=u.join(s,"salty.config.js"),{config:n}=await import(e);return n},Q=async t=>{try{const s=[],e=[],n=N(t),r=u.join(n,"index.css");(()=>{m.existsSync(n)&&W.execSync("rm -rf "+n),m.mkdirSync(n),m.mkdirSync(u.join(n,"css")),m.mkdirSync(u.join(n,"types"))})(),await U(t);const b=await Y(t);async function l(g,w){const O=m.statSync(g);if(O.isDirectory()){const C=m.readdirSync(g);await Promise.all(C.map(F=>l(u.join(g,F),u.join(w,F))))}else if(O.isFile()&&K(g)){const F=await X(g,n),D=[];Object.entries(F).forEach(([i,p])=>{if(p.isKeyframes&&p.css){const T=`${p.animationName}.css`,Z=`css/${T}`,R=u.join(n,Z);s.push(T),m.writeFileSync(R,p.css);return}if(!p.generator)return;const c=p.generator._withBuildContext({name:i,config:b}),h=`${c.hash}-${c.priority}.css`;e[c.priority]||(e[c.priority]=[]),e[c.priority].push(h),D.push(h);const S=`css/${h}`,P=u.join(n,S);m.writeFileSync(P,c.css)});const j=D.map(i=>`@import url('./${i}');`).join(`
9
- `),d=A(g,6),f=u.join(n,`css/${d}.css`);m.writeFileSync(f,j)}}await l(t,n);const $=s.map(g=>`@import url('./css/${g}');`).join(`
10
- `);let y=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
11
-
12
- ${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
13
- `)}
14
- ${$}`;if(b.importStrategy!=="component"){const g=e.flat().map(w=>`@import url('./css/${w}');`).join(`
15
- `);y+=g}m.writeFileSync(r,y)}catch(s){console.error(s)}},v=(t,s)=>{var e,n,r;(n=(e=t.module)==null?void 0:e.rules)==null||n.push({test:q(),use:[{loader:u.resolve("./loader.js"),options:{dir:s}}]}),(r=t.plugins)==null||r.push({apply:a=>{a.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await Q(s)})}})};exports.saltyPlugin=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-CgxcvuUt.cjs"),y=require("fs/promises"),g=require("fs"),p=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!t.isSaltyFile(e))return!1;const a=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(a)},c=(e,s,l=!1,a=!1)=>{var n,u,i;(u=(n=e.module)==null?void 0:n.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(i=e.plugins)==null||i.push({apply:f=>{let o=!1;f.hooks.watchRun.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,r)=>{await p(r)?await t.generateCss(s,!1,!1):t.isSaltyFile(r)&&await t.generateFile(s,r)}))})}})};exports.default=c;exports.saltyPlugin=c;
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { Configuration } from 'webpack';
2
- export declare const saltyPlugin: (config: Configuration, dir: string) => void;
2
+ export declare const saltyPlugin: (config: Configuration, dir: string, isServer?: boolean, cjs?: boolean) => void;
3
+ export default saltyPlugin;
package/index.js CHANGED
@@ -1,225 +1,35 @@
1
- import { join as m, resolve as H } from "path";
2
- import * as A from "esbuild";
3
- import { execSync as q } from "child_process";
4
- import { existsSync as B, mkdirSync as x, statSync as G, readdirSync as J, writeFileSync as w } from "fs";
5
- import "fs/promises";
6
- const E = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), K = (t, s) => {
7
- let e = "", n;
8
- for (n = Math.abs(t); n > 52; n = n / 52 | 0) e = E(n % 52) + e;
9
- return e = E(n % 52) + e, e.length < s ? e = e.padStart(s, "a") : e.length > s && (e = e.slice(-s)), e;
10
- }, L = (t, s) => {
11
- let e = s.length;
12
- for (; e; ) t = t * 33 ^ s.charCodeAt(--e);
13
- return t;
14
- }, M = (t, s = 3) => {
15
- const e = L(5381, JSON.stringify(t)) >>> 0;
16
- return K(e, s);
17
- };
18
- function T(t) {
19
- return t ? typeof t != "string" ? T(String(t)) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, e) => (e > 0 ? "-" : "") + s.toLowerCase()) : "";
20
- }
21
- const z = (t, s) => {
22
- if (typeof t != "string") return { result: t };
23
- if (!s) return { result: t };
24
- const e = [];
25
- return Object.values(s).forEach((n) => {
26
- const { pattern: r, transform: a } = n;
27
- t = t.replace(r, (g) => {
28
- const { value: l, css: b } = a(g);
29
- return b && e.push(b), l;
30
- });
31
- }), { result: t, additionalCss: e };
32
- }, Z = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${T(n[1].replaceAll(".", "-"))})`) } : { result: t }, k = (t, s, e, n) => {
33
- if (!t) return "";
34
- const r = [], a = Object.entries(t).reduce((l, [b, o]) => {
35
- const u = b.trim();
36
- if (typeof o == "function" && (o = o()), typeof o == "object") {
37
- if (!o) return l;
38
- if (u === "variants")
39
- return Object.entries(o).forEach(([f, i]) => {
40
- i && Object.entries(i).forEach(([p, c]) => {
41
- if (!c) return;
42
- const h = `${s}.${f}-${p}`, j = k(c, h);
43
- r.push(j);
44
- });
45
- }), l;
46
- if (u === "defaultVariants")
47
- return l;
48
- if (u === "compoundVariants")
49
- return o.forEach((f) => {
50
- const { css: i, ...p } = f, c = Object.entries(p).reduce((j, [C, O]) => `${j}.${C}-${O}`, s), h = k(i, c);
51
- r.push(h);
52
- }), l;
53
- if (u.startsWith("@")) {
54
- const f = k(o, s), i = `${u} {
55
- ${f.replace(`
56
- `, `
57
- `)}
58
- }`;
59
- return r.push(i), l;
60
- }
61
- const $ = b.includes("&") ? u.replace("&", s) : u.startsWith(":") ? `${s}${u}` : `${s} ${u}`, d = k(o, $);
62
- return r.push(d), l;
63
- }
64
- const y = u.startsWith("-") ? u : T(u), S = ($, d = ";") => l = `${l}${$}${d}`, D = ($) => S(`${y}:${$}`);
65
- if (typeof o == "number") return D(o);
66
- if (typeof o != "string")
67
- if ("toString" in o) o = o.toString();
68
- else return l;
69
- const { modifiers: F } = {}, V = function* () {
70
- yield Z(o), yield z(o, F);
71
- }();
72
- for (const { result: $, additionalCss: d = [] } of V)
73
- o = $, d.forEach((f) => {
74
- const i = k(f, "");
75
- S(i, "");
76
- });
77
- return D(o);
78
- }, "");
79
- if (!a) return r.join(`
80
- `);
81
- if (!s) return a;
82
- let g = "";
83
- return g = `${s} { ${a} }`, [g, ...r].join(`
84
- `);
85
- }, R = (t, s = []) => {
86
- if (!t) return "";
87
- const e = [], n = {};
88
- if (Object.entries(t).forEach(([r, a]) => {
89
- if (typeof a == "object") {
90
- if (!a) return;
91
- const g = r.trim(), l = R(a, [...s, g]);
92
- e.push(l);
93
- } else
94
- n[r] = a;
95
- }), Object.keys(n).length) {
96
- const r = s.map(T).join("-"), a = k(n, `.${r}`);
97
- e.push(a);
98
- }
99
- return e.join(`
100
- `);
101
- }, N = (t) => m(t, "./saltygen"), U = ["salty", "css", "styles", "styled"], I = (t = []) => new RegExp(`\\.(${[...U, ...t].join("|")})\\.`), X = (t, s = []) => I(s).test(t), Y = async (t) => {
102
- const s = N(t), e = m(t, "salty.config.ts"), n = m(s, "salty.config.js");
103
- await A.build({
104
- entryPoints: [e],
105
- minify: !0,
106
- treeShaking: !0,
107
- bundle: !0,
108
- outfile: n,
109
- format: "esm",
110
- external: ["react"]
111
- });
112
- const r = Date.now(), { config: a } = await import(`${n}?t=${r}`);
113
- return a;
114
- }, Q = async (t) => {
115
- const s = await Y(t), e = /* @__PURE__ */ new Set(), n = (f, i = []) => f ? Object.entries(f).flatMap(([p, c]) => {
116
- if (!c) return;
117
- if (typeof c == "object") return n(c, [...i, p]);
118
- const h = [...i, p].join(".");
119
- e.add(`"${h}"`);
120
- const j = [...i.map(T), T(p)].join("-"), { result: C } = Z(c);
121
- return `--${j}: ${C};`;
122
- }) : [], r = (f) => f ? Object.entries(f).flatMap(([i, p]) => {
123
- const c = n(p);
124
- return i === "base" ? c.join("") : `${i} { ${c.join("")} }`;
125
- }) : [], a = (f) => f ? Object.entries(f).flatMap(([i, p]) => Object.entries(p).flatMap(([c, h]) => {
126
- const j = n(h, [i]), C = `.${i}-${c}, [data-${i}="${c}"]`, O = j.join("");
127
- return `${C} { ${O} }`;
128
- })) : [], g = n(s.variables), l = r(s.responsiveVariables), b = a(s.conditionalVariables), o = N(t), u = m(o, "css/variables.css"), y = `:root { ${g.join("")} ${l.join("")} } ${b.join("")}`;
129
- w(u, y);
130
- const S = m(o, "types/css-tokens.d.ts"), F = `type VariableTokens = ${[...e].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
131
- w(S, F);
132
- const P = m(o, "css/global.css"), V = k(s.global, "");
133
- w(P, V);
134
- const $ = m(o, "css/templates.css"), d = R(s.templates);
135
- w($, d);
136
- }, v = async (t, s) => {
137
- const e = M(t), n = m(s, "js", e + ".js");
138
- await A.build({
139
- entryPoints: [t],
140
- minify: !0,
141
- treeShaking: !0,
142
- bundle: !0,
143
- outfile: n,
144
- format: "esm",
145
- target: ["es2022"],
146
- keepNames: !0,
147
- external: ["react"]
148
- });
149
- const r = Date.now();
150
- return await import(`${n}?t=${r}`);
151
- }, tt = async (t) => {
152
- const s = N(t), e = m(s, "salty.config.js"), { config: n } = await import(e);
153
- return n;
154
- }, st = async (t) => {
155
- try {
156
- const s = [], e = [], n = N(t), r = m(n, "index.css");
157
- (() => {
158
- B(n) && q("rm -rf " + n), x(n), x(m(n, "css")), x(m(n, "types"));
159
- })(), await Q(t);
160
- const g = await tt(t);
161
- async function l(y, S) {
162
- const D = G(y);
163
- if (D.isDirectory()) {
164
- const F = J(y);
165
- await Promise.all(F.map((P) => l(m(y, P), m(S, P))));
166
- } else if (D.isFile() && X(y)) {
167
- const P = await v(y, n), V = [];
168
- Object.entries(P).forEach(([i, p]) => {
169
- if (p.isKeyframes && p.css) {
170
- const O = `${p.animationName}.css`, W = `css/${O}`, _ = m(n, W);
171
- s.push(O), w(_, p.css);
172
- return;
173
- }
174
- if (!p.generator) return;
175
- const c = p.generator._withBuildContext({
176
- name: i,
177
- config: g
178
- }), h = `${c.hash}-${c.priority}.css`;
179
- e[c.priority] || (e[c.priority] = []), e[c.priority].push(h), V.push(h);
180
- const j = `css/${h}`, C = m(n, j);
181
- w(C, c.css);
182
- });
183
- const $ = V.map((i) => `@import url('./${i}');`).join(`
184
- `), d = M(y, 6), f = m(n, `css/${d}.css`);
185
- w(f, $);
186
- }
187
- }
188
- await l(t, n);
189
- const b = s.map((y) => `@import url('./css/${y}');`).join(`
190
- `);
191
- let u = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
192
-
193
- ${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@import url('./css/templates.css');"].join(`
194
- `)}
195
- ${b}`;
196
- if (g.importStrategy !== "component") {
197
- const y = e.flat().map((S) => `@import url('./css/${S}');`).join(`
198
- `);
199
- u += y;
200
- }
201
- w(r, u);
202
- } catch (s) {
203
- console.error(s);
204
- }
205
- }, it = (t, s) => {
206
- var e, n, r;
207
- (n = (e = t.module) == null ? void 0 : e.rules) == null || n.push({
208
- test: I(),
1
+ import { resolve as d } from "path";
2
+ import { i as f, s as p, g as u, a as y } from "./index-mrgKn_a7.js";
3
+ import { readFile as g } from "fs/promises";
4
+ import { watch as m } from "fs";
5
+ const w = async (s) => {
6
+ if (!s || s.includes("node_modules") || s.includes("saltygen")) return !1;
7
+ if (s.includes("salty.config")) return !0;
8
+ if (!f(s)) return !1;
9
+ const t = await g(s, "utf-8");
10
+ return !!/.+define[A-Z]\w+/.test(t);
11
+ }, j = (s, e, r = !1, t = !1) => {
12
+ var l, o, n;
13
+ (o = (l = s.module) == null ? void 0 : l.rules) == null || o.push({
14
+ test: p(),
209
15
  use: [
210
16
  {
211
- loader: H("./loader.js"),
212
- options: { dir: s }
17
+ loader: d(__dirname, t ? "./loader.cjs" : "./loader.js"),
18
+ options: { dir: e }
213
19
  }
214
20
  ]
215
- }), (r = t.plugins) == null || r.push({
216
- apply: (a) => {
217
- a.hooks.afterPlugins.tap({ name: "generateCss" }, async () => {
218
- await st(s);
21
+ }), r || (n = s.plugins) == null || n.push({
22
+ apply: (c) => {
23
+ let i = !1;
24
+ c.hooks.watchRun.tapPromise({ name: "generateCss" }, async () => {
25
+ i || (i = !0, await u(e), m(e, { recursive: !0 }, async (h, a) => {
26
+ await w(a) ? await u(e, !1, !1) : f(a) && await y(e, a);
27
+ }));
219
28
  });
220
29
  }
221
30
  });
222
31
  };
223
32
  export {
224
- it as saltyPlugin
33
+ j as default,
34
+ j as saltyPlugin
225
35
  };
package/loader.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";const i=require("./index-CgxcvuUt.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
package/loader.js ADDED
@@ -0,0 +1,8 @@
1
+ import { a as e, m as i } from "./index-mrgKn_a7.js";
2
+ async function s() {
3
+ const { dir: t } = this.getOptions(), { resourcePath: a } = this;
4
+ return await e(t, a), await i(t, a);
5
+ }
6
+ export {
7
+ s as default
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/webpack",
3
- "version": "0.0.1-alpha.18",
3
+ "version": "0.0.1-alpha.181",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -10,7 +10,12 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "homepage": "https://github.com/margarita-form/salty-css",
13
+ "description": "Webpack plugin for Salty CSS",
14
+ "homepage": "https://salty-css.dev/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/margarita-form/salty-css.git"
18
+ },
14
19
  "bugs": {
15
20
  "url": "https://github.com/margarita-form/salty-css/issues"
16
21
  },
@@ -28,8 +33,8 @@
28
33
  "require": "./index.cjs"
29
34
  }
30
35
  },
31
- "peerDependencies": {
32
- "@salty-css/core": "^0.0.1-alpha.15",
36
+ "dependencies": {
37
+ "@salty-css/core": "^0.0.1-alpha.181",
33
38
  "webpack": ">=5.x"
34
39
  }
35
40
  }