fix: use importmap to resolve spessasynth_core bare import

- Add importmap in index.html to map spessasynth_core to CDN URL
- Load spessasynth_lib from CDN directly (with importmap resolving deps)
- WorkerSynthesizer fallback also uses CDN import
- Ensures library and processor use same spessasynth_core version
This commit is contained in:
2026-07-26 18:55:08 +07:00
parent 50847fc440
commit 263c4be409
2 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -67,7 +67,7 @@
_initInProgress = false;
console.warn("[SonicSF] AudioWorklet failed, trying WorkerSynthesizer:", e);
try {
const mod = await import("https://esm.sh/spessasynth_lib@4.3.1");
const mod = await import("https://cdn.jsdelivr.net/npm/spessasynth_lib@4.3.1/dist/index.js");
_synthInstance = new mod.WorkerSynthesizer(audioContext);
await _synthInstance.isReady;
_initialized = true;
+10 -3
View File
@@ -10,11 +10,18 @@
<script src="https://unpkg.com/lucide@latest"></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 type="importmap">
{
"imports": {
"spessasynth_core": "https://cdn.jsdelivr.net/npm/spessasynth_core@latest/dist/spessasynth_core.mjs"
}
}
</script>
<script type="module">
import { WorkletSynthesizer } from 'https://esm.sh/spessasynth_lib@4.3.1';
import { WorkletSynthesizer } from 'https://cdn.jsdelivr.net/npm/spessasynth_lib@4.3.1/dist/index.js';
window.SpessaSynthClass = WorkletSynthesizer;
window.__SpessaSynthCDN = '/static/js/services/';
console.log('[SonicSF] SpessaSynth library loaded via esm.sh.');
window.__SpessaSynthCDN = 'https://cdn.jsdelivr.net/npm/spessasynth_lib@4.3.1/dist/';
console.log('[SonicSF] SpessaSynth library loaded from CDN.');
</script>
<script src="/static/js/services/api.js?v=202607232105"></script>
<script src="/static/js/services/audioEngine.js?v=202607232105"></script>