dsh-harness-toolbox 1.6.4 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -18,24 +18,31 @@ window.__ModuleLoader__.load({
18
18
  const GH_NETWORK_API = '/compression-tiers/api/github/network'
19
19
  const GH_ONLINE_API = '/compression-tiers/api/github/online'
20
20
  const GH_BINDING_API = '/compression-tiers/api/github/binding'
21
- const FFMPEG_API = '/compression-tiers/api/ffmpeg'
21
+ const COMPONENTS_API = '/compression-tiers/api/components'
22
+ const TOOLS_API = '/compression-tiers/api/tools'
23
+
24
+ /**
25
+ * The rows the component panel always renders, in this order. The payload
26
+ * fills in state, path and progress; the list itself is fixed so a slow or
27
+ * failed load still shows every button (disabled) instead of an empty panel.
28
+ */
29
+ const COMPONENT_ROWS = [
30
+ { id: 'gh', name: 'GitHub CLI' },
31
+ { id: 'git', name: 'git' },
32
+ { id: 'ffmpeg', name: 'ffmpeg' },
33
+ { id: 'python', name: 'Python' },
34
+ ]
22
35
 
23
36
  const DICTIONARIES = {
24
37
  zh: {
25
38
  sectionLabel: '上下文压缩',
26
39
  title: '上下文压缩',
27
- intro: '五档自动压缩,切换即同步到所有预设引擎;下方还有全局规则、GitHub CLI 与音视频工具。',
28
40
  levelsAria: '压缩档位',
29
41
  levelGentle: '极轻',
30
42
  levelLight: '轻量',
31
43
  levelStandard: '标准',
32
44
  levelAggressive: '积极',
33
45
  levelMax: '最大',
34
- summaryGentle: '最晚触发,与官方默认一致。',
35
- summaryLight: '比官方默认早一档。',
36
- summaryStandard: '默认:长对话更省。',
37
- summaryAggressive: '更早压缩,成本优先。',
38
- summaryMax: '最省:40% 就压缩。',
39
46
  auto: '自动 ',
40
47
  retain: '留 ',
41
48
  sep: ':',
@@ -49,9 +56,7 @@ window.__ModuleLoader__.load({
49
56
  lastCompact: '上次压缩',
50
57
  never: '暂无',
51
58
  settingsPath: '设置文件',
52
- smallWindow: '按 ≥256k 窗口设计;更小的窗口主要差在保留量。',
53
59
  rulesTitle: '全局规则',
54
- rulesIntro: '编辑官方 AGENTS.md,下次会话生效。',
55
60
  rulesLabel: '规则内容',
56
61
  rulesPlaceholder: '例如:回答用中文;改动前先读 AGENTS.md。',
57
62
  rulesSave: '保存',
@@ -63,29 +68,40 @@ window.__ModuleLoader__.load({
63
68
  rulesPathLabel: '文件',
64
69
  rulesLoading: '读取中…',
65
70
  rulesMissing: '不存在,保存后创建。',
66
- ghTitle: 'GitHub CLI',
67
- ghIntro: '官方变更请求面板需要。系统 PATH 里已有会自动使用,也可下载托管版(v2.76.2,可断点续传)。',
68
- ghProbe: '重新检测',
69
- ghInstalled: '已安装',
70
- ghSystem: '系统已安装(PATH)',
71
- ghDownloading: '下载中 ',
72
- ghPartial: '未完成,可续传',
73
- ghFailed: '下载失败',
74
- ghMissing: '未安装',
75
- ghDownload: '下载',
76
- ghKeepDownload: '仍要下载',
77
- ghContinue: '继续下载',
78
- ghRetry: '重试',
79
- ghUnsupported: '当前系统不可用',
80
- ghPathLabel: '路径',
71
+ componentsTitle: '组件管理',
72
+ componentsLoadFailed: '读取组件状态失败:',
73
+ componentsActionFailed: '操作失败:',
74
+ toolsPathLabel: '下载目录',
75
+ toolsPathCurrent: '当前目录',
76
+ toolsPathSave: '迁移',
77
+ toolsPathReset: '恢复默认',
78
+ toolsPathSaved: '已迁移。',
79
+ toolsPathInvalid: '需要绝对路径。',
80
+ toolsPathRunning: '下载中,完成后再迁移。',
81
+ toolsPathFailed: '迁移失败:',
82
+ ghAuthTitle: 'GitHub 登录',
83
+ probe: '重新检测',
84
+ downloadIdle: '下载',
85
+ downloadKeep: '重新下载',
86
+ downloadContinue: '继续下载',
87
+ downloadRetry: '重试',
88
+ downloadRunning: '下载中 ',
89
+ downloadDone: '已安装',
90
+ downloadUnsupported: '当前系统不可用',
91
+ stateMissing: '未安装',
92
+ statePartial: '未完成,可续传',
93
+ stateFailed: '下载失败',
94
+ stateSystem: '系统已安装(PATH)',
95
+ pathLabel: '路径',
81
96
  ghAuthUnknown: '正在读取登录状态…',
82
- ghAuthUnavailable: '下载 GitHub CLI 后可登录。',
97
+ ghAuthUnavailable: '不可登录',
83
98
  ghLoggedIn: '已登录:',
84
99
  ghNotLoggedIn: '未登录',
85
100
  ghLogin: '登录 GitHub',
86
101
  ghRelogin: '重新登录',
87
102
  ghLoginStarting: '正在启动 gh 登录…',
88
- ghLoginNote: '在浏览器里粘贴一次性验证码并授权,完成后这里会自动更新。',
103
+ ghLoginWaiting: '等待授权',
104
+ ghLoginInactive: '未在登录中',
89
105
  ghLoginDone: '授权完成,凭据已由 gh 保存。',
90
106
  ghLoginFailed: '登录没有完成,可以重试。',
91
107
  ghCopy: '复制验证码',
@@ -104,22 +120,9 @@ window.__ModuleLoader__.load({
104
120
  ghNetworkUnknown: '未知',
105
121
  ghDnsOff: 'DNS 不是 GitHub 地址',
106
122
  ghScopeMissing: '令牌缺少 repo scope,私有仓库推送会失败。',
107
- ghToolNote: '发布交给 github_push 工具:默认推本会话的工作目录,先体检网络、扫密钥,再带超时推送。这一栏只管 gh 本身与网络体检。',
108
- toolsTitle: '音视频工具',
109
- toolsIntro: 'ffmpeg 与 ffprobe:可下载托管版(约 110 MB,断点续传),也可直接用系统 PATH 里的版本;托管版优先。',
110
123
  toolsNotFound: '未找到',
111
124
  toolsManaged: '托管版',
112
125
  toolsSystem: '系统 PATH',
113
- toolsLoading: '读取中…',
114
- toolsInstalled: '已安装',
115
- toolsInstall: '下载安装',
116
- toolsContinue: '继续下载',
117
- toolsRetry: '重试',
118
- toolsProbe: '重新检测',
119
- toolsDownloading: '下载中 ',
120
- toolsUnsupported: '当前系统没有托管版',
121
- toolsLoadFailed: '读取音视频工具状态失败:',
122
- toolsActionFailed: '操作失败:',
123
126
  repoSelectLabel: '仓库',
124
127
  repoSelectAria: '在线仓库(github_push 的推送目标)',
125
128
  repoTitle: 'github_push 默认推送到这个在线仓库',
@@ -135,18 +138,12 @@ window.__ModuleLoader__.load({
135
138
  en: {
136
139
  sectionLabel: 'Context compression',
137
140
  title: 'Context compression',
138
- intro: 'Five automatic tiers: switching syncs every preset engine. Global rules, GitHub CLI and video tools are below.',
139
141
  levelsAria: 'Compression tier',
140
142
  levelGentle: 'Gentle',
141
143
  levelLight: 'Light',
142
144
  levelStandard: 'Standard',
143
145
  levelAggressive: 'Aggressive',
144
146
  levelMax: 'Max',
145
- summaryGentle: 'Latest trigger, matches the official default.',
146
- summaryLight: 'One step earlier than the default.',
147
- summaryStandard: 'Default: cheaper long conversations.',
148
- summaryAggressive: 'Compacts sooner, cost first.',
149
- summaryMax: 'Cheapest: compacts at 40% of the window.',
150
147
  auto: 'Auto ',
151
148
  retain: 'keep ',
152
149
  sep: ': ',
@@ -160,9 +157,7 @@ window.__ModuleLoader__.load({
160
157
  lastCompact: 'Last compaction',
161
158
  never: 'none yet',
162
159
  settingsPath: 'Settings file',
163
- smallWindow: 'Designed for windows of at least 256k tokens; smaller windows mostly differ in retain size.',
164
160
  rulesTitle: 'Global rules',
165
- rulesIntro: 'Edits the official AGENTS.md; applies from the next session.',
166
161
  rulesLabel: 'Rules',
167
162
  rulesPlaceholder: 'For example: answer in Chinese; read AGENTS.md before a change.',
168
163
  rulesSave: 'Save',
@@ -174,29 +169,40 @@ window.__ModuleLoader__.load({
174
169
  rulesPathLabel: 'File',
175
170
  rulesLoading: 'Loading…',
176
171
  rulesMissing: 'missing; saving creates it.',
177
- ghTitle: 'GitHub CLI',
178
- ghIntro: 'Needed by the official change-request panel. A gh on PATH is used first; the managed build (v2.76.2) can be downloaded here and resumes after an interruption.',
179
- ghProbe: 'Re-check',
180
- ghInstalled: 'Installed',
181
- ghSystem: 'System install (PATH)',
182
- ghDownloading: 'Downloading ',
183
- ghPartial: 'Incomplete, can resume',
184
- ghFailed: 'Download failed',
185
- ghMissing: 'Not installed',
186
- ghDownload: 'Download',
187
- ghKeepDownload: 'Download anyway',
188
- ghContinue: 'Resume download',
189
- ghRetry: 'Retry',
190
- ghUnsupported: 'Unavailable on this system',
191
- ghPathLabel: 'Path',
172
+ componentsTitle: 'Components',
173
+ componentsLoadFailed: 'Could not read the component state: ',
174
+ componentsActionFailed: 'Action failed: ',
175
+ toolsPathLabel: 'Download directory',
176
+ toolsPathCurrent: 'Current directory',
177
+ toolsPathSave: 'Move here',
178
+ toolsPathReset: 'Reset to default',
179
+ toolsPathSaved: 'Moved.',
180
+ toolsPathInvalid: 'An absolute path is required.',
181
+ toolsPathRunning: 'A download is running; move after it finishes.',
182
+ toolsPathFailed: 'Could not move: ',
183
+ ghAuthTitle: 'GitHub sign-in',
184
+ probe: 'Re-check',
185
+ downloadIdle: 'Download',
186
+ downloadKeep: 'Download again',
187
+ downloadContinue: 'Resume download',
188
+ downloadRetry: 'Retry',
189
+ downloadRunning: 'Downloading ',
190
+ downloadDone: 'Installed',
191
+ downloadUnsupported: 'Unavailable on this system',
192
+ stateMissing: 'Not installed',
193
+ statePartial: 'Incomplete, can resume',
194
+ stateFailed: 'Download failed',
195
+ stateSystem: 'System install (PATH)',
196
+ pathLabel: 'Path',
192
197
  ghAuthUnknown: 'Reading the sign-in state…',
193
- ghAuthUnavailable: 'Download GitHub CLI to sign in.',
198
+ ghAuthUnavailable: 'cannot sign in',
194
199
  ghLoggedIn: 'Signed in: ',
195
200
  ghNotLoggedIn: 'Not signed in',
196
201
  ghLogin: 'Sign in to GitHub',
197
202
  ghRelogin: 'Sign in again',
198
203
  ghLoginStarting: 'Starting gh sign-in…',
199
- ghLoginNote: 'Paste the one-time code on the GitHub page and authorize; this panel updates by itself.',
204
+ ghLoginWaiting: 'Waiting for authorization',
205
+ ghLoginInactive: 'not signing in',
200
206
  ghLoginDone: 'Authorization finished; gh stored the credential.',
201
207
  ghLoginFailed: 'Sign-in did not finish; you can retry.',
202
208
  ghCopy: 'Copy code',
@@ -215,22 +221,9 @@ window.__ModuleLoader__.load({
215
221
  ghNetworkUnknown: 'unknown',
216
222
  ghDnsOff: 'DNS is not a GitHub address',
217
223
  ghScopeMissing: 'The token has no repo scope; pushing a private repository will fail.',
218
- ghToolNote: 'Publishing belongs to the github_push tool: it pushes the session working directory after a network probe and a secret scan. This panel only manages gh and checks the network.',
219
- toolsTitle: 'Video tools',
220
- toolsIntro: 'ffmpeg and ffprobe: download the managed build (about 110 MB, resumes after an interruption) or use the copies on PATH; the managed build wins.',
221
224
  toolsNotFound: 'not found',
222
225
  toolsManaged: 'managed',
223
226
  toolsSystem: 'system PATH',
224
- toolsLoading: 'Loading…',
225
- toolsInstalled: 'Installed',
226
- toolsInstall: 'Download and install',
227
- toolsContinue: 'Resume download',
228
- toolsRetry: 'Retry',
229
- toolsProbe: 'Re-check',
230
- toolsDownloading: 'Downloading ',
231
- toolsUnsupported: 'No managed build for this system',
232
- toolsLoadFailed: 'Could not read the video-tool state: ',
233
- toolsActionFailed: 'Action failed: ',
234
227
  repoSelectLabel: 'Repo',
235
228
  repoSelectAria: 'Online repository (the github_push target)',
236
229
  repoTitle: 'github_push publishes to this online repository by default',
@@ -345,6 +338,12 @@ window.__ModuleLoader__.load({
345
338
  line-height: 18px;
346
339
  color: var(--dsw-alias-label-secondary);
347
340
  }
341
+ /* An empty status or note line is dead space at the bottom of a panel: hide it
342
+ while there is nothing to say, and let it appear together with the message. */
343
+ .ct-status:empty,
344
+ .ct-note:empty {
345
+ display: none;
346
+ }
348
347
  .ct-meta {
349
348
  display: grid;
350
349
  gap: 2px;
@@ -418,30 +417,50 @@ window.__ModuleLoader__.load({
418
417
  align-items: center;
419
418
  gap: 10px;
420
419
  }
421
- .ct-save {
420
+ /* One button standard for the whole page: the ct-btn base is the geometry,
421
+ ct-btn--primary only changes emphasis. Every panel renders its actions in a
422
+ ct-actions row so the GitHub, download-location and video panels cannot
423
+ drift into different-looking buttons. */
424
+ .ct-actions {
425
+ display: flex;
426
+ flex-wrap: wrap;
427
+ align-items: center;
428
+ gap: 8px;
429
+ }
430
+ .ct-btn {
431
+ box-sizing: border-box;
432
+ display: inline-flex;
433
+ align-items: center;
434
+ justify-content: center;
435
+ height: 30px;
422
436
  margin: 0;
423
- border: 1px solid var(--dsw-alias-border-selected);
437
+ padding: 0 12px;
438
+ border: 1px solid var(--dsw-alias-border-l2);
424
439
  border-radius: 10px;
425
- padding: 6px 14px;
426
- background: var(--dsw-alias-bg-module-platform);
440
+ background: transparent;
427
441
  color: var(--dsw-alias-label-primary);
428
442
  font: inherit;
429
443
  font-size: 13px;
430
- line-height: 20px;
444
+ line-height: 18px;
445
+ white-space: nowrap;
431
446
  cursor: pointer;
432
447
  }
448
+ .ct-btn--primary {
449
+ border-color: var(--dsw-alias-border-selected);
450
+ background: var(--dsw-alias-bg-module-platform);
451
+ }
433
452
  @media (hover: hover) {
434
- .ct-save:hover:not(:disabled) {
453
+ .ct-btn:hover:not(:disabled) {
435
454
  background: var(--dsw-alias-interactive-bg-hover);
436
455
  }
437
456
  }
438
- .ct-save:disabled {
457
+ .ct-btn:disabled {
439
458
  border-color: var(--dsw-alias-border-l2);
440
459
  background: transparent;
441
460
  color: var(--dsw-alias-label-tertiary);
442
461
  cursor: default;
443
462
  }
444
- .ct-save:focus-visible {
463
+ .ct-btn:focus-visible {
445
464
  outline: 2px solid var(--dsw-alias-state-business-primary);
446
465
  outline-offset: 2px;
447
466
  }
@@ -488,6 +507,29 @@ window.__ModuleLoader__.load({
488
507
  color: var(--dsw-alias-label-tertiary);
489
508
  word-break: break-all;
490
509
  }
510
+ .ct-component {
511
+ display: grid;
512
+ gap: 6px;
513
+ padding-top: 10px;
514
+ border-top: 1px solid var(--dsw-alias-border-l2);
515
+ }
516
+ .ct-component:first-of-type {
517
+ padding-top: 0;
518
+ border-top: 0;
519
+ }
520
+ .ct-component-head {
521
+ display: flex;
522
+ flex-wrap: wrap;
523
+ align-items: baseline;
524
+ gap: 4px 10px;
525
+ }
526
+ .ct-component-name {
527
+ font-size: 13px;
528
+ font-weight: 600;
529
+ }
530
+ .ct-component-path {
531
+ word-break: break-all;
532
+ }
491
533
  .ct-repo-slot {
492
534
  display: flex;
493
535
  align-items: center;
@@ -662,9 +704,39 @@ window.__ModuleLoader__.load({
662
704
  return t(key)
663
705
  }
664
706
 
665
- function summaryOf(t, id) {
666
- const key = 'summary' + id.charAt(0).toUpperCase() + id.slice(1)
667
- return t(key)
707
+ /** Two directory spellings that name the same place, for the move button. */
708
+ function samePathDraft(a, b) {
709
+ const clean = function (value) {
710
+ return String(value || '').trim().replace(/[\\/]+$/, '').toLowerCase()
711
+ }
712
+ return clean(a) === clean(b)
713
+ }
714
+
715
+ /** Absolute on Windows (`C:\x`, `\\host\share`) or POSIX (`/x`). */
716
+ function looksAbsolute(value) {
717
+ return /^([A-Za-z]:[\\/]|\\\\|\/)/.test(String(value || '').trim())
718
+ }
719
+
720
+ /**
721
+ * The one button standard for this page. `ct-btn` is the geometry, the
722
+ * `ct-btn--primary` modifier only adds emphasis, and `data-action` gives
723
+ * tests a stable handle. No panel may style its own button.
724
+ */
725
+ function actionButton(action, label, options) {
726
+ const config = options || {}
727
+ return h('button', {
728
+ type: 'button',
729
+ className: 'ct-btn' + (config.primary ? ' ct-btn--primary' : ''),
730
+ 'data-action': action,
731
+ disabled: config.disabled === true,
732
+ title: config.title || '',
733
+ onClick: config.onClick,
734
+ }, label)
735
+ }
736
+
737
+ /** Every panel renders its buttons in this row and nothing else. */
738
+ function actionRow(children) {
739
+ return h('div', { className: 'ct-actions' }, children)
668
740
  }
669
741
 
670
742
  function timeLabel(value) {
@@ -947,14 +1019,19 @@ window.__ModuleLoader__.load({
947
1019
  const [rulesText, setRulesText] = React.useState('')
948
1020
  const [rulesMessage, setRulesMessage] = React.useState('')
949
1021
  const [rulesBusy, setRulesBusy] = React.useState(false)
950
- const [gh, setGh] = React.useState(null)
1022
+ // One payload for the whole component panel: the four rows and the shared
1023
+ // download root they all install below.
1024
+ const [components, setComponents] = React.useState(null)
1025
+ const [componentsMessage, setComponentsMessage] = React.useState('')
1026
+ const [componentsBusy, setComponentsBusy] = React.useState(false)
1027
+ const [pathDraft, setPathDraft] = React.useState(null)
1028
+ const [pathBusy, setPathBusy] = React.useState(false)
1029
+ // The gh device-code flow; the gh binary itself is a component row.
1030
+ const [login, setLogin] = React.useState(null)
951
1031
  const [auth, setAuth] = React.useState(null)
952
1032
  const [ghMessage, setGhMessage] = React.useState('')
953
1033
  const [ghBusy, setGhBusy] = React.useState(false)
954
1034
  const [network, setNetwork] = React.useState(null)
955
- const [tools, setTools] = React.useState(null)
956
- const [toolsMessage, setToolsMessage] = React.useState('')
957
- const [toolsBusy, setToolsBusy] = React.useState(false)
958
1035
  const mounted = React.useRef(true)
959
1036
  const buttons = React.useRef({})
960
1037
 
@@ -962,34 +1039,32 @@ window.__ModuleLoader__.load({
962
1039
  mounted.current = true
963
1040
  load()
964
1041
  loadRules()
965
- loadGithub()
1042
+ loadComponents()
1043
+ loadLogin()
966
1044
  loadAuth()
967
1045
  loadNetwork()
968
- loadTools()
969
1046
  return function () {
970
1047
  mounted.current = false
971
1048
  }
972
1049
  }, [])
973
1050
 
974
- const downloading = gh && gh.gh ? gh.gh.state === 'downloading' : false
975
- const loggingIn = gh && gh.login ? gh.login.active === true : false
976
- React.useEffect(function () {
977
- if (!downloading) return undefined
978
- const timer = window.setInterval(function () { loadGithub() }, 900)
979
- return function () { window.clearInterval(timer) }
980
- }, [downloading])
1051
+ const loggingIn = login ? login.active === true : false
981
1052
  React.useEffect(function () {
982
1053
  if (!loggingIn) return undefined
983
- const timer = window.setInterval(function () { loadGithub() }, 1500)
1054
+ const timer = window.setInterval(function () { loadLogin() }, 1500)
984
1055
  return function () { window.clearInterval(timer) }
985
1056
  }, [loggingIn])
986
1057
 
987
- const toolsRunning = tools && tools.download ? tools.download.running === true : false
1058
+ // Any managed install in flight keeps the panel refreshing; the payload
1059
+ // itself reports progress, so no second timer per component is needed.
1060
+ const anyRunning = components && Array.isArray(components.components)
1061
+ ? components.components.some(function (row) { return row && row.running === true })
1062
+ : false
988
1063
  React.useEffect(function () {
989
- if (!toolsRunning) return undefined
990
- const timer = window.setInterval(function () { loadTools() }, 1200)
1064
+ if (!anyRunning) return undefined
1065
+ const timer = window.setInterval(function () { loadComponents({ quiet: true }) }, 1200)
991
1066
  return function () { window.clearInterval(timer) }
992
- }, [toolsRunning])
1067
+ }, [anyRunning])
993
1068
 
994
1069
  function load() {
995
1070
  fetch(API, { credentials: 'same-origin' })
@@ -1024,21 +1099,22 @@ window.__ModuleLoader__.load({
1024
1099
  })
1025
1100
  }
1026
1101
 
1027
- function applyGithub(body) {
1028
- setGh({ gh: body && body.gh ? body.gh : null, login: body && body.login ? body.login : null })
1102
+ /** The device-code flow state; the gh binary lives in the component rows. */
1103
+ function applyLogin(body) {
1104
+ setLogin(body && body.login ? body.login : null)
1029
1105
  }
1030
1106
 
1031
- function loadGithub() {
1107
+ function loadLogin() {
1032
1108
  return fetch(GH_API, { credentials: 'same-origin' })
1033
1109
  .then(readJson)
1034
1110
  .then(function (body) {
1035
1111
  if (!mounted.current) return
1036
- applyGithub(body)
1112
+ applyLogin(body)
1037
1113
  if (body && body.login && body.login.state === 'success') loadAuth()
1038
1114
  })
1039
1115
  .catch(function (error) {
1040
1116
  if (!mounted.current) return
1041
- setGhMessage(t('ghLoadFailed') + (error && error.message ? error.message : String(error)))
1117
+ setGhMessage(t('ghLoadFailed') + messageOf(error))
1042
1118
  })
1043
1119
  }
1044
1120
 
@@ -1064,28 +1140,6 @@ window.__ModuleLoader__.load({
1064
1140
  }).then(readJson)
1065
1141
  }
1066
1142
 
1067
- function applyLogin(body) {
1068
- setGh(function (current) { return { gh: current ? current.gh : null, login: body } })
1069
- }
1070
-
1071
- function downloadGh() {
1072
- if (ghBusy) return
1073
- setGhBusy(true)
1074
- setGhMessage('')
1075
- githubAction({ action: 'download' })
1076
- .then(function (body) {
1077
- if (!mounted.current) return
1078
- setGh(function (current) { return { gh: body.gh || null, login: current ? current.login : null } })
1079
- })
1080
- .catch(function (error) {
1081
- if (!mounted.current) return
1082
- setGhMessage(t('ghActionFailed') + (error && error.message ? error.message : String(error)))
1083
- })
1084
- .then(function () {
1085
- if (mounted.current) setGhBusy(false)
1086
- })
1087
- }
1088
-
1089
1143
  function loginGh() {
1090
1144
  if (ghBusy) return
1091
1145
  setGhBusy(true)
@@ -1123,7 +1177,6 @@ window.__ModuleLoader__.load({
1123
1177
  }
1124
1178
 
1125
1179
  function copyCode() {
1126
- const login = gh && gh.login
1127
1180
  if (!login || !login.code) return
1128
1181
  try {
1129
1182
  if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
@@ -1140,7 +1193,6 @@ window.__ModuleLoader__.load({
1140
1193
  }
1141
1194
 
1142
1195
  function openDevice() {
1143
- const login = gh && gh.login
1144
1196
  const url = login && login.url ? login.url : 'https://github.com/login/device'
1145
1197
  window.open(url, '_blank', 'noopener,noreferrer')
1146
1198
  }
@@ -1158,41 +1210,77 @@ window.__ModuleLoader__.load({
1158
1210
  })
1159
1211
  }
1160
1212
 
1161
- function loadTools() {
1162
- return fetch(FFMPEG_API, { credentials: 'same-origin' })
1213
+ /**
1214
+ * The four component rows plus the shared download root. `quiet` keeps the
1215
+ * current status line (a refetch after an action must not erase its own
1216
+ * "migrated" message).
1217
+ */
1218
+ function loadComponents(options) {
1219
+ const quiet = Boolean(options && options.quiet)
1220
+ return fetch(COMPONENTS_API, { credentials: 'same-origin' })
1163
1221
  .then(readJson)
1164
1222
  .then(function (body) {
1165
1223
  if (!mounted.current) return
1166
- setTools(body)
1167
- setToolsMessage('')
1224
+ setComponents(body)
1225
+ if (!quiet) setComponentsMessage('')
1168
1226
  })
1169
1227
  .catch(function (error) {
1170
1228
  if (!mounted.current) return
1171
- setToolsMessage(t('toolsLoadFailed') + messageOf(error))
1229
+ setComponentsMessage(t('componentsLoadFailed') + messageOf(error))
1172
1230
  })
1173
1231
  }
1174
1232
 
1175
- function downloadTools() {
1176
- if (toolsBusy) return
1177
- setToolsBusy(true)
1178
- setToolsMessage('')
1179
- fetch(FFMPEG_API, {
1233
+ /** Start one component's managed install; the poll shows its progress. */
1234
+ function downloadComponent(id) {
1235
+ if (componentsBusy) return
1236
+ setComponentsBusy(true)
1237
+ setComponentsMessage('')
1238
+ fetch(COMPONENTS_API, {
1180
1239
  method: 'POST',
1181
1240
  credentials: 'same-origin',
1182
1241
  headers: { 'content-type': 'application/json' },
1183
- body: JSON.stringify({ action: 'download' }),
1242
+ body: JSON.stringify({ id: id, action: 'download' }),
1184
1243
  })
1185
1244
  .then(readJson)
1186
1245
  .then(function (body) {
1187
1246
  if (!mounted.current) return
1188
- setTools(body)
1247
+ setComponents(body)
1189
1248
  })
1190
1249
  .catch(function (error) {
1191
1250
  if (!mounted.current) return
1192
- setToolsMessage(t('toolsActionFailed') + messageOf(error))
1251
+ setComponentsMessage(t('componentsActionFailed') + messageOf(error))
1193
1252
  })
1194
1253
  .then(function () {
1195
- if (mounted.current) setToolsBusy(false)
1254
+ if (mounted.current) setComponentsBusy(false)
1255
+ })
1256
+ }
1257
+
1258
+ /** Move every managed component to `target` and persist it. */
1259
+ function migratePath(target) {
1260
+ if (pathBusy) return
1261
+ setPathBusy(true)
1262
+ setComponentsMessage('')
1263
+ fetch(TOOLS_API, {
1264
+ method: 'POST',
1265
+ credentials: 'same-origin',
1266
+ headers: { 'content-type': 'application/json' },
1267
+ body: JSON.stringify({ action: 'migrate', path: target }),
1268
+ })
1269
+ .then(readJson)
1270
+ .then(function (body) {
1271
+ if (!mounted.current) return
1272
+ setPathDraft(null)
1273
+ setComponentsMessage(t('toolsPathSaved'))
1274
+ // Every binary location changed, so every row is stale.
1275
+ loadComponents({ quiet: true })
1276
+ })
1277
+ .catch(function (error) {
1278
+ if (!mounted.current) return
1279
+ setComponentsMessage(t('toolsPathFailed') + messageOf(error))
1280
+ loadComponents({ quiet: true })
1281
+ })
1282
+ .then(function () {
1283
+ if (mounted.current) setPathBusy(false)
1196
1284
  })
1197
1285
  }
1198
1286
 
@@ -1262,11 +1350,46 @@ window.__ModuleLoader__.load({
1262
1350
  if (node && typeof node.focus === 'function') node.focus()
1263
1351
  }
1264
1352
 
1353
+ /**
1354
+ * The one download control shared by every component row: identical state
1355
+ * line and button label for identical states, so the four rows (and any
1356
+ * component added later) cannot drift into different-looking controls.
1357
+ */
1358
+ function downloadControl(model) {
1359
+ const loading = model.loading === true
1360
+ const unsupported = model.unsupported === true
1361
+ const running = model.running === true
1362
+ const system = model.system === true
1363
+ const installed = model.installed === true && !system
1364
+ const percent = model.percent == null ? '' : model.percent + '%'
1365
+ const stateText = loading
1366
+ ? t('loading')
1367
+ : unsupported ? t('downloadUnsupported')
1368
+ : running ? t('downloadRunning') + percent
1369
+ : system ? t('stateSystem')
1370
+ : installed ? t('downloadDone')
1371
+ : model.failed === true ? t('stateFailed')
1372
+ : model.partial === true ? t('statePartial')
1373
+ : t('stateMissing')
1374
+ const label = loading
1375
+ ? t('loading')
1376
+ : unsupported ? t('downloadUnsupported')
1377
+ : running ? t('downloadRunning')
1378
+ : system ? t('downloadKeep')
1379
+ : installed ? t('downloadDone')
1380
+ : model.failed === true ? t('downloadRetry')
1381
+ : model.partial === true ? t('downloadContinue')
1382
+ : t('downloadIdle')
1383
+ return {
1384
+ stateText,
1385
+ label,
1386
+ disabled: loading || unsupported || running || installed,
1387
+ }
1388
+ }
1265
1389
  const levels = state && Array.isArray(state.levels) && state.levels.length ? state.levels : LEVELS.map(function (id) {
1266
1390
  return { id: id }
1267
1391
  })
1268
1392
  const current = state ? state.level : ''
1269
- const currentSummary = current ? summaryOf(t, current) : ''
1270
1393
  const engineCount = state && typeof state.engines === 'number' ? state.engines : 0
1271
1394
  const last = state && state.lastCompact
1272
1395
  const lastText = last && last.at
@@ -1286,7 +1409,6 @@ window.__ModuleLoader__.load({
1286
1409
  'aria-checked': selected ? 'true' : 'false',
1287
1410
  tabIndex: selected ? 0 : -1,
1288
1411
  disabled: busy,
1289
- title: summaryOf(t, id),
1290
1412
  ref: function (node) { buttons.current[id] = node },
1291
1413
  className: 'ct-level' + (selected ? ' ct-level-on' : ''),
1292
1414
  onClick: function () { select(id) },
@@ -1295,7 +1417,7 @@ window.__ModuleLoader__.load({
1295
1417
  h('strong', null, labelOf(t, id)),
1296
1418
  h('span', null, t('auto') + percent(level.thresholdRatio) + ' · ' + t('retain') + percent(level.retainRatio)))
1297
1419
  })),
1298
- h('p', { className: 'ct-summary' }, t('currentLabel') + t('sep') + labelOf(t, current) + (currentSummary ? ' — ' + currentSummary : '')),
1420
+ h('p', { className: 'ct-summary' }, t('currentLabel') + t('sep') + labelOf(t, current)),
1299
1421
  h('p', { className: 'ct-status', role: 'status', 'aria-live': 'polite' }, message))
1300
1422
  : h('p', { className: 'ct-intro', role: 'status' }, message || t('loading'))
1301
1423
 
@@ -1304,8 +1426,7 @@ window.__ModuleLoader__.load({
1304
1426
  const rulesLimit = rules && typeof rules.maxChars === 'number' ? rules.maxChars : 0
1305
1427
  const rulesPanel = h('section', { className: 'ct-panel' },
1306
1428
  h('div', { className: 'ct-rules-head' },
1307
- h('h3', null, t('rulesTitle')),
1308
- h('p', { className: 'ct-note' }, t('rulesIntro'))),
1429
+ h('h3', null, t('rulesTitle'))),
1309
1430
  h('label', { className: 'ct-field' },
1310
1431
  h('span', null, t('rulesLabel')),
1311
1432
  h('textarea', {
@@ -1317,51 +1438,148 @@ window.__ModuleLoader__.load({
1317
1438
  disabled: rulesBusy || !rules,
1318
1439
  onChange: function (event) { setRulesText(event.target.value) },
1319
1440
  })),
1320
- h('div', { className: 'ct-row' },
1321
- h('button', {
1322
- type: 'button',
1323
- className: 'ct-save',
1441
+ h('p', { className: 'ct-note' }, rules
1442
+ ? t('rulesChars') + ' ' + rulesCount + ' / ' + rulesLimit
1443
+ : (rulesMessage ? '' : t('rulesLoading'))),
1444
+ actionRow([
1445
+ actionButton('rulesSave', rulesBusy ? t('rulesSaving') : t('rulesSave'), {
1324
1446
  disabled: rulesBusy || !rules || !dirty,
1325
1447
  onClick: saveRules,
1326
- }, rulesBusy ? t('rulesSaving') : t('rulesSave')),
1327
- h('span', { className: 'ct-note' }, rules
1328
- ? t('rulesChars') + ' ' + rulesCount + ' / ' + rulesLimit
1329
- : (rulesMessage ? '' : t('rulesLoading')))),
1448
+ primary: true,
1449
+ }),
1450
+ ]),
1330
1451
  h('p', { className: 'ct-status', role: 'status', 'aria-live': 'polite' }, rulesMessage),
1331
1452
  rules && rules.path
1332
1453
  ? h('p', { className: 'ct-note' }, t('rulesPathLabel') + t('sep') + rules.path + (rules.exists === false ? ' — ' + t('rulesMissing') : ''))
1333
1454
  : null)
1334
1455
 
1335
- const ghItem = gh && gh.gh ? gh.gh : null
1336
- const login = gh && gh.login ? gh.login : null
1337
- const ghSupported = ghItem ? ghItem.supported !== false : false
1338
- const ghBusyNow = ghBusy || (ghItem ? ghItem.state === 'downloading' : false)
1339
- const ghStateText = !ghItem
1340
- ? t('loading')
1341
- : ghItem.state === 'installed'
1342
- ? t('ghInstalled')
1343
- : ghItem.state === 'system'
1344
- ? t('ghSystem')
1345
- : ghItem.state === 'downloading'
1346
- ? t('ghDownloading') + (ghItem.percent == null ? '' : ghItem.percent + '%')
1347
- : ghItem.state === 'partial'
1348
- ? t('ghPartial')
1349
- : ghItem.state === 'error'
1350
- ? t('ghFailed')
1351
- : t('ghMissing')
1352
- const downloadLabel = !ghItem || ghItem.supported === false
1353
- ? t('ghUnsupported')
1354
- : ghItem.state === 'installed'
1355
- ? t('ghInstalled')
1356
- : ghItem.state === 'system'
1357
- ? t('ghKeepDownload')
1358
- : ghItem.state === 'downloading'
1359
- ? t('ghDownloading')
1360
- : ghItem.state === 'partial'
1361
- ? t('ghContinue')
1362
- : ghItem.state === 'error'
1363
- ? t('ghRetry')
1364
- : t('ghDownload')
1456
+ /**
1457
+ * The binaries of a multi-binary component: one line per found binary.
1458
+ * Nothing is listed when none is found — the title already names the pair
1459
+ * and the state line already says 未安装, so a "未找到" line would only
1460
+ * repeat it. A single missing binary gets one line naming just that one.
1461
+ */
1462
+ function componentToolLines(row) {
1463
+ if (!row || !row.tools) return null
1464
+ const found = row.tools.filter(function (tool) { return Boolean(tool.path) })
1465
+ if (found.length === 0) return null
1466
+ const missing = row.tools.filter(function (tool) { return !tool.path })
1467
+ const lines = found.map(function (tool) {
1468
+ return h('div', { className: 'ct-tool', key: tool.name },
1469
+ h('span', { className: 'ct-tool-name' }, tool.name),
1470
+ h('span', { className: 'ct-note' }, (tool.managed ? t('toolsManaged') : t('toolsSystem')) + (tool.version ? ' v' + tool.version : '')),
1471
+ tool.path ? h('span', { className: 'ct-tool-path' }, tool.path) : null)
1472
+ })
1473
+ if (missing.length > 0) {
1474
+ lines.push(h('div', { className: 'ct-tool', key: 'missing' },
1475
+ h('span', { className: 'ct-tool-name' }, missing.map(function (tool) { return tool.name }).join(' / ')),
1476
+ h('span', { className: 'ct-note' }, t('toolsNotFound'))))
1477
+ }
1478
+ return h('div', { className: 'ct-tools-list' }, lines)
1479
+ }
1480
+
1481
+ // ---- component panel: four rows plus the download root they share ----
1482
+ const rootInfo = components && components.root ? components.root : null
1483
+ const rootPath = rootInfo && rootInfo.path ? String(rootInfo.path) : ''
1484
+ const rootDefault = rootInfo && rootInfo.defaultPath ? String(rootInfo.defaultPath) : ''
1485
+ const rootRunning = Boolean(rootInfo && rootInfo.running && COMPONENT_ROWS.some(function (def) {
1486
+ return rootInfo.running[def.id] === true
1487
+ }))
1488
+ const rowsById = {}
1489
+ if (components && Array.isArray(components.components)) {
1490
+ components.components.forEach(function (row) {
1491
+ if (row && row.id) rowsById[row.id] = row
1492
+ })
1493
+ }
1494
+ // Every row renders through the one download control and the one button
1495
+ // standard; a component whose payload has not arrived still renders its
1496
+ // two buttons, disabled, instead of vanishing from the panel.
1497
+ const componentNodes = COMPONENT_ROWS.map(function (def) {
1498
+ const row = rowsById[def.id] || null
1499
+ const control = downloadControl({
1500
+ loading: !row,
1501
+ unsupported: Boolean(row && row.supported === false),
1502
+ running: Boolean(row && row.state === 'downloading'),
1503
+ installed: Boolean(row && row.state === 'installed'),
1504
+ partial: Boolean(row && row.state === 'partial'),
1505
+ failed: Boolean(row && row.state === 'error'),
1506
+ system: Boolean(row && row.state === 'system'),
1507
+ percent: row ? row.percent : null,
1508
+ })
1509
+ const pinned = row && row.version ? ' · v' + row.version : ''
1510
+ const used = row && row.toolVersion ? ' (' + row.toolVersion + ')' : ''
1511
+ // A row that covers several binaries says so in its title, so "ffprobe
1512
+ // is part of this row" stays visible even when there is nothing to list.
1513
+ const title = row && row.tools
1514
+ ? row.tools.map(function (tool) { return tool.name }).join(' / ')
1515
+ : (row && row.name ? row.name : def.name)
1516
+ const bar = Boolean(row) && row.percent != null
1517
+ && (row.state === 'downloading' || row.state === 'partial' || row.state === 'error')
1518
+ return h('div', { className: 'ct-component', key: def.id },
1519
+ h('div', { className: 'ct-component-head' },
1520
+ h('strong', { className: 'ct-component-name' }, title),
1521
+ h('span', { className: 'ct-note' }, control.stateText + pinned + used)),
1522
+ bar ? h('div', { className: 'ct-progress' }, h('span', { style: { width: (row.percent || 0) + '%' } })) : null,
1523
+ row && row.path ? h('p', { className: 'ct-note ct-component-path' }, t('pathLabel') + t('sep') + row.path) : null,
1524
+ componentToolLines(row),
1525
+ row && row.error ? h('p', { className: 'ct-status', role: 'alert' }, row.error) : null,
1526
+ actionRow([
1527
+ actionButton('download:' + def.id, control.label, {
1528
+ disabled: componentsBusy || control.disabled,
1529
+ onClick: function () { downloadComponent(def.id) },
1530
+ primary: true,
1531
+ }),
1532
+ actionButton('probe:' + def.id, t('probe'), { onClick: function () { loadComponents(); loadAuth() } }),
1533
+ ]))
1534
+ })
1535
+
1536
+ // The shared download root sits in the same panel: it is what a component
1537
+ // installs below, so moving it is a component action. Both buttons stay
1538
+ // rendered and go disabled while a download runs or the draft is unchanged.
1539
+ const pathValue = pathDraft === null ? rootPath : pathDraft
1540
+ const pathClean = String(pathValue == null ? '' : pathValue).trim()
1541
+ const pathInvalid = pathClean.length > 0 && !looksAbsolute(pathClean)
1542
+ const pathChanged = rootPath !== '' && !samePathDraft(pathClean, rootPath)
1543
+ const pathDisabled = pathBusy || rootRunning || !rootPath || !pathClean || pathInvalid || !pathChanged
1544
+ const pathTitle = rootRunning ? t('toolsPathRunning') : pathInvalid ? t('toolsPathInvalid') : ''
1545
+ const pathBlock = h('div', { className: 'ct-rules-head' },
1546
+ h('label', { className: 'ct-field' },
1547
+ h('span', null, t('toolsPathLabel')),
1548
+ h('div', { className: 'ct-row' },
1549
+ h('input', {
1550
+ className: 'ct-input',
1551
+ type: 'text',
1552
+ spellCheck: false,
1553
+ value: pathValue,
1554
+ placeholder: rootDefault,
1555
+ disabled: pathBusy,
1556
+ onChange: function (event) { setPathDraft(event.target.value) },
1557
+ }))),
1558
+ h('p', { className: 'ct-note' }, rootPath
1559
+ ? t('toolsPathCurrent') + t('sep') + rootPath
1560
+ : (componentsMessage ? '' : t('loading'))),
1561
+ rootRunning ? h('p', { className: 'ct-note' }, t('toolsPathRunning')) : null,
1562
+ actionRow([
1563
+ actionButton('toolsPathMigrate', pathBusy ? t('rulesSaving') : t('toolsPathSave'), {
1564
+ disabled: pathDisabled,
1565
+ title: pathTitle,
1566
+ onClick: function () { migratePath(pathClean) },
1567
+ primary: true,
1568
+ }),
1569
+ actionButton('toolsPathReset', t('toolsPathReset'), {
1570
+ disabled: pathBusy || rootRunning || !rootDefault || samePathDraft(rootPath, rootDefault),
1571
+ title: rootRunning ? t('toolsPathRunning') : '',
1572
+ onClick: function () { migratePath(rootDefault) },
1573
+ }),
1574
+ ]))
1575
+
1576
+ const componentsPanel = h('section', { className: 'ct-panel' },
1577
+ h('div', { className: 'ct-rules-head' },
1578
+ h('h3', null, t('componentsTitle'))),
1579
+ componentNodes,
1580
+ pathBlock,
1581
+ h('p', { className: 'ct-status', role: 'status', 'aria-live': 'polite' }, componentsMessage))
1582
+
1365
1583
  const authText = auth === null
1366
1584
  ? t('ghAuthUnknown')
1367
1585
  : !auth.available
@@ -1369,27 +1587,39 @@ window.__ModuleLoader__.load({
1369
1587
  : auth.authenticated
1370
1588
  ? t('ghLoggedIn') + (auth.account || 'GitHub')
1371
1589
  : t('ghNotLoggedIn')
1372
- const ghLoginVisible = Boolean(login && (login.active || login.state === 'success' || login.state === 'error'))
1373
- const ghLoginLead = !login
1590
+ // The sign-in block is always rendered: a button that only exists while a
1591
+ // condition holds makes the panel jump. Unusable actions go disabled with
1592
+ // the reason in `title` instead.
1593
+ const loginActive = Boolean(login && login.active)
1594
+ const loginCode = login && login.code ? login.code : ''
1595
+ const loginLead = !login
1374
1596
  ? ''
1375
- : login.active
1376
- ? (login.code ? t('ghLoginNote') : (login.note || t('ghLoginStarting')))
1377
- : login.state === 'success' ? t('ghLoginDone') : t('ghLoginFailed')
1378
- const ghLoginBlock = ghLoginVisible
1379
- ? h('div', { className: 'ct-rules-head' },
1380
- h('p', { className: 'ct-note' }, ghLoginLead),
1381
- login.active && login.code
1382
- ? h('div', { className: 'ct-row' },
1383
- h('code', { className: 'ct-code' }, login.code),
1384
- h('button', { type: 'button', className: 'ct-save', onClick: copyCode }, t('ghCopy')))
1385
- : null,
1386
- login.active
1387
- ? h('div', { className: 'ct-row' },
1388
- h('button', { type: 'button', className: 'ct-save', onClick: openDevice }, t('ghOpenDevice')),
1389
- h('button', { type: 'button', className: 'ct-save', disabled: ghBusy, onClick: cancelLogin }, t('ghCancel')))
1390
- : null,
1391
- login.error ? h('p', { className: 'ct-status', role: 'alert' }, login.error) : null)
1392
- : null
1597
+ : loginActive
1598
+ ? (loginCode ? t('ghLoginWaiting') : (login.note || t('ghLoginStarting')))
1599
+ : login.state === 'success' ? t('ghLoginDone') : login.state === 'error' ? t('ghLoginFailed') : ''
1600
+ const loginInactiveTitle = loginActive ? '' : t('ghLoginInactive')
1601
+ const ghLoginBlock = h('div', { className: 'ct-rules-head' },
1602
+ h('p', { className: 'ct-note' }, loginLead),
1603
+ h('div', { className: 'ct-row' }, h('code', { className: 'ct-code' }, loginCode || '—')),
1604
+ actionRow([
1605
+ actionButton('ghCopy', t('ghCopy'), {
1606
+ disabled: ghBusy || !loginCode,
1607
+ title: loginCode ? '' : t('ghLoginInactive'),
1608
+ onClick: copyCode,
1609
+ }),
1610
+ actionButton('ghOpenDevice', t('ghOpenDevice'), {
1611
+ disabled: ghBusy || !loginActive,
1612
+ title: loginInactiveTitle,
1613
+ onClick: openDevice,
1614
+ primary: true,
1615
+ }),
1616
+ actionButton('ghCancel', t('ghCancel'), {
1617
+ disabled: ghBusy || !loginActive,
1618
+ title: loginInactiveTitle,
1619
+ onClick: cancelLogin,
1620
+ }),
1621
+ ]),
1622
+ login && login.error ? h('p', { className: 'ct-status', role: 'alert' }, login.error) : null)
1393
1623
  const networkText = !network
1394
1624
  ? ''
1395
1625
  : network.verdict === 'direct' ? t('ghNetworkDirect')
@@ -1404,47 +1634,23 @@ window.__ModuleLoader__.load({
1404
1634
  networkText
1405
1635
  ? h('p', { className: 'ct-note' }, t('ghNetworkLabel') + t('sep') + networkText + (dnsNote ? ' · ' + dnsNote : ''))
1406
1636
  : null,
1407
- h('p', { className: 'ct-note' }, t('ghToolNote')),
1408
- h('div', { className: 'ct-row' },
1409
- h('button', {
1410
- type: 'button',
1411
- className: 'ct-save',
1412
- onClick: function () { loadNetwork() },
1413
- }, t('ghNetwork'))))
1637
+ actionRow([
1638
+ actionButton('ghNetwork', t('ghNetwork'), { onClick: function () { loadNetwork() } }),
1639
+ ]))
1414
1640
 
1415
- const ghPanel = h('section', { className: 'ct-panel' },
1641
+ // The signed-in account, the device flow and the network probe. The `gh`
1642
+ // binary itself is one row in the component panel above.
1643
+ const ghAuthPanel = h('section', { className: 'ct-panel' },
1416
1644
  h('div', { className: 'ct-rules-head' },
1417
- h('h3', null, t('ghTitle')),
1418
- h('p', { className: 'ct-note' }, t('ghIntro'))),
1419
- h('div', { className: 'ct-row' },
1420
- h('span', { className: 'ct-note' }, ghStateText),
1421
- ghItem && ghItem.version ? h('span', { className: 'ct-note' }, 'v' + ghItem.version) : null,
1422
- h('button', {
1423
- type: 'button',
1424
- className: 'ct-save',
1425
- disabled: ghBusyNow || !ghItem || ghItem.state === 'installed' || !ghSupported,
1426
- onClick: downloadGh,
1427
- }, downloadLabel),
1428
- h('button', {
1429
- type: 'button',
1430
- className: 'ct-save',
1431
- onClick: function () { loadGithub(); loadAuth() },
1432
- }, t('ghProbe'))),
1433
- ghItem && (ghItem.state === 'downloading' || ghItem.state === 'partial') && ghItem.percent != null
1434
- ? h('div', { className: 'ct-progress' }, h('span', { style: { width: ghItem.percent + '%' } }))
1435
- : null,
1436
- ghItem && ghItem.binaryPath
1437
- ? h('p', { className: 'ct-note' }, t('ghPathLabel') + t('sep') + ghItem.binaryPath)
1438
- : null,
1439
- ghItem && ghItem.error ? h('p', { className: 'ct-status', role: 'alert' }, ghItem.error) : null,
1440
- h('div', { className: 'ct-row' },
1441
- h('span', { className: 'ct-note' }, authText),
1442
- h('button', {
1443
- type: 'button',
1444
- className: 'ct-save',
1645
+ h('h3', null, t('ghAuthTitle'))),
1646
+ h('p', { className: 'ct-note' }, authText),
1647
+ actionRow([
1648
+ actionButton('ghLogin', auth && auth.authenticated ? t('ghRelogin') : t('ghLogin'), {
1445
1649
  disabled: ghBusy || loggingIn || !auth || !auth.available,
1446
1650
  onClick: loginGh,
1447
- }, auth && auth.authenticated ? t('ghRelogin') : t('ghLogin'))),
1651
+ primary: true,
1652
+ }),
1653
+ ]),
1448
1654
  auth && auth.missingRepoScope
1449
1655
  ? h('p', { className: 'ct-status', role: 'alert' }, t('ghScopeMissing'))
1450
1656
  : null,
@@ -1452,75 +1658,20 @@ window.__ModuleLoader__.load({
1452
1658
  networkBlock,
1453
1659
  ghMessage ? h('p', { className: 'ct-status', role: 'status', 'aria-live': 'polite' }, ghMessage) : null)
1454
1660
 
1455
- const toolsItem = tools
1456
- const toolsDownload = toolsItem && toolsItem.download ? toolsItem.download : null
1457
- const toolsSupported = toolsItem ? toolsItem.supported !== false : false
1458
- const toolsRunningNow = toolsDownload ? toolsDownload.running === true : false
1459
- const toolsInstalled = toolsItem ? toolsItem.state === 'installed' : false
1460
- const toolsButton = !toolsItem
1461
- ? t('toolsLoading')
1462
- : !toolsSupported
1463
- ? t('toolsUnsupported')
1464
- : toolsRunningNow
1465
- ? t('toolsDownloading') + (toolsDownload.percent == null ? '' : toolsDownload.percent + '%')
1466
- : toolsInstalled
1467
- ? t('toolsInstalled')
1468
- : toolsDownload && toolsDownload.error
1469
- ? t('toolsRetry')
1470
- : toolsItem.state === 'missing' ? t('toolsInstall') : t('toolsContinue')
1471
- const toolRow = function (name, info) {
1472
- const version = info && info.version ? ' v' + info.version : ''
1473
- const origin = !info
1474
- ? t('toolsNotFound')
1475
- : (info.managed ? t('toolsManaged') : t('toolsSystem')) + version
1476
- return h('div', { className: 'ct-tool', key: name },
1477
- h('span', { className: 'ct-tool-name' }, name),
1478
- h('span', { className: 'ct-note' }, origin),
1479
- info && info.path ? h('span', { className: 'ct-tool-path' }, info.path) : null)
1480
- }
1481
- const toolsPanel = h('section', { className: 'ct-panel' },
1482
- h('div', { className: 'ct-rules-head' },
1483
- h('h3', null, t('toolsTitle')),
1484
- h('p', { className: 'ct-note' }, t('toolsIntro'))),
1485
- h('div', { className: 'ct-tools-list' },
1486
- toolRow('ffmpeg', toolsItem ? toolsItem.ffmpeg : null),
1487
- toolRow('ffprobe', toolsItem ? toolsItem.ffprobe : null)),
1488
- h('div', { className: 'ct-row' },
1489
- h('button', {
1490
- type: 'button',
1491
- className: 'ct-save',
1492
- disabled: toolsBusy || !toolsItem || !toolsSupported || toolsRunningNow || toolsInstalled,
1493
- onClick: downloadTools,
1494
- }, toolsButton),
1495
- h('button', {
1496
- type: 'button',
1497
- className: 'ct-save',
1498
- onClick: function () { loadTools() },
1499
- }, t('toolsProbe'))),
1500
- toolsRunningNow || (toolsDownload && toolsDownload.error && toolsDownload.percent != null)
1501
- ? h('div', { className: 'ct-progress' }, h('span', { style: { width: (toolsDownload.percent || 0) + '%' } }))
1502
- : null,
1503
- toolsDownload && toolsDownload.error
1504
- ? h('p', { className: 'ct-status', role: 'alert' }, toolsDownload.error)
1505
- : null,
1506
- toolsMessage ? h('p', { className: 'ct-status', role: 'status', 'aria-live': 'polite' }, toolsMessage) : null)
1507
-
1508
1661
  return h('section', { className: 'ct-page' },
1509
1662
  h('header', { className: 'ct-head' },
1510
- h('h2', null, t('title')),
1511
- h('p', { className: 'ct-intro' }, t('intro'))),
1663
+ h('h2', null, t('title'))),
1512
1664
  panel,
1513
1665
  rulesPanel,
1514
- ghPanel,
1515
- toolsPanel,
1666
+ componentsPanel,
1667
+ ghAuthPanel,
1516
1668
  state
1517
1669
  ? h('div', { className: 'ct-meta' },
1518
1670
  h('span', null, t('engines') + t('sep') + engineCount),
1519
1671
  h('span', null, t('lastCompact') + t('sep') + lastText),
1520
1672
  state.paths && state.paths.settings
1521
1673
  ? h('span', null, t('settingsPath') + t('sep') + state.paths.settings)
1522
- : null,
1523
- h('span', null, t('smallWindow')))
1674
+ : null)
1524
1675
  : null)
1525
1676
  }
1526
1677