From 70d2b319b364079494799b3542710adf410e97cb Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Tue, 28 Nov 2023 00:31:51 +0100 Subject: [PATCH] Fix types related to plugins and the web interface --- packages/web_ui/src/BaseWebPlugin.ts | 2 +- packages/web_ui/src/model/item_metadata.ts | 1 + plugins/global_chat/info.ts | 6 ++---- plugins/inventory_sync/info.ts | 6 ++---- plugins/inventory_sync/messages.ts | 2 +- plugins/player_auth/controller.ts | 4 ++-- plugins/player_auth/info.ts | 6 ++---- plugins/research_sync/info.ts | 6 ++---- plugins/statistics_exporter/info.ts | 6 ++---- plugins/subspace_storage/info.ts | 4 ++-- 10 files changed, 17 insertions(+), 26 deletions(-) diff --git a/packages/web_ui/src/BaseWebPlugin.ts b/packages/web_ui/src/BaseWebPlugin.ts index 755aac9b..e476cbe1 100644 --- a/packages/web_ui/src/BaseWebPlugin.ts +++ b/packages/web_ui/src/BaseWebPlugin.ts @@ -19,7 +19,7 @@ export interface PluginLoginForm { * supplied the setToken function via its props which should be called * when an authentication token is aquired via this form. */ - Component: typeof React.Component; + Component: React.ComponentType<{ setToken(token: string): void }>; }; export type UserAccount = { diff --git a/packages/web_ui/src/model/item_metadata.ts b/packages/web_ui/src/model/item_metadata.ts index e5065717..6ef564f3 100644 --- a/packages/web_ui/src/model/item_metadata.ts +++ b/packages/web_ui/src/model/item_metadata.ts @@ -7,6 +7,7 @@ type Metadata = { x: number; y: number; size: number; + localised_name?: any[]; }; let itemMetadataCache: Map | null = null; export function useItemMetadata() { diff --git a/plugins/global_chat/info.ts b/plugins/global_chat/info.ts index 192a31ba..092a3287 100644 --- a/plugins/global_chat/info.ts +++ b/plugins/global_chat/info.ts @@ -2,7 +2,7 @@ import type * as lib from "@clusterio/lib"; import { ChatEvent } from "./messages"; -const info: lib.PluginDeclaration = { +export default { name: "global_chat", title: "Global Chat", description: "Forwards chat between instances.", @@ -12,6 +12,4 @@ const info: lib.PluginDeclaration = { messages: [ ChatEvent, ], -}; - -export default info; +} satisfies lib.PluginDeclaration; diff --git a/plugins/inventory_sync/info.ts b/plugins/inventory_sync/info.ts index 29b11f2e..d3090271 100644 --- a/plugins/inventory_sync/info.ts +++ b/plugins/inventory_sync/info.ts @@ -40,7 +40,7 @@ lib.definePermission({ grantByDefault: true, }); -const info: lib.PluginDeclaration = { +export default { name: "inventory_sync", title: "Inventory sync", description: "Synchronizes players inventories between instances", @@ -60,6 +60,4 @@ const info: lib.PluginDeclaration = { ], webEntrypoint: "./web", routes: ["/inventory"], -}; - -export default info; +} satisfies lib.PluginDeclaration; diff --git a/plugins/inventory_sync/messages.ts b/plugins/inventory_sync/messages.ts index 787fc75f..a98b194f 100644 --- a/plugins/inventory_sync/messages.ts +++ b/plugins/inventory_sync/messages.ts @@ -139,7 +139,7 @@ export class DownloadRequest { } } -class DatabaseStatsResponse { +export class DatabaseStatsResponse { constructor( public databaseSize: number, public databaseEntries: number, diff --git a/plugins/player_auth/controller.ts b/plugins/player_auth/controller.ts index dbdb2c9c..f9863008 100644 --- a/plugins/player_auth/controller.ts +++ b/plugins/player_auth/controller.ts @@ -46,10 +46,10 @@ export class ControllerPlugin extends BaseControllerPlugin { }, 60e3).unref(); this.controller.app.get("/api/player_auth/servers", (req: Request, res: Response) => { - let servers = []; + let servers: string[] = []; for (let instance of this.controller.instances!.values()) { if (instance.status === "running" && instance.config.get("player_auth.load_plugin")) { - servers.push(instance.config.get("factorio.settings")["name"] || "unnamed server"); + servers.push(instance.config.get("factorio.settings")["name"] as string || "unnamed server"); } } res.send(servers); diff --git a/plugins/player_auth/info.ts b/plugins/player_auth/info.ts index 5de172e0..8289657a 100644 --- a/plugins/player_auth/info.ts +++ b/plugins/player_auth/info.ts @@ -20,7 +20,7 @@ ControllerConfigGroup.define({ }); ControllerConfigGroup.finalize(); -const info: lib.PluginDeclaration = { +export default { name: "player_auth", title: "Player Auth", description: "Provides authentication to the cluster via logging into a Factorio server.", @@ -33,6 +33,4 @@ const info: lib.PluginDeclaration = { messages.FetchPlayerCodeRequest, messages.SetVerifyCodeRequest, ], -}; - -export default info; +} satisfies lib.PluginDeclaration; diff --git a/plugins/research_sync/info.ts b/plugins/research_sync/info.ts index 55e7f4e8..b6692e12 100644 --- a/plugins/research_sync/info.ts +++ b/plugins/research_sync/info.ts @@ -2,7 +2,7 @@ import type * as lib from "@clusterio/lib"; import * as messages from "./messages"; -const info: lib.PluginDeclaration = { +export default { name: "research_sync", title: "Research Sync", description: "Synchronises technology research progress between instances.", @@ -15,6 +15,4 @@ const info: lib.PluginDeclaration = { messages.FinishedEvent, messages.SyncTechnologiesRequest, ], -}; - -export default info; +} satisfies lib.PluginDeclaration; diff --git a/plugins/statistics_exporter/info.ts b/plugins/statistics_exporter/info.ts index 9f668cb5..138e3024 100644 --- a/plugins/statistics_exporter/info.ts +++ b/plugins/statistics_exporter/info.ts @@ -12,7 +12,7 @@ InstanceConfigGroup.define({ }); InstanceConfigGroup.finalize(); -const info: lib.PluginDeclaration = { +export default { name: "statistics_exporter", title: "Statistics Exporter", description: @@ -20,6 +20,4 @@ const info: lib.PluginDeclaration = { "statistics to the cluster's Prometheus endpoint.", instanceEntrypoint: "dist/plugin/instance", InstanceConfigGroup, -}; - -export default info; +} satisfies lib.PluginDeclaration; diff --git a/plugins/subspace_storage/info.ts b/plugins/subspace_storage/info.ts index 58d7a60d..c54da3c2 100644 --- a/plugins/subspace_storage/info.ts +++ b/plugins/subspace_storage/info.ts @@ -47,7 +47,7 @@ lib.definePermission({ grantByDefault: true, }); -module.exports.default = { +export default { name: "subspace_storage", title: "Subspace Storage", description: "Provides shared storage across instances for the Subspace Storage mod", @@ -66,4 +66,4 @@ module.exports.default = { ], webEntrypoint: "./web", routes: ["/storage"], -}; +} satisfies lib.PluginDeclaration;