dsh-plugin-explorer 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client.js +86 -52
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -38,6 +38,7 @@ window.__ModuleLoader__.load({
38
38
  sortName: '名称',
39
39
  installed: '已安装 v{version}',
40
40
  update: '更新到 v{version}',
41
+ updateHint: '打开已安装页,在那里完成更新',
41
42
  updateBadge: '有新版',
42
43
  scanTitle: '安装前安全检查',
43
44
  scanSubtitle: '{name}@{version}',
@@ -54,6 +55,8 @@ window.__ModuleLoader__.load({
54
55
  networkHosts: '网络目标:{hosts}',
55
56
  networkNone: '未发现网络目标',
56
57
  hitsTitle: '命中规则({count})',
58
+ showAllHits: '展开其余 {count} 条',
59
+ showLess: '收起',
57
60
  noHits: '未命中任何规则',
58
61
  notesLine: '另有 {count} 条扫描提示',
59
62
  confirmInstall: '确认安装',
@@ -89,6 +92,7 @@ window.__ModuleLoader__.load({
89
92
  sortName: 'Name',
90
93
  installed: 'Installed v{version}',
91
94
  update: 'Update to v{version}',
95
+ updateHint: 'Open the Installed page and finish the update there',
92
96
  updateBadge: 'Update',
93
97
  scanTitle: 'Pre-install safety scan',
94
98
  scanSubtitle: '{name}@{version}',
@@ -105,6 +109,8 @@ window.__ModuleLoader__.load({
105
109
  networkHosts: 'Network targets: {hosts}',
106
110
  networkNone: 'No network targets found',
107
111
  hitsTitle: 'Rule hits ({count})',
112
+ showAllHits: 'Show {count} more',
113
+ showLess: 'Show less',
108
114
  noHits: 'No rules matched',
109
115
  notesLine: '{count} additional scan notes',
110
116
  confirmInstall: 'Install',
@@ -234,10 +240,16 @@ window.__ModuleLoader__.load({
234
240
  padding: 16px; background: rgba(0, 0, 0, 0.45);
235
241
  }
236
242
  .pf-dialog {
237
- width: min(720px, 100%); max-height: min(80vh, 760px); overflow: auto;
243
+ width: min(620px, 100%); max-height: min(76vh, 680px); overflow: hidden;
238
244
  background: var(--dsw-alias-bg-layer-1); border: 1px solid var(--dsw-alias-border-l1);
239
- border-radius: 14px; padding: 20px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
240
- display: flex; flex-direction: column; gap: 12px;
245
+ border-radius: 14px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
246
+ display: flex; flex-direction: column;
247
+ }
248
+ .pf-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
249
+ .pf-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 18px 12px; display: flex; flex-direction: column; gap: 10px; }
250
+ .pf-dialog-foot {
251
+ flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 18px 14px;
252
+ border-top: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1);
241
253
  }
242
254
  .pf-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
243
255
  .pf-dialog-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--dsw-alias-label-primary); }
@@ -254,6 +266,8 @@ window.__ModuleLoader__.load({
254
266
  .pf-verdict-block { color: light-dark(#cf222e, #f85149); }
255
267
  .pf-scan-meta { font-size: 12px; color: var(--dsw-alias-label-secondary); display: flex; flex-wrap: wrap; gap: 4px 14px; }
256
268
  .pf-hits { display: flex; flex-direction: column; gap: 6px; }
269
+ .pf-hits-block { display: flex; flex-direction: column; gap: 6px; }
270
+ .pf-hits-more { align-self: flex-start; margin-top: 2px; }
257
271
  .pf-hits-title { font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary); margin-top: 4px; }
258
272
  .pf-hit {
259
273
  font-size: 11px; line-height: 16px; padding: 8px 10px; border-radius: 8px;
@@ -269,7 +283,7 @@ window.__ModuleLoader__.load({
269
283
  .pf-hit-hint { margin-top: 4px; color: var(--dsw-alias-label-secondary); }
270
284
  .pf-recs { margin: 0; padding-left: 18px; font-size: 11px; line-height: 17px; color: var(--dsw-alias-label-secondary); }
271
285
  .pf-disclaimer { font-size: 10px; line-height: 15px; color: var(--dsw-alias-label-secondary); }
272
- .pf-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
286
+ .pf-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
273
287
  .pf-button {
274
288
  border: 1px solid var(--dsw-alias-border-l1); background: transparent; color: var(--dsw-alias-label-primary);
275
289
  border-radius: 8px; padding: 7px 14px; font: inherit; font-size: 12px; cursor: pointer;
@@ -475,7 +489,7 @@ window.__ModuleLoader__.load({
475
489
  }
476
490
 
477
491
  function FinderRow(props) {
478
- const { entry, install, onScan, installed, language, t } = props
492
+ const { entry, install, onScan, onOpen, installed, language, t } = props
479
493
  const [broken, setBroken] = useState(false)
480
494
  const description = entry.description?.[language] ?? entry.description?.en ?? entry.description?.zh
481
495
  const meta = [entry.owner, categoryLabel(entry.category, language)].filter(Boolean).join(' · ')
@@ -521,14 +535,20 @@ window.__ModuleLoader__.load({
521
535
  }, t('install'))
522
536
  : hasUpdate
523
537
  ? h('button', {
524
- type: 'button', className: 'pf-install',
525
- onClick: () => { startScan(latest) },
538
+ type: 'button', className: 'pf-install', title: t('updateHint'),
539
+ onClick: () => {
540
+ // The page's update slot only handles Git bundles; registry packages update on the
541
+ // Installed page, so jump there and let its own version check offer the update.
542
+ if (typeof onOpen === 'function') onOpen(entry.name)
543
+ else startScan(latest)
544
+ },
526
545
  }, t('update', { version: latest }))
527
546
  : null))
528
547
  }
529
548
 
530
549
  function ScanDialog(props) {
531
550
  const { scan, t, onCancel, onConfirm } = props
551
+ const [showAll, setShowAll] = useState(false)
532
552
  if (scan === null || scan === undefined) return null
533
553
  const { entry, version, status, result, error } = scan
534
554
  const verdict = result?.verdict
@@ -539,6 +559,23 @@ window.__ModuleLoader__.load({
539
559
  const hosts = Array.isArray(result?.network?.hosts) ? result.network.hosts : []
540
560
  const hits = Array.isArray(result?.hits) ? result.hits : []
541
561
  const recommendations = Array.isArray(result?.recommendations) ? result.recommendations : []
562
+ const severityRank = { high: 0, medium: 1, low: 2 }
563
+ const sortedHits = [...hits].sort((a, b) => (severityRank[a.severity] ?? 3) - (severityRank[b.severity] ?? 3))
564
+ // Low-severity rows are mostly noisy contextual matches, so they stay folded until asked for.
565
+ const importantHits = sortedHits.filter(hit => hit.severity !== 'low')
566
+ const visibleHits = showAll
567
+ ? sortedHits
568
+ : importantHits.length > 0 ? importantHits.slice(0, 6) : sortedHits.slice(0, 3)
569
+ const hiddenHits = sortedHits.length - visibleHits.length
570
+ const confirmButton = status === 'ready'
571
+ ? h('button', {
572
+ type: 'button', className: 'pf-button ' + (verdict === 'BLOCK' ? 'pf-button-danger' : 'pf-button-primary'),
573
+ onClick: () => onConfirm({ skipScan: false }),
574
+ }, confirmLabel)
575
+ : h('button', {
576
+ type: 'button', className: 'pf-button',
577
+ onClick: () => onConfirm({ skipScan: true }),
578
+ }, t('skipScan'))
542
579
  return h('div', {
543
580
  className: 'pf-overlay',
544
581
  onMouseDown: event => { if (event.target === event.currentTarget) onCancel() },
@@ -551,57 +588,54 @@ window.__ModuleLoader__.load({
551
588
  h('h3', { className: 'pf-dialog-title' }, t('scanTitle')),
552
589
  h('div', { className: 'pf-dialog-sub' }, entry.name + (version ? '@' + version : ''))),
553
590
  h('button', { type: 'button', className: 'pf-close', 'aria-label': t('cancel'), onClick: onCancel }, '×')),
554
- status === 'scanning'
555
- ? h('div', { className: 'pf-state', role: 'status' }, t('scanning'))
556
- : status === 'failed'
557
- ? h('div', null,
558
- h('div', { className: 'pf-verdict pf-verdict-block', style: { marginBottom: 6 } }, t('scanFailed')),
559
- h('div', { className: 'pf-note', style: { marginBottom: 10 } }, t('scanFailedHint')),
560
- h('div', { className: 'pf-note' }, error ?? ''))
561
- : h('div', null,
562
- h('div', { className: 'pf-verdict' },
563
- h('span', { className: 'pf-verdict-badge ' + verdictClass }, verdictText),
564
- h('span', { className: 'pf-scan-meta' },
565
- h('span', null, t('summaryLine', summary)),
566
- h('span', null, t('filesScanned', { count: result.filesScanned ?? 0 })),
567
- result.cached === true ? h('span', null, t('scanCached')) : null)),
568
- h('div', { className: 'pf-scan-meta', style: { marginTop: 8 } },
569
- h('span', null, hosts.length === 0 ? t('networkNone') : t('networkHosts', { hosts: hosts.join(', ') }))),
570
- hits.length === 0
571
- ? h('div', { className: 'pf-notes', style: { marginTop: 8 } }, t('noHits'))
572
- : h('div', null,
573
- h('div', { className: 'pf-hits-title' }, t('hitsTitle', { count: hits.length })),
574
- h('div', { className: 'pf-hits' },
575
- hits.slice(0, 40).map((hit, index) => h('div', {
576
- key: index, className: 'pf-hit', 'data-sev': hit.severity,
577
- },
578
- h('div', { className: 'pf-hit-head' },
579
- h('span', { className: 'pf-hit-rule' }, severityLabel(hit.severity, t) + ' · ' + hit.rule),
580
- h('span', { className: 'pf-hit-file' }, hit.file + ':' + hit.line)),
581
- h('div', { className: 'pf-hit-evidence' }, hit.evidence ?? ''),
582
- hit.hint === undefined ? null : h('div', { className: 'pf-hit-hint' }, hit.hint))))),
583
- (result.notes ?? 0) > 0 ? h('div', { className: 'pf-note', style: { marginTop: 6 } }, t('notesLine', { count: result.notes })) : null,
584
- recommendations.length === 0 ? null : h('ul', { className: 'pf-recs', style: { marginTop: 8 } },
585
- recommendations.slice(0, 4).map((text, index) => h('li', { key: index }, text))),
586
- h('div', { className: 'pf-disclaimer', style: { marginTop: 10 } }, t('scanDisclaimer'))),
587
- h('div', { className: 'pf-dialog-actions' },
588
- h('button', { type: 'button', className: 'pf-button', onClick: onCancel }, t('cancel')),
591
+ h('div', { className: 'pf-dialog-body' },
589
592
  status === 'scanning'
590
- ? null
593
+ ? h('div', { className: 'pf-state', role: 'status' }, t('scanning'))
591
594
  : status === 'failed'
592
- ? h('button', {
593
- type: 'button', className: 'pf-button pf-button-danger',
594
- onClick: () => onConfirm({ skipScan: true }),
595
- }, t('skipScan'))
596
- : h('button', {
597
- type: 'button', className: 'pf-button ' + (verdict === 'BLOCK' ? 'pf-button-danger' : 'pf-button-primary'),
598
- onClick: () => onConfirm({ skipScan: false }),
599
- }, confirmLabel))))
595
+ ? h('div', null,
596
+ h('div', { className: 'pf-verdict pf-verdict-block', style: { marginBottom: 6 } }, t('scanFailed')),
597
+ h('div', { className: 'pf-note', style: { marginBottom: 10 } }, t('scanFailedHint')),
598
+ h('div', { className: 'pf-note' }, error ?? ''))
599
+ : h('div', null,
600
+ h('div', { className: 'pf-verdict' },
601
+ h('span', { className: 'pf-verdict-badge ' + verdictClass }, verdictText),
602
+ h('span', { className: 'pf-scan-meta' },
603
+ h('span', null, t('summaryLine', summary)),
604
+ h('span', null, t('filesScanned', { count: result.filesScanned ?? 0 })),
605
+ result.cached === true ? h('span', null, t('scanCached')) : null)),
606
+ h('div', { className: 'pf-scan-meta', style: { marginTop: 8 } },
607
+ h('span', null, hosts.length === 0 ? t('networkNone') : t('networkHosts', { hosts: hosts.join(', ') }))),
608
+ hits.length === 0
609
+ ? h('div', { className: 'pf-notes', style: { marginTop: 8 } }, t('noHits'))
610
+ : h('div', { className: 'pf-hits-block' },
611
+ h('div', { className: 'pf-hits-title' }, t('hitsTitle', { count: sortedHits.length })),
612
+ h('div', { className: 'pf-hits' },
613
+ visibleHits.map((hit, index) => h('div', {
614
+ key: index, className: 'pf-hit', 'data-sev': hit.severity,
615
+ },
616
+ h('div', { className: 'pf-hit-head' },
617
+ h('span', { className: 'pf-hit-rule' }, severityLabel(hit.severity, t) + ' · ' + hit.rule),
618
+ h('span', { className: 'pf-hit-file' }, hit.file + ':' + hit.line)),
619
+ h('div', { className: 'pf-hit-evidence' }, hit.evidence ?? ''),
620
+ hit.hint === undefined ? null : h('div', { className: 'pf-hit-hint' }, hit.hint)))),
621
+ hiddenHits <= 0 ? null : h('button', {
622
+ type: 'button', className: 'pf-link pf-hits-more',
623
+ onClick: () => { setShowAll(value => !value) },
624
+ }, showAll ? t('showLess') : t('showAllHits', { count: hiddenHits }))),
625
+ (result.notes ?? 0) > 0 ? h('div', { className: 'pf-note', style: { marginTop: 6 } }, t('notesLine', { count: result.notes })) : null,
626
+ recommendations.length === 0 ? null : h('ul', { className: 'pf-recs', style: { marginTop: 8 } },
627
+ recommendations.slice(0, 4).map((text, index) => h('li', { key: index }, text))))),
628
+ h('div', { className: 'pf-dialog-foot' },
629
+ h('div', { className: 'pf-disclaimer' }, t('scanDisclaimer')),
630
+ h('div', { className: 'pf-dialog-actions' },
631
+ h('button', { type: 'button', className: 'pf-button', onClick: onCancel }, t('cancel')),
632
+ confirmButton))))
600
633
  }
601
634
 
602
635
  function FinderTab(props) {
603
636
  const t = props.t
604
637
  const install = props.install
638
+ const openPackage = props.openPackage
605
639
  const [catalog, setCatalog] = useState(null)
606
640
  const [status, setStatus] = useState('loading')
607
641
  const [refreshing, setRefreshing] = useState(false)
@@ -755,7 +789,7 @@ window.__ModuleLoader__.load({
755
789
  ? h('div', { className: 'pf-state' }, t('empty'))
756
790
  : h('div', { className: 'pf-list' },
757
791
  shown.map(entry => h(FinderRow, {
758
- key: entry.name, entry, install, onScan: scanEntry, installed, language, t,
792
+ key: entry.name, entry, install, onScan: scanEntry, onOpen: openPackage, installed, language, t,
759
793
  }))),
760
794
  results.length > shown.length
761
795
  ? h('button', { type: 'button', className: 'pf-more', onClick: () => { setLimit(limit + PAGE_SIZE) } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-explorer",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Search the community plugin catalog, run a pre-install safety scan, filter by category and update installed bundles from the Plugins page.",
5
5
  "license": "MIT",
6
6
  "repository": {