web-audio-recorder-ts 1.0.1 → 1.0.2
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.cjs.js +68 -52
- package/dist/index.esm.js +68 -52
- package/dist/index.umd.js +68 -52
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -702,35 +702,43 @@ function loadOggVorbisEncoderInternal(scriptUrl) {
|
|
|
702
702
|
});
|
|
703
703
|
return;
|
|
704
704
|
}
|
|
705
|
-
//
|
|
706
|
-
fetch(scriptUrl, { method: '
|
|
705
|
+
// Verificar se o arquivo existe e é JavaScript válido
|
|
706
|
+
fetch(scriptUrl, { method: 'GET', cache: 'no-cache' })
|
|
707
707
|
.then(response => {
|
|
708
708
|
if (!response.ok) {
|
|
709
|
-
throw new Error(`File not found: ${scriptUrl} (${response.status})`);
|
|
709
|
+
throw new Error(`File not found: ${scriptUrl} (${response.status} ${response.statusText})`);
|
|
710
710
|
}
|
|
711
|
-
//
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
//
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
711
|
+
// Verificar se o conteúdo é JavaScript (não HTML)
|
|
712
|
+
return response.text().then(text => {
|
|
713
|
+
// Se começar com '<', provavelmente é HTML (erro 404, etc)
|
|
714
|
+
if (text.trim().startsWith('<')) {
|
|
715
|
+
throw new Error(`Invalid response from ${scriptUrl}. Expected JavaScript but received HTML. This usually means the file was not found (404).`);
|
|
716
|
+
}
|
|
717
|
+
// Criar e carregar novo script
|
|
718
|
+
const script = document.createElement('script');
|
|
719
|
+
script.src = scriptUrl;
|
|
720
|
+
script.async = false; // Carregar de forma síncrona para garantir ordem
|
|
721
|
+
script.type = 'text/javascript';
|
|
722
|
+
script.onload = () => {
|
|
723
|
+
// Aguardar um pouco para garantir que o objeto global foi criado
|
|
724
|
+
setTimeout(() => {
|
|
725
|
+
if (typeof window.OggVorbisEncoder !== 'undefined') {
|
|
726
|
+
resolve();
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
reject(new Error('OggVorbisEncoder object not found after script load. The script may not have exported the global correctly.'));
|
|
730
|
+
}
|
|
731
|
+
}, 200);
|
|
732
|
+
};
|
|
733
|
+
script.onerror = (event) => {
|
|
734
|
+
const error = new Error(`Failed to load OggVorbisEncoder script from ${scriptUrl}. Check browser console for CORS or network errors. Make sure the file exists and is accessible.`);
|
|
735
|
+
console.error('Script load error:', event);
|
|
736
|
+
console.error('Script URL:', scriptUrl);
|
|
737
|
+
console.error('Try accessing the URL directly in your browser to verify it exists.');
|
|
738
|
+
reject(error);
|
|
739
|
+
};
|
|
740
|
+
document.head.appendChild(script);
|
|
741
|
+
});
|
|
734
742
|
})
|
|
735
743
|
.catch(error => {
|
|
736
744
|
reject(new Error(`Cannot access OggVorbisEncoder script at ${scriptUrl}: ${error.message}`));
|
|
@@ -861,35 +869,43 @@ function loadMp3LameEncoderInternal(scriptUrl) {
|
|
|
861
869
|
});
|
|
862
870
|
return;
|
|
863
871
|
}
|
|
864
|
-
//
|
|
865
|
-
fetch(scriptUrl, { method: '
|
|
872
|
+
// Verificar se o arquivo existe e é JavaScript válido
|
|
873
|
+
fetch(scriptUrl, { method: 'GET', cache: 'no-cache' })
|
|
866
874
|
.then(response => {
|
|
867
875
|
if (!response.ok) {
|
|
868
|
-
throw new Error(`File not found: ${scriptUrl} (${response.status})`);
|
|
876
|
+
throw new Error(`File not found: ${scriptUrl} (${response.status} ${response.statusText})`);
|
|
869
877
|
}
|
|
870
|
-
//
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
//
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
878
|
+
// Verificar se o conteúdo é JavaScript (não HTML)
|
|
879
|
+
return response.text().then(text => {
|
|
880
|
+
// Se começar com '<', provavelmente é HTML (erro 404, etc)
|
|
881
|
+
if (text.trim().startsWith('<')) {
|
|
882
|
+
throw new Error(`Invalid response from ${scriptUrl}. Expected JavaScript but received HTML. This usually means the file was not found (404).`);
|
|
883
|
+
}
|
|
884
|
+
// Criar e carregar novo script
|
|
885
|
+
const script = document.createElement('script');
|
|
886
|
+
script.src = scriptUrl;
|
|
887
|
+
script.async = false; // Carregar de forma síncrona para garantir ordem
|
|
888
|
+
script.type = 'text/javascript';
|
|
889
|
+
script.onload = () => {
|
|
890
|
+
// Aguardar um pouco para garantir que o objeto global foi criado
|
|
891
|
+
setTimeout(() => {
|
|
892
|
+
if (typeof window.Mp3LameEncoder !== 'undefined') {
|
|
893
|
+
resolve();
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
reject(new Error('Mp3LameEncoder object not found after script load. The script may not have exported the global correctly.'));
|
|
897
|
+
}
|
|
898
|
+
}, 200);
|
|
899
|
+
};
|
|
900
|
+
script.onerror = (event) => {
|
|
901
|
+
const error = new Error(`Failed to load Mp3LameEncoder script from ${scriptUrl}. Check browser console for CORS or network errors. Make sure the file exists and is accessible.`);
|
|
902
|
+
console.error('Script load error:', event);
|
|
903
|
+
console.error('Script URL:', scriptUrl);
|
|
904
|
+
console.error('Try accessing the URL directly in your browser to verify it exists.');
|
|
905
|
+
reject(error);
|
|
906
|
+
};
|
|
907
|
+
document.head.appendChild(script);
|
|
908
|
+
});
|
|
893
909
|
})
|
|
894
910
|
.catch(error => {
|
|
895
911
|
reject(new Error(`Cannot access Mp3LameEncoder script at ${scriptUrl}: ${error.message}`));
|
package/dist/index.esm.js
CHANGED
|
@@ -699,35 +699,43 @@ function loadOggVorbisEncoderInternal(scriptUrl) {
|
|
|
699
699
|
});
|
|
700
700
|
return;
|
|
701
701
|
}
|
|
702
|
-
//
|
|
703
|
-
fetch(scriptUrl, { method: '
|
|
702
|
+
// Verificar se o arquivo existe e é JavaScript válido
|
|
703
|
+
fetch(scriptUrl, { method: 'GET', cache: 'no-cache' })
|
|
704
704
|
.then(response => {
|
|
705
705
|
if (!response.ok) {
|
|
706
|
-
throw new Error(`File not found: ${scriptUrl} (${response.status})`);
|
|
706
|
+
throw new Error(`File not found: ${scriptUrl} (${response.status} ${response.statusText})`);
|
|
707
707
|
}
|
|
708
|
-
//
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
//
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
708
|
+
// Verificar se o conteúdo é JavaScript (não HTML)
|
|
709
|
+
return response.text().then(text => {
|
|
710
|
+
// Se começar com '<', provavelmente é HTML (erro 404, etc)
|
|
711
|
+
if (text.trim().startsWith('<')) {
|
|
712
|
+
throw new Error(`Invalid response from ${scriptUrl}. Expected JavaScript but received HTML. This usually means the file was not found (404).`);
|
|
713
|
+
}
|
|
714
|
+
// Criar e carregar novo script
|
|
715
|
+
const script = document.createElement('script');
|
|
716
|
+
script.src = scriptUrl;
|
|
717
|
+
script.async = false; // Carregar de forma síncrona para garantir ordem
|
|
718
|
+
script.type = 'text/javascript';
|
|
719
|
+
script.onload = () => {
|
|
720
|
+
// Aguardar um pouco para garantir que o objeto global foi criado
|
|
721
|
+
setTimeout(() => {
|
|
722
|
+
if (typeof window.OggVorbisEncoder !== 'undefined') {
|
|
723
|
+
resolve();
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
reject(new Error('OggVorbisEncoder object not found after script load. The script may not have exported the global correctly.'));
|
|
727
|
+
}
|
|
728
|
+
}, 200);
|
|
729
|
+
};
|
|
730
|
+
script.onerror = (event) => {
|
|
731
|
+
const error = new Error(`Failed to load OggVorbisEncoder script from ${scriptUrl}. Check browser console for CORS or network errors. Make sure the file exists and is accessible.`);
|
|
732
|
+
console.error('Script load error:', event);
|
|
733
|
+
console.error('Script URL:', scriptUrl);
|
|
734
|
+
console.error('Try accessing the URL directly in your browser to verify it exists.');
|
|
735
|
+
reject(error);
|
|
736
|
+
};
|
|
737
|
+
document.head.appendChild(script);
|
|
738
|
+
});
|
|
731
739
|
})
|
|
732
740
|
.catch(error => {
|
|
733
741
|
reject(new Error(`Cannot access OggVorbisEncoder script at ${scriptUrl}: ${error.message}`));
|
|
@@ -858,35 +866,43 @@ function loadMp3LameEncoderInternal(scriptUrl) {
|
|
|
858
866
|
});
|
|
859
867
|
return;
|
|
860
868
|
}
|
|
861
|
-
//
|
|
862
|
-
fetch(scriptUrl, { method: '
|
|
869
|
+
// Verificar se o arquivo existe e é JavaScript válido
|
|
870
|
+
fetch(scriptUrl, { method: 'GET', cache: 'no-cache' })
|
|
863
871
|
.then(response => {
|
|
864
872
|
if (!response.ok) {
|
|
865
|
-
throw new Error(`File not found: ${scriptUrl} (${response.status})`);
|
|
873
|
+
throw new Error(`File not found: ${scriptUrl} (${response.status} ${response.statusText})`);
|
|
866
874
|
}
|
|
867
|
-
//
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
//
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
875
|
+
// Verificar se o conteúdo é JavaScript (não HTML)
|
|
876
|
+
return response.text().then(text => {
|
|
877
|
+
// Se começar com '<', provavelmente é HTML (erro 404, etc)
|
|
878
|
+
if (text.trim().startsWith('<')) {
|
|
879
|
+
throw new Error(`Invalid response from ${scriptUrl}. Expected JavaScript but received HTML. This usually means the file was not found (404).`);
|
|
880
|
+
}
|
|
881
|
+
// Criar e carregar novo script
|
|
882
|
+
const script = document.createElement('script');
|
|
883
|
+
script.src = scriptUrl;
|
|
884
|
+
script.async = false; // Carregar de forma síncrona para garantir ordem
|
|
885
|
+
script.type = 'text/javascript';
|
|
886
|
+
script.onload = () => {
|
|
887
|
+
// Aguardar um pouco para garantir que o objeto global foi criado
|
|
888
|
+
setTimeout(() => {
|
|
889
|
+
if (typeof window.Mp3LameEncoder !== 'undefined') {
|
|
890
|
+
resolve();
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
reject(new Error('Mp3LameEncoder object not found after script load. The script may not have exported the global correctly.'));
|
|
894
|
+
}
|
|
895
|
+
}, 200);
|
|
896
|
+
};
|
|
897
|
+
script.onerror = (event) => {
|
|
898
|
+
const error = new Error(`Failed to load Mp3LameEncoder script from ${scriptUrl}. Check browser console for CORS or network errors. Make sure the file exists and is accessible.`);
|
|
899
|
+
console.error('Script load error:', event);
|
|
900
|
+
console.error('Script URL:', scriptUrl);
|
|
901
|
+
console.error('Try accessing the URL directly in your browser to verify it exists.');
|
|
902
|
+
reject(error);
|
|
903
|
+
};
|
|
904
|
+
document.head.appendChild(script);
|
|
905
|
+
});
|
|
890
906
|
})
|
|
891
907
|
.catch(error => {
|
|
892
908
|
reject(new Error(`Cannot access Mp3LameEncoder script at ${scriptUrl}: ${error.message}`));
|
package/dist/index.umd.js
CHANGED
|
@@ -706,35 +706,43 @@
|
|
|
706
706
|
});
|
|
707
707
|
return;
|
|
708
708
|
}
|
|
709
|
-
//
|
|
710
|
-
fetch(scriptUrl, { method: '
|
|
709
|
+
// Verificar se o arquivo existe e é JavaScript válido
|
|
710
|
+
fetch(scriptUrl, { method: 'GET', cache: 'no-cache' })
|
|
711
711
|
.then(response => {
|
|
712
712
|
if (!response.ok) {
|
|
713
|
-
throw new Error(`File not found: ${scriptUrl} (${response.status})`);
|
|
713
|
+
throw new Error(`File not found: ${scriptUrl} (${response.status} ${response.statusText})`);
|
|
714
714
|
}
|
|
715
|
-
//
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
//
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
715
|
+
// Verificar se o conteúdo é JavaScript (não HTML)
|
|
716
|
+
return response.text().then(text => {
|
|
717
|
+
// Se começar com '<', provavelmente é HTML (erro 404, etc)
|
|
718
|
+
if (text.trim().startsWith('<')) {
|
|
719
|
+
throw new Error(`Invalid response from ${scriptUrl}. Expected JavaScript but received HTML. This usually means the file was not found (404).`);
|
|
720
|
+
}
|
|
721
|
+
// Criar e carregar novo script
|
|
722
|
+
const script = document.createElement('script');
|
|
723
|
+
script.src = scriptUrl;
|
|
724
|
+
script.async = false; // Carregar de forma síncrona para garantir ordem
|
|
725
|
+
script.type = 'text/javascript';
|
|
726
|
+
script.onload = () => {
|
|
727
|
+
// Aguardar um pouco para garantir que o objeto global foi criado
|
|
728
|
+
setTimeout(() => {
|
|
729
|
+
if (typeof window.OggVorbisEncoder !== 'undefined') {
|
|
730
|
+
resolve();
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
reject(new Error('OggVorbisEncoder object not found after script load. The script may not have exported the global correctly.'));
|
|
734
|
+
}
|
|
735
|
+
}, 200);
|
|
736
|
+
};
|
|
737
|
+
script.onerror = (event) => {
|
|
738
|
+
const error = new Error(`Failed to load OggVorbisEncoder script from ${scriptUrl}. Check browser console for CORS or network errors. Make sure the file exists and is accessible.`);
|
|
739
|
+
console.error('Script load error:', event);
|
|
740
|
+
console.error('Script URL:', scriptUrl);
|
|
741
|
+
console.error('Try accessing the URL directly in your browser to verify it exists.');
|
|
742
|
+
reject(error);
|
|
743
|
+
};
|
|
744
|
+
document.head.appendChild(script);
|
|
745
|
+
});
|
|
738
746
|
})
|
|
739
747
|
.catch(error => {
|
|
740
748
|
reject(new Error(`Cannot access OggVorbisEncoder script at ${scriptUrl}: ${error.message}`));
|
|
@@ -865,35 +873,43 @@
|
|
|
865
873
|
});
|
|
866
874
|
return;
|
|
867
875
|
}
|
|
868
|
-
//
|
|
869
|
-
fetch(scriptUrl, { method: '
|
|
876
|
+
// Verificar se o arquivo existe e é JavaScript válido
|
|
877
|
+
fetch(scriptUrl, { method: 'GET', cache: 'no-cache' })
|
|
870
878
|
.then(response => {
|
|
871
879
|
if (!response.ok) {
|
|
872
|
-
throw new Error(`File not found: ${scriptUrl} (${response.status})`);
|
|
880
|
+
throw new Error(`File not found: ${scriptUrl} (${response.status} ${response.statusText})`);
|
|
873
881
|
}
|
|
874
|
-
//
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
//
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
882
|
+
// Verificar se o conteúdo é JavaScript (não HTML)
|
|
883
|
+
return response.text().then(text => {
|
|
884
|
+
// Se começar com '<', provavelmente é HTML (erro 404, etc)
|
|
885
|
+
if (text.trim().startsWith('<')) {
|
|
886
|
+
throw new Error(`Invalid response from ${scriptUrl}. Expected JavaScript but received HTML. This usually means the file was not found (404).`);
|
|
887
|
+
}
|
|
888
|
+
// Criar e carregar novo script
|
|
889
|
+
const script = document.createElement('script');
|
|
890
|
+
script.src = scriptUrl;
|
|
891
|
+
script.async = false; // Carregar de forma síncrona para garantir ordem
|
|
892
|
+
script.type = 'text/javascript';
|
|
893
|
+
script.onload = () => {
|
|
894
|
+
// Aguardar um pouco para garantir que o objeto global foi criado
|
|
895
|
+
setTimeout(() => {
|
|
896
|
+
if (typeof window.Mp3LameEncoder !== 'undefined') {
|
|
897
|
+
resolve();
|
|
898
|
+
}
|
|
899
|
+
else {
|
|
900
|
+
reject(new Error('Mp3LameEncoder object not found after script load. The script may not have exported the global correctly.'));
|
|
901
|
+
}
|
|
902
|
+
}, 200);
|
|
903
|
+
};
|
|
904
|
+
script.onerror = (event) => {
|
|
905
|
+
const error = new Error(`Failed to load Mp3LameEncoder script from ${scriptUrl}. Check browser console for CORS or network errors. Make sure the file exists and is accessible.`);
|
|
906
|
+
console.error('Script load error:', event);
|
|
907
|
+
console.error('Script URL:', scriptUrl);
|
|
908
|
+
console.error('Try accessing the URL directly in your browser to verify it exists.');
|
|
909
|
+
reject(error);
|
|
910
|
+
};
|
|
911
|
+
document.head.appendChild(script);
|
|
912
|
+
});
|
|
897
913
|
})
|
|
898
914
|
.catch(error => {
|
|
899
915
|
reject(new Error(`Cannot access Mp3LameEncoder script at ${scriptUrl}: ${error.message}`));
|
package/package.json
CHANGED