aura-glass 2.0.28 → 2.0.30

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.js CHANGED
@@ -112,14 +112,20 @@ function cn$1() {
112
112
 
113
113
  /**
114
114
  * Environment helpers to centralize SSR/browser detection and safe global access.
115
+ *
116
+ * CRITICAL: These must check dynamically, NOT cache at module load time,
117
+ * to handle polyfills and avoid locking in server environment values.
118
+ */
119
+ /**
120
+ * Dynamic check - re-evaluates on every call to support polyfills
115
121
  */
116
- const hasWindow = typeof window !== 'undefined';
117
- const hasDocument = typeof document !== 'undefined';
118
- const hasNavigator = typeof navigator !== 'undefined';
122
+ const hasWindow = () => typeof window !== 'undefined';
123
+ const hasDocument = () => typeof document !== 'undefined';
124
+ const hasNavigator = () => typeof navigator !== 'undefined';
119
125
  /**
120
126
  * Returns true when executed in a browser-like environment.
121
127
  */
122
- const isBrowser = () => hasWindow && hasDocument;
128
+ const isBrowser = () => hasWindow() && hasDocument();
123
129
  /**
124
130
  * Convenience inverse helper.
125
131
  */
@@ -127,15 +133,15 @@ const isServer = () => !isBrowser();
127
133
  /**
128
134
  * Safely access the `window` object when available.
129
135
  */
130
- const getSafeWindow = () => hasWindow ? window : undefined;
136
+ const getSafeWindow = () => hasWindow() ? window : undefined;
131
137
  /**
132
138
  * Safely access the `document` object when available.
133
139
  */
134
- const getSafeDocument = () => hasDocument ? document : undefined;
140
+ const getSafeDocument = () => hasDocument() ? document : undefined;
135
141
  /**
136
142
  * Safely access the `navigator` object when available.
137
143
  */
138
- const getSafeNavigator = () => hasNavigator ? navigator : undefined;
144
+ const getSafeNavigator = () => hasNavigator() ? navigator : undefined;
139
145
  /**
140
146
  * Helper to guard feature detection against SSR environments.
141
147
  */
@@ -3843,20 +3849,33 @@ const OptimizedGlassCore = /*#__PURE__*/React.forwardRef((props, ref) => {
3843
3849
  style
3844
3850
  } = props,
3845
3851
  restProps = _objectWithoutProperties(props, _excluded$2S);
3846
- // Detect device capabilities for auto tier selection
3847
- const device = React.useMemo(() => detectDevice(), []);
3848
- // Automatically determine performance tier based on device capabilities
3849
- const computedTier = React.useMemo(() => {
3850
- if (tier !== 'high') return tier; // Respect explicitly set tier
3851
- // Auto-detect performance tier
3852
+ // CRITICAL FIX for SSR hydration: Defer tier detection until after initial render
3853
+ // This prevents className mismatches between server and client
3854
+ const [computedTier, setComputedTier] = React.useState(() => {
3855
+ // If tier is explicitly set (not default 'high'), respect it immediately
3856
+ if (tier !== 'high') return tier;
3857
+ // Start with 'medium' for both server and initial client render
3858
+ return 'medium';
3859
+ });
3860
+ // Auto-detect performance tier on client AFTER hydration
3861
+ React.useEffect(() => {
3862
+ // Only auto-detect if using default tier
3863
+ if (tier !== 'high') {
3864
+ setComputedTier(tier);
3865
+ return;
3866
+ }
3867
+ // Skip detection on server
3868
+ if (!isBrowser()) return;
3869
+ // Detect device capabilities and update tier
3870
+ const device = detectDevice();
3852
3871
  if (device.capabilities.gpu && device.capabilities.hardwareAcceleration) {
3853
- return 'high';
3872
+ setComputedTier('high');
3854
3873
  } else if (device.capabilities.webgl) {
3855
- return 'medium';
3874
+ setComputedTier('medium');
3856
3875
  } else {
3857
- return 'low';
3876
+ setComputedTier('low');
3858
3877
  }
3859
- }, [tier, device.capabilities]);
3878
+ }, [tier]);
3860
3879
  // Use unified glass system with performance tier
3861
3880
  const glassStyles = React.useMemo(() => {
3862
3881
  const glassOptions = {
@@ -5478,6 +5497,11 @@ const UnifiedThemeProvider = _ref => {
5478
5497
  children: jsxRuntime.jsx(ResponsiveContext.Provider, {
5479
5498
  value: responsiveContextValue,
5480
5499
  children: (() => {
5500
+ // Server-side: skip styled-components entirely
5501
+ if (typeof window === 'undefined') {
5502
+ return children;
5503
+ }
5504
+ // Client-side only: load styled-components
5481
5505
  const StyledThemeProvider = getStyledThemeProvider();
5482
5506
  return StyledThemeProvider ? jsxRuntime.jsx(StyledThemeProvider, {
5483
5507
  theme: theme,