@iyowei/rim 0.0.0-stage → 0.0.1-stage

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 (55) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +74 -2
  4. package/README.zh-CN.md +75 -0
  5. package/dist/baseline.d.ts +47 -0
  6. package/dist/bridge-command.d.ts +25 -0
  7. package/dist/bridge.d.ts +18 -0
  8. package/dist/cdp.d.ts +41 -0
  9. package/dist/chrome.d.ts +51 -0
  10. package/dist/config-validate-sections.d.ts +18 -0
  11. package/dist/config-validate.d.ts +4 -0
  12. package/dist/config.d.ts +27 -0
  13. package/dist/doctor.d.ts +15 -0
  14. package/dist/errors.d.ts +10 -0
  15. package/dist/gate-pipeline.d.ts +34 -0
  16. package/dist/gate.d.ts +3 -0
  17. package/dist/html-report.d.ts +14 -0
  18. package/dist/html-scan.d.ts +32 -0
  19. package/dist/http-gate.d.ts +11 -0
  20. package/dist/index.d.ts +33 -0
  21. package/dist/index.js +10234 -0
  22. package/dist/lighthouse-extract.d.ts +20 -0
  23. package/dist/lighthouse-gate.d.ts +35 -0
  24. package/dist/locale.d.ts +14 -0
  25. package/dist/manifest.json +8 -0
  26. package/dist/probe-h2h3.d.ts +39 -0
  27. package/dist/probe-load-adapters.d.ts +38 -0
  28. package/dist/probe-load-builtin.d.ts +16 -0
  29. package/dist/probe-load-h2.d.ts +41 -0
  30. package/dist/probe-load.d.ts +28 -0
  31. package/dist/probe-perf.d.ts +36 -0
  32. package/dist/probe-proto-checks.d.ts +58 -0
  33. package/dist/probe-proto-helpers.d.ts +77 -0
  34. package/dist/probe-proto.d.ts +55 -0
  35. package/dist/probe-quality-adapters.d.ts +42 -0
  36. package/dist/probe-quality-axe.d.ts +57 -0
  37. package/dist/probe-quality-link-eval.d.ts +46 -0
  38. package/dist/probe-quality-links.d.ts +23 -0
  39. package/dist/probe-quality.d.ts +53 -0
  40. package/dist/probe-sec-csp.d.ts +21 -0
  41. package/dist/probe-sec-testssl.d.ts +22 -0
  42. package/dist/probe-sec-tls-eval.d.ts +34 -0
  43. package/dist/probe-sec-tls.d.ts +18 -0
  44. package/dist/probe-sec.d.ts +42 -0
  45. package/dist/runtime.d.ts +45 -0
  46. package/dist/security-ip.d.ts +42 -0
  47. package/dist/security.d.ts +43 -0
  48. package/dist/smoke-gate.d.ts +14 -0
  49. package/dist/static-server.d.ts +19 -0
  50. package/dist/types-config.d.ts +339 -0
  51. package/dist/types.d.ts +352 -0
  52. package/dist/verdict-lighthouse.d.ts +14 -0
  53. package/dist/verdict.d.ts +21 -0
  54. package/dist/waivers.d.ts +10 -0
  55. package/package.json +66 -4
@@ -0,0 +1,339 @@
1
+ /**
2
+ * `@iyowei/rim` 公共配置、桥接、预算、豁免与单探针配置类型定义 (`types-config.ts`)。
3
+ */
4
+ /** 五大统一探针标识 */
5
+ export type ProbeId = 'proto' | 'sec' | 'perf' | 'quality' | 'load';
6
+ /** 统一探针状态 (PASS | WARN | FAIL | WAIVED | SKIP) */
7
+ export type ProbeStatus = 'PASS' | 'WARN' | 'FAIL' | 'WAIVED' | 'SKIP';
8
+ /** 门禁预设档位: quick (零外依 proto+sec) | ci (proto+sec+perf+可选smoke) | full (全量已就绪探针) */
9
+ export type AuditPreset = 'quick' | 'ci' | 'full';
10
+ /** 浏览器/Lighthouse 设备档位 */
11
+ export type DeviceMode = 'mobile' | 'desktop';
12
+ /** 兼容旧类型别名 */
13
+ export type LighthousePreset = DeviceMode;
14
+ export type GateKind = ProbeId | 'http' | 'lighthouse' | 'smoke';
15
+ export type GateCheckStatus = 'pass' | 'warn' | 'fail' | 'waived' | 'skip' | 'disabled';
16
+ export type BridgeType = 'auto' | 'static' | 'module' | 'command';
17
+ export type ModuleExportKind = 'auto' | 'fetch' | 'factory' | 'server';
18
+ export interface BridgeConfig {
19
+ readonly type: BridgeType;
20
+ /** 静态目录路径 (type='static' 或 auto 回退) */
21
+ readonly dir?: string;
22
+ /** 可选站点子路径前缀 (如 '/bridge') */
23
+ readonly basePath?: string;
24
+ /** 静态服务是否对非资源路径回退 index.html (默认 true) */
25
+ readonly spaFallback?: boolean;
26
+ /** 进程内模块桥接文件路径 (type='module') */
27
+ readonly entry?: string;
28
+ /** 模块导出名 (如 'createBlankApp' / 'handleRequest') */
29
+ readonly export?: string;
30
+ /** 导出形态 ('auto' | 'fetch' | 'factory' | 'server') */
31
+ readonly exportKind?: ModuleExportKind;
32
+ /** 模块启动前钩子导出名 (如 'clearServerCaches') */
33
+ readonly beforeStart?: string;
34
+ /** 启动前必须存在的相对产物文件列表 (如 ['dist/web/index.html']) */
35
+ readonly requireFiles?: readonly string[];
36
+ /** 缺少前置构建产物时的明确修复提示 (如 "请先执行 bun run build") */
37
+ readonly requireFilesHint?: string;
38
+ /** 外部命令桥接参数数组 (type='command', 零 shell) */
39
+ readonly argv?: readonly string[];
40
+ /** 外部命令桥接单串 (无 shell 元字符时自动分词) */
41
+ readonly command?: string;
42
+ /** 外部命令就绪探测路径 (默认 '/') */
43
+ readonly readyPath?: string;
44
+ /** 外部命令就绪等待上限毫秒数 (默认 15_000) */
45
+ readonly readyTimeoutMs?: number;
46
+ /** 附加环境变量 (仅注入命令桥接子进程) */
47
+ readonly env?: Readonly<Record<string, string>>;
48
+ }
49
+ /** `.rim.json` 标准本地生产等效服务配置 */
50
+ export interface LocalServerConfig {
51
+ readonly requireFiles?: readonly string[];
52
+ readonly requireFilesHint?: string;
53
+ readonly startCommand?: readonly string[];
54
+ readonly port?: number | 'auto';
55
+ readonly healthPath?: string;
56
+ readonly startupTimeoutMs?: number;
57
+ readonly env?: Readonly<Record<string, string>>;
58
+ readonly bridge?: BridgeConfig;
59
+ }
60
+ export interface LighthouseThresholds {
61
+ readonly performance: number;
62
+ readonly accessibility: number;
63
+ readonly bestPractices: number;
64
+ readonly seo: number;
65
+ readonly maxLongTasks: number;
66
+ readonly maxTbtMs?: number;
67
+ readonly maxCls?: number;
68
+ }
69
+ export interface LighthouseBudgetConfig extends Partial<LighthouseThresholds> {
70
+ readonly minPerf?: number;
71
+ readonly minA11y?: number;
72
+ readonly minBp?: number;
73
+ readonly minSeo?: number;
74
+ }
75
+ export interface BudgetsConfig {
76
+ readonly htmlBrBytes?: number;
77
+ readonly totalCriticalBrBytes?: number;
78
+ readonly lighthouse?: LighthouseBudgetConfig;
79
+ }
80
+ /** 显式规则豁免声明 (报告中标 WAIVED 并展示理由) */
81
+ export interface WaiverRule {
82
+ readonly ruleId: string;
83
+ readonly reason: string;
84
+ readonly probe?: ProbeId;
85
+ }
86
+ export interface HttpRouteCheck {
87
+ readonly path: string;
88
+ readonly method?: 'GET' | 'HEAD';
89
+ readonly expectStatus?: number;
90
+ readonly expectEncoding?: 'br' | 'gzip' | 'any';
91
+ readonly requireHeaders?: readonly string[];
92
+ readonly maxTtfbMs?: number;
93
+ }
94
+ export interface HttpGateConfig {
95
+ readonly enabled?: boolean;
96
+ readonly maxTtfbMs?: number;
97
+ readonly requireEncoding?: 'br' | 'gzip' | 'any';
98
+ readonly requireSecurityHeaders?: readonly string[];
99
+ readonly warnSecurityHeaders?: readonly string[];
100
+ readonly routes?: readonly HttpRouteCheck[];
101
+ }
102
+ export interface ProtoProbeConfig {
103
+ readonly enabled?: boolean;
104
+ readonly check304?: boolean;
105
+ readonly checkPreloads?: boolean;
106
+ readonly checkH2H3?: boolean;
107
+ readonly h2h3TimeoutMs?: number;
108
+ }
109
+ export interface SecProbeConfig {
110
+ readonly enabled?: boolean;
111
+ readonly checkCsp?: boolean;
112
+ readonly checkTls?: boolean;
113
+ readonly tlsMinCertDays?: number;
114
+ readonly requireHeaders?: readonly string[];
115
+ readonly warnHeaders?: readonly string[];
116
+ readonly forbidHeaders?: readonly string[];
117
+ readonly runTestssl?: boolean;
118
+ }
119
+ export interface QualityProbeConfig {
120
+ readonly enabled?: boolean;
121
+ readonly checkLinks?: boolean;
122
+ readonly checkExternalLinks?: boolean;
123
+ readonly checkAnchors?: boolean;
124
+ readonly checkAxe?: boolean;
125
+ readonly axeTags?: readonly string[];
126
+ readonly maxLinks?: number;
127
+ readonly maxExternalLinks?: number;
128
+ readonly runAxe?: boolean;
129
+ readonly runLychee?: boolean;
130
+ readonly smoke?: SmokeGateConfig;
131
+ }
132
+ export interface LoadProbeConfig {
133
+ readonly enabled?: boolean;
134
+ readonly concurrency?: number;
135
+ readonly durationMs?: number;
136
+ readonly maxRequests?: number;
137
+ readonly runner?: 'builtin' | 'auto' | 'h2load' | 'oha';
138
+ }
139
+ export type SmokeStep = {
140
+ readonly action: 'viewport';
141
+ readonly width: number;
142
+ readonly height: number;
143
+ readonly mobile?: boolean;
144
+ readonly deviceScaleFactor?: number;
145
+ readonly label?: string;
146
+ } | {
147
+ readonly action: 'navigate';
148
+ readonly path: string;
149
+ readonly label?: string;
150
+ } | {
151
+ readonly action: 'waitUntil';
152
+ readonly expr: string;
153
+ readonly timeoutMs?: number;
154
+ readonly label?: string;
155
+ } | {
156
+ readonly action: 'click';
157
+ readonly selector: string;
158
+ readonly label?: string;
159
+ } | {
160
+ readonly action: 'setValue';
161
+ readonly selector: string;
162
+ readonly value: string;
163
+ readonly event?: 'input' | 'change';
164
+ readonly label?: string;
165
+ } | {
166
+ readonly action: 'assert';
167
+ readonly expr: string;
168
+ readonly expected?: string | number | boolean;
169
+ readonly includes?: string;
170
+ readonly label?: string;
171
+ };
172
+ export interface SmokeGateConfig {
173
+ readonly enabled?: boolean;
174
+ readonly viewport?: {
175
+ readonly width: number;
176
+ readonly height: number;
177
+ readonly mobile?: boolean;
178
+ };
179
+ readonly waitReadyTimeoutMs?: number;
180
+ readonly failOnConsoleError?: boolean;
181
+ readonly failOnPageError?: boolean;
182
+ readonly failOnRequestError?: boolean;
183
+ readonly ignoreRequestPaths?: readonly string[];
184
+ readonly steps?: readonly SmokeStep[];
185
+ readonly argv?: readonly string[];
186
+ }
187
+ export interface RimConfig {
188
+ readonly schemaVersion?: 1;
189
+ readonly name?: string;
190
+ readonly baseUrl?: string;
191
+ readonly url?: string;
192
+ readonly routes?: readonly string[];
193
+ readonly path?: string;
194
+ readonly preset?: AuditPreset;
195
+ readonly devices?: readonly DeviceMode[];
196
+ readonly presets?: readonly LighthousePreset[];
197
+ readonly local?: LocalServerConfig;
198
+ readonly bridge?: BridgeConfig;
199
+ readonly budgets?: BudgetsConfig;
200
+ readonly thresholds?: Partial<LighthouseThresholds>;
201
+ readonly waivers?: readonly WaiverRule[];
202
+ readonly proto?: ProtoProbeConfig;
203
+ readonly sec?: SecProbeConfig;
204
+ readonly quality?: QualityProbeConfig;
205
+ readonly load?: LoadProbeConfig;
206
+ readonly http?: HttpGateConfig;
207
+ readonly smoke?: SmokeGateConfig;
208
+ readonly outDir?: string;
209
+ readonly writeReports?: boolean;
210
+ readonly coldGpu?: boolean;
211
+ readonly cpuSlowdown?: number | null;
212
+ readonly strict?: boolean;
213
+ readonly strictAllowSkip?: readonly string[];
214
+ readonly timeoutMs?: number;
215
+ }
216
+ export type TlsProtocolProbeState = 'offered' | 'rejected' | 'client-unsupported' | 'error';
217
+ export interface TlsCertSummary {
218
+ readonly subject: string;
219
+ readonly issuer: string;
220
+ readonly validFrom: string;
221
+ readonly validTo: string;
222
+ readonly daysRemaining: number | null;
223
+ readonly notYetValid: boolean;
224
+ readonly authorized: boolean;
225
+ readonly authorizationError: string | null;
226
+ readonly keyType: 'RSA' | 'EC' | null;
227
+ readonly keyBits: number | null;
228
+ readonly curve: string | null;
229
+ readonly sanCount: number;
230
+ readonly fingerprint256: string | null;
231
+ readonly chainLength: number;
232
+ }
233
+ export interface BuiltinTlsAuditResult {
234
+ readonly status: 'PASS' | 'WARN' | 'FAIL' | 'SKIP';
235
+ readonly engine: 'node:tls';
236
+ readonly host: string;
237
+ readonly port: number;
238
+ readonly pinnedIp?: string;
239
+ readonly negotiatedProtocol?: string | null;
240
+ readonly negotiatedCipher?: string | null;
241
+ readonly alpnProtocol?: string | null;
242
+ readonly tls13: TlsProtocolProbeState;
243
+ readonly tls12: TlsProtocolProbeState;
244
+ readonly tls11: TlsProtocolProbeState;
245
+ readonly tls10: TlsProtocolProbeState;
246
+ readonly cert?: TlsCertSummary;
247
+ readonly weakCipher?: boolean;
248
+ readonly weakKey?: boolean;
249
+ readonly vulnerableItems: readonly string[];
250
+ readonly warnings: readonly string[];
251
+ readonly durationMs: number;
252
+ readonly reason?: string;
253
+ }
254
+ export interface AxeViolationSummary {
255
+ readonly id: string;
256
+ readonly impact: 'critical' | 'serious' | 'moderate' | 'minor' | 'unknown';
257
+ readonly help: string;
258
+ readonly helpUrl?: string;
259
+ readonly nodeCount: number;
260
+ readonly sampleTargets: readonly string[];
261
+ }
262
+ export interface BuiltinAxeAuditResult {
263
+ readonly status: 'PASS' | 'WARN' | 'FAIL' | 'SKIP';
264
+ readonly engine: 'bundled-axe-core' | 'external-axe';
265
+ readonly axeVersion?: string | null;
266
+ readonly violationCount: number;
267
+ readonly incompleteCount: number;
268
+ readonly passCount: number;
269
+ readonly violations: readonly AxeViolationSummary[];
270
+ readonly durationMs: number;
271
+ readonly binPath?: string;
272
+ readonly reason?: string;
273
+ }
274
+ export interface DoctorBuiltinCapability {
275
+ readonly engine: string;
276
+ readonly available: boolean;
277
+ readonly version?: string | null;
278
+ readonly detail: string;
279
+ }
280
+ export interface DoctorAdapterStatus {
281
+ readonly name: string;
282
+ readonly available: boolean;
283
+ readonly path: string | null;
284
+ readonly version: string | null;
285
+ readonly status: 'ready' | 'missing';
286
+ readonly installHint: string;
287
+ readonly builtinFallback?: string;
288
+ }
289
+ export interface RimRuntimeInfo {
290
+ readonly name: 'bun' | 'node';
291
+ readonly version: string;
292
+ readonly platform: NodeJS.Platform;
293
+ readonly arch: string;
294
+ }
295
+ export interface RimDoctorReport {
296
+ readonly runtime: RimRuntimeInfo;
297
+ readonly lighthouse: {
298
+ readonly available: boolean;
299
+ readonly version: string | null;
300
+ readonly resolvedPath: string | null;
301
+ readonly error?: string;
302
+ };
303
+ readonly axeCore: {
304
+ readonly available: boolean;
305
+ readonly version: string | null;
306
+ readonly resolvedPath: string | null;
307
+ readonly error?: string;
308
+ };
309
+ readonly builtins: {
310
+ readonly tls: DoctorBuiltinCapability;
311
+ readonly load: DoctorBuiltinCapability;
312
+ readonly links: DoctorBuiltinCapability;
313
+ readonly axe: DoctorBuiltinCapability;
314
+ };
315
+ readonly chrome: {
316
+ readonly available: boolean;
317
+ readonly path: string | null;
318
+ readonly version: string | null;
319
+ readonly source: 'option' | 'env' | 'standard' | 'path' | 'none';
320
+ readonly installHint?: string;
321
+ };
322
+ readonly adapters: {
323
+ readonly testssl: DoctorAdapterStatus;
324
+ readonly h2load: DoctorAdapterStatus;
325
+ readonly oha: DoctorAdapterStatus;
326
+ readonly lychee: DoctorAdapterStatus;
327
+ readonly axe: DoctorAdapterStatus;
328
+ };
329
+ readonly config: {
330
+ readonly path: string | null;
331
+ readonly valid: boolean;
332
+ readonly error?: string;
333
+ };
334
+ readonly defaultBridge: {
335
+ readonly detected: boolean;
336
+ readonly mode: 'url' | 'static' | 'module' | 'command' | 'none';
337
+ readonly detail: string;
338
+ };
339
+ }
@@ -0,0 +1,352 @@
1
+ /**
2
+ * `@iyowei/rim` 运行时报告、五大探针结果、基线对比、体检与可注入依赖类型契约 (`types.ts`)。
3
+ */
4
+ import type { RimLocale } from './locale.js';
5
+ import type { AuditPreset, BuiltinAxeAuditResult, BuiltinTlsAuditResult, DeviceMode, GateCheckStatus, GateKind, LighthousePreset, LighthouseThresholds, ProbeId, ProbeStatus, RimDoctorReport, RimRuntimeInfo, SmokeGateConfig, SmokeStep } from './types-config.js';
6
+ export type { AuditPreset, AxeViolationSummary, BridgeConfig, BridgeType, BudgetsConfig, BuiltinAxeAuditResult, BuiltinTlsAuditResult, DeviceMode, DoctorAdapterStatus, DoctorBuiltinCapability, GateCheckStatus, GateKind, HttpGateConfig, HttpRouteCheck, LighthouseBudgetConfig, LighthousePreset, LighthouseThresholds, LoadProbeConfig, LocalServerConfig, ModuleExportKind, ProbeId, ProbeStatus, ProtoProbeConfig, QualityProbeConfig, SecProbeConfig, RimConfig, RimDoctorReport, RimRuntimeInfo, SmokeGateConfig, SmokeStep, TlsCertSummary, TlsProtocolProbeState, WaiverRule, } from './types-config.js';
7
+ export interface RunningTarget {
8
+ readonly url: string;
9
+ readonly origin: string;
10
+ readonly mode: 'url' | 'static' | 'module' | 'command';
11
+ readonly detail: string;
12
+ readonly isLocal: boolean;
13
+ readonly stop: () => Promise<void>;
14
+ }
15
+ /** 统一探针发现项 */
16
+ export interface ProbeFinding {
17
+ readonly id: string;
18
+ readonly probe: ProbeId;
19
+ readonly status: ProbeStatus;
20
+ readonly title: string;
21
+ readonly detail?: string;
22
+ readonly value?: string | number | null;
23
+ readonly threshold?: string | number;
24
+ readonly waiverReason?: string;
25
+ readonly route?: string;
26
+ readonly device?: DeviceMode;
27
+ }
28
+ /** 五大探针统一返回载荷 (`id / status / durationMs / metrics / findings[] / evidence`) */
29
+ export interface ProbeResult {
30
+ readonly id: ProbeId;
31
+ readonly status: ProbeStatus;
32
+ readonly durationMs: number;
33
+ readonly metrics: Readonly<Record<string, unknown>>;
34
+ readonly findings: readonly ProbeFinding[];
35
+ readonly evidence: Readonly<Record<string, unknown>>;
36
+ readonly reason?: string;
37
+ }
38
+ export interface HttpRouteProbeResult {
39
+ readonly url: string;
40
+ readonly path: string;
41
+ readonly method: 'GET' | 'HEAD';
42
+ readonly status: number;
43
+ readonly ttfbMs: number;
44
+ readonly contentEncoding: string | null;
45
+ readonly headers: Readonly<Record<string, string>>;
46
+ readonly missingRequiredHeaders: readonly string[];
47
+ readonly missingWarnHeaders: readonly string[];
48
+ readonly passed: boolean;
49
+ readonly failureReason?: string;
50
+ }
51
+ export interface HttpGateResult {
52
+ readonly status: GateCheckStatus;
53
+ readonly routes: readonly HttpRouteProbeResult[];
54
+ readonly elapsedMs: number;
55
+ readonly reason?: string;
56
+ }
57
+ export interface LighthouseLongTask {
58
+ readonly url: string;
59
+ readonly startMs: number;
60
+ readonly durationMs: number;
61
+ }
62
+ export interface LighthouseMainThreadItem {
63
+ readonly groupLabel: string;
64
+ readonly durationMs: number;
65
+ }
66
+ export interface LighthouseBootupItem {
67
+ readonly url: string;
68
+ readonly totalMs: number;
69
+ readonly scriptingMs: number;
70
+ }
71
+ export interface LighthouseFinding {
72
+ readonly id: string;
73
+ readonly title: string;
74
+ readonly score: number | null;
75
+ readonly displayValue: string;
76
+ readonly waived?: boolean;
77
+ readonly waiverReason?: string;
78
+ }
79
+ export interface LighthouseMetrics {
80
+ readonly fcp: string;
81
+ readonly lcp: string;
82
+ readonly tbt: string;
83
+ readonly tbtMs: number | null;
84
+ readonly cls: string;
85
+ readonly clsValue: number | null;
86
+ readonly si: string;
87
+ readonly ttfb: string;
88
+ readonly ttfbMs: number | null;
89
+ }
90
+ export interface LighthousePresetSummary {
91
+ readonly preset: LighthousePreset;
92
+ readonly route?: string;
93
+ readonly url?: string;
94
+ readonly scores: Readonly<Record<string, number | null>>;
95
+ readonly metrics: LighthouseMetrics;
96
+ readonly longTasks: readonly LighthouseLongTask[];
97
+ readonly longTasksAuditPresent: boolean;
98
+ readonly mainThreadTop: readonly LighthouseMainThreadItem[];
99
+ readonly bootupTop: readonly LighthouseBootupItem[];
100
+ readonly findings: readonly LighthouseFinding[];
101
+ readonly runtimeError?: {
102
+ readonly code?: string;
103
+ readonly message: string;
104
+ };
105
+ readonly htmlPath?: string;
106
+ readonly jsonPath?: string;
107
+ readonly elapsedMs: number;
108
+ }
109
+ /** 预留给 sitespeed.io / Browsertime 等扩展性能引擎的统一适配器接口 */
110
+ export interface PerfAdapterInput {
111
+ readonly url: string;
112
+ readonly route: string;
113
+ readonly device: DeviceMode;
114
+ readonly chromePath: string;
115
+ readonly coldGpu: boolean;
116
+ readonly cpuSlowdown: number | null;
117
+ readonly outDir: string;
118
+ readonly writeReports: boolean;
119
+ readonly timeoutMs: number;
120
+ readonly locale: RimLocale;
121
+ readonly signal?: AbortSignal;
122
+ }
123
+ export interface PerfAdapterOutput {
124
+ readonly summary: LighthousePresetSummary;
125
+ readonly extraMetrics?: Readonly<Record<string, unknown>>;
126
+ }
127
+ export interface PerfRunnerAdapter {
128
+ readonly name: string;
129
+ readonly run: (input: PerfAdapterInput) => Promise<PerfAdapterOutput>;
130
+ }
131
+ export interface SmokeStepResult {
132
+ readonly index: number;
133
+ readonly action: SmokeStep['action'];
134
+ readonly label: string;
135
+ readonly passed: boolean;
136
+ readonly elapsedMs: number;
137
+ readonly error?: string;
138
+ }
139
+ export interface SmokeFailedRequest {
140
+ readonly url: string;
141
+ readonly status: number;
142
+ readonly reason: string;
143
+ }
144
+ export interface SmokeGateResult {
145
+ readonly status: GateCheckStatus;
146
+ readonly mode: 'cdp' | 'command' | 'disabled';
147
+ readonly finalUrl?: string;
148
+ readonly pageExceptions: readonly string[];
149
+ readonly consoleErrors: readonly string[];
150
+ readonly failedRequests: readonly SmokeFailedRequest[];
151
+ readonly steps: readonly SmokeStepResult[];
152
+ readonly elapsedMs: number;
153
+ readonly reason?: string;
154
+ }
155
+ export interface GateCheckItem {
156
+ readonly id: string;
157
+ readonly gate: GateKind;
158
+ readonly status: GateCheckStatus;
159
+ readonly code?: string;
160
+ readonly message: string;
161
+ readonly waiverReason?: string;
162
+ }
163
+ export interface GateVerdict {
164
+ readonly passed: boolean;
165
+ readonly strict: boolean;
166
+ readonly checks: readonly GateCheckItem[];
167
+ readonly failures: readonly GateCheckItem[];
168
+ readonly warnings: readonly GateCheckItem[];
169
+ readonly waived: readonly GateCheckItem[];
170
+ readonly skipped: readonly GateCheckItem[];
171
+ readonly disabled: readonly GateCheckItem[];
172
+ readonly executedCount: number;
173
+ }
174
+ /** 历史水位线单条 JSONL 记录 */
175
+ export interface BaselineDeviceMetrics {
176
+ readonly performance: number | null;
177
+ readonly accessibility: number | null;
178
+ readonly bestPractices: number | null;
179
+ readonly seo: number | null;
180
+ readonly longTasks: number;
181
+ readonly tbtMs: number | null;
182
+ readonly cls: number | null;
183
+ }
184
+ export interface BaselineEntry {
185
+ readonly schemaVersion: 1;
186
+ readonly timestamp: string;
187
+ readonly targetUrl: string;
188
+ readonly host: string;
189
+ readonly preset: AuditPreset;
190
+ readonly passed: boolean;
191
+ readonly metrics: {
192
+ readonly htmlBrBytes?: number | null;
193
+ readonly totalCriticalBrBytes?: number | null;
194
+ readonly ttfbMs?: number | null;
195
+ readonly mobile?: BaselineDeviceMetrics;
196
+ readonly desktop?: BaselineDeviceMetrics;
197
+ readonly secWarnings?: number;
198
+ readonly secFailures?: number;
199
+ readonly loadRps?: number | null;
200
+ readonly loadP95Ms?: number | null;
201
+ };
202
+ }
203
+ export interface BaselineDeltaItem {
204
+ readonly metric: string;
205
+ readonly before: number | null;
206
+ readonly after: number | null;
207
+ readonly delta: number | null;
208
+ readonly unit: string;
209
+ readonly direction: 'improved' | 'regressed' | 'unchanged';
210
+ }
211
+ export interface BaselineDiffResult {
212
+ readonly host: string;
213
+ readonly previousTimestamp: string | null;
214
+ readonly currentTimestamp: string;
215
+ readonly deltas: readonly BaselineDeltaItem[];
216
+ readonly regressedCount: number;
217
+ readonly improvedCount: number;
218
+ }
219
+ export interface RimProgressEvent {
220
+ readonly phase: 'bridge' | 'proto' | 'sec' | 'http' | 'chrome' | 'perf' | 'lighthouse' | 'quality' | 'smoke' | 'load' | 'baseline' | 'html' | 'done';
221
+ readonly detail: string;
222
+ }
223
+ export interface RunRimOptions {
224
+ readonly cwd?: string;
225
+ readonly configPath?: string;
226
+ readonly url?: string;
227
+ readonly local?: boolean;
228
+ readonly path?: string;
229
+ readonly paths?: readonly string[];
230
+ readonly serveDir?: string;
231
+ readonly bridgeModule?: string;
232
+ readonly startCommand?: string;
233
+ readonly preset?: AuditPreset;
234
+ readonly devices?: readonly DeviceMode[];
235
+ readonly presets?: readonly LighthousePreset[];
236
+ readonly only?: readonly GateKind[];
237
+ readonly skip?: readonly GateKind[];
238
+ readonly strict?: boolean;
239
+ readonly strictAllowSkip?: readonly string[];
240
+ readonly minPerf?: number;
241
+ readonly minA11y?: number;
242
+ readonly minBp?: number;
243
+ readonly minSeo?: number;
244
+ readonly maxLongTasks?: number;
245
+ readonly maxTbtMs?: number;
246
+ readonly maxCls?: number;
247
+ readonly cpuSlowdown?: number | null;
248
+ readonly coldGpu?: boolean;
249
+ readonly outDir?: string;
250
+ readonly writeReports?: boolean;
251
+ readonly htmlReportPath?: string;
252
+ readonly saveBaseline?: boolean;
253
+ readonly diffBaseline?: boolean;
254
+ readonly baselineCacheDir?: string;
255
+ readonly allowLoad?: boolean;
256
+ readonly chromePath?: string;
257
+ readonly timeoutMs?: number;
258
+ readonly locale?: RimLocale;
259
+ readonly signal?: AbortSignal;
260
+ readonly onProgress?: (event: RimProgressEvent) => void;
261
+ }
262
+ export interface RimReport {
263
+ readonly targetUrl: string;
264
+ readonly routes: readonly string[];
265
+ readonly preset: AuditPreset;
266
+ readonly devices: readonly DeviceMode[];
267
+ readonly bridge: {
268
+ readonly mode: RunningTarget['mode'];
269
+ readonly detail: string;
270
+ };
271
+ readonly configPath: string | null;
272
+ readonly runtime: RimRuntimeInfo;
273
+ readonly strict: boolean;
274
+ readonly passed: boolean;
275
+ readonly thresholds: LighthouseThresholds;
276
+ readonly probes: readonly ProbeResult[];
277
+ readonly disabledProbes: readonly ProbeId[];
278
+ readonly http: HttpGateResult;
279
+ readonly lighthouse: {
280
+ readonly status: GateCheckStatus;
281
+ readonly summaries: readonly LighthousePresetSummary[];
282
+ readonly reason?: string;
283
+ };
284
+ readonly smoke: SmokeGateResult;
285
+ readonly verdict: GateVerdict;
286
+ readonly htmlReportPath?: string;
287
+ readonly baselineSavedPath?: string;
288
+ readonly baselineDiff?: BaselineDiffResult;
289
+ readonly elapsedMs: number;
290
+ }
291
+ export interface LighthouseRunnerInput {
292
+ readonly url: string;
293
+ readonly port: number;
294
+ readonly preset: LighthousePreset;
295
+ readonly locale: RimLocale;
296
+ readonly cpuSlowdown: number | null;
297
+ readonly writeReports: boolean;
298
+ readonly signal?: AbortSignal;
299
+ }
300
+ export interface LighthouseRunnerOutput {
301
+ readonly lhr: Record<string, unknown>;
302
+ readonly htmlReport?: string;
303
+ readonly jsonReport?: string;
304
+ }
305
+ export interface ChromeSession {
306
+ readonly port: number;
307
+ readonly chromePath: string;
308
+ readonly cleanup: () => Promise<void>;
309
+ }
310
+ export interface RimDeps {
311
+ readonly fetchFn?: typeof fetch;
312
+ readonly resolveChrome?: (explicitPath?: string) => {
313
+ path: string | null;
314
+ source: RimDoctorReport['chrome']['source'];
315
+ };
316
+ readonly launchChromeFn?: (options: {
317
+ chromePath: string;
318
+ coldGpu: boolean;
319
+ timeoutMs: number;
320
+ locale: RimLocale;
321
+ extraFlags?: readonly string[];
322
+ signal?: AbortSignal;
323
+ }) => Promise<ChromeSession>;
324
+ readonly lighthouseRunner?: (input: LighthouseRunnerInput) => Promise<LighthouseRunnerOutput>;
325
+ readonly perfAdapter?: PerfRunnerAdapter;
326
+ readonly runSmokeFn?: (input: {
327
+ targetUrl: string;
328
+ chromePath: string;
329
+ config: SmokeGateConfig;
330
+ cwd?: string;
331
+ timeoutMs: number;
332
+ locale: RimLocale;
333
+ signal?: AbortSignal;
334
+ }) => Promise<SmokeGateResult>;
335
+ readonly resolveAdapterBin?: (names: readonly string[]) => string | null;
336
+ readonly probeBinVersion?: (binPath: string, args: readonly string[]) => string | null;
337
+ readonly tlsAuditFn?: (input: {
338
+ targetUrl: string;
339
+ allowLoopback: boolean;
340
+ minCertDays?: number;
341
+ timeoutMs: number;
342
+ locale: RimLocale;
343
+ signal?: AbortSignal;
344
+ }) => Promise<BuiltinTlsAuditResult>;
345
+ readonly axeRunner?: (input: {
346
+ targetUrl: string;
347
+ axeTags?: readonly string[];
348
+ timeoutMs: number;
349
+ locale: RimLocale;
350
+ signal?: AbortSignal;
351
+ }) => Promise<BuiltinAxeAuditResult>;
352
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Lighthouse 细粒度防假绿裁定子模块 (`verdict-lighthouse.ts`)。
3
+ */
4
+ import { type RimLocale } from './locale.js';
5
+ import type { GateCheckItem, GateCheckStatus, LighthousePresetSummary, LighthouseThresholds, WaiverRule } from './types.js';
6
+ /** 将 Lighthouse 各档位评分、长任务、TBT、CLS 与豁免展开为离散门禁检查项 */
7
+ export declare function evaluateLighthouseChecks(input: {
8
+ readonly lighthouseStatus: GateCheckStatus;
9
+ readonly lighthouseReason?: string;
10
+ readonly lighthouseSummaries: readonly LighthousePresetSummary[];
11
+ readonly thresholds: LighthouseThresholds;
12
+ readonly waivers?: readonly WaiverRule[];
13
+ readonly locale: RimLocale;
14
+ }, checks: GateCheckItem[]): void;