@combos-fun/plugin-sound 0.0.49 → 0.0.51

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.
@@ -364,7 +364,7 @@ var SoundSystem = SoundSystem$1;
364
364
  /** Auto-generated by scripts/build-package.mjs — do not edit. */
365
365
  Object.assign(SoundSystem, {
366
366
  packageName: "@combos-fun/plugin-sound",
367
- packageVersion: "0.0.49",
367
+ packageVersion: "0.0.51",
368
368
  });
369
369
 
370
370
  class Sound extends engine.Component {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-sound.cjs.js","sources":["../lib/hostMessages.ts","../lib/SoundSystem.ts","../lib/__combosPackageMeta.gen.ts","../lib/Sound.ts"],"sourcesContent":["/** Parent → iframe (also `window` CustomEvent / `game.emit`): mute or unmute. Payload: `{ muted: boolean }`. */\nexport const COMBOS_DEVELOPMENT_TOOL_SET_MUTED =\n 'combos-development-tool:set-muted' as const;\n\n/** iframe → parent (and `game.emit`): current mute snapshot after a successful change. */\nexport const COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED =\n 'combos-development-tool:state-changed' as const;\n\nexport interface CombosSoundSetMutedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_SET_MUTED;\n muted: boolean;\n}\n\nexport interface CombosSoundStateChangedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED;\n muted: boolean;\n}\n\nexport function parseSetMutedMessage(data: unknown): boolean | null {\n if (!data || typeof data !== 'object') return null;\n const d = data as { type?: unknown; muted?: unknown };\n if (d.type !== COMBOS_DEVELOPMENT_TOOL_SET_MUTED) return null;\n if (typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nexport function parseSetMutedCustomEvent(event: Event): boolean | null {\n const d = (event as CustomEvent<{ muted?: unknown }>).detail;\n if (!d || typeof d !== 'object' || typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nfunction postToParent(payload: object, targetOrigin: string): void {\n if (typeof window === 'undefined') return;\n if (!window.parent || window.parent === window) return;\n try {\n window.parent.postMessage(payload, targetOrigin);\n } catch {\n /* ignore cross-origin or detached frame */\n }\n}\n\n/** Notifies the embedding page (and `game.emit`) of the current mute flag. */\nexport function postParentSoundMuted(\n muted: boolean,\n targetOrigin: string,\n emit?: (type: string, payload: { muted: boolean }) => void,\n): void {\n const state = { muted };\n postToParent({ type: COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, ...state }, targetOrigin);\n emit?.(COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, state);\n}\n","import {\n System,\n decorators,\n ComponentChanged,\n OBSERVER_TYPE,\n resource,\n isAllowedMessageOrigin,\n mergeAllowedMessageOrigins,\n} from '@combos-fun/engine';\nimport SoundComponent from './Sound';\nimport {\n COMBOS_DEVELOPMENT_TOOL_SET_MUTED,\n parseSetMutedCustomEvent,\n parseSetMutedMessage,\n postParentSoundMuted,\n} from './hostMessages';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError?: (error: any) => void;\n /** postMessage `targetOrigin` when notifying parent (default: Game `pluginInitNotifyTargetOrigin` or `'*'`). */\n postMessageOrigin?: string;\n /**\n * Extra inbound `postMessage` origins merged with engine defaults (`knoffice.tech`, `converge.ai`).\n * Each entry is a host suffix (e.g. `localhost`) or a full origin. Pass `['*']` to accept any origin.\n */\n allowedMessageOrigins?: string[];\n}\n\n@decorators.componentObserver({\n Sound: [],\n})\nclass SoundSystem extends System {\n static systemName = 'SoundSystem';\n\n private ctx: AudioContext;\n\n private gainNode: GainNode;\n\n /** Whether to pause/resume in sync with the game. */\n private autoPauseAndStart = true;\n\n private onError: (error: any) => void;\n\n private components: SoundComponent[] = [];\n\n private pausedComponents: SoundComponent[] = [];\n\n private audioBufferCache = {};\n\n private decodeAudioPromiseMap = {};\n\n /** Desired mute/volume are the source of truth; the gain node is derived. */\n private _muted = false;\n\n private _volume = 1;\n\n private postMessageOrigin = '*';\n\n private allowedMessageOrigins = mergeAllowedMessageOrigins();\n\n private hostMuteBound = false;\n\n get muted(): boolean {\n return this._muted;\n }\n\n set muted(v: boolean) {\n this.setMuted(v);\n }\n\n get volume(): number {\n return this._volume;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this._volume = v;\n this.applyGain();\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * Assigns `gain.value` directly rather than `setValueAtTime`: `.value` updates\n * the AudioParam's intrinsic value synchronously, so the `muted` / `volume`\n * getters reflect the change immediately. `setValueAtTime` only schedules an\n * event on the automation timeline and leaves `.value` stale until the next\n * render quantum, which made `muted` report the pre-change value.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this._muted ? 0 : this._volume;\n }\n\n get audioLocked(): boolean {\n if (!this.ctx) {\n return true;\n }\n return this.ctx.state !== 'running';\n }\n\n constructor(obj?: SoundSystemParams) {\n super(obj);\n if (!obj) return;\n if (typeof obj.autoPauseAndStart === 'boolean') {\n this.autoPauseAndStart = obj.autoPauseAndStart;\n }\n if (obj.onError) {\n this.onError = obj.onError;\n }\n }\n\n /**\n * Mute or unmute the master gain and notify the embedding host.\n * Same effect as `postMessage({ type: 'combos-development-tool:set-muted', muted })`.\n */\n setMuted(muted: boolean) {\n const next = !!muted;\n if (this._muted === next) {\n return;\n }\n this._muted = next;\n this.applyGain();\n this.postMuteStateChanged();\n }\n\n /**\n * Resume playback of all paused audio.\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * Pause all currently playing audio.\n */\n pauseAll() {\n this.components.forEach(component => {\n if (component.playing) {\n this.pausedComponents.push(component);\n component.pause();\n }\n });\n this.ctx.suspend().then();\n }\n\n /**\n * Stop all currently playing audio.\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System init: configure params before the game starts.\n */\n init(params?: SoundSystemParams) {\n this.postMessageOrigin =\n params?.postMessageOrigin ?? this.game?.pluginInitNotifyTargetOrigin ?? '*';\n this.allowedMessageOrigins = mergeAllowedMessageOrigins(params?.allowedMessageOrigins);\n this.bindHostMute();\n this.setupAudioContext();\n }\n\n update() {\n const changes = this.componentObserver.clear();\n for (const changed of changes) {\n this.componentChanged(changed);\n }\n }\n\n /**\n * Called when the game starts or resumes playing after a pause.\n */\n onResume() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * Called when the game is paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * Called when the system is destroyed.\n */\n onDestroy() {\n this.unbindHostMute();\n this.components.forEach(component => {\n component.onDestroy();\n });\n this.components = [];\n if (this.ctx) {\n this.gainNode.disconnect();\n this.gainNode = null;\n this.ctx.close();\n this.ctx = null;\n }\n }\n\n private readonly onWindowSetMuted = (e: Event) => {\n const muted = parseSetMutedCustomEvent(e);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private readonly onGameSetMuted = (payload: { muted?: boolean }) => {\n if (payload && typeof payload.muted === 'boolean') {\n this.setMuted(payload.muted);\n }\n };\n\n private readonly onWindowMessage = (e: MessageEvent) => {\n if (!isAllowedMessageOrigin(e.origin, this.allowedMessageOrigins)) {\n return;\n }\n const muted = parseSetMutedMessage(e.data);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private bindHostMute() {\n if (this.hostMuteBound) return;\n this.hostMuteBound = true;\n if (typeof window !== 'undefined') {\n window.addEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.addEventListener('message', this.onWindowMessage);\n }\n this.game.on(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private unbindHostMute() {\n if (!this.hostMuteBound) return;\n this.hostMuteBound = false;\n if (typeof window !== 'undefined') {\n window.removeEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.removeEventListener('message', this.onWindowMessage);\n }\n this.game?.off(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private postMuteStateChanged() {\n postParentSoundMuted(this._muted, this.postMessageOrigin, (type, payload) => {\n this.game?.emit(type, payload);\n });\n }\n\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.add(changed);\n }\n }\n\n private setupAudioContext() {\n try {\n const AudioContext = window.AudioContext || (window as any).webkitAudioContext;\n this.ctx = new AudioContext();\n } catch (error) {\n console.error(error);\n if (this.onError) {\n this.onError(error);\n }\n }\n\n if (!this.ctx) {\n return;\n }\n this.gainNode =\n typeof this.ctx.createGain === 'undefined' ? (this.ctx as any).createGainNode() : this.ctx.createGain();\n this.applyGain();\n this.gainNode.connect(this.ctx.destination);\n this.unlockAudio();\n }\n\n private unlockAudio() {\n if (!this.ctx || !this.audioLocked) {\n return;\n }\n\n const unlock = () => {\n if (this.ctx) {\n const removeListenerFn = () => {\n document.body.removeEventListener('touchstart', unlock);\n document.body.removeEventListener('touchend', unlock);\n document.body.removeEventListener('click', unlock);\n };\n this.ctx.resume().then(removeListenerFn, removeListenerFn);\n }\n };\n document.body.addEventListener('touchstart', unlock);\n document.body.addEventListener('touchend', unlock);\n document.body.addEventListener('click', unlock);\n }\n\n private async add(changed: ComponentChanged) {\n const component = changed.component as SoundComponent;\n this.components.push(component);\n try {\n const { config } = component;\n component.state = 'loading';\n\n const audio = await resource.getResource(config.resource);\n if (!this.audioBufferCache[audio.name] && audio?.data?.audio) {\n this.audioBufferCache[audio.name] = await this.decodeAudioData(audio.data.audio, audio.name);\n }\n if (this.audioBufferCache[audio.name]) {\n component.systemContext = this.ctx;\n component.systemDestination = this.gainNode;\n component.onload(this.audioBufferCache[audio.name]);\n }\n } catch (error) {\n if (this.onError) {\n this.onError(error);\n }\n }\n }\n\n private decodeAudioData(arraybuffer: ArrayBuffer, name: string) {\n if (this.decodeAudioPromiseMap[name]) {\n return this.decodeAudioPromiseMap[name];\n }\n\n const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\n }\n\n const success = (decodedData: AudioBuffer) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n if (decodedData) {\n resolve(decodedData);\n } else {\n reject(new Error(`Error decoding audio ${name}`));\n }\n };\n\n const error = (err: DOMException) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n reject(new Error(`${err}. arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n };\n\n const promise = this.ctx.decodeAudioData(arraybuffer, success, error)\n if (promise instanceof Promise) {\n promise.catch((err) => {\n reject(new Error(`catch ${err}, arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n });\n }\n });\n\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","/** Auto-generated by scripts/build-package.mjs — do not edit. */\n\nimport SoundSystem from './SoundSystem';\n\nObject.assign(SoundSystem, {\n packageName: \"@combos-fun/plugin-sound\",\n packageVersion: \"0.0.49\",\n});\n","import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface SoundParams {\n resource: string;\n autoplay?: boolean;\n muted?: boolean;\n volume?: number;\n loop?: boolean;\n seek?: number;\n duration?: number;\n onEnd?: () => void;\n}\n\nclass Sound extends Component<SoundParams> {\n static componentName = 'Sound';\n\n systemContext: AudioContext;\n\n systemDestination: GainNode;\n\n playing: boolean;\n\n state: 'unloaded' | 'loading' | 'loaded' = 'unloaded';\n\n config: SoundParams = {\n resource: '',\n autoplay: false,\n muted: false,\n volume: 1,\n loop: false,\n seek: 0,\n };\n\n private buffer: AudioBuffer;\n\n private sourceNode: AudioBufferSourceNode;\n\n private gainNode: GainNode;\n\n private paused: boolean;\n\n private playTime: number = 0;\n\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Muted',\n description: 'Silence this sound without changing its volume setting.',\n editor: 'toggle',\n })\n get muted(): boolean {\n return this.config.muted ?? false;\n }\n\n set muted(v: boolean) {\n this.config.muted = v;\n this.applyGain();\n }\n\n @Field({\n type: 'number',\n min: 0,\n max: 1,\n step: 0.01,\n group: 'Sound',\n label: 'Volume',\n description: 'Loudness of this sound from 0 (silent) to 1 (full).',\n editor: 'volume-slider',\n })\n get volume(): number {\n return this.config.volume ?? 1;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.config.volume = v;\n this.applyGain();\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Loop',\n description: 'Replay the sound continuously when it reaches the end.',\n editor: 'toggle',\n })\n get loop(): boolean {\n return this.config.loop ?? false;\n }\n\n set loop(v: boolean) {\n this.config.loop = v;\n if (this.sourceNode) {\n this.sourceNode.loop = v;\n }\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Autoplay',\n description: 'Start playing automatically once the audio has loaded.',\n editor: 'toggle',\n })\n get autoplay(): boolean {\n return this.config.autoplay ?? false;\n }\n\n set autoplay(v: boolean) {\n this.config.autoplay = v;\n }\n\n @Field({\n type: 'string',\n group: 'Sound',\n label: 'Resource',\n description: 'Audio resource id used by the sound system.',\n editor: 'text',\n })\n get resource(): string {\n return this.config.resource ?? '';\n }\n\n set resource(v: string) {\n this.config.resource = v;\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * `config` is the source of truth and the gain is assigned via `gain.value`\n * (updates the AudioParam intrinsic value synchronously) so the `muted` /\n * `volume` getters — and anything reading them back, e.g. the scene-edit\n * volume slider — reflect the change immediately. `setValueAtTime` only\n * schedules on the automation timeline and leaves `.value` stale.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this.config.muted ? 0 : (this.config.volume ?? 1);\n }\n\n init(obj?: SoundParams) {\n if (!obj) {\n return;\n }\n\n Object.assign(this.config, obj);\n if (this.config.autoplay) {\n this.actionQueue.push(this.play.bind(this));\n }\n }\n\n play() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.play.bind(this));\n }\n this.destroySource();\n this.createSource();\n\n if (!this.sourceNode) {\n return;\n }\n const when = this.systemContext.currentTime;\n const offset = this.config.seek;\n const duration = this.config.duration;\n\n this.sourceNode.start(0, offset, duration);\n\n this.startTime = when;\n this.playTime = when - offset;\n this.paused = false;\n this.playing = true;\n this.resetConfig();\n this.endedListener = () => {\n if (!this.sourceNode) {\n return;\n }\n if (this.config.onEnd) {\n this.config.onEnd();\n }\n // Release resources once non-interactive playback finishes.\n if (this.playing) {\n this.destroySource();\n }\n };\n this.sourceNode.addEventListener('ended', this.endedListener);\n }\n\n pause() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.pause.bind(this));\n }\n if (this.paused || !this.playing) {\n return;\n }\n this.paused = true;\n this.playing = false;\n this.config.seek = this.getCurrentTime();\n this.destroySource();\n }\n\n stop() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.stop.bind(this));\n }\n if (!this.paused && !this.playing) {\n return;\n }\n this.playing = false;\n this.paused = false;\n this.destroySource();\n this.resetConfig();\n }\n\n onload(buffer: AudioBuffer) {\n this.state = 'loaded';\n this.buffer = buffer;\n this.duration = this.buffer.duration;\n this.actionQueue.forEach(action => action());\n this.actionQueue.length = 0;\n }\n\n onDestroy() {\n this.actionQueue.length = 0;\n this.destroySource();\n }\n\n private resetConfig() {\n this.config.seek = 0;\n }\n\n private getCurrentTime() {\n if (this.config.loop && this.duration > 0) {\n return (this.systemContext.currentTime - this.playTime) % this.duration;\n }\n\n return this.systemContext.currentTime - this.playTime;\n }\n\n private createSource() {\n if (!this.systemContext || this.state !== 'loaded') {\n return;\n }\n this.sourceNode = this.systemContext.createBufferSource();\n this.sourceNode.buffer = this.buffer;\n this.sourceNode.loop = this.config.loop;\n\n if (!this.gainNode) {\n this.gainNode = this.systemContext.createGain();\n this.gainNode.connect(this.systemDestination);\n Object.assign(this, this.config);\n }\n this.sourceNode.connect(this.gainNode);\n }\n\n private destroySource() {\n if (!this.sourceNode) return;\n this.sourceNode.removeEventListener('ended', this.endedListener);\n this.sourceNode.stop();\n this.sourceNode.disconnect();\n this.sourceNode = null;\n\n this.startTime = 0;\n this.playTime = 0;\n this.playing = false;\n }\n}\n\nexport default Sound;\n"],"names":["SoundSystem","System","mergeAllowedMessageOrigins","isAllowedMessageOrigin","OBSERVER_TYPE","resource","__decorate","decorators","Component","Field"],"mappings":";;;;;;AAAA;AACO,MAAM,iCAAiC,GAC5C;AAEF;AACO,MAAM,qCAAqC,GAChD;AAYI,SAAU,oBAAoB,CAAC,IAAa,EAAA;AAChD,IAAA,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;IAClD,MAAM,CAAC,GAAG,IAA2C;AACrD,IAAA,IAAI,CAAC,CAAC,IAAI,KAAK,iCAAiC;AAAE,QAAA,OAAO,IAAI;AAC7D,IAAA,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;IAC7C,OAAO,CAAC,CAAC,KAAK;AAChB;AAEM,SAAU,wBAAwB,CAAC,KAAY,EAAA;AACnD,IAAA,MAAM,CAAC,GAAI,KAA0C,CAAC,MAAM;AAC5D,IAAA,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;IAC5E,OAAO,CAAC,CAAC,K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QAAA,KAAK,EAAE,OAAO;AACd,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,WAAW,EAAE,6CAA6C;AAC1D,QAAA,MAAM,EAAE,MAAM;KACf;AAGA,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"plugin-sound.cjs.js","sources":["../lib/hostMessages.ts","../lib/SoundSystem.ts","../lib/__combosPackageMeta.gen.ts","../lib/Sound.ts"],"sourcesContent":["/** Parent → iframe (also `window` CustomEvent / `game.emit`): mute or unmute. Payload: `{ muted: boolean }`. */\nexport const COMBOS_DEVELOPMENT_TOOL_SET_MUTED =\n 'combos-development-tool:set-muted' as const;\n\n/** iframe → parent (and `game.emit`): current mute snapshot after a successful change. */\nexport const COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED =\n 'combos-development-tool:state-changed' as const;\n\nexport interface CombosSoundSetMutedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_SET_MUTED;\n muted: boolean;\n}\n\nexport interface CombosSoundStateChangedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED;\n muted: boolean;\n}\n\nexport function parseSetMutedMessage(data: unknown): boolean | null {\n if (!data || typeof data !== 'object') return null;\n const d = data as { type?: unknown; muted?: unknown };\n if (d.type !== COMBOS_DEVELOPMENT_TOOL_SET_MUTED) return null;\n if (typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nexport function parseSetMutedCustomEvent(event: Event): boolean | null {\n const d = (event as CustomEvent<{ muted?: unknown }>).detail;\n if (!d || typeof d !== 'object' || typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nfunction postToParent(payload: object, targetOrigin: string): void {\n if (typeof window === 'undefined') return;\n if (!window.parent || window.parent === window) return;\n try {\n window.parent.postMessage(payload, targetOrigin);\n } catch {\n /* ignore cross-origin or detached frame */\n }\n}\n\n/** Notifies the embedding page (and `game.emit`) of the current mute flag. */\nexport function postParentSoundMuted(\n muted: boolean,\n targetOrigin: string,\n emit?: (type: string, payload: { muted: boolean }) => void,\n): void {\n const state = { muted };\n postToParent({ type: COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, ...state }, targetOrigin);\n emit?.(COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, state);\n}\n","import {\n System,\n decorators,\n ComponentChanged,\n OBSERVER_TYPE,\n resource,\n isAllowedMessageOrigin,\n mergeAllowedMessageOrigins,\n} from '@combos-fun/engine';\nimport SoundComponent from './Sound';\nimport {\n COMBOS_DEVELOPMENT_TOOL_SET_MUTED,\n parseSetMutedCustomEvent,\n parseSetMutedMessage,\n postParentSoundMuted,\n} from './hostMessages';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError?: (error: any) => void;\n /** postMessage `targetOrigin` when notifying parent (default: Game `pluginInitNotifyTargetOrigin` or `'*'`). */\n postMessageOrigin?: string;\n /**\n * Extra inbound `postMessage` origins merged with engine defaults (`knoffice.tech`, `converge.ai`).\n * Each entry is a host suffix (e.g. `localhost`) or a full origin. Pass `['*']` to accept any origin.\n */\n allowedMessageOrigins?: string[];\n}\n\n@decorators.componentObserver({\n Sound: [],\n})\nclass SoundSystem extends System {\n static systemName = 'SoundSystem';\n\n private ctx: AudioContext;\n\n private gainNode: GainNode;\n\n /** Whether to pause/resume in sync with the game. */\n private autoPauseAndStart = true;\n\n private onError: (error: any) => void;\n\n private components: SoundComponent[] = [];\n\n private pausedComponents: SoundComponent[] = [];\n\n private audioBufferCache = {};\n\n private decodeAudioPromiseMap = {};\n\n /** Desired mute/volume are the source of truth; the gain node is derived. */\n private _muted = false;\n\n private _volume = 1;\n\n private postMessageOrigin = '*';\n\n private allowedMessageOrigins = mergeAllowedMessageOrigins();\n\n private hostMuteBound = false;\n\n get muted(): boolean {\n return this._muted;\n }\n\n set muted(v: boolean) {\n this.setMuted(v);\n }\n\n get volume(): number {\n return this._volume;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this._volume = v;\n this.applyGain();\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * Assigns `gain.value` directly rather than `setValueAtTime`: `.value` updates\n * the AudioParam's intrinsic value synchronously, so the `muted` / `volume`\n * getters reflect the change immediately. `setValueAtTime` only schedules an\n * event on the automation timeline and leaves `.value` stale until the next\n * render quantum, which made `muted` report the pre-change value.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this._muted ? 0 : this._volume;\n }\n\n get audioLocked(): boolean {\n if (!this.ctx) {\n return true;\n }\n return this.ctx.state !== 'running';\n }\n\n constructor(obj?: SoundSystemParams) {\n super(obj);\n if (!obj) return;\n if (typeof obj.autoPauseAndStart === 'boolean') {\n this.autoPauseAndStart = obj.autoPauseAndStart;\n }\n if (obj.onError) {\n this.onError = obj.onError;\n }\n }\n\n /**\n * Mute or unmute the master gain and notify the embedding host.\n * Same effect as `postMessage({ type: 'combos-development-tool:set-muted', muted })`.\n */\n setMuted(muted: boolean) {\n const next = !!muted;\n if (this._muted === next) {\n return;\n }\n this._muted = next;\n this.applyGain();\n this.postMuteStateChanged();\n }\n\n /**\n * Resume playback of all paused audio.\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * Pause all currently playing audio.\n */\n pauseAll() {\n this.components.forEach(component => {\n if (component.playing) {\n this.pausedComponents.push(component);\n component.pause();\n }\n });\n this.ctx.suspend().then();\n }\n\n /**\n * Stop all currently playing audio.\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System init: configure params before the game starts.\n */\n init(params?: SoundSystemParams) {\n this.postMessageOrigin =\n params?.postMessageOrigin ?? this.game?.pluginInitNotifyTargetOrigin ?? '*';\n this.allowedMessageOrigins = mergeAllowedMessageOrigins(params?.allowedMessageOrigins);\n this.bindHostMute();\n this.setupAudioContext();\n }\n\n update() {\n const changes = this.componentObserver.clear();\n for (const changed of changes) {\n this.componentChanged(changed);\n }\n }\n\n /**\n * Called when the game starts or resumes playing after a pause.\n */\n onResume() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * Called when the game is paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * Called when the system is destroyed.\n */\n onDestroy() {\n this.unbindHostMute();\n this.components.forEach(component => {\n component.onDestroy();\n });\n this.components = [];\n if (this.ctx) {\n this.gainNode.disconnect();\n this.gainNode = null;\n this.ctx.close();\n this.ctx = null;\n }\n }\n\n private readonly onWindowSetMuted = (e: Event) => {\n const muted = parseSetMutedCustomEvent(e);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private readonly onGameSetMuted = (payload: { muted?: boolean }) => {\n if (payload && typeof payload.muted === 'boolean') {\n this.setMuted(payload.muted);\n }\n };\n\n private readonly onWindowMessage = (e: MessageEvent) => {\n if (!isAllowedMessageOrigin(e.origin, this.allowedMessageOrigins)) {\n return;\n }\n const muted = parseSetMutedMessage(e.data);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private bindHostMute() {\n if (this.hostMuteBound) return;\n this.hostMuteBound = true;\n if (typeof window !== 'undefined') {\n window.addEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.addEventListener('message', this.onWindowMessage);\n }\n this.game.on(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private unbindHostMute() {\n if (!this.hostMuteBound) return;\n this.hostMuteBound = false;\n if (typeof window !== 'undefined') {\n window.removeEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.removeEventListener('message', this.onWindowMessage);\n }\n this.game?.off(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private postMuteStateChanged() {\n postParentSoundMuted(this._muted, this.postMessageOrigin, (type, payload) => {\n this.game?.emit(type, payload);\n });\n }\n\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.add(changed);\n }\n }\n\n private setupAudioContext() {\n try {\n const AudioContext = window.AudioContext || (window as any).webkitAudioContext;\n this.ctx = new AudioContext();\n } catch (error) {\n console.error(error);\n if (this.onError) {\n this.onError(error);\n }\n }\n\n if (!this.ctx) {\n return;\n }\n this.gainNode =\n typeof this.ctx.createGain === 'undefined' ? (this.ctx as any).createGainNode() : this.ctx.createGain();\n this.applyGain();\n this.gainNode.connect(this.ctx.destination);\n this.unlockAudio();\n }\n\n private unlockAudio() {\n if (!this.ctx || !this.audioLocked) {\n return;\n }\n\n const unlock = () => {\n if (this.ctx) {\n const removeListenerFn = () => {\n document.body.removeEventListener('touchstart', unlock);\n document.body.removeEventListener('touchend', unlock);\n document.body.removeEventListener('click', unlock);\n };\n this.ctx.resume().then(removeListenerFn, removeListenerFn);\n }\n };\n document.body.addEventListener('touchstart', unlock);\n document.body.addEventListener('touchend', unlock);\n document.body.addEventListener('click', unlock);\n }\n\n private async add(changed: ComponentChanged) {\n const component = changed.component as SoundComponent;\n this.components.push(component);\n try {\n const { config } = component;\n component.state = 'loading';\n\n const audio = await resource.getResource(config.resource);\n if (!this.audioBufferCache[audio.name] && audio?.data?.audio) {\n this.audioBufferCache[audio.name] = await this.decodeAudioData(audio.data.audio, audio.name);\n }\n if (this.audioBufferCache[audio.name]) {\n component.systemContext = this.ctx;\n component.systemDestination = this.gainNode;\n component.onload(this.audioBufferCache[audio.name]);\n }\n } catch (error) {\n if (this.onError) {\n this.onError(error);\n }\n }\n }\n\n private decodeAudioData(arraybuffer: ArrayBuffer, name: string) {\n if (this.decodeAudioPromiseMap[name]) {\n return this.decodeAudioPromiseMap[name];\n }\n\n const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\n }\n\n const success = (decodedData: AudioBuffer) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n if (decodedData) {\n resolve(decodedData);\n } else {\n reject(new Error(`Error decoding audio ${name}`));\n }\n };\n\n const error = (err: DOMException) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n reject(new Error(`${err}. arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n };\n\n const promise = this.ctx.decodeAudioData(arraybuffer, success, error)\n if (promise instanceof Promise) {\n promise.catch((err) => {\n reject(new Error(`catch ${err}, arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n });\n }\n });\n\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","/** Auto-generated by scripts/build-package.mjs — do not edit. */\n\nimport SoundSystem from './SoundSystem';\n\nObject.assign(SoundSystem, {\n packageName: \"@combos-fun/plugin-sound\",\n packageVersion: \"0.0.51\",\n});\n","import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface SoundParams {\n resource: string;\n autoplay?: boolean;\n muted?: boolean;\n volume?: number;\n loop?: boolean;\n seek?: number;\n duration?: number;\n onEnd?: () => void;\n}\n\nclass Sound extends Component<SoundParams> {\n static componentName = 'Sound';\n\n systemContext: AudioContext;\n\n systemDestination: GainNode;\n\n playing: boolean;\n\n state: 'unloaded' | 'loading' | 'loaded' = 'unloaded';\n\n config: SoundParams = {\n resource: '',\n autoplay: false,\n muted: false,\n volume: 1,\n loop: false,\n seek: 0,\n };\n\n private buffer: AudioBuffer;\n\n private sourceNode: AudioBufferSourceNode;\n\n private gainNode: GainNode;\n\n private paused: boolean;\n\n private playTime: number = 0;\n\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Muted',\n description: 'Silence this sound without changing its volume setting.',\n editor: 'toggle',\n })\n get muted(): boolean {\n return this.config.muted ?? false;\n }\n\n set muted(v: boolean) {\n this.config.muted = v;\n this.applyGain();\n }\n\n @Field({\n type: 'number',\n min: 0,\n max: 1,\n step: 0.01,\n group: 'Sound',\n label: 'Volume',\n description: 'Loudness of this sound from 0 (silent) to 1 (full).',\n editor: 'volume-slider',\n })\n get volume(): number {\n return this.config.volume ?? 1;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.config.volume = v;\n this.applyGain();\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Loop',\n description: 'Replay the sound continuously when it reaches the end.',\n editor: 'toggle',\n })\n get loop(): boolean {\n return this.config.loop ?? false;\n }\n\n set loop(v: boolean) {\n this.config.loop = v;\n if (this.sourceNode) {\n this.sourceNode.loop = v;\n }\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Autoplay',\n description: 'Start playing automatically once the audio has loaded.',\n editor: 'toggle',\n })\n get autoplay(): boolean {\n return this.config.autoplay ?? false;\n }\n\n set autoplay(v: boolean) {\n this.config.autoplay = v;\n }\n\n @Field({\n type: 'string',\n group: 'Sound',\n label: 'Resource',\n description: 'Audio resource id used by the sound system.',\n editor: 'text',\n })\n get resource(): string {\n return this.config.resource ?? '';\n }\n\n set resource(v: string) {\n this.config.resource = v;\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * `config` is the source of truth and the gain is assigned via `gain.value`\n * (updates the AudioParam intrinsic value synchronously) so the `muted` /\n * `volume` getters — and anything reading them back, e.g. the scene-edit\n * volume slider — reflect the change immediately. `setValueAtTime` only\n * schedules on the automation timeline and leaves `.value` stale.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this.config.muted ? 0 : (this.config.volume ?? 1);\n }\n\n init(obj?: SoundParams) {\n if (!obj) {\n return;\n }\n\n Object.assign(this.config, obj);\n if (this.config.autoplay) {\n this.actionQueue.push(this.play.bind(this));\n }\n }\n\n play() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.play.bind(this));\n }\n this.destroySource();\n this.createSource();\n\n if (!this.sourceNode) {\n return;\n }\n const when = this.systemContext.currentTime;\n const offset = this.config.seek;\n const duration = this.config.duration;\n\n this.sourceNode.start(0, offset, duration);\n\n this.startTime = when;\n this.playTime = when - offset;\n this.paused = false;\n this.playing = true;\n this.resetConfig();\n this.endedListener = () => {\n if (!this.sourceNode) {\n return;\n }\n if (this.config.onEnd) {\n this.config.onEnd();\n }\n // Release resources once non-interactive playback finishes.\n if (this.playing) {\n this.destroySource();\n }\n };\n this.sourceNode.addEventListener('ended', this.endedListener);\n }\n\n pause() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.pause.bind(this));\n }\n if (this.paused || !this.playing) {\n return;\n }\n this.paused = true;\n this.playing = false;\n this.config.seek = this.getCurrentTime();\n this.destroySource();\n }\n\n stop() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.stop.bind(this));\n }\n if (!this.paused && !this.playing) {\n return;\n }\n this.playing = false;\n this.paused = false;\n this.destroySource();\n this.resetConfig();\n }\n\n onload(buffer: AudioBuffer) {\n this.state = 'loaded';\n this.buffer = buffer;\n this.duration = this.buffer.duration;\n this.actionQueue.forEach(action => action());\n this.actionQueue.length = 0;\n }\n\n onDestroy() {\n this.actionQueue.length = 0;\n this.destroySource();\n }\n\n private resetConfig() {\n this.config.seek = 0;\n }\n\n private getCurrentTime() {\n if (this.config.loop && this.duration > 0) {\n return (this.systemContext.currentTime - this.playTime) % this.duration;\n }\n\n return this.systemContext.currentTime - this.playTime;\n }\n\n private createSource() {\n if (!this.systemContext || this.state !== 'loaded') {\n return;\n }\n this.sourceNode = this.systemContext.createBufferSource();\n this.sourceNode.buffer = this.buffer;\n this.sourceNode.loop = this.config.loop;\n\n if (!this.gainNode) {\n this.gainNode = this.systemContext.createGain();\n this.gainNode.connect(this.systemDestination);\n Object.assign(this, this.config);\n }\n this.sourceNode.connect(this.gainNode);\n }\n\n private destroySource() {\n if (!this.sourceNode) return;\n this.sourceNode.removeEventListener('ended', this.endedListener);\n this.sourceNode.stop();\n this.sourceNode.disconnect();\n this.sourceNode = null;\n\n this.startTime = 0;\n this.playTime = 0;\n this.playing = false;\n }\n}\n\nexport default Sound;\n"],"names":["SoundSystem","System","mergeAllowedMessageOrigins","isAllowedMessageOrigin","OBSERVER_TYPE","resource","__decorate","decorators","Component","Field"],"mappings":";;;;;;AAAA;AACO,MAAM,iCAAiC,GAC5C;AAEF;AACO,MAAM,qCAAqC,GAChD;AAYI,SAAU,oBAAoB,CAAC,IAAa,EAAA;AAChD,IAAA,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;IAClD,MAAM,CAAC,GAAG,IAA2C;AACrD,IAAA,IAAI,CAAC,CAAC,IAAI,KAAK,iCAAiC;AAAE,QAAA,OAAO,IAAI;AAC7D,IAAA,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;IAC7C,OAAO,CAAC,CAAC,KAAK;AAChB;AAEM,SAAU,wBAAwB,CAAC,KAAY,EAAA;AACnD,IAAA,MAAM,CAAC,GAAI,KAA0C,CAAC,MAAM;AAC5D,IAAA,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;IAC5E,OAAO,CAAC,CAAC,KAAK;AAChB;AAEA,SAAS,YAAY,CAAC,OAAe,EAAE,YAAoB,EAAA;IACzD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE;IACnC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI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A,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA;;;;;;;;;"}
@@ -1 +1 @@
1
- "use strict";var t=require("tslib"),e=require("@combos-fun/engine"),o=require("@combos-fun/inspector-decorator");const s="combos-development-tool:set-muted",i="combos-development-tool:state-changed";function n(t){if(!t||"object"!=typeof t)return null;const e=t;return e.type!==s||"boolean"!=typeof e.muted?null:e.muted}function u(t,e,o){const s={muted:t};!function(t,e){if("undefined"!=typeof window&&window.parent&&window.parent!==window)try{window.parent.postMessage(t,e)}catch{}}({type:i,...s},e),o?.(i,s)}let d=class extends e.System{static{this.systemName="SoundSystem"}get muted(){return this._muted}set muted(t){this.setMuted(t)}get volume(){return this._volume}set volume(t){"number"!=typeof t||t<0||t>1||(this._volume=t,this.applyGain())}applyGain(){this.gainNode&&(this.gainNode.gain.value=this._muted?0:this._volume)}get audioLocked(){return!this.ctx||"running"!==this.ctx.state}constructor(t){super(t),this.autoPauseAndStart=!0,this.components=[],this.pausedComponents=[],this.audioBufferCache={},this.decodeAudioPromiseMap={},this._muted=!1,this._volume=1,this.postMessageOrigin="*",this.allowedMessageOrigins=e.mergeAllowedMessageOrigins(),this.hostMuteBound=!1,this.onWindowSetMuted=t=>{const e=function(t){const e=t.detail;return e&&"object"==typeof e&&"boolean"==typeof e.muted?e.muted:null}(t);null!==e&&this.setMuted(e)},this.onGameSetMuted=t=>{t&&"boolean"==typeof t.muted&&this.setMuted(t.muted)},this.onWindowMessage=t=>{if(!e.isAllowedMessageOrigin(t.origin,this.allowedMessageOrigins))return;const o=n(t.data);null!==o&&this.setMuted(o)},t&&("boolean"==typeof t.autoPauseAndStart&&(this.autoPauseAndStart=t.autoPauseAndStart),t.onError&&(this.onError=t.onError))}setMuted(t){const e=!!t;this._muted!==e&&(this._muted=e,this.applyGain(),this.postMuteStateChanged())}resumeAll(){const t=()=>{this.pausedComponents.forEach(t=>{t.play()}),this.pausedComponents=[]};this.ctx.resume().then(t,t)}pauseAll(){this.components.forEach(t=>{t.playing&&(this.pausedComponents.push(t),t.pause())}),this.ctx.suspend().then()}stopAll(){this.components.forEach(t=>{t.playing&&t.stop()}),this.pausedComponents=[],this.ctx.suspend().then()}init(t){this.postMessageOrigin=t?.postMessageOrigin??this.game?.pluginInitNotifyTargetOrigin??"*",this.allowedMessageOrigins=e.mergeAllowedMessageOrigins(t?.allowedMessageOrigins),this.bindHostMute(),this.setupAudioContext()}update(){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}onResume(){this.autoPauseAndStart&&this.resumeAll()}onPause(){this.autoPauseAndStart&&this.pauseAll()}onDestroy(){this.unbindHostMute(),this.components.forEach(t=>{t.onDestroy()}),this.components=[],this.ctx&&(this.gainNode.disconnect(),this.gainNode=null,this.ctx.close(),this.ctx=null)}bindHostMute(){this.hostMuteBound||(this.hostMuteBound=!0,"undefined"!=typeof window&&(window.addEventListener(s,this.onWindowSetMuted),window.addEventListener("message",this.onWindowMessage)),this.game.on(s,this.onGameSetMuted))}unbindHostMute(){this.hostMuteBound&&(this.hostMuteBound=!1,"undefined"!=typeof window&&(window.removeEventListener(s,this.onWindowSetMuted),window.removeEventListener("message",this.onWindowMessage)),this.game?.off(s,this.onGameSetMuted))}postMuteStateChanged(){u(this._muted,this.postMessageOrigin,(t,e)=>{this.game?.emit(t,e)})}async componentChanged(t){"Sound"===t.componentName&&t.type===e.OBSERVER_TYPE.ADD&&this.add(t)}setupAudioContext(){try{const t=window.AudioContext||window.webkitAudioContext;this.ctx=new t}catch(t){console.error(t),this.onError&&this.onError(t)}this.ctx&&(this.gainNode=void 0===this.ctx.createGain?this.ctx.createGainNode():this.ctx.createGain(),this.applyGain(),this.gainNode.connect(this.ctx.destination),this.unlockAudio())}unlockAudio(){if(!this.ctx||!this.audioLocked)return;const t=()=>{if(this.ctx){const e=()=>{document.body.removeEventListener("touchstart",t),document.body.removeEventListener("touchend",t),document.body.removeEventListener("click",t)};this.ctx.resume().then(e,e)}};document.body.addEventListener("touchstart",t),document.body.addEventListener("touchend",t),document.body.addEventListener("click",t)}async add(t){const o=t.component;this.components.push(o);try{const{config:t}=o;o.state="loading";const s=await e.resource.getResource(t.resource);!this.audioBufferCache[s.name]&&s?.data?.audio&&(this.audioBufferCache[s.name]=await this.decodeAudioData(s.data.audio,s.name)),this.audioBufferCache[s.name]&&(o.systemContext=this.ctx,o.systemDestination=this.gainNode,o.onload(this.audioBufferCache[s.name]))}catch(t){this.onError&&this.onError(t)}}decodeAudioData(t,e){if(this.decodeAudioPromiseMap[e])return this.decodeAudioPromiseMap[e];const o=new Promise((o,s)=>{this.ctx||s(new Error("No audio support"));const i=this.ctx.decodeAudioData(t,t=>{this.decodeAudioPromiseMap[e]&&delete this.decodeAudioPromiseMap[e],t?o(t):s(new Error(`Error decoding audio ${e}`))},o=>{this.decodeAudioPromiseMap[e]&&delete this.decodeAudioPromiseMap[e],s(new Error(`${o}. arrayBuffer byteLength: ${t?t.byteLength:0}`))});i instanceof Promise&&i.catch(e=>{s(new Error(`catch ${e}, arrayBuffer byteLength: ${t?t.byteLength:0}`))})});return this.decodeAudioPromiseMap[e]=o,o}};d=t.__decorate([e.decorators.componentObserver({Sound:[]})],d);var a=d;Object.assign(a,{packageName:"@combos-fun/plugin-sound",packageVersion:"0.0.49"});class r extends e.Component{constructor(){super(...arguments),this.state="unloaded",this.config={resource:"",autoplay:!1,muted:!1,volume:1,loop:!1,seek:0},this.playTime=0,this.startTime=0,this.duration=0,this.actionQueue=[]}static{this.componentName="Sound"}get muted(){return this.config.muted??!1}set muted(t){this.config.muted=t,this.applyGain()}get volume(){return this.config.volume??1}set volume(t){"number"!=typeof t||t<0||t>1||(this.config.volume=t,this.applyGain())}get loop(){return this.config.loop??!1}set loop(t){this.config.loop=t,this.sourceNode&&(this.sourceNode.loop=t)}get autoplay(){return this.config.autoplay??!1}set autoplay(t){this.config.autoplay=t}get resource(){return this.config.resource??""}set resource(t){this.config.resource=t}applyGain(){this.gainNode&&(this.gainNode.gain.value=this.config.muted?0:this.config.volume??1)}init(t){t&&(Object.assign(this.config,t),this.config.autoplay&&this.actionQueue.push(this.play.bind(this)))}play(){if("loaded"!==this.state&&this.actionQueue.push(this.play.bind(this)),this.destroySource(),this.createSource(),!this.sourceNode)return;const t=this.systemContext.currentTime,e=this.config.seek,o=this.config.duration;this.sourceNode.start(0,e,o),this.startTime=t,this.playTime=t-e,this.paused=!1,this.playing=!0,this.resetConfig(),this.endedListener=()=>{this.sourceNode&&(this.config.onEnd&&this.config.onEnd(),this.playing&&this.destroySource())},this.sourceNode.addEventListener("ended",this.endedListener)}pause(){"loaded"!==this.state&&this.actionQueue.push(this.pause.bind(this)),!this.paused&&this.playing&&(this.paused=!0,this.playing=!1,this.config.seek=this.getCurrentTime(),this.destroySource())}stop(){"loaded"!==this.state&&this.actionQueue.push(this.stop.bind(this)),(this.paused||this.playing)&&(this.playing=!1,this.paused=!1,this.destroySource(),this.resetConfig())}onload(t){this.state="loaded",this.buffer=t,this.duration=this.buffer.duration,this.actionQueue.forEach(t=>t()),this.actionQueue.length=0}onDestroy(){this.actionQueue.length=0,this.destroySource()}resetConfig(){this.config.seek=0}getCurrentTime(){return this.config.loop&&this.duration>0?(this.systemContext.currentTime-this.playTime)%this.duration:this.systemContext.currentTime-this.playTime}createSource(){this.systemContext&&"loaded"===this.state&&(this.sourceNode=this.systemContext.createBufferSource(),this.sourceNode.buffer=this.buffer,this.sourceNode.loop=this.config.loop,this.gainNode||(this.gainNode=this.systemContext.createGain(),this.gainNode.connect(this.systemDestination),Object.assign(this,this.config)),this.sourceNode.connect(this.gainNode))}destroySource(){this.sourceNode&&(this.sourceNode.removeEventListener("ended",this.endedListener),this.sourceNode.stop(),this.sourceNode.disconnect(),this.sourceNode=null,this.startTime=0,this.playTime=0,this.playing=!1)}}t.__decorate([o.Field({type:"boolean",group:"Sound",label:"Muted",description:"Silence this sound without changing its volume setting.",editor:"toggle"})],r.prototype,"muted",null),t.__decorate([o.Field({type:"number",min:0,max:1,step:.01,group:"Sound",label:"Volume",description:"Loudness of this sound from 0 (silent) to 1 (full).",editor:"volume-slider"})],r.prototype,"volume",null),t.__decorate([o.Field({type:"boolean",group:"Sound",label:"Loop",description:"Replay the sound continuously when it reaches the end.",editor:"toggle"})],r.prototype,"loop",null),t.__decorate([o.Field({type:"boolean",group:"Sound",label:"Autoplay",description:"Start playing automatically once the audio has loaded.",editor:"toggle"})],r.prototype,"autoplay",null),t.__decorate([o.Field({type:"string",group:"Sound",label:"Resource",description:"Audio resource id used by the sound system.",editor:"text"})],r.prototype,"resource",null),exports.COMBOS_DEVELOPMENT_TOOL_SET_MUTED=s,exports.COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED=i,exports.Sound=r,exports.SoundSystem=a,exports.parseSetMutedMessage=n,exports.postParentSoundMuted=u;
1
+ "use strict";var t=require("tslib"),e=require("@combos-fun/engine"),o=require("@combos-fun/inspector-decorator");const s="combos-development-tool:set-muted",i="combos-development-tool:state-changed";function n(t){if(!t||"object"!=typeof t)return null;const e=t;return e.type!==s||"boolean"!=typeof e.muted?null:e.muted}function u(t,e,o){const s={muted:t};!function(t,e){if("undefined"!=typeof window&&window.parent&&window.parent!==window)try{window.parent.postMessage(t,e)}catch{}}({type:i,...s},e),o?.(i,s)}let d=class extends e.System{static{this.systemName="SoundSystem"}get muted(){return this._muted}set muted(t){this.setMuted(t)}get volume(){return this._volume}set volume(t){"number"!=typeof t||t<0||t>1||(this._volume=t,this.applyGain())}applyGain(){this.gainNode&&(this.gainNode.gain.value=this._muted?0:this._volume)}get audioLocked(){return!this.ctx||"running"!==this.ctx.state}constructor(t){super(t),this.autoPauseAndStart=!0,this.components=[],this.pausedComponents=[],this.audioBufferCache={},this.decodeAudioPromiseMap={},this._muted=!1,this._volume=1,this.postMessageOrigin="*",this.allowedMessageOrigins=e.mergeAllowedMessageOrigins(),this.hostMuteBound=!1,this.onWindowSetMuted=t=>{const e=function(t){const e=t.detail;return e&&"object"==typeof e&&"boolean"==typeof e.muted?e.muted:null}(t);null!==e&&this.setMuted(e)},this.onGameSetMuted=t=>{t&&"boolean"==typeof t.muted&&this.setMuted(t.muted)},this.onWindowMessage=t=>{if(!e.isAllowedMessageOrigin(t.origin,this.allowedMessageOrigins))return;const o=n(t.data);null!==o&&this.setMuted(o)},t&&("boolean"==typeof t.autoPauseAndStart&&(this.autoPauseAndStart=t.autoPauseAndStart),t.onError&&(this.onError=t.onError))}setMuted(t){const e=!!t;this._muted!==e&&(this._muted=e,this.applyGain(),this.postMuteStateChanged())}resumeAll(){const t=()=>{this.pausedComponents.forEach(t=>{t.play()}),this.pausedComponents=[]};this.ctx.resume().then(t,t)}pauseAll(){this.components.forEach(t=>{t.playing&&(this.pausedComponents.push(t),t.pause())}),this.ctx.suspend().then()}stopAll(){this.components.forEach(t=>{t.playing&&t.stop()}),this.pausedComponents=[],this.ctx.suspend().then()}init(t){this.postMessageOrigin=t?.postMessageOrigin??this.game?.pluginInitNotifyTargetOrigin??"*",this.allowedMessageOrigins=e.mergeAllowedMessageOrigins(t?.allowedMessageOrigins),this.bindHostMute(),this.setupAudioContext()}update(){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}onResume(){this.autoPauseAndStart&&this.resumeAll()}onPause(){this.autoPauseAndStart&&this.pauseAll()}onDestroy(){this.unbindHostMute(),this.components.forEach(t=>{t.onDestroy()}),this.components=[],this.ctx&&(this.gainNode.disconnect(),this.gainNode=null,this.ctx.close(),this.ctx=null)}bindHostMute(){this.hostMuteBound||(this.hostMuteBound=!0,"undefined"!=typeof window&&(window.addEventListener(s,this.onWindowSetMuted),window.addEventListener("message",this.onWindowMessage)),this.game.on(s,this.onGameSetMuted))}unbindHostMute(){this.hostMuteBound&&(this.hostMuteBound=!1,"undefined"!=typeof window&&(window.removeEventListener(s,this.onWindowSetMuted),window.removeEventListener("message",this.onWindowMessage)),this.game?.off(s,this.onGameSetMuted))}postMuteStateChanged(){u(this._muted,this.postMessageOrigin,(t,e)=>{this.game?.emit(t,e)})}async componentChanged(t){"Sound"===t.componentName&&t.type===e.OBSERVER_TYPE.ADD&&this.add(t)}setupAudioContext(){try{const t=window.AudioContext||window.webkitAudioContext;this.ctx=new t}catch(t){console.error(t),this.onError&&this.onError(t)}this.ctx&&(this.gainNode=void 0===this.ctx.createGain?this.ctx.createGainNode():this.ctx.createGain(),this.applyGain(),this.gainNode.connect(this.ctx.destination),this.unlockAudio())}unlockAudio(){if(!this.ctx||!this.audioLocked)return;const t=()=>{if(this.ctx){const e=()=>{document.body.removeEventListener("touchstart",t),document.body.removeEventListener("touchend",t),document.body.removeEventListener("click",t)};this.ctx.resume().then(e,e)}};document.body.addEventListener("touchstart",t),document.body.addEventListener("touchend",t),document.body.addEventListener("click",t)}async add(t){const o=t.component;this.components.push(o);try{const{config:t}=o;o.state="loading";const s=await e.resource.getResource(t.resource);!this.audioBufferCache[s.name]&&s?.data?.audio&&(this.audioBufferCache[s.name]=await this.decodeAudioData(s.data.audio,s.name)),this.audioBufferCache[s.name]&&(o.systemContext=this.ctx,o.systemDestination=this.gainNode,o.onload(this.audioBufferCache[s.name]))}catch(t){this.onError&&this.onError(t)}}decodeAudioData(t,e){if(this.decodeAudioPromiseMap[e])return this.decodeAudioPromiseMap[e];const o=new Promise((o,s)=>{this.ctx||s(new Error("No audio support"));const i=this.ctx.decodeAudioData(t,t=>{this.decodeAudioPromiseMap[e]&&delete this.decodeAudioPromiseMap[e],t?o(t):s(new Error(`Error decoding audio ${e}`))},o=>{this.decodeAudioPromiseMap[e]&&delete this.decodeAudioPromiseMap[e],s(new Error(`${o}. arrayBuffer byteLength: ${t?t.byteLength:0}`))});i instanceof Promise&&i.catch(e=>{s(new Error(`catch ${e}, arrayBuffer byteLength: ${t?t.byteLength:0}`))})});return this.decodeAudioPromiseMap[e]=o,o}};d=t.__decorate([e.decorators.componentObserver({Sound:[]})],d);var a=d;Object.assign(a,{packageName:"@combos-fun/plugin-sound",packageVersion:"0.0.51"});class r extends e.Component{constructor(){super(...arguments),this.state="unloaded",this.config={resource:"",autoplay:!1,muted:!1,volume:1,loop:!1,seek:0},this.playTime=0,this.startTime=0,this.duration=0,this.actionQueue=[]}static{this.componentName="Sound"}get muted(){return this.config.muted??!1}set muted(t){this.config.muted=t,this.applyGain()}get volume(){return this.config.volume??1}set volume(t){"number"!=typeof t||t<0||t>1||(this.config.volume=t,this.applyGain())}get loop(){return this.config.loop??!1}set loop(t){this.config.loop=t,this.sourceNode&&(this.sourceNode.loop=t)}get autoplay(){return this.config.autoplay??!1}set autoplay(t){this.config.autoplay=t}get resource(){return this.config.resource??""}set resource(t){this.config.resource=t}applyGain(){this.gainNode&&(this.gainNode.gain.value=this.config.muted?0:this.config.volume??1)}init(t){t&&(Object.assign(this.config,t),this.config.autoplay&&this.actionQueue.push(this.play.bind(this)))}play(){if("loaded"!==this.state&&this.actionQueue.push(this.play.bind(this)),this.destroySource(),this.createSource(),!this.sourceNode)return;const t=this.systemContext.currentTime,e=this.config.seek,o=this.config.duration;this.sourceNode.start(0,e,o),this.startTime=t,this.playTime=t-e,this.paused=!1,this.playing=!0,this.resetConfig(),this.endedListener=()=>{this.sourceNode&&(this.config.onEnd&&this.config.onEnd(),this.playing&&this.destroySource())},this.sourceNode.addEventListener("ended",this.endedListener)}pause(){"loaded"!==this.state&&this.actionQueue.push(this.pause.bind(this)),!this.paused&&this.playing&&(this.paused=!0,this.playing=!1,this.config.seek=this.getCurrentTime(),this.destroySource())}stop(){"loaded"!==this.state&&this.actionQueue.push(this.stop.bind(this)),(this.paused||this.playing)&&(this.playing=!1,this.paused=!1,this.destroySource(),this.resetConfig())}onload(t){this.state="loaded",this.buffer=t,this.duration=this.buffer.duration,this.actionQueue.forEach(t=>t()),this.actionQueue.length=0}onDestroy(){this.actionQueue.length=0,this.destroySource()}resetConfig(){this.config.seek=0}getCurrentTime(){return this.config.loop&&this.duration>0?(this.systemContext.currentTime-this.playTime)%this.duration:this.systemContext.currentTime-this.playTime}createSource(){this.systemContext&&"loaded"===this.state&&(this.sourceNode=this.systemContext.createBufferSource(),this.sourceNode.buffer=this.buffer,this.sourceNode.loop=this.config.loop,this.gainNode||(this.gainNode=this.systemContext.createGain(),this.gainNode.connect(this.systemDestination),Object.assign(this,this.config)),this.sourceNode.connect(this.gainNode))}destroySource(){this.sourceNode&&(this.sourceNode.removeEventListener("ended",this.endedListener),this.sourceNode.stop(),this.sourceNode.disconnect(),this.sourceNode=null,this.startTime=0,this.playTime=0,this.playing=!1)}}t.__decorate([o.Field({type:"boolean",group:"Sound",label:"Muted",description:"Silence this sound without changing its volume setting.",editor:"toggle"})],r.prototype,"muted",null),t.__decorate([o.Field({type:"number",min:0,max:1,step:.01,group:"Sound",label:"Volume",description:"Loudness of this sound from 0 (silent) to 1 (full).",editor:"volume-slider"})],r.prototype,"volume",null),t.__decorate([o.Field({type:"boolean",group:"Sound",label:"Loop",description:"Replay the sound continuously when it reaches the end.",editor:"toggle"})],r.prototype,"loop",null),t.__decorate([o.Field({type:"boolean",group:"Sound",label:"Autoplay",description:"Start playing automatically once the audio has loaded.",editor:"toggle"})],r.prototype,"autoplay",null),t.__decorate([o.Field({type:"string",group:"Sound",label:"Resource",description:"Audio resource id used by the sound system.",editor:"text"})],r.prototype,"resource",null),exports.COMBOS_DEVELOPMENT_TOOL_SET_MUTED=s,exports.COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED=i,exports.Sound=r,exports.SoundSystem=a,exports.parseSetMutedMessage=n,exports.postParentSoundMuted=u;
@@ -362,7 +362,7 @@ var SoundSystem$1 = SoundSystem;
362
362
  /** Auto-generated by scripts/build-package.mjs — do not edit. */
363
363
  Object.assign(SoundSystem$1, {
364
364
  packageName: "@combos-fun/plugin-sound",
365
- packageVersion: "0.0.49",
365
+ packageVersion: "0.0.51",
366
366
  });
367
367
 
368
368
  class Sound extends Component {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-sound.esm.js","sources":["../lib/hostMessages.ts","../lib/SoundSystem.ts","../lib/__combosPackageMeta.gen.ts","../lib/Sound.ts"],"sourcesContent":["/** Parent → iframe (also `window` CustomEvent / `game.emit`): mute or unmute. Payload: `{ muted: boolean }`. */\nexport const COMBOS_DEVELOPMENT_TOOL_SET_MUTED =\n 'combos-development-tool:set-muted' as const;\n\n/** iframe → parent (and `game.emit`): current mute snapshot after a successful change. */\nexport const COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED =\n 'combos-development-tool:state-changed' as const;\n\nexport interface CombosSoundSetMutedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_SET_MUTED;\n muted: boolean;\n}\n\nexport interface CombosSoundStateChangedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED;\n muted: boolean;\n}\n\nexport function parseSetMutedMessage(data: unknown): boolean | null {\n if (!data || typeof data !== 'object') return null;\n const d = data as { type?: unknown; muted?: unknown };\n if (d.type !== COMBOS_DEVELOPMENT_TOOL_SET_MUTED) return null;\n if (typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nexport function parseSetMutedCustomEvent(event: Event): boolean | null {\n const d = (event as CustomEvent<{ muted?: unknown }>).detail;\n if (!d || typeof d !== 'object' || typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nfunction postToParent(payload: object, targetOrigin: string): void {\n if (typeof window === 'undefined') return;\n if (!window.parent || window.parent === window) return;\n try {\n window.parent.postMessage(payload, targetOrigin);\n } catch {\n /* ignore cross-origin or detached frame */\n }\n}\n\n/** Notifies the embedding page (and `game.emit`) of the current mute flag. */\nexport function postParentSoundMuted(\n muted: boolean,\n targetOrigin: string,\n emit?: (type: string, payload: { muted: boolean }) => void,\n): void {\n const state = { muted };\n postToParent({ type: COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, ...state }, targetOrigin);\n emit?.(COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, state);\n}\n","import {\n System,\n decorators,\n ComponentChanged,\n OBSERVER_TYPE,\n resource,\n isAllowedMessageOrigin,\n mergeAllowedMessageOrigins,\n} from '@combos-fun/engine';\nimport SoundComponent from './Sound';\nimport {\n COMBOS_DEVELOPMENT_TOOL_SET_MUTED,\n parseSetMutedCustomEvent,\n parseSetMutedMessage,\n postParentSoundMuted,\n} from './hostMessages';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError?: (error: any) => void;\n /** postMessage `targetOrigin` when notifying parent (default: Game `pluginInitNotifyTargetOrigin` or `'*'`). */\n postMessageOrigin?: string;\n /**\n * Extra inbound `postMessage` origins merged with engine defaults (`knoffice.tech`, `converge.ai`).\n * Each entry is a host suffix (e.g. `localhost`) or a full origin. Pass `['*']` to accept any origin.\n */\n allowedMessageOrigins?: string[];\n}\n\n@decorators.componentObserver({\n Sound: [],\n})\nclass SoundSystem extends System {\n static systemName = 'SoundSystem';\n\n private ctx: AudioContext;\n\n private gainNode: GainNode;\n\n /** Whether to pause/resume in sync with the game. */\n private autoPauseAndStart = true;\n\n private onError: (error: any) => void;\n\n private components: SoundComponent[] = [];\n\n private pausedComponents: SoundComponent[] = [];\n\n private audioBufferCache = {};\n\n private decodeAudioPromiseMap = {};\n\n /** Desired mute/volume are the source of truth; the gain node is derived. */\n private _muted = false;\n\n private _volume = 1;\n\n private postMessageOrigin = '*';\n\n private allowedMessageOrigins = mergeAllowedMessageOrigins();\n\n private hostMuteBound = false;\n\n get muted(): boolean {\n return this._muted;\n }\n\n set muted(v: boolean) {\n this.setMuted(v);\n }\n\n get volume(): number {\n return this._volume;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this._volume = v;\n this.applyGain();\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * Assigns `gain.value` directly rather than `setValueAtTime`: `.value` updates\n * the AudioParam's intrinsic value synchronously, so the `muted` / `volume`\n * getters reflect the change immediately. `setValueAtTime` only schedules an\n * event on the automation timeline and leaves `.value` stale until the next\n * render quantum, which made `muted` report the pre-change value.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this._muted ? 0 : this._volume;\n }\n\n get audioLocked(): boolean {\n if (!this.ctx) {\n return true;\n }\n return this.ctx.state !== 'running';\n }\n\n constructor(obj?: SoundSystemParams) {\n super(obj);\n if (!obj) return;\n if (typeof obj.autoPauseAndStart === 'boolean') {\n this.autoPauseAndStart = obj.autoPauseAndStart;\n }\n if (obj.onError) {\n this.onError = obj.onError;\n }\n }\n\n /**\n * Mute or unmute the master gain and notify the embedding host.\n * Same effect as `postMessage({ type: 'combos-development-tool:set-muted', muted })`.\n */\n setMuted(muted: boolean) {\n const next = !!muted;\n if (this._muted === next) {\n return;\n }\n this._muted = next;\n this.applyGain();\n this.postMuteStateChanged();\n }\n\n /**\n * Resume playback of all paused audio.\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * Pause all currently playing audio.\n */\n pauseAll() {\n this.components.forEach(component => {\n if (component.playing) {\n this.pausedComponents.push(component);\n component.pause();\n }\n });\n this.ctx.suspend().then();\n }\n\n /**\n * Stop all currently playing audio.\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System init: configure params before the game starts.\n */\n init(params?: SoundSystemParams) {\n this.postMessageOrigin =\n params?.postMessageOrigin ?? this.game?.pluginInitNotifyTargetOrigin ?? '*';\n this.allowedMessageOrigins = mergeAllowedMessageOrigins(params?.allowedMessageOrigins);\n this.bindHostMute();\n this.setupAudioContext();\n }\n\n update() {\n const changes = this.componentObserver.clear();\n for (const changed of changes) {\n this.componentChanged(changed);\n }\n }\n\n /**\n * Called when the game starts or resumes playing after a pause.\n */\n onResume() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * Called when the game is paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * Called when the system is destroyed.\n */\n onDestroy() {\n this.unbindHostMute();\n this.components.forEach(component => {\n component.onDestroy();\n });\n this.components = [];\n if (this.ctx) {\n this.gainNode.disconnect();\n this.gainNode = null;\n this.ctx.close();\n this.ctx = null;\n }\n }\n\n private readonly onWindowSetMuted = (e: Event) => {\n const muted = parseSetMutedCustomEvent(e);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private readonly onGameSetMuted = (payload: { muted?: boolean }) => {\n if (payload && typeof payload.muted === 'boolean') {\n this.setMuted(payload.muted);\n }\n };\n\n private readonly onWindowMessage = (e: MessageEvent) => {\n if (!isAllowedMessageOrigin(e.origin, this.allowedMessageOrigins)) {\n return;\n }\n const muted = parseSetMutedMessage(e.data);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private bindHostMute() {\n if (this.hostMuteBound) return;\n this.hostMuteBound = true;\n if (typeof window !== 'undefined') {\n window.addEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.addEventListener('message', this.onWindowMessage);\n }\n this.game.on(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private unbindHostMute() {\n if (!this.hostMuteBound) return;\n this.hostMuteBound = false;\n if (typeof window !== 'undefined') {\n window.removeEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.removeEventListener('message', this.onWindowMessage);\n }\n this.game?.off(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private postMuteStateChanged() {\n postParentSoundMuted(this._muted, this.postMessageOrigin, (type, payload) => {\n this.game?.emit(type, payload);\n });\n }\n\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.add(changed);\n }\n }\n\n private setupAudioContext() {\n try {\n const AudioContext = window.AudioContext || (window as any).webkitAudioContext;\n this.ctx = new AudioContext();\n } catch (error) {\n console.error(error);\n if (this.onError) {\n this.onError(error);\n }\n }\n\n if (!this.ctx) {\n return;\n }\n this.gainNode =\n typeof this.ctx.createGain === 'undefined' ? (this.ctx as any).createGainNode() : this.ctx.createGain();\n this.applyGain();\n this.gainNode.connect(this.ctx.destination);\n this.unlockAudio();\n }\n\n private unlockAudio() {\n if (!this.ctx || !this.audioLocked) {\n return;\n }\n\n const unlock = () => {\n if (this.ctx) {\n const removeListenerFn = () => {\n document.body.removeEventListener('touchstart', unlock);\n document.body.removeEventListener('touchend', unlock);\n document.body.removeEventListener('click', unlock);\n };\n this.ctx.resume().then(removeListenerFn, removeListenerFn);\n }\n };\n document.body.addEventListener('touchstart', unlock);\n document.body.addEventListener('touchend', unlock);\n document.body.addEventListener('click', unlock);\n }\n\n private async add(changed: ComponentChanged) {\n const component = changed.component as SoundComponent;\n this.components.push(component);\n try {\n const { config } = component;\n component.state = 'loading';\n\n const audio = await resource.getResource(config.resource);\n if (!this.audioBufferCache[audio.name] && audio?.data?.audio) {\n this.audioBufferCache[audio.name] = await this.decodeAudioData(audio.data.audio, audio.name);\n }\n if (this.audioBufferCache[audio.name]) {\n component.systemContext = this.ctx;\n component.systemDestination = this.gainNode;\n component.onload(this.audioBufferCache[audio.name]);\n }\n } catch (error) {\n if (this.onError) {\n this.onError(error);\n }\n }\n }\n\n private decodeAudioData(arraybuffer: ArrayBuffer, name: string) {\n if (this.decodeAudioPromiseMap[name]) {\n return this.decodeAudioPromiseMap[name];\n }\n\n const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\n }\n\n const success = (decodedData: AudioBuffer) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n if (decodedData) {\n resolve(decodedData);\n } else {\n reject(new Error(`Error decoding audio ${name}`));\n }\n };\n\n const error = (err: DOMException) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n reject(new Error(`${err}. arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n };\n\n const promise = this.ctx.decodeAudioData(arraybuffer, success, error)\n if (promise instanceof Promise) {\n promise.catch((err) => {\n reject(new Error(`catch ${err}, arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n });\n }\n });\n\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","/** Auto-generated by scripts/build-package.mjs — do not edit. */\n\nimport SoundSystem from './SoundSystem';\n\nObject.assign(SoundSystem, {\n packageName: \"@combos-fun/plugin-sound\",\n packageVersion: \"0.0.49\",\n});\n","import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface SoundParams {\n resource: string;\n autoplay?: boolean;\n muted?: boolean;\n volume?: number;\n loop?: boolean;\n seek?: number;\n duration?: number;\n onEnd?: () => void;\n}\n\nclass Sound extends Component<SoundParams> {\n static componentName = 'Sound';\n\n systemContext: AudioContext;\n\n systemDestination: GainNode;\n\n playing: boolean;\n\n state: 'unloaded' | 'loading' | 'loaded' = 'unloaded';\n\n config: SoundParams = {\n resource: '',\n autoplay: false,\n muted: false,\n volume: 1,\n loop: false,\n seek: 0,\n };\n\n private buffer: AudioBuffer;\n\n private sourceNode: AudioBufferSourceNode;\n\n private gainNode: GainNode;\n\n private paused: boolean;\n\n private playTime: number = 0;\n\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Muted',\n description: 'Silence this sound without changing its volume setting.',\n editor: 'toggle',\n })\n get muted(): boolean {\n return this.config.muted ?? false;\n }\n\n set muted(v: boolean) {\n this.config.muted = v;\n this.applyGain();\n }\n\n @Field({\n type: 'number',\n min: 0,\n max: 1,\n step: 0.01,\n group: 'Sound',\n label: 'Volume',\n description: 'Loudness of this sound from 0 (silent) to 1 (full).',\n editor: 'volume-slider',\n })\n get volume(): number {\n return this.config.volume ?? 1;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.config.volume = v;\n this.applyGain();\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Loop',\n description: 'Replay the sound continuously when it reaches the end.',\n editor: 'toggle',\n })\n get loop(): boolean {\n return this.config.loop ?? false;\n }\n\n set loop(v: boolean) {\n this.config.loop = v;\n if (this.sourceNode) {\n this.sourceNode.loop = v;\n }\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Autoplay',\n description: 'Start playing automatically once the audio has loaded.',\n editor: 'toggle',\n })\n get autoplay(): boolean {\n return this.config.autoplay ?? false;\n }\n\n set autoplay(v: boolean) {\n this.config.autoplay = v;\n }\n\n @Field({\n type: 'string',\n group: 'Sound',\n label: 'Resource',\n description: 'Audio resource id used by the sound system.',\n editor: 'text',\n })\n get resource(): string {\n return this.config.resource ?? '';\n }\n\n set resource(v: string) {\n this.config.resource = v;\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * `config` is the source of truth and the gain is assigned via `gain.value`\n * (updates the AudioParam intrinsic value synchronously) so the `muted` /\n * `volume` getters — and anything reading them back, e.g. the scene-edit\n * volume slider — reflect the change immediately. `setValueAtTime` only\n * schedules on the automation timeline and leaves `.value` stale.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this.config.muted ? 0 : (this.config.volume ?? 1);\n }\n\n init(obj?: SoundParams) {\n if (!obj) {\n return;\n }\n\n Object.assign(this.config, obj);\n if (this.config.autoplay) {\n this.actionQueue.push(this.play.bind(this));\n }\n }\n\n play() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.play.bind(this));\n }\n this.destroySource();\n this.createSource();\n\n if (!this.sourceNode) {\n return;\n }\n const when = this.systemContext.currentTime;\n const offset = this.config.seek;\n const duration = this.config.duration;\n\n this.sourceNode.start(0, offset, duration);\n\n this.startTime = when;\n this.playTime = when - offset;\n this.paused = false;\n this.playing = true;\n this.resetConfig();\n this.endedListener = () => {\n if (!this.sourceNode) {\n return;\n }\n if (this.config.onEnd) {\n this.config.onEnd();\n }\n // Release resources once non-interactive playback finishes.\n if (this.playing) {\n this.destroySource();\n }\n };\n this.sourceNode.addEventListener('ended', this.endedListener);\n }\n\n pause() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.pause.bind(this));\n }\n if (this.paused || !this.playing) {\n return;\n }\n this.paused = true;\n this.playing = false;\n this.config.seek = this.getCurrentTime();\n this.destroySource();\n }\n\n stop() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.stop.bind(this));\n }\n if (!this.paused && !this.playing) {\n return;\n }\n this.playing = false;\n this.paused = false;\n this.destroySource();\n this.resetConfig();\n }\n\n onload(buffer: AudioBuffer) {\n this.state = 'loaded';\n this.buffer = buffer;\n this.duration = this.buffer.duration;\n this.actionQueue.forEach(action => action());\n this.actionQueue.length = 0;\n }\n\n onDestroy() {\n this.actionQueue.length = 0;\n this.destroySource();\n }\n\n private resetConfig() {\n this.config.seek = 0;\n }\n\n private getCurrentTime() {\n if (this.config.loop && this.duration > 0) {\n return (this.systemContext.currentTime - this.playTime) % this.duration;\n }\n\n return this.systemContext.currentTime - this.playTime;\n }\n\n private createSource() {\n if (!this.systemContext || this.state !== 'loaded') {\n return;\n }\n this.sourceNode = this.systemContext.createBufferSource();\n this.sourceNode.buffer = this.buffer;\n this.sourceNode.loop = this.config.loop;\n\n if (!this.gainNode) {\n this.gainNode = this.systemContext.createGain();\n this.gainNode.connect(this.systemDestination);\n Object.assign(this, this.config);\n }\n this.sourceNode.connect(this.gainNode);\n }\n\n private destroySource() {\n if (!this.sourceNode) return;\n this.sourceNode.removeEventListener('ended', this.endedListener);\n this.sourceNode.stop();\n this.sourceNode.disconnect();\n this.sourceNode = null;\n\n this.startTime = 0;\n this.playTime = 0;\n this.playing = false;\n }\n}\n\nexport default Sound;\n"],"names":["S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AAA,EAAA,IAAA,CAAA;AAiBD,UAAA,CAAA;AAPC,IAAA,KAAK,CAAC;AACL,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,WAAW,EAAE,wDAAwD;AACrE,QAAA,MAAM,EAAE,QAAQ;KACjB;AAGA,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,MAAA,EAAA,IAAA,CAAA;AAgBD,UAAA,CAAA;AAPC,IAAA,KAAK,CAAC;AACL,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,WAAW,EAAE,wDAAwD;AACrE,QAAA,MAAM,EAAE,QAAQ;KACjB;AAGA,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA;AAaD,UAAA,CAAA;AAPC,IAAA,KAAK,CAAC;AACL,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,WAAW,EAAE,6CAA6C;AAC1D,QAAA,MAAM,EAAE,MAAM;KACf;AAGA,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"plugin-sound.esm.js","sources":["../lib/hostMessages.ts","../lib/SoundSystem.ts","../lib/__combosPackageMeta.gen.ts","../lib/Sound.ts"],"sourcesContent":["/** Parent → iframe (also `window` CustomEvent / `game.emit`): mute or unmute. Payload: `{ muted: boolean }`. */\nexport const COMBOS_DEVELOPMENT_TOOL_SET_MUTED =\n 'combos-development-tool:set-muted' as const;\n\n/** iframe → parent (and `game.emit`): current mute snapshot after a successful change. */\nexport const COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED =\n 'combos-development-tool:state-changed' as const;\n\nexport interface CombosSoundSetMutedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_SET_MUTED;\n muted: boolean;\n}\n\nexport interface CombosSoundStateChangedMessage {\n type: typeof COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED;\n muted: boolean;\n}\n\nexport function parseSetMutedMessage(data: unknown): boolean | null {\n if (!data || typeof data !== 'object') return null;\n const d = data as { type?: unknown; muted?: unknown };\n if (d.type !== COMBOS_DEVELOPMENT_TOOL_SET_MUTED) return null;\n if (typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nexport function parseSetMutedCustomEvent(event: Event): boolean | null {\n const d = (event as CustomEvent<{ muted?: unknown }>).detail;\n if (!d || typeof d !== 'object' || typeof d.muted !== 'boolean') return null;\n return d.muted;\n}\n\nfunction postToParent(payload: object, targetOrigin: string): void {\n if (typeof window === 'undefined') return;\n if (!window.parent || window.parent === window) return;\n try {\n window.parent.postMessage(payload, targetOrigin);\n } catch {\n /* ignore cross-origin or detached frame */\n }\n}\n\n/** Notifies the embedding page (and `game.emit`) of the current mute flag. */\nexport function postParentSoundMuted(\n muted: boolean,\n targetOrigin: string,\n emit?: (type: string, payload: { muted: boolean }) => void,\n): void {\n const state = { muted };\n postToParent({ type: COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, ...state }, targetOrigin);\n emit?.(COMBOS_DEVELOPMENT_TOOL_STATE_CHANGED, state);\n}\n","import {\n System,\n decorators,\n ComponentChanged,\n OBSERVER_TYPE,\n resource,\n isAllowedMessageOrigin,\n mergeAllowedMessageOrigins,\n} from '@combos-fun/engine';\nimport SoundComponent from './Sound';\nimport {\n COMBOS_DEVELOPMENT_TOOL_SET_MUTED,\n parseSetMutedCustomEvent,\n parseSetMutedMessage,\n postParentSoundMuted,\n} from './hostMessages';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError?: (error: any) => void;\n /** postMessage `targetOrigin` when notifying parent (default: Game `pluginInitNotifyTargetOrigin` or `'*'`). */\n postMessageOrigin?: string;\n /**\n * Extra inbound `postMessage` origins merged with engine defaults (`knoffice.tech`, `converge.ai`).\n * Each entry is a host suffix (e.g. `localhost`) or a full origin. Pass `['*']` to accept any origin.\n */\n allowedMessageOrigins?: string[];\n}\n\n@decorators.componentObserver({\n Sound: [],\n})\nclass SoundSystem extends System {\n static systemName = 'SoundSystem';\n\n private ctx: AudioContext;\n\n private gainNode: GainNode;\n\n /** Whether to pause/resume in sync with the game. */\n private autoPauseAndStart = true;\n\n private onError: (error: any) => void;\n\n private components: SoundComponent[] = [];\n\n private pausedComponents: SoundComponent[] = [];\n\n private audioBufferCache = {};\n\n private decodeAudioPromiseMap = {};\n\n /** Desired mute/volume are the source of truth; the gain node is derived. */\n private _muted = false;\n\n private _volume = 1;\n\n private postMessageOrigin = '*';\n\n private allowedMessageOrigins = mergeAllowedMessageOrigins();\n\n private hostMuteBound = false;\n\n get muted(): boolean {\n return this._muted;\n }\n\n set muted(v: boolean) {\n this.setMuted(v);\n }\n\n get volume(): number {\n return this._volume;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this._volume = v;\n this.applyGain();\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * Assigns `gain.value` directly rather than `setValueAtTime`: `.value` updates\n * the AudioParam's intrinsic value synchronously, so the `muted` / `volume`\n * getters reflect the change immediately. `setValueAtTime` only schedules an\n * event on the automation timeline and leaves `.value` stale until the next\n * render quantum, which made `muted` report the pre-change value.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this._muted ? 0 : this._volume;\n }\n\n get audioLocked(): boolean {\n if (!this.ctx) {\n return true;\n }\n return this.ctx.state !== 'running';\n }\n\n constructor(obj?: SoundSystemParams) {\n super(obj);\n if (!obj) return;\n if (typeof obj.autoPauseAndStart === 'boolean') {\n this.autoPauseAndStart = obj.autoPauseAndStart;\n }\n if (obj.onError) {\n this.onError = obj.onError;\n }\n }\n\n /**\n * Mute or unmute the master gain and notify the embedding host.\n * Same effect as `postMessage({ type: 'combos-development-tool:set-muted', muted })`.\n */\n setMuted(muted: boolean) {\n const next = !!muted;\n if (this._muted === next) {\n return;\n }\n this._muted = next;\n this.applyGain();\n this.postMuteStateChanged();\n }\n\n /**\n * Resume playback of all paused audio.\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * Pause all currently playing audio.\n */\n pauseAll() {\n this.components.forEach(component => {\n if (component.playing) {\n this.pausedComponents.push(component);\n component.pause();\n }\n });\n this.ctx.suspend().then();\n }\n\n /**\n * Stop all currently playing audio.\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // Clear the previously cached paused list.\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System init: configure params before the game starts.\n */\n init(params?: SoundSystemParams) {\n this.postMessageOrigin =\n params?.postMessageOrigin ?? this.game?.pluginInitNotifyTargetOrigin ?? '*';\n this.allowedMessageOrigins = mergeAllowedMessageOrigins(params?.allowedMessageOrigins);\n this.bindHostMute();\n this.setupAudioContext();\n }\n\n update() {\n const changes = this.componentObserver.clear();\n for (const changed of changes) {\n this.componentChanged(changed);\n }\n }\n\n /**\n * Called when the game starts or resumes playing after a pause.\n */\n onResume() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * Called when the game is paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * Called when the system is destroyed.\n */\n onDestroy() {\n this.unbindHostMute();\n this.components.forEach(component => {\n component.onDestroy();\n });\n this.components = [];\n if (this.ctx) {\n this.gainNode.disconnect();\n this.gainNode = null;\n this.ctx.close();\n this.ctx = null;\n }\n }\n\n private readonly onWindowSetMuted = (e: Event) => {\n const muted = parseSetMutedCustomEvent(e);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private readonly onGameSetMuted = (payload: { muted?: boolean }) => {\n if (payload && typeof payload.muted === 'boolean') {\n this.setMuted(payload.muted);\n }\n };\n\n private readonly onWindowMessage = (e: MessageEvent) => {\n if (!isAllowedMessageOrigin(e.origin, this.allowedMessageOrigins)) {\n return;\n }\n const muted = parseSetMutedMessage(e.data);\n if (muted === null) return;\n this.setMuted(muted);\n };\n\n private bindHostMute() {\n if (this.hostMuteBound) return;\n this.hostMuteBound = true;\n if (typeof window !== 'undefined') {\n window.addEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.addEventListener('message', this.onWindowMessage);\n }\n this.game.on(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private unbindHostMute() {\n if (!this.hostMuteBound) return;\n this.hostMuteBound = false;\n if (typeof window !== 'undefined') {\n window.removeEventListener(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onWindowSetMuted);\n window.removeEventListener('message', this.onWindowMessage);\n }\n this.game?.off(COMBOS_DEVELOPMENT_TOOL_SET_MUTED, this.onGameSetMuted);\n }\n\n private postMuteStateChanged() {\n postParentSoundMuted(this._muted, this.postMessageOrigin, (type, payload) => {\n this.game?.emit(type, payload);\n });\n }\n\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.add(changed);\n }\n }\n\n private setupAudioContext() {\n try {\n const AudioContext = window.AudioContext || (window as any).webkitAudioContext;\n this.ctx = new AudioContext();\n } catch (error) {\n console.error(error);\n if (this.onError) {\n this.onError(error);\n }\n }\n\n if (!this.ctx) {\n return;\n }\n this.gainNode =\n typeof this.ctx.createGain === 'undefined' ? (this.ctx as any).createGainNode() : this.ctx.createGain();\n this.applyGain();\n this.gainNode.connect(this.ctx.destination);\n this.unlockAudio();\n }\n\n private unlockAudio() {\n if (!this.ctx || !this.audioLocked) {\n return;\n }\n\n const unlock = () => {\n if (this.ctx) {\n const removeListenerFn = () => {\n document.body.removeEventListener('touchstart', unlock);\n document.body.removeEventListener('touchend', unlock);\n document.body.removeEventListener('click', unlock);\n };\n this.ctx.resume().then(removeListenerFn, removeListenerFn);\n }\n };\n document.body.addEventListener('touchstart', unlock);\n document.body.addEventListener('touchend', unlock);\n document.body.addEventListener('click', unlock);\n }\n\n private async add(changed: ComponentChanged) {\n const component = changed.component as SoundComponent;\n this.components.push(component);\n try {\n const { config } = component;\n component.state = 'loading';\n\n const audio = await resource.getResource(config.resource);\n if (!this.audioBufferCache[audio.name] && audio?.data?.audio) {\n this.audioBufferCache[audio.name] = await this.decodeAudioData(audio.data.audio, audio.name);\n }\n if (this.audioBufferCache[audio.name]) {\n component.systemContext = this.ctx;\n component.systemDestination = this.gainNode;\n component.onload(this.audioBufferCache[audio.name]);\n }\n } catch (error) {\n if (this.onError) {\n this.onError(error);\n }\n }\n }\n\n private decodeAudioData(arraybuffer: ArrayBuffer, name: string) {\n if (this.decodeAudioPromiseMap[name]) {\n return this.decodeAudioPromiseMap[name];\n }\n\n const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\n }\n\n const success = (decodedData: AudioBuffer) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n if (decodedData) {\n resolve(decodedData);\n } else {\n reject(new Error(`Error decoding audio ${name}`));\n }\n };\n\n const error = (err: DOMException) => {\n if (this.decodeAudioPromiseMap[name]) {\n delete this.decodeAudioPromiseMap[name];\n }\n reject(new Error(`${err}. arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n };\n\n const promise = this.ctx.decodeAudioData(arraybuffer, success, error)\n if (promise instanceof Promise) {\n promise.catch((err) => {\n reject(new Error(`catch ${err}, arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`));\n });\n }\n });\n\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","/** Auto-generated by scripts/build-package.mjs — do not edit. */\n\nimport SoundSystem from './SoundSystem';\n\nObject.assign(SoundSystem, {\n packageName: \"@combos-fun/plugin-sound\",\n packageVersion: \"0.0.51\",\n});\n","import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface SoundParams {\n resource: string;\n autoplay?: boolean;\n muted?: boolean;\n volume?: number;\n loop?: boolean;\n seek?: number;\n duration?: number;\n onEnd?: () => void;\n}\n\nclass Sound extends Component<SoundParams> {\n static componentName = 'Sound';\n\n systemContext: AudioContext;\n\n systemDestination: GainNode;\n\n playing: boolean;\n\n state: 'unloaded' | 'loading' | 'loaded' = 'unloaded';\n\n config: SoundParams = {\n resource: '',\n autoplay: false,\n muted: false,\n volume: 1,\n loop: false,\n seek: 0,\n };\n\n private buffer: AudioBuffer;\n\n private sourceNode: AudioBufferSourceNode;\n\n private gainNode: GainNode;\n\n private paused: boolean;\n\n private playTime: number = 0;\n\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Muted',\n description: 'Silence this sound without changing its volume setting.',\n editor: 'toggle',\n })\n get muted(): boolean {\n return this.config.muted ?? false;\n }\n\n set muted(v: boolean) {\n this.config.muted = v;\n this.applyGain();\n }\n\n @Field({\n type: 'number',\n min: 0,\n max: 1,\n step: 0.01,\n group: 'Sound',\n label: 'Volume',\n description: 'Loudness of this sound from 0 (silent) to 1 (full).',\n editor: 'volume-slider',\n })\n get volume(): number {\n return this.config.volume ?? 1;\n }\n\n set volume(v: number) {\n if (typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.config.volume = v;\n this.applyGain();\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Loop',\n description: 'Replay the sound continuously when it reaches the end.',\n editor: 'toggle',\n })\n get loop(): boolean {\n return this.config.loop ?? false;\n }\n\n set loop(v: boolean) {\n this.config.loop = v;\n if (this.sourceNode) {\n this.sourceNode.loop = v;\n }\n }\n\n @Field({\n type: 'boolean',\n group: 'Sound',\n label: 'Autoplay',\n description: 'Start playing automatically once the audio has loaded.',\n editor: 'toggle',\n })\n get autoplay(): boolean {\n return this.config.autoplay ?? false;\n }\n\n set autoplay(v: boolean) {\n this.config.autoplay = v;\n }\n\n @Field({\n type: 'string',\n group: 'Sound',\n label: 'Resource',\n description: 'Audio resource id used by the sound system.',\n editor: 'text',\n })\n get resource(): string {\n return this.config.resource ?? '';\n }\n\n set resource(v: string) {\n this.config.resource = v;\n }\n\n /**\n * Apply the effective gain (`muted ? 0 : volume`) to the gain node.\n *\n * `config` is the source of truth and the gain is assigned via `gain.value`\n * (updates the AudioParam intrinsic value synchronously) so the `muted` /\n * `volume` getters — and anything reading them back, e.g. the scene-edit\n * volume slider — reflect the change immediately. `setValueAtTime` only\n * schedules on the automation timeline and leaves `.value` stale.\n */\n private applyGain() {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.value = this.config.muted ? 0 : (this.config.volume ?? 1);\n }\n\n init(obj?: SoundParams) {\n if (!obj) {\n return;\n }\n\n Object.assign(this.config, obj);\n if (this.config.autoplay) {\n this.actionQueue.push(this.play.bind(this));\n }\n }\n\n play() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.play.bind(this));\n }\n this.destroySource();\n this.createSource();\n\n if (!this.sourceNode) {\n return;\n }\n const when = this.systemContext.currentTime;\n const offset = this.config.seek;\n const duration = this.config.duration;\n\n this.sourceNode.start(0, offset, duration);\n\n this.startTime = when;\n this.playTime = when - offset;\n this.paused = false;\n this.playing = true;\n this.resetConfig();\n this.endedListener = () => {\n if (!this.sourceNode) {\n return;\n }\n if (this.config.onEnd) {\n this.config.onEnd();\n }\n // Release resources once non-interactive playback finishes.\n if (this.playing) {\n this.destroySource();\n }\n };\n this.sourceNode.addEventListener('ended', this.endedListener);\n }\n\n pause() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.pause.bind(this));\n }\n if (this.paused || !this.playing) {\n return;\n }\n this.paused = true;\n this.playing = false;\n this.config.seek = this.getCurrentTime();\n this.destroySource();\n }\n\n stop() {\n if (this.state !== 'loaded') {\n this.actionQueue.push(this.stop.bind(this));\n }\n if (!this.paused && !this.playing) {\n return;\n }\n this.playing = false;\n this.paused = false;\n this.destroySource();\n this.resetConfig();\n }\n\n onload(buffer: AudioBuffer) {\n this.state = 'loaded';\n this.buffer = buffer;\n this.duration = this.buffer.duration;\n this.actionQueue.forEach(action => action());\n this.actionQueue.length = 0;\n }\n\n onDestroy() {\n this.actionQueue.length = 0;\n this.destroySource();\n }\n\n private resetConfig() {\n this.config.seek = 0;\n }\n\n private getCurrentTime() {\n if (this.config.loop && this.duration > 0) {\n return (this.systemContext.currentTime - this.playTime) % this.duration;\n }\n\n return this.systemContext.currentTime - this.playTime;\n }\n\n private createSource() {\n if (!this.systemContext || this.state !== 'loaded') {\n return;\n }\n this.sourceNode = this.systemContext.createBufferSource();\n this.sourceNode.buffer = this.buffer;\n this.sourceNode.loop = this.config.loop;\n\n if (!this.gainNode) {\n this.gainNode = this.systemContext.createGain();\n this.gainNode.connect(this.systemDestination);\n Object.assign(this, this.config);\n }\n this.sourceNode.connect(this.gainNode);\n }\n\n private destroySource() {\n if (!this.sourceNode) return;\n this.sourceNode.removeEventListener('ended', this.endedListener);\n this.sourceNode.stop();\n this.sourceNode.disconnect();\n this.sourceNode = null;\n\n this.startTime = 0;\n this.playTime = 0;\n this.playing = false;\n }\n}\n\nexport default Sound;\n"],"names":["SoundSystem"],"mappings":";;;;AAAA;AACO,MAAM,iCAAiC,GAC5C;AAEF;AACO,MAAM,qCAAqC,GAChD;AAYI,SAAU,oBAAoB,CAAC,IAAa,EAAA;AAChD,IAAA,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;IAClD,MAAM,CAAC,GAAG,IAA2C;AACrD,IAAA,IAAI,CAAC,CAAC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A,EAAA,IAAA,CAAA;AAgBD,UAAA,CAAA;AAPC,IAAA,KAAK,CAAC;AACL,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,WAAW,EAAE,wDAAwD;AACrE,QAAA,MAAM,EAAE,QAAQ;KACjB;AAGA,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA;AAaD,UAAA,CAAA;AAPC,IAAA,KAAK,CAAC;AACL,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,WAAW,EAAE,6CAA6C;AAC1D,QAAA,MAAM,EAAE,MAAM;KACf;AAGA,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-sound",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "Audio playback",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-sound.esm.js",
@@ -38,8 +38,8 @@
38
38
  "author": "sun668 <q947692259@gmail.com>",
39
39
  "dependencies": {
40
40
  "eventemitter3": "^5.0.4",
41
- "@combos-fun/engine": "0.0.49",
42
- "@combos-fun/inspector-decorator": "0.0.49"
41
+ "@combos-fun/inspector-decorator": "0.0.51",
42
+ "@combos-fun/engine": "0.0.51"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsx": "^4.20.3"