@salty-css/core 0.0.1-alpha.24 → 0.0.1-alpha.240

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.
Files changed (99) hide show
  1. package/.saltyrc.schema.json +48 -0
  2. package/README.md +469 -26
  3. package/bin/index.cjs +1 -8
  4. package/bin/index.js +2 -129
  5. package/bin/logger.d.ts +1 -0
  6. package/bin/main.cjs +11 -0
  7. package/bin/main.d.ts +1 -0
  8. package/bin/main.js +263 -0
  9. package/compiler/get-files.d.ts +3 -0
  10. package/compiler/get-function-range.d.ts +1 -0
  11. package/compiler/index.cjs +1 -11
  12. package/compiler/index.d.ts +19 -11
  13. package/compiler/index.js +18 -172
  14. package/config/define-config.d.ts +1 -1
  15. package/config/index.cjs +1 -1
  16. package/config/index.d.ts +2 -1
  17. package/config/index.js +12 -2
  18. package/css/index.cjs +1 -1
  19. package/css/index.d.ts +4 -1
  20. package/css/index.js +10 -2
  21. package/css/keyframes.cjs +1 -0
  22. package/css/keyframes.d.ts +22 -0
  23. package/css/keyframes.js +34 -0
  24. package/css/media.cjs +1 -0
  25. package/css/media.d.ts +87 -0
  26. package/css/media.js +88 -0
  27. package/css/merge.cjs +1 -0
  28. package/css/merge.d.ts +7 -0
  29. package/css/merge.js +5 -0
  30. package/css/token.cjs +1 -0
  31. package/css/token.d.ts +1 -0
  32. package/css/token.js +4 -0
  33. package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
  34. package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
  35. package/define-templates-4A2yHcMF.js +52 -0
  36. package/define-templates-Cunsb_Tr.cjs +1 -0
  37. package/factories/define-global-styles.d.ts +7 -0
  38. package/factories/define-media-query.d.ts +8 -0
  39. package/factories/define-templates.d.ts +27 -0
  40. package/factories/define-variables.d.ts +12 -0
  41. package/factories/index.cjs +1 -0
  42. package/factories/index.d.ts +4 -0
  43. package/factories/index.js +30 -0
  44. package/generators/class-name-generator.d.ts +6 -0
  45. package/generators/index.cjs +1 -0
  46. package/generators/index.d.ts +2 -0
  47. package/generators/index.js +86 -0
  48. package/generators/styled-generator.d.ts +19 -0
  49. package/generators/styles-generator.d.ts +22 -0
  50. package/helpers/color.d.ts +18 -0
  51. package/helpers/index.cjs +1 -0
  52. package/helpers/index.d.ts +2 -0
  53. package/helpers/index.js +1156 -0
  54. package/helpers/viewport-clamp.d.ts +8 -0
  55. package/index-D8CuiJVg.js +527 -0
  56. package/index-O0uhHL8c.cjs +38 -0
  57. package/package.json +39 -3
  58. package/parse-styles-3N79AOBO.cjs +5 -0
  59. package/parse-styles-Bo7fQ_SV.js +134 -0
  60. package/parsers/index.cjs +1 -0
  61. package/parsers/index.d.ts +5 -0
  62. package/parsers/index.js +12 -0
  63. package/parsers/parse-modifiers.d.ts +3 -0
  64. package/parsers/parse-styles.d.ts +13 -0
  65. package/parsers/parse-templates.d.ts +4 -0
  66. package/parsers/parse-tokens.d.ts +3 -0
  67. package/parsers/parser-types.d.ts +8 -0
  68. package/parsers/property-name-check.d.ts +1 -0
  69. package/parsers/unit-check.d.ts +7 -0
  70. package/react-vanilla-file-CCXbsjIb.js +18 -0
  71. package/react-vanilla-file-CG_WJLam.cjs +15 -0
  72. package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
  73. package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
  74. package/server/index.cjs +1 -0
  75. package/server/index.d.ts +1 -0
  76. package/server/index.js +4 -0
  77. package/server/should-restart.d.ts +1 -0
  78. package/should-restart-BPXyHnNn.cjs +1 -0
  79. package/should-restart-CeCqMexy.js +12 -0
  80. package/templates/salty-reset.d.ts +2 -0
  81. package/types/cli-types.d.ts +10 -0
  82. package/types/config-types.d.ts +84 -0
  83. package/types/index.d.ts +53 -22
  84. package/util/dot-case.d.ts +1 -0
  85. package/util/index.cjs +1 -1
  86. package/util/index.js +1 -1
  87. package/util/module-type.d.ts +1 -0
  88. package/config/config-types.d.ts +0 -59
  89. package/generator/index.cjs +0 -1
  90. package/generator/index.d.ts +0 -1
  91. package/generator/index.js +0 -61
  92. package/generator/parse-modifiers.d.ts +0 -3
  93. package/generator/parse-styles.d.ts +0 -2
  94. package/generator/parse-templates.d.ts +0 -2
  95. package/generator/parse-tokens.d.ts +0 -2
  96. package/generator/parser-types.d.ts +0 -4
  97. package/generator/style-generator.d.ts +0 -28
  98. package/parse-templates-D4p3pgQR.js +0 -92
  99. package/parse-templates-W0YfTmOT.cjs +0 -8
package/bin/index.js CHANGED
@@ -1,130 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { Command as L } from "commander";
3
- import { mkdir as N, readFile as g, writeFile as y } from "fs/promises";
4
- import { join as o, relative as O, parse as A, format as H } from "path";
5
- import { render as T } from "ejs";
6
- import { generateCss as W } from "../compiler/index.js";
7
- import { p as B } from "../pascal-case-BQpR5PdN.js";
8
- import { createLogger as G, format as J, transports as R } from "winston";
9
- import { existsSync as q } from "fs";
10
- import { exec as M } from "child_process";
11
- import U from "ora";
12
- const i = G({
13
- level: "debug",
14
- format: J.combine(J.colorize(), J.cli()),
15
- transports: [new R.Console({})]
16
- }), _ = (e) => new Promise((l, m) => {
17
- M(e, (u) => {
18
- if (u) return m(u);
19
- l();
20
- });
21
- }), D = async (...e) => {
22
- const l = e.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()), m = U(`Installing packages: ${l.join(", ")}`).start(), u = e.join(" ");
23
- await _(`npm install ${u}`), m.succeed(`Installed packages: ${l.join(",")}`);
24
- }, V = () => q(o(process.cwd(), "node_modules", ".bin", "prettier"));
25
- async function x(e) {
26
- try {
27
- if (!V()) return;
28
- await _(`./node_modules/.bin/prettier --write "${e}"`), i.info(`Formatted ${e} with Prettier`);
29
- } catch (l) {
30
- i.error(`Error formatting ${e} with Prettier:`, l);
31
- }
32
- }
33
- async function K() {
34
- const e = new L();
35
- e.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
36
- const l = {
37
- // Core files
38
- "salty.config.ts": import("../salty.config-D9ANEDiH.js"),
39
- "saltygen/index.css": import("../index-D_732b92.js"),
40
- // React
41
- "react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js")
42
- }, m = async (a, c) => {
43
- const { default: p } = await l[a], r = T(p, c);
44
- return { fileName: a, content: r };
45
- }, u = async () => {
46
- const a = o(process.cwd(), ".saltyrc");
47
- return await g(a, "utf-8").then(JSON.parse).catch(() => ({}));
48
- }, F = async () => {
49
- const a = new URL("../package.json", import.meta.url);
50
- return await g(a, "utf-8").then(JSON.parse).catch(() => ({}));
51
- }, E = await (async () => (await u()).defaultProject)(), P = await F(), v = {
52
- core: `@salty-css/core@${P.version}`,
53
- react: `@salty-css/react@${P.version}`,
54
- eslintPluginCore: `@salty-css/eslint-plugin-core@${P.version}`,
55
- vite: `@salty-css/vite@${P.version}`
56
- };
57
- e.command("init").description("Initialize a new Salty-CSS project.").requiredOption("-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.").action(async function() {
58
- await D(v.core, v.react), await D(`-D ${v.eslintPluginCore}`), i.info("Initializing a new Salty-CSS project...");
59
- const { dir: a, cssFile: c } = this.opts(), p = process.cwd(), r = o(p, a), $ = await Promise.all([m("salty.config.ts"), m("saltygen/index.css")]);
60
- await N(r, { recursive: !0 });
61
- const I = $.map(async ({ fileName: t, content: s }) => {
62
- const d = o(r, t);
63
- if (await g(d, "utf-8").catch(() => {
64
- }) !== void 0) {
65
- i.debug("File already exists: " + d);
66
- return;
67
- }
68
- const k = t.split("/").slice(0, -1).join("/");
69
- k && await N(o(r, k), { recursive: !0 }), i.info("Writing file: " + d), await y(d, s), await x(d);
70
- });
71
- await Promise.all(I);
72
- const h = O(p, r), n = o(p, ".saltyrc"), f = await g(n, "utf-8").catch(() => {
73
- });
74
- if (f === void 0) {
75
- i.info("Creating file: " + n);
76
- const s = JSON.stringify({
77
- defaultProject: h,
78
- projects: [h]
79
- }, null, 2);
80
- await y(n, s);
81
- } else {
82
- i.info("Edit file: " + n);
83
- const t = JSON.parse(f), s = new Set((t == null ? void 0 : t.projects) || []);
84
- s.add(h), t.projects = [...s];
85
- const d = JSON.stringify(t, null, 2);
86
- await y(n, d);
87
- }
88
- const C = o(p, ".gitignore"), S = await g(C, "utf-8").catch(() => {
89
- });
90
- if (S !== void 0 && (S.includes("saltygen") || (i.info("Edit file: " + C), await y(C, S + `
91
-
92
- # Salty-CSS
93
- saltygen
94
- `))), c) {
95
- const t = o(r, c), s = await g(t, "utf-8").catch(() => {
96
- });
97
- if (s !== void 0 && !s.includes("saltygen")) {
98
- const j = o(t, ".."), z = `@import '${O(j, o(r, "saltygen/index.css"))}';`;
99
- i.info("Edit file: " + t), await y(t, z + `
100
- ` + s), await x(t);
101
- }
102
- }
103
- const w = o(r, "vite.config.ts"), b = await g(w, "utf-8").catch(() => {
104
- });
105
- if (b !== void 0 && !b.includes("saltyPlugin")) {
106
- i.info("Edit file: " + w);
107
- const s = `import { saltyPlugin } from '@salty-css/vite';
108
- `, j = b.replace(/(plugins: \[)/, `$1
109
- saltyPlugin(__dirname),`);
110
- i.info("Installing @salty-css/vite"), await D(v.vite), i.info("Adding Salty-CSS plugin to Vite config..."), await y(w, s + j), await x(w);
111
- }
112
- }), e.command("build").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.", E).action(async function() {
113
- i.info("Building the Salty-CSS project...");
114
- const { dir: a } = this.opts(), c = o(process.cwd(), a);
115
- await W(c);
116
- }), e.command("generate <file>").alias("g").description("Generate a new component file.").option("-d, --dir <dir>", "Project directory to generate the file in.", E).option("-t, --tag <tag>", "HTML tag of the component.", "div").option("-n, --name <name>", "Name of the component.").option("-c, --className <className>", "CSS class of the component.").action(async function(a) {
117
- const { dir: c, tag: p, name: r, className: $ } = this.opts(), I = o(process.cwd(), c), h = o(I, a), n = A(h);
118
- n.ext || (n.ext = ".ts"), n.name.endsWith(".css") || (n.name = n.name + ".css"), n.base = n.name + n.ext;
119
- const f = H(n);
120
- if (await g(f, "utf-8").catch(() => {
121
- }) !== void 0) {
122
- i.error("File already exists:", f);
123
- return;
124
- }
125
- i.info("Generating a new file: " + f);
126
- const S = B(r || n.base.replace(/\.css\.\w+$/, "")), { content: w } = await m("react/react-styled-file.ts", { tag: p, name: S, className: $ });
127
- await y(f, w), await x(f);
128
- }), e.parseAsync(process.argv);
129
- }
130
- K().catch((e) => console.error(e));
2
+ import { main as r } from "./main.js";
3
+ r().catch((o) => console.error(o));
package/bin/logger.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export declare const logger: import('winston').Logger;
2
+ export declare const logError: (message: string) => void;
package/bin/main.cjs ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),A=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),e=require("../index-O0uhHL8c.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora"),ae=require("../should-restart-BPXyHnNn.cjs");var G=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,x=>{if(x)return P(x);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(),x=y.join(" ");await X(`npm install ${x}`),P.succeed(`Installed packages: ${C}`)},re=()=>A.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!re())return;await X(`./node_modules/.bin/prettier --write "${y}"`),e.logger.info(`Formatted ${y} with Prettier`)}catch(C){e.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function ce(){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:f}=await C[i],d=ne.render(f,a);return{fileName:i,content:d}},x=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:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await x()).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}`},H=i=>{const a=i==="."?"":i,f=process.cwd();return n.join(f,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 e.logError("Salty CSS project must be initialized in a directory with a package.json file.");e.logger.info("Initializing a new Salty-CSS project!");const{dir:f=i,cssFile:d,skipInstall:p}=this.opts();if(!f)return e.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 c=process.cwd(),r=H(f),q=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=q.map(async({fileName:t,content:u})=>{const l=n.join(r,t);if(await s.readFile(l,"utf-8").catch(()=>{})!==void 0){e.logger.debug("File already exists: "+l);return}const k=t.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),e.logger.info("Creating file: "+l),await s.writeFile(l,u),await S(l)});await Promise.all(m);const w=n.relative(c,r)||".",h=n.join(c,".saltyrc.json"),g=await s.readFile(h,"utf-8").catch(()=>{});if(g===void 0){e.logger.info("Creating file: "+h);const u=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,u),await S(h)}else{const t=JSON.parse(g),u=(t==null?void 0:t.projects)||[];if(u.findIndex(o=>o.dir===w)===-1){u.push({dir:w,framework:"react"}),t.projects=[...u];const o=JSON.stringify(t,null,2);o!==g&&(e.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(c,".gitignore"),T=await s.readFile(j,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(e.logger.info("Edit file: "+j),await s.writeFile(j,T+`
2
+
3
+ # Salty-CSS
4
+ saltygen
5
+ `)));const F=["src","public","assets","styles","css","app"],W=["styles","css","app","pages"],M=["index","styles","main","app","global","globals"],U=[".css",".scss",".sass"],E=await(async()=>{if(d)return d;for(const t of F)for(const u of M)for(const l of U){const o=n.join(r,t,u+l);if(await s.readFile(o,"utf-8").catch(()=>{})!==void 0)return n.relative(r,o);for(const O of W){const R=n.join(r,t,O,u+l);if(await s.readFile(R,"utf-8").catch(()=>{})!==void 0)return n.relative(r,R)}}})();if(E){const t=n.join(r,E),u=await s.readFile(t,"utf-8").catch(()=>{});if(u!==void 0&&!u.includes("saltygen")){const o=n.join(t,".."),O=`@import '${n.relative(o,n.join(r,"saltygen/index.css"))}';`;e.logger.info("Adding global import statement to CSS file: "+t),await s.writeFile(t,O+`
6
+ `+u),await S(t)}}else e.logger.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const Z={projectJs:n.join(r,"eslint.config.js"),rootJs:n.join(c,"eslint.config.js"),projectMjs:n.join(r,"eslint.config.mjs"),rootMjs:n.join(c,"eslint.config.mjs"),projectJson:n.join(r,".eslintrc.json"),rootJson:n.join(c,".eslintrc.json")},v=Object.values(Z).find(t=>A.existsSync(t));if(v){p||await I(D.eslintConfigCore);const t=await s.readFile(v,"utf-8").catch(()=>{});if(!t)return e.logError("Could not read ESLint config file.");if(!t.includes("salty-css"))if(e.logger.info("Edit file: "+v),v.endsWith("js")){let o=`import saltyCss from "@salty-css/eslint-config-core/flat";
7
+ ${t}`;t.includes("typescript-eslint")?o.includes(".config(")?o=o.replace(".config(",".config(saltyCss,"):e.logger.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."):o.includes("export default [")?o=o.replace("export default [","export default [ saltyCss,"):o.includes("eslintConfig = [")?o=o.replace("eslintConfig = [","eslintConfig = [ saltyCss,"):e.logger.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."),await s.writeFile(v,o),await S(v)}else{const l=JSON.parse(t);l.extends||(l.extends=[]),l.extends.push("@salty-css/core");const o=JSON.stringify(l,null,2);await s.writeFile(v,o),await S(v)}}const L=n.join(r,"vite.config.ts"),z=await s.readFile(L,"utf-8").catch(()=>{});if(z!==void 0&&!z.includes("saltyPlugin")){e.logger.info("Edit file: "+L);const u=`import { saltyPlugin } from '@salty-css/vite';
8
+ `,o=z.replace(/(plugins: \[)/,`$1
9
+ saltyPlugin(__dirname),`);p||await I(`-D ${D.vite}`),e.logger.info("Adding Salty-CSS plugin to Vite config..."),await s.writeFile(L,u+o),await S(L)}const _=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(t=>n.join(r,t)).find(t=>A.existsSync(t));if(_){let t=await s.readFile(_,"utf-8").catch(()=>{});if(t!==void 0&&!t.includes("withSaltyCss")){let l=!1;/\splugins([^=]*)=[^[]\[/.test(t)&&!l&&(t=t.replace(/\splugins([^=]*)=[^[]\[/,(R,J)=>` plugins${J}= [withSaltyCss,`),l=!0);const k=t.includes("module.exports"),O=k?`const { withSaltyCss } = require('@salty-css/next');
10
+ `:`import { withSaltyCss } from '@salty-css/next';
11
+ `;k&&!l?(t=t.replace(/module.exports = ([^;]+)/,(R,J)=>`module.exports = withSaltyCss(${J})`),l=!0):l||(t=t.replace(/export default ([^;]+)/,(R,J)=>`export default withSaltyCss(${J})`)),p||await I(`-D ${D.next}`),e.logger.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(_,O+t),await S(_)}}const ee=await N().catch(()=>e.logError("Could not read package.json file.")).then(t=>(t.scripts||(t.scripts={}),t.scripts.prepare?t.scripts.prepare.includes("salty-css")||(e.logger.info("Edit file: "+b),t.scripts.prepare=t.scripts.prepare+" && npx salty-css build"):(e.logger.info("Edit file: "+b),t.scripts.prepare="npx salty-css build"),t));await Y(ee),e.logger.info("Running the build to generate initial CSS..."),await e.generateCss(r),e.logger.info("🎉 Salty CSS project initialized successfully!"),e.logger.info("Next steps:"),e.logger.info("1. Configure variables and templates in `salty.config.ts`"),e.logger.info("2. Create a new component with `npx salty-css generate [component-name]`"),e.logger.info("3. Run `npx salty-css build` to generate the CSS"),e.logger.info("4. Read about the features in the documentation: https://salty-css.dev"),e.logger.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐")}),y.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").option("--watch","Watch for changes and rebuild the project.").action(async function(i=V){e.logger.info("Building the Salty-CSS project...");const{dir:a=i,watch:f}=this.opts();if(!a)return e.logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const d=H(a);await e.generateCss(d),f&&(e.logger.info("Watching for changes in the project directory..."),A.watch(d,{recursive:!0},async(p,c)=>{await ae.checkShouldRestart(c)?await e.generateCss(d,!1,!1):e.isSaltyFile(c)&&await e.generateFile(d,c)}))}),y.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>","File to generate.").option("-d, --dir <dir>","Project directory to generate the file in.").option("-t, --tag <tag>","HTML tag of the component.","div").option("-n, --name <name>","Name of the component.").option("-c, --className <className>","CSS class of the component.").option("-r, --reactComponent","Generate a React component as well.").action(async function(i,a=V){const{file:f=i,dir:d=a,tag:p,name:c,className:r,reactComponent:q=!1}=this.opts();if(!f)return e.logError("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!d)return e.logError("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const m=H(d),w=f.split("/").slice(0,-1).join("/");w&&await s.mkdir(n.join(m,w),{recursive:!0});const h=n.join(m,f),g=n.parse(h);g.ext||(g.ext=".ts"),g.name.endsWith(".css")||(g.name=g.name+".css"),g.base=g.name+g.ext;const j=n.format(g);if(await s.readFile(j,"utf-8").catch(()=>{})!==void 0){e.logger.error("File already exists:",j);return}let F=ie.pascalCase(c||g.base.replace(/\.css\.\w+$/,""));if(q){const M=F+"Component";F=F+"Wrapper";const U=g.base.replace(/\.css\.\w+$/,""),{content:Q}=await P("react/react-vanilla-file.ts",{tag:p,componentName:M,styledComponentName:F,className:r,fileName:U});g.name=U.replace(/\.css$/,""),g.ext=".tsx",g.base=g.name+g.ext;const E=n.format(g);e.logger.info("Generating a new file: "+E),await s.writeFile(E,Q),await S(E)}const{content:W}=await P("react/react-styled-file.ts",{tag:p,name:F,className:r});e.logger.info("Generating a new file: "+j),await s.writeFile(j,W),await S(j)});const K=async()=>{const i=n.join(process.cwd(),"package.json"),a=await N(i).catch(p=>e.logError(p));if(!a)return e.logError("Could not read package.json file.");const f={...a.dependencies,...a.devDependencies},d=Object.entries(f).filter(([p])=>p==="salty-css"||p.startsWith("@salty-css/"));return d.length?d:e.logError("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+i)};y.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>","Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(i="latest"){const{legacyPeerDeps:a,version:f=i}=this.opts(),d=await K();if(!d)return e.logError("Could not update Salty-CSS packages as any were found in package.json.");const p=d.map(([m])=>f==="@"?`${m}@${$.version}`:`${m}@${f.replace(/^@/,"")}`);a?(e.logger.warn("Using legacy peer dependencies to update packages."),await I(...p,"--legacy-peer-deps")):await I(...p);const c=await K();if(!c)return e.logError("Something went wrong while reading the updated packages.");const r=c.reduce((m,[w,h])=>(m[h]||(m[h]=[]),m[h].push(w),m),{});if(Object.keys(r).length===1){const w=Object.keys(r)[0].replace(/^\^/,"");e.logger.info(`Updated to all Salty CSS packages successfully to ${w}`)}else for(const[m,w]of Object.entries(r)){const h=m.replace(/^\^/,"");e.logger.info(`Updated to ${h}: ${w.join(", ")}`)}}),y.option("-v, --version","Show the current version of Salty-CSS.").action(async function(){const i=await B();e.logger.info("CLI is running: "+i.version);const a=n.join(process.cwd(),"package.json"),f=await N(a).catch(c=>e.logError(c));if(!f)return;const d={...f.dependencies,...f.devDependencies},p=Object.keys(d).filter(c=>c==="salty-css"||c.startsWith("@salty-css/"));if(!p.length)return e.logError("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+a);for(const c of p)e.logger.info(`${c}: ${d[c]}`)}),y.parseAsync(process.argv)}exports.main=ce;
package/bin/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function main(): Promise<void>;
package/bin/main.js ADDED
@@ -0,0 +1,263 @@
1
+ import { Command as oe } from "commander";
2
+ import { existsSync as Q, watch as re } from "fs";
3
+ import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
4
+ import { join as a, relative as z, parse as ce, format as te } from "path";
5
+ import { render as le } from "ejs";
6
+ import { l as t, a as h, g as K, i as de, b as fe } from "../index-D8CuiJVg.js";
7
+ import { p as pe } from "../pascal-case-BQpR5PdN.js";
8
+ import { exec as ue } from "child_process";
9
+ import ge from "ora";
10
+ import { c as ye } from "../should-restart-CeCqMexy.js";
11
+ const ne = (g) => new Promise((P, x) => {
12
+ ue(g, ($) => {
13
+ if ($) return x($);
14
+ P();
15
+ });
16
+ }), E = async (...g) => {
17
+ const P = g.map((J) => J.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), x = ge(`Installing packages: ${P}`).start(), $ = g.join(" ");
18
+ await ne(`npm install ${$}`), x.succeed(`Installed packages: ${P}`);
19
+ }, me = () => Q(a(process.cwd(), "node_modules", ".bin", "prettier"));
20
+ async function j(g) {
21
+ try {
22
+ if (!me()) return;
23
+ await ne(`./node_modules/.bin/prettier --write "${g}"`), t.info(`Formatted ${g} with Prettier`);
24
+ } catch (P) {
25
+ t.error(`Error formatting ${g} with Prettier:`, P);
26
+ }
27
+ }
28
+ async function Je() {
29
+ const g = new oe();
30
+ g.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
31
+ const P = {
32
+ // Core files
33
+ "salty.config.ts": import("../salty.config-BhBY_oOk.js"),
34
+ "saltygen/index.css": import("../index-D_732b92.js"),
35
+ // React
36
+ "react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js"),
37
+ "react/react-vanilla-file.ts": import("../react-vanilla-file-CCXbsjIb.js")
38
+ }, x = async (n, i) => {
39
+ const { default: d } = await P[n], l = le(d, i);
40
+ return { fileName: n, content: l };
41
+ }, $ = async () => {
42
+ const n = a(process.cwd(), ".saltyrc.json");
43
+ return await S(n, "utf-8").then(JSON.parse).catch(() => ({}));
44
+ }, J = a(process.cwd(), "package.json"), O = async (n = J) => {
45
+ const i = await S(n, "utf-8").then(JSON.parse).catch(() => {
46
+ });
47
+ if (!i) throw "Could not read package.json file!";
48
+ return i;
49
+ }, se = async (n, i = J) => {
50
+ typeof n == "object" && (n = JSON.stringify(n, null, 2)), await C(i, n);
51
+ }, X = async () => {
52
+ const n = new URL("../package.json", import.meta.url);
53
+ return O(n);
54
+ }, Y = await (async () => (await $()).defaultProject)(), N = await X(), A = {
55
+ core: `@salty-css/core@${N.version}`,
56
+ react: `@salty-css/react@${N.version}`,
57
+ eslintConfigCore: `@salty-css/eslint-config-core@${N.version}`,
58
+ vite: `@salty-css/vite@${N.version}`,
59
+ next: `@salty-css/next@${N.version}`
60
+ }, G = (n) => {
61
+ const i = n === "." ? "" : n, d = process.cwd();
62
+ return a(d, i);
63
+ };
64
+ g.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 = ".") {
65
+ if (!await O().catch(() => {
66
+ })) return h("Salty CSS project must be initialized in a directory with a package.json file.");
67
+ t.info("Initializing a new Salty-CSS project!");
68
+ const { dir: d = n, cssFile: l, skipInstall: p } = this.opts();
69
+ if (!d) return h("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
70
+ p || await E(A.core, A.react);
71
+ const r = process.cwd(), o = G(d), T = await Promise.all([x("salty.config.ts"), x("saltygen/index.css")]);
72
+ await q(o, { recursive: !0 });
73
+ const y = T.map(async ({ fileName: e, content: u }) => {
74
+ const c = a(o, e);
75
+ if (await S(c, "utf-8").catch(() => {
76
+ }) !== void 0) {
77
+ t.debug("File already exists: " + c);
78
+ return;
79
+ }
80
+ const b = e.split("/").slice(0, -1).join("/");
81
+ b && await q(a(o, b), { recursive: !0 }), t.info("Creating file: " + c), await C(c, u), await j(c);
82
+ });
83
+ await Promise.all(y);
84
+ const w = z(r, o) || ".", m = a(r, ".saltyrc.json"), f = await S(m, "utf-8").catch(() => {
85
+ });
86
+ if (f === void 0) {
87
+ t.info("Creating file: " + m);
88
+ const u = JSON.stringify({
89
+ $schema: "./node_modules/@salty-css/core/.saltyrc.schema.json",
90
+ 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.",
91
+ defaultProject: w,
92
+ projects: [
93
+ {
94
+ dir: w,
95
+ framework: "react"
96
+ }
97
+ ]
98
+ }, null, 2);
99
+ await C(m, u), await j(m);
100
+ } else {
101
+ const e = JSON.parse(f), u = (e == null ? void 0 : e.projects) || [];
102
+ if (u.findIndex((s) => s.dir === w) === -1) {
103
+ u.push({ dir: w, framework: "react" }), e.projects = [...u];
104
+ const s = JSON.stringify(e, null, 2);
105
+ s !== f && (t.info("Edit file: " + m), await C(m, s), await j(m));
106
+ }
107
+ }
108
+ const k = a(r, ".gitignore"), H = await S(k, "utf-8").catch(() => {
109
+ });
110
+ H !== void 0 && (H.includes("saltygen") || (t.info("Edit file: " + k), await C(k, H + `
111
+
112
+ # Salty-CSS
113
+ saltygen
114
+ `)));
115
+ const F = ["src", "public", "assets", "styles", "css", "app"], M = ["styles", "css", "app", "pages"], B = ["index", "styles", "main", "app", "global", "globals"], U = [".css", ".scss", ".sass"], D = await (async () => {
116
+ if (l) return l;
117
+ for (const e of F)
118
+ for (const u of B)
119
+ for (const c of U) {
120
+ const s = a(o, e, u + c);
121
+ if (await S(s, "utf-8").catch(() => {
122
+ }) !== void 0) return z(o, s);
123
+ for (const L of M) {
124
+ const R = a(o, e, L, u + c);
125
+ if (await S(R, "utf-8").catch(() => {
126
+ }) !== void 0) return z(o, R);
127
+ }
128
+ }
129
+ })();
130
+ if (D) {
131
+ const e = a(o, D), u = await S(e, "utf-8").catch(() => {
132
+ });
133
+ if (u !== void 0 && !u.includes("saltygen")) {
134
+ const s = a(e, ".."), L = `@import '${z(s, a(o, "saltygen/index.css"))}';`;
135
+ t.info("Adding global import statement to CSS file: " + e), await C(e, L + `
136
+ ` + u), await j(e);
137
+ }
138
+ } else
139
+ t.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");
140
+ const ae = {
141
+ projectJs: a(o, "eslint.config.js"),
142
+ rootJs: a(r, "eslint.config.js"),
143
+ projectMjs: a(o, "eslint.config.mjs"),
144
+ rootMjs: a(r, "eslint.config.mjs"),
145
+ projectJson: a(o, ".eslintrc.json"),
146
+ rootJson: a(r, ".eslintrc.json")
147
+ }, v = Object.values(ae).find((e) => Q(e));
148
+ if (v) {
149
+ p || await E(A.eslintConfigCore);
150
+ const e = await S(v, "utf-8").catch(() => {
151
+ });
152
+ if (!e) return h("Could not read ESLint config file.");
153
+ if (!e.includes("salty-css"))
154
+ if (t.info("Edit file: " + v), v.endsWith("js")) {
155
+ let s = `import saltyCss from "@salty-css/eslint-config-core/flat";
156
+ ${e}`;
157
+ e.includes("typescript-eslint") ? s.includes(".config(") ? s = s.replace(".config(", ".config(saltyCss,") : t.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.") : s.includes("export default [") ? s = s.replace("export default [", "export default [ saltyCss,") : s.includes("eslintConfig = [") ? s = s.replace("eslintConfig = [", "eslintConfig = [ saltyCss,") : t.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."), await C(v, s), await j(v);
158
+ } else {
159
+ const c = JSON.parse(e);
160
+ c.extends || (c.extends = []), c.extends.push("@salty-css/core");
161
+ const s = JSON.stringify(c, null, 2);
162
+ await C(v, s), await j(v);
163
+ }
164
+ }
165
+ const W = a(o, "vite.config.ts"), V = await S(W, "utf-8").catch(() => {
166
+ });
167
+ if (V !== void 0 && !V.includes("saltyPlugin")) {
168
+ t.info("Edit file: " + W);
169
+ const u = `import { saltyPlugin } from '@salty-css/vite';
170
+ `, s = V.replace(/(plugins: \[)/, `$1
171
+ saltyPlugin(__dirname),`);
172
+ p || await E(`-D ${A.vite}`), t.info("Adding Salty-CSS plugin to Vite config..."), await C(W, u + s), await j(W);
173
+ }
174
+ const _ = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((e) => a(o, e)).find((e) => Q(e));
175
+ if (_) {
176
+ let e = await S(_, "utf-8").catch(() => {
177
+ });
178
+ if (e !== void 0 && !e.includes("withSaltyCss")) {
179
+ let c = !1;
180
+ /\splugins([^=]*)=[^[]\[/.test(e) && !c && (e = e.replace(/\splugins([^=]*)=[^[]\[/, (R, I) => ` plugins${I}= [withSaltyCss,`), c = !0);
181
+ const b = e.includes("module.exports"), L = b ? `const { withSaltyCss } = require('@salty-css/next');
182
+ ` : `import { withSaltyCss } from '@salty-css/next';
183
+ `;
184
+ b && !c ? (e = e.replace(/module.exports = ([^;]+)/, (R, I) => `module.exports = withSaltyCss(${I})`), c = !0) : c || (e = e.replace(/export default ([^;]+)/, (R, I) => `export default withSaltyCss(${I})`)), p || await E(`-D ${A.next}`), t.info("Adding Salty-CSS plugin to Next.js config..."), await C(_, L + e), await j(_);
185
+ }
186
+ }
187
+ const ie = await O().catch(() => h("Could not read package.json file.")).then((e) => (e.scripts || (e.scripts = {}), e.scripts.prepare ? e.scripts.prepare.includes("salty-css") || (t.info("Edit file: " + J), e.scripts.prepare = e.scripts.prepare + " && npx salty-css build") : (t.info("Edit file: " + J), e.scripts.prepare = "npx salty-css build"), e));
188
+ await se(ie), t.info("Running the build to generate initial CSS..."), await K(o), t.info("🎉 Salty CSS project initialized successfully!"), t.info("Next steps:"), t.info("1. Configure variables and templates in `salty.config.ts`"), t.info("2. Create a new component with `npx salty-css generate [component-name]`"), t.info("3. Run `npx salty-css build` to generate the CSS"), t.info("4. Read about the features in the documentation: https://salty-css.dev"), t.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐");
189
+ }), g.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").action(async function(n = Y) {
190
+ t.info("Building the Salty-CSS project...");
191
+ const { dir: i = n, watch: d } = this.opts();
192
+ if (!i) return h("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
193
+ const l = G(i);
194
+ await K(l), d && (t.info("Watching for changes in the project directory..."), re(l, { recursive: !0 }, async (p, r) => {
195
+ await ye(r) ? await K(l, !1, !1) : de(r) && await fe(l, r);
196
+ }));
197
+ }), g.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>", "File to generate.").option("-d, --dir <dir>", "Project directory to generate the file in.").option("-t, --tag <tag>", "HTML tag of the component.", "div").option("-n, --name <name>", "Name of the component.").option("-c, --className <className>", "CSS class of the component.").option("-r, --reactComponent", "Generate a React component as well.").action(async function(n, i = Y) {
198
+ const { file: d = n, dir: l = i, tag: p, name: r, className: o, reactComponent: T = !1 } = this.opts();
199
+ if (!d) return h("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
200
+ if (!l) return h("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
201
+ const y = G(l), w = d.split("/").slice(0, -1).join("/");
202
+ w && await q(a(y, w), { recursive: !0 });
203
+ const m = a(y, d), f = ce(m);
204
+ f.ext || (f.ext = ".ts"), f.name.endsWith(".css") || (f.name = f.name + ".css"), f.base = f.name + f.ext;
205
+ const k = te(f);
206
+ if (await S(k, "utf-8").catch(() => {
207
+ }) !== void 0) {
208
+ t.error("File already exists:", k);
209
+ return;
210
+ }
211
+ let F = pe(r || f.base.replace(/\.css\.\w+$/, ""));
212
+ if (T) {
213
+ const B = F + "Component";
214
+ F = F + "Wrapper";
215
+ const U = f.base.replace(/\.css\.\w+$/, ""), { content: ee } = await x("react/react-vanilla-file.ts", { tag: p, componentName: B, styledComponentName: F, className: o, fileName: U });
216
+ f.name = U.replace(/\.css$/, ""), f.ext = ".tsx", f.base = f.name + f.ext;
217
+ const D = te(f);
218
+ t.info("Generating a new file: " + D), await C(D, ee), await j(D);
219
+ }
220
+ const { content: M } = await x("react/react-styled-file.ts", { tag: p, name: F, className: o });
221
+ t.info("Generating a new file: " + k), await C(k, M), await j(k);
222
+ });
223
+ const Z = async () => {
224
+ const n = a(process.cwd(), "package.json"), i = await O(n).catch((p) => h(p));
225
+ if (!i) return h("Could not read package.json file.");
226
+ const d = { ...i.dependencies, ...i.devDependencies }, l = Object.entries(d).filter(([p]) => p === "salty-css" || p.startsWith("@salty-css/"));
227
+ return l.length ? l : h(
228
+ "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + n
229
+ );
230
+ };
231
+ g.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(n = "latest") {
232
+ const { legacyPeerDeps: i, version: d = n } = this.opts(), l = await Z();
233
+ if (!l) return h("Could not update Salty-CSS packages as any were found in package.json.");
234
+ const p = l.map(([y]) => d === "@" ? `${y}@${N.version}` : `${y}@${d.replace(/^@/, "")}`);
235
+ i ? (t.warn("Using legacy peer dependencies to update packages."), await E(...p, "--legacy-peer-deps")) : await E(...p);
236
+ const r = await Z();
237
+ if (!r) return h("Something went wrong while reading the updated packages.");
238
+ const o = r.reduce((y, [w, m]) => (y[m] || (y[m] = []), y[m].push(w), y), {});
239
+ if (Object.keys(o).length === 1) {
240
+ const w = Object.keys(o)[0].replace(/^\^/, "");
241
+ t.info(`Updated to all Salty CSS packages successfully to ${w}`);
242
+ } else
243
+ for (const [y, w] of Object.entries(o)) {
244
+ const m = y.replace(/^\^/, "");
245
+ t.info(`Updated to ${m}: ${w.join(", ")}`);
246
+ }
247
+ }), g.option("-v, --version", "Show the current version of Salty-CSS.").action(async function() {
248
+ const n = await X();
249
+ t.info("CLI is running: " + n.version);
250
+ const i = a(process.cwd(), "package.json"), d = await O(i).catch((r) => h(r));
251
+ if (!d) return;
252
+ const l = { ...d.dependencies, ...d.devDependencies }, p = Object.keys(l).filter((r) => r === "salty-css" || r.startsWith("@salty-css/"));
253
+ if (!p.length)
254
+ return h(
255
+ "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + i
256
+ );
257
+ for (const r of p)
258
+ t.info(`${r}: ${l[r]}`);
259
+ }), g.parseAsync(process.argv);
260
+ }
261
+ export {
262
+ Je as main
263
+ };
@@ -0,0 +1,3 @@
1
+ export declare const getSaltyRcPath: (dirname: string) => string;
2
+ export declare const getPackageJsonPath: (dirname: string) => string;
3
+ export declare const getPackageJson: (dirname: string) => Promise<any>;
@@ -0,0 +1 @@
1
+ export declare const getFunctionRange: (contents: string, name: string) => Promise<[number, number]>;
@@ -1,11 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=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(z),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`,H=`css/${k}`,I=o.join(s,H);e.push(k),r.writeFileSync(I,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
- `),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
- `);let f=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
4
-
5
- ${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
6
- `)}
7
- ${l}`;if(j.importStrategy!=="component"){const i=n.flat().map(g=>`@import url('./css/${g}');`).join(`
8
- `);f+=i}r.writeFileSync(a,f)}catch(e){console.error(e)}},L=async(t,e)=>{try{const n=[],s=o.join(t,"./saltygen"),a=o.join(s,"index.css");if(O(e)){const j=await E(t),S=await T(e,s);Object.entries(S).forEach(([g,$])=>{if(!$.generator)return;const m=$.generator._withBuildContext({name:g,config:j}),u=`${m.hash}-${m.priority}.css`,h=`css/${u}`,F=o.join(s,h);n.push(u),r.writeFileSync(F,m.css)});const l=r.readFileSync(a,"utf8").split(`
9
- `),b=n.map(g=>`@import url('../saltygen/css/${g}');`),i=[...new Set([...l,...b])].join(`
10
- `);r.writeFileSync(a,i)}}catch(n){console.error(n)}},U=async(t,e)=>{try{const n=o.join(t,"./saltygen");if(O(e)){const a=r.readFileSync(e,"utf8");a.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==a&&await K.writeFile(e,a);const j=await E(t),S=await T(e,n);let l=a;Object.entries(S).forEach(([f,i])=>{var F;if(i.isKeyframes){console.log("value",i);return}if(!i.generator)return;const g=i.generator._withBuildContext({name:f,config:j}),$=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const m=(F=$.at(1))==null?void 0:F.trim(),u=`${f} = styled(${m}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`,h=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");l=l.replace(h,u)});const b=P.toHash(e,6);return j.importStrategy==="component"&&(l=`import '../../saltygen/css/${b}.css';
11
- ${l}`),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error(n)}};exports.compileSaltyFile=T;exports.generateConfigStyles=M;exports.generateCss=A;exports.generateFile=L;exports.isSaltyFile=O;exports.minimizeFile=U;exports.saltyFileExtensions=_;exports.saltyFileRegExp=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-3N79AOBO.cjs");const e=require("../index-O0uhHL8c.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.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,16 +1,24 @@
1
- import { StyleComponentGenerator } from '../generator/style-generator';
2
1
  export declare const saltyFileExtensions: string[];
3
2
  export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
4
3
  export declare const isSaltyFile: (file: string, additional?: string[]) => boolean;
5
- export declare const generateConfigStyles: (dirname: string) => Promise<void>;
6
- export declare const compileSaltyFile: (sourceFilePath: string, outputDirectory: string) => Promise<{
7
- [key: string]: {
8
- generator: StyleComponentGenerator;
9
- isKeyframes?: boolean;
10
- animationName?: string;
11
- css?: string;
4
+ export declare const generateConfigStyles: (dirname: string, configFiles: Set<string>) => Promise<void>;
5
+ export declare const compileSaltyFile: (dirname: string, sourceFilePath: string, outputDirectory: string) => Promise<{
6
+ contents: {
7
+ [key: string]: {
8
+ generator: any;
9
+ isClassName?: boolean;
10
+ isMedia?: boolean;
11
+ isGlobalDefine?: boolean;
12
+ isDefineVariables?: boolean;
13
+ isDefineTemplates?: boolean;
14
+ isKeyframes?: boolean;
15
+ animationName?: string;
16
+ css?: Promise<string>;
17
+ styles?: any;
18
+ };
12
19
  };
20
+ outputFilePath: string;
13
21
  }>;
14
- export declare const generateCss: (dirname: string) => Promise<void>;
15
- export declare const generateFile: (dirname: string, file: string) => Promise<void>;
16
- export declare const minimizeFile: (dirname: string, file: string) => Promise<string | undefined>;
22
+ export declare const generateCss: (dirname: string, prod?: boolean, clean?: boolean) => Promise<void>;
23
+ export declare const generateFile: (dirname: string, file: string, prod?: boolean) => Promise<void>;
24
+ export declare const minimizeFile: (dirname: string, file: string, prod?: boolean) => Promise<string | undefined>;