* Gets the theme as an object * @param {'rgba'|'hex' | 'none'} colorType * @returns {Object }
(colorType = "none")
| 263 | * @returns {Object<string, string>} |
| 264 | */ |
| 265 | toJSON(colorType = "none") { |
| 266 | const res = { |
| 267 | name: this.name, |
| 268 | type: this.type, |
| 269 | version: this.version, |
| 270 | }; |
| 271 | Object.keys(this.#theme).forEach((key) => { |
| 272 | const color = |
| 273 | colorType === "hex" |
| 274 | ? Color(this.#theme[key]).hex.toString() |
| 275 | : colorType === "rgba" |
| 276 | ? Color(this.#theme[key]).rgba.toString() |
| 277 | : this.#theme[key]; |
| 278 | res[ThemeBuilder.#toPascal(key)] = color; |
| 279 | }); |
| 280 | return res; |
| 281 | } |
| 282 | |
| 283 | toString() { |
| 284 | return JSON.stringify(this.toJSON()); |