alpha-video-gpu-web 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,268 @@
1
+ import { K as KTX2PlayerCoreOptions, P as PlayerState, M as Metadata, a as KTX2Source, b as KTX2SourceOptions } from './types-C6J2fa98.mjs';
2
+ export { c as AlphaVideoGpuLoadEvent, d as AlphaVideoGpuStorage, e as MemoryStrategy, S as SharedGLResources } from './types-C6J2fa98.mjs';
3
+ export { ByteSource, ByteStore, HttpSourceError, HttpSourceOptions, SourceChangedError, SourceInfo, StorageKind, blobSource, createStore, httpSource, memorySource } from 'range-source-web';
4
+
5
+ /**
6
+ * KTX2PlayerCore - Framework-agnostic WebGL engine for KTX2 animated textures.
7
+ *
8
+ * This is the single source of truth for all web-based KTX2 playback logic.
9
+ * Framework wrappers (React Native Web, React, Vanilla JS) should be thin
10
+ * layers that create/destroy a KTX2PlayerCore instance and map props/options.
11
+ */
12
+
13
+ declare class KTX2PlayerCore {
14
+ private _autoPlay;
15
+ private _loop;
16
+ private _playbackSpeed;
17
+ private _stream;
18
+ private _streamingPrefetchAhead;
19
+ private _memoryStrategy;
20
+ private _verbose;
21
+ private _storage;
22
+ private _maxStorageBytes;
23
+ private _ZSTDDecoderClass;
24
+ private _onStateChange;
25
+ private _onLoad;
26
+ private _onFrameUpdate;
27
+ private _frameEvents;
28
+ private _onFinished;
29
+ private _onError;
30
+ private _canvas;
31
+ private _ctx2d;
32
+ private _usingSharedGL;
33
+ private _gl;
34
+ private _arrayProgram;
35
+ private _positionBuffer;
36
+ private _texCoordBuffer;
37
+ private _textureArray;
38
+ private _softwareAstc;
39
+ private _blockWidth;
40
+ private _blockHeight;
41
+ private _metadata;
42
+ private _state;
43
+ private _currentFrame;
44
+ private _animationFrameId;
45
+ private _lastFrameTime;
46
+ private _loadedSource;
47
+ private _loadId;
48
+ private _reader;
49
+ private _zstdDecoder;
50
+ private _streamingMode;
51
+ private _streamingCancelled;
52
+ private _streamingFrameCache;
53
+ private _useVramStrategy;
54
+ private _streamingRingBuffer;
55
+ private _streamingRingSlots;
56
+ private _streamingRingActualSize;
57
+ private _streamingDecodePos;
58
+ private _streamingFramesReady;
59
+ private _streamingLoopCount;
60
+ private _layerStream;
61
+ private _streamingBytesPerLayer;
62
+ private _streamingWidth;
63
+ private _streamingHeight;
64
+ private _streamingLayerCount;
65
+ private _streamingLevel0Offset;
66
+ private _streamingAstcFormat;
67
+ private _backgroundDecodeStream;
68
+ private _ended;
69
+ private _pausedByProp;
70
+ private _owedFrameId;
71
+ private _ramHeavyMode;
72
+ private _ramFrameData;
73
+ private _ramBytesPerFrame;
74
+ private _ramFrameCount;
75
+ private _ramUploadedFrame;
76
+ private _ramAstcFormat;
77
+ private _ramWidth;
78
+ private _ramHeight;
79
+ constructor(canvas: HTMLCanvasElement, options?: KTX2PlayerCoreOptions);
80
+ get state(): PlayerState;
81
+ get currentFrame(): number;
82
+ get totalFrames(): number;
83
+ get frameRate(): number;
84
+ get duration(): number;
85
+ get currentTime(): number;
86
+ get metadataInfo(): Metadata | null;
87
+ /** Whether a source starts playing once loaded. */
88
+ set autoPlay(v: boolean);
89
+ get autoPlay(): boolean;
90
+ /** Whether onFrameUpdate fires for every frame played, not only for seeks. */
91
+ set frameEvents(v: boolean);
92
+ get frameEvents(): boolean;
93
+ set loop(v: boolean);
94
+ get loop(): boolean;
95
+ set playbackSpeed(v: number);
96
+ get playbackSpeed(): number;
97
+ /** Update callbacks after construction (useful for wrappers where callbacks change). */
98
+ updateCallbacks(cbs: Partial<Pick<KTX2PlayerCoreOptions, 'onStateChange' | 'onLoad' | 'onFrameUpdate' | 'onFinished' | 'onError'>>): void;
99
+ /** Plays from the shown frame, or from the start once a clip that doesn't loop has ended. */
100
+ play(): void;
101
+ pause(): void;
102
+ resume(): void;
103
+ /**
104
+ * Holds playback and decoding, keeping the frames (the `paused` prop, for screen focus and
105
+ * blur). Unpausing plays again only when autoPlay is on; a source loaded while paused waits.
106
+ */
107
+ setPaused(paused: boolean): void;
108
+ /** Pauses on the first frame. */
109
+ stop(): void;
110
+ /**
111
+ * Shows that frame (clamped to the clip) and keeps playing or stays paused. Ignored until
112
+ * the source has loaded. While streaming, a seek outside the buffered frames decodes again.
113
+ */
114
+ seekToFrame(frame: number): void;
115
+ /** Seeks to the frame showing at that time, in seconds. */
116
+ seekToTime(seconds: number): void;
117
+ set verbose(v: boolean);
118
+ /** Reset loaded source tracking so next setSource will reload even the same URI. */
119
+ resetSource(): void;
120
+ /**
121
+ * Loads an ASTC KTX2 texture array from a URL (http(s), relative, or asset://path, served from
122
+ * the site root), a Blob or File, bytes in memory, or a ByteSource. Files are read by range:
123
+ * streaming playback starts once the first frames have arrived, and a URL's bytes are kept in
124
+ * the storage option's store for the next play.
125
+ *
126
+ * @param options cacheKey and headers; a string is taken as the cacheKey
127
+ */
128
+ setSource(source: KTX2Source, options?: KTX2SourceOptions | string): Promise<void>;
129
+ private _log;
130
+ /** Tear down all resources. Call when the player is no longer needed. */
131
+ destroy(): void;
132
+ /** Stops a load that a newer setSource or destroy has replaced. */
133
+ private _checkLoad;
134
+ private _closeReader;
135
+ private _setState;
136
+ private _finishLoad;
137
+ private _initGL;
138
+ private _ensureZstdDecoder;
139
+ /** Uses the GPU's ASTC where the browser has it, and loads the software decoder where not. */
140
+ private _prepareAstc;
141
+ /** Allocates the bound texture array: ASTC, or RGBA8 when decoding in software. */
142
+ private _allocateLayers;
143
+ /** Uploads one layer of ASTC blocks to the bound texture array, decoding it first in software. */
144
+ private _uploadLayer;
145
+ private _cleanupTextures;
146
+ private _cleanupStreamingState;
147
+ private _cleanupRamState;
148
+ private _emitLoad;
149
+ private _loadKTX2Source;
150
+ private _loadTextureArray;
151
+ private _initStreamingRingBuffer;
152
+ /**
153
+ * Plays the level a layer at a time: zstd-decoded, or read straight from the file when
154
+ * uncompressed. The first frames are read before the load finishes; the rest are read
155
+ * ahead of playback by the background decode loop.
156
+ */
157
+ private _loadStreamingTextureArray;
158
+ /**
159
+ * Reads and decodes ahead of playback, and catches up to a seek target, in slices of
160
+ * DECODE_SLICE_MS so a long catch-up doesn't hold up drawing or input. A seek during a read
161
+ * interrupts it (readLayer returns null) and the loop carries on from the new position.
162
+ */
163
+ private _startBackgroundDecompression;
164
+ private _ensureFrameInRingBuffer;
165
+ private _evictOldFramesFromCache;
166
+ private _handleStreamingLoop;
167
+ /** Starts the streaming decoder, unless it is already running. */
168
+ private _kickStreamingDecode;
169
+ /**
170
+ * Points the streaming decoder at target. Frames from target up to the decoder that are all
171
+ * still buffered are kept; otherwise decoding carries on or starts at a seek point, whichever
172
+ * reaches target sooner (see ZstdLayerStream.moveTo).
173
+ */
174
+ private _moveStreamTo;
175
+ /** Stops the stream's reads and frees the zstd decoder's WASM buffers. */
176
+ private _closeLayerStream;
177
+ /** Drops the decoded frames and has the decoder produce target next. */
178
+ private _decodeFrom;
179
+ /** Draws the shown frame once it is decoded, for a seek while not playing. */
180
+ private _drawWhenReady;
181
+ /** Draws the current frame; false when it isn't decoded yet, leaving the last one showing. */
182
+ private _render;
183
+ private _startAnimationLoop;
184
+ private _stopAnimationLoop;
185
+ }
186
+
187
+ /** A zstd decoder fed one input array at a time; see createStreamingDecoder. */
188
+ interface ZSTDStreamingDecoder {
189
+ /** Decodes the array, yielding its output in pieces. Finish iterating before the next call. */
190
+ decode(array: Uint8Array): Generator<Uint8Array, void, undefined>;
191
+ /** True when the input so far ends between frames. */
192
+ finished(): boolean;
193
+ /** Frees the WASM buffers; the decoder can't be used afterwards. */
194
+ free(): void;
195
+ }
196
+
197
+ declare class ZSTDDecoder {
198
+ init(): Promise<void>;
199
+ decode(array: Uint8Array, uncompressedSize?: number): Uint8Array;
200
+ decodeStreaming(arrays: Iterable<Uint8Array>): Generator<Uint8Array>;
201
+ createStreamingDecoder(): ZSTDStreamingDecoder;
202
+ }
203
+
204
+ /**
205
+ * KTX2 Parsing Utilities
206
+ *
207
+ * Functions for reading a KTX2 file's frame metadata and mapping ASTC formats.
208
+ */
209
+
210
+ /**
211
+ * Reads the frame size and count from the KTX2 header and the frame rate from KTXanimData, the
212
+ * KTX 2.0 key for array textures whose layers are animation frames (per-frame duration /
213
+ * timescale seconds, so 29.97 fps is exact). Returns null if the data isn't a KTX2 file.
214
+ */
215
+ declare function extractKTX2Metadata(ktx2Data: Uint8Array): Metadata | null;
216
+ /**
217
+ * ASTC VkFormat → WebGL compressed format mapping.
218
+ * Covers all 14 ASTC block sizes (UNORM and SRGB variants).
219
+ */
220
+ declare const ASTC_FORMAT_MAP: Record<number, number>;
221
+ /**
222
+ * ASTC VkFormat → block dimensions (width, height).
223
+ * All ASTC blocks are 128 bits (16 bytes), but pixel coverage varies.
224
+ * VkFormat values come in UNORM/SRGB pairs; both map to the same block size.
225
+ */
226
+ declare function getASTCBlockSize(vkFormat: number): {
227
+ blockWidth: number;
228
+ blockHeight: number;
229
+ };
230
+ /**
231
+ * Calculate bytes per layer for an ASTC-compressed texture.
232
+ * All ASTC blocks are 16 bytes regardless of block dimensions.
233
+ */
234
+ declare function getASTCBytesPerLayer(width: number, height: number, vkFormat: number): number;
235
+
236
+ /** Keeps this player's stored clips apart from other players' (each has its own cap). */
237
+ declare const STORAGE_NAMESPACE = "alpha-video-gpu";
238
+
239
+ /**
240
+ * - `ASTC_UNSUPPORTED`: the browser has no `WEBGL_compressed_texture_astc`, and the software
241
+ * decoder couldn't load either (WebAssembly blocked, as by a Content-Security-Policy without
242
+ * 'wasm-unsafe-eval').
243
+ * - `WEBGL_UNSUPPORTED`: no WebGL2 context could be created.
244
+ */
245
+ type AlphaVideoGpuErrorCode = 'ASTC_UNSUPPORTED' | 'WEBGL_UNSUPPORTED';
246
+ /** An error passed to `onError` that callers can tell apart by `code`. */
247
+ declare class AlphaVideoGpuError extends Error {
248
+ readonly code: AlphaVideoGpuErrorCode;
249
+ constructor(code: AlphaVideoGpuErrorCode, message: string);
250
+ }
251
+
252
+ /**
253
+ * alpha-video-gpu-web: transparent animations from ASTC KTX2 texture arrays, drawn into a
254
+ * <canvas> with WebGL2. The zstd decoder (JS + WASM) is bundled inline, so there are no files to
255
+ * host and no <script> tags.
256
+ *
257
+ * import { createAlphaVideoGpuPlayer } from 'alpha-video-gpu-web';
258
+ *
259
+ * const player = createAlphaVideoGpuPlayer(canvas, { autoPlay: true, loop: true });
260
+ * player.setSource('https://example.com/animation.ktx2');
261
+ *
262
+ * React: `alpha-video-gpu-web/react`.
263
+ */
264
+
265
+ /** A player on `canvas` with the bundled decoders. */
266
+ declare function createAlphaVideoGpuPlayer(canvas: HTMLCanvasElement, options?: Omit<KTX2PlayerCoreOptions, 'ZSTDDecoderClass'>): KTX2PlayerCore;
267
+
268
+ export { ASTC_FORMAT_MAP, KTX2PlayerCore as AlphaVideoGpuCore, AlphaVideoGpuError, type AlphaVideoGpuErrorCode, KTX2PlayerCoreOptions as AlphaVideoGpuOptions, KTX2Source as AlphaVideoGpuSource, KTX2SourceOptions as AlphaVideoGpuSourceOptions, Metadata, PlayerState, STORAGE_NAMESPACE, ZSTDDecoder, createAlphaVideoGpuPlayer, extractKTX2Metadata, getASTCBlockSize, getASTCBytesPerLayer };
@@ -0,0 +1,268 @@
1
+ import { K as KTX2PlayerCoreOptions, P as PlayerState, M as Metadata, a as KTX2Source, b as KTX2SourceOptions } from './types-C6J2fa98.js';
2
+ export { c as AlphaVideoGpuLoadEvent, d as AlphaVideoGpuStorage, e as MemoryStrategy, S as SharedGLResources } from './types-C6J2fa98.js';
3
+ export { ByteSource, ByteStore, HttpSourceError, HttpSourceOptions, SourceChangedError, SourceInfo, StorageKind, blobSource, createStore, httpSource, memorySource } from 'range-source-web';
4
+
5
+ /**
6
+ * KTX2PlayerCore - Framework-agnostic WebGL engine for KTX2 animated textures.
7
+ *
8
+ * This is the single source of truth for all web-based KTX2 playback logic.
9
+ * Framework wrappers (React Native Web, React, Vanilla JS) should be thin
10
+ * layers that create/destroy a KTX2PlayerCore instance and map props/options.
11
+ */
12
+
13
+ declare class KTX2PlayerCore {
14
+ private _autoPlay;
15
+ private _loop;
16
+ private _playbackSpeed;
17
+ private _stream;
18
+ private _streamingPrefetchAhead;
19
+ private _memoryStrategy;
20
+ private _verbose;
21
+ private _storage;
22
+ private _maxStorageBytes;
23
+ private _ZSTDDecoderClass;
24
+ private _onStateChange;
25
+ private _onLoad;
26
+ private _onFrameUpdate;
27
+ private _frameEvents;
28
+ private _onFinished;
29
+ private _onError;
30
+ private _canvas;
31
+ private _ctx2d;
32
+ private _usingSharedGL;
33
+ private _gl;
34
+ private _arrayProgram;
35
+ private _positionBuffer;
36
+ private _texCoordBuffer;
37
+ private _textureArray;
38
+ private _softwareAstc;
39
+ private _blockWidth;
40
+ private _blockHeight;
41
+ private _metadata;
42
+ private _state;
43
+ private _currentFrame;
44
+ private _animationFrameId;
45
+ private _lastFrameTime;
46
+ private _loadedSource;
47
+ private _loadId;
48
+ private _reader;
49
+ private _zstdDecoder;
50
+ private _streamingMode;
51
+ private _streamingCancelled;
52
+ private _streamingFrameCache;
53
+ private _useVramStrategy;
54
+ private _streamingRingBuffer;
55
+ private _streamingRingSlots;
56
+ private _streamingRingActualSize;
57
+ private _streamingDecodePos;
58
+ private _streamingFramesReady;
59
+ private _streamingLoopCount;
60
+ private _layerStream;
61
+ private _streamingBytesPerLayer;
62
+ private _streamingWidth;
63
+ private _streamingHeight;
64
+ private _streamingLayerCount;
65
+ private _streamingLevel0Offset;
66
+ private _streamingAstcFormat;
67
+ private _backgroundDecodeStream;
68
+ private _ended;
69
+ private _pausedByProp;
70
+ private _owedFrameId;
71
+ private _ramHeavyMode;
72
+ private _ramFrameData;
73
+ private _ramBytesPerFrame;
74
+ private _ramFrameCount;
75
+ private _ramUploadedFrame;
76
+ private _ramAstcFormat;
77
+ private _ramWidth;
78
+ private _ramHeight;
79
+ constructor(canvas: HTMLCanvasElement, options?: KTX2PlayerCoreOptions);
80
+ get state(): PlayerState;
81
+ get currentFrame(): number;
82
+ get totalFrames(): number;
83
+ get frameRate(): number;
84
+ get duration(): number;
85
+ get currentTime(): number;
86
+ get metadataInfo(): Metadata | null;
87
+ /** Whether a source starts playing once loaded. */
88
+ set autoPlay(v: boolean);
89
+ get autoPlay(): boolean;
90
+ /** Whether onFrameUpdate fires for every frame played, not only for seeks. */
91
+ set frameEvents(v: boolean);
92
+ get frameEvents(): boolean;
93
+ set loop(v: boolean);
94
+ get loop(): boolean;
95
+ set playbackSpeed(v: number);
96
+ get playbackSpeed(): number;
97
+ /** Update callbacks after construction (useful for wrappers where callbacks change). */
98
+ updateCallbacks(cbs: Partial<Pick<KTX2PlayerCoreOptions, 'onStateChange' | 'onLoad' | 'onFrameUpdate' | 'onFinished' | 'onError'>>): void;
99
+ /** Plays from the shown frame, or from the start once a clip that doesn't loop has ended. */
100
+ play(): void;
101
+ pause(): void;
102
+ resume(): void;
103
+ /**
104
+ * Holds playback and decoding, keeping the frames (the `paused` prop, for screen focus and
105
+ * blur). Unpausing plays again only when autoPlay is on; a source loaded while paused waits.
106
+ */
107
+ setPaused(paused: boolean): void;
108
+ /** Pauses on the first frame. */
109
+ stop(): void;
110
+ /**
111
+ * Shows that frame (clamped to the clip) and keeps playing or stays paused. Ignored until
112
+ * the source has loaded. While streaming, a seek outside the buffered frames decodes again.
113
+ */
114
+ seekToFrame(frame: number): void;
115
+ /** Seeks to the frame showing at that time, in seconds. */
116
+ seekToTime(seconds: number): void;
117
+ set verbose(v: boolean);
118
+ /** Reset loaded source tracking so next setSource will reload even the same URI. */
119
+ resetSource(): void;
120
+ /**
121
+ * Loads an ASTC KTX2 texture array from a URL (http(s), relative, or asset://path, served from
122
+ * the site root), a Blob or File, bytes in memory, or a ByteSource. Files are read by range:
123
+ * streaming playback starts once the first frames have arrived, and a URL's bytes are kept in
124
+ * the storage option's store for the next play.
125
+ *
126
+ * @param options cacheKey and headers; a string is taken as the cacheKey
127
+ */
128
+ setSource(source: KTX2Source, options?: KTX2SourceOptions | string): Promise<void>;
129
+ private _log;
130
+ /** Tear down all resources. Call when the player is no longer needed. */
131
+ destroy(): void;
132
+ /** Stops a load that a newer setSource or destroy has replaced. */
133
+ private _checkLoad;
134
+ private _closeReader;
135
+ private _setState;
136
+ private _finishLoad;
137
+ private _initGL;
138
+ private _ensureZstdDecoder;
139
+ /** Uses the GPU's ASTC where the browser has it, and loads the software decoder where not. */
140
+ private _prepareAstc;
141
+ /** Allocates the bound texture array: ASTC, or RGBA8 when decoding in software. */
142
+ private _allocateLayers;
143
+ /** Uploads one layer of ASTC blocks to the bound texture array, decoding it first in software. */
144
+ private _uploadLayer;
145
+ private _cleanupTextures;
146
+ private _cleanupStreamingState;
147
+ private _cleanupRamState;
148
+ private _emitLoad;
149
+ private _loadKTX2Source;
150
+ private _loadTextureArray;
151
+ private _initStreamingRingBuffer;
152
+ /**
153
+ * Plays the level a layer at a time: zstd-decoded, or read straight from the file when
154
+ * uncompressed. The first frames are read before the load finishes; the rest are read
155
+ * ahead of playback by the background decode loop.
156
+ */
157
+ private _loadStreamingTextureArray;
158
+ /**
159
+ * Reads and decodes ahead of playback, and catches up to a seek target, in slices of
160
+ * DECODE_SLICE_MS so a long catch-up doesn't hold up drawing or input. A seek during a read
161
+ * interrupts it (readLayer returns null) and the loop carries on from the new position.
162
+ */
163
+ private _startBackgroundDecompression;
164
+ private _ensureFrameInRingBuffer;
165
+ private _evictOldFramesFromCache;
166
+ private _handleStreamingLoop;
167
+ /** Starts the streaming decoder, unless it is already running. */
168
+ private _kickStreamingDecode;
169
+ /**
170
+ * Points the streaming decoder at target. Frames from target up to the decoder that are all
171
+ * still buffered are kept; otherwise decoding carries on or starts at a seek point, whichever
172
+ * reaches target sooner (see ZstdLayerStream.moveTo).
173
+ */
174
+ private _moveStreamTo;
175
+ /** Stops the stream's reads and frees the zstd decoder's WASM buffers. */
176
+ private _closeLayerStream;
177
+ /** Drops the decoded frames and has the decoder produce target next. */
178
+ private _decodeFrom;
179
+ /** Draws the shown frame once it is decoded, for a seek while not playing. */
180
+ private _drawWhenReady;
181
+ /** Draws the current frame; false when it isn't decoded yet, leaving the last one showing. */
182
+ private _render;
183
+ private _startAnimationLoop;
184
+ private _stopAnimationLoop;
185
+ }
186
+
187
+ /** A zstd decoder fed one input array at a time; see createStreamingDecoder. */
188
+ interface ZSTDStreamingDecoder {
189
+ /** Decodes the array, yielding its output in pieces. Finish iterating before the next call. */
190
+ decode(array: Uint8Array): Generator<Uint8Array, void, undefined>;
191
+ /** True when the input so far ends between frames. */
192
+ finished(): boolean;
193
+ /** Frees the WASM buffers; the decoder can't be used afterwards. */
194
+ free(): void;
195
+ }
196
+
197
+ declare class ZSTDDecoder {
198
+ init(): Promise<void>;
199
+ decode(array: Uint8Array, uncompressedSize?: number): Uint8Array;
200
+ decodeStreaming(arrays: Iterable<Uint8Array>): Generator<Uint8Array>;
201
+ createStreamingDecoder(): ZSTDStreamingDecoder;
202
+ }
203
+
204
+ /**
205
+ * KTX2 Parsing Utilities
206
+ *
207
+ * Functions for reading a KTX2 file's frame metadata and mapping ASTC formats.
208
+ */
209
+
210
+ /**
211
+ * Reads the frame size and count from the KTX2 header and the frame rate from KTXanimData, the
212
+ * KTX 2.0 key for array textures whose layers are animation frames (per-frame duration /
213
+ * timescale seconds, so 29.97 fps is exact). Returns null if the data isn't a KTX2 file.
214
+ */
215
+ declare function extractKTX2Metadata(ktx2Data: Uint8Array): Metadata | null;
216
+ /**
217
+ * ASTC VkFormat → WebGL compressed format mapping.
218
+ * Covers all 14 ASTC block sizes (UNORM and SRGB variants).
219
+ */
220
+ declare const ASTC_FORMAT_MAP: Record<number, number>;
221
+ /**
222
+ * ASTC VkFormat → block dimensions (width, height).
223
+ * All ASTC blocks are 128 bits (16 bytes), but pixel coverage varies.
224
+ * VkFormat values come in UNORM/SRGB pairs; both map to the same block size.
225
+ */
226
+ declare function getASTCBlockSize(vkFormat: number): {
227
+ blockWidth: number;
228
+ blockHeight: number;
229
+ };
230
+ /**
231
+ * Calculate bytes per layer for an ASTC-compressed texture.
232
+ * All ASTC blocks are 16 bytes regardless of block dimensions.
233
+ */
234
+ declare function getASTCBytesPerLayer(width: number, height: number, vkFormat: number): number;
235
+
236
+ /** Keeps this player's stored clips apart from other players' (each has its own cap). */
237
+ declare const STORAGE_NAMESPACE = "alpha-video-gpu";
238
+
239
+ /**
240
+ * - `ASTC_UNSUPPORTED`: the browser has no `WEBGL_compressed_texture_astc`, and the software
241
+ * decoder couldn't load either (WebAssembly blocked, as by a Content-Security-Policy without
242
+ * 'wasm-unsafe-eval').
243
+ * - `WEBGL_UNSUPPORTED`: no WebGL2 context could be created.
244
+ */
245
+ type AlphaVideoGpuErrorCode = 'ASTC_UNSUPPORTED' | 'WEBGL_UNSUPPORTED';
246
+ /** An error passed to `onError` that callers can tell apart by `code`. */
247
+ declare class AlphaVideoGpuError extends Error {
248
+ readonly code: AlphaVideoGpuErrorCode;
249
+ constructor(code: AlphaVideoGpuErrorCode, message: string);
250
+ }
251
+
252
+ /**
253
+ * alpha-video-gpu-web: transparent animations from ASTC KTX2 texture arrays, drawn into a
254
+ * <canvas> with WebGL2. The zstd decoder (JS + WASM) is bundled inline, so there are no files to
255
+ * host and no <script> tags.
256
+ *
257
+ * import { createAlphaVideoGpuPlayer } from 'alpha-video-gpu-web';
258
+ *
259
+ * const player = createAlphaVideoGpuPlayer(canvas, { autoPlay: true, loop: true });
260
+ * player.setSource('https://example.com/animation.ktx2');
261
+ *
262
+ * React: `alpha-video-gpu-web/react`.
263
+ */
264
+
265
+ /** A player on `canvas` with the bundled decoders. */
266
+ declare function createAlphaVideoGpuPlayer(canvas: HTMLCanvasElement, options?: Omit<KTX2PlayerCoreOptions, 'ZSTDDecoderClass'>): KTX2PlayerCore;
267
+
268
+ export { ASTC_FORMAT_MAP, KTX2PlayerCore as AlphaVideoGpuCore, AlphaVideoGpuError, type AlphaVideoGpuErrorCode, KTX2PlayerCoreOptions as AlphaVideoGpuOptions, KTX2Source as AlphaVideoGpuSource, KTX2SourceOptions as AlphaVideoGpuSourceOptions, Metadata, PlayerState, STORAGE_NAMESPACE, ZSTDDecoder, createAlphaVideoGpuPlayer, extractKTX2Metadata, getASTCBlockSize, getASTCBytesPerLayer };