@revues/web-sdk-core 0.0.1-beta.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/web-sdk-core.js +42 -0
- package/package.json +12 -4
- package/dist/index.min.js +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @revues/web-sdk-core
|
|
3
|
+
* (c) 2024-2024 Alex
|
|
4
|
+
* Released under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e,n,t){return e(t={path:n,exports:{},require:function(e,n){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==n&&t.path)}},t.exports),t.exports}var t=n((function(e){var n=Object.prototype.hasOwnProperty,t="~";function o(){}function r(e,n,t){this.fn=e,this.context=n,this.once=t||!1}function i(e,n,o,i,a){if("function"!=typeof o)throw new TypeError("The listener must be a function");var s=new r(o,i||e,a),u=t?t+n:n;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function a(e,n){0==--e._eventsCount?e._events=new o:delete e._events[n]}function s(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(t=!1)),s.prototype.eventNames=function(){var e,o,r=[];if(0===this._eventsCount)return r;for(o in e=this._events)n.call(e,o)&&r.push(t?o.slice(1):o);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},s.prototype.listeners=function(e){var n=t?t+e:e,o=this._events[n];if(!o)return[];if(o.fn)return[o.fn];for(var r=0,i=o.length,a=new Array(i);r<i;r++)a[r]=o[r].fn;return a},s.prototype.listenerCount=function(e){var n=t?t+e:e,o=this._events[n];return o?o.fn?1:o.length:0},s.prototype.emit=function(e,n,o,r,i,a){var s=t?t+e:e;if(!this._events[s])return!1;var u,d,c=this._events[s],l=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,n),!0;case 3:return c.fn.call(c.context,n,o),!0;case 4:return c.fn.call(c.context,n,o,r),!0;case 5:return c.fn.call(c.context,n,o,r,i),!0;case 6:return c.fn.call(c.context,n,o,r,i,a),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var p,f=c.length;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,n);break;case 3:c[d].fn.call(c[d].context,n,o);break;case 4:c[d].fn.call(c[d].context,n,o,r);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},s.prototype.on=function(e,n,t){return i(this,e,n,t,!1)},s.prototype.once=function(e,n,t){return i(this,e,n,t,!0)},s.prototype.removeListener=function(e,n,o,r){var i=t?t+e:e;if(!this._events[i])return this;if(!n)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==n||r&&!s.once||o&&s.context!==o||a(this,i);else{for(var u=0,d=[],c=s.length;u<c;u++)(s[u].fn!==n||r&&!s[u].once||o&&s[u].context!==o)&&d.push(s[u]);d.length?this._events[i]=1===d.length?d[0]:d:a(this,i)}return this},s.prototype.removeAllListeners=function(e){var n;return e?(n=t?t+e:e,this._events[n]&&a(this,n)):(this._events=new o,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=t,s.EventEmitter=s,e.exports=s})),o=function(e,n){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},o(e,n)};
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */function r(e,n){function t(){this.constructor=e}o(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}var i=function(){return i=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},i.apply(this,arguments)};function a(e,n,t,o){return new(t||(t=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,s)}u((o=o.apply(e,n||[])).next())}))}function s(e,n){var t,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function u(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o}function d(){var e=window.navigator.userAgent.toLowerCase();return/(iphone|ipad)/.test(e)?"IOS":/android/.test(e)?"Android":"Windows For HUYA"}function c(){var e=d();return"IOS"===e||"Android"===e}function l(e){var n=e.split("?"),t=n[0],o=n[1],r={};return null!=o&&""!==o&&o.split("&").reduce((function(e,n){var t=n.split("=");return e[t[0]]=decodeURIComponent(t[1]),e}),r),{path:t,query:r}}function p(e){for(var n="",t=new Uint8Array(e),o=t.byteLength,r=0;r<o;r++)n+=String.fromCharCode(t[r]);return window.btoa(n)}function f(e){return new Promise((function(n){setTimeout(n,e)}))}var _=function(e,n,t){var o,r=new Promise((function(n,r){o=setTimeout((function(){t&&t(e),r(new Error("Timed out in "+e+"ms."))}),e)}));return new Promise((function(e,t){Promise.race([n,r]).then((function(n){clearTimeout(o),e(n)})).catch(t)}))};var v=function(e){return 1===String(e).length?"0"+e:e},h=location.pathname.split("/"),m=h.slice(1,h.length-1),w=location.protocol+"//"+location.host+"/"+m.join("/")+"/",g=w+"view.html",y=null==window.__debug||window.__debug,b="service",A="view",T=window.__packageExtConfig,I={path:T?T.entryPagePath:"index",query:{},referrerInfo:{},scene:1001},k="onTaskProgressUpdate",x="onTaskHeadersReceived",S="miniGame",P="hyfile://";function M(e,n,t){var o=new XMLHttpRequest,r=!0;if(null!=n.sync&&(r=!n.sync),null!=n.responseType&&(o.responseType=n.responseType),o.open("GET",e,r),null!=n.header)for(var i in n.header)o.setRequestHeader(i,n.header[i]);o.onload=function(e){t(null,o.response,{e:e,xhr:o})},o.onerror=function(e){t(new Error("request settings failed!"),null,{e:e,xhr:o})},o.send(null)}var C={};var B=function(){function e(e){this.sync=!1,this.events=new t,this.el=e,this.isReady=!1}return e.prototype.getWindow=function(){return this.el.contentWindow},e.prototype.getBridge=function(){},e.prototype.emitSync=function(e){for(var n,t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];this.sync=!0,(n=this.events).emit.apply(n,u([e],t)),this.sync=!1},e}(),E={onViewDOMContentLoaded:"onViewDOMContentLoaded",onInjectHTMLCallback:"onInjectHTMLCallback"},L={};var O=function(e){function n(n){return e.call(this,n)||this}return r(n,e),n.prototype.sendToSerivce=function(e,n,t){y&&console.log("%c "+e,"color: blue;",n,t),this.getBridge().subscribeHandler(e,n,t)},n.prototype.loadSubBundle=function(e,n){if(!0!==L[e]){var t=this.getWindow();null!=t&&(t.injectHtml(t.document.body,{content:'<script charset="utf-8" src="'+n+'"><\/script>'}),L[e]=!0)}},n.prototype.invokeCallbackHandler=function(e,n,t){y&&console.log("%c "+(t||"API")+" call callback","color: blue;",e,n),this.getBridge().invokeCallbackHandler(e,n)},n.prototype.getBridge=function(){return this.getWindow().ServiceJSBridge},n}(B),H="webview-service",D=new Map;function F(e){var n=D.get(e);if(n)return n;var t=document.getElementById(e);if(null!=t){var o=new(e===H?O:ze)(t);return D.set(e,o),o}throw new Error("获取IframeManager失败, id: "+e)}function V(){return F(H)}function W(e,n,t){Ze.stack.forEach((function(o){null!=o.webviewId&&t.indexOf(o.webviewId)>-1&&(o.isReady?o.sendToView(e,n):console.error("shouldn't exctute"))}))}function N(e,n,t){F(H).sendToSerivce(e,n,t)}function j(e,n){var t,o=null===(t=Ze.currPage)||void 0===t?void 0:t.children;if(Array.isArray(o)&&o.length>0){var r=o[0];r&&r.isWebView&&r.postMessageToWebView({eventName:e,type:"subscribeHandler",params:n})}}var R=null;function G(){if(null==R)throw new Error("AdapterTarget is not set yet.");return R}var q="custom_event_";var U=n((function(n,t){
|
|
21
|
+
/*!
|
|
22
|
+
* howler.js v2.2.4
|
|
23
|
+
* howlerjs.com
|
|
24
|
+
*
|
|
25
|
+
* (c) 2013-2020, James Simpson of GoldFire Studios
|
|
26
|
+
* goldfirestudios.com
|
|
27
|
+
*
|
|
28
|
+
* MIT License
|
|
29
|
+
*/
|
|
30
|
+
!function(){var n=function(){this.init()};n.prototype={init:function(){var e=this||o;return e._counter=1e3,e._html5AudioPool=[],e.html5PoolSize=10,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.autoUnlock=!0,e._setup(),e},volume:function(e){var n=this||o;if(e=parseFloat(e),n.ctx||l(),void 0!==e&&e>=0&&e<=1){if(n._volume=e,n._muted)return n;n.usingWebAudio&&n.masterGain.gain.setValueAtTime(e,o.ctx.currentTime);for(var t=0;t<n._howls.length;t++)if(!n._howls[t]._webAudio)for(var r=n._howls[t]._getSoundIds(),i=0;i<r.length;i++){var a=n._howls[t]._soundById(r[i]);a&&a._node&&(a._node.volume=a._volume*e)}return n}return n._volume},mute:function(e){var n=this||o;n.ctx||l(),n._muted=e,n.usingWebAudio&&n.masterGain.gain.setValueAtTime(e?0:n._volume,o.ctx.currentTime);for(var t=0;t<n._howls.length;t++)if(!n._howls[t]._webAudio)for(var r=n._howls[t]._getSoundIds(),i=0;i<r.length;i++){var a=n._howls[t]._soundById(r[i]);a&&a._node&&(a._node.muted=!!e||a._muted)}return n},stop:function(){for(var e=this||o,n=0;n<e._howls.length;n++)e._howls[n].stop();return e},unload:function(){for(var e=this||o,n=e._howls.length-1;n>=0;n--)e._howls[n].unload();return e.usingWebAudio&&e.ctx&&void 0!==e.ctx.close&&(e.ctx.close(),e.ctx=null,l()),e},codecs:function(e){return(this||o)._codecs[e.replace(/^x-/,"")]},_setup:function(){var e=this||o;if(e.state=e.ctx&&e.ctx.state||"suspended",e._autoSuspend(),!e.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(e._canPlayEvent="canplay")}catch(n){e.noAudio=!0}else e.noAudio=!0;try{(new Audio).muted&&(e.noAudio=!0)}catch(e){}return e.noAudio||e._setupCodecs(),e},_setupCodecs:function(){var e=this||o,n=null;try{n="undefined"!=typeof Audio?new Audio:null}catch(n){return e}if(!n||"function"!=typeof n.canPlayType)return e;var t=n.canPlayType("audio/mpeg;").replace(/^no$/,""),r=e._navigator?e._navigator.userAgent:"",i=r.match(/OPR\/(\d+)/g),a=i&&parseInt(i[0].split("/")[1],10)<33,s=-1!==r.indexOf("Safari")&&-1===r.indexOf("Chrome"),u=r.match(/Version\/(.*?) /),d=s&&u&&parseInt(u[1],10)<15;return e._codecs={mp3:!(a||!t&&!n.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!t,opus:!!n.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!n.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!n.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(n.canPlayType('audio/wav; codecs="1"')||n.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!n.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!n.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(n.canPlayType("audio/x-m4a;")||n.canPlayType("audio/m4a;")||n.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(n.canPlayType("audio/x-m4b;")||n.canPlayType("audio/m4b;")||n.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(n.canPlayType("audio/x-mp4;")||n.canPlayType("audio/mp4;")||n.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(d||!n.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(d||!n.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!n.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(n.canPlayType("audio/x-flac;")||n.canPlayType("audio/flac;")).replace(/^no$/,"")},e},_unlockAudio:function(){var e=this||o;if(!e._audioUnlocked&&e.ctx){e._audioUnlocked=!1,e.autoUnlock=!1,e._mobileUnloaded||44100===e.ctx.sampleRate||(e._mobileUnloaded=!0,e.unload()),e._scratchBuffer=e.ctx.createBuffer(1,1,22050);var n=function(t){for(;e._html5AudioPool.length<e.html5PoolSize;)try{var o=new Audio;o._unlocked=!0,e._releaseHtml5Audio(o)}catch(t){e.noAudio=!0;break}for(var r=0;r<e._howls.length;r++)if(!e._howls[r]._webAudio)for(var i=e._howls[r]._getSoundIds(),a=0;a<i.length;a++){var s=e._howls[r]._soundById(i[a]);s&&s._node&&!s._node._unlocked&&(s._node._unlocked=!0,s._node.load())}e._autoResume();var u=e.ctx.createBufferSource();u.buffer=e._scratchBuffer,u.connect(e.ctx.destination),void 0===u.start?u.noteOn(0):u.start(0),"function"==typeof e.ctx.resume&&e.ctx.resume(),u.onended=function(){u.disconnect(0),e._audioUnlocked=!0,document.removeEventListener("touchstart",n,!0),document.removeEventListener("touchend",n,!0),document.removeEventListener("click",n,!0),document.removeEventListener("keydown",n,!0);for(var t=0;t<e._howls.length;t++)e._howls[t]._emit("unlock")}};return document.addEventListener("touchstart",n,!0),document.addEventListener("touchend",n,!0),document.addEventListener("click",n,!0),document.addEventListener("keydown",n,!0),e}},_obtainHtml5Audio:function(){var e=this||o;if(e._html5AudioPool.length)return e._html5AudioPool.pop();var n=(new Audio).play();return n&&"undefined"!=typeof Promise&&(n instanceof Promise||"function"==typeof n.then)&&n.catch((function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")})),new Audio},_releaseHtml5Audio:function(e){var n=this||o;return e._unlocked&&n._html5AudioPool.push(e),n},_autoSuspend:function(){var e=this;if(e.autoSuspend&&e.ctx&&void 0!==e.ctx.suspend&&o.usingWebAudio){for(var n=0;n<e._howls.length;n++)if(e._howls[n]._webAudio)for(var t=0;t<e._howls[n]._sounds.length;t++)if(!e._howls[n]._sounds[t]._paused)return e;return e._suspendTimer&&clearTimeout(e._suspendTimer),e._suspendTimer=setTimeout((function(){if(e.autoSuspend){e._suspendTimer=null,e.state="suspending";var n=function(){e.state="suspended",e._resumeAfterSuspend&&(delete e._resumeAfterSuspend,e._autoResume())};e.ctx.suspend().then(n,n)}}),3e4),e}},_autoResume:function(){var e=this;if(e.ctx&&void 0!==e.ctx.resume&&o.usingWebAudio)return"running"===e.state&&"interrupted"!==e.ctx.state&&e._suspendTimer?(clearTimeout(e._suspendTimer),e._suspendTimer=null):"suspended"===e.state||"running"===e.state&&"interrupted"===e.ctx.state?(e.ctx.resume().then((function(){e.state="running";for(var n=0;n<e._howls.length;n++)e._howls[n]._emit("resume")})),e._suspendTimer&&(clearTimeout(e._suspendTimer),e._suspendTimer=null)):"suspending"===e.state&&(e._resumeAfterSuspend=!0),e}};var o=new n,r=function(e){e.src&&0!==e.src.length?this.init(e):console.error("An array of source files must be passed with any new Howl.")};r.prototype={init:function(e){var n=this;return o.ctx||l(),n._autoplay=e.autoplay||!1,n._format="string"!=typeof e.format?e.format:[e.format],n._html5=e.html5||!1,n._muted=e.mute||!1,n._loop=e.loop||!1,n._pool=e.pool||5,n._preload="boolean"!=typeof e.preload&&"metadata"!==e.preload||e.preload,n._rate=e.rate||1,n._sprite=e.sprite||{},n._src="string"!=typeof e.src?e.src:[e.src],n._volume=void 0!==e.volume?e.volume:1,n._xhr={method:e.xhr&&e.xhr.method?e.xhr.method:"GET",headers:e.xhr&&e.xhr.headers?e.xhr.headers:null,withCredentials:!(!e.xhr||!e.xhr.withCredentials)&&e.xhr.withCredentials},n._duration=0,n._state="unloaded",n._sounds=[],n._endTimers={},n._queue=[],n._playLock=!1,n._onend=e.onend?[{fn:e.onend}]:[],n._onfade=e.onfade?[{fn:e.onfade}]:[],n._onload=e.onload?[{fn:e.onload}]:[],n._onloaderror=e.onloaderror?[{fn:e.onloaderror}]:[],n._onplayerror=e.onplayerror?[{fn:e.onplayerror}]:[],n._onpause=e.onpause?[{fn:e.onpause}]:[],n._onplay=e.onplay?[{fn:e.onplay}]:[],n._onstop=e.onstop?[{fn:e.onstop}]:[],n._onmute=e.onmute?[{fn:e.onmute}]:[],n._onvolume=e.onvolume?[{fn:e.onvolume}]:[],n._onrate=e.onrate?[{fn:e.onrate}]:[],n._onseek=e.onseek?[{fn:e.onseek}]:[],n._onunlock=e.onunlock?[{fn:e.onunlock}]:[],n._onresume=[],n._webAudio=o.usingWebAudio&&!n._html5,void 0!==o.ctx&&o.ctx&&o.autoUnlock&&o._unlockAudio(),o._howls.push(n),n._autoplay&&n._queue.push({event:"play",action:function(){n.play()}}),n._preload&&"none"!==n._preload&&n.load(),n},load:function(){var e=this,n=null;if(o.noAudio)e._emit("loaderror",null,"No audio support.");else{"string"==typeof e._src&&(e._src=[e._src]);for(var t=0;t<e._src.length;t++){var r,a;if(e._format&&e._format[t])r=e._format[t];else{if("string"!=typeof(a=e._src[t])){e._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}(r=/^data:audio\/([^;,]+);/i.exec(a))||(r=/\.([^.]+)$/.exec(a.split("?",1)[0])),r&&(r=r[1].toLowerCase())}if(r||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),r&&o.codecs(r)){n=e._src[t];break}}if(n)return e._src=n,e._state="loading","https:"===window.location.protocol&&"http:"===n.slice(0,5)&&(e._html5=!0,e._webAudio=!1),new i(e),e._webAudio&&s(e),e;e._emit("loaderror",null,"No codec support for selected audio sources.")}},play:function(e,n){var t=this,r=null;if("number"==typeof e)r=e,e=null;else{if("string"==typeof e&&"loaded"===t._state&&!t._sprite[e])return null;if(void 0===e&&(e="__default",!t._playLock)){for(var i=0,a=0;a<t._sounds.length;a++)t._sounds[a]._paused&&!t._sounds[a]._ended&&(i++,r=t._sounds[a]._id);1===i?e=null:r=null}}var s=r?t._soundById(r):t._inactiveSound();if(!s)return null;if(r&&!e&&(e=s._sprite||"__default"),"loaded"!==t._state){s._sprite=e,s._ended=!1;var u=s._id;return t._queue.push({event:"play",action:function(){t.play(u)}}),u}if(r&&!s._paused)return n||t._loadQueue("play"),s._id;t._webAudio&&o._autoResume();var d=Math.max(0,s._seek>0?s._seek:t._sprite[e][0]/1e3),c=Math.max(0,(t._sprite[e][0]+t._sprite[e][1])/1e3-d),l=1e3*c/Math.abs(s._rate),p=t._sprite[e][0]/1e3,f=(t._sprite[e][0]+t._sprite[e][1])/1e3;s._sprite=e,s._ended=!1;var _=function(){s._paused=!1,s._seek=d,s._start=p,s._stop=f,s._loop=!(!s._loop&&!t._sprite[e][2])};if(!(d>=f)){var v=s._node;if(t._webAudio){var h=function(){t._playLock=!1,_(),t._refreshBuffer(s);var e=s._muted||t._muted?0:s._volume;v.gain.setValueAtTime(e,o.ctx.currentTime),s._playStart=o.ctx.currentTime,void 0===v.bufferSource.start?s._loop?v.bufferSource.noteGrainOn(0,d,86400):v.bufferSource.noteGrainOn(0,d,c):s._loop?v.bufferSource.start(0,d,86400):v.bufferSource.start(0,d,c),l!==1/0&&(t._endTimers[s._id]=setTimeout(t._ended.bind(t,s),l)),n||setTimeout((function(){t._emit("play",s._id),t._loadQueue()}),0)};"running"===o.state&&"interrupted"!==o.ctx.state?h():(t._playLock=!0,t.once("resume",h),t._clearTimer(s._id))}else{var m=function(){v.currentTime=d,v.muted=s._muted||t._muted||o._muted||v.muted,v.volume=s._volume*o.volume(),v.playbackRate=s._rate;try{var r=v.play();if(r&&"undefined"!=typeof Promise&&(r instanceof Promise||"function"==typeof r.then)?(t._playLock=!0,_(),r.then((function(){t._playLock=!1,v._unlocked=!0,n?t._loadQueue():t._emit("play",s._id)})).catch((function(){t._playLock=!1,t._emit("playerror",s._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),s._ended=!0,s._paused=!0}))):n||(t._playLock=!1,_(),t._emit("play",s._id)),v.playbackRate=s._rate,v.paused)return void t._emit("playerror",s._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==e||s._loop?t._endTimers[s._id]=setTimeout(t._ended.bind(t,s),l):(t._endTimers[s._id]=function(){t._ended(s),v.removeEventListener("ended",t._endTimers[s._id],!1)},v.addEventListener("ended",t._endTimers[s._id],!1))}catch(e){t._emit("playerror",s._id,e)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===v.src&&(v.src=t._src,v.load());var w=window&&window.ejecta||!v.readyState&&o._navigator.isCocoonJS;if(v.readyState>=3||w)m();else{t._playLock=!0,t._state="loading";var g=function(){t._state="loaded",m(),v.removeEventListener(o._canPlayEvent,g,!1)};v.addEventListener(o._canPlayEvent,g,!1),t._clearTimer(s._id)}}return s._id}t._ended(s)},pause:function(e){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"pause",action:function(){n.pause(e)}}),n;for(var t=n._getSoundIds(e),o=0;o<t.length;o++){n._clearTimer(t[o]);var r=n._soundById(t[o]);if(r&&!r._paused&&(r._seek=n.seek(t[o]),r._rateSeek=0,r._paused=!0,n._stopFade(t[o]),r._node))if(n._webAudio){if(!r._node.bufferSource)continue;void 0===r._node.bufferSource.stop?r._node.bufferSource.noteOff(0):r._node.bufferSource.stop(0),n._cleanBuffer(r._node)}else isNaN(r._node.duration)&&r._node.duration!==1/0||r._node.pause();arguments[1]||n._emit("pause",r?r._id:null)}return n},stop:function(e,n){var t=this;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"stop",action:function(){t.stop(e)}}),t;for(var o=t._getSoundIds(e),r=0;r<o.length;r++){t._clearTimer(o[r]);var i=t._soundById(o[r]);i&&(i._seek=i._start||0,i._rateSeek=0,i._paused=!0,i._ended=!0,t._stopFade(o[r]),i._node&&(t._webAudio?i._node.bufferSource&&(void 0===i._node.bufferSource.stop?i._node.bufferSource.noteOff(0):i._node.bufferSource.stop(0),t._cleanBuffer(i._node)):isNaN(i._node.duration)&&i._node.duration!==1/0||(i._node.currentTime=i._start||0,i._node.pause(),i._node.duration===1/0&&t._clearSound(i._node))),n||t._emit("stop",i._id))}return t},mute:function(e,n){var t=this;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"mute",action:function(){t.mute(e,n)}}),t;if(void 0===n){if("boolean"!=typeof e)return t._muted;t._muted=e}for(var r=t._getSoundIds(n),i=0;i<r.length;i++){var a=t._soundById(r[i]);a&&(a._muted=e,a._interval&&t._stopFade(a._id),t._webAudio&&a._node?a._node.gain.setValueAtTime(e?0:a._volume,o.ctx.currentTime):a._node&&(a._node.muted=!!o._muted||e),t._emit("mute",a._id))}return t},volume:function(){var e,n,t,r=this,i=arguments;if(0===i.length)return r._volume;if(1===i.length||2===i.length&&void 0===i[1]?r._getSoundIds().indexOf(i[0])>=0?n=parseInt(i[0],10):e=parseFloat(i[0]):i.length>=2&&(e=parseFloat(i[0]),n=parseInt(i[1],10)),!(void 0!==e&&e>=0&&e<=1))return(t=n?r._soundById(n):r._sounds[0])?t._volume:0;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,i)}}),r;void 0===n&&(r._volume=e),n=r._getSoundIds(n);for(var a=0;a<n.length;a++)(t=r._soundById(n[a]))&&(t._volume=e,i[2]||r._stopFade(n[a]),r._webAudio&&t._node&&!t._muted?t._node.gain.setValueAtTime(e,o.ctx.currentTime):t._node&&!t._muted&&(t._node.volume=e*o.volume()),r._emit("volume",t._id));return r},fade:function(e,n,t,r){var i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"fade",action:function(){i.fade(e,n,t,r)}}),i;e=Math.min(Math.max(0,parseFloat(e)),1),n=Math.min(Math.max(0,parseFloat(n)),1),t=parseFloat(t),i.volume(e,r);for(var a=i._getSoundIds(r),s=0;s<a.length;s++){var u=i._soundById(a[s]);if(u){if(r||i._stopFade(a[s]),i._webAudio&&!u._muted){var d=o.ctx.currentTime,c=d+t/1e3;u._volume=e,u._node.gain.setValueAtTime(e,d),u._node.gain.linearRampToValueAtTime(n,c)}i._startFadeInterval(u,e,n,t,a[s],void 0===r)}}return i},_startFadeInterval:function(e,n,t,o,r,i){var a=this,s=n,u=t-n,d=Math.abs(u/.01),c=Math.max(4,d>0?o/d:o),l=Date.now();e._fadeTo=t,e._interval=setInterval((function(){var r=(Date.now()-l)/o;l=Date.now(),s+=u*r,s=Math.round(100*s)/100,s=u<0?Math.max(t,s):Math.min(t,s),a._webAudio?e._volume=s:a.volume(s,e._id,!0),i&&(a._volume=s),(t<n&&s<=t||t>n&&s>=t)&&(clearInterval(e._interval),e._interval=null,e._fadeTo=null,a.volume(t,e._id),a._emit("fade",e._id))}),c)},_stopFade:function(e){var n=this,t=n._soundById(e);return t&&t._interval&&(n._webAudio&&t._node.gain.cancelScheduledValues(o.ctx.currentTime),clearInterval(t._interval),t._interval=null,n.volume(t._fadeTo,e),t._fadeTo=null,n._emit("fade",e)),n},loop:function(){var e,n,t,o=this,r=arguments;if(0===r.length)return o._loop;if(1===r.length){if("boolean"!=typeof r[0])return!!(t=o._soundById(parseInt(r[0],10)))&&t._loop;e=r[0],o._loop=e}else 2===r.length&&(e=r[0],n=parseInt(r[1],10));for(var i=o._getSoundIds(n),a=0;a<i.length;a++)(t=o._soundById(i[a]))&&(t._loop=e,o._webAudio&&t._node&&t._node.bufferSource&&(t._node.bufferSource.loop=e,e&&(t._node.bufferSource.loopStart=t._start||0,t._node.bufferSource.loopEnd=t._stop,o.playing(i[a])&&(o.pause(i[a],!0),o.play(i[a],!0)))));return o},rate:function(){var e,n,t,r=this,i=arguments;if(0===i.length)n=r._sounds[0]._id;else if(1===i.length){r._getSoundIds().indexOf(i[0])>=0?n=parseInt(i[0],10):e=parseFloat(i[0])}else 2===i.length&&(e=parseFloat(i[0]),n=parseInt(i[1],10));if("number"!=typeof e)return(t=r._soundById(n))?t._rate:r._rate;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,i)}}),r;void 0===n&&(r._rate=e),n=r._getSoundIds(n);for(var a=0;a<n.length;a++)if(t=r._soundById(n[a])){r.playing(n[a])&&(t._rateSeek=r.seek(n[a]),t._playStart=r._webAudio?o.ctx.currentTime:t._playStart),t._rate=e,r._webAudio&&t._node&&t._node.bufferSource?t._node.bufferSource.playbackRate.setValueAtTime(e,o.ctx.currentTime):t._node&&(t._node.playbackRate=e);var s=r.seek(n[a]),u=1e3*((r._sprite[t._sprite][0]+r._sprite[t._sprite][1])/1e3-s)/Math.abs(t._rate);!r._endTimers[n[a]]&&t._paused||(r._clearTimer(n[a]),r._endTimers[n[a]]=setTimeout(r._ended.bind(r,t),u)),r._emit("rate",t._id)}return r},seek:function(){var e,n,t=this,r=arguments;if(0===r.length)t._sounds.length&&(n=t._sounds[0]._id);else if(1===r.length){t._getSoundIds().indexOf(r[0])>=0?n=parseInt(r[0],10):t._sounds.length&&(n=t._sounds[0]._id,e=parseFloat(r[0]))}else 2===r.length&&(e=parseFloat(r[0]),n=parseInt(r[1],10));if(void 0===n)return 0;if("number"==typeof e&&("loaded"!==t._state||t._playLock))return t._queue.push({event:"seek",action:function(){t.seek.apply(t,r)}}),t;var i=t._soundById(n);if(i){if(!("number"==typeof e&&e>=0)){if(t._webAudio){var a=t.playing(n)?o.ctx.currentTime-i._playStart:0,s=i._rateSeek?i._rateSeek-i._seek:0;return i._seek+(s+a*Math.abs(i._rate))}return i._node.currentTime}var u=t.playing(n);u&&t.pause(n,!0),i._seek=e,i._ended=!1,t._clearTimer(n),t._webAudio||!i._node||isNaN(i._node.duration)||(i._node.currentTime=e);var d=function(){u&&t.play(n,!0),t._emit("seek",n)};if(u&&!t._webAudio){var c=function(){t._playLock?setTimeout(c,0):d()};setTimeout(c,0)}else d()}return t},playing:function(e){var n=this;if("number"==typeof e){var t=n._soundById(e);return!!t&&!t._paused}for(var o=0;o<n._sounds.length;o++)if(!n._sounds[o]._paused)return!0;return!1},duration:function(e){var n=this,t=n._duration,o=n._soundById(e);return o&&(t=n._sprite[o._sprite][1]/1e3),t},state:function(){return this._state},unload:function(){for(var e=this,n=e._sounds,t=0;t<n.length;t++)n[t]._paused||e.stop(n[t]._id),e._webAudio||(e._clearSound(n[t]._node),n[t]._node.removeEventListener("error",n[t]._errorFn,!1),n[t]._node.removeEventListener(o._canPlayEvent,n[t]._loadFn,!1),n[t]._node.removeEventListener("ended",n[t]._endFn,!1),o._releaseHtml5Audio(n[t]._node)),delete n[t]._node,e._clearTimer(n[t]._id);var r=o._howls.indexOf(e);r>=0&&o._howls.splice(r,1);var i=!0;for(t=0;t<o._howls.length;t++)if(o._howls[t]._src===e._src||e._src.indexOf(o._howls[t]._src)>=0){i=!1;break}return a&&i&&delete a[e._src],o.noAudio=!1,e._state="unloaded",e._sounds=[],e=null,null},on:function(e,n,t,o){var r=this["_on"+e];return"function"==typeof n&&r.push(o?{id:t,fn:n,once:o}:{id:t,fn:n}),this},off:function(e,n,t){var o=this,r=o["_on"+e],i=0;if("number"==typeof n&&(t=n,n=null),n||t)for(i=0;i<r.length;i++){var a=t===r[i].id;if(n===r[i].fn&&a||!n&&a){r.splice(i,1);break}}else if(e)o["_on"+e]=[];else{var s=Object.keys(o);for(i=0;i<s.length;i++)0===s[i].indexOf("_on")&&Array.isArray(o[s[i]])&&(o[s[i]]=[])}return o},once:function(e,n,t){return this.on(e,n,t,1),this},_emit:function(e,n,t){for(var o=this,r=o["_on"+e],i=r.length-1;i>=0;i--)r[i].id&&r[i].id!==n&&"load"!==e||(setTimeout(function(e){e.call(this,n,t)}.bind(o,r[i].fn),0),r[i].once&&o.off(e,r[i].fn,r[i].id));return o._loadQueue(e),o},_loadQueue:function(e){var n=this;if(n._queue.length>0){var t=n._queue[0];t.event===e&&(n._queue.shift(),n._loadQueue()),e||t.action()}return n},_ended:function(e){var n=this,t=e._sprite;if(!n._webAudio&&e._node&&!e._node.paused&&!e._node.ended&&e._node.currentTime<e._stop)return setTimeout(n._ended.bind(n,e),100),n;var r=!(!e._loop&&!n._sprite[t][2]);if(n._emit("end",e._id),!n._webAudio&&r&&n.stop(e._id,!0).play(e._id),n._webAudio&&r){n._emit("play",e._id),e._seek=e._start||0,e._rateSeek=0,e._playStart=o.ctx.currentTime;var i=1e3*(e._stop-e._start)/Math.abs(e._rate);n._endTimers[e._id]=setTimeout(n._ended.bind(n,e),i)}return n._webAudio&&!r&&(e._paused=!0,e._ended=!0,e._seek=e._start||0,e._rateSeek=0,n._clearTimer(e._id),n._cleanBuffer(e._node),o._autoSuspend()),n._webAudio||r||n.stop(e._id,!0),n},_clearTimer:function(e){var n=this;if(n._endTimers[e]){if("function"!=typeof n._endTimers[e])clearTimeout(n._endTimers[e]);else{var t=n._soundById(e);t&&t._node&&t._node.removeEventListener("ended",n._endTimers[e],!1)}delete n._endTimers[e]}return n},_soundById:function(e){for(var n=this,t=0;t<n._sounds.length;t++)if(e===n._sounds[t]._id)return n._sounds[t];return null},_inactiveSound:function(){var e=this;e._drain();for(var n=0;n<e._sounds.length;n++)if(e._sounds[n]._ended)return e._sounds[n].reset();return new i(e)},_drain:function(){var e=this,n=e._pool,t=0,o=0;if(!(e._sounds.length<n)){for(o=0;o<e._sounds.length;o++)e._sounds[o]._ended&&t++;for(o=e._sounds.length-1;o>=0;o--){if(t<=n)return;e._sounds[o]._ended&&(e._webAudio&&e._sounds[o]._node&&e._sounds[o]._node.disconnect(0),e._sounds.splice(o,1),t--)}}},_getSoundIds:function(e){if(void 0===e){for(var n=[],t=0;t<this._sounds.length;t++)n.push(this._sounds[t]._id);return n}return[e]},_refreshBuffer:function(e){return e._node.bufferSource=o.ctx.createBufferSource(),e._node.bufferSource.buffer=a[this._src],e._panner?e._node.bufferSource.connect(e._panner):e._node.bufferSource.connect(e._node),e._node.bufferSource.loop=e._loop,e._loop&&(e._node.bufferSource.loopStart=e._start||0,e._node.bufferSource.loopEnd=e._stop||0),e._node.bufferSource.playbackRate.setValueAtTime(e._rate,o.ctx.currentTime),this},_cleanBuffer:function(e){var n=o._navigator&&o._navigator.vendor.indexOf("Apple")>=0;if(!e.bufferSource)return this;if(o._scratchBuffer&&e.bufferSource&&(e.bufferSource.onended=null,e.bufferSource.disconnect(0),n))try{e.bufferSource.buffer=o._scratchBuffer}catch(e){}return e.bufferSource=null,this},_clearSound:function(e){/MSIE |Trident\//.test(o._navigator&&o._navigator.userAgent)||(e.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var i=function(e){this._parent=e,this.init()};i.prototype={init:function(){var e=this,n=e._parent;return e._muted=n._muted,e._loop=n._loop,e._volume=n._volume,e._rate=n._rate,e._seek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++o._counter,n._sounds.push(e),e.create(),e},create:function(){var e=this,n=e._parent,t=o._muted||e._muted||e._parent._muted?0:e._volume;return n._webAudio?(e._node=void 0===o.ctx.createGain?o.ctx.createGainNode():o.ctx.createGain(),e._node.gain.setValueAtTime(t,o.ctx.currentTime),e._node.paused=!0,e._node.connect(o.masterGain)):o.noAudio||(e._node=o._obtainHtml5Audio(),e._errorFn=e._errorListener.bind(e),e._node.addEventListener("error",e._errorFn,!1),e._loadFn=e._loadListener.bind(e),e._node.addEventListener(o._canPlayEvent,e._loadFn,!1),e._endFn=e._endListener.bind(e),e._node.addEventListener("ended",e._endFn,!1),e._node.src=n._src,e._node.preload=!0===n._preload?"auto":n._preload,e._node.volume=t*o.volume(),e._node.load()),e},reset:function(){var e=this,n=e._parent;return e._muted=n._muted,e._loop=n._loop,e._volume=n._volume,e._rate=n._rate,e._seek=0,e._rateSeek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++o._counter,e},_errorListener:function(){var e=this;e._parent._emit("loaderror",e._id,e._node.error?e._node.error.code:0),e._node.removeEventListener("error",e._errorFn,!1)},_loadListener:function(){var e=this,n=e._parent;n._duration=Math.ceil(10*e._node.duration)/10,0===Object.keys(n._sprite).length&&(n._sprite={__default:[0,1e3*n._duration]}),"loaded"!==n._state&&(n._state="loaded",n._emit("load"),n._loadQueue()),e._node.removeEventListener(o._canPlayEvent,e._loadFn,!1)},_endListener:function(){var e=this,n=e._parent;n._duration===1/0&&(n._duration=Math.ceil(10*e._node.duration)/10,n._sprite.__default[1]===1/0&&(n._sprite.__default[1]=1e3*n._duration),n._ended(e)),e._node.removeEventListener("ended",e._endFn,!1)}};var a={},s=function(e){var n=e._src;if(a[n])return e._duration=a[n].duration,void c(e);if(/^data:[^;]+;base64,/.test(n)){for(var t=atob(n.split(",")[1]),o=new Uint8Array(t.length),r=0;r<t.length;++r)o[r]=t.charCodeAt(r);d(o.buffer,e)}else{var i=new XMLHttpRequest;i.open(e._xhr.method,n,!0),i.withCredentials=e._xhr.withCredentials,i.responseType="arraybuffer",e._xhr.headers&&Object.keys(e._xhr.headers).forEach((function(n){i.setRequestHeader(n,e._xhr.headers[n])})),i.onload=function(){var n=(i.status+"")[0];"0"===n||"2"===n||"3"===n?d(i.response,e):e._emit("loaderror",null,"Failed loading audio file with status: "+i.status+".")},i.onerror=function(){e._webAudio&&(e._html5=!0,e._webAudio=!1,e._sounds=[],delete a[n],e.load())},u(i)}},u=function(e){try{e.send()}catch(n){e.onerror()}},d=function(e,n){var t=function(){n._emit("loaderror",null,"Decoding audio data failed.")},r=function(e){e&&n._sounds.length>0?(a[n._src]=e,c(n,e)):t()};"undefined"!=typeof Promise&&1===o.ctx.decodeAudioData.length?o.ctx.decodeAudioData(e).then(r).catch(t):o.ctx.decodeAudioData(e,r,t)},c=function(e,n){n&&!e._duration&&(e._duration=n.duration),0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue())},l=function(){if(o.usingWebAudio){try{"undefined"!=typeof AudioContext?o.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?o.ctx=new webkitAudioContext:o.usingWebAudio=!1}catch(e){o.usingWebAudio=!1}o.ctx||(o.usingWebAudio=!1);var e=/iP(hone|od|ad)/.test(o._navigator&&o._navigator.platform),n=o._navigator&&o._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),t=n?parseInt(n[1],10):null;if(e&&t&&t<9){var r=/safari/.test(o._navigator&&o._navigator.userAgent.toLowerCase());o._navigator&&!r&&(o.usingWebAudio=!1)}o.usingWebAudio&&(o.masterGain=void 0===o.ctx.createGain?o.ctx.createGainNode():o.ctx.createGain(),o.masterGain.gain.setValueAtTime(o._muted?0:o._volume,o.ctx.currentTime),o.masterGain.connect(o.ctx.destination)),o._setup()}};t.Howler=o,t.Howl=r,void 0!==e?(e.HowlerGlobal=n,e.Howler=o,e.Howl=r,e.Sound=i):"undefined"!=typeof window&&(window.HowlerGlobal=n,window.Howler=o,window.Howl=r,window.Sound=i)}(),
|
|
31
|
+
/*!
|
|
32
|
+
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
|
|
33
|
+
*
|
|
34
|
+
* howler.js v2.2.4
|
|
35
|
+
* howlerjs.com
|
|
36
|
+
*
|
|
37
|
+
* (c) 2013-2020, James Simpson of GoldFire Studios
|
|
38
|
+
* goldfirestudios.com
|
|
39
|
+
*
|
|
40
|
+
* MIT License
|
|
41
|
+
*/
|
|
42
|
+
function(){var e;HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(e){var n=this;if(!n.ctx||!n.ctx.listener)return n;for(var t=n._howls.length-1;t>=0;t--)n._howls[t].stereo(e);return n},HowlerGlobal.prototype.pos=function(e,n,t){var o=this;return o.ctx&&o.ctx.listener?(n="number"!=typeof n?o._pos[1]:n,t="number"!=typeof t?o._pos[2]:t,"number"!=typeof e?o._pos:(o._pos=[e,n,t],void 0!==o.ctx.listener.positionX?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]),o)):o},HowlerGlobal.prototype.orientation=function(e,n,t,o,r,i){var a=this;if(!a.ctx||!a.ctx.listener)return a;var s=a._orientation;return n="number"!=typeof n?s[1]:n,t="number"!=typeof t?s[2]:t,o="number"!=typeof o?s[3]:o,r="number"!=typeof r?s[4]:r,i="number"!=typeof i?s[5]:i,"number"!=typeof e?s:(a._orientation=[e,n,t,o,r,i],void 0!==a.ctx.listener.forwardX?(a.ctx.listener.forwardX.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(i,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(e,n,t,o,r,i),a)},Howl.prototype.init=(e=Howl.prototype.init,function(n){var t=this;return t._orientation=n.orientation||[1,0,0],t._stereo=n.stereo||null,t._pos=n.pos||null,t._pannerAttr={coneInnerAngle:void 0!==n.coneInnerAngle?n.coneInnerAngle:360,coneOuterAngle:void 0!==n.coneOuterAngle?n.coneOuterAngle:360,coneOuterGain:void 0!==n.coneOuterGain?n.coneOuterGain:0,distanceModel:void 0!==n.distanceModel?n.distanceModel:"inverse",maxDistance:void 0!==n.maxDistance?n.maxDistance:1e4,panningModel:void 0!==n.panningModel?n.panningModel:"HRTF",refDistance:void 0!==n.refDistance?n.refDistance:1,rolloffFactor:void 0!==n.rolloffFactor?n.rolloffFactor:1},t._onstereo=n.onstereo?[{fn:n.onstereo}]:[],t._onpos=n.onpos?[{fn:n.onpos}]:[],t._onorientation=n.onorientation?[{fn:n.onorientation}]:[],e.call(this,n)}),Howl.prototype.stereo=function(e,t){var o=this;if(!o._webAudio)return o;if("loaded"!==o._state)return o._queue.push({event:"stereo",action:function(){o.stereo(e,t)}}),o;var r=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===t){if("number"!=typeof e)return o._stereo;o._stereo=e,o._pos=[e,0,0]}for(var i=o._getSoundIds(t),a=0;a<i.length;a++){var s=o._soundById(i[a]);if(s){if("number"!=typeof e)return s._stereo;s._stereo=e,s._pos=[e,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",s._panner&&s._panner.pan||n(s,r),"spatial"===r?void 0!==s._panner.positionX?(s._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(e,0,0):s._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),o._emit("stereo",s._id)}}return o},Howl.prototype.pos=function(e,t,o,r){var i=this;if(!i._webAudio)return i;if("loaded"!==i._state)return i._queue.push({event:"pos",action:function(){i.pos(e,t,o,r)}}),i;if(t="number"!=typeof t?0:t,o="number"!=typeof o?-.5:o,void 0===r){if("number"!=typeof e)return i._pos;i._pos=[e,t,o]}for(var a=i._getSoundIds(r),s=0;s<a.length;s++){var u=i._soundById(a[s]);if(u){if("number"!=typeof e)return u._pos;u._pos=[e,t,o],u._node&&(u._panner&&!u._panner.pan||n(u,"spatial"),void 0!==u._panner.positionX?(u._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(o,Howler.ctx.currentTime)):u._panner.setPosition(e,t,o)),i._emit("pos",u._id)}}return i},Howl.prototype.orientation=function(e,t,o,r){var i=this;if(!i._webAudio)return i;if("loaded"!==i._state)return i._queue.push({event:"orientation",action:function(){i.orientation(e,t,o,r)}}),i;if(t="number"!=typeof t?i._orientation[1]:t,o="number"!=typeof o?i._orientation[2]:o,void 0===r){if("number"!=typeof e)return i._orientation;i._orientation=[e,t,o]}for(var a=i._getSoundIds(r),s=0;s<a.length;s++){var u=i._soundById(a[s]);if(u){if("number"!=typeof e)return u._orientation;u._orientation=[e,t,o],u._node&&(u._panner||(u._pos||(u._pos=i._pos||[0,0,-.5]),n(u,"spatial")),void 0!==u._panner.orientationX?(u._panner.orientationX.setValueAtTime(e,Howler.ctx.currentTime),u._panner.orientationY.setValueAtTime(t,Howler.ctx.currentTime),u._panner.orientationZ.setValueAtTime(o,Howler.ctx.currentTime)):u._panner.setOrientation(e,t,o)),i._emit("orientation",u._id)}}return i},Howl.prototype.pannerAttr=function(){var e,t,o,r=this,i=arguments;if(!r._webAudio)return r;if(0===i.length)return r._pannerAttr;if(1===i.length){if("object"!=typeof i[0])return(o=r._soundById(parseInt(i[0],10)))?o._pannerAttr:r._pannerAttr;e=i[0],void 0===t&&(e.pannerAttr||(e.pannerAttr={coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}),r._pannerAttr={coneInnerAngle:void 0!==e.pannerAttr.coneInnerAngle?e.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:void 0!==e.pannerAttr.coneOuterAngle?e.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:void 0!==e.pannerAttr.coneOuterGain?e.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:void 0!==e.pannerAttr.distanceModel?e.pannerAttr.distanceModel:r._distanceModel,maxDistance:void 0!==e.pannerAttr.maxDistance?e.pannerAttr.maxDistance:r._maxDistance,refDistance:void 0!==e.pannerAttr.refDistance?e.pannerAttr.refDistance:r._refDistance,rolloffFactor:void 0!==e.pannerAttr.rolloffFactor?e.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:void 0!==e.pannerAttr.panningModel?e.pannerAttr.panningModel:r._panningModel})}else 2===i.length&&(e=i[0],t=parseInt(i[1],10));for(var a=r._getSoundIds(t),s=0;s<a.length;s++)if(o=r._soundById(a[s])){var u=o._pannerAttr;u={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:u.coneInnerAngle,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:u.coneOuterAngle,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:u.coneOuterGain,distanceModel:void 0!==e.distanceModel?e.distanceModel:u.distanceModel,maxDistance:void 0!==e.maxDistance?e.maxDistance:u.maxDistance,refDistance:void 0!==e.refDistance?e.refDistance:u.refDistance,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:u.rolloffFactor,panningModel:void 0!==e.panningModel?e.panningModel:u.panningModel};var d=o._panner;d||(o._pos||(o._pos=r._pos||[0,0,-.5]),n(o,"spatial"),d=o._panner),d.coneInnerAngle=u.coneInnerAngle,d.coneOuterAngle=u.coneOuterAngle,d.coneOuterGain=u.coneOuterGain,d.distanceModel=u.distanceModel,d.maxDistance=u.maxDistance,d.refDistance=u.refDistance,d.rolloffFactor=u.rolloffFactor,d.panningModel=u.panningModel}return r},Sound.prototype.init=function(e){return function(){var n=this,t=n._parent;n._orientation=t._orientation,n._stereo=t._stereo,n._pos=t._pos,n._pannerAttr=t._pannerAttr,e.call(this),n._stereo?t.stereo(n._stereo):n._pos&&t.pos(n._pos[0],n._pos[1],n._pos[2],n._id)}}(Sound.prototype.init),Sound.prototype.reset=function(e){return function(){var n=this,t=n._parent;return n._orientation=t._orientation,n._stereo=t._stereo,n._pos=t._pos,n._pannerAttr=t._pannerAttr,n._stereo?t.stereo(n._stereo):n._pos?t.pos(n._pos[0],n._pos[1],n._pos[2],n._id):n._panner&&(n._panner.disconnect(0),n._panner=void 0,t._refreshBuffer(n)),e.call(this)}}(Sound.prototype.reset);var n=function(e,n){"spatial"===(n=n||"spatial")?(e._panner=Howler.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,void 0!==e._panner.positionX?(e._panner.positionX.setValueAtTime(e._pos[0],Howler.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],Howler.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],Howler.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),void 0!==e._panner.orientationX?(e._panner.orientationX.setValueAtTime(e._orientation[0],Howler.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],Howler.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],Howler.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=Howler.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,Howler.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}}()}));function $(e,n,t){F(H).invokeCallbackHandler(e,n,t)}function X(e,n,t){var o,r=null===(o=Ze.currPage)||void 0===o?void 0:o.children;if(Array.isArray(r)&&r.length>0){var i=r[0];i&&i.isWebView&&i.postMessageToWebView({callbackId:e,type:"webInvokeCallbackHandler",params:n})}}var Y={},z={};function J(e,n){var t=Y[e],o=z[e];return null!=t?""!=n.src&&o!=n.src?(t.unload(),delete Y[e],delete z[e],J(e,n)):t:(z[e]=n.src,Y[e]=function(e,n){var t=new U.Howl({autoplay:e.autoplay,loop:e.loop,src:e.src,rate:e.playbackRate,onend:function(){N(K,{innerAudioContextId:n,method:Z.onEnded,data:{}})},onplay:function(){N(K,{innerAudioContextId:n,method:Z.onPlay,data:{buffered:0,currentTime:0,duration:0}})},onpause:function(e){N(K,{innerAudioContextId:e,method:Z.onPause,data:{}})},onstop:function(){N(K,{innerAudioContextId:n,method:Z.onStop,data:{}})},onseek:function(){N(K,{innerAudioContextId:n,method:Z.onSeeked,data:{}})},onplayerror:function(e,n){N(K,{innerAudioContextId:e,method:Z.onError,data:{errMsg:"播放失败 :"+n,errCode:-1}})},onloaderror:function(e,n){N(K,{innerAudioContextId:e,method:Z.onError,data:{errMsg:"播放失败 :"+n,errCode:10002}})}});return t}(n,e))}function Q(e,n,t){var o=Y[n];if(null==o){var r=e+":fail 无法找到innerAudioContextId:"+n+"对应的audio实例";throw $(t,{errMsg:r}),new Error(r)}return o}U.Howler.autoSuspend=!1;var Z={onCanplay:"onCanplay",onEnded:"onEnded",onError:"onError",onPause:"onPause",onPlay:"onPlay",onSeeked:"onSeeked",onSeeking:"onSeeking",onStop:"onStop",onTimeUpdate:"onTimeUpdate",onWaiting:"onWaiting"},K="onInnerAudio";var ee={innerAudio:function(e,n){var t,o=e.method,r=e.data,i=e.innerAudioContextId;switch(o){case"create":break;case"play":(t=J(i,r)).loop(r.loop),t.volume(r.volume),r.isPlayMethod&&t.play();break;case"stop":Q(o,i,n).stop();break;case"seek":(t=Q(o,i,n)).seek(r.position);break;case"pause":Q(o,i,n).pause();break;case"destroy":Q(o,i,n).unload();break;default:throw new Error("无法处理音频method:"+o)}return{errMsg:"innerAudio:ok"}}};function ne(e){return/^http(s?)\:\/\//.test(e)}var te={readFileSync:function(e){var n,t=e.filePath;if(t.startsWith(P))return{data:null,errMsg:"readFileSync:fail not support local file."};t=ne(t=(n=t).endsWith(".wasm")?n+".txt":n)?t:w+t;var o=null,r=null;return M(t,{sync:!0},(function(e,n){o=n,r=e})),null!=o?{data:o,errMsg:"readFileSync:ok"}:null!=r?{data:null,errMsg:"readFileSync:fail "+r.message}:{data:null,errMsg:"readFileSync:fail"}},readFile:function(e,n){var t=e.filePath,o="base64"===e.encoding,r=ne(t)?t:w+t;t.startsWith(P)?$(n,{errMsg:"readFile:fail not support local file: "+t}):M(r,{responseType:o?"arraybuffer":""},(function(e,t){$(n,null==e?{data:o?p(t):t,errMsg:"readFile:ok"}:{errMsg:"readFile:fail "+e.message})}))},access:function(){return{errMsg:"access:ok"}},mkdirSync:function(){return{errMsg:"mkdirSync:ok"}},writeFile:function(){return{errMsg:"writeFile:ok"}},writeFileSync:function(e){return e.filePath,e.data,{errMsg:"writeFileSync:ok"}},unlink:function(e,n){return e.filePath,{errMsg:"unlink:ok"}},downloadFile:function(e,n){var t=e.url,o=e.timeout,r=void 0===o?6e3:o;e.taskId,e.header,e.filePath,_(r,function(e){var n=e.url,t=e.callbackId;return e.filePath,e.header,a(this,void 0,void 0,(function(){return s(this,(function(e){return N(k,{cookies:[],progress:100,totalBytesExpectedToWrite:100,totalBytesWritten:100}),N(x,{cookies:[],header:{}}),$(t,{filePath:n,tempFilePath:n,profile:[],statusCode:200,errMsg:"downloadFile:ok"}),[2]}))}))}({url:t,callbackId:n}),(function(e){$(n,{errMsg:"downloadFile:fail timeout in "+e+"ms."})}))},copyFile:function(e,n){return e.srcPath,e.destPath,$(n,{errMsg:"copyFile:ok fake subpport."},"copyFile")}};var oe=new(function(){function e(){this.reportedEventType=new Set(["ErrorType"])}return Object.defineProperty(e.prototype,"sentry",{get:function(){return window.Sentry},enumerable:!1,configurable:!0}),e.prototype.captureException=function(e,n){var t=this.sentry;null!=t?t.captureException(e,{extra:n,level:"error"}):console.log("Sentry is not ready yet.")},e}()),re=null;function ie(){if(null==re)throw new Error("WxConfig is not ready.");return re}var ae=new t;function se(){ae.on("NavigatorBarTools:onMore",(function(){Ge.showToast({title:"暂未实现该功能"})})),ae.on("NavigatorBarTools:onClose",(function(){var e=G();null!=e&&e.invokeHandler({callbackId:-1,apiName:"exitMiniProgram",params:{},from:"service"})})),ae.on("NavigatorBar:onBack",(function(){we.navigateBack({delta:1}),console.log("onBack")})),ae.on("TabBar:change",(function(e){var n,t,o,r;N("onTabItemTap",{index:e.index,pagePath:e.item.pagePath,text:e.item.text}),we.switchTab({url:e.item.pagePath},-1),n=e.item.pagePath,t={},o=n,null!=(r=ie().windows.pages)&&r[o]&&(t.windowConfig=r[o]),ae.emit("tabItemChanged",t)})),ae.on("invokeCallbackHandler",(function(e){$(e.callbackId,e.data)}))}function ue(e){void 0!==window.__initWebFrame&&window.__initWebFrame(e,ae)}var de={getGlobalVariables:function(e){return"_launchOption"===e.variable?{_launchOption:I}:null},reportApmMonitor:function(e){var n=e.eventName,t=e.payload,o=e.eventType;oe.reportedEventType.has(o)&&oe.captureException(n,t)},addPerformance:function(){},initReady:function(){},updateAppData:function(){},injectHtmlCallback:function(e,n,t){"service"===t&&V().events.emit(E.onInjectHTMLCallback)},pageScrollTo:function(e,n){var t=e.scrollTop;e.duration;var o=Ze.currPage.getWindow();return null==o||o.scrollTo({top:t,behavior:"smooth"}),{errMsg:"pageScrollTo:ok"}},getMenuButtonBoundingClientRect:function(e,n){ae.emit("getMenuButtonBoundingClientRect",e,n)},getAccountInfoSync:function(){var e=window.__extInfo;return{data:{miniProgram:{appId:null==e?void 0:e.extUuid,envVersion:null==e?void 0:e.envVersion,version:""},plugin:{appId:"",version:""}}}},jssdkConfig:function(e,n){var t=e.jsApiList,o=[];if((void 0===t?[]:t).forEach((function(e){null==Ge[e]&&o.push(e)})),!(o.length>0))return X(n,{errMsg:"jssdkConfig:ok"});X(n,{errMsg:"jssdkConfig:fail "+o.join(",")+" 未实现."})}},ce={hideToast:function(e){return ae.emit("hideToast",e),{errMsg:"hideToast:ok"}},showToast:function(e){return ae.emit("showToast",e),{errMsg:"showToast:ok"}},showLoading:function(e){return ae.emit("showLoading",e),{errMsg:"showLoading:ok"}},hideLoading:function(e){return ae.emit("hideLoading",e),{errMsg:"hideLoading:ok"}},showModal:function(e,n){ae.emit("showModal",e,n)},showActionSheet:function(e,n){ae.emit("showActionSheet",e,n)}};function le(e,n){if(e===S)return'<script charset="utf-8" src="'+n.moduleName+'game.js"><\/script>';if("miniProgram"===e)return n.content;throw Error("unsupported projectType: "+e)}var pe=function(e){function n(n){return e.call(this,i(i({},n),{projectType:S}))||this}return r(n,e),n.prototype.injectScript=function(){var e=F(H).getWindow();e.injectHtml(e.document.body,{content:le(this.projectType,{moduleName:this.moduleName})})},n.prototype.getEntry=function(){return e=this.projectType,n={moduleName:this.moduleName},e===S?n.moduleName+"game.js":"";var e,n},n}(function(){function e(e){this.taskId=e.taskId,this.moduleName=e.moduleName,this.projectType=e.projectType,this.status="none"}return e.prototype.notifyProgressUpdate=function(e,n){N("onLoadSubPackageTaskStateChange",i({moduleName:this.moduleName,state:e,taskId:this.taskId},n))},e.prototype.injectScript=function(){},e.prototype.getEntry=function(){},e.prototype.load=function(){return a(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.notifyProgressUpdate("progressUpdate",{progress:0}),[4,f(15)];case 1:return e.sent(),this.notifyProgressUpdate("progressUpdate",{progress:50}),[4,f(30)];case 2:return e.sent(),this.injectScript(),this.notifyProgressUpdate("progressUpdate",{progress:100}),[4,f(15)];case 3:return e.sent(),this.status="success",this.notifyProgressUpdate("success",{entryPath:this.getEntry()}),[2]}}))}))},e}()),fe=0,_e={},ve={createLoadSubPackageTask:function(e){var n=e.moduleName,t=_e[n];if(t&&"success"===t.status)return{errMsg:"createLoadSubPackageTask:fail sub package already loaded."};++fe;var o=String(fe);return t=new pe({taskId:o,moduleName:n}),_e[n]=t,t.load(),{errMsg:"createLoadSubPackageTask:ok",loadTaskId:o}}},he={showNavigationBarLoading:function(){return ae.emit("showNavigationBarLoading"),{errMsg:"showNavigationBarLoading:ok"}},setNavigationBarTitle:function(e){return ae.emit("setNavigationBarTitle",e),{errMsg:"setNavigationBarTitle:ok"}},setNavigationBarColor:function(e){return ae.emit("setNavigationBarColor",e),{errMsg:"setNavigationBarColor:ok"}},hideNavigationBarLoading:function(){return ae.emit("hideNavigationBarLoading"),{errMsg:"hideNavigationBarLoading:ok"}},hideHomeButton:function(){}};function me(e,n){var t,o=function(e){e=e.replace(/\.html$/,"");var n=ie(),t=n.subpackages;if(Array.isArray(t)&&t.length>0)return t.find((function(n){return n.pageFullPath.includes(e)}));return null}(e);null==o||(t=o.root,L[t])?n():function(e,n){var t=F(H);t.events.once(E.onInjectHTMLCallback,n),t.loadSubBundle(e.root,e.packageName+".js")}(o,n)}var we={navigateTo:function(e,n){var t=e.url;if(Ze.stack.length>10)return{errMsg:"navigateTo:fail 已到达页面栈上限:10。"};var o=l(t),r=o.path,i=o.query;return me(r,(function(){var e=Ze.go(r);V().events.once(E.onViewDOMContentLoaded,(function(){N("onAppRoute",{path:r,openType:"navigateTo",options:void 0,pipMode:"",query:i,webviewId:e.webviewId},e.webviewId)}))})),{errMsg:"navigateTo:ok"}},navigateBack:function(e){var n=e.delta;try{Ze.back(n)}catch(e){return{errMsg:"navigateBack:fail "+e.message}}var t=Ze.currPage;return N("onAppRoute",{path:t.pagePath,openType:"navigateBack",options:{delta:n},pipMode:"",query:void 0,webviewId:t.webviewId},t.webviewId),{errMsg:"navigateBack:ok"}},reLaunch:function(e,n){var t=e.url,o=l(t),r=o.path,i=o.query;me(r,(function(){Ze.reLaunch(t);var e=Ze.currPage;V().events.once(E.onViewDOMContentLoaded,(function(){N("onAppRoute",{path:r,openType:"reLaunch",options:void 0,pipMode:"",query:i,webviewId:e.webviewId},e.webviewId),$(n,{errMsg:"reLaunch:ok"})}))}))},redirectTo:function(e,n){var t=l(e.url),o=t.path,r=t.query;me(o,(function(){try{Ze.redirectTo(o)}catch(e){return void $(n,{errMsg:"redirectTo:fail "+e.message})}var e=Ze.currPage;V().events.once(E.onViewDOMContentLoaded,(function(){N("onAppRoute",{path:o,openType:"redirectTo",options:void 0,pipMode:"",query:r,webviewId:e.webviewId},e.webviewId),$(n,{errMsg:"redirectTo:ok"})}))}))},switchTab:function(e,n){var t=l(e.url),o=t.path,r=t.query;me(o,(function(){try{Ze.switch(o)}catch(e){return void $(n,{errMsg:"switchTab:fail "+e.message})}var e=Ze.currPage;e.isReady?(N("onAppRoute",{path:o,openType:"switchTab",options:void 0,pipMode:"",query:r,webviewId:e.webviewId},e.webviewId),$(n,{errMsg:"switchTab:ok"})):V().events.once(E.onViewDOMContentLoaded,(function(){N("onAppRoute",{path:o,openType:"switchTab",options:void 0,pipMode:"",query:r,webviewId:e.webviewId},e.webviewId),$(n,{errMsg:"switchTab:ok"})}))}))}};function ge(e){setTimeout(e,17)}function ye(e){return Number((e/1024).toFixed(2))}var be={getStorageSync:function(e){var n=localStorage.getItem(e.key);try{return JSON.parse(n)}catch(e){return n}},getStorage:function(e,n){ge((function(){$(n,{data:be.getStorageSync(e)})}))},setStorageSync:function(e){return localStorage.setItem(e.key,e.data),{errMsg:"setStorageSync:ok"}},setStorage:function(e,n){ge((function(){localStorage.setItem(e.key,e.data),$(n,{errMsg:"setStorage:ok"})}))},removeStorageSync:function(e){return localStorage.removeItem(e.key),{errMsg:"removeStorageSync:ok"}},removeStorage:function(e,n){ge((function(){localStorage.removeItem(e.key),$(n,{errMsg:"removeStorage:ok"})}))},clearStorageSync:function(){return localStorage.clear(),{errMsg:"clearStorageSync:ok"}},clearStorage:function(e,n){ge((function(){localStorage.clear(),$(n,{errMsg:"clearStorage:ok"})}))},getStorageInfoSync:function(){var e=function(){var e=0,n=[];for(var t in localStorage)Object.prototype.hasOwnProperty.call(localStorage,t)&&(e+=localStorage[t].length,n.push(t));return{size:e,keys:n}}(),n=e.size;return{keys:e.keys,currentSize:ye(n),limitSize:ye(10485760)}},getStorageInfo:function(e,n){ge((function(){$(n,i(i({},be.getStorageInfoSync()),{errMsg:"getStorageInfo:ok"}))}))}};function Ae(e){return G().invokeHandler({callbackId:-1,apiName:e.apiName,params:e.params,from:"service"})}function Te(){return window.__extInfo||{}}var Ie=Date.now();var ke=function(e){var n=e.onBefore,t=e.onAfter,o=e.prefix,r=e.logColor,i=e.enableLog,a=void 0===i||i,s=Object.assign({info:"blue",warn:"orange",error:"red",log:"green"},r);function u(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];var r=e[0],i=e[1],s=e[2],u=d(),c={prefix:u,msg:i,data:s,desc:u+i};n&&n(c),("function"==typeof a?a(c):a)&&console.log("%c "+c.desc,"color: "+r+";",c.data),t&&t(c)}function d(){return"function"==typeof o?o():o||""}return{log:function(e,n){u(s.log,e,n,"log")},info:function(e,n){u(s.info,e,n,"info")},warn:function(e,n){u(s.warn,e,n,"warn")},error:function(e,n){u(s.error,e,n,"error")}}}({onAfter:function(e){null!=window.hyExt&&window.hyExt.logger.info(e.desc+" "+function(e){try{return JSON.stringify(e)}catch(e){return"stringify error"}}(e.data))},prefix:function(){return"web-sdk-core * date:"+(void 0===e&&(e=new Date),v(e.getHours())+":"+v(e.getMinutes())+":"+v(e.getSeconds())+" extUuid:")+Te().extUuid+" sessionId:"+Ie+" -";var e},enableLog:function(){return"develop"===Te().envVersion}});function xe(){var e=d();return("Android"===e||"IOS"===e)&&window.matchMedia("(orientation: portrait)").matches?"portrait":"landscape"}function Se(){var e,n,t,o=null===(e=Ze.currPage)||void 0===e?void 0:e.getWindow();if(null!=o){var r=o.document;return(null===(n=r.documentElement)||void 0===n?void 0:n.scrollTop)||(null===(t=r.body)||void 0===t?void 0:t.scrollTop)||0}return 0}function Pe(){return i(i({patch:!0},(e=window.innerWidth||390,n=window.innerHeight||844,t=d().toLocaleLowerCase().includes("window")?0:50,{screenWidth:e,screenHeight:n,statusBarHeight:t,devicePixelRatio:o=750/e,pixelRatio:o,windowHeight:n,windowWidth:e,safeArea:{height:n-t,widows:e,top:t,left:0,right:0}})),{scrollY:Se()});var e,n,t,o}var Me={onMemoryWarning:function(){console.error("The onMemoryWarning api is not implement.")},showShareMenu:function(){console.error("The showShareMenu api is not implement.")},getSystemInfoSync:function(){var e=Ce(),n=xe(),t=d();return ke.log("getSystemInfoSync",{windowInfo:e,deviceOrientation:n,system:t}),i({deviceOrientation:n,SDKVersion:"2.26.0",appVersion:"2.37.0",batteryLevel:98,benchmarkLevel:1,bluetoothEnabled:!1,brand:"huya",cameraAuthorized:!0,deviceId:"none",enableDebug:!0,fontSizeSetting:15,frameworkVersion:"0.0.1",inHUYA:!0,language:"zh_CN",locationAuthorized:!0,locationEnabled:!0,microphoneAuthorized:!0,mode:"default",model:"none",notificationAuthorized:!0,platform:"huya",system:t,theme:void 0,version:"8.0.28 "},e)},getWindowInfo:function(){return Ce()}};function Ce(){return c()?Ae({apiName:"getWindowInfo",params:{}}):Pe()}var Be={showTabBar:function(e){return ae.emit("showTabBar",e),{errMsg:"showTabBar:ok"}},hideTabBar:function(e){return ae.emit("hideTabBar",e),{errMsg:"hideTabBar:ok"}},setTabBarStyle:function(e){return ae.emit("setTabBarStyle",e),{errMsg:"setTabBarStyle:ok"}},setTabBarItem:function(e){return ae.emit("setTabBarItem",e),{errMsg:"setTabBarItem:ok"}},setTabBarBadge:function(e){return ae.emit("setTabBarBadge",e),{errMsg:"setTabBarBadge:ok"}},removeTabBarBadge:function(e){return ae.emit("removeTabBarBadge",e),{errMsg:"removeTabBarBadge:ok"}},hideTabBarRedDot:function(e){return ae.emit("hideTabBarRedDot",e),{errMsg:"hideTabBarRedDot:ok"}},showTabBarRedDot:function(e){return ae.emit("showTabBarRedDot",e),{errMsg:"showTabBarRedDot:ok"}}},Ee="insertHTMLWebView",Le="onWebviewLoad",Oe={insertHTMLWebView:function(e,n,t,o){Ze.initNextWebView(Ze.currPage,e.src,e.src).el.addEventListener("load",(function(){N(Le,{webviewId:o},o),j(q+"pageonshow",{})})),N(Ee,e,o)},invokeMiniProgramAPI:function(e,n){console.log(e,n);var t=e.name,o=e.arg,r=Ge[t];null!=r&&r(o,n)},postMessage:function(e,n){N("onBindMessage",e,Ze.currPage.webviewId),X(n,{errMsg:"postMessage:ok"})}},He={appDataChange:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):(!function(e){var n=i({},e.data),t=ie(),o=n.options.path,r=t.windows.pages;null!=r&&r[o]&&(n.windowConfig=r[o]),n.pages=Ze.allPages,ae.emit("appDataChange",n)}(n),W(r,n,o))},__updateAppData:function(e){!function(){var e={},n=ie(),t=Ze.currPage.pagePath.replace(/\.html$/,""),o=n.windows.pages;null!=o&&o[t]&&(e.windowConfig=o[t]),e.pages=Ze.allPages,e.currPage=t,ae.emit("updateAppData",e)}()}};var De={canvasInsert:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},canvasRemove:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},CANVAS_EVENT_V2:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},onCanvasPreloadImage:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},onCanvasGetImageData:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},onCanvasPutImageData:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},canvasActionsChanged:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},invokeCanvasToDataUrl:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},invokeCanvasPutImageData:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},invokeCanvasGetImageData:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},getImageBase64:function(e){var n=e.params;e.from,e.webviewIds;var t,o=e.event,r=e.webviewId,i=n.src;M(/^https?:\/\//.test(t=i)||/^hyfile:\/\//.test(t)?t:w+t,{responseType:"arraybuffer"},(function(e,n){if(null!=e)return"";var t=p(n),a=function(e){var n,t=e.split("/"),o=null===(n=t[t.length-1])||void 0===n?void 0:n.split("."),r=o[0],i=o[1];if(null==i||""==i)throw new Error("url:"+e+"格式错误,无法获取文件信息");return{filename:r,ext:i}}(i);W(o,{src:i,data:"data:image/"+a.ext+";base64,"+t},[r])}))}};var Fe={serviceStart:function(e){var n;n=e.params,re=n;var t=e.params;!function(e){var n=function(e){var n=e.tabBar;return null==n||0===(n.list||[]).length?[e.root]:n.list.map((function(e){return e.pagePath}))}(e);Ze.initFirstPage(n,e.root)}(t),ae.emit("serviceStart",t),ue({wxConfig:t,windowInfo:Ge.getWindowInfo()})},onLaunchCalled:function(e){},serviceReady:function(e){var n=e.params,t=e.webviewIds,o=V(),r=t[0];o.isReady||(Ze.initSlotWebviewId(r),o.events.once(E.onViewDOMContentLoaded,(function(){N("onAppRoute",{path:n.root,openType:"appLaunch",options:void 0,pipMode:"",query:void 0,webviewId:r},r)})),N("onServiceReadyDone",i(i({},I),{webviewId:r}),r),o.isReady=!0)},DOMContentLoaded:function(e){e.params;var n=e.from;e.webviewIds,e.event,e.webviewId;var t=F(H);n===A?(N("DOMContentLoaded",{},Ze.currPage.webviewId),t.events.emit(E.onViewDOMContentLoaded)):console.error("not implement for "+n),ae.emit("closeLaunchMask")},viewReady:function(){var e=Ze.currPage;null!=e&&(e.isReady=!0,e.injectScript(),e.show())},DOMReady:function(){}},Ve={info:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},log:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},initLogs:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},clearLogs:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},onViewLogEvent:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)}},We={INVOKE_METHOD:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},pageonshow:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},pageonhide:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):(W(r,n,o),j(r,n))},requestLoadFontFace:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},requestLoadGlobalFontFaces:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},responseLoadGlobalFontFaces:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)}},Ne={SPECIAL_PAGE_EVENT:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},setKeyboardValue:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)},PAGE_EVENT:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},vdSync:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event,i=e.webviewId;t===A?N(r,n,i):W(r,n,o)},vdSyncBatch:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event,i=e.webviewId;t===A?N(r,n,i):W(r,n,o)}},je={videoPlayerInsertFinish:function(e){var n=e.params,t=e.from;e.webviewIds;var o=e.event,r=e.webviewId;t===A?N(o,n,r):console.error("not implement for "+t)},videoActionChanged:function(e){var n=e.params,t=e.from,o=e.webviewIds,r=e.event;e.webviewId,t===A?console.error("not implement for "+t):W(r,n,o)}},Re=i(i(i(i(i(i(i(i({},{gameServiceReady:function(){!function(e){a(this,void 0,void 0,(function(){var n,t,o,r;return s(this,(function(i){switch(i.label){case 0:if(n=window.__deviceOrientation,t=xe(),o="string"==typeof n&&n.includes("landscape"),"landscape"===t||!o||!c())return[3,5];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,_(5e3,new Promise((function(e){var n=G();Ae({apiName:"setDeviceOrientation",params:{value:"landscape"}}),n.$events.once("onDeviceOrientationChange",(function(n){"landscape"===n.value&&e(!0)}))})))];case 2:return i.sent(),e(),[3,4];case 3:return r=i.sent(),e(r),[3,4];case 4:return[3,6];case 5:e(),i.label=6;case 6:return[2]}}))}))}((function(e){if(null!=e)return ae.emit("closeLaunchMask"),void Ge.showToast({title:"游戏加载超时"});ge((function(){console.log("load game script game.js"),V().loadSubBundle("","game.js")}))}))},gameConfigUpdate:function(e){var n=e.params;ue({windowInfo:Ge.getWindowInfo(),wxConfig:n}),ae.emit("closeLaunchMask")}}),Fe),De),He),Ve),We),Ne),je),Ge=i(i(i(i(i(i(i(i(i(i(i({},de),te),ve),we),ce),be),Me),he),Be),Oe),ee);function qe(e){var n,t=e.replace(q,""),o=Re[t];if(null==o){var r=/^video_(.*)_actionChanged$/.test(n=t)?"videoActionChanged":/^canvas(.*)actionsChanged$/.test(n)?"canvasActionsChanged":/^invokeCanvasToDataUrl_(.*)$/.test(n)?"invokeCanvasToDataUrl":/^onCanvasToDataUrl_(.*)$/.test(n)?"onCanvasToDataUrl":/^invokeCanvasPutImageData_(.*)$/.test(n)?"invokeCanvasPutImageData":/^onCanvasPutImageData_(.*)$/.test(n)?"onCanvasPutImageData":/^invokeCanvasGetImageData_(.*)$/.test(n)?"invokeCanvasGetImageData":/^onCanvasGetImageData_(.*)$/.test(n)?"onCanvasGetImageData":n;return{handler:Re[r]||null,formatedEvent:r}}return{handler:o,formatedEvent:t}}var Ue={invokeHandler:function(e){y&&console.log("invokeHander",e);var n=e.C,t=e.paramsString;e.type;var o=e.from,r=e.callbackId,i=e.webviewId,a=JSON.parse(t),s=Ge[n];if(null!=s)return s(a,r,o,i);var u=G();return null!=u?u.invokeHandler({apiName:n,params:a,callbackId:r,from:o}):void 0},publishHandler:function(e){y&&console.log("publishHandler",e);var n=e.event,t=e.from,o=e.paramsString,r=e.webviewId,i=e.webviewIds,a=qe(n),s=a.handler,u=a.formatedEvent,d=JSON.parse(o);if(null!=s)s({event:n,params:d,from:t,webviewId:r,webviewIds:b===t&&i?JSON.parse(i):void 0});else{var c=G();null!=c&&c.publishHandler({formatedEvent:u,event:n,params:d,from:t})}},webInvokeHandler:function(e){y&&console.log("webInvokeHander",e),X(e.callbackId,JSON.parse(e.paramsString))},webPublishHandler:function(e){y&&console.log("webPublishHandler",e),j(e.event,JSON.parse(e.paramsString))}};var $e=[],Xe=function(e){$e.push(e.el.src)},Ye=function(e){$e.pop()},ze=function(e){function n(n){var t=e.call(this,n)||this;return t.webviewId=null,t.pagePath="",t.wrapper=null,t.isDestoryed=!1,t.active=!1,t.__isWebView=!1,t}return r(n,e),Object.defineProperty(n.prototype,"isWebView",{get:function(){return this.__isWebView},set:function(e){this.__isWebView=e,e?Xe(this):Ye(this)},enumerable:!1,configurable:!0}),n.prototype.appendContainer=function(){var e=this.el;e.className="webview",e.setAttribute("frameborder","0"),this.hide();var n=document.getElementById("webview-container");this.wrapper=n,null!=n&&n.appendChild(e)},n.prototype.show=function(){var e=this.el;e.style.zIndex="2",e.style.opacity="1",this.active=!0,Je(this,"show")},n.prototype.hide=function(){var e=this.el;e.style.zIndex="1",e.style.opacity="0",this.active=!1,Je(this,"hide")},n.prototype.updateWebviewId=function(e){this.webviewId=e,this.updateId()},n.prototype.updateId=function(){this.el.id="webview-"+this.webviewId},n.prototype.updateSrc=function(e,n){void 0===n&&(n=g),this.el.src=n,this.pagePath=e},n.prototype.injectScript=function(){var e=this,n=this.getWindow();if(null!=n&&""!=this.pagePath){var t=this.pagePath.endsWith(".html")?this.pagePath:this.pagePath+".html",o=w+t;!function(e,n,t){if(null!=C[e])return C[e];M(e,n,(function(n,o,r){null!==n&&(C[e]=o),t(n,o,r)}))}(o,{sync:!0},(function(t,r){null!=t?console.error("init page fail in "+e.pagePath+", req: "+o+" \n "+t):n.injectHtml(n.document.body,{content:r})}))}},n.prototype.getBridge=function(){return this.getWindow().FinChatJSBridge},n.prototype.sendToView=function(e,n){var t=this;this.sync?(y&&console.log("%c "+e,"color: green;",n,this.webviewId),this.getBridge().subscribeHandler(e,n,this.webviewId)):setTimeout((function(){y&&console.log("%c "+e,"color: green;",n,t.webviewId),t.getBridge().subscribeHandler(e,n,t.webviewId)}))},n.prototype.postMessageToWebView=function(e){var n;y&&console.log("%c postMessageToWebView","color: orange;",e),null===(n=this.el.contentWindow)||void 0===n||n.postMessage(e,"*")},n.prototype.destory=function(){null!==this.wrapper&&this.wrapper.removeChild(this.el),this.el=null,this.wrapper=null,this.isDestoryed=!0,this.active=!1,this.isWebView=!1,Je(this,"destory")},n}(B);function Je(e,n){e.isVHost&&e.children&&e.children.length>0&&e.children.forEach((function(e){e[n]()}))}function Qe(e,n){return e._slots.findIndex((function(e){return e===n.replace(/\.html$/,"")}))}var Ze=new(function(){function e(){this._slotStack=[],this._extraStack=[],this._slots=[],this._webviewId=0,this.rootIndex=0}return Object.defineProperty(e.prototype,"pagePath",{get:function(){var e;return(null===(e=this.currPage)||void 0===e?void 0:e.pagePath)||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.stack[this.stack.length-2]||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this.stack[this.stack.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stack",{get:function(){var e=this._slotStack[this.rootIndex];return null==e?[]:u([e],this._extraStack)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"allPages",{get:function(){var e=this._slotStack[this.rootIndex];return null==e?[]:u([e],this._extraStack.slice(0,this._extraStack.length-1))},enumerable:!1,configurable:!0}),e.prototype.popExtraStack=function(){var e=this._extraStack,n=e.pop(),t=e.pop();return n&&e.push(n),t},e.prototype.resetExtraStack=function(){if(0!==this._extraStack.length){var e=this.top;this._extraStack.slice(0,this._extraStack.length-1).forEach((function(e){e.destory()})),this._extraStack=[e]}},e.prototype.initFirstPage=function(e,n){if(!Array.isArray(e)||0===e.length)throw new Error("slots must exist.");var t=Qe(this,n);this._slots=e;for(var o=0;o<e.length;o++){var r=document.createElement("iframe"),i=new ze(r);i.appendContainer(),this._slotStack.push(i)}t>-1&&(this.rootIndex=t),this._slotStack[this.rootIndex].updateSrc(n),this.initEmptyPage()},e.prototype.initEmptyPage=function(){var e=document.createElement("iframe"),n=new ze(e);n.appendContainer(),this._extraStack.push(n)},e.prototype.initNextPage=function(e,n){var t=this.currPage,o=this.top;return t.hide(),o.updateSrc(e,n),o.updateWebviewId(this._webviewId++),this.initEmptyPage(),o},e.prototype.initNextWebView=function(e,n,t){var o=this.initNextPage(n,t),r=this._extraStack.findIndex((function(e){return e.pagePath===n}));return r>-1&&this._extraStack.splice(r,1),e.children=[o],e.isVHost=!0,o.el.setAttribute("sandbox","allow-same-origin allow-scripts"),o.isWebView=!0,o.show(),o},e.prototype.initSlotWebviewId=function(e){this._webviewId=e,this._slotStack[this.rootIndex].updateWebviewId(this._webviewId++)},e.prototype.reinitPages=function(e){var n=this._slotStack,t=this._extraStack;n.forEach((function(e){e.destory()})),t.forEach((function(e){e.destory()})),this._slotStack=[],this._extraStack=[],this.initFirstPage(this._slots,e),this.currPage.updateWebviewId(this._webviewId++)},e.prototype.reLaunch=function(e){this.reinitPages(e)},e.prototype.redirectTo=function(e){if(Qe(this,e)>-1)throw new Error("不允许跳转到 tabbar 页面:"+e);var n=this._extraStack;if(n.length>1){var t=n.pop();n.pop().destory(),t.updateSrc(e),t.updateWebviewId(this._webviewId++),n.push(t),this.initEmptyPage()}else{null==(t=n.pop())||t.destory(),this._slotStack.forEach((function(e){e.destory()})),this.reinitPages(e)}},e.prototype.switch=function(e,n){n=null!=n?n:Qe(this,e);var t=this._slotStack,o=t[n];if(null==o)throw new Error("switchTab url is invalid: "+e);return this.resetExtraStack(),t.forEach((function(e){e.isReady&&e.hide()})),this.rootIndex=n,o.isReady?o.show():(o.updateWebviewId(this._webviewId++),o.updateSrc(e)),o},e.prototype.go=function(e){var n=Qe(this,e);return n>-1?this.switch(e,n):this.initNextPage(e)},e.prototype.back=function(e){var n,t=this._extraStack.slice(),o=t.pop(),r=t.length;if(e<=0)throw new Error("delta 不能 <= 0");if(r<e)throw new Error("delta 不能超过总栈长度:"+(r+1));var i=r-e,a=t.slice(0,i);(t.slice(i,r).forEach((function(e){e.destory()})),a.length>0)?a[a.length-1].show():null===(n=this._slotStack[this.rootIndex])||void 0===n||n.show();o&&a.push(o),this._extraStack=a},e}()),Ke=function(){function e(){this._invokeServiceCallbackHandler=$,this._dispatchViewEvent=W,this._dispatchServiceEvent=N,this.$events=new t,this._getCurrentPage=function(){return Ze.currPage},this._getAllPages=function(){return Ze.allPages}}return e.prototype.init=function(){R=this},e}();if(window.addEventListener("message",(function(e){var n=e.data;if("object"==typeof n&&null!==n)switch(n.type){case"publish":N(n.event,JSON.parse(n.paramsString));break;case"invoke":return Ue.invokeHandler(n)}})),window.FinChatJSCore=Ue,void 0===window.__initAdapter)throw new Error("Adapter is not ready yet.");window.__initAdapter(Ke),window.addEventListener("DOMContentLoaded",(function(){var e;e={windowInfo:Ge.getWindowInfo(),extInfo:Te()},void 0!==window.__initWebFrameOnContentLoad&&(se(),window.__initWebFrameOnContentLoad(e,ae),G().$events.on("onDeviceOrientationChange",(function(e){ae.emit("onDeviceOrientationChange",e)})))}))}));
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revues/web-sdk-core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "diamondloler <857276958@qq.com>",
|
|
6
6
|
"homepage": "",
|
|
7
7
|
"license": "ISC",
|
|
8
|
-
"main": "dist/
|
|
8
|
+
"main": "dist/web-sdk-core.js",
|
|
9
9
|
"directories": {
|
|
10
10
|
"src": "src"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist
|
|
13
|
+
"dist"
|
|
14
14
|
],
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
@@ -22,5 +22,13 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
24
24
|
},
|
|
25
|
-
"
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"axios": "^1.6.8",
|
|
27
|
+
"eventemitter3": "^5.0.1",
|
|
28
|
+
"howler": "^2.2.4"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/howler": "^2.2.11"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "5408ebecf3994a4ae557728f119b6c52bcbb3b1b"
|
|
26
34
|
}
|
package/dist/index.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function n(o,i,a){function c(t,e){if(!i[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(u)return u(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}r=i[t]={exports:{}},o[t][0].call(r.exports,function(e){return c(o[t][1][e]||e)},r,r.exports,n,o,i,a)}return i[t].exports}for(var u="function"==typeof require&&require,e=0;e<a.length;e++)c(a[e]);return c}({1:[function(F,H,R){"use strict";function P(e){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,r){t=i(t);var n=e,t=o()?Reflect.construct(t,r||[],i(e).constructor):t.apply(e,r);if(t&&("object"===P(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");e=n;if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function e(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}function n(e,t){return(n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function L(){L=function(){return a};var u,a={},e=Object.prototype,s=e.hasOwnProperty,l=Object.defineProperty||function(e,t,r){e[t]=r.value},t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(u){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,i,a,c,t=t&&t.prototype instanceof w?t:w,t=Object.create(t.prototype),n=new j(n||[]);return l(t,"_invoke",{value:(o=e,i=r,a=n,c=d,function(e,t){if(c===h)throw new Error("Generator is already running");if(c===v){if("throw"===e)throw t;return{value:u,done:!0}}for(a.method=e,a.arg=t;;){var r=a.delegate;if(r){r=function e(t,r){var n=r.method,o=t.iterator[n];if(o===u)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=u,e(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;n=f(o,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,y;o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}(r,a);if(r){if(r===y)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===d)throw c=v,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=h;r=f(o,i,a);if("normal"===r.type){if(c=a.done?v:p,r.arg===y)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c=v,a.method="throw",a.arg=r.arg)}})}),t}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=c;var d="suspendedStart",p="suspendedYield",h="executing",v="completed",y={};function w(){}function g(){}function m(){}var t={},b=(i(t,n,function(){return this}),Object.getPrototypeOf),b=b&&b(b(E([]))),k=(b&&b!==e&&s.call(b,n)&&(t=b),m.prototype=w.prototype=Object.create(t));function I(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function S(a,c){var t;l(this,"_invoke",{value:function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var i,e=f(a[e],a,r);if("throw"!==e.type)return(r=(i=e.arg).value)&&"object"==P(r)&&s.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){i.value=e,n(i)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}})}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function E(t){if(t||""===t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(s.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=u,e.done=!0,e}).next=e}throw new TypeError(P(t)+" is not iterable")}return l(k,"constructor",{value:g.prototype=m,configurable:!0}),l(m,"constructor",{value:g,configurable:!0}),g.displayName=i(m,o,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,i(e,o,"GeneratorFunction")),e.prototype=Object.create(k),e},a.awrap=function(e){return{__await:e}},I(S.prototype),i(S.prototype,r,function(){return this}),a.AsyncIterator=S,a.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var i=new S(c(e,t,r,n),o);return a.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},I(k),i(k,o,"Generator"),i(k,n,function(){return this}),i(k,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,r=Object(e),n=[];for(t in r)n.push(t);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=E,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=u)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return i.type="throw",i.arg=r,n.next=e,t&&(n.method="next",n.arg=u),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,T(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=u),y}},a}function u(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function t(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function a(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(Object(o),!0).forEach(function(e){var t,r;t=n,r=o[e=e],(e=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))})}return n}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function l(e,t,r){t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1})}function f(e){e=function(e,t){if("object"!=P(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==P(e)?e:String(e)}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,t)||function(e,t){var r;if(e)return"string"==typeof e?d(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var p=location.protocol+"//"+location.host+location.pathname.replace(/index\.html$/,""),h=null==window.__debug||window.__debug,D="service",v="view",y=window.packageExtConfig,w={path:y?y.entryPagePath:"index",query:{},referrerInfo:{},scene:1001},g="webview-service";var m=!1;function b(){var e,t;m||(t=k(location.search).query,null!=(e=window.__sdkUrlTemplate)&&null!=t.extType&&(e=e.replace("$1",t.extType),(t=document.createElement("script")).setAttribute("charset","utf-8"),t.src=e,document.body.appendChild(t),console.log("inject sdk script:",e),m=!0))}function k(e){var e=B(e.split("?"),2),t=e[0],e=e[1],r={};return null!=e&&""!==e&&e.split("&").reduce(function(e,t){t=t.split("=");return e[t[0]]=decodeURIComponent(t[1]),e},r),{path:t,query:r}}function I(e,t,r){var n=new XMLHttpRequest,o=!0;null!=t.sync&&(o=!t.sync),null!=t.responseType&&(n.responseType=t.responseType),n.open("GET",e,o),n.onload=function(){r(null,n.response)},n.onerror=function(e){r(new Error("request settings failed!"))},n.send(null)}function S(t){return new Promise(function(e){setTimeout(e,t)})}var O=0,T="miniGame",q=function(){function t(e){s(this,t),this.taskId=e.taskId,this.moduleName=e.moduleName,this.projectType=e.projectType,this.status="none"}var c,e;return l(t,[{key:"notifyProgressUpdate",value:function(e,t){C("onLoadSubPackageTaskStateChange",a({moduleName:this.moduleName,state:e,taskId:this.taskId},t))}},{key:"injectScript",value:function(){}},{key:"getEntry",value:function(){}},{key:"load",value:(c=L().mark(function e(){return L().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.notifyProgressUpdate("progressUpdate",{progress:0}),e.next=3,S(15);case 3:return this.notifyProgressUpdate("progressUpdate",{progress:50}),e.next=6,S(30);case 6:return this.injectScript(),this.notifyProgressUpdate("progressUpdate",{progress:100}),e.next=10,S(15);case 10:this.status="success",this.notifyProgressUpdate("success",{entryPath:this.getEntry()});case 12:case"end":return e.stop()}},e,this)}),e=function(){var e=this,a=arguments;return new Promise(function(t,r){var n=c.apply(e,a);function o(e){u(n,t,r,o,i,"next",e)}function i(e){u(n,t,r,o,i,"throw",e)}o(void 0)})},function(){return e.apply(this,arguments)})}]),t}(),W=function(){function t(e){return s(this,t),r(this,t,[a(a({},e),{},{projectType:T})])}return e(t,q),l(t,[{key:"injectScript",value:function(){var e=x(g).getWindow();e.injectHtml(e.document.body,{content:function(e,t){if(e===T)return'<script charset="utf-8" src="'.concat(t.moduleName,'game.js"><\/script>');if("miniProgram"===e)return t.content;throw Error("unsupported projectType: "+e)}(this.projectType,{moduleName:this.moduleName})})}},{key:"getEntry",value:function(){return e=this.projectType,t={moduleName:this.moduleName},e===T?"".concat(t.moduleName,"game.js"):"";var e,t}}]),t}(),j={},y={createLoadSubPackageTask:function(e){e=e.moduleName;if((r=j[e])&&"success"===r.status)return{errMsg:"createLoadSubPackageTask:fail sub package already loaded."};++O;var t=String(O),r=new W({taskId:t,moduleName:e});return(j[e]=r).load(),{errMsg:"createLoadSubPackageTask:ok",loadTaskId:t}}},U={readFileSync:function(e){var t,r,n;return(e=e.filePath).includes("gamecaches/cacheList.json")?null!=(t=localStorage.getItem(e))?{data:t,errMsg:"readFileSync:ok"}:{data:null,errMsg:"readFileSync:fail ".concat(e," not exist")}:(e=(t=e).endsWith(".wasm")?t+".txt":t,I(p+e,{sync:!(n=r=null)},function(e,t){r=t,n=e}),null!=r?{data:r,errMsg:"readFileSync:ok"}:null!=n?{data:null,errMsg:"readFileSync:fail "+n.message}:{data:null,errMsg:"readFileSync:fail"})},readFile:function(e,r){var t=e.filePath,n="base64"===e.encoding;I(p+t,{responseType:n?"arraybuffer":""},function(e,t){K(r,null!=e?{errMsg:"readFile:fail "+e.message}:{data:n?function(e){for(var t="",r=new Uint8Array(e),n=r.byteLength,o=0;o<n;o++)t+=String.fromCharCode(r[o]);return window.btoa(t)}(t):t,errMsg:"readFile:ok"})})},access:function(){return{errMsg:"access:ok"}},mkdirSync:function(){return{errMsg:"mkdirSync:ok"}},writeFileSync:function(e){var t=e.filePath,e=e.data;return localStorage.setItem(t,e),{errMsg:"writeFileSync:ok"}}},G={getStorageSync:function(t){t=localStorage.getItem(t.key);try{return JSON.parse(t)}catch(e){return t}},setStorageSync:function(e){return localStorage.setItem(e.key,e.data),{errMsg:"setStorageSync:ok"}},removeStorageSync:function(e){return localStorage.removeItem(e.key),{errMsg:"removeStorageSync:ok"}}},V=a(a(a(a(a({getGlobalVariables:function(e){return"_launchOption"===e.variable?{_launchOption:w}:null},reportApmMonitor:function(e){},getSystemInfoSync:function(){var e=750/window.innerWidth;return{deviceOrientation:"portrait",devicePixelRatio:e,screenWidth:window.innerWidth,screenHeight:window.innerHeight,SDKVersion:"2.26.0",appVersion:"2.37.0",batteryLevel:98,benchmarkLevel:1,bluetoothEnabled:!1,brand:"devtools",cameraAuthorized:!0,deviceId:"11D22B6D-B5D8-4C24-AF42-8C959C95A2E6",enableDebug:!0,errMsg:"getSystemInfoSync:ok",fontSizeSetting:15,frameworkVersion:"3.1.7",inFinChat:!0,language:"zh_CN",locationAuthorized:!0,locationEnabled:!0,microphoneAuthorized:!0,mode:"default",model:"iPhone 5",notificationAuthorized:!0,pixelRatio:e,platform:"devtools",statusBarHeight:22,system:(e=window.navigator.userAgent.toLowerCase(),/(iphone|ipad)/.test(e)?"IOS":/android/.test(e)?"Android":"Windows For HUYA"),theme:void 0,version:"8.0.28 ",windowHeight:window.innerHeight,windowWidth:window.innerWidth,safeArea:{height:window.innerHeight-22,widows:window.innerWidth,top:22,left:0,right:0}}},addPerformance:function(){},initReady:function(){},updateAppData:function(){}},{navigateTo:function(e,t){var r,e=e.url;return 10===_.length?{errMsg:"navigateTo:fail 已到达页面栈上限。"}:(C("onAppRoute",{path:r=(e=k(e)).path,openType:"navigateTo",options:void 0,pipMode:"",query:e.query,webviewId:(e=function(e){var t=N();{var r,n;if(null!=t&&t.isReady)return r=t.webviewId+1,n=_[_.length-1],t.hide(),n.updateSrc(e),n.updateWebviewId(r),M(),n;throw new Error("当前页面不存在,无法初始化下一个页面")}}(r)).webviewId},e.webviewId),{errMsg:"navigateTo:ok"})},navigateBack:function(e){var e=e.delta,t=N(),r=_.pop(),n=_.length-1,o=Math.max(n-e,0),i=_.slice(0,o+1),a=_[o];if(o===n)return{errMsg:"navigateBack:ok 页面栈已到底"};if(o+1===n)t.destory();else for(var c=o+1;c<=n;c++)_[c].destory();return a.show(),i.push(r),_=i,C("onAppRoute",{path:a.pagePath,openType:"navigateBack",options:{delta:e},pipMode:"",query:void 0,webviewId:a.webviewId},a.webviewId),{errMsg:"navigateBack:ok"}},reLaunch:function(e){var e=e.url,t=N(),e=k(e),r=e.path,e=e.query,n=_.pop();return null==n?{errMsg:"reLaunch:fail The preload view must be existed."}:(_.forEach(function(e){e.destory()}),_=[n],M(),n.updateSrc(r),n.updateWebviewId(t.webviewId+1),C("onAppRoute",{path:r,openType:"reLaunch",options:void 0,pipMode:"",query:e,webviewId:n.webviewId},n.webviewId),{errMsg:"reLaunch:ok"})},redirectTo:function(e){var e=k(e.url),t=e.path,e=e.query,r=_.pop(),n=_.pop();return null!=n&&null!=r?(n.destory(),r.updateSrc(t),r.updateWebviewId(n.webviewId+1),_.push(r),M(),C("onAppRoute",{path:t,openType:"redirectTo",options:void 0,pipMode:"",query:e,webviewId:r.webviewId},r.webviewId),{errMsg:"redirectTo:ok"}):{errMsg:"redirectTo:fail inner framework error"}},switchTab:function(e){e.url}}),U),{hideToast:function(){},showToast:function(){},showLoading:function(){},hideLoading:function(){}}),G),y);var E=new Map,z=function(){function t(e){s(this,t),this.el=e,this.isReady=!1}return l(t,[{key:"getWindow",value:function(){return this.el.contentWindow}},{key:"getBridge",value:function(){}}]),t}(),J=function(){function t(e){return s(this,t),r(this,t,[e])}return e(t,z),l(t,[{key:"sendToSerivce",value:function(e,t,r){h&&console.log("%c ".concat(e),"color: blue;",t,r),this.getBridge().subscribeHandler(e,t,r)}},{key:"invokeCallbackHandler",value:function(e,t,r){h&&console.log("%c ".concat(r||"API"," call callback"),"color: blue;",e,t),this.getBridge().invokeCallbackHandler(e,t)}},{key:"getBridge",value:function(){return this.getWindow().ServiceJSBridge}}]),t}(),Y=function(){function t(e){return s(this,t),(e=r(this,t,[e])).webviewId=null,e.tasks=[],e.pagePath="",e.sync=!1,e.wrapper=null,e.isDestoryed=!1,e}return e(t,z),l(t,[{key:"appendContainer",value:function(){var e=this.el,t=(e.className="webview",e.setAttribute("frameborder","0"),this.hide(),document.getElementById("webview-container"));null!=(this.wrapper=t)&&t.appendChild(e)}},{key:"show",value:function(){var e=this.el;e.style.zIndex=2,e.style.opacity=1}},{key:"hide",value:function(){var e=this.el;e.style.zIndex=1,e.style.opacity=0}},{key:"updateWebviewId",value:function(e){this.webviewId=e,this.updateId()}},{key:"updateId",value:function(){this.el.id="webview-".concat(this.webviewId)}},{key:"updateSrc",value:function(e){this.el.src=p+e.split("/").join("-"),this.pagePath=e}},{key:"addTask",value:function(e){this.tasks.push(e)}},{key:"emitLegencyTasks",value:function(){this.sync=!0;try{this.tasks.forEach(function(e){e()})}catch(e){console.log("excuting task error: "+e)}this.tasks=[],this.sync=!1}},{key:"getBridge",value:function(){return this.getWindow().FinChatJSBridge}},{key:"sendToView",value:function(e,t){var r=this;this.sync?(h&&console.log("%c ".concat(e),"color: green;",t,this.webviewId),this.getBridge().subscribeHandler(e,t,this.webviewId)):setTimeout(function(){h&&console.log("%c ".concat(e),"color: green;",t,r.webviewId),r.getBridge().subscribeHandler(e,t,r.webviewId)})}},{key:"destory",value:function(){null!==this.wrapper&&(this.wrapper.removeChild(this.el),this.el=null,this.wrapper=null,this.isDestoryed=!0)}}]),t}();function x(e){var t=E.get(e);if(t)return t;var t=document.getElementById(e);if(null!=t)return t=new(e===g?J:Y)(t),E.set(e,t),t;throw new Error("获取IframeManager失败, id: "+e)}function M(){var e=document.createElement("iframe"),e=new Y(e);e.appendContainer(),_.push(e)}var _=[];function N(){return _[_.length-2]||null}var $={serviceStart:function(e){var e=e.params;e=e.root,M(),_[_.length-1].updateSrc(e),M()},serviceReady:function(e){b();var t=e.params,e=e.webviewIds,r=x(g),n=N(),e=e[0];r.isReady||(n.updateWebviewId(e),C("onAppRoute",{path:t.root,openType:"appLaunch",options:void 0,pipMode:"",query:void 0,webviewId:e},e),C("onServiceReadyDone",a(a({},w),{},{webviewId:e}),e),r.isReady=!0)},onLaunchCalled:function(e){},viewReady:function(){var e=N();null!=e&&(e.isReady=!0,e.show(),e.emitLegencyTasks())},DOMReady:function(){},INVOKE_METHOD:function(e){var t=e.params,r=e.from,n=(e.webviewIds,e.event),e=e.webviewId;r===v?C(n,t,e):console.error("not implement for "+r)},vdSync:function(e){var t=e.params,r=e.from,n=e.webviewIds,o=e.event,e=e.webviewId;r===v?C(o,t,e):A(o,t,n)},vdSyncBatch:function(e){var t=e.params,r=e.from,n=e.webviewIds,o=e.event,e=e.webviewId;r===v?C(o,t,e):A(o,t,n)},appDataChange:function(e){var t=e.params,r=e.from,n=e.webviewIds,o=e.event;e.webviewId;r===v?console.error("not implement for "+r):A(o,t,n)},pageonshow:function(e){var t=e.params,r=e.from,n=e.webviewIds,o=e.event;e.webviewId;r===v?console.error("not implement for "+r):A(o,t,n)},DOMContentLoaded:function(e){var t=e.params,r=e.from,n=(e.webviewIds,e.event),e=e.webviewId;r===v?C(n,t,e):console.error("not implement for "+r)},requestLoadGlobalFontFaces:function(e){var t=e.params,r=e.from,n=(e.webviewIds,e.event),e=e.webviewId;r===v?C(n,t,e):console.error("not implement for "+r)},responseLoadGlobalFontFaces:function(e){var t=e.params,r=e.from,n=e.webviewIds,o=e.event;e.webviewId;r===v?console.error("not implement for "+r):A(o,t,n)},PAGE_EVENT:function(e){var t=e.params,r=e.from,n=(e.webviewIds,e.event),e=e.webviewId;r===v?C(n,t,e):console.error("not implement for "+r)},gameServiceReady:function(){b()},gameConfigUpdate:function(){}};function A(t,r,n){_.forEach(function(e){null!=e.webviewId&&-1<n.indexOf(e.webviewId)&&(e.isReady?e.sendToView(t,r):e.addTask(function(){e.sendToView(t,r)}))})}function C(e,t,r){x(g).sendToSerivce(e,t,r)}function K(e,t,r){x(g).invokeCallbackHandler(e,t,r)}var X="custom_event_";window.FinChatJSCore={invokeHandler:function(e){h&&console.log("invokeHander",e);var t=e.C,r=e.paramsString,e=(e.type,e.from,e.callbackId),t=V[t];if(null!=t)return t(JSON.parse(r),e)},publishHandler:function(e){h&&console.log("publishHandler",e);var t=e.event,r=e.from,n=e.paramsString,o=e.webviewId,e=e.webviewIds,i=t.replace(X,""),i=$[i];null!=i&&i({event:t,params:JSON.parse(n),from:r,webviewId:o,webviewIds:D===r?JSON.parse(e):void 0})},webInvokeHandler:function(e){h&&console.log("webInvokeHander",e)},webPublishHandler:function(e){h&&console.log("webPublishHandler",e)}}},{}]},{},[1]);
|