hyperframes 0.2.0-alpha.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +23 -37
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -49,7 +49,7 @@ var VERSION;
|
|
|
49
49
|
var init_version = __esm({
|
|
50
50
|
"src/version.ts"() {
|
|
51
51
|
"use strict";
|
|
52
|
-
VERSION = true ? "0.2.0
|
|
52
|
+
VERSION = true ? "0.2.0" : "0.0.0-dev";
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
|
|
@@ -6698,10 +6698,14 @@ function hasAttr(tag, attr) {
|
|
|
6698
6698
|
function injectAttr(tag, attr, value) {
|
|
6699
6699
|
return tag.replace(/>$/, ` ${attr}="${value}">`);
|
|
6700
6700
|
}
|
|
6701
|
-
function compileTag(tag, isVideo) {
|
|
6701
|
+
function compileTag(tag, isVideo, generateId) {
|
|
6702
6702
|
let result = tag;
|
|
6703
6703
|
let unresolved = null;
|
|
6704
|
-
|
|
6704
|
+
let id = getAttr(result, "id");
|
|
6705
|
+
if (!id) {
|
|
6706
|
+
id = `${isVideo ? "hf-video" : "hf-audio"}-${generateId()}`;
|
|
6707
|
+
result = injectAttr(result, "id", id);
|
|
6708
|
+
}
|
|
6705
6709
|
const startStr = getAttr(result, "data-start");
|
|
6706
6710
|
const start = startStr !== null ? parseFloat(startStr) : 0;
|
|
6707
6711
|
const mediaStartStr = getAttr(result, "data-media-start");
|
|
@@ -6728,13 +6732,15 @@ function compileTag(tag, isVideo) {
|
|
|
6728
6732
|
}
|
|
6729
6733
|
function compileTimingAttrs(html) {
|
|
6730
6734
|
const unresolved = [];
|
|
6735
|
+
let nextVideoId = 0;
|
|
6736
|
+
let nextAudioId = 0;
|
|
6731
6737
|
html = html.replace(/<video[^>]*>/gi, (match) => {
|
|
6732
|
-
const { tag, unresolved: u } = compileTag(match, true);
|
|
6738
|
+
const { tag, unresolved: u } = compileTag(match, true, () => nextVideoId++);
|
|
6733
6739
|
if (u) unresolved.push(u);
|
|
6734
6740
|
return tag;
|
|
6735
6741
|
});
|
|
6736
6742
|
html = html.replace(/<audio[^>]*>/gi, (match) => {
|
|
6737
|
-
const { tag, unresolved: u } = compileTag(match, false);
|
|
6743
|
+
const { tag, unresolved: u } = compileTag(match, false, () => nextAudioId++);
|
|
6738
6744
|
if (u) unresolved.push(u);
|
|
6739
6745
|
return tag;
|
|
6740
6746
|
});
|
|
@@ -21029,19 +21035,15 @@ import { join as join20 } from "path";
|
|
|
21029
21035
|
function parseVideoElements(html) {
|
|
21030
21036
|
const videos = [];
|
|
21031
21037
|
const { document: document2 } = parseHTML(html);
|
|
21032
|
-
const videoEls =
|
|
21033
|
-
|
|
21034
|
-
...Array.from(document2.querySelectorAll("video[id][src]")),
|
|
21035
|
-
...Array.from(document2.querySelectorAll("video[src][data-start]"))
|
|
21036
|
-
])
|
|
21037
|
-
);
|
|
21038
|
-
videoEls.forEach((el, i) => {
|
|
21039
|
-
if (!el.id) el.id = `hf-video-${i}`;
|
|
21040
|
-
});
|
|
21038
|
+
const videoEls = document2.querySelectorAll("video[src]");
|
|
21039
|
+
let autoIdCounter = 0;
|
|
21041
21040
|
for (const el of videoEls) {
|
|
21042
|
-
const id = el.getAttribute("id");
|
|
21043
21041
|
const src = el.getAttribute("src");
|
|
21044
|
-
if (!
|
|
21042
|
+
if (!src) continue;
|
|
21043
|
+
const id = el.getAttribute("id") || `hf-video-${autoIdCounter++}`;
|
|
21044
|
+
if (!el.getAttribute("id")) {
|
|
21045
|
+
el.setAttribute("id", id);
|
|
21046
|
+
}
|
|
21045
21047
|
const startAttr = el.getAttribute("data-start");
|
|
21046
21048
|
const endAttr = el.getAttribute("data-end");
|
|
21047
21049
|
const durationAttr = el.getAttribute("data-duration");
|
|
@@ -23806,8 +23808,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir) {
|
|
|
23806
23808
|
);
|
|
23807
23809
|
const mainVideos = parseVideoElements(html);
|
|
23808
23810
|
const mainAudios = parseAudioElements(html);
|
|
23809
|
-
const videos = dedupeElementsById([...
|
|
23810
|
-
const audios = dedupeElementsById([...
|
|
23811
|
+
const videos = dedupeElementsById([...mainVideos, ...subVideos]);
|
|
23812
|
+
const audios = dedupeElementsById([...mainAudios, ...subAudios]);
|
|
23811
23813
|
for (const video of videos) {
|
|
23812
23814
|
if (isHttpUrl(video.src)) continue;
|
|
23813
23815
|
const videoPath = resolve10(projectDir, video.src);
|
|
@@ -23826,22 +23828,6 @@ async function compileForRender(projectDir, htmlPath, downloadDir) {
|
|
|
23826
23828
|
}).catch(() => {
|
|
23827
23829
|
});
|
|
23828
23830
|
}
|
|
23829
|
-
const autoIdVideos = videos.filter((v) => v.id.startsWith("hf-video-"));
|
|
23830
|
-
let htmlWithIds = html;
|
|
23831
|
-
if (autoIdVideos.length > 0) {
|
|
23832
|
-
const { document: idDoc } = parseHTML(html);
|
|
23833
|
-
let changed = false;
|
|
23834
|
-
for (const v of autoIdVideos) {
|
|
23835
|
-
const el = idDoc.querySelector(`video[src="${v.src}"]:not([id])`);
|
|
23836
|
-
if (el) {
|
|
23837
|
-
el.id = v.id;
|
|
23838
|
-
changed = true;
|
|
23839
|
-
}
|
|
23840
|
-
}
|
|
23841
|
-
if (changed) {
|
|
23842
|
-
htmlWithIds = idDoc.documentElement?.outerHTML ?? html;
|
|
23843
|
-
}
|
|
23844
|
-
}
|
|
23845
23831
|
const { document: document2 } = parseHTML(html);
|
|
23846
23832
|
const rootEl = document2.querySelector("[data-composition-id]");
|
|
23847
23833
|
const width = rootEl ? parseInt(rootEl.getAttribute("data-width") || "1080", 10) : 1080;
|
|
@@ -23850,7 +23836,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir) {
|
|
|
23850
23836
|
rootEl.getAttribute("data-duration") || rootEl.getAttribute("data-composition-duration") || "0"
|
|
23851
23837
|
) : 0;
|
|
23852
23838
|
return {
|
|
23853
|
-
html
|
|
23839
|
+
html,
|
|
23854
23840
|
subCompositions,
|
|
23855
23841
|
videos,
|
|
23856
23842
|
audios,
|
|
@@ -23940,8 +23926,8 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
23940
23926
|
} = await parseSubCompositions(html, projectDir, downloadDir);
|
|
23941
23927
|
const mainVideos = parseVideoElements(html);
|
|
23942
23928
|
const mainAudios = parseAudioElements(html);
|
|
23943
|
-
const videos = dedupeElementsById([...
|
|
23944
|
-
const audios = dedupeElementsById([...
|
|
23929
|
+
const videos = dedupeElementsById([...mainVideos, ...subVideos]);
|
|
23930
|
+
const audios = dedupeElementsById([...mainAudios, ...subAudios]);
|
|
23945
23931
|
const remaining = compiled.unresolvedCompositions.filter(
|
|
23946
23932
|
(c2) => !resolutions.some((r) => r.id === c2.id)
|
|
23947
23933
|
);
|