next-style 2.2.3 → 2.2.4
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/README.md +5 -5
- package/dist/index.cjs +16 -16
- package/dist/index.js +21 -21
- package/dist/postcss-plugin/index.cjs +41 -41
- package/dist/postcss-plugin/index.js +41 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -650,16 +650,16 @@ export function ThemeToggle() {
|
|
|
650
650
|
1. ✅ Check that `postcss.config.js` includes `"next-style/plugin": {}`
|
|
651
651
|
2. ✅ Check that `@import "next-style";` is at the **top** of `globals.css` (before other styles)
|
|
652
652
|
3. ✅ Verify you imported `css` from the correct package:
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
653
|
+
```tsx
|
|
654
|
+
import { css } from "next-style" // ✓ correct
|
|
655
|
+
import { css } from "next-style/plugin" // ✗ incorrect
|
|
656
|
+
```
|
|
657
657
|
4. ✅ Restart the dev server after any PostCSS config change
|
|
658
658
|
5. ✅ Clear the Next.js cache: `rm -rf .next` and restart
|
|
659
659
|
|
|
660
660
|
### First cold boot shows no styles
|
|
661
661
|
|
|
662
|
-
On the very first build, no `css()` calls have been evaluated yet so the cache file doesn't exist.
|
|
662
|
+
On the very first build, no `css()` calls have been evaluated yet so the cache file doesn't exist. Starting from v2.2.4, cold builds work automatically — the PostCSS plugin scans your source files directly when the cache file is missing, so no prior dev run is required.
|
|
663
663
|
|
|
664
664
|
**For production/CI builds:** The PostCSS plugin automatically scans your source files to extract styles if the cache file is missing, so cold builds on GitHub Actions, Vercel, or other CI systems work without extra setup.
|
|
665
665
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";var H=Object.create;var $=Object.defineProperty;var
|
|
2
|
-
${r}}`,mediaQueries:{},pseudoClasses:{},keyframes:"",supports:{},layers:{}})}compileStyle(e){let{mediaQueries:t,pseudoClasses:n,normalStyles:r,keyframes:
|
|
3
|
-
${P}}`,y={};Object.entries(t).forEach(([
|
|
1
|
+
"use strict";var H=Object.create;var $=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var Z=(s,e)=>{for(var t in e)$(s,t,{get:e[t],enumerable:!0})},N=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!v.call(s,r)&&r!==t&&$(s,r,{get:()=>e[r],enumerable:!(n=G(e,r))||n.enumerable});return s};var Q=(s,e,t)=>(t=s!=null?H(L(s)):{},N(e||!s||!s.__esModule?$(t,"default",{value:s,enumerable:!0}):t,s)),_=s=>N($({},"__esModule",{value:!0}),s);var U={};Z(U,{BREAKPOINTS:()=>g,StyleCollector:()=>p,camelToKebab:()=>R,createTransformer:()=>z,css:()=>k,deduplicateStyles:()=>T,generateClassHash:()=>f,global:()=>F,normalizeMediaQuery:()=>x,styleCollector:()=>m,validateCSSProperty:()=>W});module.exports=_(U);var O=Q(require("fs"),1),E=Q(require("path"),1);function R(s){return s.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function f(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 g={"@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 g[s]??s}function W(s,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function T(s){let e=new Map,t=new Set;return s.forEach((n,r)=>{let a=JSON.stringify(n);t.has(a)||(t.add(a),e.set(r,n))}),e}function K(s){let e={};for(let[t,n]of Object.entries(s)){let r=g[t]??t;e[r]=n&&typeof n=="object"&&!Array.isArray(n)?K(n):n}return e}var p=class s{constructor(){this.styles=new Map}addStyle(e){let t=K(e),r=`ns-${f(t)}`;if(this.styles.has(r))return r;let a=this.compileStyle(t);return this.styles.set(r,a),r}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:a,supports:h,container:u,layer:S}=this.parseStyles(e),o=`ns-${f(e)}`,P=this.buildDeclarations(r),I=`.${o} {
|
|
3
|
+
${P}}`,y={};Object.entries(t).forEach(([l,d])=>{let c=x(l),C=this.buildDeclarations(d," ");if(y[c]){let B=y[c].split(`
|
|
4
4
|
`).slice(2,-2).join(`
|
|
5
|
-
`);y[
|
|
5
|
+
`);y[c]=`${c} {
|
|
6
6
|
.${o} {
|
|
7
7
|
${B}
|
|
8
8
|
${C} }
|
|
9
|
-
}`}else y[
|
|
9
|
+
}`}else y[c]=`${c} {
|
|
10
10
|
.${o} {
|
|
11
11
|
${C} }
|
|
12
|
-
}`}),Object.entries(u).forEach(([
|
|
12
|
+
}`}),Object.entries(u).forEach(([l,d])=>{let c=this.buildDeclarations(d," ");y[l]=`${l} {
|
|
13
13
|
.${o} {
|
|
14
|
-
${
|
|
15
|
-
}`});let w={};Object.entries(n).forEach(([
|
|
16
|
-
${
|
|
17
|
-
`,Object.entries(d).forEach(([
|
|
14
|
+
${c} }
|
|
15
|
+
}`});let w={};Object.entries(n).forEach(([l,d])=>{let c=this.buildDeclarations(d);w[l]=`.${o}${l} {
|
|
16
|
+
${c}}`});let b="";Object.entries(a).forEach(([l,d])=>{b+=`@keyframes ${l} {
|
|
17
|
+
`,Object.entries(d).forEach(([c,C])=>{let D=this.buildDeclarations(C," ");b+=` ${c} {
|
|
18
18
|
${D} }
|
|
19
19
|
`}),b+=`}
|
|
20
|
-
`});let
|
|
20
|
+
`});let A={};Object.entries(h).forEach(([l,d])=>{let c=this.buildDeclarations(d," ");A[l]=`@supports ${l} {
|
|
21
21
|
.${o} {
|
|
22
|
-
${
|
|
23
|
-
}`});let
|
|
24
|
-
${
|
|
22
|
+
${c} }
|
|
23
|
+
}`});let M={};return Object.entries(S).forEach(([l,d])=>{let c=this.buildDeclarations(d," ");M[l]=`@layer ${l} {
|
|
24
|
+
${c}}`}),{className:o,css:I,mediaQueries:y,pseudoClasses:w,keyframes:b,supports:A,layers:M}}parseStyles(e){let t={},n={},r={},a={},h={},u={},S={};return Object.entries(e).forEach(([i,o])=>{if(i.startsWith("@keyframes "))a[i.slice(11)]=o;else if(i==="@keyframes"&&typeof o=="object")Object.assign(a,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")?u[i]=o:i.startsWith("@layer")?S[i.slice(7)||"default"]=o:i in g||i.startsWith("@media")?n[i]=o:i.startsWith(":")||i.startsWith("::")?r[i]=o:t[i]=o}),{normalStyles:t,mediaQueries:n,pseudoClasses:r,keyframes:a,supports:h,container:u,layer:S}}buildDeclarations(e,t=" "){let n="";return Object.entries(e).forEach(([r,a])=>{(typeof a=="string"||typeof a=="number")&&(n+=`${t}${R(r)}: ${a};
|
|
25
25
|
`)}),n}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(r=>{e+=`${r}
|
|
28
28
|
`}),Object.values(t.layers).forEach(r=>{e+=`${r}
|
|
29
29
|
`}),Object.values(t.supports).forEach(r=>{e+=`${r}
|
|
30
|
-
`}),Object.entries(t.mediaQueries).sort(([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??s.defaultCacheFile();
|
|
30
|
+
`}),Object.entries(t.mediaQueries).sort(([r],[a])=>this.extractMinWidth(r)-this.extractMinWidth(a)).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??s.defaultCacheFile();O.default.mkdirSync(E.default.dirname(t),{recursive:!0}),O.default.writeFileSync(t,this.getAllStyles(),"utf-8")}catch(t){console.error("Failed to flush styles to cache file:",t)}}static defaultCacheFile(){return E.default.join(process.cwd(),"node_modules",".cache","next-style","styles.css")}getStyleMap(){return new Map(this.styles)}};function z(){let s=new p;return{collector:s,transformCssCall(e){return s.addStyle(e)}}}function k(s){let e=m.addStyle(s);return m.flush(),e}function F(s){Object.entries(s).forEach(([e,t])=>{m.addGlobalStyle(e,t)}),m.flush()}var m=new p;0&&(module.exports={BREAKPOINTS,StyleCollector,camelToKebab,createTransformer,css,deduplicateStyles,generateClassHash,global,normalizeMediaQuery,styleCollector,validateCSSProperty});
|
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
|
-
${$}}`,p={};Object.entries(t).forEach(([
|
|
1
|
+
import M from"fs";import D from"path";function P(n){return n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function C(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 g={"@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 j(n){return g[n]??n}function T(n,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function K(n){let e=new Map,t=new Set;return n.forEach((r,s)=>{let a=JSON.stringify(r);t.has(a)||(t.add(a),e.set(s,r))}),e}function N(n){let e={};for(let[t,r]of Object.entries(n)){let s=g[t]??t;e[s]=r&&typeof r=="object"&&!Array.isArray(r)?N(r):r}return e}var y=class n{constructor(){this.styles=new Map}addStyle(e){let t=N(e),s=`ns-${C(t)}`;if(this.styles.has(s))return s;let a=this.compileStyle(t);return this.styles.set(s,a),s}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:a,supports:f,container:h,layer:u}=this.parseStyles(e),o=`ns-${C(e)}`,$=this.buildDeclarations(s),Q=`.${o} {
|
|
3
|
+
${$}}`,p={};Object.entries(t).forEach(([l,d])=>{let c=j(l),b=this.buildDeclarations(d," ");if(p[c]){let W=p[c].split(`
|
|
4
4
|
`).slice(2,-2).join(`
|
|
5
|
-
`);p[
|
|
5
|
+
`);p[c]=`${c} {
|
|
6
6
|
.${o} {
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
}`}else p[
|
|
7
|
+
${W}
|
|
8
|
+
${b} }
|
|
9
|
+
}`}else p[c]=`${c} {
|
|
10
10
|
.${o} {
|
|
11
|
-
${
|
|
12
|
-
}`}),Object.entries(
|
|
11
|
+
${b} }
|
|
12
|
+
}`}),Object.entries(h).forEach(([l,d])=>{let c=this.buildDeclarations(d," ");p[l]=`${l} {
|
|
13
13
|
.${o} {
|
|
14
|
-
${
|
|
15
|
-
}`});let
|
|
16
|
-
${
|
|
17
|
-
`,Object.entries(d).forEach(([
|
|
18
|
-
${
|
|
19
|
-
`}),
|
|
20
|
-
`});let E={};Object.entries(
|
|
14
|
+
${c} }
|
|
15
|
+
}`});let O={};Object.entries(r).forEach(([l,d])=>{let c=this.buildDeclarations(d);O[l]=`.${o}${l} {
|
|
16
|
+
${c}}`});let S="";Object.entries(a).forEach(([l,d])=>{S+=`@keyframes ${l} {
|
|
17
|
+
`,Object.entries(d).forEach(([c,b])=>{let A=this.buildDeclarations(b," ");S+=` ${c} {
|
|
18
|
+
${A} }
|
|
19
|
+
`}),S+=`}
|
|
20
|
+
`});let E={};Object.entries(f).forEach(([l,d])=>{let c=this.buildDeclarations(d," ");E[l]=`@supports ${l} {
|
|
21
21
|
.${o} {
|
|
22
|
-
${
|
|
23
|
-
}`});let w={};return Object.entries(
|
|
24
|
-
${
|
|
22
|
+
${c} }
|
|
23
|
+
}`});let w={};return Object.entries(u).forEach(([l,d])=>{let c=this.buildDeclarations(d," ");w[l]=`@layer ${l} {
|
|
24
|
+
${c}}`}),{className:o,css:Q,mediaQueries:p,pseudoClasses:O,keyframes:S,supports:E,layers:w}}parseStyles(e){let t={},r={},s={},a={},f={},h={},u={};return Object.entries(e).forEach(([i,o])=>{if(i.startsWith("@keyframes "))a[i.slice(11)]=o;else if(i==="@keyframes"&&typeof o=="object")Object.assign(a,o);else if(i.startsWith("@supports")){let $=i.slice(0,9)==="@supports"?i.slice(9).trim():i;f[$]=o}else i.startsWith("@container")?h[i]=o:i.startsWith("@layer")?u[i.slice(7)||"default"]=o:i in g||i.startsWith("@media")?r[i]=o:i.startsWith(":")||i.startsWith("::")?s[i]=o:t[i]=o}),{normalStyles:t,mediaQueries:r,pseudoClasses:s,keyframes:a,supports:f,container:h,layer:u}}buildDeclarations(e,t=" "){let r="";return Object.entries(e).forEach(([s,a])=>{(typeof a=="string"||typeof a=="number")&&(r+=`${t}${P(s)}: ${a};
|
|
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??n.defaultCacheFile();
|
|
30
|
+
`}),Object.entries(t.mediaQueries).sort(([s],[a])=>this.extractMinWidth(s)-this.extractMinWidth(a)).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??n.defaultCacheFile();M.mkdirSync(D.dirname(t),{recursive:!0}),M.writeFileSync(t,this.getAllStyles(),"utf-8")}catch(t){console.error("Failed to flush styles to cache file:",t)}}static defaultCacheFile(){return D.join(process.cwd(),"node_modules",".cache","next-style","styles.css")}getStyleMap(){return new Map(this.styles)}};function z(){let n=new y;return{collector:n,transformCssCall(e){return n.addStyle(e)}}}function k(n){let e=m.addStyle(n);return m.flush(),e}function F(n){Object.entries(n).forEach(([e,t])=>{m.addGlobalStyle(e,t)}),m.flush()}var m=new y;export{g as BREAKPOINTS,y as StyleCollector,P as camelToKebab,z as createTransformer,k as css,K as deduplicateStyles,C as generateClassHash,F as global,j as normalizeMediaQuery,m as styleCollector,T as validateCSSProperty};
|