@usefragments/core 1.0.0

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-243QYRUF.js +2145 -0
  3. package/dist/chunk-243QYRUF.js.map +1 -0
  4. package/dist/chunk-3LLRNCPX.js +111 -0
  5. package/dist/chunk-3LLRNCPX.js.map +1 -0
  6. package/dist/chunk-EIYNNS77.js +48 -0
  7. package/dist/chunk-EIYNNS77.js.map +1 -0
  8. package/dist/chunk-JNBFJ34I.js +326 -0
  9. package/dist/chunk-JNBFJ34I.js.map +1 -0
  10. package/dist/chunk-R3X7UBHU.js +228 -0
  11. package/dist/chunk-R3X7UBHU.js.map +1 -0
  12. package/dist/chunk-SH4KPIYH.js +393 -0
  13. package/dist/chunk-SH4KPIYH.js.map +1 -0
  14. package/dist/chunk-V4VQB57N.js +56 -0
  15. package/dist/chunk-V4VQB57N.js.map +1 -0
  16. package/dist/chunk-X34IA4LR.js +319 -0
  17. package/dist/chunk-X34IA4LR.js.map +1 -0
  18. package/dist/chunk-YF65VYRY.js +493 -0
  19. package/dist/chunk-YF65VYRY.js.map +1 -0
  20. package/dist/codes/index.d.ts +40 -0
  21. package/dist/codes/index.js +23 -0
  22. package/dist/codes/index.js.map +1 -0
  23. package/dist/compiled-types/index.d.ts +5 -0
  24. package/dist/compiled-types/index.js +1 -0
  25. package/dist/compiled-types/index.js.map +1 -0
  26. package/dist/generate/index.d.ts +47 -0
  27. package/dist/generate/index.js +11 -0
  28. package/dist/generate/index.js.map +1 -0
  29. package/dist/governance-BOa3KyiJ.d.ts +3279 -0
  30. package/dist/graph/index.d.ts +66 -0
  31. package/dist/graph/index.js +17 -0
  32. package/dist/graph/index.js.map +1 -0
  33. package/dist/index.d.ts +11388 -0
  34. package/dist/index.js +8711 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/package-identity.d.ts +42 -0
  37. package/dist/package-identity.js +23 -0
  38. package/dist/package-identity.js.map +1 -0
  39. package/dist/preview/index.d.ts +484 -0
  40. package/dist/preview/index.js +1129 -0
  41. package/dist/preview/index.js.map +1 -0
  42. package/dist/react-types.d.ts +22 -0
  43. package/dist/react-types.js +1 -0
  44. package/dist/react-types.js.map +1 -0
  45. package/dist/registry.d.ts +2367 -0
  46. package/dist/registry.js +62 -0
  47. package/dist/registry.js.map +1 -0
  48. package/dist/schemas/index.d.ts +2584 -0
  49. package/dist/schemas/index.js +55 -0
  50. package/dist/schemas/index.js.map +1 -0
  51. package/dist/severity.d.ts +18 -0
  52. package/dist/severity.js +27 -0
  53. package/dist/severity.js.map +1 -0
  54. package/dist/test-utils.d.ts +14 -0
  55. package/dist/test-utils.js +63 -0
  56. package/dist/test-utils.js.map +1 -0
  57. package/dist/topology/index.d.ts +48 -0
  58. package/dist/topology/index.js +7 -0
  59. package/dist/topology/index.js.map +1 -0
  60. package/dist/types-xJ2xyp_G.d.ts +119 -0
  61. package/package.json +120 -0
  62. package/src/__tests__/contract-parser.test.ts +614 -0
  63. package/src/__tests__/dtcg-generators.test.ts +439 -0
  64. package/src/__tests__/dtcg-parser.test.ts +884 -0
  65. package/src/__tests__/preview-runtime.test.tsx +111 -0
  66. package/src/__tests__/schema.test.ts +31 -0
  67. package/src/__tests__/severity.test.ts +34 -0
  68. package/src/__tests__/style-comparison.test.ts +662 -0
  69. package/src/__tests__/tokens-compat.test.ts +51 -0
  70. package/src/agent-format.test.ts +105 -0
  71. package/src/agent-format.ts +141 -0
  72. package/src/bundle.ts +149 -0
  73. package/src/codes/__tests__/codes.test.ts +73 -0
  74. package/src/codes/codes.ts +463 -0
  75. package/src/codes/index.ts +7 -0
  76. package/src/codes/source-finding-bridge.ts +113 -0
  77. package/src/compiled-types/index.ts +293 -0
  78. package/src/component-contract.ts +231 -0
  79. package/src/component-discovery.ts +80 -0
  80. package/src/composition.test.ts +262 -0
  81. package/src/composition.ts +318 -0
  82. package/src/config-paths.test.ts +78 -0
  83. package/src/config-paths.ts +47 -0
  84. package/src/config.ts +18 -0
  85. package/src/conform-prove.test.ts +274 -0
  86. package/src/conform-prove.ts +326 -0
  87. package/src/conform.ts +160 -0
  88. package/src/constants.ts +114 -0
  89. package/src/context.ts +2 -0
  90. package/src/contract/fixture.ts +110 -0
  91. package/src/contract/hash.test.ts +86 -0
  92. package/src/contract/hash.ts +195 -0
  93. package/src/contract/index.ts +43 -0
  94. package/src/contract/preimage.test.ts +254 -0
  95. package/src/contract/preimage.ts +365 -0
  96. package/src/contract/stamp.test.ts +100 -0
  97. package/src/contract/stamp.ts +105 -0
  98. package/src/contract-parser.ts +141 -0
  99. package/src/defineFragment.test.ts +257 -0
  100. package/src/defineFragment.ts +293 -0
  101. package/src/dtcg-generators.ts +324 -0
  102. package/src/dtcg-parser.ts +1 -0
  103. package/src/dtcg.ts +237 -0
  104. package/src/facts/__snapshots__/facts.test.ts.snap +124 -0
  105. package/src/facts/builders.ts +835 -0
  106. package/src/facts/compile.ts +422 -0
  107. package/src/facts/fact-index.ts +394 -0
  108. package/src/facts/facts.test.ts +494 -0
  109. package/src/facts/ids.ts +125 -0
  110. package/src/facts/index.ts +119 -0
  111. package/src/facts/types.ts +614 -0
  112. package/src/figma.ts +263 -0
  113. package/src/fragment-types.ts +214 -0
  114. package/src/generate/generate.test.ts +594 -0
  115. package/src/generate/index.ts +438 -0
  116. package/src/governance-integrity.test.ts +186 -0
  117. package/src/governance-integrity.ts +282 -0
  118. package/src/governance.test.ts +300 -0
  119. package/src/governance.ts +605 -0
  120. package/src/governance.type-test.ts +75 -0
  121. package/src/graph/engine.ts +446 -0
  122. package/src/graph/graph.test.ts +746 -0
  123. package/src/graph/index.ts +32 -0
  124. package/src/graph/serialization.ts +55 -0
  125. package/src/graph/types.ts +178 -0
  126. package/src/index.ts +891 -0
  127. package/src/local-canonical.ts +102 -0
  128. package/src/mcp-snapshot.ts +222 -0
  129. package/src/package-identity-match.ts +33 -0
  130. package/src/package-identity.generated.ts +233 -0
  131. package/src/package-identity.test.ts +99 -0
  132. package/src/package-identity.ts +157 -0
  133. package/src/performance-presets.ts +142 -0
  134. package/src/preview/comparison-artifact.test.ts +228 -0
  135. package/src/preview/comparison-artifact.ts +181 -0
  136. package/src/preview/comparison-context.ts +93 -0
  137. package/src/preview/comparison-evidence.ts +112 -0
  138. package/src/preview/comparison-format.ts +21 -0
  139. package/src/preview/comparison-presentation.ts +187 -0
  140. package/src/preview/comparison-references.test.ts +430 -0
  141. package/src/preview/comparison-references.ts +72 -0
  142. package/src/preview/comparison-score.ts +59 -0
  143. package/src/preview/comparison-styles.ts +197 -0
  144. package/src/preview/comparison.test.ts +559 -0
  145. package/src/preview/comparison.ts +488 -0
  146. package/src/preview/index.ts +10 -0
  147. package/src/preview/types.ts +309 -0
  148. package/src/preview/validation.test.ts +290 -0
  149. package/src/preview/validation.ts +356 -0
  150. package/src/preview-runtime.tsx +144 -0
  151. package/src/raw-html-canonical.test.ts +41 -0
  152. package/src/raw-html-canonical.ts +179 -0
  153. package/src/react-types.ts +21 -0
  154. package/src/registry-install-plan.ts +344 -0
  155. package/src/registry.test.ts +245 -0
  156. package/src/registry.ts +369 -0
  157. package/src/rules/a11y-required-accessible-name.ts +93 -0
  158. package/src/rules/color-math.test.ts +72 -0
  159. package/src/rules/color-math.ts +192 -0
  160. package/src/rules/components-forbidden-prop-value.ts +108 -0
  161. package/src/rules/components-prefer-library.ts +943 -0
  162. package/src/rules/components-unknown-prop.ts +94 -0
  163. package/src/rules/composition-pattern-schema.ts +125 -0
  164. package/src/rules/composition-pattern.test.ts +320 -0
  165. package/src/rules/composition-pattern.ts +271 -0
  166. package/src/rules/emit-gate.test.ts +42 -0
  167. package/src/rules/emit-gate.ts +60 -0
  168. package/src/rules/finding.ts +54 -0
  169. package/src/rules/index.ts +235 -0
  170. package/src/rules/jsx-preferred-component.ts +68 -0
  171. package/src/rules/jsx-preferred-import-path.ts +67 -0
  172. package/src/rules/presets.ts +57 -0
  173. package/src/rules/props-invalid-value.ts +115 -0
  174. package/src/rules/rules.test.ts +3636 -0
  175. package/src/rules/spacing-resolution.ts +184 -0
  176. package/src/rules/styles-no-raw-color.ts +329 -0
  177. package/src/rules/styles-no-raw-dimensions.ts +357 -0
  178. package/src/rules/styles-no-raw-spacing.ts +236 -0
  179. package/src/rules/styles-no-raw-typography.ts +237 -0
  180. package/src/rules/tailwind-arbitrary-color.test.ts +128 -0
  181. package/src/rules/tailwind-arbitrary-color.ts +93 -0
  182. package/src/rules/tailwind-arbitrary-spacing.test.ts +157 -0
  183. package/src/rules/tailwind-arbitrary-spacing.ts +120 -0
  184. package/src/rules/tailwind-forbidden-palette.test.ts +116 -0
  185. package/src/rules/tailwind-forbidden-palette.ts +107 -0
  186. package/src/rules/tailwind-off-scale-spacing-token.test.ts +100 -0
  187. package/src/rules/tailwind-off-scale-spacing-token.ts +108 -0
  188. package/src/rules/tailwind-raw-color-via-token.test.ts +108 -0
  189. package/src/rules/tailwind-raw-color-via-token.ts +82 -0
  190. package/src/rules/tailwind-rule-utils.ts +106 -0
  191. package/src/rules/tailwind-unknown-class.test.ts +157 -0
  192. package/src/rules/tailwind-unknown-class.ts +121 -0
  193. package/src/rules/taxonomy.test.ts +238 -0
  194. package/src/rules/theme-no-theme-coupled-literal.ts +132 -0
  195. package/src/rules/tiers.ts +111 -0
  196. package/src/rules/tokens-css-vars-must-be-defined.test.ts +244 -0
  197. package/src/rules/tokens-css-vars-must-be-defined.ts +156 -0
  198. package/src/rules/tokens-require-dual-fallback.ts +78 -0
  199. package/src/rules/types.ts +27 -0
  200. package/src/rules/utils.test.ts +110 -0
  201. package/src/rules/utils.ts +599 -0
  202. package/src/schema.ts +427 -0
  203. package/src/schemas/index.ts +275 -0
  204. package/src/schemas/schemas.test.ts +124 -0
  205. package/src/severity.ts +54 -0
  206. package/src/storyAdapter.test.ts +571 -0
  207. package/src/storyAdapter.ts +761 -0
  208. package/src/storyFilters.test.ts +350 -0
  209. package/src/storyFilters.ts +253 -0
  210. package/src/storybook-csf.ts +11 -0
  211. package/src/style-comparison.ts +423 -0
  212. package/src/test-utils.ts +68 -0
  213. package/src/token-parser.ts +2 -0
  214. package/src/token-types.ts +287 -0
  215. package/src/tokens/categories.ts +131 -0
  216. package/src/tokens/color.ts +193 -0
  217. package/src/tokens/design-token-parser.test.ts +159 -0
  218. package/src/tokens/design-token-parser.ts +402 -0
  219. package/src/tokens/dtcg.ts +428 -0
  220. package/src/tokens/index.ts +130 -0
  221. package/src/tokens/lookup.ts +19 -0
  222. package/src/tokens/scss.ts +171 -0
  223. package/src/tokens/tailwind-v4.ts +187 -0
  224. package/src/tokens/types.ts +43 -0
  225. package/src/topology/index.ts +9 -0
  226. package/src/topology/resolve-area.test.ts +174 -0
  227. package/src/topology/resolve-area.ts +215 -0
  228. package/src/types.ts +1057 -0
@@ -0,0 +1,55 @@
1
+ import {
2
+ agentFindingSchema,
3
+ agentFormatSchema,
4
+ agentPlanSchema,
5
+ factEvidenceSchema,
6
+ factLocationSchema,
7
+ findingFixSchema,
8
+ findingReplaceClassTokenFixSchema,
9
+ findingReplaceComponentFixSchema,
10
+ findingReplaceImportFixSchema,
11
+ findingReplacePropValueFixSchema,
12
+ findingReplaceStyleValueFixSchema,
13
+ findingSchema,
14
+ fixSchema,
15
+ governanceVerdictMetadataSchema,
16
+ governanceVerdictSchema,
17
+ normalizeFinding,
18
+ normalizeSeverity,
19
+ normalizeViolation,
20
+ suppressionDirectiveSchema,
21
+ validatorResultSchema,
22
+ violationSchema
23
+ } from "../chunk-R3X7UBHU.js";
24
+ import {
25
+ legacySeverityLevelSchema,
26
+ severityLevelSchema,
27
+ severitySchema
28
+ } from "../chunk-V4VQB57N.js";
29
+ export {
30
+ agentFindingSchema,
31
+ agentFormatSchema,
32
+ agentPlanSchema,
33
+ factEvidenceSchema,
34
+ factLocationSchema,
35
+ findingFixSchema,
36
+ findingReplaceClassTokenFixSchema,
37
+ findingReplaceComponentFixSchema,
38
+ findingReplaceImportFixSchema,
39
+ findingReplacePropValueFixSchema,
40
+ findingReplaceStyleValueFixSchema,
41
+ findingSchema,
42
+ fixSchema,
43
+ governanceVerdictMetadataSchema,
44
+ governanceVerdictSchema,
45
+ legacySeverityLevelSchema,
46
+ normalizeFinding,
47
+ normalizeSeverity,
48
+ normalizeViolation,
49
+ severityLevelSchema,
50
+ severitySchema,
51
+ suppressionDirectiveSchema,
52
+ validatorResultSchema,
53
+ violationSchema
54
+ };
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const severitySchema: z.ZodEnum<["critical", "serious", "moderate", "minor"]>;
4
+ type Severity = z.infer<typeof severitySchema>;
5
+ declare const severityLevelSchema: z.ZodEnum<["error", "warn"]>;
6
+ type SeverityLevel = z.infer<typeof severityLevelSchema>;
7
+ declare const legacySeverityLevelSchema: z.ZodEnum<["error", "warn", "info", "warning"]>;
8
+ type LegacySeverityLevel = z.infer<typeof legacySeverityLevelSchema>;
9
+ declare const SEVERITIES: ["critical", "serious", "moderate", "minor"];
10
+ declare const SEVERITY_WEIGHTS: Record<Severity, number>;
11
+ declare const SEVERITY_RANK: Record<Severity, number>;
12
+ declare function severityLevel(severity: Severity): SeverityLevel;
13
+ declare function severityFromLevel(level: LegacySeverityLevel): Severity;
14
+ declare function compareSeverity(a: Severity, b: Severity): number;
15
+ declare function maxSeverity(a: Severity, b: Severity): Severity;
16
+ declare function sortBySeverity<T>(items: readonly T[], getSeverity: (item: T) => Severity): T[];
17
+
18
+ export { type LegacySeverityLevel, SEVERITIES, SEVERITY_RANK, SEVERITY_WEIGHTS, type Severity, type SeverityLevel, compareSeverity, legacySeverityLevelSchema, maxSeverity, severityFromLevel, severityLevel, severityLevelSchema, severitySchema, sortBySeverity };
@@ -0,0 +1,27 @@
1
+ import {
2
+ SEVERITIES,
3
+ SEVERITY_RANK,
4
+ SEVERITY_WEIGHTS,
5
+ compareSeverity,
6
+ legacySeverityLevelSchema,
7
+ maxSeverity,
8
+ severityFromLevel,
9
+ severityLevel,
10
+ severityLevelSchema,
11
+ severitySchema,
12
+ sortBySeverity
13
+ } from "./chunk-V4VQB57N.js";
14
+ export {
15
+ SEVERITIES,
16
+ SEVERITY_RANK,
17
+ SEVERITY_WEIGHTS,
18
+ compareSeverity,
19
+ legacySeverityLevelSchema,
20
+ maxSeverity,
21
+ severityFromLevel,
22
+ severityLevel,
23
+ severityLevelSchema,
24
+ severitySchema,
25
+ sortBySeverity
26
+ };
27
+ //# sourceMappingURL=severity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,14 @@
1
+ import { C as CompiledBlock, b as CompiledFragment } from './governance-BOa3KyiJ.js';
2
+ import 'zod';
3
+ import 'react';
4
+ import './topology/index.js';
5
+ import './types-xJ2xyp_G.js';
6
+
7
+ /**
8
+ * Shared factory builders for compiled-fragment tests.
9
+ */
10
+
11
+ declare function makeCompiledFragment(overrides?: Partial<CompiledFragment>): CompiledFragment;
12
+ declare function makeCompiledBlock(overrides?: Partial<CompiledBlock>): CompiledBlock;
13
+
14
+ export { makeCompiledBlock, makeCompiledFragment };
@@ -0,0 +1,63 @@
1
+ // src/test-utils.ts
2
+ function makeCompiledFragment(overrides = {}) {
3
+ return {
4
+ filePath: "src/components/Button/Button.fragment.tsx",
5
+ meta: {
6
+ name: "Button",
7
+ description: "A clickable button element",
8
+ category: "actions",
9
+ status: "stable",
10
+ tags: ["interactive"],
11
+ ...overrides.meta
12
+ },
13
+ usage: {
14
+ when: ["Triggering an action", "Submitting a form"],
15
+ whenNot: ["Navigating to another page"],
16
+ ...overrides.usage
17
+ },
18
+ props: overrides.props ?? {
19
+ variant: {
20
+ type: "enum",
21
+ values: ["primary", "secondary", "ghost"],
22
+ default: "primary",
23
+ description: "Visual style variant"
24
+ },
25
+ size: {
26
+ type: "enum",
27
+ values: ["sm", "md", "lg"],
28
+ default: "md",
29
+ description: "Button size"
30
+ },
31
+ disabled: {
32
+ type: "boolean",
33
+ default: false,
34
+ description: "Whether the button is disabled"
35
+ }
36
+ },
37
+ variants: overrides.variants ?? [
38
+ { name: "Primary", description: "Default primary button", code: "<Button>Click</Button>" },
39
+ { name: "Secondary", description: "Secondary variant", code: '<Button variant="secondary">Click</Button>' }
40
+ ],
41
+ relations: overrides.relations,
42
+ contract: overrides.contract,
43
+ ai: overrides.ai,
44
+ _generated: overrides._generated
45
+ };
46
+ }
47
+ function makeCompiledBlock(overrides = {}) {
48
+ return {
49
+ filePath: "src/blocks/LoginForm.block.ts",
50
+ name: "Login Form",
51
+ description: "A standard login form with email and password fields",
52
+ category: "authentication",
53
+ components: ["Input", "Button"],
54
+ code: '<form>\n <Input label="Email" />\n <Input label="Password" type="password" />\n <Button>Sign In</Button>\n</form>',
55
+ tags: ["auth", "form"],
56
+ ...overrides
57
+ };
58
+ }
59
+ export {
60
+ makeCompiledBlock,
61
+ makeCompiledFragment
62
+ };
63
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/test-utils.ts"],"sourcesContent":["/**\n * Shared factory builders for compiled-fragment tests.\n */\n\nimport type { CompiledFragment, CompiledBlock } from \"./compiled-types/index.js\";\n\nexport function makeCompiledFragment(\n overrides: Partial<CompiledFragment> = {},\n): CompiledFragment {\n return {\n filePath: \"src/components/Button/Button.fragment.tsx\",\n meta: {\n name: \"Button\",\n description: \"A clickable button element\",\n category: \"actions\",\n status: \"stable\",\n tags: [\"interactive\"],\n ...overrides.meta,\n },\n usage: {\n when: [\"Triggering an action\", \"Submitting a form\"],\n whenNot: [\"Navigating to another page\"],\n ...overrides.usage,\n },\n props: overrides.props ?? {\n variant: {\n type: \"enum\",\n values: [\"primary\", \"secondary\", \"ghost\"],\n default: \"primary\",\n description: \"Visual style variant\",\n },\n size: {\n type: \"enum\",\n values: [\"sm\", \"md\", \"lg\"],\n default: \"md\",\n description: \"Button size\",\n },\n disabled: {\n type: \"boolean\",\n default: false,\n description: \"Whether the button is disabled\",\n },\n },\n variants: overrides.variants ?? [\n { name: \"Primary\", description: \"Default primary button\", code: \"<Button>Click</Button>\" },\n { name: \"Secondary\", description: \"Secondary variant\", code: '<Button variant=\"secondary\">Click</Button>' },\n ],\n relations: overrides.relations,\n contract: overrides.contract,\n ai: overrides.ai,\n _generated: overrides._generated,\n };\n}\n\nexport function makeCompiledBlock(\n overrides: Partial<CompiledBlock> = {},\n): CompiledBlock {\n return {\n filePath: \"src/blocks/LoginForm.block.ts\",\n name: \"Login Form\",\n description: \"A standard login form with email and password fields\",\n category: \"authentication\",\n components: [\"Input\", \"Button\"],\n code: '<form>\\n <Input label=\"Email\" />\\n <Input label=\"Password\" type=\"password\" />\\n <Button>Sign In</Button>\\n</form>',\n tags: [\"auth\", \"form\"],\n ...overrides,\n };\n}\n"],"mappings":";AAMO,SAAS,qBACd,YAAuC,CAAC,GACtB;AAClB,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,MAAM,CAAC,aAAa;AAAA,MACpB,GAAG,UAAU;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACL,MAAM,CAAC,wBAAwB,mBAAmB;AAAA,MAClD,SAAS,CAAC,4BAA4B;AAAA,MACtC,GAAG,UAAU;AAAA,IACf;AAAA,IACA,OAAO,UAAU,SAAS;AAAA,MACxB,SAAS;AAAA,QACP,MAAM;AAAA,QACN,QAAQ,CAAC,WAAW,aAAa,OAAO;AAAA,QACxC,SAAS;AAAA,QACT,aAAa;AAAA,MACf;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ,CAAC,MAAM,MAAM,IAAI;AAAA,QACzB,SAAS;AAAA,QACT,aAAa;AAAA,MACf;AAAA,MACA,UAAU;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,UAAU,UAAU,YAAY;AAAA,MAC9B,EAAE,MAAM,WAAW,aAAa,0BAA0B,MAAM,yBAAyB;AAAA,MACzF,EAAE,MAAM,aAAa,aAAa,qBAAqB,MAAM,6CAA6C;AAAA,IAC5G;AAAA,IACA,WAAW,UAAU;AAAA,IACrB,UAAU,UAAU;AAAA,IACpB,IAAI,UAAU;AAAA,IACd,YAAY,UAAU;AAAA,EACxB;AACF;AAEO,SAAS,kBACd,YAAoC,CAAC,GACtB;AACf,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,IACV,YAAY,CAAC,SAAS,QAAQ;AAAA,IAC9B,MAAM;AAAA,IACN,MAAM,CAAC,QAAQ,MAAM;AAAA,IACrB,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Topology — map a repo-relative file path to its product area.
3
+ *
4
+ * This is the DRY keystone of the topology layer: the ONLY area-matching
5
+ * implementation in the monorepo. Consumers (CLI scan, Cloud managed-editor
6
+ * preview, cross-repo reconciliation) import it; none reimplements glob/area
7
+ * logic. Pure and browser-safe — no Node, no parser deps.
8
+ *
9
+ * See `apps/cloud/docs/topology/01-architecture.md §1`.
10
+ */
11
+ type AreaCriticality = "low" | "medium" | "high" | "revenue" | "regulated";
12
+ interface Area {
13
+ id: string;
14
+ name: string;
15
+ criticality: AreaCriticality;
16
+ owners: string[];
17
+ /** Globs matched against repo-relative file paths in v0. */
18
+ files: string[];
19
+ /** Stored for later route-topology adapters; NOT matched in v0. */
20
+ routes?: string[];
21
+ /** Tie-break: higher wins. Defaults to declaration order. */
22
+ priority?: number;
23
+ }
24
+ interface Topology {
25
+ /** Bump signals "re-tag" to consumers that cache. */
26
+ version: number;
27
+ /** Whether area file globs are matched relative to app.path or repo root. Defaults to "app". */
28
+ base?: "app" | "repo";
29
+ /** Array (not a keyed record) so precedence is deterministic. */
30
+ areas: Area[];
31
+ }
32
+ interface AreaMatch {
33
+ areaId: string;
34
+ areaName: string;
35
+ criticality: AreaCriticality;
36
+ owners: string[];
37
+ /** The winning pattern — surfaced in reports for transparency. */
38
+ matchedGlob: string;
39
+ }
40
+ /**
41
+ * Resolve the product area for a repo-relative path. First match by
42
+ * `(priority desc, declaration order)`. Returns `null` when nothing matches —
43
+ * the caller buckets that as the explicit "Unassigned" area (never dropped;
44
+ * dropping unmatched evidence would make coverage lie).
45
+ */
46
+ declare function resolveArea(repoRelPath: string, topology: Topology): AreaMatch | null;
47
+
48
+ export { type Area, type AreaCriticality, type AreaMatch, type Topology, resolveArea };
@@ -0,0 +1,7 @@
1
+ import {
2
+ resolveArea
3
+ } from "../chunk-3LLRNCPX.js";
4
+ export {
5
+ resolveArea
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Component Graph data model — types for the design-system-semantic relationship graph.
3
+ *
4
+ * These types describe nodes (components), edges (relationships), and health
5
+ * metrics that together give AI agents structural understanding of a design system.
6
+ */
7
+ type GraphEdgeType = 'imports' | 'hook-depends' | 'renders' | 'composes' | 'parent-of' | 'alternative-to' | 'sibling-of';
8
+ declare const GRAPH_EDGE_TYPES: readonly GraphEdgeType[];
9
+ /** Default weight for each edge type */
10
+ declare const EDGE_TYPE_WEIGHTS: Record<GraphEdgeType, number>;
11
+ interface ComponentNode {
12
+ name: string;
13
+ category: string;
14
+ status: string;
15
+ compositionPattern?: 'compound' | 'simple' | 'controlled' | 'wrapper';
16
+ subComponents?: string[];
17
+ }
18
+ interface GraphEdge {
19
+ source: string;
20
+ target: string;
21
+ type: GraphEdgeType;
22
+ weight: number;
23
+ note?: string;
24
+ /** Where this edge was detected from */
25
+ provenance: string;
26
+ }
27
+ interface GraphHealth {
28
+ /** Components with zero edges */
29
+ orphans: string[];
30
+ /** Top components by total degree (in + out) */
31
+ hubs: Array<{
32
+ name: string;
33
+ degree: number;
34
+ }>;
35
+ /** Percentage of components appearing in at least one block */
36
+ compositionCoverage: number;
37
+ /** Disconnected groups (BFS on undirected projection) */
38
+ connectedComponents: string[][];
39
+ /** Average degree across all nodes */
40
+ averageDegree: number;
41
+ /** Total node and edge counts */
42
+ nodeCount: number;
43
+ edgeCount: number;
44
+ }
45
+ interface ComponentGraph {
46
+ nodes: ComponentNode[];
47
+ edges: GraphEdge[];
48
+ health: GraphHealth;
49
+ }
50
+ interface ImpactResult {
51
+ /** The component that was changed */
52
+ component: string;
53
+ /** Components affected at each depth level */
54
+ affected: Array<{
55
+ component: string;
56
+ depth: number;
57
+ path: string[];
58
+ edgeType: GraphEdgeType;
59
+ }>;
60
+ /** Blocks that use the changed component or any affected component */
61
+ affectedBlocks: string[];
62
+ /** Total count of affected components */
63
+ totalAffected: number;
64
+ }
65
+ interface PathResult {
66
+ /** Whether a path exists */
67
+ found: boolean;
68
+ /** Nodes along the shortest path (including source and target) */
69
+ path: string[];
70
+ /** Edges along the shortest path */
71
+ edges: GraphEdge[];
72
+ }
73
+ interface NeighborResult {
74
+ /** The center component */
75
+ component: string;
76
+ /** All components reachable within maxHops */
77
+ neighbors: Array<{
78
+ component: string;
79
+ hops: number;
80
+ edgeType: GraphEdgeType;
81
+ }>;
82
+ }
83
+ interface CompositionTree {
84
+ /** The root component */
85
+ component: string;
86
+ /** Composition pattern */
87
+ compositionPattern?: 'compound' | 'simple' | 'controlled' | 'wrapper';
88
+ /** Direct sub-components */
89
+ subComponents: string[];
90
+ /** Components that declare this component as their parent */
91
+ children: string[];
92
+ /** Parent component (if this is a sub-component) */
93
+ parent?: string;
94
+ /** Sibling components at the same level */
95
+ siblings: string[];
96
+ /** Blocks that use this component */
97
+ blocks: string[];
98
+ }
99
+ interface SerializedEdge {
100
+ /** source */
101
+ s: string;
102
+ /** target */
103
+ t: string;
104
+ /** type */
105
+ ty: GraphEdgeType;
106
+ /** weight */
107
+ w: number;
108
+ /** note (optional) */
109
+ no?: string;
110
+ /** provenance */
111
+ p: string;
112
+ }
113
+ interface SerializedComponentGraph {
114
+ nodes: ComponentNode[];
115
+ edges: SerializedEdge[];
116
+ health: GraphHealth;
117
+ }
118
+
119
+ export { type ComponentGraph as C, EDGE_TYPE_WEIGHTS as E, type GraphEdgeType as G, type ImpactResult as I, type NeighborResult as N, type PathResult as P, type SerializedComponentGraph as S, type GraphEdge as a, type CompositionTree as b, type GraphHealth as c, type ComponentNode as d, GRAPH_EDGE_TYPES as e, type SerializedEdge as f };
package/package.json ADDED
@@ -0,0 +1,120 @@
1
+ {
2
+ "name": "@usefragments/core",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "description": "Core types, schemas, and runtime API for Fragments component definitions",
6
+ "author": "Conan McNicholl",
7
+ "homepage": "https://usefragments.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/fragments-sdk/fragments",
11
+ "directory": "packages/core"
12
+ },
13
+ "type": "module",
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json",
23
+ "./react": {
24
+ "types": "./dist/react-types.d.ts",
25
+ "import": "./dist/react-types.js"
26
+ },
27
+ "./compiled-types": {
28
+ "types": "./dist/compiled-types/index.d.ts",
29
+ "import": "./dist/compiled-types/index.js"
30
+ },
31
+ "./graph": {
32
+ "types": "./dist/graph/index.d.ts",
33
+ "import": "./dist/graph/index.js"
34
+ },
35
+ "./topology": {
36
+ "types": "./dist/topology/index.d.ts",
37
+ "import": "./dist/topology/index.js"
38
+ },
39
+ "./generate": {
40
+ "types": "./dist/generate/index.d.ts",
41
+ "import": "./dist/generate/index.js"
42
+ },
43
+ "./codes": {
44
+ "types": "./dist/codes/index.d.ts",
45
+ "import": "./dist/codes/index.js"
46
+ },
47
+ "./severity": {
48
+ "types": "./dist/severity.d.ts",
49
+ "import": "./dist/severity.js"
50
+ },
51
+ "./schemas": {
52
+ "types": "./dist/schemas/index.d.ts",
53
+ "import": "./dist/schemas/index.js"
54
+ },
55
+ "./registry": {
56
+ "types": "./dist/registry.d.ts",
57
+ "import": "./dist/registry.js"
58
+ },
59
+ "./preview": {
60
+ "types": "./dist/preview/index.d.ts",
61
+ "import": "./dist/preview/index.js"
62
+ },
63
+ "./package-identity": {
64
+ "types": "./dist/package-identity.d.ts",
65
+ "import": "./dist/package-identity.js"
66
+ },
67
+ "./test-utils": {
68
+ "types": "./dist/test-utils.d.ts",
69
+ "import": "./dist/test-utils.js"
70
+ }
71
+ },
72
+ "files": [
73
+ "dist",
74
+ "src"
75
+ ],
76
+ "publishConfig": {
77
+ "access": "public"
78
+ },
79
+ "keywords": [
80
+ "fragments",
81
+ "design-system",
82
+ "component-library",
83
+ "react",
84
+ "types",
85
+ "schema",
86
+ "ai",
87
+ "mcp"
88
+ ],
89
+ "dependencies": {
90
+ "zod": "^3.24.1"
91
+ },
92
+ "peerDependencies": {
93
+ "@storybook/csf": "^0.1.0",
94
+ "react": ">=18"
95
+ },
96
+ "peerDependenciesMeta": {
97
+ "@storybook/csf": {
98
+ "optional": true
99
+ },
100
+ "react": {
101
+ "optional": true
102
+ }
103
+ },
104
+ "devDependencies": {
105
+ "@storybook/csf": "^0.1.12",
106
+ "@types/node": "^22.0.0",
107
+ "@types/react": "^19.0.0",
108
+ "react": "^18.3.0",
109
+ "tsup": "^8.3.5",
110
+ "typescript": "^5.7.2",
111
+ "vitest": "^2.1.8"
112
+ },
113
+ "scripts": {
114
+ "build": "tsup",
115
+ "dev": "tsup --watch",
116
+ "test": "vitest run",
117
+ "typecheck": "tsc --noEmit",
118
+ "clean": "rm -rf dist"
119
+ }
120
+ }