mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 13:51:20 -08:00
refactor(dash): [PKG-DASH-04] migrate strict TypeScript and compatible declarations
This commit is contained in:
1 parent
7de04573b6
commit
6840544e0e
38 files changed
+1744
-102
No files matched your search
@@ -8,18 +8,20 @@ destroys it, changes its source, or adds a runtime dependency on dash.js.
|
||||
|
||||
## Module map
|
||||
|
||||
| File | Responsibility |
|
||||
| --- | --- |
|
||||
| `src/index.js` | Deferred installation, media identity, update revisions, event subscription and cleanup |
|
||||
| `src/sdk.js` | 4.x qualityIndex vs 5.x representation ID access and manual/Auto selection |
|
||||
| `src/mapping.js` | Names, current item matching, duplicate labels and selector ordering |
|
||||
| `src/menu.js` | Existing control/setting registries, menu ownership and guarded selection callbacks |
|
||||
| `src/audio.svg`, `src/quality.svg` | Existing setting icons |
|
||||
| `types/artplayer-plugin-dash-control.d.ts` | Existing public declarations; precise TS migration follows in PKG-DASH-04 |
|
||||
| File | Responsibility |
|
||||
| ------------------------------------------ | --------------------------------------------------------------------------------------- |
|
||||
| `src/index.ts` | Deferred installation, media identity, update revisions, event subscription and cleanup |
|
||||
| `src/sdk.ts` | 4.x qualityIndex vs 5.x representation ID access and manual/Auto selection |
|
||||
| `src/mapping.ts` | Names, current item matching, duplicate labels and selector ordering |
|
||||
| `src/menu.ts` | Existing control/setting registries, menu ownership and guarded selection callbacks |
|
||||
| `src/audio.svg`, `src/quality.svg` | Existing setting icons |
|
||||
| `types/artplayer-plugin-dash-control.d.ts` | Public options, generic SDK inputs and callable result |
|
||||
|
||||
Dependencies flow from the entry into mapping/menu, and from mapping into the SDK
|
||||
adapter. Mapping has no DOM dependency. Menu receives a model and validity callback;
|
||||
it does not choose SDK versions. This is the structural step, still in JavaScript.
|
||||
it does not choose SDK versions. All five owned modules are checked with strict
|
||||
TypeScript, noUncheckedIndexedAccess, and skipLibCheck=false; there are no remaining
|
||||
owned JavaScript modules in this package.
|
||||
|
||||
## Selection and lifetime
|
||||
|
||||
@@ -54,6 +56,36 @@ Keep `dash-quality`/`dash-audio`, selector shape, right control placement/paddin
|
||||
setting width/icons, defaults and unbound getName calls compatible. Do not use a
|
||||
filtered representation array index or absoluteIndex as the SDK 5 selection key.
|
||||
|
||||
## Types and compatibility
|
||||
|
||||
`src/types.ts` describes the narrow SDK and registry surfaces, menu models, event
|
||||
names, labels, and cleanup callbacks. SDK keys may be absent in malformed external
|
||||
data; the internal types retain that possibility instead of asserting every value
|
||||
exists. SDK methods are optional by generation. Non-null assertions in `sdk.ts`
|
||||
preserve the selected method family's historical synchronous failure when a caller
|
||||
provides an incomplete SDK. They do not validate the whole SDK at runtime.
|
||||
|
||||
The entry casts only the externally augmented ArtPlayer boundary to the narrow host.
|
||||
The non-empty track check protects the fallback item. Quality sorting casts apply
|
||||
before the synthetic Auto row is appended, and the manual selection key cast follows
|
||||
the Auto branch check. These assertions do not generate runtime conversions or mask
|
||||
the controlled error/identity tests. Changes to SDK capability detection belong in
|
||||
`sdk.ts`, not in a global `any` or ambient module escape.
|
||||
|
||||
Public `Config`, `Option`, `QualityLevel`, `AudioTrack`, and `Result` are named types.
|
||||
Default callbacks infer known SDK fields; explicit generic parameters or callback
|
||||
annotations accept a caller's more detailed SDK interfaces. Original object-based
|
||||
formatters remain valid. The optional overload supports omitted/undefined options;
|
||||
the last required overload preserves historical `Parameters<typeof factory>[0]`.
|
||||
Formatters still receive exactly one argument and return a string; update returns
|
||||
void synchronously. No global augmentation claims every ArtPlayer has a DASH SDK.
|
||||
|
||||
The historical `.d.ts` path stays available. `.d.cts` exports a callable CommonJS
|
||||
value with a type namespace; `.d.mts` bridges ESM default/named types. Runtime root
|
||||
and legacy paths are unchanged. `typesVersions` supports old Node10 type resolution
|
||||
for the legacy subpath. The online editor declaration is generated by `yarn build:ts`
|
||||
and checked standalone against both TS 4.3.5 and 5.9.3, then consumed by real Monaco.
|
||||
|
||||
## Validation and next work
|
||||
|
||||
Run at the workspace root with pinned Node and Yarn:
|
||||
@@ -62,6 +94,9 @@ Run at the workspace root with pinned Node and Yarn:
|
||||
yarn test:dash-control
|
||||
yarn build artplayer-plugin-dash-control
|
||||
yarn test:browser test/browser/dash-control.spec.js --trace on
|
||||
yarn test:browser test/browser/dash-editor-types.spec.js --trace on
|
||||
yarn build:ts
|
||||
yarn test:dash-types-package
|
||||
yarn ci:check
|
||||
```
|
||||
|
||||
@@ -71,6 +106,14 @@ contracts and lifecycle tests; use the operating system's path delimiter.
|
||||
and result/trace directory before running another suite because the output is shared.
|
||||
|
||||
Tests use frozen npm 1.1.0, a frozen pre-refactor 5.x implementation, and candidates.
|
||||
`test/types/dash-source.ts` checks source/public factory compatibility;
|
||||
`test/types/dash-control.ts` covers module modes and rejects invalid calls. The
|
||||
legacy fixture is checked against the actual published declaration and candidate.
|
||||
`test:dash-types-package` packs the current core and DASH with Yarn, installs the
|
||||
tarballs offline outside the workspace, repeats a frozen install and checks all
|
||||
public type modes without resolving any workspace source. It also verifies that
|
||||
implementation files/config do not leak into the archive. This is type acceptance;
|
||||
the full installed runtime and SDK release matrix still belongs to PKG-DASH-06/05.
|
||||
Browser tests exercise real old/new core DOM, menu clicks, native MP4 and cleanup,
|
||||
with controlled SDK methods. They do not load dash.js or test MPD/ABR decoding.
|
||||
PKG-DASH-05 must verify pinned dash.js 4.5.2 and 5.2.1 with real adaptive media and
|
||||
|
||||
Reference in new issue
Block a user