@salty-css/core 0.0.1-alpha.115 → 0.0.1-alpha.117
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 +3 -3
- package/{dash-case-DKzpenwY.cjs → dash-case-8PdMJjFC.cjs} +1 -1
- package/{dash-case-DMQMcCO6.js → dash-case-D_tXuO4I.js} +1 -1
- package/generator/index.cjs +1 -1
- package/generator/index.js +26 -24
- package/generator/style-generator.d.ts +2 -0
- package/index-V5AY9k9D.js +257 -0
- package/index-eyW1pjj1.cjs +21 -0
- package/package.json +1 -1
- package/{parse-templates-wUig7ACb.js → parse-templates-D1FebDfR.js} +1 -1
- package/{parse-templates-C1-wQz7G.cjs → parse-templates-lpgqU05M.cjs} +1 -1
- package/types/index.d.ts +3 -1
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.js +1 -1
- package/index-DckDeOOE.cjs +0 -21
- package/index-PIN4uCyt.js +0 -253
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-eyW1pjj1.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-V5AY9k9D.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-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-8PdMJjFC.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-lpgqU05M.cjs");const e=require("../index-eyW1pjj1.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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "esbuild";
|
|
2
2
|
import "child_process";
|
|
3
|
-
import "../dash-case-
|
|
3
|
+
import "../dash-case-D_tXuO4I.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-D1FebDfR.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-V5AY9k9D.js";
|
|
9
9
|
export {
|
|
10
10
|
p as compileSaltyFile,
|
|
11
11
|
n as generateConfigStyles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=3)=>{const t=o(5381,JSON.stringify(e))>>>0;return i(t,r)};function s(e){return e?typeof e!="string"?s(String(e)):e.replace(
|
|
1
|
+
"use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=3)=>{const t=o(5381,JSON.stringify(e))>>>0;return i(t,r)};function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(r,t)=>(t>0?"-":"")+r.toLowerCase()):""}exports.dashCase=s;exports.toHash=c;
|
|
@@ -11,7 +11,7 @@ const n = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), o = (e, r) => {
|
|
|
11
11
|
return o(t, r);
|
|
12
12
|
};
|
|
13
13
|
function s(e) {
|
|
14
|
-
return e ? typeof e != "string" ? s(String(e)) : e.replace(
|
|
14
|
+
return e ? typeof e != "string" ? s(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
17
|
s as d,
|
package/generator/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var N=(s,t,e)=>t in s?f(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var o=(s,t,e)=>N(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../dash-case-8PdMJjFC.cjs"),u=require("../parse-templates-lpgqU05M.cjs");class S{constructor(t,e){o(this,"_isProd");o(this,"_callerName");o(this,"_context");this.tagName=t,this.params=e}get hash(){return _.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:e}=this.params;return e&&t.push(e),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?u.getTemplateKeys(this._context.config.templates):[]}get css(){var n;const{base:t={},variants:e={},compoundVariants:i=[]}=this.params,r={...t,variants:e,compoundVariants:i};return u.parseStyles(r,`.${this.cssClassName}`,this.priority,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:e={},compoundVariants:i=[],defaultVariants:r={},defaultProps:n={},passProps:y}=this.params,c=new Set([]),h=a=>{const p=r[a];p!==void 0?c.add(`${a}=${String(p)}`):c.add(a)};Object.keys(e).forEach(h),i.map(a=>Object.keys(a).forEach(h));const l=new Set([]),m=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return m&&m.forEach((a,p,g)=>{const d=g.at(1);d&&l.add(d)}),{element:t,variantKeys:[...c],propValueKeys:[...l],passProps:y,defaultProps:n,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:e,config:i,prod:r}=t;return this._isProd=r,this._callerName=e,this}}exports.StyleComponentGenerator=S;
|
package/generator/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (e, t, s) =>
|
|
4
|
-
import { t as
|
|
5
|
-
import { g as
|
|
6
|
-
class
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var y = (e, t, s) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var o = (e, t, s) => y(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import { t as N } from "../dash-case-D_tXuO4I.js";
|
|
5
|
+
import { g as _, p as x } from "../parse-templates-D1FebDfR.js";
|
|
6
|
+
class K {
|
|
7
7
|
constructor(t, s) {
|
|
8
8
|
o(this, "_isProd");
|
|
9
9
|
o(this, "_callerName");
|
|
@@ -11,7 +11,7 @@ class b {
|
|
|
11
11
|
this.tagName = t, this.params = s;
|
|
12
12
|
}
|
|
13
13
|
get hash() {
|
|
14
|
-
return
|
|
14
|
+
return N(this.params.base || this.params);
|
|
15
15
|
}
|
|
16
16
|
get priority() {
|
|
17
17
|
var t;
|
|
@@ -29,27 +29,29 @@ class b {
|
|
|
29
29
|
}
|
|
30
30
|
get templateKeys() {
|
|
31
31
|
var t;
|
|
32
|
-
return (t = this._context) != null && t.config.templates ?
|
|
32
|
+
return (t = this._context) != null && t.config.templates ? _(this._context.config.templates) : [];
|
|
33
33
|
}
|
|
34
34
|
get css() {
|
|
35
|
-
var
|
|
36
|
-
const { base: t = {}, variants: s = {}, compoundVariants:
|
|
37
|
-
return
|
|
35
|
+
var n;
|
|
36
|
+
const { base: t = {}, variants: s = {}, compoundVariants: i = [] } = this.params, r = { ...t, variants: s, compoundVariants: i };
|
|
37
|
+
return x(r, `.${this.cssClassName}`, this.priority, (n = this._context) == null ? void 0 : n.config);
|
|
38
38
|
}
|
|
39
39
|
get props() {
|
|
40
|
-
const { element: t, variants: s = {}, compoundVariants:
|
|
41
|
-
const
|
|
42
|
-
|
|
40
|
+
const { element: t, variants: s = {}, compoundVariants: i = [], defaultVariants: r = {}, defaultProps: n = {}, passProps: u } = this.params, c = /* @__PURE__ */ new Set([]), h = (a) => {
|
|
41
|
+
const p = r[a];
|
|
42
|
+
p !== void 0 ? c.add(`${a}=${String(p)}`) : c.add(a);
|
|
43
43
|
};
|
|
44
|
-
Object.keys(s).forEach(h),
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
-
const
|
|
48
|
-
|
|
44
|
+
Object.keys(s).forEach(h), i.map((a) => Object.keys(a).forEach(h));
|
|
45
|
+
const m = /* @__PURE__ */ new Set([]), l = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
|
|
46
|
+
return l && l.forEach((a, p, f) => {
|
|
47
|
+
const d = f.at(1);
|
|
48
|
+
d && m.add(d);
|
|
49
49
|
}), {
|
|
50
50
|
element: t,
|
|
51
|
-
variantKeys: [...
|
|
52
|
-
propValueKeys: [...
|
|
51
|
+
variantKeys: [...c],
|
|
52
|
+
propValueKeys: [...m],
|
|
53
|
+
passProps: u,
|
|
54
|
+
defaultProps: n,
|
|
53
55
|
attr: {
|
|
54
56
|
"data-component-name": this._isProd ? void 0 : this._callerName
|
|
55
57
|
}
|
|
@@ -57,10 +59,10 @@ class b {
|
|
|
57
59
|
}
|
|
58
60
|
_withBuildContext(t) {
|
|
59
61
|
this._context = t;
|
|
60
|
-
const { name: s, config:
|
|
61
|
-
return this._isProd =
|
|
62
|
+
const { name: s, config: i, prod: r } = t;
|
|
63
|
+
return this._isProd = r, this._callerName = s, this;
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
export {
|
|
65
|
-
|
|
67
|
+
K as StyleComponentGenerator
|
|
66
68
|
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import * as G from "esbuild";
|
|
2
|
+
import { execSync as tt } from "child_process";
|
|
3
|
+
import { t as A, d as K } from "./dash-case-D_tXuO4I.js";
|
|
4
|
+
import { join as r, parse as et } from "path";
|
|
5
|
+
import { existsSync as B, writeFileSync as x, mkdirSync as N, readFileSync as V, statSync as st, readdirSync as nt } from "fs";
|
|
6
|
+
import { readFile as ot, writeFile as rt } from "fs/promises";
|
|
7
|
+
import { p as at, a as ct, b as it, c as lt } from "./parse-templates-D1FebDfR.js";
|
|
8
|
+
import { createLogger as pt, format as J, transports as ft } from "winston";
|
|
9
|
+
const W = (t) => {
|
|
10
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
|
11
|
+
const e = r(t, "package.json");
|
|
12
|
+
return B(e) ? e : W(r(t, ".."));
|
|
13
|
+
}, ut = async (t) => {
|
|
14
|
+
const e = W(t);
|
|
15
|
+
return await ot(e, "utf-8").then(JSON.parse).catch(() => {
|
|
16
|
+
});
|
|
17
|
+
}, dt = async (t) => {
|
|
18
|
+
const e = await ut(t);
|
|
19
|
+
if (e)
|
|
20
|
+
return e.type;
|
|
21
|
+
};
|
|
22
|
+
let E;
|
|
23
|
+
const H = async (t) => {
|
|
24
|
+
if (E) return E;
|
|
25
|
+
const e = await dt(t);
|
|
26
|
+
return e === "module" ? E = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (E = "cjs"), E || "esm";
|
|
27
|
+
}, R = pt({
|
|
28
|
+
level: "debug",
|
|
29
|
+
format: J.combine(J.colorize(), J.cli()),
|
|
30
|
+
transports: [new ft.Console({})]
|
|
31
|
+
}), Ft = (t) => {
|
|
32
|
+
R.error(t);
|
|
33
|
+
};
|
|
34
|
+
function L(t) {
|
|
35
|
+
return t ? typeof t != "string" ? L(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 O = {
|
|
38
|
+
externalModules: []
|
|
39
|
+
}, q = (t) => {
|
|
40
|
+
if (O.externalModules.length > 0) return O.externalModules;
|
|
41
|
+
const e = r(t, "salty.config.ts"), s = V(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
|
42
|
+
if (!s) return [];
|
|
43
|
+
const n = s[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
|
|
44
|
+
return O.externalModules = n, n;
|
|
45
|
+
}, v = (t) => r(t, "./saltygen"), gt = ["salty", "css", "styles", "styled"], mt = (t = []) => new RegExp(`\\.(${[...gt, ...t].join("|")})\\.`), I = (t, e = []) => mt(e).test(t), yt = async (t) => {
|
|
46
|
+
const e = v(t), a = r(t, "salty.config.ts"), s = r(e, "salty.config.js"), n = await H(t), l = q(t);
|
|
47
|
+
await G.build({
|
|
48
|
+
entryPoints: [a],
|
|
49
|
+
minify: !0,
|
|
50
|
+
treeShaking: !0,
|
|
51
|
+
bundle: !0,
|
|
52
|
+
outfile: s,
|
|
53
|
+
format: n,
|
|
54
|
+
external: l
|
|
55
|
+
});
|
|
56
|
+
const b = Date.now(), { config: f } = await import(`${s}?t=${b}`);
|
|
57
|
+
return f;
|
|
58
|
+
}, ht = async (t) => {
|
|
59
|
+
const e = await yt(t), a = /* @__PURE__ */ new Set(), s = (i, p = []) => i ? Object.entries(i).flatMap(([g, u]) => {
|
|
60
|
+
if (!u) return;
|
|
61
|
+
if (typeof u == "object") return s(u, [...p, g]);
|
|
62
|
+
const F = L(g), y = K(g), h = [...p, F].join(".");
|
|
63
|
+
a.add(`"${h}"`);
|
|
64
|
+
const j = [...p.map(K), y].join("-"), { result: P } = lt(u);
|
|
65
|
+
return `--${j}: ${P};`;
|
|
66
|
+
}) : [], n = (i) => i ? Object.entries(i).flatMap(([p, g]) => {
|
|
67
|
+
const u = s(g);
|
|
68
|
+
return p === "base" ? u.join("") : `${p} { ${u.join("")} }`;
|
|
69
|
+
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, g]) => Object.entries(g).flatMap(([u, F]) => {
|
|
70
|
+
const y = s(F, [p]), h = `.${p}-${u}, [data-${p}="${u}"]`, j = y.join("");
|
|
71
|
+
return `${h} { ${j} }`;
|
|
72
|
+
})) : [], b = s(e.variables), f = n(e.responsiveVariables), $ = l(e.conditionalVariables), o = v(t), D = r(o, "css/variables.css"), d = `:root { ${b.join("")} ${f.join("")} } ${$.join("")}`;
|
|
73
|
+
x(D, d);
|
|
74
|
+
const w = r(o, "css/global.css"), S = at(e.global, "");
|
|
75
|
+
x(w, S);
|
|
76
|
+
const c = r(o, "css/templates.css"), m = ct(e.templates), k = it(e.templates);
|
|
77
|
+
x(c, m);
|
|
78
|
+
const C = r(o, "types/css-tokens.d.ts"), M = `
|
|
79
|
+
// Variable types
|
|
80
|
+
type VariableTokens = ${[...a].join("|")};
|
|
81
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
82
|
+
|
|
83
|
+
// Template types
|
|
84
|
+
type TemplateTokens = {
|
|
85
|
+
${Object.entries(k).map(([i, p]) => `${i}?: ${p}`).join(`
|
|
86
|
+
`)}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
x(C, M);
|
|
90
|
+
}, Z = async (t, e, a) => {
|
|
91
|
+
const s = A(e), n = r(a, "./temp");
|
|
92
|
+
B(n) || N(n);
|
|
93
|
+
const l = et(e);
|
|
94
|
+
let b = V(e, "utf8");
|
|
95
|
+
b = b.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
|
96
|
+
const f = r(a, "js", s + ".js"), $ = q(t), o = await H(t);
|
|
97
|
+
await G.build({
|
|
98
|
+
stdin: {
|
|
99
|
+
contents: b,
|
|
100
|
+
sourcefile: l.base,
|
|
101
|
+
resolveDir: l.dir,
|
|
102
|
+
loader: "tsx"
|
|
103
|
+
},
|
|
104
|
+
minify: !1,
|
|
105
|
+
treeShaking: !0,
|
|
106
|
+
bundle: !0,
|
|
107
|
+
outfile: f,
|
|
108
|
+
format: o,
|
|
109
|
+
target: ["node20"],
|
|
110
|
+
keepNames: !0,
|
|
111
|
+
external: $,
|
|
112
|
+
packages: "external"
|
|
113
|
+
});
|
|
114
|
+
const D = Date.now();
|
|
115
|
+
return await import(`${f}?t=${D}`);
|
|
116
|
+
}, _ = async (t) => {
|
|
117
|
+
const e = v(t), a = r(e, "salty.config.js"), { config: s } = await import(a);
|
|
118
|
+
return s;
|
|
119
|
+
}, U = () => {
|
|
120
|
+
try {
|
|
121
|
+
return process.env.NODE_ENV === "production";
|
|
122
|
+
} catch {
|
|
123
|
+
return !1;
|
|
124
|
+
}
|
|
125
|
+
}, kt = async (t, e = U()) => {
|
|
126
|
+
try {
|
|
127
|
+
e ? R.info("Generating CSS in production mode! 🔥") : R.info("Generating CSS in development mode! 🚀");
|
|
128
|
+
const a = [], s = [], n = v(t), l = r(n, "index.css");
|
|
129
|
+
(() => {
|
|
130
|
+
B(n) && tt("rm -rf " + n), N(n), N(r(n, "css")), N(r(n, "types"));
|
|
131
|
+
})(), await ht(t);
|
|
132
|
+
const f = await _(t);
|
|
133
|
+
async function $(c, m) {
|
|
134
|
+
const k = ["node_modules", "saltygen"], C = st(c);
|
|
135
|
+
if (C.isDirectory()) {
|
|
136
|
+
const T = nt(c);
|
|
137
|
+
if (k.some((i) => c.includes(i))) return;
|
|
138
|
+
await Promise.all(T.map((i) => $(r(c, i), r(m, i))));
|
|
139
|
+
} else if (C.isFile() && I(c)) {
|
|
140
|
+
const M = await Z(t, c, n), i = [];
|
|
141
|
+
Object.entries(M).forEach(([F, y]) => {
|
|
142
|
+
if (y.isKeyframes && y.css) {
|
|
143
|
+
const z = `${y.animationName}.css`, Y = `css/${z}`, Q = r(n, Y);
|
|
144
|
+
a.push(z), x(Q, y.css);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!y.generator) return;
|
|
148
|
+
const h = y.generator._withBuildContext({
|
|
149
|
+
name: F,
|
|
150
|
+
config: f,
|
|
151
|
+
prod: e
|
|
152
|
+
}), j = `${h.hash}-${h.priority}.css`;
|
|
153
|
+
s[h.priority] || (s[h.priority] = []), s[h.priority].push(j), i.push(j);
|
|
154
|
+
const P = `css/${j}`, X = r(n, P);
|
|
155
|
+
x(X, h.css);
|
|
156
|
+
});
|
|
157
|
+
const p = i.map((F) => `@import url('./${F}');`).join(`
|
|
158
|
+
`), g = A(c, 6), u = r(n, `css/${g}.css`);
|
|
159
|
+
x(u, p);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
await $(t, n);
|
|
163
|
+
const o = a.map((c) => `@import url('./css/${c}');`).join(`
|
|
164
|
+
`);
|
|
165
|
+
let S = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
166
|
+
|
|
167
|
+
${["variables.css", "global.css", "templates.css"].filter((c) => {
|
|
168
|
+
try {
|
|
169
|
+
return V(r(n, "css", c), "utf8").length > 0;
|
|
170
|
+
} catch {
|
|
171
|
+
return !1;
|
|
172
|
+
}
|
|
173
|
+
}).map((c) => `@import url('./css/${c}');`).join(`
|
|
174
|
+
`)}
|
|
175
|
+
${o}`;
|
|
176
|
+
if (f.importStrategy !== "component") {
|
|
177
|
+
const c = s.flat().map((m) => `@import url('./css/${m}');`).join(`
|
|
178
|
+
`);
|
|
179
|
+
S += c;
|
|
180
|
+
}
|
|
181
|
+
x(l, S);
|
|
182
|
+
} catch (a) {
|
|
183
|
+
console.error(a);
|
|
184
|
+
}
|
|
185
|
+
}, Tt = async (t, e) => {
|
|
186
|
+
try {
|
|
187
|
+
const a = [], s = r(t, "./saltygen"), n = r(s, "index.css");
|
|
188
|
+
if (I(e)) {
|
|
189
|
+
const b = await _(t), f = await Z(t, e, s);
|
|
190
|
+
Object.entries(f).forEach(([w, S]) => {
|
|
191
|
+
if (!S.generator) return;
|
|
192
|
+
const c = S.generator._withBuildContext({
|
|
193
|
+
name: w,
|
|
194
|
+
config: b
|
|
195
|
+
}), m = `${c.hash}-${c.priority}.css`, k = `css/${m}`, C = r(s, k);
|
|
196
|
+
a.push(m), x(C, c.css);
|
|
197
|
+
});
|
|
198
|
+
const $ = V(n, "utf8").split(`
|
|
199
|
+
`), o = a.map((w) => `@import url('../saltygen/css/${w}');`), d = [.../* @__PURE__ */ new Set([...$, ...o])].join(`
|
|
200
|
+
`);
|
|
201
|
+
x(n, d);
|
|
202
|
+
}
|
|
203
|
+
} catch (a) {
|
|
204
|
+
console.error(a);
|
|
205
|
+
}
|
|
206
|
+
}, Dt = async (t, e, a = U()) => {
|
|
207
|
+
try {
|
|
208
|
+
const s = r(t, "./saltygen");
|
|
209
|
+
if (I(e)) {
|
|
210
|
+
const l = V(e, "utf8");
|
|
211
|
+
l.replace(/^(?!export\s)const\s.*/gm, (d) => `export ${d}`) !== l && await rt(e, l);
|
|
212
|
+
const f = await _(t), $ = await Z(t, e, s);
|
|
213
|
+
let o = l;
|
|
214
|
+
Object.entries($).forEach(([d, w]) => {
|
|
215
|
+
var j;
|
|
216
|
+
if (w.isKeyframes || !w.generator) return;
|
|
217
|
+
const S = w.generator._withBuildContext({
|
|
218
|
+
name: d,
|
|
219
|
+
config: f,
|
|
220
|
+
prod: a
|
|
221
|
+
}), c = new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
|
|
222
|
+
if (!c) return console.error("Could not find the original declaration");
|
|
223
|
+
const m = (j = c.at(1)) == null ? void 0 : j.trim(), k = new RegExp(`\\s${d}[=\\s]+styled\\(`, "g").exec(o);
|
|
224
|
+
if (!k) return console.error("Could not find the original declaration");
|
|
225
|
+
const { index: C } = k;
|
|
226
|
+
let T = !1;
|
|
227
|
+
const M = setTimeout(() => T = !0, 5e3);
|
|
228
|
+
let i = 0, p = !1, g = 0;
|
|
229
|
+
for (; !p && !T; ) {
|
|
230
|
+
const P = o[C + i];
|
|
231
|
+
P === "(" && g++, P === ")" && g--, g === 0 && P === ")" && (p = !0), i > o.length && (T = !0), i++;
|
|
232
|
+
}
|
|
233
|
+
if (!T) clearTimeout(M);
|
|
234
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
|
235
|
+
const u = C + i, F = o.slice(C, u), y = o, h = ` ${d} = styled(${m}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
|
236
|
+
o = o.replace(F, h), y === o && console.error("Minimize file failed to change content", { name: d, tagName: m });
|
|
237
|
+
});
|
|
238
|
+
const D = A(e, 6);
|
|
239
|
+
return f.importStrategy === "component" && (o = `import '../../saltygen/css/${D}.css';
|
|
240
|
+
${o}`), o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
|
241
|
+
}
|
|
242
|
+
} catch (s) {
|
|
243
|
+
console.error("Error in minimizeFile:", s);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
export {
|
|
247
|
+
Ft as a,
|
|
248
|
+
mt as b,
|
|
249
|
+
ht as c,
|
|
250
|
+
Z as d,
|
|
251
|
+
Tt as e,
|
|
252
|
+
kt as g,
|
|
253
|
+
I as i,
|
|
254
|
+
R as l,
|
|
255
|
+
Dt as m,
|
|
256
|
+
gt as s
|
|
257
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const se=require("esbuild"),ne=require("child_process"),O=require("./dash-case-8PdMJjFC.cjs"),o=require("path"),a=require("fs"),B=require("fs/promises"),V=require("./parse-templates-lpgqU05M.cjs"),N=require("winston");var q=typeof document<"u"?document.currentScript:null;function oe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Z=oe(se),H=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return a.existsSync(t)?t:H(o.join(e,".."))},ie=async e=>{const t=H(e);return await B.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},re=async e=>{const t=await ie(e);if(t)return t.type};let M;const K=async e=>{if(M)return M;const t=await re(e);return t==="module"?M="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-eyW1pjj1.cjs",document.baseURI).href).endsWith(".cjs"))&&(M="cjs"),M||"esm"},v=N.createLogger({level:"debug",format:N.format.combine(N.format.colorize(),N.format.cli()),transports:[new N.transports.Console({})]}),ce=e=>{v.error(e)};function L(e){return e?typeof e!="string"?L(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 I={externalModules:[]},U=e=>{if(I.externalModules.length>0)return I.externalModules;const t=o.join(e,"salty.config.ts"),n=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(u=>u.replace(/['"`]/g,"").trim());return I.externalModules=i,i},R=e=>o.join(e,"./saltygen"),G=["salty","css","styles","styled"],W=(e=[])=>new RegExp(`\\.(${[...G,...e].join("|")})\\.`),_=(e,t=[])=>W(t).test(e),ae=async e=>{const t=R(e),s=o.join(e,"salty.config.ts"),n=o.join(t,"salty.config.js"),i=await K(e),u=U(e);await Z.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:u});const S=Date.now(),{config:f}=await import(`${n}?t=${S}`);return f},X=async e=>{const t=await ae(e),s=new Set,n=(l,p=[])=>l?Object.entries(l).flatMap(([y,d])=>{if(!d)return;if(typeof d=="object")return n(d,[...p,y]);const x=L(y),h=O.dashCase(y),j=[...p,x].join(".");s.add(`"${j}"`);const C=[...p.map(O.dashCase),h].join("-"),{result:D}=V.parseValueTokens(d);return`--${C}: ${D};`}):[],i=l=>l?Object.entries(l).flatMap(([p,y])=>{const d=n(y);return p==="base"?d.join(""):`${p} { ${d.join("")} }`}):[],u=l=>l?Object.entries(l).flatMap(([p,y])=>Object.entries(y).flatMap(([d,x])=>{const h=n(x,[p]),j=`.${p}-${d}, [data-${p}="${d}"]`,C=h.join("");return`${j} { ${C} }`})):[],S=n(t.variables),f=i(t.responsiveVariables),b=u(t.conditionalVariables),r=R(e),P=o.join(r,"css/variables.css"),g=`:root { ${S.join("")} ${f.join("")} } ${b.join("")}`;a.writeFileSync(P,g);const w=o.join(r,"css/global.css"),F=V.parseStyles(t.global,"");a.writeFileSync(w,F);const c=o.join(r,"css/templates.css"),m=V.parseTemplates(t.templates),k=V.getTemplateTypes(t.templates);a.writeFileSync(c,m);const $=o.join(r,"types/css-tokens.d.ts"),E=`
|
|
2
|
+
// Variable types
|
|
3
|
+
type VariableTokens = ${[...s].join("|")};
|
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
5
|
+
|
|
6
|
+
// Template types
|
|
7
|
+
type TemplateTokens = {
|
|
8
|
+
${Object.entries(k).map(([l,p])=>`${l}?: ${p}`).join(`
|
|
9
|
+
`)}
|
|
10
|
+
}
|
|
11
|
+
`;a.writeFileSync($,E)},J=async(e,t,s)=>{const n=O.toHash(t),i=o.join(s,"./temp");a.existsSync(i)||a.mkdirSync(i);const u=o.parse(t);let S=a.readFileSync(t,"utf8");S=S.replace(/styled\([^"'`{,]+,/g,"styled('div',");const f=o.join(s,"js",n+".js"),b=U(e),r=await K(e);await Z.build({stdin:{contents:S,sourcefile:u.base,resolveDir:u.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:f,format:r,target:["node20"],keepNames:!0,external:b,packages:"external"});const P=Date.now();return await import(`${f}?t=${P}`)},z=async e=>{const t=R(e),s=o.join(t,"salty.config.js"),{config:n}=await import(s);return n},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},le=async(e,t=Y())=>{try{t?v.info("Generating CSS in production mode! 🔥"):v.info("Generating CSS in development mode! 🚀");const s=[],n=[],i=R(e),u=o.join(i,"index.css");(()=>{a.existsSync(i)&&ne.execSync("rm -rf "+i),a.mkdirSync(i),a.mkdirSync(o.join(i,"css")),a.mkdirSync(o.join(i,"types"))})(),await X(e);const f=await z(e);async function b(c,m){const k=["node_modules","saltygen"],$=a.statSync(c);if($.isDirectory()){const T=a.readdirSync(c);if(k.some(l=>c.includes(l)))return;await Promise.all(T.map(l=>b(o.join(c,l),o.join(m,l))))}else if($.isFile()&&_(c)){const E=await J(e,c,i),l=[];Object.entries(E).forEach(([x,h])=>{if(h.isKeyframes&&h.css){const A=`${h.animationName}.css`,ee=`css/${A}`,te=o.join(i,ee);s.push(A),a.writeFileSync(te,h.css);return}if(!h.generator)return;const j=h.generator._withBuildContext({name:x,config:f,prod:t}),C=`${j.hash}-${j.priority}.css`;n[j.priority]||(n[j.priority]=[]),n[j.priority].push(C),l.push(C);const D=`css/${C}`,Q=o.join(i,D);a.writeFileSync(Q,j.css)});const p=l.map(x=>`@import url('./${x}');`).join(`
|
|
12
|
+
`),y=O.toHash(c,6),d=o.join(i,`css/${y}.css`);a.writeFileSync(d,p)}}await b(e,i);const r=s.map(c=>`@import url('./css/${c}');`).join(`
|
|
13
|
+
`);let F=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
14
|
+
|
|
15
|
+
${["variables.css","global.css","templates.css"].filter(c=>{try{return a.readFileSync(o.join(i,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
|
|
16
|
+
`)}
|
|
17
|
+
${r}`;if(f.importStrategy!=="component"){const c=n.flat().map(m=>`@import url('./css/${m}');`).join(`
|
|
18
|
+
`);F+=c}a.writeFileSync(u,F)}catch(s){console.error(s)}},ue=async(e,t)=>{try{const s=[],n=o.join(e,"./saltygen"),i=o.join(n,"index.css");if(_(t)){const S=await z(e),f=await J(e,t,n);Object.entries(f).forEach(([w,F])=>{if(!F.generator)return;const c=F.generator._withBuildContext({name:w,config:S}),m=`${c.hash}-${c.priority}.css`,k=`css/${m}`,$=o.join(n,k);s.push(m),a.writeFileSync($,c.css)});const b=a.readFileSync(i,"utf8").split(`
|
|
19
|
+
`),r=s.map(w=>`@import url('../saltygen/css/${w}');`),g=[...new Set([...b,...r])].join(`
|
|
20
|
+
`);a.writeFileSync(i,g)}}catch(s){console.error(s)}},pe=async(e,t,s=Y())=>{try{const n=o.join(e,"./saltygen");if(_(t)){const u=a.readFileSync(t,"utf8");u.replace(/^(?!export\s)const\s.*/gm,g=>`export ${g}`)!==u&&await B.writeFile(t,u);const f=await z(e),b=await J(e,t,n);let r=u;Object.entries(b).forEach(([g,w])=>{var C;if(w.isKeyframes||!w.generator)return;const F=w.generator._withBuildContext({name:g,config:f,prod:s}),c=new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(u);if(!c)return console.error("Could not find the original declaration");const m=(C=c.at(1))==null?void 0:C.trim(),k=new RegExp(`\\s${g}[=\\s]+styled\\(`,"g").exec(r);if(!k)return console.error("Could not find the original declaration");const{index:$}=k;let T=!1;const E=setTimeout(()=>T=!0,5e3);let l=0,p=!1,y=0;for(;!p&&!T;){const D=r[$+l];D==="("&&y++,D===")"&&y--,y===0&&D===")"&&(p=!0),l>r.length&&(T=!0),l++}if(!T)clearTimeout(E);else throw new Error("Failed to find the end of the styled call and timed out");const d=$+l,x=r.slice($,d),h=r,j=` ${g} = styled(${m}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(x,j),h===r&&console.error("Minimize file failed to change content",{name:g,tagName:m})});const P=O.toHash(t,6);return f.importStrategy==="component"&&(r=`import '../../saltygen/css/${P}.css';
|
|
21
|
+
${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.compileSaltyFile=J;exports.generateConfigStyles=X;exports.generateCss=le;exports.generateFile=ue;exports.isSaltyFile=_;exports.logError=ce;exports.logger=v;exports.minimizeFile=pe;exports.saltyFileExtensions=G;exports.saltyFileRegExp=W;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const T=require("./dash-case-
|
|
1
|
+
"use strict";const T=require("./dash-case-8PdMJjFC.cjs"),N=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const r=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:i}=n;t=t.replace(o,d=>{const{value:c,css:j}=i(d);return j&&r.push(j),c})}),{result:t,additionalCss:r}},S=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${T.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},a=(t,e,r,n)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((c,[j,s])=>{const p=j.trim();if(typeof s=="function"&&(s=s()),typeof s=="object"){if(!s)return c;if(p==="variants")return Object.entries(s).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,m])=>{if(!m)return;const y=`${e}.${f}-${l}`,b=a(m,y,r);o.push(b)})}),c;if(p==="defaultVariants")return c;if(p==="compoundVariants")return s.forEach(f=>{const{css:u,...l}=f,m=Object.entries(l).reduce((b,[q,K])=>`${b}.${q}-${K}`,e),y=a(u,m,r);o.push(y)}),c;if(p.startsWith("@")){const f=a(s,e,r),u=`${p} {
|
|
2
2
|
${f.replace(`
|
|
3
3
|
`,`
|
|
4
4
|
`)}
|
package/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type CreateElementProps = {
|
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
className?: string;
|
|
9
9
|
element?: string;
|
|
10
|
-
|
|
10
|
+
passProps?: boolean | string | string[];
|
|
11
11
|
style?: CssProperties | {
|
|
12
12
|
[key: string]: PropertyValueToken | NeverObj;
|
|
13
13
|
};
|
|
@@ -74,6 +74,8 @@ export interface GeneratorOptions {
|
|
|
74
74
|
className?: string;
|
|
75
75
|
displayName?: string;
|
|
76
76
|
element?: string;
|
|
77
|
+
passProps?: boolean | string | string[];
|
|
78
|
+
defaultProps?: Record<PropertyKey, unknown>;
|
|
77
79
|
}
|
|
78
80
|
interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens {
|
|
79
81
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dotCase(str: PropertyKey): string;
|
package/util/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-8PdMJjFC.cjs"),t=require("../pascal-case-iWoaJWwT.cjs");function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/-([a-z])/g,r=>r[1].toUpperCase()):""}exports.dashCase=a.dashCase;exports.toHash=a.toHash;exports.pascalCase=t.pascalCase;exports.camelCase=s;
|
package/util/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as o, t as s } from "../dash-case-
|
|
1
|
+
import { d as o, t as s } from "../dash-case-D_tXuO4I.js";
|
|
2
2
|
import { p as f } from "../pascal-case-BQpR5PdN.js";
|
|
3
3
|
function r(e) {
|
|
4
4
|
return e ? typeof e != "string" ? r(String(e)) : e.replace(/\s/g, "-").replace(/-([a-z])/g, (a) => a[1].toUpperCase()) : "";
|
package/index-DckDeOOE.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";const te=require("esbuild"),se=require("child_process"),O=require("./dash-case-DKzpenwY.cjs"),o=require("path"),a=require("fs"),H=require("fs/promises"),V=require("./parse-templates-C1-wQz7G.cjs"),N=require("winston");var q=typeof document<"u"?document.currentScript:null;function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=ne(te),G=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return a.existsSync(t)?t:G(o.join(e,".."))},oe=async e=>{const t=G(e);return await H.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await oe(e);if(t)return t.type};let E;const L=async e=>{if(E)return E;const t=await ie(e);return t==="module"?E="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:q&&q.tagName.toUpperCase()==="SCRIPT"&&q.src||new URL("index-DckDeOOE.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},v=N.createLogger({level:"debug",format:N.format.combine(N.format.colorize(),N.format.cli()),transports:[new N.transports.Console({})]}),re=e=>{v.error(e)},I={externalModules:[]},W=e=>{if(I.externalModules.length>0)return I.externalModules;const t=o.join(e,"salty.config.ts"),s=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const i=s[1].split(",").map(u=>u.replace(/['"`]/g,"").trim());return I.externalModules=i,i},R=e=>o.join(e,"./saltygen"),K=["salty","css","styles","styled"],A=(e=[])=>new RegExp(`\\.(${[...K,...e].join("|")})\\.`),_=(e,t=[])=>A(t).test(e),ce=async e=>{const t=R(e),n=o.join(e,"salty.config.ts"),s=o.join(t,"salty.config.js"),i=await L(e),u=W(e);await U.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:i,external:u});const S=Date.now(),{config:f}=await import(`${s}?t=${S}`);return f},X=async e=>{const t=await ce(e),n=new Set,s=(l,p=[])=>l?Object.entries(l).flatMap(([g,d])=>{if(!d)return;if(typeof d=="object")return s(d,[...p,g]);const C=[...p,g].join(".");n.add(`"${C}"`);const h=[...p.map(O.dashCase),O.dashCase(g)].join("-"),{result:j}=V.parseValueTokens(d);return`--${h}: ${j};`}):[],i=l=>l?Object.entries(l).flatMap(([p,g])=>{const d=s(g);return p==="base"?d.join(""):`${p} { ${d.join("")} }`}):[],u=l=>l?Object.entries(l).flatMap(([p,g])=>Object.entries(g).flatMap(([d,C])=>{const h=s(C,[p]),j=`.${p}-${d}, [data-${p}="${d}"]`,T=h.join("");return`${j} { ${T} }`})):[],S=s(t.variables),f=i(t.responsiveVariables),b=u(t.conditionalVariables),r=R(e),P=o.join(r,"css/variables.css"),y=`:root { ${S.join("")} ${f.join("")} } ${b.join("")}`;a.writeFileSync(P,y);const w=o.join(r,"css/global.css"),F=V.parseStyles(t.global,"");a.writeFileSync(w,F);const c=o.join(r,"css/templates.css"),m=V.parseTemplates(t.templates),x=V.getTemplateTypes(t.templates);a.writeFileSync(c,m);const $=o.join(r,"types/css-tokens.d.ts"),D=`
|
|
2
|
-
// Variable types
|
|
3
|
-
type VariableTokens = ${[...n].join("|")};
|
|
4
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
5
|
-
|
|
6
|
-
// Template types
|
|
7
|
-
type TemplateTokens = {
|
|
8
|
-
${Object.entries(x).map(([l,p])=>`${l}?: ${p}`).join(`
|
|
9
|
-
`)}
|
|
10
|
-
}
|
|
11
|
-
`;a.writeFileSync($,D)},J=async(e,t,n)=>{const s=O.toHash(t),i=o.join(n,"./temp");a.existsSync(i)||a.mkdirSync(i);const u=o.parse(t);let S=a.readFileSync(t,"utf8");S=S.replace(/styled\([^"'`{,]+,/g,"styled('div',");const f=o.join(n,"js",s+".js"),b=W(e),r=await L(e);await U.build({stdin:{contents:S,sourcefile:u.base,resolveDir:u.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:f,format:r,target:["node20"],keepNames:!0,external:b,packages:"external"});const P=Date.now();return await import(`${f}?t=${P}`)},z=async e=>{const t=R(e),n=o.join(t,"salty.config.js"),{config:s}=await import(n);return s},Y=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(e,t=Y())=>{try{t?v.info("Generating CSS in production mode! 🔥"):v.info("Generating CSS in development mode! 🚀");const n=[],s=[],i=R(e),u=o.join(i,"index.css");(()=>{a.existsSync(i)&&se.execSync("rm -rf "+i),a.mkdirSync(i),a.mkdirSync(o.join(i,"css")),a.mkdirSync(o.join(i,"types"))})(),await X(e);const f=await z(e);async function b(c,m){const x=["node_modules","saltygen"],$=a.statSync(c);if($.isDirectory()){const k=a.readdirSync(c);if(x.some(l=>c.includes(l)))return;await Promise.all(k.map(l=>b(o.join(c,l),o.join(m,l))))}else if($.isFile()&&_(c)){const D=await J(e,c,i),l=[];Object.entries(D).forEach(([C,h])=>{if(h.isKeyframes&&h.css){const B=`${h.animationName}.css`,Q=`css/${B}`,ee=o.join(i,Q);n.push(B),a.writeFileSync(ee,h.css);return}if(!h.generator)return;const j=h.generator._withBuildContext({name:C,config:f,prod:t}),T=`${j.hash}-${j.priority}.css`;s[j.priority]||(s[j.priority]=[]),s[j.priority].push(T),l.push(T);const M=`css/${T}`,Z=o.join(i,M);a.writeFileSync(Z,j.css)});const p=l.map(C=>`@import url('./${C}');`).join(`
|
|
12
|
-
`),g=O.toHash(c,6),d=o.join(i,`css/${g}.css`);a.writeFileSync(d,p)}}await b(e,i);const r=n.map(c=>`@import url('./css/${c}');`).join(`
|
|
13
|
-
`);let F=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
14
|
-
|
|
15
|
-
${["variables.css","global.css","templates.css"].filter(c=>{try{return a.readFileSync(o.join(i,"css",c),"utf8").length>0}catch{return!1}}).map(c=>`@import url('./css/${c}');`).join(`
|
|
16
|
-
`)}
|
|
17
|
-
${r}`;if(f.importStrategy!=="component"){const c=s.flat().map(m=>`@import url('./css/${m}');`).join(`
|
|
18
|
-
`);F+=c}a.writeFileSync(u,F)}catch(n){console.error(n)}},le=async(e,t)=>{try{const n=[],s=o.join(e,"./saltygen"),i=o.join(s,"index.css");if(_(t)){const S=await z(e),f=await J(e,t,s);Object.entries(f).forEach(([w,F])=>{if(!F.generator)return;const c=F.generator._withBuildContext({name:w,config:S}),m=`${c.hash}-${c.priority}.css`,x=`css/${m}`,$=o.join(s,x);n.push(m),a.writeFileSync($,c.css)});const b=a.readFileSync(i,"utf8").split(`
|
|
19
|
-
`),r=n.map(w=>`@import url('../saltygen/css/${w}');`),y=[...new Set([...b,...r])].join(`
|
|
20
|
-
`);a.writeFileSync(i,y)}}catch(n){console.error(n)}},ue=async(e,t,n=Y())=>{try{const s=o.join(e,"./saltygen");if(_(t)){const u=a.readFileSync(t,"utf8");u.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==u&&await H.writeFile(t,u);const f=await z(e),b=await J(e,t,s);let r=u;Object.entries(b).forEach(([y,w])=>{var T;if(w.isKeyframes||!w.generator)return;const F=w.generator._withBuildContext({name:y,config:f,prod:n}),c=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(u);if(!c)return console.error("Could not find the original declaration");const m=(T=c.at(1))==null?void 0:T.trim(),x=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(r);if(!x)return console.error("Could not find the original declaration");const{index:$}=x;let k=!1;const D=setTimeout(()=>k=!0,5e3);let l=0,p=!1,g=0;for(;!p&&!k;){const M=r[$+l];M==="("&&g++,M===")"&&g--,g===0&&M===")"&&(p=!0),l>r.length&&(k=!0),l++}if(!k)clearTimeout(D);else throw new Error("Failed to find the end of the styled call and timed out");const d=$+l,C=r.slice($,d),h=r,j=` ${y} = styled(${m}, "${F.classNames}", ${JSON.stringify(F.props)});`;r=r.replace(C,j),h===r&&console.error("Minimize file failed to change content",{name:y,tagName:m})});const P=O.toHash(t,6);return f.importStrategy==="component"&&(r=`import '../../saltygen/css/${P}.css';
|
|
21
|
-
${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(s){console.error("Error in minimizeFile:",s)}};exports.compileSaltyFile=J;exports.generateConfigStyles=X;exports.generateCss=ae;exports.generateFile=le;exports.isSaltyFile=_;exports.logError=re;exports.logger=v;exports.minimizeFile=ue;exports.saltyFileExtensions=K;exports.saltyFileRegExp=A;
|
package/index-PIN4uCyt.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import * as K from "esbuild";
|
|
2
|
-
import { execSync as Q } from "child_process";
|
|
3
|
-
import { t as B, d as H } from "./dash-case-DMQMcCO6.js";
|
|
4
|
-
import { join as a, parse as tt } from "path";
|
|
5
|
-
import { existsSync as I, writeFileSync as x, mkdirSync as N, readFileSync as V, statSync as et, readdirSync as st } from "fs";
|
|
6
|
-
import { readFile as nt, writeFile as ot } from "fs/promises";
|
|
7
|
-
import { p as at, a as rt, b as ct, c as it } from "./parse-templates-wUig7ACb.js";
|
|
8
|
-
import { createLogger as lt, format as J, transports as pt } from "winston";
|
|
9
|
-
const L = (t) => {
|
|
10
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
|
11
|
-
const e = a(t, "package.json");
|
|
12
|
-
return I(e) ? e : L(a(t, ".."));
|
|
13
|
-
}, ft = async (t) => {
|
|
14
|
-
const e = L(t);
|
|
15
|
-
return await nt(e, "utf-8").then(JSON.parse).catch(() => {
|
|
16
|
-
});
|
|
17
|
-
}, ut = async (t) => {
|
|
18
|
-
const e = await ft(t);
|
|
19
|
-
if (e)
|
|
20
|
-
return e.type;
|
|
21
|
-
};
|
|
22
|
-
let M;
|
|
23
|
-
const q = async (t) => {
|
|
24
|
-
if (M) return M;
|
|
25
|
-
const e = await ut(t);
|
|
26
|
-
return e === "module" ? M = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
|
|
27
|
-
}, R = lt({
|
|
28
|
-
level: "debug",
|
|
29
|
-
format: J.combine(J.colorize(), J.cli()),
|
|
30
|
-
transports: [new pt.Console({})]
|
|
31
|
-
}), Ct = (t) => {
|
|
32
|
-
R.error(t);
|
|
33
|
-
}, O = {
|
|
34
|
-
externalModules: []
|
|
35
|
-
}, A = (t) => {
|
|
36
|
-
if (O.externalModules.length > 0) return O.externalModules;
|
|
37
|
-
const e = a(t, "salty.config.ts"), s = V(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
|
38
|
-
if (!s) return [];
|
|
39
|
-
const n = s[1].split(",").map((l) => l.replace(/['"`]/g, "").trim());
|
|
40
|
-
return O.externalModules = n, n;
|
|
41
|
-
}, v = (t) => a(t, "./saltygen"), gt = ["salty", "css", "styles", "styled"], dt = (t = []) => new RegExp(`\\.(${[...gt, ...t].join("|")})\\.`), _ = (t, e = []) => dt(e).test(t), mt = async (t) => {
|
|
42
|
-
const e = v(t), c = a(t, "salty.config.ts"), s = a(e, "salty.config.js"), n = await q(t), l = A(t);
|
|
43
|
-
await K.build({
|
|
44
|
-
entryPoints: [c],
|
|
45
|
-
minify: !0,
|
|
46
|
-
treeShaking: !0,
|
|
47
|
-
bundle: !0,
|
|
48
|
-
outfile: s,
|
|
49
|
-
format: n,
|
|
50
|
-
external: l
|
|
51
|
-
});
|
|
52
|
-
const b = Date.now(), { config: f } = await import(`${s}?t=${b}`);
|
|
53
|
-
return f;
|
|
54
|
-
}, yt = async (t) => {
|
|
55
|
-
const e = await mt(t), c = /* @__PURE__ */ new Set(), s = (i, p = []) => i ? Object.entries(i).flatMap(([d, u]) => {
|
|
56
|
-
if (!u) return;
|
|
57
|
-
if (typeof u == "object") return s(u, [...p, d]);
|
|
58
|
-
const C = [...p, d].join(".");
|
|
59
|
-
c.add(`"${C}"`);
|
|
60
|
-
const y = [...p.map(H), H(d)].join("-"), { result: h } = it(u);
|
|
61
|
-
return `--${y}: ${h};`;
|
|
62
|
-
}) : [], n = (i) => i ? Object.entries(i).flatMap(([p, d]) => {
|
|
63
|
-
const u = s(d);
|
|
64
|
-
return p === "base" ? u.join("") : `${p} { ${u.join("")} }`;
|
|
65
|
-
}) : [], l = (i) => i ? Object.entries(i).flatMap(([p, d]) => Object.entries(d).flatMap(([u, C]) => {
|
|
66
|
-
const y = s(C, [p]), h = `.${p}-${u}, [data-${p}="${u}"]`, T = y.join("");
|
|
67
|
-
return `${h} { ${T} }`;
|
|
68
|
-
})) : [], b = s(e.variables), f = n(e.responsiveVariables), $ = l(e.conditionalVariables), o = v(t), D = a(o, "css/variables.css"), g = `:root { ${b.join("")} ${f.join("")} } ${$.join("")}`;
|
|
69
|
-
x(D, g);
|
|
70
|
-
const w = a(o, "css/global.css"), S = at(e.global, "");
|
|
71
|
-
x(w, S);
|
|
72
|
-
const r = a(o, "css/templates.css"), m = rt(e.templates), F = ct(e.templates);
|
|
73
|
-
x(r, m);
|
|
74
|
-
const j = a(o, "types/css-tokens.d.ts"), P = `
|
|
75
|
-
// Variable types
|
|
76
|
-
type VariableTokens = ${[...c].join("|")};
|
|
77
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
|
78
|
-
|
|
79
|
-
// Template types
|
|
80
|
-
type TemplateTokens = {
|
|
81
|
-
${Object.entries(F).map(([i, p]) => `${i}?: ${p}`).join(`
|
|
82
|
-
`)}
|
|
83
|
-
}
|
|
84
|
-
`;
|
|
85
|
-
x(j, P);
|
|
86
|
-
}, z = async (t, e, c) => {
|
|
87
|
-
const s = B(e), n = a(c, "./temp");
|
|
88
|
-
I(n) || N(n);
|
|
89
|
-
const l = tt(e);
|
|
90
|
-
let b = V(e, "utf8");
|
|
91
|
-
b = b.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
|
92
|
-
const f = a(c, "js", s + ".js"), $ = A(t), o = await q(t);
|
|
93
|
-
await K.build({
|
|
94
|
-
stdin: {
|
|
95
|
-
contents: b,
|
|
96
|
-
sourcefile: l.base,
|
|
97
|
-
resolveDir: l.dir,
|
|
98
|
-
loader: "tsx"
|
|
99
|
-
},
|
|
100
|
-
minify: !1,
|
|
101
|
-
treeShaking: !0,
|
|
102
|
-
bundle: !0,
|
|
103
|
-
outfile: f,
|
|
104
|
-
format: o,
|
|
105
|
-
target: ["node20"],
|
|
106
|
-
keepNames: !0,
|
|
107
|
-
external: $,
|
|
108
|
-
packages: "external"
|
|
109
|
-
});
|
|
110
|
-
const D = Date.now();
|
|
111
|
-
return await import(`${f}?t=${D}`);
|
|
112
|
-
}, G = async (t) => {
|
|
113
|
-
const e = v(t), c = a(e, "salty.config.js"), { config: s } = await import(c);
|
|
114
|
-
return s;
|
|
115
|
-
}, U = () => {
|
|
116
|
-
try {
|
|
117
|
-
return process.env.NODE_ENV === "production";
|
|
118
|
-
} catch {
|
|
119
|
-
return !1;
|
|
120
|
-
}
|
|
121
|
-
}, Ft = async (t, e = U()) => {
|
|
122
|
-
try {
|
|
123
|
-
e ? R.info("Generating CSS in production mode! 🔥") : R.info("Generating CSS in development mode! 🚀");
|
|
124
|
-
const c = [], s = [], n = v(t), l = a(n, "index.css");
|
|
125
|
-
(() => {
|
|
126
|
-
I(n) && Q("rm -rf " + n), N(n), N(a(n, "css")), N(a(n, "types"));
|
|
127
|
-
})(), await yt(t);
|
|
128
|
-
const f = await G(t);
|
|
129
|
-
async function $(r, m) {
|
|
130
|
-
const F = ["node_modules", "saltygen"], j = et(r);
|
|
131
|
-
if (j.isDirectory()) {
|
|
132
|
-
const k = st(r);
|
|
133
|
-
if (F.some((i) => r.includes(i))) return;
|
|
134
|
-
await Promise.all(k.map((i) => $(a(r, i), a(m, i))));
|
|
135
|
-
} else if (j.isFile() && _(r)) {
|
|
136
|
-
const P = await z(t, r, n), i = [];
|
|
137
|
-
Object.entries(P).forEach(([C, y]) => {
|
|
138
|
-
if (y.isKeyframes && y.css) {
|
|
139
|
-
const W = `${y.animationName}.css`, Y = `css/${W}`, Z = a(n, Y);
|
|
140
|
-
c.push(W), x(Z, y.css);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (!y.generator) return;
|
|
144
|
-
const h = y.generator._withBuildContext({
|
|
145
|
-
name: C,
|
|
146
|
-
config: f,
|
|
147
|
-
prod: e
|
|
148
|
-
}), T = `${h.hash}-${h.priority}.css`;
|
|
149
|
-
s[h.priority] || (s[h.priority] = []), s[h.priority].push(T), i.push(T);
|
|
150
|
-
const E = `css/${T}`, X = a(n, E);
|
|
151
|
-
x(X, h.css);
|
|
152
|
-
});
|
|
153
|
-
const p = i.map((C) => `@import url('./${C}');`).join(`
|
|
154
|
-
`), d = B(r, 6), u = a(n, `css/${d}.css`);
|
|
155
|
-
x(u, p);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
await $(t, n);
|
|
159
|
-
const o = c.map((r) => `@import url('./css/${r}');`).join(`
|
|
160
|
-
`);
|
|
161
|
-
let S = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
162
|
-
|
|
163
|
-
${["variables.css", "global.css", "templates.css"].filter((r) => {
|
|
164
|
-
try {
|
|
165
|
-
return V(a(n, "css", r), "utf8").length > 0;
|
|
166
|
-
} catch {
|
|
167
|
-
return !1;
|
|
168
|
-
}
|
|
169
|
-
}).map((r) => `@import url('./css/${r}');`).join(`
|
|
170
|
-
`)}
|
|
171
|
-
${o}`;
|
|
172
|
-
if (f.importStrategy !== "component") {
|
|
173
|
-
const r = s.flat().map((m) => `@import url('./css/${m}');`).join(`
|
|
174
|
-
`);
|
|
175
|
-
S += r;
|
|
176
|
-
}
|
|
177
|
-
x(l, S);
|
|
178
|
-
} catch (c) {
|
|
179
|
-
console.error(c);
|
|
180
|
-
}
|
|
181
|
-
}, kt = async (t, e) => {
|
|
182
|
-
try {
|
|
183
|
-
const c = [], s = a(t, "./saltygen"), n = a(s, "index.css");
|
|
184
|
-
if (_(e)) {
|
|
185
|
-
const b = await G(t), f = await z(t, e, s);
|
|
186
|
-
Object.entries(f).forEach(([w, S]) => {
|
|
187
|
-
if (!S.generator) return;
|
|
188
|
-
const r = S.generator._withBuildContext({
|
|
189
|
-
name: w,
|
|
190
|
-
config: b
|
|
191
|
-
}), m = `${r.hash}-${r.priority}.css`, F = `css/${m}`, j = a(s, F);
|
|
192
|
-
c.push(m), x(j, r.css);
|
|
193
|
-
});
|
|
194
|
-
const $ = V(n, "utf8").split(`
|
|
195
|
-
`), o = c.map((w) => `@import url('../saltygen/css/${w}');`), g = [.../* @__PURE__ */ new Set([...$, ...o])].join(`
|
|
196
|
-
`);
|
|
197
|
-
x(n, g);
|
|
198
|
-
}
|
|
199
|
-
} catch (c) {
|
|
200
|
-
console.error(c);
|
|
201
|
-
}
|
|
202
|
-
}, Tt = async (t, e, c = U()) => {
|
|
203
|
-
try {
|
|
204
|
-
const s = a(t, "./saltygen");
|
|
205
|
-
if (_(e)) {
|
|
206
|
-
const l = V(e, "utf8");
|
|
207
|
-
l.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== l && await ot(e, l);
|
|
208
|
-
const f = await G(t), $ = await z(t, e, s);
|
|
209
|
-
let o = l;
|
|
210
|
-
Object.entries($).forEach(([g, w]) => {
|
|
211
|
-
var T;
|
|
212
|
-
if (w.isKeyframes || !w.generator) return;
|
|
213
|
-
const S = w.generator._withBuildContext({
|
|
214
|
-
name: g,
|
|
215
|
-
config: f,
|
|
216
|
-
prod: c
|
|
217
|
-
}), r = new RegExp(`\\s${g}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(l);
|
|
218
|
-
if (!r) return console.error("Could not find the original declaration");
|
|
219
|
-
const m = (T = r.at(1)) == null ? void 0 : T.trim(), F = new RegExp(`\\s${g}[=\\s]+styled\\(`, "g").exec(o);
|
|
220
|
-
if (!F) return console.error("Could not find the original declaration");
|
|
221
|
-
const { index: j } = F;
|
|
222
|
-
let k = !1;
|
|
223
|
-
const P = setTimeout(() => k = !0, 5e3);
|
|
224
|
-
let i = 0, p = !1, d = 0;
|
|
225
|
-
for (; !p && !k; ) {
|
|
226
|
-
const E = o[j + i];
|
|
227
|
-
E === "(" && d++, E === ")" && d--, d === 0 && E === ")" && (p = !0), i > o.length && (k = !0), i++;
|
|
228
|
-
}
|
|
229
|
-
if (!k) clearTimeout(P);
|
|
230
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
|
231
|
-
const u = j + i, C = o.slice(j, u), y = o, h = ` ${g} = styled(${m}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
|
232
|
-
o = o.replace(C, h), y === o && console.error("Minimize file failed to change content", { name: g, tagName: m });
|
|
233
|
-
});
|
|
234
|
-
const D = B(e, 6);
|
|
235
|
-
return f.importStrategy === "component" && (o = `import '../../saltygen/css/${D}.css';
|
|
236
|
-
${o}`), o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
|
237
|
-
}
|
|
238
|
-
} catch (s) {
|
|
239
|
-
console.error("Error in minimizeFile:", s);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
export {
|
|
243
|
-
Ct as a,
|
|
244
|
-
dt as b,
|
|
245
|
-
yt as c,
|
|
246
|
-
z as d,
|
|
247
|
-
kt as e,
|
|
248
|
-
Ft as g,
|
|
249
|
-
_ as i,
|
|
250
|
-
R as l,
|
|
251
|
-
Tt as m,
|
|
252
|
-
gt as s
|
|
253
|
-
};
|