Files
ecom-dmb/browser-extension/src/features/pdd-ad-fee/index.ts
T

46 lines
1.1 KiB
TypeScript

/**
* 远程功能包入口(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.3.10';
export interface RemoteFeatureExport {
id: string;
version: string;
executionWorld: 'main';
mount: () => Promise<void>;
unmount: () => Promise<void>;
}
installMainWorldAdapters();
const feature: RemoteFeatureExport = {
id: FEATURE_ID,
version: FEATURE_VERSION,
executionWorld: 'main',
async mount() {
setFloatingVisible(true);
},
async unmount() {
setFloatingVisible(false);
},
};
declare global {
interface Window {
__ECBI_FEATURES__?: Record<string, RemoteFeatureExport>;
}
}
const g = globalThis as typeof globalThis & {
__ECBI_FEATURES__?: Record<string, RemoteFeatureExport>;
};
g.__ECBI_FEATURES__ = g.__ECBI_FEATURES__ ?? {};
g.__ECBI_FEATURES__[FEATURE_ID] = feature;
export default feature;