@editframe/elements 0.5.0-beta.9 → 0.6.0-beta.10
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/dist/lib/av/EncodedAsset.cjs +561 -0
- package/dist/lib/av/{EncodedAsset.mjs → EncodedAsset.js} +18 -13
- package/dist/lib/av/MP4File.cjs +182 -0
- package/dist/lib/av/{MP4File.mjs → MP4File.js} +15 -10
- package/dist/lib/av/msToTimeCode.cjs +15 -0
- package/dist/lib/util/awaitMicrotask.cjs +8 -0
- package/dist/lib/util/memoize.cjs +14 -0
- package/dist/packages/elements/src/EF_FRAMEGEN.cjs +197 -0
- package/dist/packages/elements/src/EF_FRAMEGEN.d.ts +45 -0
- package/dist/packages/elements/src/{EF_FRAMEGEN.mjs → EF_FRAMEGEN.js} +21 -7
- package/dist/packages/elements/src/EF_INTERACTIVE.cjs +4 -0
- package/dist/packages/elements/src/EF_INTERACTIVE.d.ts +1 -0
- package/dist/packages/elements/src/elements/CrossUpdateController.cjs +16 -0
- package/dist/packages/elements/src/elements/CrossUpdateController.d.ts +9 -0
- package/dist/packages/elements/src/elements/EFAudio.cjs +53 -0
- package/dist/packages/elements/src/elements/EFAudio.d.ts +10 -0
- package/dist/packages/elements/src/elements/{EFAudio.mjs → EFAudio.js} +1 -1
- package/dist/packages/elements/src/elements/EFCaptions.cjs +171 -0
- package/dist/packages/elements/src/elements/EFCaptions.d.ts +39 -0
- package/dist/packages/elements/src/elements/{EFCaptions.mjs → EFCaptions.js} +13 -13
- package/dist/packages/elements/src/elements/EFImage.cjs +79 -0
- package/dist/packages/elements/src/elements/EFImage.d.ts +14 -0
- package/dist/packages/elements/src/elements/{EFImage.mjs → EFImage.js} +6 -4
- package/dist/packages/elements/src/elements/EFMedia.cjs +334 -0
- package/dist/packages/elements/src/elements/EFMedia.d.ts +61 -0
- package/dist/packages/elements/src/elements/{EFMedia.mjs → EFMedia.js} +29 -18
- package/dist/packages/elements/src/elements/EFSourceMixin.cjs +55 -0
- package/dist/packages/elements/src/elements/EFSourceMixin.d.ts +12 -0
- package/dist/packages/elements/src/elements/{EFSourceMixin.mjs → EFSourceMixin.js} +1 -1
- package/dist/packages/elements/src/elements/EFTemporal.cjs +198 -0
- package/dist/packages/elements/src/elements/EFTemporal.d.ts +36 -0
- package/dist/packages/elements/src/elements/{EFTemporal.mjs → EFTemporal.js} +4 -7
- package/dist/packages/elements/src/elements/EFTimegroup.browsertest.d.ts +12 -0
- package/dist/packages/elements/src/elements/EFTimegroup.cjs +343 -0
- package/dist/packages/elements/src/elements/EFTimegroup.d.ts +39 -0
- package/dist/packages/elements/src/elements/{EFTimegroup.mjs → EFTimegroup.js} +23 -22
- package/dist/packages/elements/src/elements/EFTimeline.cjs +15 -0
- package/dist/packages/elements/src/elements/EFTimeline.d.ts +3 -0
- package/dist/packages/elements/src/elements/{EFTimeline.mjs → EFTimeline.js} +5 -2
- package/dist/packages/elements/src/elements/EFVideo.cjs +110 -0
- package/dist/packages/elements/src/elements/EFVideo.d.ts +14 -0
- package/dist/packages/elements/src/elements/{EFVideo.mjs → EFVideo.js} +2 -2
- package/dist/packages/elements/src/elements/EFWaveform.cjs +235 -0
- package/dist/packages/elements/src/elements/EFWaveform.d.ts +28 -0
- package/dist/packages/elements/src/elements/{EFWaveform.mjs → EFWaveform.js} +14 -14
- package/dist/packages/elements/src/elements/FetchMixin.cjs +28 -0
- package/dist/packages/elements/src/elements/FetchMixin.d.ts +8 -0
- package/dist/packages/elements/src/elements/{FetchMixin.mjs → FetchMixin.js} +1 -1
- package/dist/packages/elements/src/elements/TimegroupController.cjs +20 -0
- package/dist/packages/elements/src/elements/TimegroupController.d.ts +14 -0
- package/dist/packages/elements/src/elements/durationConverter.cjs +8 -0
- package/dist/packages/elements/src/elements/durationConverter.d.ts +4 -0
- package/dist/packages/elements/src/elements/{durationConverter.mjs → durationConverter.js} +1 -1
- package/dist/packages/elements/src/elements/parseTimeToMs.cjs +12 -0
- package/dist/packages/elements/src/elements/parseTimeToMs.d.ts +1 -0
- package/dist/packages/elements/src/elements/parseTimeToMs.js +12 -0
- package/dist/packages/elements/src/elements/util.cjs +11 -0
- package/dist/packages/elements/src/elements/util.d.ts +4 -0
- package/dist/packages/elements/src/elements/{util.mjs → util.js} +1 -1
- package/dist/packages/elements/src/gui/EFFilmstrip.cjs +675 -0
- package/dist/packages/elements/src/gui/EFFilmstrip.d.ts +138 -0
- package/dist/packages/elements/src/gui/{EFFilmstrip.mjs → EFFilmstrip.js} +48 -34
- package/dist/packages/elements/src/gui/EFWorkbench.cjs +199 -0
- package/dist/packages/elements/src/gui/EFWorkbench.d.ts +44 -0
- package/dist/packages/elements/src/gui/{EFWorkbench.mjs → EFWorkbench.js} +26 -27
- package/dist/packages/elements/src/gui/TWMixin.cjs +28 -0
- package/dist/packages/elements/src/gui/TWMixin.css.cjs +3 -0
- package/dist/packages/elements/src/gui/TWMixin.d.ts +3 -0
- package/dist/packages/elements/src/gui/{TWMixin.mjs → TWMixin.js} +4 -3
- package/dist/packages/elements/src/index.cjs +47 -0
- package/dist/packages/elements/src/index.d.ts +10 -0
- package/dist/packages/elements/src/index.js +23 -0
- package/package.json +17 -3
- package/dist/packages/elements/src/elements/parseTimeToMs.mjs +0 -13
- package/dist/packages/elements/src/elements.mjs +0 -12
- /package/dist/lib/av/{msToTimeCode.mjs → msToTimeCode.js} +0 -0
- /package/dist/lib/util/{awaitMicrotask.mjs → awaitMicrotask.js} +0 -0
- /package/dist/lib/util/{memoize.mjs → memoize.js} +0 -0
- /package/dist/packages/elements/src/{EF_INTERACTIVE.mjs → EF_INTERACTIVE.js} +0 -0
- /package/dist/packages/elements/src/elements/{CrossUpdateController.mjs → CrossUpdateController.js} +0 -0
- /package/dist/packages/elements/src/elements/{TimegroupController.mjs → TimegroupController.js} +0 -0
- /package/dist/packages/elements/src/gui/{TWMixin.css.mjs → TWMixin.css.js} +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const context = require("@lit/context");
|
|
4
|
+
const decorators_js = require("lit/decorators.js");
|
|
5
|
+
const durationConverter = require("./durationConverter.cjs");
|
|
6
|
+
const task = require("@lit/task");
|
|
7
|
+
const EF_INTERACTIVE = require("../EF_INTERACTIVE.cjs");
|
|
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
|
+
const timegroupContext = context.createContext(
|
|
19
|
+
Symbol("timeGroupContext")
|
|
20
|
+
);
|
|
21
|
+
const isEFTemporal = (obj) => obj[EF_TEMPORAL];
|
|
22
|
+
const EF_TEMPORAL = Symbol("EF_TEMPORAL");
|
|
23
|
+
const deepGetTemporalElements = (element, temporals = []) => {
|
|
24
|
+
for (const child of element.children) {
|
|
25
|
+
if (isEFTemporal(child)) {
|
|
26
|
+
temporals.push(child);
|
|
27
|
+
}
|
|
28
|
+
deepGetTemporalElements(child, temporals);
|
|
29
|
+
}
|
|
30
|
+
return temporals;
|
|
31
|
+
};
|
|
32
|
+
const deepGetElementsWithFrameTasks = (element, elements = []) => {
|
|
33
|
+
for (const child of element.children) {
|
|
34
|
+
if ("frameTask" in child && child.frameTask instanceof task.Task) {
|
|
35
|
+
elements.push(child);
|
|
36
|
+
}
|
|
37
|
+
deepGetElementsWithFrameTasks(child, elements);
|
|
38
|
+
}
|
|
39
|
+
return elements;
|
|
40
|
+
};
|
|
41
|
+
const shallowGetTemporalElements = (element, temporals = []) => {
|
|
42
|
+
for (const child of element.children) {
|
|
43
|
+
if (isEFTemporal(child)) {
|
|
44
|
+
temporals.push(child);
|
|
45
|
+
} else {
|
|
46
|
+
shallowGetTemporalElements(child, temporals);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return temporals;
|
|
50
|
+
};
|
|
51
|
+
class OwnCurrentTimeController {
|
|
52
|
+
constructor(host, temporal) {
|
|
53
|
+
this.host = host;
|
|
54
|
+
this.temporal = temporal;
|
|
55
|
+
host.addController(this);
|
|
56
|
+
}
|
|
57
|
+
hostUpdated() {
|
|
58
|
+
this.temporal.requestUpdate("ownCurrentTimeMs");
|
|
59
|
+
}
|
|
60
|
+
remove() {
|
|
61
|
+
this.host.removeController(this);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const EFTemporal = (superClass) => {
|
|
65
|
+
class TemporalMixinClass extends superClass {
|
|
66
|
+
constructor() {
|
|
67
|
+
super(...arguments);
|
|
68
|
+
this._offsetMs = 0;
|
|
69
|
+
this.rootTimegroup = this.getRootTimegroup();
|
|
70
|
+
this.frameTask = new task.Task(this, {
|
|
71
|
+
autoRun: EF_INTERACTIVE.EF_INTERACTIVE,
|
|
72
|
+
args: () => [this.ownCurrentTimeMs],
|
|
73
|
+
task: async ([], { signal: _signal }) => {
|
|
74
|
+
let fullyUpdated = await this.updateComplete;
|
|
75
|
+
while (!fullyUpdated) {
|
|
76
|
+
fullyUpdated = await this.updateComplete;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
#parentTimegroup;
|
|
82
|
+
set parentTimegroup(value) {
|
|
83
|
+
this.#parentTimegroup = value;
|
|
84
|
+
this.ownCurrentTimeController?.remove();
|
|
85
|
+
this.rootTimegroup = this.getRootTimegroup();
|
|
86
|
+
if (this.rootTimegroup) {
|
|
87
|
+
this.ownCurrentTimeController = new OwnCurrentTimeController(
|
|
88
|
+
this.rootTimegroup,
|
|
89
|
+
this
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
get parentTimegroup() {
|
|
94
|
+
return this.#parentTimegroup;
|
|
95
|
+
}
|
|
96
|
+
getRootTimegroup() {
|
|
97
|
+
let parent = this.tagName === "EF-TIMEGROUP" ? this : this.parentTimegroup;
|
|
98
|
+
while (parent?.parentTimegroup) {
|
|
99
|
+
parent = parent.parentTimegroup;
|
|
100
|
+
}
|
|
101
|
+
return parent;
|
|
102
|
+
}
|
|
103
|
+
get hasOwnDuration() {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
// Defining this as a getter to a private property allows us to
|
|
107
|
+
// override it classes that include this mixin.
|
|
108
|
+
get durationMs() {
|
|
109
|
+
const durationMs = this._durationMs || this.parentTimegroup?.durationMs || 0;
|
|
110
|
+
return durationMs || 0;
|
|
111
|
+
}
|
|
112
|
+
get offsetMs() {
|
|
113
|
+
return this._offsetMs || 0;
|
|
114
|
+
}
|
|
115
|
+
get parentTemporal() {
|
|
116
|
+
let parent = this.parentElement;
|
|
117
|
+
while (parent && !isEFTemporal(parent)) {
|
|
118
|
+
parent = parent.parentElement;
|
|
119
|
+
}
|
|
120
|
+
return parent;
|
|
121
|
+
}
|
|
122
|
+
get startTimeWithinParentMs() {
|
|
123
|
+
if (!this.parentTemporal) {
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
return this.startTimeMs - this.parentTemporal.startTimeMs;
|
|
127
|
+
}
|
|
128
|
+
get startTimeMs() {
|
|
129
|
+
const parentTimegroup = this.parentTimegroup;
|
|
130
|
+
if (!parentTimegroup) {
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
switch (parentTimegroup.mode) {
|
|
134
|
+
case "sequence": {
|
|
135
|
+
const siblingTemorals = shallowGetTemporalElements(parentTimegroup);
|
|
136
|
+
const ownIndex = siblingTemorals.indexOf(this);
|
|
137
|
+
if (ownIndex === 0) {
|
|
138
|
+
return parentTimegroup.startTimeMs;
|
|
139
|
+
}
|
|
140
|
+
const previous = siblingTemorals[ownIndex - 1];
|
|
141
|
+
if (!previous) {
|
|
142
|
+
throw new Error("Previous temporal element not found");
|
|
143
|
+
}
|
|
144
|
+
return previous.startTimeMs + previous.durationMs;
|
|
145
|
+
}
|
|
146
|
+
case "contain":
|
|
147
|
+
case "fixed":
|
|
148
|
+
return parentTimegroup.startTimeMs + this.offsetMs;
|
|
149
|
+
default:
|
|
150
|
+
throw new Error(`Invalid time mode: ${parentTimegroup.mode}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
get endTimeMs() {
|
|
154
|
+
return this.startTimeMs + this.durationMs;
|
|
155
|
+
}
|
|
156
|
+
get ownCurrentTimeMs() {
|
|
157
|
+
if (this.rootTimegroup) {
|
|
158
|
+
return Math.min(
|
|
159
|
+
Math.max(0, this.rootTimegroup.currentTimeMs - this.startTimeMs),
|
|
160
|
+
this.durationMs
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
__decorateClass([
|
|
167
|
+
context.consume({ context: timegroupContext, subscribe: true }),
|
|
168
|
+
decorators_js.property({ attribute: false })
|
|
169
|
+
], TemporalMixinClass.prototype, "parentTimegroup", 1);
|
|
170
|
+
__decorateClass([
|
|
171
|
+
decorators_js.property({
|
|
172
|
+
type: String,
|
|
173
|
+
attribute: "offset",
|
|
174
|
+
converter: durationConverter.durationConverter
|
|
175
|
+
})
|
|
176
|
+
], TemporalMixinClass.prototype, "_offsetMs", 2);
|
|
177
|
+
__decorateClass([
|
|
178
|
+
decorators_js.property({
|
|
179
|
+
type: Number,
|
|
180
|
+
attribute: "duration",
|
|
181
|
+
converter: durationConverter.durationConverter
|
|
182
|
+
})
|
|
183
|
+
], TemporalMixinClass.prototype, "_durationMs", 2);
|
|
184
|
+
__decorateClass([
|
|
185
|
+
decorators_js.state()
|
|
186
|
+
], TemporalMixinClass.prototype, "rootTimegroup", 2);
|
|
187
|
+
Object.defineProperty(TemporalMixinClass.prototype, EF_TEMPORAL, {
|
|
188
|
+
value: true
|
|
189
|
+
});
|
|
190
|
+
return TemporalMixinClass;
|
|
191
|
+
};
|
|
192
|
+
exports.EFTemporal = EFTemporal;
|
|
193
|
+
exports.OwnCurrentTimeController = OwnCurrentTimeController;
|
|
194
|
+
exports.deepGetElementsWithFrameTasks = deepGetElementsWithFrameTasks;
|
|
195
|
+
exports.deepGetTemporalElements = deepGetTemporalElements;
|
|
196
|
+
exports.isEFTemporal = isEFTemporal;
|
|
197
|
+
exports.shallowGetTemporalElements = shallowGetTemporalElements;
|
|
198
|
+
exports.timegroupContext = timegroupContext;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LitElement, ReactiveController } from 'lit';
|
|
2
|
+
import { EFTimegroup } from './EFTimegroup';
|
|
3
|
+
import { Task } from '@lit/task';
|
|
4
|
+
|
|
5
|
+
export declare const timegroupContext: {
|
|
6
|
+
__context__: EFTimegroup;
|
|
7
|
+
};
|
|
8
|
+
export declare class TemporalMixinInterface {
|
|
9
|
+
get hasOwnDuration(): boolean;
|
|
10
|
+
get durationMs(): number;
|
|
11
|
+
get startTimeMs(): number;
|
|
12
|
+
get startTimeWithinParentMs(): number;
|
|
13
|
+
get endTimeMs(): number;
|
|
14
|
+
get ownCurrentTimeMs(): number;
|
|
15
|
+
parentTimegroup?: EFTimegroup;
|
|
16
|
+
rootTimegroup?: EFTimegroup;
|
|
17
|
+
frameTask: Task<readonly unknown[], unknown>;
|
|
18
|
+
}
|
|
19
|
+
export declare const isEFTemporal: (obj: any) => obj is TemporalMixinInterface;
|
|
20
|
+
export declare const deepGetTemporalElements: (element: Element, temporals?: TemporalMixinInterface[]) => TemporalMixinInterface[];
|
|
21
|
+
export declare const deepGetElementsWithFrameTasks: (element: Element, elements?: {
|
|
22
|
+
frameTask: Task;
|
|
23
|
+
}[]) => {
|
|
24
|
+
frameTask: Task;
|
|
25
|
+
}[];
|
|
26
|
+
export declare const shallowGetTemporalElements: (element: Element, temporals?: TemporalMixinInterface[]) => TemporalMixinInterface[];
|
|
27
|
+
export declare class OwnCurrentTimeController implements ReactiveController {
|
|
28
|
+
private host;
|
|
29
|
+
private temporal;
|
|
30
|
+
constructor(host: EFTimegroup, temporal: TemporalMixinInterface & LitElement);
|
|
31
|
+
hostUpdated(): void;
|
|
32
|
+
remove(): void;
|
|
33
|
+
}
|
|
34
|
+
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
35
|
+
export declare const EFTemporal: <T extends Constructor<LitElement>>(superClass: T) => Constructor<TemporalMixinInterface> & T;
|
|
36
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createContext, consume } from "@lit/context";
|
|
2
2
|
import { property, state } from "lit/decorators.js";
|
|
3
|
-
import { durationConverter } from "./durationConverter.
|
|
3
|
+
import { durationConverter } from "./durationConverter.js";
|
|
4
4
|
import { Task } from "@lit/task";
|
|
5
|
-
import { EF_INTERACTIVE } from "../EF_INTERACTIVE.
|
|
5
|
+
import { EF_INTERACTIVE } from "../EF_INTERACTIVE.js";
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
8
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -68,7 +68,7 @@ const EFTemporal = (superClass) => {
|
|
|
68
68
|
this.frameTask = new Task(this, {
|
|
69
69
|
autoRun: EF_INTERACTIVE,
|
|
70
70
|
args: () => [this.ownCurrentTimeMs],
|
|
71
|
-
task: async ([], { signal }) => {
|
|
71
|
+
task: async ([], { signal: _signal }) => {
|
|
72
72
|
let fullyUpdated = await this.updateComplete;
|
|
73
73
|
while (!fullyUpdated) {
|
|
74
74
|
fullyUpdated = await this.updateComplete;
|
|
@@ -91,9 +91,6 @@ const EFTemporal = (superClass) => {
|
|
|
91
91
|
get parentTimegroup() {
|
|
92
92
|
return this.#parentTimegroup;
|
|
93
93
|
}
|
|
94
|
-
get offsetAppliesToDuration() {
|
|
95
|
-
return !(this.parentTimegroup?.mode === "sequence");
|
|
96
|
-
}
|
|
97
94
|
getRootTimegroup() {
|
|
98
95
|
let parent = this.tagName === "EF-TIMEGROUP" ? this : this.parentTimegroup;
|
|
99
96
|
while (parent?.parentTimegroup) {
|
|
@@ -107,7 +104,7 @@ const EFTemporal = (superClass) => {
|
|
|
107
104
|
// Defining this as a getter to a private property allows us to
|
|
108
105
|
// override it classes that include this mixin.
|
|
109
106
|
get durationMs() {
|
|
110
|
-
|
|
107
|
+
const durationMs = this._durationMs || this.parentTimegroup?.durationMs || 0;
|
|
111
108
|
return durationMs || 0;
|
|
112
109
|
}
|
|
113
110
|
get offsetMs() {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
declare const TestTemporal_base: (new (...args: any[]) => import('./EFTemporal').TemporalMixinInterface) & typeof LitElement;
|
|
4
|
+
declare class TestTemporal extends TestTemporal_base {
|
|
5
|
+
get hasOwnDuration(): boolean;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
"test-temporal": TestTemporal;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const lit = require("lit");
|
|
4
|
+
const context = require("@lit/context");
|
|
5
|
+
const decorators_js = require("lit/decorators.js");
|
|
6
|
+
const EFTemporal = require("./EFTemporal.cjs");
|
|
7
|
+
const TimegroupController = require("./TimegroupController.cjs");
|
|
8
|
+
const EF_INTERACTIVE = require("../EF_INTERACTIVE.cjs");
|
|
9
|
+
const EFMedia = require("./EFMedia.cjs");
|
|
10
|
+
const task = require("@lit/task");
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __typeError = (msg) => {
|
|
14
|
+
throw TypeError(msg);
|
|
15
|
+
};
|
|
16
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
17
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
18
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
19
|
+
if (decorator = decorators[i])
|
|
20
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
21
|
+
if (kind && result) __defProp(target, key, result);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
25
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
26
|
+
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);
|
|
27
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
28
|
+
var _currentTime;
|
|
29
|
+
const shallowGetTimegroups = (element, groups = []) => {
|
|
30
|
+
for (const child of Array.from(element.children)) {
|
|
31
|
+
if (child instanceof exports.EFTimegroup) {
|
|
32
|
+
groups.push(child);
|
|
33
|
+
} else {
|
|
34
|
+
shallowGetTimegroups(child, groups);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return groups;
|
|
38
|
+
};
|
|
39
|
+
exports.EFTimegroup = class EFTimegroup extends EFTemporal.EFTemporal(lit.LitElement) {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this._timeGroupContext = this;
|
|
43
|
+
__privateAdd(this, _currentTime, 0);
|
|
44
|
+
this.mode = "sequence";
|
|
45
|
+
this.crossoverMs = 0;
|
|
46
|
+
this.frameTask = new task.Task(this, {
|
|
47
|
+
autoRun: EF_INTERACTIVE.EF_INTERACTIVE,
|
|
48
|
+
args: () => [this.ownCurrentTimeMs, this.currentTimeMs],
|
|
49
|
+
task: async ([], { signal: _signal }) => {
|
|
50
|
+
let fullyUpdated = await this.updateComplete;
|
|
51
|
+
while (!fullyUpdated) {
|
|
52
|
+
fullyUpdated = await this.updateComplete;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
set currentTime(time) {
|
|
58
|
+
__privateSet(this, _currentTime, Math.max(0, Math.min(time, this.durationMs / 1e3)));
|
|
59
|
+
try {
|
|
60
|
+
if (this.id) {
|
|
61
|
+
if (this.isConnected) {
|
|
62
|
+
localStorage.setItem(this.storageKey, time.toString());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.warn("Failed to save time to localStorage", error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
get currentTime() {
|
|
70
|
+
return __privateGet(this, _currentTime);
|
|
71
|
+
}
|
|
72
|
+
get currentTimeMs() {
|
|
73
|
+
return this.currentTime * 1e3;
|
|
74
|
+
}
|
|
75
|
+
set currentTimeMs(ms) {
|
|
76
|
+
this.currentTime = ms / 1e3;
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return lit.html`<slot></slot> `;
|
|
80
|
+
}
|
|
81
|
+
maybeLoadTimeFromLocalStorage() {
|
|
82
|
+
if (this.id) {
|
|
83
|
+
try {
|
|
84
|
+
return Number.parseFloat(localStorage.getItem(this.storageKey) || "0");
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.warn("Failed to load time from localStorage", error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
connectedCallback() {
|
|
92
|
+
super.connectedCallback();
|
|
93
|
+
if (this.id) {
|
|
94
|
+
__privateSet(this, _currentTime, this.maybeLoadTimeFromLocalStorage());
|
|
95
|
+
}
|
|
96
|
+
if (this.parentTimegroup) {
|
|
97
|
+
new TimegroupController.TimegroupController(this.parentTimegroup, this);
|
|
98
|
+
}
|
|
99
|
+
if (this.shouldWrapWithWorkbench()) {
|
|
100
|
+
this.wrapWithWorkbench();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
get storageKey() {
|
|
104
|
+
if (!this.id) {
|
|
105
|
+
throw new Error("Timegroup must have an id to use localStorage.");
|
|
106
|
+
}
|
|
107
|
+
return `ef-timegroup-${this.id}`;
|
|
108
|
+
}
|
|
109
|
+
get crossoverStartMs() {
|
|
110
|
+
const parentTimeGroup = this.parentTimegroup;
|
|
111
|
+
if (!parentTimeGroup || !this.previousElementSibling) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
return parentTimeGroup.crossoverMs;
|
|
115
|
+
}
|
|
116
|
+
get crossoverEndMs() {
|
|
117
|
+
const parentTimeGroup = this.parentTimegroup;
|
|
118
|
+
if (!parentTimeGroup || !this.nextElementSibling) {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
return parentTimeGroup.crossoverMs;
|
|
122
|
+
}
|
|
123
|
+
get durationMs() {
|
|
124
|
+
switch (this.mode) {
|
|
125
|
+
case "fixed":
|
|
126
|
+
return super.durationMs || 0;
|
|
127
|
+
case "sequence": {
|
|
128
|
+
let duration = 0;
|
|
129
|
+
for (const node of this.childTemporals) {
|
|
130
|
+
duration += node.durationMs;
|
|
131
|
+
}
|
|
132
|
+
return duration;
|
|
133
|
+
}
|
|
134
|
+
case "contain": {
|
|
135
|
+
let maxDuration = 0;
|
|
136
|
+
for (const node of this.childTemporals) {
|
|
137
|
+
if (node.hasOwnDuration) {
|
|
138
|
+
maxDuration = Math.max(maxDuration, node.durationMs);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return maxDuration;
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
throw new Error(`Invalid time mode: ${this.mode}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async waitForMediaDurations() {
|
|
148
|
+
return await Promise.all(
|
|
149
|
+
EFMedia.deepGetMediaElements(this).map(
|
|
150
|
+
(media) => media.trackFragmentIndexLoader.taskComplete
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
get childTemporals() {
|
|
155
|
+
return EFTemporal.shallowGetTemporalElements(this);
|
|
156
|
+
}
|
|
157
|
+
updated(changedProperties) {
|
|
158
|
+
super.updated(changedProperties);
|
|
159
|
+
if (changedProperties.has("currentTime") || changedProperties.has("ownCurrentTimeMs")) {
|
|
160
|
+
const timelineTimeMs = (this.rootTimegroup ?? this).currentTimeMs;
|
|
161
|
+
if (this.startTimeMs > timelineTimeMs || this.endTimeMs < timelineTimeMs) {
|
|
162
|
+
this.style.display = "none";
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this.style.display = "";
|
|
166
|
+
const animations = this.getAnimations({ subtree: true });
|
|
167
|
+
this.style.setProperty(
|
|
168
|
+
"--ef-duration",
|
|
169
|
+
`${this.durationMs + this.crossoverEndMs + this.crossoverStartMs}ms`
|
|
170
|
+
);
|
|
171
|
+
for (const animation of animations) {
|
|
172
|
+
if (animation.playState === "running") {
|
|
173
|
+
animation.pause();
|
|
174
|
+
}
|
|
175
|
+
const effect = animation.effect;
|
|
176
|
+
if (!(effect && effect instanceof KeyframeEffect)) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const target = effect.target;
|
|
180
|
+
if (!target) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (target.closest("ef-timegroup") !== this) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (EFTemporal.isEFTemporal(target)) {
|
|
187
|
+
const timing = effect.getTiming();
|
|
188
|
+
const duration = Number(timing.duration) ?? 0;
|
|
189
|
+
const delay = Number(timing.delay);
|
|
190
|
+
const newTime = Math.floor(
|
|
191
|
+
Math.min(target.ownCurrentTimeMs, duration - 1 + delay)
|
|
192
|
+
);
|
|
193
|
+
if (Number.isNaN(newTime)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
animation.currentTime = newTime;
|
|
197
|
+
} else if (target) {
|
|
198
|
+
const nearestTimegroup = target.closest("ef-timegroup");
|
|
199
|
+
if (!nearestTimegroup) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const timing = effect.getTiming();
|
|
203
|
+
const duration = Number(timing.duration) ?? 0;
|
|
204
|
+
const delay = Number(timing.delay);
|
|
205
|
+
const newTime = Math.floor(
|
|
206
|
+
Math.min(nearestTimegroup.ownCurrentTimeMs, duration - 1 + delay)
|
|
207
|
+
);
|
|
208
|
+
if (Number.isNaN(newTime)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
animation.currentTime = newTime;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
shouldWrapWithWorkbench() {
|
|
217
|
+
return EF_INTERACTIVE.EF_INTERACTIVE && this.closest("ef-timegroup") === this && this.closest("ef-workbench") === null;
|
|
218
|
+
}
|
|
219
|
+
wrapWithWorkbench() {
|
|
220
|
+
const workbench = document.createElement("ef-workbench");
|
|
221
|
+
document.body.append(workbench);
|
|
222
|
+
if (!this.hasAttribute("id")) {
|
|
223
|
+
this.setAttribute("id", "root-this");
|
|
224
|
+
}
|
|
225
|
+
this.setAttribute("slot", "canvas");
|
|
226
|
+
workbench.append(this);
|
|
227
|
+
const filmstrip = document.createElement("ef-filmstrip");
|
|
228
|
+
filmstrip.setAttribute("slot", "timeline");
|
|
229
|
+
filmstrip.setAttribute("target", `#${this.id}`);
|
|
230
|
+
workbench.append(filmstrip);
|
|
231
|
+
}
|
|
232
|
+
get hasOwnDuration() {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
get efElements() {
|
|
236
|
+
return Array.from(
|
|
237
|
+
this.querySelectorAll(
|
|
238
|
+
"ef-audio, ef-video, ef-image, ef-captions, ef-waveform"
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
async renderAudio(fromMs, toMs) {
|
|
243
|
+
await this.waitForMediaDurations();
|
|
244
|
+
const durationMs = toMs - fromMs;
|
|
245
|
+
const audioContext = new OfflineAudioContext(
|
|
246
|
+
2,
|
|
247
|
+
Math.round(48e3 * durationMs / 1e3),
|
|
248
|
+
48e3
|
|
249
|
+
);
|
|
250
|
+
await Promise.all(
|
|
251
|
+
EFMedia.deepGetMediaElements(this).map(async (mediaElement) => {
|
|
252
|
+
await mediaElement.trackFragmentIndexLoader.taskComplete;
|
|
253
|
+
const mediaStartsBeforeEnd = mediaElement.startTimeMs <= toMs;
|
|
254
|
+
const mediaEndsAfterStart = mediaElement.endTimeMs >= fromMs;
|
|
255
|
+
const mediaOverlaps = mediaStartsBeforeEnd && mediaEndsAfterStart;
|
|
256
|
+
if (!mediaOverlaps || mediaElement.defaultAudioTrackId === void 0) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const audio = await mediaElement.fetchAudioSpanningTime(fromMs, toMs);
|
|
260
|
+
if (!audio) {
|
|
261
|
+
throw new Error("Failed to fetch audio");
|
|
262
|
+
}
|
|
263
|
+
const ctxStartMs = Math.max(0, mediaElement.startTimeMs - fromMs);
|
|
264
|
+
const ctxEndMs = Math.min(durationMs, mediaElement.endTimeMs - fromMs);
|
|
265
|
+
const ctxDurationMs = ctxEndMs - ctxStartMs;
|
|
266
|
+
const offset = Math.max(0, fromMs - mediaElement.startTimeMs) - audio.startMs;
|
|
267
|
+
const bufferSource = audioContext.createBufferSource();
|
|
268
|
+
bufferSource.buffer = await audioContext.decodeAudioData(
|
|
269
|
+
await audio.blob.arrayBuffer()
|
|
270
|
+
);
|
|
271
|
+
bufferSource.connect(audioContext.destination);
|
|
272
|
+
bufferSource.start(
|
|
273
|
+
ctxStartMs / 1e3,
|
|
274
|
+
offset / 1e3,
|
|
275
|
+
ctxDurationMs / 1e3
|
|
276
|
+
);
|
|
277
|
+
})
|
|
278
|
+
);
|
|
279
|
+
return await audioContext.startRendering();
|
|
280
|
+
}
|
|
281
|
+
async loadMd5Sums() {
|
|
282
|
+
const efElements = this.efElements;
|
|
283
|
+
const loaderTasks = [];
|
|
284
|
+
for (const el of efElements) {
|
|
285
|
+
const md5SumLoader = el.md5SumLoader;
|
|
286
|
+
if (md5SumLoader instanceof task.Task) {
|
|
287
|
+
md5SumLoader.run();
|
|
288
|
+
loaderTasks.push(md5SumLoader.taskComplete);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
await Promise.all(loaderTasks);
|
|
292
|
+
efElements.map((el) => {
|
|
293
|
+
if ("productionSrc" in el && el.productionSrc instanceof Function) {
|
|
294
|
+
el.setAttribute("src", el.productionSrc());
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
_currentTime = /* @__PURE__ */ new WeakMap();
|
|
300
|
+
exports.EFTimegroup.styles = lit.css`
|
|
301
|
+
:host {
|
|
302
|
+
display: block;
|
|
303
|
+
width: 100%;
|
|
304
|
+
height: 100%;
|
|
305
|
+
position: relative;
|
|
306
|
+
top: 0;
|
|
307
|
+
}
|
|
308
|
+
`;
|
|
309
|
+
__decorateClass([
|
|
310
|
+
context.provide({ context: EFTemporal.timegroupContext })
|
|
311
|
+
], exports.EFTimegroup.prototype, "_timeGroupContext", 2);
|
|
312
|
+
__decorateClass([
|
|
313
|
+
decorators_js.property({
|
|
314
|
+
type: String,
|
|
315
|
+
attribute: "mode"
|
|
316
|
+
})
|
|
317
|
+
], exports.EFTimegroup.prototype, "mode", 2);
|
|
318
|
+
__decorateClass([
|
|
319
|
+
decorators_js.property({ type: Number })
|
|
320
|
+
], exports.EFTimegroup.prototype, "currentTime", 1);
|
|
321
|
+
__decorateClass([
|
|
322
|
+
decorators_js.property({
|
|
323
|
+
attribute: "crossover",
|
|
324
|
+
converter: {
|
|
325
|
+
fromAttribute: (value) => {
|
|
326
|
+
if (value.endsWith("ms")) {
|
|
327
|
+
return Number.parseFloat(value);
|
|
328
|
+
}
|
|
329
|
+
if (value.endsWith("s")) {
|
|
330
|
+
return Number.parseFloat(value) * 1e3;
|
|
331
|
+
}
|
|
332
|
+
throw new Error(
|
|
333
|
+
"`crossover` MUST be in milliseconds or seconds (10s, 10000ms)"
|
|
334
|
+
);
|
|
335
|
+
},
|
|
336
|
+
toAttribute: (value) => `${value}ms`
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
], exports.EFTimegroup.prototype, "crossoverMs", 2);
|
|
340
|
+
exports.EFTimegroup = __decorateClass([
|
|
341
|
+
decorators_js.customElement("ef-timegroup")
|
|
342
|
+
], exports.EFTimegroup);
|
|
343
|
+
exports.shallowGetTimegroups = shallowGetTimegroups;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement, PropertyValueMap } from 'lit';
|
|
2
|
+
import { Task } from '@lit/task';
|
|
3
|
+
|
|
4
|
+
export declare const shallowGetTimegroups: (element: Element, groups?: EFTimegroup[]) => EFTimegroup[];
|
|
5
|
+
declare const EFTimegroup_base: (new (...args: any[]) => import('./EFTemporal').TemporalMixinInterface) & typeof LitElement;
|
|
6
|
+
export declare class EFTimegroup extends EFTimegroup_base {
|
|
7
|
+
#private;
|
|
8
|
+
static styles: import('lit').CSSResult;
|
|
9
|
+
_timeGroupContext: this;
|
|
10
|
+
mode: "fixed" | "sequence" | "contain";
|
|
11
|
+
set currentTime(time: number);
|
|
12
|
+
get currentTime(): number;
|
|
13
|
+
get currentTimeMs(): number;
|
|
14
|
+
set currentTimeMs(ms: number);
|
|
15
|
+
crossoverMs: number;
|
|
16
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
17
|
+
maybeLoadTimeFromLocalStorage(): number;
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
get storageKey(): string;
|
|
20
|
+
get crossoverStartMs(): number;
|
|
21
|
+
get crossoverEndMs(): number;
|
|
22
|
+
get durationMs(): number;
|
|
23
|
+
waitForMediaDurations(): Promise<Record<number, import('../../../assets/dist/packages/assets/src').TrackFragmentIndex>[]>;
|
|
24
|
+
get childTemporals(): import('./EFTemporal').TemporalMixinInterface[];
|
|
25
|
+
protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
26
|
+
shouldWrapWithWorkbench(): boolean;
|
|
27
|
+
wrapWithWorkbench(): void;
|
|
28
|
+
get hasOwnDuration(): boolean;
|
|
29
|
+
get efElements(): Element[];
|
|
30
|
+
renderAudio(fromMs: number, toMs: number): Promise<AudioBuffer>;
|
|
31
|
+
loadMd5Sums(): Promise<void>;
|
|
32
|
+
frameTask: Task<readonly [number, number], void>;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
"ef-timegroup": EFTimegroup & Element;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {};
|