@salty-css/core 0.0.1-alpha.39 → 0.0.1-alpha.40

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
@@ -2,8 +2,8 @@
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
5
- `)));const U=["src","public","assets","styles","css","app"],B=["styles","css","app","pages"],G=["index","styles","main","global"],V=[".css",".scss",".sass"],R=await(async()=>{if(f)return f;for(const e of U)for(const d of G)for(const p of V){const g=t.join(n,e,d+p);if(await i.readFile(g,"utf-8").catch(()=>{})!==void 0)return t.relative(n,g);for(const S of B){const z=t.join(n,e,S,d+p);if(await i.readFile(z,"utf-8").catch(()=>{})!==void 0)return t.relative(n,z)}}})();if(R){const e=t.join(n,R),d=await i.readFile(e,"utf-8").catch(()=>{});if(d!==void 0&&!d.includes("saltygen")){const g=t.join(e,".."),S=`@import '${t.relative(g,t.join(n,"saltygen/index.css"))}';`;s.info("Adding global import statement to CSS file: "+e),await i.writeFile(e,S+`
6
- `+d),await I(e)}}const _=t.join(n,"vite.config.ts"),A=await i.readFile(_,"utf-8").catch(()=>{});if(A!==void 0&&!A.includes("saltyPlugin")){s.info("Edit file: "+_);const d=`import { saltyPlugin } from '@salty-css/vite';
5
+ `)));const U=["src","public","assets","styles","css","app"],B=["styles","css","app","pages"],G=["index","styles","main","global","globals"],V=[".css",".scss",".sass"],R=await(async()=>{if(f)return f;for(const e of U)for(const d of G)for(const p of V){const g=t.join(n,e,d+p);if(await i.readFile(g,"utf-8").catch(()=>{})!==void 0)return t.relative(n,g);for(const S of B){const z=t.join(n,e,S,d+p);if(await i.readFile(z,"utf-8").catch(()=>{})!==void 0)return t.relative(n,z)}}})();if(R){const e=t.join(n,R),d=await i.readFile(e,"utf-8").catch(()=>{});if(d!==void 0&&!d.includes("saltygen")){const g=t.join(e,".."),S=`@import '${t.relative(g,t.join(n,"saltygen/index.css"))}';`;s.info("Adding global import statement to CSS file: "+e),await i.writeFile(e,S+`
6
+ `+d),await I(e)}}else s.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const _=t.join(n,"vite.config.ts"),A=await i.readFile(_,"utf-8").catch(()=>{});if(A!==void 0&&!A.includes("saltyPlugin")){s.info("Edit file: "+_);const d=`import { saltyPlugin } from '@salty-css/vite';
7
7
  `,g=A.replace(/(plugins: \[)/,`$1
8
8
  saltyPlugin(__dirname),`);m||await F(`-D ${k.vite}`),s.info("Adding Salty-CSS plugin to Vite config..."),await i.writeFile(_,d+g),await I(_)}const T=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(e=>t.join(n,e)).find(e=>H.existsSync(e));if(T){let e=await i.readFile(T,"utf-8").catch(()=>{});if(e!==void 0&&!e.includes("withSaltyCss")){const p=e.includes("module.exports"),g=p?`const { withSaltyCss } = require('@salty-css/next');
9
9
  `:`import { withSaltyCss } from '@salty-css/next';
package/bin/main.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { Command as X } from "commander";
2
2
  import { existsSync as B } from "fs";
3
3
  import { mkdir as z, readFile as p, writeFile as h } from "fs/promises";
4
- import { join as i, relative as T, parse as Y, format as Z } from "path";
4
+ import { join as o, relative as T, parse as Y, format as Z } from "path";
5
5
  import { render as tt } from "ejs";
6
6
  import { generateCss as et } from "../compiler/index.js";
7
7
  import { p as nt } from "../pascal-case-BQpR5PdN.js";
8
8
  import { createLogger as it, format as H, transports as ot } from "winston";
9
9
  import { exec as st } from "child_process";
10
10
  import at from "ora";
11
- const o = it({
11
+ const i = it({
12
12
  level: "debug",
13
13
  format: H.combine(H.colorize(), H.cli()),
14
14
  transports: [new ot.Console({})]
15
15
  }), v = (s) => {
16
- o.error(s);
16
+ i.error(s);
17
17
  }, G = (s) => new Promise((g, S) => {
18
18
  st(s, (P) => {
19
19
  if (P) return S(P);
@@ -22,13 +22,13 @@ const o = it({
22
22
  }), k = async (...s) => {
23
23
  const g = s.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), S = at(`Installing packages: ${g}`).start(), P = s.join(" ");
24
24
  await G(`npm install ${P}`), S.succeed(`Installed packages: ${g}`);
25
- }, rt = () => B(i(process.cwd(), "node_modules", ".bin", "prettier"));
25
+ }, rt = () => B(o(process.cwd(), "node_modules", ".bin", "prettier"));
26
26
  async function I(s) {
27
27
  try {
28
28
  if (!rt()) return;
29
- await G(`./node_modules/.bin/prettier --write "${s}"`), o.info(`Formatted ${s} with Prettier`);
29
+ await G(`./node_modules/.bin/prettier --write "${s}"`), i.info(`Formatted ${s} with Prettier`);
30
30
  } catch (g) {
31
- o.error(`Error formatting ${s} with Prettier:`, g);
31
+ i.error(`Error formatting ${s} with Prettier:`, g);
32
32
  }
33
33
  }
34
34
  async function Pt() {
@@ -44,9 +44,9 @@ async function Pt() {
44
44
  const { default: r } = await g[n], f = tt(r, a);
45
45
  return { fileName: n, content: f };
46
46
  }, P = async () => {
47
- const n = i(process.cwd(), ".saltyrc");
47
+ const n = o(process.cwd(), ".saltyrc");
48
48
  return await p(n, "utf-8").then(JSON.parse).catch(() => ({}));
49
- }, F = async (n = i(process.cwd(), "package.json")) => {
49
+ }, F = async (n = o(process.cwd(), "package.json")) => {
50
50
  const a = await p(n, "utf-8").then(JSON.parse).catch(() => {
51
51
  });
52
52
  if (!a) throw "Could not read package.json file!";
@@ -62,85 +62,86 @@ async function Pt() {
62
62
  next: `@salty-css/next@${j.version}`
63
63
  }, O = (n) => {
64
64
  const a = n === "." ? "" : n, r = process.cwd();
65
- return i(r, a);
65
+ return o(r, a);
66
66
  };
67
67
  s.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 = ".") {
68
68
  if (!await F().catch(() => {
69
69
  })) return v("Salty CSS project must be initialized in a directory with a package.json file.");
70
- o.info("Initializing a new Salty-CSS project!");
70
+ i.info("Initializing a new Salty-CSS project!");
71
71
  const { dir: r = n, cssFile: f, skipInstall: m } = this.opts();
72
72
  if (!r) return v("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
73
73
  m || (await k($.core, $.react), await k(`-D ${$.eslintPluginCore}`));
74
74
  const y = process.cwd(), e = O(r), J = await Promise.all([S("salty.config.ts"), S("saltygen/index.css")]);
75
75
  await z(e, { recursive: !0 });
76
76
  const N = J.map(async ({ fileName: t, content: l }) => {
77
- const d = i(e, t);
77
+ const d = o(e, t);
78
78
  if (await p(d, "utf-8").catch(() => {
79
79
  }) !== void 0) {
80
- o.debug("File already exists: " + d);
80
+ i.debug("File already exists: " + d);
81
81
  return;
82
82
  }
83
83
  const x = t.split("/").slice(0, -1).join("/");
84
- x && await z(i(e, x), { recursive: !0 }), o.info("Creating file: " + d), await h(d, l), await I(d);
84
+ x && await z(o(e, x), { recursive: !0 }), i.info("Creating file: " + d), await h(d, l), await I(d);
85
85
  });
86
86
  await Promise.all(N);
87
- const b = T(y, e) || ".", c = i(y, ".saltyrc"), w = await p(c, "utf-8").catch(() => {
87
+ const b = T(y, e) || ".", c = o(y, ".saltyrc"), w = await p(c, "utf-8").catch(() => {
88
88
  });
89
89
  if (w === void 0) {
90
- o.info("Creating file: " + c);
90
+ i.info("Creating file: " + c);
91
91
  const l = JSON.stringify({
92
92
  defaultProject: b,
93
93
  projects: [b]
94
94
  }, null, 2);
95
95
  await h(c, l);
96
96
  } else {
97
- o.info("Edit file: " + c);
97
+ i.info("Edit file: " + c);
98
98
  const t = JSON.parse(w), l = new Set((t == null ? void 0 : t.projects) || []);
99
99
  l.add(b), t.projects = [...l];
100
100
  const d = JSON.stringify(t, null, 2);
101
101
  await h(c, d);
102
102
  }
103
- const A = i(y, ".gitignore"), D = await p(A, "utf-8").catch(() => {
103
+ const A = o(y, ".gitignore"), D = await p(A, "utf-8").catch(() => {
104
104
  });
105
- D !== void 0 && (D.includes("saltygen") || (o.info("Edit file: " + A), await h(A, D + `
105
+ D !== void 0 && (D.includes("saltygen") || (i.info("Edit file: " + A), await h(A, D + `
106
106
 
107
107
  # Salty-CSS
108
108
  saltygen
109
109
  `)));
110
- const _ = ["src", "public", "assets", "styles", "css", "app"], V = ["styles", "css", "app", "pages"], K = ["index", "styles", "main", "global"], Q = [".css", ".scss", ".sass"], W = await (async () => {
110
+ const _ = ["src", "public", "assets", "styles", "css", "app"], V = ["styles", "css", "app", "pages"], K = ["index", "styles", "main", "global", "globals"], Q = [".css", ".scss", ".sass"], W = await (async () => {
111
111
  if (f) return f;
112
112
  for (const t of _)
113
113
  for (const l of K)
114
114
  for (const d of Q) {
115
- const u = i(e, t, l + d);
115
+ const u = o(e, t, l + d);
116
116
  if (await p(u, "utf-8").catch(() => {
117
117
  }) !== void 0) return T(e, u);
118
118
  for (const C of V) {
119
- const q = i(e, t, C, l + d);
119
+ const q = o(e, t, C, l + d);
120
120
  if (await p(q, "utf-8").catch(() => {
121
121
  }) !== void 0) return T(e, q);
122
122
  }
123
123
  }
124
124
  })();
125
125
  if (W) {
126
- const t = i(e, W), l = await p(t, "utf-8").catch(() => {
126
+ const t = o(e, W), l = await p(t, "utf-8").catch(() => {
127
127
  });
128
128
  if (l !== void 0 && !l.includes("saltygen")) {
129
- const u = i(t, ".."), C = `@import '${T(u, i(e, "saltygen/index.css"))}';`;
130
- o.info("Adding global import statement to CSS file: " + t), await h(t, C + `
129
+ const u = o(t, ".."), C = `@import '${T(u, o(e, "saltygen/index.css"))}';`;
130
+ i.info("Adding global import statement to CSS file: " + t), await h(t, C + `
131
131
  ` + l), await I(t);
132
132
  }
133
- }
134
- const E = i(e, "vite.config.ts"), U = await p(E, "utf-8").catch(() => {
133
+ } else
134
+ i.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");
135
+ const E = o(e, "vite.config.ts"), U = await p(E, "utf-8").catch(() => {
135
136
  });
136
137
  if (U !== void 0 && !U.includes("saltyPlugin")) {
137
- o.info("Edit file: " + E);
138
+ i.info("Edit file: " + E);
138
139
  const l = `import { saltyPlugin } from '@salty-css/vite';
139
140
  `, u = U.replace(/(plugins: \[)/, `$1
140
141
  saltyPlugin(__dirname),`);
141
- m || await k(`-D ${$.vite}`), o.info("Adding Salty-CSS plugin to Vite config..."), await h(E, l + u), await I(E);
142
+ m || await k(`-D ${$.vite}`), i.info("Adding Salty-CSS plugin to Vite config..."), await h(E, l + u), await I(E);
142
143
  }
143
- const L = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((t) => i(e, t)).find((t) => B(t));
144
+ const L = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((t) => o(e, t)).find((t) => B(t));
144
145
  if (L) {
145
146
  let t = await p(L, "utf-8").catch(() => {
146
147
  });
@@ -148,11 +149,11 @@ saltygen
148
149
  const d = t.includes("module.exports"), u = d ? `const { withSaltyCss } = require('@salty-css/next');
149
150
  ` : `import { withSaltyCss } from '@salty-css/next';
150
151
  `;
151
- d ? t = t.replace(/module.exports = ([^;]+)/, (x, C) => `module.exports = withSaltyCss(${C})`) : t = t.replace(/export default ([^;]+)/, (x, C) => `export default withSaltyCss(${C})`), m || await k(`-D ${$.next}`), o.info("Adding Salty-CSS plugin to Next.js config..."), await h(L, u + t), await I(L);
152
+ d ? t = t.replace(/module.exports = ([^;]+)/, (x, C) => `module.exports = withSaltyCss(${C})`) : t = t.replace(/export default ([^;]+)/, (x, C) => `export default withSaltyCss(${C})`), m || await k(`-D ${$.next}`), i.info("Adding Salty-CSS plugin to Next.js config..."), await h(L, u + t), await I(L);
152
153
  }
153
154
  }
154
155
  }), s.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").action(async function(n = R) {
155
- o.info("Building the Salty-CSS project...");
156
+ i.info("Building the Salty-CSS project...");
156
157
  const { dir: a = n } = this.opts();
157
158
  if (!a) return v("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
158
159
  const r = O(a);
@@ -162,20 +163,20 @@ saltygen
162
163
  if (!r) return v("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
163
164
  if (!f) return v("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
164
165
  const J = O(f), N = r.split("/").slice(0, -1).join("/");
165
- N && await z(i(J, N), { recursive: !0 });
166
- const b = i(J, r), c = Y(b);
166
+ N && await z(o(J, N), { recursive: !0 });
167
+ const b = o(J, r), c = Y(b);
167
168
  c.ext || (c.ext = ".ts"), c.name.endsWith(".css") || (c.name = c.name + ".css"), c.base = c.name + c.ext;
168
169
  const w = Z(c);
169
170
  if (await p(w, "utf-8").catch(() => {
170
171
  }) !== void 0) {
171
- o.error("File already exists:", w);
172
+ i.error("File already exists:", w);
172
173
  return;
173
174
  }
174
- o.info("Generating a new file: " + w);
175
+ i.info("Generating a new file: " + w);
175
176
  const D = nt(y || c.base.replace(/\.css\.\w+$/, "")), { content: _ } = await S("react/react-styled-file.ts", { tag: m, name: D, className: e });
176
177
  await h(w, _), await I(w);
177
178
  }), s.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function() {
178
- const { legacyPeerDeps: n } = this.opts(), a = i(process.cwd(), "package.json"), r = await F(a).catch((e) => v(e));
179
+ const { legacyPeerDeps: n } = this.opts(), a = o(process.cwd(), "package.json"), r = await F(a).catch((e) => v(e));
179
180
  if (!r) return;
180
181
  const f = { ...r.dependencies, ...r.devDependencies }, m = Object.keys(f).filter((e) => e === "salty-css" || e.startsWith("@salty-css/"));
181
182
  if (!m.length)
@@ -183,7 +184,7 @@ saltygen
183
184
  "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + a
184
185
  );
185
186
  const y = m.map((e) => `${e}@${j.version}`);
186
- n ? (o.warn("Using legacy peer dependencies to update packages."), await k(...y, "--legacy-peer-deps")) : await k(...y), o.info("Salty-CSS packages updated successfully!");
187
+ n ? (i.warn("Using legacy peer dependencies to update packages."), await k(...y, "--legacy-peer-deps")) : await k(...y), i.info("Salty-CSS packages updated successfully!");
187
188
  }), s.parseAsync(process.argv);
188
189
  }
189
190
  export {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("esbuild"),B=require("child_process"),P=require("../dash-case-DKzpenwY.cjs"),o=require("path"),r=require("fs"),K=require("fs/promises"),V=require("../parse-templates-W0YfTmOT.cjs");function G(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const R=G(I),N=t=>o.join(t,"./saltygen"),_=["salty","css","styles","styled"],q=(t=[])=>new RegExp(`\\.(${[..._,...t].join("|")})\\.`),O=(t,e=[])=>q(e).test(t),J=async t=>{const e=N(t),n=o.join(t,"salty.config.ts"),s=o.join(e,"salty.config.js");await R.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:"esm",external:["react"]});const a=Date.now(),{config:w}=await import(`${s}?t=${a}`);return w},M=async t=>{const e=await J(t),n=new Set,s=(d,y=[])=>d?Object.entries(d).flatMap(([p,c])=>{if(!c)return;if(typeof c=="object")return s(c,[...y,p]);const C=[...y,p].join(".");n.add(`"${C}"`);const x=[...y.map(P.dashCase),P.dashCase(p)].join("-"),{result:D}=V.parseValueTokens(c);return`--${x}: ${D};`}):[],a=d=>d?Object.entries(d).flatMap(([y,p])=>{const c=s(p);return y==="base"?c.join(""):`${y} { ${c.join("")} }`}):[],w=d=>d?Object.entries(d).flatMap(([y,p])=>Object.entries(p).flatMap(([c,C])=>{const x=s(C,[y]),D=`.${y}-${c}, [data-${y}="${c}"]`,k=x.join("");return`${D} { ${k} }`})):[],j=s(e.variables),S=a(e.responsiveVariables),l=w(e.conditionalVariables),b=N(t),f=o.join(b,"css/variables.css"),i=`:root { ${j.join("")} ${S.join("")} } ${l.join("")}`;r.writeFileSync(f,i);const g=o.join(b,"types/css-tokens.d.ts"),m=`type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;r.writeFileSync(g,m);const u=o.join(b,"css/global.css"),h=V.parseStyles(e.global,"");r.writeFileSync(u,h);const F=o.join(b,"css/templates.css"),v=V.parseTemplates(e.templates);r.writeFileSync(F,v)},T=async(t,e)=>{const n=P.toHash(t),s=o.join(e,"js",n+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const a=Date.now();return await import(`${s}?t=${a}`)},E=async t=>{const e=N(t),n=o.join(e,"salty.config.js"),{config:s}=await import(n);return s},A=async t=>{try{const e=[],n=[],s=N(t),a=o.join(s,"index.css");(()=>{r.existsSync(s)&&B.execSync("rm -rf "+s),r.mkdirSync(s),r.mkdirSync(o.join(s,"css")),r.mkdirSync(o.join(s,"types"))})(),await M(t);const j=await E(t);async function S(i,g){const $=r.statSync(i);if($.isDirectory()){const m=r.readdirSync(i);await Promise.all(m.map(u=>S(o.join(i,u),o.join(g,u))))}else if($.isFile()&&O(i)){const u=await T(i,s),h=[];Object.entries(u).forEach(([y,p])=>{if(p.isKeyframes&&p.css){const k=`${p.animationName}.css`,z=`css/${k}`,H=o.join(s,z);e.push(k),r.writeFileSync(H,p.css);return}if(!p.generator)return;const c=p.generator._withBuildContext({name:y,config:j}),C=`${c.hash}-${c.priority}.css`;n[c.priority]||(n[c.priority]=[]),n[c.priority].push(C),h.push(C);const x=`css/${C}`,D=o.join(s,x);r.writeFileSync(D,c.css)});const F=h.map(y=>`@import url('./${y}');`).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("esbuild"),B=require("child_process"),P=require("../dash-case-DKzpenwY.cjs"),o=require("path"),r=require("fs"),K=require("fs/promises"),V=require("../parse-templates-W0YfTmOT.cjs");function G(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const R=G(I),N=t=>o.join(t,"./saltygen"),_=["salty","css","styles","styled"],q=(t=[])=>new RegExp(`\\.(${[..._,...t].join("|")})\\.`),O=(t,e=[])=>q(e).test(t),J=async t=>{const e=N(t),n=o.join(t,"salty.config.ts"),s=o.join(e,"salty.config.js");await R.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:"esm",external:["react"]});const a=Date.now(),{config:w}=await import(`${s}?t=${a}`);return w},M=async t=>{const e=await J(t),n=new Set,s=(d,y=[])=>d?Object.entries(d).flatMap(([p,c])=>{if(!c)return;if(typeof c=="object")return s(c,[...y,p]);const C=[...y,p].join(".");n.add(`"${C}"`);const x=[...y.map(P.dashCase),P.dashCase(p)].join("-"),{result:D}=V.parseValueTokens(c);return`--${x}: ${D};`}):[],a=d=>d?Object.entries(d).flatMap(([y,p])=>{const c=s(p);return y==="base"?c.join(""):`${y} { ${c.join("")} }`}):[],w=d=>d?Object.entries(d).flatMap(([y,p])=>Object.entries(p).flatMap(([c,C])=>{const x=s(C,[y]),D=`.${y}-${c}, [data-${y}="${c}"]`,k=x.join("");return`${D} { ${k} }`})):[],j=s(e.variables),S=a(e.responsiveVariables),l=w(e.conditionalVariables),b=N(t),f=o.join(b,"css/variables.css"),i=`:root { ${j.join("")} ${S.join("")} } ${l.join("")}`;r.writeFileSync(f,i);const g=o.join(b,"types/css-tokens.d.ts"),m=`type VariableTokens = ${[...n].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;r.writeFileSync(g,m);const u=o.join(b,"css/global.css"),h=V.parseStyles(e.global,"");r.writeFileSync(u,h);const F=o.join(b,"css/templates.css"),v=V.parseTemplates(e.templates);r.writeFileSync(F,v)},T=async(t,e)=>{const n=P.toHash(t),s=o.join(e,"js",n+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const a=Date.now();return await import(`${s}?t=${a}`)},E=async t=>{const e=N(t),n=o.join(e,"salty.config.js"),{config:s}=await import(n);return s},A=async t=>{try{const e=[],n=[],s=N(t),a=o.join(s,"index.css");(()=>{r.existsSync(s)&&B.execSync("rm -rf "+s),r.mkdirSync(s),r.mkdirSync(o.join(s,"css")),r.mkdirSync(o.join(s,"types"))})(),await M(t);const j=await E(t);async function S(i,g){const $=r.statSync(i);if($.isDirectory()){const m=r.readdirSync(i);await Promise.all(m.map(u=>S(o.join(i,u),o.join(g,u))))}else if($.isFile()&&O(i)){const u=await T(i,s),h=[];Object.entries(u).forEach(([y,p])=>{if(p.isKeyframes&&p.css){const k=`${p.animationName}.css`,z=`css/${k}`,H=o.join(s,z);e.push(k),r.writeFileSync(H,p.css);return}if(!p.generator)return;const c=p.generator._withBuildContext({name:y,config:j}),C=`${c.hash}-${c.priority}.css`;n[c.priority]||(n[c.priority]=[]),n[c.priority].push(C),h.push(C);const x=`css/${C}`,D=o.join(s,x);r.writeFileSync(D,c.css)});const F=h.map(y=>`@import url('./${y}');`).join(`
2
2
  `),v=P.toHash(i,6),d=o.join(s,`css/${v}.css`);r.writeFileSync(d,F)}}await S(t,s);const l=e.map(i=>`@import url('./css/${i}');`).join(`
3
3
  `);let f=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
4
4
 
package/compiler/index.js CHANGED
@@ -34,7 +34,7 @@ const N = (s) => o(s, "./saltygen"), U = ["salty", "css", "styles", "styled"], W
34
34
  return `${D} { ${P} }`;
35
35
  })) : [], d = t(e.variables), w = c(e.responsiveVariables), a = S(e.conditionalVariables), b = N(s), f = o(b, "css/variables.css"), i = `:root { ${d.join("")} ${w.join("")} } ${a.join("")}`;
36
36
  $(f, i);
37
- const y = o(b, "types/css-tokens.d.ts"), g = `type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
37
+ const y = o(b, "types/css-tokens.d.ts"), g = `type VariableTokens = ${[...n].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
38
38
  $(y, g);
39
39
  const m = o(b, "css/global.css"), F = q(e.global, "");
40
40
  $(m, F);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.39",
3
+ "version": "0.0.1-alpha.40",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",