@hyperframes/core 0.9.82 → 0.9.83
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/compiler/timingCompiler.js +39 -35
- package/package.json +4 -4
|
@@ -81,17 +81,28 @@ function replaceOpeningTags(html, names, replace) {
|
|
|
81
81
|
parts.push(html.slice(cursor));
|
|
82
82
|
return parts.join("");
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
/** Applies each tag's durations, in the order given, in one scan of the page however many there are. */
|
|
85
|
+
function applyDurationsById(html, resolutions, apply) {
|
|
86
|
+
const durationsById = new Map();
|
|
87
|
+
for (const { id, duration } of resolutions) {
|
|
88
|
+
const durations = durationsById.get(id);
|
|
89
|
+
if (durations)
|
|
90
|
+
durations.push(duration);
|
|
91
|
+
else
|
|
92
|
+
durationsById.set(id, [duration]);
|
|
93
|
+
}
|
|
85
94
|
const parts = [];
|
|
86
95
|
let cursor = 0;
|
|
87
96
|
for (const span of scanHtmlOpeningTags(html)) {
|
|
88
97
|
if (!span.closed)
|
|
89
98
|
continue;
|
|
90
|
-
const tag = html.slice(span.start, span.end);
|
|
91
99
|
const attr = span.attributes.find((attr) => attr.name === "id");
|
|
92
|
-
if (attr?.kind !== "value"
|
|
100
|
+
if (attr?.kind !== "value")
|
|
101
|
+
continue;
|
|
102
|
+
const durations = durationsById.get(decodeAuthoredAttribute(attr.value));
|
|
103
|
+
if (!durations)
|
|
93
104
|
continue;
|
|
94
|
-
parts.push(html.slice(cursor, span.start),
|
|
105
|
+
parts.push(html.slice(cursor, span.start), durations.reduce(apply, html.slice(span.start, span.end)));
|
|
95
106
|
cursor = span.end;
|
|
96
107
|
}
|
|
97
108
|
parts.push(html.slice(cursor));
|
|
@@ -209,25 +220,21 @@ export function compileTimingAttrs(html) {
|
|
|
209
220
|
* GSAP timeline queries.
|
|
210
221
|
*/
|
|
211
222
|
export function injectDurations(html, resolutions) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
if (start != null) {
|
|
224
|
-
result = injectAttr(result, "data-end", String(start + duration));
|
|
225
|
-
}
|
|
223
|
+
return applyDurationsById(html, resolutions, (tag, duration) => {
|
|
224
|
+
let result = tag;
|
|
225
|
+
// Add data-duration if missing
|
|
226
|
+
if (parseStrictFiniteTimingNumber(getAttr(result, "data-duration")) == null) {
|
|
227
|
+
result = setAttr(result, "data-duration", String(duration));
|
|
228
|
+
}
|
|
229
|
+
// Add data-end if missing. Skip relative id-refs.
|
|
230
|
+
if (!hasAttr(result, "data-end")) {
|
|
231
|
+
const start = parseNumeric(getAttr(result, "data-start"));
|
|
232
|
+
if (start != null) {
|
|
233
|
+
result = injectAttr(result, "data-end", String(start + duration));
|
|
226
234
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
return html;
|
|
235
|
+
}
|
|
236
|
+
return result;
|
|
237
|
+
});
|
|
231
238
|
}
|
|
232
239
|
/**
|
|
233
240
|
* Extract video/audio elements that already have data-duration set.
|
|
@@ -265,17 +272,14 @@ export function extractResolvedMedia(html) {
|
|
|
265
272
|
* and recomputes data-end accordingly.
|
|
266
273
|
*/
|
|
267
274
|
export function clampDurations(html, clamps) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
return html;
|
|
275
|
+
return applyDurationsById(html, clamps, (tag, duration) => {
|
|
276
|
+
// Replace data-duration value
|
|
277
|
+
if (hasAttr(tag, "data-duration"))
|
|
278
|
+
tag = setAttr(tag, "data-duration", String(duration));
|
|
279
|
+
const start = parseNumeric(getAttr(tag, "data-start"));
|
|
280
|
+
if (start != null && hasAttr(tag, "data-end")) {
|
|
281
|
+
tag = setAttr(tag, "data-end", String(start + duration));
|
|
282
|
+
}
|
|
283
|
+
return tag;
|
|
284
|
+
});
|
|
281
285
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.83",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -501,9 +501,9 @@
|
|
|
501
501
|
"linkedom": "^0.18.12",
|
|
502
502
|
"postcss": "^8.5.8",
|
|
503
503
|
"wawoff2": "^2.0.1",
|
|
504
|
-
"@hyperframes/
|
|
505
|
-
"@hyperframes/studio-server": "0.9.
|
|
506
|
-
"@hyperframes/
|
|
504
|
+
"@hyperframes/lint": "0.9.83",
|
|
505
|
+
"@hyperframes/studio-server": "0.9.83",
|
|
506
|
+
"@hyperframes/parsers": "0.9.83"
|
|
507
507
|
},
|
|
508
508
|
"devDependencies": {
|
|
509
509
|
"@fontsource/archivo-black": "^5.2.8",
|