Feat: add nosleep
All checks were successful
/ build (push) Successful in 3m36s

This commit is contained in:
Dorian Zedler 2024-01-20 15:10:56 +01:00
parent 7230eaca2b
commit 82518c0b6b
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 25 additions and 0 deletions

17
package-lock.json generated
View file

@ -8,12 +8,14 @@
"name": "bluetooth-buzzer", "name": "bluetooth-buzzer",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"nosleep.js": "^0.12.0",
"ua-parser-js": "^1.0.37" "ua-parser-js": "^1.0.37"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.3", "@sveltejs/adapter-static": "^2.0.3",
"@sveltejs/kit": "^1.27.4", "@sveltejs/kit": "^1.27.4",
"@types/nosleep.js": "^0.10.0",
"@types/ua-parser-js": "^0.7.39", "@types/ua-parser-js": "^0.7.39",
"@types/web-bluetooth": "^0.0.20", "@types/web-bluetooth": "^0.0.20",
"@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/eslint-plugin": "^6.0.0",
@ -766,6 +768,16 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"dev": true "dev": true
}, },
"node_modules/@types/nosleep.js": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/@types/nosleep.js/-/nosleep.js-0.10.0.tgz",
"integrity": "sha512-eFRD95pEYIPo7YZnRbasEJAwSzBOxkT9++vZ7ykoDDuxvBauSuEGKZsijLm2BzohGt5wIj8gSiI+9vwjKfmNgA==",
"deprecated": "This is a stub types definition. nosleep.js provides its own type definitions, so you do not need this installed.",
"dev": true,
"dependencies": {
"nosleep.js": "*"
}
},
"node_modules/@types/pug": { "node_modules/@types/pug": {
"version": "2.0.10", "version": "2.0.10",
"resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz", "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz",
@ -2592,6 +2604,11 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/nosleep.js": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/nosleep.js/-/nosleep.js-0.12.0.tgz",
"integrity": "sha512-9d1HbpKLh3sdWlhXMhU6MMH+wQzKkrgfRkYV0EBdvt99YJfj0ilCJrWRDYG2130Tm4GXbEoTCx5b34JSaP+HhA=="
},
"node_modules/object-assign": { "node_modules/object-assign": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",

View file

@ -15,6 +15,7 @@
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.3", "@sveltejs/adapter-static": "^2.0.3",
"@sveltejs/kit": "^1.27.4", "@sveltejs/kit": "^1.27.4",
"@types/nosleep.js": "^0.10.0",
"@types/ua-parser-js": "^0.7.39", "@types/ua-parser-js": "^0.7.39",
"@types/web-bluetooth": "^0.0.20", "@types/web-bluetooth": "^0.0.20",
"@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/eslint-plugin": "^6.0.0",
@ -38,6 +39,7 @@
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"nosleep.js": "^0.12.0",
"ua-parser-js": "^1.0.37" "ua-parser-js": "^1.0.37"
} }
} }

View file

@ -4,8 +4,10 @@
import { bluetoothState } from '../stores'; import { bluetoothState } from '../stores';
import { UAParser } from 'ua-parser-js'; import { UAParser } from 'ua-parser-js';
import Timer from './Timer.svelte'; import Timer from './Timer.svelte';
import NoSleep from 'nosleep.js';
const uap = new UAParser(); const uap = new UAParser();
const noSleep = new NoSleep();
let timer: Timer; let timer: Timer;
let state: 'idle' | 'wait' | 'ready' | 'running' = 'idle'; let state: 'idle' | 'wait' | 'ready' | 'running' = 'idle';
@ -15,6 +17,10 @@
}; };
const start = async () => { const start = async () => {
if (!noSleep.isEnabled) {
noSleep.enable();
}
state = 'wait'; state = 'wait';
await delay(3000); await delay(3000);
state = 'ready'; state = 'ready';