@editframe/elements 0.21.0-beta.0 → 0.23.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 (142) hide show
  1. package/dist/EF_FRAMEGEN.js +2 -3
  2. package/dist/attachContextRoot.d.ts +1 -0
  3. package/dist/attachContextRoot.js +9 -0
  4. package/dist/elements/ContextProxiesController.d.ts +1 -2
  5. package/dist/elements/EFAudio.js +2 -2
  6. package/dist/elements/EFCaptions.d.ts +1 -3
  7. package/dist/elements/EFCaptions.js +59 -51
  8. package/dist/elements/EFImage.js +2 -2
  9. package/dist/elements/EFMedia/AssetIdMediaEngine.js +1 -2
  10. package/dist/elements/EFMedia/AssetMediaEngine.js +1 -3
  11. package/dist/elements/EFMedia/BufferedSeekingInput.d.ts +1 -1
  12. package/dist/elements/EFMedia/BufferedSeekingInput.js +2 -4
  13. package/dist/elements/EFMedia/audioTasks/makeAudioBufferTask.js +4 -7
  14. package/dist/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.js +1 -2
  15. package/dist/elements/EFMedia/shared/AudioSpanUtils.js +5 -9
  16. package/dist/elements/EFMedia/shared/BufferUtils.js +1 -3
  17. package/dist/elements/EFMedia/videoTasks/makeVideoBufferTask.js +4 -7
  18. package/dist/elements/EFMedia.d.ts +19 -0
  19. package/dist/elements/EFMedia.js +19 -2
  20. package/dist/elements/EFSourceMixin.js +1 -1
  21. package/dist/elements/EFSurface.js +1 -1
  22. package/dist/elements/EFTemporal.browsertest.d.ts +11 -0
  23. package/dist/elements/EFTemporal.d.ts +10 -0
  24. package/dist/elements/EFTemporal.js +82 -5
  25. package/dist/elements/EFThumbnailStrip.js +9 -16
  26. package/dist/elements/EFTimegroup.browsertest.d.ts +3 -3
  27. package/dist/elements/EFTimegroup.d.ts +35 -14
  28. package/dist/elements/EFTimegroup.js +72 -120
  29. package/dist/elements/EFVideo.d.ts +10 -0
  30. package/dist/elements/EFVideo.js +15 -2
  31. package/dist/elements/EFWaveform.js +10 -18
  32. package/dist/elements/SampleBuffer.js +1 -2
  33. package/dist/elements/TargetController.js +2 -2
  34. package/dist/elements/renderTemporalAudio.d.ts +10 -0
  35. package/dist/elements/renderTemporalAudio.js +35 -0
  36. package/dist/elements/updateAnimations.js +7 -10
  37. package/dist/gui/ContextMixin.d.ts +5 -5
  38. package/dist/gui/ContextMixin.js +151 -117
  39. package/dist/gui/Controllable.browsertest.d.ts +0 -0
  40. package/dist/gui/Controllable.d.ts +15 -0
  41. package/dist/gui/Controllable.js +9 -0
  42. package/dist/gui/EFConfiguration.js +1 -1
  43. package/dist/gui/EFControls.browsertest.d.ts +11 -0
  44. package/dist/gui/EFControls.d.ts +18 -4
  45. package/dist/gui/EFControls.js +67 -25
  46. package/dist/gui/EFDial.browsertest.d.ts +0 -0
  47. package/dist/gui/EFDial.d.ts +18 -0
  48. package/dist/gui/EFDial.js +141 -0
  49. package/dist/gui/EFFilmstrip.browsertest.d.ts +11 -0
  50. package/dist/gui/EFFilmstrip.d.ts +12 -2
  51. package/dist/gui/EFFilmstrip.js +140 -34
  52. package/dist/gui/EFFitScale.js +2 -4
  53. package/dist/gui/EFFocusOverlay.js +1 -1
  54. package/dist/gui/EFPause.browsertest.d.ts +0 -0
  55. package/dist/gui/EFPause.d.ts +23 -0
  56. package/dist/gui/EFPause.js +59 -0
  57. package/dist/gui/EFPlay.browsertest.d.ts +0 -0
  58. package/dist/gui/EFPlay.d.ts +23 -0
  59. package/dist/gui/EFPlay.js +59 -0
  60. package/dist/gui/EFPreview.d.ts +4 -0
  61. package/dist/gui/EFPreview.js +15 -6
  62. package/dist/gui/EFResizableBox.browsertest.d.ts +0 -0
  63. package/dist/gui/EFResizableBox.d.ts +34 -0
  64. package/dist/gui/EFResizableBox.js +547 -0
  65. package/dist/gui/EFScrubber.d.ts +9 -3
  66. package/dist/gui/EFScrubber.js +7 -7
  67. package/dist/gui/EFTimeDisplay.d.ts +7 -1
  68. package/dist/gui/EFTimeDisplay.js +5 -5
  69. package/dist/gui/EFToggleLoop.d.ts +9 -3
  70. package/dist/gui/EFToggleLoop.js +6 -4
  71. package/dist/gui/EFTogglePlay.d.ts +12 -4
  72. package/dist/gui/EFTogglePlay.js +24 -19
  73. package/dist/gui/EFWorkbench.js +1 -1
  74. package/dist/gui/PlaybackController.d.ts +67 -0
  75. package/dist/gui/PlaybackController.js +310 -0
  76. package/dist/gui/TWMixin.js +1 -1
  77. package/dist/gui/TargetOrContextMixin.d.ts +10 -0
  78. package/dist/gui/TargetOrContextMixin.js +98 -0
  79. package/dist/gui/efContext.d.ts +2 -2
  80. package/dist/index.d.ts +4 -0
  81. package/dist/index.js +5 -1
  82. package/dist/otel/setupBrowserTracing.d.ts +1 -1
  83. package/dist/otel/setupBrowserTracing.js +6 -4
  84. package/dist/otel/tracingHelpers.js +1 -2
  85. package/dist/style.css +1 -1
  86. package/package.json +5 -5
  87. package/src/elements/ContextProxiesController.ts +10 -10
  88. package/src/elements/EFAudio.ts +1 -0
  89. package/src/elements/EFCaptions.browsertest.ts +128 -58
  90. package/src/elements/EFCaptions.ts +60 -34
  91. package/src/elements/EFImage.browsertest.ts +1 -2
  92. package/src/elements/EFMedia/JitMediaEngine.browsertest.ts +3 -0
  93. package/src/elements/EFMedia/audioTasks/makeAudioSeekTask.chunkboundary.regression.browsertest.ts +1 -1
  94. package/src/elements/EFMedia.browsertest.ts +8 -15
  95. package/src/elements/EFMedia.ts +38 -7
  96. package/src/elements/EFSurface.browsertest.ts +2 -6
  97. package/src/elements/EFSurface.ts +1 -0
  98. package/src/elements/EFTemporal.browsertest.ts +58 -1
  99. package/src/elements/EFTemporal.ts +140 -4
  100. package/src/elements/EFThumbnailStrip.browsertest.ts +2 -8
  101. package/src/elements/EFThumbnailStrip.ts +1 -0
  102. package/src/elements/EFTimegroup.browsertest.ts +6 -7
  103. package/src/elements/EFTimegroup.ts +162 -244
  104. package/src/elements/EFVideo.browsertest.ts +143 -47
  105. package/src/elements/EFVideo.ts +26 -0
  106. package/src/elements/FetchContext.browsertest.ts +7 -2
  107. package/src/elements/TargetController.browsertest.ts +1 -0
  108. package/src/elements/TargetController.ts +1 -0
  109. package/src/elements/renderTemporalAudio.ts +108 -0
  110. package/src/elements/updateAnimations.browsertest.ts +181 -6
  111. package/src/elements/updateAnimations.ts +6 -6
  112. package/src/gui/ContextMixin.browsertest.ts +274 -27
  113. package/src/gui/ContextMixin.ts +230 -175
  114. package/src/gui/Controllable.browsertest.ts +258 -0
  115. package/src/gui/Controllable.ts +41 -0
  116. package/src/gui/EFControls.browsertest.ts +294 -80
  117. package/src/gui/EFControls.ts +139 -28
  118. package/src/gui/EFDial.browsertest.ts +84 -0
  119. package/src/gui/EFDial.ts +172 -0
  120. package/src/gui/EFFilmstrip.browsertest.ts +712 -0
  121. package/src/gui/EFFilmstrip.ts +213 -23
  122. package/src/gui/EFPause.browsertest.ts +202 -0
  123. package/src/gui/EFPause.ts +73 -0
  124. package/src/gui/EFPlay.browsertest.ts +202 -0
  125. package/src/gui/EFPlay.ts +73 -0
  126. package/src/gui/EFPreview.ts +20 -5
  127. package/src/gui/EFResizableBox.browsertest.ts +79 -0
  128. package/src/gui/EFResizableBox.ts +898 -0
  129. package/src/gui/EFScrubber.ts +7 -5
  130. package/src/gui/EFTimeDisplay.browsertest.ts +19 -19
  131. package/src/gui/EFTimeDisplay.ts +3 -1
  132. package/src/gui/EFToggleLoop.ts +6 -5
  133. package/src/gui/EFTogglePlay.ts +30 -23
  134. package/src/gui/PlaybackController.ts +522 -0
  135. package/src/gui/TWMixin.css +3 -0
  136. package/src/gui/TargetOrContextMixin.ts +185 -0
  137. package/src/gui/efContext.ts +2 -2
  138. package/src/otel/setupBrowserTracing.ts +17 -12
  139. package/test/cache-integration-verification.browsertest.ts +1 -1
  140. package/types.json +1 -1
  141. package/dist/elements/ContextProxiesController.js +0 -49
  142. /package/dist/_virtual/{_@oxc-project_runtime@0.93.0 → _@oxc-project_runtime@0.94.0}/helpers/decorate.js +0 -0
@@ -1,8 +1,9 @@
1
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js";
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js";
2
+ import { isEFTemporal } from "../elements/EFTemporal.js";
2
3
  import { focusedElementContext } from "./focusedElementContext.js";
3
4
  import { ContextMixin } from "./ContextMixin.js";
4
- import { EFTargetable } from "../elements/TargetController.js";
5
5
  import { TWMixin } from "./TWMixin2.js";
6
+ import { EFTargetable } from "../elements/TargetController.js";
6
7
  import { provide } from "@lit/context";
7
8
  import { LitElement, css, html } from "lit";
8
9
  import { customElement } from "lit/decorators.js";
@@ -16,17 +17,25 @@ var EFPreview = class EFPreview$1 extends EFTargetable(ContextMixin(TWMixin(LitE
16
17
  }
17
18
  `];
18
19
  }
20
+ findClosestTemporal(element) {
21
+ let current = element;
22
+ while (current && current !== this) {
23
+ if (isEFTemporal(current)) return current;
24
+ current = current.parentElement;
25
+ }
26
+ return null;
27
+ }
19
28
  constructor() {
20
29
  super();
21
30
  this.addEventListener("mouseover", (e) => {
22
31
  const target = e.target;
23
- const timegroup = target.closest("ef-timegroup");
24
- if (target !== this && timegroup) this.focusedElement = target;
32
+ const temporal = this.findClosestTemporal(target);
33
+ if (target !== this && temporal) this.focusedElement = target;
25
34
  });
26
35
  this.addEventListener("mouseout", (e) => {
27
36
  const relatedTarget = e.relatedTarget;
28
- const targetingTimegroup = relatedTarget?.closest("ef-timegroup");
29
- if (!this.contains(relatedTarget) || relatedTarget === this || !targetingTimegroup) this.focusedElement = void 0;
37
+ const targetingTemporal = this.findClosestTemporal(relatedTarget);
38
+ if (!this.contains(relatedTarget) || relatedTarget === this || !targetingTemporal) this.focusedElement = void 0;
30
39
  });
31
40
  }
32
41
  render() {
File without changes
@@ -0,0 +1,34 @@
1
+ import { LitElement } from 'lit';
2
+ export interface BoxBounds {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare class EFResizableBox extends LitElement {
9
+ bounds: BoxBounds;
10
+ private containerWidth;
11
+ private containerHeight;
12
+ minSize: number;
13
+ private isDragging;
14
+ private dragMode;
15
+ private interaction;
16
+ private modifiers;
17
+ static styles: import('lit').CSSResult;
18
+ private resizeObserver?;
19
+ connectedCallback(): void;
20
+ private handlePointerDown;
21
+ private handlePointerMove;
22
+ private handlePointerUp;
23
+ private calculateBoundsWithModeAwareConstraints;
24
+ private constrainBoundsForMode;
25
+ private isValidBounds;
26
+ private constrainWithAspectRatio;
27
+ private constrainCenterResize;
28
+ private constrainCenterResizeWithAspectRatio;
29
+ private simpleConstrainBounds;
30
+ private constrainResizeDeltas;
31
+ private dispatchBoundsChange;
32
+ render(): import('lit-html').TemplateResult<1>;
33
+ private renderHandles;
34
+ }
@@ -0,0 +1,547 @@
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js";
2
+ import { LitElement, css, html } from "lit";
3
+ import { customElement, property, state } from "lit/decorators.js";
4
+ import { styleMap } from "lit/directives/style-map.js";
5
+ var DEFAULT_MIN_SIZE = 10;
6
+ var CENTER_RESIZE_MULTIPLIER = 2;
7
+ function constrainMovementDeltas(initialBounds, deltaX, deltaY, container) {
8
+ const maxLeftMovement = -initialBounds.x;
9
+ const maxRightMovement = container.width - (initialBounds.x + initialBounds.width);
10
+ const maxUpMovement = -initialBounds.y;
11
+ const maxDownMovement = container.height - (initialBounds.y + initialBounds.height);
12
+ return {
13
+ deltaX: Math.max(maxLeftMovement, Math.min(maxRightMovement, deltaX)),
14
+ deltaY: Math.max(maxUpMovement, Math.min(maxDownMovement, deltaY))
15
+ };
16
+ }
17
+ function calculateNormalResize(context, handle) {
18
+ const { initialBounds, movement } = context;
19
+ const { deltaX, deltaY } = movement;
20
+ switch (handle) {
21
+ case "bottom-right": return {
22
+ ...initialBounds,
23
+ width: initialBounds.width + deltaX,
24
+ height: initialBounds.height + deltaY
25
+ };
26
+ case "top-left": {
27
+ const rightEdge = initialBounds.x + initialBounds.width;
28
+ const bottomEdge = initialBounds.y + initialBounds.height;
29
+ const newX = initialBounds.x + deltaX;
30
+ const newY = initialBounds.y + deltaY;
31
+ return {
32
+ x: newX,
33
+ y: newY,
34
+ width: rightEdge - newX,
35
+ height: bottomEdge - newY
36
+ };
37
+ }
38
+ case "top-right": {
39
+ const bottomEdge = initialBounds.y + initialBounds.height;
40
+ const newY = initialBounds.y + deltaY;
41
+ return {
42
+ ...initialBounds,
43
+ y: newY,
44
+ width: initialBounds.width + deltaX,
45
+ height: bottomEdge - newY
46
+ };
47
+ }
48
+ case "bottom-left": {
49
+ const rightEdge = initialBounds.x + initialBounds.width;
50
+ const newX = initialBounds.x + deltaX;
51
+ return {
52
+ ...initialBounds,
53
+ x: newX,
54
+ width: rightEdge - newX,
55
+ height: initialBounds.height + deltaY
56
+ };
57
+ }
58
+ case "top": {
59
+ const bottomEdge = initialBounds.y + initialBounds.height;
60
+ const newY = initialBounds.y + deltaY;
61
+ return {
62
+ ...initialBounds,
63
+ y: newY,
64
+ height: bottomEdge - newY
65
+ };
66
+ }
67
+ case "right": return {
68
+ ...initialBounds,
69
+ width: initialBounds.width + deltaX
70
+ };
71
+ case "bottom": return {
72
+ ...initialBounds,
73
+ height: initialBounds.height + deltaY
74
+ };
75
+ case "left": {
76
+ const rightEdge = initialBounds.x + initialBounds.width;
77
+ const newX = initialBounds.x + deltaX;
78
+ return {
79
+ ...initialBounds,
80
+ x: newX,
81
+ width: rightEdge - newX
82
+ };
83
+ }
84
+ default: return initialBounds;
85
+ }
86
+ }
87
+ function calculateAspectRatioResize(context, handle) {
88
+ const { initialBounds, movement, constraints } = context;
89
+ const { deltaX, deltaY } = movement;
90
+ if (!constraints.aspectRatio) return initialBounds;
91
+ const aspectRatio = constraints.aspectRatio;
92
+ const widthMovement = deltaX;
93
+ const heightMovement = deltaY * aspectRatio;
94
+ let movementValue;
95
+ switch (handle) {
96
+ case "bottom-right":
97
+ case "top-left":
98
+ movementValue = (widthMovement + heightMovement) / 2;
99
+ break;
100
+ case "top-right":
101
+ case "bottom-left":
102
+ movementValue = (widthMovement - heightMovement) / 2;
103
+ break;
104
+ default: movementValue = widthMovement;
105
+ }
106
+ const baseWidth = handle === "top-left" || handle === "bottom-left" ? initialBounds.width - movementValue : initialBounds.width + movementValue;
107
+ const width = Math.max(constraints.minSize, baseWidth);
108
+ const height = width / aspectRatio;
109
+ const newBounds = {
110
+ ...initialBounds,
111
+ width,
112
+ height
113
+ };
114
+ switch (handle) {
115
+ case "top-left":
116
+ newBounds.x = initialBounds.x + initialBounds.width - width;
117
+ newBounds.y = initialBounds.y + initialBounds.height - height;
118
+ break;
119
+ case "top-right":
120
+ newBounds.y = initialBounds.y + initialBounds.height - height;
121
+ break;
122
+ case "bottom-left":
123
+ newBounds.x = initialBounds.x + initialBounds.width - width;
124
+ break;
125
+ }
126
+ return newBounds;
127
+ }
128
+ function calculateCenterResize(context, handle) {
129
+ const { initialBounds, movement } = context;
130
+ const { deltaX, deltaY } = movement;
131
+ const centerX = initialBounds.x + initialBounds.width / 2;
132
+ const centerY = initialBounds.y + initialBounds.height / 2;
133
+ let widthChange = 0;
134
+ let heightChange = 0;
135
+ switch (handle) {
136
+ case "bottom-right":
137
+ widthChange = deltaX * CENTER_RESIZE_MULTIPLIER;
138
+ heightChange = deltaY * CENTER_RESIZE_MULTIPLIER;
139
+ break;
140
+ case "top-left":
141
+ widthChange = -deltaX * CENTER_RESIZE_MULTIPLIER;
142
+ heightChange = -deltaY * CENTER_RESIZE_MULTIPLIER;
143
+ break;
144
+ case "top-right":
145
+ widthChange = deltaX * CENTER_RESIZE_MULTIPLIER;
146
+ heightChange = -deltaY * CENTER_RESIZE_MULTIPLIER;
147
+ break;
148
+ case "bottom-left":
149
+ widthChange = -deltaX * CENTER_RESIZE_MULTIPLIER;
150
+ heightChange = deltaY * CENTER_RESIZE_MULTIPLIER;
151
+ break;
152
+ case "top":
153
+ case "bottom":
154
+ heightChange = (handle === "bottom" ? deltaY : -deltaY) * CENTER_RESIZE_MULTIPLIER;
155
+ break;
156
+ case "left":
157
+ case "right":
158
+ widthChange = (handle === "right" ? deltaX : -deltaX) * CENTER_RESIZE_MULTIPLIER;
159
+ break;
160
+ }
161
+ const newWidth = initialBounds.width + widthChange;
162
+ const newHeight = initialBounds.height + heightChange;
163
+ return {
164
+ x: centerX - newWidth / 2,
165
+ y: centerY - newHeight / 2,
166
+ width: newWidth,
167
+ height: newHeight
168
+ };
169
+ }
170
+ function calculateCenterResizeWithAspectRatio(context, handle) {
171
+ const { initialBounds, movement, constraints } = context;
172
+ const { deltaX, deltaY } = movement;
173
+ if (!constraints.aspectRatio) return initialBounds;
174
+ const aspectRatio = constraints.aspectRatio;
175
+ const centerX = initialBounds.x + initialBounds.width / 2;
176
+ const centerY = initialBounds.y + initialBounds.height / 2;
177
+ let movementValue;
178
+ switch (handle) {
179
+ case "bottom-right":
180
+ movementValue = Math.max(deltaX, deltaY);
181
+ break;
182
+ case "top-left":
183
+ movementValue = -Math.max(-deltaX, -deltaY);
184
+ break;
185
+ case "top-right":
186
+ movementValue = Math.max(deltaX, -deltaY);
187
+ break;
188
+ case "bottom-left":
189
+ movementValue = Math.max(-deltaX, deltaY);
190
+ break;
191
+ case "top":
192
+ case "bottom":
193
+ movementValue = handle === "bottom" ? deltaY : -deltaY;
194
+ break;
195
+ case "left":
196
+ case "right":
197
+ movementValue = handle === "right" ? deltaX : -deltaX;
198
+ break;
199
+ default: movementValue = Math.max(deltaX, deltaY);
200
+ }
201
+ const newWidth = Math.max(constraints.minSize, initialBounds.width + movementValue * CENTER_RESIZE_MULTIPLIER);
202
+ const newHeight = newWidth / aspectRatio;
203
+ return {
204
+ x: centerX - newWidth / 2,
205
+ y: centerY - newHeight / 2,
206
+ width: newWidth,
207
+ height: newHeight
208
+ };
209
+ }
210
+ var EFResizableBox = class EFResizableBox$1 extends LitElement {
211
+ constructor(..._args) {
212
+ super(..._args);
213
+ this.bounds = {
214
+ x: 0,
215
+ y: 0,
216
+ width: 100,
217
+ height: 100
218
+ };
219
+ this.containerWidth = 0;
220
+ this.containerHeight = 0;
221
+ this.minSize = DEFAULT_MIN_SIZE;
222
+ this.isDragging = false;
223
+ this.dragMode = null;
224
+ this.interaction = null;
225
+ this.modifiers = {
226
+ shift: false,
227
+ alt: false
228
+ };
229
+ this.handlePointerMove = (e) => {
230
+ if (!this.isDragging || !this.interaction || e.pointerId !== this.interaction.pointerId) return;
231
+ const deltaX = e.clientX - this.interaction.startPoint.x;
232
+ const deltaY = e.clientY - this.interaction.startPoint.y;
233
+ this.modifiers = {
234
+ shift: e.shiftKey,
235
+ alt: e.altKey
236
+ };
237
+ if (this.dragMode === "move") {
238
+ const constrainedMovement = constrainMovementDeltas(this.interaction.initialBounds, deltaX, deltaY, {
239
+ width: this.containerWidth,
240
+ height: this.containerHeight
241
+ });
242
+ this.bounds = {
243
+ ...this.interaction.initialBounds,
244
+ x: this.interaction.initialBounds.x + constrainedMovement.deltaX,
245
+ y: this.interaction.initialBounds.y + constrainedMovement.deltaY
246
+ };
247
+ } else if (this.dragMode === "resize" && this.interaction.target.handle) {
248
+ const context = {
249
+ initialBounds: this.interaction.initialBounds,
250
+ container: {
251
+ width: this.containerWidth,
252
+ height: this.containerHeight
253
+ },
254
+ constraints: {
255
+ minSize: this.minSize,
256
+ aspectRatio: this.modifiers.shift ? this.interaction.initialBounds.width / this.interaction.initialBounds.height : void 0
257
+ },
258
+ movement: {
259
+ deltaX,
260
+ deltaY
261
+ },
262
+ modifiers: {
263
+ centerResize: this.modifiers.alt,
264
+ preserveAspectRatio: this.modifiers.shift
265
+ }
266
+ };
267
+ this.bounds = this.calculateBoundsWithModeAwareConstraints(context, this.interaction.target.handle);
268
+ }
269
+ this.dispatchBoundsChange();
270
+ };
271
+ this.handlePointerUp = () => {
272
+ this.isDragging = false;
273
+ this.dragMode = null;
274
+ this.interaction = null;
275
+ document.removeEventListener("pointermove", this.handlePointerMove);
276
+ document.removeEventListener("pointerup", this.handlePointerUp);
277
+ };
278
+ }
279
+ static {
280
+ this.styles = css`
281
+ .box {
282
+ position: absolute;
283
+ border: 2px solid var(--ef-resizable-box-border-color, #3b82f6);
284
+ background-color: var(--ef-resizable-box-bg-color, rgba(59, 130, 246, 0.2));
285
+ cursor: grab;
286
+ }
287
+ .box.dragging {
288
+ border-color: var(--ef-resizable-box-dragging-border-color, #2563eb);
289
+ background-color: var(--ef-resizable-box-dragging-bg-color, rgba(37, 99, 235, 0.3));
290
+ }
291
+ .handle {
292
+ position: absolute;
293
+ background-color: var(--ef-resizable-box-handle-color, #3b82f6);
294
+ touch-action: none;
295
+ }
296
+ .top-left { top: -4px; left: -4px; width: 8px; height: 8px; cursor: nwse-resize; }
297
+ .top-right { top: -4px; right: -4px; width: 8px; height: 8px; cursor: nesw-resize; }
298
+ .bottom-left { bottom: -4px; left: -4px; width: 8px; height: 8px; cursor: nesw-resize; }
299
+ .bottom-right { bottom: -4px; right: -4px; width: 8px; height: 8px; cursor: nwse-resize; }
300
+ .top { top: -4px; left: 4px; right: 4px; height: 8px; cursor: ns-resize; }
301
+ .right { top: 4px; bottom: 4px; right: -4px; width: 8px; cursor: ew-resize; }
302
+ .bottom { bottom: -4px; left: 4px; right: 4px; height: 8px; cursor: ns-resize; }
303
+ .left { top: 4px; bottom: 4px; left: -4px; width: 8px; cursor: ew-resize; }
304
+ `;
305
+ }
306
+ connectedCallback() {
307
+ super.connectedCallback();
308
+ if (this.offsetParent) {
309
+ this.containerWidth = this.offsetParent.clientWidth;
310
+ this.containerHeight = this.offsetParent.clientHeight;
311
+ }
312
+ this.resizeObserver = new ResizeObserver(() => {
313
+ if (this.offsetParent) {
314
+ this.containerWidth = this.offsetParent.clientWidth;
315
+ this.containerHeight = this.offsetParent.clientHeight;
316
+ }
317
+ });
318
+ if (this.offsetParent) this.resizeObserver.observe(this.offsetParent);
319
+ }
320
+ handlePointerDown(e, mode, handle) {
321
+ e.preventDefault();
322
+ e.stopPropagation();
323
+ this.isDragging = true;
324
+ this.dragMode = mode;
325
+ this.interaction = {
326
+ startPoint: {
327
+ x: e.clientX,
328
+ y: e.clientY
329
+ },
330
+ target: {
331
+ mode,
332
+ handle
333
+ },
334
+ initialBounds: { ...this.bounds },
335
+ pointerId: e.pointerId
336
+ };
337
+ this.modifiers = {
338
+ shift: e.shiftKey,
339
+ alt: e.altKey
340
+ };
341
+ document.addEventListener("pointermove", this.handlePointerMove);
342
+ document.addEventListener("pointerup", this.handlePointerUp);
343
+ }
344
+ calculateBoundsWithModeAwareConstraints(context, handle) {
345
+ const { modifiers, constraints, container, initialBounds } = context;
346
+ if (!modifiers.centerResize && !modifiers.preserveAspectRatio) {
347
+ const constrainedMovement = this.constrainResizeDeltas(initialBounds, context.movement.deltaX, context.movement.deltaY, handle, container, constraints.minSize);
348
+ return calculateNormalResize({
349
+ ...context,
350
+ movement: constrainedMovement
351
+ }, handle);
352
+ }
353
+ let idealBounds;
354
+ if (modifiers.centerResize && modifiers.preserveAspectRatio) idealBounds = calculateCenterResizeWithAspectRatio(context, handle);
355
+ else if (modifiers.centerResize) idealBounds = calculateCenterResize(context, handle);
356
+ else idealBounds = calculateAspectRatioResize(context, handle);
357
+ return this.constrainBoundsForMode(idealBounds, context, handle);
358
+ }
359
+ constrainBoundsForMode(idealBounds, context, handle) {
360
+ const { container, constraints, modifiers } = context;
361
+ if (this.isValidBounds(idealBounds, container, constraints.minSize)) return idealBounds;
362
+ if (modifiers.centerResize && modifiers.preserveAspectRatio && constraints.aspectRatio) return this.constrainCenterResizeWithAspectRatio(idealBounds, context);
363
+ if (modifiers.preserveAspectRatio && constraints.aspectRatio) return this.constrainWithAspectRatio(idealBounds, context, handle);
364
+ if (modifiers.centerResize) return this.constrainCenterResize(idealBounds, context);
365
+ return this.simpleConstrainBounds(idealBounds, container, constraints.minSize);
366
+ }
367
+ isValidBounds(bounds, container, minSize) {
368
+ return bounds.x >= 0 && bounds.y >= 0 && bounds.width >= minSize && bounds.height >= minSize && bounds.x + bounds.width <= container.width && bounds.y + bounds.height <= container.height;
369
+ }
370
+ constrainWithAspectRatio(idealBounds, context, handle) {
371
+ const { container, constraints, initialBounds } = context;
372
+ if (!constraints.aspectRatio) return initialBounds;
373
+ const aspectRatio = constraints.aspectRatio;
374
+ const maxWidth = container.width - Math.max(0, idealBounds.x);
375
+ const maxHeight = container.height - Math.max(0, idealBounds.y);
376
+ let constrainedWidth = Math.max(constraints.minSize, Math.min(maxWidth, idealBounds.width));
377
+ let constrainedHeight = constrainedWidth / aspectRatio;
378
+ if (constrainedHeight > maxHeight) {
379
+ constrainedHeight = Math.max(constraints.minSize, maxHeight);
380
+ constrainedWidth = constrainedHeight * aspectRatio;
381
+ }
382
+ if (constrainedWidth < constraints.minSize) {
383
+ constrainedWidth = constraints.minSize;
384
+ constrainedHeight = constrainedWidth / aspectRatio;
385
+ }
386
+ const result = {
387
+ ...idealBounds,
388
+ width: constrainedWidth,
389
+ height: constrainedHeight
390
+ };
391
+ switch (handle) {
392
+ case "top-left":
393
+ result.x = initialBounds.x + initialBounds.width - constrainedWidth;
394
+ result.y = initialBounds.y + initialBounds.height - constrainedHeight;
395
+ break;
396
+ case "top-right":
397
+ result.y = initialBounds.y + initialBounds.height - constrainedHeight;
398
+ break;
399
+ case "bottom-left":
400
+ result.x = initialBounds.x + initialBounds.width - constrainedWidth;
401
+ break;
402
+ }
403
+ result.x = Math.max(0, Math.min(container.width - result.width, result.x));
404
+ result.y = Math.max(0, Math.min(container.height - result.height, result.y));
405
+ return result;
406
+ }
407
+ constrainCenterResize(idealBounds, context) {
408
+ const { container, constraints, initialBounds } = context;
409
+ const centerX = initialBounds.x + initialBounds.width / 2;
410
+ const centerY = initialBounds.y + initialBounds.height / 2;
411
+ const maxWidthFromCenter = Math.min(centerX * 2, (container.width - centerX) * 2);
412
+ const maxHeightFromCenter = Math.min(centerY * 2, (container.height - centerY) * 2);
413
+ const constrainedWidth = Math.max(constraints.minSize, Math.min(maxWidthFromCenter, idealBounds.width));
414
+ const constrainedHeight = Math.max(constraints.minSize, Math.min(maxHeightFromCenter, idealBounds.height));
415
+ return {
416
+ x: centerX - constrainedWidth / 2,
417
+ y: centerY - constrainedHeight / 2,
418
+ width: constrainedWidth,
419
+ height: constrainedHeight
420
+ };
421
+ }
422
+ constrainCenterResizeWithAspectRatio(idealBounds, context) {
423
+ const { container, constraints, initialBounds } = context;
424
+ if (!constraints.aspectRatio) return initialBounds;
425
+ const aspectRatio = constraints.aspectRatio;
426
+ const centerX = initialBounds.x + initialBounds.width / 2;
427
+ const centerY = initialBounds.y + initialBounds.height / 2;
428
+ const maxWidthFromCenter = Math.min(centerX * 2, (container.width - centerX) * 2);
429
+ const maxHeightFromCenter = Math.min(centerY * 2, (container.height - centerY) * 2);
430
+ let constrainedWidth = Math.max(constraints.minSize, Math.min(maxWidthFromCenter, idealBounds.width));
431
+ let constrainedHeight = constrainedWidth / aspectRatio;
432
+ if (constrainedHeight > maxHeightFromCenter) {
433
+ constrainedHeight = Math.max(constraints.minSize, maxHeightFromCenter);
434
+ constrainedWidth = constrainedHeight * aspectRatio;
435
+ }
436
+ if (constrainedWidth < constraints.minSize) {
437
+ constrainedWidth = constraints.minSize;
438
+ constrainedHeight = constrainedWidth / aspectRatio;
439
+ }
440
+ if (constrainedHeight < constraints.minSize) {
441
+ constrainedHeight = constraints.minSize;
442
+ constrainedWidth = constrainedHeight * aspectRatio;
443
+ }
444
+ return {
445
+ x: centerX - constrainedWidth / 2,
446
+ y: centerY - constrainedHeight / 2,
447
+ width: constrainedWidth,
448
+ height: constrainedHeight
449
+ };
450
+ }
451
+ simpleConstrainBounds(bounds, container, minSize) {
452
+ return {
453
+ x: Math.max(0, Math.min(container.width - bounds.width, bounds.x)),
454
+ y: Math.max(0, Math.min(container.height - bounds.height, bounds.y)),
455
+ width: Math.max(minSize, Math.min(container.width - bounds.x, bounds.width)),
456
+ height: Math.max(minSize, Math.min(container.height - bounds.y, bounds.height))
457
+ };
458
+ }
459
+ constrainResizeDeltas(initialBounds, deltaX, deltaY, handle, container, minSize) {
460
+ let constrainedDeltaX = deltaX;
461
+ let constrainedDeltaY = deltaY;
462
+ switch (handle) {
463
+ case "bottom-right":
464
+ constrainedDeltaX = Math.max(minSize - initialBounds.width, Math.min(container.width - initialBounds.x - initialBounds.width, deltaX));
465
+ constrainedDeltaY = Math.max(minSize - initialBounds.height, Math.min(container.height - initialBounds.y - initialBounds.height, deltaY));
466
+ break;
467
+ case "top-left":
468
+ constrainedDeltaX = Math.max(-initialBounds.x, Math.min(initialBounds.width - minSize, deltaX));
469
+ constrainedDeltaY = Math.max(-initialBounds.y, Math.min(initialBounds.height - minSize, deltaY));
470
+ break;
471
+ case "top-right":
472
+ constrainedDeltaX = Math.max(minSize - initialBounds.width, Math.min(container.width - initialBounds.x - initialBounds.width, deltaX));
473
+ constrainedDeltaY = Math.max(-initialBounds.y, Math.min(initialBounds.height - minSize, deltaY));
474
+ break;
475
+ case "bottom-left":
476
+ constrainedDeltaX = Math.max(-initialBounds.x, Math.min(initialBounds.width - minSize, deltaX));
477
+ constrainedDeltaY = Math.max(minSize - initialBounds.height, Math.min(container.height - initialBounds.y - initialBounds.height, deltaY));
478
+ break;
479
+ case "right":
480
+ constrainedDeltaX = Math.max(minSize - initialBounds.width, Math.min(container.width - initialBounds.x - initialBounds.width, deltaX));
481
+ break;
482
+ case "left":
483
+ constrainedDeltaX = Math.max(-initialBounds.x, Math.min(initialBounds.width - minSize, deltaX));
484
+ break;
485
+ case "bottom":
486
+ constrainedDeltaY = Math.max(minSize - initialBounds.height, Math.min(container.height - initialBounds.y - initialBounds.height, deltaY));
487
+ break;
488
+ case "top":
489
+ constrainedDeltaY = Math.max(-initialBounds.y, Math.min(initialBounds.height - minSize, deltaY));
490
+ break;
491
+ }
492
+ return {
493
+ deltaX: constrainedDeltaX,
494
+ deltaY: constrainedDeltaY
495
+ };
496
+ }
497
+ dispatchBoundsChange() {
498
+ this.dispatchEvent(new CustomEvent("bounds-change", {
499
+ detail: { bounds: this.bounds },
500
+ bubbles: true,
501
+ composed: true
502
+ }));
503
+ }
504
+ render() {
505
+ const boxStyles = {
506
+ left: `${this.bounds.x}px`,
507
+ top: `${this.bounds.y}px`,
508
+ width: `${this.bounds.width}px`,
509
+ height: `${this.bounds.height}px`
510
+ };
511
+ return html`
512
+ <div
513
+ class="box ${this.isDragging ? "dragging" : ""}"
514
+ style=${styleMap(boxStyles)}
515
+ @pointerdown=${(e) => this.handlePointerDown(e, "move")}
516
+ >
517
+ ${this.renderHandles()}
518
+ <slot></slot>
519
+ </div>
520
+ `;
521
+ }
522
+ renderHandles() {
523
+ return [
524
+ "top-left",
525
+ "top-right",
526
+ "bottom-left",
527
+ "bottom-right",
528
+ "top",
529
+ "right",
530
+ "bottom",
531
+ "left"
532
+ ].map((handle) => html`
533
+ <div
534
+ class="handle ${handle}"
535
+ @pointerdown=${(e) => this.handlePointerDown(e, "resize", handle)}
536
+ ></div>
537
+ `);
538
+ }
539
+ };
540
+ __decorate([property({ type: Object })], EFResizableBox.prototype, "bounds", void 0);
541
+ __decorate([state()], EFResizableBox.prototype, "containerWidth", void 0);
542
+ __decorate([state()], EFResizableBox.prototype, "containerHeight", void 0);
543
+ __decorate([property({ type: Number })], EFResizableBox.prototype, "minSize", void 0);
544
+ __decorate([state()], EFResizableBox.prototype, "isDragging", void 0);
545
+ __decorate([state()], EFResizableBox.prototype, "dragMode", void 0);
546
+ EFResizableBox = __decorate([customElement("ef-resizable-box")], EFResizableBox);
547
+ export { EFResizableBox };
@@ -1,11 +1,16 @@
1
1
  import { LitElement } from 'lit';
2
- import { ContextMixinInterface } from './ContextMixin.js';
3
- export declare class EFScrubber extends LitElement {
2
+ import { ControllableInterface } from './Controllable.js';
3
+ declare const EFScrubber_base: (new (...args: any[]) => {
4
+ target: string;
5
+ targetElement: ControllableInterface | null;
6
+ effectiveContext: ControllableInterface | null;
7
+ }) & typeof LitElement;
8
+ export declare class EFScrubber extends EFScrubber_base {
4
9
  static styles: import('lit').CSSResult[];
5
- context?: ContextMixinInterface | null;
6
10
  playing: boolean;
7
11
  currentTimeMs: number;
8
12
  durationMs: number;
13
+ get context(): ControllableInterface | null;
9
14
  private scrubProgress;
10
15
  private isMoving;
11
16
  private scrubberRef?;
@@ -22,3 +27,4 @@ declare global {
22
27
  "ef-scrubber": EFScrubber;
23
28
  }
24
29
  }
30
+ export {};
@@ -1,13 +1,14 @@
1
1
  import { currentTimeContext } from "./currentTimeContext.js";
2
2
  import { durationContext } from "./durationContext.js";
3
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js";
4
- import { efContext } from "./efContext.js";
5
3
  import { playingContext } from "./playingContext.js";
4
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js";
5
+ import { efContext } from "./efContext.js";
6
+ import { TargetOrContextMixin } from "./TargetOrContextMixin.js";
6
7
  import { consume } from "@lit/context";
7
8
  import { LitElement, css, html } from "lit";
8
9
  import { customElement, state } from "lit/decorators.js";
9
10
  import { ref } from "lit/directives/ref.js";
10
- var EFScrubber = class EFScrubber$1 extends LitElement {
11
+ var EFScrubber = class EFScrubber$1 extends TargetOrContextMixin(LitElement, efContext) {
11
12
  constructor(..._args) {
12
13
  super(..._args);
13
14
  this.playing = false;
@@ -73,6 +74,9 @@ var EFScrubber = class EFScrubber$1 extends LitElement {
73
74
  ::part(handle) { }
74
75
  `];
75
76
  }
77
+ get context() {
78
+ return this.effectiveContext;
79
+ }
76
80
  updateProgress(e) {
77
81
  if (!this.context || !this.scrubberRef) return;
78
82
  const rect = this.scrubberRef.getBoundingClientRect();
@@ -109,10 +113,6 @@ var EFScrubber = class EFScrubber$1 extends LitElement {
109
113
  window.removeEventListener("pointermove", this.boundHandlePointerMove);
110
114
  }
111
115
  };
112
- __decorate([consume({
113
- context: efContext,
114
- subscribe: true
115
- })], EFScrubber.prototype, "context", void 0);
116
116
  __decorate([consume({
117
117
  context: playingContext,
118
118
  subscribe: true