feat: 浏览器扩展完全支持热更新

This commit is contained in:
2026-08-16 20:46:07 +08:00
parent 481518500e
commit 9568e7ac08
21 changed files with 558 additions and 94 deletions
@@ -1,20 +1,33 @@
/**
* 远程功能包入口(IIFE 构建)。
* 当前阶段导出元数据;真正 UI 仍由壳内 embedded 模块挂载。
* 后续可将 FloatingPanel 整包打入此入口并在 main world 执行。
* 远程功能包入口(IIFE → dist-features/pdd-ad-fee.js)。
* 在页面 MAIN world 执行;Open API / 设置走壳侧 postMessage 桥接。
*/
import { installMainWorldAdapters } from '@/features/runtime/mainWorldAdapters';
import { setFloatingVisible } from '@/content/floating/mount';
const FEATURE_ID = 'pdd-ad-fee';
const FEATURE_VERSION = '0.2.0';
export interface RemoteFeatureExport {
id: string;
version: string;
executionWorld: 'extension';
executionWorld: 'main';
mount: () => Promise<void>;
unmount: () => Promise<void>;
}
const meta: RemoteFeatureExport = {
installMainWorldAdapters();
const feature: RemoteFeatureExport = {
id: FEATURE_ID,
version: '0.1.0',
executionWorld: 'extension',
version: FEATURE_VERSION,
executionWorld: 'main',
async mount() {
setFloatingVisible(true);
},
async unmount() {
setFloatingVisible(false);
},
};
declare global {
@@ -27,6 +40,6 @@ const g = globalThis as typeof globalThis & {
__ECBI_FEATURES__?: Record<string, RemoteFeatureExport>;
};
g.__ECBI_FEATURES__ = g.__ECBI_FEATURES__ ?? {};
g.__ECBI_FEATURES__[FEATURE_ID] = meta;
g.__ECBI_FEATURES__[FEATURE_ID] = feature;
export default meta;
export default feature;