mirror of
https://github.com/eugene-serb/wavelovers.git
synced 2023-09-09 23:41:16 +03:00
Decomposited global imports, fixed warnings, updates
This commit is contained in:
parent
02c1ccfe45
commit
f17dcd3346
@ -1,5 +1,5 @@
|
||||
# Wavelovers
|
||||
Wavelovers in ***VueJS***, ***Typescript***, ***Javascript***, ***HTML*** and ***CSS*** **[[rep](https://github.com/eugene-serb/wavelovers/), [site](https://wavelovers.ru/)]**.
|
||||
Wavelovers in ***VueJS***, ***Typescript***, ***Javascript***, ***HTML***, ***CSS*** and ***SCSS*** **[[rep](https://github.com/eugene-serb/wavelovers/), [site](https://wavelovers.ru/)]**.
|
||||
|
||||
This is Wavelovers, which can make a vibrating massager out of a gamepad. It has 16 free vibration patterns to play with.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Wavelovers
|
||||
Wavelovers in ***VueJS***, ***Typescript***, ***Javascript***, ***HTML*** and ***CSS*** **[[rep](https://github.com/eugene-serb/wavelovers/), [site](https://wavelovers.ru/)]**.
|
||||
Wavelovers in ***VueJS***, ***Typescript***, ***Javascript***, ***HTML***, ***CSS*** and ***SCSS*** **[[rep](https://github.com/eugene-serb/wavelovers/), [site](https://wavelovers.ru/)]**.
|
||||
|
||||
This is Wavelovers, which can make a vibrating massager out of a gamepad. It has 16 free vibration patterns to play with.
|
||||
|
||||
|
@ -15,4 +15,4 @@
|
||||
trackLinks: true,
|
||||
accurateTrackBounce: true,
|
||||
webvisor: true
|
||||
});</script><script defer="defer" src="/js/chunk-vendors.277755a1.js"></script><script defer="defer" src="/js/app.5a72835e.js"></script><link href="/css/app.a72a8a93.css" rel="stylesheet"></head><body><header class="header"><div class="header-wrapper container"><div class="logo-wrapper"><span class="logo-wrapper__logo" translate="no">Wavelovers</span></div><nav class="menu-wrapper"><ul class="navigation"><li class="navigation__item"><a href="https://wavelovers.ru/" target="_self" class="navigation__link">Home</a></li><li class="navigation__item"><a href="https://wavelovers.ru/faq.html" target="_self" class="navigation__link">FAQ</a></li><li class="navigation__item"><a href="https://wavelovers.ru/about.html" target="_self" class="navigation__link">About</a></li><li class="navigation__item"><a href="https://wavelovers.ru/about.html#donate" target="_self" class="navigation__link">Donate</a></li></ul></nav></div></header><main class="page container"><h1 class="visually-hidden">Wavelovers</h1><noscript>You need to enable JavaScript to run this app.</noscript><div id="app" v-cloak></div></main><footer class="footer"><div class="footer-wrapper container"><div class="annotation"><span class="annotation__text">© 2022 Wavelovers. Content licensed under </span><a href="https://wavelovers.ru/LICENSE.md" target="_blank">GNU General Public License v3.0</a><br><span class="annotation__text">This site is open source. </span><a href="https://github.com/eugene-serb/wavelovers/" target="_blank">Improve this page.</a></div><div class="annotation created-by"><span class="annotation__text">Created by</span><a href="https://eugene-serb.github.io/" target="_blank" translate="no">Eugene Serb</a></div></div></footer><noscript><div><img src="https://mc.yandex.ru/watch/89252711" style="position:absolute; left:-9999px;" alt=""/></div></noscript></body></html>
|
||||
});</script><script defer="defer" src="/js/chunk-vendors.277755a1.js"></script><script defer="defer" src="/js/app.65320b71.js"></script><link href="/css/app.a72a8a93.css" rel="stylesheet"></head><body><header class="header"><div class="header-wrapper container"><div class="logo-wrapper"><span class="logo-wrapper__logo" translate="no">Wavelovers</span></div><nav class="menu-wrapper"><ul class="navigation"><li class="navigation__item"><a href="https://wavelovers.ru/" target="_self" class="navigation__link">Home</a></li><li class="navigation__item"><a href="https://wavelovers.ru/faq.html" target="_self" class="navigation__link">FAQ</a></li><li class="navigation__item"><a href="https://wavelovers.ru/about.html" target="_self" class="navigation__link">About</a></li><li class="navigation__item"><a href="https://wavelovers.ru/about.html#donate" target="_self" class="navigation__link">Donate</a></li></ul></nav></div></header><main class="page container"><h1 class="visually-hidden">Wavelovers</h1><noscript>You need to enable JavaScript to run this app.</noscript><div id="app" v-cloak></div></main><footer class="footer"><div class="footer-wrapper container"><div class="annotation"><span class="annotation__text">© 2022 Wavelovers. Content licensed under </span><a href="https://wavelovers.ru/LICENSE.md" target="_blank">GNU General Public License v3.0</a><br><span class="annotation__text">This site is open source. </span><a href="https://github.com/eugene-serb/wavelovers/" target="_blank">Improve this page.</a></div><div class="annotation created-by"><span class="annotation__text">Created by</span><a href="https://eugene-serb.github.io/" target="_blank" translate="no">Eugene Serb</a></div></div></footer><noscript><div><img src="https://mc.yandex.ru/watch/89252711" style="position:absolute; left:-9999px;" alt=""/></div></noscript></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
docs/js/app.65320b71.js
Normal file
2
docs/js/app.65320b71.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/js/app.65320b71.js.map
Normal file
1
docs/js/app.65320b71.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "wavelovers",
|
||||
"description": "Wavelovers. Use your device vibration correctly. Make a massager out of a gamepad.",
|
||||
"version": "1.0.0",
|
||||
"author": "Eugene Serb",
|
||||
"license": "GNU GPL v3",
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Wavelovers
|
||||
Wavelovers in ***VueJS***, ***Typescript***, ***Javascript***, ***HTML*** and ***CSS*** **[[rep](https://github.com/eugene-serb/wavelovers/), [site](https://wavelovers.ru/)]**.
|
||||
Wavelovers in ***VueJS***, ***Typescript***, ***Javascript***, ***HTML***, ***CSS*** and ***SCSS*** **[[rep](https://github.com/eugene-serb/wavelovers/), [site](https://wavelovers.ru/)]**.
|
||||
|
||||
This is Wavelovers, which can make a vibrating massager out of a gamepad. It has 16 free vibration patterns to play with.
|
||||
|
||||
|
1
src/components/Vibrator.d.ts
vendored
1
src/components/Vibrator.d.ts
vendored
@ -1 +0,0 @@
|
||||
declare module 'Vibrator';
|
@ -17,12 +17,12 @@
|
||||
import PatternList from '@/components/PatternList.vue';
|
||||
import GamepadList from '@/components/GamepadList.vue';
|
||||
import MessageItem from '@/components/MessageItem.vue';
|
||||
import { Vibrator, IGamepad, TPattern, TPatternUnit } from '@/components/Vibrator';
|
||||
|
||||
interface Event {
|
||||
gamepad: IGamepad | any;
|
||||
}
|
||||
|
||||
import { IGamepadEvent } from '@/models/IGamepadEvent';
|
||||
import { IGamepad } from '@/models/IGamepad';
|
||||
import { TPattern } from '@/models/TPattern';
|
||||
import { TPatternUnit } from '@/models/TPatternUnit';
|
||||
import { Vibrator } from '@/models/Vibrator';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'WaveloversApp',
|
||||
components: {
|
||||
@ -50,21 +50,22 @@
|
||||
console.log('Connect to the Internet for download more patterns...');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('[error]', error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
addEventListeners(): void {
|
||||
window.addEventListener('gamepadconnected', (event: Event) => this.addGamepad(event));
|
||||
window.addEventListener('gamepaddisconnected', (event: Event) => this.deleteGamepad(event));
|
||||
window.addEventListener('gamepadconnected', (event: GamepadEvent) => this.addGamepad(event));
|
||||
window.addEventListener('gamepaddisconnected', (event: GamepadEvent) => this.deleteGamepad(event));
|
||||
},
|
||||
addGamepad(event: Event) {
|
||||
addGamepad(event: GamepadEvent) {
|
||||
const ievent: IGamepadEvent = event as unknown as IGamepadEvent;
|
||||
if (this.gamepads.length >= 1) {
|
||||
return;
|
||||
} else {
|
||||
this.gamepads.push(new Vibrator(event.gamepad));
|
||||
this.gamepads.push(new Vibrator(ievent.gamepad as IGamepad));
|
||||
}
|
||||
},
|
||||
deleteGamepad(event: Event): void {
|
||||
deleteGamepad(event: GamepadEvent): void {
|
||||
this.gamepads.forEach((gamepad, index) => {
|
||||
if (gamepad.unit.id === event.gamepad.id) {
|
||||
this.gamepads.splice(index, 1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import { createApp } from 'vue';
|
||||
import App from './App.vue';
|
||||
|
||||
createApp(App).mount('#app')
|
||||
createApp(App).mount('#app');
|
||||
|
10
src/models/IGamepad.ts
Normal file
10
src/models/IGamepad.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { IVibrationActuator } from '@/models/IVibrationActuator';
|
||||
|
||||
export interface IGamepad {
|
||||
id: string;
|
||||
index: number;
|
||||
timestamp: number;
|
||||
connected: boolean;
|
||||
vibrationActuator: IVibrationActuator;
|
||||
}
|
||||
|
6
src/models/IGamepadEvent.ts
Normal file
6
src/models/IGamepadEvent.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { IGamepad } from '@/models/IGamepad';
|
||||
|
||||
export interface IGamepadEvent {
|
||||
gamepad: IGamepad;
|
||||
}
|
||||
|
8
src/models/IVibrationActuator.ts
Normal file
8
src/models/IVibrationActuator.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { TPatternUnit } from '@/models/TPatternUnit';
|
||||
|
||||
export interface IVibrationActuator {
|
||||
type: string;
|
||||
reset(): void;
|
||||
playEffect(mode: string, pattern: TPatternUnit): void;
|
||||
}
|
||||
|
15
src/models/IVibrator.ts
Normal file
15
src/models/IVibrator.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { TPatternUnit } from '@/models/TPatternUnit';
|
||||
import { IGamepad } from '@/models/IGamepad';
|
||||
|
||||
export interface IVibrator {
|
||||
readonly id: number,
|
||||
readonly canVibrate: boolean;
|
||||
isVibrating: boolean;
|
||||
unit: IGamepad;
|
||||
pattern: TPatternUnit[];
|
||||
update(): void;
|
||||
reset(): void;
|
||||
vibrate(pattern: TPatternUnit[]): void;
|
||||
sleep(ms: number): Promise<number>;
|
||||
}
|
||||
|
9
src/models/TPattern.ts
Normal file
9
src/models/TPattern.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { TPatternUnit } from '@/models/TPatternUnit';
|
||||
|
||||
export type TPattern = {
|
||||
name: string;
|
||||
type: string;
|
||||
icon: string;
|
||||
pattern: TPatternUnit[];
|
||||
}
|
||||
|
7
src/models/TPatternUnit.ts
Normal file
7
src/models/TPatternUnit.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export type TPatternUnit = {
|
||||
startDelay: number,
|
||||
duration: number,
|
||||
weakMagnitude: number,
|
||||
strongMagnitude: number,
|
||||
}
|
||||
|
@ -1,39 +1,6 @@
|
||||
export type TPattern = {
|
||||
pattern: TPatternUnit[];
|
||||
}
|
||||
|
||||
export type TPatternUnit = {
|
||||
startDelay: number,
|
||||
duration: number,
|
||||
weakMagnitude: number,
|
||||
strongMagnitude: number,
|
||||
}
|
||||
|
||||
export interface IVibrationActuator {
|
||||
type: string;
|
||||
reset(): void;
|
||||
playEffect(mode: string, pattern: TPatternUnit): void;
|
||||
}
|
||||
|
||||
export interface IGamepad {
|
||||
id: string;
|
||||
index: number;
|
||||
timestamp: number;
|
||||
connected: boolean;
|
||||
vibrationActuator: IVibrationActuator;
|
||||
}
|
||||
|
||||
export interface IVibrator {
|
||||
readonly id: number,
|
||||
readonly canVibrate: boolean;
|
||||
isVibrating: boolean;
|
||||
unit: IGamepad;
|
||||
pattern: TPatternUnit[];
|
||||
update(): void;
|
||||
reset(): void;
|
||||
vibrate(pattern: TPatternUnit[]): void;
|
||||
sleep(ms: number): Promise<number>;
|
||||
}
|
||||
import { TPatternUnit } from '@/models/TPatternUnit';
|
||||
import { IGamepad } from '@/models/IGamepad';
|
||||
import { IVibrator } from '@/models/IVibrator';
|
||||
|
||||
export class Vibrator implements IVibrator {
|
||||
readonly id: number;
|
||||
@ -52,7 +19,7 @@ export class Vibrator implements IVibrator {
|
||||
|
||||
update(): void {
|
||||
const gamepads = navigator.getGamepads();
|
||||
this.unit = <IGamepad><any>gamepads[this.unit.index];
|
||||
this.unit = <IGamepad><unknown>gamepads[this.unit.index];
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
@ -79,4 +46,5 @@ export class Vibrator implements IVibrator {
|
||||
sleep(ms: number): Promise<number> {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
src/shims-vue.d.ts
vendored
8
src/shims-vue.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
/* eslint-disable */
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user