wavelovers/docs/js/app.6d107a0d.js

2 lines
6.1 KiB
JavaScript
Raw Normal View History

(function(){var t={7375:function(t,e,n){var i=n(4344)["default"];t.exports=class{constructor(t){i(this,"init",(()=>{this.id=Date.now(),this.canVibrate=!!this.unit.vibrationActuator,this.isVibrating=!1,this.pattern=[]})),i(this,"update",(()=>{let t=navigator.getGamepads();this.unit=t[this.unit.index]})),i(this,"reset",(()=>{this.isVibrating=!1,this.unit.vibrationActuator.reset()})),i(this,"vibrate",(async t=>{this.isVibrating=!0,this.pattern=t;while(!0===this.isVibrating)for(let t=0;t<this.pattern.length;t++){if(!0!==this.isVibrating)return;this.unit.vibrationActuator.playEffect("dual-rumble",this.pattern[t]),await this.sleep(this.pattern[t].startDelay+this.pattern[t].duration+100)}})),i(this,"sleep",(t=>new Promise((e=>setTimeout(e,t))))),this.unit=t,this.init()}}},3596:function(t,e,n){"use strict";var i=n(9242),a=n(3396);function s(t,e,n,i,s,r){const o=(0,a.up)("Wavelovers");return(0,a.wg)(),(0,a.j4)(o)}const r={class:"wavelovers"},o={class:"content-item"},c={key:1,class:"message"},d=(0,a._)("span",null,"Loading...",-1),p=[d],u={class:"content-item"},h={key:1,class:"message"},l=(0,a._)("span",null,"Press any gamepad's button or connect new gamepad.",-1),m=[l];function v(t,e,n,i,s,d){const l=(0,a.up)("PatternList"),v=(0,a.up)("GamepadList");return(0,a.wg)(),(0,a.iD)("div",r,[(0,a._)("div",o,[t.patterns.length>0?((0,a.wg)(),(0,a.j4)(l,{key:0,patterns:t.patterns,mode:t.mode,isActive:t.isActive,onChange:d.change},null,8,["patterns","mode","isActive","onChange"])):((0,a.wg)(),(0,a.iD)("div",c,p))]),(0,a._)("div",u,[t.gamepads.length>0?((0,a.wg)(),(0,a.j4)(v,{key:0,gamepads:t.gamepads},null,8,["gamepads"])):((0,a.wg)(),(0,a.iD)("div",h,m))])])}const g={class:"pattern-list"};function f(t,e,n,i,s,r){const o=(0,a.up)("PatternItem");return(0,a.wg)(),(0,a.iD)("div",g,[((0,a.wg)(!0),(0,a.iD)(a.HY,null,(0,a.Ko)(n.patterns,((t,e)=>((0,a.wg)(),(0,a.j4)(o,{key:t.name,pattern:t,index:e,mode:n.mode,isActive:n.isActive,onChange:r.change},null,8,["pattern","index","mode","isActive","onChange"])))),128))])}var w=n(7139);const b=["textContent"],y=["textContent"];function A(t,e,n,i,s,r){return(0,a.wg)(),(0,a.iD)("div",{onClick:e[0]||(e[0]=t=>r.change(n.index)),class:(0,w.C_)(["pattern-item",n.index===n.mode&&!0===n.isActive?"pattern-item_selected":""])},[(0,a._)("span",{class:"pattern-item__icon",textContent:(0,w.zw)(n.pattern.icon)},null,8,b),(0,a._)("span",{class:"pattern-item__name",textContent:(0,w.zw)(n.pattern.name)},null,8,y)],2)}var x={name:"PatternItem",props:{pattern:{type:Object},index:{type:Number},mode:{type:Number},isActive:{type:Boolean}},components:{},methods:{change(t){this.$emit("change",t)}}},C=n(89);const j=(0,C.Z)(x,[["render",A]]);var _=j,k={name:"PatternList",props:{patterns:{type:Array},mode:{type:Number},isActive:{type:Boolean}},components:{PatternItem:_},methods:{change(t){this.$emit("change",t)}}};const O=(0,C.Z)(k,[["render",f]]);var P=O;const D={class:"device-list"};function G(t,e,n,i,s,r){const o=(0,a.up)("GamepadItem");return(0,a.wg)(),(0,a.iD)("div",D,[((0,a.wg)(!0),(0,a.iD)(a.HY,null,(0,a.Ko)(n.gamepads,(t=>((0,a.wg)(),(0,a.j4)(o,{key:t.id,textContent:(0,w.zw)(t.unit.id)},null,8,["textContent"])))),128))])}const L={class:"list-item"};function E(t,e,n,i,s,r){return(0,a.wg)(),(0,a.iD)("div",L)}var I={name:"GamepadItem",components:{}};const V=(0,C.Z)(I,[["render",E]]);var Z=V,z={name:"GamepadList",props:{gamepads:{type:Array}},components:{GamepadItem:Z}};const N=(0,C.Z)(z,[["render",G]]);var T=N,W=n(7375),B=n.n(W),H={name:"WaveloversApp",components:{PatternList:P,GamepadList:T},data:()=>({gamepads:[],patterns:[],isActive:!1,mode:0}),methods:{loadPatterns:async function(){const t="https://wavelovers.ru/assets/patterns.json";try{const e=await fetch(t);if(e.ok){let t=await e.json();this.patterns=t}else console.log("Connect to the Internet for download more patterns...")}catch(e){console.log("[error]",e)}},addEventListeners(){window.addEventListener("gamepadconnected",(()=>this.addGamepad(event))),window.addEventListener("gamepaddisconnected",(()=>this.deleteGamepad(event)))},addGamepad(t){this.gamepads.length>1||th
//# sourceMappingURL=app.6d107a0d.js.map