dsh-config-manager 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/mcp.js +42 -13
- package/lib/adapters/messages.d.ts +1 -0
- package/lib/adapters/messages.js +2 -0
- package/lib/adapters/patch-key-guard.d.ts +23 -0
- package/lib/adapters/patch-key-guard.js +13 -0
- package/lib/adapters/plugin-data.d.ts +19 -5
- package/lib/adapters/plugin-data.js +76 -22
- package/lib/adapters/plugins.d.ts +14 -1
- package/lib/adapters/plugins.js +147 -4
- package/lib/cli/actions.d.ts +7 -105
- package/lib/cli/actions.js +16 -172
- package/lib/cli/control-state.d.ts +54 -0
- package/lib/cli/control-state.js +107 -0
- package/lib/cli/index.js +14 -0
- package/lib/cli/write-gates.d.ts +61 -0
- package/lib/cli/write-gates.js +110 -0
- package/lib/client.d.ts +122 -50
- package/lib/client.js +12676 -12091
- package/lib/core/backup.d.ts +0 -4
- package/lib/core/backup.js +21 -4
- package/lib/core/boot-rescue.d.ts +1 -1
- package/lib/core/boot-rescue.js +12 -1
- package/lib/core/boot-safety.js +37 -2
- package/lib/core/conflict-decisions.js +2 -1
- package/lib/core/exporter.js +22 -1
- package/lib/core/journal.d.ts +54 -4
- package/lib/core/journal.js +158 -35
- package/lib/core/local-plugin-host.d.ts +29 -0
- package/lib/core/local-plugin-host.js +55 -48
- package/lib/core/messages.d.ts +7 -0
- package/lib/core/messages.js +14 -0
- package/lib/core/migration-history.js +16 -9
- package/lib/core/model-tools.d.ts +2 -2
- package/lib/core/model-tools.js +14 -2
- package/lib/core/patch-secret-guard.d.ts +49 -0
- package/lib/core/patch-secret-guard.js +164 -0
- package/lib/core/reconcile.d.ts +8 -0
- package/lib/core/reconcile.js +18 -3
- package/lib/core/reinstall.d.ts +2 -0
- package/lib/core/reinstall.js +6 -2
- package/lib/core/restore.js +31 -6
- package/lib/core/section-sanitize.d.ts +32 -0
- package/lib/core/section-sanitize.js +13 -0
- package/lib/core/snapshot-diff.d.ts +30 -0
- package/lib/core/snapshot-diff.js +56 -20
- package/lib/core/startup-barrier.js +8 -2
- package/lib/core/types.d.ts +22 -0
- package/lib/core/update-check.js +51 -2
- package/lib/foreign/kernel.js +9 -2
- package/lib/foreign/read-claude-plugins.js +29 -11
- package/lib/foreign/read-dsh.js +31 -2
- package/lib/foreign/read-trae.d.ts +11 -0
- package/lib/foreign/read-trae.js +124 -4
- package/lib/foreign/session-ir.js +50 -9
- package/lib/foreign/session-read.d.ts +8 -0
- package/lib/foreign/session-read.js +26 -0
- package/lib/foreign/session-source.d.ts +12 -4
- package/lib/foreign/session-source.js +5 -3
- package/lib/foreign/trae-sqlcipher.d.ts +127 -0
- package/lib/foreign/trae-sqlcipher.js +519 -0
- package/lib/foreign/trae.js +3 -1
- package/lib/foreign/truth-table.js +3 -2
- package/lib/foreign/types.d.ts +9 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/profiles/dsh-profile-io.d.ts +20 -0
- package/lib/profiles/dsh-profile-io.js +27 -0
- package/lib/profiles/dsh-profile-manager.d.ts +27 -0
- package/lib/profiles/dsh-profile-manager.js +45 -4
- package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
- package/lib/profiles/dsh-profile-runtime.js +16 -3
- package/lib/profiles/process-control.d.ts +18 -1
- package/lib/profiles/process-control.js +25 -1
- package/lib/routes/profiles.js +2 -1
- package/lib/routes/sync.js +13 -1
- package/lib/schema/types.d.ts +11 -0
- package/lib/security/redaction.js +22 -6
- package/lib/sync/autosync-repeat.d.ts +27 -0
- package/lib/sync/autosync-repeat.js +23 -0
- package/lib/sync/autosync-scheduler.d.ts +34 -1
- package/lib/sync/autosync-scheduler.js +151 -43
- package/lib/sync/baseline-heal.js +7 -0
- package/lib/sync/baseline-record.d.ts +67 -0
- package/lib/sync/baseline-record.js +74 -0
- package/lib/sync/blob-store.js +13 -0
- package/lib/sync/content-diff.d.ts +39 -0
- package/lib/sync/content-diff.js +46 -0
- package/lib/sync/git/git-transport.d.ts +32 -1
- package/lib/sync/git/git-transport.js +146 -26
- package/lib/sync/github-auth.d.ts +17 -1
- package/lib/sync/github-auth.js +37 -1
- package/lib/sync/merge-apply-plan.d.ts +38 -0
- package/lib/sync/merge-apply-plan.js +76 -0
- package/lib/sync/messages.d.ts +1 -0
- package/lib/sync/messages.js +2 -0
- package/lib/sync/pending-merge.d.ts +34 -0
- package/lib/sync/pending-merge.js +53 -0
- package/lib/sync/s3/s3-transport.d.ts +14 -2
- package/lib/sync/s3/s3-transport.js +72 -48
- package/lib/sync/sync-engine.d.ts +23 -40
- package/lib/sync/sync-engine.js +115 -132
- package/lib/sync/sync-history.d.ts +7 -0
- package/lib/sync/sync-state.d.ts +28 -0
- package/lib/sync/sync-state.js +20 -0
- package/lib/sync/transport.d.ts +12 -3
- package/lib/sync/transport.js +13 -4
- package/lib/sync/webdav/webdav-transport.d.ts +19 -2
- package/lib/sync/webdav/webdav-transport.js +81 -40
- package/lib/ui/commands.js +5 -11
- package/lib/ui/dsh-profiles-view.d.ts +8 -3
- package/lib/ui/dsh-profiles-view.js +9 -5
- package/lib/ui/foreign-view.d.ts +19 -0
- package/lib/ui/foreign-view.js +24 -0
- package/lib/ui/i18n.d.ts +7 -1
- package/lib/ui/i18n.js +17 -2
- package/lib/ui/menu-placement.js +1 -1
- package/lib/ui/migration-consult-view.d.ts +11 -0
- package/lib/ui/migration-consult-view.js +15 -0
- package/lib/ui/overview-view.d.ts +7 -0
- package/lib/ui/overview-view.js +3 -0
- package/lib/ui/report.d.ts +9 -0
- package/lib/ui/report.js +17 -4
- package/lib/ui/selection-model.d.ts +8 -0
- package/lib/ui/selection-model.js +16 -0
- package/lib/utils/patch-yaml.d.ts +39 -1
- package/lib/utils/patch-yaml.js +82 -2
- package/lib/utils/paths.d.ts +13 -0
- package/lib/utils/paths.js +35 -0
- package/lib/utils/workdir-lock.js +18 -3
- package/package.json +2 -1
- package/src/adapters/mcp.test.ts +29 -0
- package/src/adapters/mcp.ts +43 -12
- package/src/adapters/messages.ts +2 -0
- package/src/adapters/patch-key-guard.ts +29 -0
- package/src/adapters/plugin-data.test.ts +126 -0
- package/src/adapters/plugin-data.ts +97 -26
- package/src/adapters/plugins.test.ts +288 -0
- package/src/adapters/plugins.ts +141 -4
- package/src/cli/actions.test.ts +74 -1
- package/src/cli/actions.ts +27 -246
- package/src/cli/control-state.ts +143 -0
- package/src/cli/index.ts +18 -0
- package/src/cli/web/web.test.ts +27 -0
- package/src/cli/write-gates.ts +149 -0
- package/src/client/about/AboutPanel.tsx +7 -6
- package/src/client/about/release-notes-view.test.ts +17 -0
- package/src/client/about/release-notes-view.ts +49 -24
- package/src/client/chat/ChatEntryView.tsx +2 -2
- package/src/client/chat/rollback-entry-view.ts +6 -1
- package/src/client/common/CommandPalette.tsx +6 -3
- package/src/client/common/ConfirmDialog.tsx +29 -12
- package/src/client/common/ContentPicker.tsx +13 -12
- package/src/client/common/Modal.tsx +12 -5
- package/src/client/common/MoreMenu.tsx +4 -1
- package/src/client/common/RunsCenter.tsx +103 -32
- package/src/client/common/Select.tsx +2 -2
- package/src/client/common/floating-bounds.ts +1 -1
- package/src/client/common/floating-units.test.ts +1 -2
- package/src/client/common/plan-text-redaction.test.ts +188 -3
- package/src/client/common/runs-center-guard.test.ts +60 -0
- package/src/client/common/runs-center-view.test.ts +128 -0
- package/src/client/common/runs-center-view.ts +96 -0
- package/src/client/common/section-title-action.test.ts +66 -0
- package/src/client/common/ui.tsx +93 -30
- package/src/client/config-manager.module.css +1507 -272
- package/src/client/consult/ConsultCard.tsx +7 -6
- package/src/client/environment/EnvironmentPanel.tsx +20 -21
- package/src/client/environment/maintenance/DiskUsageCard.tsx +65 -91
- package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
- package/src/client/export/ExportView.tsx +7 -16
- package/src/client/history/HistoryPanel.tsx +88 -28
- package/src/client/history/history-locales.ts +3 -3
- package/src/client/home/BackupScheduleCard.tsx +35 -30
- package/src/client/home/HomePanel.tsx +45 -10
- package/src/client/import/ConflictList.tsx +13 -13
- package/src/client/import/ForeignImportView.tsx +32 -13
- package/src/client/import/ImportWizardView.tsx +2 -3
- package/src/client/import/PathMappingForm.tsx +4 -4
- package/src/client/import/PathPickerDialog.tsx +2 -1
- package/src/client/import/foreign-import-view-guard.test.ts +1 -1
- package/src/client/import/import-wizard-steps.tsx +51 -39
- package/src/client/import/use-import-wizard-controller.test.ts +129 -0
- package/src/client/import/use-import-wizard-controller.ts +116 -22
- package/src/client/library/ArtifactRow.tsx +2 -2
- package/src/client/library/BackupInspectView.tsx +19 -15
- package/src/client/library/LibraryActions.tsx +56 -16
- package/src/client/library/LibraryPanel.tsx +7 -7
- package/src/client/library/RestorePlanView.tsx +13 -8
- package/src/client/locales/about.ts +0 -2
- package/src/client/locales/backup.ts +10 -12
- package/src/client/locales/common.ts +2 -0
- package/src/client/locales/export.ts +5 -12
- package/src/client/locales/foreign.ts +11 -2
- package/src/client/locales/import.ts +3 -2
- package/src/client/locales/overview.ts +4 -0
- package/src/client/locales/profiles.ts +32 -4
- package/src/client/locales/restore.ts +0 -2
- package/src/client/locales/sessions.ts +0 -2
- package/src/client/locales/shell.ts +2 -2
- package/src/client/market/MarketPanel.tsx +38 -20
- package/src/client/market/MyConfigsList.tsx +34 -32
- package/src/client/market/MyConfigsLoginCard.tsx +12 -15
- package/src/client/market/MyConfigsView.tsx +5 -5
- package/src/client/market/MyConfigsWizard.tsx +7 -12
- package/src/client/market/market-locales.ts +0 -6
- package/src/client/market/my-configs-split.test.ts +2 -1
- package/src/client/nav-menu-clip-guard.test.ts +52 -0
- package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
- package/src/client/recovery/RecoveryPanel.tsx +31 -16
- package/src/client/recovery/RollbackCard.tsx +58 -16
- package/src/client/recovery/RollbackFileChanges.tsx +40 -27
- package/src/client/recovery/SessionHealthCard.tsx +2 -2
- package/src/client/recovery/SessionHealthDialog.tsx +5 -7
- package/src/client/recovery/SessionLayoutSection.tsx +3 -5
- package/src/client/recovery/recovery-locales.ts +12 -8
- package/src/client/run-store.test.ts +30 -0
- package/src/client/run-store.ts +21 -1
- package/src/client/sync/AddChannelCard.tsx +65 -0
- package/src/client/sync/AutosyncCard.tsx +182 -108
- package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
- package/src/client/sync/ChannelConfigDialog.tsx +27 -48
- package/src/client/sync/MergePreviewView.tsx +3 -5
- package/src/client/sync/PushReportSections.tsx +35 -0
- package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
- package/src/client/sync/SyncConfirmView.tsx +3 -3
- package/src/client/sync/SyncLogList.tsx +16 -5
- package/src/client/sync/SyncPanel.tsx +153 -159
- package/src/client/sync/SyncProbeRow.tsx +5 -7
- package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
- package/src/client/sync/SyncSecuritySection.tsx +157 -0
- package/src/client/sync/SyncSettingsDialog.tsx +304 -0
- package/src/client/sync/SyncSettingsView.test.ts +26 -8
- package/src/client/sync/WorkDirCard.tsx +2 -4
- package/src/client/sync/config-clear-guard.test.ts +94 -0
- package/src/client/sync/config-clear-guard.ts +98 -0
- package/src/client/sync/config-dirty.test.ts +91 -0
- package/src/client/sync/config-dirty.ts +88 -0
- package/src/client/sync/history-model.test.ts +2 -0
- package/src/client/sync/history-model.ts +3 -0
- package/src/client/sync/merge-request.ts +20 -0
- package/src/client/sync/sync-api.ts +12 -0
- package/src/client/sync/sync-locales.ts +87 -47
- package/src/client/sync/sync-panel-clear.test.ts +44 -0
- package/src/client/sync/sync-view.test.ts +20 -0
- package/src/client/sync/sync-view.ts +42 -4
- package/src/core/backup.test.ts +61 -1
- package/src/core/backup.ts +21 -4
- package/src/core/boot-rescue.test.ts +35 -0
- package/src/core/boot-rescue.ts +13 -2
- package/src/core/boot-safety.test.ts +25 -0
- package/src/core/boot-safety.ts +37 -2
- package/src/core/conflict-decisions.ts +2 -1
- package/src/core/exporter.ts +21 -1
- package/src/core/journal.test.ts +183 -0
- package/src/core/journal.ts +163 -25
- package/src/core/local-plugin-host.test.ts +68 -2
- package/src/core/local-plugin-host.ts +31 -4
- package/src/core/messages.ts +14 -0
- package/src/core/migration-history.test.ts +27 -0
- package/src/core/migration-history.ts +12 -4
- package/src/core/model-tools.test.ts +67 -0
- package/src/core/model-tools.ts +16 -4
- package/src/core/patch-secret-guard.test.ts +110 -0
- package/src/core/patch-secret-guard.ts +176 -0
- package/src/core/reconcile.ts +32 -4
- package/src/core/reinstall.ts +8 -2
- package/src/core/restore.ts +32 -7
- package/src/core/section-sanitize.ts +37 -0
- package/src/core/snapshot-diff.test.ts +73 -1
- package/src/core/snapshot-diff.ts +66 -21
- package/src/core/startup-barrier.test.ts +64 -0
- package/src/core/startup-barrier.ts +8 -2
- package/src/core/types.ts +27 -1
- package/src/core/update-check.test.ts +40 -0
- package/src/core/update-check.ts +53 -2
- package/src/foreign/claude-code.test.ts +5 -0
- package/src/foreign/claude-plugins.test.ts +57 -0
- package/src/foreign/claude-sessions-bytes.test.ts +7 -1
- package/src/foreign/dsh.test.ts +23 -0
- package/src/foreign/file-budget.test.ts +7 -1
- package/src/foreign/kernel.ts +9 -2
- package/src/foreign/read-claude-plugins.ts +32 -11
- package/src/foreign/read-dsh.ts +33 -2
- package/src/foreign/read-trae.ts +117 -5
- package/src/foreign/session-ir.test.ts +67 -0
- package/src/foreign/session-ir.ts +54 -14
- package/src/foreign/session-read.ts +23 -0
- package/src/foreign/session-source.ts +15 -5
- package/src/foreign/trae-sqlcipher.test.ts +360 -0
- package/src/foreign/trae-sqlcipher.ts +564 -0
- package/src/foreign/trae.test.ts +188 -0
- package/src/foreign/trae.ts +3 -1
- package/src/foreign/truth-table.ts +4 -2
- package/src/foreign/types.ts +10 -1
- package/src/index.ts +1 -1
- package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
- package/src/profiles/dsh-profile-io.ts +29 -0
- package/src/profiles/dsh-profile-manager.test.ts +30 -0
- package/src/profiles/dsh-profile-manager.ts +53 -5
- package/src/profiles/dsh-profile-runtime.test.ts +29 -7
- package/src/profiles/dsh-profile-runtime.ts +17 -3
- package/src/profiles/process-control.test.ts +97 -0
- package/src/profiles/process-control.ts +28 -1
- package/src/routes/profiles.ts +2 -1
- package/src/routes/sync.ts +13 -1
- package/src/schema/types.ts +16 -1
- package/src/security/redaction.test.ts +31 -0
- package/src/security/redaction.ts +23 -6
- package/src/sync/autosync-repeat.test.ts +58 -0
- package/src/sync/autosync-repeat.ts +55 -0
- package/src/sync/autosync-scheduler.test.ts +417 -0
- package/src/sync/autosync-scheduler.ts +154 -41
- package/src/sync/baseline-heal.ts +6 -0
- package/src/sync/baseline-record.ts +135 -0
- package/src/sync/blob-store.test.ts +16 -0
- package/src/sync/blob-store.ts +13 -0
- package/src/sync/content-diff.test.ts +95 -0
- package/src/sync/content-diff.ts +79 -0
- package/src/sync/git/git-transport.test.ts +151 -4
- package/src/sync/git/git-transport.ts +143 -27
- package/src/sync/github-auth.test.ts +26 -1
- package/src/sync/github-auth.ts +37 -1
- package/src/sync/merge-apply-plan.ts +117 -0
- package/src/sync/messages.ts +2 -0
- package/src/sync/pending-merge.ts +77 -0
- package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
- package/src/sync/s3/s3-transport.ts +76 -42
- package/src/sync/sync-config.test.ts +39 -12
- package/src/sync/sync-device-identity.test.ts +3 -0
- package/src/sync/sync-engine.test.ts +465 -12
- package/src/sync/sync-engine.ts +130 -135
- package/src/sync/sync-history.ts +7 -0
- package/src/sync/sync-state.ts +48 -0
- package/src/sync/transport.test.ts +13 -1
- package/src/sync/transport.ts +12 -4
- package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
- package/src/sync/webdav/webdav-transport.ts +86 -34
- package/src/ui/commands.test.ts +11 -0
- package/src/ui/commands.ts +5 -14
- package/src/ui/dsh-profiles-view.test.ts +16 -0
- package/src/ui/dsh-profiles-view.ts +11 -5
- package/src/ui/foreign-view.test.ts +36 -0
- package/src/ui/foreign-view.ts +46 -0
- package/src/ui/i18n.ts +17 -2
- package/src/ui/menu-placement.ts +1 -1
- package/src/ui/migration-consult-view.test.ts +20 -1
- package/src/ui/migration-consult-view.ts +17 -0
- package/src/ui/overview-view.ts +10 -0
- package/src/ui/report.test.ts +25 -1
- package/src/ui/report.ts +15 -4
- package/src/ui/selection-model.test.ts +15 -1
- package/src/ui/selection-model.ts +18 -0
- package/src/utils/js-yaml4.d.ts +35 -0
- package/src/utils/patch-yaml.test.ts +207 -1
- package/src/utils/patch-yaml.ts +98 -2
- package/src/utils/paths.test.ts +14 -1
- package/src/utils/paths.ts +35 -0
- package/src/utils/workdir-lock.test.ts +69 -0
- package/src/utils/workdir-lock.ts +17 -3
- package/lib/ui/path-mapping.d.ts +0 -38
- package/lib/ui/path-mapping.js +0 -75
- package/src/client/common/InfoHint.tsx +0 -289
- package/src/client/common/info-hint-guard.test.ts +0 -1119
- package/src/client/sync/DecryptPasswordCard.tsx +0 -48
- package/src/client/sync/SecurityOptionsCard.tsx +0 -97
- package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
- package/src/ui/path-mapping.test.ts +0 -67
- package/src/ui/path-mapping.ts +0 -103
|
@@ -1,1119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* t6 守卫:InfoHint(ⓘ)说明文案迁移的回归护栏(源码级、零依赖、只读)。
|
|
3
|
-
*
|
|
4
|
-
* 钉住四件事(对应 t6 契约的 acceptance 第 6~8 条):
|
|
5
|
-
* 1. **MOVE 键**(t1\u2013t5 判定清单里移入 ⓘ 的 42 个字典键)——每个键都必须落在某处
|
|
6
|
-
* `<InfoHint text={t('原键')} ... />` 里(逐字复用原键),且**不得再出现在可见说明行**
|
|
7
|
-
* (渲染到 `css.hint / css.modeHint / css.groupNote / css.noticeLine` 的那些行);
|
|
8
|
-
* 2. **KEEP 键**(错误 / 安全告警 / 状态 / 空态 / Modal 决策文案)——必须仍在可见位置渲染,
|
|
9
|
-
* 断言失败时点名 文件:行;
|
|
10
|
-
* 3. **每一处 `<InfoHint>` 调用都显式传了可访问名**(`label={t('common.infoHint')}`、
|
|
11
|
-
* 主字典翻译器 `t={t}`、或调用方显式传入的字符串 prop),**不得依赖组件内置的中文回落**;
|
|
12
|
-
* 4. **`common.infoHint` 口径一致**——凡真正出现 \u24d8 调用点的命名空间字典
|
|
13
|
-
* (主字典 + market / sync / recovery)都必须有该键,且 zh 与 en 值逐字相同。
|
|
14
|
-
* history 全目录零 MOVE(无 \u24d8),按 t6 契约 rev=4 **不要求**该键,此处也不钉它。
|
|
15
|
-
* 5. **t9 增补:气泡的渲染位置与夹紧基准**(t7 评审 F1 / F2)——气泡必须经 `createPortal`
|
|
16
|
-
* 渲进 `resolveModalRoot()`(`MODAL_ROOT_ID` = `#dsh-config-manager-root`,与 Modal 共用
|
|
17
|
-
* 同一份实现),源码里不得存在「裸 `position: fixed` 渲在 Modal children 子树内」的路径,
|
|
18
|
-
* 也**绝不能**回退 `document.body`;夹紧基准必须是插件根容器的可见矩形(恒与窗口取交集),
|
|
19
|
-
* 窗口矩形仅作兜底,「下方空间不足且上方更宽裕 → 向上翻转」保留。同样带合成片段负向自检(t9-3)。
|
|
20
|
-
* 6. **t10 增补:固定态下点击任意位置取消固定**(2026-10-04 用户反馈)——ⓘ 点开后只有再点一次
|
|
21
|
-
* 同一颗图标才能退出,与「点别处收起」的通用浮层预期不符;必须捕获阶段监听 mousedown、
|
|
22
|
-
* 只作用于固定态、放行触发按钮自身、并在卸载时移除(负向自检:逐条拆掉都必须报红)。
|
|
23
|
-
* 7. **t11 增补:弹窗里 ⓘ 的「自动选中」与气泡偏移**(2026-10-04 用户反馈②)——① Radix 弹窗挂载时的
|
|
24
|
-
* 初始焦点(focusFirst)不得打开气泡(只认用户发起的聚焦,判据 relatedTarget 在同一 [role=dialog] 内);
|
|
25
|
-
* ② 焦点环只在气泡打开时绘制(否则程序化初始焦点会画出「选中」蓝框);③ 气泡夹紧矩形必须并进锚点
|
|
26
|
-
* (弹窗卡片是 fixed、会伸出画布左缘,否则气泡与自己的 ⓘ 脱开)。三处都带负向自检。
|
|
27
|
-
*
|
|
28
|
-
* 为什么用源码扫描而不是渲染测试:本仓库没有 React 组件测试框架(AGENTS.md:逻辑提炼到
|
|
29
|
-
* `src/ui/`),而「说明行有没有被搬进 ⓘ」恰恰是渲染结构问题 —— 用源码级守卫钉住,
|
|
30
|
-
* 与 `tests/route/route-*.test.ts` / `packages-contract` 同款做法。
|
|
31
|
-
*
|
|
32
|
-
* 注释剥离复用 `src/utils/bundle-scan.ts` 的 `stripJsComments`:InfoHint.tsx 的文件头注释里
|
|
33
|
-
* 就写着 `<InfoHint text={t('原键')} />`,对原文匹配会把它当成第 42 个调用点(假阳性)。
|
|
34
|
-
*
|
|
35
|
-
* 复现:`node --test src/client/common/info-hint-guard.test.ts`
|
|
36
|
-
*/
|
|
37
|
-
import test from 'node:test';
|
|
38
|
-
import assert from 'node:assert/strict';
|
|
39
|
-
import fs from 'node:fs';
|
|
40
|
-
import path from 'node:path';
|
|
41
|
-
|
|
42
|
-
import { stripJsComments } from '../../utils/bundle-scan.ts';
|
|
43
|
-
|
|
44
|
-
/** 仓库根(本文件位于 <root>/src/client/common/)。 */
|
|
45
|
-
const ROOT = path.resolve(import.meta.dirname, '../../..');
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 换行归一(issue #70)。
|
|
49
|
-
*
|
|
50
|
-
* 为什么必须在读取处做:Windows 检出(core.autocrlf=true / CI windows-latest)落的是 CRLF,
|
|
51
|
-
* 而本文件的锚点与扫描器大量含 "\n" 字面量 —— CRLF 下 code.indexOf('\n }\n') 恒为 -1,
|
|
52
|
-
* 扫描器会拿到整段文件当函数体(end=-1 分支)而**静默变弱**,锚点则直接 assert 失败(硬红)。
|
|
53
|
-
* 先例:tests/route/route-parity.test.ts 同样在读取处归一。
|
|
54
|
-
*/
|
|
55
|
-
function normalizeEol(text: string): string {
|
|
56
|
-
return text.replace(/\r\n?/g, '\n');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 样式表源码(读入即归一 LF,与 readClientSources 同一口径)。 */
|
|
60
|
-
function readStyleSource(): string {
|
|
61
|
-
return normalizeEol(fs.readFileSync(path.join(ROOT, STYLE_FILE), 'utf8'));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** 一份「已剥注释」的客户端源码。 */
|
|
65
|
-
interface SourceFile {
|
|
66
|
-
/** 仓库相对 POSIX 路径。 */
|
|
67
|
-
rel: string;
|
|
68
|
-
/** 剥注释后的源码(换行保留,行号与原文一致)。 */
|
|
69
|
-
code: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** MOVE 键的类别(用于人工复核「输入规则类是否真的进过 ⓘ」)。 */
|
|
73
|
-
type MoveKind = '机制' | '输入规则' | '边界' | '省事提示' | '背景';
|
|
74
|
-
|
|
75
|
-
/** KEEP 键的类别(错误 / 安全 / 空态三类必须有代表)。 */
|
|
76
|
-
type KeepKind = '错误' | '安全' | '空态' | '状态' | 'Modal决策' | '元数据';
|
|
77
|
-
|
|
78
|
-
interface MovePin {
|
|
79
|
-
key: string;
|
|
80
|
-
file: string;
|
|
81
|
-
kind: MoveKind;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface KeepPin {
|
|
85
|
-
key: string;
|
|
86
|
-
file: string;
|
|
87
|
-
kind: KeepKind;
|
|
88
|
-
/** 非字典字面量形态的渲染针(如 `privateRepoHint(uiT)`);缺省 = `'key'`。 */
|
|
89
|
-
needle?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** MOVE 判定清单(t1: 2 / t2: 16 / t3: 13 / t4: 9 / t5: 2 = 42 键;t7(2026-10-12)= 41 键,合计 83)。 */
|
|
93
|
-
const MOVE_PINS: readonly MovePin[] = [
|
|
94
|
-
// t1:common/
|
|
95
|
-
{ key: 'runs.retentionHint', file: 'src/client/common/RunsCenter.tsx', kind: '机制' },
|
|
96
|
-
{ key: 'picker.sessionWorkspaceLinked', file: 'src/client/common/ContentPicker.tsx', kind: '机制' },
|
|
97
|
-
// t2:sync/
|
|
98
|
-
{ key: 'channel.perChannelHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '机制' },
|
|
99
|
-
{ key: 'config.repoUrlHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
100
|
-
{ key: 'github.description', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '机制' },
|
|
101
|
-
{ key: 'webdav.presetHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
102
|
-
{ key: 'webdav.urlHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
103
|
-
{ key: 'webdav.usernameHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
104
|
-
{ key: 'config.saveHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '机制' },
|
|
105
|
-
{ key: 'mode.sessionsPickHint', file: 'src/client/sync/SyncSectionPickerDialog.tsx', kind: '机制' },
|
|
106
|
-
{ key: 'mode.sessionsLimitHint', file: 'src/client/sync/SyncSectionPickerDialog.tsx', kind: '输入规则' },
|
|
107
|
-
{ key: 'mode.sectionsHint', file: 'src/client/sync/SyncSectionPickerDialog.tsx', kind: '机制' },
|
|
108
|
-
{ key: 'mode.hint', file: 'src/client/sync/SyncPanel.tsx', kind: '机制' },
|
|
109
|
-
// 2026-11-01 用户要求:删掉两处「保存/即时生效」ⓘ(弹窗底部与同步页分区行)——
|
|
110
|
-
// 它们在解释用户无从选择的事,MOVE 台账随之退出 2 条。
|
|
111
|
-
{ key: 'channel.openHint', file: 'src/client/sync/SyncChannelEntryCard.tsx', kind: '机制' },
|
|
112
|
-
{ key: 'autosync.description', file: 'src/client/sync/AutosyncCard.tsx', kind: '机制' },
|
|
113
|
-
{ key: 'autosync.intervalHint', file: 'src/client/sync/AutosyncCard.tsx', kind: '机制' },
|
|
114
|
-
// t3:environment/maintenance + home + library + export/(v3 搬移后的落点)
|
|
115
|
-
// UI v2:产物列表搬进产物库 → MOVE 键的渲染点随之改址
|
|
116
|
-
// 2026-10-04 用户要求:产物库页首标题行(含保留期 ⓘ)整体移除 → `snapshots.retentionHint` 退出 MOVE 台账(43 → 42)
|
|
117
|
-
// (备份文件提示随 BackupFilesCard 一起消失,其信息由行内元数据承担)
|
|
118
|
-
{ key: 'backupFiles.hint', file: 'src/client/library/LibraryPanel.tsx', kind: '机制' },
|
|
119
|
-
{ key: 'diskUsage.backupRetention', file: 'src/client/environment/maintenance/DiskUsageCard.tsx', kind: '机制' },
|
|
120
|
-
{ key: 'backupSchedule.hint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '机制' },
|
|
121
|
-
{ key: 'backupSchedule.enabledHint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '机制' },
|
|
122
|
-
{ key: 'backupSchedule.customHint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '边界' },
|
|
123
|
-
{ key: 'retention.hint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '边界' },
|
|
124
|
-
{ key: 'retention.keepLastHint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '输入规则' },
|
|
125
|
-
{ key: 'retention.keepMonthlyHint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '输入规则' },
|
|
126
|
-
{ key: 'retention.keepYearlyHint', file: 'src/client/home/BackupScheduleCard.tsx', kind: '输入规则' },
|
|
127
|
-
{ key: 'retention.appliesTo', file: 'src/client/home/BackupScheduleCard.tsx', kind: '边界' },
|
|
128
|
-
{ key: 'export.hint', file: 'src/client/export/ExportView.tsx', kind: '机制' },
|
|
129
|
-
{ key: 'export.fileNameHint', file: 'src/client/export/ExportView.tsx', kind: '输入规则' },
|
|
130
|
-
{ key: 'export.noteHint', file: 'src/client/export/ExportView.tsx', kind: '背景' },
|
|
131
|
-
// t4:market/ + about/ + profiles/
|
|
132
|
-
{ key: 'myconfigs.login.hint', file: 'src/client/market/MyConfigsLoginCard.tsx', kind: '机制' },
|
|
133
|
-
{ key: 'myconfigs.update.zipHint', file: 'src/client/market/MyConfigsWizard.tsx', kind: '机制' },
|
|
134
|
-
{ key: 'myconfigs.upload.form.nameHint', file: 'src/client/market/MyConfigsWizard.tsx', kind: '省事提示' },
|
|
135
|
-
{ key: 'about.diag.hint', file: 'src/client/about/AboutPanel.tsx', kind: '背景' },
|
|
136
|
-
{ key: 'about.feedbackHint', file: 'src/client/about/AboutPanel.tsx', kind: '省事提示' },
|
|
137
|
-
{ key: 'about.update.offline', file: 'src/client/about/AboutPanel.tsx', kind: '边界' },
|
|
138
|
-
{ key: 'about.cli.hint', file: 'src/client/about/AboutPanel.tsx', kind: '背景' },
|
|
139
|
-
{ key: 'profiles.create.hint', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '机制' },
|
|
140
|
-
{ key: 'profiles.list.hint', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '省事提示' },
|
|
141
|
-
// t5:recovery/
|
|
142
|
-
{ key: 'sessions.desc', file: 'src/client/recovery/SessionHealthCard.tsx', kind: '机制' },
|
|
143
|
-
{ key: 'recovery.preview.hint', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
|
|
144
|
-
// t7(2026-10-12 用户要求「所有描述都收进 ⓘ」):页级 / 分区级副标题 + 卡片 / 字段说明。
|
|
145
|
-
// 判定口径见 DESIGN.md §7(本次把原 KEEP-2 的**静态安全说明**与 KEEP-7 的**静态副标题**一并纳入 MOVE;
|
|
146
|
-
// 动态校验错误 / 状态 / 空态 / 禁用原因 / 确认弹窗内的危险操作说明仍常驻)。
|
|
147
|
-
{ key: 'profiles.subtitle', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '机制' },
|
|
148
|
-
{ key: 'section.description', file: 'src/client/sync/SyncPanel.tsx', kind: '机制' },
|
|
149
|
-
{ key: 'section.description', file: 'src/client/market/MarketPanel.tsx', kind: '机制' },
|
|
150
|
-
{ key: 'history.subtitle', file: 'src/client/history/HistoryPanel.tsx', kind: '机制' },
|
|
151
|
-
{ key: 'rollback.desc', file: 'src/client/recovery/RollbackCard.tsx', kind: '机制' },
|
|
152
|
-
{ key: 'rollback.preview.hint', file: 'src/client/recovery/RollbackCard.tsx', kind: '机制' },
|
|
153
|
-
{ key: 'import.select.hint', file: 'src/client/import/import-wizard-steps.tsx', kind: '机制' },
|
|
154
|
-
{ key: 'import.consult.hint', file: 'src/client/import/import-wizard-steps.tsx', kind: '机制' },
|
|
155
|
-
{ key: 'import.decryptArchive.hint', file: 'src/client/import/import-wizard-steps.tsx', kind: '机制' },
|
|
156
|
-
{ key: 'import.conflicts.hint', file: 'src/client/import/import-wizard-steps.tsx', kind: '机制' },
|
|
157
|
-
{ key: 'import.paths.hint', file: 'src/client/import/import-wizard-steps.tsx', kind: '机制' },
|
|
158
|
-
{ key: 'import.secrets.hint', file: 'src/client/import/import-wizard-steps.tsx', kind: '机制' },
|
|
159
|
-
{ key: 'import.picker.hint', file: 'src/client/import/ImportWizardView.tsx', kind: '机制' },
|
|
160
|
-
{ key: 'foreign.source.hint', file: 'src/client/import/ForeignImportView.tsx', kind: '机制' },
|
|
161
|
-
{ key: 'foreign.lossy.hint', file: 'src/client/import/ForeignImportView.tsx', kind: '机制' },
|
|
162
|
-
{ key: 'foreign.previewDryRun', file: 'src/client/import/ForeignImportView.tsx', kind: '机制' },
|
|
163
|
-
{ key: 'mode.encryptHint', file: 'src/client/sync/SecurityOptionsCard.tsx', kind: '机制' },
|
|
164
|
-
{ key: 'mode.encryptAutosyncNotice', file: 'src/client/sync/SecurityOptionsCard.tsx', kind: '边界' },
|
|
165
|
-
{ key: 'mode.includeSecretsHint', file: 'src/client/sync/SecurityOptionsCard.tsx', kind: '机制' },
|
|
166
|
-
{ key: 'mode.deletePluginsHint', file: 'src/client/sync/SyncSectionPickerDialog.tsx', kind: '边界' },
|
|
167
|
-
{ key: 'mode.passwordSavedHint', file: 'src/client/sync/SecurityOptionsCard.tsx', kind: '机制' },
|
|
168
|
-
{ key: 'mode.decryptPasswordHint', file: 'src/client/sync/DecryptPasswordCard.tsx', kind: '机制' },
|
|
169
|
-
{ key: 'export.encryptHint', file: 'src/client/export/ExportView.tsx', kind: '机制' },
|
|
170
|
-
{ key: 'export.includeSecretsHint', file: 'src/client/export/ExportView.tsx', kind: '机制' },
|
|
171
|
-
{ key: 'export.compositionHint', file: 'src/client/export/ExportView.tsx', kind: '机制' },
|
|
172
|
-
{ key: 'snapshots.selectHint', file: 'src/client/library/LibraryActions.tsx', kind: '省事提示' },
|
|
173
|
-
{ key: 'diskUsage.clean.hint', file: 'src/client/environment/maintenance/DiskUsageCard.tsx', kind: '边界' },
|
|
174
|
-
{ key: 'recovery.safeMode.detail', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
|
|
175
|
-
{ key: 'sessions.repair.desc', file: 'src/client/recovery/SessionHealthDialog.tsx', kind: '机制' },
|
|
176
|
-
{ key: 'recovery.rescue.desc', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
|
|
177
|
-
{ key: 'sessions.layout.planReadOnly', file: 'src/client/recovery/SessionLayoutSection.tsx', kind: '边界' },
|
|
178
|
-
{ key: 'recovery.incomplete.hint', file: 'src/client/recovery/IncompleteCopiesSection.tsx', kind: '机制' },
|
|
179
|
-
{ key: 'repoPicker.privateOnly', file: 'src/client/sync/SyncRepositoryPicker.tsx', kind: '输入规则' },
|
|
180
|
-
{ key: 'config.tokenHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
181
|
-
{ key: 'webdav.passwordHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
182
|
-
{ key: 'cloud.secretHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
183
|
-
{ key: 'cloud.tokenHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
|
|
184
|
-
{ key: 'myconfigs.upload.selectHint', file: 'src/client/market/MyConfigsWizard.tsx', kind: '机制' },
|
|
185
|
-
{ key: 'myconfigs.upload.mode.shareHint', file: 'src/client/market/MyConfigsWizard.tsx', kind: '背景' },
|
|
186
|
-
];
|
|
187
|
-
|
|
188
|
-
/** KEEP 判定清单(错误 / 安全 / 空态三类各有代表;每类至少一处,见 t6-2 的覆盖断言)。 */
|
|
189
|
-
const KEEP_PINS: readonly KeepPin[] = [
|
|
190
|
-
// ①错误 / 失败原因
|
|
191
|
-
{ key: 'history.autosyncError', file: 'src/client/sync/SyncLogList.tsx', kind: '错误' },
|
|
192
|
-
{ key: 'snapshots.plan.diffUnreadable', file: 'src/client/library/RestorePlanView.tsx', kind: '错误' },
|
|
193
|
-
{ key: 'export.fileNameInvalid', file: 'src/client/export/ExportView.tsx', kind: '错误' },
|
|
194
|
-
{ key: 'detail.failed', file: 'src/client/market/MarketPanel.tsx', kind: '错误' },
|
|
195
|
-
{ key: 'myconfigs.install.failed', file: 'src/client/market/MyConfigsInstall.tsx', kind: '错误' },
|
|
196
|
-
{ key: 'about.update.noCommand', file: 'src/client/about/AboutPanel.tsx', kind: '错误' },
|
|
197
|
-
{ key: 'nextSteps.unresolved.hint', file: 'src/client/import/ImportWizardView.tsx', kind: '错误' },
|
|
198
|
-
{ key: 'diskUsage.partial', file: 'src/client/environment/maintenance/DiskUsageCard.tsx', kind: '错误' },
|
|
199
|
-
{ key: 'picker.unitsUnavailable', file: 'src/client/common/ContentPicker.tsx', kind: '错误' },
|
|
200
|
-
{ key: 'runs.loadFailed', file: 'src/client/common/RunsCenter.tsx', kind: '错误' },
|
|
201
|
-
// ②安全与不可逆
|
|
202
|
-
{ key: 'privateRepoHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '安全', needle: 'privateRepoHint(uiT)' },
|
|
203
|
-
{ key: 'backupFiles.encryptedHint', file: 'src/client/library/ArtifactRow.tsx', kind: '安全' },
|
|
204
|
-
{ key: 'review.rollbackHint', file: 'src/client/market/MarketImportReview.tsx', kind: '安全' },
|
|
205
|
-
{ key: 'nextSteps.secrets.hint', file: 'src/client/import/ImportWizardView.tsx', kind: '安全' },
|
|
206
|
-
{ key: 'profiles.duplicate.includeModulesHint', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '安全' },
|
|
207
|
-
// ⑤空态解释
|
|
208
|
-
{ key: 'history.emptyHint', file: 'src/client/sync/SyncLogList.tsx', kind: '空态' },
|
|
209
|
-
{ key: 'history.empty', file: 'src/client/history/HistoryPanel.tsx', kind: '空态' },
|
|
210
|
-
{ key: 'overview.activity.empty', file: 'src/client/home/HomePanel.tsx', kind: '空态' },
|
|
211
|
-
{ key: 'review.changeEmpty', file: 'src/client/market/MarketImportReview.tsx', kind: '空态' },
|
|
212
|
-
{ key: 'export.compositionEmpty', file: 'src/client/export/ExportView.tsx', kind: '空态' },
|
|
213
|
-
{ key: 'snapshots.plan.diffIdentical', file: 'src/client/library/RestorePlanView.tsx', kind: '空态' },
|
|
214
|
-
{ key: 'profiles.running.none', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '空态' },
|
|
215
|
-
{ key: 'backupFiles.empty', file: 'src/client/library/LibraryPanel.tsx', kind: '空态' },
|
|
216
|
-
{ key: 'runs.empty', file: 'src/client/common/RunsCenter.tsx', kind: '空态' },
|
|
217
|
-
// ③状态 / 等待 / 计数
|
|
218
|
-
{ key: 'mode.decryptPasswordSaved', file: 'src/client/sync/DecryptPasswordCard.tsx', kind: '状态' },
|
|
219
|
-
{ key: 'syncflow.noSnapshots', file: 'src/client/sync/SyncPanel.tsx', kind: '状态' },
|
|
220
|
-
{ key: 'history.corruptedCount', file: 'src/client/history/HistoryPanel.tsx', kind: '状态' },
|
|
221
|
-
// v3:首页的「分区构成卡」已按 §7 移出(其等价合计在导出流程的「本次将导出」构成卡里,
|
|
222
|
-
// 走 export.composition* 键)。本键随卡片删除,不再是任何界面的渲染点 —— 故从 KEEP 台账移除。
|
|
223
|
-
{ key: 'import.skipPending', file: 'src/client/import/ImportWizardView.tsx', kind: '状态' },
|
|
224
|
-
// ⑧ Modal 内决策 / 危险操作说明
|
|
225
|
-
{ key: 'syncflow.adoptHint', file: 'src/client/sync/SyncConfirmView.tsx', kind: 'Modal决策' },
|
|
226
|
-
{ key: 'syncflow.bulkHint', file: 'src/client/sync/SyncConfirmView.tsx', kind: 'Modal决策' },
|
|
227
|
-
{ key: 'about.update.commandHint', file: 'src/client/about/AboutPanel.tsx', kind: 'Modal决策' },
|
|
228
|
-
{ key: 'about.update.copyCommand', file: 'src/client/about/AboutPanel.tsx', kind: 'Modal决策' },
|
|
229
|
-
{ key: 'profiles.duplicate.onlyManifest', file: 'src/client/environment/EnvironmentPanel.tsx', kind: 'Modal决策' },
|
|
230
|
-
// ⑥/⑦ 行内 title= 与设备告警
|
|
231
|
-
{ key: 'picker.highRiskHint', file: 'src/client/common/ContentPicker.tsx', kind: '元数据' },
|
|
232
|
-
{ key: 'export.selectionWarnings', file: 'src/client/export/ExportView.tsx', kind: '元数据' },
|
|
233
|
-
];
|
|
234
|
-
|
|
235
|
-
/** label= 白名单:值来自调用方显式传入的字符串 prop(UiT 消费方取不到主字典)。 */
|
|
236
|
-
const LABEL_PROP_PINS: Readonly<Record<string, string>> = {
|
|
237
|
-
'src/client/environment/maintenance/DiskUsageCard.tsx': 'infoHintLabel',
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
/** 上表 prop 的提供方:必须由有主字典 t 的文件显式传 `t('common.infoHint')`。 */
|
|
241
|
-
// UI v2 第 3 步:维护与诊断(含 DiskUsageCard)搬进环境页 → 提供方随之改址
|
|
242
|
-
const LABEL_PROP_PROVIDER = 'src/client/environment/EnvironmentPanel.tsx';
|
|
243
|
-
|
|
244
|
-
/** 可见说明行的 CSS Modules 类(MOVE 键不得再渲染进这些类)。 */
|
|
245
|
-
const VISIBLE_HINT_CLASS_RE = /\bcss\.(hint|modeHint|groupNote|noticeLine)\b/;
|
|
246
|
-
|
|
247
|
-
/** 自闭合的 InfoHint 调用块(含多行形态)。 */
|
|
248
|
-
const HINT_CALL_RE = /<InfoHint\b[\s\S]*?\/>/g;
|
|
249
|
-
|
|
250
|
-
/** common.infoHint 的规范值(改口径必须同时改 4 本字典 + 本守卫)。 */
|
|
251
|
-
const CANON_ZH = '查看说明';
|
|
252
|
-
const CANON_EN = 'Show description';
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* 必须带该键的命名空间字典(出现 ⓘ 调用点的命名空间;history 零 MOVE,不参与)。
|
|
256
|
-
*
|
|
257
|
-
* tech-debt #22(2026-11 字典按域拆分):`common.infoHint` 在原文里物理位于「会话归位」段
|
|
258
|
-
* (HEAD:src/client/locales.ts:715),拆完落在 `src/client/locales/sessions.ts`;聚合器
|
|
259
|
-
* `src/client/locales.ts` 只剩展开语句,不再含任何键字面量。
|
|
260
|
-
*/
|
|
261
|
-
const INFO_HINT_DICTS: readonly string[] = [
|
|
262
|
-
'src/client/locales/sessions.ts',
|
|
263
|
-
'src/client/market/market-locales.ts',
|
|
264
|
-
'src/client/sync/sync-locales.ts',
|
|
265
|
-
'src/client/recovery/recovery-locales.ts',
|
|
266
|
-
];
|
|
267
|
-
|
|
268
|
-
/** 读取 src/client 下全部非测试源码(剥注释;server 侧 / tests 不参与)。 */
|
|
269
|
-
function readClientSources(): SourceFile[] {
|
|
270
|
-
const out: SourceFile[] = [];
|
|
271
|
-
const visit = (abs: string): void => {
|
|
272
|
-
for (const entry of fs.readdirSync(abs, { withFileTypes: true }).sort((a, b) => (a.name < b.name ? -1 : 1))) {
|
|
273
|
-
const child = path.join(abs, entry.name);
|
|
274
|
-
if (entry.isDirectory()) {
|
|
275
|
-
if (entry.name !== 'node_modules') visit(child);
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
if (!/\.tsx?$/.test(entry.name) || /\.test\.tsx?$/.test(entry.name)) continue;
|
|
279
|
-
const rel = path.relative(ROOT, child).split(path.sep).join('/');
|
|
280
|
-
// issue #70:锚点是含裸 \n 的源码字面量 ⇒ 读取入口统一折 LF(本文件用 normalizeEol 同一口径)
|
|
281
|
-
out.push({ rel, code: normalizeEol(stripJsComments(fs.readFileSync(child, 'utf8'), true, false)) });
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
visit(path.join(ROOT, 'src/client'));
|
|
285
|
-
return out;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** 1-based 行号(`stripJsComments` 保留换行,故行号与原文一致)。 */
|
|
289
|
-
function lineOf(text: string, index: number): number {
|
|
290
|
-
let n = 1;
|
|
291
|
-
for (let i = 0; i < index && i < text.length; i++) if (text[i] === '\n') n++;
|
|
292
|
-
return n;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/** 把所有 InfoHint 调用块替换成等长空白(保留换行):用于「该键是否还有可见渲染点」的判定。 */
|
|
296
|
-
function maskHintCalls(code: string): string {
|
|
297
|
-
return code.replace(HINT_CALL_RE, (m) => m.replace(/[^\n]/g, ' '));
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/** 键字面量匹配(单引号形态,与仓库既有写法一致)。 */
|
|
301
|
-
function keyLiteral(key: string): string {
|
|
302
|
-
return "'" + key + "'";
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* MOVE 违规扫描:
|
|
307
|
-
* a) 该文件里必须有一处 InfoHint 的 text= 复用原键(否则说明「文案丢了」或没真正 MOVE);
|
|
308
|
-
* b) 除 InfoHint 调用外,该键不得再出现在可见说明行(css.hint / css.modeHint / …)。
|
|
309
|
-
*/
|
|
310
|
-
function findMoveViolations(files: readonly SourceFile[], pins: readonly MovePin[]): string[] {
|
|
311
|
-
const byFile = new Map(files.map((f) => [f.rel, f]));
|
|
312
|
-
const violations: string[] = [];
|
|
313
|
-
for (const pin of pins) {
|
|
314
|
-
const file = byFile.get(pin.file);
|
|
315
|
-
if (file === undefined) {
|
|
316
|
-
violations.push(pin.file + ': 文件不存在(MOVE 键 ' + pin.key + ')');
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
const hits = [...file.code.matchAll(HINT_CALL_RE)];
|
|
320
|
-
// 允许两种形态:t('key') 与带插值的 t('key', { … })
|
|
321
|
-
const needle = 't(' + keyLiteral(pin.key);
|
|
322
|
-
const shaped = hits.find((m) => {
|
|
323
|
-
const body = m[0] ?? '';
|
|
324
|
-
const at = body.indexOf(needle);
|
|
325
|
-
if (at < 0) return false;
|
|
326
|
-
const next = body.charAt(at + needle.length);
|
|
327
|
-
return next === ')' || next === ',' || next === ' ';
|
|
328
|
-
});
|
|
329
|
-
if (shaped === undefined) {
|
|
330
|
-
violations.push(pin.file + ': 找不到复用原字典键 ' + keyLiteral(pin.key) + ' 的 <InfoHint text=…> 调用(MOVE 未落地或键名写错)');
|
|
331
|
-
}
|
|
332
|
-
const masked = maskHintCalls(file.code);
|
|
333
|
-
masked.split('\n').forEach((line, i) => {
|
|
334
|
-
if (!line.includes(keyLiteral(pin.key))) return;
|
|
335
|
-
if (VISIBLE_HINT_CLASS_RE.test(line)) {
|
|
336
|
-
violations.push(pin.file + ':' + String(i + 1) + ': MOVE 键 ' + keyLiteral(pin.key) + ' 仍渲染在可见说明行:' + line.trim());
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
return violations;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* KEEP 违规扫描:该键必须仍在本文件里以可见形态出现(非 InfoHint 的 text=)。
|
|
345
|
-
* 文案本身(字典值)由 t6 的 git diff 逐字核对;这里钉的是「还有没有渲染点」。
|
|
346
|
-
*/
|
|
347
|
-
function findKeepViolations(files: readonly SourceFile[], pins: readonly KeepPin[]): string[] {
|
|
348
|
-
const byFile = new Map(files.map((f) => [f.rel, f]));
|
|
349
|
-
const violations: string[] = [];
|
|
350
|
-
for (const pin of pins) {
|
|
351
|
-
const file = byFile.get(pin.file);
|
|
352
|
-
if (file === undefined) {
|
|
353
|
-
violations.push(pin.file + ': 文件不存在(KEEP 键 ' + pin.key + ')');
|
|
354
|
-
continue;
|
|
355
|
-
}
|
|
356
|
-
const needle = pin.needle ?? keyLiteral(pin.key);
|
|
357
|
-
if (!maskHintCalls(file.code).includes(needle)) {
|
|
358
|
-
violations.push(pin.file + ': KEEP 键 ' + keyLiteral(pin.key) + ' 的可见渲染点消失了(期望仍在 ' + pin.file + ' 里以 ' + needle + ' 渲染)');
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return violations;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* 可访问名违规扫描:每一处 `<InfoHint>` 都必须显式给可访问名 ——
|
|
366
|
-
* `label={t('common.infoHint')}` / 白名单字符串 prop / 主字典翻译器 `t={t}`。
|
|
367
|
-
*/
|
|
368
|
-
function findAccessibleNameViolations(files: readonly SourceFile[]): string[] {
|
|
369
|
-
const violations: string[] = [];
|
|
370
|
-
for (const file of files) {
|
|
371
|
-
for (const m of file.code.matchAll(HINT_CALL_RE)) {
|
|
372
|
-
const body = m[0] ?? '';
|
|
373
|
-
const line = lineOf(file.code, m.index ?? 0);
|
|
374
|
-
if (/label=\{t\('common\.infoHint'\)\}/.test(body)) continue;
|
|
375
|
-
const prop = LABEL_PROP_PINS[file.rel];
|
|
376
|
-
if (prop !== undefined && body.includes('label={' + prop + '}')) continue;
|
|
377
|
-
const translator = /\bt=\{([A-Za-z_$][\w$]*)\}/.exec(body);
|
|
378
|
-
if (translator !== null && new RegExp('\\b' + (translator[1] ?? '') + '\\s*:\\s*TranslateNS<\'config-manager\'>').test(file.code)) continue;
|
|
379
|
-
violations.push(
|
|
380
|
-
file.rel + ':' + String(line) + ': <InfoHint> 没有显式可访问名(不得依赖组件内置的中文回落):' + body.replace(/\s+/g, ' '),
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return violations;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/** 解析一本字典里的 common.infoHint(zh 在前、en 在后,与仓库字典文件结构一致)。 */
|
|
388
|
-
function parseInfoHintEntry(rel: string): { zh: string | undefined; en: string | undefined; count: number } {
|
|
389
|
-
const src = fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
390
|
-
const values = [...src.matchAll(/['"]common\.infoHint['"]\s*:\s*'([^']*)'/g)].map((m) => m[1] ?? '');
|
|
391
|
-
return { zh: values[0], en: values[1], count: values.length };
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
test('t6-1 MOVE:79 个说明键都已收进 ⓘ(逐字复用原键)且不再有可见说明行', () => {
|
|
395
|
-
const files = readClientSources();
|
|
396
|
-
// 扫描范围自检:客户端源码至少覆盖 t6 涉及的面板目录
|
|
397
|
-
const dirs = new Set(MOVE_PINS.map((p) => p.file.split('/').slice(0, 3).join('/')));
|
|
398
|
-
assert.ok(dirs.size >= 8, 'MOVE 清单必须覆盖全部面板目录(实际 ' + String(dirs.size) + ' 个)');
|
|
399
|
-
// 2026-10-27 文案审计:about.subtitle 是「页面目录式副标题」(插件信息、作者与反馈入口),
|
|
400
|
-
// 页面本身已由卡片表达,随页级标题一并删除 ⇒ MOVE 清单从 82 降到 81(不是删检查项)。
|
|
401
|
-
// 2026-11-01:删掉「改动即时生效并保存」「分区选择已保存到本机」两处 ⓘ(用户要求,
|
|
402
|
-
// 属解释「用户无从选择的事」的废话)⇒ 81 降到 79(不是删检查项)。
|
|
403
|
-
// 2026-11-01:导入选择页的「从其它 agent 导入」按钮与其 ⓘ 一并移除(首页已有直达入口)⇒ 79 降到 78。
|
|
404
|
-
assert.ok(MOVE_PINS.length === 79, 'MOVE 清单长度应为 79(实际 ' + String(MOVE_PINS.length) + ')');
|
|
405
|
-
assert.ok(
|
|
406
|
-
MOVE_PINS.filter((p) => p.kind === '输入规则').length >= 5,
|
|
407
|
-
'输入规则类 MOVE 至少 5 处(config.repoUrlHint / webdav.urlHint / mode.sessionsLimitHint / retention.keep*Hint / export.fileNameHint)',
|
|
408
|
-
);
|
|
409
|
-
const violations = findMoveViolations(files, MOVE_PINS);
|
|
410
|
-
assert.deepEqual(violations, [], 'MOVE 键必须只出现在 <InfoHint text=…> 里:\n' + violations.join('\n'));
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
test('t6-2 KEEP:错误 / 安全 / 空态等常驻文案仍有可见渲染点(失败点名文件)', () => {
|
|
414
|
-
const files = readClientSources();
|
|
415
|
-
for (const kind of ['错误', '安全', '空态'] as const) {
|
|
416
|
-
assert.ok(KEEP_PINS.some((p) => p.kind === kind), 'KEEP 清单必须覆盖「' + kind + '」类');
|
|
417
|
-
}
|
|
418
|
-
const violations = findKeepViolations(files, KEEP_PINS);
|
|
419
|
-
assert.deepEqual(violations, [], 'KEEP 键的可见渲染点不得消失(这些是错误/安全/空态/状态文案):\n' + violations.join('\n'));
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
test('t6-3 每一处 <InfoHint> 都显式传了可访问名(label 或主字典翻译器)', () => {
|
|
423
|
-
const files = readClientSources();
|
|
424
|
-
const calls = files.reduce((n, f) => n + [...f.code.matchAll(HINT_CALL_RE)].length, 0);
|
|
425
|
-
assert.ok(calls >= 40, '客户端 <InfoHint> 调用点应 >= 40(实际 ' + String(calls) + ')—— 扫不到即假绿');
|
|
426
|
-
// 形态自检:非自闭合写法会被本守卫漏掉
|
|
427
|
-
const undersupported: string[] = [];
|
|
428
|
-
for (const f of files) {
|
|
429
|
-
const open = [...f.code.matchAll(/<InfoHint\b/g)].length;
|
|
430
|
-
const selfClosing = [...f.code.matchAll(HINT_CALL_RE)].length;
|
|
431
|
-
if (open !== selfClosing) undersupported.push(f.rel + ': <InfoHint 出现 ' + String(open) + ' 次,自闭合块 ' + String(selfClosing) + ' 个');
|
|
432
|
-
}
|
|
433
|
-
assert.deepEqual(undersupported, [], '<InfoHint> 必须是自闭合写法(</InfoHint> 形态守卫无法解析):\n' + undersupported.join('\n'));
|
|
434
|
-
// DiskUsageCard 走 prop:提供方必须显式给主字典键
|
|
435
|
-
const provider = files.find((f) => f.rel === LABEL_PROP_PROVIDER);
|
|
436
|
-
assert.ok(provider !== undefined, LABEL_PROP_PROVIDER + ' 必须存在');
|
|
437
|
-
for (const [rel, prop] of Object.entries(LABEL_PROP_PINS)) {
|
|
438
|
-
assert.ok(
|
|
439
|
-
provider!.code.includes(prop + "={t('common.infoHint')}"),
|
|
440
|
-
LABEL_PROP_PROVIDER + " 必须为 " + rel + ' 显式传入 ' + prop + "={t('common.infoHint')}",
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
const violations = findAccessibleNameViolations(files);
|
|
444
|
-
assert.deepEqual(violations, [], '每一处 <InfoHint> 都必须显式传可访问名:\n' + violations.join('\n'));
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
test('t6-4 common.infoHint 口径一致:主字典 + market / sync / recovery 四本字典 zh/en 逐字相同', () => {
|
|
448
|
-
const canon = parseInfoHintEntry(INFO_HINT_DICTS[0]!);
|
|
449
|
-
assert.equal(canon.count, 2, INFO_HINT_DICTS[0] + ' 必须恰好有两处 common.infoHint(zh + en),实际 ' + String(canon.count));
|
|
450
|
-
assert.equal(canon.zh, CANON_ZH, INFO_HINT_DICTS[0] + ' 的 zh 应为 ' + CANON_ZH);
|
|
451
|
-
assert.equal(canon.en, CANON_EN, INFO_HINT_DICTS[0] + ' 的 en 应为 ' + CANON_EN);
|
|
452
|
-
const violations: string[] = [];
|
|
453
|
-
for (const rel of INFO_HINT_DICTS.slice(1)) {
|
|
454
|
-
const got = parseInfoHintEntry(rel);
|
|
455
|
-
if (got.count !== 2) { violations.push(rel + ': 应有 2 处 common.infoHint(zh + en),实际 ' + String(got.count)); continue }
|
|
456
|
-
if (got.zh !== canon.zh) violations.push(rel + ': zh 期望 ' + JSON.stringify(canon.zh) + ',实际 ' + JSON.stringify(got.zh));
|
|
457
|
-
if (got.en !== canon.en) violations.push(rel + ': en 期望 ' + JSON.stringify(canon.en) + ',实际 ' + JSON.stringify(got.en));
|
|
458
|
-
}
|
|
459
|
-
// 任何其它自带该键的 *-locales.ts 也必须同口径(将来某命名空间新增 ⓘ 时自动纳入)
|
|
460
|
-
const dirs = fs.readdirSync(path.join(ROOT, 'src/client'), { withFileTypes: true }).filter((e) => e.isDirectory());
|
|
461
|
-
for (const d of dirs) {
|
|
462
|
-
const rel = 'src/client/' + d.name + '/' + d.name + '-locales.ts';
|
|
463
|
-
if (!fs.existsSync(path.join(ROOT, rel))) continue;
|
|
464
|
-
if (INFO_HINT_DICTS.includes(rel)) continue;
|
|
465
|
-
const src = fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
466
|
-
if (!src.includes("'common.infoHint'")) continue;
|
|
467
|
-
const got = parseInfoHintEntry(rel);
|
|
468
|
-
if (got.zh !== canon.zh) violations.push(rel + ': zh 与主字典不一致(' + JSON.stringify(got.zh) + ' vs ' + JSON.stringify(canon.zh) + ')');
|
|
469
|
-
if (got.en !== canon.en) violations.push(rel + ': en 与主字典不一致(' + JSON.stringify(got.en) + ' vs ' + JSON.stringify(canon.en) + ')');
|
|
470
|
-
}
|
|
471
|
-
assert.deepEqual(violations, [], 'common.infoHint 必须口径一致:\n' + violations.join('\n'));
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
test('t6-5 负向自检:守卫对合成片段真的会红(避免扫不到即假绿)', () => {
|
|
475
|
-
const syntheticMove: SourceFile[] = [{
|
|
476
|
-
rel: 'src/client/fake/Fake.tsx',
|
|
477
|
-
code: "export const A = () => <div className={css.hint}>{t('export.hint')}</div>;\n",
|
|
478
|
-
}];
|
|
479
|
-
const movePin: MovePin[] = [{ key: 'export.hint', file: 'src/client/fake/Fake.tsx', kind: '机制' }];
|
|
480
|
-
const moveBad = findMoveViolations(syntheticMove, movePin);
|
|
481
|
-
assert.equal(moveBad.length, 2, '合成片段应同时命中「没有 ⓘ」与「仍有可见说明行」两条(实际 ' + String(moveBad.length) + ':' + moveBad.join(' | ') + ')');
|
|
482
|
-
const syntheticOk: SourceFile[] = [{
|
|
483
|
-
rel: 'src/client/fake/Fake.tsx',
|
|
484
|
-
code: "<InfoHint text={t('export.hint')} label={t('common.infoHint')} />\n",
|
|
485
|
-
}];
|
|
486
|
-
assert.deepEqual(findMoveViolations(syntheticOk, movePin), [], '合法形态不得报红');
|
|
487
|
-
|
|
488
|
-
const keepBad = findKeepViolations(syntheticOk, [{ key: 'export.hint', file: 'src/client/fake/Fake.tsx', kind: '错误' }]);
|
|
489
|
-
assert.equal(keepBad.length, 1, 'KEEP 键只剩 InfoHint(可见行被搬走)时必须报红');
|
|
490
|
-
|
|
491
|
-
const a11yBad = findAccessibleNameViolations([{ rel: 'src/client/fake/Fake.tsx', code: "<InfoHint text={t('x.y')} />\n" }]);
|
|
492
|
-
assert.equal(a11yBad.length, 1, '缺少可访问名时必须报红,实际 ' + String(a11yBad.length));
|
|
493
|
-
const a11yOk = findAccessibleNameViolations([{
|
|
494
|
-
rel: 'src/client/fake/Fake.tsx',
|
|
495
|
-
code: "const A = (t: TranslateNS<'config-manager'>) => <InfoHint text={t('x.y')} t={t} />;\n",
|
|
496
|
-
}]);
|
|
497
|
-
assert.deepEqual(a11yOk, [], '主字典翻译器形态必须放行');
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
/* ================================================================
|
|
501
|
-
* t9 增补(t7 评审 F1 / F2):气泡的渲染位置与夹紧基准
|
|
502
|
-
*
|
|
503
|
-
* 为什么必须钉住:
|
|
504
|
-
* `.dialogContentCenter` 带着**常驻** `transform: translate(-50%, -50%)`(config-manager.module.css
|
|
505
|
-
* §6 Overlays)—— 按 CSS Transforms L1,带 transform 的祖先会成为后代 `position: fixed` 的
|
|
506
|
-
* **包含块**。气泡若裸渲在按钮旁边的 DOM 子树里,Modal 内的调用点就会整体偏移「卡片在视口中的
|
|
507
|
-
* 位移」,并被 `.dialogBody{overflow-y:auto}` 裁剪(t7 评审:11/41 个调用点在 Modal 内)。
|
|
508
|
-
* 修法 = `createPortal` 渲到 transform 祖先之外,**容器只能指回 `#dsh-config-manager-root`**。
|
|
509
|
-
* ================================================================ */
|
|
510
|
-
|
|
511
|
-
/** 气泡宿主 + 夹紧基准的共享实现(t9 只读这几个文件的源码)。 */
|
|
512
|
-
const INFO_HINT_FILE = 'src/client/common/InfoHint.tsx';
|
|
513
|
-
const MODAL_FILE = 'src/client/common/Modal.tsx';
|
|
514
|
-
/**
|
|
515
|
-
* 夹紧基准的**实现**所在(2026-10-03 从 InfoHint.tsx 抽到这里):Select 菜单需要同一份基准,
|
|
516
|
-
* 两处各写一份必然分叉(Select 那次跑偏正是因为直接用了视口坐标)。
|
|
517
|
-
* 守卫因此改为扫**两处**:气泡侧仍要调用 canvasBounds(),实现侧要满足容器 ∩ 窗口与唯一兜底。
|
|
518
|
-
*/
|
|
519
|
-
const FLOATING_BOUNDS_FILE = 'src/client/common/floating-bounds.ts';
|
|
520
|
-
|
|
521
|
-
/** 括号配对:`open` 指向 `(`,返回 [start, end) 实参区间;找不到配对返回 null。 */
|
|
522
|
-
function matchParen(src: string, open: number): { start: number; end: number } | null {
|
|
523
|
-
let depth = 0;
|
|
524
|
-
for (let i = open; i < src.length; i++) {
|
|
525
|
-
const c = src[i];
|
|
526
|
-
if (c === '(') depth++;
|
|
527
|
-
else if (c === ')') {
|
|
528
|
-
depth--;
|
|
529
|
-
if (depth === 0) return { start: open, end: i + 1 };
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/** 所有 `createPortal(` 调用的实参区间。 */
|
|
536
|
-
function createPortalSpans(code: string): Array<{ start: number; end: number }> {
|
|
537
|
-
const spans: Array<{ start: number; end: number }> = [];
|
|
538
|
-
for (const m of code.matchAll(/createPortal\s*\(/g)) {
|
|
539
|
-
const span = matchParen(code, (m.index ?? 0) + (m[0] ?? '').length - 1);
|
|
540
|
-
if (span !== null) spans.push(span);
|
|
541
|
-
}
|
|
542
|
-
return spans;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* F1 违规扫描:`css.infoHintBubble` 的每一处出现都必须落在某个 `createPortal(...)` 实参区间内
|
|
547
|
-
* (否则 = 裸渲在 Modal children 的 DOM 子树里,被 transform 包含块 + overflow 裁剪),
|
|
548
|
-
* 且第二实参必须是解析出的插件根容器、**不得**回退 `document.body`。
|
|
549
|
-
* 0 处引用同样算违规 —— 否则「把气泡删掉」会被读成绿灯。
|
|
550
|
-
*/
|
|
551
|
-
function findBubblePortalViolations(code: string): string[] {
|
|
552
|
-
const violations: string[] = [];
|
|
553
|
-
const spans = createPortalSpans(code);
|
|
554
|
-
if (spans.length === 0) {
|
|
555
|
-
violations.push('没有 createPortal 调用:气泡无法脱离 transform 祖先(.dialogContentCenter)');
|
|
556
|
-
}
|
|
557
|
-
let sites = 0;
|
|
558
|
-
for (const m of code.matchAll(/css\.infoHintBubble/g)) {
|
|
559
|
-
sites++;
|
|
560
|
-
const at = m.index ?? 0;
|
|
561
|
-
if (!spans.some((s) => at > s.start && at < s.end)) {
|
|
562
|
-
violations.push('css.infoHintBubble 出现在 createPortal 实参之外(裸 position:fixed 会落进 Modal children 子树,被 transform 包含块与 .dialogBody 的 overflow 裁剪)');
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
if (sites === 0) violations.push('找不到 css.infoHintBubble(气泡渲染点消失?删掉 ≠ 合规)');
|
|
566
|
-
if (/document\.body/.test(code)) {
|
|
567
|
-
violations.push('气泡容器不得回退 document.body(会被宿主 overlay z-index:1000 盖住,并连带 body pointer-events 失效)');
|
|
568
|
-
}
|
|
569
|
-
if (spans.length > 0 && !spans.some((s) => /,\s*container\s*,?\s*\)$/.test(code.slice(s.start, s.end)))) {
|
|
570
|
-
violations.push('createPortal 的第二实参必须是解析出的插件根容器(container)');
|
|
571
|
-
}
|
|
572
|
-
return violations;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* F2 违规扫描:夹紧基准必须是**插件根容器的可见矩形**(恒与窗口取交集),
|
|
577
|
-
* 窗口矩形只允许出现在兜底分支;「下方不够且上方更宽裕 → 向上翻转」必须保留。
|
|
578
|
-
*/
|
|
579
|
-
/**
|
|
580
|
-
* F2-a:**气泡侧**怎么用基准 —— 必须以 canvasBounds() 为基准、左右/上下都夹紧、保留向上翻转。
|
|
581
|
-
* 基准本身怎么算在 findBoundsImplementationViolations(2026-10-03 抽到 floating-bounds.ts 之后,
|
|
582
|
-
* 这两类检查必须分开:混在一起会让「气泡文件里没有容器 rect」被误报成不合规)。
|
|
583
|
-
*/
|
|
584
|
-
function findClampViolations(code: string): string[] {
|
|
585
|
-
const violations: string[] = [];
|
|
586
|
-
if (!/const bounds = canvasBounds\(\)/.test(code)) violations.push('reposition 必须以 canvasBounds()(容器 ∩ 窗口)为夹紧基准');
|
|
587
|
-
|
|
588
|
-
if (!/clamp\(left, minLeft, maxLeft\)/.test(code) || !/clamp\(rawTop, minTop, maxTop\)/.test(code)) {
|
|
589
|
-
violations.push('左右 / 上下都必须夹进基准矩形(clamp(left/rawTop, …))');
|
|
590
|
-
}
|
|
591
|
-
if (!/box\.height > below && above > below \? 'top' : 'bottom'/.test(code)) {
|
|
592
|
-
violations.push('「下方空间不足且上方更宽裕 → 向上翻转」的既有行为不得丢失');
|
|
593
|
-
}
|
|
594
|
-
return violations;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* 共享夹紧实现(floating-bounds.ts)的合规扫描:容器矩形 ∩ 窗口、窗口只作兜底且只出现一次、
|
|
599
|
-
* 退化时回落窗口。与 findClampViolations 分开 —— 前者管「气泡怎么用基准」,这里管「基准本身怎么算」。
|
|
600
|
-
*/
|
|
601
|
-
function findBoundsImplementationViolations(code: string): string[] {
|
|
602
|
-
const violations: string[] = [];
|
|
603
|
-
if (!/const root = resolveModalRoot\(\)/.test(code)) violations.push('夹紧基准必须取插件根容器(resolveModalRoot())');
|
|
604
|
-
if (!/const rect = root\.getBoundingClientRect\(\)/.test(code)) violations.push('必须量测插件根容器的 rect 作为夹紧基准');
|
|
605
|
-
if (!/rect\.left, win\.left/.test(code) || !/rect\.right, win\.right/.test(code)) {
|
|
606
|
-
violations.push('画布矩形必须与窗口矩形取交集(恒不出浏览器视口)');
|
|
607
|
-
}
|
|
608
|
-
const vw = [...code.matchAll(/window\.innerWidth/g)].length;
|
|
609
|
-
const vh = [...code.matchAll(/window\.innerHeight/g)].length;
|
|
610
|
-
if (vw !== 1 || vh !== 1) {
|
|
611
|
-
violations.push('window.innerWidth/innerHeight 只允许各出现一次(窗口矩形仅作兜底),实际 ' + String(vw) + '/' + String(vh));
|
|
612
|
-
}
|
|
613
|
-
if (!/const win: Bounds = \{ left: 0, top: 0, right: window\.innerWidth, bottom: window\.innerHeight \}/.test(code)) {
|
|
614
|
-
violations.push('窗口兜底矩形的形态变了(守卫需同步更新)');
|
|
615
|
-
}
|
|
616
|
-
if (!/rect\.width <= 0 \|\| rect\.height <= 0/.test(code)) {
|
|
617
|
-
violations.push('拿不到容器尺寸时必须回落窗口(不得用 0 矩形去夹紧)');
|
|
618
|
-
}
|
|
619
|
-
return violations;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
test('t9-1 F1:气泡只能经 createPortal 渲进插件根容器(裸 fixed / document.body 一律红灯)', () => {
|
|
623
|
-
const files = readClientSources();
|
|
624
|
-
const hint = files.find((f) => f.rel === INFO_HINT_FILE);
|
|
625
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
626
|
-
const violations = findBubblePortalViolations(hint.code);
|
|
627
|
-
assert.deepEqual(violations, [], '气泡必须经 createPortal 渲进插件根容器:\n' + violations.join('\n'));
|
|
628
|
-
// 容器解析必须复用 Modal.tsx 的导出(唯一实现),且 Modal 侧确实按 MODAL_ROOT_ID 查询
|
|
629
|
-
assert.ok(
|
|
630
|
-
hint.code.includes("import { resolveModalRoot } from './Modal.tsx'"),
|
|
631
|
-
'容器解析必须复用 Modal.tsx 的导出(不得各写一份 getElementById)',
|
|
632
|
-
);
|
|
633
|
-
assert.match(hint.code, /useState<HTMLElement \| null>\(resolveModalRoot\)/, '渲染期必须同步解析容器(惰性 useState)');
|
|
634
|
-
assert.match(hint.code, /setContainer\(resolveModalRoot\(\)\)/, 'layout effect 必须兜底重解析容器');
|
|
635
|
-
const modal = files.find((f) => f.rel === MODAL_FILE);
|
|
636
|
-
assert.ok(modal !== undefined, MODAL_FILE + ' 必须存在');
|
|
637
|
-
assert.match(modal.code, /export function resolveModalRoot\(\)/, 'Modal.tsx 必须导出 resolveModalRoot');
|
|
638
|
-
assert.match(modal.code, /getElementById\(MODAL_ROOT_ID\)/, '插件根节点必须按 MODAL_ROOT_ID 查询');
|
|
639
|
-
assert.match(modal.code, /export const MODAL_ROOT_ID = 'dsh-config-manager-root'/, 'MODAL_ROOT_ID 必须是 #dsh-config-manager-root');
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
test('t9-2 F2:夹紧基准 = 插件根容器可见矩形 ∩ 窗口(不是窗口),翻转行为保留', () => {
|
|
643
|
-
const files = readClientSources();
|
|
644
|
-
const hint = files.find((f) => f.rel === INFO_HINT_FILE);
|
|
645
|
-
const bounds = files.find((f) => f.rel === FLOATING_BOUNDS_FILE);
|
|
646
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
647
|
-
assert.ok(bounds !== undefined, FLOATING_BOUNDS_FILE + ' 必须存在(夹紧基准的唯一实现)');
|
|
648
|
-
// ① 气泡侧:reposition 必须以 canvasBounds() 为基准并保留翻转行为
|
|
649
|
-
const violations = findClampViolations(hint.code);
|
|
650
|
-
assert.deepEqual(violations, [], '夹紧基准必须是插件根容器:\n' + violations.join('\n'));
|
|
651
|
-
// ② 实现侧:容器 ∩ 窗口、唯一一次 window 兜底,都必须在共享文件里成立
|
|
652
|
-
const impl = findBoundsImplementationViolations(bounds.code);
|
|
653
|
-
assert.deepEqual(impl, [], '夹紧基准实现必须合规:\n' + impl.join('\n'));
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
test('t9-3 负向自检:合成片段在「拆掉 portal / 挂 body / 删掉气泡 / 丢掉容器 rect / 去掉夹紧」时必须变红', () => {
|
|
657
|
-
const hint = readClientSources().find((f) => f.rel === INFO_HINT_FILE);
|
|
658
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
659
|
-
assert.deepEqual(findBubblePortalViolations(hint.code), [], '真实实现必须合规(否则 t9-1 的绿灯不可信)');
|
|
660
|
-
assert.deepEqual(findClampViolations(hint.code), [], '真实实现的夹紧基准必须合规(否则 t9-2 的绿灯不可信)');
|
|
661
|
-
const boundsFile = readClientSources().find((f) => f.rel === FLOATING_BOUNDS_FILE);
|
|
662
|
-
assert.ok(boundsFile !== undefined, FLOATING_BOUNDS_FILE + ' 必须存在');
|
|
663
|
-
assert.deepEqual(findBoundsImplementationViolations(boundsFile.code), [], '共享夹紧实现同样必须在真实源码上合规');
|
|
664
|
-
|
|
665
|
-
const bare = 'const A = () => <span className={css.infoHintBubble} id={id} />;\n';
|
|
666
|
-
assert.ok(findBubblePortalViolations(bare).length >= 1, '裸 fixed(无 createPortal)必须报红');
|
|
667
|
-
|
|
668
|
-
const bodyPortal = 'const A = () => createPortal(<span className={css.infoHintBubble} />, document.body);\n';
|
|
669
|
-
const bodyViolations = findBubblePortalViolations(bodyPortal);
|
|
670
|
-
assert.ok(
|
|
671
|
-
bodyViolations.length >= 2,
|
|
672
|
-
'挂 document.body 必须同时命中「body 容器」与「第二实参不是 container」(实际 ' + String(bodyViolations.length) + ':' + bodyViolations.join(' | ') + ')',
|
|
673
|
-
);
|
|
674
|
-
|
|
675
|
-
const emptied = 'const A = 1;\n';
|
|
676
|
-
assert.ok(findBubblePortalViolations(emptied).length >= 2, '删掉气泡(无 createPortal / 无引用)必须报红,防「删掉即绿灯」');
|
|
677
|
-
|
|
678
|
-
const goodPortal = 'const A = () => createPortal(<span className={css.infoHintBubble} />, container);\n';
|
|
679
|
-
assert.deepEqual(findBubblePortalViolations(goodPortal), [], 'portal 到 container 的合法形态必须放行');
|
|
680
|
-
|
|
681
|
-
// 基准实现侧的负向自检(2026-10-03 拆出 floating-bounds.ts 后指向该文件的扫描器)
|
|
682
|
-
const boundsSrc = readClientSources().find((f) => f.rel === FLOATING_BOUNDS_FILE);
|
|
683
|
-
assert.ok(boundsSrc !== undefined, FLOATING_BOUNDS_FILE + ' 必须存在');
|
|
684
|
-
const noContainer = boundsSrc.code.replace('const root = resolveModalRoot()', 'const root = null');
|
|
685
|
-
assert.ok(findBoundsImplementationViolations(noContainer).length >= 1, '夹紧基准退回窗口时必须报红(画布不再是基准)');
|
|
686
|
-
const noIntersect = boundsSrc.code.replace('Math.max(rect.left, win.left)', 'rect.left');
|
|
687
|
-
assert.ok(findBoundsImplementationViolations(noIntersect).length >= 1, '容器矩形不与窗口取交集时必须报红');
|
|
688
|
-
const noSizeGuard = boundsSrc.code.replace('rect.width <= 0 || rect.height <= 0', 'false');
|
|
689
|
-
assert.ok(findBoundsImplementationViolations(noSizeGuard).length >= 1, '拿不到容器尺寸不回落窗口时必须报红');
|
|
690
|
-
|
|
691
|
-
// 气泡侧的负向自检
|
|
692
|
-
const noClamp = hint.code.replace('clamp(left, minLeft, maxLeft)', 'left');
|
|
693
|
-
assert.ok(findClampViolations(noClamp).length >= 1, '去掉左右夹紧时必须报红');
|
|
694
|
-
const noFlip = hint.code.replace(/box\.height > below && above > below \? 'top' : 'bottom'/, "'bottom'");
|
|
695
|
-
assert.ok(findClampViolations(noFlip).length >= 1, '丢掉向上翻转时必须报红');
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
/* ================================================================
|
|
699
|
-
* t10 增补(2026-10-04 用户反馈):固定态下「点击任意位置」必须能取消固定
|
|
700
|
-
*
|
|
701
|
-
* 现场:点开 ⓘ 后进入固定态(data-pinned 的主色 tint),只有**再次点击同一颗 ⓘ** 才能退出。
|
|
702
|
-
* 用户必须知道「同一颗图标既是开也是关」,与「点别处收起」的通用浮层预期不符 ——
|
|
703
|
-
* 期望是:固定态下按下任意位置即取消固定并关闭。
|
|
704
|
-
*
|
|
705
|
-
* 为什么钉在源码层:本仓库没有 React 组件测试框架(同 t6 / t9 的理由),
|
|
706
|
-
* 「监听挂没挂、门禁是不是只作用于固定态、按钮自身放没放行」是结构问题,
|
|
707
|
-
* 用合成片段做负向自检即可防住「删掉监听即绿灯」。
|
|
708
|
-
* ================================================================ */
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* t10 违规扫描(只读 InfoHint.tsx)。四条缺一不可:
|
|
712
|
-
* ① 捕获阶段监听 `mousedown`(比 click 早、覆盖右键与拖拽结束,与 Select 同源);
|
|
713
|
-
* ② 只作用于固定态(`if (!pinned) return`)—— 悬停 / 聚焦两条通道各有自己的关闭路径,不得被改写;
|
|
714
|
-
* ③ 触发按钮自身的按下必须放行(否则第 ③ 条通道「再次点击取消固定」会被抢先关闭又重开);
|
|
715
|
-
* ④ 卸载时移除监听,且依赖数组带 `pinned`(少了它监听永远挂不上 / 挂上不摘)。
|
|
716
|
-
*/
|
|
717
|
-
function findPinnedDismissViolations(code: string): string[] {
|
|
718
|
-
code = normalizeEol(code);
|
|
719
|
-
const violations: string[] = [];
|
|
720
|
-
const start = code.indexOf('if (!pinned) return');
|
|
721
|
-
if (start < 0) {
|
|
722
|
-
violations.push('找不到「仅固定态生效」的外部按下关闭效应(if (!pinned) return)');
|
|
723
|
-
return violations;
|
|
724
|
-
}
|
|
725
|
-
const depsStart = code.indexOf('\n }, [', start);
|
|
726
|
-
if (depsStart < 0) {
|
|
727
|
-
violations.push('找不到该效应的依赖数组(守卫需同步更新)');
|
|
728
|
-
return violations;
|
|
729
|
-
}
|
|
730
|
-
const depsEnd = code.indexOf('\n', depsStart + 1);
|
|
731
|
-
const block = code.slice(start, depsEnd < 0 ? code.length : depsEnd);
|
|
732
|
-
if (!/document\.addEventListener\('mousedown',\s*\w+,\s*true\)/.test(block)) {
|
|
733
|
-
violations.push("必须捕获阶段监听 document 的 'mousedown'(冒泡阶段会被弹窗/面板内的局部 handler 抢先)");
|
|
734
|
-
}
|
|
735
|
-
if (!/document\.removeEventListener\('mousedown',\s*\w+,\s*true\)/.test(block)) {
|
|
736
|
-
violations.push('卸载时必须移除 mousedown 监听(依赖变化后残留 = 监听泄漏)');
|
|
737
|
-
}
|
|
738
|
-
if (!/btn\.contains\(event\.target\)/.test(block)) {
|
|
739
|
-
violations.push('触发按钮自身的按下必须放行(const btn = btnRef.current + btn.contains(event.target))');
|
|
740
|
-
}
|
|
741
|
-
if (!/event\.target instanceof Node/.test(block)) {
|
|
742
|
-
violations.push('contains 之前必须先确认 event.target 是 Node(target 可能是文本节点 / 跨文档节点)');
|
|
743
|
-
}
|
|
744
|
-
if (!/(^|\s)close\(\)/.test(block)) {
|
|
745
|
-
violations.push('外部按下必须调用 close()(同时清掉 pinned 与 open 两个状态)');
|
|
746
|
-
}
|
|
747
|
-
if (!/\}, \[pinned, close\]\)/.test(block)) {
|
|
748
|
-
violations.push('依赖数组必须是 [pinned, close](少了 pinned 就永远不挂监听)');
|
|
749
|
-
}
|
|
750
|
-
return violations;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
/** 负向自检的改写:锚点必须命中(否则守卫已与源码脱节,必须同步更新而不是静默绿灯)。 */
|
|
754
|
-
function mutate(code: string, from: string, to: string): string {
|
|
755
|
-
assert.ok(code.includes(from), '负向自检锚点未命中(源码改写后需同步守卫):' + from);
|
|
756
|
-
return code.replace(from, to);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
test('t10 固定态下点击任意位置取消固定(用户反馈 2026-10-04)', () => {
|
|
760
|
-
const hint = readClientSources().find((f) => f.rel === INFO_HINT_FILE);
|
|
761
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
762
|
-
const violations = findPinnedDismissViolations(hint.code);
|
|
763
|
-
assert.deepEqual(violations, [], '固定态必须支持点击任意位置取消固定:\n' + violations.join('\n'));
|
|
764
|
-
|
|
765
|
-
// 负向自检:逐条拆掉都必须变红
|
|
766
|
-
const brokenGate = mutate(hint.code, 'if (!pinned) return', 'if (false) return');
|
|
767
|
-
assert.ok(findPinnedDismissViolations(brokenGate).length >= 1, '去掉固定态门禁必须报红');
|
|
768
|
-
const brokenCapture = mutate(hint.code, "document.addEventListener('mousedown', onMouseDown, true)", "document.addEventListener('mousedown', onMouseDown)");
|
|
769
|
-
assert.ok(findPinnedDismissViolations(brokenCapture).length >= 1, '退化成冒泡阶段必须报红');
|
|
770
|
-
const noCleanup = mutate(hint.code, " return () => { document.removeEventListener('mousedown', onMouseDown, true) }\n", '');
|
|
771
|
-
assert.ok(findPinnedDismissViolations(noCleanup).length >= 1, '缺卸载清理必须报红');
|
|
772
|
-
const noButtonPass = mutate(
|
|
773
|
-
hint.code,
|
|
774
|
-
' if (btn !== null && event.target instanceof Node && btn.contains(event.target)) return\n close()',
|
|
775
|
-
' if (btn !== null && event.target instanceof Node && btn.contains(event.target)) return',
|
|
776
|
-
);
|
|
777
|
-
assert.ok(findPinnedDismissViolations(noButtonPass).length >= 1, '不调用 close() 必须报红');
|
|
778
|
-
const noContains = mutate(hint.code, 'event.target instanceof Node && btn.contains(event.target)', 'false');
|
|
779
|
-
assert.ok(findPinnedDismissViolations(noContains).length >= 1, '按钮自身不放行必须报红');
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
/* ================================================================
|
|
783
|
-
* t11 增补(2026-10-04 用户反馈②):弹窗里 ⓘ 的「自动选中」与气泡偏移
|
|
784
|
-
*
|
|
785
|
-
* 两个现场(同一张真机截图):
|
|
786
|
-
* ① 进入「选择同步分区」弹窗时,标题行 trailing 的 ⓘ 自动亮起蓝框并弹出气泡 —— 用户什么都没点;
|
|
787
|
-
* ② 那个气泡的位置与 ⓘ 脱开,整体向右偏。
|
|
788
|
-
* 根因(DSH/Radix 源码 + 截图逐条对上):
|
|
789
|
-
* ① Radix 的 FocusScope 在弹窗挂载时 focusFirst(...),初始焦点落到容器内第一个可聚焦元素 ——
|
|
790
|
-
* 标题行 trailing 的 ⓘ 正是它;Chrome 对这种程序化聚焦同样命中 :focus-visible。
|
|
791
|
-
* ② 弹窗卡片是 position:fixed(相对浏览器窗口居中),而夹紧基准「宿主画布」= 插件根容器
|
|
792
|
-
* (宿主设置弹窗里靠右的一块)→ 弹窗左半边的 ⓘ 落在画布左缘之外,气泡被夹进画布而与锚点脱开。
|
|
793
|
-
* 三条不可缺:① 聚焦只认用户发起(relatedTarget 在同一 [role=dialog] 内);② 焦点环只在气泡打开时绘;
|
|
794
|
-
* ③ 夹紧矩形并进锚点(只放宽、不收紧)。同样带负向自检。
|
|
795
|
-
* ================================================================ */
|
|
796
|
-
|
|
797
|
-
/** 样式表路径:焦点环是全局样式契约,t11-3 直接读 CSS 而不是组件源码。 */
|
|
798
|
-
const STYLE_FILE = 'src/client/config-manager.module.css';
|
|
799
|
-
|
|
800
|
-
/** t11-1 违规扫描:聚焦通道只认「用户自己把焦点移过来」。 */
|
|
801
|
-
function findFocusGateViolations(code: string): string[] {
|
|
802
|
-
code = normalizeEol(code);
|
|
803
|
-
const violations: string[] = [];
|
|
804
|
-
const start = code.indexOf('const onFocus = (event: ReactFocusEvent<HTMLButtonElement>): void => {');
|
|
805
|
-
if (start < 0) {
|
|
806
|
-
violations.push('onFocus 必须接住聚焦事件(ReactFocusEvent<HTMLButtonElement>)');
|
|
807
|
-
return violations;
|
|
808
|
-
}
|
|
809
|
-
const end = code.indexOf('\n }\n', start);
|
|
810
|
-
const body = code.slice(start, end < 0 ? code.length : end);
|
|
811
|
-
if (!/closest\('\[role="dialog"\]'\)/.test(body)) {
|
|
812
|
-
violations.push("必须用 closest('[role=\"dialog\"]') 找到最近的弹窗(判断这次聚焦是不是弹窗初始焦点)");
|
|
813
|
-
}
|
|
814
|
-
if (!/dialog !== null/.test(body) || !/const from = event\.relatedTarget/.test(body)) {
|
|
815
|
-
violations.push('必须取聚焦前的 relatedTarget(from)作为「从哪儿来」的判据');
|
|
816
|
-
}
|
|
817
|
-
if (!/!\(from instanceof Node\) \|\| !dialog\.contains\(from\)/.test(body) || !/\breturn\b/.test(body)) {
|
|
818
|
-
violations.push('弹窗初始焦点(relatedTarget 在弹窗外 / 为空)必须 early return,不得打开气泡');
|
|
819
|
-
}
|
|
820
|
-
if (!/setOpen\(true\)/.test(body)) violations.push('用户发起的聚焦仍必须打开气泡(不得把聚焦通道整体删掉)');
|
|
821
|
-
if (!/focusRef\.current = true/.test(body)) {
|
|
822
|
-
violations.push('焦点记账(focusRef)必须保留 —— 外部点击 / Esc 的关闭判据要用它');
|
|
823
|
-
}
|
|
824
|
-
return violations;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/** t11-2 违规扫描:气泡夹紧矩形必须并进锚点(只放宽、不收紧),画布仍是原基准。 */
|
|
828
|
-
function findAnchorClampViolations(code: string): string[] {
|
|
829
|
-
code = normalizeEol(code);
|
|
830
|
-
const violations: string[] = [];
|
|
831
|
-
const start = code.indexOf('const anchor = btn.getBoundingClientRect()');
|
|
832
|
-
const end = code.indexOf('setPlacement', start);
|
|
833
|
-
if (start < 0 || end <= start) {
|
|
834
|
-
violations.push('找不到 reposition 的量测段(守卫需同步更新)');
|
|
835
|
-
return violations;
|
|
836
|
-
}
|
|
837
|
-
const body = code.slice(start, end);
|
|
838
|
-
if (!/const bounds = canvasBounds\(\)/.test(body)) violations.push('夹紧基准必须仍是 canvasBounds()(画布 ∩ 窗口)');
|
|
839
|
-
if (!/Math\.min\(bounds\.left, anchor\.left\)/.test(body)) violations.push('夹紧矩形左界必须并进锚点(Math.min(bounds.left, anchor.left))');
|
|
840
|
-
if (!/Math\.max\(bounds\.right, anchor\.right\)/.test(body)) violations.push('夹紧矩形右界必须并进锚点(Math.max(bounds.right, anchor.right))');
|
|
841
|
-
if (!/Math\.min\(bounds\.top, anchor\.top\)/.test(body)) violations.push('夹紧矩形上界必须并进锚点(Math.min(bounds.top, anchor.top))');
|
|
842
|
-
if (!/Math\.max\(bounds\.bottom, anchor\.bottom\)/.test(body)) violations.push('夹紧矩形下界必须并进锚点(Math.max(bounds.bottom, anchor.bottom))');
|
|
843
|
-
return violations;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
/** t11-3 违规扫描:ⓘ 的 :focus-visible 焦点环必须限定在气泡打开时([data-open])。 */
|
|
847
|
-
function findFocusRingViolations(css: string): string[] {
|
|
848
|
-
css = normalizeEol(css);
|
|
849
|
-
const violations: string[] = [];
|
|
850
|
-
const rules = [...css.matchAll(/^\.infoHintBtn([^{]*):focus-visible\s*\{/gm)];
|
|
851
|
-
if (rules.length === 0) {
|
|
852
|
-
violations.push('找不到 .infoHintBtn 的 :focus-visible 规则(可访问性焦点环被删掉 ≠ 合规)');
|
|
853
|
-
return violations;
|
|
854
|
-
}
|
|
855
|
-
for (const rule of rules) {
|
|
856
|
-
if (!(rule[1] ?? '').includes('[data-open]')) {
|
|
857
|
-
violations.push('焦点环必须限定在 [data-open](否则弹窗挂载的程序化初始焦点会画出「选中」蓝框):' + rule[0]);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
return violations;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
test('t11-1 弹窗初始焦点不得打开 ⓘ 气泡(只认用户发起的聚焦)', () => {
|
|
864
|
-
const hint = readClientSources().find((f) => f.rel === INFO_HINT_FILE);
|
|
865
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
866
|
-
const violations = findFocusGateViolations(hint.code);
|
|
867
|
-
assert.deepEqual(violations, [], '聚焦通道必须只认用户发起的聚焦:\n' + violations.join('\n'));
|
|
868
|
-
const noDialog = mutate(hint.code, "event.currentTarget.closest('[role=\"dialog\"]')", 'null');
|
|
869
|
-
assert.ok(findFocusGateViolations(noDialog).length >= 1, '丢掉弹窗判据(程序化初始焦点照开)必须报红');
|
|
870
|
-
const noRelated = mutate(hint.code, '!dialog.contains(from)', 'false');
|
|
871
|
-
assert.ok(findFocusGateViolations(noRelated).length >= 1, '不比对 relatedTarget 必须报红');
|
|
872
|
-
const noGate = mutate(hint.code, ' if (!(from instanceof Node) || !dialog.contains(from)) return\n', '');
|
|
873
|
-
assert.ok(findFocusGateViolations(noGate).length >= 1, '删掉 early return 必须报红');
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
test('t11-2 气泡夹紧矩形 = 画布 ∪ 锚点(弹窗卡片伸出画布时气泡不脱开 ⓘ)', () => {
|
|
877
|
-
const hint = readClientSources().find((f) => f.rel === INFO_HINT_FILE);
|
|
878
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
879
|
-
const violations = findAnchorClampViolations(hint.code);
|
|
880
|
-
assert.deepEqual(violations, [], '夹紧矩形必须并进锚点:\n' + violations.join('\n'));
|
|
881
|
-
const noLeft = mutate(hint.code, 'Math.min(bounds.left, anchor.left)', 'bounds.left');
|
|
882
|
-
assert.ok(findAnchorClampViolations(noLeft).length >= 1, '左界不并锚点(用户报告的偏移就是这个)必须报红');
|
|
883
|
-
const noBottom = mutate(hint.code, 'Math.max(bounds.bottom, anchor.bottom)', 'bounds.bottom');
|
|
884
|
-
assert.ok(findAnchorClampViolations(noBottom).length >= 1, '下界不并锚点必须报红');
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
test('t11-3 ⓘ 焦点环只在气泡打开时绘制(程序化初始焦点不得画出「选中」蓝框)', () => {
|
|
888
|
-
const css = readStyleSource();
|
|
889
|
-
const violations = findFocusRingViolations(css);
|
|
890
|
-
assert.deepEqual(violations, [], '焦点环必须限定在 [data-open]:\n' + violations.join('\n'));
|
|
891
|
-
const unscoped = mutate(css, '.infoHintBtn[data-open]:focus-visible', '.infoHintBtn:focus-visible');
|
|
892
|
-
assert.ok(findFocusRingViolations(unscoped).length >= 1, '去掉 [data-open] 限定必须报红');
|
|
893
|
-
// 必须连选择器一起改:同款 outline 在别的组件上也有 :focus-visible 规则,
|
|
894
|
-
// 只改 `:focus-visible {` 会命中别处、留下本规则 → 假绿。
|
|
895
|
-
const removed = mutate(
|
|
896
|
-
css,
|
|
897
|
-
'.infoHintBtn[data-open]:focus-visible {\n outline:',
|
|
898
|
-
'.infoHintBtn[data-open]:hover {\n outline:',
|
|
899
|
-
);
|
|
900
|
-
assert.ok(findFocusRingViolations(removed).length >= 1, '删掉焦点环必须报红(不得「删掉即绿灯」)');
|
|
901
|
-
});
|
|
902
|
-
|
|
903
|
-
test('t11-4(issue #70,CRLF 检出):扫描器与锚点必须与换行风格解耦', () => {
|
|
904
|
-
const hint = readClientSources().find((f) => f.rel === INFO_HINT_FILE);
|
|
905
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
906
|
-
// 读取即归一:源码与样式表里不得残留 \r(否则 "\n" 锚点在 Windows 检出 / CI 下全灭)
|
|
907
|
-
assert.ok(!hint.code.includes('\r'), 'readClientSources 必须归一 LF');
|
|
908
|
-
assert.ok(!readStyleSource().includes('\r'), '样式读取必须归一 LF');
|
|
909
|
-
const crlf = hint.code.replace(/\n/g, '\r\n');
|
|
910
|
-
const cssCrlf = readStyleSource().replace(/\n/g, '\r\n');
|
|
911
|
-
assert.deepEqual(findPinnedDismissViolations(crlf), [], 'CRLF 下固定态扫描不得失真');
|
|
912
|
-
assert.deepEqual(findFocusGateViolations(crlf), [], 'CRLF 下聚焦门禁扫描不得失真');
|
|
913
|
-
assert.deepEqual(findAnchorClampViolations(crlf), [], 'CRLF 下夹紧扫描不得失真');
|
|
914
|
-
assert.deepEqual(findFocusRingViolations(cssCrlf), [], 'CRLF 下焦点环扫描不得失真');
|
|
915
|
-
// 负向自检:CRLF 输入下同样必须报红 —— 原实现 code.indexOf('\n }\n') 在 CRLF 下返回 -1,
|
|
916
|
-
// 扫描器会把整段文件当函数体(静默变弱)或直接 assert 失败(硬红),两者都不是守法。
|
|
917
|
-
const lfBroken = hint.code.replace(" return () => { document.removeEventListener('mousedown', onMouseDown, true) }\n", '');
|
|
918
|
-
assert.ok(findPinnedDismissViolations(lfBroken).length >= 1, 'LF 下负向自检必须报红');
|
|
919
|
-
const crlfBroken = crlf.replace(" return () => { document.removeEventListener('mousedown', onMouseDown, true) }\r\n", '');
|
|
920
|
-
assert.ok(findPinnedDismissViolations(crlfBroken).length >= 1, 'CRLF 下负向自检必须报红(issue #70 的静默变弱)');
|
|
921
|
-
const crlfNoGate = crlf.replace(' if (!(from instanceof Node) || !dialog.contains(from)) return\r\n', '');
|
|
922
|
-
assert.ok(findFocusGateViolations(crlfNoGate).length >= 1, 'CRLF 下删掉 early return 必须报红');
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
/* ==================================================================== *
|
|
926
|
-
* t12(2026-11-04 用户反馈 ④):「ⓘ 必须脱离 <label>」的源码级守卫
|
|
927
|
-
*
|
|
928
|
-
* 用户原话:鼠标悬浮**选择框**时会一并触发 ⓘ 的 hover 效果。排查结论(写在
|
|
929
|
-
* common/ui.tsx 的 Field 注释里):<label> 只把「点击」转发给被包裹控件、**不转发 hover**,
|
|
930
|
-
* 所以真正的耦合是——ⓘ 被塞在 label 里,点它等于点了控件(勾选框被顺手切掉 / 下拉被打开),
|
|
931
|
-
* 而它的悬停观感又与控件区域视觉上连成一片。修法两条腿:结构上带 ⓘ 的字段壳不再是 label
|
|
932
|
-
* (t12-1),交互上 ⓘ 的 onClick 先 preventDefault 掐掉 label 激活(t12-2)。
|
|
933
|
-
*
|
|
934
|
-
* 还有一条**必须同时守住**的副作用:脱离 label 后控件就失去了「点标签文字聚焦控件」的免费
|
|
935
|
-
* 关联,无障碍名必须由调用点显式给(aria-label / Select 的 ariaLabel)⇒ t12-3。
|
|
936
|
-
*
|
|
937
|
-
* 已知边界(不修,靠 preventDefault 兜):ContentPicker / SyncSectionPickerDialog 把
|
|
938
|
-
* <InfoHint> 当 **Checkbox 的 label prop** 传进去,而 Checkbox 内部才是 <label>。本守卫只扫
|
|
939
|
-
* 本文件内的字面 <label>,看不到 Checkbox 内部 —— 这不是漏检,是那两处的结构代价:
|
|
940
|
-
* 改 Checkbox 要动公共 API + 破坏 .checkboxRow + .actionRow 相邻选择器。
|
|
941
|
-
* ==================================================================== */
|
|
942
|
-
|
|
943
|
-
/** JSX 标签的结束 `>`(跳过 {} 表达式与引号里的 >;属性里有箭头函数 => 时必备)。 */
|
|
944
|
-
function jsxTagEnd(text: string, at: number): number {
|
|
945
|
-
let depth = 0;
|
|
946
|
-
let quote = '';
|
|
947
|
-
for (let i = at; i < text.length; i++) {
|
|
948
|
-
const ch = text[i] ?? '';
|
|
949
|
-
if (quote !== '') {
|
|
950
|
-
if (ch === quote) quote = '';
|
|
951
|
-
continue;
|
|
952
|
-
}
|
|
953
|
-
if (ch === "'" || ch === '"') {
|
|
954
|
-
quote = ch;
|
|
955
|
-
continue;
|
|
956
|
-
}
|
|
957
|
-
if (ch === '{') depth++;
|
|
958
|
-
else if (ch === '}') depth--;
|
|
959
|
-
else if (ch === '>' && depth === 0) return i;
|
|
960
|
-
}
|
|
961
|
-
return -1;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* 标签配对区间(`<div …>` 与 `</div>`)。
|
|
966
|
-
* 只用于「找字段壳」这类结构判断:别的元素(span/label)不参与,闭合同名元素才配对。
|
|
967
|
-
*/
|
|
968
|
-
function fieldDivBlocks(code: string): Array<{ start: number; end: number }> {
|
|
969
|
-
const re = /<div\b|<\/div>/g;
|
|
970
|
-
const stack: number[] = [];
|
|
971
|
-
const blocks: Array<{ start: number; end: number }> = [];
|
|
972
|
-
let m: RegExpExecArray | null;
|
|
973
|
-
while ((m = re.exec(code)) !== null) {
|
|
974
|
-
if (m[0] === '<div') {
|
|
975
|
-
stack.push(m.index);
|
|
976
|
-
continue;
|
|
977
|
-
}
|
|
978
|
-
const start = stack.pop();
|
|
979
|
-
if (start !== undefined) blocks.push({ start, end: m.index });
|
|
980
|
-
}
|
|
981
|
-
return blocks;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
/**
|
|
985
|
-
* t12-1 扫描:`<InfoHint>` 落在字面 `<label>` 内部的位置(返回 文件:行 的「行」)。
|
|
986
|
-
* 栈式配对,嵌套 label 也算(历史上有 div.field > label.field 的写法)。
|
|
987
|
-
*/
|
|
988
|
-
function findHintInsideLabelViolations(code: string): number[] {
|
|
989
|
-
const re = /<label\b|<\/label>|<InfoHint\b/g;
|
|
990
|
-
const lines: number[] = [];
|
|
991
|
-
let depth = 0;
|
|
992
|
-
let m: RegExpExecArray | null;
|
|
993
|
-
while ((m = re.exec(code)) !== null) {
|
|
994
|
-
if (m[0] === '<label') depth++;
|
|
995
|
-
else if (m[0] === '</label>') depth = Math.max(0, depth - 1);
|
|
996
|
-
else if (depth > 0) lines.push(lineOf(code, m.index));
|
|
997
|
-
}
|
|
998
|
-
return lines;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
test('t12-1 ⓘ 不得再被 <label> 包住(点 ⓘ 会顺手激活它包裹的控件)', () => {
|
|
1002
|
-
const violations = readClientSources().flatMap((file) =>
|
|
1003
|
-
findHintInsideLabelViolations(file.code).map((line) => file.rel + ':' + String(line)),
|
|
1004
|
-
);
|
|
1005
|
-
assert.deepEqual(
|
|
1006
|
-
violations,
|
|
1007
|
-
[],
|
|
1008
|
-
'带 ⓘ 的字段壳必须是 <div className={css.field}>(label 会把点击转发给控件):\n' + violations.join('\n'),
|
|
1009
|
-
);
|
|
1010
|
-
// 合成片段负向自检:不依赖真实文件,规则本身必须能红
|
|
1011
|
-
const nested = "<label className={css.field}><InfoHint text={t('a.b')} /><input /></label>\n";
|
|
1012
|
-
assert.equal(findHintInsideLabelViolations(nested).length, 1, 'label 包住 ⓘ 必须报红');
|
|
1013
|
-
const deepNested = "<div className={css.field}><label className={css.field}>\n <InfoHint text={t('a.b')} />\n</label></div>\n";
|
|
1014
|
-
assert.equal(findHintInsideLabelViolations(deepNested).length, 1, '嵌套 label 里的 ⓘ 同样必须报红');
|
|
1015
|
-
const fixed = "<div className={css.field}><InfoHint text={t('a.b')} /><input aria-label={t('a.b')} /></div>\n";
|
|
1016
|
-
assert.deepEqual(findHintInsideLabelViolations(fixed), [], '改后的形态不得报红');
|
|
1017
|
-
});
|
|
1018
|
-
|
|
1019
|
-
/**
|
|
1020
|
-
* t12-2 扫描:`onClick` 必须收事件参数、并**第一件事就** `event.preventDefault()`。
|
|
1021
|
-
* 为什么是第一件事:label 激活发生在点击的默认行为里,任何提前 return(例如未固定时直接开)
|
|
1022
|
-
* 都拦不住它 —— 顺序写反等于没写。
|
|
1023
|
-
*/
|
|
1024
|
-
function findLabelActivationViolations(code: string): string[] {
|
|
1025
|
-
const violations: string[] = [];
|
|
1026
|
-
const head = /const onClick = \(event: ReactMouseEvent<HTMLButtonElement>\): void => \{\n/.exec(code);
|
|
1027
|
-
if (head === null) {
|
|
1028
|
-
violations.push('onClick 必须接收 event: ReactMouseEvent<HTMLButtonElement>(否则无从 preventDefault 掉 label 激活)');
|
|
1029
|
-
return violations;
|
|
1030
|
-
}
|
|
1031
|
-
const bodyStart = head.index + head[0].length;
|
|
1032
|
-
if (!/^\s*event\.preventDefault\(\)/m.test(code.slice(bodyStart, bodyStart + 120))) {
|
|
1033
|
-
violations.push('onClick 的第一条语句必须是 event.preventDefault()');
|
|
1034
|
-
}
|
|
1035
|
-
const body = code.slice(bodyStart, bodyStart + 600);
|
|
1036
|
-
const preventAt = body.indexOf('event.preventDefault()');
|
|
1037
|
-
const pinAt = body.indexOf('setPinned(');
|
|
1038
|
-
if (preventAt === -1) violations.push('onClick 里找不到 event.preventDefault()');
|
|
1039
|
-
else if (pinAt !== -1 && pinAt < preventAt) violations.push('preventDefault 必须在 setPinned 之前(否则状态先变、默认行为照样发生)');
|
|
1040
|
-
if (!code.includes('type MouseEvent as ReactMouseEvent')) {
|
|
1041
|
-
violations.push('必须 import type { MouseEvent as ReactMouseEvent }(事件参数的类型来源)');
|
|
1042
|
-
}
|
|
1043
|
-
return violations;
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
test('t12-2 ⓘ 的点击必须先 preventDefault(掐掉 label 的激活转发)', () => {
|
|
1047
|
-
const hint = readClientSources().find((f) => f.rel === INFO_HINT_FILE);
|
|
1048
|
-
assert.ok(hint !== undefined, INFO_HINT_FILE + ' 必须存在');
|
|
1049
|
-
const violations = findLabelActivationViolations(hint.code);
|
|
1050
|
-
assert.deepEqual(violations, [], 'label 激活转发必须被掐断:\n' + violations.join('\n'));
|
|
1051
|
-
const noPrevent = mutate(hint.code, ' event.preventDefault()\n', '');
|
|
1052
|
-
assert.ok(findLabelActivationViolations(noPrevent).length >= 1, '删掉 preventDefault(点 ⓘ 会顺手切勾选框)必须报红');
|
|
1053
|
-
const noParam = mutate(hint.code, '(event: ReactMouseEvent<HTMLButtonElement>)', '()');
|
|
1054
|
-
assert.ok(findLabelActivationViolations(noParam).length >= 1, '收不到事件参数必须报红');
|
|
1055
|
-
});
|
|
1056
|
-
|
|
1057
|
-
/** `<label>` 的成对区间(用于「控件是否已被某个 label 关联」的判断)。 */
|
|
1058
|
-
function labelSpanRanges(code: string): Array<{ start: number; end: number }> {
|
|
1059
|
-
const re = /<label\b|<\/label>/g;
|
|
1060
|
-
const stack: number[] = [];
|
|
1061
|
-
const spans: Array<{ start: number; end: number }> = [];
|
|
1062
|
-
let m: RegExpExecArray | null;
|
|
1063
|
-
while ((m = re.exec(code)) !== null) {
|
|
1064
|
-
if (m[0] === '<label') {
|
|
1065
|
-
stack.push(m.index);
|
|
1066
|
-
continue;
|
|
1067
|
-
}
|
|
1068
|
-
const start = stack.pop();
|
|
1069
|
-
if (start !== undefined) spans.push({ start, end: m.index });
|
|
1070
|
-
}
|
|
1071
|
-
return spans;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* t12-3 扫描:`<div className={css.field}>` 里既有 ⓘ 又有控件时,控件必须自带可访问名。
|
|
1076
|
-
* 这正是「脱离 label」的代价:label 包着控件时读屏靠 label 关联,换 div 后只能靠 aria-label。
|
|
1077
|
-
*
|
|
1078
|
-
* 例外:控件自己仍被**内层** `<label>` 包着(SyncRepositoryPicker 的「新建仓库」就是
|
|
1079
|
-
* div.field > groupLabel(带ⓘ) + label.field > input)—— 那种控件有名字,不该报红。
|
|
1080
|
-
*/
|
|
1081
|
-
function findFieldControlNameViolations(code: string): string[] {
|
|
1082
|
-
const violations: string[] = [];
|
|
1083
|
-
const labelSpans = labelSpanRanges(code);
|
|
1084
|
-
for (const block of fieldDivBlocks(code)) {
|
|
1085
|
-
const openEnd = jsxTagEnd(code, block.start);
|
|
1086
|
-
if (openEnd === -1) continue;
|
|
1087
|
-
if (code.slice(block.start, openEnd + 1) !== '<div className={css.field}>') continue;
|
|
1088
|
-
const body = code.slice(block.start, block.end);
|
|
1089
|
-
if (!body.includes('<InfoHint')) continue;
|
|
1090
|
-
const ctl = /<(input|textarea|Select)\b/.exec(body);
|
|
1091
|
-
if (ctl === null) continue; // 纯说明字段(无控件)不适用
|
|
1092
|
-
const at = block.start + ctl.index;
|
|
1093
|
-
if (labelSpans.some((span) => span.start < at && at < span.end)) continue; // 控件仍由内层 label 关联
|
|
1094
|
-
const end = jsxTagEnd(code, at);
|
|
1095
|
-
if (end === -1) continue;
|
|
1096
|
-
const tag = code.slice(at, end + 1);
|
|
1097
|
-
if (!/aria-label=|ariaLabel=/.test(tag)) {
|
|
1098
|
-
violations.push(
|
|
1099
|
-
code.slice(0, at).split('\n').length + ': 控件没有 aria-label/ariaLabel(脱离 label 后读屏拿不到名字):' + tag.replace(/\s+/g, ' ').slice(0, 80),
|
|
1100
|
-
);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
return violations;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
test('t12-3 带 ⓘ 的字段壳里,控件必须自带可访问名(label 关联已让位给 aria-label)', () => {
|
|
1107
|
-
const violations = readClientSources().flatMap((file) =>
|
|
1108
|
-
findFieldControlNameViolations(file.code).map((v) => file.rel + ':' + v),
|
|
1109
|
-
);
|
|
1110
|
-
assert.deepEqual(
|
|
1111
|
-
violations,
|
|
1112
|
-
[],
|
|
1113
|
-
'字段壳改成 div 后,控件必须显式给 aria-label(Select 用 ariaLabel):\n' + violations.join('\n'),
|
|
1114
|
-
);
|
|
1115
|
-
const unnamed = "<div className={css.field}>\n <InfoHint text={t('a.b')} />\n <input value={v} />\n</div>\n";
|
|
1116
|
-
assert.equal(findFieldControlNameViolations(unnamed).length, 1, '无名的控件必须报红');
|
|
1117
|
-
const named = "<div className={css.field}>\n <InfoHint text={t('a.b')} />\n <input aria-label={t('a.b')} />\n</div>\n";
|
|
1118
|
-
assert.deepEqual(findFieldControlNameViolations(named), [], '有 aria-label 不得报红');
|
|
1119
|
-
});
|