@hyperframes/parsers 0.9.55 → 0.9.56
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/composition.d.ts +1 -1
- package/dist/composition.js +98 -6
- package/dist/{fontAliases-o-I_DVRP.d.ts → fontAliases-6Aft6tHT.d.ts} +11 -11
- package/dist/hfIds.js +11 -18
- package/dist/index.d.ts +1 -1
- package/dist/index.js +109 -24
- package/package.json +2 -2
package/dist/composition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { A as AddElementData, a as Asset, B as BooleanVariable, C as CANVAS_DIMENSIONS, b as COMPOSITION_VARIABLE_TYPES, c as CanvasResolution, d as ColorVariable, e as CompositionAPI, f as CompositionAsset, g as CompositionSpec, h as CompositionVariable, i as CompositionVariableBase, j as CompositionVariableType, D as DEFAULT_DURATIONS, E as ElementKeyframes, k as EnumVariable, F as FontValue, l as FontVariable, I as ImageValue, m as ImageVariable, K as Keyframe, n as KeyframeProperties, M as MediaElementType, o as MediaFile, N as NumberVariable, P as PlayerAPI, R as ResolvedResolutionFlag, S as StageZoom, p as StageZoomKeyframe, q as StringVariable, T as TIMELINE_COLORS, r as TimelineCompositionElement, s as TimelineElement, t as TimelineElementBase, u as TimelineElementType, v as TimelineMediaElement, w as TimelineTextElement, V as VALID_CANVAS_RESOLUTIONS, x as ValidationResult, W as WaveformData, y as getDefaultStageZoom, z as isAspectAgnosticResolutionAlias, G as isCompositionElement, H as isMediaElement, J as isTextElement, L as normalizeResolutionFlag, O as resolveResolutionFlagPair } from './types-C1bWHQbs.js';
|
|
2
|
-
export { C as CANONICAL_FONT_DISPLAY_NAMES,
|
|
2
|
+
export { C as CANONICAL_FONT_DISPLAY_NAMES, a as CanvasScaffoldMatch, F as FONT_ALIAS_KEYS, b as FONT_ALIAS_MAP, M as MediaSrcMutation, R as ReadCompositionVariables, V as VariableUsageScan, e as extractMediaSrcMutations, i as isCompositionVariable, c as isFontValue, d as isImageValue, f as isSafeMediaUrl, g as isScalarVariableValue, m as matchHtmlBodyCssHeightFirst, h as matchHtmlBodyCssWidthFirst, j as matchViewportMetaSize, p as parseCompositionVariables, r as readCompositionVariables, k as replaceCanvasScaffoldSize, l as resolveAliasDisplayName, s as scanVariableUsage } from './fontAliases-6Aft6tHT.js';
|
|
3
3
|
export { d as decodeUrlPathVariants } from './urlPath-CYK47t9W.js';
|
|
4
4
|
export { CANONICAL_AUTHORED_TIMING_ATTRIBUTES, COMPOSITION_ATTRIBUTES, COMPOSITION_CONTRACT_VERSION, ClipAttributeReader, ClipAttributeWriter, ClipTiming, ClipTimingDiagnostic, ClipTimingDiagnosticCode, ClipTimingUpdate, ClipTimingWriteError, DERIVED_TIMING_ATTRIBUTES, LEGACY_TIMING_ATTRIBUTES, ReadClipTimingOptions, ReferenceExpression, SPLIT_BOUNDARY_EPSILON_S, parseNumeric, parseStartExpression, readClipTiming, writeClipTiming } from './compositionContract.js';
|
|
5
5
|
|
package/dist/composition.js
CHANGED
|
@@ -751,9 +751,100 @@ function writeClipTiming(attributes, update) {
|
|
|
751
751
|
}
|
|
752
752
|
|
|
753
753
|
// src/canvasScaffoldPatterns.ts
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
754
|
+
function capture(source, start, firstStart, firstEnd, secondStart, secondEnd) {
|
|
755
|
+
const match = [
|
|
756
|
+
source.slice(start, secondEnd),
|
|
757
|
+
source.slice(start, firstStart),
|
|
758
|
+
source.slice(firstStart, firstEnd),
|
|
759
|
+
source.slice(firstEnd, secondStart),
|
|
760
|
+
source.slice(secondStart, secondEnd)
|
|
761
|
+
];
|
|
762
|
+
return Object.assign(match, { index: start });
|
|
763
|
+
}
|
|
764
|
+
function findDimensionPair(source, first) {
|
|
765
|
+
const dimensions = /(width|height):\s*(\d+)px/gi;
|
|
766
|
+
let firstValue;
|
|
767
|
+
let token;
|
|
768
|
+
while (token = dimensions.exec(source)) {
|
|
769
|
+
if (!token[2]) continue;
|
|
770
|
+
const start = token.index + token[0].length - token[2].length - 2;
|
|
771
|
+
const end = start + token[2].length;
|
|
772
|
+
if (token[1]?.toLowerCase() === first) {
|
|
773
|
+
firstValue ??= { start, end };
|
|
774
|
+
} else if (firstValue) {
|
|
775
|
+
return [firstValue.start, firstValue.end, start, end];
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
function matchBody(source, first) {
|
|
781
|
+
let start = 0;
|
|
782
|
+
while (start < source.length) {
|
|
783
|
+
const close = source.indexOf("}", start);
|
|
784
|
+
const end = close < 0 ? source.length : close;
|
|
785
|
+
const region = source.slice(start, end);
|
|
786
|
+
const header = /html\s*,\s*body\s*\{/i.exec(region);
|
|
787
|
+
if (header) {
|
|
788
|
+
const contentStart = start + header.index + header[0].length;
|
|
789
|
+
const pair = findDimensionPair(source.slice(contentStart, end), first);
|
|
790
|
+
if (pair) {
|
|
791
|
+
return capture(
|
|
792
|
+
source,
|
|
793
|
+
start + header.index,
|
|
794
|
+
contentStart + pair[0],
|
|
795
|
+
contentStart + pair[1],
|
|
796
|
+
contentStart + pair[2],
|
|
797
|
+
contentStart + pair[3]
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
start = end + 1;
|
|
802
|
+
}
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
function matchHtmlBodyCssWidthFirst(source) {
|
|
806
|
+
return matchBody(source, "width");
|
|
807
|
+
}
|
|
808
|
+
function matchHtmlBodyCssHeightFirst(source) {
|
|
809
|
+
return matchBody(source, "height");
|
|
810
|
+
}
|
|
811
|
+
function matchViewportMetaSize(source) {
|
|
812
|
+
let start = 0;
|
|
813
|
+
while (start < source.length) {
|
|
814
|
+
const close = source.indexOf(">", start);
|
|
815
|
+
const end = close < 0 ? source.length : close;
|
|
816
|
+
const region = source.slice(start, end);
|
|
817
|
+
const meta = region.search(/<meta/i);
|
|
818
|
+
if (meta >= 0) {
|
|
819
|
+
const names = /name=["']viewport["']/gi;
|
|
820
|
+
names.lastIndex = meta + 5;
|
|
821
|
+
const name = names.exec(region);
|
|
822
|
+
if (name) {
|
|
823
|
+
const content = /content=["']width=(\d+)(,\s*height=)(\d+)/gi;
|
|
824
|
+
content.lastIndex = name.index + name[0].length;
|
|
825
|
+
const size = content.exec(region);
|
|
826
|
+
if (size && size[1] && size[2] && size[3]) {
|
|
827
|
+
const firstStart = start + size.index + 15;
|
|
828
|
+
const firstEnd = firstStart + size[1].length;
|
|
829
|
+
const secondStart = firstEnd + size[2].length;
|
|
830
|
+
return capture(
|
|
831
|
+
source,
|
|
832
|
+
start + meta,
|
|
833
|
+
firstStart,
|
|
834
|
+
firstEnd,
|
|
835
|
+
secondStart,
|
|
836
|
+
secondStart + size[3].length
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
start = end + 1;
|
|
842
|
+
}
|
|
843
|
+
return null;
|
|
844
|
+
}
|
|
845
|
+
function replaceCanvasScaffoldSize(source, match, first, second) {
|
|
846
|
+
return source.slice(0, match.index) + match[1] + first + match[3] + second + source.slice(match.index + match[0].length);
|
|
847
|
+
}
|
|
757
848
|
|
|
758
849
|
// src/mediaSrcMutation.ts
|
|
759
850
|
import * as acorn2 from "acorn";
|
|
@@ -950,13 +1041,10 @@ export {
|
|
|
950
1041
|
DERIVED_TIMING_ATTRIBUTES,
|
|
951
1042
|
FONT_ALIAS_KEYS,
|
|
952
1043
|
FONT_ALIAS_MAP,
|
|
953
|
-
HTML_BODY_CSS_HEIGHT_FIRST_RE,
|
|
954
|
-
HTML_BODY_CSS_WIDTH_FIRST_RE,
|
|
955
1044
|
LEGACY_TIMING_ATTRIBUTES,
|
|
956
1045
|
SPLIT_BOUNDARY_EPSILON_S,
|
|
957
1046
|
TIMELINE_COLORS,
|
|
958
1047
|
VALID_CANVAS_RESOLUTIONS,
|
|
959
|
-
VIEWPORT_META_SIZE_RE,
|
|
960
1048
|
decodeUrlPathVariants,
|
|
961
1049
|
extractMediaSrcMutations,
|
|
962
1050
|
fontShorthandFamilies,
|
|
@@ -970,6 +1058,9 @@ export {
|
|
|
970
1058
|
isSafeMediaUrl,
|
|
971
1059
|
isScalarVariableValue,
|
|
972
1060
|
isTextElement,
|
|
1061
|
+
matchHtmlBodyCssHeightFirst,
|
|
1062
|
+
matchHtmlBodyCssWidthFirst,
|
|
1063
|
+
matchViewportMetaSize,
|
|
973
1064
|
normalizeResolutionFlag,
|
|
974
1065
|
parseCompositionVariables,
|
|
975
1066
|
parseFontShorthand,
|
|
@@ -977,6 +1068,7 @@ export {
|
|
|
977
1068
|
parseStartExpression,
|
|
978
1069
|
readClipTiming,
|
|
979
1070
|
readCompositionVariables,
|
|
1071
|
+
replaceCanvasScaffoldSize,
|
|
980
1072
|
resolveAliasDisplayName,
|
|
981
1073
|
resolveResolutionFlagPair,
|
|
982
1074
|
scanVariableUsage,
|
|
@@ -51,16 +51,16 @@ declare function parseCompositionVariables(htmlEl: Element): CompositionVariable
|
|
|
51
51
|
*/
|
|
52
52
|
declare function isSafeMediaUrl(url: string): boolean;
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
declare
|
|
60
|
-
/**
|
|
61
|
-
declare
|
|
62
|
-
/**
|
|
63
|
-
declare
|
|
54
|
+
/** Linear-time readers for the canvas dimensions in scaffold CSS and metadata. */
|
|
55
|
+
type CanvasScaffoldMatch = [string, string, string, string, string] & {
|
|
56
|
+
index: number;
|
|
57
|
+
};
|
|
58
|
+
declare function matchHtmlBodyCssWidthFirst(source: string): CanvasScaffoldMatch | null;
|
|
59
|
+
declare function matchHtmlBodyCssHeightFirst(source: string): CanvasScaffoldMatch | null;
|
|
60
|
+
/** Scan each tag-sized region once, including malformed unterminated tags. */
|
|
61
|
+
declare function matchViewportMetaSize(source: string): CanvasScaffoldMatch | null;
|
|
62
|
+
/** Replace only the captured digits; preserve whitespace, units and surrounding text. */
|
|
63
|
+
declare function replaceCanvasScaffoldSize(source: string, match: CanvasScaffoldMatch, first: number, second: number): string;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Browser-safe static scan for composition-variable reads in script text.
|
|
@@ -188,4 +188,4 @@ declare const CANONICAL_FONT_DISPLAY_NAMES: Readonly<Record<string, string>>;
|
|
|
188
188
|
*/
|
|
189
189
|
declare function resolveAliasDisplayName(alias: string): string | undefined;
|
|
190
190
|
|
|
191
|
-
export { CANONICAL_FONT_DISPLAY_NAMES as C, FONT_ALIAS_KEYS as F,
|
|
191
|
+
export { CANONICAL_FONT_DISPLAY_NAMES as C, FONT_ALIAS_KEYS as F, type MediaSrcMutation as M, type ReadCompositionVariables as R, type VariableUsageScan as V, type CanvasScaffoldMatch as a, FONT_ALIAS_MAP as b, isFontValue as c, isImageValue as d, extractMediaSrcMutations as e, isSafeMediaUrl as f, isScalarVariableValue as g, matchHtmlBodyCssWidthFirst as h, isCompositionVariable as i, matchViewportMetaSize as j, replaceCanvasScaffoldSize as k, resolveAliasDisplayName as l, matchHtmlBodyCssHeightFirst as m, parseCompositionVariables as p, readCompositionVariables as r, scanVariableUsage as s };
|
package/dist/hfIds.js
CHANGED
|
@@ -24,6 +24,7 @@ function toHfId(hash) {
|
|
|
24
24
|
const four = s.length >= 4 ? s.slice(-4) : s.padStart(4, "0");
|
|
25
25
|
return `hf-${four}`;
|
|
26
26
|
}
|
|
27
|
+
var lastDup = /* @__PURE__ */ new WeakMap();
|
|
27
28
|
function ownText(el) {
|
|
28
29
|
let text = "";
|
|
29
30
|
el.childNodes.forEach((n) => {
|
|
@@ -40,9 +41,11 @@ function contentKey(el) {
|
|
|
40
41
|
}
|
|
41
42
|
function mintHfId(el, assigned) {
|
|
42
43
|
const key = contentKey(el);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const twins = lastDup.get(assigned) ?? /* @__PURE__ */ new Map();
|
|
45
|
+
lastDup.set(assigned, twins);
|
|
46
|
+
let dup = twins.get(key) ?? 0;
|
|
47
|
+
let id = dup > 1e4 ? `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}` : toHfId(fnv1a(dup ? `${key}#${dup}` : key));
|
|
48
|
+
while (dup <= 1e4 && assigned.has(id)) {
|
|
46
49
|
dup += 1;
|
|
47
50
|
if (dup > 1e4) {
|
|
48
51
|
id = `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}`;
|
|
@@ -50,6 +53,7 @@ function mintHfId(el, assigned) {
|
|
|
50
53
|
}
|
|
51
54
|
id = toHfId(fnv1a(`${key}#${dup}`));
|
|
52
55
|
}
|
|
56
|
+
twins.set(key, dup);
|
|
53
57
|
assigned.add(id);
|
|
54
58
|
return id;
|
|
55
59
|
}
|
|
@@ -236,21 +240,10 @@ function emptyHfIdValue(html, tag) {
|
|
|
236
240
|
return tag.nameEnd + match.index + match[0].length - 1;
|
|
237
241
|
}
|
|
238
242
|
function outsideQuotes(open) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
quote = quoteOf(quote, c);
|
|
244
|
-
}
|
|
245
|
-
return out;
|
|
246
|
-
}
|
|
247
|
-
function quoteOf(quote, c) {
|
|
248
|
-
if (quote) return c === quote ? "" : quote;
|
|
249
|
-
return c === '"' || c === "'" ? c : "";
|
|
250
|
-
}
|
|
251
|
-
function quotedChar(quote, c) {
|
|
252
|
-
if (!quote || c === quote) return c;
|
|
253
|
-
return " ".repeat(c.length);
|
|
243
|
+
return open.replace(/"[^"]*"?|'[^']*'?/g, (quoted) => {
|
|
244
|
+
const closed = quoted.length > 1 && quoted.endsWith(quoted.charAt(0));
|
|
245
|
+
return quoted.charAt(0) + " ".repeat(quoted.length - (closed ? 2 : 1)) + (closed ? quoted.charAt(0) : "");
|
|
246
|
+
});
|
|
254
247
|
}
|
|
255
248
|
function spliceIds(html, inserts) {
|
|
256
249
|
let out = "";
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { parseGsapScriptAcorn as parseGsapScript } from './gsapParserAcorn.js';
|
|
|
8
8
|
export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, mintHfId, stampHfIdsInPlace, walkCompositionDescendants } from './hfIds.js';
|
|
9
9
|
export { ParsableDocumentLike, SceneTemplateLike, SubCompositionValidity, SubCompositionValidityReason, checkSubCompositionUsability, findSceneTemplate, resolveSubCompositionContent } from './subCompositionValidity.js';
|
|
10
10
|
export { CANONICAL_AUTHORED_TIMING_ATTRIBUTES, COMPOSITION_ATTRIBUTES, COMPOSITION_CONTRACT_VERSION, ClipAttributeReader, ClipAttributeWriter, ClipTiming, ClipTimingDiagnostic, ClipTimingDiagnosticCode, ClipTimingUpdate, ClipTimingWriteError, DERIVED_TIMING_ATTRIBUTES, LEGACY_TIMING_ATTRIBUTES, ReadClipTimingOptions, ReferenceExpression, SPLIT_BOUNDARY_EPSILON_S, parseNumeric, parseStartExpression, readClipTiming, writeClipTiming } from './compositionContract.js';
|
|
11
|
-
export { C as CANONICAL_FONT_DISPLAY_NAMES, F as FONT_ALIAS_KEYS,
|
|
11
|
+
export { C as CANONICAL_FONT_DISPLAY_NAMES, a as CanvasScaffoldMatch, F as FONT_ALIAS_KEYS, b as FONT_ALIAS_MAP, M as MediaSrcMutation, V as VariableUsageScan, e as extractMediaSrcMutations, m as matchHtmlBodyCssHeightFirst, h as matchHtmlBodyCssWidthFirst, j as matchViewportMetaSize, p as parseCompositionVariables, k as replaceCanvasScaffoldSize, l as resolveAliasDisplayName, s as scanVariableUsage } from './fontAliases-6Aft6tHT.js';
|
|
12
12
|
export { StructureNode, TrackKind, TrackKindSource, isSubCompositionHost, isTimedElement, topLevelElements, trackKindOf } from './topLevelElements.js';
|
|
13
13
|
export { AttrReader, DEFAULT_IMAGE_TIMELINE_DURATION_SECONDS, MAX_PLAYBACK_RATE, MIN_PLAYBACK_RATE, MediaDurationResult, MediaDurationSource, MediaTag, PENDING_MEDIA_DURATION_READERS, ResolveMediaDurationInput, clampPlaybackRate, readAuthoredDurationSeconds, readDataDurationSeconds, readMediaOffsetSeconds, readPlaybackRate, resolveMediaDuration, resolveNaturalDurationSeconds } from './mediaDuration.js';
|
|
14
14
|
export { CompositionDurationResult, CompositionDurationSource, ResolveCompositionDurationInput, TIMING_TOLERANCE_SECONDS, resolveCompositionDuration } from './compositionDuration.js';
|
package/dist/index.js
CHANGED
|
@@ -2459,6 +2459,7 @@ function toHfId(hash) {
|
|
|
2459
2459
|
const four = s.length >= 4 ? s.slice(-4) : s.padStart(4, "0");
|
|
2460
2460
|
return `hf-${four}`;
|
|
2461
2461
|
}
|
|
2462
|
+
var lastDup = /* @__PURE__ */ new WeakMap();
|
|
2462
2463
|
function ownText(el) {
|
|
2463
2464
|
let text = "";
|
|
2464
2465
|
el.childNodes.forEach((n) => {
|
|
@@ -2475,9 +2476,11 @@ function contentKey(el) {
|
|
|
2475
2476
|
}
|
|
2476
2477
|
function mintHfId(el, assigned) {
|
|
2477
2478
|
const key = contentKey(el);
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2479
|
+
const twins = lastDup.get(assigned) ?? /* @__PURE__ */ new Map();
|
|
2480
|
+
lastDup.set(assigned, twins);
|
|
2481
|
+
let dup = twins.get(key) ?? 0;
|
|
2482
|
+
let id = dup > 1e4 ? `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}` : toHfId(fnv1a(dup ? `${key}#${dup}` : key));
|
|
2483
|
+
while (dup <= 1e4 && assigned.has(id)) {
|
|
2481
2484
|
dup += 1;
|
|
2482
2485
|
if (dup > 1e4) {
|
|
2483
2486
|
id = `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}`;
|
|
@@ -2485,6 +2488,7 @@ function mintHfId(el, assigned) {
|
|
|
2485
2488
|
}
|
|
2486
2489
|
id = toHfId(fnv1a(`${key}#${dup}`));
|
|
2487
2490
|
}
|
|
2491
|
+
twins.set(key, dup);
|
|
2488
2492
|
assigned.add(id);
|
|
2489
2493
|
return id;
|
|
2490
2494
|
}
|
|
@@ -2671,21 +2675,10 @@ function emptyHfIdValue(html, tag) {
|
|
|
2671
2675
|
return tag.nameEnd + match.index + match[0].length - 1;
|
|
2672
2676
|
}
|
|
2673
2677
|
function outsideQuotes(open) {
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
quote = quoteOf(quote, c);
|
|
2679
|
-
}
|
|
2680
|
-
return out;
|
|
2681
|
-
}
|
|
2682
|
-
function quoteOf(quote, c) {
|
|
2683
|
-
if (quote) return c === quote ? "" : quote;
|
|
2684
|
-
return c === '"' || c === "'" ? c : "";
|
|
2685
|
-
}
|
|
2686
|
-
function quotedChar(quote, c) {
|
|
2687
|
-
if (!quote || c === quote) return c;
|
|
2688
|
-
return " ".repeat(c.length);
|
|
2678
|
+
return open.replace(/"[^"]*"?|'[^']*'?/g, (quoted) => {
|
|
2679
|
+
const closed = quoted.length > 1 && quoted.endsWith(quoted.charAt(0));
|
|
2680
|
+
return quoted.charAt(0) + " ".repeat(quoted.length - (closed ? 2 : 1)) + (closed ? quoted.charAt(0) : "");
|
|
2681
|
+
});
|
|
2689
2682
|
}
|
|
2690
2683
|
function spliceIds(html, inserts) {
|
|
2691
2684
|
let out = "";
|
|
@@ -4065,9 +4058,100 @@ function unrollComputedTimeline(script) {
|
|
|
4065
4058
|
}
|
|
4066
4059
|
|
|
4067
4060
|
// src/canvasScaffoldPatterns.ts
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4061
|
+
function capture(source, start, firstStart, firstEnd, secondStart, secondEnd) {
|
|
4062
|
+
const match = [
|
|
4063
|
+
source.slice(start, secondEnd),
|
|
4064
|
+
source.slice(start, firstStart),
|
|
4065
|
+
source.slice(firstStart, firstEnd),
|
|
4066
|
+
source.slice(firstEnd, secondStart),
|
|
4067
|
+
source.slice(secondStart, secondEnd)
|
|
4068
|
+
];
|
|
4069
|
+
return Object.assign(match, { index: start });
|
|
4070
|
+
}
|
|
4071
|
+
function findDimensionPair(source, first) {
|
|
4072
|
+
const dimensions = /(width|height):\s*(\d+)px/gi;
|
|
4073
|
+
let firstValue;
|
|
4074
|
+
let token;
|
|
4075
|
+
while (token = dimensions.exec(source)) {
|
|
4076
|
+
if (!token[2]) continue;
|
|
4077
|
+
const start = token.index + token[0].length - token[2].length - 2;
|
|
4078
|
+
const end = start + token[2].length;
|
|
4079
|
+
if (token[1]?.toLowerCase() === first) {
|
|
4080
|
+
firstValue ??= { start, end };
|
|
4081
|
+
} else if (firstValue) {
|
|
4082
|
+
return [firstValue.start, firstValue.end, start, end];
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
return null;
|
|
4086
|
+
}
|
|
4087
|
+
function matchBody(source, first) {
|
|
4088
|
+
let start = 0;
|
|
4089
|
+
while (start < source.length) {
|
|
4090
|
+
const close = source.indexOf("}", start);
|
|
4091
|
+
const end = close < 0 ? source.length : close;
|
|
4092
|
+
const region = source.slice(start, end);
|
|
4093
|
+
const header = /html\s*,\s*body\s*\{/i.exec(region);
|
|
4094
|
+
if (header) {
|
|
4095
|
+
const contentStart = start + header.index + header[0].length;
|
|
4096
|
+
const pair = findDimensionPair(source.slice(contentStart, end), first);
|
|
4097
|
+
if (pair) {
|
|
4098
|
+
return capture(
|
|
4099
|
+
source,
|
|
4100
|
+
start + header.index,
|
|
4101
|
+
contentStart + pair[0],
|
|
4102
|
+
contentStart + pair[1],
|
|
4103
|
+
contentStart + pair[2],
|
|
4104
|
+
contentStart + pair[3]
|
|
4105
|
+
);
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
start = end + 1;
|
|
4109
|
+
}
|
|
4110
|
+
return null;
|
|
4111
|
+
}
|
|
4112
|
+
function matchHtmlBodyCssWidthFirst(source) {
|
|
4113
|
+
return matchBody(source, "width");
|
|
4114
|
+
}
|
|
4115
|
+
function matchHtmlBodyCssHeightFirst(source) {
|
|
4116
|
+
return matchBody(source, "height");
|
|
4117
|
+
}
|
|
4118
|
+
function matchViewportMetaSize(source) {
|
|
4119
|
+
let start = 0;
|
|
4120
|
+
while (start < source.length) {
|
|
4121
|
+
const close = source.indexOf(">", start);
|
|
4122
|
+
const end = close < 0 ? source.length : close;
|
|
4123
|
+
const region = source.slice(start, end);
|
|
4124
|
+
const meta = region.search(/<meta/i);
|
|
4125
|
+
if (meta >= 0) {
|
|
4126
|
+
const names = /name=["']viewport["']/gi;
|
|
4127
|
+
names.lastIndex = meta + 5;
|
|
4128
|
+
const name = names.exec(region);
|
|
4129
|
+
if (name) {
|
|
4130
|
+
const content = /content=["']width=(\d+)(,\s*height=)(\d+)/gi;
|
|
4131
|
+
content.lastIndex = name.index + name[0].length;
|
|
4132
|
+
const size = content.exec(region);
|
|
4133
|
+
if (size && size[1] && size[2] && size[3]) {
|
|
4134
|
+
const firstStart = start + size.index + 15;
|
|
4135
|
+
const firstEnd = firstStart + size[1].length;
|
|
4136
|
+
const secondStart = firstEnd + size[2].length;
|
|
4137
|
+
return capture(
|
|
4138
|
+
source,
|
|
4139
|
+
start + meta,
|
|
4140
|
+
firstStart,
|
|
4141
|
+
firstEnd,
|
|
4142
|
+
secondStart,
|
|
4143
|
+
secondStart + size[3].length
|
|
4144
|
+
);
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
start = end + 1;
|
|
4149
|
+
}
|
|
4150
|
+
return null;
|
|
4151
|
+
}
|
|
4152
|
+
function replaceCanvasScaffoldSize(source, match, first, second) {
|
|
4153
|
+
return source.slice(0, match.index) + match[1] + first + match[3] + second + source.slice(match.index + match[0].length);
|
|
4154
|
+
}
|
|
4071
4155
|
|
|
4072
4156
|
// src/topLevelElements.ts
|
|
4073
4157
|
var NON_RENDERED_TAGS = /* @__PURE__ */ new Set(["script", "style", "template", "noscript", "link", "meta"]);
|
|
@@ -4835,8 +4919,6 @@ export {
|
|
|
4835
4919
|
FONT_ALIAS_MAP,
|
|
4836
4920
|
GSAP_DEFAULT_DURATION,
|
|
4837
4921
|
HTML_ATTRIBUTE_ENTITIES,
|
|
4838
|
-
HTML_BODY_CSS_HEIGHT_FIRST_RE,
|
|
4839
|
-
HTML_BODY_CSS_WIDTH_FIRST_RE,
|
|
4840
4922
|
LEGACY_TIMING_ATTRIBUTES,
|
|
4841
4923
|
MAX_PLAYBACK_RATE,
|
|
4842
4924
|
MIN_PLAYBACK_RATE,
|
|
@@ -4849,7 +4931,6 @@ export {
|
|
|
4849
4931
|
TIMELINE_COLORS,
|
|
4850
4932
|
TIMING_TOLERANCE_SECONDS,
|
|
4851
4933
|
VALID_CANVAS_RESOLUTIONS,
|
|
4852
|
-
VIEWPORT_META_SIZE_RE,
|
|
4853
4934
|
addElementToHtml,
|
|
4854
4935
|
checkOutputResolutionCompatibility,
|
|
4855
4936
|
checkSubCompositionUsability,
|
|
@@ -4879,6 +4960,9 @@ export {
|
|
|
4879
4960
|
isTextElement,
|
|
4880
4961
|
isTimedElement,
|
|
4881
4962
|
keyframesToGsapAnimations,
|
|
4963
|
+
matchHtmlBodyCssHeightFirst,
|
|
4964
|
+
matchHtmlBodyCssWidthFirst,
|
|
4965
|
+
matchViewportMetaSize,
|
|
4882
4966
|
mintHfId,
|
|
4883
4967
|
normalizeResolutionFlag,
|
|
4884
4968
|
outputResolutionForSize,
|
|
@@ -4895,6 +4979,7 @@ export {
|
|
|
4895
4979
|
readPlaybackRate,
|
|
4896
4980
|
removeElementFromHtml,
|
|
4897
4981
|
removeElementWithGsapCascade,
|
|
4982
|
+
replaceCanvasScaffoldSize,
|
|
4898
4983
|
resolveAliasDisplayName,
|
|
4899
4984
|
resolveCompositionDuration,
|
|
4900
4985
|
resolveMediaDuration,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.56",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"tsx": "^4.21.0",
|
|
144
144
|
"typescript": "^5.0.0",
|
|
145
145
|
"vitest": "^4.1.12",
|
|
146
|
-
"@hyperframes/core": "0.9.
|
|
146
|
+
"@hyperframes/core": "0.9.56"
|
|
147
147
|
},
|
|
148
148
|
"scripts": {
|
|
149
149
|
"build": "tsup",
|