Skip to content

Commit d1a2688

Browse files
committed
Adding use client directive
1 parent 9704470 commit d1a2688

File tree

14 files changed

+251
-233
lines changed

14 files changed

+251
-233
lines changed

CHANGELOG.md

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# @paper-design/shaders-react
1+
# Paper Shaders
2+
3+
## Version 0.0.45
4+
5+
### General
6+
7+
- Added `'use client'` to React bundle for better RSC "out of the box" experience.
8+
- Improved RSC and SSR handling
9+
- Reduced bundle size by removing unused texture
10+
211
## Version 0.0.44
312

413
### General
@@ -13,46 +22,53 @@
1322
### Existing Shader Improvements
1423

1524
- **Antialiasing** improved across multiple shaders:
16-
- *Waves, Warp, Swirl, Spiral, SimplexNoise, PulsingBorder, LiquidMetal, GrainGradient*
25+
26+
- _Waves, Warp, Swirl, Spiral, SimplexNoise, PulsingBorder, LiquidMetal, GrainGradient_
1727

1828
- **Voronoi**
19-
- Fixed glow color behavior: glow is now fully hidden when `glow = 0`
29+
30+
- Fixed glow color behavior: glow is now fully hidden when `glow = 0`
2031

2132
- **Swirl**
22-
- Improved color distribution
23-
- Renamed `noisePower` to `noise`
24-
- Normalized `noiseFrequency`
33+
34+
- Improved color distribution
35+
- Renamed `noisePower` to `noise`
36+
- Normalized `noiseFrequency`
2537

2638
- **Spiral**
27-
- Enhanced algorithm for `lineWidth`, `strokeTaper`, `strokeCap`, `noise`, and `distortion`
28-
- Swapped `colorBack` and `colorFront`
29-
- Renamed `noisePower` to `noise`
30-
- Normalized `noiseFrequency`
39+
40+
- Enhanced algorithm for `lineWidth`, `strokeTaper`, `strokeCap`, `noise`, and `distortion`
41+
- Swapped `colorBack` and `colorFront`
42+
- Renamed `noisePower` to `noise`
43+
- Normalized `noiseFrequency`
3144

3245
- **PulsingBorder**
33-
- Normalized `thickness`, `intensity`, `spotSize`, and `smokeSize`
34-
- Renamed `spotsPerColor` to `spots`
35-
- `intensity` now affects only the shape, not color mixing
36-
- Added new `bloom` parameter to control color mixing and blending
37-
- Reduced maximum number of spots, but individual spots stay visible longer
38-
- Improved inner corner masking
39-
- Performance optimizations
40-
- Pulsing signal is now slower and simpler, (a composition of two sine waves instead of a pre-computed
41-
speech-mimicking
42-
data)
46+
47+
- Normalized `thickness`, `intensity`, `spotSize`, and `smokeSize`
48+
- Renamed `spotsPerColor` to `spots`
49+
- `intensity` now affects only the shape, not color mixing
50+
- Added new `bloom` parameter to control color mixing and blending
51+
- Reduced maximum number of spots, but individual spots stay visible longer
52+
- Improved inner corner masking
53+
- Performance optimizations
54+
- Pulsing signal is now slower and simpler, (a composition of two sine waves instead of a pre-computed
55+
speech-mimicking
56+
data)
4357

4458
- **MeshGradient**
45-
- Minor performance improvements
59+
60+
- Minor performance improvements
4661

4762
- **ColorPanels**
48-
- Added new `edges` parameter
63+
64+
- Added new `edges` parameter
4965

5066
- **Default Presets** updated for the following shaders:
51-
- *Spiral, SimplexNoise, PulsingBorder, NeuroNoise, GrainGradient, DotGrid, Dithering*
67+
- _Spiral, SimplexNoise, PulsingBorder, NeuroNoise, GrainGradient, DotGrid, Dithering_
5268

5369
---
5470

5571
### New Shaders
5672

5773
- Added `StaticMeshGradient` component
58-
- Added `StaticRadialGradient` component
74+
- Added `StaticRadialGradient` component

packages/shaders-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paper-design/shaders-react",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"license": "MIT",
55
"type": "module",
66
"sideEffects": false,

packages/shaders-react/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
export { ShaderMount } from './shader-mount.js';
24
export type { ShaderMountProps, ShaderComponentProps } from './shader-mount.js';
35

packages/shaders-react/src/shader-mount.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import {
99
} from '@paper-design/shaders';
1010
import { useMergeRefs } from './use-merge-refs.js';
1111

12-
/** React Shader Mount can also accept strings as uniform values, which will assumed to be URLs and loaded as images */
12+
/**
13+
* React Shader Mount can also accept strings as uniform values, which will assumed to be URLs and loaded as images
14+
*
15+
* We accept undefined as a convenience for server rendering, when some things may be undefined
16+
* We just skip setting the uniform if it's undefined. This allows the shader mount to still take up space during server rendering
17+
*/
1318
interface ShaderMountUniformsReact {
14-
[key: string]: string | boolean | number | number[] | number[][] | HTMLImageElement;
19+
[key: string]: string | boolean | number | number[] | number[][] | HTMLImageElement | undefined;
1520
}
1621

1722
export interface ShaderMountProps extends Omit<React.ComponentProps<'div'>, 'color' | 'ref'>, ShaderMotionParams {

packages/shaders-react/src/shaders/grain-gradient.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ export const GrainGradient: React.FC<GrainGradientProps> = memo(function GrainGr
159159
worldHeight = defaultPreset.params.worldHeight,
160160
...props
161161
}: GrainGradientProps) {
162-
const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture() };
163-
164162
const uniforms = {
165163
// Own uniforms
166164
u_colorBack: getShaderColorFromString(colorBack),
@@ -170,7 +168,7 @@ export const GrainGradient: React.FC<GrainGradientProps> = memo(function GrainGr
170168
u_intensity: intensity,
171169
u_noise: noise,
172170
u_shape: GrainGradientShapes[shape],
173-
...noiseTexture,
171+
u_noiseTexture: getShaderNoiseTexture(),
174172

175173
// Sizing uniforms
176174
u_fit: ShaderFitOptions[fit],

packages/shaders-react/src/shaders/pulsing-border.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ export const PulsingBorder: React.FC<PulsingBorderProps> = memo(function Pulsing
140140
worldHeight = defaultPreset.params.worldHeight,
141141
...props
142142
}: PulsingBorderProps) {
143-
const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture(0) };
144143
const uniforms = {
145144
// Own uniforms
146145
u_colorBack: getShaderColorFromString(colorBack),
@@ -156,7 +155,7 @@ export const PulsingBorder: React.FC<PulsingBorderProps> = memo(function Pulsing
156155
u_pulse: pulse,
157156
u_smoke: smoke,
158157
u_smokeSize: smokeSize,
159-
...noiseTexture,
158+
u_noiseTexture: getShaderNoiseTexture(),
160159

161160
// Sizing uniforms
162161
u_fit: ShaderFitOptions[fit],

packages/shaders-react/src/shaders/smoke-ring.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ export const SmokeRing: React.FC<SmokeRingProps> = memo(function SmokeRingImpl({
107107
worldHeight = defaultPreset.params.worldHeight,
108108
...props
109109
}: SmokeRingProps) {
110-
const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture() };
111-
112110
const uniforms = {
113111
// Own uniforms
114112
u_colorBack: getShaderColorFromString(colorBack),
@@ -119,7 +117,7 @@ export const SmokeRing: React.FC<SmokeRingProps> = memo(function SmokeRingImpl({
119117
u_radius: radius,
120118
u_innerShape: innerShape,
121119
u_noiseIterations: noiseIterations,
122-
...noiseTexture,
120+
u_noiseTexture: getShaderNoiseTexture(),
123121

124122
// Sizing uniforms
125123
u_fit: ShaderFitOptions[fit],

packages/shaders-react/src/shaders/voronoi.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ export const Voronoi: React.FC<VoronoiProps> = memo(function VoronoiImpl({
109109
worldHeight = defaultPreset.params.worldHeight,
110110
...props
111111
}: VoronoiProps) {
112-
const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture() };
113-
114112
const uniforms = {
115113
// Own uniforms
116114
u_colors: colors.map(getShaderColorFromString),
@@ -121,7 +119,7 @@ export const Voronoi: React.FC<VoronoiProps> = memo(function VoronoiImpl({
121119
u_distortion: distortion,
122120
u_gap: gap,
123121
u_glow: glow,
124-
...noiseTexture,
122+
u_noiseTexture: getShaderNoiseTexture(),
125123

126124
// Sizing uniforms
127125
u_fit: ShaderFitOptions[fit],

packages/shaders/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paper-design/shaders",
3-
"version": "0.0.40",
3+
"version": "0.0.45",
44
"license": "MIT",
55
"type": "module",
66
"sideEffects": false,

packages/shaders/src/get-shader-noise-texture.ts

Lines changed: 6 additions & 13 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)