visual-song 0.11.6 → 0.11.7
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 +2 -0
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ type VisualSongRef = {
|
|
|
54
54
|
updateLayout(): void;
|
|
55
55
|
setVertexShaderTransition(shader: string, mode: number, time: number, vertexCount: number, backgroundColor: Float32Array, easingType: EasingType): boolean;
|
|
56
56
|
_render(): void;
|
|
57
|
+
requestFullscreen(): void;
|
|
58
|
+
setIsSquare(isSquare: boolean): void;
|
|
57
59
|
};
|
|
58
60
|
type Props = {
|
|
59
61
|
style?: React.CSSProperties;
|
package/dist/index.js
CHANGED
|
@@ -6210,6 +6210,7 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6210
6210
|
const canvasWrapperRef = useRef(null);
|
|
6211
6211
|
const glContextRef = useRef(null);
|
|
6212
6212
|
const module = useRef(null);
|
|
6213
|
+
const isSquareRef = useRef(true);
|
|
6213
6214
|
useImperativeHandle(ref, ()=>({
|
|
6214
6215
|
resumeMainLoop () {
|
|
6215
6216
|
module.current.resumeMainLoop();
|
|
@@ -6294,6 +6295,13 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6294
6295
|
},
|
|
6295
6296
|
_render () {
|
|
6296
6297
|
module.current.frame();
|
|
6298
|
+
},
|
|
6299
|
+
requestFullscreen () {
|
|
6300
|
+
canvasWrapperRef.current.requestFullscreen();
|
|
6301
|
+
},
|
|
6302
|
+
setIsSquare (isSquare) {
|
|
6303
|
+
isSquareRef.current = isSquare;
|
|
6304
|
+
updateLayout();
|
|
6297
6305
|
}
|
|
6298
6306
|
}), []);
|
|
6299
6307
|
useEffect(()=>{
|
|
@@ -6398,8 +6406,7 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6398
6406
|
async function _init() {
|
|
6399
6407
|
await createModule().then((tempModule)=>{
|
|
6400
6408
|
module.current = tempModule;
|
|
6401
|
-
|
|
6402
|
-
module.current.initialize(temp_buffer_size, temp_buffer_size, `#${canvasRef.current.id}`);
|
|
6409
|
+
module.current.initialize(canvasRef.current.width, canvasRef.current.height, `#${canvasRef.current.id}`);
|
|
6403
6410
|
glContextRef.current = canvasRef.current.getContext('webgl2');
|
|
6404
6411
|
if (mainLoop !== undefined) {
|
|
6405
6412
|
if (mainLoop) {
|
|
@@ -6449,15 +6456,24 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6449
6456
|
if (!wrapperWidth || !wrapperHeight) {
|
|
6450
6457
|
return;
|
|
6451
6458
|
}
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
if (
|
|
6455
|
-
|
|
6456
|
-
|
|
6459
|
+
let canvasWidth = wrapperWidth;
|
|
6460
|
+
let canvasHeight = wrapperHeight;
|
|
6461
|
+
if (isSquareRef.current) {
|
|
6462
|
+
canvasWidth = Math.min(wrapperWidth, wrapperHeight);
|
|
6463
|
+
canvasHeight = canvasWidth;
|
|
6464
|
+
const divAspectRatio = wrapperWidth / wrapperHeight;
|
|
6465
|
+
if (1.0 > divAspectRatio) {
|
|
6466
|
+
canvas.style.setProperty("width", "100%");
|
|
6467
|
+
canvas.style.setProperty("height", `${canvasHeight}px`);
|
|
6468
|
+
} else {
|
|
6469
|
+
canvas.style.setProperty("width", `${Math.floor(canvasWidth)}px`);
|
|
6470
|
+
canvas.style.setProperty("height", "100%");
|
|
6471
|
+
}
|
|
6457
6472
|
} else {
|
|
6473
|
+
canvas.style.setProperty("width", "100%");
|
|
6458
6474
|
canvas.style.setProperty("height", "100%");
|
|
6459
|
-
canvas.style.setProperty("width", `${Math.floor(wrapperHeight)}px`);
|
|
6460
6475
|
}
|
|
6476
|
+
_resizeRenderer(window.devicePixelRatio * canvasWidth, window.devicePixelRatio * canvasHeight);
|
|
6461
6477
|
}
|
|
6462
6478
|
function destroy() {
|
|
6463
6479
|
if (module.current) {
|
|
@@ -6467,6 +6483,10 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6467
6483
|
glContextRef.current = null;
|
|
6468
6484
|
}
|
|
6469
6485
|
}
|
|
6486
|
+
// 전체화면 상태로 남지 않도록 정리
|
|
6487
|
+
if (document && document.exitFullscreen && document.fullscreenElement === canvasWrapperRef.current) {
|
|
6488
|
+
document.exitFullscreen().catch(()=>{});
|
|
6489
|
+
}
|
|
6470
6490
|
module.current = null;
|
|
6471
6491
|
}
|
|
6472
6492
|
return /*#__PURE__*/ jsx("div", {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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