@tripo3d/lens / index / PluginContext
Interface: PluginContext
Defined in: src/core/plugin.ts:9
L2 Core 暴露给 Plugin 的最小内核上下文:只给必需的共享基建,不透传整包参数/平台对象/Core 实例
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
app | readonly | string | 已归一的 App 段(来自 init 的 app,缺省/非法回落 'tripo');各插件据此拼 event_format 的 App 段 | src/core/plugin.ts:11 |
bus | public | Pick<EventBus, "on" | "off"> | L2 EventBus:订阅核心/跨插件事件(如 user.identified)。只暴露 on/off,不暴露 emit | src/core/plugin.ts:14 |
config | readonly | RemoteTraceConfig | 已解析的远端配置快照:init 统一 await 一次(有界超时、三层降级、永非 null),setup 内同步读 | src/core/plugin.ts:17 |
deviceId | readonly | string | 已解析的 device id;init 后可用,SSR 下为空字符串 | src/core/plugin.ts:20 |
emit | public | (event) => Promise<void> | emit 一个 RawEvent,经 Pipeline 加工后入队;Plugin 不直接发请求。 resolve 时机随优先级:P0 送达成功才 resolve、失败 reject(保「成功后才去重/回调」语义); P1/P2 入队即 resolve;被 Pipeline 丢弃同样 resolve 且不发送。 | src/core/plugin.ts:27 |
entryUrl | readonly | URLSnapshot | null | 构造 Core 时快照的 entry URL;SSR 下为 null | src/core/plugin.ts:30 |
getIdentity | public | () => IdentitySnapshot | 读取身份快照(device 之外的 user_id / traits) | src/core/plugin.ts:33 |
ingestUrl | readonly | string | SDK 自身上报接口的完整 URL;ErrorPlugin api 采集器据此自排除,避免上报失败反馈环 | src/core/plugin.ts:35 |
provideCapability | public | <T>(name, value) => Disposable | 注册具名能力(L2 Capability),返回注销句柄供 teardown 摘除;同名重复注册抛错 | src/core/plugin.ts:38 |
reportError | public | (err, ctx) => void | 统一错误上报,转发到 init 的 onError | src/core/plugin.ts:40 |