react-shadertoy 0.3.0 → 0.5.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.
package/README.md CHANGED
@@ -4,9 +4,10 @@ Run [Shadertoy](https://www.shadertoy.com/) GLSL shaders in React. Copy-paste an
4
4
 
5
5
  - Zero dependencies (just React)
6
6
  - All Shadertoy uniforms supported (`iTime`, `iResolution`, `iMouse`, `iDate`, etc.)
7
+ - iChannel0-3 textures (image URL, video, canvas)
8
+ - Multipass rendering (Buffer A-D → Image)
7
9
  - Mouse & touch interaction built-in
8
10
  - TypeScript-first
9
- - < 4KB gzipped
10
11
 
11
12
  ## Install
12
13
 
package/dist/index.d.mts CHANGED
@@ -3,17 +3,45 @@ import { CSSProperties, RefObject } from 'react';
3
3
 
4
4
  /** Texture source: URL string, or an HTML element for dynamic textures */
5
5
  type TextureSource = string | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement;
6
+ type TextureWrap = 'clamp' | 'repeat';
7
+ type TextureFilter = 'nearest' | 'linear' | 'mipmap';
8
+ /** Advanced texture options with wrap/filter/vflip control */
9
+ interface TextureOptions {
10
+ src: TextureSource;
11
+ wrap?: TextureWrap;
12
+ filter?: TextureFilter;
13
+ vflip?: boolean;
14
+ }
15
+ /** A texture input: shorthand source or full options object */
16
+ type TextureInput = TextureSource | TextureOptions;
6
17
  /** Texture inputs mapped to Shadertoy channels */
7
18
  type TextureInputs = {
8
- iChannel0?: TextureSource;
9
- iChannel1?: TextureSource;
10
- iChannel2?: TextureSource;
11
- iChannel3?: TextureSource;
19
+ iChannel0?: TextureInput;
20
+ iChannel1?: TextureInput;
21
+ iChannel2?: TextureInput;
22
+ iChannel3?: TextureInput;
23
+ };
24
+ type PassName = 'BufferA' | 'BufferB' | 'BufferC' | 'BufferD' | 'Image';
25
+ /** A channel input for a multipass pass: external texture or another pass name */
26
+ type PassInput = TextureInput | PassName;
27
+ /** Configuration for a single render pass */
28
+ interface PassConfig {
29
+ code: string;
30
+ iChannel0?: PassInput;
31
+ iChannel1?: PassInput;
32
+ iChannel2?: PassInput;
33
+ iChannel3?: PassInput;
34
+ }
35
+ /** Multipass configuration: Buffer A-D + Image */
36
+ type MultipassConfig = {
37
+ [K in PassName]?: PassConfig;
12
38
  };
13
39
  interface ShadertoyProps {
14
40
  /** Shadertoy-compatible GLSL fragment shader (must contain mainImage) */
15
- fragmentShader: string;
16
- /** Texture inputs for iChannel0-3 */
41
+ fragmentShader?: string;
42
+ /** Multipass configuration (Buffer A-D + Image) */
43
+ passes?: MultipassConfig;
44
+ /** Texture inputs for iChannel0-3 (single-pass mode) */
17
45
  textures?: TextureInputs;
18
46
  /** Container style */
19
47
  style?: CSSProperties;
@@ -33,7 +61,8 @@ interface ShadertoyProps {
33
61
  onLoad?: () => void;
34
62
  }
35
63
  interface UseShadertoyOptions {
36
- fragmentShader: string;
64
+ fragmentShader?: string;
65
+ passes?: MultipassConfig;
37
66
  textures?: TextureInputs;
38
67
  paused?: boolean;
39
68
  speed?: number;
@@ -50,8 +79,8 @@ interface UseShadertoyReturn {
50
79
  resume: () => void;
51
80
  }
52
81
 
53
- declare function Shadertoy({ fragmentShader, textures, style, className, paused, speed, pixelRatio, mouse, onError, onLoad, }: ShadertoyProps): react_jsx_runtime.JSX.Element;
82
+ declare function Shadertoy({ fragmentShader, passes, textures, style, className, paused, speed, pixelRatio, mouse, onError, onLoad, }: ShadertoyProps): react_jsx_runtime.JSX.Element;
54
83
 
55
- declare function useShadertoy({ fragmentShader, textures: texturesProp, paused, speed, pixelRatio, mouse: mouseEnabled, onError, onLoad, }: UseShadertoyOptions): UseShadertoyReturn;
84
+ declare function useShadertoy({ fragmentShader, passes: passesProp, textures: texturesProp, paused, speed, pixelRatio, mouse: mouseEnabled, onError, onLoad, }: UseShadertoyOptions): UseShadertoyReturn;
56
85
 
57
- export { Shadertoy, type ShadertoyProps, type TextureInputs, type UseShadertoyOptions, type UseShadertoyReturn, useShadertoy };
86
+ export { type MultipassConfig, type PassConfig, type PassName, Shadertoy, type ShadertoyProps, type TextureFilter, type TextureInput, type TextureInputs, type TextureOptions, type TextureWrap, type UseShadertoyOptions, type UseShadertoyReturn, useShadertoy };
package/dist/index.d.ts CHANGED
@@ -3,17 +3,45 @@ import { CSSProperties, RefObject } from 'react';
3
3
 
4
4
  /** Texture source: URL string, or an HTML element for dynamic textures */
5
5
  type TextureSource = string | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement;
6
+ type TextureWrap = 'clamp' | 'repeat';
7
+ type TextureFilter = 'nearest' | 'linear' | 'mipmap';
8
+ /** Advanced texture options with wrap/filter/vflip control */
9
+ interface TextureOptions {
10
+ src: TextureSource;
11
+ wrap?: TextureWrap;
12
+ filter?: TextureFilter;
13
+ vflip?: boolean;
14
+ }
15
+ /** A texture input: shorthand source or full options object */
16
+ type TextureInput = TextureSource | TextureOptions;
6
17
  /** Texture inputs mapped to Shadertoy channels */
7
18
  type TextureInputs = {
8
- iChannel0?: TextureSource;
9
- iChannel1?: TextureSource;
10
- iChannel2?: TextureSource;
11
- iChannel3?: TextureSource;
19
+ iChannel0?: TextureInput;
20
+ iChannel1?: TextureInput;
21
+ iChannel2?: TextureInput;
22
+ iChannel3?: TextureInput;
23
+ };
24
+ type PassName = 'BufferA' | 'BufferB' | 'BufferC' | 'BufferD' | 'Image';
25
+ /** A channel input for a multipass pass: external texture or another pass name */
26
+ type PassInput = TextureInput | PassName;
27
+ /** Configuration for a single render pass */
28
+ interface PassConfig {
29
+ code: string;
30
+ iChannel0?: PassInput;
31
+ iChannel1?: PassInput;
32
+ iChannel2?: PassInput;
33
+ iChannel3?: PassInput;
34
+ }
35
+ /** Multipass configuration: Buffer A-D + Image */
36
+ type MultipassConfig = {
37
+ [K in PassName]?: PassConfig;
12
38
  };
13
39
  interface ShadertoyProps {
14
40
  /** Shadertoy-compatible GLSL fragment shader (must contain mainImage) */
15
- fragmentShader: string;
16
- /** Texture inputs for iChannel0-3 */
41
+ fragmentShader?: string;
42
+ /** Multipass configuration (Buffer A-D + Image) */
43
+ passes?: MultipassConfig;
44
+ /** Texture inputs for iChannel0-3 (single-pass mode) */
17
45
  textures?: TextureInputs;
18
46
  /** Container style */
19
47
  style?: CSSProperties;
@@ -33,7 +61,8 @@ interface ShadertoyProps {
33
61
  onLoad?: () => void;
34
62
  }
35
63
  interface UseShadertoyOptions {
36
- fragmentShader: string;
64
+ fragmentShader?: string;
65
+ passes?: MultipassConfig;
37
66
  textures?: TextureInputs;
38
67
  paused?: boolean;
39
68
  speed?: number;
@@ -50,8 +79,8 @@ interface UseShadertoyReturn {
50
79
  resume: () => void;
51
80
  }
52
81
 
53
- declare function Shadertoy({ fragmentShader, textures, style, className, paused, speed, pixelRatio, mouse, onError, onLoad, }: ShadertoyProps): react_jsx_runtime.JSX.Element;
82
+ declare function Shadertoy({ fragmentShader, passes, textures, style, className, paused, speed, pixelRatio, mouse, onError, onLoad, }: ShadertoyProps): react_jsx_runtime.JSX.Element;
54
83
 
55
- declare function useShadertoy({ fragmentShader, textures: texturesProp, paused, speed, pixelRatio, mouse: mouseEnabled, onError, onLoad, }: UseShadertoyOptions): UseShadertoyReturn;
84
+ declare function useShadertoy({ fragmentShader, passes: passesProp, textures: texturesProp, paused, speed, pixelRatio, mouse: mouseEnabled, onError, onLoad, }: UseShadertoyOptions): UseShadertoyReturn;
56
85
 
57
- export { Shadertoy, type ShadertoyProps, type TextureInputs, type UseShadertoyOptions, type UseShadertoyReturn, useShadertoy };
86
+ export { type MultipassConfig, type PassConfig, type PassName, Shadertoy, type ShadertoyProps, type TextureFilter, type TextureInput, type TextureInputs, type TextureOptions, type TextureWrap, type UseShadertoyOptions, type UseShadertoyReturn, useShadertoy };