@hyperframes/inspector 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.
Files changed (2) hide show
  1. package/dist/service.js +34 -30
  2. package/package.json +3 -3
package/dist/service.js CHANGED
@@ -53008,15 +53008,25 @@ function replaceOpeningTags(html, names, replace3) {
53008
53008
  parts.push(html.slice(cursor));
53009
53009
  return parts.join("");
53010
53010
  }
53011
- function replaceIdTags(html, id, replace3) {
53011
+ function applyDurationsById(html, resolutions, apply) {
53012
+ const durationsById = /* @__PURE__ */ new Map();
53013
+ for (const { id, duration } of resolutions) {
53014
+ const durations = durationsById.get(id);
53015
+ if (durations) durations.push(duration);
53016
+ else durationsById.set(id, [duration]);
53017
+ }
53012
53018
  const parts = [];
53013
53019
  let cursor = 0;
53014
53020
  for (const span of scanHtmlOpeningTags(html)) {
53015
53021
  if (!span.closed) continue;
53016
- const tag = html.slice(span.start, span.end);
53017
53022
  const attr = span.attributes.find((attr2) => attr2.name === "id");
53018
- if (attr?.kind !== "value" || decodeAuthoredAttribute(attr.value) !== id) continue;
53019
- parts.push(html.slice(cursor, span.start), replace3(tag));
53023
+ if (attr?.kind !== "value") continue;
53024
+ const durations = durationsById.get(decodeAuthoredAttribute(attr.value));
53025
+ if (!durations) continue;
53026
+ parts.push(
53027
+ html.slice(cursor, span.start),
53028
+ durations.reduce(apply, html.slice(span.start, span.end))
53029
+ );
53020
53030
  cursor = span.end;
53021
53031
  }
53022
53032
  parts.push(html.slice(cursor));
@@ -53105,22 +53115,19 @@ function compileTimingAttrs(html) {
53105
53115
  return { html, unresolved };
53106
53116
  }
53107
53117
  function injectDurations(html, resolutions) {
53108
- for (const { id, duration } of resolutions) {
53109
- html = replaceIdTags(html, id, (tag) => {
53110
- let result = tag;
53111
- if (parseStrictFiniteTimingNumber(getAttr(result, "data-duration")) == null) {
53112
- result = setAttr(result, "data-duration", String(duration));
53113
- }
53114
- if (!hasAttr(result, "data-end")) {
53115
- const start = parseNumeric(getAttr(result, "data-start"));
53116
- if (start != null) {
53117
- result = injectAttr(result, "data-end", String(start + duration));
53118
- }
53118
+ return applyDurationsById(html, resolutions, (tag, duration) => {
53119
+ let result = tag;
53120
+ if (parseStrictFiniteTimingNumber(getAttr(result, "data-duration")) == null) {
53121
+ result = setAttr(result, "data-duration", String(duration));
53122
+ }
53123
+ if (!hasAttr(result, "data-end")) {
53124
+ const start = parseNumeric(getAttr(result, "data-start"));
53125
+ if (start != null) {
53126
+ result = injectAttr(result, "data-end", String(start + duration));
53119
53127
  }
53120
- return result;
53121
- });
53122
- }
53123
- return html;
53128
+ }
53129
+ return result;
53130
+ });
53124
53131
  }
53125
53132
  function extractResolvedMedia(html) {
53126
53133
  const resolved = [];
@@ -53147,17 +53154,14 @@ function extractResolvedMedia(html) {
53147
53154
  return resolved;
53148
53155
  }
53149
53156
  function clampDurations(html, clamps) {
53150
- for (const { id, duration } of clamps) {
53151
- html = replaceIdTags(html, id, (tag) => {
53152
- if (hasAttr(tag, "data-duration")) tag = setAttr(tag, "data-duration", String(duration));
53153
- const start = parseNumeric(getAttr(tag, "data-start"));
53154
- if (start != null && hasAttr(tag, "data-end")) {
53155
- tag = setAttr(tag, "data-end", String(start + duration));
53156
- }
53157
- return tag;
53158
- });
53159
- }
53160
- return html;
53157
+ return applyDurationsById(html, clamps, (tag, duration) => {
53158
+ if (hasAttr(tag, "data-duration")) tag = setAttr(tag, "data-duration", String(duration));
53159
+ const start = parseNumeric(getAttr(tag, "data-start"));
53160
+ if (start != null && hasAttr(tag, "data-end")) {
53161
+ tag = setAttr(tag, "data-end", String(start + duration));
53162
+ }
53163
+ return tag;
53164
+ });
53161
53165
  }
53162
53166
 
53163
53167
  // ../core/src/compiler/htmlCompiler.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/inspector",
3
- "version": "0.9.82",
3
+ "version": "0.9.83",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -43,8 +43,8 @@
43
43
  "htmlparser2": "^10.1.0",
44
44
  "postcss": "^8.5.8",
45
45
  "puppeteer-core": "^25.8.0",
46
- "@hyperframes/core": "0.9.82",
47
- "@hyperframes/parsers": "0.9.82"
46
+ "@hyperframes/core": "0.9.83",
47
+ "@hyperframes/parsers": "0.9.83"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/node": "^25.0.10",