/** * 一个 SanSourceFile 表示一个 San 源文件 * * San 源文件可以是一个 .san 文件,.js 文件,.ts 文件,也可以是一个 ComponentClass,具体来说: * - .ts 文件对应的类型是 TypedSanSourceFile * - .js 文件对应的类型是 JSSanSourceFile * - .san 文件会通过 WebPack 转换为 .js 文件再进入 SSR,所以也对应 JSSanSourceFile * - ComponentClass 对应的类型是 DynamicSanSourceFile */ import type { SourceFile } from 'ts-morph'; import type { DynamicComponentInfo, ComponentInfo, JSComponentInfo, TypedComponentInfo } from '../models/component-info'; /** * 一个 San 项目中的源文件 * * 是 TypeScript SourceFile 的封装,但包含组件信息 */ export declare abstract class SanSourceFileImpl { /** * 每个组件对应一个 ComponentInfo,它们可以在运行时互相调用,是平铺关系 */ readonly componentInfos: T[]; /** * componentInfos 中作为入口组件的那个 * - 对于 TypeScript 解析来的组件,是默认导出的组件 * - 对于 ComponentClass 解析来的组件,是根组件 */ readonly entryComponentInfo?: T | undefined; constructor( /** * 每个组件对应一个 ComponentInfo,它们可以在运行时互相调用,是平铺关系 */ componentInfos: T[], /** * componentInfos 中作为入口组件的那个 * - 对于 TypeScript 解析来的组件,是默认导出的组件 * - 对于 ComponentClass 解析来的组件,是根组件 */ entryComponentInfo?: T | undefined); /** * 文件路径对于命名空间(编译到非 JavaScript 时)很有用 */ abstract getFilePath(): string; } export declare class DynamicSanSourceFile extends SanSourceFileImpl { private readonly filePath; readonly entryComponentInfo: DynamicComponentInfo; constructor(componentInfos: DynamicComponentInfo[], filePath: string, entryComponentInfo: DynamicComponentInfo); getFilePath(): string; } export declare class JSSanSourceFile extends SanSourceFileImpl { private readonly filePath; private readonly fileContent; readonly entryComponentInfo?: JSComponentInfo | undefined; constructor(filePath: string, fileContent: string, componentInfos: JSComponentInfo[], entryComponentInfo?: JSComponentInfo | undefined); getFilePath(): string; getFileContent(): string; } export declare class TypedSanSourceFile extends SanSourceFileImpl { readonly tsSourceFile: SourceFile; constructor(componentInfos: TypedComponentInfo[], tsSourceFile: SourceFile, entryComponentInfo?: TypedComponentInfo); getFilePath(): import("ts-morph").StandardizedFilePath; /** * 遍历组件类声明 */ getComponentClassDeclarations(): Generator; } export type SanSourceFile = DynamicSanSourceFile | TypedSanSourceFile | JSSanSourceFile; export declare function isTypedSanSourceFile(sourceFile: SanSourceFile): sourceFile is TypedSanSourceFile; export declare function isJSSanSourceFile(sourceFile: SanSourceFile): sourceFile is JSSanSourceFile;