@idealyst/tooling 1.2.24 → 1.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/index.d.ts +65 -0
- package/dist/analyzer/index.js +687 -0
- package/dist/analyzer/index.js.map +1 -0
- package/dist/analyzers/index.d.ts +205 -0
- package/dist/analyzers/index.js +1155 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +2061 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/index.d.ts +69 -0
- package/dist/rules/index.js +481 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/types-CrlxbLFJ.d.ts +121 -0
- package/dist/types-CvIlSIOV.d.ts +149 -0
- package/dist/utils/index.d.ts +94 -0
- package/dist/utils/index.js +662 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/vite-plugin.d.ts +40 -0
- package/dist/vite-plugin.js +764 -0
- package/dist/vite-plugin.js.map +1 -0
- package/package.json +20 -24
- package/src/analyzer/component-analyzer.ts +0 -554
- package/src/analyzer/index.ts +0 -16
- package/src/analyzer/theme-analyzer.ts +0 -473
- package/src/analyzer/types.ts +0 -159
- package/src/analyzers/componentLinter.ts +0 -397
- package/src/analyzers/index.ts +0 -2
- package/src/analyzers/platformImports.ts +0 -391
- package/src/index.ts +0 -156
- package/src/rules/index.ts +0 -2
- package/src/rules/reactDomPrimitives.ts +0 -217
- package/src/rules/reactNativePrimitives.ts +0 -362
- package/src/types.ts +0 -173
- package/src/utils/fileClassifier.ts +0 -135
- package/src/utils/importParser.ts +0 -235
- package/src/utils/index.ts +0 -2
- package/src/vite-plugin.ts +0 -199
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/analyzer/component-analyzer.ts","../../src/analyzer/theme-analyzer.ts"],"sourcesContent":["/**\n * Component Analyzer - Extracts component prop definitions using TypeScript Compiler API.\n *\n * Analyzes:\n * - types.ts files for prop interfaces\n * - JSDoc comments for descriptions\n * - Static .description properties on components\n * - Theme-derived types (Intent, Size) resolved to actual values\n */\n\nimport * as ts from 'typescript';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type {\n ComponentRegistry,\n ComponentDefinition,\n PropDefinition,\n ComponentAnalyzerOptions,\n ThemeValues,\n ComponentCategory,\n SampleProps,\n} from './types';\nimport { analyzeTheme } from './theme-analyzer';\n\n/**\n * Analyze components and generate a registry.\n */\nexport function analyzeComponents(options: ComponentAnalyzerOptions): ComponentRegistry {\n const { componentPaths, themePath, include, exclude, includeInternal = false } = options;\n\n const registry: ComponentRegistry = {};\n\n // First, analyze the theme to get valid values\n const themeValues = analyzeTheme(themePath, false);\n\n // Scan each component path\n for (const componentPath of componentPaths) {\n const resolvedPath = path.resolve(componentPath);\n\n if (!fs.existsSync(resolvedPath)) {\n console.warn(`[component-analyzer] Path not found: ${resolvedPath}`);\n continue;\n }\n\n // Find all component directories (those with index.ts or types.ts)\n const componentDirs = findComponentDirs(resolvedPath);\n\n for (const dir of componentDirs) {\n const componentName = path.basename(dir);\n\n // Apply include/exclude filters\n if (include && !include.includes(componentName)) continue;\n if (exclude && exclude.includes(componentName)) continue;\n if (!includeInternal && componentName.startsWith('_')) continue;\n\n const definition = analyzeComponentDir(dir, componentName, themeValues);\n if (definition) {\n registry[componentName] = definition;\n }\n }\n }\n\n return registry;\n}\n\n/**\n * Find all component directories in a path.\n */\nfunction findComponentDirs(basePath: string): string[] {\n const dirs: string[] = [];\n\n const entries = fs.readdirSync(basePath, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n const dirPath = path.join(basePath, entry.name);\n\n // Check if it's a component directory (has index.ts or types.ts)\n const hasIndex = fs.existsSync(path.join(dirPath, 'index.ts'));\n const hasTypes = fs.existsSync(path.join(dirPath, 'types.ts'));\n\n if (hasIndex || hasTypes) {\n dirs.push(dirPath);\n }\n }\n\n return dirs;\n}\n\n/**\n * Analyze a single component directory.\n */\nfunction analyzeComponentDir(\n dir: string,\n componentName: string,\n themeValues: ThemeValues\n): ComponentDefinition | null {\n // Find all TypeScript files in the component directory\n const tsFiles = fs.readdirSync(dir)\n .filter(f => f.endsWith('.ts') || f.endsWith('.tsx'))\n .map(f => path.join(dir, f));\n\n if (tsFiles.length === 0) {\n return null;\n }\n\n // Create TypeScript program with all files\n const program = ts.createProgram(tsFiles, {\n target: ts.ScriptTarget.ES2020,\n module: ts.ModuleKind.ESNext,\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n });\n\n const typeChecker = program.getTypeChecker();\n\n // Search all files for the props interface\n const propsInterfaceName = `${componentName}Props`;\n const altNames = [`${componentName}ComponentProps`, 'Props'];\n let propsInterface: ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null = null;\n let interfaceDescription: string | undefined;\n\n // Search each file for the props interface\n for (const filePath of tsFiles) {\n const sourceFile = program.getSourceFile(filePath);\n if (!sourceFile) continue;\n\n // First try the main props interface name\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isInterfaceDeclaration(node) && node.name.text === propsInterfaceName) {\n propsInterface = node;\n interfaceDescription = getJSDocDescription(node);\n }\n if (ts.isTypeAliasDeclaration(node) && node.name.text === propsInterfaceName) {\n propsInterface = node;\n interfaceDescription = getJSDocDescription(node);\n }\n });\n\n if (propsInterface) break;\n }\n\n // If not found, try alternate naming conventions\n if (!propsInterface) {\n for (const altName of altNames) {\n for (const filePath of tsFiles) {\n const sourceFile = program.getSourceFile(filePath);\n if (!sourceFile) continue;\n\n ts.forEachChild(sourceFile, (node) => {\n if ((ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) && node.name.text === altName) {\n propsInterface = node;\n interfaceDescription = getJSDocDescription(node);\n }\n });\n\n if (propsInterface) break;\n }\n if (propsInterface) break;\n }\n }\n\n // If we couldn't find a props interface, skip this component\n if (!propsInterface) {\n return null;\n }\n\n // Extract props\n const props: Record<string, PropDefinition> = {};\n\n if (propsInterface) {\n const type = typeChecker.getTypeAtLocation(propsInterface);\n const properties = type.getProperties();\n\n for (const prop of properties) {\n const propDef = analyzeProperty(prop, typeChecker, themeValues);\n if (propDef && !isInternalProp(propDef.name)) {\n props[propDef.name] = propDef;\n }\n }\n }\n\n // Get description from the props interface JSDoc (single source of truth in types.ts)\n const description = interfaceDescription;\n\n // Determine category\n const category = inferCategory(componentName);\n\n // Look for docs.ts to extract sample props\n const sampleProps = extractSampleProps(dir);\n\n return {\n name: componentName,\n description,\n props,\n category,\n filePath: path.relative(process.cwd(), dir),\n sampleProps,\n };\n}\n\n/**\n * Extract sample props from docs.ts file if it exists.\n * The docs.ts file should export a `sampleProps` object.\n */\nfunction extractSampleProps(dir: string): SampleProps | undefined {\n const docsPath = path.join(dir, 'docs.ts');\n\n if (!fs.existsSync(docsPath)) {\n return undefined;\n }\n\n try {\n const content = fs.readFileSync(docsPath, 'utf-8');\n\n // Create a simple TypeScript program to extract the sampleProps export\n const sourceFile = ts.createSourceFile(\n 'docs.ts',\n content,\n ts.ScriptTarget.ES2020,\n true,\n ts.ScriptKind.TS\n );\n\n let samplePropsNode: ts.ObjectLiteralExpression | null = null;\n\n // Find the sampleProps export\n ts.forEachChild(sourceFile, (node) => {\n // Handle: export const sampleProps = { ... }\n if (ts.isVariableStatement(node)) {\n const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);\n if (isExported) {\n for (const decl of node.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && decl.name.text === 'sampleProps' && decl.initializer) {\n if (ts.isObjectLiteralExpression(decl.initializer)) {\n samplePropsNode = decl.initializer;\n }\n }\n }\n }\n }\n });\n\n if (!samplePropsNode) {\n return undefined;\n }\n\n // Extract the object literal as JSON-compatible structure\n // This is a simplified extraction - it handles basic literals\n const result: SampleProps = {};\n const propsNode = samplePropsNode as ts.ObjectLiteralExpression;\n\n for (const prop of propsNode.properties) {\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {\n const propName = prop.name.text;\n\n if (propName === 'props' && ts.isObjectLiteralExpression(prop.initializer)) {\n result.props = extractObjectLiteral(prop.initializer, content);\n } else if (propName === 'children') {\n // For children, we store the raw source text\n result.children = prop.initializer.getText(sourceFile);\n } else if (propName === 'state' && ts.isObjectLiteralExpression(prop.initializer)) {\n // Extract state configuration for controlled components\n result.state = extractObjectLiteral(prop.initializer, content);\n }\n }\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n } catch (e) {\n console.warn(`[component-analyzer] Error reading docs.ts in ${dir}:`, e);\n return undefined;\n }\n}\n\n/**\n * Extract an object literal to a plain object (for simple literal values).\n */\nfunction extractObjectLiteral(node: ts.ObjectLiteralExpression, sourceContent: string): Record<string, any> {\n const result: Record<string, any> = {};\n\n for (const prop of node.properties) {\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {\n const key = prop.name.text;\n const init = prop.initializer;\n\n if (ts.isStringLiteral(init)) {\n result[key] = init.text;\n } else if (ts.isNumericLiteral(init)) {\n result[key] = Number(init.text);\n } else if (init.kind === ts.SyntaxKind.TrueKeyword) {\n result[key] = true;\n } else if (init.kind === ts.SyntaxKind.FalseKeyword) {\n result[key] = false;\n } else if (ts.isArrayLiteralExpression(init)) {\n result[key] = extractArrayLiteral(init, sourceContent);\n } else if (ts.isObjectLiteralExpression(init)) {\n result[key] = extractObjectLiteral(init, sourceContent);\n } else {\n // For complex expressions (JSX, functions), store the raw source\n result[key] = init.getText();\n }\n }\n }\n\n return result;\n}\n\n/**\n * Extract an array literal to a plain array.\n */\nfunction extractArrayLiteral(node: ts.ArrayLiteralExpression, sourceContent: string): any[] {\n const result: any[] = [];\n\n for (const element of node.elements) {\n if (ts.isStringLiteral(element)) {\n result.push(element.text);\n } else if (ts.isNumericLiteral(element)) {\n result.push(Number(element.text));\n } else if (element.kind === ts.SyntaxKind.TrueKeyword) {\n result.push(true);\n } else if (element.kind === ts.SyntaxKind.FalseKeyword) {\n result.push(false);\n } else if (ts.isObjectLiteralExpression(element)) {\n result.push(extractObjectLiteral(element, sourceContent));\n } else if (ts.isArrayLiteralExpression(element)) {\n result.push(extractArrayLiteral(element, sourceContent));\n } else {\n // For complex expressions, store raw source\n result.push(element.getText());\n }\n }\n\n return result;\n}\n\n/**\n * Analyze a single property symbol.\n */\nfunction analyzeProperty(\n symbol: ts.Symbol,\n typeChecker: ts.TypeChecker,\n themeValues: ThemeValues\n): PropDefinition | null {\n const name = symbol.getName();\n const declarations = symbol.getDeclarations();\n\n if (!declarations || declarations.length === 0) return null;\n\n const declaration = declarations[0];\n const type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);\n const typeString = typeChecker.typeToString(type);\n\n // Get JSDoc description\n const description = ts.displayPartsToString(symbol.getDocumentationComment(typeChecker)) || undefined;\n\n // Check if required\n const required = !(symbol.flags & ts.SymbolFlags.Optional);\n\n // Extract values for union types / theme types\n const values = extractPropValues(type, typeString, typeChecker, themeValues);\n\n // Extract default value (from JSDoc @default tag)\n const defaultValue = extractDefaultValue(symbol);\n\n return {\n name,\n type: simplifyTypeName(typeString),\n values: values.length > 0 ? values : undefined,\n default: defaultValue,\n description,\n required,\n };\n}\n\n/**\n * Extract valid values for a prop type.\n */\nfunction extractPropValues(\n type: ts.Type,\n typeString: string,\n _typeChecker: ts.TypeChecker,\n themeValues: ThemeValues\n): string[] {\n // Handle theme-derived types\n if (typeString === 'Intent' || typeString.includes('Intent')) {\n return themeValues.intents;\n }\n if (typeString === 'Size' || typeString.includes('Size')) {\n // Return generic sizes - most components use the same keys\n return ['xs', 'sm', 'md', 'lg', 'xl'];\n }\n\n // Handle union types\n if (type.isUnion()) {\n const values: string[] = [];\n for (const unionType of type.types) {\n if (unionType.isStringLiteral()) {\n values.push(unionType.value);\n } else if ((unionType as any).intrinsicName === 'true') {\n values.push('true');\n } else if ((unionType as any).intrinsicName === 'false') {\n values.push('false');\n }\n }\n if (values.length > 0) return values;\n }\n\n // Handle boolean\n if (typeString === 'boolean') {\n return ['true', 'false'];\n }\n\n return [];\n}\n\n/**\n * Extract default value from JSDoc @default tag.\n */\nfunction extractDefaultValue(symbol: ts.Symbol): string | number | boolean | undefined {\n const tags = symbol.getJsDocTags();\n for (const tag of tags) {\n if (tag.name === 'default' && tag.text) {\n const value = ts.displayPartsToString(tag.text);\n // Try to parse as JSON\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n }\n }\n return undefined;\n}\n\n/**\n * Get JSDoc description from a node.\n */\nfunction getJSDocDescription(node: ts.Node): string | undefined {\n const jsDocs = (node as any).jsDoc as ts.JSDoc[] | undefined;\n if (!jsDocs || jsDocs.length === 0) return undefined;\n\n const firstDoc = jsDocs[0];\n if (firstDoc.comment) {\n if (typeof firstDoc.comment === 'string') {\n return firstDoc.comment;\n }\n // Handle NodeArray of JSDocComment\n return (firstDoc.comment as ts.NodeArray<ts.JSDocComment>)\n .map(c => (c as any).text || '')\n .join('');\n }\n return undefined;\n}\n\n/**\n * Simplify type names for display.\n */\nfunction simplifyTypeName(typeString: string): string {\n // Remove import paths\n typeString = typeString.replace(/import\\([^)]+\\)\\./g, '');\n\n // Simplify common complex types\n if (typeString.includes('ReactNode')) return 'ReactNode';\n if (typeString.includes('StyleProp')) return 'Style';\n\n return typeString;\n}\n\n/**\n * Check if a prop should be excluded (internal/inherited).\n */\nfunction isInternalProp(name: string): boolean {\n const internalProps = [\n 'ref',\n 'key',\n 'children',\n 'style',\n 'testID',\n 'nativeID',\n 'accessible',\n 'accessibilityActions',\n 'accessibilityComponentType',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityIgnoresInvertColors',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityLanguage',\n 'accessibilityLiveRegion',\n 'accessibilityRole',\n 'accessibilityState',\n 'accessibilityTraits',\n 'accessibilityValue',\n 'accessibilityViewIsModal',\n 'collapsable',\n 'focusable',\n 'hasTVPreferredFocus',\n 'hitSlop',\n 'importantForAccessibility',\n 'needsOffscreenAlphaCompositing',\n 'onAccessibilityAction',\n 'onAccessibilityEscape',\n 'onAccessibilityTap',\n 'onLayout',\n 'onMagicTap',\n 'onMoveShouldSetResponder',\n 'onMoveShouldSetResponderCapture',\n 'onResponderEnd',\n 'onResponderGrant',\n 'onResponderMove',\n 'onResponderReject',\n 'onResponderRelease',\n 'onResponderStart',\n 'onResponderTerminate',\n 'onResponderTerminationRequest',\n 'onStartShouldSetResponder',\n 'onStartShouldSetResponderCapture',\n 'pointerEvents',\n 'removeClippedSubviews',\n 'renderToHardwareTextureAndroid',\n 'shouldRasterizeIOS',\n 'tvParallaxMagnification',\n 'tvParallaxProperties',\n 'tvParallaxShiftDistanceX',\n 'tvParallaxShiftDistanceY',\n 'tvParallaxTiltAngle',\n ];\n\n return internalProps.includes(name) || name.startsWith('accessibility');\n}\n\n/**\n * Infer component category from name.\n */\nfunction inferCategory(componentName: string): ComponentCategory {\n const formComponents = ['Button', 'Input', 'Checkbox', 'Select', 'Switch', 'RadioButton', 'Slider', 'TextArea'];\n const displayComponents = ['Text', 'Card', 'Badge', 'Chip', 'Avatar', 'Icon', 'Skeleton', 'Alert', 'Tooltip'];\n const layoutComponents = ['View', 'Screen', 'Divider'];\n const navigationComponents = ['TabBar', 'Breadcrumb', 'Menu', 'List', 'Link'];\n const overlayComponents = ['Dialog', 'Popover', 'Modal'];\n const dataComponents = ['Table', 'Progress', 'Accordion'];\n\n if (formComponents.includes(componentName)) return 'form';\n if (displayComponents.includes(componentName)) return 'display';\n if (layoutComponents.includes(componentName)) return 'layout';\n if (navigationComponents.includes(componentName)) return 'navigation';\n if (overlayComponents.includes(componentName)) return 'overlay';\n if (dataComponents.includes(componentName)) return 'data';\n\n return 'display'; // Default\n}\n","/**\n * Theme Analyzer - Extracts theme keys by statically analyzing theme files.\n *\n * Uses TypeScript Compiler API to trace the declarative builder API:\n * - createTheme() / fromTheme(base)\n * - .addIntent('name', {...})\n * - .addRadius('name', value)\n * - .addShadow('name', {...})\n * - .setSizes({ button: { xs: {}, sm: {}, ... }, ... })\n * - .build()\n */\n\nimport * as ts from 'typescript';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { ThemeValues } from './types';\n\ninterface AnalyzerContext {\n program: ts.Program;\n typeChecker: ts.TypeChecker;\n verbose: boolean;\n}\n\n/**\n * Extract theme values from a theme file.\n */\nexport function analyzeTheme(themePath: string, verbose = false): ThemeValues {\n const resolvedPath = path.resolve(themePath);\n\n if (!fs.existsSync(resolvedPath)) {\n throw new Error(`Theme file not found: ${resolvedPath}`);\n }\n\n const log = (...args: any[]) => {\n if (verbose) console.log('[theme-analyzer]', ...args);\n };\n\n log('Analyzing theme file:', resolvedPath);\n\n // Create a TypeScript program\n const program = ts.createProgram([resolvedPath], {\n target: ts.ScriptTarget.ES2020,\n module: ts.ModuleKind.ESNext,\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n });\n\n const sourceFile = program.getSourceFile(resolvedPath);\n if (!sourceFile) {\n throw new Error(`Failed to parse theme file: ${resolvedPath}`);\n }\n\n const ctx: AnalyzerContext = {\n program,\n typeChecker: program.getTypeChecker(),\n verbose,\n };\n\n const values: ThemeValues = {\n intents: [],\n sizes: {},\n radii: [],\n shadows: [],\n breakpoints: [],\n typography: [],\n surfaceColors: [],\n textColors: [],\n borderColors: [],\n };\n\n // Track imports for base theme resolution\n const imports = new Map<string, { source: string; imported: string }>();\n\n // First pass: collect imports\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isImportDeclaration(node)) {\n const source = (node.moduleSpecifier as ts.StringLiteral).text;\n const clause = node.importClause;\n if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings)) {\n for (const element of clause.namedBindings.elements) {\n const localName = element.name.text;\n const importedName = element.propertyName?.text ?? localName;\n imports.set(localName, { source, imported: importedName });\n }\n }\n }\n });\n\n /**\n * Process a builder method call chain.\n */\n function processBuilderChain(node: ts.Node): void {\n if (!ts.isCallExpression(node)) return;\n\n // Check if this is a .build() call\n if (ts.isPropertyAccessExpression(node.expression)) {\n const methodName = node.expression.name.text;\n\n if (methodName === 'build') {\n // Trace the full chain\n const calls = traceBuilderCalls(node);\n processCalls(calls);\n return;\n }\n }\n\n // Recurse into children\n ts.forEachChild(node, processBuilderChain);\n }\n\n interface BuilderCall {\n method: string;\n args: ts.NodeArray<ts.Expression>;\n }\n\n /**\n * Trace a builder chain backwards to collect all method calls.\n */\n function traceBuilderCalls(node: ts.CallExpression, calls: BuilderCall[] = []): BuilderCall[] {\n if (!ts.isPropertyAccessExpression(node.expression)) {\n // Check for createTheme() or fromTheme()\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {\n const fnName = node.expression.text;\n if (fnName === 'fromTheme' && node.arguments.length > 0) {\n const arg = node.arguments[0];\n if (ts.isIdentifier(arg)) {\n // Analyze base theme\n analyzeBaseTheme(arg.text, imports, values, ctx);\n }\n }\n }\n return calls;\n }\n\n const methodName = node.expression.name.text;\n calls.unshift({ method: methodName, args: node.arguments });\n\n // Recurse into the object being called\n const obj = node.expression.expression;\n if (ts.isCallExpression(obj)) {\n return traceBuilderCalls(obj, calls);\n }\n\n return calls;\n }\n\n /**\n * Process the collected builder method calls.\n */\n function processCalls(calls: BuilderCall[]): void {\n log('Processing', calls.length, 'builder method calls');\n\n for (const { method, args } of calls) {\n switch (method) {\n case 'addIntent': {\n const name = getStringValue(args[0]);\n if (name && !values.intents.includes(name)) {\n values.intents.push(name);\n log(' Found intent:', name);\n }\n break;\n }\n case 'addRadius': {\n const name = getStringValue(args[0]);\n if (name && !values.radii.includes(name)) {\n values.radii.push(name);\n log(' Found radius:', name);\n }\n break;\n }\n case 'addShadow': {\n const name = getStringValue(args[0]);\n if (name && !values.shadows.includes(name)) {\n values.shadows.push(name);\n log(' Found shadow:', name);\n }\n break;\n }\n case 'setSizes': {\n if (args[0] && ts.isObjectLiteralExpression(args[0])) {\n for (const prop of args[0].properties) {\n if (ts.isPropertyAssignment(prop)) {\n const componentName = getPropertyName(prop.name);\n if (componentName && ts.isObjectLiteralExpression(prop.initializer)) {\n values.sizes[componentName] = getObjectKeys(prop.initializer);\n log(' Found sizes for', componentName + ':', values.sizes[componentName]);\n }\n }\n }\n }\n break;\n }\n case 'setBreakpoints': {\n if (args[0] && ts.isObjectLiteralExpression(args[0])) {\n values.breakpoints = getObjectKeys(args[0]);\n log(' Found breakpoints:', values.breakpoints);\n }\n break;\n }\n case 'setColors': {\n if (args[0] && ts.isObjectLiteralExpression(args[0])) {\n for (const prop of args[0].properties) {\n if (ts.isPropertyAssignment(prop)) {\n const colorType = getPropertyName(prop.name);\n if (ts.isObjectLiteralExpression(prop.initializer)) {\n const keys = getObjectKeys(prop.initializer);\n switch (colorType) {\n case 'surface':\n values.surfaceColors = keys;\n log(' Found surface colors:', keys);\n break;\n case 'text':\n values.textColors = keys;\n log(' Found text colors:', keys);\n break;\n case 'border':\n values.borderColors = keys;\n log(' Found border colors:', keys);\n break;\n }\n }\n }\n }\n }\n break;\n }\n case 'build':\n // End of chain\n break;\n default:\n log(' Skipping unknown method:', method);\n }\n }\n }\n\n // Second pass: find and process builder chains\n ts.forEachChild(sourceFile, (node) => {\n // Handle variable declarations\n if (ts.isVariableStatement(node)) {\n for (const decl of node.declarationList.declarations) {\n if (decl.initializer) {\n processBuilderChain(decl.initializer);\n }\n }\n }\n // Handle export statements\n if (ts.isExportAssignment(node)) {\n processBuilderChain(node.expression);\n }\n });\n\n // Extract typography keys from sizes if present\n if (values.sizes['typography']) {\n values.typography = values.sizes['typography'];\n }\n\n log('Extracted theme values:', values);\n\n return values;\n}\n\n/**\n * Analyze a base theme file referenced by an import.\n */\nfunction analyzeBaseTheme(\n varName: string,\n imports: Map<string, { source: string; imported: string }>,\n values: ThemeValues,\n ctx: AnalyzerContext\n): void {\n const log = (...args: any[]) => {\n if (ctx.verbose) console.log('[theme-analyzer]', ...args);\n };\n\n const importInfo = imports.get(varName);\n if (!importInfo) {\n log('Could not find import for base theme:', varName);\n return;\n }\n\n log('Base theme', varName, 'imported from', importInfo.source);\n\n // For @idealyst/theme imports, we know the structure\n if (importInfo.source === '@idealyst/theme' || importInfo.source.includes('@idealyst/theme')) {\n // Use default light theme values\n const defaultValues = getDefaultThemeValues();\n mergeThemeValues(values, defaultValues);\n log('Using default @idealyst/theme values');\n return;\n }\n\n // For relative imports, try to resolve and analyze\n // (This is simplified - full implementation would recursively analyze)\n log('Skipping base theme analysis for:', importInfo.source);\n}\n\n/**\n * Get default theme values from @idealyst/theme.\n */\nfunction getDefaultThemeValues(): ThemeValues {\n return {\n intents: ['primary', 'success', 'error', 'warning', 'neutral', 'info'],\n sizes: {\n button: ['xs', 'sm', 'md', 'lg', 'xl'],\n chip: ['xs', 'sm', 'md', 'lg', 'xl'],\n badge: ['xs', 'sm', 'md', 'lg', 'xl'],\n icon: ['xs', 'sm', 'md', 'lg', 'xl'],\n input: ['xs', 'sm', 'md', 'lg', 'xl'],\n radioButton: ['xs', 'sm', 'md', 'lg', 'xl'],\n select: ['xs', 'sm', 'md', 'lg', 'xl'],\n slider: ['xs', 'sm', 'md', 'lg', 'xl'],\n switch: ['xs', 'sm', 'md', 'lg', 'xl'],\n textarea: ['xs', 'sm', 'md', 'lg', 'xl'],\n avatar: ['xs', 'sm', 'md', 'lg', 'xl'],\n progress: ['xs', 'sm', 'md', 'lg', 'xl'],\n accordion: ['xs', 'sm', 'md', 'lg', 'xl'],\n activityIndicator: ['xs', 'sm', 'md', 'lg', 'xl'],\n breadcrumb: ['xs', 'sm', 'md', 'lg', 'xl'],\n list: ['xs', 'sm', 'md', 'lg', 'xl'],\n menu: ['xs', 'sm', 'md', 'lg', 'xl'],\n text: ['xs', 'sm', 'md', 'lg', 'xl'],\n tabBar: ['xs', 'sm', 'md', 'lg', 'xl'],\n table: ['xs', 'sm', 'md', 'lg', 'xl'],\n tooltip: ['xs', 'sm', 'md', 'lg', 'xl'],\n view: ['xs', 'sm', 'md', 'lg', 'xl'],\n },\n radii: ['none', 'xs', 'sm', 'md', 'lg', 'xl'],\n shadows: ['none', 'sm', 'md', 'lg', 'xl'],\n breakpoints: ['xs', 'sm', 'md', 'lg', 'xl'],\n typography: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption'],\n surfaceColors: ['screen', 'primary', 'secondary', 'tertiary', 'inverse', 'inverse-secondary', 'inverse-tertiary'],\n textColors: ['primary', 'secondary', 'tertiary', 'inverse', 'inverse-secondary', 'inverse-tertiary'],\n borderColors: ['primary', 'secondary', 'tertiary', 'disabled'],\n };\n}\n\n/**\n * Merge theme values, avoiding duplicates.\n */\nfunction mergeThemeValues(target: ThemeValues, source: ThemeValues): void {\n target.intents.push(...source.intents.filter(k => !target.intents.includes(k)));\n target.radii.push(...source.radii.filter(k => !target.radii.includes(k)));\n target.shadows.push(...source.shadows.filter(k => !target.shadows.includes(k)));\n target.breakpoints.push(...source.breakpoints.filter(k => !target.breakpoints.includes(k)));\n target.typography.push(...source.typography.filter(k => !target.typography.includes(k)));\n target.surfaceColors.push(...source.surfaceColors.filter(k => !target.surfaceColors.includes(k)));\n target.textColors.push(...source.textColors.filter(k => !target.textColors.includes(k)));\n target.borderColors.push(...source.borderColors.filter(k => !target.borderColors.includes(k)));\n\n for (const [comp, sizes] of Object.entries(source.sizes)) {\n if (!target.sizes[comp]) {\n target.sizes[comp] = sizes;\n }\n }\n}\n\n// Helper functions\n\nfunction getStringValue(node?: ts.Expression): string | null {\n if (!node) return null;\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isIdentifier(node)) return node.text;\n return null;\n}\n\nfunction getPropertyName(node: ts.PropertyName): string | null {\n if (ts.isIdentifier(node)) return node.text;\n if (ts.isStringLiteral(node)) return node.text;\n return null;\n}\n\nfunction getObjectKeys(node: ts.ObjectLiteralExpression): string[] {\n return node.properties\n .filter(ts.isPropertyAssignment)\n .map(prop => getPropertyName(prop.name))\n .filter((k): k is string => k !== null);\n}\n\n// ============================================================================\n// Babel Plugin Compatibility Layer\n// ============================================================================\n\n/**\n * Theme keys format expected by the Babel plugin.\n * This is a subset of ThemeValues for backwards compatibility.\n */\nexport interface BabelThemeKeys {\n intents: string[];\n sizes: Record<string, string[]>;\n radii: string[];\n shadows: string[];\n}\n\n// Cache for loadThemeKeys to avoid re-parsing\nlet themeKeysCache: BabelThemeKeys | null = null;\nlet themeLoadAttempted = false;\n\n/**\n * Load theme keys for the Babel plugin.\n * This is a compatibility wrapper around analyzeTheme() that:\n * - Provides caching (only parses once per build)\n * - Returns the subset of keys needed by the Babel plugin\n * - Handles path resolution based on babel opts\n *\n * @param opts - Babel plugin options (requires themePath)\n * @param rootDir - Root directory for path resolution\n * @param _babelTypes - Unused (kept for backwards compatibility)\n * @param verboseMode - Enable verbose logging\n */\nexport function loadThemeKeys(\n opts: { themePath?: string },\n rootDir: string,\n _babelTypes?: unknown,\n verboseMode = false\n): BabelThemeKeys {\n if (themeLoadAttempted && themeKeysCache) {\n return themeKeysCache;\n }\n themeLoadAttempted = true;\n\n const themePath = opts.themePath;\n\n if (!themePath) {\n throw new Error(\n '[idealyst-plugin] themePath is required!\\n' +\n 'Add it to your babel config:\\n' +\n ' [\"@idealyst/theme/plugin\", { themePath: \"./src/theme/styles.ts\" }]'\n );\n }\n\n // Resolve the path\n const resolvedPath = themePath.startsWith('.')\n ? path.resolve(rootDir, themePath)\n : themePath;\n\n if (verboseMode) {\n console.log('[idealyst-plugin] Analyzing theme file via @idealyst/tooling:', resolvedPath);\n }\n\n // Use the TypeScript-based analyzer\n const themeValues = analyzeTheme(resolvedPath, verboseMode);\n\n // Convert to Babel-compatible format (subset of ThemeValues)\n themeKeysCache = {\n intents: themeValues.intents,\n sizes: themeValues.sizes,\n radii: themeValues.radii,\n shadows: themeValues.shadows,\n };\n\n if (verboseMode) {\n console.log('[idealyst-plugin] Extracted theme keys:');\n console.log(' intents:', themeKeysCache.intents);\n console.log(' radii:', themeKeysCache.radii);\n console.log(' shadows:', themeKeysCache.shadows);\n console.log(' sizes:');\n for (const [component, sizes] of Object.entries(themeKeysCache.sizes)) {\n console.log(` ${component}:`, sizes);\n }\n }\n\n return themeKeysCache;\n}\n\n/**\n * Reset the theme cache. Useful for testing or hot reload.\n */\nexport function resetThemeCache(): void {\n themeKeysCache = null;\n themeLoadAttempted = false;\n}\n"],"mappings":";AAUA,YAAYA,SAAQ;AACpB,YAAYC,SAAQ;AACpB,YAAYC,WAAU;;;ACAtB,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,YAAY,UAAU;AAYf,SAAS,aAAa,WAAmB,UAAU,OAAoB;AAC5E,QAAM,eAAoB,aAAQ,SAAS;AAE3C,MAAI,CAAI,cAAW,YAAY,GAAG;AAChC,UAAM,IAAI,MAAM,yBAAyB,YAAY,EAAE;AAAA,EACzD;AAEA,QAAM,MAAM,IAAI,SAAgB;AAC9B,QAAI,QAAS,SAAQ,IAAI,oBAAoB,GAAG,IAAI;AAAA,EACtD;AAEA,MAAI,yBAAyB,YAAY;AAGzC,QAAM,UAAa,iBAAc,CAAC,YAAY,GAAG;AAAA,IAC/C,QAAW,gBAAa;AAAA,IACxB,QAAW,cAAW;AAAA,IACtB,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,8BAA8B;AAAA,EAChC,CAAC;AAED,QAAM,aAAa,QAAQ,cAAc,YAAY;AACrD,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,+BAA+B,YAAY,EAAE;AAAA,EAC/D;AAEA,QAAM,MAAuB;AAAA,IAC3B;AAAA,IACA,aAAa,QAAQ,eAAe;AAAA,IACpC;AAAA,EACF;AAEA,QAAM,SAAsB;AAAA,IAC1B,SAAS,CAAC;AAAA,IACV,OAAO,CAAC;AAAA,IACR,OAAO,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,YAAY,CAAC;AAAA,IACb,eAAe,CAAC;AAAA,IAChB,YAAY,CAAC;AAAA,IACb,cAAc,CAAC;AAAA,EACjB;AAGA,QAAM,UAAU,oBAAI,IAAkD;AAGt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mB,CAAC,QAAQ,UAAU,SAAS;AACrD,QAAM,uBAAuB,CAAC,UAAU,cAAc,QAAQ,QAAQ,MAAM;AAC5E,QAAM,oBAAoB,CAAC,UAAU,WAAW,OAAO;AACvD,QAAM,iBAAiB,CAAC,SAAS,YAAY,WAAW;AAExD,MAAI,eAAe,SAAS,aAAa,EAAG,QAAO;AACnD,MAAI,kBAAkB,SAAS,aAAa,EAAG,QAAO;AACtD,MAAI,iBAAiB,SAAS,aAAa,EAAG,QAAO;AACrD,MAAI,qBAAqB,SAAS,aAAa,EAAG,QAAO;AACzD,MAAI,kBAAkB,SAAS,aAAa,EAAG,QAAO;AACtD,MAAI,eAAe,SAAS,aAAa,EAAG,QAAO;AAEnD,SAAO;AACT;","names":["ts","fs","path"]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { b as AnalyzerOptions, A as AnalysisResult, c as FileInput, V as ViolationType, S as Severity, a as Violation } from '../types-CvIlSIOV.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Analyze a single file for platform import violations
|
|
5
|
+
*
|
|
6
|
+
* @param filePath - Path to the file being analyzed
|
|
7
|
+
* @param sourceCode - The source code content
|
|
8
|
+
* @param options - Analyzer options
|
|
9
|
+
* @returns Analysis result with violations
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const result = analyzePlatformImports(
|
|
14
|
+
* 'src/components/Button.tsx',
|
|
15
|
+
* sourceCode,
|
|
16
|
+
* { severity: 'error' }
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* if (result.violations.length > 0) {
|
|
20
|
+
* for (const v of result.violations) {
|
|
21
|
+
* console.error(`${v.filePath}:${v.line}:${v.column} - ${v.message}`);
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function analyzePlatformImports(filePath: string, sourceCode: string, options?: AnalyzerOptions): AnalysisResult;
|
|
27
|
+
/**
|
|
28
|
+
* Analyze multiple files for platform import violations
|
|
29
|
+
*
|
|
30
|
+
* @param files - Array of files to analyze
|
|
31
|
+
* @param options - Analyzer options
|
|
32
|
+
* @returns Array of analysis results
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const results = analyzeFiles(
|
|
37
|
+
* [
|
|
38
|
+
* { path: 'Button.tsx', content: buttonSource },
|
|
39
|
+
* { path: 'Button.web.tsx', content: webSource },
|
|
40
|
+
* { path: 'Button.native.tsx', content: nativeSource },
|
|
41
|
+
* ],
|
|
42
|
+
* { severity: 'warning' }
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* const failed = results.filter(r => !r.passed);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function analyzeFiles(files: FileInput[], options?: AnalyzerOptions): AnalysisResult[];
|
|
49
|
+
/**
|
|
50
|
+
* Get a summary of analysis results
|
|
51
|
+
*/
|
|
52
|
+
interface AnalysisSummary {
|
|
53
|
+
totalFiles: number;
|
|
54
|
+
passedFiles: number;
|
|
55
|
+
failedFiles: number;
|
|
56
|
+
totalViolations: number;
|
|
57
|
+
violationsByType: Record<ViolationType, number>;
|
|
58
|
+
violationsBySeverity: Record<Severity, number>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Summarize analysis results
|
|
62
|
+
*
|
|
63
|
+
* @param results - Array of analysis results
|
|
64
|
+
* @returns Summary statistics
|
|
65
|
+
*/
|
|
66
|
+
declare function summarizeResults(results: AnalysisResult[]): AnalysisSummary;
|
|
67
|
+
/**
|
|
68
|
+
* Format a violation for console output
|
|
69
|
+
*/
|
|
70
|
+
declare function formatViolation(violation: Violation): string;
|
|
71
|
+
/**
|
|
72
|
+
* Format all violations from results for console output
|
|
73
|
+
*/
|
|
74
|
+
declare function formatViolations(results: AnalysisResult[]): string[];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Types of linting issues the component linter can detect.
|
|
78
|
+
*
|
|
79
|
+
* These are issues that TypeScript cannot catch - primarily style/pattern issues
|
|
80
|
+
* that are syntactically valid but violate Idealyst conventions.
|
|
81
|
+
*/
|
|
82
|
+
type LintIssueType = 'hardcoded-color' | 'direct-platform-import';
|
|
83
|
+
/**
|
|
84
|
+
* A single lint issue found during analysis
|
|
85
|
+
*/
|
|
86
|
+
interface LintIssue {
|
|
87
|
+
/** Type of lint issue */
|
|
88
|
+
type: LintIssueType;
|
|
89
|
+
/** Severity level */
|
|
90
|
+
severity: Severity;
|
|
91
|
+
/** Line number where issue occurred */
|
|
92
|
+
line: number;
|
|
93
|
+
/** Column number where issue occurred */
|
|
94
|
+
column: number;
|
|
95
|
+
/** The problematic code snippet */
|
|
96
|
+
code: string;
|
|
97
|
+
/** Human-readable message describing the issue */
|
|
98
|
+
message: string;
|
|
99
|
+
/** Suggested fix (if available) */
|
|
100
|
+
suggestion?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Result of linting a component file
|
|
104
|
+
*/
|
|
105
|
+
interface LintResult {
|
|
106
|
+
/** Path to the analyzed file */
|
|
107
|
+
filePath: string;
|
|
108
|
+
/** List of issues found */
|
|
109
|
+
issues: LintIssue[];
|
|
110
|
+
/** Whether the file passed linting (no errors) */
|
|
111
|
+
passed: boolean;
|
|
112
|
+
/** Count of issues by severity */
|
|
113
|
+
counts: {
|
|
114
|
+
error: number;
|
|
115
|
+
warning: number;
|
|
116
|
+
info: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Options for the component linter
|
|
121
|
+
*/
|
|
122
|
+
interface ComponentLinterOptions {
|
|
123
|
+
/**
|
|
124
|
+
* Which rules to enable (all enabled by default)
|
|
125
|
+
*/
|
|
126
|
+
rules?: {
|
|
127
|
+
/** Detect hardcoded color values like '#fff', 'red', 'rgb()' */
|
|
128
|
+
hardcodedColors?: boolean | Severity;
|
|
129
|
+
/** Detect direct imports from 'react-native' in shared files */
|
|
130
|
+
directPlatformImports?: boolean | Severity;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Glob patterns for files to ignore
|
|
134
|
+
*/
|
|
135
|
+
ignoredPatterns?: string[];
|
|
136
|
+
/**
|
|
137
|
+
* Color values that are allowed (e.g., 'transparent', 'inherit')
|
|
138
|
+
* @default ['transparent', 'inherit', 'currentColor']
|
|
139
|
+
*/
|
|
140
|
+
allowedColors?: string[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Lint a component file for Idealyst-specific issues.
|
|
144
|
+
*
|
|
145
|
+
* Detects issues that TypeScript cannot catch:
|
|
146
|
+
* - Hardcoded colors (TypeScript sees these as valid strings)
|
|
147
|
+
* - Direct react-native imports in shared files (valid TS, but breaks web)
|
|
148
|
+
*
|
|
149
|
+
* @param filePath - Path to the file being analyzed
|
|
150
|
+
* @param sourceCode - The source code content
|
|
151
|
+
* @param options - Linter options
|
|
152
|
+
* @returns Lint result with issues found
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const result = lintComponent(
|
|
157
|
+
* 'src/components/MyButton.tsx',
|
|
158
|
+
* sourceCode,
|
|
159
|
+
* { rules: { hardcodedColors: 'error' } }
|
|
160
|
+
* );
|
|
161
|
+
*
|
|
162
|
+
* if (!result.passed) {
|
|
163
|
+
* for (const issue of result.issues) {
|
|
164
|
+
* console.error(`${issue.line}:${issue.column} - ${issue.message}`);
|
|
165
|
+
* }
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare function lintComponent(filePath: string, sourceCode: string, options?: ComponentLinterOptions): LintResult;
|
|
170
|
+
/**
|
|
171
|
+
* Lint multiple component files
|
|
172
|
+
*
|
|
173
|
+
* @param files - Array of files to lint
|
|
174
|
+
* @param options - Linter options
|
|
175
|
+
* @returns Array of lint results
|
|
176
|
+
*/
|
|
177
|
+
declare function lintComponents(files: Array<{
|
|
178
|
+
path: string;
|
|
179
|
+
content: string;
|
|
180
|
+
}>, options?: ComponentLinterOptions): LintResult[];
|
|
181
|
+
/**
|
|
182
|
+
* Format a lint issue for console output
|
|
183
|
+
*/
|
|
184
|
+
declare function formatLintIssue(issue: LintIssue, filePath: string): string;
|
|
185
|
+
/**
|
|
186
|
+
* Format all lint results for console output
|
|
187
|
+
*/
|
|
188
|
+
declare function formatLintResults(results: LintResult[]): string[];
|
|
189
|
+
/**
|
|
190
|
+
* Summary of lint results
|
|
191
|
+
*/
|
|
192
|
+
interface LintSummary {
|
|
193
|
+
totalFiles: number;
|
|
194
|
+
passedFiles: number;
|
|
195
|
+
failedFiles: number;
|
|
196
|
+
totalIssues: number;
|
|
197
|
+
issuesByType: Record<LintIssueType, number>;
|
|
198
|
+
issuesBySeverity: Record<Severity, number>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Summarize lint results
|
|
202
|
+
*/
|
|
203
|
+
declare function summarizeLintResults(results: LintResult[]): LintSummary;
|
|
204
|
+
|
|
205
|
+
export { type AnalysisSummary, type ComponentLinterOptions, type LintIssue, type LintIssueType, type LintResult, type LintSummary, analyzeFiles, analyzePlatformImports, formatLintIssue, formatLintResults, formatViolation, formatViolations, lintComponent, lintComponents, summarizeLintResults, summarizeResults };
|