baseguard 1.0.5 → 1.0.6

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 (80) hide show
  1. package/dist/ai/gemini-analyzer.d.ts.map +1 -1
  2. package/dist/ai/gemini-analyzer.js +1 -1
  3. package/dist/ai/gemini-analyzer.js.map +1 -1
  4. package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
  5. package/dist/ai/gemini-code-fixer.js +2 -7
  6. package/dist/ai/gemini-code-fixer.js.map +1 -1
  7. package/dist/ai/jules-implementer.d.ts +8 -0
  8. package/dist/ai/jules-implementer.d.ts.map +1 -1
  9. package/dist/ai/jules-implementer.js +115 -17
  10. package/dist/ai/jules-implementer.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/ai/__tests__/gemini-analyzer.test.ts +0 -181
  13. package/src/ai/agentkit-orchestrator.ts +0 -534
  14. package/src/ai/fix-manager.ts +0 -362
  15. package/src/ai/gemini-analyzer.ts +0 -665
  16. package/src/ai/gemini-code-fixer.ts +0 -539
  17. package/src/ai/index.ts +0 -4
  18. package/src/ai/jules-implementer.ts +0 -504
  19. package/src/ai/unified-code-fixer.ts +0 -347
  20. package/src/commands/automation.ts +0 -344
  21. package/src/commands/check.ts +0 -298
  22. package/src/commands/config.ts +0 -584
  23. package/src/commands/fix.ts +0 -269
  24. package/src/commands/index.ts +0 -7
  25. package/src/commands/init.ts +0 -156
  26. package/src/commands/status.ts +0 -307
  27. package/src/core/api-key-manager.ts +0 -298
  28. package/src/core/baseguard.ts +0 -757
  29. package/src/core/baseline-checker.ts +0 -566
  30. package/src/core/cache-manager.ts +0 -272
  31. package/src/core/configuration-recovery.ts +0 -672
  32. package/src/core/configuration.ts +0 -596
  33. package/src/core/debug-logger.ts +0 -590
  34. package/src/core/directory-filter.ts +0 -421
  35. package/src/core/error-handler.ts +0 -518
  36. package/src/core/file-processor.ts +0 -338
  37. package/src/core/gitignore-manager.ts +0 -169
  38. package/src/core/graceful-degradation-manager.ts +0 -596
  39. package/src/core/index.ts +0 -17
  40. package/src/core/lazy-loader.ts +0 -317
  41. package/src/core/logger.ts +0 -0
  42. package/src/core/memory-manager.ts +0 -290
  43. package/src/core/parser-worker.ts +0 -33
  44. package/src/core/startup-optimizer.ts +0 -246
  45. package/src/core/system-error-handler.ts +0 -755
  46. package/src/git/automation-engine.ts +0 -361
  47. package/src/git/github-manager.ts +0 -190
  48. package/src/git/hook-manager.ts +0 -210
  49. package/src/git/index.ts +0 -4
  50. package/src/index.ts +0 -8
  51. package/src/parsers/feature-validator.ts +0 -559
  52. package/src/parsers/index.ts +0 -8
  53. package/src/parsers/parser-manager.ts +0 -418
  54. package/src/parsers/parser.ts +0 -26
  55. package/src/parsers/react-parser-optimized.ts +0 -161
  56. package/src/parsers/react-parser.ts +0 -359
  57. package/src/parsers/svelte-parser.ts +0 -510
  58. package/src/parsers/vanilla-parser.ts +0 -685
  59. package/src/parsers/vue-parser.ts +0 -476
  60. package/src/types/index.ts +0 -96
  61. package/src/ui/components.ts +0 -567
  62. package/src/ui/help.ts +0 -193
  63. package/src/ui/index.ts +0 -4
  64. package/src/ui/prompts.ts +0 -681
  65. package/src/ui/terminal-header.ts +0 -59
  66. package/tests/e2e/baseguard.e2e.test.ts +0 -516
  67. package/tests/e2e/cross-platform.e2e.test.ts +0 -420
  68. package/tests/e2e/git-integration.e2e.test.ts +0 -487
  69. package/tests/fixtures/react-project/package.json +0 -14
  70. package/tests/fixtures/react-project/src/App.css +0 -76
  71. package/tests/fixtures/react-project/src/App.tsx +0 -77
  72. package/tests/fixtures/svelte-project/package.json +0 -11
  73. package/tests/fixtures/svelte-project/src/App.svelte +0 -369
  74. package/tests/fixtures/vanilla-project/index.html +0 -76
  75. package/tests/fixtures/vanilla-project/script.js +0 -331
  76. package/tests/fixtures/vanilla-project/styles.css +0 -359
  77. package/tests/fixtures/vue-project/package.json +0 -12
  78. package/tests/fixtures/vue-project/src/App.vue +0 -216
  79. package/tmp-smoke/.baseguard/backups/config-2026-02-19T12-04-11-067Z-auto.json +0 -30
  80. package/tmp-smoke/src/bad.css +0 -3
@@ -1,566 +0,0 @@
1
- import type { BrowserTarget, Violation, DetectedFeature, CompatibilityResult } from '../types/index.js';
2
- import { LazyLoader } from './lazy-loader.js';
3
- import { MemoryManager } from './memory-manager.js';
4
-
5
- // Comprehensive feature mapping dictionary for ALL web platform features
6
- const FEATURE_ID_MAP: Record<string, string> = {
7
- // CSS Properties
8
- 'container-type': 'container-queries',
9
- 'container-name': 'container-queries',
10
- 'container': 'container-queries',
11
- 'aspect-ratio': 'aspect-ratio',
12
- 'gap': 'grid-gap',
13
- 'row-gap': 'grid-gap',
14
- 'column-gap': 'grid-gap',
15
- 'scroll-behavior': 'scroll-behavior',
16
- 'backdrop-filter': 'backdrop-filter',
17
- 'color-scheme': 'color-scheme',
18
- 'accent-color': 'accent-color',
19
- 'overscroll-behavior': 'overscroll-behavior',
20
- 'scroll-snap-type': 'scroll-snap-type',
21
- 'scroll-snap-align': 'scroll-snap-align',
22
- 'object-fit': 'object-fit',
23
- 'object-position': 'object-position',
24
- 'place-items': 'place-items',
25
- 'place-content': 'place-content',
26
- 'place-self': 'place-self',
27
- 'inset': 'inset',
28
- 'inset-block': 'inset',
29
- 'inset-inline': 'inset',
30
- 'block-size': 'logical-properties',
31
- 'inline-size': 'logical-properties',
32
- 'margin-block': 'logical-properties',
33
- 'margin-inline': 'logical-properties',
34
- 'padding-block': 'logical-properties',
35
- 'padding-inline': 'logical-properties',
36
- 'border-block': 'logical-properties',
37
- 'border-inline': 'logical-properties',
38
-
39
- // CSS Selectors
40
- ':has()': 'has',
41
- ':is()': 'is',
42
- ':where()': 'where',
43
- ':focus-visible': 'focus-visible',
44
- ':focus-within': 'focus-within',
45
- ':target-within': 'target-within',
46
- '::backdrop': 'backdrop',
47
- '::marker': 'marker',
48
- '::part()': 'part',
49
- '::slotted()': 'slotted',
50
-
51
- // CSS At-rules
52
- '@supports': 'supports',
53
- '@container': 'container-queries',
54
- '@layer': 'cascade-layers',
55
- '@scope': 'scope',
56
-
57
- // JavaScript Web APIs
58
- 'HTMLDialogElement.showModal': 'dialog',
59
- 'HTMLDialogElement.show': 'dialog',
60
- 'HTMLDialogElement.close': 'dialog',
61
- 'structuredClone': 'structured-clone',
62
- 'Array.prototype.at': 'array-at',
63
- 'Array.prototype.findLast': 'array-find-last',
64
- 'Array.prototype.findLastIndex': 'array-find-last',
65
- 'String.prototype.at': 'string-at',
66
- 'String.prototype.replaceAll': 'string-replace-all',
67
- 'Object.hasOwn': 'object-has-own',
68
- 'ResizeObserver': 'resize-observer',
69
- 'IntersectionObserver': 'intersection-observer',
70
- 'MutationObserver': 'mutation-observer',
71
- 'PerformanceObserver': 'performance-observer',
72
- 'BroadcastChannel': 'broadcast-channel',
73
- 'MessageChannel': 'message-channel',
74
- 'SharedArrayBuffer': 'shared-array-buffer',
75
- 'Atomics': 'atomics',
76
- 'BigInt': 'bigint',
77
- 'WeakRef': 'weak-ref',
78
- 'FinalizationRegistry': 'finalization-registry',
79
-
80
- // Canvas and WebGL APIs
81
- 'CanvasRenderingContext2D.filter': 'canvas-filter',
82
- 'CanvasRenderingContext2D.reset': 'canvas-reset',
83
- 'WebGL2RenderingContext': 'webgl2',
84
- 'OffscreenCanvas': 'offscreen-canvas',
85
- 'OffscreenCanvasRenderingContext2D': 'offscreen-canvas',
86
- 'ImageBitmap': 'image-bitmap',
87
- 'createImageBitmap': 'image-bitmap',
88
- 'Path2D': 'path2d',
89
-
90
- // WebRTC APIs
91
- 'RTCPeerConnection': 'webrtc',
92
- 'getUserMedia': 'getusermedia',
93
- 'RTCDataChannel': 'rtc-data-channel',
94
- 'RTCRtpTransceiver': 'rtc-rtp-transceiver',
95
- 'RTCStatsReport': 'rtc-stats',
96
- 'RTCIceCandidate': 'rtc-ice-candidate',
97
- 'RTCSessionDescription': 'rtc-session-description',
98
-
99
- // Service Workers and PWA
100
- 'ServiceWorker': 'service-workers',
101
- 'navigator.serviceWorker': 'service-workers',
102
- 'ServiceWorkerRegistration': 'service-workers',
103
- 'Cache': 'cache-api',
104
- 'CacheStorage': 'cache-api',
105
- 'PushManager': 'push-api',
106
- 'PushSubscription': 'push-api',
107
- 'NotificationEvent': 'notification-api',
108
- 'BackgroundSync': 'background-sync',
109
- 'PaymentRequest': 'payment-request',
110
- 'PaymentResponse': 'payment-request',
111
-
112
- // WebAssembly
113
- 'WebAssembly': 'webassembly',
114
- 'WebAssembly.instantiate': 'webassembly',
115
- 'WebAssembly.compile': 'webassembly',
116
- 'WebAssembly.Module': 'webassembly',
117
- 'WebAssembly.Instance': 'webassembly',
118
- 'WebAssembly.Memory': 'webassembly',
119
- 'WebAssembly.Table': 'webassembly',
120
-
121
- // JavaScript Syntax (ECMAScript features)
122
- 'optional-chaining': 'optional-chaining',
123
- 'nullish-coalescing': 'nullish-coalescing',
124
- 'private-fields': 'private-fields',
125
- 'private-methods': 'private-methods',
126
- 'static-class-fields': 'static-class-fields',
127
- 'top-level-await': 'top-level-await',
128
- 'import-assertions': 'import-assertions',
129
- 'import-meta': 'import-meta',
130
- 'dynamic-import': 'dynamic-import',
131
- 'async-iteration': 'async-iteration',
132
- 'for-await-of': 'async-iteration',
133
- 'destructuring': 'destructuring',
134
- 'rest-spread': 'rest-spread',
135
- 'template-literals': 'template-literals',
136
- 'arrow-functions': 'arrow-functions',
137
- 'const-let': 'const-let',
138
- 'default-parameters': 'default-parameters',
139
-
140
- // HTML Elements and Attributes
141
- 'dialog': 'dialog',
142
- 'details': 'details-summary',
143
- 'summary': 'details-summary',
144
- 'loading="lazy"': 'loading-lazy',
145
- 'decoding="async"': 'image-decoding',
146
- 'input[type="date"]': 'input-date',
147
- 'input[type="time"]': 'input-time',
148
- 'input[type="datetime-local"]': 'input-datetime-local',
149
- 'input[type="month"]': 'input-month',
150
- 'input[type="week"]': 'input-week',
151
- 'input[type="color"]': 'input-color',
152
- 'input[type="range"]': 'input-range',
153
- 'input[type="search"]': 'input-search',
154
- 'input[type="tel"]': 'input-tel',
155
- 'input[type="url"]': 'input-url',
156
- 'input[type="email"]': 'input-email',
157
- 'input[type="number"]': 'input-number',
158
- 'datalist': 'datalist',
159
- 'output': 'output',
160
- 'progress': 'progress',
161
- 'meter': 'meter',
162
- 'picture': 'picture',
163
- 'source': 'picture',
164
- 'track': 'track',
165
- 'slot': 'slot',
166
- 'template': 'template',
167
-
168
- // DOM APIs
169
- 'DOMMatrix': 'geometry-interfaces',
170
- 'DOMPoint': 'geometry-interfaces',
171
- 'DOMRect': 'geometry-interfaces',
172
- 'DOMQuad': 'geometry-interfaces',
173
- 'AbortController': 'abort-controller',
174
- 'AbortSignal': 'abort-controller',
175
- 'FormData': 'form-data',
176
- 'URLSearchParams': 'url-search-params',
177
- 'URL': 'url',
178
- 'URLPattern': 'url-pattern',
179
- 'Blob': 'blob',
180
- 'File': 'file',
181
- 'FileReader': 'file-reader',
182
- 'FileList': 'file-list',
183
- 'DataTransfer': 'data-transfer',
184
- 'ClipboardAPI': 'clipboard-api',
185
- 'navigator.clipboard': 'clipboard-api',
186
- 'Permissions': 'permissions-api',
187
- 'navigator.permissions': 'permissions-api',
188
- 'Geolocation': 'geolocation',
189
- 'navigator.geolocation': 'geolocation',
190
- 'DeviceOrientationEvent': 'device-orientation',
191
- 'DeviceMotionEvent': 'device-motion',
192
- 'Vibration': 'vibration',
193
- 'navigator.vibrate': 'vibration',
194
- 'Battery': 'battery-status',
195
- 'navigator.getBattery': 'battery-status',
196
- 'NetworkInformation': 'network-information',
197
- 'navigator.connection': 'network-information',
198
- 'MediaDevices': 'media-devices',
199
- 'navigator.mediaDevices': 'media-devices',
200
- 'MediaStream': 'media-stream',
201
- 'MediaRecorder': 'media-recorder',
202
- 'SpeechSynthesis': 'speech-synthesis',
203
- 'SpeechRecognition': 'speech-recognition',
204
- 'Gamepad': 'gamepad',
205
- 'navigator.getGamepads': 'gamepad',
206
- 'PointerEvent': 'pointer-events',
207
- 'TouchEvent': 'touch-events',
208
- 'WheelEvent': 'wheel-events',
209
- 'KeyboardEvent': 'keyboard-events',
210
- 'MouseEvent': 'mouse-events',
211
- 'FocusEvent': 'focus-events',
212
- 'InputEvent': 'input-events',
213
- 'CompositionEvent': 'composition-events',
214
- 'CustomEvent': 'custom-events',
215
- 'EventTarget': 'event-target',
216
- 'addEventListener': 'event-listeners',
217
- 'removeEventListener': 'event-listeners',
218
- 'dispatchEvent': 'event-dispatch',
219
- 'requestAnimationFrame': 'request-animation-frame',
220
- 'cancelAnimationFrame': 'request-animation-frame',
221
- 'requestIdleCallback': 'request-idle-callback',
222
- 'cancelIdleCallback': 'request-idle-callback',
223
- 'setTimeout': 'timers',
224
- 'setInterval': 'timers',
225
- 'clearTimeout': 'timers',
226
- 'clearInterval': 'timers',
227
- 'queueMicrotask': 'queue-microtask',
228
- 'fetch': 'fetch',
229
- 'Request': 'fetch',
230
- 'Response': 'fetch',
231
- 'Headers': 'fetch',
232
- 'XMLHttpRequest': 'xhr',
233
- 'EventSource': 'server-sent-events',
234
- 'WebSocket': 'websockets',
235
- 'History': 'history-api',
236
- 'history.pushState': 'history-api',
237
- 'history.replaceState': 'history-api',
238
- 'Location': 'location',
239
- 'Navigator': 'navigator',
240
- 'Screen': 'screen',
241
- 'Window': 'window',
242
- 'Document': 'document',
243
- 'Element': 'element',
244
- 'Node': 'node',
245
- 'DocumentFragment': 'document-fragment',
246
- 'ShadowRoot': 'shadow-dom',
247
- 'customElements': 'custom-elements',
248
- 'HTMLElement': 'html-element',
249
- 'SVGElement': 'svg-element'
250
- };
251
-
252
- export class BaselineChecker {
253
- private webFeatures: any = null;
254
- private featureCache = new Map<string, any>();
255
- private initialized = false;
256
-
257
- constructor() {
258
- // Don't load web-features immediately - use lazy loading
259
- }
260
-
261
- /**
262
- * Initialize web-features data lazily
263
- */
264
- private async ensureInitialized(): Promise<void> {
265
- if (this.initialized) {
266
- return;
267
- }
268
-
269
- try {
270
- this.webFeatures = await LazyLoader.getWebFeatures();
271
- this.initialized = true;
272
- } catch (error) {
273
- console.warn('Failed to load web-features data:', error);
274
- this.webFeatures = { features: {}, browsers: {}, groups: {} };
275
- this.initialized = true;
276
- }
277
- }
278
-
279
- /**
280
- * Get feature status from web-features package with caching
281
- */
282
- private async getFeatureStatus(featureId: string): Promise<any> {
283
- await this.ensureInitialized();
284
-
285
- // Check cache first
286
- if (this.featureCache.has(featureId)) {
287
- return this.featureCache.get(featureId);
288
- }
289
-
290
- const feature = this.webFeatures?.features?.[featureId] || this.webFeatures?.[featureId];
291
-
292
- // Cache the result to avoid repeated lookups
293
- if (feature) {
294
- // Optimize the feature data to reduce memory usage
295
- const optimized = MemoryManager.optimizeObject({
296
- name: feature.name,
297
- status: feature.status,
298
- support: feature.support,
299
- baseline: feature.baseline
300
- });
301
- this.featureCache.set(featureId, optimized);
302
- return optimized;
303
- }
304
-
305
- // Cache null results too to avoid repeated failed lookups
306
- this.featureCache.set(featureId, null);
307
- return null;
308
- }
309
-
310
- /**
311
- * Map detected feature to web-features ID
312
- */
313
- private mapFeatureToId(feature: string): string | null {
314
- // Direct mapping
315
- if (FEATURE_ID_MAP[feature]) {
316
- return FEATURE_ID_MAP[feature];
317
- }
318
-
319
- // Try to find partial matches for complex features
320
- for (const [key, value] of Object.entries(FEATURE_ID_MAP)) {
321
- if (feature.includes(key) || key.includes(feature)) {
322
- return value;
323
- }
324
- }
325
-
326
- // Check if the feature exists directly in web-features
327
- if (this.webFeatures?.[feature] || this.webFeatures?.features?.[feature]) {
328
- return feature;
329
- }
330
-
331
- return null;
332
- }
333
-
334
- /**
335
- * Check if a version is supported based on browser support data
336
- */
337
- private isVersionSupported(browserSupport: any, minVersion: string): boolean {
338
- if (!browserSupport) return false;
339
-
340
- // If browser support is true, it's supported
341
- if (browserSupport === true) return true;
342
-
343
- // If browser support is false or null, it's not supported
344
- if (!browserSupport) return false;
345
-
346
- // If it's a version string, compare versions
347
- if (typeof browserSupport === 'string') {
348
- // browserSupport represents the first supporting version.
349
- // A target is compatible only when support starts at or before the target version.
350
- return this.compareVersions(browserSupport, minVersion) <= 0;
351
- }
352
-
353
- // If it's an object with version info, extract the version
354
- if (typeof browserSupport === 'object' && browserSupport.version) {
355
- return this.compareVersions(browserSupport.version, minVersion) <= 0;
356
- }
357
-
358
- return false;
359
- }
360
-
361
- /**
362
- * Compare two version strings
363
- */
364
- private compareVersions(version1: string, version2: string): number {
365
- const v1Parts = version1.split('.').map(Number);
366
- const v2Parts = version2.split('.').map(Number);
367
-
368
- const maxLength = Math.max(v1Parts.length, v2Parts.length);
369
-
370
- for (let i = 0; i < maxLength; i++) {
371
- const v1Part = v1Parts[i] || 0;
372
- const v2Part = v2Parts[i] || 0;
373
-
374
- if (v1Part > v2Part) return 1;
375
- if (v1Part < v2Part) return -1;
376
- }
377
-
378
- return 0;
379
- }
380
-
381
- /**
382
- * Map browser name to web-features format
383
- */
384
- private mapBrowserName(browser: string): string {
385
- const browserMap: Record<string, string> = {
386
- 'chrome': 'chrome',
387
- 'firefox': 'firefox',
388
- 'safari': 'safari',
389
- 'edge': 'edge',
390
- 'opera': 'opera',
391
- 'samsung': 'samsung_android'
392
- };
393
-
394
- return browserMap[browser] || browser;
395
- }
396
-
397
- /**
398
- * Create a violation object
399
- */
400
- private createViolation(
401
- detectedFeature: DetectedFeature,
402
- target: BrowserTarget,
403
- featureData: any,
404
- featureId: string
405
- ): Violation {
406
- const browserKey = this.mapBrowserName(target.browser);
407
- const support = featureData?.status?.support;
408
- const browserSupport = support ? (support as any)[browserKey] : undefined;
409
- const baselineStatus = featureData?.status?.baseline;
410
-
411
- let actual: string | false = false;
412
- if (browserSupport === true) {
413
- actual = 'supported';
414
- } else if (typeof browserSupport === 'string') {
415
- actual = browserSupport;
416
- } else if (typeof browserSupport === 'object' && browserSupport?.version) {
417
- actual = browserSupport.version;
418
- }
419
-
420
- let reason = '';
421
- if (target.minVersion === 'baseline' || target.minVersion === 'baseline-newly') {
422
- if (baselineStatus === false) {
423
- reason = 'Feature is not part of Baseline (not supported across all major browsers)';
424
- } else if (baselineStatus === 'limited') {
425
- reason = 'Feature has limited Baseline support';
426
- }
427
- } else {
428
- reason = `Feature requires ${target.browser} ${actual || 'unknown'} but target is ${target.minVersion}`;
429
- }
430
-
431
- return {
432
- feature: detectedFeature.feature,
433
- featureId,
434
- file: detectedFeature.file || 'unknown',
435
- line: detectedFeature.line,
436
- column: detectedFeature.column,
437
- context: detectedFeature.context,
438
- browser: target.browser,
439
- required: target.minVersion,
440
- actual,
441
- baselineStatus: baselineStatus === false ? 'false' : baselineStatus === true ? 'widely' : String(baselineStatus || 'unknown'),
442
- reason
443
- };
444
- }
445
-
446
- /**
447
- * Check compatibility of a detected feature against browser targets
448
- */
449
- async checkCompatibility(detectedFeature: DetectedFeature, targets: BrowserTarget[]): Promise<CompatibilityResult> {
450
- await this.ensureInitialized();
451
- const featureId = this.mapFeatureToId(detectedFeature.feature);
452
-
453
- if (!featureId) {
454
- // Feature not found in mapping, assume it's compatible
455
- return {
456
- violations: [],
457
- featureData: null
458
- };
459
- }
460
-
461
- const featureData = await this.getFeatureStatus(featureId);
462
-
463
- if (!featureData) {
464
- // Feature not found in web-features, assume it's compatible
465
- return {
466
- violations: [],
467
- featureData: null
468
- };
469
- }
470
-
471
- const violations: Violation[] = [];
472
-
473
- for (const target of targets) {
474
- if (target.minVersion === 'baseline' || target.minVersion === 'baseline-newly') {
475
- // Check baseline status
476
- const baselineStatus = featureData.status?.baseline;
477
-
478
- if (target.minVersion === 'baseline' && baselineStatus !== 'high') {
479
- violations.push(this.createViolation(detectedFeature, target, featureData, featureId));
480
- } else if (target.minVersion === 'baseline-newly' && baselineStatus === false) {
481
- violations.push(this.createViolation(detectedFeature, target, featureData, featureId));
482
- }
483
- } else {
484
- // Check specific version - map browser names to web-features format
485
- const browserKey = this.mapBrowserName(target.browser);
486
- const support = featureData.status?.support;
487
- const browserSupport = support ? (support as any)[browserKey] : undefined;
488
-
489
- if (!this.isVersionSupported(browserSupport, target.minVersion)) {
490
- violations.push(this.createViolation(detectedFeature, target, featureData, featureId));
491
- }
492
- }
493
- }
494
-
495
- return {
496
- violations,
497
- featureData
498
- };
499
- }
500
-
501
- /**
502
- * Check multiple features against browser targets with memory optimization
503
- */
504
- async checkMultipleFeatures(detectedFeatures: DetectedFeature[], targets: BrowserTarget[]): Promise<Violation[]> {
505
- const violationTracker = MemoryManager.createViolationTracker();
506
-
507
- // Process in batches to manage memory usage
508
- await MemoryManager.processBatches(
509
- detectedFeatures,
510
- async (batch) => {
511
- const batchResults = await Promise.all(
512
- batch.map(feature => this.checkCompatibility(feature, targets))
513
- );
514
-
515
- for (const result of batchResults) {
516
- for (const violation of result.violations) {
517
- violationTracker.addViolation(violation);
518
- }
519
- }
520
-
521
- return [];
522
- },
523
- 50 // Process 50 features at a time
524
- );
525
-
526
- return violationTracker.getViolations();
527
- }
528
-
529
- /**
530
- * Get available feature IDs for debugging/testing
531
- */
532
- async getAvailableFeatureIds(): Promise<string[]> {
533
- await this.ensureInitialized();
534
- return Object.keys(this.webFeatures?.features || this.webFeatures || {});
535
- }
536
-
537
- /**
538
- * Clear caches to free memory
539
- */
540
- clearCache(): void {
541
- this.featureCache.clear();
542
- }
543
-
544
- /**
545
- * Get cache statistics
546
- */
547
- getCacheStats(): {
548
- cacheSize: number;
549
- memoryEstimate: string;
550
- } {
551
- const cacheSize = this.featureCache.size;
552
- const memoryEstimate = `${Math.round(cacheSize * 500 / 1024)}KB`; // Rough estimate
553
-
554
- return {
555
- cacheSize,
556
- memoryEstimate
557
- };
558
- }
559
-
560
- /**
561
- * Get feature mapping for debugging/testing
562
- */
563
- getFeatureMapping(): Record<string, string> {
564
- return { ...FEATURE_ID_MAP };
565
- }
566
- }