From 96210373f30d91f92cd21a7ab7e2f67e9824a595 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 8 Jan 2024 23:54:12 +0100 Subject: [PATCH] Move IpcPlayerData out of inventory_sync/instance.ts Remove circular dependency between inventory_sync/message.ts and inventory_sync/instance.ts by moving the IpcPlayerData type from message.ts to instance.ts. This solves a problem with the web build checking types in instance.ts that it dosen't use. --- plugins/inventory_sync/controller.ts | 2 +- plugins/inventory_sync/instance.ts | 21 +-------------------- plugins/inventory_sync/messages.ts | 21 +++++++++++++++++++-- plugins/inventory_sync/tsconfig.web.json | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/plugins/inventory_sync/controller.ts b/plugins/inventory_sync/controller.ts index e29e9f80..0f82011e 100644 --- a/plugins/inventory_sync/controller.ts +++ b/plugins/inventory_sync/controller.ts @@ -1,5 +1,5 @@ import { BaseControllerPlugin, type InstanceInfo } from "@clusterio/controller"; -import type { IpcPlayerData } from "./instance"; +import type { IpcPlayerData } from "./messages"; import fs from "fs-extra"; import path from "path"; diff --git a/plugins/inventory_sync/instance.ts b/plugins/inventory_sync/instance.ts index 5ebd2fdd..95b7a3fe 100644 --- a/plugins/inventory_sync/instance.ts +++ b/plugins/inventory_sync/instance.ts @@ -1,32 +1,13 @@ import * as lib from "@clusterio/lib"; import { BaseInstancePlugin } from "@clusterio/host"; import { - AcquireRequest, AcquireResponse, ReleaseRequest, UploadRequest, DownloadRequest, DownloadResponse, + AcquireRequest, AcquireResponse, ReleaseRequest, UploadRequest, DownloadRequest, DownloadResponse, IpcPlayerData, } from "./messages"; type IpcPlayerName = { player_name: string } -// .\module\serialize.lua:serialize.serialize_player() -export type IpcPlayerData = { - generation: number, - controller: string, - name: string, - color: number[], - chat_color: number[], - tag: string, - force: string, - cheat_mode: boolean, - flashlight: boolean, - ticks_to_respawn?: number, - character?: any, - inventories?: any, - hotbar?: string[], - personal_logistic_slots?: {name:string, min:number, max:number}[], - crafting_queue?: any, -} - type IpcAcquireResponse = { player_name: string, status: string, diff --git a/plugins/inventory_sync/messages.ts b/plugins/inventory_sync/messages.ts index a98b194f..532dfe2f 100644 --- a/plugins/inventory_sync/messages.ts +++ b/plugins/inventory_sync/messages.ts @@ -1,8 +1,25 @@ -import type { IpcPlayerData } from "./instance"; - import { Type, Static } from "@sinclair/typebox"; import { StringEnum } from "@clusterio/lib"; +// .\module\serialize.lua:serialize.serialize_player() +export type IpcPlayerData = { + generation: number, + controller: string, + name: string, + color: number[], + chat_color: number[], + tag: string, + force: string, + cheat_mode: boolean, + flashlight: boolean, + ticks_to_respawn?: number, + character?: any, + inventories?: any, + hotbar?: string[], + personal_logistic_slots?: {name:string, min:number, max:number}[], + crafting_queue?: any, +} + const jsonPlayerData = Type.Object({ generation: Type.Number(), name: Type.String(), diff --git a/plugins/inventory_sync/tsconfig.web.json b/plugins/inventory_sync/tsconfig.web.json index 6b077616..64a8f2a5 100644 --- a/plugins/inventory_sync/tsconfig.web.json +++ b/plugins/inventory_sync/tsconfig.web.json @@ -4,7 +4,7 @@ { "path": "../../packages/lib" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "instance.ts", "package.json" ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], "compilerOptions": { "outDir": "dist/web/build", }