Fix types related to plugins and the web interface

This commit is contained in:
Hornwitser committed 2023-11-28 15:35:40 +01:00
1 parent 8b5c66d900
commit 70d2b319b3
10 files changed
+17 -26

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ export interface PluginLoginForm {
* supplied the setToken function via its props which should be called * supplied the setToken function via its props which should be called
* when an authentication token is aquired via this form. * when an authentication token is aquired via this form.
*/ */
Component: typeof React.Component; Component: React.ComponentType<{ setToken(token: string): void }>;
}; };
export type UserAccount = { export type UserAccount = {
@@ -7,6 +7,7 @@ type Metadata = {
x: number; x: number;
y: number; y: number;
size: number; size: number;
localised_name?: any[];
}; };
let itemMetadataCache: Map<string, Metadata> | null = null; let itemMetadataCache: Map<string, Metadata> | null = null;
export function useItemMetadata() { export function useItemMetadata() {
+2 -4
View File
@@ -2,7 +2,7 @@ import type * as lib from "@clusterio/lib";
import { ChatEvent } from "./messages"; import { ChatEvent } from "./messages";
const info: lib.PluginDeclaration = { export default {
name: "global_chat", name: "global_chat",
title: "Global Chat", title: "Global Chat",
description: "Forwards chat between instances.", description: "Forwards chat between instances.",
@@ -12,6 +12,4 @@ const info: lib.PluginDeclaration = {
messages: [ messages: [
ChatEvent, ChatEvent,
], ],
}; } satisfies lib.PluginDeclaration;
export default info;
+2 -4
View File
@@ -40,7 +40,7 @@ lib.definePermission({
grantByDefault: true, grantByDefault: true,
}); });
const info: lib.PluginDeclaration = { export default {
name: "inventory_sync", name: "inventory_sync",
title: "Inventory sync", title: "Inventory sync",
description: "Synchronizes players inventories between instances", description: "Synchronizes players inventories between instances",
@@ -60,6 +60,4 @@ const info: lib.PluginDeclaration = {
], ],
webEntrypoint: "./web", webEntrypoint: "./web",
routes: ["/inventory"], routes: ["/inventory"],
}; } satisfies lib.PluginDeclaration;
export default info;
+1 -1
View File
@@ -139,7 +139,7 @@ export class DownloadRequest {
} }
} }
class DatabaseStatsResponse { export class DatabaseStatsResponse {
constructor( constructor(
public databaseSize: number, public databaseSize: number,
public databaseEntries: number, public databaseEntries: number,
+2 -2
View File
@@ -46,10 +46,10 @@ export class ControllerPlugin extends BaseControllerPlugin {
}, 60e3).unref(); }, 60e3).unref();
this.controller.app.get("/api/player_auth/servers", (req: Request, res: Response) => { 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()) { for (let instance of this.controller.instances!.values()) {
if (instance.status === "running" && instance.config.get("player_auth.load_plugin")) { 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); res.send(servers);
+2 -4
View File
@@ -20,7 +20,7 @@ ControllerConfigGroup.define({
}); });
ControllerConfigGroup.finalize(); ControllerConfigGroup.finalize();
const info: lib.PluginDeclaration = { export default {
name: "player_auth", name: "player_auth",
title: "Player Auth", title: "Player Auth",
description: "Provides authentication to the cluster via logging into a Factorio server.", description: "Provides authentication to the cluster via logging into a Factorio server.",
@@ -33,6 +33,4 @@ const info: lib.PluginDeclaration = {
messages.FetchPlayerCodeRequest, messages.FetchPlayerCodeRequest,
messages.SetVerifyCodeRequest, messages.SetVerifyCodeRequest,
], ],
}; } satisfies lib.PluginDeclaration;
export default info;
+2 -4
View File
@@ -2,7 +2,7 @@ import type * as lib from "@clusterio/lib";
import * as messages from "./messages"; import * as messages from "./messages";
const info: lib.PluginDeclaration = { export default {
name: "research_sync", name: "research_sync",
title: "Research Sync", title: "Research Sync",
description: "Synchronises technology research progress between instances.", description: "Synchronises technology research progress between instances.",
@@ -15,6 +15,4 @@ const info: lib.PluginDeclaration = {
messages.FinishedEvent, messages.FinishedEvent,
messages.SyncTechnologiesRequest, messages.SyncTechnologiesRequest,
], ],
}; } satisfies lib.PluginDeclaration;
export default info;
+2 -4
View File
@@ -12,7 +12,7 @@ InstanceConfigGroup.define({
}); });
InstanceConfigGroup.finalize(); InstanceConfigGroup.finalize();
const info: lib.PluginDeclaration = { export default {
name: "statistics_exporter", name: "statistics_exporter",
title: "Statistics Exporter", title: "Statistics Exporter",
description: description:
@@ -20,6 +20,4 @@ const info: lib.PluginDeclaration = {
"statistics to the cluster's Prometheus endpoint.", "statistics to the cluster's Prometheus endpoint.",
instanceEntrypoint: "dist/plugin/instance", instanceEntrypoint: "dist/plugin/instance",
InstanceConfigGroup, InstanceConfigGroup,
}; } satisfies lib.PluginDeclaration;
export default info;
+2 -2
View File
@@ -47,7 +47,7 @@ lib.definePermission({
grantByDefault: true, grantByDefault: true,
}); });
module.exports.default = { export default {
name: "subspace_storage", name: "subspace_storage",
title: "Subspace Storage", title: "Subspace Storage",
description: "Provides shared storage across instances for the Subspace Storage mod", description: "Provides shared storage across instances for the Subspace Storage mod",
@@ -66,4 +66,4 @@ module.exports.default = {
], ],
webEntrypoint: "./web", webEntrypoint: "./web",
routes: ["/storage"], routes: ["/storage"],
}; } satisfies lib.PluginDeclaration;