Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复vite下 Lame is undefined 、 mpegmode is undefined #102

Open
liluyao1998 opened this issue Dec 12, 2024 · 0 comments
Open

修复vite下 Lame is undefined 、 mpegmode is undefined #102

liluyao1998 opened this issue Dec 12, 2024 · 0 comments

Comments

@liluyao1998
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/lamejs/src/js/BitStream.js b/node_modules/lamejs/src/js/BitStream.js
index dd9d69f..7a187a1 100644
--- a/node_modules/lamejs/src/js/BitStream.js
+++ b/node_modules/lamejs/src/js/BitStream.js
@@ -18,6 +18,7 @@ var Takehiro = require('./Takehiro.js');
 var Tables = require('./Tables.js');
 var Encoder = require('./Encoder.js');
 var LameInternalFlags = require('./LameInternalFlags.js');
+var Lame = require('./Lame.js');
 
 BitStream.EQ = function (a, b) {
     return (Math.abs(a) > Math.abs(b)) ? (Math.abs((a) - (b)) <= (Math
diff --git a/node_modules/lamejs/src/js/Encoder.js b/node_modules/lamejs/src/js/Encoder.js
index 4fea74e..ad3b467 100644
--- a/node_modules/lamejs/src/js/Encoder.js
+++ b/node_modules/lamejs/src/js/Encoder.js
@@ -109,7 +109,7 @@ Encoder.fircoef = [-0.0207887 * 5, -0.0378413 * 5,
 function Encoder() {
     var NewMDCT = require('./NewMDCT.js');
     var III_psy_ratio = require('./III_psy_ratio.js');
-
+    var MPEGMode = require('./MPEGMode.js');
     var FFTOFFSET = Encoder.FFTOFFSET;
     var MPG_MD_MS_LR = Encoder.MPG_MD_MS_LR;
     //BitStream bs;
diff --git a/node_modules/lamejs/src/js/Lame.js b/node_modules/lamejs/src/js/Lame.js
index d2dc7c0..9409360 100644
--- a/node_modules/lamejs/src/js/Lame.js
+++ b/node_modules/lamejs/src/js/Lame.js
@@ -24,11 +24,10 @@ var CBRNewIterationLoop = require('./CBRNewIterationLoop.js');
 var BitStream = require('./BitStream.js');
 var Tables = require('./Tables.js');
 var Encoder = require('./Encoder.js');
-
 function Lame() {
     var self = this;
     var LAME_MAXALBUMART = (128 * 1024);
-
+    var MPEGMode = require('./MPEGMode.js');
     Lame.V9 = 410;
     Lame.V8 = 420;
     Lame.V7 = 430;
diff --git a/node_modules/lamejs/src/js/LameGlobalFlags.js b/node_modules/lamejs/src/js/LameGlobalFlags.js
index 67ba833..69ca627 100644
--- a/node_modules/lamejs/src/js/LameGlobalFlags.js
+++ b/node_modules/lamejs/src/js/LameGlobalFlags.js
@@ -1,5 +1,4 @@
 var MPEGMode = require('./MPEGMode.js');
-
 function LameGlobalFlags() {
 
     this.class_id = 0;
diff --git a/node_modules/lamejs/src/js/Presets.js b/node_modules/lamejs/src/js/Presets.js
index a3de3c6..cde353a 100644
--- a/node_modules/lamejs/src/js/Presets.js
+++ b/node_modules/lamejs/src/js/Presets.js
@@ -15,7 +15,8 @@ var new_int_n = common.new_int_n;
 var assert = common.assert;
 
 function Presets() {
-    function VBRPresets(qual, comp, compS,
+      var Lame = require('./Lame.js');
+      function VBRPresets(qual, comp, compS,
                         y, shThreshold, shThresholdS,
                         adj, adjShort, lower,
                         curve, sens, inter,
diff --git a/node_modules/lamejs/src/js/PsyModel.js b/node_modules/lamejs/src/js/PsyModel.js
index e440280..533ca4d 100644
--- a/node_modules/lamejs/src/js/PsyModel.js
+++ b/node_modules/lamejs/src/js/PsyModel.js
@@ -159,7 +159,7 @@ var FFT = require("./FFT.js");
 var Encoder = require("./Encoder.js");
 
 function PsyModel() {
-
+    var MPEGMode = require('./MPEGMode.js');
     var fft = new FFT();
 
     var LOG10 = 2.30258509299404568402;
diff --git a/node_modules/lamejs/src/js/QuantizePVT.js b/node_modules/lamejs/src/js/QuantizePVT.js
index ef69bef..68dca33 100644
--- a/node_modules/lamejs/src/js/QuantizePVT.js
+++ b/node_modules/lamejs/src/js/QuantizePVT.js
@@ -50,7 +50,7 @@ QuantizePVT.LARGE_BITS = 100000;
 QuantizePVT.IXMAX_VAL = 8206;
 
 function QuantizePVT() {
-
+  var BitStream = require('./BitStream.js');
     var tak = null;
     var rv = null;
     var psy = null;
diff --git a/node_modules/lamejs/src/js/VBRTag.js b/node_modules/lamejs/src/js/VBRTag.js
index 164405a..cb13923 100644
--- a/node_modules/lamejs/src/js/VBRTag.js
+++ b/node_modules/lamejs/src/js/VBRTag.js
@@ -829,6 +829,7 @@ function VBRTag() {
 
     this.getLameTagFrame = function (gfp, buffer) {
         var gfc = gfp.internal_flags;
+        var Lame = require('./Lame.js');
 
         if (!gfp.bWriteVbrTag) {
             return 0;

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant