@salty-css/core 0.0.1-alpha.119 → 0.0.1-alpha.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +3 -3
- package/{dash-case-8PdMJjFC.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
- package/{dash-case-D_tXuO4I.js → dash-case-DBThphLm.js} +1 -1
- package/generator/index.cjs +1 -1
- package/generator/index.js +2 -2
- package/{index-DrkPrGSp.js → index-BKt0qRhM.js} +2 -2
- package/{index-BKHuU-Ho.cjs → index-mhoDzsNb.cjs} +1 -1
- package/package.json +1 -1
- package/{parse-templates-D1FebDfR.js → parse-templates-BuKrl3n7.js} +1 -1
- package/{parse-templates-lpgqU05M.cjs → parse-templates-DIOn-gO_.cjs} +1 -1
- package/util/index.cjs +1 -1
- package/util/index.js +1 -1
package/bin/main.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-mhoDzsNb.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
|
2
2
|
|
3
3
|
# Salty-CSS
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
@@ -3,7 +3,7 @@ import { existsSync as K } from "fs";
|
|
3
3
|
import { mkdir as q, readFile as C, writeFile as w } from "fs/promises";
|
4
4
|
import { join as i, relative as z, parse as re, format as ee } from "path";
|
5
5
|
import { render as ce } from "ejs";
|
6
|
-
import { l as t, a as h, g as te } from "../index-
|
6
|
+
import { l as t, a as h, g as te } from "../index-BKt0qRhM.js";
|
7
7
|
import { p as le } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as de } from "child_process";
|
9
9
|
import fe from "ora";
|
package/compiler/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DIOn-gO_.cjs");const e=require("../index-mhoDzsNb.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import "esbuild";
|
2
2
|
import "child_process";
|
3
|
-
import "../dash-case-
|
3
|
+
import "../dash-case-DBThphLm.js";
|
4
4
|
import "path";
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
|
-
import "../parse-templates-
|
8
|
-
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-
|
7
|
+
import "../parse-templates-BuKrl3n7.js";
|
8
|
+
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-BKt0qRhM.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=
|
1
|
+
"use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=5)=>{const t=o(5381,JSON.stringify(e))>>>0;return i(t,r)};function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(r,t)=>(t>0?"-":"")+r.toLowerCase()):""}exports.dashCase=s;exports.toHash=c;
|
@@ -6,7 +6,7 @@ const n = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), o = (e, r) => {
|
|
6
6
|
let t = r.length;
|
7
7
|
for (; t; ) e = e * 33 ^ r.charCodeAt(--t);
|
8
8
|
return e;
|
9
|
-
}, c = (e, r =
|
9
|
+
}, c = (e, r = 5) => {
|
10
10
|
const t = i(5381, JSON.stringify(e)) >>> 0;
|
11
11
|
return o(t, r);
|
12
12
|
};
|
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var f=Object.defineProperty;var N=(s,t,e)=>t in s?f(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var o=(s,t,e)=>N(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../dash-case-
|
1
|
+
"use strict";var f=Object.defineProperty;var N=(s,t,e)=>t in s?f(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var o=(s,t,e)=>N(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../dash-case-BJEkFEGQ.cjs"),u=require("../parse-templates-DIOn-gO_.cjs");class S{constructor(t,e){o(this,"_isProd");o(this,"_callerName");o(this,"_context");this.tagName=t,this.params=e}get hash(){return _.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:e}=this.params;return e&&t.push(e),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?u.getTemplateKeys(this._context.config.templates):[]}get css(){var n;const{base:t={},variants:e={},compoundVariants:i=[]}=this.params,r={...t,variants:e,compoundVariants:i};return u.parseStyles(r,`.${this.cssClassName}`,this.priority,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:e={},compoundVariants:i=[],defaultVariants:r={},defaultProps:n={},passProps:y}=this.params,c=new Set([]),h=a=>{const p=r[a];p!==void 0?c.add(`${a}=${String(p)}`):c.add(a)};Object.keys(e).forEach(h),i.map(a=>Object.keys(a).forEach(h));const l=new Set([]),m=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return m&&m.forEach((a,p,g)=>{const d=g.at(1);d&&l.add(d)}),{element:t,variantKeys:[...c],propValueKeys:[...l],passProps:y,defaultProps:n,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:e,config:i,prod:r}=t;return this._isProd=r,this._callerName=e,this}}exports.StyleComponentGenerator=S;
|
package/generator/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
var g = Object.defineProperty;
|
2
2
|
var y = (e, t, s) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
3
|
var o = (e, t, s) => y(e, typeof t != "symbol" ? t + "" : t, s);
|
4
|
-
import { t as N } from "../dash-case-
|
5
|
-
import { g as _, p as x } from "../parse-templates-
|
4
|
+
import { t as N } from "../dash-case-DBThphLm.js";
|
5
|
+
import { g as _, p as x } from "../parse-templates-BuKrl3n7.js";
|
6
6
|
class K {
|
7
7
|
constructor(t, s) {
|
8
8
|
o(this, "_isProd");
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import * as q from "esbuild";
|
2
2
|
import { execSync as et } from "child_process";
|
3
|
-
import { t as H, d as G } from "./dash-case-
|
3
|
+
import { t as H, d as G } from "./dash-case-DBThphLm.js";
|
4
4
|
import { join as o, parse as st } from "path";
|
5
5
|
import { existsSync as I, writeFileSync as b, mkdirSync as O, readFileSync as J, statSync as nt, readdirSync as ot } from "fs";
|
6
6
|
import { readFile as rt, writeFile as at } from "fs/promises";
|
7
|
-
import { p as L, a as it, b as ct, c as lt } from "./parse-templates-
|
7
|
+
import { p as L, a as it, b as ct, c as lt } from "./parse-templates-BuKrl3n7.js";
|
8
8
|
import { createLogger as pt, format as z, transports as ft } from "winston";
|
9
9
|
const U = (t) => {
|
10
10
|
if (!t || t === "/") throw new Error("Could not find package.json file");
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const se=require("esbuild"),ne=require("child_process"),_=require("./dash-case-
|
1
|
+
"use strict";const se=require("esbuild"),ne=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),o=require("path"),c=require("fs"),Z=require("fs/promises"),V=require("./parse-templates-DIOn-gO_.cjs"),R=require("winston");var I=typeof document<"u"?document.currentScript:null;function oe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const K=oe(se),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=o.join(e,"package.json");return c.existsSync(t)?t:L(o.join(e,".."))},re=async e=>{const t=L(e);return await Z.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ie=async e=>{const t=await re(e);if(t)return t.type};let E;const U=async e=>{if(E)return E;const t=await ie(e);return t==="module"?E="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-mhoDzsNb.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},J=R.createLogger({level:"debug",format:R.format.combine(R.format.colorize(),R.format.cli()),transports:[new R.transports.Console({})]}),ce=e=>{J.error(e)};function G(e){return e?typeof e!="string"?G(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const ae={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},button:{lineHeight:"1em"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},X=e=>{if(A.externalModules.length>0)return A.externalModules;const t=o.join(e,"salty.config.ts"),n=c.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(p=>p.replace(/['"`]/g,"").trim());return A.externalModules=i,i},q=e=>o.join(e,"./saltygen"),Y=["salty","css","styles","styled"],Q=(e=[])=>new RegExp(`\\.(${[...Y,...e].join("|")})\\.`),z=(e,t=[])=>Q(t).test(e),le=async e=>{const t=q(e),s=o.join(e,"salty.config.ts"),n=o.join(t,"salty.config.js"),i=await U(e),p=X(e);await K.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:p});const h=Date.now(),{config:g}=await import(`${n}?t=${h}`);return g},ee=async e=>{const t=await le(e),s=new Set,n=(f,l=[])=>f?Object.entries(f).flatMap(([d,u])=>{if(!u)return;if(typeof u=="object")return n(u,[...l,d]);const x=G(d),N=_.dashCase(d),v=[...l,x].join(".");s.add(`"${v}"`);const O=[...l.map(_.dashCase),N].join("-"),{result:H}=V.parseValueTokens(u);return`--${O}: ${H};`}):[],i=f=>f?Object.entries(f).flatMap(([l,d])=>{const u=n(d);return l==="base"?u.join(""):`${l} { ${u.join("")} }`}):[],p=f=>f?Object.entries(f).flatMap(([l,d])=>Object.entries(d).flatMap(([u,x])=>{const N=n(x,[l]),v=`.${l}-${u}, [data-${l}="${u}"]`,O=N.join("");return`${v} { ${O} }`})):[],h=n(t.variables),g=i(t.responsiveVariables),b=p(t.conditionalVariables),r=q(e),k=o.join(r,"css/variables.css"),m=`:root { ${h.join("")} ${g.join("")} } ${b.join("")}`;c.writeFileSync(k,m);const j=o.join(r,"css/global.css"),w=V.parseStyles(t.global,"");c.writeFileSync(j,`@layer global { ${w} }`);const a=o.join(r,"css/reset.css"),C=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ae,F=V.parseStyles(C,"");c.writeFileSync(a,`@layer reset { ${F} }`);const $=o.join(r,"css/templates.css"),T=V.parseTemplates(t.templates),y=V.getTemplateTypes(t.templates);c.writeFileSync($,T);const P=o.join(r,"types/css-tokens.d.ts"),M=`
|
2
2
|
// Variable types
|
3
3
|
type VariableTokens = ${[...s].join("|")};
|
4
4
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
package/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const T=require("./dash-case-
|
1
|
+
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),N=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const r=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:i}=n;t=t.replace(o,d=>{const{value:c,css:j}=i(d);return j&&r.push(j),c})}),{result:t,additionalCss:r}},S=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${T.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},a=(t,e,r,n)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((c,[j,s])=>{const p=j.trim();if(typeof s=="function"&&(s=s()),typeof s=="object"){if(!s)return c;if(p==="variants")return Object.entries(s).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,m])=>{if(!m)return;const y=`${e}.${f}-${l}`,b=a(m,y,r);o.push(b)})}),c;if(p==="defaultVariants")return c;if(p==="compoundVariants")return s.forEach(f=>{const{css:u,...l}=f,m=Object.entries(l).reduce((b,[q,K])=>`${b}.${q}-${K}`,e),y=a(u,m,r);o.push(y)}),c;if(p.startsWith("@")){const f=a(s,e,r),u=`${p} {
|
2
2
|
${f.replace(`
|
3
3
|
`,`
|
4
4
|
`)}
|
package/util/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-BJEkFEGQ.cjs"),t=require("../pascal-case-iWoaJWwT.cjs");function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/-([a-z])/g,r=>r[1].toUpperCase()):""}exports.dashCase=a.dashCase;exports.toHash=a.toHash;exports.pascalCase=t.pascalCase;exports.camelCase=s;
|
package/util/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { d as o, t as s } from "../dash-case-
|
1
|
+
import { d as o, t as s } from "../dash-case-DBThphLm.js";
|
2
2
|
import { p as f } from "../pascal-case-BQpR5PdN.js";
|
3
3
|
function r(e) {
|
4
4
|
return e ? typeof e != "string" ? r(String(e)) : e.replace(/\s/g, "-").replace(/-([a-z])/g, (a) => a[1].toUpperCase()) : "";
|