Initial release for SPT 3.9

This commit is contained in:
2024-07-20 18:08:38 +02:00
parent 7df25ba694
commit c83da69a3e
713 changed files with 34110 additions and 1 deletions

35
types/loaders/BundleLoader.d.ts vendored Normal file
View File

@@ -0,0 +1,35 @@
import { HttpServerHelper } from "@spt/helpers/HttpServerHelper";
import { BundleHashCacheService } from "@spt/services/cache/BundleHashCacheService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { JsonUtil } from "@spt/utils/JsonUtil";
import { VFS } from "@spt/utils/VFS";
export declare class BundleInfo {
modpath: string;
filename: string;
crc: number;
dependencies: string[];
constructor(modpath: string, bundle: BundleManifestEntry, bundleHash: number);
}
export declare class BundleLoader {
protected httpServerHelper: HttpServerHelper;
protected vfs: VFS;
protected jsonUtil: JsonUtil;
protected bundleHashCacheService: BundleHashCacheService;
protected cloner: ICloner;
protected bundles: Record<string, BundleInfo>;
constructor(httpServerHelper: HttpServerHelper, vfs: VFS, jsonUtil: JsonUtil, bundleHashCacheService: BundleHashCacheService, cloner: ICloner);
/**
* Handle singleplayer/bundles
*/
getBundles(): BundleInfo[];
getBundle(key: string): BundleInfo;
addBundles(modpath: string): void;
addBundle(key: string, b: BundleInfo): void;
}
export interface BundleManifest {
manifest: BundleManifestEntry[];
}
export interface BundleManifestEntry {
key: string;
dependencyKeys: string[];
}

17
types/loaders/ModLoadOrder.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
import { IPackageJsonData } from "@spt/models/spt/mod/IPackageJsonData";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { LocalisationService } from "@spt/services/LocalisationService";
export declare class ModLoadOrder {
protected logger: ILogger;
protected localisationService: LocalisationService;
protected mods: Map<string, IPackageJsonData>;
protected modsAvailable: Map<string, IPackageJsonData>;
protected loadOrder: Set<string>;
constructor(logger: ILogger, localisationService: LocalisationService);
setModList(mods: Record<string, IPackageJsonData>): void;
getLoadOrder(): string[];
getModsOnLoadBefore(mod: string): Set<string>;
getModsOnLoadAfter(mod: string): Set<string>;
protected invertLoadBefore(mod: string): void;
protected getLoadOrderRecursive(mod: string, visited: Set<string>): void;
}

43
types/loaders/ModTypeCheck.d.ts vendored Normal file
View File

@@ -0,0 +1,43 @@
import { IPostDBLoadMod } from "@spt/models/external/IPostDBLoadMod";
import { IPostDBLoadModAsync } from "@spt/models/external/IPostDBLoadModAsync";
import { IPostSptLoadMod } from "@spt/models/external/IPostSptLoadMod";
import { IPostSptLoadModAsync } from "@spt/models/external/IPostSptLoadModAsync";
import { IPreSptLoadMod } from "@spt/models/external/IPreSptLoadMod";
import { IPreSptLoadModAsync } from "@spt/models/external/IPreSptLoadModAsync";
export declare class ModTypeCheck {
/**
* Use defined safe guard to check if the mod is a IPreSptLoadMod
* @returns boolean
*/
isPreSptLoad(mod: any): mod is IPreSptLoadMod;
/**
* Use defined safe guard to check if the mod is a IPostSptLoadMod
* @returns boolean
*/
isPostSptLoad(mod: any): mod is IPostSptLoadMod;
/**
* Use defined safe guard to check if the mod is a IPostDBLoadMod
* @returns boolean
*/
isPostDBLoad(mod: any): mod is IPostDBLoadMod;
/**
* Use defined safe guard to check if the mod is a IPreSptLoadModAsync
* @returns boolean
*/
isPreSptLoadAsync(mod: any): mod is IPreSptLoadModAsync;
/**
* Use defined safe guard to check if the mod is a IPostSptLoadModAsync
* @returns boolean
*/
isPostSptLoadAsync(mod: any): mod is IPostSptLoadModAsync;
/**
* Use defined safe guard to check if the mod is a IPostDBLoadModAsync
* @returns boolean
*/
isPostDBLoadAsync(mod: any): mod is IPostDBLoadModAsync;
/**
* Checks for mod to be compatible with 3.X+
* @returns boolean
*/
isPostV3Compatible(mod: any): boolean;
}

21
types/loaders/PostDBModLoader.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
import { DependencyContainer } from "tsyringe";
import { OnLoad } from "@spt/di/OnLoad";
import { BundleLoader } from "@spt/loaders/BundleLoader";
import { ModTypeCheck } from "@spt/loaders/ModTypeCheck";
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { LocalisationService } from "@spt/services/LocalisationService";
export declare class PostDBModLoader implements OnLoad {
protected logger: ILogger;
protected bundleLoader: BundleLoader;
protected preSptModLoader: PreSptModLoader;
protected localisationService: LocalisationService;
protected modTypeCheck: ModTypeCheck;
protected container: DependencyContainer;
constructor(logger: ILogger, bundleLoader: BundleLoader, preSptModLoader: PreSptModLoader, localisationService: LocalisationService, modTypeCheck: ModTypeCheck);
onLoad(): Promise<void>;
getRoute(): string;
getModPath(mod: string): string;
protected executeModsAsync(): Promise<void>;
protected addBundles(): void;
}

17
types/loaders/PostSptModLoader.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
import { DependencyContainer } from "tsyringe";
import { ModTypeCheck } from "@spt/loaders/ModTypeCheck";
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
import { IModLoader } from "@spt/models/spt/mod/IModLoader";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { LocalisationService } from "@spt/services/LocalisationService";
export declare class PostSptModLoader implements IModLoader {
protected logger: ILogger;
protected preSptModLoader: PreSptModLoader;
protected localisationService: LocalisationService;
protected modTypeCheck: ModTypeCheck;
protected container: DependencyContainer;
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, localisationService: LocalisationService, modTypeCheck: ModTypeCheck);
getModPath(mod: string): string;
load(): Promise<void>;
protected executeModsAsync(): Promise<void>;
}

99
types/loaders/PreSptModLoader.d.ts vendored Normal file
View File

@@ -0,0 +1,99 @@
import { DependencyContainer } from "tsyringe";
import { ModLoadOrder } from "@spt/loaders/ModLoadOrder";
import { ModTypeCheck } from "@spt/loaders/ModTypeCheck";
import { ModDetails } from "@spt/models/eft/profile/ISptProfile";
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
import { IModLoader } from "@spt/models/spt/mod/IModLoader";
import { IPackageJsonData } from "@spt/models/spt/mod/IPackageJsonData";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer";
import { LocalisationService } from "@spt/services/LocalisationService";
import { ModCompilerService } from "@spt/services/ModCompilerService";
import { JsonUtil } from "@spt/utils/JsonUtil";
import { VFS } from "@spt/utils/VFS";
export declare class PreSptModLoader implements IModLoader {
protected logger: ILogger;
protected vfs: VFS;
protected jsonUtil: JsonUtil;
protected modCompilerService: ModCompilerService;
protected localisationService: LocalisationService;
protected configServer: ConfigServer;
protected modLoadOrder: ModLoadOrder;
protected modTypeCheck: ModTypeCheck;
protected container: DependencyContainer;
protected readonly basepath = "user/mods/";
protected readonly modOrderPath = "user/mods/order.json";
protected order: Record<string, number>;
protected imported: Record<string, IPackageJsonData>;
protected sptConfig: ICoreConfig;
protected serverDependencies: Record<string, string>;
protected skippedMods: Set<string>;
constructor(logger: ILogger, vfs: VFS, jsonUtil: JsonUtil, modCompilerService: ModCompilerService, localisationService: LocalisationService, configServer: ConfigServer, modLoadOrder: ModLoadOrder, modTypeCheck: ModTypeCheck);
load(container: DependencyContainer): Promise<void>;
/**
* Returns a list of mods with preserved load order
* @returns Array of mod names in load order
*/
getImportedModsNames(): string[];
getImportedModDetails(): Record<string, IPackageJsonData>;
getProfileModsGroupedByModName(profileMods: ModDetails[]): ModDetails[];
getModPath(mod: string): string;
protected importModsAsync(): Promise<void>;
protected sortMods(prev: string, next: string, missingFromOrderJSON: Record<string, boolean>): number;
/**
* Check for duplicate mods loaded, show error if any
* @param modPackageData map of mod package.json data
*/
protected checkForDuplicateMods(modPackageData: Map<string, IPackageJsonData>): void;
/**
* Returns an array of valid mods.
*
* @param mods mods to validate
* @returns array of mod folder names
*/
protected getValidMods(mods: string[]): string[];
/**
* Get packageJson data for mods
* @param mods mods to get packageJson for
* @returns map <modFolderName - package.json>
*/
protected getModsPackageData(mods: string[]): Map<string, IPackageJsonData>;
/**
* Is the passed in mod compatible with the running server version
* @param mod Mod to check compatibiltiy with SPT
* @returns True if compatible
*/
protected isModCombatibleWithSpt(mod: IPackageJsonData): boolean;
/**
* Execute each mod found in this.imported
* @returns void promise
*/
protected executeModsAsync(): Promise<void>;
/**
* Read loadorder.json (create if doesnt exist) and return sorted list of mods
* @returns string array of sorted mod names
*/
sortModsLoadOrder(): string[];
/**
* Compile mod and add into class property "imported"
* @param mod Name of mod to compile/add
*/
protected addModAsync(mod: string, pkg: IPackageJsonData): Promise<void>;
/**
* Checks if a given mod should be loaded or skipped.
*
* @param pkg mod package.json data
* @returns
*/
protected shouldSkipMod(pkg: IPackageJsonData): boolean;
protected autoInstallDependencies(modPath: string, pkg: IPackageJsonData): void;
protected areModDependenciesFulfilled(pkg: IPackageJsonData, loadedMods: Map<string, IPackageJsonData>): boolean;
protected isModCompatible(mod: IPackageJsonData, loadedMods: Map<string, IPackageJsonData>): boolean;
/**
* Validate a mod passes a number of checks
* @param modName name of mod in /mods/ to validate
* @returns true if valid
*/
protected validMod(modName: string): boolean;
getContainer(): DependencyContainer;
}