diff --git a/docs/index.html b/docs/index.html index 043e67c..4b621ac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -15,4 +15,4 @@ webvisor: true });

Wavelovers

\ No newline at end of file + }

Wavelovers

\ No newline at end of file diff --git a/docs/js/app.5a58d0e1.js b/docs/js/app.5a58d0e1.js new file mode 100644 index 0000000..5223ca1 --- /dev/null +++ b/docs/js/app.5a58d0e1.js @@ -0,0 +1,2 @@ +(function(){"use strict";var t={2679:function(t,e,n){var a=n(9242),s=n(3396);function i(t,e,n,a,i,r){const o=(0,s.up)("WaveloversApp");return(0,s.wg)(),(0,s.j4)(o)}const r={class:"wavelovers"},o=(0,s.Uk)("Loading..."),c=(0,s.Uk)("Press any gamepad button or connect a new gamepad to vibrate.");function d(t,e,n,a,i,d){const p=(0,s.up)("PatternList"),u=(0,s.up)("MessageItem"),m=(0,s.up)("GamepadList");return(0,s.wg)(),(0,s.iD)("div",r,[t.patterns.length>0?((0,s.wg)(),(0,s.j4)(p,{key:0,patterns:t.patterns,mode:t.mode,isActive:t.isActive,onChange:t.change},null,8,["patterns","mode","isActive","onChange"])):((0,s.wg)(),(0,s.j4)(u,{key:1},{default:(0,s.w5)((()=>[o])),_:1})),t.gamepads.length>0?((0,s.wg)(),(0,s.j4)(m,{key:2,gamepads:t.gamepads},null,8,["gamepads"])):((0,s.wg)(),(0,s.j4)(u,{key:3},{default:(0,s.w5)((()=>[c])),_:1}))])}const p={class:"pattern-list"};function u(t,e,n,a,i,r){const o=(0,s.up)("PatternItem");return(0,s.wg)(),(0,s.iD)("div",p,[((0,s.wg)(!0),(0,s.iD)(s.HY,null,(0,s.Ko)(t.patterns,((e,n)=>((0,s.wg)(),(0,s.j4)(o,{key:e.name,pattern:e,index:n,mode:t.mode,isActive:t.isActive,onChange:t.change},null,8,["pattern","index","mode","isActive","onChange"])))),128))])}var m=n(7139);const v=["textContent"],g=["textContent"];function l(t,e,n,a,i,r){return(0,s.wg)(),(0,s.iD)("div",{onClick:e[0]||(e[0]=e=>t.change(t.index)),class:(0,m.C_)(["pattern-item",t.index===t.mode&&!0===t.isActive?"pattern-item_selected":""])},[(0,s._)("span",{class:"pattern-item__icon",textContent:(0,m.zw)(t.pattern.icon)},null,8,v),(0,s._)("span",{class:"pattern-item__name",textContent:(0,m.zw)(t.pattern.name)},null,8,g)],2)}var h=(0,s.aZ)({name:"PatternItem",props:{pattern:{type:Object},index:{type:Number},mode:{type:Number},isActive:{type:Boolean}},methods:{change:function(t){this.$emit("change",t)}}}),f=n(89);const w=(0,f.Z)(h,[["render",l]]);var b=w,A=(0,s.aZ)({name:"PatternList",props:{patterns:{type:Array},mode:{type:Number},isActive:{type:Boolean}},components:{PatternItem:b},methods:{change:function(t){this.$emit("change",t)}}});const y=(0,f.Z)(A,[["render",u]]);var Z=y;const G={class:"device-list"};function j(t,e,n,a,i,r){const o=(0,s.up)("GamepadItem");return(0,s.wg)(),(0,s.iD)("div",G,[((0,s.wg)(!0),(0,s.iD)(s.HY,null,(0,s.Ko)(t.gamepads,(t=>((0,s.wg)(),(0,s.j4)(o,{key:t.id,textContent:(0,m.zw)(t.unit.id)},null,8,["textContent"])))),128))])}const x={class:"list-item"};function I(t,e,n,a,i,r){return(0,s.wg)(),(0,s.iD)("div",x)}var k=(0,s.aZ)({name:"GamepadItem"});const C=(0,f.Z)(k,[["render",I]]);var L=C,P=(0,s.aZ)({name:"GamepadList",props:{gamepads:{type:Array}},components:{GamepadItem:L}});const E=(0,f.Z)(P,[["render",j]]);var _=E;const O={class:"message"};function M(t,e,n,a,i,r){return(0,s.wg)(),(0,s.iD)("div",O,[(0,s._)("span",null,[(0,s.WI)(t.$slots,"default")])])}var D=(0,s.aZ)({name:"MessageItem"});const V=(0,f.Z)(D,[["render",M]]);var T=V,W=n(65),z=n(2482);class N{constructor(t){(0,z.Z)(this,"id",void 0),(0,z.Z)(this,"canVibrate",void 0),(0,z.Z)(this,"isVibrating",void 0),(0,z.Z)(this,"unit",void 0),(0,z.Z)(this,"pattern",void 0),this.unit=t,this.id=Date.now(),this.canVibrate=!!this.unit.vibrationActuator,this.isVibrating=!1,this.pattern=[]}update(){const t=navigator.getGamepads();this.unit=t[this.unit.index]}reset(){this.isVibrating=!1,this.unit.vibrationActuator.reset()}async vibrate(t){this.isVibrating=!0,this.pattern=t;while(!0===this.isVibrating)for(let t=0;tsetTimeout(e,t)))}}var $=N;const B={state:()=>({gamepads:[]}),getters:{gamepads:function(t){return t.gamepads}},mutations:{addGamepad:function(t,e){t.gamepads.push(e)},deleteGamepad:function(t,e){t.gamepads.splice(e,1)}},actions:{addGamepad:function(t,e){const n=e;t.getters.gamepads.length>=1||t.commit("addGamepad",new $(n.gamepad))},deleteGamepad:function(t,e){t.getters.gamepads.forEach(((n,a)=>{n.unit.id===e.gamepad.id&&t.commit("deleteGamepad",a)}))},vibrate:function(t){t.getters.gamepads.forEach((e=>{e.vibrate(t.getters.patterns[t.getters.mode].pattern)}))},reset:function(t){t.getters.gamepads.forEach((t=>{t.reset()}))}}};var H=B;const K={state:()=>({patterns:[]}),getters:{patterns:function(t){return t.patterns}},mutations:{setPatterns:function(t,e){t.patterns=e}},actions:{loadPatterns:async function(t){const e="https://wavelovers.ru/assets/patterns.json";try{const n=await fetch(e);if(n.ok){const e=await n.json();t.commit("setPatterns",e)}else console.log("Connect to the Internet for download more patterns...")}catch(n){console.log(n)}}}};var U=K;const Y=(0,W.MT)({state:()=>({mode:0,isActive:!1}),getters:{mode:function(t){return t.mode},isActive:function(t){return t.isActive}},mutations:{setMode:function(t,e){t.mode=e},setIsActive:function(t,e){t.isActive=e}},actions:{setMode:function(t,e){t.commit("setMode",e)},setIsActive:function(t,e){t.commit("setIsActive",e)},change:function(t,e){t.getters.mode===e?t.dispatch("setIsActive",!t.getters.isActive):(t.dispatch("setIsActive",!0),t.dispatch("setMode",e)),!0===t.getters.isActive?(t.dispatch("reset"),t.dispatch("vibrate")):t.dispatch("reset")}},modules:{MGamepads:H,MPatterns:U}});var F=Y,q=(0,s.aZ)({name:"WaveloversApp",components:{PatternList:Z,GamepadList:_,MessageItem:T},computed:{gamepads:function(){return F.getters.gamepads},patterns:function(){return F.getters.patterns},mode:function(){return F.getters.mode},isActive:function(){return F.getters.isActive}},methods:{addEventListeners(){window.addEventListener("gamepadconnected",(t=>F.dispatch("addGamepad",t))),window.addEventListener("gamepaddisconnected",(t=>F.dispatch("deleteGamepad",t)))},removeEventListeners(){window.removeEventListener("gamepadconnected",(t=>F.dispatch("addGamepad",t))),window.removeEventListener("gamepaddisconnected",(t=>F.dispatch("deleteGamepad",t)))},change(t){F.dispatch("change",t)}},mounted(){F.dispatch("loadPatterns"),this.addEventListeners()},unmounted(){this.removeEventListeners()}});const J=(0,f.Z)(q,[["render",d]]);var Q=J,R=(0,s.aZ)({name:"App",components:{WaveloversApp:Q}});const S=(0,f.Z)(R,[["render",i]]);var X=S;(0,a.ri)(X).use(F).mount("#app")}},e={};function n(a){var s=e[a];if(void 0!==s)return s.exports;var i=e[a]={exports:{}};return t[a](i,i.exports,n),i.exports}n.m=t,function(){var t=[];n.O=function(e,a,s,i){if(!a){var r=1/0;for(p=0;p=i)&&Object.keys(n.O).every((function(t){return n.O[t](a[c])}))?a.splice(c--,1):(o=!1,i0&&t[p-1][2]>i;p--)t[p]=t[p-1];t[p]=[a,s,i]}}(),function(){n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,{a:e}),e}}(),function(){n.d=function(t,e){for(var a in e)n.o(e,a)&&!n.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})}}(),function(){n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"===typeof window)return window}}()}(),function(){n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}}(),function(){var t={143:0};n.O.j=function(e){return 0===t[e]};var e=function(e,a){var s,i,r=a[0],o=a[1],c=a[2],d=0;if(r.some((function(e){return 0!==t[e]}))){for(s in o)n.o(o,s)&&(n.m[s]=o[s]);if(c)var p=c(n)}for(e&&e(a);d 0)\n ? (_openBlock(), _createBlock(_component_PatternList, {\n key: 0,\n patterns: _ctx.patterns,\n mode: _ctx.mode,\n isActive: _ctx.isActive,\n onChange: _ctx.change\n }, null, 8, [\"patterns\", \"mode\", \"isActive\", \"onChange\"]))\n : (_openBlock(), _createBlock(_component_MessageItem, { key: 1 }, {\n default: _withCtx(() => [\n _hoisted_2\n ]),\n _: 1\n })),\n (_ctx.gamepads.length > 0)\n ? (_openBlock(), _createBlock(_component_GamepadList, {\n key: 2,\n gamepads: _ctx.gamepads\n }, null, 8, [\"gamepads\"]))\n : (_openBlock(), _createBlock(_component_MessageItem, { key: 3 }, {\n default: _withCtx(() => [\n _hoisted_3\n ]),\n _: 1\n }))\n ]))\n}","import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"pattern-list\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n const _component_PatternItem = _resolveComponent(\"PatternItem\")!\n\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.patterns, (pattern, index) => {\n return (_openBlock(), _createBlock(_component_PatternItem, {\n key: pattern.name,\n pattern: pattern,\n index: index,\n mode: _ctx.mode,\n isActive: _ctx.isActive,\n onChange: _ctx.change\n }, null, 8, [\"pattern\", \"index\", \"mode\", \"isActive\", \"onChange\"]))\n }), 128))\n ]))\n}","import { toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = [\"textContent\"]\nconst _hoisted_2 = [\"textContent\"]\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", {\n onClick: _cache[0] || (_cache[0] = ($event: any) => (_ctx.change(_ctx.index))),\n class: _normalizeClass(['pattern-item',\r\n _ctx.index === _ctx.mode && _ctx.isActive === true ?\r\n 'pattern-item_selected' : '',\r\n ])\n }, [\n _createElementVNode(\"span\", {\n class: \"pattern-item__icon\",\n textContent: _toDisplayString(_ctx.pattern.icon)\n }, null, 8, _hoisted_1),\n _createElementVNode(\"span\", {\n class: \"pattern-item__name\",\n textContent: _toDisplayString(_ctx.pattern.name)\n }, null, 8, _hoisted_2)\n ], 2))\n}","\r\n import { defineComponent } from 'vue';\r\n\r\n export default defineComponent({\r\n name: 'PatternItem',\r\n props: {\r\n pattern: {\r\n type: Object,\r\n },\r\n index: {\r\n type: Number,\r\n },\r\n mode: {\r\n type: Number,\r\n },\r\n isActive: {\r\n type: Boolean,\r\n },\r\n },\r\n methods: {\r\n change: function (index: number): void {\r\n this.$emit('change', index as number);\r\n },\r\n },\r\n });\r\n","import { render } from \"./PatternItem.vue?vue&type=template&id=f864fdb0&ts=true\"\nimport script from \"./PatternItem.vue?vue&type=script&lang=ts\"\nexport * from \"./PatternItem.vue?vue&type=script&lang=ts\"\n\nimport \"./PatternItem.vue?vue&type=style&index=0&id=f864fdb0&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","\r\n import { defineComponent } from 'vue';\r\n import PatternItem from '@/components/PatternItem.vue';\r\n\r\n export default defineComponent({\r\n name: 'PatternList',\r\n props: {\r\n patterns: {\r\n type: Array,\r\n },\r\n mode: {\r\n type: Number,\r\n },\r\n isActive: {\r\n type: Boolean,\r\n },\r\n },\r\n components: {\r\n PatternItem: PatternItem,\r\n },\r\n methods: {\r\n change: function (index: number): void {\r\n this.$emit('change', index as number);\r\n },\r\n },\r\n });\r\n","import { render } from \"./PatternList.vue?vue&type=template&id=7b6b7b1f&ts=true\"\nimport script from \"./PatternList.vue?vue&type=script&lang=ts\"\nexport * from \"./PatternList.vue?vue&type=script&lang=ts\"\n\nimport \"./PatternList.vue?vue&type=style&index=0&id=7b6b7b1f&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"device-list\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n const _component_GamepadItem = _resolveComponent(\"GamepadItem\")!\n\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.gamepads, (gamepad) => {\n return (_openBlock(), _createBlock(_component_GamepadItem, {\n key: gamepad.id,\n textContent: _toDisplayString(gamepad.unit.id)\n }, null, 8, [\"textContent\"]))\n }), 128))\n ]))\n}","import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"list-item\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1))\n}","\r\n import { defineComponent } from 'vue';\r\n\r\n export default defineComponent({\r\n name: 'GamepadItem',\r\n });\r\n","import { render } from \"./GamepadItem.vue?vue&type=template&id=e6e6c988&ts=true\"\nimport script from \"./GamepadItem.vue?vue&type=script&lang=ts\"\nexport * from \"./GamepadItem.vue?vue&type=script&lang=ts\"\n\nimport \"./GamepadItem.vue?vue&type=style&index=0&id=e6e6c988&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","\r\n import { defineComponent } from 'vue';\r\n import GamepadItem from '@/components/GamepadItem.vue';\r\n\r\n export default defineComponent({\r\n name: 'GamepadList',\r\n props: {\r\n gamepads: {\r\n type: Array,\r\n },\r\n },\r\n components: {\r\n GamepadItem: GamepadItem,\r\n },\r\n });\r\n ","import { render } from \"./GamepadList.vue?vue&type=template&id=1d58b1c0&ts=true\"\nimport script from \"./GamepadList.vue?vue&type=script&lang=ts\"\nexport * from \"./GamepadList.vue?vue&type=script&lang=ts\"\n\nimport \"./GamepadList.vue?vue&type=style&index=0&id=1d58b1c0&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"message\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n _createElementVNode(\"span\", null, [\n _renderSlot(_ctx.$slots, \"default\")\n ])\n ]))\n}","\r\n import { defineComponent } from 'vue';\r\n\r\n export default defineComponent({\r\n name: 'MessageItem',\r\n });\r\n","import { render } from \"./MessageItem.vue?vue&type=template&id=32e2819b&ts=true\"\nimport script from \"./MessageItem.vue?vue&type=script&lang=ts\"\nexport * from \"./MessageItem.vue?vue&type=script&lang=ts\"\n\nimport \"./MessageItem.vue?vue&type=style&index=0&id=32e2819b&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import TPatternUnit from '@/models/TPatternUnit';\r\nimport IGamepad from '@/models/IGamepad';\r\nimport IVibrator from '@/models/IVibrator';\r\n\r\nclass Vibrator implements IVibrator {\r\n readonly id: number;\r\n readonly canVibrate: boolean;\r\n isVibrating: boolean;\r\n unit: IGamepad;\r\n pattern: TPatternUnit[];\r\n\r\n constructor(unit: IGamepad) {\r\n this.unit = unit;\r\n this.id = Date.now();\r\n this.canVibrate = (this.unit.vibrationActuator) ? true : false;\r\n this.isVibrating = false;\r\n this.pattern = [];\r\n }\r\n\r\n update(): void {\r\n const gamepads = navigator.getGamepads();\r\n this.unit = gamepads[this.unit.index];\r\n }\r\n\r\n reset(): void {\r\n this.isVibrating = false;\r\n this.unit.vibrationActuator.reset();\r\n }\r\n\r\n async vibrate(pattern: TPatternUnit[]) {\r\n this.isVibrating = true;\r\n this.pattern = pattern;\r\n\r\n while (this.isVibrating === true) {\r\n for (let i = 0; i < this.pattern.length; i++) {\r\n if (this.isVibrating === true) {\r\n this.unit.vibrationActuator.playEffect('dual-rumble', this.pattern[i]);\r\n await this.sleep(this.pattern[i].startDelay + this.pattern[i].duration);\r\n } else {\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n\r\n sleep(ms: number): Promise {\r\n return new Promise(resolve => setTimeout(resolve, ms));\r\n }\r\n}\r\n\r\nexport default Vibrator;\r\n\r\n","import { ActionContext, Module } from 'vuex';\r\nimport IRootState from '@/store/models/IRootState';\r\nimport IGamepadsState from '@/store/models/IGamepadsState';\r\nimport Vibrator from '@/models/Vibrator';\r\nimport IGamepad from '@/models/IGamepad';\r\nimport IGamepadEvent from '@/models/IGamepadEvent';\r\nimport TPatternUnit from '@/models/TPatternUnit';\r\n\r\nconst MGamepads: Module = {\r\n state: () => ({\r\n gamepads: [] as Vibrator[],\r\n }),\r\n getters: {\r\n gamepads: function (state: IGamepadsState): Vibrator[] {\r\n return state.gamepads as Vibrator[];\r\n },\r\n },\r\n mutations: {\r\n addGamepad: function (state: IGamepadsState, gamepad: Vibrator): void {\r\n state.gamepads.push(gamepad as Vibrator);\r\n },\r\n deleteGamepad: function (state: IGamepadsState, index: number): void {\r\n state.gamepads.splice(index, 1);\r\n },\r\n },\r\n actions: {\r\n addGamepad: function (\r\n context: ActionContext,\r\n event: GamepadEvent\r\n ): void {\r\n const iEvent: IGamepadEvent = event as unknown as IGamepadEvent;\r\n if (context.getters.gamepads.length >= 1) {\r\n return;\r\n } else {\r\n context.commit('addGamepad', new Vibrator(iEvent.gamepad as IGamepad));\r\n }\r\n },\r\n deleteGamepad: function (\r\n context: ActionContext,\r\n event: GamepadEvent\r\n ): void {\r\n context.getters.gamepads.forEach((gamepad: Vibrator, index: number) => {\r\n if (gamepad.unit.id === event.gamepad.id) {\r\n context.commit('deleteGamepad', index as number);\r\n }\r\n });\r\n },\r\n vibrate: function (\r\n context: ActionContext\r\n ): void {\r\n context.getters.gamepads.forEach((gamepad: Vibrator) => {\r\n gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]);\r\n });\r\n },\r\n reset: function (\r\n context: ActionContext\r\n ): void {\r\n context.getters.gamepads.forEach((gamepad: Vibrator) => {\r\n gamepad.reset();\r\n });\r\n },\r\n },\r\n};\r\n\r\nexport default MGamepads;\r\n\r\n","import { ActionContext, Module } from 'vuex';\r\nimport IRootState from '@/store/models/IRootState';\r\nimport IPatternState from '@/store/models/IPatternState';\r\nimport TPattern from '@/models/TPattern';\r\n\r\nconst MPatterns: Module = {\r\n state: () => ({\r\n patterns: [] as TPattern[],\r\n }),\r\n getters: {\r\n patterns: function (state: IPatternState): TPattern[] {\r\n return state.patterns as TPattern[];\r\n },\r\n },\r\n mutations: {\r\n setPatterns: function (state: IPatternState, patterns: TPattern[]): void {\r\n state.patterns = patterns as TPattern[];\r\n },\r\n },\r\n actions: {\r\n loadPatterns: async function (\r\n context: ActionContext\r\n ): Promise {\r\n const url = 'https://wavelovers.ru/assets/patterns.json';\r\n try {\r\n const response: Response = await fetch(url);\r\n if (response.ok) {\r\n const json: TPattern[] = await response.json();\r\n context.commit('setPatterns', json as TPattern[]);\r\n } else {\r\n console.log('Connect to the Internet for download more patterns...');\r\n }\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n },\r\n },\r\n};\r\n\r\nexport default MPatterns;\r\n\r\n","import { createStore, Store } from 'vuex';\r\nimport IRootState from './models/IRootState';\r\nimport MGamepads from '@/store/modules/MGamepads';\r\nimport MPatterns from '@/store/modules/MPatterns';\r\n\r\nconst store: Store = createStore({\r\n state: () => ({\r\n mode: 0 as number,\r\n isActive: false as boolean,\r\n }),\r\n getters: {\r\n mode: function (state: IRootState): number {\r\n return state.mode as number;\r\n },\r\n isActive: function (state: IRootState): boolean {\r\n return state.isActive as boolean;\r\n },\r\n },\r\n mutations: {\r\n setMode: function (state: IRootState, mode: number): void {\r\n state.mode = mode as number;\r\n },\r\n setIsActive: function (state: IRootState, isActive: boolean): void {\r\n state.isActive = isActive as boolean;\r\n },\r\n },\r\n actions: {\r\n setMode: function (\r\n context,\r\n index: number\r\n ): void {\r\n context.commit('setMode', index as number);\r\n },\r\n setIsActive: function (\r\n context,\r\n isActive: boolean\r\n ): void {\r\n context.commit('setIsActive', isActive as boolean);\r\n },\r\n change: function (context, index: number): void {\r\n if (context.getters.mode === index) {\r\n context.dispatch('setIsActive', !context.getters.isActive);\r\n } else {\r\n context.dispatch('setIsActive', true);\r\n context.dispatch('setMode', index);\r\n }\r\n if (context.getters.isActive === true) {\r\n context.dispatch('reset');\r\n context.dispatch('vibrate');\r\n } else {\r\n context.dispatch('reset');\r\n }\r\n },\r\n },\r\n modules: {\r\n MGamepads: MGamepads,\r\n MPatterns: MPatterns,\r\n },\r\n});\r\n\r\nexport default store;\r\n\r\n","\r\n import { defineComponent } from 'vue';\r\n import PatternList from '@/components/PatternList.vue';\r\n import GamepadList from '@/components/GamepadList.vue';\r\n import MessageItem from '@/components/MessageItem.vue';\r\n import TPattern from '@/models/TPattern';\r\n import Vibrator from '@/models/Vibrator';\r\n import store from '@/store/index';\r\n\r\n export default defineComponent({\r\n name: 'WaveloversApp',\r\n components: {\r\n PatternList: PatternList,\r\n GamepadList: GamepadList,\r\n MessageItem: MessageItem,\r\n },\r\n computed: {\r\n gamepads: function (): Vibrator[] {\r\n return store.getters.gamepads as Vibrator[];\r\n },\r\n patterns: function (): TPattern[] {\r\n return store.getters.patterns as TPattern[];\r\n },\r\n mode: function (): number {\r\n return store.getters.mode as number;\r\n },\r\n isActive: function (): boolean {\r\n return store.getters.isActive as boolean;\r\n },\r\n },\r\n methods: {\r\n addEventListeners(): void {\r\n window.addEventListener('gamepadconnected', (event: GamepadEvent) => store.dispatch('addGamepad', event));\r\n window.addEventListener('gamepaddisconnected', (event: GamepadEvent) => store.dispatch('deleteGamepad', event));\r\n },\r\n removeEventListeners(): void {\r\n window.removeEventListener('gamepadconnected', (event: GamepadEvent) => store.dispatch('addGamepad', event));\r\n window.removeEventListener('gamepaddisconnected', (event: GamepadEvent) => store.dispatch('deleteGamepad', event));\r\n },\r\n change(index: number): void {\r\n store.dispatch('change', index as number);\r\n },\r\n },\r\n mounted() {\r\n store.dispatch('loadPatterns');\r\n this.addEventListeners();\r\n },\r\n unmounted() {\r\n this.removeEventListeners();\r\n },\r\n });\r\n","import { render } from \"./WaveloversApp.vue?vue&type=template&id=34f165d2&ts=true\"\nimport script from \"./WaveloversApp.vue?vue&type=script&lang=ts\"\nexport * from \"./WaveloversApp.vue?vue&type=script&lang=ts\"\n\nimport \"./WaveloversApp.vue?vue&type=style&index=0&id=34f165d2&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","\n import { defineComponent } from 'vue';\n import WaveloversApp from '@/components/WaveloversApp.vue';\n\n export default defineComponent({\n name: 'App',\n components: {\n WaveloversApp: WaveloversApp,\n },\n });\n","import { render } from \"./App.vue?vue&type=template&id=4be8096e&ts=true\"\nimport script from \"./App.vue?vue&type=script&lang=ts\"\nexport * from \"./App.vue?vue&type=script&lang=ts\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { createApp } from 'vue';\r\nimport App from './App.vue';\r\nimport store from './store';\r\n\r\ncreateApp(App).use(store).mount('#app');\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = function(result, chunkIds, fn, priority) {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar chunkIds = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t143: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = function(chunkId) { return installedChunks[chunkId] === 0; };\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = function(parentChunkLoadingFunction, data) {\n\tvar chunkIds = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkwavelovers\"] = self[\"webpackChunkwavelovers\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [998], function() { return __webpack_require__(2679); })\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["render","_ctx","_cache","$props","$setup","$data","$options","_component_WaveloversApp","_resolveComponent","_openBlock","_createBlock","_hoisted_1","class","_hoisted_2","_createTextVNode","_hoisted_3","_component_PatternList","_component_MessageItem","_component_GamepadList","_createElementBlock","patterns","length","key","mode","isActive","onChange","change","default","_withCtx","_","gamepads","_component_PatternItem","_Fragment","_renderList","pattern","index","name","onClick","$event","_normalizeClass","_createElementVNode","textContent","_toDisplayString","icon","defineComponent","props","type","Object","Number","Boolean","methods","this","$emit","__exports__","Array","components","PatternItem","_component_GamepadItem","gamepad","id","unit","GamepadItem","_renderSlot","$slots","Vibrator","constructor","Date","now","canVibrate","vibrationActuator","isVibrating","update","navigator","getGamepads","reset","i","playEffect","sleep","startDelay","duration","ms","Promise","resolve","setTimeout","MGamepads","state","getters","mutations","addGamepad","push","deleteGamepad","splice","actions","context","event","iEvent","commit","forEach","vibrate","MPatterns","setPatterns","loadPatterns","async","url","response","fetch","ok","json","console","log","error","store","createStore","setMode","setIsActive","dispatch","modules","PatternList","GamepadList","MessageItem","computed","addEventListeners","window","addEventListener","removeEventListeners","removeEventListener","mounted","unmounted","WaveloversApp","createApp","App","use","mount","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","m","deferred","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","get","g","globalThis","Function","e","obj","prop","prototype","hasOwnProperty","call","installedChunks","chunkId","webpackJsonpCallback","parentChunkLoadingFunction","data","moreModules","runtime","some","chunkLoadingGlobal","self","bind","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/js/app.b6a47de1.js b/docs/js/app.b6a47de1.js deleted file mode 100644 index d144aab..0000000 --- a/docs/js/app.b6a47de1.js +++ /dev/null @@ -1,2 +0,0 @@ -(function(){"use strict";var t={6665:function(t,e,n){var a=n(9242),i=n(3396);function s(t,e,n,a,s,r){const o=(0,i.up)("WaveloversApp");return(0,i.wg)(),(0,i.j4)(o)}const r={class:"wavelovers"},o=(0,i.Uk)("Loading..."),c=(0,i.Uk)("Press any gamepad button or connect a new gamepad to vibrate.");function d(t,e,n,a,s,d){const p=(0,i.up)("PatternList"),u=(0,i.up)("MessageItem"),m=(0,i.up)("GamepadList");return(0,i.wg)(),(0,i.iD)("div",r,[t.patterns.length>0?((0,i.wg)(),(0,i.j4)(p,{key:0,patterns:t.patterns,mode:t.mode,isActive:t.isActive,onChange:t.change},null,8,["patterns","mode","isActive","onChange"])):((0,i.wg)(),(0,i.j4)(u,{key:1},{default:(0,i.w5)((()=>[o])),_:1})),t.gamepads.length>0?((0,i.wg)(),(0,i.j4)(m,{key:2,gamepads:t.gamepads},null,8,["gamepads"])):((0,i.wg)(),(0,i.j4)(u,{key:3},{default:(0,i.w5)((()=>[c])),_:1}))])}const p={class:"pattern-list"};function u(t,e,n,a,s,r){const o=(0,i.up)("PatternItem");return(0,i.wg)(),(0,i.iD)("div",p,[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(t.patterns,((e,n)=>((0,i.wg)(),(0,i.j4)(o,{key:e.name,pattern:e,index:n,mode:t.mode,isActive:t.isActive,onChange:t.change},null,8,["pattern","index","mode","isActive","onChange"])))),128))])}var m=n(7139);const v=["textContent"],g=["textContent"];function l(t,e,n,a,s,r){return(0,i.wg)(),(0,i.iD)("div",{onClick:e[0]||(e[0]=e=>t.change(t.index)),class:(0,m.C_)(["pattern-item",t.index===t.mode&&!0===t.isActive?"pattern-item_selected":""])},[(0,i._)("span",{class:"pattern-item__icon",textContent:(0,m.zw)(t.pattern.icon)},null,8,v),(0,i._)("span",{class:"pattern-item__name",textContent:(0,m.zw)(t.pattern.name)},null,8,g)],2)}var h=(0,i.aZ)({name:"PatternItem",props:{pattern:{type:Object},index:{type:Number},mode:{type:Number},isActive:{type:Boolean}},methods:{change:function(t){this.$emit("change",t)}}}),f=n(89);const w=(0,f.Z)(h,[["render",l]]);var b=w,A=(0,i.aZ)({name:"PatternList",props:{patterns:{type:Array},mode:{type:Number},isActive:{type:Boolean}},components:{PatternItem:b},methods:{change:function(t){this.$emit("change",t)}}});const y=(0,f.Z)(A,[["render",u]]);var Z=y;const G={class:"device-list"};function j(t,e,n,a,s,r){const o=(0,i.up)("GamepadItem");return(0,i.wg)(),(0,i.iD)("div",G,[((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(t.gamepads,(t=>((0,i.wg)(),(0,i.j4)(o,{key:t.id,textContent:(0,m.zw)(t.unit.id)},null,8,["textContent"])))),128))])}const x={class:"list-item"};function I(t,e,n,a,s,r){return(0,i.wg)(),(0,i.iD)("div",x)}var k=(0,i.aZ)({name:"GamepadItem"});const C=(0,f.Z)(k,[["render",I]]);var L=C,P=(0,i.aZ)({name:"GamepadList",props:{gamepads:{type:Array}},components:{GamepadItem:L}});const E=(0,f.Z)(P,[["render",j]]);var _=E;const O={class:"message"};function D(t,e,n,a,s,r){return(0,i.wg)(),(0,i.iD)("div",O,[(0,i._)("span",null,[(0,i.WI)(t.$slots,"default")])])}var M=(0,i.aZ)({name:"MessageItem"});const V=(0,f.Z)(M,[["render",D]]);var T=V,W=n(65),z=n(2482);class N{constructor(t){(0,z.Z)(this,"id",void 0),(0,z.Z)(this,"canVibrate",void 0),(0,z.Z)(this,"isVibrating",void 0),(0,z.Z)(this,"unit",void 0),(0,z.Z)(this,"pattern",void 0),this.unit=t,this.id=Date.now(),this.canVibrate=!!this.unit.vibrationActuator,this.isVibrating=!1,this.pattern=[]}update(){const t=navigator.getGamepads();this.unit=t[this.unit.index]}reset(){this.isVibrating=!1,this.unit.vibrationActuator.reset()}async vibrate(t){this.isVibrating=!0,this.pattern=t;while(!0===this.isVibrating)for(let t=0;tsetTimeout(e,t)))}}var $=N,B=(0,W.MT)({state:{gamepads:[],patterns:[],mode:0,isActive:!1},getters:{gamepads:function(t){return t.gamepads},patterns:function(t){return t.patterns},mode:function(t){return t.mode},isActive:function(t){return t.isActive}},mutations:{setPatterns:function(t,e){t.patterns=e},setMode:function(t,e){t.mode=e},setIsActive:function(t,e){t.isActive=e},addGamepad:function(t,e){t.gamepads.push(e)},deleteGamepad:function(t,e){t.gamepads.splice(e,1)}},actions:{loadPatterns:async function(t){const e="https://wavelovers.ru/assets/patterns.json";try{const n=await fetch(e);if(n.ok){const e=await n.json();t.commit("setPatterns",e)}else console.log("Connect to the Internet for download more patterns...")}catch(n){console.log(n)}},setMode:function(t,e){t.commit("setMode",e)},setIsActive:function(t,e){t.commit("setIsActive",e)},addGamepad:function(t,e){const n=e;t.getters.gamepads.length>=1||t.commit("addGamepad",new $(n.gamepad))},deleteGamepad:function(t,e){t.getters.gamepads.forEach(((n,a)=>{n.unit.id===e.gamepad.id&&t.commit("deleteGamepad",a)}))},vibrate:function(t){t.getters.gamepads.forEach((e=>{e.vibrate(t.getters.patterns[t.getters.mode].pattern)}))},reset:function(t){t.getters.gamepads.forEach((t=>{t.reset()}))},change:function(t,e){t.getters.mode===e?t.dispatch("setIsActive",!t.getters.isActive):(t.dispatch("setIsActive",!0),t.dispatch("setMode",e)),!0===t.getters.isActive?(t.dispatch("reset"),t.dispatch("vibrate")):t.dispatch("reset")}},modules:{}}),H=(0,i.aZ)({name:"WaveloversApp",components:{PatternList:Z,GamepadList:_,MessageItem:T},computed:{gamepads:function(){return B.getters.gamepads},patterns:function(){return B.getters.patterns},mode:function(){return B.getters.mode},isActive:function(){return B.getters.isActive}},methods:{addEventListeners(){window.addEventListener("gamepadconnected",(t=>B.dispatch("addGamepad",t))),window.addEventListener("gamepaddisconnected",(t=>B.dispatch("deleteGamepad",t)))},removeEventListeners(){window.removeEventListener("gamepadconnected",(t=>B.dispatch("addGamepad",t))),window.removeEventListener("gamepaddisconnected",(t=>B.dispatch("deleteGamepad",t)))},change(t){B.dispatch("change",t)}},mounted(){B.dispatch("loadPatterns"),this.addEventListeners()},unmounted(){this.removeEventListeners()}});const K=(0,f.Z)(H,[["render",d]]);var U=K,Y=(0,i.aZ)({name:"App",components:{WaveloversApp:U}});const F=(0,f.Z)(Y,[["render",s]]);var q=F;(0,a.ri)(q).use(B).mount("#app")}},e={};function n(a){var i=e[a];if(void 0!==i)return i.exports;var s=e[a]={exports:{}};return t[a](s,s.exports,n),s.exports}n.m=t,function(){var t=[];n.O=function(e,a,i,s){if(!a){var r=1/0;for(p=0;p=s)&&Object.keys(n.O).every((function(t){return n.O[t](a[c])}))?a.splice(c--,1):(o=!1,s0&&t[p-1][2]>s;p--)t[p]=t[p-1];t[p]=[a,i,s]}}(),function(){n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,{a:e}),e}}(),function(){n.d=function(t,e){for(var a in e)n.o(e,a)&&!n.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})}}(),function(){n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"===typeof window)return window}}()}(),function(){n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}}(),function(){var t={143:0};n.O.j=function(e){return 0===t[e]};var e=function(e,a){var i,s,r=a[0],o=a[1],c=a[2],d=0;if(r.some((function(e){return 0!==t[e]}))){for(i in o)n.o(o,i)&&(n.m[i]=o[i]);if(c)var p=c(n)}for(e&&e(a);d 0)\n ? (_openBlock(), _createBlock(_component_PatternList, {\n key: 0,\n patterns: _ctx.patterns,\n mode: _ctx.mode,\n isActive: _ctx.isActive,\n onChange: _ctx.change\n }, null, 8, [\"patterns\", \"mode\", \"isActive\", \"onChange\"]))\n : (_openBlock(), _createBlock(_component_MessageItem, { key: 1 }, {\n default: _withCtx(() => [\n _hoisted_2\n ]),\n _: 1\n })),\n (_ctx.gamepads.length > 0)\n ? (_openBlock(), _createBlock(_component_GamepadList, {\n key: 2,\n gamepads: _ctx.gamepads\n }, null, 8, [\"gamepads\"]))\n : (_openBlock(), _createBlock(_component_MessageItem, { key: 3 }, {\n default: _withCtx(() => [\n _hoisted_3\n ]),\n _: 1\n }))\n ]))\n}","import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"pattern-list\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n const _component_PatternItem = _resolveComponent(\"PatternItem\")!\n\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.patterns, (pattern, index) => {\n return (_openBlock(), _createBlock(_component_PatternItem, {\n key: pattern.name,\n pattern: pattern,\n index: index,\n mode: _ctx.mode,\n isActive: _ctx.isActive,\n onChange: _ctx.change\n }, null, 8, [\"pattern\", \"index\", \"mode\", \"isActive\", \"onChange\"]))\n }), 128))\n ]))\n}","import { toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = [\"textContent\"]\nconst _hoisted_2 = [\"textContent\"]\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", {\n onClick: _cache[0] || (_cache[0] = ($event: any) => (_ctx.change(_ctx.index))),\n class: _normalizeClass(['pattern-item',\r\n _ctx.index === _ctx.mode && _ctx.isActive === true ?\r\n 'pattern-item_selected' : '',\r\n ])\n }, [\n _createElementVNode(\"span\", {\n class: \"pattern-item__icon\",\n textContent: _toDisplayString(_ctx.pattern.icon)\n }, null, 8, _hoisted_1),\n _createElementVNode(\"span\", {\n class: \"pattern-item__name\",\n textContent: _toDisplayString(_ctx.pattern.name)\n }, null, 8, _hoisted_2)\n ], 2))\n}","\r\n import { defineComponent } from 'vue';\r\n\r\n export default defineComponent({\r\n name: 'PatternItem',\r\n props: {\r\n pattern: {\r\n type: Object,\r\n },\r\n index: {\r\n type: Number,\r\n },\r\n mode: {\r\n type: Number,\r\n },\r\n isActive: {\r\n type: Boolean,\r\n },\r\n },\r\n methods: {\r\n change: function (index: number): void {\r\n this.$emit('change', index as number);\r\n },\r\n },\r\n });\r\n","import { render } from \"./PatternItem.vue?vue&type=template&id=f864fdb0&ts=true\"\nimport script from \"./PatternItem.vue?vue&type=script&lang=ts\"\nexport * from \"./PatternItem.vue?vue&type=script&lang=ts\"\n\nimport \"./PatternItem.vue?vue&type=style&index=0&id=f864fdb0&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","\r\n import { defineComponent } from 'vue';\r\n import PatternItem from '@/components/PatternItem.vue';\r\n\r\n export default defineComponent({\r\n name: 'PatternList',\r\n props: {\r\n patterns: {\r\n type: Array,\r\n },\r\n mode: {\r\n type: Number,\r\n },\r\n isActive: {\r\n type: Boolean,\r\n },\r\n },\r\n components: {\r\n PatternItem: PatternItem,\r\n },\r\n methods: {\r\n change: function (index: number): void {\r\n this.$emit('change', index as number);\r\n },\r\n },\r\n });\r\n","import { render } from \"./PatternList.vue?vue&type=template&id=7b6b7b1f&ts=true\"\nimport script from \"./PatternList.vue?vue&type=script&lang=ts\"\nexport * from \"./PatternList.vue?vue&type=script&lang=ts\"\n\nimport \"./PatternList.vue?vue&type=style&index=0&id=7b6b7b1f&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"device-list\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n const _component_GamepadItem = _resolveComponent(\"GamepadItem\")!\n\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.gamepads, (gamepad) => {\n return (_openBlock(), _createBlock(_component_GamepadItem, {\n key: gamepad.id,\n textContent: _toDisplayString(gamepad.unit.id)\n }, null, 8, [\"textContent\"]))\n }), 128))\n ]))\n}","import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"list-item\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1))\n}","\r\n import { defineComponent } from 'vue';\r\n\r\n export default defineComponent({\r\n name: 'GamepadItem',\r\n });\r\n","import { render } from \"./GamepadItem.vue?vue&type=template&id=e6e6c988&ts=true\"\nimport script from \"./GamepadItem.vue?vue&type=script&lang=ts\"\nexport * from \"./GamepadItem.vue?vue&type=script&lang=ts\"\n\nimport \"./GamepadItem.vue?vue&type=style&index=0&id=e6e6c988&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","\r\n import { defineComponent } from 'vue';\r\n import GamepadItem from '@/components/GamepadItem.vue';\r\n\r\n export default defineComponent({\r\n name: 'GamepadList',\r\n props: {\r\n gamepads: {\r\n type: Array,\r\n },\r\n },\r\n components: {\r\n GamepadItem: GamepadItem,\r\n },\r\n });\r\n ","import { render } from \"./GamepadList.vue?vue&type=template&id=1d58b1c0&ts=true\"\nimport script from \"./GamepadList.vue?vue&type=script&lang=ts\"\nexport * from \"./GamepadList.vue?vue&type=script&lang=ts\"\n\nimport \"./GamepadList.vue?vue&type=style&index=0&id=1d58b1c0&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"message\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n _createElementVNode(\"span\", null, [\n _renderSlot(_ctx.$slots, \"default\")\n ])\n ]))\n}","\r\n import { defineComponent } from 'vue';\r\n\r\n export default defineComponent({\r\n name: 'MessageItem',\r\n });\r\n","import { render } from \"./MessageItem.vue?vue&type=template&id=32e2819b&ts=true\"\nimport script from \"./MessageItem.vue?vue&type=script&lang=ts\"\nexport * from \"./MessageItem.vue?vue&type=script&lang=ts\"\n\nimport \"./MessageItem.vue?vue&type=style&index=0&id=32e2819b&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import TPatternUnit from '@/models/TPatternUnit';\r\nimport IGamepad from '@/models/IGamepad';\r\nimport IVibrator from '@/models/IVibrator';\r\n\r\nclass Vibrator implements IVibrator {\r\n readonly id: number;\r\n readonly canVibrate: boolean;\r\n isVibrating: boolean;\r\n unit: IGamepad;\r\n pattern: TPatternUnit[];\r\n\r\n constructor(unit: IGamepad) {\r\n this.unit = unit;\r\n this.id = Date.now();\r\n this.canVibrate = (this.unit.vibrationActuator) ? true : false;\r\n this.isVibrating = false;\r\n this.pattern = [];\r\n }\r\n\r\n update(): void {\r\n const gamepads = navigator.getGamepads();\r\n this.unit = gamepads[this.unit.index];\r\n }\r\n\r\n reset(): void {\r\n this.isVibrating = false;\r\n this.unit.vibrationActuator.reset();\r\n }\r\n\r\n async vibrate(pattern: TPatternUnit[]) {\r\n this.isVibrating = true;\r\n this.pattern = pattern;\r\n\r\n while (this.isVibrating === true) {\r\n for (let i = 0; i < this.pattern.length; i++) {\r\n if (this.isVibrating === true) {\r\n this.unit.vibrationActuator.playEffect('dual-rumble', this.pattern[i]);\r\n await this.sleep(this.pattern[i].startDelay + this.pattern[i].duration);\r\n } else {\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n\r\n sleep(ms: number): Promise {\r\n return new Promise(resolve => setTimeout(resolve, ms));\r\n }\r\n}\r\n\r\nexport default Vibrator;\r\n\r\n","import { createStore } from 'vuex';\r\nimport IGamepad from '@/models/IGamepad';\r\nimport IGamepadEvent from '@/models/IGamepadEvent';\r\nimport TPattern from '@/models/TPattern';\r\nimport TPatternUnit from '@/models/TPatternUnit';\r\nimport Vibrator from '@/models/Vibrator';\r\n\r\nexport default createStore({\r\n state: {\r\n gamepads: [] as Vibrator[],\r\n patterns: [] as TPattern[],\r\n mode: 0 as number,\r\n isActive: false as boolean,\r\n },\r\n getters: {\r\n gamepads: function (state): Vibrator[] {\r\n return state.gamepads as Vibrator[];\r\n },\r\n patterns: function (state): TPattern[] {\r\n return state.patterns as TPattern[];\r\n },\r\n mode: function (state): number {\r\n return state.mode as number;\r\n },\r\n isActive: function (state): boolean {\r\n return state.isActive as boolean;\r\n },\r\n },\r\n mutations: {\r\n setPatterns: function (state, patterns: TPattern[]): void {\r\n state.patterns = patterns as TPattern[];\r\n },\r\n setMode: function (state, mode: number): void {\r\n state.mode = mode as number;\r\n },\r\n setIsActive: function (state, isActive: boolean): void {\r\n state.isActive = isActive as boolean;\r\n },\r\n addGamepad: function (state, gamepad: Vibrator): void {\r\n state.gamepads.push(gamepad as Vibrator);\r\n },\r\n deleteGamepad: function (state, index: number): void {\r\n state.gamepads.splice(index, 1);\r\n },\r\n },\r\n actions: {\r\n loadPatterns: async function (context): Promise {\r\n const url = 'https://wavelovers.ru/assets/patterns.json';\r\n try {\r\n const response: Response = await fetch(url);\r\n if (response.ok) {\r\n const json: TPattern[] = await response.json();\r\n context.commit('setPatterns', json as TPattern[]);\r\n } else {\r\n console.log('Connect to the Internet for download more patterns...');\r\n }\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n },\r\n setMode: function (context, index: number): void {\r\n context.commit('setMode', index as number);\r\n },\r\n setIsActive: function (context, isActive: boolean): void {\r\n context.commit('setIsActive', isActive as boolean);\r\n },\r\n addGamepad: function (context, event: GamepadEvent): void {\r\n const iEvent: IGamepadEvent = event as unknown as IGamepadEvent;\r\n if (context.getters.gamepads.length >= 1) {\r\n return;\r\n } else {\r\n context.commit('addGamepad', new Vibrator(iEvent.gamepad as IGamepad));\r\n }\r\n },\r\n deleteGamepad: function (context, event: GamepadEvent): void {\r\n context.getters.gamepads.forEach((gamepad: Vibrator, index: number) => {\r\n if (gamepad.unit.id === event.gamepad.id) {\r\n context.commit('deleteGamepad', index as number);\r\n }\r\n });\r\n },\r\n vibrate: function (context): void {\r\n context.getters.gamepads.forEach((gamepad: Vibrator) => {\r\n gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]);\r\n });\r\n },\r\n reset: function (context): void {\r\n context.getters.gamepads.forEach((gamepad: Vibrator) => {\r\n gamepad.reset();\r\n });\r\n },\r\n change: function (context, index: number): void {\r\n if (context.getters.mode === index) {\r\n context.dispatch('setIsActive', !context.getters.isActive);\r\n } else {\r\n context.dispatch('setIsActive', true);\r\n context.dispatch('setMode', index);\r\n }\r\n if (context.getters.isActive === true) {\r\n context.dispatch('reset');\r\n context.dispatch('vibrate');\r\n } else {\r\n context.dispatch('reset');\r\n }\r\n },\r\n },\r\n modules: {},\r\n});\r\n\r\n","\r\n import { defineComponent } from 'vue';\r\n import PatternList from '@/components/PatternList.vue';\r\n import GamepadList from '@/components/GamepadList.vue';\r\n import MessageItem from '@/components/MessageItem.vue';\r\n import TPattern from '@/models/TPattern';\r\n import Vibrator from '@/models/Vibrator';\r\n import store from '@/store/index';\r\n\r\n export default defineComponent({\r\n name: 'WaveloversApp',\r\n components: {\r\n PatternList: PatternList,\r\n GamepadList: GamepadList,\r\n MessageItem: MessageItem,\r\n },\r\n computed: {\r\n gamepads: function (): Vibrator[] {\r\n return store.getters.gamepads as Vibrator[];\r\n },\r\n patterns: function (): TPattern[] {\r\n return store.getters.patterns as TPattern[];\r\n },\r\n mode: function (): number {\r\n return store.getters.mode as number;\r\n },\r\n isActive: function (): boolean {\r\n return store.getters.isActive as boolean;\r\n },\r\n },\r\n methods: {\r\n addEventListeners(): void {\r\n window.addEventListener('gamepadconnected', (event: GamepadEvent) => store.dispatch('addGamepad', event));\r\n window.addEventListener('gamepaddisconnected', (event: GamepadEvent) => store.dispatch('deleteGamepad', event));\r\n },\r\n removeEventListeners(): void {\r\n window.removeEventListener('gamepadconnected', (event: GamepadEvent) => store.dispatch('addGamepad', event));\r\n window.removeEventListener('gamepaddisconnected', (event: GamepadEvent) => store.dispatch('deleteGamepad', event));\r\n },\r\n change(index: number): void {\r\n store.dispatch('change', index as number);\r\n },\r\n },\r\n mounted() {\r\n store.dispatch('loadPatterns');\r\n this.addEventListeners();\r\n },\r\n unmounted() {\r\n this.removeEventListeners();\r\n },\r\n });\r\n","import { render } from \"./WaveloversApp.vue?vue&type=template&id=34f165d2&ts=true\"\nimport script from \"./WaveloversApp.vue?vue&type=script&lang=ts\"\nexport * from \"./WaveloversApp.vue?vue&type=script&lang=ts\"\n\nimport \"./WaveloversApp.vue?vue&type=style&index=0&id=34f165d2&lang=scss\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","\n import { defineComponent } from 'vue';\n import WaveloversApp from '@/components/WaveloversApp.vue';\n\n export default defineComponent({\n name: 'App',\n components: {\n WaveloversApp: WaveloversApp,\n },\n });\n","import { render } from \"./App.vue?vue&type=template&id=4be8096e&ts=true\"\nimport script from \"./App.vue?vue&type=script&lang=ts\"\nexport * from \"./App.vue?vue&type=script&lang=ts\"\n\nimport exportComponent from \"E:\\\\Sources\\\\Repos\\\\wavelovers\\\\node_modules\\\\vue-loader\\\\dist\\\\exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { createApp } from 'vue';\r\nimport App from './App.vue';\r\nimport store from './store';\r\n\r\ncreateApp(App).use(store).mount('#app');\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = function(result, chunkIds, fn, priority) {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar chunkIds = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t143: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = function(chunkId) { return installedChunks[chunkId] === 0; };\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = function(parentChunkLoadingFunction, data) {\n\tvar chunkIds = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkwavelovers\"] = self[\"webpackChunkwavelovers\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [998], function() { return __webpack_require__(6665); })\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["render","_ctx","_cache","$props","$setup","$data","$options","_component_WaveloversApp","_resolveComponent","_openBlock","_createBlock","_hoisted_1","class","_hoisted_2","_createTextVNode","_hoisted_3","_component_PatternList","_component_MessageItem","_component_GamepadList","_createElementBlock","patterns","length","key","mode","isActive","onChange","change","default","_withCtx","_","gamepads","_component_PatternItem","_Fragment","_renderList","pattern","index","name","onClick","$event","_normalizeClass","_createElementVNode","textContent","_toDisplayString","icon","defineComponent","props","type","Object","Number","Boolean","methods","this","$emit","__exports__","Array","components","PatternItem","_component_GamepadItem","gamepad","id","unit","GamepadItem","_renderSlot","$slots","Vibrator","constructor","Date","now","canVibrate","vibrationActuator","isVibrating","update","navigator","getGamepads","reset","i","playEffect","sleep","startDelay","duration","ms","Promise","resolve","setTimeout","createStore","state","getters","mutations","setPatterns","setMode","setIsActive","addGamepad","push","deleteGamepad","splice","actions","loadPatterns","async","context","url","response","fetch","ok","json","commit","console","log","error","event","iEvent","forEach","vibrate","dispatch","modules","PatternList","GamepadList","MessageItem","computed","store","addEventListeners","window","addEventListener","removeEventListeners","removeEventListener","mounted","unmounted","WaveloversApp","createApp","App","use","mount","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","m","deferred","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","get","g","globalThis","Function","e","obj","prop","prototype","hasOwnProperty","call","installedChunks","chunkId","webpackJsonpCallback","parentChunkLoadingFunction","data","moreModules","runtime","some","chunkLoadingGlobal","self","bind","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/sitemap-internal.xml b/docs/sitemap-internal.xml index 32ec2d7..a8b8dca 100644 --- a/docs/sitemap-internal.xml +++ b/docs/sitemap-internal.xml @@ -2,25 +2,25 @@ https://wavelovers.ru/ - 2022-08-05 + 2022-08-06 weekly 1.0 https://wavelovers.ru/faq.html - 2022-08-05 + 2022-08-06 weekly 1.0 https://wavelovers.ru/about.html - 2022-08-05 + 2022-08-06 weekly 1.0 https://wavelovers.ru/donate.html - 2022-08-05 + 2022-08-06 weekly 1.0 diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 5a661a6..4e62920 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -2,7 +2,7 @@ https://wavelovers.ru/sitemap-internal.xml - 2022-08-05 + 2022-08-06 diff --git a/public/sitemap-internal.xml b/public/sitemap-internal.xml index 32ec2d7..a8b8dca 100644 --- a/public/sitemap-internal.xml +++ b/public/sitemap-internal.xml @@ -2,25 +2,25 @@ https://wavelovers.ru/ - 2022-08-05 + 2022-08-06 weekly 1.0 https://wavelovers.ru/faq.html - 2022-08-05 + 2022-08-06 weekly 1.0 https://wavelovers.ru/about.html - 2022-08-05 + 2022-08-06 weekly 1.0 https://wavelovers.ru/donate.html - 2022-08-05 + 2022-08-06 weekly 1.0 diff --git a/public/sitemap.xml b/public/sitemap.xml index 5a661a6..4e62920 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -2,7 +2,7 @@ https://wavelovers.ru/sitemap-internal.xml - 2022-08-05 + 2022-08-06 diff --git a/src/store/index.ts b/src/store/index.ts index a7d799a..78239b5 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,94 +1,42 @@ -import { createStore } from 'vuex'; -import IGamepad from '@/models/IGamepad'; -import IGamepadEvent from '@/models/IGamepadEvent'; -import TPattern from '@/models/TPattern'; -import TPatternUnit from '@/models/TPatternUnit'; -import Vibrator from '@/models/Vibrator'; +import { createStore, Store } from 'vuex'; +import IRootState from './models/IRootState'; +import MGamepads from '@/store/modules/MGamepads'; +import MPatterns from '@/store/modules/MPatterns'; -export default createStore({ - state: { - gamepads: [] as Vibrator[], - patterns: [] as TPattern[], +const store: Store = createStore({ + state: () => ({ mode: 0 as number, isActive: false as boolean, - }, + }), getters: { - gamepads: function (state): Vibrator[] { - return state.gamepads as Vibrator[]; - }, - patterns: function (state): TPattern[] { - return state.patterns as TPattern[]; - }, - mode: function (state): number { + mode: function (state: IRootState): number { return state.mode as number; }, - isActive: function (state): boolean { + isActive: function (state: IRootState): boolean { return state.isActive as boolean; }, }, mutations: { - setPatterns: function (state, patterns: TPattern[]): void { - state.patterns = patterns as TPattern[]; - }, - setMode: function (state, mode: number): void { + setMode: function (state: IRootState, mode: number): void { state.mode = mode as number; }, - setIsActive: function (state, isActive: boolean): void { + setIsActive: function (state: IRootState, isActive: boolean): void { state.isActive = isActive as boolean; }, - addGamepad: function (state, gamepad: Vibrator): void { - state.gamepads.push(gamepad as Vibrator); - }, - deleteGamepad: function (state, index: number): void { - state.gamepads.splice(index, 1); - }, }, actions: { - loadPatterns: async function (context): Promise { - const url = 'https://wavelovers.ru/assets/patterns.json'; - try { - const response: Response = await fetch(url); - if (response.ok) { - const json: TPattern[] = await response.json(); - context.commit('setPatterns', json as TPattern[]); - } else { - console.log('Connect to the Internet for download more patterns...'); - } - } catch (error) { - console.log(error); - } - }, - setMode: function (context, index: number): void { + setMode: function ( + context, + index: number + ): void { context.commit('setMode', index as number); }, - setIsActive: function (context, isActive: boolean): void { + setIsActive: function ( + context, + isActive: boolean + ): void { context.commit('setIsActive', isActive as boolean); }, - addGamepad: function (context, event: GamepadEvent): void { - const iEvent: IGamepadEvent = event as unknown as IGamepadEvent; - if (context.getters.gamepads.length >= 1) { - return; - } else { - context.commit('addGamepad', new Vibrator(iEvent.gamepad as IGamepad)); - } - }, - deleteGamepad: function (context, event: GamepadEvent): void { - context.getters.gamepads.forEach((gamepad: Vibrator, index: number) => { - if (gamepad.unit.id === event.gamepad.id) { - context.commit('deleteGamepad', index as number); - } - }); - }, - vibrate: function (context): void { - context.getters.gamepads.forEach((gamepad: Vibrator) => { - gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]); - }); - }, - reset: function (context): void { - context.getters.gamepads.forEach((gamepad: Vibrator) => { - gamepad.reset(); - }); - }, change: function (context, index: number): void { if (context.getters.mode === index) { context.dispatch('setIsActive', !context.getters.isActive); @@ -104,6 +52,11 @@ export default createStore({ } }, }, - modules: {}, + modules: { + MGamepads: MGamepads, + MPatterns: MPatterns, + }, }); +export default store; + diff --git a/src/store/models/IGamepadsState.ts b/src/store/models/IGamepadsState.ts new file mode 100644 index 0000000..85e0824 --- /dev/null +++ b/src/store/models/IGamepadsState.ts @@ -0,0 +1,8 @@ +import Vibrator from '@/models/Vibrator'; + +interface IGamepadsState { + gamepads: Vibrator[]; +} + +export default IGamepadsState; + diff --git a/src/store/models/IPatternState.ts b/src/store/models/IPatternState.ts new file mode 100644 index 0000000..cff8290 --- /dev/null +++ b/src/store/models/IPatternState.ts @@ -0,0 +1,8 @@ +import TPattern from '@/models/TPattern'; + +interface IPatternState { + patterns: TPattern[]; +} + +export default IPatternState; + diff --git a/src/store/models/IRootState.ts b/src/store/models/IRootState.ts new file mode 100644 index 0000000..07b2e4e --- /dev/null +++ b/src/store/models/IRootState.ts @@ -0,0 +1,7 @@ +interface IRootState { + mode: number; + isActive: boolean; +} + +export default IRootState; + diff --git a/src/store/modules/MGamepads.ts b/src/store/modules/MGamepads.ts new file mode 100644 index 0000000..4732627 --- /dev/null +++ b/src/store/modules/MGamepads.ts @@ -0,0 +1,66 @@ +import { ActionContext, Module } from 'vuex'; +import IRootState from '@/store/models/IRootState'; +import IGamepadsState from '@/store/models/IGamepadsState'; +import Vibrator from '@/models/Vibrator'; +import IGamepad from '@/models/IGamepad'; +import IGamepadEvent from '@/models/IGamepadEvent'; +import TPatternUnit from '@/models/TPatternUnit'; + +const MGamepads: Module = { + state: () => ({ + gamepads: [] as Vibrator[], + }), + getters: { + gamepads: function (state: IGamepadsState): Vibrator[] { + return state.gamepads as Vibrator[]; + }, + }, + mutations: { + addGamepad: function (state: IGamepadsState, gamepad: Vibrator): void { + state.gamepads.push(gamepad as Vibrator); + }, + deleteGamepad: function (state: IGamepadsState, index: number): void { + state.gamepads.splice(index, 1); + }, + }, + actions: { + addGamepad: function ( + context: ActionContext, + event: GamepadEvent + ): void { + const iEvent: IGamepadEvent = event as unknown as IGamepadEvent; + if (context.getters.gamepads.length >= 1) { + return; + } else { + context.commit('addGamepad', new Vibrator(iEvent.gamepad as IGamepad)); + } + }, + deleteGamepad: function ( + context: ActionContext, + event: GamepadEvent + ): void { + context.getters.gamepads.forEach((gamepad: Vibrator, index: number) => { + if (gamepad.unit.id === event.gamepad.id) { + context.commit('deleteGamepad', index as number); + } + }); + }, + vibrate: function ( + context: ActionContext + ): void { + context.getters.gamepads.forEach((gamepad: Vibrator) => { + gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]); + }); + }, + reset: function ( + context: ActionContext + ): void { + context.getters.gamepads.forEach((gamepad: Vibrator) => { + gamepad.reset(); + }); + }, + }, +}; + +export default MGamepads; + diff --git a/src/store/modules/MPatterns.ts b/src/store/modules/MPatterns.ts new file mode 100644 index 0000000..5a80ea6 --- /dev/null +++ b/src/store/modules/MPatterns.ts @@ -0,0 +1,41 @@ +import { ActionContext, Module } from 'vuex'; +import IRootState from '@/store/models/IRootState'; +import IPatternState from '@/store/models/IPatternState'; +import TPattern from '@/models/TPattern'; + +const MPatterns: Module = { + state: () => ({ + patterns: [] as TPattern[], + }), + getters: { + patterns: function (state: IPatternState): TPattern[] { + return state.patterns as TPattern[]; + }, + }, + mutations: { + setPatterns: function (state: IPatternState, patterns: TPattern[]): void { + state.patterns = patterns as TPattern[]; + }, + }, + actions: { + loadPatterns: async function ( + context: ActionContext + ): Promise { + const url = 'https://wavelovers.ru/assets/patterns.json'; + try { + const response: Response = await fetch(url); + if (response.ok) { + const json: TPattern[] = await response.json(); + context.commit('setPatterns', json as TPattern[]); + } else { + console.log('Connect to the Internet for download more patterns...'); + } + } catch (error) { + console.log(error); + } + }, + }, +}; + +export default MPatterns; +