@salty-css/webpack 0.0.1-alpha.112 → 0.0.1-alpha.113
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/{index-D6f6VgWV.js → index-B6c67i1F.js} +23 -23
- package/{index-DfOEZJUz.cjs → index-Br4T7QQ3.cjs} +2 -2
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/loader.cjs +1 -1
- package/loader.js +1 -1
- package/package.json +2 -2
@@ -62,8 +62,8 @@ const dt = (t, e) => {
|
|
62
62
|
const d = h.includes("&") ? u.replace("&", e) : u.startsWith(":") ? `${e}${u}` : `${e} ${u}`, b = D(r, d);
|
63
63
|
return o.push(b), a;
|
64
64
|
}
|
65
|
-
const $ = u.startsWith("-") ? u : V(u), k = (d, b = ";") => a = `${a}${d}${b}`,
|
66
|
-
if (typeof r == "number") return
|
65
|
+
const $ = u.startsWith("-") ? u : V(u), k = (d, b = ";") => a = `${a}${d}${b}`, x = (d) => k(`${$}:${d}`);
|
66
|
+
if (typeof r == "number") return x(r);
|
67
67
|
if (typeof r != "string")
|
68
68
|
if ("toString" in r) r = r.toString();
|
69
69
|
else return a;
|
@@ -75,7 +75,7 @@ const dt = (t, e) => {
|
|
75
75
|
const c = D(j, "");
|
76
76
|
k(c, "");
|
77
77
|
});
|
78
|
-
return
|
78
|
+
return x(r);
|
79
79
|
}, "");
|
80
80
|
if (!i) return o.join(`
|
81
81
|
`);
|
@@ -161,10 +161,10 @@ const Q = async (t) => {
|
|
161
161
|
return `${S} { ${E} }`;
|
162
162
|
})) : [], g = n(e.variables), a = o(e.responsiveVariables), h = i(e.conditionalVariables), r = A(t), u = f(r, "css/variables.css"), $ = `:root { ${g.join("")} ${a.join("")} } ${h.join("")}`;
|
163
163
|
P(u, $);
|
164
|
-
const k = f(r, "css/global.css"),
|
165
|
-
P(k,
|
166
|
-
const l = f(r, "css/templates.css"),
|
167
|
-
P(l,
|
164
|
+
const k = f(r, "css/global.css"), x = D(e.global, "");
|
165
|
+
P(k, x);
|
166
|
+
const l = f(r, "css/templates.css"), C = U(e.templates), T = yt(e.templates);
|
167
|
+
P(l, C);
|
168
168
|
const d = f(r, "types/css-tokens.d.ts"), j = `
|
169
169
|
// Variable types
|
170
170
|
type VariableTokens = ${[...s].join("|")};
|
@@ -189,7 +189,7 @@ const Q = async (t) => {
|
|
189
189
|
contents: g,
|
190
190
|
sourcefile: i.base,
|
191
191
|
resolveDir: i.dir,
|
192
|
-
loader: "
|
192
|
+
loader: "tsx"
|
193
193
|
},
|
194
194
|
minify: !1,
|
195
195
|
treeShaking: !0,
|
@@ -220,12 +220,12 @@ const Q = async (t) => {
|
|
220
220
|
W(o) && ot("rm -rf " + o), J(o), J(f(o, "css")), J(f(o, "types"));
|
221
221
|
})(), await wt(t);
|
222
222
|
const a = await z(t);
|
223
|
-
async function h(l,
|
223
|
+
async function h(l, C) {
|
224
224
|
const T = ["node_modules", "saltygen"], d = it(l);
|
225
225
|
if (d.isDirectory()) {
|
226
226
|
const b = ct(l);
|
227
227
|
if (T.some((c) => l.includes(c))) return;
|
228
|
-
await Promise.all(b.map((c) => h(f(l, c), f(
|
228
|
+
await Promise.all(b.map((c) => h(f(l, c), f(C, c))));
|
229
229
|
} else if (d.isFile() && I(l)) {
|
230
230
|
const j = await Z(t, l, o), c = [];
|
231
231
|
Object.entries(j).forEach(([F, w]) => {
|
@@ -252,7 +252,7 @@ const Q = async (t) => {
|
|
252
252
|
await h(t, o);
|
253
253
|
const r = s.map((l) => `@import url('./css/${l}');`).join(`
|
254
254
|
`);
|
255
|
-
let
|
255
|
+
let x = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
256
256
|
|
257
257
|
${["variables.css", "global.css", "templates.css"].filter((l) => {
|
258
258
|
try {
|
@@ -264,11 +264,11 @@ ${["variables.css", "global.css", "templates.css"].filter((l) => {
|
|
264
264
|
`)}
|
265
265
|
${r}`;
|
266
266
|
if (a.importStrategy !== "component") {
|
267
|
-
const l = n.flat().map((
|
267
|
+
const l = n.flat().map((C) => `@import url('./css/${C}');`).join(`
|
268
268
|
`);
|
269
|
-
|
269
|
+
x += l;
|
270
270
|
}
|
271
|
-
P(i,
|
271
|
+
P(i, x);
|
272
272
|
} catch (s) {
|
273
273
|
console.error(s);
|
274
274
|
}
|
@@ -277,13 +277,13 @@ ${r}`;
|
|
277
277
|
const s = [], n = f(t, "./saltygen"), o = f(n, "index.css");
|
278
278
|
if (I(e)) {
|
279
279
|
const g = await z(t), a = await Z(t, e, n);
|
280
|
-
Object.entries(a).forEach(([k,
|
281
|
-
if (!
|
282
|
-
const l =
|
280
|
+
Object.entries(a).forEach(([k, x]) => {
|
281
|
+
if (!x.generator) return;
|
282
|
+
const l = x.generator._withBuildContext({
|
283
283
|
name: k,
|
284
284
|
config: g
|
285
|
-
}),
|
286
|
-
s.push(
|
285
|
+
}), C = `${l.hash}-${l.priority}.css`, T = `css/${C}`, d = f(n, T);
|
286
|
+
s.push(C), P(d, l.css);
|
287
287
|
});
|
288
288
|
const h = N(o, "utf8").split(`
|
289
289
|
`), r = s.map((k) => `@import url('../saltygen/css/${k}');`), $ = [.../* @__PURE__ */ new Set([...h, ...r])].join(`
|
@@ -304,13 +304,13 @@ ${r}`;
|
|
304
304
|
Object.entries(h).forEach(([$, k]) => {
|
305
305
|
var E;
|
306
306
|
if (k.isKeyframes || !k.generator) return;
|
307
|
-
const
|
307
|
+
const x = k.generator._withBuildContext({
|
308
308
|
name: $,
|
309
309
|
config: a,
|
310
310
|
prod: s
|
311
311
|
}), l = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(i);
|
312
312
|
if (!l) return console.error("Could not find the original declaration");
|
313
|
-
const
|
313
|
+
const C = (E = l.at(1)) == null ? void 0 : E.trim(), T = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(r);
|
314
314
|
if (!T) return console.error("Could not find the original declaration");
|
315
315
|
const { index: d } = T;
|
316
316
|
let b = !1;
|
@@ -322,8 +322,8 @@ ${r}`;
|
|
322
322
|
}
|
323
323
|
if (!b) clearTimeout(j);
|
324
324
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
325
|
-
const m = d + c, F = r.slice(d, m), w = r, S = ` ${$} = styled(${
|
326
|
-
r = r.replace(F, S), w === r && console.error("Minimize file failed to change content", { name: $, tagName:
|
325
|
+
const m = d + c, F = r.slice(d, m), w = r, S = ` ${$} = styled(${C}, "${x.classNames}", ${JSON.stringify(x.props)});`;
|
326
|
+
r = r.replace(F, S), w === r && console.error("Minimize file failed to change content", { name: $, tagName: C });
|
327
327
|
});
|
328
328
|
const u = B(e, 6);
|
329
329
|
return a.importStrategy === "component" && (r = `import '../../saltygen/css/${u}.css';
|
@@ -5,7 +5,7 @@
|
|
5
5
|
}`;return o.push(c),a}const g=j.includes("&")?d.replace("&",e):d.startsWith(":")?`${e}${d}`:`${e} ${d}`,$=D(r,g);return o.push($),a}const b=d.startsWith("-")?d:M(d),k=(g,$=";")=>a=`${a}${g}${$}`,C=g=>k(`${b}:${g}`);if(typeof r=="number")return C(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:f}={},P=function*(){yield G(r),yield lt(r,f)}();for(const{result:g,additionalCss:$=[]}of P)r=g,$.forEach(S=>{const c=D(S,"");k(c,"")});return C(r)},"");if(!i)return o.join(`
|
6
6
|
`);if(!e)return i;let y="";return y=`${e} { ${i} }`,[y,...o].join(`
|
7
7
|
`)},H=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const y=o.trim(),a=H(i,[...e,y]);s.push(a)}else n[o]=i}),Object.keys(n).length){const o=e.map(M).join("-"),i=D(n,`.${o}`);s.push(i)}return s.join(`
|
8
|
-
`)},ft=t=>Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=K(n).map(o=>`"${o}"`).join(" | ")),e),{}),K=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const i=e?`${e}.${n}`:n;return typeof o=="object"?K(o,i,s):s.add(e)}),[...s]):[],X=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=l.join(t,"package.json");return u.existsSync(e)?e:X(l.join(t,".."))},ut=async t=>{const e=X(t);return await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},pt=async t=>{const e=await ut(t);if(e)return e.type};let E;const Y=async t=>{if(E)return E;const e=await pt(t);return e==="module"?E="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("index-
|
8
|
+
`)},ft=t=>Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=K(n).map(o=>`"${o}"`).join(" | ")),e),{}),K=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const i=e?`${e}.${n}`:n;return typeof o=="object"?K(o,i,s):s.add(e)}),[...s]):[],X=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=l.join(t,"package.json");return u.existsSync(e)?e:X(l.join(t,".."))},ut=async t=>{const e=X(t);return await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},pt=async t=>{const e=await ut(t);if(e)return e.type};let E;const Y=async t=>{if(E)return E;const e=await pt(t);return e==="module"?E="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("index-Br4T7QQ3.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},Z=V.createLogger({level:"debug",format:V.format.combine(V.format.colorize(),V.format.cli()),transports:[new V.transports.Console({})]}),R={externalModules:[]},Q=t=>{if(R.externalModules.length>0)return R.externalModules;const e=l.join(t,"salty.config.ts"),n=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return R.externalModules=o,o},_=t=>l.join(t,"./saltygen"),dt=["salty","css","styles","styled"],v=(t=[])=>new RegExp(`\\.(${[...dt,...t].join("|")})\\.`),q=(t,e=[])=>v(e).test(t),yt=async t=>{const e=_(t),s=l.join(t,"salty.config.ts"),n=l.join(e,"salty.config.js"),o=await Y(t),i=Q(t);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:i});const y=Date.now(),{config:a}=await import(`${n}?t=${y}`);return a},gt=async t=>{const e=await yt(t),s=new Set,n=(c,p=[])=>c?Object.entries(c).flatMap(([m,h])=>{if(!h)return;if(typeof h=="object")return n(h,[...p,m]);const T=[...p,m].join(".");s.add(`"${T}"`);const w=[...p.map(M),M(m)].join("-"),{result:F}=G(h);return`--${w}: ${F};`}):[],o=c=>c?Object.entries(c).flatMap(([p,m])=>{const h=n(m);return p==="base"?h.join(""):`${p} { ${h.join("")} }`}):[],i=c=>c?Object.entries(c).flatMap(([p,m])=>Object.entries(m).flatMap(([h,T])=>{const w=n(T,[p]),F=`.${p}-${h}, [data-${p}="${h}"]`,O=w.join("");return`${F} { ${O} }`})):[],y=n(e.variables),a=o(e.responsiveVariables),j=i(e.conditionalVariables),r=_(t),d=l.join(r,"css/variables.css"),b=`:root { ${y.join("")} ${a.join("")} } ${j.join("")}`;u.writeFileSync(d,b);const k=l.join(r,"css/global.css"),C=D(e.global,"");u.writeFileSync(k,C);const f=l.join(r,"css/templates.css"),x=H(e.templates),P=ft(e.templates);u.writeFileSync(f,x);const g=l.join(r,"types/css-tokens.d.ts"),S=`
|
9
9
|
// Variable types
|
10
10
|
type VariableTokens = ${[...s].join("|")};
|
11
11
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -15,7 +15,7 @@
|
|
15
15
|
${Object.entries(P).map(([c,p])=>`${c}?: ${p}`).join(`
|
16
16
|
`)}
|
17
17
|
}
|
18
|
-
`;u.writeFileSync(g,S)},I=async(t,e,s)=>{const n=A(e),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=l.parse(e);let y=u.readFileSync(e,"utf8");y=y.replace(/styled\([^"'`{,]+,/g,"styled('div',");const a=l.join(s,"js",n+".js"),j=Q(t),r=await Y(t);await U.build({stdin:{contents:y,sourcefile:i.base,resolveDir:i.dir,loader:"
|
18
|
+
`;u.writeFileSync(g,S)},I=async(t,e,s)=>{const n=A(e),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=l.parse(e);let y=u.readFileSync(e,"utf8");y=y.replace(/styled\([^"'`{,]+,/g,"styled('div',");const a=l.join(s,"js",n+".js"),j=Q(t),r=await Y(t);await U.build({stdin:{contents:y,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:a,format:r,target:["node20"],keepNames:!0,external:j,packages:"external"});const d=Date.now();return await import(`${a}?t=${d}`)},z=async t=>{const e=_(t),s=l.join(e,"salty.config.js"),{config:n}=await import(s);return n},tt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},mt=async(t,e=tt())=>{try{e?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const s=[],n=[],o=_(t),i=l.join(o,"index.css");(()=>{u.existsSync(o)&&rt.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(l.join(o,"css")),u.mkdirSync(l.join(o,"types"))})(),await gt(t);const a=await z(t);async function j(f,x){const P=["node_modules","saltygen"],g=u.statSync(f);if(g.isDirectory()){const $=u.readdirSync(f);if(P.some(c=>f.includes(c)))return;await Promise.all($.map(c=>j(l.join(f,c),l.join(x,c))))}else if(g.isFile()&&q(f)){const S=await I(t,f,o),c=[];Object.entries(S).forEach(([T,w])=>{if(w.isKeyframes&&w.css){const W=`${w.animationName}.css`,st=`css/${W}`,nt=l.join(o,st);s.push(W),u.writeFileSync(nt,w.css);return}if(!w.generator)return;const F=w.generator._withBuildContext({name:T,config:a,prod:e}),O=`${F.hash}-${F.priority}.css`;n[F.priority]||(n[F.priority]=[]),n[F.priority].push(O),c.push(O);const N=`css/${O}`,et=l.join(o,N);u.writeFileSync(et,F.css)});const p=c.map(T=>`@import url('./${T}');`).join(`
|
19
19
|
`),m=A(f,6),h=l.join(o,`css/${m}.css`);u.writeFileSync(h,p)}}await j(t,o);const r=s.map(f=>`@import url('./css/${f}');`).join(`
|
20
20
|
`);let C=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
21
21
|
|
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-Br4T7QQ3.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { resolve as n } from "path";
|
2
|
-
import { s as u, g as i } from "./index-
|
2
|
+
import { s as u, g as i } from "./index-B6c67i1F.js";
|
3
3
|
const g = (s, e, o = !1, r = !1) => {
|
4
4
|
var a, l, t;
|
5
5
|
(l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("./index-
|
1
|
+
"use strict";const i=require("./index-Br4T7QQ3.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
|
package/loader.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/webpack",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.113",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
}
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@salty-css/core": "^0.0.1-alpha.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.113",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|