@videojs/html 0.1.0-preview.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +26 -0
- package/dist/button-Bu1mGG-F.js +63 -0
- package/dist/button-Bu1mGG-F.js.map +1 -0
- package/dist/component-factory-vR-5t251.js +95 -0
- package/dist/component-factory-vR-5t251.js.map +1 -0
- package/dist/current-time-display-BNvqKqSQ.js +36 -0
- package/dist/current-time-display-BNvqKqSQ.js.map +1 -0
- package/dist/custom-element-3bDlB2XO.js +10 -0
- package/dist/custom-element-3bDlB2XO.js.map +1 -0
- package/dist/define/index.d.ts +12 -0
- package/dist/define/index.js +27 -0
- package/dist/define/media-container.d.ts +1 -0
- package/dist/define/media-container.js +3 -0
- package/dist/define/media-current-time-display.d.ts +1 -0
- package/dist/define/media-current-time-display.js +4 -0
- package/dist/define/media-duration-display.d.ts +1 -0
- package/dist/define/media-duration-display.js +4 -0
- package/dist/define/media-fullscreen-button.d.ts +1 -0
- package/dist/define/media-fullscreen-button.js +5 -0
- package/dist/define/media-mute-button.d.ts +1 -0
- package/dist/define/media-mute-button.js +5 -0
- package/dist/define/media-play-button.d.ts +1 -0
- package/dist/define/media-play-button.js +5 -0
- package/dist/define/media-popover.d.ts +1 -0
- package/dist/define/media-popover.js +4 -0
- package/dist/define/media-preview-time-display.d.ts +1 -0
- package/dist/define/media-preview-time-display.js +4 -0
- package/dist/define/media-time-slider.d.ts +1 -0
- package/dist/define/media-time-slider.js +4 -0
- package/dist/define/media-tooltip.d.ts +1 -0
- package/dist/define/media-tooltip.js +5 -0
- package/dist/define/media-volume-slider.d.ts +1 -0
- package/dist/define/media-volume-slider.js +4 -0
- package/dist/define/video-provider.d.ts +1 -0
- package/dist/define/video-provider.js +3 -0
- package/dist/duration-display-Dtl2RCNd.js +44 -0
- package/dist/duration-display-Dtl2RCNd.js.map +1 -0
- package/dist/fullscreen-button-CKOv8Ywh.js +40 -0
- package/dist/fullscreen-button-CKOv8Ywh.js.map +1 -0
- package/dist/icons-CuxuONCk.js +209 -0
- package/dist/icons-CuxuONCk.js.map +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +2 -0
- package/dist/index-LKrIp3Oo.d.ts +1 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/media-container-BOL0PKuG.js +80 -0
- package/dist/media-container-BOL0PKuG.js.map +1 -0
- package/dist/media-container-ChS9lZvf.d.ts +1 -0
- package/dist/media-container-DwKSOa1h.js +8 -0
- package/dist/media-container-DwKSOa1h.js.map +1 -0
- package/dist/media-current-time-display-Cd0rPAuj.d.ts +1 -0
- package/dist/media-current-time-display-Cr2LJaRo.js +8 -0
- package/dist/media-current-time-display-Cr2LJaRo.js.map +1 -0
- package/dist/media-duration-display-6KTtxmm3.js +8 -0
- package/dist/media-duration-display-6KTtxmm3.js.map +1 -0
- package/dist/media-duration-display-qvm6YX-q.d.ts +1 -0
- package/dist/media-fullscreen-button-BgUK3lgu.d.ts +1 -0
- package/dist/media-fullscreen-button-CiG60HOW.js +8 -0
- package/dist/media-fullscreen-button-CiG60HOW.js.map +1 -0
- package/dist/media-mute-button-DXq-JKvc.js +8 -0
- package/dist/media-mute-button-DXq-JKvc.js.map +1 -0
- package/dist/media-mute-button-NVJF2EEW.d.ts +1 -0
- package/dist/media-play-button-Wt6RbYe5.js +8 -0
- package/dist/media-play-button-Wt6RbYe5.js.map +1 -0
- package/dist/media-play-button-oq8yDlxe.d.ts +1 -0
- package/dist/media-popover-BtJmPv0E.d.ts +1 -0
- package/dist/media-popover-CpbBQOK2.js +8 -0
- package/dist/media-popover-CpbBQOK2.js.map +1 -0
- package/dist/media-preview-time-display-4YX5Rics.d.ts +1 -0
- package/dist/media-preview-time-display-DF6tOv7J.js +8 -0
- package/dist/media-preview-time-display-DF6tOv7J.js.map +1 -0
- package/dist/media-skin-CxnuHwhu.js +36 -0
- package/dist/media-skin-CxnuHwhu.js.map +1 -0
- package/dist/media-skin-Di3vSHvS.d.ts +11 -0
- package/dist/media-skin-Di3vSHvS.d.ts.map +1 -0
- package/dist/media-time-slider-DFfiWHUh.js +12 -0
- package/dist/media-time-slider-DFfiWHUh.js.map +1 -0
- package/dist/media-time-slider-DvMnfYXZ.d.ts +1 -0
- package/dist/media-tooltip-BqV17mdM.d.ts +1 -0
- package/dist/media-tooltip-RjL5rqLT.js +8 -0
- package/dist/media-tooltip-RjL5rqLT.js.map +1 -0
- package/dist/media-volume-slider-DHV-7FOd.js +11 -0
- package/dist/media-volume-slider-DHV-7FOd.js.map +1 -0
- package/dist/media-volume-slider-DP47VLVi.d.ts +1 -0
- package/dist/mute-button-BCN9DDLN.js +39 -0
- package/dist/mute-button-BCN9DDLN.js.map +1 -0
- package/dist/play-button-DP8VldNs.js +40 -0
- package/dist/play-button-DP8VldNs.js.map +1 -0
- package/dist/popover-ah61j3HR.js +63 -0
- package/dist/popover-ah61j3HR.js.map +1 -0
- package/dist/preview-time-display-DwLOj4CJ.js +36 -0
- package/dist/preview-time-display-DwLOj4CJ.js.map +1 -0
- package/dist/skins/frosted.d.ts +23 -0
- package/dist/skins/frosted.d.ts.map +1 -0
- package/dist/skins/frosted.js +145 -0
- package/dist/skins/frosted.js.map +1 -0
- package/dist/skins/minimal.d.ts +23 -0
- package/dist/skins/minimal.d.ts.map +1 -0
- package/dist/skins/minimal.js +150 -0
- package/dist/skins/minimal.js.map +1 -0
- package/dist/store.d.ts +1 -0
- package/dist/store.js +0 -0
- package/dist/time-slider-DBWcZzRe.js +141 -0
- package/dist/time-slider-DBWcZzRe.js.map +1 -0
- package/dist/tooltip-O0U-gkDS.js +23 -0
- package/dist/tooltip-O0U-gkDS.js.map +1 -0
- package/dist/video-provider-Bj9JwzDx.js +23 -0
- package/dist/video-provider-Bj9JwzDx.js.map +1 -0
- package/dist/video-provider-HuYjfSUk.js +8 -0
- package/dist/video-provider-HuYjfSUk.js.map +1 -0
- package/dist/video-provider-nSCfwA7l.d.ts +1 -0
- package/dist/volume-slider-cwSYSsFC.js +118 -0
- package/dist/volume-slider-cwSYSsFC.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2025-present Video.js contributors
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
14
|
+
|
|
15
|
+
------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
Trademark Notice:
|
|
18
|
+
“Video.js” is a registered trademark of Brightcove Inc.
|
|
19
|
+
The project is maintained independently by the open-source community,
|
|
20
|
+
governed by the Video.js Technical Steering Committee.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @videojs/html
|
|
2
|
+
|
|
3
|
+
[![package-badge]][package]
|
|
4
|
+
|
|
5
|
+
> **⚠️ Technical Preview - SUBJECT TO CHANGE** Not recommended for production use.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`@videojs/html` is a comprehensive library for building media players with vanilla JavaScript and Web Components. It provides a complete set of UI components, state management, and utilities for creating feature-rich, accessible video and audio players.
|
|
10
|
+
|
|
11
|
+
## Community
|
|
12
|
+
|
|
13
|
+
If you need help with anything related to Video.js 10, or if you'd like to casually chat with other
|
|
14
|
+
members:
|
|
15
|
+
|
|
16
|
+
- [Join Discord Server][discord]
|
|
17
|
+
- [See GitHub Discussions][gh-discussions]
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
[Apache-2.0](./LICENSE)
|
|
22
|
+
|
|
23
|
+
[package]: https://www.npmjs.com/package/@videojs/html
|
|
24
|
+
[package-badge]: https://img.shields.io/npm/v/@videojs/html/next?label=@videojs/html@next
|
|
25
|
+
[discord]: https://discord.gg/JBqHh485uF
|
|
26
|
+
[gh-discussions]: https://github.com/videojs/v10/discussions
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { namedNodeMapToObject } from "@videojs/utils/dom";
|
|
2
|
+
|
|
3
|
+
//#region src/elements/button.ts
|
|
4
|
+
function getTemplateHTML(_attrs, _props = {}) {
|
|
5
|
+
return `
|
|
6
|
+
<style>
|
|
7
|
+
/*
|
|
8
|
+
NOTE: Even though primitives should aim to be "unstyled" in their core definitions, we should
|
|
9
|
+
still add pointer-events, as this defines functionality. (CJP)
|
|
10
|
+
*/
|
|
11
|
+
:host {
|
|
12
|
+
pointer-events: auto;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
<slot>
|
|
16
|
+
</slot>
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
var ButtonElement = class extends HTMLElement {
|
|
20
|
+
static {
|
|
21
|
+
this.shadowRootOptions = { mode: "open" };
|
|
22
|
+
}
|
|
23
|
+
static {
|
|
24
|
+
this.getTemplateHTML = getTemplateHTML;
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.observedAttributes = ["commandfor"];
|
|
28
|
+
}
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
if (!this.shadowRoot) {
|
|
32
|
+
this.attachShadow(this.constructor.shadowRootOptions);
|
|
33
|
+
const attrs = namedNodeMapToObject(this.attributes);
|
|
34
|
+
const html = this.constructor.getTemplateHTML(attrs);
|
|
35
|
+
const shadowRoot = this.shadowRoot;
|
|
36
|
+
shadowRoot.setHTMLUnsafe ? shadowRoot.setHTMLUnsafe(html) : shadowRoot.innerHTML = html;
|
|
37
|
+
}
|
|
38
|
+
this.addEventListener("click", this);
|
|
39
|
+
this.addEventListener("keydown", this);
|
|
40
|
+
}
|
|
41
|
+
attributeChangedCallback(name, _oldValue, newValue) {
|
|
42
|
+
if (name === "commandfor") this.style.setProperty("anchor-name", `--${newValue}`);
|
|
43
|
+
}
|
|
44
|
+
handleEvent(event) {
|
|
45
|
+
const { type } = event;
|
|
46
|
+
if (type === "keydown") this.#handleKeyDown(event);
|
|
47
|
+
}
|
|
48
|
+
#handleKeyDown = (event) => {
|
|
49
|
+
const { metaKey, altKey, key } = event;
|
|
50
|
+
if (metaKey || altKey || !["Enter", " "].includes(key)) {
|
|
51
|
+
this.removeEventListener("keyup", this.#handleKeyUp);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.addEventListener("keyup", this.#handleKeyUp, { once: true });
|
|
55
|
+
};
|
|
56
|
+
#handleKeyUp = (_event) => {
|
|
57
|
+
this.handleEvent({ type: "click" });
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ButtonElement as t };
|
|
63
|
+
//# sourceMappingURL=button-Bu1mGG-F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-Bu1mGG-F.js","names":["#handleKeyDown","#handleKeyUp"],"sources":["../src/elements/button.ts"],"sourcesContent":["import { namedNodeMapToObject } from '@videojs/utils/dom';\n\nexport function getTemplateHTML(\n this: typeof ButtonElement,\n _attrs: Record<string, string>,\n _props: Record<string, any> = {},\n): string {\n return /* html */ `\n <style>\n /*\n NOTE: Even though primitives should aim to be \"unstyled\" in their core definitions, we should\n still add pointer-events, as this defines functionality. (CJP)\n */\n :host {\n pointer-events: auto;\n }\n </style>\n <slot>\n </slot>\n `;\n}\n\nexport class ButtonElement extends HTMLElement {\n static shadowRootOptions = {\n mode: 'open' as ShadowRootMode,\n };\n\n static getTemplateHTML: typeof getTemplateHTML = getTemplateHTML;\n\n static observedAttributes: string[] = ['commandfor'];\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n // Set up the Shadow DOM if not using Declarative Shadow DOM.\n this.attachShadow((this.constructor as typeof ButtonElement).shadowRootOptions);\n\n const attrs = namedNodeMapToObject(this.attributes);\n const html = (this.constructor as typeof ButtonElement).getTemplateHTML(attrs);\n // From MDN: setHTMLUnsafe should be used instead of ShadowRoot.innerHTML\n // when a string of HTML may contain declarative shadow roots.\n const shadowRoot = this.shadowRoot as unknown as ShadowRoot;\n shadowRoot.setHTMLUnsafe ? shadowRoot.setHTMLUnsafe(html) : (shadowRoot.innerHTML = html);\n }\n\n this.addEventListener('click', this);\n this.addEventListener('keydown', this);\n }\n\n attributeChangedCallback(name: string, _oldValue: string, newValue: string): void {\n if (name === 'commandfor') {\n this.style.setProperty('anchor-name', `--${newValue}`);\n }\n }\n\n handleEvent(event: Event): void {\n const { type } = event;\n if (type === 'keydown') {\n this.#handleKeyDown(event as KeyboardEvent);\n }\n }\n\n #handleKeyDown = (event: KeyboardEvent): void => {\n const { metaKey, altKey, key } = event;\n if (metaKey || altKey || !['Enter', ' '].includes(key)) {\n this.removeEventListener('keyup', this.#handleKeyUp);\n return;\n }\n this.addEventListener('keyup', this.#handleKeyUp, { once: true });\n };\n\n #handleKeyUp = (_event: KeyboardEvent): void => {\n this.handleEvent({ type: 'click' } as Event);\n };\n}\n"],"mappings":";;;AAEA,SAAgB,gBAEd,QACA,SAA8B,EAAE,EACxB;AACR,QAAkB;;;;;;;;;;;;;;AAepB,IAAa,gBAAb,cAAmC,YAAY;;2BAClB,EACzB,MAAM,QACP;;;yBAEgD;;;4BAEX,CAAC,aAAa;;CAEpD,cAAc;AACZ,SAAO;AAEP,MAAI,CAAC,KAAK,YAAY;AAEpB,QAAK,aAAc,KAAK,YAAqC,kBAAkB;GAE/E,MAAM,QAAQ,qBAAqB,KAAK,WAAW;GACnD,MAAM,OAAQ,KAAK,YAAqC,gBAAgB,MAAM;GAG9E,MAAM,aAAa,KAAK;AACxB,cAAW,gBAAgB,WAAW,cAAc,KAAK,GAAI,WAAW,YAAY;;AAGtF,OAAK,iBAAiB,SAAS,KAAK;AACpC,OAAK,iBAAiB,WAAW,KAAK;;CAGxC,yBAAyB,MAAc,WAAmB,UAAwB;AAChF,MAAI,SAAS,aACX,MAAK,MAAM,YAAY,eAAe,KAAK,WAAW;;CAI1D,YAAY,OAAoB;EAC9B,MAAM,EAAE,SAAS;AACjB,MAAI,SAAS,UACX,OAAKA,cAAe,MAAuB;;CAI/C,kBAAkB,UAA+B;EAC/C,MAAM,EAAE,SAAS,QAAQ,QAAQ;AACjC,MAAI,WAAW,UAAU,CAAC,CAAC,SAAS,IAAI,CAAC,SAAS,IAAI,EAAE;AACtD,QAAK,oBAAoB,SAAS,MAAKC,YAAa;AACpD;;AAEF,OAAK,iBAAiB,SAAS,MAAKA,aAAc,EAAE,MAAM,MAAM,CAAC;;CAGnE,gBAAgB,WAAgC;AAC9C,OAAK,YAAY,EAAE,MAAM,SAAS,CAAU"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { shallowEqual, toCamelCase } from "@videojs/utils";
|
|
2
|
+
import { ConsumerMixin } from "@open-wc/context-protocol";
|
|
3
|
+
import { setAttributes } from "@videojs/utils/dom";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/component-factory.ts
|
|
6
|
+
let currentCoreInstances = [];
|
|
7
|
+
let currentCoreIndex = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Generic factory function to create connected HTML components using hooks pattern.
|
|
10
|
+
* Provides equivalent functionality to React's toConnectedComponent but for custom elements.
|
|
11
|
+
*
|
|
12
|
+
* @param BaseClass - Base custom element class to extend
|
|
13
|
+
* @param stateHook - Hook that defines state keys and transformation logic
|
|
14
|
+
* @param propsHook - Hook that handles element attributes and properties based on state
|
|
15
|
+
* @param displayName - Display name for debugging
|
|
16
|
+
* @returns Connected custom element class with media store integration
|
|
17
|
+
*/
|
|
18
|
+
function toConnectedHTMLComponent(BaseClass, stateHook, propsHook, displayName) {
|
|
19
|
+
const ConnectedComponent = class extends ConsumerMixin(BaseClass) {
|
|
20
|
+
constructor(..._args) {
|
|
21
|
+
super(..._args);
|
|
22
|
+
this.contexts = { mediaStore: (mediaStore) => {
|
|
23
|
+
this.#mediaStore = mediaStore;
|
|
24
|
+
mediaStore.subscribe(() => {
|
|
25
|
+
this.#render();
|
|
26
|
+
for (const instance of this.#coreInstances) if (!instance.listening) {
|
|
27
|
+
instance.listening = true;
|
|
28
|
+
instance.core.subscribe(this.#render);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
} };
|
|
32
|
+
}
|
|
33
|
+
static get observedAttributes() {
|
|
34
|
+
return [...super.observedAttributes ?? []];
|
|
35
|
+
}
|
|
36
|
+
#mediaStore;
|
|
37
|
+
#coreInstances = [];
|
|
38
|
+
#render = () => {
|
|
39
|
+
if (!this.#mediaStore) return;
|
|
40
|
+
currentCoreIndex = 0;
|
|
41
|
+
currentCoreInstances = this.#coreInstances;
|
|
42
|
+
const state = stateHook?.(this, this.#mediaStore);
|
|
43
|
+
const props = propsHook(this, state ?? {});
|
|
44
|
+
this._update(props, state, this.#mediaStore);
|
|
45
|
+
};
|
|
46
|
+
_update(props, state, _mediaStore) {
|
|
47
|
+
this._state = state;
|
|
48
|
+
super._update?.(props, state, _mediaStore);
|
|
49
|
+
setAttributes(this, props);
|
|
50
|
+
}
|
|
51
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
52
|
+
super.attributeChangedCallback?.(name, oldValue, newValue);
|
|
53
|
+
this.#render();
|
|
54
|
+
}
|
|
55
|
+
connectedCallback() {
|
|
56
|
+
super.connectedCallback?.();
|
|
57
|
+
}
|
|
58
|
+
disconnectedCallback() {
|
|
59
|
+
super.disconnectedCallback?.();
|
|
60
|
+
}
|
|
61
|
+
handleEvent(event) {
|
|
62
|
+
super.handleEvent?.(event);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (displayName) Object.defineProperty(ConnectedComponent, "name", { value: displayName });
|
|
66
|
+
return ConnectedComponent;
|
|
67
|
+
}
|
|
68
|
+
function getCoreState(CoreClass, state) {
|
|
69
|
+
let core = currentCoreInstances[currentCoreIndex]?.core;
|
|
70
|
+
if (!core) {
|
|
71
|
+
core = new CoreClass();
|
|
72
|
+
currentCoreInstances[currentCoreIndex] = {
|
|
73
|
+
core,
|
|
74
|
+
listening: false
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
currentCoreIndex++;
|
|
78
|
+
const coreState = core.getState();
|
|
79
|
+
const oldState = {};
|
|
80
|
+
for (const key in state) oldState[key] = coreState[key];
|
|
81
|
+
if (!shallowEqual(oldState, state)) core.setState(state);
|
|
82
|
+
return core.getState();
|
|
83
|
+
}
|
|
84
|
+
function getPropsFromAttrs(element) {
|
|
85
|
+
const props = {};
|
|
86
|
+
for (const attr of element.attributes) {
|
|
87
|
+
const camelName = toCamelCase(attr.name);
|
|
88
|
+
props[camelName] = element[camelName];
|
|
89
|
+
}
|
|
90
|
+
return props;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { getPropsFromAttrs as n, toConnectedHTMLComponent as r, getCoreState as t };
|
|
95
|
+
//# sourceMappingURL=component-factory-vR-5t251.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-factory-vR-5t251.js","names":["currentCoreInstances: any[]","currentCoreIndex: number","#mediaStore","#render","#coreInstances","oldState: Record<string, any>","props: Record<string, any>"],"sources":["../src/utils/component-factory.ts"],"sourcesContent":["import type { MediaStore } from '@videojs/core/store';\nimport { ConsumerMixin } from '@open-wc/context-protocol';\nimport { shallowEqual, toCamelCase } from '@videojs/utils';\nimport { setAttributes } from '@videojs/utils/dom';\n\n/**\n * Generic types for HTML component hooks pattern\n * Mirrors the React hooks architecture for consistency\n */\nexport type StateHook<E extends HTMLElement, T = any> = (element: E, mediaStore: MediaStore) => T;\n\nexport type PropsHook<E extends HTMLElement, T = any, P = any> = (element: E, state: T) => P;\n\nexport interface ConnectedComponentConstructor<E extends HTMLElement, State> {\n new (state: State): E;\n}\n\nlet currentCoreInstances: any[] = [];\n// There might be multiple getCoreState calls in a single state hook\n// which should create a different core instance.\nlet currentCoreIndex: number = 0;\n\n/**\n * Generic factory function to create connected HTML components using hooks pattern.\n * Provides equivalent functionality to React's toConnectedComponent but for custom elements.\n *\n * @param BaseClass - Base custom element class to extend\n * @param stateHook - Hook that defines state keys and transformation logic\n * @param propsHook - Hook that handles element attributes and properties based on state\n * @param displayName - Display name for debugging\n * @returns Connected custom element class with media store integration\n */\nexport function toConnectedHTMLComponent<E extends HTMLElement, State = any>(\n BaseClass: CustomElementConstructor,\n stateHook: StateHook<E, State> | undefined,\n propsHook: PropsHook<E, State>,\n displayName?: string,\n): ConnectedComponentConstructor<E, State> {\n const ConnectedComponent = class extends ConsumerMixin(BaseClass) {\n static get observedAttributes(): string[] {\n return [\n // @ts-expect-error ts(2339)\n ...(super.observedAttributes ?? []),\n ];\n }\n\n _state: State | undefined;\n #mediaStore: MediaStore | undefined;\n #coreInstances: { core: any; listening: boolean }[] = [];\n\n contexts = {\n mediaStore: (mediaStore: any) => {\n this.#mediaStore = mediaStore;\n\n // Subscribe to media store state changes\n mediaStore.subscribe(() => {\n this.#render();\n\n for (const instance of this.#coreInstances) {\n if (!instance.listening) {\n instance.listening = true;\n instance.core.subscribe(this.#render);\n }\n }\n });\n },\n };\n\n #render = (): void => {\n if (!this.#mediaStore) return;\n\n currentCoreIndex = 0;\n currentCoreInstances = this.#coreInstances;\n\n // Split into two phases: state transformation, then props update\n const state = stateHook?.(this as unknown as E, this.#mediaStore);\n const props = propsHook(this as unknown as E, state ?? {} as State);\n this._update(props, state, this.#mediaStore);\n };\n\n _update(props: any, state: State | undefined, _mediaStore: MediaStore): void {\n this._state = state;\n // @ts-expect-error any\n super._update?.(props, state, _mediaStore);\n setAttributes(this, props);\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string): void {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n this.#render();\n }\n\n connectedCallback(): void {\n super.connectedCallback?.();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n }\n\n handleEvent(event: CustomEvent): void {\n // @ts-expect-error any\n super.handleEvent?.(event);\n }\n };\n\n // Set display name for debugging and dev tools\n if (displayName) {\n Object.defineProperty(ConnectedComponent, 'name', { value: displayName });\n }\n\n return ConnectedComponent as unknown as ConnectedComponentConstructor<E, State>;\n}\n\nexport function getCoreState<T extends {\n subscribe: (callback: (state: any) => void) => () => void;\n getState: () => any;\n setState: (state: any) => void;\n}>(CoreClass: new () => T, state: any): any {\n let core = currentCoreInstances[currentCoreIndex]?.core as T;\n if (!core) {\n core = new CoreClass();\n currentCoreInstances[currentCoreIndex] = { core, listening: false };\n }\n\n currentCoreIndex++;\n\n const coreState = core.getState();\n const oldState: Record<string, any> = {};\n for (const key in state) {\n oldState[key] = coreState[key];\n }\n // Only set the state if it has changed\n if (!shallowEqual(oldState, state)) {\n core.setState(state);\n }\n\n return core.getState();\n}\n\nexport function getPropsFromAttrs(element: HTMLElement): Record<string, any> {\n const props: Record<string, any> = {};\n for (const attr of element.attributes) {\n const camelName = toCamelCase(attr.name);\n props[camelName] = element[camelName as keyof typeof element];\n }\n return props;\n}\n"],"mappings":";;;;;AAiBA,IAAIA,uBAA8B,EAAE;AAGpC,IAAIC,mBAA2B;;;;;;;;;;;AAY/B,SAAgB,yBACd,WACA,WACA,WACA,aACyC;CACzC,MAAM,qBAAqB,cAAc,cAAc,UAAU,CAAC;;;mBAYrD,EACT,aAAa,eAAoB;AAC/B,UAAKC,aAAc;AAGnB,eAAW,gBAAgB;AACzB,WAAKC,QAAS;AAEd,UAAK,MAAM,YAAY,MAAKC,cAC1B,KAAI,CAAC,SAAS,WAAW;AACvB,eAAS,YAAY;AACrB,eAAS,KAAK,UAAU,MAAKD,OAAQ;;MAGzC;MAEL;;EA3BD,WAAW,qBAA+B;AACxC,UAAO,CAEL,GAAI,MAAM,sBAAsB,EAAE,CACnC;;EAIH;EACA,iBAAsD,EAAE;EAoBxD,gBAAsB;AACpB,OAAI,CAAC,MAAKD,WAAa;AAEvB,sBAAmB;AACnB,0BAAuB,MAAKE;GAG5B,MAAM,QAAQ,YAAY,MAAsB,MAAKF,WAAY;GACjE,MAAM,QAAQ,UAAU,MAAsB,SAAS,EAAE,CAAU;AACnE,QAAK,QAAQ,OAAO,OAAO,MAAKA,WAAY;;EAG9C,QAAQ,OAAY,OAA0B,aAA+B;AAC3E,QAAK,SAAS;AAEd,SAAM,UAAU,OAAO,OAAO,YAAY;AAC1C,iBAAc,MAAM,MAAM;;EAG5B,yBAAyB,MAAc,UAAkB,UAAwB;AAC/E,SAAM,2BAA2B,MAAM,UAAU,SAAS;AAC1D,SAAKC,QAAS;;EAGhB,oBAA0B;AACxB,SAAM,qBAAqB;;EAG7B,uBAA6B;AAC3B,SAAM,wBAAwB;;EAGhC,YAAY,OAA0B;AAEpC,SAAM,cAAc,MAAM;;;AAK9B,KAAI,YACF,QAAO,eAAe,oBAAoB,QAAQ,EAAE,OAAO,aAAa,CAAC;AAG3E,QAAO;;AAGT,SAAgB,aAIb,WAAwB,OAAiB;CAC1C,IAAI,OAAO,qBAAqB,mBAAmB;AACnD,KAAI,CAAC,MAAM;AACT,SAAO,IAAI,WAAW;AACtB,uBAAqB,oBAAoB;GAAE;GAAM,WAAW;GAAO;;AAGrE;CAEA,MAAM,YAAY,KAAK,UAAU;CACjC,MAAME,WAAgC,EAAE;AACxC,MAAK,MAAM,OAAO,MAChB,UAAS,OAAO,UAAU;AAG5B,KAAI,CAAC,aAAa,UAAU,MAAM,CAChC,MAAK,SAAS,MAAM;AAGtB,QAAO,KAAK,UAAU;;AAGxB,SAAgB,kBAAkB,SAA2C;CAC3E,MAAMC,QAA6B,EAAE;AACrC,MAAK,MAAM,QAAQ,QAAQ,YAAY;EACrC,MAAM,YAAY,YAAY,KAAK,KAAK;AACxC,QAAM,aAAa,QAAQ;;AAE7B,QAAO"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { r as toConnectedHTMLComponent } from "./component-factory-vR-5t251.js";
|
|
2
|
+
import { currentTimeDisplayStateDefinition } from "@videojs/core/store";
|
|
3
|
+
import { formatDisplayTime } from "@videojs/utils";
|
|
4
|
+
|
|
5
|
+
//#region src/elements/current-time-display.ts
|
|
6
|
+
const getCurrentTimeDisplayState = (_element, mediaStore) => {
|
|
7
|
+
return { ...currentTimeDisplayStateDefinition.stateTransform(mediaStore.getState()) };
|
|
8
|
+
};
|
|
9
|
+
const getCurrentTimeDisplayProps = (_element, _state) => {
|
|
10
|
+
return {};
|
|
11
|
+
};
|
|
12
|
+
var CurrentTimeDisplay = class extends HTMLElement {
|
|
13
|
+
static {
|
|
14
|
+
this.shadowRootOptions = { mode: "open" };
|
|
15
|
+
}
|
|
16
|
+
static {
|
|
17
|
+
this.observedAttributes = ["show-remaining"];
|
|
18
|
+
}
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
if (!this.shadowRoot) this.attachShadow(this.constructor.shadowRootOptions);
|
|
22
|
+
}
|
|
23
|
+
get showRemaining() {
|
|
24
|
+
return this.hasAttribute("show-remaining");
|
|
25
|
+
}
|
|
26
|
+
_update(_props, state) {
|
|
27
|
+
/** @TODO Should this live here or elsewhere? (CJP) */
|
|
28
|
+
const timeLabel = this.showRemaining && state.duration != null && state.currentTime != null ? formatDisplayTime(-(state.duration - state.currentTime)) : formatDisplayTime(state.currentTime);
|
|
29
|
+
if (this.shadowRoot) this.shadowRoot.textContent = timeLabel;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const CurrentTimeDisplayElement = toConnectedHTMLComponent(CurrentTimeDisplay, getCurrentTimeDisplayState, getCurrentTimeDisplayProps, "CurrentTimeDisplay");
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { CurrentTimeDisplayElement as t };
|
|
36
|
+
//# sourceMappingURL=current-time-display-BNvqKqSQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-time-display-BNvqKqSQ.js","names":["getCurrentTimeDisplayState: StateHook<CurrentTimeDisplay, CurrentTimeDisplayState>","getCurrentTimeDisplayProps: PropsHook<CurrentTimeDisplay, CurrentTimeDisplayState>","CurrentTimeDisplayElement: ConnectedComponentConstructor<CurrentTimeDisplay, CurrentTimeDisplayState>"],"sources":["../src/elements/current-time-display.ts"],"sourcesContent":["import type { CurrentTimeDisplayState } from '@videojs/core/store';\nimport type { ConnectedComponentConstructor, PropsHook, StateHook } from '../utils/component-factory';\n\nimport { currentTimeDisplayStateDefinition } from '@videojs/core/store';\nimport { formatDisplayTime } from '@videojs/utils';\nimport { toConnectedHTMLComponent } from '../utils/component-factory';\n\nexport const getCurrentTimeDisplayState: StateHook<CurrentTimeDisplay, CurrentTimeDisplayState> = (_element, mediaStore) => {\n return {\n ...currentTimeDisplayStateDefinition.stateTransform(mediaStore.getState()),\n // Current time display is read-only, so no request methods needed\n };\n};\n\nexport const getCurrentTimeDisplayProps: PropsHook<CurrentTimeDisplay, CurrentTimeDisplayState> = (_element, _state) => {\n return {};\n};\n\nexport class CurrentTimeDisplay extends HTMLElement {\n static shadowRootOptions = {\n mode: 'open' as ShadowRootMode,\n };\n\n static observedAttributes: string[] = ['show-remaining'];\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow((this.constructor as typeof CurrentTimeDisplay).shadowRootOptions);\n }\n }\n\n get showRemaining(): boolean {\n return this.hasAttribute('show-remaining');\n }\n\n _update(_props: any, state: CurrentTimeDisplayState): void {\n /** @TODO Should this live here or elsewhere? (CJP) */\n const timeLabel\n = this.showRemaining && state.duration != null && state.currentTime != null\n ? formatDisplayTime(-(state.duration - state.currentTime))\n : formatDisplayTime(state.currentTime);\n\n if (this.shadowRoot) {\n this.shadowRoot.textContent = timeLabel;\n }\n }\n}\n\nexport const CurrentTimeDisplayElement: ConnectedComponentConstructor<CurrentTimeDisplay, CurrentTimeDisplayState> = toConnectedHTMLComponent(\n CurrentTimeDisplay,\n getCurrentTimeDisplayState,\n getCurrentTimeDisplayProps,\n 'CurrentTimeDisplay',\n);\n"],"mappings":";;;;;AAOA,MAAaA,8BAAsF,UAAU,eAAe;AAC1H,QAAO,EACL,GAAG,kCAAkC,eAAe,WAAW,UAAU,CAAC,EAE3E;;AAGH,MAAaC,8BAAsF,UAAU,WAAW;AACtH,QAAO,EAAE;;AAGX,IAAa,qBAAb,cAAwC,YAAY;;2BACvB,EACzB,MAAM,QACP;;;4BAEqC,CAAC,iBAAiB;;CAExD,cAAc;AACZ,SAAO;AAEP,MAAI,CAAC,KAAK,WACR,MAAK,aAAc,KAAK,YAA0C,kBAAkB;;CAIxF,IAAI,gBAAyB;AAC3B,SAAO,KAAK,aAAa,iBAAiB;;CAG5C,QAAQ,QAAa,OAAsC;;EAEzD,MAAM,YACF,KAAK,iBAAiB,MAAM,YAAY,QAAQ,MAAM,eAAe,OACnE,kBAAkB,EAAE,MAAM,WAAW,MAAM,aAAa,GACxD,kBAAkB,MAAM,YAAY;AAE1C,MAAI,KAAK,WACP,MAAK,WAAW,cAAc;;;AAKpC,MAAaC,4BAAwG,yBACnH,oBACA,4BACA,4BACA,qBACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/utils/custom-element.ts
|
|
2
|
+
function defineCustomElement(tagName, ctor) {
|
|
3
|
+
if (typeof window === "undefined") return;
|
|
4
|
+
if (window.customElements.get(tagName)) return;
|
|
5
|
+
window.customElements.define(tagName, ctor);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { defineCustomElement as t };
|
|
10
|
+
//# sourceMappingURL=custom-element-3bDlB2XO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-element-3bDlB2XO.js","names":[],"sources":["../src/utils/custom-element.ts"],"sourcesContent":["export function defineCustomElement(tagName: string, ctor: CustomElementConstructor): void {\n if (typeof window === 'undefined') return;\n\n if (window.customElements.get(tagName)) return;\n\n window.customElements.define(tagName, ctor);\n}\n"],"mappings":";AAAA,SAAgB,oBAAoB,SAAiB,MAAsC;AACzF,KAAI,OAAO,WAAW,YAAa;AAEnC,KAAI,OAAO,eAAe,IAAI,QAAQ,CAAE;AAExC,QAAO,eAAe,OAAO,SAAS,KAAK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "../video-provider-nSCfwA7l.js";
|
|
2
|
+
import "../media-container-ChS9lZvf.js";
|
|
3
|
+
import "../media-play-button-oq8yDlxe.js";
|
|
4
|
+
import "../media-mute-button-NVJF2EEW.js";
|
|
5
|
+
import "../media-volume-slider-DP47VLVi.js";
|
|
6
|
+
import "../media-time-slider-DvMnfYXZ.js";
|
|
7
|
+
import "../media-fullscreen-button-BgUK3lgu.js";
|
|
8
|
+
import "../media-duration-display-qvm6YX-q.js";
|
|
9
|
+
import "../media-current-time-display-Cd0rPAuj.js";
|
|
10
|
+
import "../media-preview-time-display-4YX5Rics.js";
|
|
11
|
+
import "../media-popover-BtJmPv0E.js";
|
|
12
|
+
import "../media-tooltip-BqV17mdM.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "../component-factory-vR-5t251.js";
|
|
2
|
+
import "../current-time-display-BNvqKqSQ.js";
|
|
3
|
+
import "../duration-display-Dtl2RCNd.js";
|
|
4
|
+
import "../button-Bu1mGG-F.js";
|
|
5
|
+
import "../fullscreen-button-CKOv8Ywh.js";
|
|
6
|
+
import "../mute-button-BCN9DDLN.js";
|
|
7
|
+
import "../play-button-DP8VldNs.js";
|
|
8
|
+
import "../popover-ah61j3HR.js";
|
|
9
|
+
import "../preview-time-display-DwLOj4CJ.js";
|
|
10
|
+
import "../time-slider-DBWcZzRe.js";
|
|
11
|
+
import "../tooltip-O0U-gkDS.js";
|
|
12
|
+
import "../volume-slider-cwSYSsFC.js";
|
|
13
|
+
import "../media-container-BOL0PKuG.js";
|
|
14
|
+
import "../video-provider-Bj9JwzDx.js";
|
|
15
|
+
import "../custom-element-3bDlB2XO.js";
|
|
16
|
+
import "../video-provider-HuYjfSUk.js";
|
|
17
|
+
import "../media-container-DwKSOa1h.js";
|
|
18
|
+
import "../media-play-button-Wt6RbYe5.js";
|
|
19
|
+
import "../media-mute-button-DXq-JKvc.js";
|
|
20
|
+
import "../media-volume-slider-DHV-7FOd.js";
|
|
21
|
+
import "../media-time-slider-DFfiWHUh.js";
|
|
22
|
+
import "../media-fullscreen-button-CiG60HOW.js";
|
|
23
|
+
import "../media-duration-display-6KTtxmm3.js";
|
|
24
|
+
import "../media-current-time-display-Cr2LJaRo.js";
|
|
25
|
+
import "../media-preview-time-display-DF6tOv7J.js";
|
|
26
|
+
import "../media-popover-CpbBQOK2.js";
|
|
27
|
+
import "../media-tooltip-RjL5rqLT.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-container-ChS9lZvf.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-current-time-display-Cd0rPAuj.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-duration-display-qvm6YX-q.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-fullscreen-button-BgUK3lgu.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-mute-button-NVJF2EEW.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-play-button-oq8yDlxe.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-popover-BtJmPv0E.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-preview-time-display-4YX5Rics.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-time-slider-DvMnfYXZ.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-tooltip-BqV17mdM.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../media-volume-slider-DP47VLVi.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../video-provider-nSCfwA7l.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { r as toConnectedHTMLComponent } from "./component-factory-vR-5t251.js";
|
|
2
|
+
import { durationDisplayStateDefinition } from "@videojs/core/store";
|
|
3
|
+
import { formatDisplayTime } from "@videojs/utils";
|
|
4
|
+
import { namedNodeMapToObject } from "@videojs/utils/dom";
|
|
5
|
+
|
|
6
|
+
//#region src/elements/duration-display.ts
|
|
7
|
+
function getTemplateHTML(_attrs, _props = {}) {
|
|
8
|
+
return `
|
|
9
|
+
<span></span>
|
|
10
|
+
`;
|
|
11
|
+
}
|
|
12
|
+
var DurationDisplay = class extends HTMLElement {
|
|
13
|
+
static {
|
|
14
|
+
this.shadowRootOptions = { mode: "open" };
|
|
15
|
+
}
|
|
16
|
+
static {
|
|
17
|
+
this.getTemplateHTML = getTemplateHTML;
|
|
18
|
+
}
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
if (!this.shadowRoot) {
|
|
22
|
+
this.attachShadow(this.constructor.shadowRootOptions);
|
|
23
|
+
const attrs = namedNodeMapToObject(this.attributes);
|
|
24
|
+
const html = this.constructor.getTemplateHTML(attrs);
|
|
25
|
+
const shadowRoot = this.shadowRoot;
|
|
26
|
+
shadowRoot.setHTMLUnsafe ? shadowRoot.setHTMLUnsafe(html) : shadowRoot.innerHTML = html;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
_update(_props, state) {
|
|
30
|
+
const spanElement = this.shadowRoot?.querySelector("span");
|
|
31
|
+
if (spanElement) spanElement.textContent = formatDisplayTime(state.duration);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const getDurationDisplayState = (_element, mediaStore) => {
|
|
35
|
+
return { ...durationDisplayStateDefinition.stateTransform(mediaStore.getState()) };
|
|
36
|
+
};
|
|
37
|
+
const getDurationDisplayProps = (_element, _state) => {
|
|
38
|
+
return {};
|
|
39
|
+
};
|
|
40
|
+
const DurationDisplayElement = toConnectedHTMLComponent(DurationDisplay, getDurationDisplayState, getDurationDisplayProps, "DurationDisplay");
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { DurationDisplayElement as t };
|
|
44
|
+
//# sourceMappingURL=duration-display-Dtl2RCNd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration-display-Dtl2RCNd.js","names":["getDurationDisplayState: StateHook<DurationDisplay, DurationDisplayState>","getDurationDisplayProps: PropsHook<DurationDisplay, DurationDisplayState>","DurationDisplayElement: ConnectedComponentConstructor<DurationDisplay, DurationDisplayState>"],"sources":["../src/elements/duration-display.ts"],"sourcesContent":["import type { DurationDisplayState } from '@videojs/core/store';\nimport type { ConnectedComponentConstructor, PropsHook, StateHook } from '../utils/component-factory';\n\nimport { durationDisplayStateDefinition } from '@videojs/core/store';\n\nimport { formatDisplayTime } from '@videojs/utils';\nimport { namedNodeMapToObject } from '@videojs/utils/dom';\nimport { toConnectedHTMLComponent } from '../utils/component-factory';\n\nexport function getTemplateHTML(\n this: typeof DurationDisplay,\n _attrs: Record<string, string>,\n _props: Record<string, any> = {},\n) {\n return /* html */ `\n <span></span>\n `;\n}\n\nexport class DurationDisplay extends HTMLElement {\n static shadowRootOptions = {\n mode: 'open' as ShadowRootMode,\n };\n\n static getTemplateHTML: typeof getTemplateHTML = getTemplateHTML;\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow((this.constructor as typeof DurationDisplay).shadowRootOptions);\n\n const attrs = namedNodeMapToObject(this.attributes);\n const html = (this.constructor as typeof DurationDisplay).getTemplateHTML(attrs);\n const shadowRoot = this.shadowRoot as unknown as ShadowRoot;\n shadowRoot.setHTMLUnsafe ? shadowRoot.setHTMLUnsafe(html) : (shadowRoot.innerHTML = html);\n }\n }\n\n _update(_props: any, state: DurationDisplayState): void {\n // Update the span content with formatted duration\n const spanElement = this.shadowRoot?.querySelector('span') as HTMLElement;\n if (spanElement) {\n spanElement.textContent = formatDisplayTime(state.duration);\n }\n }\n}\n\nexport const getDurationDisplayState: StateHook<DurationDisplay, DurationDisplayState> = (_element, mediaStore) => {\n return {\n ...durationDisplayStateDefinition.stateTransform(mediaStore.getState()),\n // Duration display is read-only, so no request methods needed\n };\n};\n\nexport const getDurationDisplayProps: PropsHook<DurationDisplay, DurationDisplayState> = (_element, _state) => {\n return {};\n};\n\nexport const DurationDisplayElement: ConnectedComponentConstructor<DurationDisplay, DurationDisplayState> = toConnectedHTMLComponent(\n DurationDisplay,\n getDurationDisplayState,\n getDurationDisplayProps,\n 'DurationDisplay',\n);\n"],"mappings":";;;;;;AASA,SAAgB,gBAEd,QACA,SAA8B,EAAE,EAChC;AACA,QAAkB;;;;AAKpB,IAAa,kBAAb,cAAqC,YAAY;;2BACpB,EACzB,MAAM,QACP;;;yBAEgD;;CAEjD,cAAc;AACZ,SAAO;AAEP,MAAI,CAAC,KAAK,YAAY;AACpB,QAAK,aAAc,KAAK,YAAuC,kBAAkB;GAEjF,MAAM,QAAQ,qBAAqB,KAAK,WAAW;GACnD,MAAM,OAAQ,KAAK,YAAuC,gBAAgB,MAAM;GAChF,MAAM,aAAa,KAAK;AACxB,cAAW,gBAAgB,WAAW,cAAc,KAAK,GAAI,WAAW,YAAY;;;CAIxF,QAAQ,QAAa,OAAmC;EAEtD,MAAM,cAAc,KAAK,YAAY,cAAc,OAAO;AAC1D,MAAI,YACF,aAAY,cAAc,kBAAkB,MAAM,SAAS;;;AAKjE,MAAaA,2BAA6E,UAAU,eAAe;AACjH,QAAO,EACL,GAAG,+BAA+B,eAAe,WAAW,UAAU,CAAC,EAExE;;AAGH,MAAaC,2BAA6E,UAAU,WAAW;AAC7G,QAAO,EAAE;;AAGX,MAAaC,yBAA+F,yBAC1G,iBACA,yBACA,yBACA,kBACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { r as toConnectedHTMLComponent } from "./component-factory-vR-5t251.js";
|
|
2
|
+
import { t as ButtonElement } from "./button-Bu1mGG-F.js";
|
|
3
|
+
import { fullscreenButtonStateDefinition } from "@videojs/core/store";
|
|
4
|
+
import { memoize } from "@videojs/utils";
|
|
5
|
+
|
|
6
|
+
//#region src/elements/fullscreen-button.ts
|
|
7
|
+
const fullscreenButtonCreateRequestMethods = memoize(fullscreenButtonStateDefinition.createRequestMethods);
|
|
8
|
+
/**
|
|
9
|
+
* FullscreenButton state hook - equivalent to React's useFullscreenButtonState
|
|
10
|
+
* Handles media store state subscription and transformation
|
|
11
|
+
*/
|
|
12
|
+
const getFullscreenButtonState = (_element, mediaStore) => {
|
|
13
|
+
return {
|
|
14
|
+
...fullscreenButtonStateDefinition.stateTransform(mediaStore.getState()),
|
|
15
|
+
...fullscreenButtonCreateRequestMethods(mediaStore.dispatch)
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const getFullscreenButtonProps = (_element, state) => {
|
|
19
|
+
return {
|
|
20
|
+
"data-fullscreen": state.fullscreen,
|
|
21
|
+
role: "button",
|
|
22
|
+
tabindex: "0",
|
|
23
|
+
"aria-label": state.fullscreen ? "exit fullscreen" : "enter fullscreen",
|
|
24
|
+
"data-tooltip": state.fullscreen ? "Exit Fullscreen" : "Enter Fullscreen"
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var FullscreenButton = class extends ButtonElement {
|
|
28
|
+
handleEvent(event) {
|
|
29
|
+
super.handleEvent(event);
|
|
30
|
+
const { type } = event;
|
|
31
|
+
const state = this._state;
|
|
32
|
+
if (state && type === "click") if (state.fullscreen) state.requestExitFullscreen();
|
|
33
|
+
else state.requestEnterFullscreen();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const FullscreenButtonElement = toConnectedHTMLComponent(FullscreenButton, getFullscreenButtonState, getFullscreenButtonProps, "FullscreenButton");
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { FullscreenButtonElement as t };
|
|
40
|
+
//# sourceMappingURL=fullscreen-button-CKOv8Ywh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullscreen-button-CKOv8Ywh.js","names":["getFullscreenButtonState: StateHook<FullscreenButton, FullscreenButtonStateWithMethods>","getFullscreenButtonProps: PropsHook<FullscreenButton, FullscreenButtonStateWithMethods>","FullscreenButtonElement: ConnectedComponentConstructor<FullscreenButton, FullscreenButtonStateWithMethods>"],"sources":["../src/elements/fullscreen-button.ts"],"sourcesContent":["import type { FullscreenButtonState } from '@videojs/core/store';\nimport type { Prettify } from '../types';\nimport type { ConnectedComponentConstructor, PropsHook, StateHook } from '../utils/component-factory';\n\nimport { fullscreenButtonStateDefinition } from '@videojs/core/store';\n\nimport { memoize } from '@videojs/utils';\nimport { toConnectedHTMLComponent } from '../utils/component-factory';\nimport { ButtonElement } from './button';\n\ntype FullscreenButtonStateWithMethods = Prettify<FullscreenButtonState & ReturnType<typeof fullscreenButtonStateDefinition.createRequestMethods>>;\n\nconst fullscreenButtonCreateRequestMethods = memoize(fullscreenButtonStateDefinition.createRequestMethods);\n\n/**\n * FullscreenButton state hook - equivalent to React's useFullscreenButtonState\n * Handles media store state subscription and transformation\n */\nexport const getFullscreenButtonState: StateHook<FullscreenButton, FullscreenButtonStateWithMethods> = (_element, mediaStore) => {\n return {\n ...fullscreenButtonStateDefinition.stateTransform(mediaStore.getState()),\n ...fullscreenButtonCreateRequestMethods(mediaStore.dispatch),\n };\n};\n\nexport const getFullscreenButtonProps: PropsHook<FullscreenButton, FullscreenButtonStateWithMethods> = (_element, state) => {\n const baseProps: Record<string, any> = {\n /** data attributes/props */\n 'data-fullscreen': state.fullscreen,\n /** @TODO Need another state provider in core for i18n (CJP) */\n /** aria attributes/props */\n role: 'button',\n tabindex: '0',\n 'aria-label': state.fullscreen ? 'exit fullscreen' : 'enter fullscreen',\n /** tooltip */\n 'data-tooltip': state.fullscreen ? 'Exit Fullscreen' : 'Enter Fullscreen',\n /** @TODO Figure out how we want to handle attr overrides (e.g. aria-label) (CJP) */\n /** external props spread last to allow for overriding */\n // ...props,\n };\n return baseProps;\n};\n\nexport class FullscreenButton extends ButtonElement {\n _state: FullscreenButtonStateWithMethods | undefined;\n\n handleEvent(event: Event): void {\n super.handleEvent(event);\n\n const { type } = event;\n const state = this._state;\n if (state && type === 'click') {\n if (state.fullscreen) {\n state.requestExitFullscreen();\n } else {\n state.requestEnterFullscreen();\n }\n }\n }\n}\n\nexport const FullscreenButtonElement: ConnectedComponentConstructor<FullscreenButton, FullscreenButtonStateWithMethods> = toConnectedHTMLComponent(\n FullscreenButton,\n getFullscreenButtonState,\n getFullscreenButtonProps,\n 'FullscreenButton',\n);\n"],"mappings":";;;;;;AAYA,MAAM,uCAAuC,QAAQ,gCAAgC,qBAAqB;;;;;AAM1G,MAAaA,4BAA2F,UAAU,eAAe;AAC/H,QAAO;EACL,GAAG,gCAAgC,eAAe,WAAW,UAAU,CAAC;EACxE,GAAG,qCAAqC,WAAW,SAAS;EAC7D;;AAGH,MAAaC,4BAA2F,UAAU,UAAU;AAe1H,QAduC;EAErC,mBAAmB,MAAM;EAGzB,MAAM;EACN,UAAU;EACV,cAAc,MAAM,aAAa,oBAAoB;EAErD,gBAAgB,MAAM,aAAa,oBAAoB;EAIxD;;AAIH,IAAa,mBAAb,cAAsC,cAAc;CAGlD,YAAY,OAAoB;AAC9B,QAAM,YAAY,MAAM;EAExB,MAAM,EAAE,SAAS;EACjB,MAAM,QAAQ,KAAK;AACnB,MAAI,SAAS,SAAS,QACpB,KAAI,MAAM,WACR,OAAM,uBAAuB;MAE7B,OAAM,wBAAwB;;;AAMtC,MAAaC,0BAA6G,yBACxH,kBACA,0BACA,0BACA,mBACD"}
|