styled-components 6.0.0-beta.12 → 6.0.0-beta.13

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/base.d.ts CHANGED
@@ -8,11 +8,6 @@ import ServerStyleSheet from './models/ServerStyleSheet';
8
8
  import { IStyleSheetContext, IStyleSheetManager, IStylisContext, StyleSheetConsumer, StyleSheetContext, StyleSheetManager } from './models/StyleSheetManager';
9
9
  import ThemeProvider, { ThemeConsumer, ThemeContext } from './models/ThemeProvider';
10
10
  import isStyledComponent from './utils/isStyledComponent';
11
- declare global {
12
- interface Window {
13
- '__styled-components-init__'?: number;
14
- }
15
- }
16
11
  export * from './secretInternals';
17
12
  export { AttrsArg as Attrs, DefaultTheme, ShouldForwardProp } from './types';
18
13
  export { createGlobalStyle, css, isStyledComponent, IStyleSheetManager, IStyleSheetContext, IStylisContext, keyframes, ServerStyleSheet, StyleSheetConsumer, StyleSheetContext, StyleSheetManager, ThemeConsumer, ThemeContext, ThemeProvider, useTheme, SC_VERSION as version, withTheme, };
@@ -18,7 +18,7 @@ var SC_ATTR = (typeof process !== 'undefined' && typeof process.env !== 'undefin
18
18
  'data-styled';
19
19
  var SC_ATTR_ACTIVE = 'active';
20
20
  var SC_ATTR_VERSION = 'data-styled-version';
21
- var SC_VERSION = "6.0.0-beta.12";
21
+ var SC_VERSION = "6.0.0-beta.13";
22
22
  var SPLITTER = '/*!sc*/\n';
23
23
  var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
24
24
  var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
@@ -1551,7 +1551,11 @@ function createStyledComponent(target, options, rules) {
1551
1551
  checkDynamicCreation(displayName, styledComponentId);
1552
1552
  WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName, styledComponentId);
1553
1553
  }
1554
- WrappedStyledComponent.toString = function () { return ".".concat(WrappedStyledComponent.styledComponentId); };
1554
+ // If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
1555
+ // cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
1556
+ // mode, attempting that will be silently ignored.
1557
+ // However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
1558
+ Object.defineProperty(WrappedStyledComponent, 'toString', { value: function () { return ".".concat(WrappedStyledComponent.styledComponentId); } });
1555
1559
  if (isCompositeComponent) {
1556
1560
  var compositeComponentTarget = target;
1557
1561
  hoistNonReactStatics(WrappedStyledComponent, compositeComponentTarget, {
@@ -1822,22 +1826,21 @@ var __PRIVATE__ = {
1822
1826
  if (process.env.NODE_ENV !== 'production' &&
1823
1827
  typeof navigator !== 'undefined' &&
1824
1828
  navigator.product === 'ReactNative') {
1825
- console.warn("It looks like you've imported 'styled-components' on React Native.\n" +
1826
- "Perhaps you're looking to import 'styled-components/native'?\n" +
1827
- 'Read more about this at https://www.styled-components.com/docs/basics#react-native');
1829
+ console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");
1828
1830
  }
1831
+ var windowGlobalKey = "__sc-".concat(SC_ATTR, "__");
1829
1832
  /* Warning if there are several instances of styled-components */
1830
1833
  if (process.env.NODE_ENV !== 'production' &&
1831
1834
  process.env.NODE_ENV !== 'test' &&
1832
1835
  typeof window !== 'undefined') {
1833
- window['__styled-components-init__'] || (window['__styled-components-init__'] = 0);
1834
- if (window['__styled-components-init__'] === 1) {
1835
- console.warn("It looks like there are several instances of 'styled-components' initialized in this application. " +
1836
- 'This may cause dynamic styles to not render properly, errors during the rehydration process, ' +
1837
- 'a missing theme prop, and makes your application bigger without good reason.\n\n' +
1838
- 'See https://s-c.sh/2BAXzed for more info.');
1839
- }
1840
- window['__styled-components-init__'] += 1;
1836
+ // @ts-expect-error dynamic key not in window object
1837
+ window[windowGlobalKey] || (window[windowGlobalKey] = 0);
1838
+ // @ts-expect-error dynamic key not in window object
1839
+ if (window[windowGlobalKey] === 1) {
1840
+ console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info.");
1841
+ }
1842
+ // @ts-expect-error dynamic key not in window object
1843
+ window[windowGlobalKey] += 1;
1841
1844
  }
1842
1845
 
1843
1846
  exports.ServerStyleSheet = ServerStyleSheet;