@editframe/elements 0.7.0-beta.8 → 0.7.0-beta.9
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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/postcss.config.cjs +12 -0
- package/{dist/packages/elements/src/EF_FRAMEGEN.js → src/EF_FRAMEGEN.ts} +113 -32
- package/src/EF_INTERACTIVE.ts +2 -0
- package/src/elements.css +22 -0
- package/src/index.ts +33 -0
- package/tailwind.config.ts +10 -0
- package/tsconfig.json +4 -0
- package/vite.config.ts +8 -0
- package/dist/lib/av/EncodedAsset.cjs +0 -577
- package/dist/lib/av/EncodedAsset.js +0 -560
- package/dist/lib/av/MP4File.cjs +0 -187
- package/dist/lib/av/MP4File.js +0 -170
- package/dist/lib/av/msToTimeCode.cjs +0 -15
- package/dist/lib/av/msToTimeCode.js +0 -15
- package/dist/lib/util/awaitMicrotask.cjs +0 -4
- package/dist/lib/util/awaitMicrotask.js +0 -4
- package/dist/lib/util/memoize.cjs +0 -14
- package/dist/lib/util/memoize.js +0 -14
- package/dist/packages/elements/src/EF_FRAMEGEN.cjs +0 -197
- package/dist/packages/elements/src/EF_FRAMEGEN.d.ts +0 -44
- package/dist/packages/elements/src/EF_INTERACTIVE.cjs +0 -4
- package/dist/packages/elements/src/EF_INTERACTIVE.d.ts +0 -1
- package/dist/packages/elements/src/EF_INTERACTIVE.js +0 -4
- package/dist/packages/elements/src/elements/CrossUpdateController.cjs +0 -16
- package/dist/packages/elements/src/elements/CrossUpdateController.d.ts +0 -9
- package/dist/packages/elements/src/elements/CrossUpdateController.js +0 -16
- package/dist/packages/elements/src/elements/EFAudio.cjs +0 -53
- package/dist/packages/elements/src/elements/EFAudio.d.ts +0 -10
- package/dist/packages/elements/src/elements/EFAudio.js +0 -54
- package/dist/packages/elements/src/elements/EFCaptions.cjs +0 -164
- package/dist/packages/elements/src/elements/EFCaptions.d.ts +0 -38
- package/dist/packages/elements/src/elements/EFCaptions.js +0 -166
- package/dist/packages/elements/src/elements/EFImage.cjs +0 -79
- package/dist/packages/elements/src/elements/EFImage.d.ts +0 -14
- package/dist/packages/elements/src/elements/EFImage.js +0 -80
- package/dist/packages/elements/src/elements/EFMedia.cjs +0 -336
- package/dist/packages/elements/src/elements/EFMedia.d.ts +0 -61
- package/dist/packages/elements/src/elements/EFMedia.js +0 -336
- package/dist/packages/elements/src/elements/EFSourceMixin.cjs +0 -55
- package/dist/packages/elements/src/elements/EFSourceMixin.d.ts +0 -12
- package/dist/packages/elements/src/elements/EFSourceMixin.js +0 -55
- package/dist/packages/elements/src/elements/EFTemporal.cjs +0 -199
- package/dist/packages/elements/src/elements/EFTemporal.d.ts +0 -38
- package/dist/packages/elements/src/elements/EFTemporal.js +0 -199
- package/dist/packages/elements/src/elements/EFTimegroup.browsertest.d.ts +0 -12
- package/dist/packages/elements/src/elements/EFTimegroup.cjs +0 -352
- package/dist/packages/elements/src/elements/EFTimegroup.d.ts +0 -39
- package/dist/packages/elements/src/elements/EFTimegroup.js +0 -353
- package/dist/packages/elements/src/elements/EFVideo.cjs +0 -109
- package/dist/packages/elements/src/elements/EFVideo.d.ts +0 -14
- package/dist/packages/elements/src/elements/EFVideo.js +0 -110
- package/dist/packages/elements/src/elements/EFWaveform.cjs +0 -242
- package/dist/packages/elements/src/elements/EFWaveform.d.ts +0 -30
- package/dist/packages/elements/src/elements/EFWaveform.js +0 -226
- package/dist/packages/elements/src/elements/FetchMixin.cjs +0 -28
- package/dist/packages/elements/src/elements/FetchMixin.d.ts +0 -8
- package/dist/packages/elements/src/elements/FetchMixin.js +0 -28
- package/dist/packages/elements/src/elements/TimegroupController.cjs +0 -20
- package/dist/packages/elements/src/elements/TimegroupController.d.ts +0 -14
- package/dist/packages/elements/src/elements/TimegroupController.js +0 -20
- package/dist/packages/elements/src/elements/durationConverter.cjs +0 -8
- package/dist/packages/elements/src/elements/durationConverter.d.ts +0 -4
- package/dist/packages/elements/src/elements/durationConverter.js +0 -8
- package/dist/packages/elements/src/elements/parseTimeToMs.cjs +0 -12
- package/dist/packages/elements/src/elements/parseTimeToMs.d.ts +0 -1
- package/dist/packages/elements/src/elements/parseTimeToMs.js +0 -12
- package/dist/packages/elements/src/elements/util.cjs +0 -11
- package/dist/packages/elements/src/elements/util.d.ts +0 -4
- package/dist/packages/elements/src/elements/util.js +0 -11
- package/dist/packages/elements/src/gui/EFFilmstrip.cjs +0 -825
- package/dist/packages/elements/src/gui/EFFilmstrip.d.ts +0 -147
- package/dist/packages/elements/src/gui/EFFilmstrip.js +0 -833
- package/dist/packages/elements/src/gui/EFWorkbench.cjs +0 -214
- package/dist/packages/elements/src/gui/EFWorkbench.d.ts +0 -45
- package/dist/packages/elements/src/gui/EFWorkbench.js +0 -215
- package/dist/packages/elements/src/gui/TWMixin.cjs +0 -28
- package/dist/packages/elements/src/gui/TWMixin.css.cjs +0 -3
- package/dist/packages/elements/src/gui/TWMixin.css.js +0 -4
- package/dist/packages/elements/src/gui/TWMixin.d.ts +0 -3
- package/dist/packages/elements/src/gui/TWMixin.js +0 -28
- package/dist/packages/elements/src/index.cjs +0 -50
- package/dist/packages/elements/src/index.d.ts +0 -10
- package/dist/packages/elements/src/index.js +0 -23
- package/dist/style.css +0 -791
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class CrossUpdateController {
|
|
4
|
-
constructor(host, target) {
|
|
5
|
-
this.host = host;
|
|
6
|
-
this.target = target;
|
|
7
|
-
this.host.addController(this);
|
|
8
|
-
}
|
|
9
|
-
hostUpdate() {
|
|
10
|
-
this.target.requestUpdate();
|
|
11
|
-
}
|
|
12
|
-
remove() {
|
|
13
|
-
this.host.removeController(this);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.CrossUpdateController = CrossUpdateController;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { LitElement, ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
-
|
|
3
|
-
export declare class CrossUpdateController implements ReactiveController {
|
|
4
|
-
private host;
|
|
5
|
-
private target;
|
|
6
|
-
constructor(host: ReactiveControllerHost, target: LitElement);
|
|
7
|
-
hostUpdate(): void;
|
|
8
|
-
remove(): void;
|
|
9
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class CrossUpdateController {
|
|
2
|
-
constructor(host, target) {
|
|
3
|
-
this.host = host;
|
|
4
|
-
this.target = target;
|
|
5
|
-
this.host.addController(this);
|
|
6
|
-
}
|
|
7
|
-
hostUpdate() {
|
|
8
|
-
this.target.requestUpdate();
|
|
9
|
-
}
|
|
10
|
-
remove() {
|
|
11
|
-
this.host.removeController(this);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
CrossUpdateController
|
|
16
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const lit = require("lit");
|
|
4
|
-
const ref_js = require("lit/directives/ref.js");
|
|
5
|
-
const decorators_js = require("lit/decorators.js");
|
|
6
|
-
const EFMedia = require("./EFMedia.cjs");
|
|
7
|
-
const task = require("@lit/task");
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
12
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
-
if (decorator = decorators[i])
|
|
14
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
15
|
-
if (kind && result) __defProp(target, key, result);
|
|
16
|
-
return result;
|
|
17
|
-
};
|
|
18
|
-
exports.EFAudio = class EFAudio extends EFMedia.EFMedia {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(...arguments);
|
|
21
|
-
this.audioElementRef = ref_js.createRef();
|
|
22
|
-
this.src = "";
|
|
23
|
-
this.frameTask = new task.Task(this, {
|
|
24
|
-
args: () => [
|
|
25
|
-
this.trackFragmentIndexLoader.status,
|
|
26
|
-
this.initSegmentsLoader.status,
|
|
27
|
-
this.seekTask.status,
|
|
28
|
-
this.fetchSeekTask.status,
|
|
29
|
-
this.videoAssetTask.status
|
|
30
|
-
],
|
|
31
|
-
task: async () => {
|
|
32
|
-
await this.trackFragmentIndexLoader.taskComplete;
|
|
33
|
-
await this.initSegmentsLoader.taskComplete;
|
|
34
|
-
await this.seekTask.taskComplete;
|
|
35
|
-
await this.fetchSeekTask.taskComplete;
|
|
36
|
-
await this.videoAssetTask.taskComplete;
|
|
37
|
-
this.rootTimegroup?.requestUpdate();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
render() {
|
|
42
|
-
return lit.html`<audio ${ref_js.ref(this.audioElementRef)}></audio>`;
|
|
43
|
-
}
|
|
44
|
-
get audioElement() {
|
|
45
|
-
return this.audioElementRef.value;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
__decorateClass([
|
|
49
|
-
decorators_js.property({ type: String })
|
|
50
|
-
], exports.EFAudio.prototype, "src", 2);
|
|
51
|
-
exports.EFAudio = __decorateClass([
|
|
52
|
-
decorators_js.customElement("ef-audio")
|
|
53
|
-
], exports.EFAudio);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { EFMedia } from './EFMedia';
|
|
2
|
-
import { Task } from '@lit/task';
|
|
3
|
-
|
|
4
|
-
export declare class EFAudio extends EFMedia {
|
|
5
|
-
audioElementRef: import('lit-html/directives/ref').Ref<HTMLAudioElement>;
|
|
6
|
-
src: string;
|
|
7
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
8
|
-
get audioElement(): HTMLAudioElement | undefined;
|
|
9
|
-
frameTask: Task<readonly [import('@lit/task').TaskStatus, import('@lit/task').TaskStatus, import('@lit/task').TaskStatus, import('@lit/task').TaskStatus, import('@lit/task').TaskStatus], void>;
|
|
10
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { createRef, ref } from "lit/directives/ref.js";
|
|
3
|
-
import { property, customElement } from "lit/decorators.js";
|
|
4
|
-
import { EFMedia } from "./EFMedia.js";
|
|
5
|
-
import { Task } from "@lit/task";
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
9
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
10
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
11
|
-
if (decorator = decorators[i])
|
|
12
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
13
|
-
if (kind && result) __defProp(target, key, result);
|
|
14
|
-
return result;
|
|
15
|
-
};
|
|
16
|
-
let EFAudio = class extends EFMedia {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.audioElementRef = createRef();
|
|
20
|
-
this.src = "";
|
|
21
|
-
this.frameTask = new Task(this, {
|
|
22
|
-
args: () => [
|
|
23
|
-
this.trackFragmentIndexLoader.status,
|
|
24
|
-
this.initSegmentsLoader.status,
|
|
25
|
-
this.seekTask.status,
|
|
26
|
-
this.fetchSeekTask.status,
|
|
27
|
-
this.videoAssetTask.status
|
|
28
|
-
],
|
|
29
|
-
task: async () => {
|
|
30
|
-
await this.trackFragmentIndexLoader.taskComplete;
|
|
31
|
-
await this.initSegmentsLoader.taskComplete;
|
|
32
|
-
await this.seekTask.taskComplete;
|
|
33
|
-
await this.fetchSeekTask.taskComplete;
|
|
34
|
-
await this.videoAssetTask.taskComplete;
|
|
35
|
-
this.rootTimegroup?.requestUpdate();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
render() {
|
|
40
|
-
return html`<audio ${ref(this.audioElementRef)}></audio>`;
|
|
41
|
-
}
|
|
42
|
-
get audioElement() {
|
|
43
|
-
return this.audioElementRef.value;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
__decorateClass([
|
|
47
|
-
property({ type: String })
|
|
48
|
-
], EFAudio.prototype, "src", 2);
|
|
49
|
-
EFAudio = __decorateClass([
|
|
50
|
-
customElement("ef-audio")
|
|
51
|
-
], EFAudio);
|
|
52
|
-
export {
|
|
53
|
-
EFAudio
|
|
54
|
-
};
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const EFAudio = require("./EFAudio.cjs");
|
|
4
|
-
const lit = require("lit");
|
|
5
|
-
const task = require("@lit/task");
|
|
6
|
-
const decorators_js = require("lit/decorators.js");
|
|
7
|
-
const EFVideo = require("./EFVideo.cjs");
|
|
8
|
-
const EFTemporal = require("./EFTemporal.cjs");
|
|
9
|
-
const CrossUpdateController = require("./CrossUpdateController.cjs");
|
|
10
|
-
const FetchMixin = require("./FetchMixin.cjs");
|
|
11
|
-
const EFSourceMixin = require("./EFSourceMixin.cjs");
|
|
12
|
-
const EF_INTERACTIVE = require("../EF_INTERACTIVE.cjs");
|
|
13
|
-
var __defProp = Object.defineProperty;
|
|
14
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
16
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
17
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
18
|
-
if (decorator = decorators[i])
|
|
19
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
20
|
-
if (kind && result) __defProp(target, key, result);
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
exports.EFCaptionsActiveWord = class EFCaptionsActiveWord extends EFTemporal.EFTemporal(lit.LitElement) {
|
|
24
|
-
constructor() {
|
|
25
|
-
super(...arguments);
|
|
26
|
-
this.wordStartMs = 0;
|
|
27
|
-
this.wordEndMs = 0;
|
|
28
|
-
this.wordText = "";
|
|
29
|
-
}
|
|
30
|
-
render() {
|
|
31
|
-
return lit.html`${this.wordText}`;
|
|
32
|
-
}
|
|
33
|
-
get startTimeMs() {
|
|
34
|
-
return this.wordStartMs || 0;
|
|
35
|
-
}
|
|
36
|
-
get durationMs() {
|
|
37
|
-
return this.wordEndMs - this.wordStartMs;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
exports.EFCaptionsActiveWord.styles = [
|
|
41
|
-
lit.css`
|
|
42
|
-
:host {
|
|
43
|
-
display: inline-block;
|
|
44
|
-
}
|
|
45
|
-
`
|
|
46
|
-
];
|
|
47
|
-
__decorateClass([
|
|
48
|
-
decorators_js.property({ type: Number, attribute: false })
|
|
49
|
-
], exports.EFCaptionsActiveWord.prototype, "wordStartMs", 2);
|
|
50
|
-
__decorateClass([
|
|
51
|
-
decorators_js.property({ type: Number, attribute: false })
|
|
52
|
-
], exports.EFCaptionsActiveWord.prototype, "wordEndMs", 2);
|
|
53
|
-
__decorateClass([
|
|
54
|
-
decorators_js.property({ type: String, attribute: false })
|
|
55
|
-
], exports.EFCaptionsActiveWord.prototype, "wordText", 2);
|
|
56
|
-
exports.EFCaptionsActiveWord = __decorateClass([
|
|
57
|
-
decorators_js.customElement("ef-captions-active-word")
|
|
58
|
-
], exports.EFCaptionsActiveWord);
|
|
59
|
-
exports.EFCaptions = class EFCaptions extends EFSourceMixin.EFSourceMixin(
|
|
60
|
-
EFTemporal.EFTemporal(FetchMixin.FetchMixin(lit.LitElement)),
|
|
61
|
-
{ assetType: "caption_files" }
|
|
62
|
-
) {
|
|
63
|
-
constructor() {
|
|
64
|
-
super(...arguments);
|
|
65
|
-
this.target = null;
|
|
66
|
-
this.wordStyle = "";
|
|
67
|
-
this.activeWordContainers = this.getElementsByTagName("ef-captions-active-word");
|
|
68
|
-
this.md5SumLoader = new task.Task(this, {
|
|
69
|
-
autoRun: false,
|
|
70
|
-
args: () => [this.target],
|
|
71
|
-
task: async ([], { signal }) => {
|
|
72
|
-
const md5Path = `/@ef-asset/${this.targetElement.src ?? ""}`;
|
|
73
|
-
const response = await fetch(md5Path, { method: "HEAD", signal });
|
|
74
|
-
return response.headers.get("etag") ?? void 0;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
this.captionsDataTask = new task.Task(this, {
|
|
78
|
-
autoRun: EF_INTERACTIVE.EF_INTERACTIVE,
|
|
79
|
-
args: () => [this.captionsPath(), this.fetch],
|
|
80
|
-
task: async ([captionsPath, fetch2], { signal }) => {
|
|
81
|
-
const response = await fetch2(captionsPath, { signal });
|
|
82
|
-
return response.json();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
this.frameTask = new task.Task(this, {
|
|
86
|
-
autoRun: EF_INTERACTIVE.EF_INTERACTIVE,
|
|
87
|
-
args: () => [this.captionsDataTask.status],
|
|
88
|
-
task: async () => {
|
|
89
|
-
await this.captionsDataTask.taskComplete;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
captionsPath() {
|
|
94
|
-
const targetSrc = this.targetElement.src;
|
|
95
|
-
if (targetSrc.startsWith("editframe://") || targetSrc.startsWith("http")) {
|
|
96
|
-
return targetSrc.replace("isobmff", "caption");
|
|
97
|
-
}
|
|
98
|
-
return `/@ef-captions/${targetSrc}`;
|
|
99
|
-
}
|
|
100
|
-
connectedCallback() {
|
|
101
|
-
super.connectedCallback();
|
|
102
|
-
if (this.targetElement) {
|
|
103
|
-
new CrossUpdateController.CrossUpdateController(this.targetElement, this);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
return this.captionsDataTask.render({
|
|
108
|
-
pending: () => lit.html`<div>Generating captions data...</div>`,
|
|
109
|
-
error: () => lit.html`<div>🚫 Error generating captions data</div>`,
|
|
110
|
-
complete: () => lit.html`<slot></slot>`
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
updated(_changedProperties) {
|
|
114
|
-
this.updateActiveWord();
|
|
115
|
-
}
|
|
116
|
-
updateActiveWord() {
|
|
117
|
-
const caption = this.captionsDataTask.value;
|
|
118
|
-
if (!caption) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const words = [];
|
|
122
|
-
let startMs = 0;
|
|
123
|
-
let endMs = 0;
|
|
124
|
-
for (const segment of caption.segments) {
|
|
125
|
-
if (this.targetElement.ownCurrentTimeMs >= segment.start * 1e3 && this.targetElement.ownCurrentTimeMs <= segment.end * 1e3) {
|
|
126
|
-
for (const word of segment.words) {
|
|
127
|
-
if (this.targetElement.ownCurrentTimeMs >= word.start * 1e3 && this.targetElement.ownCurrentTimeMs <= word.end * 1e3) {
|
|
128
|
-
words.push(word.text);
|
|
129
|
-
startMs = word.start * 1e3;
|
|
130
|
-
endMs = word.end * 1e3;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
for (const container of Array.from(this.activeWordContainers)) {
|
|
136
|
-
container.wordText = words.join(" ");
|
|
137
|
-
container.wordStartMs = startMs;
|
|
138
|
-
container.wordEndMs = endMs;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
get targetElement() {
|
|
142
|
-
const target = document.getElementById(this.getAttribute("target") ?? "");
|
|
143
|
-
if (target instanceof EFAudio.EFAudio || target instanceof EFVideo.EFVideo) {
|
|
144
|
-
return target;
|
|
145
|
-
}
|
|
146
|
-
throw new Error("Invalid target, must be an EFAudio or EFVideo element");
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
exports.EFCaptions.styles = [
|
|
150
|
-
lit.css`
|
|
151
|
-
:host {
|
|
152
|
-
display: block;
|
|
153
|
-
}
|
|
154
|
-
`
|
|
155
|
-
];
|
|
156
|
-
__decorateClass([
|
|
157
|
-
decorators_js.property({ type: String, attribute: "target" })
|
|
158
|
-
], exports.EFCaptions.prototype, "target", 2);
|
|
159
|
-
__decorateClass([
|
|
160
|
-
decorators_js.property({ attribute: "word-style" })
|
|
161
|
-
], exports.EFCaptions.prototype, "wordStyle", 2);
|
|
162
|
-
exports.EFCaptions = __decorateClass([
|
|
163
|
-
decorators_js.customElement("ef-captions")
|
|
164
|
-
], exports.EFCaptions);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { EFAudio } from './EFAudio';
|
|
2
|
-
import { LitElement, PropertyValueMap } from 'lit';
|
|
3
|
-
import { Task } from '@lit/task';
|
|
4
|
-
import { EFVideo } from './EFVideo';
|
|
5
|
-
|
|
6
|
-
declare const EFCaptionsActiveWord_base: (new (...args: any[]) => import('./EFTemporal').TemporalMixinInterface) & typeof LitElement;
|
|
7
|
-
export declare class EFCaptionsActiveWord extends EFCaptionsActiveWord_base {
|
|
8
|
-
static styles: import('lit').CSSResult[];
|
|
9
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
10
|
-
wordStartMs: number;
|
|
11
|
-
wordEndMs: number;
|
|
12
|
-
wordText: string;
|
|
13
|
-
get startTimeMs(): number;
|
|
14
|
-
get durationMs(): number;
|
|
15
|
-
}
|
|
16
|
-
declare const EFCaptions_base: (new (...args: any[]) => import('./EFSourceMixin').EFSourceMixinInterface) & (new (...args: any[]) => import('./EFTemporal').TemporalMixinInterface) & (new (...args: any[]) => import('./FetchMixin').FetchMixinInterface) & typeof LitElement;
|
|
17
|
-
export declare class EFCaptions extends EFCaptions_base {
|
|
18
|
-
static styles: import('lit').CSSResult[];
|
|
19
|
-
target: null;
|
|
20
|
-
wordStyle: string;
|
|
21
|
-
activeWordContainers: HTMLCollectionOf<EFCaptionsActiveWord>;
|
|
22
|
-
captionsPath(): string;
|
|
23
|
-
protected md5SumLoader: Task<readonly [null], string | undefined>;
|
|
24
|
-
private captionsDataTask;
|
|
25
|
-
frameTask: Task<import('@lit/task').TaskStatus[], void>;
|
|
26
|
-
connectedCallback(): void;
|
|
27
|
-
render(): import('lit-html').TemplateResult<1> | undefined;
|
|
28
|
-
protected updated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
29
|
-
updateActiveWord(): void;
|
|
30
|
-
get targetElement(): EFAudio | EFVideo;
|
|
31
|
-
}
|
|
32
|
-
declare global {
|
|
33
|
-
interface HTMLElementTagNameMap {
|
|
34
|
-
"ef-captions": EFCaptions;
|
|
35
|
-
"ef-captions-active-word": EFCaptionsActiveWord;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { EFAudio } from "./EFAudio.js";
|
|
2
|
-
import { html, css, LitElement } from "lit";
|
|
3
|
-
import { Task } from "@lit/task";
|
|
4
|
-
import { property, customElement } from "lit/decorators.js";
|
|
5
|
-
import { EFVideo } from "./EFVideo.js";
|
|
6
|
-
import { EFTemporal } from "./EFTemporal.js";
|
|
7
|
-
import { CrossUpdateController } from "./CrossUpdateController.js";
|
|
8
|
-
import { FetchMixin } from "./FetchMixin.js";
|
|
9
|
-
import { EFSourceMixin } from "./EFSourceMixin.js";
|
|
10
|
-
import { EF_INTERACTIVE } from "../EF_INTERACTIVE.js";
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
14
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
15
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
-
if (decorator = decorators[i])
|
|
17
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
18
|
-
if (kind && result) __defProp(target, key, result);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
let EFCaptionsActiveWord = class extends EFTemporal(LitElement) {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
this.wordStartMs = 0;
|
|
25
|
-
this.wordEndMs = 0;
|
|
26
|
-
this.wordText = "";
|
|
27
|
-
}
|
|
28
|
-
render() {
|
|
29
|
-
return html`${this.wordText}`;
|
|
30
|
-
}
|
|
31
|
-
get startTimeMs() {
|
|
32
|
-
return this.wordStartMs || 0;
|
|
33
|
-
}
|
|
34
|
-
get durationMs() {
|
|
35
|
-
return this.wordEndMs - this.wordStartMs;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
EFCaptionsActiveWord.styles = [
|
|
39
|
-
css`
|
|
40
|
-
:host {
|
|
41
|
-
display: inline-block;
|
|
42
|
-
}
|
|
43
|
-
`
|
|
44
|
-
];
|
|
45
|
-
__decorateClass([
|
|
46
|
-
property({ type: Number, attribute: false })
|
|
47
|
-
], EFCaptionsActiveWord.prototype, "wordStartMs", 2);
|
|
48
|
-
__decorateClass([
|
|
49
|
-
property({ type: Number, attribute: false })
|
|
50
|
-
], EFCaptionsActiveWord.prototype, "wordEndMs", 2);
|
|
51
|
-
__decorateClass([
|
|
52
|
-
property({ type: String, attribute: false })
|
|
53
|
-
], EFCaptionsActiveWord.prototype, "wordText", 2);
|
|
54
|
-
EFCaptionsActiveWord = __decorateClass([
|
|
55
|
-
customElement("ef-captions-active-word")
|
|
56
|
-
], EFCaptionsActiveWord);
|
|
57
|
-
let EFCaptions = class extends EFSourceMixin(
|
|
58
|
-
EFTemporal(FetchMixin(LitElement)),
|
|
59
|
-
{ assetType: "caption_files" }
|
|
60
|
-
) {
|
|
61
|
-
constructor() {
|
|
62
|
-
super(...arguments);
|
|
63
|
-
this.target = null;
|
|
64
|
-
this.wordStyle = "";
|
|
65
|
-
this.activeWordContainers = this.getElementsByTagName("ef-captions-active-word");
|
|
66
|
-
this.md5SumLoader = new Task(this, {
|
|
67
|
-
autoRun: false,
|
|
68
|
-
args: () => [this.target],
|
|
69
|
-
task: async ([], { signal }) => {
|
|
70
|
-
const md5Path = `/@ef-asset/${this.targetElement.src ?? ""}`;
|
|
71
|
-
const response = await fetch(md5Path, { method: "HEAD", signal });
|
|
72
|
-
return response.headers.get("etag") ?? void 0;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
this.captionsDataTask = new Task(this, {
|
|
76
|
-
autoRun: EF_INTERACTIVE,
|
|
77
|
-
args: () => [this.captionsPath(), this.fetch],
|
|
78
|
-
task: async ([captionsPath, fetch2], { signal }) => {
|
|
79
|
-
const response = await fetch2(captionsPath, { signal });
|
|
80
|
-
return response.json();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
this.frameTask = new Task(this, {
|
|
84
|
-
autoRun: EF_INTERACTIVE,
|
|
85
|
-
args: () => [this.captionsDataTask.status],
|
|
86
|
-
task: async () => {
|
|
87
|
-
await this.captionsDataTask.taskComplete;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
captionsPath() {
|
|
92
|
-
const targetSrc = this.targetElement.src;
|
|
93
|
-
if (targetSrc.startsWith("editframe://") || targetSrc.startsWith("http")) {
|
|
94
|
-
return targetSrc.replace("isobmff", "caption");
|
|
95
|
-
}
|
|
96
|
-
return `/@ef-captions/${targetSrc}`;
|
|
97
|
-
}
|
|
98
|
-
connectedCallback() {
|
|
99
|
-
super.connectedCallback();
|
|
100
|
-
if (this.targetElement) {
|
|
101
|
-
new CrossUpdateController(this.targetElement, this);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
render() {
|
|
105
|
-
return this.captionsDataTask.render({
|
|
106
|
-
pending: () => html`<div>Generating captions data...</div>`,
|
|
107
|
-
error: () => html`<div>🚫 Error generating captions data</div>`,
|
|
108
|
-
complete: () => html`<slot></slot>`
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
updated(_changedProperties) {
|
|
112
|
-
this.updateActiveWord();
|
|
113
|
-
}
|
|
114
|
-
updateActiveWord() {
|
|
115
|
-
const caption = this.captionsDataTask.value;
|
|
116
|
-
if (!caption) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const words = [];
|
|
120
|
-
let startMs = 0;
|
|
121
|
-
let endMs = 0;
|
|
122
|
-
for (const segment of caption.segments) {
|
|
123
|
-
if (this.targetElement.ownCurrentTimeMs >= segment.start * 1e3 && this.targetElement.ownCurrentTimeMs <= segment.end * 1e3) {
|
|
124
|
-
for (const word of segment.words) {
|
|
125
|
-
if (this.targetElement.ownCurrentTimeMs >= word.start * 1e3 && this.targetElement.ownCurrentTimeMs <= word.end * 1e3) {
|
|
126
|
-
words.push(word.text);
|
|
127
|
-
startMs = word.start * 1e3;
|
|
128
|
-
endMs = word.end * 1e3;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
for (const container of Array.from(this.activeWordContainers)) {
|
|
134
|
-
container.wordText = words.join(" ");
|
|
135
|
-
container.wordStartMs = startMs;
|
|
136
|
-
container.wordEndMs = endMs;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
get targetElement() {
|
|
140
|
-
const target = document.getElementById(this.getAttribute("target") ?? "");
|
|
141
|
-
if (target instanceof EFAudio || target instanceof EFVideo) {
|
|
142
|
-
return target;
|
|
143
|
-
}
|
|
144
|
-
throw new Error("Invalid target, must be an EFAudio or EFVideo element");
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
EFCaptions.styles = [
|
|
148
|
-
css`
|
|
149
|
-
:host {
|
|
150
|
-
display: block;
|
|
151
|
-
}
|
|
152
|
-
`
|
|
153
|
-
];
|
|
154
|
-
__decorateClass([
|
|
155
|
-
property({ type: String, attribute: "target" })
|
|
156
|
-
], EFCaptions.prototype, "target", 2);
|
|
157
|
-
__decorateClass([
|
|
158
|
-
property({ attribute: "word-style" })
|
|
159
|
-
], EFCaptions.prototype, "wordStyle", 2);
|
|
160
|
-
EFCaptions = __decorateClass([
|
|
161
|
-
customElement("ef-captions")
|
|
162
|
-
], EFCaptions);
|
|
163
|
-
export {
|
|
164
|
-
EFCaptions,
|
|
165
|
-
EFCaptionsActiveWord
|
|
166
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const task = require("@lit/task");
|
|
4
|
-
const lit = require("lit");
|
|
5
|
-
const decorators_js = require("lit/decorators.js");
|
|
6
|
-
const ref_js = require("lit/directives/ref.js");
|
|
7
|
-
const FetchMixin = require("./FetchMixin.cjs");
|
|
8
|
-
const EFSourceMixin = require("./EFSourceMixin.cjs");
|
|
9
|
-
const EF_INTERACTIVE = require("../EF_INTERACTIVE.cjs");
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
14
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
15
|
-
if (decorator = decorators[i])
|
|
16
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
17
|
-
if (kind && result) __defProp(target, key, result);
|
|
18
|
-
return result;
|
|
19
|
-
};
|
|
20
|
-
exports.EFImage = class EFImage extends EFSourceMixin.EFSourceMixin(FetchMixin.FetchMixin(lit.LitElement), {
|
|
21
|
-
assetType: "image_files"
|
|
22
|
-
}) {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
this.imageRef = ref_js.createRef();
|
|
26
|
-
this.canvasRef = ref_js.createRef();
|
|
27
|
-
this.fetchImage = new task.Task(this, {
|
|
28
|
-
autoRun: EF_INTERACTIVE.EF_INTERACTIVE,
|
|
29
|
-
args: () => [this.assetPath(), this.fetch],
|
|
30
|
-
task: async ([assetPath, fetch], { signal }) => {
|
|
31
|
-
const response = await fetch(assetPath, { signal });
|
|
32
|
-
const image = new Image();
|
|
33
|
-
image.src = URL.createObjectURL(await response.blob());
|
|
34
|
-
await new Promise((resolve) => {
|
|
35
|
-
image.onload = resolve;
|
|
36
|
-
});
|
|
37
|
-
if (!this.canvasRef.value) throw new Error("Canvas not ready");
|
|
38
|
-
const ctx = this.canvasRef.value.getContext("2d");
|
|
39
|
-
if (!ctx) throw new Error("Canvas 2d context not ready");
|
|
40
|
-
this.canvasRef.value.width = image.width;
|
|
41
|
-
this.canvasRef.value.height = image.height;
|
|
42
|
-
ctx.drawImage(image, 0, 0);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
this.frameTask = new task.Task(this, {
|
|
46
|
-
autoRun: EF_INTERACTIVE.EF_INTERACTIVE,
|
|
47
|
-
args: () => [this.fetchImage.status],
|
|
48
|
-
task: async () => {
|
|
49
|
-
await this.fetchImage.taskComplete;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
render() {
|
|
54
|
-
return lit.html`<canvas ${ref_js.ref(this.canvasRef)}></canvas>`;
|
|
55
|
-
}
|
|
56
|
-
assetPath() {
|
|
57
|
-
if (this.src.startsWith("editframe://") || this.src.startsWith("http")) {
|
|
58
|
-
return this.src;
|
|
59
|
-
}
|
|
60
|
-
return `/@ef-image/${this.src}`;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
exports.EFImage.styles = [
|
|
64
|
-
lit.css`
|
|
65
|
-
:host {
|
|
66
|
-
display: block;
|
|
67
|
-
}
|
|
68
|
-
canvas {
|
|
69
|
-
display: block;
|
|
70
|
-
width: 100%;
|
|
71
|
-
height: 100%;
|
|
72
|
-
object-fit: fill;
|
|
73
|
-
object-position: center;
|
|
74
|
-
}
|
|
75
|
-
`
|
|
76
|
-
];
|
|
77
|
-
exports.EFImage = __decorateClass([
|
|
78
|
-
decorators_js.customElement("ef-image")
|
|
79
|
-
], exports.EFImage);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Task } from '@lit/task';
|
|
2
|
-
import { LitElement } from 'lit';
|
|
3
|
-
|
|
4
|
-
declare const EFImage_base: (new (...args: any[]) => import('./EFSourceMixin').EFSourceMixinInterface) & (new (...args: any[]) => import('./FetchMixin').FetchMixinInterface) & typeof LitElement;
|
|
5
|
-
export declare class EFImage extends EFImage_base {
|
|
6
|
-
static styles: import('lit').CSSResult[];
|
|
7
|
-
imageRef: import('lit-html/directives/ref').Ref<HTMLImageElement>;
|
|
8
|
-
canvasRef: import('lit-html/directives/ref').Ref<HTMLCanvasElement>;
|
|
9
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
10
|
-
assetPath(): string;
|
|
11
|
-
fetchImage: Task<readonly [string, typeof fetch], void>;
|
|
12
|
-
frameTask: Task<readonly [import('@lit/task').TaskStatus], void>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|