UNPKG

@tevm/ts-plugin

Version:
1 lines 49.9 kB
{"version":3,"sources":["../src/utils/isSolidity.ts","../src/utils/isRelativeSolidity.ts","../src/utils/solidityModuleResolver.ts","../src/utils/findNode.ts","../src/utils/invariant.ts","../src/utils/convertSolcAstToTsDefinitionInfo.ts","../src/utils/findContractDefinitionFileNameFromTevmNode.ts","../src/utils/index.ts","../src/decorators/getDefinitionAtPosition.ts","../src/factories/logger.ts","../src/factories/decorator.ts","../src/factories/index.ts","../src/decorators/getScriptKind.ts","../src/utils/resolveJsonAsConst.ts","../src/decorators/getScriptSnapshot.ts","../src/decorators/resolveModuleNameLiterals.ts","../src/decorators/index.ts","../src/factories/fileAccessObject.ts","../src/tsPlugin.ts","../src/index.ts"],"names":["path","createRequire","readFileSync","bundler","solc","fileName","findAll","node","minimatch","existsSync","writeFileSync","stat","statSync","mkdirSync","mkdir","writeFile","readFile","access","config","runSync","loadConfig","catchTag","logWarning","map","defaultConfig","createCache"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAiBa,UAAA;AAjBb,IAAA,eAAA,GAAA,KAAA,CAAA;AAAA,EAAA,yBAAA,GAAA;AAiBO,IAAM,UAAa,GAAA,CAAC,QAC1B,KAAA,QAAA,CAAS,QAAS,CAAA,MAAM,CAAK,IAAA,CAAC,QAAS,CAAA,QAAA,CAAS,OAAO,CAAA,IAAK,QAAa,KAAA,MAAA;AAAA;AAAA,CAAA,CAAA;;;AClB1E,IAUM,UAmBO,EAAA,kBAAA;AA7Bb,IAAA,uBAAA,GAAA,KAAA,CAAA;AAAA,EAAA,iCAAA,GAAA;AAAA,IAAA,eAAA,EAAA;AAUA,IAAM,UAAA,GAAa,CAAC,QAAqB,KAAA,QAAA,CAAS,WAAW,IAAI,CAAA,IAAK,QAAS,CAAA,UAAA,CAAW,KAAK,CAAA;AAmBxF,IAAM,qBAAqB,CAAC,QAAA,KAAqB,WAAW,QAAQ,CAAA,IAAK,WAAW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BAAA,EAAwB,kCAAoC,EAAA,0BAAA,CAA2B,KAAK,CAAC,CAAA;AAAA,gBACzG,UAAA;AAAA,gBACA,OAAQ,CAAA,UAAA;AAAA,gBACR,MAAA;AAAA,gBACAA,QAAA;AAAA,gBACA;AAAA;AACD,aACD;AAAA,YACAA,QAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAQ,CAAA,UAAA;AAAA,YACR,GAAA;AAAA,YACA;AAAA,WACD;AAEA,UAAO,OAAA,OAAA;AAAA,SACR;AAAA,QACA,gBAAA,EAAkB,CAAC,OAAY,KAAA;AAC9B,UAAA,OAAO,OAAQ,CAAA,YAAA,EAAe,CAAA,MAAA,CAAO,UAAU,CAAA;AAAA;AAChD,OACD;AAAA,KACD;AAAA;AAAA,CAAA,CAAA;;;AC/EA,IAAA,aAAA,GAAA,UAAA,CAAA;AAAA,EAAA,cAAA,CAAA,OAAA,EAAA,MAAA,EAAA;AAAA,IAAA,aAAA,EAAA;AAEA,IAAS,MAAA,CAAA,OAAA,GAAA,QAAA;AAAA;AAAA,CAAA,CAAA","file":"index.cjs","sourcesContent":["/**\n * Determines if a file path represents a Solidity source file.\n *\n * This utility checks if a path ends with the '.sol' extension while\n * excluding invalid paths like '/.sol' or just '.sol'.\n *\n * @param fileName - The file path or module name to check\n * @returns True if the file appears to be a valid Solidity file, false otherwise\n * @example\n * ```typescript\n * isSolidity('Contract.sol') // true\n * isSolidity('./path/Contract.sol') // true\n * isSolidity('.sol') // false\n * isSolidity('/.sol') // false\n * isSolidity('Contract.js') // false\n * ```\n */\nexport const isSolidity = (fileName: string) =>\n\tfileName.endsWith('.sol') && !fileName.endsWith('/.sol') && fileName !== '.sol'\n","import { isSolidity } from './isSolidity.js'\n\n/**\n * Helper function to determine if a path is a relative import.\n * Checks if the path starts with './' or '../'.\n *\n * @param fileName - The file path to check\n * @returns True if the path is a relative import, false otherwise\n * @internal\n */\nconst isRelative = (fileName: string) => fileName.startsWith('./') || fileName.startsWith('../')\n\n/**\n * Determines if a path is both a Solidity file and a relative import.\n *\n * This is used to distinguish between relative Solidity imports\n * (like './Contract.sol') and package imports (like 'package/Contract.sol'),\n * which need different resolution strategies.\n *\n * @param fileName - The file path to check\n * @returns True if the path is both a relative path and a Solidity file, false otherwise\n * @example\n * ```typescript\n * isRelativeSolidity('./Contract.sol') // true\n * isRelativeSolidity('../Contract.sol') // true\n * isRelativeSolidity('Contract.sol') // false (not relative)\n * isRelativeSolidity('./Contract.js') // false (not Solidity)\n * ```\n */\nexport const isRelativeSolidity = (fileName: string) => isRelative(fileName) && isSolidity(fileName)\n","import { createRequire } from 'node:module'\nimport path from 'node:path'\nimport type typescript from 'typescript/lib/tsserverlibrary.js'\nimport { isRelativeSolidity } from './isRelativeSolidity.js'\nimport { isSolidity } from './isSolidity.js'\n\n/**\n * Resolves a Solidity module name to its filesystem location and TypeScript type information.\n *\n * This utility handles three different import scenarios:\n * 1. Relative Solidity imports (like './Contract.sol')\n * 2. Package Solidity imports (like 'package/Contract.sol')\n * 3. Special case for '@tevm/contract' imports which need special resolution\n *\n * When Solidity files are imported, they're treated as TypeScript declaration files (.d.ts)\n * to provide type checking and IDE support for the contracts.\n *\n * @param moduleName - The module name to resolve (e.g., './Contract.sol')\n * @param ts - TypeScript library instance\n * @param createInfo - Plugin creation information from TypeScript\n * @param containingFile - Path to the file containing the import\n * @returns A resolved module with filename and extension information, or undefined if not resolvable\n */\nexport const solidityModuleResolver = (\n\tmoduleName: string,\n\tts: typeof typescript,\n\tcreateInfo: typescript.server.PluginCreateInfo,\n\tcontainingFile: string,\n): typescript.ResolvedModuleFull | undefined => {\n\tif (isRelativeSolidity(moduleName)) {\n\t\treturn {\n\t\t\textension: ts.Extension.Dts,\n\t\t\tisExternalLibraryImport: false,\n\t\t\tresolvedFileName: path.resolve(path.dirname(containingFile), moduleName),\n\t\t}\n\t}\n\tif (isSolidity(moduleName)) {\n\t\treturn {\n\t\t\textension: ts.Extension.Dts,\n\t\t\tisExternalLibraryImport: false,\n\t\t\tresolvedFileName: createRequire(path.dirname(containingFile)).resolve(moduleName),\n\t\t}\n\t}\n\n\t// to handle the case where the import is coming from a node_module or a different workspace\n\t// we need to always point @tevm/contract to the local version\n\tif (moduleName.startsWith('@tevm/contract')) {\n\t\tconst result = ts.resolveModuleName(\n\t\t\tmoduleName,\n\t\t\tcontainingFile,\n\t\t\tcreateInfo.project.getCompilerOptions(),\n\t\t\tcreateInfo.project,\n\t\t)\n\n\t\tif (result.resolvedModule) {\n\t\t\treturn {\n\t\t\t\textension: ts.Extension.Dts,\n\t\t\t\tisExternalLibraryImport: true,\n\t\t\t\tresolvedFileName: result.resolvedModule.resolvedFileName,\n\t\t\t}\n\t\t}\n\t\tconsole.error('Could not resolve module. Is tevm/core installed?', moduleName, result)\n\t\treturn undefined\n\t}\n\treturn undefined\n}\n","import type typescript from 'typescript/lib/tsserverlibrary.js'\n\n/**\n * Find the typescript node at the given position in the AST\n */\nexport function findNode(rootNode: typescript.Node, position: number): typescript.Node | null {\n\tif (position < 0) {\n\t\tthrow new Error('Position must be non-negative')\n\t}\n\tif (Number.isInteger(position) === false) {\n\t\tthrow new Error('Position must be an integer')\n\t}\n\tlet foundNode: typescript.Node | null = null\n\tfunction visit(node: typescript.Node) {\n\t\tif (position >= node.getStart() && position <= node.getEnd()) {\n\t\t\tfoundNode = node\n\t\t\tnode.forEachChild(visit)\n\t\t}\n\t}\n\trootNode.forEachChild(visit)\n\treturn foundNode\n}\n","export function invariant(condition: any, message: string): asserts condition {\n\tif (!condition) {\n\t\tthrow new Error(message)\n\t}\n}\n","import { readFileSync } from 'node:fs'\nimport type { Node } from 'solidity-ast/node.js'\nimport type { SolcInput } from 'solidity-ast/solc.js'\nimport type typescript from 'typescript/lib/tsserverlibrary.js'\n\n/**\n * Adapter from solc to typescript\n * When given basic solc information it will turn it into a TypeScript DefinitionInfo object\n */\nexport function convertSolcAstToTsDefinitionInfo(\n\tastNode: Node,\n\tfileName: string,\n\tcontainerName: string,\n\tsolcInput: SolcInput,\n\tts: typeof typescript,\n): typescript.DefinitionInfo {\n\tconst [start, length] = astNode.src.split(':').map(Number)\n\n\tlet kind = ts.ScriptElementKind.unknown\n\tlet name = 'unknown'\n\tif (astNode.nodeType === 'VariableDeclaration') {\n\t\tkind = ts.ScriptElementKind.variableElement\n\t\tname = astNode.name\n\t} else if (astNode.nodeType === 'FunctionDefinition') {\n\t\tkind = ts.ScriptElementKind.functionElement\n\t\tname = astNode.name\n\t}\n\n\tconst inputLength = solcInput.sources[fileName].content?.length as number\n\tconst actualLength = readFileSync(fileName, 'utf8').length\n\tconst offset = inputLength - actualLength\n\n\t// Create and return the TypeScript DefinitionInfo object\n\treturn {\n\t\tfileName,\n\t\ttextSpan: ts.createTextSpan(start - offset, length),\n\t\tkind,\n\t\tname,\n\t\tcontainerKind: ts.ScriptElementKind.classElement,\n\t\tcontainerName,\n\t}\n}\n","import type typescript from 'typescript/lib/tsserverlibrary.js'\n\nexport function findContractDefinitionFileNameFromTevmNode(\n\tnode: typescript.Node,\n\tlanguageService: typescript.LanguageService,\n\tfileName: string,\n\tts: typeof typescript,\n): string | null {\n\tlet current = node\n\n\twhile (current) {\n\t\tif (!ts.isPropertyAccessExpression(current)) {\n\t\t\tcurrent = current.parent\n\t\t\tcontinue\n\t\t}\n\t\tconst parent = current.expression\n\t\tif (!ts.isCallExpression(parent)) {\n\t\t\tcurrent = current.parent\n\t\t\tcontinue\n\t\t}\n\n\t\tconst grandParent = parent.expression\n\t\tif (!ts.isPropertyAccessExpression(grandParent)) {\n\t\t\tcurrent = current.parent\n\t\t\tcontinue\n\t\t}\n\n\t\tif (!['read', 'write', 'events'].includes(grandParent.name.getText())) {\n\t\t\tcurrent = current.parent\n\t\t\tcontinue\n\t\t}\n\t\tconst contractNode = grandParent.expression\n\t\tconst contractDefinition = languageService.getDefinitionAtPosition(fileName, contractNode.getStart())\n\n\t\tif (!contractDefinition || contractDefinition.length === 0) {\n\t\t\tcurrent = current.parent\n\t\t\tcontinue\n\t\t}\n\n\t\tconst out = contractDefinition[0].fileName\n\n\t\tif (!out.endsWith('.sol')) {\n\t\t\tcurrent = current.parent\n\t\t\tcontinue\n\t\t}\n\n\t\treturn out\n\t}\n\n\treturn null\n}\n","export * from './isRelativeSolidity.js'\nexport * from './isSolidity.js'\nexport * from './solidityModuleResolver.js'\nexport * from './findNode.js'\nexport * from './invariant.js'\nexport * from './convertSolcAstToTsDefinitionInfo.js'\nexport * from './findContractDefinitionFileNameFromTevmNode.js'\n","import { type FileAccessObject, bundler } from '@tevm/base-bundler'\nimport type { Cache } from '@tevm/bundler-cache'\nimport type { ResolvedCompilerConfig } from '@tevm/config'\nimport * as solc from 'solc'\nimport type { Node } from 'solidity-ast/node.js'\nimport type { SolcInput } from 'solidity-ast/solc.js'\nimport { findAll } from 'solidity-ast/utils.js'\nimport type typescript from 'typescript/lib/tsserverlibrary.js'\nimport type { Logger } from '../factories/logger.js'\nimport { findNode } from '../utils/index.js'\nimport { convertSolcAstToTsDefinitionInfo, findContractDefinitionFileNameFromTevmNode } from '../utils/index.js'\n\n/**\n * Decorates the TypeScript LanguageService to provide \"Go to Definition\" support for Solidity contracts.\n *\n * This decorator extends the standard TypeScript language service by:\n * 1. Detecting when a user attempts to navigate to a definition in a Solidity contract\n * 2. Compiling the Solidity source using solc\n * 3. Parsing the AST to find matching function/event definitions\n * 4. Converting Solidity AST nodes to TypeScript definition information\n * 5. Returning these definitions alongside any TypeScript definitions\n *\n * This enables IDE features like \"Go to Definition\" to work seamlessly between TypeScript and Solidity.\n *\n * Note: Unlike other decorators in this codebase, this decorates the language service directly,\n * not the LanguageServiceHost. Future refactoring may generalize this approach.\n *\n * @param service - The TypeScript language service to decorate\n * @param config - Compiler configuration for Solidity files\n * @param logger - Logger instance for debugging information\n * @param ts - TypeScript library instance\n * @param fao - File access object for reading files\n * @param solcCache - Cache instance for solc compilations\n * @returns Decorated TypeScript language service with Solidity definition support\n */\nexport const getDefinitionServiceDecorator = (\n\tservice: typescript.LanguageService,\n\tconfig: ResolvedCompilerConfig,\n\tlogger: Logger,\n\tts: typeof typescript,\n\tfao: FileAccessObject,\n\tsolcCache: Cache,\n): typescript.LanguageService => {\n\tconst getDefinitionAtPosition: typeof service.getDefinitionAtPosition = (fileName, position) => {\n\t\tconst definition = service.getDefinitionAtPosition(fileName, position)\n\t\tconst sourceFile = service.getProgram()?.getSourceFile(fileName)\n\t\tconst node = sourceFile && findNode(sourceFile, position)\n\t\tconst ContractPath = node && findContractDefinitionFileNameFromTevmNode(node, service, fileName, ts)\n\t\tif (!ContractPath) {\n\t\t\treturn definition\n\t\t}\n\t\tconst plugin = bundler(config, logger as any, fao, solc, solcCache)\n\t\tconst includedAst = true\n\t\tconst { asts, solcInput } = plugin.resolveDtsSync(ContractPath, process.cwd(), includedAst, false)\n\t\tif (!asts) {\n\t\t\tlogger.error(`@tevm/ts-plugin: getDefinitionAtPositionDecorator was unable to resolve asts for ${ContractPath}`)\n\t\t\treturn definition\n\t\t}\n\n\t\tconst definitions: Array<{\n\t\t\tnode: Node\n\t\t\tfileName: string\n\t\t}> = []\n\t\tfor (const [fileName, ast] of Object.entries(asts)) {\n\t\t\tfor (const functionDef of findAll('EventDefinition', ast)) {\n\t\t\t\tif (functionDef.name === node?.getText()) {\n\t\t\t\t\tdefinitions.push({\n\t\t\t\t\t\tnode: functionDef,\n\t\t\t\t\t\tfileName,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const functionDef of findAll('FunctionDefinition', ast)) {\n\t\t\t\tif (functionDef.name === node?.getText()) {\n\t\t\t\t\tdefinitions.push({\n\t\t\t\t\t\tnode: functionDef,\n\t\t\t\t\t\tfileName,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!definitions.length) {\n\t\t\tlogger.error(`@tevm/ts-plugin: unable to find definitions ${ContractPath}`)\n\t\t\treturn definition\n\t\t}\n\t\tconst contractName = ContractPath.split('/').pop()?.split('.')[0] ?? 'Contract'\n\t\t// Skip definitions that would require solcInput if it is not available\n\t\tif (!solcInput) {\n\t\t\tlogger.error(`@tevm/ts-plugin: solcInput is undefined for ${ContractPath}`)\n\t\t\treturn definition\n\t\t}\n\t\treturn [\n\t\t\t...definitions.map(({ fileName, node }) =>\n\t\t\t\tconvertSolcAstToTsDefinitionInfo(node, fileName, contractName, { sources: solcInput.sources } as SolcInput, ts),\n\t\t\t),\n\t\t\t...(definition ?? []),\n\t\t]\n\t}\n\n\tconst getDefinitionAndBoundSpan: typeof service.getDefinitionAndBoundSpan = (fileName, position) => {\n\t\tconst definitions = getDefinitionAtPosition(fileName, position)\n\t\tif (!definitions) {\n\t\t\treturn service.getDefinitionAndBoundSpan(fileName, position)\n\t\t}\n\t\tif (!definitions.some((definition) => definition.fileName.endsWith('.sol'))) {\n\t\t\treturn service.getDefinitionAndBoundSpan(fileName, position)\n\t\t}\n\t\t// Logic to determine the appropriate text span for highlighting.\n\t\tconst sourceFile = service.getProgram()?.getSourceFile(fileName)\n\t\tconst node = sourceFile && findNode(sourceFile, position)\n\t\tconst textSpan = node ? ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) : undefined\n\n\t\treturn {\n\t\t\tdefinitions,\n\t\t\ttextSpan: textSpan ?? ts.createTextSpan(0, 0), // Fallback to a zero-length span\n\t\t}\n\t}\n\n\treturn new Proxy(service, {\n\t\tget(target, key) {\n\t\t\tif (key === 'getDefinitionAtPosition') {\n\t\t\t\treturn getDefinitionAtPosition\n\t\t\t}\n\t\t\tif (key === 'getDefinitionAndBoundSpan') {\n\t\t\t\treturn getDefinitionAndBoundSpan\n\t\t\t}\n\t\t\treturn target[key as keyof typeof target]\n\t\t},\n\t})\n}\n","import type typescript from 'typescript/lib/tsserverlibrary.js'\n\n/**\n * Interface for the logger used throughout the ts-plugin.\n * Provides standard logging methods with consistent formatting.\n *\n * All log messages are prefixed with `[tevm-ts-plugin]` for easier identification\n * in TypeScript server logs.\n *\n * @see {@link createLogger} - Factory function to create a logger instance\n */\nexport type Logger = {\n\tinfo: (msg: string) => void\n\twarn: (msg: string) => void\n\terror: (msg: string) => void\n\tlog: (msg: string) => void\n}\n\n/**\n * Creates a logger that forwards messages to the TypeScript language service logger.\n *\n * This factory wraps the TypeScript project service logger to provide consistent\n * formatting and logging levels for the Tevm TypeScript plugin. All messages are\n * prefixed with `[tevm-ts-plugin]` and appropriate level indicators for easier\n * identification in the TypeScript server logs.\n *\n * @param pluginCreateInfo - The TypeScript plugin creation info containing the project service\n * @returns A Logger instance with info, warn, error, and log methods\n * @see {@link Logger} - The logger interface\n *\n * @example\n * ```typescript\n * // Create a logger from plugin creation info\n * const logger = createLogger(createInfo);\n *\n * // Log messages at different levels\n * logger.info('Plugin initialized');\n * logger.warn('Config file not found, using defaults');\n * logger.error('Failed to compile contract');\n * logger.log('Processing file: Contract.sol');\n * ```\n */\nexport const createLogger = (pluginCreateInfo: typescript.server.PluginCreateInfo): Logger => {\n\tconst info = (msg: string) => pluginCreateInfo.project.projectService.logger.info(`[tevm-ts-plugin] ${msg}`)\n\tconst warn = (msg: string) => pluginCreateInfo.project.projectService.logger.info(`[tevm-ts-plugin] warning: ${msg}`)\n\tconst error = (msg: string) => pluginCreateInfo.project.projectService.logger.info(`[tevm-ts-plugin] error: ${msg}`)\n\tconst log = (msg: string) => pluginCreateInfo.project.projectService.logger.info(`[tevm-ts-plugin] log: ${msg}`)\n\treturn { info, warn, error, log }\n}\n","import type { FileAccessObject } from '@tevm/base-bundler'\nimport type { ResolvedCompilerConfig } from '@tevm/config'\nimport type typescript from 'typescript/lib/tsserverlibrary.js'\nimport type { Logger } from './logger.js'\n\n/**\n * Represents a function that transforms a TypeScript LanguageServiceHost.\n *\n * A host decorator takes the original LanguageServiceHost from the TypeScript\n * language service and returns a modified version that alters or extends its behavior.\n * This is the primary mechanism used by this plugin to intercept and modify\n * TypeScript language service operations.\n *\n * @internal\n * @see {@link typescript.LanguageServiceHost}\n */\nexport type HostDecorator = (\n\tcreateInfo: typescript.server.PluginCreateInfo,\n\tts: typeof typescript,\n\tlogger: Logger,\n\tconfig: ResolvedCompilerConfig,\n\tfao: FileAccessObject,\n) => typescript.LanguageServiceHost\n\n/**\n * Type of function passed into createDecorator\n * @see {@link createHostDecorator}\n * @example\n * const decoratorFn: PartialDecorator = (createInfo, ts, logger) => ({\n * getScriptKind: (fileName) => {\n * if (fileName.endsWith('.sol')) {\n * return ts.ScriptKind.TS\n * }\n * return createInfo.languageServiceHost.getScriptKind(fileName)\n * },\n * })\n */\nexport type PartialHostDecorator = (\n\tcreateInfo: typescript.server.PluginCreateInfo,\n\tts: typeof typescript,\n\tlogger: Logger,\n\tconfig: ResolvedCompilerConfig,\n\tfao: FileAccessObject,\n) => Partial<typescript.LanguageServiceHost>\n\n/**\n * Creates a full LanguageServiceHost decorator from a partial decorator function.\n *\n * This factory simplifies creating decorators by allowing you to specify only the\n * methods you want to override. The resulting decorator uses JavaScript Proxy to\n * intercept only the specified methods while delegating all other method calls\n * to the original LanguageServiceHost.\n *\n * @param decorator - A function that returns partial LanguageServiceHost implementation\n * @returns A complete HostDecorator function that can be used to decorate a LanguageServiceHost\n * @see {@link PartialHostDecorator}\n * @example\n * ```typescript\n * // Create a decorator that overrides the getScriptKind method\n * const jsonDecorator = createHostDecorator((createInfo, ts) => ({\n * getScriptKind: (fileName) => {\n * if (fileName.endsWith('.json')) {\n * return ts.ScriptKind.JSON\n * }\n * return createInfo.languageServiceHost.getScriptKind(fileName)\n * }\n * }))\n * ```\n */\nexport const createHostDecorator = (decorator: PartialHostDecorator): HostDecorator => {\n\treturn (createInfo, ...rest) => {\n\t\tconst proxy = decorator(createInfo, ...rest)\n\t\treturn new Proxy(createInfo.languageServiceHost, {\n\t\t\tget(target, key) {\n\t\t\t\t// If the key is one of the keys that are to be proxied, return the proxy value.\n\t\t\t\tif (key in proxy) {\n\t\t\t\t\treturn proxy[key as keyof typescript.LanguageServiceHost]\n\t\t\t\t}\n\t\t\t\t// Otherwise, return the host value.\n\t\t\t\treturn target[key as keyof typescript.LanguageServiceHost]\n\t\t\t},\n\t\t})\n\t}\n}\n\n/**\n * Composes multiple HostDecorator functions into a single decorator.\n *\n * This utility allows combining multiple independent decorators that each modify\n * different aspects of the TypeScript LanguageServiceHost. The decorators are\n * applied in the order they are provided (first to last).\n *\n * The composition works by chaining decorators, where each decorator receives\n * the result of applying all previous decorators.\n *\n * @param decorators - Array of HostDecorator functions to compose\n * @returns A single HostDecorator that applies all the provided decorators\n * @example\n * ```typescript\n * // Combine multiple decorators into one\n * const combinedDecorator = decorateHost(\n * scriptKindDecorator,\n * moduleResolverDecorator,\n * scriptSnapshotDecorator\n * )\n *\n * // Apply all decorators at once\n * const decoratedHost = combinedDecorator(createInfo, typescript, logger, config, fao)\n * ```\n */\nexport const decorateHost = (...decorators: HostDecorator[]): HostDecorator => {\n\treturn (createInfo, ...rest) => {\n\t\tif (decorators.length === 0) {\n\t\t\treturn createInfo.languageServiceHost\n\t\t}\n\n\t\tconst [nextDecorator, ...restDecorators] = decorators\n\n\t\tconst decoratedHost = nextDecorator(createInfo, ...rest)\n\n\t\tconst decoratedCreateInfo = new Proxy(createInfo, {\n\t\t\tget(target, key) {\n\t\t\t\tif (key === 'languageServiceHost') {\n\t\t\t\t\treturn decoratedHost\n\t\t\t\t}\n\t\t\t\treturn target[key as keyof typeof target]\n\t\t\t},\n\t\t})\n\n\t\treturn decorateHost(...restDecorators)(decoratedCreateInfo, ...rest)\n\t}\n}\n","export * from './logger.js'\nexport * from './decorator.js'\n","import { createHostDecorator } from '../factories/index.js'\nimport { isRelativeSolidity, isSolidity } from '../utils/index.js'\n\n/**\n * Decorate `LangaugeServerHost.getScriptKind` to return TS type for `.sol` files\n * This lets the ts-server expect `.sol` files to resolve to `.d.ts` files in `resolveModuleNameLiterals`\n */\nexport const getScriptKindDecorator = createHostDecorator((createInfo, ts, logger, config) => {\n\treturn {\n\t\tgetScriptKind: (fileName) => {\n\t\t\t// TODO we should check if it is using ts baseUrl or paths in future\n\t\t\tif (isRelativeSolidity(fileName)) {\n\t\t\t\treturn ts.ScriptKind.TS\n\t\t\t}\n\t\t\tif (isSolidity(fileName)) {\n\t\t\t\treturn ts.ScriptKind.External\n\t\t\t}\n\t\t\tif (!createInfo.languageServiceHost.getScriptKind) {\n\t\t\t\treturn ts.ScriptKind.Unknown\n\t\t\t}\n\t\t\treturn createInfo.languageServiceHost.getScriptKind(fileName)\n\t\t},\n\t}\n})\n","import { minimatch } from 'minimatch'\n\n/**\n * Resolves JSON files as const if they match the config\n * @param config The configuration object\n * @param jsonFilePath The path to the JSON file\n * @param fao File Access Object\n * @param languageServiceHost The language service host\n * @param ts TypeScript object\n * @returns A script snapshot or undefined\n */\nexport const resolveJsonAsConst = (config: any, jsonFilePath: string, fao: any, languageServiceHost: any, ts: any) => {\n\tfor (const matcher of config.jsonAsConst) {\n\t\tif (minimatch(jsonFilePath, matcher)) {\n\t\t\tconst jsonString = fao.readFileSync(jsonFilePath, 'utf8')\n\t\t\treturn ts.ScriptSnapshot.fromString(`export default ${jsonString} as const`)\n\t\t}\n\t}\n\treturn languageServiceHost.getScriptSnapshot(jsonFilePath)\n}\n","import { existsSync, writeFileSync } from 'node:fs'\nimport { bundler } from '@tevm/base-bundler'\nimport type { Cache } from '@tevm/bundler-cache'\nimport * as solc from 'solc'\nimport { createHostDecorator } from '../factories/index.js'\nimport { isSolidity } from '../utils/index.js'\nimport { resolveJsonAsConst } from '../utils/resolveJsonAsConst.js'\n\n/**\n * Decorate `LangaugeServerHost.getScriptSnapshot` to return generated `.d.ts` file for `.sol` files\n * This will allow the language server to provide intellisense for `.sol` files\n * @see https://github.com/wagmi-dev/wagmi/blob/main/packages/cli/src/plugins/foundry.ts\n * TODO replace with modules for code reuse\n */\nexport const getScriptSnapshotDecorator = (solcCache: Cache) =>\n\tcreateHostDecorator(({ languageServiceHost }, ts, logger, config, fao) => {\n\t\treturn {\n\t\t\tgetScriptSnapshot: (filePath) => {\n\t\t\t\tif (filePath.endsWith('.json')) {\n\t\t\t\t\treturn resolveJsonAsConst(config, filePath, fao, languageServiceHost, ts)\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!isSolidity(filePath) ||\n\t\t\t\t\t!existsSync(filePath) ||\n\t\t\t\t\texistsSync(`${filePath}.d.ts`) ||\n\t\t\t\t\texistsSync(`${filePath}.ts`)\n\t\t\t\t) {\n\t\t\t\t\treturn languageServiceHost.getScriptSnapshot(filePath)\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst plugin = bundler(config, logger as any, fao, solc, solcCache)\n\t\t\t\t\tconst resolveBytecode = filePath.endsWith('.s.sol')\n\t\t\t\t\tconst snapshot = plugin.resolveDtsSync(filePath, process.cwd(), false, resolveBytecode)\n\t\t\t\t\tif (config.debug) {\n\t\t\t\t\t\twriteFileSync(\n\t\t\t\t\t\t\t`${filePath}.debug.d.ts`,\n\t\t\t\t\t\t\t`// Debug: the following snapshot is what tevm resolves ${filePath} to\\n${snapshot.code}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn ts.ScriptSnapshot.fromString(snapshot.code)\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(`@tevm/ts-plugin: getScriptSnapshotDecorator was unable to resolve dts for ${filePath}`)\n\t\t\t\t\tlogger.error(e as any)\n\t\t\t\t\treturn ts.ScriptSnapshot.fromString('export {}')\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t})\n","import { createHostDecorator } from '../factories/index.js'\nimport { solidityModuleResolver } from '../utils/index.js'\nimport { invariant } from '../utils/invariant.js'\n\n/**\n * Decorate `LangaugeServerHost.resolveModuleNameLiterals` to return config object to resolve `.sol` files\n * This tells the ts-server to resolve `.sol` files to `.d.ts` files with `getScriptSnapshot`\n */\nexport const resolveModuleNameLiteralsDecorator = createHostDecorator((createInfo, ts, logger, config) => {\n\treturn {\n\t\tresolveModuleNameLiterals: (moduleNames, containingFile, ...rest) => {\n\t\t\tconst resolvedModules = createInfo.languageServiceHost.resolveModuleNameLiterals?.(\n\t\t\t\tmoduleNames,\n\t\t\t\tcontainingFile,\n\t\t\t\t...rest,\n\t\t\t)\n\n\t\t\treturn moduleNames.map(({ text: moduleName }, index) => {\n\t\t\t\tlet remappedName = moduleName\n\t\t\t\tObject.entries(config.remappings).forEach(([from, to]) => {\n\t\t\t\t\tif (moduleName.startsWith(from)) {\n\t\t\t\t\t\tremappedName = moduleName.replace(from, to)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tinvariant(resolvedModules, 'Expected \"resolvedModules\" to be defined.')\n\t\t\t\ttry {\n\t\t\t\t\tconst resolvedModule = solidityModuleResolver(remappedName, ts, createInfo, containingFile)\n\t\t\t\t\tif (resolvedModule) {\n\t\t\t\t\t\treturn { resolvedModule }\n\t\t\t\t\t}\n\t\t\t\t\treturn resolvedModules[index]\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(e as string)\n\t\t\t\t\treturn resolvedModules[index]\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t}\n})\n","export * from './getScriptKind.js'\nexport * from './getScriptSnapshot.js'\nexport * from './resolveModuleNameLiterals.js'\n","import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises'\nimport type { FileAccessObject } from '@tevm/base-bundler'\nimport type typescript from 'typescript/lib/tsserverlibrary.js'\n\n/**\n * Creates a FileAccessObject implementation that uses the TypeScript LanguageServiceHost\n * to read and write files.\n *\n * This adapter allows the Tevm bundler to interact with the TypeScript language service's\n * virtual file system rather than directly with the real file system. The LSP maintains\n * its own view of files, which may include unsaved changes not yet written to disk.\n *\n * @param lsHost - The TypeScript language service host providing file access\n * @returns A FileAccessObject implementation that delegates to the LanguageServiceHost\n */\nexport const createFileAccessObject = (lsHost: typescript.LanguageServiceHost): FileAccessObject => {\n\treturn {\n\t\texistsSync: (fileName) => lsHost.fileExists(fileName),\n\t\treadFileSync: (fileName, encoding) => {\n\t\t\tconst file = lsHost.readFile(fileName, encoding)\n\t\t\tif (!file) {\n\t\t\t\tthrow new Error(`@tevm/ts-plugin: unable to read file ${fileName}`)\n\t\t\t}\n\t\t\treturn file\n\t\t},\n\t\twriteFileSync: (fileName, data) => {\n\t\t\tlsHost.writeFile?.(fileName, data)\n\t\t},\n\t\t// TODO clean this up. This works fine only because only the cache needs them and the cache is operating on a real file system and not a virtual one\n\t\t// These are just stubs to match interface since making multiple interfaces is tedious atm\n\t\texists: async (fileName) => {\n\t\t\treturn lsHost.fileExists(fileName)\n\t\t},\n\t\treadFile: async (fileName, encoding) => {\n\t\t\tconst file = lsHost.readFile(fileName, encoding)\n\t\t\tif (!file) {\n\t\t\t\tthrow new Error(`@tevm/ts-plugin: unable to read file ${fileName}`)\n\t\t\t}\n\t\t\treturn file\n\t\t},\n\t\tstat,\n\t\tstatSync,\n\t\tmkdirSync,\n\t\tmkdir,\n\t\twriteFile,\n\t}\n}\n\n/**\n * Creates a FileAccessObject implementation that uses the real filesystem.\n *\n * This implementation directly uses Node.js fs/fs.promises APIs to access the\n * actual filesystem rather than the TypeScript language service's virtual filesystem.\n * It's primarily used for operations that need to persist outside the language\n * service context, such as caching.\n *\n * @returns A FileAccessObject implementation using real filesystem access\n */\nexport const createRealFileAccessObject = (): FileAccessObject => {\n\treturn {\n\t\treadFile,\n\t\texistsSync,\n\t\treadFileSync,\n\t\twriteFileSync,\n\t\tstatSync,\n\t\tstat,\n\t\tmkdirSync,\n\t\tmkdir,\n\t\twriteFile,\n\t\texists: async (fileName) => {\n\t\t\ttry {\n\t\t\t\tawait access(fileName)\n\t\t\t\treturn true\n\t\t\t} catch (e) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t},\n\t}\n}\n","import { createCache } from '@tevm/bundler-cache'\nimport { defaultConfig, loadConfig } from '@tevm/config'\nimport { catchTag, logWarning, map, runSync } from 'effect/Effect'\nimport type typescript from 'typescript/lib/tsserverlibrary.js'\nimport { getDefinitionServiceDecorator } from './decorators/getDefinitionAtPosition.js'\nimport {\n\tgetScriptKindDecorator,\n\tgetScriptSnapshotDecorator,\n\tresolveModuleNameLiteralsDecorator,\n} from './decorators/index.js'\nimport { createFileAccessObject, createRealFileAccessObject } from './factories/fileAccessObject.js'\nimport { createLogger, decorateHost } from './factories/index.js'\nimport { isSolidity } from './utils/index.js'\n\n/**\n * TypeScript server plugin factory that enables Solidity support in TypeScript.\n * This plugin allows direct importing of .sol files in TypeScript with proper\n * type definitions, code navigation, and IDE support.\n *\n * The plugin works by decorating the TypeScript language service to handle\n * Solidity files, compile them with solc, and provide TypeScript definitions.\n *\n * Add to your tsconfig.json:\n * @example\n * ```json\n * {\n * \"compilerOptions\": {\n * \"plugins\": [{ \"name\": \"tevm-ts-plugin\" }]\n * }\n * }\n * ```\n *\n * @see https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin\n * @see https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin#decorator-creation\n */\nexport const tsPlugin: typescript.server.PluginModuleFactory = (modules) => {\n\treturn {\n\t\tcreate: (createInfo) => {\n\t\t\tconst logger = createLogger(createInfo)\n\n\t\t\tconst config = runSync(\n\t\t\t\tloadConfig(createInfo.project.getCurrentDirectory()).pipe(\n\t\t\t\t\tcatchTag('FailedToReadConfigError', () =>\n\t\t\t\t\t\tlogWarning('Unable to find tevm.config.json. Using default config.').pipe(map(() => defaultConfig)),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t\t// this fao uses the lsp not the real file system\n\t\t\tconst fao = createFileAccessObject(createInfo.languageServiceHost)\n\t\t\tconst cache = createCache(\n\t\t\t\tconfig.cacheDir,\n\t\t\t\t// this fao uses real file system\n\t\t\t\t// TODO we want to handle the case where fs doesn't exist\n\t\t\t\tcreateRealFileAccessObject(),\n\t\t\t\tcreateInfo.project.getCurrentDirectory(),\n\t\t\t)\n\t\t\tconst service = getDefinitionServiceDecorator(\n\t\t\t\tmodules.typescript.createLanguageService(\n\t\t\t\t\tdecorateHost(getScriptKindDecorator, resolveModuleNameLiteralsDecorator, getScriptSnapshotDecorator(cache))(\n\t\t\t\t\t\tcreateInfo,\n\t\t\t\t\t\tmodules.typescript,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tfao,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tconfig,\n\t\t\t\tlogger,\n\t\t\t\tmodules.typescript,\n\t\t\t\tfao,\n\t\t\t\tcache,\n\t\t\t)\n\n\t\t\treturn service\n\t\t},\n\t\tgetExternalFiles: (project) => {\n\t\t\treturn project.getFileNames().filter(isSolidity)\n\t\t},\n\t}\n}\n","import { tsPlugin } from './tsPlugin.js'\n\nexport = tsPlugin\n"]}