@mimir-labs/core 0.4.0 → 0.6.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 (57) hide show
  1. package/README.md +13 -2
  2. package/dist/implementation/contracts/descriptor.d.ts +7 -1
  3. package/dist/implementation/contracts/resource.d.ts +93 -0
  4. package/dist/implementation/descriptors/descriptor-repository.js +33 -14
  5. package/dist/implementation/descriptors/descriptor-repository.js.map +1 -1
  6. package/dist/implementation/generation/generate-service.d.ts +4 -0
  7. package/dist/implementation/generation/generate-service.js +14 -4
  8. package/dist/implementation/generation/generate-service.js.map +1 -1
  9. package/dist/implementation/generation/types.d.ts +1 -0
  10. package/dist/implementation/io/fs.d.ts +1 -0
  11. package/dist/implementation/io/fs.js +13 -0
  12. package/dist/implementation/io/fs.js.map +1 -1
  13. package/dist/implementation/knowledge/knowledge-engine.d.ts +8 -0
  14. package/dist/implementation/knowledge/knowledge-engine.js +40 -0
  15. package/dist/implementation/knowledge/knowledge-engine.js.map +1 -0
  16. package/dist/implementation/knowledge/knowledge-graph.d.ts +12 -0
  17. package/dist/implementation/knowledge/knowledge-graph.js +34 -0
  18. package/dist/implementation/knowledge/knowledge-graph.js.map +1 -0
  19. package/dist/implementation/knowledge/model.d.ts +44 -0
  20. package/dist/implementation/knowledge/model.js +3 -0
  21. package/dist/implementation/knowledge/model.js.map +1 -0
  22. package/dist/implementation/knowledge/persistence-policy.d.ts +21 -0
  23. package/dist/implementation/knowledge/persistence-policy.js +51 -0
  24. package/dist/implementation/knowledge/persistence-policy.js.map +1 -0
  25. package/dist/implementation/knowledge/providers.d.ts +36 -0
  26. package/dist/implementation/knowledge/providers.js +150 -0
  27. package/dist/implementation/knowledge/providers.js.map +1 -0
  28. package/dist/implementation/resource-discovery/design-token-extractor.d.ts +3 -0
  29. package/dist/implementation/resource-discovery/design-token-extractor.js +78 -0
  30. package/dist/implementation/resource-discovery/design-token-extractor.js.map +1 -0
  31. package/dist/implementation/resource-discovery/react-pattern-extractor.d.ts +3 -0
  32. package/dist/implementation/resource-discovery/react-pattern-extractor.js +49 -0
  33. package/dist/implementation/resource-discovery/react-pattern-extractor.js.map +1 -0
  34. package/dist/implementation/resource-discovery/relationship-extractor.d.ts +3 -0
  35. package/dist/implementation/resource-discovery/relationship-extractor.js +80 -0
  36. package/dist/implementation/resource-discovery/relationship-extractor.js.map +1 -0
  37. package/dist/implementation/resource-discovery/semantic-resource-classifier.d.ts +23 -0
  38. package/dist/implementation/resource-discovery/semantic-resource-classifier.js +267 -0
  39. package/dist/implementation/resource-discovery/semantic-resource-classifier.js.map +1 -0
  40. package/dist/implementation/resource-discovery/storybook-extractor.d.ts +2 -1
  41. package/dist/implementation/resource-discovery/storybook-extractor.js +83 -44
  42. package/dist/implementation/resource-discovery/storybook-extractor.js.map +1 -1
  43. package/dist/implementation/resource-discovery/typescript-analysis.d.ts +7 -0
  44. package/dist/implementation/resource-discovery/typescript-analysis.js +42 -0
  45. package/dist/implementation/resource-discovery/typescript-analysis.js.map +1 -0
  46. package/dist/implementation/resource-discovery/typescript-extractor.d.ts +8 -2
  47. package/dist/implementation/resource-discovery/typescript-extractor.js +166 -108
  48. package/dist/implementation/resource-discovery/typescript-extractor.js.map +1 -1
  49. package/dist/implementation/resource-discovery/typescript-public-api-extractor.d.ts +11 -0
  50. package/dist/implementation/resource-discovery/typescript-public-api-extractor.js +439 -0
  51. package/dist/implementation/resource-discovery/typescript-public-api-extractor.js.map +1 -0
  52. package/dist/implementation/resource-identity.d.ts +1 -0
  53. package/dist/implementation/resource-identity.js +7 -0
  54. package/dist/implementation/resource-identity.js.map +1 -1
  55. package/dist/implementation/services/authoring-service.js +251 -140
  56. package/dist/implementation/services/authoring-service.js.map +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DescriptorPersistencePolicy = void 0;
4
+ const EMPTY_REACT = {
5
+ forwardRef: false,
6
+ memo: false,
7
+ lazy: false,
8
+ suspense: false,
9
+ portal: false,
10
+ errorBoundary: false,
11
+ context: false,
12
+ provider: false,
13
+ customHook: false
14
+ };
15
+ function firstObject(graph, subject, predicate) {
16
+ return graph.factsFor(subject, predicate)[0]?.object;
17
+ }
18
+ class DescriptorPersistencePolicy {
19
+ excludedRelationshipTypes;
20
+ constructor(excludedRelationshipTypes = new Set(["imports", "exports"])) {
21
+ this.excludedRelationshipTypes = excludedRelationshipTypes;
22
+ }
23
+ select(graph) {
24
+ return graph.facts("resource")
25
+ .map((fact) => ({ subject: fact.subject, resource: fact.object }))
26
+ .filter(({ resource }) => resource.classification.generateDescriptor)
27
+ .map(({ subject, resource }) => {
28
+ const publicApi = firstObject(graph, subject, "public-api");
29
+ const relationships = graph.factsFor(subject, "relationship")
30
+ .map((fact) => fact.object)
31
+ .filter((relationship) => !this.excludedRelationshipTypes.has(relationship.type));
32
+ const examples = graph.factsFor(subject, "example").map((fact) => fact.object);
33
+ return {
34
+ resource,
35
+ props: publicApi?.props ?? {},
36
+ api: publicApi?.api,
37
+ relationships,
38
+ examples,
39
+ variants: [...new Set(examples.map((example) => example.story))].sort((a, b) => a.localeCompare(b)),
40
+ storyFiles: [...new Set(examples.map((example) => example.source.file))].sort((a, b) => a.localeCompare(b)),
41
+ react: firstObject(graph, subject, "react-patterns") ?? EMPTY_REACT,
42
+ metadata: {
43
+ confidence: resource.classification.confidence,
44
+ extractorVersion: "1.0.0"
45
+ }
46
+ };
47
+ });
48
+ }
49
+ }
50
+ exports.DescriptorPersistencePolicy = DescriptorPersistencePolicy;
51
+ //# sourceMappingURL=persistence-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence-policy.js","sourceRoot":"","sources":["../../../src/implementation/knowledge/persistence-policy.ts"],"names":[],"mappings":";;;AA2BA,MAAM,WAAW,GAA2B;IAC1C,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,QAAQ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,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAA0B,CAAC,CAAC;YACnG,OAAO;gBACL,QAAQ;gBACR,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE;gBAC7B,GAAG,EAAE,SAAS,EAAE,GAAG;gBACnB,aAAa;gBACb,QAAQ;gBACR,QAAQ,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;gBACnG,UAAU,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;gBAC3G,KAAK,EAAE,WAAW,CAAyB,KAAK,EAAE,OAAO,EAAE,gBAAgB,CAAC,IAAI,WAAW;gBAC3F,QAAQ,EAAE;oBACR,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,UAAU;oBAC9C,gBAAgB,EAAE,OAAO;iBAC1B;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AA/BD,kEA+BC"}
@@ -0,0 +1,36 @@
1
+ import type { KnowledgeFact, KnowledgeGraphReader, KnowledgeProvider, KnowledgeWorkspace } from "./model";
2
+ export declare class SemanticDiscoveryProvider implements KnowledgeProvider {
3
+ readonly id = "semantic-discovery";
4
+ readonly provides: readonly ["resource", "classification"];
5
+ collect(workspace: KnowledgeWorkspace, _graph: KnowledgeGraphReader): Promise<KnowledgeFact[]>;
6
+ }
7
+ export declare class PublicApiProvider implements KnowledgeProvider {
8
+ readonly id = "public-api";
9
+ readonly requires: readonly ["resource"];
10
+ readonly provides: readonly ["public-api"];
11
+ collect(workspace: KnowledgeWorkspace, graph: KnowledgeGraphReader): Promise<KnowledgeFact[]>;
12
+ }
13
+ export declare class StorybookProvider implements KnowledgeProvider {
14
+ readonly id = "storybook";
15
+ readonly requires: readonly ["resource"];
16
+ readonly provides: readonly ["example"];
17
+ collect(workspace: KnowledgeWorkspace, graph: KnowledgeGraphReader): Promise<KnowledgeFact[]>;
18
+ }
19
+ export declare class RelationshipProvider implements KnowledgeProvider {
20
+ readonly id = "relationships";
21
+ readonly requires: readonly ["resource"];
22
+ readonly provides: readonly ["relationship"];
23
+ collect(workspace: KnowledgeWorkspace, graph: KnowledgeGraphReader): Promise<KnowledgeFact[]>;
24
+ }
25
+ export declare class ReactProvider implements KnowledgeProvider {
26
+ readonly id = "react";
27
+ readonly requires: readonly ["resource"];
28
+ readonly provides: readonly ["react-patterns"];
29
+ collect(workspace: KnowledgeWorkspace, graph: KnowledgeGraphReader): Promise<KnowledgeFact[]>;
30
+ }
31
+ export declare class DesignTokenProvider implements KnowledgeProvider {
32
+ readonly id = "design-tokens";
33
+ readonly requires: readonly ["resource"];
34
+ readonly provides: readonly ["design-tokens"];
35
+ collect(workspace: KnowledgeWorkspace, graph: KnowledgeGraphReader): Promise<KnowledgeFact[]>;
36
+ }
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DesignTokenProvider = exports.ReactProvider = exports.RelationshipProvider = exports.StorybookProvider = exports.PublicApiProvider = exports.SemanticDiscoveryProvider = void 0;
4
+ const resource_identity_1 = require("../resource-identity");
5
+ const design_token_extractor_1 = require("../resource-discovery/design-token-extractor");
6
+ const react_pattern_extractor_1 = require("../resource-discovery/react-pattern-extractor");
7
+ const relationship_extractor_1 = require("../resource-discovery/relationship-extractor");
8
+ const storybook_extractor_1 = require("../resource-discovery/storybook-extractor");
9
+ const typescript_extractor_1 = require("../resource-discovery/typescript-extractor");
10
+ const typescript_public_api_extractor_1 = require("../resource-discovery/typescript-public-api-extractor");
11
+ function analysis(workspace) {
12
+ return { cwd: workspace.cwd, program: workspace.program, checker: workspace.checker };
13
+ }
14
+ function subjectFor(resource) {
15
+ return (0, resource_identity_1.createResourceId)(resource.packageName, resource.classification.kind, resource.name);
16
+ }
17
+ function resources(graph) {
18
+ return graph.facts("resource").map((fact) => fact.object);
19
+ }
20
+ class SemanticDiscoveryProvider {
21
+ id = "semantic-discovery";
22
+ provides = ["resource", "classification"];
23
+ async collect(workspace, _graph) {
24
+ const found = await (0, typescript_extractor_1.discoverTypeScriptResources)(workspace.cwd, workspace.packageName, workspace.discovery, analysis(workspace));
25
+ return found.flatMap((resource) => [
26
+ {
27
+ subject: subjectFor(resource),
28
+ predicate: "resource",
29
+ object: resource,
30
+ confidence: resource.classification.confidence,
31
+ source: "typescript",
32
+ evidence: resource.classification.reasons.map((detail) => ({ kind: "classification-signal", detail, file: resource.filePath, symbol: resource.name }))
33
+ },
34
+ {
35
+ subject: subjectFor(resource),
36
+ predicate: "classification",
37
+ object: resource.classification,
38
+ confidence: resource.classification.confidence,
39
+ source: "typescript",
40
+ evidence: resource.classification.reasons.map((detail) => ({ kind: "classification-signal", detail, file: resource.filePath, symbol: resource.name }))
41
+ }
42
+ ]);
43
+ }
44
+ }
45
+ exports.SemanticDiscoveryProvider = SemanticDiscoveryProvider;
46
+ class PublicApiProvider {
47
+ id = "public-api";
48
+ requires = ["resource"];
49
+ provides = ["public-api"];
50
+ async collect(workspace, graph) {
51
+ const discovered = resources(graph);
52
+ const components = discovered.map((resource) => ({ ...resource, props: {} }));
53
+ const extracted = await (0, typescript_public_api_extractor_1.extractTypeScriptPublicApi)(workspace.cwd, components, analysis(workspace));
54
+ return discovered.flatMap((resource) => {
55
+ const api = extracted.get((0, typescript_public_api_extractor_1.getComponentPublicApiKey)(resource));
56
+ return api ? [{
57
+ subject: subjectFor(resource),
58
+ predicate: "public-api",
59
+ object: { api: api.api, props: api.props },
60
+ confidence: 1,
61
+ source: "typescript",
62
+ evidence: [{ kind: "public-export", detail: resource.importName, file: resource.filePath, symbol: resource.name }]
63
+ }] : [];
64
+ });
65
+ }
66
+ }
67
+ exports.PublicApiProvider = PublicApiProvider;
68
+ class StorybookProvider {
69
+ id = "storybook";
70
+ requires = ["resource"];
71
+ provides = ["example"];
72
+ async collect(workspace, graph) {
73
+ const facts = await (0, storybook_extractor_1.extractStorybookFacts)(analysis(workspace));
74
+ return resources(graph).flatMap((resource) => (facts.examplesByComponent[resource.name] ?? []).map((example) => ({
75
+ subject: subjectFor(resource),
76
+ predicate: "example",
77
+ object: example,
78
+ confidence: 1,
79
+ source: "storybook",
80
+ evidence: [{ kind: "exported-story", detail: example.story, file: example.source.file, symbol: example.name }]
81
+ })));
82
+ }
83
+ }
84
+ exports.StorybookProvider = StorybookProvider;
85
+ class RelationshipProvider {
86
+ id = "relationships";
87
+ requires = ["resource"];
88
+ provides = ["relationship"];
89
+ async collect(workspace, graph) {
90
+ const discovered = resources(graph);
91
+ const extracted = (0, relationship_extractor_1.extractRelationships)(analysis(workspace), discovered);
92
+ return discovered.flatMap((resource) => (extracted.get((0, typescript_public_api_extractor_1.getComponentPublicApiKey)(resource)) ?? []).map((relationship) => ({
93
+ subject: subjectFor(resource),
94
+ predicate: "relationship",
95
+ object: relationship,
96
+ confidence: relationship.confidence,
97
+ source: "typescript",
98
+ evidence: [{ kind: "ast-reference", detail: relationship.type, file: resource.filePath, symbol: resource.name }]
99
+ })));
100
+ }
101
+ }
102
+ exports.RelationshipProvider = RelationshipProvider;
103
+ class ReactProvider {
104
+ id = "react";
105
+ requires = ["resource"];
106
+ provides = ["react-patterns"];
107
+ async collect(workspace, graph) {
108
+ const discovered = resources(graph);
109
+ const extracted = (0, react_pattern_extractor_1.extractReactPatterns)(analysis(workspace), discovered);
110
+ return discovered.flatMap((resource) => {
111
+ const patterns = extracted.get((0, typescript_public_api_extractor_1.getComponentPublicApiKey)(resource));
112
+ if (!patterns)
113
+ return [];
114
+ const evidence = Object.entries(patterns)
115
+ .filter(([, present]) => present)
116
+ .map(([pattern]) => ({ kind: "react-pattern", detail: pattern, file: resource.filePath, symbol: resource.name }));
117
+ return [{
118
+ subject: subjectFor(resource),
119
+ predicate: "react-patterns",
120
+ object: patterns,
121
+ confidence: 1,
122
+ source: "react",
123
+ evidence
124
+ }];
125
+ });
126
+ }
127
+ }
128
+ exports.ReactProvider = ReactProvider;
129
+ class DesignTokenProvider {
130
+ id = "design-tokens";
131
+ requires = ["resource"];
132
+ provides = ["design-tokens"];
133
+ async collect(workspace, graph) {
134
+ const discovered = resources(graph);
135
+ const extracted = (0, design_token_extractor_1.extractDesignTokens)(analysis(workspace), discovered);
136
+ return discovered.flatMap((resource) => {
137
+ const tokens = extracted.get((0, typescript_public_api_extractor_1.getComponentPublicApiKey)(resource));
138
+ return tokens ? [{
139
+ subject: subjectFor(resource),
140
+ predicate: "design-tokens",
141
+ object: tokens,
142
+ confidence: resource.classification.confidence,
143
+ source: "design-tokens",
144
+ evidence: [{ kind: "static-token-object", detail: "Statically resolved token values", file: resource.filePath, symbol: resource.name }]
145
+ }] : [];
146
+ });
147
+ }
148
+ }
149
+ exports.DesignTokenProvider = DesignTokenProvider;
150
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/implementation/knowledge/providers.ts"],"names":[],"mappings":";;;AAAA,4DAAwD;AACxD,yFAAmF;AACnF,2FAAqF;AACrF,yFAAoF;AACpF,mFAAkF;AAClF,qFAAyF;AACzF,2GAG+D;AAK/D,SAAS,QAAQ,CAAC,SAA6B;IAC7C,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,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,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;QACvE,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAmB,EAAE;YACtD,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,IAAA,0DAAwB,EAAC,QAAQ,CAAC,CAAC,CAAC;YACjE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;oBACf,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC;oBAC7B,SAAS,EAAE,eAAe;oBAC1B,MAAM,EAAE,MAAM;oBACd,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,UAAU;oBAC9C,MAAM,EAAE,eAAe;oBACvB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,kCAAkC,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;iBACxI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACV,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApBD,kDAoBC"}
@@ -0,0 +1,3 @@
1
+ import type { DiscoveredResourceFact, ExtractedDesignTokens } from "../contracts/resource";
2
+ import type { TypeScriptAnalysis } from "./typescript-analysis";
3
+ export declare function extractDesignTokens(analysis: TypeScriptAnalysis, resources: DiscoveredResourceFact[]): Map<string, ExtractedDesignTokens>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractDesignTokens = extractDesignTokens;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const typescript_1 = __importDefault(require("typescript"));
9
+ const CATEGORY_NAMES = {
10
+ color: "colors", colors: "colors", palette: "colors", spacing: "spacing", space: "spacing",
11
+ typography: "typography", font: "typography", radius: "radius", radii: "radius",
12
+ shadow: "shadows", shadows: "shadows", zindex: "zIndex", breakpoint: "breakpoints", breakpoints: "breakpoints"
13
+ };
14
+ function staticValue(node) {
15
+ if (typescript_1.default.isStringLiteral(node) || typescript_1.default.isNoSubstitutionTemplateLiteral(node))
16
+ return node.text;
17
+ if (typescript_1.default.isNumericLiteral(node))
18
+ return Number(node.text);
19
+ if (node.kind === typescript_1.default.SyntaxKind.TrueKeyword)
20
+ return true;
21
+ if (node.kind === typescript_1.default.SyntaxKind.FalseKeyword)
22
+ return false;
23
+ if (node.kind === typescript_1.default.SyntaxKind.NullKeyword)
24
+ return null;
25
+ if (typescript_1.default.isArrayLiteralExpression(node)) {
26
+ const values = node.elements.map((item) => typescript_1.default.isExpression(item) ? staticValue(item) : undefined);
27
+ return values.every((item) => item !== undefined) ? values : undefined;
28
+ }
29
+ if (typescript_1.default.isObjectLiteralExpression(node)) {
30
+ const value = {};
31
+ for (const property of node.properties) {
32
+ if (!typescript_1.default.isPropertyAssignment(property))
33
+ return undefined;
34
+ const name = property.name.getText().replace(/^['"]|['"]$/g, "");
35
+ const child = staticValue(property.initializer);
36
+ if (child === undefined)
37
+ return undefined;
38
+ value[name] = child;
39
+ }
40
+ return value;
41
+ }
42
+ return undefined;
43
+ }
44
+ function extractDesignTokens(analysis, resources) {
45
+ const result = new Map();
46
+ for (const resource of resources) {
47
+ if (resource.classification.kind !== "token" && resource.classification.kind !== "theme")
48
+ continue;
49
+ const sourceFile = analysis.program.getSourceFile(node_path_1.default.join(analysis.cwd, resource.filePath));
50
+ if (!sourceFile)
51
+ continue;
52
+ const tokens = {};
53
+ const visit = (node) => {
54
+ if (typescript_1.default.isVariableDeclaration(node) && typescript_1.default.isIdentifier(node.name) && node.initializer) {
55
+ const category = CATEGORY_NAMES[node.name.text.toLowerCase()];
56
+ const value = staticValue(node.initializer);
57
+ if (category && value && typeof value === "object" && !Array.isArray(value))
58
+ tokens[category] = value;
59
+ if (typescript_1.default.isObjectLiteralExpression(node.initializer)) {
60
+ for (const property of node.initializer.properties) {
61
+ if (!typescript_1.default.isPropertyAssignment(property))
62
+ continue;
63
+ const nestedCategory = CATEGORY_NAMES[property.name.getText().replace(/^['"]|['"]$/g, "").toLowerCase()];
64
+ const nestedValue = staticValue(property.initializer);
65
+ if (nestedCategory && nestedValue && typeof nestedValue === "object" && !Array.isArray(nestedValue)) {
66
+ tokens[nestedCategory] = nestedValue;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ typescript_1.default.forEachChild(node, visit);
72
+ };
73
+ visit(sourceFile);
74
+ result.set(`${resource.filePath}::${resource.name}`, tokens);
75
+ }
76
+ return result;
77
+ }
78
+ //# sourceMappingURL=design-token-extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-extractor.js","sourceRoot":"","sources":["../../../src/implementation/resource-discovery/design-token-extractor.ts"],"names":[],"mappings":";;;;;AAmCA,kDA6BC;AAhED,0DAA6B;AAC7B,4DAA4B;AAI5B,MAAM,cAAc,GAAwC;IAC1D,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS;IAC1F,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ;IAC/E,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa;CAC/G,CAAC;AAEF,SAAS,WAAW,CAAC,IAAmB;IACtC,IAAI,oBAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,oBAAE,CAAC,+BAA+B,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IAC3F,IAAI,oBAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD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E,CAAC;wBACnD,IAAI,CAAC,oBAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;4BAAE,SAAS;wBACjD,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;wBACzG,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;wBACtD,IAAI,cAAc,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;4BACpG,MAAM,CAAC,cAAc,CAAC,GAAG,WAAW,CAAC;wBACvC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YACD,oBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DiscoveredResourceFact, ExtractedReactPatterns } from "../contracts/resource";
2
+ import type { TypeScriptAnalysis } from "./typescript-analysis";
3
+ export declare function extractReactPatterns(analysis: TypeScriptAnalysis, resources: DiscoveredResourceFact[]): Map<string, ExtractedReactPatterns>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractReactPatterns = extractReactPatterns;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const typescript_1 = __importDefault(require("typescript"));
9
+ function extractReactPatterns(analysis, resources) {
10
+ const result = new Map();
11
+ for (const resource of resources) {
12
+ const sourceFile = analysis.program.getSourceFile(node_path_1.default.join(analysis.cwd, resource.filePath));
13
+ const patterns = {
14
+ forwardRef: false, memo: false, lazy: false, suspense: false, portal: false,
15
+ errorBoundary: false, context: false, provider: false, customHook: /^use[A-Z]/.test(resource.name)
16
+ };
17
+ const visit = (node) => {
18
+ if (typescript_1.default.isIdentifier(node)) {
19
+ if (node.text === "forwardRef")
20
+ patterns.forwardRef = true;
21
+ else if (node.text === "memo")
22
+ patterns.memo = true;
23
+ else if (node.text === "lazy")
24
+ patterns.lazy = true;
25
+ else if (node.text === "Suspense")
26
+ patterns.suspense = true;
27
+ else if (node.text === "createPortal")
28
+ patterns.portal = true;
29
+ else if (node.text === "createContext")
30
+ patterns.context = true;
31
+ else if (node.text === "Provider")
32
+ patterns.provider = true;
33
+ }
34
+ if (typescript_1.default.isClassDeclaration(node) && node.members.some((member) => typescript_1.default.isMethodDeclaration(member) && member.name.getText() === "componentDidCatch"))
35
+ patterns.errorBoundary = true;
36
+ typescript_1.default.forEachChild(node, visit);
37
+ };
38
+ if (sourceFile) {
39
+ const moduleSymbol = analysis.checker.getSymbolAtLocation(sourceFile);
40
+ const exported = moduleSymbol && analysis.checker.getExportsOfModule(moduleSymbol).find((item) => item.getName() === resource.importName);
41
+ const symbol = exported && (exported.flags & typescript_1.default.SymbolFlags.Alias ? analysis.checker.getAliasedSymbol(exported) : exported);
42
+ for (const declaration of symbol?.declarations ?? [])
43
+ visit(declaration);
44
+ }
45
+ result.set(`${resource.filePath}::${resource.name}`, patterns);
46
+ }
47
+ return result;
48
+ }
49
+ //# sourceMappingURL=react-pattern-extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-pattern-extractor.js","sourceRoot":"","sources":["../../../src/implementation/resource-discovery/react-pattern-extractor.ts"],"names":[],"mappings":";;;;;AAKA,oDA8BC;AAnCD,0DAA6B;AAC7B,4DAA4B;AAI5B,SAA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ChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DiscoveredResourceFact, ExtractedRelationship } from "../contracts/resource";
2
+ import type { TypeScriptAnalysis } from "./typescript-analysis";
3
+ export declare function extractRelationships(analysis: TypeScriptAnalysis, resources: DiscoveredResourceFact[]): Map<string, ExtractedRelationship[]>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractRelationships = extractRelationships;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const typescript_1 = __importDefault(require("typescript"));
9
+ function normalize(value) {
10
+ return value.split(node_path_1.default.sep).join("/");
11
+ }
12
+ function extractRelationships(analysis, resources) {
13
+ const resourceByDeclaration = new Map();
14
+ const declarationsByResource = new Map();
15
+ const resourceByName = new Map(resources.map((resource) => [resource.name, resource]));
16
+ for (const resource of resources) {
17
+ const sourceFile = analysis.program.getSourceFile(node_path_1.default.join(analysis.cwd, resource.filePath));
18
+ const moduleSymbol = sourceFile && analysis.checker.getSymbolAtLocation(sourceFile);
19
+ const exported = moduleSymbol && analysis.checker.getExportsOfModule(moduleSymbol).find((item) => item.getName() === resource.importName);
20
+ const symbol = exported && (exported.flags & typescript_1.default.SymbolFlags.Alias ? analysis.checker.getAliasedSymbol(exported) : exported);
21
+ const declarations = symbol?.declarations ?? [];
22
+ declarationsByResource.set(`${normalize(resource.filePath)}::${resource.name}`, declarations);
23
+ for (const declaration of declarations)
24
+ resourceByDeclaration.set(declaration, resource);
25
+ }
26
+ const result = new Map();
27
+ for (const resource of resources) {
28
+ const sourceFile = analysis.program.getSourceFile(node_path_1.default.join(analysis.cwd, resource.filePath));
29
+ if (!sourceFile)
30
+ continue;
31
+ const relationships = new Map();
32
+ const add = (type, target, confidence) => {
33
+ const targetId = typeof target === "string" ? target : `local.${target.classification.kind}.${target.name.toLowerCase()}`;
34
+ relationships.set(`${type}:${targetId}`, { type, target: targetId, confidence });
35
+ };
36
+ const visit = (node) => {
37
+ if (typescript_1.default.isImportDeclaration(node) && typescript_1.default.isStringLiteral(node.moduleSpecifier))
38
+ add("imports", node.moduleSpecifier.text, 1);
39
+ if (typescript_1.default.isExportDeclaration(node) && node.moduleSpecifier && typescript_1.default.isStringLiteral(node.moduleSpecifier))
40
+ add("exports", node.moduleSpecifier.text, 1);
41
+ if (typescript_1.default.isIdentifier(node)) {
42
+ let symbol = analysis.checker.getSymbolAtLocation(node);
43
+ if (symbol?.flags && symbol.flags & typescript_1.default.SymbolFlags.Alias)
44
+ symbol = analysis.checker.getAliasedSymbol(symbol);
45
+ const target = symbol?.declarations?.map((declaration) => resourceByDeclaration.get(declaration)).find(Boolean);
46
+ if (target && target.name !== resource.name) {
47
+ const type = typescript_1.default.isJsxOpeningElement(node.parent) || typescript_1.default.isJsxSelfClosingElement(node.parent)
48
+ ? resource.classification.kind === "page" || resource.classification.kind === "template" ? "composes" : "uses"
49
+ : typescript_1.default.isTypeReferenceNode(node.parent) ? "references" : "dependsOn";
50
+ add(type, target, 1);
51
+ }
52
+ }
53
+ if (typescript_1.default.isPropertyAccessExpression(node)) {
54
+ const name = node.name.text;
55
+ const target = resourceByName.get(node.expression.getText(sourceFile));
56
+ if (name === "Provider" && target)
57
+ add("provides", target, 1);
58
+ }
59
+ if (typescript_1.default.isCallExpression(node)) {
60
+ const callName = typescript_1.default.isIdentifier(node.expression) ? node.expression.text : typescript_1.default.isPropertyAccessExpression(node.expression) ? node.expression.name.text : "";
61
+ if (callName === "useContext" && node.arguments[0] && typescript_1.default.isIdentifier(node.arguments[0])) {
62
+ const target = resourceByName.get(node.arguments[0].text);
63
+ if (target)
64
+ add("consumes", target, 1);
65
+ }
66
+ }
67
+ typescript_1.default.forEachChild(node, visit);
68
+ };
69
+ for (const statement of sourceFile.statements) {
70
+ if (typescript_1.default.isImportDeclaration(statement) || typescript_1.default.isExportDeclaration(statement))
71
+ visit(statement);
72
+ }
73
+ const key = `${normalize(resource.filePath)}::${resource.name}`;
74
+ for (const declaration of declarationsByResource.get(key) ?? [])
75
+ visit(declaration);
76
+ result.set(key, [...relationships.values()].sort((a, b) => `${a.type}:${a.target}`.localeCompare(`${b.type}:${b.target}`)));
77
+ }
78
+ return result;
79
+ }
80
+ //# sourceMappingURL=relationship-extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship-extractor.js","sourceRoot":"","sources":["../../../src/implementation/resource-discovery/relationship-extractor.ts"],"names":[],"mappings":";;;;;AASA,oDA8DC;AAvED,0DAA6B;AAC7B,4DAA4B;AAI5B,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,oBAAoB,CAClC,QAA4B,EAC5B,SAAmC;IAEnC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAA0C,CAAC;IAChF,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAA4B,CAAC;IACnE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACvF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,mBAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9F,MAAM,YAAY,GAAG,UAAU,IAAI,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACpF,MAAM,QAAQ,GAAG,YAAY,IAAI,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAA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= {
3
+ include: Set<SemanticResourceKind>;
4
+ exclude: Set<SemanticResourceKind>;
5
+ };
6
+ export type SemanticResourceSignals = {
7
+ name: string;
8
+ filePath: string;
9
+ isPublicExport: boolean;
10
+ hasReactImport: boolean;
11
+ hasJsx: boolean;
12
+ hasCreateContextCall: boolean;
13
+ hasStyledImport: boolean;
14
+ hasStyledCall: boolean;
15
+ hasStorybookImport: boolean;
16
+ extension: string;
17
+ };
18
+ export declare function defaultResourceClassificationPolicy(): ResourceClassificationPolicy;
19
+ export declare function mergeClassificationPolicy(config?: {
20
+ include?: SemanticResourceKind[];
21
+ exclude?: SemanticResourceKind[];
22
+ }): ResourceClassificationPolicy;
23
+ export declare function classifyResource(signals: SemanticResourceSignals, policy: ResourceClassificationPolicy): ResourceClassification;