From 6a72e326b8cdc67be5cd3802e1bc498faef8a313 Mon Sep 17 00:00:00 2001 From: beefchimi Date: Thu, 21 Dec 2023 11:57:37 -0500 Subject: [PATCH] :alembic: [Dummy] Experiment with offering a dummy Earwurm --- src/dummy/DummyEarwurm.ts | 69 +++++++++++++++++++++++++++++++++++++++ src/dummy/index.ts | 1 + src/index.ts | 2 ++ 3 files changed, 72 insertions(+) create mode 100644 src/dummy/DummyEarwurm.ts create mode 100644 src/dummy/index.ts diff --git a/src/dummy/DummyEarwurm.ts b/src/dummy/DummyEarwurm.ts new file mode 100644 index 0000000..8a954dc --- /dev/null +++ b/src/dummy/DummyEarwurm.ts @@ -0,0 +1,69 @@ +import {tokens} from '../tokens'; +import type {LibraryEntry, LibraryKeys} from '../types'; + +// TODO: Ideally we can do something like `implements Earwurm`, +// but changing all internal logic to be "dumb". +export class DummyEarwurm { + static readonly maxStackSize = tokens.maxStackSize; + static readonly suspendAfterMs = tokens.suspendAfterMs; + + private _volume = 1; + private _mute = false; + + readonly unlocked = false; + readonly state = 'closed'; + readonly playing = false; + + constructor() { + this._volume = 1; + this._mute = false; + } + + get volume() { + return this._volume; + } + + set volume(value: number) { + this._volume = value; + } + + get mute() { + return this._mute; + } + + set mute(value: boolean) { + this._mute = value; + } + + get keys() { + return []; + } + + get(_id: LibraryEntry['id']) { + return undefined; + } + + has(_id: LibraryEntry['id']) { + return false; + } + + unlock() { + return this; + } + + add(..._entries: LibraryEntry[]): LibraryKeys { + return []; + } + + remove(..._ids: LibraryKeys): LibraryKeys { + return []; + } + + stop() { + return this; + } + + teardown() { + return this; + } +} diff --git a/src/dummy/index.ts b/src/dummy/index.ts new file mode 100644 index 0000000..110e363 --- /dev/null +++ b/src/dummy/index.ts @@ -0,0 +1 @@ +export {DummyEarwurm} from './DummyEarwurm'; diff --git a/src/index.ts b/src/index.ts index 6411f27..4ff04f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,8 @@ export {Earwurm} from './Earwurm'; export {Stack} from './Stack'; export {Sound} from './Sound'; +// export * from './dummy'; + export type { ManagerState, ManagerEventMap,