1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * A Map of themes built in to the browser, alongwith a Map of collections those themes belong to. Params for the objects contained
10 * The unique identifier for the theme. The map's key.
11 * @param {string} version
12 * The theme add-on's semantic version, as defined in its manifest.
13 * @param {string} path
14 * Path to the add-on files.
15 * @param {string} [expiry]
16 * Date in YYYY-MM-DD format. Optional. If defined, the themes in the collection can no longer be
17 * used after this date, unless the user has permission to retain it.
18 * @param {string} [collection]
19 * The collection id that the theme is a part of. Optional.
21 export const BuiltInThemeConfig = new Map([
23 "firefox-compact-light@mozilla.org",
26 path: "resource://builtin-themes/light/",
30 "firefox-compact-dark@mozilla.org",
33 path: "resource://builtin-themes/dark/",
37 "firefox-alpenglow@mozilla.org",
40 path: "resource://builtin-themes/alpenglow/",
44 "2022red-colorway@mozilla.org",
47 path: "resource://builtin-themes/colorways/2022red/",
48 collection: "true-colors",
52 "2022orange-colorway@mozilla.org",
55 path: "resource://builtin-themes/colorways/2022orange/",
56 collection: "true-colors",
60 "2022green-colorway@mozilla.org",
63 path: "resource://builtin-themes/colorways/2022green/",
64 collection: "true-colors",
68 "2022yellow-colorway@mozilla.org",
71 path: "resource://builtin-themes/colorways/2022yellow/",
72 collection: "true-colors",
76 "2022purple-colorway@mozilla.org",
79 path: "resource://builtin-themes/colorways/2022purple/",
80 collection: "true-colors",
84 "2022blue-colorway@mozilla.org",
87 path: "resource://builtin-themes/colorways/2022blue/",
88 collection: "true-colors",
92 "lush-soft-colorway@mozilla.org",
95 path: "resource://builtin-themes/colorways/2021lush/soft/",
96 collection: "life-in-color",
100 "lush-balanced-colorway@mozilla.org",
103 path: "resource://builtin-themes/colorways/2021lush/balanced/",
104 collection: "life-in-color",
108 "lush-bold-colorway@mozilla.org",
111 path: "resource://builtin-themes/colorways/2021lush/bold/",
112 collection: "life-in-color",
116 "abstract-soft-colorway@mozilla.org",
119 path: "resource://builtin-themes/colorways/2021abstract/soft/",
120 collection: "life-in-color",
124 "abstract-balanced-colorway@mozilla.org",
127 path: "resource://builtin-themes/colorways/2021abstract/balanced/",
128 collection: "life-in-color",
132 "abstract-bold-colorway@mozilla.org",
135 path: "resource://builtin-themes/colorways/2021abstract/bold/",
136 collection: "life-in-color",
140 "elemental-soft-colorway@mozilla.org",
143 path: "resource://builtin-themes/colorways/2021elemental/soft/",
144 collection: "life-in-color",
148 "elemental-balanced-colorway@mozilla.org",
151 path: "resource://builtin-themes/colorways/2021elemental/balanced/",
152 collection: "life-in-color",
156 "elemental-bold-colorway@mozilla.org",
159 path: "resource://builtin-themes/colorways/2021elemental/bold/",
160 collection: "life-in-color",
164 "cheers-soft-colorway@mozilla.org",
167 path: "resource://builtin-themes/colorways/2021cheers/soft/",
168 collection: "life-in-color",
172 "cheers-balanced-colorway@mozilla.org",
175 path: "resource://builtin-themes/colorways/2021cheers/balanced/",
176 collection: "life-in-color",
180 "cheers-bold-colorway@mozilla.org",
183 path: "resource://builtin-themes/colorways/2021cheers/bold/",
184 collection: "life-in-color",
188 "graffiti-soft-colorway@mozilla.org",
191 path: "resource://builtin-themes/colorways/2021graffiti/soft/",
192 collection: "life-in-color",
196 "graffiti-balanced-colorway@mozilla.org",
199 path: "resource://builtin-themes/colorways/2021graffiti/balanced/",
200 collection: "life-in-color",
204 "graffiti-bold-colorway@mozilla.org",
207 path: "resource://builtin-themes/colorways/2021graffiti/bold/",
208 collection: "life-in-color",
212 "foto-soft-colorway@mozilla.org",
215 path: "resource://builtin-themes/colorways/2021foto/soft/",
216 collection: "life-in-color",
220 "foto-balanced-colorway@mozilla.org",
223 path: "resource://builtin-themes/colorways/2021foto/balanced/",
224 collection: "life-in-color",
228 "foto-bold-colorway@mozilla.org",
231 path: "resource://builtin-themes/colorways/2021foto/bold/",
232 collection: "life-in-color",
236 "playmaker-soft-colorway@mozilla.org",
239 path: "resource://builtin-themes/colorways/2022playmaker/soft/",
240 collection: "independent-voices",
242 description: "playmaker-colorway-description",
243 groupName: "playmaker-colorway-name",
248 "playmaker-balanced-colorway@mozilla.org",
251 path: "resource://builtin-themes/colorways/2022playmaker/balanced/",
252 collection: "independent-voices",
254 description: "playmaker-colorway-description",
255 groupName: "playmaker-colorway-name",
260 "playmaker-bold-colorway@mozilla.org",
263 path: "resource://builtin-themes/colorways/2022playmaker/bold/",
264 collection: "independent-voices",
266 description: "playmaker-colorway-description",
267 groupName: "playmaker-colorway-name",
272 "expressionist-soft-colorway@mozilla.org",
275 path: "resource://builtin-themes/colorways/2022expressionist/soft/",
276 collection: "independent-voices",
278 description: "expressionist-colorway-description",
279 groupName: "expressionist-colorway-name",
284 "expressionist-balanced-colorway@mozilla.org",
287 path: "resource://builtin-themes/colorways/2022expressionist/balanced/",
288 collection: "independent-voices",
290 description: "expressionist-colorway-description",
291 groupName: "expressionist-colorway-name",
296 "expressionist-bold-colorway@mozilla.org",
299 path: "resource://builtin-themes/colorways/2022expressionist/bold/",
300 collection: "independent-voices",
302 description: "expressionist-colorway-description",
303 groupName: "expressionist-colorway-name",
308 "visionary-soft-colorway@mozilla.org",
311 path: "resource://builtin-themes/colorways/2022visionary/soft/",
312 collection: "independent-voices",
314 description: "visionary-colorway-description",
315 groupName: "visionary-colorway-name",
320 "visionary-balanced-colorway@mozilla.org",
323 path: "resource://builtin-themes/colorways/2022visionary/balanced/",
324 collection: "independent-voices",
326 description: "visionary-colorway-description",
327 groupName: "visionary-colorway-name",
332 "visionary-bold-colorway@mozilla.org",
335 path: "resource://builtin-themes/colorways/2022visionary/bold/",
336 collection: "independent-voices",
338 description: "visionary-colorway-description",
339 groupName: "visionary-colorway-name",
344 "activist-soft-colorway@mozilla.org",
347 path: "resource://builtin-themes/colorways/2022activist/soft/",
348 collection: "independent-voices",
350 description: "activist-colorway-description",
351 groupName: "activist-colorway-name",
356 "activist-balanced-colorway@mozilla.org",
359 path: "resource://builtin-themes/colorways/2022activist/balanced/",
360 collection: "independent-voices",
362 description: "activist-colorway-description",
363 groupName: "activist-colorway-name",
368 "activist-bold-colorway@mozilla.org",
371 path: "resource://builtin-themes/colorways/2022activist/bold/",
372 collection: "independent-voices",
374 description: "activist-colorway-description",
375 groupName: "activist-colorway-name",
380 "dreamer-soft-colorway@mozilla.org",
383 path: "resource://builtin-themes/colorways/2022dreamer/soft/",
384 collection: "independent-voices",
386 description: "dreamer-colorway-description",
387 groupName: "dreamer-colorway-name",
392 "dreamer-balanced-colorway@mozilla.org",
395 path: "resource://builtin-themes/colorways/2022dreamer/balanced/",
396 collection: "independent-voices",
398 description: "dreamer-colorway-description",
399 groupName: "dreamer-colorway-name",
404 "dreamer-bold-colorway@mozilla.org",
407 path: "resource://builtin-themes/colorways/2022dreamer/bold/",
408 collection: "independent-voices",
410 description: "dreamer-colorway-description",
411 groupName: "dreamer-colorway-name",
416 "innovator-soft-colorway@mozilla.org",
419 path: "resource://builtin-themes/colorways/2022innovator/soft/",
420 collection: "independent-voices",
422 description: "innovator-colorway-description",
423 groupName: "innovator-colorway-name",
428 "innovator-balanced-colorway@mozilla.org",
431 path: "resource://builtin-themes/colorways/2022innovator/balanced/",
432 collection: "independent-voices",
434 description: "innovator-colorway-description",
435 groupName: "innovator-colorway-name",
440 "innovator-bold-colorway@mozilla.org",
443 path: "resource://builtin-themes/colorways/2022innovator/bold/",
444 collection: "independent-voices",
446 description: "innovator-colorway-description",
447 groupName: "innovator-colorway-name",
453 const ColorwayCollections = [
456 expiry: "2022-02-08",
460 expiry: "2022-05-03",
463 id: "independent-voices",
464 expiry: "2023-01-17",
468 export function _applyColorwayConfig(collections) {
469 const collectionsSorted = collections
470 .map(({ expiry, ...rest }) => ({
471 expiry: new Date(expiry),
474 .sort((a, b) => a.expiry - b.expiry);
475 const collectionsMap = collectionsSorted.reduce((map, c) => {
479 for (let [key, value] of BuiltInThemeConfig.entries()) {
480 if (value.collection) {
481 const collectionConfig = collectionsMap.get(value.collection);
482 BuiltInThemeConfig.set(key, {
484 expiry: collectionConfig.expiry,
488 BuiltInThemeConfig.findActiveColorwayCollection = (now = new Date()) => {
489 let collection = null;
491 let end = collectionsSorted.length - 1;
492 while (start <= end) {
493 const mid = Math.floor((start + end) / 2);
494 const c = collectionsSorted[mid];
495 const diff = c.expiry - now;
497 // collection expired, look for newer one
500 // collection not expired, check for older one
509 _applyColorwayConfig(ColorwayCollections);