import get from "get-value"; import set from "set-value"; //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.d.mts type Input = Record; type IgnoredInput = boolean | number | null | any[] | Record | undefined; type Merger = (object: T, key: keyof T, value: T[K], namespace: string) => any; type nullish = null | undefined | void; type MergeObjects = Destination extends Defaults ? Destination : Omit & Omit & { -readonly [Key in keyof Destination & keyof Defaults]: Destination[Key] extends nullish ? Defaults[Key] extends nullish ? nullish : Defaults[Key] : Defaults[Key] extends nullish ? Destination[Key] : Merge; }; type Defu> = D extends [infer F, ...infer Rest] ? F extends Input ? Rest extends Array ? Defu, Rest> : MergeObjects : F extends IgnoredInput ? Rest extends Array ? Defu : S : S : S; type DefuFn = >(source: Source, ...defaults: Defaults) => Defu; interface DefuInstance { >(source: Source | IgnoredInput, ...defaults: Defaults): Defu; fn: DefuFn; arrayFn: DefuFn; extend(merger?: Merger): DefuFn; } type MergeArrays = Destination extends Array ? Source extends Array ? Array : Source | Array : Source | Destination; type Merge = Destination extends nullish ? Defaults extends nullish ? nullish : Defaults : Defaults extends nullish ? Destination : Destination extends Array ? Defaults extends Array ? MergeArrays : Destination | Defaults : Destination extends Function ? Destination | Defaults : Destination extends RegExp ? Destination | Defaults : Destination extends Promise ? Destination | Defaults : Defaults extends Function ? Destination | Defaults : Defaults extends RegExp ? Destination | Defaults : Defaults extends Promise ? Destination | Defaults : Destination extends Input ? Defaults extends Input ? MergeObjects : Destination | Defaults : Destination | Defaults; declare const defu: DefuInstance; //#endregion //#region src/layoutHostRegistry.d.ts interface MiniProgramLayoutHostWaitOptions { interval?: number; retries?: number; } type MiniProgramLayoutHostResolver = (bridge: TBridge, key: string) => THost | null | undefined; /** * @description 对 layout host key 去重并过滤空字符串。 */ declare function normalizeMiniProgramLayoutHostKeys(keys: string | string[]): string[]; /** * @description 创建小程序 layout host 注册表。 */ declare function createMiniProgramLayoutHostRegistry(): { register: (keys: string | string[], bridge: TBridge, pageKeys: string[]) => string[] | null; resolveBridge: (key: string, pageKeys: string[]) => TBridge | undefined; resolveHost: (key: string, pageKeys: string[], resolver: MiniProgramLayoutHostResolver) => NonNullable | null; unregister: (keys: string | string[], bridge: TBridge, pageKeys: string[]) => boolean; unregisterBridge: (bridge: TBridge) => boolean; waitForHost: (key: string, resolvePageKeys: () => string[], resolver: MiniProgramLayoutHostResolver, options?: MiniProgramLayoutHostWaitOptions) => Promise; }; //#endregion //#region src/platforms/types.d.ts type MpPlatform = 'weapp' | 'alipay' | 'tt' | 'swan' | 'jd' | 'xhs'; type MiniProgramTemplatePreset = 'wechat' | 'alipay' | 'tt' | 'swan'; type MiniProgramPlatformFamily = 'wechat' | 'alipay' | 'tt' | 'swan'; interface OutputExtensions { js: string; json: string; wxml: string; wxss: string; wxs?: string; } interface MiniProgramPageIdentityRule { /** * @description 注册 layout bridge 等页面级能力时使用的 key 前缀。 */ prefix: string; /** * @description 页面 key 的来源类型:字段或 route。 */ source: 'field' | 'route'; /** * @description 当来源类型为字段时使用的字段名。 */ field?: string; } interface MiniProgramRuntimeCapabilities { /** * @description 宿主是否支持全局 `getCurrentPages()` 页面栈读取。 */ globalPageStack: boolean; /** * @description 宿主是否支持从全局对象创建 `SelectorQuery`。 */ globalCreateSelectorQuery: boolean; /** * @description 全局 `createSelectorQuery()` 是否需要通过 `.in(instance)` 绑定作用域。 */ selectorQueryScopeByIn: boolean; /** * @description 宿主是否支持从全局对象创建 `IntersectionObserver`。 */ globalCreateIntersectionObserver: boolean; /** * @description 全局 `createIntersectionObserver()` 是否要求将实例作为首个参数传入。 */ intersectionObserverScopeByParameter: boolean; /** * @description 宿主是否支持页面分享菜单能力。 */ pageShareMenu: boolean; /** * @description 时间线分享是否要求同时展示 `shareAppMessage`。 */ shareTimelineRequiresShareAppMessage: boolean; /** * @description 宿主是否支持通过全局 `pageScrollTo` 做页面滚动桥接。 */ pageScrollApi: boolean; /** * @description 宿主是否支持通过全局 `startPullDownRefresh` 做下拉刷新桥接。 */ pullDownRefreshApi: boolean; /** * @description 宿主是否支持通过全局对象调用 `navigateTo` / `redirectTo` 等路由 API。 */ globalRouterApi: boolean; /** * @description 宿主是否支持 App 级 `onError/offError` 监听。 */ appErrorListener: boolean; /** * @description 宿主是否支持 App 级 `onPageNotFound/offPageNotFound` 监听。 */ appPageNotFoundListener: boolean; /** * @description 宿主是否支持 App 级 `onUnhandledRejection/offUnhandledRejection` 监听。 */ appUnhandledRejectionListener: boolean; /** * @description 宿主是否支持 App 级 `onThemeChange/offThemeChange` 监听。 */ appThemeChangeListener: boolean; /** * @description 宿主是否支持 App 级 `onMemoryWarning/offMemoryWarning` 监听。 */ appMemoryWarningListener: boolean; } type MiniProgramRuntimeCapabilityName = keyof MiniProgramRuntimeCapabilities; interface MiniProgramPlatformDescriptor { /** * @description 构建流程中使用的标准平台标识。 */ id: MpPlatform; /** * @description 用于日志/诊断/工具展示的可读名称。 */ displayName: string; /** * @description 平台所属语义族群,用于模板与 runtime 默认策略复用。 */ family: MiniProgramPlatformFamily; /** * @description 需要映射到该平台的别名列表。 */ aliases: readonly string[]; /** * @description 编译产物应输出的文件扩展名。 */ outputExtensions: OutputExtensions; /** * @description IDE 项目配置文件名。 */ projectConfigFileName: string; /** * @description 项目根目录候选字段,按优先级排序。 */ projectConfigRootKeys: readonly string[]; /** * @description 不同脚本模块扩展名对应的模板标签名。 */ scriptModuleTagByExtension?: Readonly>>; /** * @description 是否使用项目根目录作为 npm 产物目录基准。 */ usesProjectRootNpmDir?: boolean; /** * @description IDE 打开项目时的平台级默认行为。 */ ide?: { requiresOpenPlatformArg?: boolean; defaultProjectRoot?: string; }; /** * @description 构建流程相关的平台静态能力。 */ build?: { /** * @description 是否允许在自动模式下补齐 app 样式入口,以支持样式 HMR 等行为。 */ autoTouchAppStyle?: boolean; /** * @description 平台默认使用的构建目标。 */ defaultBuildTarget?: string; }; /** * @description 构建清理时需要保留的 npm 产物目录名。 */ resolvePreservedNpmDirNames: (options?: { alipayNpmMode?: string; }) => readonly string[]; /** * @description JSON 归一化相关的平台能力。 */ json?: { normalizeUsingComponents?: boolean; fillComponentGenericsDefault?: boolean; rewriteBundleNpmImports?: boolean; }; /** * @description npm 构建相关的平台能力。 */ npm?: { distDirName?: (options?: { alipayNpmMode?: string; }) => string; normalizeImportPath?: boolean; normalizeMiniprogramPackage?: boolean; copyEsModuleDirectory?: boolean; hoistNestedDependencies?: boolean; shouldRebuildCachedPackage?: boolean; }; /** * @description WXML / 模板转换相关的平台能力。 */ wxml?: { eventBindingStyle?: 'default' | 'alipay'; directivePrefix?: string; normalizeComponentTagName?: boolean; normalizeVueTemplate?: boolean; emitGenericPlaceholder?: boolean; }; /** * @description 模板编译器使用的策略预设。 */ compiler?: { templatePreset?: MiniProgramTemplatePreset; }; /** * @description TypeScript 支持相关的平台能力。 */ typescript?: { appTypesPackage?: string; }; /** * @description 小程序宿主 runtime 相关的静态能力描述。 */ runtime: { globalObjectKey: string; hostConfigKey: string; /** * @description 通用全局对象解析优先级,值越小越先尝试。 */ globalResolvePriority?: number; /** * @description 路由全局对象解析优先级,值越小越先尝试。 */ routeGlobalResolvePriority?: number; pageIdentityRules: readonly MiniProgramPageIdentityRule[]; capabilities: MiniProgramRuntimeCapabilities; }; } //#endregion //#region src/platforms/descriptors.d.ts /** * @description 全仓库统一的小程序平台描述表。 */ declare const MINI_PROGRAM_PLATFORM_DESCRIPTORS: readonly MiniProgramPlatformDescriptor[]; //#endregion //#region src/platforms/helpers.d.ts /** * @description 小程序平台别名映射表。 */ declare const MINI_PROGRAM_PLATFORM_ALIASES: Readonly>; /** * @description 标准化平台输入。 */ declare function normalizeMiniProgramPlatform(input?: string | null): string | undefined; /** * @description 解析平台输入到标准平台标识。 */ declare function resolveMiniProgramPlatform(input?: string | null): MpPlatform | undefined; /** * @description 返回所有受支持的小程序平台。 */ declare function getSupportedMiniProgramPlatforms(): readonly MpPlatform[]; /** * @description 返回所有受支持的小程序模板指令前缀。 */ declare function getSupportedMiniProgramDirectivePrefixes(): readonly string[]; /** * @description 返回默认小程序平台。 */ declare function getDefaultMiniProgramPlatform(): MpPlatform; /** * @description 获取平台描述。 */ declare function getMiniProgramPlatformDescriptor(platform: MpPlatform): MiniProgramPlatformDescriptor; /** * @description 获取模板编译预设。 */ declare function getMiniProgramTemplatePreset(platform?: MpPlatform): MiniProgramTemplatePreset; /** * @description 判断平台是否允许自动补齐 app 样式入口。 */ declare function supportsMiniProgramAutoTouchAppStyle(platform?: MpPlatform): boolean; /** * @description 获取平台默认构建目标。 */ declare function getMiniProgramDefaultBuildTarget(platform?: MpPlatform): string | undefined; /** * @description 获取平台默认使用的类型包。 */ declare function getMiniProgramAppTypesPackage(platform?: MpPlatform): string; /** * @description 获取平台模板指令前缀。 */ declare function getMiniProgramDirectivePrefix(platform?: MpPlatform): string; /** * @description 获取宿主全局对象 key。 */ declare function getMiniProgramRuntimeGlobalKey(platform: MpPlatform): string; /** * @description 获取默认宿主全局对象 key。 */ declare function getDefaultMiniProgramRuntimeGlobalKey(): string; /** * @description 解析宿主全局对象 key 对应的平台。 */ declare function getMiniProgramPlatformByRuntimeGlobalKey(globalObjectKey?: string | null): MpPlatform | undefined; /** * @description 返回 runtime 全局对象 key 的扫描优先级。 */ declare function getMiniProgramRuntimeGlobalKeys(platform?: MpPlatform): readonly string[]; /** * @description 返回按通用解析优先级排序的 runtime 全局对象 key。 */ declare function getMiniProgramRuntimeGlobalKeysByResolvePriority(platform?: MpPlatform): readonly string[]; /** * @description 返回按路由解析优先级排序的 runtime 全局对象 key。 */ declare function getMiniProgramRouteRuntimeGlobalKeys(platform?: MpPlatform): readonly string[]; /** * @description 获取平台 runtime 宿主配置 key。 */ declare function getMiniProgramRuntimeHostConfigKey(platform?: MpPlatform): string; /** * @description 获取平台 runtime 能力描述。 */ declare function getMiniProgramRuntimeCapabilities(platform?: MpPlatform): MiniProgramRuntimeCapabilities; /** * @description 判断平台是否支持指定 runtime 能力。 */ declare function supportsMiniProgramRuntimeCapability(platform: MpPlatform | undefined, capabilityName: MiniProgramRuntimeCapabilityName): boolean; /** * @description 根据平台描述解析页面身份 key。 */ declare function resolveMiniProgramPageKeys(page?: Record, platform?: MpPlatform): string[]; //#endregion //#region src/runtimeProviders.d.ts type RuntimeProviderBackend = 'miniprogram' | 'web'; type RuntimeProviderCompilation = 'native' | 'vue' | 'web'; type RuntimeProviderModuleKind = 'runtime' | 'reactivity' | 'template'; type RuntimeProviderVariant = 'development' | 'production'; type RuntimeProviderInjectionMode = 'none' | 'virtual-module'; type RuntimeProviderHmrMode = 'none' | 'host-reload' | 'module-accept'; /** * 运行时 provider 的开发与生产入口。 */ interface RuntimeProviderEntry { development: string; production: string; } /** * 运行时 provider 的声明式能力。 */ interface RuntimeProviderCapabilities { framework: boolean; hmr: boolean; nativeHost: boolean; webHost: boolean; } /** * 运行时 provider 的 HMR 契约。 */ interface RuntimeProviderHmrDescriptor { mode: RuntimeProviderHmrMode; acceptCode?: string; } /** * 跨包共享的运行时 provider 描述契约。 */ interface RuntimeProviderDescriptorContract { id: string; backend: RuntimeProviderBackend; compilation: RuntimeProviderCompilation; injection: RuntimeProviderInjectionMode; entries: Readonly>>; capabilities: Readonly; hmr: Readonly; contractVersion: number; } //#endregion //#region src/index.d.ts /** * @description 转义字符串中的正则特殊字符 */ declare function escapeStringRegexp(str: string): string; /** * @description 移除文件名的最后一个扩展名 */ declare function removeExtension(file: string): string; /** * @description 移除文件名的所有扩展名(多重后缀) */ declare function removeExtensionDeep(file: string): string; /** * @description 若缺少扩展名则追加(默认 .js) */ declare function addExtension(filename: string, ext?: string): string; /** * @description 将单个值转换为数组 */ declare function arrify(val: T | readonly T[]): T[]; /** * @description defu 合并策略:当目标/来源为数组时直接覆盖 */ declare const defuOverrideArray: DefuFn; /** * @description 判断是否为非 null 的对象 */ declare function isObject(x: unknown): x is Record; /** * @description 判断对象是否为空对象 */ declare function isEmptyObject(obj: unknown): boolean; //#endregion export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, MiniProgramLayoutHostResolver, MiniProgramLayoutHostWaitOptions, type MiniProgramPageIdentityRule, type MiniProgramPlatformDescriptor, type MiniProgramPlatformFamily, type MiniProgramRuntimeCapabilities, type MiniProgramRuntimeCapabilityName, type MiniProgramTemplatePreset, type MpPlatform, type OutputExtensions, RuntimeProviderBackend, RuntimeProviderCapabilities, RuntimeProviderCompilation, RuntimeProviderDescriptorContract, RuntimeProviderEntry, RuntimeProviderHmrDescriptor, RuntimeProviderHmrMode, RuntimeProviderInjectionMode, RuntimeProviderModuleKind, RuntimeProviderVariant, addExtension, arrify, createMiniProgramLayoutHostRegistry, defu, defuOverrideArray, escapeStringRegexp, get, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramPlatformDescriptor, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getMiniProgramTemplatePreset, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramLayoutHostKeys, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle, supportsMiniProgramRuntimeCapability };