zenno/doc/spark: make spark select searchable

This commit is contained in:
2026-07-09 15:40:07 -04:00
parent bc395a0788
commit fca43e64b5
2 changed files with 46 additions and 29 deletions
+22
View File
@@ -144,3 +144,25 @@ export async function sparks(): Promise<Spark[]> {
const resp = await fetch('/api/global/spark');
return resp.json();
}
export interface SparkGroup {
spark_group: number;
name: string;
description: string;
type: Type;
effects: Effect[][];
spark_ids: number[];
}
export function byGroup(sparks: Spark[]): SparkGroup[] {
const r = new Map<number, SparkGroup>();
for (const {spark_id, name, description, spark_group, type, effects} of sparks) {
let g = r.get(spark_group);
if (g == null) {
g = {spark_group, name, description, type, effects, spark_ids: []};
r.set(spark_group, g);
}
g.spark_ids.push(spark_id);
}
return [...r.values()];
}