shaderpad 1.0.0-beta.76 → 1.0.0-beta.77
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/dev/react.js +3 -1
- package/dist/dev/react.js.map +1 -1
- package/dist/dev/react.mjs +3 -1
- package/dist/dev/react.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +4 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +2 -2
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dev/react.js
CHANGED
|
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/react.tsx
|
|
22
22
|
var react_exports = {};
|
|
23
23
|
__export(react_exports, {
|
|
24
|
-
ShaderPad: () => ShaderPad2
|
|
24
|
+
ShaderPad: () => ShaderPad2,
|
|
25
|
+
default: () => react_default
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(react_exports);
|
|
27
28
|
var import_react = require("react");
|
|
@@ -1581,6 +1582,7 @@ var ShaderPad2 = (0, import_react.forwardRef)(function ShaderPad3({
|
|
|
1581
1582
|
);
|
|
1582
1583
|
});
|
|
1583
1584
|
ShaderPad2.displayName = "ShaderPad";
|
|
1585
|
+
var react_default = ShaderPad2;
|
|
1584
1586
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1585
1587
|
0 && (module.exports = {
|
|
1586
1588
|
ShaderPad
|
package/dist/dev/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react.tsx","../../src/internal/error-codes.gen.ts","../../src/internal/error-codes.dev.gen.ts","../../src/internal/util.ts","../../src/index.ts","../../src/plugins/autosize.ts"],"sourcesContent":["'use client';\n\nimport {\n\ttype ComponentPropsWithoutRef,\n\tforwardRef,\n\ttype RefObject,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\n\nimport CoreShaderPad, { type Options, type Plugin, type StepOptions } from '.';\nimport autosizePlugin, { type AutosizeOptions } from './plugins/autosize';\n\ntype CursorTarget = Window | Element | RefObject<Element | null>;\ntype EventMap = Partial<Record<string, (...args: any[]) => void>>;\n\ntype ShaderPadHandle = {\n\treadonly shader: CoreShaderPad | null;\n\treadonly canvas: HTMLCanvasElement | null;\n\tplay(): void;\n\tpause(): void;\n\tstep(options?: StepOptions): void;\n\tdraw(options?: StepOptions): void;\n\tclear(): void;\n\tresetFrame(): void;\n\treset(): void;\n\tdestroy(): void;\n};\n\nexport interface ShaderPadProps extends Omit<ComponentPropsWithoutRef<'canvas'>, 'children' | 'onError'> {\n\tshader: string;\n\tplugins?: Plugin[];\n\toptions?: Omit<Options, 'canvas' | 'plugins' | 'cursorTarget'>;\n\tautosize?: boolean | AutosizeOptions;\n\tcursorTarget?: CursorTarget;\n\tautoPlay?: boolean;\n\tpauseWhenOffscreen?: boolean;\n\tonInit?: (shader: CoreShaderPad, canvas: HTMLCanvasElement) => void;\n\tonBeforeStep?: (shader: CoreShaderPad, time: number, frame: number) => StepOptions | void;\n\tonError?: (error: unknown) => void;\n\tonOnscreenChange?: (isOnscreen: boolean) => void;\n\tevents?: EventMap;\n}\n\nfunction isRefTarget(target: CursorTarget | undefined): target is RefObject<Element | null> {\n\treturn Boolean(target && typeof target === 'object' && 'current' in target);\n}\n\nfunction resolveCursorTarget(target: CursorTarget | undefined) {\n\tif (isRefTarget(target)) {\n\t\treturn target.current ?? undefined;\n\t}\n\n\treturn target;\n}\n\nfunction isElementInViewport(element: HTMLElement) {\n\tconst rect = element.getBoundingClientRect();\n\treturn (\n\t\trect.width > 0 &&\n\t\trect.height > 0 &&\n\t\trect.bottom > 0 &&\n\t\trect.right > 0 &&\n\t\trect.top < window.innerHeight &&\n\t\trect.left < window.innerWidth\n\t);\n}\n\nfunction isElementRenderable(element: HTMLElement) {\n\tif (typeof element.checkVisibility === 'function') {\n\t\treturn element.checkVisibility({\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tcheckOpacity: true,\n\t\t\tcheckVisibilityCSS: true,\n\t\t});\n\t}\n\n\tconst style = window.getComputedStyle(element);\n\tconst rect = element.getBoundingClientRect();\n\treturn (\n\t\trect.width > 0 &&\n\t\trect.height > 0 &&\n\t\tstyle.display !== 'none' &&\n\t\tstyle.visibility !== 'hidden' &&\n\t\tstyle.opacity !== '0'\n\t);\n}\n\nexport const ShaderPad = forwardRef<ShaderPadHandle, ShaderPadProps>(function ShaderPad(\n\t{\n\t\tshader,\n\t\tplugins,\n\t\toptions,\n\t\tautosize = true,\n\t\tcursorTarget,\n\t\tautoPlay = true,\n\t\tpauseWhenOffscreen = true,\n\t\tonInit,\n\t\tonBeforeStep,\n\t\tonError,\n\t\tonOnscreenChange,\n\t\tevents,\n\t\tstyle,\n\t\t...canvasProps\n\t},\n\tref,\n) {\n\tconst canvasRef = useRef<HTMLCanvasElement>(null);\n\tconst shaderRef = useRef<CoreShaderPad | null>(null);\n\tconst destroyedShadersRef = useRef(new WeakSet<CoreShaderPad>());\n\tconst eventSubscriptionsRef = useRef<{\n\t\tshader: CoreShaderPad | null;\n\t\tlisteners: Map<string, (...args: any[]) => void>;\n\t}>({\n\t\tshader: null,\n\t\tlisteners: new Map(),\n\t});\n\tconst syncPlaybackRef = useRef<(() => void) | null>(null);\n\tconst onInitRef = useRef(onInit);\n\tconst onBeforeStepRef = useRef(onBeforeStep);\n\tconst onErrorRef = useRef(onError);\n\tconst onOnscreenChangeRef = useRef(onOnscreenChange);\n\tconst eventsRef = useRef(events);\n\tconst autoPlayRef = useRef(autoPlay);\n\tconst pauseWhenOffscreenRef = useRef(pauseWhenOffscreen);\n\tconst [cursorTargetVersion, setCursorTargetVersion] = useState(0);\n\n\tonInitRef.current = onInit;\n\tonBeforeStepRef.current = onBeforeStep;\n\tonErrorRef.current = onError;\n\tonOnscreenChangeRef.current = onOnscreenChange;\n\teventsRef.current = events;\n\tautoPlayRef.current = autoPlay;\n\tpauseWhenOffscreenRef.current = pauseWhenOffscreen;\n\n\tfunction clearEventSubscriptions(shader?: CoreShaderPad | null) {\n\t\tconst store = eventSubscriptionsRef.current;\n\t\tconst activeShader = shader ?? store.shader;\n\t\tif (!activeShader) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [name, listener] of store.listeners) {\n\t\t\tactiveShader.off(name as any, listener);\n\t\t}\n\n\t\tstore.listeners.clear();\n\t\tif (!shader || store.shader === shader) {\n\t\t\tstore.shader = null;\n\t\t}\n\t}\n\n\tfunction syncEventSubscriptions(shader: CoreShaderPad | null) {\n\t\tconst store = eventSubscriptionsRef.current;\n\t\tif (store.shader && store.shader !== shader) {\n\t\t\tclearEventSubscriptions(store.shader);\n\t\t}\n\t\tif (!shader) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entries = Object.entries(eventsRef.current ?? {}).filter(([, handler]) => typeof handler === 'function');\n\t\tconst nextKeys = new Set(entries.map(([name]) => name));\n\n\t\tfor (const [name, listener] of store.listeners) {\n\t\t\tif (!nextKeys.has(name)) {\n\t\t\t\tshader.off(name as any, listener);\n\t\t\t\tstore.listeners.delete(name);\n\t\t\t}\n\t\t}\n\n\t\tfor (const [name] of entries) {\n\t\t\tif (store.listeners.has(name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst listener = (...args: any[]) => {\n\t\t\t\tconst handler = eventsRef.current?.[name];\n\t\t\t\tif (typeof handler === 'function') {\n\t\t\t\t\thandler(...args);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tshader.on(name as any, listener);\n\t\t\tstore.listeners.set(name, listener);\n\t\t}\n\n\t\tstore.shader = shader;\n\t}\n\n\tfunction destroyShader(shader: CoreShaderPad | null) {\n\t\tif (!shader || destroyedShadersRef.current.has(shader)) {\n\t\t\treturn;\n\t\t}\n\n\t\tdestroyedShadersRef.current.add(shader);\n\t\tclearEventSubscriptions(shader);\n\t\tif (shaderRef.current === shader) {\n\t\t\tshaderRef.current = null;\n\t\t\tsyncPlaybackRef.current = null;\n\t\t}\n\t\tshader.destroy();\n\t}\n\n\tfunction playShader(shader: CoreShaderPad) {\n\t\tshader.play((time, frame) => onBeforeStepRef.current?.(shader, time, frame));\n\t}\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\tget shader() {\n\t\t\t\treturn shaderRef.current;\n\t\t\t},\n\t\t\tget canvas() {\n\t\t\t\treturn canvasRef.current;\n\t\t\t},\n\t\t\tplay() {\n\t\t\t\tconst shader = shaderRef.current;\n\t\t\t\tif (shader) {\n\t\t\t\t\tplayShader(shader);\n\t\t\t\t}\n\t\t\t},\n\t\t\tpause() {\n\t\t\t\tshaderRef.current?.pause();\n\t\t\t},\n\t\t\tstep(stepOptions) {\n\t\t\t\tshaderRef.current?.step(stepOptions);\n\t\t\t},\n\t\t\tdraw(stepOptions) {\n\t\t\t\tshaderRef.current?.draw(stepOptions);\n\t\t\t},\n\t\t\tclear() {\n\t\t\t\tshaderRef.current?.clear();\n\t\t\t},\n\t\t\tresetFrame() {\n\t\t\t\tshaderRef.current?.resetFrame();\n\t\t\t},\n\t\t\treset() {\n\t\t\t\tshaderRef.current?.reset();\n\t\t\t},\n\t\t\tdestroy() {\n\t\t\t\tdestroyShader(shaderRef.current);\n\t\t\t},\n\t\t}),\n\t\t[],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!isRefTarget(cursorTarget) || cursorTarget.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet frameId: number | null = null;\n\t\tlet isDisposed = false;\n\n\t\tconst poll = () => {\n\t\t\tif (isDisposed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (cursorTarget.current) {\n\t\t\t\tsetCursorTargetVersion(version => version + 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tframeId = requestAnimationFrame(poll);\n\t\t};\n\n\t\tframeId = requestAnimationFrame(poll);\n\n\t\treturn () => {\n\t\t\tisDisposed = true;\n\t\t\tif (frameId !== null) {\n\t\t\t\tcancelAnimationFrame(frameId);\n\t\t\t}\n\t\t};\n\t}, [cursorTarget]);\n\n\tuseEffect(() => {\n\t\tconst canvas = canvasRef.current;\n\t\tif (!canvas) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resolvedCursorTarget = resolveCursorTarget(cursorTarget);\n\t\tif (isRefTarget(cursorTarget) && !resolvedCursorTarget) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst installedPlugins =\n\t\t\tautosize === false\n\t\t\t\t? [...(plugins ?? [])]\n\t\t\t\t: [autosizePlugin(autosize === true ? undefined : autosize), ...(plugins ?? [])];\n\n\t\tlet instance: CoreShaderPad | null = null;\n\t\tlet isDisposed = false;\n\t\tlet isDocumentVisible = document.visibilityState === 'visible';\n\t\tlet isIntersecting = isElementInViewport(canvas);\n\t\tlet lastOnscreen: boolean | null = null;\n\t\tlet isPlaying = false;\n\t\tlet isManagedPlayback = false;\n\n\t\tconst handlePlay = () => {\n\t\t\tisPlaying = true;\n\t\t};\n\t\tconst handlePause = () => {\n\t\t\tisPlaying = false;\n\t\t};\n\n\t\tconst handleVisibilityChange = () => {\n\t\t\tisDocumentVisible = document.visibilityState === 'visible';\n\t\t\tsyncPlayback();\n\t\t};\n\n\t\tconst syncPlayback = () => {\n\t\t\tif (!instance || isDisposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isOnscreen = isDocumentVisible && isIntersecting && isElementRenderable(canvas) && canvas.isConnected;\n\n\t\t\tif (lastOnscreen !== isOnscreen) {\n\t\t\t\tlastOnscreen = isOnscreen;\n\t\t\t\tonOnscreenChangeRef.current?.(isOnscreen);\n\t\t\t}\n\n\t\t\tif (!autoPlayRef.current) {\n\t\t\t\tif (isManagedPlayback && isPlaying) {\n\t\t\t\t\tinstance.pause();\n\t\t\t\t}\n\t\t\t\tisManagedPlayback = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!pauseWhenOffscreenRef.current) {\n\t\t\t\tif (!isPlaying) {\n\t\t\t\t\tplayShader(instance);\n\t\t\t\t}\n\t\t\t\tisManagedPlayback = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isOnscreen) {\n\t\t\t\tif (!isPlaying) {\n\t\t\t\t\tplayShader(instance);\n\t\t\t\t}\n\t\t\t\tisManagedPlayback = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isPlaying) {\n\t\t\t\tinstance.pause();\n\t\t\t}\n\t\t\tisManagedPlayback = false;\n\t\t};\n\n\t\tconst intersectionObserver =\n\t\t\ttypeof IntersectionObserver === 'function'\n\t\t\t\t? new IntersectionObserver(\n\t\t\t\t\t\tentries => {\n\t\t\t\t\t\t\tisIntersecting = entries.some(entry => entry.isIntersecting && entry.intersectionRatio > 0);\n\t\t\t\t\t\t\tsyncPlayback();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ threshold: 0.01 },\n\t\t\t\t\t)\n\t\t\t\t: null;\n\n\t\ttry {\n\t\t\tinstance = new CoreShaderPad(shader, {\n\t\t\t\t...options,\n\t\t\t\tcanvas,\n\t\t\t\tplugins: installedPlugins,\n\t\t\t\t...(resolvedCursorTarget ? { cursorTarget: resolvedCursorTarget } : {}),\n\t\t\t});\n\t\t\tinstance.on('play', handlePlay);\n\t\t\tinstance.on('pause', handlePause);\n\t\t\tshaderRef.current = instance;\n\t\t\tsyncEventSubscriptions(instance);\n\t\t\tonInitRef.current?.(instance, canvas);\n\n\t\t\tintersectionObserver?.observe(canvas);\n\t\t\tdocument.addEventListener('visibilitychange', handleVisibilityChange);\n\t\t\tsyncPlaybackRef.current = syncPlayback;\n\t\t\tsyncPlayback();\n\t\t} catch (error) {\n\t\t\tintersectionObserver?.disconnect();\n\t\t\tdocument.removeEventListener('visibilitychange', handleVisibilityChange);\n\t\t\tif (instance) {\n\t\t\t\tinstance.off('play', handlePlay);\n\t\t\t\tinstance.off('pause', handlePause);\n\t\t\t}\n\t\t\tdestroyShader(instance);\n\t\t\tif (onErrorRef.current) {\n\t\t\t\tonErrorRef.current(error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn () => {\n\t\t\tisDisposed = true;\n\t\t\tintersectionObserver?.disconnect();\n\t\t\tdocument.removeEventListener('visibilitychange', handleVisibilityChange);\n\t\t\tif (instance) {\n\t\t\t\tinstance.off('play', handlePlay);\n\t\t\t\tinstance.off('pause', handlePause);\n\t\t\t}\n\t\t\tdestroyShader(instance);\n\t\t};\n\t}, [shader, plugins, options, autosize, cursorTarget, cursorTargetVersion]);\n\n\tuseEffect(() => {\n\t\tsyncEventSubscriptions(shaderRef.current);\n\t}, [\n\t\tObject.keys(events ?? {})\n\t\t\t.sort()\n\t\t\t.join('\\n'),\n\t]);\n\n\tuseEffect(() => {\n\t\tsyncPlaybackRef.current?.();\n\t}, [autoPlay, pauseWhenOffscreen]);\n\n\treturn (\n\t\t<canvas\n\t\t\tref={canvasRef}\n\t\t\tstyle={{\n\t\t\t\tdisplay: 'block',\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\t...style,\n\t\t\t}}\n\t\t\t{...canvasProps}\n\t\t/>\n\t);\n});\n\nShaderPad.displayName = 'ShaderPad';\n","// Generated by scripts/generate-error-code-artifacts.mjs. Do not edit manually.\nexport type ErrorCode = number;\n\nexport const ERROR_DOCS_BASE_URL = 'https://mry.ac/s/';\n\nexport function errorUrl(code: ErrorCode) {\n\treturn `${ERROR_DOCS_BASE_URL}${code}`;\n}\n","// Generated by scripts/generate-error-code-artifacts.mjs. Do not edit manually.\nimport type { ErrorCode } from './error-codes.gen.js';\n\ntype DevErrorDetails = {\n\ttitle: string;\n\tsummary: string;\n};\n\nexport const DEV_ERRORS: Record<ErrorCode, DevErrorDetails> | undefined = __SHADERPAD_DEV__\n\t? {\n\t\t\t'0': {\n\t\t\t\ttitle: 'WebGL2 Context Unavailable',\n\t\t\t\tsummary: 'ShaderPad could not create a WebGL2 rendering context.',\n\t\t\t},\n\t\t\t'1': {\n\t\t\t\ttitle: 'Program Allocation Failed',\n\t\t\t\tsummary: 'ShaderPad could not allocate a WebGL program object.',\n\t\t\t},\n\t\t\t'2': {\n\t\t\t\ttitle: 'Program Link Failed',\n\t\t\t\tsummary: 'ShaderPad compiled the shaders but failed to link them into a WebGL program.',\n\t\t\t},\n\t\t\t'3': {\n\t\t\t\ttitle: 'Unknown GL Constant',\n\t\t\t\tsummary: 'ShaderPad received a WebGL constant name it does not recognize.',\n\t\t\t},\n\t\t\t'4': {\n\t\t\t\ttitle: 'Shader Compilation Failed',\n\t\t\t\tsummary: 'A vertex or fragment shader failed to compile.',\n\t\t\t},\n\t\t\t'5': {\n\t\t\t\ttitle: 'Texture Units Exhausted',\n\t\t\t\tsummary: 'ShaderPad tried to reserve more texture units than this device exposes.',\n\t\t\t},\n\t\t\t'6': {\n\t\t\t\ttitle: 'Float Color Buffer Extension Missing',\n\t\t\t\tsummary: 'ShaderPad requested a float render texture, but EXT_color_buffer_float is unavailable.',\n\t\t\t},\n\t\t\t'7': {\n\t\t\t\ttitle: 'Uniform Already Initialized',\n\t\t\t\tsummary: 'ShaderPad was asked to register a uniform name that was already registered.',\n\t\t\t},\n\t\t\t'8': {\n\t\t\t\ttitle: 'Invalid Uniform Type',\n\t\t\t\tsummary: 'ShaderPad received an unsupported uniform type string.',\n\t\t\t},\n\t\t\t'9': {\n\t\t\t\ttitle: 'Uniform Array Length Mismatch',\n\t\t\t\tsummary: 'ShaderPad was asked to initialize a uniform array with the wrong number of elements.',\n\t\t\t},\n\t\t\t'10': {\n\t\t\t\ttitle: 'Uniform Array Update Expected An Array',\n\t\t\t\tsummary: 'ShaderPad attempted to update a uniform array, but the provided value was not an array.',\n\t\t\t},\n\t\t\t'11': {\n\t\t\t\ttitle: 'Uniform Array Update Too Large',\n\t\t\t\tsummary: 'ShaderPad received more uniform array elements than the initialized array can hold.',\n\t\t\t},\n\t\t\t'12': {\n\t\t\t\ttitle: 'Uniform Array Element Size Mismatch',\n\t\t\t\tsummary: 'At least one uniform array element has the wrong scalar or vector length.',\n\t\t\t},\n\t\t\t'13': {\n\t\t\t\ttitle: 'Uniform Array Start Index Invalid',\n\t\t\t\tsummary: 'ShaderPad could not find the requested starting index for a uniform array.',\n\t\t\t},\n\t\t\t'14': {\n\t\t\t\ttitle: 'Uniform Value Length Invalid',\n\t\t\t\tsummary: 'ShaderPad received a scalar or vector uniform update with the wrong component count.',\n\t\t\t},\n\t\t\t'15': {\n\t\t\t\ttitle: 'Texture Allocation Failed',\n\t\t\t\tsummary: 'ShaderPad could not create a WebGL texture object.',\n\t\t\t},\n\t\t\t'16': {\n\t\t\t\ttitle: 'Texture Already Initialized',\n\t\t\t\tsummary: 'ShaderPad was asked to initialize a texture name that is already registered.',\n\t\t\t},\n\t\t\t'17': {\n\t\t\t\ttitle: 'Texture Source Dimensions Invalid',\n\t\t\t\tsummary: 'ShaderPad could not determine valid width and height values for the texture source.',\n\t\t\t},\n\t\t\t'18': {\n\t\t\t\ttitle: 'Texture Not Initialized',\n\t\t\t\tsummary: 'ShaderPad was asked to update a texture name that has not been initialized.',\n\t\t\t},\n\t\t\t'19': {\n\t\t\t\ttitle: 'Uniform Missing During Initialization',\n\t\t\t\tsummary:\n\t\t\t\t\t'ShaderPad could not initialize a uniform because the shader program does not contain that symbol.',\n\t\t\t},\n\t\t\t'20': {\n\t\t\t\ttitle: 'Uniform Missing During Update',\n\t\t\t\tsummary:\n\t\t\t\t\t'ShaderPad could not update a uniform because the shader program does not contain that symbol.',\n\t\t\t},\n\t\t\t'60': {\n\t\t\t\ttitle: 'Face Mask Renderer Context Unavailable',\n\t\t\t\tsummary: 'The face plugin could not create the offscreen WebGL2 context used for face-mask rendering.',\n\t\t\t},\n\t\t\t'61': {\n\t\t\t\ttitle: 'Face Mask Shader Setup Failed',\n\t\t\t\tsummary: 'The face plugin could not build the shaders it uses for face-mask rendering.',\n\t\t\t},\n\t\t\t'62': {\n\t\t\t\ttitle: 'Face Mask Renderer Initialization Failed',\n\t\t\t\tsummary: 'The face plugin could not finish setting up its internal face-mask renderer.',\n\t\t\t},\n\t\t}\n\t: undefined;\n","import { errorUrl, type ErrorCode } from './error-codes.gen.js';\nimport { DEV_ERRORS } from './error-codes.dev.gen.js';\n\ntype DevContext = Record<string, unknown> | false | undefined;\ntype ShaderPadError = Error & { code: ErrorCode };\n\nfunction withCode(message: string, code: ErrorCode): ShaderPadError {\n\tconst error = new Error(message) as ShaderPadError;\n\terror.code = code;\n\treturn error;\n}\n\nfunction renderContext(context: Record<string, unknown>) {\n\tconst lines = ['Context:'];\n\n\tfor (const [key, value] of Object.entries(context)) {\n\t\tif (value === undefined) continue;\n\n\t\tconst rendered =\n\t\t\ttypeof value === 'string'\n\t\t\t\t? value\n\t\t\t\t: (JSON.stringify(value, null, 2) ??\n\t\t\t\t\t(typeof value === 'bigint' ||\n\t\t\t\t\ttypeof value === 'number' ||\n\t\t\t\t\ttypeof value === 'boolean' ||\n\t\t\t\t\tvalue == null\n\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t: ''));\n\n\t\tif (!rendered) continue;\n\t\tlines.push(rendered.includes('\\n') ? `${key}:\\n${rendered}` : `${key}: ${rendered}`);\n\t}\n\n\treturn lines.length > 1 ? lines.join('\\n') : '';\n}\n\nfunction renderDevMessage(code: ErrorCode, context?: DevContext) {\n\tconst error = DEV_ERRORS?.[code];\n\tconst parts = error\n\t\t? [`[ShaderPad ${code}] ${error.title}`, error.summary, `Docs: ${errorUrl(code)}`]\n\t\t: [`[ShaderPad ${code}] ${errorUrl(code)}`];\n\n\tif (context) {\n\t\tconst renderedContext = renderContext(context);\n\t\tif (renderedContext) parts.push(renderedContext);\n\t}\n\n\treturn parts.join('\\n\\n');\n}\n\nexport function spError(code: ErrorCode, context?: DevContext) {\n\treturn withCode(__SHADERPAD_DEV__ ? renderDevMessage(code, context) : `ShaderPad error: ${errorUrl(code)}`, code);\n}\n\nexport function safeMod(i: number, m: number): number {\n\treturn ((i % m) + m) % m;\n}\n","import { spError, safeMod } from './internal/util';\n\nconst DEFAULT_VERTEX_SHADER_SRC = `#version 300 es\nin vec2 a_position;\nout vec2 v_uv;\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_uv = a_position * 0.5 + 0.5;\n}`;\n\ninterface Uniform {\n\ttype: 'float' | 'int' | 'uint';\n\tlength: 1 | 2 | 3 | 4;\n\tlocation: WebGLUniformLocation;\n\tarrayLength?: number;\n}\n\ntype GLInternalFormatChannels = 'R' | 'RG' | 'RGB' | 'RGBA';\ntype GLInternalFormatDepth = '8' | '16F' | '32F' | '8UI' | '8I' | '16UI' | '16I' | '32UI' | '32I';\nexport type GLInternalFormatString = `${GLInternalFormatChannels}${GLInternalFormatDepth}`;\n\nexport type GLFormatString =\n\t| 'RED'\n\t| 'RG'\n\t| 'RGB'\n\t| 'RGBA'\n\t| 'RED_INTEGER'\n\t| 'RG_INTEGER'\n\t| 'RGB_INTEGER'\n\t| 'RGBA_INTEGER';\nexport type GLTypeString =\n\t| 'UNSIGNED_BYTE'\n\t| 'BYTE'\n\t| 'FLOAT'\n\t| 'HALF_FLOAT'\n\t| 'UNSIGNED_SHORT'\n\t| 'SHORT'\n\t| 'UNSIGNED_INT'\n\t| 'INT';\nexport type GLFilterString = 'LINEAR' | 'NEAREST';\nexport type GLWrapString = 'CLAMP_TO_EDGE' | 'REPEAT' | 'MIRRORED_REPEAT';\n\nconst FORMAT_TYPE_SUFFIXES: [string, GLTypeString][] = [\n\t['8UI', 'UNSIGNED_BYTE'],\n\t['8I', 'BYTE'],\n\t['16UI', 'UNSIGNED_SHORT'],\n\t['16I', 'SHORT'],\n\t['16F', 'HALF_FLOAT'],\n\t['32UI', 'UNSIGNED_INT'],\n\t['32I', 'INT'],\n\t['32F', 'FLOAT'],\n\t['8', 'UNSIGNED_BYTE'],\n];\n\nconst UNIFORM_TYPE_SUFFIXES: Record<Uniform['type'], string> = {\n\tfloat: 'f',\n\tint: 'i',\n\tuint: 'ui',\n};\n\nfunction typeFromInternalFormatString(internalFormatString?: GLInternalFormatString): GLTypeString | undefined {\n\treturn internalFormatString && FORMAT_TYPE_SUFFIXES.find(([suffix]) => internalFormatString.endsWith(suffix))?.[1];\n}\n\ntype GLConstantString = GLInternalFormatString | GLFormatString | GLTypeString | GLFilterString | GLWrapString;\n\nexport interface TextureOptions {\n\tinternalFormat?: GLInternalFormatString;\n\tformat?: GLFormatString;\n\ttype?: GLTypeString;\n\tminFilter?: GLFilterString;\n\tmagFilter?: GLFilterString;\n\twrapS?: GLWrapString;\n\twrapT?: GLWrapString;\n\tpreserveY?: boolean;\n}\ntype ResolvedTextureOptions = {\n\ttype: number;\n\tformat: number;\n\tinternalFormat: number;\n\tminFilter: number;\n\tmagFilter: number;\n\twrapS: number;\n\twrapT: number;\n\tpreserveY?: boolean;\n\tisIntegerColorFormat: boolean;\n};\n\ninterface Texture {\n\ttexture: WebGLTexture;\n\tunitIndex: number;\n\twidth: number;\n\theight: number;\n\thistory?: {\n\t\tdepth: number;\n\t\twriteIndex: number;\n\t};\n\toptions: ResolvedTextureOptions;\n}\n\nexport interface CustomTexture {\n\tdata: ArrayBufferView | null;\n\twidth: number;\n\theight: number;\n}\n\nexport interface PartialCustomTexture extends CustomTexture {\n\tisPartial?: boolean;\n\tx?: number;\n\ty?: number;\n}\n\nexport interface InitializeTextureOptions extends TextureOptions {\n\thistory?: number;\n}\n\nexport type TextureSource =\n\t| HTMLImageElement\n\t| HTMLVideoElement\n\t| HTMLCanvasElement\n\t| OffscreenCanvas\n\t| ImageBitmap\n\t| WebGLTexture\n\t| CustomTexture\n\t| ShaderPad;\n\n// Custom textures allow partial updates starting from (x, y).\nexport type UpdateTextureSource = Exclude<TextureSource, CustomTexture> | PartialCustomTexture;\n\nexport interface PluginContext {\n\tinjectGLSL: (code: string) => void;\n\temit: (name: ShaderPadEventName, ...args: any[]) => void;\n\tupdateTexture: (name: string, source: UpdateTextureSource, historySlots?: HistorySlots) => void;\n}\n\nexport type Plugin = (shaderPad: ShaderPad, context: PluginContext) => void;\n\nexport type ShaderPadEventName =\n\t| '_init'\n\t| 'initializeTexture'\n\t| 'initializeUniform'\n\t| 'updateTextures'\n\t| 'updateUniforms'\n\t| 'beforeStep'\n\t| 'afterStep'\n\t| 'beforeDraw'\n\t| 'afterDraw'\n\t| 'updateResolution'\n\t| 'play'\n\t| 'pause'\n\t| 'reset'\n\t| 'destroy'\n\t| `${string}:${string}`;\n\nexport type RenderTextureOptions = Omit<TextureOptions, 'preserveY'>;\n\nexport interface Options extends RenderTextureOptions {\n\tcanvas?: HTMLCanvasElement | OffscreenCanvas | { width: number; height: number } | null;\n\tplugins?: Plugin[];\n\thistory?: number;\n\tcursorTarget?: Window | Element;\n}\n\nexport interface StepOptions {\n\tskipClear?: boolean;\n\tskipHistory?: boolean;\n}\n\ntype HistorySlots = number | number[];\n\ntype TextureUnitPool = {\n\tfree: number[];\n\tnext: number;\n\tmax: number;\n};\n\nconst HISTORY_TEXTURE_KEY = Symbol('u_history');\nconst INTERMEDIATE_TEXTURE_KEY = Symbol('__SHADERPAD_BUFFER');\n\nconst canvasRegistry = new WeakMap<\n\tHTMLCanvasElement | OffscreenCanvas,\n\t{ textureUnitPool: TextureUnitPool; instances: Set<ShaderPad> }\n>();\n\nfunction combineShaderCode(shader: string, injections: string[]): string {\n\tif (!injections?.length) return shader;\n\tconst lines = shader.split('\\n');\n\tconst insertAt =\n\t\tlines.findLastIndex(line => {\n\t\t\tconst trimmed = line.trimStart();\n\t\t\treturn trimmed.startsWith('precision ') || trimmed.startsWith('#version ');\n\t\t}) + 1;\n\tlines.splice(insertAt, 0, ...injections);\n\treturn lines.join('\\n');\n}\n\nfunction getSourceDimensions(source: TextureSource): {\n\twidth: number;\n\theight: number;\n} {\n\tif (source instanceof WebGLTexture) {\n\t\treturn { width: 0, height: 0 }; // Invalid - dimensions not readable.\n\t}\n\tif (source instanceof ShaderPad) {\n\t\treturn { width: source.canvas.width, height: source.canvas.height };\n\t}\n\tif (source instanceof HTMLVideoElement) {\n\t\treturn { width: source.videoWidth, height: source.videoHeight };\n\t}\n\tif (source instanceof HTMLImageElement) {\n\t\treturn {\n\t\t\twidth: source.naturalWidth ?? source.width,\n\t\t\theight: source.naturalHeight ?? source.height,\n\t\t};\n\t}\n\t// CustomTexture, HTMLCanvasElement, OffscreenCanvas, ImageBitmap.\n\treturn { width: source.width, height: source.height };\n}\n\nfunction stringFrom(name: string | symbol) {\n\treturn typeof name === 'symbol' ? (name.description ?? '') : name;\n}\n\nclass ShaderPad {\n\tprivate isHeadless = false;\n\tprivate isTouchDevice = false;\n\tpublic readonly gl: WebGL2RenderingContext;\n\tprivate glHelpers!: {\n\t\ttypeToArray: Map<number, new (length: number) => ArrayBufferView>;\n\t\ttypeToInternalFormatString: Map<number, GLInternalFormatString>;\n\t\tunsignedIntTypes: Set<number>;\n\t};\n\tprivate uniforms: Map<string, Uniform> = new Map();\n\tprivate textures: Map<string | symbol, Texture> = new Map();\n\tprivate textureUnitPool: TextureUnitPool;\n\tprivate buffer: WebGLBuffer | null = null;\n\tprivate vao: WebGLVertexArrayObject | null = null;\n\tprivate program: WebGLProgram | null = null;\n\tprivate animationFrameId: number | null;\n\tprivate eventListeners: Map<string, EventListener> = new Map();\n\tprivate frame = 0;\n\tprivate startTime = Number.NaN;\n\tprivate isPlaying = false;\n\tprivate cursorPosition = [0.5, 0.5];\n\tprivate clickPosition = [0.5, 0.5];\n\tprivate isMouseDown = false;\n\tpublic canvas: HTMLCanvasElement | OffscreenCanvas;\n\tprivate resolutionObserver: MutationObserver | null = null;\n\tprivate hooks: Map<ShaderPadEventName, Function[]> = new Map();\n\tprivate historyDepth = 0;\n\tprivate textureOptions: TextureOptions;\n\tprivate cursorTarget: Window | Element | undefined;\n\t// WebGL can’t read from and write to the history texture at the same time.\n\t// We write to an intermediate texture then blit to the history texture.\n\tprivate intermediateFbo: WebGLFramebuffer | null = null;\n\n\tconstructor(\n\t\tfragmentShaderSrc: string,\n\t\t{ canvas, plugins, history, cursorTarget, ...textureOptions }: Options = {},\n\t) {\n\t\tif (canvas && 'getContext' in canvas) {\n\t\t\tthis.canvas = canvas;\n\t\t} else {\n\t\t\tconst { width = 1, height = 1 } = canvas || {};\n\t\t\tthis.canvas = new OffscreenCanvas(width, height);\n\t\t\tthis.isHeadless = true;\n\t\t}\n\n\t\tconst gl = this.canvas.getContext('webgl2', {\n\t\t\tantialias: false,\n\t\t}) as WebGL2RenderingContext;\n\t\tif (!gl) {\n\t\t\tthrow spError(\n\t\t\t\t0,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tcanvasType: this.canvas.constructor.name,\n\t\t\t\t\tisHeadless: this.isHeadless,\n\t\t\t\t\tcanvasWidth: this.canvas.width,\n\t\t\t\t\tcanvasHeight: this.canvas.height,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tthis.gl = gl;\n\t\tthis.glHelpers = {\n\t\t\ttypeToArray: new Map<number, new (length: number) => ArrayBufferView>([\n\t\t\t\t[gl.FLOAT, Float32Array],\n\t\t\t\t[gl.HALF_FLOAT, Uint16Array],\n\t\t\t\t[gl.UNSIGNED_SHORT, Uint16Array],\n\t\t\t\t[gl.SHORT, Int16Array],\n\t\t\t\t[gl.BYTE, Int8Array],\n\t\t\t\t[gl.UNSIGNED_INT, Uint32Array],\n\t\t\t\t[gl.INT, Int32Array],\n\t\t\t]),\n\t\t\ttypeToInternalFormatString: new Map<number, GLInternalFormatString>([\n\t\t\t\t[gl.FLOAT, 'RGBA32F'],\n\t\t\t\t[gl.HALF_FLOAT, 'RGBA16F'],\n\t\t\t\t[gl.UNSIGNED_SHORT, 'RGBA32UI'],\n\t\t\t\t[gl.SHORT, 'RGBA32I'],\n\t\t\t\t[gl.BYTE, 'RGBA32I'],\n\t\t\t\t[gl.UNSIGNED_INT, 'RGBA32UI'],\n\t\t\t\t[gl.INT, 'RGBA32I'],\n\t\t\t]),\n\t\t\tunsignedIntTypes: new Set([gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.UNSIGNED_INT]),\n\t\t};\n\n\t\tlet registryEntry = canvasRegistry.get(this.canvas);\n\t\tif (!registryEntry) {\n\t\t\tregistryEntry = {\n\t\t\t\ttextureUnitPool: {\n\t\t\t\t\tfree: [],\n\t\t\t\t\tnext: 0,\n\t\t\t\t\tmax: gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n\t\t\t\t},\n\t\t\t\tinstances: new Set([this]),\n\t\t\t};\n\t\t\tcanvasRegistry.set(this.canvas, registryEntry);\n\t\t}\n\t\tthis.textureUnitPool = registryEntry.textureUnitPool;\n\t\tregistryEntry.instances.add(this);\n\n\t\tthis.textureOptions = textureOptions;\n\n\t\tif (history) this.historyDepth = history;\n\t\tthis.cursorTarget = cursorTarget ?? (this.canvas instanceof HTMLCanvasElement ? this.canvas : undefined);\n\t\tthis.animationFrameId = null;\n\n\t\tconst glslInjections: string[] = [];\n\t\tif (plugins) {\n\t\t\tplugins.forEach(plugin =>\n\t\t\t\tplugin(this, {\n\t\t\t\t\tinjectGLSL: (code: string) => {\n\t\t\t\t\t\tglslInjections.push(code);\n\t\t\t\t\t},\n\t\t\t\t\temit: this.emit.bind(this),\n\t\t\t\t\tupdateTexture: this.updateTexture.bind(this),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst program = this.gl.createProgram();\n\t\tif (!program) {\n\t\t\tthrow spError(1);\n\t\t}\n\t\tthis.program = program;\n\n\t\tconst vertexShader = this.createShader(this.gl.VERTEX_SHADER, DEFAULT_VERTEX_SHADER_SRC);\n\t\tconst fragmentShader = this.createShader(\n\t\t\tgl.FRAGMENT_SHADER,\n\t\t\tcombineShaderCode(fragmentShaderSrc, glslInjections),\n\t\t);\n\t\tgl.attachShader(program, vertexShader);\n\t\tgl.attachShader(program, fragmentShader);\n\t\tgl.bindAttribLocation(program, 0, 'a_position');\n\t\tgl.linkProgram(program);\n\t\tgl.deleteShader(vertexShader);\n\t\tgl.deleteShader(fragmentShader);\n\n\t\tif (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n\t\t\tconst programInfoLog = gl.getProgramInfoLog(program);\n\t\t\tconst linkError = spError(\n\t\t\t\t2,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tprogramInfoLog,\n\t\t\t\t\tfragmentShaderLength: fragmentShaderSrc.length,\n\t\t\t\t\tglslInjectionCount: glslInjections.length,\n\t\t\t\t},\n\t\t\t);\n\t\t\tgl.deleteProgram(program);\n\t\t\tthrow linkError;\n\t\t}\n\n\t\tthis.vao = gl.createVertexArray();\n\t\tgl.bindVertexArray(this.vao);\n\t\tthis.buffer = gl.createBuffer();\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n\t\tgl.enableVertexAttribArray(0);\n\t\tgl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n\n\t\tgl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);\n\n\t\tgl.useProgram(program);\n\n\t\tif (this.canvas instanceof HTMLCanvasElement) {\n\t\t\tthis.resolutionObserver = new MutationObserver(() => this.syncResolution());\n\t\t\tthis.resolutionObserver.observe(this.canvas, {\n\t\t\t\tattributes: true,\n\t\t\t\tattributeFilter: ['width', 'height'],\n\t\t\t});\n\t\t} else {\n\t\t\tconst wrapDimension = (dimension: 'width' | 'height') => {\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(OffscreenCanvas.prototype, dimension)!;\n\t\t\t\tconst canvas = this.canvas;\n\t\t\t\tObject.defineProperty(canvas, dimension, {\n\t\t\t\t\tget: () => descriptor.get!.call(canvas),\n\t\t\t\t\tset: v => {\n\t\t\t\t\t\tdescriptor.set!.call(canvas, v);\n\t\t\t\t\t\tconst entry = canvasRegistry.get(canvas);\n\t\t\t\t\t\tif (entry) {\n\t\t\t\t\t\t\tfor (const instance of entry.instances) {\n\t\t\t\t\t\t\t\tinstance.syncResolution();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tconfigurable: descriptor.configurable,\n\t\t\t\t\tenumerable: descriptor.enumerable,\n\t\t\t\t});\n\t\t\t};\n\t\t\twrapDimension('width');\n\t\t\twrapDimension('height');\n\t\t}\n\t\tthis.syncResolution();\n\n\t\tthis.initializeUniform('u_cursor', 'float', this.cursorPosition, { allowMissing: true });\n\t\tthis.initializeUniform('u_click', 'float', [...this.clickPosition, this.isMouseDown ? 1.0 : 0.0], {\n\t\t\tallowMissing: true,\n\t\t});\n\t\tthis.initializeUniform('u_time', 'float', 0, { allowMissing: true });\n\t\tthis.initializeUniform('u_frame', 'int', 0, { allowMissing: true });\n\n\t\tthis._initializeTexture(INTERMEDIATE_TEXTURE_KEY, this.canvas, {\n\t\t\t...this.textureOptions,\n\t\t});\n\t\tthis.intermediateFbo = gl.createFramebuffer();\n\t\tthis.bindIntermediate();\n\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\n\t\tif (this.historyDepth > 0) {\n\t\t\tthis._initializeTexture(HISTORY_TEXTURE_KEY, this.canvas, {\n\t\t\t\thistory: this.historyDepth,\n\t\t\t\t...this.textureOptions,\n\t\t\t});\n\t\t}\n\t\tthis.addEventListeners();\n\t\tthis.emit('_init');\n\t}\n\n\tprivate resolveGLConstant(value: GLConstantString): number {\n\t\tconst resolved = this.gl[value];\n\t\tif (resolved === undefined) {\n\t\t\tthrow spError(3, __SHADERPAD_DEV__ && { value });\n\t\t}\n\t\treturn resolved;\n\t}\n\n\tprivate emit(name: ShaderPadEventName, ...args: any[]) {\n\t\tthis.hooks.get(name)?.forEach(hook => hook.call(this, ...args));\n\t}\n\n\ton(name: ShaderPadEventName, fn: Function) {\n\t\tif (!this.hooks.has(name)) {\n\t\t\tthis.hooks.set(name, []);\n\t\t}\n\t\tthis.hooks.get(name)!.push(fn);\n\t}\n\n\toff(name: ShaderPadEventName, fn: Function) {\n\t\tconst hooks = this.hooks.get(name);\n\t\tif (hooks) {\n\t\t\tconst index = hooks.indexOf(fn);\n\t\t\tif (index >= 0) {\n\t\t\t\thooks.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createShader(type: number, source: string): WebGLShader {\n\t\tconst shader = this.gl.createShader(type)!;\n\t\tthis.gl.shaderSource(shader, source);\n\t\tthis.gl.compileShader(shader);\n\t\tif (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n\t\t\tconst shaderInfoLog = this.gl.getShaderInfoLog(shader);\n\t\t\tconst shaderType = type === this.gl.VERTEX_SHADER ? 'vertex' : 'fragment';\n\t\t\tconst compilationError = spError(\n\t\t\t\t4,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tshaderType,\n\t\t\t\t\tshaderInfoLog,\n\t\t\t\t\tsource,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.gl.deleteShader(shader);\n\t\t\tthrow compilationError;\n\t\t}\n\t\treturn shader;\n\t}\n\n\tprivate getCursorTargetRect(): {\n\t\tleft: number;\n\t\ttop: number;\n\t\twidth: number;\n\t\theight: number;\n\t} {\n\t\tconst target = this.cursorTarget!;\n\t\tif (target === window) {\n\t\t\treturn {\n\t\t\t\tleft: 0,\n\t\t\t\ttop: 0,\n\t\t\t\twidth: window.innerWidth,\n\t\t\t\theight: window.innerHeight,\n\t\t\t};\n\t\t}\n\t\treturn (target as Element).getBoundingClientRect();\n\t}\n\n\tprivate addEventListeners() {\n\t\tif (!this.cursorTarget) return;\n\t\tconst updateCursor = (x: number, y: number) => {\n\t\t\tif (!this.uniforms.has('u_cursor')) return;\n\t\t\tconst rect = this.getCursorTargetRect();\n\t\t\tconst u = (x - rect.left) / rect.width;\n\t\t\tconst v = 1 - (y - rect.top) / rect.height; // Flip Y for WebGL\n\t\t\tthis.cursorPosition[0] = Math.max(0, Math.min(1, u));\n\t\t\tthis.cursorPosition[1] = Math.max(0, Math.min(1, v));\n\t\t\tthis.updateUniforms({ u_cursor: this.cursorPosition });\n\t\t};\n\n\t\tconst updateClick = (isMouseDown: boolean, x?: number, y?: number) => {\n\t\t\tif (!this.uniforms.has('u_click')) return;\n\t\t\tthis.isMouseDown = isMouseDown;\n\t\t\tif (isMouseDown) {\n\t\t\t\tconst rect = this.getCursorTargetRect();\n\t\t\t\tconst xVal = x as number;\n\t\t\t\tconst yVal = y as number;\n\t\t\t\tthis.clickPosition[0] = Math.max(0, Math.min(1, (xVal - rect.left) / rect.width));\n\t\t\t\tthis.clickPosition[1] = Math.max(0, Math.min(1, 1 - (yVal - rect.top) / rect.height)); // Flip Y for WebGL\n\t\t\t}\n\t\t\tthis.updateUniforms({\n\t\t\t\tu_click: [...this.clickPosition, this.isMouseDown ? 1.0 : 0.0],\n\t\t\t});\n\t\t};\n\n\t\tthis.eventListeners.set('mousemove', event => {\n\t\t\tconst mouseEvent = event as MouseEvent;\n\t\t\tif (!this.isTouchDevice) {\n\t\t\t\tupdateCursor(mouseEvent.clientX, mouseEvent.clientY);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('mousedown', event => {\n\t\t\tconst mouseEvent = event as MouseEvent;\n\t\t\tif (!this.isTouchDevice) {\n\t\t\t\tif (mouseEvent.button === 0) {\n\t\t\t\t\tthis.isMouseDown = true;\n\t\t\t\t\tupdateClick(true, mouseEvent.clientX, mouseEvent.clientY);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('mouseup', event => {\n\t\t\tconst mouseEvent = event as MouseEvent;\n\t\t\tif (!this.isTouchDevice) {\n\t\t\t\tif (mouseEvent.button === 0) {\n\t\t\t\t\tupdateClick(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('touchmove', event => {\n\t\t\tconst touchEvent = event as TouchEvent;\n\t\t\tif (touchEvent.touches.length > 0) {\n\t\t\t\tupdateCursor(touchEvent.touches[0].clientX, touchEvent.touches[0].clientY);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('touchstart', event => {\n\t\t\tconst touchEvent = event as TouchEvent;\n\t\t\tthis.isTouchDevice = true;\n\t\t\tif (touchEvent.touches.length > 0) {\n\t\t\t\tupdateCursor(touchEvent.touches[0].clientX, touchEvent.touches[0].clientY);\n\t\t\t\tupdateClick(true, touchEvent.touches[0].clientX, touchEvent.touches[0].clientY);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('touchend', event => {\n\t\t\tconst touchEvent = event as TouchEvent;\n\t\t\tif (touchEvent.touches.length === 0) {\n\t\t\t\tupdateClick(false);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.forEach((listener, event) => {\n\t\t\tthis.cursorTarget!.addEventListener(event, listener);\n\t\t});\n\t}\n\n\tprivate syncResolution() {\n\t\tconst resolution: [number, number] = [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n\t\tthis.gl.viewport(0, 0, ...resolution);\n\t\tif (this.uniforms.has('u_resolution')) {\n\t\t\tthis.updateUniforms({ u_resolution: resolution });\n\t\t} else {\n\t\t\tthis.initializeUniform('u_resolution', 'float', resolution, { allowMissing: true });\n\t\t}\n\t\tthis.resizeTexture(INTERMEDIATE_TEXTURE_KEY, ...resolution);\n\t\tif (this.historyDepth > 0) {\n\t\t\tthis.resizeTexture(HISTORY_TEXTURE_KEY, ...resolution);\n\t\t}\n\t\tthis.emit('updateResolution', ...resolution);\n\t}\n\n\tprivate resizeTexture(name: string | symbol, width: number, height: number) {\n\t\tconst info = this.textures.get(name);\n\t\tif (!info || (info.width === width && info.height === height)) return;\n\n\t\tthis.gl.deleteTexture(info.texture);\n\t\tinfo.width = width;\n\t\tinfo.height = height;\n\t\tconst { texture } = this.createTexture(name, info);\n\t\tinfo.texture = texture;\n\t\tthis.resetHistoryTextureState(name, info);\n\t}\n\n\tprivate reserveTextureUnit(name: string | symbol) {\n\t\tconst existing = this.textures.get(name);\n\t\tif (existing) return existing.unitIndex;\n\t\tif (this.textureUnitPool.free.length > 0) return this.textureUnitPool.free.pop()!;\n\t\tif (this.textureUnitPool.next >= this.textureUnitPool.max) {\n\t\t\tthrow spError(\n\t\t\t\t5,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname: stringFrom(name),\n\t\t\t\t\tnextTextureUnit: this.textureUnitPool.next,\n\t\t\t\t\tmaxTextureUnits: this.textureUnitPool.max,\n\t\t\t\t\tfreeTextureUnits: this.textureUnitPool.free.length,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn this.textureUnitPool.next++;\n\t}\n\n\tprivate resolveTextureOptions(options?: TextureOptions): ResolvedTextureOptions {\n\t\tconst { gl } = this;\n\t\tconst internalFormatOption = options?.internalFormat;\n\t\tconst typeString = options?.type ?? typeFromInternalFormatString(internalFormatOption) ?? 'UNSIGNED_BYTE';\n\t\tconst type = this.resolveGLConstant(typeString);\n\t\tconst internalFormatString =\n\t\t\tinternalFormatOption ?? this.glHelpers.typeToInternalFormatString.get(type) ?? 'RGBA8';\n\t\tconst isIntegerColorFormat = /^(R|RG|RGB|RGBA)(8|16|32)(UI|I)$/.test(internalFormatString);\n\t\tconst formatString = options?.format ?? (isIntegerColorFormat ? 'RGBA_INTEGER' : 'RGBA');\n\t\tconst result: ResolvedTextureOptions = {\n\t\t\ttype,\n\t\t\tformat: this.resolveGLConstant(formatString),\n\t\t\tinternalFormat: this.resolveGLConstant(internalFormatString),\n\t\t\tminFilter: this.resolveGLConstant(options?.minFilter ?? 'LINEAR'),\n\t\t\tmagFilter: this.resolveGLConstant(options?.magFilter ?? 'LINEAR'),\n\t\t\twrapS: this.resolveGLConstant(options?.wrapS ?? 'CLAMP_TO_EDGE'),\n\t\t\twrapT: this.resolveGLConstant(options?.wrapT ?? 'CLAMP_TO_EDGE'),\n\t\t\tpreserveY: options?.preserveY,\n\t\t\tisIntegerColorFormat,\n\t\t};\n\t\tconst isFloatColorFormat = result.internalFormat === gl.RGBA16F || result.internalFormat === gl.RGBA32F;\n\t\t// gl.getExtension isn’t just a check, it’s a required side-effect to enable floats.\n\t\tif (isFloatColorFormat && !gl.getExtension('EXT_color_buffer_float')) {\n\t\t\tthrow spError(\n\t\t\t\t6,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tinternalFormat: internalFormatString,\n\t\t\t\t\ttype: typeString,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate getPixelArray(type: number, size: number): ArrayBufferView {\n\t\tconst ArrayType = this.glHelpers.typeToArray.get(type) ?? Uint8Array;\n\t\treturn new ArrayType(size);\n\t}\n\n\tprivate isNotRgba(format: number): boolean {\n\t\treturn format !== this.gl.RGBA && format !== this.gl.RGBA_INTEGER;\n\t}\n\n\tprivate clearHistoryTextureLayers(textureInfo: Texture): void {\n\t\tif (!textureInfo.history) return;\n\n\t\tconst gl = this.gl;\n\t\tconst { type, format } = textureInfo.options;\n\t\tconst transparent = this.getPixelArray(type, textureInfo.width * textureInfo.height * 4);\n\t\tgl.activeTexture(gl.TEXTURE0 + textureInfo.unitIndex);\n\t\tgl.bindTexture(gl.TEXTURE_2D_ARRAY, textureInfo.texture);\n\t\tconst needsAlignmentFix = this.isNotRgba(format);\n\t\tlet previousAlignment;\n\t\tif (needsAlignmentFix) {\n\t\t\tpreviousAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);\n\t\t\tgl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n\t\t}\n\t\tfor (let layer = 0; layer < textureInfo.history.depth; ++layer) {\n\t\t\tgl.texSubImage3D(\n\t\t\t\tgl.TEXTURE_2D_ARRAY,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tlayer,\n\t\t\t\ttextureInfo.width,\n\t\t\t\ttextureInfo.height,\n\t\t\t\t1,\n\t\t\t\tformat,\n\t\t\t\ttype,\n\t\t\t\ttransparent,\n\t\t\t);\n\t\t}\n\t\tif (needsAlignmentFix) gl.pixelStorei(gl.UNPACK_ALIGNMENT, previousAlignment);\n\t}\n\n\tprivate updateTextureFrameOffset(\n\t\tname: string | symbol,\n\t\tframeOffset: number,\n\t\toptions?: {\n\t\t\tallowMissing?: boolean;\n\t\t},\n\t) {\n\t\tthis.updateUniforms(\n\t\t\t{\n\t\t\t\t[`${stringFrom(name)}FrameOffset`]: frameOffset,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t}\n\n\tprivate resetHistoryTextureState(name: string | symbol, textureInfo: Texture) {\n\t\tif (!textureInfo.history) return;\n\t\ttextureInfo.history.writeIndex = 0;\n\t\tthis.clearHistoryTextureLayers(textureInfo);\n\t\tthis.updateTextureFrameOffset(name, 0, { allowMissing: true });\n\t}\n\n\tinitializeUniform(\n\t\tname: string,\n\t\ttype: Uniform['type'],\n\t\tvalue: number | number[] | (number | number[])[],\n\t\toptions?: { arrayLength?: number; allowMissing?: boolean },\n\t) {\n\t\tconst arrayLength = options?.arrayLength;\n\t\tconst allowMissing = options?.allowMissing ?? false;\n\t\tif (this.uniforms.has(name)) {\n\t\t\tthrow spError(7, __SHADERPAD_DEV__ && { name, arrayLength: arrayLength ?? null });\n\t\t}\n\t\tif (!UNIFORM_TYPE_SUFFIXES[type]) {\n\t\t\tthrow spError(\n\t\t\t\t8,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname,\n\t\t\t\t\ttype,\n\t\t\t\t\tsupportedTypes: Object.keys(UNIFORM_TYPE_SUFFIXES),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tif (arrayLength && !(Array.isArray(value) && value.length === arrayLength)) {\n\t\t\tthrow spError(\n\t\t\t\t9,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname,\n\t\t\t\t\texpectedLength: arrayLength,\n\t\t\t\t\treceivedLength: Array.isArray(value) ? value.length : 1,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tlet location = this.gl.getUniformLocation(this.program!, name);\n\t\tif (!location && arrayLength) {\n\t\t\tlocation = this.gl.getUniformLocation(this.program!, `${name}[0]`);\n\t\t}\n\t\tif (!location) {\n\t\t\tif (allowMissing) return;\n\t\t\tthrow spError(19, __SHADERPAD_DEV__ && { name, arrayLength: arrayLength ?? null });\n\t\t}\n\n\t\tconst probeValue = arrayLength ? (value as number[] | number[][])[0] : value;\n\t\tconst length = Array.isArray(probeValue) ? (probeValue.length as 1 | 2 | 3 | 4) : 1;\n\t\tthis.uniforms.set(name, { type, length, location, arrayLength });\n\n\t\ttry {\n\t\t\tthis.updateUniforms({ [name]: value });\n\t\t} catch (error) {\n\t\t\tthis.uniforms.delete(name);\n\t\t\tthrow error;\n\t\t}\n\t\tthis.emit('initializeUniform', ...arguments);\n\t}\n\n\tupdateUniforms(\n\t\tupdates: Record<string, number | number[] | (number | number[])[]>,\n\t\toptions?: { startIndex?: number; allowMissing?: boolean },\n\t) {\n\t\tthis.gl.useProgram(this.program);\n\t\tObject.entries(updates).forEach(([name, newValue]) => {\n\t\t\tconst uniform = this.uniforms.get(name);\n\t\t\tif (!uniform) {\n\t\t\t\tif (options?.allowMissing) return;\n\t\t\t\tthrow spError(\n\t\t\t\t\t20,\n\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tstartIndex: options?.startIndex ?? null,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet glFunctionName = `uniform${uniform.length}${UNIFORM_TYPE_SUFFIXES[uniform.type]}`;\n\t\t\tif (uniform.arrayLength) {\n\t\t\t\tif (!Array.isArray(newValue)) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t10,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\treceivedType: typeof newValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst nValues = newValue.length;\n\t\t\t\tif (!nValues) return;\n\t\t\t\tif (nValues > uniform.arrayLength) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t11,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\treceivedLength: nValues,\n\t\t\t\t\t\t\tmaxLength: uniform.arrayLength,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (newValue.some(item => (Array.isArray(item) ? item.length : 1) !== uniform.length)) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t12,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\texpectedElementLength: uniform.length,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst flat = newValue.flat();\n\t\t\t\tconst typedArray =\n\t\t\t\t\tuniform.type === 'float'\n\t\t\t\t\t\t? new Float32Array(flat)\n\t\t\t\t\t\t: uniform.type === 'uint'\n\t\t\t\t\t\t\t? new Uint32Array(flat)\n\t\t\t\t\t\t\t: new Int32Array(flat);\n\t\t\t\tlet location = uniform.location;\n\t\t\t\tif (options?.startIndex) {\n\t\t\t\t\tconst newLocation = this.gl.getUniformLocation(this.program!, `${name}[${options.startIndex}]`);\n\t\t\t\t\tif (!newLocation) {\n\t\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t\t13,\n\t\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tstartIndex: options.startIndex,\n\t\t\t\t\t\t\t\tarrayLength: uniform.arrayLength,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tlocation = newLocation;\n\t\t\t\t}\n\t\t\t\t(this.gl as any)[glFunctionName + 'v'](location, typedArray);\n\t\t\t} else {\n\t\t\t\tif (!Array.isArray(newValue)) newValue = [newValue];\n\t\t\t\tconst scalarValue = newValue as number[];\n\t\t\t\tif (scalarValue.length !== uniform.length) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t14,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\treceivedLength: scalarValue.length,\n\t\t\t\t\t\t\texpectedLength: uniform.length,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t(this.gl as any)[glFunctionName](uniform.location, ...scalarValue);\n\t\t\t}\n\t\t});\n\t\tthis.emit('updateUniforms', ...arguments);\n\t}\n\n\tprivate createTexture(\n\t\tname: string | symbol,\n\t\ttextureInfo: Pick<Texture, 'width' | 'height' | 'history' | 'options'> & { unitIndex?: number },\n\t) {\n\t\tconst { width, height } = textureInfo;\n\t\tconst historyDepth = textureInfo.history?.depth ?? 0;\n\n\t\tconst texture = this.gl.createTexture();\n\t\tif (!texture) {\n\t\t\tthrow spError(\n\t\t\t\t15,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname: stringFrom(name),\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\thistoryDepth,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tlet unitIndex = textureInfo.unitIndex;\n\t\tif (typeof unitIndex !== 'number') {\n\t\t\ttry {\n\t\t\t\tunitIndex = this.reserveTextureUnit(name);\n\t\t\t} catch (error) {\n\t\t\t\tthis.gl.deleteTexture(texture);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tconst hasHistory = historyDepth > 0;\n\t\tconst textureTarget = hasHistory ? this.gl.TEXTURE_2D_ARRAY : this.gl.TEXTURE_2D;\n\t\tconst { options } = textureInfo;\n\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + unitIndex);\n\t\tthis.gl.bindTexture(textureTarget, texture);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_WRAP_S, options.wrapS);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_WRAP_T, options.wrapT);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_MIN_FILTER, options.minFilter);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_MAG_FILTER, options.magFilter);\n\t\tif (hasHistory) {\n\t\t\tthis.gl.texStorage3D(textureTarget, 1, options.internalFormat, width, height, historyDepth);\n\t\t} else if (name === INTERMEDIATE_TEXTURE_KEY) {\n\t\t\tthis.gl.texImage2D(\n\t\t\t\tthis.gl.TEXTURE_2D,\n\t\t\t\t0,\n\t\t\t\toptions.internalFormat,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\t0,\n\t\t\t\toptions.format,\n\t\t\t\toptions.type,\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\t\treturn { texture, unitIndex };\n\t}\n\n\tprivate _initializeTexture(name: string | symbol, source: TextureSource, options?: InitializeTextureOptions) {\n\t\tif (this.textures.has(name)) {\n\t\t\tthrow spError(16, __SHADERPAD_DEV__ && { name: stringFrom(name) });\n\t\t}\n\n\t\tconst { history: historyDepth = 0, ...textureOptions } = options ?? {};\n\t\tconst { width, height } = getSourceDimensions(source);\n\t\tif (!width || !height) {\n\t\t\tthrow spError(\n\t\t\t\t17,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname: stringFrom(name),\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tsourceType: source.constructor.name,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst textureInfo: Pick<Texture, 'width' | 'height' | 'history' | 'options'> = {\n\t\t\twidth,\n\t\t\theight,\n\t\t\toptions:\n\t\t\t\tsource instanceof ShaderPad &&\n\t\t\t\tObject.keys(textureOptions).length === 0 &&\n\t\t\t\tsource.textures.has(INTERMEDIATE_TEXTURE_KEY)\n\t\t\t\t\t? source.textures.get(INTERMEDIATE_TEXTURE_KEY)!.options\n\t\t\t\t\t: this.resolveTextureOptions(textureOptions),\n\t\t};\n\t\tif (historyDepth > 0) {\n\t\t\ttextureInfo.history = { depth: historyDepth, writeIndex: 0 };\n\t\t}\n\t\tconst { texture, unitIndex } = this.createTexture(name, textureInfo);\n\t\tconst completeTextureInfo: Texture = {\n\t\t\ttexture,\n\t\t\tunitIndex,\n\t\t\t...textureInfo,\n\t\t};\n\t\tif (historyDepth > 0) {\n\t\t\tthis.initializeUniform(`${stringFrom(name)}FrameOffset`, 'int', 0, { allowMissing: true });\n\t\t\tthis.clearHistoryTextureLayers(completeTextureInfo);\n\t\t}\n\t\tthis.textures.set(name, completeTextureInfo);\n\t\tif (name !== INTERMEDIATE_TEXTURE_KEY && name !== HISTORY_TEXTURE_KEY) {\n\t\t\tthis.updateTexture(name, source);\n\t\t}\n\n\t\t// Set a uniform to access the texture in the fragment shader.\n\t\tthis.gl.useProgram(this.program!);\n\t\tconst uSampler = this.gl.getUniformLocation(this.program!, stringFrom(name));\n\t\tif (uSampler) {\n\t\t\tthis.gl.uniform1i(uSampler, unitIndex);\n\t\t}\n\t}\n\n\tinitializeTexture(name: string, source: TextureSource, options?: InitializeTextureOptions) {\n\t\t// Since history[0] is the current frame, add 1 to history depth to allow history[maxHistory].\n\t\tconst opts =\n\t\t\toptions?.history != null && options.history > 0 ? { ...options, history: options.history + 1 } : options;\n\t\tthis._initializeTexture(name, source, opts);\n\t\tthis.emit('initializeTexture', ...arguments);\n\t}\n\n\tupdateTextures(updates: Record<string, UpdateTextureSource>) {\n\t\tObject.entries(updates).forEach(([name, source]) => {\n\t\t\tthis.updateTexture(name, source);\n\t\t});\n\t\tthis.emit('updateTextures', ...arguments);\n\t}\n\n\tprivate updateTexture(name: string | symbol, source: UpdateTextureSource, historySlots?: HistorySlots) {\n\t\tconst info = this.textures.get(name);\n\t\tif (!info) {\n\t\t\tthrow spError(18, __SHADERPAD_DEV__ && { name: stringFrom(name) });\n\t\t}\n\n\t\tif (source instanceof WebGLTexture) {\n\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D, source);\n\t\t\treturn;\n\t\t}\n\n\t\tlet nonShaderPadSource = source as Exclude<UpdateTextureSource, ShaderPad>;\n\t\tif (source instanceof ShaderPad) {\n\t\t\tconst sourceIntermediateInfo = source.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\t\tconst srcW = sourceIntermediateInfo.width;\n\t\t\tconst srcH = sourceIntermediateInfo.height;\n\n\t\t\tif (source.gl === this.gl) {\n\t\t\t\tif (!info.history) {\n\t\t\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D, sourceIntermediateInfo.texture);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { depth } = info.history;\n\t\t\t\tconst targetSlots =\n\t\t\t\t\thistorySlots === undefined\n\t\t\t\t\t\t? [info.history.writeIndex]\n\t\t\t\t\t\t: Array.isArray(historySlots)\n\t\t\t\t\t\t\t? historySlots.map(i => safeMod(i, depth))\n\t\t\t\t\t\t\t: [safeMod(historySlots, depth)];\n\t\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, info.texture);\n\t\t\t\tthis.gl.bindFramebuffer(this.gl.READ_FRAMEBUFFER, source.intermediateFbo);\n\t\t\t\tfor (const slot of targetSlots) {\n\t\t\t\t\tthis.gl.copyTexSubImage3D(this.gl.TEXTURE_2D_ARRAY, 0, 0, 0, slot, 0, 0, srcW, srcH);\n\t\t\t\t}\n\t\t\t\tthis.gl.bindFramebuffer(this.gl.READ_FRAMEBUFFER, null);\n\t\t\t\tthis.updateTextureFrameOffset(name, targetSlots[targetSlots.length - 1], { allowMissing: true });\n\t\t\t\tif (historySlots === undefined) {\n\t\t\t\t\tinfo.history.writeIndex = (info.history.writeIndex + 1) % depth;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Different contexts - transfer via readPixels to preserve precision.\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\toptions: { format, type },\n\t\t\t} = sourceIntermediateInfo;\n\t\t\tconst pixels = this.getPixelArray(type, width * height * 4);\n\t\t\tsource.gl.bindFramebuffer(source.gl.FRAMEBUFFER, source.intermediateFbo);\n\t\t\tsource.gl.readPixels(0, 0, width, height, format, type, pixels);\n\t\t\tsource.gl.bindFramebuffer(source.gl.FRAMEBUFFER, null);\n\t\t\tnonShaderPadSource = { data: pixels, width, height };\n\t\t}\n\n\t\t// If dimensions changed, recreate the texture with new dimensions.\n\t\tconst { width, height } = getSourceDimensions(nonShaderPadSource);\n\t\tif (!width || !height) return;\n\n\t\tconst isPartial = 'isPartial' in nonShaderPadSource && nonShaderPadSource.isPartial;\n\t\tif (!isPartial) {\n\t\t\tthis.resizeTexture(name, width, height);\n\t\t}\n\n\t\t// UNPACK_FLIP_Y_WEBGL only works for DOM element sources, not typed arrays.\n\t\tconst isTypedArray = 'data' in nonShaderPadSource && nonShaderPadSource.data;\n\t\tconst shouldFlipY = !isTypedArray && !info.options?.preserveY;\n\t\tconst previousFlipY = this.gl.getParameter(this.gl.UNPACK_FLIP_Y_WEBGL);\n\t\tconst needsAlignmentFix = isTypedArray && this.isNotRgba(info.options.format);\n\t\tlet previousAlignment;\n\t\tif (needsAlignmentFix) {\n\t\t\tpreviousAlignment = this.gl.getParameter(this.gl.UNPACK_ALIGNMENT);\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);\n\t\t}\n\n\t\tif (info.history) {\n\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, info.texture);\n\t\t\tconst { depth } = info.history;\n\t\t\tconst targetSlots =\n\t\t\t\thistorySlots === undefined\n\t\t\t\t\t? [info.history.writeIndex]\n\t\t\t\t\t: Array.isArray(historySlots)\n\t\t\t\t\t\t? historySlots.map(i => safeMod(i, depth))\n\t\t\t\t\t\t: [safeMod(historySlots, depth)];\n\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, shouldFlipY);\n\t\t\tconst partialSource = nonShaderPadSource as PartialCustomTexture;\n\t\t\tconst sourceData =\n\t\t\t\tpartialSource.data ?? (nonShaderPadSource as Exclude<TextureSource, CustomTexture | ShaderPad>);\n\t\t\tconst xOffset = isPartial ? (partialSource.x ?? 0) : 0;\n\t\t\tconst yOffset = isPartial ? (partialSource.y ?? 0) : 0;\n\n\t\t\tfor (const slot of targetSlots) {\n\t\t\t\tthis.gl.texSubImage3D(\n\t\t\t\t\tthis.gl.TEXTURE_2D_ARRAY,\n\t\t\t\t\t0,\n\t\t\t\t\txOffset,\n\t\t\t\t\tyOffset,\n\t\t\t\t\tslot,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\t1,\n\t\t\t\t\tinfo.options.format,\n\t\t\t\t\tinfo.options.type,\n\t\t\t\t\tsourceData as any,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, previousFlipY);\n\t\t\tthis.updateTextureFrameOffset(name, targetSlots[targetSlots.length - 1]);\n\t\t\tif (historySlots === undefined) {\n\t\t\t\tinfo.history.writeIndex = (info.history.writeIndex + 1) % depth;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D, info.texture);\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, shouldFlipY);\n\n\t\t\tif (isPartial) {\n\t\t\t\tconst partialSource = nonShaderPadSource as PartialCustomTexture;\n\t\t\t\tthis.gl.texSubImage2D(\n\t\t\t\t\tthis.gl.TEXTURE_2D,\n\t\t\t\t\t0,\n\t\t\t\t\tpartialSource.x ?? 0,\n\t\t\t\t\tpartialSource.y ?? 0,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tinfo.options.format,\n\t\t\t\t\tinfo.options.type,\n\t\t\t\t\tpartialSource.data,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.gl.texImage2D(\n\t\t\t\t\tthis.gl.TEXTURE_2D,\n\t\t\t\t\t0,\n\t\t\t\t\tinfo.options.internalFormat,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\t0,\n\t\t\t\t\tinfo.options.format,\n\t\t\t\t\tinfo.options.type,\n\t\t\t\t\t((nonShaderPadSource as PartialCustomTexture).data ??\n\t\t\t\t\t\t(nonShaderPadSource as Exclude<TextureSource, CustomTexture | ShaderPad>)) as any,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, previousFlipY);\n\t\t}\n\t\tif (needsAlignmentFix) this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, previousAlignment);\n\t}\n\n\tprivate bindIntermediate() {\n\t\tconst gl = this.gl;\n\t\tconst intermediateInfo = this.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, this.intermediateFbo);\n\t\tgl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, intermediateInfo.texture, 0);\n\t}\n\n\tclear() {\n\t\tthis.bindIntermediate();\n\t\tconst gl = this.gl;\n\t\tconst intermediateInfo = this.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\tif (intermediateInfo.options.isIntegerColorFormat) {\n\t\t\tconst t = intermediateInfo.options.type;\n\t\t\tif (this.glHelpers.unsignedIntTypes.has(t)) {\n\t\t\t\tgl.clearBufferuiv(gl.COLOR, 0, new Uint32Array(4));\n\t\t\t} else {\n\t\t\t\tgl.clearBufferiv(gl.COLOR, 0, new Int32Array(4));\n\t\t\t}\n\t\t} else {\n\t\t\tgl.clear(gl.COLOR_BUFFER_BIT);\n\t\t}\n\t}\n\n\tdraw(options?: StepOptions) {\n\t\tthis.emit('beforeDraw', ...arguments);\n\t\tconst gl = this.gl;\n\t\tconst w = gl.drawingBufferWidth;\n\t\tconst h = gl.drawingBufferHeight;\n\n\t\tif (options?.skipClear) {\n\t\t\tthis.bindIntermediate();\n\t\t} else {\n\t\t\tthis.clear();\n\t\t}\n\n\t\tgl.useProgram(this.program);\n\t\tgl.bindVertexArray(this.vao);\n\t\tgl.viewport(0, 0, w, h);\n\t\tgl.drawArrays(gl.TRIANGLES, 0, 3);\n\n\t\tif (!this.isHeadless) {\n\t\t\tconst intermediateInfo = this.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\t\tif (!intermediateInfo.options.isIntegerColorFormat) {\n\t\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, this.intermediateFbo);\n\t\t\t\tgl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);\n\t\t\t\tgl.blitFramebuffer(0, 0, w, h, 0, 0, w, h, gl.COLOR_BUFFER_BIT, gl.NEAREST);\n\t\t\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\t\t\t}\n\t\t}\n\t\tthis.emit('afterDraw', ...arguments);\n\t}\n\n\tstep(options?: StepOptions) {\n\t\tif (!Number.isFinite(this.startTime)) {\n\t\t\tthis.startTime = performance.now();\n\t\t}\n\t\tthis._step((performance.now() - this.startTime) / 1000, options);\n\t}\n\n\tprivate _step(time: number, options?: StepOptions) {\n\t\tthis.emit('beforeStep', time, this.frame, options);\n\t\tconst updates: Record<string, number> = {};\n\t\tif (this.uniforms.has('u_time')) updates.u_time = time;\n\t\tif (this.uniforms.has('u_frame')) updates.u_frame = this.frame;\n\t\tthis.updateUniforms(updates);\n\t\tthis.draw(options);\n\t\tconst historyInfo = this.textures.get(HISTORY_TEXTURE_KEY);\n\t\tif (historyInfo && !options?.skipHistory) {\n\t\t\tconst { writeIndex, depth } = historyInfo.history!;\n\t\t\tconst gl = this.gl;\n\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, this.intermediateFbo);\n\t\t\tgl.bindTexture(gl.TEXTURE_2D_ARRAY, historyInfo.texture);\n\t\t\tgl.copyTexSubImage3D(\n\t\t\t\tgl.TEXTURE_2D_ARRAY,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\twriteIndex,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tgl.drawingBufferWidth,\n\t\t\t\tgl.drawingBufferHeight,\n\t\t\t);\n\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);\n\t\t\tconst nextWriteIndex = (writeIndex + 1) % depth;\n\t\t\tthis.updateTextureFrameOffset(HISTORY_TEXTURE_KEY, nextWriteIndex, { allowMissing: true });\n\t\t\thistoryInfo.history!.writeIndex = nextWriteIndex;\n\t\t}\n\t\t++this.frame;\n\t\tthis.emit('afterStep', time, this.frame, options);\n\t}\n\n\tplay(onBeforeStep?: (time: number, frame: number) => StepOptions | void) {\n\t\tthis._pause();\n\t\tif (!Number.isFinite(this.startTime)) {\n\t\t\tthis.startTime = performance.now();\n\t\t}\n\t\tthis.isPlaying = true;\n\t\tconst loop = (time: number) => {\n\t\t\ttime = (time - this.startTime) / 1000; // Convert from milliseconds to seconds.\n\t\t\tconst options = onBeforeStep?.(time, this.frame) ?? undefined;\n\t\t\tthis._step(time, options);\n\t\t\tif (this.isPlaying) this.animationFrameId = requestAnimationFrame(loop);\n\t\t};\n\t\tthis.animationFrameId = requestAnimationFrame(loop);\n\t\tthis.emit('play');\n\t}\n\n\tprivate _pause() {\n\t\tconst wasPlaying = this.isPlaying;\n\t\tthis.isPlaying = false;\n\t\tif (this.animationFrameId) {\n\t\t\tcancelAnimationFrame(this.animationFrameId);\n\t\t\tthis.animationFrameId = null;\n\t\t}\n\t\treturn wasPlaying;\n\t}\n\n\tpause() {\n\t\tif (this._pause()) {\n\t\t\tthis.emit('pause');\n\t\t}\n\t}\n\n\tresetFrame() {\n\t\tthis.frame = 0;\n\t\tthis.startTime = performance.now();\n\t}\n\n\treset() {\n\t\tthis.resetFrame();\n\t\tthis.textures.forEach((texture, name) => {\n\t\t\tthis.resetHistoryTextureState(name, texture);\n\t\t});\n\t\tthis.clear();\n\t\tthis.emit('reset');\n\t}\n\n\tdestroy() {\n\t\tthis.emit('destroy');\n\n\t\tthis._pause();\n\n\t\tif (this.cursorTarget) {\n\t\t\tthis.eventListeners.forEach((listener, event) => {\n\t\t\t\tthis.cursorTarget!.removeEventListener(event, listener);\n\t\t\t});\n\t\t\tthis.eventListeners.clear();\n\t\t}\n\n\t\tif (this.resolutionObserver) {\n\t\t\tthis.resolutionObserver.disconnect();\n\t\t\tthis.resolutionObserver = null;\n\t\t}\n\n\t\tif (this.program) {\n\t\t\tthis.gl.deleteProgram(this.program);\n\t\t\tthis.program = null;\n\t\t}\n\n\t\tif (this.intermediateFbo) {\n\t\t\tthis.gl.deleteFramebuffer(this.intermediateFbo);\n\t\t\tthis.intermediateFbo = null;\n\t\t}\n\n\t\tthis.textures.forEach(texture => {\n\t\t\tthis.textureUnitPool.free.push(texture.unitIndex);\n\t\t\tthis.gl.deleteTexture(texture.texture);\n\t\t});\n\t\tthis.textures.clear();\n\t\tconst entry = canvasRegistry.get(this.canvas);\n\t\tif (entry) {\n\t\t\tentry.instances.delete(this);\n\t\t\tif (entry.instances.size === 0) {\n\t\t\t\tcanvasRegistry.delete(this.canvas);\n\t\t\t}\n\t\t}\n\n\t\tif (this.vao) {\n\t\t\tthis.gl.deleteVertexArray(this.vao);\n\t\t\tthis.vao = null;\n\t\t}\n\n\t\tif (this.buffer) {\n\t\t\tthis.gl.deleteBuffer(this.buffer);\n\t\t\tthis.buffer = null;\n\t\t}\n\n\t\tthis.uniforms.clear();\n\t\tthis.hooks.clear();\n\t}\n}\n\nexport default ShaderPad;\n","import ShaderPad, { PluginContext } from '..';\n\nconst THROTTLE_INTERVAL_DEFAULT = 1000 / 30;\n\nexport interface AutosizeOptions {\n\tscale?: number;\n\ttarget?: Element | Window;\n\tthrottle?: number;\n}\n\nfunction autosize(options: AutosizeOptions = {}) {\n\treturn function (shaderPad: ShaderPad, context: PluginContext) {\n\t\tconst { emit } = context;\n\t\tconst { canvas } = shaderPad;\n\t\tconst {\n\t\t\tscale = window.devicePixelRatio || 1,\n\t\t\ttarget = canvas instanceof HTMLCanvasElement ? canvas : window,\n\t\t\tthrottle = THROTTLE_INTERVAL_DEFAULT,\n\t\t} = options;\n\n\t\tlet resizeTimeout: ReturnType<typeof setTimeout> | null = null;\n\t\tlet lastResizeTime = -Infinity;\n\t\tfunction throttledHandleResize() {\n\t\t\tif (resizeTimeout) clearTimeout(resizeTimeout);\n\t\t\tconst now = performance.now();\n\t\t\tconst timeUntilNextResize = lastResizeTime + throttle - now;\n\t\t\tif (timeUntilNextResize <= 0) {\n\t\t\t\tlastResizeTime = now;\n\t\t\t\thandleResize();\n\t\t\t} else {\n\t\t\t\tresizeTimeout = setTimeout(() => throttledHandleResize(), timeUntilNextResize);\n\t\t\t}\n\t\t}\n\n\t\tfunction handleResize() {\n\t\t\tlet width, height;\n\t\t\tif (target instanceof Window) {\n\t\t\t\twidth = window.innerWidth * scale;\n\t\t\t\theight = window.innerHeight * scale;\n\t\t\t} else {\n\t\t\t\twidth = target.clientWidth * scale;\n\t\t\t\theight = target.clientHeight * scale;\n\t\t\t}\n\t\t\twidth = Math.max(1, Math.round(width));\n\t\t\theight = Math.max(1, Math.round(height));\n\t\t\tif (canvas.width !== width || canvas.height !== height) {\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\t\t\t\temit('autosize:resize', width, height);\n\t\t\t}\n\t\t}\n\n\t\thandleResize();\n\n\t\tlet resizeObserver: ResizeObserver | null = null;\n\t\tif (target instanceof Window) {\n\t\t\twindow.addEventListener('resize', throttledHandleResize);\n\t\t} else if (target instanceof Element) {\n\t\t\tresizeObserver = new ResizeObserver(() => throttledHandleResize());\n\t\t\tresizeObserver.observe(target);\n\t\t}\n\n\t\tshaderPad.on('destroy', () => {\n\t\t\tif (resizeTimeout) clearTimeout(resizeTimeout);\n\t\t\tif (resizeObserver) resizeObserver.disconnect();\n\t\t\tif (target instanceof Window) {\n\t\t\t\twindow.removeEventListener('resize', throttledHandleResize);\n\t\t\t}\n\t\t});\n\t};\n}\n\nexport default autosize;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,mBAAAA;AAAA;AAAA;AAEA,mBAQO;;;ACPA,IAAM,sBAAsB;AAE5B,SAAS,SAAS,MAAiB;AACzC,SAAO,GAAG,mBAAmB,GAAG,IAAI;AACrC;;;ACCO,IAAM,aAA6D,OACvE;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,MAAM;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,MAAM;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACV;AAAA,EACA,MAAM;AAAA,IACL,OAAO;AAAA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A,EACD,GAAG,CAAC,QAAQ,SAAS,SAASA,WAAU,cAAc,mBAAmB,CAAC;AAE1E,8BAAU,MAAM;AACf,2BAAuB,UAAU,OAAO;AAAA,EACzC,GAAG;AAAA,IACF,OAAO,KAAK,UAAU,CAAC,CAAC,EACtB,KAAK,EACL,KAAK,IAAI;AAAA,EACZ,CAAC;AAED,8BAAU,MAAM;AACf,oBAAgB,UAAU;AAAA,EAC3B,GAAG,CAAC,UAAU,kBAAkB,CAAC;AAEjC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAK;AAAA,MACL,OAAO;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,GAAG;AAAA,MACJ;AAAA,MACC,GAAG;AAAA;AAAA,EACL;AAEF,CAAC;AAEDD,WAAU,cAAc;","names":["ShaderPad","canvas","width","height","ShaderPad","autosize","shader"]}
|
|
1
|
+
{"version":3,"sources":["../../src/react.tsx","../../src/internal/error-codes.gen.ts","../../src/internal/error-codes.dev.gen.ts","../../src/internal/util.ts","../../src/index.ts","../../src/plugins/autosize.ts"],"sourcesContent":["'use client';\n\nimport {\n\ttype ComponentPropsWithoutRef,\n\tforwardRef,\n\ttype RefObject,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\n\nimport CoreShaderPad, { type Options, type Plugin, type StepOptions } from '.';\nimport autosizePlugin, { type AutosizeOptions } from './plugins/autosize';\n\ntype CursorTarget = Window | Element | RefObject<Element | null>;\ntype EventMap = Partial<Record<string, (...args: any[]) => void>>;\n\ntype ShaderPadHandle = {\n\treadonly shader: CoreShaderPad | null;\n\treadonly canvas: HTMLCanvasElement | null;\n\tplay(): void;\n\tpause(): void;\n\tstep(options?: StepOptions): void;\n\tdraw(options?: StepOptions): void;\n\tclear(): void;\n\tresetFrame(): void;\n\treset(): void;\n\tdestroy(): void;\n};\n\nexport interface ShaderPadProps extends Omit<ComponentPropsWithoutRef<'canvas'>, 'children' | 'onError'> {\n\tshader: string;\n\tplugins?: Plugin[];\n\toptions?: Omit<Options, 'canvas' | 'plugins' | 'cursorTarget'>;\n\tautosize?: boolean | AutosizeOptions;\n\tcursorTarget?: CursorTarget;\n\tautoPlay?: boolean;\n\tpauseWhenOffscreen?: boolean;\n\tonInit?: (shader: CoreShaderPad, canvas: HTMLCanvasElement) => void;\n\tonBeforeStep?: (shader: CoreShaderPad, time: number, frame: number) => StepOptions | void;\n\tonError?: (error: unknown) => void;\n\tonOnscreenChange?: (isOnscreen: boolean) => void;\n\tevents?: EventMap;\n}\n\nfunction isRefTarget(target: CursorTarget | undefined): target is RefObject<Element | null> {\n\treturn Boolean(target && typeof target === 'object' && 'current' in target);\n}\n\nfunction resolveCursorTarget(target: CursorTarget | undefined) {\n\tif (isRefTarget(target)) {\n\t\treturn target.current ?? undefined;\n\t}\n\n\treturn target;\n}\n\nfunction isElementInViewport(element: HTMLElement) {\n\tconst rect = element.getBoundingClientRect();\n\treturn (\n\t\trect.width > 0 &&\n\t\trect.height > 0 &&\n\t\trect.bottom > 0 &&\n\t\trect.right > 0 &&\n\t\trect.top < window.innerHeight &&\n\t\trect.left < window.innerWidth\n\t);\n}\n\nfunction isElementRenderable(element: HTMLElement) {\n\tif (typeof element.checkVisibility === 'function') {\n\t\treturn element.checkVisibility({\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tcheckOpacity: true,\n\t\t\tcheckVisibilityCSS: true,\n\t\t});\n\t}\n\n\tconst style = window.getComputedStyle(element);\n\tconst rect = element.getBoundingClientRect();\n\treturn (\n\t\trect.width > 0 &&\n\t\trect.height > 0 &&\n\t\tstyle.display !== 'none' &&\n\t\tstyle.visibility !== 'hidden' &&\n\t\tstyle.opacity !== '0'\n\t);\n}\n\nexport const ShaderPad = forwardRef<ShaderPadHandle, ShaderPadProps>(function ShaderPad(\n\t{\n\t\tshader,\n\t\tplugins,\n\t\toptions,\n\t\tautosize = true,\n\t\tcursorTarget,\n\t\tautoPlay = true,\n\t\tpauseWhenOffscreen = true,\n\t\tonInit,\n\t\tonBeforeStep,\n\t\tonError,\n\t\tonOnscreenChange,\n\t\tevents,\n\t\tstyle,\n\t\t...canvasProps\n\t},\n\tref,\n) {\n\tconst canvasRef = useRef<HTMLCanvasElement>(null);\n\tconst shaderRef = useRef<CoreShaderPad | null>(null);\n\tconst destroyedShadersRef = useRef(new WeakSet<CoreShaderPad>());\n\tconst eventSubscriptionsRef = useRef<{\n\t\tshader: CoreShaderPad | null;\n\t\tlisteners: Map<string, (...args: any[]) => void>;\n\t}>({\n\t\tshader: null,\n\t\tlisteners: new Map(),\n\t});\n\tconst syncPlaybackRef = useRef<(() => void) | null>(null);\n\tconst onInitRef = useRef(onInit);\n\tconst onBeforeStepRef = useRef(onBeforeStep);\n\tconst onErrorRef = useRef(onError);\n\tconst onOnscreenChangeRef = useRef(onOnscreenChange);\n\tconst eventsRef = useRef(events);\n\tconst autoPlayRef = useRef(autoPlay);\n\tconst pauseWhenOffscreenRef = useRef(pauseWhenOffscreen);\n\tconst [cursorTargetVersion, setCursorTargetVersion] = useState(0);\n\n\tonInitRef.current = onInit;\n\tonBeforeStepRef.current = onBeforeStep;\n\tonErrorRef.current = onError;\n\tonOnscreenChangeRef.current = onOnscreenChange;\n\teventsRef.current = events;\n\tautoPlayRef.current = autoPlay;\n\tpauseWhenOffscreenRef.current = pauseWhenOffscreen;\n\n\tfunction clearEventSubscriptions(shader?: CoreShaderPad | null) {\n\t\tconst store = eventSubscriptionsRef.current;\n\t\tconst activeShader = shader ?? store.shader;\n\t\tif (!activeShader) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [name, listener] of store.listeners) {\n\t\t\tactiveShader.off(name as any, listener);\n\t\t}\n\n\t\tstore.listeners.clear();\n\t\tif (!shader || store.shader === shader) {\n\t\t\tstore.shader = null;\n\t\t}\n\t}\n\n\tfunction syncEventSubscriptions(shader: CoreShaderPad | null) {\n\t\tconst store = eventSubscriptionsRef.current;\n\t\tif (store.shader && store.shader !== shader) {\n\t\t\tclearEventSubscriptions(store.shader);\n\t\t}\n\t\tif (!shader) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entries = Object.entries(eventsRef.current ?? {}).filter(([, handler]) => typeof handler === 'function');\n\t\tconst nextKeys = new Set(entries.map(([name]) => name));\n\n\t\tfor (const [name, listener] of store.listeners) {\n\t\t\tif (!nextKeys.has(name)) {\n\t\t\t\tshader.off(name as any, listener);\n\t\t\t\tstore.listeners.delete(name);\n\t\t\t}\n\t\t}\n\n\t\tfor (const [name] of entries) {\n\t\t\tif (store.listeners.has(name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst listener = (...args: any[]) => {\n\t\t\t\tconst handler = eventsRef.current?.[name];\n\t\t\t\tif (typeof handler === 'function') {\n\t\t\t\t\thandler(...args);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tshader.on(name as any, listener);\n\t\t\tstore.listeners.set(name, listener);\n\t\t}\n\n\t\tstore.shader = shader;\n\t}\n\n\tfunction destroyShader(shader: CoreShaderPad | null) {\n\t\tif (!shader || destroyedShadersRef.current.has(shader)) {\n\t\t\treturn;\n\t\t}\n\n\t\tdestroyedShadersRef.current.add(shader);\n\t\tclearEventSubscriptions(shader);\n\t\tif (shaderRef.current === shader) {\n\t\t\tshaderRef.current = null;\n\t\t\tsyncPlaybackRef.current = null;\n\t\t}\n\t\tshader.destroy();\n\t}\n\n\tfunction playShader(shader: CoreShaderPad) {\n\t\tshader.play((time, frame) => onBeforeStepRef.current?.(shader, time, frame));\n\t}\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\tget shader() {\n\t\t\t\treturn shaderRef.current;\n\t\t\t},\n\t\t\tget canvas() {\n\t\t\t\treturn canvasRef.current;\n\t\t\t},\n\t\t\tplay() {\n\t\t\t\tconst shader = shaderRef.current;\n\t\t\t\tif (shader) {\n\t\t\t\t\tplayShader(shader);\n\t\t\t\t}\n\t\t\t},\n\t\t\tpause() {\n\t\t\t\tshaderRef.current?.pause();\n\t\t\t},\n\t\t\tstep(stepOptions) {\n\t\t\t\tshaderRef.current?.step(stepOptions);\n\t\t\t},\n\t\t\tdraw(stepOptions) {\n\t\t\t\tshaderRef.current?.draw(stepOptions);\n\t\t\t},\n\t\t\tclear() {\n\t\t\t\tshaderRef.current?.clear();\n\t\t\t},\n\t\t\tresetFrame() {\n\t\t\t\tshaderRef.current?.resetFrame();\n\t\t\t},\n\t\t\treset() {\n\t\t\t\tshaderRef.current?.reset();\n\t\t\t},\n\t\t\tdestroy() {\n\t\t\t\tdestroyShader(shaderRef.current);\n\t\t\t},\n\t\t}),\n\t\t[],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!isRefTarget(cursorTarget) || cursorTarget.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet frameId: number | null = null;\n\t\tlet isDisposed = false;\n\n\t\tconst poll = () => {\n\t\t\tif (isDisposed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (cursorTarget.current) {\n\t\t\t\tsetCursorTargetVersion(version => version + 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tframeId = requestAnimationFrame(poll);\n\t\t};\n\n\t\tframeId = requestAnimationFrame(poll);\n\n\t\treturn () => {\n\t\t\tisDisposed = true;\n\t\t\tif (frameId !== null) {\n\t\t\t\tcancelAnimationFrame(frameId);\n\t\t\t}\n\t\t};\n\t}, [cursorTarget]);\n\n\tuseEffect(() => {\n\t\tconst canvas = canvasRef.current;\n\t\tif (!canvas) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resolvedCursorTarget = resolveCursorTarget(cursorTarget);\n\t\tif (isRefTarget(cursorTarget) && !resolvedCursorTarget) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst installedPlugins =\n\t\t\tautosize === false\n\t\t\t\t? [...(plugins ?? [])]\n\t\t\t\t: [autosizePlugin(autosize === true ? undefined : autosize), ...(plugins ?? [])];\n\n\t\tlet instance: CoreShaderPad | null = null;\n\t\tlet isDisposed = false;\n\t\tlet isDocumentVisible = document.visibilityState === 'visible';\n\t\tlet isIntersecting = isElementInViewport(canvas);\n\t\tlet lastOnscreen: boolean | null = null;\n\t\tlet isPlaying = false;\n\t\tlet isManagedPlayback = false;\n\n\t\tconst handlePlay = () => {\n\t\t\tisPlaying = true;\n\t\t};\n\t\tconst handlePause = () => {\n\t\t\tisPlaying = false;\n\t\t};\n\n\t\tconst handleVisibilityChange = () => {\n\t\t\tisDocumentVisible = document.visibilityState === 'visible';\n\t\t\tsyncPlayback();\n\t\t};\n\n\t\tconst syncPlayback = () => {\n\t\t\tif (!instance || isDisposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isOnscreen = isDocumentVisible && isIntersecting && isElementRenderable(canvas) && canvas.isConnected;\n\n\t\t\tif (lastOnscreen !== isOnscreen) {\n\t\t\t\tlastOnscreen = isOnscreen;\n\t\t\t\tonOnscreenChangeRef.current?.(isOnscreen);\n\t\t\t}\n\n\t\t\tif (!autoPlayRef.current) {\n\t\t\t\tif (isManagedPlayback && isPlaying) {\n\t\t\t\t\tinstance.pause();\n\t\t\t\t}\n\t\t\t\tisManagedPlayback = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!pauseWhenOffscreenRef.current) {\n\t\t\t\tif (!isPlaying) {\n\t\t\t\t\tplayShader(instance);\n\t\t\t\t}\n\t\t\t\tisManagedPlayback = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isOnscreen) {\n\t\t\t\tif (!isPlaying) {\n\t\t\t\t\tplayShader(instance);\n\t\t\t\t}\n\t\t\t\tisManagedPlayback = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isPlaying) {\n\t\t\t\tinstance.pause();\n\t\t\t}\n\t\t\tisManagedPlayback = false;\n\t\t};\n\n\t\tconst intersectionObserver =\n\t\t\ttypeof IntersectionObserver === 'function'\n\t\t\t\t? new IntersectionObserver(\n\t\t\t\t\t\tentries => {\n\t\t\t\t\t\t\tisIntersecting = entries.some(entry => entry.isIntersecting && entry.intersectionRatio > 0);\n\t\t\t\t\t\t\tsyncPlayback();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ threshold: 0.01 },\n\t\t\t\t\t)\n\t\t\t\t: null;\n\n\t\ttry {\n\t\t\tinstance = new CoreShaderPad(shader, {\n\t\t\t\t...options,\n\t\t\t\tcanvas,\n\t\t\t\tplugins: installedPlugins,\n\t\t\t\t...(resolvedCursorTarget ? { cursorTarget: resolvedCursorTarget } : {}),\n\t\t\t});\n\t\t\tinstance.on('play', handlePlay);\n\t\t\tinstance.on('pause', handlePause);\n\t\t\tshaderRef.current = instance;\n\t\t\tsyncEventSubscriptions(instance);\n\t\t\tonInitRef.current?.(instance, canvas);\n\n\t\t\tintersectionObserver?.observe(canvas);\n\t\t\tdocument.addEventListener('visibilitychange', handleVisibilityChange);\n\t\t\tsyncPlaybackRef.current = syncPlayback;\n\t\t\tsyncPlayback();\n\t\t} catch (error) {\n\t\t\tintersectionObserver?.disconnect();\n\t\t\tdocument.removeEventListener('visibilitychange', handleVisibilityChange);\n\t\t\tif (instance) {\n\t\t\t\tinstance.off('play', handlePlay);\n\t\t\t\tinstance.off('pause', handlePause);\n\t\t\t}\n\t\t\tdestroyShader(instance);\n\t\t\tif (onErrorRef.current) {\n\t\t\t\tonErrorRef.current(error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn () => {\n\t\t\tisDisposed = true;\n\t\t\tintersectionObserver?.disconnect();\n\t\t\tdocument.removeEventListener('visibilitychange', handleVisibilityChange);\n\t\t\tif (instance) {\n\t\t\t\tinstance.off('play', handlePlay);\n\t\t\t\tinstance.off('pause', handlePause);\n\t\t\t}\n\t\t\tdestroyShader(instance);\n\t\t};\n\t}, [shader, plugins, options, autosize, cursorTarget, cursorTargetVersion]);\n\n\tuseEffect(() => {\n\t\tsyncEventSubscriptions(shaderRef.current);\n\t}, [\n\t\tObject.keys(events ?? {})\n\t\t\t.sort()\n\t\t\t.join('\\n'),\n\t]);\n\n\tuseEffect(() => {\n\t\tsyncPlaybackRef.current?.();\n\t}, [autoPlay, pauseWhenOffscreen]);\n\n\treturn (\n\t\t<canvas\n\t\t\tref={canvasRef}\n\t\t\tstyle={{\n\t\t\t\tdisplay: 'block',\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\t...style,\n\t\t\t}}\n\t\t\t{...canvasProps}\n\t\t/>\n\t);\n});\n\nShaderPad.displayName = 'ShaderPad';\n\nexport default ShaderPad;\n","// Generated by scripts/generate-error-code-artifacts.mjs. Do not edit manually.\nexport type ErrorCode = number;\n\nexport const ERROR_DOCS_BASE_URL = 'https://mry.ac/s/';\n\nexport function errorUrl(code: ErrorCode) {\n\treturn `${ERROR_DOCS_BASE_URL}${code}`;\n}\n","// Generated by scripts/generate-error-code-artifacts.mjs. Do not edit manually.\nimport type { ErrorCode } from './error-codes.gen.js';\n\ntype DevErrorDetails = {\n\ttitle: string;\n\tsummary: string;\n};\n\nexport const DEV_ERRORS: Record<ErrorCode, DevErrorDetails> | undefined = __SHADERPAD_DEV__\n\t? {\n\t\t\t'0': {\n\t\t\t\ttitle: 'WebGL2 Context Unavailable',\n\t\t\t\tsummary: 'ShaderPad could not create a WebGL2 rendering context.',\n\t\t\t},\n\t\t\t'1': {\n\t\t\t\ttitle: 'Program Allocation Failed',\n\t\t\t\tsummary: 'ShaderPad could not allocate a WebGL program object.',\n\t\t\t},\n\t\t\t'2': {\n\t\t\t\ttitle: 'Program Link Failed',\n\t\t\t\tsummary: 'ShaderPad compiled the shaders but failed to link them into a WebGL program.',\n\t\t\t},\n\t\t\t'3': {\n\t\t\t\ttitle: 'Unknown GL Constant',\n\t\t\t\tsummary: 'ShaderPad received a WebGL constant name it does not recognize.',\n\t\t\t},\n\t\t\t'4': {\n\t\t\t\ttitle: 'Shader Compilation Failed',\n\t\t\t\tsummary: 'A vertex or fragment shader failed to compile.',\n\t\t\t},\n\t\t\t'5': {\n\t\t\t\ttitle: 'Texture Units Exhausted',\n\t\t\t\tsummary: 'ShaderPad tried to reserve more texture units than this device exposes.',\n\t\t\t},\n\t\t\t'6': {\n\t\t\t\ttitle: 'Float Color Buffer Extension Missing',\n\t\t\t\tsummary: 'ShaderPad requested a float render texture, but EXT_color_buffer_float is unavailable.',\n\t\t\t},\n\t\t\t'7': {\n\t\t\t\ttitle: 'Uniform Already Initialized',\n\t\t\t\tsummary: 'ShaderPad was asked to register a uniform name that was already registered.',\n\t\t\t},\n\t\t\t'8': {\n\t\t\t\ttitle: 'Invalid Uniform Type',\n\t\t\t\tsummary: 'ShaderPad received an unsupported uniform type string.',\n\t\t\t},\n\t\t\t'9': {\n\t\t\t\ttitle: 'Uniform Array Length Mismatch',\n\t\t\t\tsummary: 'ShaderPad was asked to initialize a uniform array with the wrong number of elements.',\n\t\t\t},\n\t\t\t'10': {\n\t\t\t\ttitle: 'Uniform Array Update Expected An Array',\n\t\t\t\tsummary: 'ShaderPad attempted to update a uniform array, but the provided value was not an array.',\n\t\t\t},\n\t\t\t'11': {\n\t\t\t\ttitle: 'Uniform Array Update Too Large',\n\t\t\t\tsummary: 'ShaderPad received more uniform array elements than the initialized array can hold.',\n\t\t\t},\n\t\t\t'12': {\n\t\t\t\ttitle: 'Uniform Array Element Size Mismatch',\n\t\t\t\tsummary: 'At least one uniform array element has the wrong scalar or vector length.',\n\t\t\t},\n\t\t\t'13': {\n\t\t\t\ttitle: 'Uniform Array Start Index Invalid',\n\t\t\t\tsummary: 'ShaderPad could not find the requested starting index for a uniform array.',\n\t\t\t},\n\t\t\t'14': {\n\t\t\t\ttitle: 'Uniform Value Length Invalid',\n\t\t\t\tsummary: 'ShaderPad received a scalar or vector uniform update with the wrong component count.',\n\t\t\t},\n\t\t\t'15': {\n\t\t\t\ttitle: 'Texture Allocation Failed',\n\t\t\t\tsummary: 'ShaderPad could not create a WebGL texture object.',\n\t\t\t},\n\t\t\t'16': {\n\t\t\t\ttitle: 'Texture Already Initialized',\n\t\t\t\tsummary: 'ShaderPad was asked to initialize a texture name that is already registered.',\n\t\t\t},\n\t\t\t'17': {\n\t\t\t\ttitle: 'Texture Source Dimensions Invalid',\n\t\t\t\tsummary: 'ShaderPad could not determine valid width and height values for the texture source.',\n\t\t\t},\n\t\t\t'18': {\n\t\t\t\ttitle: 'Texture Not Initialized',\n\t\t\t\tsummary: 'ShaderPad was asked to update a texture name that has not been initialized.',\n\t\t\t},\n\t\t\t'19': {\n\t\t\t\ttitle: 'Uniform Missing During Initialization',\n\t\t\t\tsummary:\n\t\t\t\t\t'ShaderPad could not initialize a uniform because the shader program does not contain that symbol.',\n\t\t\t},\n\t\t\t'20': {\n\t\t\t\ttitle: 'Uniform Missing During Update',\n\t\t\t\tsummary:\n\t\t\t\t\t'ShaderPad could not update a uniform because the shader program does not contain that symbol.',\n\t\t\t},\n\t\t\t'60': {\n\t\t\t\ttitle: 'Face Mask Renderer Context Unavailable',\n\t\t\t\tsummary: 'The face plugin could not create the offscreen WebGL2 context used for face-mask rendering.',\n\t\t\t},\n\t\t\t'61': {\n\t\t\t\ttitle: 'Face Mask Shader Setup Failed',\n\t\t\t\tsummary: 'The face plugin could not build the shaders it uses for face-mask rendering.',\n\t\t\t},\n\t\t\t'62': {\n\t\t\t\ttitle: 'Face Mask Renderer Initialization Failed',\n\t\t\t\tsummary: 'The face plugin could not finish setting up its internal face-mask renderer.',\n\t\t\t},\n\t\t}\n\t: undefined;\n","import { errorUrl, type ErrorCode } from './error-codes.gen.js';\nimport { DEV_ERRORS } from './error-codes.dev.gen.js';\n\ntype DevContext = Record<string, unknown> | false | undefined;\ntype ShaderPadError = Error & { code: ErrorCode };\n\nfunction withCode(message: string, code: ErrorCode): ShaderPadError {\n\tconst error = new Error(message) as ShaderPadError;\n\terror.code = code;\n\treturn error;\n}\n\nfunction renderContext(context: Record<string, unknown>) {\n\tconst lines = ['Context:'];\n\n\tfor (const [key, value] of Object.entries(context)) {\n\t\tif (value === undefined) continue;\n\n\t\tconst rendered =\n\t\t\ttypeof value === 'string'\n\t\t\t\t? value\n\t\t\t\t: (JSON.stringify(value, null, 2) ??\n\t\t\t\t\t(typeof value === 'bigint' ||\n\t\t\t\t\ttypeof value === 'number' ||\n\t\t\t\t\ttypeof value === 'boolean' ||\n\t\t\t\t\tvalue == null\n\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t: ''));\n\n\t\tif (!rendered) continue;\n\t\tlines.push(rendered.includes('\\n') ? `${key}:\\n${rendered}` : `${key}: ${rendered}`);\n\t}\n\n\treturn lines.length > 1 ? lines.join('\\n') : '';\n}\n\nfunction renderDevMessage(code: ErrorCode, context?: DevContext) {\n\tconst error = DEV_ERRORS?.[code];\n\tconst parts = error\n\t\t? [`[ShaderPad ${code}] ${error.title}`, error.summary, `Docs: ${errorUrl(code)}`]\n\t\t: [`[ShaderPad ${code}] ${errorUrl(code)}`];\n\n\tif (context) {\n\t\tconst renderedContext = renderContext(context);\n\t\tif (renderedContext) parts.push(renderedContext);\n\t}\n\n\treturn parts.join('\\n\\n');\n}\n\nexport function spError(code: ErrorCode, context?: DevContext) {\n\treturn withCode(__SHADERPAD_DEV__ ? renderDevMessage(code, context) : `ShaderPad error: ${errorUrl(code)}`, code);\n}\n\nexport function safeMod(i: number, m: number): number {\n\treturn ((i % m) + m) % m;\n}\n","import { spError, safeMod } from './internal/util';\n\nconst DEFAULT_VERTEX_SHADER_SRC = `#version 300 es\nin vec2 a_position;\nout vec2 v_uv;\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_uv = a_position * 0.5 + 0.5;\n}`;\n\ninterface Uniform {\n\ttype: 'float' | 'int' | 'uint';\n\tlength: 1 | 2 | 3 | 4;\n\tlocation: WebGLUniformLocation;\n\tarrayLength?: number;\n}\n\ntype GLInternalFormatChannels = 'R' | 'RG' | 'RGB' | 'RGBA';\ntype GLInternalFormatDepth = '8' | '16F' | '32F' | '8UI' | '8I' | '16UI' | '16I' | '32UI' | '32I';\nexport type GLInternalFormatString = `${GLInternalFormatChannels}${GLInternalFormatDepth}`;\n\nexport type GLFormatString =\n\t| 'RED'\n\t| 'RG'\n\t| 'RGB'\n\t| 'RGBA'\n\t| 'RED_INTEGER'\n\t| 'RG_INTEGER'\n\t| 'RGB_INTEGER'\n\t| 'RGBA_INTEGER';\nexport type GLTypeString =\n\t| 'UNSIGNED_BYTE'\n\t| 'BYTE'\n\t| 'FLOAT'\n\t| 'HALF_FLOAT'\n\t| 'UNSIGNED_SHORT'\n\t| 'SHORT'\n\t| 'UNSIGNED_INT'\n\t| 'INT';\nexport type GLFilterString = 'LINEAR' | 'NEAREST';\nexport type GLWrapString = 'CLAMP_TO_EDGE' | 'REPEAT' | 'MIRRORED_REPEAT';\n\nconst FORMAT_TYPE_SUFFIXES: [string, GLTypeString][] = [\n\t['8UI', 'UNSIGNED_BYTE'],\n\t['8I', 'BYTE'],\n\t['16UI', 'UNSIGNED_SHORT'],\n\t['16I', 'SHORT'],\n\t['16F', 'HALF_FLOAT'],\n\t['32UI', 'UNSIGNED_INT'],\n\t['32I', 'INT'],\n\t['32F', 'FLOAT'],\n\t['8', 'UNSIGNED_BYTE'],\n];\n\nconst UNIFORM_TYPE_SUFFIXES: Record<Uniform['type'], string> = {\n\tfloat: 'f',\n\tint: 'i',\n\tuint: 'ui',\n};\n\nfunction typeFromInternalFormatString(internalFormatString?: GLInternalFormatString): GLTypeString | undefined {\n\treturn internalFormatString && FORMAT_TYPE_SUFFIXES.find(([suffix]) => internalFormatString.endsWith(suffix))?.[1];\n}\n\ntype GLConstantString = GLInternalFormatString | GLFormatString | GLTypeString | GLFilterString | GLWrapString;\n\nexport interface TextureOptions {\n\tinternalFormat?: GLInternalFormatString;\n\tformat?: GLFormatString;\n\ttype?: GLTypeString;\n\tminFilter?: GLFilterString;\n\tmagFilter?: GLFilterString;\n\twrapS?: GLWrapString;\n\twrapT?: GLWrapString;\n\tpreserveY?: boolean;\n}\ntype ResolvedTextureOptions = {\n\ttype: number;\n\tformat: number;\n\tinternalFormat: number;\n\tminFilter: number;\n\tmagFilter: number;\n\twrapS: number;\n\twrapT: number;\n\tpreserveY?: boolean;\n\tisIntegerColorFormat: boolean;\n};\n\ninterface Texture {\n\ttexture: WebGLTexture;\n\tunitIndex: number;\n\twidth: number;\n\theight: number;\n\thistory?: {\n\t\tdepth: number;\n\t\twriteIndex: number;\n\t};\n\toptions: ResolvedTextureOptions;\n}\n\nexport interface CustomTexture {\n\tdata: ArrayBufferView | null;\n\twidth: number;\n\theight: number;\n}\n\nexport interface PartialCustomTexture extends CustomTexture {\n\tisPartial?: boolean;\n\tx?: number;\n\ty?: number;\n}\n\nexport interface InitializeTextureOptions extends TextureOptions {\n\thistory?: number;\n}\n\nexport type TextureSource =\n\t| HTMLImageElement\n\t| HTMLVideoElement\n\t| HTMLCanvasElement\n\t| OffscreenCanvas\n\t| ImageBitmap\n\t| WebGLTexture\n\t| CustomTexture\n\t| ShaderPad;\n\n// Custom textures allow partial updates starting from (x, y).\nexport type UpdateTextureSource = Exclude<TextureSource, CustomTexture> | PartialCustomTexture;\n\nexport interface PluginContext {\n\tinjectGLSL: (code: string) => void;\n\temit: (name: ShaderPadEventName, ...args: any[]) => void;\n\tupdateTexture: (name: string, source: UpdateTextureSource, historySlots?: HistorySlots) => void;\n}\n\nexport type Plugin = (shaderPad: ShaderPad, context: PluginContext) => void;\n\nexport type ShaderPadEventName =\n\t| '_init'\n\t| 'initializeTexture'\n\t| 'initializeUniform'\n\t| 'updateTextures'\n\t| 'updateUniforms'\n\t| 'beforeStep'\n\t| 'afterStep'\n\t| 'beforeDraw'\n\t| 'afterDraw'\n\t| 'updateResolution'\n\t| 'play'\n\t| 'pause'\n\t| 'reset'\n\t| 'destroy'\n\t| `${string}:${string}`;\n\nexport type RenderTextureOptions = Omit<TextureOptions, 'preserveY'>;\n\nexport interface Options extends RenderTextureOptions {\n\tcanvas?: HTMLCanvasElement | OffscreenCanvas | { width: number; height: number } | null;\n\tplugins?: Plugin[];\n\thistory?: number;\n\tcursorTarget?: Window | Element;\n}\n\nexport interface StepOptions {\n\tskipClear?: boolean;\n\tskipHistory?: boolean;\n}\n\ntype HistorySlots = number | number[];\n\ntype TextureUnitPool = {\n\tfree: number[];\n\tnext: number;\n\tmax: number;\n};\n\nconst HISTORY_TEXTURE_KEY = Symbol('u_history');\nconst INTERMEDIATE_TEXTURE_KEY = Symbol('__SHADERPAD_BUFFER');\n\nconst canvasRegistry = new WeakMap<\n\tHTMLCanvasElement | OffscreenCanvas,\n\t{ textureUnitPool: TextureUnitPool; instances: Set<ShaderPad> }\n>();\n\nfunction combineShaderCode(shader: string, injections: string[]): string {\n\tif (!injections?.length) return shader;\n\tconst lines = shader.split('\\n');\n\tconst insertAt =\n\t\tlines.findLastIndex(line => {\n\t\t\tconst trimmed = line.trimStart();\n\t\t\treturn trimmed.startsWith('precision ') || trimmed.startsWith('#version ');\n\t\t}) + 1;\n\tlines.splice(insertAt, 0, ...injections);\n\treturn lines.join('\\n');\n}\n\nfunction getSourceDimensions(source: TextureSource): {\n\twidth: number;\n\theight: number;\n} {\n\tif (source instanceof WebGLTexture) {\n\t\treturn { width: 0, height: 0 }; // Invalid - dimensions not readable.\n\t}\n\tif (source instanceof ShaderPad) {\n\t\treturn { width: source.canvas.width, height: source.canvas.height };\n\t}\n\tif (source instanceof HTMLVideoElement) {\n\t\treturn { width: source.videoWidth, height: source.videoHeight };\n\t}\n\tif (source instanceof HTMLImageElement) {\n\t\treturn {\n\t\t\twidth: source.naturalWidth ?? source.width,\n\t\t\theight: source.naturalHeight ?? source.height,\n\t\t};\n\t}\n\t// CustomTexture, HTMLCanvasElement, OffscreenCanvas, ImageBitmap.\n\treturn { width: source.width, height: source.height };\n}\n\nfunction stringFrom(name: string | symbol) {\n\treturn typeof name === 'symbol' ? (name.description ?? '') : name;\n}\n\nclass ShaderPad {\n\tprivate isHeadless = false;\n\tprivate isTouchDevice = false;\n\tpublic readonly gl: WebGL2RenderingContext;\n\tprivate glHelpers!: {\n\t\ttypeToArray: Map<number, new (length: number) => ArrayBufferView>;\n\t\ttypeToInternalFormatString: Map<number, GLInternalFormatString>;\n\t\tunsignedIntTypes: Set<number>;\n\t};\n\tprivate uniforms: Map<string, Uniform> = new Map();\n\tprivate textures: Map<string | symbol, Texture> = new Map();\n\tprivate textureUnitPool: TextureUnitPool;\n\tprivate buffer: WebGLBuffer | null = null;\n\tprivate vao: WebGLVertexArrayObject | null = null;\n\tprivate program: WebGLProgram | null = null;\n\tprivate animationFrameId: number | null;\n\tprivate eventListeners: Map<string, EventListener> = new Map();\n\tprivate frame = 0;\n\tprivate startTime = Number.NaN;\n\tprivate isPlaying = false;\n\tprivate cursorPosition = [0.5, 0.5];\n\tprivate clickPosition = [0.5, 0.5];\n\tprivate isMouseDown = false;\n\tpublic canvas: HTMLCanvasElement | OffscreenCanvas;\n\tprivate resolutionObserver: MutationObserver | null = null;\n\tprivate hooks: Map<ShaderPadEventName, Function[]> = new Map();\n\tprivate historyDepth = 0;\n\tprivate textureOptions: TextureOptions;\n\tprivate cursorTarget: Window | Element | undefined;\n\t// WebGL can’t read from and write to the history texture at the same time.\n\t// We write to an intermediate texture then blit to the history texture.\n\tprivate intermediateFbo: WebGLFramebuffer | null = null;\n\n\tconstructor(\n\t\tfragmentShaderSrc: string,\n\t\t{ canvas, plugins, history, cursorTarget, ...textureOptions }: Options = {},\n\t) {\n\t\tif (canvas && 'getContext' in canvas) {\n\t\t\tthis.canvas = canvas;\n\t\t} else {\n\t\t\tconst { width = 1, height = 1 } = canvas || {};\n\t\t\tthis.canvas = new OffscreenCanvas(width, height);\n\t\t\tthis.isHeadless = true;\n\t\t}\n\n\t\tconst gl = this.canvas.getContext('webgl2', {\n\t\t\tantialias: false,\n\t\t}) as WebGL2RenderingContext;\n\t\tif (!gl) {\n\t\t\tthrow spError(\n\t\t\t\t0,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tcanvasType: this.canvas.constructor.name,\n\t\t\t\t\tisHeadless: this.isHeadless,\n\t\t\t\t\tcanvasWidth: this.canvas.width,\n\t\t\t\t\tcanvasHeight: this.canvas.height,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tthis.gl = gl;\n\t\tthis.glHelpers = {\n\t\t\ttypeToArray: new Map<number, new (length: number) => ArrayBufferView>([\n\t\t\t\t[gl.FLOAT, Float32Array],\n\t\t\t\t[gl.HALF_FLOAT, Uint16Array],\n\t\t\t\t[gl.UNSIGNED_SHORT, Uint16Array],\n\t\t\t\t[gl.SHORT, Int16Array],\n\t\t\t\t[gl.BYTE, Int8Array],\n\t\t\t\t[gl.UNSIGNED_INT, Uint32Array],\n\t\t\t\t[gl.INT, Int32Array],\n\t\t\t]),\n\t\t\ttypeToInternalFormatString: new Map<number, GLInternalFormatString>([\n\t\t\t\t[gl.FLOAT, 'RGBA32F'],\n\t\t\t\t[gl.HALF_FLOAT, 'RGBA16F'],\n\t\t\t\t[gl.UNSIGNED_SHORT, 'RGBA32UI'],\n\t\t\t\t[gl.SHORT, 'RGBA32I'],\n\t\t\t\t[gl.BYTE, 'RGBA32I'],\n\t\t\t\t[gl.UNSIGNED_INT, 'RGBA32UI'],\n\t\t\t\t[gl.INT, 'RGBA32I'],\n\t\t\t]),\n\t\t\tunsignedIntTypes: new Set([gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.UNSIGNED_INT]),\n\t\t};\n\n\t\tlet registryEntry = canvasRegistry.get(this.canvas);\n\t\tif (!registryEntry) {\n\t\t\tregistryEntry = {\n\t\t\t\ttextureUnitPool: {\n\t\t\t\t\tfree: [],\n\t\t\t\t\tnext: 0,\n\t\t\t\t\tmax: gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n\t\t\t\t},\n\t\t\t\tinstances: new Set([this]),\n\t\t\t};\n\t\t\tcanvasRegistry.set(this.canvas, registryEntry);\n\t\t}\n\t\tthis.textureUnitPool = registryEntry.textureUnitPool;\n\t\tregistryEntry.instances.add(this);\n\n\t\tthis.textureOptions = textureOptions;\n\n\t\tif (history) this.historyDepth = history;\n\t\tthis.cursorTarget = cursorTarget ?? (this.canvas instanceof HTMLCanvasElement ? this.canvas : undefined);\n\t\tthis.animationFrameId = null;\n\n\t\tconst glslInjections: string[] = [];\n\t\tif (plugins) {\n\t\t\tplugins.forEach(plugin =>\n\t\t\t\tplugin(this, {\n\t\t\t\t\tinjectGLSL: (code: string) => {\n\t\t\t\t\t\tglslInjections.push(code);\n\t\t\t\t\t},\n\t\t\t\t\temit: this.emit.bind(this),\n\t\t\t\t\tupdateTexture: this.updateTexture.bind(this),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst program = this.gl.createProgram();\n\t\tif (!program) {\n\t\t\tthrow spError(1);\n\t\t}\n\t\tthis.program = program;\n\n\t\tconst vertexShader = this.createShader(this.gl.VERTEX_SHADER, DEFAULT_VERTEX_SHADER_SRC);\n\t\tconst fragmentShader = this.createShader(\n\t\t\tgl.FRAGMENT_SHADER,\n\t\t\tcombineShaderCode(fragmentShaderSrc, glslInjections),\n\t\t);\n\t\tgl.attachShader(program, vertexShader);\n\t\tgl.attachShader(program, fragmentShader);\n\t\tgl.bindAttribLocation(program, 0, 'a_position');\n\t\tgl.linkProgram(program);\n\t\tgl.deleteShader(vertexShader);\n\t\tgl.deleteShader(fragmentShader);\n\n\t\tif (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n\t\t\tconst programInfoLog = gl.getProgramInfoLog(program);\n\t\t\tconst linkError = spError(\n\t\t\t\t2,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tprogramInfoLog,\n\t\t\t\t\tfragmentShaderLength: fragmentShaderSrc.length,\n\t\t\t\t\tglslInjectionCount: glslInjections.length,\n\t\t\t\t},\n\t\t\t);\n\t\t\tgl.deleteProgram(program);\n\t\t\tthrow linkError;\n\t\t}\n\n\t\tthis.vao = gl.createVertexArray();\n\t\tgl.bindVertexArray(this.vao);\n\t\tthis.buffer = gl.createBuffer();\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n\t\tgl.enableVertexAttribArray(0);\n\t\tgl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n\n\t\tgl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);\n\n\t\tgl.useProgram(program);\n\n\t\tif (this.canvas instanceof HTMLCanvasElement) {\n\t\t\tthis.resolutionObserver = new MutationObserver(() => this.syncResolution());\n\t\t\tthis.resolutionObserver.observe(this.canvas, {\n\t\t\t\tattributes: true,\n\t\t\t\tattributeFilter: ['width', 'height'],\n\t\t\t});\n\t\t} else {\n\t\t\tconst wrapDimension = (dimension: 'width' | 'height') => {\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(OffscreenCanvas.prototype, dimension)!;\n\t\t\t\tconst canvas = this.canvas;\n\t\t\t\tObject.defineProperty(canvas, dimension, {\n\t\t\t\t\tget: () => descriptor.get!.call(canvas),\n\t\t\t\t\tset: v => {\n\t\t\t\t\t\tdescriptor.set!.call(canvas, v);\n\t\t\t\t\t\tconst entry = canvasRegistry.get(canvas);\n\t\t\t\t\t\tif (entry) {\n\t\t\t\t\t\t\tfor (const instance of entry.instances) {\n\t\t\t\t\t\t\t\tinstance.syncResolution();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tconfigurable: descriptor.configurable,\n\t\t\t\t\tenumerable: descriptor.enumerable,\n\t\t\t\t});\n\t\t\t};\n\t\t\twrapDimension('width');\n\t\t\twrapDimension('height');\n\t\t}\n\t\tthis.syncResolution();\n\n\t\tthis.initializeUniform('u_cursor', 'float', this.cursorPosition, { allowMissing: true });\n\t\tthis.initializeUniform('u_click', 'float', [...this.clickPosition, this.isMouseDown ? 1.0 : 0.0], {\n\t\t\tallowMissing: true,\n\t\t});\n\t\tthis.initializeUniform('u_time', 'float', 0, { allowMissing: true });\n\t\tthis.initializeUniform('u_frame', 'int', 0, { allowMissing: true });\n\n\t\tthis._initializeTexture(INTERMEDIATE_TEXTURE_KEY, this.canvas, {\n\t\t\t...this.textureOptions,\n\t\t});\n\t\tthis.intermediateFbo = gl.createFramebuffer();\n\t\tthis.bindIntermediate();\n\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\n\t\tif (this.historyDepth > 0) {\n\t\t\tthis._initializeTexture(HISTORY_TEXTURE_KEY, this.canvas, {\n\t\t\t\thistory: this.historyDepth,\n\t\t\t\t...this.textureOptions,\n\t\t\t});\n\t\t}\n\t\tthis.addEventListeners();\n\t\tthis.emit('_init');\n\t}\n\n\tprivate resolveGLConstant(value: GLConstantString): number {\n\t\tconst resolved = this.gl[value];\n\t\tif (resolved === undefined) {\n\t\t\tthrow spError(3, __SHADERPAD_DEV__ && { value });\n\t\t}\n\t\treturn resolved;\n\t}\n\n\tprivate emit(name: ShaderPadEventName, ...args: any[]) {\n\t\tthis.hooks.get(name)?.forEach(hook => hook.call(this, ...args));\n\t}\n\n\ton(name: ShaderPadEventName, fn: Function) {\n\t\tif (!this.hooks.has(name)) {\n\t\t\tthis.hooks.set(name, []);\n\t\t}\n\t\tthis.hooks.get(name)!.push(fn);\n\t}\n\n\toff(name: ShaderPadEventName, fn: Function) {\n\t\tconst hooks = this.hooks.get(name);\n\t\tif (hooks) {\n\t\t\tconst index = hooks.indexOf(fn);\n\t\t\tif (index >= 0) {\n\t\t\t\thooks.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createShader(type: number, source: string): WebGLShader {\n\t\tconst shader = this.gl.createShader(type)!;\n\t\tthis.gl.shaderSource(shader, source);\n\t\tthis.gl.compileShader(shader);\n\t\tif (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n\t\t\tconst shaderInfoLog = this.gl.getShaderInfoLog(shader);\n\t\t\tconst shaderType = type === this.gl.VERTEX_SHADER ? 'vertex' : 'fragment';\n\t\t\tconst compilationError = spError(\n\t\t\t\t4,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tshaderType,\n\t\t\t\t\tshaderInfoLog,\n\t\t\t\t\tsource,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.gl.deleteShader(shader);\n\t\t\tthrow compilationError;\n\t\t}\n\t\treturn shader;\n\t}\n\n\tprivate getCursorTargetRect(): {\n\t\tleft: number;\n\t\ttop: number;\n\t\twidth: number;\n\t\theight: number;\n\t} {\n\t\tconst target = this.cursorTarget!;\n\t\tif (target === window) {\n\t\t\treturn {\n\t\t\t\tleft: 0,\n\t\t\t\ttop: 0,\n\t\t\t\twidth: window.innerWidth,\n\t\t\t\theight: window.innerHeight,\n\t\t\t};\n\t\t}\n\t\treturn (target as Element).getBoundingClientRect();\n\t}\n\n\tprivate addEventListeners() {\n\t\tif (!this.cursorTarget) return;\n\t\tconst updateCursor = (x: number, y: number) => {\n\t\t\tif (!this.uniforms.has('u_cursor')) return;\n\t\t\tconst rect = this.getCursorTargetRect();\n\t\t\tconst u = (x - rect.left) / rect.width;\n\t\t\tconst v = 1 - (y - rect.top) / rect.height; // Flip Y for WebGL\n\t\t\tthis.cursorPosition[0] = Math.max(0, Math.min(1, u));\n\t\t\tthis.cursorPosition[1] = Math.max(0, Math.min(1, v));\n\t\t\tthis.updateUniforms({ u_cursor: this.cursorPosition });\n\t\t};\n\n\t\tconst updateClick = (isMouseDown: boolean, x?: number, y?: number) => {\n\t\t\tif (!this.uniforms.has('u_click')) return;\n\t\t\tthis.isMouseDown = isMouseDown;\n\t\t\tif (isMouseDown) {\n\t\t\t\tconst rect = this.getCursorTargetRect();\n\t\t\t\tconst xVal = x as number;\n\t\t\t\tconst yVal = y as number;\n\t\t\t\tthis.clickPosition[0] = Math.max(0, Math.min(1, (xVal - rect.left) / rect.width));\n\t\t\t\tthis.clickPosition[1] = Math.max(0, Math.min(1, 1 - (yVal - rect.top) / rect.height)); // Flip Y for WebGL\n\t\t\t}\n\t\t\tthis.updateUniforms({\n\t\t\t\tu_click: [...this.clickPosition, this.isMouseDown ? 1.0 : 0.0],\n\t\t\t});\n\t\t};\n\n\t\tthis.eventListeners.set('mousemove', event => {\n\t\t\tconst mouseEvent = event as MouseEvent;\n\t\t\tif (!this.isTouchDevice) {\n\t\t\t\tupdateCursor(mouseEvent.clientX, mouseEvent.clientY);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('mousedown', event => {\n\t\t\tconst mouseEvent = event as MouseEvent;\n\t\t\tif (!this.isTouchDevice) {\n\t\t\t\tif (mouseEvent.button === 0) {\n\t\t\t\t\tthis.isMouseDown = true;\n\t\t\t\t\tupdateClick(true, mouseEvent.clientX, mouseEvent.clientY);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('mouseup', event => {\n\t\t\tconst mouseEvent = event as MouseEvent;\n\t\t\tif (!this.isTouchDevice) {\n\t\t\t\tif (mouseEvent.button === 0) {\n\t\t\t\t\tupdateClick(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('touchmove', event => {\n\t\t\tconst touchEvent = event as TouchEvent;\n\t\t\tif (touchEvent.touches.length > 0) {\n\t\t\t\tupdateCursor(touchEvent.touches[0].clientX, touchEvent.touches[0].clientY);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('touchstart', event => {\n\t\t\tconst touchEvent = event as TouchEvent;\n\t\t\tthis.isTouchDevice = true;\n\t\t\tif (touchEvent.touches.length > 0) {\n\t\t\t\tupdateCursor(touchEvent.touches[0].clientX, touchEvent.touches[0].clientY);\n\t\t\t\tupdateClick(true, touchEvent.touches[0].clientX, touchEvent.touches[0].clientY);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.set('touchend', event => {\n\t\t\tconst touchEvent = event as TouchEvent;\n\t\t\tif (touchEvent.touches.length === 0) {\n\t\t\t\tupdateClick(false);\n\t\t\t}\n\t\t});\n\n\t\tthis.eventListeners.forEach((listener, event) => {\n\t\t\tthis.cursorTarget!.addEventListener(event, listener);\n\t\t});\n\t}\n\n\tprivate syncResolution() {\n\t\tconst resolution: [number, number] = [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n\t\tthis.gl.viewport(0, 0, ...resolution);\n\t\tif (this.uniforms.has('u_resolution')) {\n\t\t\tthis.updateUniforms({ u_resolution: resolution });\n\t\t} else {\n\t\t\tthis.initializeUniform('u_resolution', 'float', resolution, { allowMissing: true });\n\t\t}\n\t\tthis.resizeTexture(INTERMEDIATE_TEXTURE_KEY, ...resolution);\n\t\tif (this.historyDepth > 0) {\n\t\t\tthis.resizeTexture(HISTORY_TEXTURE_KEY, ...resolution);\n\t\t}\n\t\tthis.emit('updateResolution', ...resolution);\n\t}\n\n\tprivate resizeTexture(name: string | symbol, width: number, height: number) {\n\t\tconst info = this.textures.get(name);\n\t\tif (!info || (info.width === width && info.height === height)) return;\n\n\t\tthis.gl.deleteTexture(info.texture);\n\t\tinfo.width = width;\n\t\tinfo.height = height;\n\t\tconst { texture } = this.createTexture(name, info);\n\t\tinfo.texture = texture;\n\t\tthis.resetHistoryTextureState(name, info);\n\t}\n\n\tprivate reserveTextureUnit(name: string | symbol) {\n\t\tconst existing = this.textures.get(name);\n\t\tif (existing) return existing.unitIndex;\n\t\tif (this.textureUnitPool.free.length > 0) return this.textureUnitPool.free.pop()!;\n\t\tif (this.textureUnitPool.next >= this.textureUnitPool.max) {\n\t\t\tthrow spError(\n\t\t\t\t5,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname: stringFrom(name),\n\t\t\t\t\tnextTextureUnit: this.textureUnitPool.next,\n\t\t\t\t\tmaxTextureUnits: this.textureUnitPool.max,\n\t\t\t\t\tfreeTextureUnits: this.textureUnitPool.free.length,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn this.textureUnitPool.next++;\n\t}\n\n\tprivate resolveTextureOptions(options?: TextureOptions): ResolvedTextureOptions {\n\t\tconst { gl } = this;\n\t\tconst internalFormatOption = options?.internalFormat;\n\t\tconst typeString = options?.type ?? typeFromInternalFormatString(internalFormatOption) ?? 'UNSIGNED_BYTE';\n\t\tconst type = this.resolveGLConstant(typeString);\n\t\tconst internalFormatString =\n\t\t\tinternalFormatOption ?? this.glHelpers.typeToInternalFormatString.get(type) ?? 'RGBA8';\n\t\tconst isIntegerColorFormat = /^(R|RG|RGB|RGBA)(8|16|32)(UI|I)$/.test(internalFormatString);\n\t\tconst formatString = options?.format ?? (isIntegerColorFormat ? 'RGBA_INTEGER' : 'RGBA');\n\t\tconst result: ResolvedTextureOptions = {\n\t\t\ttype,\n\t\t\tformat: this.resolveGLConstant(formatString),\n\t\t\tinternalFormat: this.resolveGLConstant(internalFormatString),\n\t\t\tminFilter: this.resolveGLConstant(options?.minFilter ?? 'LINEAR'),\n\t\t\tmagFilter: this.resolveGLConstant(options?.magFilter ?? 'LINEAR'),\n\t\t\twrapS: this.resolveGLConstant(options?.wrapS ?? 'CLAMP_TO_EDGE'),\n\t\t\twrapT: this.resolveGLConstant(options?.wrapT ?? 'CLAMP_TO_EDGE'),\n\t\t\tpreserveY: options?.preserveY,\n\t\t\tisIntegerColorFormat,\n\t\t};\n\t\tconst isFloatColorFormat = result.internalFormat === gl.RGBA16F || result.internalFormat === gl.RGBA32F;\n\t\t// gl.getExtension isn’t just a check, it’s a required side-effect to enable floats.\n\t\tif (isFloatColorFormat && !gl.getExtension('EXT_color_buffer_float')) {\n\t\t\tthrow spError(\n\t\t\t\t6,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tinternalFormat: internalFormatString,\n\t\t\t\t\ttype: typeString,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate getPixelArray(type: number, size: number): ArrayBufferView {\n\t\tconst ArrayType = this.glHelpers.typeToArray.get(type) ?? Uint8Array;\n\t\treturn new ArrayType(size);\n\t}\n\n\tprivate isNotRgba(format: number): boolean {\n\t\treturn format !== this.gl.RGBA && format !== this.gl.RGBA_INTEGER;\n\t}\n\n\tprivate clearHistoryTextureLayers(textureInfo: Texture): void {\n\t\tif (!textureInfo.history) return;\n\n\t\tconst gl = this.gl;\n\t\tconst { type, format } = textureInfo.options;\n\t\tconst transparent = this.getPixelArray(type, textureInfo.width * textureInfo.height * 4);\n\t\tgl.activeTexture(gl.TEXTURE0 + textureInfo.unitIndex);\n\t\tgl.bindTexture(gl.TEXTURE_2D_ARRAY, textureInfo.texture);\n\t\tconst needsAlignmentFix = this.isNotRgba(format);\n\t\tlet previousAlignment;\n\t\tif (needsAlignmentFix) {\n\t\t\tpreviousAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);\n\t\t\tgl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n\t\t}\n\t\tfor (let layer = 0; layer < textureInfo.history.depth; ++layer) {\n\t\t\tgl.texSubImage3D(\n\t\t\t\tgl.TEXTURE_2D_ARRAY,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tlayer,\n\t\t\t\ttextureInfo.width,\n\t\t\t\ttextureInfo.height,\n\t\t\t\t1,\n\t\t\t\tformat,\n\t\t\t\ttype,\n\t\t\t\ttransparent,\n\t\t\t);\n\t\t}\n\t\tif (needsAlignmentFix) gl.pixelStorei(gl.UNPACK_ALIGNMENT, previousAlignment);\n\t}\n\n\tprivate updateTextureFrameOffset(\n\t\tname: string | symbol,\n\t\tframeOffset: number,\n\t\toptions?: {\n\t\t\tallowMissing?: boolean;\n\t\t},\n\t) {\n\t\tthis.updateUniforms(\n\t\t\t{\n\t\t\t\t[`${stringFrom(name)}FrameOffset`]: frameOffset,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t}\n\n\tprivate resetHistoryTextureState(name: string | symbol, textureInfo: Texture) {\n\t\tif (!textureInfo.history) return;\n\t\ttextureInfo.history.writeIndex = 0;\n\t\tthis.clearHistoryTextureLayers(textureInfo);\n\t\tthis.updateTextureFrameOffset(name, 0, { allowMissing: true });\n\t}\n\n\tinitializeUniform(\n\t\tname: string,\n\t\ttype: Uniform['type'],\n\t\tvalue: number | number[] | (number | number[])[],\n\t\toptions?: { arrayLength?: number; allowMissing?: boolean },\n\t) {\n\t\tconst arrayLength = options?.arrayLength;\n\t\tconst allowMissing = options?.allowMissing ?? false;\n\t\tif (this.uniforms.has(name)) {\n\t\t\tthrow spError(7, __SHADERPAD_DEV__ && { name, arrayLength: arrayLength ?? null });\n\t\t}\n\t\tif (!UNIFORM_TYPE_SUFFIXES[type]) {\n\t\t\tthrow spError(\n\t\t\t\t8,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname,\n\t\t\t\t\ttype,\n\t\t\t\t\tsupportedTypes: Object.keys(UNIFORM_TYPE_SUFFIXES),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tif (arrayLength && !(Array.isArray(value) && value.length === arrayLength)) {\n\t\t\tthrow spError(\n\t\t\t\t9,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname,\n\t\t\t\t\texpectedLength: arrayLength,\n\t\t\t\t\treceivedLength: Array.isArray(value) ? value.length : 1,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tlet location = this.gl.getUniformLocation(this.program!, name);\n\t\tif (!location && arrayLength) {\n\t\t\tlocation = this.gl.getUniformLocation(this.program!, `${name}[0]`);\n\t\t}\n\t\tif (!location) {\n\t\t\tif (allowMissing) return;\n\t\t\tthrow spError(19, __SHADERPAD_DEV__ && { name, arrayLength: arrayLength ?? null });\n\t\t}\n\n\t\tconst probeValue = arrayLength ? (value as number[] | number[][])[0] : value;\n\t\tconst length = Array.isArray(probeValue) ? (probeValue.length as 1 | 2 | 3 | 4) : 1;\n\t\tthis.uniforms.set(name, { type, length, location, arrayLength });\n\n\t\ttry {\n\t\t\tthis.updateUniforms({ [name]: value });\n\t\t} catch (error) {\n\t\t\tthis.uniforms.delete(name);\n\t\t\tthrow error;\n\t\t}\n\t\tthis.emit('initializeUniform', ...arguments);\n\t}\n\n\tupdateUniforms(\n\t\tupdates: Record<string, number | number[] | (number | number[])[]>,\n\t\toptions?: { startIndex?: number; allowMissing?: boolean },\n\t) {\n\t\tthis.gl.useProgram(this.program);\n\t\tObject.entries(updates).forEach(([name, newValue]) => {\n\t\t\tconst uniform = this.uniforms.get(name);\n\t\t\tif (!uniform) {\n\t\t\t\tif (options?.allowMissing) return;\n\t\t\t\tthrow spError(\n\t\t\t\t\t20,\n\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tstartIndex: options?.startIndex ?? null,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet glFunctionName = `uniform${uniform.length}${UNIFORM_TYPE_SUFFIXES[uniform.type]}`;\n\t\t\tif (uniform.arrayLength) {\n\t\t\t\tif (!Array.isArray(newValue)) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t10,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\treceivedType: typeof newValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst nValues = newValue.length;\n\t\t\t\tif (!nValues) return;\n\t\t\t\tif (nValues > uniform.arrayLength) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t11,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\treceivedLength: nValues,\n\t\t\t\t\t\t\tmaxLength: uniform.arrayLength,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (newValue.some(item => (Array.isArray(item) ? item.length : 1) !== uniform.length)) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t12,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\texpectedElementLength: uniform.length,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst flat = newValue.flat();\n\t\t\t\tconst typedArray =\n\t\t\t\t\tuniform.type === 'float'\n\t\t\t\t\t\t? new Float32Array(flat)\n\t\t\t\t\t\t: uniform.type === 'uint'\n\t\t\t\t\t\t\t? new Uint32Array(flat)\n\t\t\t\t\t\t\t: new Int32Array(flat);\n\t\t\t\tlet location = uniform.location;\n\t\t\t\tif (options?.startIndex) {\n\t\t\t\t\tconst newLocation = this.gl.getUniformLocation(this.program!, `${name}[${options.startIndex}]`);\n\t\t\t\t\tif (!newLocation) {\n\t\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t\t13,\n\t\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tstartIndex: options.startIndex,\n\t\t\t\t\t\t\t\tarrayLength: uniform.arrayLength,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tlocation = newLocation;\n\t\t\t\t}\n\t\t\t\t(this.gl as any)[glFunctionName + 'v'](location, typedArray);\n\t\t\t} else {\n\t\t\t\tif (!Array.isArray(newValue)) newValue = [newValue];\n\t\t\t\tconst scalarValue = newValue as number[];\n\t\t\t\tif (scalarValue.length !== uniform.length) {\n\t\t\t\t\tthrow spError(\n\t\t\t\t\t\t14,\n\t\t\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\treceivedLength: scalarValue.length,\n\t\t\t\t\t\t\texpectedLength: uniform.length,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t(this.gl as any)[glFunctionName](uniform.location, ...scalarValue);\n\t\t\t}\n\t\t});\n\t\tthis.emit('updateUniforms', ...arguments);\n\t}\n\n\tprivate createTexture(\n\t\tname: string | symbol,\n\t\ttextureInfo: Pick<Texture, 'width' | 'height' | 'history' | 'options'> & { unitIndex?: number },\n\t) {\n\t\tconst { width, height } = textureInfo;\n\t\tconst historyDepth = textureInfo.history?.depth ?? 0;\n\n\t\tconst texture = this.gl.createTexture();\n\t\tif (!texture) {\n\t\t\tthrow spError(\n\t\t\t\t15,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname: stringFrom(name),\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\thistoryDepth,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tlet unitIndex = textureInfo.unitIndex;\n\t\tif (typeof unitIndex !== 'number') {\n\t\t\ttry {\n\t\t\t\tunitIndex = this.reserveTextureUnit(name);\n\t\t\t} catch (error) {\n\t\t\t\tthis.gl.deleteTexture(texture);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tconst hasHistory = historyDepth > 0;\n\t\tconst textureTarget = hasHistory ? this.gl.TEXTURE_2D_ARRAY : this.gl.TEXTURE_2D;\n\t\tconst { options } = textureInfo;\n\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + unitIndex);\n\t\tthis.gl.bindTexture(textureTarget, texture);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_WRAP_S, options.wrapS);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_WRAP_T, options.wrapT);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_MIN_FILTER, options.minFilter);\n\t\tthis.gl.texParameteri(textureTarget, this.gl.TEXTURE_MAG_FILTER, options.magFilter);\n\t\tif (hasHistory) {\n\t\t\tthis.gl.texStorage3D(textureTarget, 1, options.internalFormat, width, height, historyDepth);\n\t\t} else if (name === INTERMEDIATE_TEXTURE_KEY) {\n\t\t\tthis.gl.texImage2D(\n\t\t\t\tthis.gl.TEXTURE_2D,\n\t\t\t\t0,\n\t\t\t\toptions.internalFormat,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\t0,\n\t\t\t\toptions.format,\n\t\t\t\toptions.type,\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\t\treturn { texture, unitIndex };\n\t}\n\n\tprivate _initializeTexture(name: string | symbol, source: TextureSource, options?: InitializeTextureOptions) {\n\t\tif (this.textures.has(name)) {\n\t\t\tthrow spError(16, __SHADERPAD_DEV__ && { name: stringFrom(name) });\n\t\t}\n\n\t\tconst { history: historyDepth = 0, ...textureOptions } = options ?? {};\n\t\tconst { width, height } = getSourceDimensions(source);\n\t\tif (!width || !height) {\n\t\t\tthrow spError(\n\t\t\t\t17,\n\t\t\t\t__SHADERPAD_DEV__ && {\n\t\t\t\t\tname: stringFrom(name),\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tsourceType: source.constructor.name,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst textureInfo: Pick<Texture, 'width' | 'height' | 'history' | 'options'> = {\n\t\t\twidth,\n\t\t\theight,\n\t\t\toptions:\n\t\t\t\tsource instanceof ShaderPad &&\n\t\t\t\tObject.keys(textureOptions).length === 0 &&\n\t\t\t\tsource.textures.has(INTERMEDIATE_TEXTURE_KEY)\n\t\t\t\t\t? source.textures.get(INTERMEDIATE_TEXTURE_KEY)!.options\n\t\t\t\t\t: this.resolveTextureOptions(textureOptions),\n\t\t};\n\t\tif (historyDepth > 0) {\n\t\t\ttextureInfo.history = { depth: historyDepth, writeIndex: 0 };\n\t\t}\n\t\tconst { texture, unitIndex } = this.createTexture(name, textureInfo);\n\t\tconst completeTextureInfo: Texture = {\n\t\t\ttexture,\n\t\t\tunitIndex,\n\t\t\t...textureInfo,\n\t\t};\n\t\tif (historyDepth > 0) {\n\t\t\tthis.initializeUniform(`${stringFrom(name)}FrameOffset`, 'int', 0, { allowMissing: true });\n\t\t\tthis.clearHistoryTextureLayers(completeTextureInfo);\n\t\t}\n\t\tthis.textures.set(name, completeTextureInfo);\n\t\tif (name !== INTERMEDIATE_TEXTURE_KEY && name !== HISTORY_TEXTURE_KEY) {\n\t\t\tthis.updateTexture(name, source);\n\t\t}\n\n\t\t// Set a uniform to access the texture in the fragment shader.\n\t\tthis.gl.useProgram(this.program!);\n\t\tconst uSampler = this.gl.getUniformLocation(this.program!, stringFrom(name));\n\t\tif (uSampler) {\n\t\t\tthis.gl.uniform1i(uSampler, unitIndex);\n\t\t}\n\t}\n\n\tinitializeTexture(name: string, source: TextureSource, options?: InitializeTextureOptions) {\n\t\t// Since history[0] is the current frame, add 1 to history depth to allow history[maxHistory].\n\t\tconst opts =\n\t\t\toptions?.history != null && options.history > 0 ? { ...options, history: options.history + 1 } : options;\n\t\tthis._initializeTexture(name, source, opts);\n\t\tthis.emit('initializeTexture', ...arguments);\n\t}\n\n\tupdateTextures(updates: Record<string, UpdateTextureSource>) {\n\t\tObject.entries(updates).forEach(([name, source]) => {\n\t\t\tthis.updateTexture(name, source);\n\t\t});\n\t\tthis.emit('updateTextures', ...arguments);\n\t}\n\n\tprivate updateTexture(name: string | symbol, source: UpdateTextureSource, historySlots?: HistorySlots) {\n\t\tconst info = this.textures.get(name);\n\t\tif (!info) {\n\t\t\tthrow spError(18, __SHADERPAD_DEV__ && { name: stringFrom(name) });\n\t\t}\n\n\t\tif (source instanceof WebGLTexture) {\n\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D, source);\n\t\t\treturn;\n\t\t}\n\n\t\tlet nonShaderPadSource = source as Exclude<UpdateTextureSource, ShaderPad>;\n\t\tif (source instanceof ShaderPad) {\n\t\t\tconst sourceIntermediateInfo = source.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\t\tconst srcW = sourceIntermediateInfo.width;\n\t\t\tconst srcH = sourceIntermediateInfo.height;\n\n\t\t\tif (source.gl === this.gl) {\n\t\t\t\tif (!info.history) {\n\t\t\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D, sourceIntermediateInfo.texture);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { depth } = info.history;\n\t\t\t\tconst targetSlots =\n\t\t\t\t\thistorySlots === undefined\n\t\t\t\t\t\t? [info.history.writeIndex]\n\t\t\t\t\t\t: Array.isArray(historySlots)\n\t\t\t\t\t\t\t? historySlots.map(i => safeMod(i, depth))\n\t\t\t\t\t\t\t: [safeMod(historySlots, depth)];\n\t\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, info.texture);\n\t\t\t\tthis.gl.bindFramebuffer(this.gl.READ_FRAMEBUFFER, source.intermediateFbo);\n\t\t\t\tfor (const slot of targetSlots) {\n\t\t\t\t\tthis.gl.copyTexSubImage3D(this.gl.TEXTURE_2D_ARRAY, 0, 0, 0, slot, 0, 0, srcW, srcH);\n\t\t\t\t}\n\t\t\t\tthis.gl.bindFramebuffer(this.gl.READ_FRAMEBUFFER, null);\n\t\t\t\tthis.updateTextureFrameOffset(name, targetSlots[targetSlots.length - 1], { allowMissing: true });\n\t\t\t\tif (historySlots === undefined) {\n\t\t\t\t\tinfo.history.writeIndex = (info.history.writeIndex + 1) % depth;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Different contexts - transfer via readPixels to preserve precision.\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\toptions: { format, type },\n\t\t\t} = sourceIntermediateInfo;\n\t\t\tconst pixels = this.getPixelArray(type, width * height * 4);\n\t\t\tsource.gl.bindFramebuffer(source.gl.FRAMEBUFFER, source.intermediateFbo);\n\t\t\tsource.gl.readPixels(0, 0, width, height, format, type, pixels);\n\t\t\tsource.gl.bindFramebuffer(source.gl.FRAMEBUFFER, null);\n\t\t\tnonShaderPadSource = { data: pixels, width, height };\n\t\t}\n\n\t\t// If dimensions changed, recreate the texture with new dimensions.\n\t\tconst { width, height } = getSourceDimensions(nonShaderPadSource);\n\t\tif (!width || !height) return;\n\n\t\tconst isPartial = 'isPartial' in nonShaderPadSource && nonShaderPadSource.isPartial;\n\t\tif (!isPartial) {\n\t\t\tthis.resizeTexture(name, width, height);\n\t\t}\n\n\t\t// UNPACK_FLIP_Y_WEBGL only works for DOM element sources, not typed arrays.\n\t\tconst isTypedArray = 'data' in nonShaderPadSource && nonShaderPadSource.data;\n\t\tconst shouldFlipY = !isTypedArray && !info.options?.preserveY;\n\t\tconst previousFlipY = this.gl.getParameter(this.gl.UNPACK_FLIP_Y_WEBGL);\n\t\tconst needsAlignmentFix = isTypedArray && this.isNotRgba(info.options.format);\n\t\tlet previousAlignment;\n\t\tif (needsAlignmentFix) {\n\t\t\tpreviousAlignment = this.gl.getParameter(this.gl.UNPACK_ALIGNMENT);\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);\n\t\t}\n\n\t\tif (info.history) {\n\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, info.texture);\n\t\t\tconst { depth } = info.history;\n\t\t\tconst targetSlots =\n\t\t\t\thistorySlots === undefined\n\t\t\t\t\t? [info.history.writeIndex]\n\t\t\t\t\t: Array.isArray(historySlots)\n\t\t\t\t\t\t? historySlots.map(i => safeMod(i, depth))\n\t\t\t\t\t\t: [safeMod(historySlots, depth)];\n\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, shouldFlipY);\n\t\t\tconst partialSource = nonShaderPadSource as PartialCustomTexture;\n\t\t\tconst sourceData =\n\t\t\t\tpartialSource.data ?? (nonShaderPadSource as Exclude<TextureSource, CustomTexture | ShaderPad>);\n\t\t\tconst xOffset = isPartial ? (partialSource.x ?? 0) : 0;\n\t\t\tconst yOffset = isPartial ? (partialSource.y ?? 0) : 0;\n\n\t\t\tfor (const slot of targetSlots) {\n\t\t\t\tthis.gl.texSubImage3D(\n\t\t\t\t\tthis.gl.TEXTURE_2D_ARRAY,\n\t\t\t\t\t0,\n\t\t\t\t\txOffset,\n\t\t\t\t\tyOffset,\n\t\t\t\t\tslot,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\t1,\n\t\t\t\t\tinfo.options.format,\n\t\t\t\t\tinfo.options.type,\n\t\t\t\t\tsourceData as any,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, previousFlipY);\n\t\t\tthis.updateTextureFrameOffset(name, targetSlots[targetSlots.length - 1]);\n\t\t\tif (historySlots === undefined) {\n\t\t\t\tinfo.history.writeIndex = (info.history.writeIndex + 1) % depth;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.gl.activeTexture(this.gl.TEXTURE0 + info.unitIndex);\n\t\t\tthis.gl.bindTexture(this.gl.TEXTURE_2D, info.texture);\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, shouldFlipY);\n\n\t\t\tif (isPartial) {\n\t\t\t\tconst partialSource = nonShaderPadSource as PartialCustomTexture;\n\t\t\t\tthis.gl.texSubImage2D(\n\t\t\t\t\tthis.gl.TEXTURE_2D,\n\t\t\t\t\t0,\n\t\t\t\t\tpartialSource.x ?? 0,\n\t\t\t\t\tpartialSource.y ?? 0,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tinfo.options.format,\n\t\t\t\t\tinfo.options.type,\n\t\t\t\t\tpartialSource.data,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.gl.texImage2D(\n\t\t\t\t\tthis.gl.TEXTURE_2D,\n\t\t\t\t\t0,\n\t\t\t\t\tinfo.options.internalFormat,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\t0,\n\t\t\t\t\tinfo.options.format,\n\t\t\t\t\tinfo.options.type,\n\t\t\t\t\t((nonShaderPadSource as PartialCustomTexture).data ??\n\t\t\t\t\t\t(nonShaderPadSource as Exclude<TextureSource, CustomTexture | ShaderPad>)) as any,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, previousFlipY);\n\t\t}\n\t\tif (needsAlignmentFix) this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, previousAlignment);\n\t}\n\n\tprivate bindIntermediate() {\n\t\tconst gl = this.gl;\n\t\tconst intermediateInfo = this.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, this.intermediateFbo);\n\t\tgl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, intermediateInfo.texture, 0);\n\t}\n\n\tclear() {\n\t\tthis.bindIntermediate();\n\t\tconst gl = this.gl;\n\t\tconst intermediateInfo = this.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\tif (intermediateInfo.options.isIntegerColorFormat) {\n\t\t\tconst t = intermediateInfo.options.type;\n\t\t\tif (this.glHelpers.unsignedIntTypes.has(t)) {\n\t\t\t\tgl.clearBufferuiv(gl.COLOR, 0, new Uint32Array(4));\n\t\t\t} else {\n\t\t\t\tgl.clearBufferiv(gl.COLOR, 0, new Int32Array(4));\n\t\t\t}\n\t\t} else {\n\t\t\tgl.clear(gl.COLOR_BUFFER_BIT);\n\t\t}\n\t}\n\n\tdraw(options?: StepOptions) {\n\t\tthis.emit('beforeDraw', ...arguments);\n\t\tconst gl = this.gl;\n\t\tconst w = gl.drawingBufferWidth;\n\t\tconst h = gl.drawingBufferHeight;\n\n\t\tif (options?.skipClear) {\n\t\t\tthis.bindIntermediate();\n\t\t} else {\n\t\t\tthis.clear();\n\t\t}\n\n\t\tgl.useProgram(this.program);\n\t\tgl.bindVertexArray(this.vao);\n\t\tgl.viewport(0, 0, w, h);\n\t\tgl.drawArrays(gl.TRIANGLES, 0, 3);\n\n\t\tif (!this.isHeadless) {\n\t\t\tconst intermediateInfo = this.textures.get(INTERMEDIATE_TEXTURE_KEY)!;\n\t\t\tif (!intermediateInfo.options.isIntegerColorFormat) {\n\t\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, this.intermediateFbo);\n\t\t\t\tgl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);\n\t\t\t\tgl.blitFramebuffer(0, 0, w, h, 0, 0, w, h, gl.COLOR_BUFFER_BIT, gl.NEAREST);\n\t\t\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\t\t\t}\n\t\t}\n\t\tthis.emit('afterDraw', ...arguments);\n\t}\n\n\tstep(options?: StepOptions) {\n\t\tif (!Number.isFinite(this.startTime)) {\n\t\t\tthis.startTime = performance.now();\n\t\t}\n\t\tthis._step((performance.now() - this.startTime) / 1000, options);\n\t}\n\n\tprivate _step(time: number, options?: StepOptions) {\n\t\tthis.emit('beforeStep', time, this.frame, options);\n\t\tconst updates: Record<string, number> = {};\n\t\tif (this.uniforms.has('u_time')) updates.u_time = time;\n\t\tif (this.uniforms.has('u_frame')) updates.u_frame = this.frame;\n\t\tthis.updateUniforms(updates);\n\t\tthis.draw(options);\n\t\tconst historyInfo = this.textures.get(HISTORY_TEXTURE_KEY);\n\t\tif (historyInfo && !options?.skipHistory) {\n\t\t\tconst { writeIndex, depth } = historyInfo.history!;\n\t\t\tconst gl = this.gl;\n\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, this.intermediateFbo);\n\t\t\tgl.bindTexture(gl.TEXTURE_2D_ARRAY, historyInfo.texture);\n\t\t\tgl.copyTexSubImage3D(\n\t\t\t\tgl.TEXTURE_2D_ARRAY,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\twriteIndex,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tgl.drawingBufferWidth,\n\t\t\t\tgl.drawingBufferHeight,\n\t\t\t);\n\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);\n\t\t\tconst nextWriteIndex = (writeIndex + 1) % depth;\n\t\t\tthis.updateTextureFrameOffset(HISTORY_TEXTURE_KEY, nextWriteIndex, { allowMissing: true });\n\t\t\thistoryInfo.history!.writeIndex = nextWriteIndex;\n\t\t}\n\t\t++this.frame;\n\t\tthis.emit('afterStep', time, this.frame, options);\n\t}\n\n\tplay(onBeforeStep?: (time: number, frame: number) => StepOptions | void) {\n\t\tthis._pause();\n\t\tif (!Number.isFinite(this.startTime)) {\n\t\t\tthis.startTime = performance.now();\n\t\t}\n\t\tthis.isPlaying = true;\n\t\tconst loop = (time: number) => {\n\t\t\ttime = (time - this.startTime) / 1000; // Convert from milliseconds to seconds.\n\t\t\tconst options = onBeforeStep?.(time, this.frame) ?? undefined;\n\t\t\tthis._step(time, options);\n\t\t\tif (this.isPlaying) this.animationFrameId = requestAnimationFrame(loop);\n\t\t};\n\t\tthis.animationFrameId = requestAnimationFrame(loop);\n\t\tthis.emit('play');\n\t}\n\n\tprivate _pause() {\n\t\tconst wasPlaying = this.isPlaying;\n\t\tthis.isPlaying = false;\n\t\tif (this.animationFrameId) {\n\t\t\tcancelAnimationFrame(this.animationFrameId);\n\t\t\tthis.animationFrameId = null;\n\t\t}\n\t\treturn wasPlaying;\n\t}\n\n\tpause() {\n\t\tif (this._pause()) {\n\t\t\tthis.emit('pause');\n\t\t}\n\t}\n\n\tresetFrame() {\n\t\tthis.frame = 0;\n\t\tthis.startTime = performance.now();\n\t}\n\n\treset() {\n\t\tthis.resetFrame();\n\t\tthis.textures.forEach((texture, name) => {\n\t\t\tthis.resetHistoryTextureState(name, texture);\n\t\t});\n\t\tthis.clear();\n\t\tthis.emit('reset');\n\t}\n\n\tdestroy() {\n\t\tthis.emit('destroy');\n\n\t\tthis._pause();\n\n\t\tif (this.cursorTarget) {\n\t\t\tthis.eventListeners.forEach((listener, event) => {\n\t\t\t\tthis.cursorTarget!.removeEventListener(event, listener);\n\t\t\t});\n\t\t\tthis.eventListeners.clear();\n\t\t}\n\n\t\tif (this.resolutionObserver) {\n\t\t\tthis.resolutionObserver.disconnect();\n\t\t\tthis.resolutionObserver = null;\n\t\t}\n\n\t\tif (this.program) {\n\t\t\tthis.gl.deleteProgram(this.program);\n\t\t\tthis.program = null;\n\t\t}\n\n\t\tif (this.intermediateFbo) {\n\t\t\tthis.gl.deleteFramebuffer(this.intermediateFbo);\n\t\t\tthis.intermediateFbo = null;\n\t\t}\n\n\t\tthis.textures.forEach(texture => {\n\t\t\tthis.textureUnitPool.free.push(texture.unitIndex);\n\t\t\tthis.gl.deleteTexture(texture.texture);\n\t\t});\n\t\tthis.textures.clear();\n\t\tconst entry = canvasRegistry.get(this.canvas);\n\t\tif (entry) {\n\t\t\tentry.instances.delete(this);\n\t\t\tif (entry.instances.size === 0) {\n\t\t\t\tcanvasRegistry.delete(this.canvas);\n\t\t\t}\n\t\t}\n\n\t\tif (this.vao) {\n\t\t\tthis.gl.deleteVertexArray(this.vao);\n\t\t\tthis.vao = null;\n\t\t}\n\n\t\tif (this.buffer) {\n\t\t\tthis.gl.deleteBuffer(this.buffer);\n\t\t\tthis.buffer = null;\n\t\t}\n\n\t\tthis.uniforms.clear();\n\t\tthis.hooks.clear();\n\t}\n}\n\nexport default ShaderPad;\n","import ShaderPad, { PluginContext } from '..';\n\nconst THROTTLE_INTERVAL_DEFAULT = 1000 / 30;\n\nexport interface AutosizeOptions {\n\tscale?: number;\n\ttarget?: Element | Window;\n\tthrottle?: number;\n}\n\nfunction autosize(options: AutosizeOptions = {}) {\n\treturn function (shaderPad: ShaderPad, context: PluginContext) {\n\t\tconst { emit } = context;\n\t\tconst { canvas } = shaderPad;\n\t\tconst {\n\t\t\tscale = window.devicePixelRatio || 1,\n\t\t\ttarget = canvas instanceof HTMLCanvasElement ? canvas : window,\n\t\t\tthrottle = THROTTLE_INTERVAL_DEFAULT,\n\t\t} = options;\n\n\t\tlet resizeTimeout: ReturnType<typeof setTimeout> | null = null;\n\t\tlet lastResizeTime = -Infinity;\n\t\tfunction throttledHandleResize() {\n\t\t\tif (resizeTimeout) clearTimeout(resizeTimeout);\n\t\t\tconst now = performance.now();\n\t\t\tconst timeUntilNextResize = lastResizeTime + throttle - now;\n\t\t\tif (timeUntilNextResize <= 0) {\n\t\t\t\tlastResizeTime = now;\n\t\t\t\thandleResize();\n\t\t\t} else {\n\t\t\t\tresizeTimeout = setTimeout(() => throttledHandleResize(), timeUntilNextResize);\n\t\t\t}\n\t\t}\n\n\t\tfunction handleResize() {\n\t\t\tlet width, height;\n\t\t\tif (target instanceof Window) {\n\t\t\t\twidth = window.innerWidth * scale;\n\t\t\t\theight = window.innerHeight * scale;\n\t\t\t} else {\n\t\t\t\twidth = target.clientWidth * scale;\n\t\t\t\theight = target.clientHeight * scale;\n\t\t\t}\n\t\t\twidth = Math.max(1, Math.round(width));\n\t\t\theight = Math.max(1, Math.round(height));\n\t\t\tif (canvas.width !== width || canvas.height !== height) {\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\t\t\t\temit('autosize:resize', width, height);\n\t\t\t}\n\t\t}\n\n\t\thandleResize();\n\n\t\tlet resizeObserver: ResizeObserver | null = null;\n\t\tif (target instanceof Window) {\n\t\t\twindow.addEventListener('resize', throttledHandleResize);\n\t\t} else if (target instanceof Element) {\n\t\t\tresizeObserver = new ResizeObserver(() => throttledHandleResize());\n\t\t\tresizeObserver.observe(target);\n\t\t}\n\n\t\tshaderPad.on('destroy', () => {\n\t\t\tif (resizeTimeout) clearTimeout(resizeTimeout);\n\t\t\tif (resizeObserver) resizeObserver.disconnect();\n\t\t\tif (target instanceof Window) {\n\t\t\t\twindow.removeEventListener('resize', throttledHandleResize);\n\t\t\t}\n\t\t});\n\t};\n}\n\nexport default autosize;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,mBAAAA;AAAA,EAAA;AAAA;AAAA;AAEA,mBAQO;;;ACPA,IAAM,sBAAsB;AAE5B,SAAS,SAAS,MAAiB;AACzC,SAAO,GAAG,mBAAmB,GAAG,IA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QAAQ;AAAA,QACR,GAAG;AAAA,MACJ;AAAA,MACC,GAAG;AAAA;AAAA,EACL;AAEF,CAAC;AAEDD,WAAU,cAAc;AAExB,IAAO,gBAAQA;","names":["ShaderPad","canvas","width","height","ShaderPad","autosize","shader"]}
|
package/dist/dev/react.mjs
CHANGED
|
@@ -336,7 +336,9 @@ var ShaderPad = forwardRef(function ShaderPad2({
|
|
|
336
336
|
);
|
|
337
337
|
});
|
|
338
338
|
ShaderPad.displayName = "ShaderPad";
|
|
339
|
+
var react_default = ShaderPad;
|
|
339
340
|
export {
|
|
340
|
-
ShaderPad
|
|
341
|
+
ShaderPad,
|
|
342
|
+
react_default as default
|
|
341
343
|
};
|
|
342
344
|
//# sourceMappingURL=react.mjs.map
|