From 82518c0b6bcd1718e35715f056b7b8ed88e0316e Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sat, 20 Jan 2024 15:10:56 +0100 Subject: [PATCH] Feat: add nosleep --- package-lock.json | 17 +++++++++++++++++ package.json | 2 ++ src/routes/+page.svelte | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/package-lock.json b/package-lock.json index 932f2d2..3470fa3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,12 +8,14 @@ "name": "bluetooth-buzzer", "version": "0.0.1", "dependencies": { + "nosleep.js": "^0.12.0", "ua-parser-js": "^1.0.37" }, "devDependencies": { "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-static": "^2.0.3", "@sveltejs/kit": "^1.27.4", + "@types/nosleep.js": "^0.10.0", "@types/ua-parser-js": "^0.7.39", "@types/web-bluetooth": "^0.0.20", "@typescript-eslint/eslint-plugin": "^6.0.0", @@ -766,6 +768,16 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "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": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz", @@ -2592,6 +2604,11 @@ "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": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", diff --git a/package.json b/package.json index bcbbfc5..59ba03b 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-static": "^2.0.3", "@sveltejs/kit": "^1.27.4", + "@types/nosleep.js": "^0.10.0", "@types/ua-parser-js": "^0.7.39", "@types/web-bluetooth": "^0.0.20", "@typescript-eslint/eslint-plugin": "^6.0.0", @@ -38,6 +39,7 @@ }, "type": "module", "dependencies": { + "nosleep.js": "^0.12.0", "ua-parser-js": "^1.0.37" } } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index a828ec9..a259122 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -4,8 +4,10 @@ import { bluetoothState } from '../stores'; import { UAParser } from 'ua-parser-js'; import Timer from './Timer.svelte'; + import NoSleep from 'nosleep.js'; const uap = new UAParser(); + const noSleep = new NoSleep(); let timer: Timer; let state: 'idle' | 'wait' | 'ready' | 'running' = 'idle'; @@ -15,6 +17,10 @@ }; const start = async () => { + if (!noSleep.isEnabled) { + noSleep.enable(); + } + state = 'wait'; await delay(3000); state = 'ready';