forked from mystiq/hydrogen-web
Add more logging
This commit is contained in:
parent
51a837d459
commit
d08cfe3a29
2 changed files with 78 additions and 70 deletions
|
@ -188,8 +188,9 @@ export class Platform {
|
|||
this._config.push
|
||||
);
|
||||
const manifests = this.config["themeManifests"];
|
||||
await this._themeLoader?.init(manifests);
|
||||
await this._themeLoader?.init(manifests, log);
|
||||
const { themeName, themeVariant } = await this._themeLoader.getActiveTheme();
|
||||
log.log({ l: "Active theme", name: themeName, variant: themeVariant });
|
||||
this._themeLoader?.setTheme(themeName, themeVariant, log);
|
||||
});
|
||||
} catch (err) {
|
||||
|
|
|
@ -55,7 +55,8 @@ export class ThemeLoader {
|
|||
this._platform = platform;
|
||||
}
|
||||
|
||||
async init(manifestLocations: string[]): Promise<void> {
|
||||
async init(manifestLocations: string[], log?: ILogItem): Promise<void> {
|
||||
await this._platform.logger.wrapOrRun(log, "ThemeLoader.init", async (log) => {
|
||||
this._themeMapping = {};
|
||||
for (const manifestLocation of manifestLocations) {
|
||||
const { body } = await this._platform
|
||||
|
@ -65,11 +66,13 @@ export class ThemeLoader {
|
|||
cache: true,
|
||||
})
|
||||
.response();
|
||||
this._populateThemeMap(body);
|
||||
this._populateThemeMap(body, log);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private _populateThemeMap(manifest) {
|
||||
private _populateThemeMap(manifest, log: ILogItem) {
|
||||
log.wrap("populateThemeMap", (l) => {
|
||||
/*
|
||||
After build has finished, the source section of each theme manifest
|
||||
contains `built-assets` which is a mapping from the theme-id to
|
||||
|
@ -129,6 +132,10 @@ export class ThemeLoader {
|
|||
this._themeMapping["Default"] = { id: "default", cssLocation: themeDetails.cssLocation };
|
||||
}
|
||||
}
|
||||
l.log({ l: "Default Theme", theme: defaultThemeId});
|
||||
l.log({ l: "Preferred colorscheme", scheme: this.preferredColorScheme === ColorSchemePreference.Dark ? "dark" : "light" });
|
||||
l.log({ l: "Result", themeMapping: this._themeMapping });
|
||||
});
|
||||
}
|
||||
|
||||
setTheme(themeName: string, themeVariant?: "light" | "dark" | "default", log?: ILogItem) {
|
||||
|
|
Loading…
Reference in a new issue