@hyperframes/parsers 0.8.27 → 0.8.29
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.d.ts +5 -3
- package/dist/index.js +34 -31
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ declare function addElementToHtml(html: string, element: Omit<TimelineElement, "
|
|
|
38
38
|
html: string;
|
|
39
39
|
id: string;
|
|
40
40
|
};
|
|
41
|
+
/** Remove a source subtree and its unambiguous, directly targeted GSAP tweens. */
|
|
42
|
+
declare function removeElementWithGsapCascade(doc: Document, element: Element): void;
|
|
41
43
|
declare function removeElementFromHtml(html: string, elementId: string): string;
|
|
42
44
|
interface CompositionMetadata {
|
|
43
45
|
compositionId: string | null;
|
|
@@ -73,7 +75,7 @@ declare function validateCompositionHtml(html: string): ValidationResult;
|
|
|
73
75
|
* `core`. The geometry it needs (`CANVAS_DIMENSIONS`) already lives here.
|
|
74
76
|
*/
|
|
75
77
|
|
|
76
|
-
type OutputResolutionIssueKind = "hdr-incompatible" | "
|
|
78
|
+
type OutputResolutionIssueKind = "hdr-incompatible" | "aspect-mismatch" | "downsampling" | "non-integer-scale";
|
|
77
79
|
interface OutputResolutionCompatibility {
|
|
78
80
|
ok: boolean;
|
|
79
81
|
/** Present when `ok` is false. */
|
|
@@ -107,7 +109,7 @@ interface OutputResolutionCompatibility {
|
|
|
107
109
|
declare function suggestMatchingPreset(compositionWidth: number, compositionHeight: number, chosen: CanvasResolution): CanvasResolution | undefined;
|
|
108
110
|
/**
|
|
109
111
|
* Check whether rendering a composition of the given dimensions with the given
|
|
110
|
-
* `outputResolution` preset (and
|
|
112
|
+
* `outputResolution` preset (and HDR mode) is supported.
|
|
111
113
|
*
|
|
112
114
|
* Pure and dependency-free — the single source of truth for the constraints
|
|
113
115
|
* `resolveDeviceScaleFactor` enforces, so the CLI can run the exact same check
|
|
@@ -133,4 +135,4 @@ declare function unrollComputedTimeline(script: string): string;
|
|
|
133
135
|
|
|
134
136
|
declare function queryByAttr(root: ParentNode, attr: string, value: string, tag?: string): Element | null;
|
|
135
137
|
|
|
136
|
-
export { CanvasResolution, CompositionHtmlParseError, type CompositionMetadata, CompositionVariable, Keyframe, type OutputResolutionCompatibility, type OutputResolutionIssueKind, type ParsedHtml, StageZoomKeyframe, TimelineElement, ValidationResult, addElementToHtml, checkOutputResolutionCompatibility, extractCompositionMetadata, parseHtml, queryByAttr, removeElementFromHtml, suggestMatchingPreset, unrollComputedTimeline, updateElementInHtml, validateCompositionHtml };
|
|
138
|
+
export { CanvasResolution, CompositionHtmlParseError, type CompositionMetadata, CompositionVariable, Keyframe, type OutputResolutionCompatibility, type OutputResolutionIssueKind, type ParsedHtml, StageZoomKeyframe, TimelineElement, ValidationResult, addElementToHtml, checkOutputResolutionCompatibility, extractCompositionMetadata, parseHtml, queryByAttr, removeElementFromHtml, removeElementWithGsapCascade, suggestMatchingPreset, unrollComputedTimeline, updateElementInHtml, validateCompositionHtml };
|
package/dist/index.js
CHANGED
|
@@ -3179,29 +3179,38 @@ function addElementToHtml(html, element) {
|
|
|
3179
3179
|
id
|
|
3180
3180
|
};
|
|
3181
3181
|
}
|
|
3182
|
-
function
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
}
|
|
3199
|
-
|
|
3182
|
+
function elementSelectors(element) {
|
|
3183
|
+
const selectors = [];
|
|
3184
|
+
const id = element.getAttribute("id");
|
|
3185
|
+
const hfId = element.getAttribute("data-hf-id");
|
|
3186
|
+
if (id) selectors.push(`#${id}`);
|
|
3187
|
+
if (hfId) selectors.push(`[data-hf-id="${hfId}"]`, `[data-hf-id='${hfId}']`);
|
|
3188
|
+
return selectors;
|
|
3189
|
+
}
|
|
3190
|
+
function removeElementWithGsapCascade(doc, element) {
|
|
3191
|
+
const removedSelectors = new Set(elementSelectors(element));
|
|
3192
|
+
walkCompositionDescendants(element, (child) => {
|
|
3193
|
+
for (const selector of elementSelectors(child)) removedSelectors.add(selector);
|
|
3194
|
+
});
|
|
3195
|
+
element.remove();
|
|
3196
|
+
walkCompositionDescendants(doc, (survivor) => {
|
|
3197
|
+
for (const selector of elementSelectors(survivor)) removedSelectors.delete(selector);
|
|
3198
|
+
});
|
|
3199
|
+
if (removedSelectors.size === 0) return;
|
|
3200
3200
|
for (const script of findScriptElementsDeep(doc)) {
|
|
3201
|
-
|
|
3202
|
-
if (!
|
|
3203
|
-
|
|
3204
|
-
|
|
3201
|
+
let current = script.textContent ?? "";
|
|
3202
|
+
if (!current.includes("gsap") && !current.includes("ScrollTrigger")) continue;
|
|
3203
|
+
for (; ; ) {
|
|
3204
|
+
const parsed = parseGsapScriptAcornForWrite(current);
|
|
3205
|
+
const match = parsed?.located.find(
|
|
3206
|
+
(located) => removedSelectors.has(located.animation.targetSelector)
|
|
3207
|
+
);
|
|
3208
|
+
if (!match) break;
|
|
3209
|
+
const updated = removeAnimationFromScript(current, match.id);
|
|
3210
|
+
if (updated === current) break;
|
|
3211
|
+
current = updated;
|
|
3212
|
+
}
|
|
3213
|
+
if (current !== script.textContent) script.textContent = current;
|
|
3205
3214
|
}
|
|
3206
3215
|
}
|
|
3207
3216
|
function removeElementFromHtml(html, elementId) {
|
|
@@ -3212,8 +3221,8 @@ function removeElementFromHtml(html, elementId) {
|
|
|
3212
3221
|
"removeElementFromHtml: input HTML is empty or could not be parsed"
|
|
3213
3222
|
);
|
|
3214
3223
|
}
|
|
3215
|
-
doc.getElementById(elementId)
|
|
3216
|
-
|
|
3224
|
+
const element = doc.getElementById(elementId);
|
|
3225
|
+
if (element) removeElementWithGsapCascade(doc, element);
|
|
3217
3226
|
return "<!DOCTYPE html>\n" + doc.documentElement.outerHTML;
|
|
3218
3227
|
}
|
|
3219
3228
|
function extractCompositionMetadata(html) {
|
|
@@ -3390,13 +3399,6 @@ function checkOutputResolutionCompatibility(input) {
|
|
|
3390
3399
|
message: `outputResolution cannot be combined with hdrMode='force-hdr'. HDR rendering composites at composition dimensions and does not yet support supersampling. Pick one or render in two passes.`
|
|
3391
3400
|
};
|
|
3392
3401
|
}
|
|
3393
|
-
if (input.alphaRequested) {
|
|
3394
|
-
return {
|
|
3395
|
-
ok: false,
|
|
3396
|
-
kind: "alpha-incompatible",
|
|
3397
|
-
message: `outputResolution cannot be combined with alpha output (--format webm|mov|png-sequence). The alpha screenshot path does not yet apply deviceScaleFactor and would silently produce composition-resolution frames. Render alpha at composition resolution and upscale separately, or use --format mp4.`
|
|
3398
|
-
};
|
|
3399
|
-
}
|
|
3400
3402
|
const target = CANVAS_DIMENSIONS[outputResolution];
|
|
3401
3403
|
if (target.width * compositionHeight !== target.height * compositionWidth) {
|
|
3402
3404
|
return buildAspectMismatch(compositionWidth, compositionHeight, outputResolution, target);
|
|
@@ -3785,6 +3787,7 @@ export {
|
|
|
3785
3787
|
queryByAttr,
|
|
3786
3788
|
readClipTiming,
|
|
3787
3789
|
removeElementFromHtml,
|
|
3790
|
+
removeElementWithGsapCascade,
|
|
3788
3791
|
resolveAliasDisplayName,
|
|
3789
3792
|
resolveResolutionFlagPair,
|
|
3790
3793
|
scanVariableUsage,
|