baseguard 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.baseguardrc.example.json +63 -63
- package/.eslintrc.json +24 -24
- package/.prettierrc +7 -7
- package/CHANGELOG.md +195 -195
- package/DEPLOYMENT.md +624 -624
- package/DEPLOYMENT_CHECKLIST.md +239 -239
- package/DEPLOYMENT_SUMMARY_v1.0.2.md +202 -202
- package/QUICK_START.md +134 -134
- package/README.md +488 -488
- package/RELEASE_NOTES_v1.0.2.md +434 -434
- package/bin/base.js +628 -613
- package/dist/ai/fix-manager.d.ts.map +1 -1
- package/dist/ai/fix-manager.js +1 -1
- package/dist/ai/fix-manager.js.map +1 -1
- package/dist/ai/gemini-analyzer.d.ts.map +1 -1
- package/dist/ai/gemini-analyzer.js +29 -35
- package/dist/ai/gemini-analyzer.js.map +1 -1
- package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
- package/dist/ai/gemini-code-fixer.js +58 -58
- package/dist/ai/gemini-code-fixer.js.map +1 -1
- package/dist/ai/jules-implementer.d.ts +3 -0
- package/dist/ai/jules-implementer.d.ts.map +1 -1
- package/dist/ai/jules-implementer.js +63 -32
- package/dist/ai/jules-implementer.js.map +1 -1
- package/dist/ai/unified-code-fixer.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +1 -1
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/config.js +2 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +44 -15
- package/dist/commands/fix.js.map +1 -1
- package/dist/core/api-key-manager.js +2 -2
- package/dist/core/api-key-manager.js.map +1 -1
- package/dist/core/baseguard.d.ts +1 -0
- package/dist/core/baseguard.d.ts.map +1 -1
- package/dist/core/baseguard.js +13 -10
- package/dist/core/baseguard.js.map +1 -1
- package/dist/core/baseline-checker.d.ts.map +1 -1
- package/dist/core/baseline-checker.js +2 -1
- package/dist/core/baseline-checker.js.map +1 -1
- package/dist/core/configuration-recovery.d.ts.map +1 -1
- package/dist/core/configuration-recovery.js +1 -1
- package/dist/core/configuration-recovery.js.map +1 -1
- package/dist/core/debug-logger.d.ts.map +1 -1
- package/dist/core/debug-logger.js +1 -1
- package/dist/core/debug-logger.js.map +1 -1
- package/dist/core/error-handler.d.ts.map +1 -1
- package/dist/core/error-handler.js +2 -1
- package/dist/core/error-handler.js.map +1 -1
- package/dist/core/gitignore-manager.js +5 -5
- package/dist/core/graceful-degradation-manager.d.ts.map +1 -1
- package/dist/core/graceful-degradation-manager.js +16 -16
- package/dist/core/graceful-degradation-manager.js.map +1 -1
- package/dist/core/lazy-loader.d.ts.map +1 -1
- package/dist/core/lazy-loader.js +9 -2
- package/dist/core/lazy-loader.js.map +1 -1
- package/dist/core/memory-manager.d.ts +0 -3
- package/dist/core/memory-manager.d.ts.map +1 -1
- package/dist/core/memory-manager.js.map +1 -1
- package/dist/core/parser-worker.d.ts +2 -0
- package/dist/core/parser-worker.d.ts.map +1 -0
- package/dist/core/parser-worker.js +19 -0
- package/dist/core/parser-worker.js.map +1 -0
- package/dist/core/startup-optimizer.d.ts +2 -0
- package/dist/core/startup-optimizer.d.ts.map +1 -1
- package/dist/core/startup-optimizer.js +19 -12
- package/dist/core/startup-optimizer.js.map +1 -1
- package/dist/core/system-error-handler.d.ts.map +1 -1
- package/dist/core/system-error-handler.js +18 -11
- package/dist/core/system-error-handler.js.map +1 -1
- package/dist/git/automation-engine.d.ts.map +1 -1
- package/dist/git/automation-engine.js +5 -4
- package/dist/git/automation-engine.js.map +1 -1
- package/dist/git/github-manager.d.ts.map +1 -1
- package/dist/git/github-manager.js.map +1 -1
- package/dist/git/hook-manager.js +5 -5
- package/dist/git/hook-manager.js.map +1 -1
- package/dist/parsers/parser-manager.d.ts.map +1 -1
- package/dist/parsers/parser-manager.js +1 -1
- package/dist/parsers/parser-manager.js.map +1 -1
- package/dist/parsers/svelte-parser.js +1 -1
- package/dist/parsers/svelte-parser.js.map +1 -1
- package/dist/parsers/vanilla-parser.d.ts.map +1 -1
- package/dist/parsers/vanilla-parser.js.map +1 -1
- package/dist/parsers/vue-parser.d.ts.map +1 -1
- package/dist/parsers/vue-parser.js.map +1 -1
- package/dist/ui/components.d.ts +1 -1
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/components.js +11 -11
- package/dist/ui/components.js.map +1 -1
- package/dist/ui/terminal-header.js +14 -14
- package/package.json +105 -105
- package/src/ai/__tests__/gemini-analyzer.test.ts +180 -180
- package/src/ai/agentkit-orchestrator.ts +533 -533
- package/src/ai/fix-manager.ts +362 -362
- package/src/ai/gemini-analyzer.ts +665 -671
- package/src/ai/gemini-code-fixer.ts +539 -540
- package/src/ai/index.ts +3 -3
- package/src/ai/jules-implementer.ts +504 -460
- package/src/ai/unified-code-fixer.ts +347 -347
- package/src/commands/automation.ts +343 -343
- package/src/commands/check.ts +298 -299
- package/src/commands/config.ts +584 -583
- package/src/commands/fix.ts +264 -238
- package/src/commands/index.ts +6 -6
- package/src/commands/init.ts +155 -155
- package/src/commands/status.ts +306 -306
- package/src/core/api-key-manager.ts +298 -298
- package/src/core/baseguard.ts +757 -756
- package/src/core/baseline-checker.ts +564 -563
- package/src/core/cache-manager.ts +271 -271
- package/src/core/configuration-recovery.ts +672 -673
- package/src/core/configuration.ts +595 -595
- package/src/core/debug-logger.ts +590 -590
- package/src/core/directory-filter.ts +420 -420
- package/src/core/error-handler.ts +518 -517
- package/src/core/file-processor.ts +337 -337
- package/src/core/gitignore-manager.ts +168 -168
- package/src/core/graceful-degradation-manager.ts +596 -596
- package/src/core/index.ts +16 -16
- package/src/core/lazy-loader.ts +317 -307
- package/src/core/memory-manager.ts +290 -295
- package/src/core/parser-worker.ts +33 -0
- package/src/core/startup-optimizer.ts +246 -243
- package/src/core/system-error-handler.ts +755 -750
- package/src/git/automation-engine.ts +361 -361
- package/src/git/github-manager.ts +190 -192
- package/src/git/hook-manager.ts +210 -210
- package/src/git/index.ts +3 -3
- package/src/index.ts +7 -7
- package/src/parsers/feature-validator.ts +558 -558
- package/src/parsers/index.ts +7 -7
- package/src/parsers/parser-manager.ts +418 -419
- package/src/parsers/parser.ts +25 -25
- package/src/parsers/react-parser-optimized.ts +160 -160
- package/src/parsers/react-parser.ts +358 -358
- package/src/parsers/svelte-parser.ts +510 -510
- package/src/parsers/vanilla-parser.ts +685 -686
- package/src/parsers/vue-parser.ts +476 -478
- package/src/types/index.ts +95 -95
- package/src/ui/components.ts +567 -567
- package/src/ui/help.ts +192 -192
- package/src/ui/index.ts +3 -3
- package/src/ui/prompts.ts +680 -680
- package/src/ui/terminal-header.ts +58 -58
- package/test-build.js +40 -40
- package/test-config-commands.js +55 -55
- package/test-header-simple.js +32 -32
- package/test-terminal-header.js +11 -11
- package/test-ui.js +28 -28
- package/tests/e2e/baseguard.e2e.test.ts +515 -515
- package/tests/e2e/cross-platform.e2e.test.ts +419 -419
- package/tests/e2e/git-integration.e2e.test.ts +486 -486
- package/tests/fixtures/react-project/package.json +13 -13
- package/tests/fixtures/react-project/src/App.css +75 -75
- package/tests/fixtures/react-project/src/App.tsx +76 -76
- package/tests/fixtures/svelte-project/package.json +10 -10
- package/tests/fixtures/svelte-project/src/App.svelte +368 -368
- package/tests/fixtures/vanilla-project/index.html +75 -75
- package/tests/fixtures/vanilla-project/script.js +330 -330
- package/tests/fixtures/vanilla-project/styles.css +358 -358
- package/tests/fixtures/vue-project/package.json +11 -11
- package/tests/fixtures/vue-project/src/App.vue +215 -215
- package/tsconfig.json +34 -34
- package/vitest.config.ts +11 -11
- package/dist/terminal-header.d.ts +0 -12
- package/dist/terminal-header.js +0 -45
|
@@ -1,478 +1,476 @@
|
|
|
1
|
-
import { Parser } from './parser.js';
|
|
2
|
-
import type { DetectedFeature } from '../types/index.js';
|
|
3
|
-
import { LazyLoader } from '../core/lazy-loader.js';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
'
|
|
155
|
-
'
|
|
156
|
-
'
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
'
|
|
163
|
-
'
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
rule.selector.includes(':
|
|
271
|
-
|
|
272
|
-
rule.selector
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (t.
|
|
372
|
-
apiName = node.callee
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (t.
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (selector.includes(':
|
|
425
|
-
if (selector.includes(':
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
'
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
/
|
|
444
|
-
/
|
|
445
|
-
/
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
}
|
|
1
|
+
import { Parser } from './parser.js';
|
|
2
|
+
import type { DetectedFeature } from '../types/index.js';
|
|
3
|
+
import { LazyLoader } from '../core/lazy-loader.js';
|
|
4
|
+
import * as t from '@babel/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Vue single-file component parser - extracts ALL web platform features
|
|
8
|
+
* while ignoring Vue-specific APIs
|
|
9
|
+
*/
|
|
10
|
+
export class VueParser extends Parser {
|
|
11
|
+
private readonly VUE_SPECIFIC_APIS = new Set([
|
|
12
|
+
// Vue 3 Composition API
|
|
13
|
+
'ref', 'reactive', 'computed', 'watch', 'watchEffect', 'onMounted', 'onUnmounted',
|
|
14
|
+
'onBeforeMount', 'onBeforeUnmount', 'onUpdated', 'onBeforeUpdate',
|
|
15
|
+
'onActivated', 'onDeactivated', 'onErrorCaptured', 'provide', 'inject',
|
|
16
|
+
'getCurrentInstance', 'nextTick', 'defineComponent', 'defineProps', 'defineEmits',
|
|
17
|
+
'defineExpose', 'withDefaults', 'toRef', 'toRefs', 'unref', 'isRef',
|
|
18
|
+
|
|
19
|
+
// Vue 2 Options API
|
|
20
|
+
'Vue', 'data', 'props', 'methods', 'computed', 'watch', 'created', 'mounted',
|
|
21
|
+
'updated', 'destroyed', 'beforeCreate', 'beforeMount', 'beforeUpdate', 'beforeDestroy',
|
|
22
|
+
'activated', 'deactivated', 'errorCaptured', 'mixins', 'extends', 'components',
|
|
23
|
+
|
|
24
|
+
// Vue Router
|
|
25
|
+
'useRouter', 'useRoute', '$router', '$route', 'router-link', 'router-view',
|
|
26
|
+
|
|
27
|
+
// Vuex/Pinia
|
|
28
|
+
'useStore', '$store', 'mapState', 'mapGetters', 'mapMutations', 'mapActions'
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
private readonly VUE_DIRECTIVES = new Set([
|
|
32
|
+
'v-if', 'v-else', 'v-else-if', 'v-for', 'v-show', 'v-bind', 'v-on', 'v-model',
|
|
33
|
+
'v-slot', 'v-pre', 'v-cloak', 'v-once', 'v-memo', 'v-html', 'v-text'
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
private readonly WEB_PLATFORM_APIS = new Set([
|
|
37
|
+
// Canvas APIs
|
|
38
|
+
'getContext', 'CanvasRenderingContext2D', 'WebGLRenderingContext', 'WebGL2RenderingContext',
|
|
39
|
+
'OffscreenCanvas', 'ImageBitmap', 'createImageBitmap', 'Path2D',
|
|
40
|
+
|
|
41
|
+
// WebRTC APIs
|
|
42
|
+
'RTCPeerConnection', 'RTCDataChannel', 'RTCSessionDescription', 'RTCIceCandidate',
|
|
43
|
+
'getUserMedia', 'getDisplayMedia', 'MediaStream', 'MediaStreamTrack',
|
|
44
|
+
|
|
45
|
+
// WebAssembly
|
|
46
|
+
'WebAssembly', 'instantiate', 'compile', 'validate',
|
|
47
|
+
|
|
48
|
+
// Service Workers & PWA
|
|
49
|
+
'ServiceWorker', 'serviceWorker', 'register', 'Cache', 'caches',
|
|
50
|
+
'PushManager', 'Notification', 'showNotification',
|
|
51
|
+
|
|
52
|
+
// DOM APIs
|
|
53
|
+
'querySelector', 'querySelectorAll', 'getElementById', 'getElementsByClassName',
|
|
54
|
+
'addEventListener', 'removeEventListener', 'dispatchEvent', 'CustomEvent',
|
|
55
|
+
'MutationObserver', 'ResizeObserver', 'IntersectionObserver', 'PerformanceObserver',
|
|
56
|
+
'AbortController', 'AbortSignal', 'FormData', 'URLSearchParams', 'URL',
|
|
57
|
+
'fetch', 'Request', 'Response', 'Headers', 'Blob', 'File', 'FileReader',
|
|
58
|
+
|
|
59
|
+
// Web APIs
|
|
60
|
+
'navigator', 'geolocation', 'permissions', 'clipboard', 'share',
|
|
61
|
+
'requestAnimationFrame', 'cancelAnimationFrame', 'requestIdleCallback',
|
|
62
|
+
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
|
|
63
|
+
'localStorage', 'sessionStorage', 'indexedDB', 'crypto', 'performance',
|
|
64
|
+
|
|
65
|
+
// Audio/Video APIs
|
|
66
|
+
'AudioContext', 'MediaRecorder', 'MediaSource', 'SourceBuffer',
|
|
67
|
+
'HTMLMediaElement', 'HTMLAudioElement', 'HTMLVideoElement',
|
|
68
|
+
|
|
69
|
+
// Modern JavaScript APIs
|
|
70
|
+
'structuredClone', 'queueMicrotask', 'reportError',
|
|
71
|
+
'WeakRef', 'FinalizationRegistry', 'AggregateError',
|
|
72
|
+
|
|
73
|
+
// Intl APIs
|
|
74
|
+
'Intl', 'DateTimeFormat', 'NumberFormat', 'Collator', 'PluralRules',
|
|
75
|
+
'RelativeTimeFormat', 'ListFormat', 'Locale'
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
canParse(filePath: string): boolean {
|
|
79
|
+
return /\.vue$/.test(filePath);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async parseFeatures(content: string, filePath: string): Promise<DetectedFeature[]> {
|
|
83
|
+
const features: DetectedFeature[] = [];
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
// Lazy load Vue compiler
|
|
87
|
+
const vueCompiler = await LazyLoader.getVueCompiler();
|
|
88
|
+
const { descriptor } = vueCompiler.parse(content, { filename: filePath });
|
|
89
|
+
|
|
90
|
+
// Parse script blocks for JavaScript features
|
|
91
|
+
if (descriptor.script) {
|
|
92
|
+
const scriptFeatures = await this.parseScriptBlock(
|
|
93
|
+
descriptor.script.content,
|
|
94
|
+
descriptor.script.lang || 'js',
|
|
95
|
+
filePath
|
|
96
|
+
);
|
|
97
|
+
features.push(...scriptFeatures);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (descriptor.scriptSetup) {
|
|
101
|
+
const setupFeatures = await this.parseScriptBlock(
|
|
102
|
+
descriptor.scriptSetup.content,
|
|
103
|
+
descriptor.scriptSetup.lang || 'js',
|
|
104
|
+
filePath
|
|
105
|
+
);
|
|
106
|
+
features.push(...setupFeatures);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Parse style blocks for CSS features
|
|
110
|
+
if (descriptor.styles) {
|
|
111
|
+
for (const style of descriptor.styles) {
|
|
112
|
+
const styleFeatures = await this.parseStyleBlock(
|
|
113
|
+
style.content,
|
|
114
|
+
style.lang || 'css',
|
|
115
|
+
filePath
|
|
116
|
+
);
|
|
117
|
+
features.push(...styleFeatures);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Parse template for HTML features (standard elements only)
|
|
122
|
+
if (descriptor.template) {
|
|
123
|
+
const templateFeatures = this.parseTemplateBlock(
|
|
124
|
+
descriptor.template.content,
|
|
125
|
+
filePath
|
|
126
|
+
);
|
|
127
|
+
features.push(...templateFeatures);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.warn(`Warning: Could not parse Vue file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return features;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private async parseScriptBlock(content: string, lang: string, filePath: string): Promise<DetectedFeature[]> {
|
|
138
|
+
const features: DetectedFeature[] = [];
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
const isTypeScript = lang === 'ts' || lang === 'typescript';
|
|
142
|
+
|
|
143
|
+
// Lazy load Babel dependencies
|
|
144
|
+
const [parser, traverse] = await Promise.all([
|
|
145
|
+
LazyLoader.getBabelParser(),
|
|
146
|
+
LazyLoader.getBabelTraverse()
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
const ast = parser.parse(content, {
|
|
150
|
+
sourceType: 'module',
|
|
151
|
+
plugins: [
|
|
152
|
+
'typescript',
|
|
153
|
+
'decorators-legacy',
|
|
154
|
+
'classProperties',
|
|
155
|
+
'objectRestSpread',
|
|
156
|
+
'asyncGenerators',
|
|
157
|
+
'functionBind',
|
|
158
|
+
'exportDefaultFrom',
|
|
159
|
+
'exportNamespaceFrom',
|
|
160
|
+
'dynamicImport',
|
|
161
|
+
'nullishCoalescingOperator',
|
|
162
|
+
'optionalChaining',
|
|
163
|
+
'topLevelAwait'
|
|
164
|
+
].filter(plugin => isTypeScript || plugin !== 'typescript')
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
traverse(ast, {
|
|
168
|
+
// Extract JavaScript Web APIs
|
|
169
|
+
MemberExpression: (path: any) => {
|
|
170
|
+
const feature = this.extractWebAPIFeature(path.node, path, content);
|
|
171
|
+
if (feature) {
|
|
172
|
+
features.push({ ...feature, file: filePath });
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
// Extract function calls to Web APIs
|
|
177
|
+
CallExpression: (path: any) => {
|
|
178
|
+
const feature = this.extractWebAPICall(path.node, path, content);
|
|
179
|
+
if (feature) {
|
|
180
|
+
features.push({ ...feature, file: filePath });
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
// Extract modern JavaScript syntax features
|
|
185
|
+
OptionalMemberExpression: (path: any) => {
|
|
186
|
+
features.push({
|
|
187
|
+
feature: 'optional-chaining',
|
|
188
|
+
type: 'js',
|
|
189
|
+
context: this.getContext(content, path.node.loc?.start.line || 0),
|
|
190
|
+
line: path.node.loc?.start.line || 0,
|
|
191
|
+
column: path.node.loc?.start.column || 0,
|
|
192
|
+
file: filePath
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// Nullish coalescing
|
|
197
|
+
LogicalExpression: (path: any) => {
|
|
198
|
+
if (path.node.operator === '??') {
|
|
199
|
+
features.push({
|
|
200
|
+
feature: 'nullish-coalescing',
|
|
201
|
+
type: 'js',
|
|
202
|
+
context: this.getContext(content, path.node.loc?.start.line || 0),
|
|
203
|
+
line: path.node.loc?.start.line || 0,
|
|
204
|
+
column: path.node.loc?.start.column || 0,
|
|
205
|
+
file: filePath
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// Private class fields
|
|
211
|
+
ClassPrivateProperty: (path: any) => {
|
|
212
|
+
features.push({
|
|
213
|
+
feature: 'private-fields',
|
|
214
|
+
type: 'js',
|
|
215
|
+
context: this.getContext(content, path.node.loc?.start.line || 0),
|
|
216
|
+
line: path.node.loc?.start.line || 0,
|
|
217
|
+
column: path.node.loc?.start.column || 0,
|
|
218
|
+
file: filePath
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// Top-level await
|
|
223
|
+
AwaitExpression: (path: any) => {
|
|
224
|
+
if (this.isTopLevelAwait(path)) {
|
|
225
|
+
features.push({
|
|
226
|
+
feature: 'top-level-await',
|
|
227
|
+
type: 'js',
|
|
228
|
+
context: this.getContext(content, path.node.loc?.start.line || 0),
|
|
229
|
+
line: path.node.loc?.start.line || 0,
|
|
230
|
+
column: path.node.loc?.start.column || 0,
|
|
231
|
+
file: filePath
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.warn(`Warning: Could not parse script block in ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return features;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private async parseStyleBlock(content: string, lang: string, filePath: string): Promise<DetectedFeature[]> {
|
|
245
|
+
const features: DetectedFeature[] = [];
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
// For now, only handle CSS (not SCSS, Less, etc.)
|
|
249
|
+
if (lang === 'css' || !lang) {
|
|
250
|
+
// Lazy load PostCSS
|
|
251
|
+
const postcss = await LazyLoader.getPostCSS();
|
|
252
|
+
const root = postcss.parse(content);
|
|
253
|
+
|
|
254
|
+
root.walkDecls((decl: any) => {
|
|
255
|
+
features.push({
|
|
256
|
+
feature: decl.prop,
|
|
257
|
+
type: 'css',
|
|
258
|
+
context: `${decl.prop}: ${decl.value}`,
|
|
259
|
+
line: decl.source?.start?.line || 0,
|
|
260
|
+
column: decl.source?.start?.column || 0,
|
|
261
|
+
file: filePath
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
root.walkRules((rule: any) => {
|
|
266
|
+
// Extract CSS selectors that might be modern features
|
|
267
|
+
if (rule.selector.includes(':has(') ||
|
|
268
|
+
rule.selector.includes(':is(') ||
|
|
269
|
+
rule.selector.includes(':where(') ||
|
|
270
|
+
rule.selector.includes(':focus-visible')) {
|
|
271
|
+
features.push({
|
|
272
|
+
feature: this.extractSelectorFeature(rule.selector),
|
|
273
|
+
type: 'css',
|
|
274
|
+
context: rule.selector,
|
|
275
|
+
line: rule.source?.start?.line || 0,
|
|
276
|
+
column: rule.source?.start?.column || 0,
|
|
277
|
+
file: filePath
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
root.walkAtRules((atRule: any) => {
|
|
283
|
+
// Extract at-rules like @supports, @container, etc.
|
|
284
|
+
features.push({
|
|
285
|
+
feature: `@${atRule.name}`,
|
|
286
|
+
type: 'css',
|
|
287
|
+
context: `@${atRule.name} ${atRule.params}`,
|
|
288
|
+
line: atRule.source?.start?.line || 0,
|
|
289
|
+
column: atRule.source?.start?.column || 0,
|
|
290
|
+
file: filePath
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
} catch (error) {
|
|
295
|
+
console.warn(`Warning: Could not parse style block in ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return features;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private parseTemplateBlock(content: string, filePath: string): DetectedFeature[] {
|
|
302
|
+
const features: DetectedFeature[] = [];
|
|
303
|
+
|
|
304
|
+
// Extract standard HTML elements and attributes (ignore Vue directives)
|
|
305
|
+
const htmlElementRegex = /<(\w+)([^>]*)>/g;
|
|
306
|
+
const lines = content.split('\n');
|
|
307
|
+
|
|
308
|
+
lines.forEach((line, index) => {
|
|
309
|
+
let match: RegExpExecArray | null;
|
|
310
|
+
while ((match = htmlElementRegex.exec(line)) !== null) {
|
|
311
|
+
const tagName = match[1];
|
|
312
|
+
const attributes = match[2];
|
|
313
|
+
|
|
314
|
+
// Check for modern HTML elements
|
|
315
|
+
if (tagName && this.isModernHTMLElement(tagName)) {
|
|
316
|
+
features.push({
|
|
317
|
+
feature: tagName,
|
|
318
|
+
type: 'html',
|
|
319
|
+
context: line.trim(),
|
|
320
|
+
line: index + 1,
|
|
321
|
+
column: match.index,
|
|
322
|
+
file: filePath
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Check for modern HTML attributes (ignore Vue directives)
|
|
327
|
+
if (attributes) {
|
|
328
|
+
const modernAttrs = this.extractModernAttributes(attributes);
|
|
329
|
+
modernAttrs.forEach(attr => {
|
|
330
|
+
features.push({
|
|
331
|
+
feature: attr,
|
|
332
|
+
type: 'html',
|
|
333
|
+
context: line.trim(),
|
|
334
|
+
line: index + 1,
|
|
335
|
+
column: match!.index,
|
|
336
|
+
file: filePath
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
return features;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
private extractWebAPIFeature(node: t.MemberExpression, path: any, content: string): DetectedFeature | null {
|
|
347
|
+
const apiName = this.getMemberExpressionName(node);
|
|
348
|
+
|
|
349
|
+
if (!apiName || this.VUE_SPECIFIC_APIS.has(apiName)) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (this.WEB_PLATFORM_APIS.has(apiName)) {
|
|
354
|
+
return {
|
|
355
|
+
feature: apiName,
|
|
356
|
+
type: 'js',
|
|
357
|
+
context: this.getContext(content, node.loc?.start.line || 0),
|
|
358
|
+
line: node.loc?.start.line || 0,
|
|
359
|
+
column: node.loc?.start.column || 0
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private extractWebAPICall(node: t.CallExpression, path: any, content: string): DetectedFeature | null {
|
|
367
|
+
let apiName = '';
|
|
368
|
+
|
|
369
|
+
if (t.isIdentifier(node.callee)) {
|
|
370
|
+
apiName = node.callee.name;
|
|
371
|
+
} else if (t.isMemberExpression(node.callee)) {
|
|
372
|
+
apiName = this.getMemberExpressionName(node.callee);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (!apiName || this.VUE_SPECIFIC_APIS.has(apiName)) {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (this.WEB_PLATFORM_APIS.has(apiName)) {
|
|
380
|
+
return {
|
|
381
|
+
feature: apiName,
|
|
382
|
+
type: 'js',
|
|
383
|
+
context: this.getContext(content, node.loc?.start.line || 0),
|
|
384
|
+
line: node.loc?.start.line || 0,
|
|
385
|
+
column: node.loc?.start.column || 0
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
private getMemberExpressionName(node: t.MemberExpression): string {
|
|
393
|
+
const parts: string[] = [];
|
|
394
|
+
|
|
395
|
+
const traverse = (n: t.Expression): void => {
|
|
396
|
+
if (t.isIdentifier(n)) {
|
|
397
|
+
parts.unshift(n.name);
|
|
398
|
+
} else if (t.isMemberExpression(n)) {
|
|
399
|
+
if (t.isIdentifier(n.property)) {
|
|
400
|
+
parts.unshift(n.property.name);
|
|
401
|
+
}
|
|
402
|
+
traverse(n.object);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
traverse(node);
|
|
407
|
+
return parts.join('.');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
private isTopLevelAwait(path: any): boolean {
|
|
411
|
+
let parent = path.parent;
|
|
412
|
+
while (parent) {
|
|
413
|
+
if (t.isFunction(parent) || t.isArrowFunctionExpression(parent)) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
parent = path.parentPath?.parent;
|
|
417
|
+
}
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private extractSelectorFeature(selector: string): string {
|
|
422
|
+
if (selector.includes(':has(')) return ':has()';
|
|
423
|
+
if (selector.includes(':is(')) return ':is()';
|
|
424
|
+
if (selector.includes(':where(')) return ':where()';
|
|
425
|
+
if (selector.includes(':focus-visible')) return ':focus-visible';
|
|
426
|
+
return selector;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private isModernHTMLElement(tagName: string): boolean {
|
|
430
|
+
const modernElements = new Set([
|
|
431
|
+
'dialog', 'details', 'summary', 'main', 'article', 'section', 'nav', 'aside',
|
|
432
|
+
'header', 'footer', 'figure', 'figcaption', 'time', 'mark', 'progress', 'meter',
|
|
433
|
+
'canvas', 'video', 'audio', 'source', 'track', 'embed', 'object'
|
|
434
|
+
]);
|
|
435
|
+
return modernElements.has(tagName);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
private extractModernAttributes(attributes: string): string[] {
|
|
439
|
+
const modernAttrs: string[] = [];
|
|
440
|
+
const modernAttrPatterns = [
|
|
441
|
+
/loading=["']lazy["']/,
|
|
442
|
+
/decoding=["']async["']/,
|
|
443
|
+
/fetchpriority=["'](high|low)["']/,
|
|
444
|
+
/enterkeyhint=["']\w+["']/,
|
|
445
|
+
/inputmode=["']\w+["']/
|
|
446
|
+
];
|
|
447
|
+
|
|
448
|
+
modernAttrPatterns.forEach(pattern => {
|
|
449
|
+
if (pattern.test(attributes)) {
|
|
450
|
+
const match = attributes.match(pattern);
|
|
451
|
+
if (match && match[0]) {
|
|
452
|
+
const attrName = match[0].split('=')[0];
|
|
453
|
+
if (attrName) {
|
|
454
|
+
modernAttrs.push(attrName);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
return modernAttrs;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
private getContext(content: string, line: number): string {
|
|
464
|
+
const lines = content.split('\n');
|
|
465
|
+
const targetLine = lines[line - 1] || '';
|
|
466
|
+
return targetLine.trim();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
getSupportedExtensions(): string[] {
|
|
470
|
+
return ['.vue'];
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
getName(): string {
|
|
474
|
+
return 'VueParser';
|
|
475
|
+
}
|
|
476
|
+
}
|