refactoring of cmaps, widgets, etc.

This commit is contained in:
2026-09-02 16:06:26 +02:00
parent 38f255c1a4
commit f0562a06cc
52 changed files with 3626 additions and 2642 deletions
@@ -0,0 +1,30 @@
import { CmapAppearance } from "./appearance.js";
/**
* Persist wiki-wide CMap appearance through the backend.
* Styles and the colour palette form one appearance aggregate.
*/
export class CmapAppearanceRepository {
constructor(api) {
if (typeof api !== "function") throw new TypeError("A wiki API function is required");
this.api = api;
}
/** Load and deserialize the complete wiki-wide appearance aggregate. */
async load() {
const result = await this.api("/api/cmap-appearance");
return new CmapAppearance(result);
}
/** Persist one appearance aggregate and refresh it with backend normalization. */
async save(appearance) {
if (!(appearance instanceof CmapAppearance)) {
throw new TypeError("A CmapAppearance is required");
}
const result = await this.api("/api/cmap-appearance", {
method: "PUT",
body: JSON.stringify(appearance.toData())
});
return appearance.replace(result);
}
}