@editframe/elements 0.16.7-beta.0 → 0.17.6-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 (101) hide show
  1. package/README.md +30 -0
  2. package/dist/DecoderResetFrequency.test.d.ts +1 -0
  3. package/dist/DecoderResetRecovery.test.d.ts +1 -0
  4. package/dist/DelayedLoadingState.d.ts +48 -0
  5. package/dist/DelayedLoadingState.integration.test.d.ts +1 -0
  6. package/dist/DelayedLoadingState.js +113 -0
  7. package/dist/DelayedLoadingState.test.d.ts +1 -0
  8. package/dist/EF_FRAMEGEN.d.ts +10 -1
  9. package/dist/EF_FRAMEGEN.js +199 -179
  10. package/dist/EF_INTERACTIVE.js +2 -6
  11. package/dist/EF_RENDERING.js +1 -3
  12. package/dist/JitTranscodingClient.browsertest.d.ts +1 -0
  13. package/dist/JitTranscodingClient.d.ts +167 -0
  14. package/dist/JitTranscodingClient.js +373 -0
  15. package/dist/JitTranscodingClient.test.d.ts +1 -0
  16. package/dist/LoadingDebounce.test.d.ts +1 -0
  17. package/dist/LoadingIndicator.browsertest.d.ts +0 -0
  18. package/dist/ManualScrubTest.test.d.ts +1 -0
  19. package/dist/ScrubResolvedFlashing.test.d.ts +1 -0
  20. package/dist/ScrubTrackIntegration.test.d.ts +1 -0
  21. package/dist/ScrubTrackManager.d.ts +96 -0
  22. package/dist/ScrubTrackManager.js +216 -0
  23. package/dist/ScrubTrackManager.test.d.ts +1 -0
  24. package/dist/SegmentSwitchLoading.test.d.ts +1 -0
  25. package/dist/VideoSeekFlashing.browsertest.d.ts +0 -0
  26. package/dist/VideoStuckDiagnostic.test.d.ts +1 -0
  27. package/dist/elements/CrossUpdateController.js +13 -15
  28. package/dist/elements/EFAudio.browsertest.d.ts +0 -0
  29. package/dist/elements/EFAudio.d.ts +1 -1
  30. package/dist/elements/EFAudio.js +30 -43
  31. package/dist/elements/EFCaptions.js +337 -373
  32. package/dist/elements/EFImage.js +64 -90
  33. package/dist/elements/EFMedia.d.ts +98 -33
  34. package/dist/elements/EFMedia.js +1169 -678
  35. package/dist/elements/EFSourceMixin.js +31 -48
  36. package/dist/elements/EFTemporal.d.ts +1 -0
  37. package/dist/elements/EFTemporal.js +266 -360
  38. package/dist/elements/EFTimegroup.d.ts +3 -1
  39. package/dist/elements/EFTimegroup.js +262 -323
  40. package/dist/elements/EFVideo.browsertest.d.ts +0 -0
  41. package/dist/elements/EFVideo.d.ts +90 -2
  42. package/dist/elements/EFVideo.js +408 -111
  43. package/dist/elements/EFWaveform.js +375 -411
  44. package/dist/elements/FetchMixin.js +14 -24
  45. package/dist/elements/MediaController.d.ts +30 -0
  46. package/dist/elements/TargetController.js +130 -156
  47. package/dist/elements/TimegroupController.js +17 -19
  48. package/dist/elements/durationConverter.js +15 -4
  49. package/dist/elements/parseTimeToMs.js +4 -10
  50. package/dist/elements/printTaskStatus.d.ts +2 -0
  51. package/dist/elements/printTaskStatus.js +11 -0
  52. package/dist/elements/updateAnimations.js +39 -59
  53. package/dist/getRenderInfo.js +58 -67
  54. package/dist/gui/ContextMixin.js +203 -288
  55. package/dist/gui/EFConfiguration.js +27 -43
  56. package/dist/gui/EFFilmstrip.js +440 -620
  57. package/dist/gui/EFFitScale.js +112 -135
  58. package/dist/gui/EFFocusOverlay.js +45 -61
  59. package/dist/gui/EFPreview.js +30 -49
  60. package/dist/gui/EFScrubber.js +78 -99
  61. package/dist/gui/EFTimeDisplay.js +49 -70
  62. package/dist/gui/EFToggleLoop.js +17 -34
  63. package/dist/gui/EFTogglePlay.js +37 -58
  64. package/dist/gui/EFWorkbench.js +66 -88
  65. package/dist/gui/TWMixin.js +2 -48
  66. package/dist/gui/TWMixin2.js +31 -0
  67. package/dist/gui/efContext.js +2 -6
  68. package/dist/gui/fetchContext.js +1 -3
  69. package/dist/gui/focusContext.js +1 -3
  70. package/dist/gui/focusedElementContext.js +2 -6
  71. package/dist/gui/playingContext.js +1 -4
  72. package/dist/index.js +5 -30
  73. package/dist/msToTimeCode.js +11 -13
  74. package/dist/style.css +2 -1
  75. package/package.json +3 -3
  76. package/src/elements/EFAudio.browsertest.ts +569 -0
  77. package/src/elements/EFAudio.ts +4 -6
  78. package/src/elements/EFCaptions.browsertest.ts +0 -1
  79. package/src/elements/EFImage.browsertest.ts +0 -1
  80. package/src/elements/EFMedia.browsertest.ts +147 -115
  81. package/src/elements/EFMedia.ts +1339 -307
  82. package/src/elements/EFTemporal.browsertest.ts +0 -1
  83. package/src/elements/EFTemporal.ts +11 -0
  84. package/src/elements/EFTimegroup.ts +73 -10
  85. package/src/elements/EFVideo.browsertest.ts +680 -0
  86. package/src/elements/EFVideo.ts +729 -50
  87. package/src/elements/EFWaveform.ts +4 -4
  88. package/src/elements/MediaController.ts +108 -0
  89. package/src/elements/__screenshots__/EFMedia.browsertest.ts/EFMedia-JIT-audio-playback-audioBufferTask-should-work-in-JIT-mode-without-URL-errors-1.png +0 -0
  90. package/src/elements/printTaskStatus.ts +16 -0
  91. package/src/elements/updateAnimations.ts +6 -0
  92. package/src/gui/TWMixin.ts +10 -3
  93. package/test/EFVideo.frame-tasks.browsertest.ts +524 -0
  94. package/test/EFVideo.framegen.browsertest.ts +118 -0
  95. package/test/createJitTestClips.ts +293 -0
  96. package/test/useAssetMSW.ts +49 -0
  97. package/test/useMSW.ts +31 -0
  98. package/types.json +1 -1
  99. package/dist/gui/TWMixin.css.js +0 -4
  100. /package/dist/elements/{TargetController.test.d.ts → TargetController.browsertest.d.ts} +0 -0
  101. /package/src/elements/{TargetController.test.ts → TargetController.browsertest.ts} +0 -0
@@ -1,138 +1,115 @@
1
1
  import { LitElement } from "lit";
2
- import { state, customElement } from "lit/decorators.js";
2
+ import { customElement, state } from "lit/decorators.js";
3
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
3
4
  import { createRef } from "lit/directives/ref.js";
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __decorateClass = (decorators, target, key, kind) => {
7
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
- if (decorator = decorators[i])
10
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
- if (kind && result) __defProp(target, key, result);
12
- return result;
13
- };
14
- let EFFitScale = class extends LitElement {
15
- constructor() {
16
- super(...arguments);
17
- this.containerRef = createRef();
18
- this.contentRef = createRef();
19
- this.uniqueId = Math.random().toString(36).substring(2, 15);
20
- this.scale = 1;
21
- this.scaleLastSetOn = null;
22
- this.setScale = () => {
23
- if (this.isConnected) {
24
- const { scale } = this.scaleInfo;
25
- if (this.contentChild) {
26
- const containerRect = this.getBoundingClientRect();
27
- const contentRect = this.contentChild.getBoundingClientRect();
28
- const unscaledWidth = contentRect.width / this.scale;
29
- const unscaledHeight = contentRect.height / this.scale;
30
- const scaledWidth = unscaledWidth * scale;
31
- const scaledHeight = unscaledHeight * scale;
32
- const translateX = (containerRect.width - scaledWidth) / 2;
33
- const translateY = (containerRect.height - scaledHeight) / 2;
34
- if (this.scaleLastSetOn !== this.contentChild) {
35
- this.removeScale();
36
- }
37
- Object.assign(this.contentChild.style, {
38
- transform: `translate(${translateX.toFixed(4)}px, ${translateY.toFixed(4)}px) scale(${scale.toFixed(4)})`,
39
- transformOrigin: "top left"
40
- });
41
- this.scale = scale;
42
- this.scaleLastSetOn = this.contentChild;
43
- }
44
- this.animationFrameId = requestAnimationFrame(this.setScale);
45
- }
46
- };
47
- this.removeScale = () => {
48
- if (this.scaleLastSetOn) {
49
- Object.assign(this.scaleLastSetOn.style, {
50
- transform: "",
51
- transformOrigin: ""
52
- });
53
- this.scaleLastSetOn = null;
54
- }
55
- };
56
- }
57
- createRenderRoot() {
58
- Object.assign(this.style, {
59
- display: "grid",
60
- width: "100%",
61
- height: "100%",
62
- gridTemplateColumns: "100%",
63
- gridTemplateRows: "100%",
64
- overflow: "hidden",
65
- boxSizing: "border-box",
66
- contain: "strict",
67
- position: "relative"
68
- });
69
- this.id = `${this.uniqueId}`;
70
- return this;
71
- }
72
- get contentChild() {
73
- const firstElement = this.children[0];
74
- if (!firstElement) return null;
75
- let current = firstElement;
76
- while (current) {
77
- if (current instanceof HTMLSlotElement) {
78
- const assigned = current.assignedElements()[0];
79
- if (!assigned) break;
80
- current = assigned;
81
- continue;
82
- }
83
- const display = window.getComputedStyle(current).display;
84
- if (display !== "contents" && display !== "none") {
85
- return current;
86
- }
87
- const firstChild = current.children[0];
88
- if (!firstChild) break;
89
- current = firstChild;
90
- }
91
- return firstElement;
92
- }
93
- get scaleInfo() {
94
- if (!this.contentChild) {
95
- return {
96
- scale: 1,
97
- containerWidth: 0,
98
- containerHeight: 0,
99
- contentWidth: 0,
100
- contentHeight: 0
101
- };
102
- }
103
- const containerWidth = this.clientWidth;
104
- const containerHeight = this.clientHeight;
105
- const contentWidth = this.contentChild.clientWidth;
106
- const contentHeight = this.contentChild.clientHeight;
107
- const containerRatio = containerWidth / containerHeight;
108
- const contentRatio = contentWidth / contentHeight;
109
- const scale = containerRatio > contentRatio ? containerHeight / contentHeight : containerWidth / contentWidth;
110
- return {
111
- scale,
112
- containerWidth,
113
- containerHeight,
114
- contentWidth,
115
- contentHeight
116
- };
117
- }
118
- connectedCallback() {
119
- super.connectedCallback();
120
- this.animationFrameId = requestAnimationFrame(this.setScale);
121
- }
122
- disconnectedCallback() {
123
- super.disconnectedCallback();
124
- this.removeScale();
125
- if (this.animationFrameId) {
126
- cancelAnimationFrame(this.animationFrameId);
127
- }
128
- }
129
- };
130
- __decorateClass([
131
- state()
132
- ], EFFitScale.prototype, "scale", 2);
133
- EFFitScale = __decorateClass([
134
- customElement("ef-fit-scale")
135
- ], EFFitScale);
136
- export {
137
- EFFitScale
5
+ let EFFitScale = class EFFitScale$1 extends LitElement {
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.containerRef = createRef();
9
+ this.contentRef = createRef();
10
+ this.uniqueId = Math.random().toString(36).substring(2, 15);
11
+ this.scale = 1;
12
+ this.scaleLastSetOn = null;
13
+ this.setScale = () => {
14
+ if (this.isConnected) {
15
+ const { scale } = this.scaleInfo;
16
+ if (this.contentChild) {
17
+ const containerRect = this.getBoundingClientRect();
18
+ const contentRect = this.contentChild.getBoundingClientRect();
19
+ const unscaledWidth = contentRect.width / this.scale;
20
+ const unscaledHeight = contentRect.height / this.scale;
21
+ const scaledWidth = unscaledWidth * scale;
22
+ const scaledHeight = unscaledHeight * scale;
23
+ const translateX = (containerRect.width - scaledWidth) / 2;
24
+ const translateY = (containerRect.height - scaledHeight) / 2;
25
+ if (this.scaleLastSetOn !== this.contentChild) this.removeScale();
26
+ Object.assign(this.contentChild.style, {
27
+ transform: `translate(${translateX.toFixed(4)}px, ${translateY.toFixed(4)}px) scale(${scale.toFixed(4)})`,
28
+ transformOrigin: "top left"
29
+ });
30
+ this.scale = scale;
31
+ this.scaleLastSetOn = this.contentChild;
32
+ }
33
+ this.animationFrameId = requestAnimationFrame(this.setScale);
34
+ }
35
+ };
36
+ this.removeScale = () => {
37
+ if (this.scaleLastSetOn) {
38
+ Object.assign(this.scaleLastSetOn.style, {
39
+ transform: "",
40
+ transformOrigin: ""
41
+ });
42
+ this.scaleLastSetOn = null;
43
+ }
44
+ };
45
+ }
46
+ createRenderRoot() {
47
+ Object.assign(this.style, {
48
+ display: "grid",
49
+ width: "100%",
50
+ height: "100%",
51
+ gridTemplateColumns: "100%",
52
+ gridTemplateRows: "100%",
53
+ overflow: "hidden",
54
+ boxSizing: "border-box",
55
+ contain: "strict",
56
+ position: "relative"
57
+ });
58
+ this.id = `${this.uniqueId}`;
59
+ return this;
60
+ }
61
+ get contentChild() {
62
+ const firstElement = this.children[0];
63
+ if (!firstElement) return null;
64
+ let current = firstElement;
65
+ while (current) {
66
+ if (current instanceof HTMLSlotElement) {
67
+ const assigned = current.assignedElements()[0];
68
+ if (!assigned) break;
69
+ current = assigned;
70
+ continue;
71
+ }
72
+ const display = window.getComputedStyle(current).display;
73
+ if (display !== "contents" && display !== "none") return current;
74
+ const firstChild = current.children[0];
75
+ if (!firstChild) break;
76
+ current = firstChild;
77
+ }
78
+ return firstElement;
79
+ }
80
+ get scaleInfo() {
81
+ if (!this.contentChild) return {
82
+ scale: 1,
83
+ containerWidth: 0,
84
+ containerHeight: 0,
85
+ contentWidth: 0,
86
+ contentHeight: 0
87
+ };
88
+ const containerWidth = this.clientWidth;
89
+ const containerHeight = this.clientHeight;
90
+ const contentWidth = this.contentChild.clientWidth;
91
+ const contentHeight = this.contentChild.clientHeight;
92
+ const containerRatio = containerWidth / containerHeight;
93
+ const contentRatio = contentWidth / contentHeight;
94
+ const scale = containerRatio > contentRatio ? containerHeight / contentHeight : containerWidth / contentWidth;
95
+ return {
96
+ scale,
97
+ containerWidth,
98
+ containerHeight,
99
+ contentWidth,
100
+ contentHeight
101
+ };
102
+ }
103
+ connectedCallback() {
104
+ super.connectedCallback();
105
+ this.animationFrameId = requestAnimationFrame(this.setScale);
106
+ }
107
+ disconnectedCallback() {
108
+ super.disconnectedCallback();
109
+ this.removeScale();
110
+ if (this.animationFrameId) cancelAnimationFrame(this.animationFrameId);
111
+ }
138
112
  };
113
+ _decorate([state()], EFFitScale.prototype, "scale", void 0);
114
+ EFFitScale = _decorate([customElement("ef-fit-scale")], EFFitScale);
115
+ export { EFFitScale };
@@ -1,59 +1,30 @@
1
+ import { focusedElementContext } from "./focusedElementContext.js";
1
2
  import { consume } from "@lit/context";
2
- import { css, LitElement, html } from "lit";
3
+ import { LitElement, css, html } from "lit";
3
4
  import { customElement } from "lit/decorators.js";
5
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
4
6
  import { createRef, ref } from "lit/directives/ref.js";
5
- import { focusedElementContext } from "./focusedElementContext.js";
6
- var __defProp = Object.defineProperty;
7
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
- var __decorateClass = (decorators, target, key, kind) => {
9
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
10
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
- if (decorator = decorators[i])
12
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
13
- if (kind && result) __defProp(target, key, result);
14
- return result;
15
- };
16
- let EFFocusOverlay = class extends LitElement {
17
- constructor() {
18
- super(...arguments);
19
- this.overlay = createRef();
20
- this.drawOverlay = () => {
21
- const overlay = this.overlay.value;
22
- if (overlay) {
23
- if (this.focusedElement) {
24
- overlay.style.display = "block";
25
- const rect = this.focusedElement.getBoundingClientRect();
26
- Object.assign(overlay.style, {
27
- top: `${rect.top}px`,
28
- left: `${rect.left}px`,
29
- width: `${rect.width}px`,
30
- height: `${rect.height}px`
31
- });
32
- this.animationFrame = requestAnimationFrame(this.drawOverlay);
33
- } else {
34
- overlay.style.display = "none";
35
- }
36
- }
37
- };
38
- }
39
- render() {
40
- return html`<div ${ref(this.overlay)} class="overlay"></div>`;
41
- }
42
- connectedCallback() {
43
- super.connectedCallback();
44
- this.drawOverlay();
45
- }
46
- disconnectedCallback() {
47
- super.disconnectedCallback();
48
- if (this.animationFrame) {
49
- cancelAnimationFrame(this.animationFrame);
50
- }
51
- }
52
- updated() {
53
- this.drawOverlay();
54
- }
55
- };
56
- EFFocusOverlay.styles = css`
7
+ let EFFocusOverlay = class EFFocusOverlay$1 extends LitElement {
8
+ constructor(..._args) {
9
+ super(..._args);
10
+ this.overlay = createRef();
11
+ this.drawOverlay = () => {
12
+ const overlay = this.overlay.value;
13
+ if (overlay) if (this.focusedElement) {
14
+ overlay.style.display = "block";
15
+ const rect = this.focusedElement.getBoundingClientRect();
16
+ Object.assign(overlay.style, {
17
+ top: `${rect.top}px`,
18
+ left: `${rect.left}px`,
19
+ width: `${rect.width}px`,
20
+ height: `${rect.height}px`
21
+ });
22
+ this.animationFrame = requestAnimationFrame(this.drawOverlay);
23
+ } else overlay.style.display = "none";
24
+ };
25
+ }
26
+ static {
27
+ this.styles = css`
57
28
  :host {
58
29
  display: block;
59
30
  position: relative;
@@ -71,12 +42,25 @@ EFFocusOverlay.styles = css`
71
42
  display: none;
72
43
  }
73
44
  `;
74
- __decorateClass([
75
- consume({ context: focusedElementContext, subscribe: true })
76
- ], EFFocusOverlay.prototype, "focusedElement", 2);
77
- EFFocusOverlay = __decorateClass([
78
- customElement("ef-focus-overlay")
79
- ], EFFocusOverlay);
80
- export {
81
- EFFocusOverlay
45
+ }
46
+ render() {
47
+ return html`<div ${ref(this.overlay)} class="overlay"></div>`;
48
+ }
49
+ connectedCallback() {
50
+ super.connectedCallback();
51
+ this.drawOverlay();
52
+ }
53
+ disconnectedCallback() {
54
+ super.disconnectedCallback();
55
+ if (this.animationFrame) cancelAnimationFrame(this.animationFrame);
56
+ }
57
+ updated() {
58
+ this.drawOverlay();
59
+ }
82
60
  };
61
+ _decorate([consume({
62
+ context: focusedElementContext,
63
+ subscribe: true
64
+ })], EFFocusOverlay.prototype, "focusedElement", void 0);
65
+ EFFocusOverlay = _decorate([customElement("ef-focus-overlay")], EFFocusOverlay);
66
+ export { EFFocusOverlay };
@@ -1,56 +1,37 @@
1
- import { LitElement, html, css } from "lit";
2
- import { customElement } from "lit/decorators.js";
3
- import { provide } from "@lit/context";
4
- import { ContextMixin } from "./ContextMixin.js";
5
- import { TWMixin } from "./TWMixin.js";
6
1
  import { focusedElementContext } from "./focusedElementContext.js";
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __decorateClass = (decorators, target, key, kind) => {
10
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
11
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
12
- if (decorator = decorators[i])
13
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
14
- if (kind && result) __defProp(target, key, result);
15
- return result;
16
- };
17
- let EFPreview = class extends ContextMixin(TWMixin(LitElement)) {
18
- constructor() {
19
- super();
20
- this.addEventListener("mouseover", (e) => {
21
- const target = e.target;
22
- const timegroup = target.closest("ef-timegroup");
23
- if (target !== this && timegroup) {
24
- this.focusedElement = target;
25
- }
26
- });
27
- this.addEventListener("mouseout", (e) => {
28
- const relatedTarget = e.relatedTarget;
29
- const targetingTimegroup = relatedTarget?.closest("ef-timegroup");
30
- if (!this.contains(relatedTarget) || relatedTarget === this || !targetingTimegroup) {
31
- this.focusedElement = void 0;
32
- }
33
- });
34
- }
35
- render() {
36
- return html`<slot></slot>`;
37
- }
38
- };
39
- EFPreview.styles = [
40
- css`
2
+ import { ContextMixin } from "./ContextMixin.js";
3
+ import { TWMixin } from "./TWMixin2.js";
4
+ import { provide } from "@lit/context";
5
+ import { LitElement, css, html } from "lit";
6
+ import { customElement } from "lit/decorators.js";
7
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
8
+ let EFPreview = class EFPreview$1 extends ContextMixin(TWMixin(LitElement)) {
9
+ static {
10
+ this.styles = [css`
41
11
  :host {
42
12
  position: relative;
43
13
  display: block;
44
14
  cursor: crosshair;
45
15
  }
46
- `
47
- ];
48
- __decorateClass([
49
- provide({ context: focusedElementContext })
50
- ], EFPreview.prototype, "focusedElement", 2);
51
- EFPreview = __decorateClass([
52
- customElement("ef-preview")
53
- ], EFPreview);
54
- export {
55
- EFPreview
16
+ `];
17
+ }
18
+ constructor() {
19
+ super();
20
+ this.addEventListener("mouseover", (e) => {
21
+ const target = e.target;
22
+ const timegroup = target.closest("ef-timegroup");
23
+ if (target !== this && timegroup) this.focusedElement = target;
24
+ });
25
+ this.addEventListener("mouseout", (e) => {
26
+ const relatedTarget = e.relatedTarget;
27
+ const targetingTimegroup = relatedTarget?.closest("ef-timegroup");
28
+ if (!this.contains(relatedTarget) || relatedTarget === this || !targetingTimegroup) this.focusedElement = void 0;
29
+ });
30
+ }
31
+ render() {
32
+ return html`<slot></slot>`;
33
+ }
56
34
  };
35
+ _decorate([provide({ context: focusedElementContext })], EFPreview.prototype, "focusedElement", void 0);
36
+ EFPreview = _decorate([customElement("ef-preview")], EFPreview);
37
+ export { EFPreview };
@@ -1,82 +1,31 @@
1
- import { consume } from "@lit/context";
2
- import { css, LitElement, html } from "lit";
3
- import { state, customElement } from "lit/decorators.js";
4
- import { ref } from "lit/directives/ref.js";
5
1
  import { efContext } from "./efContext.js";
6
2
  import { playingContext } from "./playingContext.js";
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __decorateClass = (decorators, target, key, kind) => {
10
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
11
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
12
- if (decorator = decorators[i])
13
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
14
- if (kind && result) __defProp(target, key, result);
15
- return result;
16
- };
17
- let EFScrubber = class extends LitElement {
18
- constructor() {
19
- super(...arguments);
20
- this.playing = false;
21
- this.lastTimeUpdateProgress = 0;
22
- this.scrubProgress = 0;
23
- this.isDragging = false;
24
- this.boundHandleMouseDown = (e) => {
25
- this.isDragging = true;
26
- e.preventDefault();
27
- this.updateProgress(e);
28
- };
29
- this.boundHandleMouseMove = (e) => {
30
- if (this.isDragging) {
31
- this.updateProgress(e);
32
- }
33
- };
34
- this.boundHandleMouseUp = () => {
35
- this.isDragging = false;
36
- };
37
- }
38
- updateProgress(e) {
39
- if (!this.context || !this.scrubberRef) return;
40
- const rect = this.scrubberRef.getBoundingClientRect();
41
- const x = e.clientX - rect.left;
42
- const progress = Math.max(0, Math.min(1, x / rect.width));
43
- this.scrubProgress = progress;
44
- this.context.currentTimeMs = progress * (this.context.targetTimegroup?.durationMs ?? 0);
45
- }
46
- render() {
47
- const displayProgress = this.isDragging ? this.scrubProgress : this.lastTimeUpdateProgress;
48
- return html`
49
- <div
50
- ${ref((el) => {
51
- this.scrubberRef = el;
52
- })}
53
- part="scrubber"
54
- class="scrubber"
55
- @mousedown=${this.boundHandleMouseDown}
56
- >
57
- <div class="progress" style="width: ${displayProgress * 100}%"></div>
58
- <div class="handle" style="left: ${displayProgress * 100}%"></div>
59
- </div>
60
- `;
61
- }
62
- connectedCallback() {
63
- super.connectedCallback();
64
- window.addEventListener("mouseup", this.boundHandleMouseUp);
65
- window.addEventListener("mousemove", this.boundHandleMouseMove);
66
- if (this.context) {
67
- this.context.addEventListener("timeupdate", (e) => {
68
- this.lastTimeUpdateProgress = e.detail.progress;
69
- });
70
- }
71
- }
72
- disconnectedCallback() {
73
- super.disconnectedCallback();
74
- window.removeEventListener("mouseup", this.boundHandleMouseUp);
75
- window.removeEventListener("mousemove", this.boundHandleMouseMove);
76
- }
77
- };
78
- EFScrubber.styles = [
79
- css`
3
+ import { consume } from "@lit/context";
4
+ import { LitElement, css, html } from "lit";
5
+ import { customElement, state } from "lit/decorators.js";
6
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
7
+ import { ref } from "lit/directives/ref.js";
8
+ let EFScrubber = class EFScrubber$1 extends LitElement {
9
+ constructor(..._args) {
10
+ super(..._args);
11
+ this.playing = false;
12
+ this.lastTimeUpdateProgress = 0;
13
+ this.scrubProgress = 0;
14
+ this.isDragging = false;
15
+ this.boundHandleMouseDown = (e) => {
16
+ this.isDragging = true;
17
+ e.preventDefault();
18
+ this.updateProgress(e);
19
+ };
20
+ this.boundHandleMouseMove = (e) => {
21
+ if (this.isDragging) this.updateProgress(e);
22
+ };
23
+ this.boundHandleMouseUp = () => {
24
+ this.isDragging = false;
25
+ };
26
+ }
27
+ static {
28
+ this.styles = [css`
80
29
  :host {
81
30
  --ef-scrubber-height: 4px;
82
31
  --ef-scrubber-background: rgb(209 213 219);
@@ -117,26 +66,56 @@ EFScrubber.styles = [
117
66
  ::part(scrubber) { }
118
67
  ::part(progress) { }
119
68
  ::part(handle) { }
120
- `
121
- ];
122
- __decorateClass([
123
- consume({ context: efContext, subscribe: true })
124
- ], EFScrubber.prototype, "context", 2);
125
- __decorateClass([
126
- consume({ context: playingContext, subscribe: true })
127
- ], EFScrubber.prototype, "playing", 2);
128
- __decorateClass([
129
- state()
130
- ], EFScrubber.prototype, "lastTimeUpdateProgress", 2);
131
- __decorateClass([
132
- state()
133
- ], EFScrubber.prototype, "scrubProgress", 2);
134
- __decorateClass([
135
- state()
136
- ], EFScrubber.prototype, "isDragging", 2);
137
- EFScrubber = __decorateClass([
138
- customElement("ef-scrubber")
139
- ], EFScrubber);
140
- export {
141
- EFScrubber
69
+ `];
70
+ }
71
+ updateProgress(e) {
72
+ if (!this.context || !this.scrubberRef) return;
73
+ const rect = this.scrubberRef.getBoundingClientRect();
74
+ const x = e.clientX - rect.left;
75
+ const progress = Math.max(0, Math.min(1, x / rect.width));
76
+ this.scrubProgress = progress;
77
+ this.context.currentTimeMs = progress * (this.context.targetTimegroup?.durationMs ?? 0);
78
+ }
79
+ render() {
80
+ const displayProgress = this.isDragging ? this.scrubProgress : this.lastTimeUpdateProgress;
81
+ return html`
82
+ <div
83
+ ${ref((el) => {
84
+ this.scrubberRef = el;
85
+ })}
86
+ part="scrubber"
87
+ class="scrubber"
88
+ @mousedown=${this.boundHandleMouseDown}
89
+ >
90
+ <div class="progress" style="width: ${displayProgress * 100}%"></div>
91
+ <div class="handle" style="left: ${displayProgress * 100}%"></div>
92
+ </div>
93
+ `;
94
+ }
95
+ connectedCallback() {
96
+ super.connectedCallback();
97
+ window.addEventListener("mouseup", this.boundHandleMouseUp);
98
+ window.addEventListener("mousemove", this.boundHandleMouseMove);
99
+ if (this.context) this.context.addEventListener("timeupdate", (e) => {
100
+ this.lastTimeUpdateProgress = e.detail.progress;
101
+ });
102
+ }
103
+ disconnectedCallback() {
104
+ super.disconnectedCallback();
105
+ window.removeEventListener("mouseup", this.boundHandleMouseUp);
106
+ window.removeEventListener("mousemove", this.boundHandleMouseMove);
107
+ }
142
108
  };
109
+ _decorate([consume({
110
+ context: efContext,
111
+ subscribe: true
112
+ })], EFScrubber.prototype, "context", void 0);
113
+ _decorate([consume({
114
+ context: playingContext,
115
+ subscribe: true
116
+ })], EFScrubber.prototype, "playing", void 0);
117
+ _decorate([state()], EFScrubber.prototype, "lastTimeUpdateProgress", void 0);
118
+ _decorate([state()], EFScrubber.prototype, "scrubProgress", void 0);
119
+ _decorate([state()], EFScrubber.prototype, "isDragging", void 0);
120
+ EFScrubber = _decorate([customElement("ef-scrubber")], EFScrubber);
121
+ export { EFScrubber };