@salty-css/core 0.0.1-alpha.104 → 0.0.1-alpha.106

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