@editframe/elements 0.20.4-beta.0 → 0.21.0-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 (92) hide show
  1. package/dist/DelayedLoadingState.js +0 -27
  2. package/dist/EF_FRAMEGEN.d.ts +5 -3
  3. package/dist/EF_FRAMEGEN.js +50 -11
  4. package/dist/_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js +7 -0
  5. package/dist/elements/ContextProxiesController.js +2 -22
  6. package/dist/elements/EFAudio.js +4 -8
  7. package/dist/elements/EFCaptions.js +59 -84
  8. package/dist/elements/EFImage.js +5 -6
  9. package/dist/elements/EFMedia/AssetIdMediaEngine.js +2 -4
  10. package/dist/elements/EFMedia/AssetMediaEngine.js +35 -30
  11. package/dist/elements/EFMedia/BaseMediaEngine.js +57 -73
  12. package/dist/elements/EFMedia/BufferedSeekingInput.js +134 -76
  13. package/dist/elements/EFMedia/JitMediaEngine.js +9 -19
  14. package/dist/elements/EFMedia/audioTasks/makeAudioBufferTask.js +3 -6
  15. package/dist/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.js +1 -1
  16. package/dist/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.js +1 -1
  17. package/dist/elements/EFMedia/audioTasks/makeAudioInputTask.js +6 -5
  18. package/dist/elements/EFMedia/audioTasks/makeAudioSeekTask.js +1 -3
  19. package/dist/elements/EFMedia/audioTasks/makeAudioSegmentFetchTask.js +1 -1
  20. package/dist/elements/EFMedia/audioTasks/makeAudioSegmentIdTask.js +1 -1
  21. package/dist/elements/EFMedia/audioTasks/makeAudioTimeDomainAnalysisTask.js +1 -1
  22. package/dist/elements/EFMedia/shared/AudioSpanUtils.js +4 -16
  23. package/dist/elements/EFMedia/shared/BufferUtils.js +2 -15
  24. package/dist/elements/EFMedia/shared/GlobalInputCache.js +0 -24
  25. package/dist/elements/EFMedia/shared/PrecisionUtils.js +0 -21
  26. package/dist/elements/EFMedia/shared/ThumbnailExtractor.js +0 -17
  27. package/dist/elements/EFMedia/tasks/makeMediaEngineTask.js +1 -10
  28. package/dist/elements/EFMedia/videoTasks/MainVideoInputCache.d.ts +29 -0
  29. package/dist/elements/EFMedia/videoTasks/MainVideoInputCache.js +32 -0
  30. package/dist/elements/EFMedia/videoTasks/ScrubInputCache.js +1 -15
  31. package/dist/elements/EFMedia/videoTasks/makeScrubVideoBufferTask.js +1 -7
  32. package/dist/elements/EFMedia/videoTasks/makeScrubVideoInputTask.js +8 -5
  33. package/dist/elements/EFMedia/videoTasks/makeScrubVideoSeekTask.js +12 -13
  34. package/dist/elements/EFMedia/videoTasks/makeScrubVideoSegmentIdTask.js +1 -1
  35. package/dist/elements/EFMedia/videoTasks/makeUnifiedVideoSeekTask.js +134 -70
  36. package/dist/elements/EFMedia/videoTasks/makeVideoBufferTask.js +7 -11
  37. package/dist/elements/EFMedia.js +26 -24
  38. package/dist/elements/EFSourceMixin.js +5 -7
  39. package/dist/elements/EFSurface.js +6 -9
  40. package/dist/elements/EFTemporal.js +19 -37
  41. package/dist/elements/EFThumbnailStrip.js +16 -59
  42. package/dist/elements/EFTimegroup.js +95 -90
  43. package/dist/elements/EFVideo.d.ts +6 -2
  44. package/dist/elements/EFVideo.js +142 -107
  45. package/dist/elements/EFWaveform.js +18 -27
  46. package/dist/elements/SampleBuffer.js +2 -5
  47. package/dist/elements/TargetController.js +3 -3
  48. package/dist/elements/durationConverter.js +4 -4
  49. package/dist/elements/updateAnimations.js +14 -35
  50. package/dist/gui/ContextMixin.js +23 -52
  51. package/dist/gui/EFConfiguration.js +7 -7
  52. package/dist/gui/EFControls.js +5 -5
  53. package/dist/gui/EFFilmstrip.js +77 -98
  54. package/dist/gui/EFFitScale.js +5 -6
  55. package/dist/gui/EFFocusOverlay.js +4 -4
  56. package/dist/gui/EFPreview.js +4 -4
  57. package/dist/gui/EFScrubber.js +9 -9
  58. package/dist/gui/EFTimeDisplay.js +5 -5
  59. package/dist/gui/EFToggleLoop.js +4 -4
  60. package/dist/gui/EFTogglePlay.js +5 -5
  61. package/dist/gui/EFWorkbench.js +5 -5
  62. package/dist/gui/TWMixin2.js +1 -1
  63. package/dist/index.d.ts +1 -0
  64. package/dist/otel/BridgeSpanExporter.d.ts +13 -0
  65. package/dist/otel/BridgeSpanExporter.js +87 -0
  66. package/dist/otel/setupBrowserTracing.d.ts +12 -0
  67. package/dist/otel/setupBrowserTracing.js +30 -0
  68. package/dist/otel/tracingHelpers.d.ts +34 -0
  69. package/dist/otel/tracingHelpers.js +113 -0
  70. package/dist/transcoding/cache/RequestDeduplicator.js +0 -21
  71. package/dist/transcoding/cache/URLTokenDeduplicator.js +1 -21
  72. package/dist/transcoding/utils/UrlGenerator.js +2 -19
  73. package/dist/utils/LRUCache.js +6 -53
  74. package/package.json +10 -2
  75. package/src/elements/EFCaptions.browsertest.ts +2 -0
  76. package/src/elements/EFMedia/AssetMediaEngine.ts +65 -37
  77. package/src/elements/EFMedia/BaseMediaEngine.ts +110 -52
  78. package/src/elements/EFMedia/BufferedSeekingInput.ts +218 -101
  79. package/src/elements/EFMedia/audioTasks/makeAudioInputTask.ts +7 -3
  80. package/src/elements/EFMedia/videoTasks/MainVideoInputCache.ts +76 -0
  81. package/src/elements/EFMedia/videoTasks/makeScrubVideoInputTask.ts +16 -10
  82. package/src/elements/EFMedia/videoTasks/makeScrubVideoSeekTask.ts +7 -1
  83. package/src/elements/EFMedia/videoTasks/makeUnifiedVideoSeekTask.ts +222 -116
  84. package/src/elements/EFMedia.ts +16 -1
  85. package/src/elements/EFTimegroup.browsertest.ts +10 -8
  86. package/src/elements/EFTimegroup.ts +164 -76
  87. package/src/elements/EFVideo.browsertest.ts +19 -27
  88. package/src/elements/EFVideo.ts +203 -101
  89. package/src/otel/BridgeSpanExporter.ts +150 -0
  90. package/src/otel/setupBrowserTracing.ts +68 -0
  91. package/src/otel/tracingHelpers.ts +251 -0
  92. package/types.json +1 -1
@@ -6,9 +6,6 @@ var DelayedLoadingState = class {
6
6
  this.loadingDelayMs = delayMs;
7
7
  this.onStateChange = onStateChange;
8
8
  }
9
- /**
10
- * Start a delayed loading operation
11
- */
12
9
  startLoading(operationId, message, options = {}) {
13
10
  const isBackground = options.background || false;
14
11
  const existingOp = this.operations.get(operationId);
@@ -34,9 +31,6 @@ var DelayedLoadingState = class {
34
31
  isBackground: false
35
32
  });
36
33
  }
37
- /**
38
- * Clear a loading operation
39
- */
40
34
  clearLoading(operationId) {
41
35
  const operation = this.operations.get(operationId);
42
36
  if (!operation) return;
@@ -44,36 +38,21 @@ var DelayedLoadingState = class {
44
38
  this.operations.delete(operationId);
45
39
  this.updateLoadingState();
46
40
  }
47
- /**
48
- * Clear all loading operations
49
- */
50
41
  clearAllLoading() {
51
42
  for (const operation of this.operations.values()) if (operation.timeout) clearTimeout(operation.timeout);
52
43
  this.operations.clear();
53
44
  this.updateLoadingState();
54
45
  }
55
- /**
56
- * Get current loading state
57
- */
58
46
  get isLoading() {
59
47
  return this.isCurrentlyLoading;
60
48
  }
61
- /**
62
- * Get current loading message
63
- */
64
49
  get message() {
65
50
  return this.currentMessage;
66
51
  }
67
- /**
68
- * Check if any non-background operations are active
69
- */
70
52
  hasActiveOperations() {
71
53
  for (const operation of this.operations.values()) if (!operation.isBackground) return true;
72
54
  return false;
73
55
  }
74
- /**
75
- * Get the message for the most recent non-background operation
76
- */
77
56
  getCurrentMessage() {
78
57
  let latestTime = 0;
79
58
  let latestMessage = "";
@@ -83,9 +62,6 @@ var DelayedLoadingState = class {
83
62
  }
84
63
  return latestMessage;
85
64
  }
86
- /**
87
- * Trigger loading state (called by timeout)
88
- */
89
65
  triggerLoadingState() {
90
66
  if (this.hasActiveOperations() && !this.isCurrentlyLoading) {
91
67
  this.isCurrentlyLoading = true;
@@ -93,9 +69,6 @@ var DelayedLoadingState = class {
93
69
  this.onStateChange?.(true, this.currentMessage);
94
70
  }
95
71
  }
96
- /**
97
- * Update loading state based on current operations
98
- */
99
72
  updateLoadingState() {
100
73
  const shouldBeLoading = this.hasActiveOperations();
101
74
  if (shouldBeLoading !== this.isCurrentlyLoading) {
@@ -1,12 +1,14 @@
1
1
  import { VideoRenderOptions } from '../../assets/src/index.ts';
2
+ import { TraceContext } from './otel/tracingHelpers.js';
2
3
  interface Bridge {
3
- onInitialize: (callback: (renderOptions: VideoRenderOptions) => void) => void;
4
+ onInitialize: (callback: (renderOptions: VideoRenderOptions, traceContext?: TraceContext, otelEndpoint?: string) => void) => void;
4
5
  initialized(): void;
5
- onBeginFrame(callback: (frameNumber: number, isLast: boolean) => void): void;
6
- onTriggerCanvas(callback: () => void): void;
6
+ onBeginFrame(callback: (frameNumber: number, isLast: boolean, traceContext?: TraceContext) => void): void;
7
+ onTriggerCanvas(callback: (traceContext?: TraceContext) => void): void;
7
8
  frameReady(frameNumber: number, audioSamples: ArrayBuffer): void;
8
9
  error(error: Error): void;
9
10
  syncLog(sequence: number, message: string, callback: () => void): void;
11
+ exportSpans?: (endpoint: string, payload: string) => void;
10
12
  }
11
13
  declare global {
12
14
  interface Window {
@@ -1,4 +1,6 @@
1
+ import { clearCurrentFrameSpan, enableTracing, extractParentContext, setCurrentFrameSpan, withSpan, withSpanAndContext } from "./otel/tracingHelpers.js";
1
2
  import { shallowGetTimegroups } from "./elements/EFTimegroup.js";
3
+ import { setupBrowserTracing } from "./otel/setupBrowserTracing.js";
2
4
  var TriggerCanvas = class {
3
5
  constructor() {
4
6
  this.canvasInitialized = false;
@@ -91,17 +93,55 @@ var EFFramegen = class {
91
93
  connectToBridge() {
92
94
  const BRIDGE = this.BRIDGE;
93
95
  if (!BRIDGE) throw new Error("No BRIDGE when attempting to connect to bridge");
94
- BRIDGE.onInitialize(async (renderOptions) => {
95
- await this.initialize(renderOptions).catch((error) => {
96
- console.error("[EF_FRAMEGEN.connectToBridge] error initializing", error);
96
+ BRIDGE.onInitialize(async (renderOptions, traceContext, otelEndpoint) => {
97
+ if (renderOptions.enableTracing && otelEndpoint) {
98
+ enableTracing();
99
+ setupBrowserTracing({
100
+ otelEndpoint,
101
+ serviceName: "telecine-browser",
102
+ bridge: BRIDGE,
103
+ useBatching: true
104
+ });
105
+ }
106
+ const parentContext = extractParentContext(traceContext);
107
+ await withSpan("browser.initialize", {
108
+ width: renderOptions.encoderOptions.video.width,
109
+ height: renderOptions.encoderOptions.video.height,
110
+ fps: renderOptions.encoderOptions.video.framerate,
111
+ durationMs: renderOptions.encoderOptions.toMs - renderOptions.encoderOptions.fromMs
112
+ }, parentContext, async () => {
113
+ await this.initialize(renderOptions).catch((error) => {
114
+ console.error("[EF_FRAMEGEN.connectToBridge] error initializing", error);
115
+ throw error;
116
+ });
97
117
  });
98
118
  BRIDGE.initialized();
99
119
  });
100
- BRIDGE.onBeginFrame((frameNumber, isLast) => {
101
- this.beginFrame(frameNumber, isLast);
120
+ BRIDGE.onBeginFrame((frameNumber, isLast, traceContext) => {
121
+ const parentContext = extractParentContext(traceContext);
122
+ withSpanAndContext("browser.frame.render", {
123
+ frameNumber,
124
+ isLast
125
+ }, parentContext, async (span, _spanContext) => {
126
+ setCurrentFrameSpan(span);
127
+ try {
128
+ await this.beginFrame(frameNumber, isLast);
129
+ } finally {
130
+ clearCurrentFrameSpan();
131
+ }
132
+ }).catch((error) => {
133
+ console.error("[EF_FRAMEGEN.beginFrame] error:", error);
134
+ clearCurrentFrameSpan();
135
+ throw error;
136
+ });
102
137
  });
103
- BRIDGE.onTriggerCanvas(() => {
104
- this.triggerCanvas.trigger();
138
+ BRIDGE.onTriggerCanvas((traceContext) => {
139
+ const parentContext = extractParentContext(traceContext);
140
+ withSpan("browser.canvas.trigger", {}, parentContext, async () => {
141
+ this.triggerCanvas.trigger();
142
+ }).catch((error) => {
143
+ console.error("[EF_FRAMEGEN.triggerCanvas] error:", error);
144
+ });
105
145
  });
106
146
  }
107
147
  get showFrameBox() {
@@ -113,8 +153,7 @@ var EFFramegen = class {
113
153
  if (!workbench) throw new Error("No workbench found");
114
154
  workbench.rendering = true;
115
155
  workbench.playing = false;
116
- const timegroups = shallowGetTimegroups(workbench);
117
- const firstGroup = timegroups[0];
156
+ const firstGroup = shallowGetTimegroups(workbench)[0];
118
157
  if (!firstGroup) throw new Error("No temporal elements found");
119
158
  const startingTimeMs = renderOptions.encoderOptions.fromMs;
120
159
  await firstGroup.waitForMediaDurations();
@@ -142,8 +181,7 @@ var EFFramegen = class {
142
181
  const workbench = document.querySelector("ef-workbench");
143
182
  if (!workbench) throw new Error("No workbench found");
144
183
  workbench.rendering = true;
145
- const timegroups = shallowGetTimegroups(workbench);
146
- const firstGroup = timegroups[0];
184
+ const firstGroup = shallowGetTimegroups(workbench)[0];
147
185
  if (!firstGroup) throw new Error("No temporal elements found");
148
186
  const frameTime = this.renderOptions.encoderOptions.fromMs + frameNumber * this.frameDurationMs;
149
187
  firstGroup.currentTimeMs = Number(Number(frameTime).toFixed(5));
@@ -183,3 +221,4 @@ var EFFramegen = class {
183
221
  }
184
222
  };
185
223
  if (typeof window !== "undefined") window.EF_FRAMEGEN = new EFFramegen();
224
+ export {};
@@ -0,0 +1,7 @@
1
+ function __decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ export { __decorate };
@@ -1,22 +1,4 @@
1
1
  import { ContextEvent } from "@lit/context";
2
- /**
3
- * A ReactiveController that proxies context requests to a target element.
4
- *
5
- * Usage:
6
- * ```typescript
7
- * @customElement('my-proxy')
8
- * class MyProxy extends LitElement {
9
- * @state()
10
- * targetElement: HTMLElement | null = null;
11
- *
12
- * // @ts-expect-error controller is intentionally not referenced directly
13
- * #contextProxyController = new ContextProxyController(this, {
14
- * target: () => this.targetElement,
15
- * contexts: [playingContext, loopContext, targetTimegroupContext]
16
- * });
17
- * }
18
- * ```
19
- */
20
2
  var ContextProxyController = class {
21
3
  constructor(host, config) {
22
4
  this.proxyMap = /* @__PURE__ */ new Map();
@@ -43,11 +25,9 @@ var ContextProxyController = class {
43
25
  }
44
26
  handleContextRequest(event) {
45
27
  const contextEvent = event;
46
- const targetGetter = this.proxyMap.get(contextEvent.context);
47
- if (targetGetter) {
28
+ if (this.proxyMap.get(contextEvent.context)) {
48
29
  contextEvent.stopPropagation();
49
- const processed = this.processContextRequest(contextEvent);
50
- if (!processed) this.pendingRequests.push(contextEvent);
30
+ if (!this.processContextRequest(contextEvent)) this.pendingRequests.push(contextEvent);
51
31
  }
52
32
  }
53
33
  processContextRequest(contextEvent) {
@@ -1,12 +1,12 @@
1
1
  import { EF_INTERACTIVE } from "../EF_INTERACTIVE.js";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js";
2
3
  import { EFMedia } from "./EFMedia.js";
3
4
  import { TWMixin } from "../gui/TWMixin2.js";
4
5
  import { Task } from "@lit/task";
5
6
  import { html } from "lit";
6
7
  import { customElement, property } from "lit/decorators.js";
7
- import _decorate from "@oxc-project/runtime/helpers/decorate";
8
8
  import { createRef, ref } from "lit/directives/ref.js";
9
- let EFAudio = class EFAudio$1 extends TWMixin(EFMedia) {
9
+ var EFAudio = class EFAudio$1 extends TWMixin(EFMedia) {
10
10
  constructor(..._args) {
11
11
  super(..._args);
12
12
  this._propertyHack = false;
@@ -31,17 +31,13 @@ let EFAudio = class EFAudio$1 extends TWMixin(EFMedia) {
31
31
  render() {
32
32
  return html`<audio ${ref(this.audioElementRef)}></audio>`;
33
33
  }
34
- /**
35
- * Legacy getter for fragment index task (maps to audioSegmentIdTask)
36
- * Still used by EFCaptions
37
- */
38
34
  get fragmentIndexTask() {
39
35
  return this.audioSegmentIdTask;
40
36
  }
41
37
  };
42
- _decorate([property({
38
+ __decorate([property({
43
39
  type: Boolean,
44
40
  attribute: "dummy-property"
45
41
  })], EFAudio.prototype, "_propertyHack", void 0);
46
- EFAudio = _decorate([customElement("ef-audio")], EFAudio);
42
+ EFAudio = __decorate([customElement("ef-audio")], EFAudio);
47
43
  export { EFAudio };
@@ -1,4 +1,5 @@
1
1
  import { EF_INTERACTIVE } from "../EF_INTERACTIVE.js";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js";
2
3
  import { EFSourceMixin } from "./EFSourceMixin.js";
3
4
  import { EFTemporal, flushStartTimeMsCache } from "./EFTemporal.js";
4
5
  import { FetchMixin } from "./FetchMixin.js";
@@ -9,15 +10,14 @@ import { CrossUpdateController } from "./CrossUpdateController.js";
9
10
  import { Task, TaskStatus } from "@lit/task";
10
11
  import { LitElement, css, html } from "lit";
11
12
  import { customElement, property } from "lit/decorators.js";
12
- import _decorate from "@oxc-project/runtime/helpers/decorate";
13
- const stopWords = new Set([
13
+ var stopWords = new Set([
14
14
  "",
15
15
  ".",
16
16
  "!",
17
17
  "?",
18
18
  ","
19
19
  ]);
20
- let EFCaptionsActiveWord = class EFCaptionsActiveWord$1 extends EFTemporal(LitElement) {
20
+ var EFCaptionsActiveWord = class EFCaptionsActiveWord$1 extends EFTemporal(LitElement) {
21
21
  constructor(..._args) {
22
22
  super(..._args);
23
23
  this.wordStartMs = 0;
@@ -41,50 +41,45 @@ let EFCaptionsActiveWord = class EFCaptionsActiveWord$1 extends EFTemporal(LitEl
41
41
  render() {
42
42
  if (stopWords.has(this.wordText)) {
43
43
  this.hidden = true;
44
- return void 0;
44
+ return;
45
45
  }
46
46
  this.hidden = false;
47
- const seed = this.wordIndex * 9007 % 233;
48
- const seedValue = seed / 233;
47
+ const seedValue = this.wordIndex * 9007 % 233 / 233;
49
48
  this.style.setProperty("--ef-word-seed", seedValue.toString());
50
49
  return html` ${this.wordText.trim()} `;
51
50
  }
52
51
  get startTimeMs() {
53
- const parentCaptions = this.closest("ef-captions");
54
- const parentStartTime = parentCaptions?.startTimeMs || 0;
55
- return parentStartTime + (this.wordStartMs || 0);
52
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.wordStartMs || 0);
56
53
  }
57
54
  get endTimeMs() {
58
- const parentCaptions = this.closest("ef-captions");
59
- const parentStartTime = parentCaptions?.startTimeMs || 0;
60
- return parentStartTime + (this.wordEndMs || 0);
55
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.wordEndMs || 0);
61
56
  }
62
57
  get durationMs() {
63
58
  return this.wordEndMs - this.wordStartMs;
64
59
  }
65
60
  };
66
- _decorate([property({
61
+ __decorate([property({
67
62
  type: Number,
68
63
  attribute: false
69
64
  })], EFCaptionsActiveWord.prototype, "wordStartMs", void 0);
70
- _decorate([property({
65
+ __decorate([property({
71
66
  type: Number,
72
67
  attribute: false
73
68
  })], EFCaptionsActiveWord.prototype, "wordEndMs", void 0);
74
- _decorate([property({
69
+ __decorate([property({
75
70
  type: String,
76
71
  attribute: false
77
72
  })], EFCaptionsActiveWord.prototype, "wordText", void 0);
78
- _decorate([property({
73
+ __decorate([property({
79
74
  type: Number,
80
75
  attribute: false
81
76
  })], EFCaptionsActiveWord.prototype, "wordIndex", void 0);
82
- _decorate([property({
77
+ __decorate([property({
83
78
  type: Boolean,
84
79
  reflect: true
85
80
  })], EFCaptionsActiveWord.prototype, "hidden", void 0);
86
- EFCaptionsActiveWord = _decorate([customElement("ef-captions-active-word")], EFCaptionsActiveWord);
87
- let EFCaptionsSegment = class EFCaptionsSegment$1 extends EFTemporal(LitElement) {
81
+ EFCaptionsActiveWord = __decorate([customElement("ef-captions-active-word")], EFCaptionsActiveWord);
82
+ var EFCaptionsSegment = class EFCaptionsSegment$1 extends EFTemporal(LitElement) {
88
83
  constructor(..._args2) {
89
84
  super(..._args2);
90
85
  this.segmentStartMs = 0;
@@ -105,43 +100,39 @@ let EFCaptionsSegment = class EFCaptionsSegment$1 extends EFTemporal(LitElement)
105
100
  render() {
106
101
  if (stopWords.has(this.segmentText)) {
107
102
  this.hidden = true;
108
- return void 0;
103
+ return;
109
104
  }
110
105
  this.hidden = false;
111
106
  return html`${this.segmentText}`;
112
107
  }
113
108
  get startTimeMs() {
114
- const parentCaptions = this.closest("ef-captions");
115
- const parentStartTime = parentCaptions?.startTimeMs || 0;
116
- return parentStartTime + (this.segmentStartMs || 0);
109
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.segmentStartMs || 0);
117
110
  }
118
111
  get endTimeMs() {
119
- const parentCaptions = this.closest("ef-captions");
120
- const parentStartTime = parentCaptions?.startTimeMs || 0;
121
- return parentStartTime + (this.segmentEndMs || 0);
112
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.segmentEndMs || 0);
122
113
  }
123
114
  get durationMs() {
124
115
  return this.segmentEndMs - this.segmentStartMs;
125
116
  }
126
117
  };
127
- _decorate([property({
118
+ __decorate([property({
128
119
  type: Number,
129
120
  attribute: false
130
121
  })], EFCaptionsSegment.prototype, "segmentStartMs", void 0);
131
- _decorate([property({
122
+ __decorate([property({
132
123
  type: Number,
133
124
  attribute: false
134
125
  })], EFCaptionsSegment.prototype, "segmentEndMs", void 0);
135
- _decorate([property({
126
+ __decorate([property({
136
127
  type: String,
137
128
  attribute: false
138
129
  })], EFCaptionsSegment.prototype, "segmentText", void 0);
139
- _decorate([property({
130
+ __decorate([property({
140
131
  type: Boolean,
141
132
  reflect: true
142
133
  })], EFCaptionsSegment.prototype, "hidden", void 0);
143
- EFCaptionsSegment = _decorate([customElement("ef-captions-segment")], EFCaptionsSegment);
144
- let EFCaptionsBeforeActiveWord = class EFCaptionsBeforeActiveWord$1 extends EFCaptionsSegment {
134
+ EFCaptionsSegment = __decorate([customElement("ef-captions-segment")], EFCaptionsSegment);
135
+ var EFCaptionsBeforeActiveWord = class EFCaptionsBeforeActiveWord$1 extends EFCaptionsSegment {
145
136
  constructor(..._args3) {
146
137
  super(..._args3);
147
138
  this.hidden = false;
@@ -163,43 +154,39 @@ let EFCaptionsBeforeActiveWord = class EFCaptionsBeforeActiveWord$1 extends EFCa
163
154
  render() {
164
155
  if (stopWords.has(this.segmentText)) {
165
156
  this.hidden = true;
166
- return void 0;
157
+ return;
167
158
  }
168
159
  this.hidden = false;
169
160
  return html` ${this.segmentText}`;
170
161
  }
171
162
  get startTimeMs() {
172
- const parentCaptions = this.closest("ef-captions");
173
- const parentStartTime = parentCaptions?.startTimeMs || 0;
174
- return parentStartTime + (this.segmentStartMs || 0);
163
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.segmentStartMs || 0);
175
164
  }
176
165
  get endTimeMs() {
177
- const parentCaptions = this.closest("ef-captions");
178
- const parentStartTime = parentCaptions?.startTimeMs || 0;
179
- return parentStartTime + (this.segmentEndMs || 0);
166
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.segmentEndMs || 0);
180
167
  }
181
168
  get durationMs() {
182
169
  return this.segmentEndMs - this.segmentStartMs;
183
170
  }
184
171
  };
185
- _decorate([property({
172
+ __decorate([property({
186
173
  type: Boolean,
187
174
  reflect: true
188
175
  })], EFCaptionsBeforeActiveWord.prototype, "hidden", void 0);
189
- _decorate([property({
176
+ __decorate([property({
190
177
  type: String,
191
178
  attribute: false
192
179
  })], EFCaptionsBeforeActiveWord.prototype, "segmentText", void 0);
193
- _decorate([property({
180
+ __decorate([property({
194
181
  type: Number,
195
182
  attribute: false
196
183
  })], EFCaptionsBeforeActiveWord.prototype, "segmentStartMs", void 0);
197
- _decorate([property({
184
+ __decorate([property({
198
185
  type: Number,
199
186
  attribute: false
200
187
  })], EFCaptionsBeforeActiveWord.prototype, "segmentEndMs", void 0);
201
- EFCaptionsBeforeActiveWord = _decorate([customElement("ef-captions-before-active-word")], EFCaptionsBeforeActiveWord);
202
- let EFCaptionsAfterActiveWord = class EFCaptionsAfterActiveWord$1 extends EFCaptionsSegment {
188
+ EFCaptionsBeforeActiveWord = __decorate([customElement("ef-captions-before-active-word")], EFCaptionsBeforeActiveWord);
189
+ var EFCaptionsAfterActiveWord = class EFCaptionsAfterActiveWord$1 extends EFCaptionsSegment {
203
190
  constructor(..._args4) {
204
191
  super(..._args4);
205
192
  this.hidden = false;
@@ -221,43 +208,39 @@ let EFCaptionsAfterActiveWord = class EFCaptionsAfterActiveWord$1 extends EFCapt
221
208
  render() {
222
209
  if (stopWords.has(this.segmentText)) {
223
210
  this.hidden = true;
224
- return void 0;
211
+ return;
225
212
  }
226
213
  this.hidden = false;
227
214
  return html`${this.segmentText} `;
228
215
  }
229
216
  get startTimeMs() {
230
- const parentCaptions = this.closest("ef-captions");
231
- const parentStartTime = parentCaptions?.startTimeMs || 0;
232
- return parentStartTime + (this.segmentStartMs || 0);
217
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.segmentStartMs || 0);
233
218
  }
234
219
  get endTimeMs() {
235
- const parentCaptions = this.closest("ef-captions");
236
- const parentStartTime = parentCaptions?.startTimeMs || 0;
237
- return parentStartTime + (this.segmentEndMs || 0);
220
+ return (this.closest("ef-captions")?.startTimeMs || 0) + (this.segmentEndMs || 0);
238
221
  }
239
222
  get durationMs() {
240
223
  return this.segmentEndMs - this.segmentStartMs;
241
224
  }
242
225
  };
243
- _decorate([property({
226
+ __decorate([property({
244
227
  type: Boolean,
245
228
  reflect: true
246
229
  })], EFCaptionsAfterActiveWord.prototype, "hidden", void 0);
247
- _decorate([property({
230
+ __decorate([property({
248
231
  type: String,
249
232
  attribute: false
250
233
  })], EFCaptionsAfterActiveWord.prototype, "segmentText", void 0);
251
- _decorate([property({
234
+ __decorate([property({
252
235
  type: Number,
253
236
  attribute: false
254
237
  })], EFCaptionsAfterActiveWord.prototype, "segmentStartMs", void 0);
255
- _decorate([property({
238
+ __decorate([property({
256
239
  type: Number,
257
240
  attribute: false
258
241
  })], EFCaptionsAfterActiveWord.prototype, "segmentEndMs", void 0);
259
- EFCaptionsAfterActiveWord = _decorate([customElement("ef-captions-after-active-word")], EFCaptionsAfterActiveWord);
260
- let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(LitElement)), { assetType: "caption_files" }) {
242
+ EFCaptionsAfterActiveWord = __decorate([customElement("ef-captions-after-active-word")], EFCaptionsAfterActiveWord);
243
+ var EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(LitElement)), { assetType: "caption_files" }) {
261
244
  constructor(..._args5) {
262
245
  super(..._args5);
263
246
  this.displayMode = "segment";
@@ -277,11 +260,10 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
277
260
  task: async ([_target, fetch], { signal }) => {
278
261
  if (!this.targetElement) return null;
279
262
  const md5Path = `/@ef-asset/${this.targetElement.src ?? ""}`;
280
- const response = await fetch(md5Path, {
263
+ return (await fetch(md5Path, {
281
264
  method: "HEAD",
282
265
  signal
283
- });
284
- return response.headers.get("etag") ?? void 0;
266
+ })).headers.get("etag") ?? void 0;
285
267
  }
286
268
  });
287
269
  this.transcriptionDataTask = new Task(this, {
@@ -293,8 +275,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
293
275
  ],
294
276
  task: async ([transcriptionsPath, fetch, hasCustomData], { signal }) => {
295
277
  if (hasCustomData || !transcriptionsPath) return null;
296
- const response = await fetch(transcriptionsPath, { signal });
297
- return response.json();
278
+ return (await fetch(transcriptionsPath, { signal })).json();
298
279
  }
299
280
  });
300
281
  this.fragmentIndexTask = new Task(this, {
@@ -302,8 +283,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
302
283
  args: () => [this.transcriptionDataTask.value, this.ownCurrentTimeMs],
303
284
  task: async ([transcription, ownCurrentTimeMs]) => {
304
285
  if (!transcription) return null;
305
- const fragmentIndex = Math.floor(ownCurrentTimeMs / transcription.work_slice_ms);
306
- return fragmentIndex;
286
+ return Math.floor(ownCurrentTimeMs / transcription.work_slice_ms);
307
287
  }
308
288
  });
309
289
  this.customCaptionsDataTask = new Task(this, {
@@ -326,8 +306,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
326
306
  }
327
307
  }
328
308
  if (captionsSrc) try {
329
- const response = await fetch(captionsSrc, { signal });
330
- return await response.json();
309
+ return await (await fetch(captionsSrc, { signal })).json();
331
310
  } catch (error) {
332
311
  console.error(`Failed to load captions from ${captionsSrc}:`, error);
333
312
  return null;
@@ -345,8 +324,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
345
324
  task: async ([transcription, fragmentIndex, fetch], { signal }) => {
346
325
  if (transcription === null || transcription === void 0 || fragmentIndex === null || fragmentIndex === void 0) return null;
347
326
  const fragmentPath = this.transcriptionFragmentPath(transcription.id, fragmentIndex);
348
- const response = await fetch(fragmentPath, { signal });
349
- return response.json();
327
+ return (await fetch(fragmentPath, { signal })).json();
350
328
  }
351
329
  });
352
330
  this.unifiedCaptionsDataTask = new Task(this, {
@@ -402,8 +380,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
402
380
  captionsPath() {
403
381
  if (!this.targetElement) return null;
404
382
  if (this.targetElement.assetId) return `${this.apiHost}/api/v1/caption_files/${this.targetElement.assetId}`;
405
- const targetSrc = this.targetElement.src;
406
- return `/@ef-captions/${targetSrc}`;
383
+ return `/@ef-captions/${this.targetElement.src}`;
407
384
  }
408
385
  transcriptionFragmentPath(transcriptionId, fragmentIndex) {
409
386
  return `${this.apiHost}/api/v1/transcriptions/${transcriptionId}/fragments/${fragmentIndex}`;
@@ -430,8 +407,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
430
407
  updateTextContainers() {
431
408
  const captionsData = this.unifiedCaptionsDataTask.value;
432
409
  if (!captionsData) return;
433
- const currentTimeMs = this.targetElement ? this.targetElement.currentSourceTimeMs : this.ownCurrentTimeMs;
434
- const currentTimeSec = currentTimeMs / 1e3;
410
+ const currentTimeSec = (this.targetElement ? this.targetElement.currentSourceTimeMs : this.ownCurrentTimeMs) / 1e3;
435
411
  const currentWord = captionsData.word_segments.find((word) => currentTimeSec >= word.start && currentTimeSec < word.end);
436
412
  const currentSegment = captionsData.segments.find((segment) => currentTimeSec >= segment.start && currentTimeSec < segment.end);
437
413
  for (const wordContainer of this.activeWordContainers) if (currentWord) {
@@ -476,8 +452,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
476
452
  } else if (currentSegment) {
477
453
  const segmentWords = captionsData.word_segments.filter((word) => word.start >= currentSegment.start && word.end <= currentSegment.end);
478
454
  const firstWord = segmentWords[0];
479
- const isBeforeFirstWord = firstWord && currentTimeSec < firstWord.start;
480
- if (isBeforeFirstWord) {
455
+ if (firstWord && currentTimeSec < firstWord.start) {
481
456
  const allWords = segmentWords.map((w) => w.text.trim()).join(" ");
482
457
  for (const container of this.beforeActiveWordContainers) {
483
458
  container.segmentText = "";
@@ -533,7 +508,7 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
533
508
  captionsData = JSON.parse(scriptElement.textContent);
534
509
  } catch {}
535
510
  } else if (this.customCaptionsDataTask.value) captionsData = this.customCaptionsDataTask.value;
536
- if (!captionsData) return void 0;
511
+ if (!captionsData) return;
537
512
  if (captionsData.segments.length === 0 && captionsData.word_segments.length === 0) return 0;
538
513
  const maxSegmentEnd = captionsData.segments.length > 0 ? Math.max(...captionsData.segments.map((s) => s.end)) : 0;
539
514
  const maxWordEnd = captionsData.word_segments.length > 0 ? Math.max(...captionsData.word_segments.map((w) => w.end)) : 0;
@@ -543,35 +518,35 @@ let EFCaptions = class EFCaptions$1 extends EFSourceMixin(EFTemporal(FetchMixin(
543
518
  return !!(this.captionsData || this.captionsScript || this.customCaptionsDataTask.value);
544
519
  }
545
520
  };
546
- _decorate([property({
521
+ __decorate([property({
547
522
  type: String,
548
523
  attribute: "display-mode",
549
524
  reflect: true
550
525
  })], EFCaptions.prototype, "displayMode", void 0);
551
- _decorate([property({
526
+ __decorate([property({
552
527
  type: Number,
553
528
  attribute: "context-words",
554
529
  reflect: true
555
530
  })], EFCaptions.prototype, "contextWords", void 0);
556
- _decorate([property({
531
+ __decorate([property({
557
532
  type: String,
558
533
  attribute: "target",
559
534
  reflect: true
560
535
  })], EFCaptions.prototype, "targetSelector", void 0);
561
- _decorate([property({ attribute: "word-style" })], EFCaptions.prototype, "wordStyle", void 0);
562
- _decorate([property({
536
+ __decorate([property({ attribute: "word-style" })], EFCaptions.prototype, "wordStyle", void 0);
537
+ __decorate([property({
563
538
  type: String,
564
539
  attribute: "captions-src",
565
540
  reflect: true
566
541
  })], EFCaptions.prototype, "captionsSrc", void 0);
567
- _decorate([property({
542
+ __decorate([property({
568
543
  type: Object,
569
544
  attribute: false
570
545
  })], EFCaptions.prototype, "captionsData", void 0);
571
- _decorate([property({
546
+ __decorate([property({
572
547
  type: String,
573
548
  attribute: "captions-script",
574
549
  reflect: true
575
550
  })], EFCaptions.prototype, "captionsScript", void 0);
576
- EFCaptions = _decorate([customElement("ef-captions")], EFCaptions);
551
+ EFCaptions = __decorate([customElement("ef-captions")], EFCaptions);
577
552
  export { EFCaptions, EFCaptionsActiveWord, EFCaptionsAfterActiveWord, EFCaptionsBeforeActiveWord, EFCaptionsSegment };