@editframe/elements 0.5.0-beta.7 → 0.5.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/dist/{editor/util/EncodedAsset → lib/av}/EncodedAsset.mjs +24 -22
- package/dist/{editor/util → lib/av}/MP4File.mjs +50 -51
- package/dist/{util → lib/util}/memoize.mjs +1 -2
- package/dist/packages/elements/src/EF_FRAMEGEN.mjs +183 -0
- package/dist/{elements → packages/elements}/src/elements/EFAudio.mjs +1 -4
- package/dist/{elements → packages/elements}/src/elements/EFCaptions.mjs +5 -7
- package/dist/{elements → packages/elements}/src/elements/EFImage.mjs +2 -3
- package/dist/{elements → packages/elements}/src/elements/EFMedia.mjs +18 -27
- package/dist/{elements → packages/elements}/src/elements/EFSourceMixin.mjs +5 -7
- package/dist/{elements → packages/elements}/src/elements/EFTemporal.mjs +2 -15
- package/dist/{elements → packages/elements}/src/elements/EFTimegroup.mjs +32 -43
- package/dist/{elements → packages/elements}/src/elements/EFVideo.mjs +8 -30
- package/dist/{elements → packages/elements}/src/elements/EFWaveform.mjs +1 -2
- package/dist/{elements → packages/elements}/src/elements/FetchMixin.mjs +4 -6
- package/dist/{elements → packages/elements}/src/gui/EFFilmstrip.mjs +10 -22
- package/dist/{elements → packages/elements}/src/gui/EFWorkbench.mjs +4 -25
- package/dist/packages/elements/src/gui/TWMixin.css.mjs +4 -0
- package/dist/style.css +13 -4
- package/package.json +7 -2
- package/dist/elements/src/EF_FRAMEGEN.mjs +0 -130
- package/dist/elements/src/gui/TWMixin.css.mjs +0 -4
- package/dist/util/awaitAnimationFrame.mjs +0 -11
- package/docker-compose.yaml +0 -17
- package/src/EF_FRAMEGEN.ts +0 -208
- package/src/EF_INTERACTIVE.ts +0 -2
- package/src/elements/CrossUpdateController.ts +0 -18
- package/src/elements/EFAudio.ts +0 -42
- package/src/elements/EFCaptions.ts +0 -202
- package/src/elements/EFImage.ts +0 -70
- package/src/elements/EFMedia.ts +0 -395
- package/src/elements/EFSourceMixin.ts +0 -57
- package/src/elements/EFTemporal.ts +0 -246
- package/src/elements/EFTimegroup.browsertest.ts +0 -360
- package/src/elements/EFTimegroup.ts +0 -394
- package/src/elements/EFTimeline.ts +0 -13
- package/src/elements/EFVideo.ts +0 -114
- package/src/elements/EFWaveform.ts +0 -407
- package/src/elements/FetchMixin.ts +0 -18
- package/src/elements/TimegroupController.ts +0 -25
- package/src/elements/buildLitFixture.ts +0 -13
- package/src/elements/durationConverter.ts +0 -6
- package/src/elements/parseTimeToMs.ts +0 -10
- package/src/elements/util.ts +0 -24
- package/src/gui/EFFilmstrip.ts +0 -702
- package/src/gui/EFWorkbench.ts +0 -242
- package/src/gui/TWMixin.css +0 -3
- package/src/gui/TWMixin.ts +0 -27
- package/src/util.d.ts +0 -1
- /package/dist/{editor → lib/av}/msToTimeCode.mjs +0 -0
- /package/dist/{util → lib/util}/awaitMicrotask.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/EF_INTERACTIVE.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements/CrossUpdateController.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements/EFTimeline.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements/TimegroupController.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements/durationConverter.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements/parseTimeToMs.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements/util.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/elements.mjs +0 -0
- /package/dist/{elements → packages/elements}/src/gui/TWMixin.mjs +0 -0
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { LitElement, ReactiveController } from "lit";
|
|
2
|
-
import { consume, createContext } from "@lit/context";
|
|
3
|
-
import { property, state } from "lit/decorators.js";
|
|
4
|
-
import { EFTimegroup } from "./EFTimegroup";
|
|
5
|
-
|
|
6
|
-
import { durationConverter } from "./durationConverter";
|
|
7
|
-
import { Task } from "@lit/task";
|
|
8
|
-
import { EF_INTERACTIVE } from "../EF_INTERACTIVE";
|
|
9
|
-
|
|
10
|
-
export const timegroupContext = createContext<EFTimegroup>(
|
|
11
|
-
Symbol("timeGroupContext"),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export declare class TemporalMixinInterface {
|
|
15
|
-
get hasOwnDuration(): boolean;
|
|
16
|
-
get durationMs(): number;
|
|
17
|
-
get startTimeMs(): number;
|
|
18
|
-
get startTimeWithinParentMs(): number;
|
|
19
|
-
get endTimeMs(): number;
|
|
20
|
-
get ownCurrentTimeMs(): number;
|
|
21
|
-
|
|
22
|
-
parentTimegroup?: EFTimegroup;
|
|
23
|
-
rootTimegroup?: EFTimegroup;
|
|
24
|
-
|
|
25
|
-
frameTask: Task<readonly unknown[], unknown>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const isEFTemporal = (obj: any): obj is TemporalMixinInterface =>
|
|
29
|
-
obj[EF_TEMPORAL];
|
|
30
|
-
|
|
31
|
-
const EF_TEMPORAL = Symbol("EF_TEMPORAL");
|
|
32
|
-
|
|
33
|
-
export const deepGetTemporalElements = (
|
|
34
|
-
element: Element,
|
|
35
|
-
temporals: TemporalMixinInterface[] = [],
|
|
36
|
-
) => {
|
|
37
|
-
for (const child of element.children) {
|
|
38
|
-
if (isEFTemporal(child)) {
|
|
39
|
-
temporals.push(child);
|
|
40
|
-
}
|
|
41
|
-
deepGetTemporalElements(child, temporals);
|
|
42
|
-
}
|
|
43
|
-
return temporals;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const deepGetElementsWithFrameTasks = (
|
|
47
|
-
element: Element,
|
|
48
|
-
elements: { frameTask: Task }[] = [],
|
|
49
|
-
) => {
|
|
50
|
-
for (const child of element.children) {
|
|
51
|
-
if ("frameTask" in child && child.frameTask instanceof Task) {
|
|
52
|
-
elements.push(child as { frameTask: Task });
|
|
53
|
-
}
|
|
54
|
-
deepGetElementsWithFrameTasks(child, elements);
|
|
55
|
-
}
|
|
56
|
-
return elements;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const shallowGetTemporalElements = (
|
|
60
|
-
element: Element,
|
|
61
|
-
temporals: TemporalMixinInterface[] = [],
|
|
62
|
-
) => {
|
|
63
|
-
for (const child of element.children) {
|
|
64
|
-
if (isEFTemporal(child)) {
|
|
65
|
-
temporals.push(child);
|
|
66
|
-
} else {
|
|
67
|
-
shallowGetTemporalElements(child, temporals);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return temporals;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const shallowGetTimegroups = (
|
|
74
|
-
element: Element,
|
|
75
|
-
groups: EFTimegroup[] = [],
|
|
76
|
-
) => {
|
|
77
|
-
for (const child of element.children) {
|
|
78
|
-
if (child instanceof EFTimegroup) {
|
|
79
|
-
groups.push(child);
|
|
80
|
-
} else {
|
|
81
|
-
shallowGetTimegroups(child, groups);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return groups;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export class OwnCurrentTimeController implements ReactiveController {
|
|
88
|
-
constructor(
|
|
89
|
-
private host: EFTimegroup,
|
|
90
|
-
private temporal: TemporalMixinInterface & LitElement,
|
|
91
|
-
) {
|
|
92
|
-
host.addController(this);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
hostUpdated() {
|
|
96
|
-
this.temporal.requestUpdate("ownCurrentTimeMs");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
remove() {
|
|
100
|
-
this.host.removeController(this);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const EFTemporal = <T extends Constructor<LitElement>>(
|
|
105
|
-
superClass: T,
|
|
106
|
-
) => {
|
|
107
|
-
class TemporalMixinClass extends superClass {
|
|
108
|
-
ownCurrentTimeController?: OwnCurrentTimeController;
|
|
109
|
-
|
|
110
|
-
#parentTimegroup?: EFTimegroup;
|
|
111
|
-
@consume({ context: timegroupContext, subscribe: true })
|
|
112
|
-
@property({ attribute: false })
|
|
113
|
-
set parentTimegroup(value: EFTimegroup | undefined) {
|
|
114
|
-
this.#parentTimegroup = value;
|
|
115
|
-
this.ownCurrentTimeController?.remove();
|
|
116
|
-
this.rootTimegroup = this.getRootTimegroup();
|
|
117
|
-
if (this.rootTimegroup) {
|
|
118
|
-
this.ownCurrentTimeController = new OwnCurrentTimeController(
|
|
119
|
-
this.rootTimegroup,
|
|
120
|
-
this,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
get parentTimegroup() {
|
|
125
|
-
return this.#parentTimegroup;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@property({
|
|
129
|
-
type: String,
|
|
130
|
-
attribute: "offset",
|
|
131
|
-
converter: durationConverter,
|
|
132
|
-
})
|
|
133
|
-
private _offsetMs = 0;
|
|
134
|
-
|
|
135
|
-
@property({
|
|
136
|
-
type: Number,
|
|
137
|
-
attribute: "duration",
|
|
138
|
-
converter: durationConverter,
|
|
139
|
-
})
|
|
140
|
-
private _durationMs?: number;
|
|
141
|
-
|
|
142
|
-
private get offsetAppliesToDuration() {
|
|
143
|
-
return !(this.parentTimegroup?.mode === "sequence");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@state()
|
|
147
|
-
rootTimegroup?: EFTimegroup = this.getRootTimegroup();
|
|
148
|
-
|
|
149
|
-
private getRootTimegroup(): EFTimegroup | undefined {
|
|
150
|
-
let parent = this instanceof EFTimegroup ? this : this.parentTimegroup;
|
|
151
|
-
while (parent?.parentTimegroup) {
|
|
152
|
-
parent = parent.parentTimegroup;
|
|
153
|
-
}
|
|
154
|
-
return parent;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
get hasOwnDuration() {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Defining this as a getter to a private property allows us to
|
|
162
|
-
// override it classes that include this mixin.
|
|
163
|
-
get durationMs() {
|
|
164
|
-
let durationMs =
|
|
165
|
-
this._durationMs || this.parentTimegroup?.durationMs || 0;
|
|
166
|
-
return durationMs || 0;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
get offsetMs() {
|
|
170
|
-
return this._offsetMs || 0;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
get parentTemporal() {
|
|
174
|
-
let parent = this.parentElement;
|
|
175
|
-
while (parent && !isEFTemporal(parent)) {
|
|
176
|
-
parent = parent.parentElement;
|
|
177
|
-
}
|
|
178
|
-
return parent;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
get startTimeWithinParentMs() {
|
|
182
|
-
if (!this.parentTemporal) {
|
|
183
|
-
return 0;
|
|
184
|
-
}
|
|
185
|
-
return this.startTimeMs - this.parentTemporal.startTimeMs;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
get startTimeMs(): number {
|
|
189
|
-
const parentTimegroup = this.parentTimegroup;
|
|
190
|
-
if (!parentTimegroup) {
|
|
191
|
-
return 0;
|
|
192
|
-
}
|
|
193
|
-
switch (parentTimegroup.mode) {
|
|
194
|
-
case "sequence": {
|
|
195
|
-
const siblingTemorals = shallowGetTemporalElements(parentTimegroup);
|
|
196
|
-
const ownIndex = siblingTemorals.indexOf(this);
|
|
197
|
-
if (ownIndex === 0) {
|
|
198
|
-
return parentTimegroup.startTimeMs;
|
|
199
|
-
}
|
|
200
|
-
const previous = siblingTemorals[ownIndex - 1];
|
|
201
|
-
if (!previous) {
|
|
202
|
-
throw new Error("Previous temporal element not found");
|
|
203
|
-
}
|
|
204
|
-
return previous.startTimeMs + previous.durationMs;
|
|
205
|
-
}
|
|
206
|
-
case "contain":
|
|
207
|
-
case "fixed":
|
|
208
|
-
return parentTimegroup.startTimeMs + this.offsetMs;
|
|
209
|
-
default:
|
|
210
|
-
throw new Error(`Invalid time mode: ${parentTimegroup.mode}`);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
get endTimeMs(): number {
|
|
215
|
-
return this.startTimeMs + this.durationMs;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
get ownCurrentTimeMs() {
|
|
219
|
-
if (this.rootTimegroup) {
|
|
220
|
-
return Math.min(
|
|
221
|
-
Math.max(0, this.rootTimegroup.currentTimeMs - this.startTimeMs),
|
|
222
|
-
this.durationMs,
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
return 0;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
frameTask = new Task(this, {
|
|
229
|
-
autoRun: EF_INTERACTIVE,
|
|
230
|
-
args: () => [this.ownCurrentTimeMs] as const,
|
|
231
|
-
task: async ([], { signal }) => {
|
|
232
|
-
let fullyUpdated = await this.updateComplete;
|
|
233
|
-
while (!fullyUpdated) {
|
|
234
|
-
fullyUpdated = await this.updateComplete;
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
Object.defineProperty(TemporalMixinClass.prototype, EF_TEMPORAL, {
|
|
241
|
-
value: true,
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
return TemporalMixinClass as unknown as Constructor<TemporalMixinInterface> &
|
|
245
|
-
T;
|
|
246
|
-
};
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { LitElement, render, html } from "lit";
|
|
2
|
-
import { customElement } from "lit/decorators.js";
|
|
3
|
-
import { describe, test, assert, beforeEach } from "vitest";
|
|
4
|
-
import "./EFTimegroup";
|
|
5
|
-
import { EFTimegroup } from "./EFTimegroup";
|
|
6
|
-
import { EFTemporal } from "./EFTemporal";
|
|
7
|
-
import { buildLitFixture } from "./buildLitFixture";
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
11
|
-
localStorage.removeItem(localStorage.key(i)!);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
@customElement("test-temporal")
|
|
16
|
-
class TestTemporal extends EFTemporal(LitElement) {
|
|
17
|
-
get hasOwnDuration(): boolean {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare global {
|
|
23
|
-
interface HTMLElementTagNameMap {
|
|
24
|
-
"test-temporal": TestTemporal;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const litTest = test.extend<{
|
|
29
|
-
container: HTMLDivElement;
|
|
30
|
-
timegroup: EFTimegroup;
|
|
31
|
-
containTimegroup: EFTimegroup;
|
|
32
|
-
sequenceTimegroup: EFTimegroup;
|
|
33
|
-
fixedTimegroup: EFTimegroup;
|
|
34
|
-
tenSecondTimegroup: EFTimegroup;
|
|
35
|
-
}>({
|
|
36
|
-
container: async ({}, use) => {
|
|
37
|
-
const container = document.createElement("div");
|
|
38
|
-
document.body.appendChild(container);
|
|
39
|
-
await use(container);
|
|
40
|
-
document.body.removeChild(container);
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
timegroup: buildLitFixture<EFTimegroup>(html`<ef-timegroup></ef-timegroup>`),
|
|
44
|
-
containTimegroup: buildLitFixture<EFTimegroup>(
|
|
45
|
-
html`<ef-timegroup mode="contain"></ef-timegroup>`,
|
|
46
|
-
),
|
|
47
|
-
sequenceTimegroup: buildLitFixture<EFTimegroup>(
|
|
48
|
-
html`<ef-timegroup mode="sequence"></ef-timegroup>`,
|
|
49
|
-
),
|
|
50
|
-
fixedTimegroup: buildLitFixture<EFTimegroup>(
|
|
51
|
-
html`<ef-timegroup mode="fixed"></ef-timegroup>`,
|
|
52
|
-
),
|
|
53
|
-
tenSecondTimegroup: buildLitFixture<EFTimegroup>(
|
|
54
|
-
html`<ef-timegroup id="ten-second" duration="10s"></ef-timegroup>`,
|
|
55
|
-
),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe(`<ef-timegroup mode="fixed">`, () => {
|
|
59
|
-
litTest(
|
|
60
|
-
"can explicitly set a duration in seconds",
|
|
61
|
-
async ({ fixedTimegroup: timegroup }) => {
|
|
62
|
-
timegroup.setAttribute("duration", "10s");
|
|
63
|
-
assert.equal(timegroup.durationMs, 10_000);
|
|
64
|
-
},
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
litTest(
|
|
68
|
-
"can explicitly set a duration in milliseconds",
|
|
69
|
-
async ({ fixedTimegroup: timegroup }) => {
|
|
70
|
-
timegroup.setAttribute("duration", "10ms");
|
|
71
|
-
assert.equal(timegroup.durationMs, 10);
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe(`<ef-timegroup mode="sequence">`, () => {
|
|
77
|
-
litTest("fixed duration is ignored", ({ sequenceTimegroup: timegroup }) => {
|
|
78
|
-
timegroup.setAttribute("duration", "10s");
|
|
79
|
-
assert.equal(timegroup.durationMs, 0);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
litTest(
|
|
83
|
-
"duration is the sum of child time groups",
|
|
84
|
-
async ({ sequenceTimegroup: timegroup }) => {
|
|
85
|
-
render(
|
|
86
|
-
html`
|
|
87
|
-
<ef-timegroup mode="fixed" duration="5s"></ef-timegroup>
|
|
88
|
-
<ef-timegroup mode="fixed" duration="5s"></ef-timegroup>
|
|
89
|
-
`,
|
|
90
|
-
timegroup,
|
|
91
|
-
);
|
|
92
|
-
await timegroup.updateComplete;
|
|
93
|
-
assert.equal(timegroup.durationMs, 10_000);
|
|
94
|
-
},
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
litTest(
|
|
98
|
-
"duration can include any element with a durationMs value",
|
|
99
|
-
async ({ sequenceTimegroup: TimeGroup }) => {
|
|
100
|
-
render(
|
|
101
|
-
html`
|
|
102
|
-
<ef-timegroup mode="fixed" duration="5s"></ef-timegroup>
|
|
103
|
-
<test-temporal duration="5s"></test-temporal>
|
|
104
|
-
`,
|
|
105
|
-
TimeGroup,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
assert.equal(TimeGroup.durationMs, 10_000);
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
litTest("arbitrary html is ignored", ({ sequenceTimegroup: timegroup }) => {
|
|
113
|
-
render(
|
|
114
|
-
html`
|
|
115
|
-
<div>
|
|
116
|
-
<ef-timegroup mode="fixed" duration="5s"></ef-timegroup>
|
|
117
|
-
</div>
|
|
118
|
-
`,
|
|
119
|
-
timegroup,
|
|
120
|
-
);
|
|
121
|
-
assert.equal(timegroup.durationMs, 5_000);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
litTest(
|
|
125
|
-
"nested time groups are ignored",
|
|
126
|
-
async ({ sequenceTimegroup: timegroup }) => {
|
|
127
|
-
render(
|
|
128
|
-
html`
|
|
129
|
-
<ef-timegroup mode="fixed" duration="5s">
|
|
130
|
-
<ef-timegroup mode="fixed" duration="5s"></ef-timegroup>
|
|
131
|
-
</ef-timegroup>
|
|
132
|
-
`,
|
|
133
|
-
timegroup,
|
|
134
|
-
);
|
|
135
|
-
await timegroup.updateComplete;
|
|
136
|
-
assert.equal(timegroup.durationMs, 5_000);
|
|
137
|
-
},
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe(`<ef-timegroup mode="contain">`, () => {
|
|
142
|
-
litTest("fixed duration is ignored", ({ containTimegroup: timegroup }) => {
|
|
143
|
-
timegroup.setAttribute("duration", "10s");
|
|
144
|
-
assert.equal(timegroup.durationMs, 0);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
litTest(
|
|
148
|
-
"duration is the max of child time groups",
|
|
149
|
-
async ({ containTimegroup: timegroup }) => {
|
|
150
|
-
render(
|
|
151
|
-
html`
|
|
152
|
-
<ef-timegroup mode="fixed" duration="5s"></ef-timegroup>
|
|
153
|
-
<ef-timegroup mode="fixed" duration="10s"></ef-timegroup>
|
|
154
|
-
`,
|
|
155
|
-
timegroup,
|
|
156
|
-
);
|
|
157
|
-
await timegroup.updateComplete;
|
|
158
|
-
assert.equal(timegroup.durationMs, 10_000);
|
|
159
|
-
},
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe("startTimeMs", () => {
|
|
164
|
-
litTest(
|
|
165
|
-
"is computed relative to the root time group",
|
|
166
|
-
async ({ container }) => {
|
|
167
|
-
render(
|
|
168
|
-
html`<ef-timegroup id="root" mode="sequence">
|
|
169
|
-
<ef-timegroup id="a" mode="fixed" duration="5s"></ef-timegroup>
|
|
170
|
-
<ef-timegroup id="b" mode="sequence">
|
|
171
|
-
<ef-timegroup id="c" mode="fixed" duration="5s"></ef-timegroup>
|
|
172
|
-
<ef-timegroup id="d" mode="contain">
|
|
173
|
-
<ef-timegroup id="e" mode="fixed" duration="5s"></ef-timegroup>
|
|
174
|
-
<ef-timegroup id="f" mode="fixed" duration="5s"></ef-timegroup>
|
|
175
|
-
</ef-timegroup>
|
|
176
|
-
</ef-timegroup>
|
|
177
|
-
</ef-timegroup>`,
|
|
178
|
-
container,
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const a = container.querySelector("#a") as EFTimegroup;
|
|
182
|
-
const b = container.querySelector("#b") as EFTimegroup;
|
|
183
|
-
const c = container.querySelector("#c") as EFTimegroup;
|
|
184
|
-
const d = container.querySelector("#d") as EFTimegroup;
|
|
185
|
-
const e = container.querySelector("#e") as EFTimegroup;
|
|
186
|
-
const f = container.querySelector("#f") as EFTimegroup;
|
|
187
|
-
|
|
188
|
-
assert.equal(a.startTimeMs, 0);
|
|
189
|
-
assert.equal(b.startTimeMs, 5_000);
|
|
190
|
-
assert.equal(c.startTimeMs, 5_000);
|
|
191
|
-
assert.equal(d.startTimeMs, 10_000);
|
|
192
|
-
assert.equal(e.startTimeMs, 10_000);
|
|
193
|
-
assert.equal(f.startTimeMs, 10_000);
|
|
194
|
-
},
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
// TODO: Rethink offset math, it shouldn't effect the duration of a temporal item
|
|
198
|
-
// but actually change the start and end time.
|
|
199
|
-
litTest.skip("can be offset with offset attribute", async ({ container }) => {
|
|
200
|
-
render(
|
|
201
|
-
html`<ef-timegroup id="root" mode="contain">
|
|
202
|
-
<test-temporal id="a" duration="5s" offset="5s"></test-temporal>
|
|
203
|
-
</ef-timegroup> `,
|
|
204
|
-
container,
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
const root = container.querySelector("#root") as EFTimegroup;
|
|
208
|
-
const a = container.querySelector("#a") as TestTemporal;
|
|
209
|
-
|
|
210
|
-
assert.equal(a.durationMs, 5_000);
|
|
211
|
-
assert.equal(root.durationMs, 10_000);
|
|
212
|
-
assert.equal(a.startTimeMs, 5_000);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
litTest.skip(
|
|
216
|
-
"offsets do not affect start time when in a sequence group",
|
|
217
|
-
async ({ container }) => {
|
|
218
|
-
render(
|
|
219
|
-
html`<ef-timegroup id="root" mode="sequence">
|
|
220
|
-
<test-temporal id="a" duration="5s"></test-temporal>
|
|
221
|
-
<test-temporal id="b" duration="5s" offset="5s"></test-temporal>
|
|
222
|
-
</ef-timegroup> `,
|
|
223
|
-
container,
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
const root = container.querySelector("#root") as EFTimegroup;
|
|
227
|
-
const a = container.querySelector("#a") as TestTemporal;
|
|
228
|
-
const b = container.querySelector("#b") as TestTemporal;
|
|
229
|
-
|
|
230
|
-
assert.equal(root.durationMs, 10_000);
|
|
231
|
-
assert.equal(a.startTimeMs, 0);
|
|
232
|
-
assert.equal(b.startTimeMs, 5_000);
|
|
233
|
-
},
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
litTest(
|
|
237
|
-
"temporal elements default to expand to fill a timegroup",
|
|
238
|
-
async ({ container }) => {
|
|
239
|
-
render(
|
|
240
|
-
html`<ef-timegroup id="root" mode="fixed" duration="10s">
|
|
241
|
-
<test-temporal id="a"></test-temporal>
|
|
242
|
-
</ef-timegroup> `,
|
|
243
|
-
container,
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
const root = container.querySelector("#root") as EFTimegroup;
|
|
247
|
-
const a = container.querySelector("#a") as TestTemporal;
|
|
248
|
-
|
|
249
|
-
assert.equal(root.durationMs, 10_000);
|
|
250
|
-
assert.equal(a.durationMs, 10_000);
|
|
251
|
-
},
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
litTest(
|
|
255
|
-
"element's parentTimegroup updates as they move",
|
|
256
|
-
async ({ container }) => {
|
|
257
|
-
const timegroup1 = document.createElement("ef-timegroup");
|
|
258
|
-
timegroup1.setAttribute("mode", "fixed");
|
|
259
|
-
timegroup1.setAttribute("duration", "5s");
|
|
260
|
-
|
|
261
|
-
const timegroup2 = document.createElement("ef-timegroup");
|
|
262
|
-
timegroup2.setAttribute("mode", "fixed");
|
|
263
|
-
timegroup2.setAttribute("duration", "5s");
|
|
264
|
-
|
|
265
|
-
container.appendChild(timegroup1);
|
|
266
|
-
container.appendChild(timegroup2);
|
|
267
|
-
|
|
268
|
-
const temporal = document.createElement("test-temporal");
|
|
269
|
-
|
|
270
|
-
timegroup1.appendChild(temporal);
|
|
271
|
-
|
|
272
|
-
assert.equal(temporal.parentTimegroup, timegroup1);
|
|
273
|
-
|
|
274
|
-
timegroup2.appendChild(temporal);
|
|
275
|
-
assert.equal(temporal.parentTimegroup, timegroup2);
|
|
276
|
-
},
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
litTest(
|
|
280
|
-
"elements can access their root temporal element",
|
|
281
|
-
async ({ container }) => {
|
|
282
|
-
render(
|
|
283
|
-
html`<ef-timegroup id="root" mode="contain" duration="10s">
|
|
284
|
-
<ef-timegroup id="a" mode="contain">
|
|
285
|
-
<div>
|
|
286
|
-
<ef-timegroup id="b" mode="contain">
|
|
287
|
-
<div>
|
|
288
|
-
<test-temporal id="c" duration="5s"></test-temporal>
|
|
289
|
-
</div>
|
|
290
|
-
</ef-timegroup>
|
|
291
|
-
</div>
|
|
292
|
-
</ef-timegroup>
|
|
293
|
-
</ef-timegroup> `,
|
|
294
|
-
container,
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const root = container.querySelector("#root") as EFTimegroup;
|
|
298
|
-
const a = container.querySelector("#a") as EFTimegroup;
|
|
299
|
-
const b = container.querySelector("#b") as EFTimegroup;
|
|
300
|
-
const c = container.querySelector("#c") as TestTemporal;
|
|
301
|
-
|
|
302
|
-
assert.equal(root.rootTimegroup, root);
|
|
303
|
-
|
|
304
|
-
assert.equal(a.rootTimegroup, root);
|
|
305
|
-
assert.equal(b.rootTimegroup, root);
|
|
306
|
-
assert.equal(c.rootTimegroup, root);
|
|
307
|
-
},
|
|
308
|
-
);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
describe("setting currentTime", () => {
|
|
312
|
-
litTest(
|
|
313
|
-
"persists in localStorage if the timegroup has an id",
|
|
314
|
-
async ({ tenSecondTimegroup: timegroup }) => {
|
|
315
|
-
assert.isNull(localStorage.getItem(timegroup.storageKey));
|
|
316
|
-
timegroup.currentTime = 5_000;
|
|
317
|
-
assert.equal(localStorage.getItem(timegroup.storageKey), "5000");
|
|
318
|
-
},
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
litTest(
|
|
322
|
-
"does not persist in localStorage if the timegroup has no id",
|
|
323
|
-
async ({ timegroup }) => {
|
|
324
|
-
timegroup.currentTime = 5_000;
|
|
325
|
-
assert.isNull(localStorage.getItem(timegroup.storageKey));
|
|
326
|
-
},
|
|
327
|
-
);
|
|
328
|
-
|
|
329
|
-
litTest(
|
|
330
|
-
"nested items derive their ownCurrentTimeMs",
|
|
331
|
-
async ({ container }) => {
|
|
332
|
-
render(
|
|
333
|
-
html`
|
|
334
|
-
<ef-timegroup id="root" mode="sequence">
|
|
335
|
-
<ef-timegroup id="a" mode="fixed" duration="5s"> </ef-timegroup>
|
|
336
|
-
<test-temporal id="b" mode="fixed" duration="5s"> </test-temporal>
|
|
337
|
-
</ef-timegroup>
|
|
338
|
-
`,
|
|
339
|
-
container,
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
const root = container.querySelector("#root") as EFTimegroup;
|
|
343
|
-
const a = container.querySelector("#a") as TestTemporal;
|
|
344
|
-
const b = container.querySelector("#b") as TestTemporal;
|
|
345
|
-
|
|
346
|
-
assert.equal(a.ownCurrentTimeMs, 0);
|
|
347
|
-
assert.equal(b.ownCurrentTimeMs, 0);
|
|
348
|
-
|
|
349
|
-
root.currentTimeMs = 2_500;
|
|
350
|
-
|
|
351
|
-
assert.equal(a.ownCurrentTimeMs, 2_500);
|
|
352
|
-
assert.equal(b.ownCurrentTimeMs, 0);
|
|
353
|
-
|
|
354
|
-
root.currentTimeMs = 7_500;
|
|
355
|
-
|
|
356
|
-
assert.equal(a.ownCurrentTimeMs, 5_000);
|
|
357
|
-
assert.equal(b.ownCurrentTimeMs, 2_500);
|
|
358
|
-
},
|
|
359
|
-
);
|
|
360
|
-
});
|