next-style 2.1.5 → 2.1.6
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 +21 -21
- package/dist/index.js +20 -20
- package/dist/postcss-plugin/index.cjs +72 -72
- package/dist/postcss-plugin/index.js +72 -72
- package/package.json +1 -7
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
${
|
|
3
|
-
${
|
|
1
|
+
"use strict";var P=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var I=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},B=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of z(e))!F.call(n,s)&&s!==t&&P(n,s,{get:()=>e[s],enumerable:!(r=K(e,s))||r.enumerable});return n};var H=n=>B(P({},"__esModule",{value:!0}),n);var k={};I(k,{BREAKPOINTS:()=>m,StyleCollector:()=>d,camelToKebab:()=>$,createTransformer:()=>D,css:()=>N,deduplicateStyles:()=>A,generateClassHash:()=>f,global:()=>Q,normalizeMediaQuery:()=>R,styleCollector:()=>g,validateCSSProperty:()=>M});module.exports=H(k);function $(n){return n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function f(n){let e=typeof n=="string"?n:JSON.stringify(n),t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=t*16777619>>>0;return t.toString(36)}var m={"@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 R(n){return m[n]??n}function M(n,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function A(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 d=class n{constructor(){this.styles=new Map}addStyle(e){let r=`ns-${f(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:h,container:u,layer:S}=this.parseStyles(e),o=`ns-${f(e)}`,x=this.buildDeclarations(s),W=`.${o} {
|
|
3
|
+
${x}}`,y={};Object.entries(t).forEach(([c,p])=>{let a=R(c),b=this.buildDeclarations(p," ");if(y[a]){let T=y[a].split(`
|
|
4
4
|
`).slice(2,-2).join(`
|
|
5
5
|
`);y[a]=`${a} {
|
|
6
6
|
.${o} {
|
|
7
|
-
${
|
|
8
|
-
${
|
|
7
|
+
${T}
|
|
8
|
+
${b} }
|
|
9
9
|
}`}else y[a]=`${a} {
|
|
10
10
|
.${o} {
|
|
11
|
-
${
|
|
12
|
-
}`}),Object.entries(u).forEach(([c,
|
|
11
|
+
${b} }
|
|
12
|
+
}`}),Object.entries(u).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");y[c]=`${c} {
|
|
13
13
|
.${o} {
|
|
14
14
|
${a} }
|
|
15
|
-
}`});let
|
|
16
|
-
${a}}`});let
|
|
17
|
-
`,Object.entries(
|
|
18
|
-
${
|
|
19
|
-
`}),
|
|
20
|
-
`});let
|
|
15
|
+
}`});let O={};Object.entries(r).forEach(([c,p])=>{let a=this.buildDeclarations(p);O[c]=`.${o}${c} {
|
|
16
|
+
${a}}`});let C="";Object.entries(l).forEach(([c,p])=>{C+=`@keyframes ${c} {
|
|
17
|
+
`,Object.entries(p).forEach(([a,b])=>{let w=this.buildDeclarations(b," ");C+=` ${a} {
|
|
18
|
+
${w} }
|
|
19
|
+
`}),C+=`}
|
|
20
|
+
`});let j={};Object.entries(h).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");j[c]=`@supports ${c} {
|
|
21
21
|
.${o} {
|
|
22
22
|
${a} }
|
|
23
|
-
}`});let
|
|
24
|
-
${a}}`}),{className:o,css:
|
|
25
|
-
`)}),
|
|
23
|
+
}`});let E={};return Object.entries(S).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");E[c]=`@layer ${c} {
|
|
24
|
+
${a}}`}),{className:o,css:W,mediaQueries:y,pseudoClasses:O,keyframes:C,supports:j,layers:E}}parseStyles(e){let t={},r={},s={},l={},h={},u={},S={};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 x=i.slice(0,9)==="@supports"?i.slice(9).trim():i;h[x]=o}else i.startsWith("@container")?u[i]=o:i.startsWith("@layer")?S[i.slice(7)||"default"]=o:i in m||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:h,container:u,layer:S}}buildDeclarations(e,t=" "){let r="";return Object.entries(e).forEach(([s,l])=>{(typeof l=="string"||typeof l=="number")&&(r+=`${t}${$(s)}: ${l};
|
|
25
|
+
`)}),r}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??
|
|
27
|
+
`),Object.values(t.pseudoClasses).forEach(s=>{e+=`${s}
|
|
28
|
+
`}),Object.values(t.layers).forEach(s=>{e+=`${s}
|
|
29
|
+
`}),Object.values(t.supports).forEach(s=>{e+=`${s}
|
|
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){if(!(typeof process>"u"||process.versions?.node==null))try{let t=require("fs"),r=require("path"),s=e??n.defaultCacheFile();t.mkdirSync(r.dirname(s),{recursive:!0}),t.writeFileSync(s,this.getAllStyles(),"utf-8")}catch(t){console.error("Failed to flush styles to cache file:",t)}}static defaultCacheFile(){return require("path").join(process.cwd(),"node_modules",".cache","next-style","styles.css")}getStyleMap(){return new Map(this.styles)}};function D(){let n=new d;return{collector:n,transformCssCall(e){return n.addStyle(e)}}}function N(n){let e=g.addStyle(n);return g.flush(),e}function Q(n){Object.entries(n).forEach(([e,t])=>{g.addGlobalStyle(e,t)}),g.flush()}var g=new d;0&&(module.exports={BREAKPOINTS,StyleCollector,camelToKebab,createTransformer,css,deduplicateStyles,generateClassHash,global,normalizeMediaQuery,styleCollector,validateCSSProperty});
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
${
|
|
3
|
-
${$}}`,
|
|
1
|
+
var R=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});function x(n){return n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function C(n){let e=typeof n=="string"?n:JSON.stringify(n),t=2166136261;for(let s=0;s<e.length;s++)t^=e.charCodeAt(s),t=t*16777619>>>0;return t.toString(36)}var b={"@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 P(n){return b[n]??n}function D(n,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function N(n){let e=new Map,t=new Set;return n.forEach((s,r)=>{let l=JSON.stringify(s);t.has(l)||(t.add(l),e.set(r,s))}),e}var y=class n{constructor(){this.styles=new Map}addStyle(e){let s=`ns-${C(e)}`;if(this.styles.has(s))return s;let r=this.compileStyle(e);return this.styles.set(s,r),s}addGlobalStyle(e,t){let s=`global:${e}`;if(this.styles.has(s))return;let r=this.buildDeclarations(t);r&&this.styles.set(s,{className:s,css:`${e} {
|
|
2
|
+
${r}}`,mediaQueries:{},pseudoClasses:{},keyframes:"",supports:{},layers:{}})}compileStyle(e){let{mediaQueries:t,pseudoClasses:s,normalStyles:r,keyframes:l,supports:f,container:m,layer:h}=this.parseStyles(e),o=`ns-${C(e)}`,$=this.buildDeclarations(r),M=`.${o} {
|
|
3
|
+
${$}}`,d={};Object.entries(t).forEach(([c,p])=>{let a=P(c),S=this.buildDeclarations(p," ");if(d[a]){let A=d[a].split(`
|
|
4
4
|
`).slice(2,-2).join(`
|
|
5
|
-
`);
|
|
5
|
+
`);d[a]=`${a} {
|
|
6
6
|
.${o} {
|
|
7
|
-
${
|
|
7
|
+
${A}
|
|
8
8
|
${S} }
|
|
9
|
-
}`}else
|
|
9
|
+
}`}else d[a]=`${a} {
|
|
10
10
|
.${o} {
|
|
11
11
|
${S} }
|
|
12
|
-
}`}),Object.entries(
|
|
12
|
+
}`}),Object.entries(m).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");d[c]=`${c} {
|
|
13
13
|
.${o} {
|
|
14
14
|
${a} }
|
|
15
|
-
}`});let
|
|
16
|
-
${a}}`});let u="";Object.entries(l).forEach(([c,
|
|
17
|
-
`,Object.entries(
|
|
18
|
-
${
|
|
15
|
+
}`});let O={};Object.entries(s).forEach(([c,p])=>{let a=this.buildDeclarations(p);O[c]=`.${o}${c} {
|
|
16
|
+
${a}}`});let u="";Object.entries(l).forEach(([c,p])=>{u+=`@keyframes ${c} {
|
|
17
|
+
`,Object.entries(p).forEach(([a,S])=>{let w=this.buildDeclarations(S," ");u+=` ${a} {
|
|
18
|
+
${w} }
|
|
19
19
|
`}),u+=`}
|
|
20
|
-
`});let
|
|
20
|
+
`});let j={};Object.entries(f).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");j[c]=`@supports ${c} {
|
|
21
21
|
.${o} {
|
|
22
22
|
${a} }
|
|
23
|
-
}`});let
|
|
24
|
-
${a}}`}),{className:o,css:
|
|
25
|
-
`)}),
|
|
23
|
+
}`});let E={};return Object.entries(h).forEach(([c,p])=>{let a=this.buildDeclarations(p," ");E[c]=`@layer ${c} {
|
|
24
|
+
${a}}`}),{className:o,css:M,mediaQueries:d,pseudoClasses:O,keyframes:u,supports:j,layers:E}}parseStyles(e){let t={},s={},r={},l={},f={},m={},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;f[$]=o}else i.startsWith("@container")?m[i]=o:i.startsWith("@layer")?h[i.slice(7)||"default"]=o:i in b||i.startsWith("@media")?s[i]=o:i.startsWith(":")||i.startsWith("::")?r[i]=o:t[i]=o}),{normalStyles:t,mediaQueries:s,pseudoClasses:r,keyframes:l,supports:f,container:m,layer:h}}buildDeclarations(e,t=" "){let s="";return Object.entries(e).forEach(([r,l])=>{(typeof l=="string"||typeof l=="number")&&(s+=`${t}${x(r)}: ${l};
|
|
25
|
+
`)}),s}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??n.defaultCacheFile();
|
|
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){if(!(typeof process>"u"||process.versions?.node==null))try{let t=R("fs"),s=R("path"),r=e??n.defaultCacheFile();t.mkdirSync(s.dirname(r),{recursive:!0}),t.writeFileSync(r,this.getAllStyles(),"utf-8")}catch(t){console.error("Failed to flush styles to cache file:",t)}}static defaultCacheFile(){return R("path").join(process.cwd(),"node_modules",".cache","next-style","styles.css")}getStyleMap(){return new Map(this.styles)}};function Q(){let n=new y;return{collector:n,transformCssCall(e){return n.addStyle(e)}}}function W(n){let e=g.addStyle(n);return g.flush(),e}function T(n){Object.entries(n).forEach(([e,t])=>{g.addGlobalStyle(e,t)}),g.flush()}var g=new y;export{b as BREAKPOINTS,y as StyleCollector,x as camelToKebab,Q as createTransformer,W as css,N as deduplicateStyles,C as generateClassHash,T as global,P as normalizeMediaQuery,g as styleCollector,D as validateCSSProperty};
|