@editframe/elements 0.15.0-beta.10 → 0.15.0-beta.12
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/elements/EFMedia.d.ts +1 -1
- package/dist/elements/EFMedia.js +7 -2
- package/dist/elements/EFTimegroup.d.ts +1 -1
- package/dist/getRenderInfo.d.ts +51 -0
- package/dist/getRenderInfo.js +72 -0
- package/dist/gui/TWMixin.js +10 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/package.json +4 -3
- package/src/elements/EFMedia.ts +8 -2
- package/src/gui/TWMixin.ts +15 -2
- package/types.json +1 -1
|
@@ -19,7 +19,7 @@ export declare class EFMedia extends EFMedia_base {
|
|
|
19
19
|
get assetId(): string | null;
|
|
20
20
|
fragmentIndexPath(): string;
|
|
21
21
|
fragmentTrackPath(trackId: string): string;
|
|
22
|
-
trackFragmentIndexLoader: Task<readonly [string, typeof fetch], Record<number, TrackFragmentIndex
|
|
22
|
+
trackFragmentIndexLoader: Task<readonly [string, typeof fetch], Record<number, TrackFragmentIndex> | undefined>;
|
|
23
23
|
initSegmentsLoader: Task<readonly [Record<number, TrackFragmentIndex> | undefined, string, typeof fetch], {
|
|
24
24
|
trackId: string;
|
|
25
25
|
buffer: MP4Box.MP4ArrayBuffer;
|
package/dist/elements/EFMedia.js
CHANGED
|
@@ -70,8 +70,13 @@ const _EFMedia = class _EFMedia2 extends EFTargetable(
|
|
|
70
70
|
this.trackFragmentIndexLoader = new Task(this, {
|
|
71
71
|
args: () => [this.fragmentIndexPath(), this.fetch],
|
|
72
72
|
task: async ([fragmentIndexPath, fetch], { signal }) => {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(fragmentIndexPath, { signal });
|
|
75
|
+
return await response.json();
|
|
76
|
+
} catch (error) {
|
|
77
|
+
log("Failed to load track fragment index", error);
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
75
80
|
},
|
|
76
81
|
onComplete: () => {
|
|
77
82
|
this.requestUpdate("ownCurrentTimeMs");
|
|
@@ -27,7 +27,7 @@ export declare class EFTimegroup extends EFTimegroup_base {
|
|
|
27
27
|
* that caused issues with constructing audio data. We had negative durations
|
|
28
28
|
* in calculations and it was not clear why.
|
|
29
29
|
*/
|
|
30
|
-
waitForMediaDurations(): Promise<Record<number, import('../../../assets/src/index.ts').TrackFragmentIndex>[]>;
|
|
30
|
+
waitForMediaDurations(): Promise<(Record<number, import('../../../assets/src/index.ts').TrackFragmentIndex> | undefined)[]>;
|
|
31
31
|
get childTemporals(): import('./EFTemporal.js').TemporalMixinInterface[];
|
|
32
32
|
protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
33
33
|
private updateAnimations;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RenderInfo: z.ZodObject<{
|
|
3
|
+
width: z.ZodNumber;
|
|
4
|
+
height: z.ZodNumber;
|
|
5
|
+
fps: z.ZodNumber;
|
|
6
|
+
durationMs: z.ZodNumber;
|
|
7
|
+
assets: z.ZodObject<{
|
|
8
|
+
efMedia: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
9
|
+
efCaptions: z.ZodArray<z.ZodString, "many">;
|
|
10
|
+
efImage: z.ZodArray<z.ZodString, "many">;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
efMedia: Record<string, any>;
|
|
13
|
+
efCaptions: string[];
|
|
14
|
+
efImage: string[];
|
|
15
|
+
}, {
|
|
16
|
+
efMedia: Record<string, any>;
|
|
17
|
+
efCaptions: string[];
|
|
18
|
+
efImage: string[];
|
|
19
|
+
}>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
fps: number;
|
|
24
|
+
durationMs: number;
|
|
25
|
+
assets: {
|
|
26
|
+
efMedia: Record<string, any>;
|
|
27
|
+
efCaptions: string[];
|
|
28
|
+
efImage: string[];
|
|
29
|
+
};
|
|
30
|
+
}, {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
fps: number;
|
|
34
|
+
durationMs: number;
|
|
35
|
+
assets: {
|
|
36
|
+
efMedia: Record<string, any>;
|
|
37
|
+
efCaptions: string[];
|
|
38
|
+
efImage: string[];
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export declare const getRenderInfo: () => Promise<{
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
fps: number;
|
|
45
|
+
durationMs: number;
|
|
46
|
+
assets: {
|
|
47
|
+
efMedia: Record<string, any>;
|
|
48
|
+
efCaptions: string[];
|
|
49
|
+
efImage: string[];
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const RenderInfo = z.object({
|
|
3
|
+
width: z.number().positive(),
|
|
4
|
+
height: z.number().positive(),
|
|
5
|
+
fps: z.number().positive(),
|
|
6
|
+
durationMs: z.number().positive(),
|
|
7
|
+
assets: z.object({
|
|
8
|
+
efMedia: z.record(z.any()),
|
|
9
|
+
efCaptions: z.array(z.string()),
|
|
10
|
+
efImage: z.array(z.string())
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
const getRenderInfo = async () => {
|
|
14
|
+
const rootTimeGroup = document.querySelector("ef-timegroup");
|
|
15
|
+
if (!rootTimeGroup) {
|
|
16
|
+
throw new Error("No ef-timegroup found");
|
|
17
|
+
}
|
|
18
|
+
console.error("Waiting for media durations", rootTimeGroup);
|
|
19
|
+
await rootTimeGroup.waitForMediaDurations();
|
|
20
|
+
const width = rootTimeGroup.clientWidth;
|
|
21
|
+
const height = rootTimeGroup.clientHeight;
|
|
22
|
+
const fps = 30;
|
|
23
|
+
const durationMs = Math.round(rootTimeGroup.durationMs);
|
|
24
|
+
const elements = document.querySelectorAll(
|
|
25
|
+
"ef-audio, ef-video, ef-image, ef-captions"
|
|
26
|
+
);
|
|
27
|
+
const assets = {
|
|
28
|
+
efMedia: {},
|
|
29
|
+
efCaptions: /* @__PURE__ */ new Set(),
|
|
30
|
+
efImage: /* @__PURE__ */ new Set()
|
|
31
|
+
};
|
|
32
|
+
for (const element of elements) {
|
|
33
|
+
switch (element.tagName) {
|
|
34
|
+
case "EF-AUDIO":
|
|
35
|
+
case "EF-VIDEO": {
|
|
36
|
+
const src = element.src;
|
|
37
|
+
console.error("Processing element", element.tagName, src);
|
|
38
|
+
assets.efMedia[src] = element.trackFragmentIndexLoader.value;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "EF-IMAGE": {
|
|
42
|
+
const src = element.src;
|
|
43
|
+
console.error("Processing element", element.tagName, src);
|
|
44
|
+
assets.efImage.add(src);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "EF-CAPTIONS": {
|
|
48
|
+
const src = element.targetElement?.src;
|
|
49
|
+
console.error("Processing element", element.tagName, src);
|
|
50
|
+
assets.efCaptions.add(src);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const renderInfo = {
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
fps,
|
|
59
|
+
durationMs,
|
|
60
|
+
assets: {
|
|
61
|
+
efMedia: assets.efMedia,
|
|
62
|
+
efCaptions: Array.from(assets.efCaptions),
|
|
63
|
+
efImage: Array.from(assets.efImage)
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
console.error("Render info", renderInfo);
|
|
67
|
+
return renderInfo;
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
RenderInfo,
|
|
71
|
+
getRenderInfo
|
|
72
|
+
};
|
package/dist/gui/TWMixin.js
CHANGED
|
@@ -18,13 +18,21 @@ function TWMixin(Base) {
|
|
|
18
18
|
"twSheet not found. Probable cause: CSSStyleSheet not supported in this environment"
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
+
const constructorStylesheets = [];
|
|
22
|
+
const constructorStyles = "styles" in this.constructor && this.constructor.styles || [];
|
|
23
|
+
for (const item of constructorStyles) {
|
|
24
|
+
if (item.styleSheet) {
|
|
25
|
+
constructorStylesheets.push(item.styleSheet);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
21
28
|
if (renderRoot?.adoptedStyleSheets) {
|
|
22
29
|
renderRoot.adoptedStyleSheets = [
|
|
23
30
|
twSheet,
|
|
24
|
-
...renderRoot.adoptedStyleSheets
|
|
31
|
+
...renderRoot.adoptedStyleSheets,
|
|
32
|
+
...constructorStylesheets
|
|
25
33
|
];
|
|
26
34
|
} else {
|
|
27
|
-
renderRoot.adoptedStyleSheets = [twSheet];
|
|
35
|
+
renderRoot.adoptedStyleSheets = [twSheet, ...constructorStylesheets];
|
|
28
36
|
}
|
|
29
37
|
return renderRoot;
|
|
30
38
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export { EFToggleLoop } from './gui/EFToggleLoop.js';
|
|
|
14
14
|
export { EFScrubber } from './gui/EFScrubber.js';
|
|
15
15
|
export { EFTimeDisplay } from './gui/EFTimeDisplay.js';
|
|
16
16
|
export { EFFocusOverlay } from './gui/EFFocusOverlay.js';
|
|
17
|
+
export { getRenderInfo, RenderInfo } from './getRenderInfo.js';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { EFScrubber } from "./gui/EFScrubber.js";
|
|
|
16
16
|
import { EFTimeDisplay } from "./gui/EFTimeDisplay.js";
|
|
17
17
|
import { EFFocusOverlay } from "./gui/EFFocusOverlay.js";
|
|
18
18
|
import "./EF_FRAMEGEN.js";
|
|
19
|
+
import { RenderInfo, getRenderInfo } from "./getRenderInfo.js";
|
|
19
20
|
if (typeof window !== "undefined") {
|
|
20
21
|
window.EF_REGISTERED = true;
|
|
21
22
|
}
|
|
@@ -38,5 +39,7 @@ export {
|
|
|
38
39
|
EFTogglePlay,
|
|
39
40
|
EFVideo,
|
|
40
41
|
EFWaveform,
|
|
41
|
-
EFWorkbench
|
|
42
|
+
EFWorkbench,
|
|
43
|
+
RenderInfo,
|
|
44
|
+
getRenderInfo
|
|
42
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/elements",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
"license": "UNLICENSED",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@bramus/style-observer": "^1.3.0",
|
|
30
|
-
"@editframe/assets": "0.15.0-beta.
|
|
30
|
+
"@editframe/assets": "0.15.0-beta.12",
|
|
31
31
|
"@lit/context": "^1.1.2",
|
|
32
32
|
"@lit/task": "^1.0.1",
|
|
33
33
|
"d3": "^7.9.0",
|
|
34
34
|
"debug": "^4.3.5",
|
|
35
35
|
"lit": "^3.1.4",
|
|
36
|
-
"mp4box": "^0.5.2"
|
|
36
|
+
"mp4box": "^0.5.2",
|
|
37
|
+
"zod": "^3.24.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/d3": "^7.4.3",
|
package/src/elements/EFMedia.ts
CHANGED
|
@@ -126,8 +126,14 @@ export class EFMedia extends EFTargetable(
|
|
|
126
126
|
public trackFragmentIndexLoader = new Task(this, {
|
|
127
127
|
args: () => [this.fragmentIndexPath(), this.fetch] as const,
|
|
128
128
|
task: async ([fragmentIndexPath, fetch], { signal }) => {
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
try {
|
|
130
|
+
const response = await fetch(fragmentIndexPath, { signal });
|
|
131
|
+
|
|
132
|
+
return (await response.json()) as Record<number, TrackFragmentIndex>;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
log("Failed to load track fragment index", error);
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
131
137
|
},
|
|
132
138
|
onComplete: () => {
|
|
133
139
|
this.requestUpdate("ownCurrentTimeMs");
|
package/src/gui/TWMixin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LitElement } from "lit";
|
|
1
|
+
import type { CSSResult, LitElement } from "lit";
|
|
2
2
|
// @ts-expect-error cannot figure out how to declare this module as a string
|
|
3
3
|
import twStyle from "./TWMixin.css?inline";
|
|
4
4
|
|
|
@@ -21,13 +21,26 @@ export function TWMixin<T extends new (...args: any[]) => LitElement>(Base: T) {
|
|
|
21
21
|
"twSheet not found. Probable cause: CSSStyleSheet not supported in this environment",
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
const constructorStylesheets: CSSStyleSheet[] = [];
|
|
26
|
+
const constructorStyles = (("styles" in this.constructor &&
|
|
27
|
+
this.constructor.styles) ||
|
|
28
|
+
[]) as CSSResult[];
|
|
29
|
+
|
|
30
|
+
for (const item of constructorStyles) {
|
|
31
|
+
if (item.styleSheet) {
|
|
32
|
+
constructorStylesheets.push(item.styleSheet);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
if (renderRoot?.adoptedStyleSheets) {
|
|
25
37
|
renderRoot.adoptedStyleSheets = [
|
|
26
38
|
twSheet,
|
|
27
39
|
...renderRoot.adoptedStyleSheets,
|
|
40
|
+
...constructorStylesheets,
|
|
28
41
|
];
|
|
29
42
|
} else {
|
|
30
|
-
renderRoot.adoptedStyleSheets = [twSheet];
|
|
43
|
+
renderRoot.adoptedStyleSheets = [twSheet, ...constructorStylesheets];
|
|
31
44
|
}
|
|
32
45
|
return renderRoot;
|
|
33
46
|
}
|