@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,137 +0,0 @@
1
- 'use client';
2
-
3
- import type { ReactNode } from 'react';
4
- import { CodeBlock, Tabs } from '@fragments-sdk/ui';
5
- import styles from './VariantPreviewCard.module.scss';
6
-
7
- /** Detect auto-generated descriptions like "Alternative Layout variant" or "Default ActionMenu" */
8
- function isGenericVariantDescription(name: string, description: string): boolean {
9
- const lower = description.toLowerCase().trim();
10
- const nameLower = name.toLowerCase().trim();
11
- return (
12
- lower === `${nameLower} variant` ||
13
- lower === `default ${nameLower}` ||
14
- lower === nameLower ||
15
- // "Default SomeComponent" — "Default" followed by a PascalCase component name
16
- /^default [a-z][a-z0-9]*$/i.test(description.trim())
17
- );
18
- }
19
-
20
- export interface VariantPreviewCardProps {
21
- name: string;
22
- description?: string;
23
- code?: string;
24
- children: ReactNode;
25
- isLoading?: boolean;
26
- error?: string | null;
27
- defaultTab?: 'preview' | 'code';
28
- highlight?: boolean;
29
- id?: string;
30
- headerActions?: ReactNode;
31
- className?: string;
32
- }
33
-
34
- export function VariantPreviewCard({
35
- name,
36
- description,
37
- code,
38
- children,
39
- isLoading,
40
- error,
41
- defaultTab = 'preview',
42
- highlight,
43
- id,
44
- headerActions,
45
- className,
46
- }: VariantPreviewCardProps) {
47
- const cardClassName = [
48
- styles.card,
49
- highlight && styles.highlighted,
50
- className,
51
- ]
52
- .filter(Boolean)
53
- .join(' ');
54
-
55
- // Use defaultTab as a signal: when 'preview' is requested, a preview IS expected
56
- // even if children/isLoading haven't arrived yet (async hook still settling).
57
- // Always use tabbed layout so code stays hidden in its tab.
58
- const hasPreview = !!children || !!isLoading || defaultTab === 'preview';
59
- const hasCode = typeof code === 'string' && code.length > 0;
60
-
61
- // No preview, code only — render without tabs
62
- if (!hasPreview && hasCode) {
63
- return (
64
- <div className={cardClassName} id={id}>
65
- <div className={styles.header}>
66
- <div className={styles.headerContent}>
67
- <h3 className={styles.title}>{name}</h3>
68
- {description && !isGenericVariantDescription(name, description) && <p className={styles.description}>{description}</p>}
69
- </div>
70
- {headerActions && <div className={styles.headerActions}>{headerActions}</div>}
71
- </div>
72
- <div className={styles.codePanel}>
73
- <CodeBlock code={code} language="tsx" />
74
- </div>
75
- </div>
76
- );
77
- }
78
-
79
- // No code — render preview only, no tabs
80
- if (!hasCode) {
81
- return (
82
- <div className={cardClassName} id={id}>
83
- <div className={styles.header}>
84
- <div className={styles.headerContent}>
85
- <h3 className={styles.title}>{name}</h3>
86
- {description && !isGenericVariantDescription(name, description) && <p className={styles.description}>{description}</p>}
87
- </div>
88
- {headerActions && <div className={styles.headerActions}>{headerActions}</div>}
89
- </div>
90
- <div className={styles.previewPanel}>
91
- {isLoading ? (
92
- <div className={styles.placeholder}>Loading preview...</div>
93
- ) : error ? (
94
- <div className={styles.placeholder}>Preview error: {error}</div>
95
- ) : (
96
- children
97
- )}
98
- </div>
99
- </div>
100
- );
101
- }
102
-
103
- // Both preview and code — render with tabs
104
- return (
105
- <div className={cardClassName} id={id}>
106
- <Tabs defaultValue={defaultTab}>
107
- <div className={styles.header}>
108
- <div className={styles.headerContent}>
109
- <h3 className={styles.title}>{name}</h3>
110
- {description && !isGenericVariantDescription(name, description) && <p className={styles.description}>{description}</p>}
111
- </div>
112
- <div className={styles.headerActions}>
113
- {headerActions}
114
- <Tabs.List variant="pills">
115
- <Tabs.Tab value="preview">Preview</Tabs.Tab>
116
- <Tabs.Tab value="code">Code</Tabs.Tab>
117
- </Tabs.List>
118
- </div>
119
- </div>
120
-
121
- <Tabs.Panel value="preview" className={styles.previewPanel}>
122
- {isLoading ? (
123
- <div className={styles.placeholder}>Loading preview...</div>
124
- ) : error ? (
125
- <div className={styles.placeholder}>Preview error: {error}</div>
126
- ) : (
127
- children
128
- )}
129
- </Tabs.Panel>
130
-
131
- <Tabs.Panel value="code" className={styles.codePanel}>
132
- <CodeBlock code={code} language="tsx" />
133
- </Tabs.Panel>
134
- </Tabs>
135
- </div>
136
- );
137
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Docs data — single source of truth for content shared across
3
- * READMEs, docs pages, and MCP tool descriptions.
4
- *
5
- * Follows the same pattern as `cli-commands/index.ts`.
6
- */
7
-
8
- export {
9
- NEUTRAL_PALETTES,
10
- DENSITY_PRESETS,
11
- RADIUS_STYLES,
12
- SEED_DEFAULTS,
13
- type PaletteDef,
14
- type DensityDef,
15
- type RadiusDef,
16
- } from './palettes.js';
17
-
18
- export {
19
- SCSS_SETUP_MINIMAL,
20
- SCSS_SETUP_FULL,
21
- USE_THEME_EXAMPLE,
22
- USE_THEME_RETURN_SHAPE,
23
- PROVIDER_SETUP_EXAMPLE,
24
- MIXIN_IMPORT,
25
- STYLES_IMPORT_JS,
26
- STYLES_IMPORT_SCSS,
27
- } from './setup-examples.js';
28
-
29
- export {
30
- MCP_CONFIGS,
31
- type McpConfigDef,
32
- } from './mcp-configs.js';
@@ -1,72 +0,0 @@
1
- /**
2
- * MCP server configuration examples per AI tool.
3
- *
4
- * Single source of truth for all READMEs and docs pages
5
- * that show how to configure the Fragments MCP server.
6
- */
7
-
8
- export interface McpConfigDef {
9
- /** AI tool name (e.g., "Claude Code", "Cursor") */
10
- tool: string;
11
- /** Config file path */
12
- filePath: string;
13
- /** JSON config string (with comment header) */
14
- config: string;
15
- }
16
-
17
- const npxArgs = `["-y", "@fragments-sdk/mcp@latest"]`;
18
-
19
- export const MCP_CONFIGS: McpConfigDef[] = [
20
- {
21
- tool: 'Claude Code',
22
- filePath: '.mcp.json',
23
- config: `// .mcp.json (project root)
24
- {
25
- "mcpServers": {
26
- "fragments": {
27
- "command": "npx",
28
- "args": ${npxArgs}
29
- }
30
- }
31
- }`,
32
- },
33
- {
34
- tool: 'Cursor',
35
- filePath: '.cursor/mcp.json',
36
- config: `// .cursor/mcp.json
37
- {
38
- "mcpServers": {
39
- "fragments": {
40
- "command": "npx",
41
- "args": ${npxArgs}
42
- }
43
- }
44
- }`,
45
- },
46
- {
47
- tool: 'VS Code',
48
- filePath: '.vscode/mcp.json',
49
- config: `// .vscode/mcp.json
50
- {
51
- "servers": {
52
- "fragments": {
53
- "command": "npx",
54
- "args": ${npxArgs}
55
- }
56
- }
57
- }`,
58
- },
59
- {
60
- tool: 'Windsurf',
61
- filePath: '~/.codeium/windsurf/mcp_config.json',
62
- config: `// ~/.codeium/windsurf/mcp_config.json
63
- {
64
- "mcpServers": {
65
- "fragments": {
66
- "command": "npx",
67
- "args": ${npxArgs}
68
- }
69
- }
70
- }`,
71
- },
72
- ];
@@ -1,75 +0,0 @@
1
- /**
2
- * Design token seed definitions — single source of truth.
3
- *
4
- * Values must match libs/ui/src/tokens/_seeds.scss exactly.
5
- * READMEs, docs pages, and MCP tool descriptions are generated from these.
6
- */
7
-
8
- // ---------------------------------------------------------------------------
9
- // Types
10
- // ---------------------------------------------------------------------------
11
-
12
- export interface PaletteDef {
13
- name: string;
14
- description: string;
15
- }
16
-
17
- export interface DensityDef {
18
- readonly name: string;
19
- readonly baseUnit: string;
20
- readonly description: string;
21
- }
22
-
23
- export interface RadiusDef {
24
- readonly name: string;
25
- readonly description: string;
26
- }
27
-
28
- // ---------------------------------------------------------------------------
29
- // Neutral Palettes (must match _seeds.scss:27)
30
- // ---------------------------------------------------------------------------
31
-
32
- export const NEUTRAL_PALETTES: PaletteDef[] = [
33
- { name: 'stone', description: 'Cool gray neutrals (balanced, professional) — default' },
34
- { name: 'ice', description: 'Cool blue-tinted grays (crisp, technical)' },
35
- { name: 'earth', description: 'Warm brown-tinted grays (natural, grounded)' },
36
- { name: 'sand', description: 'Warm tan-tinted grays (organic, approachable)' },
37
- { name: 'fire', description: 'Warm red-tinted grays (bold, energetic)' },
38
- ];
39
-
40
- // ---------------------------------------------------------------------------
41
- // Density Presets (must match _seeds.scss:32)
42
- // ---------------------------------------------------------------------------
43
-
44
- export const DENSITY_PRESETS: readonly DensityDef[] = [
45
- { name: 'compact', baseUnit: '6px', description: 'Tighter spacing, smaller elements' },
46
- { name: 'default', baseUnit: '7px', description: 'Balanced, standard appearance' },
47
- { name: 'relaxed', baseUnit: '8px', description: 'More spacious layout' },
48
- ] as const;
49
-
50
- // ---------------------------------------------------------------------------
51
- // Radius Styles (must match _seeds.scss:37)
52
- // ---------------------------------------------------------------------------
53
-
54
- export const RADIUS_STYLES: readonly RadiusDef[] = [
55
- { name: 'sharp', description: 'No rounding (technical, precise)' },
56
- { name: 'subtle', description: 'Minimal rounding (modern minimal)' },
57
- { name: 'default', description: 'Balanced rounding' },
58
- { name: 'rounded', description: 'More prominent (friendly)' },
59
- { name: 'pill', description: 'Maximum rounding (playful, soft)' },
60
- ] as const;
61
-
62
- // ---------------------------------------------------------------------------
63
- // Seed Defaults (must match _seeds.scss)
64
- // ---------------------------------------------------------------------------
65
-
66
- export const SEED_DEFAULTS = {
67
- brand: '#18181b',
68
- neutral: 'stone',
69
- density: 'default',
70
- radiusStyle: 'default',
71
- danger: '#ef4444',
72
- success: '#22c55e',
73
- warning: '#f59e0b',
74
- info: '#3b82f6',
75
- } as const;
@@ -1,55 +0,0 @@
1
- /**
2
- * Correct code examples for setup documentation.
3
- *
4
- * These are the canonical snippets used across READMEs and docs pages.
5
- * If you change a pattern here, all generated docs update automatically.
6
- */
7
-
8
- // ---------------------------------------------------------------------------
9
- // SCSS Setup
10
- // ---------------------------------------------------------------------------
11
-
12
- /** Minimal SCSS setup — @use with() syntax, not standalone variables */
13
- export const SCSS_SETUP_MINIMAL = `@use '@fragments-sdk/ui/styles' with (
14
- $fui-brand: #0066ff
15
- );`;
16
-
17
- /** Full SCSS setup with all seeds */
18
- export const SCSS_SETUP_FULL = `@use '@fragments-sdk/ui/styles' with (
19
- $fui-brand: #0066ff,
20
- $fui-neutral: "ice",
21
- $fui-density: "compact",
22
- $fui-radius-style: "rounded"
23
- );`;
24
-
25
- // ---------------------------------------------------------------------------
26
- // Theme API
27
- // ---------------------------------------------------------------------------
28
-
29
- /** Correct useTheme() API — mode/setMode, NOT theme/setTheme */
30
- export const USE_THEME_EXAMPLE = `const { mode, setMode } = useTheme();`;
31
-
32
- /** Full useTheme return shape */
33
- export const USE_THEME_RETURN_SHAPE = `interface UseThemeReturn {
34
- mode: ThemeMode;
35
- setMode: (mode: ThemeMode) => void;
36
- resolvedMode: 'light' | 'dark';
37
- systemPreference: 'light' | 'dark';
38
- toggleMode: () => void;
39
- }`;
40
-
41
- /** Canonical ThemeProvider prop — defaultMode, NOT defaultTheme */
42
- export const PROVIDER_SETUP_EXAMPLE = `<ThemeProvider defaultMode="system">`;
43
-
44
- // ---------------------------------------------------------------------------
45
- // Import Paths
46
- // ---------------------------------------------------------------------------
47
-
48
- /** Correct mixin import path (NOT /tokens) */
49
- export const MIXIN_IMPORT = `@use '@fragments-sdk/ui/mixins' as *;`;
50
-
51
- /** Correct styles import — JS side */
52
- export const STYLES_IMPORT_JS = `import '@fragments-sdk/ui/styles';`;
53
-
54
- /** Correct styles import — SCSS side */
55
- export const STYLES_IMPORT_SCSS = `@use '@fragments-sdk/ui/styles'`;
@@ -1,28 +0,0 @@
1
- .shared-docs-main-content {
2
- width: 100%;
3
- }
4
-
5
- .shared-docs-search-container {
6
- position: relative;
7
- width: 100%;
8
- max-width: 240px;
9
- }
10
-
11
- .shared-docs-search-results {
12
- position: absolute;
13
- top: calc(100% + 4px);
14
- left: 0;
15
- right: 0;
16
- z-index: 100;
17
- }
18
-
19
- .shared-docs-search-result-label {
20
- flex: 1;
21
- font-weight: var(--fui-font-weight-medium);
22
- }
23
-
24
- .shared-docs-search-result-section {
25
- font-size: var(--fui-font-size-xs);
26
- color: var(--fui-text-tertiary);
27
- margin-left: auto;
28
- }
@@ -1,2 +0,0 @@
1
- declare const styles: string;
2
- export default styles;
@@ -1,34 +0,0 @@
1
- 'use client';
2
-
3
- import './docs-layout.scss';
4
-
5
- export { DocsPageShell } from './DocsPageShell';
6
- export { DocsSidebarNav } from './DocsSidebarNav';
7
- export { DocsSearchCommand } from './DocsSearchCommand';
8
- export { DocsHeaderBar } from './DocsHeaderBar';
9
- export {
10
- DocsPageAsideHost,
11
- DocsPageAsidePortal,
12
- DocsPageAsideProvider,
13
- useDocsPageAside,
14
- } from './DocsPageAsideHost';
15
-
16
- export type {
17
- NavItem,
18
- NavSection,
19
- SearchItem,
20
- DocsNavLinkRenderProps,
21
- DocsNavLinkRenderer,
22
- HeaderNavEntry,
23
- HeaderNavLink,
24
- HeaderNavDropdown,
25
- } from './types';
26
- export { isDropdown } from './types';
27
-
28
- export { VariantPreviewCard } from './VariantPreviewCard';
29
- export type { VariantPreviewCardProps } from './VariantPreviewCard';
30
-
31
- export { PropsTable } from './PropsTable';
32
- export { ComponentDocContent } from './ComponentDocContent';
33
- export type { ComponentDocContentProps } from './ComponentDocContent';
34
- export type { DocProp } from './types';
@@ -1,53 +0,0 @@
1
- import type { ReactElement } from 'react';
2
-
3
- export interface NavItem {
4
- label: string;
5
- href: string;
6
- }
7
-
8
- export interface NavSection {
9
- title: string;
10
- items: NavItem[];
11
- collapsible?: boolean;
12
- defaultOpen?: boolean;
13
- }
14
-
15
- export interface SearchItem extends NavItem {
16
- section: string;
17
- }
18
-
19
- export interface DocsNavLinkRenderProps {
20
- href: string;
21
- label: string;
22
- onClick?: () => void;
23
- }
24
-
25
- export type DocsNavLinkRenderer = (props: DocsNavLinkRenderProps) => ReactElement;
26
-
27
- export interface HeaderNavLink {
28
- label: string;
29
- href: string;
30
- }
31
-
32
- export interface HeaderNavDropdown {
33
- label: string;
34
- items: NavItem[];
35
- }
36
-
37
- export type HeaderNavEntry = HeaderNavLink | HeaderNavDropdown;
38
-
39
- export function isDropdown(entry: HeaderNavEntry): entry is HeaderNavDropdown {
40
- return 'items' in entry;
41
- }
42
-
43
- /**
44
- * Prop documentation type for shared PropsTable / ComponentDocContent.
45
- * Intentionally simple — consumers map their richer types into this shape.
46
- */
47
- export interface DocProp {
48
- type: string;
49
- description: string;
50
- required?: boolean;
51
- default?: unknown;
52
- values?: string[];
53
- }
@@ -1,108 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { ToolAnalyticsCollector } from '../analytics.js';
3
- import type { ToolCallEvent } from '@fragments-sdk/webmcp';
4
-
5
- function createEvent(overrides: Partial<ToolCallEvent> = {}): ToolCallEvent {
6
- return {
7
- toolName: 'fragments_discover',
8
- input: {},
9
- output: {},
10
- error: null,
11
- durationMs: 50,
12
- timestamp: Date.now(),
13
- ...overrides,
14
- };
15
- }
16
-
17
- describe('ToolAnalyticsCollector', () => {
18
- it('records events and computes summary', () => {
19
- const collector = new ToolAnalyticsCollector();
20
- collector.record(createEvent({ toolName: 'fragments_discover', durationMs: 10 }));
21
- collector.record(createEvent({ toolName: 'fragments_discover', durationMs: 20 }));
22
- collector.record(createEvent({ toolName: 'fragments_inspect', durationMs: 30 }));
23
-
24
- const summary = collector.toSummary();
25
- expect(summary.totalCalls).toBe(3);
26
- expect(summary.uniqueTools).toBe(2);
27
- expect(summary.toolStats.fragments_discover.callCount).toBe(2);
28
- expect(summary.toolStats.fragments_discover.avgDuration).toBe(15);
29
- expect(summary.toolStats.fragments_inspect.callCount).toBe(1);
30
- });
31
-
32
- it('tracks error rate', () => {
33
- const collector = new ToolAnalyticsCollector();
34
- collector.record(createEvent({ error: null }));
35
- collector.record(createEvent({ error: 'fail' }));
36
-
37
- const summary = collector.toSummary();
38
- expect(summary.errorRate).toBe(0.5);
39
- });
40
-
41
- it('detects common flows', () => {
42
- const collector = new ToolAnalyticsCollector();
43
- const base = Date.now();
44
-
45
- // Create a repeated flow: discover -> inspect -> discover -> inspect
46
- collector.record(createEvent({ toolName: 'fragments_discover', timestamp: base }));
47
- collector.record(createEvent({ toolName: 'fragments_inspect', timestamp: base + 100 }));
48
- collector.record(createEvent({ toolName: 'fragments_discover', timestamp: base + 200 }));
49
- collector.record(createEvent({ toolName: 'fragments_inspect', timestamp: base + 300 }));
50
-
51
- const summary = collector.toSummary();
52
- expect(summary.commonFlows.length).toBeGreaterThan(0);
53
- expect(summary.commonFlows[0].sequence).toEqual(['fragments_discover', 'fragments_inspect']);
54
- expect(summary.commonFlows[0].count).toBe(2);
55
- });
56
-
57
- it('splits sessions on 30s gap', () => {
58
- const collector = new ToolAnalyticsCollector();
59
- const base = Date.now();
60
-
61
- collector.record(createEvent({ toolName: 'a', timestamp: base }));
62
- collector.record(createEvent({ toolName: 'b', timestamp: base + 100 }));
63
- // 31s gap
64
- collector.record(createEvent({ toolName: 'a', timestamp: base + 31_100 }));
65
- collector.record(createEvent({ toolName: 'b', timestamp: base + 31_200 }));
66
-
67
- const summary = collector.toSummary();
68
- // "a -> b" appears in both sessions
69
- const abFlow = summary.commonFlows.find(f =>
70
- f.sequence[0] === 'a' && f.sequence[1] === 'b'
71
- );
72
- expect(abFlow).toBeDefined();
73
- expect(abFlow!.count).toBe(2);
74
- });
75
-
76
- it('computes percentiles', () => {
77
- const collector = new ToolAnalyticsCollector();
78
- for (let i = 1; i <= 100; i++) {
79
- collector.record(createEvent({ durationMs: i }));
80
- }
81
-
82
- const summary = collector.toSummary();
83
- const stat = summary.toolStats.fragments_discover;
84
- expect(stat.p50).toBeGreaterThanOrEqual(49);
85
- expect(stat.p50).toBeLessThanOrEqual(51);
86
- expect(stat.p95).toBeGreaterThanOrEqual(94);
87
- expect(stat.p95).toBeLessThanOrEqual(96);
88
- });
89
-
90
- it('produces PostHog properties', () => {
91
- const collector = new ToolAnalyticsCollector();
92
- collector.record(createEvent());
93
-
94
- const props = collector.toPostHogProperties();
95
- expect(props.webmcp_total_calls).toBe(1);
96
- expect(props.webmcp_unique_tools).toBe(1);
97
- expect(typeof props.webmcp_tool_breakdown).toBe('string');
98
- });
99
-
100
- it('resets state', () => {
101
- const collector = new ToolAnalyticsCollector();
102
- collector.record(createEvent());
103
- collector.reset();
104
-
105
- const summary = collector.toSummary();
106
- expect(summary.totalCalls).toBe(0);
107
- });
108
- });