visual-song 0.13.1 → 0.13.3
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.d.ts +8 -4
- package/dist/index.js +52 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ declare enum EasingType {
|
|
|
29
29
|
OutBounce = 23,
|
|
30
30
|
InOutBounce = 24
|
|
31
31
|
}
|
|
32
|
+
declare enum RenderMode {
|
|
33
|
+
CONTINUOUS = "CONTINUOUS",
|
|
34
|
+
ONCE = "ONCE",
|
|
35
|
+
PAUSED = "PAUSED"
|
|
36
|
+
}
|
|
32
37
|
declare function VisualSongProvider({ children }: PropsWithChildren<{}>): react_jsx_runtime.JSX.Element;
|
|
33
38
|
type VisualSongAudioRef = {
|
|
34
39
|
play(): void;
|
|
@@ -45,8 +50,6 @@ type VisualSongAudioRef = {
|
|
|
45
50
|
declare function useVisualSongAudio(file?: File): VisualSongAudioRef;
|
|
46
51
|
type VisualSongRef = {
|
|
47
52
|
IsInitialized(): boolean;
|
|
48
|
-
resumeMainLoop(): void;
|
|
49
|
-
pauseMainLoop(): void;
|
|
50
53
|
getBackgroundColor(): Float32Array;
|
|
51
54
|
setBackgroundColor(color: Float32Array): void;
|
|
52
55
|
setVertexShader(shader: string): boolean;
|
|
@@ -64,14 +67,15 @@ type VisualSongRef = {
|
|
|
64
67
|
};
|
|
65
68
|
type Props = {
|
|
66
69
|
style?: React.CSSProperties;
|
|
67
|
-
mainLoop?: boolean;
|
|
68
70
|
backgroundColor?: Float32Array;
|
|
69
71
|
vertexShader?: string;
|
|
70
72
|
primitiveMode?: number;
|
|
71
73
|
vertexCount?: number;
|
|
74
|
+
useSinWaveOnly?: boolean;
|
|
75
|
+
renderMode?: RenderMode;
|
|
72
76
|
initializedCallback?: () => void;
|
|
73
77
|
};
|
|
74
78
|
declare const VisualSong: react.ForwardRefExoticComponent<Props & react.RefAttributes<VisualSongRef>>;
|
|
75
79
|
|
|
76
|
-
export { EasingType, VisualSong, VisualSongProvider, useVisualSongAudio };
|
|
80
|
+
export { EasingType, RenderMode, VisualSong, VisualSongProvider, useVisualSongAudio };
|
|
77
81
|
export type { VisualSongAudioRef, VisualSongRef };
|
package/dist/index.js
CHANGED
|
@@ -6203,6 +6203,12 @@ var EasingType = /*#__PURE__*/ function(EasingType) {
|
|
|
6203
6203
|
EasingType[EasingType["InOutBounce"] = 24] = "InOutBounce";
|
|
6204
6204
|
return EasingType;
|
|
6205
6205
|
}({});
|
|
6206
|
+
var RenderMode = /*#__PURE__*/ function(RenderMode) {
|
|
6207
|
+
RenderMode["CONTINUOUS"] = "CONTINUOUS";
|
|
6208
|
+
RenderMode["ONCE"] = "ONCE";
|
|
6209
|
+
RenderMode["PAUSED"] = "PAUSED";
|
|
6210
|
+
return RenderMode;
|
|
6211
|
+
}({});
|
|
6206
6212
|
const VisualSongContext = /*#__PURE__*/ createContext({
|
|
6207
6213
|
module: null
|
|
6208
6214
|
});
|
|
@@ -6303,7 +6309,7 @@ function useVisualSongAudio(file) {
|
|
|
6303
6309
|
}
|
|
6304
6310
|
};
|
|
6305
6311
|
}
|
|
6306
|
-
const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style,
|
|
6312
|
+
const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, backgroundColor, vertexShader, primitiveMode, vertexCount, useSinWaveOnly, renderMode, initializedCallback }, ref) {
|
|
6307
6313
|
const canvasRef = useRef(null);
|
|
6308
6314
|
const canvasWrapperRef = useRef(null);
|
|
6309
6315
|
const glContextRef = useRef(null);
|
|
@@ -6317,12 +6323,12 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6317
6323
|
});
|
|
6318
6324
|
const useCustomResolutionRef = useRef(false);
|
|
6319
6325
|
useImperativeHandle(ref, ()=>({
|
|
6320
|
-
resumeMainLoop
|
|
6321
|
-
|
|
6322
|
-
},
|
|
6323
|
-
pauseMainLoop
|
|
6324
|
-
|
|
6325
|
-
},
|
|
6326
|
+
// resumeMainLoop(): void {
|
|
6327
|
+
// module.current!.resumeMainLoop();
|
|
6328
|
+
// },
|
|
6329
|
+
// pauseMainLoop(): void {
|
|
6330
|
+
// module.current!.pauseMainLoop();
|
|
6331
|
+
// },
|
|
6326
6332
|
IsInitialized () {
|
|
6327
6333
|
return module.current !== null && playerRef.current !== null;
|
|
6328
6334
|
},
|
|
@@ -6382,6 +6388,15 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6382
6388
|
},
|
|
6383
6389
|
setFPS (fps) {
|
|
6384
6390
|
module.current.Renderer.getInstance().setFPS(fps);
|
|
6391
|
+
},
|
|
6392
|
+
setUseSinWaveOnly (use) {
|
|
6393
|
+
playerRef.current.setUseSinWaveOnly(use);
|
|
6394
|
+
},
|
|
6395
|
+
getUseSinWaveOnly () {
|
|
6396
|
+
return playerRef.current.getUseSinWaveOnly();
|
|
6397
|
+
},
|
|
6398
|
+
setRenderMode (mode) {
|
|
6399
|
+
playerRef.current.setRenderMode(module.current.RenderMode[mode]);
|
|
6385
6400
|
}
|
|
6386
6401
|
}), []);
|
|
6387
6402
|
useEffect(()=>{
|
|
@@ -6401,18 +6416,6 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6401
6416
|
destroy();
|
|
6402
6417
|
};
|
|
6403
6418
|
}, []);
|
|
6404
|
-
useEffect(()=>{
|
|
6405
|
-
if (!module.current) return;
|
|
6406
|
-
if (typeof mainLoop === 'boolean') {
|
|
6407
|
-
if (mainLoop) {
|
|
6408
|
-
module.current.resumeMainLoop();
|
|
6409
|
-
} else {
|
|
6410
|
-
module.current.pauseMainLoop();
|
|
6411
|
-
}
|
|
6412
|
-
}
|
|
6413
|
-
}, [
|
|
6414
|
-
mainLoop
|
|
6415
|
-
]);
|
|
6416
6419
|
useEffect(()=>{
|
|
6417
6420
|
if (!module.current) return;
|
|
6418
6421
|
setBackgroundColorInternal(backgroundColor);
|
|
@@ -6443,6 +6446,22 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6443
6446
|
}, [
|
|
6444
6447
|
vertexCount
|
|
6445
6448
|
]);
|
|
6449
|
+
useEffect(()=>{
|
|
6450
|
+
if (!module.current || !playerRef.current) return;
|
|
6451
|
+
if (typeof useSinWaveOnly === 'boolean') {
|
|
6452
|
+
playerRef.current.setUseSinWaveOnly(useSinWaveOnly);
|
|
6453
|
+
}
|
|
6454
|
+
}, [
|
|
6455
|
+
useSinWaveOnly
|
|
6456
|
+
]);
|
|
6457
|
+
useEffect(()=>{
|
|
6458
|
+
if (!module.current || !playerRef.current) return;
|
|
6459
|
+
if (renderMode !== undefined) {
|
|
6460
|
+
playerRef.current.setRenderMode(module.current.RenderMode[renderMode]);
|
|
6461
|
+
}
|
|
6462
|
+
}, [
|
|
6463
|
+
renderMode
|
|
6464
|
+
]);
|
|
6446
6465
|
function setBackgroundColorInternal(color) {
|
|
6447
6466
|
if (color && color.length >= 4) {
|
|
6448
6467
|
if (!playerRef.current) return;
|
|
@@ -6467,13 +6486,13 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6467
6486
|
const renderer = module.current.Renderer.getInstance();
|
|
6468
6487
|
playerRef.current = renderer.createPlayer(width, height, `#${canvas.id}`);
|
|
6469
6488
|
glContextRef.current = canvas.getContext('webgl2');
|
|
6470
|
-
if
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
}
|
|
6489
|
+
// if(mainLoop !== undefined) {
|
|
6490
|
+
// if(mainLoop) {
|
|
6491
|
+
// module.current!.resumeMainLoop();
|
|
6492
|
+
// } else {
|
|
6493
|
+
// module.current!.pauseMainLoop();
|
|
6494
|
+
// }
|
|
6495
|
+
// }
|
|
6477
6496
|
if (backgroundColor !== undefined) {
|
|
6478
6497
|
setBackgroundColorInternal(backgroundColor);
|
|
6479
6498
|
}
|
|
@@ -6486,6 +6505,12 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6486
6505
|
if (vertexCount !== undefined) {
|
|
6487
6506
|
playerRef.current.setVertexCount(vertexCount);
|
|
6488
6507
|
}
|
|
6508
|
+
if (useSinWaveOnly !== undefined) {
|
|
6509
|
+
playerRef.current.setUseSinWaveOnly(useSinWaveOnly);
|
|
6510
|
+
}
|
|
6511
|
+
if (renderMode !== undefined) {
|
|
6512
|
+
playerRef.current.setRenderMode(module.current.RenderMode[renderMode]);
|
|
6513
|
+
}
|
|
6489
6514
|
updateLayout();
|
|
6490
6515
|
if (initializedCallback !== undefined) {
|
|
6491
6516
|
initializedCallback();
|
|
@@ -6562,4 +6587,4 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6562
6587
|
});
|
|
6563
6588
|
});
|
|
6564
6589
|
|
|
6565
|
-
export { EasingType, VisualSong, VisualSongProvider, useVisualSongAudio };
|
|
6590
|
+
export { EasingType, RenderMode, VisualSong, VisualSongProvider, useVisualSongAudio };
|