@hyperframes/parsers 0.8.201 → 0.8.203

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 CHANGED
@@ -130,6 +130,23 @@ declare function checkOutputResolutionCompatibility(input: {
130
130
  alphaRequested?: boolean;
131
131
  hdrRequested?: boolean;
132
132
  }): OutputResolutionCompatibility;
133
+ type OutputSizeResolution = {
134
+ ok: true;
135
+ outputResolution: CanvasResolution | undefined;
136
+ } | {
137
+ ok: false;
138
+ message: string;
139
+ };
140
+ /**
141
+ * The preset a requested pixel size stands for on a composition: none when it is the composition's own size,
142
+ * else the preset of exactly that size when it is a whole-number multiple (3840×2160 on 1920×1080 is scale 2).
143
+ */
144
+ declare function outputResolutionForSize(input: {
145
+ compositionWidth: number;
146
+ compositionHeight: number;
147
+ width: number;
148
+ height: number;
149
+ }): OutputSizeResolution;
133
150
 
134
151
  /** Rewrite top-level helper calls and loops into literal tweens; unchanged when nothing can be unrolled. */
135
152
  declare function unrollComputedTimeline(script: string): string;
@@ -168,4 +185,4 @@ interface TimingMismatchReport {
168
185
  */
169
186
  declare function timingMismatches(html: string): TimingMismatchReport;
170
187
 
171
- export { CanvasResolution, CompositionHtmlParseError, type CompositionMetadata, CompositionVariable, Keyframe, type OutputResolutionCompatibility, type OutputResolutionIssueKind, type ParsedHtml, StageZoomKeyframe, TimelineElement, type TimingFinding, type TimingMismatchReport, type UnresolvedTiming, ValidationResult, addElementToHtml, checkOutputResolutionCompatibility, extractCompositionMetadata, parseHtml, queryByAttr, removeElementFromHtml, removeElementWithGsapCascade, suggestMatchingPreset, timingMismatches, unrollComputedTimeline, updateElementInHtml, validateCompositionHtml };
188
+ export { CanvasResolution, CompositionHtmlParseError, type CompositionMetadata, CompositionVariable, Keyframe, type OutputResolutionCompatibility, type OutputResolutionIssueKind, type OutputSizeResolution, type ParsedHtml, StageZoomKeyframe, TimelineElement, type TimingFinding, type TimingMismatchReport, type UnresolvedTiming, ValidationResult, addElementToHtml, checkOutputResolutionCompatibility, extractCompositionMetadata, outputResolutionForSize, parseHtml, queryByAttr, removeElementFromHtml, removeElementWithGsapCascade, suggestMatchingPreset, timingMismatches, unrollComputedTimeline, updateElementInHtml, validateCompositionHtml };
package/dist/index.js CHANGED
@@ -3738,6 +3738,34 @@ function checkOutputResolutionCompatibility(input) {
3738
3738
  }
3739
3739
  return OK;
3740
3740
  }
3741
+ function outputResolutionForSize(input) {
3742
+ const { compositionWidth, compositionHeight, width, height } = input;
3743
+ if (width === compositionWidth && height === compositionHeight) {
3744
+ return { ok: true, outputResolution: void 0 };
3745
+ }
3746
+ const composition = `${compositionWidth}\xD7${compositionHeight}`;
3747
+ const scale = width / compositionWidth;
3748
+ if (width < compositionWidth || height < compositionHeight) {
3749
+ return {
3750
+ ok: false,
3751
+ message: `${width}\xD7${height} is smaller than the composition (${composition}). Use the composition's size, or a whole-number multiple of it.`
3752
+ };
3753
+ }
3754
+ const preset = VALID_CANVAS_RESOLUTIONS.find(
3755
+ (name) => CANVAS_DIMENSIONS[name].width === width && CANVAS_DIMENSIONS[name].height === height
3756
+ );
3757
+ if (!Number.isInteger(scale) || height !== compositionHeight * scale || !preset || !checkOutputResolutionCompatibility({
3758
+ compositionWidth,
3759
+ compositionHeight,
3760
+ outputResolution: preset
3761
+ }).ok) {
3762
+ return {
3763
+ ok: false,
3764
+ message: `${width}\xD7${height} is not a whole-number multiple of the composition (${composition}) at a supported size. Use ${composition}, or a multiple such as ${compositionWidth * 2}\xD7${compositionHeight * 2} when that is a preset size (${VALID_CANVAS_RESOLUTIONS.map((name) => `${CANVAS_DIMENSIONS[name].width}\xD7${CANVAS_DIMENSIONS[name].height}`).join(", ")}).`
3765
+ };
3766
+ }
3767
+ return { ok: true, outputResolution: preset };
3768
+ }
3741
3769
 
3742
3770
  // src/gsapUnroll.ts
3743
3771
  import * as acorn2 from "acorn";
@@ -4643,6 +4671,7 @@ export {
4643
4671
  keyframesToGsapAnimations,
4644
4672
  mintHfId,
4645
4673
  normalizeResolutionFlag,
4674
+ outputResolutionForSize,
4646
4675
  parseCompositionVariables,
4647
4676
  parseGsapScriptAcorn as parseGsapScript,
4648
4677
  parseHtml,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/parsers",
3
- "version": "0.8.201",
3
+ "version": "0.8.203",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -135,7 +135,7 @@
135
135
  "tsx": "^4.21.0",
136
136
  "typescript": "^5.0.0",
137
137
  "vitest": "^4.1.11",
138
- "@hyperframes/core": "0.8.201"
138
+ "@hyperframes/core": "0.8.203"
139
139
  },
140
140
  "scripts": {
141
141
  "build": "tsup",