mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-03-28 09:44:39 +09:00
Merge branch 'aperx' of https://github.com/PHIDIAS0303/ExpCluster into aperx
This commit is contained in:
@@ -11,25 +11,25 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@clusterio/lib": "^2.0.0-alpha.19"
|
"@clusterio/lib": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@clusterio/lib": "^2.0.0-alpha.20",
|
"@clusterio/lib": "catalog:",
|
||||||
"@clusterio/web_ui": "^2.0.0-alpha.20.b",
|
"@clusterio/web_ui": "catalog:",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^20.4.5",
|
"@types/node": "catalog:",
|
||||||
"@types/react": "^18.2.21",
|
"@types/react": "catalog:",
|
||||||
"antd": "^5.13.0",
|
"antd": "catalog:",
|
||||||
"react": "^18.2.0",
|
"react": "catalog:",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "catalog:",
|
||||||
"typescript": "^5.5.3",
|
"typescript": "catalog:",
|
||||||
"webpack": "^5.98.0",
|
"webpack": "catalog:",
|
||||||
"webpack-cli": "^5.1.4",
|
"webpack-cli": "catalog:",
|
||||||
"webpack-merge": "^5.9.0"
|
"webpack-merge": "catalog:"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sinclair/typebox": "^0.30.4",
|
"@sinclair/typebox": "catalog:",
|
||||||
"fs-extra": "^11.2.0"
|
"fs-extra": "^11.3.3"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as Messages from "./messages";
|
// import * as Messages from "./messages";
|
||||||
|
|
||||||
lib.definePermission({
|
lib.definePermission({
|
||||||
name: "exp_scenario.config.view",
|
name: "exp_scenario.config.view",
|
||||||
@@ -24,6 +24,7 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
controllerEntrypoint: "./dist/node/controller",
|
controllerEntrypoint: "./dist/node/controller",
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance",
|
||||||
|
|
||||||
|
/*
|
||||||
messages: [
|
messages: [
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -31,4 +32,5 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
routes: [
|
routes: [
|
||||||
"/exp_scenario",
|
"/exp_scenario",
|
||||||
],
|
],
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
import React, {
|
|
||||||
useContext, useEffect, useState,
|
|
||||||
useCallback, useSyncExternalStore,
|
|
||||||
} from "react";
|
|
||||||
|
|
||||||
// import {
|
|
||||||
//
|
|
||||||
// } from "antd";
|
|
||||||
|
|
||||||
import {
|
|
||||||
BaseWebPlugin, PageLayout, PageHeader, Control, ControlContext, notifyErrorHandler,
|
|
||||||
} from "@clusterio/web_ui";
|
|
||||||
|
|
||||||
import {
|
|
||||||
PluginExampleEvent, PluginExampleRequest,
|
|
||||||
ExampleSubscribableUpdate, ExampleSubscribableValue,
|
|
||||||
} from "../messages";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
|
||||||
|
|
||||||
function MyTemplatePage() {
|
|
||||||
const control = useContext(ControlContext);
|
|
||||||
const plugin = control.plugins.get("exp_scenario") as WebPlugin;
|
|
||||||
const [subscribableData, synced] = plugin.useSubscribableData();
|
|
||||||
|
|
||||||
return <PageLayout nav={[{ name: "exp_scenario" }]}>
|
|
||||||
<PageHeader title="exp_scenario" />
|
|
||||||
Synced: {String(synced)} Data: {JSON.stringify([...subscribableData.values()])}
|
|
||||||
</PageLayout>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class WebPlugin extends BaseWebPlugin {
|
|
||||||
subscribableData = new lib.EventSubscriber(ExampleSubscribableUpdate, this.control);
|
|
||||||
|
|
||||||
async init() {
|
|
||||||
this.pages = [
|
|
||||||
{
|
|
||||||
path: "/exp_scenario",
|
|
||||||
sidebarName: "exp_scenario",
|
|
||||||
// This permission is client side only, so it must match the permission string of a resource request to be secure
|
|
||||||
// An undefined value means that the page will always be visible
|
|
||||||
permission: "exp_scenario.example.permission.subscribe",
|
|
||||||
content: <MyTemplatePage/>,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
this.control.handle(PluginExampleEvent, this.handlePluginExampleEvent.bind(this));
|
|
||||||
this.control.handle(PluginExampleRequest, this.handlePluginExampleRequest.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
useSubscribableData() {
|
|
||||||
const control = useContext(ControlContext);
|
|
||||||
const subscribe = useCallback((callback: () => void) => this.subscribableData.subscribe(callback), [control]);
|
|
||||||
return useSyncExternalStore(subscribe, () => this.subscribableData.getSnapshot());
|
|
||||||
}
|
|
||||||
|
|
||||||
async handlePluginExampleEvent(event: PluginExampleEvent) {
|
|
||||||
this.logger.info(JSON.stringify(event));
|
|
||||||
}
|
|
||||||
|
|
||||||
async handlePluginExampleRequest(request: PluginExampleRequest) {
|
|
||||||
this.logger.info(JSON.stringify(request));
|
|
||||||
return {
|
|
||||||
myResponseString: request.myString,
|
|
||||||
myResponseNumbers: request.myNumberArray,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
68
exp_scenario/web/~index.tsx
Normal file
68
exp_scenario/web/~index.tsx
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import React, {
|
||||||
|
useContext, useEffect, useState,
|
||||||
|
useCallback, useSyncExternalStore,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
|
// import {
|
||||||
|
//
|
||||||
|
// } from "antd";
|
||||||
|
|
||||||
|
import {
|
||||||
|
BaseWebPlugin, PageLayout, PageHeader, Control, ControlContext, notifyErrorHandler,
|
||||||
|
} from "@clusterio/web_ui";
|
||||||
|
|
||||||
|
import {
|
||||||
|
PluginExampleEvent, PluginExampleRequest,
|
||||||
|
ExampleSubscribableUpdate, ExampleSubscribableValue,
|
||||||
|
} from "../messages";
|
||||||
|
|
||||||
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
|
function MyTemplatePage() {
|
||||||
|
const control = useContext(ControlContext);
|
||||||
|
const plugin = control.plugins.get("exp_scenario") as WebPlugin;
|
||||||
|
const [subscribableData, synced] = plugin.useSubscribableData();
|
||||||
|
|
||||||
|
return <PageLayout nav={[{ name: "exp_scenario" }]}>
|
||||||
|
<PageHeader title="exp_scenario" />
|
||||||
|
Synced: {String(synced)} Data: {JSON.stringify([...subscribableData.values()])}
|
||||||
|
</PageLayout>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class WebPlugin extends BaseWebPlugin {
|
||||||
|
subscribableData = new lib.EventSubscriber(ExampleSubscribableUpdate, this.control);
|
||||||
|
|
||||||
|
async init() {
|
||||||
|
this.pages = [
|
||||||
|
{
|
||||||
|
path: "/exp_scenario",
|
||||||
|
sidebarName: "exp_scenario",
|
||||||
|
// This permission is client side only, so it must match the permission string of a resource request to be secure
|
||||||
|
// An undefined value means that the page will always be visible
|
||||||
|
permission: "exp_scenario.example.permission.subscribe",
|
||||||
|
content: <MyTemplatePage/>,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
this.control.handle(PluginExampleEvent, this.handlePluginExampleEvent.bind(this));
|
||||||
|
this.control.handle(PluginExampleRequest, this.handlePluginExampleRequest.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
useSubscribableData() {
|
||||||
|
const control = useContext(ControlContext);
|
||||||
|
const subscribe = useCallback((callback: () => void) => this.subscribableData.subscribe(callback), [control]);
|
||||||
|
return useSyncExternalStore(subscribe, () => this.subscribableData.getSnapshot());
|
||||||
|
}
|
||||||
|
|
||||||
|
async handlePluginExampleEvent(event: PluginExampleEvent) {
|
||||||
|
this.logger.info(JSON.stringify(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
async handlePluginExampleRequest(request: PluginExampleRequest) {
|
||||||
|
this.logger.info(JSON.stringify(request));
|
||||||
|
return {
|
||||||
|
myResponseString: request.myString,
|
||||||
|
myResponseNumbers: request.myNumberArray,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
2338
pnpm-lock.yaml
generated
2338
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,16 @@
|
|||||||
packages:
|
packages:
|
||||||
- "*"
|
- '*'
|
||||||
|
|
||||||
catalog:
|
catalog:
|
||||||
"@clusterio/lib": ^2.0.0-alpha.21
|
'@clusterio/lib': 2.0.0-alpha.22b
|
||||||
"@clusterio/web_ui": ^2.0.0-alpha.21
|
'@clusterio/web_ui': 2.0.0-alpha.22b
|
||||||
"@sinclair/typebox": ^0.30.4
|
'@sinclair/typebox': ^0.30.4
|
||||||
"@types/node": ^20.14.9
|
'@types/node': ^20.19.29
|
||||||
"@types/react": ^18.2.21
|
'@types/react': 18.2.0
|
||||||
"typescript": ^5.5.3
|
antd: 5.24.2
|
||||||
"antd": ^5.13.0
|
react: 18.2.0
|
||||||
"react": ^18.2.0
|
react-dom: 18.2.0
|
||||||
"react-dom": ^18.2.0
|
typescript: ^5.9.3
|
||||||
"webpack": ^5.98.0
|
webpack: 5.98.0
|
||||||
"webpack-cli": ^5.1.4
|
webpack-cli: 5.1.4
|
||||||
"webpack-merge": ^5.9.0
|
webpack-merge: 5.9.0
|
||||||
|
|||||||
15
zh_Hans.tbx
Normal file
15
zh_Hans.tbx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE martif PUBLIC "ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN" "TBXcdv04.dtd">
|
||||||
|
<martif type="TBX">
|
||||||
|
<martifHeader>
|
||||||
|
<fileDesc>
|
||||||
|
<sourceDesc>
|
||||||
|
<p>Weblate Glossary</p>
|
||||||
|
</sourceDesc>
|
||||||
|
</fileDesc>
|
||||||
|
</martifHeader>
|
||||||
|
<text>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</text>
|
||||||
|
</martif>
|
||||||
15
zh_Hant.tbx
Normal file
15
zh_Hant.tbx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE martif PUBLIC "ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN" "TBXcdv04.dtd">
|
||||||
|
<martif type="TBX">
|
||||||
|
<martifHeader>
|
||||||
|
<fileDesc>
|
||||||
|
<sourceDesc>
|
||||||
|
<p>Weblate Glossary</p>
|
||||||
|
</sourceDesc>
|
||||||
|
</fileDesc>
|
||||||
|
</martifHeader>
|
||||||
|
<text>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</text>
|
||||||
|
</martif>
|
||||||
Reference in New Issue
Block a user