@salty-css/core 0.0.1-alpha.187 → 0.0.1-alpha.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/config/index.cjs +1 -1
- package/config/index.js +7 -10
- package/css/index.cjs +1 -1
- package/css/index.js +29 -136
- package/css/keyframes.cjs +1 -0
- package/css/keyframes.js +34 -0
- package/css/media.cjs +1 -0
- package/css/media.js +88 -0
- package/css/merge.cjs +1 -0
- package/{merge-BVm9us1A.js → css/merge.js} +1 -1
- package/css/token.cjs +1 -0
- package/css/token.js +4 -0
- package/factories/define-variables.d.ts +9 -12
- package/factories/index.cjs +1 -1
- package/factories/index.js +11 -14
- package/index-D9fpGzLy.cjs +30 -0
- package/index-_9I4QIPW.js +433 -0
- package/package.json +17 -1
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/types/config-types.d.ts +12 -13
- package/index-BmsXxgnE.cjs +0 -30
- package/index-DKkgPK-r.js +0 -433
- package/merge-DxGoJDHv.cjs +0 -1
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-D9fpGzLy.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,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.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"))},P=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 f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{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,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=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,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];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(f,".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
|
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 re, format as ee } from "path";
|
5
5
|
import { render as ce } from "ejs";
|
6
|
-
import { l as t, a as h, g as te } from "../index-
|
6
|
+
import { l as t, a as h, g as te } from "../index-_9I4QIPW.js";
|
7
7
|
import { p as le } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as de } from "child_process";
|
9
9
|
import fe from "ora";
|
package/compiler/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-3zK35muR.cjs");require("../parse-templates-VIvmVb52.cjs");const e=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-3zK35muR.cjs");require("../parse-templates-VIvmVb52.cjs");const e=require("../index-D9fpGzLy.cjs");require("../css/merge.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
@@ -6,8 +6,8 @@ import "fs";
|
|
6
6
|
import "fs/promises";
|
7
7
|
import "../parse-styles-DrLhKtqW.js";
|
8
8
|
import "../parse-templates-DRKlN-pP.js";
|
9
|
-
import { d as g, c as F, g as y, e as x, i as S, m as c, s as f, b as C } from "../index-
|
10
|
-
import "../merge
|
9
|
+
import { d as g, c as F, g as y, e as x, i as S, m as c, s as f, b as C } from "../index-_9I4QIPW.js";
|
10
|
+
import "../css/merge.js";
|
11
11
|
export {
|
12
12
|
g as compileSaltyFile,
|
13
13
|
F as generateConfigStyles,
|
package/config/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../factories/index.cjs"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../factories/index.cjs"),t=a=>a;exports.GlobalStylesFactory=e.GlobalStylesFactory;exports.TemplatesFactory=e.TemplatesFactory;exports.VariablesFactory=e.VariablesFactory;exports.defineGlobalStyles=e.defineGlobalStyles;exports.defineTemplates=e.defineTemplates;exports.defineVariables=e.defineVariables;exports.defineConfig=t;
|
package/config/index.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
import { GlobalStylesFactory as
|
1
|
+
import { GlobalStylesFactory as o, TemplatesFactory as r, VariablesFactory as i, defineGlobalStyles as n, defineTemplates as s, defineVariables as f } from "../factories/index.js";
|
2
2
|
const a = (e) => e;
|
3
3
|
export {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
r as defineConditionalVariables,
|
4
|
+
o as GlobalStylesFactory,
|
5
|
+
r as TemplatesFactory,
|
6
|
+
i as VariablesFactory,
|
8
7
|
a as defineConfig,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
b as defineTemplates,
|
13
|
-
c as defineVariables
|
8
|
+
n as defineGlobalStyles,
|
9
|
+
s as defineTemplates,
|
10
|
+
f as defineVariables
|
14
11
|
};
|
package/css/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var n=Object.defineProperty;var h=(a,s,e)=>s in a?n(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e;var r=(a,s,e)=>h(a,typeof s!="symbol"?s+"":s,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./keyframes.cjs"),i=require("./media.cjs"),l=require("./token.cjs"),u=require("./merge.cjs"),d=require("../parse-styles-3zK35muR.cjs"),c=require("../dash-case-BJEkFEGQ.cjs");class y{constructor(s){r(this,"_isProd");r(this,"_callerName");this.params=s}get hash(){return c.toHash(this.params.base||this.params)}get cssClassName(){return this.hash}get classNames(){const s=[this.hash],{className:e}=this.params;return e&&s.push(e),s.join(" ")}get cssFileName(){return this._callerName?`cl_${c.dashCase(this._callerName)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:e={},compoundVariants:t=[]}=this.params,o={...s,variants:e,compoundVariants:t};return d.parseStyles(o,`.${this.cssClassName}`)}_withBuildContext(s){const{name:e,prod:t}=s;return this._isProd=t,this._callerName=e,this}}exports.keyframes=m.keyframes;exports.MediaQueryFactory=i.MediaQueryFactory;exports.media=i.media;exports.token=l.token;exports.mergeStyles=u.mergeStyles;exports.ClassNameFactory=y;
|
package/css/index.js
CHANGED
@@ -1,152 +1,45 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
fillMode: N = "forwards",
|
16
|
-
playState: v = "running"
|
17
|
-
} = { ...t, ...o }, $ = `${n} ${a} ${c} ${m} ${l} ${f} ${N} ${v}`;
|
18
|
-
if (!s) return $;
|
19
|
-
const d = e.from || e["0%"];
|
20
|
-
if (!d) return $;
|
21
|
-
const y = p(d, "");
|
22
|
-
return `${$};${y}`;
|
23
|
-
}, b = Object.entries(e).reduce((o, [a, c]) => {
|
24
|
-
if (!c) return o;
|
25
|
-
const m = p(c, ""), l = typeof a == "number" ? `${a}%` : a;
|
26
|
-
return `${o}${l}{${m}}`;
|
27
|
-
}, ""), x = `@keyframes ${n} {${b}}`;
|
28
|
-
return Object.assign(i, {
|
29
|
-
toString: i,
|
30
|
-
isKeyframes: !0,
|
31
|
-
animationName: n,
|
32
|
-
css: x,
|
33
|
-
keyframes: e
|
34
|
-
}), i;
|
35
|
-
};
|
36
|
-
class u {
|
37
|
-
constructor(t = "@media") {
|
38
|
-
h(this, "next", (t) => {
|
39
|
-
const s = new String(t);
|
40
|
-
return Object.assign(s, {
|
41
|
-
get isMedia() {
|
42
|
-
return !0;
|
43
|
-
},
|
44
|
-
get and() {
|
45
|
-
return new u(`${t} and`);
|
46
|
-
},
|
47
|
-
get or() {
|
48
|
-
return new u(`${t},`);
|
49
|
-
}
|
50
|
-
}), s;
|
51
|
-
});
|
52
|
-
this.base = t;
|
53
|
-
}
|
54
|
-
custom(t) {
|
55
|
-
return this.next(`${this.base} ${t}`);
|
56
|
-
}
|
57
|
-
minWidth(t) {
|
58
|
-
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (min-width: ${s})`;
|
59
|
-
return this.next(e);
|
60
|
-
}
|
61
|
-
maxWidth(t) {
|
62
|
-
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (max-width: ${s})`;
|
63
|
-
return this.next(e);
|
64
|
-
}
|
65
|
-
minHeight(t) {
|
66
|
-
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (min-height: ${s})`;
|
67
|
-
return this.next(e);
|
68
|
-
}
|
69
|
-
maxHeight(t) {
|
70
|
-
const s = typeof t == "number" ? `${t}px` : t, e = `${this.base} (max-height: ${s})`;
|
71
|
-
return this.next(e);
|
72
|
-
}
|
73
|
-
get portrait() {
|
74
|
-
const t = `${this.base} (orientation: portrait)`;
|
75
|
-
return this.next(t);
|
76
|
-
}
|
77
|
-
get landscape() {
|
78
|
-
const t = `${this.base} (orientation: landscape)`;
|
79
|
-
return this.next(t);
|
80
|
-
}
|
81
|
-
prefersColorScheme(t) {
|
82
|
-
const s = `${this.base} (prefers-color-scheme: ${t})`;
|
83
|
-
return this.next(s);
|
84
|
-
}
|
85
|
-
get dark() {
|
86
|
-
return this.prefersColorScheme("dark");
|
87
|
-
}
|
88
|
-
get light() {
|
89
|
-
return this.prefersColorScheme("light");
|
90
|
-
}
|
91
|
-
get print() {
|
92
|
-
const t = `${this.base} print`;
|
93
|
-
return this.next(t);
|
94
|
-
}
|
95
|
-
get screen() {
|
96
|
-
const t = `${this.base} screen`;
|
97
|
-
return this.next(t);
|
98
|
-
}
|
99
|
-
get speech() {
|
100
|
-
const t = `${this.base} speech`;
|
101
|
-
return this.next(t);
|
102
|
-
}
|
103
|
-
get all() {
|
104
|
-
const t = `${this.base} all`;
|
105
|
-
return this.next(t);
|
106
|
-
}
|
107
|
-
get not() {
|
108
|
-
const t = `${this.base} not`;
|
109
|
-
return this.next(t);
|
110
|
-
}
|
111
|
-
get reducedMotion() {
|
112
|
-
const t = `${this.base} (prefers-reduced-motion: reduce)`;
|
113
|
-
return this.next(t);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
const k = new u(), z = (r) => `{${r}}`;
|
117
|
-
class F {
|
118
|
-
constructor(t) {
|
119
|
-
h(this, "_isProd");
|
120
|
-
h(this, "_callerName");
|
121
|
-
this.params = t;
|
1
|
+
var i = Object.defineProperty;
|
2
|
+
var h = (t, s, a) => s in t ? i(t, s, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[s] = a;
|
3
|
+
var r = (t, s, a) => h(t, typeof s != "symbol" ? s + "" : s, a);
|
4
|
+
import { keyframes as y } from "./keyframes.js";
|
5
|
+
import { MediaQueryFactory as x, media as C } from "./media.js";
|
6
|
+
import { token as b } from "./token.js";
|
7
|
+
import { mergeStyles as S } from "./merge.js";
|
8
|
+
import { p as c } from "../parse-styles-DrLhKtqW.js";
|
9
|
+
import { t as m, d as n } from "../dash-case-DBThphLm.js";
|
10
|
+
class N {
|
11
|
+
constructor(s) {
|
12
|
+
r(this, "_isProd");
|
13
|
+
r(this, "_callerName");
|
14
|
+
this.params = s;
|
122
15
|
}
|
123
16
|
get hash() {
|
124
|
-
return
|
17
|
+
return m(this.params.base || this.params);
|
125
18
|
}
|
126
19
|
get cssClassName() {
|
127
20
|
return this.hash;
|
128
21
|
}
|
129
22
|
get classNames() {
|
130
|
-
const
|
131
|
-
return
|
23
|
+
const s = [this.hash], { className: a } = this.params;
|
24
|
+
return a && s.push(a), s.join(" ");
|
132
25
|
}
|
133
26
|
get cssFileName() {
|
134
|
-
return this._callerName ? `cl_${
|
27
|
+
return this._callerName ? `cl_${n(this._callerName)}-${this.hash}.css` : `${this.hash}.css`;
|
135
28
|
}
|
136
29
|
get css() {
|
137
|
-
const { base:
|
138
|
-
return
|
30
|
+
const { base: s = {}, variants: a = {}, compoundVariants: e = [] } = this.params, o = { ...s, variants: a, compoundVariants: e };
|
31
|
+
return c(o, `.${this.cssClassName}`);
|
139
32
|
}
|
140
|
-
_withBuildContext(
|
141
|
-
const { name:
|
142
|
-
return this._isProd = e, this._callerName =
|
33
|
+
_withBuildContext(s) {
|
34
|
+
const { name: a, prod: e } = s;
|
35
|
+
return this._isProd = e, this._callerName = a, this;
|
143
36
|
}
|
144
37
|
}
|
145
38
|
export {
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
39
|
+
N as ClassNameFactory,
|
40
|
+
x as MediaQueryFactory,
|
41
|
+
y as keyframes,
|
42
|
+
C as media,
|
43
|
+
S as mergeStyles,
|
44
|
+
b as token
|
152
45
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("../parse-styles-3zK35muR.cjs"),j=require("../dash-case-BJEkFEGQ.cjs"),C=({animationName:m,params:l,appendInitialStyles:f,...t})=>{const r=m||j.toHash(t),o=(s={})=>{const{duration:e="500ms",easing:n="ease-in-out",delay:a="0s",iterationCount:i="1",direction:S="normal",fillMode:g="forwards",playState:p="running"}={...l,...s},c=`${r} ${e} ${n} ${a} ${i} ${S} ${g} ${p}`;if(!f)return c;const u=t.from||t["0%"];if(!u)return c;const b=$.parseStyles(u,"");return`${c};${b}`},y=Object.entries(t).reduce((s,[e,n])=>{if(!n)return s;const a=$.parseStyles(n,""),i=typeof e=="number"?`${e}%`:e;return`${s}${i}{${a}}`},""),d=`@keyframes ${r} {${y}}`;return Object.assign(o,{toString:o,isKeyframes:!0,animationName:r,css:d,keyframes:t}),o};exports.keyframes=C;
|
package/css/keyframes.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
import { p as c } from "../parse-styles-DrLhKtqW.js";
|
2
|
+
import { t as j } from "../dash-case-DBThphLm.js";
|
3
|
+
const O = ({ animationName: u, params: f, appendInitialStyles: p, ...t }) => {
|
4
|
+
const o = u || j(t), e = (r = {}) => {
|
5
|
+
const {
|
6
|
+
duration: n = "500ms",
|
7
|
+
easing: s = "ease-in-out",
|
8
|
+
delay: a = "0s",
|
9
|
+
iterationCount: i = "1",
|
10
|
+
direction: y = "normal",
|
11
|
+
fillMode: g = "forwards",
|
12
|
+
playState: S = "running"
|
13
|
+
} = { ...f, ...r }, m = `${o} ${n} ${s} ${a} ${i} ${y} ${g} ${S}`;
|
14
|
+
if (!p) return m;
|
15
|
+
const $ = t.from || t["0%"];
|
16
|
+
if (!$) return m;
|
17
|
+
const b = c($, "");
|
18
|
+
return `${m};${b}`;
|
19
|
+
}, l = Object.entries(t).reduce((r, [n, s]) => {
|
20
|
+
if (!s) return r;
|
21
|
+
const a = c(s, ""), i = typeof n == "number" ? `${n}%` : n;
|
22
|
+
return `${r}${i}{${a}}`;
|
23
|
+
}, ""), d = `@keyframes ${o} {${l}}`;
|
24
|
+
return Object.assign(e, {
|
25
|
+
toString: e,
|
26
|
+
isKeyframes: !0,
|
27
|
+
animationName: o,
|
28
|
+
css: d,
|
29
|
+
keyframes: t
|
30
|
+
}), e;
|
31
|
+
};
|
32
|
+
export {
|
33
|
+
O as keyframes
|
34
|
+
};
|
package/css/media.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var a=Object.defineProperty;var o=(s,e,t)=>e in s?a(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>o(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{constructor(e="@media"){i(this,"next",e=>{const t=new String(e);return Object.assign(t,{get isMedia(){return!0},get and(){return new r(`${e} and`)},get or(){return new r(`${e},`)}}),t});this.base=e}custom(e){return this.next(`${this.base} ${e}`)}minWidth(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (min-width: ${t})`;return this.next(n)}maxWidth(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (max-width: ${t})`;return this.next(n)}minHeight(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (min-height: ${t})`;return this.next(n)}maxHeight(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (max-height: ${t})`;return this.next(n)}get portrait(){const e=`${this.base} (orientation: portrait)`;return this.next(e)}get landscape(){const e=`${this.base} (orientation: landscape)`;return this.next(e)}prefersColorScheme(e){const t=`${this.base} (prefers-color-scheme: ${e})`;return this.next(t)}get dark(){return this.prefersColorScheme("dark")}get light(){return this.prefersColorScheme("light")}get print(){const e=`${this.base} print`;return this.next(e)}get screen(){const e=`${this.base} screen`;return this.next(e)}get speech(){const e=`${this.base} speech`;return this.next(e)}get all(){const e=`${this.base} all`;return this.next(e)}get not(){const e=`${this.base} not`;return this.next(e)}get reducedMotion(){const e=`${this.base} (prefers-reduced-motion: reduce)`;return this.next(e)}}const u=new r;exports.MediaQueryFactory=r;exports.media=u;
|
package/css/media.js
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
var a = Object.defineProperty;
|
2
|
+
var o = (s, t, e) => t in s ? a(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
3
|
+
var i = (s, t, e) => o(s, typeof t != "symbol" ? t + "" : t, e);
|
4
|
+
class r {
|
5
|
+
constructor(t = "@media") {
|
6
|
+
i(this, "next", (t) => {
|
7
|
+
const e = new String(t);
|
8
|
+
return Object.assign(e, {
|
9
|
+
get isMedia() {
|
10
|
+
return !0;
|
11
|
+
},
|
12
|
+
get and() {
|
13
|
+
return new r(`${t} and`);
|
14
|
+
},
|
15
|
+
get or() {
|
16
|
+
return new r(`${t},`);
|
17
|
+
}
|
18
|
+
}), e;
|
19
|
+
});
|
20
|
+
this.base = t;
|
21
|
+
}
|
22
|
+
custom(t) {
|
23
|
+
return this.next(`${this.base} ${t}`);
|
24
|
+
}
|
25
|
+
minWidth(t) {
|
26
|
+
const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (min-width: ${e})`;
|
27
|
+
return this.next(n);
|
28
|
+
}
|
29
|
+
maxWidth(t) {
|
30
|
+
const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (max-width: ${e})`;
|
31
|
+
return this.next(n);
|
32
|
+
}
|
33
|
+
minHeight(t) {
|
34
|
+
const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (min-height: ${e})`;
|
35
|
+
return this.next(n);
|
36
|
+
}
|
37
|
+
maxHeight(t) {
|
38
|
+
const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (max-height: ${e})`;
|
39
|
+
return this.next(n);
|
40
|
+
}
|
41
|
+
get portrait() {
|
42
|
+
const t = `${this.base} (orientation: portrait)`;
|
43
|
+
return this.next(t);
|
44
|
+
}
|
45
|
+
get landscape() {
|
46
|
+
const t = `${this.base} (orientation: landscape)`;
|
47
|
+
return this.next(t);
|
48
|
+
}
|
49
|
+
prefersColorScheme(t) {
|
50
|
+
const e = `${this.base} (prefers-color-scheme: ${t})`;
|
51
|
+
return this.next(e);
|
52
|
+
}
|
53
|
+
get dark() {
|
54
|
+
return this.prefersColorScheme("dark");
|
55
|
+
}
|
56
|
+
get light() {
|
57
|
+
return this.prefersColorScheme("light");
|
58
|
+
}
|
59
|
+
get print() {
|
60
|
+
const t = `${this.base} print`;
|
61
|
+
return this.next(t);
|
62
|
+
}
|
63
|
+
get screen() {
|
64
|
+
const t = `${this.base} screen`;
|
65
|
+
return this.next(t);
|
66
|
+
}
|
67
|
+
get speech() {
|
68
|
+
const t = `${this.base} speech`;
|
69
|
+
return this.next(t);
|
70
|
+
}
|
71
|
+
get all() {
|
72
|
+
const t = `${this.base} all`;
|
73
|
+
return this.next(t);
|
74
|
+
}
|
75
|
+
get not() {
|
76
|
+
const t = `${this.base} not`;
|
77
|
+
return this.next(t);
|
78
|
+
}
|
79
|
+
get reducedMotion() {
|
80
|
+
const t = `${this.base} (prefers-reduced-motion: reduce)`;
|
81
|
+
return this.next(t);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
const u = new r();
|
85
|
+
export {
|
86
|
+
r as MediaQueryFactory,
|
87
|
+
u as media
|
88
|
+
};
|
package/css/merge.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(...t)=>t.flat().reduce((e,r)=>r!=null&&r._current?{...e,...r._current}:{...e,...r},{});exports.mergeStyles=u;
|
package/css/token.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>`{${e}}`;exports.token=t;
|
package/css/token.js
ADDED
@@ -1,15 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
export interface VariablesFactoryParams {
|
3
|
-
variables?: CssVariables;
|
4
|
-
responsiveVariables?: CssResponsiveVariables;
|
5
|
-
conditionalVariables?: CssConditionalVariables;
|
6
|
-
}
|
1
|
+
import { SaltyVariables } from '../types/config-types';
|
7
2
|
export declare class VariablesFactory {
|
8
|
-
_current:
|
9
|
-
constructor(_current:
|
3
|
+
_current: SaltyVariables;
|
4
|
+
constructor(_current: SaltyVariables);
|
10
5
|
get isDefineVariables(): boolean;
|
11
6
|
}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
/**
|
8
|
+
* Base level variables that can be used in all styles as they are applied globally to :root.
|
9
|
+
@param responsive Variables that are defined for different media queries.
|
10
|
+
@param conditional Variables that are defined for different parent selectors (classes or data attributes).
|
11
|
+
*/
|
12
|
+
export declare const defineVariables: (variables: SaltyVariables) => VariablesFactory;
|
package/factories/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{constructor(t){this._current=t}get isGlobalDefine(){return!0}}const l=e=>new r(e);class s{constructor(t){this._current=t}get isDefineVariables(){return!0}}const n=e=>new s(e);class a{constructor(t){this._current=t}get isDefineTemplates(){return!0}}const o=e=>new a(e);exports.GlobalStylesFactory=r;exports.TemplatesFactory=a;exports.VariablesFactory=s;exports.defineGlobalStyles=l;exports.defineTemplates=o;exports.defineVariables=n;
|
package/factories/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class r {
|
2
2
|
constructor(t) {
|
3
3
|
this._current = t;
|
4
4
|
}
|
@@ -6,8 +6,8 @@ class n {
|
|
6
6
|
return !0;
|
7
7
|
}
|
8
8
|
}
|
9
|
-
const a = (e) => new
|
10
|
-
class
|
9
|
+
const a = (e) => new r(e);
|
10
|
+
class s {
|
11
11
|
constructor(t) {
|
12
12
|
this._current = t;
|
13
13
|
}
|
@@ -15,8 +15,8 @@ class r {
|
|
15
15
|
return !0;
|
16
16
|
}
|
17
17
|
}
|
18
|
-
const
|
19
|
-
class
|
18
|
+
const c = (e) => new s(e);
|
19
|
+
class n {
|
20
20
|
constructor(t) {
|
21
21
|
this._current = t;
|
22
22
|
}
|
@@ -24,15 +24,12 @@ class s {
|
|
24
24
|
return !0;
|
25
25
|
}
|
26
26
|
}
|
27
|
-
const
|
27
|
+
const l = (e) => new n(e);
|
28
28
|
export {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
l as defineConditionalVariables,
|
29
|
+
r as GlobalStylesFactory,
|
30
|
+
n as TemplatesFactory,
|
31
|
+
s as VariablesFactory,
|
33
32
|
a as defineGlobalStyles,
|
34
|
-
|
35
|
-
c as
|
36
|
-
u as defineTemplates,
|
37
|
-
i as defineVariables
|
33
|
+
l as defineTemplates,
|
34
|
+
c as defineVariables
|
38
35
|
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";const ge=require("esbuild"),he=require("child_process"),P=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),i=require("fs"),ee=require("fs/promises"),X=require("./parse-styles-3zK35muR.cjs"),oe=require("./parse-templates-VIvmVb52.cjs"),q=require("winston"),v=require("./css/merge.cjs");var Y=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 c=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,c.get?c:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const re=Se(ge),ce=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return i.existsSync(t)?t:ce(o.join(e,".."))},we=async e=>{const t=ce(e);return await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Fe=async e=>{const t=await we(e);if(t)return t.type};let V;const ae=async e=>{if(V)return V;const t=await Fe(e);return t==="module"?V="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:Y&&Y.tagName.toUpperCase()==="SCRIPT"&&Y.src||new URL("index-D9fpGzLy.cjs",document.baseURI).href).endsWith(".cjs"))&&(V="cjs"),V||"esm"},I=q.createLogger({level:"debug",format:q.format.combine(q.format.colorize(),q.format.cli()),transports:[new q.transports.Console({})]}),je=e=>{I.error(e)};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 be={"*, *::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"}},T={externalModules:[],rcFile:void 0,destDir:void 0},fe=e=>{if(T.externalModules.length>0)return T.externalModules;const s=i.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const c=s[1].split(",").map(f=>f.replace(/['"`]/g,"").trim());return T.externalModules=c,c},O=async e=>{if(T.destDir)return T.destDir;const t=await se(e),s=o.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return T.destDir=s,s},te=["salty","css","styles","styled"],de=(e=[])=>new RegExp(`\\.(${[...te,...e].join("|")})\\.`),L=(e,t=[])=>de(t).test(e),pe=async e=>{if(T.rcFile)return T.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=o.join(e,".saltyrc.json"),s=await ee.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(T.rcFile=s,s):pe(o.join(e,".."))},se=async e=>{var c,f;const t=await pe(e),s=(c=t.projects)==null?void 0:c.find(a=>e.endsWith(a.dir||""));return s||((f=t.projects)==null?void 0:f.find(a=>a.dir===t.defaultProject))},$e=async e=>{const t=await se(e),s=await O(e),c=o.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),f=o.join(s,"salty.config.js"),a=await ae(e),l=fe(c);await re.build({entryPoints:[c],minify:!0,treeShaking:!0,bundle:!0,outfile:f,format:a,external:l});const h=Date.now(),{config:u}=await import(`${f}?t=${h}`);return u},ue=async(e,t)=>{var H,G;const s=await $e(e),c={...s},f=new Set,a=(b,$=[])=>b?Object.entries(b).flatMap(([M,_])=>{if(!_)return;if(typeof _=="object")return a(_,[...$,M]);const Z=le(M),A=P.dashCase(M),U=[...$,Z].join(".");f.add(`"${U}"`);const Q=[...$.map(P.dashCase),A].join("-"),{result:me}=X.parseValueTokens(_);return`--${Q}: ${me};`}):[],l=b=>b?Object.entries(b).flatMap(([$,M])=>{const _=a(M);return $==="base"?_.join(""):`${$} { ${_.join("")} }`}):[],h=b=>b?Object.entries(b).flatMap(([$,M])=>Object.entries(M).flatMap(([_,Z])=>{const A=a(Z,[$]),U=`.${$}-${_}, [data-${$}="${_}"]`,Q=A.join("");return`${U} { ${Q} }`})):[],u=b=>({...b,responsive:void 0,conditional:void 0}),n=b=>t.variables.map($=>b==="static"?u($._current):$._current[b]),g=a(v.mergeStyles(u(s.variables),n("static"))),m=l(v.mergeStyles((H=s.variables)==null?void 0:H.responsive,n("responsive"))),y=h(v.mergeStyles((G=s.variables)==null?void 0:G.conditional,n("conditional"))),F=await O(e),x=o.join(F,"css/_variables.css"),E=`:root { ${g.join("")} ${m.join("")} } ${y.join("")}`;i.writeFileSync(x,E);const D=o.join(F,"css/_global.css"),N=v.mergeStyles(s.global,t.globalStyles),R=X.parseStyles(N,"");i.writeFileSync(D,`@layer global { ${R} }`);const k=o.join(F,"css/_reset.css"),r=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:be,C=X.parseStyles(r,"");i.writeFileSync(k,`@layer reset { ${C} }`);const j=o.join(F,"css/_templates.css"),S=v.mergeStyles(s.templates,t.templates),p=oe.parseTemplates(S),w=oe.getTemplateTypes(S);i.writeFileSync(j,p),c.templates=S;const d=o.join(F,"types/css-tokens.d.ts"),z=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...f].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(w).map(([b,$])=>`${b}?: ${$}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;i.writeFileSync(d,z);const B=o.join(F,"cache/config-cache.json");i.writeFileSync(B,JSON.stringify(c,null,2))},ie=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const f=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!f.test(e))return t;const l=f.exec(e);if(l){const h=l.at(1);if(te.some(n=>h==null?void 0:h.includes(n)))return t}return"styled('div',"}),K=async(e,t,s)=>{const c=P.toHash(t),f=o.join(s,"./temp");i.existsSync(f)||i.mkdirSync(f);const a=o.parse(t);let l=i.readFileSync(t,"utf8");l=ie(l);const h=o.join(s,"js",c+".js"),u=await se(e),n=o.join(e,(u==null?void 0:u.configDir)||"","salty.config.ts"),g=fe(n),m=await ae(e);await re.build({stdin:{contents:l,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:m,target:["node20"],keepNames:!0,external:g,packages:"external",plugins:[{name:"test",setup:x=>{x.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},E=>{const D=i.readFileSync(E.path,"utf8");return{contents:ie(D),loader:"ts"}})}}]});const y=Date.now();return await import(`${h}?t=${y}`)},Ce=async e=>{const t=await O(e),s=o.join(t,"cache/config-cache.json"),c=i.readFileSync(s,"utf8");if(!c)throw new Error("Could not find config cache file");return JSON.parse(c)},ne=async e=>{const t=await Ce(e),s=await O(e),c=o.join(s,"salty.config.js"),f=Date.now(),{config:a}=await import(`${c}?t=${f}`);return v.mergeStyles(a,t)},ye=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=ye(),s=!0)=>{try{const c=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const f=[],a=[],l=await O(e),h=o.join(l,"index.css");s&&(()=>{i.existsSync(l)&&he.execSync("rm -rf "+l),i.mkdirSync(l,{recursive:!0}),i.mkdirSync(o.join(l,"css")),i.mkdirSync(o.join(l,"types")),i.mkdirSync(o.join(l,"js")),i.mkdirSync(o.join(l,"cache"))})();const n={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],templates:[],components:[],classNames:[]};async function g(r){const C=["node_modules","saltygen"],j=i.statSync(r);if(j.isDirectory()){const S=i.readdirSync(r);if(C.some(w=>r.includes(w)))return;await Promise.all(S.map(w=>g(o.join(r,w))))}else if(j.isFile()&&L(r)){const p=await K(e,r,l);Object.entries(p).forEach(([w,d])=>{d.isKeyframes?n.keyframes.push({value:d,src:r,name:w}):d.isMedia?n.mediaQueries.push(d):d.isGlobalDefine?n.globalStyles.push(d):d.isDefineVariables?n.variables.push(d):d.isDefineTemplates?n.templates.push(d):d.isClassName?n.classNames.push({value:d.factory,src:r,name:w}):d.generator&&n.components.push({value:d.generator,src:r,name:w})})}}await g(e),await ue(e,n);const m=await ne(e);for(const r of n.keyframes){const{value:C}=r,j=`a_${C.animationName}.css`,S=`css/${j}`,p=o.join(l,S);f.push(j),i.writeFileSync(p,C.css)}const y={};for(const r of n.components){const{value:C,name:j,src:S}=r,p=C._withBuildContext({name:j,config:m,prod:t});a[p.priority]||(a[p.priority]=[]),a[p.priority].push(p.cssFileName);const w=`css/${p.cssFileName}`,d=o.join(l,w);i.writeFileSync(d,p.css),m.importStrategy==="component"&&(y[S]?y[S].push(p.cssFileName):y[S]=[p.cssFileName])}for(const r of n.classNames){const{value:C,src:j,name:S}=r,p=C._withBuildContext({name:S,prod:t});a[0].push(p.cssFileName);const w=`css/${p.cssFileName}`,d=o.join(l,w);i.writeFileSync(d,p.css),m.importStrategy==="component"&&(y[j]?y[j].push(p.cssFileName):y[j]=[p.cssFileName])}m.importStrategy==="component"&&Object.entries(y).forEach(([r,C])=>{const j=C.map(W=>`@import url('./${W}');`).join(`
|
12
|
+
`),S=P.toHash(r,6),p=o.parse(r),w=P.dashCase(p.name),d=o.join(l,`css/f_${w}-${S}.css`);i.writeFileSync(d,j)});const F=f.map(r=>`@import url('./css/${r}');`).join(`
|
13
|
+
`);let N=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
+
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(r=>{try{return i.readFileSync(o.join(l,"css",r),"utf8").length>0}catch{return!1}}).map(r=>`@import url('./css/${r}');`).join(`
|
16
|
+
`)}
|
17
|
+
${F}`;if(m.importStrategy!=="component"){const r=a.reduce((C,j,S)=>{const p=j.reduce((z,B)=>{var $;const H=o.join(l,"css",B),G=i.readFileSync(H,"utf8"),b=(($=/.*-([^-]+)-\d+.css/.exec(B))==null?void 0:$.at(1))||P.toHash(H,6);return z.includes(b)?z:`${z}
|
18
|
+
/*start:${b}*/
|
19
|
+
${G}
|
20
|
+
/*end:${b}*/
|
21
|
+
`},""),w=`l_${S}.css`,d=o.join(l,"css",w),W=`@layer l${S} { ${p}
|
22
|
+
}`;return i.writeFileSync(d,W),`${C}
|
23
|
+
@import url('./css/${w}');`},"");N+=r}i.writeFileSync(h,N);const k=Date.now()-c,J=k<200?"🔥":k<500?"🚀":k<1e3?"🎉":k<2e3?"🚗":k<5e3?"🤔":"🥴";I.info(`Generated CSS in ${k}ms! ${J}`)}catch(c){console.error(c)}},ke=async(e,t)=>{try{const s=await O(e);if(L(t)){const f=[],a=await ne(e),l=await K(e,t,s);if(Object.entries(l).forEach(([h,u])=>{if(u.isKeyframes&&u.css){const F=`css/${`a_${u.animationName}.css`}`,x=o.join(s,F);i.writeFileSync(x,u.css);return}if(u.isClassName){const y=u.factory._withBuildContext({name:h});f[0].push(y.cssFileName);const F=`css/${y.cssFileName}`,x=o.join(s,F);i.writeFileSync(x,y.css)}if(!u.generator)return;const n=u.generator._withBuildContext({name:h,config:a}),g=`css/${n.cssFileName}`,m=o.join(s,g);i.writeFileSync(m,n.css),f[n.priority]||(f[n.priority]=[]),f[n.priority].push(n.cssFileName)}),a.importStrategy!=="component")f.forEach((h,u)=>{const n=`l_${u}.css`,g=o.join(s,"css",n);let m=i.readFileSync(g,"utf8");h.forEach(y=>{var D;const F=o.join(s,"css",y),x=((D=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:D.at(1))||P.toHash(F,6);if(!m.includes(x)){const N=i.readFileSync(F,"utf8"),R=`/*start:${x}*/
|
24
|
+
${N}
|
25
|
+
/*end:${x}*/
|
26
|
+
`;m=`${m.replace(/\}$/,"")}
|
27
|
+
${R}
|
28
|
+
}`}}),i.writeFileSync(g,m)});else{const h=f.flat().map(y=>`@import url('./${y}');`).join(`
|
29
|
+
`),u=P.toHash(t,6),n=o.parse(t),g=P.dashCase(n.name),m=o.join(s,`css/f_${g}-${u}.css`);i.writeFileSync(m,h)}}}catch(s){console.error(s)}},Ne=async(e,t,s=ye())=>{try{const c=await O(e);if(L(t)){const a=i.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==a&&await ee.writeFile(t,a);const h=await ne(e),u=await K(e,t,c);let n=a;if(Object.entries(u).forEach(([g,m])=>{var w;if(m.isKeyframes||!m.generator)return;const y=m.generator._withBuildContext({name:g,config:h,prod:s}),F=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!F)return console.error("Could not find the original declaration");const x=(w=F.at(1))==null?void 0:w.trim(),E=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(n);if(!E)return console.error("Could not find the original declaration");const{index:D}=E;let N=!1;const R=setTimeout(()=>N=!0,5e3);let k=0,J=!1,r=0;for(;!J&&!N;){const d=n[D+k];d==="("&&r++,d===")"&&r--,r===0&&d===")"&&(J=!0),k>n.length&&(N=!0),k++}if(!N)clearTimeout(R);else throw new Error("Failed to find the end of the styled call and timed out");const C=D+k,j=n.slice(D,C),S=n,p=` ${g} = styled(${x}, "${y.classNames}", ${JSON.stringify(y.props)});`;n=n.replace(j,p),S===n&&console.error("Minimize file failed to change content",{name:g,tagName:x})}),h.importStrategy==="component"){const g=P.toHash(t,6),m=o.parse(t);n=`import '../../saltygen/css/${`f_${P.dashCase(m.name)}-${g}.css`}';
|
30
|
+
${n}`}return n=n.replace("{ styled }","{ styledClient as styled }"),n=n.replace("@salty-css/react/styled","@salty-css/react/styled-client"),n}}catch(c){console.error("Error in minimizeFile:",c)}};exports.compileSaltyFile=K;exports.generateConfigStyles=ue;exports.generateCss=xe;exports.generateFile=ke;exports.isSaltyFile=L;exports.logError=je;exports.logger=I;exports.minimizeFile=Ne;exports.saltyFileExtensions=te;exports.saltyFileRegExp=de;
|