@hyperframes/parsers 0.8.48 → 0.8.50

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
@@ -8,6 +8,7 @@ export { parseGsapScriptAcorn as parseGsapScript } from './gsapParserAcorn.js';
8
8
  export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, mintHfId, walkCompositionDescendants } from './hfIds.js';
9
9
  export { ParsableDocumentLike, SubCompositionValidity, SubCompositionValidityReason, checkSubCompositionUsability } 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, parseNumeric, parseStartExpression, readClipTiming, writeClipTiming } from './compositionContract.js';
11
+ export { StructureNode, TrackKind, TrackKindSource, isSubCompositionHost, isTimedElement, topLevelElements, trackKindOf } from './topLevelElements.js';
11
12
  export { CANONICAL_FONT_DISPLAY_NAMES, FONT_ALIAS_KEYS, FONT_ALIAS_MAP, VariableUsageScan, decodeUrlPathVariants, parseCompositionVariables, resolveAliasDisplayName, scanVariableUsage } from './composition.js';
12
13
 
13
14
  /**
package/dist/index.js CHANGED
@@ -3526,6 +3526,40 @@ var HTML_BODY_CSS_WIDTH_FIRST_RE = /(html\s*,\s*body\s*\{[^}]*?width:\s*)(\d+)px
3526
3526
  var HTML_BODY_CSS_HEIGHT_FIRST_RE = /(html\s*,\s*body\s*\{[^}]*?height:\s*)(\d+)px([^}]*?width:\s*)(\d+)px/i;
3527
3527
  var VIEWPORT_META_SIZE_RE = /(<meta[^>]*name=["']viewport["'][^>]*content=["']width=)(\d+)(,\s*height=)(\d+)/i;
3528
3528
 
3529
+ // src/topLevelElements.ts
3530
+ var NON_RENDERED_TAGS = /* @__PURE__ */ new Set(["script", "style", "template", "noscript", "link", "meta"]);
3531
+ var MEDIA_TAGS = /* @__PURE__ */ new Set(["video", "audio", "img"]);
3532
+ var TRACK_KINDS = ["video", "audio", "captions", "graphics"];
3533
+ function isSubCompositionHost(node) {
3534
+ return node.attrs["data-composition-src"] !== void 0 || node.attrs["data-composition-id"] !== void 0;
3535
+ }
3536
+ function isTimedElement(node) {
3537
+ const { attrs } = node;
3538
+ return attrs["data-start"] !== void 0 || attrs["data-track-index"] !== void 0 && attrs["data-duration"] !== void 0 || MEDIA_TAGS.has(node.tag.toLowerCase());
3539
+ }
3540
+ function topLevelElements(root) {
3541
+ const rows = [];
3542
+ const visit = (node) => {
3543
+ if (NON_RENDERED_TAGS.has(node.tag.toLowerCase())) return;
3544
+ if (isSubCompositionHost(node) || isTimedElement(node)) rows.push(node);
3545
+ else node.children.forEach(visit);
3546
+ };
3547
+ root.children.forEach(visit);
3548
+ return rows;
3549
+ }
3550
+ function trackKindOf(node) {
3551
+ const explicit = node.attrs["data-track-kind"]?.trim().toLowerCase();
3552
+ if (explicit && TRACK_KINDS.includes(explicit))
3553
+ return { kind: explicit, source: "attribute" };
3554
+ const tag = node.tag.toLowerCase();
3555
+ if (tag === "video" || tag === "audio") return { kind: tag, source: "tag" };
3556
+ if (isSubCompositionHost(node)) {
3557
+ const legacy = node.attrs["data-composition-id"] === "captions" || /(?:^|\s)caption[-_]/.test(node.attrs.class ?? "");
3558
+ return legacy ? { kind: "captions", source: "legacy-captions" } : { kind: "graphics", source: "sub-composition" };
3559
+ }
3560
+ return { kind: "graphics", source: "tag" };
3561
+ }
3562
+
3529
3563
  // src/utils/urlPath.ts
3530
3564
  function decodeUrlPathVariants(path) {
3531
3565
  const variants = [path];
@@ -3863,7 +3897,9 @@ export {
3863
3897
  isCompositionTemplate,
3864
3898
  isMediaElement,
3865
3899
  isStudioHoldSet,
3900
+ isSubCompositionHost,
3866
3901
  isTextElement,
3902
+ isTimedElement,
3867
3903
  keyframesToGsapAnimations,
3868
3904
  mintHfId,
3869
3905
  normalizeResolutionFlag,
@@ -3881,6 +3917,8 @@ export {
3881
3917
  scanVariableUsage,
3882
3918
  serializeGsapAnimations,
3883
3919
  suggestMatchingPreset,
3920
+ topLevelElements,
3921
+ trackKindOf,
3884
3922
  unrollComputedTimeline,
3885
3923
  updateElementInHtml,
3886
3924
  validateCompositionGsap,