@hyperframes/parsers 0.8.81 → 0.8.83

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.
@@ -14,6 +14,7 @@ interface ResolveCompositionDurationInput {
14
14
  /** Each clip's end on the composition timeline, or null while its length is pending. */
15
15
  clipEndsSeconds: readonly (number | null)[];
16
16
  }
17
+ declare const TIMING_TOLERANCE_SECONDS = 0.05;
17
18
  declare function resolveCompositionDuration(input: ResolveCompositionDurationInput): CompositionDurationResult;
18
19
 
19
- export { type CompositionDurationResult, type CompositionDurationSource, type ResolveCompositionDurationInput, resolveCompositionDuration };
20
+ export { type CompositionDurationResult, type CompositionDurationSource, type ResolveCompositionDurationInput, TIMING_TOLERANCE_SECONDS, resolveCompositionDuration };
@@ -1,4 +1,5 @@
1
1
  // src/compositionDuration.ts
2
+ var TIMING_TOLERANCE_SECONDS = 0.05;
2
3
  var isPositiveFinite = (value) => value !== null && Number.isFinite(value) && value > 0;
3
4
  function resolveCompositionDuration(input) {
4
5
  const pendingClips = input.clipEndsSeconds.filter((end) => end === null).length;
@@ -17,6 +18,7 @@ function resolveCompositionDuration(input) {
17
18
  };
18
19
  }
19
20
  export {
21
+ TIMING_TOLERANCE_SECONDS,
20
22
  resolveCompositionDuration
21
23
  };
22
24
  //# sourceMappingURL=compositionDuration.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compositionDuration.ts"],"sourcesContent":["/** How long a composition is when nothing runs it: its authored `data-duration`, else the latest\n * end among its clips. A clip whose length is not known yet is counted, never guessed. */\n\nexport type CompositionDurationSource = \"authored\" | \"derived\" | \"unresolved\";\n\nexport interface CompositionDurationResult {\n seconds: number | null;\n source: CompositionDurationSource;\n /** Clips whose end is not known yet; a `derived` length is a lower bound while this is above 0. */\n pendingClips: number;\n /** Set only when source is \"unresolved\". */\n reason?: string;\n}\n\nexport interface ResolveCompositionDurationInput {\n authoredDurationSeconds: number | null;\n /** Each clip's end on the composition timeline, or null while its length is pending. */\n clipEndsSeconds: readonly (number | null)[];\n}\n\nconst isPositiveFinite = (value: number | null): value is number =>\n value !== null && Number.isFinite(value) && value > 0;\n\nexport function resolveCompositionDuration(\n input: ResolveCompositionDurationInput,\n): CompositionDurationResult {\n const pendingClips = input.clipEndsSeconds.filter((end) => end === null).length;\n if (isPositiveFinite(input.authoredDurationSeconds)) {\n return { seconds: input.authoredDurationSeconds, source: \"authored\", pendingClips };\n }\n const known = input.clipEndsSeconds.filter(isPositiveFinite);\n if (known.length > 0) {\n return { seconds: Math.max(...known), source: \"derived\", pendingClips };\n }\n return {\n seconds: null,\n source: \"unresolved\",\n pendingClips,\n reason:\n pendingClips > 0\n ? \"every clip's length is still pending\"\n : \"no authored duration and no clip with a length\",\n };\n}\n"],"mappings":";AAoBA,IAAM,mBAAmB,CAAC,UACxB,UAAU,QAAQ,OAAO,SAAS,KAAK,KAAK,QAAQ;AAE/C,SAAS,2BACd,OAC2B;AAC3B,QAAM,eAAe,MAAM,gBAAgB,OAAO,CAAC,QAAQ,QAAQ,IAAI,EAAE;AACzE,MAAI,iBAAiB,MAAM,uBAAuB,GAAG;AACnD,WAAO,EAAE,SAAS,MAAM,yBAAyB,QAAQ,YAAY,aAAa;AAAA,EACpF;AACA,QAAM,QAAQ,MAAM,gBAAgB,OAAO,gBAAgB;AAC3D,MAAI,MAAM,SAAS,GAAG;AACpB,WAAO,EAAE,SAAS,KAAK,IAAI,GAAG,KAAK,GAAG,QAAQ,WAAW,aAAa;AAAA,EACxE;AACA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR;AAAA,IACA,QACE,eAAe,IACX,yCACA;AAAA,EACR;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/compositionDuration.ts"],"sourcesContent":["/** How long a composition is when nothing runs it: its authored `data-duration`, else the latest\n * end among its clips. A clip whose length is not known yet is counted, never guessed. */\n\nexport type CompositionDurationSource = \"authored\" | \"derived\" | \"unresolved\";\n\nexport interface CompositionDurationResult {\n seconds: number | null;\n source: CompositionDurationSource;\n /** Clips whose end is not known yet; a `derived` length is a lower bound while this is above 0. */\n pendingClips: number;\n /** Set only when source is \"unresolved\". */\n reason?: string;\n}\n\nexport interface ResolveCompositionDurationInput {\n authoredDurationSeconds: number | null;\n /** Each clip's end on the composition timeline, or null while its length is pending. */\n clipEndsSeconds: readonly (number | null)[];\n}\n\nexport const TIMING_TOLERANCE_SECONDS = 0.05;\n\nconst isPositiveFinite = (value: number | null): value is number =>\n value !== null && Number.isFinite(value) && value > 0;\n\nexport function resolveCompositionDuration(\n input: ResolveCompositionDurationInput,\n): CompositionDurationResult {\n const pendingClips = input.clipEndsSeconds.filter((end) => end === null).length;\n if (isPositiveFinite(input.authoredDurationSeconds)) {\n return { seconds: input.authoredDurationSeconds, source: \"authored\", pendingClips };\n }\n const known = input.clipEndsSeconds.filter(isPositiveFinite);\n if (known.length > 0) {\n return { seconds: Math.max(...known), source: \"derived\", pendingClips };\n }\n return {\n seconds: null,\n source: \"unresolved\",\n pendingClips,\n reason:\n pendingClips > 0\n ? \"every clip's length is still pending\"\n : \"no authored duration and no clip with a length\",\n };\n}\n"],"mappings":";AAoBO,IAAM,2BAA2B;AAExC,IAAM,mBAAmB,CAAC,UACxB,UAAU,QAAQ,OAAO,SAAS,KAAK,KAAK,QAAQ;AAE/C,SAAS,2BACd,OAC2B;AAC3B,QAAM,eAAe,MAAM,gBAAgB,OAAO,CAAC,QAAQ,QAAQ,IAAI,EAAE;AACzE,MAAI,iBAAiB,MAAM,uBAAuB,GAAG;AACnD,WAAO,EAAE,SAAS,MAAM,yBAAyB,QAAQ,YAAY,aAAa;AAAA,EACpF;AACA,QAAM,QAAQ,MAAM,gBAAgB,OAAO,gBAAgB;AAC3D,MAAI,MAAM,SAAS,GAAG;AACpB,WAAO,EAAE,SAAS,KAAK,IAAI,GAAG,KAAK,GAAG,QAAQ,WAAW,aAAa;AAAA,EACxE;AACA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR;AAAA,IACA,QACE,eAAe,IACX,yCACA;AAAA,EACR;AACF;","names":[]}
@@ -1400,7 +1400,10 @@ function findStatementPath(path) {
1400
1400
  }
1401
1401
  function insertAfterAnchor(parsed, newStatement) {
1402
1402
  const lastCall = parsed.located[parsed.located.length - 1]?.call;
1403
- const anchorPath = lastCall ? findStatementPath(lastCall.path) : findTimelineDeclarationPath(parsed.ast, parsed.timelineVar);
1403
+ const lastPath = lastCall ? findStatementPath(lastCall.path) : null;
1404
+ const timeline = findTimelineDeclarationPath(parsed.ast, parsed.timelineVar);
1405
+ const beforeTimeline = !!timeline && !!lastPath && lastPath.node.start < timeline.node.start;
1406
+ const anchorPath = !lastCall || beforeTimeline ? timeline : lastPath;
1404
1407
  if (anchorPath) {
1405
1408
  anchorPath.insertAfter(newStatement);
1406
1409
  } else {