fix(thumbnail): [PKG-TOOL-THUMB-03] own input resources and separate sheet export

This commit is contained in:
Harvey Zhao committed 2026-09-13 03:51:26 +08:00
1 parent 1cb7779192
commit 426c0c5d42
22 files changed
+13724 -256

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,71 @@
# PKG-TOOL-THUMB-03 input and sheet checkpoint
Started from 1cb7779192cf552c0dfabcbb6de4f26b39e33045. Task 03 remains **doing**:
this checkpoint changes production input ownership and separates sheet/export
logic; extraction jobs and source/Blob cancellation still need implementation.
## Source changes and compatibility
`src/input.js` owns generated inputs, wrapper positioning and registered callbacks
in a private WeakMap. Setup validates before mutating committed options/DOM,
reuses an existing owned wrapper input, installs replacement listeners and then
cleans up the previous target. Caller-provided file inputs are retained. Failed
registration removes partial new listeners; failed construction rolls back owned
input/video resources. The historical instance ondrop method is now actually
registered for drop events. This repairs the undefined static callback defect.
Destroy is idempotent and attempts all input/video/current-URL/event cleanup even
when a cleanup step throws. It preserves the first cleanup failure. Mutating the
public option field does not erase the input ownership record. After destruction,
setup/inputChange/ondrop/loadVideo cannot allocate new input/source resources.
Wrapper position is restored only when it still matches the tool's relative write.
`src/sheet.js` contains midpoint coordinates, footer/canvas creation and download
anchor handling. Historical calculations, attribution, creat* spellings and
filename behavior stay unchanged. Download removes its temporary anchor even if
click fails. The public class delegates existing methods rather than adding new
public entry points. Constructor fields/order, direct class exports, defaults,
event timing and chaining remain covered. Runtime source is still JS pending 04;
emitter provenance and public declarations are not claimed complete.
The package now has an actual ARCHITECTURE.md map, maintenance commands, ownership
rules and explicit continuation boundaries. Normal package builds regenerate
main/legacy/ESM plus docs copies. No hand editing of generated artifacts occurs.
## Evidence
`test/thumbnail-input.test.js` adds 14 candidate regressions. The unchanged tests
on frozen workspace main produce **2 passes/12 failures**. Source and both built
UMD variants pass all 14. These include real defect contrasts and compatibility
checks, not only assertions that new helper functions exist.
Browser candidate coverage is added alongside frozen implementations. A separate
native DOM test selects files through generated inputs, replaces/reuses wrappers,
dispatches events to old detached inputs, verifies listener removal, restores
styles and verifies cleanup when a destroy listener throws. It runs without
requiring Blob media decoding and therefore also executes on Windows WebKit.
Each source/main/legacy run contains 54 rows: 32 actual tool scenarios in
Chromium/Firefox across old and candidate versions, 3 candidate input/DOM scenarios
across all engines, 16 Windows WebKit Blob-unavailable controls and 3 native media
comparison tests. The 16 controls are not successful extraction. Old defect rows
remain unchanged; candidate drop and repeated-destroy expectations reflect fixes.
The candidate late-Blob and replacement-URL scenarios still reproduce outstanding
03 defects, explicitly preventing a claim of complete lifecycle repair.
Final logs, per-case measurements, artifact hashes and CI results are recorded in
`refactor/baselines/thumbnail-input-checkpoint.json`. The current coverage policy
only measures core/chapter; no thumbnail coverage percentage is claimed here.
No hosted CI, physical Safari acceptance, npm publish or version bump occurred.
## Remaining work and rollback
Finish 03 with owned metadata waiting, extraction jobs, native error handling,
source/thumbnail URL lifetime and cancellation/late-callback protection. The
current pending extraction behavior is intentionally not declared fixed. Test
failure-path reentrancy during constructor/setup cleanup as part of that ownership
pass. Preserve the frozen default delay/height conflict until a concrete policy
is documented. Task 04 owns strict TS, emitter attribution and missing types;
05/06 retain full media/core integration, Safari/WebKit and distribution gates.
All thumbnail risks remain open. Revert this checkpoint and run the normal package
build to roll back the input/sheet change. The task completion count does not change.
+3 -2
View File
@@ -4,7 +4,7 @@
基线:`40fcda6a37d0049d42e49c1e64e70d4fd9ba5f7f`。总任务 222 项,范围 22 个包及工作区/示例。
状态:todo 101 / doing 10 / blocked 0 / done 111 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。
状态:todo 100 / doing 11 / blocked 0 / done 111 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。
前置依赖是启动条件;验收是完成条件。任务可以继续拆分,但不能复用或悄悄删除旧 ID。
@@ -357,7 +357,7 @@
| --- | --- | --- | --- | --- | --- | --- |
| PKG-TOOL-THUMB-01 | artplayer-tool-thumbnail<br>核对包契约与历史用法 | BASE-05 | 构造/defaults/事件/方法/历史拼写、.esm.js 入口和缺失 types | 源码/声明/README/demo/可恢复发布内容差异已登记;公开形状和版本范围冻结;区分旧 npm 的 main/CSS 与当前工作区无 main、.esm.js/类型缺失,不把工作区状态冒称旧 npm 发布事实 | H | done |
| PKG-TOOL-THUMB-02 | artplayer-tool-thumbnail<br>建立特有行为与错误测试 | PKG-TOOL-THUMB-01, ENG-03, ENG-05 | 文件输入/拖放、抽帧网格、begin/end、进度/失败/重复任务 | 旧版本行为可重跑,成功/失败/切源/销毁有必要断言 | H | done |
| PKG-TOOL-THUMB-03 | artplayer-tool-thumbnail<br>整理内部职责与资源 | PKG-TOOL-THUMB-02, CORE-01 | 输入、抽帧队列、网格导出、URL/监听清理分离 | 结构变化和缺陷修复分开记录;原 API/事件/资源生命周期通过 | H | todo |
| PKG-TOOL-THUMB-03 | artplayer-tool-thumbnail<br>整理内部职责与资源 | PKG-TOOL-THUMB-02, CORE-01 | 输入、抽帧队列、网格导出、URL/监听清理分离 | 结构变化和缺陷修复分开记录;原 API/事件/资源生命周期通过 | H | doing |
| PKG-TOOL-THUMB-04 | artplayer-tool-thumbnail<br>迁移自有源码和公开类型 | PKG-TOOL-THUMB-03, ENG-04, ENG-06, CORE-07 | 补齐真实 API 声明,自有 emitter/utils TS 化 | 严格类型检查、旧消费样例通过;声明路径/导出和同步异步兼容;为 BASE-DIST-01 提供兼容入口/声明及消费者验证 | H | todo |
| PKG-TOOL-THUMB-05 | artplayer-tool-thumbnail<br>验证新旧核心和组合 | PKG-TOOL-THUMB-04, CORE-22 | 工具独立浏览器使用,生成缩略图在核心中显示 | 最终核心与原支持范围核心分别通过;设备/SDK 缺证据不能标完成 | H | todo |
| PKG-TOOL-THUMB-06 | artplayer-tool-thumbnail<br>验证分发并同步文档 | PKG-TOOL-THUMB-05, ENG-07 | tool.thumbnail.js、历史 ESM 兼容文件、types 路径和 tarball | tarball 入口/资源、类型、8082 demo 和 README 一致,有回退记录 | H | todo |
@@ -537,4 +537,5 @@
- PKG-IFRAME-05: [记录](changes/2026-09-13-PKG-IFRAME-05-integration.md) [记录](baselines/iframe-integration-validation.json) [记录](changes/2026-09-13-PKG-IFRAME-05-history.md) [记录](baselines/iframe-history-validation.json)
- PKG-TOOL-THUMB-01: [记录](baselines/thumbnail-release.json) [记录](baselines/thumbnail-contract.md) [记录](changes/2026-09-13-PKG-TOOL-THUMB-01-contract.md) [记录](baselines/thumbnail-contract-validation.json)
- PKG-TOOL-THUMB-02: [记录](baselines/thumbnail-behavior-validation.json) [记录](changes/2026-09-13-PKG-TOOL-THUMB-02-behavior.md)
- PKG-TOOL-THUMB-03: [记录](changes/2026-09-13-PKG-TOOL-THUMB-03-input-checkpoint.md) [记录](baselines/thumbnail-input-checkpoint.json)
- PKG-FACTORY-01: [记录](baselines/factory-assignment-gaps.json) [记录](baselines/factory-compatibility-proposals.json) [记录](factory-compatibility-decision.md) [记录](changes/2026-09-12-PKG-FACTORY-01-decision.md)
+12
View File
@@ -1,5 +1,17 @@
# 进度与证据
## PKG-TOOL-THUMB-03 输入与导出源码检查点(doing)
生产入口拆出input/sheet模块,修复drop注册、输入切换与wrapper所有权、构造/安装失败
回滚、重复destroy及下载锚点清理;新增包内ARCHITECTURE.md。公开字段/方法/defaults
和正常事件顺序保持。14项新回归在旧版2通过/12失败,源码/main/legacy各14通过。
三份浏览器各54项通过:32真实工具场景、3候选原生输入场景、16WebKit Blob不可用
对照、3原生媒体对照;不把不可用对照算作成功抽帧。正常构建同步dist/docs副本。
完整CI1620、330生产TS与3导入测试通过。队列/URL取消、迟到Blob和失败重入仍需继续,
本项不标done;04负责最终TS与声明。见[变更](changes/2026-09-13-PKG-TOOL-THUMB-03-input-checkpoint.md)
和[验证](baselines/thumbnail-input-checkpoint.json)。222项:111 done、11 doing、100 todo。
## PKG-TOOL-THUMB-02 完成:抽帧、失败与资源基线
新增36项历史抽帧/生命周期测试,与26项契约共同通过;普通CI已接入新测试。
+7 -2
View File
@@ -3879,7 +3879,7 @@
"PKG-TOOL-THUMB-03",
"PKG-TOOL-THUMB-05"
],
"compatibleResolution": "36 frozen behavior tests reproduce timer/input/source/callback ownership gaps and historical error ordering. Actual Chromium/Firefox native Blob callbacks prove late update and URL leaks after destroy. Task 03 must add corrected candidate regressions and owned cleanup; 05 retains real integration acceptance.",
"compatibleResolution": "03 input checkpoint fixes registered drop, input/wrapper ownership, failed setup/construction cleanup, repeated destroy and temporary download anchors. Candidate input regressions contrast 12 old failures; source/main/legacy verify preserved shape. Pending extraction callbacks, source URL replacement, cancellation and failure reentrancy remain open for the rest of 03 and real integration in 05.",
"closureCriteria": "Deterministic old failure/candidate success for replacement, error and destruction plus real media/browser resource validation.",
"status": "open",
"evidence": [
@@ -3889,7 +3889,12 @@
"refactor/baselines/thumbnail-behavior-validation.json",
"refactor/changes/2026-09-13-PKG-TOOL-THUMB-02-behavior.md",
"test/thumbnail.test.js",
"test/browser/thumbnail-tool.spec.js"
"test/browser/thumbnail-tool.spec.js",
"refactor/changes/2026-09-13-PKG-TOOL-THUMB-03-input-checkpoint.md",
"packages/artplayer-tool-thumbnail/ARCHITECTURE.md",
"test/thumbnail-input.test.js",
"test/browser/thumbnail-input.spec.js",
"refactor/baselines/thumbnail-input-checkpoint.json"
]
},
{
+5 -2
View File
@@ -3785,11 +3785,14 @@
"PKG-TOOL-THUMB-02",
"CORE-01"
],
"status": "todo",
"status": "doing",
"risk": "H",
"deliverable": "输入、抽帧队列、网格导出、URL/监听清理分离",
"acceptance": "结构变化和缺陷修复分开记录;原 API/事件/资源生命周期通过",
"evidence": []
"evidence": [
"changes/2026-09-13-PKG-TOOL-THUMB-03-input-checkpoint.md",
"baselines/thumbnail-input-checkpoint.json"
]
},
{
"id": "PKG-TOOL-THUMB-04",