@salty-css/core 0.0.1-alpha.258 → 0.0.1-alpha.259
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 +2 -2
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +11 -10
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +1 -1
- package/index-Cpvtq5h9.js +517 -0
- package/index-DV-sarjD.cjs +41 -0
- package/package.json +1 -1
- package/{parse-styles-DzvIRlln.js → parse-styles-CKmL8EwD.js} +43 -40
- package/parse-styles-DZYIEhB4.cjs +5 -0
- package/parsers/index.cjs +2 -1
- package/parsers/index.js +31 -10
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/{should-restart-DuV6TZaJ.cjs → should-restart-B6uSbFR6.cjs} +1 -1
- package/{should-restart-D12YL-ao.js → should-restart-M_v7QUN8.js} +1 -1
- package/index-C6aWAT5E.js +0 -534
- package/index-hRLfXvS_.cjs +0 -42
- package/parse-styles-BV4RZMzC.cjs +0 -5
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";const Te=require("esbuild"),_e=require("child_process"),_=require("./dash-case-BJEkFEGQ.cjs"),i=require("path"),c=require("fs"),Se=require("fs/promises"),ae=require("./parse-styles-DZYIEhB4.cjs"),he=require("./parsers/index.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),ve=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=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 be=Oe(Te),je=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=i.join(e,"package.json");return c.existsSync(t)?t:je(i.join(e,".."))},Ee=async e=>{const t=je(e);return await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ve=async e=>{const t=await Ee(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Ve(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-DV-sarjD.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),Re=e=>{B.error(e)};function $e(e){return e?typeof e!="string"?$e(String(e)):e.replace(/[^\d\w]/g,"."):""}const Me={"*, *::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"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},Je=(e,t)=>new Promise((s,n)=>{const r=setTimeout(()=>{n(new Error("Timeout"))},100),l=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function o(y){if(ce.isVariableDeclaration(y)&&y.name.getText()===t){const S=y.getStart(),m=y.getEnd();clearTimeout(r),s([S,m])}y.forEachChild(o)}o(l)}),O={externalModules:[],rcFile:void 0,destDir:void 0},Ce=e=>{if(O.externalModules.length>0)return O.externalModules;const s=c.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return O.externalModules=n,n},q=async e=>{if(O.destDir)return O.destDir;const t=await fe(e),s=i.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},le=["salty","css","styles","styled"],Pe=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),Z=(e,t=[])=>Pe(t).test(e),Ne=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=i.join(e,".saltyrc.json"),s=await Se.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):Ne(i.join(e,".."))},fe=async e=>{var n,r;const t=await Ne(e),s=(n=t.projects)==null?void 0:n.find(l=>e.endsWith(l.dir||""));return s||((r=t.projects)==null?void 0:r.find(l=>l.dir===t.defaultProject))},qe=async e=>{const t=await fe(e),s=await q(e),n=i.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),r=i.join(s,"salty.config.js"),l=await Fe(e),o=Ce(n);await be.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:l,external:o});const y=Date.now(),{config:S}=await import(`${r}?t=${y}`);return{config:S,path:r}},xe=async(e,t)=>{var de,ye;const s=await q(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:F,outputFilePath:K}=await U(e,w,s);Object.entries(F).forEach(([D,P])=>{P.isMedia?n.mediaQueries.push([D,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${D};;${K}`))})}));const{config:r,path:l}=await qe(e),o={...r},{mediaQueries:y}=n;o.mediaQueries=Object.fromEntries(y.map(([w,F])=>[`@${w}`,F]));const S=y.map(([w])=>`'@${w}'`).join(" | "),m=new Set,a=async(w,F=[])=>{if(!w)return[];const K=Object.entries(w).map(async([P,M])=>{const L=async T=>{if(!T)return;if(T instanceof Promise)return await L(await T);if(typeof T=="function")return await L(await T());if(typeof T=="object")return await a(T,[...F,P]);const ne=$e(P),oe=_.dashCase(P),ie=[...F,ne].join(".");m.add(`"${ie}"`);const Y=[...F.map(_.dashCase),oe].join("-"),ge=ae.parseVariableTokens(T);return ge?`--${Y}: ${ge.transformed};`:`--${Y}: ${T};`};return await L(M)});return(await Promise.all(K)).flat()},g=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=await a(P);return D==="base"?M.join(""):o.mediaQueries[D]?`${o.mediaQueries[D]} { ${M.join("")} }`:`${D} { ${M.join("")} }`});return(await Promise.all(F)).flat()},d=async w=>{if(!w)return[];const F=Object.entries(w).map(async([D,P])=>{const M=Object.entries(P).map(async([T,ne])=>{const oe=await a(ne,[D]),ie=`.${D}-${T}, [data-${D}="${T}"]`,Y=oe.join("");return`${ie} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all(F)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map(F=>w==="static"?h(F._current):F._current[w]),$=J.mergeObjects(h(r.variables),p("static")),x=await a($),k=J.mergeObjects((de=r.variables)==null?void 0:de.responsive,p("responsive")),E=await g(k),z=J.mergeObjects((ye=r.variables)==null?void 0:ye.conditional,p("conditional")),A=await d(z),me=i.join(s,"css/_variables.css"),V=`:root { ${x.join("")} ${E.join("")} } ${A.join("")}`;c.writeFileSync(me,V),o.staticVariables=$;const ee=i.join(s,"css/_global.css"),u=J.mergeObjects(r.global,n.globalStyles),b=await ae.parseAndJoinStyles(u,"");c.writeFileSync(ee,`@layer global { ${b} }`);const j=i.join(s,"css/_reset.css"),C=r.reset==="none"?{}:typeof r.reset=="object"?r.reset:Me,N=await ae.parseAndJoinStyles(C,"");c.writeFileSync(j,`@layer reset { ${N} }`);const v=i.join(s,"css/_templates.css"),R=J.mergeObjects(r.templates,n.templates),W=await he.parseTemplates(R),I=he.getTemplateTypes(R);c.writeFileSync(v,`@layer templates { ${W} }`),o.templates=R;const X=r.templates?[ve.defineTemplates(r.templates)._setPath(`config;;${l}`)]:[],te=J.mergeFactories(n.templates,X);o.templatePaths=Object.fromEntries(Object.entries(te).map(([w,F])=>[w,F._path]));const G=i.join(s,"types/css-tokens.d.ts"),ke=`
|
2
|
+
// Variable types
|
3
|
+
type VariableTokens = ${[...m].join("|")};
|
4
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
5
|
+
|
6
|
+
// Template types
|
7
|
+
type TemplateTokens = {
|
8
|
+
${Object.entries(I).map(([w,F])=>`${w}?: ${F}`).join(`
|
9
|
+
`)}
|
10
|
+
}
|
11
|
+
|
12
|
+
// Media query types
|
13
|
+
type MediaQueryKeys = ${S||"''"};
|
14
|
+
`;c.writeFileSync(G,ke);const De=i.join(s,"cache/config-cache.json");c.writeFileSync(De,JSON.stringify(o,null,2))},we=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const r=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!r.test(e))return t;const o=r.exec(e);if(o){const y=o.at(1);if(le.some(m=>y==null?void 0:y.includes(m)))return t}return"styled('div',"}),ze=(e,t)=>{try{const s=c.readFileSync(i.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
15
|
+
|
16
|
+
${e}`:`globalThis.saltyConfig = {};
|
17
|
+
|
18
|
+
${e}`}catch{return e}},U=async(e,t,s)=>{const n=_.toHash(t),r=i.join(s,"./temp");c.existsSync(r)||c.mkdirSync(r);const l=i.parse(t);let o=c.readFileSync(t,"utf8");o=we(o),o=ze(o,e);const y=i.join(s,"js",n+".js"),S=await fe(e),m=i.join(e,(S==null?void 0:S.configDir)||"","salty.config.ts"),a=Ce(m),g=await Fe(e);await be.build({stdin:{contents:o,sourcefile:l.base,resolveDir:l.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:a,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},$=>{const x=c.readFileSync($.path,"utf8");return{contents:we(x),loader:"ts"}})}}]});const d=Date.now();return{contents:await import(`${y}?t=${d}`),outputFilePath:y}},He=async e=>{const t=await q(e),s=i.join(t,"cache/config-cache.json"),n=c.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ue=async e=>{const t=await He(e),s=await q(e),n=i.join(s,"salty.config.js"),r=Date.now(),{config:l}=await import(`${n}?t=${r}`);return J.mergeObjects(l,t)},pe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},We=async(e,t=pe(),s=!0)=>{try{const n=Date.now();t?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const r=[],l=[],o=await q(e),y=i.join(o,"index.css");s&&(()=>{c.existsSync(o)&&_e.execSync("rm -rf "+o),c.mkdirSync(o,{recursive:!0}),c.mkdirSync(i.join(o,"css")),c.mkdirSync(i.join(o,"types")),c.mkdirSync(i.join(o,"js")),c.mkdirSync(i.join(o,"cache"))})();const m=new Set,a=new Set;async function g(u){const b=["node_modules","saltygen"],j=c.statSync(u);if(j.isDirectory()){const f=c.readdirSync(u);if(b.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>g(i.join(u,N))))}else if(j.isFile()&&Z(u)){m.add(u);const C=c.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&a.add(u)}}await g(e),await xe(e,a);const d={keyframes:[],components:[],classNames:[]};await Promise.all([...m].map(async u=>{const{contents:b}=await U(e,u,o);for(let[j,f]of Object.entries(b))f instanceof Promise&&(f=await f),f.isKeyframes?d.keyframes.push({value:f,src:u,name:j}):f.isClassName?d.classNames.push({...f,src:u,name:j}):f.generator&&d.components.push({...f,src:u,name:j})}));const h=await ue(e);for(const u of d.keyframes){const{value:b}=u,j=`a_${b.animationName}.css`,f=`css/${j}`,C=i.join(o,f);r.push(j),c.writeFileSync(C,b.css)}const p={};for(const u of d.components){const{src:b,name:j}=u;p[b]||(p[b]=[]);const f=u.generator._withBuildContext({callerName:j,isProduction:t,config:h});l[f.priority]||(l[f.priority]=[]);const C=await f.css;if(!C)continue;l[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,v=i.join(o,N);c.writeFileSync(v,C),h.importStrategy==="component"&&p[b].push(f.cssFileName)}for(const u of d.classNames){const{src:b,name:j}=u;p[b]||(p[b]=[]);const f=u.generator._withBuildContext({callerName:j,isProduction:t,config:h}),C=await f.css;if(!C)continue;l[f.priority]||(l[f.priority]=[]),l[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,v=i.join(o,N);c.writeFileSync(v,C),h.importStrategy==="component"&&p[b].push(f.cssFileName)}h.importStrategy==="component"&&Object.entries(p).forEach(([u,b])=>{const j=b.map(R=>`@import url('./${R}');`).join(`
|
19
|
+
`),f=_.toHash(u,6),C=i.parse(u),N=_.dashCase(C.name),v=i.join(o,`css/f_${N}-${f}.css`);c.writeFileSync(v,j||"/* Empty file */")});const $=r.map(u=>`@import url('./css/${u}');`).join(`
|
20
|
+
`);let A=`/*!
|
21
|
+
* Generated with Salty CSS (https://salty-css.dev)
|
22
|
+
* Do not edit this file directly
|
23
|
+
*/
|
24
|
+
@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
25
|
+
|
26
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(u=>{try{return c.readFileSync(i.join(o,"css",u),"utf8").length>0}catch{return!1}}).map(u=>`@import url('./css/${u}');`).join(`
|
27
|
+
`)}
|
28
|
+
${$}`;if(h.importStrategy!=="component"){const u=l.reduce((b,j,f)=>{const C=j.reduce((W,I)=>{var se;const X=i.join(o,"css",I),te=c.readFileSync(X,"utf8"),G=((se=/.*-([^-]+)-\d+.css/.exec(I))==null?void 0:se.at(1))||_.toHash(X,6);return W.includes(G)?W:`${W}
|
29
|
+
/*start:${G}-${I}*/
|
30
|
+
${te}
|
31
|
+
/*end:${G}*/
|
32
|
+
`},""),N=`l_${f}.css`,v=i.join(o,"css",N),R=`@layer l${f} { ${C}
|
33
|
+
}`;return c.writeFileSync(v,R),`${b}
|
34
|
+
@import url('./css/${N}');`},"");A+=u}c.writeFileSync(y,A);const V=Date.now()-n,ee=V<200?"🔥":V<500?"🚀":V<1e3?"🎉":V<2e3?"🚗":V<5e3?"🤔":"🥴";B.info(`Generated CSS in ${V}ms! ${ee}`)}catch(n){console.error(n)}},Ie=async(e,t,s=pe())=>{try{const n=await q(e);if(Z(t)){const l=[],o=await ue(e),{contents:y}=await U(e,t,n);for(const[S,m]of Object.entries(y)){if(m.isKeyframes&&m.css){const $=`css/${`a_${m.animationName}.css`}`,x=i.join(n,$);c.writeFileSync(x,await m.css);continue}if(m.isClassName){const p=m.generator._withBuildContext({callerName:S,isProduction:s,config:o}),$=await p.css;if(!$)continue;l[p.priority]||(l[p.priority]=[]),l[p.priority].push(p.cssFileName);const x=`css/${p.cssFileName}`,k=i.join(n,x);c.writeFileSync(k,$);continue}if(!m.generator)continue;const a=m.generator._withBuildContext({callerName:S,isProduction:s,config:o}),g=await a.css;if(!g)continue;const d=`css/${a.cssFileName}`,h=i.join(n,d);c.writeFileSync(h,g),l[a.priority]||(l[a.priority]=[]),l[a.priority].push(a.cssFileName)}if(o.importStrategy!=="component")l.forEach((S,m)=>{const a=`l_${m}.css`,g=i.join(n,"css",a);let d=c.readFileSync(g,"utf8");S.forEach(h=>{var k;const p=i.join(n,"css",h),$=((k=/.*-([^-]+)-\d+.css/.exec(h))==null?void 0:k.at(1))||_.toHash(p,6);if(!d.includes($)){const E=c.readFileSync(p,"utf8"),z=`/*start:${$}-${h}*/
|
35
|
+
${E}
|
36
|
+
/*end:${$}*/
|
37
|
+
`;d=`${d.replace(/\}$/,"")}
|
38
|
+
${z}
|
39
|
+
}`}}),c.writeFileSync(g,d)});else{const S=l.flat().map(h=>`@import url('./${h}');`).join(`
|
40
|
+
`),m=_.toHash(t,6),a=i.parse(t),g=_.dashCase(a.name),d=i.join(n,`css/f_${g}-${m}.css`);c.writeFileSync(d,S||"/* Empty file */")}}}catch(n){console.error(n)}},Ge=async(e,t,s=pe())=>{var n,r;try{const l=await q(e);if(Z(t)){const y=c.readFileSync(t,"utf8"),S=await ue(e),{contents:m}=await U(e,t,l);let a=y;for(const[g,d]of Object.entries(m)){if(d.isKeyframes||!d.generator)continue;const h=d.generator._withBuildContext({callerName:g,isProduction:s,config:S}),[p,$]=await Je(a,g),x=a.slice(p,$);if(d.isClassName){const k=a,E=` ${g} = className("${h.classNames}")`;a=a.replace(x,E),k===a&&console.error("Minimize file failed to change content",{name:g})}if(x.includes("styled")){const k=(r=(n=/styled\(([^,]+),/.exec(x))==null?void 0:n.at(1))==null?void 0:r.trim(),E=a,z=` ${g} = styled(${k}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;a=a.replace(x,z),E===a&&console.error("Minimize file failed to change content",{name:g,tagName:k})}}if(S.importStrategy==="component"){const g=_.toHash(t,6),d=i.parse(t);a=`import '../../saltygen/css/${`f_${_.dashCase(d.name)}-${g}.css`}';
|
41
|
+
${a}`}return a=a.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),a=a.replace("{ styled }","{ styledClient as styled }"),a=a.replace("@salty-css/react/styled","@salty-css/react/styled-client"),a}}catch(l){console.error("Error in minimizeFile:",l)}};exports.compileSaltyFile=U;exports.generateConfigStyles=xe;exports.generateCss=We;exports.generateFile=Ie;exports.isSaltyFile=Z;exports.logError=Re;exports.logger=B;exports.minimizeFile=Ge;exports.saltyFileExtensions=le;exports.saltyFileRegExp=Pe;
|
package/package.json
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
import { d as O } from "./dash-case-DBThphLm.js";
|
2
|
-
import { d as
|
2
|
+
import { d as N } from "./viewport-clamp-BOc-8Oph.js";
|
3
3
|
const U = (o) => (s) => {
|
4
4
|
if (typeof s != "string" || !o) return;
|
5
5
|
let t = s;
|
6
|
-
const
|
6
|
+
const m = [];
|
7
7
|
return Object.values(o).forEach((e) => {
|
8
|
-
const { pattern:
|
9
|
-
t = t.replace(
|
10
|
-
const { value: x, css: v } =
|
11
|
-
return v &&
|
8
|
+
const { pattern: p, transform: f } = e;
|
9
|
+
t = t.replace(p, (E) => {
|
10
|
+
const { value: x, css: v } = f(E);
|
11
|
+
return v && m.push(v), x;
|
12
12
|
});
|
13
|
-
}), { transformed: t, additionalCss:
|
14
|
-
},
|
15
|
-
const
|
16
|
-
return
|
17
|
-
}) }, D =
|
13
|
+
}), { transformed: t, additionalCss: m };
|
14
|
+
}, A = (o) => (s) => typeof s != "string" || !/\{[^{}]+\}/g.test(s) ? void 0 : { transformed: s.replace(/\{([^{}]+)\}/g, (...e) => {
|
15
|
+
const p = O(e[1].replaceAll(".", "-"));
|
16
|
+
return o && !o.includes(p) && console.warn(`Token ${p} might not exist`), p.startsWith("-") ? `-${p}` : `var(--${p})`;
|
17
|
+
}) }, D = A(), M = [
|
18
18
|
"top",
|
19
19
|
"right",
|
20
20
|
"bottom",
|
@@ -40,27 +40,27 @@ const U = (o) => (s) => {
|
|
40
40
|
const e = (t == null ? void 0 : t.defaultUnit) || "px";
|
41
41
|
if (e.startsWith("viewport-clamp:"))
|
42
42
|
try {
|
43
|
-
const
|
44
|
-
return
|
45
|
-
screenSize: parseInt(
|
43
|
+
const f = e.split(":")[1];
|
44
|
+
return N({
|
45
|
+
screenSize: parseInt(f)
|
46
46
|
})(Number(s));
|
47
|
-
} catch (
|
48
|
-
throw console.error(
|
47
|
+
} catch (f) {
|
48
|
+
throw console.error(f), new Error(`Invalid viewport-clamp value: ${e}`);
|
49
49
|
}
|
50
50
|
return `${s}${e}`;
|
51
51
|
}
|
52
52
|
return `${s}`;
|
53
|
-
}, _ = ["Webkit", "Moz", "ms", "O"],
|
53
|
+
}, _ = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : _.some((s) => o.startsWith(s)) ? `-${O(o)}` : O(o), y = async (o, s = "", t, m = !1) => {
|
54
54
|
if (!o) throw new Error("No styles provided to parseStyles function!");
|
55
|
-
const e = /* @__PURE__ */ new Set(),
|
55
|
+
const e = /* @__PURE__ */ new Set(), p = Object.entries(o), f = async ([u, r]) => {
|
56
56
|
var P;
|
57
|
-
const n = u.trim().replace(/^\?+/g, ""), b =
|
58
|
-
if (typeof r == "function") return
|
59
|
-
if (r instanceof Promise) return
|
57
|
+
const n = u.trim().replace(/^\?+/g, ""), b = q(n), h = (a, c = ";") => `${b}:${a}${c}`, C = { scope: s, config: t };
|
58
|
+
if (typeof r == "function") return f([u, r(C)]);
|
59
|
+
if (r instanceof Promise) return f([u, await r]);
|
60
60
|
if (t != null && t.templates && t.templatePaths[n])
|
61
61
|
try {
|
62
|
-
const [a, c] = t.templatePaths[n].split(";;"), i = await import(c),
|
63
|
-
if (
|
62
|
+
const [a, c] = t.templatePaths[n].split(";;"), i = await import(c), d = c.includes("salty.config"), l = d ? i[a].templates : i[a], $ = d ? l[n] : l.params[n];
|
63
|
+
if (l && typeof $ == "function") {
|
64
64
|
const j = await $(r), [w] = await y(j, "");
|
65
65
|
return w;
|
66
66
|
}
|
@@ -69,8 +69,8 @@ const U = (o) => (s) => {
|
|
69
69
|
return;
|
70
70
|
}
|
71
71
|
if (t != null && t.templates && t.templates[n]) {
|
72
|
-
if (
|
73
|
-
const c = r.split(".").reduce((i,
|
72
|
+
if (m) return;
|
73
|
+
const c = r.split(".").reduce((i, d) => i[d], t.templates[n]);
|
74
74
|
if (c) {
|
75
75
|
const [i] = await y(c, "");
|
76
76
|
return i;
|
@@ -84,27 +84,27 @@ const U = (o) => (s) => {
|
|
84
84
|
if (n === "defaultVariants") return;
|
85
85
|
if (n === "variants") {
|
86
86
|
const i = Object.entries(r);
|
87
|
-
for (const [
|
88
|
-
if (!
|
89
|
-
const $ = Object.entries(
|
87
|
+
for (const [d, l] of i) {
|
88
|
+
if (!l) continue;
|
89
|
+
const $ = Object.entries(l);
|
90
90
|
for (const [j, w] of $) {
|
91
91
|
if (!w) continue;
|
92
|
-
const W = `${s}.${
|
93
|
-
(await y(w, W, t)).forEach((
|
92
|
+
const W = `${s}.${d}-${j}`;
|
93
|
+
(await y(w, W, t)).forEach((I) => e.add(I));
|
94
94
|
}
|
95
95
|
}
|
96
96
|
return;
|
97
97
|
}
|
98
98
|
if (n === "compoundVariants") {
|
99
99
|
for (const i of r) {
|
100
|
-
const { css:
|
101
|
-
(await y(
|
100
|
+
const { css: d, ...l } = i, $ = Object.entries(l).reduce((w, [W, V]) => `${w}.${W}-${V}`, s);
|
101
|
+
(await y(d, $, t)).forEach((w) => e.add(w));
|
102
102
|
}
|
103
103
|
return;
|
104
104
|
}
|
105
105
|
if (n.startsWith("@")) {
|
106
|
-
const i = ((P = t == null ? void 0 : t.mediaQueries) == null ? void 0 : P[n]) || n,
|
107
|
-
e.add(
|
106
|
+
const i = ((P = t == null ? void 0 : t.mediaQueries) == null ? void 0 : P[n]) || n, d = await z(r, s, t), l = `${i} { ${d} }`;
|
107
|
+
e.add(l);
|
108
108
|
return;
|
109
109
|
}
|
110
110
|
const a = u.includes("&") ? n.replaceAll("&", s) : n.startsWith(":") ? `${s}${n}` : `${s} ${n}`;
|
@@ -119,7 +119,7 @@ const U = (o) => (s) => {
|
|
119
119
|
if ("toString" in r) r = r.toString();
|
120
120
|
else throw new Error(`Invalid value type for property ${b}`);
|
121
121
|
return h(r);
|
122
|
-
}, E =
|
122
|
+
}, E = p.map(f), { modifiers: x } = t || {}, v = [A(), U(x)], S = (await Promise.all(E).then((u) => Promise.all(
|
123
123
|
u.map((r) => v.reduce(async (n, b) => {
|
124
124
|
const h = await n;
|
125
125
|
if (!h) return h;
|
@@ -129,19 +129,22 @@ const U = (o) => (s) => {
|
|
129
129
|
let c = "";
|
130
130
|
if (a)
|
131
131
|
for (const i of a)
|
132
|
-
c += await
|
132
|
+
c += await z(i, "");
|
133
133
|
return `${c}${P}`;
|
134
134
|
}, Promise.resolve(r)))
|
135
135
|
))).filter((u) => u !== void 0).join(`
|
136
136
|
`);
|
137
137
|
if (!S.trim()) return Array.from(e);
|
138
|
-
const
|
138
|
+
const T = s ? `${s} {
|
139
139
|
${S}
|
140
140
|
}` : S;
|
141
|
-
return e.has(
|
142
|
-
},
|
141
|
+
return e.has(T) ? Array.from(e) : [T, ...e];
|
142
|
+
}, z = async (o, s, t, m = !1) => (await y(o, s, t, m)).join(`
|
143
143
|
`);
|
144
144
|
export {
|
145
145
|
D as a,
|
146
|
-
|
146
|
+
U as b,
|
147
|
+
y as c,
|
148
|
+
A as d,
|
149
|
+
z as p
|
147
150
|
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
"use strict";const x=require("./dash-case-BJEkFEGQ.cjs"),M=require("./viewport-clamp-kY8JqYzm.cjs"),q=o=>s=>{if(typeof s!="string"||!o)return;let t=s;const u=[];return Object.values(o).forEach(e=>{const{pattern:p,transform:f}=e;t=t.replace(p,C=>{const{value:V,css:v}=f(C);return v&&u.push(v),V})}),{transformed:t,additionalCss:u}},A=o=>s=>typeof s!="string"||!/\{[^{}]+\}/g.test(s)?void 0:{transformed:s.replace(/\{([^{}]+)\}/g,(...e)=>{const p=x.dashCase(e[1].replaceAll(".","-"));return o&&!o.includes(p)&&console.warn(`Token ${p} might not exist`),p.startsWith("-")?`-${p}`:`var(--${p})`})},N=A(),U=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],k=(o,s,t)=>{if(U.some(e=>typeof e=="string"?e===o:e.test(o))){const e=(t==null?void 0:t.defaultUnit)||"px";if(e.startsWith("viewport-clamp:"))try{const f=e.split(":")[1];return M.defineViewportClamp({screenSize:parseInt(f)})(Number(s))}catch(f){throw console.error(f),new Error(`Invalid viewport-clamp value: ${e}`)}return`${s}${e}`}return`${s}`},J=["Webkit","Moz","ms","O"],Q=o=>o.startsWith("-")?o:J.some(s=>o.startsWith(s))?`-${x.dashCase(o)}`:x.dashCase(o),$=async(o,s="",t,u=!1)=>{if(!o)throw new Error("No styles provided to parseStyles function!");const e=new Set,p=Object.entries(o),f=async([m,r])=>{var P;const n=m.trim().replace(/^\?+/g,""),b=Q(n),h=(a,c=";")=>`${b}:${a}${c}`,E={scope:s,config:t};if(typeof r=="function")return f([m,r(E)]);if(r instanceof Promise)return f([m,await r]);if(t!=null&&t.templates&&t.templatePaths[n])try{const[a,c]=t.templatePaths[n].split(";;"),i=await import(c),l=c.includes("salty.config"),d=l?i[a].templates:i[a],y=l?d[n]:d.params[n];if(d&&typeof y=="function"){const S=await y(r),[w]=await $(S,"");return w}}catch(a){console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`,a);return}if(t!=null&&t.templates&&t.templates[n]){if(u)return;const c=r.split(".").reduce((i,l)=>i[l],t.templates[n]);if(c){const[i]=await $(c,"");return i}console.warn(`Template "${n}" with path of "${r}" was not found in config!`);return}if(typeof r=="object"){if(!r)return;if(r.isColor)return h(r.toString());if(n==="defaultVariants")return;if(n==="variants"){const i=Object.entries(r);for(const[l,d]of i){if(!d)continue;const y=Object.entries(d);for(const[S,w]of y){if(!w)continue;const T=`${s}.${l}-${S}`;(await $(w,T,t)).forEach(I=>e.add(I))}}return}if(n==="compoundVariants"){for(const i of r){const{css:l,...d}=i,y=Object.entries(d).reduce((w,[T,z])=>`${w}.${T}-${z}`,s);(await $(l,y,t)).forEach(w=>e.add(w))}return}if(n.startsWith("@")){const i=((P=t==null?void 0:t.mediaQueries)==null?void 0:P[n])||n,l=await W(r,s,t),d=`${i} { ${l} }`;e.add(d);return}const a=m.includes("&")?n.replaceAll("&",s):n.startsWith(":")?`${s}${n}`:`${s} ${n}`;(await $(r,a,t)).forEach(i=>e.add(i));return}if(typeof r=="number"){const a=k(b,r,t);return h(a)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${b}`);return h(r)},C=p.map(f),{modifiers:V}=t||{},v=[A(),q(V)],j=(await Promise.all(C).then(m=>Promise.all(m.map(r=>v.reduce(async(n,b)=>{const h=await n;if(!h)return h;const E=await b(h);if(!E)return h;const{transformed:P,additionalCss:a}=E;let c="";if(a)for(const i of a)c+=await W(i,"");return`${c}${P}`},Promise.resolve(r)))))).filter(m=>m!==void 0).join(`
|
2
|
+
`);if(!j.trim())return Array.from(e);const O=s?`${s} {
|
3
|
+
${j}
|
4
|
+
}`:j;return e.has(O)?Array.from(e):[O,...e]},W=async(o,s,t,u=!1)=>(await $(o,s,t,u)).join(`
|
5
|
+
`);exports.parseAndJoinStyles=W;exports.parseStyles=$;exports.parseValueModifiers=q;exports.parseValueTokens=A;exports.parseVariableTokens=N;
|
package/parsers/index.cjs
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../parse-styles-DZYIEhB4.cjs"),c=require("../dash-case-BJEkFEGQ.cjs"),p=async(e,s=[])=>{if(!e)return"";const t=[],r={};for(const[n,o]of Object.entries(e))if(typeof o!="function")if(o&&typeof o=="object"){const i=n.trim(),u=await p(o,[...s,i]);t.push(u)}else r[n]=o;if(Object.keys(r).length){const n=s.map(c.dashCase).join("-"),o="t_"+c.toHash(n,4),i=await a.parseAndJoinStyles(r,`.${n}, .${o}`);t.push(i)}return t.join(`
|
2
|
+
`)},y=e=>Object.keys(e),f=e=>e?Object.entries(e).reduce((s,[t,r])=>(typeof r=="function"?s[t]="any":typeof r=="object"&&(s[t]=l(r).map(n=>`"${n}"`).join(" | ")),s),{}):{},l=(e,s="",t=new Set)=>e?(Object.entries(e).forEach(([r,n])=>{const o=s?`${s}.${r}`:r;return typeof n=="object"?l(n,o,t):t.add(s)}),[...t]):[];exports.parseAndJoinStyles=a.parseAndJoinStyles;exports.parseStyles=a.parseStyles;exports.parseValueModifiers=a.parseValueModifiers;exports.parseValueTokens=a.parseValueTokens;exports.parseVariableTokens=a.parseVariableTokens;exports.getTemplateKeys=y;exports.getTemplateTokens=l;exports.getTemplateTypes=f;exports.parseTemplates=p;
|
package/parsers/index.js
CHANGED
@@ -1,12 +1,33 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { p as f } from "../parse-styles-CKmL8EwD.js";
|
2
|
+
import { c as T, b as O, d as $, a as g } from "../parse-styles-CKmL8EwD.js";
|
3
|
+
import { d as p, t as u } from "../dash-case-DBThphLm.js";
|
4
|
+
const l = async (e, s = []) => {
|
5
|
+
if (!e) return "";
|
6
|
+
const t = [], r = {};
|
7
|
+
for (const [n, o] of Object.entries(e))
|
8
|
+
if (typeof o != "function") if (o && typeof o == "object") {
|
9
|
+
const a = n.trim(), c = await l(o, [...s, a]);
|
10
|
+
t.push(c);
|
11
|
+
} else
|
12
|
+
r[n] = o;
|
13
|
+
if (Object.keys(r).length) {
|
14
|
+
const n = s.map(p).join("-"), o = "t_" + u(n, 4), a = await f(r, `.${n}, .${o}`);
|
15
|
+
t.push(a);
|
16
|
+
}
|
17
|
+
return t.join(`
|
18
|
+
`);
|
19
|
+
}, b = (e) => Object.keys(e), m = (e) => e ? Object.entries(e).reduce((s, [t, r]) => (typeof r == "function" ? s[t] = "any" : typeof r == "object" && (s[t] = i(r).map((n) => `"${n}"`).join(" | ")), s), {}) : {}, i = (e, s = "", t = /* @__PURE__ */ new Set()) => e ? (Object.entries(e).forEach(([r, n]) => {
|
20
|
+
const o = s ? `${s}.${r}` : r;
|
21
|
+
return typeof n == "object" ? i(n, o, t) : t.add(s);
|
22
|
+
}), [...t]) : [];
|
3
23
|
export {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
24
|
+
b as getTemplateKeys,
|
25
|
+
i as getTemplateTokens,
|
26
|
+
m as getTemplateTypes,
|
27
|
+
f as parseAndJoinStyles,
|
28
|
+
T as parseStyles,
|
29
|
+
l as parseTemplates,
|
30
|
+
O as parseValueModifiers,
|
31
|
+
$ as parseValueTokens,
|
32
|
+
g as parseVariableTokens
|
12
33
|
};
|
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../should-restart-B6uSbFR6.cjs");exports.checkShouldRestart=e.checkShouldRestart;
|
package/server/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const s=require("fs/promises"),r=require("./index-
|
1
|
+
"use strict";const s=require("fs/promises"),r=require("./index-DV-sarjD.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!(/.+define[A-Z]\w+/.test(e)||/.+keyframes\(.+/.test(e))};exports.checkShouldRestart=i;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { readFile as r } from "fs/promises";
|
2
|
-
import { i as e } from "./index-
|
2
|
+
import { i as e } from "./index-Cpvtq5h9.js";
|
3
3
|
const f = async (t) => {
|
4
4
|
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
5
|
if (t.includes("salty.config")) return !0;
|