diff --git a/packages/controller/src/routes.ts b/packages/controller/src/routes.ts index d5f9dfbe..45d5dbc4 100644 --- a/packages/controller/src/routes.ts +++ b/packages/controller/src/routes.ts @@ -93,20 +93,8 @@ async function getMetrics(req: Request, res: Response, next: any) { } -export type PluginWebApi = { - name: string; - version: string; - enabled: boolean; - loaded: boolean; - web: { - main: string; - error?: string; - }; - requirePath: string; -} - function getPlugins(req: Request, res: Response) { - let plugins: PluginWebApi[] = []; + let plugins: lib.PluginWebApi[] = []; for (let pluginInfo of req.app.locals.controller.pluginInfos) { let name = pluginInfo.name; let loaded = req.app.locals.controller.plugins.has(name); diff --git a/packages/lib/browser.js b/packages/lib/browser.js index ad4ccaf1..15cd95d5 100644 --- a/packages/lib/browser.js +++ b/packages/lib/browser.js @@ -1,3 +1,4 @@ +export * from "./dist/src/api"; export * from "./dist/src/config"; export * from "./dist/src/data"; export * from "./dist/src/errors"; diff --git a/packages/lib/index.ts b/packages/lib/index.ts index 428086e3..4740305f 100644 --- a/packages/lib/index.ts +++ b/packages/lib/index.ts @@ -3,6 +3,7 @@ * @module lib */ export * from "./build_mod"; +export * from "./src/api"; export * from "./src/command"; export * from "./src/config"; export * from "./src/data"; diff --git a/packages/lib/src/api.ts b/packages/lib/src/api.ts new file mode 100644 index 00000000..b9ecc4d0 --- /dev/null +++ b/packages/lib/src/api.ts @@ -0,0 +1,11 @@ +export type PluginWebApi = { + name: string; + version: string; + enabled: boolean; + loaded: boolean; + web: { + main: string; + error?: string; + }; + requirePath: string; +} diff --git a/packages/web_ui/src/bootstrap.tsx b/packages/web_ui/src/bootstrap.tsx index d97fb4ff..582be9f0 100644 --- a/packages/web_ui/src/bootstrap.tsx +++ b/packages/web_ui/src/bootstrap.tsx @@ -4,7 +4,6 @@ import React from "react"; import { createRoot } from "react-dom/client"; import * as lib from "@clusterio/lib"; -import type { PluginWebApi } from "@clusterio/controller/src/routes"; import App from "./components/App"; import BaseWebPlugin from "./BaseWebPlugin"; @@ -29,7 +28,7 @@ async function loadScript(url: string) { async function loadPluginInfos(): Promise { let response = await fetch(`${window.webRoot}api/plugins`); - let pluginList: PluginWebApi[]; + let pluginList: lib.PluginWebApi[]; if (response.ok) { pluginList = await response.json(); diff --git a/packages/web_ui/src/components/HostsPage.tsx b/packages/web_ui/src/components/HostsPage.tsx index 8b70a713..c59b3c67 100644 --- a/packages/web_ui/src/components/HostsPage.tsx +++ b/packages/web_ui/src/components/HostsPage.tsx @@ -3,7 +3,6 @@ import { useNavigate } from "react-router-dom"; import { Button, Form, InputNumber, Modal, Table, Tag, Typography } from "antd"; import CopyOutlined from "@ant-design/icons/lib/icons/CopyOutlined"; -import type { PluginWebApi } from "@clusterio/controller/src/routes"; import * as lib from "@clusterio/lib"; import { useAccount } from "../model/account"; @@ -23,7 +22,7 @@ function GenerateHostTokenButton() { let [token, setToken] = useState(null); let [hostId, setHostId] = useState(null); let [form] = Form.useForm(); - let [pluginList, setPluginList] = useState([]); + let [pluginList, setPluginList] = useState([]); useEffect(() => { (async () => { let response = await fetch(`${window.webRoot}api/plugins`); diff --git a/packages/web_ui/src/components/PluginViewPage.tsx b/packages/web_ui/src/components/PluginViewPage.tsx index 429a5222..a52e396e 100644 --- a/packages/web_ui/src/components/PluginViewPage.tsx +++ b/packages/web_ui/src/components/PluginViewPage.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useContext, useState } from "react"; import { useParams } from "react-router-dom"; import { Alert, Descriptions, Spin } from "antd"; -import type { PluginWebApi } from "@clusterio/controller/src/routes"; +import type { PluginWebApi } from "@clusterio/lib"; import ControlContext from "./ControlContext"; import PageLayout from "./PageLayout"; diff --git a/packages/web_ui/src/components/PluginsPage.tsx b/packages/web_ui/src/components/PluginsPage.tsx index f47546b1..0902ff84 100644 --- a/packages/web_ui/src/components/PluginsPage.tsx +++ b/packages/web_ui/src/components/PluginsPage.tsx @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { Table } from "antd"; -import type { PluginWebApi } from "@clusterio/controller/src/routes"; +import type { PluginWebApi } from "@clusterio/lib"; import notify from "../util/notify"; import ControlContext from "./ControlContext";