@fragments-sdk/mcp 0.5.18 → 0.6.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.
@@ -0,0 +1,1093 @@
1
+ import "./chunk-VRPDT3Y6.js";
2
+
3
+ // ../extract/dist/index.js
4
+ import { createRequire as __banner_createRequire } from "module";
5
+ import ts from "typescript";
6
+ import { readFileSync } from "fs";
7
+ import { resolve, dirname } from "path";
8
+ import { existsSync as existsSync2, statSync as statSync2 } from "fs";
9
+ import { dirname as dirname2, extname, join as join2, resolve as resolve2 } from "path";
10
+ import ts2 from "typescript";
11
+ import { resolve as resolve3, dirname as dirname3, basename } from "path";
12
+ import { existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
13
+ var require2 = __banner_createRequire(import.meta.url);
14
+ function createComponentExtractor(tsconfigPath) {
15
+ let projectVersion = 0;
16
+ const fileVersions = /* @__PURE__ */ new Map();
17
+ const fileSnapshots = /* @__PURE__ */ new Map();
18
+ const rootDir = tsconfigPath ? dirname(resolve(tsconfigPath)) : process.cwd();
19
+ const parsedCommandLine = tsconfigPath ? parseTsConfig(tsconfigPath) : inferCompilerOptions(rootDir);
20
+ const scriptFileNames = new Set(parsedCommandLine.fileNames);
21
+ const host = {
22
+ getProjectVersion: () => projectVersion.toString(),
23
+ getScriptVersion: (fileName) => (fileVersions.get(fileName) ?? 0).toString(),
24
+ getScriptSnapshot: (fileName) => {
25
+ const cached = fileSnapshots.get(fileName);
26
+ if (cached) return cached;
27
+ let text;
28
+ try {
29
+ text = readFileSync(fileName, "utf-8");
30
+ } catch {
31
+ return void 0;
32
+ }
33
+ const snapshot = ts.ScriptSnapshot.fromString(text);
34
+ fileSnapshots.set(fileName, snapshot);
35
+ return snapshot;
36
+ },
37
+ getScriptFileNames: () => [...scriptFileNames],
38
+ getCompilationSettings: () => parsedCommandLine.options,
39
+ getCurrentDirectory: () => rootDir,
40
+ getDefaultLibFileName: ts.getDefaultLibFilePath,
41
+ fileExists: ts.sys.fileExists,
42
+ readFile: ts.sys.readFile,
43
+ readDirectory: ts.sys.readDirectory,
44
+ directoryExists: ts.sys.directoryExists,
45
+ getDirectories: ts.sys.getDirectories,
46
+ resolveModuleNames: (moduleNames, containingFile) => moduleNames.map((moduleName) => {
47
+ const resolved = ts.resolveModuleName(
48
+ moduleName,
49
+ containingFile,
50
+ parsedCommandLine.options,
51
+ {
52
+ fileExists: ts.sys.fileExists,
53
+ readFile: ts.sys.readFile,
54
+ realpath: ts.sys.realpath,
55
+ directoryExists: ts.sys.directoryExists,
56
+ getDirectories: ts.sys.getDirectories,
57
+ getCurrentDirectory: () => rootDir
58
+ }
59
+ );
60
+ return resolved.resolvedModule;
61
+ })
62
+ };
63
+ const languageService = ts.createLanguageService(host, ts.createDocumentRegistry());
64
+ function ensureFile(filePath) {
65
+ const resolved = resolve(filePath);
66
+ if (!scriptFileNames.has(resolved)) {
67
+ scriptFileNames.add(resolved);
68
+ projectVersion++;
69
+ }
70
+ }
71
+ function getChecker() {
72
+ const program = languageService.getProgram();
73
+ if (!program) throw new Error("Failed to get program from LanguageService");
74
+ return program.getTypeChecker();
75
+ }
76
+ function getSourceFile(filePath) {
77
+ return languageService.getProgram()?.getSourceFile(resolve(filePath));
78
+ }
79
+ return {
80
+ extract(filePath, exportName) {
81
+ const resolved = resolve(filePath);
82
+ ensureFile(resolved);
83
+ const sourceFile = getSourceFile(resolved);
84
+ if (!sourceFile) return null;
85
+ const checker = getChecker();
86
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
87
+ if (!moduleSymbol) return null;
88
+ const exports = checker.getExportsOfModule(moduleSymbol);
89
+ const targetName = exportName ?? findPrimaryExport(exports, sourceFile);
90
+ if (!targetName) return null;
91
+ const exportSymbol = exports.find((s) => s.getName() === targetName);
92
+ if (!exportSymbol) return null;
93
+ const component = resolveExportedComponent(checker, exportSymbol, sourceFile);
94
+ if (!component) return null;
95
+ return buildComponentMeta(checker, component, resolved, sourceFile, exports);
96
+ },
97
+ extractAll(filePath) {
98
+ const resolved = resolve(filePath);
99
+ ensureFile(resolved);
100
+ const sourceFile = getSourceFile(resolved);
101
+ if (!sourceFile) return [];
102
+ const checker = getChecker();
103
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
104
+ if (!moduleSymbol) return [];
105
+ const exports = checker.getExportsOfModule(moduleSymbol);
106
+ const results = [];
107
+ for (const exportSymbol of exports) {
108
+ const name = exportSymbol.getName();
109
+ if (!/^[A-Z]/.test(name)) continue;
110
+ const component = resolveExportedComponent(checker, exportSymbol, sourceFile);
111
+ if (!component) continue;
112
+ const meta = buildComponentMeta(checker, component, resolved, sourceFile, exports);
113
+ if (meta) results.push(meta);
114
+ }
115
+ return results;
116
+ },
117
+ invalidate(filePath) {
118
+ const resolved = resolve(filePath);
119
+ fileVersions.set(resolved, (fileVersions.get(resolved) ?? 0) + 1);
120
+ fileSnapshots.delete(resolved);
121
+ projectVersion++;
122
+ },
123
+ dispose() {
124
+ languageService.dispose();
125
+ fileSnapshots.clear();
126
+ fileVersions.clear();
127
+ }
128
+ };
129
+ }
130
+ function parseTsConfig(tsconfigPath) {
131
+ const resolved = resolve(tsconfigPath);
132
+ const configFile = ts.readConfigFile(resolved, ts.sys.readFile);
133
+ if (configFile.error) {
134
+ throw new Error(`Failed to read tsconfig: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`);
135
+ }
136
+ return ts.parseJsonConfigFileContent(
137
+ configFile.config,
138
+ ts.sys,
139
+ dirname(resolved),
140
+ void 0,
141
+ resolved
142
+ );
143
+ }
144
+ function inferCompilerOptions(rootDir) {
145
+ return {
146
+ options: {
147
+ target: ts.ScriptTarget.ES2022,
148
+ module: ts.ModuleKind.ESNext,
149
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
150
+ jsx: ts.JsxEmit.ReactJSX,
151
+ allowSyntheticDefaultImports: true,
152
+ esModuleInterop: true,
153
+ skipLibCheck: true,
154
+ strict: false,
155
+ noEmit: true
156
+ },
157
+ fileNames: [],
158
+ errors: []
159
+ };
160
+ }
161
+ function findPrimaryExport(exports, sourceFile) {
162
+ const defaultExport = exports.find((s) => s.getName() === "default");
163
+ if (defaultExport) return "default";
164
+ for (const s of exports) {
165
+ if (/^[A-Z][a-zA-Z0-9]*$/.test(s.getName())) {
166
+ return s.getName();
167
+ }
168
+ }
169
+ return null;
170
+ }
171
+ function resolveExportedComponent(checker, exportSymbol, sourceFile) {
172
+ const name = exportSymbol.getName();
173
+ let symbol = exportSymbol;
174
+ if (symbol.flags & ts.SymbolFlags.Alias) {
175
+ symbol = checker.getAliasedSymbol(symbol);
176
+ }
177
+ const declarations = symbol.getDeclarations();
178
+ if (!declarations || declarations.length === 0) return null;
179
+ const declaration = declarations[0];
180
+ if (ts.isVariableDeclaration(declaration) && declaration.initializer) {
181
+ return resolveFromExpression(checker, name, declaration.initializer, declaration, sourceFile);
182
+ }
183
+ if (ts.isFunctionDeclaration(declaration)) {
184
+ const propsType = extractPropsFromFunctionLike(checker, declaration);
185
+ return propsType ? { name, propsType, componentNode: declaration, compoundParts: null } : null;
186
+ }
187
+ if (ts.isExportAssignment(declaration) && declaration.expression) {
188
+ return resolveFromExpression(checker, name, declaration.expression, null, sourceFile);
189
+ }
190
+ return null;
191
+ }
192
+ function resolveFromExpression(checker, name, expression, variableDecl, sourceFile) {
193
+ expression = unwrapExpression(expression);
194
+ if (ts.isArrowFunction(expression) || ts.isFunctionExpression(expression)) {
195
+ const propsType = extractPropsFromFunctionLike(checker, expression);
196
+ return propsType ? { name, propsType, componentNode: expression, compoundParts: null } : null;
197
+ }
198
+ if (ts.isCallExpression(expression)) {
199
+ return resolveCallExpression(checker, name, expression, variableDecl, sourceFile);
200
+ }
201
+ if (ts.isIdentifier(expression)) {
202
+ const sym = checker.getSymbolAtLocation(expression);
203
+ if (sym) {
204
+ const decls = sym.getDeclarations();
205
+ if (decls && decls.length > 0) {
206
+ const decl = decls[0];
207
+ if (ts.isVariableDeclaration(decl) && decl.initializer) {
208
+ return resolveFromExpression(checker, name, decl.initializer, decl, sourceFile);
209
+ }
210
+ if (ts.isFunctionDeclaration(decl)) {
211
+ const propsType = extractPropsFromFunctionLike(checker, decl);
212
+ return propsType ? { name, propsType, componentNode: decl, compoundParts: null } : null;
213
+ }
214
+ }
215
+ }
216
+ }
217
+ if (variableDecl?.type && ts.isTypeReferenceNode(variableDecl.type)) {
218
+ const typeName = variableDecl.type.typeName.getText(sourceFile);
219
+ if (typeName.includes("FC") || typeName.includes("FunctionComponent")) {
220
+ const typeArg = variableDecl.type.typeArguments?.[0];
221
+ if (typeArg) {
222
+ const propsType = checker.getTypeFromTypeNode(typeArg);
223
+ return { name, propsType, componentNode: expression, compoundParts: null };
224
+ }
225
+ }
226
+ }
227
+ return null;
228
+ }
229
+ function resolveCallExpression(checker, name, call, variableDecl, sourceFile) {
230
+ const callee = call.expression;
231
+ if (isObjectAssignCall(callee, sourceFile)) {
232
+ return resolveObjectAssign(checker, name, call, sourceFile);
233
+ }
234
+ if (isForwardRefCall(callee)) {
235
+ return resolveForwardRef(checker, name, call, sourceFile);
236
+ }
237
+ if (isMemoCall(callee)) {
238
+ const innerArg = call.arguments[0];
239
+ if (innerArg) {
240
+ return resolveFromExpression(checker, name, innerArg, variableDecl, sourceFile);
241
+ }
242
+ }
243
+ return null;
244
+ }
245
+ function resolveObjectAssign(checker, name, call, sourceFile) {
246
+ if (call.arguments.length < 2) return null;
247
+ const rootExpr = call.arguments[0];
248
+ const rootResult = resolveFromExpression(checker, name, rootExpr, null, sourceFile);
249
+ const subsArg = call.arguments[1];
250
+ const compoundParts = /* @__PURE__ */ new Map();
251
+ if (ts.isObjectLiteralExpression(subsArg)) {
252
+ for (const prop of subsArg.properties) {
253
+ let subName = null;
254
+ let subExpression = null;
255
+ if (ts.isShorthandPropertyAssignment(prop)) {
256
+ subName = prop.name.text;
257
+ const sym = checker.getSymbolAtLocation(prop.name);
258
+ if (sym) {
259
+ const subPropsType = extractPropsFromComponentSymbol(checker, sym);
260
+ if (subPropsType) {
261
+ compoundParts.set(subName, subPropsType);
262
+ }
263
+ }
264
+ } else if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {
265
+ subName = prop.name.text;
266
+ subExpression = prop.initializer;
267
+ if (subExpression) {
268
+ const subType = extractPropsFromExpression(checker, subExpression, sourceFile);
269
+ if (subType) {
270
+ compoundParts.set(subName, subType);
271
+ }
272
+ }
273
+ }
274
+ }
275
+ }
276
+ return {
277
+ name,
278
+ propsType: rootResult?.propsType ?? null,
279
+ componentNode: rootResult?.componentNode ?? rootExpr,
280
+ compoundParts: compoundParts.size > 0 ? compoundParts : null
281
+ };
282
+ }
283
+ function extractPropsFromComponentSymbol(checker, symbol) {
284
+ let sym = symbol;
285
+ if (sym.flags & ts.SymbolFlags.Alias) {
286
+ sym = checker.getAliasedSymbol(sym);
287
+ }
288
+ const decls = sym.getDeclarations();
289
+ if (!decls || decls.length === 0) return null;
290
+ const decl = decls[0];
291
+ if (ts.isFunctionDeclaration(decl)) {
292
+ return extractPropsFromFunctionLike(checker, decl);
293
+ }
294
+ if (ts.isVariableDeclaration(decl) && decl.initializer) {
295
+ return extractPropsFromExpressionDeep(checker, decl);
296
+ }
297
+ return null;
298
+ }
299
+ function extractPropsFromExpression(checker, expr, sourceFile) {
300
+ expr = unwrapExpression(expr);
301
+ if (ts.isIdentifier(expr)) {
302
+ const sym = checker.getSymbolAtLocation(expr);
303
+ if (sym) return extractPropsFromComponentSymbol(checker, sym);
304
+ }
305
+ if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr)) {
306
+ return extractPropsFromFunctionLike(checker, expr);
307
+ }
308
+ if (ts.isCallExpression(expr)) {
309
+ if (isForwardRefCall(expr.expression)) {
310
+ const typeArg = expr.typeArguments?.[1];
311
+ if (typeArg) return checker.getTypeFromTypeNode(typeArg);
312
+ const innerArg = expr.arguments[0];
313
+ if (innerArg && (ts.isArrowFunction(innerArg) || ts.isFunctionExpression(innerArg))) {
314
+ return extractPropsFromFunctionLike(checker, innerArg);
315
+ }
316
+ }
317
+ if (isMemoCall(expr.expression) && expr.arguments[0]) {
318
+ return extractPropsFromExpression(checker, expr.arguments[0], sourceFile);
319
+ }
320
+ }
321
+ return null;
322
+ }
323
+ function extractPropsFromExpressionDeep(checker, decl) {
324
+ if (!decl.initializer) return null;
325
+ const expr = unwrapExpression(decl.initializer);
326
+ if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr)) {
327
+ return extractPropsFromFunctionLike(checker, expr);
328
+ }
329
+ if (ts.isCallExpression(expr)) {
330
+ if (isForwardRefCall(expr.expression)) {
331
+ const typeArg = expr.typeArguments?.[1];
332
+ if (typeArg) return checker.getTypeFromTypeNode(typeArg);
333
+ const innerArg = expr.arguments[0];
334
+ if (innerArg && (ts.isArrowFunction(innerArg) || ts.isFunctionExpression(innerArg))) {
335
+ return extractPropsFromFunctionLike(checker, innerArg);
336
+ }
337
+ }
338
+ if (isMemoCall(expr.expression) && expr.arguments[0]) {
339
+ return extractPropsFromExpressionDeep(checker, {
340
+ ...decl,
341
+ initializer: expr.arguments[0]
342
+ });
343
+ }
344
+ }
345
+ return null;
346
+ }
347
+ function resolveForwardRef(checker, name, call, sourceFile) {
348
+ const propsTypeArg = call.typeArguments?.[1];
349
+ if (propsTypeArg) {
350
+ const propsType = checker.getTypeFromTypeNode(propsTypeArg);
351
+ const innerArg2 = call.arguments[0];
352
+ const componentNode = innerArg2 && (ts.isArrowFunction(innerArg2) || ts.isFunctionExpression(innerArg2)) ? innerArg2 : null;
353
+ return { name, propsType, componentNode, compoundParts: null };
354
+ }
355
+ const innerArg = call.arguments[0];
356
+ if (innerArg) {
357
+ if (ts.isArrowFunction(innerArg) || ts.isFunctionExpression(innerArg)) {
358
+ const propsType = extractPropsFromFunctionLike(checker, innerArg);
359
+ return propsType ? { name, propsType, componentNode: innerArg, compoundParts: null } : null;
360
+ }
361
+ if (ts.isIdentifier(innerArg)) {
362
+ const sym = checker.getSymbolAtLocation(innerArg);
363
+ if (sym) {
364
+ const propsType = extractPropsFromComponentSymbol(checker, sym);
365
+ if (propsType) return { name, propsType, componentNode: innerArg, compoundParts: null };
366
+ }
367
+ }
368
+ }
369
+ return null;
370
+ }
371
+ function extractPropsFromFunctionLike(checker, func) {
372
+ const firstParam = func.parameters[0];
373
+ if (!firstParam) return null;
374
+ if (firstParam.type) {
375
+ const directType = checker.getTypeFromTypeNode(firstParam.type);
376
+ if (checker.getPropertiesOfType(directType).length > 0) {
377
+ return directType;
378
+ }
379
+ const apparentType = checker.getApparentType(directType);
380
+ if (checker.getPropertiesOfType(apparentType).length > 0) {
381
+ return apparentType;
382
+ }
383
+ const paramType = checker.getTypeAtLocation(firstParam);
384
+ if (checker.getPropertiesOfType(paramType).length > 0) {
385
+ return paramType;
386
+ }
387
+ const constrainedType = checker.getBaseConstraintOfType(directType);
388
+ if (constrainedType && checker.getPropertiesOfType(constrainedType).length > 0) {
389
+ return constrainedType;
390
+ }
391
+ return directType;
392
+ }
393
+ const paramSymbol = checker.getSymbolAtLocation(firstParam.name);
394
+ if (paramSymbol) {
395
+ return checker.getTypeOfSymbolAtLocation(paramSymbol, firstParam);
396
+ }
397
+ return null;
398
+ }
399
+ function buildComponentMeta(checker, component, filePath, sourceFile, moduleExports) {
400
+ const props = {};
401
+ const sourceFilePath = toPosixPath(sourceFile.fileName);
402
+ if (component.propsType) {
403
+ extractPropsFromType(checker, component.propsType, props, sourceFilePath);
404
+ if (Object.keys(props).length === 0) {
405
+ const apparentPropsType = checker.getApparentType(component.propsType);
406
+ if (apparentPropsType !== component.propsType) {
407
+ extractPropsFromType(checker, apparentPropsType, props, sourceFilePath);
408
+ }
409
+ }
410
+ if (Object.keys(props).length === 0) {
411
+ const constrainedPropsType = checker.getBaseConstraintOfType(component.propsType);
412
+ if (constrainedPropsType) {
413
+ extractPropsFromType(checker, constrainedPropsType, props, sourceFilePath);
414
+ }
415
+ }
416
+ }
417
+ const destructuredProps = component.componentNode ? extractDestructuredPropNames(component.componentNode) : /* @__PURE__ */ new Set();
418
+ for (const propName of destructuredProps) {
419
+ if (props[propName]) {
420
+ props[propName].source = "local";
421
+ }
422
+ }
423
+ const defaults = component.componentNode ? extractDefaultValues(component.componentNode) : {};
424
+ for (const [propName, defaultVal] of Object.entries(defaults)) {
425
+ if (props[propName]) {
426
+ props[propName].default = defaultVal;
427
+ }
428
+ }
429
+ let composition = null;
430
+ if (component.compoundParts && component.compoundParts.size > 0) {
431
+ const parts = [];
432
+ for (const [partName, partType] of component.compoundParts) {
433
+ const partProps = {};
434
+ extractPropsFromType(checker, partType, partProps, sourceFilePath);
435
+ parts.push({ name: partName, props: partProps });
436
+ }
437
+ composition = {
438
+ pattern: "compound",
439
+ parts,
440
+ required: []
441
+ // Could be inferred from usage patterns
442
+ };
443
+ }
444
+ let description = "";
445
+ const componentSymbol = moduleExports.find((s) => s.getName() === component.name);
446
+ if (componentSymbol) {
447
+ description = extractJSDocDescription(checker, componentSymbol);
448
+ }
449
+ const exportNames = moduleExports.filter((s) => /^[A-Z]/.test(s.getName())).map((s) => s.getName());
450
+ const dependencies = extractDependencies(sourceFile);
451
+ return {
452
+ name: component.name,
453
+ filePath,
454
+ description,
455
+ props,
456
+ composition,
457
+ exports: exportNames,
458
+ dependencies
459
+ };
460
+ }
461
+ function extractPropsFromType(checker, propsType, result, sourceFilePath) {
462
+ for (const symbol of checker.getPropertiesOfType(propsType)) {
463
+ const propName = symbol.getName();
464
+ if (propName.startsWith("_") || propName.startsWith("$")) continue;
465
+ if (propName === "key" || propName === "ref") continue;
466
+ const declarations = symbol.getDeclarations() ?? [];
467
+ const isLocal = declarations.some(
468
+ (d) => toPosixPath(d.getSourceFile().fileName) === sourceFilePath
469
+ );
470
+ const referenceNode = declarations[0];
471
+ if (!referenceNode) continue;
472
+ const propType = checker.getTypeOfSymbolAtLocation(symbol, referenceNode);
473
+ const serialized = serializePropType(checker, propType);
474
+ const description = ts.displayPartsToString(symbol.getDocumentationComment(checker)).trim();
475
+ const required = (symbol.flags & ts.SymbolFlags.Optional) === 0;
476
+ let jsDocDefault;
477
+ const jsDocTags = symbol.getJsDocTags(checker);
478
+ const defaultTag = jsDocTags.find((t) => t.name === "default");
479
+ if (defaultTag?.text) {
480
+ jsDocDefault = ts.displayPartsToString(defaultTag.text).trim();
481
+ }
482
+ result[propName] = {
483
+ name: propName,
484
+ type: serialized.type,
485
+ typeKind: serialized.typeKind,
486
+ values: serialized.values,
487
+ default: jsDocDefault,
488
+ description: description || void 0,
489
+ required,
490
+ source: isLocal ? "local" : "inherited"
491
+ };
492
+ }
493
+ }
494
+ function serializePropType(checker, type) {
495
+ const aliasSymbol = type.aliasSymbol;
496
+ if (aliasSymbol) {
497
+ const aliasName = aliasSymbol.getName();
498
+ if (aliasName === "ReactNode") {
499
+ return { type: "ReactNode", typeKind: "node" };
500
+ }
501
+ if (aliasName === "ReactElement") {
502
+ return { type: "ReactElement", typeKind: "element" };
503
+ }
504
+ }
505
+ if (type.isUnion()) {
506
+ const nonNullableTypes = type.types.filter(
507
+ (t) => !(t.flags & ts.TypeFlags.Undefined || t.flags & ts.TypeFlags.Null || t.flags & ts.TypeFlags.Void)
508
+ );
509
+ if (nonNullableTypes.length === 1) {
510
+ return serializePropType(checker, nonNullableTypes[0]);
511
+ }
512
+ if (nonNullableTypes.length > 0 && nonNullableTypes.every((t) => t.isStringLiteral())) {
513
+ const values = nonNullableTypes.map((t) => t.value);
514
+ return {
515
+ type: values.map((v) => `"${v}"`).join(" | "),
516
+ typeKind: "enum",
517
+ values
518
+ };
519
+ }
520
+ if (nonNullableTypes.every((t) => isBooleanLike(t))) {
521
+ return { type: "boolean", typeKind: "boolean" };
522
+ }
523
+ const typeStr2 = checker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
524
+ return { type: typeStr2, typeKind: "union" };
525
+ }
526
+ const typeStr = checker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
527
+ if (typeStr.includes("ReactNode")) {
528
+ return { type: "ReactNode", typeKind: "node" };
529
+ }
530
+ if (typeStr.includes("ReactElement") || typeStr.includes("JSX.Element")) {
531
+ return { type: "ReactElement", typeKind: "element" };
532
+ }
533
+ if (type.getCallSignatures().length > 0) {
534
+ return { type: typeStr, typeKind: "function" };
535
+ }
536
+ if (type.flags & ts.TypeFlags.String) return { type: "string", typeKind: "string" };
537
+ if (type.flags & ts.TypeFlags.Number) return { type: "number", typeKind: "number" };
538
+ if (type.flags & ts.TypeFlags.Boolean || type.flags & ts.TypeFlags.BooleanLiteral) {
539
+ return { type: "boolean", typeKind: "boolean" };
540
+ }
541
+ if (type.isStringLiteral()) {
542
+ return { type: `"${type.value}"`, typeKind: "enum", values: [type.value] };
543
+ }
544
+ if (checker.isArrayType(type) || checker.isTupleType(type)) {
545
+ return { type: typeStr, typeKind: "array" };
546
+ }
547
+ if (type.flags & ts.TypeFlags.Object) {
548
+ return { type: typeStr, typeKind: "object" };
549
+ }
550
+ return { type: typeStr, typeKind: "custom" };
551
+ }
552
+ function extractDefaultValues(node) {
553
+ const defaults = {};
554
+ let funcNode = null;
555
+ if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
556
+ funcNode = node;
557
+ }
558
+ if (!funcNode?.parameters?.length) return defaults;
559
+ const firstParam = funcNode.parameters[0];
560
+ if (!ts.isObjectBindingPattern(firstParam.name)) return defaults;
561
+ for (const element of firstParam.name.elements) {
562
+ let propName = null;
563
+ if (element.propertyName) {
564
+ if (ts.isIdentifier(element.propertyName) || ts.isStringLiteral(element.propertyName)) {
565
+ propName = element.propertyName.text;
566
+ }
567
+ } else if (ts.isIdentifier(element.name)) {
568
+ propName = element.name.text;
569
+ }
570
+ if (!propName || !element.initializer) continue;
571
+ const value = readLiteralValue(element.initializer);
572
+ if (value !== void 0) {
573
+ defaults[propName] = value;
574
+ }
575
+ }
576
+ return defaults;
577
+ }
578
+ function extractDestructuredPropNames(node) {
579
+ const names = /* @__PURE__ */ new Set();
580
+ let funcNode = null;
581
+ if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
582
+ funcNode = node;
583
+ }
584
+ if (!funcNode?.parameters?.length) return names;
585
+ const firstParam = funcNode.parameters[0];
586
+ if (!ts.isObjectBindingPattern(firstParam.name)) return names;
587
+ for (const element of firstParam.name.elements) {
588
+ if (element.dotDotDotToken || !ts.isIdentifier(element.name)) continue;
589
+ const propName = element.propertyName ? element.propertyName.getText() : element.name.text;
590
+ if (propName === "className" || propName === "children" || propName === "ref") {
591
+ continue;
592
+ }
593
+ names.add(propName);
594
+ }
595
+ return names;
596
+ }
597
+ function readLiteralValue(expression) {
598
+ if (ts.isStringLiteral(expression) || ts.isNoSubstitutionTemplateLiteral(expression)) {
599
+ return expression.text;
600
+ }
601
+ if (ts.isNumericLiteral(expression)) {
602
+ return expression.text;
603
+ }
604
+ if (expression.kind === ts.SyntaxKind.TrueKeyword) return "true";
605
+ if (expression.kind === ts.SyntaxKind.FalseKeyword) return "false";
606
+ if (expression.kind === ts.SyntaxKind.NullKeyword) return "null";
607
+ if (ts.isPrefixUnaryExpression(expression) && expression.operator === ts.SyntaxKind.MinusToken && ts.isNumericLiteral(expression.operand)) {
608
+ return `-${expression.operand.text}`;
609
+ }
610
+ return void 0;
611
+ }
612
+ function extractJSDocDescription(checker, symbol) {
613
+ let sym = symbol;
614
+ if (sym.flags & ts.SymbolFlags.Alias) {
615
+ sym = checker.getAliasedSymbol(sym);
616
+ }
617
+ const docComment = ts.displayPartsToString(sym.getDocumentationComment(checker)).trim();
618
+ if (docComment) return docComment;
619
+ const decls = sym.getDeclarations();
620
+ if (decls) {
621
+ for (const decl of decls) {
622
+ const sourceFile = decl.getSourceFile();
623
+ for (const stmt of sourceFile.statements) {
624
+ if ((ts.isInterfaceDeclaration(stmt) || ts.isTypeAliasDeclaration(stmt)) && stmt.name.text === `${symbol.getName()}Props`) {
625
+ const propsDoc = ts.displayPartsToString(
626
+ checker.getSymbolAtLocation(stmt.name)?.getDocumentationComment(checker) ?? []
627
+ ).trim();
628
+ if (propsDoc) return propsDoc;
629
+ }
630
+ }
631
+ }
632
+ }
633
+ return "";
634
+ }
635
+ function extractDependencies(sourceFile) {
636
+ const deps = [];
637
+ for (const stmt of sourceFile.statements) {
638
+ if (!ts.isImportDeclaration(stmt)) continue;
639
+ if (!ts.isStringLiteral(stmt.moduleSpecifier)) continue;
640
+ const modulePath = stmt.moduleSpecifier.text;
641
+ if (!modulePath.startsWith(".") && !modulePath.startsWith("/")) continue;
642
+ const clause = stmt.importClause;
643
+ if (!clause) continue;
644
+ if (clause.name && /^[A-Z]/.test(clause.name.text)) {
645
+ deps.push(clause.name.text);
646
+ }
647
+ if (clause.namedBindings && ts.isNamedImports(clause.namedBindings)) {
648
+ for (const element of clause.namedBindings.elements) {
649
+ if (/^[A-Z]/.test(element.name.text)) {
650
+ deps.push(element.name.text);
651
+ }
652
+ }
653
+ }
654
+ }
655
+ return deps;
656
+ }
657
+ function unwrapExpression(expr) {
658
+ while (true) {
659
+ if (ts.isParenthesizedExpression(expr)) {
660
+ expr = expr.expression;
661
+ } else if (ts.isAsExpression(expr) || ts.isTypeAssertionExpression(expr)) {
662
+ expr = expr.expression;
663
+ } else {
664
+ return expr;
665
+ }
666
+ }
667
+ }
668
+ function isObjectAssignCall(callee, sourceFile) {
669
+ if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "Object" && callee.name.text === "assign") {
670
+ return true;
671
+ }
672
+ return false;
673
+ }
674
+ function isForwardRefCall(callee) {
675
+ if (ts.isPropertyAccessExpression(callee) && callee.name.text === "forwardRef") {
676
+ return true;
677
+ }
678
+ if (ts.isIdentifier(callee) && callee.text === "forwardRef") {
679
+ return true;
680
+ }
681
+ return false;
682
+ }
683
+ function isMemoCall(callee) {
684
+ if (ts.isPropertyAccessExpression(callee) && callee.name.text === "memo") {
685
+ return true;
686
+ }
687
+ if (ts.isIdentifier(callee) && callee.text === "memo") {
688
+ return true;
689
+ }
690
+ return false;
691
+ }
692
+ function isBooleanLike(type) {
693
+ return (type.flags & ts.TypeFlags.BooleanLike) !== 0 || type.flags === ts.TypeFlags.BooleanLiteral;
694
+ }
695
+ function toPosixPath(filePath) {
696
+ return filePath.replace(/\\/g, "/");
697
+ }
698
+ function toPosixPath2(filePath) {
699
+ return filePath.replace(/\\/g, "/");
700
+ }
701
+ function isFile(filePath) {
702
+ if (!existsSync2(filePath)) return false;
703
+ try {
704
+ return statSync2(filePath).isFile();
705
+ } catch {
706
+ return false;
707
+ }
708
+ }
709
+ function resolveModulePath(basePath) {
710
+ const candidates = [];
711
+ const extension = extname(basePath);
712
+ if (extension) {
713
+ candidates.push(basePath);
714
+ } else {
715
+ candidates.push(
716
+ `${basePath}.tsx`,
717
+ `${basePath}.ts`,
718
+ `${basePath}.jsx`,
719
+ `${basePath}.js`,
720
+ join2(basePath, "index.tsx"),
721
+ join2(basePath, "index.ts"),
722
+ join2(basePath, "index.jsx"),
723
+ join2(basePath, "index.js")
724
+ );
725
+ }
726
+ for (const candidate of candidates) {
727
+ if (isFile(candidate)) {
728
+ return resolve2(candidate);
729
+ }
730
+ }
731
+ return null;
732
+ }
733
+ function resolveComponentSourcePath(fragmentFileAbsolutePath, componentImportPath) {
734
+ if (!componentImportPath) return null;
735
+ if (!componentImportPath.startsWith(".")) return null;
736
+ const fragmentDir = dirname2(fragmentFileAbsolutePath);
737
+ const basePath = resolve2(fragmentDir, componentImportPath);
738
+ return resolveModulePath(basePath);
739
+ }
740
+ function collectTopLevelDeclarations(sourceFile) {
741
+ const typeDeclarations = /* @__PURE__ */ new Map();
742
+ const functionDeclarations = /* @__PURE__ */ new Map();
743
+ const variableDeclarations = /* @__PURE__ */ new Map();
744
+ for (const node of sourceFile.statements) {
745
+ if (ts2.isInterfaceDeclaration(node)) {
746
+ typeDeclarations.set(node.name.text, node);
747
+ continue;
748
+ }
749
+ if (ts2.isTypeAliasDeclaration(node)) {
750
+ typeDeclarations.set(node.name.text, node);
751
+ continue;
752
+ }
753
+ if (ts2.isFunctionDeclaration(node) && node.name) {
754
+ functionDeclarations.set(node.name.text, node);
755
+ continue;
756
+ }
757
+ if (ts2.isVariableStatement(node)) {
758
+ for (const declaration of node.declarationList.declarations) {
759
+ if (ts2.isIdentifier(declaration.name)) {
760
+ variableDeclarations.set(declaration.name.text, declaration);
761
+ }
762
+ }
763
+ }
764
+ }
765
+ return { typeDeclarations, functionDeclarations, variableDeclarations };
766
+ }
767
+ function readDefaultValue(expression) {
768
+ if (ts2.isStringLiteral(expression) || ts2.isNoSubstitutionTemplateLiteral(expression)) {
769
+ return expression.text;
770
+ }
771
+ if (ts2.isNumericLiteral(expression)) {
772
+ return Number(expression.text);
773
+ }
774
+ if (expression.kind === ts2.SyntaxKind.TrueKeyword) return true;
775
+ if (expression.kind === ts2.SyntaxKind.FalseKeyword) return false;
776
+ if (expression.kind === ts2.SyntaxKind.NullKeyword) return null;
777
+ if (ts2.isPrefixUnaryExpression(expression) && expression.operator === ts2.SyntaxKind.MinusToken && ts2.isNumericLiteral(expression.operand)) {
778
+ return -Number(expression.operand.text);
779
+ }
780
+ return void 0;
781
+ }
782
+ function extractDefaultValues2(componentNode) {
783
+ const defaults = {};
784
+ if (!componentNode?.parameters?.length) return defaults;
785
+ const firstParam = componentNode.parameters[0];
786
+ if (!ts2.isObjectBindingPattern(firstParam.name)) return defaults;
787
+ for (const element of firstParam.name.elements) {
788
+ let propName = null;
789
+ if (element.propertyName) {
790
+ if (ts2.isIdentifier(element.propertyName) || ts2.isStringLiteral(element.propertyName)) {
791
+ propName = element.propertyName.text;
792
+ }
793
+ } else if (ts2.isIdentifier(element.name)) {
794
+ propName = element.name.text;
795
+ }
796
+ if (!propName || !element.initializer) continue;
797
+ const value = readDefaultValue(element.initializer);
798
+ if (value !== void 0) {
799
+ defaults[propName] = value;
800
+ }
801
+ }
802
+ return defaults;
803
+ }
804
+ function isNullishType(type) {
805
+ return (type.flags & ts2.TypeFlags.Null) !== 0 || (type.flags & ts2.TypeFlags.Undefined) !== 0 || (type.flags & ts2.TypeFlags.Void) !== 0;
806
+ }
807
+ function isBooleanLikeType(type) {
808
+ return (type.flags & ts2.TypeFlags.BooleanLike) !== 0 || type.flags === ts2.TypeFlags.BooleanLiteral;
809
+ }
810
+ function inferPropType(type, checker) {
811
+ const typeText = checker.typeToString(type, void 0, ts2.TypeFormatFlags.NoTruncation);
812
+ if (typeText.includes("ReactNode")) {
813
+ return { type: "node" };
814
+ }
815
+ if (typeText.includes("ReactElement") || typeText.includes("JSX.Element")) {
816
+ return { type: "element" };
817
+ }
818
+ if (type.getCallSignatures().length > 0) {
819
+ return { type: "function" };
820
+ }
821
+ if (checker.isArrayType(type) || checker.isTupleType(type)) {
822
+ return { type: "array" };
823
+ }
824
+ if (type.isUnion()) {
825
+ const nonNullableTypes = type.types.filter((unionType) => !isNullishType(unionType));
826
+ if (nonNullableTypes.length === 1) {
827
+ return inferPropType(nonNullableTypes[0], checker);
828
+ }
829
+ const stringLiteralValues = nonNullableTypes.filter((unionType) => (unionType.flags & ts2.TypeFlags.StringLiteral) !== 0).map((unionType) => unionType.value);
830
+ if (stringLiteralValues.length > 0 && stringLiteralValues.length === nonNullableTypes.length) {
831
+ return { type: "enum", values: stringLiteralValues };
832
+ }
833
+ if (nonNullableTypes.every((unionType) => isBooleanLikeType(unionType))) {
834
+ return { type: "boolean" };
835
+ }
836
+ return { type: "union" };
837
+ }
838
+ if ((type.flags & ts2.TypeFlags.StringLike) !== 0) {
839
+ return { type: "string" };
840
+ }
841
+ if ((type.flags & ts2.TypeFlags.NumberLike) !== 0) {
842
+ return { type: "number" };
843
+ }
844
+ if ((type.flags & ts2.TypeFlags.BooleanLike) !== 0) {
845
+ return { type: "boolean" };
846
+ }
847
+ if ((type.flags & ts2.TypeFlags.Object) !== 0) {
848
+ return { type: "object" };
849
+ }
850
+ return { type: "custom" };
851
+ }
852
+ function resolveComponentSignature(exportName, declarations, sourceFile) {
853
+ const visitedNames = /* @__PURE__ */ new Set();
854
+ const typeNodeFromFunction = (node) => ({
855
+ propsTypeNode: node.parameters[0]?.type ?? null,
856
+ componentNode: node
857
+ });
858
+ const resolveFromExpression2 = (expression) => {
859
+ if (ts2.isParenthesizedExpression(expression)) {
860
+ return resolveFromExpression2(expression.expression);
861
+ }
862
+ if (ts2.isAsExpression(expression) || ts2.isTypeAssertionExpression(expression)) {
863
+ return resolveFromExpression2(expression.expression);
864
+ }
865
+ if (ts2.isArrowFunction(expression) || ts2.isFunctionExpression(expression)) {
866
+ return typeNodeFromFunction(expression);
867
+ }
868
+ if (ts2.isIdentifier(expression)) {
869
+ return resolveFromIdentifier(expression.text);
870
+ }
871
+ if (ts2.isCallExpression(expression)) {
872
+ if (ts2.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === "forwardRef") {
873
+ const forwardRefPropsType = expression.typeArguments?.[1] ?? null;
874
+ const innerArg = expression.arguments[0];
875
+ const inner = innerArg && (ts2.isArrowFunction(innerArg) || ts2.isFunctionExpression(innerArg)) ? typeNodeFromFunction(innerArg) : innerArg && ts2.isIdentifier(innerArg) ? resolveFromIdentifier(innerArg.text) : { propsTypeNode: null, componentNode: null };
876
+ return {
877
+ propsTypeNode: forwardRefPropsType ?? inner.propsTypeNode,
878
+ componentNode: inner.componentNode
879
+ };
880
+ }
881
+ if (ts2.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === "memo" && expression.arguments[0]) {
882
+ return resolveFromExpression2(expression.arguments[0]);
883
+ }
884
+ if (ts2.isPropertyAccessExpression(expression.expression) && expression.expression.expression.getText(sourceFile) === "Object" && expression.expression.name.text === "assign" && expression.arguments[0]) {
885
+ return resolveFromExpression2(expression.arguments[0]);
886
+ }
887
+ }
888
+ return { propsTypeNode: null, componentNode: null };
889
+ };
890
+ const resolveFromVariable = (declaration) => {
891
+ if (declaration.type && ts2.isTypeReferenceNode(declaration.type) && declaration.type.typeArguments?.length) {
892
+ const typeName = declaration.type.typeName.getText(sourceFile);
893
+ if (typeName.includes("FC") || typeName.includes("FunctionComponent")) {
894
+ const componentNode = declaration.initializer && (ts2.isArrowFunction(declaration.initializer) || ts2.isFunctionExpression(declaration.initializer)) ? declaration.initializer : null;
895
+ return {
896
+ propsTypeNode: declaration.type.typeArguments[0] ?? null,
897
+ componentNode
898
+ };
899
+ }
900
+ }
901
+ if (declaration.initializer) {
902
+ return resolveFromExpression2(declaration.initializer);
903
+ }
904
+ return { propsTypeNode: null, componentNode: null };
905
+ };
906
+ const resolveFromIdentifier = (name) => {
907
+ if (!name || visitedNames.has(name)) {
908
+ return { propsTypeNode: null, componentNode: null };
909
+ }
910
+ visitedNames.add(name);
911
+ const functionDeclaration = declarations.functionDeclarations.get(name);
912
+ if (functionDeclaration) {
913
+ return typeNodeFromFunction(functionDeclaration);
914
+ }
915
+ const variableDeclaration = declarations.variableDeclarations.get(name);
916
+ if (variableDeclaration) {
917
+ return resolveFromVariable(variableDeclaration);
918
+ }
919
+ return { propsTypeNode: null, componentNode: null };
920
+ };
921
+ return resolveFromIdentifier(exportName);
922
+ }
923
+ function extractCustomPropsFromComponentFile(componentFilePath, exportName) {
924
+ const warnings = [];
925
+ const resolvedPath = resolve2(componentFilePath);
926
+ if (!existsSync2(resolvedPath)) {
927
+ return {
928
+ props: {},
929
+ warnings: [`Component file not found: ${resolvedPath}`],
930
+ resolved: false
931
+ };
932
+ }
933
+ const compilerOptions = {
934
+ target: ts2.ScriptTarget.ESNext,
935
+ module: ts2.ModuleKind.ESNext,
936
+ moduleResolution: ts2.ModuleResolutionKind.Bundler,
937
+ jsx: ts2.JsxEmit.ReactJSX,
938
+ allowSyntheticDefaultImports: true,
939
+ esModuleInterop: true,
940
+ skipLibCheck: true,
941
+ strict: false,
942
+ noEmit: true
943
+ };
944
+ const program = ts2.createProgram([resolvedPath], compilerOptions);
945
+ const sourceFile = program.getSourceFile(resolvedPath);
946
+ if (!sourceFile) {
947
+ return {
948
+ props: {},
949
+ warnings: [`Unable to parse component source: ${resolvedPath}`],
950
+ resolved: false
951
+ };
952
+ }
953
+ const checker = program.getTypeChecker();
954
+ const declarations = collectTopLevelDeclarations(sourceFile);
955
+ const signature = resolveComponentSignature(exportName, declarations, sourceFile);
956
+ if (!signature.propsTypeNode) {
957
+ return {
958
+ props: {},
959
+ warnings: [`Unable to resolve props type for export: ${exportName}`],
960
+ resolved: false
961
+ };
962
+ }
963
+ const propsType = checker.getTypeFromTypeNode(signature.propsTypeNode);
964
+ const defaultValues = extractDefaultValues2(signature.componentNode);
965
+ const sourceFilePath = toPosixPath2(sourceFile.fileName);
966
+ const extractedProps = {};
967
+ for (const symbol of checker.getPropertiesOfType(propsType)) {
968
+ const propName = symbol.getName();
969
+ if (propName.startsWith("_") || propName.startsWith("$")) {
970
+ continue;
971
+ }
972
+ const declarationsForSymbol = symbol.getDeclarations() ?? [];
973
+ const localDeclarations = declarationsForSymbol.filter(
974
+ (declaration) => toPosixPath2(declaration.getSourceFile().fileName) === sourceFilePath
975
+ );
976
+ if (localDeclarations.length === 0) {
977
+ continue;
978
+ }
979
+ const referenceNode = localDeclarations[0];
980
+ const inferredType = inferPropType(checker.getTypeOfSymbolAtLocation(symbol, referenceNode), checker);
981
+ const description = ts2.displayPartsToString(symbol.getDocumentationComment(checker)).trim();
982
+ extractedProps[propName] = {
983
+ type: inferredType.type,
984
+ description,
985
+ required: (symbol.getFlags() & ts2.SymbolFlags.Optional) === 0,
986
+ ...inferredType.values && { values: inferredType.values },
987
+ ...defaultValues[propName] !== void 0 && { default: defaultValues[propName] }
988
+ };
989
+ }
990
+ if (Object.keys(extractedProps).length === 0) {
991
+ warnings.push(`Resolved props type for ${exportName}, but no local custom props were found`);
992
+ }
993
+ return {
994
+ props: extractedProps,
995
+ warnings,
996
+ resolved: true
997
+ };
998
+ }
999
+ function roundRgbValues(value) {
1000
+ return value.replace(
1001
+ /rgb\(([^)]+)\)/g,
1002
+ (_full, inner) => {
1003
+ const parts = inner.split(",").map((p) => p.trim());
1004
+ const rounded = parts.map((p) => {
1005
+ const num = parseFloat(p);
1006
+ return isNaN(num) ? p : String(Math.round(num));
1007
+ });
1008
+ return `rgb(${rounded.join(", ")})`;
1009
+ }
1010
+ ).replace(
1011
+ /rgba\(([^)]+)\)/g,
1012
+ (_full, inner) => {
1013
+ const parts = inner.split(",").map((p) => p.trim());
1014
+ const rounded = parts.map((p, i) => {
1015
+ if (i >= 3) return p;
1016
+ const num = parseFloat(p);
1017
+ return isNaN(num) ? p : String(Math.round(num));
1018
+ });
1019
+ return `rgba(${rounded.join(", ")})`;
1020
+ }
1021
+ );
1022
+ }
1023
+ async function resolveTokensWithSass(unresolvedTokens, tokensDir) {
1024
+ const resolvedMap = /* @__PURE__ */ new Map();
1025
+ const needsResolution = unresolvedTokens.filter(
1026
+ (t) => t.value.includes("#{") || t.value.includes("$")
1027
+ );
1028
+ if (needsResolution.length === 0) {
1029
+ return resolvedMap;
1030
+ }
1031
+ try {
1032
+ const sass = await import("./sass.node-4XJK6YBF-2NJM7G64.js");
1033
+ const variablesPath = findVariablesFile(tokensDir);
1034
+ if (!variablesPath) {
1035
+ return resolvedMap;
1036
+ }
1037
+ const fileName = basename(variablesPath);
1038
+ const moduleName = fileName.replace(/^_/, "").replace(/\.scss$/, "");
1039
+ const scssSource = `
1040
+ @use '${moduleName}' as vars;
1041
+ :root { @include vars.fui-css-variables; }
1042
+ `;
1043
+ const compiled = sass.compileString(scssSource, {
1044
+ loadPaths: [tokensDir, dirname3(tokensDir)],
1045
+ style: "expanded",
1046
+ // Suppress sass deprecation warnings during build
1047
+ logger: { warn() {
1048
+ }, debug() {
1049
+ } }
1050
+ });
1051
+ const cssVarRegex = /(--[\w-]+)\s*:\s*([^;]+)/g;
1052
+ let match;
1053
+ const allResolved = /* @__PURE__ */ new Map();
1054
+ while ((match = cssVarRegex.exec(compiled.css)) !== null) {
1055
+ allResolved.set(match[1], roundRgbValues(match[2].trim()));
1056
+ }
1057
+ for (const token of needsResolution) {
1058
+ const value = allResolved.get(token.name);
1059
+ if (value !== void 0) {
1060
+ resolvedMap.set(token.name, value);
1061
+ }
1062
+ }
1063
+ } catch {
1064
+ }
1065
+ return resolvedMap;
1066
+ }
1067
+ function findVariablesFile(tokensDir) {
1068
+ const candidates = ["_variables.scss", "variables.scss"];
1069
+ for (const name of candidates) {
1070
+ const path = resolve3(tokensDir, name);
1071
+ if (existsSync3(path)) {
1072
+ return path;
1073
+ }
1074
+ }
1075
+ try {
1076
+ const files = readdirSync2(tokensDir).filter((f) => f.endsWith(".scss"));
1077
+ for (const file of files) {
1078
+ const path = resolve3(tokensDir, file);
1079
+ if (file.includes("variables") || file.includes("tokens")) {
1080
+ return path;
1081
+ }
1082
+ }
1083
+ } catch {
1084
+ }
1085
+ return null;
1086
+ }
1087
+ export {
1088
+ createComponentExtractor,
1089
+ extractCustomPropsFromComponentFile,
1090
+ resolveComponentSourcePath,
1091
+ resolveTokensWithSass
1092
+ };
1093
+ //# sourceMappingURL=dist-V7D67NXS.js.map