mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Port remaining plugins to Typescript (#499)
* .js to .ts * Allow access to _items entries; getItemCount return number * add permission field to PluginPage interface * port plugins to typescript * update Request classes * fix IpcFlowType
This commit is contained in:
1 parent
50f12c719b
commit
0b3550b472
51 files changed
+1033
-1026
No files matched your search
@@ -224,14 +224,14 @@ export class ItemDatabase {
|
||||
* @param name - The name of the item to get the count of.
|
||||
* @returns The count of the item stored.
|
||||
*/
|
||||
getItemCount(name: string) {
|
||||
getItemCount(name: string): number {
|
||||
checkName(name);
|
||||
|
||||
if (!this._items.has(name)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this._items.get(name);
|
||||
return this._items.get(name)!;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,4 +274,11 @@ export class ItemDatabase {
|
||||
|
||||
this._items.set(name, count);
|
||||
};
|
||||
|
||||
/**
|
||||
* Allow to iterate through the items.
|
||||
*/
|
||||
getEntries(): IterableIterator<[string, number]> {
|
||||
return this._items.entries()
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,9 @@ import type { ParsedFactorioOutput } from "./logging_utils";
|
||||
import type { ModPack, ModInfo } from "./data";
|
||||
import type { Link } from "./link";
|
||||
import type { CommandTree } from "./command";
|
||||
import type { User } from "./users";
|
||||
import type { MessageRequest, MessageEvent } from "./data";
|
||||
|
||||
|
||||
/**
|
||||
* Conceptual base for controller and instance plugins.
|
||||
@@ -671,6 +674,10 @@ export interface PluginPage {
|
||||
* Should render a PageLayout.
|
||||
*/
|
||||
content?: React["ReactNode"];
|
||||
/**
|
||||
* Permission to access page. function are expected to throw an error if access is deny.
|
||||
*/
|
||||
permission?: string | ((user: User, message: MessageRequest|MessageEvent) => void);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user