Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/components/composables/GameSelectionComposable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ export function useGameSelectionComposable() {
return;
}

const platform = selectedPlatform.value as Platform;

try {
ProviderUtils.setupGameProviders(selectedGame.value, selectedPlatform.value);
ProviderUtils.setupGameProviders(selectedGame.value as Game, platform);
} catch (error) {
if (error instanceof R2Error) {
store.commit('error/handleError', error);
Expand All @@ -130,10 +132,10 @@ export function useGameSelectionComposable() {
throw error;
}

const s = await ManagerSettings.getSingleton(selectedGame.value);
await s.setLastSelectedGame(selectedGame.value);
await s.setLastSelectedPlatform(selectedPlatform.value);
await GameManager.activate(selectedGame.value, selectedPlatform.value);
const s = await ManagerSettings.getSingleton(selectedGame.value as Game);
await s.setLastSelectedGame(selectedGame.value as Game);
await s.setLastSelectedPlatform(platform);
await GameManager.activate(selectedGame.value as Game, platform);
await store.dispatch('setActiveGame', selectedGame.value);

await router.push({ name: 'splash' });
Expand All @@ -142,7 +144,7 @@ export function useGameSelectionComposable() {
async function selectPlatformForGame(game: Game) {
const s = await ManagerSettings.getSingleton(game);
const platform = await s.getLastSelectedPlatform();
selectedPlatform.value = platform ? Platform[platform] : null;
selectedPlatform.value = platform ? Platform[platform as unknown as keyof typeof Platform] : null;
}

async function initialize() {
Expand All @@ -168,7 +170,8 @@ export function useGameSelectionComposable() {
viewMode.value = GameSelectionViewMode.CARD;
}

const { defaultGame, defaultPlatform } = ManagerUtils.getDefaults(settings.value);
const settingsInstance = settings.value as ManagerSettings;
const { defaultGame, defaultPlatform } = ManagerUtils.getDefaults(settingsInstance);
if (defaultGame && defaultPlatform) {
markAsSelectedGame(defaultGame);
selectedPlatform.value = defaultPlatform;
Expand All @@ -181,8 +184,9 @@ export function useGameSelectionComposable() {
return;
}

const s = await ManagerSettings.getSingleton(selectedGame.value);
await s.setDefaultGame(selectedGame.value);
const game = selectedGame.value as Game;
const s = await ManagerSettings.getSingleton(game);
await s.setDefaultGame(game);
await s.setDefaultStorePlatform(selectedPlatform.value);

return proceed();
Expand Down
2 changes: 1 addition & 1 deletion src/depots/loader/DepotLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class DepotLoader {
);
}
const protonRequired = depots[depotIdentifier] || depots[this.DEPOT_DEFAULT_KEY];
return protonRequired.use_proton;
return protonRequired!.use_proton;
}

}
14 changes: 12 additions & 2 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ declare namespace NodeJS {

declare global {
interface Window {
zip: ZipProvider,
zip: {
extractAllTo: (zip: string | Buffer, outputFolder: string) => Promise<void>;
readFile: (zip: string | Buffer, file: string) => Promise<Buffer | null>;
getEntries: (zip: string | Buffer) => Promise<ZipEntryInterface[]>;
extractEntryTo: (zip: string | Buffer, target: string, outputPath: string) => Promise<void>;
zipBuilder: () => ZipBuilder;
createNewTemporaryZip: () => number;
addBufferToTemporaryZip: (id: number, fileName: string, buffer: Buffer) => Promise<void>;
addFolderToTemporaryZip: (id: number, zippedFolderName: string, folderName: string) => Promise<void>;
finalizeTemporaryZip: (id: number, outputPath: string) => Promise<void>;
},
node: {
fs: NodeFsProvider,
path: NodePathProvider,
Expand All @@ -44,7 +54,7 @@ declare global {
openPath: (path: string) => void;
openExternal: (path: string) => void;
selectFile: (path: string) => void;
getEnvironmentVariables: () => Record<string, string>;
getEnvironmentVariables: () => Promise<string>;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/installers/LovelyInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export class LovelyInstaller implements PackageInstaller {

const targets = lovelyTree.getRecursiveFiles().map((x) => x.replace(packagePath, "")).map((x) => [x, path.join("mods", x)]);
for (const target of targets) {
const absSrc = path.join(packagePath, target[0]);
const absDest = profile.joinToProfilePath(target[1]);
const absSrc = path.join(packagePath, target[0]!);
const absDest = profile.joinToProfilePath(target[1]!);

await FileUtils.ensureDirectory(path.dirname(absDest));
await fs.copyFile(absSrc, absDest);

fileRelocations.set(absSrc, target[1]);
fileRelocations.set(absSrc, target[1]!);
}

await addToStateFile(mod, fileRelocations, profile);
Expand Down
2 changes: 1 addition & 1 deletion src/installers/PackageInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function uninstallModLoader(mod: ManifestV2, profile: ImmutableProf
const fs = FsProvider.instance;

try {
const loader = MOD_LOADER_VARIANTS[GameManager.activeGame.internalFolderName].find(
const loader = MOD_LOADER_VARIANTS[GameManager.activeGame.internalFolderName]!.find(
loader => loader.packageName.toLowerCase() === mod.getName().toLowerCase()
);

Expand Down
6 changes: 3 additions & 3 deletions src/installers/ShimloaderInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export class ShimloaderInstaller implements PackageInstaller {
}

for (const targetPath of targets) {
const absSrc = path.join(packagePath, targetPath[0]);
const absDest = profile.joinToProfilePath(targetPath[1]);
const absSrc = path.join(packagePath, targetPath[0]!);
const absDest = profile.joinToProfilePath(targetPath[1]!);

await FileUtils.ensureDirectory(path.dirname(absDest));
await fs.copyFile(absSrc, absDest);

fileRelocations.set(absSrc, targetPath[1]);
fileRelocations.set(absSrc, targetPath[1]!);
}

// The config subdir needs to be created for shimloader (it will get cranky if it's not there).
Expand Down
2 changes: 1 addition & 1 deletion src/model/ThunderstoreCombo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class ThunderstoreCombo {
);
}

return foundMod[0];
return foundMod[0]!;
}

public getMod(): ThunderstoreMod {
Expand Down
11 changes: 1 addition & 10 deletions src/model/ThunderstoreMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default class ThunderstoreMod extends ThunderstoreVersion {
private rating: number = 0;
private owner: string = '';
private packageUrl: string = '';
private dateCreated: string = '';
private dateUpdated: string = '';
private uuid4: string = '';
private pinned: boolean = false;
Expand All @@ -30,7 +29,7 @@ export default class ThunderstoreMod extends ThunderstoreVersion {
return a.getDateUpdated() >= b.getDateUpdated() ? -1 : 1;
}

public static parseFromThunderstoreData(data: any): ThunderstoreMod {
public static override parseFromThunderstoreData(data: any): ThunderstoreMod {
const mod = new ThunderstoreMod();
mod.setName(data.name);
mod.setFullName(data.full_name);
Expand Down Expand Up @@ -115,14 +114,6 @@ export default class ThunderstoreMod extends ThunderstoreVersion {
this.packageUrl = url;
}

public getDateCreated(): string {
return this.dateCreated;
}

public setDateCreated(date: string) {
this.dateCreated = date;
}

public getDateUpdated(): string {
return this.dateUpdated;
}
Expand Down
6 changes: 3 additions & 3 deletions src/model/VersionNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export default class VersionNumber {
}
});
// If successful, assign values.
this.major = numberArray[0];
this.minor = numberArray[1];
this.patch = numberArray[2];
this.major = numberArray[0]!;
this.minor = numberArray[1]!;
this.patch = numberArray[2]!;
} catch (e) {
// If an error was thrown, log reason.
return new VersionNumber('0.0.0');
Expand Down
2 changes: 1 addition & 1 deletion src/model/errors/FileWriteError.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import R2Error from './R2Error';

export default class FileWriteError extends R2Error {
public static fromThrownValue(
public static override fromThrownValue(
error: R2Error | Error | unknown,
name: string = "An unhandled error occurred",
solution: string | null = null,
Expand Down
11 changes: 7 additions & 4 deletions src/model/errors/R2Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ interface Action {
}

export default class R2Error extends Error {
public name: string;
public message: string;
public stack?: string | undefined;
public override name: string;
public override message: string;
public override stack?: string;
public solution: string;
public errorReferenceString: string | undefined;
public action?: Action;
Expand All @@ -16,7 +16,10 @@ export default class R2Error extends Error {
this.name = name;
this.message = message;
this.solution = solution || '';
this.stack = new Error().stack;
const stackError = new Error().stack;
if (stackError) {
this.stack = stackError;
}
Object.setPrototypeOf(this, R2Error.prototype);
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/exports/ExportMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class ExportMod {
const name = modStr.match(new RegExp("(.+)-\\d+\\.\\d+\\.\\d+$"));
let resolvedName: string;
if (name !== null) {
resolvedName = name[1];
resolvedName = name[1]!;
} else {
resolvedName = "";
}
Expand Down
4 changes: 2 additions & 2 deletions src/model/file/FileTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class FileTree {

public navigate(...args: string[]): FileTree | undefined {
if (args[0] !== undefined) {
const foundDir = this.directories.find(value => value.directoryName.toLowerCase() === args[0].toLowerCase());
const foundDir = this.directories.find(value => value.directoryName.toLowerCase() === args[0]!.toLowerCase());
if (foundDir !== undefined) {
return foundDir.subNavigate(...args.splice(1));
}
Expand All @@ -91,7 +91,7 @@ export default class FileTree {

private subNavigate(...args: string[]): FileTree | undefined {
if (args[0] !== undefined) {
const foundDir = this.directories.find(value => value.directoryName.toLowerCase() === args[0].toLowerCase());
const foundDir = this.directories.find(value => value.directoryName.toLowerCase() === args[0]!.toLowerCase());
if (foundDir !== undefined) {
return foundDir.subNavigate(...args.splice(1));
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/game/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class Game {
this._thunderstoreUrl = tsUrl;
this._thunderstoreIdentifier = tsIdentifier;
this._storePlatformMetadata = platforms;
this._activePlatform = platforms[0];
this._activePlatform = platforms[0]!;
this._iconUrl = iconUrl;
this._displayMode = displayMode;
this._instanceType = instanceType;
Expand Down
2 changes: 2 additions & 0 deletions src/providers/generic/zip/AdmZipProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default class AdmZipProvider extends ZipProvider {
zipBuilder(): ZipBuilder {
return new AdmZipBuilder();
}


}

export class AdmZipBuilder extends ZipBuilder {
Expand Down
1 change: 0 additions & 1 deletion src/providers/generic/zip/ZipProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ export default abstract class ZipProvider {
public abstract zipBuilder(): ZipBuilder;

}

1 change: 1 addition & 0 deletions src/providers/node/path/NodePathImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const NodePathImplementation: NodePathProvider = {
dirname: (...args) => window.node.path.dirname(...args),
resolve: (...args) => window.node.path.resolve(...args),
get sep() {
// @ts-ignore
return window.node.path.sep()
}
}
2 changes: 1 addition & 1 deletion src/r2mm/downloading/BetterThunderstoreDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader
throw new R2Error('No mods to download', 'An empty list of mods was passed to the downloader');
}

let modInProgressName = combos[0].getMod().getName();
let modInProgressName = combos[0]!.getMod().getName();
let finishedModsDownloadedSize = 0;

const singleModProgressCallback = (downloadedBytes: number, status: DownloadStatusEnum, err: R2Error | null) => {
Expand Down
6 changes: 3 additions & 3 deletions src/r2mm/manager/ManagerSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class ManagerSettings {

public getInstalledSortBy() {
try {
return Object.entries(SortNaming).filter(value => value[0] === ManagerSettings.CONTEXT.gameSpecific.installedSortBy)[0][1];
return Object.entries(SortNaming).filter(value => value[0] === ManagerSettings.CONTEXT.gameSpecific.installedSortBy)[0]![1];
} catch (e) {
console.log("Failed to get installedSortBy:", e);
return SortNaming.CUSTOM;
Expand All @@ -144,7 +144,7 @@ export default class ManagerSettings {

public getInstalledSortDirection() {
try {
return Object.entries(SortDirection).filter(value => value[0] === ManagerSettings.CONTEXT.gameSpecific.installedSortDirection)[0][1];
return Object.entries(SortDirection).filter(value => value[0] === ManagerSettings.CONTEXT.gameSpecific.installedSortDirection)[0]![1];
} catch (e) {
console.log("Failed to get installedSortDirection:", e);
return SortDirection.STANDARD;
Expand All @@ -158,7 +158,7 @@ export default class ManagerSettings {

public getInstalledDisablePosition() {
try {
return Object.entries(SortLocalDisabledMods).filter(value => value[0] === ManagerSettings.CONTEXT.gameSpecific.installedDisablePosition)[0][1];
return Object.entries(SortLocalDisabledMods).filter(value => value[0] === ManagerSettings.CONTEXT.gameSpecific.installedDisablePosition)[0]![1];
} catch (e) {
console.log("Failed to get installedDisablePosition:", e);
return SortLocalDisabledMods.CUSTOM;
Expand Down
4 changes: 2 additions & 2 deletions src/r2mm/manager/PackageDexieStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ interface IndexChunkHash {
}

class PackageDexieStore extends Dexie {
packages!: Table<DexiePackage, string>;
packages!: Table<DexiePackage, [string, string]>;
indexHashes!: Table<IndexChunkHash, string>;
summaries!: Table<DexieSummary, string>;
summaries!: Table<DexieSummary, [string, string]>;

constructor() {
super('tsPackages');
Expand Down
2 changes: 1 addition & 1 deletion src/r2mm/system/DataFolderProviderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class DataFolderProviderImpl extends DataFolderProvider {
}

if (files.length === 1) {
return files[0];
return files[0]!;
}

// Shouldn't be possible to select multiple folders but someone always finds a way.
Expand Down
3 changes: 2 additions & 1 deletion src/r2mm/system/InteractionProviderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class InteractionProviderImpl extends InteractionProvider {
}

async getEnvironmentVariables() {
return JSON.parse((await window.electron.getEnvironmentVariables()));
const envVars = await window.electron.getEnvironmentVariables();
return JSON.parse(envVars);
}
}
8 changes: 5 additions & 3 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { ActionContext, createStore } from 'vuex';
import ErrorModule from './modules/ErrorModule';
import { DownloadModule } from './modules/DownloadModule';
import ModalsModule from './modules/ModalsModule';
import ModFilterModule from './modules/ModFilterModule';
import ModFilterModule, { State as ModFilterState } from './modules/ModFilterModule';
import ProfileModule from './modules/ProfileModule';
import ProfileExportModule from './modules/ProfileExportModule';
import { ProfilesModule } from './modules/ProfilesModule';
import { TsModsModule } from './modules/TsModsModule';
import { TsModsModule, State as TsModsState } from './modules/TsModsModule';
import { FolderMigration } from '../migrations/FolderMigration';
import Game from '../model/game/Game';
import GameManager from '../model/game/GameManager';
Expand All @@ -22,6 +22,8 @@ export interface State {
isMigrationChecked: boolean;
modLoaderPackageNames: string[];
_settings: ManagerSettings | null;
modFilters: ModFilterState;
tsMods: TsModsState;
}

type Context = ActionContext<State, State>;
Expand All @@ -39,7 +41,7 @@ export const store = {

// Access through getters to ensure the settings are loaded.
_settings: null,
},
} as unknown as State,
actions: {
async checkMigrations({commit, state}: Context) {
if (state.isMigrationChecked) {
Expand Down
Loading
Loading