@knapsack/renderer-react 4.71.19--canary.5222.cb1568a.0 → 4.71.19--canary.5325.d5f1abb.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/analyze/infer-spec.test.d.ts +2 -0
- package/dist/analyze/infer-spec.test.d.ts.map +1 -0
- package/dist/analyze/infer-spec.test.js +112 -0
- package/dist/analyze/infer-spec.test.js.map +1 -0
- package/dist/analyze/mui.test.d.ts +2 -0
- package/dist/analyze/mui.test.d.ts.map +1 -0
- package/dist/analyze/mui.test.js +60 -0
- package/dist/analyze/mui.test.js.map +1 -0
- package/dist/analyze/pkg-basic.test.d.ts +2 -0
- package/dist/analyze/pkg-basic.test.d.ts.map +1 -0
- package/dist/analyze/pkg-basic.test.js +33 -0
- package/dist/analyze/pkg-basic.test.js.map +1 -0
- package/dist/analyze/pkg-diff-types.test.d.ts +2 -0
- package/dist/analyze/pkg-diff-types.test.d.ts.map +1 -0
- package/dist/analyze/pkg-diff-types.test.js +43 -0
- package/dist/analyze/pkg-diff-types.test.js.map +1 -0
- package/dist/renderer-react.d.ts.map +1 -1
- package/dist/renderer-react.js +8 -9
- package/dist/renderer-react.js.map +1 -1
- package/package.json +14 -16
- package/dist/analyze/index.d.mts +0 -2
- package/dist/analyze/index.d.mts.map +0 -1
- package/dist/analyze/index.mjs +0 -2
- package/dist/analyze/index.mjs.map +0 -1
- package/dist/analyze/infer-spec-fixtures/components.d.ts +0 -99
- package/dist/analyze/infer-spec-fixtures/components.d.ts.map +0 -1
- package/dist/analyze/infer-spec-fixtures/components.js +0 -59
- package/dist/analyze/infer-spec-fixtures/components.js.map +0 -1
- package/dist/analyze/infer-spec-fixtures/index.d.mts +0 -2
- package/dist/analyze/infer-spec-fixtures/index.d.mts.map +0 -1
- package/dist/analyze/infer-spec-fixtures/index.mjs +0 -2
- package/dist/analyze/infer-spec-fixtures/index.mjs.map +0 -1
- package/dist/analyze/infer-spec.d.mts +0 -27
- package/dist/analyze/infer-spec.d.mts.map +0 -1
- package/dist/analyze/infer-spec.mjs +0 -98
- package/dist/analyze/infer-spec.mjs.map +0 -1
- package/dist/analyze/infer-spec.test.d.mts +0 -2
- package/dist/analyze/infer-spec.test.d.mts.map +0 -1
- package/dist/analyze/infer-spec.test.mjs +0 -214
- package/dist/analyze/infer-spec.test.mjs.map +0 -1
- package/dist/analyze/mui.test.d.mts +0 -2
- package/dist/analyze/mui.test.d.mts.map +0 -1
- package/dist/analyze/mui.test.mjs +0 -88
- package/dist/analyze/mui.test.mjs.map +0 -1
- package/dist/analyze/pkg-basic.test.d.mts +0 -2
- package/dist/analyze/pkg-basic.test.d.mts.map +0 -1
- package/dist/analyze/pkg-basic.test.mjs +0 -28
- package/dist/analyze/pkg-basic.test.mjs.map +0 -1
- package/dist/analyze/pkg-diff-types.test.d.mts +0 -2
- package/dist/analyze/pkg-diff-types.test.d.mts.map +0 -1
- package/dist/analyze/pkg-diff-types.test.mjs +0 -29
- package/dist/analyze/pkg-diff-types.test.mjs.map +0 -1
- package/dist/analyze/utils/importer.d.mts +0 -17
- package/dist/analyze/utils/importer.d.mts.map +0 -1
- package/dist/analyze/utils/importer.mjs +0 -80
- package/dist/analyze/utils/importer.mjs.map +0 -1
- package/dist/analyze/utils/react-component-analyzer.d.mts +0 -24
- package/dist/analyze/utils/react-component-analyzer.d.mts.map +0 -1
- package/dist/analyze/utils/react-component-analyzer.mjs +0 -151
- package/dist/analyze/utils/react-component-analyzer.mjs.map +0 -1
- package/turbo.json +0 -9
- /package/{.eslintrc.cjs → .eslintrc.js} +0 -0
@@ -1,17 +0,0 @@
|
|
1
|
-
import { ComponentType } from 'react';
|
2
|
-
export declare const clearImporterCache: () => void;
|
3
|
-
export declare function importComponent({ path, alias, resolveFrom, pkgPathAliases, }: {
|
4
|
-
path: string;
|
5
|
-
alias?: string;
|
6
|
-
resolveFrom?: string;
|
7
|
-
pkgPathAliases?: Record<string, string>;
|
8
|
-
}): Promise<ComponentType<unknown>>;
|
9
|
-
export declare function getPkgComponentsForSuggestions({ path, pkgPathAliases, resolveFrom, }: {
|
10
|
-
path: string;
|
11
|
-
resolveFrom?: string;
|
12
|
-
pkgPathAliases?: Record<string, string>;
|
13
|
-
}): Promise<Array<{
|
14
|
-
alias: string;
|
15
|
-
path: string;
|
16
|
-
}>>;
|
17
|
-
//# sourceMappingURL=importer.d.mts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"importer.d.mts","sourceRoot":"","sources":["../../../src/analyze/utils/importer.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA0BtC,eAAO,MAAM,kBAAkB,YAA+B,CAAC;AAuC/D,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,KAAiB,EACjB,WAA2B,EAC3B,cAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAoBlC;AAED,wBAAsB,8BAA8B,CAAC,EACnD,IAAI,EACJ,cAAc,EACd,WAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAgBlD"}
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import { resolvePath } from '@knapsack/file-utils';
|
2
|
-
async function importPkgUncached({ path, pkgPathAliases, resolveFrom = process.cwd(), }) {
|
3
|
-
try {
|
4
|
-
const mod = await import(path);
|
5
|
-
return mod;
|
6
|
-
}
|
7
|
-
catch (e) {
|
8
|
-
const { absolutePath } = await resolvePath({
|
9
|
-
path,
|
10
|
-
resolveFromDir: resolveFrom,
|
11
|
-
pkgPathAliases,
|
12
|
-
});
|
13
|
-
return import(absolutePath);
|
14
|
-
}
|
15
|
-
}
|
16
|
-
const importPkgCache = new Map();
|
17
|
-
export const clearImporterCache = () => importPkgCache.clear();
|
18
|
-
async function importPkg(args) {
|
19
|
-
const cacheKey = JSON.stringify(args);
|
20
|
-
if (!importPkgCache.has(cacheKey)) {
|
21
|
-
const result = importPkgUncached(args);
|
22
|
-
importPkgCache.set(cacheKey, result);
|
23
|
-
result.catch(() => {
|
24
|
-
// remove from cache if error
|
25
|
-
importPkgCache.delete(cacheKey);
|
26
|
-
});
|
27
|
-
return result;
|
28
|
-
}
|
29
|
-
return importPkgCache.get(cacheKey);
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Type guard to check if a value is a React component
|
33
|
-
*/
|
34
|
-
function isReactComponent(component) {
|
35
|
-
var _a, _b, _c, _d;
|
36
|
-
if (typeof component !== 'function')
|
37
|
-
return false;
|
38
|
-
// Class components
|
39
|
-
if ((_a = component.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent) {
|
40
|
-
return true;
|
41
|
-
}
|
42
|
-
// Function components
|
43
|
-
if (typeof component === 'function' &&
|
44
|
-
!((_d = (_c = (_b = component.prototype) === null || _b === void 0 ? void 0 : _b.constructor) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.includes('Function')))
|
45
|
-
return true;
|
46
|
-
return false;
|
47
|
-
}
|
48
|
-
export async function importComponent({ path, alias = 'default', resolveFrom = process.cwd(), pkgPathAliases, }) {
|
49
|
-
const pkg = await importPkg({
|
50
|
-
path,
|
51
|
-
resolveFrom,
|
52
|
-
pkgPathAliases,
|
53
|
-
});
|
54
|
-
const component = pkg[alias];
|
55
|
-
if (!component) {
|
56
|
-
throw new Error(`Component ${alias} not found in ${path}`);
|
57
|
-
}
|
58
|
-
if (!isReactComponent(component)) {
|
59
|
-
throw new Error(`Export ${alias} in ${path} is not a valid React component`);
|
60
|
-
}
|
61
|
-
return component;
|
62
|
-
}
|
63
|
-
export async function getPkgComponentsForSuggestions({ path, pkgPathAliases, resolveFrom, }) {
|
64
|
-
const thePkg = await importPkg({
|
65
|
-
path,
|
66
|
-
resolveFrom,
|
67
|
-
pkgPathAliases,
|
68
|
-
});
|
69
|
-
return Object.entries(thePkg || {})
|
70
|
-
.filter(([exportName, exportValue]) => {
|
71
|
-
if (exportName === 'default')
|
72
|
-
return false;
|
73
|
-
return isReactComponent(exportValue);
|
74
|
-
})
|
75
|
-
.map(([name]) => ({
|
76
|
-
alias: name,
|
77
|
-
path,
|
78
|
-
}));
|
79
|
-
}
|
80
|
-
//# sourceMappingURL=importer.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"importer.mjs","sourceRoot":"","sources":["../../../src/analyze/utils/importer.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,KAAK,UAAU,iBAAiB,CAAC,EAC/B,IAAI,EACJ,cAAc,EACd,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,GAK5B;IACC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,WAAW,CAAC;YACzC,IAAI;YACJ,cAAc,EAAE,WAAW;YAC3B,cAAc;SACf,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgD,CAAC;AAE/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;AAE/D,KAAK,UAAU,SAAS,CA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AE7B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,aAAa,KAAK,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,UAAU,KAAK,OAAO,IAAI,iCAAiC,CAC5D,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,EACnD,IAAI,EACJ,cAAc,EACd,WAAW,GAKZ;IACC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;QAC7B,IAAI;QACJ,WAAW;QACX,cAAc;KACf,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,EAAE;QACpC,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC3C,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAChB,KAAK,EAAE,IAAI;QACX,IAAI;KACL,CAAC,CAAC,CAAC;AACR,CAAC"}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import { type TypeInfo } from '@knapsack/spec-utils';
|
2
|
-
export type ComponentProps = Record<string, {
|
3
|
-
required: boolean;
|
4
|
-
description?: string;
|
5
|
-
typeInfo: TypeInfo;
|
6
|
-
}>;
|
7
|
-
export type SlotInfo = {
|
8
|
-
title: string;
|
9
|
-
description?: string;
|
10
|
-
};
|
11
|
-
export type ComponentAnalysis = {
|
12
|
-
props: ComponentProps;
|
13
|
-
slots: SlotInfo[];
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
* Analyzes a React component to extract its props and slots information
|
17
|
-
*/
|
18
|
-
export declare function analyzeComponent({ fileName, exportName, pkgPathAliases, resolveFromDir, }: {
|
19
|
-
fileName: string;
|
20
|
-
exportName?: string;
|
21
|
-
pkgPathAliases?: Record<string, string>;
|
22
|
-
resolveFromDir?: string;
|
23
|
-
}): Promise<ComponentAnalysis>;
|
24
|
-
//# sourceMappingURL=react-component-analyzer.d.mts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"react-component-analyzer.d.mts","sourceRoot":"","sources":["../../../src/analyze/utils/react-component-analyzer.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,sBAAsB,CAAC;AAGpE,MAAM,MAAM,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CACF,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC;AAqFF;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,cAAc,EACd,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyF7B"}
|
@@ -1,151 +0,0 @@
|
|
1
|
-
import { analyzeExport } from '@knapsack/spec-utils';
|
2
|
-
import { importComponent } from './importer.mjs';
|
3
|
-
/**
|
4
|
-
* Merges properties from multiple object types in a union
|
5
|
-
*/
|
6
|
-
const mergeUnionObjectProperties = ({ items, }) => {
|
7
|
-
const mergedProperties = {};
|
8
|
-
items.forEach((item) => {
|
9
|
-
if (item.type === 'object' && item.properties) {
|
10
|
-
Object.entries(item.properties).forEach(([propName, propInfo]) => {
|
11
|
-
// If property already exists, merge with existing
|
12
|
-
if (mergedProperties[propName]) {
|
13
|
-
mergedProperties[propName] = {
|
14
|
-
...propInfo.typeInfo,
|
15
|
-
isOptional: mergedProperties[propName].isOptional ||
|
16
|
-
propInfo.typeInfo.isOptional,
|
17
|
-
};
|
18
|
-
}
|
19
|
-
else {
|
20
|
-
mergedProperties[propName] = propInfo.typeInfo;
|
21
|
-
}
|
22
|
-
});
|
23
|
-
}
|
24
|
-
});
|
25
|
-
return mergedProperties;
|
26
|
-
};
|
27
|
-
/**
|
28
|
-
* Processes prop information and adds it to the props object
|
29
|
-
*/
|
30
|
-
const processProps = ({ properties, }) => {
|
31
|
-
const props = {};
|
32
|
-
const slots = [];
|
33
|
-
const isReactNodeType = (typeInfo) => {
|
34
|
-
var _a, _b, _c;
|
35
|
-
// Check the TypeScript metadata for React.ReactNode type
|
36
|
-
const typeName = (_c = (_b = (_a = typeInfo.tsMetadata) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.symbol) === null || _c === void 0 ? void 0 : _c.name;
|
37
|
-
// Common React type names
|
38
|
-
if (typeName === 'ReactNode' || typeInfo.tsRawType === 'ReactNode') {
|
39
|
-
return true;
|
40
|
-
}
|
41
|
-
// Handle union types that might include React nodes
|
42
|
-
if (typeInfo.type === 'union') {
|
43
|
-
return typeInfo.items.some((item) => isReactNodeType(item));
|
44
|
-
}
|
45
|
-
return false;
|
46
|
-
};
|
47
|
-
Object.entries(properties).forEach(([propName, propInfo]) => {
|
48
|
-
var _a, _b;
|
49
|
-
props[propName] = {
|
50
|
-
required: !propInfo.typeInfo.isOptional,
|
51
|
-
description: (_a = propInfo.jsDoc) === null || _a === void 0 ? void 0 : _a.description,
|
52
|
-
typeInfo: propInfo.typeInfo,
|
53
|
-
};
|
54
|
-
// Check for slot-like props
|
55
|
-
const isSlotProp = propName === 'children' || isReactNodeType(propInfo.typeInfo);
|
56
|
-
if (isSlotProp) {
|
57
|
-
slots.push({
|
58
|
-
title: propName,
|
59
|
-
...(((_b = propInfo.jsDoc) === null || _b === void 0 ? void 0 : _b.description) && {
|
60
|
-
description: propInfo.jsDoc.description,
|
61
|
-
}),
|
62
|
-
});
|
63
|
-
}
|
64
|
-
});
|
65
|
-
return { props, slots };
|
66
|
-
};
|
67
|
-
/**
|
68
|
-
* Analyzes a React component to extract its props and slots information
|
69
|
-
*/
|
70
|
-
export async function analyzeComponent({ fileName, exportName, pkgPathAliases, resolveFromDir, }) {
|
71
|
-
var _a;
|
72
|
-
const props = {};
|
73
|
-
const slots = [];
|
74
|
-
try {
|
75
|
-
// Use analyzeExport to get TypeScript type information
|
76
|
-
const { typeInfo } = analyzeExport({
|
77
|
-
fileName,
|
78
|
-
exportName,
|
79
|
-
pkgPathAliases,
|
80
|
-
resolveFromDir,
|
81
|
-
});
|
82
|
-
// For function components, the first parameter contains the props type
|
83
|
-
if (typeInfo.type === 'function') {
|
84
|
-
const propsParam = (_a = typeInfo.parameters) === null || _a === void 0 ? void 0 : _a[0];
|
85
|
-
if ((propsParam === null || propsParam === void 0 ? void 0 : propsParam.typeInfo.type) === 'union') {
|
86
|
-
// Handle union component types by merging their properties
|
87
|
-
const mergedProperties = mergeUnionObjectProperties({
|
88
|
-
items: propsParam.typeInfo.items,
|
89
|
-
});
|
90
|
-
// Wrap the properties in a typeInfo object
|
91
|
-
const wrappedProperties = Object.fromEntries(Object.entries(mergedProperties).map(([key, info]) => [
|
92
|
-
key,
|
93
|
-
{ typeInfo: info },
|
94
|
-
]));
|
95
|
-
const result = processProps({
|
96
|
-
properties: wrappedProperties,
|
97
|
-
});
|
98
|
-
Object.assign(props, result.props);
|
99
|
-
slots.push(...result.slots);
|
100
|
-
}
|
101
|
-
else if ((propsParam === null || propsParam === void 0 ? void 0 : propsParam.typeInfo.type) === 'object') {
|
102
|
-
const result = processProps({
|
103
|
-
properties: propsParam.typeInfo.properties,
|
104
|
-
});
|
105
|
-
Object.assign(props, result.props);
|
106
|
-
slots.push(...result.slots);
|
107
|
-
}
|
108
|
-
}
|
109
|
-
if (typeInfo.type === 'class') {
|
110
|
-
// const propsParam = typeInfo.constructorParameters?.[0];
|
111
|
-
console.warn('class components are not setup for infer spec');
|
112
|
-
}
|
113
|
-
}
|
114
|
-
catch (error) {
|
115
|
-
console.log('Failed to analyze component types using TypeScript, falling back to PropTypes', error);
|
116
|
-
const component = await importComponent({
|
117
|
-
path: fileName,
|
118
|
-
alias: exportName,
|
119
|
-
pkgPathAliases,
|
120
|
-
resolveFrom: resolveFromDir,
|
121
|
-
});
|
122
|
-
// Fallback to checking PropTypes
|
123
|
-
const defaultProps = component.defaultProps || {};
|
124
|
-
const propTypes = component.propTypes || {};
|
125
|
-
Object.keys(propTypes).forEach((propName) => {
|
126
|
-
props[propName] = {
|
127
|
-
required: !Object.prototype.hasOwnProperty.call(defaultProps, propName) &&
|
128
|
-
propTypes[propName].isRequired,
|
129
|
-
typeInfo: {
|
130
|
-
type: 'misc',
|
131
|
-
tsRawType: 'unknown',
|
132
|
-
tsMetadata: {
|
133
|
-
typeFlags: [],
|
134
|
-
type: 'Unknown',
|
135
|
-
},
|
136
|
-
},
|
137
|
-
};
|
138
|
-
if (propName === 'children') {
|
139
|
-
slots.push({
|
140
|
-
title: 'children',
|
141
|
-
description: propTypes[propName].description,
|
142
|
-
});
|
143
|
-
}
|
144
|
-
});
|
145
|
-
}
|
146
|
-
return {
|
147
|
-
props,
|
148
|
-
slots,
|
149
|
-
};
|
150
|
-
}
|
151
|
-
//# sourceMappingURL=react-component-analyzer.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"react-component-analyzer.mjs","sourceRoot":"","sources":["../../../src/analyze/ut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