@sublane/core 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/contract.ts +5 -0
- package/src/runtime.ts +17 -2
package/package.json
CHANGED
package/src/contract.ts
CHANGED
|
@@ -169,6 +169,11 @@ export interface DetachedHandle {
|
|
|
169
169
|
unmount(): void | Promise<void>
|
|
170
170
|
/** 替换数据源(如切换 Clip 区间);不重挂 DOM */
|
|
171
171
|
setSource(source: TrackSource): void
|
|
172
|
+
/** 0.3.1 可选(缺口3):订阅 detached 渲染器**有效轨**的只读事件流(回显语义——
|
|
173
|
+
* 事件 = 渲染器实际持有的规范化 cue 视图;订阅即 reset,onUpdate/setSource → upsert)。
|
|
174
|
+
* injected-only 下宿主本持有注入数据,此成员的契约价值 = 以统一词汇表观测渲染器
|
|
175
|
+
* 的有效视图(规范化后含推断区间),并为未来 hybrid 模式预留同一订阅面。 */
|
|
176
|
+
subscribeCues?(listener: (event: CueStreamEvent) => void): () => void
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
/** detached 会话上下文:与 live PluginMountContext 同形,但编排器已将 emitConfigPatch
|
package/src/runtime.ts
CHANGED
|
@@ -175,6 +175,12 @@ export function createVideoSubtitleFramework({ ctx, plugins, storage: storagePor
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
return {
|
|
178
|
+
/** 0.3.1(缺口1):宿主访问 live 实例的唯一受支持通道——F-26 subscribeCues 消费入口。
|
|
179
|
+
* 快照语义:返回调用时刻的装配集(start 前为空;applyConfig 每次重建,旧快照冻结)。
|
|
180
|
+
* integration.md 曾承诺"经框架回调拿到实例引用"而代码缺位——本访问器补齐该行为。 */
|
|
181
|
+
instances(): ReadonlyMap<string, VideoSubtitlePluginInstance> {
|
|
182
|
+
return new Map([...running].map(([id, run]) => [id, run.instance]))
|
|
183
|
+
},
|
|
178
184
|
async start(): Promise<void> {
|
|
179
185
|
ctx.onInvalidated(() => {
|
|
180
186
|
stopped = true
|
|
@@ -291,7 +297,10 @@ export async function createDetachedSession(opts: CreateDetachedSessionOptions):
|
|
|
291
297
|
}
|
|
292
298
|
}
|
|
293
299
|
|
|
294
|
-
// pass 2 车道分配(算法同 applyConfig:133-139)+
|
|
300
|
+
// pass 2 车道分配(算法同 applyConfig:133-139)+ 实例创建。
|
|
301
|
+
// F-29(0.3.2):逐家异常隔离——单家构造抛错 = 该家缺席 handles + 日志,会话不 reject,
|
|
302
|
+
// 他家照常(对齐 pass1 getTrack 失败与 R7「单家失败不连坐」);已挂实例归会话所有,
|
|
303
|
+
// dispose 正常清理(不因部分失败泄漏)。失败家的缺席不触发 lane 重排(Q3:重建会话重排)。
|
|
295
304
|
for (const [index, plugin] of admitted.entries()) {
|
|
296
305
|
const lane = { index, count: admitted.length }
|
|
297
306
|
const ctxForDetached: DetachedInstanceContext = {
|
|
@@ -299,7 +308,13 @@ export async function createDetachedSession(opts: CreateDetachedSessionOptions):
|
|
|
299
308
|
config: { enabled: true, lane, settings: frameworkConfig.suppliers[plugin.id]?.settings ?? {} },
|
|
300
309
|
emitConfigPatch: () => {}, // M1:中立化——detached 的 settings 权威在框架键,实例不得回写
|
|
301
310
|
}
|
|
302
|
-
|
|
311
|
+
let instance: VideoSubtitlePluginInstance & { detach(): DetachedHandle }
|
|
312
|
+
try {
|
|
313
|
+
instance = await plugin.createDetachedInstance(ctxForDetached, video, source, options)
|
|
314
|
+
} catch (error) {
|
|
315
|
+
log(`[${plugin.id}] detached 实例创建失败(缺席 handles,其余不受影响):${error instanceof Error ? error.message : error}`)
|
|
316
|
+
continue
|
|
317
|
+
}
|
|
303
318
|
await Promise.resolve(instance.mount()).catch((error: unknown) => log(`[${plugin.id}] detached mount 失败:${error instanceof Error ? error.message : error}`))
|
|
304
319
|
const handle = instance.detach()
|
|
305
320
|
records.push({ id: plugin.id, instance, handle, lane })
|