@votax572002/fluxfx 0.0.0-stage → 0.1.1
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/fluxfx.min.js +1302 -0
- package/dist/index.cjs +1302 -0
- package/dist/index.d.cts +206 -0
- package/dist/index.d.ts +206 -0
- package/dist/index.js +1302 -0
- package/dist/react.cjs +1303 -0
- package/dist/react.d.cts +127 -0
- package/dist/react.d.ts +127 -0
- package/dist/react.js +1303 -0
- package/package.json +47 -5
- package/README.md +0 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
type QualityLevel = 'low' | 'medium' | 'high';
|
|
2
|
+
type UniformValue = number | [number, number] | [number, number, number] | [number, number, number, number] | Float32Array;
|
|
3
|
+
interface PerformanceOptions {
|
|
4
|
+
/** Enable adaptive DPR scaling when FPS drops (default: true) */
|
|
5
|
+
dynamicResolution?: boolean;
|
|
6
|
+
/** Minimum DPR floor (default based on quality) */
|
|
7
|
+
minDpr?: number;
|
|
8
|
+
/** Maximum DPR cap (default based on quality) */
|
|
9
|
+
maxDpr?: number;
|
|
10
|
+
/** Run WebGL2 on a background thread via OffscreenCanvas (default: true) */
|
|
11
|
+
offscreen?: boolean;
|
|
12
|
+
/** Automatically pause rendering when scrolled out of view (default: true) */
|
|
13
|
+
pauseWhenHidden?: boolean;
|
|
14
|
+
/** Render a static frame & stop loop when OS Reduce Motion is enabled (default: true) */
|
|
15
|
+
respectReducedMotion?: boolean;
|
|
16
|
+
/** Track container scroll progress (uScroll) and velocity (uScrollVel) (default: false) */
|
|
17
|
+
trackScroll?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface FXOptions extends PerformanceOptions {
|
|
20
|
+
speed?: number;
|
|
21
|
+
quality?: QualityLevel;
|
|
22
|
+
colors?: string | [string, string, string] | string[];
|
|
23
|
+
color1?: string;
|
|
24
|
+
color2?: string;
|
|
25
|
+
color3?: string;
|
|
26
|
+
interactive?: boolean;
|
|
27
|
+
maxTilt?: number;
|
|
28
|
+
scale?: number;
|
|
29
|
+
perspective?: number;
|
|
30
|
+
glare?: boolean;
|
|
31
|
+
strength?: number;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
interface FXInstance {
|
|
35
|
+
update?: (time: number, delta: number) => void;
|
|
36
|
+
/** Hot-update options/uniforms without destroying & remounting WebGL context */
|
|
37
|
+
setOptions?: (options: FXOptions) => void;
|
|
38
|
+
resize?: () => void;
|
|
39
|
+
pause?: () => void;
|
|
40
|
+
resume?: () => void;
|
|
41
|
+
destroy: () => void;
|
|
42
|
+
}
|
|
43
|
+
interface FXPlugin {
|
|
44
|
+
name: string;
|
|
45
|
+
mount: (el: HTMLElement, options: FXOptions) => FXInstance;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface FluxStats {
|
|
49
|
+
mounted: number;
|
|
50
|
+
visible: number;
|
|
51
|
+
activeLoops: number;
|
|
52
|
+
registered: number;
|
|
53
|
+
webglContexts: number;
|
|
54
|
+
reducedMotion: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare class FluxEngine {
|
|
57
|
+
private plugins;
|
|
58
|
+
private activeByElement;
|
|
59
|
+
private activeSet;
|
|
60
|
+
private visibilityObserver;
|
|
61
|
+
private visibilityCallbacks;
|
|
62
|
+
private removeTicker;
|
|
63
|
+
private ensureObserver;
|
|
64
|
+
private ensureTicker;
|
|
65
|
+
private stopTickerIfEmpty;
|
|
66
|
+
register(plugin: FXPlugin): this;
|
|
67
|
+
has(name: string): boolean;
|
|
68
|
+
getStats(): FluxStats;
|
|
69
|
+
/**
|
|
70
|
+
* Mounts an effect on a DOM element and returns a cleanup function.
|
|
71
|
+
* React StrictMode safe and error-isolated.
|
|
72
|
+
*/
|
|
73
|
+
apply(el: HTMLElement, name: string, options?: FXOptions): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Hot-updates options on an already-mounted effect without destroying its WebGL context.
|
|
76
|
+
* Falls back to seamless in-place remount if the plugin does not implement setOptions().
|
|
77
|
+
*/
|
|
78
|
+
update(el: HTMLElement, name: string, options?: FXOptions): boolean;
|
|
79
|
+
scan(root?: ParentNode): void;
|
|
80
|
+
init(root?: ParentNode): void;
|
|
81
|
+
destroyAll(): void;
|
|
82
|
+
private parseDatasetOptions;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface WebGLQuadOptions extends PerformanceOptions {
|
|
86
|
+
fragmentShader: string;
|
|
87
|
+
vertexShader?: string;
|
|
88
|
+
/** Optional Ping-Pong feedback shader (samples previous frame via `uniform sampler2D uPrevFrame`) */
|
|
89
|
+
feedbackShader?: string;
|
|
90
|
+
/** Feedback FBO resolution scale relative to canvas (default: 0.5) */
|
|
91
|
+
feedbackScale?: number;
|
|
92
|
+
/** Max pixel dimension on longest FBO edge so 4K/5K Retina stays silky smooth */
|
|
93
|
+
feedbackMaxDim?: number;
|
|
94
|
+
/** Prefer RGBA16F half-float FBO textures with automatic RGBA8 fallback (default: true) */
|
|
95
|
+
feedbackFloat?: boolean;
|
|
96
|
+
speed?: number;
|
|
97
|
+
quality?: QualityLevel;
|
|
98
|
+
colors?: [string, string, string] | string[];
|
|
99
|
+
uniforms?: Record<string, UniformValue>;
|
|
100
|
+
interactive?: boolean;
|
|
101
|
+
}
|
|
102
|
+
declare class WebGLQuad {
|
|
103
|
+
private static _activeContexts;
|
|
104
|
+
static get activeContexts(): number;
|
|
105
|
+
private container;
|
|
106
|
+
private canvas;
|
|
107
|
+
private options;
|
|
108
|
+
private resizeObserver;
|
|
109
|
+
private visibilityObserver;
|
|
110
|
+
private reducedMotionQuery;
|
|
111
|
+
private dprMediaQuery;
|
|
112
|
+
private worker;
|
|
113
|
+
private isOffscreen;
|
|
114
|
+
private gl;
|
|
115
|
+
private programEntry;
|
|
116
|
+
private feedbackProgramEntry;
|
|
117
|
+
private vao;
|
|
118
|
+
private vbo;
|
|
119
|
+
private dynamicRes;
|
|
120
|
+
private lastRenderNow;
|
|
121
|
+
private elapsedSec;
|
|
122
|
+
private lastDeltaSec;
|
|
123
|
+
private currentSpeed;
|
|
124
|
+
private targetSpeed;
|
|
125
|
+
private needsResize;
|
|
126
|
+
private pingPong;
|
|
127
|
+
private fboW;
|
|
128
|
+
private fboH;
|
|
129
|
+
private fboFormat;
|
|
130
|
+
private fboType;
|
|
131
|
+
private readIdx;
|
|
132
|
+
private writeIdx;
|
|
133
|
+
private feedbackScale;
|
|
134
|
+
private feedbackMaxDim;
|
|
135
|
+
private feedbackFloat;
|
|
136
|
+
private customUniforms;
|
|
137
|
+
private mouse;
|
|
138
|
+
private targetMouse;
|
|
139
|
+
private mouseVel;
|
|
140
|
+
private mouseDown;
|
|
141
|
+
private mouseActive;
|
|
142
|
+
private targetMouseActive;
|
|
143
|
+
private isPointerInside;
|
|
144
|
+
private scroll;
|
|
145
|
+
private targetScroll;
|
|
146
|
+
private scrollVel;
|
|
147
|
+
private trackScroll;
|
|
148
|
+
private hasScrollListener;
|
|
149
|
+
private width;
|
|
150
|
+
private height;
|
|
151
|
+
private isPaused;
|
|
152
|
+
private isHiddenByViewport;
|
|
153
|
+
private isContextLost;
|
|
154
|
+
private isReducedMotion;
|
|
155
|
+
private respectReducedMotion;
|
|
156
|
+
private isDestroyed;
|
|
157
|
+
private interactive;
|
|
158
|
+
private hasPointerListener;
|
|
159
|
+
private countedContext;
|
|
160
|
+
constructor(container: HTMLElement, options: WebGLQuadOptions);
|
|
161
|
+
private resolveDprBounds;
|
|
162
|
+
private computeScrollProgress;
|
|
163
|
+
private markContextActive;
|
|
164
|
+
private markContextReleased;
|
|
165
|
+
private seedUniformsFromOptions;
|
|
166
|
+
private fallbackToMainThread;
|
|
167
|
+
private initOffscreenMode;
|
|
168
|
+
private computeFboDimsMain;
|
|
169
|
+
private destroyPingPongMain;
|
|
170
|
+
private createPingPongMain;
|
|
171
|
+
private resizePingPongMain;
|
|
172
|
+
private initMainThreadPipeline;
|
|
173
|
+
private initMainThreadMode;
|
|
174
|
+
private handleContextLost;
|
|
175
|
+
private handleContextRestored;
|
|
176
|
+
private applyCanvasSize;
|
|
177
|
+
private bindCommonUniformsMain;
|
|
178
|
+
private drawMainThreadFrame;
|
|
179
|
+
render(_timeSec?: number, _deltaSec?: number): void;
|
|
180
|
+
private syncDprBounds;
|
|
181
|
+
private handleDprChange;
|
|
182
|
+
private watchDevicePixelRatio;
|
|
183
|
+
updateOptions(next: Partial<WebGLQuadOptions>): void;
|
|
184
|
+
private applyReducedMotionState;
|
|
185
|
+
private handleReducedMotionChange;
|
|
186
|
+
private getLocalPointerCoords;
|
|
187
|
+
private handlePointerEnter;
|
|
188
|
+
private handlePointerMove;
|
|
189
|
+
private handlePointerLeave;
|
|
190
|
+
private handlePointerDown;
|
|
191
|
+
private handlePointerUp;
|
|
192
|
+
private handleScroll;
|
|
193
|
+
private syncPointerListener;
|
|
194
|
+
private syncScrollListener;
|
|
195
|
+
private handleDocVisibility;
|
|
196
|
+
private bindObservers;
|
|
197
|
+
setUniform(name: string, value: UniformValue): void;
|
|
198
|
+
setColor(uniformName: string, color: string): void;
|
|
199
|
+
pause(): void;
|
|
200
|
+
resume(): void;
|
|
201
|
+
destroy(): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const FluxFX: FluxEngine;
|
|
205
|
+
|
|
206
|
+
export { type FXInstance, type FXOptions, type FXPlugin, FluxEngine, FluxFX, WebGLQuad };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
type QualityLevel = 'low' | 'medium' | 'high';
|
|
2
|
+
type UniformValue = number | [number, number] | [number, number, number] | [number, number, number, number] | Float32Array;
|
|
3
|
+
interface PerformanceOptions {
|
|
4
|
+
/** Enable adaptive DPR scaling when FPS drops (default: true) */
|
|
5
|
+
dynamicResolution?: boolean;
|
|
6
|
+
/** Minimum DPR floor (default based on quality) */
|
|
7
|
+
minDpr?: number;
|
|
8
|
+
/** Maximum DPR cap (default based on quality) */
|
|
9
|
+
maxDpr?: number;
|
|
10
|
+
/** Run WebGL2 on a background thread via OffscreenCanvas (default: true) */
|
|
11
|
+
offscreen?: boolean;
|
|
12
|
+
/** Automatically pause rendering when scrolled out of view (default: true) */
|
|
13
|
+
pauseWhenHidden?: boolean;
|
|
14
|
+
/** Render a static frame & stop loop when OS Reduce Motion is enabled (default: true) */
|
|
15
|
+
respectReducedMotion?: boolean;
|
|
16
|
+
/** Track container scroll progress (uScroll) and velocity (uScrollVel) (default: false) */
|
|
17
|
+
trackScroll?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface FXOptions extends PerformanceOptions {
|
|
20
|
+
speed?: number;
|
|
21
|
+
quality?: QualityLevel;
|
|
22
|
+
colors?: string | [string, string, string] | string[];
|
|
23
|
+
color1?: string;
|
|
24
|
+
color2?: string;
|
|
25
|
+
color3?: string;
|
|
26
|
+
interactive?: boolean;
|
|
27
|
+
maxTilt?: number;
|
|
28
|
+
scale?: number;
|
|
29
|
+
perspective?: number;
|
|
30
|
+
glare?: boolean;
|
|
31
|
+
strength?: number;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
interface FXInstance {
|
|
35
|
+
update?: (time: number, delta: number) => void;
|
|
36
|
+
/** Hot-update options/uniforms without destroying & remounting WebGL context */
|
|
37
|
+
setOptions?: (options: FXOptions) => void;
|
|
38
|
+
resize?: () => void;
|
|
39
|
+
pause?: () => void;
|
|
40
|
+
resume?: () => void;
|
|
41
|
+
destroy: () => void;
|
|
42
|
+
}
|
|
43
|
+
interface FXPlugin {
|
|
44
|
+
name: string;
|
|
45
|
+
mount: (el: HTMLElement, options: FXOptions) => FXInstance;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface FluxStats {
|
|
49
|
+
mounted: number;
|
|
50
|
+
visible: number;
|
|
51
|
+
activeLoops: number;
|
|
52
|
+
registered: number;
|
|
53
|
+
webglContexts: number;
|
|
54
|
+
reducedMotion: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare class FluxEngine {
|
|
57
|
+
private plugins;
|
|
58
|
+
private activeByElement;
|
|
59
|
+
private activeSet;
|
|
60
|
+
private visibilityObserver;
|
|
61
|
+
private visibilityCallbacks;
|
|
62
|
+
private removeTicker;
|
|
63
|
+
private ensureObserver;
|
|
64
|
+
private ensureTicker;
|
|
65
|
+
private stopTickerIfEmpty;
|
|
66
|
+
register(plugin: FXPlugin): this;
|
|
67
|
+
has(name: string): boolean;
|
|
68
|
+
getStats(): FluxStats;
|
|
69
|
+
/**
|
|
70
|
+
* Mounts an effect on a DOM element and returns a cleanup function.
|
|
71
|
+
* React StrictMode safe and error-isolated.
|
|
72
|
+
*/
|
|
73
|
+
apply(el: HTMLElement, name: string, options?: FXOptions): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Hot-updates options on an already-mounted effect without destroying its WebGL context.
|
|
76
|
+
* Falls back to seamless in-place remount if the plugin does not implement setOptions().
|
|
77
|
+
*/
|
|
78
|
+
update(el: HTMLElement, name: string, options?: FXOptions): boolean;
|
|
79
|
+
scan(root?: ParentNode): void;
|
|
80
|
+
init(root?: ParentNode): void;
|
|
81
|
+
destroyAll(): void;
|
|
82
|
+
private parseDatasetOptions;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface WebGLQuadOptions extends PerformanceOptions {
|
|
86
|
+
fragmentShader: string;
|
|
87
|
+
vertexShader?: string;
|
|
88
|
+
/** Optional Ping-Pong feedback shader (samples previous frame via `uniform sampler2D uPrevFrame`) */
|
|
89
|
+
feedbackShader?: string;
|
|
90
|
+
/** Feedback FBO resolution scale relative to canvas (default: 0.5) */
|
|
91
|
+
feedbackScale?: number;
|
|
92
|
+
/** Max pixel dimension on longest FBO edge so 4K/5K Retina stays silky smooth */
|
|
93
|
+
feedbackMaxDim?: number;
|
|
94
|
+
/** Prefer RGBA16F half-float FBO textures with automatic RGBA8 fallback (default: true) */
|
|
95
|
+
feedbackFloat?: boolean;
|
|
96
|
+
speed?: number;
|
|
97
|
+
quality?: QualityLevel;
|
|
98
|
+
colors?: [string, string, string] | string[];
|
|
99
|
+
uniforms?: Record<string, UniformValue>;
|
|
100
|
+
interactive?: boolean;
|
|
101
|
+
}
|
|
102
|
+
declare class WebGLQuad {
|
|
103
|
+
private static _activeContexts;
|
|
104
|
+
static get activeContexts(): number;
|
|
105
|
+
private container;
|
|
106
|
+
private canvas;
|
|
107
|
+
private options;
|
|
108
|
+
private resizeObserver;
|
|
109
|
+
private visibilityObserver;
|
|
110
|
+
private reducedMotionQuery;
|
|
111
|
+
private dprMediaQuery;
|
|
112
|
+
private worker;
|
|
113
|
+
private isOffscreen;
|
|
114
|
+
private gl;
|
|
115
|
+
private programEntry;
|
|
116
|
+
private feedbackProgramEntry;
|
|
117
|
+
private vao;
|
|
118
|
+
private vbo;
|
|
119
|
+
private dynamicRes;
|
|
120
|
+
private lastRenderNow;
|
|
121
|
+
private elapsedSec;
|
|
122
|
+
private lastDeltaSec;
|
|
123
|
+
private currentSpeed;
|
|
124
|
+
private targetSpeed;
|
|
125
|
+
private needsResize;
|
|
126
|
+
private pingPong;
|
|
127
|
+
private fboW;
|
|
128
|
+
private fboH;
|
|
129
|
+
private fboFormat;
|
|
130
|
+
private fboType;
|
|
131
|
+
private readIdx;
|
|
132
|
+
private writeIdx;
|
|
133
|
+
private feedbackScale;
|
|
134
|
+
private feedbackMaxDim;
|
|
135
|
+
private feedbackFloat;
|
|
136
|
+
private customUniforms;
|
|
137
|
+
private mouse;
|
|
138
|
+
private targetMouse;
|
|
139
|
+
private mouseVel;
|
|
140
|
+
private mouseDown;
|
|
141
|
+
private mouseActive;
|
|
142
|
+
private targetMouseActive;
|
|
143
|
+
private isPointerInside;
|
|
144
|
+
private scroll;
|
|
145
|
+
private targetScroll;
|
|
146
|
+
private scrollVel;
|
|
147
|
+
private trackScroll;
|
|
148
|
+
private hasScrollListener;
|
|
149
|
+
private width;
|
|
150
|
+
private height;
|
|
151
|
+
private isPaused;
|
|
152
|
+
private isHiddenByViewport;
|
|
153
|
+
private isContextLost;
|
|
154
|
+
private isReducedMotion;
|
|
155
|
+
private respectReducedMotion;
|
|
156
|
+
private isDestroyed;
|
|
157
|
+
private interactive;
|
|
158
|
+
private hasPointerListener;
|
|
159
|
+
private countedContext;
|
|
160
|
+
constructor(container: HTMLElement, options: WebGLQuadOptions);
|
|
161
|
+
private resolveDprBounds;
|
|
162
|
+
private computeScrollProgress;
|
|
163
|
+
private markContextActive;
|
|
164
|
+
private markContextReleased;
|
|
165
|
+
private seedUniformsFromOptions;
|
|
166
|
+
private fallbackToMainThread;
|
|
167
|
+
private initOffscreenMode;
|
|
168
|
+
private computeFboDimsMain;
|
|
169
|
+
private destroyPingPongMain;
|
|
170
|
+
private createPingPongMain;
|
|
171
|
+
private resizePingPongMain;
|
|
172
|
+
private initMainThreadPipeline;
|
|
173
|
+
private initMainThreadMode;
|
|
174
|
+
private handleContextLost;
|
|
175
|
+
private handleContextRestored;
|
|
176
|
+
private applyCanvasSize;
|
|
177
|
+
private bindCommonUniformsMain;
|
|
178
|
+
private drawMainThreadFrame;
|
|
179
|
+
render(_timeSec?: number, _deltaSec?: number): void;
|
|
180
|
+
private syncDprBounds;
|
|
181
|
+
private handleDprChange;
|
|
182
|
+
private watchDevicePixelRatio;
|
|
183
|
+
updateOptions(next: Partial<WebGLQuadOptions>): void;
|
|
184
|
+
private applyReducedMotionState;
|
|
185
|
+
private handleReducedMotionChange;
|
|
186
|
+
private getLocalPointerCoords;
|
|
187
|
+
private handlePointerEnter;
|
|
188
|
+
private handlePointerMove;
|
|
189
|
+
private handlePointerLeave;
|
|
190
|
+
private handlePointerDown;
|
|
191
|
+
private handlePointerUp;
|
|
192
|
+
private handleScroll;
|
|
193
|
+
private syncPointerListener;
|
|
194
|
+
private syncScrollListener;
|
|
195
|
+
private handleDocVisibility;
|
|
196
|
+
private bindObservers;
|
|
197
|
+
setUniform(name: string, value: UniformValue): void;
|
|
198
|
+
setColor(uniformName: string, color: string): void;
|
|
199
|
+
pause(): void;
|
|
200
|
+
resume(): void;
|
|
201
|
+
destroy(): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const FluxFX: FluxEngine;
|
|
205
|
+
|
|
206
|
+
export { type FXInstance, type FXOptions, type FXPlugin, FluxEngine, FluxFX, WebGLQuad };
|