mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 16:11:20 -08:00
fix(vtt-thumbnail): [PKG-VTT-THUMB-04] preserve historical type shapes
This commit is contained in:
1 parent
c4c7491e16
commit
58d2c95d8e
16 files changed
+235
-57
No files matched your search
@@ -58,21 +58,29 @@ legacy parameter/result/factory extraction, replacement factories and accurate a
|
||||
through `/runtime`, including negative cases. The source factory explicitly returns Promise;
|
||||
its final assertion only describes the self-reference that Object.assign creates.
|
||||
|
||||
Root and legacy use paired `.d.mts`/`.d.cts` default declarations. `/runtime` uses an ESM
|
||||
default and a CommonJS export assignment, supporting direct and `.default` require calls.
|
||||
Classic resolution uses `.d.ts` and typesVersions, including TypeScript 4.3. The generated
|
||||
Root and legacy select the original `.d.ts` shape in every export condition, preserving
|
||||
latest npm 1.1.0's NodeNext ESM namespace and plain factory replacements. Do not add a
|
||||
required self alias or silently make the root ESM namespace callable. Previously added
|
||||
root `.d.mts`/`.d.cts` files remain packaged but are not selected by these entrypoints.
|
||||
`/runtime` uses an ESM default and a CommonJS export assignment, supporting direct and
|
||||
`.default` calls. Its Node10 `.d.ts` also uses export=, including raw require without
|
||||
interop on TS 4.3/5.9. Each runtime declaration exports the same four named types.
|
||||
Classic resolution uses typesVersions. The generated
|
||||
editor global retains the legacy callable type; its RuntimeFactory namespace member is only
|
||||
a type, not an additional runtime global. Do not hand-edit generated editor declarations.
|
||||
|
||||
The installed-consumer command packs both core and plugin, installs outside the workspace,
|
||||
verifies member hashes, and repeats an offline frozen install. It tests five actual old npm
|
||||
declarations in five modes on TS 4.3/5.9 and seven candidate modes: 32 default-import cells,
|
||||
including one expected 1.1.0 NodeNext ESM declaration failure. Candidate ESM passes that cell.
|
||||
including one expected 1.1.0 raw NodeNext ESM declaration failure. Candidate root keeps
|
||||
the old namespace shape and verifies its legal calls and whole-module replacements;
|
||||
accurate direct ESM calls use /runtime. Negative cases are checked at their exact lines.
|
||||
Another 36 direct/default CommonJS extraction/replacement forms reproduce the opposing 1.0.x
|
||||
export-assignment and 1.1.0 default declaration shapes. Candidate preserves the latter.
|
||||
Earlier type-only direct module extraction remains an explicit decision in task 04; a broken
|
||||
historical JS direct call does not waive that type-only consumer. See the module-forms change
|
||||
record for the concrete required/optional default-property alternatives and migration proposal.
|
||||
Earlier type-only direct module extraction now follows the user's approved rule in
|
||||
../../refactor/type-compatibility-policy.md: keep latest 1.1.0 types and document the
|
||||
1.0.x export= migration without changing valid JavaScript behavior. Historical failures
|
||||
remain in the installed reports; runtime failures never stand in for type evidence.
|
||||
|
||||
## Compatibility and intentional fixes
|
||||
|
||||
@@ -102,9 +110,9 @@ plugin. Empty or comment-only input remains a valid empty preview.
|
||||
|
||||
The exported callable has a writable self `.default` alias, restoring the usable 1.0.x
|
||||
CommonJS default access while retaining direct calls. It does not add a name property to the
|
||||
registration Promise. Earlier `thumbnails` control names and remaining historical declaration
|
||||
forms are separately frozen and remain compatibility work for tasks 04-06. The full package
|
||||
refactor is not yet finished.
|
||||
registration Promise. Earlier `thumbnails` control names are separately frozen and remain
|
||||
combination/distribution work for tasks 05-06. The approved declaration migration does not
|
||||
complete the remaining package or device acceptance.
|
||||
|
||||
## Verification and future changes
|
||||
|
||||
|
||||
@@ -27,6 +27,33 @@ returned a Promise at runtime. Reading `result.name` requires awaiting registrat
|
||||
to `/runtime` opts into that accurate type without changing runtime behavior. The option
|
||||
object remains required, and its `vtt` and `style` fields remain optional.
|
||||
|
||||
The root factory keeps the latest published 1.1.0 type shape, with no required `.default`
|
||||
property. Plain replacement functions remain assignable in both directions. `/runtime`
|
||||
exports `Option`, `Result`, `Factory` and `RuntimeFactory` in all resolution modes; its
|
||||
factory describes the actual writable `.default` self alias and asynchronous registration.
|
||||
|
||||
### Earlier declaration migration
|
||||
|
||||
The 1.0.x declarations used `export =`, while 1.1.0 uses `export default`. Following the
|
||||
approved compatibility policy, the root retains 1.1.0. Older TypeScript code that directly
|
||||
calls or extracts the type of `import vtt = require('artplayer-plugin-vtt-thumbnail')`
|
||||
should use the accurate runtime entry:
|
||||
|
||||
```ts
|
||||
import vtt = require('artplayer-plugin-vtt-thumbnail/runtime')
|
||||
|
||||
const register = vtt({ vtt: '/thumbnails/index.vtt' })
|
||||
const result = await register(art)
|
||||
console.log(result.name)
|
||||
```
|
||||
|
||||
This export-assignment form supports Node10 resolution without `esModuleInterop`.
|
||||
Default `/runtime` imports support interoperability and native NodeNext ESM. Root
|
||||
NodeNext ESM intentionally preserves the old declaration namespace shape (the factory
|
||||
is `root.default` after a default import); that historical declaration does not accurately
|
||||
describe the actual ESM export. Use `/runtime` for accurate ESM calls. Valid historical
|
||||
JavaScript default access, the direct factory, and legacy distribution entrypoints remain.
|
||||
|
||||
See [ARCHITECTURE.md](ARCHITECTURE.md) for module ownership, testing commands and remaining
|
||||
compatibility validation.
|
||||
|
||||
|
||||
@@ -19,24 +19,14 @@
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./types/artplayer-plugin-vtt-thumbnail.d.mts",
|
||||
"default": "./dist/artplayer-plugin-vtt-thumbnail.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/artplayer-plugin-vtt-thumbnail.d.cts",
|
||||
"default": "./dist/artplayer-plugin-vtt-thumbnail.js"
|
||||
}
|
||||
"types": "./types/artplayer-plugin-vtt-thumbnail.d.ts",
|
||||
"import": "./dist/artplayer-plugin-vtt-thumbnail.mjs",
|
||||
"require": "./dist/artplayer-plugin-vtt-thumbnail.js"
|
||||
},
|
||||
"./legacy": {
|
||||
"import": {
|
||||
"types": "./types/artplayer-plugin-vtt-thumbnail.d.mts",
|
||||
"default": "./dist/artplayer-plugin-vtt-thumbnail.legacy.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/artplayer-plugin-vtt-thumbnail.d.cts",
|
||||
"default": "./dist/artplayer-plugin-vtt-thumbnail.legacy.js"
|
||||
}
|
||||
"types": "./types/artplayer-plugin-vtt-thumbnail.d.ts",
|
||||
"import": "./dist/artplayer-plugin-vtt-thumbnail.legacy.js",
|
||||
"require": "./dist/artplayer-plugin-vtt-thumbnail.legacy.js"
|
||||
},
|
||||
"./runtime": {
|
||||
"import": {
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import type { RuntimeFactory } from './artplayer-plugin-vtt-thumbnail.js'
|
||||
|
||||
declare const artplayerPluginVttThumbnail: RuntimeFactory
|
||||
// eslint-disable-next-line ts/no-redeclare -- Ambient merge exposes types on the CommonJS factory.
|
||||
declare namespace artplayerPluginVttThumbnail {
|
||||
type Option = import('./artplayer-plugin-vtt-thumbnail.js').Option
|
||||
type Result = import('./artplayer-plugin-vtt-thumbnail.js').Result
|
||||
type Factory = import('./artplayer-plugin-vtt-thumbnail.js').Factory
|
||||
type RuntimeFactory = import('./artplayer-plugin-vtt-thumbnail.js').RuntimeFactory
|
||||
}
|
||||
export = artplayerPluginVttThumbnail
|
||||
@@ -2,4 +2,4 @@ import type { RuntimeFactory } from './artplayer-plugin-vtt-thumbnail.js'
|
||||
|
||||
declare const artplayerPluginVttThumbnail: RuntimeFactory
|
||||
export default artplayerPluginVttThumbnail
|
||||
export type { Option, Result, RuntimeFactory } from './artplayer-plugin-vtt-thumbnail.js'
|
||||
export type { Factory, Option, Result, RuntimeFactory } from './artplayer-plugin-vtt-thumbnail.js'
|
||||
@@ -1,5 +1,11 @@
|
||||
import type { RuntimeFactory } from './artplayer-plugin-vtt-thumbnail.js'
|
||||
|
||||
declare const artplayerPluginVttThumbnail: RuntimeFactory
|
||||
export default artplayerPluginVttThumbnail
|
||||
export type { Option, Result, RuntimeFactory } from './artplayer-plugin-vtt-thumbnail.js'
|
||||
// eslint-disable-next-line ts/no-redeclare -- Ambient merge exposes types on the CommonJS factory.
|
||||
declare namespace artplayerPluginVttThumbnail {
|
||||
type Option = import('./artplayer-plugin-vtt-thumbnail.js').Option
|
||||
type Result = import('./artplayer-plugin-vtt-thumbnail.js').Result
|
||||
type Factory = import('./artplayer-plugin-vtt-thumbnail.js').Factory
|
||||
type RuntimeFactory = import('./artplayer-plugin-vtt-thumbnail.js').RuntimeFactory
|
||||
}
|
||||
export = artplayerPluginVttThumbnail
|
||||
Reference in new issue
Block a user