next-style 2.0.7 → 2.0.8
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/index.cjs +27 -27
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +25 -25
- package/dist/postcss-plugin/index.cjs +1 -1
- package/dist/postcss-plugin/index.d.cts +1 -1
- package/dist/postcss-plugin/index.d.ts +1 -1
- package/dist/postcss-plugin/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
${
|
|
3
|
-
${
|
|
1
|
+
"use strict";var G=Object.create;var $=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var _=(s,e)=>{for(var t in e)$(s,t,{get:e[t],enumerable:!0})},D=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!Z.call(s,r)&&r!==t&&$(s,r,{get:()=>e[r],enumerable:!(n=J(e,r))||n.enumerable});return s};var O=(s,e,t)=>(t=s!=null?G(k(s)):{},D(e||!s||!s.__esModule?$(t,"default",{value:s,enumerable:!0}):t,s)),U=s=>D($({},"__esModule",{value:!0}),s);var V={};_(V,{BREAKPOINTS:()=>f,StyleCollector:()=>d,camelToKebab:()=>R,createTransformer:()=>z,css:()=>I,deduplicateStyles:()=>Q,generateClassHash:()=>m,global:()=>B,normalizeMediaQuery:()=>x,styleCollector:()=>y,validateCSSProperty:()=>N});module.exports=U(V);var W=O(require("fs"),1),T=O(require("os"),1),K=O(require("path"),1);function R(s){return s.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function m(s){let e=typeof s=="string"?s:JSON.stringify(s),t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t=t&t}return Math.abs(t).toString(36)}var f={"@sm":"@media (min-width: 640px)","@md":"@media (min-width: 768px)","@lg":"@media (min-width: 1024px)","@xl":"@media (min-width: 1280px)","@2xl":"@media (min-width: 1536px)"};function x(s){return f[s]??s}function N(s,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function Q(s){let e=new Map,t=new Set;return s.forEach((n,r)=>{let l=JSON.stringify(n);t.has(l)||(t.add(l),e.set(r,n))}),e}var d=class{constructor(){this.styles=new Map}addStyle(e){let n=`ns-${m(e)}`;if(this.styles.has(n))return n;let r=this.compileStyle(e);return this.styles.set(n,r),n}addGlobalStyle(e,t){let n=`global:${e}`;if(this.styles.has(n))return;let r=this.buildDeclarations(t);r&&this.styles.set(n,{className:n,css:`${e} {
|
|
2
|
+
${r}}`,mediaQueries:{},pseudoClasses:{},keyframes:"",supports:{},layers:{}})}compileStyle(e){let{mediaQueries:t,pseudoClasses:n,normalStyles:r,keyframes:l,supports:h,container:S,layer:u}=this.parseStyles(e),o=`ns-${m(e)}`,P=this.buildDeclarations(r),H=`.${o} {
|
|
3
|
+
${P}}`,g={};Object.entries(t).forEach(([c,p])=>{let a=x(c),C=this.buildDeclarations(p," ");if(g[a]){let F=g[a].split(`
|
|
4
4
|
`).slice(2,-2).join(`
|
|
5
|
-
`);
|
|
6
|
-
.${
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
}`}else
|
|
10
|
-
.${
|
|
11
|
-
${
|
|
12
|
-
}`}),Object.entries(
|
|
13
|
-
.${
|
|
14
|
-
${
|
|
15
|
-
}`});let
|
|
16
|
-
${
|
|
17
|
-
`,Object.entries(p).forEach(([
|
|
18
|
-
${
|
|
5
|
+
`);g[a]=`${a} {
|
|
6
|
+
.${o} {
|
|
7
|
+
${F}
|
|
8
|
+
${C} }
|
|
9
|
+
}`}else g[a]=`${a} {
|
|
10
|
+
.${o} {
|
|
11
|
+
${C} }
|
|
12
|
+
}`}),Object.entries(S).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");g[c]=`${c} {
|
|
13
|
+
.${o} {
|
|
14
|
+
${a} }
|
|
15
|
+
}`});let E={};Object.entries(n).forEach(([c,p])=>{let a=this.buildDeclarations(p);E[c]=`.${o}${c} {
|
|
16
|
+
${a}}`});let b="";Object.entries(l).forEach(([c,p])=>{b+=`@keyframes ${c} {
|
|
17
|
+
`,Object.entries(p).forEach(([a,C])=>{let A=this.buildDeclarations(C," ");b+=` ${a} {
|
|
18
|
+
${A} }
|
|
19
19
|
`}),b+=`}
|
|
20
|
-
`});let
|
|
21
|
-
.${
|
|
22
|
-
${
|
|
23
|
-
}`});let
|
|
24
|
-
${
|
|
20
|
+
`});let M={};Object.entries(h).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");M[c]=`@supports ${c} {
|
|
21
|
+
.${o} {
|
|
22
|
+
${a} }
|
|
23
|
+
}`});let w={};return Object.entries(u).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");w[c]=`@layer ${c} {
|
|
24
|
+
${a}}`}),{className:o,css:H,mediaQueries:g,pseudoClasses:E,keyframes:b,supports:M,layers:w}}parseStyles(e){let t={},n={},r={},l={},h={},S={},u={};return Object.entries(e).forEach(([i,o])=>{if(i.startsWith("@keyframes "))l[i.slice(11)]=o;else if(i==="@keyframes"&&typeof o=="object")Object.assign(l,o);else if(i.startsWith("@supports")){let P=i.slice(0,9)==="@supports"?i.slice(9).trim():i;h[P]=o}else i.startsWith("@container")?S[i]=o:i.startsWith("@layer")?u[i.slice(7)||"default"]=o:i in f||i.startsWith("@media")?n[i]=o:i.startsWith(":")||i.startsWith("::")?r[i]=o:t[i]=o}),{normalStyles:t,mediaQueries:n,pseudoClasses:r,keyframes:l,supports:h,container:S,layer:u}}buildDeclarations(e,t=" "){let n="";return Object.entries(e).forEach(([r,l])=>{(typeof l=="string"||typeof l=="number")&&(n+=`${t}${R(r)}: ${l};
|
|
25
25
|
`)}),n}getAllStyles(){let e="";return this.styles.forEach(t=>{t.keyframes&&(e+=`${t.keyframes}
|
|
26
26
|
`),t.css&&(e+=`${t.css}
|
|
27
|
-
`),Object.values(t.pseudoClasses).forEach(
|
|
28
|
-
`}),Object.values(t.layers).forEach(
|
|
29
|
-
`}),Object.values(t.supports).forEach(
|
|
30
|
-
`}),Object.entries(t.mediaQueries).sort(([
|
|
31
|
-
`})}),e}extractMinWidth(e){let t=e.match(/min-width:\s*(\d+)px/);return t?parseInt(t[1],10):0}flush(e){try{let t=e??K.default.join(
|
|
27
|
+
`),Object.values(t.pseudoClasses).forEach(r=>{e+=`${r}
|
|
28
|
+
`}),Object.values(t.layers).forEach(r=>{e+=`${r}
|
|
29
|
+
`}),Object.values(t.supports).forEach(r=>{e+=`${r}
|
|
30
|
+
`}),Object.entries(t.mediaQueries).sort(([r],[l])=>this.extractMinWidth(r)-this.extractMinWidth(l)).forEach(([,r])=>{e+=`${r}
|
|
31
|
+
`})}),e}extractMinWidth(e){let t=e.match(/min-width:\s*(\d+)px/);return t?parseInt(t[1],10):0}flush(e){try{let t=e??K.default.join(T.default.tmpdir(),"next-style.css");W.default.writeFileSync(t,this.getAllStyles(),"utf-8")}catch(t){console.error("Failed to flush styles to cache file:",t)}}getStyleMap(){return new Map(this.styles)}};function z(){let s=new d;return{collector:s,transformCssCall(e){return s.addStyle(e)}}}function I(s){let e=y.addStyle(s);return y.flush(),e}function B(s){Object.entries(s).forEach(([e,t])=>{y.addGlobalStyle(e,t)}),y.flush()}var y=new d;0&&(module.exports={BREAKPOINTS,StyleCollector,camelToKebab,createTransformer,css,deduplicateStyles,generateClassHash,global,normalizeMediaQuery,styleCollector,validateCSSProperty});
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
${s}}`,mediaQueries:{},pseudoClasses:{},keyframes:"",supports:{},layers:{}})}compileStyle(e){let{mediaQueries:t,pseudoClasses:r,normalStyles:s,keyframes:
|
|
3
|
-
${
|
|
1
|
+
import W from"fs";import T from"os";import K from"path";function P(n){return n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function b(n){let e=typeof n=="string"?n:JSON.stringify(n),t=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);t=(t<<5)-t+s,t=t&t}return Math.abs(t).toString(36)}var C={"@sm":"@media (min-width: 640px)","@md":"@media (min-width: 768px)","@lg":"@media (min-width: 1024px)","@xl":"@media (min-width: 1280px)","@2xl":"@media (min-width: 1536px)"};function O(n){return C[n]??n}function N(n,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function Q(n){let e=new Map,t=new Set;return n.forEach((r,s)=>{let l=JSON.stringify(r);t.has(l)||(t.add(l),e.set(s,r))}),e}var g=class{constructor(){this.styles=new Map}addStyle(e){let r=`ns-${b(e)}`;if(this.styles.has(r))return r;let s=this.compileStyle(e);return this.styles.set(r,s),r}addGlobalStyle(e,t){let r=`global:${e}`;if(this.styles.has(r))return;let s=this.buildDeclarations(t);s&&this.styles.set(r,{className:r,css:`${e} {
|
|
2
|
+
${s}}`,mediaQueries:{},pseudoClasses:{},keyframes:"",supports:{},layers:{}})}compileStyle(e){let{mediaQueries:t,pseudoClasses:r,normalStyles:s,keyframes:l,supports:m,container:f,layer:h}=this.parseStyles(e),o=`ns-${b(e)}`,$=this.buildDeclarations(s),A=`.${o} {
|
|
3
|
+
${$}}`,d={};Object.entries(t).forEach(([c,p])=>{let a=O(c),u=this.buildDeclarations(p," ");if(d[a]){let D=d[a].split(`
|
|
4
4
|
`).slice(2,-2).join(`
|
|
5
|
-
`);
|
|
6
|
-
.${
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
}`}else
|
|
10
|
-
.${
|
|
11
|
-
${
|
|
12
|
-
}`}),Object.entries(
|
|
13
|
-
.${
|
|
14
|
-
${
|
|
15
|
-
}`});let j={};Object.entries(r).forEach(([
|
|
16
|
-
${
|
|
17
|
-
`,Object.entries(p).forEach(([
|
|
18
|
-
${
|
|
19
|
-
`}),
|
|
20
|
-
`});let
|
|
21
|
-
.${
|
|
22
|
-
${
|
|
23
|
-
}`});let
|
|
24
|
-
${
|
|
5
|
+
`);d[a]=`${a} {
|
|
6
|
+
.${o} {
|
|
7
|
+
${D}
|
|
8
|
+
${u} }
|
|
9
|
+
}`}else d[a]=`${a} {
|
|
10
|
+
.${o} {
|
|
11
|
+
${u} }
|
|
12
|
+
}`}),Object.entries(f).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");d[c]=`${c} {
|
|
13
|
+
.${o} {
|
|
14
|
+
${a} }
|
|
15
|
+
}`});let j={};Object.entries(r).forEach(([c,p])=>{let a=this.buildDeclarations(p);j[c]=`.${o}${c} {
|
|
16
|
+
${a}}`});let S="";Object.entries(l).forEach(([c,p])=>{S+=`@keyframes ${c} {
|
|
17
|
+
`,Object.entries(p).forEach(([a,u])=>{let w=this.buildDeclarations(u," ");S+=` ${a} {
|
|
18
|
+
${w} }
|
|
19
|
+
`}),S+=`}
|
|
20
|
+
`});let E={};Object.entries(m).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");E[c]=`@supports ${c} {
|
|
21
|
+
.${o} {
|
|
22
|
+
${a} }
|
|
23
|
+
}`});let M={};return Object.entries(h).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");M[c]=`@layer ${c} {
|
|
24
|
+
${a}}`}),{className:o,css:A,mediaQueries:d,pseudoClasses:j,keyframes:S,supports:E,layers:M}}parseStyles(e){let t={},r={},s={},l={},m={},f={},h={};return Object.entries(e).forEach(([i,o])=>{if(i.startsWith("@keyframes "))l[i.slice(11)]=o;else if(i==="@keyframes"&&typeof o=="object")Object.assign(l,o);else if(i.startsWith("@supports")){let $=i.slice(0,9)==="@supports"?i.slice(9).trim():i;m[$]=o}else i.startsWith("@container")?f[i]=o:i.startsWith("@layer")?h[i.slice(7)||"default"]=o:i in C||i.startsWith("@media")?r[i]=o:i.startsWith(":")||i.startsWith("::")?s[i]=o:t[i]=o}),{normalStyles:t,mediaQueries:r,pseudoClasses:s,keyframes:l,supports:m,container:f,layer:h}}buildDeclarations(e,t=" "){let r="";return Object.entries(e).forEach(([s,l])=>{(typeof l=="string"||typeof l=="number")&&(r+=`${t}${P(s)}: ${l};
|
|
25
25
|
`)}),r}getAllStyles(){let e="";return this.styles.forEach(t=>{t.keyframes&&(e+=`${t.keyframes}
|
|
26
26
|
`),t.css&&(e+=`${t.css}
|
|
27
27
|
`),Object.values(t.pseudoClasses).forEach(s=>{e+=`${s}
|
|
28
28
|
`}),Object.values(t.layers).forEach(s=>{e+=`${s}
|
|
29
29
|
`}),Object.values(t.supports).forEach(s=>{e+=`${s}
|
|
30
|
-
`}),Object.entries(t.mediaQueries).sort(([s],[
|
|
31
|
-
`})}),e}extractMinWidth(e){let t=e.match(/min-width:\s*(\d+)px/);return t?parseInt(t[1],10):0}flush(e){try{let t=e??K.join(
|
|
30
|
+
`}),Object.entries(t.mediaQueries).sort(([s],[l])=>this.extractMinWidth(s)-this.extractMinWidth(l)).forEach(([,s])=>{e+=`${s}
|
|
31
|
+
`})}),e}extractMinWidth(e){let t=e.match(/min-width:\s*(\d+)px/);return t?parseInt(t[1],10):0}flush(e){try{let t=e??K.join(T.tmpdir(),"next-style.css");W.writeFileSync(t,this.getAllStyles(),"utf-8")}catch(t){console.error("Failed to flush styles to cache file:",t)}}getStyleMap(){return new Map(this.styles)}};function z(){let n=new g;return{collector:n,transformCssCall(e){return n.addStyle(e)}}}function I(n){let e=y.addStyle(n);return y.flush(),e}function B(n){Object.entries(n).forEach(([e,t])=>{y.addGlobalStyle(e,t)}),y.flush()}var y=new g;export{C as BREAKPOINTS,g as StyleCollector,P as camelToKebab,z as createTransformer,I as css,Q as deduplicateStyles,b as generateClassHash,B as global,O as normalizeMediaQuery,y as styleCollector,N as validateCSSProperty};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.create;var r=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of y(t))!F.call(e,s)&&s!==n&&r(e,s,{get:()=>t[s],enumerable:!(c=x(t,s))||c.enumerable});return e};var l=(e,t,n)=>(n=e!=null?h(P(e)):{},u(t||!e||!e.__esModule?r(n,"default",{value:e,enumerable:!0}):n,e)),C=e=>u(r({},"__esModule",{value:!0}),e);var w={};O(w,{CACHE_FILE:()=>g,default:()=>_,plugin:()=>v});module.exports=C(w);var m=l(require("fs"),1),f=l(require("path"),1),o=l(require("postcss"),1),E=/^next-style$/,g=f.default.join(process.cwd(),"node_modules",".cache","next-style","styles.css");function p(e={}){let t=e.cacheFile??g;return{postcssPlugin:"next-style",Once(c){let s="";try{s=m.default.readFileSync(t,"utf-8")}catch{}let a=!1;c.walkAtRules("import",i=>{let d=i.params.replace(/['"]/g,"").trim();E.test(d)&&(s.trim()?i.replaceWith(o.default.parse(s)):i.remove(),a=!0)}),!a&&s.trim()&&c.prepend(o.default.parse(s))}}}p.postcss=!0;var _=p,v=p;0&&(module.exports={CACHE_FILE,plugin});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p from"fs";import a from"path";import r from"postcss";var u=/^next-style$/,m=a.join(process.cwd(),"node_modules",".cache","next-style","styles.css");function s(i={}){let l=i.cacheFile??m;return{postcssPlugin:"next-style",Once(n){let e="";try{e=p.readFileSync(l,"utf-8")}catch{}let c=!1;n.walkAtRules("import",t=>{let o=t.params.replace(/['"]/g,"").trim();u.test(o)&&(e.trim()?t.replaceWith(r.parse(e)):t.remove(),c=!0)}),!c&&e.trim()&&n.prepend(r.parse(e))}}}s.postcss=!0;var P=s,F=s;export{m as CACHE_FILE,P as default,F as plugin};
|