@hyperframes/core 0.8.225 → 0.8.226

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 @@ export type AudioClockSource = {
14
14
  rate?: RateSpec;
15
15
  } | {
16
16
  currentTimeSeconds: number;
17
+ webAudio?: boolean;
17
18
  };
18
19
  export declare class TransportClock {
19
20
  private _baseTime;
@@ -57,6 +58,7 @@ export declare class TransportClock {
57
58
  audioElement(): HTMLMediaElement | null;
58
59
  hasAudioSource(): boolean;
59
60
  getSource(): "monotonic" | "audio";
61
+ followedClock(): "audio" | "webaudio" | "monotonic";
60
62
  snapshot(): TransportClockSnapshot;
61
63
  reachedEnd(): boolean;
62
64
  }
@@ -182,6 +182,13 @@ export class TransportClock {
182
182
  }
183
183
  return "monotonic";
184
184
  }
185
+ followedClock() {
186
+ if (this.getSource() === "monotonic")
187
+ return "monotonic";
188
+ return this._audioSource && "webAudio" in this._audioSource && this._audioSource.webAudio
189
+ ? "webaudio"
190
+ : "audio";
191
+ }
185
192
  snapshot() {
186
193
  return {
187
194
  time: this.now(),
@@ -1,3 +1,4 @@
1
1
  export declare const MEDIA_ELEMENT_LEAD_SECONDS = 0.00001;
2
2
  export declare function mediaElementTime(sourceSeconds: number): number;
3
3
  export declare function startsSoundOnlyInsideATap(): boolean;
4
+ export declare function isWebKit(): boolean;
@@ -6,3 +6,7 @@ export function startsSoundOnlyInsideATap() {
6
6
  const { userAgent, maxTouchPoints } = navigator;
7
7
  return /iP(hone|ad|od)/.test(userAgent) || (/Macintosh/.test(userAgent) && maxTouchPoints > 1);
8
8
  }
9
+ export function isWebKit() {
10
+ const { userAgent } = navigator;
11
+ return /AppleWebKit/.test(userAgent) && !/Chrom(e|ium)\/|Edg\/|Android/.test(userAgent);
12
+ }
@@ -1,3 +1,4 @@
1
+ import { isWebKit } from "./mediaClock.js";
1
2
  /** Drift a playing element may carry before sync pulls it back onto the playhead. */
2
3
  export const MEDIA_SYNC_TOLERANCE_SECONDS = 0.04;
3
4
  export const MEDIA_HARD_SYNC_SECONDS = 0.5;
@@ -11,6 +12,7 @@ const MEDIA_STEER_RELEASE_SECONDS = 0.01;
11
12
  // Audio never steers past 10%, where speech changes tempo; a lag held past 100 ms is seeked instead.
12
13
  const AUDIO_MAX_STEER = 0.1;
13
14
  const AUDIO_STEER_LIMIT_SECONDS = 0.1;
15
+ const WEBKIT_AUDIO_START_LAG_SECONDS = 0.65;
14
16
  /** Direction (+1 fast, -1 slow) an element is being steered in; absent when it plays at its authored rate. */
15
17
  const steering = new WeakMap();
16
18
  /** Started or seeked, not yet moving in tolerance: its lag is its own output latency, which a seek only renews. */
@@ -21,6 +23,10 @@ export function markMediaRestarted(el) {
21
23
  /** Rate or seek for media `offset` s behind (+) or ahead (-); a lag still growing (`settled` false) never seeks. */
22
24
  export function steerMedia(el, offset, baseRate, settled, audioOnly = el.tagName === "AUDIO") {
23
25
  const lag = Math.abs(offset);
26
+ if (audioOnly && isWebKit()) {
27
+ steering.delete(el);
28
+ return { rate: baseRate, seek: settled && lag > WEBKIT_AUDIO_START_LAG_SECONDS };
29
+ }
24
30
  if (settled && lag <= MEDIA_SYNC_TOLERANCE_SECONDS)
25
31
  catchingUp.delete(el);
26
32
  const seekable = !catchingUp.has(el) || lag > MEDIA_HARD_SYNC_SECONDS;
@@ -243,6 +243,7 @@ export type RuntimePreviewHealthMessage = {
243
243
  frozenShare: number;
244
244
  gapP50Ms: number;
245
245
  gapP95Ms: number;
246
+ clockSource: "audio" | "webaudio" | "monotonic";
246
247
  mode: "play";
247
248
  } | null;
248
249
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.8.225",
3
+ "version": "0.8.226",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -429,9 +429,9 @@
429
429
  "linkedom": "^0.18.12",
430
430
  "postcss": "^8.5.8",
431
431
  "wawoff2": "^2.0.1",
432
- "@hyperframes/lint": "0.8.225",
433
- "@hyperframes/studio-server": "0.8.225",
434
- "@hyperframes/parsers": "0.8.225"
432
+ "@hyperframes/lint": "0.8.226",
433
+ "@hyperframes/parsers": "0.8.226",
434
+ "@hyperframes/studio-server": "0.8.226"
435
435
  },
436
436
  "devDependencies": {
437
437
  "@fontsource/archivo-black": "^5.2.8",