import type { Plugin } from 'vite'; import type { DiagnosticWithLocation, SourceFile, TransformationContext, TransformerFactory } from 'typescript'; import type { SyncUniModulesFilePreprocessor, UniXCompiler } from '@dcloudio/uni-uts-v1'; type TypeScriptCompiler = typeof import('typescript'); export interface WorkerSourceEdit { start: number; end: number; content: string; } export interface WorkerTransformOptions { extname?: string; rewriteRootDir?: string; resolve(): Record; } export interface WorkerTransformerOptions extends WorkerTransformOptions { typescript: TypeScriptCompiler; platform?: 'app-android' | 'app-ios' | 'app-harmony' | 'mp-weixin' | 'web'; dom2?: boolean; targetLanguage?: 'Kotlin' | 'Swift' | 'JavaScript' | 'ArkTS'; onSourceEdit?: (edit: WorkerSourceEdit) => void; reportDiagnostic(context: TransformationContext, diagnostic: DiagnosticWithLocation): void; } export interface WorkerTransformPluginOptions extends WorkerTransformOptions { createWorkerTransformer: typeof createWorkerTransformer; } export declare function getWorkers(): Record; /** 将标准 JS/TS 中的 uni.createWorker 路径转换为编译后的 worker 路径。 */ export declare function createWorkerTransformer(options: WorkerTransformerOptions): TransformerFactory; export declare function resolveWorkersRootDir(): string; export declare function getWorkersRootDirs(): string[]; export declare function initWorkerTransformOptions(): WorkerTransformPluginOptions; /** * 遍历目录下的所有uts文件,读取文件内容,正则匹配出定义的worker,返回文件名和类名的映射关系 * export class MyWorkerTask extends WorkerTaskImpl {} * @param dir */ export declare function initWorkers(workersDirs: string[], rootDir: string): Record; export declare function uniWorkersPlugin(): Plugin; export declare function syncWorkersFiles(platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string, preprocessor: SyncUniModulesFilePreprocessor, options?: { cache?: Record; workersDirs?: string[]; resolvePreprocessor?: (workersDir: string) => SyncUniModulesFilePreprocessor; }): Promise; export declare function resolveWorkersDir(inputDir: string): Array; export declare function normalizeJavaScriptWorkerSource(content: string): string; export declare function genAlipayWorkerRuntimeImportCode(file: string, workerRootDir?: string): string; export declare function resolveMiniProgramWorkerPaths(workerRootDir?: string): string[]; export declare function uniJavaScriptWorkersPlugin(): Plugin; export declare function initUniXCompilerRootWorkers(rootDir: string, compiler: UniXCompiler): Promise; export {};