import { WithValidations, RuntimeMode, CompilerSourceFile, GenericTypescriptSourceFile, MainRuntimeModes, GenerateTarget } from '@jay-framework/compiler-shared'; import * as ts from 'typescript'; import { JayHtmlSourceFile } from '@jay-framework/compiler-jay-html'; export { generateElementDefinitionFile } from '@jay-framework/compiler-jay-html'; declare enum VariableRootType { FunctionParameter = 0, FunctionDefinition = 1, Literal = 2, ImportModule = 3, FunctionCall = 4, Global = 5, Other = 6 } interface VariableRoot { kind: VariableRootType; } interface ParamVariableRoot extends VariableRoot { kind: VariableRootType.FunctionParameter; paramIndex: number; param: ts.ParameterDeclaration; } declare function mkParameterVariableRoot(param: ts.ParameterDeclaration, paramIndex: number): ParamVariableRoot; interface FunctionVariableRoot extends VariableRoot { kind: VariableRootType.FunctionDefinition; func: ts.FunctionLikeDeclarationBase; } declare function mkFunctionVariableRoot(func: ts.FunctionLikeDeclarationBase): FunctionVariableRoot; interface LiteralVariableRoot extends VariableRoot { kind: VariableRootType.Literal; literal: ts.Expression; } declare function mkLiteralVariableRoot(literal: ts.Expression): LiteralVariableRoot; declare enum ImportType { defaultImport = 0, namedImport = 1 } interface ImportModuleVariableRoot extends VariableRoot { kind: VariableRootType.ImportModule; module: ts.Expression; importType: ImportType; } declare function mkImportModuleVariableRoot(module: ts.Expression, importType: ImportType): ImportModuleVariableRoot; interface FunctionCallVariableRoot extends VariableRoot { kind: VariableRootType.FunctionCall; node: ts.CallExpression; } declare function mkFunctionCallVariableRoot(node: ts.CallExpression): FunctionCallVariableRoot; interface GlobalVariableRoot extends VariableRoot { kind: VariableRootType.Global; name: string; } declare function mkGlobalVariableRoot(name: string): GlobalVariableRoot; interface OtherVariableRoot extends VariableRoot { kind: VariableRootType.Other; node: ts.Node; } declare function mkOtherVariableRoot(node: ts.Node): OtherVariableRoot; declare function isParamVariableRoot(vr: VariableRoot): vr is ParamVariableRoot; declare function isFunctionVariableRoot(vr: VariableRoot): vr is FunctionVariableRoot; declare function isImportModuleVariableRoot(vr: VariableRoot): vr is ImportModuleVariableRoot; declare function isLiteralVariableRoot(vr: VariableRoot): vr is LiteralVariableRoot; declare function isFunctionCallVariableRoot(vr: VariableRoot): vr is FunctionCallVariableRoot; declare function isGlobalVariableRoot(vr: VariableRoot): vr is GlobalVariableRoot; declare function isOtherVariableRoot(vr: VariableRoot): vr is OtherVariableRoot; declare enum LetOrConst { LET = 0, CONST = 1 } interface Variable { name?: string; letOrConst?: LetOrConst; definingStatement?: ts.Statement; accessedFrom?: Variable; accessedByProperty?: string; assignedFrom?: Variable; root?: VariableRoot; properties?: Variable[]; } declare function mkVariable(members: { name?: string; letOrConst?: LetOrConst; definingStatement?: ts.Statement; accessedFrom?: Variable; accessedByProperty?: string; assignedFrom?: Variable; root?: VariableRoot; properties?: Variable[]; }): { [k: string]: string | ts.Statement | VariableRoot | Variable | LetOrConst | Variable[]; }; declare const UNKNOWN_VARIABLE: Variable; declare function tsBindingNameToVariable(binding: ts.BindingName, accessedFrom?: Variable, assignedFrom?: Variable, propertyName?: ts.PropertyName, root?: ParamVariableRoot): Variable[]; declare class NameBindingResolver { readonly parentNameResolver?: NameBindingResolver; constructor(parentNameResolver?: NameBindingResolver); variables: Map; addVariable(name: string, variable: Variable): void; addFunctionParams(functionDeclaration: ts.FunctionLikeDeclarationBase): void; addFunctionDeclaration(statement: ts.FunctionDeclaration): void; addVariableDeclarationList(declarationList: ts.VariableDeclarationList): void; addVariableStatement(variableStatement: ts.VariableStatement): void; getVariable(name: string): Variable; resolvePropertyAccessChain(expression: ts.Expression): Variable; resolvePropertyAccess(expression: ts.PropertyAccessExpression): Variable; resolveIdentifier(expression: ts.Identifier): Variable; addImportDeclaration(node: ts.ImportDeclaration): void; } interface FlattenedAccessChain { path: string[]; root: VariableRoot; } declare function flattenVariable(variable: Variable, path?: string[]): FlattenedAccessChain; interface ResolvedType { canBeAssignedFrom(rightSide: ResolvedType): any; } declare class SourceFileBindingResolver { private nameBindingResolvers; constructor(sourceFile: ts.SourceFile); findBindingResolver(node: ts.Node): NameBindingResolver; explain(identifier: ts.Identifier | ts.PropertyAccessExpression): Variable; explainFlattenedVariableType(flattened: FlattenedAccessChain): ResolvedType; explainType(type: ts.TypeNode): ResolvedType; globalType(globalVariableRoot: GlobalVariableRoot): ResolvedType; } declare enum CompilePatternType { RETURN = 0, CALL = 1, CHAINABLE_CALL = 2, ASSIGNMENT_LEFT_SIDE = 3, KNOWN_VARIABLE_READ = 4, CONST_READ = 5, INLINE_ARROW_FUNCTION = 6 } declare enum JayTargetEnv { main = 0, any = 1, sandbox = 2 } interface CompiledPattern { patternType: CompilePatternType; leftSidePath: string[]; leftSideType: ResolvedType; callArgumentTypes?: ResolvedType[]; returnType: ResolvedType; targetEnvForStatement: JayTargetEnv; name: string; } declare function compileFunctionSplitPatternsBlock(patternFiles: ts.SourceFile[]): WithValidations; interface FunctionRepositoryCodeFragment { handlerCode: string; key: string; } declare class GeneratedFunctionRepository { readonly hasFunctionRepository: boolean; readonly functionRepository: string; constructor(hasFunctionRepository: boolean, functionRepository: string); map(mapper: (value: string) => string): GeneratedFunctionRepository; } declare class FunctionRepositoryBuilder { readonly fragments: Array; readonly consts: Array; private nextIndex; addFunction(handlerCode: string): string; addConst(constCode: string): void; generate(): GeneratedFunctionRepository; generateGlobalFile(): GeneratedFunctionRepository; } declare function transformComponentBridge(importerMode: RuntimeMode, patterns: CompiledPattern[], globalFunctionRepository: FunctionRepositoryBuilder): (context: ts.TransformationContext) => ts.Transformer; declare function transformComponent(patterns: CompiledPattern[], globalFunctionRepository: FunctionRepositoryBuilder): (context: ts.TransformationContext) => ts.Transformer; declare function extractImportDeclarations(sourceFile: ts.SourceFile): ts.ImportDeclaration[]; declare function extractImportedModules(sourceFile: ts.SourceFile): string[]; declare function isRelativeImport(module: string): boolean; declare function getImportSpecifiers(importDeclaration: ts.ImportDeclaration): ts.NodeArray | undefined; declare function getImportName(importSpecifier: ts.ImportSpecifier): string; declare function generateImportsFileFromTsSource(filename: string, source: string): string; declare function generateImportsFileFromJayFile(jayFile: CompilerSourceFile): string; declare function parseGenericTypescriptFile(filePath: string, code: string): WithValidations; declare function createTsSourceFileFromSource(filePath: string, sourceCode: string, scriptKind?: ts.ScriptKind): ts.SourceFile; declare function transformComponentImports(needsHandler$: boolean, needsFunc$: boolean, needsFuncGlobal$: boolean, transformedSourceFile: ts.SourceFile, context: ts.TransformationContext, factory: ts.NodeFactory, sourceFile: ts.SourceFile): ts.SourceFile; interface StatementDependencies { id: number; parent?: ts.Statement; statement: ts.Statement; dependsOn: Set; isDependencyFor: Set; } declare class SourceFileStatementDependencies { private statementDependencies; constructor(sourceFile: ts.SourceFile, bindingResolver: SourceFileBindingResolver); getDependsOn(statement: ts.Statement): Set; getIsDependencyFor(statement: ts.Statement): Set; getAllStatements(): IterableIterator; getStatementDependencies(statement: ts.Statement): StatementDependencies; } interface SourceFileTransformerContext { factory: ts.NodeFactory; context: ts.TransformationContext; sourceFile: ts.SourceFile; } type SourceFileTransformer = (data: SourceFileTransformerContext) => ts.SourceFile; declare function mkTransformer(fileTransformer: SourceFileTransformer, config?: C): ts.TransformerFactory; /** * Compare two FlattenedAccessChain objects for equality * * Two chains are equal if: * 1. Their paths are identical (same length, same elements in order) * 2. Their roots refer to the same source */ declare function areFlattenedAccessChainsEqual(chain1: FlattenedAccessChain, chain2: FlattenedAccessChain): boolean; declare function generateElementFile(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes, generateTarget?: GenerateTarget): WithValidations; export { type CompiledPattern, type FlattenedAccessChain, type FunctionCallVariableRoot, FunctionRepositoryBuilder, type FunctionVariableRoot, type GlobalVariableRoot, type ImportModuleVariableRoot, ImportType, LetOrConst, type LiteralVariableRoot, NameBindingResolver, type OtherVariableRoot, type ParamVariableRoot, SourceFileBindingResolver, SourceFileStatementDependencies, type SourceFileTransformerContext, UNKNOWN_VARIABLE, type Variable, type VariableRoot, VariableRootType, areFlattenedAccessChainsEqual, compileFunctionSplitPatternsBlock, createTsSourceFileFromSource, extractImportDeclarations, extractImportedModules, flattenVariable, generateElementFile, generateImportsFileFromJayFile, generateImportsFileFromTsSource, getImportName, getImportSpecifiers, isFunctionCallVariableRoot, isFunctionVariableRoot, isGlobalVariableRoot, isImportModuleVariableRoot, isLiteralVariableRoot, isOtherVariableRoot, isParamVariableRoot, isRelativeImport, mkFunctionCallVariableRoot, mkFunctionVariableRoot, mkGlobalVariableRoot, mkImportModuleVariableRoot, mkLiteralVariableRoot, mkOtherVariableRoot, mkParameterVariableRoot, mkTransformer, mkVariable, parseGenericTypescriptFile, transformComponent, transformComponentBridge, transformComponentImports, tsBindingNameToVariable };