@salty-css/core 0.0.1-alpha.133 → 0.0.1-alpha.135
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/generator/index.cjs +1 -1
- package/generator/index.js +26 -26
- package/generator/parse-styles.d.ts +1 -1
- package/index-Dh3cyaBa.js +328 -0
- package/index-Dlz3Sbky.cjs +21 -0
- package/package.json +1 -1
- package/parse-templates-CgZo0YA1.js +97 -0
- package/parse-templates-DD4hQEpv.cjs +8 -0
- package/index-BfaeXpVd.cjs +0 -21
- package/index-D3LMeqt-.js +0 -315
- package/parse-templates-DdYSw-iq.cjs +0 -8
- package/parse-templates-DnLWJ7Hc.js +0 -100
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-Dlz3Sbky.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-Dh3cyaBa.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-templates-
|
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-templates-DD4hQEpv.cjs");const e=require("../index-Dlz3Sbky.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
@@ -4,8 +4,8 @@ import "../dash-case-DBThphLm.js";
|
|
4
4
|
import "path";
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
|
-
import "../parse-templates-
|
8
|
-
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-
|
7
|
+
import "../parse-templates-CgZo0YA1.js";
|
8
|
+
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-Dh3cyaBa.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var f=Object.defineProperty;var y=(a,s,t)=>s in a?f(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var c=(a,s,t)=>y(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dash-case-BJEkFEGQ.cjs"),g=require("../parse-templates-DD4hQEpv.cjs");class N{constructor(s,t){c(this,"_isProd");c(this,"_callerName");c(this,"_context");this.tagName=s,this.params=t}get hash(){return u.toHash(this.params.base||this.params)}get priority(){var s;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((s=this.tagName.generator)==null?void 0:s.priority)||0)+1:0}get classNames(){const s=[this.hash],{className:t}=this.params;return t&&s.push(t),s.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get cssFileName(){return this._callerName?`c_${u.dashCase(this._callerName)}-${this.hash}-${this.priority}.css`:`${this.hash}-${this.priority}.css`}get templateKeys(){var s;return(s=this._context)!=null&&s.config.templates?g.getTemplateKeys(this._context.config.templates):[]}get css(){var n;const{base:s={},variants:t={},compoundVariants:i=[]}=this.params,r={...s,variants:t,compoundVariants:i};return g.parseStyles(r,`.${this.cssClassName}`,(n=this._context)==null?void 0:n.config)}get props(){const{element:s,variants:t={},compoundVariants:i=[],defaultVariants:r={},defaultProps:p={},passProps:n}=this.params,h=new Set([]),l=e=>{const o=r[e];o!==void 0?h.add(`${e}=${String(o)}`):h.add(e)};Object.keys(t).forEach(l),i.map(e=>Object.keys(e).forEach(l));const m=new Set([]);if(this.params.base){const e=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);e&&e.forEach(o=>{const d=o.replace(/\{props\.([\w\d]+)\}/gi,"$1");d&&m.add(d)})}return{element:s,variantKeys:[...h],propValueKeys:[...m],passProps:n,defaultProps:p,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(s){this._context=s;const{name:t,config:i,prod:r}=s;return this._isProd=r,this._callerName=t,this}}exports.StyleComponentGenerator=N;
|
package/generator/index.js
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
var u = Object.defineProperty;
|
2
|
-
var f = (a,
|
3
|
-
var c = (a,
|
2
|
+
var f = (a, s, t) => s in a ? u(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
|
3
|
+
var c = (a, s, t) => f(a, typeof s != "symbol" ? s + "" : s, t);
|
4
4
|
import { t as g, d as y } from "../dash-case-DBThphLm.js";
|
5
|
-
import { g as N, p as _ } from "../parse-templates-
|
5
|
+
import { g as N, p as _ } from "../parse-templates-CgZo0YA1.js";
|
6
6
|
class v {
|
7
|
-
constructor(
|
7
|
+
constructor(s, t) {
|
8
8
|
c(this, "_isProd");
|
9
9
|
c(this, "_callerName");
|
10
10
|
c(this, "_context");
|
11
|
-
this.tagName =
|
11
|
+
this.tagName = s, this.params = t;
|
12
12
|
}
|
13
13
|
get hash() {
|
14
14
|
return g(this.params.base || this.params);
|
15
15
|
}
|
16
16
|
get priority() {
|
17
|
-
var
|
18
|
-
return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((
|
17
|
+
var s;
|
18
|
+
return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((s = this.tagName.generator) == null ? void 0 : s.priority) || 0) + 1 : 0;
|
19
19
|
}
|
20
20
|
get classNames() {
|
21
|
-
const
|
22
|
-
return
|
21
|
+
const s = [this.hash], { className: t } = this.params;
|
22
|
+
return t && s.push(t), s.join(" ");
|
23
23
|
}
|
24
24
|
get cssClassName() {
|
25
25
|
return this.hash;
|
@@ -31,43 +31,43 @@ class v {
|
|
31
31
|
return this._callerName ? `c_${y(this._callerName)}-${this.hash}-${this.priority}.css` : `${this.hash}-${this.priority}.css`;
|
32
32
|
}
|
33
33
|
get templateKeys() {
|
34
|
-
var
|
35
|
-
return (
|
34
|
+
var s;
|
35
|
+
return (s = this._context) != null && s.config.templates ? N(this._context.config.templates) : [];
|
36
36
|
}
|
37
37
|
get css() {
|
38
38
|
var n;
|
39
|
-
const { base:
|
40
|
-
return _(r, `.${this.cssClassName}`,
|
39
|
+
const { base: s = {}, variants: t = {}, compoundVariants: i = [] } = this.params, r = { ...s, variants: t, compoundVariants: i };
|
40
|
+
return _(r, `.${this.cssClassName}`, (n = this._context) == null ? void 0 : n.config);
|
41
41
|
}
|
42
42
|
get props() {
|
43
|
-
const { element:
|
43
|
+
const { element: s, variants: t = {}, compoundVariants: i = [], defaultVariants: r = {}, defaultProps: p = {}, passProps: n } = this.params, h = /* @__PURE__ */ new Set([]), m = (e) => {
|
44
44
|
const o = r[e];
|
45
45
|
o !== void 0 ? h.add(`${e}=${String(o)}`) : h.add(e);
|
46
46
|
};
|
47
|
-
Object.keys(
|
48
|
-
const
|
47
|
+
Object.keys(t).forEach(m), i.map((e) => Object.keys(e).forEach(m));
|
48
|
+
const l = /* @__PURE__ */ new Set([]);
|
49
49
|
if (this.params.base) {
|
50
50
|
const e = JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);
|
51
51
|
e && e.forEach((o) => {
|
52
|
-
const
|
53
|
-
|
52
|
+
const d = o.replace(/\{props\.([\w\d]+)\}/gi, "$1");
|
53
|
+
d && l.add(d);
|
54
54
|
});
|
55
55
|
}
|
56
56
|
return {
|
57
|
-
element:
|
57
|
+
element: s,
|
58
58
|
variantKeys: [...h],
|
59
|
-
propValueKeys: [...
|
60
|
-
passProps:
|
61
|
-
defaultProps:
|
59
|
+
propValueKeys: [...l],
|
60
|
+
passProps: n,
|
61
|
+
defaultProps: p,
|
62
62
|
attr: {
|
63
63
|
"data-component-name": this._isProd ? void 0 : this._callerName
|
64
64
|
}
|
65
65
|
};
|
66
66
|
}
|
67
|
-
_withBuildContext(
|
68
|
-
this._context =
|
69
|
-
const { name:
|
70
|
-
return this._isProd = r, this._callerName =
|
67
|
+
_withBuildContext(s) {
|
68
|
+
this._context = s;
|
69
|
+
const { name: t, config: i, prod: r } = s;
|
70
|
+
return this._isProd = r, this._callerName = t, this;
|
71
71
|
}
|
72
72
|
}
|
73
73
|
export {
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { SaltyConfig } from '../config/config-types';
|
2
|
-
export declare const parseStyles: <T extends object>(styles: T, currentClass: string,
|
2
|
+
export declare const parseStyles: <T extends object>(styles: T, currentClass: string, config?: SaltyConfig | undefined) => string;
|
@@ -0,0 +1,328 @@
|
|
1
|
+
import * as X from "esbuild";
|
2
|
+
import { execSync as it } from "child_process";
|
3
|
+
import { t as B, d as z } from "./dash-case-DBThphLm.js";
|
4
|
+
import { join as o, parse as H } from "path";
|
5
|
+
import { existsSync as K, writeFileSync as x, mkdirSync as J, readFileSync as R, statSync as lt, readdirSync as pt } from "fs";
|
6
|
+
import { readFile as ft, writeFile as dt } from "fs/promises";
|
7
|
+
import { p as U, a as ut, b as gt, c as mt } from "./parse-templates-CgZo0YA1.js";
|
8
|
+
import { createLogger as yt, format as W, transports as ht } from "winston";
|
9
|
+
const Y = (t) => {
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
+
const e = o(t, "package.json");
|
12
|
+
return K(e) ? e : Y(o(t, ".."));
|
13
|
+
}, bt = async (t) => {
|
14
|
+
const e = Y(t);
|
15
|
+
return await ft(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
+
});
|
17
|
+
}, $t = async (t) => {
|
18
|
+
const e = await bt(t);
|
19
|
+
if (e)
|
20
|
+
return e.type;
|
21
|
+
};
|
22
|
+
let _;
|
23
|
+
const Q = async (t) => {
|
24
|
+
if (_) return _;
|
25
|
+
const e = await $t(t);
|
26
|
+
return e === "module" ? _ = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (_ = "cjs"), _ || "esm";
|
27
|
+
}, O = yt({
|
28
|
+
level: "debug",
|
29
|
+
format: W.combine(W.colorize(), W.cli()),
|
30
|
+
transports: [new ht.Console({})]
|
31
|
+
}), Et = (t) => {
|
32
|
+
O.error(t);
|
33
|
+
};
|
34
|
+
function tt(t) {
|
35
|
+
return t ? typeof t != "string" ? tt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, c) => (c > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
+
}
|
37
|
+
const St = {
|
38
|
+
/** Set box model to border-box */
|
39
|
+
"*, *::before, *::after": {
|
40
|
+
boxSizing: "border-box"
|
41
|
+
},
|
42
|
+
/** Remove default margin and padding */
|
43
|
+
"*": {
|
44
|
+
margin: 0
|
45
|
+
},
|
46
|
+
/** Remove adjust font properties */
|
47
|
+
html: {
|
48
|
+
lineHeight: 1.15,
|
49
|
+
textSizeAdjust: "100%",
|
50
|
+
WebkitFontSmoothing: "antialiased"
|
51
|
+
},
|
52
|
+
/** Make media elements responsive */
|
53
|
+
"img, picture, video, canvas, svg": {
|
54
|
+
display: "block",
|
55
|
+
maxWidth: "100%"
|
56
|
+
},
|
57
|
+
/** Avoid overflow of text */
|
58
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
59
|
+
overflowWrap: "break-word"
|
60
|
+
},
|
61
|
+
/** Improve text wrapping */
|
62
|
+
p: {
|
63
|
+
textWrap: "pretty"
|
64
|
+
},
|
65
|
+
"h1, h2, h3, h4, h5, h6": {
|
66
|
+
textWrap: "balance"
|
67
|
+
},
|
68
|
+
/** Improve link color */
|
69
|
+
a: {
|
70
|
+
color: "currentColor"
|
71
|
+
},
|
72
|
+
/** Improve button line height */
|
73
|
+
button: {
|
74
|
+
lineHeight: "1em",
|
75
|
+
color: "currentColor"
|
76
|
+
},
|
77
|
+
/** Improve form elements */
|
78
|
+
"input, optgroup, select, textarea": {
|
79
|
+
fontFamily: "inherit",
|
80
|
+
fontSize: "100%",
|
81
|
+
lineHeight: "1.15em"
|
82
|
+
}
|
83
|
+
}, A = {
|
84
|
+
externalModules: []
|
85
|
+
}, et = (t) => {
|
86
|
+
if (A.externalModules.length > 0) return A.externalModules;
|
87
|
+
const e = o(t, "salty.config.ts"), r = R(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
88
|
+
if (!r) return [];
|
89
|
+
const l = r[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
90
|
+
return A.externalModules = l, l;
|
91
|
+
}, I = (t) => o(t, "./saltygen"), st = ["salty", "css", "styles", "styled"], wt = (t = []) => new RegExp(`\\.(${[...st, ...t].join("|")})\\.`), Z = (t, e = []) => wt(e).test(t), xt = async (t) => {
|
92
|
+
const e = I(t), c = o(t, "salty.config.ts"), r = o(e, "salty.config.js"), l = await Q(t), s = et(t);
|
93
|
+
await X.build({
|
94
|
+
entryPoints: [c],
|
95
|
+
minify: !0,
|
96
|
+
treeShaking: !0,
|
97
|
+
bundle: !0,
|
98
|
+
outfile: r,
|
99
|
+
format: l,
|
100
|
+
external: s
|
101
|
+
});
|
102
|
+
const m = Date.now(), { config: b } = await import(`${r}?t=${m}`);
|
103
|
+
return b;
|
104
|
+
}, Ft = async (t) => {
|
105
|
+
const e = await xt(t), c = /* @__PURE__ */ new Set(), r = (i, d = []) => i ? Object.entries(i).flatMap(([w, u]) => {
|
106
|
+
if (!u) return;
|
107
|
+
if (typeof u == "object") return r(u, [...d, w]);
|
108
|
+
const V = tt(w), v = z(w), M = [...d, V].join(".");
|
109
|
+
c.add(`"${M}"`);
|
110
|
+
const D = [...d.map(z), v].join("-"), { result: T } = mt(u);
|
111
|
+
return `--${D}: ${T};`;
|
112
|
+
}) : [], l = (i) => i ? Object.entries(i).flatMap(([d, w]) => {
|
113
|
+
const u = r(w);
|
114
|
+
return d === "base" ? u.join("") : `${d} { ${u.join("")} }`;
|
115
|
+
}) : [], s = (i) => i ? Object.entries(i).flatMap(([d, w]) => Object.entries(w).flatMap(([u, V]) => {
|
116
|
+
const v = r(V, [d]), M = `.${d}-${u}, [data-${d}="${u}"]`, D = v.join("");
|
117
|
+
return `${M} { ${D} }`;
|
118
|
+
})) : [], m = r(e.variables), b = l(e.responsiveVariables), C = s(e.conditionalVariables), n = I(t), p = o(n, "css/_variables.css"), F = `:root { ${m.join("")} ${b.join("")} } ${C.join("")}`;
|
119
|
+
x(p, F);
|
120
|
+
const y = o(n, "css/_global.css"), f = U(e.global, "");
|
121
|
+
x(y, `@layer global { ${f} }`);
|
122
|
+
const $ = o(n, "css/_reset.css"), g = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : St, S = U(g, "");
|
123
|
+
x($, `@layer reset { ${S} }`);
|
124
|
+
const a = o(n, "css/_templates.css"), h = ut(e.templates), j = gt(e.templates);
|
125
|
+
x(a, h);
|
126
|
+
const k = o(n, "types/css-tokens.d.ts"), N = `
|
127
|
+
// Variable types
|
128
|
+
type VariableTokens = ${[...c].join("|")};
|
129
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
130
|
+
|
131
|
+
// Template types
|
132
|
+
type TemplateTokens = {
|
133
|
+
${Object.entries(j).map(([i, d]) => `${i}?: ${d}`).join(`
|
134
|
+
`)}
|
135
|
+
}
|
136
|
+
`;
|
137
|
+
x(k, N);
|
138
|
+
}, G = async (t, e, c) => {
|
139
|
+
const r = B(e), l = o(c, "./temp");
|
140
|
+
K(l) || J(l);
|
141
|
+
const s = H(e);
|
142
|
+
let m = R(e, "utf8");
|
143
|
+
m = m.replace(/styled\(([^"'`{,]+),/g, (y, f) => {
|
144
|
+
if (/^['"`]/.test(f)) return y;
|
145
|
+
const P = new RegExp(`import\\s?\\{[^{}]*${f}[^{}]*\\}\\s?from\\s?([^{};]+);`);
|
146
|
+
if (!P.test(m)) return y;
|
147
|
+
const S = P.exec(m);
|
148
|
+
if (S) {
|
149
|
+
const a = S.at(1);
|
150
|
+
if (st.some((j) => a == null ? void 0 : a.includes(j))) return y;
|
151
|
+
}
|
152
|
+
return "styled('div',";
|
153
|
+
});
|
154
|
+
const b = o(c, "js", r + ".js"), C = et(t), n = await Q(t);
|
155
|
+
await X.build({
|
156
|
+
stdin: {
|
157
|
+
contents: m,
|
158
|
+
sourcefile: s.base,
|
159
|
+
resolveDir: s.dir,
|
160
|
+
loader: "tsx"
|
161
|
+
},
|
162
|
+
minify: !1,
|
163
|
+
treeShaking: !0,
|
164
|
+
bundle: !0,
|
165
|
+
outfile: b,
|
166
|
+
format: n,
|
167
|
+
target: ["node20"],
|
168
|
+
keepNames: !0,
|
169
|
+
external: C,
|
170
|
+
packages: "external"
|
171
|
+
});
|
172
|
+
const p = Date.now();
|
173
|
+
return await import(`${b}?t=${p}`);
|
174
|
+
}, L = async (t) => {
|
175
|
+
const e = I(t), c = o(e, "salty.config.js"), r = Date.now(), { config: l } = await import(`${c}?t=${r}`);
|
176
|
+
return l;
|
177
|
+
}, nt = () => {
|
178
|
+
try {
|
179
|
+
return process.env.NODE_ENV === "production";
|
180
|
+
} catch {
|
181
|
+
return !1;
|
182
|
+
}
|
183
|
+
}, Mt = async (t, e = nt()) => {
|
184
|
+
try {
|
185
|
+
const c = Date.now();
|
186
|
+
e ? O.info("Generating CSS in production mode! 🔥") : O.info("Generating CSS in development mode! 🚀");
|
187
|
+
const r = [], l = [], s = I(t), m = o(s, "index.css");
|
188
|
+
(() => {
|
189
|
+
K(s) && it("rm -rf " + s), J(s), J(o(s, "css")), J(o(s, "types"));
|
190
|
+
})(), await Ft(t);
|
191
|
+
const C = await L(t);
|
192
|
+
async function n(a, h) {
|
193
|
+
const j = ["node_modules", "saltygen"], k = lt(a);
|
194
|
+
if (k.isDirectory()) {
|
195
|
+
const E = pt(a);
|
196
|
+
if (j.some((i) => a.includes(i))) return;
|
197
|
+
await Promise.all(E.map((i) => n(o(a, i), o(h, i))));
|
198
|
+
} else if (k.isFile() && Z(a)) {
|
199
|
+
const N = await G(t, a, s), i = [];
|
200
|
+
Object.entries(N).forEach(([M, D]) => {
|
201
|
+
if (D.isKeyframes && D.css) {
|
202
|
+
const q = `a_${D.animationName}.css`, at = `css/${q}`, ct = o(s, at);
|
203
|
+
r.push(q), x(ct, D.css);
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
if (!D.generator) return;
|
207
|
+
const T = D.generator._withBuildContext({
|
208
|
+
name: M,
|
209
|
+
config: C,
|
210
|
+
prod: e
|
211
|
+
});
|
212
|
+
l[T.priority] || (l[T.priority] = []), l[T.priority].push(T.cssFileName), i.push(T.cssFileName);
|
213
|
+
const ot = `css/${T.cssFileName}`, rt = o(s, ot);
|
214
|
+
x(rt, T.css);
|
215
|
+
});
|
216
|
+
const d = i.map((M) => `@import url('./${M}');`).join(`
|
217
|
+
`), w = B(a, 6), u = H(a), V = z(u.name), v = o(s, `css/f_${V}-${w}.css`);
|
218
|
+
x(v, d);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
await n(t, s);
|
222
|
+
const p = r.map((a) => `@import url('./css/${a}');`).join(`
|
223
|
+
`);
|
224
|
+
let $ = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
225
|
+
|
226
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((a) => {
|
227
|
+
try {
|
228
|
+
return R(o(s, "css", a), "utf8").length > 0;
|
229
|
+
} catch {
|
230
|
+
return !1;
|
231
|
+
}
|
232
|
+
}).map((a) => `@import url('./css/${a}');`).join(`
|
233
|
+
`)}
|
234
|
+
${p}`;
|
235
|
+
if (C.importStrategy !== "component") {
|
236
|
+
const a = l.reduce((h, j, k) => {
|
237
|
+
const E = j.reduce((N, i) => N + `@import url('./css/${i}') layer(l${k});`, "");
|
238
|
+
return `${h}
|
239
|
+
${E}`;
|
240
|
+
}, "");
|
241
|
+
$ += a;
|
242
|
+
}
|
243
|
+
x(m, $);
|
244
|
+
const g = Date.now() - c, S = g < 200 ? "🔥" : g < 500 ? "🚀" : g < 1e3 ? "🎉" : g < 2e3 ? "🚗" : g < 5e3 ? "🤔" : "🥴";
|
245
|
+
O.info(`Generated CSS in ${g}ms! ${S}`);
|
246
|
+
} catch (c) {
|
247
|
+
console.error(c);
|
248
|
+
}
|
249
|
+
}, _t = async (t, e) => {
|
250
|
+
try {
|
251
|
+
const c = [], r = o(t, "./saltygen"), l = o(r, "index.css");
|
252
|
+
if (Z(e)) {
|
253
|
+
const m = await L(t), b = await G(t, e, r);
|
254
|
+
Object.entries(b).forEach(([y, f]) => {
|
255
|
+
if (f.isKeyframes && f.css) {
|
256
|
+
const a = `css/${`a_${f.animationName}.css`}`, h = o(r, a);
|
257
|
+
x(h, f.css);
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
if (!f.generator) return;
|
261
|
+
const $ = f.generator._withBuildContext({
|
262
|
+
name: y,
|
263
|
+
config: m
|
264
|
+
}), P = `css/${$.cssFileName}`, g = o(r, P);
|
265
|
+
c.push($.cssFileName), x(g, $.css);
|
266
|
+
});
|
267
|
+
const C = R(l, "utf8").split(`
|
268
|
+
`), n = c.map((y) => `@import url('../saltygen/css/${y}');`), F = [.../* @__PURE__ */ new Set([...C, ...n])].join(`
|
269
|
+
`);
|
270
|
+
x(l, F);
|
271
|
+
}
|
272
|
+
} catch (c) {
|
273
|
+
console.error(c);
|
274
|
+
}
|
275
|
+
}, Vt = async (t, e, c = nt()) => {
|
276
|
+
try {
|
277
|
+
const r = o(t, "./saltygen");
|
278
|
+
if (Z(e)) {
|
279
|
+
const s = R(e, "utf8");
|
280
|
+
s.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== s && await dt(e, s);
|
281
|
+
const b = await L(t), C = await G(t, e, r);
|
282
|
+
let n = s;
|
283
|
+
if (Object.entries(C).forEach(([p, F]) => {
|
284
|
+
var w;
|
285
|
+
if (F.isKeyframes || !F.generator) return;
|
286
|
+
const y = F.generator._withBuildContext({
|
287
|
+
name: p,
|
288
|
+
config: b,
|
289
|
+
prod: c
|
290
|
+
}), f = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
291
|
+
if (!f) return console.error("Could not find the original declaration");
|
292
|
+
const $ = (w = f.at(1)) == null ? void 0 : w.trim(), P = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(n);
|
293
|
+
if (!P) return console.error("Could not find the original declaration");
|
294
|
+
const { index: g } = P;
|
295
|
+
let S = !1;
|
296
|
+
const a = setTimeout(() => S = !0, 5e3);
|
297
|
+
let h = 0, j = !1, k = 0;
|
298
|
+
for (; !j && !S; ) {
|
299
|
+
const u = n[g + h];
|
300
|
+
u === "(" && k++, u === ")" && k--, k === 0 && u === ")" && (j = !0), h > n.length && (S = !0), h++;
|
301
|
+
}
|
302
|
+
if (!S) clearTimeout(a);
|
303
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
304
|
+
const E = g + h, N = n.slice(g, E), i = n, d = ` ${p} = styled(${$}, "${y.classNames}", ${JSON.stringify(y.props)});`;
|
305
|
+
n = n.replace(N, d), i === n && console.error("Minimize file failed to change content", { name: p, tagName: $ });
|
306
|
+
}), b.importStrategy === "component") {
|
307
|
+
const p = B(e, 6), F = H(e);
|
308
|
+
n = `import '../../saltygen/css/${`f_${z(F.name)}-${p}.css`}';
|
309
|
+
${n}`;
|
310
|
+
}
|
311
|
+
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
312
|
+
}
|
313
|
+
} catch (r) {
|
314
|
+
console.error("Error in minimizeFile:", r);
|
315
|
+
}
|
316
|
+
};
|
317
|
+
export {
|
318
|
+
Et as a,
|
319
|
+
wt as b,
|
320
|
+
Ft as c,
|
321
|
+
G as d,
|
322
|
+
_t as e,
|
323
|
+
Mt as g,
|
324
|
+
Z as i,
|
325
|
+
O as l,
|
326
|
+
Vt as m,
|
327
|
+
st as s
|
328
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";const ce=require("esbuild"),ae=require("child_process"),M=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),a=require("fs"),G=require("fs/promises"),v=require("./parse-templates-DD4hQEpv.cjs"),z=require("winston");var H=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const L=le(ce),U=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return a.existsSync(t)?t:U(s.join(e,".."))},pe=async e=>{const t=U(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let R;const X=async e=>{if(R)return R;const t=await ue(e);return t==="module"?R="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:H&&H.tagName.toUpperCase()==="SCRIPT"&&H.src||new URL("index-Dlz3Sbky.cjs",document.baseURI).href).endsWith(".cjs"))&&(R="cjs"),R||"esm"},I=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{I.error(e)};function Y(e){return e?typeof e!="string"?Y(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,n)=>(n>0?".":"")+t.toLowerCase()):""}const fe={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},Q=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),o=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const p=o[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return A.externalModules=p,p},J=e=>s.join(e,"./saltygen"),B=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...B,...e].join("|")})\\.`),q=(e,t=[])=>ee(t).test(e),ge=async e=>{const t=J(e),n=s.join(e,"salty.config.ts"),o=s.join(t,"salty.config.js"),p=await X(e),r=Q(e);await L.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:p,external:r});const m=Date.now(),{config:b}=await import(`${o}?t=${m}`);return b},te=async e=>{const t=await ge(e),n=new Set,o=(l,f=[])=>l?Object.entries(l).flatMap(([F,g])=>{if(!g)return;if(typeof g=="object")return o(g,[...f,F]);const O=Y(F),V=M.dashCase(F),E=[...f,O].join(".");n.add(`"${E}"`);const T=[...f.map(M.dashCase),V].join("-"),{result:D}=v.parseValueTokens(g);return`--${T}: ${D};`}):[],p=l=>l?Object.entries(l).flatMap(([f,F])=>{const g=o(F);return f==="base"?g.join(""):`${f} { ${g.join("")} }`}):[],r=l=>l?Object.entries(l).flatMap(([f,F])=>Object.entries(F).flatMap(([g,O])=>{const V=o(O,[f]),E=`.${f}-${g}, [data-${f}="${g}"]`,T=V.join("");return`${E} { ${T} }`})):[],m=o(t.variables),b=p(t.responsiveVariables),x=r(t.conditionalVariables),i=J(e),u=s.join(i,"css/_variables.css"),$=`:root { ${m.join("")} ${b.join("")} } ${x.join("")}`;a.writeFileSync(u,$);const h=s.join(i,"css/_global.css"),d=v.parseStyles(t.global,"");a.writeFileSync(h,`@layer global { ${d} }`);const j=s.join(i,"css/_reset.css"),y=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,w=v.parseStyles(y,"");a.writeFileSync(j,`@layer reset { ${w} }`);const c=s.join(i,"css/_templates.css"),S=v.parseTemplates(t.templates),C=v.getTemplateTypes(t.templates);a.writeFileSync(c,S);const k=s.join(i,"types/css-tokens.d.ts"),N=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...n].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(C).map(([l,f])=>`${l}?: ${f}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
`;a.writeFileSync(k,N)},W=async(e,t,n)=>{const o=M.toHash(t),p=s.join(n,"./temp");a.existsSync(p)||a.mkdirSync(p);const r=s.parse(t);let m=a.readFileSync(t,"utf8");m=m.replace(/styled\(([^"'`{,]+),/g,(h,d)=>{if(/^['"`]/.test(d))return h;const P=new RegExp(`import\\s?\\{[^{}]*${d}[^{}]*\\}\\s?from\\s?([^{};]+);`);if(!P.test(m))return h;const w=P.exec(m);if(w){const c=w.at(1);if(B.some(C=>c==null?void 0:c.includes(C)))return h}return"styled('div',"});const b=s.join(n,"js",o+".js"),x=Q(e),i=await X(e);await L.build({stdin:{contents:m,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:b,format:i,target:["node20"],keepNames:!0,external:x,packages:"external"});const u=Date.now();return await import(`${b}?t=${u}`)},K=async e=>{const t=J(e),n=s.join(t,"salty.config.js"),o=Date.now(),{config:p}=await import(`${n}?t=${o}`);return p},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ye=async(e,t=se())=>{try{const n=Date.now();t?I.info("Generating CSS in production mode! 🔥"):I.info("Generating CSS in development mode! 🚀");const o=[],p=[],r=J(e),m=s.join(r,"index.css");(()=>{a.existsSync(r)&&ae.execSync("rm -rf "+r),a.mkdirSync(r),a.mkdirSync(s.join(r,"css")),a.mkdirSync(s.join(r,"types"))})(),await te(e);const x=await K(e);async function i(c,S){const C=["node_modules","saltygen"],k=a.statSync(c);if(k.isDirectory()){const _=a.readdirSync(c);if(C.some(l=>c.includes(l)))return;await Promise.all(_.map(l=>i(s.join(c,l),s.join(S,l))))}else if(k.isFile()&&q(c)){const N=await W(e,c,r),l=[];Object.entries(N).forEach(([E,T])=>{if(T.isKeyframes&&T.css){const Z=`a_${T.animationName}.css`,re=`css/${Z}`,ie=s.join(r,re);o.push(Z),a.writeFileSync(ie,T.css);return}if(!T.generator)return;const D=T.generator._withBuildContext({name:E,config:x,prod:t});p[D.priority]||(p[D.priority]=[]),p[D.priority].push(D.cssFileName),l.push(D.cssFileName);const ne=`css/${D.cssFileName}`,oe=s.join(r,ne);a.writeFileSync(oe,D.css)});const f=l.map(E=>`@import url('./${E}');`).join(`
|
12
|
+
`),F=M.toHash(c,6),g=s.parse(c),O=M.dashCase(g.name),V=s.join(r,`css/f_${O}-${F}.css`);a.writeFileSync(V,f)}}await i(e,r);const u=o.map(c=>`@import url('./css/${c}');`).join(`
|
13
|
+
`);let j=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
+
|
15
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(c=>{try{return a.readFileSync(s.join(r,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
|
16
|
+
`)}
|
17
|
+
${u}`;if(x.importStrategy!=="component"){const c=p.reduce((S,C,k)=>{const _=C.reduce((N,l)=>N+`@import url('./css/${l}') layer(l${k});`,"");return`${S}
|
18
|
+
${_}`},"");j+=c}a.writeFileSync(m,j);const y=Date.now()-n,w=y<200?"🔥":y<500?"🚀":y<1e3?"🎉":y<2e3?"🚗":y<5e3?"🤔":"🥴";I.info(`Generated CSS in ${y}ms! ${w}`)}catch(n){console.error(n)}},me=async(e,t)=>{try{const n=[],o=s.join(e,"./saltygen"),p=s.join(o,"index.css");if(q(t)){const m=await K(e),b=await W(e,t,o);Object.entries(b).forEach(([h,d])=>{if(d.isKeyframes&&d.css){const c=`css/${`a_${d.animationName}.css`}`,S=s.join(o,c);a.writeFileSync(S,d.css);return}if(!d.generator)return;const j=d.generator._withBuildContext({name:h,config:m}),P=`css/${j.cssFileName}`,y=s.join(o,P);n.push(j.cssFileName),a.writeFileSync(y,j.css)});const x=a.readFileSync(p,"utf8").split(`
|
19
|
+
`),i=n.map(h=>`@import url('../saltygen/css/${h}');`),$=[...new Set([...x,...i])].join(`
|
20
|
+
`);a.writeFileSync(p,$)}}catch(n){console.error(n)}},he=async(e,t,n=se())=>{try{const o=s.join(e,"./saltygen");if(q(t)){const r=a.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==r&&await G.writeFile(t,r);const b=await K(e),x=await W(e,t,o);let i=r;if(Object.entries(x).forEach(([u,$])=>{var F;if($.isKeyframes||!$.generator)return;const h=$.generator._withBuildContext({name:u,config:b,prod:n}),d=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!d)return console.error("Could not find the original declaration");const j=(F=d.at(1))==null?void 0:F.trim(),P=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(i);if(!P)return console.error("Could not find the original declaration");const{index:y}=P;let w=!1;const c=setTimeout(()=>w=!0,5e3);let S=0,C=!1,k=0;for(;!C&&!w;){const g=i[y+S];g==="("&&k++,g===")"&&k--,k===0&&g===")"&&(C=!0),S>i.length&&(w=!0),S++}if(!w)clearTimeout(c);else throw new Error("Failed to find the end of the styled call and timed out");const _=y+S,N=i.slice(y,_),l=i,f=` ${u} = styled(${j}, "${h.classNames}", ${JSON.stringify(h.props)});`;i=i.replace(N,f),l===i&&console.error("Minimize file failed to change content",{name:u,tagName:j})}),b.importStrategy==="component"){const u=M.toHash(t,6),$=s.parse(t);i=`import '../../saltygen/css/${`f_${M.dashCase($.name)}-${u}.css`}';
|
21
|
+
${i}`}return i=i.replace("{ styled }","{ styledClient as styled }"),i=i.replace("@salty-css/react/styled","@salty-css/react/styled-client"),i}}catch(o){console.error("Error in minimizeFile:",o)}};exports.compileSaltyFile=W;exports.generateConfigStyles=te;exports.generateCss=ye;exports.generateFile=me;exports.isSaltyFile=q;exports.logError=de;exports.logger=I;exports.minimizeFile=he;exports.saltyFileExtensions=B;exports.saltyFileRegExp=ee;
|
package/package.json
CHANGED
@@ -0,0 +1,97 @@
|
|
1
|
+
import { d as l } from "./dash-case-DBThphLm.js";
|
2
|
+
const W = (t, s) => {
|
3
|
+
if (typeof t != "string") return { result: t };
|
4
|
+
if (!s) return { result: t };
|
5
|
+
const r = [];
|
6
|
+
return Object.values(s).forEach((n) => {
|
7
|
+
const { pattern: o, transform: p } = n;
|
8
|
+
t = t.replace(o, (i) => {
|
9
|
+
const { value: d, css: e } = p(i);
|
10
|
+
return e && r.push(e), d;
|
11
|
+
});
|
12
|
+
}), { result: t, additionalCss: r };
|
13
|
+
}, N = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${l(n[1].replaceAll(".", "-"))})`) } : { result: t }, a = (t, s, r) => {
|
14
|
+
if (!t) return "";
|
15
|
+
const n = [], o = Object.entries(t).reduce((i, [d, e]) => {
|
16
|
+
const c = d.trim();
|
17
|
+
if (typeof e == "function" && (e = e()), typeof e == "object") {
|
18
|
+
if (!e) return i;
|
19
|
+
if (c === "variants")
|
20
|
+
return Object.entries(e).forEach(([f, u]) => {
|
21
|
+
u && Object.entries(u).forEach(([y, j]) => {
|
22
|
+
if (!j) return;
|
23
|
+
const b = `${s}.${f}-${y}`, m = a(j, b, r);
|
24
|
+
n.push(m);
|
25
|
+
});
|
26
|
+
}), i;
|
27
|
+
if (c === "defaultVariants")
|
28
|
+
return i;
|
29
|
+
if (c === "compoundVariants")
|
30
|
+
return e.forEach((f) => {
|
31
|
+
const { css: u, ...y } = f, j = Object.entries(y).reduce((m, [k, w]) => `${m}.${k}-${w}`, s), b = a(u, j, r);
|
32
|
+
n.push(b);
|
33
|
+
}), i;
|
34
|
+
if (c.startsWith("@")) {
|
35
|
+
const f = a(e, s, r), u = `${c} {
|
36
|
+
${f.replace(`
|
37
|
+
`, `
|
38
|
+
`)}
|
39
|
+
}`;
|
40
|
+
return n.push(u), i;
|
41
|
+
}
|
42
|
+
const $ = d.includes("&") ? c.replace("&", s) : c.startsWith(":") ? `${s}${c}` : `${s} ${c}`, h = a(e, $, r);
|
43
|
+
return n.push(h), i;
|
44
|
+
}
|
45
|
+
if (r != null && r.templates && r.templates[c]) {
|
46
|
+
const h = e.split(".").reduce((f, u) => f[u], r.templates[c]);
|
47
|
+
if (h) {
|
48
|
+
const f = a(h, "");
|
49
|
+
return `${i}${f}`;
|
50
|
+
}
|
51
|
+
return console.warn(`Template "${c}" with path of "${e}" was not found in config!`), i;
|
52
|
+
}
|
53
|
+
const S = c.startsWith("-") ? c : l(c), O = ($, h = ";") => i = `${i}${$}${h}`, T = ($) => O(`${S}:${$}`);
|
54
|
+
if (typeof e == "number") return T(e);
|
55
|
+
if (typeof e != "string")
|
56
|
+
if ("toString" in e) e = e.toString();
|
57
|
+
else return i;
|
58
|
+
const { modifiers: V } = r || {}, g = function* () {
|
59
|
+
yield N(e), yield W(e, V);
|
60
|
+
}();
|
61
|
+
for (const { result: $, additionalCss: h = [] } of g)
|
62
|
+
e = $, h.forEach((f) => {
|
63
|
+
const u = a(f, "");
|
64
|
+
O(u, "");
|
65
|
+
});
|
66
|
+
return T(e);
|
67
|
+
}, "");
|
68
|
+
return o ? s ? [`${s} { ${o} }`, ...n].join(`
|
69
|
+
`) : o : n.join(`
|
70
|
+
`);
|
71
|
+
}, P = (t, s = []) => {
|
72
|
+
if (!t) return "";
|
73
|
+
const r = [], n = {};
|
74
|
+
if (Object.entries(t).forEach(([o, p]) => {
|
75
|
+
if (typeof p == "object") {
|
76
|
+
if (!p) return;
|
77
|
+
const i = o.trim(), d = P(p, [...s, i]);
|
78
|
+
r.push(d);
|
79
|
+
} else
|
80
|
+
n[o] = p;
|
81
|
+
}), Object.keys(n).length) {
|
82
|
+
const o = s.map(l).join("-"), p = a(n, `.${o}`);
|
83
|
+
r.push(p);
|
84
|
+
}
|
85
|
+
return r.join(`
|
86
|
+
`);
|
87
|
+
}, x = (t) => Object.keys(t), A = (t) => Object.entries(t).reduce((s, [r, n]) => (typeof n == "object" && (s[r] = E(n).map((o) => `"${o}"`).join(" | ")), s), {}), E = (t, s = "", r = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
88
|
+
const p = s ? `${s}.${n}` : n;
|
89
|
+
return typeof o == "object" ? E(o, p, r) : r.add(s);
|
90
|
+
}), [...r]) : [];
|
91
|
+
export {
|
92
|
+
P as a,
|
93
|
+
A as b,
|
94
|
+
N as c,
|
95
|
+
x as g,
|
96
|
+
a as p
|
97
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";const b=require("./dash-case-BJEkFEGQ.cjs"),K=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const e=[];return Object.values(s).forEach(n=>{const{pattern:o,transform:p}=n;t=t.replace(o,i=>{const{value:d,css:r}=p(i);return r&&e.push(r),d})}),{result:t,additionalCss:e}},S=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${b.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},h=(t,s,e)=>{if(!t)return"";const n=[],o=Object.entries(t).reduce((i,[d,r])=>{const c=d.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(c==="variants")return Object.entries(r).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,y])=>{if(!y)return;const j=`${s}.${f}-${l}`,m=h(y,j,e);n.push(m)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(f=>{const{css:u,...l}=f,y=Object.entries(l).reduce((m,[W,q])=>`${m}.${W}-${q}`,s),j=h(u,y,e);n.push(j)}),i;if(c.startsWith("@")){const f=h(r,s,e),u=`${c} {
|
2
|
+
${f.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return n.push(u),i}const a=d.includes("&")?c.replace("&",s):c.startsWith(":")?`${s}${c}`:`${s} ${c}`,$=h(r,a,e);return n.push($),i}if(e!=null&&e.templates&&e.templates[c]){const $=r.split(".").reduce((f,u)=>f[u],e.templates[c]);if($){const f=h($,"");return`${i}${f}`}return console.warn(`Template "${c}" with path of "${r}" was not found in config!`),i}const g=c.startsWith("-")?c:b.dashCase(c),T=(a,$=";")=>i=`${i}${a}${$}`,O=a=>T(`${g}:${a}`);if(typeof r=="number")return O(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:k}=e||{},w=function*(){yield S(r),yield K(r,k)}();for(const{result:a,additionalCss:$=[]}of w)r=a,$.forEach(f=>{const u=h(f,"");T(u,"")});return O(r)},"");return o?s?[`${s} { ${o} }`,...n].join(`
|
6
|
+
`):o:n.join(`
|
7
|
+
`)},E=(t,s=[])=>{if(!t)return"";const e=[],n={};if(Object.entries(t).forEach(([o,p])=>{if(typeof p=="object"){if(!p)return;const i=o.trim(),d=E(p,[...s,i]);e.push(d)}else n[o]=p}),Object.keys(n).length){const o=s.map(b.dashCase).join("-"),p=h(n,`.${o}`);e.push(p)}return e.join(`
|
8
|
+
`)},N=t=>Object.keys(t),P=t=>Object.entries(t).reduce((s,[e,n])=>(typeof n=="object"&&(s[e]=V(n).map(o=>`"${o}"`).join(" | ")),s),{}),V=(t,s="",e=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const p=s?`${s}.${n}`:n;return typeof o=="object"?V(o,p,e):e.add(s)}),[...e]):[];exports.getTemplateKeys=N;exports.getTemplateTypes=P;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=S;
|
package/index-BfaeXpVd.cjs
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";const ce=require("esbuild"),ae=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),c=require("fs"),Z=require("fs/promises"),R=require("./parse-templates-DdYSw-iq.cjs"),z=require("winston");var I=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const G=le(ce),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return c.existsSync(t)?t:L(s.join(e,".."))},pe=async e=>{const t=L(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let M;const U=async e=>{if(M)return M;const t=await ue(e);return t==="module"?M="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-BfaeXpVd.cjs",document.baseURI).href).endsWith(".cjs"))&&(M="cjs"),M||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{J.error(e)};function X(e){return e?typeof e!="string"?X(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,n)=>(n>0?".":"")+t.toLowerCase()):""}const fe={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},Y=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),o=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const l=o[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return A.externalModules=l,l},q=e=>s.join(e,"./saltygen"),Q=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...Q,...e].join("|")})\\.`),W=(e,t=[])=>ee(t).test(e),ge=async e=>{const t=q(e),n=s.join(e,"salty.config.ts"),o=s.join(t,"salty.config.js"),l=await U(e),r=Y(e);await G.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:l,external:r});const h=Date.now(),{config:S}=await import(`${o}?t=${h}`);return S},te=async e=>{const t=await ge(e),n=new Set,o=(p,d=[])=>p?Object.entries(p).flatMap(([b,f])=>{if(!f)return;if(typeof f=="object")return o(f,[...d,b]);const V=X(b),v=D.dashCase(b),T=[...d,V].join(".");n.add(`"${T}"`);const C=[...d.map(D.dashCase),v].join("-"),{result:k}=R.parseValueTokens(f);return`--${C}: ${k};`}):[],l=p=>p?Object.entries(p).flatMap(([d,b])=>{const f=o(b);return d==="base"?f.join(""):`${d} { ${f.join("")} }`}):[],r=p=>p?Object.entries(p).flatMap(([d,b])=>Object.entries(b).flatMap(([f,V])=>{const v=o(V,[d]),T=`.${d}-${f}, [data-${d}="${f}"]`,C=v.join("");return`${T} { ${C} }`})):[],h=o(t.variables),S=l(t.responsiveVariables),w=r(t.conditionalVariables),i=q(e),u=s.join(i,"css/_variables.css"),j=`:root { ${h.join("")} ${S.join("")} } ${w.join("")}`;c.writeFileSync(u,j);const $=s.join(i,"css/_global.css"),y=R.parseStyles(t.global,"");c.writeFileSync($,`@layer global { ${y} }`);const F=s.join(i,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,x=R.parseStyles(g,"");c.writeFileSync(F,`@layer reset { ${x} }`);const a=s.join(i,"css/_templates.css"),m=R.parseTemplates(t.templates),_=R.getTemplateTypes(t.templates);c.writeFileSync(a,m);const P=s.join(i,"types/css-tokens.d.ts"),E=`
|
2
|
-
// Variable types
|
3
|
-
type VariableTokens = ${[...n].join("|")};
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
-
|
6
|
-
// Template types
|
7
|
-
type TemplateTokens = {
|
8
|
-
${Object.entries(_).map(([p,d])=>`${p}?: ${d}`).join(`
|
9
|
-
`)}
|
10
|
-
}
|
11
|
-
`;c.writeFileSync(P,E)},H=async(e,t,n)=>{const o=D.toHash(t),l=s.join(n,"./temp");c.existsSync(l)||c.mkdirSync(l);const r=s.parse(t);let h=c.readFileSync(t,"utf8");h=h.replace(/styled\([^"'`{,]+,/g,"styled('div',");const S=s.join(n,"js",o+".js"),w=Y(e),i=await U(e);await G.build({stdin:{contents:h,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:S,format:i,target:["node20"],keepNames:!0,external:w,packages:"external"});const u=Date.now();return await import(`${S}?t=${u}`)},B=async e=>{const t=q(e),n=s.join(t,"salty.config.js"),o=Date.now(),{config:l}=await import(`${n}?t=${o}`);return l},se=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ye=async(e,t=se())=>{try{const n=Date.now();t?J.info("Generating CSS in production mode! 🔥"):J.info("Generating CSS in development mode! 🚀");const o=[],l=[],r=q(e),h=s.join(r,"index.css");(()=>{c.existsSync(r)&&ae.execSync("rm -rf "+r),c.mkdirSync(r),c.mkdirSync(s.join(r,"css")),c.mkdirSync(s.join(r,"types"))})(),await te(e);const w=await B(e);async function i(a,m){const _=["node_modules","saltygen"],P=c.statSync(a);if(P.isDirectory()){const O=c.readdirSync(a);if(_.some(p=>a.includes(p)))return;await Promise.all(O.map(p=>i(s.join(a,p),s.join(m,p))))}else if(P.isFile()&&W(a)){const E=await H(e,a,r),p=[];Object.entries(E).forEach(([T,C])=>{if(C.isKeyframes&&C.css){const K=`a_${C.animationName}.css`,re=`css/${K}`,ie=s.join(r,re);o.push(K),c.writeFileSync(ie,C.css);return}if(!C.generator)return;const k=C.generator._withBuildContext({name:T,config:w,prod:t});l[k.priority]||(l[k.priority]=[]),l[k.priority].push(k.cssFileName),p.push(k.cssFileName);const ne=`css/${k.cssFileName}`,oe=s.join(r,ne);c.writeFileSync(oe,k.css)});const d=p.map(T=>`@import url('./${T}');`).join(`
|
12
|
-
`),b=D.toHash(a,6),f=s.parse(a),V=D.dashCase(f.name),v=s.join(r,`css/f_${V}-${b}.css`);c.writeFileSync(v,d)}}await i(e,r);const u=o.map(a=>`@import url('./css/${a}');`).join(`
|
13
|
-
`);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
14
|
-
|
15
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return c.readFileSync(s.join(r,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
|
16
|
-
`)}
|
17
|
-
${u}`;if(w.importStrategy!=="component"){const a=l.flat().map(m=>`@import url('./css/${m}');`).join(`
|
18
|
-
`);F+=a}c.writeFileSync(h,F);const g=Date.now()-n,x=g<200?"🔥":g<500?"🚀":g<1e3?"🎉":g<2e3?"🚗":g<5e3?"🤔":"🥴";J.info(`Generated CSS in ${g}ms! ${x}`)}catch(n){console.error(n)}},me=async(e,t)=>{try{const n=[],o=s.join(e,"./saltygen"),l=s.join(o,"index.css");if(W(t)){const h=await B(e),S=await H(e,t,o);Object.entries(S).forEach(([$,y])=>{if(y.isKeyframes&&y.css){const a=`css/${`a_${y.animationName}.css`}`,m=s.join(o,a);c.writeFileSync(m,y.css);return}if(!y.generator)return;const F=y.generator._withBuildContext({name:$,config:h}),N=`css/${F.cssFileName}`,g=s.join(o,N);n.push(F.cssFileName),c.writeFileSync(g,F.css)});const w=c.readFileSync(l,"utf8").split(`
|
19
|
-
`),i=n.map($=>`@import url('../saltygen/css/${$}');`),j=[...new Set([...w,...i])].join(`
|
20
|
-
`);c.writeFileSync(l,j)}}catch(n){console.error(n)}},he=async(e,t,n=se())=>{try{const o=s.join(e,"./saltygen");if(W(t)){const r=c.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,u=>`export ${u}`)!==r&&await Z.writeFile(t,r);const S=await B(e),w=await H(e,t,o);let i=r;if(Object.entries(w).forEach(([u,j])=>{var b;if(j.isKeyframes||!j.generator)return;const $=j.generator._withBuildContext({name:u,config:S,prod:n}),y=new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!y)return console.error("Could not find the original declaration");const F=(b=y.at(1))==null?void 0:b.trim(),N=new RegExp(`\\s${u}[=\\s]+styled\\(`,"g").exec(i);if(!N)return console.error("Could not find the original declaration");const{index:g}=N;let x=!1;const a=setTimeout(()=>x=!0,5e3);let m=0,_=!1,P=0;for(;!_&&!x;){const f=i[g+m];f==="("&&P++,f===")"&&P--,P===0&&f===")"&&(_=!0),m>i.length&&(x=!0),m++}if(!x)clearTimeout(a);else throw new Error("Failed to find the end of the styled call and timed out");const O=g+m,E=i.slice(g,O),p=i,d=` ${u} = styled(${F}, "${$.classNames}", ${JSON.stringify($.props)});`;i=i.replace(E,d),p===i&&console.error("Minimize file failed to change content",{name:u,tagName:F})}),S.importStrategy==="component"){const u=D.toHash(t,6),j=s.parse(t);i=`import '../../saltygen/css/${`f_${D.dashCase(j.name)}-${u}.css`}';
|
21
|
-
${i}`}return i=i.replace("{ styled }","{ styledClient as styled }"),i=i.replace("@salty-css/react/styled","@salty-css/react/styled-client"),i}}catch(o){console.error("Error in minimizeFile:",o)}};exports.compileSaltyFile=H;exports.generateConfigStyles=te;exports.generateCss=ye;exports.generateFile=me;exports.isSaltyFile=W;exports.logError=de;exports.logger=J;exports.minimizeFile=he;exports.saltyFileExtensions=Q;exports.saltyFileRegExp=ee;
|
package/index-D3LMeqt-.js
DELETED
@@ -1,315 +0,0 @@
|
|
1
|
-
import * as X from "esbuild";
|
2
|
-
import { execSync as ct } from "child_process";
|
3
|
-
import { t as H, d as R } from "./dash-case-DBThphLm.js";
|
4
|
-
import { join as o, parse as I } from "path";
|
5
|
-
import { existsSync as K, writeFileSync as $, mkdirSync as O, readFileSync as J, statSync as it, readdirSync as lt } from "fs";
|
6
|
-
import { readFile as pt, writeFile as ft } from "fs/promises";
|
7
|
-
import { p as U, a as dt, b as ut, c as gt } from "./parse-templates-DnLWJ7Hc.js";
|
8
|
-
import { createLogger as mt, format as A, transports as yt } from "winston";
|
9
|
-
const Y = (t) => {
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
11
|
-
const e = o(t, "package.json");
|
12
|
-
return K(e) ? e : Y(o(t, ".."));
|
13
|
-
}, ht = async (t) => {
|
14
|
-
const e = Y(t);
|
15
|
-
return await pt(e, "utf-8").then(JSON.parse).catch(() => {
|
16
|
-
});
|
17
|
-
}, bt = async (t) => {
|
18
|
-
const e = await ht(t);
|
19
|
-
if (e)
|
20
|
-
return e.type;
|
21
|
-
};
|
22
|
-
let _;
|
23
|
-
const Q = async (t) => {
|
24
|
-
if (_) return _;
|
25
|
-
const e = await bt(t);
|
26
|
-
return e === "module" ? _ = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (_ = "cjs"), _ || "esm";
|
27
|
-
}, z = mt({
|
28
|
-
level: "debug",
|
29
|
-
format: A.combine(A.colorize(), A.cli()),
|
30
|
-
transports: [new yt.Console({})]
|
31
|
-
}), Mt = (t) => {
|
32
|
-
z.error(t);
|
33
|
-
};
|
34
|
-
function tt(t) {
|
35
|
-
return t ? typeof t != "string" ? tt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, a) => (a > 0 ? "." : "") + e.toLowerCase()) : "";
|
36
|
-
}
|
37
|
-
const $t = {
|
38
|
-
/** Set box model to border-box */
|
39
|
-
"*, *::before, *::after": {
|
40
|
-
boxSizing: "border-box"
|
41
|
-
},
|
42
|
-
/** Remove default margin and padding */
|
43
|
-
"*": {
|
44
|
-
margin: 0
|
45
|
-
},
|
46
|
-
/** Remove adjust font properties */
|
47
|
-
html: {
|
48
|
-
lineHeight: 1.15,
|
49
|
-
textSizeAdjust: "100%",
|
50
|
-
WebkitFontSmoothing: "antialiased"
|
51
|
-
},
|
52
|
-
/** Make media elements responsive */
|
53
|
-
"img, picture, video, canvas, svg": {
|
54
|
-
display: "block",
|
55
|
-
maxWidth: "100%"
|
56
|
-
},
|
57
|
-
/** Avoid overflow of text */
|
58
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
59
|
-
overflowWrap: "break-word"
|
60
|
-
},
|
61
|
-
/** Improve text wrapping */
|
62
|
-
p: {
|
63
|
-
textWrap: "pretty"
|
64
|
-
},
|
65
|
-
"h1, h2, h3, h4, h5, h6": {
|
66
|
-
textWrap: "balance"
|
67
|
-
},
|
68
|
-
/** Improve link color */
|
69
|
-
a: {
|
70
|
-
color: "currentColor"
|
71
|
-
},
|
72
|
-
/** Improve button line height */
|
73
|
-
button: {
|
74
|
-
lineHeight: "1em",
|
75
|
-
color: "currentColor"
|
76
|
-
},
|
77
|
-
/** Improve form elements */
|
78
|
-
"input, optgroup, select, textarea": {
|
79
|
-
fontFamily: "inherit",
|
80
|
-
fontSize: "100%",
|
81
|
-
lineHeight: "1.15em"
|
82
|
-
}
|
83
|
-
}, B = {
|
84
|
-
externalModules: []
|
85
|
-
}, et = (t) => {
|
86
|
-
if (B.externalModules.length > 0) return B.externalModules;
|
87
|
-
const e = o(t, "salty.config.ts"), r = J(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
88
|
-
if (!r) return [];
|
89
|
-
const i = r[1].split(",").map((s) => s.replace(/['"`]/g, "").trim());
|
90
|
-
return B.externalModules = i, i;
|
91
|
-
}, W = (t) => o(t, "./saltygen"), wt = ["salty", "css", "styles", "styled"], St = (t = []) => new RegExp(`\\.(${[...wt, ...t].join("|")})\\.`), Z = (t, e = []) => St(e).test(t), Ft = async (t) => {
|
92
|
-
const e = W(t), a = o(t, "salty.config.ts"), r = o(e, "salty.config.js"), i = await Q(t), s = et(t);
|
93
|
-
await X.build({
|
94
|
-
entryPoints: [a],
|
95
|
-
minify: !0,
|
96
|
-
treeShaking: !0,
|
97
|
-
bundle: !0,
|
98
|
-
outfile: r,
|
99
|
-
format: i,
|
100
|
-
external: s
|
101
|
-
});
|
102
|
-
const y = Date.now(), { config: h } = await import(`${r}?t=${y}`);
|
103
|
-
return h;
|
104
|
-
}, xt = async (t) => {
|
105
|
-
const e = await Ft(t), a = /* @__PURE__ */ new Set(), r = (l, f = []) => l ? Object.entries(l).flatMap(([b, d]) => {
|
106
|
-
if (!d) return;
|
107
|
-
if (typeof d == "object") return r(d, [...f, b]);
|
108
|
-
const V = tt(b), v = R(b), D = [...f, V].join(".");
|
109
|
-
a.add(`"${D}"`);
|
110
|
-
const C = [...f.map(R), v].join("-"), { result: k } = gt(d);
|
111
|
-
return `--${C}: ${k};`;
|
112
|
-
}) : [], i = (l) => l ? Object.entries(l).flatMap(([f, b]) => {
|
113
|
-
const d = r(b);
|
114
|
-
return f === "base" ? d.join("") : `${f} { ${d.join("")} }`;
|
115
|
-
}) : [], s = (l) => l ? Object.entries(l).flatMap(([f, b]) => Object.entries(b).flatMap(([d, V]) => {
|
116
|
-
const v = r(V, [f]), D = `.${f}-${d}, [data-${f}="${d}"]`, C = v.join("");
|
117
|
-
return `${D} { ${C} }`;
|
118
|
-
})) : [], y = r(e.variables), h = i(e.responsiveVariables), F = s(e.conditionalVariables), n = W(t), p = o(n, "css/_variables.css"), w = `:root { ${y.join("")} ${h.join("")} } ${F.join("")}`;
|
119
|
-
$(p, w);
|
120
|
-
const x = o(n, "css/_global.css"), g = U(e.global, "");
|
121
|
-
$(x, `@layer global { ${g} }`);
|
122
|
-
const S = o(n, "css/_reset.css"), u = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : $t, j = U(u, "");
|
123
|
-
$(S, `@layer reset { ${j} }`);
|
124
|
-
const c = o(n, "css/_templates.css"), m = dt(e.templates), N = ut(e.templates);
|
125
|
-
$(c, m);
|
126
|
-
const P = o(n, "types/css-tokens.d.ts"), M = `
|
127
|
-
// Variable types
|
128
|
-
type VariableTokens = ${[...a].join("|")};
|
129
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
130
|
-
|
131
|
-
// Template types
|
132
|
-
type TemplateTokens = {
|
133
|
-
${Object.entries(N).map(([l, f]) => `${l}?: ${f}`).join(`
|
134
|
-
`)}
|
135
|
-
}
|
136
|
-
`;
|
137
|
-
$(P, M);
|
138
|
-
}, G = async (t, e, a) => {
|
139
|
-
const r = H(e), i = o(a, "./temp");
|
140
|
-
K(i) || O(i);
|
141
|
-
const s = I(e);
|
142
|
-
let y = J(e, "utf8");
|
143
|
-
y = y.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
144
|
-
const h = o(a, "js", r + ".js"), F = et(t), n = await Q(t);
|
145
|
-
await X.build({
|
146
|
-
stdin: {
|
147
|
-
contents: y,
|
148
|
-
sourcefile: s.base,
|
149
|
-
resolveDir: s.dir,
|
150
|
-
loader: "tsx"
|
151
|
-
},
|
152
|
-
minify: !1,
|
153
|
-
treeShaking: !0,
|
154
|
-
bundle: !0,
|
155
|
-
outfile: h,
|
156
|
-
format: n,
|
157
|
-
target: ["node20"],
|
158
|
-
keepNames: !0,
|
159
|
-
external: F,
|
160
|
-
packages: "external"
|
161
|
-
});
|
162
|
-
const p = Date.now();
|
163
|
-
return await import(`${h}?t=${p}`);
|
164
|
-
}, L = async (t) => {
|
165
|
-
const e = W(t), a = o(e, "salty.config.js"), r = Date.now(), { config: i } = await import(`${a}?t=${r}`);
|
166
|
-
return i;
|
167
|
-
}, st = () => {
|
168
|
-
try {
|
169
|
-
return process.env.NODE_ENV === "production";
|
170
|
-
} catch {
|
171
|
-
return !1;
|
172
|
-
}
|
173
|
-
}, _t = async (t, e = st()) => {
|
174
|
-
try {
|
175
|
-
const a = Date.now();
|
176
|
-
e ? z.info("Generating CSS in production mode! 🔥") : z.info("Generating CSS in development mode! 🚀");
|
177
|
-
const r = [], i = [], s = W(t), y = o(s, "index.css");
|
178
|
-
(() => {
|
179
|
-
K(s) && ct("rm -rf " + s), O(s), O(o(s, "css")), O(o(s, "types"));
|
180
|
-
})(), await xt(t);
|
181
|
-
const F = await L(t);
|
182
|
-
async function n(c, m) {
|
183
|
-
const N = ["node_modules", "saltygen"], P = it(c);
|
184
|
-
if (P.isDirectory()) {
|
185
|
-
const E = lt(c);
|
186
|
-
if (N.some((l) => c.includes(l))) return;
|
187
|
-
await Promise.all(E.map((l) => n(o(c, l), o(m, l))));
|
188
|
-
} else if (P.isFile() && Z(c)) {
|
189
|
-
const M = await G(t, c, s), l = [];
|
190
|
-
Object.entries(M).forEach(([D, C]) => {
|
191
|
-
if (C.isKeyframes && C.css) {
|
192
|
-
const q = `a_${C.animationName}.css`, rt = `css/${q}`, at = o(s, rt);
|
193
|
-
r.push(q), $(at, C.css);
|
194
|
-
return;
|
195
|
-
}
|
196
|
-
if (!C.generator) return;
|
197
|
-
const k = C.generator._withBuildContext({
|
198
|
-
name: D,
|
199
|
-
config: F,
|
200
|
-
prod: e
|
201
|
-
});
|
202
|
-
i[k.priority] || (i[k.priority] = []), i[k.priority].push(k.cssFileName), l.push(k.cssFileName);
|
203
|
-
const nt = `css/${k.cssFileName}`, ot = o(s, nt);
|
204
|
-
$(ot, k.css);
|
205
|
-
});
|
206
|
-
const f = l.map((D) => `@import url('./${D}');`).join(`
|
207
|
-
`), b = H(c, 6), d = I(c), V = R(d.name), v = o(s, `css/f_${V}-${b}.css`);
|
208
|
-
$(v, f);
|
209
|
-
}
|
210
|
-
}
|
211
|
-
await n(t, s);
|
212
|
-
const p = r.map((c) => `@import url('./css/${c}');`).join(`
|
213
|
-
`);
|
214
|
-
let S = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
215
|
-
|
216
|
-
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((c) => {
|
217
|
-
try {
|
218
|
-
return J(o(s, "css", c), "utf8").length > 0;
|
219
|
-
} catch {
|
220
|
-
return !1;
|
221
|
-
}
|
222
|
-
}).map((c) => `@import url('./css/${c}');`).join(`
|
223
|
-
`)}
|
224
|
-
${p}`;
|
225
|
-
if (F.importStrategy !== "component") {
|
226
|
-
const c = i.flat().map((m) => `@import url('./css/${m}');`).join(`
|
227
|
-
`);
|
228
|
-
S += c;
|
229
|
-
}
|
230
|
-
$(y, S);
|
231
|
-
const u = Date.now() - a, j = u < 200 ? "🔥" : u < 500 ? "🚀" : u < 1e3 ? "🎉" : u < 2e3 ? "🚗" : u < 5e3 ? "🤔" : "🥴";
|
232
|
-
z.info(`Generated CSS in ${u}ms! ${j}`);
|
233
|
-
} catch (a) {
|
234
|
-
console.error(a);
|
235
|
-
}
|
236
|
-
}, Et = async (t, e) => {
|
237
|
-
try {
|
238
|
-
const a = [], r = o(t, "./saltygen"), i = o(r, "index.css");
|
239
|
-
if (Z(e)) {
|
240
|
-
const y = await L(t), h = await G(t, e, r);
|
241
|
-
Object.entries(h).forEach(([x, g]) => {
|
242
|
-
if (g.isKeyframes && g.css) {
|
243
|
-
const c = `css/${`a_${g.animationName}.css`}`, m = o(r, c);
|
244
|
-
$(m, g.css);
|
245
|
-
return;
|
246
|
-
}
|
247
|
-
if (!g.generator) return;
|
248
|
-
const S = g.generator._withBuildContext({
|
249
|
-
name: x,
|
250
|
-
config: y
|
251
|
-
}), T = `css/${S.cssFileName}`, u = o(r, T);
|
252
|
-
a.push(S.cssFileName), $(u, S.css);
|
253
|
-
});
|
254
|
-
const F = J(i, "utf8").split(`
|
255
|
-
`), n = a.map((x) => `@import url('../saltygen/css/${x}');`), w = [.../* @__PURE__ */ new Set([...F, ...n])].join(`
|
256
|
-
`);
|
257
|
-
$(i, w);
|
258
|
-
}
|
259
|
-
} catch (a) {
|
260
|
-
console.error(a);
|
261
|
-
}
|
262
|
-
}, Vt = async (t, e, a = st()) => {
|
263
|
-
try {
|
264
|
-
const r = o(t, "./saltygen");
|
265
|
-
if (Z(e)) {
|
266
|
-
const s = J(e, "utf8");
|
267
|
-
s.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== s && await ft(e, s);
|
268
|
-
const h = await L(t), F = await G(t, e, r);
|
269
|
-
let n = s;
|
270
|
-
if (Object.entries(F).forEach(([p, w]) => {
|
271
|
-
var b;
|
272
|
-
if (w.isKeyframes || !w.generator) return;
|
273
|
-
const x = w.generator._withBuildContext({
|
274
|
-
name: p,
|
275
|
-
config: h,
|
276
|
-
prod: a
|
277
|
-
}), g = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(s);
|
278
|
-
if (!g) return console.error("Could not find the original declaration");
|
279
|
-
const S = (b = g.at(1)) == null ? void 0 : b.trim(), T = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(n);
|
280
|
-
if (!T) return console.error("Could not find the original declaration");
|
281
|
-
const { index: u } = T;
|
282
|
-
let j = !1;
|
283
|
-
const c = setTimeout(() => j = !0, 5e3);
|
284
|
-
let m = 0, N = !1, P = 0;
|
285
|
-
for (; !N && !j; ) {
|
286
|
-
const d = n[u + m];
|
287
|
-
d === "(" && P++, d === ")" && P--, P === 0 && d === ")" && (N = !0), m > n.length && (j = !0), m++;
|
288
|
-
}
|
289
|
-
if (!j) clearTimeout(c);
|
290
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
291
|
-
const E = u + m, M = n.slice(u, E), l = n, f = ` ${p} = styled(${S}, "${x.classNames}", ${JSON.stringify(x.props)});`;
|
292
|
-
n = n.replace(M, f), l === n && console.error("Minimize file failed to change content", { name: p, tagName: S });
|
293
|
-
}), h.importStrategy === "component") {
|
294
|
-
const p = H(e, 6), w = I(e);
|
295
|
-
n = `import '../../saltygen/css/${`f_${R(w.name)}-${p}.css`}';
|
296
|
-
${n}`;
|
297
|
-
}
|
298
|
-
return n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
299
|
-
}
|
300
|
-
} catch (r) {
|
301
|
-
console.error("Error in minimizeFile:", r);
|
302
|
-
}
|
303
|
-
};
|
304
|
-
export {
|
305
|
-
Mt as a,
|
306
|
-
St as b,
|
307
|
-
xt as c,
|
308
|
-
G as d,
|
309
|
-
Et as e,
|
310
|
-
_t as g,
|
311
|
-
Z as i,
|
312
|
-
z as l,
|
313
|
-
Vt as m,
|
314
|
-
wt as s
|
315
|
-
};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),N=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const n=[];return Object.values(s).forEach(e=>{const{pattern:o,transform:i}=e;t=t.replace(o,d=>{const{value:p,css:j}=i(d);return j&&n.push(j),p})}),{result:t,additionalCss:n}},E=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...e)=>`var(--${T.dashCase(e[1].replaceAll(".","-"))})`)}:{result:t},a=(t,s,n,e)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((p,[j,r])=>{const c=j.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return p;if(c==="variants")return Object.entries(r).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,m])=>{if(!m)return;const y=`${s}.${f}-${l}`,b=a(m,y,n,e);o.push(b)})}),p;if(c==="defaultVariants")return p;if(c==="compoundVariants")return r.forEach(f=>{const{css:u,...l}=f,m=Object.entries(l).reduce((b,[q,K])=>`${b}.${q}-${K}`,s),y=a(u,m,n,e);o.push(y)}),p;if(c.startsWith("@")){const f=a(r,s,n,e),u=`${c} {
|
2
|
-
${f.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return o.push(u),p}const $=j.includes("&")?c.replace("&",s):c.startsWith(":")?`${s}${c}`:`${s} ${c}`,h=a(r,$,n,e);return o.push(h),p}if(e!=null&&e.templates&&e.templates[c]){const h=r.split(".").reduce((f,u)=>f[u],e.templates[c]);if(h){const f=a(h,"");return`${p}${f}`}return console.warn(`Template "${c}" with path of "${r}" was not found in config!`),p}const k=c.startsWith("-")?c:T.dashCase(c),O=($,h=";")=>p=`${p}${$}${h}`,S=$=>O(`${k}:${$}`);if(typeof r=="number")return S(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return p;const{modifiers:w}=e||{},W=function*(){yield E(r),yield N(r,w)}();for(const{result:$,additionalCss:h=[]}of W)r=$,h.forEach(f=>{const u=a(f,"");O(u,"")});return S(r)},"");if(!i)return o.join(`
|
6
|
-
`);if(!s)return i;let d="";return n!==void 0?d=`@layer l${n} { ${s} { ${i} } }`:d=`${s} { ${i} }`,[d,...o].join(`
|
7
|
-
`)},V=(t,s=[])=>{if(!t)return"";const n=[],e={};if(Object.entries(t).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const d=o.trim(),p=V(i,[...s,d]);n.push(p)}else e[o]=i}),Object.keys(e).length){const o=s.map(T.dashCase).join("-"),i=a(e,`.${o}`);n.push(i)}return n.join(`
|
8
|
-
`)},P=t=>Object.keys(t),_=t=>Object.entries(t).reduce((s,[n,e])=>(typeof e=="object"&&(s[n]=g(e).map(o=>`"${o}"`).join(" | ")),s),{}),g=(t,s="",n=new Set)=>t?(Object.entries(t).forEach(([e,o])=>{const i=s?`${s}.${e}`:e;return typeof o=="object"?g(o,i,n):n.add(s)}),[...n]):[];exports.getTemplateKeys=P;exports.getTemplateTypes=_;exports.parseStyles=a;exports.parseTemplates=V;exports.parseValueTokens=E;
|
@@ -1,100 +0,0 @@
|
|
1
|
-
import { d as O } from "./dash-case-DBThphLm.js";
|
2
|
-
const N = (t, r) => {
|
3
|
-
if (typeof t != "string") return { result: t };
|
4
|
-
if (!r) return { result: t };
|
5
|
-
const n = [];
|
6
|
-
return Object.values(r).forEach((e) => {
|
7
|
-
const { pattern: o, transform: i } = e;
|
8
|
-
t = t.replace(o, (d) => {
|
9
|
-
const { value: c, css: j } = i(d);
|
10
|
-
return j && n.push(j), c;
|
11
|
-
});
|
12
|
-
}), { result: t, additionalCss: n };
|
13
|
-
}, P = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...e) => `var(--${O(e[1].replaceAll(".", "-"))})`) } : { result: t }, a = (t, r, n, e) => {
|
14
|
-
if (!t) return "";
|
15
|
-
const o = [], i = Object.entries(t).reduce((c, [j, s]) => {
|
16
|
-
const p = j.trim();
|
17
|
-
if (typeof s == "function" && (s = s()), typeof s == "object") {
|
18
|
-
if (!s) return c;
|
19
|
-
if (p === "variants")
|
20
|
-
return Object.entries(s).forEach(([f, u]) => {
|
21
|
-
u && Object.entries(u).forEach(([m, b]) => {
|
22
|
-
if (!b) return;
|
23
|
-
const y = `${r}.${f}-${m}`, l = a(b, y, n, e);
|
24
|
-
o.push(l);
|
25
|
-
});
|
26
|
-
}), c;
|
27
|
-
if (p === "defaultVariants")
|
28
|
-
return c;
|
29
|
-
if (p === "compoundVariants")
|
30
|
-
return s.forEach((f) => {
|
31
|
-
const { css: u, ...m } = f, b = Object.entries(m).reduce((l, [w, W]) => `${l}.${w}-${W}`, r), y = a(u, b, n, e);
|
32
|
-
o.push(y);
|
33
|
-
}), c;
|
34
|
-
if (p.startsWith("@")) {
|
35
|
-
const f = a(s, r, n, e), u = `${p} {
|
36
|
-
${f.replace(`
|
37
|
-
`, `
|
38
|
-
`)}
|
39
|
-
}`;
|
40
|
-
return o.push(u), c;
|
41
|
-
}
|
42
|
-
const $ = j.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, h = a(s, $, n, e);
|
43
|
-
return o.push(h), c;
|
44
|
-
}
|
45
|
-
if (e != null && e.templates && e.templates[p]) {
|
46
|
-
const h = s.split(".").reduce((f, u) => f[u], e.templates[p]);
|
47
|
-
if (h) {
|
48
|
-
const f = a(h, "");
|
49
|
-
return `${c}${f}`;
|
50
|
-
}
|
51
|
-
return console.warn(`Template "${p}" with path of "${s}" was not found in config!`), c;
|
52
|
-
}
|
53
|
-
const V = p.startsWith("-") ? p : O(p), T = ($, h = ";") => c = `${c}${$}${h}`, E = ($) => T(`${V}:${$}`);
|
54
|
-
if (typeof s == "number") return E(s);
|
55
|
-
if (typeof s != "string")
|
56
|
-
if ("toString" in s) s = s.toString();
|
57
|
-
else return c;
|
58
|
-
const { modifiers: g } = e || {}, k = function* () {
|
59
|
-
yield P(s), yield N(s, g);
|
60
|
-
}();
|
61
|
-
for (const { result: $, additionalCss: h = [] } of k)
|
62
|
-
s = $, h.forEach((f) => {
|
63
|
-
const u = a(f, "");
|
64
|
-
T(u, "");
|
65
|
-
});
|
66
|
-
return E(s);
|
67
|
-
}, "");
|
68
|
-
if (!i) return o.join(`
|
69
|
-
`);
|
70
|
-
if (!r) return i;
|
71
|
-
let d = "";
|
72
|
-
return n !== void 0 ? d = `@layer l${n} { ${r} { ${i} } }` : d = `${r} { ${i} }`, [d, ...o].join(`
|
73
|
-
`);
|
74
|
-
}, _ = (t, r = []) => {
|
75
|
-
if (!t) return "";
|
76
|
-
const n = [], e = {};
|
77
|
-
if (Object.entries(t).forEach(([o, i]) => {
|
78
|
-
if (typeof i == "object") {
|
79
|
-
if (!i) return;
|
80
|
-
const d = o.trim(), c = _(i, [...r, d]);
|
81
|
-
n.push(c);
|
82
|
-
} else
|
83
|
-
e[o] = i;
|
84
|
-
}), Object.keys(e).length) {
|
85
|
-
const o = r.map(O).join("-"), i = a(e, `.${o}`);
|
86
|
-
n.push(i);
|
87
|
-
}
|
88
|
-
return n.join(`
|
89
|
-
`);
|
90
|
-
}, A = (t) => Object.keys(t), K = (t) => Object.entries(t).reduce((r, [n, e]) => (typeof e == "object" && (r[n] = S(e).map((o) => `"${o}"`).join(" | ")), r), {}), S = (t, r = "", n = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([e, o]) => {
|
91
|
-
const i = r ? `${r}.${e}` : e;
|
92
|
-
return typeof o == "object" ? S(o, i, n) : n.add(r);
|
93
|
-
}), [...n]) : [];
|
94
|
-
export {
|
95
|
-
_ as a,
|
96
|
-
K as b,
|
97
|
-
P as c,
|
98
|
-
A as g,
|
99
|
-
a as p
|
100
|
-
};
|