import { Program, ImportDeclaration } from '@babel/types'; import * as _babel_parser from '@babel/parser'; import { ParserPlugin } from '@babel/parser'; import { EmittedAsset, PluginContext } from 'rollup'; import * as _vue_compiler_core from '@vue/compiler-core'; import { ElementNode, RootNode, TemplateChildNode, TransformContext, NodeTransform, DirectiveNode, DirectiveTransform, ComponentNode, AttributeNode, ExpressionNode, SourceLocation, Position, Node, SimpleExpressionNode, CompoundExpressionNode, ParserOptions } from '@vue/compiler-core'; import { WatchOptions } from 'chokidar'; export { default as chokidar } from 'chokidar'; import * as vite from 'vite'; import { Plugin, LogErrorOptions, LogOptions, ResolvedConfig, UserConfig, ConfigEnv } from 'vite'; import * as BabelCore from '@babel/core'; import { PluginObj } from '@babel/core'; import { TemplateCompiler, SFCStyleCompileOptions, CompilerOptions } from '@vue/compiler-sfc'; import { PluginCreator, Plugin as Plugin$1 } from 'postcss'; import { Options } from 'autoprefixer'; import * as _esbuild from 'esbuild'; import { BuildOptions } from 'esbuild'; import { BaseNode, Property, Identifier, AssignmentExpression, CallExpression, MemberExpression, MethodDefinition, ExportSpecifier, Literal } from 'estree'; import { FilterPattern } from '@rollup/pluginutils'; export { default as hash } from 'hash-sum'; /** @format */ declare function emptyDir(dir: string, skip?: string[]): void; /** @format */ declare function parseProgram(code: string, importer: string, { babelParserPlugins }: { babelParserPlugins?: ParserPlugin[]; }): Program; /** @format */ declare function parseWxsCallMethods(code: string): string[]; declare function genWxsCallMethodsCode(code: string): string; /** @format */ declare function formatMiniProgramEvent(eventName: string, { isCatch, isCapture, isComponent, }: { isCatch?: boolean; isCapture?: boolean; isComponent?: boolean; }): string; /** @format */ declare function transformScopedCss(cssCode: string): string; /** @format */ declare function isMiniProgramAssetFile(filename: string): boolean; /** @format */ type LazyElementFn = (node: ElementNode, context: { isMiniProgramComponent(name: string): 'plugin' | 'component' | 'dynamicLib' | undefined; }) => { [name: string]: { name: 'on' | 'bind'; arg: string[]; }[] | true; } | boolean; interface MiniProgramCompilerOptions { /** * 需要延迟渲染的组件,通常是某个组件的某个事件会立刻触发,需要延迟到首次 render 之后,比如微信 editor 的 ready 事件,快手 switch 的 change */ lazyElement?: { [name: string]: { name: 'on' | 'bind'; arg: string[]; }[] | true; } | LazyElementFn; event?: { key?: boolean; format?(name: string, opts: { isCatch?: boolean; isCapture?: boolean; isComponent?: boolean; }): string; }; class: { /** * 是否支持绑定 array 类型 */ array: boolean; }; slot: { /** * 是否支持 $slots.default 访问 */ $slots?: boolean; /** * 是否支持后备内容 */ fallbackContent?: boolean; /** * 是否支持动态插槽名 */ dynamicSlotNames?: boolean; }; filter?: { lang: string; }; component?: { /** * 平台自定义组件目录,如 wxcomponents */ dir?: string; /** * 自定义组件自定义 hidden 属性用于实现 v-show */ vShow?: string; /** * 父组件 setData 后,子组件的 properties 是否可以同步获取,目前仅 mp-weixin,mp-qq,mp-alipay 支持 */ getPropertySync?: boolean; /** * 格式化组件名称,比如 wx-btn => weixin-btn (微信不允许以 wx 命名自定义组件) */ normalizeName?: (name: string) => string; /** * 合并虚拟化节点属性(class、style) */ mergeVirtualHostAttributes?: boolean; }; directive: string; emitFile?: (emittedFile: EmittedAsset) => string; } interface MiniProgramFilterOptions { id: string; type: string; name: string; src?: string; code: string; } type GenFilterFn = (filter: MiniProgramFilterOptions, filename: string) => string | void; declare function findMiniProgramTemplateFiles(genFilter?: GenFilterFn): Record; declare function clearMiniProgramTemplateFiles(): void; declare function addMiniProgramTemplateFile(filename: string, code: string): void; declare function clearMiniProgramTemplateFilter(filename: string): void; declare function addMiniProgramTemplateFilter(filename: string, filter: MiniProgramFilterOptions): void; /** @format */ declare const COMPONENT_ON_LINK = "onVI"; declare const COMPONENT_BIND_LINK = "__l"; declare const COMPONENT_CUSTOM_HIDDEN = "data-c-h"; declare const COMPONENT_CUSTOM_HIDDEN_BIND: string; declare const MP_PLUGIN_JSON_NAME = "plugin.json"; /** @format */ declare const HTML_TO_MINI_PROGRAM_TAGS: Record; /** @format */ type FileTransform = (source: Buffer, filename: string) => void | string; interface FileWatcherOptions { src: string | string[]; dest: string; transform?: FileTransform; verbose?: boolean; } /** @format */ type QinViteCopyPluginTarget = Omit & { watchOptions?: WatchOptions; }; interface QinViteCopyPluginOptions { targets: QinViteCopyPluginTarget[]; verbose: boolean; } declare function qinViteCopyPlugin({ targets, verbose, }: QinViteCopyPluginOptions): Plugin; /** @format */ declare const copyMiniProgramPluginJson: QinViteCopyPluginTarget; declare const copyMiniProgramThemeJson: () => QinViteCopyPluginTarget[]; /** @format */ type BindingComponents = Record; interface MainDescriptor { imports: ImportDeclaration[]; script: string; template: string; } declare function parseMainDescriptor(filename: string, ast: Program, resolve: ParseDescriptor['resolve']): Promise; declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void; declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void; declare function updateMiniProgramGlobalComponents(filename: string, ast: Program, { inputDir, resolve, normalizeComponentName, }: { inputDir: string; resolve: ParseDescriptor['resolve']; normalizeComponentName: (name: string) => string; }): Promise<{ imports: ImportDeclaration[]; }>; declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void; interface TemplateDescriptor { bindingComponents: BindingComponents; imports: ImportDeclaration[]; } /** * 解析 template * @param filename * @param code * @param ast * @param options * @returns */ declare function parseTemplateDescriptor(filename: string, ast: Program, options: ParseDescriptor): Promise; interface ParseDescriptor { resolve: PluginContext['resolve']; isExternal: boolean; } interface ScriptDescriptor extends TemplateDescriptor { setupBindingComponents: BindingComponents; } /** * 解析 script * @param filename * @param code * @param ast * @param options * @returns */ declare function parseScriptDescriptor(filename: string, ast: Program, options: ParseDescriptor): Promise; /** * static import => dynamic import * @param code * @param imports * @param dynamicImport * @returns */ declare function transformDynamicImports(code: string, imports: ImportDeclaration[], { id, sourceMap, dynamicImport, }: { id?: string; sourceMap?: boolean; dynamicImport: (name: string, source: string) => string; }): Promise<{ code: string; map: null; }>; /** @format */ declare function hasExternalClasses(code: string): boolean; declare function findMiniProgramComponentExternalClasses(filename: string): string[] | undefined; declare function updateMiniProgramComponentExternalClasses(filename: string, classes: string[]): void; declare function parseExternalClasses(ast: Program): string[]; /** @format */ declare function encodeBase64Url(str: string): string; declare function decodeBase64Url(str: string): string; /** @format */ declare function initDefine(stringifyBoolean?: boolean): { 'process.env.NODE_ENV': string; 'process.env.QIN_DEBUG': string | boolean; 'process.env.QIN_APP_ID': string; 'process.env.QIN_APP_NAME': string; 'process.env.QIN_APP_VERSION_NAME': string; 'process.env.QIN_APP_VERSION_CODE': string; 'process.env.QIN_PLATFORM': string; 'process.env.QIN_MIN_PLUGIN': string; 'process.env.QIN_SUBPACKAGE': string; 'process.env.QIN_COMPILER_VERSION': string; 'process.env.QIN_AUTOMATOR_WS_ENDPOINT': string; 'process.env.QIN_CLOUD_PROVIDER': string; 'process.env.QINCLOUD_DEBUG': string; 'process.env.VUE_APP_DARK_MODE': string; 'process.env.QIN_ROUTER_JSON': string; }; /** @format */ declare function initH5Provide(): { __f__: string[]; }; /** @format */ declare const onIsDebug: () => boolean; /** @format */ declare function initModuleAlias(): void; /** @format */ declare const stripOptions: { include: string[]; functions: string[]; }; /** @format */ declare function transformRef(node: RootNode | TemplateChildNode, context: TransformContext): void; /** @format */ declare const transformPageHead: NodeTransform; /** @format */ declare function createTransformComponentLink(name: typeof COMPONENT_BIND_LINK | typeof COMPONENT_ON_LINK, type?: 6 | 7): (node: RootNode | TemplateChildNode, context: TransformContext) => void; /** @format */ declare function createTransformEvent(options: Record string)>): NodeTransform; /** @format */ declare function createTransformTag(opts: Record): NodeTransform; /** @format */ interface AssetURLTagConfig { [name: string]: string[]; } interface AssetURLOptions { /** * If base is provided, instead of transforming relative asset urls into * imports, they will be directly rewritten to absolute urls. */ base?: string | null; /** * If true, also processes absolute urls. */ includeAbsolute?: boolean; tags?: AssetURLTagConfig; } declare const createAssetUrlTransformWithOptions: (options: Required) => NodeTransform; /** @format */ declare const createSrcsetTransformWithOptions: (options: Required) => NodeTransform; declare function defaultMatch$1(name: string, node: ElementNode, context: TransformContext): boolean; interface CreateTransformOnOptions { match: typeof defaultMatch$1; } /** * 百度、快手小程序的自定义组件,不支持动态事件绑定,故转换为静态事件 + dataset * @param baseTransformOn * @returns */ declare function createTransformOn(baseTransformOn: DirectiveTransform, { match }?: CreateTransformOnOptions): DirectiveTransform; declare const ATTR_DATASET_EVENT_OPTS = "data-e-o"; declare const STRINGIFY_JSON: unique symbol; /** @format */ declare function defaultMatch(node: ElementNode, context: TransformContext): boolean; interface CreateTransformModelOptions { match: typeof defaultMatch; } /** * 百度、快手小程序的自定义组件,不支持动态事件绑定,故 v-model 也需要调整 * @param baseTransformModel * @returns */ declare function createTransformModel(baseTransformModel: DirectiveTransform, { match }?: CreateTransformModelOptions): DirectiveTransform; declare const transformH5BuiltInComponents: _vue_compiler_core.NodeTransform; declare const transformMatchMedia: _vue_compiler_core.NodeTransform; declare const transformTapToClick: _vue_compiler_core.NodeTransform; declare const transformComponentLink: (node: _vue_compiler_core.RootNode | _vue_compiler_core.TemplateChildNode, context: _vue_compiler_core.TransformContext) => void; declare const VUE_REF = "r"; declare const VUE_REF_IN_FOR = "r-i-f"; declare function isVueSfcFile(id: string): boolean; declare function isUserComponent(node: RootNode | TemplateChildNode, context: { isBuiltInComponent: TransformContext['isBuiltInComponent']; }): node is ComponentNode; declare function createAttributeNode(name: string, content: string): AttributeNode; declare function addStaticClass(node: ElementNode, clazz: string): string | number | undefined; declare function createDirectiveNode(name: string, arg: string, exp?: string | ExpressionNode): DirectiveNode; declare function createOnDirectiveNode(name: string, value: string): DirectiveNode; declare function createBindDirectiveNode(name: string, value: string | ExpressionNode): DirectiveNode; declare function createQinVueTransformAssetUrls(base: string): { base: string; includeAbsolute: boolean; tags: { audio: string[]; video: string[]; img: string[]; image: string[]; 'cover-image': string[]; 'v-qin-audio': string[]; 'v-qin-video': string[]; 'v-qin-image': string[]; 'v-qin-cover-image': string[]; 'u-image': string[]; 'u-video': string[]; }; }; declare function getBaseNodeTransforms(base: string): _vue_compiler_core.NodeTransform[]; declare function renameProp(name: string, prop?: DirectiveNode | AttributeNode): void; declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation; declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position; declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position; /** @format */ declare function parseVueCode(code: string, isNVue?: boolean): { code: string; files?: undefined; errors?: undefined; } | { code: string; files: string[]; errors: SyntaxError[]; }; declare function parseBlockCode(ast: RootNode, code: string): string; declare function parseWxsNodes(ast: RootNode): ElementNode[]; declare function parseWxsCode(wxsNodes: ElementNode[], code: string): string; /** @format */ declare function transformQinH5Jsx({ types }: typeof BabelCore): PluginObj; /** @format */ declare function isExternalUrl(url: string): boolean; /** @format */ declare function formatErrMsg(msg: string, options?: LogErrorOptions): string; declare function formatInfoMsg(msg: string, options?: LogOptions & { nvue?: boolean; }): string; declare function formatWarnMsg(msg: string, options?: LogOptions): string; /** @format */ declare function initI18nOptions(platform: QinApp.PLATFORM, inputDir: string, warning?: boolean, withMessages?: boolean): { locale: string; locales: Record>; delimiters: [string, string]; } | undefined; declare const initI18nOptionsOnce: typeof initI18nOptions; declare function isQinAppLocaleFile(filepath: string): boolean; declare function getLocaleFiles(cwd: string): string[]; declare function initLocales(dir: string, withMessages?: boolean): Record>; declare function resolveI18nLocale(platform: QinApp.PLATFORM, locales: string[], locale?: string): string; /** @format */ declare const API_DEPS_CSS: { showModal: string[]; showToast: string[]; showActionSheet: string[]; previewImage: string[]; openLocation: string[]; chooseLocation: string[]; }; declare const COMPONENT_DEPS_CSS: { canvas: string[]; image: string[]; 'movable-area': string[]; 'picker-view': string[]; 'picker-view-column': string[]; 'rich-text': string[]; textarea: string[]; 'web-view': string[]; picker: string[]; }; /** @format */ interface ComponentJson { component: true; usingComponents?: UsingComponents; usingSwanComponents?: UsingComponents; styleIsolation?: 'apply-shared' | 'shared'; } interface ShareWindowOptions { navigationBarBackgroundColor?: string; navigationBarTextStyle?: 'white' | 'black'; navigationBarTitleText?: string; navigationStyle?: 'default' | 'custom'; backgroundColor?: string; backgroundTextStyle?: 'dark' | 'light'; backgroundColorTop?: string; backgroundColorBottom?: string; enablePullDownRefresh?: boolean; onReachBottomDistance?: number; pageOrientation?: 'portrait' | 'landscape' | 'auto'; } type Style = 'v2' | string; type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string; interface PageWindowOptions extends ShareWindowOptions { component?: true; disableScroll?: boolean; usingComponents?: UsingComponents; usingSwanComponents?: UsingComponents; initialRenderingCache?: 'static' | string; style?: Style; singlePage?: SinglePage; restartStrategy?: RestartStrategy; } interface AppWindowOptions extends ShareWindowOptions { visualEffectInBackground?: 'none' | 'hidden'; } interface SubPackage { name?: string; root: string; pages: string[]; independent?: boolean; } interface TabBarItem { pagePath: string; text: string; iconPath?: string; selectedIconPath?: string; } interface TabBar { color: string; selectedColor: string; backgroundColor: string; borderStyle?: 'black' | 'white'; list: TabBarItem[]; position?: 'bottom' | 'top'; custom?: boolean; } interface NetworkTimeout { request?: number; requeconnectSocketst?: number; uploadFile?: number; downloadFile?: number; } interface Plugins { [name: string]: { version: string; provider: string; }; } interface PreloadRule { [name: string]: { network: 'wifi' | 'all'; packages: string[]; }; } interface UsingComponents { [name: string]: string; } interface Permission { [name: string]: { desc: string; }; } interface UseExtendedLib { kbone: boolean; weui: boolean; } interface EntranceDeclare { locationMessage: { path: string; query: string; }; } interface SinglePage { navigationBarFit?: 'squeezed' | 'float'; } interface AppJson { entryPagePath?: string; pages: string[]; window?: AppWindowOptions; tabBar?: TabBar; networkTimeout?: NetworkTimeout; debug?: boolean; functionalPages?: boolean; subPackages?: SubPackage[]; workers?: string; requiredBackgroundModes?: string[]; plugins?: Plugins; preloadRule?: PreloadRule; resizable?: boolean; usingComponents?: UsingComponents; permission?: Permission; sitemapLocation?: string; style?: Style; useExtendedLib?: UseExtendedLib; entranceDeclare?: EntranceDeclare; darkmode?: boolean; themeLocation?: string; lazyCodeLoading?: 'requiredComponents' | string; singlePage?: SinglePage; restartStrategy?: RestartStrategy; [name: string]: unknown; } /** @format */ declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean; declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean; declare function hasJsonFile(filename: string): boolean; declare function getComponentJsonFilenames(): string[]; declare function findJsonFile(filename: string): Record | ComponentJson | PageWindowOptions | undefined; declare function findUsingComponents(filename: string): UsingComponents | undefined; declare function normalizeJsonFilename(filename: string): string; declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean): Map; declare function addMiniProgramAppJson(appJson: Record): void; declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void; declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void; declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void; declare function isMiniProgramUsingComponent(name: string, options: { filename: string; inputDir: string; componentsDir?: string; }): boolean; interface MiniProgramComponents { [name: string]: 'plugin' | 'component' | 'dynamicLib'; } declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: { filename: string; inputDir: string; componentsDir?: string; }): MiniProgramComponents; /** @format */ interface ParsePagesJsonOptions { debug?: boolean; darkmode?: boolean; subpackages: boolean; windowOptionsMap?: Record; tabBarOptionsMap?: Record; tabBarItemOptionsMap?: Record; networkTimeout?: NetworkTimeout; } declare function parseMiniProgramPagesJson(jsonStr: string, platform: QinApp.PLATFORM, options?: ParsePagesJsonOptions): { appJson: AppJson; pageJsons: Record; nvuePages: string[]; }; declare function mergeMiniProgramAppJson(appJson: Record, platformJson?: Record): void; /** @format */ interface ParseMiniProgramProjectJsonOptions { template: Record; pagesJson: QinApp.PagesJson; } interface ProjectConfig { appid: string; projectname: string; condition?: { miniprogram?: QinApp.PagesJson['condition']; }; } declare function parseMiniProgramProjectJson(jsonStr: string, platform: QinApp.PLATFORM, { template, pagesJson }: ParseMiniProgramProjectJsonOptions): ProjectConfig; /** @format */ declare function parseJson(jsonStr: string, shouldPre?: boolean): any; /** @format */ declare function isQinPageFile(file: string, inputDir?: string): boolean; declare function isQinPageSetupAndTs(file: string): boolean; declare function isQinPageSfcFile(file: string, inputDir?: string): boolean; /** * 小程序平台慎用,因为该解析不支持 subpackages * @param inputDir * @param platform * @param normalize * @returns */ declare const parsePagesJson: (inputDir: string, platform: QinApp.PLATFORM, normalize?: boolean) => QinApp.PagesJson; /** * 该方法解析出来的是不支持 subpackages,会被合并入 pages */ declare const parsePagesJsonOnce: (inputDir: string, platform: QinApp.PLATFORM, normalize?: boolean) => QinApp.PagesJson; declare const getPageRotersConfig: (inputDir: string, platform: QinApp.PLATFORM, normalize?: boolean) => any[]; /** * 目前 App 和 H5 使用了该方法 * @param jsonStr * @param platform * @param param2 * @returns */ declare function normalizePagesJson(jsonStr: string, platform: QinApp.PLATFORM, { subpackages, }?: { subpackages: boolean; }): QinApp.PagesJson; declare function validatePages(pagesJson: Record, jsonStr: string): void; declare function removePlatformStyle(pageStyle: Record): Record; declare function normalizePagesRoute(pagesJson: QinApp.PagesJson): QinApp.QinRoute[]; declare function parseSubpackagesRoot(inputDir: string, platform: QinApp.PLATFORM): string[]; declare const parseSubpackagesRootOnce: typeof parseSubpackagesRoot; /** @format */ declare const parseManifestJson: (inputDir: string) => any; declare const parseManifestJsonOnce: (inputDir: string) => any; declare const parseRpx2UnitOnce: (inputDir: string, platform?: QinApp.PLATFORM) => any; interface CompilerCompatConfig { MODE?: 2 | 3; } declare function parseCompatConfig(_inputDir: string): CompilerCompatConfig; declare const parseCompatConfigOnce: typeof parseCompatConfig; declare const defaultNetworkTimeout: { request: number; connectSocket: number; uploadFile: number; downloadFile: number; }; declare function normalizeNetworkTimeout(networkTimeout?: Partial): { request: number; connectSocket: number; uploadFile: number; downloadFile: number; }; declare function getQinStatistics(inputDir: string, platform: QinApp.PLATFORM): any; declare function isEnableQinPushV1(inputDir: string, platform: QinApp.PLATFORM): boolean; declare function isEnableQinPushV2(inputDir: string, platform: QinApp.PLATFORM): boolean; declare function isEnableSecureNetwork(inputDir: string, platform: QinApp.PLATFORM): boolean; declare function hasPushModule(inputDir: string): boolean; declare function isQinPushOffline(inputDir: string): boolean; declare function getRouterOptions(manifestJson: Record): { mode?: 'history' | 'hash'; base?: string; }; declare function isEnableTreeShaking(manifestJson: Record): boolean; declare function getDevServerOptions(manifestJson: Record): any; declare function getPlatformManifestJsonOnce(): any; /** @format */ declare function hasThemeJson(themeLocation: string): boolean; declare const parseThemeJson: (themeLocation?: string) => QinApp.ThemeJson; declare const normalizeThemeConfigOnce: (manifestJsonPlatform?: Record) => QinApp.ThemeJson; declare function initTheme(manifestJson: Record, pagesJson: T): T; declare const isProperty: (node: BaseNode) => node is Property; declare const isIdentifier: (node: BaseNode) => node is Identifier; declare const isAssignmentExpression: (node: BaseNode) => node is AssignmentExpression; declare const isCallExpression: (node: BaseNode) => node is CallExpression; declare const isMemberExpression: (node: BaseNode) => node is MemberExpression; declare const isMethodDefinition: (node: BaseNode) => node is MethodDefinition; declare const isExportSpecifier: (node: BaseNode) => node is ExportSpecifier; declare const isReference: (node: BaseNode, parent: BaseNode) => boolean; declare function createLiteral(value: string): Literal; declare function createIdentifier(name: string): Identifier; declare function createCallExpression(callee: unknown, args: unknown[]): CallExpression; declare function parseVue(code: string, errors: SyntaxError[]): _vue_compiler_core.RootNode; declare function isElementNode(node: Node): node is ElementNode; declare function isAttributeNode(node: Node): node is AttributeNode; declare function isDirectiveNode(node: Node): node is DirectiveNode; declare function isSimpleExpressionNode(node: Node): node is SimpleExpressionNode; declare function isCompoundExpressionNode(node: Node): node is CompoundExpressionNode; /** @format */ interface VueQuery { vue?: boolean; src?: boolean; type?: 'script' | 'template' | 'style' | 'custom'; index?: number; lang?: string; raw?: boolean; setup?: boolean; 'lang.ts'?: string; 'lang.js'?: string; } declare function parseVueRequest(id: string): { filename: string; query: VueQuery; }; declare const isImportRequest: (url: string) => boolean; /** * Prefix for resolved fs paths, since windows paths may not be valid as URLs. */ declare const FS_PREFIX = "/@fs/"; /** * Prefix for resolved Ids that are not valid browser import specifiers */ declare const VALID_ID_PREFIX = "/@id/"; declare const CLIENT_PUBLIC_PATH = "/@vite/client"; declare const ENV_PUBLIC_PATH = "/@vite/env"; declare const isInternalRequest: (url: string) => boolean; declare const queryRE: RegExp; declare const hashRE: RegExp; declare const cleanUrl: (url: string) => string; declare function isJsFile(id: string): boolean; /** @format */ type CreateQinViteFilterPlugin = (opts: QinViteFilterPluginOptions) => Plugin; interface QinViteFilterPluginOptions { resolvedConfig: ResolvedConfig; filter: (id: string) => boolean; } declare function injectAssetPlugin(config: ResolvedConfig, options?: { isAppX: boolean; }): void; declare function injectCssPlugin(config: ResolvedConfig): void; declare function injectCssPostPlugin(config: ResolvedConfig, newCssPostPlugin: Plugin): void; declare function replacePlugins(plugins: Plugin[], config: ResolvedConfig): void; declare function removePlugins(plugins: string | string[], config: ResolvedConfig): void; declare function insertBeforePlugin(plugin: Plugin, before: string, config: ResolvedConfig): void; /** @format */ declare function withSourcemap(config: ResolvedConfig): boolean; declare function isInHybridNVue(config: UserConfig | ResolvedConfig): boolean; declare function isSsr(command: ConfigEnv['command'], config: UserConfig | ResolvedConfig): boolean; /** @format */ declare const buildInCssSet: Set; declare function isCombineBuiltInCss(config: ResolvedConfig): boolean; /** @format */ declare function addScoped(code: string): string; interface QinCssScopedPluginOptions { filter: (id: string) => boolean; } declare function qinRemoveCssScopedPlugin({ filter }?: QinCssScopedPluginOptions): Plugin; declare function qinCssScopedPlugin({ filter }?: QinCssScopedPluginOptions): Plugin; /** @format */ type Injectment = string | [string, string]; interface InjectOptions { sourceMap?: boolean; callback?: (imports: Map, mod: [string, string]) => void; include?: FilterPattern; exclude?: FilterPattern; [str: string]: Injectment | FilterPattern | Boolean | Function | undefined; } declare function qinViteInjectPlugin(name: string, options: InjectOptions): Plugin; declare function defineQinMainJsPlugin(createQinMainJsPlugin: CreateQinViteFilterPlugin): vite.Plugin; declare const defineQinPagesJsonPlugin: (createVitePlugin: CreateQinViteFilterPlugin) => vite.Plugin; declare const defineQinManifestJsonPlugin: (createVitePlugin: CreateQinViteFilterPlugin) => vite.Plugin; declare const defineQinChangeRouterJsonPlugin: (createVitePlugin: CreateQinViteFilterPlugin) => vite.Plugin; /** @format */ interface ConsoleOptions { method: string; filename?: (filename: string) => string; include?: FilterPattern; exclude?: FilterPattern; } declare function qinConsolePlugin(options: ConsoleOptions): Plugin; /** @format */ declare function dynamicImportPolyfill(promise?: boolean): Plugin; /** @format */ /** * Also supports loading plain strings with import text from './foo.txt?raw' */ declare function assetPlugin(config: ResolvedConfig, options?: { isAppX: boolean; }): Plugin; declare function parseAssets(config: ResolvedConfig, code: string): string; declare function getAssetHash(content: Buffer | string): string; /** @format */ declare const cssLangRE: RegExp; declare const commonjsProxyRE: RegExp; declare const isCSSRequest: (request: string) => boolean; /** * Plugin applied before user plugins */ declare function cssPlugin(config: ResolvedConfig): Plugin; /** * Plugin applied after user plugins */ declare function cssPostPlugin(config: ResolvedConfig, { platform, isJsCode, chunkCssFilename, chunkCssCode, includeComponentCss, }: { platform: QinApp.PLATFORM; isJsCode?: boolean; chunkCssFilename: (id: string) => string | void; chunkCssCode: (filename: string, cssCode: string) => Promise | string; includeComponentCss?: boolean; }): Plugin; declare function minifyCSS(css: string, config: ResolvedConfig): Promise; /** * https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts * * @format */ declare function locToStartAndEnd(source: string, loc: { start: { line: number; column: number; }; end: { line: number; column: number; }; }): { start: number; end: number; }; declare function generateCodeFrame(source: string, start?: number | { line: number; column: number; }, end?: number): string; /** @format */ type FEATURE_DEFINES = ReturnType; interface InitFeaturesOptions { pagesJson: QinApp.PagesJson; manifestJson: any; inputDir: string; platform: QinApp.PLATFORM; command: ConfigEnv['command']; ssr: boolean; } declare function initFeatures(options: InitFeaturesOptions): { __VUE_OPTIONS_API__: boolean; __VUE_PROD_DEVTOOLS__: boolean; __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: boolean; __QIN_FEATURE_WX__: boolean; __QIN_FEATURE_WXS__: boolean; __QIN_FEATURE_RPX__: boolean; __QIN_FEATURE_PROMISE__: boolean; __QIN_FEATURE_LONGPRESS__: boolean; __QIN_FEATURE_I18N_EN__: boolean; __QIN_FEATURE_I18N_ES__: boolean; __QIN_FEATURE_I18N_FR__: boolean; __QIN_FEATURE_I18N_ZH_HANS__: boolean; __QIN_FEATURE_I18N_ZH_HANT__: boolean; __QIN_FEATURE_I18N_LOCALE__: boolean; __QIN_FEATURE_NVUE__: boolean; __QIN_FEATURE_ROUTER_MODE__: "\"hash\"" | "\"history\""; __QIN_FEATURE_PAGES__: boolean; __QIN_FEATURE_TABBAR__: boolean; __QIN_FEATURE_TABBAR_MIDBUTTON__: boolean; __QIN_FEATURE_TOPWINDOW__: boolean; __QIN_FEATURE_LEFTWINDOW__: boolean; __QIN_FEATURE_RIGHTWINDOW__: boolean; __QIN_FEATURE_RESPONSIVE__: boolean; __QIN_FEATURE_NAVIGATIONBAR__: boolean; __QIN_FEATURE_PULL_DOWN_REFRESH__: boolean; __QIN_FEATURE_NAVIGATIONBAR_BUTTONS__: boolean; __QIN_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: boolean; __QIN_FEATURE_NAVIGATIONBAR_TRANSPARENT__: boolean; }; /** @format */ declare const cssTarget = "chrome53"; interface CopyOptions { /** * 静态资源,配置的目录,在 uni_modules 中同样支持 */ assets?: string[]; targets?: QinViteCopyPluginOptions['targets']; } interface QinVitePluginQinOptions { compiler?: TemplateCompiler; styleOptions?: Pick; compilerOptions?: { miniProgram?: { emitFile?: (emittedFile: EmittedAsset) => string; }; isNativeTag?: ParserOptions['isNativeTag']; isCustomElement?: ParserOptions['isCustomElement']; directiveTransforms?: CompilerOptions['directiveTransforms']; nodeTransforms?: CompilerOptions['nodeTransforms']; }; jsxOptions?: { babelPlugins?: any[]; }; copyOptions?: CopyOptions | (() => CopyOptions); } interface QinVitePlugin extends Plugin { qin?: QinVitePluginQinOptions; } declare const isWindows: boolean; declare function normalizePath(id: string): string; declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode; declare function normalizeIdentifier(str: string): Capitalize; declare function normalizePagePath(pagePath: string): string | undefined; declare function removeExt(str: string): string; declare function normalizeNodeModules(str: string): string; declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string; declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (_babel_parser.ParserPluginWithOptions | ("asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "jsx" | "logicalAssignment" | "importAssertions" | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "sourcePhaseImports" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "optionalChainingAssign" | "pipelineOperator" | "recordAndTuple" | "typescript"))[]; declare function pathToGlob(pathString: string, glob: string, options?: { windows?: boolean; escape?: boolean; }): string; declare function resolveSourceMapPath(outputDir?: string, platform?: QinApp.PLATFORM): string; declare function installDepTips(type: 'dependencies' | 'devDependencies', module: string, version?: string): string; declare function getCoreJsonLocalConfigName(name: 'pages' | 'manifest', platform?: QinApp.PLATFORM | string): string; declare function getJsonConfigName(theJsonName: 'pages' | 'manifest'): string; declare function getJsonTransformJsName(name: string, suffix?: string): string; /** @format */ interface EasycomOption { dirs?: string[]; rootDir: string; extensions: string[]; autoscan?: boolean; custom?: EasycomCustom; } interface EasycomMatcher { name: string; pattern: RegExp; replacement: string; } interface EasycomCustom { [key: string]: string; } declare function initEasycoms(inputDir: string, { dirs, platform, isX, }: { dirs: string[]; platform: QinApp.PLATFORM; isX?: boolean; }): { options: EasycomOption; filter: (id: unknown) => boolean; refresh(): void; easycoms: EasycomMatcher[]; }; declare const initEasycomsOnce: typeof initEasycoms; declare function matchEasycom(tag: string): string | false | undefined; declare function addImportDeclaration(importDeclarations: string[], local: string, source: string, imported?: string): string; declare function genResolveEasycomCode(importDeclarations: string[], code: string, name: string): string; declare const QIN_EASYCOM_EXCLUDE: RegExp[]; /** @format */ declare const PUBLIC_DIR = "static"; declare const EXTNAME_JS: string[]; declare const EXTNAME_TS: string[]; declare const EXTNAME_VUE: string[]; declare const EXTNAME_VUE_TEMPLATE: string[]; declare const EXTNAME_VUE_RE: RegExp; declare const EXTNAME_JS_RE: RegExp; declare const EXTNAME_TS_RE: RegExp; declare const extensions: string[]; declare const PAGES_JSON_UTS = "pages-json-uts"; declare const MANIFEST_JSON_UTS = "manifest-json-uts"; declare const ASSETS_INLINE_LIMIT: number; declare const APP_SERVICE_FILENAME = "app-service.js"; declare const APP_CONFIG = "app-config.js"; declare const APP_CONFIG_SERVICE = "app-config-service.js"; declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__"; declare const PAGE_EXTNAME: string[]; declare const H5_API_STYLE_PATH = "@fe6/qinjs-platform-h5/style/api/"; declare const H5_FRAMEWORK_STYLE_PATH = "@fe6/qinjs-platform-h5/style/framework/"; declare const H5_COMPONENTS_STYLE_PATH = "@fe6/qinjs-platform-h5/style/"; declare const BASE_COMPONENTS_STYLE_PATH = "@fe6/qinjs-platform-h5/comps-style/"; declare const COMMON_EXCLUDE: RegExp[]; declare const KNOWN_ASSET_TYPES: string[]; declare const DEFAULT_ASSETS_RE: RegExp; declare const TEXT_STYLE: string[]; declare function initPreContext(platform: QinApp.PLATFORM, userPreContext?: Record | string, viteJsonConfig?: any): void; /** @format */ declare function qinViteConfig(): any; declare function preJs(jsCode: string): any; declare function preHtml(htmlCode: string): any; declare const preCss: typeof preJs; declare const preJson: typeof preJs; declare function preNVueJs(jsCode: string): any; declare function preNVueHtml(htmlCode: string): any; declare const preNVueCss: typeof preNVueJs; declare const preNVueJson: typeof preNVueJs; declare function preUVueJs(jsCode: string): any; declare function preUVueHtml(htmlCode: string): any; declare const preUVueCss: typeof preUVueJs; declare const preUVueJson: typeof preUVueJs; /** @format */ declare const scopedPlugin: PluginCreator; /** @format */ interface QinAppCssProcessorOptions { unit?: string; unitRatio?: number; unitPrecision?: number; } declare const qinapp: { (opts?: QinAppCssProcessorOptions): Plugin$1; postcss: boolean; }; /** @format */ declare function initPostcssPlugin({ qinApp, autoprefixer, }?: { qinApp?: QinAppCssProcessorOptions; autoprefixer?: Options | false; }): Plugin$1[]; /** @format */ declare function isWxs(id: string): boolean; declare function isSjs(id: string): boolean; declare function isRenderjs(id: string): boolean; type FilterType = 'wxs' | 'renderjs' | 'sjs'; declare function parseRenderjs(id: string): { type: FilterType; name: string; filename: string; } | { readonly type: ""; readonly name: ""; readonly filename: ""; }; declare function missingModuleName(type: FilterType, code: string): string; declare function parseFilterNames(lang: string, code: string): string[]; declare function transformWithEsbuild(code: string, filename: string, options: BuildOptions): Promise<_esbuild.BuildResult>; declare function esbuild(options: BuildOptions): Promise<_esbuild.BuildResult>; /** @format */ declare function tryRequire(id: string, from?: string): any; declare function requireResolve(filename: string, basedir: string): string; declare function relativeFile(from: string, to: string): string; declare const resolveMainPathOnce: (inputDir: string) => string; declare function getBuiltInPaths(): string[]; declare function resolveBuiltIn(thePath: string, theBaseUrl?: string): string; declare function resolveVueI18nRuntime(): string; /** @format */ declare function parseScripts(name: string, pkgPath: string): { name: string; platform: keyof QinApp.PagesJsonPagePlatformStyle; define: { [name: string]: string; }; context: { [name: string]: boolean; }; } | undefined; /** @format */ declare const MIN_PLATFORM: QinApp.MINPLATFORM[]; declare const H5_PLATFORMS: QinApp.PLATFORM[]; declare const PLATFORMS: QinApp.PLATFORM[]; declare function registerPlatform(platform: QinApp.PLATFORM): void; declare function getPlatforms(): (keyof QinApp.PagesJsonPagePlatformStyle)[]; declare function getPlatformDir(): keyof QinApp.PagesJsonPagePlatformStyle; declare function isMiniProgramPlatform(): boolean; /** @format */ type DefineOptions = { name?: string; app?: boolean | { js?: boolean; kotlin?: boolean; swift?: boolean; }; [key: string]: any; }; type Define = string | string[] | Record | false; type Defines = { [name: string]: Define; }; interface Exports { [name: string]: Define | Defines | false; } declare function parseQinExtApis(vite: boolean | undefined, platform: typeof process.env.QIN_UTS_PLATFORM, language?: any): Injects; type Injects = { [name: string]: string | [string, string] | [string, string, DefineOptions['app']] | false; }; /** * qin:'getBatteryInfo' * import getBatteryInfo from '..' * * qin:['getBatteryInfo'] * import { getBatteryInfo } from '..' * * qin:['openLocation','chooseLocation'] * import { openLocation, chooseLocation } from '..' * * qin:{ * onUserCaptureScreen: "onCaptureScreen" * offUserCaptureScreen: "offCaptureScreen" * } * * qin.getBatteryInfo = getBatteryInfo * @param source * @param globalObject * @param define * @returns */ declare function parseInjects(vite: boolean | undefined, platform: typeof process.env.QIN_UTS_PLATFORM, language: any, source: string, uniModuleRootDir: string, exports: Exports | undefined, theType: 'uni' | 'qin'): Injects; export { API_DEPS_CSS, APP_CONFIG, APP_CONFIG_SERVICE, APP_SERVICE_FILENAME, ASSETS_INLINE_LIMIT, ATTR_DATASET_EVENT_OPTS, type AppJson, BASE_COMPONENTS_STYLE_PATH, BINDING_COMPONENTS, CLIENT_PUBLIC_PATH, COMMON_EXCLUDE, COMPONENT_BIND_LINK, COMPONENT_CUSTOM_HIDDEN, COMPONENT_CUSTOM_HIDDEN_BIND, COMPONENT_DEPS_CSS, COMPONENT_ON_LINK, type ConsoleOptions, type CopyOptions, type CreateQinViteFilterPlugin, DEFAULT_ASSETS_RE, ENV_PUBLIC_PATH, EXTNAME_JS, EXTNAME_JS_RE, EXTNAME_TS, EXTNAME_TS_RE, EXTNAME_VUE, EXTNAME_VUE_RE, EXTNAME_VUE_TEMPLATE, type EasycomMatcher, type FEATURE_DEFINES, FS_PREFIX, H5_API_STYLE_PATH, H5_COMPONENTS_STYLE_PATH, H5_FRAMEWORK_STYLE_PATH, H5_PLATFORMS, HTML_TO_MINI_PROGRAM_TAGS, type InjectOptions, KNOWN_ASSET_TYPES, MANIFEST_JSON_UTS, MIN_PLATFORM, MP_PLUGIN_JSON_NAME, type MiniProgramCompilerOptions, type MiniProgramFilterOptions, PAGES_JSON_UTS, PAGE_EXTNAME, PLATFORMS, PUBLIC_DIR, type PageWindowOptions, QIN_EASYCOM_EXCLUDE, type QinViteCopyPluginOptions, type QinViteCopyPluginTarget, type QinViteFilterPluginOptions, type QinVitePlugin, STRINGIFY_JSON, TEXT_STYLE, VALID_ID_PREFIX, VUE_REF, VUE_REF_IN_FOR, type VueQuery, addImportDeclaration, addMiniProgramAppJson, addMiniProgramComponentJson, addMiniProgramPageJson, addMiniProgramTemplateFile, addMiniProgramTemplateFilter, addMiniProgramUsingComponents, addScoped, addStaticClass, advancePositionWithClone, advancePositionWithMutation, assetPlugin, buildInCssSet, checkElementNodeTag, cleanUrl, clearMiniProgramTemplateFiles, clearMiniProgramTemplateFilter, commonjsProxyRE, copyMiniProgramPluginJson, copyMiniProgramThemeJson, createAssetUrlTransformWithOptions, createAttributeNode, createBindDirectiveNode, createCallExpression, createDirectiveNode, createIdentifier, createLiteral, createOnDirectiveNode, createQinVueTransformAssetUrls, createSrcsetTransformWithOptions, createTransformComponentLink, createTransformEvent, createTransformModel, createTransformOn, createTransformTag, cssLangRE, cssPlugin, cssPostPlugin, cssTarget, decodeBase64Url, defineQinChangeRouterJsonPlugin, defineQinMainJsPlugin, defineQinManifestJsonPlugin, defineQinPagesJsonPlugin, dynamicImportPolyfill, emptyDir, encodeBase64Url, esbuild, extensions, findChangedJsonFiles, findJsonFile, findMiniProgramComponentExternalClasses, findMiniProgramTemplateFiles, findMiniProgramUsingComponents, findUsingComponents, formatErrMsg, formatInfoMsg, formatMiniProgramEvent, formatWarnMsg, genResolveEasycomCode, genWxsCallMethodsCode, generateCodeFrame, getAssetHash, getBaseNodeTransforms, getBuiltInPaths, getComponentJsonFilenames, getCoreJsonLocalConfigName, getDevServerOptions, getInnerRange, getJsonConfigName, getJsonTransformJsName, getLocaleFiles, getPageRotersConfig, getPlatformDir, getPlatformManifestJsonOnce, getPlatforms, getQinStatistics, getRouterOptions, hasExternalClasses, hasJsonFile, hasPushModule, hasThemeJson, hashRE, initDefine, initEasycoms, initEasycomsOnce, initFeatures, initH5Provide, initI18nOptions, initI18nOptionsOnce, initLocales, initModuleAlias, initPostcssPlugin, initPreContext, initTheme, injectAssetPlugin, injectCssPlugin, injectCssPostPlugin, insertBeforePlugin, installDepTips, isAssignmentExpression, isAttributeNode, isCSSRequest, isCallExpression, isCombineBuiltInCss, isCompoundExpressionNode, isDirectiveNode, isElementNode, isEnableQinPushV1, isEnableQinPushV2, isEnableSecureNetwork, isEnableTreeShaking, isExportSpecifier, isExternalUrl, isIdentifier, isImportRequest, isInHybridNVue, isInternalRequest, isJsFile, isMemberExpression, isMethodDefinition, isMiniProgramAssetFile, isMiniProgramPageFile, isMiniProgramPageSfcFile, isMiniProgramPlatform, isMiniProgramUsingComponent, isProperty, isQinAppLocaleFile, isQinPageFile, isQinPageSetupAndTs, isQinPageSfcFile, isQinPushOffline, isReference, isRenderjs, isSimpleExpressionNode, isSjs, isSsr, isUserComponent, isVueSfcFile, isWindows, isWxs, locToStartAndEnd, matchEasycom, defaultMatch as matchTransformModel, defaultMatch$1 as matchTransformOn, mergeMiniProgramAppJson, minifyCSS, missingModuleName, normalizeIdentifier, normalizeJsonFilename, normalizeMiniProgramFilename, normalizeNetworkTimeout, normalizeNodeModules, normalizePagePath, normalizePagesJson, normalizePagesRoute, normalizeParsePlugins, normalizePath, normalizeThemeConfigOnce, onIsDebug, parseAssets, parseBlockCode, parseCompatConfigOnce, parseExternalClasses, parseFilterNames, parseInjects, parseJson, parseMainDescriptor, parseManifestJson, parseManifestJsonOnce, parseMiniProgramPagesJson, parseMiniProgramProjectJson, parsePagesJson, parsePagesJsonOnce, parseProgram, parseQinExtApis, parseRenderjs, parseRpx2UnitOnce, parseScriptDescriptor, parseScripts, parseSubpackagesRootOnce, parseTemplateDescriptor, parseThemeJson, parseVue, parseVueCode, parseVueRequest, parseWxsCallMethods, parseWxsCode, parseWxsNodes, pathToGlob, preCss, preHtml, preJs, preJson, preNVueCss, preNVueHtml, preNVueJs, preNVueJson, preUVueCss, preUVueHtml, preUVueJs, preUVueJson, qinConsolePlugin, qinCssScopedPlugin, qinapp as qinPostcssPlugin, scopedPlugin as qinPostcssScopedPlugin, qinRemoveCssScopedPlugin, qinViteConfig, qinViteCopyPlugin, qinViteInjectPlugin, queryRE, registerPlatform, relativeFile, removeExt, removePlatformStyle, removePlugins, renameProp, replacePlugins, requireResolve, resolveBuiltIn, resolveI18nLocale, resolveMainPathOnce, resolveSourceMapPath, resolveVueI18nRuntime, stripOptions, transformComponentLink, transformDynamicImports, transformH5BuiltInComponents, transformMatchMedia, transformPageHead, transformQinH5Jsx, transformRef, transformScopedCss, transformTapToClick, transformWithEsbuild, tryRequire, updateMiniProgramComponentExternalClasses, updateMiniProgramComponentsByMainFilename, updateMiniProgramComponentsByScriptFilename, updateMiniProgramComponentsByTemplateFilename, updateMiniProgramGlobalComponents, validatePages, withSourcemap };