visual-song 0.13.7 → 0.13.8

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 CHANGED
@@ -48,7 +48,7 @@ type VisualSongAudioRef = {
48
48
  setLoop(loop: boolean): void;
49
49
  };
50
50
  declare function useVisualSongAudio(file?: File): VisualSongAudioRef;
51
- declare function setMainLoop(loop: boolean): void;
51
+ declare function useMainLoop(): (loop: boolean) => void;
52
52
  type VisualSongRef = {
53
53
  IsInitialized(): boolean;
54
54
  getBackgroundColor(): Float32Array;
@@ -81,5 +81,5 @@ type Props = {
81
81
  };
82
82
  declare const VisualSong: react.ForwardRefExoticComponent<Props & react.RefAttributes<VisualSongRef>>;
83
83
 
84
- export { EasingType, RenderMode, VisualSong, VisualSongProvider, setMainLoop, useVisualSongAudio };
84
+ export { EasingType, RenderMode, VisualSong, VisualSongProvider, useMainLoop, useVisualSongAudio };
85
85
  export type { VisualSongAudioRef, VisualSongRef };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useState, useEffect, createContext, useContext, useRef, useImperativeHandle } from 'react';
2
+ import { forwardRef, useState, useEffect, createContext, useContext, useCallback, useRef, useImperativeHandle } from 'react';
3
3
 
4
4
  function _define_property(obj, key, value) {
5
5
  if (key in obj) {
@@ -6312,14 +6312,15 @@ function useVisualSongAudio(file) {
6312
6312
  }
6313
6313
  };
6314
6314
  }
6315
- function setMainLoop(loop) {
6315
+ function useMainLoop() {
6316
6316
  const { module } = useContext(VisualSongContext);
6317
- if (!module) return;
6318
- if (loop) {
6319
- module.resumeMainLoop();
6320
- } else {
6321
- module.pauseMainLoop();
6322
- }
6317
+ return useCallback((loop)=>{
6318
+ if (!module) return;
6319
+ if (loop) module.resumeMainLoop();
6320
+ else module.pauseMainLoop();
6321
+ }, [
6322
+ module
6323
+ ]);
6323
6324
  }
6324
6325
  const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, backgroundColor, vertexShader, primitiveMode, vertexCount, useSinWaveOnly, renderMode, initializedCallback }, ref) {
6325
6326
  const canvasRef = useRef(null);
@@ -6600,4 +6601,4 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, backgro
6600
6601
  });
6601
6602
  });
6602
6603
 
6603
- export { EasingType, RenderMode, VisualSong, VisualSongProvider, setMainLoop, useVisualSongAudio };
6604
+ export { EasingType, RenderMode, VisualSong, VisualSongProvider, useMainLoop, useVisualSongAudio };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visual-song",
3
- "version": "0.13.7",
3
+ "version": "0.13.8",
4
4
  "description": "visual-song core library",
5
5
  "author": "kunyoungparkk (rjsdud3263@gmail.com)",
6
6
  "license": "MIT",