next-style 2.1.0 → 2.1.1

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 CHANGED
@@ -1,15 +1,15 @@
1
- "use strict";var k=Object.create;var $=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var _=(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 G(e))!L.call(s,r)&&r!==t&&$(s,r,{get:()=>e[r],enumerable:!(n=F(e,r))||n.enumerable});return s};var Q=(s,e,t)=>(t=s!=null?k(J(s)):{},N(e||!s||!s.__esModule?$(t,"default",{value:s,enumerable:!0}):t,s)),Z=s=>N($({},"__esModule",{value:!0}),s);var v={};_(v,{BREAKPOINTS:()=>f,StyleCollector:()=>p,camelToKebab:()=>R,createTransformer:()=>K,css:()=>z,deduplicateStyles:()=>T,generateClassHash:()=>m,global:()=>I,normalizeMediaQuery:()=>x,styleCollector:()=>g,validateCSSProperty:()=>W});module.exports=Z(v);var j=Q(require("fs"),1),E=Q(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 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 l=JSON.stringify(n);t.has(l)||(t.add(l),e.set(r,n))}),e}var p=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),B=`.${o} {
3
- ${P}}`,y={};Object.entries(t).forEach(([c,d])=>{let a=x(c),C=this.buildDeclarations(d," ");if(y[a]){let H=y[a].split(`
1
+ "use strict";var H=Object.create;var $=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,L=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 G(e))!L.call(s,r)&&r!==t&&$(s,r,{get:()=>e[r],enumerable:!(n=k(e,r))||n.enumerable});return s};var Q=(s,e,t)=>(t=s!=null?H(J(s)):{},N(e||!s||!s.__esModule?$(t,"default",{value:s,enumerable:!0}):t,s)),_=s=>N($({},"__esModule",{value:!0}),s);var v={};Z(v,{BREAKPOINTS:()=>f,StyleCollector:()=>p,camelToKebab:()=>R,createTransformer:()=>K,css:()=>z,deduplicateStyles:()=>T,generateClassHash:()=>m,global:()=>F,normalizeMediaQuery:()=>x,styleCollector:()=>g,validateCSSProperty:()=>W});module.exports=_(v);var j=Q(require("fs"),1),E=Q(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 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 l=JSON.stringify(n);t.has(l)||(t.add(l),e.set(r,n))}),e}var p=class s{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:u,layer:S}=this.parseStyles(e),o=`ns-${m(e)}`,P=this.buildDeclarations(r),I=`.${o} {
3
+ ${P}}`,y={};Object.entries(t).forEach(([c,d])=>{let a=x(c),C=this.buildDeclarations(d," ");if(y[a]){let B=y[a].split(`
4
4
  `).slice(2,-2).join(`
5
5
  `);y[a]=`${a} {
6
6
  .${o} {
7
- ${H}
7
+ ${B}
8
8
  ${C} }
9
9
  }`}else y[a]=`${a} {
10
10
  .${o} {
11
11
  ${C} }
12
- }`}),Object.entries(S).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");y[c]=`${c} {
12
+ }`}),Object.entries(u).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");y[c]=`${c} {
13
13
  .${o} {
14
14
  ${a} }
15
15
  }`});let w={};Object.entries(n).forEach(([c,d])=>{let a=this.buildDeclarations(d);w[c]=`.${o}${c} {
@@ -20,12 +20,12 @@ ${D} }
20
20
  `});let M={};Object.entries(h).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");M[c]=`@supports ${c} {
21
21
  .${o} {
22
22
  ${a} }
23
- }`});let A={};return Object.entries(u).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");A[c]=`@layer ${c} {
24
- ${a}}`}),{className:o,css:B,mediaQueries:y,pseudoClasses:w,keyframes:b,supports:M,layers:A}}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};
23
+ }`});let A={};return Object.entries(S).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");A[c]=`@layer ${c} {
24
+ ${a}}`}),{className:o,css:I,mediaQueries:y,pseudoClasses:w,keyframes:b,supports:M,layers:A}}parseStyles(e){let t={},n={},r={},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 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 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:u,layer:S}}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
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
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??E.default.join(process.cwd(),"node_modules",".cache","next-style","styles.css");j.default.mkdirSync(E.default.dirname(t),{recursive:!0}),j.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 K(){let s=new p;return{collector:s,transformCssCall(e){return s.addStyle(e)}}}function z(s){let e=g.addStyle(s);return g.flush(),e}function I(s){Object.entries(s).forEach(([e,t])=>{g.addGlobalStyle(e,t)}),g.flush()}var g=new p;0&&(module.exports={BREAKPOINTS,StyleCollector,camelToKebab,createTransformer,css,deduplicateStyles,generateClassHash,global,normalizeMediaQuery,styleCollector,validateCSSProperty});
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();j.default.mkdirSync(E.default.dirname(t),{recursive:!0}),j.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 K(){let s=new p;return{collector:s,transformCssCall(e){return s.addStyle(e)}}}function z(s){let e=g.addStyle(s);return g.flush(),e}function F(s){Object.entries(s).forEach(([e,t])=>{g.addGlobalStyle(e,t)}),g.flush()}var g=new p;0&&(module.exports={BREAKPOINTS,StyleCollector,camelToKebab,createTransformer,css,deduplicateStyles,generateClassHash,global,normalizeMediaQuery,styleCollector,validateCSSProperty});
package/dist/index.d.cts CHANGED
@@ -77,6 +77,12 @@ declare class StyleCollector {
77
77
  * @param filePath - Destination file path. Defaults to `os.tmpdir()/next-style.css`.
78
78
  */
79
79
  flush(filePath?: string): void;
80
+ /**
81
+ * Returns the default cache file path, resolved at call-time from
82
+ * `process.cwd()` so it reflects the actual working directory of the
83
+ * running process rather than the directory at module-load time.
84
+ */
85
+ static defaultCacheFile(): string;
80
86
  /**
81
87
  * Returns a snapshot of the internal style map.
82
88
  * Intended for inspection and testing — not for direct mutation.
package/dist/index.d.ts CHANGED
@@ -77,6 +77,12 @@ declare class StyleCollector {
77
77
  * @param filePath - Destination file path. Defaults to `os.tmpdir()/next-style.css`.
78
78
  */
79
79
  flush(filePath?: string): void;
80
+ /**
81
+ * Returns the default cache file path, resolved at call-time from
82
+ * `process.cwd()` so it reflects the actual working directory of the
83
+ * running process rather than the directory at module-load time.
84
+ */
85
+ static defaultCacheFile(): string;
80
86
  /**
81
87
  * Returns a snapshot of the internal style map.
82
88
  * Intended for inspection and testing — not for direct mutation.
package/dist/index.js CHANGED
@@ -1,31 +1,31 @@
1
- import A from"fs";import D 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 W(n,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function T(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 y=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} {
1
+ import A from"fs";import D 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 W(n,e){return typeof e=="string"||typeof e=="number"||typeof e=="object"&&!Array.isArray(e)}function T(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 y=class n{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
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),N=`.${o} {
3
- ${$}}`,p={};Object.entries(t).forEach(([c,d])=>{let a=O(c),u=this.buildDeclarations(d," ");if(p[a]){let Q=p[a].split(`
3
+ ${$}}`,p={};Object.entries(t).forEach(([c,d])=>{let a=O(c),S=this.buildDeclarations(d," ");if(p[a]){let Q=p[a].split(`
4
4
  `).slice(2,-2).join(`
5
5
  `);p[a]=`${a} {
6
6
  .${o} {
7
7
  ${Q}
8
- ${u} }
8
+ ${S} }
9
9
  }`}else p[a]=`${a} {
10
10
  .${o} {
11
- ${u} }
11
+ ${S} }
12
12
  }`}),Object.entries(f).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");p[c]=`${c} {
13
13
  .${o} {
14
14
  ${a} }
15
15
  }`});let j={};Object.entries(r).forEach(([c,d])=>{let a=this.buildDeclarations(d);j[c]=`.${o}${c} {
16
- ${a}}`});let S="";Object.entries(l).forEach(([c,d])=>{S+=`@keyframes ${c} {
17
- `,Object.entries(d).forEach(([a,u])=>{let M=this.buildDeclarations(u," ");S+=` ${a} {
16
+ ${a}}`});let u="";Object.entries(l).forEach(([c,d])=>{u+=`@keyframes ${c} {
17
+ `,Object.entries(d).forEach(([a,S])=>{let M=this.buildDeclarations(S," ");u+=` ${a} {
18
18
  ${M} }
19
- `}),S+=`}
19
+ `}),u+=`}
20
20
  `});let E={};Object.entries(m).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");E[c]=`@supports ${c} {
21
21
  .${o} {
22
22
  ${a} }
23
23
  }`});let w={};return Object.entries(h).forEach(([c,d])=>{let a=this.buildDeclarations(d," ");w[c]=`@layer ${c} {
24
- ${a}}`}),{className:o,css:N,mediaQueries:p,pseudoClasses:j,keyframes:S,supports:E,layers:w}}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};
24
+ ${a}}`}),{className:o,css:N,mediaQueries:p,pseudoClasses:j,keyframes:u,supports:E,layers:w}}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
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??D.join(process.cwd(),"node_modules",".cache","next-style","styles.css");A.mkdirSync(D.dirname(t),{recursive:!0}),A.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 K(){let n=new y;return{collector:n,transformCssCall(e){return n.addStyle(e)}}}function z(n){let e=g.addStyle(n);return g.flush(),e}function I(n){Object.entries(n).forEach(([e,t])=>{g.addGlobalStyle(e,t)}),g.flush()}var g=new y;export{C as BREAKPOINTS,y as StyleCollector,P as camelToKebab,K as createTransformer,z as css,T as deduplicateStyles,b as generateClassHash,I as global,O as normalizeMediaQuery,g as styleCollector,W as validateCSSProperty};
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();A.mkdirSync(D.dirname(t),{recursive:!0}),A.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 K(){let n=new y;return{collector:n,transformCssCall(e){return n.addStyle(e)}}}function z(n){let e=g.addStyle(n);return g.flush(),e}function F(n){Object.entries(n).forEach(([e,t])=>{g.addGlobalStyle(e,t)}),g.flush()}var g=new y;export{C as BREAKPOINTS,y as StyleCollector,P as camelToKebab,K as createTransformer,z as css,T as deduplicateStyles,b as generateClassHash,F as global,O as normalizeMediaQuery,g as styleCollector,W as validateCSSProperty};
@@ -1 +1 @@
1
- "use strict";var x=Object.create;var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var s in t)i(e,s,{get:t[s],enumerable:!0})},d=(e,t,s,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of F(t))!P.call(e,n)&&n!==s&&i(e,n,{get:()=>t[n],enumerable:!(c=h(t,n))||c.enumerable});return e};var l=(e,t,s)=>(s=e!=null?x(E(e)):{},d(t||!e||!e.__esModule?i(s,"default",{value:e,enumerable:!0}):s,e)),O=e=>d(i({},"__esModule",{value:!0}),e);var _={};N(_,{CACHE_FILE:()=>y,default:()=>C,plugin:()=>S});module.exports=O(_);var m=l(require("fs"),1),g=l(require("path"),1),p=l(require("postcss"),1),w=/^next-style$/,y=g.default.join(process.cwd(),"node_modules",".cache","next-style","styles.css");function a(e={}){let t=e.cacheFile??y;return{postcssPlugin:"next-style",Once(c,{result:n}){n.messages.push({type:"dependency",plugin:"next-style",file:t,parent:n.opts.from??""});let r="";try{r=m.default.readFileSync(t,"utf-8")}catch(o){o.code==="ENOENT"||console.warn("[next-style] Failed to read cache file:",o)}let u=!1;c.walkAtRules("import",o=>{let f=o.params.replace(/['"]/g,"").trim();w.test(f)&&(r.trim()?o.replaceWith(p.default.parse(r)):o.remove(),u=!0)}),!u&&r.trim()&&c.prepend(p.default.parse(r))}}}a.postcss=!0;var C=a,S=a;0&&(module.exports={CACHE_FILE,plugin});
1
+ "use strict";var h=Object.create;var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},m=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of F(t))!j.call(e,s)&&s!==n&&l(e,s,{get:()=>t[s],enumerable:!(r=x(t,s))||r.enumerable});return e};var p=(e,t,n)=>(n=e!=null?h(P(e)):{},m(t||!e||!e.__esModule?l(n,"default",{value:e,enumerable:!0}):n,e)),N=e=>m(l({},"__esModule",{value:!0}),e);var R={};E(R,{default:()=>S,plugin:()=>v,resolveCacheFile:()=>y});module.exports=N(R);var u=p(require("fs"),1),c=p(require("path"),1),a=p(require("postcss"),1),O=/^next-style$/;function w(e){let t=c.default.dirname(e);for(;;){if(u.default.existsSync(c.default.join(t,"package.json")))return t;let n=c.default.dirname(t);if(n===t)return null;t=n}}function y(e){let t=(e?w(e):null)??process.cwd();return c.default.join(t,"node_modules",".cache","next-style","styles.css")}function f(e={}){return{postcssPlugin:"next-style",Once(n,{result:r}){let s=e.cacheFile??y(r.opts.from);r.messages.push({type:"dependency",plugin:"next-style",file:s,parent:r.opts.from??""});let o="";try{o=u.default.readFileSync(s,"utf-8")}catch(i){i.code==="ENOENT"||console.warn("[next-style] Failed to read cache file:",i)}let d=!1;n.walkAtRules("import",i=>{let g=i.params.replace(/['"]/g,"").trim();O.test(g)&&(o.trim()?i.replaceWith(a.default.parse(o)):i.remove(),d=!0)}),!d&&o.trim()&&n.prepend(a.default.parse(o))}}}f.postcss=!0;var S=f,v=f;0&&(module.exports={plugin,resolveCacheFile});
@@ -1,11 +1,15 @@
1
1
  import postcss from 'postcss';
2
2
 
3
- /** Path to the temp file used as IPC bridge between runtime and PostCSS. */
4
- declare const CACHE_FILE: string;
3
+ /**
4
+ * Resolves the cache file path from the PostCSS `result.opts.from` field.
5
+ * Falls back to `process.cwd()` when `from` is absent (e.g. standalone runs).
6
+ */
7
+ declare function resolveCacheFile(from: string | undefined): string;
5
8
  interface PluginOptions {
6
9
  /**
7
10
  * Override the cache file path.
8
- * Defaults to `process.cwd()/node_modules/.cache/next-style/styles.css`.
11
+ * When omitted, the path is derived from the CSS file being processed
12
+ * (`result.opts.from`) by walking up to the nearest `package.json`.
9
13
  */
10
14
  cacheFile?: string;
11
15
  }
@@ -16,4 +20,4 @@ declare namespace nextStylePlugin {
16
20
 
17
21
  declare const plugin: typeof nextStylePlugin;
18
22
 
19
- export { CACHE_FILE, nextStylePlugin as default, plugin };
23
+ export { nextStylePlugin as default, plugin, resolveCacheFile };
@@ -1,11 +1,15 @@
1
1
  import postcss from 'postcss';
2
2
 
3
- /** Path to the temp file used as IPC bridge between runtime and PostCSS. */
4
- declare const CACHE_FILE: string;
3
+ /**
4
+ * Resolves the cache file path from the PostCSS `result.opts.from` field.
5
+ * Falls back to `process.cwd()` when `from` is absent (e.g. standalone runs).
6
+ */
7
+ declare function resolveCacheFile(from: string | undefined): string;
5
8
  interface PluginOptions {
6
9
  /**
7
10
  * Override the cache file path.
8
- * Defaults to `process.cwd()/node_modules/.cache/next-style/styles.css`.
11
+ * When omitted, the path is derived from the CSS file being processed
12
+ * (`result.opts.from`) by walking up to the nearest `package.json`.
9
13
  */
10
14
  cacheFile?: string;
11
15
  }
@@ -16,4 +20,4 @@ declare namespace nextStylePlugin {
16
20
 
17
21
  declare const plugin: typeof nextStylePlugin;
18
22
 
19
- export { CACHE_FILE, nextStylePlugin as default, plugin };
23
+ export { nextStylePlugin as default, plugin, resolveCacheFile };
@@ -1 +1 @@
1
- import a from"fs";import u from"path";import l from"postcss";var f=/^next-style$/,d=u.join(process.cwd(),"node_modules",".cache","next-style","styles.css");function s(p={}){let n=p.cacheFile??d;return{postcssPlugin:"next-style",Once(o,{result:c}){c.messages.push({type:"dependency",plugin:"next-style",file:n,parent:c.opts.from??""});let t="";try{t=a.readFileSync(n,"utf-8")}catch(e){e.code==="ENOENT"||console.warn("[next-style] Failed to read cache file:",e)}let r=!1;o.walkAtRules("import",e=>{let i=e.params.replace(/['"]/g,"").trim();f.test(i)&&(t.trim()?e.replaceWith(l.parse(t)):e.remove(),r=!0)}),!r&&t.trim()&&o.prepend(l.parse(t))}}}s.postcss=!0;var E=s,P=s;export{d as CACHE_FILE,E as default,P as plugin};
1
+ import f from"fs";import i from"path";import u from"postcss";var d=/^next-style$/;function g(t){let e=i.dirname(t);for(;;){if(f.existsSync(i.join(e,"package.json")))return e;let s=i.dirname(e);if(s===e)return null;e=s}}function m(t){let e=(t?g(t):null)??process.cwd();return i.join(e,"node_modules",".cache","next-style","styles.css")}function c(t={}){return{postcssPlugin:"next-style",Once(s,{result:o}){let l=t.cacheFile??m(o.opts.from);o.messages.push({type:"dependency",plugin:"next-style",file:l,parent:o.opts.from??""});let r="";try{r=f.readFileSync(l,"utf-8")}catch(n){n.code==="ENOENT"||console.warn("[next-style] Failed to read cache file:",n)}let p=!1;s.walkAtRules("import",n=>{let a=n.params.replace(/['"]/g,"").trim();d.test(a)&&(r.trim()?n.replaceWith(u.parse(r)):n.remove(),p=!0)}),!p&&r.trim()&&s.prepend(u.parse(r))}}}c.postcss=!0;var j=c,E=c;export{j as default,E as plugin,m as resolveCacheFile};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-style",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Zero-Runtime CSS-in-JS for Next.js + Turbopack",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",