@vosjs/studio-core 0.41.0 → 0.41.1

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.js CHANGED
@@ -5061,26 +5061,32 @@ var STUDIO_SETUP = `async (ctx) => {
5061
5061
  fontCache.set(oc.asset.url, font)
5062
5062
  } catch (e) { console.warn('[voila] typeface failed to load', oc.asset.url, e) }
5063
5063
  }
5064
- // Audio clips (music/SFX): pre-decode into a shared cache so first play is
5065
- // instant. The AudioContext starts suspended (autoplay policy) \u2014 onFrame
5066
- // resumes it on the first play. Failures degrade to a silent clip.
5064
+ // Audio clips (music/SFX): start decoding into the shared cache now, but
5065
+ // never hold the first frame for it. Playback starts on a press, so the
5066
+ // decodes almost always land first; one that lands later clears the
5067
+ // scheduler's signature and the next playing frame schedules it at the
5068
+ // right offset (the onFrame path does the same for clips added later).
5069
+ // Exports never read this cache: they mix offline. The AudioContext starts
5070
+ // suspended (autoplay policy); onFrame resumes it on the first play.
5071
+ // Failures degrade to a silent clip.
5067
5072
  const clips = ctx.data.audio || []
5068
5073
  if (clips.length && window.AudioContext) {
5069
5074
  const actx = ns.audioCtx || (ns.audioCtx = new window.AudioContext())
5070
5075
  const bufs = ns.audioBuffers || (ns.audioBuffers = new Map())
5071
5076
  const pend = ns.audioPending || (ns.audioPending = new Set())
5072
- await Promise.all(clips.map(async (c) => {
5073
- if (bufs.has(c.key) || pend.has(c.key)) return
5077
+ for (const c of clips) {
5078
+ if (bufs.has(c.key) || pend.has(c.key)) continue
5074
5079
  pend.add(c.key)
5075
- try {
5076
- const res = await fetch(c.key)
5077
- bufs.set(c.key, await actx.decodeAudioData(await res.arrayBuffer()))
5078
- } catch (e) {
5079
- console.warn('[voila] audio decode failed', c.key, e)
5080
- } finally {
5081
- pend.delete(c.key)
5082
- }
5083
- }))
5080
+ fetch(c.key)
5081
+ .then((res) => res.arrayBuffer())
5082
+ .then((ab) => actx.decodeAudioData(ab))
5083
+ .then((b) => {
5084
+ bufs.set(c.key, b)
5085
+ if (ns.audioSched) ns.audioSched.sig = ''
5086
+ })
5087
+ .catch((e) => console.warn('[voila] audio decode failed', c.key, e))
5088
+ .then(() => pend.delete(c.key))
5089
+ }
5084
5090
  }
5085
5091
  }`;
5086
5092
  var STUDIO_CONTENT = `(ctx) => {