@motionscript/browser 0.1.0-alpha.0 → 0.1.0-alpha.5

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.
Files changed (90) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +48 -0
  4. package/README.md +118 -69
  5. package/dist/asset-bytes.d.ts +7 -1
  6. package/dist/asset-bytes.d.ts.map +1 -1
  7. package/dist/asset-bytes.js +14 -1
  8. package/dist/asset-bytes.js.map +1 -1
  9. package/dist/audio/bus-graph.d.ts +12 -3
  10. package/dist/audio/bus-graph.d.ts.map +1 -1
  11. package/dist/audio/bus-graph.js +24 -29
  12. package/dist/audio/bus-graph.js.map +1 -1
  13. package/dist/audio/filter-graph.d.ts +6 -5
  14. package/dist/audio/filter-graph.d.ts.map +1 -1
  15. package/dist/audio/filter-graph.js +29 -23
  16. package/dist/audio/filter-graph.js.map +1 -1
  17. package/dist/audio/index.js.map +1 -1
  18. package/dist/audio/loop-region.d.ts +31 -0
  19. package/dist/audio/loop-region.d.ts.map +1 -0
  20. package/dist/audio/loop-region.js +43 -0
  21. package/dist/audio/loop-region.js.map +1 -0
  22. package/dist/audio/mixer.d.ts.map +1 -1
  23. package/dist/audio/mixer.js +30 -11
  24. package/dist/audio/mixer.js.map +1 -1
  25. package/dist/audio/player.d.ts +4 -4
  26. package/dist/audio/player.d.ts.map +1 -1
  27. package/dist/audio/player.js +19 -15
  28. package/dist/audio/player.js.map +1 -1
  29. package/dist/browser/THIRD_PARTY_LICENSES.txt +432 -0
  30. package/dist/browser/audio.js +1 -1
  31. package/dist/browser/chunks/chunk-2MAFJWBZ.js +2 -0
  32. package/dist/browser/chunks/chunk-2MAFJWBZ.js.map +7 -0
  33. package/dist/browser/index.js +133 -279
  34. package/dist/browser/index.js.map +4 -4
  35. package/dist/browser/manifest.json +19 -2
  36. package/dist/concat.js.map +1 -1
  37. package/dist/decode/image-levels.js.map +1 -1
  38. package/dist/decode/levels.js.map +1 -1
  39. package/dist/decode/video-levels.js.map +1 -1
  40. package/dist/dynamic-nodes.d.ts.map +1 -1
  41. package/dist/dynamic-nodes.js +5 -1
  42. package/dist/dynamic-nodes.js.map +1 -1
  43. package/dist/engine.d.ts.map +1 -1
  44. package/dist/engine.js +18 -5
  45. package/dist/engine.js.map +1 -1
  46. package/dist/exporter.d.ts +10 -2
  47. package/dist/exporter.d.ts.map +1 -1
  48. package/dist/exporter.js +8 -7
  49. package/dist/exporter.js.map +1 -1
  50. package/dist/getter.js.map +1 -1
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +2 -27
  54. package/dist/index.js.map +1 -1
  55. package/dist/measure-context.js.map +1 -1
  56. package/dist/mix-timeline-audio.d.ts +2 -2
  57. package/dist/mix-timeline-audio.d.ts.map +1 -1
  58. package/dist/mix-timeline-audio.js +1 -2
  59. package/dist/mix-timeline-audio.js.map +1 -1
  60. package/dist/render-context.d.ts +5 -3
  61. package/dist/render-context.d.ts.map +1 -1
  62. package/dist/render-context.js +7 -3
  63. package/dist/render-context.js.map +1 -1
  64. package/dist/screenshot.d.ts +3 -3
  65. package/dist/screenshot.d.ts.map +1 -1
  66. package/dist/screenshot.js +1 -2
  67. package/dist/screenshot.js.map +1 -1
  68. package/dist/still.d.ts +18 -8
  69. package/dist/still.d.ts.map +1 -1
  70. package/dist/still.js +28 -21
  71. package/dist/still.js.map +1 -1
  72. package/dist/storage-adapter.d.ts +1 -1
  73. package/dist/storage-adapter.d.ts.map +1 -1
  74. package/dist/storage-adapter.js +12 -10
  75. package/dist/storage-adapter.js.map +1 -1
  76. package/dist/three/renderer.d.ts +10 -11
  77. package/dist/three/renderer.d.ts.map +1 -1
  78. package/dist/three/renderer.js +18 -13
  79. package/dist/three/renderer.js.map +1 -1
  80. package/dist/ticker.d.ts +22 -4
  81. package/dist/ticker.d.ts.map +1 -1
  82. package/dist/ticker.js +65 -28
  83. package/dist/ticker.js.map +1 -1
  84. package/package.json +8 -6
  85. package/dist/browser/chunks/chunk-NSFLRI4P.js +0 -2
  86. package/dist/browser/chunks/chunk-NSFLRI4P.js.map +0 -7
  87. package/dist/output.d.ts +0 -7
  88. package/dist/output.d.ts.map +0 -1
  89. package/dist/output.js +0 -6
  90. package/dist/output.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/audio/player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAY/G;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAC/B,OAAO,CAAe;IACtB,WAAW,CAAU;IACrB,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC5C,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IACzC,SAAS,GAAmB,EAAE,CAAC;IAC/B,QAAQ,GAAY,KAAK,CAAC;IAC1B,UAAU,CAAW;IAC7B,oEAAoE;IAC5D,KAAK,CAAgB;IACrB,KAAK,GAAG,KAAK,CAAC;IACd,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,OAAsB;QAC9B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,YAAY,EAAE,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC5C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,K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;QACH,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACL,uBAAuB;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACtD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { AudioSink, AudioRequest, sourceTimeAtSceneElapsed } from \"@motionscript/core\";\nimport { AudioBusGraph } from \"./bus-graph\";\nimport { buildAudioFilterGraph, effectiveSpeed, speedCurveOf, applySpeedToPlaybackRate } from \"./filter-graph\";\n\ntype ActiveSource = {\n source: AudioBufferSourceNode;\n gainNode: GainNode;\n request: AudioRequest;\n /** Filter-graph nodes to disconnect on teardown. */\n filterNodes: AudioNode[];\n /** Tremolo LFOs to stop on teardown. */\n oscillators: OscillatorNode[];\n};\n\n/**\n * Web Audio implementation of {@link AudioSink} — decodes and caches source\n * buffers, then schedules/plays {@link AudioRequest}s as `AudioBufferSourceNode`s\n * through a shared master gain (global mute and volume). `schedule` registers the\n * active set of requests for the current frame; `syncTo` then starts/stops\n * sources to match `sceneTime`, so playback follows scrubbing and seeks.\n */\nexport class WebAudioSink extends AudioSink {\n private context: AudioContext;\n private ownsContext: boolean;\n private bufferCache = new Map<string, AudioBuffer>();\n private decoding = new Map<string, Promise<void>>();\n private active = new Map<string, ActiveSource>();\n private scheduled: AudioRequest[] = [];\n private disposed: boolean = false;\n private masterGain: GainNode;\n /** The live bus chains, shared across every clip that names one. */\n private buses: AudioBusGraph;\n private muted = false;\n private volume = 1;\n\n constructor(context?: AudioContext) {\n super();\n this.context = context ?? new AudioContext();\n this.ownsContext = !context;\n this.masterGain = this.context.createGain();\n this.masterGain.connect(this.context.destination);\n this.buses = new AudioBusGraph(this.context, this.masterGain);\n }\n\n getContext(): AudioContext {\n return this.context;\n }\n\n /**\n * Resume the AudioContext. Must be called from within a user gesture\n * (e.g. a click handler) the first time, or browsers keep the context\n * suspended and no audio is heard.\n */\n unlock(): void {\n if (this.context.state === \"suspended\") {\n this.context.resume();\n }\n }\n\n has(src: string): boolean {\n return this.bufferCache.has(src);\n }\n\n async append(src: string, data: ArrayBuffer): Promise<void> {\n if (this.bufferCache.has(src)) return;\n const existing = this.decoding.get(src);\n if (existing) return existing;\n\n // decodeAudioData detaches `data` — that's fine, the caller in\n // AssetManager.fetchAudio discards its reference immediately after\n // awaiting append. Skipping the defensive .slice(0) saves a multi-MB\n // allocation per audio source.\n const job = this.context.decodeAudioData(data).then((buffer) => {\n this.bufferCache.set(src, buffer);\n }).finally(() => {\n this.decoding.delete(src);\n });\n this.decoding.set(src, job);\n await job;\n }\n\n /** Drops cached buffers and stops active sources for srcs/requests no longer referenced — called when the asset set changes (e.g. seeking across scene boundaries). */\n retain(keep: ReadonlySet<string>): void {\n for (const src of [...this.bufferCache.keys()]) {\n if (!keep.has(src)) this.bufferCache.delete(src);\n }\n for (const [id, active] of this.active) {\n if (!keep.has(active.request.src)) this.stopSource(id, active);\n }\n }\n\n /** Replaces the active request set; stops any currently-playing source whose request is no longer scheduled. Actual start/stop-to-match-time happens in `syncTo`. */\n schedule(requests: readonly AudioRequest[]): void {\n const next = new Set(requests.map(r => r.id));\n for (const [id, active] of this.active) {\n if (!next.has(id)) this.stopSource(id, active);\n }\n this.scheduled = requests.slice();\n }\n\n /** Starts sources whose `[startAt, endAt)` window now contains `sceneTime` (computing the correct buffer offset for the seek point) and stops any that have fallen outside it. */\n syncTo(sceneTime: number): void {\n const liveIds = new Set<string>();\n\n for (const req of this.scheduled) {\n // `endAt` is `Infinity` for an open clip, so the comparison needs no\n // nullish fallback — see AudioRequest.endAt.\n const isInWindow = sceneTime >= req.startAt && sceneTime < req.endAt;\n if (!isInWindow) continue;\n\n liveIds.add(req.id);\n if (!this.active.has(req.id)) {\n const buffer = this.bufferCache.get(req.src);\n if (buffer) this.playBuffer(buffer, req, sceneTime);\n }\n }\n\n for (const [id, active] of this.active) {\n if (!liveIds.has(id)) this.stopSource(id, active);\n }\n }\n\n async play(time: number, _speed: number, _reverse: boolean): Promise<void> {\n if (this.context.state === \"suspended\") {\n await this.context.resume();\n }\n this.syncTo(time);\n }\n\n stop(): void {\n for (const [id, active] of this.active) {\n this.stopSource(id, active);\n }\n }\n\n setMuted(muted: boolean): void {\n this.muted = muted;\n this.applyMasterGain();\n }\n\n setVolume(volume: number): void {\n this.volume = Math.max(0, volume);\n this.applyMasterGain();\n }\n\n /** Mute and volume are held separately so unmuting restores the set level. */\n private applyMasterGain(): void {\n this.masterGain.gain.value = this.muted ? 0 : this.volume;\n }\n\n /** Starts a buffer source mid-clip if `sceneTime` lands after the request's start — `audioOffset` accounts for the request's trim, the elapsed time since `startAt`, and any speed (playbackRate) change. */\n private playBuffer(buffer: AudioBuffer, req: AudioRequest, sceneTime: number): void {\n const gainNode = this.context.createGain();\n // Guard against a missing/NaN volume — a non-finite AudioParam value throws.\n gainNode.gain.value = Number.isFinite(req.volume) ? req.volume : 1;\n // Into this clip's bus chain, or straight to the master when it has none.\n // The chain is shared: two clips on one bus reach the same nodes, which is\n // what makes a bus effect one tail rather than one per clip.\n gainNode.connect(this.buses.inputFor(req.bus, this.context.currentTime));\n\n const source = this.context.createBufferSource();\n source.buffer = buffer;\n source.loop = req.loop;\n\n const scalarSpeed = effectiveSpeed(req.filters);\n const rate = Number.isFinite(scalarSpeed) && scalarSpeed > 0 ? scalarSpeed : 1;\n const speedCurve = speedCurveOf(req.filters);\n if (rate !== 1 && !speedCurve) source.playbackRate.value = rate;\n\n const elapsed = Math.max(0, sceneTime - req.startAt);\n // Trimmed source length the filter curves / speed curve are authored over.\n const sourceLength = Math.max(0, buffer.duration - req.trimStart);\n // Scene-time length of the clip. Prefer the bounded [startAt, endAt) span; if\n // endAt is unbounded (an open/looping clip reaching the device unresolved),\n // fall back to the source length scaled by speed so curve params still resolve\n // (a clipDuration of 0 would otherwise silently drop every fade/sweep).\n const clipDuration = isFinite(req.endAt)\n ? Math.max(0, req.endAt - req.startAt)\n : sourceLength / (rate || 1);\n\n // Insert the filter chain between the source and the per-request gain. Pass\n // the start time, clip duration, and elapsed so curve-valued params schedule\n // and align to a mid-clip seek.\n const startTime = this.context.currentTime;\n const graph = buildAudioFilterGraph(\n this.context, source, req.filters ?? [], startTime, clipDuration, elapsed,\n );\n graph.output.connect(gainNode);\n\n // Source-time offset for a mid-clip seek. Scalar speed scales linearly; a\n // speed curve uses the integral inverse to find the true source position.\n let audioOffset: number;\n if (speedCurve) {\n audioOffset = req.trimStart + sourceTimeAtSceneElapsed(speedCurve, sourceLength, elapsed);\n // Schedule the time-varying playbackRate (folds in any scalar speed too).\n applySpeedToPlaybackRate(\n source.playbackRate, speedCurve, sourceLength, clipDuration, rate, startTime, elapsed,\n );\n } else {\n audioOffset = req.trimStart + elapsed * rate;\n }\n\n source.start(startTime, audioOffset);\n for (const osc of graph.oscillators) osc.start(startTime);\n\n source.onended = () => {\n if (this.active.get(req.id)?.source === source) {\n this.active.delete(req.id);\n }\n };\n\n this.active.set(req.id, {\n source,\n gainNode,\n request: req,\n filterNodes: graph.nodes,\n oscillators: graph.oscillators,\n });\n }\n\n private stopSource(id: string, active: ActiveSource): void {\n try {\n active.source.onended = null;\n active.source.stop();\n for (const osc of active.oscillators) osc.stop();\n active.source.disconnect();\n for (const node of active.filterNodes) node.disconnect();\n active.gainNode.disconnect();\n } catch {\n // already stopped\n }\n this.active.delete(id);\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n super.dispose();\n this.bufferCache.clear();\n this.decoding.clear();\n this.scheduled.length = 0;\n this.buses.dispose();\n try {\n this.masterGain.disconnect();\n } catch {\n // already disconnected\n }\n if (this.ownsContext && this.context.state !== \"closed\") {\n this.context.close();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/audio/player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAY/G;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAC/B,OAAO,CAAe;IACtB,WAAW,CAAU;IACrB,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC5C,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IACzC,SAAS,GAAmB,EAAE,CAAC;IAC/B,QAAQ,GAAY,KAAK,CAAC;IAC1B,UAAU,CAAW;IAC7B,oEAAoE;IAC5D,KAAK,CAAgB;IACrB,KAAK,GAAG,KAAK,CAAC;IACd,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,OAAsB;QAC9B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,YAAY,EAAE,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC5C,IAA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,UAAU,EAAE,CAAC;YACzD,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACL,kBAAkB;QACtB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO;QACH,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACL,uBAAuB;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACtD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { AudioSink, AudioRequest, sourceTimeAtClipElapsed } from \"@motionscript/core\";\r\nimport { AudioBusGraph } from \"./bus-graph\";\r\nimport { applyLoop, wrapIntoRegion } from \"./loop-region\";\r\nimport { buildAudioFilterGraph, effectiveSpeed, speedCurveOf, applySpeedToPlaybackRate } from \"./filter-graph\";\r\n\r\ntype ActiveSource = {\r\n source: AudioBufferSourceNode;\r\n gainNode: GainNode;\r\n request: AudioRequest;\r\n /** Filter-graph nodes to disconnect on teardown. */\r\n filterNodes: AudioNode[];\r\n /** Tremolo LFOs to stop on teardown. */\r\n oscillators: OscillatorNode[];\r\n};\r\n\r\n/**\r\n * Web Audio implementation of {@link AudioSink} — decodes and caches source\r\n * buffers, then schedules/plays {@link AudioRequest}s as `AudioBufferSourceNode`s\r\n * through a shared master gain (global mute and volume). `schedule` registers the\r\n * active set of requests for the current frame; `syncTo` then starts/stops\r\n * sources to match `clipTime`, so playback follows scrubbing and seeks.\r\n */\r\nexport class WebAudioSink extends AudioSink {\r\n private context: AudioContext;\r\n private ownsContext: boolean;\r\n private bufferCache = new Map<string, AudioBuffer>();\r\n private decoding = new Map<string, Promise<void>>();\r\n private active = new Map<string, ActiveSource>();\r\n private scheduled: AudioRequest[] = [];\r\n private disposed: boolean = false;\r\n private masterGain: GainNode;\r\n /** The live bus chains, shared across every clip that names one. */\r\n private buses: AudioBusGraph;\r\n private muted = false;\r\n private volume = 1;\r\n\r\n constructor(context?: AudioContext) {\r\n super();\r\n this.context = context ?? new AudioContext();\r\n this.ownsContext = !context;\r\n this.masterGain = this.context.createGain();\r\n this.masterGain.connect(this.context.destination);\r\n this.buses = new AudioBusGraph(this.context, this.masterGain);\r\n }\r\n\r\n getContext(): AudioContext {\r\n return this.context;\r\n }\r\n\r\n /**\r\n * Resume the AudioContext. Must be called from within a user gesture\r\n * (e.g. a click handler) the first time, or browsers keep the context\r\n * suspended and no audio is heard.\r\n */\r\n unlock(): void {\r\n if (this.context.state === \"suspended\") {\r\n this.context.resume();\r\n }\r\n }\r\n\r\n has(src: string): boolean {\r\n return this.bufferCache.has(src);\r\n }\r\n\r\n async append(src: string, data: ArrayBuffer): Promise<void> {\r\n if (this.bufferCache.has(src)) return;\r\n const existing = this.decoding.get(src);\r\n if (existing) return existing;\r\n\r\n // decodeAudioData detaches `data` — that's fine, the caller in\r\n // AssetManager.fetchAudio discards its reference immediately after\r\n // awaiting append. Skipping the defensive .slice(0) saves a multi-MB\r\n // allocation per audio source.\r\n const job = this.context.decodeAudioData(data).then((buffer) => {\r\n this.bufferCache.set(src, buffer);\r\n }).finally(() => {\r\n this.decoding.delete(src);\r\n });\r\n this.decoding.set(src, job);\r\n await job;\r\n }\r\n\r\n /** Drops cached buffers and stops active sources for srcs/requests no longer referenced — called when the asset set changes (e.g. seeking across scene boundaries). */\r\n retain(keep: ReadonlySet<string>): void {\r\n for (const src of [...this.bufferCache.keys()]) {\r\n if (!keep.has(src)) this.bufferCache.delete(src);\r\n }\r\n for (const [id, active] of this.active) {\r\n if (!keep.has(active.request.src)) this.stopSource(id, active);\r\n }\r\n }\r\n\r\n /** Replaces the active request set; stops any currently-playing source whose request is no longer scheduled. Actual start/stop-to-match-time happens in `syncTo`. */\r\n schedule(requests: readonly AudioRequest[]): void {\r\n const next = new Set(requests.map(r => r.id));\r\n for (const [id, active] of this.active) {\r\n if (!next.has(id)) this.stopSource(id, active);\r\n }\r\n this.scheduled = requests.slice();\r\n }\r\n\r\n /** Starts sources whose `[startAt, endAt)` window now contains `clipTime` (computing the correct buffer offset for the seek point) and stops any that have fallen outside it. */\r\n syncTo(clipTime: number): void {\r\n const liveIds = new Set<string>();\r\n\r\n for (const req of this.scheduled) {\r\n // `endAt` is `Infinity` for an open clip, so the comparison needs no\r\n // nullish fallback — see AudioRequest.endAt.\r\n const isInWindow = clipTime >= req.startAt && clipTime < req.endAt;\r\n if (!isInWindow) continue;\r\n\r\n liveIds.add(req.id);\r\n if (!this.active.has(req.id)) {\r\n const buffer = this.bufferCache.get(req.src);\r\n if (buffer) this.playBuffer(buffer, req, clipTime);\r\n }\r\n }\r\n\r\n for (const [id, active] of this.active) {\r\n if (!liveIds.has(id)) this.stopSource(id, active);\r\n }\r\n }\r\n\r\n async play(time: number, _speed: number, _reverse: boolean): Promise<void> {\r\n if (this.context.state === \"suspended\") {\r\n await this.context.resume();\r\n }\r\n this.syncTo(time);\r\n }\r\n\r\n stop(): void {\r\n for (const [id, active] of this.active) {\r\n this.stopSource(id, active);\r\n }\r\n // A bus's curves are scheduled against the clock of the run that built\r\n // it, so the next play, from wherever it lands, builds them again.\r\n this.buses.dispose();\r\n }\r\n\r\n setMuted(muted: boolean): void {\r\n this.muted = muted;\r\n this.applyMasterGain();\r\n }\r\n\r\n setVolume(volume: number): void {\r\n this.volume = Math.max(0, volume);\r\n this.applyMasterGain();\r\n }\r\n\r\n /** Mute and volume are held separately so unmuting restores the set level. */\r\n private applyMasterGain(): void {\r\n this.masterGain.gain.value = this.muted ? 0 : this.volume;\r\n }\r\n\r\n /** Starts a buffer source mid-clip if `clipTime` lands after the request's start — `audioOffset` accounts for the request's trim, the elapsed time since `startAt`, and any speed (playbackRate) change. */\r\n private playBuffer(buffer: AudioBuffer, req: AudioRequest, clipTime: number): void {\r\n const startTime = this.context.currentTime;\r\n const gainNode = this.context.createGain();\r\n // Guard against a missing/NaN volume — a non-finite AudioParam value throws.\r\n gainNode.gain.value = Number.isFinite(req.volume) ? req.volume : 1;\r\n // Into this clip's bus chain, or straight to the master when it has none.\r\n // The chain is shared: two clips on one bus reach the same nodes, which is\r\n // what makes a bus effect one tail rather than one per clip.\r\n gainNode.connect(this.buses.inputFor(req.bus, startTime, clipTime));\r\n\r\n const source = this.context.createBufferSource();\r\n source.buffer = buffer;\r\n const loopRegion = applyLoop(source, req);\r\n\r\n const scalarSpeed = effectiveSpeed(req.filters);\r\n const rate = Number.isFinite(scalarSpeed) && scalarSpeed > 0 ? scalarSpeed : 1;\r\n const speedCurve = speedCurveOf(req.filters);\r\n if (rate !== 1 && !speedCurve) source.playbackRate.value = rate;\r\n\r\n const elapsed = Math.max(0, clipTime - req.startAt);\r\n // Trimmed source length the filter curves / speed curve are authored over.\r\n const sourceLength = Math.max(0, buffer.duration - req.trimStart);\r\n // Clip-time length of the clip. Prefer the bounded [startAt, endAt) span; if\r\n // endAt is unbounded (an open/looping clip reaching the device unresolved),\r\n // fall back to the source length scaled by speed so curve params still resolve\r\n // (a clipDuration of 0 would otherwise silently drop every fade/sweep).\r\n const clipDuration = isFinite(req.endAt)\r\n ? Math.max(0, req.endAt - req.startAt)\r\n : sourceLength / (rate || 1);\r\n\r\n // Insert the filter chain between the source and the per-request gain. Pass\r\n // the start time, clip duration, and elapsed so curve-valued params schedule\r\n // and align to a mid-clip seek.\r\n const graph = buildAudioFilterGraph(\r\n this.context, source, req.filters ?? [], startTime, clipDuration, elapsed,\r\n );\r\n graph.output.connect(gainNode);\r\n\r\n // Source-time offset for a mid-clip seek. Scalar speed scales linearly; a\r\n // speed curve uses the integral inverse to find the true source position.\r\n let audioOffset: number;\r\n if (speedCurve) {\r\n audioOffset = req.trimStart + sourceTimeAtClipElapsed(speedCurve, sourceLength, elapsed);\r\n // Schedule the time-varying playbackRate (folds in any scalar speed too).\r\n applySpeedToPlaybackRate(\r\n source.playbackRate, speedCurve, sourceLength, clipDuration, rate, startTime, elapsed,\r\n );\r\n } else {\r\n audioOffset = req.trimStart + elapsed * rate;\r\n }\r\n\r\n source.start(startTime, wrapIntoRegion(loopRegion, audioOffset));\r\n for (const osc of graph.oscillators) osc.start(startTime);\r\n\r\n source.onended = () => {\r\n if (this.active.get(req.id)?.source === source) {\r\n this.active.delete(req.id);\r\n }\r\n };\r\n\r\n this.active.set(req.id, {\r\n source,\r\n gainNode,\r\n request: req,\r\n filterNodes: graph.nodes,\r\n oscillators: graph.oscillators,\r\n });\r\n }\r\n\r\n private stopSource(id: string, active: ActiveSource): void {\r\n try {\r\n active.source.onended = null;\r\n active.source.stop();\r\n for (const osc of active.oscillators) osc.stop();\r\n active.source.disconnect();\r\n for (const node of active.filterNodes) node.disconnect();\r\n active.gainNode.disconnect();\r\n } catch {\r\n // already stopped\r\n }\r\n this.active.delete(id);\r\n }\r\n\r\n dispose(): void {\r\n if (this.disposed) return;\r\n this.disposed = true;\r\n super.dispose();\r\n this.bufferCache.clear();\r\n this.decoding.clear();\r\n this.scheduled.length = 0;\r\n this.buses.dispose();\r\n try {\r\n this.masterGain.disconnect();\r\n } catch {\r\n // already disconnected\r\n }\r\n if (this.ownsContext && this.context.state !== \"closed\") {\r\n this.context.close();\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,432 @@
1
+ Third-party software bundled into @motionscript/browser's browser build (dist/browser/).
2
+
3
+ esbuild-wasm 0.28.2
4
+ License: MIT
5
+
6
+ MIT License
7
+
8
+ Copyright (c) 2020 Evan Wallace
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ ------------------------------------------------------------------------------
29
+
30
+ mediabunny 1.49.0
31
+ License: MPL-2.0
32
+
33
+ Mozilla Public License Version 2.0
34
+ ==================================
35
+
36
+ 1. Definitions
37
+ --------------
38
+
39
+ 1.1. "Contributor"
40
+ means each individual or legal entity that creates, contributes to
41
+ the creation of, or owns Covered Software.
42
+
43
+ 1.2. "Contributor Version"
44
+ means the combination of the Contributions of others (if any) used
45
+ by a Contributor and that particular Contributor's Contribution.
46
+
47
+ 1.3. "Contribution"
48
+ means Covered Software of a particular Contributor.
49
+
50
+ 1.4. "Covered Software"
51
+ means Source Code Form to which the initial Contributor has attached
52
+ the notice in Exhibit A, the Executable Form of such Source Code
53
+ Form, and Modifications of such Source Code Form, in each case
54
+ including portions thereof.
55
+
56
+ 1.5. "Incompatible With Secondary Licenses"
57
+ means
58
+
59
+ (a) that the initial Contributor has attached the notice described
60
+ in Exhibit B to the Covered Software; or
61
+
62
+ (b) that the Covered Software was made available under the terms of
63
+ version 1.1 or earlier of the License, but not also under the
64
+ terms of a Secondary License.
65
+
66
+ 1.6. "Executable Form"
67
+ means any form of the work other than Source Code Form.
68
+
69
+ 1.7. "Larger Work"
70
+ means a work that combines Covered Software with other material, in
71
+ a separate file or files, that is not Covered Software.
72
+
73
+ 1.8. "License"
74
+ means this document.
75
+
76
+ 1.9. "Licensable"
77
+ means having the right to grant, to the maximum extent possible,
78
+ whether at the time of the initial grant or subsequently, any and
79
+ all of the rights conveyed by this License.
80
+
81
+ 1.10. "Modifications"
82
+ means any of the following:
83
+
84
+ (a) any file in Source Code Form that results from an addition to,
85
+ deletion from, or modification of the contents of Covered
86
+ Software; or
87
+
88
+ (b) any new file in Source Code Form that contains any Covered
89
+ Software.
90
+
91
+ 1.11. "Patent Claims" of a Contributor
92
+ means any patent claim(s), including without limitation, method,
93
+ process, and apparatus claims, in any patent Licensable by such
94
+ Contributor that would be infringed, but for the grant of the
95
+ License, by the making, using, selling, offering for sale, having
96
+ made, import, or transfer of either its Contributions or its
97
+ Contributor Version.
98
+
99
+ 1.12. "Secondary License"
100
+ means either the GNU General Public License, Version 2.0, the GNU
101
+ Lesser General Public License, Version 2.1, the GNU Affero General
102
+ Public License, Version 3.0, or any later versions of those
103
+ licenses.
104
+
105
+ 1.13. "Source Code Form"
106
+ means the form of the work preferred for making modifications.
107
+
108
+ 1.14. "You" (or "Your")
109
+ means an individual or a legal entity exercising rights under this
110
+ License. For legal entities, "You" includes any entity that
111
+ controls, is controlled by, or is under common control with You. For
112
+ purposes of this definition, "control" means (a) the power, direct
113
+ or indirect, to cause the direction or management of such entity,
114
+ whether by contract or otherwise, or (b) ownership of more than
115
+ fifty percent (50%) of the outstanding shares or beneficial
116
+ ownership of such entity.
117
+
118
+ 2. License Grants and Conditions
119
+ --------------------------------
120
+
121
+ 2.1. Grants
122
+
123
+ Each Contributor hereby grants You a world-wide, royalty-free,
124
+ non-exclusive license:
125
+
126
+ (a) under intellectual property rights (other than patent or trademark)
127
+ Licensable by such Contributor to use, reproduce, make available,
128
+ modify, display, perform, distribute, and otherwise exploit its
129
+ Contributions, either on an unmodified basis, with Modifications, or
130
+ as part of a Larger Work; and
131
+
132
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
133
+ for sale, have made, import, and otherwise transfer either its
134
+ Contributions or its Contributor Version.
135
+
136
+ 2.2. Effective Date
137
+
138
+ The licenses granted in Section 2.1 with respect to any Contribution
139
+ become effective for each Contribution on the date the Contributor first
140
+ distributes such Contribution.
141
+
142
+ 2.3. Limitations on Grant Scope
143
+
144
+ The licenses granted in this Section 2 are the only rights granted under
145
+ this License. No additional rights or licenses will be implied from the
146
+ distribution or licensing of Covered Software under this License.
147
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
148
+ Contributor:
149
+
150
+ (a) for any code that a Contributor has removed from Covered Software;
151
+ or
152
+
153
+ (b) for infringements caused by: (i) Your and any other third party's
154
+ modifications of Covered Software, or (ii) the combination of its
155
+ Contributions with other software (except as part of its Contributor
156
+ Version); or
157
+
158
+ (c) under Patent Claims infringed by Covered Software in the absence of
159
+ its Contributions.
160
+
161
+ This License does not grant any rights in the trademarks, service marks,
162
+ or logos of any Contributor (except as may be necessary to comply with
163
+ the notice requirements in Section 3.4).
164
+
165
+ 2.4. Subsequent Licenses
166
+
167
+ No Contributor makes additional grants as a result of Your choice to
168
+ distribute the Covered Software under a subsequent version of this
169
+ License (see Section 10.2) or under the terms of a Secondary License (if
170
+ permitted under the terms of Section 3.3).
171
+
172
+ 2.5. Representation
173
+
174
+ Each Contributor represents that the Contributor believes its
175
+ Contributions are its original creation(s) or it has sufficient rights
176
+ to grant the rights to its Contributions conveyed by this License.
177
+
178
+ 2.6. Fair Use
179
+
180
+ This License is not intended to limit any rights You have under
181
+ applicable copyright doctrines of fair use, fair dealing, or other
182
+ equivalents.
183
+
184
+ 2.7. Conditions
185
+
186
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
187
+ in Section 2.1.
188
+
189
+ 3. Responsibilities
190
+ -------------------
191
+
192
+ 3.1. Distribution of Source Form
193
+
194
+ All distribution of Covered Software in Source Code Form, including any
195
+ Modifications that You create or to which You contribute, must be under
196
+ the terms of this License. You must inform recipients that the Source
197
+ Code Form of the Covered Software is governed by the terms of this
198
+ License, and how they can obtain a copy of this License. You may not
199
+ attempt to alter or restrict the recipients' rights in the Source Code
200
+ Form.
201
+
202
+ 3.2. Distribution of Executable Form
203
+
204
+ If You distribute Covered Software in Executable Form then:
205
+
206
+ (a) such Covered Software must also be made available in Source Code
207
+ Form, as described in Section 3.1, and You must inform recipients of
208
+ the Executable Form how they can obtain a copy of such Source Code
209
+ Form by reasonable means in a timely manner, at a charge no more
210
+ than the cost of distribution to the recipient; and
211
+
212
+ (b) You may distribute such Executable Form under the terms of this
213
+ License, or sublicense it under different terms, provided that the
214
+ license for the Executable Form does not attempt to limit or alter
215
+ the recipients' rights in the Source Code Form under this License.
216
+
217
+ 3.3. Distribution of a Larger Work
218
+
219
+ You may create and distribute a Larger Work under terms of Your choice,
220
+ provided that You also comply with the requirements of this License for
221
+ the Covered Software. If the Larger Work is a combination of Covered
222
+ Software with a work governed by one or more Secondary Licenses, and the
223
+ Covered Software is not Incompatible With Secondary Licenses, this
224
+ License permits You to additionally distribute such Covered Software
225
+ under the terms of such Secondary License(s), so that the recipient of
226
+ the Larger Work may, at their option, further distribute the Covered
227
+ Software under the terms of either this License or such Secondary
228
+ License(s).
229
+
230
+ 3.4. Notices
231
+
232
+ You may not remove or alter the substance of any license notices
233
+ (including copyright notices, patent notices, disclaimers of warranty,
234
+ or limitations of liability) contained within the Source Code Form of
235
+ the Covered Software, except that You may alter any license notices to
236
+ the extent required to remedy known factual inaccuracies.
237
+
238
+ 3.5. Application of Additional Terms
239
+
240
+ You may choose to offer, and to charge a fee for, warranty, support,
241
+ indemnity or liability obligations to one or more recipients of Covered
242
+ Software. However, You may do so only on Your own behalf, and not on
243
+ behalf of any Contributor. You must make it absolutely clear that any
244
+ such warranty, support, indemnity, or liability obligation is offered by
245
+ You alone, and You hereby agree to indemnify every Contributor for any
246
+ liability incurred by such Contributor as a result of warranty, support,
247
+ indemnity or liability terms You offer. You may include additional
248
+ disclaimers of warranty and limitations of liability specific to any
249
+ jurisdiction.
250
+
251
+ 4. Inability to Comply Due to Statute or Regulation
252
+ ---------------------------------------------------
253
+
254
+ If it is impossible for You to comply with any of the terms of this
255
+ License with respect to some or all of the Covered Software due to
256
+ statute, judicial order, or regulation then You must: (a) comply with
257
+ the terms of this License to the maximum extent possible; and (b)
258
+ describe the limitations and the code they affect. Such description must
259
+ be placed in a text file included with all distributions of the Covered
260
+ Software under this License. Except to the extent prohibited by statute
261
+ or regulation, such description must be sufficiently detailed for a
262
+ recipient of ordinary skill to be able to understand it.
263
+
264
+ 5. Termination
265
+ --------------
266
+
267
+ 5.1. The rights granted under this License will terminate automatically
268
+ if You fail to comply with any of its terms. However, if You become
269
+ compliant, then the rights granted under this License from a particular
270
+ Contributor are reinstated (a) provisionally, unless and until such
271
+ Contributor explicitly and finally terminates Your grants, and (b) on an
272
+ ongoing basis, if such Contributor fails to notify You of the
273
+ non-compliance by some reasonable means prior to 60 days after You have
274
+ come back into compliance. Moreover, Your grants from a particular
275
+ Contributor are reinstated on an ongoing basis if such Contributor
276
+ notifies You of the non-compliance by some reasonable means, this is the
277
+ first time You have received notice of non-compliance with this License
278
+ from such Contributor, and You become compliant prior to 30 days after
279
+ Your receipt of the notice.
280
+
281
+ 5.2. If You initiate litigation against any entity by asserting a patent
282
+ infringement claim (excluding declaratory judgment actions,
283
+ counter-claims, and cross-claims) alleging that a Contributor Version
284
+ directly or indirectly infringes any patent, then the rights granted to
285
+ You by any and all Contributors for the Covered Software under Section
286
+ 2.1 of this License shall terminate.
287
+
288
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
289
+ end user license agreements (excluding distributors and resellers) which
290
+ have been validly granted by You or Your distributors under this License
291
+ prior to termination shall survive termination.
292
+
293
+ ************************************************************************
294
+ * *
295
+ * 6. Disclaimer of Warranty *
296
+ * ------------------------- *
297
+ * *
298
+ * Covered Software is provided under this License on an "as is" *
299
+ * basis, without warranty of any kind, either expressed, implied, or *
300
+ * statutory, including, without limitation, warranties that the *
301
+ * Covered Software is free of defects, merchantable, fit for a *
302
+ * particular purpose or non-infringing. The entire risk as to the *
303
+ * quality and performance of the Covered Software is with You. *
304
+ * Should any Covered Software prove defective in any respect, You *
305
+ * (not any Contributor) assume the cost of any necessary servicing, *
306
+ * repair, or correction. This disclaimer of warranty constitutes an *
307
+ * essential part of this License. No use of any Covered Software is *
308
+ * authorized under this License except under this disclaimer. *
309
+ * *
310
+ ************************************************************************
311
+
312
+ ************************************************************************
313
+ * *
314
+ * 7. Limitation of Liability *
315
+ * -------------------------- *
316
+ * *
317
+ * Under no circumstances and under no legal theory, whether tort *
318
+ * (including negligence), contract, or otherwise, shall any *
319
+ * Contributor, or anyone who distributes Covered Software as *
320
+ * permitted above, be liable to You for any direct, indirect, *
321
+ * special, incidental, or consequential damages of any character *
322
+ * including, without limitation, damages for lost profits, loss of *
323
+ * goodwill, work stoppage, computer failure or malfunction, or any *
324
+ * and all other commercial damages or losses, even if such party *
325
+ * shall have been informed of the possibility of such damages. This *
326
+ * limitation of liability shall not apply to liability for death or *
327
+ * personal injury resulting from such party's negligence to the *
328
+ * extent applicable law prohibits such limitation. Some *
329
+ * jurisdictions do not allow the exclusion or limitation of *
330
+ * incidental or consequential damages, so this exclusion and *
331
+ * limitation may not apply to You. *
332
+ * *
333
+ ************************************************************************
334
+
335
+ 8. Litigation
336
+ -------------
337
+
338
+ Any litigation relating to this License may be brought only in the
339
+ courts of a jurisdiction where the defendant maintains its principal
340
+ place of business and such litigation shall be governed by laws of that
341
+ jurisdiction, without reference to its conflict-of-law provisions.
342
+ Nothing in this Section shall prevent a party's ability to bring
343
+ cross-claims or counter-claims.
344
+
345
+ 9. Miscellaneous
346
+ ----------------
347
+
348
+ This License represents the complete agreement concerning the subject
349
+ matter hereof. If any provision of this License is held to be
350
+ unenforceable, such provision shall be reformed only to the extent
351
+ necessary to make it enforceable. Any law or regulation which provides
352
+ that the language of a contract shall be construed against the drafter
353
+ shall not be used to construe this License against a Contributor.
354
+
355
+ 10. Versions of the License
356
+ ---------------------------
357
+
358
+ 10.1. New Versions
359
+
360
+ Mozilla Foundation is the license steward. Except as provided in Section
361
+ 10.3, no one other than the license steward has the right to modify or
362
+ publish new versions of this License. Each version will be given a
363
+ distinguishing version number.
364
+
365
+ 10.2. Effect of New Versions
366
+
367
+ You may distribute the Covered Software under the terms of the version
368
+ of the License under which You originally received the Covered Software,
369
+ or under the terms of any subsequent version published by the license
370
+ steward.
371
+
372
+ 10.3. Modified Versions
373
+
374
+ If you create software not governed by this License, and you want to
375
+ create a new license for such software, you may create and use a
376
+ modified version of this License if you rename the license and remove
377
+ any references to the name of the license steward (except to note that
378
+ such modified license differs from this License).
379
+
380
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
381
+ Licenses
382
+
383
+ If You choose to distribute Source Code Form that is Incompatible With
384
+ Secondary Licenses under the terms of this version of the License, the
385
+ notice described in Exhibit B of this License must be attached.
386
+
387
+ Exhibit A - Source Code Form License Notice
388
+ -------------------------------------------
389
+
390
+ This Source Code Form is subject to the terms of the Mozilla Public
391
+ License, v. 2.0. If a copy of the MPL was not distributed with this
392
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
393
+
394
+ If it is not possible or desirable to put the notice in a particular
395
+ file, then You may include the notice in a location (such as a LICENSE
396
+ file in a relevant directory) where a recipient would be likely to look
397
+ for such a notice.
398
+
399
+ You may add additional accurate notices of copyright ownership.
400
+
401
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
402
+ ---------------------------------------------------------
403
+
404
+ This Source Code Form is "Incompatible With Secondary Licenses", as
405
+ defined by the Mozilla Public License, v. 2.0.
406
+
407
+ ------------------------------------------------------------------------------
408
+
409
+ three 0.185.1
410
+ License: MIT
411
+
412
+ The MIT License
413
+
414
+ Copyright © 2010-2026 three.js authors
415
+
416
+ Permission is hereby granted, free of charge, to any person obtaining a copy
417
+ of this software and associated documentation files (the "Software"), to deal
418
+ in the Software without restriction, including without limitation the rights
419
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
420
+ copies of the Software, and to permit persons to whom the Software is
421
+ furnished to do so, subject to the following conditions:
422
+
423
+ The above copyright notice and this permission notice shall be included in
424
+ all copies or substantial portions of the Software.
425
+
426
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
427
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
428
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
429
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
430
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
431
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
432
+ THE SOFTWARE.
@@ -1,2 +1,2 @@
1
- import{a as e,b as i,c as r,d as A,e as d,f as o}from"./chunks/chunk-NSFLRI4P.js";import"./chunks/chunk-FY3BTKY4.js";export{e as AudioBusGraph,i as DEFAULT_SAMPLE_RATE,A as WebAudioMixer,o as WebAudioPlayer,o as WebAudioSink,d as encodeWav,r as mixAudio};
1
+ import{d as e,e as i,f as r,g as A,h as d,i as o}from"./chunks/chunk-2MAFJWBZ.js";import"./chunks/chunk-FY3BTKY4.js";export{e as AudioBusGraph,i as DEFAULT_SAMPLE_RATE,A as WebAudioMixer,o as WebAudioPlayer,o as WebAudioSink,d as encodeWav,r as mixAudio};
2
2
  //# sourceMappingURL=audio.js.map
@@ -0,0 +1,2 @@
1
+ var E=null;function tt(n){E=n}async function N(n){if(!E)return null;try{return await E(n)}catch{return null}}async function U(n){let t=await fetch(n);if(!t.ok){let e=t.statusText?`${t.status} ${t.statusText}`:`${t.status}`;throw new Error(`Fetching "${n}" failed: HTTP ${e}`)}return t.blob()}import{busStopKey as Q}from"@motionscript/core";import{isCurve as C,sourceTimeAtClipElapsed as O}from"@motionscript/core";var I=200;function H(n,t,e,o,c,l,h=a=>a){let a=s=>{let i=h(s);return Number.isFinite(i)?i:t.value};if(!C(e)){t.value=a(e);return}if(!Number.isFinite(c)||c<=0){t.value=a(e.staticValue(t.value));return}let p=o-l,u=e.resolve(c,t.value);if(u.length===0)return;let f=e.sampleAt(Math.max(0,l),c,t.value);t.setValueAtTime(a(f),o);for(let s of u){let i=p+s.startTime,r=p+s.endTime;if(r<=o||!Number.isFinite(i)||!Number.isFinite(r))continue;let d=s.endTime-s.startTime;if(d<=0){t.setValueAtTime(a(s.to),Math.max(i,o));continue}let x=Math.max(0,(o-i)/d),m=Math.max(i,o);if(s.isLinear)x===0&&t.setValueAtTime(a(s.from),m),t.linearRampToValueAtTime(a(s.to),r);else{let y=r-m;if(y<=0)continue;let A=Math.max(2,Math.ceil(y*I)),g=new Float32Array(A);for(let v=0;v<A;v++){let M=x+(1-x)*(v/(A-1));g[v]=a(s.from+(s.to-s.from)*s.ease(M))}t.setValueCurveAtTime(g,m,y)}}}function b(n,t,e,o=n.currentTime,c=0,l=0){let h=[],a=[],p=t,u=s=>{p.connect(s),h.push(s),p=s},f=(s,i,r)=>H(n,s,i,o,c,l,r);for(let s of e)switch(s.type){case"gain":{let i=n.createGain();f(i.gain,s.value),u(i);break}case"highpass":case"lowpass":{let i=n.createBiquadFilter();i.type=s.type==="highpass"?"highpass":"lowpass",f(i.frequency,s.frequency),s.q!==void 0&&f(i.Q,s.q),u(i);break}case"tremolo":{let i=n.createGain(),r=n.createOscillator(),d=n.createGain();f(i.gain,s.depth,x=>1-S(x)/2),f(d.gain,s.depth,x=>S(x)/2),f(r.frequency,s.rate),r.connect(d),d.connect(i.gain),h.push(d),a.push(r),u(i);break}case"echo":{let i=p,r=n.createGain(),d=n.createGain();f(d.gain,s.mix??.5,g=>1-S(g)),i.connect(d),d.connect(r);let x=K(s.delay),m=n.createDelay(Math.max(1,x+1));f(m.delayTime,s.delay);let y=n.createGain();f(y.gain,s.feedback,g=>Math.max(0,Math.min(.99,g)));let A=n.createGain();f(A.gain,s.mix??.5,g=>S(g)),i.connect(m),m.connect(y),y.connect(m),m.connect(A),A.connect(r),h.push(d,m,y,A,r),p=r;break}case"speed":break}return{output:p,nodes:h,oscillators:a}}function S(n){return Math.max(0,Math.min(1,n))}function K(n){return C(n)?n.staticValue(0):n}function F(n){if(!n)return 1;let t=1;for(let e of n)e.type==="speed"&&!C(e.value)&&e.value>0&&(t*=e.value);return t}function G(n){if(n){for(let t of n)if(t.type==="speed"&&C(t.value))return t.value}}function R(n,t,e,o,c,l,h){if(!t)return;let a=1/I,p=Math.max(0,h),u=O(t,e,p);n.setValueAtTime(Math.max(1e-4,t.sampleAt(u,e,1)*c),l);for(let f=p+a;f<=o+a;f+=a){let s=Math.min(f,o),i=O(t,e,s),r=Math.max(1e-4,t.sampleAt(i,e,1)*c),d=l+(s-p);if(n.linearRampToValueAtTime(r,d),s>=o)break}}var w=class{ctx;destination;constructor(t,e){this.ctx=t,this.destination=e}inputFor(t,e,o){return!t||t.length===0?this.destination:this.chainFrom(t,0,e,o)}dispose(){for(let t of this.nodes)try{t.disconnect()}catch{}for(let t of this.oscillators)try{t.stop()}catch{}this.nodes.length=0,this.oscillators.length=0,this.inputs.clear()}inputs=new Map;nodes=[];oscillators=[];chainFrom(t,e,o,c){if(e>=t.length)return this.destination;let l=t[e],h=t.slice(e).map(Q).join(">"),a=this.inputs.get(h);if(a)return a;let p=this.chainFrom(t,e+1,o,c),u=this.ctx.createGain();u.gain.value=1;let f={type:"gain",value:l.mute?0:l.volume},s=b(this.ctx,u,[...l.filters??[],f],o,l.endAt-l.startAt,c-l.startAt);s.output.connect(p),this.nodes.push(u,...s.nodes),this.oscillators.push(...s.oscillators);for(let i of s.oscillators)i.start(o);return this.inputs.set(h,u),u}};import{sourceTimeAtClipElapsed as J}from"@motionscript/core";function z(n,t){if(!n.loop)return null;let e=Math.min(Math.max(0,n.trimStart),t),o=Math.min(n.trimEnd??t,t);return o>e?{start:e,end:o}:null}function k(n,t){n.loop=t.loop;let e=n.buffer?z(t,n.buffer.duration):null;return e&&(n.loopStart=e.start,n.loopEnd=e.end),e}function _(n,t){return!n||t<n.end?t:n.start+(t-n.start)%(n.end-n.start)}var D=44100;function P(n,t){if(!t)return n;try{return t.getAudioMeta(n).src||n}catch{try{return t.getVideoMeta(n).src||n}catch{return n}}}async function X(n,t){let e=await N(n)??await U(n);return t.decodeAudioData(await e.arrayBuffer())}async function Y(n,t,e={}){if(n.length===0)return null;let o=e.sampleRate??D,c=Math.ceil(t*o);if(c<=0)return null;let l=[...new Set(n.map(s=>s.request.src))],h=new OfflineAudioContext(2,c,o),a=new Set(n.filter(s=>!s.request.optional).map(s=>s.request.src)),p=new Map;await Promise.all(l.map(async s=>{try{p.set(s,await X(P(s,e.catalog),h))}catch(i){if(a.has(s))throw i}}));let u=new OfflineAudioContext(2,c,o),f=new w(u,u.destination);for(let{request:s,globalOffset:i}of n){let r=p.get(s.src);if(!r)continue;let d=i+s.startAt,m=Math.min(i+s.endAt,t)-d;if(m<=0)continue;let y=u.createBufferSource();y.buffer=r,k(y,s);let A=F(s.filters),g=Number.isFinite(A)&&A>0?A:1,v=G(s.filters);g!==1&&!v&&(y.playbackRate.value=g);let M=u.createGain();M.gain.value=Number.isFinite(s.volume)?s.volume:1;let T=Math.max(0,r.duration-s.trimStart),B=Number.isFinite(s.endAt)?Math.max(0,s.endAt-s.startAt):T/g,V=b(u,y,s.filters??[],d,B,0);V.output.connect(M),M.connect(f.inputFor(s.bus,0,-i)),v&&R(y.playbackRate,v,T,B,g,d,0);let j=v?J(v,T,m):m*g;y.start(d,s.trimStart,j);for(let W of V.oscillators)W.start(d)}return u.startRendering()}var L=class{sampleRate;catalog;constructor(t=D,e){this.sampleRate=t,this.catalog=e}mix(t,e){return Y(t,e,{sampleRate:this.sampleRate,catalog:this.catalog})}};function pt(n){let t=n.numberOfChannels,e=n.length,o=2,c=t*o,l=e*c,h=new ArrayBuffer(44+l),a=new DataView(h),p=(s,i)=>{for(let r=0;r<i.length;r++)a.setUint8(s+r,i.charCodeAt(r))};p(0,"RIFF"),a.setUint32(4,36+l,!0),p(8,"WAVE"),p(12,"fmt "),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,t,!0),a.setUint32(24,n.sampleRate,!0),a.setUint32(28,n.sampleRate*c,!0),a.setUint16(32,c,!0),a.setUint16(34,8*o,!0),p(36,"data"),a.setUint32(40,l,!0);let u=[];for(let s=0;s<t;s++)u.push(n.getChannelData(s));let f=44;for(let s=0;s<e;s++)for(let i=0;i<t;i++){let r=Math.max(-1,Math.min(1,u[i][s]));a.setInt16(f,r<0?r*32768:r*32767,!0),f+=o}return new Uint8Array(h)}import{AudioSink as Z,sourceTimeAtClipElapsed as q}from"@motionscript/core";var $=class extends Z{context;ownsContext;bufferCache=new Map;decoding=new Map;active=new Map;scheduled=[];disposed=!1;masterGain;buses;muted=!1;volume=1;constructor(t){super(),this.context=t??new AudioContext,this.ownsContext=!t,this.masterGain=this.context.createGain(),this.masterGain.connect(this.context.destination),this.buses=new w(this.context,this.masterGain)}getContext(){return this.context}unlock(){this.context.state==="suspended"&&this.context.resume()}has(t){return this.bufferCache.has(t)}async append(t,e){if(this.bufferCache.has(t))return;let o=this.decoding.get(t);if(o)return o;let c=this.context.decodeAudioData(e).then(l=>{this.bufferCache.set(t,l)}).finally(()=>{this.decoding.delete(t)});this.decoding.set(t,c),await c}retain(t){for(let e of[...this.bufferCache.keys()])t.has(e)||this.bufferCache.delete(e);for(let[e,o]of this.active)t.has(o.request.src)||this.stopSource(e,o)}schedule(t){let e=new Set(t.map(o=>o.id));for(let[o,c]of this.active)e.has(o)||this.stopSource(o,c);this.scheduled=t.slice()}syncTo(t){let e=new Set;for(let o of this.scheduled)if(t>=o.startAt&&t<o.endAt&&(e.add(o.id),!this.active.has(o.id))){let l=this.bufferCache.get(o.src);l&&this.playBuffer(l,o,t)}for(let[o,c]of this.active)e.has(o)||this.stopSource(o,c)}async play(t,e,o){this.context.state==="suspended"&&await this.context.resume(),this.syncTo(t)}stop(){for(let[t,e]of this.active)this.stopSource(t,e);this.buses.dispose()}setMuted(t){this.muted=t,this.applyMasterGain()}setVolume(t){this.volume=Math.max(0,t),this.applyMasterGain()}applyMasterGain(){this.masterGain.gain.value=this.muted?0:this.volume}playBuffer(t,e,o){let c=this.context.currentTime,l=this.context.createGain();l.gain.value=Number.isFinite(e.volume)?e.volume:1,l.connect(this.buses.inputFor(e.bus,c,o));let h=this.context.createBufferSource();h.buffer=t;let a=k(h,e),p=F(e.filters),u=Number.isFinite(p)&&p>0?p:1,f=G(e.filters);u!==1&&!f&&(h.playbackRate.value=u);let s=Math.max(0,o-e.startAt),i=Math.max(0,t.duration-e.trimStart),r=isFinite(e.endAt)?Math.max(0,e.endAt-e.startAt):i/(u||1),d=b(this.context,h,e.filters??[],c,r,s);d.output.connect(l);let x;f?(x=e.trimStart+q(f,i,s),R(h.playbackRate,f,i,r,u,c,s)):x=e.trimStart+s*u,h.start(c,_(a,x));for(let m of d.oscillators)m.start(c);h.onended=()=>{this.active.get(e.id)?.source===h&&this.active.delete(e.id)},this.active.set(e.id,{source:h,gainNode:l,request:e,filterNodes:d.nodes,oscillators:d.oscillators})}stopSource(t,e){try{e.source.onended=null,e.source.stop();for(let o of e.oscillators)o.stop();e.source.disconnect();for(let o of e.filterNodes)o.disconnect();e.gainNode.disconnect()}catch{}this.active.delete(t)}dispose(){if(!this.disposed){this.disposed=!0,super.dispose(),this.bufferCache.clear(),this.decoding.clear(),this.scheduled.length=0,this.buses.dispose();try{this.masterGain.disconnect()}catch{}this.ownsContext&&this.context.state!=="closed"&&this.context.close()}}};export{tt as a,N as b,U as c,w as d,D as e,Y as f,L as g,pt as h,$ as i};
2
+ //# sourceMappingURL=chunk-2MAFJWBZ.js.map