@votax572002/fluxfx 0.1.3 → 0.1.5
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 +63 -0
- package/dist/fluxfx.min.js +946 -112
- package/dist/index.cjs +946 -112
- package/dist/index.d.cts +234 -15
- package/dist/index.d.ts +234 -15
- package/dist/index.js +946 -112
- package/dist/react.cjs +946 -112
- package/dist/react.d.cts +191 -46
- package/dist/react.d.ts +191 -46
- package/dist/react.js +946 -112
- package/package.json +48 -48
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
type ProtectionTier = 0 | 1 | 2 | 3;
|
|
2
|
+
type ProtectionLabel = 'normal' | 'reduced-res' | 'low-fps' | 'survival';
|
|
3
|
+
|
|
1
4
|
type QualityLevel = 'low' | 'medium' | 'high';
|
|
5
|
+
type ThemeMode = 'auto' | 'light' | 'dark';
|
|
6
|
+
type LayerMode = 'background' | 'overlay';
|
|
7
|
+
type PrismShape = 'prism' | 'torus' | 'orb';
|
|
8
|
+
type DeviceTarget = 'all' | 'desktop' | 'mobile' | 'tablet';
|
|
9
|
+
type ImageFitMode = 'cover' | 'contain';
|
|
10
|
+
type ImagePosition = 'center' | 'top' | 'bottom';
|
|
2
11
|
type UniformValue = number | [number, number] | [number, number, number] | [number, number, number, number] | Float32Array;
|
|
3
12
|
interface PerformanceOptions {
|
|
4
13
|
/** Enable adaptive DPR scaling when FPS drops (default: true) */
|
|
@@ -15,11 +24,50 @@ interface PerformanceOptions {
|
|
|
15
24
|
respectReducedMotion?: boolean;
|
|
16
25
|
/** Track container scroll progress (uScroll) and velocity (uScrollVel) (default: false) */
|
|
17
26
|
trackScroll?: boolean;
|
|
27
|
+
/** Target specific device class: 'all' | 'desktop' | 'mobile' | 'tablet' (default: 'all') */
|
|
28
|
+
device?: DeviceTarget;
|
|
29
|
+
/** Minimum viewport width in px required to mount/run the effect */
|
|
30
|
+
minWidth?: number;
|
|
31
|
+
/** Maximum viewport width in px allowed to mount/run the effect */
|
|
32
|
+
maxWidth?: number;
|
|
33
|
+
/** Shortcut: disable effect cleanly on mobile viewports (< mobileBreakpoint) */
|
|
34
|
+
disableOnMobile?: boolean;
|
|
35
|
+
/** Shortcut: disable effect cleanly on desktop viewports (>= mobileBreakpoint) */
|
|
36
|
+
disableOnDesktop?: boolean;
|
|
37
|
+
/** Viewport breakpoint in px separating mobile vs desktop (default: 768) */
|
|
38
|
+
mobileBreakpoint?: number;
|
|
39
|
+
}
|
|
40
|
+
interface FXInstance {
|
|
41
|
+
readonly isWebGL?: boolean;
|
|
42
|
+
update?: (time: number, delta: number) => void;
|
|
43
|
+
/** Hot-update options/uniforms without destroying & remounting WebGL context */
|
|
44
|
+
setOptions?: (options: FXOptions) => void;
|
|
45
|
+
resize?: () => void;
|
|
46
|
+
pause?: () => void;
|
|
47
|
+
resume?: () => void;
|
|
48
|
+
/** Optional: returns true when the effect is settled/idle and needs no ticks */
|
|
49
|
+
isIdle?: () => boolean;
|
|
50
|
+
/** Optional: Engine registers a wake callback so an idle effect can restart the ticker */
|
|
51
|
+
onWake?: (wake: () => void) => void;
|
|
52
|
+
destroy: () => void;
|
|
53
|
+
}
|
|
54
|
+
interface FXPlugin {
|
|
55
|
+
name: string;
|
|
56
|
+
mount: (el: HTMLElement, options: FXOptions) => FXInstance;
|
|
18
57
|
}
|
|
19
58
|
interface FXOptions extends PerformanceOptions {
|
|
20
59
|
speed?: number;
|
|
21
60
|
quality?: QualityLevel;
|
|
61
|
+
bgColor?: string;
|
|
22
62
|
colors?: string | [string, string, string] | string[];
|
|
63
|
+
theme?: ThemeMode;
|
|
64
|
+
lightColors?: string | [string, string, string] | string[];
|
|
65
|
+
darkColors?: string | [string, string, string] | string[];
|
|
66
|
+
scrollColors?: string[] | Array<[string, string]>;
|
|
67
|
+
layer?: LayerMode;
|
|
68
|
+
preserveBg?: boolean;
|
|
69
|
+
adaptToSurface?: boolean;
|
|
70
|
+
overlayOpacity?: number;
|
|
23
71
|
color1?: string;
|
|
24
72
|
color2?: string;
|
|
25
73
|
color3?: string;
|
|
@@ -29,29 +77,55 @@ interface FXOptions extends PerformanceOptions {
|
|
|
29
77
|
perspective?: number;
|
|
30
78
|
glare?: boolean;
|
|
31
79
|
strength?: number;
|
|
80
|
+
shape?: PrismShape;
|
|
81
|
+
depth?: number;
|
|
82
|
+
gloss?: number;
|
|
83
|
+
distortion?: number;
|
|
84
|
+
baseImage?: string;
|
|
85
|
+
revealImage?: string;
|
|
86
|
+
image?: string;
|
|
87
|
+
fit?: ImageFitMode;
|
|
88
|
+
position?: ImagePosition;
|
|
89
|
+
softness?: number;
|
|
90
|
+
edgeNoise?: number;
|
|
91
|
+
edgeGlow?: number;
|
|
92
|
+
ambient?: boolean;
|
|
93
|
+
clickReveal?: boolean;
|
|
94
|
+
activeIndex?: number;
|
|
95
|
+
focused?: boolean;
|
|
96
|
+
wrap?: boolean;
|
|
97
|
+
spread?: number;
|
|
98
|
+
depthScale?: number;
|
|
99
|
+
curve?: number;
|
|
100
|
+
parallax?: boolean | number;
|
|
101
|
+
focusOffsetX?: number;
|
|
102
|
+
focusScale?: number;
|
|
103
|
+
spotRadius?: number;
|
|
104
|
+
spotIntensity?: number;
|
|
105
|
+
spotPosition?: [number, number] | 'center' | 'left' | 'right';
|
|
106
|
+
onChange?: (detail: {
|
|
107
|
+
index: number;
|
|
108
|
+
focused: boolean;
|
|
109
|
+
element: HTMLElement | null;
|
|
110
|
+
}) => void;
|
|
32
111
|
[key: string]: unknown;
|
|
33
112
|
}
|
|
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
113
|
|
|
48
114
|
interface FluxStats {
|
|
49
115
|
mounted: number;
|
|
50
116
|
visible: number;
|
|
117
|
+
pausedEffects: number;
|
|
51
118
|
activeLoops: number;
|
|
52
119
|
registered: number;
|
|
53
120
|
webglContexts: number;
|
|
121
|
+
activeContexts: number;
|
|
122
|
+
maxWebGLContexts: number;
|
|
123
|
+
suspendedContexts: number;
|
|
124
|
+
fps: number;
|
|
125
|
+
frameTimeMs: number;
|
|
54
126
|
reducedMotion: boolean;
|
|
127
|
+
protectionTier: ProtectionTier;
|
|
128
|
+
protectionLabel: ProtectionLabel;
|
|
55
129
|
}
|
|
56
130
|
declare class FluxEngine {
|
|
57
131
|
private plugins;
|
|
@@ -60,11 +134,26 @@ declare class FluxEngine {
|
|
|
60
134
|
private visibilityObserver;
|
|
61
135
|
private visibilityCallbacks;
|
|
62
136
|
private removeTicker;
|
|
137
|
+
private removeVisibilitySub;
|
|
138
|
+
private hasResizeListener;
|
|
139
|
+
private resizeRaf;
|
|
140
|
+
private isDeviceAllowed;
|
|
141
|
+
private hasDeviceConstraints;
|
|
142
|
+
private mountEntryInstance;
|
|
143
|
+
private unmountEntryInstance;
|
|
144
|
+
private attachEntryObserver;
|
|
145
|
+
private handleViewportResize;
|
|
146
|
+
private syncResizeWatcher;
|
|
63
147
|
private ensureObserver;
|
|
148
|
+
private ensureVisibilitySub;
|
|
149
|
+
private hasActiveTickWork;
|
|
150
|
+
private syncTickerState;
|
|
64
151
|
private ensureTicker;
|
|
65
|
-
private
|
|
152
|
+
private cleanupEmptyEngine;
|
|
153
|
+
private bindWake;
|
|
66
154
|
register(plugin: FXPlugin): this;
|
|
67
155
|
has(name: string): boolean;
|
|
156
|
+
setMaxWebGLContexts(limit: number): void;
|
|
68
157
|
getStats(): FluxStats;
|
|
69
158
|
/**
|
|
70
159
|
* Mounts an effect on a DOM element and returns a cleanup function.
|
|
@@ -96,12 +185,38 @@ interface WebGLQuadOptions extends PerformanceOptions {
|
|
|
96
185
|
speed?: number;
|
|
97
186
|
quality?: QualityLevel;
|
|
98
187
|
colors?: [string, string, string] | string[];
|
|
188
|
+
theme?: ThemeMode;
|
|
189
|
+
lightColors?: string | [string, string, string] | string[];
|
|
190
|
+
darkColors?: string | [string, string, string] | string[];
|
|
191
|
+
scrollColors?: string[] | Array<[string, string]>;
|
|
192
|
+
layer?: LayerMode;
|
|
193
|
+
preserveBg?: boolean;
|
|
194
|
+
adaptToSurface?: boolean;
|
|
195
|
+
overlayOpacity?: number;
|
|
99
196
|
uniforms?: Record<string, UniformValue>;
|
|
197
|
+
textures?: Record<string, string>;
|
|
100
198
|
interactive?: boolean;
|
|
101
199
|
}
|
|
102
200
|
declare class WebGLQuad {
|
|
103
201
|
private static _activeContexts;
|
|
202
|
+
private static _maxContexts;
|
|
203
|
+
private static instances;
|
|
204
|
+
private static recycledMainContexts;
|
|
205
|
+
private static acquireRecycledMainContext;
|
|
206
|
+
private static recycleMainContext;
|
|
104
207
|
static get activeContexts(): number;
|
|
208
|
+
static get maxActiveContexts(): number;
|
|
209
|
+
static get suspendedContexts(): number;
|
|
210
|
+
static setMaxActiveContexts(limit: number): void;
|
|
211
|
+
private static pickEvictionVictim;
|
|
212
|
+
private static ensureContextBudget;
|
|
213
|
+
private static enforceContextBudget;
|
|
214
|
+
private static reclaimBudgetForWaiting;
|
|
215
|
+
static getRenderStats(): {
|
|
216
|
+
activeRendering: number;
|
|
217
|
+
fps: number;
|
|
218
|
+
frameTimeMs: number;
|
|
219
|
+
};
|
|
105
220
|
private container;
|
|
106
221
|
private canvas;
|
|
107
222
|
private options;
|
|
@@ -118,6 +233,13 @@ declare class WebGLQuad {
|
|
|
118
233
|
private vbo;
|
|
119
234
|
private dynamicRes;
|
|
120
235
|
private lastRenderNow;
|
|
236
|
+
private lastDrawNow;
|
|
237
|
+
private lastTargetFps;
|
|
238
|
+
private prevFrameDrew;
|
|
239
|
+
private avgDrawDeltaMs;
|
|
240
|
+
private boostUntil;
|
|
241
|
+
private reportedFps;
|
|
242
|
+
private reportedFrameTimeMs;
|
|
121
243
|
private elapsedSec;
|
|
122
244
|
private lastDeltaSec;
|
|
123
245
|
private currentSpeed;
|
|
@@ -131,9 +253,16 @@ declare class WebGLQuad {
|
|
|
131
253
|
private readIdx;
|
|
132
254
|
private writeIdx;
|
|
133
255
|
private feedbackScale;
|
|
256
|
+
private baseFeedbackMaxDim;
|
|
134
257
|
private feedbackMaxDim;
|
|
135
258
|
private feedbackFloat;
|
|
136
259
|
private customUniforms;
|
|
260
|
+
private textureUrls;
|
|
261
|
+
private textureUnits;
|
|
262
|
+
private loadedImages;
|
|
263
|
+
private mainTextures;
|
|
264
|
+
private textureLoadTokens;
|
|
265
|
+
private nextTextureUnit;
|
|
137
266
|
private mouse;
|
|
138
267
|
private targetMouse;
|
|
139
268
|
private mouseVel;
|
|
@@ -154,14 +283,79 @@ declare class WebGLQuad {
|
|
|
154
283
|
private isReducedMotion;
|
|
155
284
|
private respectReducedMotion;
|
|
156
285
|
private isDestroyed;
|
|
286
|
+
private wakeCallback;
|
|
287
|
+
private ambientFps;
|
|
288
|
+
private activeFps;
|
|
289
|
+
private protectionTier;
|
|
290
|
+
private isSurvivalSuspended;
|
|
291
|
+
private unsubscribeGuard;
|
|
292
|
+
private isBudgetSuspended;
|
|
293
|
+
private lastActiveAt;
|
|
294
|
+
private hasDocVisibilityListener;
|
|
157
295
|
private interactive;
|
|
158
296
|
private hasPointerListener;
|
|
159
297
|
private countedContext;
|
|
298
|
+
private isBodyMount;
|
|
299
|
+
private origBodyMinHeight;
|
|
300
|
+
private themeMode;
|
|
301
|
+
private resolvedDarkTheme;
|
|
302
|
+
private currentTheme;
|
|
303
|
+
private themeTweenRaf;
|
|
304
|
+
private colorSchemeQuery;
|
|
305
|
+
private themeMutationObserver;
|
|
306
|
+
private basePaletteRgb;
|
|
307
|
+
private activePaletteRgb;
|
|
308
|
+
private scrollStopsRgb;
|
|
309
|
+
private lastScrollColorT;
|
|
310
|
+
private hasScrollColorListener;
|
|
311
|
+
private scrollColorRaf;
|
|
312
|
+
private hasTouchListener;
|
|
313
|
+
private touchBurstTimer;
|
|
314
|
+
private touchLeaveTimer;
|
|
315
|
+
private layerMode;
|
|
316
|
+
private adaptToSurface;
|
|
317
|
+
private rawBasePaletteRgb;
|
|
318
|
+
private lastSurfaceEl;
|
|
319
|
+
private lastSurfaceKey;
|
|
320
|
+
private lastSurfaceCheckAt;
|
|
321
|
+
private isSurfaceAdapted;
|
|
160
322
|
constructor(container: HTMLElement, options: WebGLQuadOptions);
|
|
323
|
+
private boostInteraction;
|
|
324
|
+
private resetFrameTracking;
|
|
325
|
+
private resolveTierConfig;
|
|
161
326
|
private resolveDprBounds;
|
|
162
327
|
private computeScrollProgress;
|
|
163
328
|
private markContextActive;
|
|
164
329
|
private markContextReleased;
|
|
330
|
+
private uniformVec3Css;
|
|
331
|
+
private applyBudgetFallbackStyle;
|
|
332
|
+
private syncDocVisibilityListener;
|
|
333
|
+
private releaseMainThreadContext;
|
|
334
|
+
private suspendContextForBudget;
|
|
335
|
+
private restoreContextFromBudget;
|
|
336
|
+
private computeEffectiveQuality;
|
|
337
|
+
private shouldPreserveBg;
|
|
338
|
+
private applyCanvasLayerStyle;
|
|
339
|
+
private startPaletteTween;
|
|
340
|
+
private inspectSurfaceFromTarget;
|
|
341
|
+
private parseColorList;
|
|
342
|
+
private parseScrollStops;
|
|
343
|
+
private detectDarkTheme;
|
|
344
|
+
private resolveTargetPalette;
|
|
345
|
+
private toTriplet;
|
|
346
|
+
private pushUniformBatch;
|
|
347
|
+
private startThemeTransition;
|
|
348
|
+
private handleThemeChange;
|
|
349
|
+
private bindThemeWatchers;
|
|
350
|
+
private unbindThemeWatchers;
|
|
351
|
+
private updateScrollColorShift;
|
|
352
|
+
private handleScrollColorEvent;
|
|
353
|
+
private syncScrollColorListener;
|
|
354
|
+
private getLocalTouchCoords;
|
|
355
|
+
private handleTouchStart;
|
|
356
|
+
private handleTouchMove;
|
|
357
|
+
private handleTouchEnd;
|
|
358
|
+
private syncTouchListener;
|
|
165
359
|
private seedUniformsFromOptions;
|
|
166
360
|
private fallbackToMainThread;
|
|
167
361
|
private initOffscreenMode;
|
|
@@ -177,6 +371,8 @@ declare class WebGLQuad {
|
|
|
177
371
|
private bindCommonUniformsMain;
|
|
178
372
|
private drawMainThreadFrame;
|
|
179
373
|
render(_timeSec?: number, _deltaSec?: number): void;
|
|
374
|
+
private applyProtectionState;
|
|
375
|
+
private handleProtectionTierChange;
|
|
180
376
|
private syncDprBounds;
|
|
181
377
|
private handleDprChange;
|
|
182
378
|
private watchDevicePixelRatio;
|
|
@@ -184,6 +380,8 @@ declare class WebGLQuad {
|
|
|
184
380
|
private applyReducedMotionState;
|
|
185
381
|
private handleReducedMotionChange;
|
|
186
382
|
private getLocalPointerCoords;
|
|
383
|
+
private syncInteractiveAttr;
|
|
384
|
+
private isShadowedByChildInteractive;
|
|
187
385
|
private handlePointerEnter;
|
|
188
386
|
private handlePointerMove;
|
|
189
387
|
private handlePointerLeave;
|
|
@@ -196,11 +394,32 @@ declare class WebGLQuad {
|
|
|
196
394
|
private bindObservers;
|
|
197
395
|
setUniform(name: string, value: UniformValue): void;
|
|
198
396
|
setColor(uniformName: string, color: string): void;
|
|
397
|
+
get isIdle(): boolean;
|
|
398
|
+
onWake(cb: (() => void) | null): void;
|
|
199
399
|
pause(): void;
|
|
200
400
|
resume(): void;
|
|
201
401
|
destroy(): void;
|
|
402
|
+
private resolveTextureUrl;
|
|
403
|
+
private destroyMainTextures;
|
|
404
|
+
private bindMainTextures;
|
|
405
|
+
private uploadImageTexture;
|
|
406
|
+
private reuploadLoadedTextures;
|
|
407
|
+
private clearTextureSlot;
|
|
408
|
+
private syncTexturesFromOptions;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
interface WebGLEffectConfig {
|
|
412
|
+
name: string;
|
|
413
|
+
fragmentShader: string;
|
|
414
|
+
vertexShader?: string;
|
|
415
|
+
feedbackShader?: string;
|
|
416
|
+
feedbackFloat?: boolean;
|
|
417
|
+
defaultColors: [string, string, string];
|
|
418
|
+
resolveUniforms?: (options: FXOptions) => Record<string, UniformValue>;
|
|
419
|
+
resolveTextures?: (options: FXOptions) => Record<string, string>;
|
|
202
420
|
}
|
|
421
|
+
declare function createWebGLEffect(config: WebGLEffectConfig): FXPlugin;
|
|
203
422
|
|
|
204
423
|
declare const FluxFX: FluxEngine;
|
|
205
424
|
|
|
206
|
-
export { type FXInstance, type FXOptions, type FXPlugin, FluxEngine, FluxFX, WebGLQuad };
|
|
425
|
+
export { type DeviceTarget, type FXInstance, type FXOptions, type FXPlugin, FluxEngine, FluxFX, type FluxStats, type ImageFitMode, type ImagePosition, type LayerMode, type PrismShape, type QualityLevel, type ThemeMode, type WebGLEffectConfig, WebGLQuad, createWebGLEffect };
|