@hyzyn/dsh-docker 0.1.0 → 0.3.0

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.
Files changed (3) hide show
  1. package/README.md +47 -9
  2. package/client.js +180 -21
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,7 +15,8 @@ DSH Web GUI 的 **Docker 容器面板**插件:侧边栏「容器」入口打
15
15
  | 主机指纹 | 本插件自持一份 `hostKeys`(TOFU),并**优先以 tty 已记录的指纹作种子**——同一主机不必在两处各确认一次 |
16
16
  | 执行通道 | 自持池化 SSH exec(`src/ssh-exec.ts`),与 tty 的 PTY 会话完全独立,互不占名额 |
17
17
  | 上下文入口 | tty ≥ 0.13.0 时可选消费其客户端服务 `ttyConnbar`,在 SSH 连接栏(SFTP 旁)插入「容器」按钮(**注册即显示**),目标在点击时按当前会话解析;tty 未装 / 版本过旧则静默跳过 |
18
- | 终端承载 | 交互式终端由 tty 承载(它才是 PTY 的所有者):tty ≥ 0.15 时经 `ttyTerminal.mount` **就地嵌入**到本面板底部的终端抽屉,tty ≥ 0.14 时退回「开标签 + 收面板」,都没有则复制命令。本插件不实现 PTY / xterm / 重连栈 |
18
+ | 面板承载 | tty ≥ 0.16 且终端面板正开着时,容器面板经 `ttyPanel.mountPane` **挂在终端右侧的 dock**(拖宽 / 折叠 / ✕ 由 tty 提供),终端继续可见可用;否则回退到自带 backdrop 的全屏模态。面板本身是同一份组件,只是宿主不同。dock 同一时刻只挂一个:本插件挂上去时会收掉前一个(例如 tty 自己的 SFTP),反过来 SFTP 遇到已被占用的挂载位会退回它自己的对话框 |
19
+ | 终端承载 | 交互式终端由 tty 承载(它才是 PTY 的所有者):tty ≥ 0.15 时经 `ttyTerminal.mount` **就地嵌入**到本面板底部的终端抽屉(dock 模式下改为在同面板**新开标签**,避免终端套面板套终端),tty ≥ 0.14 时退回「开标签 + 收面板」,都没有则复制命令。本插件不实现 PTY / xterm / 重连栈 |
19
20
  | 分工 | **交互式排障**(`docker exec -it`、容器内 shell、TUI)由 tty 承载(抽屉内嵌或标签);**只读巡检与 agent 自动化**用本插件自己的 exec 通道 |
20
21
 
21
22
  数据级复用、代码级不耦合:连接簿与指纹种子是「读同一份 settings」,连接栏按钮是
@@ -48,12 +49,23 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
48
49
  连接簿时按条目名匹配,否则按 `host:port` 匹配已解析的目标;**没配到目标也不会
49
50
  藏按钮**——面板会带一条提示告诉你会话主机(含连接簿名)该去设置卡片怎么配。
50
51
 
52
+ ![docker 面板挂进终端面板右侧 dock:终端保持可见可用](../../docs/dsh-plugin-kit-docker-dock.png)
53
+
54
+ 这条路径打开的面板**不会盖住终端**:tty ≥ 0.16 时它挂在终端面板右侧的 dock 里
55
+ (可拖宽、可折叠成窄条、✕ 收起),终端照常敲命令;tty 更旧或面板没开时才退回
56
+ 全屏模态。dock 模式下卡片「终端」按钮改为**在同一终端面板新开标签**执行
57
+ `docker exec -it`(面板已经在一个终端里了,再嵌一层没有意义);同时**不再渲染
58
+ 面板自己的头部**——标题与 ✕ 由侧栏标题栏承担,刷新与只读徽标并进工具条首行
59
+ (刷新中图标自己转,不再另挂 spinner),520px 窄栏里不会白留一条空行。
60
+
51
61
  面板内:
52
62
 
53
63
  - **目标选择**:面板先选目标(来自配置 `targets`,本机 / SSH);只配置了一个
54
64
  目标时默认选中它,agent 工具也可以省略 `target` 参数。
55
65
  - **容器列表**:名称 / 状态 / 健康态 / 镜像 / 端口映射 / compose 项目与服务 /
56
- 短 ID;支持按名称或镜像**搜索**、按状态**筛选**(运行中 / 已停止 / 全部)。
66
+ 短 ID;支持按名称或镜像**搜索**、按状态**筛选**(运行中 / 已停止 / 全部),
67
+ 以及**自动刷新**(按 `pollIntervalSec` 轮询,切到镜像页会暂停且不显示该开关——
68
+ 镜像变化慢,没必要每 5s 跑一次 `docker images`;切回容器页原设置照旧生效)。
57
69
  - **容器卡片**:与参考布局一致的「标签 + 值」行(镜像 / ID / 端口 / 创建 /
58
70
  compose,值等宽、可省略)+ 一排图标操作按钮,**按「查看 / 变更」两组用竖线分隔**:
59
71
 
@@ -69,8 +81,9 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
69
81
  统计。从卡片的日志 / 统计图标可直接落到对应标签页。
70
82
  - **日志视图(紧凑两行)**:第一行 = 返回 + 容器名 + 状态 + 目标主机 +
71
83
  `LINES`(尾部行数)/ `TIMESTAMPS` / `AUTO REFRESH`(开关 + 2/3/5/10s 间隔,
72
- 仅日志页轮询)+ 刷新 / 下载 / 关闭;第二行 = 标签页 + 可折叠的「过滤日志」
73
- (带匹配行数统计)。日志正文按级别着色(`[INFO]` 与 `|INFO` 两种常见前缀
84
+ 仅日志页轮询)+ 刷新 / 下载 / 关闭;第二行 = 标签页 + **常驻**的「过滤日志」
85
+ 输入框(右侧固定槽显示「N 行」/「N / M 行匹配」;有内容时框内浮出 ✕ 清空,
86
+ Esc 也能清空)。输入框宽度与位置恒定,输入 / 清空都不会挤动这一行。日志正文按级别着色(`[INFO]` 与 `|INFO` 两种常见前缀
74
87
  都能识别),时间戳压暗,过滤命中高亮;超过 2000 行只对尾部着色并提示。
75
88
  详情视图下不再叠加列表工具条与面板头,每屏只有一个刷新入口。
76
89
  - **概览**:`docker inspect` 的权威数据——状态与健康、退出码、重启次数与策略、
@@ -82,14 +95,21 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
82
95
  块 IO / PIDs),面板按 `pollIntervalSec` 轮询刷新。
83
96
  - **镜像**:`docker images` 列表(reference / 大小 / 创建时间 / 短 ID);
84
97
  `<none>:<none>` 的 dangling 镜像带 `dangling` 标记。**只有列表,没有删除 /
85
- 拉取 / 构建**。
98
+ 拉取 / 构建**。搜索框与「N / M 个镜像」计数**固定在工具条里**(不随列表滚走),
99
+ 表头列名在表体内吸顶——镜像多的时候滚到哪都还知道自己在看什么列。
86
100
  - **一次性 exec**:`allowExec` 开启后可输入命令,等价
87
101
  `docker exec <容器> sh -c "<命令>"`,返回退出码与 stdout/stderr(无 TTY)。
88
102
  - **交互式终端(卡片第一个图标)**:跑 `docker exec -it '<容器>' sh`。按 tty 能力
89
103
  三级降级——
104
+ ![exec 终端抽屉 + 日志页共存:折叠只藏起来、会话保持运行](../../docs/dsh-plugin-kit-docker-exec.png)
105
+
90
106
  1. **就地嵌入(tty ≥ 0.15,推荐)**:在面板底部开一个**终端抽屉**,由 tty 的
91
107
  `ttyTerminal.mount` 把终端挂进来。面板不收起,看着容器日志直接进容器敲命令,
92
- 上下文不断;收起抽屉即结束会话。
108
+ 上下文不断。抽屉会挤占正文高度,所以它可以让位而不结束会话:
109
+ **折叠**(标题栏右侧的箭头,或双击顶边)只把抽屉压成一条标题栏,会话照旧跑着;
110
+ **拖拽顶边**可调高度(上限为面板高度的 75%)。真正结束会话的动作只有两个——
111
+ 抽屉上的 ✕,以及关闭面板;有活动会话时关闭面板会先弹确认,避免点 backdrop
112
+ 空白处时误杀一个正在排障的容器 shell(全局终端面板也是「点空白 = 最小化」,同一取向)。
93
113
  2. **借 tty 弹窗开标签(tty ≥ 0.14)**:tty 新开一个标签执行同一命令,随后收起本
94
114
  面板(本面板 z-index 更高,不收起用户只会觉得「点了没反应」)。
95
115
  3. **复制命令**:未装 tty / 版本过旧 / 内联目标用了 key·password 认证(浏览器端
@@ -123,6 +143,8 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
123
143
 
124
144
  ## 配置(设置 → 插件 → Docker 容器面板,保存即热生效)
125
145
 
146
+ ![设置卡片:目标 CRUD、能力开关与参数,保存即热生效](../../docs/dsh-plugin-kit-docker-setting.png)
147
+
126
148
  配置落在 settings 命名空间 `docker`,即 `~/.dsh/settings.yaml` 的 `docker:`
127
149
  段(`$DSH_HOME/settings.yaml`;DSH 的 settings 文件由宿主 `dsh-settings-file`
128
150
  提供)。插件行里的 composition 配置作为 schema `base` 打底,settings 层覆盖
@@ -290,10 +312,12 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
290
312
  ├─ 侧边栏「容器」入口 → 面板:目标选择 / 容器列表(搜索 + 状态筛选)/
291
313
  │ 容器卡片(动作条分两组:查看=终端/日志/统计 | 变更=启停/重启/删除)/ 镜像列表 / 一次性 exec
292
314
  │ └─ 终端抽屉:tty ≥ 0.15 时经 ttyTerminal.mount 就地嵌入 tty 的终端
293
- │ (面板不收起;关抽屉即 dispose,tty 那边结束会话并拆 DOM)
315
+ │ (面板不收起;折叠/拖拽只改尺寸,会话不中断;✕ 或关面板才 dispose,
316
+ │ 有活动会话时关面板先确认 → tty 那边结束会话并拆 DOM)
294
317
  │ └─ fetch → /api/dsh-docker/*(loopback 围栏)
295
318
  ├─ 可选消费 tty 的 ttyConnbar 服务 → SSH 连接栏「容器」按钮
296
319
  │ (按 book 名 / host:port 匹配已配置目标,命中才出现)
320
+ ├─ 可选消费 tty 的 ttyPanel 服务(0.16.0)→ 终端面板开着时挂右侧 dock
297
321
  └─ 可选消费 tty 的 ttyTerminal 服务 → 卡片「终端」按钮直接开 docker exec 标签
298
322
  (tty 不可用 / 凭证不在浏览器时退回复制命令)
299
323
 
@@ -340,7 +364,7 @@ stats 解析(百分比 / 内存 / IO / PIDs)、size 与 percent 的异常输
340
364
  工具不注册、打开开关后(含 `settings/updated` 热更新路径)立即解锁、非 loopback
341
365
  403、容器名注入尝试被白名单拒绝、省略 `target` 的回落与多目标报错。
342
366
 
343
- `scripts/client-smoke.mjs`(8 项)在 Node 里用最小 DOM / React 桩执行构建产物
367
+ `scripts/client-smoke.mjs`(11 项)在 Node 里用最小 DOM / React 桩执行构建产物
344
368
  `client.js`:验证注册 id 与 factory 形状、只 require 平台 seed 提供的模块
345
369
  (`react` / `react/jsx-runtime` / `react-dom/client`)、`apply` 注册的 settings
346
370
  卡片 key 等于命名空间 `docker`、找不到宿主侧边栏时安静降级且卸载可重复调用,ttyConnbar 集成的四条路径(连接簿名命中 / host:port 命中 / 未配置主机不加按钮 / tty 未安装静默跳过),以及侧边栏折叠态(`data-sidebar-collapsed`)隐藏入口标签的样式规则。
@@ -362,7 +386,21 @@ stats 解析(百分比 / 内存 / IO / PIDs)、size 与 percent 的异常输
362
386
  6. **`allowExec` 打开后**:`ls -la /app` 之类命令返回 stdout 与退出码;把命令
363
387
  换成 `sleep 60`(`timeoutSec` 调小)应被中断并报超时;`command` 超过 8000
364
388
  字符被拒绝。
389
+ 7. **exec 抽屉与正文共存**(tty ≥ 0.15):卡片「终端」开抽屉后切到日志 / 统计 /
390
+ 另一台容器的详情,抽屉与终端会话都必须活着;**折叠**(箭头或双击顶边)把抽屉
391
+ 压成一条标题栏、会话继续跑(展开即回原样);**拖拽顶边**能调高度且不超过面板
392
+ 的 75%;此时点 backdrop 空白处或面板 ✕ 应弹「结束容器终端会话」确认,取消后
393
+ 会话仍在,确认才结束(tty 侧收到 kill)。
394
+ 离线回归:`node packages/tty/scripts/preview.mjs docker-exec-logs`
395
+ (无头 Chrome 跑真实客户端:抽屉 + 日志页 + 折叠展开,断言会话未被结束)。
396
+ 8. **从连接栏进容器面板(dock 模式,需 tty ≥ 0.16)**:tty 面板里开一个 SSH 标签 →
397
+ 连接栏「容器」→ 容器面板应挂在**终端右侧**(不是全屏弹窗),终端仍可输入;
398
+ 拖左边缘可调宽(上限面板宽 72%)、标题栏箭头折叠成窄条(终端拿回全部宽度、
399
+ 容器面板不卸载)、✕ 收起面板且 SSH 标签不受影响;此时点卡片「终端」应在同一
400
+ 终端面板**新开一个 `<容器> · exec` 标签**,而不是再嵌一个终端抽屉。
401
+ 离线回归:`node packages/tty/scripts/preview.mjs docker-dock`
402
+ (断言 docked / 无 backdrop / 折叠后终端变宽 / 容器面板存活)。
365
403
 
366
404
  ## 版本 / 许可证
367
405
 
368
- `@hyzyn/dsh-docker` 0.1.0 · [Apache License 2.0](../../LICENSE)
406
+ `@hyzyn/dsh-docker` 0.3.0 · [Apache License 2.0](../../LICENSE)
package/client.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var He=`/* eslint-disable */
1
+ "use strict";(()=>{var Xe=`/* eslint-disable */
2
2
  /**
3
3
  * @hyzyn/dsh-docker \u2014 \u9762\u677F\u6837\u5F0F\u8868\u3002
4
4
  *
@@ -34,6 +34,8 @@
34
34
  --dk-gap-md: 8px;
35
35
  --dk-gap-lg: 12px;
36
36
  --dk-gap-xl: 16px;
37
+ /* \u8BBE\u7F6E\u5361\u7247\u6807\u9898\u884C\u5185\u8FB9\u8DDD\uFF1A\u5BF9\u9F50 DSH \u5185\u7F6E\u5361\u7247 / \u5176\u4ED6\u63D2\u4EF6\u5361\u7247\uFF08pM_pluginCard\u3001tt_card\uFF09 */
38
+ --dk-pad-cardHead: 14px 16px;
37
39
  --dk-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
38
40
  --dk-ease: cubic-bezier(.2, .8, .2, 1);
39
41
  --dk-dur: .16s;
@@ -47,6 +49,7 @@
47
49
  --dk-hover-solid: var(--dsw-alias-interactive-bg-hover-solid, rgba(127, 127, 127, .16));
48
50
  --dk-label: var(--dsw-alias-label-primary, #1a1a1a);
49
51
  --dk-label-2: var(--dsw-alias-label-secondary, #555);
52
+ --dk-label-dimmed: var(--dsw-alias-label-dimmed, var(--dk-label-3));
50
53
  --dk-label-3: var(--dsw-alias-label-tertiary, #888);
51
54
  --dk-surface: var(--dsw-alias-bg-base, #fff);
52
55
  --dk-surface-solid: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-base, #fff));
@@ -207,8 +210,22 @@
207
210
  line-height: 1.5;
208
211
  }
209
212
 
213
+ /*
214
+ * dock \u6A21\u5F0F\uFF080.3.0\uFF09\uFF1A\u9762\u677F\u957F\u5728 tty \u9762\u677F\u7684\u53F3\u4FA7\u6302\u8F7D\u4F4D\u91CC\uFF0C\u6491\u6EE1\u5BBF\u4E3B\u5373\u53EF\u2014\u2014
215
+ * \u5916\u6846 / \u5706\u89D2 / \u9634\u5F71 / \u6700\u5C0F\u9AD8\u5EA6\u90FD\u662F\u300C\u72EC\u7ACB\u5F39\u7A97\u300D\u7684\u88C5\u9970\uFF0C\u6302\u5728\u522B\u4EBA\u680F\u91CC\u8981\u5168\u53BB\u6389\u3002
216
+ */
217
+ .dk_panelDock {
218
+ width: 100%;
219
+ height: 100%;
220
+ min-height: 0;
221
+ border: none;
222
+ border-radius: 0;
223
+ box-shadow: none;
224
+ }
225
+
210
226
  /* ---- \u4EA4\u4E92\u5F0F\u7EC8\u7AEF\u62BD\u5C49\uFF08ttyTerminal.mount \u5C31\u5730\u5D4C\u5165\uFF0C0.15.0\uFF09 ---- */
211
227
  .dk_drawer {
228
+ position: relative; /* \u9876\u90E8\u62D6\u62FD\u6761\u7684\u5B9A\u4F4D\u57FA\u51C6 */
212
229
  flex: 0 0 auto;
213
230
  display: flex;
214
231
  flex-direction: column;
@@ -219,6 +236,34 @@
219
236
  animation: dk_drawerIn var(--dk-dur) var(--dk-ease);
220
237
  }
221
238
 
239
+ /* \u62D6\u62FD\u6761\uFF1A\u8D34\u7740\u62BD\u5C49\u4E0A\u6CBF\uFF0C\u9F20\u6807\u8FDB\u5165\u624D\u663E\u5F62\uFF08\u5E38\u6001\u4E0D\u6253\u6270\u7EC8\u7AEF\u5185\u5BB9\uFF09 */
240
+ .dk_drawerResize {
241
+ position: absolute;
242
+ top: 0;
243
+ left: 0;
244
+ right: 0;
245
+ z-index: 2;
246
+ height: 5px;
247
+ cursor: ns-resize;
248
+ }
249
+
250
+ .dk_drawerResize:hover { background: color-mix(in srgb, var(--dk-accent) 55%, transparent); }
251
+
252
+ /*
253
+ * \u6298\u53E0\uFF1A\u53EA\u628A\u62BD\u5C49\u538B\u5230\u6807\u9898\u680F\u9AD8\u5EA6\uFF08\u6B63\u6587\u9690\u85CF\uFF09\uFF0C**\u4E0D\u5378\u8F7D**\u6302\u8F7D\u70B9\u2014\u2014tty \u90A3\u8FB9\u7684
254
+ * xterm \u4E0E PTY \u4F1A\u8BDD\u7167\u65E7\u8DD1\u7740\uFF0C\u5C55\u5F00\u5373\u539F\u6837\u56DE\u6765\u3002
255
+ */
256
+ .dk_drawer[data-collapsed="1"] {
257
+ height: auto; /* \u53EA\u5269\u6807\u9898\u680F\uFF08\u6B63\u6587 display:none\uFF09\uFF0C\u522B\u5199\u6B7B\u9AD8\u5EA6\uFF1Aheader \u662F\u5185\u5BB9\u76D2 + \u5185\u8FB9\u8DDD */
258
+ min-height: 0;
259
+ }
260
+
261
+ .dk_drawer[data-collapsed="1"] .dk_drawerResize,
262
+ .dk_drawer[data-collapsed="1"] .dk_drawerBody { display: none; }
263
+
264
+ .dk_drawerFold .dk_iconGlyph { transition: transform var(--dk-dur) var(--dk-ease); }
265
+ .dk_drawer[data-collapsed="1"] .dk_drawerFold .dk_iconGlyph { transform: rotate(180deg); }
266
+
222
267
  @keyframes dk_drawerIn {
223
268
  from { opacity: 0; transform: translateY(8px); }
224
269
  to { opacity: 1; transform: none; }
@@ -319,6 +364,13 @@
319
364
  .dk_iconBtn:focus-visible { outline: none; box-shadow: var(--dk-ring); }
320
365
  .dk_iconBtn:disabled { opacity: .45; cursor: not-allowed; }
321
366
 
367
+ /*
368
+ * \u5237\u65B0\u4E2D\u7684\u56FE\u6807\u81EA\u5DF1\u8F6C\uFF08data-spin \u7531\u5404\u5904\u7684 refresh \u6309\u94AE\u6309 loading \u6253\uFF09\uFF1A
369
+ * \u6BD4\u5728\u6309\u94AE\u65C1\u8FB9\u53E6\u6302\u4E00\u4E2A\u72EC\u7ACB spinner \u76F4\u89C2\u2014\u2014\u7528\u6237\u521A\u70B9\u7684\u5C31\u662F\u8FD9\u9897\u3002
370
+ */
371
+ .dk_iconBtn[data-spin="1"] { color: var(--dk-accent); }
372
+ .dk_iconBtn[data-spin="1"] > span { animation: dk_spin .8s linear infinite; }
373
+
322
374
  /* ============================ \u5DE5\u5177\u680F ============================ */
323
375
 
324
376
  .dk_toolbar {
@@ -354,6 +406,9 @@
354
406
 
355
407
  .dk_search { flex: 1 1 200px; min-width: 160px; }
356
408
 
409
+ /* \u5DE5\u5177\u6761\u91CC\u7684\u7ED3\u679C\u8BA1\u6570\uFF08\u955C\u50CF\uFF1A23 / 23 \u4E2A\u955C\u50CF\uFF09\uFF1A\u522B\u88AB\u538B\u7F29\uFF0C\u6570\u5B57\u7B49\u5BBD */
410
+ .dk_searchCount { flex: none; font-variant-numeric: tabular-nums; }
411
+
357
412
  .dk_seg {
358
413
  display: inline-flex;
359
414
  padding: 2px;
@@ -639,12 +694,14 @@
639
694
  }
640
695
 
641
696
  .dk_filterBar {
697
+ position: relative;
642
698
  display: flex;
643
699
  align-items: center;
644
700
  gap: var(--dk-gap-md);
645
701
  flex: 1 1 auto;
646
702
  min-width: 0;
647
- padding: var(--dk-gap-xs) 0;
703
+ /* \u53F3\u4FA7\u7ED9\u8BA1\u6570\u7559\u56FA\u5B9A\u69FD\uFF0892px \u2248 4 \u4F4D\u6570 + \u300C\u884C\u5339\u914D\u300D\uFF09\uFF0C\u8F93\u5165\u6846\u5BBD\u5EA6\u56E0\u6B64\u6052\u5B9A */
704
+ padding: var(--dk-gap-xs) 92px var(--dk-gap-xs) 0;
648
705
  }
649
706
 
650
707
  .dk_tab {
@@ -716,24 +773,53 @@
716
773
  }
717
774
 
718
775
 
719
- .dk_filterToggle {
776
+ /* \u8FC7\u6EE4\u8F93\u5165\u6846\u5E38\u9A7B\uFF1B\u6E05\u7A7A\u6309\u94AE\u6D6E\u5728\u6846\u5185\u53F3\u4FA7\uFF08\u7EDD\u5BF9\u5B9A\u4F4D \u2192 \u51FA\u73B0/\u6D88\u5931\u90FD\u4E0D\u6324\u52A8\u5E03\u5C40\uFF09 */
777
+ .dk_filterWrap {
778
+ position: relative;
779
+ display: flex;
780
+ flex: 1 1 200px;
781
+ min-width: 0;
782
+ }
783
+
784
+ .dk_filterInput {
785
+ flex: 1 1 auto;
786
+ height: var(--dk-h-md);
787
+ min-width: 0;
788
+ /* \u5E38\u9A7B\u53F3\u4FA7\u5185\u8FB9\u8DDD\u7ED9\u6E05\u9664\u6309\u94AE\u7559\u4F4D\uFF1A\u5185\u8FB9\u8DDD\u8DDF\u7740\u5185\u5BB9\u53D8\u4F1A\u6539 flex \u57FA\u51C6\uFF0C\u53CD\u800C\u6324\u52A8\u8F93\u5165\u6846 */
789
+ padding-right: 28px;
790
+ }
791
+
792
+ .dk_filterClear {
793
+ position: absolute;
794
+ top: 50%;
795
+ right: 4px;
796
+ transform: translateY(-50%);
720
797
  display: inline-flex;
721
798
  align-items: center;
722
- gap: var(--dk-gap-xs);
799
+ justify-content: center;
800
+ width: 20px;
801
+ height: 20px;
723
802
  padding: 0;
724
803
  border: none;
804
+ border-radius: var(--dk-r-sm);
725
805
  background: transparent;
726
- color: var(--dk-label-2);
727
- font-size: 12px;
728
- font-family: inherit;
806
+ color: var(--dk-label-3);
729
807
  cursor: pointer;
730
808
  }
731
809
 
732
- .dk_filterToggle:hover { color: var(--dk-label); }
733
- .dk_caret { display: inline-flex; transform: rotate(-90deg); transition: transform var(--dk-dur) var(--dk-ease); }
734
- .dk_filterToggle[data-on="1"] .dk_caret { transform: none; }
735
- .dk_filterInput { flex: 1 1 200px; height: var(--dk-h-md); min-width: 0; }
736
- .dk_filterCount { flex: none; color: var(--dk-label-3); font-size: 11px; font-variant-numeric: tabular-nums; }
810
+ .dk_filterClear:hover { background: var(--dk-hover); color: var(--dk-label); }
811
+ .dk_filterClear:focus-visible { outline: none; box-shadow: var(--dk-ring); }
812
+ /* \u8BA1\u6570\uFF08\u300C201 \u884C\u300D/\u300C1 / 201 \u884C\u5339\u914D\u300D\uFF09\u53F3\u5BF9\u9F50\u5728\u56FA\u5B9A\u69FD\u91CC\uFF1A\u6587\u6848\u53D8\u957F\u4E5F\u4E0D\u4F1A\u628A\u8F93\u5165\u6846\u6324\u52A8 */
813
+ .dk_filterCount {
814
+ position: absolute;
815
+ top: 50%;
816
+ right: 0;
817
+ transform: translateY(-50%);
818
+ white-space: nowrap;
819
+ color: var(--dk-label-3);
820
+ font-size: 11px;
821
+ font-variant-numeric: tabular-nums;
822
+ }
737
823
 
738
824
  .dk_logBody {
739
825
  flex: 1 1 auto;
@@ -863,6 +949,36 @@
863
949
 
864
950
  .dk_tableWrap { overflow: auto; }
865
951
 
952
+ /*
953
+ * \u955C\u50CF\u9875\uFF1A\u641C\u7D22\u6846\u5DF2\u7ECF\u5728\u5DE5\u5177\u6761\uFF08\u56FA\u5B9A\u533A\uFF09\uFF0C\u8FD9\u91CC\u518D\u8BA9\u8868\u4F53\u81EA\u5DF1\u6EDA\u3001\u8868\u5934\u9489\u4F4F\u2014\u2014
954
+ * \u957F\u955C\u50CF\u5217\u8868\u6EDA\u5230\u5E95\u65F6\u5217\u540D\uFF08\u955C\u50CF / \u5927\u5C0F / \u521B\u5EFA / ID\uFF09\u4ECD\u7136\u770B\u5F97\u89C1\u3002
955
+ */
956
+ .dk_mainImages {
957
+ display: flex;
958
+ flex-direction: column;
959
+ /* auto \u800C\u4E0D\u662F hidden\uFF1A\u6A2A\u5E45 / \u7A7A\u6001\u5728\u77EE\u9762\u677F\u91CC\u4ECD\u53EF\u6EDA\uFF0C\u4E0D\u4F1A\u88AB\u88C1\u6389 */
960
+ overflow: auto;
961
+ }
962
+
963
+ .dk_imagesView {
964
+ display: flex;
965
+ flex-direction: column;
966
+ flex: 1 1 auto;
967
+ min-height: 0;
968
+ }
969
+
970
+ .dk_mainImages .dk_tableWrap {
971
+ flex: 1 1 auto;
972
+ min-height: 0;
973
+ }
974
+
975
+ .dk_images thead th {
976
+ position: sticky;
977
+ top: 0;
978
+ z-index: 1;
979
+ background: var(--dk-surface-solid);
980
+ }
981
+
866
982
  .dk_images {
867
983
  width: 100%;
868
984
  border-collapse: collapse;
@@ -953,14 +1069,57 @@
953
1069
 
954
1070
  /* ============================ \u8BBE\u7F6E\u5361\u7247 ============================ */
955
1071
 
956
- .dk_cardBody {
1072
+ /*
1073
+ * \u5916\u6846\u4E0E DSH \u5185\u7F6E\u5361\u7247 / \u5176\u4ED6\u63D2\u4EF6\u5361\u7247\uFF08pM_pluginCard\u3001tt_card\uFF09\u540C\u4E00\u5957\u5EA6\u91CF\uFF1A
1074
+ * border-l2 + bg-layer-3\uFF08\u5C55\u5F00\u65F6 layer-2\uFF09\u300112px \u5706\u89D2\u3001\u6807\u9898\u884C 14/16\u3001
1075
+ * \u6807\u9898 14px/600\u3001\u63CF\u8FF0 12px/label-secondary\u3002
1076
+ * \u4E4B\u524D\u662F\u5185\u8054\u7684 10px \u5706\u89D2 + \u66F4\u6D45\u7684\u8FB9\u6846 + 13px \u6807\u9898\uFF0C\u5728\u8BBE\u7F6E\u5217\u8868\u91CC\u4E00\u773C\u5C31\u662F\u300C\u53E6\u4E00\u5957\u300D\u3002
1077
+ */
1078
+ .dk_settingsCard {
1079
+ list-style: none;
1080
+ border: 1px solid var(--dk-border-strong);
1081
+ border-radius: var(--dk-r-xl);
1082
+ background: var(--dk-surface-3);
1083
+ transition: border-color var(--dk-dur) var(--dk-ease), background var(--dk-dur) var(--dk-ease);
1084
+ }
1085
+
1086
+ .dk_settingsCard:hover { border-color: var(--dk-label-dimmed); }
1087
+ .dk_settingsCardOpen { background: var(--dk-surface-2); border-color: var(--dk-label-dimmed); }
1088
+
1089
+ .dk_settingsHead {
1090
+ display: flex;
1091
+ align-items: center;
1092
+ gap: var(--dk-gap-lg);
1093
+ width: 100%;
1094
+ padding: var(--dk-pad-cardHead);
1095
+ border: 0;
1096
+ border-radius: var(--dk-r-xl);
1097
+ background: transparent;
1098
+ color: inherit;
1099
+ font: inherit;
1100
+ text-align: left;
1101
+ cursor: pointer;
1102
+ }
1103
+
1104
+ .dk_settingsHead:focus-visible { outline: none; box-shadow: var(--dk-ring); }
1105
+ .dk_settingsHeadText { display: flex; flex-direction: column; gap: var(--dk-gap-xs); flex: 1; min-width: 0; }
1106
+ .dk_settingsName { color: var(--dk-label); font-size: 14px; font-weight: 600; line-height: 1.4; }
1107
+ .dk_settingsDesc { color: var(--dk-label-2); font-size: 12px; line-height: 1.5; }
1108
+
1109
+ .dk_settingsChevron {
1110
+ flex: none;
1111
+ display: inline-flex;
1112
+ color: var(--dk-label-3);
1113
+ transition: transform var(--dk-dur) var(--dk-ease);
1114
+ }
1115
+
1116
+ .dk_settingsCardOpen .dk_settingsChevron { transform: rotate(180deg); }
1117
+
1118
+ .dk_settingsBody {
957
1119
  display: flex;
958
1120
  flex-direction: column;
959
1121
  gap: var(--dk-gap-lg);
960
- padding: var(--dk-gap-lg);
961
- border: 1px solid var(--dk-border);
962
- border-radius: var(--dk-r-lg);
963
- background: var(--dk-surface-solid);
1122
+ padding: 2px var(--dk-gap-xl) var(--dk-gap-xl);
964
1123
  color: var(--dk-label);
965
1124
  font-size: 13px;
966
1125
  }
@@ -1043,8 +1202,8 @@
1043
1202
  .dk_targetRow { grid-template-columns: 1fr 1fr; }
1044
1203
  .dk_cardRow { grid-template-columns: 40px 1fr; }
1045
1204
  }
1046
- `;var ot="/api/dsh-docker",Pe="dsh-docker-style";function Se(){if(document.getElementById(Pe)!==null)return;let l=document.createElement("style");l.id=Pe,l.textContent=He,document.head.appendChild(l)}async function F(l,m){let e=await fetch(ot+l,{...m,headers:{"content-type":"application/json",...m?.headers??{}}}),d=null;try{d=await e.json()}catch{}if(!e.ok){let O=d!==null&&typeof d.error=="string"?d.error:`HTTP ${String(e.status)}`;throw new Error(O)}if(d!==null&&d.ok===!1)throw new Error(typeof d.error=="string"?d.error:"\u8BF7\u6C42\u5931\u8D25");return d}var R={config:()=>F("/config"),saveConfig:l=>F("/config",{method:"POST",body:JSON.stringify(l)}),targets:()=>F("/targets"),probe:l=>F("/probe",{method:"POST",body:JSON.stringify({target:l})}),containers:(l,m)=>F("/containers",{method:"POST",body:JSON.stringify({target:l,all:m})}),inspect:(l,m)=>F("/inspect",{method:"POST",body:JSON.stringify({target:l,id:m})}),logs:(l,m,e)=>F("/logs",{method:"POST",body:JSON.stringify({target:l,id:m,...e})}),stats:(l,m)=>F("/stats",{method:"POST",body:JSON.stringify({target:l,ids:m})}),images:l=>F("/images",{method:"POST",body:JSON.stringify({target:l})}),action:(l,m,e)=>F("/action",{method:"POST",body:JSON.stringify({target:l,action:m,id:e})}),exec:(l,m,e,d)=>F("/exec",{method:"POST",body:JSON.stringify({target:l,id:m,command:e,timeoutSec:d})})};function lt(l){return l==null||!Number.isFinite(l)?"\u2014":l.toFixed(l>=10?1:2)+"%"}function it(l){return l.hostPort===void 0?String(l.containerPort)+"/"+l.protocol:String(l.hostPort)+"\u2192"+String(l.containerPort)+"/"+l.protocol}function ze(l){if(!Array.isArray(l)||l.length===0)return"\u65E0\u7AEF\u53E3\u6620\u5C04";let m=new Set,e=[];for(let d of l){let O=it(d);m.has(O)||(m.add(O),e.push(O))}return e.join(" ")}function st(l){let m=/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/.exec(l);return m===null?l:m[1]+" "+m[2]}function ct(l){return{running:"\u8FD0\u884C\u4E2D",exited:"\u5DF2\u505C\u6B62",created:"\u5DF2\u521B\u5EFA",paused:"\u5DF2\u6682\u505C",restarting:"\u91CD\u542F\u4E2D",dead:"dead",removing:"\u5220\u9664\u4E2D",unknown:"\u672A\u77E5"}[l]??l}function kt(l,m){let e=new Blob([m],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(e),O=document.createElement("a");O.href=d,O.download=l,O.click(),setTimeout(()=>URL.revokeObjectURL(d),1e3)}function je(l){return"docker exec -it '"+String(l).replaceAll("'","'\\''")+"' sh"}var re=null,ie=null,Ie=[],Ue=0;function Te(l){l!==null&&typeof l=="object"&&(ie=l),Ue=Date.now()}async function ve(){try{let[l,m]=await Promise.all([R.config(),R.targets()]);return ie=l.config,Ie=m.targets??[],Ue=Date.now(),!0}catch(l){return console.warn("[dsh-docker] \u76EE\u6807\u7F13\u5B58\u5237\u65B0\u5931\u8D25\uFF1A"+(l instanceof Error?l.message:String(l))),!1}}async function ut(l,m){let e=Oe(l,m);return e!==void 0?e:(await ve(),Oe(l,m))}function Oe(l,m){let e=ie!==null&&Array.isArray(ie.targets)?ie.targets:[];if(typeof m=="string"&&m!==""){let C=e.find(K=>K.kind==="ssh"&&K.book===m);if(C!==void 0)return C.name}let d=typeof l?.host=="string"?l.host:"";if(d==="")return;let O=Number(l?.port),h=Number.isInteger(O)&&O>0?O:22;for(let C of Ie){if(C.kind!=="ssh"||typeof C.label!="string")continue;let K=/^([^@]+)@(.+?)(?::(\d+))?$/.exec(C.label);if(K!==null&&K[2]===d&&Number(K[3]??22)===h)return C.name}}var Fe='<svg viewBox="0 0 16 16" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',gt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Le='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Be='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M4.5 4.5l7 7"/><path d="M11.5 4.5l-7 7"/></svg>',ht='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3.4l7.4 4.6L5 12.6z"/></svg>',pt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4.2" y="4.2" width="7.6" height="7.6" rx="1.2"/></svg>',mt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',vt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4.6h10"/><path d="M6.2 4.6V3.4a.8.8 0 0 1 .8-.8h2a.8.8 0 0 1 .8.8v1.2"/><path d="M4.6 4.6l.6 8a.9.9 0 0 0 .9.8h3.8a.9.9 0 0 0 .9-.8l.6-8"/></svg>';var ft='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v7.2"/><path d="M5 7.4L8 10.4l3-3"/><path d="M3.4 12.8h9.2"/></svg>',bt='<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.6l5.8 10.4H2.2z"/><path d="M8 6.4v3.2"/><path d="M8 11.6h.01"/></svg>',Ke='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5l3.5 3L3 11"/><path d="M8.5 11H13"/></svg>',_t='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3 4.5h10"/><path d="M3 8h10"/><path d="M3 11.5h6"/></svg>',xt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3.5 12.5v-4"/><path d="M7 12.5v-8"/><path d="M10.5 12.5v-5"/><path d="M13 12.5v-2"/></svg>',wt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.5 8h-9"/><path d="M7 4.5L3.5 8 7 11.5"/></svg>',Ve='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6.5L8 10.5l4-4"/></svg>';window.__ModuleLoader__.load({id:"@hyzyn/dsh-docker",factory:l=>{let m=l("react"),{jsx:e,jsxs:d}=l("react/jsx-runtime"),{createRoot:O}=l("react-dom/client"),{useState:h,useEffect:C,useRef:K,useCallback:de}=m;function Ge(t,n,i){if(n==="")return t;let k=t.toLowerCase(),_=n.toLowerCase(),r=[],v=0,x=k.indexOf(_),w=0;for(;x>=0&&w<500;)x>v&&r.push(t.slice(v,x)),r.push(e("mark",{children:t.slice(x,x+_.length)},i+"-m"+String(w))),v=x+_.length,w+=1,x=k.indexOf(_,v);return v<t.length&&r.push(t.slice(v)),r}function Ee(t){let n=t.health==="unhealthy"?"unhealthy":t.state,i=t.health==="unhealthy"?"\u4E0D\u5065\u5EB7":ct(t.state);return e("span",{className:"dk_badge","data-state":n,title:t.status??"",children:i})}function V(t){return d("div",{className:"dk_banner","data-kind":t.kind??"error",children:[e("span",{className:"dk_bannerIcon",dangerouslySetInnerHTML:{__html:bt}},"icon"),d("div",{className:"dk_bannerBody",children:[e("div",{children:t.title}),t.hint===void 0?null:e("div",{className:"dk_hint",style:{marginTop:4},children:t.hint})]},"body"),t.action===void 0?null:e("div",{className:"dk_bannerAction",children:t.action},"action")]})}function Me(t){return d("div",{className:"dk_confirmBackdrop",onMouseDown:n=>n.stopPropagation(),children:[d("div",{className:"dk_confirm",children:[e("div",{className:"dk_confirmTitle",children:t.title}),e("div",{className:"dk_confirmText",children:t.text}),d("div",{className:"dk_confirmActions",children:[e("button",{type:"button",className:"dk_btn",onClick:t.onCancel,children:"\u53D6\u6D88"}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:t.onConfirm,children:t.confirmLabel})]})]})]})}function yt(t){return e("button",{type:"button",className:"dk_btn"+(t.danger===!0?" dk_btnDanger":""),disabled:t.disabled===!0,title:t.title??"",onClick:n=>{n.stopPropagation(),t.onClick()},children:t.children})}function se(t){return d("div",{className:"dk_cardRow",children:[e("span",{className:"dk_cardLabel",children:t.label}),e("span",{className:"dk_cardValue",title:String(t.value),children:t.value})]})}function U(t){let n=t.disabled===!0;return e("button",{type:"button",className:"dk_iconBtn"+(t.danger===!0?" dk_iconBtnDanger":""),"data-on":t.on===!0?"1":void 0,disabled:n,title:t.title,"aria-label":t.title,onClick:i=>{i.stopPropagation(),!n&&t.onClick()},children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:t.icon}})})}function We(t){let n=t.item,i=t.allowMutations!==!0,k=n.state==="running"||n.state==="paused"||n.state==="restarting",_=n.createdAt===null?n.runningFor===""?"\u2014":n.runningFor:st(n.createdAt);return d("div",{className:"dk_card",role:"button",tabIndex:0,"data-selected":t.selected===!0?"1":"0",onClick:()=>t.onOpen(n,"overview"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.onOpen(n,"overview"))},children:[d("div",{className:"dk_cardHead",children:[e("span",{className:"dk_cardName",title:n.name,children:n.name}),e(Ee,{state:n.state,health:n.health,status:n.status})]},"head"),d("div",{className:"dk_cardRows",children:[e(se,{label:"\u955C\u50CF",value:n.image},"image"),e(se,{label:"ID",value:n.shortId},"id"),e(se,{label:"\u7AEF\u53E3",value:ze(n.ports)},"ports"),e(se,{label:"\u521B\u5EFA",value:_},"created"),n.composeProject===null?null:e(se,{label:"compose",value:n.composeProject+(n.composeService===null?"":"/"+n.composeService)},"compose")]},"rows"),d("div",{className:"dk_actionBar",children:[e(U,{icon:Ke,title:"\u5728\u5BB9\u5668\u5185\u6253\u5F00\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\uFF08docker exec -it "+n.name+" sh\uFF09",onClick:()=>t.onExec(n)},"exec"),e(U,{icon:_t,title:"\u67E5\u770B\u65E5\u5FD7",onClick:()=>t.onOpen(n,"logs")},"logs"),e(U,{icon:xt,title:"\u8D44\u6E90\u5360\u7528",onClick:()=>t.onOpen(n,"stats")},"stats"),e("span",{className:"dk_actionBarSep","aria-hidden":"true"},"sep"),e(U,{icon:k?pt:ht,title:i?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":k?"\u505C\u6B62\u5BB9\u5668":"\u542F\u52A8\u5BB9\u5668",disabled:i,onClick:()=>t.onAction(k?"stop":"start",n)},"power"),e(U,{icon:mt,title:i?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u91CD\u542F\u5BB9\u5668",disabled:i,onClick:()=>t.onAction("restart",n)},"restart"),e(U,{icon:vt,danger:!0,title:i?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u5220\u9664\u5BB9\u5668\uFF08\u4E0D\u53EF\u6062\u590D\uFF09",disabled:i,onClick:()=>t.onAction("remove",n)},"remove")]},"actions")]})}let Je=/^\s*(\[\d{4}-\d{2}-\d{2}[ T][0-9:.,]+\]|\d{2}:\d{2}:\d{2}[,.]\d{3})/,$e=/^\s*(\[(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\]|\|\s*(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL))/,qe=/(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)/,fe=2e3;function Ye(t,n,i){let k=[],_=t;for(let r=0;r<2;r+=1){let v=Je.exec(_);if(v!==null){k.push(e("span",{className:"dk_logTs",children:v[1]},"ts"+String(r))),_=_.slice(v[0].length);continue}let x=$e.exec(_);if(x!==null){let w=qe.exec(x[1]);k.push(e("span",{className:"dk_logLevel","data-level":w===null?"":w[1],children:x[1].trim()},"lv"+String(r))),_=_.slice(x[0].length);continue}break}return k.push(e("span",{className:"dk_logText",children:Ge(_,i,"x"+String(n))},"tx")),d("div",{className:"dk_logLine",children:k},String(n))}function Xe(t){let n=t.item,i=t.config,[k,_]=h(t.initialTab??"overview"),[r,v]=h(null),[x,w]=h(""),[N,A]=h({tail:i.logTailDefault,timestamps:!1}),[E,I]=h(null),[T,Q]=h(""),[$,Z]=h(!1),[H,P]=h(""),[B,z]=h(!0),[G,o]=h(!1),[s,p]=h(3),[S,ee]=h(null),[ge,q]=h(""),[Y,_e]=h(""),[j,M]=h(null),[te,ce]=h(""),[he,W]=h(!1);C(()=>{let g=!0;return v(null),w(""),R.inspect(t.target,n.id).then(b=>{g&&v(b.details?.[0]??null)}).catch(b=>{g&&w(b.message)}),()=>{g=!1}},[t.target,n.id,t.refreshToken]);let D=de(()=>{Z(!0),Q(""),R.logs(t.target,n.id,{tail:N.tail,timestamps:N.timestamps}).then(g=>I(g.logs)).catch(g=>Q(g.message)).finally(()=>Z(!1))},[t.target,n.id,N.tail,N.timestamps]);C(()=>{k==="logs"&&D()},[k,D,t.refreshToken]),C(()=>{if(k!=="logs"||!G)return;let g=setInterval(D,Math.max(1,s)*1e3);return()=>clearInterval(g)},[k,G,s,D]),C(()=>{if(k!=="stats")return;let g=!0,b=()=>{R.stats(t.target,[n.id]).then(y=>{g&&(ee(y.stats?.[0]??null),q(""))}).catch(y=>{g&&q(y.message)})};b();let c=setInterval(b,Math.max(2,i.pollIntervalSec)*1e3);return()=>{g=!1,clearInterval(c)}},[k,t.target,n.id,i.pollIntervalSec,t.refreshToken]);let oe=()=>{Y.trim()!==""&&(W(!0),ce(""),M(null),R.exec(t.target,n.id,Y,i.execTimeoutSec).then(g=>M(g.result)).catch(g=>ce(g.message)).finally(()=>W(!1)))},pe=()=>{if(x!=="")return e(V,{title:"\u8BFB\u53D6\u5BB9\u5668\u8BE6\u60C5\u5931\u8D25",hint:x});if(r===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let g=[["\u72B6\u6001",r.state+(r.health===null?"":" / "+r.health)+(r.status===""?"":"\uFF08"+r.status+"\uFF09")],["\u955C\u50CF",r.image],["\u5BB9\u5668 ID",r.shortId],["\u542F\u52A8\u65F6\u95F4",r.startedAt??"\u2014"],["\u7ED3\u675F\u65F6\u95F4",r.finishedAt??"\u2014"],["\u9000\u51FA\u7801",r.exitCode===null?"\u2014":String(r.exitCode)],["\u91CD\u542F\u6B21\u6570",r.restartCount===null?"\u2014":String(r.restartCount)],["\u91CD\u542F\u7B56\u7565",r.restartPolicy??"\u2014"],["PID",r.pid===null?"\u2014":String(r.pid)],["\u7AEF\u53E3",r.ports.length===0?"\u2014":ze(r.ports)],["\u6302\u8F7D",r.mounts.length===0?"\u2014":r.mounts.map(c=>c.source+"\u2192"+c.destination+(c.readWrite?"":"\uFF08\u53EA\u8BFB\uFF09")).join(`
1047
- `)],["\u7F51\u7EDC",r.networks.length===0?"\u2014":r.networks.map(c=>c.name+(c.ip===null?"":"\uFF08"+c.ip+"\uFF09")).join(", ")],["\u547D\u4EE4",(r.entrypoint+" "+r.command).trim()||"\u2014"],["\u5DE5\u4F5C\u76EE\u5F55",r.workingDir===""?"\u2014":r.workingDir],["\u7528\u6237",r.user===""?"\u2014":r.user]],b=d("div",{className:"dk_kv",children:g.flatMap(([c,y],L)=>[e("div",{className:"dk_kvKey",children:c},"k"+String(L)),e("div",{className:"dk_kvVal"+(c==="\u5BB9\u5668 ID"||c==="\u547D\u4EE4"||c==="\u955C\u50CF"?" dk_kvValMono":""),children:y},"v"+String(L))])});return d("div",{children:[r.healthLogTail===null?null:e("div",{className:"dk_hint",style:{marginBottom:8},children:"\u6700\u8FD1\u5065\u5EB7\u68C0\u67E5\u8F93\u51FA\uFF1A"+r.healthLogTail}),b,e("div",{className:"dk_cardSection",style:{marginTop:16},children:"\u4E00\u6B21\u6027\u547D\u4EE4\uFF08docker exec\uFF09"}),i.allowExec!==!0?e(V,{kind:"info",title:"exec \u672A\u542F\u7528",hint:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8 exec\u300D\uFF0C\u6216\u76F4\u63A5\u590D\u5236\u5361\u7247\u4E0A\u7684 exec \u547D\u4EE4\u5230\u7EC8\u7AEF\u9762\u677F\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u3002"}):d("div",{children:[d("div",{className:"dk_row",children:[e("input",{className:"dk_input",style:{flex:"1 1 auto"},placeholder:"\u5982 ls -la /app \u6216 cat /etc/nginx/nginx.conf",value:Y,onChange:c=>_e(c.target.value),onKeyDown:c=>{c.key==="Enter"&&oe()}}),e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:he,onClick:oe,children:he?"\u6267\u884C\u4E2D\u2026":"\u6267\u884C"})]}),te===""?null:e(V,{title:"\u6267\u884C\u5931\u8D25",hint:te}),j===null?null:d("div",{style:{marginTop:8},children:[e("div",{className:"dk_hint",children:"\u9000\u51FA\u7801 "+(j.code===null?"?":String(j.code))+" \xB7 \u8017\u65F6 "+String(j.durationMs)+"ms"+(j.truncated?" \xB7 \u8F93\u51FA\u5DF2\u622A\u65AD":"")}),e("pre",{className:"dk_logBox",style:{marginTop:6},children:(j.stdout||"")+(j.stderr===""?"":`
1205
+ `;var Tt="/api/dsh-docker",Qe="dsh-docker-style";function Pe(){if(document.getElementById(Qe)!==null)return;let i=document.createElement("style");i.id=Qe,i.textContent=Xe,document.head.appendChild(i)}async function V(i,m){let e=await fetch(Tt+i,{...m,headers:{"content-type":"application/json",...m?.headers??{}}}),d=null;try{d=await e.json()}catch{}if(!e.ok){let E=d!==null&&typeof d.error=="string"?d.error:`HTTP ${String(e.status)}`;throw new Error(E)}if(d!==null&&d.ok===!1)throw new Error(typeof d.error=="string"?d.error:"\u8BF7\u6C42\u5931\u8D25");return d}var H={config:()=>V("/config"),saveConfig:i=>V("/config",{method:"POST",body:JSON.stringify(i)}),targets:()=>V("/targets"),probe:i=>V("/probe",{method:"POST",body:JSON.stringify({target:i})}),containers:(i,m)=>V("/containers",{method:"POST",body:JSON.stringify({target:i,all:m})}),inspect:(i,m)=>V("/inspect",{method:"POST",body:JSON.stringify({target:i,id:m})}),logs:(i,m,e)=>V("/logs",{method:"POST",body:JSON.stringify({target:i,id:m,...e})}),stats:(i,m)=>V("/stats",{method:"POST",body:JSON.stringify({target:i,ids:m})}),images:i=>V("/images",{method:"POST",body:JSON.stringify({target:i})}),action:(i,m,e)=>V("/action",{method:"POST",body:JSON.stringify({target:i,action:m,id:e})}),exec:(i,m,e,d)=>V("/exec",{method:"POST",body:JSON.stringify({target:i,id:m,command:e,timeoutSec:d})})};function Lt(i){return i==null||!Number.isFinite(i)?"\u2014":i.toFixed(i>=10?1:2)+"%"}function Et(i){return i.hostPort===void 0?String(i.containerPort)+"/"+i.protocol:String(i.hostPort)+"\u2192"+String(i.containerPort)+"/"+i.protocol}function Ze(i){if(!Array.isArray(i)||i.length===0)return"\u65E0\u7AEF\u53E3\u6620\u5C04";let m=new Set,e=[];for(let d of i){let E=Et(d);m.has(E)||(m.add(E),e.push(E))}return e.join(" ")}function Bt(i){let m=/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/.exec(i);return m===null?i:m[1]+" "+m[2]}function It(i){return{running:"\u8FD0\u884C\u4E2D",exited:"\u5DF2\u505C\u6B62",created:"\u5DF2\u521B\u5EFA",paused:"\u5DF2\u6682\u505C",restarting:"\u91CD\u542F\u4E2D",dead:"dead",removing:"\u5220\u9664\u4E2D",unknown:"\u672A\u77E5"}[i]??i}function Mt(i,m){let e=new Blob([m],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(e),E=document.createElement("a");E.href=d,E.download=i,E.click(),setTimeout(()=>URL.revokeObjectURL(d),1e3)}function et(i){return"docker exec -it '"+String(i).replaceAll("'","'\\''")+"' sh"}var Z=null,re=null,ce=null,Fe=[],rt=0;function ze(i){i!==null&&typeof i=="object"&&(ce=i),rt=Date.now()}async function Se(){try{let[i,m]=await Promise.all([H.config(),H.targets()]);return ce=i.config,Fe=m.targets??[],rt=Date.now(),!0}catch(i){return console.warn("[dsh-docker] \u76EE\u6807\u7F13\u5B58\u5237\u65B0\u5931\u8D25\uFF1A"+(i instanceof Error?i.message:String(i))),!1}}async function Ot(i,m){let e=je(i,m);return e!==void 0?e:(await Se(),je(i,m))}function je(i,m){let e=ce!==null&&Array.isArray(ce.targets)?ce.targets:[];if(typeof m=="string"&&m!==""){let C=e.find(P=>P.kind==="ssh"&&P.book===m);if(C!==void 0)return C.name}let d=typeof i?.host=="string"?i.host:"";if(d==="")return;let E=Number(i?.port),g=Number.isInteger(E)&&E>0?E:22;for(let C of Fe){if(C.kind!=="ssh"||typeof C.label!="string")continue;let P=/^([^@]+)@(.+?)(?::(\d+))?$/.exec(C.label);if(P!==null&&P[2]===d&&Number(P[3]??22)===g)return C.name}}var tt='<svg viewBox="0 0 16 16" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Rt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Ne='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Ce='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M4.5 4.5l7 7"/><path d="M11.5 4.5l-7 7"/></svg>',Dt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3.4l7.4 4.6L5 12.6z"/></svg>',At='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4.2" y="4.2" width="7.6" height="7.6" rx="1.2"/></svg>',Ht='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Pt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4.6h10"/><path d="M6.2 4.6V3.4a.8.8 0 0 1 .8-.8h2a.8.8 0 0 1 .8.8v1.2"/><path d="M4.6 4.6l.6 8a.9.9 0 0 0 .9.8h3.8a.9.9 0 0 0 .9-.8l.6-8"/></svg>';var zt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v7.2"/><path d="M5 7.4L8 10.4l3-3"/><path d="M3.4 12.8h9.2"/></svg>',jt='<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.6l5.8 10.4H2.2z"/><path d="M8 6.4v3.2"/><path d="M8 11.6h.01"/></svg>',nt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5l3.5 3L3 11"/><path d="M8.5 11H13"/></svg>',Ft='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3 4.5h10"/><path d="M3 8h10"/><path d="M3 11.5h6"/></svg>',Vt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3.5 12.5v-4"/><path d="M7 12.5v-8"/><path d="M10.5 12.5v-5"/><path d="M13 12.5v-2"/></svg>',Gt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.5 8h-9"/><path d="M7 4.5L3.5 8 7 11.5"/></svg>',at='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6.5L8 10.5l4-4"/></svg>';window.__ModuleLoader__.load({id:"@hyzyn/dsh-docker",factory:i=>{let m=i("react"),{jsx:e,jsxs:d}=i("react/jsx-runtime"),{createRoot:E}=i("react-dom/client"),{useState:g,useEffect:C,useRef:P,useCallback:de}=m;function dt(t,a,o){if(a==="")return t;let c=t.toLowerCase(),v=a.toLowerCase(),r=[],b=0,x=c.indexOf(v),w=0;for(;x>=0&&w<500;)x>b&&r.push(t.slice(b,x)),r.push(e("mark",{children:t.slice(x,x+v.length)},o+"-m"+String(w))),b=x+v.length,w+=1,x=c.indexOf(v,b);return b<t.length&&r.push(t.slice(b)),r}function Ve(t){let a=t.health==="unhealthy"?"unhealthy":t.state,o=t.health==="unhealthy"?"\u4E0D\u5065\u5EB7":It(t.state);return e("span",{className:"dk_badge","data-state":a,title:t.status??"",children:o})}function G(t){return d("div",{className:"dk_banner","data-kind":t.kind??"error",children:[e("span",{className:"dk_bannerIcon",dangerouslySetInnerHTML:{__html:jt}},"icon"),d("div",{className:"dk_bannerBody",children:[e("div",{children:t.title}),t.hint===void 0?null:e("div",{className:"dk_hint",style:{marginTop:4},children:t.hint})]},"body"),t.action===void 0?null:e("div",{className:"dk_bannerAction",children:t.action},"action")]})}function Te(t){return d("div",{className:"dk_confirmBackdrop",onMouseDown:a=>a.stopPropagation(),children:[d("div",{className:"dk_confirm",children:[e("div",{className:"dk_confirmTitle",children:t.title}),e("div",{className:"dk_confirmText",children:t.text}),d("div",{className:"dk_confirmActions",children:[e("button",{type:"button",className:"dk_btn",onClick:t.onCancel,children:"\u53D6\u6D88"}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:t.onConfirm,children:t.confirmLabel})]})]})]})}function Kt(t){return e("button",{type:"button",className:"dk_btn"+(t.danger===!0?" dk_btnDanger":""),disabled:t.disabled===!0,title:t.title??"",onClick:a=>{a.stopPropagation(),t.onClick()},children:t.children})}function ke(t){return d("div",{className:"dk_cardRow",children:[e("span",{className:"dk_cardLabel",children:t.label}),e("span",{className:"dk_cardValue",title:String(t.value),children:t.value})]})}function K(t){let a=t.disabled===!0;return e("button",{type:"button",className:"dk_iconBtn"+(t.danger===!0?" dk_iconBtnDanger":""),"data-on":t.on===!0?"1":void 0,"data-spin":t.spin===!0?"1":void 0,disabled:a,title:t.title,"aria-label":t.title,onClick:o=>{o.stopPropagation(),!a&&t.onClick()},children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:t.icon}})})}function ot(t){let a=t.item,o=t.allowMutations!==!0,c=a.state==="running"||a.state==="paused"||a.state==="restarting",v=a.createdAt===null?a.runningFor===""?"\u2014":a.runningFor:Bt(a.createdAt);return d("div",{className:"dk_card",role:"button",tabIndex:0,"data-selected":t.selected===!0?"1":"0",onClick:()=>t.onOpen(a,"overview"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.onOpen(a,"overview"))},children:[d("div",{className:"dk_cardHead",children:[e("span",{className:"dk_cardName",title:a.name,children:a.name}),e(Ve,{state:a.state,health:a.health,status:a.status})]},"head"),d("div",{className:"dk_cardRows",children:[e(ke,{label:"\u955C\u50CF",value:a.image},"image"),e(ke,{label:"ID",value:a.shortId},"id"),e(ke,{label:"\u7AEF\u53E3",value:Ze(a.ports)},"ports"),e(ke,{label:"\u521B\u5EFA",value:v},"created"),a.composeProject===null?null:e(ke,{label:"compose",value:a.composeProject+(a.composeService===null?"":"/"+a.composeService)},"compose")]},"rows"),d("div",{className:"dk_actionBar",children:[e(K,{icon:nt,title:"\u5728\u5BB9\u5668\u5185\u6253\u5F00\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\uFF08docker exec -it "+a.name+" sh\uFF09",onClick:()=>t.onExec(a)},"exec"),e(K,{icon:Ft,title:"\u67E5\u770B\u65E5\u5FD7",onClick:()=>t.onOpen(a,"logs")},"logs"),e(K,{icon:Vt,title:"\u8D44\u6E90\u5360\u7528",onClick:()=>t.onOpen(a,"stats")},"stats"),e("span",{className:"dk_actionBarSep","aria-hidden":"true"},"sep"),e(K,{icon:c?At:Dt,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":c?"\u505C\u6B62\u5BB9\u5668":"\u542F\u52A8\u5BB9\u5668",disabled:o,onClick:()=>t.onAction(c?"stop":"start",a)},"power"),e(K,{icon:Ht,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u91CD\u542F\u5BB9\u5668",disabled:o,onClick:()=>t.onAction("restart",a)},"restart"),e(K,{icon:Pt,danger:!0,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u5220\u9664\u5BB9\u5668\uFF08\u4E0D\u53EF\u6062\u590D\uFF09",disabled:o,onClick:()=>t.onAction("remove",a)},"remove")]},"actions")]})}let lt=/^\s*(\[\d{4}-\d{2}-\d{2}[ T][0-9:.,]+\]|\d{2}:\d{2}:\d{2}[,.]\d{3})/,it=/^\s*(\[(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\]|\|\s*(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL))/,st=/(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)/,Le=2e3;function ct(t,a,o){let c=[],v=t;for(let r=0;r<2;r+=1){let b=lt.exec(v);if(b!==null){c.push(e("span",{className:"dk_logTs",children:b[1]},"ts"+String(r))),v=v.slice(b[0].length);continue}let x=it.exec(v);if(x!==null){let w=st.exec(x[1]);c.push(e("span",{className:"dk_logLevel","data-level":w===null?"":w[1],children:x[1].trim()},"lv"+String(r))),v=v.slice(x[0].length);continue}break}return c.push(e("span",{className:"dk_logText",children:dt(v,o,"x"+String(a))},"tx")),d("div",{className:"dk_logLine",children:c},String(a))}function kt(t){let a=t.item,o=t.config,[c,v]=g(t.initialTab??"overview"),[r,b]=g(null),[x,w]=g(""),[N,j]=g({tail:o.logTailDefault,timestamps:!1}),[B,I]=g(null),[T,$]=g(""),[Y,ee]=g(!1),[M,O]=g(""),[S,F]=g(!1),[J,l]=g(3),[s,h]=g(null),[z,q]=g(""),[ge,X]=g(""),[R,be]=g(null),[he,D]=g(""),[te,pe]=g(!1);C(()=>{let p=!0;return b(null),w(""),H.inspect(t.target,a.id).then(_=>{p&&b(_.details?.[0]??null)}).catch(_=>{p&&w(_.message)}),()=>{p=!1}},[t.target,a.id,t.refreshToken]);let Q=de(()=>{ee(!0),$(""),H.logs(t.target,a.id,{tail:N.tail,timestamps:N.timestamps}).then(p=>I(p.logs)).catch(p=>$(p.message)).finally(()=>ee(!1))},[t.target,a.id,N.tail,N.timestamps]);C(()=>{c==="logs"&&Q()},[c,Q,t.refreshToken]),C(()=>{if(c!=="logs"||!S)return;let p=setInterval(Q,Math.max(1,J)*1e3);return()=>clearInterval(p)},[c,S,J,Q]),C(()=>{if(c!=="stats")return;let p=!0,_=()=>{H.stats(t.target,[a.id]).then(y=>{p&&(h(y.stats?.[0]??null),q(""))}).catch(y=>{p&&q(y.message)})};_();let k=setInterval(_,Math.max(2,o.pollIntervalSec)*1e3);return()=>{p=!1,clearInterval(k)}},[c,t.target,a.id,o.pollIntervalSec,t.refreshToken]);let U=()=>{ge.trim()!==""&&(pe(!0),D(""),be(null),H.exec(t.target,a.id,ge,o.execTimeoutSec).then(p=>be(p.result)).catch(p=>D(p.message)).finally(()=>pe(!1)))},W=()=>{if(x!=="")return e(G,{title:"\u8BFB\u53D6\u5BB9\u5668\u8BE6\u60C5\u5931\u8D25",hint:x});if(r===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let p=[["\u72B6\u6001",r.state+(r.health===null?"":" / "+r.health)+(r.status===""?"":"\uFF08"+r.status+"\uFF09")],["\u955C\u50CF",r.image],["\u5BB9\u5668 ID",r.shortId],["\u542F\u52A8\u65F6\u95F4",r.startedAt??"\u2014"],["\u7ED3\u675F\u65F6\u95F4",r.finishedAt??"\u2014"],["\u9000\u51FA\u7801",r.exitCode===null?"\u2014":String(r.exitCode)],["\u91CD\u542F\u6B21\u6570",r.restartCount===null?"\u2014":String(r.restartCount)],["\u91CD\u542F\u7B56\u7565",r.restartPolicy??"\u2014"],["PID",r.pid===null?"\u2014":String(r.pid)],["\u7AEF\u53E3",r.ports.length===0?"\u2014":Ze(r.ports)],["\u6302\u8F7D",r.mounts.length===0?"\u2014":r.mounts.map(k=>k.source+"\u2192"+k.destination+(k.readWrite?"":"\uFF08\u53EA\u8BFB\uFF09")).join(`
1206
+ `)],["\u7F51\u7EDC",r.networks.length===0?"\u2014":r.networks.map(k=>k.name+(k.ip===null?"":"\uFF08"+k.ip+"\uFF09")).join(", ")],["\u547D\u4EE4",(r.entrypoint+" "+r.command).trim()||"\u2014"],["\u5DE5\u4F5C\u76EE\u5F55",r.workingDir===""?"\u2014":r.workingDir],["\u7528\u6237",r.user===""?"\u2014":r.user]],_=d("div",{className:"dk_kv",children:p.flatMap(([k,y],L)=>[e("div",{className:"dk_kvKey",children:k},"k"+String(L)),e("div",{className:"dk_kvVal"+(k==="\u5BB9\u5668 ID"||k==="\u547D\u4EE4"||k==="\u955C\u50CF"?" dk_kvValMono":""),children:y},"v"+String(L))])});return d("div",{children:[r.healthLogTail===null?null:e("div",{className:"dk_hint",style:{marginBottom:8},children:"\u6700\u8FD1\u5065\u5EB7\u68C0\u67E5\u8F93\u51FA\uFF1A"+r.healthLogTail}),_,e("div",{className:"dk_cardSection",style:{marginTop:16},children:"\u4E00\u6B21\u6027\u547D\u4EE4\uFF08docker exec\uFF09"}),o.allowExec!==!0?e(G,{kind:"info",title:"exec \u672A\u542F\u7528",hint:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8 exec\u300D\uFF0C\u6216\u76F4\u63A5\u590D\u5236\u5361\u7247\u4E0A\u7684 exec \u547D\u4EE4\u5230\u7EC8\u7AEF\u9762\u677F\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u3002"}):d("div",{children:[d("div",{className:"dk_row",children:[e("input",{className:"dk_input",style:{flex:"1 1 auto"},placeholder:"\u5982 ls -la /app \u6216 cat /etc/nginx/nginx.conf",value:ge,onChange:k=>X(k.target.value),onKeyDown:k=>{k.key==="Enter"&&U()}}),e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:te,onClick:U,children:te?"\u6267\u884C\u4E2D\u2026":"\u6267\u884C"})]}),he===""?null:e(G,{title:"\u6267\u884C\u5931\u8D25",hint:he}),R===null?null:d("div",{style:{marginTop:8},children:[e("div",{className:"dk_hint",children:"\u9000\u51FA\u7801 "+(R.code===null?"?":String(R.code))+" \xB7 \u8017\u65F6 "+String(R.durationMs)+"ms"+(R.truncated?" \xB7 \u8F93\u51FA\u5DF2\u622A\u65AD":"")}),e("pre",{className:"dk_logBox",style:{marginTop:6},children:(R.stdout||"")+(R.stderr===""?"":`
1048
1207
  [stderr]
1049
- `+j.stderr)||"(\u65E0\u8F93\u51FA)"})]})]})]})},le=()=>{let g=E===null?"":E.text,b=H.trim().toLowerCase(),c=g===""?[]:g.split(`
1050
- `),y=b===""?c:c.filter(L=>L.toLowerCase().includes(b));return{raw:g,needle:b,allLines:c,matchedLines:y}},ke=(g,b,c)=>e("button",{type:"button",className:"dk_pill","data-on":g?"1":"0",onClick:c,children:b}),xe=()=>{let{raw:g}=le(),b=[...new Set([100,200,500,1e3,5e3,Number(i.logTailDefault)||200,Number(N.tail)||200])].filter(c=>Number.isInteger(c)&&c>0).sort((c,y)=>c-y);return d("div",{className:"dk_logTools",children:[e("span",{className:"dk_toolLabel",children:"LINES"}),e("select",{className:"dk_select dk_selectSm",value:String(N.tail),onChange:c=>A({...N,tail:Number(c.target.value)}),children:b.map(c=>e("option",{value:String(c),children:c===5e3?"Last 5000":"Last "+String(c)},String(c)))}),e("span",{className:"dk_toolLabel",children:"TIMESTAMPS"}),ke(N.timestamps,N.timestamps?"On":"Off",()=>A({...N,timestamps:!N.timestamps})),e("span",{className:"dk_toolLabel",children:"AUTO REFRESH"}),ke(G,G?"On":"Off",()=>o(c=>!c)),e("select",{className:"dk_select dk_selectSm",value:String(s),title:"\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u5F00\u542F AUTO REFRESH \u540E\u6309\u6B64\u8F6E\u8BE2\uFF09",onChange:c=>p(Number(c.target.value)),children:[2,3,5,10].map(c=>e("option",{value:String(c),children:String(c)+"s"},String(c)))}),$?e("span",{className:"dk_spin"}):null,e(U,{icon:Le,title:"\u5237\u65B0\u65E5\u5FD7",onClick:D},"refresh"),e(U,{icon:ft,title:"\u4E0B\u8F7D\u65E5\u5FD7",disabled:g==="",onClick:()=>kt(n.name+".log",g)},"download")]})},ae=()=>{let{needle:g,allLines:b,matchedLines:c}=le();return d("div",{className:"dk_filterBar",children:[e("button",{type:"button",className:"dk_filterToggle","data-on":B?"1":"0",onClick:()=>z(y=>!y),children:[e("span",{className:"dk_caret",dangerouslySetInnerHTML:{__html:Ve}},"c"),"\u8FC7\u6EE4\u65E5\u5FD7"]}),B?e("input",{className:"dk_input dk_filterInput",placeholder:"\u8FC7\u6EE4\u65E5\u5FD7\u2026",value:H,onChange:y=>P(y.target.value)}):null,e("span",{className:"dk_filterCount",children:g===""?String(b.length)+" \u884C":String(c.length)+" / "+String(b.length)+" \u884C\u5339\u914D"})]})},ue=()=>{let{needle:g,matchedLines:b}=le(),c=b.length>fe?b.slice(-fe):b;return d("div",{className:"dk_logs",children:[T===""?null:e(V,{title:"\u8BFB\u53D6\u65E5\u5FD7\u5931\u8D25",hint:T+(T.includes("Failed to fetch")?"\uFF08\u7F51\u7EDC\u8BF7\u6C42\u6CA1\u5230\u5BBF\u4E3B\uFF1A\u5BBF\u4E3B\u53EF\u80FD\u521A\u91CD\u542F\u3001\u6216\u8FDE\u63A5\u88AB\u4E2D\u65AD\uFF09":""),action:e("button",{type:"button",className:"dk_btn",disabled:$,onClick:D,children:"\u91CD\u8BD5"})}),E!==null&&E.truncated===!0?e(V,{kind:"warn",title:"\u65E5\u5FD7\u8F93\u51FA\u8D85\u8FC7\u4E0A\u9650\uFF0C\u5DF2\u622A\u65AD",hint:"\u8C03\u5C0F\u300CLINES\u300D\u6216\u5230\u8BBE\u7F6E\u5361\u7247\u8C03\u5927\u300C\u5355\u6B21\u547D\u4EE4\u8F93\u51FA\u4E0A\u9650\u300D\u3002"}):null,d("div",{className:"dk_logBody",children:[b.length>c.length?e("div",{className:"dk_logLine dk_logMore",children:"\uFF08\u53EA\u663E\u793A\u6700\u8FD1 "+String(fe)+" \u884C\uFF0C\u5171 "+String(b.length)+" \u884C\u5339\u914D\uFF09"},"more"):null,T!==""?null:E===null?e("div",{className:"dk_logLine",children:"\u8BFB\u53D6\u4E2D\u2026"},"loading"):c.length===0?e("div",{className:"dk_logLine",children:g===""?"(\u65E0\u65E5\u5FD7)":"(\u65E0\u5339\u914D\u65E5\u5FD7)"},"empty"):c.map((y,L)=>Ye(y,L,g))]})]})},we=()=>{if(ge!=="")return e(V,{title:"\u8BFB\u53D6\u7EDF\u8BA1\u5931\u8D25",hint:ge});if(S===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let g=S.cpuPercent??0,b=S.memPercent??0,c=L=>d("div",{className:"dk_bar",children:[e("div",{className:"dk_barFill","data-warn":L>=60&&L<85?"1":void 0,"data-danger":L>=85?"1":void 0,style:{width:Math.min(100,Math.max(0,L))+"%"}})]}),y=(L,Ne,a)=>d("tr",{children:[e("td",{children:L}),e("td",{className:"dk_num",children:Ne}),e("td",{children:a??null})]},L);return d("table",{className:"dk_stats",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u6307\u6807"}),e("th",{children:"\u6570\u503C"}),e("th",{children:"\u5360\u7528"})]})}),e("tbody",{children:[y("CPU",lt(S.cpuPercent),c(g)),y("\u5185\u5B58",S.memUsage,c(b)),y("\u7F51\u7EDC IO",S.netIO,null),y("\u78C1\u76D8 IO",S.blockIO,null),y("PIDs",S.pids===null?"\u2014":String(S.pids),null)]})]})},ye=[["overview","\u6982\u89C8"],["logs","\u65E5\u5FD7"],["stats","\u7EDF\u8BA1"]];return d("div",{className:"dk_detail",children:[d("div",{className:"dk_header dk_headerDetail",children:[e(U,{icon:wt,title:"\u8FD4\u56DE\u5BB9\u5668\u5217\u8868",onClick:t.onBack},"back"),e("span",{className:"dk_detailTitle",title:n.name,children:n.name}),e(Ee,{state:n.state,health:n.health,status:n.status}),e("span",{className:"dk_detailSub",children:t.targetLabel??""}),e("span",{className:"dk_headerSpacer"}),k==="logs"?xe():e(U,{icon:Le,title:"\u5237\u65B0",onClick:t.onRefresh},"refresh"),e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:t.onClose,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Be}})},"close")]}),d("div",{className:"dk_tabs",children:[...ye.map(([g,b])=>e("button",{type:"button",className:"dk_tab","data-on":k===g?"1":"0",onClick:()=>_(g),children:b},g)),k==="logs"?e("span",{className:"dk_headerSpacer"},"spacer"):null,k==="logs"?ae():null]}),e("div",{className:"dk_detailBody",children:k==="overview"?pe():k==="logs"?ue():we()})]})}function Qe(t){return d("div",{className:"dk_drawer",children:[d("div",{className:"dk_drawerHead",children:[e("span",{className:"dk_drawerIcon",dangerouslySetInnerHTML:{__html:Ke}}),e("span",{className:"dk_drawerTitle",title:t.label,children:t.label}),e("span",{className:"dk_drawerHint",children:"\u7531\u7EC8\u7AEF\u9762\u677F\u627F\u8F7D \xB7 \u6536\u8D77\u62BD\u5C49\u7ED3\u675F\u4F1A\u8BDD"}),e("span",{className:"dk_headerSpacer"}),e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u7EC8\u7AEF",onClick:t.onClose,children:e("span",{dangerouslySetInnerHTML:{__html:Be}})})]}),e("div",{className:"dk_drawerBody",ref:t.hostRef})]})}function Ze(t){let[n,i]=h(null),[k,_]=h([]),[r,v]=h(t.initialTarget??""),x=t.sessionHint!==void 0&&(t.initialTarget??"")==="",[w,N]=h("containers"),[A,E]=h([]),[I,T]=h([]),[Q,$]=h(!1),[Z,H]=h(""),[P,B]=h(""),[z,G]=h(!0),[o,s]=h(""),[p,S]=h("all"),[ee,ge]=h(!1),[q,Y]=h(null),[_e,j]=h(0),[M,te]=h(null),[ce,he]=h(""),W=K(!0),[D,oe]=h(null),pe=K(null);C(()=>()=>{W.current=!1},[]),C(()=>{if(D===null)return;let a=pe.current;if(a===null)return;let u=null;try{u=re.mount(a,D.options)}catch(f){B("\u7EC8\u7AEF\u542F\u52A8\u5931\u8D25\uFF1A"+(f instanceof Error?f.message:String(f))),oe(null);return}return()=>{try{u?.()}catch{}}},[D]),C(()=>{R.config().then(a=>{let u=a.config;i(u),!x&&Array.isArray(u.targets)&&u.targets.length>0&&v(f=>f===""?u.targets[0].name:f),Te(u)}).catch(a=>H(a.message)),R.targets().then(a=>{_(a.targets??[]),Ie=a.targets??[];let u=(a.targets??[])[0];u!==void 0&&!x&&v(f=>f===""?u.name:f)}).catch(()=>{})},[]);let le=de(()=>{r!==""&&($(!0),R.containers(r,z).then(a=>{W.current&&(E(a.containers??[]),H(""))}).catch(a=>{W.current&&H(a.message)}).finally(()=>{W.current&&$(!1)}))},[r,z]),ke=de(()=>{r!==""&&($(!0),R.images(r).then(a=>{W.current&&(T(a.images??[]),H(""))}).catch(a=>{W.current&&H(a.message)}).finally(()=>{W.current&&$(!1)}))},[r]),xe=de(()=>j(a=>a+1),[]),ae=de(()=>{w==="images"?ke():le(),j(a=>a+1)},[w,le,ke]);C(()=>{r!==""&&ae()},[r,z,w]),C(()=>{if(!ee||r==="")return;let a=setInterval(ae,Math.max(2,n?.pollIntervalSec??5)*1e3);return()=>clearInterval(a)},[ee,ae,r,n]),C(()=>{if(P==="")return;let a=setTimeout(()=>B(""),4e3);return()=>clearTimeout(a)},[P]);let ue=(a,u)=>{let f=je(a.name);navigator.clipboard.writeText(f).then(()=>{B("\u5DF2\u590D\u5236\uFF1A"+f+(u===void 0?"":"\uFF08"+u+"\uFF09"))}).catch(()=>B("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C\uFF1A"+f))},we=a=>{let u=je(a.name);if(re===null){let ne=document.querySelector("[data-dsh-tty-entry]")!==null;ue(a,ne?"\u7EC8\u7AEF\u9762\u677F\u7248\u672C\u8FC7\u65E7\uFF08\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u9700\u8981 dsh-tty \u2265 0.14.0\uFF09\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C":"\u672A\u5B89\u88C5 dsh-tty \u7EC8\u7AEF\u9762\u677F\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C\uFF08\u88C5 dsh-tty \u540E\u53EF\u76F4\u63A5\u5728\u6B64\u5F00\u7EC8\u7AEF\uFF09");return}let f=(n?.targets??[]).find(ne=>ne.name===r),me=a.name+" \xB7 exec",Ce=f===void 0||f.kind==="local"?{command:u,label:me}:typeof f.book=="string"&&f.book!==""?{book:f.book,command:u,label:me}:(f.auth??"agent")==="agent"?{spec:{host:f.host,port:f.port,username:f.username,auth:"agent",agentForward:f.agentForward===!0},command:u,label:me}:null;if(Ce===null){ue(a,"\u5185\u8054\u76EE\u6807\u7528\u4E86 key/password \u8BA4\u8BC1\uFF0C\u6D4F\u89C8\u5668\u7AEF\u62FF\u4E0D\u5230\u51ED\u8BC1");return}if(typeof re.mount=="function"&&Number(re.version??0)>=2){oe({label:me,options:Ce});return}try{re.open(Ce),t.onClose()}catch(ne){ue(a,ne instanceof Error?ne.message:String(ne))}},ye=(a,u)=>{te({title:a==="remove"?"\u5220\u9664\u5BB9\u5668":a==="stop"?"\u505C\u6B62\u5BB9\u5668":a==="start"?"\u542F\u52A8\u5BB9\u5668":"\u91CD\u542F\u5BB9\u5668",text:a==="remove"?`\u786E\u5B9A\u5220\u9664\u5BB9\u5668 ${u.name}\uFF1F\u5BB9\u5668\u7684\u53EF\u5199\u5C42\u4E0E\u914D\u7F6E\u4F1A\u88AB\u5220\u9664\uFF08\u547D\u540D\u6570\u636E\u5377\u4FDD\u7559\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`:`\u786E\u5B9A\u5BF9\u5BB9\u5668 ${u.name} \u6267\u884C${a==="stop"?"\u505C\u6B62":a==="start"?"\u542F\u52A8":"\u91CD\u542F"}\u64CD\u4F5C\uFF1F`,confirmLabel:a==="remove"?"\u5220\u9664":"\u786E\u5B9A",run:()=>{te(null),R.action(r,a,u.id).then(f=>{B(`${f.result.action} ${u.name}\uFF1A${f.result.message}`),ae()}).catch(f=>H(f.message))}})},g=q===null?null:A.find(a=>a.id===q.id)??q.item,b=A.filter(a=>{if(p==="running"&&!(a.state==="running"||a.state==="paused"||a.state==="restarting")||p==="stopped"&&a.state==="running"||p==="unhealthy"&&a.health!=="unhealthy")return!1;let u=o.trim().toLowerCase();return u===""?!0:a.name.toLowerCase().includes(u)||a.image.toLowerCase().includes(u)||a.id.toLowerCase().includes(u)}),c=I.filter(a=>{let u=ce.trim().toLowerCase();return u===""||a.reference.toLowerCase().includes(u)||a.id.toLowerCase().includes(u)}),y=a=>{let u=k.find(f=>f.name===a);return u===void 0||u.label===void 0?a:a+" \xB7 "+u.label},L=()=>Q?e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]}):r===""?x?d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u4E0D\u662F Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u6309\u4E0A\u9762\u7684\u63D0\u793A\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761\u76EE\u6807\uFF08\u63A8\u8350\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u3002\u4E3A\u907F\u514D\u5F20\u51A0\u674E\u6234\uFF0C\u9762\u677F\u4E0D\u4F1A\u81EA\u52A8\u5207\u5230\u5176\u4ED6\u76EE\u6807\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u8FD8\u6CA1\u6709\u914D\u7F6E Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u4E2A\u76EE\u6807\uFF1A\u672C\u673A\u76F4\u63A5\u9009\u300C\u672C\u673A\u300D\uFF1B\u8FDC\u7A0B\u4E3B\u673A\u53EF\u4EE5\u5F15\u7528 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:w==="images"?"\u6CA1\u6709\u955C\u50CF":"\u6CA1\u6709\u5BB9\u5668"}),e("div",{className:"dk_emptyHint",children:o.trim()===""?"\u76EE\u6807\u4E0A\u6CA1\u6709\u5339\u914D\u7684\u6570\u636E\uFF0C\u6216\u7B5B\u9009\u6761\u4EF6\u8FC7\u7A84\u3002":"\u6CA1\u6709\u5339\u914D\u300C"+o.trim()+"\u300D\u7684\u7ED3\u679C\u3002"})]}),Ne=()=>w==="images"?d("div",{children:[e("div",{className:"dk_logBar",children:[e("input",{className:"dk_input",style:{flex:"1 1 200px"},placeholder:"\u641C\u7D22\u955C\u50CF\uFF08\u4ED3\u5E93 / \u6807\u7B7E / ID\uFF09",value:ce,onChange:a=>he(a.target.value)}),e("span",{className:"dk_hint",children:String(c.length)+" / "+String(I.length)+" \u4E2A\u955C\u50CF"})]}),c.length===0?L():e("div",{className:"dk_tableWrap",children:d("table",{className:"dk_images",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u955C\u50CF"}),e("th",{children:"\u5927\u5C0F"}),e("th",{children:"\u521B\u5EFA"}),e("th",{children:"ID"})]})}),e("tbody",{children:c.map(a=>d("tr",{children:[e("td",{className:"dk_mono",children:a.reference}),e("td",{children:a.sizeText}),e("td",{children:a.createdSince}),e("td",{className:"dk_mono",children:a.shortId})]},a.id+a.reference))})]})})]}):b.length===0?L():e("div",{className:"dk_grid",children:b.map(a=>e(We,{item:a,selected:q!==null&&a.id===q.id,allowMutations:n?.allowMutations===!0,onOpen:(u,f)=>Y({id:u.id,tab:f,item:u}),onExec:we,onAction:ye,onCopyExec:u=>{navigator.clipboard.writeText("docker exec -it "+u.name+" sh").then(()=>B("\u5DF2\u590D\u5236\uFF1Adocker exec -it "+u.name+" sh")).catch(()=>B("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236"))}},a.id))});return d("div",{className:"dk_backdrop",onMouseDown:()=>t.onClose(),children:[d("div",{className:"dk_panel",onMouseDown:a=>a.stopPropagation(),children:[g!==null?[e(Xe,{item:g,target:r,targetLabel:y(r),config:n??{pollIntervalSec:5,logTailDefault:200,allowExec:!1,execTimeoutSec:30},initialTab:q.tab,refreshToken:_e,onBack:()=>Y(null),onRefresh:xe,onClose:t.onClose},"detail"),M===null?null:e(Me,{title:M.title,text:M.text,confirmLabel:M.confirmLabel,onCancel:()=>te(null),onConfirm:M.run},"confirm")]:[d("div",{className:"dk_header",children:[e("span",{className:"dk_titleIcon",dangerouslySetInnerHTML:{__html:Fe}}),e("span",{className:"dk_title",children:"Docker \u5BB9\u5668"}),n?.allowMutations===!0?null:e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"}),e("span",{className:"dk_headerSpacer"}),Q?e("span",{className:"dk_spin"}):null,g!==null?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868",onClick:ae,children:e("span",{dangerouslySetInnerHTML:{__html:Le}})}),e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:t.onClose,children:e("span",{dangerouslySetInnerHTML:{__html:Be}})})]}),g!==null?null:d("div",{className:"dk_toolbar",children:[e("select",{className:"dk_select",value:r,onChange:a=>{v(a.target.value),Y(null)},children:[...r===""?[e("option",{value:"",children:"\uFF08\u672A\u9009\u62E9\u76EE\u6807\uFF09"},"__none")]:[],...(k.length===0&&r!==""?[{name:r,label:void 0}]:k).map(a=>e("option",{value:a.name,children:y(a.name)},a.name))]}),e("div",{className:"dk_seg",children:[["containers","\u5BB9\u5668"],["images","\u955C\u50CF"]].map(([a,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":w===a?"1":"0",onClick:()=>{N(a),Y(null)},children:u},a))}),w==="containers"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u540D\u79F0 / \u955C\u50CF / ID",value:o,onChange:a=>s(a.target.value)}):null,w==="containers"?e("div",{className:"dk_seg",children:[["all","\u5168\u90E8"],["running","\u8FD0\u884C\u4E2D"],["stopped","\u5DF2\u505C\u6B62"],["unhealthy","\u4E0D\u5065\u5EB7"]].map(([a,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":p===a?"1":"0",onClick:()=>S(a),children:u},a))}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:z,onChange:a=>G(a.target.checked)}),"\u542B\u5DF2\u505C\u6B62"]}):null,e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:ee,onChange:a=>ge(a.target.checked)}),"\u81EA\u52A8\u5237\u65B0"]})]}),d("div",{className:"dk_body",children:[d("div",{className:"dk_main",children:[Z===""?null:e(V,{title:"\u64CD\u4F5C\u5931\u8D25",hint:Z}),P===""?null:e(V,{kind:"info",title:P}),t.sessionHint===void 0?null:e(V,{kind:"info",title:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u6CA1\u914D\u7F6E\u4E3A Docker \u76EE\u6807",hint:"\u4F1A\u8BDD\u4E3B\u673A\uFF1A"+t.sessionHint.host+(t.sessionHint.port===22?"":":"+String(t.sessionHint.port))+(t.sessionHint.book===""?"":"\uFF08\u8FDE\u63A5\u7C3F\uFF1A"+t.sessionHint.book+"\uFF09")+" \u2014 \u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761 kind=ssh \u76EE\u6807"+(t.sessionHint.book===""?"\uFF08\u586B host/username\uFF0C\u6216\u7528\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09":"\uFF0C\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\u300C"+t.sessionHint.book+"\u300D")+"\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u5373\u53EF\u3002"}),n!==null&&n.allowMutations!==!0?e(V,{kind:"info",title:"\u5F53\u524D\u4E3A\u53EA\u8BFB\u6A21\u5F0F",hint:"\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\u9700\u8981\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D\u3002"}):null,Ne()]})]}),M===null?null:e(Me,{title:M.title,text:M.text,confirmLabel:M.confirmLabel,onCancel:()=>te(null),onConfirm:M.run})],D===null?null:e(Qe,{label:D.label,hostRef:pe,onClose:()=>oe(null)},"execDrawer")]})]})}function et(){let[t,n]=h(!1),[i,k]=h(null),[_,r]=h(!1),[v,x]=h(!1),[w,N]=h({kind:"",text:""}),A=K(0),E=de(()=>{R.config().then(o=>{k(o.config),Te(o.config),A.current=Array.isArray(o.config?.targets)?o.config.targets.length:0,r(!0)}).catch(o=>{N({kind:"error",text:"\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25\uFF1A"+o.message}),r(!0)})},[]);C(()=>{t&&!_&&E()},[t,_,E]);let I=o=>k(s=>({...s,...o})),T=(o,s)=>k(p=>{let S=p.targets.slice();return S[o]={...S[o],...s},{...p,targets:S}}),Q=()=>k(o=>({...o,targets:[...o.targets,{name:"\u76EE\u6807"+String(o.targets.length+1),kind:"local",book:"",host:"",port:22,username:"",auth:"agent",keyPath:"",agentForward:!1,passwordSet:!1,passphraseSet:!1}]})),$=o=>k(s=>({...s,targets:s.targets.filter((p,S)=>S!==o)})),Z=o=>k(s=>({...s,hostKeys:s.hostKeys.filter(p=>!(p.host===o.host&&p.port===o.port))})),H=()=>{x(!0),N({kind:"",text:""});let o={enabled:i.enabled,announceToAgent:i.announceToAgent,dockerBin:i.dockerBin,allowMutations:i.allowMutations,allowExec:i.allowExec,execTimeoutSec:i.execTimeoutSec,pollIntervalSec:i.pollIntervalSec,logTailDefault:i.logTailDefault,maxOutputKb:i.maxOutputKb,targets:i.targets.map(s=>({name:s.name,kind:s.kind,book:s.book??"",host:s.host??"",port:Number(s.port)||22,username:s.username??"",auth:s.auth??"agent",keyPath:s.keyPath??"",...s.password===void 0||s.password===""?{}:{password:s.password},...s.passphrase===void 0||s.passphrase===""?{}:{passphrase:s.passphrase},agentForward:s.agentForward===!0})),hostKeys:i.hostKeys,...i.targets.length===0&&A.current>0?{clearTargets:!0}:{}};R.saveConfig(o).then(s=>{k(s.config),Te(s.config),A.current=Array.isArray(s.config?.targets)?s.config.targets.length:0,ve(),N(s.warning===void 0?{kind:"ok",text:"\u5DF2\u4FDD\u5B58\u5E76\u70ED\u751F\u6548"}:{kind:"error",text:s.warning})}).catch(s=>{N({kind:"error",text:"\u4FDD\u5B58\u5931\u8D25\uFF1A"+s.message})}).finally(()=>x(!1))},P=o=>e("div",{className:"dk_cardSection",children:o}),B=(o,s,p)=>d("div",{className:"dk_field",children:[e("span",{className:"dk_label",children:o}),s,p===void 0?null:e("span",{className:"dk_hint",children:p})]}),z=(o,s,p,S)=>e("input",{className:"dk_input",type:"number",min:s,max:p,value:i[o],onChange:ee=>I({[o]:Number(ee.target.value)})}),G=d("div",{className:"dk_targetHead",role:"button",tabIndex:0,style:{cursor:"pointer",padding:"10px 12px",border:"1px solid var(--dk-border)",borderRadius:"var(--dk-r-lg)",background:"var(--dk-surface-solid)"},onClick:()=>n(o=>!o),onKeyDown:o=>{o.key==="Enter"&&n(s=>!s)},children:[d("div",{children:[e("div",{style:{fontWeight:600,fontSize:13},children:"Docker \u5BB9\u5668\u9762\u677F"}),e("div",{className:"dk_hint",children:"\u672C\u673A / SSH \u4E3B\u673A\u4E0A\u7684\u5BB9\u5668\u4E0E\u955C\u50CF\uFF1B\u9ED8\u8BA4\u53EA\u8BFB\uFF0C\u53D8\u66F4\u64CD\u4F5C\u9700\u663E\u5F0F\u5F00\u542F"})]}),e("span",{style:{transform:t?"rotate(180deg)":"none",transition:"transform var(--dk-dur) var(--dk-ease)"},dangerouslySetInnerHTML:{__html:Ve}})]});return t?!_||i===null?d("div",{children:[G,e("div",{className:"dk_cardBody",children:d("div",{className:"dk_row",children:[e("span",{className:"dk_spin"}),"\u8BFB\u53D6\u914D\u7F6E\u2026"]})})]}):d("div",{children:[G,e("div",{className:"dk_cardBody",children:[P("\u57FA\u672C"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:i.enabled,onChange:o=>I({enabled:o.target.checked})}),"\u542F\u7528\u63D2\u4EF6"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:i.announceToAgent,onChange:o=>I({announceToAgent:o.target.checked})}),"\u5411 agent \u516C\u544A\u80FD\u529B"]})]}),d("div",{className:"dk_row",children:[B("docker CLI",e("input",{className:"dk_input",value:i.dockerBin,onChange:o=>I({dockerBin:o.target.value})}),"\u9ED8\u8BA4 docker\uFF1Bpodman \u53EF\u586B podman"),B("\u7EDF\u8BA1\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09",z("pollIntervalSec",1,60)),B("\u65E5\u5FD7\u9ED8\u8BA4\u884C\u6570",z("logTailDefault",1,5e3)),B("\u8F93\u51FA\u4E0A\u9650\uFF08KB\uFF09",z("maxOutputKb",1,8192)),B("exec \u8D85\u65F6\uFF08\u79D2\uFF09",z("execTimeoutSec",1,120))]}),P("\u80FD\u529B\u5F00\u5173\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF09"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:i.allowMutations,onChange:o=>I({allowMutations:o.target.checked})}),"\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\uFF08\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\uFF09"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:i.allowExec,onChange:o=>I({allowExec:o.target.checked})}),"\u5141\u8BB8 exec\uFF08\u5728\u5BB9\u5668\u5185\u6267\u884C\u547D\u4EE4\uFF09"]})]}),e("span",{className:"dk_hint",children:"docker socket \u7B49\u4EF7\u4E8E\u76EE\u6807\u4E3B\u673A\u7684 root \u6743\u9650\u3002\u5F00\u542F\u540E\uFF0C\u6D4F\u89C8\u5668\u9762\u677F\u4E0E agent \u90FD\u80FD\u6267\u884C\u5BF9\u5E94\u64CD\u4F5C\uFF0C\u8BF7\u53EA\u5728\u53EF\u4FE1\u73AF\u5883\u4E0B\u6253\u5F00\u3002"}),P("\u76EE\u6807"),...i.targets.map((o,s)=>d("div",{className:"dk_targetRow",children:[e("input",{className:"dk_input",value:o.name,placeholder:"\u76EE\u6807\u540D",onChange:p=>T(s,{name:p.target.value})}),e("select",{className:"dk_select",value:o.kind,onChange:p=>T(s,{kind:p.target.value}),children:[e("option",{value:"local",children:"\u672C\u673A"}),e("option",{value:"ssh",children:"SSH \u4E3B\u673A"})]}),o.kind==="local"?e("span",{className:"dk_hint",children:"\u5BBF\u4E3B\u6240\u5728\u673A\u5668\u4E0A\u7684 docker"}):d("div",{className:"dk_row",style:{gridColumn:"span 1"},children:[e("select",{className:"dk_select",value:o.book??"",onChange:p=>T(s,{book:p.target.value}),children:[e("option",{value:"",children:i.ttyBooks.length===0?"\uFF08\u65E0 tty \u8FDE\u63A5\u7C3F\uFF0C\u8BF7\u586B\u5185\u8054\u4FE1\u606F\uFF09":"\uFF08\u4E0D\u7528\u8FDE\u63A5\u7C3F\uFF0C\u624B\u586B\uFF09"}),...i.ttyBooks.map(p=>e("option",{value:p,children:"\u8FDE\u63A5\u7C3F\uFF1A"+p},p))]})]}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:()=>$(s),children:"\u5220\u9664"}),o.kind==="ssh"&&(o.book??"")===""?d("div",{className:"dk_row",style:{gridColumn:"1 / -1"},children:[e("input",{className:"dk_input",placeholder:"host",value:o.host??"",onChange:p=>T(s,{host:p.target.value})}),e("input",{className:"dk_input",style:{width:90},placeholder:"port",value:o.port??22,onChange:p=>T(s,{port:Number(p.target.value)||22})}),e("input",{className:"dk_input",placeholder:"username",value:o.username??"",onChange:p=>T(s,{username:p.target.value})}),e("select",{className:"dk_select",value:o.auth??"agent",onChange:p=>T(s,{auth:p.target.value}),children:[e("option",{value:"agent",children:"ssh-agent"}),e("option",{value:"key",children:"\u79C1\u94A5"}),e("option",{value:"password",children:"\u5BC6\u7801"})]}),(o.auth??"agent")==="key"?e("input",{className:"dk_input",placeholder:"~/.ssh/id_ed25519",value:o.keyPath??"",onChange:p=>T(s,{keyPath:p.target.value})}):null,(o.auth??"agent")==="password"?e("input",{className:"dk_input",type:"password",placeholder:o.passwordSet===!0?"\uFF08\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8\uFF09":"env:SSH_PASSWORD",value:o.password??"",onChange:p=>T(s,{password:p.target.value})}):null,e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.agentForward===!0,onChange:p=>T(s,{agentForward:p.target.checked})}),"agent forwarding"]})]}):null]},String(s)+o.name)),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn",onClick:Q,children:"\u6DFB\u52A0\u76EE\u6807"}),e("span",{className:"dk_hint",children:"SSH \u76EE\u6807\u63A8\u8350\u76F4\u63A5\u9009 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF08\u51ED\u8BC1\u53EA\u9700\u7EF4\u62A4\u4E00\u5904\uFF09\uFF1B\u624B\u586B\u65F6\u5BC6\u7801 / \u53E3\u4EE4\u5EFA\u8BAE\u5199 env:VAR\u3002"})]}),P("SSH \u4E3B\u673A\u5BC6\u94A5\u8BB0\u5F55\uFF08TOFU\uFF09"),...i.hostKeys.length===0?[e("span",{className:"dk_hint",children:"\u6682\u65E0\u8BB0\u5F55 \u2014 \u9996\u6B21 SSH \u8FDE\u63A5\u6210\u529F\u540E\u81EA\u52A8\u8BB0\u5F55\u4E3B\u673A\u6307\u7EB9\uFF08\u82E5 tty \u5DF2\u8BB0\u5F55\u540C\u4E00\u4E3B\u673A\uFF0C\u4F1A\u76F4\u63A5\u590D\u7528\uFF09\u3002"},"none")]:i.hostKeys.map(o=>d("div",{className:"dk_targetRow",children:[e("span",{children:o.host+":"+String(o.port)}),e("span",{className:"dk_hint",style:{gridColumn:"span 2",wordBreak:"break-all"},children:"sha256:"+o.fingerprint}),e("button",{type:"button",className:"dk_btn",onClick:()=>Z(o),children:"\u5220\u9664"})]},o.host+":"+String(o.port))),e("span",{className:"dk_hint",children:"\u6307\u7EB9\u53D8\u66F4\u65F6\u8FDE\u63A5\u4F1A\u88AB\u62D2\u7EDD\uFF08\u9632\u4E2D\u95F4\u4EBA\uFF09\uFF1B\u786E\u8BA4\u5B89\u5168\u540E\u5220\u9664\u5BF9\u5E94\u8BB0\u5F55\u5373\u53EF\u91CD\u8FDE\u3002"}),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:v,onClick:H,children:v?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58"}),e("span",{className:"dk_msg","data-kind":w.kind,children:w.text})]})]})]}):G}let J=null,X=null;function Re(){if(X!==null){let t=X;X=null,setTimeout(()=>t.unmount(),0)}if(J!==null){let t=J;J=null,setTimeout(()=>t.remove(),0)}}function De(t){if(J!==null){let n=J,i=X;J=null,X=null;try{i?.unmount()}catch{}n.remove()}Se(),J=document.createElement("div"),document.body.appendChild(J),X=O(J),X.render(e(Ze,{onClose:Re,initialTarget:t?.target??"",sessionHint:t?.sessionHint}))}function tt(){let t=document.querySelector('[data-pane="sidebar"], [class*="sidebarCol"]');if(t!==null)return t.querySelector('[class*="logoRow"]')?.parentElement??t.firstElementChild}function at(t){let n=t.querySelector('button[class*="newSession"]');if(n!==null)return n;for(let i of t.children)if(i.tagName==="BUTTON")return i}function nt(){let t=document.createElement("div");return t.dataset.dshDockerEntry="",t.className="dk_sidebarEntry",t.setAttribute("role","button"),t.setAttribute("aria-label","\u5BB9\u5668"),t.innerHTML='<span class="dk_entryIcon">'+Fe+'</span><span class="dk_entryLabel">\u5BB9\u5668</span>',t.addEventListener("click",n=>{n.preventDefault(),De()}),t}function Ae(t,n){let i=at(t);if(i===void 0)return!1;if(n.parentElement!==t){let k=i.closest('[class*="logoRow"]'),_=k!==null&&k.parentElement===t?k:i,r=Array.from(t.children).filter(v=>v instanceof HTMLElement&&v.matches("[data-dsh-global-search-entry], [data-dsh-rss-entry], [data-dsh-taskboard-entry], [data-dsh-ssh-entry], [data-dsh-tty-entry], [data-dsh-docker-entry]"));if(r.length>0){let v=r[r.length-1];t.insertBefore(n,v.nextSibling)}else t.insertBefore(n,_.nextElementSibling)}return!0}function rt(){if(Se(),document.querySelector("[data-dsh-docker-entry]")!==null)return()=>{};let t=nt(),n,i=!1,k=()=>{if(n!==void 0&&!n.isConnected&&(r.disconnect(),n=void 0,i=!1),i){if(document.body.contains(t))return;r.disconnect(),n=void 0,i=!1}n??(n=tt()),n!==void 0&&(i=Ae(n,t),i&&r.observe(n,{childList:!0,subtree:!0}))},_=new MutationObserver(()=>{k()});_.observe(document.body,{childList:!0,subtree:!0});let r=new MutationObserver(()=>{if(n===void 0||!n.isConnected){i=!1,k();return}n.contains(t)||(i=Ae(n,t))});return k(),()=>{_.disconnect(),r.disconnect(),t.remove()}}let be={};return be.inject=["slots"],be.apply=t=>{Se();let n=rt(),i=t.slots.inject("settings.plugin.item",()=>t.slots.register({name:"settings.plugin.item",key:"docker",order:112},et));t.inject(["ttyTerminal"],_=>(re=_.ttyTerminal??null,()=>{re=null}));let k=()=>{};return ve(),t.inject(["ttyConnbar"],_=>{let r=_.ttyConnbar;r!==void 0&&(k=r.addAction(v=>{let x=v?.spec??{};if(x.t!=="ssh")return;let w=typeof v?.bookName=="string"?v.bookName:"",N=Oe(x,w),A=N!==void 0?`\u6253\u5F00\u8BE5\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F\uFF08\u76EE\u6807\uFF1A${N}\uFF09`:ie===null?"\u6253\u5F00\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F":"\u8BE5\u4E3B\u673A\u5C1A\u672A\u914D\u7F6E\u4E3A Docker \u76EE\u6807 \u2014 \u70B9\u51FB\u6253\u5F00\u9762\u677F\u67E5\u770B/\u914D\u7F6E";v.addAction(gt,"\u5BB9\u5668",A,()=>{(async()=>{let E=await ut(x,w),I=Number(x.port);De({target:E??"",sessionHint:E===void 0?{host:typeof x.host=="string"?x.host:"",port:Number.isInteger(I)&&I>0?I:22,book:w}:void 0})})()})}),(async()=>{for(let v=0;v<3;v+=1){if(await ve()){typeof r.requestRender=="function"&&r.requestRender();return}await new Promise(x=>setTimeout(x,2e3))}})())}),()=>{k(),i(),n(),Re()}},be}});})();
1208
+ `+R.stderr)||"(\u65E0\u8F93\u51FA)"})]})]})]})},ne=()=>{let p=B!==null&&typeof B=="object"&&typeof B.text=="string"?B.text:"",_=M.trim().toLowerCase(),k=p===""?[]:p.split(`
1209
+ `),y=_===""?k:k.filter(L=>L.toLowerCase().includes(_));return{raw:p,needle:_,allLines:k,matchedLines:y}},me=(p,_,k)=>e("button",{type:"button",className:"dk_pill","data-on":p?"1":"0",onClick:k,children:_}),Ie=()=>{let{raw:p}=ne(),_=[...new Set([100,200,500,1e3,5e3,Number(o.logTailDefault)||200,Number(N.tail)||200])].filter(k=>Number.isInteger(k)&&k>0).sort((k,y)=>k-y);return d("div",{className:"dk_logTools",children:[e("span",{className:"dk_toolLabel",children:"LINES"}),e("select",{className:"dk_select dk_selectSm",value:String(N.tail),onChange:k=>j({...N,tail:Number(k.target.value)}),children:_.map(k=>e("option",{value:String(k),children:k===5e3?"Last 5000":"Last "+String(k)},String(k)))}),e("span",{className:"dk_toolLabel",children:"TIMESTAMPS"}),me(N.timestamps,N.timestamps?"On":"Off",()=>j({...N,timestamps:!N.timestamps})),e("span",{className:"dk_toolLabel",children:"AUTO REFRESH"}),me(S,S?"On":"Off",()=>F(k=>!k)),e("select",{className:"dk_select dk_selectSm",value:String(J),title:"\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u5F00\u542F AUTO REFRESH \u540E\u6309\u6B64\u8F6E\u8BE2\uFF09",onChange:k=>l(Number(k.target.value)),children:[2,3,5,10].map(k=>e("option",{value:String(k),children:String(k)+"s"},String(k)))}),Y?e("span",{className:"dk_spin"}):null,e(K,{icon:Ne,title:"\u5237\u65B0\u65E5\u5FD7",onClick:Q},"refresh"),e(K,{icon:zt,title:"\u4E0B\u8F7D\u65E5\u5FD7",disabled:p==="",onClick:()=>Mt(a.name+".log",p)},"download")]})},_e=()=>{let{needle:p,allLines:_,matchedLines:k}=ne();return d("div",{className:"dk_filterBar",children:[d("div",{className:"dk_filterWrap",children:[e("input",{className:"dk_input dk_filterInput",placeholder:"\u8FC7\u6EE4\u65E5\u5FD7\u2026",value:M,onChange:y=>O(y.target.value),onKeyDown:y=>{y.key==="Escape"&&M!==""&&(y.stopPropagation(),O(""))}}),M===""?null:e("button",{type:"button",className:"dk_filterClear",title:"\u6E05\u7A7A\u8FC7\u6EE4","aria-label":"\u6E05\u7A7A\u8FC7\u6EE4",onClick:()=>O(""),children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ce}})},"clear")]}),e("span",{className:"dk_filterCount",children:p===""?String(_.length)+" \u884C":String(k.length)+" / "+String(_.length)+" \u884C\u5339\u914D"})]})},Me=()=>{let{needle:p,matchedLines:_}=ne(),k=_.length>Le?_.slice(-Le):_;return d("div",{className:"dk_logs",children:[T===""?null:e(G,{title:"\u8BFB\u53D6\u65E5\u5FD7\u5931\u8D25",hint:T+(T.includes("Failed to fetch")?"\uFF08\u7F51\u7EDC\u8BF7\u6C42\u6CA1\u5230\u5BBF\u4E3B\uFF1A\u5BBF\u4E3B\u53EF\u80FD\u521A\u91CD\u542F\u3001\u6216\u8FDE\u63A5\u88AB\u4E2D\u65AD\uFF09":""),action:e("button",{type:"button",className:"dk_btn",disabled:Y,onClick:Q,children:"\u91CD\u8BD5"})}),B!==null&&B.truncated===!0?e(G,{kind:"warn",title:"\u65E5\u5FD7\u8F93\u51FA\u8D85\u8FC7\u4E0A\u9650\uFF0C\u5DF2\u622A\u65AD",hint:"\u8C03\u5C0F\u300CLINES\u300D\u6216\u5230\u8BBE\u7F6E\u5361\u7247\u8C03\u5927\u300C\u5355\u6B21\u547D\u4EE4\u8F93\u51FA\u4E0A\u9650\u300D\u3002"}):null,d("div",{className:"dk_logBody",children:[_.length>k.length?e("div",{className:"dk_logLine dk_logMore",children:"\uFF08\u53EA\u663E\u793A\u6700\u8FD1 "+String(Le)+" \u884C\uFF0C\u5171 "+String(_.length)+" \u884C\u5339\u914D\uFF09"},"more"):null,T!==""?null:B===null?e("div",{className:"dk_logLine",children:"\u8BFB\u53D6\u4E2D\u2026"},"loading"):k.length===0?e("div",{className:"dk_logLine",children:p===""?"(\u65E0\u65E5\u5FD7)":"(\u65E0\u5339\u914D\u65E5\u5FD7)"},"empty"):k.map((y,L)=>ct(y,L,p))]})]})},Oe=()=>{if(z!=="")return e(G,{title:"\u8BFB\u53D6\u7EDF\u8BA1\u5931\u8D25",hint:z});if(s===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let p=s.cpuPercent??0,_=s.memPercent??0,k=L=>d("div",{className:"dk_bar",children:[e("div",{className:"dk_barFill","data-warn":L>=60&&L<85?"1":void 0,"data-danger":L>=85?"1":void 0,style:{width:Math.min(100,Math.max(0,L))+"%"}})]}),y=(L,xe,De)=>d("tr",{children:[e("td",{children:L}),e("td",{className:"dk_num",children:xe}),e("td",{children:De??null})]},L);return d("table",{className:"dk_stats",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u6307\u6807"}),e("th",{children:"\u6570\u503C"}),e("th",{children:"\u5360\u7528"})]})}),e("tbody",{children:[y("CPU",Lt(s.cpuPercent),k(p)),y("\u5185\u5B58",s.memUsage,k(_)),y("\u7F51\u7EDC IO",s.netIO,null),y("\u78C1\u76D8 IO",s.blockIO,null),y("PIDs",s.pids===null?"\u2014":String(s.pids),null)]})]})},Re=[["overview","\u6982\u89C8"],["logs","\u65E5\u5FD7"],["stats","\u7EDF\u8BA1"]],fe=c==="overview"?r===null&&x==="":c==="stats"?s===null&&z==="":!1;return d("div",{className:"dk_detail",children:[d("div",{className:"dk_header dk_headerDetail",children:[e(K,{icon:Gt,title:"\u8FD4\u56DE\u5BB9\u5668\u5217\u8868",onClick:t.onBack},"back"),e("span",{className:"dk_detailTitle",title:a.name,children:a.name}),e(Ve,{state:a.state,health:a.health,status:a.status}),e("span",{className:"dk_detailSub",children:t.targetLabel??""}),e("span",{className:"dk_headerSpacer"}),c==="logs"?Ie():e(K,{icon:Ne,title:"\u5237\u65B0",spin:fe,onClick:t.onRefresh},"refresh"),t.docked===!0?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:t.onClose,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ce}})},"close")]}),d("div",{className:"dk_tabs",children:[...Re.map(([p,_])=>e("button",{type:"button",className:"dk_tab","data-on":c===p?"1":"0",onClick:()=>v(p),children:_},p)),c==="logs"?e("span",{className:"dk_headerSpacer"},"spacer"):null,c==="logs"?_e():null]}),e("div",{className:"dk_detailBody",children:c==="overview"?W():c==="logs"?Me():Oe()})]})}function ut(t){let a=t.collapsed===!0;return d("div",{className:"dk_drawer","data-collapsed":a?"1":void 0,style:a||t.height===null?void 0:{height:String(t.height)+"px"},children:[e("div",{className:"dk_drawerResize",title:"\u62D6\u52A8\u8C03\u6574\u7EC8\u7AEF\u9AD8\u5EA6\uFF08\u53CC\u51FB\u6298\u53E0 / \u5C55\u5F00\uFF09",onMouseDown:t.onResizeStart,onDoubleClick:t.onToggleCollapse},"resize"),d("div",{className:"dk_drawerHead",children:[e("span",{className:"dk_drawerIcon",dangerouslySetInnerHTML:{__html:nt}}),e("span",{className:"dk_drawerTitle",title:t.label,children:t.label}),e("span",{className:"dk_drawerHint",children:a?"\u5DF2\u6298\u53E0 \xB7 \u4F1A\u8BDD\u4FDD\u6301\u8FD0\u884C":"\u7531\u7EC8\u7AEF\u9762\u677F\u627F\u8F7D \xB7 \u6298\u53E0\u4FDD\u7559\u4F1A\u8BDD"}),e("span",{className:"dk_headerSpacer"}),e("button",{type:"button",className:"dk_iconBtn dk_drawerFold",title:a?"\u5C55\u5F00\u7EC8\u7AEF\uFF08\u4F1A\u8BDD\u672A\u4E2D\u65AD\uFF09":"\u6298\u53E0\u7EC8\u7AEF\uFF08\u4F1A\u8BDD\u4FDD\u6301\u8FD0\u884C\uFF09",onClick:t.onToggleCollapse,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:at}})},"fold"),e("button",{type:"button",className:"dk_iconBtn",title:"\u7ED3\u675F\u7EC8\u7AEF\u4F1A\u8BDD\u5E76\u6536\u8D77\u62BD\u5C49",onClick:t.onClose,children:e("span",{dangerouslySetInnerHTML:{__html:Ce}})},"close")]}),e("div",{className:"dk_drawerBody",ref:t.hostRef})]})}function Ge(t){let[a,o]=g(null),[c,v]=g([]),[r,b]=g(t.initialTarget??""),x=t.sessionHint!==void 0&&(t.initialTarget??"")==="",[w,N]=g("containers"),[j,B]=g([]),[I,T]=g([]),[$,Y]=g(!1),[ee,M]=g(""),[O,S]=g(""),[F,J]=g(!0),[l,s]=g(""),[h,z]=g("all"),[q,ge]=g(!1),[X,R]=g(null),[be,he]=g(0),[D,te]=g(null),[pe,Q]=g(""),U=P(!0),[W,ne]=g(null),me=P(null),[Ie,_e]=g(!1),[Me,Oe]=g(null),[Re,fe]=g(!1),p=P(null),_=P(!1);C(()=>()=>{U.current=!1},[]),C(()=>{if(W===null)return;let n=me.current;if(n===null)return;let u=null;try{u=Z.mount(n,W.options)}catch(f){S("\u7EC8\u7AEF\u542F\u52A8\u5931\u8D25\uFF1A"+(f instanceof Error?f.message:String(f))),ne(null);return}return()=>{try{u?.()}catch{}}},[W]);let k=n=>{if(n.button!==void 0&&n.button!==0)return;let u=n.currentTarget.parentElement,f=p.current;if(u===null||f===null)return;n.preventDefault();let ie=n.clientY,se=u.getBoundingClientRect().height,A=Math.max(160,Math.round(f.getBoundingClientRect().height*.75)),$e=Nt=>{let Ct=Math.round(se+(ie-Nt.clientY));Oe(Math.min(A,Math.max(160,Ct)))},qe=()=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",qe),document.body.style.userSelect=""};document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",qe)},y=()=>{if(W===null){t.onClose();return}fe(!0)};C(()=>{H.config().then(n=>{let u=n.config;o(u),!x&&Array.isArray(u.targets)&&u.targets.length>0&&b(f=>f===""?u.targets[0].name:f),ze(u)}).catch(n=>M(n.message)),H.targets().then(n=>{v(n.targets??[]),Fe=n.targets??[];let u=(n.targets??[])[0];u!==void 0&&!x&&b(f=>f===""?u.name:f)}).catch(()=>{})},[]);let L=de(()=>{r!==""&&(Y(!0),H.containers(r,F).then(n=>{U.current&&(B(n.containers??[]),M(""))}).catch(n=>{U.current&&M(n.message)}).finally(()=>{U.current&&Y(!1)}))},[r,F]),xe=de(()=>{r!==""&&(Y(!0),H.images(r).then(n=>{U.current&&(T(n.images??[]),M(""))}).catch(n=>{U.current&&M(n.message)}).finally(()=>{U.current&&Y(!1)}))},[r]),De=de(()=>he(n=>n+1),[]),le=de(()=>{w==="images"?xe():L(),he(n=>n+1)},[w,L,xe]);C(()=>{r!==""&&le()},[r,F,w]),C(()=>{if(!q||r===""||w!=="containers")return;let n=setInterval(le,Math.max(2,a?.pollIntervalSec??5)*1e3);return()=>clearInterval(n)},[q,le,r,a,w]),C(()=>{if(O==="")return;let n=setTimeout(()=>S(""),4e3);return()=>clearTimeout(n)},[O]);let we=(n,u)=>{let f=et(n.name);navigator.clipboard.writeText(f).then(()=>{S("\u5DF2\u590D\u5236\uFF1A"+f+(u===void 0?"":"\uFF08"+u+"\uFF09"))}).catch(()=>S("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C\uFF1A"+f))},_t=n=>{let u=et(n.name);if(Z===null){let A=document.querySelector("[data-dsh-tty-entry]")!==null;we(n,A?"\u7EC8\u7AEF\u9762\u677F\u7248\u672C\u8FC7\u65E7\uFF08\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u9700\u8981 dsh-tty \u2265 0.14.0\uFF09\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C":"\u672A\u5B89\u88C5 dsh-tty \u7EC8\u7AEF\u9762\u677F\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C\uFF08\u88C5 dsh-tty \u540E\u53EF\u76F4\u63A5\u5728\u6B64\u5F00\u7EC8\u7AEF\uFF09");return}let f=(a?.targets??[]).find(A=>A.name===r),ie=n.name+" \xB7 exec",se=f===void 0||f.kind==="local"?{command:u,label:ie}:typeof f.book=="string"&&f.book!==""?{book:f.book,command:u,label:ie}:(f.auth??"agent")==="agent"?{spec:{host:f.host,port:f.port,username:f.username,auth:"agent",agentForward:f.agentForward===!0},command:u,label:ie}:null;if(se===null){we(n,"\u5185\u8054\u76EE\u6807\u7528\u4E86 key/password \u8BA4\u8BC1\uFF0C\u6D4F\u89C8\u5668\u7AEF\u62FF\u4E0D\u5230\u51ED\u8BC1");return}if(t.docked===!0){try{Z.open(se)}catch(A){we(n,A instanceof Error?A.message:String(A))}return}if(typeof Z.mount=="function"&&Number(Z.version??0)>=2){ne({label:ie,options:se}),_e(!1);return}try{Z.open(se),t.onClose()}catch(A){we(n,A instanceof Error?A.message:String(A))}},xt=(n,u)=>{te({title:n==="remove"?"\u5220\u9664\u5BB9\u5668":n==="stop"?"\u505C\u6B62\u5BB9\u5668":n==="start"?"\u542F\u52A8\u5BB9\u5668":"\u91CD\u542F\u5BB9\u5668",text:n==="remove"?`\u786E\u5B9A\u5220\u9664\u5BB9\u5668 ${u.name}\uFF1F\u5BB9\u5668\u7684\u53EF\u5199\u5C42\u4E0E\u914D\u7F6E\u4F1A\u88AB\u5220\u9664\uFF08\u547D\u540D\u6570\u636E\u5377\u4FDD\u7559\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`:`\u786E\u5B9A\u5BF9\u5BB9\u5668 ${u.name} \u6267\u884C${n==="stop"?"\u505C\u6B62":n==="start"?"\u542F\u52A8":"\u91CD\u542F"}\u64CD\u4F5C\uFF1F`,confirmLabel:n==="remove"?"\u5220\u9664":"\u786E\u5B9A",run:()=>{te(null),H.action(r,n,u.id).then(f=>{S(`${f.result.action} ${u.name}\uFF1A${f.result.message}`),le()}).catch(f=>M(f.message))}})},ye=X===null?null:j.find(n=>n.id===X.id)??X.item,We=j.filter(n=>{if(h==="running"&&!(n.state==="running"||n.state==="paused"||n.state==="restarting")||h==="stopped"&&n.state==="running"||h==="unhealthy"&&n.health!=="unhealthy")return!1;let u=l.trim().toLowerCase();return u===""?!0:n.name.toLowerCase().includes(u)||n.image.toLowerCase().includes(u)||n.id.toLowerCase().includes(u)}),Ae=I.filter(n=>{let u=pe.trim().toLowerCase();return u===""||n.reference.toLowerCase().includes(u)||n.id.toLowerCase().includes(u)}),He=n=>{let u=c.find(f=>f.name===n);return u===void 0||u.label===void 0?n:n+" \xB7 "+u.label},Ye=()=>$?e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]}):r===""?x?d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u4E0D\u662F Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u6309\u4E0A\u9762\u7684\u63D0\u793A\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761\u76EE\u6807\uFF08\u63A8\u8350\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u3002\u4E3A\u907F\u514D\u5F20\u51A0\u674E\u6234\uFF0C\u9762\u677F\u4E0D\u4F1A\u81EA\u52A8\u5207\u5230\u5176\u4ED6\u76EE\u6807\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u8FD8\u6CA1\u6709\u914D\u7F6E Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u4E2A\u76EE\u6807\uFF1A\u672C\u673A\u76F4\u63A5\u9009\u300C\u672C\u673A\u300D\uFF1B\u8FDC\u7A0B\u4E3B\u673A\u53EF\u4EE5\u5F15\u7528 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:w==="images"?"\u6CA1\u6709\u955C\u50CF":"\u6CA1\u6709\u5BB9\u5668"}),e("div",{className:"dk_emptyHint",children:l.trim()===""?"\u76EE\u6807\u4E0A\u6CA1\u6709\u5339\u914D\u7684\u6570\u636E\uFF0C\u6216\u7B5B\u9009\u6761\u4EF6\u8FC7\u7A84\u3002":"\u6CA1\u6709\u5339\u914D\u300C"+l.trim()+"\u300D\u7684\u7ED3\u679C\u3002"})]}),wt=()=>w==="images"?d("div",{className:"dk_imagesView",children:[Ae.length===0?Ye():e("div",{className:"dk_tableWrap",children:d("table",{className:"dk_images",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u955C\u50CF"}),e("th",{children:"\u5927\u5C0F"}),e("th",{children:"\u521B\u5EFA"}),e("th",{children:"ID"})]})}),e("tbody",{children:Ae.map(n=>d("tr",{children:[e("td",{className:"dk_mono",children:n.reference}),e("td",{children:n.sizeText}),e("td",{children:n.createdSince}),e("td",{className:"dk_mono",children:n.shortId})]},n.id+n.reference))})]})})]}):We.length===0?Ye():e("div",{className:"dk_grid",children:We.map(n=>e(ot,{item:n,selected:X!==null&&n.id===X.id,allowMutations:a?.allowMutations===!0,onOpen:(u,f)=>R({id:u.id,tab:f,item:u}),onExec:_t,onAction:xt,onCopyExec:u=>{navigator.clipboard.writeText("docker exec -it "+u.name+" sh").then(()=>S("\u5DF2\u590D\u5236\uFF1Adocker exec -it "+u.name+" sh")).catch(()=>S("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236"))}},n.id))}),ae=t.docked===!0,yt=[ye!==null?[e(kt,{item:ye,target:r,targetLabel:He(r),config:a??{pollIntervalSec:5,logTailDefault:200,allowExec:!1,execTimeoutSec:30},initialTab:X.tab,refreshToken:be,onBack:()=>R(null),onRefresh:De,onClose:y,docked:ae},"detail"),D===null?null:e(Te,{title:D.title,text:D.text,confirmLabel:D.confirmLabel,onCancel:()=>te(null),onConfirm:D.run},"confirm")]:[ae?null:d("div",{className:"dk_header",children:[e("span",{className:"dk_titleIcon",dangerouslySetInnerHTML:{__html:tt}}),e("span",{className:"dk_title",children:"Docker \u5BB9\u5668"}),a?.allowMutations===!0?null:e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"}),e("span",{className:"dk_headerSpacer"}),ye!==null?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868","data-spin":$?"1":void 0,onClick:le,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ne}})}),e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:y,children:e("span",{dangerouslySetInnerHTML:{__html:Ce}})})]}),ye!==null?null:d("div",{className:"dk_toolbar",children:[ae?e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868","data-spin":$?"1":void 0,onClick:le,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ne}})},"refresh"):null,ae&&a?.allowMutations!==!0?e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"},"readonly"):null,e("select",{className:"dk_select",value:r,onChange:n=>{b(n.target.value),R(null),t.onTargetChange?.(He(n.target.value))},children:[...r===""?[e("option",{value:"",children:"\uFF08\u672A\u9009\u62E9\u76EE\u6807\uFF09"},"__none")]:[],...(c.length===0&&r!==""?[{name:r,label:void 0}]:c).map(n=>e("option",{value:n.name,children:He(n.name)},n.name))]}),e("div",{className:"dk_seg",children:[["containers","\u5BB9\u5668"],["images","\u955C\u50CF"]].map(([n,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":w===n?"1":"0",onClick:()=>{N(n),R(null)},children:u},n))}),w==="containers"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u540D\u79F0 / \u955C\u50CF / ID",value:l,onChange:n=>s(n.target.value)}):null,w==="images"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u955C\u50CF\uFF08\u4ED3\u5E93 / \u6807\u7B7E / ID\uFF09",value:pe,onChange:n=>Q(n.target.value)}):null,w==="images"?e("span",{className:"dk_hint dk_searchCount",children:String(Ae.length)+" / "+String(I.length)+" \u4E2A\u955C\u50CF"}):null,w==="containers"?e("div",{className:"dk_seg",children:[["all","\u5168\u90E8"],["running","\u8FD0\u884C\u4E2D"],["stopped","\u5DF2\u505C\u6B62"],["unhealthy","\u4E0D\u5065\u5EB7"]].map(([n,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":h===n?"1":"0",onClick:()=>z(n),children:u},n))}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:F,onChange:n=>J(n.target.checked)}),"\u542B\u5DF2\u505C\u6B62"]}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:q,onChange:n=>ge(n.target.checked)}),"\u81EA\u52A8\u5237\u65B0"]}):null]}),d("div",{className:"dk_body",children:[d("div",{className:"dk_main"+(w==="images"?" dk_mainImages":""),children:[ee===""?null:e(G,{title:"\u64CD\u4F5C\u5931\u8D25",hint:ee}),O===""?null:e(G,{kind:"info",title:O}),t.sessionHint===void 0?null:e(G,{kind:"info",title:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u6CA1\u914D\u7F6E\u4E3A Docker \u76EE\u6807",hint:"\u4F1A\u8BDD\u4E3B\u673A\uFF1A"+t.sessionHint.host+(t.sessionHint.port===22?"":":"+String(t.sessionHint.port))+(t.sessionHint.book===""?"":"\uFF08\u8FDE\u63A5\u7C3F\uFF1A"+t.sessionHint.book+"\uFF09")+" \u2014 \u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761 kind=ssh \u76EE\u6807"+(t.sessionHint.book===""?"\uFF08\u586B host/username\uFF0C\u6216\u7528\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09":"\uFF0C\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\u300C"+t.sessionHint.book+"\u300D")+"\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u5373\u53EF\u3002"}),a!==null&&a.allowMutations!==!0?e(G,{kind:"info",title:"\u5F53\u524D\u4E3A\u53EA\u8BFB\u6A21\u5F0F",hint:"\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\u9700\u8981\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D\u3002"}):null,wt()]})]}),D===null?null:e(Te,{title:D.title,text:D.text,confirmLabel:D.confirmLabel,onCancel:()=>te(null),onConfirm:D.run})],W===null?null:e(ut,{label:W.label,hostRef:me,collapsed:Ie,height:Me,onToggleCollapse:()=>_e(n=>!n),onResizeStart:k,onClose:()=>ne(null)},"execDrawer"),Re&&W!==null?e(Te,{title:"\u7ED3\u675F\u5BB9\u5668\u7EC8\u7AEF\u4F1A\u8BDD",text:"\u5173\u95ED\u9762\u677F\u4F1A\u7ED3\u675F\u300C"+W.label+"\u300D\u7684\u7EC8\u7AEF\u4F1A\u8BDD\uFF08docker exec -it \u2026\uFF09\u3002\u82E5\u53EA\u662F\u60F3\u7ED9\u65E5\u5FD7 / \u5217\u8868\u817E\u5730\u65B9\uFF0C\u5148\u70B9\u62BD\u5C49\u53F3\u4E0A\u89D2\u7684\u6298\u53E0\u6309\u94AE\u5373\u53EF\uFF0C\u4F1A\u8BDD\u4F1A\u4FDD\u6301\u8FD0\u884C\u3002",confirmLabel:"\u7ED3\u675F\u5E76\u5173\u95ED",onCancel:()=>fe(!1),onConfirm:()=>{fe(!1),t.onClose()}},"closeConfirm"):null],Je=d("div",{className:"dk_panel"+(ae?" dk_panelDock":""),"data-dock":ae?"1":void 0,ref:p,onMouseDown:n=>n.stopPropagation(),children:yt});return ae?Je:d("div",{className:"dk_backdrop",onMouseDown:n=>{_.current=n.target===n.currentTarget},onMouseUp:n=>{let u=_.current&&n.target===n.currentTarget;_.current=!1,u&&y()},children:[Je]})}function gt(){let[t,a]=g(!1),[o,c]=g(null),[v,r]=g(!1),[b,x]=g(!1),[w,N]=g({kind:"",text:""}),j=P(0),B=de(()=>{H.config().then(l=>{c(l.config),ze(l.config),j.current=Array.isArray(l.config?.targets)?l.config.targets.length:0,r(!0)}).catch(l=>{N({kind:"error",text:"\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25\uFF1A"+l.message}),r(!0)})},[]);C(()=>{t&&!v&&B()},[t,v,B]);let I=l=>c(s=>({...s,...l})),T=(l,s)=>c(h=>{let z=h.targets.slice();return z[l]={...z[l],...s},{...h,targets:z}}),$=()=>c(l=>({...l,targets:[...l.targets,{name:"\u76EE\u6807"+String(l.targets.length+1),kind:"local",book:"",host:"",port:22,username:"",auth:"agent",keyPath:"",agentForward:!1,passwordSet:!1,passphraseSet:!1}]})),Y=l=>c(s=>({...s,targets:s.targets.filter((h,z)=>z!==l)})),ee=l=>c(s=>({...s,hostKeys:s.hostKeys.filter(h=>!(h.host===l.host&&h.port===l.port))})),M=()=>{x(!0),N({kind:"",text:""});let l={enabled:o.enabled,announceToAgent:o.announceToAgent,dockerBin:o.dockerBin,allowMutations:o.allowMutations,allowExec:o.allowExec,execTimeoutSec:o.execTimeoutSec,pollIntervalSec:o.pollIntervalSec,logTailDefault:o.logTailDefault,maxOutputKb:o.maxOutputKb,targets:o.targets.map(s=>({name:s.name,kind:s.kind,book:s.book??"",host:s.host??"",port:Number(s.port)||22,username:s.username??"",auth:s.auth??"agent",keyPath:s.keyPath??"",...s.password===void 0||s.password===""?{}:{password:s.password},...s.passphrase===void 0||s.passphrase===""?{}:{passphrase:s.passphrase},agentForward:s.agentForward===!0})),hostKeys:o.hostKeys,...o.targets.length===0&&j.current>0?{clearTargets:!0}:{}};H.saveConfig(l).then(s=>{c(s.config),ze(s.config),j.current=Array.isArray(s.config?.targets)?s.config.targets.length:0,Se(),N(s.warning===void 0?{kind:"ok",text:"\u5DF2\u4FDD\u5B58\u5E76\u70ED\u751F\u6548"}:{kind:"error",text:s.warning})}).catch(s=>{N({kind:"error",text:"\u4FDD\u5B58\u5931\u8D25\uFF1A"+s.message})}).finally(()=>x(!1))},O=l=>e("div",{className:"dk_cardSection",children:l}),S=(l,s,h)=>d("div",{className:"dk_field",children:[e("span",{className:"dk_label",children:l}),s,h===void 0?null:e("span",{className:"dk_hint",children:h})]}),F=(l,s,h,z)=>e("input",{className:"dk_input",type:"number",min:s,max:h,value:o[l],onChange:q=>I({[l]:Number(q.target.value)})}),J=l=>d("li",{className:"dk_settingsCard"+(t?" dk_settingsCardOpen":""),children:[d("button",{type:"button",className:"dk_settingsHead","aria-expanded":t,onClick:()=>a(s=>!s),children:[d("span",{className:"dk_settingsHeadText",children:[e("span",{className:"dk_settingsName",children:"Docker \u5BB9\u5668\u9762\u677F"}),e("span",{className:"dk_settingsDesc",children:"\u672C\u673A / SSH \u4E3B\u673A\u4E0A\u7684\u5BB9\u5668\u4E0E\u955C\u50CF\uFF1B\u9ED8\u8BA4\u53EA\u8BFB\uFF0C\u53D8\u66F4\u64CD\u4F5C\u9700\u663E\u5F0F\u5F00\u542F"})]}),e("span",{className:"dk_settingsChevron",dangerouslySetInnerHTML:{__html:at}})]}),t?e("div",{className:"dk_settingsBody",children:l}):null]});return J(t?!v||o===null?d("div",{className:"dk_row",children:[e("span",{className:"dk_spin"}),"\u8BFB\u53D6\u914D\u7F6E\u2026"]}):[O("\u57FA\u672C"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.enabled,onChange:l=>I({enabled:l.target.checked})}),"\u542F\u7528\u63D2\u4EF6"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.announceToAgent,onChange:l=>I({announceToAgent:l.target.checked})}),"\u5411 agent \u516C\u544A\u80FD\u529B"]})]}),d("div",{className:"dk_row",children:[S("docker CLI",e("input",{className:"dk_input",value:o.dockerBin,onChange:l=>I({dockerBin:l.target.value})}),"\u9ED8\u8BA4 docker\uFF1Bpodman \u53EF\u586B podman"),S("\u7EDF\u8BA1\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09",F("pollIntervalSec",1,60)),S("\u65E5\u5FD7\u9ED8\u8BA4\u884C\u6570",F("logTailDefault",1,5e3)),S("\u8F93\u51FA\u4E0A\u9650\uFF08KB\uFF09",F("maxOutputKb",1,8192)),S("exec \u8D85\u65F6\uFF08\u79D2\uFF09",F("execTimeoutSec",1,120))]}),O("\u80FD\u529B\u5F00\u5173\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF09"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.allowMutations,onChange:l=>I({allowMutations:l.target.checked})}),"\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\uFF08\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\uFF09"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.allowExec,onChange:l=>I({allowExec:l.target.checked})}),"\u5141\u8BB8 exec\uFF08\u5728\u5BB9\u5668\u5185\u6267\u884C\u547D\u4EE4\uFF09"]})]}),e("span",{className:"dk_hint",children:"docker socket \u7B49\u4EF7\u4E8E\u76EE\u6807\u4E3B\u673A\u7684 root \u6743\u9650\u3002\u5F00\u542F\u540E\uFF0C\u6D4F\u89C8\u5668\u9762\u677F\u4E0E agent \u90FD\u80FD\u6267\u884C\u5BF9\u5E94\u64CD\u4F5C\uFF0C\u8BF7\u53EA\u5728\u53EF\u4FE1\u73AF\u5883\u4E0B\u6253\u5F00\u3002"}),O("\u76EE\u6807"),...o.targets.map((l,s)=>d("div",{className:"dk_targetRow",children:[e("input",{className:"dk_input",value:l.name,placeholder:"\u76EE\u6807\u540D",onChange:h=>T(s,{name:h.target.value})}),e("select",{className:"dk_select",value:l.kind,onChange:h=>T(s,{kind:h.target.value}),children:[e("option",{value:"local",children:"\u672C\u673A"}),e("option",{value:"ssh",children:"SSH \u4E3B\u673A"})]}),l.kind==="local"?e("span",{className:"dk_hint",children:"\u5BBF\u4E3B\u6240\u5728\u673A\u5668\u4E0A\u7684 docker"}):d("div",{className:"dk_row",style:{gridColumn:"span 1"},children:[e("select",{className:"dk_select",value:l.book??"",onChange:h=>T(s,{book:h.target.value}),children:[e("option",{value:"",children:o.ttyBooks.length===0?"\uFF08\u65E0 tty \u8FDE\u63A5\u7C3F\uFF0C\u8BF7\u586B\u5185\u8054\u4FE1\u606F\uFF09":"\uFF08\u4E0D\u7528\u8FDE\u63A5\u7C3F\uFF0C\u624B\u586B\uFF09"}),...o.ttyBooks.map(h=>e("option",{value:h,children:"\u8FDE\u63A5\u7C3F\uFF1A"+h},h))]})]}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:()=>Y(s),children:"\u5220\u9664"}),l.kind==="ssh"&&(l.book??"")===""?d("div",{className:"dk_row",style:{gridColumn:"1 / -1"},children:[e("input",{className:"dk_input",placeholder:"host",value:l.host??"",onChange:h=>T(s,{host:h.target.value})}),e("input",{className:"dk_input",style:{width:90},placeholder:"port",value:l.port??22,onChange:h=>T(s,{port:Number(h.target.value)||22})}),e("input",{className:"dk_input",placeholder:"username",value:l.username??"",onChange:h=>T(s,{username:h.target.value})}),e("select",{className:"dk_select",value:l.auth??"agent",onChange:h=>T(s,{auth:h.target.value}),children:[e("option",{value:"agent",children:"ssh-agent"}),e("option",{value:"key",children:"\u79C1\u94A5"}),e("option",{value:"password",children:"\u5BC6\u7801"})]}),(l.auth??"agent")==="key"?e("input",{className:"dk_input",placeholder:"~/.ssh/id_ed25519",value:l.keyPath??"",onChange:h=>T(s,{keyPath:h.target.value})}):null,(l.auth??"agent")==="password"?e("input",{className:"dk_input",type:"password",placeholder:l.passwordSet===!0?"\uFF08\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8\uFF09":"env:SSH_PASSWORD",value:l.password??"",onChange:h=>T(s,{password:h.target.value})}):null,e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:l.agentForward===!0,onChange:h=>T(s,{agentForward:h.target.checked})}),"agent forwarding"]})]}):null]},String(s)+l.name)),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn",onClick:$,children:"\u6DFB\u52A0\u76EE\u6807"}),e("span",{className:"dk_hint",children:"SSH \u76EE\u6807\u63A8\u8350\u76F4\u63A5\u9009 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF08\u51ED\u8BC1\u53EA\u9700\u7EF4\u62A4\u4E00\u5904\uFF09\uFF1B\u624B\u586B\u65F6\u5BC6\u7801 / \u53E3\u4EE4\u5EFA\u8BAE\u5199 env:VAR\u3002"})]}),O("SSH \u4E3B\u673A\u5BC6\u94A5\u8BB0\u5F55\uFF08TOFU\uFF09"),...o.hostKeys.length===0?[e("span",{className:"dk_hint",children:"\u6682\u65E0\u8BB0\u5F55 \u2014 \u9996\u6B21 SSH \u8FDE\u63A5\u6210\u529F\u540E\u81EA\u52A8\u8BB0\u5F55\u4E3B\u673A\u6307\u7EB9\uFF08\u82E5 tty \u5DF2\u8BB0\u5F55\u540C\u4E00\u4E3B\u673A\uFF0C\u4F1A\u76F4\u63A5\u590D\u7528\uFF09\u3002"},"none")]:o.hostKeys.map(l=>d("div",{className:"dk_targetRow",children:[e("span",{children:l.host+":"+String(l.port)}),e("span",{className:"dk_hint",style:{gridColumn:"span 2",wordBreak:"break-all"},children:"sha256:"+l.fingerprint}),e("button",{type:"button",className:"dk_btn",onClick:()=>ee(l),children:"\u5220\u9664"})]},l.host+":"+String(l.port))),e("span",{className:"dk_hint",children:"\u6307\u7EB9\u53D8\u66F4\u65F6\u8FDE\u63A5\u4F1A\u88AB\u62D2\u7EDD\uFF08\u9632\u4E2D\u95F4\u4EBA\uFF09\uFF1B\u786E\u8BA4\u5B89\u5168\u540E\u5220\u9664\u5BF9\u5E94\u8BB0\u5F55\u5373\u53EF\u91CD\u8FDE\u3002"}),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:b,onClick:M,children:b?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58"}),e("span",{className:"dk_msg","data-kind":w.kind,children:w.text})]})]:null)}let ue=null,oe=null,Ee=null;function ve(){let t=oe,a=ue,o=Ee;if(oe=null,ue=null,Ee=null,a!==null&&a.remove(),t!==null&&setTimeout(()=>{try{t.unmount()}catch{}},0),o!==null)try{o.dispose()}catch{}}function ht(t){return t!==null&&typeof t=="object"&&typeof t.appendChild=="function"}function pt(){return typeof re?.mountPane=="function"&&typeof re.isOpen=="function"&&Number(re.version??0)>=1&&re.isOpen()===!0}function Ke(t){ve(),Pe();let a={onClose:ve,initialTarget:t?.target??"",sessionHint:t?.sessionHint};if(pt()){let o=null;try{o=re.mountPane({title:"Docker \u5BB9\u5668",hint:t?.target===void 0||t.target===""?"":t.target,size:520,min:360,onClose:()=>ve()})}catch(c){o=null,console.warn("[dsh-docker] \u6302\u8F7D\u5230\u7EC8\u7AEF\u9762\u677F\u5931\u8D25\uFF0C\u56DE\u9000\u5F39\u7A97\uFF1A"+(c instanceof Error?c.message:String(c)))}if(o!==null&&ht(o.element)){Ee=o,oe=E(o.element),oe.render(e(Ge,{...a,docked:!0,onTargetChange:c=>{try{o.setHint(c)}catch{}}}));return}}ue=document.createElement("div"),document.body.appendChild(ue),oe=E(ue),oe.render(e(Ge,a))}function mt(){let t=document.querySelector('[data-pane="sidebar"], [class*="sidebarCol"]');if(t!==null)return t.querySelector('[class*="logoRow"]')?.parentElement??t.firstElementChild}function ft(t){let a=t.querySelector('button[class*="newSession"]');if(a!==null)return a;for(let o of t.children)if(o.tagName==="BUTTON")return o}function vt(){let t=document.createElement("div");return t.dataset.dshDockerEntry="",t.className="dk_sidebarEntry",t.setAttribute("role","button"),t.setAttribute("aria-label","\u5BB9\u5668"),t.innerHTML='<span class="dk_entryIcon">'+tt+'</span><span class="dk_entryLabel">\u5BB9\u5668</span>',t.addEventListener("click",a=>{a.preventDefault(),Ke()}),t}function Ue(t,a){let o=ft(t);if(o===void 0)return!1;if(a.parentElement!==t){let c=o.closest('[class*="logoRow"]'),v=c!==null&&c.parentElement===t?c:o,r=Array.from(t.children).filter(b=>b instanceof HTMLElement&&b.matches("[data-dsh-global-search-entry], [data-dsh-rss-entry], [data-dsh-taskboard-entry], [data-dsh-ssh-entry], [data-dsh-tty-entry], [data-dsh-docker-entry]"));if(r.length>0){let b=r[r.length-1];t.insertBefore(a,b.nextSibling)}else t.insertBefore(a,v.nextElementSibling)}return!0}function bt(){if(Pe(),document.querySelector("[data-dsh-docker-entry]")!==null)return()=>{};let t=vt(),a,o=!1,c=()=>{if(a!==void 0&&!a.isConnected&&(r.disconnect(),a=void 0,o=!1),o){if(document.body.contains(t))return;r.disconnect(),a=void 0,o=!1}a??(a=mt()),a!==void 0&&(o=Ue(a,t),o&&r.observe(a,{childList:!0,subtree:!0}))},v=new MutationObserver(()=>{c()});v.observe(document.body,{childList:!0,subtree:!0});let r=new MutationObserver(()=>{if(a===void 0||!a.isConnected){o=!1,c();return}a.contains(t)||(o=Ue(a,t))});return c(),()=>{v.disconnect(),r.disconnect(),t.remove()}}let Be={};return Be.inject=["slots"],Be.apply=t=>{Pe();let a=bt(),o=t.slots.inject("settings.plugin.item",()=>t.slots.register({name:"settings.plugin.item",key:"docker",order:112},gt));t.inject(["ttyTerminal"],v=>(Z=v.ttyTerminal??null,()=>{Z=null})),t.inject(["ttyPanel"],v=>(re=v.ttyPanel??null,()=>{re=null}));let c=()=>{};return Se(),t.inject(["ttyConnbar"],v=>{let r=v.ttyConnbar;r!==void 0&&(c=r.addAction(b=>{let x=b?.spec??{};if(x.t!=="ssh")return;let w=typeof b?.bookName=="string"?b.bookName:"",N=je(x,w),j=N!==void 0?`\u6253\u5F00\u8BE5\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F\uFF08\u76EE\u6807\uFF1A${N}\uFF09`:ce===null?"\u6253\u5F00\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F":"\u8BE5\u4E3B\u673A\u5C1A\u672A\u914D\u7F6E\u4E3A Docker \u76EE\u6807 \u2014 \u70B9\u51FB\u6253\u5F00\u9762\u677F\u67E5\u770B/\u914D\u7F6E";b.addAction(Rt,"\u5BB9\u5668",j,()=>{(async()=>{let B=await Ot(x,w),I=Number(x.port);Ke({target:B??"",sessionHint:B===void 0?{host:typeof x.host=="string"?x.host:"",port:Number.isInteger(I)&&I>0?I:22,book:w}:void 0})})()})}),(async()=>{for(let b=0;b<3;b+=1){if(await Se()){typeof r.requestRender=="function"&&r.requestRender();return}await new Promise(x=>setTimeout(x,2e3))}})())}),()=>{c(),o(),a(),ve()}},Be}});})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyzyn/dsh-docker",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "DSH Web GUI 的 Docker 容器面板插件:本机或 SSH 主机上的容器列表 / 启停删 / 日志 / 统计 / 镜像 / 一次性 exec,默认只读,配套只读优先的 agent 工具。",
5
5
  "keywords": [
6
6
  "dsh",