@fragments-sdk/cli 0.7.0 → 0.7.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.
- package/dist/bin.js +245 -245
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-XHUDJNN3.js → chunk-32VIEOQY.js} +18 -18
- package/dist/chunk-32VIEOQY.js.map +1 -0
- package/dist/{chunk-CVXKXVOY.js → chunk-5ITIP3ES.js} +27 -27
- package/dist/chunk-5ITIP3ES.js.map +1 -0
- package/dist/{chunk-RVRTRESS.js → chunk-DQHWLAUV.js} +29 -29
- package/dist/chunk-DQHWLAUV.js.map +1 -0
- package/dist/{chunk-TJ34N7C7.js → chunk-GCZMFLDI.js} +30 -32
- package/dist/chunk-GCZMFLDI.js.map +1 -0
- package/dist/{chunk-6JBGU74P.js → chunk-GHYYFAQN.js} +23 -23
- package/dist/chunk-GHYYFAQN.js.map +1 -0
- package/dist/{chunk-NWQ4CJOQ.js → chunk-GKX2HPZ6.js} +40 -40
- package/dist/chunk-GKX2HPZ6.js.map +1 -0
- package/dist/{chunk-7OPWMLOE.js → chunk-U6VTHBNI.js} +110 -110
- package/dist/chunk-U6VTHBNI.js.map +1 -0
- package/dist/{core-W2HYIQW6.js → core-SFHPYR5H.js} +24 -26
- package/dist/{generate-LMTISDIJ.js → generate-54GJAWUY.js} +5 -5
- package/dist/generate-54GJAWUY.js.map +1 -0
- package/dist/index.d.ts +23 -27
- package/dist/index.js +10 -10
- package/dist/{init-7CHRKQ7P.js → init-EIM5WNMP.js} +5 -5
- package/dist/{init-7CHRKQ7P.js.map → init-EIM5WNMP.js.map} +1 -1
- package/dist/mcp-bin.js +73 -73
- package/dist/mcp-bin.js.map +1 -1
- package/dist/scan-KQBKUS64.js +12 -0
- package/dist/{service-T2L7VLTE.js → service-ED2LNCTU.js} +6 -6
- package/dist/{static-viewer-GBR7YNF3.js → static-viewer-Q4F4QP5M.js} +4 -4
- package/dist/{test-OJRXNDO2.js → test-6VN2DA3S.js} +19 -19
- package/dist/test-6VN2DA3S.js.map +1 -0
- package/dist/{tokens-3BWDESVM.js → tokens-P2B7ZAM3.js} +5 -5
- package/dist/{viewer-SUFOISZM.js → viewer-GM7IQPPB.js} +199 -199
- package/dist/viewer-GM7IQPPB.js.map +1 -0
- package/package.json +2 -2
- package/src/ai.ts +5 -5
- package/src/analyze.ts +11 -11
- package/src/bin.ts +1 -1
- package/src/build.ts +33 -33
- package/src/commands/a11y.ts +6 -6
- package/src/commands/add.ts +11 -11
- package/src/commands/audit.ts +4 -4
- package/src/commands/baseline.ts +3 -3
- package/src/commands/build.ts +8 -8
- package/src/commands/compare.ts +20 -20
- package/src/commands/context.ts +16 -16
- package/src/commands/enhance.ts +36 -36
- package/src/commands/generate.ts +1 -1
- package/src/commands/graph.ts +3 -3
- package/src/commands/init.ts +1 -1
- package/src/commands/link/figma.ts +82 -82
- package/src/commands/link/index.ts +3 -3
- package/src/commands/link/storybook.ts +9 -9
- package/src/commands/list.ts +2 -2
- package/src/commands/reset.ts +15 -15
- package/src/commands/scan.ts +27 -27
- package/src/commands/storygen.ts +24 -24
- package/src/commands/validate.ts +2 -2
- package/src/commands/verify.ts +8 -8
- package/src/core/auto-props.ts +4 -4
- package/src/core/composition.test.ts +36 -36
- package/src/core/composition.ts +19 -19
- package/src/core/config.ts +6 -6
- package/src/core/{defineSegment.ts → defineFragment.ts} +16 -22
- package/src/core/discovery.ts +6 -6
- package/src/core/figma.ts +2 -2
- package/src/core/graph-extractor.test.ts +77 -77
- package/src/core/graph-extractor.ts +32 -32
- package/src/core/importAnalyzer.ts +1 -1
- package/src/core/index.ts +22 -23
- package/src/core/loader.ts +22 -22
- package/src/core/node.ts +5 -5
- package/src/core/parser.ts +31 -31
- package/src/core/previewLoader.ts +1 -1
- package/src/core/schema.ts +16 -16
- package/src/core/storyAdapter.test.ts +87 -87
- package/src/core/storyAdapter.ts +16 -16
- package/src/core/types.ts +21 -26
- package/src/diff.ts +22 -22
- package/src/index.ts +2 -2
- package/src/mcp/server.ts +80 -80
- package/src/migrate/__tests__/utils/utils.test.ts +3 -3
- package/src/migrate/bin.ts +4 -4
- package/src/migrate/converter.ts +16 -16
- package/src/migrate/index.ts +3 -3
- package/src/migrate/migrate.ts +3 -3
- package/src/migrate/parser.ts +8 -8
- package/src/migrate/report.ts +2 -2
- package/src/migrate/types.ts +4 -4
- package/src/screenshot.ts +22 -22
- package/src/service/__tests__/props-extractor.test.ts +15 -15
- package/src/service/analytics.ts +39 -39
- package/src/service/enhance/codebase-scanner.ts +1 -1
- package/src/service/enhance/index.ts +1 -1
- package/src/service/enhance/props-extractor.ts +2 -2
- package/src/service/enhance/types.ts +2 -2
- package/src/service/index.ts +2 -2
- package/src/service/metrics-store.ts +1 -1
- package/src/service/patch-generator.ts +1 -1
- package/src/setup.ts +52 -52
- package/src/shared/dev-server-client.ts +7 -7
- package/src/shared/fragment-loader.ts +59 -0
- package/src/shared/index.ts +1 -1
- package/src/shared/types.ts +4 -4
- package/src/static-viewer.ts +35 -35
- package/src/test/discovery.ts +6 -6
- package/src/test/index.ts +5 -5
- package/src/test/reporters/console.ts +1 -1
- package/src/test/reporters/junit.ts +1 -1
- package/src/test/runner.ts +7 -7
- package/src/test/types.ts +3 -3
- package/src/test/watch.ts +9 -9
- package/src/validators.ts +26 -26
- package/src/viewer/__tests__/render-utils.test.ts +28 -28
- package/src/viewer/__tests__/viewer-integration.test.ts +4 -4
- package/src/viewer/cli/health.ts +26 -26
- package/src/viewer/components/App.tsx +79 -79
- package/src/viewer/components/BottomPanel.tsx +17 -17
- package/src/viewer/components/CodePanel.tsx +3 -3
- package/src/viewer/components/CommandPalette.tsx +11 -11
- package/src/viewer/components/ComponentGraph.tsx +28 -28
- package/src/viewer/components/ComponentHeader.tsx +2 -2
- package/src/viewer/components/ContractPanel.tsx +6 -6
- package/src/viewer/components/FigmaEmbed.tsx +9 -9
- package/src/viewer/components/HealthDashboard.tsx +17 -17
- package/src/viewer/components/InteractionsPanel.tsx +2 -2
- package/src/viewer/components/IsolatedPreviewFrame.tsx +6 -6
- package/src/viewer/components/IsolatedRender.tsx +10 -10
- package/src/viewer/components/LeftSidebar.tsx +28 -28
- package/src/viewer/components/MultiViewportPreview.tsx +14 -14
- package/src/viewer/components/PreviewArea.tsx +11 -11
- package/src/viewer/components/PreviewFrameHost.tsx +51 -51
- package/src/viewer/components/RightSidebar.tsx +9 -9
- package/src/viewer/components/Sidebar.tsx +17 -17
- package/src/viewer/components/StoryRenderer.tsx +2 -2
- package/src/viewer/components/TokenStylePanel.tsx +1 -1
- package/src/viewer/components/UsageSection.tsx +2 -2
- package/src/viewer/components/VariantMatrix.tsx +11 -11
- package/src/viewer/components/VariantRenderer.tsx +3 -3
- package/src/viewer/components/VariantTabs.tsx +2 -2
- package/src/viewer/components/_future/CreatePage.tsx +6 -6
- package/src/viewer/composition-renderer.ts +11 -11
- package/src/viewer/entry.tsx +40 -40
- package/src/viewer/hooks/useFigmaIntegration.ts +1 -1
- package/src/viewer/hooks/usePreviewBridge.ts +5 -5
- package/src/viewer/hooks/useUrlState.ts +6 -6
- package/src/viewer/index.ts +2 -2
- package/src/viewer/intelligence/healthReport.ts +17 -17
- package/src/viewer/intelligence/styleDrift.ts +1 -1
- package/src/viewer/intelligence/usageScanner.ts +1 -1
- package/src/viewer/render-template.html +1 -1
- package/src/viewer/render-utils.ts +21 -21
- package/src/viewer/server.ts +18 -18
- package/src/viewer/utils/detectRelationships.ts +22 -22
- package/src/viewer/vite-plugin.ts +213 -213
- package/dist/chunk-6JBGU74P.js.map +0 -1
- package/dist/chunk-7OPWMLOE.js.map +0 -1
- package/dist/chunk-CVXKXVOY.js.map +0 -1
- package/dist/chunk-NWQ4CJOQ.js.map +0 -1
- package/dist/chunk-RVRTRESS.js.map +0 -1
- package/dist/chunk-TJ34N7C7.js.map +0 -1
- package/dist/chunk-XHUDJNN3.js.map +0 -1
- package/dist/generate-LMTISDIJ.js.map +0 -1
- package/dist/scan-WY23TJCP.js +0 -12
- package/dist/test-OJRXNDO2.js.map +0 -1
- package/dist/viewer-SUFOISZM.js.map +0 -1
- package/src/shared/segment-loader.ts +0 -59
- /package/dist/{core-W2HYIQW6.js.map → core-SFHPYR5H.js.map} +0 -0
- /package/dist/{scan-WY23TJCP.js.map → scan-KQBKUS64.js.map} +0 -0
- /package/dist/{service-T2L7VLTE.js.map → service-ED2LNCTU.js.map} +0 -0
- /package/dist/{static-viewer-GBR7YNF3.js.map → static-viewer-Q4F4QP5M.js.map} +0 -0
- /package/dist/{tokens-3BWDESVM.js.map → tokens-P2B7ZAM3.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __banner_createRequire } from 'module'; const require
|
|
|
2
2
|
import {
|
|
3
3
|
BRAND,
|
|
4
4
|
DEFAULTS
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GHYYFAQN.js";
|
|
6
6
|
|
|
7
7
|
// src/service/browser-pool.ts
|
|
8
8
|
import { chromium } from "playwright";
|
|
@@ -1475,22 +1475,22 @@ function createFigmaClient(accessToken) {
|
|
|
1475
1475
|
|
|
1476
1476
|
// src/service/analytics.ts
|
|
1477
1477
|
function analyzeDesignSystem(data) {
|
|
1478
|
-
const
|
|
1478
|
+
const fragments = Object.values(data.fragments);
|
|
1479
1479
|
const analyzedAt = /* @__PURE__ */ new Date();
|
|
1480
|
-
const summaries =
|
|
1481
|
-
const coverage = calculateCoverage(
|
|
1482
|
-
const quality = calculateQuality(
|
|
1483
|
-
const distribution = buildDistribution(
|
|
1480
|
+
const summaries = fragments.map((s) => buildComponentSummary(s));
|
|
1481
|
+
const coverage = calculateCoverage(fragments, summaries);
|
|
1482
|
+
const quality = calculateQuality(fragments, summaries);
|
|
1483
|
+
const distribution = buildDistribution(fragments, summaries);
|
|
1484
1484
|
const inventory = buildInventory(summaries);
|
|
1485
1485
|
const recommendations = generateRecommendations(coverage, quality, summaries);
|
|
1486
1486
|
const overallScore = calculateOverallScore(coverage, quality, summaries);
|
|
1487
|
-
const categories = [...new Set(
|
|
1487
|
+
const categories = [...new Set(fragments.map((s) => s.meta.category))].sort();
|
|
1488
1488
|
return {
|
|
1489
1489
|
analyzedAt,
|
|
1490
1490
|
summary: {
|
|
1491
|
-
totalComponents:
|
|
1492
|
-
totalVariants:
|
|
1493
|
-
totalProps:
|
|
1491
|
+
totalComponents: fragments.length,
|
|
1492
|
+
totalVariants: fragments.reduce((sum, s) => sum + s.variants.length, 0),
|
|
1493
|
+
totalProps: fragments.reduce(
|
|
1494
1494
|
(sum, s) => sum + Object.keys(s.props ?? {}).length,
|
|
1495
1495
|
0
|
|
1496
1496
|
),
|
|
@@ -1504,16 +1504,16 @@ function analyzeDesignSystem(data) {
|
|
|
1504
1504
|
recommendations
|
|
1505
1505
|
};
|
|
1506
1506
|
}
|
|
1507
|
-
function buildComponentSummary(
|
|
1508
|
-
const propCount = Object.keys(
|
|
1509
|
-
const hasUsageWhen = (
|
|
1510
|
-
const hasUsageWhenNot = (
|
|
1511
|
-
const hasGuidelines = (
|
|
1512
|
-
const hasRelations = (
|
|
1507
|
+
function buildComponentSummary(fragment) {
|
|
1508
|
+
const propCount = Object.keys(fragment.props ?? {}).length;
|
|
1509
|
+
const hasUsageWhen = (fragment.usage?.when?.length ?? 0) > 0;
|
|
1510
|
+
const hasUsageWhenNot = (fragment.usage?.whenNot?.length ?? 0) > 0;
|
|
1511
|
+
const hasGuidelines = (fragment.usage?.guidelines?.length ?? 0) > 0;
|
|
1512
|
+
const hasRelations = (fragment.relations?.length ?? 0) > 0;
|
|
1513
1513
|
let docScore = 0;
|
|
1514
1514
|
let docTotal = 0;
|
|
1515
1515
|
docTotal += 20;
|
|
1516
|
-
if (
|
|
1516
|
+
if (fragment.meta.description && fragment.meta.description.length > 20) {
|
|
1517
1517
|
docScore += 20;
|
|
1518
1518
|
}
|
|
1519
1519
|
docTotal += 20;
|
|
@@ -1526,7 +1526,7 @@ function buildComponentSummary(segment) {
|
|
|
1526
1526
|
if (hasRelations) docScore += 10;
|
|
1527
1527
|
docTotal += 15;
|
|
1528
1528
|
if (propCount > 0) {
|
|
1529
|
-
const documentedProps = Object.values(
|
|
1529
|
+
const documentedProps = Object.values(fragment.props ?? {}).filter(
|
|
1530
1530
|
(p) => p.description && p.description.length > 5
|
|
1531
1531
|
).length;
|
|
1532
1532
|
docScore += Math.round(documentedProps / propCount * 15);
|
|
@@ -1534,10 +1534,10 @@ function buildComponentSummary(segment) {
|
|
|
1534
1534
|
docScore += 15;
|
|
1535
1535
|
}
|
|
1536
1536
|
return {
|
|
1537
|
-
name:
|
|
1538
|
-
category:
|
|
1539
|
-
status:
|
|
1540
|
-
variantCount:
|
|
1537
|
+
name: fragment.meta.name,
|
|
1538
|
+
category: fragment.meta.category,
|
|
1539
|
+
status: fragment.meta.status ?? "stable",
|
|
1540
|
+
variantCount: fragment.variants.length,
|
|
1541
1541
|
propCount,
|
|
1542
1542
|
hasUsageWhen,
|
|
1543
1543
|
hasUsageWhenNot,
|
|
@@ -1546,11 +1546,11 @@ function buildComponentSummary(segment) {
|
|
|
1546
1546
|
documentationScore: Math.round(docScore / docTotal * 100)
|
|
1547
1547
|
};
|
|
1548
1548
|
}
|
|
1549
|
-
function calculateCoverage(
|
|
1550
|
-
const total =
|
|
1549
|
+
function calculateCoverage(fragments, summaries) {
|
|
1550
|
+
const total = fragments.length;
|
|
1551
1551
|
const fields = {
|
|
1552
1552
|
description: {
|
|
1553
|
-
covered:
|
|
1553
|
+
covered: fragments.filter(
|
|
1554
1554
|
(s) => s.meta.description && s.meta.description.length > 10
|
|
1555
1555
|
).length,
|
|
1556
1556
|
total,
|
|
@@ -1572,7 +1572,7 @@ function calculateCoverage(segments, summaries) {
|
|
|
1572
1572
|
percentage: 0
|
|
1573
1573
|
},
|
|
1574
1574
|
accessibility: {
|
|
1575
|
-
covered:
|
|
1575
|
+
covered: fragments.filter((s) => (s.usage?.accessibility?.length ?? 0) > 0).length,
|
|
1576
1576
|
total,
|
|
1577
1577
|
percentage: 0
|
|
1578
1578
|
},
|
|
@@ -1592,8 +1592,8 @@ function calculateCoverage(segments, summaries) {
|
|
|
1592
1592
|
percentage: 0
|
|
1593
1593
|
}
|
|
1594
1594
|
};
|
|
1595
|
-
for (const
|
|
1596
|
-
const props = Object.values(
|
|
1595
|
+
for (const fragment of fragments) {
|
|
1596
|
+
const props = Object.values(fragment.props ?? {});
|
|
1597
1597
|
fields.propDescriptions.total += props.length;
|
|
1598
1598
|
fields.propConstraints.total += props.length;
|
|
1599
1599
|
fields.propDescriptions.covered += props.filter(
|
|
@@ -1622,21 +1622,21 @@ function calculateCoverage(segments, summaries) {
|
|
|
1622
1622
|
);
|
|
1623
1623
|
return { overall, fields, incomplete };
|
|
1624
1624
|
}
|
|
1625
|
-
function calculateQuality(
|
|
1625
|
+
function calculateQuality(fragments, summaries) {
|
|
1626
1626
|
const missingWhenNot = summaries.filter((s) => !s.hasUsageWhenNot).map((s) => s.name);
|
|
1627
1627
|
const isolated = summaries.filter((s) => !s.hasRelations).map((s) => s.name);
|
|
1628
1628
|
const deprecated = summaries.filter((s) => s.status === "deprecated").map((s) => s.name);
|
|
1629
1629
|
const fewVariants = summaries.filter((s) => s.variantCount < 2).map((s) => s.name);
|
|
1630
1630
|
const undocumentedProps = [];
|
|
1631
1631
|
const unconstrainedProps = [];
|
|
1632
|
-
for (const
|
|
1633
|
-
for (const [propName, prop] of Object.entries(
|
|
1632
|
+
for (const fragment of fragments) {
|
|
1633
|
+
for (const [propName, prop] of Object.entries(fragment.props ?? {})) {
|
|
1634
1634
|
if (!prop.description || prop.description.length < 5) {
|
|
1635
|
-
undocumentedProps.push({ component:
|
|
1635
|
+
undocumentedProps.push({ component: fragment.meta.name, prop: propName });
|
|
1636
1636
|
}
|
|
1637
1637
|
if ((prop.constraints?.length ?? 0) === 0 && prop.type !== "boolean" && prop.type !== "function") {
|
|
1638
1638
|
unconstrainedProps.push({
|
|
1639
|
-
component:
|
|
1639
|
+
component: fragment.meta.name,
|
|
1640
1640
|
prop: propName
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
@@ -1651,7 +1651,7 @@ function calculateQuality(segments, summaries) {
|
|
|
1651
1651
|
unconstrainedProps
|
|
1652
1652
|
};
|
|
1653
1653
|
}
|
|
1654
|
-
function buildDistribution(
|
|
1654
|
+
function buildDistribution(fragments, summaries) {
|
|
1655
1655
|
const variantsPerComponent = summaries.map((s) => ({ name: s.name, count: s.variantCount })).sort((a, b) => b.count - a.count);
|
|
1656
1656
|
const propsPerComponent = summaries.map((s) => ({ name: s.name, count: s.propCount })).sort((a, b) => b.count - a.count);
|
|
1657
1657
|
const categoryMap = /* @__PURE__ */ new Map();
|
|
@@ -1665,8 +1665,8 @@ function buildDistribution(segments, summaries) {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
const statusDistribution = Array.from(statusMap.entries()).map(([status, count]) => ({ status, count })).sort((a, b) => b.count - a.count);
|
|
1667
1667
|
const tagMap = /* @__PURE__ */ new Map();
|
|
1668
|
-
for (const
|
|
1669
|
-
for (const tag of
|
|
1668
|
+
for (const fragment of fragments) {
|
|
1669
|
+
for (const tag of fragment.meta.tags ?? []) {
|
|
1670
1670
|
tagMap.set(tag, (tagMap.get(tag) ?? 0) + 1);
|
|
1671
1671
|
}
|
|
1672
1672
|
}
|
|
@@ -4726,7 +4726,7 @@ var DEFAULT_EXCLUDE = [
|
|
|
4726
4726
|
"**/*.test.*",
|
|
4727
4727
|
"**/*.spec.*",
|
|
4728
4728
|
"**/*.stories.*",
|
|
4729
|
-
"**/*.
|
|
4729
|
+
"**/*.fragment.*",
|
|
4730
4730
|
"**/storybook-static/**"
|
|
4731
4731
|
];
|
|
4732
4732
|
async function scanCodebase(options) {
|
|
@@ -6206,7 +6206,7 @@ function inferComponentName2(filePath) {
|
|
|
6206
6206
|
}
|
|
6207
6207
|
return name;
|
|
6208
6208
|
}
|
|
6209
|
-
function
|
|
6209
|
+
function convertToFragmentProps(props) {
|
|
6210
6210
|
const result = {};
|
|
6211
6211
|
for (const prop of props) {
|
|
6212
6212
|
const definition = {
|
|
@@ -6627,7 +6627,7 @@ export {
|
|
|
6627
6627
|
generateUserPrompt,
|
|
6628
6628
|
extractPropsFromFile,
|
|
6629
6629
|
extractPropsFromSource,
|
|
6630
|
-
|
|
6630
|
+
convertToFragmentProps,
|
|
6631
6631
|
extractPropsForComponent,
|
|
6632
6632
|
extractAllComponentProps,
|
|
6633
6633
|
renderVariants,
|
|
@@ -6635,4 +6635,4 @@ export {
|
|
|
6635
6635
|
getStorybookStoryIds,
|
|
6636
6636
|
renderAllComponentVariants
|
|
6637
6637
|
};
|
|
6638
|
-
//# sourceMappingURL=chunk-
|
|
6638
|
+
//# sourceMappingURL=chunk-GKX2HPZ6.js.map
|