bundle.js
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as v from 'valibot'
import { ScriptLine } from './script-line.js'
/**
* 场景引用:Bundle 内联引用一个场景(按 id 指向 assets 库的场景资源),
* 仅在 Bundle 内部使用,不单独作为公共 schema 出包。
* @typedef {{ id: string, background?: string, props?: string[] }} SceneRefT
*/
export const SceneRef = v.object({
id: v.string(),
background: v.optional(v.string()),
props: v.optional(v.array(v.string())),
})
/**
* Bundle 元信息:drama 级别的播放元数据。
* @typedef {{ locale: string, version: number, duration?: number }} BundleMetaT
*/
export const BundleMeta = v.object({
locale: v.string(),
version: v.number(),
duration: v.optional(v.number()),
})
/**
* 播放包:`<DramaPlayer :bundle>` 的入参、`@drama/core` 消费、`@drama/bundle` 出包。
* 组合 drama 元信息 + rig 引用 + 场景序列 + 剧本行序列。
* @typedef {{
* drama_id: string,
* title: string,
* rig_ref: string,
* scenes: SceneRefT[],
* lines: import('./script-line.js').ScriptLineT[],
* meta: BundleMetaT
* }} BundleT
*/
export const Bundle = v.object({
drama_id: v.string(),
title: v.string(),
rig_ref: v.string(),
scenes: v.array(SceneRef),
lines: v.array(ScriptLine),
meta: BundleMeta,
})