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.
package/dist/index.mjs ADDED
@@ -0,0 +1,43 @@
1
+ import {
2
+ ASTC_FORMAT_MAP,
3
+ AlphaVideoGpuError,
4
+ KTX2PlayerCore,
5
+ STORAGE_NAMESPACE,
6
+ ZSTDDecoder,
7
+ extractKTX2Metadata,
8
+ getASTCBlockSize,
9
+ getASTCBytesPerLayer
10
+ } from "./chunk-P3MJ6UC3.mjs";
11
+
12
+ // src/index.ts
13
+ import {
14
+ blobSource,
15
+ createStore,
16
+ httpSource,
17
+ memorySource,
18
+ HttpSourceError,
19
+ SourceChangedError
20
+ } from "range-source-web";
21
+ function createAlphaVideoGpuPlayer(canvas, options = {}) {
22
+ return new KTX2PlayerCore(canvas, {
23
+ ...options,
24
+ ZSTDDecoderClass: ZSTDDecoder
25
+ });
26
+ }
27
+ export {
28
+ ASTC_FORMAT_MAP,
29
+ KTX2PlayerCore as AlphaVideoGpuCore,
30
+ AlphaVideoGpuError,
31
+ HttpSourceError,
32
+ STORAGE_NAMESPACE,
33
+ SourceChangedError,
34
+ ZSTDDecoder,
35
+ blobSource,
36
+ createAlphaVideoGpuPlayer,
37
+ createStore,
38
+ extractKTX2Metadata,
39
+ getASTCBlockSize,
40
+ getASTCBytesPerLayer,
41
+ httpSource,
42
+ memorySource
43
+ };
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { a as KTX2Source, d as KTX2Storage, e as MemoryStrategy, c as KTX2LoadEvent, P as PlayerState } from './types-C6J2fa98.mjs';
3
+ import 'range-source-web';
4
+
5
+ /**
6
+ * AlphaVideoGpuPlayer - React-only Wrapper (no React Native dependency)
7
+ *
8
+ * GPU-accelerated transparent alpha video player.
9
+ *
10
+ * Usage:
11
+ * import { AlphaVideoGpuPlayer } from 'alpha-video-gpu-web/react';
12
+ *
13
+ * <AlphaVideoGpuPlayer
14
+ * src="https://example.com/animation.ktx2"
15
+ * width={300}
16
+ * height={300}
17
+ * autoPlay
18
+ * loop
19
+ * />
20
+ *
21
+ * Self-contained: the ZSTD decoder (JS + WASM) is bundled inline.
22
+ * No external files or <script> tags needed.
23
+ */
24
+
25
+ interface AlphaVideoGpuPlayerProps {
26
+ /** The KTX2 file: a URL, a Blob or File, bytes in memory, or a ByteSource */
27
+ src?: KTX2Source;
28
+ /** Names the stored copy, for URLs that change while the file doesn't (presigned URLs) */
29
+ cacheKey?: string;
30
+ /** Sent with every request for a URL source, e.g. Authorization; a change doesn't reload */
31
+ headers?: Record<string, string>;
32
+ /** Where a URL's bytes are kept between plays. Default: 'auto' (OPFS, else IndexedDB). Read on mount */
33
+ storage?: KTX2Storage;
34
+ /** Cap on the stored bytes across clips. Default: 512 MB. Read on mount */
35
+ maxStorageBytes?: number;
36
+ /** Canvas width in pixels */
37
+ width?: number;
38
+ /** Canvas height in pixels */
39
+ height?: number;
40
+ /** CSS class for the canvas element */
41
+ className?: string;
42
+ /** Inline styles for the canvas element */
43
+ style?: React.CSSProperties;
44
+ autoPlay?: boolean;
45
+ loop?: boolean;
46
+ playbackSpeed?: number;
47
+ paused?: boolean;
48
+ stream?: boolean;
49
+ streamingPrefetchAhead?: number;
50
+ memoryStrategy?: MemoryStrategy;
51
+ /** Log info traces to the console. Default: false */
52
+ verbose?: boolean;
53
+ onLoad?: (event: KTX2LoadEvent) => void;
54
+ onStateChange?: (state: PlayerState) => void;
55
+ onFrameUpdate?: (frame: number, total: number) => void;
56
+ onFinished?: () => void;
57
+ onError?: (error: Error) => void;
58
+ }
59
+ /**
60
+ * Seeks show the frame (clamped to the clip) and keep playing, or stay paused. They are ignored
61
+ * until the source has loaded.
62
+ */
63
+ interface AlphaVideoGpuPlayerRef {
64
+ /** Plays from the shown frame, or from the start once a clip that doesn't loop has finished. */
65
+ play: () => void;
66
+ pause: () => void;
67
+ /** Pauses on the first frame. */
68
+ stop: () => void;
69
+ seekToFrame: (frame: number) => void;
70
+ /** Seeks to the frame showing at that time, in seconds. */
71
+ seekToTime: (seconds: number) => void;
72
+ }
73
+ declare const AlphaVideoGpuPlayer: React.ForwardRefExoticComponent<AlphaVideoGpuPlayerProps & React.RefAttributes<AlphaVideoGpuPlayerRef>>;
74
+
75
+ export { KTX2LoadEvent as AlphaVideoGpuLoadEvent, AlphaVideoGpuPlayer, type AlphaVideoGpuPlayerProps, type AlphaVideoGpuPlayerRef, KTX2Source as AlphaVideoGpuSource, KTX2Storage as AlphaVideoGpuStorage, MemoryStrategy, PlayerState };
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { a as KTX2Source, d as KTX2Storage, e as MemoryStrategy, c as KTX2LoadEvent, P as PlayerState } from './types-C6J2fa98.js';
3
+ import 'range-source-web';
4
+
5
+ /**
6
+ * AlphaVideoGpuPlayer - React-only Wrapper (no React Native dependency)
7
+ *
8
+ * GPU-accelerated transparent alpha video player.
9
+ *
10
+ * Usage:
11
+ * import { AlphaVideoGpuPlayer } from 'alpha-video-gpu-web/react';
12
+ *
13
+ * <AlphaVideoGpuPlayer
14
+ * src="https://example.com/animation.ktx2"
15
+ * width={300}
16
+ * height={300}
17
+ * autoPlay
18
+ * loop
19
+ * />
20
+ *
21
+ * Self-contained: the ZSTD decoder (JS + WASM) is bundled inline.
22
+ * No external files or <script> tags needed.
23
+ */
24
+
25
+ interface AlphaVideoGpuPlayerProps {
26
+ /** The KTX2 file: a URL, a Blob or File, bytes in memory, or a ByteSource */
27
+ src?: KTX2Source;
28
+ /** Names the stored copy, for URLs that change while the file doesn't (presigned URLs) */
29
+ cacheKey?: string;
30
+ /** Sent with every request for a URL source, e.g. Authorization; a change doesn't reload */
31
+ headers?: Record<string, string>;
32
+ /** Where a URL's bytes are kept between plays. Default: 'auto' (OPFS, else IndexedDB). Read on mount */
33
+ storage?: KTX2Storage;
34
+ /** Cap on the stored bytes across clips. Default: 512 MB. Read on mount */
35
+ maxStorageBytes?: number;
36
+ /** Canvas width in pixels */
37
+ width?: number;
38
+ /** Canvas height in pixels */
39
+ height?: number;
40
+ /** CSS class for the canvas element */
41
+ className?: string;
42
+ /** Inline styles for the canvas element */
43
+ style?: React.CSSProperties;
44
+ autoPlay?: boolean;
45
+ loop?: boolean;
46
+ playbackSpeed?: number;
47
+ paused?: boolean;
48
+ stream?: boolean;
49
+ streamingPrefetchAhead?: number;
50
+ memoryStrategy?: MemoryStrategy;
51
+ /** Log info traces to the console. Default: false */
52
+ verbose?: boolean;
53
+ onLoad?: (event: KTX2LoadEvent) => void;
54
+ onStateChange?: (state: PlayerState) => void;
55
+ onFrameUpdate?: (frame: number, total: number) => void;
56
+ onFinished?: () => void;
57
+ onError?: (error: Error) => void;
58
+ }
59
+ /**
60
+ * Seeks show the frame (clamped to the clip) and keep playing, or stay paused. They are ignored
61
+ * until the source has loaded.
62
+ */
63
+ interface AlphaVideoGpuPlayerRef {
64
+ /** Plays from the shown frame, or from the start once a clip that doesn't loop has finished. */
65
+ play: () => void;
66
+ pause: () => void;
67
+ /** Pauses on the first frame. */
68
+ stop: () => void;
69
+ seekToFrame: (frame: number) => void;
70
+ /** Seeks to the frame showing at that time, in seconds. */
71
+ seekToTime: (seconds: number) => void;
72
+ }
73
+ declare const AlphaVideoGpuPlayer: React.ForwardRefExoticComponent<AlphaVideoGpuPlayerProps & React.RefAttributes<AlphaVideoGpuPlayerRef>>;
74
+
75
+ export { KTX2LoadEvent as AlphaVideoGpuLoadEvent, AlphaVideoGpuPlayer, type AlphaVideoGpuPlayerProps, type AlphaVideoGpuPlayerRef, KTX2Source as AlphaVideoGpuSource, KTX2Storage as AlphaVideoGpuStorage, MemoryStrategy, PlayerState };