@salty-css/core 0.4.5 → 0.4.6-feat-astro-css-collector.0
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/dist/bin/index.cjs +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/bin/main.cjs +1 -1
- package/dist/bin/main.js +1 -1
- package/dist/bin/templates.d.ts +7 -7
- package/dist/compiler/get-files.cjs +1 -1
- package/dist/compiler/get-files.js +4 -1
- package/dist/compiler/salty-compiler.cjs +1 -1
- package/dist/compiler/salty-compiler.js +1 -1
- package/dist/css/keyframes.cjs +1 -1
- package/dist/css/keyframes.js +1 -1
- package/dist/factories/index.cjs +1 -1
- package/dist/factories/index.js +1 -1
- package/dist/generators/index.cjs +1 -1
- package/dist/generators/index.js +1 -1
- package/dist/{generators-Drnkwo8s.js → generators-DAdl36fA.js} +5 -5
- package/dist/generators-DZKr85A5.cjs +1 -0
- package/dist/helpers/index.cjs +1 -1
- package/dist/instances/classname-instance.cjs +1 -1
- package/dist/instances/classname-instance.js +9 -3
- package/dist/{main-3GC2lwLY.js → main-BVs2D1Kc.js} +56 -52
- package/dist/main-D_Tzl7kF.cjs +11 -0
- package/dist/{parse-styles-iylx7U1R.js → parse-styles-Cz2VD8e7.js} +6 -4
- package/dist/parse-styles-rgixHoC7.cjs +3 -0
- package/dist/parsers/index.cjs +3 -3
- package/dist/parsers/index.js +16 -14
- package/dist/{chunk-CMqjfN_6.cjs → rolldown-runtime-BocRIvOZ.cjs} +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/salty-compiler-B6rmZXo5.cjs +34 -0
- package/dist/{salty-compiler-CfYjQZDA.js → salty-compiler-DjKIsORy.js} +76 -54
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +2 -4
- package/package.json +1 -1
- package/dist/generators-BVhdBePh.cjs +0 -1
- package/dist/main-wweiiOF1.cjs +0 -11
- package/dist/parse-styles-B51bN86A.cjs +0 -3
- package/dist/salty-compiler-CFuCIw5V.cjs +0 -34
package/dist/bin/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require("../main-
|
|
2
|
+
require("../main-D_Tzl7kF.cjs").t().catch(e=>console.error(e));
|
package/dist/bin/index.js
CHANGED
package/dist/bin/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../main-D_Tzl7kF.cjs");exports.main=e.t;
|
package/dist/bin/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../main-
|
|
1
|
+
import { t as e } from "../main-BVs2D1Kc.js";
|
|
2
2
|
export { e as main };
|
package/dist/bin/templates.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare const templateLoaders: {
|
|
2
|
-
readonly 'salty.config.ts': () => Promise<typeof import(
|
|
3
|
-
readonly 'styles/index.css': () => Promise<typeof import(
|
|
4
|
-
readonly 'saltygen/index.css': () => Promise<typeof import(
|
|
5
|
-
readonly 'react/styled-file.ts': () => Promise<typeof import(
|
|
6
|
-
readonly 'react/vanilla-file.ts': () => Promise<typeof import(
|
|
7
|
-
readonly 'astro/styled-file.ts': () => Promise<typeof import(
|
|
8
|
-
readonly 'astro/component.astro': () => Promise<typeof import(
|
|
2
|
+
readonly 'salty.config.ts': () => Promise<typeof import('*__template')>;
|
|
3
|
+
readonly 'styles/index.css': () => Promise<typeof import('*__template')>;
|
|
4
|
+
readonly 'saltygen/index.css': () => Promise<typeof import('*__template')>;
|
|
5
|
+
readonly 'react/styled-file.ts': () => Promise<typeof import('*__template')>;
|
|
6
|
+
readonly 'react/vanilla-file.ts': () => Promise<typeof import('*__template')>;
|
|
7
|
+
readonly 'astro/styled-file.ts': () => Promise<typeof import('*__template')>;
|
|
8
|
+
readonly 'astro/component.astro': () => Promise<typeof import('*__template')>;
|
|
9
9
|
};
|
|
10
10
|
export type TemplateKey = keyof typeof templateLoaders;
|
|
11
11
|
export declare const readTemplate: <T extends object>(key: TemplateKey, options?: T) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("fs"),t=require("path"),n=require("fs/promises");var r=n=>{if(!n||n===`/`)throw Error(`Could not find .saltyrc.json file`);let i=(0,t.join)(n,`.saltyrc.json`);return(0,e.existsSync)(i)?i:r((0,t.join)(n,`..`))},i=n=>{if(!n||n===`/`)throw Error(`Could not find package.json file`);let r=(0,t.join)(n,`package.json`);return(0,e.existsSync)(r)?r:i((0,t.join)(n,`..`))},a=async e=>await(0,n.readFile)(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("fs"),t=require("path"),n=require("fs/promises");var r=n=>{if(!n||n===`/`)throw Error(`Could not find .saltyrc.json file`);let i=(0,t.join)(n,`.saltyrc.json`);return(0,e.existsSync)(i)?i:r((0,t.join)(n,`..`))},i=n=>{if(!n||n===`/`)throw Error(`Could not find package.json file`);let r=(0,t.join)(n,`package.json`);return(0,e.existsSync)(r)?r:i((0,t.join)(n,`..`))},a=async e=>{let t=i(e);return await(0,n.readFile)(t,`utf-8`).then(JSON.parse).catch(()=>void 0)};exports.getPackageJson=a,exports.getPackageJsonPath=i,exports.getSaltyRcPath=r;
|
|
@@ -10,6 +10,9 @@ var r = (n) => {
|
|
|
10
10
|
if (!n || n === "/") throw Error("Could not find package.json file");
|
|
11
11
|
let r = t(n, "package.json");
|
|
12
12
|
return e(r) ? r : i(t(n, ".."));
|
|
13
|
-
}, a = async (e) =>
|
|
13
|
+
}, a = async (e) => {
|
|
14
|
+
let t = i(e);
|
|
15
|
+
return await n(t, "utf-8").then(JSON.parse).catch(() => void 0);
|
|
16
|
+
};
|
|
14
17
|
//#endregion
|
|
15
18
|
export { a as getPackageJson, i as getPackageJsonPath, r as getSaltyRcPath };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../salty-compiler-B6rmZXo5.cjs");exports.SaltyCompiler=e.t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../salty-compiler-
|
|
1
|
+
import { t as e } from "../salty-compiler-DjKIsORy.js";
|
|
2
2
|
export { e as SaltyCompiler };
|
package/dist/css/keyframes.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../parse-styles-rgixHoC7.cjs");var n=({animationName:n,params:r,appendInitialStyles:i,...a})=>{let o=async(o={})=>{let s=n||e.toHash(a),c=async()=>{let{duration:e=`500ms`,easing:n=`ease-in-out`,delay:c=`0s`,iterationCount:l=`1`,direction:u=`normal`,fillMode:d=`forwards`,playState:f=`running`}={...r,...o},p=`${s} ${e} ${n} ${c} ${l} ${u} ${d} ${f}`;if(!i)return p;let m=a.from||a[`0%`];return m?`${p};${await t.t(m,``)}`:p},l=Object.entries(a).map(async([e,n])=>{if(!n)return``;let r=await t.t(n,``);return`${/^-?\d+$/.test(e)?`${e}%`:e}{${r}}`}),u=`@keyframes ${s} {${(await Promise.all(l)).join(``)}}`;return Object.assign(c,{toString:c,isKeyframes:!0,animationName:s,css:u,keyframes:a}),c};return Object.assign(o,{_shouldResolve:!0}),o};exports.keyframes=n;
|
package/dist/css/keyframes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toHash as e } from "../util/index.js";
|
|
2
|
-
import { t } from "../parse-styles-
|
|
2
|
+
import { t } from "../parse-styles-Cz2VD8e7.js";
|
|
3
3
|
//#region src/css/keyframes.ts
|
|
4
4
|
var n = ({ animationName: n, params: r, appendInitialStyles: i, ...a }) => {
|
|
5
5
|
let o = async (o = {}) => {
|
package/dist/factories/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../css/media.cjs");var n={woff2:`woff2`,woff:`woff`,ttf:`truetype`,otf:`opentype`,eot:`embedded-opentype`,svg:`svg`,ttc:`collection`},r=e=>{let t=e.split(`?`)[0].split(`#`)[0],r=t.lastIndexOf(`.`);
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../util/index.cjs"),t=require("../css/media.cjs");var n={woff2:`woff2`,woff:`woff`,ttf:`truetype`,otf:`opentype`,eot:`embedded-opentype`,svg:`svg`,ttc:`collection`},r=e=>{let t=e.split(`?`)[0].split(`#`)[0],r=t.lastIndexOf(`.`);return r===-1?void 0:n[t.slice(r+1).toLowerCase()]},i=e=>typeof e==`string`?{url:e,format:r(e)}:e,a=e=>Array.isArray(e)?e.map(i):[i(e)],o=t=>{let n=t.trim().replace(/^--/,``);if(!n)throw Error(`defineFont: invalid \`variable\` value "${t}".`);return`--${e.dashCase(n)}`},s=t=>{let n=[t.name,t.fallback,`variants`in t?t.variants:void 0,`import`in t?t.import:void 0];return`--font-${e.dashCase(t.name)}-${e.toHash(n,6)}`},c=e=>/^["'].*["']$/.test(e)?e:/\s/.test(e)?`"${e}"`:e,l=(e,t)=>{let n=c(e);return!t||t.length===0?n:[n,t].join(`, `)},u=e=>{let t=[`url("${e.url}")`];return e.format&&t.push(`format("${e.format}")`),e.tech&&t.push(`tech(${e.tech})`),t.join(` `)},d=(e,t,n)=>{let r=a(t.src);if(r.length===0)throw Error(`defineFont(${e}): variant must declare at least one \`src\`.`);let i=[`font-family: ${c(e)};`,`src: ${r.map(u).join(`, `)};`,`font-display: ${t.display??n};`];return t.weight!==void 0&&i.push(`font-weight: ${t.weight};`),t.style!==void 0&&i.push(`font-style: ${t.style};`),t.stretch!==void 0&&i.push(`font-stretch: ${t.stretch};`),t.unicodeRange!==void 0&&i.push(`unicode-range: ${t.unicodeRange};`),t.ascentOverride!==void 0&&i.push(`ascent-override: ${t.ascentOverride};`),t.descentOverride!==void 0&&i.push(`descent-override: ${t.descentOverride};`),t.lineGapOverride!==void 0&&i.push(`line-gap-override: ${t.lineGapOverride};`),t.sizeAdjust!==void 0&&i.push(`size-adjust: ${t.sizeAdjust};`),`@font-face { ${i.join(` `)} }`},f=class{_options;variable;fontFamily;className;constructor(t){if(this._options=t,!t||!t.name)throw Error("defineFont: `name` is required.");if(`variants`in t&&`import`in t&&t.import!==void 0&&t.variants!==void 0)throw Error("defineFont: provide either `variants` or `import`, not both.");if(!(`variants`in t&&t.variants)&&!(`import`in t&&t.import))throw Error("defineFont: must provide either `variants` or `import`.");this.variable=t.variable?o(t.variable):s(t),this.fontFamily=l(t.name,t.fallback),this.className=`font-${e.dashCase(t.name)}`}get isDefineFont(){return!0}toString(){return this.fontFamily}get style(){return{fontFamily:this.fontFamily,[this.variable]:this.fontFamily}}_toCss(){let e=[],t=[];if(`import`in this._options&&this._options.import)e.push(`@import url("${this._options.import}");`);else if(`variants`in this._options&&this._options.variants){let e=this._options.display??`swap`;for(let n of this._options.variants)t.push(d(this._options.name,n,e))}return t.push(`:root { ${this.variable}: ${this.fontFamily}; }`,`.${this.className} { font-family: var(${this.variable}); }`),{imports:e,body:t.join(` `)}}},p=e=>new f(e),m=class{_current;constructor(e){this._current=e}get isGlobalDefine(){return!0}},h=e=>new m(e),g=class{_current;_path;constructor(e){this._current=e}get isDefineImport(){return!0}_setPath(e){return this._path=e,this}},_=(...e)=>new g(e),v=e=>e(t.media),y=class{_current;constructor(e){this._current=e}get isDefineVariables(){return!0}},b=e=>new y(e),x=class{params;_path;constructor(e){this.params=e}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(e){return this._path=e,this}},S=class{params;_path;templates=[];constructor(e){this.params=e,Object.entries(e).forEach(([e,t])=>{this.templates.push(new x({name:e,template:t}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(e=>[e.params.name,e]))}get isDefineTemplates(){return!0}_setPath(e){return this._path=e,this.templates.forEach(t=>t._setPath(e)),this}},C=e=>new S(e);exports.FontFactory=f,exports.GlobalStylesFactory=m,exports.ImportFactory=g,exports.TemplateFactory=x,exports.TemplatesFactory=S,exports.VariablesFactory=y,exports.defineFont=p,exports.defineGlobalStyles=h,exports.defineImport=_,exports.defineMediaQuery=v,exports.defineTemplates=C,exports.defineVariables=b;
|
package/dist/factories/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var r = {
|
|
|
11
11
|
ttc: "collection"
|
|
12
12
|
}, i = (e) => {
|
|
13
13
|
let t = e.split("?")[0].split("#")[0], n = t.lastIndexOf(".");
|
|
14
|
-
|
|
14
|
+
return n === -1 ? void 0 : r[t.slice(n + 1).toLowerCase()];
|
|
15
15
|
}, a = (e) => typeof e == "string" ? {
|
|
16
16
|
url: e,
|
|
17
17
|
format: i(e)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-DZKr85A5.cjs");exports.ClassNameGenerator=e.n,exports.StyledGenerator=e.t;
|
package/dist/generators/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "../generators-
|
|
1
|
+
import { n as e, t } from "../generators-DAdl36fA.js";
|
|
2
2
|
export { e as ClassNameGenerator, t as StyledGenerator };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dashCase as e, toHash as t } from "./util/index.js";
|
|
2
|
-
import { i as n, t as r } from "./parse-styles-
|
|
2
|
+
import { i as n, t as r } from "./parse-styles-Cz2VD8e7.js";
|
|
3
3
|
//#region src/generators/styles-generator.ts
|
|
4
4
|
var i = class {
|
|
5
5
|
params;
|
|
@@ -26,7 +26,7 @@ var i = class {
|
|
|
26
26
|
return this.hash;
|
|
27
27
|
}
|
|
28
28
|
get classNames() {
|
|
29
|
-
let e = new Set([this.cssClassName]), { className: t } = this.params;
|
|
29
|
+
let e = /* @__PURE__ */ new Set([this.cssClassName]), { className: t } = this.params;
|
|
30
30
|
return typeof t == "string" && e.add(t), typeof t == "object" && t.forEach((t) => e.add(t)), this.getTemplateClasses().forEach((t) => e.add(t)), this.buildContext.classNames && this.buildContext.classNames.forEach((t) => e.add(t)), [...e].join(" ");
|
|
31
31
|
}
|
|
32
32
|
get cssFileName() {
|
|
@@ -34,13 +34,13 @@ var i = class {
|
|
|
34
34
|
return t ? `cl_${e(t)}-${this.hash}.css` : `${this.hash}.css`;
|
|
35
35
|
}
|
|
36
36
|
get css() {
|
|
37
|
-
let { base: e = {}, variants: t = {}, compoundVariants: n = [], anyOfVariants: i = [] } = this.params, { config: a } = this.buildContext
|
|
38
|
-
return r({
|
|
37
|
+
let { base: e = {}, variants: t = {}, compoundVariants: n = [], anyOfVariants: i = [] } = this.params, { config: a } = this.buildContext, o = {
|
|
39
38
|
...e,
|
|
40
39
|
variants: t,
|
|
41
40
|
compoundVariants: n,
|
|
42
41
|
anyOfVariants: i
|
|
43
|
-
}
|
|
42
|
+
};
|
|
43
|
+
return r(o, `.${this.cssClassName}`, a, this.isRoot);
|
|
44
44
|
}
|
|
45
45
|
getTemplateClasses(r = this.buildContext.config) {
|
|
46
46
|
if (!r?.templates || !this.params.base || this.priority > 0) return [];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./util/index.cjs"),t=require("./parse-styles-rgixHoC7.cjs");var n=class{params;buildContext={};constructor(e){this.params=e}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){let{base:t,variants:n,compoundVariants:r,anyOfVariants:i}=this.params;return e.toHash({base:t,variants:n,compoundVariants:r,anyOfVariants:i})}get cssClassName(){return this.hash}get classNames(){let e=new Set([this.cssClassName]),{className:t}=this.params;return typeof t==`string`&&e.add(t),typeof t==`object`&&t.forEach(t=>e.add(t)),this.getTemplateClasses().forEach(t=>e.add(t)),this.buildContext.classNames&&this.buildContext.classNames.forEach(t=>e.add(t)),[...e].join(` `)}get cssFileName(){let{callerName:t}=this.buildContext;return t?`cl_${e.dashCase(t)}-${this.hash}.css`:`${this.hash}.css`}get css(){let{base:e={},variants:n={},compoundVariants:r=[],anyOfVariants:i=[]}=this.params,{config:a}=this.buildContext,o={...e,variants:n,compoundVariants:r,anyOfVariants:i};return t.t(o,`.${this.cssClassName}`,a,this.isRoot)}getTemplateClasses(n=this.buildContext.config){if(!n?.templates||!this.params.base||this.priority>0)return[];let r=Object.keys(n.templates);return Object.entries(this.params.base).reduce((n,[i,a])=>{if(!r.includes(i))return n;let o=t.i(a);if(!o||o.path.length===0)return n;let{path:s,variants:c}=o,l=[];for(let t of s){l.push(t);let r=e.dashCase(`${i}-${l.join(`.`)}`);n.push(`t_`+e.toHash(r,4));for(let[t,i]of Object.entries(c)){if(i===!1||i===void 0)continue;let a=i===!0?``:`-${e.dashCase(String(i))}`,o=`${r}-${e.dashCase(t)}${a}`;n.push(`tv_`+e.toHash(o,4))}}return n},[])}_withBuildContext(e){return this.buildContext=e,this}},r=class extends n{_params;constructor(e){super(e),this._params=e}get priority(){return this.params.priority?this.params.priority:0}},i=class extends n{tagName;_params;constructor(e,t){super(t),this.tagName=e,this._params=t}get priority(){return this.params.priority?this.params.priority:this.tagName&&(typeof this.tagName==`function`||typeof this.tagName==`object`)?(this.tagName.generator?.priority||0)+1:0}get clientProps(){let{element:t,as:n,variants:r={},compoundVariants:i=[],anyOfVariants:a=[],defaultVariants:o={},defaultProps:s={},passProps:c}=this.params,l=n??t,{callerName:u,isProduction:d}=this.buildContext,f=new Set([]),p=e=>{let t=o[e];t===void 0?f.add(e):f.add(`${e}=${String(t)}`)};Object.keys(r).forEach(p),i.map(e=>Object.keys(e).forEach(p)),a.map(e=>Object.keys(e).forEach(p));let m=new Set([]);if(this.params.base){let t=JSON.stringify(this.params.base).match(/\{-?props\.([^}]+)\}/gi);t&&t.forEach(t=>{let n=t.replace(/\{(?:-)?props\.([^}]+)\}/gi,`$1`),r=e.dashCase(n);n&&m.add(r)})}return{element:l,hash:this.hash,variantKeys:[...f],propValueKeys:[...m],passProps:c,defaultProps:s,attr:{"data-component-name":d?void 0:u}}}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BocRIvOZ.cjs"),t=require("../viewport-clamp-CHOyzt37.cjs");let n=require("color");n=e.t(n,1);var r=class{base;isColor=!0;currentColor;constructor(e){this.base=e;let t=this._resolveBaseColor(e);return this.currentColor=(0,n.default)(t),this._createProxy()}_createProxy(){return new Proxy(this,{get(e,t){return t in e?e[t]:t in e.currentColor?e._handleColorMethod(t):e[t]}})}_resolveBaseColor(e){if(typeof e!=`string`||!/\{[^{}]+\}/g.test(e))return e;if(typeof saltyConfig>`u`)return`transparent`;let{staticVariables:t}=saltyConfig;return t?e.replace(/^\{|\}$/g,``).split(`.`).reduce((e,t)=>e[t],t):`transparent`}_handleColorMethod(e){let t=this.currentColor;return typeof t[e]==`function`?(...n)=>(this.currentColor=t[e](...n),this._createProxy()):t[e]}toString(){return this.currentColor.toString()}},i=e=>new r(e);exports.color=i,exports.defineViewportClamp=t.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../generators-DZKr85A5.cjs");var t=t=>{let n=new e.n(t),r=e=>{let t=new String(e);return Object.assign(t,{get isClassName(){return!0},variant:(e,n)=>{let i=`${e}-${n}`,a=`${t} ${i}`;return r(a)},variants:e=>{let n=Object.entries(e).reduce((e,[t,n])=>(e+=` ${t}-${n}`,e),``),i=`${t}${n}`.trim();return r(i)},generator:n}),t};return r(n.cssClassName)};exports.classNameInstance=t;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "../generators-
|
|
1
|
+
import { n as e } from "../generators-DAdl36fA.js";
|
|
2
2
|
//#region src/instances/classname-instance.ts
|
|
3
3
|
var t = (t) => {
|
|
4
4
|
let n = new e(t), r = (e) => {
|
|
@@ -7,8 +7,14 @@ var t = (t) => {
|
|
|
7
7
|
get isClassName() {
|
|
8
8
|
return !0;
|
|
9
9
|
},
|
|
10
|
-
variant: (e, n) =>
|
|
11
|
-
|
|
10
|
+
variant: (e, n) => {
|
|
11
|
+
let i = `${e}-${n}`, a = `${t} ${i}`;
|
|
12
|
+
return r(a);
|
|
13
|
+
},
|
|
14
|
+
variants: (e) => {
|
|
15
|
+
let n = Object.entries(e).reduce((e, [t, n]) => (e += ` ${t}-${n}`, e), ""), i = `${t}${n}`.trim();
|
|
16
|
+
return r(i);
|
|
17
|
+
},
|
|
12
18
|
generator: n
|
|
13
19
|
}), t;
|
|
14
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./salty-compiler-
|
|
1
|
+
import { n as e, r as t, t as n } from "./salty-compiler-DjKIsORy.js";
|
|
2
2
|
import { isSaltyFile as r } from "./compiler/helpers.js";
|
|
3
3
|
import { pascalCase as i } from "./util/index.js";
|
|
4
4
|
import { checkShouldRestart as a } from "./server/index.js";
|
|
@@ -42,16 +42,16 @@ var b = u(process.cwd(), "package.json"), x = async (e = b) => {
|
|
|
42
42
|
}), D = async (...e) => {
|
|
43
43
|
let t = e.map((e) => e.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), n = _(`Installing packages: ${t}`).start();
|
|
44
44
|
await E(`npm install ${e.join(" ")}`), n.succeed(`Installed packages: ${t}`);
|
|
45
|
-
},
|
|
46
|
-
async function
|
|
45
|
+
}, O = () => s(u(process.cwd(), "node_modules", ".bin", "prettier"));
|
|
46
|
+
async function k(e) {
|
|
47
47
|
try {
|
|
48
|
-
if (!
|
|
48
|
+
if (!O()) return;
|
|
49
49
|
await E(`./node_modules/.bin/prettier --write "${e}"`), t.info(`Formatted ${e} with Prettier`);
|
|
50
50
|
} catch (n) {
|
|
51
51
|
t.error(`Error formatting ${e} with Prettier:`, n);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
var
|
|
54
|
+
var A = (e = process.cwd()) => u(e, ".saltyrc.json"), j = async (e = process.cwd()) => await m(A(e), "utf-8").then(JSON.parse).catch(() => ({})), M = async (e = process.cwd()) => m(A(e), "utf-8").catch(() => void 0), N = async (e = process.cwd()) => (await j(e)).defaultProject, ee = (e, t, n, r = {}) => {
|
|
55
55
|
let i = u(t, n.srcDirectory), a = {
|
|
56
56
|
dir: i,
|
|
57
57
|
framework: n.name,
|
|
@@ -80,30 +80,30 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
80
80
|
changed: c !== e,
|
|
81
81
|
created: !1
|
|
82
82
|
};
|
|
83
|
-
},
|
|
84
|
-
let a =
|
|
85
|
-
return s ? (c ? t.info("Creating file: " + a) : t.info("Edit file: " + a), await h(a, o), await
|
|
86
|
-
},
|
|
87
|
-
let t = process.cwd(), n =
|
|
83
|
+
}, te = async (e, n, r, i = {}) => {
|
|
84
|
+
let a = A(e), { content: o, changed: s, created: c } = ee(await M(e), n, r, i);
|
|
85
|
+
return s ? (c ? t.info("Creating file: " + a) : t.info("Edit file: " + a), await h(a, o), await k(a), !0) : !1;
|
|
86
|
+
}, ne = (e, t) => (e.projects || []).find((e) => e.dir === t)?.framework, P = (e, t = process.cwd()) => u(t, e === "." ? "" : e), F = async (e) => {
|
|
87
|
+
let t = process.cwd(), n = P(e.dir, t), r = f(t, n) || ".", i = await x().catch(() => void 0);
|
|
88
88
|
if (e.requirePackageJson !== !1 && !i) throw Error("Salty CSS project must be initialized in a directory with a package.json file.");
|
|
89
89
|
return {
|
|
90
90
|
cwd: t,
|
|
91
91
|
projectDir: n,
|
|
92
92
|
relativeProjectPath: r,
|
|
93
93
|
packageJson: i,
|
|
94
|
-
rcFile: await
|
|
94
|
+
rcFile: await j(t),
|
|
95
95
|
cliVersion: (await C()).version || "0.0.0",
|
|
96
96
|
skipInstall: !!e.skipInstall,
|
|
97
97
|
yes: !!e.yes
|
|
98
98
|
};
|
|
99
|
-
},
|
|
99
|
+
}, I = (i, o) => {
|
|
100
100
|
i.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.").option("--mode <mode>", "Build mode: \"production\" or \"development\". Defaults to NODE_ENV-based detection.").action(async function(i = o) {
|
|
101
101
|
t.info("Building the Salty-CSS project...");
|
|
102
102
|
let { dir: s = i, watch: l, mode: u } = this.opts();
|
|
103
103
|
if (u !== void 0 && u !== "production" && u !== "development") return e(`Invalid --mode "${u}". Expected "production" or "development".`);
|
|
104
|
-
let d = s ?? await
|
|
104
|
+
let d = s ?? await N();
|
|
105
105
|
if (!d) return e("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
|
106
|
-
let f =
|
|
106
|
+
let f = P(d), p = new n(f, { mode: u });
|
|
107
107
|
await p.generateCss(), l && (t.info("Watching for changes in the project directory..."), c(f, { recursive: !0 }, async (e, t) => {
|
|
108
108
|
if (!t) return console.warn("File path not provided for change event");
|
|
109
109
|
await a(t) ? await p.generateCss(!1) : r(t) && await p.generateFile(t);
|
|
@@ -183,44 +183,44 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
183
183
|
if (!s) return e("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
|
|
184
184
|
let v;
|
|
185
185
|
try {
|
|
186
|
-
v = await
|
|
186
|
+
v = await F({
|
|
187
187
|
dir: s,
|
|
188
188
|
requirePackageJson: !1
|
|
189
189
|
});
|
|
190
190
|
} catch (t) {
|
|
191
191
|
return e(t instanceof Error ? t.message : String(t));
|
|
192
192
|
}
|
|
193
|
-
let y = U(
|
|
193
|
+
let y = U(ne(v.rcFile, v.relativeProjectPath)) ?? await H(v), b = o.split("/").slice(0, -1).join("/");
|
|
194
194
|
b && await p(u(v.projectDir, b), { recursive: !0 });
|
|
195
|
-
let x =
|
|
196
|
-
|
|
197
|
-
let
|
|
198
|
-
if (await m(
|
|
199
|
-
t.error("File already exists: " +
|
|
195
|
+
let x = u(v.projectDir, o), S = d(x);
|
|
196
|
+
S.ext ||= ".ts", S.name.endsWith(".css") || (S.name += ".css"), S.base = S.name + S.ext;
|
|
197
|
+
let C = l(S);
|
|
198
|
+
if (await m(C, "utf-8").catch(() => void 0) !== void 0) {
|
|
199
|
+
t.error("File already exists: " + C);
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
-
let
|
|
202
|
+
let w = i(f || S.base.replace(/\.css\.\w+$/, ""));
|
|
203
203
|
if (_) {
|
|
204
204
|
if (!y.templates.component) return e(`--reactComponent is not supported for the ${y.name} framework.`);
|
|
205
|
-
let n =
|
|
206
|
-
|
|
207
|
-
let r =
|
|
205
|
+
let n = w + "Component";
|
|
206
|
+
w += "Wrapper";
|
|
207
|
+
let r = S.base.replace(/\.css\.\w+$/, ""), { content: i } = await G(y.templates.component.wrapper, {
|
|
208
208
|
tag: c,
|
|
209
209
|
componentName: n,
|
|
210
|
-
styledComponentName:
|
|
210
|
+
styledComponentName: w,
|
|
211
211
|
className: g,
|
|
212
212
|
fileName: r
|
|
213
213
|
});
|
|
214
|
-
|
|
215
|
-
let a = l(
|
|
216
|
-
t.info("Generating a new file: " + a), await h(a, i), await
|
|
214
|
+
S.name = r.replace(/\.css$/, ""), S.ext = y.templates.component.wrapperExt, S.base = S.name + S.ext;
|
|
215
|
+
let a = l(S);
|
|
216
|
+
t.info("Generating a new file: " + a), await h(a, i), await k(a);
|
|
217
217
|
}
|
|
218
|
-
let { content:
|
|
218
|
+
let { content: T } = await G(_ && y.templates.component ? y.templates.component.styled : y.templates.styled, {
|
|
219
219
|
tag: c,
|
|
220
|
-
name:
|
|
220
|
+
name: w,
|
|
221
221
|
className: g
|
|
222
222
|
});
|
|
223
|
-
t.info("Generating a new file: " +
|
|
223
|
+
t.info("Generating a new file: " + C), await h(C, T), await k(C);
|
|
224
224
|
});
|
|
225
225
|
}, q = (e) => {
|
|
226
226
|
let t = e.trim();
|
|
@@ -306,7 +306,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
306
306
|
let a = i.content;
|
|
307
307
|
return {
|
|
308
308
|
packages: [`-D ${ue(e.cliVersion)}`],
|
|
309
|
-
execute: async () => (t.info("Adding Salty-CSS integration to Astro config: " + n), await h(n, a), await
|
|
309
|
+
execute: async () => (t.info("Adding Salty-CSS integration to Astro config: " + n), await h(n, a), await k(n), { changed: !0 })
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
312
|
}, me = [
|
|
@@ -316,16 +316,20 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
316
316
|
["rootMjs", "eslint.config.mjs"],
|
|
317
317
|
["projectJson", ".eslintrc.json"],
|
|
318
318
|
["rootJson", ".eslintrc.json"]
|
|
319
|
-
], he = (e, t) => me.map(([n, r]) =>
|
|
319
|
+
], he = (e, t) => me.map(([n, r]) => {
|
|
320
|
+
let i = n.startsWith("root") ? t : e;
|
|
321
|
+
return u(i, r);
|
|
322
|
+
}), ge = (e, t) => {
|
|
320
323
|
if (e.includes("salty-css")) return { content: null };
|
|
321
324
|
if (t) {
|
|
322
325
|
let t = `import saltyCss from "@salty-css/eslint-config-core/flat";\n${e}`;
|
|
323
|
-
if (e.includes("typescript-eslint"))
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
if (e.includes("typescript-eslint")) {
|
|
327
|
+
if (t.includes(".config(")) t = t.replace(".config(", ".config(saltyCss,");
|
|
328
|
+
else return {
|
|
329
|
+
content: null,
|
|
330
|
+
warning: "Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."
|
|
331
|
+
};
|
|
332
|
+
} else if (t.includes("export default [")) t = t.replace("export default [", "export default [ saltyCss,");
|
|
329
333
|
else if (t.includes("eslintConfig = [")) t = t.replace("eslintConfig = [", "eslintConfig = [ saltyCss,");
|
|
330
334
|
else return {
|
|
331
335
|
content: null,
|
|
@@ -346,7 +350,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
346
350
|
let a = i.content;
|
|
347
351
|
return {
|
|
348
352
|
packages: [w.eslintConfigCore(e.cliVersion)],
|
|
349
|
-
execute: async () => (t.info("Edit file: " + n), await h(n, a), await
|
|
353
|
+
execute: async () => (t.info("Edit file: " + n), await h(n, a), await k(n), { changed: !0 })
|
|
350
354
|
};
|
|
351
355
|
}
|
|
352
356
|
}, ve = [
|
|
@@ -369,7 +373,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
369
373
|
let { content: i } = be(r);
|
|
370
374
|
return i === null ? null : {
|
|
371
375
|
packages: [`-D ${ye(e.cliVersion)}`],
|
|
372
|
-
execute: async () => (t.info("Adding Salty-CSS plugin to Next.js config..."), await h(n, i), await
|
|
376
|
+
execute: async () => (t.info("Adding Salty-CSS plugin to Next.js config..."), await h(n, i), await k(n), { changed: !0 })
|
|
373
377
|
};
|
|
374
378
|
}
|
|
375
379
|
}, Se = (e) => `@salty-css/vite@${e}`, Ce = (e) => e.includes("saltyPlugin") ? { content: null } : { content: "import { saltyPlugin } from '@salty-css/vite';\n" + e.replace(/(plugins: \[)/, "$1\n saltyPlugin(__dirname),") }, we = [
|
|
@@ -386,7 +390,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
386
390
|
let { content: i } = Ce(r);
|
|
387
391
|
return i === null ? null : {
|
|
388
392
|
packages: [`-D ${Se(e.cliVersion)}`],
|
|
389
|
-
execute: async () => (t.info("Edit file: " + n), t.info("Adding Salty-CSS plugin to Vite config..."), await h(n, i), await
|
|
393
|
+
execute: async () => (t.info("Edit file: " + n), t.info("Adding Salty-CSS plugin to Vite config..."), await h(n, i), await k(n), { changed: !0 })
|
|
390
394
|
};
|
|
391
395
|
}
|
|
392
396
|
},
|
|
@@ -430,7 +434,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
430
434
|
return;
|
|
431
435
|
}
|
|
432
436
|
let a = n.split("/").slice(0, -1).join("/");
|
|
433
|
-
a && await p(u(e, a), { recursive: !0 }), t.info("Creating file: " + i), await h(i, r), await
|
|
437
|
+
a && await p(u(e, a), { recursive: !0 }), t.info("Creating file: " + i), await h(i, r), await k(i);
|
|
434
438
|
}, Q = async (e) => {
|
|
435
439
|
let n = u(e, ".gitignore"), r = await m(n, "utf-8").catch(() => void 0);
|
|
436
440
|
r !== void 0 && (r.includes("saltygen") || (t.info("Edit file: " + n), await h(n, r + "\n\n# Salty-CSS\nsaltygen\n")));
|
|
@@ -447,8 +451,8 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
447
451
|
}
|
|
448
452
|
let i = u(e, r), a = await m(i, "utf-8").catch(() => void 0);
|
|
449
453
|
if (a === void 0 || a.includes("saltygen")) return;
|
|
450
|
-
let o =
|
|
451
|
-
t.info("Adding global import statement to CSS file: " + i), await h(i, `@import '${
|
|
454
|
+
let o = u(i, ".."), s = f(o, u(e, "saltygen/index.css"));
|
|
455
|
+
t.info("Adding global import statement to CSS file: " + i), await h(i, `@import '${s}';\n` + a), await k(i);
|
|
452
456
|
}, Ae = async () => {
|
|
453
457
|
let t = await x().catch(() => {
|
|
454
458
|
e("Could not read package.json file.");
|
|
@@ -461,7 +465,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
461
465
|
try {
|
|
462
466
|
let i = this.opts(), a = i.dir ?? r;
|
|
463
467
|
if (!a) return e("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
|
|
464
|
-
let o = await
|
|
468
|
+
let o = await F({
|
|
465
469
|
dir: a,
|
|
466
470
|
skipInstall: i.skipInstall,
|
|
467
471
|
yes: i.yes
|
|
@@ -485,7 +489,7 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
485
489
|
integrations: l.map((e) => e.name),
|
|
486
490
|
hasSrcDir: s(u(o.projectDir, "src"))
|
|
487
491
|
});
|
|
488
|
-
await
|
|
492
|
+
await te(o.cwd, o.relativeProjectPath, c, m), await Q(o.cwd), await ke(f, i.cssFile), await Ee(l), await Ae(), t.info("Running the build to generate initial CSS..."), await new n(f).generateCss(), 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 ⭐");
|
|
489
493
|
} catch (t) {
|
|
490
494
|
return e(t instanceof Error ? t.message : String(t));
|
|
491
495
|
}
|
|
@@ -516,13 +520,13 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
516
520
|
let e = Object.keys(f)[0];
|
|
517
521
|
t.info(`Updated to all Salty CSS packages successfully to ${e.replace(/^\^/, "")}`);
|
|
518
522
|
} else for (let [e, n] of Object.entries(f)) t.info(`Updated to ${e.replace(/^\^/, "")}: ${n.join(", ")}`);
|
|
519
|
-
let p = s ?? await
|
|
523
|
+
let p = s ?? await N();
|
|
520
524
|
if (!p) {
|
|
521
525
|
t.warn("Skipping rebuild: no project directory configured. Run `salty-css build [dir]` manually.");
|
|
522
526
|
return;
|
|
523
527
|
}
|
|
524
528
|
if (!await X("Rebuild Salty CSS now?", { yes: o })) return;
|
|
525
|
-
let m =
|
|
529
|
+
let m = P(p);
|
|
526
530
|
t.info("Rebuilding Salty-CSS project..."), await new n(m).generateCss(), t.info("Rebuild complete.");
|
|
527
531
|
});
|
|
528
532
|
}, Ne = (n) => {
|
|
@@ -544,8 +548,8 @@ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd
|
|
|
544
548
|
async function Pe() {
|
|
545
549
|
let e = new o();
|
|
546
550
|
e.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
|
|
547
|
-
let t = await
|
|
548
|
-
je(e), Me(e), Ne(e),
|
|
551
|
+
let t = await N();
|
|
552
|
+
je(e), Me(e), Ne(e), I(e, t), K(e, t), e.parseAsync(process.argv);
|
|
549
553
|
}
|
|
550
554
|
//#endregion
|
|
551
555
|
export { Pe as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./salty-compiler-B6rmZXo5.cjs"),n=require("./compiler/helpers.cjs"),r=require("./util/index.cjs"),i=require("./server/index.cjs");let a=require("commander"),o=require("fs"),s=require("path"),c=require("fs/promises"),l=require("child_process"),u=require("ora");u=e.t(u,1);let d=require("ejs");d=e.t(d,1);let f=require("readline/promises");var p=(0,s.join)(process.cwd(),`package.json`),m=async(e=p)=>{let t=await(0,c.readFile)(e,`utf-8`).then(JSON.parse).catch(()=>void 0);if(!t)throw`Could not read package.json file!`;return t},h=async(e,t=p)=>{typeof e==`object`&&(e=JSON.stringify(e,null,2)),await(0,c.writeFile)(t,e)},g=async()=>m(new URL(`../package.json`,``+{}.url)),_={core:e=>`@salty-css/core@${e}`,eslintConfigCore:e=>`@salty-css/eslint-config-core@${e}`},v=e=>{e.scripts||={};let t=e.scripts.prepare;if(t){if(t.includes(`salty-css`))return{changed:!1,pkg:e};e.scripts.prepare=t+` && npx salty-css build`}else e.scripts.prepare=`npx salty-css build`;return{changed:!0,pkg:e}},y=e=>new Promise((t,n)=>{(0,l.exec)(e,e=>{if(e)return n(e);t()})}),b=async(...e)=>{let t=e.map(e=>e.replace(`-D`,``).split(`@`).slice(0,-1).join(`@`).trim()).join(`, `),n=(0,u.default)(`Installing packages: ${t}`).start();await y(`npm install ${e.join(` `)}`),n.succeed(`Installed packages: ${t}`)},x=()=>(0,o.existsSync)((0,s.join)(process.cwd(),`node_modules`,`.bin`,`prettier`));async function S(e){try{if(!x())return;await y(`./node_modules/.bin/prettier --write "${e}"`),t.r.info(`Formatted ${e} with Prettier`)}catch(n){t.r.error(`Error formatting ${e} with Prettier:`,n)}}var C=(e=process.cwd())=>(0,s.join)(e,`.saltyrc.json`),w=async(e=process.cwd())=>await(0,c.readFile)(C(e),`utf-8`).then(JSON.parse).catch(()=>({})),ee=async(e=process.cwd())=>(0,c.readFile)(C(e),`utf-8`).catch(()=>void 0),T=async(e=process.cwd())=>(await w(e)).defaultProject,E=(e,t,n,r={})=>{let i=(0,s.join)(t,n.srcDirectory),a={dir:i,framework:n.name,...r};if(e===void 0)return{content: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:i,projects:[a]},null,2),changed:!0,created:!0};let o=JSON.parse(e),c=o.projects||[];if(c.some(e=>e.dir===i))return{content:e,changed:!1,created:!1};c.push(a),o.projects=[...c];let l=JSON.stringify(o,null,2);return{content:l,changed:l!==e,created:!1}},D=async(e,n,r,i={})=>{let a=C(e),{content:o,changed:s,created:l}=E(await ee(e),n,r,i);return s?(l?t.r.info(`Creating file: `+a):t.r.info(`Edit file: `+a),await(0,c.writeFile)(a,o),await S(a),!0):!1},te=(e,t)=>(e.projects||[]).find(e=>e.dir===t)?.framework,O=(e,t=process.cwd())=>(0,s.join)(t,e===`.`?``:e),k=async e=>{let t=process.cwd(),n=O(e.dir,t),r=(0,s.relative)(t,n)||`.`,i=await m().catch(()=>void 0);if(e.requirePackageJson!==!1&&!i)throw Error(`Salty CSS project must be initialized in a directory with a package.json file.`);return{cwd:t,projectDir:n,relativeProjectPath:r,packageJson:i,rcFile:await w(t),cliVersion:(await g()).version||`0.0.0`,skipInstall:!!e.skipInstall,yes:!!e.yes}},A=(e,r)=>{e.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.`).option(`--mode <mode>`,`Build mode: "production" or "development". Defaults to NODE_ENV-based detection.`).action(async function(e=r){t.r.info(`Building the Salty-CSS project...`);let{dir:a=e,watch:s,mode:c}=this.opts();if(c!==void 0&&c!==`production`&&c!==`development`)return t.n(`Invalid --mode "${c}". Expected "production" or "development".`);let l=a??await T();if(!l)return t.n(`Project directory must be provided. Add it as the first argument after build command or use the --dir option.`);let u=O(l),d=new t.t(u,{mode:c});await d.generateCss(),s&&(t.r.info(`Watching for changes in the project directory...`),(0,o.watch)(u,{recursive:!0},async(e,t)=>{if(!t)return console.warn(`File path not provided for change event`);await i.checkShouldRestart(t)?await d.generateCss(!1):n.isSaltyFile(t)&&await d.generateFile(t)}))})},ne=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.cjs`],j=e=>{for(let t of ne){let n=(0,s.join)(e,t);if((0,o.existsSync)(n))return n}return null},M=e=>{let t=e.packageJson;if(!t)return!1;let n={...t.dependencies,...t.devDependencies};return Object.prototype.hasOwnProperty.call(n,`astro`)},N={name:`astro`,srcDirectory:`src`,detect:e=>!!j(e.projectDir)||M(e),runtimePackage:e=>`@salty-css/astro@${e}`,templates:{styled:`astro/styled-file.ts`,component:{styled:`astro/styled-file.ts`,wrapper:`astro/component.astro`,wrapperExt:`.astro`}}},P={name:`react`,srcDirectory:``,detect:()=>!0,runtimePackage:e=>`@salty-css/react@${e}`,templates:{styled:`react/styled-file.ts`,component:{styled:`react/styled-file.ts`,wrapper:`react/vanilla-file.ts`,wrapperExt:`.tsx`}}},F=[N,P],I={astro:N,react:P},L=async e=>{for(let t of F)if(await t.detect(e))return t;return P},R=e=>{if(e)return I[e]},z={"salty.config.ts":()=>Promise.resolve().then(()=>require("./salty.config-B0ZiRpHR.cjs")),"styles/index.css":()=>Promise.resolve().then(()=>require("./styles_index-DgmdjfFo.cjs")),"saltygen/index.css":()=>Promise.resolve().then(()=>require("./saltygen_index-BGHLaAOm.cjs")),"react/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-BCbAEzBB.cjs")),"react/vanilla-file.ts":()=>Promise.resolve().then(()=>require("./vanilla-file-Z3VsOa_U.cjs")),"astro/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-DorArlCk.cjs")),"astro/component.astro":()=>Promise.resolve().then(()=>require("./astro-component-r0qEcF1p.cjs"))},B=async(e,t)=>{let{default:n}=await z[e]();return{fileName:e,content:d.default.render(n,t)}},V=(e,n)=>{e.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 wrapper component file alongside the styled definition.`).action(async function(e,i=n){let{file:a=e,dir:o=i,tag:l,name:u,className:d,reactComponent:f=!1}=this.opts();if(!a)return t.n(`File to generate must be provided. Add it as the first argument after generate command or use the --file option.`);if(!o)return t.n(`Project directory must be provided. Add it as the second argument after generate command or use the --dir option.`);let p;try{p=await k({dir:o,requirePackageJson:!1})}catch(e){return t.n(e instanceof Error?e.message:String(e))}let m=R(te(p.rcFile,p.relativeProjectPath))??await L(p),h=a.split(`/`).slice(0,-1).join(`/`);h&&await(0,c.mkdir)((0,s.join)(p.projectDir,h),{recursive:!0});let g=(0,s.join)(p.projectDir,a),_=(0,s.parse)(g);_.ext||=`.ts`,_.name.endsWith(`.css`)||(_.name+=`.css`),_.base=_.name+_.ext;let v=(0,s.format)(_);if(await(0,c.readFile)(v,`utf-8`).catch(()=>void 0)!==void 0){t.r.error(`File already exists: `+v);return}let y=r.pascalCase(u||_.base.replace(/\.css\.\w+$/,``));if(f){if(!m.templates.component)return t.n(`--reactComponent is not supported for the ${m.name} framework.`);let e=y+`Component`;y+=`Wrapper`;let n=_.base.replace(/\.css\.\w+$/,``),{content:r}=await B(m.templates.component.wrapper,{tag:l,componentName:e,styledComponentName:y,className:d,fileName:n});_.name=n.replace(/\.css$/,``),_.ext=m.templates.component.wrapperExt,_.base=_.name+_.ext;let i=(0,s.format)(_);t.r.info(`Generating a new file: `+i),await(0,c.writeFile)(i,r),await S(i)}let{content:b}=await B(f&&m.templates.component?m.templates.component.styled:m.templates.styled,{tag:l,name:y,className:d});t.r.info(`Generating a new file: `+v),await(0,c.writeFile)(v,b),await S(v)})},H=e=>{let t=e.trim();return t.startsWith(`-D `)?`${t.slice(3).trim()} (dev)`:t},U=e=>e.map(e=>` + ${H(e)}`).join(`
|
|
2
|
+
`),W=async(e,t,n={})=>{if(t||e.length===0)return;let r=n.input??process.stdin,i=n.output??process.stdout;if(!(n.isTTY??process.stdin.isTTY??!1))throw Error(`Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.`);i.write(`The following packages will be installed:\n${U(e)}\n`);let a=(0,f.createInterface)({input:r,output:i,terminal:!1});try{let e=(await a.question(`Proceed? (y/N) `)).trim().toLowerCase();if(e!==`y`&&e!==`yes`)throw Error(`Install cancelled by user.`)}finally{a.close()}},G=async(e,t={})=>{if(t.yes)return!0;let n=t.input??process.stdin,r=t.output??process.stdout;if(!(t.isTTY??process.stdin.isTTY??!1))return!1;let i=t.defaultYes?`(Y/n)`:`(y/N)`,a=(0,f.createInterface)({input:n,output:r,terminal:!1});try{let n=(await a.question(`${e} ${i} `)).trim().toLowerCase();return n===``?!!t.defaultYes:n===`y`||n===`yes`}finally{a.close()}},K=[`src`,`public`,`assets`,`styles`,`css`,`app`],q=[`styles`,`css`,`app`,`pages`],J=[`index`,`styles`,`main`,`app`,`global`,`globals`],Y=[`.css`,`.scss`,`.sass`],X=async e=>{for(let t of K)for(let n of J)for(let r of Y){let i=(0,s.join)(e,t,n+r);if(await(0,c.readFile)(i,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,i);for(let i of q){let a=(0,s.join)(e,t,i,n+r);if(await(0,c.readFile)(a,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,a)}}},Z=e=>`@salty-css/astro@${e}`,re=`import saltyIntegration from '@salty-css/astro/integration';
|
|
3
|
+
`,ie=e=>{if(e.includes(`@salty-css/astro`))return{content:null};let t=e,n=!1;return/integrations\s*:\s*\[/.test(t)?(t=t.replace(/integrations\s*:\s*\[/,e=>`${e}saltyIntegration(),`),n=!0):/defineConfig\s*\(\s*\{/.test(t)&&(t=t.replace(/defineConfig\s*\(\s*\{/,e=>`${e}\n integrations: [saltyIntegration()],`),n=!0),n?{content:re+t}:{content:null,warning:`Could not find a place to add saltyIntegration() in the Astro config. Please add it manually.`}},ae={name:`astro`,detect:e=>j(e.projectDir),plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let i=ie(r);if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[`-D ${Z(e.cliVersion)}`],execute:async()=>(t.r.info(`Adding Salty-CSS integration to Astro config: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},oe=[[`projectJs`,`eslint.config.js`],[`rootJs`,`eslint.config.js`],[`projectMjs`,`eslint.config.mjs`],[`rootMjs`,`eslint.config.mjs`],[`projectJson`,`.eslintrc.json`],[`rootJson`,`.eslintrc.json`]],se=(e,t)=>oe.map(([n,r])=>{let i=n.startsWith(`root`)?t:e;return(0,s.join)(i,r)}),ce=(e,t)=>{if(e.includes(`salty-css`))return{content:null};if(t){let t=`import saltyCss from "@salty-css/eslint-config-core/flat";\n${e}`;if(e.includes(`typescript-eslint`)){if(t.includes(`.config(`))t=t.replace(`.config(`,`.config(saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`}}else if(t.includes(`export default [`))t=t.replace(`export default [`,`export default [ saltyCss,`);else if(t.includes(`eslintConfig = [`))t=t.replace(`eslintConfig = [`,`eslintConfig = [ saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};return{content:t}}let n=JSON.parse(e);return n.extends||=[],n.extends.includes(`@salty-css/core`)||n.extends.push(`@salty-css/core`),{content:JSON.stringify(n,null,2)}},le={name:`eslint`,detect:e=>se(e.projectDir,e.cwd).find(e=>(0,o.existsSync)(e))??null,plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return t.r.error(`Could not read ESLint config file.`),null;let i=ce(r,n.endsWith(`js`));if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[_.eslintConfigCore(e.cliVersion)],execute:async()=>(t.r.info(`Edit file: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},ue=[`next.config.js`,`next.config.cjs`,`next.config.ts`,`next.config.mjs`],de=e=>`@salty-css/next@${e}`,fe=e=>{if(e.includes(`withSaltyCss`))return{content:null};let t=e,n=!1;/\splugins([^=]*)=[^[]\[/.test(t)&&(t=t.replace(/\splugins([^=]*)=[^[]\[/,(e,t)=>` plugins${t}= [withSaltyCss,`),n=!0);let r=t.includes(`module.exports`),i=r?`const { withSaltyCss } = require('@salty-css/next');
|
|
4
|
+
`:`import { withSaltyCss } from '@salty-css/next';
|
|
5
|
+
`;return r&&!n?(t=t.replace(/module.exports = ([^;]+)/,(e,t)=>`module.exports = withSaltyCss(${t})`),n=!0):n||(t=t.replace(/export default ([^;]+)/,(e,t)=>`export default withSaltyCss(${t})`)),{content:i+t}},pe={name:`next`,detect:e=>ue.map(t=>(0,s.join)(e.projectDir,t)).find(e=>(0,o.existsSync)(e))??null,plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let{content:i}=fe(r);return i===null?null:{packages:[`-D ${de(e.cliVersion)}`],execute:async()=>(t.r.info(`Adding Salty-CSS plugin to Next.js config...`),await(0,c.writeFile)(n,i),await S(n),{changed:!0})}}},me=e=>`@salty-css/vite@${e}`,he=e=>e.includes(`saltyPlugin`)?{content:null}:{content:`import { saltyPlugin } from '@salty-css/vite';
|
|
6
|
+
`+e.replace(/(plugins: \[)/,`$1
|
|
7
|
+
saltyPlugin(__dirname),`)},ge=[le,{name:`vite`,detect:e=>{let t=(0,s.join)(e.projectDir,`vite.config.ts`);return(0,o.existsSync)(t)?t:null},plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let{content:i}=he(r);return i===null?null:{packages:[`-D ${me(e.cliVersion)}`],execute:async()=>(t.r.info(`Edit file: `+n),t.r.info(`Adding Salty-CSS plugin to Vite config...`),await(0,c.writeFile)(n,i),await S(n),{changed:!0})}}},pe,ae],_e=async e=>{let t=[];for(let n of ge){let r=await n.detect(e);if(!r)continue;let i=await n.plan(e,r);i&&t.push({name:n.name,configPath:r,plan:i})}return t},ve=async e=>{let t=[];for(let{name:n,configPath:r,plan:i}of e){let e=await i.execute();t.push({name:n,configPath:r,changed:e.changed})}return t},ye={vite:[`dist/**`],next:[`.next/**`,`out/**`]},be=({framework:e,integrations:t,hasSrcDir:n})=>{if(e===`astro`)return{};let r=[...new Set(t.flatMap(e=>ye[e]??[]))],i={};return n&&(i.include=[`src/**`]),r.length&&(i.exclude=r),i},Q=async(e,n,r)=>{let i=(0,s.join)(e,n);if((0,o.existsSync)(i)){t.r.debug(`File already exists: `+i);return}let a=n.split(`/`).slice(0,-1).join(`/`);a&&await(0,c.mkdir)((0,s.join)(e,a),{recursive:!0}),t.r.info(`Creating file: `+i),await(0,c.writeFile)(i,r),await S(i)},xe=async e=>{let n=(0,s.join)(e,`.gitignore`),r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);r!==void 0&&(r.includes(`saltygen`)||(t.r.info(`Edit file: `+n),await(0,c.writeFile)(n,r+`
|
|
8
|
+
|
|
9
|
+
# Salty-CSS
|
|
10
|
+
saltygen
|
|
11
|
+
`)))},Se=async(e,n)=>{let r=n??await X(e);if(!r){if(!await G("Could not find a CSS file to import the generated CSS. Do you want to create a new `styles/index.css` file and import it there? (y/N) ")){t.r.warn(`Could not find a CSS file to import the generated CSS. Please add it manually.`);return}let{fileName:n,content:r}=await B(`styles/index.css`);await Q(e,n,r);return}let i=(0,s.join)(e,r),a=await(0,c.readFile)(i,`utf-8`).catch(()=>void 0);if(a===void 0||a.includes(`saltygen`))return;let o=(0,s.join)(i,`..`),l=(0,s.relative)(o,(0,s.join)(e,`saltygen/index.css`));t.r.info(`Adding global import statement to CSS file: `+i),await(0,c.writeFile)(i,`@import '${l}';\n`+a),await S(i)},Ce=async()=>{let e=await m().catch(()=>{t.n(`Could not read package.json file.`)});if(!e)return;let{pkg:n}=v(e);await h(n)},we=e=>{e.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.`).option(`-y, --yes`,`Skip the install confirmation prompt.`).action(async function(e=`.`){try{let n=this.opts(),r=n.dir??e;if(!r)return t.n(`Project directory must be provided. Add it as the first argument after init command or use the --dir option.`);let i=await k({dir:r,skipInstall:n.skipInstall,yes:n.yes});t.r.info(`Initializing a new Salty-CSS project!`);let a=await L(i);t.r.info(`Detected framework: ${a.name}`);let l=await _e(i);if(!i.skipInstall){let e=[_.core(i.cliVersion),a.runtimePackage(i.cliVersion),...l.flatMap(e=>e.plan.packages)];await W(e,i.yes),await b(...e)}let u=await Promise.all([B(`salty.config.ts`),B(`saltygen/index.css`)]),d=(0,s.join)(i.projectDir,a.srcDirectory);await(0,c.mkdir)(d,{recursive:!0}),await Promise.all(u.map(({fileName:e,content:t})=>Q(d,e,t)));let f=be({framework:a.name,integrations:l.map(e=>e.name),hasSrcDir:(0,o.existsSync)((0,s.join)(i.projectDir,`src`))});await D(i.cwd,i.relativeProjectPath,a,f),await xe(i.cwd),await Se(d,n.cssFile),await ve(l),await Ce(),t.r.info(`Running the build to generate initial CSS...`),await new t.t(d).generateCss(),t.r.info(`🎉 Salty CSS project initialized successfully!`),t.r.info(`Next steps:`),t.r.info("1. Configure variables and templates in `salty.config.ts`"),t.r.info("2. Create a new component with `npx salty-css generate [component-name]`"),t.r.info("3. Run `npx salty-css build` to generate the CSS"),t.r.info(`4. Read about the features in the documentation: https://salty-css.dev`),t.r.info(`5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐`)}catch(e){return t.n(e instanceof Error?e.message:String(e))}})},$=async()=>{let e=(0,s.join)(process.cwd(),`package.json`),n=await m(e).catch(e=>t.n(e));if(!n)return t.n(`Could not read package.json file.`);let r={...n.dependencies,...n.devDependencies},i=Object.entries(r).filter(([e])=>e===`salty-css`||e.startsWith(`@salty-css/`));return i.length?i:t.n(`No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: `+e)},Te=e=>{e.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).option(`-y, --yes`,`Skip confirmation prompts (install and rebuild).`).option(`-d, --dir <dir>`,`Project directory to rebuild after updating.`).action(async function(e=`latest`){let{legacyPeerDeps:n,version:r=e,yes:i=!1,dir:a}=this.opts(),o=await $();if(!o)return t.n(`Could not update Salty-CSS packages as any were found in package.json.`);let s=await g(),c=o.map(([e])=>r===`@`?`${e}@${s.version}`:`${e}@${r.replace(/^@/,``)}`);try{await W(c,i)}catch(e){return t.n(e instanceof Error?e.message:String(e))}n?(t.r.warn(`Using legacy peer dependencies to update packages.`),await b(...c,`--legacy-peer-deps`)):await b(...c);let l=await $();if(!l)return t.n(`Something went wrong while reading the updated packages.`);let u=l.reduce((e,[t,n])=>(e[n]||(e[n]=[]),e[n].push(t),e),{});if(Object.keys(u).length===1){let e=Object.keys(u)[0];t.r.info(`Updated to all Salty CSS packages successfully to ${e.replace(/^\^/,``)}`)}else for(let[e,n]of Object.entries(u))t.r.info(`Updated to ${e.replace(/^\^/,``)}: ${n.join(`, `)}`);let d=a??await T();if(!d){t.r.warn("Skipping rebuild: no project directory configured. Run `salty-css build [dir]` manually.");return}if(!await G(`Rebuild Salty CSS now?`,{yes:i}))return;let f=O(d);t.r.info(`Rebuilding Salty-CSS project...`),await new t.t(f).generateCss(),t.r.info(`Rebuild complete.`)})},Ee=e=>{e.option(`-v, --version`,`Show the current version of Salty-CSS.`).action(async function(){let e=await g();t.r.info(`CLI is running: `+e.version);let n=(0,s.join)(process.cwd(),`package.json`),r=await m(n).catch(e=>t.n(e));if(!r)return;let i={...r.dependencies,...r.devDependencies},a=Object.keys(i).filter(e=>e===`salty-css`||e.startsWith(`@salty-css/`));if(!a.length)return t.n(`No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: `+n);for(let e of a)t.r.info(`${e}: ${i[e]}`)})};async function De(){let e=new a.Command;e.name(`salty-css`).description(`Salty-CSS CLI tool to help with annoying configuration tasks.`);let t=await T();we(e),Te(e),Ee(e),A(e,t),V(e,t),e.parseAsync(process.argv)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return De}});
|
|
@@ -79,7 +79,7 @@ var r = (e) => (t) => {
|
|
|
79
79
|
else {
|
|
80
80
|
let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
|
|
81
81
|
if (!n) continue;
|
|
82
|
-
|
|
82
|
+
i[n] = r === "true" || r !== "false" && r;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
return {
|
|
@@ -228,7 +228,7 @@ var r = (e) => (t) => {
|
|
|
228
228
|
}
|
|
229
229
|
return console.warn(`Template "${i}" received an unsupported call-site value.`), y();
|
|
230
230
|
}
|
|
231
|
-
if (
|
|
231
|
+
if (i !== "compoundVariants" && i !== "anyOfVariants" && Array.isArray(r)) return r.length === 0 ? y() : g([e, r.join(", ")]);
|
|
232
232
|
if (typeof r == "object") {
|
|
233
233
|
if (!r) return y();
|
|
234
234
|
if (r.isColor || r.isDefineFont) return y(x(r.toString()));
|
|
@@ -273,8 +273,10 @@ var r = (e) => (t) => {
|
|
|
273
273
|
if (typeof r == "boolean") return d(l, `Property "${i}" has a boolean value (${r}) — skipping.`), y();
|
|
274
274
|
if (r === "") return y();
|
|
275
275
|
if (typeof r == "number") return Number.isFinite(r) ? y(x(s(c, r, a))) : (d(l, `Property "${i}" has a non-finite numeric value (${r}) — skipping.`), y());
|
|
276
|
-
if (typeof r != "string")
|
|
277
|
-
|
|
276
|
+
if (typeof r != "string") {
|
|
277
|
+
if (r && typeof r == "object" && "toString" in r) r = r.toString();
|
|
278
|
+
else return d(l, `Property "${i}" has an unsupported value type (${typeof r}) — skipping.`), y();
|
|
279
|
+
}
|
|
278
280
|
return typeof r == "string" && p.test(r) && d(l, `Property "${i}" value "${r}" contains an unresolved \`\${...}\` — did you forget to interpolate?`), y(x(r));
|
|
279
281
|
}, { modifiers: v } = a || {}, y = [i(), r(v)], x = await Promise.all(c.map(g)), S = await Promise.all(x.map(({ value: e }) => e === void 0 ? Promise.resolve(void 0) : y.reduce(async (e, t) => {
|
|
280
282
|
let n = await e;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=require("./util/index.cjs"),t=require("./viewport-clamp-CHOyzt37.cjs");var n=e=>t=>{if(typeof t!=`string`||!e)return;let n=t,r=[];return Object.values(e).forEach(e=>{let{pattern:t,transform:i}=e;n=n.replace(t,e=>{let{value:t,css:n}=i(e);return n&&r.push(n),t})}),{transformed:n,additionalCss:r}},r=t=>n=>{if(typeof n==`string`&&/\{[^{}]+\}/g.test(n))return{transformed:n.replace(/\{([^{}]+)\}/g,(...n)=>{let r=e.dashCase(n[1].trim().replaceAll(`.`,`-`));return t&&!t.includes(r)&&console.warn(`Token ${r} might not exist`),r.startsWith(`-`)?`-${r}`:`var(--${r})`})}},i=r(),a=[`top`,`right`,`bottom`,`left`,`min-width`,/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],o=(e,n,r)=>{if(a.some(t=>typeof t==`string`?t===e:t.test(e))){let e=r?.defaultUnit||`px`;if(e.startsWith(`viewport-clamp:`))try{let r=e.split(`:`)[1];return t.t({screenSize:parseInt(r)})(Number(n))}catch(t){throw console.error(t),Error(`Invalid viewport-clamp value: ${e}`)}return`${n}${e}`}return`${n}`},s=[`Webkit`,`Moz`,`ms`,`O`],c=e=>s.some(t=>{if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n>=`A`&&n<=`Z`}),l=t=>t.startsWith(`-`)?t:c(t)?`-${e.dashCase(t)}`:e.dashCase(t),u=(e,t)=>{if(e===!0)throw Error(`[salty-css] ${t}`);e===`warn`&&console.warn(`[salty-css] ${t}`)},d=/^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/,f=/\$\{[^}]+\}/,p=/^@(media|supports|container|layer)\s*$/,m=/^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/,h=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.keys(e);return t.includes(`base`)||t.includes(`variants`)},g=e=>{if(typeof e==`string`){let[t,n]=e.split(`@`,2),r=t.split(`.`).filter(Boolean);if(!r.length)return;let i={};if(n)for(let e of n.split(`&`)){if(!e)continue;let t=e.indexOf(`=`);if(t===-1)i[e.trim()]=!0;else{let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!n)continue;i[n]=r===`true`||r!==`false`&&r}}return{path:r,variants:i}}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,n=t.name;if(typeof n!=`string`)return;let r=n.split(`.`).filter(Boolean);if(!r.length)return;let i={};for(let[e,n]of Object.entries(t))e!==`name`&&(typeof n==`string`||typeof n==`boolean`)&&(i[e]=n);return{path:r,variants:i}}},_=e=>{if(e!==void 0)return typeof e==`boolean`?String(e):e},v=(e,t)=>{let n=[{node:e,isRich:h(e)}],r=e;for(let e of t){if(typeof r!=`object`||!r)return;let t=r[e];if(t===void 0)return;n.push({node:t,isRich:h(t)}),r=t}return n},y=(e,t)=>{let n=v(e,t);return n?n.some(e=>e.isRich):!1},b=(e,t)=>{for(let[n,r]of Object.entries(e))if(n!==`css`&&t[n]!==_(r))return!1;return!0},x=(e,t)=>{let n=!1;for(let[r,i]of Object.entries(e))if(r!==`css`&&(n=!0,t[r]===_(i)))return!0;return!n},S=(e,t,n,r)=>{let i=v(e,t);if(!i)return;let a=i.map(e=>e.isRich?e.node:e.node&&typeof e.node==`object`&&!Array.isArray(e.node)?Object.keys(e.node).every(t=>e.node[t]&&typeof e.node[t]==`object`&&!h(e.node[t]))?{}:{base:e.node}:{}),o=new Set;for(let e of a)if(e.variants)for(let t of Object.keys(e.variants))o.add(t);for(let e of a)if(e.defaultVariants)for(let t of Object.keys(e.defaultVariants))o.add(t);let s={};for(let e of o){if(e in n){s[e]=_(n[e]);continue}for(let t=a.length-1;t>=0;t--){let n=a[t].defaultVariants?.[e];if(n!==void 0){s[e]=_(n);break}}}for(let[e,i]of Object.entries(n)){if(!o.has(e)){console.warn(`Template "${r}" path "${t.join(`.`)}" has no variant axis "${e}"; ignored.`);continue}let n=_(i),s=!1;for(let t of a)if(t.variants?.[e]&&n!==void 0&&n in t.variants[e]){s=!0;break}!s&&n!==void 0&&a.some(t=>t.variants&&e in t.variants)&&console.warn(`Template "${r}" axis "${e}" has no value "${n}" on path "${t.join(`.`)}"; ignored.`)}let c={};for(let e of a)e.base&&Object.assign(c,e.base);for(let e of Object.keys(s)){let t=s[e];if(t!==void 0)for(let n=a.length-1;n>=0;n--){let r=a[n].variants?.[e]?.[t];if(r){Object.assign(c,r);break}}}for(let e of a){if(e.compoundVariants)for(let t of e.compoundVariants)b(t,s)&&t.css&&Object.assign(c,t.css);if(e.anyOfVariants)for(let t of e.anyOfVariants)x(t,s)&&t.css&&Object.assign(c,t.css)}return c},C=async(t,i=``,a,s=!1)=>{if(!t)throw Error(`No styles provided to parseStyles function!`);let c=Object.entries(t),h=a?.strict;k(c,a,h);let _=async([t,n])=>{let r=t.trim().replace(/^\?+/g,``),c=l(r),v=[],b=e=>({value:e,nested:v}),x=(e,t=`;`)=>`${c}:${e}${t}`,T={scope:i,config:a};if(typeof n==`function`)try{return await _([t,n(T)])}catch(e){return u(h,`Function value for "${r}" threw: ${e?.message??e}`),b()}if(n instanceof Promise)return _([t,await n]);if(a?.templates&&a.templatePaths?.[r])try{let[e,t]=a.templatePaths[r].split(`;;`),i=await import(t),o=t.includes(`salty.config`),s=o?i[e].templates:i[e],c=o?s[r]:s.params[r];if(s&&typeof c==`function`){let[e]=await C(await c(n),``);return b(e)}}catch(e){return console.error(`Error loading template "${r}" from path "${a.templatePaths[r]}"`,e),b()}if(a?.templates&&a.templates[r]){if(s)return b();let e=a.templates[r],t=g(n);if(t){let{path:n,variants:i}=t;if(Object.keys(i).length>0||y(e,n)){let t=S(e,n,i,r);if(t){let[e]=await C(t,``);return b(e)}return console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`),b()}let a=n.reduce((e,t)=>e?.[t],e);if(a){let[e]=await C(a,``);return b(e)}return console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`),b()}return console.warn(`Template "${r}" received an unsupported call-site value.`),b()}if(r!==`compoundVariants`&&r!==`anyOfVariants`&&Array.isArray(n))return n.length===0?b():_([t,n.join(`, `)]);if(typeof n==`object`){if(!n)return b();if(n.isColor||n.isDefineFont)return b(x(n.toString()));if(r===`defaultVariants`)return b();if(r===`variants`){let t=Object.entries(n);for(let[n,r]of t){if(!r)continue;let t=Object.entries(r);for(let[r,o]of t)o&&(await C(o,`${i}.${`${e.sanitizeClassName(n)}-${e.sanitizeClassName(r)}`}`,a)).forEach(e=>v.push(e))}return b()}if(r===`compoundVariants`){for(let t of n){let{css:n,...r}=t;(await C(n,Object.entries(r).reduce((t,[n,r=``])=>`${t}.${`${e.sanitizeClassName(n)}-${e.sanitizeClassName(r)}`}`,i),a)).forEach(e=>v.push(e))}return b()}if(r===`anyOfVariants`){for(let t of n){let{css:n,...r}=t;(await C(n,`${i}:where(${Object.entries(r).map(([t,n=``])=>`.${`${e.sanitizeClassName(t)}-${e.sanitizeClassName(n)}`}`).join(`, `)})`,a)).forEach(e=>v.push(e))}return b()}if(r===`global`)return(await C(n,``,a)).forEach(e=>v.push(e)),b();if(r.startsWith(`@`)){p.test(r)&&u(h,`At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);let e=m.test(r)?``:i,t=`${a?.mediaQueries?.[r]||r} { ${await w(n,e,a)} }`;return v.push(t),b()}if(Object.keys(n).length===0)return b();d.test(r)&&u(h,`Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);let t=D(i,r);return(await C(n,t,a)).forEach(e=>v.push(e)),b()}if(r.startsWith(`$`))return u(h,`Property key "${r}" looks like a SCSS variable — Salty does not support those.`),b();if(r.includes(`:`))return u(h,`Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`),b();if(n==null)return u(h,`Property "${r}" has a ${n===void 0?`undefined`:`null`} value — skipping.`),b();if(typeof n==`boolean`)return u(h,`Property "${r}" has a boolean value (${n}) — skipping.`),b();if(n===``)return b();if(typeof n==`number`)return Number.isFinite(n)?b(x(o(c,n,a))):(u(h,`Property "${r}" has a non-finite numeric value (${n}) — skipping.`),b());if(typeof n!=`string`){if(n&&typeof n==`object`&&`toString`in n)n=n.toString();else return u(h,`Property "${r}" has an unsupported value type (${typeof n}) — skipping.`),b()}return typeof n==`string`&&f.test(n)&&u(h,`Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`),b(x(n))},{modifiers:v}=a||{},b=[r(),n(v)],x=await Promise.all(c.map(_)),T=await Promise.all(x.map(({value:e})=>e===void 0?Promise.resolve(void 0):b.reduce(async(e,t)=>{let n=await e;if(!n)return n;let r=await t(n);if(!r)return n;let{transformed:i,additionalCss:a}=r,o=``;if(a)for(let e of a)o+=await w(e,``);return`${o}${i}`},Promise.resolve(e)))),E=new Set;for(let{nested:e}of x)for(let t of e)E.add(t);let O=T.filter(e=>e!==void 0).join(`
|
|
2
|
+
`);if(!O.trim())return Array.from(E);let A=i?`${i} {\n\t${O}\n}`:O;return E.has(A)?Array.from(E):[A,...E]},w=async(e,t,n,r=!1)=>(await C(e,t,n,r)).join(`
|
|
3
|
+
`),T=e=>{let t=[],n=0,r=``;for(let i of e)if(i===`(`||i===`[`?n++:(i===`)`||i===`]`)&&(n=Math.max(0,n-1)),i===`,`&&n===0){let e=r.trim();e&&t.push(e),r=``}else r+=i;let i=r.trim();return i&&t.push(i),t},E=(e,t)=>t.includes(`&`)?t.replaceAll(`&`,e):t.startsWith(`:`)?`${e}${t}`:`${e} ${t}`,D=(e,t)=>{if(!e)return t;let n=T(e),r=T(t);if(!r.length)return e;if(n.length<=1&&r.length<=1)return E(n[0]??e,r[0]);let i=[];for(let e of n)for(let t of r)i.push(E(e,t));return i.join(`, `)},O=/\((max|min)-width:\s*([\d.]+)(px|r?em)\)/g,k=(e,t,n)=>{if(!n)return;let r={},i={};for(let[n,a]of e){let e=n.trim().replace(/^\?+/g,``);if(!e.startsWith(`@`)||typeof a!=`object`||!a)continue;let o=[...(t?.mediaQueries?.[e]||e).matchAll(O)];if(o.length!==1)continue;let[,s,c,l]=o[0],d=parseFloat(c);if(s===`max`){let t=r[l];t&&d>t.value&&u(`warn`,`Media query "${e}" (max-width: ${d}${l}) is declared after "${t.key}" (max-width: ${t.value}${l}); wider max-width queries override narrower ones at overlapping widths — order them widest → narrowest.`),(!t||d<t.value)&&(r[l]={value:d,key:e})}else{let t=i[l];t&&d<t.value&&u(`warn`,`Media query "${e}" (min-width: ${d}${l}) is declared after "${t.key}" (min-width: ${t.value}${l}); narrower min-width queries are overridden by wider ones at overlapping widths — order them narrowest → widest.`),(!t||d>t.value)&&(i[l]={value:d,key:e})}}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});
|