import { Plugin } from 'vite'; /** * @yunhai/vite-plugin-theme — 云海管理端远程主题接入插件。 * * 接入面收敛成一行:plugins: [vue(), yhTheme()]。插件负责四件事: * 1. transformIndexHtml: 内注入 yh-theme-init.js(在 env-config bootstrap 之后)+ 首帧兜底 inline style; * 刻意不静态注入 preload——构建期 URL 没有 ?v=,与 loader 运行时版本化 URL 永不匹配(缓存键含 query)。 * 2. virtual:yh-theme-loader:入口末位运行时 append ,保证远程 CSS 排在 viewuiplus.css 之后(dev/build 同构)。 * 3. transform:自动在入口末位 import 该虚拟模块,应用侧不用手改 main.ts。 * 4. /static dev proxy:本地联调不必装内网 DNS;环境变量 YH_THEME_PROXY_TARGET 可指向模拟通道。 */ interface YhThemeOptions { /** 产物档:pc 为第一波实现,app 占位 */ target?: "pc" | "app"; /** 静态通道前缀:'' 同源根相对(默认)| '/xxx' | 'http(s)://…'。禁止传 vite base(如 './') */ staticBase?: string; /** dev /static proxy 目标;环境变量 YH_THEME_PROXY_TARGET 优先 */ proxyTarget?: string; /** 入口匹配(相对路径正则),默认 src/main.(ts|js) */ entry?: RegExp; } declare const DEFAULT_PROXY_TARGET = "http://base.yunhaixingtong.com"; declare const VIRTUAL_ID = "virtual:yh-theme-loader"; declare const RESOLVED_VIRTUAL_ID = "\0virtual:yh-theme-loader"; declare const MANIFEST = "manifest.json"; declare const FALLBACK_STYLE = "html:not(.yh-theme-ready) body { opacity: 0; }\nhtml.yh-theme-ready body { opacity: 1; transition: opacity .15s; }"; /** staticBase 只接受根相对绝对前缀或完整 URL:vite base(Notice 是 './')会让 /static 解析成 /notice/front/static/… */ declare function isValidStaticBase(v: string): boolean; /** * loader 运行时实现 —— 基准为《第一波实施清单》§B3 代码块,语义一字不改。 * 复用 init 已启动的 manifest 预取;URL 与 init 的带版本 preload 一字不差;500ms 兜底;失败挂双类。 */ declare function loaderSource(staticBase: string): string; /** * init 用 document.write 挂:直接写