@zenk-agent/plugin-preview 0.0.24 → 0.0.26
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/app/src/App.tsx +39 -78
- package/app/src/assets/preview-background.png +0 -0
- package/package.json +4 -4
package/app/src/App.tsx
CHANGED
|
@@ -1,98 +1,59 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
1
|
import { HostedPluginCard, RemotePluginCardHost, renderDefaultPluginModal } from '@zenk-agent/plugin-host'
|
|
3
2
|
import { decision, demoTheme, fetchFn, navigate, ontology } from './preview-host'
|
|
4
3
|
import { previewPluginDir, previewPlugins } from 'virtual:tool-plugin-preview'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
const [collapsed, setCollapsed] = useState(false)
|
|
5
|
+
const previewBackgroundUrl = new URL('./assets/preview-background.png', import.meta.url).href
|
|
8
6
|
|
|
7
|
+
function App() {
|
|
9
8
|
return (
|
|
10
|
-
<main className="relative min-h-screen bg-[
|
|
11
|
-
{/*
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<p className="mt-3 rounded-2xl border border-white/10 bg-white/[0.04] px-4 py-3 text-sm text-slate-300">
|
|
20
|
-
<span className="font-semibold text-white">Plugin dir</span>: {previewPluginDir}
|
|
21
|
-
</p>
|
|
22
|
-
</header>
|
|
23
|
-
|
|
9
|
+
<main className="relative min-h-screen overflow-hidden bg-[#020617] text-slate-50">
|
|
10
|
+
{/* Preview background */}
|
|
11
|
+
<section className="absolute inset-y-0 left-0 right-[400px] hidden lg:block" aria-label="背景图">
|
|
12
|
+
<div
|
|
13
|
+
className="h-full w-full bg-cover bg-center bg-no-repeat"
|
|
14
|
+
style={{
|
|
15
|
+
backgroundImage: `linear-gradient(90deg, rgba(2, 6, 23, 0.12), rgba(2, 6, 23, 0.04)), url(${previewBackgroundUrl})`,
|
|
16
|
+
}}
|
|
17
|
+
/>
|
|
24
18
|
{previewPlugins.length === 0 ? (
|
|
25
|
-
<
|
|
19
|
+
<div className="absolute left-8 top-8 max-w-xl rounded-2xl border border-amber-300/20 bg-slate-950/75 px-6 py-6 shadow-[0_24px_60px_rgba(2,8,23,0.32)] backdrop-blur">
|
|
26
20
|
<p className="text-lg font-semibold text-white">没有匹配到可预览的插件</p>
|
|
27
21
|
<p className="mt-2 text-sm leading-6 text-slate-300">
|
|
28
22
|
当前目录需要包含 `package.json`,并在 `zenk.publicPlugin` 或 `zenk.publicPlugins` 中声明 config 和 worker 导出。
|
|
29
23
|
</p>
|
|
30
|
-
|
|
24
|
+
<p className="mt-3 rounded-xl border border-white/10 bg-white/[0.04] px-4 py-3 text-sm text-slate-300">
|
|
25
|
+
<span className="font-semibold text-white">Plugin dir</span>: {previewPluginDir}
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
31
28
|
) : null}
|
|
32
|
-
</
|
|
29
|
+
</section>
|
|
33
30
|
|
|
34
31
|
{/* Right toolbar */}
|
|
35
|
-
<aside
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
<aside className="absolute inset-0 z-20 h-full w-full bg-white/[0.05] backdrop-blur-sm lg:inset-y-0 lg:left-auto lg:right-0 lg:w-[400px] lg:border-l lg:border-white/10">
|
|
33
|
+
{/* Toolbar content */}
|
|
34
|
+
<div className="h-full overflow-y-auto px-4 pb-6 pt-2 scrollbar-thin">
|
|
35
|
+
<div className="space-y-4">
|
|
36
|
+
{previewPlugins.map((plugin) => (
|
|
37
|
+
<HostedPluginCard
|
|
38
|
+
key={plugin.id}
|
|
39
|
+
plugin={plugin}
|
|
40
|
+
renderPluginContent={() => (
|
|
41
|
+
<RemotePluginCardHost
|
|
42
|
+
plugin={plugin}
|
|
43
|
+
navigate={navigate}
|
|
44
|
+
fetchFn={fetchFn}
|
|
45
|
+
getTheme={() => demoTheme}
|
|
46
|
+
storage={window.localStorage}
|
|
47
|
+
decision={decision}
|
|
48
|
+
ontology={ontology}
|
|
49
|
+
renderModal={renderDefaultPluginModal}
|
|
50
|
+
styleIsolation="shadow"
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
47
53
|
/>
|
|
48
|
-
|
|
49
|
-
{!collapsed ? <span className="text-[16px] font-medium text-white">插件预览</span> : null}
|
|
54
|
+
))}
|
|
50
55
|
</div>
|
|
51
|
-
<button
|
|
52
|
-
type="button"
|
|
53
|
-
onClick={() => setCollapsed((prev) => !prev)}
|
|
54
|
-
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-[#d7dbe4] transition hover:bg-white/10 hover:text-white"
|
|
55
|
-
aria-label={collapsed ? '展开工具栏' : '收起工具栏'}
|
|
56
|
-
title={collapsed ? '展开工具栏' : '收起工具栏'}
|
|
57
|
-
>
|
|
58
|
-
<svg className="h-4 w-4" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
59
|
-
<path
|
|
60
|
-
d={collapsed ? 'M6 3.5L10 8L6 12.5' : 'M10 3.5L6 8L10 12.5'}
|
|
61
|
-
stroke="currentColor"
|
|
62
|
-
strokeWidth="1.4"
|
|
63
|
-
strokeLinecap="round"
|
|
64
|
-
strokeLinejoin="round"
|
|
65
|
-
/>
|
|
66
|
-
</svg>
|
|
67
|
-
</button>
|
|
68
56
|
</div>
|
|
69
|
-
|
|
70
|
-
{/* Toolbar content */}
|
|
71
|
-
{!collapsed ? (
|
|
72
|
-
<div className="h-[calc(100%-54px)] overflow-y-auto px-4 py-4 pb-6 scrollbar-thin">
|
|
73
|
-
<div className="space-y-4">
|
|
74
|
-
{previewPlugins.map((plugin) => (
|
|
75
|
-
<HostedPluginCard
|
|
76
|
-
key={plugin.id}
|
|
77
|
-
plugin={plugin}
|
|
78
|
-
renderPluginContent={() => (
|
|
79
|
-
<RemotePluginCardHost
|
|
80
|
-
plugin={plugin}
|
|
81
|
-
navigate={navigate}
|
|
82
|
-
fetchFn={fetchFn}
|
|
83
|
-
getTheme={() => demoTheme}
|
|
84
|
-
storage={window.localStorage}
|
|
85
|
-
decision={decision}
|
|
86
|
-
ontology={ontology}
|
|
87
|
-
renderModal={renderDefaultPluginModal}
|
|
88
|
-
styleIsolation="shadow"
|
|
89
|
-
/>
|
|
90
|
-
)}
|
|
91
|
-
/>
|
|
92
|
-
))}
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
) : null}
|
|
96
57
|
</aside>
|
|
97
58
|
</main>
|
|
98
59
|
)
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenk-agent/plugin-preview",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.mjs",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"react-dom": "19.2.5",
|
|
30
30
|
"tailwindcss": "^3.4.17",
|
|
31
31
|
"vite": "^7.2.0",
|
|
32
|
-
"@zenk-agent/plugin-host": "0.0.
|
|
33
|
-
"@zenk-agent/plugin-sdk": "0.0.
|
|
34
|
-
"@zenk-agent/plugin-types": "0.0.
|
|
32
|
+
"@zenk-agent/plugin-host": "0.0.26",
|
|
33
|
+
"@zenk-agent/plugin-sdk": "0.0.26",
|
|
34
|
+
"@zenk-agent/plugin-types": "0.0.26"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^24.10.1",
|