diff --git a/package.json b/package.json index 6698504b8..64fb8988d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "check:toolchain": "node scripts/check-toolchain.mjs", "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/declarations.test.js test/editor-types.test.js test/coverage.test.js test/performance-report.test.js test/media-gate.test.js test/ci-summary.test.js test/package-runtime.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/coverage.test.js test/performance-report.test.js test/media-gate.test.js test/ci-summary.test.js test/package-runtime.test.js test/library-build.test.js", "test:baseline": "node --test refactor/scripts/*.test.mjs", "ci:check": "yarn check:toolchain --strict && yarn check:commits --report && yarn check:impact --report && yarn check:ci && yarn test:contracts && yarn check:contracts --report && 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", diff --git a/packages/artplayer/dist/artplayer.cts b/packages/artplayer/dist/artplayer.cts deleted file mode 100644 index 4693bc06d..000000000 --- a/packages/artplayer/dist/artplayer.cts +++ /dev/null @@ -1,29 +0,0 @@ -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> = Definition.Emitter - 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 = Definition.PluginFactory - 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 diff --git a/packages/artplayer/dist/artplayer.mts b/packages/artplayer/dist/artplayer.mts deleted file mode 100644 index 7400ac73a..000000000 --- a/packages/artplayer/dist/artplayer.mts +++ /dev/null @@ -1,2 +0,0 @@ -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' diff --git a/packages/artplayer/dist/artplayer.ts b/packages/artplayer/dist/artplayer.ts deleted file mode 100644 index df439aaa2..000000000 --- a/packages/artplayer/dist/artplayer.ts +++ /dev/null @@ -1,216 +0,0 @@ -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 - static readonly Emitter: new >(...args: unknown[]) => Emitter - static readonly validator: (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(name: T, fn: (...args: Events[T]) => unknown, ctx?: object): this - on(name: T, fn: (...args: SubtitleUpdateEvents[T]) => unknown, ctx?: object): this - on(name: string, fn: (...args: unknown[]) => unknown, ctx?: object): this - - once(name: T, fn: (...args: Events[T]) => unknown, ctx?: object): this - once(name: T, fn: (...args: SubtitleUpdateEvents[T]) => unknown, ctx?: object): this - once(name: string, fn: (...args: unknown[]) => unknown, ctx?: object): this - - emit(name: T, ...args: Events[T]): this - emit(name: T, ...args: SubtitleUpdateEvents[T]): this - emit(name: string, ...args: unknown[]): this - - off(name: T, callback?: (...args: Events[T]) => unknown): this - off(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: (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 - get: { - (key: string): unknown - (): Record - } - set: (key: string, value: unknown) => void - del: (key: string) => void - clear: () => void - } - - readonly icons: Icons - - readonly i18n: { - languages: I18n - language: Partial> - init: () => void - get: (key: string) => string - update: (language: Partial) => void - } - - readonly notice: { - timer: number | null - get show(): string | Error | false | '' - set show(msg: string | Error | false | '') - destroy: () => void - } - - readonly layers: Record & Component - readonly controls: Record & Component - readonly contextmenu: Record & Component - - readonly subtitle: { - get url(): string - set url(url: string) - get textTrack(): TextTrack | undefined - get activeCues(): VTTCue[] - get cues(): VTTCue[] - style: (name: string | Partial, value?: string) => void - switch: (url: string, option?: Subtitle) => Promise - init: (subtitle: Subtitle) => Promise - } & Component - - readonly info: Component - readonly loading: Component - - readonly hotkey: { - keys: Record 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 diff --git a/packages/artplayer/dist/component.ts b/packages/artplayer/dist/component.ts deleted file mode 100644 index 7fdf4213d..000000000 --- a/packages/artplayer/dist/component.ts +++ /dev/null @@ -1,143 +0,0 @@ -import type Artplayer from './artplayer' - -/** Input accepted by the existing HTML renderer, including numeric content. */ -export interface ComponentInput extends Omit { - 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 - - /** - * 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) - - /** - * 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 -} diff --git a/packages/artplayer/dist/config.ts b/packages/artplayer/dist/config.ts deleted file mode 100644 index 11c753b4e..000000000 --- a/packages/artplayer/dist/config.ts +++ /dev/null @@ -1,81 +0,0 @@ -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', - ] -} diff --git a/packages/artplayer/dist/cssVar.ts b/packages/artplayer/dist/cssVar.ts deleted file mode 100644 index e9384c07f..000000000 --- a/packages/artplayer/dist/cssVar.ts +++ /dev/null @@ -1,45 +0,0 @@ -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 -} diff --git a/packages/artplayer/dist/emitter.ts b/packages/artplayer/dist/emitter.ts deleted file mode 100644 index f9bb749c1..000000000 --- a/packages/artplayer/dist/emitter.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** The event bus exposed by Artplayer.Emitter; no new runtime export. */ -export interface Emitter> { - e?: { [Name in keyof Events]?: { fn: (...args: [...Events[Name]]) => unknown, ctx: unknown }[] } - on: (name: Name, fn: (this: Context, ...args: [...Events[Name]]) => unknown, ctx?: Context) => this - once: (name: Name, fn: (this: Context, ...args: [...Events[Name]]) => unknown, ctx?: Context) => this - emit: (name: Name, ...args: [...Events[Name]]) => this - off: (name: Name, fn?: (...args: [...Events[Name]]) => unknown) => this -} diff --git a/packages/artplayer/dist/events.ts b/packages/artplayer/dist/events.ts deleted file mode 100644 index 624bbd55a..000000000 --- a/packages/artplayer/dist/events.ts +++ /dev/null @@ -1,106 +0,0 @@ -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] -} diff --git a/packages/artplayer/dist/i18n.ts b/packages/artplayer/dist/i18n.ts deleted file mode 100644 index 214c5dec2..000000000 --- a/packages/artplayer/dist/i18n.ts +++ /dev/null @@ -1,61 +0,0 @@ -type I18nKeys - = | 'en' - | 'zh-cn' - | 'zh-tw' - | 'pl' - | 'cs' - | 'es' - | 'fa' - | 'fr' - | 'id' - | 'ru' - | 'tr' - | 'ar' - | 'vi' - | (string & Record) - -interface I18nValue { - 'Context Menu'?: string - 'Lock'?: string - 'Video Info': string - 'Close': string - 'Video Load Failed': string - 'Volume': string - 'Progress'?: string - 'Back'?: string - 'Settings'?: 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>> diff --git a/packages/artplayer/dist/icons.ts b/packages/artplayer/dist/icons.ts deleted file mode 100644 index b97cf5662..000000000 --- a/packages/artplayer/dist/icons.ts +++ /dev/null @@ -1,30 +0,0 @@ -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 -} diff --git a/packages/artplayer/dist/language.cts b/packages/artplayer/dist/language.cts deleted file mode 100644 index ab9320684..000000000 --- a/packages/artplayer/dist/language.cts +++ /dev/null @@ -1,5 +0,0 @@ -import type { I18n } from './i18n.js' - -declare const language: NonNullable -// eslint-disable-next-line no-restricted-syntax -- Preserve the language object's CommonJS value export. -export = language diff --git a/packages/artplayer/dist/language.mts b/packages/artplayer/dist/language.mts deleted file mode 100644 index 3b243cb0a..000000000 --- a/packages/artplayer/dist/language.mts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './language.cjs' diff --git a/packages/artplayer/dist/legacy/language.ts b/packages/artplayer/dist/legacy/language.ts deleted file mode 100644 index 34de69188..000000000 --- a/packages/artplayer/dist/legacy/language.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { I18n } from '../i18n' - -declare const language: NonNullable -export default language diff --git a/packages/artplayer/dist/option.ts b/packages/artplayer/dist/option.ts deleted file mode 100644 index 022d146bf..000000000 --- a/packages/artplayer/dist/option.ts +++ /dev/null @@ -1,331 +0,0 @@ -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) - -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 { - 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 unknown - ? never - : K]: HTMLVideoElement[K] - }>> - - /** - * Custom i18n - */ - i18n?: I18n - - /** - * Custom default icons - */ - icons?: { - [key in keyof Icons]?: HTMLElement | string - } - - /** - * Custom css variables - */ - cssVar?: Partial - - /** - * Custom video type function - */ - customType?: Partial< - Record< - CustomType, - (this: Artplayer, video: HTMLVideoElement, url: string, art: Artplayer) => unknown | Promise - > - > -} diff --git a/packages/artplayer/dist/playback.ts b/packages/artplayer/dist/playback.ts deleted file mode 100644 index b9452c046..000000000 --- a/packages/artplayer/dist/playback.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** Accurate playback method view; assign an existing player without a runtime wrapper. */ -export interface PlaybackControls { - play: () => Promise - pause: () => void - toggle: () => Promise | void -} diff --git a/packages/artplayer/dist/player.ts b/packages/artplayer/dist/player.ts deleted file mode 100644 index 14051a790..000000000 --- a/packages/artplayer/dist/player.ts +++ /dev/null @@ -1,113 +0,0 @@ -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) -export type PlaybackRate = 0.5 | 0.75 | 1.0 | 1.25 | 1.5 | 1.75 | 2.0 | (number & Record) -export type Flip = 'normal' | 'horizontal' | 'vertical' | (string & Record) -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 - /** Legacy signature; runtime preserves pause's synchronous result or play's Promise. */ - toggle(): void - - attr(key: string, value?: unknown): unknown - cssVar(key: T, value?: CssVar[T]): CssVar[T] - - switchUrl(url: string): Promise - switchQuality(url: string): Promise - - getDataURL(): Promise - getBlobUrl(): Promise - screenshot(name?: string): Promise - - airplay(): void - autoSize(): void - autoHeight(): void - reset(): void -} diff --git a/packages/artplayer/dist/plugin.ts b/packages/artplayer/dist/plugin.ts deleted file mode 100644 index 1f4a61ee6..000000000 --- a/packages/artplayer/dist/plugin.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type Artplayer from './artplayer' - -export type PluginFactory = (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 - [name: string]: unknown -} diff --git a/packages/artplayer/dist/quality.ts b/packages/artplayer/dist/quality.ts deleted file mode 100644 index 04058141a..000000000 --- a/packages/artplayer/dist/quality.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface Quality { - /** - * Whether the default is selected - */ - default?: boolean - - /** - * Html string of quality - */ - html: string | HTMLElement - - /** - * Video quality url - */ - url: string -} diff --git a/packages/artplayer/dist/runtime.cts b/packages/artplayer/dist/runtime.cts deleted file mode 100644 index 77fa28d37..000000000 --- a/packages/artplayer/dist/runtime.cts +++ /dev/null @@ -1,54 +0,0 @@ -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 = Definition.PluginFactory - 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 = Definition.PluginRegistration - 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 = Definition.Player - type Template = Definition.Template - type Icons = Definition.Icons - type Config = Definition.Config - type EventRegistry = Definition.EventRegistry - type Storage = Definition.Storage - type I18n = Definition.I18n - type Hotkey = Definition.Hotkey - type Languages = Definition.Languages - type Dictionary = Definition.Dictionary - type QualityItem = Definition.QualityItem - type SettingItem = Definition.SettingItem - type ComponentInput = Definition.ComponentInput - type ComponentOption = Definition.ComponentOption - type ControlInput = Definition.ControlInput - type ControlOption = Definition.ControlOption - type SelectorItem = Definition.SelectorItem - type SubtitleCue = Definition.SubtitleCue - type SubtitleOption = Definition.SubtitleOption - type Emitter> = Definition.Emitter -} - -// eslint-disable-next-line no-restricted-syntax -- Preserve the actual CommonJS constructor export. -export = Artplayer diff --git a/packages/artplayer/dist/runtime.mts b/packages/artplayer/dist/runtime.mts deleted file mode 100644 index afba2a834..000000000 --- a/packages/artplayer/dist/runtime.mts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from './runtime.cjs' -export type * from './runtime.js' diff --git a/packages/artplayer/dist/runtime.ts b/packages/artplayer/dist/runtime.ts deleted file mode 100644 index fe19bce2e..000000000 --- a/packages/artplayer/dist/runtime.ts +++ /dev/null @@ -1,125 +0,0 @@ -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 = FactoryView -export interface OptionInput extends Omit, 'plugins' | 'proxy' | 'customType' | 'layers' | 'controls' | 'contextmenu'> { - plugins?: PluginFactory[] - proxy?: (this: ProxyHost, art: ProxyHost) => MediaSurface - customType?: Record unknown) | undefined> - layers?: ComponentInput[] - controls?: ControlInput[] - contextmenu?: ComponentInput[] -} -export interface Option extends OptionView {} -export interface Component extends ComponentView {} -export interface Controls extends ControlsView {} -export interface Setting extends SettingView {} -export interface Subtitle extends SubtitleView, Omit {} -export interface Notice extends NoticeView { art: Artplayer } - -/** Augment with installed results. Factories are not wrapped or converted. */ -export interface PluginAdd { - (plugin: FactoryView): PluginRegistration - (plugin: LegacyPluginFactory): PluginRegistration -} - -type LegacyPluginResults = { - [Name in keyof LegacyPlugins as string extends Name ? never : number extends Name ? never : Name extends keyof PluginsView ? never : Name]: LegacyPlugins[Name] -} - -export interface Plugins extends Omit, 'add'>, LegacyPluginResults { - add: PluginAdd - [name: string]: unknown -} - -/** Public view of the existing constructor; this interface emits no runtime fields. */ -interface Artplayer extends Player, Emitter { - 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 - events: EventRegistry - storage: Storage - icons: Icons - i18n: I18n - 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 - mask: Component - setting: Setting - plugins: Plugins - readonly query: Template['query'] - readonly proxy: EventRegistry['proxy'] - readonly video: MediaSurface - reset: () => void - destroy: (removeHtml?: boolean) => void -} - -type StaticOptions = Pick>> - -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 - readonly Emitter: new >(...args: unknown[]) => Emitter - readonly validator: (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 diff --git a/packages/artplayer/dist/runtime/component.ts b/packages/artplayer/dist/runtime/component.ts deleted file mode 100644 index f23ae4b3f..000000000 --- a/packages/artplayer/dist/runtime/component.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 { - html?: string | HTMLElement | number - disable?: boolean - name?: string - index?: number - style?: Partial - tooltip?: string | number - position?: string - selector?: SelectorItem[] - click?: (this: Host, component: Component, 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 = ComponentOption | ((art: Host) => ComponentOption) - -export interface ControlOption extends Omit, 'position'> { - position: 'top' | 'left' | 'right' -} - -export type ControlInput = ControlOption | ((art: Host) => ControlOption) - -export interface ComponentEntry { - $ref: HTMLDivElement - events: EventCleanup[] - option: ComponentOption -} - -export interface Component { - id: number - art: Host - name?: string - $parent?: HTMLElement - cache: Map> - show: boolean - toggle: () => void - add: (input: ComponentInput) => HTMLDivElement | undefined - remove: (name: string) => void - update: (option: ComponentOption) => ReturnType - selector?: (option: ComponentOption, element: HTMLDivElement, events: EventCleanup[]) => void -} - -export interface Controls extends Omit, 'add' | 'update' | 'selector'> { - isHover: boolean - timer: number - setting?: HTMLDivElement - thumbnails?: HTMLDivElement - init: () => void - add: (input: ControlInput) => undefined - update: (option: ComponentOption) => undefined - check: (target?: SelectorItem) => void - selector: (option: ComponentOption, element: HTMLDivElement, events: EventCleanup[]) => void -} diff --git a/packages/artplayer/dist/runtime/construction.ts b/packages/artplayer/dist/runtime/construction.ts deleted file mode 100644 index 0dc902200..000000000 --- a/packages/artplayer/dist/runtime/construction.ts +++ /dev/null @@ -1,19 +0,0 @@ -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, Pick {} - -// Mapped types collapse distinct getter/setter types; preserve Player directly. -type Pending = Player & Omit & Partial> -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 -export type ControlHost = Pending> -export type ContextmenuHost = Pending> -/** Constructor factories run before the Plugins registry is assigned to the player. */ -export type PluginHost = Pending<'plugins'> diff --git a/packages/artplayer/dist/runtime/events.ts b/packages/artplayer/dist/runtime/events.ts deleted file mode 100644 index 0d5e26888..000000000 --- a/packages/artplayer/dist/runtime/events.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Events as LegacyEvents } from '../events' -import type { SubtitleCue, SubtitleOption } from './subtitle' - -type NativeEvents = { [Name in Extract]: [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, NativeEvents, BuiltinEvents, Record {} diff --git a/packages/artplayer/dist/runtime/media.ts b/packages/artplayer/dist/runtime/media.ts deleted file mode 100644 index 335620f65..000000000 --- a/packages/artplayer/dist/runtime/media.ts +++ /dev/null @@ -1,41 +0,0 @@ -export type MediaState = Pick & { - readonly playing?: boolean -} - -export interface PlaybackMethods { - play: () => PlayResult - pause: () => PauseResult -} - -export interface OptionalMediaCapabilities { - readonly textTracks?: ArrayLike - readonly error?: unknown - requestPictureInPicture?: () => Promise - 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 & 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 diff --git a/packages/artplayer/dist/runtime/option.ts b/packages/artplayer/dist/runtime/option.ts deleted file mode 100644 index 9b7f8d477..000000000 --- a/packages/artplayer/dist/runtime/option.ts +++ /dev/null @@ -1,28 +0,0 @@ -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 extends Omit { - container: string | HTMLDivElement - proxy?: (this: Host, art: Host) => MediaSurface | undefined - plugins?: PluginFactory[] - layers?: ComponentInput[] - controls?: ControlInput[] - contextmenu?: ComponentInput[] - settings?: SettingItem[] - customType?: Record unknown) | undefined> - i18n?: Languages - icons?: Record -} - -/** Defaults are merged once; later setters may replace thumbnails with a partial input. */ -export interface Option extends Omit>, 'proxy' | 'subtitle' | 'thumbnails'> { - proxy: OptionInput['proxy'] - subtitle: SubtitleOption - thumbnails: Thumbnails -} diff --git a/packages/artplayer/dist/runtime/player.ts b/packages/artplayer/dist/runtime/player.ts deleted file mode 100644 index 1180dc68d..000000000 --- a/packages/artplayer/dist/runtime/player.ts +++ /dev/null @@ -1,78 +0,0 @@ -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 { - 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>> - pause: () => ReturnType - toggle: () => Promise>> | ReturnType - switchUrl: (url: string) => Promise - switchQuality: (url: string) => Promise - autoSize: () => void - autoHeight: () => void - airplay: () => void - getDataURL: () => Promise - getBlobUrl: () => Promise - screenshot: (name?: string) => Promise - attr: { - (key: PropertyKey): unknown - (key: PropertyKey, value: unknown): unknown - } - cssVar: { - (key: string): string - (key: string, value: unknown): string | void - } -} diff --git a/packages/artplayer/dist/runtime/plugin.ts b/packages/artplayer/dist/runtime/plugin.ts deleted file mode 100644 index 3192f3c11..000000000 --- a/packages/artplayer/dist/runtime/plugin.ts +++ /dev/null @@ -1,13 +0,0 @@ -export type PluginFactory = (this: Host, art: Host) => Result - -export type PluginRegistration - = unknown extends Result ? Registry | Promise - : Result extends Promise ? Promise : Registry - -/** The same registry is returned immediately or after its Promise factory settles. */ -export interface Plugins { - art: Host - id: number - add: (plugin: PluginFactory) => PluginRegistration - next: (plugin: PluginFactory, result: unknown) => this -} diff --git a/packages/artplayer/dist/runtime/services.ts b/packages/artplayer/dist/runtime/services.ts deleted file mode 100644 index 50c4f507f..000000000 --- a/packages/artplayer/dist/runtime/services.ts +++ /dev/null @@ -1,57 +0,0 @@ -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 - 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 - get: (key?: PropertyKey) => unknown - set: (key: PropertyKey, value: unknown) => void - del: (key: PropertyKey) => void - clear: () => void -} - -export type Dictionary = Record -export type Languages = Record - -export interface I18n { - art: Host - languages: Languages - language: Dictionary - init: () => void - get: (key: string) => string - update: (value: Languages) => void -} - -export type HotkeyCallback = (this: Host, event: KeyboardEvent) => unknown - -export interface Hotkey { - art: Host - keys: Record[]> - init: () => void - add: (key: string, callback: HotkeyCallback) => this - remove: (key: string, callback: HotkeyCallback) => 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 } diff --git a/packages/artplayer/dist/runtime/setting.ts b/packages/artplayer/dist/runtime/setting.ts deleted file mode 100644 index dda910320..000000000 --- a/packages/artplayer/dist/runtime/setting.ts +++ /dev/null @@ -1,58 +0,0 @@ -export type SettingContent = string | HTMLElement | number -export type SettingRange = [value?: number, min?: number, max?: number, step?: number] -export type SettingCallback = (this: Host, item: SettingItem, element: HTMLDivElement, event: Event) => unknown - -export interface SettingItem { - name?: string - html?: SettingContent - icon?: SettingContent - tooltip?: SettingContent - width?: number - value?: string | number - default?: boolean - switch?: boolean - range?: SettingRange - selector?: SettingItem[] - mounted?: (this: Host, element: HTMLDivElement, item: SettingItem) => unknown - onClick?: SettingCallback - onSwitch?: SettingCallback - onRange?: SettingCallback - onChange?: SettingCallback - onSelect?: SettingCallback - readonly $parent?: SettingItem - readonly $parents?: SettingItem[] - readonly $option?: SettingItem[] - 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 { - id: number - art: Host - name: string - $parent: HTMLElement - cache: Map[], HTMLDivElement> - active: SettingItem[] | null - option: SettingItem[] - readonly builtin: SettingItem[] - show: boolean - toggle: () => void - traverse: (callback: (item: SettingItem) => void, option?: SettingItem[]) => void - check: (target?: SettingItem | null) => void - format: (option?: SettingItem[], parent?: SettingItem, parents?: SettingItem[], names?: string[]) => void - find: (name?: string) => SettingItem | null - resize: () => void - inactivate: (item: SettingItem) => void - remove: (name: string) => void - update: (item: SettingItem) => SettingItem - add: >(item: Item, option?: SettingItem[]) => Item - createHeader: (item: SettingItem) => void - createItem: (item: SettingItem, isUpdate?: boolean) => void - render: (option?: SettingItem[]) => void -} diff --git a/packages/artplayer/dist/runtime/subtitle.ts b/packages/artplayer/dist/runtime/subtitle.ts deleted file mode 100644 index 0fe6c0350..000000000 --- a/packages/artplayer/dist/runtime/subtitle.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { Subtitle as SubtitleInput } from '../subtitle' - -export type SubtitleOption = Required - -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): HTMLDivElement - (key: string, value: string | number): HTMLDivElement - } - update: () => void - switch: (url: string, option?: SubtitleInput) => Promise - init: (option: SubtitleOption) => Promise - createTrack: (kind: string, url: string) => void -} - -export interface Notice { - timer: number | null - get show(): boolean - set show(value: string | Error | false) - destroy: () => void -} diff --git a/packages/artplayer/dist/runtime/template.ts b/packages/artplayer/dist/runtime/template.ts deleted file mode 100644 index 0ac9b2409..000000000 --- a/packages/artplayer/dist/runtime/template.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { MediaSurface } from './media' - -/** Query results remain nullable for caller-supplied SSR templates. */ -export interface Template { - 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: (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> & { readonly [name: string]: HTMLElement | undefined } diff --git a/packages/artplayer/dist/runtime/utils.ts b/packages/artplayer/dist/runtime/utils.ts deleted file mode 100644 index 50e38626f..000000000 --- a/packages/artplayer/dist/runtime/utils.ts +++ /dev/null @@ -1,67 +0,0 @@ -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: (selector: string, parent?: ParentNode) => T | null - queryAll: (selector: string, parent?: ParentNode) => T[] - addClass: (target: Pick, className: string) => void - removeClass: (target: Pick, className: string) => void - hasClass: (target: Pick, className: string) => boolean - append: (parent: Element, child: unknown) => Element | ChildNode | null - remove: (child: T) => T - replaceElement: (newChild: T, oldChild: Node) => T - siblings: (target: Element) => Element[] - inverseClass: (target: Element, className: string) => void - createElement: { - (tag: K): HTMLElementTagNameMap[K] - (tag: string): HTMLElement - } - setStyle: (element: T, key: PropertyKey, value: unknown) => T - setStyles: (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) => DOMRect - tooltip: (target: Element, message: string | number, position?: string) => void - isInViewport: (target: Pick, 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 - errorHandle: (condition: T, message?: string) => T - silencePromise: (value: T) => T extends Promise ? Promise : T - def: (object: T, name: PropertyKey, descriptor: PropertyDescriptor & object & ThisType) => T - has: (object: object, name: PropertyKey) => boolean - get: (object: object, name: PropertyKey) => PropertyDescriptor | undefined - mergeDeep: (...objects: T) => T[number] - sleep: (milliseconds?: number) => Promise - /** The wrapper preserves its call receiver; the old context argument is ignored. */ - debounce: (callback: (this: Receiver, ...args: Args) => unknown, duration: number, context?: object) => (this: Receiver, ...args: Args) => void - throttle: (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 -} diff --git a/packages/artplayer/dist/setting.ts b/packages/artplayer/dist/setting.ts deleted file mode 100644 index 739dd5908..000000000 --- a/packages/artplayer/dist/setting.ts +++ /dev/null @@ -1,95 +0,0 @@ -import type Artplayer from './artplayer' - -export interface SettingOption extends Omit { - 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 -} diff --git a/packages/artplayer/dist/subtitle.ts b/packages/artplayer/dist/subtitle.ts deleted file mode 100644 index 9783d155c..000000000 --- a/packages/artplayer/dist/subtitle.ts +++ /dev/null @@ -1,36 +0,0 @@ -export interface Subtitle { - /** - * The subtitle url - */ - url?: string - - /** - * The subtitle name - */ - name?: string - - /** - * The subtitle type - */ - type?: 'vtt' | 'srt' | 'ass' | (string & Record) - - /** - * The subtitle style object - */ - style?: Partial - - /** - * The subtitle encoding, default utf-8 - */ - encoding?: string - - /** - * Whether use escape, default true - */ - escape?: boolean - - /** - * Change the vtt text - */ - onVttLoad?: (vtt: string) => string -} diff --git a/packages/artplayer/dist/template.ts b/packages/artplayer/dist/template.ts deleted file mode 100644 index 50c346a65..000000000 --- a/packages/artplayer/dist/template.ts +++ /dev/null @@ -1,27 +0,0 @@ -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 -} diff --git a/packages/artplayer/dist/utils.ts b/packages/artplayer/dist/utils.ts deleted file mode 100644 index 63229ca7f..000000000 --- a/packages/artplayer/dist/utils.ts +++ /dev/null @@ -1,73 +0,0 @@ -export interface Utils { - isBrowser: boolean - userAgent: string - isMobile: boolean - isSafari: boolean - isIOS: boolean - isIOS13: boolean - - query: (selector: string, parent?: Document | HTMLElement) => T | null - queryAll: (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: (tag: K) => HTMLElementTagNameMap[K] - setStyle: ( - element: HTMLElement, - key: T, - value: string | CSSStyleDeclaration[T], - ) => HTMLElement - setStyles: (element: HTMLElement, styles: Partial) => 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 - - errorHandle: (condition: T, msg: string) => T extends true ? T : never - silencePromise: (value: T) => T extends Promise ? Promise : T - def: { - /** Historical string-key signature; runtime returns obj. */ - (obj: object, name: string, value: unknown): void - (obj: T, name: PropertyKey, value: PropertyDescriptor & ThisType): T - } - has: (obj: object, name: PropertyKey) => boolean - get: (obj: object, name: PropertyKey) => PropertyDescriptor | undefined - mergeDeep: (...args: T) => T[number] - - sleep: (ms?: number) => Promise - /** Historical return type; runtime discards the callback result and ignores context. */ - debounce: any>(func: F, wait: number, context?: object) => (...args: Parameters) => ReturnType - /** Historical return type; runtime discards the callback result. */ - throttle: any>(func: F, wait: number) => (...args: Parameters) => ReturnType - - 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 -} diff --git a/refactor/baselines/library-public-validation.json b/refactor/baselines/library-public-validation.json new file mode 100644 index 000000000..795c0a672 --- /dev/null +++ b/refactor/baselines/library-public-validation.json @@ -0,0 +1,97 @@ +{ + "schemaVersion": 1, + "task": "ENG-12", + "date": "2026-09-13", + "baseCommit": "38355ae4cf058053d050a69625808af0b18290ff", + "worktreeScope": "CORE-25 default fix and tests were also present; their runtime acceptance belongs to CORE-25", + "before": { + "archiveSha256": "e742d78759a036df6a745973e053b272447e879f139f3641d909fa261f9360b3", + "copiedSources": [ + "package/dist/artplayer.cts", + "package/dist/artplayer.mts", + "package/dist/artplayer.ts", + "package/dist/component.ts", + "package/dist/config.ts", + "package/dist/cssVar.ts", + "package/dist/emitter.ts", + "package/dist/events.ts", + "package/dist/i18n.ts", + "package/dist/icons.ts", + "package/dist/language.cts", + "package/dist/language.mts", + "package/dist/legacy/language.ts", + "package/dist/option.ts", + "package/dist/playback.ts", + "package/dist/player.ts", + "package/dist/plugin.ts", + "package/dist/quality.ts", + "package/dist/runtime.cts", + "package/dist/runtime.mts", + "package/dist/runtime.ts", + "package/dist/runtime/component.ts", + "package/dist/runtime/construction.ts", + "package/dist/runtime/events.ts", + "package/dist/runtime/media.ts", + "package/dist/runtime/option.ts", + "package/dist/runtime/player.ts", + "package/dist/runtime/plugin.ts", + "package/dist/runtime/services.ts", + "package/dist/runtime/setting.ts", + "package/dist/runtime/subtitle.ts", + "package/dist/runtime/template.ts", + "package/dist/runtime/utils.ts", + "package/dist/setting.ts", + "package/dist/subtitle.ts", + "package/dist/template.ts", + "package/dist/utils.ts" + ] + }, + "after": { + "archiveSha256": "9e2fcf57f3ad0c9eba9e50aea4118b053c36616a905ffe14a1c0a69cfcb47f2b", + "remainingFiles": 68, + "allRemainingMemberBytesIdentical": true + }, + "fixture": { + "before": "Private declaration source was copied", + "after": "all 3 real Vite formats omit private .ts and unrelated .txt", + "focusedTests": 3 + }, + "build": { + "command": "yarn ci:build", + "libraries": 21, + "imports": 3, + "seconds": 72.79, + "declarationsChanged": 0, + "exitCode": 0 + }, + "packageCheck": { + "command": "yarn test:package:release", + "exitCode": 0, + "includesUncommittedCore25": true + }, + "incidentalGeneratedFilesRestored": 58, + "newGeneratedDocsArchived": 13, + "logs": [ + { + "file": "refactor/.cache/eng12-build-before.log", + "sha256": "547c7cbba4362e1f191c7b6da96219a08c1a8a5e410e170f1d19276629cbf9c9" + }, + { + "file": "refactor/.cache/eng12-focused.log", + "sha256": "809b43ea894b0e1eb7d30663667f04befbc964c540f455edbcb0fe84cffc3f72" + }, + { + "file": "refactor/.cache/eng12-build.log", + "sha256": "cbdf8ebacd81a12a97ea27be151e4ac355fa8c86bc4dd1bc4556b0e7c95c8717" + }, + { + "file": "refactor/.cache/eng12-package.log", + "sha256": "e01db4a932d5f596b5c223641ec860e3d1ce10ff289102b451842da2f880bde2" + }, + { + "file": "refactor/.cache/eng12-lint.log", + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + ], + "remoteRun": null +} diff --git a/refactor/build-development.md b/refactor/build-development.md index 7fa347926..845e2ee3a 100644 --- a/refactor/build-development.md +++ b/refactor/build-development.md @@ -2,6 +2,12 @@ ENG-06 保留原来的 Vite 7.3.6、Terser、三种库产物及路径,增加选包参数和 TS 入口;未切换 bundler 或运行时依赖。固定工具链仍为 Node 24.21.0 / Yarn 1.22.22。 +ENG-12 将库配置的 publicDir 设为 false,防止 core/public 的声明源码被复制到 dist。 +库静态资源须通过已有显式 import/构建入口处理;文档站仍使用独立 VitePress 配置。 +打包检查拒绝非声明形式的 .ts/.cts/.mts,保留 .d.ts/.d.cts/.d.mts; +实际三格式构建回归见 test/library-build.test.js 和 +[修复记录](changes/2026-09-13-ENG-12-library-public.md)。 + ```sh yarn build # TTY 中原交互选择 yarn build artplayer # 一个包,无交互 diff --git a/refactor/changes/2026-09-13-ENG-12-library-public.md b/refactor/changes/2026-09-13-ENG-12-library-public.md new file mode 100644 index 000000000..c9783f18e --- /dev/null +++ b/refactor/changes/2026-09-13-ENG-12-library-public.md @@ -0,0 +1,31 @@ +# ENG-12 隔离库构建的 public 声明源码 + +CORE-25 生成产物时 Vite 复制 public/artplayer.cts 到 dist 触发 Windows copyfile UNKNOWN。 +进一步检查实际 tarball,确认声明源码目录此前被默认 publicDir 当静态资源复制。 +这是重构新增声明源码目录后的分发污染;真实 npm 基线不包含这些错误复制路径。 +不能只重试 Windows 错误而保留复制行为,也不能把偶发 copyfile 错误断言为确定的锁原因。 + +scripts/utils.js 的库配置显式设置 publicDir:false。它用于库 build/dev/i18n;文档站 +使用独立 VitePress 构建。根下实际只有 core 的 public 目录,其他库没有依赖该目录 +复制的资源。此选项行为见 [Vite 文档](https://vite.dev/config/shared-options#publicdir)。 +scripts/package-check.mjs 同时拒绝任意路径中非 .d.ts/.d.cts/.d.mts 的 TS 文件, +防止将来换个目录仍泄漏声明源码;原路径、历史文件和声明存在性检查继续保留。 + +新增 test/library-build.test.js 实际执行三个格式构建,用 public 内的私有 TS 和无关 +文本作反例。修复前稳定失败,修复后 dist 只包含三个 JS 文件,已接入 test:node。 +test/package-check.test.js 覆盖 .ts/.cts/.mts 拒绝与三种声明后缀允许;真实旧候选 +tarball 同样被拒绝。新 tarball 只移除误复制的文件,其他所有成员字节完全一致。 + +完整 yarn ci:build(21 库、i18n、编辑器、文档站、3 项导入)通过;声明生成零变化, +定向三项测试和只读 lint 通过。此时工作区还有 CORE-25 修复和测试,其运行时与浏览器 +验收属于独立 CORE-25;本任务不宣称它已经完成。真实 package:release 也通过,但 +该结果包含 CORE-25 工作区补丁,不代表仅检出 ENG-12 提交就消除了默认选项缺陷。 +计数、成员与日志摘要见 [证据](../baselines/library-public-validation.json)。 + +完整构建生成的其他包/站点漂移已恢复,新增站点 hash 资源移至忽略缓存留存。 +本提交只包含构建策略、包成员检查、测试/文档以及构建删除的 core 错误复制源码; +CORE-25 的三个 JS 产物与源码保留到其自己的提交。没有手改生成代码,也没有新依赖。 + +后续 AI 添加库静态资源时应显式设计资源入口和包成员检查,不重开隐式 public 复制。 +回退需同时恢复配置和检查,但会重新引入已证明的分发污染,不能直接拿来发布。 +独立提交主题:fix(build): [ENG-12] exclude declaration sources from library artifacts。 diff --git a/refactor/plan.md b/refactor/plan.md index 8d32a1dc8..1c06f1e69 100644 --- a/refactor/plan.md +++ b/refactor/plan.md @@ -2,9 +2,9 @@ > 由 tasks.json 生成。请修改数据后运行 `node refactor/scripts/plan.mjs --write`,不要手改本表。 -基线:`40fcda6a37d0049d42e49c1e64e70d4fd9ba5f7f`。总任务 224 项,范围 22 个包及工作区/示例。 +基线:`40fcda6a37d0049d42e49c1e64e70d4fd9ba5f7f`。总任务 225 项,范围 22 个包及工作区/示例。 -状态:todo 87 / doing 16 / blocked 0 / done 121 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。 +状态:todo 87 / doing 16 / blocked 0 / done 122 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。 前置依赖是启动条件;验收是完成条件。任务可以继续拆分,但不能复用或悄悄删除旧 ID。 @@ -14,7 +14,7 @@ | 包 | 基线版本 | 任务 | | --- | --- | --- | -| artplayer | 5.4.1 | CORE-01, CORE-02, CORE-03, CORE-04, CORE-05, CORE-06, CORE-07, CORE-08, CORE-09, CORE-10, CORE-11, CORE-12, CORE-13, CORE-14, CORE-15, CORE-16, CORE-17, CORE-18, CORE-19, CORE-20, CORE-21, CORE-23, CORE-22, CORE-24, CORE-25 | +| artplayer | 5.4.1 | CORE-01, CORE-02, CORE-03, CORE-04, CORE-05, CORE-06, CORE-07, CORE-08, CORE-09, CORE-10, CORE-11, CORE-12, CORE-13, CORE-14, CORE-15, CORE-16, CORE-17, CORE-18, CORE-19, CORE-20, CORE-21, CORE-23, CORE-22, CORE-24, CORE-25, ENG-12 | | artplayer-plugin-ads | 2.1.0 | PKG-ADS-01, PKG-ADS-02, PKG-ADS-03, PKG-ADS-04, PKG-ADS-05, PKG-ADS-06 | | artplayer-plugin-ambilight | 1.1.0 | PKG-AMBILIGHT-01, PKG-AMBILIGHT-02, PKG-AMBILIGHT-03, PKG-AMBILIGHT-04, PKG-AMBILIGHT-PROXY-01, PKG-AMBILIGHT-05, PKG-AMBILIGHT-06, PKG-FACTORY-01 | | artplayer-plugin-asr | 2.1.0 | PKG-ASR-01, PKG-ASR-02, PKG-ASR-03, PKG-ASR-04, PKG-ASR-05, PKG-ASR-06 | @@ -132,7 +132,7 @@ | CORE-23 | artplayer
检查并补齐键盘、焦点与可访问名称 | CORE-13, CORE-14, CORE-17, ENG-05, BASE-04 | 主要控件/设置/模式退出的键盘与焦点回归、名称和字幕可用性检查及必要兼容修正 | 保持旧快捷键和 DOM/CSS 钩子;真实浏览器验证,不以静态属性检查代替交互;处理 BASE-DOM-01 的主要控件 Tab 不可达,保留既有名称与快捷键 | H | done | | CORE-22 | artplayer
核心阶段完整验收 | CORE-21, CORE-23, PILOT-01, ENG-08, ENG-10, ENG-11 | 核心与旧插件的可自动化完整回归、资源/性能及明确外部验证缺口 | 核心自动化和公开差异处置通过;真实环境缺口链接包集成/REL 门槛,阶段完成不代表可公开发布 | H | done | | CORE-24 | artplayer
修复连续切源的播放意图继承 | CORE-22, PKG-AUDIO-04 | 连续切源保留原播放意图,同时尊重显式暂停与最新来源,回归旧/新 audio | 真实暂停状态的受控测试、重入/取消/失败/销毁、三引擎和 main/legacy 产物验证通过;不恢复过期来源的公开副作用 | H | done | -| CORE-25 | artplayer
修复无 navigator 环境读取默认选项 | CORE-22 | 安全读取默认语言并保留浏览器已有默认值;实际 Node 与发布产物正反例 | 记录旧发布版 ReferenceError;候选在无 navigator 时可读默认选项,浏览器语言和公开类型不回归;不以补全局对象隐藏错误 | M | todo | +| CORE-25 | artplayer
修复无 navigator 环境读取默认选项 | CORE-22, ENG-12 | 安全读取默认语言并保留浏览器已有默认值;实际 Node 与发布产物正反例 | 记录旧发布版 ReferenceError;候选在无 navigator 时可读默认选项,浏览器语言和公开类型不回归;不以补全局对象隐藏错误 | M | todo | ## 5 包迁移:artplayer-plugin-chapter @@ -416,6 +416,12 @@ | --- | --- | --- | --- | --- | --- | --- | | PKG-FACTORY-01 | artplayer-proxy-canvas, artplayer-plugin-ambilight
修复已迁移工厂的反向赋值兼容 | PKG-CANVAS-04, PKG-AMBILIGHT-04, PKG-DPIP-04 | 复现两包旧typeof工厂替换与新.default/可选重载冲突,修复公开类型并补安装消费者、产物和文档 | 默认工厂的历史合法反向赋值继续通过;既有类型/运行时导出逐版本核对,不能只验证Parameters或直接调用 | H | doing | +## 2 测试与工程基础 + +| ID | 范围 / 步骤 | 前置依赖 | 交付物 | 验收条件 | 风险 | 状态 | +| --- | --- | --- | --- | --- | --- | --- | +| ENG-12 | workspace, artplayer
隔离库构建的 public 源码与分发内容 | ENG-03, CORE-21 | 禁用库的隐式 public 复制,拒绝误入包内的 TS 源码,清理生成污染并验证真实构建 | 三格式真实构建和严格 tarball 检查通过;已有声明和所有剩余成员字节不变;文档站使用独立构建 | M | done | + ## 完成证据与阻塞 - DOC-01: [记录](progress.md) @@ -557,3 +563,4 @@ - PKG-TOOL-THUMB-04: [记录](changes/2026-09-13-PKG-TOOL-THUMB-04-runtime-types.md) [记录](baselines/thumbnail-runtime-types-validation.json) [记录](changes/2026-09-13-PKG-TOOL-THUMB-04-public-types.md) [记录](baselines/thumbnail-public-types-validation.json) [记录](changes/2026-09-13-PKG-TOOL-THUMB-04-emitter.md) [记录](baselines/thumbnail-emitter-validation.json) - PKG-FACTORY-01: [记录](baselines/factory-assignment-gaps.json) [记录](baselines/factory-compatibility-proposals.json) [记录](factory-compatibility-decision.md) [记录](changes/2026-09-12-PKG-FACTORY-01-decision.md) - CORE-25: [记录](changes/2026-09-13-CI-01-node-consumers.md) +- ENG-12: [记录](changes/2026-09-13-ENG-12-library-public.md) [记录](baselines/library-public-validation.json) diff --git a/refactor/progress.md b/refactor/progress.md index 261b45d5e..bf82f3549 100644 --- a/refactor/progress.md +++ b/refactor/progress.md @@ -1,5 +1,19 @@ # 进度与证据 +## ENG-12 库声明源码复制修复完成 + +CORE-25 构建期间发现 Vite 默认复制 core/public 到 dist;实际候选 tarball 含 37 个 +误复制的声明源码。库配置现在禁用 publicDir,打包检查拒绝任意路径非声明 TS 后缀。 +三个格式真实磁盘构建反例由失败转通过;旧候选被新检查拒绝,新包去掉 37 个文件, +其余 68 成员字节完全一致。完整 ci:build 的 21 库/i18n/编辑器/文档站/3 导入通过。 +定向 3 项、元数据 9 项和 lint 通过;本任务未另跑完整 ci:check,留给 CORE-25 最终验证。 +见[记录](changes/2026-09-13-ENG-12-library-public.md)和[证据](baselines/library-public-validation.json)。 +恢复 58 个无关生成文件,13 个新增站点 hash 资源移至缓存;保留构建移除的污染文件。 +CORE-25 源码/测试/三个 JS 产物仍在工作区,尚未完成/提交;本提交不包含这些修改。 +225 项:122 done、16 doing、87 todo;202 风险。ENG-DIST-PUBLIC-01 关闭。 +独立本地提交,不推送、不发布;下一步完成 CORE-25 全量验收。 + + ## CI-01 Node 消费者矩阵检查点(doing) 标准 Node 24.21.0 构建同一 core/chapter tarball,20.19.0/22.12.0/24.21.0 实际 diff --git a/refactor/risk-table.md b/refactor/risk-table.md index ccd62459c..515d5dc94 100644 --- a/refactor/risk-table.md +++ b/refactor/risk-table.md @@ -205,3 +205,4 @@ | JASSUB-TYPE-01 | open / 已复现 | JASSUB declared required URLs, Promise methods and resize parameter order differ from actual historical behavior | PKG-JASSUB-04 | | JASSUB-EXPORT-01 | open / 已复现 | JASSUB historical CommonJS object.default changes to a direct factory in 1.1.0 | PKG-JASSUB-04, PKG-JASSUB-06 | | CORE-DEFAULTS-SSR-01 | open / 已复现 | Reading static defaults throws when navigator is absent | CORE-25 | +| ENG-DIST-PUBLIC-01 | resolved / 已复现 | Vite copied authored declarations into library distribution | ENG-12 | diff --git a/refactor/risks.json b/refactor/risks.json index 2113a95b1..da1096b38 100644 --- a/refactor/risks.json +++ b/refactor/risks.json @@ -4514,6 +4514,28 @@ "compatibleResolution": "Read navigator through a guarded global lookup while preserving browser language defaults and public declaration shape.", "closureCriteria": "Published failure remains explicit; source and actual installed candidate defaults work without navigator on selected Node versions and browser language behavior stays unchanged.", "workspaceState": "Node 20.19.0 actual installed probe fails with ReferenceError: navigator is not defined. Published 5.4.0 and candidate 5.4.1 both reproduce under explicitly absent navigator on every selected runtime. CI-01 records this known failure, then compares default values under the same controlled en-US navigator; this is not a production fix." + }, + { + "id": "ENG-DIST-PUBLIC-01", + "title": "Vite copied authored declarations into library distribution", + "confirmation": "reproduced", + "status": "resolved", + "owners": [ + "ENG-12" + ], + "evidence": [ + "test/library-build.test.js", + "refactor/baselines/library-public-validation.json", + "refactor/changes/2026-09-13-ENG-12-library-public.md" + ], + "compatibleResolution": "Disable library publicDir copying and reject non-declaration TypeScript members anywhere in checked tarballs.", + "closureCriteria": "Actual format builds omit public source/resources; dirty historical candidate fails the guard; new archive has no copied sources and preserves other bytes.", + "workspaceState": "Actual candidate had copied authored public TS files in dist; getViteBuildConfig now disables publicDir. Strict member checking rejects the prior archive, and the replacement differs only by source removals.", + "resolutionEvidence": [ + "refactor/baselines/library-public-validation.json", + "refactor/changes/2026-09-13-ENG-12-library-public.md" + ], + "resolutionRationale": "Three-format disk fixture and actual core archive prove removal; all other package members remain byte-identical. Full 21-library and docs build passed. CORE-25 runtime work was present but is not closed by this task." } ] } diff --git a/refactor/tasks.json b/refactor/tasks.json index 454aee62e..a96a571b0 100644 --- a/refactor/tasks.json +++ b/refactor/tasks.json @@ -4490,7 +4490,8 @@ "artplayer" ], "dependsOn": [ - "CORE-22" + "CORE-22", + "ENG-12" ], "status": "todo", "risk": "M", @@ -4499,6 +4500,27 @@ "evidence": [ "changes/2026-09-13-CI-01-node-consumers.md" ] + }, + { + "id": "ENG-12", + "phase": "2 测试与工程基础", + "title": "隔离库构建的 public 源码与分发内容", + "scope": [ + "workspace", + "artplayer" + ], + "dependsOn": [ + "ENG-03", + "CORE-21" + ], + "status": "done", + "risk": "M", + "deliverable": "禁用库的隐式 public 复制,拒绝误入包内的 TS 源码,清理生成污染并验证真实构建", + "acceptance": "三格式真实构建和严格 tarball 检查通过;已有声明和所有剩余成员字节不变;文档站使用独立构建", + "evidence": [ + "changes/2026-09-13-ENG-12-library-public.md", + "baselines/library-public-validation.json" + ] } ] } diff --git a/scripts/package-check.mjs b/scripts/package-check.mjs index 557421890..acfce69ea 100644 --- a/scripts/package-check.mjs +++ b/scripts/package-check.mjs @@ -26,6 +26,7 @@ export function checkFiles(manifest, files, historical = []) { for (const file of historical.filter(file => /^package\/(?:dist|types)\//.test(file))) assert(files.includes(file), `Historical distribution file removed: ${file}`) assert(!files.some(file => /^package\/(?:src|public|node_modules)\//.test(file)), 'Source/dependencies leaked into package') + assert(!files.some(file => /\.[cm]?ts$/.test(file) && !/\.d\.[cm]?ts$/.test(file)), 'Authored TypeScript leaked into package') assert(!files.includes('package/tsconfig.json'), 'Implementation tsconfig leaked into package') } diff --git a/scripts/utils.js b/scripts/utils.js index 5a4b8582f..1da24e90b 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -36,6 +36,7 @@ export function getViteBuildConfig(options) { const config = { configFile: false, + publicDir: false, logLevel: 'warn', build: { outDir, diff --git a/test/library-build.test.js b/test/library-build.test.js new file mode 100644 index 000000000..9b2ba208c --- /dev/null +++ b/test/library-build.test.js @@ -0,0 +1,31 @@ +import assert from 'node:assert/strict' +import fs from 'node:fs' +import path from 'node:path' +// eslint-disable-next-line test/no-import-node-test -- Exercise actual Vite library output on disk. +import test from 'node:test' +import { build } from 'vite' +import { getViteBuildConfig } from '../scripts/utils.js' + +test('Library builds never copy declaration sources or unrelated public resources into dist', async () => { + const parent = fs.realpathSync('refactor/.cache') + const root = fs.mkdtempSync(path.join(parent, 'library-build-')) + try { + fs.mkdirSync(path.join(root, 'src')) + fs.mkdirSync(path.join(root, 'public')) + fs.writeFileSync(path.join(root, 'src/index.ts'), 'export default function answer() { return 42 }\n') + fs.writeFileSync(path.join(root, 'public/internal.ts'), 'export type PrivateImplementation = { secret: number }\n') + fs.writeFileSync(path.join(root, 'public/unrelated.txt'), 'must not ship\n') + for (const [format, fileName, target] of [['umd', 'index.js', 'es2020'], ['umd', 'index.legacy.js', 'es2015'], ['es', 'index.mjs', 'es2020']]) { + const config = getViteBuildConfig({ entry: path.join(root, 'src/index.ts'), outDir: path.join(root, 'dist'), name: 'Fixture', format, fileName, target }) + await build({ root, ...config }) + assert(!fs.existsSync(path.join(root, 'dist/internal.ts')), 'Private declaration source was copied') + assert(!fs.existsSync(path.join(root, 'dist/unrelated.txt')), 'Unrelated public asset was copied') + } + assert.deepEqual(fs.readdirSync(path.join(root, 'dist')).sort(), ['index.js', 'index.legacy.js', 'index.mjs']) + } + finally { + assert.equal(path.dirname(fs.realpathSync(root)), parent) + assert(path.basename(root).startsWith('library-build-')) + fs.rmSync(root, { recursive: true, force: true }) + } +}) diff --git a/test/package-check.test.js b/test/package-check.test.js index 5fc88ee62..5f0b5b6e9 100644 --- a/test/package-check.test.js +++ b/test/package-check.test.js @@ -16,6 +16,9 @@ test('Package checks reject missing files, missing wildcard exports and internal assert.throws(() => checkFiles(manifest, [...files, 'package/tsconfig.json']), /tsconfig/) for (const source of ['src/internal.ts', 'public/artplayer.ts', 'node_modules/private/index.js']) assert.throws(() => checkFiles(manifest, [...files, `package/${source}`]), /Source\/dependencies/) + for (const source of ['dist/internal.ts', 'dist/internal.cts', 'dist/internal.mts']) + assert.throws(() => checkFiles(manifest, [...files, `package/${source}`]), /Authored TypeScript/) + checkFiles(manifest, [...files, 'package/types/entry.d.cts', 'package/types/entry.d.mts']) assert.throws(() => checkFiles(manifest, files, ['package/dist/old.js']), /Historical/) })