svader
Version: 
Create GPU-rendered Svelte components
81 lines (80 loc) • 2.81 kB
TypeScript
export default WebGpuShader;
/**
 * The commonly used parameter values that the component can pass to the shader.
 *
 * - **resolution**: A `vec2f` of the canvas width and height in physical device pixels.
 *
 * - **offset**: A `vec2f` to be added to the `@builtin(position)` of the fragment shader,
 *               to compensate for cases where the size of the canvas is capped by hardware limitations.
 *
 * - **scale**: An `f32` of the current scale factor, i.e. zoom level.
 *
 * - **time**: An `f32` of the current time in seconds.
 *             NOTE: When the `"time"` parameter is passed to the shader, it will rerender every frame.
 *             If the user agent has reduced motion enabled, the time parameter will always be equal to 0.0.
 */
export type BuiltinValue = "resolution" | "offset" | "scale" | "time";
export type BuiltinParameter = {
    label: string;
    binding: number;
    value: BuiltinValue;
    storage?: boolean;
};
export type NonBuiltinParameter = {
    label: string;
    binding: number;
    value: BufferSource;
    storage?: boolean;
};
export type Parameter = BuiltinParameter | NonBuiltinParameter;
export type GlobalConfig = {
    device: GPUDevice;
    vertexBuffer: GPUBuffer;
    vertexBufferLayout: GPUVertexBufferLayout;
};
type WebGpuShader = SvelteComponent<$$__sveltets_2_PropsWithChildren<{
    code: string | Promise<string>;
    width?: string | undefined;
    height?: string | undefined;
    forceAnimation?: boolean | undefined;
    parameters?: readonly Parameter[] | undefined;
}, {
    default: {};
}>, {
    [evt: string]: CustomEvent<any>;
}, {
    default: {};
}> & {
    $$bindings?: string | undefined;
};
declare const WebGpuShader: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
    code: string | Promise<string>;
    width?: string | undefined;
    height?: string | undefined;
    forceAnimation?: boolean | undefined;
    parameters?: readonly Parameter[] | undefined;
}, {
    default: {};
}>, {
    [evt: string]: CustomEvent<any>;
}, {
    default: {};
}, {}, string>;
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
    default: any;
} ? Props extends Record<string, never> ? any : {
    children?: any;
} : {});
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
    new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
        $$bindings?: Bindings;
    } & Exports;
    (internal: unknown, props: Props & {
        $$events?: Events;
        $$slots?: Slots;
    }): Exports & {
        $set?: any;
        $on?: any;
    };
    z_$$bindings?: Bindings;
}