@eva/plugin-sound 1.2.7-editor.9 → 1.2.7-fix.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,10 +40,6 @@ var _EVA_IIFE_sound = function (exports, eva_js) {
40
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
41
41
  }
42
42
 
43
- function __metadata(metadataKey, metadataValue) {
44
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
45
- }
46
-
47
43
  function __awaiter(thisArg, _arguments, P, generator) {
48
44
  function adopt(value) {
49
45
  return value instanceof P ? value : new P(function (resolve) {
@@ -518,7 +514,7 @@ var _EVA_IIFE_sound = function (exports, eva_js) {
518
514
  SoundSystem.systemName = 'SoundSystem';
519
515
  SoundSystem = __decorate([eva_js.decorators.componentObserver({
520
516
  Sound: []
521
- }), __metadata("design:paramtypes", [Object])], SoundSystem);
517
+ })], SoundSystem);
522
518
  return SoundSystem;
523
519
  }(eva_js.System);
524
520
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EVA.plugin.sound.js","sources":["../../../node_modules/tslib/tslib.es6.js","../lib/SoundSystem.ts","../lib/Sound.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { System, decorators, ComponentChanged, OBSERVER_TYPE, resource } from '@eva/eva.js';\nimport SoundComponent from './Sound';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError: (error: any) => void;\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 /** 是否和游戏同步暂停和启动 */\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 get muted(): boolean {\n return this.gainNode ? this.gainNode.gain.value === 0 : false;\n }\n\n set muted(v: boolean) {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v ? 0 : 1, 0);\n }\n\n get volume(): number {\n return this.gainNode ? this.gainNode.gain.value : 1;\n }\n\n set volume(v: number) {\n if (!this.gainNode || typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v, 0);\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();\n Object.assign(this, obj);\n }\n\n /**\n * 恢复播放所有被暂停的音频\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // 清理之前缓存的暂停列表\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * 暂停所有正在播放的音频\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 * 停止所有正在播放的音频\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // 清理之前缓存的暂停列表\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System 初始化用,可以配置参数,游戏未开始\n *\n * System init, set params, game is not begain\n */\n init() {\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 * 游戏开始和游戏暂停后开始播放的时候调用。\n *\n * Called while the game to play when game pause.\n */\n onPlay() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * 游戏暂停的时候调用。\n *\n * Called while the game paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * System 被销毁的时候调用。\n * Called while the system be destroyed.\n */\n onDestroy() {\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') {\n 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.gainNode.gain.setValueAtTime(this.muted ? 0 : this.volume, this.ctx.currentTime);\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]) {\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 console.error(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 const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\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 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 this.ctx.decodeAudioData(arraybuffer, success, error);\n });\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","import { Component } from '@eva/eva.js';\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 // @ts-ignore\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n get muted(): boolean {\n return this.gainNode ? this.gainNode.gain.value === 0 : false;\n }\n\n set muted(v: boolean) {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v ? 0 : this.config.volume, 0);\n }\n\n get volume(): number {\n return this.gainNode ? this.gainNode.gain.value : 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 if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v, 0);\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 // 非交互事件播放完成需要销毁资源\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":["OBSERVER_TYPE","resource","decorators","System","Component"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACA;IACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;IACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;IACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;IACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC;AACF;IACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;IAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,IAAI,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE;IAC3C,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzF,C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AC,UAAU,CAAC,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YAEvB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACtB;QA5LM,mBAAa,GAAG,OAAO,CAAC;QA6LjC,YAAC;KAAA,CA9LmBC,gBAAS,GA8L5B;AAED,kBAAe,KAAK;;;;;;;;;;;"}
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_sound=function(t,e){"use strict";var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},o(t,e)};function n(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function i(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function r(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{a(n.next(t))}catch(t){r(t)}}function u(t){try{a(n.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,u)}a((n=n.apply(t,e||[])).next())}))}function s(t,e){var o,n,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function u(r){return function(u){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],n=0}finally{o=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,u])}}}var u=function(t){function o(e){var o=t.call(this)||this;return o.autoPauseAndStart=!0,o.components=[],o.pausedComponents=[],o.audioBufferCache={},o.decodeAudioPromiseMap={},_extends(o,e),o}return n(o,t),Object.defineProperty(o.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:1,0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){!this.gainNode||"number"!=typeof t||t<0||t>1||this.gainNode.gain.setValueAtTime(t,0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"audioLocked",{get:function(){return!this.ctx||"running"!==this.ctx.state},enumerable:!1,configurable:!0}),o.prototype.resumeAll=function(){var t=this,e=function(){t.pausedComponents.forEach((function(t){t.play()})),t.pausedComponents=[]};this.ctx.resume().then(e,e)},o.prototype.pauseAll=function(){var t=this;this.components.forEach((function(e){e.playing&&(t.pausedComponents.push(e),e.pause())})),this.ctx.suspend().then()},o.prototype.stopAll=function(){this.components.forEach((function(t){t.playing&&t.stop()})),this.pausedComponents=[],this.ctx.suspend().then()},o.prototype.init=function(){this.setupAudioContext()},o.prototype.update=function(){var t,e,o=this.componentObserver.clear();try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,o=e&&t[e],n=0;if(o)return o.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(o),i=n.next();!i.done;i=n.next()){var r=i.value;this.componentChanged(r)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},o.prototype.onResume=function(){this.autoPauseAndStart&&this.resumeAll()},o.prototype.onPause=function(){this.autoPauseAndStart&&this.pauseAll()},o.prototype.onDestroy=function(){this.components.forEach((function(t){t.onDestroy()})),this.components=[],this.ctx&&(this.gainNode.disconnect(),this.gainNode=null,this.ctx.close(),this.ctx=null)},o.prototype.componentChanged=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(o){return"Sound"!==t.componentName||t.type===e.OBSERVER_TYPE.ADD&&this.add(t),[2]}))}))},o.prototype.setupAudioContext=function(){try{var 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.gainNode.gain.setValueAtTime(this.muted?0:this.volume,this.ctx.currentTime),this.gainNode.connect(this.ctx.destination),this.unlockAudio())},o.prototype.unlockAudio=function(){var t=this;if(this.ctx&&this.audioLocked){var e=function e(){if(t.ctx){var o=function(){document.body.removeEventListener("touchstart",e),document.body.removeEventListener("touchend",e),document.body.removeEventListener("click",e)};t.ctx.resume().then(o,o)}};document.body.addEventListener("touchstart",e),document.body.addEventListener("touchend",e),document.body.addEventListener("click",e)}},o.prototype.add=function(t){var o;return r(this,void 0,void 0,(function(){var n,i,r,u,a,c;return s(this,(function(s){switch(s.label){case 0:n=t.component,this.components.push(n),s.label=1;case 1:return s.trys.push([1,5,,6]),i=n.config,n.state="loading",[4,e.resource.getResource(i.resource)];case 2:return r=s.sent(),this.audioBufferCache[r.name]||!(null===(o=null==r?void 0:r.data)||void 0===o?void 0:o.audio)?[3,4]:(u=this.audioBufferCache,a=r.name,[4,this.decodeAudioData(r.data.audio,r.name)]);case 3:u[a]=s.sent(),s.label=4;case 4:return this.audioBufferCache[r.name]&&(n.systemContext=this.ctx,n.systemDestination=this.gainNode,n.onload(this.audioBufferCache[r.name])),[3,6];case 5:return c=s.sent(),this.onError&&this.onError(c),[3,6];case 6:return[2]}}))}))},o.prototype.decodeAudioData=function(t,e){var o=this;if(this.decodeAudioPromiseMap[e])return this.decodeAudioPromiseMap[e];var n=new Promise((function(n,i){o.ctx||i(new Error("No audio support"));var r=o.ctx.decodeAudioData(t,(function(t){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],t?n(t):i(new Error("Error decoding audio "+e))}),(function(n){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],i(new Error(n+". arrayBuffer byteLength: "+(t?t.byteLength:0)))}));r instanceof Promise&&r.catch((function(e){i(new Error("catch "+e+", arrayBuffer byteLength: "+(t?t.byteLength:0)))}))}));return this.decodeAudioPromiseMap[e]=n,n},o.systemName="SoundSystem",o=function(t,e,o,n){var i,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var u=t.length-1;u>=0;u--)(i=t[u])&&(s=(r<3?i(s):r>3?i(e,o,s):i(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s}([e.decorators.componentObserver({Sound:[]}),i("design:paramtypes",[Object])],o),o}(e.System),a=u,c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state="unloaded",e.config={resource:"",autoplay:!1,muted:!1,volume:1,loop:!1,seek:0},e.playTime=0,e.startTime=0,e.duration=0,e.actionQueue=[],e}return n(e,t),Object.defineProperty(e.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:this.config.volume,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){"number"!=typeof t||t<0||t>1||(this.config.volume=t,this.gainNode&&this.gainNode.gain.setValueAtTime(t,0))},enumerable:!1,configurable:!0}),e.prototype.init=function(t){t&&(_extends(this.config,t),this.config.autoplay&&this.actionQueue.push(this.play.bind(this)))},e.prototype.play=function(){var t=this;if("loaded"!==this.state&&this.actionQueue.push(this.play.bind(this)),this.destroySource(),this.createSource(),this.sourceNode){var e=this.systemContext.currentTime,o=this.config.seek,n=this.config.duration;this.sourceNode.start(0,o,n),this.startTime=e,this.playTime=e-o,this.paused=!1,this.playing=!0,this.resetConfig(),this.endedListener=function(){t.sourceNode&&(t.config.onEnd&&t.config.onEnd(),t.playing&&t.destroySource())},this.sourceNode.addEventListener("ended",this.endedListener)}},e.prototype.pause=function(){"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())},e.prototype.stop=function(){"loaded"!==this.state&&this.actionQueue.push(this.stop.bind(this)),(this.paused||this.playing)&&(this.playing=!1,this.paused=!1,this.destroySource(),this.resetConfig())},e.prototype.onload=function(t){this.state="loaded",this.buffer=t,this.duration=this.buffer.duration,this.actionQueue.forEach((function(t){return t()})),this.actionQueue.length=0},e.prototype.onDestroy=function(){this.actionQueue.length=0,this.destroySource()},e.prototype.resetConfig=function(){this.config.seek=0},e.prototype.getCurrentTime=function(){return this.config.loop&&this.duration>0?(this.systemContext.currentTime-this.playTime)%this.duration:this.systemContext.currentTime-this.playTime},e.prototype.createSource=function(){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),_extends(this,this.config)),this.sourceNode.connect(this.gainNode))},e.prototype.destroySource=function(){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)},e.componentName="Sound",e}(e.Component),d=c;return t.Sound=d,t.SoundSystem=a,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.sound=window.EVA.plugin.sound||_EVA_IIFE_sound;
1
+ function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_sound=function(t,e){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};function n(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function i(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{a(n.next(t))}catch(t){r(t)}}function u(t){try{a(n.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,u)}a((n=n.apply(t,e||[])).next())}))}function r(t,e){var o,n,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function u(r){return function(u){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],n=0}finally{o=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,u])}}}var s=function(t){function o(e){var o=t.call(this)||this;return o.autoPauseAndStart=!0,o.components=[],o.pausedComponents=[],o.audioBufferCache={},o.decodeAudioPromiseMap={},_extends(o,e),o}return n(o,t),Object.defineProperty(o.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:1,0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){!this.gainNode||"number"!=typeof t||t<0||t>1||this.gainNode.gain.setValueAtTime(t,0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"audioLocked",{get:function(){return!this.ctx||"running"!==this.ctx.state},enumerable:!1,configurable:!0}),o.prototype.resumeAll=function(){var t=this,e=function(){t.pausedComponents.forEach((function(t){t.play()})),t.pausedComponents=[]};this.ctx.resume().then(e,e)},o.prototype.pauseAll=function(){var t=this;this.components.forEach((function(e){e.playing&&(t.pausedComponents.push(e),e.pause())})),this.ctx.suspend().then()},o.prototype.stopAll=function(){this.components.forEach((function(t){t.playing&&t.stop()})),this.pausedComponents=[],this.ctx.suspend().then()},o.prototype.init=function(){this.setupAudioContext()},o.prototype.update=function(){var t,e,o=this.componentObserver.clear();try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,o=e&&t[e],n=0;if(o)return o.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(o),i=n.next();!i.done;i=n.next()){var r=i.value;this.componentChanged(r)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},o.prototype.onResume=function(){this.autoPauseAndStart&&this.resumeAll()},o.prototype.onPause=function(){this.autoPauseAndStart&&this.pauseAll()},o.prototype.onDestroy=function(){this.components.forEach((function(t){t.onDestroy()})),this.components=[],this.ctx&&(this.gainNode.disconnect(),this.gainNode=null,this.ctx.close(),this.ctx=null)},o.prototype.componentChanged=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(o){return"Sound"!==t.componentName||t.type===e.OBSERVER_TYPE.ADD&&this.add(t),[2]}))}))},o.prototype.setupAudioContext=function(){try{var 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.gainNode.gain.setValueAtTime(this.muted?0:this.volume,this.ctx.currentTime),this.gainNode.connect(this.ctx.destination),this.unlockAudio())},o.prototype.unlockAudio=function(){var t=this;if(this.ctx&&this.audioLocked){var e=function e(){if(t.ctx){var o=function(){document.body.removeEventListener("touchstart",e),document.body.removeEventListener("touchend",e),document.body.removeEventListener("click",e)};t.ctx.resume().then(o,o)}};document.body.addEventListener("touchstart",e),document.body.addEventListener("touchend",e),document.body.addEventListener("click",e)}},o.prototype.add=function(t){var o;return i(this,void 0,void 0,(function(){var n,i,s,u,a,c;return r(this,(function(r){switch(r.label){case 0:n=t.component,this.components.push(n),r.label=1;case 1:return r.trys.push([1,5,,6]),i=n.config,n.state="loading",[4,e.resource.getResource(i.resource)];case 2:return s=r.sent(),this.audioBufferCache[s.name]||!(null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.audio)?[3,4]:(u=this.audioBufferCache,a=s.name,[4,this.decodeAudioData(s.data.audio,s.name)]);case 3:u[a]=r.sent(),r.label=4;case 4:return this.audioBufferCache[s.name]&&(n.systemContext=this.ctx,n.systemDestination=this.gainNode,n.onload(this.audioBufferCache[s.name])),[3,6];case 5:return c=r.sent(),this.onError&&this.onError(c),[3,6];case 6:return[2]}}))}))},o.prototype.decodeAudioData=function(t,e){var o=this;if(this.decodeAudioPromiseMap[e])return this.decodeAudioPromiseMap[e];var n=new Promise((function(n,i){o.ctx||i(new Error("No audio support"));var r=o.ctx.decodeAudioData(t,(function(t){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],t?n(t):i(new Error("Error decoding audio "+e))}),(function(n){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],i(new Error(n+". arrayBuffer byteLength: "+(t?t.byteLength:0)))}));r instanceof Promise&&r.catch((function(e){i(new Error("catch "+e+", arrayBuffer byteLength: "+(t?t.byteLength:0)))}))}));return this.decodeAudioPromiseMap[e]=n,n},o.systemName="SoundSystem",o=function(t,e,o,n){var i,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var u=t.length-1;u>=0;u--)(i=t[u])&&(s=(r<3?i(s):r>3?i(e,o,s):i(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s}([e.decorators.componentObserver({Sound:[]})],o)}(e.System),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state="unloaded",e.config={resource:"",autoplay:!1,muted:!1,volume:1,loop:!1,seek:0},e.playTime=0,e.startTime=0,e.duration=0,e.actionQueue=[],e}return n(e,t),Object.defineProperty(e.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:this.config.volume,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){"number"!=typeof t||t<0||t>1||(this.config.volume=t,this.gainNode&&this.gainNode.gain.setValueAtTime(t,0))},enumerable:!1,configurable:!0}),e.prototype.init=function(t){t&&(_extends(this.config,t),this.config.autoplay&&this.actionQueue.push(this.play.bind(this)))},e.prototype.play=function(){var t=this;if("loaded"!==this.state&&this.actionQueue.push(this.play.bind(this)),this.destroySource(),this.createSource(),this.sourceNode){var e=this.systemContext.currentTime,o=this.config.seek,n=this.config.duration;this.sourceNode.start(0,o,n),this.startTime=e,this.playTime=e-o,this.paused=!1,this.playing=!0,this.resetConfig(),this.endedListener=function(){t.sourceNode&&(t.config.onEnd&&t.config.onEnd(),t.playing&&t.destroySource())},this.sourceNode.addEventListener("ended",this.endedListener)}},e.prototype.pause=function(){"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())},e.prototype.stop=function(){"loaded"!==this.state&&this.actionQueue.push(this.stop.bind(this)),(this.paused||this.playing)&&(this.playing=!1,this.paused=!1,this.destroySource(),this.resetConfig())},e.prototype.onload=function(t){this.state="loaded",this.buffer=t,this.duration=this.buffer.duration,this.actionQueue.forEach((function(t){return t()})),this.actionQueue.length=0},e.prototype.onDestroy=function(){this.actionQueue.length=0,this.destroySource()},e.prototype.resetConfig=function(){this.config.seek=0},e.prototype.getCurrentTime=function(){return this.config.loop&&this.duration>0?(this.systemContext.currentTime-this.playTime)%this.duration:this.systemContext.currentTime-this.playTime},e.prototype.createSource=function(){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),_extends(this,this.config)),this.sourceNode.connect(this.gainNode))},e.prototype.destroySource=function(){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)},e.componentName="Sound",e}(e.Component);return t.Sound=u,t.SoundSystem=s,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.sound=window.EVA.plugin.sound||_EVA_IIFE_sound;
@@ -0,0 +1,529 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import { windowAlias, documentAlias } from '@eva/miniprogram-adapter';
4
+ import { __extends, __values, __awaiter, __generator, __decorate } from 'tslib';
5
+ import { OBSERVER_TYPE, resource, decorators, System, Component } from '@eva/eva.js/dist/miniprogram';
6
+
7
+ var SoundSystem = function (_super) {
8
+ __extends(SoundSystem, _super);
9
+
10
+ function SoundSystem(obj) {
11
+ var _this = _super.call(this) || this;
12
+
13
+ _this.autoPauseAndStart = true;
14
+ _this.components = [];
15
+ _this.pausedComponents = [];
16
+ _this.audioBufferCache = {};
17
+ _this.decodeAudioPromiseMap = {};
18
+
19
+ _extends(_this, obj);
20
+
21
+ return _this;
22
+ }
23
+
24
+ Object.defineProperty(SoundSystem.prototype, "muted", {
25
+ get: function get() {
26
+ return this.gainNode ? this.gainNode.gain.value === 0 : false;
27
+ },
28
+ set: function set(v) {
29
+ if (!this.gainNode) {
30
+ return;
31
+ }
32
+
33
+ this.gainNode.gain.setValueAtTime(v ? 0 : 1, 0);
34
+ },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
38
+ Object.defineProperty(SoundSystem.prototype, "volume", {
39
+ get: function get() {
40
+ return this.gainNode ? this.gainNode.gain.value : 1;
41
+ },
42
+ set: function set(v) {
43
+ if (!this.gainNode || typeof v !== 'number' || v < 0 || v > 1) {
44
+ return;
45
+ }
46
+
47
+ this.gainNode.gain.setValueAtTime(v, 0);
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ Object.defineProperty(SoundSystem.prototype, "audioLocked", {
53
+ get: function get() {
54
+ if (!this.ctx) {
55
+ return true;
56
+ }
57
+
58
+ return this.ctx.state !== 'running';
59
+ },
60
+ enumerable: false,
61
+ configurable: true
62
+ });
63
+
64
+ SoundSystem.prototype.resumeAll = function () {
65
+ var _this = this;
66
+
67
+ var handleResume = function handleResume() {
68
+ _this.pausedComponents.forEach(function (component) {
69
+ component.play();
70
+ });
71
+
72
+ _this.pausedComponents = [];
73
+ };
74
+
75
+ this.ctx.resume().then(handleResume, handleResume);
76
+ };
77
+
78
+ SoundSystem.prototype.pauseAll = function () {
79
+ var _this = this;
80
+
81
+ this.components.forEach(function (component) {
82
+ if (component.playing) {
83
+ _this.pausedComponents.push(component);
84
+
85
+ component.pause();
86
+ }
87
+ });
88
+ this.ctx.suspend().then();
89
+ };
90
+
91
+ SoundSystem.prototype.stopAll = function () {
92
+ this.components.forEach(function (component) {
93
+ if (component.playing) {
94
+ component.stop();
95
+ }
96
+ });
97
+ this.pausedComponents = [];
98
+ this.ctx.suspend().then();
99
+ };
100
+
101
+ SoundSystem.prototype.init = function () {
102
+ this.setupAudioContext();
103
+ };
104
+
105
+ SoundSystem.prototype.update = function () {
106
+ var e_1, _a;
107
+
108
+ var changes = this.componentObserver.clear();
109
+
110
+ try {
111
+ for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
112
+ var changed = changes_1_1.value;
113
+ this.componentChanged(changed);
114
+ }
115
+ } catch (e_1_1) {
116
+ e_1 = {
117
+ error: e_1_1
118
+ };
119
+ } finally {
120
+ try {
121
+ if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
122
+ } finally {
123
+ if (e_1) throw e_1.error;
124
+ }
125
+ }
126
+ };
127
+
128
+ SoundSystem.prototype.onResume = function () {
129
+ if (!this.autoPauseAndStart) {
130
+ return;
131
+ }
132
+
133
+ this.resumeAll();
134
+ };
135
+
136
+ SoundSystem.prototype.onPause = function () {
137
+ if (!this.autoPauseAndStart) {
138
+ return;
139
+ }
140
+
141
+ this.pauseAll();
142
+ };
143
+
144
+ SoundSystem.prototype.onDestroy = function () {
145
+ this.components.forEach(function (component) {
146
+ component.onDestroy();
147
+ });
148
+ this.components = [];
149
+
150
+ if (this.ctx) {
151
+ this.gainNode.disconnect();
152
+ this.gainNode = null;
153
+ this.ctx.close();
154
+ this.ctx = null;
155
+ }
156
+ };
157
+
158
+ SoundSystem.prototype.componentChanged = function (changed) {
159
+ return __awaiter(this, void 0, void 0, function () {
160
+ return __generator(this, function (_a) {
161
+ if (changed.componentName !== 'Sound') return [2];
162
+
163
+ if (changed.type === OBSERVER_TYPE.ADD) {
164
+ this.add(changed);
165
+ }
166
+
167
+ return [2];
168
+ });
169
+ });
170
+ };
171
+
172
+ SoundSystem.prototype.setupAudioContext = function () {
173
+ try {
174
+ var AudioContext_1 = windowAlias.AudioContext || windowAlias.webkitAudioContext;
175
+ this.ctx = new AudioContext_1();
176
+ } catch (error) {
177
+ console.error(error);
178
+
179
+ if (this.onError) {
180
+ this.onError(error);
181
+ }
182
+ }
183
+
184
+ if (!this.ctx) {
185
+ return;
186
+ }
187
+
188
+ this.gainNode = typeof this.ctx.createGain === 'undefined' ? this.ctx.createGainNode() : this.ctx.createGain();
189
+ this.gainNode.gain.setValueAtTime(this.muted ? 0 : this.volume, this.ctx.currentTime);
190
+ this.gainNode.connect(this.ctx.destination);
191
+ this.unlockAudio();
192
+ };
193
+
194
+ SoundSystem.prototype.unlockAudio = function () {
195
+ var _this = this;
196
+
197
+ if (!this.ctx || !this.audioLocked) {
198
+ return;
199
+ }
200
+
201
+ var unlock = function unlock() {
202
+ if (_this.ctx) {
203
+ var removeListenerFn = function removeListenerFn() {
204
+ documentAlias.body.removeEventListener('touchstart', unlock);
205
+ documentAlias.body.removeEventListener('touchend', unlock);
206
+ documentAlias.body.removeEventListener('click', unlock);
207
+ };
208
+
209
+ _this.ctx.resume().then(removeListenerFn, removeListenerFn);
210
+ }
211
+ };
212
+
213
+ documentAlias.body.addEventListener('touchstart', unlock);
214
+ documentAlias.body.addEventListener('touchend', unlock);
215
+ documentAlias.body.addEventListener('click', unlock);
216
+ };
217
+
218
+ SoundSystem.prototype.add = function (changed) {
219
+ var _a;
220
+
221
+ return __awaiter(this, void 0, void 0, function () {
222
+ var component, config, audio, _b, _c, error_1;
223
+
224
+ return __generator(this, function (_d) {
225
+ switch (_d.label) {
226
+ case 0:
227
+ component = changed.component;
228
+ this.components.push(component);
229
+ _d.label = 1;
230
+
231
+ case 1:
232
+ _d.trys.push([1, 5,, 6]);
233
+
234
+ config = component.config;
235
+ component.state = 'loading';
236
+ return [4, resource.getResource(config.resource)];
237
+
238
+ case 2:
239
+ audio = _d.sent();
240
+ if (!(!this.audioBufferCache[audio.name] && ((_a = audio === null || audio === void 0 ? void 0 : audio.data) === null || _a === void 0 ? void 0 : _a.audio))) return [3, 4];
241
+ _b = this.audioBufferCache;
242
+ _c = audio.name;
243
+ return [4, this.decodeAudioData(audio.data.audio, audio.name)];
244
+
245
+ case 3:
246
+ _b[_c] = _d.sent();
247
+ _d.label = 4;
248
+
249
+ case 4:
250
+ if (this.audioBufferCache[audio.name]) {
251
+ component.systemContext = this.ctx;
252
+ component.systemDestination = this.gainNode;
253
+ component.onload(this.audioBufferCache[audio.name]);
254
+ }
255
+
256
+ return [3, 6];
257
+
258
+ case 5:
259
+ error_1 = _d.sent();
260
+
261
+ if (this.onError) {
262
+ this.onError(error_1);
263
+ }
264
+
265
+ return [3, 6];
266
+
267
+ case 6:
268
+ return [2];
269
+ }
270
+ });
271
+ });
272
+ };
273
+
274
+ SoundSystem.prototype.decodeAudioData = function (arraybuffer, name) {
275
+ var _this = this;
276
+
277
+ if (this.decodeAudioPromiseMap[name]) {
278
+ return this.decodeAudioPromiseMap[name];
279
+ }
280
+
281
+ var promise = new Promise(function (resolve, reject) {
282
+ if (!_this.ctx) {
283
+ reject(new Error('No audio support'));
284
+ }
285
+
286
+ var success = function success(decodedData) {
287
+ if (_this.decodeAudioPromiseMap[name]) {
288
+ delete _this.decodeAudioPromiseMap[name];
289
+ }
290
+
291
+ if (decodedData) {
292
+ resolve(decodedData);
293
+ } else {
294
+ reject(new Error("Error decoding audio " + name));
295
+ }
296
+ };
297
+
298
+ var error = function error(err) {
299
+ if (_this.decodeAudioPromiseMap[name]) {
300
+ delete _this.decodeAudioPromiseMap[name];
301
+ }
302
+
303
+ reject(new Error(err + ". arrayBuffer byteLength: " + (arraybuffer ? arraybuffer.byteLength : 0)));
304
+ };
305
+
306
+ var promise = _this.ctx.decodeAudioData(arraybuffer, success, error);
307
+
308
+ if (promise instanceof Promise) {
309
+ promise.catch(function (err) {
310
+ reject(new Error("catch " + err + ", arrayBuffer byteLength: " + (arraybuffer ? arraybuffer.byteLength : 0)));
311
+ });
312
+ }
313
+ });
314
+ this.decodeAudioPromiseMap[name] = promise;
315
+ return promise;
316
+ };
317
+
318
+ SoundSystem.systemName = 'SoundSystem';
319
+ SoundSystem = __decorate([decorators.componentObserver({
320
+ Sound: []
321
+ })], SoundSystem);
322
+ return SoundSystem;
323
+ }(System);
324
+
325
+ var SoundSystem$1 = SoundSystem;
326
+
327
+ var Sound = function (_super) {
328
+ __extends(Sound, _super);
329
+
330
+ function Sound() {
331
+ var _this = _super !== null && _super.apply(this, arguments) || this;
332
+
333
+ _this.state = 'unloaded';
334
+ _this.config = {
335
+ resource: '',
336
+ autoplay: false,
337
+ muted: false,
338
+ volume: 1,
339
+ loop: false,
340
+ seek: 0
341
+ };
342
+ _this.playTime = 0;
343
+ _this.startTime = 0;
344
+ _this.duration = 0;
345
+ _this.actionQueue = [];
346
+ return _this;
347
+ }
348
+
349
+ Object.defineProperty(Sound.prototype, "muted", {
350
+ get: function get() {
351
+ return this.gainNode ? this.gainNode.gain.value === 0 : false;
352
+ },
353
+ set: function set(v) {
354
+ if (!this.gainNode) {
355
+ return;
356
+ }
357
+
358
+ this.gainNode.gain.setValueAtTime(v ? 0 : this.config.volume, 0);
359
+ },
360
+ enumerable: false,
361
+ configurable: true
362
+ });
363
+ Object.defineProperty(Sound.prototype, "volume", {
364
+ get: function get() {
365
+ return this.gainNode ? this.gainNode.gain.value : 1;
366
+ },
367
+ set: function set(v) {
368
+ if (typeof v !== 'number' || v < 0 || v > 1) {
369
+ return;
370
+ }
371
+
372
+ this.config.volume = v;
373
+
374
+ if (!this.gainNode) {
375
+ return;
376
+ }
377
+
378
+ this.gainNode.gain.setValueAtTime(v, 0);
379
+ },
380
+ enumerable: false,
381
+ configurable: true
382
+ });
383
+
384
+ Sound.prototype.init = function (obj) {
385
+ if (!obj) {
386
+ return;
387
+ }
388
+
389
+ _extends(this.config, obj);
390
+
391
+ if (this.config.autoplay) {
392
+ this.actionQueue.push(this.play.bind(this));
393
+ }
394
+ };
395
+
396
+ Sound.prototype.play = function () {
397
+ var _this = this;
398
+
399
+ if (this.state !== 'loaded') {
400
+ this.actionQueue.push(this.play.bind(this));
401
+ }
402
+
403
+ this.destroySource();
404
+ this.createSource();
405
+
406
+ if (!this.sourceNode) {
407
+ return;
408
+ }
409
+
410
+ var when = this.systemContext.currentTime;
411
+ var offset = this.config.seek;
412
+ var duration = this.config.duration;
413
+ this.sourceNode.start(0, offset, duration);
414
+ this.startTime = when;
415
+ this.playTime = when - offset;
416
+ this.paused = false;
417
+ this.playing = true;
418
+ this.resetConfig();
419
+
420
+ this.endedListener = function () {
421
+ if (!_this.sourceNode) {
422
+ return;
423
+ }
424
+
425
+ if (_this.config.onEnd) {
426
+ _this.config.onEnd();
427
+ }
428
+
429
+ if (_this.playing) {
430
+ _this.destroySource();
431
+ }
432
+ };
433
+
434
+ this.sourceNode.addEventListener('ended', this.endedListener);
435
+ };
436
+
437
+ Sound.prototype.pause = function () {
438
+ if (this.state !== 'loaded') {
439
+ this.actionQueue.push(this.pause.bind(this));
440
+ }
441
+
442
+ if (this.paused || !this.playing) {
443
+ return;
444
+ }
445
+
446
+ this.paused = true;
447
+ this.playing = false;
448
+ this.config.seek = this.getCurrentTime();
449
+ this.destroySource();
450
+ };
451
+
452
+ Sound.prototype.stop = function () {
453
+ if (this.state !== 'loaded') {
454
+ this.actionQueue.push(this.stop.bind(this));
455
+ }
456
+
457
+ if (!this.paused && !this.playing) {
458
+ return;
459
+ }
460
+
461
+ this.playing = false;
462
+ this.paused = false;
463
+ this.destroySource();
464
+ this.resetConfig();
465
+ };
466
+
467
+ Sound.prototype.onload = function (buffer) {
468
+ this.state = 'loaded';
469
+ this.buffer = buffer;
470
+ this.duration = this.buffer.duration;
471
+ this.actionQueue.forEach(function (action) {
472
+ return action();
473
+ });
474
+ this.actionQueue.length = 0;
475
+ };
476
+
477
+ Sound.prototype.onDestroy = function () {
478
+ this.actionQueue.length = 0;
479
+ this.destroySource();
480
+ };
481
+
482
+ Sound.prototype.resetConfig = function () {
483
+ this.config.seek = 0;
484
+ };
485
+
486
+ Sound.prototype.getCurrentTime = function () {
487
+ if (this.config.loop && this.duration > 0) {
488
+ return (this.systemContext.currentTime - this.playTime) % this.duration;
489
+ }
490
+
491
+ return this.systemContext.currentTime - this.playTime;
492
+ };
493
+
494
+ Sound.prototype.createSource = function () {
495
+ if (!this.systemContext || this.state !== 'loaded') {
496
+ return;
497
+ }
498
+
499
+ this.sourceNode = this.systemContext.createBufferSource();
500
+ this.sourceNode.buffer = this.buffer;
501
+ this.sourceNode.loop = this.config.loop;
502
+
503
+ if (!this.gainNode) {
504
+ this.gainNode = this.systemContext.createGain();
505
+ this.gainNode.connect(this.systemDestination);
506
+
507
+ _extends(this, this.config);
508
+ }
509
+
510
+ this.sourceNode.connect(this.gainNode);
511
+ };
512
+
513
+ Sound.prototype.destroySource = function () {
514
+ if (!this.sourceNode) return;
515
+ this.sourceNode.removeEventListener('ended', this.endedListener);
516
+ this.sourceNode.stop();
517
+ this.sourceNode.disconnect();
518
+ this.sourceNode = null;
519
+ this.startTime = 0;
520
+ this.playTime = 0;
521
+ this.playing = false;
522
+ };
523
+
524
+ Sound.componentName = 'Sound';
525
+ return Sound;
526
+ }(Component);
527
+
528
+ var Sound$1 = Sound;
529
+ export { Sound$1 as Sound, SoundSystem$1 as SoundSystem };
@@ -40,10 +40,6 @@ function __decorate(decorators, target, key, desc) {
40
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
41
41
  }
42
42
 
43
- function __metadata(metadataKey, metadataValue) {
44
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
45
- }
46
-
47
43
  function __awaiter(thisArg, _arguments, P, generator) {
48
44
  return new (P || (P = Promise))(function (resolve, reject) {
49
45
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -346,8 +342,7 @@ var SoundSystem = (function (_super) {
346
342
  SoundSystem = __decorate([
347
343
  eva_js.decorators.componentObserver({
348
344
  Sound: [],
349
- }),
350
- __metadata("design:paramtypes", [Object])
345
+ })
351
346
  ], SoundSystem);
352
347
  return SoundSystem;
353
348
  }(eva_js.System));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-sound.cjs.js","sources":["../lib/SoundSystem.ts","../lib/Sound.ts"],"sourcesContent":["import { System, decorators, ComponentChanged, OBSERVER_TYPE, resource } from '@eva/eva.js';\nimport SoundComponent from './Sound';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError: (error: any) => void;\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 /** 是否和游戏同步暂停和启动 */\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 get muted(): boolean {\n return this.gainNode ? this.gainNode.gain.value === 0 : false;\n }\n\n set muted(v: boolean) {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v ? 0 : 1, 0);\n }\n\n get volume(): number {\n return this.gainNode ? this.gainNode.gain.value : 1;\n }\n\n set volume(v: number) {\n if (!this.gainNode || typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v, 0);\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();\n Object.assign(this, obj);\n }\n\n /**\n * 恢复播放所有被暂停的音频\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // 清理之前缓存的暂停列表\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * 暂停所有正在播放的音频\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 * 停止所有正在播放的音频\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // 清理之前缓存的暂停列表\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System 初始化用,可以配置参数,游戏未开始\n *\n * System init, set params, game is not begain\n */\n init() {\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 * 游戏开始和游戏暂停后开始播放的时候调用。\n *\n * Called while the game to play when game pause.\n */\n onPlay() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * 游戏暂停的时候调用。\n *\n * Called while the game paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * System 被销毁的时候调用。\n * Called while the system be destroyed.\n */\n onDestroy() {\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') {\n 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.gainNode.gain.setValueAtTime(this.muted ? 0 : this.volume, this.ctx.currentTime);\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]) {\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 console.error(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 const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\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 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 this.ctx.decodeAudioData(arraybuffer, success, error);\n });\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","import { Component } from '@eva/eva.js';\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 // @ts-ignore\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n get muted(): boolean {\n return this.gainNode ? this.gainNode.gain.value === 0 : false;\n }\n\n set muted(v: boolean) {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v ? 0 : this.config.volume, 0);\n }\n\n get volume(): number {\n return this.gainNode ? this.gainNode.gain.value : 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 if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v, 0);\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 // 非交互事件播放完成需要销毁资源\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":["OBSERVER_TYPE","resource","decorators","System","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;IAA0B,+BAAM;IAiD9B,qBAAY,GAAuB;QAAnC,YACE,iBAAO,SAER;QA5CO,uBAAiB,GAAG,IAAI,CAAC;QAIzB,gBAAU,GAAqB,EAAE,CAAC;QAElC,sBAAgB,GAAqB,EAAE,CAAC;QAExC,sBAAgB,GAAG,EAAE,CAAC;QAEtB,2BAAqB,GAAG,EAAE,CAAC;QAiCjC,MAAM,CAAC,MAAM,CAAC,KAAI,EAAE,GAAG,CAAC,CAAC;;KAC1B;IAhCD,sBAAI,8BAAK;aAAT;YACE,OAAO,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC;SAC/D;aAED,UAAU,CAAU;YAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClB,OAAO;aACR;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,GAA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ClB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;KACtB;IA5LM,mBAAa,GAAG,OAAO,CAAC;IA6LjC,YAAC;CAAA,CA9LmBC,gBAAS,GA8L5B;AAED,cAAe,KAAK;;;;;"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},e(t,o)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,o)};
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -12,4 +12,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */function o(t,o){function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}function n(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function i(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{a(n.next(t))}catch(t){r(t)}}function u(t){try{a(n.throw(t))}catch(t){r(t)}}function a(t){t.done?i(t.value):new o((function(e){e(t.value)})).then(s,u)}a((n=n.apply(t,e||[])).next())}))}function r(t,e){var o,n,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function u(r){return function(u){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],n=0}finally{o=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,u])}}}var s=function(e){function s(t){var o=e.call(this)||this;return o.autoPauseAndStart=!0,o.components=[],o.pausedComponents=[],o.audioBufferCache={},o.decodeAudioPromiseMap={},Object.assign(o,t),o}return o(s,e),Object.defineProperty(s.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:1,0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){!this.gainNode||"number"!=typeof t||t<0||t>1||this.gainNode.gain.setValueAtTime(t,0)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"audioLocked",{get:function(){return!this.ctx||"running"!==this.ctx.state},enumerable:!1,configurable:!0}),s.prototype.resumeAll=function(){var t=this,e=function(){t.pausedComponents.forEach((function(t){t.play()})),t.pausedComponents=[]};this.ctx.resume().then(e,e)},s.prototype.pauseAll=function(){var t=this;this.components.forEach((function(e){e.playing&&(t.pausedComponents.push(e),e.pause())})),this.ctx.suspend().then()},s.prototype.stopAll=function(){this.components.forEach((function(t){t.playing&&t.stop()})),this.pausedComponents=[],this.ctx.suspend().then()},s.prototype.init=function(){this.setupAudioContext()},s.prototype.update=function(){var t,e,o=this.componentObserver.clear();try{for(var n=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],o=0;return e?e.call(t):{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}}}(o),i=n.next();!i.done;i=n.next()){var r=i.value;this.componentChanged(r)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},s.prototype.onResume=function(){this.autoPauseAndStart&&this.resumeAll()},s.prototype.onPause=function(){this.autoPauseAndStart&&this.pauseAll()},s.prototype.onDestroy=function(){this.components.forEach((function(t){t.onDestroy()})),this.components=[],this.ctx&&(this.gainNode.disconnect(),this.gainNode=null,this.ctx.close(),this.ctx=null)},s.prototype.componentChanged=function(e){return i(this,void 0,void 0,(function(){return r(this,(function(o){return"Sound"!==e.componentName||e.type===t.OBSERVER_TYPE.ADD&&this.add(e),[2]}))}))},s.prototype.setupAudioContext=function(){try{var 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.gainNode.gain.setValueAtTime(this.muted?0:this.volume,this.ctx.currentTime),this.gainNode.connect(this.ctx.destination),this.unlockAudio())},s.prototype.unlockAudio=function(){var t=this;if(this.ctx&&this.audioLocked){var e=function(){if(t.ctx){var o=function(){document.body.removeEventListener("touchstart",e),document.body.removeEventListener("touchend",e),document.body.removeEventListener("click",e)};t.ctx.resume().then(o,o)}};document.body.addEventListener("touchstart",e),document.body.addEventListener("touchend",e),document.body.addEventListener("click",e)}},s.prototype.add=function(e){var o;return i(this,void 0,void 0,(function(){var n,i,s,u,a,c;return r(this,(function(r){switch(r.label){case 0:n=e.component,this.components.push(n),r.label=1;case 1:return r.trys.push([1,5,,6]),i=n.config,n.state="loading",[4,t.resource.getResource(i.resource)];case 2:return s=r.sent(),this.audioBufferCache[s.name]||!(null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.audio)?[3,4]:(u=this.audioBufferCache,a=s.name,[4,this.decodeAudioData(s.data.audio,s.name)]);case 3:u[a]=r.sent(),r.label=4;case 4:return this.audioBufferCache[s.name]&&(n.systemContext=this.ctx,n.systemDestination=this.gainNode,n.onload(this.audioBufferCache[s.name])),[3,6];case 5:return c=r.sent(),this.onError&&this.onError(c),[3,6];case 6:return[2]}}))}))},s.prototype.decodeAudioData=function(t,e){var o=this;if(this.decodeAudioPromiseMap[e])return this.decodeAudioPromiseMap[e];var n=new Promise((function(n,i){o.ctx||i(new Error("No audio support"));var r=o.ctx.decodeAudioData(t,(function(t){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],t?n(t):i(new Error("Error decoding audio "+e))}),(function(n){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],i(new Error(n+". arrayBuffer byteLength: "+(t?t.byteLength:0)))}));r instanceof Promise&&r.catch((function(e){i(new Error("catch "+e+", arrayBuffer byteLength: "+(t?t.byteLength:0)))}))}));return this.decodeAudioPromiseMap[e]=n,n},s.systemName="SoundSystem",s=function(t,e,o,n){var i,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var u=t.length-1;u>=0;u--)(i=t[u])&&(s=(r<3?i(s):r>3?i(e,o,s):i(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s}([t.decorators.componentObserver({Sound:[]}),n("design:paramtypes",[Object])],s),s}(t.System),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state="unloaded",e.config={resource:"",autoplay:!1,muted:!1,volume:1,loop:!1,seek:0},e.playTime=0,e.startTime=0,e.duration=0,e.actionQueue=[],e}return o(e,t),Object.defineProperty(e.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:this.config.volume,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){"number"!=typeof t||t<0||t>1||(this.config.volume=t,this.gainNode&&this.gainNode.gain.setValueAtTime(t,0))},enumerable:!1,configurable:!0}),e.prototype.init=function(t){t&&(Object.assign(this.config,t),this.config.autoplay&&this.actionQueue.push(this.play.bind(this)))},e.prototype.play=function(){var t=this;if("loaded"!==this.state&&this.actionQueue.push(this.play.bind(this)),this.destroySource(),this.createSource(),this.sourceNode){var e=this.systemContext.currentTime,o=this.config.seek,n=this.config.duration;this.sourceNode.start(0,o,n),this.startTime=e,this.playTime=e-o,this.paused=!1,this.playing=!0,this.resetConfig(),this.endedListener=function(){t.sourceNode&&(t.config.onEnd&&t.config.onEnd(),t.playing&&t.destroySource())},this.sourceNode.addEventListener("ended",this.endedListener)}},e.prototype.pause=function(){"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())},e.prototype.stop=function(){"loaded"!==this.state&&this.actionQueue.push(this.stop.bind(this)),(this.paused||this.playing)&&(this.playing=!1,this.paused=!1,this.destroySource(),this.resetConfig())},e.prototype.onload=function(t){this.state="loaded",this.buffer=t,this.duration=this.buffer.duration,this.actionQueue.forEach((function(t){return t()})),this.actionQueue.length=0},e.prototype.onDestroy=function(){this.actionQueue.length=0,this.destroySource()},e.prototype.resetConfig=function(){this.config.seek=0},e.prototype.getCurrentTime=function(){return this.config.loop&&this.duration>0?(this.systemContext.currentTime-this.playTime)%this.duration:this.systemContext.currentTime-this.playTime},e.prototype.createSource=function(){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))},e.prototype.destroySource=function(){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)},e.componentName="Sound",e}(t.Component);exports.Sound=u,exports.SoundSystem=s;
15
+ ***************************************************************************** */function o(t,o){function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}function n(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{a(n.next(t))}catch(t){r(t)}}function u(t){try{a(n.throw(t))}catch(t){r(t)}}function a(t){t.done?i(t.value):new o((function(e){e(t.value)})).then(s,u)}a((n=n.apply(t,e||[])).next())}))}function i(t,e){var o,n,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function u(r){return function(u){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],n=0}finally{o=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,u])}}}var r=function(e){function r(t){var o=e.call(this)||this;return o.autoPauseAndStart=!0,o.components=[],o.pausedComponents=[],o.audioBufferCache={},o.decodeAudioPromiseMap={},Object.assign(o,t),o}return o(r,e),Object.defineProperty(r.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:1,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){!this.gainNode||"number"!=typeof t||t<0||t>1||this.gainNode.gain.setValueAtTime(t,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"audioLocked",{get:function(){return!this.ctx||"running"!==this.ctx.state},enumerable:!1,configurable:!0}),r.prototype.resumeAll=function(){var t=this,e=function(){t.pausedComponents.forEach((function(t){t.play()})),t.pausedComponents=[]};this.ctx.resume().then(e,e)},r.prototype.pauseAll=function(){var t=this;this.components.forEach((function(e){e.playing&&(t.pausedComponents.push(e),e.pause())})),this.ctx.suspend().then()},r.prototype.stopAll=function(){this.components.forEach((function(t){t.playing&&t.stop()})),this.pausedComponents=[],this.ctx.suspend().then()},r.prototype.init=function(){this.setupAudioContext()},r.prototype.update=function(){var t,e,o=this.componentObserver.clear();try{for(var n=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],o=0;return e?e.call(t):{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}}}(o),i=n.next();!i.done;i=n.next()){var r=i.value;this.componentChanged(r)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},r.prototype.onResume=function(){this.autoPauseAndStart&&this.resumeAll()},r.prototype.onPause=function(){this.autoPauseAndStart&&this.pauseAll()},r.prototype.onDestroy=function(){this.components.forEach((function(t){t.onDestroy()})),this.components=[],this.ctx&&(this.gainNode.disconnect(),this.gainNode=null,this.ctx.close(),this.ctx=null)},r.prototype.componentChanged=function(e){return n(this,void 0,void 0,(function(){return i(this,(function(o){return"Sound"!==e.componentName||e.type===t.OBSERVER_TYPE.ADD&&this.add(e),[2]}))}))},r.prototype.setupAudioContext=function(){try{var 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.gainNode.gain.setValueAtTime(this.muted?0:this.volume,this.ctx.currentTime),this.gainNode.connect(this.ctx.destination),this.unlockAudio())},r.prototype.unlockAudio=function(){var t=this;if(this.ctx&&this.audioLocked){var e=function(){if(t.ctx){var o=function(){document.body.removeEventListener("touchstart",e),document.body.removeEventListener("touchend",e),document.body.removeEventListener("click",e)};t.ctx.resume().then(o,o)}};document.body.addEventListener("touchstart",e),document.body.addEventListener("touchend",e),document.body.addEventListener("click",e)}},r.prototype.add=function(e){var o;return n(this,void 0,void 0,(function(){var n,r,s,u,a,c;return i(this,(function(i){switch(i.label){case 0:n=e.component,this.components.push(n),i.label=1;case 1:return i.trys.push([1,5,,6]),r=n.config,n.state="loading",[4,t.resource.getResource(r.resource)];case 2:return s=i.sent(),this.audioBufferCache[s.name]||!(null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.audio)?[3,4]:(u=this.audioBufferCache,a=s.name,[4,this.decodeAudioData(s.data.audio,s.name)]);case 3:u[a]=i.sent(),i.label=4;case 4:return this.audioBufferCache[s.name]&&(n.systemContext=this.ctx,n.systemDestination=this.gainNode,n.onload(this.audioBufferCache[s.name])),[3,6];case 5:return c=i.sent(),this.onError&&this.onError(c),[3,6];case 6:return[2]}}))}))},r.prototype.decodeAudioData=function(t,e){var o=this;if(this.decodeAudioPromiseMap[e])return this.decodeAudioPromiseMap[e];var n=new Promise((function(n,i){o.ctx||i(new Error("No audio support"));var r=o.ctx.decodeAudioData(t,(function(t){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],t?n(t):i(new Error("Error decoding audio "+e))}),(function(n){o.decodeAudioPromiseMap[e]&&delete o.decodeAudioPromiseMap[e],i(new Error(n+". arrayBuffer byteLength: "+(t?t.byteLength:0)))}));r instanceof Promise&&r.catch((function(e){i(new Error("catch "+e+", arrayBuffer byteLength: "+(t?t.byteLength:0)))}))}));return this.decodeAudioPromiseMap[e]=n,n},r.systemName="SoundSystem",r=function(t,e,o,n){var i,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var u=t.length-1;u>=0;u--)(i=t[u])&&(s=(r<3?i(s):r>3?i(e,o,s):i(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s}([t.decorators.componentObserver({Sound:[]})],r)}(t.System),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state="unloaded",e.config={resource:"",autoplay:!1,muted:!1,volume:1,loop:!1,seek:0},e.playTime=0,e.startTime=0,e.duration=0,e.actionQueue=[],e}return o(e,t),Object.defineProperty(e.prototype,"muted",{get:function(){return!!this.gainNode&&0===this.gainNode.gain.value},set:function(t){this.gainNode&&this.gainNode.gain.setValueAtTime(t?0:this.config.volume,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this.gainNode?this.gainNode.gain.value:1},set:function(t){"number"!=typeof t||t<0||t>1||(this.config.volume=t,this.gainNode&&this.gainNode.gain.setValueAtTime(t,0))},enumerable:!1,configurable:!0}),e.prototype.init=function(t){t&&(Object.assign(this.config,t),this.config.autoplay&&this.actionQueue.push(this.play.bind(this)))},e.prototype.play=function(){var t=this;if("loaded"!==this.state&&this.actionQueue.push(this.play.bind(this)),this.destroySource(),this.createSource(),this.sourceNode){var e=this.systemContext.currentTime,o=this.config.seek,n=this.config.duration;this.sourceNode.start(0,o,n),this.startTime=e,this.playTime=e-o,this.paused=!1,this.playing=!0,this.resetConfig(),this.endedListener=function(){t.sourceNode&&(t.config.onEnd&&t.config.onEnd(),t.playing&&t.destroySource())},this.sourceNode.addEventListener("ended",this.endedListener)}},e.prototype.pause=function(){"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())},e.prototype.stop=function(){"loaded"!==this.state&&this.actionQueue.push(this.stop.bind(this)),(this.paused||this.playing)&&(this.playing=!1,this.paused=!1,this.destroySource(),this.resetConfig())},e.prototype.onload=function(t){this.state="loaded",this.buffer=t,this.duration=this.buffer.duration,this.actionQueue.forEach((function(t){return t()})),this.actionQueue.length=0},e.prototype.onDestroy=function(){this.actionQueue.length=0,this.destroySource()},e.prototype.resetConfig=function(){this.config.seek=0},e.prototype.getCurrentTime=function(){return this.config.loop&&this.duration>0?(this.systemContext.currentTime-this.playTime)%this.duration:this.systemContext.currentTime-this.playTime},e.prototype.createSource=function(){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))},e.prototype.destroySource=function(){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)},e.componentName="Sound",e}(t.Component);exports.Sound=s,exports.SoundSystem=r;
@@ -36,10 +36,6 @@ function __decorate(decorators, target, key, desc) {
36
36
  return c > 3 && r && Object.defineProperty(target, key, r), r;
37
37
  }
38
38
 
39
- function __metadata(metadataKey, metadataValue) {
40
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
41
- }
42
-
43
39
  function __awaiter(thisArg, _arguments, P, generator) {
44
40
  return new (P || (P = Promise))(function (resolve, reject) {
45
41
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -342,8 +338,7 @@ var SoundSystem = (function (_super) {
342
338
  SoundSystem = __decorate([
343
339
  decorators.componentObserver({
344
340
  Sound: [],
345
- }),
346
- __metadata("design:paramtypes", [Object])
341
+ })
347
342
  ], SoundSystem);
348
343
  return SoundSystem;
349
344
  }(System));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-sound.esm.js","sources":["../lib/SoundSystem.ts","../lib/Sound.ts"],"sourcesContent":["import { System, decorators, ComponentChanged, OBSERVER_TYPE, resource } from '@eva/eva.js';\nimport SoundComponent from './Sound';\n\ninterface SoundSystemParams {\n autoPauseAndStart?: boolean;\n onError: (error: any) => void;\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 /** 是否和游戏同步暂停和启动 */\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 get muted(): boolean {\n return this.gainNode ? this.gainNode.gain.value === 0 : false;\n }\n\n set muted(v: boolean) {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v ? 0 : 1, 0);\n }\n\n get volume(): number {\n return this.gainNode ? this.gainNode.gain.value : 1;\n }\n\n set volume(v: number) {\n if (!this.gainNode || typeof v !== 'number' || v < 0 || v > 1) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v, 0);\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();\n Object.assign(this, obj);\n }\n\n /**\n * 恢复播放所有被暂停的音频\n */\n resumeAll() {\n const handleResume = () => {\n this.pausedComponents.forEach(component => {\n component.play();\n });\n // 清理之前缓存的暂停列表\n this.pausedComponents = [];\n };\n this.ctx.resume().then(handleResume, handleResume);\n }\n\n /**\n * 暂停所有正在播放的音频\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 * 停止所有正在播放的音频\n */\n stopAll() {\n this.components.forEach(component => {\n if (component.playing) {\n component.stop();\n }\n });\n // 清理之前缓存的暂停列表\n this.pausedComponents = [];\n this.ctx.suspend().then();\n }\n\n /**\n * System 初始化用,可以配置参数,游戏未开始\n *\n * System init, set params, game is not begain\n */\n init() {\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 * 游戏开始和游戏暂停后开始播放的时候调用。\n *\n * Called while the game to play when game pause.\n */\n onPlay() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.resumeAll();\n }\n\n /**\n * 游戏暂停的时候调用。\n *\n * Called while the game paused.\n */\n onPause() {\n if (!this.autoPauseAndStart) {\n return;\n }\n this.pauseAll();\n }\n\n /**\n * System 被销毁的时候调用。\n * Called while the system be destroyed.\n */\n onDestroy() {\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Sound') {\n 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.gainNode.gain.setValueAtTime(this.muted ? 0 : this.volume, this.ctx.currentTime);\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]) {\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 console.error(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 const promise = new Promise<AudioBuffer>((resolve, reject) => {\n if (!this.ctx) {\n reject(new Error('No audio support'));\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 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 this.ctx.decodeAudioData(arraybuffer, success, error);\n });\n this.decodeAudioPromiseMap[name] = promise;\n return promise;\n }\n}\n\nexport default SoundSystem;\n","import { Component } from '@eva/eva.js';\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 // @ts-ignore\n private startTime: number = 0;\n\n private duration: number = 0;\n\n private actionQueue: (() => void)[] = [];\n\n private endedListener: () => void;\n\n get muted(): boolean {\n return this.gainNode ? this.gainNode.gain.value === 0 : false;\n }\n\n set muted(v: boolean) {\n if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v ? 0 : this.config.volume, 0);\n }\n\n get volume(): number {\n return this.gainNode ? this.gainNode.gain.value : 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 if (!this.gainNode) {\n return;\n }\n this.gainNode.gain.setValueAtTime(v, 0);\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 // 非交互事件播放完成需要销毁资源\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":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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I,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;YAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACxC;IAEO,6BAAa,GAArB;QACE,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7B,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;KACtB;IA5LM,mBAAa,GAAG,OAAO,CAAC;IA6LjC,YAAC;CAAA,CA9LmB,SAAS,GA8L5B;AAED,cAAe,KAAK;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-sound",
3
- "version": "1.2.7-editor.9",
3
+ "version": "1.2.7-fix.5",
4
4
  "description": "@eva/plugin-sound",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-sound.esm.js",
@@ -18,7 +18,7 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "1.2.7-editor.9",
21
+ "@eva/eva.js": "1.2.7-fix.5",
22
22
  "eventemitter3": "^3.1.2"
23
23
  }
24
24
  }