@webmusic/kernel 0.1.0 → 0.4.0
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/LICENSE +202 -21
- package/NOTICE +2 -0
- package/README.md +138 -101
- package/dist/audio-context.cjs.map +1 -1
- package/dist/build-receipt.json +3 -3
- package/dist/chunk-27LH6QLZ.cjs +277 -0
- package/dist/chunk-27LH6QLZ.cjs.map +1 -0
- package/dist/chunk-3INDOVUC.cjs.map +1 -1
- package/dist/chunk-3RR2VIKA.js +393 -0
- package/dist/chunk-3RR2VIKA.js.map +1 -0
- package/dist/chunk-3YTKIKKX.cjs +378 -0
- package/dist/chunk-3YTKIKKX.cjs.map +1 -0
- package/dist/chunk-4RG4WQKC.js +360 -0
- package/dist/chunk-4RG4WQKC.js.map +1 -0
- package/dist/chunk-5AHVQXTF.cjs +620 -0
- package/dist/chunk-5AHVQXTF.cjs.map +1 -0
- package/dist/chunk-624KWJWZ.js +170 -0
- package/dist/chunk-624KWJWZ.js.map +1 -0
- package/dist/chunk-6HGFEKD3.cjs +851 -0
- package/dist/chunk-6HGFEKD3.cjs.map +1 -0
- package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
- package/dist/chunk-ALWV4P7D.js +726 -0
- package/dist/chunk-ALWV4P7D.js.map +1 -0
- package/dist/chunk-BADJJ6DV.cjs +143 -0
- package/dist/chunk-BADJJ6DV.cjs.map +1 -0
- package/dist/chunk-C3LMS36L.cjs +393 -0
- package/dist/chunk-C3LMS36L.cjs.map +1 -0
- package/dist/chunk-C3YWUZW3.cjs.map +1 -1
- package/dist/chunk-CR6OUWBJ.cjs +726 -0
- package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
- package/dist/chunk-CYWDZLWC.js +2141 -0
- package/dist/chunk-CYWDZLWC.js.map +1 -0
- package/dist/chunk-DDOGX2D5.js +378 -0
- package/dist/chunk-DDOGX2D5.js.map +1 -0
- package/dist/chunk-DVN6E5U3.js +620 -0
- package/dist/chunk-DVN6E5U3.js.map +1 -0
- package/dist/chunk-EURMRU2S.js +208 -0
- package/dist/chunk-EURMRU2S.js.map +1 -0
- package/dist/chunk-EXDCK2VL.cjs +20 -0
- package/dist/chunk-EXDCK2VL.cjs.map +1 -0
- package/dist/chunk-G5EIUP52.js +114 -0
- package/dist/chunk-G5EIUP52.js.map +1 -0
- package/dist/chunk-GB4DGKLZ.js +143 -0
- package/dist/chunk-GB4DGKLZ.js.map +1 -0
- package/dist/chunk-GPOEAYOW.js +2147 -0
- package/dist/chunk-GPOEAYOW.js.map +1 -0
- package/dist/chunk-I4YMA5VM.cjs +120 -0
- package/dist/chunk-I4YMA5VM.cjs.map +1 -0
- package/dist/chunk-IVWHMDCB.cjs +4383 -0
- package/dist/chunk-IVWHMDCB.cjs.map +1 -0
- package/dist/chunk-JFCBJMA7.cjs +2147 -0
- package/dist/chunk-JFCBJMA7.cjs.map +1 -0
- package/dist/chunk-JLVSAZ3K.cjs +813 -0
- package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
- package/dist/chunk-K7FYH6UG.cjs +208 -0
- package/dist/chunk-K7FYH6UG.cjs.map +1 -0
- package/dist/chunk-L4MYCETM.cjs +970 -0
- package/dist/chunk-L4MYCETM.cjs.map +1 -0
- package/dist/chunk-MNCMYNYL.js +970 -0
- package/dist/chunk-MNCMYNYL.js.map +1 -0
- package/dist/chunk-NT2BZ3QM.js +120 -0
- package/dist/chunk-NT2BZ3QM.js.map +1 -0
- package/dist/chunk-O7SA5GLC.js +277 -0
- package/dist/chunk-O7SA5GLC.js.map +1 -0
- package/dist/chunk-OCKAHITL.cjs +548 -0
- package/dist/chunk-OCKAHITL.cjs.map +1 -0
- package/dist/{chunk-HOKRTYPV.js → chunk-OPBHDUZK.js} +39 -1
- package/dist/chunk-OPBHDUZK.js.map +1 -0
- package/dist/chunk-OTXYWCLA.js +206 -0
- package/dist/chunk-OTXYWCLA.js.map +1 -0
- package/dist/chunk-P6ZA63J7.js +548 -0
- package/dist/chunk-P6ZA63J7.js.map +1 -0
- package/dist/chunk-QLF3BOST.js +20 -0
- package/dist/chunk-QLF3BOST.js.map +1 -0
- package/dist/chunk-RCWFRZDR.js +4383 -0
- package/dist/chunk-RCWFRZDR.js.map +1 -0
- package/dist/chunk-RZBLPM3L.cjs +206 -0
- package/dist/chunk-RZBLPM3L.cjs.map +1 -0
- package/dist/chunk-TA3TNJZU.cjs +360 -0
- package/dist/chunk-TA3TNJZU.cjs.map +1 -0
- package/dist/chunk-TZSRPTQL.cjs +2141 -0
- package/dist/chunk-TZSRPTQL.cjs.map +1 -0
- package/dist/chunk-UMTPJ76S.cjs.map +1 -1
- package/dist/chunk-UY77FXDW.js +813 -0
- package/dist/chunk-UY77FXDW.js.map +1 -0
- package/dist/chunk-VFU3S7OC.js +851 -0
- package/dist/chunk-VFU3S7OC.js.map +1 -0
- package/dist/chunk-VY6WWZSW.cjs.map +1 -1
- package/dist/chunk-WN5DZOVT.cjs +170 -0
- package/dist/chunk-WN5DZOVT.cjs.map +1 -0
- package/dist/{chunk-HZQX4J2J.cjs → chunk-WOPW6WLR.cjs} +40 -2
- package/dist/chunk-WOPW6WLR.cjs.map +1 -0
- package/dist/chunk-XBSIYUHM.cjs +114 -0
- package/dist/chunk-XBSIYUHM.cjs.map +1 -0
- package/dist/chunk-ZMU72HJS.cjs.map +1 -1
- package/dist/context-DSa0ymyN.d.cts +664 -0
- package/dist/context-DaxfAg3b.d.ts +664 -0
- package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
- package/dist/effect-chain-Do75T7uK.d.cts +91 -0
- package/dist/effect.cjs +16 -1
- package/dist/effect.cjs.map +1 -1
- package/dist/effect.d.cts +56 -14
- package/dist/effect.d.ts +56 -14
- package/dist/effect.js +16 -1
- package/dist/elements.cjs +37 -2
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.d.cts +197 -8
- package/dist/elements.d.ts +197 -8
- package/dist/elements.js +36 -1
- package/dist/events.cjs.map +1 -1
- package/dist/index.cjs +556 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +567 -20
- package/dist/message.cjs +104 -0
- package/dist/message.cjs.map +1 -0
- package/dist/message.d.cts +738 -0
- package/dist/message.d.ts +738 -0
- package/dist/message.js +104 -0
- package/dist/meter.cjs +2 -2
- package/dist/meter.cjs.map +1 -1
- package/dist/meter.d.cts +9 -1
- package/dist/meter.d.ts +9 -1
- package/dist/meter.js +1 -1
- package/dist/module-control-C25BMtH7.d.ts +61 -0
- package/dist/module-control-yH6nTJM9.d.cts +61 -0
- package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
- package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
- package/dist/module.cjs +263 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +1112 -0
- package/dist/module.d.ts +1112 -0
- package/dist/module.js +263 -0
- package/dist/parameter-DwQzFmBR.d.cts +172 -0
- package/dist/parameter-DwQzFmBR.d.ts +172 -0
- package/dist/player.cjs.map +1 -1
- package/dist/processor-worklet.cjs +18 -0
- package/dist/processor-worklet.cjs.map +1 -0
- package/dist/processor-worklet.d.cts +166 -0
- package/dist/processor-worklet.d.ts +166 -0
- package/dist/processor-worklet.js +18 -0
- package/dist/processor-worklet.js.map +1 -0
- package/dist/processor.cjs +51 -0
- package/dist/processor.cjs.map +1 -0
- package/dist/processor.d.cts +397 -0
- package/dist/processor.d.ts +397 -0
- package/dist/processor.js +51 -0
- package/dist/processor.js.map +1 -0
- package/dist/project-types-BU4awMnL.d.ts +323 -0
- package/dist/project-types-DufCV8Ma.d.cts +323 -0
- package/dist/ring-C-i9N90a.d.cts +139 -0
- package/dist/ring-DkcMt2Eg.d.ts +139 -0
- package/dist/sequence.cjs +68 -0
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.cts +303 -0
- package/dist/sequence.d.ts +303 -0
- package/dist/sequence.js +68 -0
- package/dist/sequence.js.map +1 -0
- package/dist/session.cjs +16 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +407 -0
- package/dist/session.d.ts +407 -0
- package/dist/session.js +16 -0
- package/dist/session.js.map +1 -0
- package/dist/tick.cjs.map +1 -1
- package/dist/transport.cjs +50 -2
- package/dist/transport.cjs.map +1 -1
- package/dist/transport.d.cts +145 -1
- package/dist/transport.d.ts +145 -1
- package/dist/transport.js +51 -3
- package/dist/worker.cjs.map +1 -1
- package/package.json +62 -11
- package/dist/chunk-53YD73OY.js +0 -162
- package/dist/chunk-53YD73OY.js.map +0 -1
- package/dist/chunk-BR63OD53.cjs +0 -1
- package/dist/chunk-BR63OD53.cjs.map +0 -1
- package/dist/chunk-HOKRTYPV.js.map +0 -1
- package/dist/chunk-HZQX4J2J.cjs.map +0 -1
- package/dist/chunk-JNXB74G3.cjs +0 -987
- package/dist/chunk-JNXB74G3.cjs.map +0 -1
- package/dist/chunk-SM5YPDDI.cjs +0 -162
- package/dist/chunk-SM5YPDDI.cjs.map +0 -1
- package/dist/chunk-TEM2I2NN.js +0 -1
- package/dist/chunk-VVZX7DQ6.cjs +0 -254
- package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
- package/dist/chunk-WNFGDB7B.js +0 -254
- package/dist/chunk-WNFGDB7B.js.map +0 -1
- package/dist/chunk-XBJBY4J5.js +0 -987
- package/dist/chunk-XBJBY4J5.js.map +0 -1
- package/dist/sync.cjs +0 -12
- package/dist/sync.cjs.map +0 -1
- package/dist/sync.d.cts +0 -304
- package/dist/sync.d.ts +0 -304
- package/dist/sync.js +0 -12
- /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
- /package/dist/{sync.js.map → module.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transition-insert-chain.ts"],"sourcesContent":["import {InsertChain, type EffectNodes, type InsertChainOptions, type InsertSlot} from './effect-chain';\nimport {effectGenerationGuards} from './effect-generation-guard';\nimport {createTickSource, type TickSource, type TickSourceOptions} from './tick';\n\nexport interface InsertTransitionOptions {\n /** Linear crossfade in audio seconds. Default 0.02; finite and nonnegative. */\n readonly fadeSeconds?: number;\n /** Stop feeding the outgoing graph, then fade its tail over this duration. Default 0. */\n readonly tailSeconds?: number;\n}\n\nexport interface TransitionInsertChainOptions extends InsertChainOptions {\n /** Maximum simultaneously retiring generations. Default 8; positive integer. */\n readonly maxRetiring?: number;\n readonly tick?: TickSourceOptions;\n}\n\nexport interface RetiringInsertChain {\n readonly chain: InsertChain;\n /** Absolute audio-context time; suspension does not consume the tail budget. */\n readonly retireAt: number;\n}\n\ninterface Ramp {\n readonly start: number;\n readonly end: number;\n readonly from: number;\n readonly to: number;\n}\n\ninterface Generation {\n readonly chain: InsertChain;\n readonly inlet: GainNode;\n readonly outlet: GainNode;\n readonly edges: Array<{source: AudioNode; destination: AudioNode}>;\n inputRamp: Ramp;\n outputRamp: Ramp;\n retireAt?: number;\n drainingTail?: boolean;\n}\n\nlet sequence = 0;\n\n/**\n * Explicit whole-generation effect changes with stable external ports. Each\n * replacement builds fresh owned circuits; parameter/CV/automation identities\n * stay with their generation, and are never silently copied to its successor.\n * Ordinary InsertChain edits retain their existing reuse and immediate-cut rules.\n */\nexport class TransitionInsertChain {\n readonly id: string;\n readonly input: GainNode;\n readonly output: GainNode;\n private active: Generation;\n private previous: Generation[] = [];\n private ticker?: TickSource;\n private readonly maxRetiring: number;\n private serial = 0;\n private graphRevision = 0;\n private ended = false;\n private editing = false;\n\n constructor(readonly context: BaseAudioContext, private readonly options: TransitionInsertChainOptions = {}) {\n this.id = options.id ?? `transition-insert-${++sequence}`;\n if (!this.id) throw new Error('A TransitionInsertChain requires a nonempty id.');\n this.maxRetiring = options.maxRetiring ?? 8;\n if (!Number.isSafeInteger(this.maxRetiring) || this.maxRetiring < 1) {\n throw new RangeError('maxRetiring must be a positive safe integer.');\n }\n this.input = context.createGain();\n let output: GainNode | undefined;\n try {\n this.output = output = context.createGain();\n this.active = this.build([], 1);\n } catch (error) {\n try { this.input.disconnect(); } catch (cleanupError) { this.report(cleanupError); }\n try { output?.disconnect(); } catch (cleanupError) { this.report(cleanupError); }\n throw error;\n }\n }\n\n get current(): InsertChain { return this.active.chain; }\n get retiring(): readonly RetiringInsertChain[] {\n return Object.freeze(this.previous.map((generation) => Object.freeze({\n chain: generation.chain, retireAt: generation.retireAt!,\n })));\n }\n get revision(): number { return this.graphRevision; }\n get disposed(): boolean { return this.ended; }\n\n replace(slots: readonly InsertSlot[], options: InsertTransitionOptions = {}): void {\n this.assertEditable();\n const fade = duration(options.fadeSeconds ?? 0.02, 'fadeSeconds');\n const tail = duration(options.tailSeconds ?? 0, 'tailSeconds');\n let now = this.context.currentTime;\n let retireAt: number;\n if (!Number.isFinite(now) || !Number.isFinite(fade + tail)) throw new RangeError('Transition times must be finite.');\n if (slots.some((slot) => slot.ownership === 'borrowed')) {\n throw new Error('Transition generations require fresh owned effect slots.');\n }\n this.collect();\n this.assertEditable();\n if (fade + tail > 0 && this.previous.length >= this.maxRetiring) {\n throw new Error('The retiring effect generation limit has been reached.');\n }\n this.editing = true;\n const old = this.active;\n const changed: Array<{generation: Generation; input: Ramp; output: Ramp}> = [];\n let candidate: Generation | undefined;\n try {\n candidate = this.build(slots, 0);\n this.assertAlive();\n // Acquire the cleanup driver before modifying the audible generation.\n if (fade + tail > 0) {\n this.ticker ??= createTickSource(this.options.tick);\n this.ticker.start(() => this.collect());\n }\n // Recipe/worker callbacks may take longer than a fade. The commit anchor\n // is chosen only after the silent candidate and cleanup driver are ready.\n now = this.context.currentTime;\n const fadeEnd = now + fade;\n retireAt = fadeEnd + tail;\n if (!Number.isFinite(now) || !Number.isFinite(retireAt)) throw new RangeError('Transition times must be finite.');\n candidate.outputRamp = this.ramp(candidate.outlet.gain, candidate.outputRamp, now, now, fadeEnd, 1);\n // An interrupted crossfade hands off the whole audible mix, not just its\n // newest generation. Keep intentional tails on their existing deadlines.\n const outgoing = [old, ...this.previous.filter((generation) => !generation.drainingTail && generation.retireAt! > now)];\n for (const generation of outgoing) {\n const {inputRamp: input, outputRamp: output} = generation;\n changed.push({generation, input, output});\n if (tail > 0) {\n generation.inputRamp = this.ramp(generation.inlet.gain, input, now, now, fadeEnd, 0);\n generation.outputRamp = this.ramp(generation.outlet.gain, output, now, fadeEnd, retireAt, 0);\n } else {\n generation.outputRamp = this.ramp(generation.outlet.gain, output, now, now, fadeEnd, 0);\n generation.inputRamp = this.ramp(generation.inlet.gain, input, now, fadeEnd, fadeEnd, 0);\n }\n }\n this.assertAlive();\n } catch (error) {\n if (candidate) this.release(candidate);\n if (!this.ended) {\n for (const {generation, input, output} of changed) {\n this.restore(generation.inlet.gain, input, now);\n this.restore(generation.outlet.gain, output, now);\n generation.inputRamp = input;\n generation.outputRamp = output;\n }\n }\n if (!this.previous.length) this.ticker?.stop();\n this.editing = false;\n throw error;\n }\n this.active = candidate;\n for (const {generation} of changed) {\n generation.retireAt = retireAt;\n generation.drainingTail = tail > 0;\n }\n this.previous.push(old);\n this.graphRevision++;\n this.editing = false;\n this.collect();\n }\n\n /** Release expired generations; useful after deterministic offline rendering. */\n collect(): void {\n if (this.ended || this.editing) return;\n this.editing = true;\n const due = this.previous.filter((generation) => generation.retireAt! <= this.context.currentTime);\n this.previous = this.previous.filter((generation) => !due.includes(generation));\n for (const generation of due) this.release(generation);\n this.editing = false;\n if (!this.previous.length) this.ticker?.stop();\n }\n\n dispose(): void {\n if (this.ended) return;\n this.ended = true;\n this.graphRevision++;\n try { this.ticker?.dispose(); } catch (error) { this.report(error); }\n const generations = [this.active, ...this.previous];\n this.previous = [];\n for (const generation of generations) this.release(generation);\n }\n\n private build(slots: readonly InsertSlot[], level: number): Generation {\n const chain = new InsertChain(this.context, {id: `${this.id}/generation-${++this.serial}`, onCleanupError: this.options.onCleanupError});\n let generation: Generation | undefined;\n try {\n generation = {\n chain, inlet: this.context.createGain(), outlet: this.context.createGain(), edges: [],\n inputRamp: {start: this.context.currentTime, end: this.context.currentTime, from: 1, to: 1},\n outputRamp: {start: this.context.currentTime, end: this.context.currentTime, from: level, to: level},\n };\n const owner = generation;\n effectGenerationGuards.set(chain, (nodes) => this.reserved(nodes, owner));\n generation.inlet.gain.value = 1;\n generation.outlet.gain.value = level;\n chain.replace(slots);\n this.assertAlive();\n for (const edge of [\n {source: this.input, destination: generation.inlet},\n {source: generation.inlet, destination: chain.input},\n {source: chain.output, destination: generation.outlet},\n {source: generation.outlet, destination: this.output},\n ]) {\n generation.edges.push(edge);\n edge.source.connect(edge.destination);\n this.assertAlive();\n }\n return generation;\n } catch (error) {\n if (generation) this.release(generation);\n else {\n try { chain.dispose(); } catch (cleanupError) { this.report(cleanupError); }\n }\n throw error;\n }\n }\n\n private reserved(nodes: EffectNodes, owner: Generation): boolean {\n const touches = (node: AudioNode) => nodes.input === node || nodes.output === node;\n if ([this.input, this.output, owner.inlet, owner.outlet].some(touches)) return true;\n for (const generation of [this.active, ...this.previous]) {\n if (!generation || generation === owner) continue;\n if ([generation.inlet, generation.outlet, generation.chain.input, generation.chain.output].some(touches)) return true;\n for (const instance of generation.chain.instances) {\n if (touches(instance.nodes.input) || touches(instance.nodes.output)) return true;\n const parameters = new Set(Object.values(instance.nodes.params ?? {}));\n if (Object.values(nodes.params ?? {}).some((parameter) => parameters.has(parameter))) return true;\n }\n }\n return false;\n }\n\n private ramp(parameter: AudioParam, previous: Ramp, now: number, start: number, end: number, to: number): Ramp {\n const from = valueAt(previous, now);\n hold(parameter, from, now);\n if (start > now) parameter.setValueAtTime(from, start);\n if (end > start) parameter.linearRampToValueAtTime(to, end);\n else parameter.setValueAtTime(to, end);\n return {start, end, from, to};\n }\n\n private restore(parameter: AudioParam, previous: Ramp, now: number): void {\n try {\n hold(parameter, valueAt(previous, now), now);\n if (previous.start > now) parameter.setValueAtTime(previous.from, previous.start);\n if (previous.end > now) {\n if (previous.end > previous.start) parameter.linearRampToValueAtTime(previous.to, previous.end);\n else parameter.setValueAtTime(previous.to, previous.end);\n }\n } catch (error) { this.report(error); }\n }\n\n private release(generation: Generation): void {\n effectGenerationGuards.delete(generation.chain);\n for (const edge of [...generation.edges].reverse()) {\n try { edge.source.disconnect(edge.destination); } catch (error) { this.report(error); }\n }\n generation.edges.length = 0;\n try { generation.chain.dispose(); } catch (error) { this.report(error); }\n }\n\n private assertAlive(): void {\n if (this.ended) throw new Error('TransitionInsertChain is disposed.');\n }\n\n private assertEditable(): void {\n this.assertAlive();\n if (this.editing) throw new Error('TransitionInsertChain edits cannot re-enter graph construction or cleanup.');\n }\n\n private report(error: unknown): void {\n try { this.options.onCleanupError?.(error); } catch { /* Diagnostics cannot change graph ownership. */ }\n }\n}\n\nfunction valueAt(ramp: Ramp, time: number): number {\n if (time < ramp.start) return ramp.from;\n if (time >= ramp.end) return ramp.to;\n return ramp.from + (ramp.to - ramp.from) * (time - ramp.start) / (ramp.end - ramp.start);\n}\n\nfunction hold(parameter: AudioParam, value: number, time: number): void {\n if (typeof parameter.cancelAndHoldAtTime === 'function') parameter.cancelAndHoldAtTime(time);\n else {\n parameter.cancelScheduledValues(time);\n // Re-establish the truncated linear ramp, including its already elapsed\n // portion in OfflineAudioContext command sequences prepared before render.\n parameter.linearRampToValueAtTime(value, time);\n }\n parameter.setValueAtTime(value, time);\n}\n\nfunction duration(value: number, name: string): number {\n if (!Number.isFinite(value) || value < 0) throw new RangeError(`${name} must be finite and nonnegative.`);\n return value;\n}\n"],"mappings":";;;;;;;;;AAyCA,IAAI,WAAW;AAQR,IAAM,wBAAN,MAA4B;AAAA,EAajC,YAAqB,SAA4C,UAAwC,CAAC,GAAG;AAAxF;AAA4C;AARjE,SAAQ,WAAyB,CAAC;AAGlC,SAAQ,SAAS;AACjB,SAAQ,gBAAgB;AACxB,SAAQ,QAAQ;AAChB,SAAQ,UAAU;AAGhB,SAAK,KAAK,QAAQ,MAAM,qBAAqB,EAAE,QAAQ;AACvD,QAAI,CAAC,KAAK,GAAI,OAAM,IAAI,MAAM,iDAAiD;AAC/E,SAAK,cAAc,QAAQ,eAAe;AAC1C,Q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AAO,QAAO,KAAK;AACnC,MAAI,QAAQ,KAAK,IAAK,QAAO,KAAK;AAClC,SAAO,KAAK,QAAQ,KAAK,KAAK,KAAK,SAAS,OAAO,KAAK,UAAU,KAAK,MAAM,KAAK;AACpF;AAEA,SAAS,KAAK,WAAuB,OAAe,MAAoB;AACtE,MAAI,OAAO,UAAU,wBAAwB,WAAY,WAAU,oBAAoB,IAAI;AAAA,OACtF;AACH,cAAU,sBAAsB,IAAI;AAGpC,cAAU,wBAAwB,OAAO,IAAI;AAAA,EAC/C;AACA,YAAU,eAAe,OAAO,IAAI;AACtC;AAEA,SAAS,SAAS,OAAe,MAAsB;AACrD,MAAI,CAAC,OAAO,SAAS,KAAK,KAAK,QAAQ,EAAG,OAAM,IAAI,WAAW,GAAG,IAAI,kCAAkC;AACxG,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkVY6WWZSWcjs = require('./chunk-VY6WWZSW.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkI4YMA5VMcjs = require('./chunk-I4YMA5VM.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkBADJJ6DVcjs = require('./chunk-BADJJ6DV.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkEXDCK2VLcjs = require('./chunk-EXDCK2VL.cjs');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunk7ZTZZ5PNcjs = require('./chunk-7ZTZZ5PN.cjs');
|
|
20
|
+
|
|
21
|
+
// src/module/transport-port.ts
|
|
22
|
+
function project(snapshot) {
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
revision: snapshot.revision,
|
|
25
|
+
axis: snapshot.axis,
|
|
26
|
+
referenceTime: snapshot.referenceTime,
|
|
27
|
+
position: snapshot.position,
|
|
28
|
+
durationSeconds: snapshot.durationSeconds,
|
|
29
|
+
playing: !snapshot.paused,
|
|
30
|
+
rate: snapshot.rate,
|
|
31
|
+
loop: snapshot.loop,
|
|
32
|
+
ended: snapshot.ended,
|
|
33
|
+
pending: snapshot.pending,
|
|
34
|
+
schedulingMode: snapshot.schedulingMode
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function createTransportPort(session, options = {}) {
|
|
38
|
+
let detached = false;
|
|
39
|
+
const read = () => project(session.snapshot);
|
|
40
|
+
const outcome = async (run) => {
|
|
41
|
+
try {
|
|
42
|
+
const commit = await run();
|
|
43
|
+
return Object.freeze({ status: commit.status, revision: commit.revision, snapshot: project(commit.snapshot) });
|
|
44
|
+
} catch (error) {
|
|
45
|
+
let snapshot;
|
|
46
|
+
try {
|
|
47
|
+
snapshot = read();
|
|
48
|
+
} catch (e) {
|
|
49
|
+
snapshot = last;
|
|
50
|
+
}
|
|
51
|
+
return Object.freeze({ status: "failed", revision: null, snapshot, error });
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
let last = read();
|
|
55
|
+
const commands = options.commands ? Object.freeze({
|
|
56
|
+
play: () => outcome(() => session.play()),
|
|
57
|
+
pause: () => outcome(() => session.pause()),
|
|
58
|
+
stop: () => outcome(() => session.stop()),
|
|
59
|
+
seek: (position) => outcome(() => session.seek(position)),
|
|
60
|
+
setRate: (rate) => outcome(() => session.setRate(rate)),
|
|
61
|
+
setLoop: (loop) => outcome(() => session.setLoop(loop))
|
|
62
|
+
}) : void 0;
|
|
63
|
+
return Object.freeze({
|
|
64
|
+
id: _nullishCoalesce(options.id, () => ( "transport")),
|
|
65
|
+
family: "transport",
|
|
66
|
+
direction: "output",
|
|
67
|
+
multiplicity: "single",
|
|
68
|
+
schemaVersion: 1,
|
|
69
|
+
get readiness() {
|
|
70
|
+
if (detached) return "detached";
|
|
71
|
+
try {
|
|
72
|
+
return session.snapshot.disposed ? "detached" : "ready";
|
|
73
|
+
} catch (e2) {
|
|
74
|
+
detached = true;
|
|
75
|
+
return "detached";
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
axis: last.axis,
|
|
79
|
+
...commands ? { commands } : {},
|
|
80
|
+
snapshot: () => {
|
|
81
|
+
try {
|
|
82
|
+
last = read();
|
|
83
|
+
} catch (e3) {
|
|
84
|
+
detached = true;
|
|
85
|
+
}
|
|
86
|
+
return last;
|
|
87
|
+
},
|
|
88
|
+
positionAt: (referenceTime) => session.scheduling.positionAt(referenceTime),
|
|
89
|
+
subscribe: (listener) => {
|
|
90
|
+
if (typeof listener !== "function") throw new TypeError("Listener must be a function");
|
|
91
|
+
return session.subscribe((event) => {
|
|
92
|
+
last = project(event.snapshot);
|
|
93
|
+
listener(last);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/module/context.ts
|
|
100
|
+
var sessionPorts = /* @__PURE__ */ new WeakMap();
|
|
101
|
+
function sessionPort(session) {
|
|
102
|
+
let port = sessionPorts.get(session);
|
|
103
|
+
if (!port) {
|
|
104
|
+
port = createTransportPort(session, { commands: true });
|
|
105
|
+
sessionPorts.set(session, port);
|
|
106
|
+
}
|
|
107
|
+
return port;
|
|
108
|
+
}
|
|
109
|
+
var _context, _create, _owned, _disposed, _preparing, _ModuleAudioEnvironment_instances, close_fn;
|
|
110
|
+
var ModuleAudioEnvironment = class {
|
|
111
|
+
constructor(options = {}) {
|
|
112
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _ModuleAudioEnvironment_instances);
|
|
113
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _context);
|
|
114
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _create);
|
|
115
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _owned);
|
|
116
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _disposed, false);
|
|
117
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _preparing, false);
|
|
118
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _context, options.context);
|
|
119
|
+
this.createTickSource = options.createTickSource;
|
|
120
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _owned, !options.context && (_nullishCoalesce(options.owned, () => ( true))));
|
|
121
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _create, _nullishCoalesce(options.create, () => ( (() => {
|
|
122
|
+
const Constructor = _chunkVY6WWZSWcjs.getAudioContextConstructor.call(void 0, );
|
|
123
|
+
if (!Constructor) throw new Error("AudioContext is unavailable");
|
|
124
|
+
return new Constructor();
|
|
125
|
+
}))));
|
|
126
|
+
}
|
|
127
|
+
get disposed() {
|
|
128
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed);
|
|
129
|
+
}
|
|
130
|
+
peek() {
|
|
131
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _context);
|
|
132
|
+
}
|
|
133
|
+
prepare() {
|
|
134
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed)) throw new Error("ModuleAudioEnvironment is disposed");
|
|
135
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _preparing)) throw new Error("Module audio preparation cannot re-enter");
|
|
136
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _context)) {
|
|
137
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _context).state === "closed") throw new Error("Module audio context is closed");
|
|
138
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _context);
|
|
139
|
+
}
|
|
140
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _preparing, true);
|
|
141
|
+
try {
|
|
142
|
+
const context = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _create).call(this);
|
|
143
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed)) {
|
|
144
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _owned)) _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _ModuleAudioEnvironment_instances, close_fn).call(this, context);
|
|
145
|
+
throw new Error("ModuleAudioEnvironment was disposed during preparation");
|
|
146
|
+
}
|
|
147
|
+
if (context.state === "closed") throw new Error("Module audio context is closed");
|
|
148
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _context, context);
|
|
149
|
+
return context;
|
|
150
|
+
} finally {
|
|
151
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _preparing, false);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
dispose() {
|
|
155
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed)) return;
|
|
156
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _disposed, true);
|
|
157
|
+
const context = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _context);
|
|
158
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _context, void 0);
|
|
159
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _owned) && context) _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _ModuleAudioEnvironment_instances, close_fn).call(this, context);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
_context = new WeakMap();
|
|
163
|
+
_create = new WeakMap();
|
|
164
|
+
_owned = new WeakMap();
|
|
165
|
+
_disposed = new WeakMap();
|
|
166
|
+
_preparing = new WeakMap();
|
|
167
|
+
_ModuleAudioEnvironment_instances = new WeakSet();
|
|
168
|
+
close_fn = function(context) {
|
|
169
|
+
if ("close" in context && typeof context.close === "function" && context.state !== "closed") {
|
|
170
|
+
void Promise.resolve(context.close()).catch(() => {
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var _transport;
|
|
175
|
+
var _ModuleContext = class _ModuleContext {
|
|
176
|
+
constructor(options) {
|
|
177
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _transport);
|
|
178
|
+
_chunkBADJJ6DVcjs.assertModuleId.call(void 0, options.id);
|
|
179
|
+
this.id = options.id;
|
|
180
|
+
this.audio = options.audio;
|
|
181
|
+
this.registry = _nullishCoalesce(options.registry, () => ( new (0, _chunkBADJJ6DVcjs.ModuleRegistry)()));
|
|
182
|
+
this.session = options.session;
|
|
183
|
+
this.destination = options.destination;
|
|
184
|
+
this.admit = options.admit;
|
|
185
|
+
this.target = options.target;
|
|
186
|
+
this.capabilities = _nullishCoalesce(options.capabilities, () => ( new (0, _chunkI4YMA5VMcjs.ModuleCapabilities)()));
|
|
187
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _transport, options.transport);
|
|
188
|
+
Object.freeze(this);
|
|
189
|
+
}
|
|
190
|
+
/** The transport port this scope lends, if any; observing it grants no command authority beyond its own `commands`. */
|
|
191
|
+
get transport() {
|
|
192
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _transport) === null) return void 0;
|
|
193
|
+
return _nullishCoalesce(_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _transport), () => ( (this.session ? sessionPort(this.session) : void 0)));
|
|
194
|
+
}
|
|
195
|
+
derive(options) {
|
|
196
|
+
const sessionChanged = options.session !== void 0 && (_nullishCoalesce(options.session, () => ( void 0))) !== this.session;
|
|
197
|
+
const transport = options.transport !== void 0 ? options.transport : sessionChanged ? void 0 : _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _transport);
|
|
198
|
+
return new _ModuleContext({
|
|
199
|
+
transport,
|
|
200
|
+
id: options.id,
|
|
201
|
+
audio: this.audio,
|
|
202
|
+
registry: _nullishCoalesce(options.registry, () => ( this.registry)),
|
|
203
|
+
session: options.session === void 0 ? this.session : _nullishCoalesce(options.session, () => ( void 0)),
|
|
204
|
+
destination: _nullishCoalesce(options.destination, () => ( this.destination)),
|
|
205
|
+
admit: options.admit === void 0 ? this.admit : _nullishCoalesce(options.admit, () => ( void 0)),
|
|
206
|
+
target: options.target === void 0 ? this.target : _nullishCoalesce(options.target, () => ( void 0)),
|
|
207
|
+
capabilities: _nullishCoalesce(options.capabilities, () => ( this.capabilities))
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
_transport = new WeakMap();
|
|
212
|
+
var ModuleContext = _ModuleContext;
|
|
213
|
+
function moduleScopeChange(previous, next) {
|
|
214
|
+
if (!previous || !next || previous.audio !== next.audio || previous.session !== next.session || previous.registry !== next.registry || previous.admit !== next.admit || previous.transport !== next.transport) return "scope";
|
|
215
|
+
return previous.destination === next.destination ? "none" : "destination";
|
|
216
|
+
}
|
|
217
|
+
function sameModuleScope(left, right) {
|
|
218
|
+
return moduleScopeChange(left, right) === "none";
|
|
219
|
+
}
|
|
220
|
+
function routeModuleOutput(context, module, port) {
|
|
221
|
+
if (context.admit) return context.admit(module, port);
|
|
222
|
+
const destination = _nullishCoalesce(_optionalChain([context, 'access', _ => _.destination, 'optionalCall', _2 => _2()]), () => ( context.audio.prepare().destination));
|
|
223
|
+
port.setDefault(destination);
|
|
224
|
+
return _chunkEXDCK2VLcjs.createConnectionLease.call(void 0, () => {
|
|
225
|
+
if (!port.disposed && port.defaultDestination === destination) port.setDefault(void 0);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/module/audio-port.ts
|
|
230
|
+
var edges = /* @__PURE__ */ new WeakMap();
|
|
231
|
+
var connecting = /* @__PURE__ */ new WeakSet();
|
|
232
|
+
function connect(source, destination) {
|
|
233
|
+
if (connecting.has(source)) throw new Error("Audio connections from the same node cannot re-enter");
|
|
234
|
+
if (!destination || source.context !== destination.context) {
|
|
235
|
+
throw new Error("Audio endpoints must use the same context");
|
|
236
|
+
}
|
|
237
|
+
if (source === destination) throw new Error("An audio output cannot feed itself");
|
|
238
|
+
const visited = /* @__PURE__ */ new Set();
|
|
239
|
+
const pending = [destination];
|
|
240
|
+
while (pending.length) {
|
|
241
|
+
const node = pending.pop();
|
|
242
|
+
if (node === source) throw new Error("Managed audio connections cannot form a feedback cycle");
|
|
243
|
+
if (visited.has(node)) continue;
|
|
244
|
+
visited.add(node);
|
|
245
|
+
pending.push(..._nullishCoalesce(_optionalChain([edges, 'access', _3 => _3.get, 'call', _4 => _4(node), 'optionalAccess', _5 => _5.keys, 'call', _6 => _6()]), () => ( [])));
|
|
246
|
+
}
|
|
247
|
+
const outgoing = _nullishCoalesce(edges.get(source), () => ( /* @__PURE__ */ new Map()));
|
|
248
|
+
const references = _nullishCoalesce(outgoing.get(destination), () => ( 0));
|
|
249
|
+
if (references === 0) {
|
|
250
|
+
connecting.add(source);
|
|
251
|
+
try {
|
|
252
|
+
source.connect(destination);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
try {
|
|
255
|
+
source.disconnect(destination);
|
|
256
|
+
} catch (e4) {
|
|
257
|
+
}
|
|
258
|
+
throw error;
|
|
259
|
+
} finally {
|
|
260
|
+
connecting.delete(source);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
outgoing.set(destination, references + 1);
|
|
264
|
+
edges.set(source, outgoing);
|
|
265
|
+
return _chunkEXDCK2VLcjs.createConnectionLease.call(void 0, () => {
|
|
266
|
+
const count = _nullishCoalesce(outgoing.get(destination), () => ( 0));
|
|
267
|
+
if (count > 1) {
|
|
268
|
+
outgoing.set(destination, count - 1);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
outgoing.delete(destination);
|
|
272
|
+
if (outgoing.size === 0) edges.delete(source);
|
|
273
|
+
source.disconnect(destination);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
var _onCleanupError, _branches, _defaultDestination, _defaultEdge, _replacement, _disposed2, _editing, _afterEdit, _AudioOutputPort_instances, branch_fn, releaseReplacement_fn, endEdit_fn, beginEdit_fn, connect_fn, assertActive_fn, retire_fn, report_fn;
|
|
277
|
+
var AudioOutputPort = class {
|
|
278
|
+
constructor(node, options = {}) {
|
|
279
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _AudioOutputPort_instances);
|
|
280
|
+
this.kind = "audio";
|
|
281
|
+
this.family = "audio";
|
|
282
|
+
this.direction = "output";
|
|
283
|
+
/** One main route; sends and taps are separate branches. */
|
|
284
|
+
this.multiplicity = "single";
|
|
285
|
+
this.schemaVersion = 1;
|
|
286
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _onCleanupError);
|
|
287
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _branches, /* @__PURE__ */ new Set());
|
|
288
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _defaultDestination);
|
|
289
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _defaultEdge);
|
|
290
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _replacement);
|
|
291
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _disposed2, false);
|
|
292
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _editing, false);
|
|
293
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _afterEdit);
|
|
294
|
+
this.node = node;
|
|
295
|
+
this.context = node.context;
|
|
296
|
+
this.id = _nullishCoalesce(options.id, () => ( "main"));
|
|
297
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _onCleanupError, options.onCleanupError);
|
|
298
|
+
if (options.defaultDestination) this.setDefault(options.defaultDestination);
|
|
299
|
+
Object.freeze(this);
|
|
300
|
+
}
|
|
301
|
+
get disposed() {
|
|
302
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2);
|
|
303
|
+
}
|
|
304
|
+
get readiness() {
|
|
305
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2) ? "detached" : "ready";
|
|
306
|
+
}
|
|
307
|
+
get defaultDestination() {
|
|
308
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultDestination);
|
|
309
|
+
}
|
|
310
|
+
get replaced() {
|
|
311
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _replacement) !== void 0;
|
|
312
|
+
}
|
|
313
|
+
setDefault(destination) {
|
|
314
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, beginEdit_fn).call(this);
|
|
315
|
+
try {
|
|
316
|
+
if (destination && destination.context !== this.context) throw new Error("Audio endpoints must use the same context");
|
|
317
|
+
if (destination === this.node) throw new Error("An audio output cannot feed itself");
|
|
318
|
+
if (destination === _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultDestination)) return;
|
|
319
|
+
const next = destination && !_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _replacement) ? _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, connect_fn).call(this, destination) : void 0;
|
|
320
|
+
const previous = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultEdge);
|
|
321
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _defaultDestination, destination);
|
|
322
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _defaultEdge, next);
|
|
323
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, previous);
|
|
324
|
+
} finally {
|
|
325
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, endEdit_fn).call(this);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
replace(destination) {
|
|
329
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, beginEdit_fn).call(this);
|
|
330
|
+
try {
|
|
331
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _replacement)) throw new Error("The main route already has a replacement claimant");
|
|
332
|
+
const edge = _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, connect_fn).call(this, destination);
|
|
333
|
+
const lease = _chunkEXDCK2VLcjs.createConnectionLease.call(void 0, () => {
|
|
334
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _editing) && !_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2)) {
|
|
335
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _afterEdit, () => _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, releaseReplacement_fn).call(this, lease));
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, releaseReplacement_fn).call(this, lease);
|
|
339
|
+
});
|
|
340
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _replacement, { lease, edge });
|
|
341
|
+
const previous = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultEdge);
|
|
342
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _defaultEdge, void 0);
|
|
343
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, previous);
|
|
344
|
+
return lease;
|
|
345
|
+
} finally {
|
|
346
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, endEdit_fn).call(this);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
send(destination) {
|
|
350
|
+
return _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, branch_fn).call(this, destination);
|
|
351
|
+
}
|
|
352
|
+
tap(destination) {
|
|
353
|
+
return _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, branch_fn).call(this, destination);
|
|
354
|
+
}
|
|
355
|
+
dispose() {
|
|
356
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2)) return;
|
|
357
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _disposed2, true);
|
|
358
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _defaultDestination, void 0);
|
|
359
|
+
const normal = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultEdge);
|
|
360
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _defaultEdge, void 0);
|
|
361
|
+
const replacement = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _replacement);
|
|
362
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, normal);
|
|
363
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, _optionalChain([replacement, 'optionalAccess', _7 => _7.lease]));
|
|
364
|
+
if (replacement) _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, releaseReplacement_fn).call(this, replacement.lease);
|
|
365
|
+
for (const lease of [..._chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _branches)]) _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, lease);
|
|
366
|
+
_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _branches).clear();
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
_onCleanupError = new WeakMap();
|
|
370
|
+
_branches = new WeakMap();
|
|
371
|
+
_defaultDestination = new WeakMap();
|
|
372
|
+
_defaultEdge = new WeakMap();
|
|
373
|
+
_replacement = new WeakMap();
|
|
374
|
+
_disposed2 = new WeakMap();
|
|
375
|
+
_editing = new WeakMap();
|
|
376
|
+
_afterEdit = new WeakMap();
|
|
377
|
+
_AudioOutputPort_instances = new WeakSet();
|
|
378
|
+
branch_fn = function(destination) {
|
|
379
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, beginEdit_fn).call(this);
|
|
380
|
+
try {
|
|
381
|
+
const edge = _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, connect_fn).call(this, destination);
|
|
382
|
+
const lease = _chunkEXDCK2VLcjs.createConnectionLease.call(void 0, () => {
|
|
383
|
+
_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _branches).delete(lease);
|
|
384
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, edge);
|
|
385
|
+
});
|
|
386
|
+
_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _branches).add(lease);
|
|
387
|
+
return lease;
|
|
388
|
+
} finally {
|
|
389
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, endEdit_fn).call(this);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
releaseReplacement_fn = function(lease) {
|
|
393
|
+
const current = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _replacement);
|
|
394
|
+
if (!current || current.lease !== lease) return;
|
|
395
|
+
const alreadyEditing = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _editing);
|
|
396
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _editing, true);
|
|
397
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _replacement, void 0);
|
|
398
|
+
try {
|
|
399
|
+
if (!_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2) && _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultDestination)) {
|
|
400
|
+
try {
|
|
401
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _defaultEdge, _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, connect_fn).call(this, _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _defaultDestination)));
|
|
402
|
+
} catch (error) {
|
|
403
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, report_fn).call(this, error);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, current.edge);
|
|
407
|
+
} finally {
|
|
408
|
+
if (!alreadyEditing) _chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, endEdit_fn).call(this);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
endEdit_fn = function() {
|
|
412
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _editing, false);
|
|
413
|
+
const after = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _afterEdit);
|
|
414
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _afterEdit, void 0);
|
|
415
|
+
_optionalChain([after, 'optionalCall', _8 => _8()]);
|
|
416
|
+
};
|
|
417
|
+
beginEdit_fn = function() {
|
|
418
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, assertActive_fn).call(this);
|
|
419
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _editing)) throw new Error("Audio port edits cannot re-enter");
|
|
420
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _editing, true);
|
|
421
|
+
};
|
|
422
|
+
connect_fn = function(destination) {
|
|
423
|
+
const edge = connect(this.node, destination);
|
|
424
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2)) {
|
|
425
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, retire_fn).call(this, edge);
|
|
426
|
+
throw new Error("AudioOutputPort was disposed during connection");
|
|
427
|
+
}
|
|
428
|
+
return edge;
|
|
429
|
+
};
|
|
430
|
+
assertActive_fn = function() {
|
|
431
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed2)) throw new Error("AudioOutputPort is disposed");
|
|
432
|
+
};
|
|
433
|
+
retire_fn = function(lease) {
|
|
434
|
+
try {
|
|
435
|
+
_optionalChain([lease, 'optionalAccess', _9 => _9.release, 'call', _10 => _10()]);
|
|
436
|
+
} catch (error) {
|
|
437
|
+
_chunk7ZTZZ5PNcjs.__privateMethod.call(void 0, this, _AudioOutputPort_instances, report_fn).call(this, error);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
report_fn = function(error) {
|
|
441
|
+
var _a;
|
|
442
|
+
try {
|
|
443
|
+
(_a = _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _onCleanupError)) == null ? void 0 : _a.call(this, error);
|
|
444
|
+
} catch (e5) {
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
var _producers, _disposed3;
|
|
448
|
+
var AudioInputPort = class {
|
|
449
|
+
constructor(node, options = {}) {
|
|
450
|
+
this.family = "audio";
|
|
451
|
+
this.direction = "input";
|
|
452
|
+
this.schemaVersion = 1;
|
|
453
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _producers, /* @__PURE__ */ new Map());
|
|
454
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _disposed3, false);
|
|
455
|
+
const latency = _nullishCoalesce(options.latencySeconds, () => ( 0));
|
|
456
|
+
if (!Number.isFinite(latency) || latency < 0) throw new RangeError("latencySeconds must be nonnegative finite seconds");
|
|
457
|
+
const multiplicity = _nullishCoalesce(options.multiplicity, () => ( "sum"));
|
|
458
|
+
if (multiplicity !== "single" && multiplicity !== "sum") throw new TypeError(`Unknown port multiplicity: ${String(multiplicity)}`);
|
|
459
|
+
this.node = node;
|
|
460
|
+
this.context = node.context;
|
|
461
|
+
this.id = _nullishCoalesce(options.id, () => ( "input"));
|
|
462
|
+
this.multiplicity = multiplicity;
|
|
463
|
+
this.latencySeconds = latency;
|
|
464
|
+
Object.freeze(this);
|
|
465
|
+
}
|
|
466
|
+
get disposed() {
|
|
467
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed3);
|
|
468
|
+
}
|
|
469
|
+
get readiness() {
|
|
470
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed3) ? "detached" : "ready";
|
|
471
|
+
}
|
|
472
|
+
get channelCount() {
|
|
473
|
+
return this.node.channelCount;
|
|
474
|
+
}
|
|
475
|
+
get channelInterpretation() {
|
|
476
|
+
return this.node.channelInterpretation;
|
|
477
|
+
}
|
|
478
|
+
get producers() {
|
|
479
|
+
return Object.freeze([..._chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).keys()]);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Admit a producer. `main` claims the producer's main route through
|
|
483
|
+
* {@link AudioOutputPort.replace}; `send` adds a branch. Validation happens
|
|
484
|
+
* before any edge changes, so a rejected producer keeps its current route.
|
|
485
|
+
*/
|
|
486
|
+
connect(output, mode = "main") {
|
|
487
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed3)) throw new Error("AudioInputPort is disposed");
|
|
488
|
+
if (output.disposed) throw new Error("AudioOutputPort is disposed");
|
|
489
|
+
if (output.context !== this.context) throw new Error("Audio endpoints must use the same context");
|
|
490
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).has(output)) throw new Error(`Audio output is already connected to input: ${this.id}`);
|
|
491
|
+
if (this.multiplicity === "single" && _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).size > 0) {
|
|
492
|
+
throw new Error(`Audio input accepts a single producer: ${this.id}`);
|
|
493
|
+
}
|
|
494
|
+
if (mode !== "main" && mode !== "send") throw new TypeError(`Unknown audio connection mode: ${String(mode)}`);
|
|
495
|
+
const edge = mode === "main" ? output.replace(this.node) : output.send(this.node);
|
|
496
|
+
const lease = _chunkEXDCK2VLcjs.createConnectionLease.call(void 0, () => {
|
|
497
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).get(output) === lease) _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).delete(output);
|
|
498
|
+
edge.release();
|
|
499
|
+
});
|
|
500
|
+
_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).set(output, lease);
|
|
501
|
+
return lease;
|
|
502
|
+
}
|
|
503
|
+
/** Release every admitted producer; the borrowed node stays connected to its own consumers. */
|
|
504
|
+
dispose() {
|
|
505
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _disposed3)) return;
|
|
506
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _disposed3, true);
|
|
507
|
+
let failure;
|
|
508
|
+
for (const lease of [..._chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).values()]) {
|
|
509
|
+
try {
|
|
510
|
+
lease.release();
|
|
511
|
+
} catch (error) {
|
|
512
|
+
_nullishCoalesce(failure, () => ( (failure = error)));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _producers).clear();
|
|
516
|
+
if (failure !== void 0) throw failure;
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
_producers = new WeakMap();
|
|
520
|
+
_disposed3 = new WeakMap();
|
|
521
|
+
|
|
522
|
+
// src/module/control-port.ts
|
|
523
|
+
function createControlPort(params, options = {}) {
|
|
524
|
+
return Object.freeze({
|
|
525
|
+
id: _nullishCoalesce(options.id, () => ( "params")),
|
|
526
|
+
family: "control",
|
|
527
|
+
direction: "input",
|
|
528
|
+
multiplicity: "sum",
|
|
529
|
+
schemaVersion: 1,
|
|
530
|
+
get readiness() {
|
|
531
|
+
return params.handles.length > 0 && params.handles.every((handle) => handle.snapshot.disposed) ? "detached" : "ready";
|
|
532
|
+
},
|
|
533
|
+
params
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
exports.createTransportPort = createTransportPort; exports.ModuleAudioEnvironment = ModuleAudioEnvironment; exports.ModuleContext = ModuleContext; exports.moduleScopeChange = moduleScopeChange; exports.sameModuleScope = sameModuleScope; exports.routeModuleOutput = routeModuleOutput; exports.AudioOutputPort = AudioOutputPort; exports.AudioInputPort = AudioInputPort; exports.createControlPort = createControlPort;
|
|
548
|
+
//# sourceMappingURL=chunk-OCKAHITL.cjs.map
|