dsh-release-depot 1.1.2 → 1.1.4

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
@@ -20,6 +20,22 @@ window.__ModuleLoader__.load({
20
20
  let localeService = null
21
21
  const hostServices = {}
22
22
 
23
+ let sidebarVisible = true
24
+ const sidebarListeners = new Set()
25
+ function setSidebarVisibleState(next) {
26
+ const normalized = next !== false
27
+ if (normalized === sidebarVisible) return
28
+ sidebarVisible = normalized
29
+ for (const fn of [...sidebarListeners]) fn()
30
+ }
31
+ function subscribeSidebar(fn) {
32
+ sidebarListeners.add(fn)
33
+ return () => sidebarListeners.delete(fn)
34
+ }
35
+ function useSidebarVisible() {
36
+ return React.useSyncExternalStore(subscribeSidebar, () => sidebarVisible, () => true)
37
+ }
38
+
23
39
  let themeScheme = 'light'
24
40
  const themeListeners = new Set()
25
41
  function setThemeScheme(next) {
@@ -77,6 +93,17 @@ window.__ModuleLoader__.load({
77
93
 
78
94
  const RPC = '/dsh-release-depot/rpc'
79
95
 
96
+ /**
97
+ * Small mutable scratchpad for values that must survive a confirm dialog's
98
+ * render without forcing the parent to re-render on every keystroke.
99
+ * Reset it right before opening a dialog.
100
+ */
101
+ const OT = { npmOtp: '', confirmText: '' }
102
+ function resetScratch() {
103
+ OT.npmOtp = ''
104
+ OT.confirmText = ''
105
+ }
106
+
80
107
  class ApiError extends Error {
81
108
  constructor(info) {
82
109
  super(info?.message ?? '请求失败')
@@ -84,6 +111,7 @@ window.__ModuleLoader__.load({
84
111
  this.code = info?.code ?? 'EUNKNOWN'
85
112
  this.hint = info?.hint ?? ''
86
113
  this.status = info?.status ?? 0
114
+ this.details = info?.details ?? null
87
115
  }
88
116
  }
89
117
 
@@ -127,6 +155,30 @@ window.__ModuleLoader__.load({
127
155
  return error.hint ? `${base} 提示:${error.hint}` : base
128
156
  }
129
157
 
158
+ /** Collect actionable links a Host error carried in `details`. */
159
+ function errorLinks(error) {
160
+ const details = error?.details
161
+ if (details === null || typeof details !== 'object') return []
162
+ const links = []
163
+ const push = (label, href) => {
164
+ if (typeof href !== 'string' || href === '' || !/^https:\/\//.test(href)) return
165
+ if (links.some((item) => item.href === href)) return
166
+ links.push({ label, href })
167
+ }
168
+ push('打开 npm Token 页面', details.npmTokenPage)
169
+ push('设置 npm 两步验证', details.npmTwoFactorPage)
170
+ push('npm 2FA 说明', details.npmHelpPage)
171
+ push('我的 npm 包', details.npmPackagesPage)
172
+ push('到 npm 网页删除', details.npmPackagePage)
173
+ push('GitHub Token 设置', details.tokenSettingsUrl)
174
+ push('GitHub 细粒度 Token', details.fineGrainedUrl)
175
+ return links
176
+ }
177
+
178
+ function errorHint(error) {
179
+ return typeof error?.hint === 'string' ? error.hint : ''
180
+ }
181
+
130
182
  function formatTime(value, lang) {
131
183
  if (typeof value !== 'string' || value === '') return '—'
132
184
  const date = new Date(value)
@@ -316,7 +368,18 @@ window.__ModuleLoader__.load({
316
368
  return h('div', { className: 'sd-toasts', 'aria-live': 'polite' },
317
369
  items.map((item) => h('div', { key: item.id, className: `sd-toast sd-toast-${item.tone}` },
318
370
  h('span', { className: 'sd-toast-icon' }, item.tone === 'error' ? h(Icons.warn, null) : h(Icons.check, null)),
319
- h('span', { className: 'sd-toast-text' }, item.text))))
371
+ h('div', { className: 'sd-toast-body' },
372
+ h('span', { className: 'sd-toast-text' }, item.text),
373
+ Array.isArray(item.links) && item.links.length > 0
374
+ ? h('div', { className: 'sd-toast-links' },
375
+ item.links.map((link) => h('a', {
376
+ key: link.href,
377
+ className: 'sd-toast-link',
378
+ href: link.href,
379
+ target: '_blank',
380
+ rel: 'noopener noreferrer',
381
+ }, link.label, h(Icons.external, null))))
382
+ : null))))
320
383
  }
321
384
 
322
385
  function CopyButton(props) {
@@ -364,23 +427,39 @@ window.__ModuleLoader__.load({
364
427
 
365
428
  function BundleEntryCard() {
366
429
  const t = useT()
367
- const openPanel = () => {
368
- const layout = hostServices.layout
369
- if (layout !== undefined && typeof layout.selectPanel === 'function') {
370
- try {
371
- layout.selectPanel('ship-deck')
372
- } catch {
373
- /* host without main-panel navigation */
374
- }
430
+ const enabled = useSidebarVisible()
431
+ const [saving, setSaving] = React.useState(false)
432
+ const [error, setError] = React.useState(null)
433
+ const toggle = async () => {
434
+ const next = !enabled
435
+ hostServices.sidebar?.setEnabled(next)
436
+ setSaving(true)
437
+ setError(null)
438
+ try {
439
+ await call('prefs.set', { sidebarVisible: next })
440
+ } catch (err) {
441
+ hostServices.sidebar?.setEnabled(!next)
442
+ setError(errorText(err))
443
+ } finally {
444
+ setSaving(false)
375
445
  }
376
446
  }
377
447
  return h('div', { className: 'sd-bundle-card' },
378
448
  h('div', { className: 'sd-bundle-icon' }, h(LogoMark, null)),
379
449
  h('div', { className: 'sd-bundle-copy' },
380
- h('strong', null, t('发布仓工作台', 'Release Depot workbench')),
381
- h('span', null, t('左侧栏「发布仓」或 设置 → 发布仓;登录 npm / GitHub 后即可发布与管理。',
382
- 'Open from 发布仓 in the left sidebar, or Settings → 发布仓; connect npm / GitHub to publish.'))),
383
- h('button', { type: 'button', className: 'sd-bundle-action', onClick: openPanel }, t('打开工作台', 'Open workbench')))
450
+ h('strong', null, t('左侧栏「发布仓」开关', 'Show Release Depot in sidebar')),
451
+ h('span', null, t('默认打开;关闭后隐藏左侧栏入口,可随时在这里重新打开。',
452
+ 'On by default. Turn it off to hide the left-sidebar entry; reopen it here anytime.')),
453
+ error !== null ? h('span', { className: 'sd-bundle-error' }, error) : null),
454
+ h('button', {
455
+ type: 'button',
456
+ role: 'switch',
457
+ className: 'sd-switch' + (enabled ? ' is-on' : ''),
458
+ 'aria-checked': enabled,
459
+ 'aria-label': t('左侧栏「发布仓」开关', 'Show Release Depot in sidebar'),
460
+ disabled: saving,
461
+ onClick: toggle,
462
+ }, h('span', { className: 'sd-switch-knob', 'aria-hidden': 'true' })))
384
463
  }
385
464
 
386
465
  // ── panel ──────────────────────────────────────────────────────────────
@@ -449,17 +528,18 @@ window.__ModuleLoader__.load({
449
528
  .catch(() => {})
450
529
  }, [status?.npm?.connected, refresh])
451
530
 
452
- const toast = React.useCallback((text, tone = 'ok') => {
531
+ const toast = React.useCallback((text, tone = 'ok', options = {}) => {
453
532
  const id = toastId.current
454
533
  toastId.current += 1
455
- setToasts((items) => [...items, { id, text, tone }])
534
+ const links = Array.isArray(options?.links) ? options.links : []
535
+ setToasts((items) => [...items, { id, text, tone, links }])
456
536
  window.setTimeout(() => {
457
537
  setToasts((items) => items.filter((item) => item.id !== id))
458
- }, tone === 'error' ? 7000 : 3500)
538
+ }, tone === 'error' ? 9000 : 3500)
459
539
  }, [])
460
540
 
461
541
  const fail = React.useCallback((error) => {
462
- toast(errorText(error), 'error')
542
+ toast(errorText(error), 'error', { links: errorLinks(error) })
463
543
  }, [toast])
464
544
 
465
545
  const go = React.useCallback((nextTab) => {
@@ -474,7 +554,6 @@ window.__ModuleLoader__.load({
474
554
  { id: 'dashboard', label: t('工作台', 'Workbench'), icon: Icons.dashboard },
475
555
  { id: 'packages', label: t('npm 包库', 'npm packages'), icon: Icons.package, badge: status?.counts?.npmPackages },
476
556
  { id: 'repos', label: t('GitHub 仓库', 'GitHub repos'), icon: Icons.repo, badge: status?.github?.connected ? 'ON' : null },
477
- { id: 'records', label: t('发布记录', 'Publish log'), icon: Icons.record, badge: status?.counts?.history },
478
557
  { id: 'settings', label: t('设置', 'Settings'), icon: Icons.settings },
479
558
  ]
480
559
 
@@ -482,7 +561,6 @@ window.__ModuleLoader__.load({
482
561
  dashboard: t('工作台', 'Workbench'),
483
562
  packages: t('npm 包库', 'npm packages'),
484
563
  repos: t('GitHub 仓库', 'GitHub repos'),
485
- records: t('发布记录', 'Publish log'),
486
564
  settings: t('设置', 'Settings'),
487
565
  }
488
566
 
@@ -520,7 +598,7 @@ window.__ModuleLoader__.load({
520
598
  h('div', null,
521
599
  h('strong', null, t('仅本机凭据', 'Local credentials only')),
522
600
  h('span', null, t('令牌只保存在 DSH home。', 'Tokens stay in your DSH home.')))),
523
- h('div', { className: 'sd-side-foot' }, h('span', null, `v${status?.version ?? '1.1.2'}`), h('span', null, t('本地运行', 'local runtime')))),
601
+ h('div', { className: 'sd-side-foot' }, h('span', null, `v${status?.version ?? '1.1.4'}`), h('span', null, t('本地运行', 'local runtime')))),
524
602
  h('main', { className: 'sd-main' },
525
603
  h('header', { className: 'sd-top' },
526
604
  h('div', { className: 'sd-crumb' },
@@ -531,9 +609,9 @@ window.__ModuleLoader__.load({
531
609
  h('span', { className: 'sd-pill ' + (status?.npm?.connected || status?.github?.connected ? 'sd-pill-ok' : 'sd-pill-warn') },
532
610
  h('span', { className: 'sd-dot' }),
533
611
  status?.npm?.connected && status?.github?.connected
534
- ? t('实时数据 · 双账号就绪', 'Live · both accounts ready')
612
+ ? t('双账号已连接', 'Both accounts connected')
535
613
  : status?.npm?.connected || status?.github?.connected
536
- ? t('实时数据 · 单账号', 'Live · one account')
614
+ ? t('单账号已连接', 'One account connected')
537
615
  : t('账号未连接', 'No account yet')))),
538
616
  h('div', { className: 'sd-hazard', 'aria-hidden': 'true' }),
539
617
  h('div', { className: 'sd-content' },
@@ -547,15 +625,14 @@ window.__ModuleLoader__.load({
547
625
  h('button', { type: 'button', className: 'sd-link-btn', onClick: () => setNoticeHidden(true) }, t('知道了', 'Got it')))
548
626
  : null,
549
627
  tab === 'dashboard' && h(Dashboard, {
550
- status, loading, refresh, openWizard, go, lang, t, onOpenDetail: setDetail,
628
+ status, loading, refresh, openWizard, lang, t, toast, fail, setConfirm,
551
629
  }),
552
- tab === 'packages' && h(PackagesPage, { status, t, lang, toast, fail, openWizard, onOpenDetail: setDetail, go }),
630
+ tab === 'packages' && h(PackagesPage, { status, t, lang, toast, fail, openWizard, onOpenDetail: setDetail, refreshStatus: refresh }),
553
631
  tab === 'repos' && h(ReposPage, {
554
- status, t, lang, toast, fail, openPush: setPushRepo, openReleases: setReleasesRepo, refreshStatus: refresh, go,
632
+ status, t, lang, toast, fail, openPush: setPushRepo, openReleases: setReleasesRepo, refreshStatus: refresh, setConfirm,
555
633
  }),
556
- tab === 'records' && h(RecordsPage, { t, lang, toast, fail, setConfirm }),
557
634
  tab === 'settings' && h(SettingsPage, {
558
- status, t, lang, toast, fail, refreshStatus: refresh,
635
+ status, t, lang, toast, fail, refreshStatus: refresh, setConfirm,
559
636
  }))),
560
637
  h(Toasts, { items: toasts }),
561
638
  detail !== null && h(PackageDetail, {
@@ -629,10 +706,10 @@ window.__ModuleLoader__.load({
629
706
  const github = status.github?.connected === true
630
707
  if (!npm && !github) {
631
708
  return {
632
- text: t('还没有连接账号。先在「设置」里登录 npm 或 GitHub,发布仓才能代你发布。',
633
- 'No account connected yet. Sign in to npm or GitHub under Settings before publishing.'),
634
- actionLabel: t('去设置', 'Open settings'),
635
- action: () => setTabAndScroll('settings'),
709
+ text: t('还没有连接账号。先在「npm 包库」或「GitHub 仓库」顶部登录,发布仓才能代你发布。',
710
+ 'No account connected yet. Sign in at the top of npm packages or GitHub repos before publishing.'),
711
+ actionLabel: t('去 npm 包库', 'Open npm packages'),
712
+ action: () => setTabAndScroll('packages'),
636
713
  }
637
714
  }
638
715
  if (npm && status?.npm?.expiresInDays !== null && status?.npm?.expiresInDays !== undefined && status.npm.expiresInDays <= 21) {
@@ -642,7 +719,7 @@ window.__ModuleLoader__.load({
642
719
  : t(`npm Token 还有 ${status.npm.expiresInDays} 天到期。npm 不再提供永久 Token,插件不会保存密码,因此不会自动续期;请到 Token 页面重新生成并更新到期日。`,
643
720
  `The npm token expires in ${status.npm.expiresInDays} days. npm no longer issues permanent tokens and the plugin does not store your password, so renewal is manual; regenerate it on the token page.`),
644
721
  actionLabel: t('去续期', 'Renew'),
645
- action: () => setTabAndScroll('settings'),
722
+ action: () => setTabAndScroll('packages'),
646
723
  }
647
724
  }
648
725
  if (npm && status?.npm?.bypass2fa === true) {
@@ -650,7 +727,7 @@ window.__ModuleLoader__.load({
650
727
  text: t('当前 npm Token 勾选了 Bypass two-factor authentication。npm 会在 2027 年 1 月撤销这类 Token;建议改用普通 Granular Token,并在发布时填 6 位 TOTP。',
651
728
  'This npm token bypasses two-factor authentication. npm will revoke such tokens in January 2027; switch to a normal granular token and enter the 6-digit TOTP at publish time.'),
652
729
  actionLabel: t('去更换', 'Replace'),
653
- action: () => setTabAndScroll('settings'),
730
+ action: () => setTabAndScroll('packages'),
654
731
  }
655
732
  }
656
733
  if (!github) {
@@ -658,7 +735,7 @@ window.__ModuleLoader__.load({
658
735
  text: t('npm 已连接,GitHub 未连接。发布到 npm 可以直接开始;GitHub Packages 与 Release 需要先连接 GitHub。',
659
736
  'npm is connected, GitHub is not. npm publishing works now; GitHub Packages and releases need GitHub.'),
660
737
  actionLabel: t('连接 GitHub', 'Connect GitHub'),
661
- action: () => setTabAndScroll('settings'),
738
+ action: () => setTabAndScroll('repos'),
662
739
  }
663
740
  }
664
741
  if (!npm) {
@@ -666,7 +743,7 @@ window.__ModuleLoader__.load({
666
743
  text: t('GitHub 已连接,npm 未连接。可以推送仓库和创建 Release;发布到 npm 需要先登录。',
667
744
  'GitHub is connected, npm is not. Repos and releases work; npm publishing needs a token.'),
668
745
  actionLabel: t('连接 npm', 'Connect npm'),
669
- action: () => setTabAndScroll('settings'),
746
+ action: () => setTabAndScroll('packages'),
670
747
  }
671
748
  }
672
749
  return {
@@ -702,82 +779,83 @@ window.__ModuleLoader__.load({
702
779
  }
703
780
 
704
781
  function Dashboard(props) {
705
- const { status, loading, refresh, openWizard, go, lang, t } = props
782
+ const { status, loading, refresh, openWizard, lang, t, toast, fail, setConfirm } = props
783
+ const [records, setRecords] = React.useState(null)
784
+ const [recordsLoading, setRecordsLoading] = React.useState(false)
785
+ const [recordsError, setRecordsError] = React.useState(null)
786
+
787
+ const loadRecords = React.useCallback(async () => {
788
+ setRecordsLoading(true)
789
+ try {
790
+ const result = await call('history', { limit: 100 })
791
+ setRecords(result.items ?? [])
792
+ setRecordsError(null)
793
+ } catch (error) {
794
+ setRecordsError(error)
795
+ } finally {
796
+ setRecordsLoading(false)
797
+ }
798
+ }, [])
799
+
800
+ React.useEffect(() => { loadRecords() }, [loadRecords, status?.counts?.history])
801
+
706
802
  if (loading && status === null) {
707
803
  return h('div', { className: 'sd-loading' }, h(Spinner, { large: true }), h('span', null, t('读取中…', 'Loading…')))
708
804
  }
709
805
  const npmConnected = status?.npm?.connected === true
710
806
  const githubConnected = status?.github?.connected === true
711
- const both = npmConnected && githubConnected
712
807
  const projects = status?.recentProjects ?? []
713
- const recent = status?.recentHistory ?? []
714
- const stateTitle = both
715
- ? t('发布就绪 · 选择项目', 'Ready to ship · pick a project')
716
- : npmConnected || githubConnected
717
- ? t('部分就绪 · 还差一个账号', 'Partly ready · one account missing')
718
- : t('等待账号 · 尚未连接', 'Waiting · connect an account')
719
- const stateBody = both
720
- ? t('npm 与 GitHub 均已连接。打包、发布、建 Release 都在本地完成,令牌不会离开这台机器。',
721
- 'npm and GitHub are connected. Packing, publishing and releases run locally; tokens never leave this machine.')
722
- : npmConnected
723
- ? t('npm 可以发布。连接 GitHub 后还能推仓库、发 GitHub Packages 与 Release。',
724
- 'npm is ready. Connect GitHub for repo pushes, GitHub Packages and releases.')
725
- : githubConnected
726
- ? t('GitHub 可以推送与建 Release。登录 npm 后即可发布包版本。',
727
- 'GitHub is ready for pushes and releases. Connect npm to publish versions.')
728
- : t('先连接 npm 或 GitHub。连接只需要一个 Token 或一次设备流授权。',
729
- 'Connect npm or GitHub first: a token or a device-flow approval is enough.')
808
+
809
+ const clearRecords = () => {
810
+ setConfirm({
811
+ title: t('清空发布记录?', 'Clear publish log?'),
812
+ body: t('只删除本机的记录,不会影响 npm 包或 GitHub Release。', 'Only the local log is removed; npm packages and GitHub releases are untouched.'),
813
+ confirmLabel: t('清空', 'Clear'),
814
+ onConfirm: async () => {
815
+ try {
816
+ await call('history.clear')
817
+ setRecords([])
818
+ refresh()
819
+ toast(t('发布记录已清空', 'Publish log cleared'), 'ok')
820
+ } catch (error) {
821
+ fail(error)
822
+ }
823
+ },
824
+ })
825
+ }
730
826
 
731
827
  return h('div', { className: 'sd-page' },
732
828
  h('div', { className: 'sd-glance' },
733
829
  h('div', null,
734
- h('span', { className: 'sd-eyebrow' }, 'AT A GLANCE'),
830
+ h('span', { className: 'sd-eyebrow' }, 'WORKBENCH'),
735
831
  h('h1', { className: 'sd-h1' }, t('工作台', 'Workbench')),
736
- h('p', { className: 'sd-sub' }, t('管理 npm 与 GitHub 的账号、包、版本与发布。', 'Manage npm and GitHub accounts, packages, versions and releases.'))),
737
- h('span', { className: 'sd-mini-badge' }, t('实时 · 本地凭据', 'Live · local credentials'))),
738
- h('div', { className: 'sd-dash-grid' },
739
- h('section', { className: 'sd-state-card' },
740
- h('div', { className: 'sd-state-head' },
741
- h('div', { className: 'sd-state-tile' }, h(LogoMark, null)),
742
- h('div', { className: 'sd-state-copy' },
743
- h('h2', { className: 'sd-state-title' }, stateTitle),
744
- h('p', { className: 'sd-state-body' }, stateBody))),
745
- h('div', { className: 'sd-state-actions' },
746
- h(Btn, { variant: 'primary', onClick: () => openWizard({}) }, h(Icons.play, null), t('打开发布向导', 'Open publish wizard')),
747
- h(Btn, { variant: 'default', onClick: refresh }, h(Icons.refresh, null), t('刷新状态', 'Refresh')),
748
- h(Btn, { variant: 'ghost', onClick: () => go('records') }, t('查看记录', 'View log'))),
749
- h('div', { className: 'sd-dash' }),
750
- h('div', { className: 'sd-steps' },
751
- step(1, t('选择项目', 'Pick project'), true),
752
- step(2, t('选择目标', 'Pick targets'), false),
753
- step(3, t('确认发布', 'Confirm'), false))),
754
- h('div', { className: 'sd-stat-stack' },
755
- h(StatCard, {
756
- color: 'mint',
757
- label: t('npm 包', 'NPM PACKAGES'),
758
- value: status?.counts?.npmPackages ?? '—',
759
- sub: npmConnected
760
- ? t(`账号 @${status.npm.username ?? '?'} 可管理的包`, `packages @${status.npm.username ?? '?'} can manage`)
761
- : t('连接 npm 后加载包列表', 'connect npm to load packages'),
762
- }),
763
- h(StatCard, {
764
- color: 'blue',
765
- label: t('GitHub Releases', 'GITHUB RELEASES'),
766
- value: status?.counts?.githubReleases ?? 0,
767
- sub: githubConnected
768
- ? t(`账号 @${status.github.login ?? '?'} · 本地记录`, `@${status.github.login ?? '?'} · local log`)
769
- : t('连接 GitHub 后可创建 Release', 'connect GitHub to create releases'),
770
- }),
771
- h(StatCard, {
772
- color: 'pink',
773
- label: t('本地发布记录', 'LOCAL PUBLISHES'),
774
- value: status?.counts?.history ?? 0,
775
- sub: t('只保存在本机,不上传', 'stored locally, never uploaded'),
776
- }))),
832
+ h('p', { className: 'sd-sub' }, t('账号、包、Release 与发布记录都在这里。', 'Accounts, packages, releases and the publish log in one place.'))),
833
+ h('div', { className: 'sd-page-actions' },
834
+ h(Btn, { variant: 'primary', onClick: () => openWizard({}) }, h(Icons.play, null), t('打开发布向导', 'Publish')),
835
+ h(Btn, { variant: 'default', onClick: refresh, busy: loading }, h(Icons.refresh, null), t('刷新', 'Refresh')))),
836
+ h('div', { className: 'sd-stat-grid' },
837
+ h(StatCard, {
838
+ color: 'mint',
839
+ label: t('npm 包', 'NPM PACKAGES'),
840
+ value: status?.counts?.npmPackages ?? '—',
841
+ sub: npmConnected ? `@${status.npm.username ?? '?'}` : t('连接 npm 后加载', 'connect npm'),
842
+ }),
843
+ h(StatCard, {
844
+ color: 'blue',
845
+ label: t('GitHub Releases', 'GITHUB RELEASES'),
846
+ value: status?.counts?.githubReleases ?? 0,
847
+ sub: githubConnected ? `@${status.github.login ?? '?'}` : t('连接 GitHub 后可创建', 'connect GitHub'),
848
+ }),
849
+ h(StatCard, {
850
+ color: 'pink',
851
+ label: t('本地发布记录', 'LOCAL PUBLISHES'),
852
+ value: status?.counts?.history ?? 0,
853
+ sub: t('只保存在本机', 'stored locally'),
854
+ })),
777
855
  h('section', { className: 'sd-section' },
778
856
  h('div', { className: 'sd-section-head' },
779
857
  h('h2', { className: 'sd-section-title' }, t('从最近项目开始', 'Start from a recent project')),
780
- h('span', { className: 'sd-section-hint' }, t('发布记录里的项目会出现在这里', 'Projects with history appear here'))),
858
+ h('span', { className: 'sd-section-hint' }, t('发布过的项目会出现在这里', 'Projects with history appear here'))),
781
859
  projects.length === 0
782
860
  ? h('div', { className: 'sd-project-empty' },
783
861
  h('div', { className: 'sd-empty-icon' }, h(Icons.folder, null)),
@@ -796,17 +874,19 @@ window.__ModuleLoader__.load({
796
874
  })))),
797
875
  h('section', { className: 'sd-section' },
798
876
  h('div', { className: 'sd-section-head' },
799
- h('h2', { className: 'sd-section-title' }, t('最近发布', 'Recent publishes')),
800
- h('button', { type: 'button', className: 'sd-link-btn', onClick: () => go('records') }, t('全部记录 →', 'All records →'))),
801
- recent.length === 0
802
- ? h('div', { className: 'sd-empty sd-empty-flat' }, h('span', null, t('还没有发布记录。完成一次发布后会记录在这里。', 'No publish records yet. The first publish will appear here.')))
803
- : h(HistoryTable, { items: recent, compact: true, t, lang })))
804
-
805
- function step(number, label, active) {
806
- return h('div', { className: 'sd-step' + (active ? ' is-active' : '') },
807
- h('span', { className: 'sd-step-num' }, String(number)),
808
- h('span', null, label))
809
- }
877
+ h('h2', { className: 'sd-section-title' }, t('发布记录', 'Publish log')),
878
+ h('div', { className: 'sd-inline-row' },
879
+ h(Btn, { size: 'sm', variant: 'ghost', onClick: loadRecords, busy: recordsLoading }, h(Icons.refresh, null), t('刷新', 'Refresh')),
880
+ records !== null && records.length > 0 ? h(Btn, { size: 'sm', variant: 'ghost', onClick: clearRecords }, h(Icons.trash, null), t('清空', 'Clear')) : null)),
881
+ recordsError !== null
882
+ ? h('div', { className: 'sd-note sd-note-danger sd-inline-row' },
883
+ h('span', { style: { flex: 1 } }, errorText(recordsError)),
884
+ h(Btn, { size: 'sm', onClick: loadRecords }, t('重试', 'Retry')))
885
+ : recordsLoading && records === null
886
+ ? h('div', { className: 'sd-loading' }, h(Spinner, { large: true }))
887
+ : records !== null && records.length === 0
888
+ ? h('div', { className: 'sd-empty sd-empty-flat' }, h('span', null, t('还没有发布记录。完成一次发布后会记录在这里。', 'No publish records yet. The first publish will appear here.')))
889
+ : h(HistoryTable, { items: records ?? [], t, lang })))
810
890
  }
811
891
 
812
892
  function ProjectCard(props) {
@@ -899,7 +979,7 @@ window.__ModuleLoader__.load({
899
979
  // ── npm packages ───────────────────────────────────────────────────────
900
980
 
901
981
  function PackagesPage(props) {
902
- const { status, t, lang, toast, fail, openWizard, onOpenDetail, go } = props
982
+ const { status, t, lang, toast, fail, openWizard, onOpenDetail, refreshStatus } = props
903
983
  const [data, setData] = React.useState(null)
904
984
  const [loading, setLoading] = React.useState(true)
905
985
  const [query, setQuery] = React.useState('')
@@ -916,33 +996,16 @@ window.__ModuleLoader__.load({
916
996
  const result = await call('npm.packages', { limit: 60, refresh })
917
997
  setData(result)
918
998
  setError(null)
999
+ if (typeof refreshStatus === 'function') refreshStatus()
919
1000
  } catch (err) {
920
1001
  setError(err)
921
1002
  } finally {
922
1003
  setLoading(false)
923
1004
  }
924
- }, [connected])
1005
+ }, [connected, refreshStatus])
925
1006
 
926
1007
  React.useEffect(() => { load(false) }, [load])
927
1008
 
928
- if (!connected) {
929
- return h('div', { className: 'sd-page' },
930
- h(PageHead, {
931
- eyebrow: 'NPM REGISTRY',
932
- title: t('npm 包库', 'npm packages'),
933
- desc: t('登录 npm 后,这里会列出你有权限管理的包,并支持 dist-tag、废弃与删除。',
934
- 'After signing in, this lists packages you can manage and offers dist-tags, deprecation and unpublish.'),
935
- actions: h(Btn, { variant: 'primary', onClick: () => go('settings') }, t('连接 npm', 'Connect npm')),
936
- }),
937
- h(EmptyState, {
938
- icon: h(Icons.npm, null),
939
- title: t('npm 尚未登录', 'npm is not connected'),
940
- body: t('粘贴一个 Granular Access Token(勾选 Read and write),发布仓即可读取你的包。',
941
- 'Paste a Granular Access Token with Read and write access to load your packages.'),
942
- action: h(Btn, { variant: 'primary', onClick: () => go('settings') }, t('去设置', 'Open settings')),
943
- }))
944
- }
945
-
946
1009
  const items = (data?.items ?? []).filter((item) => {
947
1010
  const text = query.trim().toLowerCase()
948
1011
  if (text === '') return true
@@ -953,59 +1016,68 @@ window.__ModuleLoader__.load({
953
1016
  h(PageHead, {
954
1017
  eyebrow: 'NPM REGISTRY',
955
1018
  title: t('npm 包库', 'npm packages'),
956
- desc: t('读取你有写权限的包;dist-tag、废弃与删除都直接调用 registry。',
957
- 'Packages you can write to, with registry-backed dist-tags, deprecation and unpublish.'),
1019
+ desc: t('账号、包列表与版本管理;dist-tag、访问级别、废弃与删除都直接调用 registry。',
1020
+ 'Account, packages and version management; dist-tags, access, deprecation and unpublish call the registry.'),
958
1021
  actions: h(React.Fragment, null,
959
- h(Btn, { onClick: () => load(true), busy: loading }, h(Icons.refresh, null), t('刷新', 'Refresh')),
1022
+ connected ? h(Btn, { onClick: () => load(true), busy: loading }, h(Icons.refresh, null), t('刷新', 'Refresh')) : null,
960
1023
  h(Btn, { variant: 'primary', onClick: () => openWizard({}) }, h(Icons.plus, null), t('发布新包', 'Publish'))),
961
1024
  }),
962
- h('div', { className: 'sd-toolbar' },
963
- h('div', { className: 'sd-search' },
964
- h('span', { className: 'sd-search-icon' }, h(Icons.package, null)),
965
- h('input', {
966
- type: 'search',
967
- className: 'sd-input sd-search-input',
968
- placeholder: t('按包名或描述过滤…', 'Filter by name or description…'),
969
- 'aria-label': t('过滤 npm 包', 'Filter npm packages'),
970
- value: query,
971
- onChange: (event) => setQuery(event.target.value),
972
- })),
973
- data !== null && h(Chip, { tone: 'plain' }, data.source === 'search'
974
- ? t('来自 registry 搜索', 'registry search')
975
- : t('账号授权列表', 'account access list')),
976
- data !== null && h('span', { className: 'sd-toolbar-note' },
977
- `${data.total ?? items.length} ${t('个包', 'packages')}${data.truncated ? t('(已截断)', ' (truncated)') : ''}`)),
978
- data?.warnings?.length > 0
979
- ? h('div', { className: 'sd-note sd-note-warn' }, data.warnings.map((warning, index) => h('div', { key: index }, warning)))
980
- : null,
981
- error !== null
982
- ? h('div', { className: 'sd-note sd-note-danger' }, errorText(error))
983
- : null,
984
- loading && data === null
985
- ? h('div', { className: 'sd-loading' }, h(Spinner, { large: true }), h('span', null, t('读取包列表…', 'Loading packages…')))
986
- : items.length === 0
987
- ? h(EmptyState, {
988
- title: t('没有匹配的包', 'No matching packages'),
989
- body: error !== null ? t('上一次读取失败,可以点刷新重试。', 'The last read failed; try Refresh.') : t('换一个关键词,或先发布第一个包。', 'Try another keyword, or publish your first package.'),
990
- })
991
- : h('div', { className: 'sd-pkg-list' },
992
- items.map((item) => h(PackageRow, {
993
- key: item.name,
994
- item,
995
- t,
996
- lang,
997
- status,
998
- onOpen: () => onOpenDetail(item.name),
999
- onCopy: async () => {
1000
- const command = `npm i ${item.name}@${item.version ?? 'latest'}`
1001
- try {
1002
- await navigator.clipboard.writeText(command)
1003
- toast(t('已复制安装命令', 'Install command copied'), 'ok')
1004
- } catch {
1005
- toast(command, 'ok')
1006
- }
1007
- },
1008
- }))))
1025
+ h(NpmAccountCard, { status, t, toast, fail, refreshStatus, packageCount: data?.total ?? null }),
1026
+ connected
1027
+ ? h(React.Fragment, null,
1028
+ h('div', { className: 'sd-toolbar' },
1029
+ h('div', { className: 'sd-search' },
1030
+ h('span', { className: 'sd-search-icon' }, h(Icons.package, null)),
1031
+ h('input', {
1032
+ type: 'search',
1033
+ className: 'sd-input sd-search-input',
1034
+ placeholder: t('按包名或描述过滤…', 'Filter by name or description…'),
1035
+ 'aria-label': t('过滤 npm 包', 'Filter npm packages'),
1036
+ value: query,
1037
+ onChange: (event) => setQuery(event.target.value),
1038
+ })),
1039
+ data !== null && h(Chip, { tone: 'plain' }, data.source === 'search'
1040
+ ? t('公开搜索 · 私有包不显示', 'public search · private packages hidden')
1041
+ : t('账号授权列表', 'account access list')),
1042
+ data !== null && h('span', { className: 'sd-toolbar-note' },
1043
+ `${data.total ?? items.length} ${t('个包', 'packages')}${data.truncated ? t('(已截断)', ' (truncated)') : ''}`)),
1044
+ data?.warnings?.length > 0
1045
+ ? h('div', { className: 'sd-note' }, data.warnings.map((warning, index) => h('div', { key: index }, warning)))
1046
+ : null,
1047
+ error !== null
1048
+ ? h('div', { className: 'sd-note sd-note-danger' }, errorText(error))
1049
+ : null,
1050
+ loading && data === null
1051
+ ? h('div', { className: 'sd-loading' }, h(Spinner, { large: true }), h('span', null, t('读取包列表…', 'Loading packages…')))
1052
+ : items.length === 0
1053
+ ? h(EmptyState, {
1054
+ title: t('没有匹配的包', 'No matching packages'),
1055
+ body: error !== null ? t('上一次读取失败,可以点刷新重试。', 'The last read failed; try Refresh.') : t('换一个关键词,或先发布第一个包。', 'Try another keyword, or publish your first package.'),
1056
+ })
1057
+ : h('div', { className: 'sd-pkg-list' },
1058
+ items.map((item) => h(PackageRow, {
1059
+ key: item.name,
1060
+ item,
1061
+ t,
1062
+ lang,
1063
+ status,
1064
+ onOpen: () => onOpenDetail(item.name),
1065
+ onCopy: async () => {
1066
+ const command = `npm i ${item.name}@${item.version ?? 'latest'}`
1067
+ try {
1068
+ await navigator.clipboard.writeText(command)
1069
+ toast(t('已复制安装命令', 'Install command copied'), 'ok')
1070
+ } catch {
1071
+ toast(command, 'ok')
1072
+ }
1073
+ },
1074
+ }))))
1075
+ : h(EmptyState, {
1076
+ icon: h(Icons.npm, null),
1077
+ title: t('npm 尚未登录', 'npm is not connected'),
1078
+ body: t('在上方粘贴 Granular Access Token(Permissions 选 Read and write (publish and stage)),保存后即可读取你的包。',
1079
+ 'Paste a granular access token above with Read and write (publish and stage) to load your packages.'),
1080
+ }))
1009
1081
  }
1010
1082
 
1011
1083
  function PackageRow(props) {
@@ -1048,7 +1120,7 @@ window.__ModuleLoader__.load({
1048
1120
  const [deprecateMessage, setDeprecateMessage] = React.useState('')
1049
1121
  const [deprecateOtp, setDeprecateOtp] = React.useState('')
1050
1122
  const [deprecateBusy, setDeprecateBusy] = React.useState(false)
1051
- const [unpublish, setUnpublish] = React.useState({ version: '', confirmName: '', otp: '', whole: false, open: false })
1123
+ const [unpublish, setUnpublish] = React.useState({ version: '', confirmName: '', whole: false, open: false })
1052
1124
  const [accessForm, setAccessForm] = React.useState({ access: 'public', otp: '' })
1053
1125
  const [accessBusy, setAccessBusy] = React.useState(false)
1054
1126
  const [ownerForm, setOwnerForm] = React.useState({ user: '', otp: '' })
@@ -1164,11 +1236,36 @@ window.__ModuleLoader__.load({
1164
1236
  toast(t('请输入完整包名以确认删除整包', 'Type the exact package name to remove the whole package'), 'error')
1165
1237
  return
1166
1238
  }
1239
+ resetScratch()
1167
1240
  setConfirm?.({
1168
1241
  title: t('删除 npm 包内容', 'Remove from npm'),
1169
1242
  body: unpublish.whole
1170
1243
  ? t(`即将删除整个包 ${name} 及其所有版本。这可能不可恢复。`, `This removes ${name} and every version. It may be unrecoverable.`)
1171
1244
  : t(`即将删除 ${name}@${version}。同一天内可重新发布该版本。`, `This removes ${name}@${version}. npm allows republishing that version only within the same day.`),
1245
+ note: h('div', { className: 'sd-confirm-otp' },
1246
+ h('strong', { className: 'sd-confirm-warn' },
1247
+ t('npm 侧大概率还没启用 2FA', 'npm 2FA is probably not enabled yet')),
1248
+ h('span', { className: 'sd-field-hint' },
1249
+ t('npm 的规则是「账号开启 2FA」或「Token 勾选 Bypass 2FA」二选一。如果账号没绑验证器,这里填任何 6 位数字都会被拒绝——因为 npm 根本不校验它。',
1250
+ 'npm requires either account 2FA or a bypass-2FA token. If no authenticator is registered, any 6-digit code is rejected — npm never even checks it.')),
1251
+ h(TextInput, {
1252
+ defaultValue: OT.npmOtp,
1253
+ placeholder: t('已绑定验证器时填 6 位码', '6-digit code if an authenticator is registered'),
1254
+ inputMode: 'numeric',
1255
+ autoComplete: 'one-time-code',
1256
+ maxLength: 6,
1257
+ autoFocus: true,
1258
+ onChange: (event) => { OT.npmOtp = event.target.value },
1259
+ }),
1260
+ h('span', { className: 'sd-confirm-otp-warn' },
1261
+ t('⚠ 恢复码(recovery codes)不能填这里:npm 只接受真正的动态码,填恢复码会触发 72 小时安全限制,期间无法发布或删除。',
1262
+ '⚠ Do not paste recovery codes here: npm only accepts a real TOTP. A recovery code triggers a 72-hour security hold during which publishing and unpublishing are blocked.')),
1263
+ h('span', { className: 'sd-field-hint' },
1264
+ t('两个更省事的选择:', 'Two easier options: '),
1265
+ h('a', { className: 'sd-link', href: `https://www.npmjs.com/package/${name}/access`, target: '_blank', rel: 'noopener noreferrer' }, t('在 npm 网页删除', 'delete on npm')),
1266
+ t(',或 '),
1267
+ h('a', { className: 'sd-link', href: 'https://www.npmjs.com/settings/~/two-factor-authentication', target: '_blank', rel: 'noopener noreferrer' }, t('去开启 2FA', 'enable 2FA')),
1268
+ t('(开启时会显示二维码和 secret,可导入电脑上的验证器)。', ' (setup shows a QR code and secret you can import into a desktop authenticator).'))),
1172
1269
  danger: true,
1173
1270
  confirmLabel: t('确认删除', 'Remove'),
1174
1271
  onConfirm: async () => {
@@ -1177,7 +1274,7 @@ window.__ModuleLoader__.load({
1177
1274
  version: unpublish.whole ? '' : version,
1178
1275
  force: true,
1179
1276
  confirmName: unpublish.confirmName.trim(),
1180
- otp: unpublish.otp.trim(),
1277
+ otp: OT.npmOtp.trim(),
1181
1278
  })
1182
1279
  toast(t('删除成功', 'Removed'), 'ok')
1183
1280
  if (unpublish.whole) {
@@ -1271,9 +1368,8 @@ window.__ModuleLoader__.load({
1271
1368
  },
1272
1369
  h('option', { value: '' }, t('选择版本', 'select version')),
1273
1370
  info.versions.map((version) => h('option', { key: version.version, value: version.version }, version.version))),
1274
- h(TextInput, { placeholder: 'OTP(若开启 2FA)', value: unpublish.otp, onChange: (event) => setUnpublish({ ...unpublish, otp: event.target.value }), maxLength: 6 }),
1275
1371
  h(Btn, { size: 'sm', variant: 'danger', onClick: askUnpublish }, h(Icons.trash, null), t('删除', 'Remove')))
1276
- : h('div', { className: 'sd-field-hint' }, t('npm 只允许同一天内重新发布被删除的版本。', 'npm lets you republish a removed version only within the same day.')))),
1372
+ : h('div', { className: 'sd-field-hint' }, t('npm 只允许同一天内重新发布被删除的版本;删除需要在 npm 网页或 npm CLI 完成。', 'npm only allows republishing a removed version the same day; deletion must be done on the npm website or with the npm CLI.')))),
1277
1373
  h('section', { className: 'sd-subcard' },
1278
1374
  h('div', { className: 'sd-subhead' }, h('h3', null, t('访问级别', 'Access')), h(Icons.shield, null)),
1279
1375
  h('div', { className: 'sd-inline-row' },
@@ -1284,7 +1380,7 @@ window.__ModuleLoader__.load({
1284
1380
  onChange: (event) => setAccessForm({ ...accessForm, access: event.target.value }),
1285
1381
  },
1286
1382
  h('option', { value: 'public' }, 'public'),
1287
- h('option', { value: 'private' }, t('private(仅 scoped 包)', 'private (scoped only)'))),
1383
+ h('option', { value: 'restricted' }, t('private(仅 scoped 包)', 'private (scoped only)'))),
1288
1384
  h(TextInput, { placeholder: 'OTP', 'aria-label': t('一次性验证码', 'one-time code'), value: accessForm.otp, maxLength: 6, className: 'sd-input-mini', onChange: (event) => setAccessForm({ ...accessForm, otp: event.target.value }) }),
1289
1385
  h(Btn, { size: 'sm', variant: 'primary', busy: accessBusy, onClick: saveAccess }, t('更新', 'Update'))),
1290
1386
  h('div', { className: 'sd-field-hint' }, t('只有 scoped 包(@scope/name)可以设为 private;私有包可能需要付费账户。', 'Only scoped packages can be private; private packages may require a paid account.'))),
@@ -1352,7 +1448,7 @@ window.__ModuleLoader__.load({
1352
1448
  // ── GitHub repos ───────────────────────────────────────────────────────
1353
1449
 
1354
1450
  function ReposPage(props) {
1355
- const { status, t, lang, toast, fail, openPush, openReleases, refreshStatus, go } = props
1451
+ const { status, t, lang, toast, fail, openPush, openReleases, refreshStatus, setConfirm } = props
1356
1452
  const [repos, setRepos] = React.useState([])
1357
1453
  const [loading, setLoading] = React.useState(true)
1358
1454
  const [reposError, setReposError] = React.useState(null)
@@ -1402,19 +1498,72 @@ window.__ModuleLoader__.load({
1402
1498
  }
1403
1499
  }
1404
1500
 
1501
+ const missingDeleteScope = connected &&
1502
+ Array.isArray(status?.github?.scopes) && status.github.scopes.length > 0 &&
1503
+ !status.github.scopes.includes('delete_repo')
1504
+
1505
+ const askDeleteRepo = (repo) => {
1506
+ resetScratch()
1507
+ setConfirm?.({
1508
+ title: t(`删除仓库 ${repo.fullName}?`, `Delete ${repo.fullName}?`),
1509
+ body: t('将永久删除该仓库及其所有代码、Issue、Release 与 tag;GitHub 不提供回收站。', 'This permanently deletes the repository, all code, issues, releases and tags; GitHub has no trash.'),
1510
+ note: h('div', { className: 'sd-confirm-otp' },
1511
+ missingDeleteScope
1512
+ ? h(React.Fragment, null,
1513
+ h('strong', { className: 'sd-confirm-warn' }, t('当前 Token 缺少 delete_repo 权限', 'This token lacks delete_repo')),
1514
+ h('span', { className: 'sd-field-hint' },
1515
+ t('你的 Token scopes 是 ', 'Your token scopes are '),
1516
+ h('code', null, (status.github.scopes ?? []).join(', ')),
1517
+ t(',里面没有 delete_repo,所以删除一定会被 GitHub 拒绝。', ' — no delete_repo, so GitHub will always refuse.')),
1518
+ h('a', {
1519
+ className: 'sd-btn sd-btn-sm sd-btn-primary',
1520
+ href: 'https://github.com/settings/tokens',
1521
+ target: '_blank',
1522
+ rel: 'noopener noreferrer',
1523
+ }, t('去 GitHub 勾选 delete_repo 并重新生成', 'Add delete_repo on GitHub')) ,
1524
+ h('span', { className: 'sd-field-hint' },
1525
+ t('重新生成后回到「GitHub 仓库」顶部更新 Token 即可。', 'After regenerating, update the token at the top of GitHub repos.')))
1526
+ : h(React.Fragment, null,
1527
+ h('span', { className: 'sd-field-hint' }, t(`输入 ${repo.fullName} 确认;需要该仓库的 Administration 权限。`, `Type ${repo.fullName}; requires Administration access to this repository.`)),
1528
+ h(TextInput, {
1529
+ autoFocus: true,
1530
+ placeholder: repo.fullName,
1531
+ onChange: (event) => { OT.confirmText = event.target.value },
1532
+ }))),
1533
+ danger: true,
1534
+ confirmLabel: t('永久删除仓库', 'Delete repository'),
1535
+ onConfirm: async () => {
1536
+ if (missingDeleteScope) {
1537
+ throw new Error(t('Token 缺少 delete_repo,请先在 GitHub 上重新生成 Token。', 'The token lacks delete_repo; regenerate it on GitHub first.'))
1538
+ }
1539
+ if (OT.confirmText.trim() !== repo.fullName) {
1540
+ throw new Error(t(`请准确输入 ${repo.fullName}`, `Type ${repo.fullName} exactly`))
1541
+ }
1542
+ await call('github.delete-repo', {
1543
+ owner: repo.owner,
1544
+ repo: repo.name,
1545
+ force: true,
1546
+ confirmName: OT.confirmText.trim(),
1547
+ })
1548
+ toast(t(`已删除 ${repo.fullName}`, `Deleted ${repo.fullName}`), 'ok')
1549
+ await load(true)
1550
+ refreshStatus()
1551
+ },
1552
+ })
1553
+ }
1554
+
1405
1555
  if (!connected) {
1406
1556
  return h('div', { className: 'sd-page' },
1407
1557
  h(PageHead, {
1408
1558
  eyebrow: 'GITHUB',
1409
1559
  title: t('GitHub 仓库', 'GitHub repos'),
1410
- desc: t('连接 GitHub 后可以列出仓库、推送目录、创建 Release。', 'Connect GitHub to list repositories, push a directory and create releases.'),
1411
- actions: h(Btn, { variant: 'primary', onClick: () => go('settings') }, t('连接 GitHub', 'Connect GitHub')),
1560
+ desc: t('账号、仓库、Release 与推送;连接后可以列出仓库、推送目录、创建 Release。', 'Account, repositories, releases and pushes.'),
1412
1561
  }),
1562
+ h(GithubAccountCard, { status, t, toast, fail, refreshStatus }),
1413
1563
  h(EmptyState, {
1414
1564
  icon: h(Icons.github, null),
1415
1565
  title: t('GitHub 尚未连接', 'GitHub is not connected'),
1416
- body: t('用设备流或 Personal Access Token 登录;令牌只保存在本机。', 'Sign in with the device flow or a personal access token; the token stays local.'),
1417
- action: h(Btn, { variant: 'primary', onClick: () => go('settings') }, t('去设置', 'Open settings')),
1566
+ body: t('在上方用设备流或 Personal Access Token 登录;令牌只保存在本机。', 'Sign in above with the device flow or a personal access token; the token stays local.'),
1418
1567
  }))
1419
1568
  }
1420
1569
 
@@ -1431,17 +1580,7 @@ window.__ModuleLoader__.load({
1431
1580
  'Repositories you own or collaborate on; push a directory as a commit, and attach the npm tarball to a release.'),
1432
1581
  actions: h(Btn, { onClick: () => load(true), busy: loading }, h(Icons.refresh, null), t('刷新', 'Refresh')),
1433
1582
  }),
1434
- h('div', { className: 'sd-account-strip' },
1435
- status.github.avatarUrl
1436
- ? h('img', { className: 'sd-avatar', src: status.github.avatarUrl, alt: '' })
1437
- : h('span', { className: 'sd-avatar sd-avatar-fallback' }, h(Icons.github, null)),
1438
- h('div', { className: 'sd-account-copy' },
1439
- h('strong', null, `@${status.github.login}`),
1440
- h('span', null, status.github.name ? `${status.github.name} · ${t('已连接', 'connected')}` : t('已连接', 'connected'))),
1441
- h('div', { className: 'sd-account-tags' },
1442
- (status.github.scopes ?? []).slice(0, 5).map((scope) => h(Chip, { key: scope, tone: 'plain' }, scope)),
1443
- h('a', { className: 'sd-link', href: `https://github.com/${status.github.login}`, target: '_blank', rel: 'noopener noreferrer' }, t('打开主页', 'Profile'))),
1444
- ),
1583
+ h(GithubAccountCard, { status, t, toast, fail, refreshStatus }),
1445
1584
  h('div', { className: 'sd-repo-layout' },
1446
1585
  h('section', { className: 'sd-repo-main' },
1447
1586
  h('div', { className: 'sd-toolbar' },
@@ -1477,6 +1616,7 @@ window.__ModuleLoader__.load({
1477
1616
  h('div', { className: 'sd-repo-actions' },
1478
1617
  h(Btn, { size: 'sm', onClick: () => openPush(repo) }, t('推送目录', 'Push dir')),
1479
1618
  h(Btn, { size: 'sm', variant: 'ghost', onClick: () => openReleases(repo) }, t('Releases', 'Releases')),
1619
+ h(Btn, { size: 'sm', variant: 'danger', onClick: () => askDeleteRepo(repo) }, h(Icons.trash, null), t('删除', 'Delete')),
1480
1620
  repo.htmlUrl ? h('a', {
1481
1621
  className: 'sd-btn sd-btn-sm sd-btn-ghost', href: repo.htmlUrl, target: '_blank', rel: 'noopener noreferrer',
1482
1622
  }, t('打开', 'Open')) : null))))),
@@ -1644,7 +1784,7 @@ window.__ModuleLoader__.load({
1644
1784
  danger: true,
1645
1785
  confirmLabel: t('删除', 'Delete'),
1646
1786
  onConfirm: async () => {
1647
- await call('github.delete-release', { owner: repo.owner, repo: repo.name, releaseId: release.id })
1787
+ await call('github.delete-release', { owner: repo.owner, repo: repo.name, releaseId: release.id, force: true })
1648
1788
  toast(t('Release 已删除(tag 仍保留)', 'Release deleted (tag kept)'), 'ok')
1649
1789
  await load()
1650
1790
  },
@@ -1665,7 +1805,7 @@ window.__ModuleLoader__.load({
1665
1805
  form.open
1666
1806
  ? h('div', { className: 'sd-inline-form sd-inline-card' },
1667
1807
  h('div', { className: 'sd-field-grid' },
1668
- h(Field, { label: 'Tag' }, h(TextInput, { value: form.tag, placeholder: 'v1.1.2', onChange: (event) => setForm({ ...form, tag: event.target.value }) })),
1808
+ h(Field, { label: 'Tag' }, h(TextInput, { value: form.tag, placeholder: 'v1.1.4', onChange: (event) => setForm({ ...form, tag: event.target.value }) })),
1669
1809
  h(Field, { label: t('标题', 'Title'), optional: true }, h(TextInput, { value: form.name, onChange: (event) => setForm({ ...form, name: event.target.value }) }))),
1670
1810
  h(Field, { label: t('说明', 'Notes'), optional: true },
1671
1811
  h('textarea', { className: 'sd-input sd-textarea', rows: 3, value: form.body, onChange: (event) => setForm({ ...form, body: event.target.value }) })),
@@ -1816,12 +1956,9 @@ window.__ModuleLoader__.load({
1816
1956
  h(PageHead, {
1817
1957
  eyebrow: 'SETTINGS',
1818
1958
  title: t('设置', 'Settings'),
1819
- desc: t('账号、默认发布参数与网络诊断。令牌只保存在本机,界面永远只显示账号信息。',
1820
- 'Accounts, publish defaults and network diagnostics. Tokens stay on this machine and are never shown.'),
1959
+ desc: t('默认发布参数、网络诊断与安全说明。账号连接已移到 npm 包库 / GitHub 仓库顶部。',
1960
+ 'Publish defaults, network diagnostics and security. Account connections live at the top of npm packages / GitHub repos.'),
1821
1961
  }),
1822
- h('div', { className: 'sd-settings-grid' },
1823
- h(NpmAccountCard, { status, t, toast, fail, refreshStatus }),
1824
- h(GithubAccountCard, { status, t, toast, fail, refreshStatus })),
1825
1962
  h('section', { className: 'sd-card sd-settings-card' },
1826
1963
  h('div', { className: 'sd-subhead' }, h('h3', null, t('默认发布参数', 'Publish defaults')), h(Icons.tag, null)),
1827
1964
  prefs === null
@@ -1893,7 +2030,7 @@ window.__ModuleLoader__.load({
1893
2030
  }
1894
2031
 
1895
2032
  function NpmAccountCard(props) {
1896
- const { status, t, toast, fail, refreshStatus } = props
2033
+ const { status, t, toast, fail, refreshStatus, packageCount } = props
1897
2034
  const lang = useLang()
1898
2035
  const [token, setToken] = React.useState('')
1899
2036
  const [registry, setRegistry] = React.useState(status?.registries?.npm ?? '')
@@ -1901,6 +2038,7 @@ window.__ModuleLoader__.load({
1901
2038
  const [verifying, setVerifying] = React.useState(false)
1902
2039
  const [expiryDraft, setExpiryDraft] = React.useState(status?.npm?.expiresAt ?? '')
1903
2040
  const [savingExpiry, setSavingExpiry] = React.useState(false)
2041
+ const [syncingToken, setSyncingToken] = React.useState(false)
1904
2042
 
1905
2043
  React.useEffect(() => {
1906
2044
  if (typeof status?.npm?.expiresAt === 'string') setExpiryDraft(status.npm.expiresAt)
@@ -1949,6 +2087,21 @@ window.__ModuleLoader__.load({
1949
2087
  }
1950
2088
  }
1951
2089
 
2090
+ const syncTokenInfo = async () => {
2091
+ setSyncingToken(true)
2092
+ try {
2093
+ const result = await call('npm.token-info')
2094
+ toast(result.matched
2095
+ ? t('Token 信息已同步', 'Token info synced')
2096
+ : t('没有匹配到当前 Token 的信息', 'No metadata matched the current token'), result.matched ? 'ok' : 'error')
2097
+ refreshStatus()
2098
+ } catch (error) {
2099
+ fail(error)
2100
+ } finally {
2101
+ setSyncingToken(false)
2102
+ }
2103
+ }
2104
+
1952
2105
  const disconnect = () => {
1953
2106
  call('npm.disconnect').then(() => {
1954
2107
  toast(t('npm 已断开', 'npm disconnected'), 'ok')
@@ -1962,13 +2115,31 @@ window.__ModuleLoader__.load({
1962
2115
  status?.npm?.connected ? h(Chip, { tone: 'ok' }, t('已连接', 'connected')) : h(Chip, { tone: 'warn' }, t('未连接', 'offline'))),
1963
2116
  status?.npm?.connected
1964
2117
  ? h(React.Fragment, null,
1965
- h('div', { className: 'sd-account-line' }, h('span', null, t('账号', 'Account')), h('strong', { className: 'sd-mono' }, `@${status.npm.username ?? '?'}`)),
2118
+ h('div', { className: 'sd-account-hero' },
2119
+ h('span', { className: 'sd-avatar sd-avatar-lg sd-avatar-npm' }, (status.npm.username ?? 'N').slice(0, 1).toUpperCase()),
2120
+ h('div', { className: 'sd-account-hero-copy' },
2121
+ h('strong', null, `@${status.npm.username ?? '?'}`),
2122
+ h('span', null, status.npm.email || t('npm registry 账号', 'npm registry account')),
2123
+ status.npm.username
2124
+ ? h('a', { className: 'sd-link', href: `https://www.npmjs.com/~${encodeURIComponent(status.npm.username)}`, target: '_blank', rel: 'noopener noreferrer' }, t('打开 npm 主页', 'Open npm profile'))
2125
+ : null),
2126
+ h('span', { className: 'sd-mono sd-stat-inline' }, `${packageCount ?? status.counts?.npmPackages ?? '—'} ${t('个包', 'packages')}`)),
1966
2127
  h('div', { className: 'sd-account-line' }, h('span', null, 'registry'), h('span', { className: 'sd-mono sd-ellipsis' }, status.npm.registry ?? '—')),
2128
+ h('div', { className: 'sd-account-line' }, h('span', null, t('Token 名称', 'Token name')), h('span', null, status.npm.tokenName || '—')),
2129
+ status.npm.tokenPermissions?.length > 0
2130
+ ? h('div', { className: 'sd-account-line sd-account-line-wrap' }, h('span', null, t('Token 权限', 'Token permissions')),
2131
+ h('span', { className: 'sd-chips' }, status.npm.tokenPermissions.map((permission) => h(Chip, { key: `${permission.name}:${permission.action}`, tone: permission.action === 'write' ? 'ok' : 'plain' }, `${permission.name}:${permission.action}`))))
2132
+ : null,
2133
+ status.npm.tokenScopes?.length > 0
2134
+ ? h('div', { className: 'sd-account-line sd-account-line-wrap' }, h('span', null, 'scopes'),
2135
+ h('span', { className: 'sd-chips' }, status.npm.tokenScopes.map((scope, index) => h(Chip, { key: `${scope.type}-${scope.name}-${index}`, tone: 'plain' }, scope.name ? `${scope.type}:${scope.name}` : scope.type))))
2136
+ : null,
1967
2137
  status.npm.bypass2fa === true
1968
2138
  ? h('div', { className: 'sd-account-line' }, h('span', null, t('Token 类型', 'Token type')), h('span', { className: 'sd-inline-row' },
1969
2139
  h(Chip, { tone: 'danger' }, 'Bypass 2FA'),
1970
- h('span', { className: 'sd-field-hint' }, t('2027-01 会被 npm 撤销', 'revoked by npm in Jan 2027'))))
2140
+ h('span', { className: 'sd-field-hint' }, t('2027-01 会被 npm 撤销;新建 Token 时可取消勾选,改用 TOTP 仍可发布', 'revoked by npm in Jan 2027; create a non-bypass token and use TOTP to keep publishing'))))
1971
2141
  : null,
2142
+ h('div', { className: 'sd-account-line' }, h('span', null, t('连接时间', 'Connected')), h('span', null, formatTime(status.npm.connectedAt, lang))),
1972
2143
  h('div', { className: 'sd-account-line' }, h('span', null, t('最近验证', 'Last verified')), h('span', null, formatTime(status.npm.lastVerifiedAt, lang))),
1973
2144
  h('div', { className: 'sd-account-line' }, h('span', null, t('Token 到期', 'Token expiry')), h('span', null,
1974
2145
  status.npm.expiresAt === null
@@ -1991,6 +2162,7 @@ window.__ModuleLoader__.load({
1991
2162
  : null,
1992
2163
  h('div', { className: 'sd-inline-row' },
1993
2164
  h(Btn, { size: 'sm', variant: 'ghost', busy: verifying, onClick: verify }, t('验证', 'Verify')),
2165
+ h(Btn, { size: 'sm', variant: 'ghost', busy: syncingToken, onClick: syncTokenInfo }, t('同步 Token 信息', 'Sync token info')),
1994
2166
  h(Btn, { size: 'sm', variant: 'danger', onClick: disconnect }, t('断开', 'Disconnect'))))
1995
2167
  : h(React.Fragment, null,
1996
2168
  h(Field, { label: t('npm Access Token', 'npm access token'), hint: t('Permission 选 Read and write (publish and stage)。如账户用 TOTP,可不必勾 Bypass 2FA,在发布向导里填 6 位验证码;Bypass 2FA 的 Token 会在 2027-01 被 npm 撤销。', 'Choose Read and write (publish and stage). With TOTP you can leave Bypass 2FA off and enter the 6-digit code in the wizard; npm revokes Bypass-2FA tokens in January 2027.') },
@@ -2018,6 +2190,14 @@ window.__ModuleLoader__.load({
2018
2190
  const [busy, setBusy] = React.useState(false)
2019
2191
  const [device, setDevice] = React.useState(null)
2020
2192
  const [error, setError] = React.useState(null)
2193
+
2194
+ React.useEffect(() => {
2195
+ if (status?.github?.connected !== true) return
2196
+ if (status.github.publicRepos !== null || status.github.htmlUrl !== null) return
2197
+ call('github.verify').then(() => refreshStatus()).catch(() => {
2198
+ /* metadata is best-effort; the profile still works without it */
2199
+ })
2200
+ }, [status?.github?.connected, status?.github?.publicRepos, status?.github?.htmlUrl, refreshStatus])
2021
2201
  const [copied, setCopied] = React.useState(false)
2022
2202
  const pollTimer = React.useRef(null)
2023
2203
  const mounted = React.useRef(true)
@@ -2116,13 +2296,22 @@ window.__ModuleLoader__.load({
2116
2296
  ? h(React.Fragment, null,
2117
2297
  h('div', { className: 'sd-github-user' },
2118
2298
  status.github.avatarUrl
2119
- ? h('img', { className: 'sd-avatar', src: status.github.avatarUrl, alt: '' })
2120
- : h('span', { className: 'sd-avatar sd-avatar-fallback' }, h(Icons.github, null)),
2121
- h('div', null,
2122
- h('strong', { className: 'sd-mono' }, `@${status.github.login ?? '?'}`),
2123
- h('div', { className: 'sd-field-hint' }, status.github.kind === 'pat' ? 'Personal Access Token' : 'OAuth device flow'))),
2124
- h('div', { className: 'sd-chips' }, (status.github.scopes ?? []).map((scope) => h(Chip, { key: scope, tone: 'plain' }, scope))),
2299
+ ? h('img', { className: 'sd-avatar sd-avatar-lg', src: status.github.avatarUrl, alt: '' })
2300
+ : h('span', { className: 'sd-avatar sd-avatar-lg sd-avatar-fallback' }, h(Icons.github, null)),
2301
+ h('div', { className: 'sd-github-copy' },
2302
+ h('strong', null, status.github.name || `@${status.github.login ?? '?'}`),
2303
+ h('span', { className: 'sd-mono' }, `@${status.github.login ?? '?'}`)),
2304
+ status.github.htmlUrl
2305
+ ? h('a', { className: 'sd-link', href: status.github.htmlUrl, target: '_blank', rel: 'noopener noreferrer' }, t('打开 GitHub 主页', 'Open GitHub profile'))
2306
+ : null),
2307
+ h('div', { className: 'sd-account-line' }, h('span', null, t('认证方式', 'Auth')), h('span', null, status.github.kind === 'pat' ? 'Personal Access Token' : 'OAuth device flow')),
2308
+ h('div', { className: 'sd-account-line' }, h('span', null, t('公开仓库', 'Public repos')), h('span', { className: 'sd-mono' }, status.github.publicRepos ?? '—')),
2309
+ h('div', { className: 'sd-account-line' }, h('span', null, t('连接时间', 'Connected')), h('span', null, formatTime(status.github.connectedAt, lang))),
2125
2310
  h('div', { className: 'sd-account-line' }, h('span', null, t('最近验证', 'Last verified')), h('span', null, formatTime(status.github.lastVerifiedAt, lang))),
2311
+ h('div', { className: 'sd-account-line sd-account-line-wrap' }, h('span', null, 'scopes'),
2312
+ h('span', { className: 'sd-chips' }, (status.github.scopes ?? []).length === 0
2313
+ ? h('span', { className: 'sd-field-hint' }, t('未返回 scopes(fine-grained PAT 正常)', 'No scopes returned (normal for fine-grained PATs)'))
2314
+ : (status.github.scopes ?? []).map((scope) => h(Chip, { key: scope, tone: 'plain' }, scope)))),
2126
2315
  h('div', { className: 'sd-inline-row' },
2127
2316
  h(Btn, { size: 'sm', variant: 'ghost', onClick: () => call('github.verify').then(() => { toast(t('验证完成', 'Verified'), 'ok'); refreshStatus() }).catch(fail) }, t('验证', 'Verify')),
2128
2317
  h(Btn, { size: 'sm', variant: 'danger', onClick: disconnect }, t('断开', 'Disconnect'))))
@@ -2242,8 +2431,8 @@ window.__ModuleLoader__.load({
2242
2431
  if (dir.trim() !== '' && inspect === null && inspectBusy === false) inspectProject(dir)
2243
2432
  }, [])
2244
2433
 
2245
- const goSettings = () => {
2246
- window.dispatchEvent(new CustomEvent('ship-deck:tab', { detail: 'settings' }))
2434
+ const goAccounts = () => {
2435
+ window.dispatchEvent(new CustomEvent('ship-deck:tab', { detail: npmReady ? 'repos' : 'packages' }))
2247
2436
  onClose()
2248
2437
  }
2249
2438
 
@@ -2364,7 +2553,10 @@ window.__ModuleLoader__.load({
2364
2553
  setResult(value)
2365
2554
  setStep(4)
2366
2555
  refreshStatus()
2367
- toast(value.ok ? t('发布完成', 'Publish complete') : t('部分目标失败,请查看结果', 'Some targets failed; see results'), value.ok ? 'ok' : 'error')
2556
+ const pending = Array.isArray(value.record?.targets) && value.record.targets.some((target) => target.pending === true)
2557
+ toast(value.ok
2558
+ ? pending ? t('npm 已受理,registry 正在同步', 'npm accepted; registry is syncing') : t('发布完成', 'Publish complete')
2559
+ : t('部分目标失败,请查看结果', 'Some targets failed; see results'), value.ok ? 'ok' : 'error')
2368
2560
  } catch (error) {
2369
2561
  fail(error)
2370
2562
  } finally {
@@ -2434,11 +2626,11 @@ window.__ModuleLoader__.load({
2434
2626
  ? h('div', { className: 'sd-note sd-note-warn sd-inline-row' },
2435
2627
  h('span', { style: { flex: 1 } },
2436
2628
  !npmReady && !githubReady
2437
- ? t('npm 与 GitHub 都未连接:先在设置里连接账号,发布目标才可选。', 'Neither npm nor GitHub is connected; connect an account in Settings to pick a target.')
2629
+ ? t('npm 与 GitHub 都未连接:先在「npm 包库 / GitHub 仓库」顶部连接账号,发布目标才可选。', 'Neither npm nor GitHub is connected; connect an account at the top of npm packages / GitHub repos to pick a target.')
2438
2630
  : !npmReady
2439
2631
  ? t('npm 未连接:npm 与 GitHub Packages 目标需要它。', 'npm is not connected; npm and GitHub Packages targets need it.')
2440
2632
  : t('GitHub 未连接:GitHub Packages 与 Release 目标需要它。', 'GitHub is not connected; GitHub Packages and release targets need it.')),
2441
- h(Btn, { size: 'sm', variant: 'default', onClick: goSettings }, t('去设置', 'Open settings')))
2633
+ h(Btn, { size: 'sm', variant: 'default', onClick: goAccounts }, t('去连接', 'Connect')))
2442
2634
  : null,
2443
2635
  h('div', { className: 'sd-target-grid' },
2444
2636
  targetCard('npm', 'npm registry', status?.registries?.npm ?? 'registry.npmjs.org', npmReady, t('发布到 npmjs.com', 'Publish to npmjs.com')),
@@ -2529,13 +2721,18 @@ window.__ModuleLoader__.load({
2529
2721
  h('div', { className: 'sd-result-hero' + (result.ok ? ' is-ok' : ' is-fail') },
2530
2722
  h('div', { className: 'sd-result-hero-icon' }, result.ok ? h(Icons.check, null) : h(Icons.warn, null)),
2531
2723
  h('div', null,
2532
- h('div', { className: 'sd-result-hero-title' }, result.ok ? t('发布完成', 'Published') : t('部分目标失败', 'Partly failed')),
2724
+ h('div', { className: 'sd-result-hero-title' }, result.ok
2725
+ ? (Array.isArray(result.record.targets) && result.record.targets.some((target) => target.pending === true)
2726
+ ? t('已受理 · registry 同步中', 'Accepted · registry syncing')
2727
+ : t('发布完成', 'Published'))
2728
+ : t('部分目标失败', 'Partly failed')),
2533
2729
  h('div', { className: 'sd-result-hero-sub' }, `${result.record.package}@${result.record.version} · ${result.record.dryRun ? 'dry run' : formatTime(result.record.at, lang)}`))),
2534
2730
  h('div', { className: 'sd-purposes' },
2535
2731
  result.record.targets.map((target) => h('div', { key: target.target, className: 'sd-purpose' + (target.ok ? ' is-ok' : ' is-fail') },
2536
2732
  h('div', { className: 'sd-purpose-head' },
2537
2733
  h('strong', null, target.target),
2538
- h(Chip, { tone: target.ok ? 'ok' : 'danger' }, target.ok ? 'ok' : 'fail')),
2734
+ h(Chip, { tone: target.ok ? 'ok' : 'danger' }, target.ok ? 'ok' : 'fail'),
2735
+ target.pending === true ? h(Chip, { tone: 'warn' }, t('同步中', 'syncing')) : null),
2539
2736
  h('div', { className: 'sd-record-links' },
2540
2737
  target.url ? h('a', { className: 'sd-link', href: target.url, target: '_blank', rel: 'noopener noreferrer' }, 'npm package') : null,
2541
2738
  target.release?.htmlUrl ? h('a', { className: 'sd-link', href: target.release.htmlUrl, target: '_blank', rel: 'noopener noreferrer' }, `Release ${target.release.tag}`) : null,
@@ -2794,6 +2991,8 @@ window.__ModuleLoader__.load({
2794
2991
  .sd-step.is-active { background: var(--sd-yellow); color: #141414; }
2795
2992
  .sd-step-num { width: 18px; height: 18px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; background: #141414; color: #fff8e7; font-family: ui-monospace, monospace; font-size: 10px; flex: none; }
2796
2993
  .sd-stat-stack { display: flex; flex-direction: column; gap: 12px; }
2994
+ .sd-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
2995
+ .sd-page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
2797
2996
  .sd-stat { border: 2.5px solid var(--sd-line); border-radius: 13px; padding: 13px 15px; box-shadow: 4px 4px 0 var(--sd-shadow); color: #141414; flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-height: 105px; }
2798
2997
  .sd-stat-mint { background: var(--sd-mint); }
2799
2998
  .sd-stat-blue { background: var(--sd-blue); }
@@ -2916,6 +3115,12 @@ window.__ModuleLoader__.load({
2916
3115
  .sd-bundle-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
2917
3116
  .sd-bundle-copy strong { font-size: 13px; }
2918
3117
  .sd-bundle-copy span { font-size: 12px; line-height: 1.45; color: var(--dsw-alias-label-secondary, #888); }
3118
+ .sd-bundle-error { color: var(--dsw-alias-label-danger, #d33); font-size: 11px; }
3119
+ .sd-switch { flex: none; width: 48px; height: 28px; padding: 2px; border: 1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.35)); border-radius: 999px; background: var(--dsw-alias-bg-layer-2, rgba(127,127,127,.2)); cursor: pointer; transition: background 140ms ease; }
3120
+ .sd-switch.is-on { background: var(--dsw-alias-fill-primary, #2f5bff); }
3121
+ .sd-switch-knob { display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transform: translateX(0); transition: transform 140ms ease; }
3122
+ .sd-switch.is-on .sd-switch-knob { transform: translateX(20px); }
3123
+ .sd-switch:disabled { opacity: .6; cursor: wait; }
2919
3124
  .sd-bundle-action { flex: none; border: 1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.4)); background: var(--dsw-alias-bg-layer-2, rgba(127,127,127,.12)); color: var(--dsw-alias-label-primary, inherit); border-radius: 8px; padding: 6px 11px; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
2920
3125
  .sd-bundle-action:hover { background: var(--dsw-alias-bg-layer-1, rgba(127,127,127,.18)); }
2921
3126
 
@@ -2926,7 +3131,18 @@ window.__ModuleLoader__.load({
2926
3131
  .sd-account-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11.5px; border-bottom: 1px dotted var(--sd-line); padding-bottom: 4px; }
2927
3132
  .sd-account-line > span:first-child { color: var(--sd-muted); }
2928
3133
  .sd-github-user { display: flex; align-items: center; gap: 10px; }
2929
- .sd-github-user strong { font-size: 13px; }
3134
+ .sd-github-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
3135
+ .sd-github-copy strong { font-size: 14px; }
3136
+ .sd-github-copy span { color: var(--sd-muted); font-size: 11px; }
3137
+ .sd-account-hero { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
3138
+ .sd-account-hero-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
3139
+ .sd-account-hero-copy strong { font-size: 15px; font-family: ui-monospace, monospace; }
3140
+ .sd-account-hero-copy > span { color: var(--sd-muted); font-size: 11px; }
3141
+ .sd-stat-inline { margin-left: auto; font-size: 12px; color: var(--sd-muted); }
3142
+ .sd-avatar-lg { width: 52px; height: 52px; }
3143
+ .sd-avatar-npm { display: inline-flex; align-items: center; justify-content: center; background: var(--sd-yellow); color: #141414; font-size: 22px; font-weight: 900; border-radius: 12px; }
3144
+ .sd-account-line-wrap { align-items: flex-start; }
3145
+ .sd-account-line-wrap > .sd-chips { justify-content: flex-end; max-width: 70%; }
2930
3146
  .sd-tabs { display: flex; gap: 3px; border: 2px solid var(--sd-line); border-radius: 8px; padding: 2px; background: var(--sd-panel-2); }
2931
3147
  .sd-tab { flex: 1; border: 0; border-radius: 5px; background: transparent; color: var(--sd-muted); font-family: inherit; font-size: 11px; font-weight: 700; padding: 5px 8px; cursor: pointer; }
2932
3148
  .sd-tab.is-active { background: #141414; color: #fff8e7; }
@@ -2952,11 +3168,19 @@ window.__ModuleLoader__.load({
2952
3168
  .sd-modal-body { padding: 15px 16px; overflow: auto; min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 11px; }
2953
3169
  .sd-modal-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 11px 16px; border-top: 2.5px solid var(--sd-line); background: var(--sd-panel-2); flex-wrap: wrap; }
2954
3170
  .sd-confirm-band { padding: 9px 16px 0; }
3171
+ .sd-confirm-otp { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding: 11px; border: 1.5px dashed var(--sd-line); border-radius: 8px; }
3172
+ .sd-confirm-warn { font-size: 12.5px; font-weight: 800; }
3173
+ .sd-confirm-otp-warn { font-size: 11px; line-height: 1.5; color: #8a2b2b; background: rgba(255, 120, 120, .14); border-radius: 5px; padding: 6px 8px; }
2955
3174
  .sd-confirm-text { margin: 8px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--sd-muted); }
2956
3175
  .sd-toasts { position: absolute; left: 22px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 7px; max-width: 440px; }
2957
3176
  .sd-toast { display: flex; align-items: flex-start; gap: 8px; border: 2.5px solid var(--sd-line); border-radius: 10px; padding: 9px 11px; font-size: 12px; line-height: 1.45; box-shadow: 4px 4px 0 var(--sd-shadow); background: var(--sd-mint); color: #141414; animation: sd-toast-in 160ms ease; }
2958
3177
  .sd-toast-error { background: var(--sd-pink); }
2959
3178
  .sd-toast-icon { display: inline-flex; margin-top: 1px; flex: none; }
3179
+ .sd-toast-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
3180
+ .sd-toast-links { display: flex; flex-wrap: wrap; gap: 6px; }
3181
+ .sd-toast-link { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border: 1.5px solid var(--sd-line); border-radius: 5px; background: #fff8e7; color: #141414; font-size: 11px; font-weight: 700; text-decoration: none; }
3182
+ .sd-toast-link:hover { background: var(--sd-mint); }
3183
+ .sd-toast-link .sd-i { width: 11px; height: 11px; }
2960
3184
  @keyframes sd-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
2961
3185
 
2962
3186
  /* wizard */
@@ -3012,6 +3236,7 @@ window.__ModuleLoader__.load({
3012
3236
  .sd-h1 { font-size: 36px; }
3013
3237
  .sd-dash-grid { grid-template-columns: 1fr; }
3014
3238
  .sd-stat-stack { flex-direction: row; flex-wrap: wrap; }
3239
+ .sd-stat-grid { grid-template-columns: 1fr; }
3015
3240
  .sd-stat { min-width: 150px; }
3016
3241
  .sd-repo-layout, .sd-settings-grid { grid-template-columns: 1fr; }
3017
3242
  .sd-split, .sd-wizard-grid { grid-template-columns: 1fr; }
@@ -3054,15 +3279,20 @@ window.__ModuleLoader__.load({
3054
3279
  apply(ctx) {
3055
3280
  const locale = ctx.get?.('locale')
3056
3281
  if (locale !== null && locale !== undefined) localeService = locale
3057
- hostServices.uiWorkspace = ctx.get?.('uiWorkspace')
3282
+ ctx.inject(['uiWorkspace'], (scoped) => {
3283
+ hostServices.uiWorkspace = scoped.uiWorkspace
3284
+ return () => {
3285
+ if (hostServices.uiWorkspace === scoped.uiWorkspace) hostServices.uiWorkspace = undefined
3286
+ }
3287
+ })
3058
3288
  ctx.inject(['layout'], (scoped) => {
3059
3289
  hostServices.layout = scoped.layout
3060
3290
  return () => {
3061
3291
  if (hostServices.layout === scoped.layout) hostServices.layout = undefined
3062
3292
  }
3063
3293
  })
3064
- const theme = ctx.get?.('theme')
3065
- if (theme !== undefined && theme !== null) {
3294
+ ctx.inject(['theme'], (scoped) => {
3295
+ const theme = scoped.theme
3066
3296
  const readTheme = () => {
3067
3297
  try {
3068
3298
  setThemeScheme(theme.getTheme()?.active?.colorScheme)
@@ -3071,8 +3301,9 @@ window.__ModuleLoader__.load({
3071
3301
  }
3072
3302
  }
3073
3303
  readTheme()
3074
- ctx.effect(() => ctx.on('theme/change', readTheme), `${NS}: theme`)
3075
- }
3304
+ const off = scoped.on('theme/change', readTheme)
3305
+ return () => off()
3306
+ })
3076
3307
  ctx.effect(() => {
3077
3308
  const tag = document.createElement('style')
3078
3309
  tag.setAttribute('data-plugin', NS)
@@ -3081,40 +3312,79 @@ window.__ModuleLoader__.load({
3081
3312
  return () => tag.remove()
3082
3313
  }, `${NS}: styles`)
3083
3314
 
3084
- ctx.slots.inject('main', () => ctx.slots.register(
3085
- { name: 'main', key: 'ship-deck' },
3086
- () => h(Panel, null),
3087
- ))
3088
-
3089
- ctx.slots.inject('sidebar.panellist', () => ctx.slots.register(
3090
- {
3091
- name: 'sidebar.panellist',
3092
- id: 'ship-deck',
3093
- order: 30,
3094
- label: () => (detectLang() === 'zh' ? '发布仓' : 'Release Depot'),
3095
- },
3096
- (props) => h(SidebarIcon, props),
3097
- ))
3098
-
3099
- ctx.slots.inject('settings.section', () => ctx.slots.register(
3100
- {
3101
- name: 'settings.section',
3102
- id: 'ship-deck',
3103
- order: 50,
3104
- label: () => (detectLang() === 'zh' ? '发布仓' : 'Release Depot'),
3105
- },
3106
- () => h(Panel, null),
3107
- ))
3108
-
3109
- ctx.slots.inject('settings.section.icon', () => ctx.slots.register(
3110
- { name: 'settings.section.icon', id: 'ship-deck' },
3111
- (props) => h(SidebarIcon, props),
3112
- ))
3113
-
3114
3315
  ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register(
3115
3316
  { name: 'plugins.bundle.config', key: 'dsh-release-depot' },
3116
3317
  () => h(BundleEntryCard, null),
3117
3318
  ))
3319
+
3320
+ let mainStop = null
3321
+ let sidebarStop = null
3322
+ const enableSidebar = () => {
3323
+ if (mainStop === null) {
3324
+ mainStop = ctx.slots.inject('main', () => ctx.slots.register(
3325
+ { name: 'main', key: 'ship-deck' },
3326
+ () => h(Panel, null),
3327
+ ))
3328
+ }
3329
+ if (sidebarStop === null) {
3330
+ sidebarStop = ctx.slots.inject('sidebar.panellist', () => ctx.slots.register(
3331
+ {
3332
+ name: 'sidebar.panellist',
3333
+ id: 'ship-deck',
3334
+ order: 30,
3335
+ label: () => (detectLang() === 'zh' ? '发布仓' : 'Release Depot'),
3336
+ },
3337
+ (props) => h(SidebarIcon, props),
3338
+ ))
3339
+ }
3340
+ }
3341
+ const disableSidebar = () => {
3342
+ if (mainStop !== null) {
3343
+ mainStop()
3344
+ mainStop = null
3345
+ }
3346
+ if (sidebarStop !== null) {
3347
+ sidebarStop()
3348
+ sidebarStop = null
3349
+ }
3350
+ const layout = hostServices.layout
3351
+ try {
3352
+ if (layout?.panelInfo?.getSnapshot?.()?.activePanelId === 'ship-deck') layout.selectPanel(null)
3353
+ } catch {
3354
+ /* ignore panel navigation failures */
3355
+ }
3356
+ }
3357
+ const readStoredVisibility = () => {
3358
+ try {
3359
+ return localStorage.getItem('sd.sidebarVisible') !== 'false'
3360
+ } catch {
3361
+ return true
3362
+ }
3363
+ }
3364
+ const applyVisibility = (visible) => {
3365
+ setSidebarVisibleState(visible)
3366
+ if (visible) enableSidebar()
3367
+ else disableSidebar()
3368
+ try {
3369
+ localStorage.setItem('sd.sidebarVisible', visible ? 'true' : 'false')
3370
+ } catch {
3371
+ /* ignore */
3372
+ }
3373
+ }
3374
+ hostServices.sidebar = {
3375
+ isEnabled: () => sidebarVisible,
3376
+ subscribe: subscribeSidebar,
3377
+ setEnabled: (next) => applyVisibility(next !== false),
3378
+ }
3379
+ applyVisibility(readStoredVisibility())
3380
+ call('prefs.get')
3381
+ .then((result) => {
3382
+ const visible = result?.prefs?.sidebarVisible !== false
3383
+ if (visible !== sidebarVisible) applyVisibility(visible)
3384
+ })
3385
+ .catch(() => {
3386
+ /* keep the local preference */
3387
+ })
3118
3388
  },
3119
3389
  }
3120
3390
  return module.exports