A persisted store will be used to store
- Themes/components install metadata and options (id, source URL, date installed, etc.).
- Currently applied manifest from the last runtime
The store state would look similar to this:
{
installedThemes: [
{
id: "pylixonly.winter",
sourceUrl: "https://example.com/pylixonly.winter.json",
etag: "1234567890abcdef",
installedAt: "2023-10-01T12:00:00Z",
updatedAt: "2023-10-01T12:00:00Z",
}
],
installedComponents: [
{
id: "pylixonly.winter.palette",
type: "palette",
from: "pylixonly.winter", // <- Optional, if not specified, this component is considered standalone, not part of a theme
etag: "1234567890abcdef",
sourceUrl: "https://example.com/pylixonly.winter.palette.json",
installedAt: "2023-10-01T12:00:00Z",
updatedAt: "2023-10-01T12:00:00Z",
},
{
id: "pylixonly.winter.background",
type: "background",
from: "pylixonly.winter",
etag: "1234567890abcdef",
sourceUrl: "https://example.com/pylixonly.winter.background.json",
installedAt: "2023-10-01T12:00:00Z",
updatedAt: "2023-10-01T12:00:00Z",
},
{
id: "name.solar.json",
type: "icons",
sourceUrl: "https://example.com/name.solar.json",
etag: "1234567890abcdef",
installedAt: "2023-10-01T12:00:00Z",
updatedAt: "2023-10-01T12:00:00Z",
},
{
id: "name.ggsans",
type: "fonts",
sourceUrl: "https://example.com/name.ggsans.json",
etag: "1234567890abcdef",
installedAt: "2023-10-01T12:00:00Z",
updatedAt: "2023-10-01T12:00:00Z",
}
],
// Snapshot of the currently applied theme and components from the last runtime.
// This is stored here because we're storing the installed themes and components in FS and FS is async.
// Since we need to apply the theme and components synchronously, we need to store the last applied theme and components here.
activeComponents: {
palette: {
// ... The rest of the palette component manifest
},
background: {
// ... The rest of the background component manifest
},
icons: {
// ... The rest of the icons component manifest
},
fonts: {
// ... The rest of the font component manifest
}
}
}
The manifests for each themes and components are saved in the file system in a directory, it should be stored as it was fetched from the server:
.
└── themes/
└── manifests/
├── pylixonly.winter.json (Theme)
├── pylixonly.winter.palette.json (Palette)
├── pylixonly.winter.background.json (Background)
├── name.solar.json (Icons)
└── name.ggsans (Fonts)
Once the app starts, theme components will be applied synchronously from the restored store state. A fetch to the source URL will be made to check for an update. If there is any, components that can be applied during runtime (such as background) will be updated and user will be prompted to update for the fully updated version of the theme.