···
170
170
.controller menu {
171
171
align-items: center;
172
172
display: flex;
173
173
-
font-size: var(--fs-md);
173
173
+
font-size: var(--fs-lg);
174
174
gap: var(--space-lg);
175
175
justify-content: center;
176
176
-
margin: var(--space-sm) 0;
176
176
+
margin: var(--space-md) 0;
177
177
padding: 0;
178
178
text-align: center;
179
179
}
···
185
185
186
186
.controller .ph-pause,
187
187
.controller .ph-play {
188
188
-
font-size: var(--fs-lg);
188
188
+
font-size: var(--fs-xl);
189
189
}
190
190
191
191
/* Volume */
···
1
1
import type { Track } from "@applets/core/types";
2
2
3
3
+
export type Item<Stats = TrackStats, Tags = TrackTags> = Track & {
4
4
+
manualEntry?: boolean;
5
5
+
};
6
6
+
3
7
export interface State<Stats = TrackStats, Tags = TrackTags> {
4
4
-
past: Track<Stats, Tags>[];
5
5
-
now: Track<Stats, Tags> | null;
6
6
-
future: Track<Stats, Tags>[];
8
8
+
past: Item<Stats, Tags>[];
9
9
+
now: Item<Stats, Tags> | null;
10
10
+
future: Item<Stats, Tags>[];
7
11
}
···
1
1
import type { Track } from "@applets/core/types.js";
2
2
-
import type { State } from "./types";
3
3
-
import { expose, transfer } from "@scripts/common.ts";
2
2
+
import type { Item, State } from "./types";
3
3
+
import { arrayShuffle, expose, transfer } from "@scripts/common.ts";
4
4
5
5
////////////////////////////////////////////
6
6
// STATE
···
26
26
27
27
// Actions
28
28
29
29
-
function add(state: State, items: Track[]): State {
29
29
+
function add(state: State, items: Item[]): State {
30
30
return transfer({ ...state, future: [...state.future, ...items] });
31
31
}
32
32
···
67
67
68
68
// 🛠️
69
69
70
70
-
// TODO: Shuffle, limit track amount, etc.
70
70
+
// TODO: Most likely there's a more performant solution
71
71
function fill(state: State): State {
72
72
-
return state.future.length < QUEUE_SIZE
73
73
-
? add(
74
74
-
state,
75
75
-
internal.pool.slice(
76
76
-
state.past.length,
77
77
-
state.past.length + (QUEUE_SIZE - state.future.length),
78
78
-
),
79
79
-
)
80
80
-
: state;
72
72
+
if (state.future.length >= QUEUE_SIZE) return state;
73
73
+
74
74
+
let reducedPool = internal.pool.reduce(
75
75
+
({ past, pool }: { past: Set<string>; pool: Track[] }, track: Track) => {
76
76
+
if (past.has(track.id))
77
77
+
return {
78
78
+
past: past.difference(new Set(track.id)),
79
79
+
pool,
80
80
+
};
81
81
+
82
82
+
return {
83
83
+
past,
84
84
+
pool: [...pool, track],
85
85
+
};
86
86
+
},
87
87
+
{ past: new Set(state.past.map((t) => t.id)), pool: [] },
88
88
+
).pool;
89
89
+
90
90
+
if (reducedPool.length === 0) {
91
91
+
reducedPool = internal.pool;
92
92
+
}
93
93
+
94
94
+
const poolSelection = arrayShuffle(reducedPool).slice(0, QUEUE_SIZE - state.future.length);
95
95
+
return add(state, poolSelection);
81
96
}