aboutsummaryrefslogtreecommitdiff
path: root/loading/progress.ts
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-04-22 08:03:06 +0530
committerBobby <[email protected]>2026-04-22 08:03:06 +0530
commite72162b34bddbf04998eea934335e9496b8649f8 (patch)
tree121f6442c797fe7a3581f98c631810431a0bcae5 /loading/progress.ts
parent4938bd9e1454769f5cc338ba9fab437eaa7e8f58 (diff)
downloadhollowdark-e72162b34bddbf04998eea934335e9496b8649f8.tar.xz
hollowdark-e72162b34bddbf04998eea934335e9496b8649f8.zip
Implement initial load + Begin screens with stub 3s loading pipeline
Diffstat (limited to 'loading/progress.ts')
-rw-r--r--loading/progress.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/loading/progress.ts b/loading/progress.ts
new file mode 100644
index 0000000..f631757
--- /dev/null
+++ b/loading/progress.ts
@@ -0,0 +1,30 @@
+import { writable, type Writable } from 'svelte/store'
+
+/**
+ * Phase the loading pipeline is in.
+ * `idle` nothing running yet; percentage is 0.
+ * `loading` a load is in flight; percentage advances 0 → 1.
+ * `complete` load finished; percentage is 1.
+ */
+export type LoadingPhase = 'idle' | 'loading' | 'complete'
+
+/** Reactive snapshot of the loading pipeline. */
+export interface LoadingProgress {
+ readonly percentage: number
+ readonly currentMessage: string
+ readonly phase: LoadingPhase
+}
+
+const DEFAULT: LoadingProgress = {
+ percentage: 0,
+ currentMessage: 'Preparing your reading space',
+ phase: 'idle'
+}
+
+/** Global store of the initial-load progress. Components subscribe via `$`. */
+export const loadingProgress: Writable<LoadingProgress> = writable(DEFAULT)
+
+/** Reset the store to its initial state. Useful between sessions in dev. */
+export function resetLoadingProgress(): void {
+ loadingProgress.set(DEFAULT)
+}