@hyperframes/parsers 0.8.65 → 0.8.66

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
@@ -6,7 +6,7 @@ export { PROPERTY_GROUPS, PropertyGroupName, SUPPORTED_EASES, SUPPORTED_PROPS, c
6
6
  export { SPRING_PRESETS, SpringPreset, generateSpringEaseData } from './springEase.js';
7
7
  export { parseGsapScriptAcorn as parseGsapScript } from './gsapParserAcorn.js';
8
8
  export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, mintHfId, walkCompositionDescendants } from './hfIds.js';
9
- export { ParsableDocumentLike, SubCompositionValidity, SubCompositionValidityReason, checkSubCompositionUsability } from './subCompositionValidity.js';
9
+ export { ParsableDocumentLike, SubCompositionValidity, SubCompositionValidityReason, checkSubCompositionUsability, 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, parseNumeric, parseStartExpression, readClipTiming, writeClipTiming } from './compositionContract.js';
11
11
  export { StructureNode, TrackKind, TrackKindSource, isSubCompositionHost, isTimedElement, topLevelElements, trackKindOf } from './topLevelElements.js';
12
12
  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';
package/dist/index.js CHANGED
@@ -3370,6 +3370,14 @@ function extractGsapScripts(doc) {
3370
3370
  }
3371
3371
 
3372
3372
  // src/subCompositionValidity.ts
3373
+ function resolveSubCompositionContent(html, document) {
3374
+ const template = document.querySelector("template");
3375
+ if (template) return { contentHtml: template.innerHTML ?? "", hasTemplate: true };
3376
+ const body = document.querySelector("body");
3377
+ if (body) return { contentHtml: body.innerHTML ?? "", hasTemplate: false };
3378
+ const contentHtml = document.querySelector("html") ? "" : html;
3379
+ return { contentHtml, hasTemplate: false };
3380
+ }
3373
3381
  function checkSubCompositionUsability(html, parseHtml2) {
3374
3382
  if (html == null || !html.trim()) {
3375
3383
  return {
@@ -3386,8 +3394,7 @@ function checkSubCompositionUsability(html, parseHtml2) {
3386
3394
  detail: "the file's contents could not be parsed as HTML"
3387
3395
  };
3388
3396
  }
3389
- const contentRoot = compDoc.querySelector("template");
3390
- const contentHtml = contentRoot ? contentRoot.innerHTML || "" : compDoc.body?.innerHTML || "";
3397
+ const { contentHtml } = resolveSubCompositionContent(html, compDoc);
3391
3398
  if (!contentHtml.trim()) {
3392
3399
  return {
3393
3400
  ok: false,
@@ -3400,14 +3407,14 @@ function checkSubCompositionUsability(html, parseHtml2) {
3400
3407
  return {
3401
3408
  ok: false,
3402
3409
  reason: "unparsable",
3403
- detail: "the file's <template>/<body> contents could not be parsed as HTML"
3410
+ detail: "the file's resolved contents could not be parsed as HTML"
3404
3411
  };
3405
3412
  }
3406
3413
  if (!contentDoc.querySelector("[data-composition-id]")) {
3407
3414
  return {
3408
3415
  ok: false,
3409
3416
  reason: "no-composition-root",
3410
- detail: "the file's <template>/<body> content has no element with a data-composition-id attribute"
3417
+ detail: "the file's resolved content has no element with a data-composition-id attribute"
3411
3418
  };
3412
3419
  }
3413
3420
  return { ok: true };
@@ -4275,6 +4282,7 @@ export {
4275
4282
  resolveMediaDuration,
4276
4283
  resolveNaturalDurationSeconds,
4277
4284
  resolveResolutionFlagPair,
4285
+ resolveSubCompositionContent,
4278
4286
  scanVariableUsage,
4279
4287
  serializeGsapAnimations,
4280
4288
  suggestMatchingPreset,