@editframe/elements 0.26.3-beta.0 → 0.26.4-beta.0

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.
Files changed (132) hide show
  1. package/package.json +2 -2
  2. package/scripts/build-css.js +3 -3
  3. package/tsdown.config.ts +1 -1
  4. package/src/elements/ContextProxiesController.ts +0 -124
  5. package/src/elements/CrossUpdateController.ts +0 -22
  6. package/src/elements/EFAudio.browsertest.ts +0 -706
  7. package/src/elements/EFAudio.ts +0 -56
  8. package/src/elements/EFCaptions.browsertest.ts +0 -1960
  9. package/src/elements/EFCaptions.ts +0 -823
  10. package/src/elements/EFImage.browsertest.ts +0 -120
  11. package/src/elements/EFImage.ts +0 -113
  12. package/src/elements/EFMedia/AssetIdMediaEngine.test.ts +0 -224
  13. package/src/elements/EFMedia/AssetIdMediaEngine.ts +0 -110
  14. package/src/elements/EFMedia/AssetMediaEngine.browsertest.ts +0 -140
  15. package/src/elements/EFMedia/AssetMediaEngine.ts +0 -385
  16. package/src/elements/EFMedia/BaseMediaEngine.browsertest.ts +0 -400
  17. package/src/elements/EFMedia/BaseMediaEngine.ts +0 -505
  18. package/src/elements/EFMedia/BufferedSeekingInput.browsertest.ts +0 -386
  19. package/src/elements/EFMedia/BufferedSeekingInput.ts +0 -430
  20. package/src/elements/EFMedia/JitMediaEngine.browsertest.ts +0 -226
  21. package/src/elements/EFMedia/JitMediaEngine.ts +0 -256
  22. package/src/elements/EFMedia/audioTasks/makeAudioBufferTask.browsertest.ts +0 -679
  23. package/src/elements/EFMedia/audioTasks/makeAudioBufferTask.ts +0 -117
  24. package/src/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.ts +0 -246
  25. package/src/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.browsertest.ts +0 -59
  26. package/src/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.ts +0 -27
  27. package/src/elements/EFMedia/audioTasks/makeAudioInputTask.browsertest.ts +0 -55
  28. package/src/elements/EFMedia/audioTasks/makeAudioInputTask.ts +0 -53
  29. package/src/elements/EFMedia/audioTasks/makeAudioSeekTask.chunkboundary.regression.browsertest.ts +0 -207
  30. package/src/elements/EFMedia/audioTasks/makeAudioSeekTask.ts +0 -72
  31. package/src/elements/EFMedia/audioTasks/makeAudioSegmentFetchTask.ts +0 -32
  32. package/src/elements/EFMedia/audioTasks/makeAudioSegmentIdTask.ts +0 -29
  33. package/src/elements/EFMedia/audioTasks/makeAudioTasksVideoOnly.browsertest.ts +0 -95
  34. package/src/elements/EFMedia/audioTasks/makeAudioTimeDomainAnalysisTask.ts +0 -184
  35. package/src/elements/EFMedia/shared/AudioSpanUtils.ts +0 -129
  36. package/src/elements/EFMedia/shared/BufferUtils.ts +0 -342
  37. package/src/elements/EFMedia/shared/GlobalInputCache.ts +0 -77
  38. package/src/elements/EFMedia/shared/MediaTaskUtils.ts +0 -44
  39. package/src/elements/EFMedia/shared/PrecisionUtils.ts +0 -46
  40. package/src/elements/EFMedia/shared/RenditionHelpers.browsertest.ts +0 -246
  41. package/src/elements/EFMedia/shared/RenditionHelpers.ts +0 -56
  42. package/src/elements/EFMedia/shared/ThumbnailExtractor.ts +0 -227
  43. package/src/elements/EFMedia/tasks/makeMediaEngineTask.browsertest.ts +0 -167
  44. package/src/elements/EFMedia/tasks/makeMediaEngineTask.ts +0 -88
  45. package/src/elements/EFMedia/videoTasks/MainVideoInputCache.ts +0 -76
  46. package/src/elements/EFMedia/videoTasks/ScrubInputCache.ts +0 -61
  47. package/src/elements/EFMedia/videoTasks/makeScrubVideoBufferTask.ts +0 -114
  48. package/src/elements/EFMedia/videoTasks/makeScrubVideoInitSegmentFetchTask.ts +0 -35
  49. package/src/elements/EFMedia/videoTasks/makeScrubVideoInputTask.ts +0 -52
  50. package/src/elements/EFMedia/videoTasks/makeScrubVideoSeekTask.ts +0 -124
  51. package/src/elements/EFMedia/videoTasks/makeScrubVideoSegmentFetchTask.ts +0 -44
  52. package/src/elements/EFMedia/videoTasks/makeScrubVideoSegmentIdTask.ts +0 -32
  53. package/src/elements/EFMedia/videoTasks/makeUnifiedVideoSeekTask.ts +0 -370
  54. package/src/elements/EFMedia/videoTasks/makeVideoBufferTask.ts +0 -109
  55. package/src/elements/EFMedia.browsertest.ts +0 -872
  56. package/src/elements/EFMedia.ts +0 -341
  57. package/src/elements/EFSourceMixin.ts +0 -60
  58. package/src/elements/EFSurface.browsertest.ts +0 -151
  59. package/src/elements/EFSurface.ts +0 -142
  60. package/src/elements/EFTemporal.browsertest.ts +0 -215
  61. package/src/elements/EFTemporal.ts +0 -800
  62. package/src/elements/EFThumbnailStrip.browsertest.ts +0 -585
  63. package/src/elements/EFThumbnailStrip.media-engine.browsertest.ts +0 -714
  64. package/src/elements/EFThumbnailStrip.ts +0 -906
  65. package/src/elements/EFTimegroup.browsertest.ts +0 -934
  66. package/src/elements/EFTimegroup.ts +0 -882
  67. package/src/elements/EFVideo.browsertest.ts +0 -1482
  68. package/src/elements/EFVideo.ts +0 -564
  69. package/src/elements/EFWaveform.ts +0 -547
  70. package/src/elements/FetchContext.browsertest.ts +0 -401
  71. package/src/elements/FetchMixin.ts +0 -38
  72. package/src/elements/SampleBuffer.ts +0 -94
  73. package/src/elements/TargetController.browsertest.ts +0 -230
  74. package/src/elements/TargetController.ts +0 -224
  75. package/src/elements/TimegroupController.ts +0 -26
  76. package/src/elements/durationConverter.ts +0 -35
  77. package/src/elements/parseTimeToMs.ts +0 -9
  78. package/src/elements/printTaskStatus.ts +0 -16
  79. package/src/elements/renderTemporalAudio.ts +0 -108
  80. package/src/elements/updateAnimations.browsertest.ts +0 -1884
  81. package/src/elements/updateAnimations.ts +0 -217
  82. package/src/elements/util.ts +0 -24
  83. package/src/gui/ContextMixin.browsertest.ts +0 -860
  84. package/src/gui/ContextMixin.ts +0 -562
  85. package/src/gui/Controllable.browsertest.ts +0 -258
  86. package/src/gui/Controllable.ts +0 -41
  87. package/src/gui/EFConfiguration.ts +0 -40
  88. package/src/gui/EFControls.browsertest.ts +0 -389
  89. package/src/gui/EFControls.ts +0 -195
  90. package/src/gui/EFDial.browsertest.ts +0 -84
  91. package/src/gui/EFDial.ts +0 -172
  92. package/src/gui/EFFilmstrip.browsertest.ts +0 -712
  93. package/src/gui/EFFilmstrip.ts +0 -1349
  94. package/src/gui/EFFitScale.ts +0 -152
  95. package/src/gui/EFFocusOverlay.ts +0 -79
  96. package/src/gui/EFPause.browsertest.ts +0 -202
  97. package/src/gui/EFPause.ts +0 -73
  98. package/src/gui/EFPlay.browsertest.ts +0 -202
  99. package/src/gui/EFPlay.ts +0 -73
  100. package/src/gui/EFPreview.ts +0 -74
  101. package/src/gui/EFResizableBox.browsertest.ts +0 -79
  102. package/src/gui/EFResizableBox.ts +0 -898
  103. package/src/gui/EFScrubber.ts +0 -151
  104. package/src/gui/EFTimeDisplay.browsertest.ts +0 -237
  105. package/src/gui/EFTimeDisplay.ts +0 -55
  106. package/src/gui/EFToggleLoop.ts +0 -35
  107. package/src/gui/EFTogglePlay.ts +0 -70
  108. package/src/gui/EFWorkbench.ts +0 -115
  109. package/src/gui/PlaybackController.ts +0 -527
  110. package/src/gui/TWMixin.css +0 -6
  111. package/src/gui/TWMixin.ts +0 -61
  112. package/src/gui/TargetOrContextMixin.ts +0 -185
  113. package/src/gui/currentTimeContext.ts +0 -5
  114. package/src/gui/durationContext.ts +0 -3
  115. package/src/gui/efContext.ts +0 -6
  116. package/src/gui/fetchContext.ts +0 -5
  117. package/src/gui/focusContext.ts +0 -7
  118. package/src/gui/focusedElementContext.ts +0 -5
  119. package/src/gui/playingContext.ts +0 -5
  120. package/src/otel/BridgeSpanExporter.ts +0 -150
  121. package/src/otel/setupBrowserTracing.ts +0 -73
  122. package/src/otel/tracingHelpers.ts +0 -251
  123. package/src/transcoding/cache/RequestDeduplicator.test.ts +0 -170
  124. package/src/transcoding/cache/RequestDeduplicator.ts +0 -65
  125. package/src/transcoding/cache/URLTokenDeduplicator.test.ts +0 -182
  126. package/src/transcoding/cache/URLTokenDeduplicator.ts +0 -101
  127. package/src/transcoding/types/index.ts +0 -312
  128. package/src/transcoding/utils/MediaUtils.ts +0 -63
  129. package/src/transcoding/utils/UrlGenerator.ts +0 -68
  130. package/src/transcoding/utils/constants.ts +0 -36
  131. package/src/utils/LRUCache.test.ts +0 -274
  132. package/src/utils/LRUCache.ts +0 -696
@@ -1,152 +0,0 @@
1
- import { LitElement } from "lit";
2
- import { customElement, state } from "lit/decorators.js";
3
- import { createRef } from "lit/directives/ref.js";
4
-
5
- @customElement("ef-fit-scale")
6
- export class EFFitScale extends LitElement {
7
- containerRef = createRef<HTMLDivElement>();
8
- contentRef = createRef<HTMLSlotElement>();
9
-
10
- createRenderRoot() {
11
- Object.assign(this.style, {
12
- display: "grid",
13
- width: "100%",
14
- height: "100%",
15
- gridTemplateColumns: "100%",
16
- gridTemplateRows: "100%",
17
- overflow: "hidden",
18
- boxSizing: "border-box",
19
- contain: "strict",
20
- position: "relative",
21
- });
22
- this.id = `${this.uniqueId}`;
23
- return this;
24
- }
25
-
26
- uniqueId = Math.random().toString(36).substring(2, 15);
27
-
28
- @state()
29
- private scale = 1;
30
-
31
- private animationFrameId?: number;
32
-
33
- get contentChild() {
34
- const firstElement = this.children[0];
35
- if (!firstElement) return null;
36
-
37
- let current: Element = firstElement;
38
- while (current) {
39
- if (current instanceof HTMLSlotElement) {
40
- const assigned = current.assignedElements()[0];
41
- if (!assigned) break;
42
- current = assigned;
43
- continue;
44
- }
45
-
46
- const display = window.getComputedStyle(current).display;
47
- if (display !== "contents" && display !== "none") {
48
- return current as HTMLElement;
49
- }
50
- const firstChild = current.children[0];
51
- if (!firstChild) break;
52
- current = firstChild;
53
- }
54
- return firstElement as HTMLElement; // Fallback to first element if no non-contents found
55
- }
56
-
57
- get scaleInfo() {
58
- if (!this.contentChild) {
59
- return {
60
- scale: 1,
61
- containerWidth: 0,
62
- containerHeight: 0,
63
- contentWidth: 0,
64
- contentHeight: 0,
65
- };
66
- }
67
-
68
- const containerWidth = this.clientWidth;
69
- const containerHeight = this.clientHeight;
70
- const contentWidth = this.contentChild.clientWidth;
71
- const contentHeight = this.contentChild.clientHeight;
72
-
73
- const containerRatio = containerWidth / containerHeight;
74
- const contentRatio = contentWidth / contentHeight;
75
-
76
- const scale =
77
- containerRatio > contentRatio
78
- ? containerHeight / contentHeight
79
- : containerWidth / contentWidth;
80
-
81
- return {
82
- scale,
83
- containerWidth,
84
- containerHeight,
85
- contentWidth,
86
- contentHeight,
87
- };
88
- }
89
-
90
- scaleLastSetOn: HTMLElement | null = null;
91
-
92
- setScale = () => {
93
- if (this.isConnected) {
94
- const { scale } = this.scaleInfo;
95
- if (this.contentChild) {
96
- const containerRect = this.getBoundingClientRect();
97
- const contentRect = this.contentChild.getBoundingClientRect();
98
-
99
- const unscaledWidth = contentRect.width / this.scale;
100
- const unscaledHeight = contentRect.height / this.scale;
101
- const scaledWidth = unscaledWidth * scale;
102
- const scaledHeight = unscaledHeight * scale;
103
- const translateX = (containerRect.width - scaledWidth) / 2;
104
- const translateY = (containerRect.height - scaledHeight) / 2;
105
-
106
- // In the rare event that the content child is changed, we need to remove the scale
107
- // because we don't want to have a scale on the old content child that is somewhere else in the DOM
108
- if (this.scaleLastSetOn !== this.contentChild) {
109
- this.removeScale();
110
- }
111
- // Use toFixed to avoid floating point precision issues
112
- // this will update every frame with sub-pixel changes if we don't pin it down
113
- Object.assign(this.contentChild.style, {
114
- transform: `translate(${translateX.toFixed(4)}px, ${translateY.toFixed(4)}px) scale(${scale.toFixed(4)})`,
115
- transformOrigin: "top left",
116
- });
117
- this.scale = scale;
118
- this.scaleLastSetOn = this.contentChild;
119
- }
120
- this.animationFrameId = requestAnimationFrame(this.setScale);
121
- }
122
- };
123
-
124
- removeScale = () => {
125
- if (this.scaleLastSetOn) {
126
- Object.assign(this.scaleLastSetOn.style, {
127
- transform: "",
128
- transformOrigin: "",
129
- });
130
- this.scaleLastSetOn = null;
131
- }
132
- };
133
-
134
- connectedCallback(): void {
135
- super.connectedCallback();
136
- this.animationFrameId = requestAnimationFrame(this.setScale);
137
- }
138
-
139
- disconnectedCallback(): void {
140
- super.disconnectedCallback();
141
- this.removeScale();
142
- if (this.animationFrameId) {
143
- cancelAnimationFrame(this.animationFrameId);
144
- }
145
- }
146
- }
147
-
148
- declare global {
149
- interface HTMLElementTagNameMap {
150
- "ef-fit-scale": EFFitScale;
151
- }
152
- }
@@ -1,79 +0,0 @@
1
- import { consume } from "@lit/context";
2
- import { css, html, LitElement } from "lit";
3
- import { customElement } from "lit/decorators.js";
4
- import { createRef, ref } from "lit/directives/ref.js";
5
- import { focusedElementContext } from "./focusedElementContext.js";
6
-
7
- @customElement("ef-focus-overlay")
8
- export class EFFocusOverlay extends LitElement {
9
- static styles = css`
10
- :host {
11
- display: block;
12
- position: relative;
13
- width: 100%;
14
- height: 100%;
15
- pointer-events: none;
16
- }
17
- .overlay {
18
- position: fixed;
19
- outline: 2px solid var(--ef-focus-overlay-color, rgb(59, 130, 246));
20
- background: var(--ef-focus-overlay-background, rgb(59, 130, 246));
21
- outline: 2px solid var(--ef-focus-overlay-color, rgb(59, 130, 246));
22
- mix-blend-mode: multiply;
23
- opacity: 0.4;
24
- display: none;
25
- }
26
- `;
27
-
28
- @consume({ context: focusedElementContext, subscribe: true })
29
- focusedElement?: HTMLElement | null;
30
-
31
- overlay = createRef<HTMLDivElement>();
32
-
33
- private animationFrame?: number;
34
-
35
- drawOverlay = () => {
36
- const overlay = this.overlay.value;
37
- if (overlay) {
38
- if (this.focusedElement) {
39
- overlay.style.display = "block";
40
- const rect = this.focusedElement.getBoundingClientRect();
41
- Object.assign(overlay.style, {
42
- top: `${rect.top}px`,
43
- left: `${rect.left}px`,
44
- width: `${rect.width}px`,
45
- height: `${rect.height}px`,
46
- });
47
- this.animationFrame = requestAnimationFrame(this.drawOverlay);
48
- } else {
49
- overlay.style.display = "none";
50
- }
51
- }
52
- };
53
-
54
- render() {
55
- return html`<div ${ref(this.overlay)} class="overlay"></div>`;
56
- }
57
-
58
- connectedCallback(): void {
59
- super.connectedCallback();
60
- this.drawOverlay();
61
- }
62
-
63
- disconnectedCallback(): void {
64
- super.disconnectedCallback();
65
- if (this.animationFrame) {
66
- cancelAnimationFrame(this.animationFrame);
67
- }
68
- }
69
-
70
- protected updated(): void {
71
- this.drawOverlay();
72
- }
73
- }
74
-
75
- declare global {
76
- interface HTMLElementTagNameMap {
77
- "ef-focus-overlay": EFFocusOverlay;
78
- }
79
- }
@@ -1,202 +0,0 @@
1
- import { html, render } from "lit";
2
- import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
3
-
4
- import "../elements/EFTimegroup.js";
5
- import "../elements/EFVideo.js";
6
- import "./EFConfiguration.js";
7
- import "./EFPause.js";
8
- import "./EFPreview.js";
9
-
10
- describe("EFPause", () => {
11
- beforeEach(() => {
12
- while (document.body.children.length) {
13
- document.body.children[0]?.remove();
14
- }
15
- });
16
-
17
- afterEach(() => {
18
- const elements = document.querySelectorAll("ef-pause");
19
- for (const element of elements) {
20
- element.remove();
21
- }
22
- });
23
-
24
- test("should be defined", () => {
25
- const element = document.createElement("ef-pause");
26
- expect(element).toBeDefined();
27
- expect(element.tagName).toBe("EF-PAUSE");
28
- });
29
-
30
- test("should be hidden when not playing", async () => {
31
- const container = document.createElement("div");
32
- render(
33
- html`
34
- <ef-configuration api-host="http://localhost:63315" signing-url="">
35
- <ef-preview id="test-preview">
36
- <ef-video src="bars-n-tone.mp4"></ef-video>
37
- <ef-pause>Pause Button</ef-pause>
38
- </ef-preview>
39
- </ef-configuration>
40
- `,
41
- container,
42
- );
43
- document.body.appendChild(container);
44
-
45
- const pause = container.querySelector("ef-pause") as any;
46
- const preview = container.querySelector("ef-preview") as any;
47
- const video = container.querySelector("ef-video") as any;
48
-
49
- await pause.updateComplete;
50
- await preview.updateComplete;
51
- await video.updateComplete;
52
-
53
- await video.mediaEngineTask.run();
54
- await new Promise((resolve) => setTimeout(resolve, 100));
55
- await pause.updateComplete;
56
-
57
- expect(pause.playing).toBe(false);
58
- expect(getComputedStyle(pause).display).toBe("none");
59
-
60
- container.remove();
61
- });
62
-
63
- test("should be visible when playing", async () => {
64
- const container = document.createElement("div");
65
- render(
66
- html`
67
- <ef-configuration api-host="http://localhost:63315" signing-url="">
68
- <ef-preview id="test-preview">
69
- <ef-video src="bars-n-tone.mp4"></ef-video>
70
- <ef-pause>Pause Button</ef-pause>
71
- </ef-preview>
72
- </ef-configuration>
73
- `,
74
- container,
75
- );
76
- document.body.appendChild(container);
77
-
78
- const pause = container.querySelector("ef-pause") as any;
79
- const preview = container.querySelector("ef-preview") as any;
80
- const video = container.querySelector("ef-video") as any;
81
-
82
- await pause.updateComplete;
83
- await preview.updateComplete;
84
- await video.updateComplete;
85
-
86
- await video.mediaEngineTask.run();
87
- await new Promise((resolve) => setTimeout(resolve, 100));
88
- await pause.updateComplete;
89
-
90
- expect(getComputedStyle(pause).display).toBe("none");
91
-
92
- // Manually trigger playing state change to test visibility mechanism
93
- pause.playing = true;
94
- await pause.updateComplete;
95
-
96
- expect(getComputedStyle(pause).display).not.toBe("none");
97
-
98
- container.remove();
99
- });
100
-
101
- test("should call pause() when clicked", async () => {
102
- const container = document.createElement("div");
103
- render(
104
- html`
105
- <ef-configuration api-host="http://localhost:63315" signing-url="">
106
- <ef-preview id="test-preview">
107
- <ef-video src="bars-n-tone.mp4"></ef-video>
108
- <ef-pause>Pause Button</ef-pause>
109
- </ef-preview>
110
- </ef-configuration>
111
- `,
112
- container,
113
- );
114
- document.body.appendChild(container);
115
-
116
- const pause = container.querySelector("ef-pause") as any;
117
- const preview = container.querySelector("ef-preview") as any;
118
- const video = container.querySelector("ef-video") as any;
119
-
120
- await pause.updateComplete;
121
- await preview.updateComplete;
122
- await video.updateComplete;
123
-
124
- await video.mediaEngineTask.run();
125
- await new Promise((resolve) => setTimeout(resolve, 100));
126
- await pause.updateComplete;
127
-
128
- const pauseSpy = vi.spyOn(video.playbackController, "pause");
129
-
130
- pause.click();
131
-
132
- expect(pauseSpy).toHaveBeenCalledTimes(1);
133
-
134
- pauseSpy.mockRestore();
135
- container.remove();
136
- }, 1000);
137
-
138
- test("should pass through children with default slot", async () => {
139
- const container = document.createElement("div");
140
- render(
141
- html`
142
- <ef-configuration api-host="http://localhost:63315" signing-url="">
143
- <ef-preview id="test-preview">
144
- <ef-video src="bars-n-tone.mp4"></ef-video>
145
- <ef-pause><span id="pause-content">⏸ Pause</span></ef-pause>
146
- </ef-preview>
147
- </ef-configuration>
148
- `,
149
- container,
150
- );
151
- document.body.appendChild(container);
152
-
153
- const pause = container.querySelector("ef-pause") as any;
154
- const content = container.querySelector("#pause-content");
155
-
156
- await pause.updateComplete;
157
-
158
- expect(content).toBeDefined();
159
- expect(content?.textContent).toBe("⏸ Pause");
160
-
161
- container.remove();
162
- });
163
-
164
- test("should work with target attribute", async () => {
165
- const container = document.createElement("div");
166
- render(
167
- html`
168
- <ef-configuration api-host="http://localhost:63315" signing-url="">
169
- <ef-preview id="test-preview">
170
- <ef-video src="bars-n-tone.mp4"></ef-video>
171
- </ef-preview>
172
- <ef-pause target="test-preview">Pause Button</ef-pause>
173
- </ef-configuration>
174
- `,
175
- container,
176
- );
177
- document.body.appendChild(container);
178
-
179
- const pause = container.querySelector("ef-pause") as any;
180
- const preview = container.querySelector("ef-preview") as any;
181
- const video = container.querySelector("ef-video") as any;
182
-
183
- await pause.updateComplete;
184
- await preview.updateComplete;
185
- await video.updateComplete;
186
-
187
- await video.mediaEngineTask.run();
188
- await new Promise((resolve) => setTimeout(resolve, 100));
189
- await pause.updateComplete;
190
-
191
- expect(pause.efContext).toBe(preview);
192
-
193
- const pauseSpy = vi.spyOn(video.playbackController, "pause");
194
-
195
- pause.click();
196
-
197
- expect(pauseSpy).toHaveBeenCalledTimes(1);
198
-
199
- pauseSpy.mockRestore();
200
- container.remove();
201
- }, 1000);
202
- });
@@ -1,73 +0,0 @@
1
- import { consume } from "@lit/context";
2
- import { css, html, LitElement } from "lit";
3
- import { customElement, state } from "lit/decorators.js";
4
- import { attachContextRoot } from "../attachContextRoot.js";
5
- import type { ControllableInterface } from "./Controllable.js";
6
- import { efContext } from "./efContext.js";
7
- import { playingContext } from "./playingContext.js";
8
- import { TargetOrContextMixin } from "./TargetOrContextMixin.js";
9
-
10
- attachContextRoot();
11
-
12
- @customElement("ef-pause")
13
- export class EFPause extends TargetOrContextMixin(LitElement, efContext) {
14
- static styles = [
15
- css`
16
- :host {
17
- display: block;
18
- }
19
- :host([hidden]) {
20
- display: none;
21
- }
22
- div {
23
- all: inherit;
24
- }
25
- `,
26
- ];
27
-
28
- @consume({ context: playingContext, subscribe: true })
29
- @state()
30
- playing = false;
31
-
32
- get efContext(): ControllableInterface | null {
33
- return this.effectiveContext;
34
- }
35
-
36
- connectedCallback() {
37
- super.connectedCallback();
38
- this.addEventListener("click", this.handleClick);
39
- }
40
-
41
- disconnectedCallback() {
42
- super.disconnectedCallback();
43
- this.removeEventListener("click", this.handleClick);
44
- }
45
-
46
- updated(changedProperties: Map<string | number | symbol, unknown>): void {
47
- super.updated(changedProperties);
48
-
49
- if (changedProperties.has("playing")) {
50
- this.style.display = this.playing ? "" : "none";
51
- }
52
- }
53
-
54
- render() {
55
- return html`
56
- <div>
57
- <slot></slot>
58
- </div>
59
- `;
60
- }
61
-
62
- handleClick = () => {
63
- if (this.efContext) {
64
- this.efContext.pause();
65
- }
66
- };
67
- }
68
-
69
- declare global {
70
- interface HTMLElementTagNameMap {
71
- "ef-pause": EFPause;
72
- }
73
- }
@@ -1,202 +0,0 @@
1
- import { html, render } from "lit";
2
- import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
3
-
4
- import "../elements/EFTimegroup.js";
5
- import "../elements/EFVideo.js";
6
- import "./EFConfiguration.js";
7
- import "./EFPlay.js";
8
- import "./EFPreview.js";
9
-
10
- describe("EFPlay", () => {
11
- beforeEach(() => {
12
- while (document.body.children.length) {
13
- document.body.children[0]?.remove();
14
- }
15
- });
16
-
17
- afterEach(() => {
18
- const elements = document.querySelectorAll("ef-play");
19
- for (const element of elements) {
20
- element.remove();
21
- }
22
- });
23
-
24
- test("should be defined", () => {
25
- const element = document.createElement("ef-play");
26
- expect(element).toBeDefined();
27
- expect(element.tagName).toBe("EF-PLAY");
28
- });
29
-
30
- test("should be visible when not playing", async () => {
31
- const container = document.createElement("div");
32
- render(
33
- html`
34
- <ef-configuration api-host="http://localhost:63315" signing-url="">
35
- <ef-preview id="test-preview">
36
- <ef-video src="bars-n-tone.mp4"></ef-video>
37
- <ef-play>Play Button</ef-play>
38
- </ef-preview>
39
- </ef-configuration>
40
- `,
41
- container,
42
- );
43
- document.body.appendChild(container);
44
-
45
- const play = container.querySelector("ef-play") as any;
46
- const preview = container.querySelector("ef-preview") as any;
47
- const video = container.querySelector("ef-video") as any;
48
-
49
- await play.updateComplete;
50
- await preview.updateComplete;
51
- await video.updateComplete;
52
-
53
- await video.mediaEngineTask.run();
54
- await new Promise((resolve) => setTimeout(resolve, 100));
55
- await play.updateComplete;
56
-
57
- expect(play.playing).toBe(false);
58
- expect(getComputedStyle(play).display).not.toBe("none");
59
-
60
- container.remove();
61
- });
62
-
63
- test("should be hidden when playing", async () => {
64
- const container = document.createElement("div");
65
- render(
66
- html`
67
- <ef-configuration api-host="http://localhost:63315" signing-url="">
68
- <ef-preview id="test-preview">
69
- <ef-video src="bars-n-tone.mp4"></ef-video>
70
- <ef-play id="play-btn">Play Button</ef-play>
71
- </ef-preview>
72
- </ef-configuration>
73
- `,
74
- container,
75
- );
76
- document.body.appendChild(container);
77
-
78
- const play = container.querySelector("ef-play") as any;
79
- const preview = container.querySelector("ef-preview") as any;
80
- const video = container.querySelector("ef-video") as any;
81
-
82
- await play.updateComplete;
83
- await preview.updateComplete;
84
- await video.updateComplete;
85
-
86
- await video.mediaEngineTask.run();
87
- await new Promise((resolve) => setTimeout(resolve, 100));
88
- await play.updateComplete;
89
-
90
- expect(getComputedStyle(play).display).not.toBe("none");
91
-
92
- // Manually trigger playing state change to test visibility mechanism
93
- play.playing = true;
94
- await play.updateComplete;
95
-
96
- expect(getComputedStyle(play).display).toBe("none");
97
-
98
- container.remove();
99
- });
100
-
101
- test("should call play() when clicked", async () => {
102
- const container = document.createElement("div");
103
- render(
104
- html`
105
- <ef-configuration api-host="http://localhost:63315" signing-url="">
106
- <ef-preview id="test-preview">
107
- <ef-video src="bars-n-tone.mp4"></ef-video>
108
- <ef-play>Play Button</ef-play>
109
- </ef-preview>
110
- </ef-configuration>
111
- `,
112
- container,
113
- );
114
- document.body.appendChild(container);
115
-
116
- const play = container.querySelector("ef-play") as any;
117
- const preview = container.querySelector("ef-preview") as any;
118
- const video = container.querySelector("ef-video") as any;
119
-
120
- await play.updateComplete;
121
- await preview.updateComplete;
122
- await video.updateComplete;
123
-
124
- await video.mediaEngineTask.run();
125
- await new Promise((resolve) => setTimeout(resolve, 100));
126
- await play.updateComplete;
127
-
128
- const playSpy = vi.spyOn(video.playbackController, "play");
129
-
130
- play.click();
131
-
132
- expect(playSpy).toHaveBeenCalledTimes(1);
133
-
134
- playSpy.mockRestore();
135
- container.remove();
136
- }, 1000);
137
-
138
- test("should pass through children with default slot", async () => {
139
- const container = document.createElement("div");
140
- render(
141
- html`
142
- <ef-configuration api-host="http://localhost:63315" signing-url="">
143
- <ef-preview id="test-preview">
144
- <ef-video src="bars-n-tone.mp4"></ef-video>
145
- <ef-play><span id="play-content">▶ Play</span></ef-play>
146
- </ef-preview>
147
- </ef-configuration>
148
- `,
149
- container,
150
- );
151
- document.body.appendChild(container);
152
-
153
- const play = container.querySelector("ef-play") as any;
154
- const content = container.querySelector("#play-content");
155
-
156
- await play.updateComplete;
157
-
158
- expect(content).toBeDefined();
159
- expect(content?.textContent).toBe("▶ Play");
160
-
161
- container.remove();
162
- });
163
-
164
- test("should work with target attribute", async () => {
165
- const container = document.createElement("div");
166
- render(
167
- html`
168
- <ef-configuration api-host="http://localhost:63315" signing-url="">
169
- <ef-preview id="test-preview">
170
- <ef-video src="bars-n-tone.mp4"></ef-video>
171
- </ef-preview>
172
- <ef-play target="test-preview">Play Button</ef-play>
173
- </ef-configuration>
174
- `,
175
- container,
176
- );
177
- document.body.appendChild(container);
178
-
179
- const play = container.querySelector("ef-play") as any;
180
- const preview = container.querySelector("ef-preview") as any;
181
- const video = container.querySelector("ef-video") as any;
182
-
183
- await play.updateComplete;
184
- await preview.updateComplete;
185
- await video.updateComplete;
186
-
187
- await video.mediaEngineTask.run();
188
- await new Promise((resolve) => setTimeout(resolve, 100));
189
- await play.updateComplete;
190
-
191
- expect(play.efContext).toBe(preview);
192
-
193
- const playSpy = vi.spyOn(video.playbackController, "play");
194
-
195
- play.click();
196
-
197
- expect(playSpy).toHaveBeenCalledTimes(1);
198
-
199
- playSpy.mockRestore();
200
- container.remove();
201
- }, 1000);
202
- });