shader-bg 0.0.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.
@@ -0,0 +1,11 @@
1
+ export declare class BackBufferManager {
2
+ private gl;
3
+ private canvas;
4
+ texture?: WebGLTexture;
5
+ enabled: boolean;
6
+ constructor(gl: WebGLRenderingContext, canvas: HTMLCanvasElement, enabled: boolean);
7
+ init(): void;
8
+ resize(): void;
9
+ capture(): void;
10
+ dispose(): void;
11
+ }
@@ -0,0 +1,10 @@
1
+ export declare class GlProgram {
2
+ private gl;
3
+ program: WebGLProgram;
4
+ private vertexShader;
5
+ private fragmentShader;
6
+ constructor(gl: WebGLRenderingContext, vertexSource: string, fragmentSource: string);
7
+ private compile;
8
+ use(): void;
9
+ dispose(): void;
10
+ }
@@ -0,0 +1,12 @@
1
+ export declare class Renderer {
2
+ private gl;
3
+ private program;
4
+ private rafId;
5
+ private uniformsUpdate?;
6
+ private afterRender?;
7
+ constructor(gl: WebGLRenderingContext, program: WebGLProgram, uniformsUpdate?: () => void, afterRender?: () => void);
8
+ private setupBuffer;
9
+ private render;
10
+ start(): void;
11
+ stop(): void;
12
+ }
@@ -0,0 +1,8 @@
1
+ export declare class ResizeManager {
2
+ private canvas;
3
+ private static observer;
4
+ private static readonly observerMap;
5
+ constructor(canvas: HTMLCanvasElement, onResize: () => void);
6
+ private static init;
7
+ dispose(): void;
8
+ }
@@ -0,0 +1,26 @@
1
+ import { Target } from './utils/Target.ts';
2
+ import { OptionsInput } from './utils/Options.ts';
3
+ import { GlProgram } from './GlProgram.ts';
4
+ import { UniformManager } from './UniformManager.ts';
5
+ import { Renderer } from './Renderer.ts';
6
+ export declare class ShaderBg {
7
+ canvas: HTMLCanvasElement;
8
+ private ownsCanvas;
9
+ private options;
10
+ private gl;
11
+ program: GlProgram;
12
+ uniforms: UniformManager;
13
+ renderer: Renderer;
14
+ private resizeManager;
15
+ private backBufferManager;
16
+ private mousePos;
17
+ private startTime;
18
+ private setup_canvas;
19
+ constructor(target: Target, options: OptionsInput);
20
+ private mouse_move;
21
+ private updateCommonUniforms;
22
+ start(): void;
23
+ stop(): void;
24
+ private resize;
25
+ dispose(): void;
26
+ }
@@ -0,0 +1,15 @@
1
+ type UniformValue = number | number[] | WebGLTexture;
2
+ export declare class UniformManager {
3
+ private gl;
4
+ private program;
5
+ private locations;
6
+ private textureUnits;
7
+ private nextTextureUnit;
8
+ private readonly maxTextureUnits;
9
+ constructor(gl: WebGLRenderingContext, program: WebGLProgram);
10
+ private getTextureUnit;
11
+ private getLocation;
12
+ set(name: string, value: UniformValue): void;
13
+ clear(): void;
14
+ }
15
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
@@ -0,0 +1,33 @@
1
+ export type UniformValue = number | number[] | WebGLTexture;
2
+ export type UniformValueSetter = UniformValue | (() => UniformValue);
3
+ export interface BackbufferOptionsInput {
4
+ enabled?: boolean;
5
+ uniformName?: string;
6
+ }
7
+ export interface OptionsInput {
8
+ vertexShader?: string;
9
+ fragmentShader?: string;
10
+ canvas?: {
11
+ class?: string;
12
+ id?: string;
13
+ style?: Partial<CSSStyleDeclaration>;
14
+ };
15
+ uniforms?: Record<string, UniformValueSetter>;
16
+ backbuffer?: boolean | BackbufferOptionsInput;
17
+ }
18
+ export interface Options {
19
+ vertexShader: string;
20
+ fragmentShader: string;
21
+ canvas: {
22
+ class: string;
23
+ id?: string;
24
+ style: CSSStyleDeclaration;
25
+ };
26
+ uniforms: Record<string, UniformValueSetter>;
27
+ backbuffer: {
28
+ enabled: boolean;
29
+ uniformName: string;
30
+ };
31
+ }
32
+ export declare const DEFAULT_OPTIONS: Options;
33
+ export declare function mergeOptions(options?: OptionsInput): Options;
@@ -0,0 +1,2 @@
1
+ export type Target = string | HTMLElement | Element;
2
+ export declare function GetTarget(target: Target): HTMLElement;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "shader-bg",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "main": "./dist/shader-bg.cjs",
6
+ "module": "./dist/shader-bg.js",
7
+ "types": "./dist/shader-bg.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/shader-bg.js",
11
+ "require": "./dist/shader-bg.cjs",
12
+ "types": "./dist/shader-bg.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "sideEffects": false,
19
+ "keywords": [
20
+ "shader",
21
+ "background",
22
+ "webgl",
23
+ "canvas",
24
+ "animation"
25
+ ],
26
+ "author": "ProductionPanic",
27
+ "license": "MIT",
28
+ "devDependencies": {
29
+ "@types/node": "^25.5.0",
30
+ "typescript": "~5.9.3",
31
+ "vite": "^8.0.1",
32
+ "vite-plugin-dts": "^4.5.4"
33
+ },
34
+ "scripts": {
35
+ "dev": "vite",
36
+ "build": "tsc && vite build"
37
+ }
38
+ }