mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 10:31:20 -08:00
fix(types): PKG-CHAPTER-04 preserve CJS ESM and legacy consumer contracts
This commit is contained in:
1 parent
48660c4e12
commit
bab80ff886
41 files changed
+1087
-119
No files matched your search
@@ -15,6 +15,7 @@ method; the update object is required. All implementation modules are TypeScript
|
||||
| `src/types.ts` | Internal aliases derived from the existing public declaration; no runtime imports |
|
||||
| `src/style.less` | Existing CSS classes and theme variables |
|
||||
| `types/artplayer-plugin-chapter.d.ts` | Consumer declaration and compatibility boundary |
|
||||
| `types/*.d.cts`, `types/*.d.mts` | CJS/ESM bridges sharing the same public types |
|
||||
|
||||
Dependencies flow from the entry to normalization and rendering. Neither of those
|
||||
modules receives an ArtPlayer instance. Rendering accepts a progress container and
|
||||
@@ -82,7 +83,9 @@ For UI, start at progress.ts/style.less and verify real mouse interaction. For e
|
||||
or cleanup changes, start at index.ts and rerun early destroy/multiple-instance tests.
|
||||
Any public declaration change also needs new/old compiler and tarball consumers.
|
||||
|
||||
The public declaration is intentionally retained during the structural migration;
|
||||
PKG-CHAPTER-04 owns NodeNext ESM and legacy subpath declaration fixes. The frozen
|
||||
The public declaration remains available to old compilers and exports Chapters,
|
||||
Option and Result as types. Modern import/require conditions select format-specific
|
||||
bridges; typesVersions provides the legacy subpath to old resolvers. All bridges
|
||||
refer to one contract and runtime import paths stay unchanged. The frozen
|
||||
published baseline is under refactor/baselines; never overwrite it with candidate
|
||||
behavior. Physical device, full editor and final release checks remain separate tasks.
|
||||
@@ -22,6 +22,10 @@ The registered name is `artplayerPluginChapter`. After metadata loads, use
|
||||
`update({})` to clear them. Update is synchronous and requires an options object.
|
||||
Chapter times are seconds; ranges must not overlap. `Infinity` as an end value uses the current duration.
|
||||
|
||||
TypeScript users can import `Chapters`, `Option` and `Result` with `import type`.
|
||||
Modern ESM/CommonJS and `/legacy` share the same API; old TypeScript resolution
|
||||
keeps the original `.d.ts` entry and a legacy subpath fallback.
|
||||
|
||||
The existing implementation sorts and fills the supplied array in place and replaces its Infinity end
|
||||
values. Pass a fresh array when you need to retain the original configuration. After switching media,
|
||||
call update with chapters appropriate to the new duration; initialization listens to metadata once.
|
||||
|
||||
@@ -19,19 +19,36 @@
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./types/artplayer-plugin-chapter.d.ts",
|
||||
"import": "./dist/artplayer-plugin-chapter.mjs",
|
||||
"require": "./dist/artplayer-plugin-chapter.js"
|
||||
"import": {
|
||||
"types": "./types/artplayer-plugin-chapter.d.mts",
|
||||
"default": "./dist/artplayer-plugin-chapter.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/artplayer-plugin-chapter.d.cts",
|
||||
"default": "./dist/artplayer-plugin-chapter.js"
|
||||
}
|
||||
},
|
||||
"./legacy": {
|
||||
"types": "./types/artplayer-plugin-chapter.d.ts",
|
||||
"import": "./dist/artplayer-plugin-chapter.legacy.js",
|
||||
"require": "./dist/artplayer-plugin-chapter.legacy.js"
|
||||
"import": {
|
||||
"types": "./types/artplayer-plugin-chapter.d.cts",
|
||||
"default": "./dist/artplayer-plugin-chapter.legacy.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/artplayer-plugin-chapter.d.cts",
|
||||
"default": "./dist/artplayer-plugin-chapter.legacy.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/artplayer-plugin-chapter.js",
|
||||
"module": "./dist/artplayer-plugin-chapter.mjs",
|
||||
"types": "./types/artplayer-plugin-chapter.d.ts",
|
||||
"legacy": "./dist/artplayer-plugin-chapter.legacy.js",
|
||||
"browserslist": "last 1 Chrome version"
|
||||
"browserslist": "last 1 Chrome version",
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"legacy": [
|
||||
"types/artplayer-plugin-chapter.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts", "src/**/*.cts", "types/**/*.d.ts", "../../types/assets.d.ts"]
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.mts", "src/**/*.cts", "types/**/*.d.ts", "types/**/*.d.mts", "types/**/*.d.cts", "../../types/assets.d.ts"]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type * as Definition from './artplayer-plugin-chapter.js'
|
||||
|
||||
declare const artplayerPluginChapter: typeof Definition.default
|
||||
|
||||
declare namespace artplayerPluginChapter {
|
||||
type Chapters = Definition.Chapters
|
||||
type Option = Definition.Option
|
||||
type Result = Definition.Result
|
||||
}
|
||||
|
||||
export = artplayerPluginChapter
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default } from './artplayer-plugin-chapter.cjs'
|
||||
export type { Chapters, Option, Result } from './artplayer-plugin-chapter.js'
|
||||
@@ -1,16 +1,16 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
|
||||
type Chapters = {
|
||||
export type Chapters = {
|
||||
start: number
|
||||
end: number
|
||||
title: string
|
||||
}[]
|
||||
|
||||
interface Option {
|
||||
export interface Option {
|
||||
chapters?: Chapters
|
||||
}
|
||||
|
||||
interface Result {
|
||||
export interface Result {
|
||||
name: 'artplayerPluginChapter'
|
||||
update: (option: Option) => void
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user