@zhin.js/console 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +144 -1
- package/dist/client.js +1 -9
- package/dist/index.js +1 -9
- package/dist/lucide-react.js +0 -9294
- package/dist/radix-ui-themes.js +272 -288
- package/dist/radix-ui.js +337 -348
- package/dist/react-dom-client.js +22 -76
- package/dist/react-dom.js +1 -10
- package/dist/react-jsx-dev-runtime.js +1 -10
- package/dist/react-jsx-runtime.js +1 -10
- package/dist/react-router.js +5517 -4507
- package/dist/react.js +1 -10
- package/dist/style.css +2 -2
- package/lib/dev.js +76 -63
- package/lib/index.d.ts +18 -7
- package/lib/index.js +337 -102
- package/lib/websocket.d.ts +1 -0
- package/lib/websocket.js +69 -1
- package/package.json +15 -16
package/lib/websocket.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
|
+
import { usePlugin } from '@zhin.js/core';
|
|
2
3
|
|
|
3
4
|
// src/websocket.ts
|
|
5
|
+
var { root, logger } = usePlugin();
|
|
4
6
|
function setupWebSocket(webServer) {
|
|
5
7
|
webServer.ws.on("connection", (ws) => {
|
|
6
8
|
ws.send(
|
|
@@ -39,7 +41,7 @@ function setupWebSocket(webServer) {
|
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
async function handleWebSocketMessage(ws, message, webServer) {
|
|
42
|
-
const { type, requestId } = message;
|
|
44
|
+
const { type, requestId, pluginName } = message;
|
|
43
45
|
switch (type) {
|
|
44
46
|
case "ping":
|
|
45
47
|
ws.send(JSON.stringify({ type: "pong", requestId }));
|
|
@@ -52,6 +54,72 @@ async function handleWebSocketMessage(ws, message, webServer) {
|
|
|
52
54
|
})
|
|
53
55
|
);
|
|
54
56
|
break;
|
|
57
|
+
case "config:get":
|
|
58
|
+
try {
|
|
59
|
+
const configService = root.inject("config");
|
|
60
|
+
const appConfig = configService.get("zhin.config.yml");
|
|
61
|
+
const config = pluginName ? appConfig[pluginName] || {} : appConfig;
|
|
62
|
+
ws.send(JSON.stringify({ requestId, data: config }));
|
|
63
|
+
} catch (error) {
|
|
64
|
+
ws.send(JSON.stringify({ requestId, error: `Failed to get config: ${error.message}` }));
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case "config:get-all":
|
|
68
|
+
try {
|
|
69
|
+
const configService = root.inject("config");
|
|
70
|
+
const appConfig = configService.get("zhin.config.yml");
|
|
71
|
+
ws.send(JSON.stringify({ requestId, data: appConfig }));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
ws.send(JSON.stringify({ requestId, error: `Failed to get all configs: ${error.message}` }));
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "config:set":
|
|
77
|
+
try {
|
|
78
|
+
const { data } = message;
|
|
79
|
+
if (!pluginName) {
|
|
80
|
+
ws.send(JSON.stringify({ requestId, error: "Plugin name is required" }));
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
const configService = root.inject("config");
|
|
84
|
+
const appConfig = configService.get("zhin.config.yml");
|
|
85
|
+
appConfig[pluginName] = data;
|
|
86
|
+
configService.set("zhin.config.yml", appConfig);
|
|
87
|
+
ws.send(JSON.stringify({ requestId, success: true }));
|
|
88
|
+
broadcastToAll(webServer, {
|
|
89
|
+
type: "config:updated",
|
|
90
|
+
data: { pluginName, config: data }
|
|
91
|
+
});
|
|
92
|
+
} catch (error) {
|
|
93
|
+
ws.send(JSON.stringify({ requestId, error: `Failed to set config: ${error.message}` }));
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case "schema:get":
|
|
97
|
+
try {
|
|
98
|
+
const schemaService = root.inject("schema");
|
|
99
|
+
const schema = pluginName && schemaService ? schemaService.get(pluginName) : null;
|
|
100
|
+
if (schema) {
|
|
101
|
+
ws.send(JSON.stringify({ requestId, data: schema.toJSON() }));
|
|
102
|
+
} else {
|
|
103
|
+
ws.send(JSON.stringify({ requestId, data: null }));
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
ws.send(JSON.stringify({ requestId, error: `Failed to get schema: ${error.message}` }));
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case "schema:get-all":
|
|
110
|
+
try {
|
|
111
|
+
const schemaService = root.inject("schema");
|
|
112
|
+
const schemas = {};
|
|
113
|
+
if (schemaService) {
|
|
114
|
+
for (const [name, schema] of schemaService.items.entries()) {
|
|
115
|
+
schemas[name] = schema.toJSON();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
ws.send(JSON.stringify({ requestId, data: schemas }));
|
|
119
|
+
} catch (error) {
|
|
120
|
+
ws.send(JSON.stringify({ requestId, error: `Failed to get all schemas: ${error.message}` }));
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
55
123
|
default:
|
|
56
124
|
ws.send(
|
|
57
125
|
JSON.stringify({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/console",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Zhin 控制台",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -23,16 +23,22 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./lib/index.d.ts",
|
|
26
|
+
"development": "./src/index.ts",
|
|
26
27
|
"import": "./lib/index.js"
|
|
27
28
|
},
|
|
28
29
|
"./client": {
|
|
29
30
|
"types": "./lib/client/index.d.ts",
|
|
31
|
+
"development": "./client/index.tsx",
|
|
30
32
|
"import": "./lib/client/index.js"
|
|
31
33
|
},
|
|
32
34
|
"./browser.tsconfig.json": "./broswer.tsconfig.json",
|
|
33
35
|
"./node.tsconfig.json": "./node.tsconfig.json"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
38
|
+
"mime": "^4.1.0",
|
|
39
|
+
"ws": "^8.18.3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
36
42
|
"@radix-ui/themes": "^3.2.1",
|
|
37
43
|
"@reduxjs/toolkit": "^2.9.0",
|
|
38
44
|
"@tailwindcss/postcss": "^4.1.11",
|
|
@@ -41,29 +47,22 @@
|
|
|
41
47
|
"clsx": "^2.1.1",
|
|
42
48
|
"koa-connect": "^2.1.0",
|
|
43
49
|
"lucide-react": "^0.469.0",
|
|
44
|
-
"mime": "^4.1.0",
|
|
45
50
|
"radix-ui": "^1.4.3",
|
|
46
51
|
"react": "19.2.0",
|
|
47
52
|
"react-dom": "19.2.0",
|
|
48
53
|
"react-redux": "9.2.0",
|
|
49
|
-
"react-router": "7.
|
|
54
|
+
"react-router": "7.5.2",
|
|
50
55
|
"redux-persist": "6.0.0",
|
|
51
56
|
"tailwind-merge": "^3.3.1",
|
|
52
57
|
"tailwindcss": "latest",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
58
|
+
"tsup": "^8.5.1",
|
|
59
|
+
"vite": "^7.0.6"
|
|
55
60
|
},
|
|
56
61
|
"peerDependencies": {
|
|
57
62
|
"@types/ws": "^8.18.1",
|
|
58
|
-
"@zhin.js/client": "^1.0.
|
|
59
|
-
"@zhin.js/
|
|
60
|
-
"@zhin.js/
|
|
61
|
-
"@zhin.js/types": "^1.0.5"
|
|
62
|
-
},
|
|
63
|
-
"peerDependenciesMeta": {
|
|
64
|
-
"@zhin.js/types": {
|
|
65
|
-
"optional": true
|
|
66
|
-
}
|
|
63
|
+
"@zhin.js/client": "^1.0.6",
|
|
64
|
+
"@zhin.js/http": "^1.0.9",
|
|
65
|
+
"@zhin.js/core": "^1.0.18"
|
|
67
66
|
},
|
|
68
67
|
"files": [
|
|
69
68
|
"lib",
|
|
@@ -73,8 +72,8 @@
|
|
|
73
72
|
"client",
|
|
74
73
|
"CHANGELOG.md"
|
|
75
74
|
],
|
|
76
|
-
"
|
|
77
|
-
"
|
|
75
|
+
"optionalDependencies": {
|
|
76
|
+
"koa-connect": "^2.1.0"
|
|
78
77
|
},
|
|
79
78
|
"scripts": {
|
|
80
79
|
"build": "pnpm build:node && pnpm build:client",
|