@hyperframes/producer 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/index.js +22 -36
- package/dist/index.js.map +2 -2
- package/dist/public-server.js +22 -36
- package/dist/public-server.js.map +2 -2
- package/dist/services/htmlCompiler.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -99063,10 +99063,14 @@ function hasAttr(tag, attr) {
|
|
|
99063
99063
|
function injectAttr(tag, attr, value) {
|
|
99064
99064
|
return tag.replace(/>$/, ` ${attr}="${value}">`);
|
|
99065
99065
|
}
|
|
99066
|
-
function compileTag(tag, isVideo) {
|
|
99066
|
+
function compileTag(tag, isVideo, generateId) {
|
|
99067
99067
|
let result = tag;
|
|
99068
99068
|
let unresolved = null;
|
|
99069
|
-
|
|
99069
|
+
let id = getAttr(result, "id");
|
|
99070
|
+
if (!id) {
|
|
99071
|
+
id = `${isVideo ? "hf-video" : "hf-audio"}-${generateId()}`;
|
|
99072
|
+
result = injectAttr(result, "id", id);
|
|
99073
|
+
}
|
|
99070
99074
|
const startStr = getAttr(result, "data-start");
|
|
99071
99075
|
const start = startStr !== null ? parseFloat(startStr) : 0;
|
|
99072
99076
|
const mediaStartStr = getAttr(result, "data-media-start");
|
|
@@ -99093,13 +99097,15 @@ function compileTag(tag, isVideo) {
|
|
|
99093
99097
|
}
|
|
99094
99098
|
function compileTimingAttrs(html) {
|
|
99095
99099
|
const unresolved = [];
|
|
99100
|
+
let nextVideoId = 0;
|
|
99101
|
+
let nextAudioId = 0;
|
|
99096
99102
|
html = html.replace(/<video[^>]*>/gi, (match2) => {
|
|
99097
|
-
const { tag, unresolved: u } = compileTag(match2, true);
|
|
99103
|
+
const { tag, unresolved: u } = compileTag(match2, true, () => nextVideoId++);
|
|
99098
99104
|
if (u) unresolved.push(u);
|
|
99099
99105
|
return tag;
|
|
99100
99106
|
});
|
|
99101
99107
|
html = html.replace(/<audio[^>]*>/gi, (match2) => {
|
|
99102
|
-
const { tag, unresolved: u } = compileTag(match2, false);
|
|
99108
|
+
const { tag, unresolved: u } = compileTag(match2, false, () => nextAudioId++);
|
|
99103
99109
|
if (u) unresolved.push(u);
|
|
99104
99110
|
return tag;
|
|
99105
99111
|
});
|
|
@@ -101636,19 +101642,15 @@ function isHttpUrl(path12) {
|
|
|
101636
101642
|
function parseVideoElements(html) {
|
|
101637
101643
|
const videos = [];
|
|
101638
101644
|
const { document: document2 } = parseHTML(html);
|
|
101639
|
-
const videoEls =
|
|
101640
|
-
|
|
101641
|
-
...Array.from(document2.querySelectorAll("video[id][src]")),
|
|
101642
|
-
...Array.from(document2.querySelectorAll("video[src][data-start]"))
|
|
101643
|
-
])
|
|
101644
|
-
);
|
|
101645
|
-
videoEls.forEach((el, i) => {
|
|
101646
|
-
if (!el.id) el.id = `hf-video-${i}`;
|
|
101647
|
-
});
|
|
101645
|
+
const videoEls = document2.querySelectorAll("video[src]");
|
|
101646
|
+
let autoIdCounter = 0;
|
|
101648
101647
|
for (const el of videoEls) {
|
|
101649
|
-
const id = el.getAttribute("id");
|
|
101650
101648
|
const src = el.getAttribute("src");
|
|
101651
|
-
if (!
|
|
101649
|
+
if (!src) continue;
|
|
101650
|
+
const id = el.getAttribute("id") || `hf-video-${autoIdCounter++}`;
|
|
101651
|
+
if (!el.getAttribute("id")) {
|
|
101652
|
+
el.setAttribute("id", id);
|
|
101653
|
+
}
|
|
101652
101654
|
const startAttr = el.getAttribute("data-start");
|
|
101653
101655
|
const endAttr = el.getAttribute("data-end");
|
|
101654
101656
|
const durationAttr = el.getAttribute("data-duration");
|
|
@@ -106169,8 +106171,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir) {
|
|
|
106169
106171
|
);
|
|
106170
106172
|
const mainVideos = parseVideoElements(html);
|
|
106171
106173
|
const mainAudios = parseAudioElements(html);
|
|
106172
|
-
const videos = dedupeElementsById([...
|
|
106173
|
-
const audios = dedupeElementsById([...
|
|
106174
|
+
const videos = dedupeElementsById([...mainVideos, ...subVideos]);
|
|
106175
|
+
const audios = dedupeElementsById([...mainAudios, ...subAudios]);
|
|
106174
106176
|
for (const video of videos) {
|
|
106175
106177
|
if (isHttpUrl(video.src)) continue;
|
|
106176
106178
|
const videoPath = resolve8(projectDir, video.src);
|
|
@@ -106189,22 +106191,6 @@ async function compileForRender(projectDir, htmlPath, downloadDir) {
|
|
|
106189
106191
|
}).catch(() => {
|
|
106190
106192
|
});
|
|
106191
106193
|
}
|
|
106192
|
-
const autoIdVideos = videos.filter((v) => v.id.startsWith("hf-video-"));
|
|
106193
|
-
let htmlWithIds = html;
|
|
106194
|
-
if (autoIdVideos.length > 0) {
|
|
106195
|
-
const { document: idDoc } = parseHTML(html);
|
|
106196
|
-
let changed = false;
|
|
106197
|
-
for (const v of autoIdVideos) {
|
|
106198
|
-
const el = idDoc.querySelector(`video[src="${v.src}"]:not([id])`);
|
|
106199
|
-
if (el) {
|
|
106200
|
-
el.id = v.id;
|
|
106201
|
-
changed = true;
|
|
106202
|
-
}
|
|
106203
|
-
}
|
|
106204
|
-
if (changed) {
|
|
106205
|
-
htmlWithIds = idDoc.documentElement?.outerHTML ?? html;
|
|
106206
|
-
}
|
|
106207
|
-
}
|
|
106208
106194
|
const { document: document2 } = parseHTML(html);
|
|
106209
106195
|
const rootEl = document2.querySelector("[data-composition-id]");
|
|
106210
106196
|
const width = rootEl ? parseInt(rootEl.getAttribute("data-width") || "1080", 10) : 1080;
|
|
@@ -106213,7 +106199,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir) {
|
|
|
106213
106199
|
rootEl.getAttribute("data-duration") || rootEl.getAttribute("data-composition-duration") || "0"
|
|
106214
106200
|
) : 0;
|
|
106215
106201
|
return {
|
|
106216
|
-
html
|
|
106202
|
+
html,
|
|
106217
106203
|
subCompositions,
|
|
106218
106204
|
videos,
|
|
106219
106205
|
audios,
|
|
@@ -106303,8 +106289,8 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
106303
106289
|
} = await parseSubCompositions(html, projectDir, downloadDir);
|
|
106304
106290
|
const mainVideos = parseVideoElements(html);
|
|
106305
106291
|
const mainAudios = parseAudioElements(html);
|
|
106306
|
-
const videos = dedupeElementsById([...
|
|
106307
|
-
const audios = dedupeElementsById([...
|
|
106292
|
+
const videos = dedupeElementsById([...mainVideos, ...subVideos]);
|
|
106293
|
+
const audios = dedupeElementsById([...mainAudios, ...subAudios]);
|
|
106308
106294
|
const remaining = compiled.unresolvedCompositions.filter(
|
|
106309
106295
|
(c) => !resolutions.some((r) => r.id === c.id)
|
|
106310
106296
|
);
|