mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 23:14:53 +09:00
Move PluginWebApi to lib
Resolve circular dependency of controller depending on web_ui and web_ui depending on controller by moving the type from controller that was used in web_ui to lib.
This commit is contained in:
1 parent
47c5a727b5
commit
9df6717364
8 files changed
+18
-19
No files matched your search
@@ -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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./dist/src/api";
|
||||
export * from "./dist/src/config";
|
||||
export * from "./dist/src/data";
|
||||
export * from "./dist/src/errors";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export type PluginWebApi = {
|
||||
name: string;
|
||||
version: string;
|
||||
enabled: boolean;
|
||||
loaded: boolean;
|
||||
web: {
|
||||
main: string;
|
||||
error?: string;
|
||||
};
|
||||
requirePath: string;
|
||||
}
|
||||
@@ -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<lib.PluginWebpackEnvInfo[]> {
|
||||
let response = await fetch(`${window.webRoot}api/plugins`);
|
||||
let pluginList: PluginWebApi[];
|
||||
let pluginList: lib.PluginWebApi[];
|
||||
if (response.ok) {
|
||||
pluginList = await response.json();
|
||||
|
||||
|
||||
@@ -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<string|null>(null);
|
||||
let [hostId, setHostId] = useState<number|null>(null);
|
||||
let [form] = Form.useForm();
|
||||
let [pluginList, setPluginList] = useState<PluginWebApi[]>([]);
|
||||
let [pluginList, setPluginList] = useState<lib.PluginWebApi[]>([]);
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
let response = await fetch(`${window.webRoot}api/plugins`);
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user