aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2023-09-29 10:11:33 -0500
committerMatt Strapp <matt@mattstrapp.net>2023-09-29 10:11:33 -0500
commit11ece69e006b446b9ca4e06eb5af5662bc811469 (patch)
tree29dbb0b4b88aa9eae29d80f5ebc08b8f710f51f8 /app/src/lib
parentUpdate dep + fix build (diff)
downloadtrinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar
trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.gz
trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.bz2
trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.lz
trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.xz
trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.zst
trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.zip
Formatting
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r--app/src/lib/svelte/Navigation.svelte20
-rw-r--r--app/src/lib/svelte/ReloadPrompt.svelte60
-rw-r--r--app/src/lib/ts/download.ts32
-rw-r--r--app/src/lib/ts/truncate.worker.ts14
-rw-r--r--app/src/lib/types/truncate-worker.ts10
5 files changed, 67 insertions, 69 deletions
diff --git a/app/src/lib/svelte/Navigation.svelte b/app/src/lib/svelte/Navigation.svelte
index 9246c28..fa9182f 100644
--- a/app/src/lib/svelte/Navigation.svelte
+++ b/app/src/lib/svelte/Navigation.svelte
@@ -1,22 +1,22 @@
<script lang="ts">
- import { page } from '$app/stores';
+ import { page } from '$app/stores'
- import Icon from '@iconify/svelte';
- import homeIcon from '@iconify/icons-carbon/home';
- import logoGithub from '@iconify/icons-carbon/logo-github';
- import menuIcon from '@iconify/icons-carbon/menu';
- import pageBreak from '@iconify/icons-carbon/page-break';
+ import Icon from '@iconify/svelte'
+ import homeIcon from '@iconify/icons-carbon/home'
+ import logoGithub from '@iconify/icons-carbon/logo-github'
+ import menuIcon from '@iconify/icons-carbon/menu'
+ import pageBreak from '@iconify/icons-carbon/page-break'
- import { AppRail, AppRailAnchor, getDrawerStore } from '@skeletonlabs/skeleton';
+ import { AppRail, AppRailAnchor, getDrawerStore } from '@skeletonlabs/skeleton'
- const drawerStore = getDrawerStore();
+ const drawerStore = getDrawerStore()
function drawerClose(): void {
- drawerStore.close();
+ drawerStore.close()
}
// Hamburgers
- export let menu = false;
+ export let menu = false
</script>
<AppRail>
diff --git a/app/src/lib/svelte/ReloadPrompt.svelte b/app/src/lib/svelte/ReloadPrompt.svelte
index d54a202..e6effbb 100644
--- a/app/src/lib/svelte/ReloadPrompt.svelte
+++ b/app/src/lib/svelte/ReloadPrompt.svelte
@@ -1,34 +1,32 @@
<script lang="ts">
- import { getToastStore } from "@skeletonlabs/skeleton";
- import { useRegisterSW } from "virtual:pwa-register/svelte";
+ import { getToastStore } from '@skeletonlabs/skeleton'
+ import { useRegisterSW } from 'virtual:pwa-register/svelte'
- const toastStore = getToastStore();
+ const toastStore = getToastStore()
- const {
- updateServiceWorker,
- } = useRegisterSW({
- onRegisteredSW(r) {
- console.log("SW Registered: ", r)
- },
- onNeedRefresh() {
- toastStore.trigger({
- message: 'A new version of the application is available.',
- autohide: false,
- action: {
- label: 'Refresh',
- response: updateServiceWorker
- }
- });
- },
- onOfflineReady() {
- toastStore.trigger({
- background: 'variant-filled-success',
- message: 'Now ready for offline use!',
- timeout: 5000
- });
- },
- onRegisterError(err) {
- console.error("SW Registration Error: ", err)
- }
- })
-</script> \ No newline at end of file
+ const { updateServiceWorker } = useRegisterSW({
+ onRegisteredSW(r) {
+ console.log('SW Registered: ', r)
+ },
+ onNeedRefresh() {
+ toastStore.trigger({
+ message: 'A new version of the application is available.',
+ autohide: false,
+ action: {
+ label: 'Refresh',
+ response: updateServiceWorker,
+ },
+ })
+ },
+ onOfflineReady() {
+ toastStore.trigger({
+ background: 'variant-filled-success',
+ message: 'Now ready for offline use!',
+ timeout: 5000,
+ })
+ },
+ onRegisterError(err) {
+ console.error('SW Registration Error: ', err)
+ },
+ })
+</script>
diff --git a/app/src/lib/ts/download.ts b/app/src/lib/ts/download.ts
index c3e98b0..48debec 100644
--- a/app/src/lib/ts/download.ts
+++ b/app/src/lib/ts/download.ts
@@ -5,33 +5,33 @@ export default async function saveFile(blob: ArrayBuffer, suggestedName: string
'showSaveFilePicker' in window &&
(() => {
try {
- return window.self === window.top;
+ return window.self === window.top
} catch {
- return false;
+ return false
}
- })();
+ })()
if (supportsFSAccess) {
try {
const handle = await window.showSaveFilePicker({
- suggestedName: suggestedName
- });
- const writable = await handle.createWritable();
- await writable.write(blob);
- await writable.close();
- return;
+ suggestedName: suggestedName,
+ })
+ const writable = await handle.createWritable()
+ await writable.write(blob)
+ await writable.close()
+ return
} catch (err: unknown) {
// TypeScript
if ((err as Error)?.name !== 'AbortError') {
- return Promise.reject(err);
+ return Promise.reject(err)
}
}
} else {
- const anchor = document.createElement('a');
- anchor.download = suggestedName ?? 'truncated';
- anchor.href = URL.createObjectURL(new Blob([blob]));
- anchor.click();
- URL.revokeObjectURL(anchor.href);
- document.body.removeChild(anchor);
+ const anchor = document.createElement('a')
+ anchor.download = suggestedName ?? 'truncated'
+ anchor.href = URL.createObjectURL(new Blob([blob]))
+ anchor.click()
+ URL.revokeObjectURL(anchor.href)
+ document.body.removeChild(anchor)
}
}
diff --git a/app/src/lib/ts/truncate.worker.ts b/app/src/lib/ts/truncate.worker.ts
index 9ddf63c..da75041 100644
--- a/app/src/lib/ts/truncate.worker.ts
+++ b/app/src/lib/ts/truncate.worker.ts
@@ -1,9 +1,9 @@
-import type { TruncateRequest, TruncateResponse } from '../types/truncate-worker';
+import type { TruncateRequest, TruncateResponse } from '../types/truncate-worker'
onmessage = async (message: MessageEvent<TruncateRequest>) => {
- console.log('File received. Truncating...');
- const file = message.data.file;
- const buffer = await file.arrayBuffer();
- const truncated = buffer.slice(0, message.data.size);
- postMessage({ file: truncated } as TruncateResponse);
-};
+ console.log('File received. Truncating...')
+ const file = message.data.file
+ const buffer = await file.arrayBuffer()
+ const truncated = buffer.slice(0, message.data.size)
+ postMessage({ file: truncated } as TruncateResponse)
+}
diff --git a/app/src/lib/types/truncate-worker.ts b/app/src/lib/types/truncate-worker.ts
index 7052d17..2691ccb 100644
--- a/app/src/lib/types/truncate-worker.ts
+++ b/app/src/lib/types/truncate-worker.ts
@@ -1,8 +1,8 @@
export type TruncateRequest = {
- file: File;
- size: number;
-};
+ file: File
+ size: number
+}
export type TruncateResponse = {
- file: ArrayBuffer;
-};
+ file: ArrayBuffer
+}