@hyperframes/parsers 0.8.142 → 0.8.144
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/assetResolution.d.ts +2 -31
- package/dist/assetResolution.js +104 -19
- package/dist/assetResolution.js.map +1 -1
- package/dist/assets.d.ts +2 -0
- package/dist/assets.js +52 -15
- package/dist/assets.js.map +1 -1
- package/dist/composition.d.ts +2 -3
- package/dist/composition.js +11 -7
- package/dist/composition.js.map +1 -1
- package/dist/hfIds.js +3 -1
- package/dist/hfIds.js.map +1 -1
- package/dist/htmlAttributeSpans.d.ts +27 -0
- package/dist/htmlAttributeSpans.js +100 -0
- package/dist/htmlAttributeSpans.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +129 -8
- package/dist/index.js.map +1 -1
- package/dist/slideshow.js +14 -2
- package/dist/slideshow.js.map +1 -1
- package/dist/urlPath-C_0f_-Hp.d.ts +11 -0
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -2421,7 +2421,9 @@ function assignHfIds(body) {
|
|
|
2421
2421
|
|
|
2422
2422
|
// src/hfIds.ts
|
|
2423
2423
|
function ensureHfIds(html) {
|
|
2424
|
-
const wrapped =
|
|
2424
|
+
const wrapped = !/^(?:<!doctype|<html[\s>/])/i.test(
|
|
2425
|
+
html.replace(/^(?:\s|<!--(?:>|->|[\s\S]*?-->))*/, "")
|
|
2426
|
+
);
|
|
2425
2427
|
const { document } = wrapped ? parseHTML(`<!DOCTYPE html><html><head></head><body>${html}</body></html>`) : parseHTML(html);
|
|
2426
2428
|
if (!document.body) return html;
|
|
2427
2429
|
assignHfIds(document.body);
|
|
@@ -3960,13 +3962,32 @@ var PENDING_MEDIA_DURATION_READERS = [
|
|
|
3960
3962
|
|
|
3961
3963
|
// src/utils/urlPath.ts
|
|
3962
3964
|
function decodeUrlPathVariants(path) {
|
|
3963
|
-
const
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
}
|
|
3968
|
-
|
|
3969
|
-
|
|
3965
|
+
const decoded = decodeWellFormedEscapes(path);
|
|
3966
|
+
return decoded === path ? [path] : [decoded, path];
|
|
3967
|
+
}
|
|
3968
|
+
function decodeWellFormedEscapes(path) {
|
|
3969
|
+
return path.replace(/(?:%[0-9A-Fa-f]{2})+/g, (run) => {
|
|
3970
|
+
try {
|
|
3971
|
+
return decodeURIComponent(run);
|
|
3972
|
+
} catch {
|
|
3973
|
+
return run;
|
|
3974
|
+
}
|
|
3975
|
+
});
|
|
3976
|
+
}
|
|
3977
|
+
function splitUrlSuffix(urlValue) {
|
|
3978
|
+
const queryIdx = urlValue.indexOf("?");
|
|
3979
|
+
const hashIdx = urlValue.indexOf("#");
|
|
3980
|
+
if (queryIdx < 0 && hashIdx < 0) return { basePath: urlValue, suffix: "" };
|
|
3981
|
+
let cutIdx = urlValue.length;
|
|
3982
|
+
if (queryIdx >= 0) cutIdx = Math.min(cutIdx, queryIdx);
|
|
3983
|
+
if (hashIdx >= 0) cutIdx = Math.min(cutIdx, hashIdx);
|
|
3984
|
+
return { basePath: urlValue.slice(0, cutIdx), suffix: urlValue.slice(cutIdx) };
|
|
3985
|
+
}
|
|
3986
|
+
function decodedUrlPath(url) {
|
|
3987
|
+
return decodeWellFormedEscapes(splitUrlSuffix(url).basePath);
|
|
3988
|
+
}
|
|
3989
|
+
function encodeUrlPath(path) {
|
|
3990
|
+
return encodeURIComponent(path).replace(/%2F/g, "/").replace(/['()]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
3970
3991
|
}
|
|
3971
3992
|
|
|
3972
3993
|
// src/variableUsage.ts
|
|
@@ -4252,6 +4273,101 @@ function resolveAliasDisplayName(alias) {
|
|
|
4252
4273
|
if (!slug) return void 0;
|
|
4253
4274
|
return CANONICAL_FONT_DISPLAY_NAMES[slug];
|
|
4254
4275
|
}
|
|
4276
|
+
|
|
4277
|
+
// src/htmlAttributeSpans.ts
|
|
4278
|
+
import { decodeHTMLAttribute } from "entities/decode";
|
|
4279
|
+
function readAttributeValue(html, at) {
|
|
4280
|
+
while (/[\t\n\f\r ]/.test(html.charAt(at))) at++;
|
|
4281
|
+
const quote = ['"', "'"].includes(html.charAt(at)) ? html.charAt(at) : "";
|
|
4282
|
+
if (quote) at++;
|
|
4283
|
+
const valueStart = at;
|
|
4284
|
+
if (quote) {
|
|
4285
|
+
const closing = html.indexOf(quote, at);
|
|
4286
|
+
at = closing === -1 ? html.length : closing;
|
|
4287
|
+
} else {
|
|
4288
|
+
while (at < html.length && !/[\t\n\f\r >]/.test(html[at])) at++;
|
|
4289
|
+
}
|
|
4290
|
+
const valueEnd = at;
|
|
4291
|
+
const end = quote ? Math.min(valueEnd + 1, html.length) : valueEnd;
|
|
4292
|
+
return { value: html.slice(valueStart, valueEnd), valueStart, valueEnd, quote, end };
|
|
4293
|
+
}
|
|
4294
|
+
function readAttribute(html, start) {
|
|
4295
|
+
let at = start;
|
|
4296
|
+
while (at < html.length && !/[\t\n\f\r =/>]/.test(html[at])) at++;
|
|
4297
|
+
if (at === start) return null;
|
|
4298
|
+
const name = html.slice(start, at).toLowerCase();
|
|
4299
|
+
const nameEnd = at;
|
|
4300
|
+
while (/[\t\n\f\r ]/.test(html[at] ?? "")) at++;
|
|
4301
|
+
if (html[at] !== "=") return { kind: "boolean", name, start, end: nameEnd };
|
|
4302
|
+
return { kind: "value", name, start, ...readAttributeValue(html, at + 1) };
|
|
4303
|
+
}
|
|
4304
|
+
function readOpeningTag(html, start, name, at) {
|
|
4305
|
+
const attributes = [];
|
|
4306
|
+
while (at < html.length) {
|
|
4307
|
+
while (/[\t\n\f\r /]/.test(html[at] ?? "")) at++;
|
|
4308
|
+
if (at >= html.length || html[at] === ">") break;
|
|
4309
|
+
const attribute = readAttribute(html, at);
|
|
4310
|
+
if (attribute === null) {
|
|
4311
|
+
at++;
|
|
4312
|
+
continue;
|
|
4313
|
+
}
|
|
4314
|
+
attributes.push(attribute);
|
|
4315
|
+
at = attribute.end;
|
|
4316
|
+
}
|
|
4317
|
+
const closed = html[at] === ">";
|
|
4318
|
+
return {
|
|
4319
|
+
name: name.toLowerCase(),
|
|
4320
|
+
start,
|
|
4321
|
+
bodyEnd: at,
|
|
4322
|
+
end: closed ? at + 1 : at,
|
|
4323
|
+
closed,
|
|
4324
|
+
rawTextEnd: null,
|
|
4325
|
+
attributes
|
|
4326
|
+
};
|
|
4327
|
+
}
|
|
4328
|
+
function scanHtmlOpeningTags(html) {
|
|
4329
|
+
const tags = [];
|
|
4330
|
+
const opening = /<!--[\s\S]*?(?:--!?>|$)|<([a-z][^\t\n\f\r />]*)/gi;
|
|
4331
|
+
let match;
|
|
4332
|
+
while ((match = opening.exec(html)) !== null) {
|
|
4333
|
+
if (!match[1]) continue;
|
|
4334
|
+
const tag = readOpeningTag(html, match.index, match[1], opening.lastIndex);
|
|
4335
|
+
tags.push(tag);
|
|
4336
|
+
opening.lastIndex = tag.end;
|
|
4337
|
+
if ([
|
|
4338
|
+
"script",
|
|
4339
|
+
"style",
|
|
4340
|
+
"textarea",
|
|
4341
|
+
"title",
|
|
4342
|
+
"xmp",
|
|
4343
|
+
"iframe",
|
|
4344
|
+
"noembed",
|
|
4345
|
+
"noframes",
|
|
4346
|
+
"plaintext"
|
|
4347
|
+
].includes(tag.name)) {
|
|
4348
|
+
if (tag.name === "plaintext") {
|
|
4349
|
+
tag.rawTextEnd = html.length;
|
|
4350
|
+
break;
|
|
4351
|
+
}
|
|
4352
|
+
const closing = new RegExp(`</${tag.name}(?=[\\t\\n\\f\\r />])`, "gi");
|
|
4353
|
+
closing.lastIndex = tag.end;
|
|
4354
|
+
const end = closing.exec(html);
|
|
4355
|
+
tag.rawTextEnd = end?.index ?? html.length;
|
|
4356
|
+
opening.lastIndex = tag.rawTextEnd;
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
return tags;
|
|
4360
|
+
}
|
|
4361
|
+
var HTML_ATTRIBUTE_ENTITIES = {
|
|
4362
|
+
"&": ["&"],
|
|
4363
|
+
'"': ["""],
|
|
4364
|
+
"'": ["'", "'"],
|
|
4365
|
+
"<": ["<"],
|
|
4366
|
+
">": [">"]
|
|
4367
|
+
};
|
|
4368
|
+
function decodeAuthoredAttribute(value) {
|
|
4369
|
+
return decodeHTMLAttribute(value);
|
|
4370
|
+
}
|
|
4255
4371
|
export {
|
|
4256
4372
|
CANONICAL_AUTHORED_TIMING_ATTRIBUTES,
|
|
4257
4373
|
CANONICAL_FONT_DISPLAY_NAMES,
|
|
@@ -4268,6 +4384,7 @@ export {
|
|
|
4268
4384
|
FONT_ALIAS_KEYS,
|
|
4269
4385
|
FONT_ALIAS_MAP,
|
|
4270
4386
|
GSAP_DEFAULT_DURATION,
|
|
4387
|
+
HTML_ATTRIBUTE_ENTITIES,
|
|
4271
4388
|
HTML_BODY_CSS_HEIGHT_FIRST_RE,
|
|
4272
4389
|
HTML_BODY_CSS_WIDTH_FIRST_RE,
|
|
4273
4390
|
LEGACY_TIMING_ATTRIBUTES,
|
|
@@ -4288,8 +4405,11 @@ export {
|
|
|
4288
4405
|
clampPlaybackRate,
|
|
4289
4406
|
classifyPropertyGroup,
|
|
4290
4407
|
classifyTweenPropertyGroup,
|
|
4408
|
+
decodeAuthoredAttribute,
|
|
4291
4409
|
decodeUrlPathVariants,
|
|
4410
|
+
decodedUrlPath,
|
|
4292
4411
|
editabilityForProvenance,
|
|
4412
|
+
encodeUrlPath,
|
|
4293
4413
|
ensureHfIds,
|
|
4294
4414
|
extractCompositionMetadata,
|
|
4295
4415
|
extractMediaSrcMutations,
|
|
@@ -4328,6 +4448,7 @@ export {
|
|
|
4328
4448
|
resolveNaturalDurationSeconds,
|
|
4329
4449
|
resolveResolutionFlagPair,
|
|
4330
4450
|
resolveSubCompositionContent,
|
|
4451
|
+
scanHtmlOpeningTags,
|
|
4331
4452
|
scanVariableUsage,
|
|
4332
4453
|
serializeGsapAnimations,
|
|
4333
4454
|
suggestMatchingPreset,
|