mirror of
https://github.com/motajs/template.git
synced 2026-11-30 02:34:30 +08:00
feat: 音频包接入 mediabunny 探测与 Opus 解码
This commit is contained in:
1 parent
24f7f8d558
commit
7bec42a304
16 files changed
+7421
-10
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,214 @@
|
||||
---
|
||||
phase: 09-minimum-browser-runnable
|
||||
plan: 61
|
||||
subsystem: audio
|
||||
tags: [audio, decode, opus, mediabunny, wasm-fallback, tracer]
|
||||
depends_on:
|
||||
requires: [09-60]
|
||||
provides: [probeAudioSource, OpusDecodeSession, IAudioDecodeProvider 实现]
|
||||
affects: [09-62, 09-63]
|
||||
tech-stack:
|
||||
added: [mediabunny@1.66.3]
|
||||
patterns: [原生命令优先加 WASM 兜底, 动态导入解码器]
|
||||
key-files:
|
||||
created:
|
||||
- packages/audio/src/probe.ts
|
||||
- packages/audio/src/opusSession.ts
|
||||
- packages/audio/src/__test__/opusDecodeSession.test.ts
|
||||
modified:
|
||||
- package.json
|
||||
- pnpm-lock.yaml
|
||||
- packages/audio/src/types.ts
|
||||
- packages/audio/src/context.ts
|
||||
decisions:
|
||||
- 探测与解码都用 mediabunny,原生 decodeAudioData 优先,失败才走 Opus 会话
|
||||
- opus-decoder 只动态加载并缓存,Node 用主线程解码器、浏览器用 WebWorker 变体
|
||||
metrics:
|
||||
duration: 约 1 小时 5 分钟(19:00 - 19:45)
|
||||
completed: 2026-11-24
|
||||
status: complete
|
||||
estimate:
|
||||
tokens: 34000
|
||||
tasks: 3
|
||||
confidence: low
|
||||
actuals:
|
||||
tokens: 4496
|
||||
tasks: 3
|
||||
commits: 0
|
||||
---
|
||||
|
||||
# Phase 9 Plan 61: mediabunny 探测 + 整文件 Ogg Opus 解码 tracer Summary
|
||||
|
||||
一句话:用 mediabunny 探测容器与编码,原生 `decodeAudioData` 优先、失败后对 Ogg/WebM Opus 走 `opus-decoder` 整文件解码,把 09-60 声明好的解码接口第一次跑通。
|
||||
|
||||
## 问题
|
||||
|
||||
09-60 只声明了 `IAudioDecodeProvider` / `IAudioDecodeSession` / `IAudioDecodedChunk` 等接口,没有任何实现。整文件音频解码此前只能依赖浏览器原生 `decodeAudioData`,浏览器(尤其 Safari)不支持 Ogg Opus 时 `VanillaDecoder` 直接失败,浏览器最小可运行版本卡在音频解码这一步。
|
||||
|
||||
## 文件清单
|
||||
|
||||
- `package.json`:根 `dependencies` 新增 1 行 `"mediabunny": "^1.66.3"`。
|
||||
- `pnpm-lock.yaml`:由 `pnpm` 生成,新增 `mediabunny` 的 importers 条目与包解析条目(共 23 行新增)。
|
||||
- `packages/audio/src/types.ts`:单 hunk,只改 `IMotaAudioContext` 的父接口行。
|
||||
- `packages/audio/src/context.ts`:新增 5 个私有方法与 `probeAudio` / `createDecodeSession` 两个公开方法,重写 `decodeAudio` / `decodeToAudioBuffer`。
|
||||
- `packages/audio/src/probe.ts`:新文件,mediabunny 探测。
|
||||
- `packages/audio/src/opusSession.ts`:新文件,整文件 Ogg/WebM Opus 解码会话。
|
||||
- `packages/audio/src/__test__/opusDecodeSession.test.ts`:新文件,Node 侧 tracer 测试(4 个 `it`)。
|
||||
- `.planning/phases/09-minimum-browser-runnable/09-61-SUMMARY.md`:本文件,未提交。
|
||||
|
||||
## 新增命名
|
||||
|
||||
### B. `probe.ts`
|
||||
|
||||
| 名称 | 可见性 | 签名 |
|
||||
|------|--------|------|
|
||||
| `mediaFormats` | 模块常量(不导出) | `[OGG, WEBM]` |
|
||||
| `createMediaSource` | 模块私有 | `(source: AudioInputSource): BufferSource \| BlobSource \| UrlSource \| null` |
|
||||
| `createMediaInput` | `export function` | `(source: AudioInputSource): Input \| null` |
|
||||
| `toAudioCodec` | 模块私有 | `(codec: string \| null): AudioCodec` |
|
||||
| `probeAudioSource` | `export async function` | `(source: AudioInputSource): Promise<IAudioFormatInfo \| null>` |
|
||||
|
||||
### C. `opusSession.ts`
|
||||
|
||||
| 名称 | 可见性 | 说明 |
|
||||
|------|--------|------|
|
||||
| `IOpusIdentificationHeader` | 非导出 interface | `preSkip` / `channels` / `streamCount` / `coupledStreamCount` / `channelMappingTable` |
|
||||
| `IOpusDecodedAudio` | 非导出 interface | `channelData` / `samplesDecoded` / `sampleRate` / `errors` |
|
||||
| `IOpusDecoderOptions` | 非导出 interface | `sampleRate: 48000` 与 OpusHead 映射字段 |
|
||||
| `IOpusDecoderInstance` | 非导出 interface | `ready` / `decodeFrame` / `free` |
|
||||
| `IOpusDecoderModule` | 非导出 interface | `OpusDecoder` / `OpusDecoderWebWorker` 构造签名 |
|
||||
| `parseOpusIdentificationHeader` | `export function` | `(description: Uint8Array \| null, channels: number): IOpusIdentificationHeader` |
|
||||
| `OpusDecodeSession` | `export class implements IAudioDecodeSession` | 整文件会话 |
|
||||
| `info` / `chunks` | `public readonly` | 接口成员;`chunks` 在构造器内赋为私有生成器 |
|
||||
| `opusModule` | `private static` | 缓存的动态导入模块 |
|
||||
| `input` / `sink` / `decoder` | `private readonly` | mediabunny `Input`、`EncodedPacketSink`、解码器实例 |
|
||||
| `closed` | `private` | 关闭标记 |
|
||||
| `loadDecoder` | `private static async` | `(header: IOpusIdentificationHeader): Promise<IOpusDecoderInstance>` |
|
||||
| `create` | `public static async` | `(source: AudioInputSource, info: IAudioFormatInfo): Promise<OpusDecodeSession \| null>` |
|
||||
| `decodePacket` | `private async` | `(packet: EncodedPacket): Promise<IAudioDecodedChunk \| null>` |
|
||||
| `generateChunks` | `private async *` | `(): AsyncGenerator<IAudioDecodedChunk>` |
|
||||
|
||||
### D. `context.ts`
|
||||
|
||||
| 名称 | 可见性 | 说明 |
|
||||
|------|--------|------|
|
||||
| `probeAudio` | `public`(实现 `IAudioDecodeProvider`) | 转调 `probeAudioSource` |
|
||||
| `createDecodeSession` | `public`(实现 `IAudioDecodeProvider`) | 只对 Ogg/WebM + Opus 返回会话 |
|
||||
| `decodeNative` | `private async` | 复制字节后原生解码,失败返回 `null` |
|
||||
| `convertAudioBuffer` | `private` | `AudioBuffer` 转 `IAudioDecodeData` |
|
||||
| `mergeChannelData` | `private` | 合并同声道分块 |
|
||||
| `decodeSession` | `private async` | 整文件遍历会话并 `close()` |
|
||||
| `decodeAudioLegacy` | `private async` | 与改动前 `decodeAudio` 函数体逐字等价 |
|
||||
| `decodeAudio` | `public`(重写) | 探测、原生、会话、旧路径 |
|
||||
| `decodeToAudioBuffer` | `public`(重写) | 探测、原生、会话、旧路径 |
|
||||
|
||||
删除命名:无。`seek` 按接口可选成员未实现,tracer 不支持跳转。
|
||||
|
||||
## 依赖
|
||||
|
||||
- 新增依赖:`mediabunny`,批准区间 `^1.66.3`,锁文件实际解析版本 **1.66.3**。
|
||||
- 安装命令(计划要求):`pnpm.cmd add mediabunny@^1.66.3`;实际执行见「偏差」节(需要 `-w`,且 `^` 需绕开 `cmd.exe` 解析)。
|
||||
- `opus-decoder` 已是既有依赖(`^0.7.11`),未新增、未升级。
|
||||
- `packages/audio/package.json` 零改动(哈希与基线一致,仍只有 workspace 依赖)。
|
||||
|
||||
## 兜底顺序
|
||||
|
||||
1. `probeAudio` 探测格式(mediabunny,精选 `[OGG, WEBM]`)。
|
||||
2. `decodeNative` 原生 `decodeAudioData`:先 `data.slice()` 复制字节,避免原生解码 detach 原始缓冲区;`try` / `catch` 捕获失败并返回 `null`。
|
||||
3. 仅当探测结果是 Ogg/WebM + Opus 时,`createDecodeSession` 建立 `OpusDecodeSession` 整文件解码。
|
||||
4. `decodeAudio` 最后落回 `decodeAudioLegacy`,其函数体与改动前 `decodeAudio` 逐字等价,MP3/WAV/FLAC/AAC 与已注册解码器的结果不回退。
|
||||
|
||||
`decodeNative` 内的 `try` / `catch` 是用户在计划中明确要求的「原生失败 → WASM 兜底」路径,属于 `dev.md`「不建议 try-catch」的**授权例外**,未扩散到其它方法。
|
||||
|
||||
**已知不等价点:** `decodeToAudioBuffer` 的 vanilla 分支改为经 `decodeNative`(先复制字节、`try` 捕获、失败返回 `null`),旧实现的 `data.buffer instanceof ArrayBuffer` 守卫随复制一起移除,因此该分支只保证解码结果等价,不再逐字等价;该差异已在 Task 0 报备并在此记录。
|
||||
|
||||
## 限制
|
||||
|
||||
- `ReadableStream` 输入不在 tracer 范围:`createMediaSource` 返回 `null`,探测与会话随之返回 `null`。
|
||||
- `seek` 未实现(接口可选成员)。
|
||||
- Node 环境(`typeof Worker === 'undefined'`)使用主线程 `OpusDecoder`,浏览器使用 `OpusDecoderWebWorker`。
|
||||
- 结构损坏但仍可识别容器的文件可能在 mediabunny 解析阶段抛错,tracer 不额外兜底,留给 09-62 / 09-63。
|
||||
- 探测与会话各建立一次 mediabunny `Input`(多一次头部解析),合并留给 09-63。
|
||||
- `opus-decoder` 在 `packages/audio/src` 内只有 1 处 `await import('opus-decoder')`,0 处静态导入。
|
||||
|
||||
## 未改项
|
||||
|
||||
以下 11 条只读路径的 `git hash-object` 与基线逐一相等:
|
||||
|
||||
1. `packages/audio/src/source.ts`
|
||||
2. `packages/audio/src/bgm.ts`
|
||||
3. `packages/audio/src/decoder.ts`
|
||||
4. `packages/audio/src/effect.ts`
|
||||
5. `packages/audio/src/sound.ts`
|
||||
6. `packages/audio/src/support.ts`
|
||||
7. `packages/audio/src/index.ts`
|
||||
8. `packages/audio/package.json`
|
||||
9. `script/build-game.ts`
|
||||
10. `vite.config.ts`
|
||||
11. `vitest.perf.config.ts`
|
||||
|
||||
另外 `getAudioTypeFromData` / `getErrorHeaderInfo` / `toAudioBuffer` 实现体与既有 jsDoc 注释均未改动;`decoder.ts` 的旧解码器未动;`types.ts` 只改父接口行(`IMotaAudioContext extends IMotaAudioContextCreator, IAudioDecodeProvider`),未新增 `IAudioDecoderRegistry`。
|
||||
|
||||
## 门禁真实输出
|
||||
|
||||
### tracer 测试
|
||||
|
||||
命令:`node node_modules/vitest/vitest.mjs run packages/audio/src/__test__/opusDecodeSession.test.ts`
|
||||
|
||||
- 1 个测试文件、4 个用例全部通过(探测 Ogg Opus / 未知数据为 null / 解析 OpusHead / 整文件解码),耗时约 170 ms。
|
||||
- 探测结果:容器 Ogg、编码 opus、采样率 48000、2 声道、时长 57.6535 秒。
|
||||
- OpusHead:`description` 19 字节,`preSkip` 312,`channels` 2,`streamCount` 1,`coupledStreamCount` 1,映射表 `[0, 1]`。
|
||||
- 整文件解码:2883 个包,总采样数 **2767368**,折算 **57.6535 秒**(与探测时长差 0),首个包时间戳 0.0135、最后 57.6335,峰值 **0.8153754472732544**。
|
||||
|
||||
### 静态检查
|
||||
|
||||
- prettier `--check`:6 个文件(`package.json`、`types.ts`、`context.ts`、`probe.ts`、`opusSession.ts`、测试)全部通过。
|
||||
- eslint:同样 6 个文件,退出码 0,**0 error 0 warning**。
|
||||
- 结构闸门:通过(`import('opus-decoder')` 恰 1 处、0 静态导入、两文件外部依赖只有 `mediabunny`、`[OGG, WEBM]` 且无 `ALL_FORMATS`、`EncodedPacketSink` / `sink.packets()` / `packet.timestamp` / `packet.duration` / `getDecoderConfig(` / `typeof Worker` / `OpusDecoderWebWorker` 均在位、`context.ts` 新调用点齐全、`getAudioTypeFromData` 无删除行、全仓 `mediabunny` 只出现在两个新文件、`script/build-game.ts` 的 `manualChunks` 仍 1 处)。
|
||||
- `types.ts` 单 hunk:通过(1 个 `@@`,新增行含 `IMotaAudioContext` 与 `IAudioDecodeProvider`,删除行是旧的 `IMotaAudioContextCreator {`)。
|
||||
- 11 路径哈希:通过,11 行集合与清单完全相等,逐条哈希未变。
|
||||
- 依赖闸门:根 `dependencies.mediabunny` 恰为 `^1.66.3`,`git diff -U0 package.json` 只有 1 条新增行,锁文件含 `mediabunny@1.66.`(3 处引用),`packages/audio/package.json` 哈希未变。
|
||||
|
||||
### 全仓类型检查(`node node_modules/vue-tsc/bin/vue-tsc.js --noEmit`)
|
||||
|
||||
| 阶段 | error 头行数 | `packages/audio` error 头行数 |
|
||||
|------|--------------|-------------------------------|
|
||||
| 装依赖前(`gsd-09-61-tsc-before.txt`) | 279 | 0 |
|
||||
| 装依赖后(`gsd-09-61-tsc-installed.txt`) | 279 | 0 |
|
||||
| 改完源码与测试(`gsd-09-61-tsc-after.txt`) | 279 | 0 |
|
||||
|
||||
装依赖零新增、改完代码零新增,`packages/audio/` 全程零错误。
|
||||
|
||||
### 状态与提交
|
||||
|
||||
- 现场基线:13 条(用户并发改动 12 条 + 未跟踪的 `09-61-PLAN.md`)。
|
||||
- Task 1 结束:基线 ∪ 6 个路径(`package.json`、`pnpm-lock.yaml`、`types.ts`、`context.ts`、`probe.ts`、`opusSession.ts`)。
|
||||
- Task 2 结束:基线 ∪ 8 个路径(再加测试文件与本 SUMMARY);基线条目一个不少、状态行不变。
|
||||
- `HEAD` 两处断言均为 `282875c956c8a460768b6a705ef2356af21d7c8e`,未变;工作树仍脏。
|
||||
- 新增文件纯 CRLF、0 制表符、无 BOM(4 个源码文件 + 测试文件 + 本 SUMMARY)。
|
||||
|
||||
## 未提交声明
|
||||
|
||||
- **0 提交**:未执行任何 git 写命令(`git add` / `git commit` / `git tag` / `git push` / `git stash` / `git checkout` / `git worktree`)。
|
||||
- `.planning/config.json` 的 `workflow.commit_docs: true` 与 `mode: yolo` 会触发文档提交,本计划**显式跳过**该提交;`use_worktrees: true` 不适用,全程在当前工作树执行。
|
||||
- 所有产物与本 SUMMARY 都**未提交**,留在工作树等用户验收。
|
||||
|
||||
## 偏差
|
||||
|
||||
1. **`pnpm add` 需要 `-w`**:首次 `pnpm.cmd add mediabunny@^1.66.3` 被 pnpm 以 `ERR_PNPM_ADDING_TO_ROOT` 拒绝(未写任何文件),随后加上 `-w` 才落到根 `package.json`。
|
||||
2. **`^` 被 `cmd.exe` 吞掉**:通过 `pnpm.cmd` 调用时 `python` 语义外的 `^` 被 shell 解析剥除,pnpm 把版本存成精确值 `1.66.3`。为落到批准的 `^1.66.3`,先手工把 `package.json` 的该行改成 `^1.66.3`,再用 `D:\nvm\v24.21.0\node_modules\pnpm\pnpm.exe add mediabunny@^1.66.3 -w`(不经过 `cmd.exe`)让 pnpm 自己把锁文件 importer 的 `specifier` 更新为 `^1.66.3`。最终 `package.json` 仍只有 1 行新增,解析版本 1.66.3。
|
||||
3. **`pnpm-workspace.yaml` 被 pnpm 自动追加**:pnpm 12 自动写入 `minimumReleaseAgeExclude: mediabunny@1.66.3`。该文件不在 `files_modified` 内,已按 HEAD 内容逐字节还原(blob `c5c1938`),因此不出现在 `git status`。如果本机的 minimum release age 策略需要该豁免,请用户自行重新加入。
|
||||
4. **测试文件导入改为 `node:fs` 并加 `@ts-expect-error`**:计划原文写的是 `from 'fs'`,但仓库根类型检查未加载 Node 类型(既有 `packages/render-anim/src/__test__/parse.test.ts` 同样用 `// @ts-expect-error` 处理)。为让 `packages/audio` 保持零类型错误,按仓库既有范式改为 `node:fs` 并加说明注释;运行时行为不变,测试通过。
|
||||
5. **prettier 归一了两处换行**:`probeAudio` 的签名与 `createDecodeSession` 内的容器判断条件被折成多行(行长归一,计划允许);除此之外未改动规格外内容。
|
||||
6. **门禁脚本与统计脚本写在固定临时目录** `C:/Users/13194/AppData/Local/Temp/opencode`(`gsd-09-61-*`),不是仓库产物。
|
||||
|
||||
## 未校准估算
|
||||
|
||||
- `confidence: low`,`tokens: 34000`,3 个任务 —— 未校准估算。
|
||||
- 实测(按 realized diff 的字符数 / 4,与新代码同尺度):约 4496 tokens;任务 3 个;提交 0 个。
|
||||
|
||||
## 用户验收
|
||||
|
||||
- 自动闸门只覆盖 Node 侧 tracer 测试与静态检查。
|
||||
- 真实浏览器里原生支持与 WASM 兜底的降级效果(Safari 等不支持 Ogg Opus 的浏览器)请用户手动验收,不作为自动断言。
|
||||
- 工作树与 SUMMARY 未提交,等待用户验收后再决定是否提交。
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,119 @@
|
||||
---
|
||||
phase: 09-minimum-browser-runnable
|
||||
plan: 62
|
||||
subsystem: audio
|
||||
tags: [comments, gap-closure, dev-md-compliance]
|
||||
requires: [09-61]
|
||||
provides:
|
||||
- 15 处私有函数 / 成员 / 方法的注释
|
||||
- 可运行的注释完整性闸门与逐字文本闸门
|
||||
affects:
|
||||
- packages/audio/src/probe.ts
|
||||
- packages/audio/src/opusSession.ts
|
||||
- packages/audio/src/context.ts
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- 私有字段使用单行 JSDoc
|
||||
- 私有函数与方法使用多行 JSDoc
|
||||
key-files:
|
||||
created:
|
||||
- .planning/phases/09-minimum-browser-runnable/09-62-SUMMARY.md
|
||||
modified:
|
||||
- packages/audio/src/probe.ts
|
||||
- packages/audio/src/opusSession.ts
|
||||
- packages/audio/src/context.ts
|
||||
decisions:
|
||||
- 只补注释,不改任何逻辑、签名、类型、测试、依赖或构建配置
|
||||
- createController 因 dev.md L75 显式排除,不添加注释
|
||||
- 0 提交,工作树与 SUMMARY 留待用户验收
|
||||
metrics:
|
||||
duration: 约 14 分钟
|
||||
completed: 2026-11-24
|
||||
status: complete
|
||||
actuals:
|
||||
tokens: 238
|
||||
tasks: 3
|
||||
commits: 0
|
||||
plan_head_before: 800a005ada84b4a1f8ea8e5eba07bd439751f6ff
|
||||
---
|
||||
|
||||
# Phase 09 Plan 62: 补齐 09-61 遗漏的 15 处私有成员与方法注释 Summary
|
||||
|
||||
只给 09-61 落地的三个源码文件补 15 处私有函数、私有成员与私有方法的注释,零逻辑改动,0 提交。
|
||||
|
||||
## 问题与根因
|
||||
|
||||
- 问题:09-61 让 `probe.ts` / `opusSession.ts` / `context.ts` 落地后,15 个私有函数、私有成员与私有方法没有任何注释。`dev.md` L74 明确要求其他常用成员、方法、类型也必须添加注释,因此 09-61 属 `dev.md` 合规失败,未被接受、也未提交。
|
||||
- 根因:09-61 的规划只逐个报备了新增命名与签名,没有把注释要求写进任何任务或闸门;执行器按命名已获批直接落地,遗漏了私有成员与方法注释。
|
||||
- 本计划定位:只补注释,不改逻辑;并通过可运行的注释完整性闸门防止同类遗漏再次发生。
|
||||
|
||||
## 文件清单
|
||||
|
||||
| 文件 | 改动 | 说明 |
|
||||
|------|------|------|
|
||||
| `packages/audio/src/probe.ts` | 2 处 | 两个私有函数的多行 JSDoc |
|
||||
| `packages/audio/src/opusSession.ts` | 8 处 | 5 个私有字段单行注释 + 3 个私有方法多行 JSDoc |
|
||||
| `packages/audio/src/context.ts` | 5 处 | 5 个私有方法多行 JSDoc |
|
||||
| `.planning/phases/09-minimum-browser-runnable/09-62-SUMMARY.md` | 新建 | 本摘要,未提交 |
|
||||
|
||||
上述三个源码文件只加注释,无逻辑、签名、类型、测试、依赖、构建配置改动。
|
||||
|
||||
## 15 个目标与注释
|
||||
|
||||
| 文件 | 目标 | 形式 | 批准的注释文本(含 @param) |
|
||||
|------|------|------|------------------------------|
|
||||
| probe.ts | `createMediaSource` | 多行 JSDoc | 把统一的音频输入类型转换为 mediabunny 支持的数据源,不支持的输入返回 null;`@param source 音频输入数据` |
|
||||
| probe.ts | `toAudioCodec` | 多行 JSDoc | 把 mediabunny 的编码字符串映射为本包的音频编码枚举;`@param codec mediabunny 返回的编码字符串` |
|
||||
| opusSession.ts | `opusModule` | 单行 | 缓存的 opus-decoder 模块,避免重复动态导入 |
|
||||
| opusSession.ts | `input` | 单行 | 会话持有的 mediabunny 输入,关闭会话时释放 |
|
||||
| opusSession.ts | `sink` | 单行 | 按包顺序读取编码数据的包读取器 |
|
||||
| opusSession.ts | `decoder` | 单行 | 当前会话使用的 Opus 解码器实例 |
|
||||
| opusSession.ts | `closed` | 单行 | 会话是否已关闭,用于中止异步迭代 |
|
||||
| opusSession.ts | `loadDecoder` | 多行 JSDoc | 按 OpusHead 配置并创建解码器,浏览器使用 Worker 变体,Node 使用主线程变体;`@param header 解析得到的 Opus 识别头` |
|
||||
| opusSession.ts | `decodePacket` | 多行 JSDoc | 解码单个 Opus 包,空包返回 null;`@param packet 待解码的编码包` |
|
||||
| opusSession.ts | `generateChunks` | 多行 JSDoc | 顺序读取并解码全部 Opus 包,会话关闭后提前结束 |
|
||||
| context.ts | `decodeNative` | 多行 JSDoc | 复制字节后尝试浏览器原生解码,失败返回 null;先复制是为了避免 decodeAudioData 分离原始数据;`@param data 待解码的原始音频数据` |
|
||||
| context.ts | `convertAudioBuffer` | 多行 JSDoc | 把 AudioBuffer 转换为统一解码结果;`@param buffer 原生解码得到的音频缓冲` |
|
||||
| context.ts | `mergeChannelData` | 多行 JSDoc | 按顺序拼接同一声道的多个 PCM 片段;`@param chunks 同一声道的 PCM 片段` |
|
||||
| context.ts | `decodeSession` | 多行 JSDoc | 消费会话的全部 PCM 片段并合并,结束后关闭会话;`@param session 已建立但尚未消费的解码会话` |
|
||||
| context.ts | `decodeAudioLegacy` | 多行 JSDoc | 使用旧的格式探测与解码器路径,作为新路径失败后的兜底;`@param data 待解码的原始音频数据` |
|
||||
|
||||
字段注释单行、方法注释多行;注释与声明之间不留空行;未改动任何既有注释。
|
||||
|
||||
## createController 排除
|
||||
|
||||
受保护 `createController` 位于 `packages/audio/src/source.ts` 第 99、479、552 行与 `packages/audio/src/route.ts` 第 80 行,这些类均 `extends Hookable`,该方法是基类抽象方法的实现。`dev.md` L75 规定继承或 implements 而来的 API 不应重复添加 jsDoc,因此不添加注释。`source.ts` / `route.ts` 零改动,`source.ts` 位于 11 条只读哈希内且哈希未变。
|
||||
|
||||
## 闸门真实输出
|
||||
|
||||
| 闸门 | 结果 |
|
||||
|------|------|
|
||||
| `gsd-09-62-gate-comments` | OK: 15/15 个目标声明上方都有非空注释;修复前 15/15 缺失,修复后通过 |
|
||||
| `gsd-09-62-gate-comment-text` | OK: 15/15 个目标注释与批准文本逐字一致(描述句与 @param 全部匹配) |
|
||||
| `gsd-09-62-gate-delta` | OK: probe 8 行 / opusSession 16 行 / context 21 行,共 45 行新增,全部为注释行;15 个注释块;无删除或修改的代码行 |
|
||||
| `gsd-09-62-gate-targets-changed` | OK: 3 个目标文件相对改前基线均已变化 |
|
||||
| `gsd-09-62-gate-readonly` | OK: 11 条只读路径哈希与基线一致,未越界 |
|
||||
| prettier | `node node_modules/prettier/bin/prettier.cjs --check` 通过,All matched files use Prettier code style |
|
||||
| eslint | `node node_modules/eslint/bin/eslint.js` 通过,0 error 0 warning |
|
||||
| vue-tsc 集合差集 | 改前 279 条 error 头行、改后 279 条,集合差集 0 新增;`packages/audio` 改前 0、改后 0 |
|
||||
| CRLF | `gsd-09-62-gate-text` 对 3 个源码文件通过:纯 CRLF、0 制表符、无 BOM |
|
||||
| 状态差集 | `--expect-task2` 通过:10 条基线路经全部保留、状态行不变、无删除;基线外仅新增 1 条 `09-62-SUMMARY.md` |
|
||||
| HEAD | `gsd-09-62-gate-head` 最终失败,原因是用户外部提交把 HEAD 从 `800a005a...` 移到 `9c6693d4...`;该提交只含 textbox.tsx / textboxTyper.ts,本执行器 0 提交 |
|
||||
|
||||
实际命令均以 `node node_modules/...` 等价执行 `pnpm exec ...`(`pnpm.ps1` 被执行策略禁止)。
|
||||
|
||||
## 偏差
|
||||
|
||||
1. 外部并发改动(不计为本计划偏差,仅记录):执行期间用户并发修改了 `packages-user/client-base/src/components/textboxTyper.ts` 与 `textbox.tsx`。该中间状态曾让 `vue-tsc` 全局集合差集新增 7 条 error 头行(textbox.tsx 2 条、textboxTyper.ts 5 条),随后用户把这两个文件改回并提交;最终 `vue-tsc` 复核为 0 新增、`packages/audio` 改前 0、改后 0。本计划未修改、未回滚这些外部改动。
|
||||
2. 外部提交(不计为本计划偏差,仅记录):用户在上述外部改动完成后提交了 `9c6693d4b79832dea3e8bc2670c80d73cba6563f`(refactor: TextContentTyper 删除 eventemitter3 依赖,换用 Hook 接口),该提交只含 `textbox.tsx` 与 `textboxTyper.ts`,不含本计划任何文件。因此 `HEAD` 从基线 `800a005ada84b4a1f8ea8e5eba07bd439751f6ff` 移到 `9c6693d4...`,`gate-head` 仅因 HEAD 比对而失败;本执行器未提交、未暂存、未改动该提交。
|
||||
3. `gate-status --expect-task1` 在外部改动期间曾因 textbox 条目字面失败;外部提交落地后 `--expect-task2` 通过(10 条基线路经全部保留、状态行不变、无删除,基线外仅新增 `09-62-SUMMARY.md`)。
|
||||
4. 除上述外部改动与外部提交外,本计划相对计划的偏差:无。
|
||||
|
||||
## 未校准估算
|
||||
|
||||
`confidence: low`,`tokens: 14000`(advisory),3 个任务;实际新增注释 45 行、约 950 字符(约 238 tokens),远低于估算上限。
|
||||
|
||||
## 0 提交声明
|
||||
|
||||
未执行任何 git 写命令(无 `git add` / `git commit` / `git tag` / `git push` / `git stash` / `git checkout` / `git worktree` / `git add -N`);显式跳过 `workflow.commit_docs`;未使用 worktree;本执行器 0 提交。执行期间 HEAD 由用户外部提交从基线 `800a005ada84b4a1f8ea8e5eba07bd439751f6ff` 移到 `9c6693d4b79832dea3e8bc2670c80d73cba6563f`,该提交不含本计划文件;本计划三个源码文件与 `09-62-SUMMARY.md` 仍未提交,工作树留待用户验收。
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,205 @@
|
||||
---
|
||||
phase: 09-minimum-browser-runnable
|
||||
plan: 63
|
||||
subsystem: audio
|
||||
tags: [opus, mediabunny, typescript, jsdoc, comments, factory-function]
|
||||
|
||||
requires:
|
||||
- phase: 09-minimum-browser-runnable
|
||||
provides: "09-61 落地的 Opus 解码会话,以及 09-62 落地的类内静态成员与注释现状"
|
||||
|
||||
provides:
|
||||
- "opusSession.ts 的 5 个内部接口共 20 个成员注释"
|
||||
- "opusSession.ts 的 3 个模块级声明注释:opusModulePromise / loadOpusDecoder / createOpusDecodeSession"
|
||||
- "类静态成员改为模块级 Promise 缓存与工厂函数,类内零 static"
|
||||
- "context.ts 与 tracer 测试改用 createOpusDecodeSession"
|
||||
|
||||
affects: [09-minimum-browser-runnable]
|
||||
|
||||
actuals:
|
||||
tokens: 2050
|
||||
tasks: 3
|
||||
commits: 0
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "模块级 Promise 缓存 + pending.catch 清缓存并重抛,替代类静态成员"
|
||||
- "模块级工厂函数承担原静态入口职责,类只保留实例成员"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ".planning/phases/09-minimum-browser-runnable/09-63-SUMMARY.md"
|
||||
modified:
|
||||
- "packages/audio/src/opusSession.ts"
|
||||
- "packages/audio/src/context.ts"
|
||||
- "packages/audio/src/__test__/opusDecodeSession.test.ts"
|
||||
|
||||
key-decisions:
|
||||
- "接口成员按 dev.md 第 74 行逐个补注释;接口本体按第 82 行不加注释"
|
||||
- "3 个类静态成员改为模块级,只有 createOpusDecodeSession 导出"
|
||||
- "缓存清理用 Promise.catch 形式,不用 try 语句,符合 dev.md 第 121 行"
|
||||
- "0 提交,工作树与 SUMMARY 留待用户验收"
|
||||
|
||||
patterns-established:
|
||||
- "模块级非导出 let 作为惰性 Promise 缓存,失败时清回 null 保证可重试"
|
||||
|
||||
requirements-completed: []
|
||||
|
||||
duration: 7min
|
||||
completed: 2026-11-25
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 9 Plan 63: 接口成员注释与类静态成员改模块级 Summary
|
||||
|
||||
**给 `opusSession.ts` 的 5 个内部接口补 20 个成员注释与 3 个模块级声明注释,并把 3 个类静态成员改为模块级 Promise 缓存与工厂函数,解码行为零变化**
|
||||
|
||||
## 补 09-61 / 09-62 遗留的两个问题
|
||||
|
||||
本计划是 gap closure,专门补 **09-61 / 09-62 遗留**的两个问题,两个问题均已由用户确认:
|
||||
|
||||
1. **接口成员无注释。** `packages/audio/src/opusSession.ts` 的 5 个内部接口共 20 个成员全部没有注释。`dev.md` 第 74 行要求「其他常用成员、方法、类型也必须添加注释」;第 82 行只说明不建议给接口本体写注释,并未豁免成员;`AGENTS.md` 第 37 行把这类建议视为硬要求,因此 09-61 / 09-62 的注释工作未达标。
|
||||
2. **`OpusDecodeSession` 使用类静态成员。** `private static opusModule`、`private static loadDecoder`、`static async create` 属遗留静态风格。用户明确当前设计不应新增静态方法,此处也没有必要。
|
||||
|
||||
## 目标(Objective)
|
||||
|
||||
- 给 5 个内部接口的 20 个成员逐个补注释,非方法成员用单行 jsDoc,`decodeFrame` 与 `free` 两个方法用换行风格 jsDoc。
|
||||
- 把 3 个类静态成员改为模块级:`opusModulePromise`、`loadOpusDecoder`、`createOpusDecodeSession`,其中只有 `createOpusDecodeSession` 导出。
|
||||
- `context.ts` 与 tracer 测试各改 2 行改用新工厂。
|
||||
- 不碰仓库其它位置的旧静态方法,不改 `probe.ts` / `types.ts` / 依赖 / 构建配置,无行为变化,0 提交。
|
||||
|
||||
## 执行摘要
|
||||
|
||||
### 修改的文件
|
||||
|
||||
| 文件 | 改动 | 说明 |
|
||||
|------|------|------|
|
||||
| `packages/audio/src/opusSession.ts` | 全文替换 | 20 个接口成员注释 + 3 个模块级声明注释;删除 3 个类静态成员,改为模块级缓存与工厂 |
|
||||
| `packages/audio/src/context.ts` | 2 行 | import 与 `createDecodeSession` 返回改调 `createOpusDecodeSession` |
|
||||
| `packages/audio/src/__test__/opusDecodeSession.test.ts` | 2 行 | import 与整文件解码调用改调 `createOpusDecodeSession`,4 个 `it` 与断言不变 |
|
||||
| `.planning/phases/09-minimum-browser-runnable/09-63-SUMMARY.md` | 新增 | 本摘要,未提交 |
|
||||
|
||||
除「静态成员改模块级」和「新增注释」外无行为变化。`parseOpusIdentificationHeader` 的实现与注释、类实例成员、构造器、`decodePacket`、`generateChunks`、`close` 逐字保留。
|
||||
|
||||
### 23 个注释目标
|
||||
|
||||
5 个内部接口:`IOpusIdentificationHeader`、`IOpusDecodedAudio`、`IOpusDecoderOptions`、`IOpusDecoderInstance`、`IOpusDecoderModule`。
|
||||
|
||||
20 个接口成员(非方法成员单行,方法换行):
|
||||
|
||||
| # | 接口 | 成员 | 注释 |
|
||||
|---|------|------|------|
|
||||
| 1 | `IOpusIdentificationHeader` | `preSkip` | OpusHead 中声明的起始预跳过采样数,解码后需要丢弃 |
|
||||
| 2 | `IOpusIdentificationHeader` | `channels` | 输出声道数 |
|
||||
| 3 | `IOpusIdentificationHeader` | `streamCount` | 独立 Opus 流数量 |
|
||||
| 4 | `IOpusIdentificationHeader` | `coupledStreamCount` | 耦合 Opus 流数量 |
|
||||
| 5 | `IOpusIdentificationHeader` | `channelMappingTable` | 输出声道到 Opus 流的映射表 |
|
||||
| 6 | `IOpusDecodedAudio` | `channelData` | 每个声道的 PCM 数据 |
|
||||
| 7 | `IOpusDecodedAudio` | `samplesDecoded` | 每个声道解码出的采样数 |
|
||||
| 8 | `IOpusDecodedAudio` | `sampleRate` | 解码后的采样率 |
|
||||
| 9 | `IOpusDecodedAudio` | `errors` | 解码过程中产生的错误列表 |
|
||||
| 10 | `IOpusDecoderOptions` | `sampleRate` | Opus 输出采样率,固定为 48000 |
|
||||
| 11 | `IOpusDecoderOptions` | `channels` | 输出声道数 |
|
||||
| 12 | `IOpusDecoderOptions` | `preSkip` | 起始处需要跳过的采样数 |
|
||||
| 13 | `IOpusDecoderOptions` | `streamCount` | 独立 Opus 流数量 |
|
||||
| 14 | `IOpusDecoderOptions` | `coupledStreamCount` | 耦合 Opus 流数量 |
|
||||
| 15 | `IOpusDecoderOptions` | `channelMappingTable` | 输出声道到 Opus 流的映射表 |
|
||||
| 16 | `IOpusDecoderInstance` | `ready` | WASM 初始化完成的 Promise |
|
||||
| 17 | `IOpusDecoderInstance` | `decodeFrame` | 多行:解码单个 Opus 包 / `@param packet 待解码的 Opus 包` / `@returns 解码后的 PCM 数据,可能是同步值或 Promise` |
|
||||
| 18 | `IOpusDecoderInstance` | `free` | 多行:释放解码器占用的资源 |
|
||||
| 19 | `IOpusDecoderModule` | `OpusDecoder` | 主线程 Opus 解码器构造函数 |
|
||||
| 20 | `IOpusDecoderModule` | `OpusDecoderWebWorker` | Web Worker Opus 解码器构造函数 |
|
||||
|
||||
3 个模块级声明:
|
||||
|
||||
| # | 声明 | 形式 | 注释 |
|
||||
|---|------|------|------|
|
||||
| 21 | `opusModulePromise` | 单行 | 缓存的 opus-decoder 动态导入 Promise,避免并发重复加载 |
|
||||
| 22 | `loadOpusDecoder` | 多行 | 按 OpusHead 配置并创建 Opus 解码器;浏览器使用 Worker 变体,Node 使用主线程变体 + `@param header 已解析的 Opus 识别头` |
|
||||
| 23 | `createOpusDecodeSession` | 多行 | 为 Ogg / WebM Opus 创建整文件解码会话 + `@param source 音频输入数据` + `@param info 探测得到的格式信息` |
|
||||
|
||||
明确不注释:5 个接口本体(`dev.md` 第 82 行);`OpusDecodeSession` 的 `info` / `chunks` / `close`(`dev.md` 第 75 行,接口实现不重复 jsDoc);构造器(`dev.md` 第 76 行)。已带注释的 `parseOpusIdentificationHeader`、`decodePacket`、`generateChunks`、`input` / `sink` / `decoder` / `closed` 逐字保留。
|
||||
|
||||
### 静态改模块级设计
|
||||
|
||||
| 目标 | 可见性 | 说明 |
|
||||
|------|--------|------|
|
||||
| `opusModulePromise` | 模块私有 `let` | 类型为 `Promise<IOpusDecoderModule>` 或 `null`,作为动态导入的 Promise 缓存 |
|
||||
| `loadOpusDecoder(header)` | 模块私有 `async function` | 复用缓存;为空时存入 `import('opus-decoder')` 的 Promise;加载失败时用 `pending.catch` 把缓存清回 `null` 并重新抛出,保证后续调用可重试 |
|
||||
| `createOpusDecodeSession(source, info)` | 导出 `async function` | 搬原 `static create` 的输入 / 音轨 / sink 装配,返回 `Promise<OpusDecodeSession>` 或 `null` |
|
||||
|
||||
- 类内零 `static`:删除了 `private static opusModule`、`private static async loadDecoder`、`static async create` 及其各自的注释。
|
||||
- 解码器选项仍为 `sampleRate: 48000` 与 OpusHead 的 `channels` / `preSkip` / `streamCount` / `coupledStreamCount` / `channelMappingTable`。
|
||||
- Worker 选择不变:`typeof Worker === 'undefined'` 用 `opus.OpusDecoder`,否则用 `opus.OpusDecoderWebWorker`,`await decoder.ready` 后返回。
|
||||
- 缓存清理用 `Promise.catch` 形式,未使用 `try` 语句,符合 `dev.md` 第 121 行。
|
||||
|
||||
## 行为不变证据
|
||||
|
||||
- **tracer 测试 4/4 通过**:1 个测试文件、4 个用例(探测 Ogg Opus 格式 / 未知数据探测为 null / 解析 OpusHead / 整文件解码)全部通过。
|
||||
- **调用点闸门**:`context.ts` 与测试文件各只改批准的 2 行,行数不变,4 个 `it` 与断言逐字未改。
|
||||
- **结构闸门**:`decodePacket` / `generateChunks` / `close` / 工厂装配与既有 jsDoc 描述的关键语句全部在位。
|
||||
- **类型检查**:`vue-tsc --noEmit` 改前 / 改后 error 头行集合零新增,`packages/audio` 零 error。
|
||||
|
||||
## 闸门真实输出
|
||||
|
||||
| 闸门 | 命令 | 结果 |
|
||||
|------|------|------|
|
||||
| 注释完整性 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-comments.cjs` | `OK: 23/23 个目标声明上方都有非空注释,接口本体与类的 info / chunks / close 上方均无注释` |
|
||||
| 注释逐字文本 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-comment-text.cjs` | `OK: 23/23 个目标注释与批准文本逐字一致` |
|
||||
| 结构(零静态) | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-structure.cjs` | `OK: zero static, no old static names, single dynamic import, all key statements in place` |
|
||||
| 调用点 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-callsite.cjs` | `OK: context.ts 与测试各只改批准的 2 行,4 个 it 与断言逐字不变` |
|
||||
| 16 条守卫哈希 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-guard.cjs` | `OK: 16 条守卫路径哈希与基线一致` |
|
||||
| 范围(Task 1) | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-scope.cjs --expect-task1` | `OK: scope within expectation (--expect-task1), packages/audio baseline 5 entries unchanged, no deletions` |
|
||||
| 范围(Task 2) | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-scope.cjs --expect-task2` | `OK: scope within expectation (--expect-task2), packages/audio baseline 5 entries unchanged, no deletions` |
|
||||
| CRLF / 无 tab / 无 BOM | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-text.cjs <3 个文件>` | `OK: CRLF, no tab, no BOM (3 files)` |
|
||||
| prettier | `node node_modules/prettier/bin/prettier.cjs --check <3 个文件>` | `All matched files use Prettier code style!`(未使用 `--write`) |
|
||||
| eslint | `node node_modules/eslint/bin/eslint.js <3 个文件>` | 无任何输出,退出码 0,0 error 0 warning |
|
||||
| vitest | `node node_modules/vitest/vitest.mjs run packages/audio/src/__test__/opusDecodeSession.test.ts` | `Test Files 1 passed (1)`、`Tests 4 passed (4)` |
|
||||
| vue-tsc 改前 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-capture-tsc.cjs .../gsd-09-63-tsc-before.txt` | 279 个 error 头行,`packages/audio` 0 个 |
|
||||
| vue-tsc 改后 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-capture-tsc.cjs .../gsd-09-63-tsc-after.txt` | 279 个 error 头行,`packages/audio` 0 个 |
|
||||
| vue-tsc 差集 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-tsc.cjs <before> <after> --audio` | `OK: tsc set-diff has 0 new error headers; packages/audio errors = 0` |
|
||||
| SUMMARY 内容 | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-summary.cjs` | `OK: SUMMARY content, CRLF, no tab, no BOM` |
|
||||
| HEAD | `node C:/Users/13194/AppData/Local/Temp/opencode/gsd-09-63-gate-head.cjs` | HEAD 未变 `ba90ce6dace27cbedf6618858cf91ffbfe5f7af2`,工作树仍脏,产物未提交 |
|
||||
|
||||
### 实际命令(本机 `pnpm.ps1` 被执行策略拦截)
|
||||
|
||||
- prettier:`node node_modules/prettier/bin/prettier.cjs --check <3 个文件>`(等价于 `pnpm exec prettier --check <3 个文件>`)
|
||||
- eslint:`node node_modules/eslint/bin/eslint.js <3 个文件>`(等价于 `pnpm exec eslint <3 个文件>`)
|
||||
- vitest:`node node_modules/vitest/vitest.mjs run packages/audio/src/__test__/opusDecodeSession.test.ts`(等价于 `pnpm exec vitest run <同一路径>`)
|
||||
- vue-tsc:由 `gsd-09-63-capture-tsc.cjs` 内部执行 `node_modules/vue-tsc/bin/vue-tsc.js --noEmit`(等价于 `pnpm exec vue-tsc --noEmit`)
|
||||
|
||||
## 决策
|
||||
|
||||
- 接口成员按 `dev.md` 第 74 行逐个补注释,接口本体按第 82 行不加注释;类的 `info` / `chunks` / `close` 按第 75 行不加注释。
|
||||
- 3 个类静态成员改为模块级,只有 `createOpusDecodeSession` 导出,`opusModulePromise` 与 `loadOpusDecoder` 模块私有。
|
||||
- 缓存失败重试用 `Promise.catch` 形式而非 `try` 语句,遵循 `dev.md` 第 121 行。
|
||||
- 0 提交,工作树与 SUMMARY 留待用户验收。
|
||||
|
||||
## 偏差
|
||||
|
||||
1. **新增一个临时校验脚本**:为逐字核对 `opusSession.ts` 与计划「源文件规格」全文一致,在固定临时目录额外写了 `gsd-09-63-gate-spec.cjs`(输出 `OK: opusSession.ts 与源文件规格逐字一致`)。它不是仓库产物,不进入 `git status`,也不替代任何计划闸门。
|
||||
2. **`opusSession.ts` 写入后做了一次行尾归一**:Write 工具先写出 LF,随后用固定临时目录的 `gsd-09-63-crlf.cjs` 转为 CRLF,以满足 `.prettierrc` 的 `endOfLine: crlf`;归一后 `gate-text` 与 `prettier --check` 均通过。未产生任何内容变化。
|
||||
3. **未使用 `prettier --write`**:`--check` 首轮即通过,Task 1 第 5 步的兜底路径未触发。
|
||||
4. **外部改动(只记录、未回退)**:执行期间工作树出现用户的外部改动 `M packages/render/src/core/render.ts`(已暂存,不在本计划范围内,不在基线中)。删除、回退或提交它都未执行;`gate-scope` 只校验 `packages/audio` 与阶段目录,因此不受影响。外部 `HEAD` 未变化。
|
||||
5. 其余与计划一致,源码与调用点均按规格逐字落地。
|
||||
|
||||
## 未校准估算
|
||||
|
||||
计划 `estimate` 为 `confidence: low`、`tokens: 18000`、3 个任务,属**未校准**的 advisory 值,不作为拆分或阻断依据。本摘要 `actuals.tokens` 取实现文本差异(`opusSession.ts` 全文重写 7984 字符 + `context.ts` 与测试各 2 行)约 2050,与 18000 不同尺度(后者含汇报关卡、全仓类型检查与多次闸门运行的整体成本),仅作记录。
|
||||
|
||||
## 校验(Self-Check)
|
||||
|
||||
- [x] `packages/audio/src/opusSession.ts` 存在且与源文件规格逐字一致
|
||||
- [x] `packages/audio/src/context.ts` 仅改批准的 2 行
|
||||
- [x] `packages/audio/src/__test__/opusDecodeSession.test.ts` 仅改批准的 2 行,4 个 `it` 与断言不变
|
||||
- [x] 23/23 注释目标与批准措辞通过
|
||||
- [x] 零 `static`、零旧名、单次动态导入、关键语句在位
|
||||
- [x] 16 条守卫路径哈希不变
|
||||
- [x] `packages/audio` 状态条目与基线 5 条既有产物逐行相等
|
||||
- [x] prettier / eslint / vitest 4/4 / vue-tsc 差集通过
|
||||
- [x] 0 提交,无提交包含本计划文件,工作树仍脏
|
||||
|
||||
## 0 提交声明
|
||||
|
||||
未执行任何 git 写命令(含 `git add` / `git add -N` / `git commit` / `git tag` / `git push` / `git stash` / `git checkout` / `git worktree` / `git restore`)。显式跳过 `workflow.commit_docs`,未使用 worktree。最终产物是**未提交的工作树 + 未提交的 SUMMARY**,留待用户验收。外部 `HEAD` 与 status 变化只记录、只上报,未回退。
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,168 @@
|
||||
---
|
||||
phase: 09-minimum-browser-runnable
|
||||
plan: 64
|
||||
subsystem: audio
|
||||
tags: [opus, mediabunny, logger, error-codes, gap-closure, typescript]
|
||||
|
||||
requires:
|
||||
- phase: 09-minimum-browser-runnable
|
||||
provides: "09-61 落地的 Opus 探测与整文件解码会话,09-63 落地的模块级工厂与接口注释"
|
||||
|
||||
provides:
|
||||
- "logger.json 的 error 97(会话创建失败)与 warn 217(输入类型不支持)"
|
||||
- "probe.ts 的 warn 217、容器未知 / 无主音轨各一次 error 97、getFormat 前置"
|
||||
- "opusSession.ts 的 OpusHead 改返 null、四处 error 97、零采样带错误保留"
|
||||
- "context.ts 公共边界两处 error 25 + null"
|
||||
- "测试 6 个 it 与单参数解析调用"
|
||||
|
||||
affects: [09-minimum-browser-runnable]
|
||||
|
||||
actuals:
|
||||
tokens: 830
|
||||
tasks: 3
|
||||
commits: 0
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "静默兜底与可诊断失败分离:期望内路径不发声,异常路径各记一次码"
|
||||
- "零采样但带错误时保留 chunk,把 errors 一路带到公共边界统一记一次 25"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- ".planning/phases/09-minimum-browser-runnable/09-64-SUMMARY.md"
|
||||
modified:
|
||||
- "packages/common/src/logger.json"
|
||||
- "packages/audio/src/probe.ts"
|
||||
- "packages/audio/src/opusSession.ts"
|
||||
- "packages/audio/src/context.ts"
|
||||
- "packages/audio/src/__test__/opusDecodeSession.test.ts"
|
||||
|
||||
key-decisions:
|
||||
- "decodePacket 零采样带错误时保留零采样 chunk,让 decodeSession 收集 errors 后由公共边界记一次 error 25;DTX 空包仍静默跳过"
|
||||
- "loadOpusDecoder 里 09-63 既有的唯一一处 throw error(清缓存后重抛)原样保留,全文件零新增 throw"
|
||||
- "既有 if (!x) return null 守卫全部保留,按 dev.md 第 124 行前提不改写为提前返回"
|
||||
- "测试解析断言的 header 加一处非空断言以满足 vue-tsc,属计划严格差异规格未覆盖的必要类型修正"
|
||||
- "0 提交,工作树与 SUMMARY 留待用户验收"
|
||||
|
||||
patterns-established:
|
||||
- "异常分支各记一次日志码,期望内兜底(canRead 失败、decodeNative 失败、DTX)不记录,避免日志风暴"
|
||||
|
||||
requirements-completed: []
|
||||
|
||||
duration: 28min
|
||||
completed: 2026-11-25
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Phase 9 Plan 64: 静默失败补日志与两个日志码 Summary
|
||||
|
||||
**给 09-61 / 09-63 遗留的静默失败补上 error 97 与 warn 217,把 OpusHead 的默认回退改为返回 null,并把零采样带错误的解码失败一路带到公共边界记一次 error 25**
|
||||
|
||||
## 补 09-61 / 09-63 遗留的五个问题
|
||||
|
||||
本计划是 gap closure,专门补 **09-61 / 09-63 遗留**的问题,五个问题均已由用户确认:
|
||||
|
||||
1. **不支持的输入类型完全静默。** `probe.ts` 的 `createMediaSource` 对 `AudioInputSource` 联合类型里的 `ReadableStream` 直接返回 null,调用方无法判断是数据不是 Ogg / WebM,还是输入类型根本没实现。
|
||||
2. **Ogg / WebM 的异常分支静默。** `probeAudioSource` 先取主音轨后判容器,「容器是 Ogg / WebM 但没有主音轨」与「容器未知」都只返回 null。
|
||||
3. **`parseOpusIdentificationHeader` 静默回退默认值。** 缺失或非法的 OpusHead 被伪造成 `preSkip: 0` 与单流映射,解码结果失真且无提示。
|
||||
4. **解码器的错误被吞掉。** `decodePacket` 对零采样一律返回 null,`decoded.errors` 里有内容也会消失;公共边界拿到 null 直接返回,用户看不到失败。
|
||||
5. **两个日志码不存在。** `logger.json` 的 error 段止于 96、warn 段止于 216。
|
||||
|
||||
## 修改的文件
|
||||
|
||||
| 文件 | 改动 | 说明 |
|
||||
|------|------|------|
|
||||
| `packages/common/src/logger.json` | 新增 2 行 | error 97 紧跟 96、warn 217 紧跟 216 |
|
||||
| `packages/audio/src/probe.ts` | 全文替换 | 新增 logger 引入、warn 217、getFormat 前置、两处 error 97 |
|
||||
| `packages/audio/src/opusSession.ts` | 全文替换 | OpusHead 改返 null、删 fallback、四处 error 97、零采样带错误保留 |
|
||||
| `packages/audio/src/context.ts` | 2 个块 | 公共边界两处 error 25 + null |
|
||||
| `packages/audio/src/__test__/opusDecodeSession.test.ts` | 1 行 + 1 行 + 2 个 it | 单参数解析调用、`Math.max` 声道数、两个新 it |
|
||||
| `.planning/phases/09-minimum-browser-runnable/09-64-SUMMARY.md` | 新增 | 本摘要,未提交 |
|
||||
|
||||
无新功能、无新依赖、无新增 `throw`、无新增测试文件。`types.ts` / `source.ts` / `bgm.ts` / `decoder.ts` / 依赖 / 构建配置逐字未动。
|
||||
|
||||
## 日志码
|
||||
|
||||
| 码 | 级别 | 插入位置 | 消息 | 长度 / 上限 |
|
||||
|----|------|----------|------|-------------|
|
||||
| 97 | error | error 段 `"96"` 之后、`"2001"` 之前 | `Cannot create audio decode session: the audio track or its decoder description is missing.` | 90 / 96 |
|
||||
| 217 | warn | warn 段 `"216"` 之后、`"1001"` 之前 | `Unsupported audio input source type: '$1'.` | 42 / 216 |
|
||||
|
||||
两条均为普通顺序码,不使用 1000+ / 2000+ 域段;本段内各恰好出现 1 次。
|
||||
|
||||
## 记录与静默的分支
|
||||
|
||||
| 文件 | 分支 | 处理 | 记录 |
|
||||
|------|------|------|------|
|
||||
| `probe.ts` | 不支持的输入类型(`ReadableStream`) | 返回 null | `logger.warn(217, source.constructor.name)` |
|
||||
| `probe.ts` | `canRead()` 为 false | dispose 后返回 null | 不记录(数据不是 Ogg / WebM) |
|
||||
| `probe.ts` | 容器既非 Ogg 也非 WebM | dispose 后返回 null | `logger.error(97)` |
|
||||
| `probe.ts` | Ogg / WebM 但无主音轨 | dispose 后返回 null | `logger.error(97)` |
|
||||
| `opusSession.ts` | 不可读 | dispose 后返回 null | `logger.error(97)` |
|
||||
| `opusSession.ts` | 无主音轨 | dispose 后返回 null | `logger.error(97)` |
|
||||
| `opusSession.ts` | 无 `getDecoderConfig().description` | dispose 后返回 null | `logger.error(97)` |
|
||||
| `opusSession.ts` | OpusHead 非法 | dispose 后返回 null | `logger.error(97)` |
|
||||
| `opusSession.ts` | 零采样且无错误(DTX) | 返回 null,跳过该包 | 不记录 |
|
||||
| `context.ts` | `decodeNative` 失败 | 返回 null | 不记录(走 Opus 会话或 legacy) |
|
||||
| `context.ts` | `decodeSession` 零采样 | 返回 null | 不记录(由公共边界记 25) |
|
||||
| `context.ts` | 会话存在但结果零采样或 errors 非空 | 返回 null | `logger.error(25, this.getErrorHeaderInfo(data))`,两个公共方法各 1 次 |
|
||||
| `context.ts` | `session` 为 null,走 legacy | legacy 原有行为 | legacy 自己的 error 25 / 53,不新增第二条 |
|
||||
|
||||
## 契约裁定
|
||||
|
||||
- **零采样带错误:** `decodePacket` 先算 `isEmpty`,仅当 `isEmpty && errors.length === 0` 才返回 null;零采样但带错误时保留零采样 chunk,让 `decodeSession` 收集 `errors` 后由公共边界记一次 error 25。零采样且无错误(DTX)仍静默跳过。
|
||||
- **既有 `throw` 保留:** `opusSession.ts` 中 09-63 既有的唯一一处 `throw error`(清缓存后重抛,保证后续可重试)原样保留,全文件 `throw` 计数仍为 1,零新增。
|
||||
- **公共边界返回 null:** Opus 会话存在但结果为零采样或 `errors` 非空时,`decodeAudio` 与 `decodeToAudioBuffer` 各记一次 error 25 并返回 null;`session` 为 null 时仍走 legacy,不新增第二条 error 25。
|
||||
- **守卫控制流:** 既有 `if (!x) return null` 守卫全部保留,按 `dev.md` 第 124 行的前提(该条约束的是并列条件)不改写为 `if / else`,也不合并。
|
||||
|
||||
## 行为与证据
|
||||
|
||||
- **测试:** `vitest` 1 个测试文件、6 个用例全部通过;6 个 `it` 前各有一行中文注释。
|
||||
- **类型检查:** `vue-tsc --noEmit` 集合差集对改前基线新增 0 个 error 头行,`packages/audio` 0 error。
|
||||
- **格式:** `prettier --check` 首轮通过;`eslint` 退出码 0,0 error 0 warning。
|
||||
- **严格差异:** 5 个文件严格等于「改前副本 + 已批准替换」(含任务中必要的非空断言修正)。
|
||||
- **结构:** `opusSession.ts` 零 `static`、`throw` 计数 1(opusSession)/ 0(probe、context);`logger.error(97)` 计数 4(opusSession)/ 2(probe);`logger.warn(217` 计数 1;`context.ts` 的 error 25 计数 4、公共边界判空块 2 处;守卫与关键语句在位。
|
||||
- **守卫与范围:** 16 条守卫路径哈希与基线一致;范围只新增 `logger.json` 与 `09-64-SUMMARY.md` 两个条目,范围内无删除。
|
||||
|
||||
## 闸门真实输出
|
||||
|
||||
| 闸门 | 结果 |
|
||||
|------|------|
|
||||
| 日志码 `gsd-09-64-gate-codes.cjs` | `OK: error 97 / warn 217 唯一、位置正确、消息逐字一致(90 / 42 字符)` |
|
||||
| 结构 `gsd-09-64-gate-structure.cjs` | `OK: zero static, single throw, logger points, guards and 6 commented its in place` |
|
||||
| 严格差异 `gsd-09-64-gate-diff.cjs` | `OK: 5 个文件严格等于「改前副本 + 已批准替换」` |
|
||||
| 守卫哈希 `gsd-09-64-gate-guard.cjs` | `OK: 16 条守卫路径哈希与基线一致` |
|
||||
| 范围 Task 1 `gsd-09-64-gate-scope.cjs --expect-task1` | `OK: scope within expectation (--expect-task1), packages/audio baseline 5 entries unchanged, logger.json added, no scoped deletions` |
|
||||
| CRLF `gsd-09-64-gate-text.cjs` | `OK: CRLF, no tab, no BOM (5 files)` |
|
||||
| `prettier --check` | `All matched files use Prettier code style!`(未使用 `--write`) |
|
||||
| `eslint` | 无输出,退出码 0,0 error 0 warning |
|
||||
| `vitest` | `Test Files 1 passed (1)`、`Tests 6 passed (6)` |
|
||||
| `vue-tsc` 改前采集 | 286 个 error 头行,`packages/audio` 0 个 |
|
||||
| `vue-tsc` 改后采集 | 284 个 error 头行,`packages/audio` 0 个(期间用户外部提交修复了若干既有错误) |
|
||||
| `vue-tsc` 差集 `gsd-09-64-gate-tsc.cjs <before> <after> --audio` | `OK: tsc set-diff has 0 new error headers; packages/audio errors = 0` |
|
||||
| SUMMARY 内容 `gsd-09-64-gate-summary.cjs` | 见写后闸门输出 |
|
||||
| HEAD `gsd-09-64-gate-head.cjs` | `OK: HEAD 由不含本计划文件的提交推进到 24f7f8d558d7083925f81b15eb3c05948b72a9eb,工作树仍脏,产物未提交` |
|
||||
|
||||
### 实际命令(本机 `pnpm.ps1` 被执行策略拦截)
|
||||
|
||||
- `vitest`:`node node_modules/vitest/vitest.mjs run packages/audio/src/__test__/opusDecodeSession.test.ts`(等价于 `pnpm exec vitest run <同一路径>`)
|
||||
- `vue-tsc`:由 `gsd-09-64-capture-tsc.cjs` 内部执行 `node_modules/vue-tsc/bin/vue-tsc.js --noEmit`(等价于 `pnpm exec vue-tsc --noEmit`)
|
||||
- `prettier`:`node node_modules/prettier/bin/prettier.cjs --check <5 个文件>`(等价于 `pnpm exec prettier --check <5 个文件>`)
|
||||
- `eslint`:`node node_modules/eslint/bin/eslint.js <4 个 TS 文件>`(等价于 `pnpm exec eslint <4 个 TS 文件>`)
|
||||
|
||||
## 偏差
|
||||
|
||||
1. **测试解析断言补一处非空断言(Rule 1 - 类型错误)。** 计划把 `parseOpusIdentificationHeader` 的返回类型改为 `IOpusIdentificationHeader | null`,但计划给出的测试改动只有三处,未覆盖既有「解析 OpusHead」用例里对 `header.preSkip` 等属性的直接访问;只按计划落地会产生 5 条 `TS18047 'header' is possibly 'null'`。为满足计划自身的 `vue-tsc` 集合差集零新增闸门,把已批准的替换行改为 `const header = parseOpusIdentificationHeader(head)!;`(`dev.md` 第 110 行允许必要的非空断言;测试文件只需遵守每个 `it` 前一行注释的规则)。相应地,严格差异闸门脚本里该替换的期望文本同步为带 `!` 的版本;其余 4 个文件的已批准替换不变。改后重采 `vue-tsc` 为 0 新增、`packages/audio` 0 error。
|
||||
2. **行尾归一。** Write / Edit 可能写出 LF,已用固定临时目录的 `gsd-09-64-crlf.cjs` 对 5 个文件与 SUMMARY 归一为 CRLF,未改动任何字符。
|
||||
3. **未使用 `prettier --write`。** `--check` 首轮即通过,兜底路径未触发。
|
||||
4. **外部提交与 HEAD 移动(只记录、未回退)。** 执行期间 HEAD 由基线 `6773069c2405392bf53f791a8675dd8089960236` 推进到 `24f7f8d558d7083925f81b15eb3c05948b72a9eb`,含两个外部提交:`24f7f8d`(fix: 遗漏的 types.ts)与 `8fe1c84`(feat: client 上关于 mainTextboxManager 的默认主对象实例),只涉及 `packages-user/client-base/...` 与 `packages-user/client-modules/src/client.ts`,不含本计划 6 个路径、也不含 16 条守卫路径。工作树另有外部改动 `M package.json`、`M pnpm-lock.yaml`。以上只记录、只上报,未执行任何回退、rebase 或 checkout。
|
||||
5. 其余与计划一致。
|
||||
|
||||
## 未校准估算
|
||||
|
||||
计划 `estimate` 为 `confidence: low`、`tokens: 24000`、3 个任务,属**未校准**的 advisory 值,不作为拆分或阻断依据。本摘要 `actuals.tokens` 取实现文本差异(新增 58 行 2287 字符 + 删除 25 行 1032 字符,约 830 tokens),与 24000 不同尺度(后者含 Task 0 汇报关卡、全仓类型检查与多次闸门运行的整体成本),仅作记录。
|
||||
|
||||
## 0 提交声明
|
||||
|
||||
未执行任何 git 写命令(含 `git add` / `git add -N` / `git commit` / `git tag` / `git push` / `git stash` / `git checkout` / `git worktree` / `git restore`)。显式跳过 `workflow.commit_docs`,未使用 worktree。最终产物是**未提交的工作树 + 未提交的 SUMMARY**,留待用户验收。外部 `HEAD` 与 status 变化只记录、只上报,未回退。
|
||||
@@ -46,6 +46,7 @@
|
||||
"lodash-es": "^4.17.23",
|
||||
"lz-string": "^1.5.0",
|
||||
"maxrects-packer": "^2.7.3",
|
||||
"mediabunny": "^1.66.3",
|
||||
"ogg-opus-decoder": "^1.7.3",
|
||||
"opus-decoder": "^0.7.11",
|
||||
"vue": "^3.5.29"
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// 校验 Ogg Opus 的格式探测、OpusHead 解析与整文件解码会话
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { AudioCodec, AudioContainer } from '../types';
|
||||
import {
|
||||
parseOpusIdentificationHeader,
|
||||
createOpusDecodeSession
|
||||
} from '../opusSession';
|
||||
import { probeAudioSource } from '../probe';
|
||||
// 仓库根类型检查未加载 Node 类型,测试需要在 Node 环境下读取音频样例
|
||||
// @ts-expect-error 此处缺少 node:fs 的模块声明,仅测试环境使用
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const fixture = new Uint8Array(
|
||||
readFileSync(
|
||||
new URL('../../../../public/project/bgms/bgm.opus', import.meta.url)
|
||||
)
|
||||
);
|
||||
|
||||
describe('opus 解码', () => {
|
||||
// 探测 bgm.opus 应识别为 Ogg 容器下的 Opus 编码
|
||||
it('探测 Ogg Opus 格式', async () => {
|
||||
const info = await probeAudioSource(fixture);
|
||||
expect(info).not.toBeNull();
|
||||
const format = info!;
|
||||
expect(format.container).toBe(AudioContainer.Ogg);
|
||||
expect(format.codec).toBe(AudioCodec.Opus);
|
||||
expect(format.sampleRate).toBe(48000);
|
||||
expect(format.channels).toBe(2);
|
||||
expect(format.duration).not.toBeNull();
|
||||
expect(Math.abs(format.duration! - 57.66)).toBeLessThan(1);
|
||||
});
|
||||
|
||||
// 无法识别的数据应探测为 null
|
||||
it('未知数据探测为 null', async () => {
|
||||
const info = await probeAudioSource(new Uint8Array(64));
|
||||
expect(info).toBeNull();
|
||||
});
|
||||
|
||||
// OpusHead 解析应读出预跳过采样数与声道映射
|
||||
it('解析 OpusHead', () => {
|
||||
const head = new Uint8Array(19);
|
||||
head.set([0x4f, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], 0);
|
||||
head[8] = 1;
|
||||
head[9] = 2;
|
||||
head[10] = 0x38;
|
||||
head[11] = 0x01;
|
||||
const header = parseOpusIdentificationHeader(head)!;
|
||||
expect(header.preSkip).toBe(312);
|
||||
expect(header.channels).toBe(2);
|
||||
expect(header.streamCount).toBe(1);
|
||||
expect(header.coupledStreamCount).toBe(1);
|
||||
expect(header.channelMappingTable).toEqual([0, 1]);
|
||||
});
|
||||
|
||||
// OpusHead 缺失或非法时应解析为 null,不再回退到默认映射
|
||||
it('非法 OpusHead 解析为 null', () => {
|
||||
expect(parseOpusIdentificationHeader(null)).toBeNull();
|
||||
expect(parseOpusIdentificationHeader(new Uint8Array(10))).toBeNull();
|
||||
expect(parseOpusIdentificationHeader(new Uint8Array(19))).toBeNull();
|
||||
});
|
||||
|
||||
// 不支持的输入类型应探测为 null,不建立解码会话
|
||||
it('不支持的输入类型探测为 null', async () => {
|
||||
const info = await probeAudioSource(new ReadableStream<Uint8Array>());
|
||||
expect(info).toBeNull();
|
||||
});
|
||||
|
||||
// 整文件会话应解出非空 PCM,且总采样数与探测时长一致
|
||||
it('整文件解码', async () => {
|
||||
const info = await probeAudioSource(fixture);
|
||||
expect(info).not.toBeNull();
|
||||
const session = await createOpusDecodeSession(fixture, info!);
|
||||
expect(session).not.toBeNull();
|
||||
let samples = 0;
|
||||
let channels = 0;
|
||||
let lastTimestamp = -1;
|
||||
let peak = 0;
|
||||
for await (const chunk of session!.chunks) {
|
||||
channels = Math.max(channels, chunk.channelData.length);
|
||||
samples += chunk.samplesDecoded;
|
||||
lastTimestamp = chunk.timestamp;
|
||||
for (const channel of chunk.channelData) {
|
||||
for (let i = 0; i < channel.length; i++) {
|
||||
const abs = Math.abs(channel[i]);
|
||||
if (abs > peak) peak = abs;
|
||||
}
|
||||
}
|
||||
}
|
||||
session!.close();
|
||||
expect(channels).toBe(2);
|
||||
expect(samples).toBeGreaterThan(48000);
|
||||
expect(Math.abs(samples / 48000 - info!.duration!)).toBeLessThan(1);
|
||||
expect(lastTimestamp).toBeGreaterThan(0);
|
||||
expect(peak).toBeGreaterThan(0.001);
|
||||
});
|
||||
});
|
||||
@@ -14,15 +14,21 @@ import { logger } from '@motajs/common';
|
||||
import { VanillaDecoder } from './decoder';
|
||||
import {
|
||||
AudioDecoderCreateFunc,
|
||||
AudioCodec,
|
||||
AudioContainer,
|
||||
AudioInputSource,
|
||||
AudioType,
|
||||
IAudioBufferSource,
|
||||
IAudioChannelVolumeEffect,
|
||||
IAudioDecodeData,
|
||||
IAudioDecodeError,
|
||||
IAudioDecoder,
|
||||
IAudioDecodeSession,
|
||||
IAudioDelayEffect,
|
||||
IAudioEchoEffect,
|
||||
IAudioEffect,
|
||||
IAudioElementSource,
|
||||
IAudioFormatInfo,
|
||||
IAudioRoute,
|
||||
IAudioSource,
|
||||
IAudioStereoEffect,
|
||||
@@ -31,6 +37,8 @@ import {
|
||||
IMotaAudioContext,
|
||||
ISoundPlayer
|
||||
} from './types';
|
||||
import { probeAudioSource } from './probe';
|
||||
import { createOpusDecodeSession } from './opusSession';
|
||||
import { SoundPlayer } from './sound';
|
||||
import { AudioRoute } from './route';
|
||||
|
||||
@@ -402,7 +410,94 @@ export class MotaAudioContext implements IMotaAudioContext {
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
async decodeAudio(data: Uint8Array): Promise<IAudioDecodeData | null> {
|
||||
/**
|
||||
* 复制字节后尝试浏览器原生解码,失败返回 null
|
||||
* 先复制是为了避免 decodeAudioData 分离原始数据
|
||||
* @param data 待解码的原始音频数据
|
||||
*/
|
||||
private async decodeNative(data: Uint8Array): Promise<AudioBuffer | null> {
|
||||
const copy = data.slice();
|
||||
try {
|
||||
return await this.ac.decodeAudioData(copy.buffer);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 AudioBuffer 转换为统一解码结果
|
||||
* @param buffer 原生解码得到的音频缓冲
|
||||
*/
|
||||
private convertAudioBuffer(buffer: AudioBuffer): IAudioDecodeData {
|
||||
const channelData: Float32Array<ArrayBuffer>[] = [];
|
||||
for (let i = 0; i < buffer.numberOfChannels; i++) {
|
||||
channelData.push(buffer.getChannelData(i));
|
||||
}
|
||||
return {
|
||||
channelData,
|
||||
samplesDecoded: buffer.length,
|
||||
sampleRate: buffer.sampleRate,
|
||||
errors: []
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 按顺序拼接同一声道的多个 PCM 片段
|
||||
* @param chunks 同一声道的 PCM 片段
|
||||
*/
|
||||
private mergeChannelData(
|
||||
chunks: Float32Array<ArrayBuffer>[]
|
||||
): Float32Array<ArrayBuffer> {
|
||||
const total = chunks.reduce((prev, curr) => prev + curr.length, 0);
|
||||
const merged = new Float32Array(total);
|
||||
let offset = 0;
|
||||
for (const chunk of chunks) {
|
||||
merged.set(chunk, offset);
|
||||
offset += chunk.length;
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费会话的全部 PCM 片段并合并,结束后关闭会话
|
||||
* @param session 已建立但尚未消费的解码会话
|
||||
*/
|
||||
private async decodeSession(
|
||||
session: IAudioDecodeSession
|
||||
): Promise<IAudioDecodeData | null> {
|
||||
const channelChunks: Float32Array<ArrayBuffer>[][] = [];
|
||||
const errors: IAudioDecodeError[] = [];
|
||||
let samplesDecoded = 0;
|
||||
let sampleRate = 0;
|
||||
for await (const chunk of session.chunks) {
|
||||
for (let i = 0; i < chunk.channelData.length; i++) {
|
||||
if (!channelChunks[i]) channelChunks[i] = [];
|
||||
channelChunks[i].push(chunk.channelData[i]);
|
||||
}
|
||||
samplesDecoded += chunk.samplesDecoded;
|
||||
sampleRate = chunk.sampleRate;
|
||||
errors.push(...chunk.errors);
|
||||
}
|
||||
session.close();
|
||||
if (samplesDecoded === 0) return null;
|
||||
const channelData = channelChunks.map(chunks =>
|
||||
this.mergeChannelData(chunks)
|
||||
);
|
||||
return {
|
||||
channelData,
|
||||
samplesDecoded: channelData[0].length,
|
||||
sampleRate,
|
||||
errors
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用旧的格式探测与解码器路径,作为新路径失败后的兜底
|
||||
* @param data 待解码的原始音频数据
|
||||
*/
|
||||
private async decodeAudioLegacy(
|
||||
data: Uint8Array
|
||||
): Promise<IAudioDecodeData | null> {
|
||||
const type = this.getAudioTypeFromData(data);
|
||||
if (type === AudioType.Unknown) {
|
||||
logger.error(25, this.getErrorHeaderInfo(data));
|
||||
@@ -419,6 +514,46 @@ export class MotaAudioContext implements IMotaAudioContext {
|
||||
return decoded;
|
||||
}
|
||||
|
||||
async probeAudio(
|
||||
source: AudioInputSource
|
||||
): Promise<IAudioFormatInfo | null> {
|
||||
return probeAudioSource(source);
|
||||
}
|
||||
|
||||
async createDecodeSession(
|
||||
source: AudioInputSource
|
||||
): Promise<IAudioDecodeSession | null> {
|
||||
const info = await this.probeAudio(source);
|
||||
if (!info) return null;
|
||||
if (info.codec !== AudioCodec.Opus) return null;
|
||||
const container = info.container;
|
||||
if (
|
||||
container !== AudioContainer.Ogg &&
|
||||
container !== AudioContainer.WebM
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return createOpusDecodeSession(source, info);
|
||||
}
|
||||
|
||||
async decodeAudio(data: Uint8Array): Promise<IAudioDecodeData | null> {
|
||||
const info = await this.probeAudio(data);
|
||||
if (info) {
|
||||
const native = await this.decodeNative(data);
|
||||
if (native) return this.convertAudioBuffer(native);
|
||||
const session = await this.createDecodeSession(data);
|
||||
if (session) {
|
||||
const decoded = await this.decodeSession(session);
|
||||
if (!decoded || decoded.errors.length > 0) {
|
||||
logger.error(25, this.getErrorHeaderInfo(data));
|
||||
return null;
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
}
|
||||
return this.decodeAudioLegacy(data);
|
||||
}
|
||||
|
||||
toAudioBuffer(data: IAudioDecodeData): AudioBuffer {
|
||||
const buffer = this.ac.createBuffer(
|
||||
data.channelData.length,
|
||||
@@ -432,18 +567,28 @@ export class MotaAudioContext implements IMotaAudioContext {
|
||||
}
|
||||
|
||||
async decodeToAudioBuffer(data: Uint8Array): Promise<AudioBuffer | null> {
|
||||
const info = await this.probeAudio(data);
|
||||
if (info) {
|
||||
const native = await this.decodeNative(data);
|
||||
if (native) return native;
|
||||
const session = await this.createDecodeSession(data);
|
||||
if (session) {
|
||||
const decoded = await this.decodeSession(session);
|
||||
if (!decoded || decoded.errors.length > 0) {
|
||||
logger.error(25, this.getErrorHeaderInfo(data));
|
||||
return null;
|
||||
}
|
||||
return this.toAudioBuffer(decoded);
|
||||
}
|
||||
}
|
||||
const type = this.getAudioTypeFromData(data);
|
||||
if (type === AudioType.Unknown) {
|
||||
logger.error(53, this.getErrorHeaderInfo(data));
|
||||
return null;
|
||||
}
|
||||
if (!(data.buffer instanceof ArrayBuffer)) return null;
|
||||
if (this.isAudioVanillaSupport(type)) {
|
||||
return this.ac.decodeAudioData(data.buffer);
|
||||
} else {
|
||||
const decoded = await this.decodeAudio(data);
|
||||
if (!decoded) return null;
|
||||
else return this.toAudioBuffer(decoded);
|
||||
}
|
||||
if (this.isAudioVanillaSupport(type)) return this.decodeNative(data);
|
||||
const legacy = await this.decodeAudioLegacy(data);
|
||||
if (!legacy) return null;
|
||||
return this.toAudioBuffer(legacy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
import { EncodedPacket, EncodedPacketSink, Input } from 'mediabunny';
|
||||
import { logger } from '@motajs/common';
|
||||
import {
|
||||
AudioInputSource,
|
||||
IAudioDecodeError,
|
||||
IAudioDecodedChunk,
|
||||
IAudioDecodeSession,
|
||||
IAudioFormatInfo
|
||||
} from './types';
|
||||
import { createMediaInput } from './probe';
|
||||
|
||||
interface IOpusIdentificationHeader {
|
||||
/** OpusHead 中声明的起始预跳过采样数,解码后需要丢弃 */
|
||||
readonly preSkip: number;
|
||||
/** 输出声道数 */
|
||||
readonly channels: number;
|
||||
/** 独立 Opus 流数量 */
|
||||
readonly streamCount: number;
|
||||
/** 耦合 Opus 流数量 */
|
||||
readonly coupledStreamCount: number;
|
||||
/** 输出声道到 Opus 流的映射表 */
|
||||
readonly channelMappingTable: number[];
|
||||
}
|
||||
|
||||
interface IOpusDecodedAudio {
|
||||
/** 每个声道的 PCM 数据 */
|
||||
readonly channelData: Float32Array[];
|
||||
/** 每个声道解码出的采样数 */
|
||||
readonly samplesDecoded: number;
|
||||
/** 解码后的采样率 */
|
||||
readonly sampleRate: number;
|
||||
/** 解码过程中产生的错误列表 */
|
||||
readonly errors: IAudioDecodeError[];
|
||||
}
|
||||
|
||||
interface IOpusDecoderOptions {
|
||||
/** Opus 输出采样率,固定为 48000 */
|
||||
readonly sampleRate: 48000;
|
||||
/** 输出声道数 */
|
||||
readonly channels: number;
|
||||
/** 起始处需要跳过的采样数 */
|
||||
readonly preSkip: number;
|
||||
/** 独立 Opus 流数量 */
|
||||
readonly streamCount: number;
|
||||
/** 耦合 Opus 流数量 */
|
||||
readonly coupledStreamCount: number;
|
||||
/** 输出声道到 Opus 流的映射表 */
|
||||
readonly channelMappingTable: number[];
|
||||
}
|
||||
|
||||
interface IOpusDecoderInstance {
|
||||
/** WASM 初始化完成的 Promise */
|
||||
readonly ready: Promise<void>;
|
||||
|
||||
/**
|
||||
* 解码单个 Opus 包
|
||||
* @param packet 待解码的 Opus 包
|
||||
* @returns 解码后的 PCM 数据,可能是同步值或 Promise
|
||||
*/
|
||||
decodeFrame(
|
||||
packet: Uint8Array
|
||||
): IOpusDecodedAudio | Promise<IOpusDecodedAudio>;
|
||||
|
||||
/**
|
||||
* 释放解码器占用的资源
|
||||
*/
|
||||
free(): void | Promise<void>;
|
||||
}
|
||||
|
||||
interface IOpusDecoderModule {
|
||||
/** 主线程 Opus 解码器构造函数 */
|
||||
readonly OpusDecoder: new (
|
||||
options: IOpusDecoderOptions
|
||||
) => IOpusDecoderInstance;
|
||||
/** Web Worker Opus 解码器构造函数 */
|
||||
readonly OpusDecoderWebWorker: new (
|
||||
options: IOpusDecoderOptions
|
||||
) => IOpusDecoderInstance;
|
||||
}
|
||||
|
||||
/** 缓存的 opus-decoder 动态导入 Promise,避免并发重复加载 */
|
||||
let opusModulePromise: Promise<IOpusDecoderModule> | null = null;
|
||||
|
||||
/**
|
||||
* 解析 Opus 识别头,缺少或非法时返回 null
|
||||
* @param description 解码器描述数据,即 OpusHead
|
||||
* @returns 解析得到的识别头,缺少或非法时为 null
|
||||
*/
|
||||
export function parseOpusIdentificationHeader(
|
||||
description: Uint8Array | null
|
||||
): IOpusIdentificationHeader | null {
|
||||
if (!description || description.length < 19) return null;
|
||||
const magic = new TextDecoder().decode(description.slice(0, 8));
|
||||
if (magic !== 'OpusHead') return null;
|
||||
const channelCount = description[9];
|
||||
if (channelCount < 1) return null;
|
||||
const view = new DataView(
|
||||
description.buffer,
|
||||
description.byteOffset,
|
||||
description.byteLength
|
||||
);
|
||||
const preSkip = view.getUint16(10, true);
|
||||
const mappingFamily = description[18];
|
||||
if (mappingFamily !== 0 && description.length < 21 + channelCount) {
|
||||
return null;
|
||||
}
|
||||
if (mappingFamily === 0) {
|
||||
return {
|
||||
preSkip,
|
||||
channels: channelCount,
|
||||
streamCount: 1,
|
||||
coupledStreamCount: channelCount - 1,
|
||||
channelMappingTable: channelCount === 2 ? [0, 1] : [0]
|
||||
};
|
||||
}
|
||||
const streamCount = description[19];
|
||||
const coupledStreamCount = description[20];
|
||||
const channelMappingTable: number[] = [];
|
||||
for (let i = 0; i < channelCount; i++) {
|
||||
channelMappingTable.push(description[21 + i]);
|
||||
}
|
||||
return {
|
||||
preSkip,
|
||||
channels: channelCount,
|
||||
streamCount,
|
||||
coupledStreamCount,
|
||||
channelMappingTable
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 OpusHead 配置并创建 Opus 解码器;浏览器使用 Worker 变体,Node 使用主线程变体
|
||||
* @param header 已解析的 Opus 识别头
|
||||
*/
|
||||
async function loadOpusDecoder(
|
||||
header: IOpusIdentificationHeader
|
||||
): Promise<IOpusDecoderInstance> {
|
||||
let pending = opusModulePromise;
|
||||
if (!pending) {
|
||||
pending = import('opus-decoder');
|
||||
opusModulePromise = pending;
|
||||
}
|
||||
const opus = await pending.catch(error => {
|
||||
// 加载失败时清空缓存,保证后续调用可以重试
|
||||
opusModulePromise = null;
|
||||
throw error;
|
||||
});
|
||||
const options: IOpusDecoderOptions = {
|
||||
sampleRate: 48000,
|
||||
channels: header.channels,
|
||||
preSkip: header.preSkip,
|
||||
streamCount: header.streamCount,
|
||||
coupledStreamCount: header.coupledStreamCount,
|
||||
channelMappingTable: header.channelMappingTable
|
||||
};
|
||||
const decoder: IOpusDecoderInstance =
|
||||
typeof Worker === 'undefined'
|
||||
? new opus.OpusDecoder(options)
|
||||
: new opus.OpusDecoderWebWorker(options);
|
||||
await decoder.ready;
|
||||
return decoder;
|
||||
}
|
||||
|
||||
export class OpusDecodeSession implements IAudioDecodeSession {
|
||||
readonly info: IAudioFormatInfo;
|
||||
readonly chunks: AsyncIterable<IAudioDecodedChunk>;
|
||||
|
||||
/** 会话持有的 mediabunny 输入,关闭会话时释放 */
|
||||
private readonly input: Input;
|
||||
/** 按包顺序读取编码数据的包读取器 */
|
||||
private readonly sink: EncodedPacketSink;
|
||||
/** 当前会话使用的 Opus 解码器实例 */
|
||||
private readonly decoder: IOpusDecoderInstance;
|
||||
/** 会话是否已关闭,用于中止异步迭代 */
|
||||
private closed: boolean = false;
|
||||
|
||||
constructor(
|
||||
input: Input,
|
||||
sink: EncodedPacketSink,
|
||||
info: IAudioFormatInfo,
|
||||
decoder: IOpusDecoderInstance
|
||||
) {
|
||||
this.input = input;
|
||||
this.sink = sink;
|
||||
this.info = info;
|
||||
this.decoder = decoder;
|
||||
this.chunks = this.generateChunks();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码单个 Opus 包,空包返回 null
|
||||
* @param packet 待解码的编码包
|
||||
*/
|
||||
private async decodePacket(
|
||||
packet: EncodedPacket
|
||||
): Promise<IAudioDecodedChunk | null> {
|
||||
const decoded = await this.decoder.decodeFrame(packet.data);
|
||||
// 零采样但带解码错误时需要保留错误,交给上层记录失败
|
||||
const isEmpty = decoded.samplesDecoded === 0;
|
||||
if (isEmpty && decoded.errors.length === 0) return null;
|
||||
return {
|
||||
channelData: decoded.channelData.map(
|
||||
channel => new Float32Array(channel)
|
||||
),
|
||||
samplesDecoded: decoded.samplesDecoded,
|
||||
sampleRate: decoded.sampleRate,
|
||||
timestamp: packet.timestamp,
|
||||
duration: packet.duration,
|
||||
errors: decoded.errors
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 顺序读取并解码全部 Opus 包,会话关闭后提前结束
|
||||
*/
|
||||
private async *generateChunks(): AsyncGenerator<IAudioDecodedChunk> {
|
||||
for await (const packet of this.sink.packets()) {
|
||||
if (this.closed) return;
|
||||
const chunk = await this.decodePacket(packet);
|
||||
if (chunk) yield chunk;
|
||||
}
|
||||
}
|
||||
|
||||
close(): void {
|
||||
if (this.closed) return;
|
||||
this.closed = true;
|
||||
this.input.dispose();
|
||||
this.decoder.free();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 Ogg / WebM Opus 创建整文件解码会话
|
||||
* @param source 音频输入数据
|
||||
* @param info 探测得到的格式信息
|
||||
*/
|
||||
export async function createOpusDecodeSession(
|
||||
source: AudioInputSource,
|
||||
info: IAudioFormatInfo
|
||||
): Promise<OpusDecodeSession | null> {
|
||||
const input = createMediaInput(source);
|
||||
if (!input) return null;
|
||||
const readable = await input.canRead();
|
||||
if (!readable) {
|
||||
input.dispose();
|
||||
logger.error(97);
|
||||
return null;
|
||||
}
|
||||
const track = await input.getPrimaryAudioTrack();
|
||||
if (!track) {
|
||||
input.dispose();
|
||||
logger.error(97);
|
||||
return null;
|
||||
}
|
||||
const config = await track.getDecoderConfig();
|
||||
if (!config || !(config.description instanceof Uint8Array)) {
|
||||
input.dispose();
|
||||
logger.error(97);
|
||||
return null;
|
||||
}
|
||||
const header = parseOpusIdentificationHeader(config.description);
|
||||
if (!header) {
|
||||
input.dispose();
|
||||
logger.error(97);
|
||||
return null;
|
||||
}
|
||||
const decoder = await loadOpusDecoder(header);
|
||||
const sink = new EncodedPacketSink(track);
|
||||
return new OpusDecodeSession(input, sink, info, decoder);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import {
|
||||
BlobSource,
|
||||
BufferSource,
|
||||
Input,
|
||||
OGG,
|
||||
UrlSource,
|
||||
WEBM
|
||||
} from 'mediabunny';
|
||||
import { logger } from '@motajs/common';
|
||||
import {
|
||||
AudioCodec,
|
||||
AudioContainer,
|
||||
AudioInputSource,
|
||||
IAudioFormatInfo
|
||||
} from './types';
|
||||
|
||||
// 只声明本 tracer 支持的容器格式,避免为其它格式付解析器体积
|
||||
const mediaFormats = [OGG, WEBM];
|
||||
|
||||
/**
|
||||
* 把统一的音频输入类型转换为 mediabunny 支持的数据源,不支持的输入返回 null
|
||||
* @param source 音频输入数据
|
||||
*/
|
||||
function createMediaSource(
|
||||
source: AudioInputSource
|
||||
): BufferSource | BlobSource | UrlSource | null {
|
||||
if (source instanceof ArrayBuffer) return new BufferSource(source);
|
||||
if (source instanceof Uint8Array) return new BufferSource(source);
|
||||
if (source instanceof Blob) return new BlobSource(source);
|
||||
if (typeof source === 'string') return new UrlSource(source);
|
||||
logger.warn(217, source.constructor.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用 Ogg / WebM 精选格式表创建一个 mediabunny 输入
|
||||
* @param source 音频输入数据
|
||||
*/
|
||||
export function createMediaInput(source: AudioInputSource): Input | null {
|
||||
const mediaSource = createMediaSource(source);
|
||||
if (!mediaSource) return null;
|
||||
return new Input({ formats: mediaFormats, source: mediaSource });
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 mediabunny 的编码字符串映射为本包的音频编码枚举
|
||||
* @param codec mediabunny 返回的编码字符串
|
||||
*/
|
||||
function toAudioCodec(codec: string | null): AudioCodec {
|
||||
switch (codec) {
|
||||
case 'opus':
|
||||
return AudioCodec.Opus;
|
||||
case 'vorbis':
|
||||
return AudioCodec.Vorbis;
|
||||
case 'aac':
|
||||
return AudioCodec.Aac;
|
||||
case 'mp3':
|
||||
return AudioCodec.Mp3;
|
||||
case 'flac':
|
||||
return AudioCodec.Flac;
|
||||
case 'pcm-s16':
|
||||
case 'pcm-s24':
|
||||
case 'pcm-s32':
|
||||
case 'pcm-f32':
|
||||
return AudioCodec.Pcm;
|
||||
default:
|
||||
return AudioCodec.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 探测音频数据的容器、编码、采样率、声道数与总时长
|
||||
* @param source 音频输入数据
|
||||
*/
|
||||
export async function probeAudioSource(
|
||||
source: AudioInputSource
|
||||
): Promise<IAudioFormatInfo | null> {
|
||||
const input = createMediaInput(source);
|
||||
if (!input) return null;
|
||||
const readable = await input.canRead();
|
||||
if (!readable) {
|
||||
input.dispose();
|
||||
return null;
|
||||
}
|
||||
const format = await input.getFormat();
|
||||
let container = AudioContainer.Unknown;
|
||||
if (format === OGG) container = AudioContainer.Ogg;
|
||||
else if (format === WEBM) container = AudioContainer.WebM;
|
||||
if (container === AudioContainer.Unknown) {
|
||||
// 已注册格式表只有 Ogg / WebM,走到这里说明探测结果异常
|
||||
input.dispose();
|
||||
logger.error(97);
|
||||
return null;
|
||||
}
|
||||
const track = await input.getPrimaryAudioTrack();
|
||||
if (!track) {
|
||||
input.dispose();
|
||||
logger.error(97);
|
||||
return null;
|
||||
}
|
||||
const codec = toAudioCodec(await track.getCodec());
|
||||
const sampleRate = await track.getSampleRate();
|
||||
const channels = await track.getNumberOfChannels();
|
||||
const duration = await input.computeDuration();
|
||||
input.dispose();
|
||||
return { container, codec, sampleRate, channels, duration };
|
||||
}
|
||||
@@ -467,7 +467,8 @@ export type AudioDecoderCreateFunc = (
|
||||
context: IMotaAudioContext
|
||||
) => IAudioDecoder;
|
||||
|
||||
export interface IMotaAudioContext extends IMotaAudioContextCreator {
|
||||
export interface IMotaAudioContext
|
||||
extends IMotaAudioContextCreator, IAudioDecodeProvider {
|
||||
/** 音频上下文 */
|
||||
readonly ac: AudioContext;
|
||||
/** 音频播放路由 */
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
"94": "Cannot parse animation: invalid sound $2 in frame $1, reason: '$3'.",
|
||||
"95": "Cannot parse animation: invalid metadata, reason: '$1'.",
|
||||
"96": "Cannot parse animation: image failed, reason: '$1'.",
|
||||
"97": "Cannot create audio decode session: the audio track or its decoder description is missing.",
|
||||
"2001": "Replay($1): Replay parameter count mismatch: expected $2, got $3.",
|
||||
"2002": "Replay($1): Replay parameter type mismatch: index $2, expected $3, got $4.",
|
||||
"2003": "Replay(move): Expected hero to be stopped before execute moving step.",
|
||||
@@ -322,6 +323,7 @@
|
||||
"214": "Range setting item get a number range that cannot be divided into integer by step: range=[$1, $2], step=$3. This may cause issues, please ensure number range can be divided by step evenly.",
|
||||
"215": "Cannot change canvas size or block size of size-freezed map renderer.",
|
||||
"216": "Expected all sequence curve arrays with a same length and larger than zero, but got: seq: $1, duration: $2, scale: $3, move: $4.",
|
||||
"217": "Unsupported audio input source type: '$1'.",
|
||||
"1001": "Event(setBlock): Unknown tile '$1' when setting block."
|
||||
}
|
||||
}
|
||||
Generated
+23
@@ -211,6 +211,9 @@ importers:
|
||||
maxrects-packer:
|
||||
specifier: ^2.7.3
|
||||
version: 2.7.3
|
||||
mediabunny:
|
||||
specifier: ^1.66.3
|
||||
version: 1.66.3
|
||||
ogg-opus-decoder:
|
||||
specifier: ^1.7.3
|
||||
version: 1.7.3
|
||||
@@ -2428,6 +2431,12 @@ packages:
|
||||
'@types/deep-eql@4.0.2':
|
||||
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
|
||||
|
||||
'@types/dom-mediacapture-transform@0.1.12':
|
||||
resolution: {integrity: sha512-d7/QsLRwF864A5mgIM/YrfiglHoYn7zgCcAoJgW404r+2DwnNr7EBbLnCWpmOMgH8y0te73L1AV6H1bmauaWFw==}
|
||||
|
||||
'@types/dom-webcodecs@0.1.13':
|
||||
resolution: {integrity: sha512-O5hkiFIcjjszPIYyUSyvScyvrBoV3NOEEZx/pMlsu44TKzWNkLVBBxnxJz42in5n3QIolYOcBYFCPZZ0h8SkwQ==}
|
||||
|
||||
'@types/estree@1.0.8':
|
||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||
|
||||
@@ -4768,6 +4777,9 @@ packages:
|
||||
resolution: {integrity: sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
mediabunny@1.66.3:
|
||||
resolution: {integrity: sha512-ugNU19umLxfjMaJLWKYUaFTWtmg+k0rwF6bmL5YfSX+BbCHGAOTxsecRzuHKX/OA+tO81pkI/2pNIo8nZdJZmA==}
|
||||
|
||||
mensch@0.3.4:
|
||||
resolution: {integrity: sha512-IAeFvcOnV9V0Yk+bFhYR07O3yNina9ANIN5MoXBKYJ/RLYPurd2d0yw14MDhpr9/momp0WofT1bPUh3hkzdi/g==}
|
||||
|
||||
@@ -8340,6 +8352,12 @@ snapshots:
|
||||
|
||||
'@types/deep-eql@4.0.2': {}
|
||||
|
||||
'@types/dom-mediacapture-transform@0.1.12':
|
||||
dependencies:
|
||||
'@types/dom-webcodecs': 0.1.13
|
||||
|
||||
'@types/dom-webcodecs@0.1.13': {}
|
||||
|
||||
'@types/estree@1.0.8': {}
|
||||
|
||||
'@types/express-serve-static-core@5.1.1':
|
||||
@@ -11182,6 +11200,11 @@ snapshots:
|
||||
|
||||
media-typer@1.1.0: {}
|
||||
|
||||
mediabunny@1.66.3:
|
||||
dependencies:
|
||||
'@types/dom-mediacapture-transform': 0.1.12
|
||||
'@types/dom-webcodecs': 0.1.13
|
||||
|
||||
mensch@0.3.4: {}
|
||||
|
||||
meow@13.2.0: {}
|
||||
|
||||
Reference in new issue
Block a user