fix: use esm.sh CDN to resolve spessasynth_core bare import

- jdelivr raw index.js has bare import 'spessasynth_core' which browser can't resolve
- esm.sh automatically rewrites bare imports to full URLs
- Keep jdelivr for worklet processor (self-contained, no imports)
- WorkerSynthesizer fallback also uses esm.sh
This commit is contained in:
2026-07-26 18:09:12 +07:00
parent 0d1ef0f895
commit 09def59cac
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -68,7 +68,8 @@
} catch (e) { } catch (e) {
console.warn("[SonicSF] SpessaSynth AudioWorklet init failed:", e, "- trying WorkerSynthesizer..."); console.warn("[SonicSF] SpessaSynth AudioWorklet init failed:", e, "- trying WorkerSynthesizer...");
try { try {
const { WorkerSynthesizer } = await import(window.__SpessaSynthCDN + "index.js"); const mod = await import("https://esm.sh/spessasynth_lib@4.3.1");
const WorkerSynthesizer = mod.WorkerSynthesizer;
_synthInstance = new WorkerSynthesizer(audioContext); _synthInstance = new WorkerSynthesizer(audioContext);
await _synthInstance.isReady; await _synthInstance.isReady;
_initialized = true; _initialized = true;
+2 -2
View File
@@ -11,10 +11,10 @@
<script src="https://unpkg.com/react@18.3.1/umd/react.production.min.js"></script> <script src="https://unpkg.com/react@18.3.1/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js"></script> <script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js"></script>
<script type="module"> <script type="module">
import { WorkletSynthesizer } from 'https://cdn.jsdelivr.net/npm/spessasynth_lib@4.3.1/dist/index.js'; import { WorkletSynthesizer } from 'https://esm.sh/spessasynth_lib@4.3.1';
window.SpessaSynthClass = WorkletSynthesizer; window.SpessaSynthClass = WorkletSynthesizer;
window.__SpessaSynthCDN = 'https://cdn.jsdelivr.net/npm/spessasynth_lib@4.3.1/dist/'; window.__SpessaSynthCDN = 'https://cdn.jsdelivr.net/npm/spessasynth_lib@4.3.1/dist/';
console.log('[SonicSF] SpessaSynth library loaded.'); console.log('[SonicSF] SpessaSynth library loaded via esm.sh.');
</script> </script>
<script src="/static/js/services/api.js?v=202607232105"></script> <script src="/static/js/services/api.js?v=202607232105"></script>
<script src="/static/js/services/audioEngine.js?v=202607232105"></script> <script src="/static/js/services/audioEngine.js?v=202607232105"></script>