styled-components 6.2.0 → 6.2.1-prerelease.0

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.
Files changed (98) hide show
  1. package/README.md +2 -1
  2. package/dist/styled-components.browser.cjs.js +1 -1
  3. package/dist/styled-components.browser.cjs.js.map +1 -1
  4. package/dist/styled-components.browser.esm.js +1 -1
  5. package/dist/styled-components.browser.esm.js.map +1 -1
  6. package/dist/styled-components.cjs.js +1 -1
  7. package/dist/styled-components.cjs.js.map +1 -1
  8. package/dist/styled-components.esm.js +1 -1
  9. package/dist/styled-components.esm.js.map +1 -1
  10. package/dist/styled-components.js +165 -100
  11. package/dist/styled-components.js.map +1 -1
  12. package/dist/styled-components.min.js +1 -1
  13. package/dist/styled-components.min.js.map +1 -1
  14. package/native/dist/constants.d.ts +5 -0
  15. package/native/dist/dist/constants.d.ts +5 -0
  16. package/native/dist/dist/hoc/withTheme.spec.d.ts +1 -0
  17. package/native/dist/dist/index.d.ts +2 -2
  18. package/native/dist/dist/models/ComponentStyle.d.ts +4 -1
  19. package/native/dist/dist/sheet/Tag.d.ts +4 -4
  20. package/native/dist/dist/test/utils.d.ts +33 -14
  21. package/native/dist/dist/types.d.ts +11 -3
  22. package/native/dist/dist/utils/domElements.d.ts +2 -2
  23. package/native/dist/dist/utils/isRSC.d.ts +11 -0
  24. package/native/dist/hoc/withTheme.spec.d.ts +1 -0
  25. package/native/dist/index.d.ts +2 -2
  26. package/native/dist/models/ComponentStyle.d.ts +4 -1
  27. package/native/dist/sheet/Tag.d.ts +4 -4
  28. package/native/dist/styled-components.native.cjs.js +1 -1
  29. package/native/dist/styled-components.native.cjs.js.map +1 -1
  30. package/native/dist/styled-components.native.esm.js +1 -1
  31. package/native/dist/styled-components.native.esm.js.map +1 -1
  32. package/native/dist/test/utils.d.ts +32 -13
  33. package/native/dist/types.d.ts +11 -3
  34. package/native/dist/utils/domElements.d.ts +2 -2
  35. package/native/dist/utils/isRSC.d.ts +11 -0
  36. package/package.json +6 -6
  37. package/dist/base.d.ts +0 -12
  38. package/dist/constants.d.ts +0 -8
  39. package/dist/constructors/constructWithOptions.d.ts +0 -17
  40. package/dist/constructors/createGlobalStyle.d.ts +0 -3
  41. package/dist/constructors/css.d.ts +0 -4
  42. package/dist/constructors/keyframes.d.ts +0 -3
  43. package/dist/constructors/styled.d.ts +0 -17
  44. package/dist/hoc/withTheme.d.ts +0 -4
  45. package/dist/index-standalone.d.ts +0 -2
  46. package/dist/index.d.ts +0 -4
  47. package/dist/models/ComponentStyle.d.ts +0 -15
  48. package/dist/models/GlobalStyle.d.ts +0 -11
  49. package/dist/models/InlineStyle.d.ts +0 -7
  50. package/dist/models/Keyframes.d.ts +0 -10
  51. package/dist/models/ServerStyleSheet.d.ts +0 -15
  52. package/dist/models/StyleSheetManager.d.ts +0 -65
  53. package/dist/models/StyledComponent.d.ts +0 -3
  54. package/dist/models/StyledNativeComponent.d.ts +0 -3
  55. package/dist/models/ThemeProvider.d.ts +0 -47
  56. package/dist/native/index.d.ts +0 -19
  57. package/dist/secretInternals.d.ts +0 -5
  58. package/dist/sheet/GroupIDAllocator.d.ts +0 -4
  59. package/dist/sheet/GroupedTag.d.ts +0 -11
  60. package/dist/sheet/Rehydration.d.ts +0 -3
  61. package/dist/sheet/Sheet.d.ts +0 -40
  62. package/dist/sheet/Tag.d.ts +0 -55
  63. package/dist/sheet/dom.d.ts +0 -5
  64. package/dist/sheet/index.d.ts +0 -1
  65. package/dist/sheet/types.d.ts +0 -36
  66. package/dist/test/globals.d.ts +0 -2
  67. package/dist/test/utils.d.ts +0 -144
  68. package/dist/test/veryLargeUnionType.d.ts +0 -1
  69. package/dist/types.d.ts +0 -204
  70. package/dist/utils/addUnitIfNeeded.d.ts +0 -1
  71. package/dist/utils/checkDynamicCreation.d.ts +0 -1
  72. package/dist/utils/createWarnTooManyClasses.d.ts +0 -3
  73. package/dist/utils/determineTheme.d.ts +0 -4
  74. package/dist/utils/domElements.d.ts +0 -4
  75. package/dist/utils/empties.d.ts +0 -3
  76. package/dist/utils/error.d.ts +0 -5
  77. package/dist/utils/errors.d.ts +0 -21
  78. package/dist/utils/escape.d.ts +0 -5
  79. package/dist/utils/flatten.d.ts +0 -4
  80. package/dist/utils/generateAlphabeticName.d.ts +0 -1
  81. package/dist/utils/generateComponentId.d.ts +0 -1
  82. package/dist/utils/generateDisplayName.d.ts +0 -2
  83. package/dist/utils/getComponentName.d.ts +0 -2
  84. package/dist/utils/hash.d.ts +0 -3
  85. package/dist/utils/hoist.d.ts +0 -51
  86. package/dist/utils/hyphenateStyleName.d.ts +0 -14
  87. package/dist/utils/interleave.d.ts +0 -2
  88. package/dist/utils/isFunction.d.ts +0 -1
  89. package/dist/utils/isPlainObject.d.ts +0 -1
  90. package/dist/utils/isStatelessFunction.d.ts +0 -1
  91. package/dist/utils/isStaticRules.d.ts +0 -2
  92. package/dist/utils/isStyledComponent.d.ts +0 -2
  93. package/dist/utils/isTag.d.ts +0 -2
  94. package/dist/utils/joinStrings.d.ts +0 -5
  95. package/dist/utils/mixinDeep.d.ts +0 -6
  96. package/dist/utils/nonce.d.ts +0 -1
  97. package/dist/utils/setToString.d.ts +0 -17
  98. package/dist/utils/stylis.d.ts +0 -10
@@ -10,9 +10,14 @@
10
10
  'data-styled';
11
11
  var SC_ATTR_ACTIVE = 'active';
12
12
  var SC_ATTR_VERSION = 'data-styled-version';
13
- var SC_VERSION = "6.2.0";
13
+ var SC_VERSION = "6.2.1-prerelease.0";
14
14
  var SPLITTER = '/*!sc*/\n';
15
15
  var IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';
16
+ /**
17
+ * Detect if we're running in a React Server Component environment.
18
+ * RSC environments lack createContext, making this a reliable indicator.
19
+ */
20
+ var IS_RSC = typeof React.createContext === 'undefined';
16
21
  var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
17
22
  ? SC_DISABLE_SPEEDY
18
23
  : typeof process !== 'undefined' &&
@@ -568,53 +573,6 @@
568
573
  return StyleSheet;
569
574
  }());
570
575
 
571
- //
572
-
573
- var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
574
- var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
575
-
576
- if (ret !== void 0) {
577
- return !!ret;
578
- }
579
-
580
- if (objA === objB) {
581
- return true;
582
- }
583
-
584
- if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
585
- return false;
586
- }
587
-
588
- var keysA = Object.keys(objA);
589
- var keysB = Object.keys(objB);
590
-
591
- if (keysA.length !== keysB.length) {
592
- return false;
593
- }
594
-
595
- var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
596
-
597
- // Test for A's keys different from B.
598
- for (var idx = 0; idx < keysA.length; idx++) {
599
- var key = keysA[idx];
600
-
601
- if (!bHasOwnProperty(key)) {
602
- return false;
603
- }
604
-
605
- var valueA = objA[key];
606
- var valueB = objB[key];
607
-
608
- ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
609
-
610
- if (ret === false || (ret === void 0 && valueA !== valueB)) {
611
- return false;
612
- }
613
- }
614
-
615
- return true;
616
- };
617
-
618
576
  var e="-ms-";var r="-moz-";var a="-webkit-";var c="comm";var n="rule";var s="decl";var i="@import";var v="@namespace";var b="@keyframes";var g="@layer";var $=Math.abs;var m=String.fromCharCode;var x=Object.assign;function y(e,r){return A(e,0)^45?(((r<<2^A(e,0))<<2^A(e,1))<<2^A(e,2))<<2^A(e,3):0}function j(e){return e.trim()}function z(e,r){return (e=r.exec(e))?e[0]:e}function C(e,r,a){return e.replace(r,a)}function O(e,r,a){return e.indexOf(r,a)}function A(e,r){return e.charCodeAt(r)|0}function M(e,r,a){return e.slice(r,a)}function S(e){return e.length}function q(e){return e.length}function B(e,r){return r.push(e),e}function D(e,r){return e.map(r).join("")}function E(e,r){return e.filter((function(e){return !z(e,r)}))}var F=1;var G=1;var H=0;var I=0;var J=0;var K="";function L(e,r,a,c,n,s,t,u){return {value:e,root:r,parent:a,type:c,props:n,children:s,line:F,column:G,length:t,return:"",siblings:u}}function N(e,r){return x(L("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},r)}function P(e){while(e.root)e=N(e.root,{children:[e]});B(e,e.siblings);}function Q(){return J}function R(){J=I>0?A(K,--I):0;if(G--,J===10)G=1,F--;return J}function T(){J=I<H?A(K,I++):0;if(G++,J===10)G=1,F++;return J}function U(){return A(K,I)}function V(){return I}function W(e,r){return M(K,e,r)}function X(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Y(e){return F=G=1,H=S(K=e),I=0,[]}function Z(e){return K="",e}function _(e){return j(W(I-1,ne(e===91?e+2:e===40?e+1:e)))}function re(e){while(J=U())if(J<33)T();else break;return X(e)>2||X(J)>3?"":" "}function ce(e,r){while(--r&&T())if(J<48||J>102||J>57&&J<65||J>70&&J<97)break;return W(e,V()+(r<6&&U()==32&&T()==32))}function ne(e){while(T())switch(J){case e:return I;case 34:case 39:if(e!==34&&e!==39)ne(J);break;case 40:if(e===41)ne(e);break;case 92:T();break}return I}function se(e,r){while(T())if(e+J===47+10)break;else if(e+J===42+42&&U()===47)break;return "/*"+W(r,I-1)+"*"+m(e===47?e:T())}function te(e){while(!X(U()))T();return W(e,I)}function ue(e){return Z(ie("",null,null,null,[""],e=Y(e),0,[0],e))}function ie(e,r,a,c,n,s,t,u,i){var f=0;var o=0;var l=t;var p=0;var v=0;var b=0;var h=1;var w=1;var d=1;var g=0;var k="";var x=n;var y=s;var j=c;var z=k;while(w)switch(b=g,g=T()){case 40:if(b!=108&&A(z,l-1)==58){if(O(z+=C(_(g),"&","&\f"),"&\f",$(f?u[f-1]:0))!=-1)d=-1;break}case 34:case 39:case 91:z+=_(g);break;case 9:case 10:case 13:case 32:z+=re(b);break;case 92:z+=ce(V()-1,7);continue;case 47:switch(U()){case 42:case 47:B(oe(se(T(),V()),r,a,i),i);if((X(b||1)==5||X(U()||1)==5)&&S(z)&&M(z,-1,void 0)!==" ")z+=" ";break;default:z+="/";}break;case 123*h:u[f++]=S(z)*d;case 125*h:case 59:case 0:switch(g){case 0:case 125:w=0;case 59+o:if(d==-1)z=C(z,/\f/g,"");if(v>0&&(S(z)-l||h===0&&b===47))B(v>32?le(z+";",c,a,l-1,i):le(C(z," ","")+";",c,a,l-2,i),i);break;case 59:z+=";";default:B(j=fe(z,r,a,f,o,n,u,k,x=[],y=[],l,s),s);if(g===123)if(o===0)ie(z,r,j,j,x,s,l,u,y);else {switch(p){case 99:if(A(z,3)===110)break;case 108:if(A(z,2)===97)break;default:o=0;case 100:case 109:case 115:}if(o)ie(e,j,j,c&&B(fe(e,j,j,0,0,n,u,k,n,x=[],l,y),y),n,y,l,u,c?x:y);else ie(z,j,j,j,[""],y,0,u,y);}}f=o=v=0,h=d=1,k=z="",l=t;break;case 58:l=1+S(z),v=b;default:if(h<1)if(g==123)--h;else if(g==125&&h++==0&&R()==125)continue;switch(z+=m(g),g*h){case 38:d=o>0?1:(z+="\f",-1);break;case 44:u[f++]=(S(z)-1)*d,d=1;break;case 64:if(U()===45)z+=_(T());p=U(),o=l=S(k=z+=te(V())),g++;break;case 45:if(b===45&&S(z)==2)h=0;}}return s}function fe(e,r,a,c,s,t,u,i,f,o,l,p){var v=s-1;var b=s===0?t:[""];var h=q(b);for(var w=0,d=0,g=0;w<c;++w)for(var k=0,m=M(e,v+1,v=$(d=u[w])),x=e;k<h;++k)if(x=j(d>0?b[k]+" "+m:C(m,/&\f/g,b[k])))f[g++]=x;return L(e,r,a,s===0?n:i,f,o,l,p)}function oe(e,r,a,n){return L(e,r,a,c,m(Q()),M(e,2,-2),0,n)}function le(e,r,a,c,n){return L(e,r,a,s,M(e,0,c),M(e,c+1,-1),c,n)}function pe(c,n,s){switch(y(c,n)){case 5103:return a+"print-"+c+c;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return a+c+c;case 4855:return a+c.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+c;case 4789:return r+c+c;case 5349:case 4246:case 4810:case 6968:case 2756:return a+c+r+c+e+c+c;case 5936:switch(A(c,n+11)){case 114:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"tb")+c;case 108:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"tb-rl")+c;case 45:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"lr")+c}case 6828:case 4268:case 2903:return a+c+e+c+c;case 6165:return a+c+e+"flex-"+c+c;case 5187:return a+c+C(c,/(\w+).+(:[^]+)/,a+"box-$1$2"+e+"flex-$1$2")+c;case 5443:return a+c+e+"flex-item-"+C(c,/flex-|-self/g,"")+(!z(c,/flex-|baseline/)?e+"grid-row-"+C(c,/flex-|-self/g,""):"")+c;case 4675:return a+c+e+"flex-line-pack"+C(c,/align-content|flex-|-self/g,"")+c;case 5548:return a+c+e+C(c,"shrink","negative")+c;case 5292:return a+c+e+C(c,"basis","preferred-size")+c;case 6060:return a+"box-"+C(c,"-grow","")+a+c+e+C(c,"grow","positive")+c;case 4554:return a+C(c,/([^-])(transform)/g,"$1"+a+"$2")+c;case 6187:return C(C(C(c,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),c,"")+c;case 5495:case 3959:return C(c,/(image-set\([^]*)/,a+"$1"+"$`$1");case 4968:return C(C(c,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+e+"flex-pack:$3"),/space-between/,"justify")+a+c+c;case 4200:if(!z(c,/flex-|baseline/))return e+"grid-column-align"+M(c,n)+c;break;case 2592:case 3360:return e+C(c,"template-","")+c;case 4384:case 3616:if(s&&s.some((function(e,r){return n=r,z(e.props,/grid-\w+-end/)}))){return ~O(c+(s=s[n].value),"span",0)?c:e+C(c,"-start","")+c+e+"grid-row-span:"+(~O(s,"span",0)?z(s,/\d+/):+z(s,/\d+/)-+z(c,/\d+/))+";"}return e+C(c,"-start","")+c;case 4896:case 4128:return s&&s.some((function(e){return z(e.props,/grid-\w+-start/)}))?c:e+C(C(c,"-end","-span"),"span ","")+c;case 4095:case 3583:case 4068:case 2532:return C(c,/(.+)-inline(.+)/,a+"$1$2")+c;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(S(c)-1-n>6)switch(A(c,n+1)){case 109:if(A(c,n+4)!==45)break;case 102:return C(c,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3"+"$1"+r+(A(c,n+3)==108?"$3":"$2-$3"))+c;case 115:return ~O(c,"stretch",0)?pe(C(c,"stretch","fill-available"),n,s)+c:c}break;case 5152:case 5920:return C(c,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,(function(r,a,n,s,t,u,i){return e+a+":"+n+i+(s?e+a+"-span:"+(t?u:+u-+n)+i:"")+c}));case 4949:if(A(c,n+6)===121)return C(c,":",":"+a)+c;break;case 6444:switch(A(c,A(c,14)===45?18:11)){case 120:return C(c,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+a+(A(c,14)===45?"inline-":"")+"box$3"+"$1"+a+"$2$3"+"$1"+e+"$2box$3")+c;case 100:return C(c,":",":"+e)+c}break;case 5719:case 2647:case 2135:case 3927:case 2391:return C(c,"scroll-","scroll-snap-")+c}return c}function ve(e,r){var a="";for(var c=0;c<e.length;c++)a+=r(e[c],c,e,r)||"";return a}function be(e,r,a,t){switch(e.type){case g:if(e.children.length)break;case i:case v:case s:return e.return=e.return||e.value;case c:return "";case b:return e.return=e.value+"{"+ve(e.children,t)+"}";case n:if(!S(e.value=e.props.join(",")))return ""}return S(a=ve(e.children,t))?e.return=e.value+"{"+a+"}":""}function he(e){var r=q(e);return function(a,c,n,s){var t="";for(var u=0;u<r;u++)t+=e[u](a,c,n,s)||"";return t}}function we(e){return function(r){if(!r.root)if(r=r.return)e(r);}}function de(c,t,u,i){if(c.length>-1)if(!c.return)switch(c.type){case s:c.return=pe(c.value,c.length,u);return;case b:return ve([N(c,{value:C(c.value,"@","@"+a)})],i);case n:if(c.length)return D(u=c.props,(function(n){switch(z(n,i=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":P(N(c,{props:[C(n,/:(read-\w+)/,":"+r+"$1")]}));P(N(c,{props:[n]}));x(c,{props:E(u,i)});break;case"::placeholder":P(N(c,{props:[C(n,/:(plac\w+)/,":"+a+"input-$1")]}));P(N(c,{props:[C(n,/:(plac\w+)/,":"+r+"$1")]}));P(N(c,{props:[C(n,/:(plac\w+)/,e+"input-$1")]}));P(N(c,{props:[n]}));x(c,{props:E(u,i)});break}return ""}))}}
619
577
 
620
578
  var SEED$1 = 5381;
@@ -741,18 +699,46 @@
741
699
 
742
700
  var mainSheet = new StyleSheet();
743
701
  var mainStylis = createStylisInstance();
744
- var StyleSheetContext = React.createContext({
702
+ var defaultContextValue = {
745
703
  shouldForwardProp: undefined,
746
704
  styleSheet: mainSheet,
747
705
  stylis: mainStylis,
748
- });
706
+ };
707
+ // Create context only if createContext is available, otherwise create a fallback
708
+ var StyleSheetContext = !IS_RSC
709
+ ? React.createContext(defaultContextValue)
710
+ : {
711
+ Provider: function (_a) {
712
+ var children = _a.children;
713
+ return children;
714
+ },
715
+ Consumer: function (_a) {
716
+ var children = _a.children;
717
+ return children(defaultContextValue);
718
+ },
719
+ };
749
720
  var StyleSheetConsumer = StyleSheetContext.Consumer;
750
- var StylisContext = React.createContext(undefined);
721
+ var StylisContext = !IS_RSC
722
+ ? React.createContext(undefined)
723
+ : {
724
+ Provider: function (_a) {
725
+ var children = _a.children;
726
+ return children;
727
+ },
728
+ Consumer: function (_a) {
729
+ var children = _a.children;
730
+ return children(undefined);
731
+ },
732
+ };
751
733
  function useStyleSheetContext() {
752
- return React.useContext(StyleSheetContext);
734
+ // Skip useContext if we're in an RSC environment without context support
735
+ return !IS_RSC && React.useContext ? React.useContext(StyleSheetContext) : defaultContextValue;
753
736
  }
754
737
  function StyleSheetManager(props) {
755
- var _a = React.useState(props.stylisPlugins), plugins = _a[0], setPlugins = _a[1];
738
+ // In RSC environments without context support, StyleSheetManager becomes a no-op
739
+ if (IS_RSC || !React.useMemo) {
740
+ return props.children;
741
+ }
756
742
  var styleSheet = useStyleSheetContext().styleSheet;
757
743
  var resolvedStyleSheet = React.useMemo(function () {
758
744
  var sheet = styleSheet;
@@ -770,13 +756,9 @@
770
756
  var stylis = React.useMemo(function () {
771
757
  return createStylisInstance({
772
758
  options: { namespace: props.namespace, prefix: props.enableVendorPrefixes },
773
- plugins: plugins,
759
+ plugins: props.stylisPlugins,
774
760
  });
775
- }, [props.enableVendorPrefixes, props.namespace, plugins]);
776
- React.useEffect(function () {
777
- if (!shallowequal(plugins, props.stylisPlugins))
778
- setPlugins(props.stylisPlugins);
779
- }, [props.stylisPlugins]);
761
+ }, [props.enableVendorPrefixes, props.namespace, props.stylisPlugins]);
780
762
  var styleSheetContextValue = React.useMemo(function () { return ({
781
763
  shouldForwardProp: props.shouldForwardProp,
782
764
  styleSheet: resolvedStyleSheet,
@@ -1063,7 +1045,19 @@
1063
1045
  return GlobalStyle;
1064
1046
  }());
1065
1047
 
1066
- var ThemeContext = React.createContext(undefined);
1048
+ // Create context only if createContext is available, otherwise create a fallback
1049
+ var ThemeContext = !IS_RSC
1050
+ ? React.createContext(undefined)
1051
+ : {
1052
+ Provider: function (_a) {
1053
+ var children = _a.children;
1054
+ return children;
1055
+ },
1056
+ Consumer: function (_a) {
1057
+ var children = _a.children;
1058
+ return children(undefined);
1059
+ },
1060
+ };
1067
1061
  var ThemeConsumer = ThemeContext.Consumer;
1068
1062
  function mergeTheme(theme, outerTheme) {
1069
1063
  if (!theme) {
@@ -1090,7 +1084,8 @@
1090
1084
  * is no `ThemeProvider` ancestor.
1091
1085
  */
1092
1086
  function useTheme() {
1093
- var theme = React.useContext(ThemeContext);
1087
+ // Skip useContext if we're in an RSC environment without context support
1088
+ var theme = !IS_RSC && React.useContext ? React.useContext(ThemeContext) : undefined;
1094
1089
  if (!theme) {
1095
1090
  throw throwStyledComponentsError(18);
1096
1091
  }
@@ -1100,6 +1095,10 @@
1100
1095
  * Provide a theme to an entire react component tree via context
1101
1096
  */
1102
1097
  function ThemeProvider(props) {
1098
+ // In RSC environments without context support, ThemeProvider becomes a no-op
1099
+ if (IS_RSC || !React.useContext || !React.useMemo) {
1100
+ return props.children;
1101
+ }
1103
1102
  var outerTheme = React.useContext(ThemeContext);
1104
1103
  var themeContext = React.useMemo(function () { return mergeTheme(props.theme, outerTheme); }, [props.theme, outerTheme]);
1105
1104
  if (!props.children) {
@@ -1139,9 +1138,12 @@
1139
1138
  originalConsoleError_1.apply(void 0, __spreadArray([consoleErrorMessage], consoleErrorArgs, false));
1140
1139
  }
1141
1140
  };
1142
- // We purposefully call `useRef` outside of a component and expect it to throw
1141
+ // We purposefully call a hook outside of a component and expect it to throw
1143
1142
  // If it doesn't, then we're inside another component.
1144
- React.useRef();
1143
+ // Use useState instead of useRef to avoid importing useRef
1144
+ if (typeof React.useState === 'function') {
1145
+ React.useState(null);
1146
+ }
1145
1147
  if (didNotCallInvalidHook_1 && !seen.has(message_1)) {
1146
1148
  console.warn(message_1);
1147
1149
  seen.add(message_1);
@@ -1233,11 +1235,17 @@
1233
1235
  {
1234
1236
  checkDynamicCreation(styledComponentId);
1235
1237
  }
1238
+ // Use a WeakMap to maintain stable instances per stylesheet
1239
+ var instanceMap = new WeakMap();
1236
1240
  var GlobalStyleComponent = function (props) {
1237
1241
  var ssc = useStyleSheetContext();
1238
- var theme = React.useContext(ThemeContext);
1239
- var instanceRef = React.useRef(ssc.styleSheet.allocateGSInstance(styledComponentId));
1240
- var instance = instanceRef.current;
1242
+ var theme = React.useContext ? React.useContext(ThemeContext) : undefined;
1243
+ // Get or create instance ID for this stylesheet
1244
+ var instance = instanceMap.get(ssc.styleSheet);
1245
+ if (instance === undefined) {
1246
+ instance = ssc.styleSheet.allocateGSInstance(styledComponentId);
1247
+ instanceMap.set(ssc.styleSheet, instance);
1248
+ }
1241
1249
  if (// @ts-expect-error invariant check
1242
1250
  React.Children.count(props.children)) {
1243
1251
  console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
@@ -1245,16 +1253,36 @@
1245
1253
  if (rules.some(function (rule) { return typeof rule === 'string' && rule.indexOf('@import') !== -1; })) {
1246
1254
  console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app.");
1247
1255
  }
1248
- if (ssc.styleSheet.server) {
1256
+ // Render styles during component execution
1257
+ // Use runtime check since false build constant may not match actual environment
1258
+ var shouldRenderStyles = typeof window === 'undefined' || !ssc.styleSheet.server;
1259
+ if (shouldRenderStyles) {
1249
1260
  renderStyles(instance, props, ssc.styleSheet, theme, ssc.stylis);
1250
1261
  }
1251
- {
1262
+ // Client-side cleanup: conditionally use useLayoutEffect
1263
+ // The IS_RSC check is module-level and deterministic, so this doesn't violate rules of hooks
1264
+ if (!IS_RSC && typeof React.useLayoutEffect === 'function') {
1252
1265
  React.useLayoutEffect(function () {
1253
- if (!ssc.styleSheet.server) {
1254
- renderStyles(instance, props, ssc.styleSheet, theme, ssc.stylis);
1255
- return function () { return globalStyle.removeStyles(instance, ssc.styleSheet); };
1256
- }
1257
- }, [instance, props, ssc.styleSheet, theme, ssc.stylis]);
1266
+ return function () {
1267
+ globalStyle.removeStyles(instance, ssc.styleSheet);
1268
+ };
1269
+ }, [instance, ssc.styleSheet]);
1270
+ }
1271
+ // RSC mode: output style tag
1272
+ if (IS_RSC) {
1273
+ var id = styledComponentId + instance;
1274
+ var css_1 = typeof window === 'undefined' ? ssc.styleSheet.getTag().getGroup(getGroupForId(id)) : '';
1275
+ if (css_1) {
1276
+ var cssHash = generateAlphabeticName(hash(css_1) >>> 0);
1277
+ var href = "sc-global-".concat(styledComponentId, "-").concat(instance, "-").concat(cssHash);
1278
+ return React.createElement('style', {
1279
+ key: href,
1280
+ 'data-styled-global': styledComponentId,
1281
+ precedence: 'styled-components',
1282
+ href: href,
1283
+ children: css_1,
1284
+ });
1285
+ }
1258
1286
  }
1259
1287
  return null;
1260
1288
  };
@@ -1392,7 +1420,7 @@
1392
1420
 
1393
1421
  function withTheme(Component) {
1394
1422
  var WithTheme = React.forwardRef(function (props, ref) {
1395
- var theme = React.useContext(ThemeContext);
1423
+ var theme = React.useContext ? React.useContext(ThemeContext) : undefined;
1396
1424
  var themeProp = determineTheme(props, theme, Component.defaultProps);
1397
1425
  if (themeProp === undefined) {
1398
1426
  console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
@@ -1556,7 +1584,6 @@
1556
1584
  };
1557
1585
  });
1558
1586
 
1559
- // Thanks to ReactDOMFactories for this handy list!
1560
1587
  var elements = [
1561
1588
  'a',
1562
1589
  'abbr',
@@ -1566,13 +1593,10 @@
1566
1593
  'aside',
1567
1594
  'audio',
1568
1595
  'b',
1569
- 'base',
1570
1596
  'bdi',
1571
1597
  'bdo',
1572
- 'big',
1573
1598
  'blockquote',
1574
1599
  'body',
1575
- 'br',
1576
1600
  'button',
1577
1601
  'canvas',
1578
1602
  'caption',
@@ -1613,27 +1637,21 @@
1613
1637
  'input',
1614
1638
  'ins',
1615
1639
  'kbd',
1616
- 'keygen',
1617
1640
  'label',
1618
1641
  'legend',
1619
1642
  'li',
1620
- 'link',
1621
1643
  'main',
1622
1644
  'map',
1623
1645
  'mark',
1624
1646
  'menu',
1625
- 'menuitem',
1626
- 'meta',
1627
1647
  'meter',
1628
1648
  'nav',
1629
- 'noscript',
1630
1649
  'object',
1631
1650
  'ol',
1632
1651
  'optgroup',
1633
1652
  'option',
1634
1653
  'output',
1635
1654
  'p',
1636
- 'param',
1637
1655
  'picture',
1638
1656
  'pre',
1639
1657
  'progress',
@@ -1643,37 +1661,61 @@
1643
1661
  'ruby',
1644
1662
  's',
1645
1663
  'samp',
1646
- 'script',
1664
+ 'search',
1647
1665
  'section',
1648
1666
  'select',
1667
+ 'slot',
1649
1668
  'small',
1650
- 'source',
1651
1669
  'span',
1652
1670
  'strong',
1653
- 'style',
1654
1671
  'sub',
1655
1672
  'summary',
1656
1673
  'sup',
1657
1674
  'table',
1658
1675
  'tbody',
1659
1676
  'td',
1677
+ 'template',
1660
1678
  'textarea',
1661
1679
  'tfoot',
1662
1680
  'th',
1663
1681
  'thead',
1664
1682
  'time',
1665
1683
  'tr',
1666
- 'track',
1667
1684
  'u',
1668
1685
  'ul',
1669
- 'use',
1670
1686
  'var',
1671
1687
  'video',
1672
- 'wbr', // SVG
1688
+ 'wbr',
1673
1689
  'circle',
1674
1690
  'clipPath',
1675
1691
  'defs',
1676
1692
  'ellipse',
1693
+ 'feBlend',
1694
+ 'feColorMatrix',
1695
+ 'feComponentTransfer',
1696
+ 'feComposite',
1697
+ 'feConvolveMatrix',
1698
+ 'feDiffuseLighting',
1699
+ 'feDisplacementMap',
1700
+ 'feDistantLight',
1701
+ 'feDropShadow',
1702
+ 'feFlood',
1703
+ 'feFuncA',
1704
+ 'feFuncB',
1705
+ 'feFuncG',
1706
+ 'feFuncR',
1707
+ 'feGaussianBlur',
1708
+ 'feImage',
1709
+ 'feMerge',
1710
+ 'feMergeNode',
1711
+ 'feMorphology',
1712
+ 'feOffset',
1713
+ 'fePointLight',
1714
+ 'feSpecularLighting',
1715
+ 'feSpotLight',
1716
+ 'feTile',
1717
+ 'feTurbulence',
1718
+ 'filter',
1677
1719
  'foreignObject',
1678
1720
  'g',
1679
1721
  'image',
@@ -1689,8 +1731,12 @@
1689
1731
  'rect',
1690
1732
  'stop',
1691
1733
  'svg',
1734
+ 'switch',
1735
+ 'symbol',
1692
1736
  'text',
1737
+ 'textPath',
1693
1738
  'tspan',
1739
+ 'use',
1694
1740
  ];
1695
1741
  var domElements = new Set(elements);
1696
1742
 
@@ -1773,7 +1819,7 @@
1773
1819
  }
1774
1820
  ComponentStyle.prototype.generateAndInjectStyles = function (executionContext, styleSheet, stylis) {
1775
1821
  var names = this.baseStyle
1776
- ? this.baseStyle.generateAndInjectStyles(executionContext, styleSheet, stylis)
1822
+ ? this.baseStyle.generateAndInjectStyles(executionContext, styleSheet, stylis).className
1777
1823
  : '';
1778
1824
  // force dynamic classnames if user-supplied stylis plugins are in use
1779
1825
  if (this.isStatic && !stylis.hash) {
@@ -1810,12 +1856,17 @@
1810
1856
  if (css) {
1811
1857
  var name_2 = generateAlphabeticName(dynamicHash >>> 0);
1812
1858
  if (!styleSheet.hasNameForId(this.componentId, name_2)) {
1813
- styleSheet.insertRules(this.componentId, name_2, stylis(css, ".".concat(name_2), undefined, this.componentId));
1859
+ var cssFormatted = stylis(css, ".".concat(name_2), undefined, this.componentId);
1860
+ styleSheet.insertRules(this.componentId, name_2, cssFormatted);
1814
1861
  }
1815
1862
  names = joinStrings(names, name_2);
1816
1863
  }
1817
1864
  }
1818
- return names;
1865
+ // Retrieve CSS from Tag for RSC rendering
1866
+ var generatedCSS = typeof window === 'undefined'
1867
+ ? styleSheet.getTag().getGroup(getGroupForId(this.componentId))
1868
+ : '';
1869
+ return { className: names, css: generatedCSS };
1819
1870
  };
1820
1871
  return ComponentStyle;
1821
1872
  }());
@@ -1834,9 +1885,11 @@
1834
1885
  }
1835
1886
  function useInjectedStyle(componentStyle, resolvedAttrs) {
1836
1887
  var ssc = useStyleSheetContext();
1837
- var className = componentStyle.generateAndInjectStyles(resolvedAttrs, ssc.styleSheet, ssc.stylis);
1838
- React.useDebugValue(className);
1839
- return className;
1888
+ var result = componentStyle.generateAndInjectStyles(resolvedAttrs, ssc.styleSheet, ssc.stylis);
1889
+ if (React.useDebugValue) {
1890
+ React.useDebugValue(result.className);
1891
+ }
1892
+ return result;
1840
1893
  }
1841
1894
  function resolveContext(attrs, props, theme) {
1842
1895
  var context = __assign(__assign({}, props), {
@@ -1867,10 +1920,12 @@
1867
1920
  var seenUnknownProps = new Set();
1868
1921
  function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1869
1922
  var componentAttrs = forwardedComponent.attrs, componentStyle = forwardedComponent.componentStyle, defaultProps = forwardedComponent.defaultProps, foldedComponentIds = forwardedComponent.foldedComponentIds, styledComponentId = forwardedComponent.styledComponentId, target = forwardedComponent.target;
1870
- var contextTheme = React.useContext(ThemeContext);
1923
+ var contextTheme = React.useContext ? React.useContext(ThemeContext) : undefined;
1871
1924
  var ssc = useStyleSheetContext();
1872
1925
  var shouldForwardProp = forwardedComponent.shouldForwardProp || ssc.shouldForwardProp;
1873
- React.useDebugValue(styledComponentId);
1926
+ if (React.useDebugValue) {
1927
+ React.useDebugValue(styledComponentId);
1928
+ }
1874
1929
  // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
1875
1930
  // but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
1876
1931
  // should be an immutable value, but behave for now.
@@ -1899,7 +1954,7 @@
1899
1954
  }
1900
1955
  }
1901
1956
  }
1902
- var generatedClassName = useInjectedStyle(componentStyle, context);
1957
+ var _a = useInjectedStyle(componentStyle, context), generatedClassName = _a.className, css = _a.css;
1903
1958
  if (forwardedComponent.warnTooManyClasses) {
1904
1959
  forwardedComponent.warnTooManyClasses(generatedClassName);
1905
1960
  }
@@ -1922,7 +1977,17 @@
1922
1977
  if (forwardedRef) {
1923
1978
  propsForElement.ref = forwardedRef;
1924
1979
  }
1925
- return React.createElement(elementToBeCreated, propsForElement);
1980
+ var element = React.createElement(elementToBeCreated, propsForElement);
1981
+ // RSC mode: output style tag alongside element
1982
+ // React 19's style hoisting will deduplicate by href and move to <head>
1983
+ if (IS_RSC && css) {
1984
+ return React.createElement(React.Fragment, null, React.createElement('style', {
1985
+ precedence: 'styled-components',
1986
+ href: "sc-".concat(styledComponentId, "-").concat(generatedClassName),
1987
+ children: css,
1988
+ }), element);
1989
+ }
1990
+ return element;
1926
1991
  }
1927
1992
  function createStyledComponent(target, options, rules) {
1928
1993
  var isTargetStyledComp = isStyledComponent(target);