mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
refactor(core): [CORE-21] generate compatible public and editor declarations
This commit is contained in:
1 parent
ee895a558f
commit
faaa3e8c2d
123 files changed
+31305
-1712
No files matched your search
@@ -18,6 +18,9 @@ Include the task ID in the commit subject and include its implementation, tests,
|
||||
and status updates together. Verify the commit before starting the next task. Do not bundle
|
||||
multiple newly completed tasks or include unrelated work. This does not authorize pushing or publishing.
|
||||
Use Yarn Classic 1.22.22 as packageManager and maintain only the root yarn.lock.
|
||||
Core public declarations are authored in packages/artplayer/public/ and generated
|
||||
with yarn build:types into the existing types/ entrypoints. Do not hand-edit the
|
||||
generated core declarations; yarn check:types is read-only and rejects drift.
|
||||
Use Node from .node-version; frozen Yarn installs and strict toolchain checks are required.
|
||||
Bun remains an isolated evaluation and must not replace Yarn without a new user decision.
|
||||
The user also authorizes installing needed dependencies and adding or improving reasonable
|
||||
@@ -137,7 +140,8 @@ For proxy/plugin work, prefer validating on the local demo page rather than reas
|
||||
- `packages/artplayer/src/contextmenu/`: context menu items
|
||||
- `packages/artplayer/src/plugins/`: built-in plugins
|
||||
- `packages/artplayer/src/utils/`: shared helpers, component base classes, DOM utilities
|
||||
- `packages/artplayer/types/`: public TS declarations
|
||||
- `packages/artplayer/public/`: public TypeScript declaration sources
|
||||
- `packages/artplayer/types/`: generated public declarations and compatibility documentation
|
||||
|
||||
### Ecosystem packages
|
||||
|
||||
@@ -246,7 +250,8 @@ If adding HLS-like quality/audio selection elsewhere:
|
||||
|
||||
## Build and Artifact Rules
|
||||
|
||||
- Always edit `src/` and `types/` first.
|
||||
- Always edit source first: core runtime in `src/`, core declarations in `public/`;
|
||||
other packages retain `types/` until their own declaration source migration.
|
||||
- Rebuild package artifacts after source changes that should ship.
|
||||
- Do not treat `dist/` as source of truth.
|
||||
- If a change affects demo behavior, also verify the matching file in `docs/assets/example/`.
|
||||
|
||||
Vendored
+1357
-1350
File diff suppressed because it is too large.
Load diff
+14
-7
@@ -3,6 +3,7 @@
|
||||
"type": "module",
|
||||
"version": "6.1.0",
|
||||
"private": true,
|
||||
"packageManager": "yarn@1.22.22",
|
||||
"description": "ArtPlayer.js is a modern and full featured HTML5 video player",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -38,15 +39,15 @@
|
||||
"test:dash-control": "node --test test/dash-control.test.js",
|
||||
"dev": "npx cross-env NODE_ENV=development node ./scripts/dev.js",
|
||||
"build": "npx cross-env NODE_ENV=production node ./scripts/build.js",
|
||||
"lint": "eslint \"packages/*/{src,types,package.json}\" \"scripts/*.{js,mjs}\" \"test/*\" \"docs/assets/ts/*\" \"types/*.d.ts\" playwright.config.js --no-fix",
|
||||
"lint": "eslint \"packages/*/{src,public,types,package.json}\" \"scripts/*.{js,mjs}\" \"test/*\" \"docs/assets/ts/*\" \"types/*.d.ts\" playwright.config.js --no-fix",
|
||||
"build:all": "yarn ci:build && yarn lint",
|
||||
"check:toolchain": "node scripts/check-toolchain.mjs",
|
||||
"lint:fix": "eslint \"packages/*/{src,types,package.json}\" \"scripts/*.{js,mjs}\" \"test/*\" \"docs/assets/ts/*\" \"types/*.d.ts\" playwright.config.js --fix",
|
||||
"lint:fix": "eslint \"packages/*/{src,public,types,package.json}\" \"scripts/*.{js,mjs}\" \"test/*\" \"docs/assets/ts/*\" \"types/*.d.ts\" playwright.config.js --fix",
|
||||
"check:plan": "node refactor/scripts/plan.mjs --check",
|
||||
"test:node": "yarn test:unit && node --test test/toolchain.test.js test/build-docs.test.js test/package-check.test.js",
|
||||
"test:node": "yarn test:unit && node --test test/toolchain.test.js test/build-docs.test.js test/package-check.test.js test/declarations.test.js test/editor-types.test.js",
|
||||
"test:baseline": "node --test refactor/scripts/*.test.mjs",
|
||||
"ci:check": "yarn check:toolchain --strict && yarn check:plan && yarn lint && yarn typecheck && yarn test",
|
||||
"ci:build": "yarn build all && yarn build:i18n && yarn build:ts && yarn build:docs && yarn test:imports",
|
||||
"ci:check": "yarn check:toolchain --strict && yarn check:plan && yarn lint && yarn check:types && yarn typecheck && yarn test",
|
||||
"ci:build": "yarn build:types && yarn build all && yarn build:i18n && yarn build:ts && yarn build:docs && yarn test:imports",
|
||||
"test:imports": "node --test test/esm.test.js test/i18n.test.js test/ssr.test.js",
|
||||
"typecheck": "node scripts/typecheck.mjs",
|
||||
"test:unit": "node --test test/playback.test.js test/dash-control.test.js test/public-behavior.test.js test/helpers.test.js test/chapter.test.js test/utils.test.js test/resource-scope.test.js test/instance-lifecycle.test.js test/options.test.js test/media-hosts.test.js test/plugins.test.js test/source.test.js test/playback-properties.test.js test/media-events.test.js test/template-resources.test.js test/core-vendor.test.js test/component-resources.test.js test/setting-model.test.js test/setting-layout.test.js test/setting-resources.test.js test/subtitle.test.js test/display-native.test.js test/display-video-fullscreen.test.js test/display-pip.test.js test/display-mini.test.js test/display-sizing.test.js test/display-orientation.test.js test/hotkey.test.js test/listener-registry.test.js test/global-events.test.js test/pointer-events.test.js test/gesture.test.js test/event-scheduling.test.js test/notice.test.js test/fast-forward.test.js test/auto-playback.test.js test/builtin-layers.test.js test/prompt-components.test.js test/screenshot.test.js test/thumbnails.test.js test/progress.test.js test/environment.test.js test/storage.test.js test/facade-properties.test.js test/dom-boundaries.test.js test/initialization.test.js test/entry.test.js",
|
||||
@@ -55,7 +56,9 @@
|
||||
"test:browser:install": "playwright install chromium firefox webkit",
|
||||
"test:browser:report": "playwright show-report refactor/.cache/browser/html",
|
||||
"test:package": "node scripts/package-check.mjs",
|
||||
"test:package:release": "node scripts/package-check.mjs --release"
|
||||
"test:package:release": "node scripts/package-check.mjs --release",
|
||||
"build:types": "node scripts/build-types.mjs --write",
|
||||
"check:types": "node scripts/build-types.mjs --check"
|
||||
},
|
||||
"browserslist": "last 1 Chrome version",
|
||||
"devDependencies": {
|
||||
@@ -67,6 +70,7 @@
|
||||
"cross-env": "10.1.0",
|
||||
"cross-spawn": "7.0.6",
|
||||
"dotenv": "17.2.4",
|
||||
"dts-bundle-generator": "9.5.1",
|
||||
"esbuild": "0.27.7",
|
||||
"eslint": "9.39.2",
|
||||
"eslint-plugin-format": "2.0.1",
|
||||
@@ -79,7 +83,10 @@
|
||||
"terser": "5.51.2",
|
||||
"typescript": "5.9.3",
|
||||
"typescript-compat": "npm:typescript@4.3.5",
|
||||
"typescript-runtime-compat": "npm:typescript@5.1.6",
|
||||
"vite": "7.3.6"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22"
|
||||
"resolutions": {
|
||||
"dts-bundle-generator/typescript": "5.9.3"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,5 @@ yarn.lock
|
||||
package-lock.json
|
||||
src
|
||||
tsconfig.json
|
||||
|
||||
/public/
|
||||
@@ -4,6 +4,65 @@ ArtPlayer keeps its existing constructor, player mixins, plugins and DOM/CSS hoo
|
||||
The production entry is `src/index.ts`. All owned core production modules use
|
||||
TypeScript; libs/screenfull.js remains an audited third-party source file.
|
||||
|
||||
## Public declaration sources
|
||||
|
||||
`public/` owns the TypeScript sources for the historical package declarations.
|
||||
They deliberately form a separate dependency graph from `src/`: implementation
|
||||
classes, resource ownership details and browser-only imports must not leak into
|
||||
consumer declarations. `scripts/build-types.mjs` emits only declarations into
|
||||
the existing `types/` paths, using the pinned compiler and preserving the shared
|
||||
default/CJS/ESM/legacy/i18n identities. `public/` is excluded from npm packages.
|
||||
|
||||
Run `yarn build:types` after editing public sources and `yarn check:types` to verify
|
||||
generated files without writing. CI and isolated package builds use the same
|
||||
generator. Read `types/COMPATIBILITY.md` before changing a public return or callback:
|
||||
the historical facade retains old acceptance while the optional runtime facade
|
||||
describes actual results. Runtime and public source views are checked
|
||||
separately; generating a declaration does not prove runtime correspondence.
|
||||
|
||||
`public/runtime/` contains the precise media/player, utility, plugin, template/icon,
|
||||
subtitle/notice, event and component/setting views introduced by CORE-21.
|
||||
Their generic host parameters let tests compare the public contracts with the
|
||||
corresponding minimal implementation hosts. `public/runtime.ts` assembles them;
|
||||
`artplayer/runtime` and `artplayer/runtime/legacy` select precise declarations
|
||||
while resolving to the same JS files as the existing matching entrypoints.
|
||||
`artplayer/runtime/types` is the shared type-only augmentation path.
|
||||
`src/events/core-types.ts` consumes the generated
|
||||
event view: custom legacy channels remain available while builtin cue/error/blur
|
||||
payloads are corrected. Declaration-only imports add no runtime dependency.
|
||||
|
||||
`test/types/runtime-*.ts` separates source correspondence from generated declaration
|
||||
consumption. The latter runs with TypeScript 5.9.3 and the dev-only 5.1.6 alias in
|
||||
four module-resolution modes; the existing root consumers still run with 4.3.5.
|
||||
Keep old entry declarations independent of these modern accessor types.
|
||||
Old plugin factories have explicit input overloads, and declared legacy plugin
|
||||
results/custom events flow into the new view. No wrapper or runtime conversion
|
||||
is introduced. A returned precise instance must not be assigned to the legacy
|
||||
instance type: some legacy return assumptions intentionally remain inaccurate.
|
||||
Constructor PluginFactory uses PluginHost with an optional plugins registry;
|
||||
plugins.add callbacks receive the completed Artplayer view. ControlInput requires
|
||||
top/left/right because Control.add validates position before component registration.
|
||||
`runtime/construction.ts` describes early callback hosts. ProxyHost exposes safe
|
||||
initial fields and the event bus before Template returns; it does not expose the
|
||||
video/query/proxy getters. Layer/control/contextmenu hosts mark subsequent
|
||||
components optional. customType and setting mounted are deferred, so they receive
|
||||
the completed player. Pending views preserve Player directly because mapped types
|
||||
would otherwise collapse different getter/setter types. Browser tests compare
|
||||
the exact initialized fields against published and candidate construction.
|
||||
The container remains an HTMLDivElement; a general HTMLElement is rejected by
|
||||
the existing tag validation. TypeScript does not model arbitrary user mutations
|
||||
or guarantee every subsystem remains usable after explicit destroy.
|
||||
|
||||
`scripts/editor-types.mjs` bundles the historical public dependency graph with
|
||||
the pinned dts-bundle-generator and TypeScript, then uses the TypeScript AST to
|
||||
give the existing UMD global its constructor and named types. Definitions have a
|
||||
private namespace to avoid circular aliases. Both old/current compilers validate
|
||||
the standalone result before build:ts writes it; a CI test rejects drift.
|
||||
The browser editor test uses the actual vendored Monaco worker and generated core
|
||||
declaration to compile and execute a player example. Plugin/editor UI generation
|
||||
modernization remains SITE-02; this core flow does not concatenate modern accessors
|
||||
into the legacy editor or publish an additional JS implementation.
|
||||
|
||||
## Entry and bootstrap (CORE-20)
|
||||
|
||||
The typed entry checks subsystem composition. Seven leaf
|
||||
@@ -52,7 +111,7 @@ still propagate. Its controlled tests do not certify an actual Apple receiver.
|
||||
test/initialization.test.js compares frozen CORE-19 functions with the new code;
|
||||
test/types/core-initialization.ts checks raw storage, mutable config and nullable DOM
|
||||
results. Internal PiP consumers accept the native element/null/boolean getter and
|
||||
boolean setter; the public declaration compatibility work remains in CORE-21.
|
||||
boolean setter; the optional runtime entry exposes the same precise contract.
|
||||
The auto-playback consumer owns the legacy unvalidated record assumption locally;
|
||||
Storage does not promise that arbitrary persisted values are PlaybackTimes.
|
||||
|
||||
@@ -87,8 +146,8 @@ as the legacy declaration class. template/types.ts names the PlayerTemplate cont
|
||||
canonical template nodes plus a native/media-like proxy. The entry makes one scoped
|
||||
assertion for caller-provided SSR/proxy inputs. This is a compatibility precondition,
|
||||
not runtime validation; no eager missing-node rejection or synthesized nodes are added.
|
||||
Template itself and query helpers keep nullable results. Complete public declaration
|
||||
generation and consumer views remain CORE-21 work.
|
||||
Template itself and query helpers keep nullable results. Generated runtime declarations
|
||||
retain these nullable views; the old root preserves historical consumer acceptance.
|
||||
|
||||
events/core-types.ts names known core/native payloads while leaving extension event
|
||||
names open. CoreEmission narrows a module's emitted names against that shared map.
|
||||
@@ -205,7 +264,7 @@ overwriting newer messages. Public art/timer fields and destroy/show methods rem
|
||||
False/empty assignment only hides the notice; the old pending expiry still clears
|
||||
its text. Manual notice.destroy cancels the timer without hiding or permanently
|
||||
disabling a live instance. The source getter is boolean; the legacy public message
|
||||
read type remains tracked by BASE-TYPE-07 for compatible coordination in CORE-21.
|
||||
read type is retained at the old root; the runtime entry exposes the boolean getter.
|
||||
|
||||
`src/plugins/fastForward.ts` wires the unchanged plugin result and input events.
|
||||
`src/input/long-press.ts` owns one press at a time in the current source scope,
|
||||
@@ -404,8 +463,9 @@ screen rotation is tested below; final installed-artifact acceptance remains a C
|
||||
plugins/autoOrientation.ts composes the mobile-only builtin, retaining its name/state
|
||||
getter and mismatch rule. It rejects unready geometry and scopes the two ArtPlayer event
|
||||
subscriptions. orientation-types.ts models the minimal host and optional platform lock.
|
||||
The builtin registry currently bridges its generic JS host at this one assembly boundary;
|
||||
the complete constructor host remains for CORE-21, without widening the implementation.
|
||||
The builtin registry bridges its host at this one assembly boundary. Public construction
|
||||
callbacks use the phase-specific hosts in public/runtime/construction.ts without widening
|
||||
the implementation's minimal orientation host.
|
||||
|
||||
display/orientation-web.ts owns delayed rotation and its four inline style properties.
|
||||
Each new fullscreen session cancels the previous timer. Repeated entry reapplies dimensions
|
||||
@@ -525,8 +585,8 @@ Destruction's synchronous WebKit failure follows the normal lifecycle error coll
|
||||
late cleanup is best effort. Platform UI remains the browser's responsibility.
|
||||
|
||||
The internal PipProperty reflects the branch-dependent getter. Historical public boolean
|
||||
declarations remain unchanged pending BASE-TYPE-10 / CORE-21; this is an explicit legacy
|
||||
declaration discrepancy, not a reason to convert native JS consumers to boolean.
|
||||
declarations remain unchanged at the old root; the runtime entry exposes Element|null|boolean
|
||||
reads and boolean writes. Native JS return values retain their identity.
|
||||
Run `node --test test/display-pip.test.js` and
|
||||
`yarn test:browser test/browser/display-pip.spec.js test/browser/display-pip-webkit.spec.js`.
|
||||
The actual native test records capabilities and, when supported, a native window, media
|
||||
@@ -590,7 +650,8 @@ Track load errors notify only while that node is current; all owned load/error/c
|
||||
callbacks are cleared on replacement or destroy. HTTP errors reject before conversion.
|
||||
Constructor and URL-setter calls report through notice and consume their otherwise
|
||||
unobservable rejected promises; explicit init/switch calls keep rejection semantics.
|
||||
Public cue event inference remains tracked by BASE-TYPE-07 / CORE-21. Browser-engine
|
||||
The runtime entry infers cue arrays; the old root retains scalar inference and its
|
||||
explicit array-listener overloads for compatibility. Browser-engine
|
||||
tests do not certify physical iOS/Safari fullscreen or every proxy implementation.
|
||||
|
||||
## Settings (CORE-14)
|
||||
@@ -666,9 +727,9 @@ trusted keyboard input/change ordering, pointer switch callbacks, touch selectio
|
||||
and actual builtin autoOrientation transforms with a local video. Mobile UA/viewport
|
||||
and touch emulation are not certification on physical mobile devices.
|
||||
|
||||
Public Setting return declaration discrepancies remain tracked by BASE-TYPE-07 for
|
||||
the compatible public facade at CORE-21. The source manager has precise item/null/void
|
||||
returns and does not change runtime behavior to match incorrect legacy declarations.
|
||||
The runtime entry and source manager expose precise item/null/void Setting returns.
|
||||
The old root retains historical return declarations for existing consumers; the manager
|
||||
does not change runtime behavior to match those declarations.
|
||||
|
||||
Tests: setting-model.test.js, setting-layout.test.js, setting-resources.test.js,
|
||||
types/setting-model.ts, types/setting-manager.ts and
|
||||
@@ -701,7 +762,7 @@ click/mounted/beforeUnmount use art as this; index 0 still follows the old index
|
||||
rule; equal indexes insert before their predecessor. update mutates the cached option
|
||||
before remove, so the newly supplied beforeUnmount runs on the old node. Component
|
||||
add/update may return a div; Control add/update still return undefined. Source types
|
||||
model that distinction; historical public declaration conflicts remain CORE-21 work.
|
||||
and the runtime entry model that distinction; historical root declarations are retained.
|
||||
A name of `__proto__` now creates a normal own DOM alias without replacing the registry
|
||||
prototype. Other historical aliases and shadowing behavior are not broadly renamed.
|
||||
|
||||
@@ -766,7 +827,7 @@ construction still fails with the original browser-only error.
|
||||
`icons/defaults.ts` owns SVG inputs; `icons/index.ts` creates the per-instance registry.
|
||||
Each read creates a fresh i.art-icon wrapper. Custom DOM nodes move into that wrapper;
|
||||
they are not cloned. Public declarations historically say HTMLDivElement, while source
|
||||
uses the actual HTMLElement shape. This mismatch remains tracked for CORE-21.
|
||||
and the runtime entry use the actual HTMLElement shape. Custom icon keys may be absent.
|
||||
|
||||
`i18n/index.ts` owns selected language, deep updates and key fallback. Standalone
|
||||
language modules keep default exports and artplayer-i18n-* aliases through publish.ts.
|
||||
@@ -833,7 +894,7 @@ Public PluginFactory and Plugins are type-only contracts. Augment `artplayer/typ
|
||||
for a common plugin-result/event interface across old TS, NodeNext CJS/ESM and Bundler;
|
||||
augmenting the CJS root alias directly is not equivalent. The new subpath has only
|
||||
a types condition and typesVersions fallback: runtime require/import must reject it.
|
||||
Public add's legacy return signature remains tracked by BASE-TYPE-04/CORE-21; internal
|
||||
The old root retains add's legacy return signature. Runtime-entry and internal
|
||||
registration types preserve known synchronous/Promise results and use a union for
|
||||
unknown results. The Promise distinction retains instanceof semantics: foreign
|
||||
Promises and ordinary thenables are stored synchronously, not assimilated.
|
||||
@@ -1084,8 +1145,9 @@ reads template.$video on each access, as before.
|
||||
The typed construction facade checks these host requirements while retaining the
|
||||
original staged initialization. Do not assume these types validate every third-party proxy.
|
||||
Public art.video remains the original object and retains its existing declaration
|
||||
for consumer compatibility. A public proxy typing extension requires separate
|
||||
consumer checks; internal code must not use that old declaration to hide a canvas.
|
||||
at the old root for consumer compatibility. The runtime entry exposes MediaSurface
|
||||
and a construction-stage ProxyHost, checked in installed consumers; internal code
|
||||
must not use the old declaration to hide a canvas.
|
||||
|
||||
`test/media-hosts.test.js` covers structural media methods, receiver/return values,
|
||||
event and mutex order, property descriptors and live getters. `test/types/media-hosts.ts`
|
||||
@@ -1103,7 +1165,8 @@ compatibility surface; see [types/README.md](./types/README.md).
|
||||
Public return discrepancies remain after CORE-07. It adds unescape/ArtPlayerError,
|
||||
optional sleep and a symbol/PropertyKey def overload; old string def and debounce/throttle return declarations
|
||||
remain for source compatibility. The old debounce context argument is ignored at runtime.
|
||||
BASE-TYPE-05 remains open through CORE-21; use the actual source types internally.
|
||||
The runtime entry exposes the actual target identity and timer void returns;
|
||||
use the actual source types internally.
|
||||
Lifecycle-owned timer cancellation is part of CORE-04/17 and the existing BASE-PERF-01
|
||||
finding, not a claim that a standalone debounce can know when its owner is destroyed.
|
||||
|
||||
@@ -1214,5 +1277,5 @@ core files in docs/compiled when committing a shippable core change.
|
||||
For new utility behavior, extend the same old/new contract tests. Clearly separate
|
||||
intentional defect corrections from preserved behavior. For timers or Blob URLs,
|
||||
also identify the owner and verify cleanup in the consuming module. Remaining
|
||||
public declaration convergence, accessibility and release validation are recorded
|
||||
ecosystem declaration work, accessibility and release validation are recorded
|
||||
in refactor/tasks.json and should extend this map as they land.
|
||||
@@ -31,6 +31,29 @@
|
||||
"./types": {
|
||||
"types": "./types/artplayer.d.ts"
|
||||
},
|
||||
"./runtime": {
|
||||
"import": {
|
||||
"types": "./types/runtime.d.mts",
|
||||
"default": "./dist/artplayer.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/runtime.d.cts",
|
||||
"default": "./dist/artplayer.js"
|
||||
}
|
||||
},
|
||||
"./runtime/types": {
|
||||
"types": "./types/runtime.d.ts"
|
||||
},
|
||||
"./runtime/legacy": {
|
||||
"import": {
|
||||
"types": "./types/runtime.d.cts",
|
||||
"default": "./dist/artplayer.legacy.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/runtime.d.cts",
|
||||
"default": "./dist/artplayer.legacy.js"
|
||||
}
|
||||
},
|
||||
"./legacy": {
|
||||
"import": {
|
||||
"types": "./types/artplayer.d.cts",
|
||||
@@ -60,6 +83,15 @@
|
||||
"types": [
|
||||
"types/artplayer.d.ts"
|
||||
],
|
||||
"runtime": [
|
||||
"types/runtime.d.ts"
|
||||
],
|
||||
"runtime/types": [
|
||||
"types/runtime.d.ts"
|
||||
],
|
||||
"runtime/legacy": [
|
||||
"types/runtime.d.ts"
|
||||
],
|
||||
"i18n/*": [
|
||||
"types/legacy/language.d.ts"
|
||||
],
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import type * as Definition from './artplayer.js'
|
||||
|
||||
declare const Artplayer: typeof Definition.default
|
||||
// eslint-disable-next-line ts/no-redeclare -- CJS constructor value and instance type share the export.
|
||||
type Artplayer = Definition.default
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare, ts/no-namespace -- Namespace merging carries named types on the existing CJS export.
|
||||
declare namespace Artplayer {
|
||||
type Config = Definition.Config
|
||||
type Emitter<Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>> = Definition.Emitter<Events>
|
||||
type Events = Definition.Events
|
||||
type I18n = Definition.I18n
|
||||
type Icons = Definition.Icons
|
||||
type Option = Definition.Option
|
||||
type OptionInput = Definition.OptionInput
|
||||
type Player = Definition.Player
|
||||
type PlaybackControls = Definition.PlaybackControls
|
||||
type PluginFactory<Host = Artplayer, Result = unknown> = Definition.PluginFactory<Host, Result>
|
||||
type Plugins = Definition.Plugins
|
||||
type Setting = Definition.Setting
|
||||
type SettingOption = Definition.SettingOption
|
||||
type Subtitle = Definition.Subtitle
|
||||
type SubtitleUpdateEvents = Definition.SubtitleUpdateEvents
|
||||
type Template = Definition.Template
|
||||
type Utils = Definition.Utils
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax -- Preserve the real CommonJS constructor export.
|
||||
export = Artplayer
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default } from './artplayer.cjs'
|
||||
export type { Config, Emitter, Events, I18n, Icons, Option, OptionInput, PlaybackControls, Player, PluginFactory, Plugins, Setting, SettingOption, Subtitle, SubtitleUpdateEvents, Template, Utils } from './artplayer.js'
|
||||
@@ -0,0 +1,216 @@
|
||||
import type { Component } from './component'
|
||||
import type { Config } from './config'
|
||||
import type { Emitter } from './emitter'
|
||||
import type { Events, SubtitleUpdateEvents } from './events'
|
||||
import type { I18n } from './i18n'
|
||||
import type { Icons } from './icons'
|
||||
import type { Option, OptionInput } from './option'
|
||||
import type { PlaybackControls } from './playback'
|
||||
import type { Player } from './player'
|
||||
import type { PluginFactory, Plugins } from './plugin'
|
||||
import type { Setting, SettingOption } from './setting'
|
||||
import type { Subtitle } from './subtitle'
|
||||
import type { Template } from './template'
|
||||
import type { Utils } from './utils'
|
||||
|
||||
export type {
|
||||
Config,
|
||||
Emitter,
|
||||
Events,
|
||||
I18n,
|
||||
Icons,
|
||||
Option,
|
||||
OptionInput,
|
||||
PlaybackControls,
|
||||
Player,
|
||||
PluginFactory,
|
||||
Plugins,
|
||||
Setting,
|
||||
SettingOption,
|
||||
Subtitle,
|
||||
SubtitleUpdateEvents,
|
||||
Template,
|
||||
Utils,
|
||||
}
|
||||
|
||||
declare class Artplayer extends Player {
|
||||
constructor(option: Option, readyCallback?: (this: Artplayer, art: Artplayer) => unknown)
|
||||
constructor(option: OptionInput, readyCallback?: (this: Artplayer, art: Artplayer) => unknown)
|
||||
|
||||
static readonly instances: Artplayer[]
|
||||
static readonly version: string
|
||||
static readonly env: 'development' | 'production'
|
||||
static readonly build: string
|
||||
static readonly config: Config
|
||||
static readonly utils: Utils
|
||||
static readonly scheme: Record<keyof Option, unknown>
|
||||
static readonly Emitter: new <Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>>(...args: unknown[]) => Emitter<Events>
|
||||
static readonly validator: <T extends object>(option: T, scheme: object) => T
|
||||
static readonly kindOf: (item: unknown) => string
|
||||
static readonly html: Artplayer['template']['html']
|
||||
static readonly option: Option
|
||||
|
||||
static STYLE: string
|
||||
static DEBUG: boolean
|
||||
static CONTEXTMENU: boolean
|
||||
static NOTICE_TIME: number
|
||||
static SETTING_WIDTH: number
|
||||
static SETTING_ITEM_WIDTH: number
|
||||
static SETTING_ITEM_HEIGHT: number
|
||||
static RESIZE_TIME: number
|
||||
static SCROLL_TIME: number
|
||||
static SCROLL_GAP: number
|
||||
static AUTO_PLAYBACK_MAX: number
|
||||
static AUTO_PLAYBACK_MIN: number
|
||||
static AUTO_PLAYBACK_TIMEOUT: number
|
||||
static RECONNECT_TIME_MAX: number
|
||||
static RECONNECT_SLEEP_TIME: number
|
||||
static CONTROL_HIDE_TIME: number
|
||||
static DBCLICK_TIME: number
|
||||
static DBCLICK_FULLSCREEN: boolean
|
||||
static MOBILE_DBCLICK_PLAY: boolean
|
||||
static MOBILE_CLICK_PLAY: boolean
|
||||
static AUTO_ORIENTATION_TIME: number
|
||||
static INFO_LOOP_TIME: number
|
||||
static FAST_FORWARD_VALUE: number
|
||||
static FAST_FORWARD_TIME: number
|
||||
static TOUCH_MOVE_RATIO: number
|
||||
static VOLUME_STEP: number
|
||||
static SEEK_STEP: number
|
||||
static PLAYBACK_RATE: number[]
|
||||
static ASPECT_RATIO: string[]
|
||||
static FLIP: string[]
|
||||
static FULLSCREEN_WEB_IN_BODY: boolean
|
||||
static LOG_VERSION: boolean
|
||||
static USE_RAF: boolean
|
||||
static REMOVE_SRC_WHEN_DESTROY: boolean
|
||||
|
||||
readonly id: number
|
||||
readonly option: Option
|
||||
readonly isLock: boolean
|
||||
readonly isReady: boolean
|
||||
readonly isFocus: boolean
|
||||
readonly isInput: boolean
|
||||
readonly isRotate: boolean
|
||||
readonly isDestroy: boolean
|
||||
|
||||
flv?: unknown
|
||||
m3u8?: unknown
|
||||
hls?: unknown
|
||||
ts?: unknown
|
||||
mpd?: unknown
|
||||
torrent?: unknown
|
||||
|
||||
on<T extends keyof Events>(name: T, fn: (...args: Events[T]) => unknown, ctx?: object): this
|
||||
on<T extends keyof SubtitleUpdateEvents>(name: T, fn: (...args: SubtitleUpdateEvents[T]) => unknown, ctx?: object): this
|
||||
on(name: string, fn: (...args: unknown[]) => unknown, ctx?: object): this
|
||||
|
||||
once<T extends keyof Events>(name: T, fn: (...args: Events[T]) => unknown, ctx?: object): this
|
||||
once<T extends keyof SubtitleUpdateEvents>(name: T, fn: (...args: SubtitleUpdateEvents[T]) => unknown, ctx?: object): this
|
||||
once(name: string, fn: (...args: unknown[]) => unknown, ctx?: object): this
|
||||
|
||||
emit<T extends keyof Events>(name: T, ...args: Events[T]): this
|
||||
emit<T extends keyof SubtitleUpdateEvents>(name: T, ...args: SubtitleUpdateEvents[T]): this
|
||||
emit(name: string, ...args: unknown[]): this
|
||||
|
||||
off<T extends keyof Events>(name: T, callback?: (...args: Events[T]) => unknown): this
|
||||
off<T extends keyof SubtitleUpdateEvents>(name: T, callback?: (...args: SubtitleUpdateEvents[T]) => unknown): this
|
||||
off(name: string, callback?: (...args: unknown[]) => unknown): this
|
||||
|
||||
query: Artplayer['template']['query']
|
||||
proxy: Artplayer['events']['proxy']
|
||||
video: Artplayer['template']['$video']
|
||||
|
||||
e: { [K in keyof Events]?: { fn: (...args: Events[K]) => unknown, ctx: unknown }[] }
|
||||
|
||||
destroy(removeHtml?: boolean): void
|
||||
reset(): void
|
||||
|
||||
readonly template: {
|
||||
get html(): string
|
||||
query: <T extends Element = Element>(selector: string) => T | null
|
||||
} & Template
|
||||
|
||||
readonly events: {
|
||||
proxy: {
|
||||
(target: EventTarget, eventName: string, handler: (event: Event) => void, options?: boolean | AddEventListenerOptions): () => void
|
||||
(target: EventTarget, eventName: string[], handler: (event: Event) => void, options?: boolean | AddEventListenerOptions): Array<() => void>
|
||||
}
|
||||
hover: (element: HTMLElement, mouseenter?: (event: Event) => any, mouseleave?: (event: Event) => any) => void
|
||||
remove: (destroyEvent: () => void) => void
|
||||
destroy: () => void
|
||||
bindGlobalEvents: (source?: { window?: Window, document?: Document }) => void
|
||||
}
|
||||
|
||||
readonly storage: {
|
||||
name: string
|
||||
settings: Record<string, unknown>
|
||||
get: {
|
||||
(key: string): unknown
|
||||
(): Record<string, unknown>
|
||||
}
|
||||
set: (key: string, value: unknown) => void
|
||||
del: (key: string) => void
|
||||
clear: () => void
|
||||
}
|
||||
|
||||
readonly icons: Icons
|
||||
|
||||
readonly i18n: {
|
||||
languages: I18n
|
||||
language: Partial<Record<string, string>>
|
||||
init: () => void
|
||||
get: (key: string) => string
|
||||
update: (language: Partial<I18n>) => void
|
||||
}
|
||||
|
||||
readonly notice: {
|
||||
timer: number | null
|
||||
get show(): string | Error | false | ''
|
||||
set show(msg: string | Error | false | '')
|
||||
destroy: () => void
|
||||
}
|
||||
|
||||
readonly layers: Record<string, HTMLElement | undefined> & Component
|
||||
readonly controls: Record<string, HTMLElement | undefined> & Component
|
||||
readonly contextmenu: Record<string, HTMLElement | undefined> & Component
|
||||
|
||||
readonly subtitle: {
|
||||
get url(): string
|
||||
set url(url: string)
|
||||
get textTrack(): TextTrack | undefined
|
||||
get activeCues(): VTTCue[]
|
||||
get cues(): VTTCue[]
|
||||
style: (name: string | Partial<CSSStyleDeclaration>, value?: string) => void
|
||||
switch: (url: string, option?: Subtitle) => Promise<string>
|
||||
init: (subtitle: Subtitle) => Promise<string | null | undefined>
|
||||
} & Component
|
||||
|
||||
readonly info: Component
|
||||
readonly loading: Component
|
||||
|
||||
readonly hotkey: {
|
||||
keys: Record<string, ((event: KeyboardEvent) => any)[]>
|
||||
add: (key: string, callback: (this: Artplayer, event: KeyboardEvent) => any) => Artplayer['hotkey']
|
||||
remove: (key: string, callback: (event: KeyboardEvent) => any) => Artplayer['hotkey']
|
||||
}
|
||||
|
||||
readonly mask: Component
|
||||
|
||||
readonly setting: {
|
||||
option: SettingOption[]
|
||||
updateStyle: (width?: number) => void
|
||||
/** Legacy return signature; a missing runtime entry is null. */
|
||||
find: (name: string) => SettingOption | undefined
|
||||
/** Legacy return signature; runtime returns the formatted input item. */
|
||||
add: (setting: Setting) => Artplayer['setting']
|
||||
/** Legacy return signature; runtime returns the updated or added item. */
|
||||
update: (settings: Setting) => Artplayer['setting']
|
||||
/** Legacy return signature; runtime returns undefined. */
|
||||
remove: (name: string) => Artplayer['setting']
|
||||
} & Component
|
||||
|
||||
readonly plugins: Plugins
|
||||
}
|
||||
|
||||
export default Artplayer
|
||||
@@ -0,0 +1,143 @@
|
||||
import type Artplayer from './artplayer'
|
||||
|
||||
/** Input accepted by the existing HTML renderer, including numeric content. */
|
||||
export interface ComponentInput extends Omit<ComponentOption, 'html'> {
|
||||
html?: string | HTMLElement | number
|
||||
}
|
||||
|
||||
export interface Selector {
|
||||
/**
|
||||
* Whether the default is selected
|
||||
*/
|
||||
default?: boolean
|
||||
|
||||
/**
|
||||
* Html string of selector
|
||||
*/
|
||||
html: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Value of selector item
|
||||
*/
|
||||
value?: string | number
|
||||
|
||||
/**
|
||||
* Allow custom properties
|
||||
*/
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface Component {
|
||||
/**
|
||||
* Component self-increasing id
|
||||
*/
|
||||
readonly id: number
|
||||
|
||||
/**
|
||||
* Component parent name
|
||||
*/
|
||||
readonly name: string | undefined
|
||||
|
||||
/**
|
||||
* Component parent element
|
||||
*/
|
||||
readonly $parent: HTMLElement | undefined
|
||||
|
||||
/**
|
||||
* Whether to show component parent
|
||||
*/
|
||||
get show(): boolean
|
||||
|
||||
/**
|
||||
* Whether to show component parent
|
||||
*/
|
||||
set show(state: boolean)
|
||||
|
||||
/**
|
||||
* Toggle the component parent
|
||||
*/
|
||||
toggle: () => void
|
||||
|
||||
/**
|
||||
* Dynamic add a component
|
||||
*/
|
||||
add: {
|
||||
(option: ComponentOption | ((art: Artplayer) => ComponentOption)): HTMLElement | undefined
|
||||
(option: ComponentInput | ((art: Artplayer) => ComponentInput)): HTMLElement | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic remove a component by name
|
||||
*/
|
||||
remove: (name: string) => void
|
||||
|
||||
/**
|
||||
* Dynamic update a component
|
||||
*/
|
||||
update: {
|
||||
(option: ComponentOption): HTMLElement | undefined
|
||||
(option: ComponentInput): HTMLElement | undefined
|
||||
}
|
||||
}
|
||||
|
||||
export interface ComponentOption {
|
||||
/**
|
||||
* Html string or html element of component
|
||||
*/
|
||||
html?: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Whether to disable component
|
||||
*/
|
||||
disable?: boolean
|
||||
|
||||
/**
|
||||
* Unique name for component
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* Component sort index
|
||||
*/
|
||||
index?: number
|
||||
|
||||
/**
|
||||
* Component style object
|
||||
*/
|
||||
style?: Partial<CSSStyleDeclaration>
|
||||
|
||||
/**
|
||||
* Component click event
|
||||
*/
|
||||
click?: (this: Artplayer, component: Component, event: Event) => void
|
||||
|
||||
/**
|
||||
* When the component was mounted
|
||||
*/
|
||||
mounted?: (this: Artplayer, element: HTMLElement) => void
|
||||
|
||||
/**
|
||||
* When the component was before unmount
|
||||
*/
|
||||
beforeUnmount?: (this: Artplayer, element: HTMLElement) => void
|
||||
|
||||
/**
|
||||
* Component tooltip, use in controls
|
||||
*/
|
||||
tooltip?: string
|
||||
|
||||
/**
|
||||
* Component position, use in controls
|
||||
*/
|
||||
position?: 'top' | 'left' | 'right' | (string & Record<never, never>)
|
||||
|
||||
/**
|
||||
* Custom selector list, use in controls
|
||||
*/
|
||||
selector?: Selector[]
|
||||
|
||||
/**
|
||||
* When selector item click, use in controls
|
||||
*/
|
||||
onSelect?: (this: Artplayer, selector: Selector, element: HTMLElement, event: Event) => void
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
export interface Config {
|
||||
readonly properties: readonly [
|
||||
'audioTracks',
|
||||
'autoplay',
|
||||
'buffered',
|
||||
'controller',
|
||||
'controls',
|
||||
'crossOrigin',
|
||||
'currentSrc',
|
||||
'currentTime',
|
||||
'defaultMuted',
|
||||
'defaultPlaybackRate',
|
||||
'duration',
|
||||
'ended',
|
||||
'error',
|
||||
'loop',
|
||||
'mediaGroup',
|
||||
'muted',
|
||||
'networkState',
|
||||
'paused',
|
||||
'playbackRate',
|
||||
'played',
|
||||
'preload',
|
||||
'readyState',
|
||||
'seekable',
|
||||
'seeking',
|
||||
'src',
|
||||
'startDate',
|
||||
'textTracks',
|
||||
'videoTracks',
|
||||
'volume',
|
||||
]
|
||||
readonly methods: readonly ['addTextTrack', 'canPlayType', 'load', 'play', 'pause']
|
||||
readonly events: readonly [
|
||||
'abort',
|
||||
'canplay',
|
||||
'canplaythrough',
|
||||
'durationchange',
|
||||
'emptied',
|
||||
'ended',
|
||||
'error',
|
||||
'loadeddata',
|
||||
'loadedmetadata',
|
||||
'loadstart',
|
||||
'pause',
|
||||
'play',
|
||||
'playing',
|
||||
'progress',
|
||||
'ratechange',
|
||||
'seeked',
|
||||
'seeking',
|
||||
'stalled',
|
||||
'suspend',
|
||||
'timeupdate',
|
||||
'volumechange',
|
||||
'waiting',
|
||||
]
|
||||
readonly prototypes: readonly [
|
||||
'width',
|
||||
'height',
|
||||
'videoWidth',
|
||||
'videoHeight',
|
||||
'poster',
|
||||
'webkitDecodedFrameCount',
|
||||
'webkitDroppedFrameCount',
|
||||
'playsInline',
|
||||
'webkitSupportsFullscreen',
|
||||
'webkitDisplayingFullscreen',
|
||||
'onenterpictureinpicture',
|
||||
'onleavepictureinpicture',
|
||||
'disablePictureInPicture',
|
||||
'cancelVideoFrameCallback',
|
||||
'requestVideoFrameCallback',
|
||||
'getVideoPlaybackQuality',
|
||||
'requestPictureInPicture',
|
||||
'webkitEnterFullScreen',
|
||||
'webkitEnterFullscreen',
|
||||
'webkitExitFullScreen',
|
||||
'webkitExitFullscreen',
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
export interface CssVar {
|
||||
'--art-theme': string
|
||||
'--art-font-color': string
|
||||
'--art-background-color': string
|
||||
'--art-text-shadow-color': string
|
||||
'--art-transition-duration': string
|
||||
'--art-padding': string
|
||||
'--art-border-radius': string
|
||||
'--art-progress-height': string
|
||||
'--art-progress-color': string
|
||||
'--art-progress-top-gap': string
|
||||
'--art-hover-color': string
|
||||
'--art-loaded-color': string
|
||||
'--art-state-size': string
|
||||
'--art-state-opacity': number
|
||||
'--art-bottom-height': string
|
||||
'--art-bottom-offset': string
|
||||
'--art-bottom-gap': string
|
||||
'--art-highlight-width': string
|
||||
'--art-highlight-color': string
|
||||
'--art-control-height': string
|
||||
'--art-control-opacity': number
|
||||
'--art-control-icon-size': string
|
||||
'--art-control-icon-scale': number
|
||||
'--art-volume-height': string
|
||||
'--art-volume-handle-size': string
|
||||
'--art-lock-size': string
|
||||
'--art-indicator-scale': number
|
||||
'--art-indicator-size': string
|
||||
'--art-fullscreen-web-index': 9999
|
||||
'--art-settings-icon-size': string
|
||||
'--art-settings-max-height': string
|
||||
'--art-selector-max-height': string
|
||||
'--art-contextmenus-min-width': string
|
||||
'--art-subtitle-font-size': string
|
||||
'--art-subtitle-gap': string
|
||||
'--art-subtitle-bottom': string
|
||||
'--art-subtitle-border': string
|
||||
'--art-widget-background': string
|
||||
'--art-tip-background': string
|
||||
'--art-scrollbar-size': string
|
||||
'--art-scrollbar-background': string
|
||||
'--art-scrollbar-background-hover': string
|
||||
'--art-mini-progress-height': string
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/** The event bus exposed by Artplayer.Emitter; no new runtime export. */
|
||||
export interface Emitter<Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>> {
|
||||
e?: { [Name in keyof Events]?: { fn: (...args: [...Events[Name]]) => unknown, ctx: unknown }[] }
|
||||
on: <Name extends keyof Events, Context>(name: Name, fn: (this: Context, ...args: [...Events[Name]]) => unknown, ctx?: Context) => this
|
||||
once: <Name extends keyof Events, Context>(name: Name, fn: (this: Context, ...args: [...Events[Name]]) => unknown, ctx?: Context) => this
|
||||
emit: <Name extends keyof Events>(name: Name, ...args: [...Events[Name]]) => this
|
||||
off: <Name extends keyof Events>(name: Name, fn?: (...args: [...Events[Name]]) => unknown) => this
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import type { AspectRatio, Flip } from './player'
|
||||
import type { Subtitle } from './subtitle'
|
||||
|
||||
export type Bar = 'loaded' | 'played' | 'hover'
|
||||
|
||||
/** Actual built-in subtitle update payloads; legacy Events keeps its scalar types. */
|
||||
export interface SubtitleUpdateEvents {
|
||||
subtitleBeforeUpdate: [cues: VTTCue[]]
|
||||
subtitleAfterUpdate: [cues: VTTCue[]]
|
||||
}
|
||||
|
||||
export interface Events {
|
||||
'document:click': [event: Event]
|
||||
'document:mouseup': [event: Event]
|
||||
'document:keydown': [event: Event]
|
||||
'document:touchend': [event: Event]
|
||||
'document:touchcancel': [event: Event]
|
||||
'document:touchmove': [event: Event]
|
||||
'document:mousemove': [event: Event]
|
||||
'document:pointerup': [event: Event]
|
||||
'document:contextmenu': [event: Event]
|
||||
'document:pointermove': [event: Event]
|
||||
'document:visibilitychange': [event: Event]
|
||||
'document:webkitfullscreenchange': [event: Event]
|
||||
|
||||
'window:resize': [event: Event]
|
||||
'window:scroll': [event: Event]
|
||||
'window:orientationchange': [event: Event]
|
||||
|
||||
'video:abort': [event: Event]
|
||||
'video:canplay': [event: Event]
|
||||
'video:canplaythrough': [event: Event]
|
||||
'video:complete': [event: Event]
|
||||
'video:durationchange': [event: Event]
|
||||
'video:emptied': [event: Event]
|
||||
'video:encrypted': [event: Event]
|
||||
'video:ended': [event: Event]
|
||||
'video:error': [error: Error]
|
||||
'video:loadeddata': [event: Event]
|
||||
'video:loadedmetadata': [event: Event]
|
||||
'video:loadstart': [event: Event]
|
||||
'video:pause': [event: Event]
|
||||
'video:play': [event: Event]
|
||||
'video:playing': [event: Event]
|
||||
'video:progress': [event: Event]
|
||||
'video:ratechange': [event: Event]
|
||||
'video:seeked': [event: Event]
|
||||
'video:seeking': [event: Event]
|
||||
'video:stalled': [event: Event]
|
||||
'video:suspend': [event: Event]
|
||||
'video:timeupdate': [event: Event]
|
||||
'video:volumechange': [event: Event]
|
||||
'video:waiting': [event: Event]
|
||||
|
||||
'info': [state: boolean]
|
||||
'layer': [state: boolean]
|
||||
'loading': [state: boolean]
|
||||
'mask': [state: boolean]
|
||||
'subtitle': [state: boolean]
|
||||
'contextmenu': [state: boolean]
|
||||
'control': [state: boolean]
|
||||
'setting': [state: boolean]
|
||||
'hotkey': [event: KeyboardEvent]
|
||||
|
||||
'destroy': []
|
||||
|
||||
'subtitleOffset': [offset: number]
|
||||
/** Legacy contextual type; annotate listeners with VTTCue[] for the runtime payload. */
|
||||
'subtitleBeforeUpdate': [cue: VTTCue]
|
||||
/** Legacy contextual type; annotate listeners with VTTCue[] for the runtime payload. */
|
||||
'subtitleAfterUpdate': [cue: VTTCue]
|
||||
'subtitleLoad': [cues: VTTCue[], option: Subtitle]
|
||||
|
||||
'focus': [event: Event]
|
||||
'blur': [event: Event]
|
||||
'dblclick': [event: Event]
|
||||
'click': [event: Event]
|
||||
'hover': [state: boolean, event: Event]
|
||||
'mousemove': [event: Event]
|
||||
|
||||
'resize': []
|
||||
'view': [state: boolean]
|
||||
'lock': [state: boolean]
|
||||
'aspectRatio': [aspectRatio: AspectRatio]
|
||||
'autoHeight': [height: number]
|
||||
'autoSize': [size: { width: number, height: number }]
|
||||
'ready': []
|
||||
'airplay': []
|
||||
'raf': []
|
||||
|
||||
'error': [error: Error, reconnectTime: number]
|
||||
'flip': [flip: Flip]
|
||||
'fullscreen': [state: boolean]
|
||||
'fullscreenError': [event: Event]
|
||||
'fullscreenWeb': [state: boolean]
|
||||
'mini': [state: boolean]
|
||||
'pause': []
|
||||
'pip': [state: boolean]
|
||||
'play': []
|
||||
'screenshot': [dataUri: string]
|
||||
'seek': [currentTime: number, time: number]
|
||||
'restart': [url: string]
|
||||
'muted': [state: boolean]
|
||||
'setBar': [type: Bar, percentage: number, event?: Event | undefined]
|
||||
'keydown': [event: KeyboardEvent]
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
type I18nKeys
|
||||
= | 'en'
|
||||
| 'zh-cn'
|
||||
| 'zh-tw'
|
||||
| 'pl'
|
||||
| 'cs'
|
||||
| 'es'
|
||||
| 'fa'
|
||||
| 'fr'
|
||||
| 'id'
|
||||
| 'ru'
|
||||
| 'tr'
|
||||
| 'ar'
|
||||
| 'vi'
|
||||
| (string & Record<never, never>)
|
||||
|
||||
interface I18nValue {
|
||||
'Video Info': string
|
||||
'Close': string
|
||||
'Video Load Failed': string
|
||||
'Volume': string
|
||||
'Play': string
|
||||
'Pause': string
|
||||
'Rate': string
|
||||
'Mute': string
|
||||
'Video Flip': string
|
||||
'Horizontal': string
|
||||
'Vertical': string
|
||||
'Reconnect': string
|
||||
'Show Setting': string
|
||||
'Hide Setting': string
|
||||
'Screenshot': string
|
||||
'Play Speed': string
|
||||
'Aspect Ratio': string
|
||||
'Default': string
|
||||
'Normal': string
|
||||
'Open': string
|
||||
'Switch Video': string
|
||||
'Switch Subtitle': string
|
||||
'Fullscreen': string
|
||||
'Exit Fullscreen': string
|
||||
'Web Fullscreen': string
|
||||
'Exit Web Fullscreen': string
|
||||
'Mini Player': string
|
||||
'PIP Mode': string
|
||||
'Exit PIP Mode': string
|
||||
'PIP Not Supported': string
|
||||
'Fullscreen Not Supported': string
|
||||
'Subtitle Offset': string
|
||||
'Last Seen': string
|
||||
'Jump Play': string
|
||||
'AirPlay': string
|
||||
'AirPlay Not Available': string
|
||||
}
|
||||
|
||||
export type I18n = Partial<Record<I18nKeys, Partial<I18nValue>>>
|
||||
@@ -0,0 +1,30 @@
|
||||
export interface Icons {
|
||||
readonly loading: HTMLDivElement
|
||||
readonly state: HTMLDivElement
|
||||
readonly play: HTMLDivElement
|
||||
readonly pause: HTMLDivElement
|
||||
readonly check: HTMLDivElement
|
||||
readonly volume: HTMLDivElement
|
||||
readonly volumeClose: HTMLDivElement
|
||||
readonly screenshot: HTMLDivElement
|
||||
readonly setting: HTMLDivElement
|
||||
readonly pip: HTMLDivElement
|
||||
readonly arrowLeft: HTMLDivElement
|
||||
readonly arrowRight: HTMLDivElement
|
||||
readonly playbackRate: HTMLDivElement
|
||||
readonly aspectRatio: HTMLDivElement
|
||||
readonly config: HTMLDivElement
|
||||
readonly lock: HTMLDivElement
|
||||
readonly flip: HTMLDivElement
|
||||
readonly unlock: HTMLDivElement
|
||||
readonly fullscreenOff: HTMLDivElement
|
||||
readonly fullscreenOn: HTMLDivElement
|
||||
readonly fullscreenWebOff: HTMLDivElement
|
||||
readonly fullscreenWebOn: HTMLDivElement
|
||||
readonly switchOn: HTMLDivElement
|
||||
readonly switchOff: HTMLDivElement
|
||||
readonly error: HTMLDivElement
|
||||
readonly close: HTMLDivElement
|
||||
readonly airplay: HTMLDivElement
|
||||
readonly [key: string]: HTMLDivElement
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { I18n } from './i18n.js'
|
||||
|
||||
declare const language: NonNullable<I18n['en']>
|
||||
// eslint-disable-next-line no-restricted-syntax -- Preserve the language object's CommonJS value export.
|
||||
export = language
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from './language.cjs'
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { I18n } from '../i18n'
|
||||
|
||||
declare const language: NonNullable<I18n['en']>
|
||||
export default language
|
||||
@@ -0,0 +1,331 @@
|
||||
import type Artplayer from './artplayer'
|
||||
import type { ComponentInput, ComponentOption } from './component'
|
||||
import type { CssVar } from './cssVar'
|
||||
import type { I18n } from './i18n'
|
||||
import type { Icons } from './icons'
|
||||
import type { PluginFactory } from './plugin'
|
||||
import type { Quality } from './quality'
|
||||
import type { Setting } from './setting'
|
||||
import type { Subtitle } from './subtitle'
|
||||
|
||||
export type CustomType
|
||||
= | 'flv'
|
||||
| 'm3u8'
|
||||
| 'hls'
|
||||
| 'ts'
|
||||
| 'mpd'
|
||||
| 'torrent'
|
||||
| (string & Record<never, never>)
|
||||
|
||||
export interface Thumbnails {
|
||||
/**
|
||||
* The thumbnail image url
|
||||
*/
|
||||
url: string
|
||||
|
||||
/**
|
||||
* The thumbnail item number
|
||||
*/
|
||||
number?: number
|
||||
|
||||
/**
|
||||
* The thumbnail column size
|
||||
*/
|
||||
column?: number
|
||||
|
||||
/**
|
||||
* The thumbnail width
|
||||
*/
|
||||
width?: number
|
||||
|
||||
/**
|
||||
* The thumbnail height
|
||||
*/
|
||||
height?: number
|
||||
|
||||
/**
|
||||
* The thumbnail scale
|
||||
*/
|
||||
scale?: number
|
||||
}
|
||||
|
||||
/** Constructor input; Option retains its historical required URL/read types. */
|
||||
export interface OptionInput extends Omit<Option, 'url' | 'controls' | 'layers' | 'contextmenu'> {
|
||||
url?: string
|
||||
controls?: ComponentInput[]
|
||||
layers?: ComponentInput[]
|
||||
contextmenu?: ComponentInput[]
|
||||
}
|
||||
|
||||
export interface Option {
|
||||
/**
|
||||
* The player id
|
||||
*/
|
||||
id?: string
|
||||
|
||||
/**
|
||||
* The container mounted by the player
|
||||
*/
|
||||
container: string | HTMLDivElement
|
||||
|
||||
/**
|
||||
* Video url
|
||||
*/
|
||||
url: string
|
||||
|
||||
/**
|
||||
* Video poster image url
|
||||
*/
|
||||
poster?: string
|
||||
|
||||
/**
|
||||
* Video url type
|
||||
*/
|
||||
type?: CustomType
|
||||
|
||||
/**
|
||||
* Player color theme
|
||||
*/
|
||||
theme?: string
|
||||
|
||||
/**
|
||||
* Player language
|
||||
*/
|
||||
lang?: keyof I18n
|
||||
|
||||
/**
|
||||
* Player default volume
|
||||
*/
|
||||
volume?: number
|
||||
|
||||
/**
|
||||
* Whether live broadcast mode
|
||||
*/
|
||||
isLive?: boolean
|
||||
|
||||
/**
|
||||
* Whether video muted
|
||||
*/
|
||||
muted?: boolean
|
||||
|
||||
/**
|
||||
* Whether video auto play
|
||||
*/
|
||||
autoplay?: boolean
|
||||
|
||||
/**
|
||||
* Whether player auto resize
|
||||
*/
|
||||
autoSize?: boolean
|
||||
|
||||
/**
|
||||
* Whether player auto run mini mode
|
||||
*/
|
||||
autoMini?: boolean
|
||||
|
||||
/**
|
||||
* Whether video auto loop
|
||||
*/
|
||||
loop?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video flip button
|
||||
*/
|
||||
flip?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video playback rate button
|
||||
*/
|
||||
playbackRate?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video aspect ratio button
|
||||
*/
|
||||
aspectRatio?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video screenshot button
|
||||
*/
|
||||
screenshot?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video setting button
|
||||
*/
|
||||
setting?: boolean
|
||||
|
||||
/**
|
||||
* Whether to enable player hotkey
|
||||
*/
|
||||
hotkey?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video pip button
|
||||
*/
|
||||
pip?: boolean
|
||||
|
||||
/**
|
||||
* Do you want to run only one player at a time
|
||||
*/
|
||||
mutex?: boolean
|
||||
|
||||
/**
|
||||
* Whether use backdrop in UI
|
||||
*/
|
||||
backdrop?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video window fullscreen button
|
||||
*/
|
||||
fullscreen?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video web fullscreen button
|
||||
*/
|
||||
fullscreenWeb?: boolean
|
||||
|
||||
/**
|
||||
* Whether to enable player subtitle offset
|
||||
*/
|
||||
subtitleOffset?: boolean
|
||||
|
||||
/**
|
||||
* Whether to enable player mini progress bar
|
||||
*/
|
||||
miniProgressBar?: boolean
|
||||
|
||||
/**
|
||||
* Whether use SSR function
|
||||
*/
|
||||
useSSR?: boolean
|
||||
|
||||
/**
|
||||
* Whether use playsInline in mobile
|
||||
*/
|
||||
playsInline?: boolean
|
||||
|
||||
/**
|
||||
* Whether use lock in mobile
|
||||
*/
|
||||
lock?: boolean
|
||||
|
||||
/**
|
||||
* Whether use gesture in mobile
|
||||
*/
|
||||
gesture?: boolean
|
||||
|
||||
/**
|
||||
* Whether use fast forward in mobile
|
||||
*/
|
||||
fastForward?: boolean
|
||||
|
||||
/**
|
||||
* Whether use auto playback
|
||||
*/
|
||||
autoPlayback?: boolean
|
||||
|
||||
/**
|
||||
* Whether use auto orientation in mobile
|
||||
*/
|
||||
autoOrientation?: boolean
|
||||
|
||||
/**
|
||||
* Whether use airplay
|
||||
*/
|
||||
airplay?: boolean
|
||||
|
||||
/**
|
||||
* Custom video proxy
|
||||
*/
|
||||
proxy?: (this: Artplayer, art: Artplayer) => HTMLCanvasElement | HTMLVideoElement | undefined
|
||||
|
||||
/**
|
||||
* Custom plugin list
|
||||
*/
|
||||
plugins?: PluginFactory[]
|
||||
|
||||
/**
|
||||
* Custom layer list
|
||||
*/
|
||||
layers?: ComponentOption[]
|
||||
|
||||
/**
|
||||
* Custom contextmenu list
|
||||
*/
|
||||
contextmenu?: ComponentOption[]
|
||||
|
||||
/**
|
||||
* Custom control list
|
||||
*/
|
||||
controls?: ComponentOption[]
|
||||
|
||||
/**
|
||||
* Custom setting list
|
||||
*/
|
||||
settings?: Setting[]
|
||||
|
||||
/**
|
||||
* Custom video quality list
|
||||
*/
|
||||
quality?: Quality[]
|
||||
|
||||
/**
|
||||
* Custom highlight list
|
||||
*/
|
||||
highlight?: {
|
||||
/**
|
||||
* The highlight time
|
||||
*/
|
||||
time: number
|
||||
|
||||
/**
|
||||
* The highlight text
|
||||
*/
|
||||
text: string
|
||||
}[]
|
||||
|
||||
/**
|
||||
* Custom thumbnail
|
||||
*/
|
||||
thumbnails?: Thumbnails
|
||||
|
||||
/**
|
||||
* Custom subtitle option
|
||||
*/
|
||||
subtitle?: Subtitle
|
||||
|
||||
/**
|
||||
* Other video attribute
|
||||
*/
|
||||
moreVideoAttr?: Partial<Readonly<{
|
||||
[K in keyof HTMLVideoElement as HTMLVideoElement[K] extends (...args: unknown[]) => unknown
|
||||
? never
|
||||
: K]: HTMLVideoElement[K]
|
||||
}>>
|
||||
|
||||
/**
|
||||
* Custom i18n
|
||||
*/
|
||||
i18n?: I18n
|
||||
|
||||
/**
|
||||
* Custom default icons
|
||||
*/
|
||||
icons?: {
|
||||
[key in keyof Icons]?: HTMLElement | string
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom css variables
|
||||
*/
|
||||
cssVar?: Partial<CssVar>
|
||||
|
||||
/**
|
||||
* Custom video type function
|
||||
*/
|
||||
customType?: Partial<
|
||||
Record<
|
||||
CustomType,
|
||||
(this: Artplayer, video: HTMLVideoElement, url: string, art: Artplayer) => unknown | Promise<unknown>
|
||||
>
|
||||
>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/** Accurate playback method view; assign an existing player without a runtime wrapper. */
|
||||
export interface PlaybackControls {
|
||||
play: () => Promise<void>
|
||||
pause: () => void
|
||||
toggle: () => Promise<void> | void
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import type { CssVar } from './cssVar'
|
||||
import type { CustomType, Thumbnails } from './option'
|
||||
import type { Quality } from './quality'
|
||||
|
||||
export type AspectRatio = 'default' | '4:3' | '16:9' | (`${number}:${number}` & Record<never, never>)
|
||||
export type PlaybackRate = 0.5 | 0.75 | 1.0 | 1.25 | 1.5 | 1.75 | 2.0 | (number & Record<never, never>)
|
||||
export type Flip = 'normal' | 'horizontal' | 'vertical' | (string & Record<never, never>)
|
||||
export type State = 'standard' | 'mini' | 'pip' | 'fullscreen' | 'fullscreenWeb'
|
||||
|
||||
export declare class Player {
|
||||
get aspectRatio(): AspectRatio
|
||||
set aspectRatio(ratio: AspectRatio)
|
||||
|
||||
get state(): State
|
||||
set state(state: State)
|
||||
|
||||
get type(): CustomType
|
||||
set type(name: CustomType)
|
||||
|
||||
get playbackRate(): PlaybackRate
|
||||
set playbackRate(rate: PlaybackRate)
|
||||
|
||||
get currentTime(): number
|
||||
set currentTime(time: number)
|
||||
|
||||
get duration(): number
|
||||
get played(): number
|
||||
get playing(): boolean
|
||||
|
||||
get flip(): Flip
|
||||
set flip(state: Flip)
|
||||
|
||||
get fullscreen(): boolean
|
||||
set fullscreen(state: boolean)
|
||||
|
||||
get fullscreenWeb(): boolean
|
||||
set fullscreenWeb(state: boolean)
|
||||
|
||||
get loaded(): number
|
||||
get loadedTime(): number
|
||||
|
||||
get mini(): boolean
|
||||
set mini(state: boolean)
|
||||
|
||||
get pip(): boolean
|
||||
set pip(state: boolean)
|
||||
|
||||
get poster(): string
|
||||
set poster(url: string)
|
||||
|
||||
get rect(): DOMRect
|
||||
get bottom(): number
|
||||
get height(): number
|
||||
get left(): number
|
||||
get right(): number
|
||||
get top(): number
|
||||
get width(): number
|
||||
get x(): number
|
||||
get y(): number
|
||||
|
||||
set seek(time: number)
|
||||
get seek(): number
|
||||
|
||||
set forward(time: number)
|
||||
get forward(): number
|
||||
|
||||
set backward(time: number)
|
||||
get backward(): number
|
||||
|
||||
get url(): string
|
||||
set url(url: string)
|
||||
|
||||
get volume(): number
|
||||
set volume(percentage: number)
|
||||
|
||||
get muted(): boolean
|
||||
set muted(state: boolean)
|
||||
|
||||
get theme(): string
|
||||
set theme(theme: string)
|
||||
|
||||
get subtitleOffset(): number
|
||||
set subtitleOffset(time: number)
|
||||
|
||||
get switch(): string
|
||||
set switch(url: string)
|
||||
|
||||
get quality(): Quality[]
|
||||
set quality(quality: Quality[])
|
||||
|
||||
get thumbnails(): Thumbnails
|
||||
set thumbnails(thumbnails: Thumbnails)
|
||||
|
||||
pause(): void
|
||||
play(): Promise<void>
|
||||
/** Legacy signature; runtime preserves pause's synchronous result or play's Promise. */
|
||||
toggle(): void
|
||||
|
||||
attr(key: string, value?: unknown): unknown
|
||||
cssVar<T extends keyof CssVar>(key: T, value?: CssVar[T]): CssVar[T]
|
||||
|
||||
switchUrl(url: string): Promise<void>
|
||||
switchQuality(url: string): Promise<void>
|
||||
|
||||
getDataURL(): Promise<string>
|
||||
getBlobUrl(): Promise<string>
|
||||
screenshot(name?: string): Promise<string>
|
||||
|
||||
airplay(): void
|
||||
autoSize(): void
|
||||
autoHeight(): void
|
||||
reset(): void
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type Artplayer from './artplayer'
|
||||
|
||||
export type PluginFactory<Host = Artplayer, Result = unknown> = (this: Host, art: Host) => Result
|
||||
|
||||
/** Augment this interface with installed plugin results; augmentation does not register a plugin. */
|
||||
export interface Plugins {
|
||||
/** Legacy signature: synchronous factories return this registry; Promise factories return a Promise of it. */
|
||||
add: (plugin: PluginFactory) => Promise<Plugins>
|
||||
[name: string]: unknown
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
export interface Quality {
|
||||
/**
|
||||
* Whether the default is selected
|
||||
*/
|
||||
default?: boolean
|
||||
|
||||
/**
|
||||
* Html string of quality
|
||||
*/
|
||||
html: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Video quality url
|
||||
*/
|
||||
url: string
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import type * as Definition from './runtime.js'
|
||||
|
||||
declare const Artplayer: typeof Definition.default
|
||||
// eslint-disable-next-line ts/no-redeclare -- CJS constructor value and instance type share the export.
|
||||
type Artplayer = Definition.default
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare, ts/no-namespace -- Named types share the existing CommonJS export.
|
||||
declare namespace Artplayer {
|
||||
type ArtplayerConstructor = Definition.ArtplayerConstructor
|
||||
type OptionInput = Definition.OptionInput
|
||||
type Option = Definition.Option
|
||||
type Events = Definition.Events
|
||||
type Plugins = Definition.Plugins
|
||||
type PluginFactory<Result = unknown> = Definition.PluginFactory<Result>
|
||||
type PluginHost = Definition.PluginHost
|
||||
type ProxyHost = Definition.ProxyHost
|
||||
type CustomTypeHost = Definition.CustomTypeHost
|
||||
type LayerHost = Definition.LayerHost
|
||||
type ControlHost = Definition.ControlHost
|
||||
type ContextmenuHost = Definition.ContextmenuHost
|
||||
type PluginRegistration<Result, Registry> = Definition.PluginRegistration<Result, Registry>
|
||||
type Component = Definition.Component
|
||||
type Controls = Definition.Controls
|
||||
type Setting = Definition.Setting
|
||||
type Subtitle = Definition.Subtitle
|
||||
type Notice = Definition.Notice
|
||||
type Utils = Definition.Utils
|
||||
type MediaSurface = Definition.MediaSurface
|
||||
type NativeMedia = Definition.NativeMedia
|
||||
type CanvasMedia = Definition.CanvasMedia
|
||||
type Player<Media extends MediaSurface = MediaSurface> = Definition.Player<Media>
|
||||
type Template<Host = Artplayer, Media extends MediaSurface = MediaSurface> = Definition.Template<Host, Media>
|
||||
type Icons = Definition.Icons
|
||||
type Config = Definition.Config
|
||||
type EventRegistry = Definition.EventRegistry
|
||||
type Storage = Definition.Storage
|
||||
type I18n<Host = Artplayer> = Definition.I18n<Host>
|
||||
type Hotkey<Host = Artplayer> = Definition.Hotkey<Host>
|
||||
type Languages = Definition.Languages
|
||||
type Dictionary = Definition.Dictionary
|
||||
type QualityItem = Definition.QualityItem
|
||||
type SettingItem<Host = Artplayer> = Definition.SettingItem<Host>
|
||||
type ComponentInput<Host = Artplayer> = Definition.ComponentInput<Host>
|
||||
type ComponentOption<Host = Artplayer> = Definition.ComponentOption<Host>
|
||||
type ControlInput<Host = Artplayer> = Definition.ControlInput<Host>
|
||||
type ControlOption<Host = Artplayer> = Definition.ControlOption<Host>
|
||||
type SelectorItem = Definition.SelectorItem
|
||||
type SubtitleCue = Definition.SubtitleCue
|
||||
type SubtitleOption = Definition.SubtitleOption
|
||||
type Emitter<Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>> = Definition.Emitter<Events>
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax -- Preserve the actual CommonJS constructor export.
|
||||
export = Artplayer
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default } from './runtime.cjs'
|
||||
export type * from './runtime.js'
|
||||
@@ -0,0 +1,125 @@
|
||||
import type LegacyArtplayer from './artplayer'
|
||||
import type { Emitter } from './emitter'
|
||||
import type { OptionInput as LegacyOptionInput } from './option'
|
||||
import type { PluginFactory as LegacyPluginFactory, Plugins as LegacyPlugins } from './plugin'
|
||||
import type { ComponentInput, Component as ComponentView, ControlInput, Controls as ControlsView } from './runtime/component'
|
||||
import type { ContextmenuHost, ControlHost, CustomTypeHost, LayerHost, PluginHost, ProxyHost } from './runtime/construction'
|
||||
import type { Events } from './runtime/events'
|
||||
import type { MediaSurface } from './runtime/media'
|
||||
import type { OptionInput as OptionInputView, Option as OptionView } from './runtime/option'
|
||||
import type { Player } from './runtime/player'
|
||||
import type { PluginFactory as FactoryView, PluginRegistration, Plugins as PluginsView } from './runtime/plugin'
|
||||
import type { Config, EventRegistry, Hotkey, I18n, Scheme, Storage, ValidatorPath } from './runtime/services'
|
||||
import type { Setting as SettingView } from './runtime/setting'
|
||||
import type { Notice as NoticeView, Subtitle as SubtitleView } from './runtime/subtitle'
|
||||
import type { Icons, Template } from './runtime/template'
|
||||
import type { Utils } from './runtime/utils'
|
||||
|
||||
export type { Emitter } from './emitter'
|
||||
export type { ComponentInput, ComponentOption, ControlInput, ControlOption, SelectorItem } from './runtime/component'
|
||||
export type { ContextmenuHost, ControlHost, CustomTypeHost, LayerHost, PluginHost, ProxyHost } from './runtime/construction'
|
||||
export type { Events } from './runtime/events'
|
||||
export type { CanvasMedia, MediaSurface, NativeMedia } from './runtime/media'
|
||||
export type { Player, QualityItem } from './runtime/player'
|
||||
export type { PluginRegistration } from './runtime/plugin'
|
||||
export type { Config, Dictionary, EventRegistry, Hotkey, I18n, Languages, Storage } from './runtime/services'
|
||||
export type { SettingItem } from './runtime/setting'
|
||||
export type { SubtitleCue, SubtitleOption } from './runtime/subtitle'
|
||||
export type { Icons, Template } from './runtime/template'
|
||||
export type { Utils } from './runtime/utils'
|
||||
|
||||
export type PluginFactory<Result = unknown> = FactoryView<PluginHost, Result>
|
||||
export interface OptionInput extends Omit<OptionInputView<Artplayer>, 'plugins' | 'proxy' | 'customType' | 'layers' | 'controls' | 'contextmenu'> {
|
||||
plugins?: PluginFactory[]
|
||||
proxy?: (this: ProxyHost, art: ProxyHost) => MediaSurface
|
||||
customType?: Record<string, ((this: CustomTypeHost, video: MediaSurface, url: string, art: CustomTypeHost) => unknown) | undefined>
|
||||
layers?: ComponentInput<LayerHost>[]
|
||||
controls?: ControlInput<ControlHost>[]
|
||||
contextmenu?: ComponentInput<ContextmenuHost>[]
|
||||
}
|
||||
export interface Option extends OptionView<Artplayer> {}
|
||||
export interface Component extends ComponentView<Artplayer> {}
|
||||
export interface Controls extends ControlsView<Artplayer> {}
|
||||
export interface Setting extends SettingView<Artplayer> {}
|
||||
export interface Subtitle extends SubtitleView, Omit<Component, keyof SubtitleView> {}
|
||||
export interface Notice extends NoticeView { art: Artplayer }
|
||||
|
||||
/** Augment with installed results. Factories are not wrapped or converted. */
|
||||
export interface PluginAdd<Registry> {
|
||||
<Result>(plugin: FactoryView<Artplayer, Result>): PluginRegistration<Result, Registry>
|
||||
<Result>(plugin: LegacyPluginFactory<LegacyArtplayer, Result>): PluginRegistration<Result, Registry>
|
||||
}
|
||||
|
||||
type LegacyPluginResults = {
|
||||
[Name in keyof LegacyPlugins as string extends Name ? never : number extends Name ? never : Name extends keyof PluginsView<Artplayer> ? never : Name]: LegacyPlugins[Name]
|
||||
}
|
||||
|
||||
export interface Plugins extends Omit<PluginsView<Artplayer>, 'add'>, LegacyPluginResults {
|
||||
add: PluginAdd<this>
|
||||
[name: string]: unknown
|
||||
}
|
||||
|
||||
/** Public view of the existing constructor; this interface emits no runtime fields. */
|
||||
interface Artplayer extends Player, Emitter<Events> {
|
||||
constructor: ArtplayerConstructor
|
||||
id: number
|
||||
option: Option
|
||||
isLock: boolean
|
||||
isReady: boolean
|
||||
isFocus: boolean
|
||||
isInput: boolean
|
||||
isRotate: boolean
|
||||
isDestroy: boolean
|
||||
flv?: unknown
|
||||
m3u8?: unknown
|
||||
hls?: unknown
|
||||
ts?: unknown
|
||||
mpd?: unknown
|
||||
torrent?: unknown
|
||||
template: Template<Artplayer>
|
||||
events: EventRegistry
|
||||
storage: Storage
|
||||
icons: Icons
|
||||
i18n: I18n<Artplayer>
|
||||
notice: Notice
|
||||
/** The descriptor installer has no public instance members. */
|
||||
player: object
|
||||
layers: Component
|
||||
controls: Controls
|
||||
contextmenu: Component & { init: () => void }
|
||||
subtitle: Subtitle
|
||||
info: Component & { init: () => void }
|
||||
loading: Component
|
||||
hotkey: Hotkey<Artplayer>
|
||||
mask: Component
|
||||
setting: Setting
|
||||
plugins: Plugins
|
||||
readonly query: Template<Artplayer>['query']
|
||||
readonly proxy: EventRegistry['proxy']
|
||||
readonly video: MediaSurface
|
||||
reset: () => void
|
||||
destroy: (removeHtml?: boolean) => void
|
||||
}
|
||||
|
||||
type StaticOptions = Pick<typeof LegacyArtplayer, Extract<keyof typeof LegacyArtplayer, Uppercase<string>>>
|
||||
|
||||
export interface ArtplayerConstructor extends StaticOptions {
|
||||
new (option: OptionInput, readyCallback?: (this: Artplayer, art: Artplayer) => unknown): Artplayer
|
||||
new (option: LegacyOptionInput, readyCallback?: (this: Artplayer, art: Artplayer) => unknown): Artplayer
|
||||
readonly prototype: Artplayer
|
||||
readonly instances: Artplayer[]
|
||||
readonly version: string
|
||||
readonly config: Config
|
||||
readonly utils: Utils
|
||||
readonly scheme: Record<keyof Option, Scheme>
|
||||
readonly Emitter: new <Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>>(...args: unknown[]) => Emitter<Events>
|
||||
readonly validator: <T>(option: T, scheme: Scheme, paths?: ValidatorPath) => T
|
||||
readonly kindOf: (value: unknown) => string
|
||||
readonly html: string
|
||||
readonly option: Option
|
||||
}
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- One existing constructor value and its instance view.
|
||||
declare const Artplayer: ArtplayerConstructor
|
||||
|
||||
export default Artplayer
|
||||
@@ -0,0 +1,65 @@
|
||||
export type EventCleanup = () => void
|
||||
|
||||
export interface SelectorItem {
|
||||
html: string | HTMLElement | number
|
||||
value?: string | number
|
||||
default?: boolean
|
||||
readonly $control_option?: SelectorItem[]
|
||||
readonly $control_item?: HTMLDivElement
|
||||
readonly $control_value?: HTMLDivElement
|
||||
}
|
||||
|
||||
export interface ComponentOption<Host> {
|
||||
html?: string | HTMLElement | number
|
||||
disable?: boolean
|
||||
name?: string
|
||||
index?: number
|
||||
style?: Partial<CSSStyleDeclaration>
|
||||
tooltip?: string | number
|
||||
position?: string
|
||||
selector?: SelectorItem[]
|
||||
click?: (this: Host, component: Component<Host>, event: Event) => unknown
|
||||
mounted?: (this: Host, element: HTMLDivElement) => unknown
|
||||
beforeUnmount?: (this: Host, element: HTMLDivElement) => unknown
|
||||
onSelect?: (this: Host, item: SelectorItem, element: HTMLDivElement, event: Event) => unknown
|
||||
}
|
||||
|
||||
export type ComponentInput<Host> = ComponentOption<Host> | ((art: Host) => ComponentOption<Host>)
|
||||
|
||||
export interface ControlOption<Host> extends Omit<ComponentOption<Host>, 'position'> {
|
||||
position: 'top' | 'left' | 'right'
|
||||
}
|
||||
|
||||
export type ControlInput<Host> = ControlOption<Host> | ((art: Host) => ControlOption<Host>)
|
||||
|
||||
export interface ComponentEntry<Host> {
|
||||
$ref: HTMLDivElement
|
||||
events: EventCleanup[]
|
||||
option: ComponentOption<Host>
|
||||
}
|
||||
|
||||
export interface Component<Host> {
|
||||
id: number
|
||||
art: Host
|
||||
name?: string
|
||||
$parent?: HTMLElement
|
||||
cache: Map<string, ComponentEntry<Host>>
|
||||
show: boolean
|
||||
toggle: () => void
|
||||
add: (input: ComponentInput<Host>) => HTMLDivElement | undefined
|
||||
remove: (name: string) => void
|
||||
update: (option: ComponentOption<Host>) => ReturnType<this['add']>
|
||||
selector?: (option: ComponentOption<Host>, element: HTMLDivElement, events: EventCleanup[]) => void
|
||||
}
|
||||
|
||||
export interface Controls<Host> extends Omit<Component<Host>, 'add' | 'update' | 'selector'> {
|
||||
isHover: boolean
|
||||
timer: number
|
||||
setting?: HTMLDivElement
|
||||
thumbnails?: HTMLDivElement
|
||||
init: () => void
|
||||
add: (input: ControlInput<Host>) => undefined
|
||||
update: (option: ComponentOption<Host>) => undefined
|
||||
check: (target?: SelectorItem) => void
|
||||
selector: (option: ComponentOption<Host>, element: HTMLDivElement, events: EventCleanup[]) => void
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { Emitter } from '../emitter'
|
||||
import type Artplayer from '../runtime'
|
||||
import type { Events } from './events'
|
||||
import type { Player } from './player'
|
||||
|
||||
/** Safe fields before Template returns; video/query/proxy getters are not usable yet. */
|
||||
export interface ProxyHost extends Emitter<Events>, Pick<Artplayer, 'constructor' | 'id' | 'option' | 'isLock' | 'isReady' | 'isFocus' | 'isInput' | 'isRotate' | 'isDestroy' | 'destroy'> {}
|
||||
|
||||
// Mapped types collapse distinct getter/setter types; preserve Player directly.
|
||||
type Pending<Names extends keyof Artplayer> = Player & Omit<Artplayer, Names | keyof Player> & Partial<Pick<Artplayer, Names>>
|
||||
type AfterPlayer = 'layers' | 'controls' | 'contextmenu' | 'subtitle' | 'info' | 'loading' | 'hotkey' | 'mask' | 'setting' | 'plugins'
|
||||
|
||||
/** URL assignment awaits its owned delay before invoking customType. */
|
||||
export type CustomTypeHost = Artplayer
|
||||
export type LayerHost = Pending<AfterPlayer>
|
||||
export type ControlHost = Pending<Exclude<AfterPlayer, 'layers'>>
|
||||
export type ContextmenuHost = Pending<Exclude<AfterPlayer, 'layers' | 'controls'>>
|
||||
/** Constructor factories run before the Plugins registry is assigned to the player. */
|
||||
export type PluginHost = Pending<'plugins'>
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { Events as LegacyEvents } from '../events'
|
||||
import type { SubtitleCue, SubtitleOption } from './subtitle'
|
||||
|
||||
type NativeEvents = { [Name in Extract<keyof LegacyEvents, `video:${string}`>]: [event: Event] }
|
||||
|
||||
interface BuiltinEvents {
|
||||
[name: `video:${string}`]: [event: Event]
|
||||
'document:keydown': [KeyboardEvent]
|
||||
'document:mousemove': [MouseEvent]
|
||||
'document:mouseup': [MouseEvent]
|
||||
'mousemove': [MouseEvent]
|
||||
'click': [MouseEvent]
|
||||
'blur': [Event]
|
||||
'error': [error: unknown, attempt: number]
|
||||
'fullscreenError': [error: unknown]
|
||||
'aspectRatio': [string]
|
||||
'flip': [string]
|
||||
'seek': [time: number, requestedTime: number | string]
|
||||
'setBar': [type: string, percentage: number, event?: MouseEvent | TouchEvent]
|
||||
'subtitleBeforeUpdate': [cues: SubtitleCue[]]
|
||||
'subtitleAfterUpdate': [cues: SubtitleCue[]]
|
||||
'subtitleLoad': [cues: SubtitleCue[], option: SubtitleOption | null]
|
||||
}
|
||||
|
||||
/** Legacy custom event augmentation is retained; builtin payload corrections take precedence. */
|
||||
export interface Events extends Omit<LegacyEvents, keyof BuiltinEvents>, NativeEvents, BuiltinEvents, Record<PropertyKey, unknown[]> {}
|
||||
@@ -0,0 +1,41 @@
|
||||
export type MediaState = Pick<HTMLMediaElement, 'currentTime' | 'duration' | 'paused' | 'ended' | 'readyState'> & {
|
||||
readonly playing?: boolean
|
||||
}
|
||||
|
||||
export interface PlaybackMethods<PlayResult = unknown, PauseResult = unknown> {
|
||||
play: () => PlayResult
|
||||
pause: () => PauseResult
|
||||
}
|
||||
|
||||
export interface OptionalMediaCapabilities {
|
||||
readonly textTracks?: ArrayLike<TextTrack>
|
||||
readonly error?: unknown
|
||||
requestPictureInPicture?: () => Promise<PictureInPictureWindow>
|
||||
requestVideoFrameCallback?: (callback: VideoFrameRequestCallback) => number
|
||||
cancelVideoFrameCallback?: (handle: number) => void
|
||||
webkitEnterFullscreen?: () => void
|
||||
webkitExitFullscreen?: () => void
|
||||
readonly webkitSupportsFullscreen?: boolean
|
||||
webkitShowPlaybackTargetPicker?: () => void
|
||||
webkitSupportsPresentationMode?: (mode: string) => boolean
|
||||
webkitSetPresentationMode?: (mode: string) => void
|
||||
readonly webkitPresentationMode?: string
|
||||
readonly webkitDisplayingFullscreen?: boolean
|
||||
}
|
||||
|
||||
export type NativeMedia = Omit<HTMLVideoElement, keyof OptionalMediaCapabilities> & OptionalMediaCapabilities
|
||||
|
||||
export type CanvasMedia = HTMLCanvasElement & MediaState & PlaybackMethods & OptionalMediaCapabilities & {
|
||||
src: string | null
|
||||
readonly currentSrc: string | null
|
||||
readonly videoWidth: number
|
||||
readonly videoHeight: number
|
||||
readonly buffered: TimeRanges
|
||||
volume: number
|
||||
muted: boolean
|
||||
playbackRate: number
|
||||
load: () => unknown
|
||||
}
|
||||
|
||||
/** Check optional capabilities before calling them on a native or proxy surface. */
|
||||
export type MediaSurface = NativeMedia | CanvasMedia
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { OptionInput as LegacyOptionInput, Thumbnails } from '../option'
|
||||
import type { ComponentInput, ControlInput } from './component'
|
||||
import type { MediaSurface } from './media'
|
||||
import type { PluginFactory } from './plugin'
|
||||
import type { Languages } from './services'
|
||||
import type { SettingItem } from './setting'
|
||||
import type { SubtitleOption } from './subtitle'
|
||||
|
||||
/** Callback receivers are the unchanged player instance selected by this view. */
|
||||
export interface OptionInput<Host> extends Omit<LegacyOptionInput, 'container' | 'proxy' | 'plugins' | 'layers' | 'controls' | 'contextmenu' | 'settings' | 'customType' | 'i18n' | 'icons'> {
|
||||
container: string | HTMLDivElement
|
||||
proxy?: (this: Host, art: Host) => MediaSurface | undefined
|
||||
plugins?: PluginFactory<Host>[]
|
||||
layers?: ComponentInput<Host>[]
|
||||
controls?: ControlInput<Host>[]
|
||||
contextmenu?: ComponentInput<Host>[]
|
||||
settings?: SettingItem<Host>[]
|
||||
customType?: Record<string, ((this: Host, video: MediaSurface, url: string, art: Host) => unknown) | undefined>
|
||||
i18n?: Languages
|
||||
icons?: Record<string, string | HTMLElement | undefined>
|
||||
}
|
||||
|
||||
/** Defaults are merged once; later setters may replace thumbnails with a partial input. */
|
||||
export interface Option<Host> extends Omit<Required<OptionInput<Host>>, 'proxy' | 'subtitle' | 'thumbnails'> {
|
||||
proxy: OptionInput<Host>['proxy']
|
||||
subtitle: SubtitleOption
|
||||
thumbnails: Thumbnails
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import type { Thumbnails } from '../option'
|
||||
import type { State } from '../player'
|
||||
import type { MediaSurface } from './media'
|
||||
|
||||
export interface QualityItem {
|
||||
html: string | HTMLElement
|
||||
url: string
|
||||
default?: boolean
|
||||
}
|
||||
|
||||
/** Player-facing descriptors; native/proxy method results retain their identity. */
|
||||
export interface Player<Media extends MediaSurface = MediaSurface> {
|
||||
get currentTime(): number
|
||||
set currentTime(time: number | string)
|
||||
readonly duration: number
|
||||
get seek(): undefined
|
||||
set seek(time: number | string)
|
||||
get forward(): undefined
|
||||
set forward(time: number)
|
||||
get backward(): undefined
|
||||
set backward(time: number)
|
||||
get switch(): undefined
|
||||
set switch(url: string)
|
||||
get quality(): undefined
|
||||
set quality(items: QualityItem[])
|
||||
get url(): string | null
|
||||
set url(value: string)
|
||||
get state(): State
|
||||
set state(value: string)
|
||||
get pip(): Element | null | boolean
|
||||
set pip(value: boolean)
|
||||
/** The descriptor may be absent before metadata installs the available mode. */
|
||||
fullscreen?: boolean
|
||||
fullscreenWeb: boolean
|
||||
mini: boolean
|
||||
volume: number
|
||||
muted: boolean
|
||||
playbackRate: number
|
||||
aspectRatio: string
|
||||
flip: string
|
||||
poster: string
|
||||
theme: string
|
||||
type: string
|
||||
subtitleOffset: number
|
||||
thumbnails: Thumbnails
|
||||
readonly loaded: number
|
||||
readonly loadedTime: number
|
||||
readonly played: number
|
||||
readonly playing: boolean
|
||||
readonly rect: DOMRect
|
||||
readonly bottom: number
|
||||
readonly height: number
|
||||
readonly left: number
|
||||
readonly right: number
|
||||
readonly top: number
|
||||
readonly width: number
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
play: () => Promise<Awaited<ReturnType<Media['play']>>>
|
||||
pause: () => ReturnType<Media['pause']>
|
||||
toggle: () => Promise<Awaited<ReturnType<Media['play']>>> | ReturnType<Media['pause']>
|
||||
switchUrl: (url: string) => Promise<void>
|
||||
switchQuality: (url: string) => Promise<void>
|
||||
autoSize: () => void
|
||||
autoHeight: () => void
|
||||
airplay: () => void
|
||||
getDataURL: () => Promise<string>
|
||||
getBlobUrl: () => Promise<string>
|
||||
screenshot: (name?: string) => Promise<string>
|
||||
attr: {
|
||||
(key: PropertyKey): unknown
|
||||
(key: PropertyKey, value: unknown): unknown
|
||||
}
|
||||
cssVar: {
|
||||
(key: string): string
|
||||
(key: string, value: unknown): string | void
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export type PluginFactory<Host, Result = unknown> = (this: Host, art: Host) => Result
|
||||
|
||||
export type PluginRegistration<Result, Registry>
|
||||
= unknown extends Result ? Registry | Promise<Registry>
|
||||
: Result extends Promise<unknown> ? Promise<Registry> : Registry
|
||||
|
||||
/** The same registry is returned immediately or after its Promise factory settles. */
|
||||
export interface Plugins<Host> {
|
||||
art: Host
|
||||
id: number
|
||||
add: <Result>(plugin: PluginFactory<Host, Result>) => PluginRegistration<Result, this>
|
||||
next: (plugin: PluginFactory<Host>, result: unknown) => this
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
export interface Config {
|
||||
properties: string[]
|
||||
methods: string[]
|
||||
events: string[]
|
||||
prototypes: string[]
|
||||
}
|
||||
|
||||
export type Disposer = () => void
|
||||
export type Listener = EventListenerOrEventListenerObject | null
|
||||
|
||||
export interface EventRegistry {
|
||||
destroyEvents: Set<Disposer>
|
||||
proxy: {
|
||||
(target: EventTarget, name: string, callback: Listener, option?: boolean | AddEventListenerOptions | null): Disposer
|
||||
(target: EventTarget, name: string[], callback: Listener, option?: boolean | AddEventListenerOptions | null): Disposer[]
|
||||
(target: EventTarget, name: string | string[], callback: Listener, option?: boolean | AddEventListenerOptions | null): Disposer | Disposer[]
|
||||
}
|
||||
hover: (target: EventTarget, mouseenter?: (event: Event) => unknown, mouseleave?: (event: Event) => unknown) => void
|
||||
remove: (dispose: Disposer) => void
|
||||
destroy: () => void
|
||||
bindGlobalEvents: (source?: { window?: Window, document?: Document }) => void
|
||||
}
|
||||
|
||||
export interface Storage {
|
||||
name: string
|
||||
settings: Record<PropertyKey, unknown>
|
||||
get: (key?: PropertyKey) => unknown
|
||||
set: (key: PropertyKey, value: unknown) => void
|
||||
del: (key: PropertyKey) => void
|
||||
clear: () => void
|
||||
}
|
||||
|
||||
export type Dictionary = Record<string, string | undefined>
|
||||
export type Languages = Record<string, Dictionary | undefined>
|
||||
|
||||
export interface I18n<Host> {
|
||||
art: Host
|
||||
languages: Languages
|
||||
language: Dictionary
|
||||
init: () => void
|
||||
get: (key: string) => string
|
||||
update: (value: Languages) => void
|
||||
}
|
||||
|
||||
export type HotkeyCallback<Host> = (this: Host, event: KeyboardEvent) => unknown
|
||||
|
||||
export interface Hotkey<Host> {
|
||||
art: Host
|
||||
keys: Record<string, HotkeyCallback<Host>[]>
|
||||
init: () => void
|
||||
add: (key: string, callback: HotkeyCallback<Host>) => this
|
||||
remove: (key: string, callback: HotkeyCallback<Host>) => this
|
||||
}
|
||||
|
||||
export type ValidatorPath = (string | number)[]
|
||||
export type Validator = (value: unknown, type: string, paths: ValidatorPath) => unknown
|
||||
export type Scheme = string | Validator | Scheme[] | { [key: string]: Scheme }
|
||||
@@ -0,0 +1,58 @@
|
||||
export type SettingContent = string | HTMLElement | number
|
||||
export type SettingRange = [value?: number, min?: number, max?: number, step?: number]
|
||||
export type SettingCallback<Host> = (this: Host, item: SettingItem<Host>, element: HTMLDivElement, event: Event) => unknown
|
||||
|
||||
export interface SettingItem<Host> {
|
||||
name?: string
|
||||
html?: SettingContent
|
||||
icon?: SettingContent
|
||||
tooltip?: SettingContent
|
||||
width?: number
|
||||
value?: string | number
|
||||
default?: boolean
|
||||
switch?: boolean
|
||||
range?: SettingRange
|
||||
selector?: SettingItem<Host>[]
|
||||
mounted?: (this: Host, element: HTMLDivElement, item: SettingItem<Host>) => unknown
|
||||
onClick?: SettingCallback<Host>
|
||||
onSwitch?: SettingCallback<Host>
|
||||
onRange?: SettingCallback<Host>
|
||||
onChange?: SettingCallback<Host>
|
||||
onSelect?: SettingCallback<Host>
|
||||
readonly $parent?: SettingItem<Host>
|
||||
readonly $parents?: SettingItem<Host>[]
|
||||
readonly $option?: SettingItem<Host>[]
|
||||
readonly $events?: (() => void)[]
|
||||
readonly $formatted?: boolean
|
||||
readonly $item?: HTMLDivElement
|
||||
readonly $icon?: HTMLDivElement
|
||||
readonly $html?: HTMLDivElement
|
||||
readonly $tooltip?: HTMLDivElement
|
||||
readonly $switch?: HTMLDivElement
|
||||
readonly $range?: HTMLInputElement
|
||||
}
|
||||
|
||||
export interface Setting<Host> {
|
||||
id: number
|
||||
art: Host
|
||||
name: string
|
||||
$parent: HTMLElement
|
||||
cache: Map<SettingItem<Host>[], HTMLDivElement>
|
||||
active: SettingItem<Host>[] | null
|
||||
option: SettingItem<Host>[]
|
||||
readonly builtin: SettingItem<Host>[]
|
||||
show: boolean
|
||||
toggle: () => void
|
||||
traverse: (callback: (item: SettingItem<Host>) => void, option?: SettingItem<Host>[]) => void
|
||||
check: (target?: SettingItem<Host> | null) => void
|
||||
format: (option?: SettingItem<Host>[], parent?: SettingItem<Host>, parents?: SettingItem<Host>[], names?: string[]) => void
|
||||
find: (name?: string) => SettingItem<Host> | null
|
||||
resize: () => void
|
||||
inactivate: (item: SettingItem<Host>) => void
|
||||
remove: (name: string) => void
|
||||
update: (item: SettingItem<Host>) => SettingItem<Host>
|
||||
add: <Item extends SettingItem<Host>>(item: Item, option?: SettingItem<Host>[]) => Item
|
||||
createHeader: (item: SettingItem<Host>) => void
|
||||
createItem: (item: SettingItem<Host>, isUpdate?: boolean) => void
|
||||
render: (option?: SettingItem<Host>[]) => void
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { Subtitle as SubtitleInput } from '../subtitle'
|
||||
|
||||
export type SubtitleOption = Required<SubtitleInput>
|
||||
|
||||
export interface SubtitleCue extends TextTrackCue {
|
||||
text: string
|
||||
originalStartTime?: number
|
||||
originalEndTime?: number
|
||||
}
|
||||
|
||||
export interface SubtitleTrack extends HTMLTrackElement { offset?: number }
|
||||
|
||||
export interface Subtitle {
|
||||
name: string
|
||||
option: SubtitleOption | null
|
||||
destroyEvent: () => unknown
|
||||
url: string
|
||||
readonly textTrack: TextTrack | undefined
|
||||
readonly activeCues: SubtitleCue[]
|
||||
readonly cues: SubtitleCue[]
|
||||
show: boolean
|
||||
toggle: () => void
|
||||
style: {
|
||||
(styles: Partial<CSSStyleDeclaration>): HTMLDivElement
|
||||
(key: string, value: string | number): HTMLDivElement
|
||||
}
|
||||
update: () => void
|
||||
switch: (url: string, option?: SubtitleInput) => Promise<string | null | undefined>
|
||||
init: (option: SubtitleOption) => Promise<string | null | undefined>
|
||||
createTrack: (kind: string, url: string) => void
|
||||
}
|
||||
|
||||
export interface Notice {
|
||||
timer: number | null
|
||||
get show(): boolean
|
||||
set show(value: string | Error | false)
|
||||
destroy: () => void
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import type { MediaSurface } from './media'
|
||||
|
||||
/** Query results remain nullable for caller-supplied SSR templates. */
|
||||
export interface Template<Host, Media extends MediaSurface = MediaSurface> {
|
||||
art: Host
|
||||
$container: HTMLDivElement
|
||||
$player: HTMLDivElement | null
|
||||
$video: Media
|
||||
$track: HTMLTrackElement | null
|
||||
$poster: HTMLDivElement | null
|
||||
$subtitle: HTMLDivElement | null
|
||||
$danmuku: HTMLDivElement | null
|
||||
$bottom: HTMLDivElement | null
|
||||
$progress: HTMLDivElement | null
|
||||
$controls: HTMLDivElement | null
|
||||
$controlsLeft: HTMLDivElement | null
|
||||
$controlsCenter: HTMLDivElement | null
|
||||
$controlsRight: HTMLDivElement | null
|
||||
$layer: HTMLDivElement | null
|
||||
$loading: HTMLDivElement | null
|
||||
$notice: HTMLDivElement | null
|
||||
$noticeInner: HTMLDivElement | null
|
||||
$mask: HTMLDivElement | null
|
||||
$state: HTMLDivElement | null
|
||||
$setting: HTMLDivElement | null
|
||||
$info: HTMLDivElement | null
|
||||
$infoPanel: HTMLDivElement | null
|
||||
$infoClose: HTMLDivElement | null
|
||||
$contextmenu: HTMLDivElement | null
|
||||
$mini?: HTMLElement
|
||||
query: <ElementType extends Element = Element>(selector: string) => ElementType | null
|
||||
init: () => void
|
||||
destroy: (removeHtml: boolean) => void
|
||||
}
|
||||
|
||||
export type IconName = 'loading' | 'state' | 'play' | 'pause' | 'check' | 'volume' | 'volumeClose'
|
||||
| 'screenshot' | 'setting' | 'pip' | 'arrowLeft' | 'arrowRight' | 'playbackRate' | 'aspectRatio'
|
||||
| 'config' | 'lock' | 'flip' | 'unlock' | 'fullscreenOff' | 'fullscreenOn' | 'fullscreenWebOff'
|
||||
| 'fullscreenWebOn' | 'switchOn' | 'switchOff' | 'error' | 'close' | 'airplay'
|
||||
|
||||
/** Default getters create fresh icon wrappers; unknown custom keys may be absent. */
|
||||
export type Icons = Readonly<Record<IconName, HTMLElement>> & { readonly [name: string]: HTMLElement | undefined }
|
||||
@@ -0,0 +1,67 @@
|
||||
interface StyledElement { style: CSSStyleDeclaration }
|
||||
interface EventPathSource {
|
||||
target: EventTarget | null
|
||||
composedPath?: () => EventTarget[]
|
||||
}
|
||||
type StackFrame = ((...args: never[]) => unknown) | (abstract new (...args: never[]) => object)
|
||||
|
||||
export interface Utils {
|
||||
isBrowser: boolean
|
||||
userAgent: string
|
||||
isMobile: boolean
|
||||
isSafari: boolean
|
||||
isIOS: boolean
|
||||
isIOS13: boolean
|
||||
query: <T extends Element = Element>(selector: string, parent?: ParentNode) => T | null
|
||||
queryAll: <T extends Element = Element>(selector: string, parent?: ParentNode) => T[]
|
||||
addClass: (target: Pick<Element, 'classList'>, className: string) => void
|
||||
removeClass: (target: Pick<Element, 'classList'>, className: string) => void
|
||||
hasClass: (target: Pick<Element, 'classList'>, className: string) => boolean
|
||||
append: (parent: Element, child: unknown) => Element | ChildNode | null
|
||||
remove: <T extends Node>(child: T) => T
|
||||
replaceElement: <T extends Node>(newChild: T, oldChild: Node) => T
|
||||
siblings: (target: Element) => Element[]
|
||||
inverseClass: (target: Element, className: string) => void
|
||||
createElement: {
|
||||
<K extends keyof HTMLElementTagNameMap>(tag: K): HTMLElementTagNameMap[K]
|
||||
(tag: string): HTMLElement
|
||||
}
|
||||
setStyle: <T extends StyledElement>(element: T, key: PropertyKey, value: unknown) => T
|
||||
setStyles: <T extends StyledElement>(element: T, styles: object) => T
|
||||
getStyle: {
|
||||
(element: Element, key: string, numberType?: true): number
|
||||
(element: Element, key: string, numberType: false): string
|
||||
(element: Element, key: string, numberType: boolean): number | string
|
||||
}
|
||||
setStyleText: (id: string, cssText: string) => void
|
||||
getRect: (element: Pick<Element, 'getBoundingClientRect'>) => DOMRect
|
||||
tooltip: (target: Element, message: string | number, position?: string) => void
|
||||
isInViewport: (target: Pick<Element, 'getBoundingClientRect'>, offset?: number) => boolean
|
||||
includeFromEvent: (event: EventPathSource, target: EventTarget | null | undefined) => boolean
|
||||
getSafeAreaInsets: () => { top: number, right: number, bottom: number, left: number }
|
||||
srtToVtt: (text: string) => string
|
||||
vttToBlob: (text: string) => string
|
||||
assToVtt: (text: string) => string
|
||||
getExt: (url: string) => string
|
||||
download: (url: string, name: string) => void
|
||||
loadImg: (url: string, scale?: number) => Promise<HTMLImageElement>
|
||||
errorHandle: <T>(condition: T, message?: string) => T
|
||||
silencePromise: <T>(value: T) => T extends Promise<infer Result> ? Promise<Result | undefined> : T
|
||||
def: <T extends object>(object: T, name: PropertyKey, descriptor: PropertyDescriptor & object & ThisType<T>) => T
|
||||
has: (object: object, name: PropertyKey) => boolean
|
||||
get: (object: object, name: PropertyKey) => PropertyDescriptor | undefined
|
||||
mergeDeep: <T extends object[]>(...objects: T) => T[number]
|
||||
sleep: (milliseconds?: number) => Promise<void>
|
||||
/** The wrapper preserves its call receiver; the old context argument is ignored. */
|
||||
debounce: <Receiver, Args extends unknown[]>(callback: (this: Receiver, ...args: Args) => unknown, duration: number, context?: object) => (this: Receiver, ...args: Args) => void
|
||||
throttle: <Receiver, Args extends unknown[]>(callback: (this: Receiver, ...args: Args) => unknown, duration: number) => (this: Receiver, ...args: Args) => void
|
||||
clamp: (number: number, a: number, b: number) => number
|
||||
secondToTime: (second: number) => string
|
||||
escape: (text: string) => string
|
||||
unescape: (text: string) => string
|
||||
capitalize: (text: string) => string
|
||||
ArtPlayerError: new (message?: string, context?: StackFrame) => Error
|
||||
getIcon: (key?: string, html?: string | HTMLElement) => HTMLElement
|
||||
getComposedPath: (event: EventPathSource) => EventTarget[]
|
||||
supportsFlex: () => boolean
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import type Artplayer from './artplayer'
|
||||
|
||||
export interface SettingOption extends Omit<Setting, 'html' | 'icon' | 'tooltip'> {
|
||||
html: string
|
||||
icon: string | undefined
|
||||
tooltip: string | undefined
|
||||
$item: HTMLDivElement
|
||||
$icon: HTMLDivElement | undefined
|
||||
$html: HTMLDivElement
|
||||
$tooltip: HTMLDivElement | undefined
|
||||
$switch: HTMLDivElement | undefined
|
||||
$range: HTMLInputElement | undefined
|
||||
$parent: SettingOption | undefined
|
||||
$parents: SettingOption[]
|
||||
$option: SettingOption[]
|
||||
$events: Array<() => void>
|
||||
$formatted: boolean
|
||||
}
|
||||
|
||||
export interface Setting {
|
||||
/**
|
||||
* Html string or html element of setting name
|
||||
*/
|
||||
html: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Html string or html element of setting icon
|
||||
*/
|
||||
icon?: string | HTMLElement
|
||||
|
||||
/**
|
||||
* The width of setting
|
||||
*/
|
||||
width?: number
|
||||
|
||||
/**
|
||||
* The tooltip of setting
|
||||
*/
|
||||
tooltip?: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Whether the default is selected
|
||||
*/
|
||||
default?: boolean
|
||||
|
||||
/**
|
||||
* Custom selector list
|
||||
*/
|
||||
selector?: Setting[]
|
||||
|
||||
/**
|
||||
* When the setting was mounted
|
||||
*/
|
||||
mounted?: (this: Artplayer, panel: HTMLDivElement, item: Setting) => void
|
||||
|
||||
/**
|
||||
* When selector item click
|
||||
*/
|
||||
onSelect?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* Custom switch item
|
||||
*/
|
||||
switch?: boolean
|
||||
|
||||
/**
|
||||
* When switch item click
|
||||
*/
|
||||
onSwitch?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* Custom range item
|
||||
*/
|
||||
range?: [value?: number, min?: number, max?: number, step?: number]
|
||||
|
||||
/**
|
||||
* When range item change
|
||||
*/
|
||||
onRange?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* When range item change in real time
|
||||
*/
|
||||
onChange?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* When range item change in real time
|
||||
*/
|
||||
onClick?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* Allow custom properties
|
||||
*/
|
||||
[key: string]: any
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
export interface Subtitle {
|
||||
/**
|
||||
* The subtitle url
|
||||
*/
|
||||
url?: string
|
||||
|
||||
/**
|
||||
* The subtitle name
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* The subtitle type
|
||||
*/
|
||||
type?: 'vtt' | 'srt' | 'ass' | (string & Record<never, never>)
|
||||
|
||||
/**
|
||||
* The subtitle style object
|
||||
*/
|
||||
style?: Partial<CSSStyleDeclaration>
|
||||
|
||||
/**
|
||||
* The subtitle encoding, default utf-8
|
||||
*/
|
||||
encoding?: string
|
||||
|
||||
/**
|
||||
* Whether use escape, default true
|
||||
*/
|
||||
escape?: boolean
|
||||
|
||||
/**
|
||||
* Change the vtt text
|
||||
*/
|
||||
onVttLoad?: (vtt: string) => string
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
export interface Template {
|
||||
readonly html: string
|
||||
readonly $container: HTMLDivElement
|
||||
readonly $player: HTMLDivElement
|
||||
readonly $video: HTMLVideoElement
|
||||
readonly $track: HTMLTrackElement
|
||||
readonly $poster: HTMLDivElement
|
||||
readonly $subtitle: HTMLDivElement
|
||||
readonly $danmuku: HTMLDivElement
|
||||
readonly $bottom: HTMLDivElement
|
||||
readonly $progress: HTMLDivElement
|
||||
readonly $controls: HTMLDivElement
|
||||
readonly $controlsLeft: HTMLDivElement
|
||||
readonly $controlsCenter: HTMLDivElement
|
||||
readonly $controlsRight: HTMLDivElement
|
||||
readonly $layer: HTMLDivElement
|
||||
readonly $loading: HTMLDivElement
|
||||
readonly $notice: HTMLDivElement
|
||||
readonly $noticeInner: HTMLDivElement
|
||||
readonly $mask: HTMLDivElement
|
||||
readonly $state: HTMLDivElement
|
||||
readonly $setting: HTMLDivElement
|
||||
readonly $info: HTMLDivElement
|
||||
readonly $infoPanel: HTMLDivElement
|
||||
readonly $infoClose: HTMLDivElement
|
||||
readonly $contextmenu: HTMLDivElement
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
export interface Utils {
|
||||
isBrowser: boolean
|
||||
userAgent: string
|
||||
isMobile: boolean
|
||||
isSafari: boolean
|
||||
isIOS: boolean
|
||||
isIOS13: boolean
|
||||
|
||||
query: <T extends Element = Element>(selector: string, parent?: Document | HTMLElement) => T | null
|
||||
queryAll: <T extends Element = Element>(selector: string, parent?: Document | HTMLElement) => T[]
|
||||
addClass: (target: HTMLElement, className: string) => void
|
||||
removeClass: (target: HTMLElement, className: string) => void
|
||||
hasClass: (target: HTMLElement, className: string) => boolean
|
||||
append: (target: HTMLElement, child: HTMLElement | string) => Element | ChildNode
|
||||
remove: (target: HTMLElement) => HTMLElement
|
||||
replaceElement: (newChild: HTMLElement, oldChild: HTMLElement) => HTMLElement
|
||||
siblings: (target: HTMLElement) => HTMLElement[]
|
||||
inverseClass: (target: HTMLElement, className: string) => void
|
||||
createElement: <K extends keyof HTMLElementTagNameMap>(tag: K) => HTMLElementTagNameMap[K]
|
||||
setStyle: <T extends keyof CSSStyleDeclaration>(
|
||||
element: HTMLElement,
|
||||
key: T,
|
||||
value: string | CSSStyleDeclaration[T],
|
||||
) => HTMLElement
|
||||
setStyles: (element: HTMLElement, styles: Partial<CSSStyleDeclaration>) => HTMLElement
|
||||
getStyle: {
|
||||
(element: HTMLElement, key: keyof CSSStyleDeclaration, numberType?: true): number
|
||||
(element: HTMLElement, key: keyof CSSStyleDeclaration, numberType: false): string
|
||||
}
|
||||
setStyleText: (id: string, cssText: string) => void
|
||||
getRect: (el: HTMLElement) => { top: number, left: number, width: number, height: number }
|
||||
tooltip: (target: HTMLElement, msg: string, pos?: string) => void
|
||||
isInViewport: (target: HTMLElement, offset?: number) => boolean
|
||||
includeFromEvent: (event: Event, target: HTMLElement) => boolean
|
||||
getSafeAreaInsets: () => { top: number, right: number, bottom: number, left: number }
|
||||
|
||||
srtToVtt: (srtText: string) => string
|
||||
vttToBlob: (vttText: string) => string
|
||||
assToVtt: (assText: string) => string
|
||||
|
||||
getExt: (url: string) => string
|
||||
download: (url: string, name: string) => void
|
||||
loadImg: (url: string, scale?: number) => Promise<HTMLImageElement>
|
||||
|
||||
errorHandle: <T extends boolean>(condition: T, msg: string) => T extends true ? T : never
|
||||
silencePromise: <T>(value: T) => T extends Promise<infer R> ? Promise<R | undefined> : T
|
||||
def: {
|
||||
/** Historical string-key signature; runtime returns obj. */
|
||||
(obj: object, name: string, value: unknown): void
|
||||
<T>(obj: T, name: PropertyKey, value: PropertyDescriptor & ThisType<T>): T
|
||||
}
|
||||
has: (obj: object, name: PropertyKey) => boolean
|
||||
get: (obj: object, name: PropertyKey) => PropertyDescriptor | undefined
|
||||
mergeDeep: <T extends object[]>(...args: T) => T[number]
|
||||
|
||||
sleep: (ms?: number) => Promise<void>
|
||||
/** Historical return type; runtime discards the callback result and ignores context. */
|
||||
debounce: <F extends (...args: any[]) => any>(func: F, wait: number, context?: object) => (...args: Parameters<F>) => ReturnType<F>
|
||||
/** Historical return type; runtime discards the callback result. */
|
||||
throttle: <F extends (...args: any[]) => any>(func: F, wait: number) => (...args: Parameters<F>) => ReturnType<F>
|
||||
|
||||
clamp: (num: number, a: number, b: number) => number
|
||||
secondToTime: (second: number) => string
|
||||
escape: (str: string) => string
|
||||
unescape: (str: string) => string
|
||||
capitalize: (str: string) => string
|
||||
|
||||
ArtPlayerError: new (message?: string, context?: ((...args: never[]) => unknown) | (abstract new (...args: never[]) => object)) => Error
|
||||
|
||||
getIcon: (key?: string, html?: string | HTMLElement) => HTMLElement
|
||||
getComposedPath: (event: Event) => EventTarget[]
|
||||
supportsFlex: () => boolean
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export interface UIEvents {
|
||||
'setting': [boolean]
|
||||
'aspectRatio': [string]
|
||||
'flip': [string]
|
||||
'blur': []
|
||||
'blur': [Event]
|
||||
'resize': []
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,8 @@
|
||||
import type { UIEvents } from '../control/types'
|
||||
import type { Events } from '../../types/runtime/events'
|
||||
|
||||
// The emitter stays open to extension names. Known native events retain their
|
||||
// payloads so subsystem subscriptions are checked against the assembled player.
|
||||
export interface CoreEvents extends UIEvents, Record<PropertyKey, unknown[]> {
|
||||
[name: `video:${string}`]: [event: Event]
|
||||
'ready': []
|
||||
'error': [error: unknown, attempt: number]
|
||||
'fullscreenError': [error: unknown]
|
||||
'destroy': []
|
||||
'restart': [string]
|
||||
'focus': [Event]
|
||||
'lock': [boolean]
|
||||
'view': [boolean]
|
||||
'subtitleOffset': [number]
|
||||
'seek': [time: number, requestedTime: number | string]
|
||||
'document:click': [Event]
|
||||
'document:contextmenu': [Event]
|
||||
'document:keydown': [KeyboardEvent]
|
||||
'document:touchmove': [Event]
|
||||
'document:touchend': [Event]
|
||||
'document:touchcancel': [Event]
|
||||
'window:resize': [Event]
|
||||
'window:orientationchange': [Event]
|
||||
'window:scroll': [Event]
|
||||
}
|
||||
export interface CoreEvents extends Events {}
|
||||
|
||||
export interface CoreEmission<Names extends keyof CoreEvents = keyof CoreEvents> {
|
||||
emit: <Name extends Names>(name: Name, ...args: [...CoreEvents[Name]]) => unknown
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface SettingItem extends TreeItem {
|
||||
}
|
||||
|
||||
export interface SettingEvents {
|
||||
'blur': []
|
||||
'blur': [Event]
|
||||
'focus': [event: Event]
|
||||
'resize': []
|
||||
'video:ratechange': [Event]
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"types/**/*.d.mts",
|
||||
"types/**/*.d.cts",
|
||||
"../../types/assets.d.ts",
|
||||
"../../types/option-validator.d.ts"
|
||||
"../../types/option-validator.d.ts",
|
||||
"public/**/*.ts",
|
||||
"public/**/*.mts",
|
||||
"public/**/*.cts"
|
||||
]
|
||||
}
|
||||
@@ -46,10 +46,10 @@ if (pending)
|
||||
|
||||
The original `art.toggle(): void` declaration remains accepted by historical
|
||||
consumers. The optional view exposes `Promise<void> | void`; play rejection and
|
||||
the original object identity remain unchanged. BASE-TYPE-04 stays open for the
|
||||
remaining plugins.add conflict and CORE-21's full facade review.
|
||||
the original object identity remain unchanged. CORE-21 also provides a complete
|
||||
optional precise entry for these differences, described below.
|
||||
|
||||
| Surface | Actual runtime | Retained historical declaration | Follow-up |
|
||||
| Surface | Actual runtime | Retained historical declaration | Owning task / finding |
|
||||
| ------------------------------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------ |
|
||||
| plugins.add | Registry for a synchronous factory; Promise of registry for a Promise factory | Always Promise | CORE-08/21, BASE-TYPE-04 |
|
||||
| toggle | Pause result or original play Promise, including rejection | void | CORE-10/21, BASE-TYPE-04 |
|
||||
@@ -61,9 +61,9 @@ remaining plugins.add conflict and CORE-21's full facade review.
|
||||
| notice.show getter | Boolean visibility | Historical message/false union | CORE-18/21, BASE-TYPE-07 |
|
||||
| seek/forward/backward/switch/quality reads | Undefined: these descriptors only have setters | Numeric/string/quality-array getters | CORE-21, BASE-TYPE-08 |
|
||||
|
||||
These remain open declaration work, not release waivers. CORE-21 must resolve the
|
||||
public/generated facade strategy against both actual returns and historical source
|
||||
consumers. Migrated implementation modules must use their accurate internal types.
|
||||
These historical declarations remain intentionally compatible. The runtime entry
|
||||
below provides their accurate counterparts; it does not change the implementation
|
||||
to make historical inaccuracies true. Migrated modules use accurate internal types.
|
||||
For existing application code, awaiting plugins.add or toggle works for synchronous
|
||||
and Promise results; ignore timer results, guard setting.find with a truthiness
|
||||
check, and explicitly annotate cue-array listeners. Do not rely on the inaccurate
|
||||
@@ -74,6 +74,49 @@ these command properties returns undefined; use currentTime, option and media
|
||||
state for observations. Source interfaces model undefined reads independently
|
||||
of setter inputs. Historical public getter declarations are not removed here.
|
||||
|
||||
## Precise entry and compiler boundary
|
||||
|
||||
Use `artplayer/runtime` for precise types on the existing modern JS constructor,
|
||||
or `artplayer/runtime/legacy` for the existing legacy JS constructor. Both share
|
||||
the `artplayer/runtime/types` augmentation entry and the same public TypeScript
|
||||
source graph. Existing root/legacy/types/i18n imports retain their old acceptance
|
||||
and TypeScript 4.3.5 support. The precise entry is tested with 5.1.6 and 5.9.3;
|
||||
unrelated getter/setter types require the TypeScript 5.1 language feature.
|
||||
|
||||
```ts
|
||||
import Artplayer from 'artplayer/runtime'
|
||||
|
||||
const art = new Artplayer({ container: '#player' })
|
||||
const registered = art.plugins.add(() => ({ name: 'example' })) // same registry
|
||||
art.seek = 12
|
||||
const seekRead: undefined = art.seek
|
||||
const visible: boolean = art.notice.show
|
||||
const item = art.setting.find('quality') // item or null
|
||||
```
|
||||
|
||||
Precise timer wrappers return void, def requires object target/descriptor and
|
||||
returns the target, settings return their actual item/null/void values, and
|
||||
subtitle update callbacks infer cue arrays. Media/proxy method return types are
|
||||
kept distinct. Command reads are undefined; native PiP reads Element|null while
|
||||
fallbacks read boolean. Template nodes may be null, icons are HTMLElement wrappers,
|
||||
template.html is absent, and only the constructor exposes html. env/build are
|
||||
not fabricated. Containers must be div elements and new controls need a supported
|
||||
position. The old fields and wrong signatures remain available only in the legacy
|
||||
type view; precise instances are not asserted assignable to that inaccurate view.
|
||||
|
||||
Constructor input overloads accept old typed plugins without wrapping factories.
|
||||
Named plugin result/custom event augmentation flows from the old shared types to
|
||||
the new view; new augmentation should target artplayer/runtime/types. Constructor
|
||||
plugin callbacks see plugins as optional until its registry is assigned. Other
|
||||
early construction hosts similarly expose only initialized components; customType,
|
||||
setting mounted and ready callbacks run after construction. The actual input
|
||||
factory, callback receiver and player identities are unchanged.
|
||||
|
||||
The docs global keeps the legacy view for its bundled Monaco compiler. build:ts
|
||||
follows the public type graph and generates a standalone UMD declaration; modern
|
||||
runtime declarations are not merged into it. This is independent of the npm
|
||||
declaration generator and does not add runtime code.
|
||||
|
||||
## Evidence and maintenance
|
||||
|
||||
declaration-legacy.ts is a compile-only regression fixture, not recommended runtime
|
||||
|
||||
@@ -1,8 +1,36 @@
|
||||
# Declaration entrypoints
|
||||
|
||||
`artplayer.d.ts` remains the shared API definition and old TypeScript entry. Its
|
||||
relative declarations describe the existing player; they are not a claim that the
|
||||
runtime has already migrated to TypeScript.
|
||||
The TypeScript files in `../public/` are the source for these declarations.
|
||||
`yarn build:types` uses the pinned TypeScript compiler to emit the existing `.d.ts`,
|
||||
`.d.mts` and `.d.cts` paths; `yarn check:types` verifies them without writing.
|
||||
Do not hand-edit generated declarations. The generator rejects dependencies on
|
||||
implementation files and emits no JavaScript. Public source files are excluded
|
||||
from the npm package.
|
||||
|
||||
`artplayer.d.ts` remains the shared API definition and old TypeScript entry.
|
||||
This facade preserves historical consumer acceptance; COMPATIBILITY.md explains
|
||||
the retained inaccuracies and the optional precise view.
|
||||
|
||||
CORE-21 generates precise modules in `runtime/` and assembles them in runtime.d.ts.
|
||||
Choose `import Artplayer from 'artplayer/runtime'` for the precise view, or
|
||||
`artplayer/runtime/legacy` for the existing legacy JS build with the same precise
|
||||
types. These views require the modern accessor syntax tested with TypeScript
|
||||
5.1.6 and 5.9.3. Their JS targets are identical to the corresponding existing
|
||||
entrypoints; no constructor or instance wrapper is created.
|
||||
|
||||
Use the type-only `artplayer/runtime/types` entry to augment precise Plugins and
|
||||
Events. Legacy custom event/plugin result augmentation is also retained. Existing
|
||||
root entrypoints do not import the modern views, preserving TypeScript 4.3.5.
|
||||
Old typed plugin factories remain accepted by explicit input overloads; precise
|
||||
instances do not pretend to satisfy inaccurate legacy return declarations.
|
||||
PluginFactory uses PluginHost: its plugins field is optional because constructor
|
||||
factories execute before that registry is assigned. Inline plugins.add callbacks
|
||||
receive the completed player. New controls require a top/left/right position;
|
||||
updates may retain the existing position. ProxyHost exposes safe initial fields
|
||||
before Template returns. Layer/control/contextmenu hosts mark later components
|
||||
optional; customType and setting mounted run after a delay and receive the full
|
||||
instance. These hosts retain distinct Player getter/setter types. Container inputs
|
||||
and template.$container remain HTMLDivElement because only div is supported.
|
||||
|
||||
Conditional exports select `artplayer.d.mts` for ESM and `artplayer.d.cts` for CJS
|
||||
and legacy. The CJS bridge uses `export =` for the real module.exports constructor
|
||||
@@ -17,15 +45,18 @@ i18n.d.ts contains dictionary definitions without suppressed module augmentation
|
||||
The editor's global language module is generated separately as
|
||||
docs/assets/ts/artplayer-i18n.d.ts so it cannot contaminate npm consumers.
|
||||
|
||||
Top-level types and historical .d.ts filenames remain available; runtime paths and
|
||||
exports do not change. See TypeScript's declaration module format and conditional
|
||||
Top-level types and historical .d.ts filenames remain available; existing runtime
|
||||
paths and exports do not change. See TypeScript's declaration module format and conditional
|
||||
resolution rules: https://www.typescriptlang.org/docs/handbook/modules/reference.html
|
||||
|
||||
When changing types, run `yarn typecheck`, `yarn test:baseline` and
|
||||
`yarn test:package:release`. They cover default/named types, core/legacy constructors,
|
||||
chapter/legacy factories, language data, invalid inputs, NodeNext/Bundler and old
|
||||
TS 4.3.5 consumers. Run `yarn build:ts` to refresh editor declarations. Full editor
|
||||
behavior and other core declaration/runtime mismatches have CORE-07/SITE tasks.
|
||||
TS 4.3.5 consumers. Run `yarn build:ts` to refresh editor declarations. The core
|
||||
editor bundle comes from the public dependency graph and is checked standalone
|
||||
with both compilers. editor-types.test.js rejects stale or invalid output, and
|
||||
editor-types.spec.js exercises the real Monaco worker and typed example playback.
|
||||
Plugin/editor UI modernization remains in SITE tasks.
|
||||
|
||||
## Configuration migration boundary
|
||||
|
||||
@@ -42,8 +73,8 @@ test/types/options-source.ts and declaration-inputs.ts cover those forms positiv
|
||||
declaration-legacy.ts preserves old reads and historically legal return assumptions.
|
||||
Do not change runtime validation to match a narrower declaration. The additions,
|
||||
retained conflicts and follow-up owners are detailed in [COMPATIBILITY.md](./COMPATIBILITY.md).
|
||||
CORE-07 coordinates the differences; it does not close every conflicting old return
|
||||
signature. CORE-21 remains responsible for the generated/public declaration strategy.
|
||||
CORE-07 introduced compatible additions. CORE-21 supplies the generated precise
|
||||
runtime entry for remaining conflicts while preserving historical root signatures.
|
||||
|
||||
## Internal media migration
|
||||
|
||||
@@ -58,7 +89,7 @@ shims and minimal playback/layout dependencies. These types are not exported by
|
||||
the package. Public art.video keeps its historical declaration and runtime identity;
|
||||
do not cast an internal canvas to HTMLVideoElement merely to satisfy that public
|
||||
declaration. Optional capability checks belong to their consumers. Full constructor
|
||||
type integration is tracked by CORE-20; proxy package migration validates each real
|
||||
type integration was completed in CORE-20; proxy package migration validates each real
|
||||
adapter separately. Source type fixtures and real canvas integration live in
|
||||
test/types/media-hosts.ts and test/browser/media-hosts.spec.js.
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Generated from public/artplayer.cts by yarn build:types. Do not edit.
|
||||
/* eslint-disable ts/no-redeclare -- Constructor, instance and named types share the export. */
|
||||
import type * as Definition from './artplayer.js'
|
||||
|
||||
declare const Artplayer: typeof Definition.default
|
||||
// eslint-disable-next-line ts/no-redeclare -- CJS constructor value and instance type share the export.
|
||||
type Artplayer = Definition.default
|
||||
|
||||
// eslint-disable-next-line ts/no-redeclare -- Namespace merging carries named types on export =.
|
||||
declare namespace Artplayer {
|
||||
type Config = Definition.Config
|
||||
type Emitter<Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>> = Definition.Emitter<Events>
|
||||
type Emitter<Events extends {
|
||||
[Name in keyof Events]: readonly unknown[];
|
||||
} = Record<PropertyKey, unknown[]>> = Definition.Emitter<Events>
|
||||
type Events = Definition.Events
|
||||
type I18n = Definition.I18n
|
||||
type Icons = Definition.Icons
|
||||
@@ -24,5 +25,4 @@ declare namespace Artplayer {
|
||||
type Template = Definition.Template
|
||||
type Utils = Definition.Utils
|
||||
}
|
||||
|
||||
export = Artplayer
|
||||
@@ -1,2 +1,3 @@
|
||||
// Generated from public/artplayer.mts by yarn build:types. Do not edit.
|
||||
export { default } from './artplayer.cjs'
|
||||
export type { Config, Emitter, Events, I18n, Icons, Option, OptionInput, PlaybackControls, Player, PluginFactory, Plugins, Setting, SettingOption, Subtitle, SubtitleUpdateEvents, Template, Utils } from './artplayer.js'
|
||||
+18
-39
@@ -1,3 +1,4 @@
|
||||
// Generated from public/artplayer.ts by yarn build:types. Do not edit.
|
||||
import type { Component } from './component'
|
||||
import type { Config } from './config'
|
||||
import type { Emitter } from './emitter'
|
||||
@@ -13,30 +14,10 @@ import type { Subtitle } from './subtitle'
|
||||
import type { Template } from './template'
|
||||
import type { Utils } from './utils'
|
||||
|
||||
export type {
|
||||
Config,
|
||||
Emitter,
|
||||
Events,
|
||||
I18n,
|
||||
Icons,
|
||||
Option,
|
||||
OptionInput,
|
||||
PlaybackControls,
|
||||
Player,
|
||||
PluginFactory,
|
||||
Plugins,
|
||||
Setting,
|
||||
SettingOption,
|
||||
Subtitle,
|
||||
SubtitleUpdateEvents,
|
||||
Template,
|
||||
Utils,
|
||||
}
|
||||
|
||||
export default class Artplayer extends Player {
|
||||
export type { Config, Emitter, Events, I18n, Icons, Option, OptionInput, PlaybackControls, Player, PluginFactory, Plugins, Setting, SettingOption, Subtitle, SubtitleUpdateEvents, Template, Utils }
|
||||
declare class Artplayer extends Player {
|
||||
constructor(option: Option, readyCallback?: (this: Artplayer, art: Artplayer) => unknown)
|
||||
constructor(option: OptionInput, readyCallback?: (this: Artplayer, art: Artplayer) => unknown)
|
||||
|
||||
static readonly instances: Artplayer[]
|
||||
static readonly version: string
|
||||
static readonly env: 'development' | 'production'
|
||||
@@ -44,12 +25,14 @@ export default class Artplayer extends Player {
|
||||
static readonly config: Config
|
||||
static readonly utils: Utils
|
||||
static readonly scheme: Record<keyof Option, unknown>
|
||||
static readonly Emitter: new <Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>>(...args: unknown[]) => Emitter<Events>
|
||||
static readonly Emitter: new <Events extends {
|
||||
[Name in keyof Events]: readonly unknown[];
|
||||
} = Record<PropertyKey, unknown[]>>(...args: unknown[]) => Emitter<Events>
|
||||
|
||||
static readonly validator: <T extends object>(option: T, scheme: object) => T
|
||||
static readonly kindOf: (item: unknown) => string
|
||||
static readonly html: Artplayer['template']['html']
|
||||
static readonly option: Option
|
||||
|
||||
static STYLE: string
|
||||
static DEBUG: boolean
|
||||
static CONTEXTMENU: boolean
|
||||
@@ -84,7 +67,6 @@ export default class Artplayer extends Player {
|
||||
static LOG_VERSION: boolean
|
||||
static USE_RAF: boolean
|
||||
static REMOVE_SRC_WHEN_DESTROY: boolean
|
||||
|
||||
readonly id: number
|
||||
readonly option: Option
|
||||
readonly isLock: boolean
|
||||
@@ -93,39 +75,36 @@ export default class Artplayer extends Player {
|
||||
readonly isInput: boolean
|
||||
readonly isRotate: boolean
|
||||
readonly isDestroy: boolean
|
||||
|
||||
flv?: unknown
|
||||
m3u8?: unknown
|
||||
hls?: unknown
|
||||
ts?: unknown
|
||||
mpd?: unknown
|
||||
torrent?: unknown
|
||||
|
||||
on<T extends keyof Events>(name: T, fn: (...args: Events[T]) => unknown, ctx?: object): this
|
||||
on<T extends keyof SubtitleUpdateEvents>(name: T, fn: (...args: SubtitleUpdateEvents[T]) => unknown, ctx?: object): this
|
||||
on(name: string, fn: (...args: unknown[]) => unknown, ctx?: object): this
|
||||
|
||||
once<T extends keyof Events>(name: T, fn: (...args: Events[T]) => unknown, ctx?: object): this
|
||||
once<T extends keyof SubtitleUpdateEvents>(name: T, fn: (...args: SubtitleUpdateEvents[T]) => unknown, ctx?: object): this
|
||||
once(name: string, fn: (...args: unknown[]) => unknown, ctx?: object): this
|
||||
|
||||
emit<T extends keyof Events>(name: T, ...args: Events[T]): this
|
||||
emit<T extends keyof SubtitleUpdateEvents>(name: T, ...args: SubtitleUpdateEvents[T]): this
|
||||
emit(name: string, ...args: unknown[]): this
|
||||
|
||||
off<T extends keyof Events>(name: T, callback?: (...args: Events[T]) => unknown): this
|
||||
off<T extends keyof SubtitleUpdateEvents>(name: T, callback?: (...args: SubtitleUpdateEvents[T]) => unknown): this
|
||||
off(name: string, callback?: (...args: unknown[]) => unknown): this
|
||||
|
||||
query: Artplayer['template']['query']
|
||||
proxy: Artplayer['events']['proxy']
|
||||
video: Artplayer['template']['$video']
|
||||
|
||||
e: { [K in keyof Events]?: { fn: (...args: Events[K]) => unknown, ctx: unknown }[] }
|
||||
e: {
|
||||
[K in keyof Events]?: {
|
||||
fn: (...args: Events[K]) => unknown
|
||||
ctx: unknown
|
||||
}[];
|
||||
}
|
||||
|
||||
destroy(removeHtml?: boolean): void
|
||||
reset(): void
|
||||
|
||||
readonly template: {
|
||||
get html(): string
|
||||
query: <T extends Element = Element>(selector: string) => T | null
|
||||
@@ -139,7 +118,10 @@ export default class Artplayer extends Player {
|
||||
hover: (element: HTMLElement, mouseenter?: (event: Event) => any, mouseleave?: (event: Event) => any) => void
|
||||
remove: (destroyEvent: () => void) => void
|
||||
destroy: () => void
|
||||
bindGlobalEvents: (source?: { window?: Window, document?: Document }) => void
|
||||
bindGlobalEvents: (source?: {
|
||||
window?: Window
|
||||
document?: Document
|
||||
}) => void
|
||||
}
|
||||
|
||||
readonly storage: {
|
||||
@@ -155,7 +137,6 @@ export default class Artplayer extends Player {
|
||||
}
|
||||
|
||||
readonly icons: Icons
|
||||
|
||||
readonly i18n: {
|
||||
languages: I18n
|
||||
language: Partial<Record<string, string>>
|
||||
@@ -174,7 +155,6 @@ export default class Artplayer extends Player {
|
||||
readonly layers: Record<string, HTMLElement | undefined> & Component
|
||||
readonly controls: Record<string, HTMLElement | undefined> & Component
|
||||
readonly contextmenu: Record<string, HTMLElement | undefined> & Component
|
||||
|
||||
readonly subtitle: {
|
||||
get url(): string
|
||||
set url(url: string)
|
||||
@@ -188,7 +168,6 @@ export default class Artplayer extends Player {
|
||||
|
||||
readonly info: Component
|
||||
readonly loading: Component
|
||||
|
||||
readonly hotkey: {
|
||||
keys: Record<string, ((event: KeyboardEvent) => any)[]>
|
||||
add: (key: string, callback: (this: Artplayer, event: KeyboardEvent) => any) => Artplayer['hotkey']
|
||||
@@ -196,7 +175,6 @@ export default class Artplayer extends Player {
|
||||
}
|
||||
|
||||
readonly mask: Component
|
||||
|
||||
readonly setting: {
|
||||
option: SettingOption[]
|
||||
updateStyle: (width?: number) => void
|
||||
@@ -212,3 +190,4 @@ export default class Artplayer extends Player {
|
||||
|
||||
readonly plugins: Plugins
|
||||
}
|
||||
export default Artplayer
|
||||
+1
-26
@@ -1,63 +1,52 @@
|
||||
// Generated from public/component.ts by yarn build:types. Do not edit.
|
||||
import type Artplayer from './artplayer'
|
||||
|
||||
/** Input accepted by the existing HTML renderer, including numeric content. */
|
||||
export interface ComponentInput extends Omit<ComponentOption, 'html'> {
|
||||
html?: string | HTMLElement | number
|
||||
}
|
||||
|
||||
export interface Selector {
|
||||
/**
|
||||
* Whether the default is selected
|
||||
*/
|
||||
default?: boolean
|
||||
|
||||
/**
|
||||
* Html string of selector
|
||||
*/
|
||||
html: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Value of selector item
|
||||
*/
|
||||
value?: string | number
|
||||
|
||||
/**
|
||||
* Allow custom properties
|
||||
*/
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface Component {
|
||||
/**
|
||||
* Component self-increasing id
|
||||
*/
|
||||
readonly id: number
|
||||
|
||||
/**
|
||||
* Component parent name
|
||||
*/
|
||||
readonly name: string | undefined
|
||||
|
||||
/**
|
||||
* Component parent element
|
||||
*/
|
||||
readonly $parent: HTMLElement | undefined
|
||||
|
||||
/**
|
||||
* Whether to show component parent
|
||||
*/
|
||||
get show(): boolean
|
||||
|
||||
/**
|
||||
* Whether to show component parent
|
||||
*/
|
||||
set show(state: boolean)
|
||||
|
||||
/**
|
||||
* Toggle the component parent
|
||||
*/
|
||||
toggle: () => void
|
||||
|
||||
/**
|
||||
* Dynamic add a component
|
||||
*/
|
||||
@@ -65,12 +54,10 @@ export interface Component {
|
||||
(option: ComponentOption | ((art: Artplayer) => ComponentOption)): HTMLElement | undefined
|
||||
(option: ComponentInput | ((art: Artplayer) => ComponentInput)): HTMLElement | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic remove a component by name
|
||||
*/
|
||||
remove: (name: string) => void
|
||||
|
||||
/**
|
||||
* Dynamic update a component
|
||||
*/
|
||||
@@ -79,63 +66,51 @@ export interface Component {
|
||||
(option: ComponentInput): HTMLElement | undefined
|
||||
}
|
||||
}
|
||||
|
||||
export interface ComponentOption {
|
||||
/**
|
||||
* Html string or html element of component
|
||||
*/
|
||||
html?: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Whether to disable component
|
||||
*/
|
||||
disable?: boolean
|
||||
|
||||
/**
|
||||
* Unique name for component
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* Component sort index
|
||||
*/
|
||||
index?: number
|
||||
|
||||
/**
|
||||
* Component style object
|
||||
*/
|
||||
style?: Partial<CSSStyleDeclaration>
|
||||
|
||||
/**
|
||||
* Component click event
|
||||
*/
|
||||
click?: (this: Artplayer, component: Component, event: Event) => void
|
||||
|
||||
/**
|
||||
* When the component was mounted
|
||||
*/
|
||||
mounted?: (this: Artplayer, element: HTMLElement) => void
|
||||
|
||||
/**
|
||||
* When the component was before unmount
|
||||
*/
|
||||
beforeUnmount?: (this: Artplayer, element: HTMLElement) => void
|
||||
|
||||
/**
|
||||
* Component tooltip, use in controls
|
||||
*/
|
||||
tooltip?: string
|
||||
|
||||
/**
|
||||
* Component position, use in controls
|
||||
*/
|
||||
position?: 'top' | 'left' | 'right' | (string & Record<never, never>)
|
||||
|
||||
/**
|
||||
* Custom selector list, use in controls
|
||||
*/
|
||||
selector?: Selector[]
|
||||
|
||||
/**
|
||||
* When selector item click, use in controls
|
||||
*/
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// Generated from public/config.ts by yarn build:types. Do not edit.
|
||||
export interface Config {
|
||||
readonly properties: readonly [
|
||||
'audioTracks',
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// Generated from public/cssVar.ts by yarn build:types. Do not edit.
|
||||
export interface CssVar {
|
||||
'--art-theme': string
|
||||
'--art-font-color': string
|
||||
|
||||
+10
-2
@@ -1,6 +1,14 @@
|
||||
// Generated from public/emitter.ts by yarn build:types. Do not edit.
|
||||
/** The event bus exposed by Artplayer.Emitter; no new runtime export. */
|
||||
export interface Emitter<Events extends { [Name in keyof Events]: readonly unknown[] } = Record<PropertyKey, unknown[]>> {
|
||||
e?: { [Name in keyof Events]?: { fn: (...args: [...Events[Name]]) => unknown, ctx: unknown }[] }
|
||||
export interface Emitter<Events extends {
|
||||
[Name in keyof Events]: readonly unknown[];
|
||||
} = Record<PropertyKey, unknown[]>> {
|
||||
e?: {
|
||||
[Name in keyof Events]?: {
|
||||
fn: (...args: [...Events[Name]]) => unknown
|
||||
ctx: unknown
|
||||
}[];
|
||||
}
|
||||
on: <Name extends keyof Events, Context>(name: Name, fn: (this: Context, ...args: [...Events[Name]]) => unknown, ctx?: Context) => this
|
||||
once: <Name extends keyof Events, Context>(name: Name, fn: (this: Context, ...args: [...Events[Name]]) => unknown, ctx?: Context) => this
|
||||
emit: <Name extends keyof Events>(name: Name, ...args: [...Events[Name]]) => this
|
||||
|
||||
Vendored
+5
-11
@@ -1,14 +1,13 @@
|
||||
// Generated from public/events.ts by yarn build:types. Do not edit.
|
||||
import type { AspectRatio, Flip } from './player'
|
||||
import type { Subtitle } from './subtitle'
|
||||
|
||||
export type Bar = 'loaded' | 'played' | 'hover'
|
||||
|
||||
/** Actual built-in subtitle update payloads; legacy Events keeps its scalar types. */
|
||||
export interface SubtitleUpdateEvents {
|
||||
subtitleBeforeUpdate: [cues: VTTCue[]]
|
||||
subtitleAfterUpdate: [cues: VTTCue[]]
|
||||
}
|
||||
|
||||
export interface Events {
|
||||
'document:click': [event: Event]
|
||||
'document:mouseup': [event: Event]
|
||||
@@ -22,11 +21,9 @@ export interface Events {
|
||||
'document:pointermove': [event: Event]
|
||||
'document:visibilitychange': [event: Event]
|
||||
'document:webkitfullscreenchange': [event: Event]
|
||||
|
||||
'window:resize': [event: Event]
|
||||
'window:scroll': [event: Event]
|
||||
'window:orientationchange': [event: Event]
|
||||
|
||||
'video:abort': [event: Event]
|
||||
'video:canplay': [event: Event]
|
||||
'video:canplaythrough': [event: Event]
|
||||
@@ -51,7 +48,6 @@ export interface Events {
|
||||
'video:timeupdate': [event: Event]
|
||||
'video:volumechange': [event: Event]
|
||||
'video:waiting': [event: Event]
|
||||
|
||||
'info': [state: boolean]
|
||||
'layer': [state: boolean]
|
||||
'loading': [state: boolean]
|
||||
@@ -61,33 +57,31 @@ export interface Events {
|
||||
'control': [state: boolean]
|
||||
'setting': [state: boolean]
|
||||
'hotkey': [event: KeyboardEvent]
|
||||
|
||||
'destroy': []
|
||||
|
||||
'subtitleOffset': [offset: number]
|
||||
/** Legacy contextual type; annotate listeners with VTTCue[] for the runtime payload. */
|
||||
'subtitleBeforeUpdate': [cue: VTTCue]
|
||||
/** Legacy contextual type; annotate listeners with VTTCue[] for the runtime payload. */
|
||||
'subtitleAfterUpdate': [cue: VTTCue]
|
||||
'subtitleLoad': [cues: VTTCue[], option: Subtitle]
|
||||
|
||||
'focus': [event: Event]
|
||||
'blur': [event: Event]
|
||||
'dblclick': [event: Event]
|
||||
'click': [event: Event]
|
||||
'hover': [state: boolean, event: Event]
|
||||
'mousemove': [event: Event]
|
||||
|
||||
'resize': []
|
||||
'view': [state: boolean]
|
||||
'lock': [state: boolean]
|
||||
'aspectRatio': [aspectRatio: AspectRatio]
|
||||
'autoHeight': [height: number]
|
||||
'autoSize': [size: { width: number, height: number }]
|
||||
'autoSize': [size: {
|
||||
width: number
|
||||
height: number
|
||||
}]
|
||||
'ready': []
|
||||
'airplay': []
|
||||
'raf': []
|
||||
|
||||
'error': [error: Error, reconnectTime: number]
|
||||
'flip': [flip: Flip]
|
||||
'fullscreen': [state: boolean]
|
||||
|
||||
Vendored
+3
-17
@@ -1,19 +1,5 @@
|
||||
type I18nKeys
|
||||
= | 'en'
|
||||
| 'zh-cn'
|
||||
| 'zh-tw'
|
||||
| 'pl'
|
||||
| 'cs'
|
||||
| 'es'
|
||||
| 'fa'
|
||||
| 'fr'
|
||||
| 'id'
|
||||
| 'ru'
|
||||
| 'tr'
|
||||
| 'ar'
|
||||
| 'vi'
|
||||
| (string & Record<never, never>)
|
||||
|
||||
// Generated from public/i18n.ts by yarn build:types. Do not edit.
|
||||
type I18nKeys = 'en' | 'zh-cn' | 'zh-tw' | 'pl' | 'cs' | 'es' | 'fa' | 'fr' | 'id' | 'ru' | 'tr' | 'ar' | 'vi' | (string & Record<never, never>)
|
||||
interface I18nValue {
|
||||
'Video Info': string
|
||||
'Close': string
|
||||
@@ -52,5 +38,5 @@ interface I18nValue {
|
||||
'AirPlay': string
|
||||
'AirPlay Not Available': string
|
||||
}
|
||||
|
||||
export type I18n = Partial<Record<I18nKeys, Partial<I18nValue>>>
|
||||
export {}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// Generated from public/icons.ts by yarn build:types. Do not edit.
|
||||
export interface Icons {
|
||||
readonly loading: HTMLDivElement
|
||||
readonly state: HTMLDivElement
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Generated from public/language.cts by yarn build:types. Do not edit.
|
||||
import type { I18n } from './i18n.js'
|
||||
|
||||
declare const language: NonNullable<I18n['en']>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
// Generated from public/language.mts by yarn build:types. Do not edit.
|
||||
export { default } from './language.cjs'
|
||||
@@ -1,3 +1,4 @@
|
||||
// Generated from public/legacy/language.ts by yarn build:types. Do not edit.
|
||||
import type { I18n } from '../i18n'
|
||||
|
||||
declare const language: NonNullable<I18n['en']>
|
||||
|
||||
Vendored
+5
-76
@@ -1,3 +1,4 @@
|
||||
// Generated from public/option.ts by yarn build:types. Do not edit.
|
||||
import type Artplayer from './artplayer'
|
||||
import type { ComponentInput, ComponentOption } from './component'
|
||||
import type { CssVar } from './cssVar'
|
||||
@@ -8,47 +9,33 @@ import type { Quality } from './quality'
|
||||
import type { Setting } from './setting'
|
||||
import type { Subtitle } from './subtitle'
|
||||
|
||||
export type CustomType
|
||||
= | 'flv'
|
||||
| 'm3u8'
|
||||
| 'hls'
|
||||
| 'ts'
|
||||
| 'mpd'
|
||||
| 'torrent'
|
||||
| (string & Record<never, never>)
|
||||
|
||||
export type CustomType = 'flv' | 'm3u8' | 'hls' | 'ts' | 'mpd' | 'torrent' | (string & Record<never, never>)
|
||||
export interface Thumbnails {
|
||||
/**
|
||||
* The thumbnail image url
|
||||
*/
|
||||
url: string
|
||||
|
||||
/**
|
||||
* The thumbnail item number
|
||||
*/
|
||||
number?: number
|
||||
|
||||
/**
|
||||
* The thumbnail column size
|
||||
*/
|
||||
column?: number
|
||||
|
||||
/**
|
||||
* The thumbnail width
|
||||
*/
|
||||
width?: number
|
||||
|
||||
/**
|
||||
* The thumbnail height
|
||||
*/
|
||||
height?: number
|
||||
|
||||
/**
|
||||
* The thumbnail scale
|
||||
*/
|
||||
scale?: number
|
||||
}
|
||||
|
||||
/** Constructor input; Option retains its historical required URL/read types. */
|
||||
export interface OptionInput extends Omit<Option, 'url' | 'controls' | 'layers' | 'contextmenu'> {
|
||||
url?: string
|
||||
@@ -56,218 +43,175 @@ export interface OptionInput extends Omit<Option, 'url' | 'controls' | 'layers'
|
||||
layers?: ComponentInput[]
|
||||
contextmenu?: ComponentInput[]
|
||||
}
|
||||
|
||||
export interface Option {
|
||||
/**
|
||||
* The player id
|
||||
*/
|
||||
id?: string
|
||||
|
||||
/**
|
||||
* The container mounted by the player
|
||||
*/
|
||||
container: string | HTMLDivElement
|
||||
|
||||
/**
|
||||
* Video url
|
||||
*/
|
||||
url: string
|
||||
|
||||
/**
|
||||
* Video poster image url
|
||||
*/
|
||||
poster?: string
|
||||
|
||||
/**
|
||||
* Video url type
|
||||
*/
|
||||
type?: CustomType
|
||||
|
||||
/**
|
||||
* Player color theme
|
||||
*/
|
||||
theme?: string
|
||||
|
||||
/**
|
||||
* Player language
|
||||
*/
|
||||
lang?: keyof I18n
|
||||
|
||||
/**
|
||||
* Player default volume
|
||||
*/
|
||||
volume?: number
|
||||
|
||||
/**
|
||||
* Whether live broadcast mode
|
||||
*/
|
||||
isLive?: boolean
|
||||
|
||||
/**
|
||||
* Whether video muted
|
||||
*/
|
||||
muted?: boolean
|
||||
|
||||
/**
|
||||
* Whether video auto play
|
||||
*/
|
||||
autoplay?: boolean
|
||||
|
||||
/**
|
||||
* Whether player auto resize
|
||||
*/
|
||||
autoSize?: boolean
|
||||
|
||||
/**
|
||||
* Whether player auto run mini mode
|
||||
*/
|
||||
autoMini?: boolean
|
||||
|
||||
/**
|
||||
* Whether video auto loop
|
||||
*/
|
||||
loop?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video flip button
|
||||
*/
|
||||
flip?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video playback rate button
|
||||
*/
|
||||
playbackRate?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video aspect ratio button
|
||||
*/
|
||||
aspectRatio?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video screenshot button
|
||||
*/
|
||||
screenshot?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video setting button
|
||||
*/
|
||||
setting?: boolean
|
||||
|
||||
/**
|
||||
* Whether to enable player hotkey
|
||||
*/
|
||||
hotkey?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video pip button
|
||||
*/
|
||||
pip?: boolean
|
||||
|
||||
/**
|
||||
* Do you want to run only one player at a time
|
||||
*/
|
||||
mutex?: boolean
|
||||
|
||||
/**
|
||||
* Whether use backdrop in UI
|
||||
*/
|
||||
backdrop?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video window fullscreen button
|
||||
*/
|
||||
fullscreen?: boolean
|
||||
|
||||
/**
|
||||
* Whether show video web fullscreen button
|
||||
*/
|
||||
fullscreenWeb?: boolean
|
||||
|
||||
/**
|
||||
* Whether to enable player subtitle offset
|
||||
*/
|
||||
subtitleOffset?: boolean
|
||||
|
||||
/**
|
||||
* Whether to enable player mini progress bar
|
||||
*/
|
||||
miniProgressBar?: boolean
|
||||
|
||||
/**
|
||||
* Whether use SSR function
|
||||
*/
|
||||
useSSR?: boolean
|
||||
|
||||
/**
|
||||
* Whether use playsInline in mobile
|
||||
*/
|
||||
playsInline?: boolean
|
||||
|
||||
/**
|
||||
* Whether use lock in mobile
|
||||
*/
|
||||
lock?: boolean
|
||||
|
||||
/**
|
||||
* Whether use gesture in mobile
|
||||
*/
|
||||
gesture?: boolean
|
||||
|
||||
/**
|
||||
* Whether use fast forward in mobile
|
||||
*/
|
||||
fastForward?: boolean
|
||||
|
||||
/**
|
||||
* Whether use auto playback
|
||||
*/
|
||||
autoPlayback?: boolean
|
||||
|
||||
/**
|
||||
* Whether use auto orientation in mobile
|
||||
*/
|
||||
autoOrientation?: boolean
|
||||
|
||||
/**
|
||||
* Whether use airplay
|
||||
*/
|
||||
airplay?: boolean
|
||||
|
||||
/**
|
||||
* Custom video proxy
|
||||
*/
|
||||
proxy?: (this: Artplayer, art: Artplayer) => HTMLCanvasElement | HTMLVideoElement | undefined
|
||||
|
||||
/**
|
||||
* Custom plugin list
|
||||
*/
|
||||
plugins?: PluginFactory[]
|
||||
|
||||
/**
|
||||
* Custom layer list
|
||||
*/
|
||||
layers?: ComponentOption[]
|
||||
|
||||
/**
|
||||
* Custom contextmenu list
|
||||
*/
|
||||
contextmenu?: ComponentOption[]
|
||||
|
||||
/**
|
||||
* Custom control list
|
||||
*/
|
||||
controls?: ComponentOption[]
|
||||
|
||||
/**
|
||||
* Custom setting list
|
||||
*/
|
||||
settings?: Setting[]
|
||||
|
||||
/**
|
||||
* Custom video quality list
|
||||
*/
|
||||
quality?: Quality[]
|
||||
|
||||
/**
|
||||
* Custom highlight list
|
||||
*/
|
||||
@@ -276,56 +220,41 @@ export interface Option {
|
||||
* The highlight time
|
||||
*/
|
||||
time: number
|
||||
|
||||
/**
|
||||
* The highlight text
|
||||
*/
|
||||
text: string
|
||||
}[]
|
||||
|
||||
/**
|
||||
* Custom thumbnail
|
||||
*/
|
||||
thumbnails?: Thumbnails
|
||||
|
||||
/**
|
||||
* Custom subtitle option
|
||||
*/
|
||||
subtitle?: Subtitle
|
||||
|
||||
/**
|
||||
* Other video attribute
|
||||
*/
|
||||
moreVideoAttr?: Partial<Readonly<{
|
||||
[K in keyof HTMLVideoElement as HTMLVideoElement[K] extends (...args: unknown[]) => unknown
|
||||
? never
|
||||
: K]: HTMLVideoElement[K]
|
||||
[K in keyof HTMLVideoElement as HTMLVideoElement[K] extends (...args: unknown[]) => unknown ? never : K]: HTMLVideoElement[K];
|
||||
}>>
|
||||
|
||||
/**
|
||||
* Custom i18n
|
||||
*/
|
||||
i18n?: I18n
|
||||
|
||||
/**
|
||||
* Custom default icons
|
||||
*/
|
||||
icons?: {
|
||||
[key in keyof Icons]?: HTMLElement | string
|
||||
[key in keyof Icons]?: HTMLElement | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom css variables
|
||||
*/
|
||||
cssVar?: Partial<CssVar>
|
||||
|
||||
/**
|
||||
* Custom video type function
|
||||
*/
|
||||
customType?: Partial<
|
||||
Record<
|
||||
CustomType,
|
||||
(this: Artplayer, video: HTMLVideoElement, url: string, art: Artplayer) => unknown | Promise<unknown>
|
||||
>
|
||||
>
|
||||
customType?: Partial<Record<CustomType, (this: Artplayer, video: HTMLVideoElement, url: string, art: Artplayer) => unknown | Promise<unknown>>>
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// Generated from public/playback.ts by yarn build:types. Do not edit.
|
||||
/** Accurate playback method view; assign an existing player without a runtime wrapper. */
|
||||
export interface PlaybackControls {
|
||||
play: () => Promise<void>
|
||||
|
||||
Vendored
+1
-30
@@ -1,3 +1,4 @@
|
||||
// Generated from public/player.ts by yarn build:types. Do not edit.
|
||||
import type { CssVar } from './cssVar'
|
||||
import type { CustomType, Thumbnails } from './option'
|
||||
import type { Quality } from './quality'
|
||||
@@ -6,48 +7,34 @@ export type AspectRatio = 'default' | '4:3' | '16:9' | (`${number}:${number}` &
|
||||
export type PlaybackRate = 0.5 | 0.75 | 1.0 | 1.25 | 1.5 | 1.75 | 2.0 | (number & Record<never, never>)
|
||||
export type Flip = 'normal' | 'horizontal' | 'vertical' | (string & Record<never, never>)
|
||||
export type State = 'standard' | 'mini' | 'pip' | 'fullscreen' | 'fullscreenWeb'
|
||||
|
||||
export declare class Player {
|
||||
get aspectRatio(): AspectRatio
|
||||
set aspectRatio(ratio: AspectRatio)
|
||||
|
||||
get state(): State
|
||||
set state(state: State)
|
||||
|
||||
get type(): CustomType
|
||||
set type(name: CustomType)
|
||||
|
||||
get playbackRate(): PlaybackRate
|
||||
set playbackRate(rate: PlaybackRate)
|
||||
|
||||
get currentTime(): number
|
||||
set currentTime(time: number)
|
||||
|
||||
get duration(): number
|
||||
get played(): number
|
||||
get playing(): boolean
|
||||
|
||||
get flip(): Flip
|
||||
set flip(state: Flip)
|
||||
|
||||
get fullscreen(): boolean
|
||||
set fullscreen(state: boolean)
|
||||
|
||||
get fullscreenWeb(): boolean
|
||||
set fullscreenWeb(state: boolean)
|
||||
|
||||
get loaded(): number
|
||||
get loadedTime(): number
|
||||
|
||||
get mini(): boolean
|
||||
set mini(state: boolean)
|
||||
|
||||
get pip(): boolean
|
||||
set pip(state: boolean)
|
||||
|
||||
get poster(): string
|
||||
set poster(url: string)
|
||||
|
||||
get rect(): DOMRect
|
||||
get bottom(): number
|
||||
get height(): number
|
||||
@@ -57,55 +44,39 @@ export declare class Player {
|
||||
get width(): number
|
||||
get x(): number
|
||||
get y(): number
|
||||
|
||||
set seek(time: number)
|
||||
get seek(): number
|
||||
|
||||
set forward(time: number)
|
||||
get forward(): number
|
||||
|
||||
set backward(time: number)
|
||||
get backward(): number
|
||||
|
||||
get url(): string
|
||||
set url(url: string)
|
||||
|
||||
get volume(): number
|
||||
set volume(percentage: number)
|
||||
|
||||
get muted(): boolean
|
||||
set muted(state: boolean)
|
||||
|
||||
get theme(): string
|
||||
set theme(theme: string)
|
||||
|
||||
get subtitleOffset(): number
|
||||
set subtitleOffset(time: number)
|
||||
|
||||
get switch(): string
|
||||
set switch(url: string)
|
||||
|
||||
get quality(): Quality[]
|
||||
set quality(quality: Quality[])
|
||||
|
||||
get thumbnails(): Thumbnails
|
||||
set thumbnails(thumbnails: Thumbnails)
|
||||
|
||||
pause(): void
|
||||
play(): Promise<void>
|
||||
/** Legacy signature; runtime preserves pause's synchronous result or play's Promise. */
|
||||
toggle(): void
|
||||
|
||||
attr(key: string, value?: unknown): unknown
|
||||
cssVar<T extends keyof CssVar>(key: T, value?: CssVar[T]): CssVar[T]
|
||||
|
||||
switchUrl(url: string): Promise<void>
|
||||
switchQuality(url: string): Promise<void>
|
||||
|
||||
getDataURL(): Promise<string>
|
||||
getBlobUrl(): Promise<string>
|
||||
screenshot(name?: string): Promise<string>
|
||||
|
||||
airplay(): void
|
||||
autoSize(): void
|
||||
autoHeight(): void
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Generated from public/plugin.ts by yarn build:types. Do not edit.
|
||||
import type Artplayer from './artplayer'
|
||||
|
||||
export type PluginFactory<Host = Artplayer, Result = unknown> = (this: Host, art: Host) => Result
|
||||
|
||||
/** Augment this interface with installed plugin results; augmentation does not register a plugin. */
|
||||
export interface Plugins {
|
||||
/** Legacy signature: synchronous factories return this registry; Promise factories return a Promise of it. */
|
||||
|
||||
+1
-2
@@ -1,14 +1,13 @@
|
||||
// Generated from public/quality.ts by yarn build:types. Do not edit.
|
||||
export interface Quality {
|
||||
/**
|
||||
* Whether the default is selected
|
||||
*/
|
||||
default?: boolean
|
||||
|
||||
/**
|
||||
* Html string of quality
|
||||
*/
|
||||
html: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Video quality url
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// Generated from public/runtime.cts by yarn build:types. Do not edit.
|
||||
/* eslint-disable ts/no-redeclare -- Constructor, instance and named types share the export. */
|
||||
import type * as Definition from './runtime.js'
|
||||
|
||||
declare const Artplayer: typeof Definition.default
|
||||
type Artplayer = Definition.default
|
||||
declare namespace Artplayer {
|
||||
type ArtplayerConstructor = Definition.ArtplayerConstructor
|
||||
type OptionInput = Definition.OptionInput
|
||||
type Option = Definition.Option
|
||||
type Events = Definition.Events
|
||||
type Plugins = Definition.Plugins
|
||||
type PluginFactory<Result = unknown> = Definition.PluginFactory<Result>
|
||||
type PluginHost = Definition.PluginHost
|
||||
type ProxyHost = Definition.ProxyHost
|
||||
type CustomTypeHost = Definition.CustomTypeHost
|
||||
type LayerHost = Definition.LayerHost
|
||||
type ControlHost = Definition.ControlHost
|
||||
type ContextmenuHost = Definition.ContextmenuHost
|
||||
type PluginRegistration<Result, Registry> = Definition.PluginRegistration<Result, Registry>
|
||||
type Component = Definition.Component
|
||||
type Controls = Definition.Controls
|
||||
type Setting = Definition.Setting
|
||||
type Subtitle = Definition.Subtitle
|
||||
type Notice = Definition.Notice
|
||||
type Utils = Definition.Utils
|
||||
type MediaSurface = Definition.MediaSurface
|
||||
type NativeMedia = Definition.NativeMedia
|
||||
type CanvasMedia = Definition.CanvasMedia
|
||||
type Player<Media extends MediaSurface = MediaSurface> = Definition.Player<Media>
|
||||
type Template<Host = Artplayer, Media extends MediaSurface = MediaSurface> = Definition.Template<Host, Media>
|
||||
type Icons = Definition.Icons
|
||||
type Config = Definition.Config
|
||||
type EventRegistry = Definition.EventRegistry
|
||||
type Storage = Definition.Storage
|
||||
type I18n<Host = Artplayer> = Definition.I18n<Host>
|
||||
type Hotkey<Host = Artplayer> = Definition.Hotkey<Host>
|
||||
type Languages = Definition.Languages
|
||||
type Dictionary = Definition.Dictionary
|
||||
type QualityItem = Definition.QualityItem
|
||||
type SettingItem<Host = Artplayer> = Definition.SettingItem<Host>
|
||||
type ComponentInput<Host = Artplayer> = Definition.ComponentInput<Host>
|
||||
type ComponentOption<Host = Artplayer> = Definition.ComponentOption<Host>
|
||||
type ControlInput<Host = Artplayer> = Definition.ControlInput<Host>
|
||||
type ControlOption<Host = Artplayer> = Definition.ControlOption<Host>
|
||||
type SelectorItem = Definition.SelectorItem
|
||||
type SubtitleCue = Definition.SubtitleCue
|
||||
type SubtitleOption = Definition.SubtitleOption
|
||||
type Emitter<Events extends {
|
||||
[Name in keyof Events]: readonly unknown[];
|
||||
} = Record<PropertyKey, unknown[]>> = Definition.Emitter<Events>
|
||||
}
|
||||
export = Artplayer
|
||||
@@ -0,0 +1,3 @@
|
||||
// Generated from public/runtime.mts by yarn build:types. Do not edit.
|
||||
export { default } from './runtime.cjs'
|
||||
export type * from './runtime.js'
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
// Generated from public/runtime.ts by yarn build:types. Do not edit.
|
||||
/* eslint-disable ts/no-redeclare -- Constructor, instance and named types share the export. */
|
||||
import type LegacyArtplayer from './artplayer'
|
||||
import type { Emitter } from './emitter'
|
||||
import type { OptionInput as LegacyOptionInput } from './option'
|
||||
import type { PluginFactory as LegacyPluginFactory, Plugins as LegacyPlugins } from './plugin'
|
||||
import type { ComponentInput, Component as ComponentView, ControlInput, Controls as ControlsView } from './runtime/component'
|
||||
import type { ContextmenuHost, ControlHost, CustomTypeHost, LayerHost, PluginHost, ProxyHost } from './runtime/construction'
|
||||
import type { Events } from './runtime/events'
|
||||
import type { MediaSurface } from './runtime/media'
|
||||
import type { OptionInput as OptionInputView, Option as OptionView } from './runtime/option'
|
||||
import type { Player } from './runtime/player'
|
||||
import type { PluginFactory as FactoryView, PluginRegistration, Plugins as PluginsView } from './runtime/plugin'
|
||||
import type { Config, EventRegistry, Hotkey, I18n, Scheme, Storage, ValidatorPath } from './runtime/services'
|
||||
import type { Setting as SettingView } from './runtime/setting'
|
||||
import type { Notice as NoticeView, Subtitle as SubtitleView } from './runtime/subtitle'
|
||||
import type { Icons, Template } from './runtime/template'
|
||||
import type { Utils } from './runtime/utils'
|
||||
|
||||
export type { Emitter } from './emitter'
|
||||
export type { ComponentInput, ComponentOption, ControlInput, ControlOption, SelectorItem } from './runtime/component'
|
||||
export type { ContextmenuHost, ControlHost, CustomTypeHost, LayerHost, PluginHost, ProxyHost } from './runtime/construction'
|
||||
export type { Events } from './runtime/events'
|
||||
export type { CanvasMedia, MediaSurface, NativeMedia } from './runtime/media'
|
||||
export type { Player, QualityItem } from './runtime/player'
|
||||
export type { PluginRegistration } from './runtime/plugin'
|
||||
export type { Config, Dictionary, EventRegistry, Hotkey, I18n, Languages, Storage } from './runtime/services'
|
||||
export type { SettingItem } from './runtime/setting'
|
||||
export type { SubtitleCue, SubtitleOption } from './runtime/subtitle'
|
||||
export type { Icons, Template } from './runtime/template'
|
||||
export type { Utils } from './runtime/utils'
|
||||
export type PluginFactory<Result = unknown> = FactoryView<PluginHost, Result>
|
||||
export interface OptionInput extends Omit<OptionInputView<Artplayer>, 'plugins' | 'proxy' | 'customType' | 'layers' | 'controls' | 'contextmenu'> {
|
||||
plugins?: PluginFactory[]
|
||||
proxy?: (this: ProxyHost, art: ProxyHost) => MediaSurface
|
||||
customType?: Record<string, ((this: CustomTypeHost, video: MediaSurface, url: string, art: CustomTypeHost) => unknown) | undefined>
|
||||
layers?: ComponentInput<LayerHost>[]
|
||||
controls?: ControlInput<ControlHost>[]
|
||||
contextmenu?: ComponentInput<ContextmenuHost>[]
|
||||
}
|
||||
export interface Option extends OptionView<Artplayer> {
|
||||
}
|
||||
export interface Component extends ComponentView<Artplayer> {
|
||||
}
|
||||
export interface Controls extends ControlsView<Artplayer> {
|
||||
}
|
||||
export interface Setting extends SettingView<Artplayer> {
|
||||
}
|
||||
export interface Subtitle extends SubtitleView, Omit<Component, keyof SubtitleView> {
|
||||
}
|
||||
export interface Notice extends NoticeView {
|
||||
art: Artplayer
|
||||
}
|
||||
/** Augment with installed results. Factories are not wrapped or converted. */
|
||||
export interface PluginAdd<Registry> {
|
||||
<Result>(plugin: FactoryView<Artplayer, Result>): PluginRegistration<Result, Registry>
|
||||
<Result>(plugin: LegacyPluginFactory<LegacyArtplayer, Result>): PluginRegistration<Result, Registry>
|
||||
}
|
||||
type LegacyPluginResults = {
|
||||
[Name in keyof LegacyPlugins as string extends Name ? never : number extends Name ? never : Name extends keyof PluginsView<Artplayer> ? never : Name]: LegacyPlugins[Name];
|
||||
}
|
||||
export interface Plugins extends Omit<PluginsView<Artplayer>, 'add'>, LegacyPluginResults {
|
||||
add: PluginAdd<this>
|
||||
[name: string]: unknown
|
||||
}
|
||||
/** Public view of the existing constructor; this interface emits no runtime fields. */
|
||||
interface Artplayer extends Player, Emitter<Events> {
|
||||
constructor: ArtplayerConstructor
|
||||
id: number
|
||||
option: Option
|
||||
isLock: boolean
|
||||
isReady: boolean
|
||||
isFocus: boolean
|
||||
isInput: boolean
|
||||
isRotate: boolean
|
||||
isDestroy: boolean
|
||||
flv?: unknown
|
||||
m3u8?: unknown
|
||||
hls?: unknown
|
||||
ts?: unknown
|
||||
mpd?: unknown
|
||||
torrent?: unknown
|
||||
template: Template<Artplayer>
|
||||
events: EventRegistry
|
||||
storage: Storage
|
||||
icons: Icons
|
||||
i18n: I18n<Artplayer>
|
||||
notice: Notice
|
||||
/** The descriptor installer has no public instance members. */
|
||||
player: object
|
||||
layers: Component
|
||||
controls: Controls
|
||||
contextmenu: Component & {
|
||||
init: () => void
|
||||
}
|
||||
subtitle: Subtitle
|
||||
info: Component & {
|
||||
init: () => void
|
||||
}
|
||||
loading: Component
|
||||
hotkey: Hotkey<Artplayer>
|
||||
mask: Component
|
||||
setting: Setting
|
||||
plugins: Plugins
|
||||
readonly query: Template<Artplayer>['query']
|
||||
readonly proxy: EventRegistry['proxy']
|
||||
readonly video: MediaSurface
|
||||
reset: () => void
|
||||
destroy: (removeHtml?: boolean) => void
|
||||
}
|
||||
type StaticOptions = Pick<typeof LegacyArtplayer, Extract<keyof typeof LegacyArtplayer, Uppercase<string>>>
|
||||
export interface ArtplayerConstructor extends StaticOptions {
|
||||
new (option: OptionInput, readyCallback?: (this: Artplayer, art: Artplayer) => unknown): Artplayer
|
||||
new (option: LegacyOptionInput, readyCallback?: (this: Artplayer, art: Artplayer) => unknown): Artplayer
|
||||
readonly prototype: Artplayer
|
||||
readonly instances: Artplayer[]
|
||||
readonly version: string
|
||||
readonly config: Config
|
||||
readonly utils: Utils
|
||||
readonly scheme: Record<keyof Option, Scheme>
|
||||
readonly Emitter: new <Events extends {
|
||||
[Name in keyof Events]: readonly unknown[];
|
||||
} = Record<PropertyKey, unknown[]>>(...args: unknown[]) => Emitter<Events>
|
||||
readonly validator: <T>(option: T, scheme: Scheme, paths?: ValidatorPath) => T
|
||||
readonly kindOf: (value: unknown) => string
|
||||
readonly html: string
|
||||
readonly option: Option
|
||||
}
|
||||
declare const Artplayer: ArtplayerConstructor
|
||||
export default Artplayer
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// Generated from public/runtime/component.ts by yarn build:types. Do not edit.
|
||||
export type EventCleanup = () => void
|
||||
export interface SelectorItem {
|
||||
html: string | HTMLElement | number
|
||||
value?: string | number
|
||||
default?: boolean
|
||||
readonly $control_option?: SelectorItem[]
|
||||
readonly $control_item?: HTMLDivElement
|
||||
readonly $control_value?: HTMLDivElement
|
||||
}
|
||||
export interface ComponentOption<Host> {
|
||||
html?: string | HTMLElement | number
|
||||
disable?: boolean
|
||||
name?: string
|
||||
index?: number
|
||||
style?: Partial<CSSStyleDeclaration>
|
||||
tooltip?: string | number
|
||||
position?: string
|
||||
selector?: SelectorItem[]
|
||||
click?: (this: Host, component: Component<Host>, event: Event) => unknown
|
||||
mounted?: (this: Host, element: HTMLDivElement) => unknown
|
||||
beforeUnmount?: (this: Host, element: HTMLDivElement) => unknown
|
||||
onSelect?: (this: Host, item: SelectorItem, element: HTMLDivElement, event: Event) => unknown
|
||||
}
|
||||
export type ComponentInput<Host> = ComponentOption<Host> | ((art: Host) => ComponentOption<Host>)
|
||||
export interface ControlOption<Host> extends Omit<ComponentOption<Host>, 'position'> {
|
||||
position: 'top' | 'left' | 'right'
|
||||
}
|
||||
export type ControlInput<Host> = ControlOption<Host> | ((art: Host) => ControlOption<Host>)
|
||||
export interface ComponentEntry<Host> {
|
||||
$ref: HTMLDivElement
|
||||
events: EventCleanup[]
|
||||
option: ComponentOption<Host>
|
||||
}
|
||||
export interface Component<Host> {
|
||||
id: number
|
||||
art: Host
|
||||
name?: string
|
||||
$parent?: HTMLElement
|
||||
cache: Map<string, ComponentEntry<Host>>
|
||||
show: boolean
|
||||
toggle: () => void
|
||||
add: (input: ComponentInput<Host>) => HTMLDivElement | undefined
|
||||
remove: (name: string) => void
|
||||
update: (option: ComponentOption<Host>) => ReturnType<this['add']>
|
||||
selector?: (option: ComponentOption<Host>, element: HTMLDivElement, events: EventCleanup[]) => void
|
||||
}
|
||||
export interface Controls<Host> extends Omit<Component<Host>, 'add' | 'update' | 'selector'> {
|
||||
isHover: boolean
|
||||
timer: number
|
||||
setting?: HTMLDivElement
|
||||
thumbnails?: HTMLDivElement
|
||||
init: () => void
|
||||
add: (input: ControlInput<Host>) => undefined
|
||||
update: (option: ComponentOption<Host>) => undefined
|
||||
check: (target?: SelectorItem) => void
|
||||
selector: (option: ComponentOption<Host>, element: HTMLDivElement, events: EventCleanup[]) => void
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Generated from public/runtime/construction.ts by yarn build:types. Do not edit.
|
||||
import type { Emitter } from '../emitter'
|
||||
import type Artplayer from '../runtime'
|
||||
import type { Events } from './events'
|
||||
import type { Player } from './player'
|
||||
/** Safe fields before Template returns; video/query/proxy getters are not usable yet. */
|
||||
export interface ProxyHost extends Emitter<Events>, Pick<Artplayer, 'constructor' | 'id' | 'option' | 'isLock' | 'isReady' | 'isFocus' | 'isInput' | 'isRotate' | 'isDestroy' | 'destroy'> {
|
||||
}
|
||||
type Pending<Names extends keyof Artplayer> = Player & Omit<Artplayer, Names | keyof Player> & Partial<Pick<Artplayer, Names>>
|
||||
type AfterPlayer = 'layers' | 'controls' | 'contextmenu' | 'subtitle' | 'info' | 'loading' | 'hotkey' | 'mask' | 'setting' | 'plugins'
|
||||
/** URL assignment awaits its owned delay before invoking customType. */
|
||||
export type CustomTypeHost = Artplayer
|
||||
export type LayerHost = Pending<AfterPlayer>
|
||||
export type ControlHost = Pending<Exclude<AfterPlayer, 'layers'>>
|
||||
export type ContextmenuHost = Pending<Exclude<AfterPlayer, 'layers' | 'controls'>>
|
||||
/** Constructor factories run before the Plugins registry is assigned to the player. */
|
||||
export type PluginHost = Pending<'plugins'>
|
||||
export {}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// Generated from public/runtime/events.ts by yarn build:types. Do not edit.
|
||||
import type { Events as LegacyEvents } from '../events'
|
||||
import type { SubtitleCue, SubtitleOption } from './subtitle'
|
||||
|
||||
type NativeEvents = {
|
||||
[Name in Extract<keyof LegacyEvents, `video:${string}`>]: [event: Event];
|
||||
}
|
||||
interface BuiltinEvents {
|
||||
[name: `video:${string}`]: [event: Event]
|
||||
'document:keydown': [KeyboardEvent]
|
||||
'document:mousemove': [MouseEvent]
|
||||
'document:mouseup': [MouseEvent]
|
||||
'mousemove': [MouseEvent]
|
||||
'click': [MouseEvent]
|
||||
'blur': [Event]
|
||||
'error': [error: unknown, attempt: number]
|
||||
'fullscreenError': [error: unknown]
|
||||
'aspectRatio': [string]
|
||||
'flip': [string]
|
||||
'seek': [time: number, requestedTime: number | string]
|
||||
'setBar': [type: string, percentage: number, event?: MouseEvent | TouchEvent]
|
||||
'subtitleBeforeUpdate': [cues: SubtitleCue[]]
|
||||
'subtitleAfterUpdate': [cues: SubtitleCue[]]
|
||||
'subtitleLoad': [cues: SubtitleCue[], option: SubtitleOption | null]
|
||||
}
|
||||
/** Legacy custom event augmentation is retained; builtin payload corrections take precedence. */
|
||||
export interface Events extends Omit<LegacyEvents, keyof BuiltinEvents>, NativeEvents, BuiltinEvents, Record<PropertyKey, unknown[]> {
|
||||
}
|
||||
export {}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Generated from public/runtime/media.ts by yarn build:types. Do not edit.
|
||||
export type MediaState = Pick<HTMLMediaElement, 'currentTime' | 'duration' | 'paused' | 'ended' | 'readyState'> & {
|
||||
readonly playing?: boolean
|
||||
}
|
||||
export interface PlaybackMethods<PlayResult = unknown, PauseResult = unknown> {
|
||||
play: () => PlayResult
|
||||
pause: () => PauseResult
|
||||
}
|
||||
export interface OptionalMediaCapabilities {
|
||||
readonly textTracks?: ArrayLike<TextTrack>
|
||||
readonly error?: unknown
|
||||
requestPictureInPicture?: () => Promise<PictureInPictureWindow>
|
||||
requestVideoFrameCallback?: (callback: VideoFrameRequestCallback) => number
|
||||
cancelVideoFrameCallback?: (handle: number) => void
|
||||
webkitEnterFullscreen?: () => void
|
||||
webkitExitFullscreen?: () => void
|
||||
readonly webkitSupportsFullscreen?: boolean
|
||||
webkitShowPlaybackTargetPicker?: () => void
|
||||
webkitSupportsPresentationMode?: (mode: string) => boolean
|
||||
webkitSetPresentationMode?: (mode: string) => void
|
||||
readonly webkitPresentationMode?: string
|
||||
readonly webkitDisplayingFullscreen?: boolean
|
||||
}
|
||||
export type NativeMedia = Omit<HTMLVideoElement, keyof OptionalMediaCapabilities> & OptionalMediaCapabilities
|
||||
export type CanvasMedia = HTMLCanvasElement & MediaState & PlaybackMethods & OptionalMediaCapabilities & {
|
||||
src: string | null
|
||||
readonly currentSrc: string | null
|
||||
readonly videoWidth: number
|
||||
readonly videoHeight: number
|
||||
readonly buffered: TimeRanges
|
||||
volume: number
|
||||
muted: boolean
|
||||
playbackRate: number
|
||||
load: () => unknown
|
||||
}
|
||||
/** Check optional capabilities before calling them on a native or proxy surface. */
|
||||
export type MediaSurface = NativeMedia | CanvasMedia
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// Generated from public/runtime/option.ts by yarn build:types. Do not edit.
|
||||
import type { OptionInput as LegacyOptionInput, Thumbnails } from '../option'
|
||||
import type { ComponentInput, ControlInput } from './component'
|
||||
import type { MediaSurface } from './media'
|
||||
import type { PluginFactory } from './plugin'
|
||||
import type { Languages } from './services'
|
||||
import type { SettingItem } from './setting'
|
||||
import type { SubtitleOption } from './subtitle'
|
||||
/** Callback receivers are the unchanged player instance selected by this view. */
|
||||
export interface OptionInput<Host> extends Omit<LegacyOptionInput, 'container' | 'proxy' | 'plugins' | 'layers' | 'controls' | 'contextmenu' | 'settings' | 'customType' | 'i18n' | 'icons'> {
|
||||
container: string | HTMLDivElement
|
||||
proxy?: (this: Host, art: Host) => MediaSurface | undefined
|
||||
plugins?: PluginFactory<Host>[]
|
||||
layers?: ComponentInput<Host>[]
|
||||
controls?: ControlInput<Host>[]
|
||||
contextmenu?: ComponentInput<Host>[]
|
||||
settings?: SettingItem<Host>[]
|
||||
customType?: Record<string, ((this: Host, video: MediaSurface, url: string, art: Host) => unknown) | undefined>
|
||||
i18n?: Languages
|
||||
icons?: Record<string, string | HTMLElement | undefined>
|
||||
}
|
||||
/** Defaults are merged once; later setters may replace thumbnails with a partial input. */
|
||||
export interface Option<Host> extends Omit<Required<OptionInput<Host>>, 'proxy' | 'subtitle' | 'thumbnails'> {
|
||||
proxy: OptionInput<Host>['proxy']
|
||||
subtitle: SubtitleOption
|
||||
thumbnails: Thumbnails
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
// Generated from public/runtime/player.ts by yarn build:types. Do not edit.
|
||||
import type { Thumbnails } from '../option'
|
||||
import type { State } from '../player'
|
||||
import type { MediaSurface } from './media'
|
||||
|
||||
export interface QualityItem {
|
||||
html: string | HTMLElement
|
||||
url: string
|
||||
default?: boolean
|
||||
}
|
||||
/** Player-facing descriptors; native/proxy method results retain their identity. */
|
||||
export interface Player<Media extends MediaSurface = MediaSurface> {
|
||||
get currentTime(): number
|
||||
set currentTime(time: number | string)
|
||||
readonly duration: number
|
||||
get seek(): undefined
|
||||
set seek(time: number | string)
|
||||
get forward(): undefined
|
||||
set forward(time: number)
|
||||
get backward(): undefined
|
||||
set backward(time: number)
|
||||
get switch(): undefined
|
||||
set switch(url: string)
|
||||
get quality(): undefined
|
||||
set quality(items: QualityItem[])
|
||||
get url(): string | null
|
||||
set url(value: string)
|
||||
get state(): State
|
||||
set state(value: string)
|
||||
get pip(): Element | null | boolean
|
||||
set pip(value: boolean)
|
||||
/** The descriptor may be absent before metadata installs the available mode. */
|
||||
fullscreen?: boolean
|
||||
fullscreenWeb: boolean
|
||||
mini: boolean
|
||||
volume: number
|
||||
muted: boolean
|
||||
playbackRate: number
|
||||
aspectRatio: string
|
||||
flip: string
|
||||
poster: string
|
||||
theme: string
|
||||
type: string
|
||||
subtitleOffset: number
|
||||
thumbnails: Thumbnails
|
||||
readonly loaded: number
|
||||
readonly loadedTime: number
|
||||
readonly played: number
|
||||
readonly playing: boolean
|
||||
readonly rect: DOMRect
|
||||
readonly bottom: number
|
||||
readonly height: number
|
||||
readonly left: number
|
||||
readonly right: number
|
||||
readonly top: number
|
||||
readonly width: number
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
play: () => Promise<Awaited<ReturnType<Media['play']>>>
|
||||
pause: () => ReturnType<Media['pause']>
|
||||
toggle: () => Promise<Awaited<ReturnType<Media['play']>>> | ReturnType<Media['pause']>
|
||||
switchUrl: (url: string) => Promise<void>
|
||||
switchQuality: (url: string) => Promise<void>
|
||||
autoSize: () => void
|
||||
autoHeight: () => void
|
||||
airplay: () => void
|
||||
getDataURL: () => Promise<string>
|
||||
getBlobUrl: () => Promise<string>
|
||||
screenshot: (name?: string) => Promise<string>
|
||||
attr: {
|
||||
(key: PropertyKey): unknown
|
||||
(key: PropertyKey, value: unknown): unknown
|
||||
}
|
||||
cssVar: {
|
||||
(key: string): string
|
||||
(key: string, value: unknown): string | void
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Generated from public/runtime/plugin.ts by yarn build:types. Do not edit.
|
||||
export type PluginFactory<Host, Result = unknown> = (this: Host, art: Host) => Result
|
||||
export type PluginRegistration<Result, Registry> = unknown extends Result ? Registry | Promise<Registry> : Result extends Promise<unknown> ? Promise<Registry> : Registry
|
||||
/** The same registry is returned immediately or after its Promise factory settles. */
|
||||
export interface Plugins<Host> {
|
||||
art: Host
|
||||
id: number
|
||||
add: <Result>(plugin: PluginFactory<Host, Result>) => PluginRegistration<Result, this>
|
||||
next: (plugin: PluginFactory<Host>, result: unknown) => this
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// Generated from public/runtime/services.ts by yarn build:types. Do not edit.
|
||||
export interface Config {
|
||||
properties: string[]
|
||||
methods: string[]
|
||||
events: string[]
|
||||
prototypes: string[]
|
||||
}
|
||||
export type Disposer = () => void
|
||||
export type Listener = EventListenerOrEventListenerObject | null
|
||||
export interface EventRegistry {
|
||||
destroyEvents: Set<Disposer>
|
||||
proxy: {
|
||||
(target: EventTarget, name: string, callback: Listener, option?: boolean | AddEventListenerOptions | null): Disposer
|
||||
(target: EventTarget, name: string[], callback: Listener, option?: boolean | AddEventListenerOptions | null): Disposer[]
|
||||
(target: EventTarget, name: string | string[], callback: Listener, option?: boolean | AddEventListenerOptions | null): Disposer | Disposer[]
|
||||
}
|
||||
hover: (target: EventTarget, mouseenter?: (event: Event) => unknown, mouseleave?: (event: Event) => unknown) => void
|
||||
remove: (dispose: Disposer) => void
|
||||
destroy: () => void
|
||||
bindGlobalEvents: (source?: {
|
||||
window?: Window
|
||||
document?: Document
|
||||
}) => void
|
||||
}
|
||||
export interface Storage {
|
||||
name: string
|
||||
settings: Record<PropertyKey, unknown>
|
||||
get: (key?: PropertyKey) => unknown
|
||||
set: (key: PropertyKey, value: unknown) => void
|
||||
del: (key: PropertyKey) => void
|
||||
clear: () => void
|
||||
}
|
||||
export type Dictionary = Record<string, string | undefined>
|
||||
export type Languages = Record<string, Dictionary | undefined>
|
||||
export interface I18n<Host> {
|
||||
art: Host
|
||||
languages: Languages
|
||||
language: Dictionary
|
||||
init: () => void
|
||||
get: (key: string) => string
|
||||
update: (value: Languages) => void
|
||||
}
|
||||
export type HotkeyCallback<Host> = (this: Host, event: KeyboardEvent) => unknown
|
||||
export interface Hotkey<Host> {
|
||||
art: Host
|
||||
keys: Record<string, HotkeyCallback<Host>[]>
|
||||
init: () => void
|
||||
add: (key: string, callback: HotkeyCallback<Host>) => this
|
||||
remove: (key: string, callback: HotkeyCallback<Host>) => this
|
||||
}
|
||||
export type ValidatorPath = (string | number)[]
|
||||
export type Validator = (value: unknown, type: string, paths: ValidatorPath) => unknown
|
||||
export type Scheme = string | Validator | Scheme[] | {
|
||||
[key: string]: Scheme
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// Generated from public/runtime/setting.ts by yarn build:types. Do not edit.
|
||||
export type SettingContent = string | HTMLElement | number
|
||||
export type SettingRange = [value?: number, min?: number, max?: number, step?: number]
|
||||
export type SettingCallback<Host> = (this: Host, item: SettingItem<Host>, element: HTMLDivElement, event: Event) => unknown
|
||||
export interface SettingItem<Host> {
|
||||
name?: string
|
||||
html?: SettingContent
|
||||
icon?: SettingContent
|
||||
tooltip?: SettingContent
|
||||
width?: number
|
||||
value?: string | number
|
||||
default?: boolean
|
||||
switch?: boolean
|
||||
range?: SettingRange
|
||||
selector?: SettingItem<Host>[]
|
||||
mounted?: (this: Host, element: HTMLDivElement, item: SettingItem<Host>) => unknown
|
||||
onClick?: SettingCallback<Host>
|
||||
onSwitch?: SettingCallback<Host>
|
||||
onRange?: SettingCallback<Host>
|
||||
onChange?: SettingCallback<Host>
|
||||
onSelect?: SettingCallback<Host>
|
||||
readonly $parent?: SettingItem<Host>
|
||||
readonly $parents?: SettingItem<Host>[]
|
||||
readonly $option?: SettingItem<Host>[]
|
||||
readonly $events?: (() => void)[]
|
||||
readonly $formatted?: boolean
|
||||
readonly $item?: HTMLDivElement
|
||||
readonly $icon?: HTMLDivElement
|
||||
readonly $html?: HTMLDivElement
|
||||
readonly $tooltip?: HTMLDivElement
|
||||
readonly $switch?: HTMLDivElement
|
||||
readonly $range?: HTMLInputElement
|
||||
}
|
||||
export interface Setting<Host> {
|
||||
id: number
|
||||
art: Host
|
||||
name: string
|
||||
$parent: HTMLElement
|
||||
cache: Map<SettingItem<Host>[], HTMLDivElement>
|
||||
active: SettingItem<Host>[] | null
|
||||
option: SettingItem<Host>[]
|
||||
readonly builtin: SettingItem<Host>[]
|
||||
show: boolean
|
||||
toggle: () => void
|
||||
traverse: (callback: (item: SettingItem<Host>) => void, option?: SettingItem<Host>[]) => void
|
||||
check: (target?: SettingItem<Host> | null) => void
|
||||
format: (option?: SettingItem<Host>[], parent?: SettingItem<Host>, parents?: SettingItem<Host>[], names?: string[]) => void
|
||||
find: (name?: string) => SettingItem<Host> | null
|
||||
resize: () => void
|
||||
inactivate: (item: SettingItem<Host>) => void
|
||||
remove: (name: string) => void
|
||||
update: (item: SettingItem<Host>) => SettingItem<Host>
|
||||
add: <Item extends SettingItem<Host>>(item: Item, option?: SettingItem<Host>[]) => Item
|
||||
createHeader: (item: SettingItem<Host>) => void
|
||||
createItem: (item: SettingItem<Host>, isUpdate?: boolean) => void
|
||||
render: (option?: SettingItem<Host>[]) => void
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Generated from public/runtime/subtitle.ts by yarn build:types. Do not edit.
|
||||
import type { Subtitle as SubtitleInput } from '../subtitle'
|
||||
|
||||
export type SubtitleOption = Required<SubtitleInput>
|
||||
export interface SubtitleCue extends TextTrackCue {
|
||||
text: string
|
||||
originalStartTime?: number
|
||||
originalEndTime?: number
|
||||
}
|
||||
export interface SubtitleTrack extends HTMLTrackElement {
|
||||
offset?: number
|
||||
}
|
||||
export interface Subtitle {
|
||||
name: string
|
||||
option: SubtitleOption | null
|
||||
destroyEvent: () => unknown
|
||||
url: string
|
||||
readonly textTrack: TextTrack | undefined
|
||||
readonly activeCues: SubtitleCue[]
|
||||
readonly cues: SubtitleCue[]
|
||||
show: boolean
|
||||
toggle: () => void
|
||||
style: {
|
||||
(styles: Partial<CSSStyleDeclaration>): HTMLDivElement
|
||||
(key: string, value: string | number): HTMLDivElement
|
||||
}
|
||||
update: () => void
|
||||
switch: (url: string, option?: SubtitleInput) => Promise<string | null | undefined>
|
||||
init: (option: SubtitleOption) => Promise<string | null | undefined>
|
||||
createTrack: (kind: string, url: string) => void
|
||||
}
|
||||
export interface Notice {
|
||||
timer: number | null
|
||||
get show(): boolean
|
||||
set show(value: string | Error | false)
|
||||
destroy: () => void
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// Generated from public/runtime/template.ts by yarn build:types. Do not edit.
|
||||
import type { MediaSurface } from './media'
|
||||
/** Query results remain nullable for caller-supplied SSR templates. */
|
||||
export interface Template<Host, Media extends MediaSurface = MediaSurface> {
|
||||
art: Host
|
||||
$container: HTMLDivElement
|
||||
$player: HTMLDivElement | null
|
||||
$video: Media
|
||||
$track: HTMLTrackElement | null
|
||||
$poster: HTMLDivElement | null
|
||||
$subtitle: HTMLDivElement | null
|
||||
$danmuku: HTMLDivElement | null
|
||||
$bottom: HTMLDivElement | null
|
||||
$progress: HTMLDivElement | null
|
||||
$controls: HTMLDivElement | null
|
||||
$controlsLeft: HTMLDivElement | null
|
||||
$controlsCenter: HTMLDivElement | null
|
||||
$controlsRight: HTMLDivElement | null
|
||||
$layer: HTMLDivElement | null
|
||||
$loading: HTMLDivElement | null
|
||||
$notice: HTMLDivElement | null
|
||||
$noticeInner: HTMLDivElement | null
|
||||
$mask: HTMLDivElement | null
|
||||
$state: HTMLDivElement | null
|
||||
$setting: HTMLDivElement | null
|
||||
$info: HTMLDivElement | null
|
||||
$infoPanel: HTMLDivElement | null
|
||||
$infoClose: HTMLDivElement | null
|
||||
$contextmenu: HTMLDivElement | null
|
||||
$mini?: HTMLElement
|
||||
query: <ElementType extends Element = Element>(selector: string) => ElementType | null
|
||||
init: () => void
|
||||
destroy: (removeHtml: boolean) => void
|
||||
}
|
||||
export type IconName = 'loading' | 'state' | 'play' | 'pause' | 'check' | 'volume' | 'volumeClose' | 'screenshot' | 'setting' | 'pip' | 'arrowLeft' | 'arrowRight' | 'playbackRate' | 'aspectRatio' | 'config' | 'lock' | 'flip' | 'unlock' | 'fullscreenOff' | 'fullscreenOn' | 'fullscreenWebOff' | 'fullscreenWebOn' | 'switchOn' | 'switchOff' | 'error' | 'close' | 'airplay'
|
||||
/** Default getters create fresh icon wrappers; unknown custom keys may be absent. */
|
||||
export type Icons = Readonly<Record<IconName, HTMLElement>> & {
|
||||
readonly [name: string]: HTMLElement | undefined
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// Generated from public/runtime/utils.ts by yarn build:types. Do not edit.
|
||||
interface StyledElement {
|
||||
style: CSSStyleDeclaration
|
||||
}
|
||||
interface EventPathSource {
|
||||
target: EventTarget | null
|
||||
composedPath?: () => EventTarget[]
|
||||
}
|
||||
type StackFrame = ((...args: never[]) => unknown) | (abstract new (...args: never[]) => object)
|
||||
export interface Utils {
|
||||
isBrowser: boolean
|
||||
userAgent: string
|
||||
isMobile: boolean
|
||||
isSafari: boolean
|
||||
isIOS: boolean
|
||||
isIOS13: boolean
|
||||
query: <T extends Element = Element>(selector: string, parent?: ParentNode) => T | null
|
||||
queryAll: <T extends Element = Element>(selector: string, parent?: ParentNode) => T[]
|
||||
addClass: (target: Pick<Element, 'classList'>, className: string) => void
|
||||
removeClass: (target: Pick<Element, 'classList'>, className: string) => void
|
||||
hasClass: (target: Pick<Element, 'classList'>, className: string) => boolean
|
||||
append: (parent: Element, child: unknown) => Element | ChildNode | null
|
||||
remove: <T extends Node>(child: T) => T
|
||||
replaceElement: <T extends Node>(newChild: T, oldChild: Node) => T
|
||||
siblings: (target: Element) => Element[]
|
||||
inverseClass: (target: Element, className: string) => void
|
||||
createElement: {
|
||||
<K extends keyof HTMLElementTagNameMap>(tag: K): HTMLElementTagNameMap[K]
|
||||
(tag: string): HTMLElement
|
||||
}
|
||||
setStyle: <T extends StyledElement>(element: T, key: PropertyKey, value: unknown) => T
|
||||
setStyles: <T extends StyledElement>(element: T, styles: object) => T
|
||||
getStyle: {
|
||||
(element: Element, key: string, numberType?: true): number
|
||||
(element: Element, key: string, numberType: false): string
|
||||
(element: Element, key: string, numberType: boolean): number | string
|
||||
}
|
||||
setStyleText: (id: string, cssText: string) => void
|
||||
getRect: (element: Pick<Element, 'getBoundingClientRect'>) => DOMRect
|
||||
tooltip: (target: Element, message: string | number, position?: string) => void
|
||||
isInViewport: (target: Pick<Element, 'getBoundingClientRect'>, offset?: number) => boolean
|
||||
includeFromEvent: (event: EventPathSource, target: EventTarget | null | undefined) => boolean
|
||||
getSafeAreaInsets: () => {
|
||||
top: number
|
||||
right: number
|
||||
bottom: number
|
||||
left: number
|
||||
}
|
||||
srtToVtt: (text: string) => string
|
||||
vttToBlob: (text: string) => string
|
||||
assToVtt: (text: string) => string
|
||||
getExt: (url: string) => string
|
||||
download: (url: string, name: string) => void
|
||||
loadImg: (url: string, scale?: number) => Promise<HTMLImageElement>
|
||||
errorHandle: <T>(condition: T, message?: string) => T
|
||||
silencePromise: <T>(value: T) => T extends Promise<infer Result> ? Promise<Result | undefined> : T
|
||||
def: <T extends object>(object: T, name: PropertyKey, descriptor: PropertyDescriptor & object & ThisType<T>) => T
|
||||
has: (object: object, name: PropertyKey) => boolean
|
||||
get: (object: object, name: PropertyKey) => PropertyDescriptor | undefined
|
||||
mergeDeep: <T extends object[]>(...objects: T) => T[number]
|
||||
sleep: (milliseconds?: number) => Promise<void>
|
||||
/** The wrapper preserves its call receiver; the old context argument is ignored. */
|
||||
debounce: <Receiver, Args extends unknown[]>(callback: (this: Receiver, ...args: Args) => unknown, duration: number, context?: object) => (this: Receiver, ...args: Args) => void
|
||||
throttle: <Receiver, Args extends unknown[]>(callback: (this: Receiver, ...args: Args) => unknown, duration: number) => (this: Receiver, ...args: Args) => void
|
||||
clamp: (number: number, a: number, b: number) => number
|
||||
secondToTime: (second: number) => string
|
||||
escape: (text: string) => string
|
||||
unescape: (text: string) => string
|
||||
capitalize: (text: string) => string
|
||||
ArtPlayerError: new (message?: string, context?: StackFrame) => Error
|
||||
getIcon: (key?: string, html?: string | HTMLElement) => HTMLElement
|
||||
getComposedPath: (event: EventPathSource) => EventTarget[]
|
||||
supportsFlex: () => boolean
|
||||
}
|
||||
export {}
|
||||
+1
-15
@@ -1,3 +1,4 @@
|
||||
// Generated from public/setting.ts by yarn build:types. Do not edit.
|
||||
import type Artplayer from './artplayer'
|
||||
|
||||
export interface SettingOption extends Omit<Setting, 'html' | 'icon' | 'tooltip'> {
|
||||
@@ -16,78 +17,63 @@ export interface SettingOption extends Omit<Setting, 'html' | 'icon' | 'tooltip'
|
||||
$events: Array<() => void>
|
||||
$formatted: boolean
|
||||
}
|
||||
|
||||
export interface Setting {
|
||||
/**
|
||||
* Html string or html element of setting name
|
||||
*/
|
||||
html: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Html string or html element of setting icon
|
||||
*/
|
||||
icon?: string | HTMLElement
|
||||
|
||||
/**
|
||||
* The width of setting
|
||||
*/
|
||||
width?: number
|
||||
|
||||
/**
|
||||
* The tooltip of setting
|
||||
*/
|
||||
tooltip?: string | HTMLElement
|
||||
|
||||
/**
|
||||
* Whether the default is selected
|
||||
*/
|
||||
default?: boolean
|
||||
|
||||
/**
|
||||
* Custom selector list
|
||||
*/
|
||||
selector?: Setting[]
|
||||
|
||||
/**
|
||||
* When the setting was mounted
|
||||
*/
|
||||
mounted?: (this: Artplayer, panel: HTMLDivElement, item: Setting) => void
|
||||
|
||||
/**
|
||||
* When selector item click
|
||||
*/
|
||||
onSelect?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* Custom switch item
|
||||
*/
|
||||
switch?: boolean
|
||||
|
||||
/**
|
||||
* When switch item click
|
||||
*/
|
||||
onSwitch?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* Custom range item
|
||||
*/
|
||||
range?: [value?: number, min?: number, max?: number, step?: number]
|
||||
|
||||
/**
|
||||
* When range item change
|
||||
*/
|
||||
onRange?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* When range item change in real time
|
||||
*/
|
||||
onChange?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* When range item change in real time
|
||||
*/
|
||||
onClick?: (this: Artplayer, item: SettingOption, element: HTMLDivElement, event: Event) => void
|
||||
|
||||
/**
|
||||
* Allow custom properties
|
||||
*/
|
||||
|
||||
+1
-6
@@ -1,34 +1,29 @@
|
||||
// Generated from public/subtitle.ts by yarn build:types. Do not edit.
|
||||
export interface Subtitle {
|
||||
/**
|
||||
* The subtitle url
|
||||
*/
|
||||
url?: string
|
||||
|
||||
/**
|
||||
* The subtitle name
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* The subtitle type
|
||||
*/
|
||||
type?: 'vtt' | 'srt' | 'ass' | (string & Record<never, never>)
|
||||
|
||||
/**
|
||||
* The subtitle style object
|
||||
*/
|
||||
style?: Partial<CSSStyleDeclaration>
|
||||
|
||||
/**
|
||||
* The subtitle encoding, default utf-8
|
||||
*/
|
||||
encoding?: string
|
||||
|
||||
/**
|
||||
* Whether use escape, default true
|
||||
*/
|
||||
escape?: boolean
|
||||
|
||||
/**
|
||||
* Change the vtt text
|
||||
*/
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// Generated from public/template.ts by yarn build:types. Do not edit.
|
||||
export interface Template {
|
||||
readonly html: string
|
||||
readonly $container: HTMLDivElement
|
||||
|
||||
Vendored
+14
-15
@@ -1,3 +1,4 @@
|
||||
// Generated from public/utils.ts by yarn build:types. Do not edit.
|
||||
export interface Utils {
|
||||
isBrowser: boolean
|
||||
userAgent: string
|
||||
@@ -5,7 +6,6 @@ export interface Utils {
|
||||
isSafari: boolean
|
||||
isIOS: boolean
|
||||
isIOS13: boolean
|
||||
|
||||
query: <T extends Element = Element>(selector: string, parent?: Document | HTMLElement) => T | null
|
||||
queryAll: <T extends Element = Element>(selector: string, parent?: Document | HTMLElement) => T[]
|
||||
addClass: (target: HTMLElement, className: string) => void
|
||||
@@ -17,31 +17,34 @@ export interface Utils {
|
||||
siblings: (target: HTMLElement) => HTMLElement[]
|
||||
inverseClass: (target: HTMLElement, className: string) => void
|
||||
createElement: <K extends keyof HTMLElementTagNameMap>(tag: K) => HTMLElementTagNameMap[K]
|
||||
setStyle: <T extends keyof CSSStyleDeclaration>(
|
||||
element: HTMLElement,
|
||||
key: T,
|
||||
value: string | CSSStyleDeclaration[T],
|
||||
) => HTMLElement
|
||||
setStyle: <T extends keyof CSSStyleDeclaration>(element: HTMLElement, key: T, value: string | CSSStyleDeclaration[T]) => HTMLElement
|
||||
setStyles: (element: HTMLElement, styles: Partial<CSSStyleDeclaration>) => HTMLElement
|
||||
getStyle: {
|
||||
(element: HTMLElement, key: keyof CSSStyleDeclaration, numberType?: true): number
|
||||
(element: HTMLElement, key: keyof CSSStyleDeclaration, numberType: false): string
|
||||
}
|
||||
setStyleText: (id: string, cssText: string) => void
|
||||
getRect: (el: HTMLElement) => { top: number, left: number, width: number, height: number }
|
||||
getRect: (el: HTMLElement) => {
|
||||
top: number
|
||||
left: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
tooltip: (target: HTMLElement, msg: string, pos?: string) => void
|
||||
isInViewport: (target: HTMLElement, offset?: number) => boolean
|
||||
includeFromEvent: (event: Event, target: HTMLElement) => boolean
|
||||
getSafeAreaInsets: () => { top: number, right: number, bottom: number, left: number }
|
||||
|
||||
getSafeAreaInsets: () => {
|
||||
top: number
|
||||
right: number
|
||||
bottom: number
|
||||
left: number
|
||||
}
|
||||
srtToVtt: (srtText: string) => string
|
||||
vttToBlob: (vttText: string) => string
|
||||
assToVtt: (assText: string) => string
|
||||
|
||||
getExt: (url: string) => string
|
||||
download: (url: string, name: string) => void
|
||||
loadImg: (url: string, scale?: number) => Promise<HTMLImageElement>
|
||||
|
||||
errorHandle: <T extends boolean>(condition: T, msg: string) => T extends true ? T : never
|
||||
silencePromise: <T>(value: T) => T extends Promise<infer R> ? Promise<R | undefined> : T
|
||||
def: {
|
||||
@@ -52,21 +55,17 @@ export interface Utils {
|
||||
has: (obj: object, name: PropertyKey) => boolean
|
||||
get: (obj: object, name: PropertyKey) => PropertyDescriptor | undefined
|
||||
mergeDeep: <T extends object[]>(...args: T) => T[number]
|
||||
|
||||
sleep: (ms?: number) => Promise<void>
|
||||
/** Historical return type; runtime discards the callback result and ignores context. */
|
||||
debounce: <F extends (...args: any[]) => any>(func: F, wait: number, context?: object) => (...args: Parameters<F>) => ReturnType<F>
|
||||
/** Historical return type; runtime discards the callback result. */
|
||||
throttle: <F extends (...args: any[]) => any>(func: F, wait: number) => (...args: Parameters<F>) => ReturnType<F>
|
||||
|
||||
clamp: (num: number, a: number, b: number) => number
|
||||
secondToTime: (second: number) => string
|
||||
escape: (str: string) => string
|
||||
unescape: (str: string) => string
|
||||
capitalize: (str: string) => string
|
||||
|
||||
ArtPlayerError: new (message?: string, context?: ((...args: never[]) => unknown) | (abstract new (...args: never[]) => object)) => Error
|
||||
|
||||
getIcon: (key?: string, html?: string | HTMLElement) => HTMLElement
|
||||
getComposedPath: (event: Event) => EventTarget[]
|
||||
supportsFlex: () => boolean
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
| [第三方来源清单](third-party.json) | 依赖解析、vendor 文件指纹、SDK/CDN 与许可来源缺口 |
|
||||
| [消费者与真实环境矩阵](environment-matrix.md) | 22 包的版本依据、能力/设备/样本、现有证据、验证任务及发布影响 |
|
||||
| [类型检查与迁移入口](typechecking.md) | 根/分包配置、当前/旧编译器、严格正反例和历史声明错误 |
|
||||
| [核心公共类型出口设计](core-public-types.md) | CORE-21 的声明生成、旧编译器兼容、精确入口和编辑器验收 |
|
||||
| [JS/TS 构建与开发](build-development.md) | 非交互选包、开发重建、资源夹具和 AMD 全局修复 |
|
||||
| [测试目录维护说明](../test/README.md) | 统一测试命令、JS/TS loader、受控媒体及新旧公共契约 |
|
||||
| [真实浏览器入口](../test/browser/README.md) | 三浏览器、解码画面与媒体状态、Range/失败服务及候选文件映射 |
|
||||
|
||||
@@ -0,0 +1,535 @@
|
||||
{
|
||||
"task": "CORE-21",
|
||||
"date": "2026-09-11",
|
||||
"status": "partial-generation-only",
|
||||
"parentCommit": "ee895a558ff0c8a62274eb64049cedfd8409112d",
|
||||
"files": {
|
||||
"packages/artplayer/public/artplayer.cts": "0e91e907d021db02a68004603e6190505fdc0806d873ebb6af171aa089a81da7",
|
||||
"packages/artplayer/public/artplayer.mts": "f6292596a9ccb1d43a6d6a12c35f859b1889ad15924c5ae0f9f280941aade313",
|
||||
"packages/artplayer/public/artplayer.ts": "26a42ac66811e70f68a8ebe62cbf304eb1993451b3e658961be98e7106162527",
|
||||
"packages/artplayer/public/component.ts": "aa1c43be67322781b4b355b143bc69d9f29d22e578e4974d6a13e957a7c0334f",
|
||||
"packages/artplayer/public/config.ts": "c4fd8681bf32b10c743e3e561c532520c8f32e43fd765524850b15e55cb91c72",
|
||||
"packages/artplayer/public/cssVar.ts": "e027d82fb4f01c9ce7559cf679b2d5ee1962d3f7e5b4dd64ca21f472b933efb6",
|
||||
"packages/artplayer/public/emitter.ts": "9c62551cdcc6dd3966bed8a7a85dd477435db977c91a294d2ac8f162f9592537",
|
||||
"packages/artplayer/public/events.ts": "af191f862af4ec8933b09113b8c074603ae254a8b70460d0f3006646cd74ae42",
|
||||
"packages/artplayer/public/i18n.ts": "3e14759caf71f97f01650839248c8737c42d2c2979dabc43ad92b724da648708",
|
||||
"packages/artplayer/public/icons.ts": "0d8e8e52e52130dd4a29bab551dd7a2a954797e42e92a6e068c85d583e23e6a4",
|
||||
"packages/artplayer/public/language.cts": "2248040d86a8e34626755c4ecf53ea0174706c653073cf0e15884a030d173120",
|
||||
"packages/artplayer/public/language.mts": "c391e863012c77769e661afbf8fa949e9373aa88d17f58cbba7f5696edb8077f",
|
||||
"packages/artplayer/public/legacy/language.ts": "c452ffd764ff9b29b819b3475c42395d2ea7a33560d8c186ef5df3844b9524c3",
|
||||
"packages/artplayer/public/option.ts": "850e5264219b8b438c80694402225b690b131786677a5da0d22739ec2352d263",
|
||||
"packages/artplayer/public/playback.ts": "1ceaed3aa1cef511fe8b20f4874647f6065c723ad805b742a0a9247e16bb1bb5",
|
||||
"packages/artplayer/public/player.ts": "f1e50257df2ea592d0a0e1f36078dda77eaf2cf3b3d795307501396562d99f28",
|
||||
"packages/artplayer/public/plugin.ts": "2a57e148fda00ee687da5036b890b0f611cb94bb403a1ed52602179060259d35",
|
||||
"packages/artplayer/public/quality.ts": "7ed6ed78cea52991b2f6ddd2bd3b7bd8c5146fdfff7486fe8b814c3e632f1567",
|
||||
"packages/artplayer/public/setting.ts": "d12a75b656fff70cbb30be4bffec46d9c4273636e8722bce971a4d2b188712a1",
|
||||
"packages/artplayer/public/subtitle.ts": "d25b470e47d6a9bd696d9c1ad8adb58e56a208f05695186d513bc8c43c2e8acf",
|
||||
"packages/artplayer/public/template.ts": "68aed9e97d006d6be4fabb8504ca84dafab770b0925f4d6e7319e67c82f21b0d",
|
||||
"packages/artplayer/public/utils.ts": "494ec447ab467a07ddd7a2c2abf778b3fce69fd28a09aaa8ced9759f8de2e3f6",
|
||||
"packages/artplayer/types/artplayer.d.cts": "62ec73de1cdd5915760509408b384f19f37e621f7d636aa72999d44e0c69df43",
|
||||
"packages/artplayer/types/artplayer.d.mts": "b664fec51ee5c5381f2ceab25d99d52aee56feab04a2ee7b4ea5b2145ea5fa0e",
|
||||
"packages/artplayer/types/artplayer.d.ts": "5d0162adf7ac6d0f2bb9b5cfe361f28657c4d9c540cadbf36eba3cc954ce50f8",
|
||||
"packages/artplayer/types/component.d.ts": "ae5bc1ddeaa1ee1ebbc62573e32423993727079205c64751a5a314170e588a32",
|
||||
"packages/artplayer/types/config.d.ts": "36f9a84cd436f17701a0d11d3417fc1fe0414e0c52c80083b94a85dfc329e37e",
|
||||
"packages/artplayer/types/cssVar.d.ts": "93217860fff2ebf750f606d95ddd22220a58837119e63bdf2f5f78fd7488458b",
|
||||
"packages/artplayer/types/emitter.d.ts": "7e1f9a2a8ce65feb95734f1ed52d1334e57aa388bbef2a43d8bc53a9b6f6623c",
|
||||
"packages/artplayer/types/events.d.ts": "f83624c9268a284477e8bd793fe3562a2363b72f2a44d5c64fe8c6a6cede8830",
|
||||
"packages/artplayer/types/i18n.d.ts": "bebbe372d9b22443e75e0c0cea05bd52e8a44c1f82ce656d278a100a21a85b57",
|
||||
"packages/artplayer/types/icons.d.ts": "326a67ba7bdcf52862c5b2a269e540140aff98d05c7b96196485a77f84fe5960",
|
||||
"packages/artplayer/types/language.d.cts": "f7928e108cf7b7814c2d75cb0a525333e95873fca6cd6d89a740450656b9c1cd",
|
||||
"packages/artplayer/types/language.d.mts": "6619a26d604b7cccbe2f596243d87ae37cfaae33b8b52874ec071d9787446f9e",
|
||||
"packages/artplayer/types/legacy/language.d.ts": "c7abda4d506fd933c350e9030290bf9e64347a921d683a66115da1995ebe0a81",
|
||||
"packages/artplayer/types/option.d.ts": "ccf2c8ddc537dc65c9682d39f044726e23bff18f476b622512d7e6a4b949b5f6",
|
||||
"packages/artplayer/types/playback.d.ts": "58705c273df6e76a77a6575e769a9ec6c013785c25080f2551aa22415788d870",
|
||||
"packages/artplayer/types/player.d.ts": "92b00211b70ac71336e495899df972a0519dd138111846044fe4e0f967966177",
|
||||
"packages/artplayer/types/plugin.d.ts": "fc3594a41c51d8248713e33c486fb1f6a518ac5c7ce31be6988a6cd8d052c5f3",
|
||||
"packages/artplayer/types/quality.d.ts": "1ac1a48b4f74ff9ba1ce60443e1463d50d1c6a2e5d87d63dc7d2a8eb7f4c2c34",
|
||||
"packages/artplayer/types/setting.d.ts": "08305a75dff96f06490430e099338b463df471b550c1d0dac3abc8995b39eb09",
|
||||
"packages/artplayer/types/subtitle.d.ts": "b18314e2d64efdb6045830b6e12f615ae2ed585416130e562329ad3ea337f6ce",
|
||||
"packages/artplayer/types/template.d.ts": "4792bc0c2cbcb7966e4375118bd34b326166e0831862e94ace4cf6b1bbe6a8c8",
|
||||
"packages/artplayer/types/utils.d.ts": "fca0d3d814df94a25f9eb067c86fa0cf272e2791bac793b91229d57680797712",
|
||||
"scripts/build-types.mjs": "d3bc5fc09598c3e8772aeec9e72ea5daad5e641a786107dfa0e374d1e6f75f2a",
|
||||
"scripts/package-check.mjs": "ef962a33947d113a01995731123429edc41bb88dfb5b1d68bc930c6b21827351",
|
||||
"packages/artplayer/.npmignore": "ee5bface8b8b100272b150e927f059fbd106f7ece38b65125f4f9864deb979bd",
|
||||
"packages/artplayer/tsconfig.json": "c074f0621b18e6f209e217a702745e4118ee7724955e8104c7e3df3a223a9921",
|
||||
"package.json": "7edd6f8a0d97cf6e52238e5dbf57ae658ddb0c51bab3f80728fa6063f1a91e37",
|
||||
"test/declarations.test.js": "5f7c72b23fcde96082f5e7ef639c9f85d10d186336271363d6882b50b338aee6",
|
||||
"test/package-check.test.js": "daecef5ca8f436efb8a72c5e99632061aa9110d2c295cd97eeed5bc9fd0a3aa5"
|
||||
},
|
||||
"ci": {
|
||||
"total": 448,
|
||||
"unit": 418,
|
||||
"engineering": 5,
|
||||
"baseline": 25,
|
||||
"strictProductionTS": 229,
|
||||
"logSha256": "99052a3dbaccd8d8851cff89c32eb9a5e7f5ee8e23a233fba884282d40a8e8b6",
|
||||
"scope": "Generation foundation; the subsequent package-source leak assertions were separately verified."
|
||||
},
|
||||
"additionalChecks": [
|
||||
{
|
||||
"file": "refactor/.cache/core21-generated-typecheck.log",
|
||||
"sha256": "28566c127da4d8a47f811eba48b01797de8434b554899ab849130252b6a9a05d"
|
||||
},
|
||||
{
|
||||
"file": "refactor/.cache/core21-generator-tests.log",
|
||||
"sha256": "4dda583d13be1c6a8c9b29d337f48383dc0961cce38180b77ce5d8ba5132062f"
|
||||
},
|
||||
{
|
||||
"file": "refactor/.cache/core21-generated-lint.log",
|
||||
"sha256": "8ac071e5fee6b40acdb65ebcb26d6ebb55aaf2736d0e718407466ec5ab1674a1"
|
||||
},
|
||||
{
|
||||
"file": "refactor/.cache/core21-package-source-negative.log",
|
||||
"sha256": "48dc2f8a26f00e2dfbc5152b2ffb1b804a0f7a97da5bd782bea59a2e0049f22d"
|
||||
}
|
||||
],
|
||||
"package": {
|
||||
"output": "refactor/.cache/packages/run-GY8u71",
|
||||
"reportSha256": "8813ab6594cfc70cf940bd9e592549676151627889e0c7be541bccdb91dc51fb",
|
||||
"runtime": [
|
||||
"DIST.cjs",
|
||||
"DIST.cjs-legacy",
|
||||
"DIST.esm",
|
||||
"DIST.esm-default-only",
|
||||
"DIST.esm-legacy",
|
||||
"DIST.global-core",
|
||||
"DIST.amd-core",
|
||||
"DIST.global-core-legacy",
|
||||
"DIST.amd-core-legacy",
|
||||
"DIST.global-chapter",
|
||||
"DIST.amd-chapter",
|
||||
"DIST.global-chapter-legacy",
|
||||
"DIST.amd-chapter-legacy",
|
||||
"SSR.import-template",
|
||||
"SSR.constructor-browser-only",
|
||||
"SSR.custom-ua-umd-legacy",
|
||||
"SSR.custom-ua-esm",
|
||||
"DIST.i18n-cjs-esm-global",
|
||||
"DIST.exports-boundary",
|
||||
"DIST.direct-esm-file",
|
||||
"EVENT.lazy-registry",
|
||||
"EVENT.symbol-number-channels",
|
||||
"EVENT.context-removal",
|
||||
"EVENT.once-throw-consumed",
|
||||
"EVENT.chain-context-arguments",
|
||||
"EVENT.once-reentry",
|
||||
"EVENT.dispatch-snapshot",
|
||||
"EVENT.off-original-once",
|
||||
"EVENT.throw-propagation"
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"compiler": "5.9.3",
|
||||
"mode": "node10-commonjs",
|
||||
"diagnostics": [],
|
||||
"declarations": [
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.legacy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.dom.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.collection.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.core.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.generator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.iterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.proxy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.reflect.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.array.include.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.regexp.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.array.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.bigint.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.number.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es5.d.ts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.ts",
|
||||
"node_modules/artplayer/types/artplayer.d.ts",
|
||||
"node_modules/artplayer/types/component.d.ts",
|
||||
"node_modules/artplayer/types/config.d.ts",
|
||||
"node_modules/artplayer/types/cssVar.d.ts",
|
||||
"node_modules/artplayer/types/emitter.d.ts",
|
||||
"node_modules/artplayer/types/events.d.ts",
|
||||
"node_modules/artplayer/types/i18n.d.ts",
|
||||
"node_modules/artplayer/types/icons.d.ts",
|
||||
"node_modules/artplayer/types/legacy/language.d.ts",
|
||||
"node_modules/artplayer/types/option.d.ts",
|
||||
"node_modules/artplayer/types/playback.d.ts",
|
||||
"node_modules/artplayer/types/player.d.ts",
|
||||
"node_modules/artplayer/types/plugin.d.ts",
|
||||
"node_modules/artplayer/types/quality.d.ts",
|
||||
"node_modules/artplayer/types/setting.d.ts",
|
||||
"node_modules/artplayer/types/subtitle.d.ts",
|
||||
"node_modules/artplayer/types/template.d.ts",
|
||||
"node_modules/artplayer/types/utils.d.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"compiler": "5.9.3",
|
||||
"mode": "nodenext-cjs",
|
||||
"diagnostics": [],
|
||||
"declarations": [
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.legacy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.dom.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.collection.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.core.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.generator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.iterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.proxy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.reflect.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.array.include.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.regexp.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.array.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.bigint.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.number.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es5.d.ts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.cts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.ts",
|
||||
"node_modules/artplayer/types/artplayer.d.cts",
|
||||
"node_modules/artplayer/types/artplayer.d.ts",
|
||||
"node_modules/artplayer/types/component.d.ts",
|
||||
"node_modules/artplayer/types/config.d.ts",
|
||||
"node_modules/artplayer/types/cssVar.d.ts",
|
||||
"node_modules/artplayer/types/emitter.d.ts",
|
||||
"node_modules/artplayer/types/events.d.ts",
|
||||
"node_modules/artplayer/types/i18n.d.ts",
|
||||
"node_modules/artplayer/types/icons.d.ts",
|
||||
"node_modules/artplayer/types/language.d.cts",
|
||||
"node_modules/artplayer/types/option.d.ts",
|
||||
"node_modules/artplayer/types/playback.d.ts",
|
||||
"node_modules/artplayer/types/player.d.ts",
|
||||
"node_modules/artplayer/types/plugin.d.ts",
|
||||
"node_modules/artplayer/types/quality.d.ts",
|
||||
"node_modules/artplayer/types/setting.d.ts",
|
||||
"node_modules/artplayer/types/subtitle.d.ts",
|
||||
"node_modules/artplayer/types/template.d.ts",
|
||||
"node_modules/artplayer/types/utils.d.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"compiler": "5.9.3",
|
||||
"mode": "bundler-esm",
|
||||
"diagnostics": [],
|
||||
"declarations": [
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.legacy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.dom.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.collection.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.core.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.generator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.iterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.proxy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.reflect.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.array.include.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.regexp.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.array.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.bigint.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.number.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es5.d.ts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.cts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.mts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.ts",
|
||||
"node_modules/artplayer/types/artplayer.d.cts",
|
||||
"node_modules/artplayer/types/artplayer.d.mts",
|
||||
"node_modules/artplayer/types/artplayer.d.ts",
|
||||
"node_modules/artplayer/types/component.d.ts",
|
||||
"node_modules/artplayer/types/config.d.ts",
|
||||
"node_modules/artplayer/types/cssVar.d.ts",
|
||||
"node_modules/artplayer/types/emitter.d.ts",
|
||||
"node_modules/artplayer/types/events.d.ts",
|
||||
"node_modules/artplayer/types/i18n.d.ts",
|
||||
"node_modules/artplayer/types/icons.d.ts",
|
||||
"node_modules/artplayer/types/language.d.cts",
|
||||
"node_modules/artplayer/types/language.d.mts",
|
||||
"node_modules/artplayer/types/option.d.ts",
|
||||
"node_modules/artplayer/types/playback.d.ts",
|
||||
"node_modules/artplayer/types/player.d.ts",
|
||||
"node_modules/artplayer/types/plugin.d.ts",
|
||||
"node_modules/artplayer/types/quality.d.ts",
|
||||
"node_modules/artplayer/types/setting.d.ts",
|
||||
"node_modules/artplayer/types/subtitle.d.ts",
|
||||
"node_modules/artplayer/types/template.d.ts",
|
||||
"node_modules/artplayer/types/utils.d.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"compiler": "4.3.5",
|
||||
"mode": "node10-commonjs",
|
||||
"diagnostics": [],
|
||||
"declarations": [
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.dom.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.collection.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.core.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.generator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.iterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.proxy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.reflect.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2015.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2016.array.include.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2016.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2017.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2017.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2017.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2017.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2017.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2017.typedarrays.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2018.asyncgenerator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2018.asynciterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2018.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2018.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2018.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2018.regexp.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2019.array.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2019.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2019.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2019.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2019.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.bigint.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es2020.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript-compat/lib/lib.es5.d.ts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.ts",
|
||||
"node_modules/artplayer/types/artplayer.d.ts",
|
||||
"node_modules/artplayer/types/component.d.ts",
|
||||
"node_modules/artplayer/types/config.d.ts",
|
||||
"node_modules/artplayer/types/cssVar.d.ts",
|
||||
"node_modules/artplayer/types/emitter.d.ts",
|
||||
"node_modules/artplayer/types/events.d.ts",
|
||||
"node_modules/artplayer/types/i18n.d.ts",
|
||||
"node_modules/artplayer/types/icons.d.ts",
|
||||
"node_modules/artplayer/types/legacy/language.d.ts",
|
||||
"node_modules/artplayer/types/option.d.ts",
|
||||
"node_modules/artplayer/types/playback.d.ts",
|
||||
"node_modules/artplayer/types/player.d.ts",
|
||||
"node_modules/artplayer/types/plugin.d.ts",
|
||||
"node_modules/artplayer/types/quality.d.ts",
|
||||
"node_modules/artplayer/types/setting.d.ts",
|
||||
"node_modules/artplayer/types/subtitle.d.ts",
|
||||
"node_modules/artplayer/types/template.d.ts",
|
||||
"node_modules/artplayer/types/utils.d.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"compiler": "5.9.3",
|
||||
"mode": "nodenext-esm",
|
||||
"diagnostics": [],
|
||||
"declarations": [
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.decorators.legacy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.dom.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.collection.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.core.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.generator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.iterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.proxy.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.reflect.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.array.include.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2016.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2018.regexp.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.array.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.object.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2019.symbol.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.bigint.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.date.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.intl.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.number.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.promise.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.string.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts",
|
||||
"D:/github/ArtPlayer/node_modules/typescript/lib/lib.es5.d.ts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.cts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.mts",
|
||||
"node_modules/artplayer-plugin-chapter/types/artplayer-plugin-chapter.d.ts",
|
||||
"node_modules/artplayer/types/artplayer.d.cts",
|
||||
"node_modules/artplayer/types/artplayer.d.mts",
|
||||
"node_modules/artplayer/types/artplayer.d.ts",
|
||||
"node_modules/artplayer/types/component.d.ts",
|
||||
"node_modules/artplayer/types/config.d.ts",
|
||||
"node_modules/artplayer/types/cssVar.d.ts",
|
||||
"node_modules/artplayer/types/emitter.d.ts",
|
||||
"node_modules/artplayer/types/events.d.ts",
|
||||
"node_modules/artplayer/types/i18n.d.ts",
|
||||
"node_modules/artplayer/types/icons.d.ts",
|
||||
"node_modules/artplayer/types/language.d.cts",
|
||||
"node_modules/artplayer/types/language.d.mts",
|
||||
"node_modules/artplayer/types/option.d.ts",
|
||||
"node_modules/artplayer/types/playback.d.ts",
|
||||
"node_modules/artplayer/types/player.d.ts",
|
||||
"node_modules/artplayer/types/plugin.d.ts",
|
||||
"node_modules/artplayer/types/quality.d.ts",
|
||||
"node_modules/artplayer/types/setting.d.ts",
|
||||
"node_modules/artplayer/types/subtitle.d.ts",
|
||||
"node_modules/artplayer/types/template.d.ts",
|
||||
"node_modules/artplayer/types/utils.d.ts"
|
||||
]
|
||||
}
|
||||
],
|
||||
"packages": [
|
||||
{
|
||||
"name": "artplayer",
|
||||
"sha256": "6cd924741f139b45ec3c63bbc31a3799d2813655b920ff1484a405745d2a9dd2"
|
||||
},
|
||||
{
|
||||
"name": "artplayer-plugin-chapter",
|
||||
"sha256": "03f55c1cb940d46c7d992f860b8fd2676493070dd905e8a2bc4ba3a5fffe099b"
|
||||
}
|
||||
],
|
||||
"scope": "Initial generated declaration tarball. All declaration and runtime bytes still match; subsequent package documentation edits require a new final tarball."
|
||||
},
|
||||
"accessorProbe": [
|
||||
{
|
||||
"caseName": "accurate",
|
||||
"compiler": "5.9.3",
|
||||
"diagnostics": []
|
||||
},
|
||||
{
|
||||
"caseName": "accurate",
|
||||
"compiler": "4.3.5",
|
||||
"diagnostics": [
|
||||
{
|
||||
"file": "test/types/consumer.ts",
|
||||
"code": 2380,
|
||||
"line": 1,
|
||||
"message": "The return type of a 'get' accessor must be assignable to its 'set' accessor type"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"caseName": "widened",
|
||||
"compiler": "5.9.3",
|
||||
"diagnostics": []
|
||||
},
|
||||
{
|
||||
"caseName": "widened",
|
||||
"compiler": "4.3.5",
|
||||
"diagnostics": []
|
||||
}
|
||||
],
|
||||
"officialAccessorReference": "https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-1.html",
|
||||
"outstanding": [
|
||||
"Precise public entry and declaration strategy for six open CORE-21 risks",
|
||||
"Old plugin and augmentation compatibility with the precise view",
|
||||
"Editor declaration compatibility",
|
||||
"Final package, compiler and applicable browser acceptance",
|
||||
"Completed task commit"
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,97 @@
|
||||
# CORE-21 公开声明生成与兼容视图
|
||||
|
||||
从 ee895a55 接续;CORE-20 已独立提交,开始时工作区干净。下文保留各阶段当时的进展与限制,最终结果见末尾验收章节;阶段快照不替代最终证据。
|
||||
|
||||
## 范围和约束
|
||||
|
||||
既有 default/named、CJS/ESM/legacy/i18n、TS 4.3.5 和模块扩展入口必须继续有效。类型源码、生成的声明和编辑器文件应有明确来源;内部实现路径及测试文件不能进入 npm 声明依赖。CORE-20 的安装包证据固定旧声明,本任务改变包内容后必须重新验收。
|
||||
|
||||
BASE-TYPE-04/05/07/08/09/10 包括同步插件注册、timer 返回、setting 返回、cue 数组、notice、只写命令、template/icons 和 PiP 的历史声明冲突。不能把不相容返回写成交叉类型,不能用运行时包装或增加虚构 getter 迎合错误声明。先保留旧合法消费,再明确准确视图的入口与取舍;本任务完成前不能继续把这些差异推迟而不提供方案。
|
||||
|
||||
## 声明生成第一阶段
|
||||
|
||||
以 packages/artplayer/public/ 作为公开声明的 TypeScript 源。先等价迁移现有定义及 CJS/ESM/语言桥,保留共享身份和扩展位置,由固定 TypeScript 编译器输出至历史 types/ 路径。public/ 不进入发布包;实际实现仍是 src/。这只是生成与兼容基础,不代表这些旧定义已经准确描述全部运行时。
|
||||
|
||||
生成流程必须支持只读检查,禁止以一次自动重写隐藏漂移;错误源、过期产物和意外实现 import 应使检查失败。包构建/打包消费和 CI 接入同一流程;docs 编辑器声明生成需另行核实实际依赖图,不能继续依靠删除 import 后拼接字符串。
|
||||
|
||||
未新增依赖或变更版本,使用固定 Node 24.21.0、Yarn 1.22.22、TypeScript 5.9.3,旧消费者继续用 4.3.5。下一步实现生成器,验证原声明消费者,再逐项完成精确类型策略、包内容及编辑器回归。
|
||||
|
||||
## 生成基础验证
|
||||
|
||||
固定编译器已生成 22 个原路径文件,包含 CJS/ESM 桥及旧语言回退。public/artplayer.ts 使用 ambient class 和 default 标识符导出,维持同一类型身份;CJS 的值、实例别名与 namespace 合并明确保留。编译器会移除普通行注释,生成桥的必要 lint 合并说明由生成器标头提供,不关闭其他文件的规则。
|
||||
|
||||
新增 build:types/check:types;CI 只读验证生成状态,ci:build 与隔离 package 构建先生成。严格类型检查及五组旧消费者通过,CI 448 项通过(418 单元、5 工程、25 基线),229 个生产 TS 文件。生成器负例覆盖缺失/过期产物、错误源不覆盖已有文件、内部实现 import 拒绝和不生成 JS。随后追加 public/src/node_modules 包泄漏负例,两个 package-check 测试及对应 lint 通过。未删除或放宽旧消费者断言。
|
||||
|
||||
run-GY8u71 初次实际安装包通过 29 项运行时与五组类型,public/ 未进入包;此后 README/ARCHITECTURE.md 更新,所以它仅为生成基础阶段证据,不能代替最终包验收。当前没有改变播放器运行时代码。[阶段证据](../baselines/core-declarations-generation.json) 固定声明源、生成文件、脚本、日志和编译器探针;任务保持开放。
|
||||
|
||||
## 访问器约束与下一步
|
||||
|
||||
真实编译器探针确认精确 undefined getter/number setter 在 4.3.5 报 TS2380,而 5.9.3 通过;写入扩大为 number|undefined 才能通过 4.3.5,但会改变类型接受范围。详见 [公共类型出口设计](../core-public-types.md) 及其官方语言依据。下一步优先实现并检验映射到同一 JS 产物的可选精确入口,保留全部旧入口及旧编译器支持。
|
||||
|
||||
目前未实现精确入口,也未完成六项类型差异与编辑器验收;任务保持 doing,未提交完成 commit。生成流程的成功不能作为类型已准确的证明。
|
||||
|
||||
## 精确模块与源码对应检查
|
||||
|
||||
public/runtime/ 已新增九个声明源模块:media、player、utils、plugin、template、subtitle、events、component、setting。它们描述实际只写属性、原生/proxy 结果、PiP、可空模板节点、图标 wrapper、同步/异步注册、timer/def 返回、notice、字幕及设置/控件结果。声明总数现为 31;构造器/包 exports 精确入口尚未接入,不能把这些模块当作已经可用的 artplayer/runtime import。
|
||||
|
||||
新增 runtime-player/utils/subsystems/events/components 类型夹具直接将真实源码属性或对应最小 Host 的子系统赋给公开接口,没有整实例双重断言。检查全部 Player 属性和 Utils 导出覆盖、默认图标名称、输入对象身份、回调 this、Promise 分支及拒绝错误读取。原生默认播放与 canvas/proxy 的结果分别建模。此阶段将模板 container 写为 HTMLElement 的假设不准确,后续已根据真实 DIV 校验纠正,见下文。
|
||||
|
||||
源码 CoreEvents 改为引用生成的精确事件契约,保留旧 Events 的自定义扩展并覆盖已知 builtin 错误。字幕更新数组和 video:error 的 Event、blur 的原事件、seek 的数字/字符串请求值都有正反例。仅模板字面量索引不能满足现有泛型 Host 对具名媒体事件的结构检查,因此显式保留具名原生事件映射;没有改写监听器实现。control/setting 的内部 blur payload 同步为 Event。
|
||||
|
||||
def 的首个严格负例发现标准库的 PropertyDescriptor 与 ThisType 组合仍会接受 primitive;精确视图增加 object 约束,仍由真实 Object.defineProperty 实现赋值证明。没有删除这个负例或用 void/交叉返回隐藏问题。
|
||||
|
||||
## 新增编译器与阶段验收
|
||||
|
||||
新增根 devDependency:typescript-runtime-compat = npm:typescript@5.1.6。它只验证现代精确声明的最低编译器点,不进入任何播放器运行依赖;5.9.3 继续开发/生成,4.3.5 继续旧入口回归。yarn.lock 仅新增该 alias 的五行固定解析与 integrity。首次 add 使用了不必要的 engine/platform/optional 忽略选项,随后已执行正常 frozen install(只跳过生命周期脚本)恢复标准解析,并通过严格工具链检查;这些忽略选项没有进入项目脚本或 CI。
|
||||
|
||||
七模块阶段的 CI 448 项、229 个生产 TS 检查、旧入口五组消费者及精确叶层 5.9.3/5.1.6 各四组解析通过。run-SIkzMV 阶段安装包通过 29 项运行时和五组旧类型,证明当前生成链能打包,不能代表完整精确入口。随后新增 component/setting,正在复验包含九模块的新阶段。旧生成基础和七模块报告保留历史快照,不覆盖它们。
|
||||
|
||||
下一步组装 runtime 构造器、option 与静态/实例门面,处理旧插件工厂接收者、Plugins/Events 扩展、设置回调与最小内部 Host 的关系。当前模块按 Host 参数检查实际子系统;内部最小 Host 并不等于公开回调真的只收到这些字段。对无法直接由结构赋值证明的旧声明边界,必须用明确的兼容输入方案和实际回调身份/消费者验证,不制造假的实例类型关系。全部六项风险和 CORE-21 仍保持开放。
|
||||
|
||||
## 精确构造器与安装包阶段
|
||||
|
||||
新增 runtime.ts/cts/mts 门面及 runtime/services、runtime/option,共 36 个声明文件。精确门面覆盖真实实例和静态成员;缺失/虚构成员分别有 keyof 负向覆盖,服务、存储、config、validator 与非回调配置直接赋值对照源码。static env/build 不在新视图中,存储原始 JSON 为 unknown,config 数组保持可变;字幕保留实际继承的 Component 成员并覆盖不同 update 返回。
|
||||
|
||||
artplayer/runtime 和 artplayer/runtime/legacy 的 JS 条件出口分别指向现有 modern/legacy 文件,runtime/types 为共享扩展入口。CJS 构造器值/实例/namespace 和 ESM 类型共享定义;旧入口不引入现代访问器语法。新旧插件/事件模块扩展均有正负例,旧 factory 通过明确输入重载接入,内联 add 回调推断完整实例;没有伪造新实例可赋给错误旧返回视图的关系。
|
||||
|
||||
浏览器专项纠正了三个初始测试假设:构造工厂运行时 plugins 尚未赋值;controls.add 缺少 position 会抛错;pause 会再显示提示,因此 notice 隐藏状态要在 pause 前取样。前两项同时改进精确声明:PluginFactory 的 PluginHost 将 plugins 标为可选,Controls.add/OptionInput.controls 使用要求 top/left/right 的 ControlInput。加入相应类型负例,旧根声明不收窄,运行时不改。其余 proxy/层/控件/设置构造回调的阶段宿主还需审查,不能宣布整个初始化类型已经精确。
|
||||
|
||||
初次入口 run-j7FG9r 为中间快照;当前 run-heewv5 的真实 tarball 通过 34 项运行时、五组旧类型、八组精确类型(5.1.6/5.9.3 各四模式)。旧 4.3.5 消费者继续通过,实际解析全部限制在临时安装目录与编译器标准库内。验证 CJS/ESM/legacy 新旧入口模块、构造器和实例集合身份相同,type-only 入口不能在运行时导入;public 源不泄漏,36 个声明与包内字节对应。
|
||||
|
||||
当前 CI 448 项、229 个生产 TS 检查通过;新增 UMD 与 legacy 安装产物专项各在 Chromium/Firefox/WebKit 通过,使用真实媒体 ready 和已发布 chapter 工厂,核对 this/参数、保留 option 工厂身份、同步/异步注册、只写读取、控件/设置/字幕/notice 和不存在的字段。三个运行时产物 SHA 与 CORE-20 一致;历史全量浏览器证据只按相同字节引用,不冒充本轮重新全量运行。[阶段证据](../baselines/runtime-entry-partial.json) 固定当前源、工具、生成声明、包文件、类型结果和浏览器摘要。
|
||||
|
||||
build:ts 排除了新增 runtime 根声明,避免把第二份门面拼入历史全局编辑器;该旧字符串拼接器的完整语义与生成流程仍未验收。下一步继续构造回调宿主和编辑器,六项类型风险与任务保持 doing;本轮没有完成任务 commit,也没有 push/publish/tag/merge。
|
||||
|
||||
## 构造阶段回调与编辑器生成
|
||||
|
||||
新增 public/runtime/construction.ts,声明总数 37。proxy 仅暴露已初始化的基础字段和 Emitter,不暴露尚不可用的 template/video/query/proxy getter。layers、controls、contextmenu 的构造输入回调按当时赋值顺序标记未来子系统可选;PluginHost 的 plugins 可选。直接组合 Player 而非对其做 Omit/Pick,避免映射类型丢失独立读写访问器。runtime-construction.ts 在工作区和真实安装消费者中检查这些边界及 seek 写入。
|
||||
|
||||
读取 urlMix 和 setting 调度实现后确认,customType 在 await wait 后执行,setting mounted 经过定时调度,二者接收完整实例。浏览器同时检查冻结发布包和候选的阶段字段及接收者身份。模板明确只接受 DIV,故修正精确 OptionInput/container 与 template.$container 的 HTMLElement 假设;非法 section 和配置 proxy 返回 undefined 均有反例。旧类型入口接受范围和运行时构造顺序保持。
|
||||
|
||||
核心 build:ts 不再剥离 import 后拼接声明。新增 scripts/editor-types.mjs 与 tsconfig.editor.json,以 dts-bundle-generator 9.5.1 读取旧 public/artplayer.ts 依赖图,再由 TypeScript AST 生成私有 ArtplayerDefinitions 命名空间及 Artplayer 构造器/实例/命名别名。直接打包 CJS 桥的早期探针产生自引用别名,因此未采用该输出;独立语义检查拒绝别名损坏、外部依赖、私有全局泄漏及错误泛型。TS 4.3.5 和 5.9.3 都检查,不使用 skipLibCheck。原插件编辑器输出未改变,SITE-02 仍负责全站/插件生成器改造。
|
||||
|
||||
新增根 devDependency dts-bundle-generator@9.5.1。它的 TypeScript 范围首次解析到 7.0.2;随即增加 dts-bundle-generator/typescript=5.9.3 的 Yarn resolution,正常安装去掉该临时图,生成器同时核对实际编译器身份。最终 frozen install --ignore-scripts --non-interactive 和严格工具链通过:Node 24.21.0、Yarn 1.22.22、22 workspaces、23 pinned tools、1343 dependency selectors。依赖不进入播放器运行包,编译器点继续为旧 4.3.5、精确最低 5.1.6、生成/当前 5.9.3。
|
||||
|
||||
新增 editor-types 工程用例:生成输出漂移检查、独立编译、损坏声明必须报错。新增真实 Monaco worker 用例:加载 vendored editor、编译生成声明和有效/无效代码、执行编译后的播放器并等待真实媒体 ready。构造/返回/Monaco 共 18 项三浏览器专项已通过,其阶段报告使用此前安装的运行时产物,不作为最新包内容的最终证据。
|
||||
|
||||
最新 runtime-public.ts 的安装消费者进一步检查 PiP 的 Element|null|boolean 读取与 boolean 写入、图标元素/可空节点、setting 对象身份/void、字幕 style 元素、def 目标身份、debounce/throttle 的 void 返回;正反例均在 5.1.6/5.9.3 各四模式运行。完整 CI 已通过 449 项(418 单元、6 工程、25 基线),229 个生产 TS 文件,37 个生成声明无漂移。最终包与全量浏览器验收继续执行。
|
||||
|
||||
## 最终验收与交接
|
||||
|
||||
CORE-21 完成。公开接口按实际职责拆为历史兼容源、精确媒体/播放器/组件/服务模块、构造阶段宿主和 CJS/ESM 桥;内部实现保持独立,不泄漏至 npm 声明图。新增运行时入口共享既有 JS 构造器;旧入口、TS 4.3.5、语言及旧插件接受范围保留。包内 ARCHITECTURE.md 与类型维护文档已同步实际实现,旧段落中的待 CORE-21 表述已清理。
|
||||
|
||||
| 验收项 | 已取得证据 |
|
||||
| --- | --- |
|
||||
| 严格检查 | CI 449 项,229 个生产 TS 文件,37 个生成声明无漂移;新增类型/浏览器夹具另行显式 lint 通过 |
|
||||
| 安装消费 | 最终 run-LYDR8W:34 项运行时、五组旧类型、八组精确类型,零诊断;public/src/node_modules 不泄漏 |
|
||||
| 浏览器 | UMD 1521 项、legacy 1521 项;各含 18 项构造/返回/编辑器检查,无失败、重试或跳过 |
|
||||
| 实际环境 | Windows Chromium 153.0.8010.12、Firefox 155.0、WebKit 26.6;使用真实媒体与已安装包 |
|
||||
| 产物对应 | 三个核心 JS 与 CORE-20 字节一致;最后打包仅更新 ARCHITECTURE.md、types/README.md、types/COMPATIBILITY.md,JS/类型与浏览器使用的 run-y0PLWJ 完全一致 |
|
||||
| 编辑器 | TS 4.3.5/5.9.3 独立语义、生成漂移负例、真实 Monaco worker 编译并运行类型示例;vendored 资源指纹保留 |
|
||||
| 依赖复现 | Yarn frozen 安装、严格工具链、开发 bundler 的 TypeScript resolution 与实际加载身份检查通过 |
|
||||
|
||||
[最终验收证据](../baselines/core-declarations-validation.json) 保存全部源/声明/工具指纹、完整包文件、类型解析图、每个浏览器用例与报告指纹,以及文档重打包的差异。此前生成基础和 36 文件阶段 JSON 保持历史原样。
|
||||
|
||||
关闭 BASE-TYPE-04/05/07/08/09/10:实际类型使用可选 runtime 入口,历史入口保留既有接受范围;没有引入虚假交叉返回、运行时 Promise 包装或不存在的 getter。浏览器受控能力测试不等于物理 Apple/AirPlay/触摸/IME 认证,BASE-ENV-01 与 REL-03/REVIEW-02 门槛继续保留。全站及插件编辑器现代化由 SITE-02 负责,其余生态包、CORE-23 和 CORE-22 尚未完成。
|
||||
|
||||
本任务独立本地提交,包含实现、测试、文档、风险和任务状态;无 push/publish/tag/merge。回退时以 CORE-20 的 ee895a55 为父状态,对本任务 commit 做整体 revert,避免只回退生成声明而留下 manifest/编辑器/消费脚本不一致。下一步 CORE-23 键盘、焦点和可访问名称,随后 CORE-22 核心完整验收。
|
||||
@@ -0,0 +1,52 @@
|
||||
# CORE-21 公共类型出口设计
|
||||
|
||||
本页记录 CORE-21 的类型出口方案及验证过程。生成声明、安装消费和核心编辑器已验收;尚未发布 npm。最终结果见 [验收证据](baselines/core-declarations-validation.json)。
|
||||
|
||||
## 已验证的约束
|
||||
|
||||
根入口历史声明必须继续接受 test/types/declaration-legacy.ts 的旧消费者,包括已知不准确的 Promise/void、setting 返回及只写属性读取。替换这些返回会破坏已有 TS 代码;在原签名上增加一个虚假的交叉类型也不能解决实际值不同的问题。
|
||||
|
||||
固定编译器探针进一步确认:同一个属性声明为 `get seek(): undefined`、`set seek(value: number)`,TS 5.9.3 通过,4.3.5 报 TS2380。把 setter 扩成 `number | undefined` 虽可通过旧编译器,却额外允许并非原声明接受的写入;不能为了让编译器通过而机械扩宽所有命令输入。探针见本任务阶段证据。
|
||||
|
||||
[TypeScript 5.1 发布说明](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-1.html) 明确从该版本起允许显式注解的读写访问器使用不相关类型。这个语言限制与 ArtPlayer 的 JS 行为无关,不应通过制造运行时 getter 来处理。
|
||||
|
||||
## 已实施方案与验证要求
|
||||
|
||||
保留现有 `artplayer`、`artplayer/legacy`、`artplayer/types` 与语言入口的历史类型接受范围和 TS 4.3.5 验证。可选择的精确声明入口 `artplayer/runtime` 映射到同一已有 JS 构造器产物:它只改变所选类型视图,不创建第二个播放器、包装实例或重跑全局初始化。独立读写访问器需要 TS 5.1 语言特性,实际最低验证点为 5.1.6,当前编译器为 5.9.3。
|
||||
|
||||
旧入口不能引用新的现代声明,否则旧编译器仍会被迫解析它。也不能在旧根入口导出一个间接引用现代声明的类型别名。新入口与旧入口的构造器及实例运行时身份需要安装包内的 CJS/ESM/legacy 对照证明;用户继续使用旧 import 时无需改动。
|
||||
|
||||
精确公开声明仍从 public/ 的 TypeScript 源生成,不能直接发布 src/ 的整个内部图。通过源类型夹具逐项检查实际实现和公开视图的对应关系,尤其注意 getter/setter、可空节点、media-like proxy、插件工厂 this 和返回、事件泛型及链式 this;不能用整个实例双重断言当对应证明。
|
||||
|
||||
本任务逐项实现并留证的边界:
|
||||
|
||||
- 插件注册同步/Promise 分支与旧插件工厂接收者:保持原注册身份,验证旧插件可接入及新内联回调有正确上下文推断。
|
||||
- toggle、timer、def、setting/subtitle/notice:分别提供实际结果,旧入口的历史错误仍明确记录,不假装已变成正确返回。
|
||||
- seek/forward/backward/switch/quality:精确入口读为 undefined,写入仍按对应运行时参数建模;拒绝仅为满足旧 TS 关系而扩宽。
|
||||
- template/icons、PiP、fullscreen、URL、option 与 static:区分真实能力、可空结果、可变配置和不存在的旧声明字段,不把初始化时的默认形状当永远成立。
|
||||
- 新入口的 Events/Plugins 扩展要到达正确共享定义;旧 `artplayer/types` 的扩展能力继续回归。
|
||||
- 新声明、旧声明、文档编辑器与 npm 路径保持明确依赖关系。SITE-02 负责整个编辑器/示例生成器现代化,但本任务引入的声明布局不能破坏当前 build:ts 或编辑器消费。
|
||||
|
||||
旧插件输入重载、新旧扩展关系、真实返回和安装入口身份已分别验证。六项类型风险按最终证据关闭;旧入口历史错误接受范围是明确的兼容保留,不宣称旧声明因此变得准确。
|
||||
|
||||
## 构造器入口阶段记录(36 文件快照)
|
||||
|
||||
public/runtime.ts 组合 11 个精确叶模块,生成总数为 36 个声明文件。新增 artplayer/runtime 与 artplayer/runtime/legacy 的条件类型出口,分别重用已有 modern 与 legacy JS;artplayer/runtime/types 为共享扩展入口。CJS 桥使用 export =,ESM 桥共享类型定义,不新增运行时导出。
|
||||
|
||||
首轮真实 tarball run-j7FG9r 通过 34 项运行时、五组旧类型、八组精确类型检查(5.1.6/5.9.3 各四模式),包括 require/import/legacy 模块对象和构造器身份相同。后续新增 PluginHost、ControlInput,最终证据需重新生成,不能把初次 tarball 当当前声明验收。旧工厂有显式接收重载;旧 Plugins 已声明结果和 Events 自定义载荷传递至新共享接口,内联 add 回调保持精确推断。
|
||||
|
||||
浏览器专项先暴露测试错误假设:构造插件工厂运行时 art.plugins 尚未赋值;新 PluginFactory 改用 plugins 可选的 PluginHost,并加入负例。add 的内联工厂仍接收完整 Artplayer。控件 add 的 position 在运行时必填,ControlInput 现要求 top/left/right;更新已有条目仍可沿用原位置。另一个测试顺序问题是 pause 会更新 notice,验证隐藏状态必须在 pause 前取值,不能把后续提示当 getter 错误。
|
||||
|
||||
下一步继续审查 proxy、层、控件和设置在构造期间执行的回调宿主,区分当时已赋值的子系统;完成编辑器生成/语义消费与最终浏览器复验后才考虑关闭风险。build:ts 已避免把新 runtime 根声明拼入旧编辑器,但现有字符串拼接器和编辑器完整语义仍未验收。
|
||||
|
||||
## 构造阶段与编辑器实现(当前 37 文件)
|
||||
|
||||
新增 runtime/construction.ts,按实际构造顺序描述 ProxyHost、LayerHost、ControlHost、ContextmenuHost 和 PluginHost。proxy 执行时 template 尚未赋值,不能暴露依赖 template/events 的 getter;组件 mounted 执行时未来子系统可选;构造插件执行时 plugins 可选。公开实例的身份不变,类型描述当时可用的字段。Player 必须直接继承,不能经过 Omit/Pick 映射后丢失独立 getter/setter 写入类型。
|
||||
|
||||
customType 在 url setter 的 await wait 后执行,setting mounted 也经过延迟调度,二者收到完整宿主;不能误认为它们在构造中同步运行。真实发布包与候选的浏览器快照分别核对字段可用性和接收者身份。容器运行时明确验证 DIV,精确输入和 template.$container 改为 HTMLDivElement;旧入口保持原接受范围。此前阶段记录中的 HTMLElement 假设已由源码及浏览器反例纠正。
|
||||
|
||||
核心编辑器生成改用 dts-bundle-generator 9.5.1 解析旧 public/artplayer.ts 依赖图,并用 TypeScript AST 构造私有定义命名空间和 Artplayer 全局/UMD 别名。拒绝未解析 import/export、重复/未知声明;生成结果同时经过 TS 4.3.5/5.9.3 的独立语义消费,不能解析回工作区。负例验证错误别名确实报错,私有定义不泄漏全局,泛型/构造器及命名类型仍有效。生成漂移纳入 test:node。
|
||||
|
||||
新增依赖只属于根开发工具;Yarn resolution 将 bundler 的 TypeScript 固定为已有 5.9.3,生成器核实实际加载同一编译器。固定工具链与正常 frozen install 已通过。docs Monaco 的真实 worker 编译生成声明、报告非法输入,再执行编译后的播放器示例并等待真实媒体 ready。插件编辑器生成仍保留原流程,整体 SITE-02 改造另行验收。
|
||||
|
||||
构造/精确返回与 Monaco 专项共 18 项三浏览器通过,并纳入最终 UMD/legacy 各 1521 项全量回归。CI 449 项、229 个生产 TS 文件、37 个声明生成检查通过;最终 run-LYDR8W 的 34 项运行时、五组旧类型、八组精确类型全部通过。浏览器使用 run-y0PLWJ 的安装字节,最后一次重打包仅修改三个 Markdown 文档;全量文件对照证明 JS/类型完全一致,两个包及声明源/脚本/Monaco 指纹均保存在最终证据中。
|
||||
+3
-2
@@ -4,7 +4,7 @@
|
||||
|
||||
基线:`40fcda6a37d0049d42e49c1e64e70d4fd9ba5f7f`。总任务 214 项,范围 22 个包及工作区/示例。
|
||||
|
||||
状态:todo 158 / doing 0 / blocked 0 / done 56 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。
|
||||
状态:todo 157 / doing 0 / blocked 0 / done 57 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。
|
||||
|
||||
前置依赖是启动条件;验收是完成条件。任务可以继续拆分,但不能复用或悄悄删除旧 ID。
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
| CORE-18 | artplayer<br>迁移内置插件和提示模块 | CORE-14, CORE-16, CORE-17 | autoPlayback/autoOrientation/fastForward/lock/miniProgressBar 及 info/notice/loading/mask | 默认启用条件、storage 格式、定时器/动画清理通过;结合 BASE-PERF-01 防止销毁后重新安排 notice timer;接续 BASE-TYPE-07 的 notice.show boolean getter 与历史读类型冲突 | M | done |
|
||||
| CORE-19 | artplayer<br>整理进度、质量、缩略图和截图 | CORE-10, CORE-13, CORE-16 | 相关 player/control 功能与纯计算分离 | 截图跨域失败、缩略图布局、quality/进度边界保持 | M | done |
|
||||
| CORE-20 | artplayer<br>收敛核心入口与依赖方向 | CORE-14, CORE-15, CORE-18, CORE-19 | Artplayer 门面、初始化依赖与最终目录 | 所有核心自有源码迁移,公开描述符/静态接口/事件差分通过 | H | done |
|
||||
| CORE-21 | artplayer<br>生成核心声明并校验包内容 | CORE-20, ENG-07 | 由 TS 生成的既有入口声明与三种发布产物 | 内部类型不泄漏,旧 JS/TS 消费者与 i18n 通过;逐项完成 CORE-07 留下的 BASE-TYPE-04/05/07 声明方案,旧合法消费者与实际返回分别留证;不能以虚假的交叉返回类型或改变运行时来掩盖冲突,未决项阻止核心声明出口;处理 CORE-10 / BASE-TYPE-08 的 setter-only 属性虚构 getter 声明,并复核 PlaybackControls 精确视图与旧 toggle 声明共存策略 | H | todo |
|
||||
| CORE-21 | artplayer<br>生成核心声明并校验包内容 | CORE-20, ENG-07 | 由 TS 生成的既有入口声明与三种发布产物 | 内部类型不泄漏,旧 JS/TS 消费者与 i18n 通过;逐项完成 CORE-07 留下的 BASE-TYPE-04/05/07 声明方案,旧合法消费者与实际返回分别留证;不能以虚假的交叉返回类型或改变运行时来掩盖冲突,未决项阻止核心声明出口;处理 CORE-10 / BASE-TYPE-08 的 setter-only 属性虚构 getter 声明,并复核 PlaybackControls 精确视图与旧 toggle 声明共存策略 | H | done |
|
||||
| CORE-23 | artplayer<br>检查并补齐键盘、焦点与可访问名称 | CORE-13, CORE-14, CORE-17, ENG-05, BASE-04 | 主要控件/设置/模式退出的键盘与焦点回归、名称和字幕可用性检查及必要兼容修正 | 保持旧快捷键和 DOM/CSS 钩子;真实浏览器验证,不以静态属性检查代替交互;处理 BASE-DOM-01 的主要控件 Tab 不可达,保留既有名称与快捷键 | H | todo |
|
||||
| CORE-22 | artplayer<br>核心阶段完整验收 | CORE-21, CORE-23, PILOT-01, ENG-08, ENG-10 | 核心与旧插件的可自动化完整回归、资源/性能及明确外部验证缺口 | 核心自动化和公开差异处置通过;真实环境缺口链接包集成/REL 门槛,阶段完成不代表可公开发布 | H | todo |
|
||||
|
||||
@@ -455,6 +455,7 @@
|
||||
- CORE-18: [记录](changes/2026-09-11-CORE-18-builtins-prompts.md) [记录](baselines/builtins-prompts-validation.json)
|
||||
- CORE-19: [记录](changes/2026-09-11-CORE-19-capture-thumbnails.md) [记录](baselines/capture-progress-validation.json)
|
||||
- CORE-20: [记录](changes/2026-09-11-CORE-20-entry.md) [记录](baselines/entry-validation.json)
|
||||
- CORE-21: [记录](changes/2026-09-11-CORE-21-public-declarations.md) [记录](baselines/core-declarations-validation.json) [记录](core-public-types.md) [记录](typechecking.md)
|
||||
- PKG-CHAPTER-01: [记录](changes/2026-09-10-PKG-CHAPTER-01-contract.md) [记录](baselines/chapter-contract.md)
|
||||
- PKG-CHAPTER-02: [记录](changes/2026-09-10-PKG-CHAPTER-02-tests.md) [记录](baselines/chapter-validation.json)
|
||||
- PKG-CHAPTER-03: [记录](changes/2026-09-10-PKG-CHAPTER-03-typescript-modules.md) [记录](baselines/chapter-migration-validation.json)
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# 进度与证据
|
||||
|
||||
## 当前实施:CORE-21 公开声明生成与兼容视图完成
|
||||
|
||||
从 ee895a55 接续。公开声明源移至 packages/artplayer/public/,生成 37 个声明文件:22 个历史文件与精确模块/入口。新增 artplayer/runtime、runtime/legacy 和共享类型扩展入口,映射原有 JS 产物;build:types/check:types 已接入 CI 和隔离构建。旧入口继续支持 4.3.5,新精确入口验证 5.1.6/5.9.3 各四模式。核心自有源码 TS 迁移已在 CORE-20 完成,本任务完成公开类型出口与核心编辑器验收。
|
||||
|
||||
CI 449 项、229 个生产 TS 检查、37 个生成声明无漂移通过。最终隔离安装 run-LYDR8W 通过 34 项运行时、五组旧类型和八组精确类型;CJS/ESM/legacy 入口身份相同。UMD 与 legacy 各 1521 项三浏览器检查通过,各含 18 项构造/返回/Monaco 专项。浏览器使用 run-y0PLWJ 的实际安装字节,最后打包仅修改三个 Markdown 文档,JS/声明逐文件一致;三个核心 JS 与 CORE-20 字节一致。见 [最终证据](baselines/core-declarations-validation.json),先前阶段快照保持历史原样。
|
||||
|
||||
已完成 proxy/组件/插件构造阶段宿主,并纠正 DIV 容器及 customType 延迟执行的假设。核心编辑器使用依赖图打包和 AST 全局桥,独立 TS 4.3.5/5.9.3 语义检查及真实 Monaco worker 运行通过;冻结 Yarn 安装与严格工具链通过。关闭 BASE-TYPE-04/05/07/08/09/10,保留旧入口历史类型接受范围。214 项:57 done、157 todo,下一步 CORE-23 键盘/焦点/名称,然后 CORE-22 核心完整验收。详见 [设计](core-public-types.md) 与 [实施记录](changes/2026-09-11-CORE-21-public-declarations.md)。本任务独立本地提交,无推送或发布;真机门槛、其余生态包和多轮复盘仍待完成。
|
||||
|
||||
## 当前实施:CORE-20 核心入口与依赖收敛完成
|
||||
|
||||
核心全部 224 个自有源文件已迁移 TS,唯一 JS 为登记第三方 libs/screenfull.js。拆清入口、浏览器 bootstrap、DOM 叶层、实际属性/事件与初始化依赖;保持公开形状及顺序,修复构造/配置/AirPlay 销毁后继续安装和 proxy 挂载清理。
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
| BASE-TYPE-01 | resolved / 已复现 | NodeNext ESM 默认导出与声明互操作失配 | ENG-04, CORE-07, PKG-CHAPTER-04 |
|
||||
| BASE-TYPE-02 | resolved / 已复现 | chapter 可选运行时参数被声明为必填 | PKG-CHAPTER-02 |
|
||||
| BASE-TYPE-03 | resolved / 已复现 | chapter legacy 缺旧模块解析的声明回退 | ENG-04, PKG-CHAPTER-04 |
|
||||
| BASE-TYPE-04 | open / 已复现 | plugins.add / toggle 的旧声明返回值与运行时不同 | CORE-07, CORE-08, CORE-10, CORE-21 |
|
||||
| BASE-TYPE-04 | resolved / 已复现 | plugins.add / toggle 的旧声明返回值与运行时不同 | CORE-07, CORE-08, CORE-10, CORE-21 |
|
||||
| BASE-DIST-01 | open / 源码/产物事实 | thumbnail tool 分发入口与类型文件缺失 | PKG-TOOL-THUMB-01, PKG-TOOL-THUMB-04 |
|
||||
| BASE-PERF-01 | resolved / 已复现 | 销毁后的 resize 防抖重新创建 notice timer | CORE-17, CORE-04, CORE-18 |
|
||||
| BASE-SOURCE-01 | open / 源码/产物事实 | 工作区 5.4.1 与采集时真实发布 5.4.0 不同 | BASE-08, REL-01 |
|
||||
@@ -46,16 +46,16 @@
|
||||
| BUILD-AMD-01 | resolved / 已复现 | AMD 全局导出补丁误将固定参数 t 当作全局对象 | ENG-06 |
|
||||
| UTIL-MERGE-01 | resolved / 已复现 | mergeDeep lets a JSON __proto__ key replace the result prototype | CORE-01 |
|
||||
| UTIL-DOWNLOAD-01 | resolved / 源码/产物事实 | Temporary download anchor remains if click throws | CORE-01 |
|
||||
| BASE-TYPE-05 | open / 源码/产物事实 | Public Utils declarations omit exports and misstate timer/descriptor signatures | CORE-07, CORE-21 |
|
||||
| BASE-TYPE-05 | resolved / 源码/产物事实 | Public Utils declarations omit exports and misstate timer/descriptor signatures | CORE-07, CORE-21 |
|
||||
| EVENT-NAME-01 | resolved / 已复现 | Emitter event names collide with Object.prototype | CORE-02 |
|
||||
| EVENT-ONCE-01 | resolved / 已复现 | Nested dispatch snapshots invoke the same once registration twice | CORE-02 |
|
||||
| BASE-TYPE-06 | resolved / 已复现 | Public Option requires url and excludes numeric control HTML accepted by existing JS | CORE-07 |
|
||||
| BASE-TYPE-07 | open / 已复现 | Setting returns, subtitle contextual payloads and notice getter conflict with historical declarations | CORE-07, CORE-14, CORE-15, CORE-18, CORE-21 |
|
||||
| BASE-TYPE-08 | open / 已复现 | Write-only player commands have fictitious public getter declarations | CORE-21 |
|
||||
| BASE-TYPE-07 | resolved / 已复现 | Setting returns, subtitle contextual payloads and notice getter conflict with historical declarations | CORE-07, CORE-14, CORE-15, CORE-18, CORE-21 |
|
||||
| BASE-TYPE-08 | resolved / 已复现 | Write-only player commands have fictitious public getter declarations | CORE-21 |
|
||||
| BASE-LIFE-07 | resolved / 已复现 | Queued reconnect survives source replacement and reloads the new resource | CORE-11 |
|
||||
| BASE-LIFE-08 | resolved / 已复现 | Ready continues after a control callback destroys the instance | CORE-11 |
|
||||
| BASE-I18N-01 | resolved / 已复现 | Missing prototype-named translations return inherited functions | CORE-12 |
|
||||
| BASE-TYPE-09 | open / 源码/产物事实 | Template and icon declarations claim incompatible DOM and static shapes | CORE-21 |
|
||||
| BASE-TYPE-09 | resolved / 源码/产物事实 | Template and icon declarations claim incompatible DOM and static shapes | CORE-21 |
|
||||
| BASE-LIFE-09 | resolved / 已复现 | Removed builtin controls retain subscriptions and progress drag effects | CORE-13 |
|
||||
| BASE-LIFE-10 | resolved / 已复现 | Component mounting and removal failures leave partial entries or recurse | CORE-13 |
|
||||
| BASE-LIFE-11 | resolved / 已复现 | Selector failures are unhandled and obsolete completion overwrites current UI | CORE-13 |
|
||||
@@ -78,7 +78,7 @@
|
||||
| BASE-LIFE-19 | resolved / 已复现 | Video-only fullscreen survives player destruction and late entry | CORE-16 |
|
||||
| BASE-DOM-12 | resolved / 已复现 | PiP reports another video as active and WebKit ignores native presentation transitions | CORE-16 |
|
||||
| BASE-LIFE-20 | resolved / 已复现 | PiP survives destruction or late entry and rejected assignments become unhandled | CORE-16 |
|
||||
| BASE-TYPE-10 | open / 已复现 | PiP getter is declared boolean but native runtime returns an element or null | CORE-16, CORE-21 |
|
||||
| BASE-TYPE-10 | resolved / 已复现 | PiP getter is declared boolean but native runtime returns an element or null | CORE-16, CORE-21 |
|
||||
| BASE-DOM-13 | resolved / 已复现 | Mini exit loses the video's original parent and sibling position | CORE-16 |
|
||||
| BASE-LIFE-21 | resolved / 已复现 | Mini leaves a connected popup after player destruction | CORE-16 |
|
||||
| BASE-DOM-14 | resolved / 已复现 | Unready media sizing partially overwrites layout and emits NaN height | CORE-16 |
|
||||
|
||||
+56
-14
@@ -276,7 +276,7 @@
|
||||
"id": "BASE-TYPE-04",
|
||||
"title": "plugins.add / toggle 的旧声明返回值与运行时不同",
|
||||
"confirmation": "reproduced",
|
||||
"status": "open",
|
||||
"status": "resolved",
|
||||
"owners": [
|
||||
"CORE-07",
|
||||
"CORE-08",
|
||||
@@ -293,8 +293,15 @@
|
||||
],
|
||||
"compatibleResolution": "保留旧声明接受范围并协调精确重载/扩展,不静默把同步注册改成 async。",
|
||||
"closureCriteria": "返回值类型与运行时差异逐项说明,旧合法消费和拒绝传播回归通过。",
|
||||
"scopeNote": "CORE-07 retains historical legal return assignments and records actual runtime separately; incompatible return tightening remains open through CORE-21. No release waiver.",
|
||||
"playbackResolution": "CORE-10 adds assignable PlaybackControls with Promise<void> | void toggle; legacy root void remains accepted. All five installed type modes pass. The overall facade and plugins.add conflict stay open through CORE-21."
|
||||
"scopeNote": "Historical root inaccuracies remain intentional compatibility behavior; the optional runtime entry provides the accurate alternative validated by CORE-21.",
|
||||
"playbackResolution": "Both the existing PlaybackControls view and the new runtime entry expose accurate playback results; old root acceptance remains unchanged.",
|
||||
"resolutionRationale": "The optional runtime entry models sync registration as the original registry, Promise registration as Promise<registry>, and toggle as the actual play/pause result. Old root returns remain accepted. Installed module/constructor identity, old factories, rejection tests and all five legacy/eight precise consumer modes pass without runtime wrappers.",
|
||||
"resolutionEvidence": [
|
||||
"refactor/baselines/core-declarations-validation.json",
|
||||
"refactor/changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"packages/artplayer/types/COMPATIBILITY.md",
|
||||
"test/types/runtime-public.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "BASE-DIST-01",
|
||||
@@ -791,7 +798,7 @@
|
||||
"id": "BASE-TYPE-05",
|
||||
"title": "Public Utils declarations omit exports and misstate timer/descriptor signatures",
|
||||
"confirmation": "source-observed",
|
||||
"status": "open",
|
||||
"status": "resolved",
|
||||
"owners": [
|
||||
"CORE-07",
|
||||
"CORE-21"
|
||||
@@ -807,7 +814,14 @@
|
||||
],
|
||||
"compatibleResolution": "Coordinate compatible public overloads/exports separately; use accurate strict types in migrated source.",
|
||||
"closureCriteria": "Cover missing unescape/ArtPlayerError, def identity/property keys, optional sleep, timer void returns and ignored debounce context; retain legal old consumers in new/old compilers.",
|
||||
"scopeNote": "CORE-07 retains historical legal return assignments and records actual runtime separately; incompatible return tightening remains open through CORE-21. No release waiver."
|
||||
"scopeNote": "Historical root inaccuracies remain intentional compatibility behavior; the optional runtime entry provides the accurate alternative validated by CORE-21.",
|
||||
"resolutionRationale": "Generated runtime Utils covers actual exports, object/PropertyKey def target identity, optional sleep, timer void results and preserved receivers with ignored debounce context documented. Source correspondence, installed positive/negative consumers and real utility behavior pass; historical root signatures remain accepted.",
|
||||
"resolutionEvidence": [
|
||||
"refactor/baselines/core-declarations-validation.json",
|
||||
"refactor/changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"packages/artplayer/types/COMPATIBILITY.md",
|
||||
"test/types/runtime-public.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "EVENT-NAME-01",
|
||||
@@ -883,7 +897,7 @@
|
||||
"id": "BASE-TYPE-07",
|
||||
"title": "Setting returns, subtitle contextual payloads and notice getter conflict with historical declarations",
|
||||
"confirmation": "reproduced",
|
||||
"status": "open",
|
||||
"status": "resolved",
|
||||
"owners": [
|
||||
"CORE-07",
|
||||
"CORE-14",
|
||||
@@ -900,14 +914,21 @@
|
||||
],
|
||||
"compatibleResolution": "Keep legacy consumers; add explicit cue-array listener overloads, type internal implementations accurately, and resolve remaining generated/public facade contracts at CORE-21 without false intersections.",
|
||||
"closureCriteria": "Actual setting/null/void and notice boolean returns, cue array callbacks and old legal type consumers all have an explicit compatible declaration strategy and package tests.",
|
||||
"scopeNote": "CORE-07 provides runtime evidence and explicit cue-array overloads; old inferred scalar event callbacks and return signatures are not claimed corrected.",
|
||||
"workspaceState": "CORE-14 source models item/null/void setting returns; CORE-15 source models cue arrays and string/null/undefined subtitle results. Historical public consumers and explicit array listener overloads still compile; scalar inference and public return facade coordination remain CORE-18/21. CORE-18 notice.ts now models a boolean getter and string/Error/false writes; source and retained public consumer fixtures are in test/types/notice.ts. Public precise-view coordination remains CORE-21."
|
||||
"scopeNote": "Historical root inaccuracies remain intentional compatibility behavior; the optional runtime entry provides the accurate alternative validated by CORE-21.",
|
||||
"workspaceState": "Generated runtime Setting/Subtitle/Notice expose item/null/void, cue-array contextual payloads and boolean notice reads independently from message writes. Installed consumers and real browser callbacks/returns pass. The historical root retains its old inference/returns and explicit array overloads rather than using false intersections.",
|
||||
"resolutionRationale": "Generated runtime Setting/Subtitle/Notice expose item/null/void, cue-array contextual payloads and boolean notice reads independently from message writes. Installed consumers and real browser callbacks/returns pass. The historical root retains its old inference/returns and explicit array overloads rather than using false intersections.",
|
||||
"resolutionEvidence": [
|
||||
"refactor/baselines/core-declarations-validation.json",
|
||||
"refactor/changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"packages/artplayer/types/COMPATIBILITY.md",
|
||||
"test/types/runtime-public.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "BASE-TYPE-08",
|
||||
"title": "Write-only player commands have fictitious public getter declarations",
|
||||
"confirmation": "reproduced",
|
||||
"status": "open",
|
||||
"status": "resolved",
|
||||
"owners": [
|
||||
"CORE-21"
|
||||
],
|
||||
@@ -920,7 +941,14 @@
|
||||
"test/types/declaration-legacy.ts"
|
||||
],
|
||||
"compatibleResolution": "Keep historical consumer acceptance, model source command reads as undefined, and provide an accurate public facade without inventing runtime getters.",
|
||||
"closureCriteria": "seek/forward/backward/switch/quality reads and writes have an explicit accurate compatibility strategy validated against old TypeScript consumers and real package descriptors."
|
||||
"closureCriteria": "seek/forward/backward/switch/quality reads and writes have an explicit accurate compatibility strategy validated against old TypeScript consumers and real package descriptors.",
|
||||
"resolutionRationale": "The optional runtime entry exposes undefined reads and the actual write types for seek/forward/backward/switch/quality; TS 5.1.6/5.9.3 consumers verify independent accessors. Published/candidate descriptors and reads pass; historical TS 4.3.5 consumers and PlaybackControls remain accepted. No runtime getter was invented.",
|
||||
"resolutionEvidence": [
|
||||
"refactor/baselines/core-declarations-validation.json",
|
||||
"refactor/changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"packages/artplayer/types/COMPATIBILITY.md",
|
||||
"test/types/runtime-public.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "BASE-LIFE-07",
|
||||
@@ -995,7 +1023,7 @@
|
||||
"id": "BASE-TYPE-09",
|
||||
"title": "Template and icon declarations claim incompatible DOM and static shapes",
|
||||
"confirmation": "source-observed",
|
||||
"status": "open",
|
||||
"status": "resolved",
|
||||
"owners": [
|
||||
"CORE-21"
|
||||
],
|
||||
@@ -1006,7 +1034,14 @@
|
||||
"refactor/changes/2026-09-11-CORE-12-template-resources.md"
|
||||
],
|
||||
"compatibleResolution": "Keep old legal declarations accepted, expose accurate template and icon views without inventing runtime properties.",
|
||||
"closureCriteria": "Old consumers and accurate template/media/icon view consumers pass all supported type modes and runtime shape checks."
|
||||
"closureCriteria": "Old consumers and accurate template/media/icon view consumers pass all supported type modes and runtime shape checks.",
|
||||
"resolutionRationale": "Generated runtime Template/Icons/MediaSurface model nullable SSR/query nodes, real icon wrappers, div container validation and static html placement. Constructor-stage host consumers reject premature getters; installed type modes and published/candidate shape/browser checks pass while old imports remain compatible.",
|
||||
"resolutionEvidence": [
|
||||
"refactor/baselines/core-declarations-validation.json",
|
||||
"refactor/changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"packages/artplayer/types/COMPATIBILITY.md",
|
||||
"test/types/runtime-public.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "BASE-LIFE-09",
|
||||
@@ -1532,7 +1567,7 @@
|
||||
"id": "BASE-TYPE-10",
|
||||
"title": "PiP getter is declared boolean but native runtime returns an element or null",
|
||||
"confirmation": "reproduced",
|
||||
"status": "open",
|
||||
"status": "resolved",
|
||||
"owners": [
|
||||
"CORE-16",
|
||||
"CORE-21"
|
||||
@@ -1544,7 +1579,14 @@
|
||||
],
|
||||
"compatibleResolution": "Keep old legal JS return identities and historical public consumers; model the internal branch-dependent getter accurately and coordinate a compatible public declaration strategy in CORE-21.",
|
||||
"closureCriteria": "Public declaration strategy and installed JS/TS consumers explicitly cover native element/null and fallback boolean without silently narrowing old legal consumption.",
|
||||
"workspaceState": "CORE-16 preserves historical native Element/null and WebKit boolean runtime returns with precise internal PipProperty. The installed old public consumers still pass; public declaration coordination remains CORE-21."
|
||||
"workspaceState": "Generated runtime Player exposes native Element|null or WebKit boolean PiP reads and boolean writes. Installed positive/negative type consumers and native/fallback browser behavior pass, preserving original JS return identity and historical boolean declaration acceptance at the old root. Physical Apple/AirPlay certification remains a separate release gate.",
|
||||
"resolutionRationale": "Generated runtime Player exposes native Element|null or WebKit boolean PiP reads and boolean writes. Installed positive/negative type consumers and native/fallback browser behavior pass, preserving original JS return identity and historical boolean declaration acceptance at the old root. Physical Apple/AirPlay certification remains a separate release gate.",
|
||||
"resolutionEvidence": [
|
||||
"refactor/baselines/core-declarations-validation.json",
|
||||
"refactor/changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"packages/artplayer/types/COMPATIBILITY.md",
|
||||
"test/types/runtime-public.ts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "BASE-DOM-13",
|
||||
|
||||
+7
-2
@@ -1153,11 +1153,16 @@
|
||||
"CORE-20",
|
||||
"ENG-07"
|
||||
],
|
||||
"status": "todo",
|
||||
"status": "done",
|
||||
"risk": "H",
|
||||
"deliverable": "由 TS 生成的既有入口声明与三种发布产物",
|
||||
"acceptance": "内部类型不泄漏,旧 JS/TS 消费者与 i18n 通过;逐项完成 CORE-07 留下的 BASE-TYPE-04/05/07 声明方案,旧合法消费者与实际返回分别留证;不能以虚假的交叉返回类型或改变运行时来掩盖冲突,未决项阻止核心声明出口;处理 CORE-10 / BASE-TYPE-08 的 setter-only 属性虚构 getter 声明,并复核 PlaybackControls 精确视图与旧 toggle 声明共存策略",
|
||||
"evidence": []
|
||||
"evidence": [
|
||||
"changes/2026-09-11-CORE-21-public-declarations.md",
|
||||
"baselines/core-declarations-validation.json",
|
||||
"core-public-types.md",
|
||||
"typechecking.md"
|
||||
]
|
||||
},
|
||||
{
|
||||
"scope": [
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
# 已实现的类型检查与迁移入口
|
||||
|
||||
CORE-21 已完成声明与消费者验收。核心公开声明源已迁至 packages/artplayer/public/,
|
||||
使用 yarn build:types 生成历史 types/ 路径;yarn check:types 只读检查漂移、
|
||||
源错误和内部依赖,已接入 ci:check。public/ 与 src/ 分别纳入严格检查,
|
||||
public/ 不打入 npm 包。当前生成 37 个声明,精确构造器及阶段回调宿主已接入。
|
||||
核心编辑器从同一旧入口依赖图生成,并有独立 TS 4.3.5/5.9.3 语义检查和真实 Monaco 验证;
|
||||
CI 449 项、229 个生产 TS 文件及最终安装包五组旧/八组精确类型通过,
|
||||
UMD/legacy 各 1521 项三浏览器回归通过,见 core-public-types.md。
|
||||
|
||||
精确模块额外使用根开发 alias typescript-runtime-compat(npm:typescript@5.1.6)
|
||||
验证当前/最低现代编译器的 Node10、NodeNext CJS/ESM 和 Bundler 四模式。
|
||||
它不替换生成编译器或旧入口 4.3.5 回归。runtime-leaf-consumer.ts 直接消费
|
||||
生成模块;runtime-public.ts/runtime-commonjs.cts 通过真实精确入口检查默认/CJS/legacy、
|
||||
回调、返回值和新旧模块扩展。安装包检查在仓库外重复五组旧类型及八组精确类型,
|
||||
并禁止解析逃回工作区。runtime-facade.ts 检查源成员覆盖和服务对应,
|
||||
其余 runtime 类型夹具逐项对照实现,不使用整实例双重断言来制造对应证明。
|
||||
runtime-construction.ts 同时在仓库和安装包检查 proxy/组件/插件的阶段宿主,
|
||||
保留独立访问器写入,并区分延迟执行的完整 customType/setting 宿主。
|
||||
scripts/editor-types.mjs 负责核心编辑器依赖打包、AST 全局桥和独立编译;
|
||||
test/editor-types.test.js 检查漂移及损坏输出,test/browser/editor-types.spec.js 验证实际 worker。
|
||||
|
||||
PKG-CHAPTER-04 已修复核心/chapter 的条件类型入口、language 与 chapter legacy 回退。
|
||||
当前五组编译模式均要求零诊断,覆盖默认/命名类型、legacy、语言与 CJS require 形式;
|
||||
七条历史 NodeNext 诊断和打包额外四条诊断的候选豁免已移除,冻结发布基线不变。
|
||||
|
||||
+2
-10
@@ -2,6 +2,7 @@ import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { ESLint } from 'eslint'
|
||||
import { glob } from 'glob'
|
||||
import { generateCoreEditorDeclaration } from './editor-types.mjs'
|
||||
|
||||
function ensureDirExists(filePath) {
|
||||
const dir = path.dirname(filePath)
|
||||
@@ -26,17 +27,8 @@ function parsePluginInfo(pluginPath) {
|
||||
}
|
||||
|
||||
const reg = /^import.*$/gim
|
||||
const artplayerTS = glob.sync('packages/artplayer/types/*.d.ts')
|
||||
const artplayerTSoutput = path.join('docs/assets/ts/artplayer.d.ts')
|
||||
|
||||
let code = ''
|
||||
for (let index = 0; index < artplayerTS.length; index++) {
|
||||
const type = artplayerTS[index]
|
||||
code += `${String(fs.readFileSync(type)).replace(reg, '')}\n`
|
||||
}
|
||||
|
||||
code.replace('export default ', '')
|
||||
code += `export = Artplayer;\nexport as namespace Artplayer;\n`
|
||||
const code = generateCoreEditorDeclaration()
|
||||
ensureDirExists(artplayerTSoutput)
|
||||
fs.writeFileSync(artplayerTSoutput, code.trim())
|
||||
console.log(`✨ Built ${artplayerTSoutput}`);
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { ESLint } from 'eslint'
|
||||
import ts from 'typescript'
|
||||
|
||||
const workspace = fileURLToPath(new URL('../', import.meta.url))
|
||||
const normalize = value => value.replaceAll('\\', '/')
|
||||
|
||||
export async function generateCoreDeclarations({ root = workspace, write = false } = {}) {
|
||||
const packageRoot = path.join(root, 'packages/artplayer')
|
||||
const sourceRoot = path.join(packageRoot, 'public')
|
||||
const outputRoot = path.join(packageRoot, 'types')
|
||||
const files = ts.sys.readDirectory(sourceRoot, ['.ts', '.mts', '.cts']).sort()
|
||||
assert(files.length > 0, 'No public TypeScript sources found')
|
||||
assert(files.every(file => !/\.d\.[cm]?ts$/.test(file)), 'Public sources must be TypeScript, not copied declaration artifacts')
|
||||
const options = {
|
||||
strict: true,
|
||||
skipLibCheck: false,
|
||||
types: [],
|
||||
target: ts.ScriptTarget.ES2020,
|
||||
lib: ['lib.es2020.d.ts', 'lib.dom.d.ts', 'lib.dom.iterable.d.ts'],
|
||||
module: ts.ModuleKind.NodeNext,
|
||||
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
||||
declaration: true,
|
||||
emitDeclarationOnly: true,
|
||||
noEmitOnError: true,
|
||||
rootDir: sourceRoot,
|
||||
outDir: outputRoot,
|
||||
newLine: ts.NewLineKind.LineFeed,
|
||||
}
|
||||
const outputs = new Map()
|
||||
const program = ts.createProgram(files, options)
|
||||
const formatHost = { getCurrentDirectory: () => root, getCanonicalFileName: name => name, getNewLine: () => '\n' }
|
||||
const errors = ts.getPreEmitDiagnostics(program)
|
||||
assert.equal(errors.length, 0, ts.formatDiagnosticsWithColorAndContext(errors, formatHost))
|
||||
for (const source of program.getSourceFiles()) {
|
||||
if (program.isSourceFileDefaultLibrary(source))
|
||||
continue
|
||||
assert(files.includes(source.fileName), `Public declarations depend on a non-public source: ${normalize(path.relative(root, source.fileName))}`)
|
||||
}
|
||||
const emitted = program.emit(undefined, (file, text) => {
|
||||
const relative = normalize(path.relative(outputRoot, file))
|
||||
assert(!relative.startsWith('../') && !path.isAbsolute(relative) && /\.d\.[cm]?ts$/.test(relative), `Unexpected declaration output: ${file}`)
|
||||
outputs.set(relative, text)
|
||||
})
|
||||
assert.equal(emitted.emitSkipped, false, ts.formatDiagnosticsWithColorAndContext(emitted.diagnostics, formatHost))
|
||||
assert.equal(outputs.size, files.length, 'Each public source must emit one declaration')
|
||||
|
||||
const eslint = new ESLint({ cwd: workspace, fix: true, fixTypes: ['layout'] })
|
||||
const generated = new Map()
|
||||
for (const [relative, content] of outputs) {
|
||||
const source = `public/${relative.replace('.d.', '.')}`
|
||||
// Declaration emit omits line comments. This bridge intentionally merges
|
||||
// the constructor value, instance alias and CJS named-type namespace.
|
||||
const bridge = ['artplayer.d.cts', 'runtime.d.cts', 'runtime.d.ts'].includes(relative) ? '/* eslint-disable ts/no-redeclare -- Constructor, instance and named types share the export. */\n' : ''
|
||||
const code = `// Generated from ${source} by yarn build:types. Do not edit.\n${bridge}${content}`
|
||||
const [result] = await eslint.lintText(code, { filePath: path.join(workspace, 'packages/artplayer/types', relative) })
|
||||
if (result.errorCount) {
|
||||
const formatter = await eslint.loadFormatter('stylish')
|
||||
throw new Error(formatter.format([result]))
|
||||
}
|
||||
generated.set(relative, result.output || code)
|
||||
}
|
||||
const existing = ts.sys.readDirectory(outputRoot, ['.d.ts', '.d.mts', '.d.cts'])
|
||||
for (const file of existing)
|
||||
assert(generated.has(normalize(path.relative(outputRoot, file))), `Declaration has no public source: ${file}`)
|
||||
const changed = []
|
||||
for (const [relative, text] of generated) {
|
||||
const file = path.join(outputRoot, relative)
|
||||
const actual = fs.existsSync(file) ? fs.readFileSync(file, 'utf8').replaceAll('\r\n', '\n') : null
|
||||
if (actual === text)
|
||||
continue
|
||||
changed.push(relative)
|
||||
if (write) {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true })
|
||||
fs.writeFileSync(file, text)
|
||||
}
|
||||
}
|
||||
assert(write || changed.length === 0, `Generated core declarations are stale: ${changed.join(', ')}. Run yarn build:types.`)
|
||||
return { files: [...generated.keys()].sort(), changed }
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
assert(process.argv.length === 3 && ['--write', '--check'].includes(process.argv[2]), 'Use build-types.mjs --write or --check')
|
||||
const result = await generateCoreDeclarations({ write: process.argv[2] === '--write' })
|
||||
console.log(`Core declarations ${process.argv[2]}: ${result.files.length} files; ${result.changed.length} changed`)
|
||||
}
|
||||
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user