@fragments-sdk/cli 0.10.1 → 0.11.1

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 (149) hide show
  1. package/dist/bin.js +20 -2
  2. package/dist/bin.js.map +1 -1
  3. package/dist/{init-NDQXUWDU.js → init-UFGK5TCN.js} +75 -4
  4. package/dist/init-UFGK5TCN.js.map +1 -0
  5. package/dist/snapshot-SV2JOFZH.js +139 -0
  6. package/dist/snapshot-SV2JOFZH.js.map +1 -0
  7. package/dist/{viewer-DNMNC5VS.js → viewer-DLLJIMCK.js} +68 -46
  8. package/dist/viewer-DLLJIMCK.js.map +1 -0
  9. package/package.json +6 -14
  10. package/src/bin.ts +30 -0
  11. package/src/commands/init.ts +76 -1
  12. package/src/commands/snapshot.ts +197 -0
  13. package/src/viewer/__tests__/viewer-integration.test.ts +85 -74
  14. package/src/viewer/server.ts +37 -22
  15. package/src/viewer/vite-plugin.ts +25 -9
  16. package/dist/init-NDQXUWDU.js.map +0 -1
  17. package/dist/viewer-DNMNC5VS.js.map +0 -1
  18. package/src/viewer/__tests__/a11y-fixes.test.ts +0 -358
  19. package/src/viewer/__tests__/jsx-parser.test.ts +0 -502
  20. package/src/viewer/__tests__/render-utils.test.ts +0 -232
  21. package/src/viewer/__tests__/style-utils.test.ts +0 -404
  22. package/src/viewer/assets/fragments-logo.ts +0 -4
  23. package/src/viewer/assets/fragments_logo.png +0 -0
  24. package/src/viewer/components/AccessibilityPanel.tsx +0 -1457
  25. package/src/viewer/components/ActionCapture.tsx +0 -172
  26. package/src/viewer/components/ActionsPanel.tsx +0 -332
  27. package/src/viewer/components/AllVariantsPreview.tsx +0 -78
  28. package/src/viewer/components/App.tsx +0 -582
  29. package/src/viewer/components/BottomPanel.tsx +0 -288
  30. package/src/viewer/components/CodePanel.naming.test.tsx +0 -59
  31. package/src/viewer/components/CodePanel.tsx +0 -118
  32. package/src/viewer/components/CommandPalette.tsx +0 -392
  33. package/src/viewer/components/ComponentDocView.tsx +0 -164
  34. package/src/viewer/components/ComponentGraph.tsx +0 -380
  35. package/src/viewer/components/ComponentHeader.tsx +0 -88
  36. package/src/viewer/components/ContractPanel.tsx +0 -241
  37. package/src/viewer/components/EmptyVariantMessage.tsx +0 -54
  38. package/src/viewer/components/ErrorBoundary.tsx +0 -97
  39. package/src/viewer/components/FigmaEmbed.tsx +0 -238
  40. package/src/viewer/components/FragmentEditor.tsx +0 -525
  41. package/src/viewer/components/FragmentRenderer.tsx +0 -61
  42. package/src/viewer/components/HeaderSearch.tsx +0 -24
  43. package/src/viewer/components/HealthDashboard.tsx +0 -441
  44. package/src/viewer/components/HmrStatusIndicator.tsx +0 -61
  45. package/src/viewer/components/Icons.tsx +0 -479
  46. package/src/viewer/components/InteractionsPanel.tsx +0 -757
  47. package/src/viewer/components/IsolatedPreviewFrame.tsx +0 -346
  48. package/src/viewer/components/IsolatedRender.tsx +0 -113
  49. package/src/viewer/components/KeyboardShortcutsHelp.tsx +0 -53
  50. package/src/viewer/components/LandingPage.tsx +0 -421
  51. package/src/viewer/components/Layout.tsx +0 -27
  52. package/src/viewer/components/LeftSidebar.tsx +0 -472
  53. package/src/viewer/components/LoadErrorMessage.tsx +0 -102
  54. package/src/viewer/components/MultiViewportPreview.tsx +0 -522
  55. package/src/viewer/components/NoVariantsMessage.tsx +0 -59
  56. package/src/viewer/components/PanelShell.tsx +0 -161
  57. package/src/viewer/components/PerformancePanel.tsx +0 -304
  58. package/src/viewer/components/PreviewArea.tsx +0 -472
  59. package/src/viewer/components/PreviewAside.tsx +0 -168
  60. package/src/viewer/components/PreviewFrameHost.tsx +0 -303
  61. package/src/viewer/components/PreviewPane.tsx +0 -149
  62. package/src/viewer/components/PreviewToolbar.tsx +0 -80
  63. package/src/viewer/components/PropsEditor.tsx +0 -506
  64. package/src/viewer/components/PropsTable.tsx +0 -111
  65. package/src/viewer/components/RelationsSection.tsx +0 -88
  66. package/src/viewer/components/ResizablePanel.tsx +0 -271
  67. package/src/viewer/components/RightSidebar.tsx +0 -102
  68. package/src/viewer/components/RuntimeToolsRegistrar.tsx +0 -17
  69. package/src/viewer/components/ScreenshotButton.tsx +0 -90
  70. package/src/viewer/components/Sidebar.tsx +0 -169
  71. package/src/viewer/components/SkeletonLoader.tsx +0 -161
  72. package/src/viewer/components/ThemeProvider.tsx +0 -42
  73. package/src/viewer/components/Toast.tsx +0 -3
  74. package/src/viewer/components/TokenStylePanel.tsx +0 -699
  75. package/src/viewer/components/TopToolbar.tsx +0 -159
  76. package/src/viewer/components/UsageSection.tsx +0 -95
  77. package/src/viewer/components/VariantMatrix.tsx +0 -388
  78. package/src/viewer/components/VariantRenderer.tsx +0 -131
  79. package/src/viewer/components/VariantTabs.tsx +0 -40
  80. package/src/viewer/components/ViewerHeader.tsx +0 -69
  81. package/src/viewer/components/ViewerStateSync.tsx +0 -52
  82. package/src/viewer/components/ViewportSelector.tsx +0 -172
  83. package/src/viewer/components/WebMCPDevTools.tsx +0 -503
  84. package/src/viewer/components/WebMCPIntegration.tsx +0 -47
  85. package/src/viewer/components/WebMCPStatusIndicator.tsx +0 -60
  86. package/src/viewer/components/_future/CreatePage.tsx +0 -836
  87. package/src/viewer/components/viewer-utils.ts +0 -16
  88. package/src/viewer/composition-renderer.ts +0 -381
  89. package/src/viewer/constants/index.ts +0 -1
  90. package/src/viewer/constants/ui.ts +0 -166
  91. package/src/viewer/entry.tsx +0 -335
  92. package/src/viewer/hooks/index.ts +0 -2
  93. package/src/viewer/hooks/useA11yCache.ts +0 -383
  94. package/src/viewer/hooks/useA11yService.ts +0 -364
  95. package/src/viewer/hooks/useActions.ts +0 -138
  96. package/src/viewer/hooks/useAppState.ts +0 -147
  97. package/src/viewer/hooks/useCompiledFragments.ts +0 -42
  98. package/src/viewer/hooks/useFigmaIntegration.ts +0 -132
  99. package/src/viewer/hooks/useHmrStatus.ts +0 -109
  100. package/src/viewer/hooks/useKeyboardShortcuts.ts +0 -270
  101. package/src/viewer/hooks/usePreviewBridge.ts +0 -347
  102. package/src/viewer/hooks/useScrollSpy.ts +0 -78
  103. package/src/viewer/hooks/useUrlState.ts +0 -318
  104. package/src/viewer/hooks/useViewSettings.ts +0 -111
  105. package/src/viewer/index.html +0 -28
  106. package/src/viewer/intelligence/healthReport.ts +0 -505
  107. package/src/viewer/intelligence/styleDrift.ts +0 -340
  108. package/src/viewer/intelligence/usageScanner.ts +0 -309
  109. package/src/viewer/jsx-parser.ts +0 -486
  110. package/src/viewer/preview-frame-entry.tsx +0 -25
  111. package/src/viewer/preview-frame.html +0 -125
  112. package/src/viewer/public/favicon.ico +0 -0
  113. package/src/viewer/render-template.html +0 -68
  114. package/src/viewer/styles/globals.css +0 -278
  115. package/src/viewer/types/a11y.ts +0 -197
  116. package/src/viewer/utils/a11y-fixes.ts +0 -509
  117. package/src/viewer/utils/actionExport.ts +0 -372
  118. package/src/viewer/utils/colorSchemes.ts +0 -201
  119. package/src/viewer/utils/detectRelationships.ts +0 -256
  120. package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss +0 -10
  121. package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss.d.ts +0 -2
  122. package/src/viewer/vendor/shared/src/ComponentDocContent.tsx +0 -274
  123. package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +0 -129
  124. package/src/viewer/vendor/shared/src/DocsPageAsideHost.tsx +0 -89
  125. package/src/viewer/vendor/shared/src/DocsPageShell.tsx +0 -124
  126. package/src/viewer/vendor/shared/src/DocsSearchCommand.tsx +0 -99
  127. package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +0 -66
  128. package/src/viewer/vendor/shared/src/PropsTable.module.scss +0 -68
  129. package/src/viewer/vendor/shared/src/PropsTable.module.scss.d.ts +0 -2
  130. package/src/viewer/vendor/shared/src/PropsTable.tsx +0 -76
  131. package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +0 -114
  132. package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss.d.ts +0 -2
  133. package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +0 -137
  134. package/src/viewer/vendor/shared/src/docs-data/index.ts +0 -32
  135. package/src/viewer/vendor/shared/src/docs-data/mcp-configs.ts +0 -72
  136. package/src/viewer/vendor/shared/src/docs-data/palettes.ts +0 -75
  137. package/src/viewer/vendor/shared/src/docs-data/setup-examples.ts +0 -55
  138. package/src/viewer/vendor/shared/src/docs-layout.scss +0 -28
  139. package/src/viewer/vendor/shared/src/docs-layout.scss.d.ts +0 -2
  140. package/src/viewer/vendor/shared/src/index.ts +0 -34
  141. package/src/viewer/vendor/shared/src/types.ts +0 -53
  142. package/src/viewer/webmcp/__tests__/analytics.test.ts +0 -108
  143. package/src/viewer/webmcp/analytics.ts +0 -165
  144. package/src/viewer/webmcp/index.ts +0 -3
  145. package/src/viewer/webmcp/posthog-bridge.ts +0 -39
  146. package/src/viewer/webmcp/runtime-tools.ts +0 -152
  147. package/src/viewer/webmcp/scan-utils.ts +0 -135
  148. package/src/viewer/webmcp/use-tool-analytics.ts +0 -69
  149. package/src/viewer/webmcp/viewer-state.ts +0 -45
@@ -1,383 +0,0 @@
1
- /**
2
- * Shared A11y Cache
3
- *
4
- * Provides a global cache for accessibility scan results that:
5
- * 1. Persists in sessionStorage across page navigations
6
- * 2. Is shared between Dashboard and AccessibilityPanel
7
- * 3. Stores full violation details for rich UI display
8
- * 4. Supports component-level invalidation
9
- */
10
-
11
- import { BRAND } from '../../core/index.js';
12
- import type {
13
- CachedA11yResult,
14
- SerializedViolation,
15
- A11ySummary,
16
- } from '../types/a11y.js';
17
-
18
- const CACHE_KEY = `${BRAND.storagePrefix}a11y-cache`;
19
- const CACHE_VERSION = 2; // Bumped for new schema with full violations
20
-
21
- /**
22
- * Legacy interface for backward compatibility
23
- * @deprecated Use CachedA11yResult instead
24
- */
25
- export interface ComponentA11yData {
26
- violations: number;
27
- passes: number;
28
- incomplete: number;
29
- critical: number;
30
- serious: number;
31
- moderate: number;
32
- minor: number;
33
- scannedAt: number;
34
- variant?: string;
35
- }
36
-
37
- interface A11yCacheData {
38
- version: number;
39
- components: Record<string, CachedA11yResult>;
40
- lastFullScan?: number;
41
- }
42
-
43
- /**
44
- * Load cache from sessionStorage
45
- */
46
- function loadCache(): A11yCacheData {
47
- try {
48
- const stored = sessionStorage.getItem(CACHE_KEY);
49
- if (stored) {
50
- const data = JSON.parse(stored) as A11yCacheData;
51
- if (data.version === CACHE_VERSION) {
52
- return data;
53
- }
54
- // Version mismatch - clear old cache
55
- sessionStorage.removeItem(CACHE_KEY);
56
- }
57
- } catch (e) {
58
- // Ignore parse errors
59
- }
60
- return { version: CACHE_VERSION, components: {} };
61
- }
62
-
63
- /**
64
- * Save cache to sessionStorage
65
- */
66
- function saveCache(data: A11yCacheData): void {
67
- try {
68
- sessionStorage.setItem(CACHE_KEY, JSON.stringify(data));
69
- } catch (e) {
70
- // Storage might be full - try clearing old data
71
- try {
72
- sessionStorage.removeItem(CACHE_KEY);
73
- sessionStorage.setItem(CACHE_KEY, JSON.stringify(data));
74
- } catch {
75
- // Ignore storage errors
76
- }
77
- }
78
- }
79
-
80
- /**
81
- * Get cached a11y result for a component (full data)
82
- */
83
- export function getComponentA11yResult(componentName: string): CachedA11yResult | null {
84
- const cache = loadCache();
85
- return cache.components[componentName] || null;
86
- }
87
-
88
- /**
89
- * Get cached a11y data for a component (legacy format for backward compatibility)
90
- */
91
- export function getComponentA11y(componentName: string): ComponentA11yData | null {
92
- const result = getComponentA11yResult(componentName);
93
- if (!result) return null;
94
-
95
- return {
96
- violations: result.violations.length,
97
- passes: result.passes,
98
- incomplete: result.incomplete,
99
- critical: result.counts.critical,
100
- serious: result.counts.serious,
101
- moderate: result.counts.moderate,
102
- minor: result.counts.minor,
103
- scannedAt: result.scannedAt,
104
- variant: result.variant,
105
- };
106
- }
107
-
108
- /**
109
- * Get all cached a11y data (full results)
110
- */
111
- export function getAllA11yResults(): Record<string, CachedA11yResult> {
112
- const cache = loadCache();
113
- return cache.components;
114
- }
115
-
116
- /**
117
- * Get all cached a11y data (legacy format)
118
- */
119
- export function getAllA11yData(): Record<string, ComponentA11yData> {
120
- const cache = loadCache();
121
- const result: Record<string, ComponentA11yData> = {};
122
-
123
- for (const [name, data] of Object.entries(cache.components)) {
124
- result[name] = {
125
- violations: data.violations.length,
126
- passes: data.passes,
127
- incomplete: data.incomplete,
128
- critical: data.counts.critical,
129
- serious: data.counts.serious,
130
- moderate: data.counts.moderate,
131
- minor: data.counts.minor,
132
- scannedAt: data.scannedAt,
133
- variant: data.variant,
134
- };
135
- }
136
-
137
- return result;
138
- }
139
-
140
- /**
141
- * Get timestamp of last full scan
142
- */
143
- export function getLastFullScanTime(): number | undefined {
144
- const cache = loadCache();
145
- return cache.lastFullScan;
146
- }
147
-
148
- /**
149
- * Update cache with full a11y result for a component
150
- */
151
- export function updateComponentA11yResult(
152
- componentName: string,
153
- result: Omit<CachedA11yResult, 'componentName' | 'scannedAt'> & { scannedAt?: number }
154
- ): void {
155
- const cache = loadCache();
156
- cache.components[componentName] = {
157
- componentName,
158
- ...result,
159
- scannedAt: result.scannedAt || Date.now(),
160
- };
161
- saveCache(cache);
162
-
163
- // Dispatch event for listeners
164
- window.dispatchEvent(new CustomEvent('a11y-cache-updated', {
165
- detail: {
166
- componentName,
167
- data: cache.components[componentName],
168
- // Include legacy format for backward compatibility
169
- legacyData: {
170
- violations: result.violations.length,
171
- passes: result.passes,
172
- incomplete: result.incomplete,
173
- critical: result.counts.critical,
174
- serious: result.counts.serious,
175
- moderate: result.counts.moderate,
176
- minor: result.counts.minor,
177
- scannedAt: result.scannedAt || Date.now(),
178
- variant: result.variant,
179
- },
180
- },
181
- }));
182
- }
183
-
184
- /**
185
- * Update cache for a single component (legacy format, converted to new format)
186
- */
187
- export function updateComponentA11y(
188
- componentName: string,
189
- data: Omit<ComponentA11yData, 'scannedAt'> & { scannedAt?: number },
190
- violations?: SerializedViolation[]
191
- ): void {
192
- const cache = loadCache();
193
-
194
- // Convert to new format
195
- cache.components[componentName] = {
196
- componentName,
197
- violations: violations || [], // Use provided violations or empty array
198
- passes: data.passes,
199
- incomplete: data.incomplete,
200
- scannedAt: data.scannedAt || Date.now(),
201
- variant: data.variant,
202
- counts: {
203
- critical: data.critical,
204
- serious: data.serious,
205
- moderate: data.moderate,
206
- minor: data.minor,
207
- },
208
- };
209
- saveCache(cache);
210
-
211
- // Dispatch event for listeners
212
- window.dispatchEvent(new CustomEvent('a11y-cache-updated', {
213
- detail: { componentName, data: cache.components[componentName] },
214
- }));
215
- }
216
-
217
- /**
218
- * Invalidate cache for specific components
219
- * This marks them for re-scan without removing the data
220
- */
221
- export function invalidateComponents(componentNames: string[]): void {
222
- const cache = loadCache();
223
- let changed = false;
224
-
225
- for (const name of componentNames) {
226
- if (cache.components[name]) {
227
- // Set scannedAt to 0 to mark as stale
228
- cache.components[name].scannedAt = 0;
229
- changed = true;
230
- }
231
- }
232
-
233
- if (changed) {
234
- saveCache(cache);
235
-
236
- // Dispatch event for listeners
237
- window.dispatchEvent(new CustomEvent('a11y-cache-invalidated', {
238
- detail: { components: componentNames },
239
- }));
240
- }
241
- }
242
-
243
- /**
244
- * Check if a component's cache is stale (needs re-scan)
245
- */
246
- export function isComponentStale(componentName: string, maxAgeMs: number = 30000): boolean {
247
- const cache = loadCache();
248
- const data = cache.components[componentName];
249
-
250
- if (!data) return true;
251
- if (data.scannedAt === 0) return true; // Explicitly invalidated
252
-
253
- return Date.now() - data.scannedAt > maxAgeMs;
254
- }
255
-
256
- /**
257
- * Mark that a full scan was completed
258
- */
259
- export function markFullScanComplete(): void {
260
- const cache = loadCache();
261
- cache.lastFullScan = Date.now();
262
- saveCache(cache);
263
- }
264
-
265
- /**
266
- * Clear all cached data
267
- */
268
- export function clearA11yCache(): void {
269
- try {
270
- sessionStorage.removeItem(CACHE_KEY);
271
- } catch (e) {
272
- // Ignore
273
- }
274
- window.dispatchEvent(new CustomEvent('a11y-cache-cleared'));
275
- }
276
-
277
- /**
278
- * Clear cache for a specific component
279
- */
280
- export function clearComponentCache(componentName: string): void {
281
- const cache = loadCache();
282
- if (cache.components[componentName]) {
283
- delete cache.components[componentName];
284
- saveCache(cache);
285
-
286
- window.dispatchEvent(new CustomEvent('a11y-cache-updated', {
287
- detail: { componentName, data: null },
288
- }));
289
- }
290
- }
291
-
292
- /**
293
- * Calculate summary from cached data
294
- */
295
- export function getA11ySummary(): A11ySummary {
296
- const cache = loadCache();
297
- const components = Object.values(cache.components);
298
-
299
- const summary: A11ySummary = {
300
- accessibleComponents: 0,
301
- totalComponents: components.length,
302
- violationsByImpact: {
303
- critical: 0,
304
- serious: 0,
305
- moderate: 0,
306
- minor: 0,
307
- },
308
- topViolations: [],
309
- };
310
-
311
- // Track violations by rule ID for top violations
312
- const violationsByRule = new Map<string, {
313
- ruleId: string;
314
- description: string;
315
- impact: 'critical' | 'serious' | 'moderate' | 'minor' | null;
316
- affectedComponents: Set<string>;
317
- }>();
318
-
319
- for (const comp of components) {
320
- // Count by impact
321
- summary.violationsByImpact.critical += comp.counts.critical;
322
- summary.violationsByImpact.serious += comp.counts.serious;
323
- summary.violationsByImpact.moderate += comp.counts.moderate;
324
- summary.violationsByImpact.minor += comp.counts.minor;
325
-
326
- // Check if accessible (no critical/serious)
327
- if (comp.counts.critical === 0 && comp.counts.serious === 0) {
328
- summary.accessibleComponents++;
329
- }
330
-
331
- // Aggregate violations by rule
332
- for (const violation of comp.violations) {
333
- const existing = violationsByRule.get(violation.id);
334
- if (existing) {
335
- existing.affectedComponents.add(comp.componentName);
336
- } else {
337
- violationsByRule.set(violation.id, {
338
- ruleId: violation.id,
339
- description: violation.description,
340
- impact: violation.impact,
341
- affectedComponents: new Set([comp.componentName]),
342
- });
343
- }
344
- }
345
- }
346
-
347
- // Sort by number of affected components and take top 5
348
- summary.topViolations = Array.from(violationsByRule.values())
349
- .sort((a, b) => b.affectedComponents.size - a.affectedComponents.size)
350
- .slice(0, 5)
351
- .map(v => ({
352
- ruleId: v.ruleId,
353
- description: v.description,
354
- impact: v.impact,
355
- affectedComponents: Array.from(v.affectedComponents),
356
- }));
357
-
358
- return summary;
359
- }
360
-
361
- /**
362
- * Get legacy summary format for backward compatibility
363
- */
364
- export function getLegacyA11ySummary(): {
365
- totalComponents: number;
366
- accessibleComponents: number;
367
- totalViolations: number;
368
- totalCritical: number;
369
- totalSerious: number;
370
- } {
371
- const summary = getA11ySummary();
372
- return {
373
- totalComponents: summary.totalComponents,
374
- accessibleComponents: summary.accessibleComponents,
375
- totalViolations:
376
- summary.violationsByImpact.critical +
377
- summary.violationsByImpact.serious +
378
- summary.violationsByImpact.moderate +
379
- summary.violationsByImpact.minor,
380
- totalCritical: summary.violationsByImpact.critical,
381
- totalSerious: summary.violationsByImpact.serious,
382
- };
383
- }