@editframe/elements 0.7.0-beta.9 → 0.8.0-beta.2

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 (97) hide show
  1. package/dist/EF_FRAMEGEN.d.ts +44 -0
  2. package/dist/EF_INTERACTIVE.d.ts +1 -0
  3. package/dist/assets/dist/EncodedAsset.js +560 -0
  4. package/dist/assets/dist/MP4File.js +170 -0
  5. package/dist/assets/dist/memoize.js +14 -0
  6. package/dist/elements/CrossUpdateController.d.ts +9 -0
  7. package/dist/elements/EFAudio.d.ts +10 -0
  8. package/dist/elements/EFCaptions.d.ts +38 -0
  9. package/dist/elements/EFImage.d.ts +14 -0
  10. package/dist/elements/EFMedia.d.ts +64 -0
  11. package/dist/elements/EFSourceMixin.d.ts +12 -0
  12. package/dist/elements/EFTemporal.d.ts +38 -0
  13. package/dist/elements/EFTimegroup.browsertest.d.ts +12 -0
  14. package/dist/elements/EFTimegroup.d.ts +39 -0
  15. package/dist/elements/EFVideo.d.ts +14 -0
  16. package/dist/elements/EFWaveform.d.ts +30 -0
  17. package/dist/elements/FetchMixin.d.ts +8 -0
  18. package/dist/elements/TimegroupController.d.ts +14 -0
  19. package/dist/elements/durationConverter.d.ts +4 -0
  20. package/dist/elements/parseTimeToMs.d.ts +1 -0
  21. package/{src/EF_FRAMEGEN.ts → dist/elements/src/EF_FRAMEGEN.js} +35 -115
  22. package/dist/elements/src/EF_INTERACTIVE.js +7 -0
  23. package/dist/elements/src/elements/CrossUpdateController.js +16 -0
  24. package/dist/elements/src/elements/EFAudio.js +54 -0
  25. package/dist/elements/src/elements/EFCaptions.js +166 -0
  26. package/dist/elements/src/elements/EFImage.js +80 -0
  27. package/dist/elements/src/elements/EFMedia.js +356 -0
  28. package/dist/elements/src/elements/EFSourceMixin.js +55 -0
  29. package/dist/elements/src/elements/EFTemporal.js +234 -0
  30. package/dist/elements/src/elements/EFTimegroup.js +355 -0
  31. package/dist/elements/src/elements/EFVideo.js +110 -0
  32. package/dist/elements/src/elements/EFWaveform.js +226 -0
  33. package/dist/elements/src/elements/FetchMixin.js +28 -0
  34. package/dist/elements/src/elements/TimegroupController.js +20 -0
  35. package/dist/elements/src/elements/durationConverter.js +8 -0
  36. package/dist/elements/src/elements/parseTimeToMs.js +12 -0
  37. package/dist/elements/src/elements/util.js +11 -0
  38. package/dist/elements/src/gui/ContextMixin.js +236 -0
  39. package/dist/elements/src/gui/EFFilmstrip.js +729 -0
  40. package/dist/elements/src/gui/EFPreview.js +45 -0
  41. package/dist/elements/src/gui/EFWorkbench.js +128 -0
  42. package/dist/elements/src/gui/TWMixin.css.js +4 -0
  43. package/dist/elements/src/gui/TWMixin.js +36 -0
  44. package/dist/elements/src/gui/apiHostContext.js +5 -0
  45. package/dist/elements/src/gui/fetchContext.js +5 -0
  46. package/dist/elements/src/gui/focusContext.js +5 -0
  47. package/dist/elements/src/gui/focusedElementContext.js +7 -0
  48. package/dist/elements/src/gui/playingContext.js +5 -0
  49. package/dist/elements/src/index.js +27 -0
  50. package/dist/elements/src/msToTimeCode.js +15 -0
  51. package/dist/elements/util.d.ts +4 -0
  52. package/dist/gui/ContextMixin.d.ts +23 -0
  53. package/dist/gui/EFFilmstrip.d.ts +144 -0
  54. package/dist/gui/EFPreview.d.ts +27 -0
  55. package/dist/gui/EFWorkbench.d.ts +34 -0
  56. package/dist/gui/TWMixin.d.ts +3 -0
  57. package/dist/gui/apiHostContext.d.ts +3 -0
  58. package/dist/gui/fetchContext.d.ts +3 -0
  59. package/dist/gui/focusContext.d.ts +6 -0
  60. package/dist/gui/focusedElementContext.d.ts +3 -0
  61. package/dist/gui/playingContext.d.ts +3 -0
  62. package/dist/index.d.ts +11 -0
  63. package/dist/msToTimeCode.d.ts +1 -0
  64. package/dist/style.css +800 -0
  65. package/package.json +6 -9
  66. package/src/elements/EFAudio.ts +1 -1
  67. package/src/elements/EFCaptions.ts +9 -9
  68. package/src/elements/EFImage.ts +3 -3
  69. package/src/elements/EFMedia.ts +39 -11
  70. package/src/elements/EFSourceMixin.ts +1 -1
  71. package/src/elements/EFTemporal.ts +42 -5
  72. package/src/elements/EFTimegroup.browsertest.ts +3 -3
  73. package/src/elements/EFTimegroup.ts +9 -6
  74. package/src/elements/EFVideo.ts +2 -2
  75. package/src/elements/EFWaveform.ts +6 -6
  76. package/src/elements/FetchMixin.ts +5 -3
  77. package/src/elements/TimegroupController.ts +1 -1
  78. package/src/elements/durationConverter.ts +1 -1
  79. package/src/elements/util.ts +1 -1
  80. package/src/gui/ContextMixin.ts +256 -0
  81. package/src/gui/EFFilmstrip.ts +41 -150
  82. package/src/gui/EFPreview.ts +39 -0
  83. package/src/gui/EFWorkbench.ts +7 -105
  84. package/src/gui/TWMixin.ts +10 -3
  85. package/src/gui/apiHostContext.ts +3 -0
  86. package/src/gui/fetchContext.ts +5 -0
  87. package/src/gui/focusContext.ts +7 -0
  88. package/src/gui/focusedElementContext.ts +5 -0
  89. package/src/gui/playingContext.ts +3 -0
  90. package/CHANGELOG.md +0 -7
  91. package/postcss.config.cjs +0 -12
  92. package/src/EF_INTERACTIVE.ts +0 -2
  93. package/src/elements.css +0 -22
  94. package/src/index.ts +0 -33
  95. package/tailwind.config.ts +0 -10
  96. package/tsconfig.json +0 -4
  97. package/vite.config.ts +0 -8
@@ -0,0 +1,729 @@
1
+ import { css, html, nothing, LitElement } from "lit";
2
+ import { property, customElement, state, eventOptions } from "lit/decorators.js";
3
+ import { consume } from "@lit/context";
4
+ import { styleMap } from "lit/directives/style-map.js";
5
+ import { createRef, ref } from "lit/directives/ref.js";
6
+ import { EFImage } from "../elements/EFImage.js";
7
+ import { EFAudio } from "../elements/EFAudio.js";
8
+ import { EFVideo } from "../elements/EFVideo.js";
9
+ import { EFCaptions, EFCaptionsActiveWord } from "../elements/EFCaptions.js";
10
+ import { EFWaveform } from "../elements/EFWaveform.js";
11
+ import { EFTimegroup } from "../elements/EFTimegroup.js";
12
+ import { TimegroupController } from "../elements/TimegroupController.js";
13
+ import { TWMixin } from "./TWMixin.js";
14
+ import { msToTimeCode } from "../msToTimeCode.js";
15
+ import { focusedElementContext } from "./focusedElementContext.js";
16
+ import { focusContext } from "./focusContext.js";
17
+ import { playingContext } from "./playingContext.js";
18
+ var __defProp = Object.defineProperty;
19
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20
+ var __typeError = (msg) => {
21
+ throw TypeError(msg);
22
+ };
23
+ var __decorateClass = (decorators, target, key, kind) => {
24
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
25
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
26
+ if (decorator = decorators[i])
27
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
28
+ if (kind && result) __defProp(target, key, result);
29
+ return result;
30
+ };
31
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
32
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
33
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
34
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
35
+ var _EFFilmstrip_instances, bindToTargetTimegroup_fn, _handleKeyPress, contextElement_get;
36
+ class ElementFilmstripController {
37
+ constructor(host, filmstrip) {
38
+ this.host = host;
39
+ this.filmstrip = filmstrip;
40
+ this.host.addController(this);
41
+ }
42
+ remove() {
43
+ this.host.removeController(this);
44
+ }
45
+ hostDisconnected() {
46
+ this.host.removeController(this);
47
+ }
48
+ hostUpdated() {
49
+ this.filmstrip.requestUpdate();
50
+ }
51
+ }
52
+ const CommonEffectKeys = /* @__PURE__ */ new Set([
53
+ "offset",
54
+ "easing",
55
+ "composite",
56
+ "computedOffset"
57
+ ]);
58
+ class FilmstripItem extends TWMixin(LitElement) {
59
+ constructor() {
60
+ super(...arguments);
61
+ this.element = new EFTimegroup();
62
+ this.pixelsPerMs = 0.04;
63
+ }
64
+ static {
65
+ this.styles = [
66
+ css`
67
+ :host {
68
+ display: block;
69
+ }
70
+ `
71
+ ];
72
+ }
73
+ get isFocused() {
74
+ return this.element && this.focusContext?.focusedElement === this.element;
75
+ }
76
+ get styles() {
77
+ return {
78
+ position: "relative",
79
+ left: `${this.pixelsPerMs * this.element.startTimeWithinParentMs}px`,
80
+ width: `${this.pixelsPerMs * this.element.durationMs}px`
81
+ };
82
+ }
83
+ render() {
84
+ return html` <div class="" style=${styleMap(this.styles)}>
85
+ <div
86
+ class="border-outset relative mb-[1px] block h-[1.1rem] text-nowrap border border-slate-500 bg-blue-200 hover:bg-blue-400 text-sm data-[focused]:bg-slate-400"
87
+ ?data-focused=${this.isFocused}
88
+ @mouseenter=${() => {
89
+ if (this.focusContext) {
90
+ this.focusContext.focusedElement = this.element;
91
+ }
92
+ }}
93
+ @mouseleave=${() => {
94
+ if (this.focusContext) {
95
+ this.focusContext.focusedElement = null;
96
+ }
97
+ }}
98
+ >
99
+ ${this.animations()}
100
+ </div>
101
+ ${this.renderChildren()}
102
+ </div>`;
103
+ }
104
+ renderChildren() {
105
+ return renderFilmstripChildren(
106
+ Array.from(this.element.children),
107
+ this.pixelsPerMs
108
+ );
109
+ }
110
+ contents() {
111
+ return html``;
112
+ }
113
+ animations() {
114
+ const animations = this.element.getAnimations();
115
+ return animations.map((animation) => {
116
+ const effect = animation.effect;
117
+ if (!(effect instanceof KeyframeEffect)) {
118
+ return nothing;
119
+ }
120
+ const start = effect.getTiming().delay ?? 0;
121
+ const duration = effect.getTiming().duration;
122
+ if (duration === null) {
123
+ return nothing;
124
+ }
125
+ const keyframes = effect.getKeyframes();
126
+ const firstKeyframe = keyframes[0];
127
+ if (!firstKeyframe) {
128
+ return nothing;
129
+ }
130
+ const properties = new Set(Object.keys(firstKeyframe));
131
+ for (const key of CommonEffectKeys) {
132
+ properties.delete(key);
133
+ }
134
+ return html`<div
135
+ class="relative h-[5px] bg-blue-500 opacity-50"
136
+ label="animation"
137
+ style=${styleMap({
138
+ left: `${this.pixelsPerMs * start}px`,
139
+ width: `${this.pixelsPerMs * Number(duration)}px`
140
+ })}
141
+ >
142
+ <!-- <div class="text-nowrap">${Array.from(properties).join(" ")}</div> -->
143
+ ${effect.getKeyframes().map((keyframe) => {
144
+ return html`<div
145
+ class="absolute top-0 h-full w-1 bg-red-500"
146
+ style=${styleMap({
147
+ left: `${this.pixelsPerMs * keyframe.computedOffset * Number(duration)}px`
148
+ })}
149
+ ></div>`;
150
+ })}
151
+ </div>`;
152
+ });
153
+ }
154
+ update(changedProperties) {
155
+ if (changedProperties.has("element") && this.element instanceof LitElement) {
156
+ this.filmstripController?.remove();
157
+ this.filmstripController = new ElementFilmstripController(
158
+ this.element,
159
+ this
160
+ );
161
+ }
162
+ super.update(changedProperties);
163
+ }
164
+ }
165
+ __decorateClass([
166
+ consume({ context: focusContext, subscribe: true })
167
+ ], FilmstripItem.prototype, "focusContext", 2);
168
+ __decorateClass([
169
+ consume({ context: focusedElementContext, subscribe: true })
170
+ ], FilmstripItem.prototype, "focusedElement", 2);
171
+ __decorateClass([
172
+ property({ type: Object, attribute: false })
173
+ ], FilmstripItem.prototype, "element", 2);
174
+ __decorateClass([
175
+ property({ type: Number })
176
+ ], FilmstripItem.prototype, "pixelsPerMs", 2);
177
+ let EFAudioFilmstrip = class extends FilmstripItem {
178
+ contents() {
179
+ return html``;
180
+ }
181
+ };
182
+ EFAudioFilmstrip = __decorateClass([
183
+ customElement("ef-audio-filmstrip")
184
+ ], EFAudioFilmstrip);
185
+ let EFVideoFilmstrip = class extends FilmstripItem {
186
+ contents() {
187
+ return html` 📼 `;
188
+ }
189
+ };
190
+ EFVideoFilmstrip = __decorateClass([
191
+ customElement("ef-video-filmstrip")
192
+ ], EFVideoFilmstrip);
193
+ let EFCaptionsFilmstrip = class extends FilmstripItem {
194
+ contents() {
195
+ return html` 📝 `;
196
+ }
197
+ };
198
+ EFCaptionsFilmstrip = __decorateClass([
199
+ customElement("ef-captions-filmstrip")
200
+ ], EFCaptionsFilmstrip);
201
+ let EFWaveformFilmstrip = class extends FilmstripItem {
202
+ contents() {
203
+ return html` 🌊 `;
204
+ }
205
+ renderChildren() {
206
+ return nothing;
207
+ }
208
+ };
209
+ EFWaveformFilmstrip = __decorateClass([
210
+ customElement("ef-waveform-filmstrip")
211
+ ], EFWaveformFilmstrip);
212
+ let EFImageFilmstrip = class extends FilmstripItem {
213
+ contents() {
214
+ return html` 🖼️ `;
215
+ }
216
+ };
217
+ EFImageFilmstrip = __decorateClass([
218
+ customElement("ef-image-filmstrip")
219
+ ], EFImageFilmstrip);
220
+ let EFTimegroupFilmstrip = class extends FilmstripItem {
221
+ contents() {
222
+ return html`
223
+ <span>TIME GROUP</span>
224
+ ${renderFilmstripChildren(
225
+ Array.from(this.element.children || []),
226
+ this.pixelsPerMs
227
+ )}
228
+ </div>
229
+ `;
230
+ }
231
+ };
232
+ EFTimegroupFilmstrip = __decorateClass([
233
+ customElement("ef-timegroup-filmstrip")
234
+ ], EFTimegroupFilmstrip);
235
+ let EFHTMLFilmstrip = class extends FilmstripItem {
236
+ contents() {
237
+ return html`
238
+ <span>${this.element.tagName}</span>
239
+ ${renderFilmstripChildren(
240
+ Array.from(this.element.children || []),
241
+ this.pixelsPerMs
242
+ )}
243
+ `;
244
+ }
245
+ };
246
+ EFHTMLFilmstrip = __decorateClass([
247
+ customElement("ef-html-filmstrip")
248
+ ], EFHTMLFilmstrip);
249
+ let EFHierarchyItem = class extends TWMixin(LitElement) {
250
+ constructor() {
251
+ super(...arguments);
252
+ this.element = new EFTimegroup();
253
+ }
254
+ get icon() {
255
+ return "📼";
256
+ }
257
+ get isFocused() {
258
+ return this.element && this.focusContext?.focusedElement === this.element;
259
+ }
260
+ displayLabel() {
261
+ return nothing;
262
+ }
263
+ render() {
264
+ return html`
265
+ <div>
266
+ <div
267
+ class="peer
268
+ flex h-[1.1rem] items-center overflow-hidden text-nowrap border border-slate-500
269
+ bg-slate-200 pl-2 text-xs font-mono hover:bg-slate-400 data-[focused]:bg-slate-400"
270
+ ?data-focused=${this.isFocused}
271
+ @mouseenter=${() => {
272
+ if (this.focusContext) {
273
+ this.focusContext.focusedElement = this.element;
274
+ }
275
+ }}
276
+ @mouseleave=${() => {
277
+ if (this.focusContext) {
278
+ this.focusContext.focusedElement = null;
279
+ }
280
+ }}
281
+ >
282
+ ${this.icon} ${this.displayLabel()}
283
+ </div>
284
+ <div
285
+ class="p-[1px] pb-0 pl-2 pr-0 peer-hover:bg-slate-300 peer-data-[focused]:bg-slate-300 peer-hover:border-slate-400 peer-data-[focused]:border-slate-400""
286
+ >
287
+ ${this.renderChildren()}
288
+ </div>
289
+ </div>`;
290
+ }
291
+ renderChildren() {
292
+ return renderHierarchyChildren(Array.from(this.element.children));
293
+ }
294
+ };
295
+ __decorateClass([
296
+ property({ type: Object, attribute: false })
297
+ ], EFHierarchyItem.prototype, "element", 2);
298
+ __decorateClass([
299
+ consume({ context: focusContext })
300
+ ], EFHierarchyItem.prototype, "focusContext", 2);
301
+ __decorateClass([
302
+ consume({ context: focusedElementContext, subscribe: true })
303
+ ], EFHierarchyItem.prototype, "focusedElement", 2);
304
+ EFHierarchyItem = __decorateClass([
305
+ customElement("ef-hierarchy-item")
306
+ ], EFHierarchyItem);
307
+ let EFTimegroupHierarchyItem = class extends EFHierarchyItem {
308
+ get icon() {
309
+ return "🕒";
310
+ }
311
+ displayLabel() {
312
+ return this.element.mode ?? "(no mode)";
313
+ }
314
+ };
315
+ EFTimegroupHierarchyItem = __decorateClass([
316
+ customElement("ef-timegroup-hierarchy-item")
317
+ ], EFTimegroupHierarchyItem);
318
+ let EFAudioHierarchyItem = class extends EFHierarchyItem {
319
+ get icon() {
320
+ return "🔊";
321
+ }
322
+ displayLabel() {
323
+ return this.element.src ?? "(no src)";
324
+ }
325
+ };
326
+ EFAudioHierarchyItem = __decorateClass([
327
+ customElement("ef-audio-hierarchy-item")
328
+ ], EFAudioHierarchyItem);
329
+ let EFVideoHierarchyItem = class extends EFHierarchyItem {
330
+ get icon() {
331
+ return "📼";
332
+ }
333
+ displayLabel() {
334
+ return this.element.src ?? "(no src)";
335
+ }
336
+ };
337
+ EFVideoHierarchyItem = __decorateClass([
338
+ customElement("ef-video-hierarchy-item")
339
+ ], EFVideoHierarchyItem);
340
+ let EFCaptionsHierarchyItem = class extends EFHierarchyItem {
341
+ get icon() {
342
+ return "📝 Captions";
343
+ }
344
+ };
345
+ EFCaptionsHierarchyItem = __decorateClass([
346
+ customElement("ef-captions-hierarchy-item")
347
+ ], EFCaptionsHierarchyItem);
348
+ let EFCaptionsActiveWordHierarchyItem = class extends EFHierarchyItem {
349
+ get icon() {
350
+ return "🗣️ Active Word";
351
+ }
352
+ };
353
+ EFCaptionsActiveWordHierarchyItem = __decorateClass([
354
+ customElement("ef-captions-active-word-hierarchy-item")
355
+ ], EFCaptionsActiveWordHierarchyItem);
356
+ let EFWaveformHierarchyItem = class extends EFHierarchyItem {
357
+ get icon() {
358
+ return "🌊";
359
+ }
360
+ renderChildren() {
361
+ return nothing;
362
+ }
363
+ };
364
+ EFWaveformHierarchyItem = __decorateClass([
365
+ customElement("ef-waveform-hierarchy-item")
366
+ ], EFWaveformHierarchyItem);
367
+ let EFImageHierarchyItem = class extends EFHierarchyItem {
368
+ get icon() {
369
+ return "🖼️";
370
+ }
371
+ displayLabel() {
372
+ return this.element.src ?? "(no src)";
373
+ }
374
+ };
375
+ EFImageHierarchyItem = __decorateClass([
376
+ customElement("ef-image-hierarchy-item")
377
+ ], EFImageHierarchyItem);
378
+ let EFHTMLHierarchyItem = class extends EFHierarchyItem {
379
+ get icon() {
380
+ return html`<code>${`<${this.element.tagName.toLowerCase()}>`}</code>`;
381
+ }
382
+ };
383
+ EFHTMLHierarchyItem = __decorateClass([
384
+ customElement("ef-html-hierarchy-item")
385
+ ], EFHTMLHierarchyItem);
386
+ const renderHierarchyChildren = (children) => {
387
+ return children.map((child) => {
388
+ if (child instanceof EFTimegroup) {
389
+ return html`<ef-timegroup-hierarchy-item
390
+ .element=${child}
391
+ ></ef-timegroup-hierarchy-item>`;
392
+ }
393
+ if (child instanceof EFImage) {
394
+ return html`<ef-image-hierarchy-item
395
+ .element=${child}
396
+ ></ef-image-hierarchy-item>`;
397
+ }
398
+ if (child instanceof EFAudio) {
399
+ return html`<ef-audio-hierarchy-item
400
+ .element=${child}
401
+ ></ef-audio-hierarchy-item>`;
402
+ }
403
+ if (child instanceof EFVideo) {
404
+ return html`<ef-video-hierarchy-item
405
+ .element=${child}
406
+ ></ef-video-hierarchy-item>`;
407
+ }
408
+ if (child instanceof EFCaptions) {
409
+ return html`<ef-captions-hierarchy-item
410
+ .element=${child}
411
+ ></ef-captions-hierarchy-item>`;
412
+ }
413
+ if (child instanceof EFCaptionsActiveWord) {
414
+ return html`<ef-captions-active-word-hierarchy-item
415
+ .element=${child}
416
+ ></ef-captions-active-word-hierarchy-item>`;
417
+ }
418
+ if (child instanceof EFWaveform) {
419
+ return html`<ef-waveform-hierarchy-item
420
+ .element=${child}
421
+ ></ef-waveform-hierarchy-item>`;
422
+ }
423
+ return html`<ef-html-hierarchy-item
424
+ .element=${child}
425
+ ></ef-html-hierarchy-item>`;
426
+ });
427
+ };
428
+ const renderFilmstripChildren = (children, pixelsPerMs) => {
429
+ return children.map((child) => {
430
+ if (child instanceof EFTimegroup) {
431
+ return html`<ef-timegroup-filmstrip
432
+ .element=${child}
433
+ .pixelsPerMs=${pixelsPerMs}
434
+ >
435
+ </ef-timegroup-filmstrip>`;
436
+ }
437
+ if (child instanceof EFImage) {
438
+ return html`<ef-image-filmstrip
439
+ .element=${child}
440
+ .pixelsPerMs=${pixelsPerMs}
441
+ ></ef-image-filmstrip>`;
442
+ }
443
+ if (child instanceof EFAudio) {
444
+ return html`<ef-audio-filmstrip
445
+ .element=${child}
446
+ .pixelsPerMs=${pixelsPerMs}
447
+ ></ef-audio-filmstrip>`;
448
+ }
449
+ if (child instanceof EFVideo) {
450
+ return html`<ef-video-filmstrip
451
+ .element=${child}
452
+ .pixelsPerMs=${pixelsPerMs}
453
+ ></ef-video-filmstrip>`;
454
+ }
455
+ if (child instanceof EFCaptions) {
456
+ return html`<ef-captions-filmstrip
457
+ .element=${child}
458
+ .pixelsPerMs=${pixelsPerMs}
459
+ ></ef-captions-filmstrip>`;
460
+ }
461
+ if (child instanceof EFWaveform) {
462
+ return html`<ef-waveform-filmstrip
463
+ .element=${child}
464
+ .pixelsPerMs=${pixelsPerMs}
465
+ ></ef-waveform-filmstrip>`;
466
+ }
467
+ return html`<ef-html-filmstrip
468
+ .element=${child}
469
+ .pixelsPerMs=${pixelsPerMs}
470
+ ></ef-html-filmstrip>`;
471
+ });
472
+ };
473
+ let EFFilmstrip = class extends TWMixin(LitElement) {
474
+ constructor() {
475
+ super(...arguments);
476
+ __privateAdd(this, _EFFilmstrip_instances);
477
+ this.pixelsPerMs = 0.04;
478
+ this.scrubbing = false;
479
+ this.timelineScrolltop = 0;
480
+ this.currentTimeMs = 0;
481
+ __privateAdd(this, _handleKeyPress, (event) => {
482
+ if (event.key === " ") {
483
+ const interactiveSelector = "input, textarea, button, select, a, [contenteditable]";
484
+ const closestInteractive = event.target?.closest(
485
+ interactiveSelector
486
+ );
487
+ if (closestInteractive) {
488
+ return;
489
+ }
490
+ event.preventDefault();
491
+ if (__privateGet(this, _EFFilmstrip_instances, contextElement_get)) {
492
+ __privateGet(this, _EFFilmstrip_instances, contextElement_get).playing = !__privateGet(this, _EFFilmstrip_instances, contextElement_get).playing;
493
+ }
494
+ }
495
+ });
496
+ this.gutterRef = createRef();
497
+ this.hierarchyRef = createRef();
498
+ this.playheadRef = createRef();
499
+ }
500
+ connectedCallback() {
501
+ super.connectedCallback();
502
+ __privateMethod(this, _EFFilmstrip_instances, bindToTargetTimegroup_fn).call(this);
503
+ window.addEventListener("keypress", __privateGet(this, _handleKeyPress));
504
+ }
505
+ disconnectedCallback() {
506
+ super.disconnectedCallback();
507
+ window.removeEventListener("keypress", __privateGet(this, _handleKeyPress));
508
+ }
509
+ syncGutterScroll() {
510
+ if (this.gutter && this.hierarchyRef.value) {
511
+ this.hierarchyRef.value.scrollTop = this.gutter.scrollTop;
512
+ this.timelineScrolltop = this.gutter.scrollTop;
513
+ }
514
+ }
515
+ syncHierarchyScroll() {
516
+ if (this.gutter && this.hierarchyRef.value) {
517
+ this.gutter.scrollTop = this.hierarchyRef.value.scrollTop;
518
+ this.timelineScrolltop = this.hierarchyRef.value.scrollTop;
519
+ }
520
+ }
521
+ scrub(e) {
522
+ if (this.playing) {
523
+ return;
524
+ }
525
+ if (!this.scrubbing) {
526
+ return;
527
+ }
528
+ const gutter = this.shadowRoot?.querySelector("#gutter");
529
+ if (!gutter) {
530
+ return;
531
+ }
532
+ const rect = gutter.getBoundingClientRect();
533
+ if (this.targetTimegroup) {
534
+ const layerX = e.pageX - rect.left + gutter.scrollLeft;
535
+ this.targetTimegroup.currentTimeMs = layerX / this.pixelsPerMs;
536
+ }
537
+ }
538
+ startScrub(e) {
539
+ e.preventDefault();
540
+ this.scrubbing = true;
541
+ queueMicrotask(() => {
542
+ const gutter = this.shadowRoot?.querySelector("#gutter");
543
+ if (!gutter) {
544
+ return;
545
+ }
546
+ const rect = gutter.getBoundingClientRect();
547
+ if (this.targetTimegroup) {
548
+ const layerX = e.pageX - rect.left + gutter.scrollLeft;
549
+ this.targetTimegroup.currentTimeMs = layerX / this.pixelsPerMs;
550
+ }
551
+ });
552
+ addEventListener(
553
+ "mouseup",
554
+ () => {
555
+ this.scrubbing = false;
556
+ },
557
+ { once: true }
558
+ );
559
+ }
560
+ scrollScrub(e) {
561
+ if (this.targetTimegroup && this.gutter && !this.playing) {
562
+ e.preventDefault();
563
+ if (this.gutterRef.value && this.gutterRef.value.scrollLeft === 0 && e.deltaX < 0) {
564
+ this.gutter.scrollBy(0, e.deltaY);
565
+ return;
566
+ }
567
+ if (this.gutter.scrollWidth - this.gutter.scrollLeft === this.gutter.clientWidth && e.deltaX > 0) {
568
+ this.gutter.scrollBy(0, e.deltaY);
569
+ return;
570
+ }
571
+ if (this) {
572
+ this.gutter.scrollBy(e.deltaX, e.deltaY);
573
+ this.targetTimegroup.currentTimeMs += e.deltaX / this.pixelsPerMs;
574
+ }
575
+ }
576
+ }
577
+ get gutter() {
578
+ return this.gutterRef.value;
579
+ }
580
+ render() {
581
+ const target = this.targetTimegroup;
582
+ return html` <div
583
+ class="grid h-full bg-slate-100"
584
+ style=${styleMap({
585
+ gridTemplateColumns: "200px 1fr",
586
+ gridTemplateRows: "1.5rem 1fr"
587
+ })}
588
+ >
589
+ <div
590
+ class="z-20 col-span-2 border-b-slate-600 bg-slate-100 shadow shadow-slate-300"
591
+ >
592
+ <input
593
+ type="range"
594
+ .value=${this.pixelsPerMs}
595
+ min="0.01"
596
+ max="0.1"
597
+ step="0.001"
598
+ @input=${(e) => {
599
+ const target2 = e.target;
600
+ this.pixelsPerMs = Number.parseFloat(target2.value);
601
+ }}
602
+ />
603
+ <code>${msToTimeCode(this.currentTimeMs, true)} </code> /
604
+ <code>${msToTimeCode(target?.durationMs ?? 0, true)}</code>
605
+ ${this.playing ? html`<button
606
+ @click=${() => {
607
+ if (__privateGet(this, _EFFilmstrip_instances, contextElement_get)) {
608
+ __privateGet(this, _EFFilmstrip_instances, contextElement_get).playing = false;
609
+ }
610
+ }}
611
+ >
612
+ ⏸️
613
+ </button>` : html`<button
614
+ @click=${() => {
615
+ if (__privateGet(this, _EFFilmstrip_instances, contextElement_get)) {
616
+ __privateGet(this, _EFFilmstrip_instances, contextElement_get).playing = true;
617
+ }
618
+ }}
619
+ >
620
+ ▶️
621
+ </button>`}
622
+ </div>
623
+ <div
624
+ class="z-10 pl-1 pr-1 pt-2 shadow shadow-slate-600 overflow-auto"
625
+ ${ref(this.hierarchyRef)}
626
+ @scroll=${this.syncHierarchyScroll}
627
+ >
628
+ ${renderHierarchyChildren(target ? [target] : [])}
629
+ </div>
630
+ <div
631
+ class="h-full w-full cursor-crosshair overflow-auto bg-slate-200 pt-2"
632
+ id="gutter"
633
+ ${ref(this.gutterRef)}
634
+ @scroll=${this.syncGutterScroll}
635
+ @wheel=${this.scrollScrub}
636
+ >
637
+ <div
638
+ class="relative h-full w-full"
639
+ style="width: ${this.pixelsPerMs * (target?.durationMs ?? 0)}px;"
640
+ @mousemove=${this.scrub}
641
+ @mousedown=${this.startScrub}
642
+ >
643
+ <div
644
+ class="border-red pointer-events-none absolute z-10 h-full w-[2px] border-r-2 border-red-700"
645
+ style=${styleMap({
646
+ left: `${this.pixelsPerMs * this.currentTimeMs}px`,
647
+ top: `${this.timelineScrolltop}px`
648
+ })}
649
+ ${ref(this.playheadRef)}
650
+ ></div>
651
+
652
+ ${renderFilmstripChildren(target ? [target] : [], this.pixelsPerMs)}
653
+ </div>
654
+ </div>
655
+ </div>`;
656
+ }
657
+ updated(changes) {
658
+ if (!this.targetTimegroup) {
659
+ return;
660
+ }
661
+ if (changes.has("currentTimeMs")) {
662
+ if (this.targetTimegroup.currentTimeMs !== this.currentTimeMs) {
663
+ this.targetTimegroup.currentTimeMs = this.currentTimeMs;
664
+ }
665
+ }
666
+ }
667
+ get targetTimegroup() {
668
+ return __privateGet(this, _EFFilmstrip_instances, contextElement_get)?.targetTimegroup;
669
+ }
670
+ };
671
+ _EFFilmstrip_instances = /* @__PURE__ */ new WeakSet();
672
+ bindToTargetTimegroup_fn = function() {
673
+ if (this.timegroupController) {
674
+ this.timegroupController.remove();
675
+ }
676
+ const target = this.targetTimegroup;
677
+ if (target) {
678
+ this.timegroupController = new TimegroupController(target, this);
679
+ this.currentTimeMs = target.currentTimeMs;
680
+ }
681
+ };
682
+ _handleKeyPress = /* @__PURE__ */ new WeakMap();
683
+ contextElement_get = function() {
684
+ return this.closest("ef-workbench, ef-preview");
685
+ };
686
+ __decorateClass([
687
+ property({ type: Number })
688
+ ], EFFilmstrip.prototype, "pixelsPerMs", 2);
689
+ __decorateClass([
690
+ state()
691
+ ], EFFilmstrip.prototype, "scrubbing", 2);
692
+ __decorateClass([
693
+ state()
694
+ ], EFFilmstrip.prototype, "timelineScrolltop", 2);
695
+ __decorateClass([
696
+ consume({ context: playingContext, subscribe: true }),
697
+ state()
698
+ ], EFFilmstrip.prototype, "playing", 2);
699
+ __decorateClass([
700
+ state()
701
+ ], EFFilmstrip.prototype, "currentTimeMs", 2);
702
+ __decorateClass([
703
+ eventOptions({ passive: false })
704
+ ], EFFilmstrip.prototype, "syncGutterScroll", 1);
705
+ __decorateClass([
706
+ eventOptions({ passive: false })
707
+ ], EFFilmstrip.prototype, "syncHierarchyScroll", 1);
708
+ __decorateClass([
709
+ eventOptions({ capture: false })
710
+ ], EFFilmstrip.prototype, "scrub", 1);
711
+ __decorateClass([
712
+ eventOptions({ capture: false })
713
+ ], EFFilmstrip.prototype, "startScrub", 1);
714
+ __decorateClass([
715
+ eventOptions({ passive: false })
716
+ ], EFFilmstrip.prototype, "scrollScrub", 1);
717
+ EFFilmstrip = __decorateClass([
718
+ customElement("ef-filmstrip")
719
+ ], EFFilmstrip);
720
+ export {
721
+ EFAudioFilmstrip,
722
+ EFCaptionsFilmstrip,
723
+ EFFilmstrip,
724
+ EFHTMLFilmstrip,
725
+ EFImageFilmstrip,
726
+ EFTimegroupFilmstrip,
727
+ EFVideoFilmstrip,
728
+ EFWaveformFilmstrip
729
+ };