mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-22 15:00:38 -04:00
Update wago support some more
This commit is contained in:
@@ -270,6 +270,7 @@ function createWindow(): BrowserWindow {
|
||||
`--user-data-path=${app.getPath("userData")}`,
|
||||
`--base-bg-color=${getBackgroundColor()}`,
|
||||
],
|
||||
webviewTag: true,
|
||||
},
|
||||
show: false,
|
||||
};
|
||||
@@ -300,6 +301,12 @@ function createWindow(): BrowserWindow {
|
||||
|
||||
win.webContents.userAgent = USER_AGENT;
|
||||
|
||||
win.webContents.on("will-attach-webview", (evt, webPreferences, params) => {
|
||||
log.debug("will-attach-webview", webPreferences, params);
|
||||
// in order for the wago token to be delivered this must be disabled
|
||||
// webPreferences.contextIsolation = false;
|
||||
});
|
||||
|
||||
win.webContents.on("zoom-changed", (evt, zoomDirection) => {
|
||||
sendEventToContents(win, "zoom-changed", zoomDirection);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,8 @@ export type AddonProviderType =
|
||||
| "WowUpHub"
|
||||
| "RaiderIO"
|
||||
| "Zip"
|
||||
| "WowUpCompanion";
|
||||
| "WowUpCompanion"
|
||||
| "Wago";
|
||||
|
||||
export interface GetAllBatchResult {
|
||||
installationResults: { [installationId: string]: AddonSearchResult[] };
|
||||
|
||||
108
wowup-electron/src/app/addon-providers/wago-addon-provider.ts
Normal file
108
wowup-electron/src/app/addon-providers/wago-addon-provider.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { ADDON_PROVIDER_WAGO } from "../../common/constants";
|
||||
import { AppConfig } from "../../environments/environment";
|
||||
import { ElectronService } from "../services";
|
||||
import { WarcraftService } from "../services/warcraft/warcraft.service";
|
||||
import { CachingService } from "../services/caching/caching-service";
|
||||
import { CircuitBreakerWrapper, NetworkService } from "../services/network/network.service";
|
||||
import { AddonProvider } from "./addon-provider";
|
||||
import { WowInstallation } from "../../common/warcraft/wow-installation";
|
||||
import { AddonChannelType } from "../../common/wowup/models";
|
||||
import { AddonFolder } from "../models/wowup/addon-folder";
|
||||
import { WowClientGroup, WowClientType } from "../../common/warcraft/wow-client-type";
|
||||
import { AppWowUpScanResult } from "../models/wowup/app-wowup-scan-result";
|
||||
import { TocService } from "../services/toc/toc.service";
|
||||
|
||||
declare type WagoGameVersion = "retail" | "classic" | "bcc";
|
||||
|
||||
interface WagoFingerprintAddon {
|
||||
hash: string; // hash fingerprint of the folder
|
||||
cf?: string; // curseforge toc id
|
||||
wowi?: string; // wow interface toc id
|
||||
wago?: string; // wago interface toc id
|
||||
}
|
||||
|
||||
interface WagoFingerprintRequest {
|
||||
game_version: WagoGameVersion;
|
||||
addons: { [folder: string]: WagoFingerprintAddon };
|
||||
}
|
||||
|
||||
export class WagoAddonProvider extends AddonProvider {
|
||||
private readonly _circuitBreaker: CircuitBreakerWrapper;
|
||||
|
||||
public readonly name = ADDON_PROVIDER_WAGO;
|
||||
public readonly forceIgnore = false;
|
||||
public enabled = true;
|
||||
|
||||
public constructor(
|
||||
private _electronService: ElectronService,
|
||||
private _cachingService: CachingService,
|
||||
private _networkService: NetworkService,
|
||||
private _warcraftService: WarcraftService,
|
||||
private _tocService: TocService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._circuitBreaker = _networkService.getCircuitBreaker(
|
||||
`${this.name}_main`,
|
||||
AppConfig.defaultHttpResetTimeoutMs,
|
||||
AppConfig.wagoHttpTimeoutMs
|
||||
);
|
||||
}
|
||||
|
||||
public async scan(
|
||||
installation: WowInstallation,
|
||||
addonChannelType: AddonChannelType,
|
||||
addonFolders: AddonFolder[]
|
||||
): Promise<void> {
|
||||
const gameVersion = this.getGameVersion(installation.clientType);
|
||||
|
||||
console.time("WagoScan");
|
||||
const scanResults = await this.getScanResults(addonFolders);
|
||||
console.timeEnd("WagoScan");
|
||||
|
||||
const request: WagoFingerprintRequest = {
|
||||
game_version: gameVersion,
|
||||
addons: {},
|
||||
};
|
||||
|
||||
scanResults.forEach((res) => {
|
||||
const addonFolder = addonFolders.find((af) => af.name === res.folderName);
|
||||
const toc = this._tocService.getTocForGameType2(addonFolder, installation.clientType);
|
||||
|
||||
const waddon: WagoFingerprintAddon = {
|
||||
hash: res.fingerprint,
|
||||
};
|
||||
|
||||
if (toc.wagoAddonId) {
|
||||
waddon.wago = toc.wagoAddonId;
|
||||
}
|
||||
|
||||
request.addons[res.folderName] = waddon;
|
||||
});
|
||||
|
||||
console.debug(`[wago] scan`, request);
|
||||
console.debug(JSON.stringify(request, null, 2));
|
||||
}
|
||||
|
||||
// The wago name for the client type
|
||||
private getGameVersion(clientType: WowClientType): WagoGameVersion {
|
||||
const clientGroup = this._warcraftService.getClientGroup(clientType);
|
||||
switch (clientGroup) {
|
||||
case WowClientGroup.BurningCrusade:
|
||||
return "bcc";
|
||||
case WowClientGroup.Classic:
|
||||
return "classic";
|
||||
case WowClientGroup.Retail:
|
||||
return "retail";
|
||||
default:
|
||||
throw new Error(`[wago] Un-handled client type: ${clientType}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Scan the actual folders, luckily wago uses the same fingerprint method as wowup
|
||||
private getScanResults = async (addonFolders: AddonFolder[]): Promise<AppWowUpScanResult[]> => {
|
||||
const filePaths = addonFolders.map((addonFolder) => addonFolder.path);
|
||||
const scanResults: AppWowUpScanResult[] = await this._electronService.invoke("wowup-get-scan-results", filePaths);
|
||||
return scanResults;
|
||||
};
|
||||
}
|
||||
@@ -308,9 +308,7 @@ export class WowUpAddonProvider extends AddonProvider {
|
||||
|
||||
public getScanResults = async (addonFolders: AddonFolder[]): Promise<AppWowUpScanResult[]> => {
|
||||
const filePaths = addonFolders.map((addonFolder) => addonFolder.path);
|
||||
|
||||
const scanResults: AppWowUpScanResult[] = await this._electronService.invoke(IPC_WOWUP_GET_SCAN_RESULTS, filePaths);
|
||||
|
||||
return scanResults;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export class WebviewComponent implements OnInit {
|
||||
const placeholder = document.createElement("div");
|
||||
placeholder.innerHTML = `
|
||||
<webview id="${this._id}"
|
||||
src="https://addons.wago.io/app_ads.html"
|
||||
src="https://addons.wago.io/wowup_ad"
|
||||
httpreferrer="https://wago.io"
|
||||
style="width: 100%; height: 100%;"
|
||||
nodeintegration="false"
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface Toc {
|
||||
dependencies?: string;
|
||||
curseProjectId?: string;
|
||||
wowInterfaceId?: string;
|
||||
wagoAddonId?: string;
|
||||
tukUiProjectId?: string;
|
||||
tukUiProjectFolders?: string;
|
||||
loadOnDemand?: string;
|
||||
|
||||
@@ -17,6 +17,7 @@ import { FileService } from "../files/file.service";
|
||||
import { TocService } from "../toc/toc.service";
|
||||
import { WarcraftService } from "../warcraft/warcraft.service";
|
||||
import { WowUpApiService } from "../wowup-api/wowup-api.service";
|
||||
import { WagoAddonProvider } from "../../addon-providers/wago-addon-provider";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
@@ -36,6 +37,16 @@ export class AddonProviderFactory {
|
||||
private _wowupApiService: WowUpApiService
|
||||
) {}
|
||||
|
||||
public createWagoAddonProvider(): WagoAddonProvider {
|
||||
return new WagoAddonProvider(
|
||||
this._electronService,
|
||||
this._cachingService,
|
||||
this._networkService,
|
||||
this._warcraftService,
|
||||
this._tocService
|
||||
);
|
||||
}
|
||||
|
||||
public createWowUpCompanionAddonProvider(): WowUpCompanionAddonProvider {
|
||||
return new WowUpCompanionAddonProvider(this._fileService, this._tocService);
|
||||
}
|
||||
@@ -81,6 +92,7 @@ export class AddonProviderFactory {
|
||||
this.createRaiderIoAddonProvider(),
|
||||
this.createWowUpCompanionAddonProvider(),
|
||||
this.createWowUpAddonProvider(),
|
||||
this.createWagoAddonProvider(),
|
||||
this.createCurseAddonProvider(),
|
||||
this.createTukUiAddonProvider(),
|
||||
this.createWowInterfaceAddonProvider(),
|
||||
|
||||
@@ -25,6 +25,7 @@ const TOC_X_TUKUI_PROJECTID = "X-Tukui-ProjectID"; // WowInterface
|
||||
const TOC_X_TUKUI_PROJECTFOLDERS = "X-Tukui-ProjectFolders"; // WowInterface
|
||||
const TOC_X_WEBSITE = "X-Website";
|
||||
const TOC_X_WOWI_ID = "X-WoWI-ID"; // WowInterface
|
||||
const TOC_X_WAGO_ID = "X-Wago-ID"; // WowInterface
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
@@ -54,6 +55,7 @@ export class TocService {
|
||||
category: this.getValue(TOC_X_CATEGORY, tocText),
|
||||
localizations: this.getValue(TOC_X_LOCALIZATIONS, tocText),
|
||||
wowInterfaceId: this.getValue(TOC_X_WOWI_ID, tocText),
|
||||
wagoAddonId: this.getValue(TOC_X_WAGO_ID, tocText),
|
||||
dependencies,
|
||||
dependencyList,
|
||||
tukUiProjectId: this.getValue(TOC_X_TUKUI_PROJECTID, tocText),
|
||||
|
||||
@@ -11,6 +11,7 @@ export const ADDON_PROVIDER_TUKUI = "TukUI";
|
||||
export const ADDON_PROVIDER_UNKNOWN = "Unknown";
|
||||
export const ADDON_PROVIDER_HUB_LEGACY = "Hub";
|
||||
export const ADDON_PROVIDER_HUB = "WowUpHub";
|
||||
export const ADDON_PROVIDER_WAGO = "Wago";
|
||||
export const ADDON_PROVIDER_WOWUP_COMPANION = "WowUpCompanion";
|
||||
export const ADDON_PROVIDER_ZIP = "Zip";
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ export const AppConfig = {
|
||||
defaultHttpTimeoutMs: 10000,
|
||||
defaultHttpResetTimeoutMs: 30000,
|
||||
wowUpHubHttpTimeoutMs: 10000,
|
||||
wagoHttpTimeoutMs: 10000,
|
||||
newsRefreshIntervalMs: 3600000, // 1 hour
|
||||
featuredAddonsCacheTimeSec: 30, // 30 sec
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ export const AppConfig = {
|
||||
defaultHttpTimeoutMs: 10000,
|
||||
defaultHttpResetTimeoutMs: 30000,
|
||||
wowUpHubHttpTimeoutMs: 10000,
|
||||
wagoHttpTimeoutMs: 10000,
|
||||
newsRefreshIntervalMs: 3600000, // 1 hour
|
||||
featuredAddonsCacheTimeSec: 30, // 30 sec
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ export const AppConfig = {
|
||||
defaultHttpTimeoutMs: 10000,
|
||||
defaultHttpResetTimeoutMs: 30000,
|
||||
wowUpHubHttpTimeoutMs: 10000,
|
||||
wagoHttpTimeoutMs: 10000,
|
||||
newsRefreshIntervalMs: 3600000, // 1 hour
|
||||
featuredAddonsCacheTimeSec: 30, // 30 sec
|
||||
};
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
"es2016",
|
||||
"es2015",
|
||||
"dom",
|
||||
"ES2020.String",
|
||||
"ES2019.Array",
|
||||
"ES2020.String",
|
||||
"ES2021.String",
|
||||
"ESNext.String"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user