@zhin.js/console 1.0.12 → 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 +18 -0
- package/README.md +144 -1
- package/client/src/pages/dashboard-plugin-detail.tsx +33 -5
- package/dist/client.js +1 -9
- package/dist/index.js +5 -13
- 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/bin.d.ts +0 -2
- package/lib/bin.js +101 -15
- package/lib/build.d.ts +4 -2
- package/lib/build.js +83 -83
- package/lib/dev.d.ts +6 -4
- package/lib/dev.js +80 -69
- package/lib/index.d.ts +23 -10
- package/lib/index.js +405 -147
- package/lib/websocket.d.ts +10 -5
- package/lib/websocket.js +139 -78
- package/package.json +25 -21
- package/lib/bin.d.ts.map +0 -1
- package/lib/bin.js.map +0 -1
- package/lib/build.d.ts.map +0 -1
- package/lib/build.js.map +0 -1
- package/lib/dev.d.ts.map +0 -1
- package/lib/dev.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/websocket.d.ts.map +0 -1
- package/lib/websocket.js.map +0 -1
package/lib/bin.d.ts
CHANGED
package/lib/bin.js
CHANGED
|
@@ -1,21 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import * as vite from 'vite';
|
|
3
|
+
import { existsSync, promises } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
7
|
+
|
|
8
|
+
async function build2(root, config = {}) {
|
|
9
|
+
if (!existsSync(root + "/client")) return;
|
|
10
|
+
const outDir = root + "/dist";
|
|
11
|
+
if (existsSync(outDir)) {
|
|
12
|
+
await promises.rm(outDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
const maybeFiles = [
|
|
15
|
+
join(root, "client", "index.tsx"),
|
|
16
|
+
join(root, "client", "index.ts"),
|
|
17
|
+
join(root, "client", "index.js"),
|
|
18
|
+
join(root, "client", "index.jsx")
|
|
19
|
+
];
|
|
20
|
+
const entry = maybeFiles.find((file) => existsSync(file));
|
|
21
|
+
if (!entry) {
|
|
22
|
+
throw new Error("No entry file found");
|
|
23
|
+
}
|
|
24
|
+
await promises.mkdir(root + "/dist", { recursive: true });
|
|
25
|
+
const results = await vite.build(vite.mergeConfig({
|
|
26
|
+
root,
|
|
27
|
+
build: {
|
|
28
|
+
write: false,
|
|
29
|
+
outDir: "dist",
|
|
30
|
+
assetsDir: "",
|
|
31
|
+
minify: true,
|
|
32
|
+
emptyOutDir: true,
|
|
33
|
+
commonjsOptions: {
|
|
34
|
+
strictRequires: true
|
|
35
|
+
},
|
|
36
|
+
lib: {
|
|
37
|
+
entry,
|
|
38
|
+
fileName: "index",
|
|
39
|
+
formats: ["es"]
|
|
40
|
+
},
|
|
41
|
+
rollupOptions: {
|
|
42
|
+
makeAbsoluteExternalsRelative: true,
|
|
43
|
+
external: [
|
|
44
|
+
"react",
|
|
45
|
+
"react-dom",
|
|
46
|
+
"react/jsx-runtime",
|
|
47
|
+
"react/jsx-dev-runtime",
|
|
48
|
+
"radix-ui",
|
|
49
|
+
"@radix-ui/themes",
|
|
50
|
+
"lucide-react",
|
|
51
|
+
"@zhin.js/client"
|
|
52
|
+
],
|
|
53
|
+
resolve: {
|
|
54
|
+
alias: {
|
|
55
|
+
"react/jsx-runtime": root + "/react-jsx-runtime.js",
|
|
56
|
+
"react/jsx-dev-runtime": root + "/react-jsx-dev-runtime.js",
|
|
57
|
+
"react": root + "/react.js",
|
|
58
|
+
"react-dom": root + "/react-dom.js",
|
|
59
|
+
"radix-ui": root + "/radix-ui.js",
|
|
60
|
+
"@radix-ui/themes": root + "/radix-ui-themes.js"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
output: {
|
|
64
|
+
format: "iife"
|
|
13
65
|
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
plugins: [
|
|
69
|
+
react(),
|
|
70
|
+
tailwindcss()
|
|
71
|
+
],
|
|
72
|
+
define: {
|
|
73
|
+
"process.env.NODE_ENV": '"production"'
|
|
74
|
+
}
|
|
75
|
+
}, config));
|
|
76
|
+
for (const item of results[0].output) {
|
|
77
|
+
if (item.fileName === "index.mjs") item.fileName = "index.js";
|
|
78
|
+
const dest = root + "/dist/" + item.fileName;
|
|
79
|
+
if (item.type === "asset") {
|
|
80
|
+
await promises.writeFile(dest, item.source);
|
|
81
|
+
} else {
|
|
82
|
+
const result = await vite.transformWithEsbuild(item.code, dest, {
|
|
83
|
+
minifyWhitespace: true,
|
|
84
|
+
charset: "utf8"
|
|
85
|
+
});
|
|
86
|
+
await promises.writeFile(dest, result.code);
|
|
14
87
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/bin.ts
|
|
92
|
+
var args = process.argv.slice(2);
|
|
93
|
+
var command = args[0];
|
|
94
|
+
async function main() {
|
|
95
|
+
try {
|
|
96
|
+
switch (command) {
|
|
97
|
+
case "build":
|
|
98
|
+
console.log("\u{1F528} Building plugin client...");
|
|
99
|
+
await build2(process.cwd());
|
|
100
|
+
break;
|
|
18
101
|
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error("\u274C Build failed:", error);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
19
106
|
}
|
|
20
107
|
main();
|
|
21
|
-
//# sourceMappingURL=bin.js.map
|
package/lib/build.d.ts
CHANGED
package/lib/build.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
|
-
import { existsSync, promises
|
|
2
|
+
import { existsSync, promises } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import react from '@vitejs/plugin-react';
|
|
5
|
-
import tailwindcss from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
resolve: {
|
|
53
|
-
alias: {
|
|
54
|
-
'react/jsx-runtime': root + '/react-jsx-runtime.js',
|
|
55
|
-
'react/jsx-dev-runtime': root + '/react-jsx-dev-runtime.js',
|
|
56
|
-
'react': root + '/react.js',
|
|
57
|
-
'react-dom': root + '/react-dom.js',
|
|
58
|
-
'radix-ui': root + '/radix-ui.js',
|
|
59
|
-
'@radix-ui/themes': root + '/radix-ui-themes.js',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
output: {
|
|
63
|
-
format: 'iife',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
plugins: [
|
|
68
|
-
react(),
|
|
69
|
-
tailwindcss(),
|
|
5
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
6
|
+
|
|
7
|
+
// src/build.ts
|
|
8
|
+
async function build2(root, config = {}) {
|
|
9
|
+
if (!existsSync(root + "/client")) return;
|
|
10
|
+
const outDir = root + "/dist";
|
|
11
|
+
if (existsSync(outDir)) {
|
|
12
|
+
await promises.rm(outDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
const maybeFiles = [
|
|
15
|
+
join(root, "client", "index.tsx"),
|
|
16
|
+
join(root, "client", "index.ts"),
|
|
17
|
+
join(root, "client", "index.js"),
|
|
18
|
+
join(root, "client", "index.jsx")
|
|
19
|
+
];
|
|
20
|
+
const entry = maybeFiles.find((file) => existsSync(file));
|
|
21
|
+
if (!entry) {
|
|
22
|
+
throw new Error("No entry file found");
|
|
23
|
+
}
|
|
24
|
+
await promises.mkdir(root + "/dist", { recursive: true });
|
|
25
|
+
const results = await vite.build(vite.mergeConfig({
|
|
26
|
+
root,
|
|
27
|
+
build: {
|
|
28
|
+
write: false,
|
|
29
|
+
outDir: "dist",
|
|
30
|
+
assetsDir: "",
|
|
31
|
+
minify: true,
|
|
32
|
+
emptyOutDir: true,
|
|
33
|
+
commonjsOptions: {
|
|
34
|
+
strictRequires: true
|
|
35
|
+
},
|
|
36
|
+
lib: {
|
|
37
|
+
entry,
|
|
38
|
+
fileName: "index",
|
|
39
|
+
formats: ["es"]
|
|
40
|
+
},
|
|
41
|
+
rollupOptions: {
|
|
42
|
+
makeAbsoluteExternalsRelative: true,
|
|
43
|
+
external: [
|
|
44
|
+
"react",
|
|
45
|
+
"react-dom",
|
|
46
|
+
"react/jsx-runtime",
|
|
47
|
+
"react/jsx-dev-runtime",
|
|
48
|
+
"radix-ui",
|
|
49
|
+
"@radix-ui/themes",
|
|
50
|
+
"lucide-react",
|
|
51
|
+
"@zhin.js/client"
|
|
70
52
|
],
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
resolve: {
|
|
54
|
+
alias: {
|
|
55
|
+
"react/jsx-runtime": root + "/react-jsx-runtime.js",
|
|
56
|
+
"react/jsx-dev-runtime": root + "/react-jsx-dev-runtime.js",
|
|
57
|
+
"react": root + "/react.js",
|
|
58
|
+
"react-dom": root + "/react-dom.js",
|
|
59
|
+
"radix-ui": root + "/radix-ui.js",
|
|
60
|
+
"@radix-ui/themes": root + "/radix-ui-themes.js"
|
|
61
|
+
}
|
|
73
62
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (item.fileName === 'index.mjs')
|
|
77
|
-
item.fileName = 'index.js';
|
|
78
|
-
const dest = root + '/dist/' + item.fileName;
|
|
79
|
-
if (item.type === 'asset') {
|
|
80
|
-
await fs.writeFile(dest, item.source);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const result = await vite.transformWithEsbuild(item.code, dest, {
|
|
84
|
-
minifyWhitespace: true,
|
|
85
|
-
charset: 'utf8',
|
|
86
|
-
});
|
|
87
|
-
await fs.writeFile(dest, result.code);
|
|
63
|
+
output: {
|
|
64
|
+
format: "iife"
|
|
88
65
|
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
plugins: [
|
|
69
|
+
react(),
|
|
70
|
+
tailwindcss()
|
|
71
|
+
],
|
|
72
|
+
define: {
|
|
73
|
+
"process.env.NODE_ENV": '"production"'
|
|
74
|
+
}
|
|
75
|
+
}, config));
|
|
76
|
+
for (const item of results[0].output) {
|
|
77
|
+
if (item.fileName === "index.mjs") item.fileName = "index.js";
|
|
78
|
+
const dest = root + "/dist/" + item.fileName;
|
|
79
|
+
if (item.type === "asset") {
|
|
80
|
+
await promises.writeFile(dest, item.source);
|
|
81
|
+
} else {
|
|
82
|
+
const result = await vite.transformWithEsbuild(item.code, dest, {
|
|
83
|
+
minifyWhitespace: true,
|
|
84
|
+
charset: "utf8"
|
|
85
|
+
});
|
|
86
|
+
await promises.writeFile(dest, result.code);
|
|
89
87
|
}
|
|
88
|
+
}
|
|
90
89
|
}
|
|
91
|
-
|
|
90
|
+
|
|
91
|
+
export { build2 as build };
|
package/lib/dev.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ViteDevServer } from
|
|
2
|
-
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface DevServerOptions {
|
|
3
4
|
/** 客户端代码根目录 */
|
|
4
5
|
root: string;
|
|
5
6
|
/** 基础路径,默认 /vite/ */
|
|
@@ -12,5 +13,6 @@ export interface DevServerOptions {
|
|
|
12
13
|
* @param options 开发服务器选项
|
|
13
14
|
* @returns Vite 开发服务器实例
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
declare function createViteDevServer(options: DevServerOptions): Promise<ViteDevServer>;
|
|
17
|
+
|
|
18
|
+
export { type DevServerOptions, createViteDevServer };
|
package/lib/dev.js
CHANGED
|
@@ -1,76 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
// src/dev.ts
|
|
5
|
+
async function createViteDevServer(options) {
|
|
6
|
+
const { root, base = "/vite/", enableTailwind = true } = options;
|
|
7
|
+
try {
|
|
8
|
+
const [
|
|
9
|
+
{ createServer, searchForWorkspaceRoot },
|
|
10
|
+
{ default: react },
|
|
11
|
+
{ default: tailwindcss }
|
|
12
|
+
] = await Promise.all([
|
|
13
|
+
import('vite'),
|
|
14
|
+
import('@vitejs/plugin-react'),
|
|
15
|
+
import('@tailwindcss/vite')
|
|
16
|
+
]);
|
|
13
17
|
const plugins = [react()];
|
|
14
18
|
if (enableTailwind) {
|
|
15
|
-
|
|
19
|
+
plugins.push(tailwindcss());
|
|
16
20
|
}
|
|
17
|
-
const clientPath = path.resolve(process.cwd(),
|
|
21
|
+
const clientPath = path.resolve(process.cwd(), "node_modules/@zhin.js/client/client");
|
|
18
22
|
if (!fs.existsSync(clientPath)) {
|
|
19
|
-
|
|
23
|
+
throw new Error("@zhin.js/client not found");
|
|
20
24
|
}
|
|
21
|
-
return await
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
25
|
+
return await createServer({
|
|
26
|
+
root,
|
|
27
|
+
base,
|
|
28
|
+
plugins: [react(), tailwindcss()],
|
|
29
|
+
server: {
|
|
30
|
+
middlewareMode: true,
|
|
31
|
+
allowedHosts: true,
|
|
32
|
+
fs: {
|
|
33
|
+
strict: false,
|
|
34
|
+
// 添加文件访问过滤,避免访问特殊文件
|
|
35
|
+
allow: [
|
|
36
|
+
// 允许访问的目录
|
|
37
|
+
root,
|
|
38
|
+
searchForWorkspaceRoot(root),
|
|
39
|
+
path.resolve(process.cwd(), "node_modules"),
|
|
40
|
+
path.resolve(process.cwd(), "client"),
|
|
41
|
+
path.resolve(process.cwd(), "src")
|
|
42
|
+
],
|
|
43
|
+
// 拒绝访问某些文件模式
|
|
44
|
+
deny: [
|
|
45
|
+
"**/.git/**",
|
|
46
|
+
"**/node_modules/.cache/**",
|
|
47
|
+
"**/*.socket",
|
|
48
|
+
"**/*.pipe",
|
|
49
|
+
"**/Dockerfile*",
|
|
50
|
+
"**/.env*"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
resolve: {
|
|
55
|
+
dedupe: [
|
|
56
|
+
"react",
|
|
57
|
+
"react-dom",
|
|
58
|
+
"clsx",
|
|
59
|
+
"tailwind-merge",
|
|
60
|
+
"@reduxjs/toolkit",
|
|
61
|
+
"react-router",
|
|
62
|
+
"react-redux",
|
|
63
|
+
"redux-persist"
|
|
64
|
+
],
|
|
65
|
+
alias: {
|
|
66
|
+
"@zhin.js/client": path.resolve(process.cwd(), "node_modules/@zhin.js/client/client"),
|
|
67
|
+
"@": path.resolve(root, "../client/src")
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
optimizeDeps: {
|
|
71
|
+
include: ["react", "react-dom"]
|
|
72
|
+
},
|
|
73
|
+
build: {
|
|
74
|
+
rollupOptions: {
|
|
75
|
+
input: root + "/index.html"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
74
78
|
});
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Failed to create Vite dev server. Make sure all development dependencies are installed: vite, @vitejs/plugin-react, @tailwindcss/vite. Run: pnpm install --include=optional
|
|
82
|
+
Original error: ${error.message}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
75
85
|
}
|
|
76
|
-
|
|
86
|
+
|
|
87
|
+
export { createViteDevServer };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as _zhin_js_http from '@zhin.js/http';
|
|
2
|
+
import { WebSocketServer } from 'ws';
|
|
3
|
+
import { ViteDevServer } from 'vite';
|
|
4
|
+
|
|
5
|
+
interface ConsoleConfig {
|
|
6
|
+
/** 是否启用控制台插件,默认 true */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** 是否延迟加载 Vite(开发模式),默认 true */
|
|
9
|
+
/** 端口号(继承自 http 配置) */
|
|
10
|
+
port?: number;
|
|
7
11
|
}
|
|
8
|
-
|
|
12
|
+
type WebEntry = string | {
|
|
9
13
|
production: string;
|
|
10
14
|
development: string;
|
|
11
15
|
};
|
|
12
|
-
|
|
16
|
+
interface WebServer {
|
|
13
17
|
vite?: ViteDevServer;
|
|
14
18
|
addEntry(entry: WebEntry): () => void;
|
|
15
19
|
entries: Record<string, string>;
|
|
16
20
|
ws: WebSocketServer;
|
|
17
|
-
}
|
|
18
|
-
|
|
21
|
+
}
|
|
22
|
+
declare module "@zhin.js/core" {
|
|
23
|
+
namespace Plugin {
|
|
24
|
+
interface Contexts {
|
|
25
|
+
web: WebServer;
|
|
26
|
+
router: _zhin_js_http.Router;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type { ConsoleConfig, WebEntry, WebServer };
|